From e14de72a1fff23afb0068abf7282704a90233d8c Mon Sep 17 00:00:00 2001 From: faneaatiku Date: Thu, 14 Mar 2024 01:16:32 +0200 Subject: [PATCH 01/35] cleanup tradebin keeper dependencies --- app/app.go | 1 - testutil/keeper/tradebin.go | 1 - testutil/simapp/app.go | 1 - x/tradebin/keeper/keeper.go | 20 ++++++++++---------- x/tradebin/types/expected_keepers.go | 10 ---------- 5 files changed, 10 insertions(+), 23 deletions(-) diff --git a/app/app.go b/app/app.go index 90ed2ace..7deda9c4 100644 --- a/app/app.go +++ b/app/app.go @@ -450,7 +450,6 @@ func New( keys[tradebintypes.MemStoreKey], app.GetSubspace(tradebintypes.ModuleName), app.BankKeeper, - app.AccountKeeper, app.DistrKeeper, ) diff --git a/testutil/keeper/tradebin.go b/testutil/keeper/tradebin.go index 112a3fe3..fea12fbe 100644 --- a/testutil/keeper/tradebin.go +++ b/testutil/keeper/tradebin.go @@ -43,7 +43,6 @@ func TradebinKeeper(t testing.TB) (*keeper.Keeper, sdk.Context) { paramsSubspace, nil, nil, - nil, ) ctx := sdk.NewContext(stateStore, tmproto.Header{}, false, log.NewNopLogger()) diff --git a/testutil/simapp/app.go b/testutil/simapp/app.go index 3b7460f9..35ca8e05 100644 --- a/testutil/simapp/app.go +++ b/testutil/simapp/app.go @@ -450,7 +450,6 @@ func New( keys[tradebintypes.MemStoreKey], app.GetSubspace(tradebintypes.ModuleName), app.BankKeeper, - app.AccountKeeper, app.DistrKeeper, ) diff --git a/x/tradebin/keeper/keeper.go b/x/tradebin/keeper/keeper.go index d94feb3a..b6c376e9 100644 --- a/x/tradebin/keeper/keeper.go +++ b/x/tradebin/keeper/keeper.go @@ -18,9 +18,8 @@ type ( memKey sdk.StoreKey paramstore paramtypes.Subspace - bankKeeper types.BankKeeper - accountKeeper types.AccountKeeper - distrKeeper types.DistrKeeper + bankKeeper types.BankKeeper + distrKeeper types.DistrKeeper } ) @@ -29,8 +28,8 @@ func NewKeeper( storeKey, memKey sdk.StoreKey, ps paramtypes.Subspace, - - bankKeeper types.BankKeeper, accountKeeper types.AccountKeeper, distrKeeper types.DistrKeeper, + bankKeeper types.BankKeeper, + distrKeeper types.DistrKeeper, ) *Keeper { // set KeyTable if it has not already been set if !ps.HasKeyTable() { @@ -39,11 +38,12 @@ func NewKeeper( return &Keeper{ - cdc: cdc, - storeKey: storeKey, - memKey: memKey, - paramstore: ps, - bankKeeper: bankKeeper, accountKeeper: accountKeeper, distrKeeper: distrKeeper, + cdc: cdc, + storeKey: storeKey, + memKey: memKey, + paramstore: ps, + bankKeeper: bankKeeper, + distrKeeper: distrKeeper, } } diff --git a/x/tradebin/types/expected_keepers.go b/x/tradebin/types/expected_keepers.go index 5113518f..c6520621 100644 --- a/x/tradebin/types/expected_keepers.go +++ b/x/tradebin/types/expected_keepers.go @@ -2,24 +2,14 @@ package types import ( sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/x/auth/types" - banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" ) type DistrKeeper interface { FundCommunityPool(ctx sdk.Context, amount sdk.Coins, sender sdk.AccAddress) error } -// AccountKeeper defines the expected account keeper used for simulations (noalias) -type AccountKeeper interface { - GetAccount(ctx sdk.Context, addr sdk.AccAddress) types.AccountI - // Methods imported from account should be defined here -} - // BankKeeper defines the expected interface needed to retrieve account balances. type BankKeeper interface { - SpendableCoins(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins - GetDenomMetaData(ctx sdk.Context, denom string) (banktypes.Metadata, bool) HasSupply(ctx sdk.Context, denom string) bool SendCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error SendCoinsFromModuleToAccount(ctx sdk.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error From 53404dac1158063656155d2172e6afa2f2fa0802 Mon Sep 17 00:00:00 2001 From: faneaatiku Date: Thu, 14 Mar 2024 01:44:19 +0200 Subject: [PATCH 02/35] created rewards module --- app/app.go | 26 +- docs/static/openapi.yml | 61 + proto/rewards/genesis.proto | 14 + proto/rewards/params.proto | 14 + proto/rewards/query.proto | 30 + proto/rewards/tx.proto | 13 + testutil/keeper/rewards.go | 54 + testutil/simapp/app.go | 2 +- .../bze-alphateam/bze/bze.v1.rewards/index.ts | 141 + .../bze/bze.v1.rewards/module/index.ts | 57 + .../bze/bze.v1.rewards/module/rest.ts | 250 + .../cosmos/base/query/v1beta1/pagination.ts | 328 + .../module/types/gogoproto/gogo.ts | 2 + .../module/types/google/api/annotations.ts | 2 + .../module/types/google/api/http.ts | 706 +++ .../types/google/protobuf/descriptor.ts | 5314 +++++++++++++++++ .../module/types/rewards/genesis.ts | 78 + .../module/types/rewards/params.ts | 110 + .../module/types/rewards/query.ts | 148 + .../bze.v1.rewards/module/types/rewards/tx.ts | 20 + .../bze/bze.v1.rewards/package.json | 18 + .../bze/bze.v1.rewards/vuex-root | 1 + .../bze/bzealphateam.bze.rewards/index.ts | 141 + .../bzealphateam.bze.rewards/module/index.ts | 57 + .../bzealphateam.bze.rewards/module/rest.ts | 250 + .../cosmos/base/query/v1beta1/pagination.ts | 328 + .../module/types/gogoproto/gogo.ts | 2 + .../module/types/google/api/annotations.ts | 2 + .../module/types/google/api/http.ts | 706 +++ .../types/google/protobuf/descriptor.ts | 5314 +++++++++++++++++ .../module/types/rewards/genesis.ts | 78 + .../module/types/rewards/params.ts | 110 + .../module/types/rewards/query.ts | 152 + .../module/types/rewards/tx.ts | 20 + .../bze/bzealphateam.bze.rewards/package.json | 18 + .../bze/bzealphateam.bze.rewards/vuex-root | 1 + vue/src/store/generated/index.ts | 4 + x/rewards/client/cli/query.go | 31 + x/rewards/client/cli/query_params.go | 34 + x/rewards/client/cli/tx.go | 36 + x/rewards/genesis.go | 24 + x/rewards/genesis_test.go | 29 + x/rewards/handler.go | 26 + x/rewards/keeper/grpc_query.go | 7 + x/rewards/keeper/grpc_query_params.go | 19 + x/rewards/keeper/grpc_query_params_test.go | 21 + x/rewards/keeper/keeper.go | 51 + x/rewards/keeper/msg_server.go | 17 + x/rewards/keeper/msg_server_test.go | 16 + x/rewards/keeper/params.go | 31 + x/rewards/keeper/params_test.go | 20 + x/rewards/module.go | 177 + x/rewards/module_simulation.go | 71 + x/rewards/simulation/simap.go | 15 + x/rewards/types/codec.go | 23 + x/rewards/types/errors.go | 12 + x/rewards/types/expected_keepers.go | 22 + x/rewards/types/genesis.go | 20 + x/rewards/types/genesis.pb.go | 321 + x/rewards/types/genesis_test.go | 40 + x/rewards/types/keys.go | 22 + x/rewards/types/params.go | 97 + x/rewards/types/params.pb.go | 371 ++ x/rewards/types/query.pb.go | 538 ++ x/rewards/types/query.pb.gw.go | 153 + x/rewards/types/tx.pb.go | 80 + x/rewards/types/types.go | 1 + x/tradebin/module.go | 7 +- x/tradebin/module_simulation.go | 6 +- x/tradebin/simulation/cancel_order.go | 1 - x/tradebin/simulation/create_market.go | 1 - x/tradebin/simulation/create_order.go | 1 - 72 files changed, 16899 insertions(+), 14 deletions(-) create mode 100644 proto/rewards/genesis.proto create mode 100644 proto/rewards/params.proto create mode 100644 proto/rewards/query.proto create mode 100644 proto/rewards/tx.proto create mode 100644 testutil/keeper/rewards.go create mode 100755 vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/index.ts create mode 100755 vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/index.ts create mode 100644 vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/rest.ts create mode 100644 vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/cosmos/base/query/v1beta1/pagination.ts create mode 100644 vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/gogoproto/gogo.ts create mode 100644 vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/google/api/annotations.ts create mode 100644 vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/google/api/http.ts create mode 100644 vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/google/protobuf/descriptor.ts create mode 100644 vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/genesis.ts create mode 100644 vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/params.ts create mode 100644 vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/query.ts create mode 100644 vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/tx.ts create mode 100755 vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/package.json create mode 100755 vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/vuex-root create mode 100755 vue/src/store/generated/bze-alphateam/bze/bzealphateam.bze.rewards/index.ts create mode 100755 vue/src/store/generated/bze-alphateam/bze/bzealphateam.bze.rewards/module/index.ts create mode 100644 vue/src/store/generated/bze-alphateam/bze/bzealphateam.bze.rewards/module/rest.ts create mode 100644 vue/src/store/generated/bze-alphateam/bze/bzealphateam.bze.rewards/module/types/cosmos/base/query/v1beta1/pagination.ts create mode 100644 vue/src/store/generated/bze-alphateam/bze/bzealphateam.bze.rewards/module/types/gogoproto/gogo.ts create mode 100644 vue/src/store/generated/bze-alphateam/bze/bzealphateam.bze.rewards/module/types/google/api/annotations.ts create mode 100644 vue/src/store/generated/bze-alphateam/bze/bzealphateam.bze.rewards/module/types/google/api/http.ts create mode 100644 vue/src/store/generated/bze-alphateam/bze/bzealphateam.bze.rewards/module/types/google/protobuf/descriptor.ts create mode 100644 vue/src/store/generated/bze-alphateam/bze/bzealphateam.bze.rewards/module/types/rewards/genesis.ts create mode 100644 vue/src/store/generated/bze-alphateam/bze/bzealphateam.bze.rewards/module/types/rewards/params.ts create mode 100644 vue/src/store/generated/bze-alphateam/bze/bzealphateam.bze.rewards/module/types/rewards/query.ts create mode 100644 vue/src/store/generated/bze-alphateam/bze/bzealphateam.bze.rewards/module/types/rewards/tx.ts create mode 100755 vue/src/store/generated/bze-alphateam/bze/bzealphateam.bze.rewards/package.json create mode 100755 vue/src/store/generated/bze-alphateam/bze/bzealphateam.bze.rewards/vuex-root create mode 100644 x/rewards/client/cli/query.go create mode 100644 x/rewards/client/cli/query_params.go create mode 100644 x/rewards/client/cli/tx.go create mode 100644 x/rewards/genesis.go create mode 100644 x/rewards/genesis_test.go create mode 100644 x/rewards/handler.go create mode 100644 x/rewards/keeper/grpc_query.go create mode 100644 x/rewards/keeper/grpc_query_params.go create mode 100644 x/rewards/keeper/grpc_query_params_test.go create mode 100644 x/rewards/keeper/keeper.go create mode 100644 x/rewards/keeper/msg_server.go create mode 100644 x/rewards/keeper/msg_server_test.go create mode 100644 x/rewards/keeper/params.go create mode 100644 x/rewards/keeper/params_test.go create mode 100644 x/rewards/module.go create mode 100644 x/rewards/module_simulation.go create mode 100644 x/rewards/simulation/simap.go create mode 100644 x/rewards/types/codec.go create mode 100644 x/rewards/types/errors.go create mode 100644 x/rewards/types/expected_keepers.go create mode 100644 x/rewards/types/genesis.go create mode 100644 x/rewards/types/genesis.pb.go create mode 100644 x/rewards/types/genesis_test.go create mode 100644 x/rewards/types/keys.go create mode 100644 x/rewards/types/params.go create mode 100644 x/rewards/types/params.pb.go create mode 100644 x/rewards/types/query.pb.go create mode 100644 x/rewards/types/query.pb.gw.go create mode 100644 x/rewards/types/tx.pb.go create mode 100644 x/rewards/types/types.go diff --git a/app/app.go b/app/app.go index 7deda9c4..feebcf65 100644 --- a/app/app.go +++ b/app/app.go @@ -6,6 +6,9 @@ import ( "github.com/bze-alphateam/bze/x/epochs" epochskeeper "github.com/bze-alphateam/bze/x/epochs/keeper" epochstypes "github.com/bze-alphateam/bze/x/epochs/types" + "github.com/bze-alphateam/bze/x/rewards" + rewardskeeper "github.com/bze-alphateam/bze/x/rewards/keeper" + rewardstypes "github.com/bze-alphateam/bze/x/rewards/types" "github.com/bze-alphateam/bze/x/tradebin" tradebinkeeper "github.com/bze-alphateam/bze/x/tradebin/keeper" tradebintypes "github.com/bze-alphateam/bze/x/tradebin/types" @@ -178,6 +181,7 @@ var ( tokenfactory.AppModuleBasic{}, tradebin.AppModuleBasic{}, epochs.AppModuleBasic{}, + rewards.AppModuleBasic{}, // this line is used by starport scaffolding # stargate/app/moduleBasic ) @@ -196,6 +200,7 @@ var ( tokenfactorytypes.ModuleName: {authtypes.Minter, authtypes.Burner}, tradebintypes.ModuleName: nil, epochstypes.ModuleName: nil, + rewardstypes.ModuleName: nil, // this line is used by starport scaffolding # stargate/app/maccPerms } @@ -264,6 +269,7 @@ type App struct { TokenFactoryKeeper tokenfactorykeeper.Keeper TradebinKeeper tradebinkeeper.Keeper EpochsKeeper epochskeeper.Keeper + RewardsKeeper rewardskeeper.Keeper // this line is used by starport scaffolding # stargate/app/keeperDeclaration // the module manager @@ -314,6 +320,7 @@ func New( tokenfactorytypes.StoreKey, tradebintypes.StoreKey, epochstypes.StoreKey, + rewardstypes.StoreKey, // this line is used by starport scaffolding # stargate/app/storeKey ) tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey) @@ -460,12 +467,22 @@ func New( nil, //no hooks registered ) + app.RewardsKeeper = *rewardskeeper.NewKeeper( + appCodec, + keys[rewardstypes.StoreKey], + keys[rewardstypes.MemStoreKey], + app.GetSubspace(rewardstypes.ModuleName), + app.BankKeeper, + app.DistrKeeper, + ) + scavengeModule := scavengemodule.NewAppModule(appCodec, app.ScavengeKeeper) cointrunkModule := cointrunkmodule.NewAppModule(appCodec, app.CointrunkKeeper, app.AccountKeeper, app.BankKeeper, app.DistrKeeper) burnerModule := burnermodule.NewAppModule(appCodec, app.BurnerKeeper, app.AccountKeeper, app.BankKeeper) tokenfactoryModule := tokenfactory.NewAppModule(appCodec, app.TokenFactoryKeeper, app.AccountKeeper, app.BankKeeper) - tradebinModule := tradebin.NewAppModule(appCodec, app.TradebinKeeper, app.AccountKeeper, app.BankKeeper) + tradebinModule := tradebin.NewAppModule(appCodec, app.TradebinKeeper, app.BankKeeper) epochsModule := epochs.NewAppModule(appCodec, app.EpochsKeeper) + rewardsModule := rewards.NewAppModule(appCodec, app.RewardsKeeper, app.AccountKeeper, app.BankKeeper) // this line is used by starport scaffolding # stargate/app/keeperDefinition // register the proposal types @@ -527,6 +544,7 @@ func New( tokenfactoryModule, tradebinModule, epochsModule, + rewardsModule, // this line is used by starport scaffolding # stargate/app/appModule ) @@ -559,6 +577,7 @@ func New( tokenfactorytypes.ModuleName, tradebintypes.ModuleName, epochstypes.ModuleName, + rewardstypes.ModuleName, ) app.mm.SetOrderEndBlockers( @@ -586,6 +605,7 @@ func New( tokenfactorytypes.ModuleName, tradebintypes.ModuleName, epochstypes.ModuleName, + rewardstypes.ModuleName, ) // NOTE: The genutils module must occur after staking so that pools are @@ -618,6 +638,7 @@ func New( tokenfactorytypes.ModuleName, tradebintypes.ModuleName, epochstypes.ModuleName, + rewardstypes.ModuleName, // this line is used by starport scaffolding # stargate/app/initGenesis ) @@ -682,7 +703,7 @@ func (app *App) setupUpgradeHandlers() { if upgradeInfo.Name == v700.UpgradeName { storeUpgrades := storetypes.StoreUpgrades{ - Added: []string{tokenfactorytypes.StoreKey, tradebintypes.StoreKey, epochstypes.StoreKey}, + Added: []string{tokenfactorytypes.StoreKey, tradebintypes.StoreKey, epochstypes.StoreKey, rewardstypes.StoreKey}, } // configure store loader that checks if version == upgradeHeight and applies store upgrades @@ -837,6 +858,7 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino paramsKeeper.Subspace(burnermoduletypes.ModuleName) paramsKeeper.Subspace(tokenfactorytypes.ModuleName) paramsKeeper.Subspace(tradebintypes.ModuleName) + paramsKeeper.Subspace(rewardstypes.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 71dd7882..5494fc4c 100644 --- a/docs/static/openapi.yml +++ b/docs/static/openapi.yml @@ -2151,6 +2151,47 @@ paths: type: boolean tags: - Query + /bze/rewards/v1/params: + get: + summary: Parameters queries the parameters of the module. + operationId: BzeV1RewardsParams + responses: + '200': + description: A successful response. + schema: + type: object + properties: + params: + description: params holds all the parameters of this module. + type: object + properties: + createStakingRewardFee: + type: string + createTradingRewardFee: + type: string + 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 /cosmos/auth/v1beta1/accounts: get: summary: Accounts returns all the existing accounts @@ -33920,6 +33961,26 @@ definitions: repeated Bar results = 1; PageResponse page = 2; } + bze.v1.rewards.Params: + type: object + properties: + createStakingRewardFee: + type: string + createTradingRewardFee: + type: string + description: Params defines the parameters for the module. + bze.v1.rewards.QueryParamsResponse: + type: object + properties: + params: + description: params holds all the parameters of this module. + type: object + properties: + createStakingRewardFee: + type: string + createTradingRewardFee: + type: string + description: QueryParamsResponse is response type for the Query/Params RPC method. cosmos.auth.v1beta1.Params: type: object properties: diff --git a/proto/rewards/genesis.proto b/proto/rewards/genesis.proto new file mode 100644 index 00000000..e592b6ab --- /dev/null +++ b/proto/rewards/genesis.proto @@ -0,0 +1,14 @@ +syntax = "proto3"; +package bze.v1.rewards; + +import "gogoproto/gogo.proto"; +import "rewards/params.proto"; +// this line is used by starport scaffolding # genesis/proto/import + +option go_package = "github.com/bze-alphateam/bze/x/rewards/types"; + +// GenesisState defines the rewards module's genesis state. +message GenesisState { + Params params = 1 [(gogoproto.nullable) = false]; + // this line is used by starport scaffolding # genesis/proto/state +} diff --git a/proto/rewards/params.proto b/proto/rewards/params.proto new file mode 100644 index 00000000..e1b3435c --- /dev/null +++ b/proto/rewards/params.proto @@ -0,0 +1,14 @@ +syntax = "proto3"; +package bze.v1.rewards; + +import "gogoproto/gogo.proto"; + +option go_package = "github.com/bze-alphateam/bze/x/rewards/types"; + +// Params defines the parameters for the module. +message Params { + option (gogoproto.goproto_stringer) = false; + + string createStakingRewardFee = 1 [(gogoproto.moretags) = "yaml:\"create_staking_reward_fee\""]; + string createTradingRewardFee = 2 [(gogoproto.moretags) = "yaml:\"create_trading_reward_fee\""]; +} diff --git a/proto/rewards/query.proto b/proto/rewards/query.proto new file mode 100644 index 00000000..36bf9fcf --- /dev/null +++ b/proto/rewards/query.proto @@ -0,0 +1,30 @@ +syntax = "proto3"; +package bze.v1.rewards; + +import "gogoproto/gogo.proto"; +import "google/api/annotations.proto"; +import "cosmos/base/query/v1beta1/pagination.proto"; +import "rewards/params.proto"; +// this line is used by starport scaffolding # 1 + +option go_package = "github.com/bze-alphateam/bze/x/rewards/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 = "/bze/rewards/v1/params"; + } + // this line is used by starport scaffolding # 2 +} + +// 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]; +} + +// this line is used by starport scaffolding # 3 diff --git a/proto/rewards/tx.proto b/proto/rewards/tx.proto new file mode 100644 index 00000000..8ddfe6bf --- /dev/null +++ b/proto/rewards/tx.proto @@ -0,0 +1,13 @@ +syntax = "proto3"; +package bze.v1.rewards; + +// this line is used by starport scaffolding # proto/tx/import + +option go_package = "github.com/bze-alphateam/bze/x/rewards/types"; + +// Msg defines the Msg service. +service Msg { + // this line is used by starport scaffolding # proto/tx/rpc +} + +// this line is used by starport scaffolding # proto/tx/message diff --git a/testutil/keeper/rewards.go b/testutil/keeper/rewards.go new file mode 100644 index 00000000..c10a70d9 --- /dev/null +++ b/testutil/keeper/rewards.go @@ -0,0 +1,54 @@ +package keeper + +import ( + "testing" + + "github.com/bze-alphateam/bze/x/rewards/keeper" + "github.com/bze-alphateam/bze/x/rewards/types" + "github.com/cosmos/cosmos-sdk/codec" + codectypes "github.com/cosmos/cosmos-sdk/codec/types" + "github.com/cosmos/cosmos-sdk/store" + storetypes "github.com/cosmos/cosmos-sdk/store/types" + sdk "github.com/cosmos/cosmos-sdk/types" + typesparams "github.com/cosmos/cosmos-sdk/x/params/types" + "github.com/stretchr/testify/require" + "github.com/tendermint/tendermint/libs/log" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" + tmdb "github.com/tendermint/tm-db" +) + +func RewardsKeeper(t testing.TB) (*keeper.Keeper, sdk.Context) { + storeKey := sdk.NewKVStoreKey(types.StoreKey) + memStoreKey := storetypes.NewMemoryStoreKey(types.MemStoreKey) + + db := tmdb.NewMemDB() + stateStore := store.NewCommitMultiStore(db) + stateStore.MountStoreWithDB(storeKey, sdk.StoreTypeIAVL, db) + stateStore.MountStoreWithDB(memStoreKey, sdk.StoreTypeMemory, nil) + require.NoError(t, stateStore.LoadLatestVersion()) + + registry := codectypes.NewInterfaceRegistry() + cdc := codec.NewProtoCodec(registry) + + paramsSubspace := typesparams.NewSubspace(cdc, + types.Amino, + storeKey, + memStoreKey, + "RewardsParams", + ) + k := keeper.NewKeeper( + cdc, + storeKey, + memStoreKey, + paramsSubspace, + nil, + nil, + ) + + ctx := sdk.NewContext(stateStore, tmproto.Header{}, false, log.NewNopLogger()) + + // Initialize params + k.SetParams(ctx, types.DefaultParams()) + + return k, ctx +} diff --git a/testutil/simapp/app.go b/testutil/simapp/app.go index 35ca8e05..55caf10d 100644 --- a/testutil/simapp/app.go +++ b/testutil/simapp/app.go @@ -464,7 +464,7 @@ func New( cointrunkModule := cointrunkmodule.NewAppModule(appCodec, app.CointrunkKeeper, app.AccountKeeper, app.BankKeeper, app.DistrKeeper) burnerModule := burnermodule.NewAppModule(appCodec, app.BurnerKeeper, app.AccountKeeper, app.BankKeeper) tokenfactoryModule := tokenfactory.NewAppModule(appCodec, app.TokenFactoryKeeper, app.AccountKeeper, app.BankKeeper) - tradebinModule := tradebin.NewAppModule(appCodec, app.TradebinKeeper, app.AccountKeeper, app.BankKeeper) + tradebinModule := tradebin.NewAppModule(appCodec, app.TradebinKeeper, app.BankKeeper) epochsModule := epochs.NewAppModule(appCodec, app.EpochsKeeper) // this line is used by starport scaffolding # stargate/app/keeperDefinition diff --git a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/index.ts b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/index.ts new file mode 100755 index 00000000..b921b54f --- /dev/null +++ b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/index.ts @@ -0,0 +1,141 @@ +import { txClient, queryClient, MissingWalletError , registry} from './module' + +import { Params } from "./module/types/rewards/params" + + +export { Params }; + +async function initTxClient(vuexGetters) { + return await txClient(vuexGetters['common/wallet/signer'], { + addr: vuexGetters['common/env/apiTendermint'] + }) +} + +async function initQueryClient(vuexGetters) { + return await queryClient({ + addr: vuexGetters['common/env/apiCosmos'] + }) +} + +function mergeResults(value, next_values) { + for (let prop of Object.keys(next_values)) { + if (Array.isArray(next_values[prop])) { + value[prop]=[...value[prop], ...next_values[prop]] + }else{ + value[prop]=next_values[prop] + } + } + return value +} + +function getStructure(template) { + let structure = { fields: [] } + for (const [key, value] of Object.entries(template)) { + let field: any = {} + field.name = key + field.type = typeof value + structure.fields.push(field) + } + return structure +} + +const getDefaultState = () => { + return { + Params: {}, + + _Structure: { + Params: getStructure(Params.fromPartial({})), + + }, + _Registry: registry, + _Subscriptions: new Set(), + } +} + +// initial state +const state = getDefaultState() + +export default { + namespaced: true, + state, + mutations: { + RESET_STATE(state) { + Object.assign(state, getDefaultState()) + }, + QUERY(state, { query, key, value }) { + state[query][JSON.stringify(key)] = value + }, + SUBSCRIBE(state, subscription) { + state._Subscriptions.add(JSON.stringify(subscription)) + }, + UNSUBSCRIBE(state, subscription) { + state._Subscriptions.delete(JSON.stringify(subscription)) + } + }, + getters: { + getParams: (state) => (params = { params: {}}) => { + if (!( params).query) { + ( params).query=null + } + return state.Params[JSON.stringify(params)] ?? {} + }, + + getTypeStructure: (state) => (type) => { + return state._Structure[type].fields + }, + getRegistry: (state) => { + return state._Registry + } + }, + actions: { + init({ dispatch, rootGetters }) { + console.log('Vuex module: bze.v1.rewards initialized!') + if (rootGetters['common/env/client']) { + rootGetters['common/env/client'].on('newblock', () => { + dispatch('StoreUpdate') + }) + } + }, + resetState({ commit }) { + commit('RESET_STATE') + }, + unsubscribe({ commit }, subscription) { + commit('UNSUBSCRIBE', subscription) + }, + async StoreUpdate({ state, dispatch }) { + state._Subscriptions.forEach(async (subscription) => { + try { + const sub=JSON.parse(subscription) + await dispatch(sub.action, sub.payload) + }catch(e) { + throw new Error('Subscriptions: ' + e.message) + } + }) + }, + + + + + + + async QueryParams({ commit, rootGetters, getters }, { options: { subscribe, all} = { subscribe:false, all:false}, params, query=null }) { + try { + const key = params ?? {}; + const queryClient=await initQueryClient(rootGetters) + let value= (await queryClient.queryParams()).data + + + commit('QUERY', { query: 'Params', key: { params: {...key}, query}, value }) + if (subscribe) commit('SUBSCRIBE', { action: 'QueryParams', payload: { options: { all }, params: {...key},query }}) + return getters['getParams']( { params: {...key}, query}) ?? {} + } catch (e) { + throw new Error('QueryClient:QueryParams API Node Unavailable. Could not perform query: ' + e.message) + + } + }, + + + + + } +} diff --git a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/index.ts b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/index.ts new file mode 100755 index 00000000..67d4b093 --- /dev/null +++ b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/index.ts @@ -0,0 +1,57 @@ +// THIS FILE IS GENERATED AUTOMATICALLY. DO NOT MODIFY. + +import { StdFee } from "@cosmjs/launchpad"; +import { SigningStargateClient } from "@cosmjs/stargate"; +import { Registry, OfflineSigner, EncodeObject, DirectSecp256k1HdWallet } from "@cosmjs/proto-signing"; +import { Api } from "./rest"; + + +const types = [ + +]; +export const MissingWalletError = new Error("wallet is required"); + +export const registry = new Registry(types); + +const defaultFee = { + amount: [], + gas: "200000", +}; + +interface TxClientOptions { + addr: string +} + +interface SignAndBroadcastOptions { + fee: StdFee, + memo?: string +} + +const txClient = async (wallet: OfflineSigner, { addr: addr }: TxClientOptions = { addr: "http://localhost:26657" }) => { + if (!wallet) throw MissingWalletError; + let client; + if (addr) { + client = await SigningStargateClient.connectWithSigner(addr, wallet, { registry }); + }else{ + client = await SigningStargateClient.offline( wallet, { registry }); + } + const { address } = (await wallet.getAccounts())[0]; + + return { + signAndBroadcast: (msgs: EncodeObject[], { fee, memo }: SignAndBroadcastOptions = {fee: defaultFee, memo: ""}) => client.signAndBroadcast(address, msgs, fee,memo), + + }; +}; + +interface QueryClientOptions { + addr: string +} + +const queryClient = async ({ addr: addr }: QueryClientOptions = { addr: "http://localhost:1317" }) => { + return new Api({ baseUrl: addr }); +}; + +export { + txClient, + queryClient, +}; diff --git a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/rest.ts b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/rest.ts new file mode 100644 index 00000000..7d83cbdb --- /dev/null +++ b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/rest.ts @@ -0,0 +1,250 @@ +/* eslint-disable */ +/* tslint:disable */ +/* + * --------------------------------------------------------------- + * ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ## + * ## ## + * ## AUTHOR: acacode ## + * ## SOURCE: https://github.com/acacode/swagger-typescript-api ## + * --------------------------------------------------------------- + */ + +export interface ProtobufAny { + "@type"?: string; +} + +/** + * QueryParamsResponse is response type for the Query/Params RPC method. + */ +export interface RewardsQueryParamsResponse { + /** params holds all the parameters of this module. */ + params?: V1RewardsParams; +} + +export interface RpcStatus { + /** @format int32 */ + code?: number; + message?: string; + details?: ProtobufAny[]; +} + +/** + * Params defines the parameters for the module. + */ +export interface V1RewardsParams { + createStakingRewardFee?: string; + createTradingRewardFee?: string; +} + +export type QueryParamsType = Record; +export type ResponseFormat = keyof Omit; + +export interface FullRequestParams extends Omit { + /** set parameter to `true` for call `securityWorker` for this request */ + secure?: boolean; + /** request path */ + path: string; + /** content type of request body */ + type?: ContentType; + /** query params */ + query?: QueryParamsType; + /** format of response (i.e. response.json() -> format: "json") */ + format?: keyof Omit; + /** request body */ + body?: unknown; + /** base url */ + baseUrl?: string; + /** request cancellation token */ + cancelToken?: CancelToken; +} + +export type RequestParams = Omit; + +export interface ApiConfig { + baseUrl?: string; + baseApiParams?: Omit; + securityWorker?: (securityData: SecurityDataType) => RequestParams | void; +} + +export interface HttpResponse extends Response { + data: D; + error: E; +} + +type CancelToken = Symbol | string | number; + +export enum ContentType { + Json = "application/json", + FormData = "multipart/form-data", + UrlEncoded = "application/x-www-form-urlencoded", +} + +export class HttpClient { + public baseUrl: string = ""; + private securityData: SecurityDataType = null as any; + private securityWorker: null | ApiConfig["securityWorker"] = null; + private abortControllers = new Map(); + + private baseApiParams: RequestParams = { + credentials: "same-origin", + headers: {}, + redirect: "follow", + referrerPolicy: "no-referrer", + }; + + constructor(apiConfig: ApiConfig = {}) { + Object.assign(this, apiConfig); + } + + public setSecurityData = (data: SecurityDataType) => { + this.securityData = data; + }; + + private addQueryParam(query: QueryParamsType, key: string) { + const value = query[key]; + + return ( + encodeURIComponent(key) + + "=" + + encodeURIComponent(Array.isArray(value) ? value.join(",") : typeof value === "number" ? value : `${value}`) + ); + } + + protected toQueryString(rawQuery?: QueryParamsType): string { + const query = rawQuery || {}; + const keys = Object.keys(query).filter((key) => "undefined" !== typeof query[key]); + return keys + .map((key) => + typeof query[key] === "object" && !Array.isArray(query[key]) + ? this.toQueryString(query[key] as QueryParamsType) + : this.addQueryParam(query, key), + ) + .join("&"); + } + + protected addQueryParams(rawQuery?: QueryParamsType): string { + const queryString = this.toQueryString(rawQuery); + return queryString ? `?${queryString}` : ""; + } + + private contentFormatters: Record any> = { + [ContentType.Json]: (input: any) => + input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input, + [ContentType.FormData]: (input: any) => + Object.keys(input || {}).reduce((data, key) => { + data.append(key, input[key]); + return data; + }, new FormData()), + [ContentType.UrlEncoded]: (input: any) => this.toQueryString(input), + }; + + private mergeRequestParams(params1: RequestParams, params2?: RequestParams): RequestParams { + return { + ...this.baseApiParams, + ...params1, + ...(params2 || {}), + headers: { + ...(this.baseApiParams.headers || {}), + ...(params1.headers || {}), + ...((params2 && params2.headers) || {}), + }, + }; + } + + private createAbortSignal = (cancelToken: CancelToken): AbortSignal | undefined => { + if (this.abortControllers.has(cancelToken)) { + const abortController = this.abortControllers.get(cancelToken); + if (abortController) { + return abortController.signal; + } + return void 0; + } + + const abortController = new AbortController(); + this.abortControllers.set(cancelToken, abortController); + return abortController.signal; + }; + + public abortRequest = (cancelToken: CancelToken) => { + const abortController = this.abortControllers.get(cancelToken); + + if (abortController) { + abortController.abort(); + this.abortControllers.delete(cancelToken); + } + }; + + public request = ({ + body, + secure, + path, + type, + query, + format = "json", + baseUrl, + cancelToken, + ...params + }: FullRequestParams): Promise> => { + const secureParams = (secure && this.securityWorker && this.securityWorker(this.securityData)) || {}; + const requestParams = this.mergeRequestParams(params, secureParams); + const queryString = query && this.toQueryString(query); + const payloadFormatter = this.contentFormatters[type || ContentType.Json]; + + return fetch(`${baseUrl || this.baseUrl || ""}${path}${queryString ? `?${queryString}` : ""}`, { + ...requestParams, + headers: { + ...(type && type !== ContentType.FormData ? { "Content-Type": type } : {}), + ...(requestParams.headers || {}), + }, + signal: cancelToken ? this.createAbortSignal(cancelToken) : void 0, + body: typeof body === "undefined" || body === null ? null : payloadFormatter(body), + }).then(async (response) => { + const r = response as HttpResponse; + r.data = (null as unknown) as T; + r.error = (null as unknown) as E; + + const data = await response[format]() + .then((data) => { + if (r.ok) { + r.data = data; + } else { + r.error = data; + } + return r; + }) + .catch((e) => { + r.error = e; + return r; + }); + + if (cancelToken) { + this.abortControllers.delete(cancelToken); + } + + if (!response.ok) throw data; + return data; + }); + }; +} + +/** + * @title rewards/genesis.proto + * @version version not set + */ +export class Api extends HttpClient { + /** + * No description + * + * @tags Query + * @name QueryParams + * @summary Parameters queries the parameters of the module. + * @request GET:/bze/rewards/v1/params + */ + queryParams = (params: RequestParams = {}) => + this.request({ + path: `/bze/rewards/v1/params`, + method: "GET", + format: "json", + ...params, + }); +} diff --git a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/cosmos/base/query/v1beta1/pagination.ts b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/cosmos/base/query/v1beta1/pagination.ts new file mode 100644 index 00000000..9c87ac0c --- /dev/null +++ b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/cosmos/base/query/v1beta1/pagination.ts @@ -0,0 +1,328 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "cosmos.base.query.v1beta1"; + +/** + * PageRequest is to be embedded in gRPC request messages for efficient + * pagination. Ex: + * + * message SomeRequest { + * Foo some_parameter = 1; + * PageRequest pagination = 2; + * } + */ +export interface PageRequest { + /** + * key is a value returned in PageResponse.next_key to begin + * querying the next page most efficiently. Only one of offset or key + * should be set. + */ + key: Uint8Array; + /** + * offset is a numeric offset that can be used when key is unavailable. + * It is less efficient than using key. Only one of offset or key should + * be set. + */ + offset: number; + /** + * limit is the total number of results to be returned in the result page. + * If left empty it will default to a value to be set by each app. + */ + limit: number; + /** + * count_total is set to true to indicate that the result set should include + * a count of the total number of items available for pagination in UIs. + * count_total is only respected when offset is used. It is ignored when key + * is set. + */ + count_total: boolean; + /** + * reverse is set to true if results are to be returned in the descending order. + * + * Since: cosmos-sdk 0.43 + */ + reverse: boolean; +} + +/** + * PageResponse is to be embedded in gRPC response messages where the + * corresponding request message has used PageRequest. + * + * message SomeResponse { + * repeated Bar results = 1; + * PageResponse page = 2; + * } + */ +export interface PageResponse { + /** + * next_key is the key to be passed to PageRequest.key to + * query the next page most efficiently + */ + next_key: Uint8Array; + /** + * total is total number of results available if PageRequest.count_total + * was set, its value is undefined otherwise + */ + total: number; +} + +const basePageRequest: object = { + offset: 0, + limit: 0, + count_total: false, + reverse: false, +}; + +export const PageRequest = { + encode(message: PageRequest, writer: Writer = Writer.create()): Writer { + if (message.key.length !== 0) { + writer.uint32(10).bytes(message.key); + } + if (message.offset !== 0) { + writer.uint32(16).uint64(message.offset); + } + if (message.limit !== 0) { + writer.uint32(24).uint64(message.limit); + } + if (message.count_total === true) { + writer.uint32(32).bool(message.count_total); + } + if (message.reverse === true) { + writer.uint32(40).bool(message.reverse); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): PageRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...basePageRequest } as PageRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.key = reader.bytes(); + break; + case 2: + message.offset = longToNumber(reader.uint64() as Long); + break; + case 3: + message.limit = longToNumber(reader.uint64() as Long); + break; + case 4: + message.count_total = reader.bool(); + break; + case 5: + message.reverse = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): PageRequest { + const message = { ...basePageRequest } as PageRequest; + if (object.key !== undefined && object.key !== null) { + message.key = bytesFromBase64(object.key); + } + if (object.offset !== undefined && object.offset !== null) { + message.offset = Number(object.offset); + } else { + message.offset = 0; + } + if (object.limit !== undefined && object.limit !== null) { + message.limit = Number(object.limit); + } else { + message.limit = 0; + } + if (object.count_total !== undefined && object.count_total !== null) { + message.count_total = Boolean(object.count_total); + } else { + message.count_total = false; + } + if (object.reverse !== undefined && object.reverse !== null) { + message.reverse = Boolean(object.reverse); + } else { + message.reverse = false; + } + return message; + }, + + toJSON(message: PageRequest): unknown { + const obj: any = {}; + message.key !== undefined && + (obj.key = base64FromBytes( + message.key !== undefined ? message.key : new Uint8Array() + )); + message.offset !== undefined && (obj.offset = message.offset); + message.limit !== undefined && (obj.limit = message.limit); + message.count_total !== undefined && + (obj.count_total = message.count_total); + message.reverse !== undefined && (obj.reverse = message.reverse); + return obj; + }, + + fromPartial(object: DeepPartial): PageRequest { + const message = { ...basePageRequest } as PageRequest; + if (object.key !== undefined && object.key !== null) { + message.key = object.key; + } else { + message.key = new Uint8Array(); + } + if (object.offset !== undefined && object.offset !== null) { + message.offset = object.offset; + } else { + message.offset = 0; + } + if (object.limit !== undefined && object.limit !== null) { + message.limit = object.limit; + } else { + message.limit = 0; + } + if (object.count_total !== undefined && object.count_total !== null) { + message.count_total = object.count_total; + } else { + message.count_total = false; + } + if (object.reverse !== undefined && object.reverse !== null) { + message.reverse = object.reverse; + } else { + message.reverse = false; + } + return message; + }, +}; + +const basePageResponse: object = { total: 0 }; + +export const PageResponse = { + encode(message: PageResponse, writer: Writer = Writer.create()): Writer { + if (message.next_key.length !== 0) { + writer.uint32(10).bytes(message.next_key); + } + if (message.total !== 0) { + writer.uint32(16).uint64(message.total); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): PageResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...basePageResponse } as PageResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.next_key = reader.bytes(); + break; + case 2: + message.total = longToNumber(reader.uint64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): PageResponse { + const message = { ...basePageResponse } as PageResponse; + if (object.next_key !== undefined && object.next_key !== null) { + message.next_key = bytesFromBase64(object.next_key); + } + if (object.total !== undefined && object.total !== null) { + message.total = Number(object.total); + } else { + message.total = 0; + } + return message; + }, + + toJSON(message: PageResponse): unknown { + const obj: any = {}; + message.next_key !== undefined && + (obj.next_key = base64FromBytes( + message.next_key !== undefined ? message.next_key : new Uint8Array() + )); + message.total !== undefined && (obj.total = message.total); + return obj; + }, + + fromPartial(object: DeepPartial): PageResponse { + const message = { ...basePageResponse } as PageResponse; + if (object.next_key !== undefined && object.next_key !== null) { + message.next_key = object.next_key; + } else { + message.next_key = new Uint8Array(); + } + if (object.total !== undefined && object.total !== null) { + message.total = object.total; + } else { + message.total = 0; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/gogoproto/gogo.ts b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/gogoproto/gogo.ts new file mode 100644 index 00000000..3f41a047 --- /dev/null +++ b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/gogoproto/gogo.ts @@ -0,0 +1,2 @@ +/* eslint-disable */ +export const protobufPackage = "gogoproto"; diff --git a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/google/api/annotations.ts b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/google/api/annotations.ts new file mode 100644 index 00000000..aace4787 --- /dev/null +++ b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/google/api/annotations.ts @@ -0,0 +1,2 @@ +/* eslint-disable */ +export const protobufPackage = "google.api"; diff --git a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/google/api/http.ts b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/google/api/http.ts new file mode 100644 index 00000000..ccadff68 --- /dev/null +++ b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/google/api/http.ts @@ -0,0 +1,706 @@ +/* eslint-disable */ +import { Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "google.api"; + +/** + * Defines the HTTP configuration for an API service. It contains a list of + * [HttpRule][google.api.HttpRule], each specifying the mapping of an RPC method + * to one or more HTTP REST API methods. + */ +export interface Http { + /** + * A list of HTTP configuration rules that apply to individual API methods. + * + * **NOTE:** All service configuration rules follow "last one wins" order. + */ + rules: HttpRule[]; + /** + * When set to true, URL path parmeters will be fully URI-decoded except in + * cases of single segment matches in reserved expansion, where "%2F" will be + * left encoded. + * + * The default behavior is to not decode RFC 6570 reserved characters in multi + * segment matches. + */ + fully_decode_reserved_expansion: boolean; +} + +/** + * `HttpRule` defines the mapping of an RPC method to one or more HTTP + * REST API methods. The mapping specifies how different portions of the RPC + * request message are mapped to URL path, URL query parameters, and + * HTTP request body. The mapping is typically specified as an + * `google.api.http` annotation on the RPC method, + * see "google/api/annotations.proto" for details. + * + * The mapping consists of a field specifying the path template and + * method kind. The path template can refer to fields in the request + * message, as in the example below which describes a REST GET + * operation on a resource collection of messages: + * + * + * service Messaging { + * rpc GetMessage(GetMessageRequest) returns (Message) { + * option (google.api.http).get = "/v1/messages/{message_id}/{sub.subfield}"; + * } + * } + * message GetMessageRequest { + * message SubMessage { + * string subfield = 1; + * } + * string message_id = 1; // mapped to the URL + * SubMessage sub = 2; // `sub.subfield` is url-mapped + * } + * message Message { + * string text = 1; // content of the resource + * } + * + * The same http annotation can alternatively be expressed inside the + * `GRPC API Configuration` YAML file. + * + * http: + * rules: + * - selector: .Messaging.GetMessage + * get: /v1/messages/{message_id}/{sub.subfield} + * + * This definition enables an automatic, bidrectional mapping of HTTP + * JSON to RPC. Example: + * + * HTTP | RPC + * -----|----- + * `GET /v1/messages/123456/foo` | `GetMessage(message_id: "123456" sub: SubMessage(subfield: "foo"))` + * + * In general, not only fields but also field paths can be referenced + * from a path pattern. Fields mapped to the path pattern cannot be + * repeated and must have a primitive (non-message) type. + * + * Any fields in the request message which are not bound by the path + * pattern automatically become (optional) HTTP query + * parameters. Assume the following definition of the request message: + * + * + * service Messaging { + * rpc GetMessage(GetMessageRequest) returns (Message) { + * option (google.api.http).get = "/v1/messages/{message_id}"; + * } + * } + * message GetMessageRequest { + * message SubMessage { + * string subfield = 1; + * } + * string message_id = 1; // mapped to the URL + * int64 revision = 2; // becomes a parameter + * SubMessage sub = 3; // `sub.subfield` becomes a parameter + * } + * + * + * This enables a HTTP JSON to RPC mapping as below: + * + * HTTP | RPC + * -----|----- + * `GET /v1/messages/123456?revision=2&sub.subfield=foo` | `GetMessage(message_id: "123456" revision: 2 sub: SubMessage(subfield: "foo"))` + * + * Note that fields which are mapped to HTTP parameters must have a + * primitive type or a repeated primitive type. Message types are not + * allowed. In the case of a repeated type, the parameter can be + * repeated in the URL, as in `...?param=A¶m=B`. + * + * For HTTP method kinds which allow a request body, the `body` field + * specifies the mapping. Consider a REST update method on the + * message resource collection: + * + * + * service Messaging { + * rpc UpdateMessage(UpdateMessageRequest) returns (Message) { + * option (google.api.http) = { + * put: "/v1/messages/{message_id}" + * body: "message" + * }; + * } + * } + * message UpdateMessageRequest { + * string message_id = 1; // mapped to the URL + * Message message = 2; // mapped to the body + * } + * + * + * The following HTTP JSON to RPC mapping is enabled, where the + * representation of the JSON in the request body is determined by + * protos JSON encoding: + * + * HTTP | RPC + * -----|----- + * `PUT /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: "123456" message { text: "Hi!" })` + * + * The special name `*` can be used in the body mapping to define that + * every field not bound by the path template should be mapped to the + * request body. This enables the following alternative definition of + * the update method: + * + * service Messaging { + * rpc UpdateMessage(Message) returns (Message) { + * option (google.api.http) = { + * put: "/v1/messages/{message_id}" + * body: "*" + * }; + * } + * } + * message Message { + * string message_id = 1; + * string text = 2; + * } + * + * + * The following HTTP JSON to RPC mapping is enabled: + * + * HTTP | RPC + * -----|----- + * `PUT /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: "123456" text: "Hi!")` + * + * Note that when using `*` in the body mapping, it is not possible to + * have HTTP parameters, as all fields not bound by the path end in + * the body. This makes this option more rarely used in practice of + * defining REST APIs. The common usage of `*` is in custom methods + * which don't use the URL at all for transferring data. + * + * It is possible to define multiple HTTP methods for one RPC by using + * the `additional_bindings` option. Example: + * + * service Messaging { + * rpc GetMessage(GetMessageRequest) returns (Message) { + * option (google.api.http) = { + * get: "/v1/messages/{message_id}" + * additional_bindings { + * get: "/v1/users/{user_id}/messages/{message_id}" + * } + * }; + * } + * } + * message GetMessageRequest { + * string message_id = 1; + * string user_id = 2; + * } + * + * + * This enables the following two alternative HTTP JSON to RPC + * mappings: + * + * HTTP | RPC + * -----|----- + * `GET /v1/messages/123456` | `GetMessage(message_id: "123456")` + * `GET /v1/users/me/messages/123456` | `GetMessage(user_id: "me" message_id: "123456")` + * + * # Rules for HTTP mapping + * + * The rules for mapping HTTP path, query parameters, and body fields + * to the request message are as follows: + * + * 1. The `body` field specifies either `*` or a field path, or is + * omitted. If omitted, it indicates there is no HTTP request body. + * 2. Leaf fields (recursive expansion of nested messages in the + * request) can be classified into three types: + * (a) Matched in the URL template. + * (b) Covered by body (if body is `*`, everything except (a) fields; + * else everything under the body field) + * (c) All other fields. + * 3. URL query parameters found in the HTTP request are mapped to (c) fields. + * 4. Any body sent with an HTTP request can contain only (b) fields. + * + * The syntax of the path template is as follows: + * + * Template = "/" Segments [ Verb ] ; + * Segments = Segment { "/" Segment } ; + * Segment = "*" | "**" | LITERAL | Variable ; + * Variable = "{" FieldPath [ "=" Segments ] "}" ; + * FieldPath = IDENT { "." IDENT } ; + * Verb = ":" LITERAL ; + * + * The syntax `*` matches a single path segment. The syntax `**` matches zero + * or more path segments, which must be the last part of the path except the + * `Verb`. The syntax `LITERAL` matches literal text in the path. + * + * The syntax `Variable` matches part of the URL path as specified by its + * template. A variable template must not contain other variables. If a variable + * matches a single path segment, its template may be omitted, e.g. `{var}` + * is equivalent to `{var=*}`. + * + * If a variable contains exactly one path segment, such as `"{var}"` or + * `"{var=*}"`, when such a variable is expanded into a URL path, all characters + * except `[-_.~0-9a-zA-Z]` are percent-encoded. Such variables show up in the + * Discovery Document as `{var}`. + * + * If a variable contains one or more path segments, such as `"{var=foo/*}"` + * or `"{var=**}"`, when such a variable is expanded into a URL path, all + * characters except `[-_.~/0-9a-zA-Z]` are percent-encoded. Such variables + * show up in the Discovery Document as `{+var}`. + * + * NOTE: While the single segment variable matches the semantics of + * [RFC 6570](https://tools.ietf.org/html/rfc6570) Section 3.2.2 + * Simple String Expansion, the multi segment variable **does not** match + * RFC 6570 Reserved Expansion. The reason is that the Reserved Expansion + * does not expand special characters like `?` and `#`, which would lead + * to invalid URLs. + * + * NOTE: the field paths in variables and in the `body` must not refer to + * repeated fields or map fields. + */ +export interface HttpRule { + /** + * Selects methods to which this rule applies. + * + * Refer to [selector][google.api.DocumentationRule.selector] for syntax details. + */ + selector: string; + /** Used for listing and getting information about resources. */ + get: string | undefined; + /** Used for updating a resource. */ + put: string | undefined; + /** Used for creating a resource. */ + post: string | undefined; + /** Used for deleting a resource. */ + delete: string | undefined; + /** Used for updating a resource. */ + patch: string | undefined; + /** + * The custom pattern is used for specifying an HTTP method that is not + * included in the `pattern` field, such as HEAD, or "*" to leave the + * HTTP method unspecified for this rule. The wild-card rule is useful + * for services that provide content to Web (HTML) clients. + */ + custom: CustomHttpPattern | undefined; + /** + * The name of the request field whose value is mapped to the HTTP body, or + * `*` for mapping all fields not captured by the path pattern to the HTTP + * body. NOTE: the referred field must not be a repeated field and must be + * present at the top-level of request message type. + */ + body: string; + /** + * Optional. The name of the response field whose value is mapped to the HTTP + * body of response. Other response fields are ignored. When + * not set, the response message will be used as HTTP body of response. + */ + response_body: string; + /** + * Additional HTTP bindings for the selector. Nested bindings must + * not contain an `additional_bindings` field themselves (that is, + * the nesting may only be one level deep). + */ + additional_bindings: HttpRule[]; +} + +/** A custom pattern is used for defining custom HTTP verb. */ +export interface CustomHttpPattern { + /** The name of this custom HTTP verb. */ + kind: string; + /** The path matched by this custom verb. */ + path: string; +} + +const baseHttp: object = { fully_decode_reserved_expansion: false }; + +export const Http = { + encode(message: Http, writer: Writer = Writer.create()): Writer { + for (const v of message.rules) { + HttpRule.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.fully_decode_reserved_expansion === true) { + writer.uint32(16).bool(message.fully_decode_reserved_expansion); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Http { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseHttp } as Http; + message.rules = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.rules.push(HttpRule.decode(reader, reader.uint32())); + break; + case 2: + message.fully_decode_reserved_expansion = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Http { + const message = { ...baseHttp } as Http; + message.rules = []; + if (object.rules !== undefined && object.rules !== null) { + for (const e of object.rules) { + message.rules.push(HttpRule.fromJSON(e)); + } + } + if ( + object.fully_decode_reserved_expansion !== undefined && + object.fully_decode_reserved_expansion !== null + ) { + message.fully_decode_reserved_expansion = Boolean( + object.fully_decode_reserved_expansion + ); + } else { + message.fully_decode_reserved_expansion = false; + } + return message; + }, + + toJSON(message: Http): unknown { + const obj: any = {}; + if (message.rules) { + obj.rules = message.rules.map((e) => + e ? HttpRule.toJSON(e) : undefined + ); + } else { + obj.rules = []; + } + message.fully_decode_reserved_expansion !== undefined && + (obj.fully_decode_reserved_expansion = + message.fully_decode_reserved_expansion); + return obj; + }, + + fromPartial(object: DeepPartial): Http { + const message = { ...baseHttp } as Http; + message.rules = []; + if (object.rules !== undefined && object.rules !== null) { + for (const e of object.rules) { + message.rules.push(HttpRule.fromPartial(e)); + } + } + if ( + object.fully_decode_reserved_expansion !== undefined && + object.fully_decode_reserved_expansion !== null + ) { + message.fully_decode_reserved_expansion = + object.fully_decode_reserved_expansion; + } else { + message.fully_decode_reserved_expansion = false; + } + return message; + }, +}; + +const baseHttpRule: object = { selector: "", body: "", response_body: "" }; + +export const HttpRule = { + encode(message: HttpRule, writer: Writer = Writer.create()): Writer { + if (message.selector !== "") { + writer.uint32(10).string(message.selector); + } + if (message.get !== undefined) { + writer.uint32(18).string(message.get); + } + if (message.put !== undefined) { + writer.uint32(26).string(message.put); + } + if (message.post !== undefined) { + writer.uint32(34).string(message.post); + } + if (message.delete !== undefined) { + writer.uint32(42).string(message.delete); + } + if (message.patch !== undefined) { + writer.uint32(50).string(message.patch); + } + if (message.custom !== undefined) { + CustomHttpPattern.encode( + message.custom, + writer.uint32(66).fork() + ).ldelim(); + } + if (message.body !== "") { + writer.uint32(58).string(message.body); + } + if (message.response_body !== "") { + writer.uint32(98).string(message.response_body); + } + for (const v of message.additional_bindings) { + HttpRule.encode(v!, writer.uint32(90).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): HttpRule { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseHttpRule } as HttpRule; + message.additional_bindings = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.selector = reader.string(); + break; + case 2: + message.get = reader.string(); + break; + case 3: + message.put = reader.string(); + break; + case 4: + message.post = reader.string(); + break; + case 5: + message.delete = reader.string(); + break; + case 6: + message.patch = reader.string(); + break; + case 8: + message.custom = CustomHttpPattern.decode(reader, reader.uint32()); + break; + case 7: + message.body = reader.string(); + break; + case 12: + message.response_body = reader.string(); + break; + case 11: + message.additional_bindings.push( + HttpRule.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): HttpRule { + const message = { ...baseHttpRule } as HttpRule; + message.additional_bindings = []; + if (object.selector !== undefined && object.selector !== null) { + message.selector = String(object.selector); + } else { + message.selector = ""; + } + if (object.get !== undefined && object.get !== null) { + message.get = String(object.get); + } else { + message.get = undefined; + } + if (object.put !== undefined && object.put !== null) { + message.put = String(object.put); + } else { + message.put = undefined; + } + if (object.post !== undefined && object.post !== null) { + message.post = String(object.post); + } else { + message.post = undefined; + } + if (object.delete !== undefined && object.delete !== null) { + message.delete = String(object.delete); + } else { + message.delete = undefined; + } + if (object.patch !== undefined && object.patch !== null) { + message.patch = String(object.patch); + } else { + message.patch = undefined; + } + if (object.custom !== undefined && object.custom !== null) { + message.custom = CustomHttpPattern.fromJSON(object.custom); + } else { + message.custom = undefined; + } + if (object.body !== undefined && object.body !== null) { + message.body = String(object.body); + } else { + message.body = ""; + } + if (object.response_body !== undefined && object.response_body !== null) { + message.response_body = String(object.response_body); + } else { + message.response_body = ""; + } + if ( + object.additional_bindings !== undefined && + object.additional_bindings !== null + ) { + for (const e of object.additional_bindings) { + message.additional_bindings.push(HttpRule.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: HttpRule): unknown { + const obj: any = {}; + message.selector !== undefined && (obj.selector = message.selector); + message.get !== undefined && (obj.get = message.get); + message.put !== undefined && (obj.put = message.put); + message.post !== undefined && (obj.post = message.post); + message.delete !== undefined && (obj.delete = message.delete); + message.patch !== undefined && (obj.patch = message.patch); + message.custom !== undefined && + (obj.custom = message.custom + ? CustomHttpPattern.toJSON(message.custom) + : undefined); + message.body !== undefined && (obj.body = message.body); + message.response_body !== undefined && + (obj.response_body = message.response_body); + if (message.additional_bindings) { + obj.additional_bindings = message.additional_bindings.map((e) => + e ? HttpRule.toJSON(e) : undefined + ); + } else { + obj.additional_bindings = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): HttpRule { + const message = { ...baseHttpRule } as HttpRule; + message.additional_bindings = []; + if (object.selector !== undefined && object.selector !== null) { + message.selector = object.selector; + } else { + message.selector = ""; + } + if (object.get !== undefined && object.get !== null) { + message.get = object.get; + } else { + message.get = undefined; + } + if (object.put !== undefined && object.put !== null) { + message.put = object.put; + } else { + message.put = undefined; + } + if (object.post !== undefined && object.post !== null) { + message.post = object.post; + } else { + message.post = undefined; + } + if (object.delete !== undefined && object.delete !== null) { + message.delete = object.delete; + } else { + message.delete = undefined; + } + if (object.patch !== undefined && object.patch !== null) { + message.patch = object.patch; + } else { + message.patch = undefined; + } + if (object.custom !== undefined && object.custom !== null) { + message.custom = CustomHttpPattern.fromPartial(object.custom); + } else { + message.custom = undefined; + } + if (object.body !== undefined && object.body !== null) { + message.body = object.body; + } else { + message.body = ""; + } + if (object.response_body !== undefined && object.response_body !== null) { + message.response_body = object.response_body; + } else { + message.response_body = ""; + } + if ( + object.additional_bindings !== undefined && + object.additional_bindings !== null + ) { + for (const e of object.additional_bindings) { + message.additional_bindings.push(HttpRule.fromPartial(e)); + } + } + return message; + }, +}; + +const baseCustomHttpPattern: object = { kind: "", path: "" }; + +export const CustomHttpPattern = { + encode(message: CustomHttpPattern, writer: Writer = Writer.create()): Writer { + if (message.kind !== "") { + writer.uint32(10).string(message.kind); + } + if (message.path !== "") { + writer.uint32(18).string(message.path); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): CustomHttpPattern { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseCustomHttpPattern } as CustomHttpPattern; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.kind = reader.string(); + break; + case 2: + message.path = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): CustomHttpPattern { + const message = { ...baseCustomHttpPattern } as CustomHttpPattern; + if (object.kind !== undefined && object.kind !== null) { + message.kind = String(object.kind); + } else { + message.kind = ""; + } + if (object.path !== undefined && object.path !== null) { + message.path = String(object.path); + } else { + message.path = ""; + } + return message; + }, + + toJSON(message: CustomHttpPattern): unknown { + const obj: any = {}; + message.kind !== undefined && (obj.kind = message.kind); + message.path !== undefined && (obj.path = message.path); + return obj; + }, + + fromPartial(object: DeepPartial): CustomHttpPattern { + const message = { ...baseCustomHttpPattern } as CustomHttpPattern; + if (object.kind !== undefined && object.kind !== null) { + message.kind = object.kind; + } else { + message.kind = ""; + } + if (object.path !== undefined && object.path !== null) { + message.path = object.path; + } else { + message.path = ""; + } + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/google/protobuf/descriptor.ts b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/google/protobuf/descriptor.ts new file mode 100644 index 00000000..a0167cb2 --- /dev/null +++ b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/google/protobuf/descriptor.ts @@ -0,0 +1,5314 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "google.protobuf"; + +/** + * The protocol compiler can output a FileDescriptorSet containing the .proto + * files it parses. + */ +export interface FileDescriptorSet { + file: FileDescriptorProto[]; +} + +/** Describes a complete .proto file. */ +export interface FileDescriptorProto { + /** file name, relative to root of source tree */ + name: string; + /** e.g. "foo", "foo.bar", etc. */ + package: string; + /** Names of files imported by this file. */ + dependency: string[]; + /** Indexes of the public imported files in the dependency list above. */ + public_dependency: number[]; + /** + * Indexes of the weak imported files in the dependency list. + * For Google-internal migration only. Do not use. + */ + weak_dependency: number[]; + /** All top-level definitions in this file. */ + message_type: DescriptorProto[]; + enum_type: EnumDescriptorProto[]; + service: ServiceDescriptorProto[]; + extension: FieldDescriptorProto[]; + options: FileOptions | undefined; + /** + * This field contains optional information about the original source code. + * You may safely remove this entire field without harming runtime + * functionality of the descriptors -- the information is needed only by + * development tools. + */ + source_code_info: SourceCodeInfo | undefined; + /** + * The syntax of the proto file. + * The supported values are "proto2" and "proto3". + */ + syntax: string; +} + +/** Describes a message type. */ +export interface DescriptorProto { + name: string; + field: FieldDescriptorProto[]; + extension: FieldDescriptorProto[]; + nested_type: DescriptorProto[]; + enum_type: EnumDescriptorProto[]; + extension_range: DescriptorProto_ExtensionRange[]; + oneof_decl: OneofDescriptorProto[]; + options: MessageOptions | undefined; + reserved_range: DescriptorProto_ReservedRange[]; + /** + * Reserved field names, which may not be used by fields in the same message. + * A given name may only be reserved once. + */ + reserved_name: string[]; +} + +export interface DescriptorProto_ExtensionRange { + /** Inclusive. */ + start: number; + /** Exclusive. */ + end: number; + options: ExtensionRangeOptions | undefined; +} + +/** + * Range of reserved tag numbers. Reserved tag numbers may not be used by + * fields or extension ranges in the same message. Reserved ranges may + * not overlap. + */ +export interface DescriptorProto_ReservedRange { + /** Inclusive. */ + start: number; + /** Exclusive. */ + end: number; +} + +export interface ExtensionRangeOptions { + /** The parser stores options it doesn't recognize here. See above. */ + uninterpreted_option: UninterpretedOption[]; +} + +/** Describes a field within a message. */ +export interface FieldDescriptorProto { + name: string; + number: number; + label: FieldDescriptorProto_Label; + /** + * If type_name is set, this need not be set. If both this and type_name + * are set, this must be one of TYPE_ENUM, TYPE_MESSAGE or TYPE_GROUP. + */ + type: FieldDescriptorProto_Type; + /** + * For message and enum types, this is the name of the type. If the name + * starts with a '.', it is fully-qualified. Otherwise, C++-like scoping + * rules are used to find the type (i.e. first the nested types within this + * message are searched, then within the parent, on up to the root + * namespace). + */ + type_name: string; + /** + * For extensions, this is the name of the type being extended. It is + * resolved in the same manner as type_name. + */ + extendee: string; + /** + * For numeric types, contains the original text representation of the value. + * For booleans, "true" or "false". + * For strings, contains the default text contents (not escaped in any way). + * For bytes, contains the C escaped value. All bytes >= 128 are escaped. + * TODO(kenton): Base-64 encode? + */ + default_value: string; + /** + * If set, gives the index of a oneof in the containing type's oneof_decl + * list. This field is a member of that oneof. + */ + oneof_index: number; + /** + * JSON name of this field. The value is set by protocol compiler. If the + * user has set a "json_name" option on this field, that option's value + * will be used. Otherwise, it's deduced from the field's name by converting + * it to camelCase. + */ + json_name: string; + options: FieldOptions | undefined; + /** + * If true, this is a proto3 "optional". When a proto3 field is optional, it + * tracks presence regardless of field type. + * + * When proto3_optional is true, this field must be belong to a oneof to + * signal to old proto3 clients that presence is tracked for this field. This + * oneof is known as a "synthetic" oneof, and this field must be its sole + * member (each proto3 optional field gets its own synthetic oneof). Synthetic + * oneofs exist in the descriptor only, and do not generate any API. Synthetic + * oneofs must be ordered after all "real" oneofs. + * + * For message fields, proto3_optional doesn't create any semantic change, + * since non-repeated message fields always track presence. However it still + * indicates the semantic detail of whether the user wrote "optional" or not. + * This can be useful for round-tripping the .proto file. For consistency we + * give message fields a synthetic oneof also, even though it is not required + * to track presence. This is especially important because the parser can't + * tell if a field is a message or an enum, so it must always create a + * synthetic oneof. + * + * Proto2 optional fields do not set this flag, because they already indicate + * optional with `LABEL_OPTIONAL`. + */ + proto3_optional: boolean; +} + +export enum FieldDescriptorProto_Type { + /** + * TYPE_DOUBLE - 0 is reserved for errors. + * Order is weird for historical reasons. + */ + TYPE_DOUBLE = 1, + TYPE_FLOAT = 2, + /** + * TYPE_INT64 - Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT64 if + * negative values are likely. + */ + TYPE_INT64 = 3, + TYPE_UINT64 = 4, + /** + * TYPE_INT32 - Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT32 if + * negative values are likely. + */ + TYPE_INT32 = 5, + TYPE_FIXED64 = 6, + TYPE_FIXED32 = 7, + TYPE_BOOL = 8, + TYPE_STRING = 9, + /** + * TYPE_GROUP - Tag-delimited aggregate. + * Group type is deprecated and not supported in proto3. However, Proto3 + * implementations should still be able to parse the group wire format and + * treat group fields as unknown fields. + */ + TYPE_GROUP = 10, + /** TYPE_MESSAGE - Length-delimited aggregate. */ + TYPE_MESSAGE = 11, + /** TYPE_BYTES - New in version 2. */ + TYPE_BYTES = 12, + TYPE_UINT32 = 13, + TYPE_ENUM = 14, + TYPE_SFIXED32 = 15, + TYPE_SFIXED64 = 16, + /** TYPE_SINT32 - Uses ZigZag encoding. */ + TYPE_SINT32 = 17, + /** TYPE_SINT64 - Uses ZigZag encoding. */ + TYPE_SINT64 = 18, + UNRECOGNIZED = -1, +} + +export function fieldDescriptorProto_TypeFromJSON( + object: any +): FieldDescriptorProto_Type { + switch (object) { + case 1: + case "TYPE_DOUBLE": + return FieldDescriptorProto_Type.TYPE_DOUBLE; + case 2: + case "TYPE_FLOAT": + return FieldDescriptorProto_Type.TYPE_FLOAT; + case 3: + case "TYPE_INT64": + return FieldDescriptorProto_Type.TYPE_INT64; + case 4: + case "TYPE_UINT64": + return FieldDescriptorProto_Type.TYPE_UINT64; + case 5: + case "TYPE_INT32": + return FieldDescriptorProto_Type.TYPE_INT32; + case 6: + case "TYPE_FIXED64": + return FieldDescriptorProto_Type.TYPE_FIXED64; + case 7: + case "TYPE_FIXED32": + return FieldDescriptorProto_Type.TYPE_FIXED32; + case 8: + case "TYPE_BOOL": + return FieldDescriptorProto_Type.TYPE_BOOL; + case 9: + case "TYPE_STRING": + return FieldDescriptorProto_Type.TYPE_STRING; + case 10: + case "TYPE_GROUP": + return FieldDescriptorProto_Type.TYPE_GROUP; + case 11: + case "TYPE_MESSAGE": + return FieldDescriptorProto_Type.TYPE_MESSAGE; + case 12: + case "TYPE_BYTES": + return FieldDescriptorProto_Type.TYPE_BYTES; + case 13: + case "TYPE_UINT32": + return FieldDescriptorProto_Type.TYPE_UINT32; + case 14: + case "TYPE_ENUM": + return FieldDescriptorProto_Type.TYPE_ENUM; + case 15: + case "TYPE_SFIXED32": + return FieldDescriptorProto_Type.TYPE_SFIXED32; + case 16: + case "TYPE_SFIXED64": + return FieldDescriptorProto_Type.TYPE_SFIXED64; + case 17: + case "TYPE_SINT32": + return FieldDescriptorProto_Type.TYPE_SINT32; + case 18: + case "TYPE_SINT64": + return FieldDescriptorProto_Type.TYPE_SINT64; + case -1: + case "UNRECOGNIZED": + default: + return FieldDescriptorProto_Type.UNRECOGNIZED; + } +} + +export function fieldDescriptorProto_TypeToJSON( + object: FieldDescriptorProto_Type +): string { + switch (object) { + case FieldDescriptorProto_Type.TYPE_DOUBLE: + return "TYPE_DOUBLE"; + case FieldDescriptorProto_Type.TYPE_FLOAT: + return "TYPE_FLOAT"; + case FieldDescriptorProto_Type.TYPE_INT64: + return "TYPE_INT64"; + case FieldDescriptorProto_Type.TYPE_UINT64: + return "TYPE_UINT64"; + case FieldDescriptorProto_Type.TYPE_INT32: + return "TYPE_INT32"; + case FieldDescriptorProto_Type.TYPE_FIXED64: + return "TYPE_FIXED64"; + case FieldDescriptorProto_Type.TYPE_FIXED32: + return "TYPE_FIXED32"; + case FieldDescriptorProto_Type.TYPE_BOOL: + return "TYPE_BOOL"; + case FieldDescriptorProto_Type.TYPE_STRING: + return "TYPE_STRING"; + case FieldDescriptorProto_Type.TYPE_GROUP: + return "TYPE_GROUP"; + case FieldDescriptorProto_Type.TYPE_MESSAGE: + return "TYPE_MESSAGE"; + case FieldDescriptorProto_Type.TYPE_BYTES: + return "TYPE_BYTES"; + case FieldDescriptorProto_Type.TYPE_UINT32: + return "TYPE_UINT32"; + case FieldDescriptorProto_Type.TYPE_ENUM: + return "TYPE_ENUM"; + case FieldDescriptorProto_Type.TYPE_SFIXED32: + return "TYPE_SFIXED32"; + case FieldDescriptorProto_Type.TYPE_SFIXED64: + return "TYPE_SFIXED64"; + case FieldDescriptorProto_Type.TYPE_SINT32: + return "TYPE_SINT32"; + case FieldDescriptorProto_Type.TYPE_SINT64: + return "TYPE_SINT64"; + default: + return "UNKNOWN"; + } +} + +export enum FieldDescriptorProto_Label { + /** LABEL_OPTIONAL - 0 is reserved for errors */ + LABEL_OPTIONAL = 1, + LABEL_REQUIRED = 2, + LABEL_REPEATED = 3, + UNRECOGNIZED = -1, +} + +export function fieldDescriptorProto_LabelFromJSON( + object: any +): FieldDescriptorProto_Label { + switch (object) { + case 1: + case "LABEL_OPTIONAL": + return FieldDescriptorProto_Label.LABEL_OPTIONAL; + case 2: + case "LABEL_REQUIRED": + return FieldDescriptorProto_Label.LABEL_REQUIRED; + case 3: + case "LABEL_REPEATED": + return FieldDescriptorProto_Label.LABEL_REPEATED; + case -1: + case "UNRECOGNIZED": + default: + return FieldDescriptorProto_Label.UNRECOGNIZED; + } +} + +export function fieldDescriptorProto_LabelToJSON( + object: FieldDescriptorProto_Label +): string { + switch (object) { + case FieldDescriptorProto_Label.LABEL_OPTIONAL: + return "LABEL_OPTIONAL"; + case FieldDescriptorProto_Label.LABEL_REQUIRED: + return "LABEL_REQUIRED"; + case FieldDescriptorProto_Label.LABEL_REPEATED: + return "LABEL_REPEATED"; + default: + return "UNKNOWN"; + } +} + +/** Describes a oneof. */ +export interface OneofDescriptorProto { + name: string; + options: OneofOptions | undefined; +} + +/** Describes an enum type. */ +export interface EnumDescriptorProto { + name: string; + value: EnumValueDescriptorProto[]; + options: EnumOptions | undefined; + /** + * Range of reserved numeric values. Reserved numeric values may not be used + * by enum values in the same enum declaration. Reserved ranges may not + * overlap. + */ + reserved_range: EnumDescriptorProto_EnumReservedRange[]; + /** + * Reserved enum value names, which may not be reused. A given name may only + * be reserved once. + */ + reserved_name: string[]; +} + +/** + * Range of reserved numeric values. Reserved values may not be used by + * entries in the same enum. Reserved ranges may not overlap. + * + * Note that this is distinct from DescriptorProto.ReservedRange in that it + * is inclusive such that it can appropriately represent the entire int32 + * domain. + */ +export interface EnumDescriptorProto_EnumReservedRange { + /** Inclusive. */ + start: number; + /** Inclusive. */ + end: number; +} + +/** Describes a value within an enum. */ +export interface EnumValueDescriptorProto { + name: string; + number: number; + options: EnumValueOptions | undefined; +} + +/** Describes a service. */ +export interface ServiceDescriptorProto { + name: string; + method: MethodDescriptorProto[]; + options: ServiceOptions | undefined; +} + +/** Describes a method of a service. */ +export interface MethodDescriptorProto { + name: string; + /** + * Input and output type names. These are resolved in the same way as + * FieldDescriptorProto.type_name, but must refer to a message type. + */ + input_type: string; + output_type: string; + options: MethodOptions | undefined; + /** Identifies if client streams multiple client messages */ + client_streaming: boolean; + /** Identifies if server streams multiple server messages */ + server_streaming: boolean; +} + +export interface FileOptions { + /** + * Sets the Java package where classes generated from this .proto will be + * placed. By default, the proto package is used, but this is often + * inappropriate because proto packages do not normally start with backwards + * domain names. + */ + java_package: string; + /** + * Controls the name of the wrapper Java class generated for the .proto file. + * That class will always contain the .proto file's getDescriptor() method as + * well as any top-level extensions defined in the .proto file. + * If java_multiple_files is disabled, then all the other classes from the + * .proto file will be nested inside the single wrapper outer class. + */ + java_outer_classname: string; + /** + * If enabled, then the Java code generator will generate a separate .java + * file for each top-level message, enum, and service defined in the .proto + * file. Thus, these types will *not* be nested inside the wrapper class + * named by java_outer_classname. However, the wrapper class will still be + * generated to contain the file's getDescriptor() method as well as any + * top-level extensions defined in the file. + */ + java_multiple_files: boolean; + /** + * This option does nothing. + * + * @deprecated + */ + java_generate_equals_and_hash: boolean; + /** + * If set true, then the Java2 code generator will generate code that + * throws an exception whenever an attempt is made to assign a non-UTF-8 + * byte sequence to a string field. + * Message reflection will do the same. + * However, an extension field still accepts non-UTF-8 byte sequences. + * This option has no effect on when used with the lite runtime. + */ + java_string_check_utf8: boolean; + optimize_for: FileOptions_OptimizeMode; + /** + * Sets the Go package where structs generated from this .proto will be + * placed. If omitted, the Go package will be derived from the following: + * - The basename of the package import path, if provided. + * - Otherwise, the package statement in the .proto file, if present. + * - Otherwise, the basename of the .proto file, without extension. + */ + go_package: string; + /** + * Should generic services be generated in each language? "Generic" services + * are not specific to any particular RPC system. They are generated by the + * main code generators in each language (without additional plugins). + * Generic services were the only kind of service generation supported by + * early versions of google.protobuf. + * + * Generic services are now considered deprecated in favor of using plugins + * that generate code specific to your particular RPC system. Therefore, + * these default to false. Old code which depends on generic services should + * explicitly set them to true. + */ + cc_generic_services: boolean; + java_generic_services: boolean; + py_generic_services: boolean; + php_generic_services: boolean; + /** + * Is this file deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for everything in the file, or it will be completely ignored; in the very + * least, this is a formalization for deprecating files. + */ + deprecated: boolean; + /** + * Enables the use of arenas for the proto messages in this file. This applies + * only to generated classes for C++. + */ + cc_enable_arenas: boolean; + /** + * Sets the objective c class prefix which is prepended to all objective c + * generated classes from this .proto. There is no default. + */ + objc_class_prefix: string; + /** Namespace for generated classes; defaults to the package. */ + csharp_namespace: string; + /** + * By default Swift generators will take the proto package and CamelCase it + * replacing '.' with underscore and use that to prefix the types/symbols + * defined. When this options is provided, they will use this value instead + * to prefix the types/symbols defined. + */ + swift_prefix: string; + /** + * Sets the php class prefix which is prepended to all php generated classes + * from this .proto. Default is empty. + */ + php_class_prefix: string; + /** + * Use this option to change the namespace of php generated classes. Default + * is empty. When this option is empty, the package name will be used for + * determining the namespace. + */ + php_namespace: string; + /** + * Use this option to change the namespace of php generated metadata classes. + * Default is empty. When this option is empty, the proto file name will be + * used for determining the namespace. + */ + php_metadata_namespace: string; + /** + * Use this option to change the package of ruby generated classes. Default + * is empty. When this option is not set, the package name will be used for + * determining the ruby package. + */ + ruby_package: string; + /** + * The parser stores options it doesn't recognize here. + * See the documentation for the "Options" section above. + */ + uninterpreted_option: UninterpretedOption[]; +} + +/** Generated classes can be optimized for speed or code size. */ +export enum FileOptions_OptimizeMode { + /** SPEED - Generate complete code for parsing, serialization, */ + SPEED = 1, + /** CODE_SIZE - etc. */ + CODE_SIZE = 2, + /** LITE_RUNTIME - Generate code using MessageLite and the lite runtime. */ + LITE_RUNTIME = 3, + UNRECOGNIZED = -1, +} + +export function fileOptions_OptimizeModeFromJSON( + object: any +): FileOptions_OptimizeMode { + switch (object) { + case 1: + case "SPEED": + return FileOptions_OptimizeMode.SPEED; + case 2: + case "CODE_SIZE": + return FileOptions_OptimizeMode.CODE_SIZE; + case 3: + case "LITE_RUNTIME": + return FileOptions_OptimizeMode.LITE_RUNTIME; + case -1: + case "UNRECOGNIZED": + default: + return FileOptions_OptimizeMode.UNRECOGNIZED; + } +} + +export function fileOptions_OptimizeModeToJSON( + object: FileOptions_OptimizeMode +): string { + switch (object) { + case FileOptions_OptimizeMode.SPEED: + return "SPEED"; + case FileOptions_OptimizeMode.CODE_SIZE: + return "CODE_SIZE"; + case FileOptions_OptimizeMode.LITE_RUNTIME: + return "LITE_RUNTIME"; + default: + return "UNKNOWN"; + } +} + +export interface MessageOptions { + /** + * Set true to use the old proto1 MessageSet wire format for extensions. + * This is provided for backwards-compatibility with the MessageSet wire + * format. You should not use this for any other reason: It's less + * efficient, has fewer features, and is more complicated. + * + * The message must be defined exactly as follows: + * message Foo { + * option message_set_wire_format = true; + * extensions 4 to max; + * } + * Note that the message cannot have any defined fields; MessageSets only + * have extensions. + * + * All extensions of your type must be singular messages; e.g. they cannot + * be int32s, enums, or repeated messages. + * + * Because this is an option, the above two restrictions are not enforced by + * the protocol compiler. + */ + message_set_wire_format: boolean; + /** + * Disables the generation of the standard "descriptor()" accessor, which can + * conflict with a field of the same name. This is meant to make migration + * from proto1 easier; new code should avoid fields named "descriptor". + */ + no_standard_descriptor_accessor: boolean; + /** + * Is this message deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the message, or it will be completely ignored; in the very least, + * this is a formalization for deprecating messages. + */ + deprecated: boolean; + /** + * Whether the message is an automatically generated map entry type for the + * maps field. + * + * For maps fields: + * map map_field = 1; + * The parsed descriptor looks like: + * message MapFieldEntry { + * option map_entry = true; + * optional KeyType key = 1; + * optional ValueType value = 2; + * } + * repeated MapFieldEntry map_field = 1; + * + * Implementations may choose not to generate the map_entry=true message, but + * use a native map in the target language to hold the keys and values. + * The reflection APIs in such implementations still need to work as + * if the field is a repeated message field. + * + * NOTE: Do not set the option in .proto files. Always use the maps syntax + * instead. The option should only be implicitly set by the proto compiler + * parser. + */ + map_entry: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpreted_option: UninterpretedOption[]; +} + +export interface FieldOptions { + /** + * The ctype option instructs the C++ code generator to use a different + * representation of the field than it normally would. See the specific + * options below. This option is not yet implemented in the open source + * release -- sorry, we'll try to include it in a future version! + */ + ctype: FieldOptions_CType; + /** + * The packed option can be enabled for repeated primitive fields to enable + * a more efficient representation on the wire. Rather than repeatedly + * writing the tag and type for each element, the entire array is encoded as + * a single length-delimited blob. In proto3, only explicit setting it to + * false will avoid using packed encoding. + */ + packed: boolean; + /** + * The jstype option determines the JavaScript type used for values of the + * field. The option is permitted only for 64 bit integral and fixed types + * (int64, uint64, sint64, fixed64, sfixed64). A field with jstype JS_STRING + * is represented as JavaScript string, which avoids loss of precision that + * can happen when a large value is converted to a floating point JavaScript. + * Specifying JS_NUMBER for the jstype causes the generated JavaScript code to + * use the JavaScript "number" type. The behavior of the default option + * JS_NORMAL is implementation dependent. + * + * This option is an enum to permit additional types to be added, e.g. + * goog.math.Integer. + */ + jstype: FieldOptions_JSType; + /** + * Should this field be parsed lazily? Lazy applies only to message-type + * fields. It means that when the outer message is initially parsed, the + * inner message's contents will not be parsed but instead stored in encoded + * form. The inner message will actually be parsed when it is first accessed. + * + * This is only a hint. Implementations are free to choose whether to use + * eager or lazy parsing regardless of the value of this option. However, + * setting this option true suggests that the protocol author believes that + * using lazy parsing on this field is worth the additional bookkeeping + * overhead typically needed to implement it. + * + * This option does not affect the public interface of any generated code; + * all method signatures remain the same. Furthermore, thread-safety of the + * interface is not affected by this option; const methods remain safe to + * call from multiple threads concurrently, while non-const methods continue + * to require exclusive access. + * + * + * Note that implementations may choose not to check required fields within + * a lazy sub-message. That is, calling IsInitialized() on the outer message + * may return true even if the inner message has missing required fields. + * This is necessary because otherwise the inner message would have to be + * parsed in order to perform the check, defeating the purpose of lazy + * parsing. An implementation which chooses not to check required fields + * must be consistent about it. That is, for any particular sub-message, the + * implementation must either *always* check its required fields, or *never* + * check its required fields, regardless of whether or not the message has + * been parsed. + */ + lazy: boolean; + /** + * Is this field deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for accessors, or it will be completely ignored; in the very least, this + * is a formalization for deprecating fields. + */ + deprecated: boolean; + /** For Google-internal migration only. Do not use. */ + weak: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpreted_option: UninterpretedOption[]; +} + +export enum FieldOptions_CType { + /** STRING - Default mode. */ + STRING = 0, + CORD = 1, + STRING_PIECE = 2, + UNRECOGNIZED = -1, +} + +export function fieldOptions_CTypeFromJSON(object: any): FieldOptions_CType { + switch (object) { + case 0: + case "STRING": + return FieldOptions_CType.STRING; + case 1: + case "CORD": + return FieldOptions_CType.CORD; + case 2: + case "STRING_PIECE": + return FieldOptions_CType.STRING_PIECE; + case -1: + case "UNRECOGNIZED": + default: + return FieldOptions_CType.UNRECOGNIZED; + } +} + +export function fieldOptions_CTypeToJSON(object: FieldOptions_CType): string { + switch (object) { + case FieldOptions_CType.STRING: + return "STRING"; + case FieldOptions_CType.CORD: + return "CORD"; + case FieldOptions_CType.STRING_PIECE: + return "STRING_PIECE"; + default: + return "UNKNOWN"; + } +} + +export enum FieldOptions_JSType { + /** JS_NORMAL - Use the default type. */ + JS_NORMAL = 0, + /** JS_STRING - Use JavaScript strings. */ + JS_STRING = 1, + /** JS_NUMBER - Use JavaScript numbers. */ + JS_NUMBER = 2, + UNRECOGNIZED = -1, +} + +export function fieldOptions_JSTypeFromJSON(object: any): FieldOptions_JSType { + switch (object) { + case 0: + case "JS_NORMAL": + return FieldOptions_JSType.JS_NORMAL; + case 1: + case "JS_STRING": + return FieldOptions_JSType.JS_STRING; + case 2: + case "JS_NUMBER": + return FieldOptions_JSType.JS_NUMBER; + case -1: + case "UNRECOGNIZED": + default: + return FieldOptions_JSType.UNRECOGNIZED; + } +} + +export function fieldOptions_JSTypeToJSON(object: FieldOptions_JSType): string { + switch (object) { + case FieldOptions_JSType.JS_NORMAL: + return "JS_NORMAL"; + case FieldOptions_JSType.JS_STRING: + return "JS_STRING"; + case FieldOptions_JSType.JS_NUMBER: + return "JS_NUMBER"; + default: + return "UNKNOWN"; + } +} + +export interface OneofOptions { + /** The parser stores options it doesn't recognize here. See above. */ + uninterpreted_option: UninterpretedOption[]; +} + +export interface EnumOptions { + /** + * Set this option to true to allow mapping different tag names to the same + * value. + */ + allow_alias: boolean; + /** + * Is this enum deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the enum, or it will be completely ignored; in the very least, this + * is a formalization for deprecating enums. + */ + deprecated: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpreted_option: UninterpretedOption[]; +} + +export interface EnumValueOptions { + /** + * Is this enum value deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the enum value, or it will be completely ignored; in the very least, + * this is a formalization for deprecating enum values. + */ + deprecated: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpreted_option: UninterpretedOption[]; +} + +export interface ServiceOptions { + /** + * Is this service deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the service, or it will be completely ignored; in the very least, + * this is a formalization for deprecating services. + */ + deprecated: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpreted_option: UninterpretedOption[]; +} + +export interface MethodOptions { + /** + * Is this method deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the method, or it will be completely ignored; in the very least, + * this is a formalization for deprecating methods. + */ + deprecated: boolean; + idempotency_level: MethodOptions_IdempotencyLevel; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpreted_option: UninterpretedOption[]; +} + +/** + * Is this method side-effect-free (or safe in HTTP parlance), or idempotent, + * or neither? HTTP based RPC implementation may choose GET verb for safe + * methods, and PUT verb for idempotent methods instead of the default POST. + */ +export enum MethodOptions_IdempotencyLevel { + IDEMPOTENCY_UNKNOWN = 0, + /** NO_SIDE_EFFECTS - implies idempotent */ + NO_SIDE_EFFECTS = 1, + /** IDEMPOTENT - idempotent, but may have side effects */ + IDEMPOTENT = 2, + UNRECOGNIZED = -1, +} + +export function methodOptions_IdempotencyLevelFromJSON( + object: any +): MethodOptions_IdempotencyLevel { + switch (object) { + case 0: + case "IDEMPOTENCY_UNKNOWN": + return MethodOptions_IdempotencyLevel.IDEMPOTENCY_UNKNOWN; + case 1: + case "NO_SIDE_EFFECTS": + return MethodOptions_IdempotencyLevel.NO_SIDE_EFFECTS; + case 2: + case "IDEMPOTENT": + return MethodOptions_IdempotencyLevel.IDEMPOTENT; + case -1: + case "UNRECOGNIZED": + default: + return MethodOptions_IdempotencyLevel.UNRECOGNIZED; + } +} + +export function methodOptions_IdempotencyLevelToJSON( + object: MethodOptions_IdempotencyLevel +): string { + switch (object) { + case MethodOptions_IdempotencyLevel.IDEMPOTENCY_UNKNOWN: + return "IDEMPOTENCY_UNKNOWN"; + case MethodOptions_IdempotencyLevel.NO_SIDE_EFFECTS: + return "NO_SIDE_EFFECTS"; + case MethodOptions_IdempotencyLevel.IDEMPOTENT: + return "IDEMPOTENT"; + default: + return "UNKNOWN"; + } +} + +/** + * A message representing a option the parser does not recognize. This only + * appears in options protos created by the compiler::Parser class. + * DescriptorPool resolves these when building Descriptor objects. Therefore, + * options protos in descriptor objects (e.g. returned by Descriptor::options(), + * or produced by Descriptor::CopyTo()) will never have UninterpretedOptions + * in them. + */ +export interface UninterpretedOption { + name: UninterpretedOption_NamePart[]; + /** + * The value of the uninterpreted option, in whatever type the tokenizer + * identified it as during parsing. Exactly one of these should be set. + */ + identifier_value: string; + positive_int_value: number; + negative_int_value: number; + double_value: number; + string_value: Uint8Array; + aggregate_value: string; +} + +/** + * The name of the uninterpreted option. Each string represents a segment in + * a dot-separated name. is_extension is true iff a segment represents an + * extension (denoted with parentheses in options specs in .proto files). + * E.g.,{ ["foo", false], ["bar.baz", true], ["qux", false] } represents + * "foo.(bar.baz).qux". + */ +export interface UninterpretedOption_NamePart { + name_part: string; + is_extension: boolean; +} + +/** + * Encapsulates information about the original source file from which a + * FileDescriptorProto was generated. + */ +export interface SourceCodeInfo { + /** + * A Location identifies a piece of source code in a .proto file which + * corresponds to a particular definition. This information is intended + * to be useful to IDEs, code indexers, documentation generators, and similar + * tools. + * + * For example, say we have a file like: + * message Foo { + * optional string foo = 1; + * } + * Let's look at just the field definition: + * optional string foo = 1; + * ^ ^^ ^^ ^ ^^^ + * a bc de f ghi + * We have the following locations: + * span path represents + * [a,i) [ 4, 0, 2, 0 ] The whole field definition. + * [a,b) [ 4, 0, 2, 0, 4 ] The label (optional). + * [c,d) [ 4, 0, 2, 0, 5 ] The type (string). + * [e,f) [ 4, 0, 2, 0, 1 ] The name (foo). + * [g,h) [ 4, 0, 2, 0, 3 ] The number (1). + * + * Notes: + * - A location may refer to a repeated field itself (i.e. not to any + * particular index within it). This is used whenever a set of elements are + * logically enclosed in a single code segment. For example, an entire + * extend block (possibly containing multiple extension definitions) will + * have an outer location whose path refers to the "extensions" repeated + * field without an index. + * - Multiple locations may have the same path. This happens when a single + * logical declaration is spread out across multiple places. The most + * obvious example is the "extend" block again -- there may be multiple + * extend blocks in the same scope, each of which will have the same path. + * - A location's span is not always a subset of its parent's span. For + * example, the "extendee" of an extension declaration appears at the + * beginning of the "extend" block and is shared by all extensions within + * the block. + * - Just because a location's span is a subset of some other location's span + * does not mean that it is a descendant. For example, a "group" defines + * both a type and a field in a single declaration. Thus, the locations + * corresponding to the type and field and their components will overlap. + * - Code which tries to interpret locations should probably be designed to + * ignore those that it doesn't understand, as more types of locations could + * be recorded in the future. + */ + location: SourceCodeInfo_Location[]; +} + +export interface SourceCodeInfo_Location { + /** + * Identifies which part of the FileDescriptorProto was defined at this + * location. + * + * Each element is a field number or an index. They form a path from + * the root FileDescriptorProto to the place where the definition. For + * example, this path: + * [ 4, 3, 2, 7, 1 ] + * refers to: + * file.message_type(3) // 4, 3 + * .field(7) // 2, 7 + * .name() // 1 + * This is because FileDescriptorProto.message_type has field number 4: + * repeated DescriptorProto message_type = 4; + * and DescriptorProto.field has field number 2: + * repeated FieldDescriptorProto field = 2; + * and FieldDescriptorProto.name has field number 1: + * optional string name = 1; + * + * Thus, the above path gives the location of a field name. If we removed + * the last element: + * [ 4, 3, 2, 7 ] + * this path refers to the whole field declaration (from the beginning + * of the label to the terminating semicolon). + */ + path: number[]; + /** + * Always has exactly three or four elements: start line, start column, + * end line (optional, otherwise assumed same as start line), end column. + * These are packed into a single field for efficiency. Note that line + * and column numbers are zero-based -- typically you will want to add + * 1 to each before displaying to a user. + */ + span: number[]; + /** + * If this SourceCodeInfo represents a complete declaration, these are any + * comments appearing before and after the declaration which appear to be + * attached to the declaration. + * + * A series of line comments appearing on consecutive lines, with no other + * tokens appearing on those lines, will be treated as a single comment. + * + * leading_detached_comments will keep paragraphs of comments that appear + * before (but not connected to) the current element. Each paragraph, + * separated by empty lines, will be one comment element in the repeated + * field. + * + * Only the comment content is provided; comment markers (e.g. //) are + * stripped out. For block comments, leading whitespace and an asterisk + * will be stripped from the beginning of each line other than the first. + * Newlines are included in the output. + * + * Examples: + * + * optional int32 foo = 1; // Comment attached to foo. + * // Comment attached to bar. + * optional int32 bar = 2; + * + * optional string baz = 3; + * // Comment attached to baz. + * // Another line attached to baz. + * + * // Comment attached to qux. + * // + * // Another line attached to qux. + * optional double qux = 4; + * + * // Detached comment for corge. This is not leading or trailing comments + * // to qux or corge because there are blank lines separating it from + * // both. + * + * // Detached comment for corge paragraph 2. + * + * optional string corge = 5; + * /* Block comment attached + * * to corge. Leading asterisks + * * will be removed. * / + * /* Block comment attached to + * * grault. * / + * optional int32 grault = 6; + * + * // ignored detached comments. + */ + leading_comments: string; + trailing_comments: string; + leading_detached_comments: string[]; +} + +/** + * Describes the relationship between generated code and its original source + * file. A GeneratedCodeInfo message is associated with only one generated + * source file, but may contain references to different source .proto files. + */ +export interface GeneratedCodeInfo { + /** + * An Annotation connects some span of text in generated code to an element + * of its generating .proto file. + */ + annotation: GeneratedCodeInfo_Annotation[]; +} + +export interface GeneratedCodeInfo_Annotation { + /** + * Identifies the element in the original source .proto file. This field + * is formatted the same as SourceCodeInfo.Location.path. + */ + path: number[]; + /** Identifies the filesystem path to the original source .proto. */ + source_file: string; + /** + * Identifies the starting offset in bytes in the generated code + * that relates to the identified object. + */ + begin: number; + /** + * Identifies the ending offset in bytes in the generated code that + * relates to the identified offset. The end offset should be one past + * the last relevant byte (so the length of the text = end - begin). + */ + end: number; +} + +const baseFileDescriptorSet: object = {}; + +export const FileDescriptorSet = { + encode(message: FileDescriptorSet, writer: Writer = Writer.create()): Writer { + for (const v of message.file) { + FileDescriptorProto.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FileDescriptorSet { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFileDescriptorSet } as FileDescriptorSet; + message.file = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.file.push( + FileDescriptorProto.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FileDescriptorSet { + const message = { ...baseFileDescriptorSet } as FileDescriptorSet; + message.file = []; + if (object.file !== undefined && object.file !== null) { + for (const e of object.file) { + message.file.push(FileDescriptorProto.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: FileDescriptorSet): unknown { + const obj: any = {}; + if (message.file) { + obj.file = message.file.map((e) => + e ? FileDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.file = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): FileDescriptorSet { + const message = { ...baseFileDescriptorSet } as FileDescriptorSet; + message.file = []; + if (object.file !== undefined && object.file !== null) { + for (const e of object.file) { + message.file.push(FileDescriptorProto.fromPartial(e)); + } + } + return message; + }, +}; + +const baseFileDescriptorProto: object = { + name: "", + package: "", + dependency: "", + public_dependency: 0, + weak_dependency: 0, + syntax: "", +}; + +export const FileDescriptorProto = { + encode( + message: FileDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.package !== "") { + writer.uint32(18).string(message.package); + } + for (const v of message.dependency) { + writer.uint32(26).string(v!); + } + writer.uint32(82).fork(); + for (const v of message.public_dependency) { + writer.int32(v); + } + writer.ldelim(); + writer.uint32(90).fork(); + for (const v of message.weak_dependency) { + writer.int32(v); + } + writer.ldelim(); + for (const v of message.message_type) { + DescriptorProto.encode(v!, writer.uint32(34).fork()).ldelim(); + } + for (const v of message.enum_type) { + EnumDescriptorProto.encode(v!, writer.uint32(42).fork()).ldelim(); + } + for (const v of message.service) { + ServiceDescriptorProto.encode(v!, writer.uint32(50).fork()).ldelim(); + } + for (const v of message.extension) { + FieldDescriptorProto.encode(v!, writer.uint32(58).fork()).ldelim(); + } + if (message.options !== undefined) { + FileOptions.encode(message.options, writer.uint32(66).fork()).ldelim(); + } + if (message.source_code_info !== undefined) { + SourceCodeInfo.encode( + message.source_code_info, + writer.uint32(74).fork() + ).ldelim(); + } + if (message.syntax !== "") { + writer.uint32(98).string(message.syntax); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FileDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFileDescriptorProto } as FileDescriptorProto; + message.dependency = []; + message.public_dependency = []; + message.weak_dependency = []; + message.message_type = []; + message.enum_type = []; + message.service = []; + message.extension = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.package = reader.string(); + break; + case 3: + message.dependency.push(reader.string()); + break; + case 10: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.public_dependency.push(reader.int32()); + } + } else { + message.public_dependency.push(reader.int32()); + } + break; + case 11: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.weak_dependency.push(reader.int32()); + } + } else { + message.weak_dependency.push(reader.int32()); + } + break; + case 4: + message.message_type.push( + DescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 5: + message.enum_type.push( + EnumDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 6: + message.service.push( + ServiceDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 7: + message.extension.push( + FieldDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 8: + message.options = FileOptions.decode(reader, reader.uint32()); + break; + case 9: + message.source_code_info = SourceCodeInfo.decode( + reader, + reader.uint32() + ); + break; + case 12: + message.syntax = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FileDescriptorProto { + const message = { ...baseFileDescriptorProto } as FileDescriptorProto; + message.dependency = []; + message.public_dependency = []; + message.weak_dependency = []; + message.message_type = []; + message.enum_type = []; + message.service = []; + message.extension = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.package !== undefined && object.package !== null) { + message.package = String(object.package); + } else { + message.package = ""; + } + if (object.dependency !== undefined && object.dependency !== null) { + for (const e of object.dependency) { + message.dependency.push(String(e)); + } + } + if ( + object.public_dependency !== undefined && + object.public_dependency !== null + ) { + for (const e of object.public_dependency) { + message.public_dependency.push(Number(e)); + } + } + if ( + object.weak_dependency !== undefined && + object.weak_dependency !== null + ) { + for (const e of object.weak_dependency) { + message.weak_dependency.push(Number(e)); + } + } + if (object.message_type !== undefined && object.message_type !== null) { + for (const e of object.message_type) { + message.message_type.push(DescriptorProto.fromJSON(e)); + } + } + if (object.enum_type !== undefined && object.enum_type !== null) { + for (const e of object.enum_type) { + message.enum_type.push(EnumDescriptorProto.fromJSON(e)); + } + } + if (object.service !== undefined && object.service !== null) { + for (const e of object.service) { + message.service.push(ServiceDescriptorProto.fromJSON(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = FileOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if ( + object.source_code_info !== undefined && + object.source_code_info !== null + ) { + message.source_code_info = SourceCodeInfo.fromJSON( + object.source_code_info + ); + } else { + message.source_code_info = undefined; + } + if (object.syntax !== undefined && object.syntax !== null) { + message.syntax = String(object.syntax); + } else { + message.syntax = ""; + } + return message; + }, + + toJSON(message: FileDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.package !== undefined && (obj.package = message.package); + if (message.dependency) { + obj.dependency = message.dependency.map((e) => e); + } else { + obj.dependency = []; + } + if (message.public_dependency) { + obj.public_dependency = message.public_dependency.map((e) => e); + } else { + obj.public_dependency = []; + } + if (message.weak_dependency) { + obj.weak_dependency = message.weak_dependency.map((e) => e); + } else { + obj.weak_dependency = []; + } + if (message.message_type) { + obj.message_type = message.message_type.map((e) => + e ? DescriptorProto.toJSON(e) : undefined + ); + } else { + obj.message_type = []; + } + if (message.enum_type) { + obj.enum_type = message.enum_type.map((e) => + e ? EnumDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.enum_type = []; + } + if (message.service) { + obj.service = message.service.map((e) => + e ? ServiceDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.service = []; + } + if (message.extension) { + obj.extension = message.extension.map((e) => + e ? FieldDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.extension = []; + } + message.options !== undefined && + (obj.options = message.options + ? FileOptions.toJSON(message.options) + : undefined); + message.source_code_info !== undefined && + (obj.source_code_info = message.source_code_info + ? SourceCodeInfo.toJSON(message.source_code_info) + : undefined); + message.syntax !== undefined && (obj.syntax = message.syntax); + return obj; + }, + + fromPartial(object: DeepPartial): FileDescriptorProto { + const message = { ...baseFileDescriptorProto } as FileDescriptorProto; + message.dependency = []; + message.public_dependency = []; + message.weak_dependency = []; + message.message_type = []; + message.enum_type = []; + message.service = []; + message.extension = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.package !== undefined && object.package !== null) { + message.package = object.package; + } else { + message.package = ""; + } + if (object.dependency !== undefined && object.dependency !== null) { + for (const e of object.dependency) { + message.dependency.push(e); + } + } + if ( + object.public_dependency !== undefined && + object.public_dependency !== null + ) { + for (const e of object.public_dependency) { + message.public_dependency.push(e); + } + } + if ( + object.weak_dependency !== undefined && + object.weak_dependency !== null + ) { + for (const e of object.weak_dependency) { + message.weak_dependency.push(e); + } + } + if (object.message_type !== undefined && object.message_type !== null) { + for (const e of object.message_type) { + message.message_type.push(DescriptorProto.fromPartial(e)); + } + } + if (object.enum_type !== undefined && object.enum_type !== null) { + for (const e of object.enum_type) { + message.enum_type.push(EnumDescriptorProto.fromPartial(e)); + } + } + if (object.service !== undefined && object.service !== null) { + for (const e of object.service) { + message.service.push(ServiceDescriptorProto.fromPartial(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = FileOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if ( + object.source_code_info !== undefined && + object.source_code_info !== null + ) { + message.source_code_info = SourceCodeInfo.fromPartial( + object.source_code_info + ); + } else { + message.source_code_info = undefined; + } + if (object.syntax !== undefined && object.syntax !== null) { + message.syntax = object.syntax; + } else { + message.syntax = ""; + } + return message; + }, +}; + +const baseDescriptorProto: object = { name: "", reserved_name: "" }; + +export const DescriptorProto = { + encode(message: DescriptorProto, writer: Writer = Writer.create()): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + for (const v of message.field) { + FieldDescriptorProto.encode(v!, writer.uint32(18).fork()).ldelim(); + } + for (const v of message.extension) { + FieldDescriptorProto.encode(v!, writer.uint32(50).fork()).ldelim(); + } + for (const v of message.nested_type) { + DescriptorProto.encode(v!, writer.uint32(26).fork()).ldelim(); + } + for (const v of message.enum_type) { + EnumDescriptorProto.encode(v!, writer.uint32(34).fork()).ldelim(); + } + for (const v of message.extension_range) { + DescriptorProto_ExtensionRange.encode( + v!, + writer.uint32(42).fork() + ).ldelim(); + } + for (const v of message.oneof_decl) { + OneofDescriptorProto.encode(v!, writer.uint32(66).fork()).ldelim(); + } + if (message.options !== undefined) { + MessageOptions.encode(message.options, writer.uint32(58).fork()).ldelim(); + } + for (const v of message.reserved_range) { + DescriptorProto_ReservedRange.encode( + v!, + writer.uint32(74).fork() + ).ldelim(); + } + for (const v of message.reserved_name) { + writer.uint32(82).string(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): DescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseDescriptorProto } as DescriptorProto; + message.field = []; + message.extension = []; + message.nested_type = []; + message.enum_type = []; + message.extension_range = []; + message.oneof_decl = []; + message.reserved_range = []; + message.reserved_name = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.field.push( + FieldDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 6: + message.extension.push( + FieldDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 3: + message.nested_type.push( + DescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 4: + message.enum_type.push( + EnumDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 5: + message.extension_range.push( + DescriptorProto_ExtensionRange.decode(reader, reader.uint32()) + ); + break; + case 8: + message.oneof_decl.push( + OneofDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 7: + message.options = MessageOptions.decode(reader, reader.uint32()); + break; + case 9: + message.reserved_range.push( + DescriptorProto_ReservedRange.decode(reader, reader.uint32()) + ); + break; + case 10: + message.reserved_name.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DescriptorProto { + const message = { ...baseDescriptorProto } as DescriptorProto; + message.field = []; + message.extension = []; + message.nested_type = []; + message.enum_type = []; + message.extension_range = []; + message.oneof_decl = []; + message.reserved_range = []; + message.reserved_name = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.field !== undefined && object.field !== null) { + for (const e of object.field) { + message.field.push(FieldDescriptorProto.fromJSON(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromJSON(e)); + } + } + if (object.nested_type !== undefined && object.nested_type !== null) { + for (const e of object.nested_type) { + message.nested_type.push(DescriptorProto.fromJSON(e)); + } + } + if (object.enum_type !== undefined && object.enum_type !== null) { + for (const e of object.enum_type) { + message.enum_type.push(EnumDescriptorProto.fromJSON(e)); + } + } + if ( + object.extension_range !== undefined && + object.extension_range !== null + ) { + for (const e of object.extension_range) { + message.extension_range.push( + DescriptorProto_ExtensionRange.fromJSON(e) + ); + } + } + if (object.oneof_decl !== undefined && object.oneof_decl !== null) { + for (const e of object.oneof_decl) { + message.oneof_decl.push(OneofDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = MessageOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.reserved_range !== undefined && object.reserved_range !== null) { + for (const e of object.reserved_range) { + message.reserved_range.push(DescriptorProto_ReservedRange.fromJSON(e)); + } + } + if (object.reserved_name !== undefined && object.reserved_name !== null) { + for (const e of object.reserved_name) { + message.reserved_name.push(String(e)); + } + } + return message; + }, + + toJSON(message: DescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + if (message.field) { + obj.field = message.field.map((e) => + e ? FieldDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.field = []; + } + if (message.extension) { + obj.extension = message.extension.map((e) => + e ? FieldDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.extension = []; + } + if (message.nested_type) { + obj.nested_type = message.nested_type.map((e) => + e ? DescriptorProto.toJSON(e) : undefined + ); + } else { + obj.nested_type = []; + } + if (message.enum_type) { + obj.enum_type = message.enum_type.map((e) => + e ? EnumDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.enum_type = []; + } + if (message.extension_range) { + obj.extension_range = message.extension_range.map((e) => + e ? DescriptorProto_ExtensionRange.toJSON(e) : undefined + ); + } else { + obj.extension_range = []; + } + if (message.oneof_decl) { + obj.oneof_decl = message.oneof_decl.map((e) => + e ? OneofDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.oneof_decl = []; + } + message.options !== undefined && + (obj.options = message.options + ? MessageOptions.toJSON(message.options) + : undefined); + if (message.reserved_range) { + obj.reserved_range = message.reserved_range.map((e) => + e ? DescriptorProto_ReservedRange.toJSON(e) : undefined + ); + } else { + obj.reserved_range = []; + } + if (message.reserved_name) { + obj.reserved_name = message.reserved_name.map((e) => e); + } else { + obj.reserved_name = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): DescriptorProto { + const message = { ...baseDescriptorProto } as DescriptorProto; + message.field = []; + message.extension = []; + message.nested_type = []; + message.enum_type = []; + message.extension_range = []; + message.oneof_decl = []; + message.reserved_range = []; + message.reserved_name = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.field !== undefined && object.field !== null) { + for (const e of object.field) { + message.field.push(FieldDescriptorProto.fromPartial(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromPartial(e)); + } + } + if (object.nested_type !== undefined && object.nested_type !== null) { + for (const e of object.nested_type) { + message.nested_type.push(DescriptorProto.fromPartial(e)); + } + } + if (object.enum_type !== undefined && object.enum_type !== null) { + for (const e of object.enum_type) { + message.enum_type.push(EnumDescriptorProto.fromPartial(e)); + } + } + if ( + object.extension_range !== undefined && + object.extension_range !== null + ) { + for (const e of object.extension_range) { + message.extension_range.push( + DescriptorProto_ExtensionRange.fromPartial(e) + ); + } + } + if (object.oneof_decl !== undefined && object.oneof_decl !== null) { + for (const e of object.oneof_decl) { + message.oneof_decl.push(OneofDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = MessageOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.reserved_range !== undefined && object.reserved_range !== null) { + for (const e of object.reserved_range) { + message.reserved_range.push( + DescriptorProto_ReservedRange.fromPartial(e) + ); + } + } + if (object.reserved_name !== undefined && object.reserved_name !== null) { + for (const e of object.reserved_name) { + message.reserved_name.push(e); + } + } + return message; + }, +}; + +const baseDescriptorProto_ExtensionRange: object = { start: 0, end: 0 }; + +export const DescriptorProto_ExtensionRange = { + encode( + message: DescriptorProto_ExtensionRange, + writer: Writer = Writer.create() + ): Writer { + if (message.start !== 0) { + writer.uint32(8).int32(message.start); + } + if (message.end !== 0) { + writer.uint32(16).int32(message.end); + } + if (message.options !== undefined) { + ExtensionRangeOptions.encode( + message.options, + writer.uint32(26).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): DescriptorProto_ExtensionRange { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseDescriptorProto_ExtensionRange, + } as DescriptorProto_ExtensionRange; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.start = reader.int32(); + break; + case 2: + message.end = reader.int32(); + break; + case 3: + message.options = ExtensionRangeOptions.decode( + reader, + reader.uint32() + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DescriptorProto_ExtensionRange { + const message = { + ...baseDescriptorProto_ExtensionRange, + } as DescriptorProto_ExtensionRange; + if (object.start !== undefined && object.start !== null) { + message.start = Number(object.start); + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = ExtensionRangeOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: DescriptorProto_ExtensionRange): unknown { + const obj: any = {}; + message.start !== undefined && (obj.start = message.start); + message.end !== undefined && (obj.end = message.end); + message.options !== undefined && + (obj.options = message.options + ? ExtensionRangeOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): DescriptorProto_ExtensionRange { + const message = { + ...baseDescriptorProto_ExtensionRange, + } as DescriptorProto_ExtensionRange; + if (object.start !== undefined && object.start !== null) { + message.start = object.start; + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = ExtensionRangeOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseDescriptorProto_ReservedRange: object = { start: 0, end: 0 }; + +export const DescriptorProto_ReservedRange = { + encode( + message: DescriptorProto_ReservedRange, + writer: Writer = Writer.create() + ): Writer { + if (message.start !== 0) { + writer.uint32(8).int32(message.start); + } + if (message.end !== 0) { + writer.uint32(16).int32(message.end); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): DescriptorProto_ReservedRange { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseDescriptorProto_ReservedRange, + } as DescriptorProto_ReservedRange; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.start = reader.int32(); + break; + case 2: + message.end = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DescriptorProto_ReservedRange { + const message = { + ...baseDescriptorProto_ReservedRange, + } as DescriptorProto_ReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = Number(object.start); + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + return message; + }, + + toJSON(message: DescriptorProto_ReservedRange): unknown { + const obj: any = {}; + message.start !== undefined && (obj.start = message.start); + message.end !== undefined && (obj.end = message.end); + return obj; + }, + + fromPartial( + object: DeepPartial + ): DescriptorProto_ReservedRange { + const message = { + ...baseDescriptorProto_ReservedRange, + } as DescriptorProto_ReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = object.start; + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + return message; + }, +}; + +const baseExtensionRangeOptions: object = {}; + +export const ExtensionRangeOptions = { + encode( + message: ExtensionRangeOptions, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.uninterpreted_option) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ExtensionRangeOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseExtensionRangeOptions } as ExtensionRangeOptions; + message.uninterpreted_option = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 999: + message.uninterpreted_option.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ExtensionRangeOptions { + const message = { ...baseExtensionRangeOptions } as ExtensionRangeOptions; + message.uninterpreted_option = []; + if ( + object.uninterpreted_option !== undefined && + object.uninterpreted_option !== null + ) { + for (const e of object.uninterpreted_option) { + message.uninterpreted_option.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: ExtensionRangeOptions): unknown { + const obj: any = {}; + if (message.uninterpreted_option) { + obj.uninterpreted_option = message.uninterpreted_option.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpreted_option = []; + } + return obj; + }, + + fromPartial( + object: DeepPartial + ): ExtensionRangeOptions { + const message = { ...baseExtensionRangeOptions } as ExtensionRangeOptions; + message.uninterpreted_option = []; + if ( + object.uninterpreted_option !== undefined && + object.uninterpreted_option !== null + ) { + for (const e of object.uninterpreted_option) { + message.uninterpreted_option.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseFieldDescriptorProto: object = { + name: "", + number: 0, + label: 1, + type: 1, + type_name: "", + extendee: "", + default_value: "", + oneof_index: 0, + json_name: "", + proto3_optional: false, +}; + +export const FieldDescriptorProto = { + encode( + message: FieldDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.number !== 0) { + writer.uint32(24).int32(message.number); + } + if (message.label !== 1) { + writer.uint32(32).int32(message.label); + } + if (message.type !== 1) { + writer.uint32(40).int32(message.type); + } + if (message.type_name !== "") { + writer.uint32(50).string(message.type_name); + } + if (message.extendee !== "") { + writer.uint32(18).string(message.extendee); + } + if (message.default_value !== "") { + writer.uint32(58).string(message.default_value); + } + if (message.oneof_index !== 0) { + writer.uint32(72).int32(message.oneof_index); + } + if (message.json_name !== "") { + writer.uint32(82).string(message.json_name); + } + if (message.options !== undefined) { + FieldOptions.encode(message.options, writer.uint32(66).fork()).ldelim(); + } + if (message.proto3_optional === true) { + writer.uint32(136).bool(message.proto3_optional); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FieldDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFieldDescriptorProto } as FieldDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 3: + message.number = reader.int32(); + break; + case 4: + message.label = reader.int32() as any; + break; + case 5: + message.type = reader.int32() as any; + break; + case 6: + message.type_name = reader.string(); + break; + case 2: + message.extendee = reader.string(); + break; + case 7: + message.default_value = reader.string(); + break; + case 9: + message.oneof_index = reader.int32(); + break; + case 10: + message.json_name = reader.string(); + break; + case 8: + message.options = FieldOptions.decode(reader, reader.uint32()); + break; + case 17: + message.proto3_optional = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FieldDescriptorProto { + const message = { ...baseFieldDescriptorProto } as FieldDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = Number(object.number); + } else { + message.number = 0; + } + if (object.label !== undefined && object.label !== null) { + message.label = fieldDescriptorProto_LabelFromJSON(object.label); + } else { + message.label = 1; + } + if (object.type !== undefined && object.type !== null) { + message.type = fieldDescriptorProto_TypeFromJSON(object.type); + } else { + message.type = 1; + } + if (object.type_name !== undefined && object.type_name !== null) { + message.type_name = String(object.type_name); + } else { + message.type_name = ""; + } + if (object.extendee !== undefined && object.extendee !== null) { + message.extendee = String(object.extendee); + } else { + message.extendee = ""; + } + if (object.default_value !== undefined && object.default_value !== null) { + message.default_value = String(object.default_value); + } else { + message.default_value = ""; + } + if (object.oneof_index !== undefined && object.oneof_index !== null) { + message.oneof_index = Number(object.oneof_index); + } else { + message.oneof_index = 0; + } + if (object.json_name !== undefined && object.json_name !== null) { + message.json_name = String(object.json_name); + } else { + message.json_name = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = FieldOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if ( + object.proto3_optional !== undefined && + object.proto3_optional !== null + ) { + message.proto3_optional = Boolean(object.proto3_optional); + } else { + message.proto3_optional = false; + } + return message; + }, + + toJSON(message: FieldDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.number !== undefined && (obj.number = message.number); + message.label !== undefined && + (obj.label = fieldDescriptorProto_LabelToJSON(message.label)); + message.type !== undefined && + (obj.type = fieldDescriptorProto_TypeToJSON(message.type)); + message.type_name !== undefined && (obj.type_name = message.type_name); + message.extendee !== undefined && (obj.extendee = message.extendee); + message.default_value !== undefined && + (obj.default_value = message.default_value); + message.oneof_index !== undefined && + (obj.oneof_index = message.oneof_index); + message.json_name !== undefined && (obj.json_name = message.json_name); + message.options !== undefined && + (obj.options = message.options + ? FieldOptions.toJSON(message.options) + : undefined); + message.proto3_optional !== undefined && + (obj.proto3_optional = message.proto3_optional); + return obj; + }, + + fromPartial(object: DeepPartial): FieldDescriptorProto { + const message = { ...baseFieldDescriptorProto } as FieldDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = object.number; + } else { + message.number = 0; + } + if (object.label !== undefined && object.label !== null) { + message.label = object.label; + } else { + message.label = 1; + } + if (object.type !== undefined && object.type !== null) { + message.type = object.type; + } else { + message.type = 1; + } + if (object.type_name !== undefined && object.type_name !== null) { + message.type_name = object.type_name; + } else { + message.type_name = ""; + } + if (object.extendee !== undefined && object.extendee !== null) { + message.extendee = object.extendee; + } else { + message.extendee = ""; + } + if (object.default_value !== undefined && object.default_value !== null) { + message.default_value = object.default_value; + } else { + message.default_value = ""; + } + if (object.oneof_index !== undefined && object.oneof_index !== null) { + message.oneof_index = object.oneof_index; + } else { + message.oneof_index = 0; + } + if (object.json_name !== undefined && object.json_name !== null) { + message.json_name = object.json_name; + } else { + message.json_name = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = FieldOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if ( + object.proto3_optional !== undefined && + object.proto3_optional !== null + ) { + message.proto3_optional = object.proto3_optional; + } else { + message.proto3_optional = false; + } + return message; + }, +}; + +const baseOneofDescriptorProto: object = { name: "" }; + +export const OneofDescriptorProto = { + encode( + message: OneofDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.options !== undefined) { + OneofOptions.encode(message.options, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): OneofDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseOneofDescriptorProto } as OneofDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.options = OneofOptions.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): OneofDescriptorProto { + const message = { ...baseOneofDescriptorProto } as OneofDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = OneofOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: OneofDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.options !== undefined && + (obj.options = message.options + ? OneofOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): OneofDescriptorProto { + const message = { ...baseOneofDescriptorProto } as OneofDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = OneofOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseEnumDescriptorProto: object = { name: "", reserved_name: "" }; + +export const EnumDescriptorProto = { + encode( + message: EnumDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + for (const v of message.value) { + EnumValueDescriptorProto.encode(v!, writer.uint32(18).fork()).ldelim(); + } + if (message.options !== undefined) { + EnumOptions.encode(message.options, writer.uint32(26).fork()).ldelim(); + } + for (const v of message.reserved_range) { + EnumDescriptorProto_EnumReservedRange.encode( + v!, + writer.uint32(34).fork() + ).ldelim(); + } + for (const v of message.reserved_name) { + writer.uint32(42).string(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): EnumDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseEnumDescriptorProto } as EnumDescriptorProto; + message.value = []; + message.reserved_range = []; + message.reserved_name = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.value.push( + EnumValueDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 3: + message.options = EnumOptions.decode(reader, reader.uint32()); + break; + case 4: + message.reserved_range.push( + EnumDescriptorProto_EnumReservedRange.decode( + reader, + reader.uint32() + ) + ); + break; + case 5: + message.reserved_name.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumDescriptorProto { + const message = { ...baseEnumDescriptorProto } as EnumDescriptorProto; + message.value = []; + message.reserved_range = []; + message.reserved_name = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.value !== undefined && object.value !== null) { + for (const e of object.value) { + message.value.push(EnumValueDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.reserved_range !== undefined && object.reserved_range !== null) { + for (const e of object.reserved_range) { + message.reserved_range.push( + EnumDescriptorProto_EnumReservedRange.fromJSON(e) + ); + } + } + if (object.reserved_name !== undefined && object.reserved_name !== null) { + for (const e of object.reserved_name) { + message.reserved_name.push(String(e)); + } + } + return message; + }, + + toJSON(message: EnumDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + if (message.value) { + obj.value = message.value.map((e) => + e ? EnumValueDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.value = []; + } + message.options !== undefined && + (obj.options = message.options + ? EnumOptions.toJSON(message.options) + : undefined); + if (message.reserved_range) { + obj.reserved_range = message.reserved_range.map((e) => + e ? EnumDescriptorProto_EnumReservedRange.toJSON(e) : undefined + ); + } else { + obj.reserved_range = []; + } + if (message.reserved_name) { + obj.reserved_name = message.reserved_name.map((e) => e); + } else { + obj.reserved_name = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): EnumDescriptorProto { + const message = { ...baseEnumDescriptorProto } as EnumDescriptorProto; + message.value = []; + message.reserved_range = []; + message.reserved_name = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.value !== undefined && object.value !== null) { + for (const e of object.value) { + message.value.push(EnumValueDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.reserved_range !== undefined && object.reserved_range !== null) { + for (const e of object.reserved_range) { + message.reserved_range.push( + EnumDescriptorProto_EnumReservedRange.fromPartial(e) + ); + } + } + if (object.reserved_name !== undefined && object.reserved_name !== null) { + for (const e of object.reserved_name) { + message.reserved_name.push(e); + } + } + return message; + }, +}; + +const baseEnumDescriptorProto_EnumReservedRange: object = { start: 0, end: 0 }; + +export const EnumDescriptorProto_EnumReservedRange = { + encode( + message: EnumDescriptorProto_EnumReservedRange, + writer: Writer = Writer.create() + ): Writer { + if (message.start !== 0) { + writer.uint32(8).int32(message.start); + } + if (message.end !== 0) { + writer.uint32(16).int32(message.end); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): EnumDescriptorProto_EnumReservedRange { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseEnumDescriptorProto_EnumReservedRange, + } as EnumDescriptorProto_EnumReservedRange; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.start = reader.int32(); + break; + case 2: + message.end = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumDescriptorProto_EnumReservedRange { + const message = { + ...baseEnumDescriptorProto_EnumReservedRange, + } as EnumDescriptorProto_EnumReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = Number(object.start); + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + return message; + }, + + toJSON(message: EnumDescriptorProto_EnumReservedRange): unknown { + const obj: any = {}; + message.start !== undefined && (obj.start = message.start); + message.end !== undefined && (obj.end = message.end); + return obj; + }, + + fromPartial( + object: DeepPartial + ): EnumDescriptorProto_EnumReservedRange { + const message = { + ...baseEnumDescriptorProto_EnumReservedRange, + } as EnumDescriptorProto_EnumReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = object.start; + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + return message; + }, +}; + +const baseEnumValueDescriptorProto: object = { name: "", number: 0 }; + +export const EnumValueDescriptorProto = { + encode( + message: EnumValueDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.number !== 0) { + writer.uint32(16).int32(message.number); + } + if (message.options !== undefined) { + EnumValueOptions.encode( + message.options, + writer.uint32(26).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): EnumValueDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseEnumValueDescriptorProto, + } as EnumValueDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.number = reader.int32(); + break; + case 3: + message.options = EnumValueOptions.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumValueDescriptorProto { + const message = { + ...baseEnumValueDescriptorProto, + } as EnumValueDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = Number(object.number); + } else { + message.number = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumValueOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: EnumValueDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.number !== undefined && (obj.number = message.number); + message.options !== undefined && + (obj.options = message.options + ? EnumValueOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): EnumValueDescriptorProto { + const message = { + ...baseEnumValueDescriptorProto, + } as EnumValueDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = object.number; + } else { + message.number = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumValueOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseServiceDescriptorProto: object = { name: "" }; + +export const ServiceDescriptorProto = { + encode( + message: ServiceDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + for (const v of message.method) { + MethodDescriptorProto.encode(v!, writer.uint32(18).fork()).ldelim(); + } + if (message.options !== undefined) { + ServiceOptions.encode(message.options, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ServiceDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseServiceDescriptorProto } as ServiceDescriptorProto; + message.method = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.method.push( + MethodDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 3: + message.options = ServiceOptions.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ServiceDescriptorProto { + const message = { ...baseServiceDescriptorProto } as ServiceDescriptorProto; + message.method = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.method !== undefined && object.method !== null) { + for (const e of object.method) { + message.method.push(MethodDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = ServiceOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: ServiceDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + if (message.method) { + obj.method = message.method.map((e) => + e ? MethodDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.method = []; + } + message.options !== undefined && + (obj.options = message.options + ? ServiceOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): ServiceDescriptorProto { + const message = { ...baseServiceDescriptorProto } as ServiceDescriptorProto; + message.method = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.method !== undefined && object.method !== null) { + for (const e of object.method) { + message.method.push(MethodDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = ServiceOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseMethodDescriptorProto: object = { + name: "", + input_type: "", + output_type: "", + client_streaming: false, + server_streaming: false, +}; + +export const MethodDescriptorProto = { + encode( + message: MethodDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.input_type !== "") { + writer.uint32(18).string(message.input_type); + } + if (message.output_type !== "") { + writer.uint32(26).string(message.output_type); + } + if (message.options !== undefined) { + MethodOptions.encode(message.options, writer.uint32(34).fork()).ldelim(); + } + if (message.client_streaming === true) { + writer.uint32(40).bool(message.client_streaming); + } + if (message.server_streaming === true) { + writer.uint32(48).bool(message.server_streaming); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MethodDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMethodDescriptorProto } as MethodDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.input_type = reader.string(); + break; + case 3: + message.output_type = reader.string(); + break; + case 4: + message.options = MethodOptions.decode(reader, reader.uint32()); + break; + case 5: + message.client_streaming = reader.bool(); + break; + case 6: + message.server_streaming = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MethodDescriptorProto { + const message = { ...baseMethodDescriptorProto } as MethodDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.input_type !== undefined && object.input_type !== null) { + message.input_type = String(object.input_type); + } else { + message.input_type = ""; + } + if (object.output_type !== undefined && object.output_type !== null) { + message.output_type = String(object.output_type); + } else { + message.output_type = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = MethodOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if ( + object.client_streaming !== undefined && + object.client_streaming !== null + ) { + message.client_streaming = Boolean(object.client_streaming); + } else { + message.client_streaming = false; + } + if ( + object.server_streaming !== undefined && + object.server_streaming !== null + ) { + message.server_streaming = Boolean(object.server_streaming); + } else { + message.server_streaming = false; + } + return message; + }, + + toJSON(message: MethodDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.input_type !== undefined && (obj.input_type = message.input_type); + message.output_type !== undefined && + (obj.output_type = message.output_type); + message.options !== undefined && + (obj.options = message.options + ? MethodOptions.toJSON(message.options) + : undefined); + message.client_streaming !== undefined && + (obj.client_streaming = message.client_streaming); + message.server_streaming !== undefined && + (obj.server_streaming = message.server_streaming); + return obj; + }, + + fromPartial( + object: DeepPartial + ): MethodDescriptorProto { + const message = { ...baseMethodDescriptorProto } as MethodDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.input_type !== undefined && object.input_type !== null) { + message.input_type = object.input_type; + } else { + message.input_type = ""; + } + if (object.output_type !== undefined && object.output_type !== null) { + message.output_type = object.output_type; + } else { + message.output_type = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = MethodOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if ( + object.client_streaming !== undefined && + object.client_streaming !== null + ) { + message.client_streaming = object.client_streaming; + } else { + message.client_streaming = false; + } + if ( + object.server_streaming !== undefined && + object.server_streaming !== null + ) { + message.server_streaming = object.server_streaming; + } else { + message.server_streaming = false; + } + return message; + }, +}; + +const baseFileOptions: object = { + java_package: "", + java_outer_classname: "", + java_multiple_files: false, + java_generate_equals_and_hash: false, + java_string_check_utf8: false, + optimize_for: 1, + go_package: "", + cc_generic_services: false, + java_generic_services: false, + py_generic_services: false, + php_generic_services: false, + deprecated: false, + cc_enable_arenas: false, + objc_class_prefix: "", + csharp_namespace: "", + swift_prefix: "", + php_class_prefix: "", + php_namespace: "", + php_metadata_namespace: "", + ruby_package: "", +}; + +export const FileOptions = { + encode(message: FileOptions, writer: Writer = Writer.create()): Writer { + if (message.java_package !== "") { + writer.uint32(10).string(message.java_package); + } + if (message.java_outer_classname !== "") { + writer.uint32(66).string(message.java_outer_classname); + } + if (message.java_multiple_files === true) { + writer.uint32(80).bool(message.java_multiple_files); + } + if (message.java_generate_equals_and_hash === true) { + writer.uint32(160).bool(message.java_generate_equals_and_hash); + } + if (message.java_string_check_utf8 === true) { + writer.uint32(216).bool(message.java_string_check_utf8); + } + if (message.optimize_for !== 1) { + writer.uint32(72).int32(message.optimize_for); + } + if (message.go_package !== "") { + writer.uint32(90).string(message.go_package); + } + if (message.cc_generic_services === true) { + writer.uint32(128).bool(message.cc_generic_services); + } + if (message.java_generic_services === true) { + writer.uint32(136).bool(message.java_generic_services); + } + if (message.py_generic_services === true) { + writer.uint32(144).bool(message.py_generic_services); + } + if (message.php_generic_services === true) { + writer.uint32(336).bool(message.php_generic_services); + } + if (message.deprecated === true) { + writer.uint32(184).bool(message.deprecated); + } + if (message.cc_enable_arenas === true) { + writer.uint32(248).bool(message.cc_enable_arenas); + } + if (message.objc_class_prefix !== "") { + writer.uint32(290).string(message.objc_class_prefix); + } + if (message.csharp_namespace !== "") { + writer.uint32(298).string(message.csharp_namespace); + } + if (message.swift_prefix !== "") { + writer.uint32(314).string(message.swift_prefix); + } + if (message.php_class_prefix !== "") { + writer.uint32(322).string(message.php_class_prefix); + } + if (message.php_namespace !== "") { + writer.uint32(330).string(message.php_namespace); + } + if (message.php_metadata_namespace !== "") { + writer.uint32(354).string(message.php_metadata_namespace); + } + if (message.ruby_package !== "") { + writer.uint32(362).string(message.ruby_package); + } + for (const v of message.uninterpreted_option) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FileOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFileOptions } as FileOptions; + message.uninterpreted_option = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.java_package = reader.string(); + break; + case 8: + message.java_outer_classname = reader.string(); + break; + case 10: + message.java_multiple_files = reader.bool(); + break; + case 20: + message.java_generate_equals_and_hash = reader.bool(); + break; + case 27: + message.java_string_check_utf8 = reader.bool(); + break; + case 9: + message.optimize_for = reader.int32() as any; + break; + case 11: + message.go_package = reader.string(); + break; + case 16: + message.cc_generic_services = reader.bool(); + break; + case 17: + message.java_generic_services = reader.bool(); + break; + case 18: + message.py_generic_services = reader.bool(); + break; + case 42: + message.php_generic_services = reader.bool(); + break; + case 23: + message.deprecated = reader.bool(); + break; + case 31: + message.cc_enable_arenas = reader.bool(); + break; + case 36: + message.objc_class_prefix = reader.string(); + break; + case 37: + message.csharp_namespace = reader.string(); + break; + case 39: + message.swift_prefix = reader.string(); + break; + case 40: + message.php_class_prefix = reader.string(); + break; + case 41: + message.php_namespace = reader.string(); + break; + case 44: + message.php_metadata_namespace = reader.string(); + break; + case 45: + message.ruby_package = reader.string(); + break; + case 999: + message.uninterpreted_option.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FileOptions { + const message = { ...baseFileOptions } as FileOptions; + message.uninterpreted_option = []; + if (object.java_package !== undefined && object.java_package !== null) { + message.java_package = String(object.java_package); + } else { + message.java_package = ""; + } + if ( + object.java_outer_classname !== undefined && + object.java_outer_classname !== null + ) { + message.java_outer_classname = String(object.java_outer_classname); + } else { + message.java_outer_classname = ""; + } + if ( + object.java_multiple_files !== undefined && + object.java_multiple_files !== null + ) { + message.java_multiple_files = Boolean(object.java_multiple_files); + } else { + message.java_multiple_files = false; + } + if ( + object.java_generate_equals_and_hash !== undefined && + object.java_generate_equals_and_hash !== null + ) { + message.java_generate_equals_and_hash = Boolean( + object.java_generate_equals_and_hash + ); + } else { + message.java_generate_equals_and_hash = false; + } + if ( + object.java_string_check_utf8 !== undefined && + object.java_string_check_utf8 !== null + ) { + message.java_string_check_utf8 = Boolean(object.java_string_check_utf8); + } else { + message.java_string_check_utf8 = false; + } + if (object.optimize_for !== undefined && object.optimize_for !== null) { + message.optimize_for = fileOptions_OptimizeModeFromJSON( + object.optimize_for + ); + } else { + message.optimize_for = 1; + } + if (object.go_package !== undefined && object.go_package !== null) { + message.go_package = String(object.go_package); + } else { + message.go_package = ""; + } + if ( + object.cc_generic_services !== undefined && + object.cc_generic_services !== null + ) { + message.cc_generic_services = Boolean(object.cc_generic_services); + } else { + message.cc_generic_services = false; + } + if ( + object.java_generic_services !== undefined && + object.java_generic_services !== null + ) { + message.java_generic_services = Boolean(object.java_generic_services); + } else { + message.java_generic_services = false; + } + if ( + object.py_generic_services !== undefined && + object.py_generic_services !== null + ) { + message.py_generic_services = Boolean(object.py_generic_services); + } else { + message.py_generic_services = false; + } + if ( + object.php_generic_services !== undefined && + object.php_generic_services !== null + ) { + message.php_generic_services = Boolean(object.php_generic_services); + } else { + message.php_generic_services = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.cc_enable_arenas !== undefined && + object.cc_enable_arenas !== null + ) { + message.cc_enable_arenas = Boolean(object.cc_enable_arenas); + } else { + message.cc_enable_arenas = false; + } + if ( + object.objc_class_prefix !== undefined && + object.objc_class_prefix !== null + ) { + message.objc_class_prefix = String(object.objc_class_prefix); + } else { + message.objc_class_prefix = ""; + } + if ( + object.csharp_namespace !== undefined && + object.csharp_namespace !== null + ) { + message.csharp_namespace = String(object.csharp_namespace); + } else { + message.csharp_namespace = ""; + } + if (object.swift_prefix !== undefined && object.swift_prefix !== null) { + message.swift_prefix = String(object.swift_prefix); + } else { + message.swift_prefix = ""; + } + if ( + object.php_class_prefix !== undefined && + object.php_class_prefix !== null + ) { + message.php_class_prefix = String(object.php_class_prefix); + } else { + message.php_class_prefix = ""; + } + if (object.php_namespace !== undefined && object.php_namespace !== null) { + message.php_namespace = String(object.php_namespace); + } else { + message.php_namespace = ""; + } + if ( + object.php_metadata_namespace !== undefined && + object.php_metadata_namespace !== null + ) { + message.php_metadata_namespace = String(object.php_metadata_namespace); + } else { + message.php_metadata_namespace = ""; + } + if (object.ruby_package !== undefined && object.ruby_package !== null) { + message.ruby_package = String(object.ruby_package); + } else { + message.ruby_package = ""; + } + if ( + object.uninterpreted_option !== undefined && + object.uninterpreted_option !== null + ) { + for (const e of object.uninterpreted_option) { + message.uninterpreted_option.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: FileOptions): unknown { + const obj: any = {}; + message.java_package !== undefined && + (obj.java_package = message.java_package); + message.java_outer_classname !== undefined && + (obj.java_outer_classname = message.java_outer_classname); + message.java_multiple_files !== undefined && + (obj.java_multiple_files = message.java_multiple_files); + message.java_generate_equals_and_hash !== undefined && + (obj.java_generate_equals_and_hash = + message.java_generate_equals_and_hash); + message.java_string_check_utf8 !== undefined && + (obj.java_string_check_utf8 = message.java_string_check_utf8); + message.optimize_for !== undefined && + (obj.optimize_for = fileOptions_OptimizeModeToJSON(message.optimize_for)); + message.go_package !== undefined && (obj.go_package = message.go_package); + message.cc_generic_services !== undefined && + (obj.cc_generic_services = message.cc_generic_services); + message.java_generic_services !== undefined && + (obj.java_generic_services = message.java_generic_services); + message.py_generic_services !== undefined && + (obj.py_generic_services = message.py_generic_services); + message.php_generic_services !== undefined && + (obj.php_generic_services = message.php_generic_services); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.cc_enable_arenas !== undefined && + (obj.cc_enable_arenas = message.cc_enable_arenas); + message.objc_class_prefix !== undefined && + (obj.objc_class_prefix = message.objc_class_prefix); + message.csharp_namespace !== undefined && + (obj.csharp_namespace = message.csharp_namespace); + message.swift_prefix !== undefined && + (obj.swift_prefix = message.swift_prefix); + message.php_class_prefix !== undefined && + (obj.php_class_prefix = message.php_class_prefix); + message.php_namespace !== undefined && + (obj.php_namespace = message.php_namespace); + message.php_metadata_namespace !== undefined && + (obj.php_metadata_namespace = message.php_metadata_namespace); + message.ruby_package !== undefined && + (obj.ruby_package = message.ruby_package); + if (message.uninterpreted_option) { + obj.uninterpreted_option = message.uninterpreted_option.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpreted_option = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): FileOptions { + const message = { ...baseFileOptions } as FileOptions; + message.uninterpreted_option = []; + if (object.java_package !== undefined && object.java_package !== null) { + message.java_package = object.java_package; + } else { + message.java_package = ""; + } + if ( + object.java_outer_classname !== undefined && + object.java_outer_classname !== null + ) { + message.java_outer_classname = object.java_outer_classname; + } else { + message.java_outer_classname = ""; + } + if ( + object.java_multiple_files !== undefined && + object.java_multiple_files !== null + ) { + message.java_multiple_files = object.java_multiple_files; + } else { + message.java_multiple_files = false; + } + if ( + object.java_generate_equals_and_hash !== undefined && + object.java_generate_equals_and_hash !== null + ) { + message.java_generate_equals_and_hash = + object.java_generate_equals_and_hash; + } else { + message.java_generate_equals_and_hash = false; + } + if ( + object.java_string_check_utf8 !== undefined && + object.java_string_check_utf8 !== null + ) { + message.java_string_check_utf8 = object.java_string_check_utf8; + } else { + message.java_string_check_utf8 = false; + } + if (object.optimize_for !== undefined && object.optimize_for !== null) { + message.optimize_for = object.optimize_for; + } else { + message.optimize_for = 1; + } + if (object.go_package !== undefined && object.go_package !== null) { + message.go_package = object.go_package; + } else { + message.go_package = ""; + } + if ( + object.cc_generic_services !== undefined && + object.cc_generic_services !== null + ) { + message.cc_generic_services = object.cc_generic_services; + } else { + message.cc_generic_services = false; + } + if ( + object.java_generic_services !== undefined && + object.java_generic_services !== null + ) { + message.java_generic_services = object.java_generic_services; + } else { + message.java_generic_services = false; + } + if ( + object.py_generic_services !== undefined && + object.py_generic_services !== null + ) { + message.py_generic_services = object.py_generic_services; + } else { + message.py_generic_services = false; + } + if ( + object.php_generic_services !== undefined && + object.php_generic_services !== null + ) { + message.php_generic_services = object.php_generic_services; + } else { + message.php_generic_services = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.cc_enable_arenas !== undefined && + object.cc_enable_arenas !== null + ) { + message.cc_enable_arenas = object.cc_enable_arenas; + } else { + message.cc_enable_arenas = false; + } + if ( + object.objc_class_prefix !== undefined && + object.objc_class_prefix !== null + ) { + message.objc_class_prefix = object.objc_class_prefix; + } else { + message.objc_class_prefix = ""; + } + if ( + object.csharp_namespace !== undefined && + object.csharp_namespace !== null + ) { + message.csharp_namespace = object.csharp_namespace; + } else { + message.csharp_namespace = ""; + } + if (object.swift_prefix !== undefined && object.swift_prefix !== null) { + message.swift_prefix = object.swift_prefix; + } else { + message.swift_prefix = ""; + } + if ( + object.php_class_prefix !== undefined && + object.php_class_prefix !== null + ) { + message.php_class_prefix = object.php_class_prefix; + } else { + message.php_class_prefix = ""; + } + if (object.php_namespace !== undefined && object.php_namespace !== null) { + message.php_namespace = object.php_namespace; + } else { + message.php_namespace = ""; + } + if ( + object.php_metadata_namespace !== undefined && + object.php_metadata_namespace !== null + ) { + message.php_metadata_namespace = object.php_metadata_namespace; + } else { + message.php_metadata_namespace = ""; + } + if (object.ruby_package !== undefined && object.ruby_package !== null) { + message.ruby_package = object.ruby_package; + } else { + message.ruby_package = ""; + } + if ( + object.uninterpreted_option !== undefined && + object.uninterpreted_option !== null + ) { + for (const e of object.uninterpreted_option) { + message.uninterpreted_option.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseMessageOptions: object = { + message_set_wire_format: false, + no_standard_descriptor_accessor: false, + deprecated: false, + map_entry: false, +}; + +export const MessageOptions = { + encode(message: MessageOptions, writer: Writer = Writer.create()): Writer { + if (message.message_set_wire_format === true) { + writer.uint32(8).bool(message.message_set_wire_format); + } + if (message.no_standard_descriptor_accessor === true) { + writer.uint32(16).bool(message.no_standard_descriptor_accessor); + } + if (message.deprecated === true) { + writer.uint32(24).bool(message.deprecated); + } + if (message.map_entry === true) { + writer.uint32(56).bool(message.map_entry); + } + for (const v of message.uninterpreted_option) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MessageOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMessageOptions } as MessageOptions; + message.uninterpreted_option = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.message_set_wire_format = reader.bool(); + break; + case 2: + message.no_standard_descriptor_accessor = reader.bool(); + break; + case 3: + message.deprecated = reader.bool(); + break; + case 7: + message.map_entry = reader.bool(); + break; + case 999: + message.uninterpreted_option.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MessageOptions { + const message = { ...baseMessageOptions } as MessageOptions; + message.uninterpreted_option = []; + if ( + object.message_set_wire_format !== undefined && + object.message_set_wire_format !== null + ) { + message.message_set_wire_format = Boolean(object.message_set_wire_format); + } else { + message.message_set_wire_format = false; + } + if ( + object.no_standard_descriptor_accessor !== undefined && + object.no_standard_descriptor_accessor !== null + ) { + message.no_standard_descriptor_accessor = Boolean( + object.no_standard_descriptor_accessor + ); + } else { + message.no_standard_descriptor_accessor = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if (object.map_entry !== undefined && object.map_entry !== null) { + message.map_entry = Boolean(object.map_entry); + } else { + message.map_entry = false; + } + if ( + object.uninterpreted_option !== undefined && + object.uninterpreted_option !== null + ) { + for (const e of object.uninterpreted_option) { + message.uninterpreted_option.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: MessageOptions): unknown { + const obj: any = {}; + message.message_set_wire_format !== undefined && + (obj.message_set_wire_format = message.message_set_wire_format); + message.no_standard_descriptor_accessor !== undefined && + (obj.no_standard_descriptor_accessor = + message.no_standard_descriptor_accessor); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.map_entry !== undefined && (obj.map_entry = message.map_entry); + if (message.uninterpreted_option) { + obj.uninterpreted_option = message.uninterpreted_option.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpreted_option = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): MessageOptions { + const message = { ...baseMessageOptions } as MessageOptions; + message.uninterpreted_option = []; + if ( + object.message_set_wire_format !== undefined && + object.message_set_wire_format !== null + ) { + message.message_set_wire_format = object.message_set_wire_format; + } else { + message.message_set_wire_format = false; + } + if ( + object.no_standard_descriptor_accessor !== undefined && + object.no_standard_descriptor_accessor !== null + ) { + message.no_standard_descriptor_accessor = + object.no_standard_descriptor_accessor; + } else { + message.no_standard_descriptor_accessor = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if (object.map_entry !== undefined && object.map_entry !== null) { + message.map_entry = object.map_entry; + } else { + message.map_entry = false; + } + if ( + object.uninterpreted_option !== undefined && + object.uninterpreted_option !== null + ) { + for (const e of object.uninterpreted_option) { + message.uninterpreted_option.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseFieldOptions: object = { + ctype: 0, + packed: false, + jstype: 0, + lazy: false, + deprecated: false, + weak: false, +}; + +export const FieldOptions = { + encode(message: FieldOptions, writer: Writer = Writer.create()): Writer { + if (message.ctype !== 0) { + writer.uint32(8).int32(message.ctype); + } + if (message.packed === true) { + writer.uint32(16).bool(message.packed); + } + if (message.jstype !== 0) { + writer.uint32(48).int32(message.jstype); + } + if (message.lazy === true) { + writer.uint32(40).bool(message.lazy); + } + if (message.deprecated === true) { + writer.uint32(24).bool(message.deprecated); + } + if (message.weak === true) { + writer.uint32(80).bool(message.weak); + } + for (const v of message.uninterpreted_option) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FieldOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFieldOptions } as FieldOptions; + message.uninterpreted_option = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.ctype = reader.int32() as any; + break; + case 2: + message.packed = reader.bool(); + break; + case 6: + message.jstype = reader.int32() as any; + break; + case 5: + message.lazy = reader.bool(); + break; + case 3: + message.deprecated = reader.bool(); + break; + case 10: + message.weak = reader.bool(); + break; + case 999: + message.uninterpreted_option.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FieldOptions { + const message = { ...baseFieldOptions } as FieldOptions; + message.uninterpreted_option = []; + if (object.ctype !== undefined && object.ctype !== null) { + message.ctype = fieldOptions_CTypeFromJSON(object.ctype); + } else { + message.ctype = 0; + } + if (object.packed !== undefined && object.packed !== null) { + message.packed = Boolean(object.packed); + } else { + message.packed = false; + } + if (object.jstype !== undefined && object.jstype !== null) { + message.jstype = fieldOptions_JSTypeFromJSON(object.jstype); + } else { + message.jstype = 0; + } + if (object.lazy !== undefined && object.lazy !== null) { + message.lazy = Boolean(object.lazy); + } else { + message.lazy = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if (object.weak !== undefined && object.weak !== null) { + message.weak = Boolean(object.weak); + } else { + message.weak = false; + } + if ( + object.uninterpreted_option !== undefined && + object.uninterpreted_option !== null + ) { + for (const e of object.uninterpreted_option) { + message.uninterpreted_option.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: FieldOptions): unknown { + const obj: any = {}; + message.ctype !== undefined && + (obj.ctype = fieldOptions_CTypeToJSON(message.ctype)); + message.packed !== undefined && (obj.packed = message.packed); + message.jstype !== undefined && + (obj.jstype = fieldOptions_JSTypeToJSON(message.jstype)); + message.lazy !== undefined && (obj.lazy = message.lazy); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.weak !== undefined && (obj.weak = message.weak); + if (message.uninterpreted_option) { + obj.uninterpreted_option = message.uninterpreted_option.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpreted_option = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): FieldOptions { + const message = { ...baseFieldOptions } as FieldOptions; + message.uninterpreted_option = []; + if (object.ctype !== undefined && object.ctype !== null) { + message.ctype = object.ctype; + } else { + message.ctype = 0; + } + if (object.packed !== undefined && object.packed !== null) { + message.packed = object.packed; + } else { + message.packed = false; + } + if (object.jstype !== undefined && object.jstype !== null) { + message.jstype = object.jstype; + } else { + message.jstype = 0; + } + if (object.lazy !== undefined && object.lazy !== null) { + message.lazy = object.lazy; + } else { + message.lazy = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if (object.weak !== undefined && object.weak !== null) { + message.weak = object.weak; + } else { + message.weak = false; + } + if ( + object.uninterpreted_option !== undefined && + object.uninterpreted_option !== null + ) { + for (const e of object.uninterpreted_option) { + message.uninterpreted_option.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseOneofOptions: object = {}; + +export const OneofOptions = { + encode(message: OneofOptions, writer: Writer = Writer.create()): Writer { + for (const v of message.uninterpreted_option) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): OneofOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseOneofOptions } as OneofOptions; + message.uninterpreted_option = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 999: + message.uninterpreted_option.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): OneofOptions { + const message = { ...baseOneofOptions } as OneofOptions; + message.uninterpreted_option = []; + if ( + object.uninterpreted_option !== undefined && + object.uninterpreted_option !== null + ) { + for (const e of object.uninterpreted_option) { + message.uninterpreted_option.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: OneofOptions): unknown { + const obj: any = {}; + if (message.uninterpreted_option) { + obj.uninterpreted_option = message.uninterpreted_option.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpreted_option = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): OneofOptions { + const message = { ...baseOneofOptions } as OneofOptions; + message.uninterpreted_option = []; + if ( + object.uninterpreted_option !== undefined && + object.uninterpreted_option !== null + ) { + for (const e of object.uninterpreted_option) { + message.uninterpreted_option.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseEnumOptions: object = { allow_alias: false, deprecated: false }; + +export const EnumOptions = { + encode(message: EnumOptions, writer: Writer = Writer.create()): Writer { + if (message.allow_alias === true) { + writer.uint32(16).bool(message.allow_alias); + } + if (message.deprecated === true) { + writer.uint32(24).bool(message.deprecated); + } + for (const v of message.uninterpreted_option) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): EnumOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseEnumOptions } as EnumOptions; + message.uninterpreted_option = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + message.allow_alias = reader.bool(); + break; + case 3: + message.deprecated = reader.bool(); + break; + case 999: + message.uninterpreted_option.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumOptions { + const message = { ...baseEnumOptions } as EnumOptions; + message.uninterpreted_option = []; + if (object.allow_alias !== undefined && object.allow_alias !== null) { + message.allow_alias = Boolean(object.allow_alias); + } else { + message.allow_alias = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.uninterpreted_option !== undefined && + object.uninterpreted_option !== null + ) { + for (const e of object.uninterpreted_option) { + message.uninterpreted_option.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: EnumOptions): unknown { + const obj: any = {}; + message.allow_alias !== undefined && + (obj.allow_alias = message.allow_alias); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + if (message.uninterpreted_option) { + obj.uninterpreted_option = message.uninterpreted_option.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpreted_option = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): EnumOptions { + const message = { ...baseEnumOptions } as EnumOptions; + message.uninterpreted_option = []; + if (object.allow_alias !== undefined && object.allow_alias !== null) { + message.allow_alias = object.allow_alias; + } else { + message.allow_alias = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.uninterpreted_option !== undefined && + object.uninterpreted_option !== null + ) { + for (const e of object.uninterpreted_option) { + message.uninterpreted_option.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseEnumValueOptions: object = { deprecated: false }; + +export const EnumValueOptions = { + encode(message: EnumValueOptions, writer: Writer = Writer.create()): Writer { + if (message.deprecated === true) { + writer.uint32(8).bool(message.deprecated); + } + for (const v of message.uninterpreted_option) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): EnumValueOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseEnumValueOptions } as EnumValueOptions; + message.uninterpreted_option = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.deprecated = reader.bool(); + break; + case 999: + message.uninterpreted_option.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumValueOptions { + const message = { ...baseEnumValueOptions } as EnumValueOptions; + message.uninterpreted_option = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.uninterpreted_option !== undefined && + object.uninterpreted_option !== null + ) { + for (const e of object.uninterpreted_option) { + message.uninterpreted_option.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: EnumValueOptions): unknown { + const obj: any = {}; + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + if (message.uninterpreted_option) { + obj.uninterpreted_option = message.uninterpreted_option.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpreted_option = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): EnumValueOptions { + const message = { ...baseEnumValueOptions } as EnumValueOptions; + message.uninterpreted_option = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.uninterpreted_option !== undefined && + object.uninterpreted_option !== null + ) { + for (const e of object.uninterpreted_option) { + message.uninterpreted_option.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseServiceOptions: object = { deprecated: false }; + +export const ServiceOptions = { + encode(message: ServiceOptions, writer: Writer = Writer.create()): Writer { + if (message.deprecated === true) { + writer.uint32(264).bool(message.deprecated); + } + for (const v of message.uninterpreted_option) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ServiceOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseServiceOptions } as ServiceOptions; + message.uninterpreted_option = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 33: + message.deprecated = reader.bool(); + break; + case 999: + message.uninterpreted_option.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ServiceOptions { + const message = { ...baseServiceOptions } as ServiceOptions; + message.uninterpreted_option = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.uninterpreted_option !== undefined && + object.uninterpreted_option !== null + ) { + for (const e of object.uninterpreted_option) { + message.uninterpreted_option.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: ServiceOptions): unknown { + const obj: any = {}; + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + if (message.uninterpreted_option) { + obj.uninterpreted_option = message.uninterpreted_option.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpreted_option = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): ServiceOptions { + const message = { ...baseServiceOptions } as ServiceOptions; + message.uninterpreted_option = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.uninterpreted_option !== undefined && + object.uninterpreted_option !== null + ) { + for (const e of object.uninterpreted_option) { + message.uninterpreted_option.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseMethodOptions: object = { deprecated: false, idempotency_level: 0 }; + +export const MethodOptions = { + encode(message: MethodOptions, writer: Writer = Writer.create()): Writer { + if (message.deprecated === true) { + writer.uint32(264).bool(message.deprecated); + } + if (message.idempotency_level !== 0) { + writer.uint32(272).int32(message.idempotency_level); + } + for (const v of message.uninterpreted_option) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MethodOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMethodOptions } as MethodOptions; + message.uninterpreted_option = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 33: + message.deprecated = reader.bool(); + break; + case 34: + message.idempotency_level = reader.int32() as any; + break; + case 999: + message.uninterpreted_option.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MethodOptions { + const message = { ...baseMethodOptions } as MethodOptions; + message.uninterpreted_option = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.idempotency_level !== undefined && + object.idempotency_level !== null + ) { + message.idempotency_level = methodOptions_IdempotencyLevelFromJSON( + object.idempotency_level + ); + } else { + message.idempotency_level = 0; + } + if ( + object.uninterpreted_option !== undefined && + object.uninterpreted_option !== null + ) { + for (const e of object.uninterpreted_option) { + message.uninterpreted_option.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: MethodOptions): unknown { + const obj: any = {}; + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.idempotency_level !== undefined && + (obj.idempotency_level = methodOptions_IdempotencyLevelToJSON( + message.idempotency_level + )); + if (message.uninterpreted_option) { + obj.uninterpreted_option = message.uninterpreted_option.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpreted_option = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): MethodOptions { + const message = { ...baseMethodOptions } as MethodOptions; + message.uninterpreted_option = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.idempotency_level !== undefined && + object.idempotency_level !== null + ) { + message.idempotency_level = object.idempotency_level; + } else { + message.idempotency_level = 0; + } + if ( + object.uninterpreted_option !== undefined && + object.uninterpreted_option !== null + ) { + for (const e of object.uninterpreted_option) { + message.uninterpreted_option.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseUninterpretedOption: object = { + identifier_value: "", + positive_int_value: 0, + negative_int_value: 0, + double_value: 0, + aggregate_value: "", +}; + +export const UninterpretedOption = { + encode( + message: UninterpretedOption, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.name) { + UninterpretedOption_NamePart.encode( + v!, + writer.uint32(18).fork() + ).ldelim(); + } + if (message.identifier_value !== "") { + writer.uint32(26).string(message.identifier_value); + } + if (message.positive_int_value !== 0) { + writer.uint32(32).uint64(message.positive_int_value); + } + if (message.negative_int_value !== 0) { + writer.uint32(40).int64(message.negative_int_value); + } + if (message.double_value !== 0) { + writer.uint32(49).double(message.double_value); + } + if (message.string_value.length !== 0) { + writer.uint32(58).bytes(message.string_value); + } + if (message.aggregate_value !== "") { + writer.uint32(66).string(message.aggregate_value); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): UninterpretedOption { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseUninterpretedOption } as UninterpretedOption; + message.name = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + message.name.push( + UninterpretedOption_NamePart.decode(reader, reader.uint32()) + ); + break; + case 3: + message.identifier_value = reader.string(); + break; + case 4: + message.positive_int_value = longToNumber(reader.uint64() as Long); + break; + case 5: + message.negative_int_value = longToNumber(reader.int64() as Long); + break; + case 6: + message.double_value = reader.double(); + break; + case 7: + message.string_value = reader.bytes(); + break; + case 8: + message.aggregate_value = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): UninterpretedOption { + const message = { ...baseUninterpretedOption } as UninterpretedOption; + message.name = []; + if (object.name !== undefined && object.name !== null) { + for (const e of object.name) { + message.name.push(UninterpretedOption_NamePart.fromJSON(e)); + } + } + if ( + object.identifier_value !== undefined && + object.identifier_value !== null + ) { + message.identifier_value = String(object.identifier_value); + } else { + message.identifier_value = ""; + } + if ( + object.positive_int_value !== undefined && + object.positive_int_value !== null + ) { + message.positive_int_value = Number(object.positive_int_value); + } else { + message.positive_int_value = 0; + } + if ( + object.negative_int_value !== undefined && + object.negative_int_value !== null + ) { + message.negative_int_value = Number(object.negative_int_value); + } else { + message.negative_int_value = 0; + } + if (object.double_value !== undefined && object.double_value !== null) { + message.double_value = Number(object.double_value); + } else { + message.double_value = 0; + } + if (object.string_value !== undefined && object.string_value !== null) { + message.string_value = bytesFromBase64(object.string_value); + } + if ( + object.aggregate_value !== undefined && + object.aggregate_value !== null + ) { + message.aggregate_value = String(object.aggregate_value); + } else { + message.aggregate_value = ""; + } + return message; + }, + + toJSON(message: UninterpretedOption): unknown { + const obj: any = {}; + if (message.name) { + obj.name = message.name.map((e) => + e ? UninterpretedOption_NamePart.toJSON(e) : undefined + ); + } else { + obj.name = []; + } + message.identifier_value !== undefined && + (obj.identifier_value = message.identifier_value); + message.positive_int_value !== undefined && + (obj.positive_int_value = message.positive_int_value); + message.negative_int_value !== undefined && + (obj.negative_int_value = message.negative_int_value); + message.double_value !== undefined && + (obj.double_value = message.double_value); + message.string_value !== undefined && + (obj.string_value = base64FromBytes( + message.string_value !== undefined + ? message.string_value + : new Uint8Array() + )); + message.aggregate_value !== undefined && + (obj.aggregate_value = message.aggregate_value); + return obj; + }, + + fromPartial(object: DeepPartial): UninterpretedOption { + const message = { ...baseUninterpretedOption } as UninterpretedOption; + message.name = []; + if (object.name !== undefined && object.name !== null) { + for (const e of object.name) { + message.name.push(UninterpretedOption_NamePart.fromPartial(e)); + } + } + if ( + object.identifier_value !== undefined && + object.identifier_value !== null + ) { + message.identifier_value = object.identifier_value; + } else { + message.identifier_value = ""; + } + if ( + object.positive_int_value !== undefined && + object.positive_int_value !== null + ) { + message.positive_int_value = object.positive_int_value; + } else { + message.positive_int_value = 0; + } + if ( + object.negative_int_value !== undefined && + object.negative_int_value !== null + ) { + message.negative_int_value = object.negative_int_value; + } else { + message.negative_int_value = 0; + } + if (object.double_value !== undefined && object.double_value !== null) { + message.double_value = object.double_value; + } else { + message.double_value = 0; + } + if (object.string_value !== undefined && object.string_value !== null) { + message.string_value = object.string_value; + } else { + message.string_value = new Uint8Array(); + } + if ( + object.aggregate_value !== undefined && + object.aggregate_value !== null + ) { + message.aggregate_value = object.aggregate_value; + } else { + message.aggregate_value = ""; + } + return message; + }, +}; + +const baseUninterpretedOption_NamePart: object = { + name_part: "", + is_extension: false, +}; + +export const UninterpretedOption_NamePart = { + encode( + message: UninterpretedOption_NamePart, + writer: Writer = Writer.create() + ): Writer { + if (message.name_part !== "") { + writer.uint32(10).string(message.name_part); + } + if (message.is_extension === true) { + writer.uint32(16).bool(message.is_extension); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): UninterpretedOption_NamePart { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseUninterpretedOption_NamePart, + } as UninterpretedOption_NamePart; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name_part = reader.string(); + break; + case 2: + message.is_extension = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): UninterpretedOption_NamePart { + const message = { + ...baseUninterpretedOption_NamePart, + } as UninterpretedOption_NamePart; + if (object.name_part !== undefined && object.name_part !== null) { + message.name_part = String(object.name_part); + } else { + message.name_part = ""; + } + if (object.is_extension !== undefined && object.is_extension !== null) { + message.is_extension = Boolean(object.is_extension); + } else { + message.is_extension = false; + } + return message; + }, + + toJSON(message: UninterpretedOption_NamePart): unknown { + const obj: any = {}; + message.name_part !== undefined && (obj.name_part = message.name_part); + message.is_extension !== undefined && + (obj.is_extension = message.is_extension); + return obj; + }, + + fromPartial( + object: DeepPartial + ): UninterpretedOption_NamePart { + const message = { + ...baseUninterpretedOption_NamePart, + } as UninterpretedOption_NamePart; + if (object.name_part !== undefined && object.name_part !== null) { + message.name_part = object.name_part; + } else { + message.name_part = ""; + } + if (object.is_extension !== undefined && object.is_extension !== null) { + message.is_extension = object.is_extension; + } else { + message.is_extension = false; + } + return message; + }, +}; + +const baseSourceCodeInfo: object = {}; + +export const SourceCodeInfo = { + encode(message: SourceCodeInfo, writer: Writer = Writer.create()): Writer { + for (const v of message.location) { + SourceCodeInfo_Location.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): SourceCodeInfo { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseSourceCodeInfo } as SourceCodeInfo; + message.location = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.location.push( + SourceCodeInfo_Location.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): SourceCodeInfo { + const message = { ...baseSourceCodeInfo } as SourceCodeInfo; + message.location = []; + if (object.location !== undefined && object.location !== null) { + for (const e of object.location) { + message.location.push(SourceCodeInfo_Location.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: SourceCodeInfo): unknown { + const obj: any = {}; + if (message.location) { + obj.location = message.location.map((e) => + e ? SourceCodeInfo_Location.toJSON(e) : undefined + ); + } else { + obj.location = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): SourceCodeInfo { + const message = { ...baseSourceCodeInfo } as SourceCodeInfo; + message.location = []; + if (object.location !== undefined && object.location !== null) { + for (const e of object.location) { + message.location.push(SourceCodeInfo_Location.fromPartial(e)); + } + } + return message; + }, +}; + +const baseSourceCodeInfo_Location: object = { + path: 0, + span: 0, + leading_comments: "", + trailing_comments: "", + leading_detached_comments: "", +}; + +export const SourceCodeInfo_Location = { + encode( + message: SourceCodeInfo_Location, + writer: Writer = Writer.create() + ): Writer { + writer.uint32(10).fork(); + for (const v of message.path) { + writer.int32(v); + } + writer.ldelim(); + writer.uint32(18).fork(); + for (const v of message.span) { + writer.int32(v); + } + writer.ldelim(); + if (message.leading_comments !== "") { + writer.uint32(26).string(message.leading_comments); + } + if (message.trailing_comments !== "") { + writer.uint32(34).string(message.trailing_comments); + } + for (const v of message.leading_detached_comments) { + writer.uint32(50).string(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): SourceCodeInfo_Location { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseSourceCodeInfo_Location, + } as SourceCodeInfo_Location; + message.path = []; + message.span = []; + message.leading_detached_comments = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.path.push(reader.int32()); + } + } else { + message.path.push(reader.int32()); + } + break; + case 2: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.span.push(reader.int32()); + } + } else { + message.span.push(reader.int32()); + } + break; + case 3: + message.leading_comments = reader.string(); + break; + case 4: + message.trailing_comments = reader.string(); + break; + case 6: + message.leading_detached_comments.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): SourceCodeInfo_Location { + const message = { + ...baseSourceCodeInfo_Location, + } as SourceCodeInfo_Location; + message.path = []; + message.span = []; + message.leading_detached_comments = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(Number(e)); + } + } + if (object.span !== undefined && object.span !== null) { + for (const e of object.span) { + message.span.push(Number(e)); + } + } + if ( + object.leading_comments !== undefined && + object.leading_comments !== null + ) { + message.leading_comments = String(object.leading_comments); + } else { + message.leading_comments = ""; + } + if ( + object.trailing_comments !== undefined && + object.trailing_comments !== null + ) { + message.trailing_comments = String(object.trailing_comments); + } else { + message.trailing_comments = ""; + } + if ( + object.leading_detached_comments !== undefined && + object.leading_detached_comments !== null + ) { + for (const e of object.leading_detached_comments) { + message.leading_detached_comments.push(String(e)); + } + } + return message; + }, + + toJSON(message: SourceCodeInfo_Location): unknown { + const obj: any = {}; + if (message.path) { + obj.path = message.path.map((e) => e); + } else { + obj.path = []; + } + if (message.span) { + obj.span = message.span.map((e) => e); + } else { + obj.span = []; + } + message.leading_comments !== undefined && + (obj.leading_comments = message.leading_comments); + message.trailing_comments !== undefined && + (obj.trailing_comments = message.trailing_comments); + if (message.leading_detached_comments) { + obj.leading_detached_comments = message.leading_detached_comments.map( + (e) => e + ); + } else { + obj.leading_detached_comments = []; + } + return obj; + }, + + fromPartial( + object: DeepPartial + ): SourceCodeInfo_Location { + const message = { + ...baseSourceCodeInfo_Location, + } as SourceCodeInfo_Location; + message.path = []; + message.span = []; + message.leading_detached_comments = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(e); + } + } + if (object.span !== undefined && object.span !== null) { + for (const e of object.span) { + message.span.push(e); + } + } + if ( + object.leading_comments !== undefined && + object.leading_comments !== null + ) { + message.leading_comments = object.leading_comments; + } else { + message.leading_comments = ""; + } + if ( + object.trailing_comments !== undefined && + object.trailing_comments !== null + ) { + message.trailing_comments = object.trailing_comments; + } else { + message.trailing_comments = ""; + } + if ( + object.leading_detached_comments !== undefined && + object.leading_detached_comments !== null + ) { + for (const e of object.leading_detached_comments) { + message.leading_detached_comments.push(e); + } + } + return message; + }, +}; + +const baseGeneratedCodeInfo: object = {}; + +export const GeneratedCodeInfo = { + encode(message: GeneratedCodeInfo, writer: Writer = Writer.create()): Writer { + for (const v of message.annotation) { + GeneratedCodeInfo_Annotation.encode( + v!, + writer.uint32(10).fork() + ).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): GeneratedCodeInfo { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseGeneratedCodeInfo } as GeneratedCodeInfo; + message.annotation = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.annotation.push( + GeneratedCodeInfo_Annotation.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GeneratedCodeInfo { + const message = { ...baseGeneratedCodeInfo } as GeneratedCodeInfo; + message.annotation = []; + if (object.annotation !== undefined && object.annotation !== null) { + for (const e of object.annotation) { + message.annotation.push(GeneratedCodeInfo_Annotation.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: GeneratedCodeInfo): unknown { + const obj: any = {}; + if (message.annotation) { + obj.annotation = message.annotation.map((e) => + e ? GeneratedCodeInfo_Annotation.toJSON(e) : undefined + ); + } else { + obj.annotation = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): GeneratedCodeInfo { + const message = { ...baseGeneratedCodeInfo } as GeneratedCodeInfo; + message.annotation = []; + if (object.annotation !== undefined && object.annotation !== null) { + for (const e of object.annotation) { + message.annotation.push(GeneratedCodeInfo_Annotation.fromPartial(e)); + } + } + return message; + }, +}; + +const baseGeneratedCodeInfo_Annotation: object = { + path: 0, + source_file: "", + begin: 0, + end: 0, +}; + +export const GeneratedCodeInfo_Annotation = { + encode( + message: GeneratedCodeInfo_Annotation, + writer: Writer = Writer.create() + ): Writer { + writer.uint32(10).fork(); + for (const v of message.path) { + writer.int32(v); + } + writer.ldelim(); + if (message.source_file !== "") { + writer.uint32(18).string(message.source_file); + } + if (message.begin !== 0) { + writer.uint32(24).int32(message.begin); + } + if (message.end !== 0) { + writer.uint32(32).int32(message.end); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): GeneratedCodeInfo_Annotation { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseGeneratedCodeInfo_Annotation, + } as GeneratedCodeInfo_Annotation; + message.path = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.path.push(reader.int32()); + } + } else { + message.path.push(reader.int32()); + } + break; + case 2: + message.source_file = reader.string(); + break; + case 3: + message.begin = reader.int32(); + break; + case 4: + message.end = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GeneratedCodeInfo_Annotation { + const message = { + ...baseGeneratedCodeInfo_Annotation, + } as GeneratedCodeInfo_Annotation; + message.path = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(Number(e)); + } + } + if (object.source_file !== undefined && object.source_file !== null) { + message.source_file = String(object.source_file); + } else { + message.source_file = ""; + } + if (object.begin !== undefined && object.begin !== null) { + message.begin = Number(object.begin); + } else { + message.begin = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + return message; + }, + + toJSON(message: GeneratedCodeInfo_Annotation): unknown { + const obj: any = {}; + if (message.path) { + obj.path = message.path.map((e) => e); + } else { + obj.path = []; + } + message.source_file !== undefined && + (obj.source_file = message.source_file); + message.begin !== undefined && (obj.begin = message.begin); + message.end !== undefined && (obj.end = message.end); + return obj; + }, + + fromPartial( + object: DeepPartial + ): GeneratedCodeInfo_Annotation { + const message = { + ...baseGeneratedCodeInfo_Annotation, + } as GeneratedCodeInfo_Annotation; + message.path = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(e); + } + } + if (object.source_file !== undefined && object.source_file !== null) { + message.source_file = object.source_file; + } else { + message.source_file = ""; + } + if (object.begin !== undefined && object.begin !== null) { + message.begin = object.begin; + } else { + message.begin = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/genesis.ts b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/genesis.ts new file mode 100644 index 00000000..3c128f61 --- /dev/null +++ b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/genesis.ts @@ -0,0 +1,78 @@ +/* eslint-disable */ +import { Params } from "../rewards/params"; +import { Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "bze.v1.rewards"; + +/** GenesisState defines the rewards module's genesis state. */ +export interface GenesisState { + /** this line is used by starport scaffolding # genesis/proto/state */ + params: Params | undefined; +} + +const baseGenesisState: object = {}; + +export const GenesisState = { + encode(message: GenesisState, writer: Writer = Writer.create()): Writer { + if (message.params !== undefined) { + Params.encode(message.params, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): GenesisState { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseGenesisState } as GenesisState; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.params = Params.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GenesisState { + const message = { ...baseGenesisState } as GenesisState; + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromJSON(object.params); + } else { + message.params = undefined; + } + return message; + }, + + toJSON(message: GenesisState): unknown { + const obj: any = {}; + message.params !== undefined && + (obj.params = message.params ? Params.toJSON(message.params) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): GenesisState { + const message = { ...baseGenesisState } as GenesisState; + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromPartial(object.params); + } else { + message.params = undefined; + } + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/params.ts b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/params.ts new file mode 100644 index 00000000..0d486868 --- /dev/null +++ b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/params.ts @@ -0,0 +1,110 @@ +/* eslint-disable */ +import { Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "bze.v1.rewards"; + +/** Params defines the parameters for the module. */ +export interface Params { + createStakingRewardFee: string; + createTradingRewardFee: string; +} + +const baseParams: object = { + createStakingRewardFee: "", + createTradingRewardFee: "", +}; + +export const Params = { + encode(message: Params, writer: Writer = Writer.create()): Writer { + if (message.createStakingRewardFee !== "") { + writer.uint32(10).string(message.createStakingRewardFee); + } + if (message.createTradingRewardFee !== "") { + writer.uint32(18).string(message.createTradingRewardFee); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Params { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseParams } as Params; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.createStakingRewardFee = reader.string(); + break; + case 2: + message.createTradingRewardFee = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Params { + const message = { ...baseParams } as Params; + if ( + object.createStakingRewardFee !== undefined && + object.createStakingRewardFee !== null + ) { + message.createStakingRewardFee = String(object.createStakingRewardFee); + } else { + message.createStakingRewardFee = ""; + } + if ( + object.createTradingRewardFee !== undefined && + object.createTradingRewardFee !== null + ) { + message.createTradingRewardFee = String(object.createTradingRewardFee); + } else { + message.createTradingRewardFee = ""; + } + return message; + }, + + toJSON(message: Params): unknown { + const obj: any = {}; + message.createStakingRewardFee !== undefined && + (obj.createStakingRewardFee = message.createStakingRewardFee); + message.createTradingRewardFee !== undefined && + (obj.createTradingRewardFee = message.createTradingRewardFee); + return obj; + }, + + fromPartial(object: DeepPartial): Params { + const message = { ...baseParams } as Params; + if ( + object.createStakingRewardFee !== undefined && + object.createStakingRewardFee !== null + ) { + message.createStakingRewardFee = object.createStakingRewardFee; + } else { + message.createStakingRewardFee = ""; + } + if ( + object.createTradingRewardFee !== undefined && + object.createTradingRewardFee !== null + ) { + message.createTradingRewardFee = object.createTradingRewardFee; + } else { + message.createTradingRewardFee = ""; + } + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/query.ts b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/query.ts new file mode 100644 index 00000000..b07f4653 --- /dev/null +++ b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/query.ts @@ -0,0 +1,148 @@ +/* eslint-disable */ +import { Reader, Writer } from "protobufjs/minimal"; +import { Params } from "../rewards/params"; + +export const protobufPackage = "bze.v1.rewards"; + +/** QueryParamsRequest is request type for the Query/Params RPC method. */ +export interface QueryParamsRequest {} + +/** QueryParamsResponse is response type for the Query/Params RPC method. */ +export interface QueryParamsResponse { + /** params holds all the parameters of this module. */ + params: Params | undefined; +} + +const baseQueryParamsRequest: object = {}; + +export const QueryParamsRequest = { + encode(_: QueryParamsRequest, writer: Writer = Writer.create()): Writer { + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QueryParamsRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryParamsRequest } as QueryParamsRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): QueryParamsRequest { + const message = { ...baseQueryParamsRequest } as QueryParamsRequest; + return message; + }, + + toJSON(_: QueryParamsRequest): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial(_: DeepPartial): QueryParamsRequest { + const message = { ...baseQueryParamsRequest } as QueryParamsRequest; + return message; + }, +}; + +const baseQueryParamsResponse: object = {}; + +export const QueryParamsResponse = { + encode( + message: QueryParamsResponse, + writer: Writer = Writer.create() + ): Writer { + if (message.params !== undefined) { + Params.encode(message.params, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QueryParamsResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryParamsResponse } as QueryParamsResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.params = Params.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryParamsResponse { + const message = { ...baseQueryParamsResponse } as QueryParamsResponse; + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromJSON(object.params); + } else { + message.params = undefined; + } + return message; + }, + + toJSON(message: QueryParamsResponse): unknown { + const obj: any = {}; + message.params !== undefined && + (obj.params = message.params ? Params.toJSON(message.params) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): QueryParamsResponse { + const message = { ...baseQueryParamsResponse } as QueryParamsResponse; + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromPartial(object.params); + } else { + message.params = undefined; + } + return message; + }, +}; + +/** Query defines the gRPC querier service. */ +export interface Query { + /** Parameters queries the parameters of the module. */ + Params(request: QueryParamsRequest): Promise; +} + +export class QueryClientImpl implements Query { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + } + Params(request: QueryParamsRequest): Promise { + const data = QueryParamsRequest.encode(request).finish(); + const promise = this.rpc.request("bze.v1.rewards.Query", "Params", data); + return promise.then((data) => QueryParamsResponse.decode(new Reader(data))); + } +} + +interface Rpc { + request( + service: string, + method: string, + data: Uint8Array + ): Promise; +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/tx.ts b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/tx.ts new file mode 100644 index 00000000..0e007f76 --- /dev/null +++ b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/tx.ts @@ -0,0 +1,20 @@ +/* eslint-disable */ +export const protobufPackage = "bze.v1.rewards"; + +/** Msg defines the Msg service. */ +export interface Msg {} + +export class MsgClientImpl implements Msg { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + } +} + +interface Rpc { + request( + service: string, + method: string, + data: Uint8Array + ): Promise; +} diff --git a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/package.json b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/package.json new file mode 100755 index 00000000..a11a7ee6 --- /dev/null +++ b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/package.json @@ -0,0 +1,18 @@ +{ + "name": "bze-v1-rewards-js", + "version": "0.1.0", + "description": "Autogenerated vuex store for Cosmos module bze.v1.rewards", + "author": "Starport Codegen ", + "homepage": "http://github.com/bze-alphateam/bze/x/rewards/types", + "license": "Apache-2.0", + "licenses": [ + { + "type": "Apache-2.0", + "url": "http://www.apache.org/licenses/LICENSE-2.0" + } + ], + "main": "index.js", + "publishConfig": { + "access": "public" + } +} \ No newline at end of file diff --git a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/vuex-root b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/vuex-root new file mode 100755 index 00000000..0fcc121a --- /dev/null +++ b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/vuex-root @@ -0,0 +1 @@ +THIS FILE IS GENERATED AUTOMATICALLY. DO NOT DELETE. diff --git a/vue/src/store/generated/bze-alphateam/bze/bzealphateam.bze.rewards/index.ts b/vue/src/store/generated/bze-alphateam/bze/bzealphateam.bze.rewards/index.ts new file mode 100755 index 00000000..fe6cb1fa --- /dev/null +++ b/vue/src/store/generated/bze-alphateam/bze/bzealphateam.bze.rewards/index.ts @@ -0,0 +1,141 @@ +import { txClient, queryClient, MissingWalletError , registry} from './module' + +import { Params } from "./module/types/rewards/params" + + +export { Params }; + +async function initTxClient(vuexGetters) { + return await txClient(vuexGetters['common/wallet/signer'], { + addr: vuexGetters['common/env/apiTendermint'] + }) +} + +async function initQueryClient(vuexGetters) { + return await queryClient({ + addr: vuexGetters['common/env/apiCosmos'] + }) +} + +function mergeResults(value, next_values) { + for (let prop of Object.keys(next_values)) { + if (Array.isArray(next_values[prop])) { + value[prop]=[...value[prop], ...next_values[prop]] + }else{ + value[prop]=next_values[prop] + } + } + return value +} + +function getStructure(template) { + let structure = { fields: [] } + for (const [key, value] of Object.entries(template)) { + let field: any = {} + field.name = key + field.type = typeof value + structure.fields.push(field) + } + return structure +} + +const getDefaultState = () => { + return { + Params: {}, + + _Structure: { + Params: getStructure(Params.fromPartial({})), + + }, + _Registry: registry, + _Subscriptions: new Set(), + } +} + +// initial state +const state = getDefaultState() + +export default { + namespaced: true, + state, + mutations: { + RESET_STATE(state) { + Object.assign(state, getDefaultState()) + }, + QUERY(state, { query, key, value }) { + state[query][JSON.stringify(key)] = value + }, + SUBSCRIBE(state, subscription) { + state._Subscriptions.add(JSON.stringify(subscription)) + }, + UNSUBSCRIBE(state, subscription) { + state._Subscriptions.delete(JSON.stringify(subscription)) + } + }, + getters: { + getParams: (state) => (params = { params: {}}) => { + if (!( params).query) { + ( params).query=null + } + return state.Params[JSON.stringify(params)] ?? {} + }, + + getTypeStructure: (state) => (type) => { + return state._Structure[type].fields + }, + getRegistry: (state) => { + return state._Registry + } + }, + actions: { + init({ dispatch, rootGetters }) { + console.log('Vuex module: bzealphateam.bze.rewards initialized!') + if (rootGetters['common/env/client']) { + rootGetters['common/env/client'].on('newblock', () => { + dispatch('StoreUpdate') + }) + } + }, + resetState({ commit }) { + commit('RESET_STATE') + }, + unsubscribe({ commit }, subscription) { + commit('UNSUBSCRIBE', subscription) + }, + async StoreUpdate({ state, dispatch }) { + state._Subscriptions.forEach(async (subscription) => { + try { + const sub=JSON.parse(subscription) + await dispatch(sub.action, sub.payload) + }catch(e) { + throw new Error('Subscriptions: ' + e.message) + } + }) + }, + + + + + + + async QueryParams({ commit, rootGetters, getters }, { options: { subscribe, all} = { subscribe:false, all:false}, params, query=null }) { + try { + const key = params ?? {}; + const queryClient=await initQueryClient(rootGetters) + let value= (await queryClient.queryParams()).data + + + commit('QUERY', { query: 'Params', key: { params: {...key}, query}, value }) + if (subscribe) commit('SUBSCRIBE', { action: 'QueryParams', payload: { options: { all }, params: {...key},query }}) + return getters['getParams']( { params: {...key}, query}) ?? {} + } catch (e) { + throw new Error('QueryClient:QueryParams API Node Unavailable. Could not perform query: ' + e.message) + + } + }, + + + + + } +} diff --git a/vue/src/store/generated/bze-alphateam/bze/bzealphateam.bze.rewards/module/index.ts b/vue/src/store/generated/bze-alphateam/bze/bzealphateam.bze.rewards/module/index.ts new file mode 100755 index 00000000..67d4b093 --- /dev/null +++ b/vue/src/store/generated/bze-alphateam/bze/bzealphateam.bze.rewards/module/index.ts @@ -0,0 +1,57 @@ +// THIS FILE IS GENERATED AUTOMATICALLY. DO NOT MODIFY. + +import { StdFee } from "@cosmjs/launchpad"; +import { SigningStargateClient } from "@cosmjs/stargate"; +import { Registry, OfflineSigner, EncodeObject, DirectSecp256k1HdWallet } from "@cosmjs/proto-signing"; +import { Api } from "./rest"; + + +const types = [ + +]; +export const MissingWalletError = new Error("wallet is required"); + +export const registry = new Registry(types); + +const defaultFee = { + amount: [], + gas: "200000", +}; + +interface TxClientOptions { + addr: string +} + +interface SignAndBroadcastOptions { + fee: StdFee, + memo?: string +} + +const txClient = async (wallet: OfflineSigner, { addr: addr }: TxClientOptions = { addr: "http://localhost:26657" }) => { + if (!wallet) throw MissingWalletError; + let client; + if (addr) { + client = await SigningStargateClient.connectWithSigner(addr, wallet, { registry }); + }else{ + client = await SigningStargateClient.offline( wallet, { registry }); + } + const { address } = (await wallet.getAccounts())[0]; + + return { + signAndBroadcast: (msgs: EncodeObject[], { fee, memo }: SignAndBroadcastOptions = {fee: defaultFee, memo: ""}) => client.signAndBroadcast(address, msgs, fee,memo), + + }; +}; + +interface QueryClientOptions { + addr: string +} + +const queryClient = async ({ addr: addr }: QueryClientOptions = { addr: "http://localhost:1317" }) => { + return new Api({ baseUrl: addr }); +}; + +export { + txClient, + queryClient, +}; diff --git a/vue/src/store/generated/bze-alphateam/bze/bzealphateam.bze.rewards/module/rest.ts b/vue/src/store/generated/bze-alphateam/bze/bzealphateam.bze.rewards/module/rest.ts new file mode 100644 index 00000000..63315243 --- /dev/null +++ b/vue/src/store/generated/bze-alphateam/bze/bzealphateam.bze.rewards/module/rest.ts @@ -0,0 +1,250 @@ +/* eslint-disable */ +/* tslint:disable */ +/* + * --------------------------------------------------------------- + * ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ## + * ## ## + * ## AUTHOR: acacode ## + * ## SOURCE: https://github.com/acacode/swagger-typescript-api ## + * --------------------------------------------------------------- + */ + +/** + * Params defines the parameters for the module. + */ +export interface BzerewardsParams { + createStakingRewardFee?: string; + createTradingRewardFee?: string; +} + +export interface ProtobufAny { + "@type"?: string; +} + +/** + * QueryParamsResponse is response type for the Query/Params RPC method. + */ +export interface RewardsQueryParamsResponse { + /** params holds all the parameters of this module. */ + params?: BzerewardsParams; +} + +export interface RpcStatus { + /** @format int32 */ + code?: number; + message?: string; + details?: ProtobufAny[]; +} + +export type QueryParamsType = Record; +export type ResponseFormat = keyof Omit; + +export interface FullRequestParams extends Omit { + /** set parameter to `true` for call `securityWorker` for this request */ + secure?: boolean; + /** request path */ + path: string; + /** content type of request body */ + type?: ContentType; + /** query params */ + query?: QueryParamsType; + /** format of response (i.e. response.json() -> format: "json") */ + format?: keyof Omit; + /** request body */ + body?: unknown; + /** base url */ + baseUrl?: string; + /** request cancellation token */ + cancelToken?: CancelToken; +} + +export type RequestParams = Omit; + +export interface ApiConfig { + baseUrl?: string; + baseApiParams?: Omit; + securityWorker?: (securityData: SecurityDataType) => RequestParams | void; +} + +export interface HttpResponse extends Response { + data: D; + error: E; +} + +type CancelToken = Symbol | string | number; + +export enum ContentType { + Json = "application/json", + FormData = "multipart/form-data", + UrlEncoded = "application/x-www-form-urlencoded", +} + +export class HttpClient { + public baseUrl: string = ""; + private securityData: SecurityDataType = null as any; + private securityWorker: null | ApiConfig["securityWorker"] = null; + private abortControllers = new Map(); + + private baseApiParams: RequestParams = { + credentials: "same-origin", + headers: {}, + redirect: "follow", + referrerPolicy: "no-referrer", + }; + + constructor(apiConfig: ApiConfig = {}) { + Object.assign(this, apiConfig); + } + + public setSecurityData = (data: SecurityDataType) => { + this.securityData = data; + }; + + private addQueryParam(query: QueryParamsType, key: string) { + const value = query[key]; + + return ( + encodeURIComponent(key) + + "=" + + encodeURIComponent(Array.isArray(value) ? value.join(",") : typeof value === "number" ? value : `${value}`) + ); + } + + protected toQueryString(rawQuery?: QueryParamsType): string { + const query = rawQuery || {}; + const keys = Object.keys(query).filter((key) => "undefined" !== typeof query[key]); + return keys + .map((key) => + typeof query[key] === "object" && !Array.isArray(query[key]) + ? this.toQueryString(query[key] as QueryParamsType) + : this.addQueryParam(query, key), + ) + .join("&"); + } + + protected addQueryParams(rawQuery?: QueryParamsType): string { + const queryString = this.toQueryString(rawQuery); + return queryString ? `?${queryString}` : ""; + } + + private contentFormatters: Record any> = { + [ContentType.Json]: (input: any) => + input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input, + [ContentType.FormData]: (input: any) => + Object.keys(input || {}).reduce((data, key) => { + data.append(key, input[key]); + return data; + }, new FormData()), + [ContentType.UrlEncoded]: (input: any) => this.toQueryString(input), + }; + + private mergeRequestParams(params1: RequestParams, params2?: RequestParams): RequestParams { + return { + ...this.baseApiParams, + ...params1, + ...(params2 || {}), + headers: { + ...(this.baseApiParams.headers || {}), + ...(params1.headers || {}), + ...((params2 && params2.headers) || {}), + }, + }; + } + + private createAbortSignal = (cancelToken: CancelToken): AbortSignal | undefined => { + if (this.abortControllers.has(cancelToken)) { + const abortController = this.abortControllers.get(cancelToken); + if (abortController) { + return abortController.signal; + } + return void 0; + } + + const abortController = new AbortController(); + this.abortControllers.set(cancelToken, abortController); + return abortController.signal; + }; + + public abortRequest = (cancelToken: CancelToken) => { + const abortController = this.abortControllers.get(cancelToken); + + if (abortController) { + abortController.abort(); + this.abortControllers.delete(cancelToken); + } + }; + + public request = ({ + body, + secure, + path, + type, + query, + format = "json", + baseUrl, + cancelToken, + ...params + }: FullRequestParams): Promise> => { + const secureParams = (secure && this.securityWorker && this.securityWorker(this.securityData)) || {}; + const requestParams = this.mergeRequestParams(params, secureParams); + const queryString = query && this.toQueryString(query); + const payloadFormatter = this.contentFormatters[type || ContentType.Json]; + + return fetch(`${baseUrl || this.baseUrl || ""}${path}${queryString ? `?${queryString}` : ""}`, { + ...requestParams, + headers: { + ...(type && type !== ContentType.FormData ? { "Content-Type": type } : {}), + ...(requestParams.headers || {}), + }, + signal: cancelToken ? this.createAbortSignal(cancelToken) : void 0, + body: typeof body === "undefined" || body === null ? null : payloadFormatter(body), + }).then(async (response) => { + const r = response as HttpResponse; + r.data = (null as unknown) as T; + r.error = (null as unknown) as E; + + const data = await response[format]() + .then((data) => { + if (r.ok) { + r.data = data; + } else { + r.error = data; + } + return r; + }) + .catch((e) => { + r.error = e; + return r; + }); + + if (cancelToken) { + this.abortControllers.delete(cancelToken); + } + + if (!response.ok) throw data; + return data; + }); + }; +} + +/** + * @title rewards/genesis.proto + * @version version not set + */ +export class Api extends HttpClient { + /** + * No description + * + * @tags Query + * @name QueryParams + * @summary Parameters queries the parameters of the module. + * @request GET:/bze-alphateam/bze/rewards/params + */ + queryParams = (params: RequestParams = {}) => + this.request({ + path: `/bze-alphateam/bze/rewards/params`, + method: "GET", + format: "json", + ...params, + }); +} diff --git a/vue/src/store/generated/bze-alphateam/bze/bzealphateam.bze.rewards/module/types/cosmos/base/query/v1beta1/pagination.ts b/vue/src/store/generated/bze-alphateam/bze/bzealphateam.bze.rewards/module/types/cosmos/base/query/v1beta1/pagination.ts new file mode 100644 index 00000000..9c87ac0c --- /dev/null +++ b/vue/src/store/generated/bze-alphateam/bze/bzealphateam.bze.rewards/module/types/cosmos/base/query/v1beta1/pagination.ts @@ -0,0 +1,328 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "cosmos.base.query.v1beta1"; + +/** + * PageRequest is to be embedded in gRPC request messages for efficient + * pagination. Ex: + * + * message SomeRequest { + * Foo some_parameter = 1; + * PageRequest pagination = 2; + * } + */ +export interface PageRequest { + /** + * key is a value returned in PageResponse.next_key to begin + * querying the next page most efficiently. Only one of offset or key + * should be set. + */ + key: Uint8Array; + /** + * offset is a numeric offset that can be used when key is unavailable. + * It is less efficient than using key. Only one of offset or key should + * be set. + */ + offset: number; + /** + * limit is the total number of results to be returned in the result page. + * If left empty it will default to a value to be set by each app. + */ + limit: number; + /** + * count_total is set to true to indicate that the result set should include + * a count of the total number of items available for pagination in UIs. + * count_total is only respected when offset is used. It is ignored when key + * is set. + */ + count_total: boolean; + /** + * reverse is set to true if results are to be returned in the descending order. + * + * Since: cosmos-sdk 0.43 + */ + reverse: boolean; +} + +/** + * PageResponse is to be embedded in gRPC response messages where the + * corresponding request message has used PageRequest. + * + * message SomeResponse { + * repeated Bar results = 1; + * PageResponse page = 2; + * } + */ +export interface PageResponse { + /** + * next_key is the key to be passed to PageRequest.key to + * query the next page most efficiently + */ + next_key: Uint8Array; + /** + * total is total number of results available if PageRequest.count_total + * was set, its value is undefined otherwise + */ + total: number; +} + +const basePageRequest: object = { + offset: 0, + limit: 0, + count_total: false, + reverse: false, +}; + +export const PageRequest = { + encode(message: PageRequest, writer: Writer = Writer.create()): Writer { + if (message.key.length !== 0) { + writer.uint32(10).bytes(message.key); + } + if (message.offset !== 0) { + writer.uint32(16).uint64(message.offset); + } + if (message.limit !== 0) { + writer.uint32(24).uint64(message.limit); + } + if (message.count_total === true) { + writer.uint32(32).bool(message.count_total); + } + if (message.reverse === true) { + writer.uint32(40).bool(message.reverse); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): PageRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...basePageRequest } as PageRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.key = reader.bytes(); + break; + case 2: + message.offset = longToNumber(reader.uint64() as Long); + break; + case 3: + message.limit = longToNumber(reader.uint64() as Long); + break; + case 4: + message.count_total = reader.bool(); + break; + case 5: + message.reverse = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): PageRequest { + const message = { ...basePageRequest } as PageRequest; + if (object.key !== undefined && object.key !== null) { + message.key = bytesFromBase64(object.key); + } + if (object.offset !== undefined && object.offset !== null) { + message.offset = Number(object.offset); + } else { + message.offset = 0; + } + if (object.limit !== undefined && object.limit !== null) { + message.limit = Number(object.limit); + } else { + message.limit = 0; + } + if (object.count_total !== undefined && object.count_total !== null) { + message.count_total = Boolean(object.count_total); + } else { + message.count_total = false; + } + if (object.reverse !== undefined && object.reverse !== null) { + message.reverse = Boolean(object.reverse); + } else { + message.reverse = false; + } + return message; + }, + + toJSON(message: PageRequest): unknown { + const obj: any = {}; + message.key !== undefined && + (obj.key = base64FromBytes( + message.key !== undefined ? message.key : new Uint8Array() + )); + message.offset !== undefined && (obj.offset = message.offset); + message.limit !== undefined && (obj.limit = message.limit); + message.count_total !== undefined && + (obj.count_total = message.count_total); + message.reverse !== undefined && (obj.reverse = message.reverse); + return obj; + }, + + fromPartial(object: DeepPartial): PageRequest { + const message = { ...basePageRequest } as PageRequest; + if (object.key !== undefined && object.key !== null) { + message.key = object.key; + } else { + message.key = new Uint8Array(); + } + if (object.offset !== undefined && object.offset !== null) { + message.offset = object.offset; + } else { + message.offset = 0; + } + if (object.limit !== undefined && object.limit !== null) { + message.limit = object.limit; + } else { + message.limit = 0; + } + if (object.count_total !== undefined && object.count_total !== null) { + message.count_total = object.count_total; + } else { + message.count_total = false; + } + if (object.reverse !== undefined && object.reverse !== null) { + message.reverse = object.reverse; + } else { + message.reverse = false; + } + return message; + }, +}; + +const basePageResponse: object = { total: 0 }; + +export const PageResponse = { + encode(message: PageResponse, writer: Writer = Writer.create()): Writer { + if (message.next_key.length !== 0) { + writer.uint32(10).bytes(message.next_key); + } + if (message.total !== 0) { + writer.uint32(16).uint64(message.total); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): PageResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...basePageResponse } as PageResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.next_key = reader.bytes(); + break; + case 2: + message.total = longToNumber(reader.uint64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): PageResponse { + const message = { ...basePageResponse } as PageResponse; + if (object.next_key !== undefined && object.next_key !== null) { + message.next_key = bytesFromBase64(object.next_key); + } + if (object.total !== undefined && object.total !== null) { + message.total = Number(object.total); + } else { + message.total = 0; + } + return message; + }, + + toJSON(message: PageResponse): unknown { + const obj: any = {}; + message.next_key !== undefined && + (obj.next_key = base64FromBytes( + message.next_key !== undefined ? message.next_key : new Uint8Array() + )); + message.total !== undefined && (obj.total = message.total); + return obj; + }, + + fromPartial(object: DeepPartial): PageResponse { + const message = { ...basePageResponse } as PageResponse; + if (object.next_key !== undefined && object.next_key !== null) { + message.next_key = object.next_key; + } else { + message.next_key = new Uint8Array(); + } + if (object.total !== undefined && object.total !== null) { + message.total = object.total; + } else { + message.total = 0; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/vue/src/store/generated/bze-alphateam/bze/bzealphateam.bze.rewards/module/types/gogoproto/gogo.ts b/vue/src/store/generated/bze-alphateam/bze/bzealphateam.bze.rewards/module/types/gogoproto/gogo.ts new file mode 100644 index 00000000..3f41a047 --- /dev/null +++ b/vue/src/store/generated/bze-alphateam/bze/bzealphateam.bze.rewards/module/types/gogoproto/gogo.ts @@ -0,0 +1,2 @@ +/* eslint-disable */ +export const protobufPackage = "gogoproto"; diff --git a/vue/src/store/generated/bze-alphateam/bze/bzealphateam.bze.rewards/module/types/google/api/annotations.ts b/vue/src/store/generated/bze-alphateam/bze/bzealphateam.bze.rewards/module/types/google/api/annotations.ts new file mode 100644 index 00000000..aace4787 --- /dev/null +++ b/vue/src/store/generated/bze-alphateam/bze/bzealphateam.bze.rewards/module/types/google/api/annotations.ts @@ -0,0 +1,2 @@ +/* eslint-disable */ +export const protobufPackage = "google.api"; diff --git a/vue/src/store/generated/bze-alphateam/bze/bzealphateam.bze.rewards/module/types/google/api/http.ts b/vue/src/store/generated/bze-alphateam/bze/bzealphateam.bze.rewards/module/types/google/api/http.ts new file mode 100644 index 00000000..ccadff68 --- /dev/null +++ b/vue/src/store/generated/bze-alphateam/bze/bzealphateam.bze.rewards/module/types/google/api/http.ts @@ -0,0 +1,706 @@ +/* eslint-disable */ +import { Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "google.api"; + +/** + * Defines the HTTP configuration for an API service. It contains a list of + * [HttpRule][google.api.HttpRule], each specifying the mapping of an RPC method + * to one or more HTTP REST API methods. + */ +export interface Http { + /** + * A list of HTTP configuration rules that apply to individual API methods. + * + * **NOTE:** All service configuration rules follow "last one wins" order. + */ + rules: HttpRule[]; + /** + * When set to true, URL path parmeters will be fully URI-decoded except in + * cases of single segment matches in reserved expansion, where "%2F" will be + * left encoded. + * + * The default behavior is to not decode RFC 6570 reserved characters in multi + * segment matches. + */ + fully_decode_reserved_expansion: boolean; +} + +/** + * `HttpRule` defines the mapping of an RPC method to one or more HTTP + * REST API methods. The mapping specifies how different portions of the RPC + * request message are mapped to URL path, URL query parameters, and + * HTTP request body. The mapping is typically specified as an + * `google.api.http` annotation on the RPC method, + * see "google/api/annotations.proto" for details. + * + * The mapping consists of a field specifying the path template and + * method kind. The path template can refer to fields in the request + * message, as in the example below which describes a REST GET + * operation on a resource collection of messages: + * + * + * service Messaging { + * rpc GetMessage(GetMessageRequest) returns (Message) { + * option (google.api.http).get = "/v1/messages/{message_id}/{sub.subfield}"; + * } + * } + * message GetMessageRequest { + * message SubMessage { + * string subfield = 1; + * } + * string message_id = 1; // mapped to the URL + * SubMessage sub = 2; // `sub.subfield` is url-mapped + * } + * message Message { + * string text = 1; // content of the resource + * } + * + * The same http annotation can alternatively be expressed inside the + * `GRPC API Configuration` YAML file. + * + * http: + * rules: + * - selector: .Messaging.GetMessage + * get: /v1/messages/{message_id}/{sub.subfield} + * + * This definition enables an automatic, bidrectional mapping of HTTP + * JSON to RPC. Example: + * + * HTTP | RPC + * -----|----- + * `GET /v1/messages/123456/foo` | `GetMessage(message_id: "123456" sub: SubMessage(subfield: "foo"))` + * + * In general, not only fields but also field paths can be referenced + * from a path pattern. Fields mapped to the path pattern cannot be + * repeated and must have a primitive (non-message) type. + * + * Any fields in the request message which are not bound by the path + * pattern automatically become (optional) HTTP query + * parameters. Assume the following definition of the request message: + * + * + * service Messaging { + * rpc GetMessage(GetMessageRequest) returns (Message) { + * option (google.api.http).get = "/v1/messages/{message_id}"; + * } + * } + * message GetMessageRequest { + * message SubMessage { + * string subfield = 1; + * } + * string message_id = 1; // mapped to the URL + * int64 revision = 2; // becomes a parameter + * SubMessage sub = 3; // `sub.subfield` becomes a parameter + * } + * + * + * This enables a HTTP JSON to RPC mapping as below: + * + * HTTP | RPC + * -----|----- + * `GET /v1/messages/123456?revision=2&sub.subfield=foo` | `GetMessage(message_id: "123456" revision: 2 sub: SubMessage(subfield: "foo"))` + * + * Note that fields which are mapped to HTTP parameters must have a + * primitive type or a repeated primitive type. Message types are not + * allowed. In the case of a repeated type, the parameter can be + * repeated in the URL, as in `...?param=A¶m=B`. + * + * For HTTP method kinds which allow a request body, the `body` field + * specifies the mapping. Consider a REST update method on the + * message resource collection: + * + * + * service Messaging { + * rpc UpdateMessage(UpdateMessageRequest) returns (Message) { + * option (google.api.http) = { + * put: "/v1/messages/{message_id}" + * body: "message" + * }; + * } + * } + * message UpdateMessageRequest { + * string message_id = 1; // mapped to the URL + * Message message = 2; // mapped to the body + * } + * + * + * The following HTTP JSON to RPC mapping is enabled, where the + * representation of the JSON in the request body is determined by + * protos JSON encoding: + * + * HTTP | RPC + * -----|----- + * `PUT /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: "123456" message { text: "Hi!" })` + * + * The special name `*` can be used in the body mapping to define that + * every field not bound by the path template should be mapped to the + * request body. This enables the following alternative definition of + * the update method: + * + * service Messaging { + * rpc UpdateMessage(Message) returns (Message) { + * option (google.api.http) = { + * put: "/v1/messages/{message_id}" + * body: "*" + * }; + * } + * } + * message Message { + * string message_id = 1; + * string text = 2; + * } + * + * + * The following HTTP JSON to RPC mapping is enabled: + * + * HTTP | RPC + * -----|----- + * `PUT /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: "123456" text: "Hi!")` + * + * Note that when using `*` in the body mapping, it is not possible to + * have HTTP parameters, as all fields not bound by the path end in + * the body. This makes this option more rarely used in practice of + * defining REST APIs. The common usage of `*` is in custom methods + * which don't use the URL at all for transferring data. + * + * It is possible to define multiple HTTP methods for one RPC by using + * the `additional_bindings` option. Example: + * + * service Messaging { + * rpc GetMessage(GetMessageRequest) returns (Message) { + * option (google.api.http) = { + * get: "/v1/messages/{message_id}" + * additional_bindings { + * get: "/v1/users/{user_id}/messages/{message_id}" + * } + * }; + * } + * } + * message GetMessageRequest { + * string message_id = 1; + * string user_id = 2; + * } + * + * + * This enables the following two alternative HTTP JSON to RPC + * mappings: + * + * HTTP | RPC + * -----|----- + * `GET /v1/messages/123456` | `GetMessage(message_id: "123456")` + * `GET /v1/users/me/messages/123456` | `GetMessage(user_id: "me" message_id: "123456")` + * + * # Rules for HTTP mapping + * + * The rules for mapping HTTP path, query parameters, and body fields + * to the request message are as follows: + * + * 1. The `body` field specifies either `*` or a field path, or is + * omitted. If omitted, it indicates there is no HTTP request body. + * 2. Leaf fields (recursive expansion of nested messages in the + * request) can be classified into three types: + * (a) Matched in the URL template. + * (b) Covered by body (if body is `*`, everything except (a) fields; + * else everything under the body field) + * (c) All other fields. + * 3. URL query parameters found in the HTTP request are mapped to (c) fields. + * 4. Any body sent with an HTTP request can contain only (b) fields. + * + * The syntax of the path template is as follows: + * + * Template = "/" Segments [ Verb ] ; + * Segments = Segment { "/" Segment } ; + * Segment = "*" | "**" | LITERAL | Variable ; + * Variable = "{" FieldPath [ "=" Segments ] "}" ; + * FieldPath = IDENT { "." IDENT } ; + * Verb = ":" LITERAL ; + * + * The syntax `*` matches a single path segment. The syntax `**` matches zero + * or more path segments, which must be the last part of the path except the + * `Verb`. The syntax `LITERAL` matches literal text in the path. + * + * The syntax `Variable` matches part of the URL path as specified by its + * template. A variable template must not contain other variables. If a variable + * matches a single path segment, its template may be omitted, e.g. `{var}` + * is equivalent to `{var=*}`. + * + * If a variable contains exactly one path segment, such as `"{var}"` or + * `"{var=*}"`, when such a variable is expanded into a URL path, all characters + * except `[-_.~0-9a-zA-Z]` are percent-encoded. Such variables show up in the + * Discovery Document as `{var}`. + * + * If a variable contains one or more path segments, such as `"{var=foo/*}"` + * or `"{var=**}"`, when such a variable is expanded into a URL path, all + * characters except `[-_.~/0-9a-zA-Z]` are percent-encoded. Such variables + * show up in the Discovery Document as `{+var}`. + * + * NOTE: While the single segment variable matches the semantics of + * [RFC 6570](https://tools.ietf.org/html/rfc6570) Section 3.2.2 + * Simple String Expansion, the multi segment variable **does not** match + * RFC 6570 Reserved Expansion. The reason is that the Reserved Expansion + * does not expand special characters like `?` and `#`, which would lead + * to invalid URLs. + * + * NOTE: the field paths in variables and in the `body` must not refer to + * repeated fields or map fields. + */ +export interface HttpRule { + /** + * Selects methods to which this rule applies. + * + * Refer to [selector][google.api.DocumentationRule.selector] for syntax details. + */ + selector: string; + /** Used for listing and getting information about resources. */ + get: string | undefined; + /** Used for updating a resource. */ + put: string | undefined; + /** Used for creating a resource. */ + post: string | undefined; + /** Used for deleting a resource. */ + delete: string | undefined; + /** Used for updating a resource. */ + patch: string | undefined; + /** + * The custom pattern is used for specifying an HTTP method that is not + * included in the `pattern` field, such as HEAD, or "*" to leave the + * HTTP method unspecified for this rule. The wild-card rule is useful + * for services that provide content to Web (HTML) clients. + */ + custom: CustomHttpPattern | undefined; + /** + * The name of the request field whose value is mapped to the HTTP body, or + * `*` for mapping all fields not captured by the path pattern to the HTTP + * body. NOTE: the referred field must not be a repeated field and must be + * present at the top-level of request message type. + */ + body: string; + /** + * Optional. The name of the response field whose value is mapped to the HTTP + * body of response. Other response fields are ignored. When + * not set, the response message will be used as HTTP body of response. + */ + response_body: string; + /** + * Additional HTTP bindings for the selector. Nested bindings must + * not contain an `additional_bindings` field themselves (that is, + * the nesting may only be one level deep). + */ + additional_bindings: HttpRule[]; +} + +/** A custom pattern is used for defining custom HTTP verb. */ +export interface CustomHttpPattern { + /** The name of this custom HTTP verb. */ + kind: string; + /** The path matched by this custom verb. */ + path: string; +} + +const baseHttp: object = { fully_decode_reserved_expansion: false }; + +export const Http = { + encode(message: Http, writer: Writer = Writer.create()): Writer { + for (const v of message.rules) { + HttpRule.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.fully_decode_reserved_expansion === true) { + writer.uint32(16).bool(message.fully_decode_reserved_expansion); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Http { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseHttp } as Http; + message.rules = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.rules.push(HttpRule.decode(reader, reader.uint32())); + break; + case 2: + message.fully_decode_reserved_expansion = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Http { + const message = { ...baseHttp } as Http; + message.rules = []; + if (object.rules !== undefined && object.rules !== null) { + for (const e of object.rules) { + message.rules.push(HttpRule.fromJSON(e)); + } + } + if ( + object.fully_decode_reserved_expansion !== undefined && + object.fully_decode_reserved_expansion !== null + ) { + message.fully_decode_reserved_expansion = Boolean( + object.fully_decode_reserved_expansion + ); + } else { + message.fully_decode_reserved_expansion = false; + } + return message; + }, + + toJSON(message: Http): unknown { + const obj: any = {}; + if (message.rules) { + obj.rules = message.rules.map((e) => + e ? HttpRule.toJSON(e) : undefined + ); + } else { + obj.rules = []; + } + message.fully_decode_reserved_expansion !== undefined && + (obj.fully_decode_reserved_expansion = + message.fully_decode_reserved_expansion); + return obj; + }, + + fromPartial(object: DeepPartial): Http { + const message = { ...baseHttp } as Http; + message.rules = []; + if (object.rules !== undefined && object.rules !== null) { + for (const e of object.rules) { + message.rules.push(HttpRule.fromPartial(e)); + } + } + if ( + object.fully_decode_reserved_expansion !== undefined && + object.fully_decode_reserved_expansion !== null + ) { + message.fully_decode_reserved_expansion = + object.fully_decode_reserved_expansion; + } else { + message.fully_decode_reserved_expansion = false; + } + return message; + }, +}; + +const baseHttpRule: object = { selector: "", body: "", response_body: "" }; + +export const HttpRule = { + encode(message: HttpRule, writer: Writer = Writer.create()): Writer { + if (message.selector !== "") { + writer.uint32(10).string(message.selector); + } + if (message.get !== undefined) { + writer.uint32(18).string(message.get); + } + if (message.put !== undefined) { + writer.uint32(26).string(message.put); + } + if (message.post !== undefined) { + writer.uint32(34).string(message.post); + } + if (message.delete !== undefined) { + writer.uint32(42).string(message.delete); + } + if (message.patch !== undefined) { + writer.uint32(50).string(message.patch); + } + if (message.custom !== undefined) { + CustomHttpPattern.encode( + message.custom, + writer.uint32(66).fork() + ).ldelim(); + } + if (message.body !== "") { + writer.uint32(58).string(message.body); + } + if (message.response_body !== "") { + writer.uint32(98).string(message.response_body); + } + for (const v of message.additional_bindings) { + HttpRule.encode(v!, writer.uint32(90).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): HttpRule { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseHttpRule } as HttpRule; + message.additional_bindings = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.selector = reader.string(); + break; + case 2: + message.get = reader.string(); + break; + case 3: + message.put = reader.string(); + break; + case 4: + message.post = reader.string(); + break; + case 5: + message.delete = reader.string(); + break; + case 6: + message.patch = reader.string(); + break; + case 8: + message.custom = CustomHttpPattern.decode(reader, reader.uint32()); + break; + case 7: + message.body = reader.string(); + break; + case 12: + message.response_body = reader.string(); + break; + case 11: + message.additional_bindings.push( + HttpRule.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): HttpRule { + const message = { ...baseHttpRule } as HttpRule; + message.additional_bindings = []; + if (object.selector !== undefined && object.selector !== null) { + message.selector = String(object.selector); + } else { + message.selector = ""; + } + if (object.get !== undefined && object.get !== null) { + message.get = String(object.get); + } else { + message.get = undefined; + } + if (object.put !== undefined && object.put !== null) { + message.put = String(object.put); + } else { + message.put = undefined; + } + if (object.post !== undefined && object.post !== null) { + message.post = String(object.post); + } else { + message.post = undefined; + } + if (object.delete !== undefined && object.delete !== null) { + message.delete = String(object.delete); + } else { + message.delete = undefined; + } + if (object.patch !== undefined && object.patch !== null) { + message.patch = String(object.patch); + } else { + message.patch = undefined; + } + if (object.custom !== undefined && object.custom !== null) { + message.custom = CustomHttpPattern.fromJSON(object.custom); + } else { + message.custom = undefined; + } + if (object.body !== undefined && object.body !== null) { + message.body = String(object.body); + } else { + message.body = ""; + } + if (object.response_body !== undefined && object.response_body !== null) { + message.response_body = String(object.response_body); + } else { + message.response_body = ""; + } + if ( + object.additional_bindings !== undefined && + object.additional_bindings !== null + ) { + for (const e of object.additional_bindings) { + message.additional_bindings.push(HttpRule.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: HttpRule): unknown { + const obj: any = {}; + message.selector !== undefined && (obj.selector = message.selector); + message.get !== undefined && (obj.get = message.get); + message.put !== undefined && (obj.put = message.put); + message.post !== undefined && (obj.post = message.post); + message.delete !== undefined && (obj.delete = message.delete); + message.patch !== undefined && (obj.patch = message.patch); + message.custom !== undefined && + (obj.custom = message.custom + ? CustomHttpPattern.toJSON(message.custom) + : undefined); + message.body !== undefined && (obj.body = message.body); + message.response_body !== undefined && + (obj.response_body = message.response_body); + if (message.additional_bindings) { + obj.additional_bindings = message.additional_bindings.map((e) => + e ? HttpRule.toJSON(e) : undefined + ); + } else { + obj.additional_bindings = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): HttpRule { + const message = { ...baseHttpRule } as HttpRule; + message.additional_bindings = []; + if (object.selector !== undefined && object.selector !== null) { + message.selector = object.selector; + } else { + message.selector = ""; + } + if (object.get !== undefined && object.get !== null) { + message.get = object.get; + } else { + message.get = undefined; + } + if (object.put !== undefined && object.put !== null) { + message.put = object.put; + } else { + message.put = undefined; + } + if (object.post !== undefined && object.post !== null) { + message.post = object.post; + } else { + message.post = undefined; + } + if (object.delete !== undefined && object.delete !== null) { + message.delete = object.delete; + } else { + message.delete = undefined; + } + if (object.patch !== undefined && object.patch !== null) { + message.patch = object.patch; + } else { + message.patch = undefined; + } + if (object.custom !== undefined && object.custom !== null) { + message.custom = CustomHttpPattern.fromPartial(object.custom); + } else { + message.custom = undefined; + } + if (object.body !== undefined && object.body !== null) { + message.body = object.body; + } else { + message.body = ""; + } + if (object.response_body !== undefined && object.response_body !== null) { + message.response_body = object.response_body; + } else { + message.response_body = ""; + } + if ( + object.additional_bindings !== undefined && + object.additional_bindings !== null + ) { + for (const e of object.additional_bindings) { + message.additional_bindings.push(HttpRule.fromPartial(e)); + } + } + return message; + }, +}; + +const baseCustomHttpPattern: object = { kind: "", path: "" }; + +export const CustomHttpPattern = { + encode(message: CustomHttpPattern, writer: Writer = Writer.create()): Writer { + if (message.kind !== "") { + writer.uint32(10).string(message.kind); + } + if (message.path !== "") { + writer.uint32(18).string(message.path); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): CustomHttpPattern { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseCustomHttpPattern } as CustomHttpPattern; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.kind = reader.string(); + break; + case 2: + message.path = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): CustomHttpPattern { + const message = { ...baseCustomHttpPattern } as CustomHttpPattern; + if (object.kind !== undefined && object.kind !== null) { + message.kind = String(object.kind); + } else { + message.kind = ""; + } + if (object.path !== undefined && object.path !== null) { + message.path = String(object.path); + } else { + message.path = ""; + } + return message; + }, + + toJSON(message: CustomHttpPattern): unknown { + const obj: any = {}; + message.kind !== undefined && (obj.kind = message.kind); + message.path !== undefined && (obj.path = message.path); + return obj; + }, + + fromPartial(object: DeepPartial): CustomHttpPattern { + const message = { ...baseCustomHttpPattern } as CustomHttpPattern; + if (object.kind !== undefined && object.kind !== null) { + message.kind = object.kind; + } else { + message.kind = ""; + } + if (object.path !== undefined && object.path !== null) { + message.path = object.path; + } else { + message.path = ""; + } + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/vue/src/store/generated/bze-alphateam/bze/bzealphateam.bze.rewards/module/types/google/protobuf/descriptor.ts b/vue/src/store/generated/bze-alphateam/bze/bzealphateam.bze.rewards/module/types/google/protobuf/descriptor.ts new file mode 100644 index 00000000..a0167cb2 --- /dev/null +++ b/vue/src/store/generated/bze-alphateam/bze/bzealphateam.bze.rewards/module/types/google/protobuf/descriptor.ts @@ -0,0 +1,5314 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "google.protobuf"; + +/** + * The protocol compiler can output a FileDescriptorSet containing the .proto + * files it parses. + */ +export interface FileDescriptorSet { + file: FileDescriptorProto[]; +} + +/** Describes a complete .proto file. */ +export interface FileDescriptorProto { + /** file name, relative to root of source tree */ + name: string; + /** e.g. "foo", "foo.bar", etc. */ + package: string; + /** Names of files imported by this file. */ + dependency: string[]; + /** Indexes of the public imported files in the dependency list above. */ + public_dependency: number[]; + /** + * Indexes of the weak imported files in the dependency list. + * For Google-internal migration only. Do not use. + */ + weak_dependency: number[]; + /** All top-level definitions in this file. */ + message_type: DescriptorProto[]; + enum_type: EnumDescriptorProto[]; + service: ServiceDescriptorProto[]; + extension: FieldDescriptorProto[]; + options: FileOptions | undefined; + /** + * This field contains optional information about the original source code. + * You may safely remove this entire field without harming runtime + * functionality of the descriptors -- the information is needed only by + * development tools. + */ + source_code_info: SourceCodeInfo | undefined; + /** + * The syntax of the proto file. + * The supported values are "proto2" and "proto3". + */ + syntax: string; +} + +/** Describes a message type. */ +export interface DescriptorProto { + name: string; + field: FieldDescriptorProto[]; + extension: FieldDescriptorProto[]; + nested_type: DescriptorProto[]; + enum_type: EnumDescriptorProto[]; + extension_range: DescriptorProto_ExtensionRange[]; + oneof_decl: OneofDescriptorProto[]; + options: MessageOptions | undefined; + reserved_range: DescriptorProto_ReservedRange[]; + /** + * Reserved field names, which may not be used by fields in the same message. + * A given name may only be reserved once. + */ + reserved_name: string[]; +} + +export interface DescriptorProto_ExtensionRange { + /** Inclusive. */ + start: number; + /** Exclusive. */ + end: number; + options: ExtensionRangeOptions | undefined; +} + +/** + * Range of reserved tag numbers. Reserved tag numbers may not be used by + * fields or extension ranges in the same message. Reserved ranges may + * not overlap. + */ +export interface DescriptorProto_ReservedRange { + /** Inclusive. */ + start: number; + /** Exclusive. */ + end: number; +} + +export interface ExtensionRangeOptions { + /** The parser stores options it doesn't recognize here. See above. */ + uninterpreted_option: UninterpretedOption[]; +} + +/** Describes a field within a message. */ +export interface FieldDescriptorProto { + name: string; + number: number; + label: FieldDescriptorProto_Label; + /** + * If type_name is set, this need not be set. If both this and type_name + * are set, this must be one of TYPE_ENUM, TYPE_MESSAGE or TYPE_GROUP. + */ + type: FieldDescriptorProto_Type; + /** + * For message and enum types, this is the name of the type. If the name + * starts with a '.', it is fully-qualified. Otherwise, C++-like scoping + * rules are used to find the type (i.e. first the nested types within this + * message are searched, then within the parent, on up to the root + * namespace). + */ + type_name: string; + /** + * For extensions, this is the name of the type being extended. It is + * resolved in the same manner as type_name. + */ + extendee: string; + /** + * For numeric types, contains the original text representation of the value. + * For booleans, "true" or "false". + * For strings, contains the default text contents (not escaped in any way). + * For bytes, contains the C escaped value. All bytes >= 128 are escaped. + * TODO(kenton): Base-64 encode? + */ + default_value: string; + /** + * If set, gives the index of a oneof in the containing type's oneof_decl + * list. This field is a member of that oneof. + */ + oneof_index: number; + /** + * JSON name of this field. The value is set by protocol compiler. If the + * user has set a "json_name" option on this field, that option's value + * will be used. Otherwise, it's deduced from the field's name by converting + * it to camelCase. + */ + json_name: string; + options: FieldOptions | undefined; + /** + * If true, this is a proto3 "optional". When a proto3 field is optional, it + * tracks presence regardless of field type. + * + * When proto3_optional is true, this field must be belong to a oneof to + * signal to old proto3 clients that presence is tracked for this field. This + * oneof is known as a "synthetic" oneof, and this field must be its sole + * member (each proto3 optional field gets its own synthetic oneof). Synthetic + * oneofs exist in the descriptor only, and do not generate any API. Synthetic + * oneofs must be ordered after all "real" oneofs. + * + * For message fields, proto3_optional doesn't create any semantic change, + * since non-repeated message fields always track presence. However it still + * indicates the semantic detail of whether the user wrote "optional" or not. + * This can be useful for round-tripping the .proto file. For consistency we + * give message fields a synthetic oneof also, even though it is not required + * to track presence. This is especially important because the parser can't + * tell if a field is a message or an enum, so it must always create a + * synthetic oneof. + * + * Proto2 optional fields do not set this flag, because they already indicate + * optional with `LABEL_OPTIONAL`. + */ + proto3_optional: boolean; +} + +export enum FieldDescriptorProto_Type { + /** + * TYPE_DOUBLE - 0 is reserved for errors. + * Order is weird for historical reasons. + */ + TYPE_DOUBLE = 1, + TYPE_FLOAT = 2, + /** + * TYPE_INT64 - Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT64 if + * negative values are likely. + */ + TYPE_INT64 = 3, + TYPE_UINT64 = 4, + /** + * TYPE_INT32 - Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT32 if + * negative values are likely. + */ + TYPE_INT32 = 5, + TYPE_FIXED64 = 6, + TYPE_FIXED32 = 7, + TYPE_BOOL = 8, + TYPE_STRING = 9, + /** + * TYPE_GROUP - Tag-delimited aggregate. + * Group type is deprecated and not supported in proto3. However, Proto3 + * implementations should still be able to parse the group wire format and + * treat group fields as unknown fields. + */ + TYPE_GROUP = 10, + /** TYPE_MESSAGE - Length-delimited aggregate. */ + TYPE_MESSAGE = 11, + /** TYPE_BYTES - New in version 2. */ + TYPE_BYTES = 12, + TYPE_UINT32 = 13, + TYPE_ENUM = 14, + TYPE_SFIXED32 = 15, + TYPE_SFIXED64 = 16, + /** TYPE_SINT32 - Uses ZigZag encoding. */ + TYPE_SINT32 = 17, + /** TYPE_SINT64 - Uses ZigZag encoding. */ + TYPE_SINT64 = 18, + UNRECOGNIZED = -1, +} + +export function fieldDescriptorProto_TypeFromJSON( + object: any +): FieldDescriptorProto_Type { + switch (object) { + case 1: + case "TYPE_DOUBLE": + return FieldDescriptorProto_Type.TYPE_DOUBLE; + case 2: + case "TYPE_FLOAT": + return FieldDescriptorProto_Type.TYPE_FLOAT; + case 3: + case "TYPE_INT64": + return FieldDescriptorProto_Type.TYPE_INT64; + case 4: + case "TYPE_UINT64": + return FieldDescriptorProto_Type.TYPE_UINT64; + case 5: + case "TYPE_INT32": + return FieldDescriptorProto_Type.TYPE_INT32; + case 6: + case "TYPE_FIXED64": + return FieldDescriptorProto_Type.TYPE_FIXED64; + case 7: + case "TYPE_FIXED32": + return FieldDescriptorProto_Type.TYPE_FIXED32; + case 8: + case "TYPE_BOOL": + return FieldDescriptorProto_Type.TYPE_BOOL; + case 9: + case "TYPE_STRING": + return FieldDescriptorProto_Type.TYPE_STRING; + case 10: + case "TYPE_GROUP": + return FieldDescriptorProto_Type.TYPE_GROUP; + case 11: + case "TYPE_MESSAGE": + return FieldDescriptorProto_Type.TYPE_MESSAGE; + case 12: + case "TYPE_BYTES": + return FieldDescriptorProto_Type.TYPE_BYTES; + case 13: + case "TYPE_UINT32": + return FieldDescriptorProto_Type.TYPE_UINT32; + case 14: + case "TYPE_ENUM": + return FieldDescriptorProto_Type.TYPE_ENUM; + case 15: + case "TYPE_SFIXED32": + return FieldDescriptorProto_Type.TYPE_SFIXED32; + case 16: + case "TYPE_SFIXED64": + return FieldDescriptorProto_Type.TYPE_SFIXED64; + case 17: + case "TYPE_SINT32": + return FieldDescriptorProto_Type.TYPE_SINT32; + case 18: + case "TYPE_SINT64": + return FieldDescriptorProto_Type.TYPE_SINT64; + case -1: + case "UNRECOGNIZED": + default: + return FieldDescriptorProto_Type.UNRECOGNIZED; + } +} + +export function fieldDescriptorProto_TypeToJSON( + object: FieldDescriptorProto_Type +): string { + switch (object) { + case FieldDescriptorProto_Type.TYPE_DOUBLE: + return "TYPE_DOUBLE"; + case FieldDescriptorProto_Type.TYPE_FLOAT: + return "TYPE_FLOAT"; + case FieldDescriptorProto_Type.TYPE_INT64: + return "TYPE_INT64"; + case FieldDescriptorProto_Type.TYPE_UINT64: + return "TYPE_UINT64"; + case FieldDescriptorProto_Type.TYPE_INT32: + return "TYPE_INT32"; + case FieldDescriptorProto_Type.TYPE_FIXED64: + return "TYPE_FIXED64"; + case FieldDescriptorProto_Type.TYPE_FIXED32: + return "TYPE_FIXED32"; + case FieldDescriptorProto_Type.TYPE_BOOL: + return "TYPE_BOOL"; + case FieldDescriptorProto_Type.TYPE_STRING: + return "TYPE_STRING"; + case FieldDescriptorProto_Type.TYPE_GROUP: + return "TYPE_GROUP"; + case FieldDescriptorProto_Type.TYPE_MESSAGE: + return "TYPE_MESSAGE"; + case FieldDescriptorProto_Type.TYPE_BYTES: + return "TYPE_BYTES"; + case FieldDescriptorProto_Type.TYPE_UINT32: + return "TYPE_UINT32"; + case FieldDescriptorProto_Type.TYPE_ENUM: + return "TYPE_ENUM"; + case FieldDescriptorProto_Type.TYPE_SFIXED32: + return "TYPE_SFIXED32"; + case FieldDescriptorProto_Type.TYPE_SFIXED64: + return "TYPE_SFIXED64"; + case FieldDescriptorProto_Type.TYPE_SINT32: + return "TYPE_SINT32"; + case FieldDescriptorProto_Type.TYPE_SINT64: + return "TYPE_SINT64"; + default: + return "UNKNOWN"; + } +} + +export enum FieldDescriptorProto_Label { + /** LABEL_OPTIONAL - 0 is reserved for errors */ + LABEL_OPTIONAL = 1, + LABEL_REQUIRED = 2, + LABEL_REPEATED = 3, + UNRECOGNIZED = -1, +} + +export function fieldDescriptorProto_LabelFromJSON( + object: any +): FieldDescriptorProto_Label { + switch (object) { + case 1: + case "LABEL_OPTIONAL": + return FieldDescriptorProto_Label.LABEL_OPTIONAL; + case 2: + case "LABEL_REQUIRED": + return FieldDescriptorProto_Label.LABEL_REQUIRED; + case 3: + case "LABEL_REPEATED": + return FieldDescriptorProto_Label.LABEL_REPEATED; + case -1: + case "UNRECOGNIZED": + default: + return FieldDescriptorProto_Label.UNRECOGNIZED; + } +} + +export function fieldDescriptorProto_LabelToJSON( + object: FieldDescriptorProto_Label +): string { + switch (object) { + case FieldDescriptorProto_Label.LABEL_OPTIONAL: + return "LABEL_OPTIONAL"; + case FieldDescriptorProto_Label.LABEL_REQUIRED: + return "LABEL_REQUIRED"; + case FieldDescriptorProto_Label.LABEL_REPEATED: + return "LABEL_REPEATED"; + default: + return "UNKNOWN"; + } +} + +/** Describes a oneof. */ +export interface OneofDescriptorProto { + name: string; + options: OneofOptions | undefined; +} + +/** Describes an enum type. */ +export interface EnumDescriptorProto { + name: string; + value: EnumValueDescriptorProto[]; + options: EnumOptions | undefined; + /** + * Range of reserved numeric values. Reserved numeric values may not be used + * by enum values in the same enum declaration. Reserved ranges may not + * overlap. + */ + reserved_range: EnumDescriptorProto_EnumReservedRange[]; + /** + * Reserved enum value names, which may not be reused. A given name may only + * be reserved once. + */ + reserved_name: string[]; +} + +/** + * Range of reserved numeric values. Reserved values may not be used by + * entries in the same enum. Reserved ranges may not overlap. + * + * Note that this is distinct from DescriptorProto.ReservedRange in that it + * is inclusive such that it can appropriately represent the entire int32 + * domain. + */ +export interface EnumDescriptorProto_EnumReservedRange { + /** Inclusive. */ + start: number; + /** Inclusive. */ + end: number; +} + +/** Describes a value within an enum. */ +export interface EnumValueDescriptorProto { + name: string; + number: number; + options: EnumValueOptions | undefined; +} + +/** Describes a service. */ +export interface ServiceDescriptorProto { + name: string; + method: MethodDescriptorProto[]; + options: ServiceOptions | undefined; +} + +/** Describes a method of a service. */ +export interface MethodDescriptorProto { + name: string; + /** + * Input and output type names. These are resolved in the same way as + * FieldDescriptorProto.type_name, but must refer to a message type. + */ + input_type: string; + output_type: string; + options: MethodOptions | undefined; + /** Identifies if client streams multiple client messages */ + client_streaming: boolean; + /** Identifies if server streams multiple server messages */ + server_streaming: boolean; +} + +export interface FileOptions { + /** + * Sets the Java package where classes generated from this .proto will be + * placed. By default, the proto package is used, but this is often + * inappropriate because proto packages do not normally start with backwards + * domain names. + */ + java_package: string; + /** + * Controls the name of the wrapper Java class generated for the .proto file. + * That class will always contain the .proto file's getDescriptor() method as + * well as any top-level extensions defined in the .proto file. + * If java_multiple_files is disabled, then all the other classes from the + * .proto file will be nested inside the single wrapper outer class. + */ + java_outer_classname: string; + /** + * If enabled, then the Java code generator will generate a separate .java + * file for each top-level message, enum, and service defined in the .proto + * file. Thus, these types will *not* be nested inside the wrapper class + * named by java_outer_classname. However, the wrapper class will still be + * generated to contain the file's getDescriptor() method as well as any + * top-level extensions defined in the file. + */ + java_multiple_files: boolean; + /** + * This option does nothing. + * + * @deprecated + */ + java_generate_equals_and_hash: boolean; + /** + * If set true, then the Java2 code generator will generate code that + * throws an exception whenever an attempt is made to assign a non-UTF-8 + * byte sequence to a string field. + * Message reflection will do the same. + * However, an extension field still accepts non-UTF-8 byte sequences. + * This option has no effect on when used with the lite runtime. + */ + java_string_check_utf8: boolean; + optimize_for: FileOptions_OptimizeMode; + /** + * Sets the Go package where structs generated from this .proto will be + * placed. If omitted, the Go package will be derived from the following: + * - The basename of the package import path, if provided. + * - Otherwise, the package statement in the .proto file, if present. + * - Otherwise, the basename of the .proto file, without extension. + */ + go_package: string; + /** + * Should generic services be generated in each language? "Generic" services + * are not specific to any particular RPC system. They are generated by the + * main code generators in each language (without additional plugins). + * Generic services were the only kind of service generation supported by + * early versions of google.protobuf. + * + * Generic services are now considered deprecated in favor of using plugins + * that generate code specific to your particular RPC system. Therefore, + * these default to false. Old code which depends on generic services should + * explicitly set them to true. + */ + cc_generic_services: boolean; + java_generic_services: boolean; + py_generic_services: boolean; + php_generic_services: boolean; + /** + * Is this file deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for everything in the file, or it will be completely ignored; in the very + * least, this is a formalization for deprecating files. + */ + deprecated: boolean; + /** + * Enables the use of arenas for the proto messages in this file. This applies + * only to generated classes for C++. + */ + cc_enable_arenas: boolean; + /** + * Sets the objective c class prefix which is prepended to all objective c + * generated classes from this .proto. There is no default. + */ + objc_class_prefix: string; + /** Namespace for generated classes; defaults to the package. */ + csharp_namespace: string; + /** + * By default Swift generators will take the proto package and CamelCase it + * replacing '.' with underscore and use that to prefix the types/symbols + * defined. When this options is provided, they will use this value instead + * to prefix the types/symbols defined. + */ + swift_prefix: string; + /** + * Sets the php class prefix which is prepended to all php generated classes + * from this .proto. Default is empty. + */ + php_class_prefix: string; + /** + * Use this option to change the namespace of php generated classes. Default + * is empty. When this option is empty, the package name will be used for + * determining the namespace. + */ + php_namespace: string; + /** + * Use this option to change the namespace of php generated metadata classes. + * Default is empty. When this option is empty, the proto file name will be + * used for determining the namespace. + */ + php_metadata_namespace: string; + /** + * Use this option to change the package of ruby generated classes. Default + * is empty. When this option is not set, the package name will be used for + * determining the ruby package. + */ + ruby_package: string; + /** + * The parser stores options it doesn't recognize here. + * See the documentation for the "Options" section above. + */ + uninterpreted_option: UninterpretedOption[]; +} + +/** Generated classes can be optimized for speed or code size. */ +export enum FileOptions_OptimizeMode { + /** SPEED - Generate complete code for parsing, serialization, */ + SPEED = 1, + /** CODE_SIZE - etc. */ + CODE_SIZE = 2, + /** LITE_RUNTIME - Generate code using MessageLite and the lite runtime. */ + LITE_RUNTIME = 3, + UNRECOGNIZED = -1, +} + +export function fileOptions_OptimizeModeFromJSON( + object: any +): FileOptions_OptimizeMode { + switch (object) { + case 1: + case "SPEED": + return FileOptions_OptimizeMode.SPEED; + case 2: + case "CODE_SIZE": + return FileOptions_OptimizeMode.CODE_SIZE; + case 3: + case "LITE_RUNTIME": + return FileOptions_OptimizeMode.LITE_RUNTIME; + case -1: + case "UNRECOGNIZED": + default: + return FileOptions_OptimizeMode.UNRECOGNIZED; + } +} + +export function fileOptions_OptimizeModeToJSON( + object: FileOptions_OptimizeMode +): string { + switch (object) { + case FileOptions_OptimizeMode.SPEED: + return "SPEED"; + case FileOptions_OptimizeMode.CODE_SIZE: + return "CODE_SIZE"; + case FileOptions_OptimizeMode.LITE_RUNTIME: + return "LITE_RUNTIME"; + default: + return "UNKNOWN"; + } +} + +export interface MessageOptions { + /** + * Set true to use the old proto1 MessageSet wire format for extensions. + * This is provided for backwards-compatibility with the MessageSet wire + * format. You should not use this for any other reason: It's less + * efficient, has fewer features, and is more complicated. + * + * The message must be defined exactly as follows: + * message Foo { + * option message_set_wire_format = true; + * extensions 4 to max; + * } + * Note that the message cannot have any defined fields; MessageSets only + * have extensions. + * + * All extensions of your type must be singular messages; e.g. they cannot + * be int32s, enums, or repeated messages. + * + * Because this is an option, the above two restrictions are not enforced by + * the protocol compiler. + */ + message_set_wire_format: boolean; + /** + * Disables the generation of the standard "descriptor()" accessor, which can + * conflict with a field of the same name. This is meant to make migration + * from proto1 easier; new code should avoid fields named "descriptor". + */ + no_standard_descriptor_accessor: boolean; + /** + * Is this message deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the message, or it will be completely ignored; in the very least, + * this is a formalization for deprecating messages. + */ + deprecated: boolean; + /** + * Whether the message is an automatically generated map entry type for the + * maps field. + * + * For maps fields: + * map map_field = 1; + * The parsed descriptor looks like: + * message MapFieldEntry { + * option map_entry = true; + * optional KeyType key = 1; + * optional ValueType value = 2; + * } + * repeated MapFieldEntry map_field = 1; + * + * Implementations may choose not to generate the map_entry=true message, but + * use a native map in the target language to hold the keys and values. + * The reflection APIs in such implementations still need to work as + * if the field is a repeated message field. + * + * NOTE: Do not set the option in .proto files. Always use the maps syntax + * instead. The option should only be implicitly set by the proto compiler + * parser. + */ + map_entry: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpreted_option: UninterpretedOption[]; +} + +export interface FieldOptions { + /** + * The ctype option instructs the C++ code generator to use a different + * representation of the field than it normally would. See the specific + * options below. This option is not yet implemented in the open source + * release -- sorry, we'll try to include it in a future version! + */ + ctype: FieldOptions_CType; + /** + * The packed option can be enabled for repeated primitive fields to enable + * a more efficient representation on the wire. Rather than repeatedly + * writing the tag and type for each element, the entire array is encoded as + * a single length-delimited blob. In proto3, only explicit setting it to + * false will avoid using packed encoding. + */ + packed: boolean; + /** + * The jstype option determines the JavaScript type used for values of the + * field. The option is permitted only for 64 bit integral and fixed types + * (int64, uint64, sint64, fixed64, sfixed64). A field with jstype JS_STRING + * is represented as JavaScript string, which avoids loss of precision that + * can happen when a large value is converted to a floating point JavaScript. + * Specifying JS_NUMBER for the jstype causes the generated JavaScript code to + * use the JavaScript "number" type. The behavior of the default option + * JS_NORMAL is implementation dependent. + * + * This option is an enum to permit additional types to be added, e.g. + * goog.math.Integer. + */ + jstype: FieldOptions_JSType; + /** + * Should this field be parsed lazily? Lazy applies only to message-type + * fields. It means that when the outer message is initially parsed, the + * inner message's contents will not be parsed but instead stored in encoded + * form. The inner message will actually be parsed when it is first accessed. + * + * This is only a hint. Implementations are free to choose whether to use + * eager or lazy parsing regardless of the value of this option. However, + * setting this option true suggests that the protocol author believes that + * using lazy parsing on this field is worth the additional bookkeeping + * overhead typically needed to implement it. + * + * This option does not affect the public interface of any generated code; + * all method signatures remain the same. Furthermore, thread-safety of the + * interface is not affected by this option; const methods remain safe to + * call from multiple threads concurrently, while non-const methods continue + * to require exclusive access. + * + * + * Note that implementations may choose not to check required fields within + * a lazy sub-message. That is, calling IsInitialized() on the outer message + * may return true even if the inner message has missing required fields. + * This is necessary because otherwise the inner message would have to be + * parsed in order to perform the check, defeating the purpose of lazy + * parsing. An implementation which chooses not to check required fields + * must be consistent about it. That is, for any particular sub-message, the + * implementation must either *always* check its required fields, or *never* + * check its required fields, regardless of whether or not the message has + * been parsed. + */ + lazy: boolean; + /** + * Is this field deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for accessors, or it will be completely ignored; in the very least, this + * is a formalization for deprecating fields. + */ + deprecated: boolean; + /** For Google-internal migration only. Do not use. */ + weak: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpreted_option: UninterpretedOption[]; +} + +export enum FieldOptions_CType { + /** STRING - Default mode. */ + STRING = 0, + CORD = 1, + STRING_PIECE = 2, + UNRECOGNIZED = -1, +} + +export function fieldOptions_CTypeFromJSON(object: any): FieldOptions_CType { + switch (object) { + case 0: + case "STRING": + return FieldOptions_CType.STRING; + case 1: + case "CORD": + return FieldOptions_CType.CORD; + case 2: + case "STRING_PIECE": + return FieldOptions_CType.STRING_PIECE; + case -1: + case "UNRECOGNIZED": + default: + return FieldOptions_CType.UNRECOGNIZED; + } +} + +export function fieldOptions_CTypeToJSON(object: FieldOptions_CType): string { + switch (object) { + case FieldOptions_CType.STRING: + return "STRING"; + case FieldOptions_CType.CORD: + return "CORD"; + case FieldOptions_CType.STRING_PIECE: + return "STRING_PIECE"; + default: + return "UNKNOWN"; + } +} + +export enum FieldOptions_JSType { + /** JS_NORMAL - Use the default type. */ + JS_NORMAL = 0, + /** JS_STRING - Use JavaScript strings. */ + JS_STRING = 1, + /** JS_NUMBER - Use JavaScript numbers. */ + JS_NUMBER = 2, + UNRECOGNIZED = -1, +} + +export function fieldOptions_JSTypeFromJSON(object: any): FieldOptions_JSType { + switch (object) { + case 0: + case "JS_NORMAL": + return FieldOptions_JSType.JS_NORMAL; + case 1: + case "JS_STRING": + return FieldOptions_JSType.JS_STRING; + case 2: + case "JS_NUMBER": + return FieldOptions_JSType.JS_NUMBER; + case -1: + case "UNRECOGNIZED": + default: + return FieldOptions_JSType.UNRECOGNIZED; + } +} + +export function fieldOptions_JSTypeToJSON(object: FieldOptions_JSType): string { + switch (object) { + case FieldOptions_JSType.JS_NORMAL: + return "JS_NORMAL"; + case FieldOptions_JSType.JS_STRING: + return "JS_STRING"; + case FieldOptions_JSType.JS_NUMBER: + return "JS_NUMBER"; + default: + return "UNKNOWN"; + } +} + +export interface OneofOptions { + /** The parser stores options it doesn't recognize here. See above. */ + uninterpreted_option: UninterpretedOption[]; +} + +export interface EnumOptions { + /** + * Set this option to true to allow mapping different tag names to the same + * value. + */ + allow_alias: boolean; + /** + * Is this enum deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the enum, or it will be completely ignored; in the very least, this + * is a formalization for deprecating enums. + */ + deprecated: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpreted_option: UninterpretedOption[]; +} + +export interface EnumValueOptions { + /** + * Is this enum value deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the enum value, or it will be completely ignored; in the very least, + * this is a formalization for deprecating enum values. + */ + deprecated: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpreted_option: UninterpretedOption[]; +} + +export interface ServiceOptions { + /** + * Is this service deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the service, or it will be completely ignored; in the very least, + * this is a formalization for deprecating services. + */ + deprecated: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpreted_option: UninterpretedOption[]; +} + +export interface MethodOptions { + /** + * Is this method deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the method, or it will be completely ignored; in the very least, + * this is a formalization for deprecating methods. + */ + deprecated: boolean; + idempotency_level: MethodOptions_IdempotencyLevel; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpreted_option: UninterpretedOption[]; +} + +/** + * Is this method side-effect-free (or safe in HTTP parlance), or idempotent, + * or neither? HTTP based RPC implementation may choose GET verb for safe + * methods, and PUT verb for idempotent methods instead of the default POST. + */ +export enum MethodOptions_IdempotencyLevel { + IDEMPOTENCY_UNKNOWN = 0, + /** NO_SIDE_EFFECTS - implies idempotent */ + NO_SIDE_EFFECTS = 1, + /** IDEMPOTENT - idempotent, but may have side effects */ + IDEMPOTENT = 2, + UNRECOGNIZED = -1, +} + +export function methodOptions_IdempotencyLevelFromJSON( + object: any +): MethodOptions_IdempotencyLevel { + switch (object) { + case 0: + case "IDEMPOTENCY_UNKNOWN": + return MethodOptions_IdempotencyLevel.IDEMPOTENCY_UNKNOWN; + case 1: + case "NO_SIDE_EFFECTS": + return MethodOptions_IdempotencyLevel.NO_SIDE_EFFECTS; + case 2: + case "IDEMPOTENT": + return MethodOptions_IdempotencyLevel.IDEMPOTENT; + case -1: + case "UNRECOGNIZED": + default: + return MethodOptions_IdempotencyLevel.UNRECOGNIZED; + } +} + +export function methodOptions_IdempotencyLevelToJSON( + object: MethodOptions_IdempotencyLevel +): string { + switch (object) { + case MethodOptions_IdempotencyLevel.IDEMPOTENCY_UNKNOWN: + return "IDEMPOTENCY_UNKNOWN"; + case MethodOptions_IdempotencyLevel.NO_SIDE_EFFECTS: + return "NO_SIDE_EFFECTS"; + case MethodOptions_IdempotencyLevel.IDEMPOTENT: + return "IDEMPOTENT"; + default: + return "UNKNOWN"; + } +} + +/** + * A message representing a option the parser does not recognize. This only + * appears in options protos created by the compiler::Parser class. + * DescriptorPool resolves these when building Descriptor objects. Therefore, + * options protos in descriptor objects (e.g. returned by Descriptor::options(), + * or produced by Descriptor::CopyTo()) will never have UninterpretedOptions + * in them. + */ +export interface UninterpretedOption { + name: UninterpretedOption_NamePart[]; + /** + * The value of the uninterpreted option, in whatever type the tokenizer + * identified it as during parsing. Exactly one of these should be set. + */ + identifier_value: string; + positive_int_value: number; + negative_int_value: number; + double_value: number; + string_value: Uint8Array; + aggregate_value: string; +} + +/** + * The name of the uninterpreted option. Each string represents a segment in + * a dot-separated name. is_extension is true iff a segment represents an + * extension (denoted with parentheses in options specs in .proto files). + * E.g.,{ ["foo", false], ["bar.baz", true], ["qux", false] } represents + * "foo.(bar.baz).qux". + */ +export interface UninterpretedOption_NamePart { + name_part: string; + is_extension: boolean; +} + +/** + * Encapsulates information about the original source file from which a + * FileDescriptorProto was generated. + */ +export interface SourceCodeInfo { + /** + * A Location identifies a piece of source code in a .proto file which + * corresponds to a particular definition. This information is intended + * to be useful to IDEs, code indexers, documentation generators, and similar + * tools. + * + * For example, say we have a file like: + * message Foo { + * optional string foo = 1; + * } + * Let's look at just the field definition: + * optional string foo = 1; + * ^ ^^ ^^ ^ ^^^ + * a bc de f ghi + * We have the following locations: + * span path represents + * [a,i) [ 4, 0, 2, 0 ] The whole field definition. + * [a,b) [ 4, 0, 2, 0, 4 ] The label (optional). + * [c,d) [ 4, 0, 2, 0, 5 ] The type (string). + * [e,f) [ 4, 0, 2, 0, 1 ] The name (foo). + * [g,h) [ 4, 0, 2, 0, 3 ] The number (1). + * + * Notes: + * - A location may refer to a repeated field itself (i.e. not to any + * particular index within it). This is used whenever a set of elements are + * logically enclosed in a single code segment. For example, an entire + * extend block (possibly containing multiple extension definitions) will + * have an outer location whose path refers to the "extensions" repeated + * field without an index. + * - Multiple locations may have the same path. This happens when a single + * logical declaration is spread out across multiple places. The most + * obvious example is the "extend" block again -- there may be multiple + * extend blocks in the same scope, each of which will have the same path. + * - A location's span is not always a subset of its parent's span. For + * example, the "extendee" of an extension declaration appears at the + * beginning of the "extend" block and is shared by all extensions within + * the block. + * - Just because a location's span is a subset of some other location's span + * does not mean that it is a descendant. For example, a "group" defines + * both a type and a field in a single declaration. Thus, the locations + * corresponding to the type and field and their components will overlap. + * - Code which tries to interpret locations should probably be designed to + * ignore those that it doesn't understand, as more types of locations could + * be recorded in the future. + */ + location: SourceCodeInfo_Location[]; +} + +export interface SourceCodeInfo_Location { + /** + * Identifies which part of the FileDescriptorProto was defined at this + * location. + * + * Each element is a field number or an index. They form a path from + * the root FileDescriptorProto to the place where the definition. For + * example, this path: + * [ 4, 3, 2, 7, 1 ] + * refers to: + * file.message_type(3) // 4, 3 + * .field(7) // 2, 7 + * .name() // 1 + * This is because FileDescriptorProto.message_type has field number 4: + * repeated DescriptorProto message_type = 4; + * and DescriptorProto.field has field number 2: + * repeated FieldDescriptorProto field = 2; + * and FieldDescriptorProto.name has field number 1: + * optional string name = 1; + * + * Thus, the above path gives the location of a field name. If we removed + * the last element: + * [ 4, 3, 2, 7 ] + * this path refers to the whole field declaration (from the beginning + * of the label to the terminating semicolon). + */ + path: number[]; + /** + * Always has exactly three or four elements: start line, start column, + * end line (optional, otherwise assumed same as start line), end column. + * These are packed into a single field for efficiency. Note that line + * and column numbers are zero-based -- typically you will want to add + * 1 to each before displaying to a user. + */ + span: number[]; + /** + * If this SourceCodeInfo represents a complete declaration, these are any + * comments appearing before and after the declaration which appear to be + * attached to the declaration. + * + * A series of line comments appearing on consecutive lines, with no other + * tokens appearing on those lines, will be treated as a single comment. + * + * leading_detached_comments will keep paragraphs of comments that appear + * before (but not connected to) the current element. Each paragraph, + * separated by empty lines, will be one comment element in the repeated + * field. + * + * Only the comment content is provided; comment markers (e.g. //) are + * stripped out. For block comments, leading whitespace and an asterisk + * will be stripped from the beginning of each line other than the first. + * Newlines are included in the output. + * + * Examples: + * + * optional int32 foo = 1; // Comment attached to foo. + * // Comment attached to bar. + * optional int32 bar = 2; + * + * optional string baz = 3; + * // Comment attached to baz. + * // Another line attached to baz. + * + * // Comment attached to qux. + * // + * // Another line attached to qux. + * optional double qux = 4; + * + * // Detached comment for corge. This is not leading or trailing comments + * // to qux or corge because there are blank lines separating it from + * // both. + * + * // Detached comment for corge paragraph 2. + * + * optional string corge = 5; + * /* Block comment attached + * * to corge. Leading asterisks + * * will be removed. * / + * /* Block comment attached to + * * grault. * / + * optional int32 grault = 6; + * + * // ignored detached comments. + */ + leading_comments: string; + trailing_comments: string; + leading_detached_comments: string[]; +} + +/** + * Describes the relationship between generated code and its original source + * file. A GeneratedCodeInfo message is associated with only one generated + * source file, but may contain references to different source .proto files. + */ +export interface GeneratedCodeInfo { + /** + * An Annotation connects some span of text in generated code to an element + * of its generating .proto file. + */ + annotation: GeneratedCodeInfo_Annotation[]; +} + +export interface GeneratedCodeInfo_Annotation { + /** + * Identifies the element in the original source .proto file. This field + * is formatted the same as SourceCodeInfo.Location.path. + */ + path: number[]; + /** Identifies the filesystem path to the original source .proto. */ + source_file: string; + /** + * Identifies the starting offset in bytes in the generated code + * that relates to the identified object. + */ + begin: number; + /** + * Identifies the ending offset in bytes in the generated code that + * relates to the identified offset. The end offset should be one past + * the last relevant byte (so the length of the text = end - begin). + */ + end: number; +} + +const baseFileDescriptorSet: object = {}; + +export const FileDescriptorSet = { + encode(message: FileDescriptorSet, writer: Writer = Writer.create()): Writer { + for (const v of message.file) { + FileDescriptorProto.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FileDescriptorSet { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFileDescriptorSet } as FileDescriptorSet; + message.file = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.file.push( + FileDescriptorProto.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FileDescriptorSet { + const message = { ...baseFileDescriptorSet } as FileDescriptorSet; + message.file = []; + if (object.file !== undefined && object.file !== null) { + for (const e of object.file) { + message.file.push(FileDescriptorProto.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: FileDescriptorSet): unknown { + const obj: any = {}; + if (message.file) { + obj.file = message.file.map((e) => + e ? FileDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.file = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): FileDescriptorSet { + const message = { ...baseFileDescriptorSet } as FileDescriptorSet; + message.file = []; + if (object.file !== undefined && object.file !== null) { + for (const e of object.file) { + message.file.push(FileDescriptorProto.fromPartial(e)); + } + } + return message; + }, +}; + +const baseFileDescriptorProto: object = { + name: "", + package: "", + dependency: "", + public_dependency: 0, + weak_dependency: 0, + syntax: "", +}; + +export const FileDescriptorProto = { + encode( + message: FileDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.package !== "") { + writer.uint32(18).string(message.package); + } + for (const v of message.dependency) { + writer.uint32(26).string(v!); + } + writer.uint32(82).fork(); + for (const v of message.public_dependency) { + writer.int32(v); + } + writer.ldelim(); + writer.uint32(90).fork(); + for (const v of message.weak_dependency) { + writer.int32(v); + } + writer.ldelim(); + for (const v of message.message_type) { + DescriptorProto.encode(v!, writer.uint32(34).fork()).ldelim(); + } + for (const v of message.enum_type) { + EnumDescriptorProto.encode(v!, writer.uint32(42).fork()).ldelim(); + } + for (const v of message.service) { + ServiceDescriptorProto.encode(v!, writer.uint32(50).fork()).ldelim(); + } + for (const v of message.extension) { + FieldDescriptorProto.encode(v!, writer.uint32(58).fork()).ldelim(); + } + if (message.options !== undefined) { + FileOptions.encode(message.options, writer.uint32(66).fork()).ldelim(); + } + if (message.source_code_info !== undefined) { + SourceCodeInfo.encode( + message.source_code_info, + writer.uint32(74).fork() + ).ldelim(); + } + if (message.syntax !== "") { + writer.uint32(98).string(message.syntax); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FileDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFileDescriptorProto } as FileDescriptorProto; + message.dependency = []; + message.public_dependency = []; + message.weak_dependency = []; + message.message_type = []; + message.enum_type = []; + message.service = []; + message.extension = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.package = reader.string(); + break; + case 3: + message.dependency.push(reader.string()); + break; + case 10: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.public_dependency.push(reader.int32()); + } + } else { + message.public_dependency.push(reader.int32()); + } + break; + case 11: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.weak_dependency.push(reader.int32()); + } + } else { + message.weak_dependency.push(reader.int32()); + } + break; + case 4: + message.message_type.push( + DescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 5: + message.enum_type.push( + EnumDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 6: + message.service.push( + ServiceDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 7: + message.extension.push( + FieldDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 8: + message.options = FileOptions.decode(reader, reader.uint32()); + break; + case 9: + message.source_code_info = SourceCodeInfo.decode( + reader, + reader.uint32() + ); + break; + case 12: + message.syntax = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FileDescriptorProto { + const message = { ...baseFileDescriptorProto } as FileDescriptorProto; + message.dependency = []; + message.public_dependency = []; + message.weak_dependency = []; + message.message_type = []; + message.enum_type = []; + message.service = []; + message.extension = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.package !== undefined && object.package !== null) { + message.package = String(object.package); + } else { + message.package = ""; + } + if (object.dependency !== undefined && object.dependency !== null) { + for (const e of object.dependency) { + message.dependency.push(String(e)); + } + } + if ( + object.public_dependency !== undefined && + object.public_dependency !== null + ) { + for (const e of object.public_dependency) { + message.public_dependency.push(Number(e)); + } + } + if ( + object.weak_dependency !== undefined && + object.weak_dependency !== null + ) { + for (const e of object.weak_dependency) { + message.weak_dependency.push(Number(e)); + } + } + if (object.message_type !== undefined && object.message_type !== null) { + for (const e of object.message_type) { + message.message_type.push(DescriptorProto.fromJSON(e)); + } + } + if (object.enum_type !== undefined && object.enum_type !== null) { + for (const e of object.enum_type) { + message.enum_type.push(EnumDescriptorProto.fromJSON(e)); + } + } + if (object.service !== undefined && object.service !== null) { + for (const e of object.service) { + message.service.push(ServiceDescriptorProto.fromJSON(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = FileOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if ( + object.source_code_info !== undefined && + object.source_code_info !== null + ) { + message.source_code_info = SourceCodeInfo.fromJSON( + object.source_code_info + ); + } else { + message.source_code_info = undefined; + } + if (object.syntax !== undefined && object.syntax !== null) { + message.syntax = String(object.syntax); + } else { + message.syntax = ""; + } + return message; + }, + + toJSON(message: FileDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.package !== undefined && (obj.package = message.package); + if (message.dependency) { + obj.dependency = message.dependency.map((e) => e); + } else { + obj.dependency = []; + } + if (message.public_dependency) { + obj.public_dependency = message.public_dependency.map((e) => e); + } else { + obj.public_dependency = []; + } + if (message.weak_dependency) { + obj.weak_dependency = message.weak_dependency.map((e) => e); + } else { + obj.weak_dependency = []; + } + if (message.message_type) { + obj.message_type = message.message_type.map((e) => + e ? DescriptorProto.toJSON(e) : undefined + ); + } else { + obj.message_type = []; + } + if (message.enum_type) { + obj.enum_type = message.enum_type.map((e) => + e ? EnumDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.enum_type = []; + } + if (message.service) { + obj.service = message.service.map((e) => + e ? ServiceDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.service = []; + } + if (message.extension) { + obj.extension = message.extension.map((e) => + e ? FieldDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.extension = []; + } + message.options !== undefined && + (obj.options = message.options + ? FileOptions.toJSON(message.options) + : undefined); + message.source_code_info !== undefined && + (obj.source_code_info = message.source_code_info + ? SourceCodeInfo.toJSON(message.source_code_info) + : undefined); + message.syntax !== undefined && (obj.syntax = message.syntax); + return obj; + }, + + fromPartial(object: DeepPartial): FileDescriptorProto { + const message = { ...baseFileDescriptorProto } as FileDescriptorProto; + message.dependency = []; + message.public_dependency = []; + message.weak_dependency = []; + message.message_type = []; + message.enum_type = []; + message.service = []; + message.extension = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.package !== undefined && object.package !== null) { + message.package = object.package; + } else { + message.package = ""; + } + if (object.dependency !== undefined && object.dependency !== null) { + for (const e of object.dependency) { + message.dependency.push(e); + } + } + if ( + object.public_dependency !== undefined && + object.public_dependency !== null + ) { + for (const e of object.public_dependency) { + message.public_dependency.push(e); + } + } + if ( + object.weak_dependency !== undefined && + object.weak_dependency !== null + ) { + for (const e of object.weak_dependency) { + message.weak_dependency.push(e); + } + } + if (object.message_type !== undefined && object.message_type !== null) { + for (const e of object.message_type) { + message.message_type.push(DescriptorProto.fromPartial(e)); + } + } + if (object.enum_type !== undefined && object.enum_type !== null) { + for (const e of object.enum_type) { + message.enum_type.push(EnumDescriptorProto.fromPartial(e)); + } + } + if (object.service !== undefined && object.service !== null) { + for (const e of object.service) { + message.service.push(ServiceDescriptorProto.fromPartial(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = FileOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if ( + object.source_code_info !== undefined && + object.source_code_info !== null + ) { + message.source_code_info = SourceCodeInfo.fromPartial( + object.source_code_info + ); + } else { + message.source_code_info = undefined; + } + if (object.syntax !== undefined && object.syntax !== null) { + message.syntax = object.syntax; + } else { + message.syntax = ""; + } + return message; + }, +}; + +const baseDescriptorProto: object = { name: "", reserved_name: "" }; + +export const DescriptorProto = { + encode(message: DescriptorProto, writer: Writer = Writer.create()): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + for (const v of message.field) { + FieldDescriptorProto.encode(v!, writer.uint32(18).fork()).ldelim(); + } + for (const v of message.extension) { + FieldDescriptorProto.encode(v!, writer.uint32(50).fork()).ldelim(); + } + for (const v of message.nested_type) { + DescriptorProto.encode(v!, writer.uint32(26).fork()).ldelim(); + } + for (const v of message.enum_type) { + EnumDescriptorProto.encode(v!, writer.uint32(34).fork()).ldelim(); + } + for (const v of message.extension_range) { + DescriptorProto_ExtensionRange.encode( + v!, + writer.uint32(42).fork() + ).ldelim(); + } + for (const v of message.oneof_decl) { + OneofDescriptorProto.encode(v!, writer.uint32(66).fork()).ldelim(); + } + if (message.options !== undefined) { + MessageOptions.encode(message.options, writer.uint32(58).fork()).ldelim(); + } + for (const v of message.reserved_range) { + DescriptorProto_ReservedRange.encode( + v!, + writer.uint32(74).fork() + ).ldelim(); + } + for (const v of message.reserved_name) { + writer.uint32(82).string(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): DescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseDescriptorProto } as DescriptorProto; + message.field = []; + message.extension = []; + message.nested_type = []; + message.enum_type = []; + message.extension_range = []; + message.oneof_decl = []; + message.reserved_range = []; + message.reserved_name = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.field.push( + FieldDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 6: + message.extension.push( + FieldDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 3: + message.nested_type.push( + DescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 4: + message.enum_type.push( + EnumDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 5: + message.extension_range.push( + DescriptorProto_ExtensionRange.decode(reader, reader.uint32()) + ); + break; + case 8: + message.oneof_decl.push( + OneofDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 7: + message.options = MessageOptions.decode(reader, reader.uint32()); + break; + case 9: + message.reserved_range.push( + DescriptorProto_ReservedRange.decode(reader, reader.uint32()) + ); + break; + case 10: + message.reserved_name.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DescriptorProto { + const message = { ...baseDescriptorProto } as DescriptorProto; + message.field = []; + message.extension = []; + message.nested_type = []; + message.enum_type = []; + message.extension_range = []; + message.oneof_decl = []; + message.reserved_range = []; + message.reserved_name = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.field !== undefined && object.field !== null) { + for (const e of object.field) { + message.field.push(FieldDescriptorProto.fromJSON(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromJSON(e)); + } + } + if (object.nested_type !== undefined && object.nested_type !== null) { + for (const e of object.nested_type) { + message.nested_type.push(DescriptorProto.fromJSON(e)); + } + } + if (object.enum_type !== undefined && object.enum_type !== null) { + for (const e of object.enum_type) { + message.enum_type.push(EnumDescriptorProto.fromJSON(e)); + } + } + if ( + object.extension_range !== undefined && + object.extension_range !== null + ) { + for (const e of object.extension_range) { + message.extension_range.push( + DescriptorProto_ExtensionRange.fromJSON(e) + ); + } + } + if (object.oneof_decl !== undefined && object.oneof_decl !== null) { + for (const e of object.oneof_decl) { + message.oneof_decl.push(OneofDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = MessageOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.reserved_range !== undefined && object.reserved_range !== null) { + for (const e of object.reserved_range) { + message.reserved_range.push(DescriptorProto_ReservedRange.fromJSON(e)); + } + } + if (object.reserved_name !== undefined && object.reserved_name !== null) { + for (const e of object.reserved_name) { + message.reserved_name.push(String(e)); + } + } + return message; + }, + + toJSON(message: DescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + if (message.field) { + obj.field = message.field.map((e) => + e ? FieldDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.field = []; + } + if (message.extension) { + obj.extension = message.extension.map((e) => + e ? FieldDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.extension = []; + } + if (message.nested_type) { + obj.nested_type = message.nested_type.map((e) => + e ? DescriptorProto.toJSON(e) : undefined + ); + } else { + obj.nested_type = []; + } + if (message.enum_type) { + obj.enum_type = message.enum_type.map((e) => + e ? EnumDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.enum_type = []; + } + if (message.extension_range) { + obj.extension_range = message.extension_range.map((e) => + e ? DescriptorProto_ExtensionRange.toJSON(e) : undefined + ); + } else { + obj.extension_range = []; + } + if (message.oneof_decl) { + obj.oneof_decl = message.oneof_decl.map((e) => + e ? OneofDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.oneof_decl = []; + } + message.options !== undefined && + (obj.options = message.options + ? MessageOptions.toJSON(message.options) + : undefined); + if (message.reserved_range) { + obj.reserved_range = message.reserved_range.map((e) => + e ? DescriptorProto_ReservedRange.toJSON(e) : undefined + ); + } else { + obj.reserved_range = []; + } + if (message.reserved_name) { + obj.reserved_name = message.reserved_name.map((e) => e); + } else { + obj.reserved_name = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): DescriptorProto { + const message = { ...baseDescriptorProto } as DescriptorProto; + message.field = []; + message.extension = []; + message.nested_type = []; + message.enum_type = []; + message.extension_range = []; + message.oneof_decl = []; + message.reserved_range = []; + message.reserved_name = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.field !== undefined && object.field !== null) { + for (const e of object.field) { + message.field.push(FieldDescriptorProto.fromPartial(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromPartial(e)); + } + } + if (object.nested_type !== undefined && object.nested_type !== null) { + for (const e of object.nested_type) { + message.nested_type.push(DescriptorProto.fromPartial(e)); + } + } + if (object.enum_type !== undefined && object.enum_type !== null) { + for (const e of object.enum_type) { + message.enum_type.push(EnumDescriptorProto.fromPartial(e)); + } + } + if ( + object.extension_range !== undefined && + object.extension_range !== null + ) { + for (const e of object.extension_range) { + message.extension_range.push( + DescriptorProto_ExtensionRange.fromPartial(e) + ); + } + } + if (object.oneof_decl !== undefined && object.oneof_decl !== null) { + for (const e of object.oneof_decl) { + message.oneof_decl.push(OneofDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = MessageOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.reserved_range !== undefined && object.reserved_range !== null) { + for (const e of object.reserved_range) { + message.reserved_range.push( + DescriptorProto_ReservedRange.fromPartial(e) + ); + } + } + if (object.reserved_name !== undefined && object.reserved_name !== null) { + for (const e of object.reserved_name) { + message.reserved_name.push(e); + } + } + return message; + }, +}; + +const baseDescriptorProto_ExtensionRange: object = { start: 0, end: 0 }; + +export const DescriptorProto_ExtensionRange = { + encode( + message: DescriptorProto_ExtensionRange, + writer: Writer = Writer.create() + ): Writer { + if (message.start !== 0) { + writer.uint32(8).int32(message.start); + } + if (message.end !== 0) { + writer.uint32(16).int32(message.end); + } + if (message.options !== undefined) { + ExtensionRangeOptions.encode( + message.options, + writer.uint32(26).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): DescriptorProto_ExtensionRange { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseDescriptorProto_ExtensionRange, + } as DescriptorProto_ExtensionRange; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.start = reader.int32(); + break; + case 2: + message.end = reader.int32(); + break; + case 3: + message.options = ExtensionRangeOptions.decode( + reader, + reader.uint32() + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DescriptorProto_ExtensionRange { + const message = { + ...baseDescriptorProto_ExtensionRange, + } as DescriptorProto_ExtensionRange; + if (object.start !== undefined && object.start !== null) { + message.start = Number(object.start); + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = ExtensionRangeOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: DescriptorProto_ExtensionRange): unknown { + const obj: any = {}; + message.start !== undefined && (obj.start = message.start); + message.end !== undefined && (obj.end = message.end); + message.options !== undefined && + (obj.options = message.options + ? ExtensionRangeOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): DescriptorProto_ExtensionRange { + const message = { + ...baseDescriptorProto_ExtensionRange, + } as DescriptorProto_ExtensionRange; + if (object.start !== undefined && object.start !== null) { + message.start = object.start; + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = ExtensionRangeOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseDescriptorProto_ReservedRange: object = { start: 0, end: 0 }; + +export const DescriptorProto_ReservedRange = { + encode( + message: DescriptorProto_ReservedRange, + writer: Writer = Writer.create() + ): Writer { + if (message.start !== 0) { + writer.uint32(8).int32(message.start); + } + if (message.end !== 0) { + writer.uint32(16).int32(message.end); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): DescriptorProto_ReservedRange { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseDescriptorProto_ReservedRange, + } as DescriptorProto_ReservedRange; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.start = reader.int32(); + break; + case 2: + message.end = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DescriptorProto_ReservedRange { + const message = { + ...baseDescriptorProto_ReservedRange, + } as DescriptorProto_ReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = Number(object.start); + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + return message; + }, + + toJSON(message: DescriptorProto_ReservedRange): unknown { + const obj: any = {}; + message.start !== undefined && (obj.start = message.start); + message.end !== undefined && (obj.end = message.end); + return obj; + }, + + fromPartial( + object: DeepPartial + ): DescriptorProto_ReservedRange { + const message = { + ...baseDescriptorProto_ReservedRange, + } as DescriptorProto_ReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = object.start; + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + return message; + }, +}; + +const baseExtensionRangeOptions: object = {}; + +export const ExtensionRangeOptions = { + encode( + message: ExtensionRangeOptions, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.uninterpreted_option) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ExtensionRangeOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseExtensionRangeOptions } as ExtensionRangeOptions; + message.uninterpreted_option = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 999: + message.uninterpreted_option.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ExtensionRangeOptions { + const message = { ...baseExtensionRangeOptions } as ExtensionRangeOptions; + message.uninterpreted_option = []; + if ( + object.uninterpreted_option !== undefined && + object.uninterpreted_option !== null + ) { + for (const e of object.uninterpreted_option) { + message.uninterpreted_option.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: ExtensionRangeOptions): unknown { + const obj: any = {}; + if (message.uninterpreted_option) { + obj.uninterpreted_option = message.uninterpreted_option.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpreted_option = []; + } + return obj; + }, + + fromPartial( + object: DeepPartial + ): ExtensionRangeOptions { + const message = { ...baseExtensionRangeOptions } as ExtensionRangeOptions; + message.uninterpreted_option = []; + if ( + object.uninterpreted_option !== undefined && + object.uninterpreted_option !== null + ) { + for (const e of object.uninterpreted_option) { + message.uninterpreted_option.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseFieldDescriptorProto: object = { + name: "", + number: 0, + label: 1, + type: 1, + type_name: "", + extendee: "", + default_value: "", + oneof_index: 0, + json_name: "", + proto3_optional: false, +}; + +export const FieldDescriptorProto = { + encode( + message: FieldDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.number !== 0) { + writer.uint32(24).int32(message.number); + } + if (message.label !== 1) { + writer.uint32(32).int32(message.label); + } + if (message.type !== 1) { + writer.uint32(40).int32(message.type); + } + if (message.type_name !== "") { + writer.uint32(50).string(message.type_name); + } + if (message.extendee !== "") { + writer.uint32(18).string(message.extendee); + } + if (message.default_value !== "") { + writer.uint32(58).string(message.default_value); + } + if (message.oneof_index !== 0) { + writer.uint32(72).int32(message.oneof_index); + } + if (message.json_name !== "") { + writer.uint32(82).string(message.json_name); + } + if (message.options !== undefined) { + FieldOptions.encode(message.options, writer.uint32(66).fork()).ldelim(); + } + if (message.proto3_optional === true) { + writer.uint32(136).bool(message.proto3_optional); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FieldDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFieldDescriptorProto } as FieldDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 3: + message.number = reader.int32(); + break; + case 4: + message.label = reader.int32() as any; + break; + case 5: + message.type = reader.int32() as any; + break; + case 6: + message.type_name = reader.string(); + break; + case 2: + message.extendee = reader.string(); + break; + case 7: + message.default_value = reader.string(); + break; + case 9: + message.oneof_index = reader.int32(); + break; + case 10: + message.json_name = reader.string(); + break; + case 8: + message.options = FieldOptions.decode(reader, reader.uint32()); + break; + case 17: + message.proto3_optional = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FieldDescriptorProto { + const message = { ...baseFieldDescriptorProto } as FieldDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = Number(object.number); + } else { + message.number = 0; + } + if (object.label !== undefined && object.label !== null) { + message.label = fieldDescriptorProto_LabelFromJSON(object.label); + } else { + message.label = 1; + } + if (object.type !== undefined && object.type !== null) { + message.type = fieldDescriptorProto_TypeFromJSON(object.type); + } else { + message.type = 1; + } + if (object.type_name !== undefined && object.type_name !== null) { + message.type_name = String(object.type_name); + } else { + message.type_name = ""; + } + if (object.extendee !== undefined && object.extendee !== null) { + message.extendee = String(object.extendee); + } else { + message.extendee = ""; + } + if (object.default_value !== undefined && object.default_value !== null) { + message.default_value = String(object.default_value); + } else { + message.default_value = ""; + } + if (object.oneof_index !== undefined && object.oneof_index !== null) { + message.oneof_index = Number(object.oneof_index); + } else { + message.oneof_index = 0; + } + if (object.json_name !== undefined && object.json_name !== null) { + message.json_name = String(object.json_name); + } else { + message.json_name = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = FieldOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if ( + object.proto3_optional !== undefined && + object.proto3_optional !== null + ) { + message.proto3_optional = Boolean(object.proto3_optional); + } else { + message.proto3_optional = false; + } + return message; + }, + + toJSON(message: FieldDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.number !== undefined && (obj.number = message.number); + message.label !== undefined && + (obj.label = fieldDescriptorProto_LabelToJSON(message.label)); + message.type !== undefined && + (obj.type = fieldDescriptorProto_TypeToJSON(message.type)); + message.type_name !== undefined && (obj.type_name = message.type_name); + message.extendee !== undefined && (obj.extendee = message.extendee); + message.default_value !== undefined && + (obj.default_value = message.default_value); + message.oneof_index !== undefined && + (obj.oneof_index = message.oneof_index); + message.json_name !== undefined && (obj.json_name = message.json_name); + message.options !== undefined && + (obj.options = message.options + ? FieldOptions.toJSON(message.options) + : undefined); + message.proto3_optional !== undefined && + (obj.proto3_optional = message.proto3_optional); + return obj; + }, + + fromPartial(object: DeepPartial): FieldDescriptorProto { + const message = { ...baseFieldDescriptorProto } as FieldDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = object.number; + } else { + message.number = 0; + } + if (object.label !== undefined && object.label !== null) { + message.label = object.label; + } else { + message.label = 1; + } + if (object.type !== undefined && object.type !== null) { + message.type = object.type; + } else { + message.type = 1; + } + if (object.type_name !== undefined && object.type_name !== null) { + message.type_name = object.type_name; + } else { + message.type_name = ""; + } + if (object.extendee !== undefined && object.extendee !== null) { + message.extendee = object.extendee; + } else { + message.extendee = ""; + } + if (object.default_value !== undefined && object.default_value !== null) { + message.default_value = object.default_value; + } else { + message.default_value = ""; + } + if (object.oneof_index !== undefined && object.oneof_index !== null) { + message.oneof_index = object.oneof_index; + } else { + message.oneof_index = 0; + } + if (object.json_name !== undefined && object.json_name !== null) { + message.json_name = object.json_name; + } else { + message.json_name = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = FieldOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if ( + object.proto3_optional !== undefined && + object.proto3_optional !== null + ) { + message.proto3_optional = object.proto3_optional; + } else { + message.proto3_optional = false; + } + return message; + }, +}; + +const baseOneofDescriptorProto: object = { name: "" }; + +export const OneofDescriptorProto = { + encode( + message: OneofDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.options !== undefined) { + OneofOptions.encode(message.options, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): OneofDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseOneofDescriptorProto } as OneofDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.options = OneofOptions.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): OneofDescriptorProto { + const message = { ...baseOneofDescriptorProto } as OneofDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = OneofOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: OneofDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.options !== undefined && + (obj.options = message.options + ? OneofOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): OneofDescriptorProto { + const message = { ...baseOneofDescriptorProto } as OneofDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = OneofOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseEnumDescriptorProto: object = { name: "", reserved_name: "" }; + +export const EnumDescriptorProto = { + encode( + message: EnumDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + for (const v of message.value) { + EnumValueDescriptorProto.encode(v!, writer.uint32(18).fork()).ldelim(); + } + if (message.options !== undefined) { + EnumOptions.encode(message.options, writer.uint32(26).fork()).ldelim(); + } + for (const v of message.reserved_range) { + EnumDescriptorProto_EnumReservedRange.encode( + v!, + writer.uint32(34).fork() + ).ldelim(); + } + for (const v of message.reserved_name) { + writer.uint32(42).string(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): EnumDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseEnumDescriptorProto } as EnumDescriptorProto; + message.value = []; + message.reserved_range = []; + message.reserved_name = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.value.push( + EnumValueDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 3: + message.options = EnumOptions.decode(reader, reader.uint32()); + break; + case 4: + message.reserved_range.push( + EnumDescriptorProto_EnumReservedRange.decode( + reader, + reader.uint32() + ) + ); + break; + case 5: + message.reserved_name.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumDescriptorProto { + const message = { ...baseEnumDescriptorProto } as EnumDescriptorProto; + message.value = []; + message.reserved_range = []; + message.reserved_name = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.value !== undefined && object.value !== null) { + for (const e of object.value) { + message.value.push(EnumValueDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.reserved_range !== undefined && object.reserved_range !== null) { + for (const e of object.reserved_range) { + message.reserved_range.push( + EnumDescriptorProto_EnumReservedRange.fromJSON(e) + ); + } + } + if (object.reserved_name !== undefined && object.reserved_name !== null) { + for (const e of object.reserved_name) { + message.reserved_name.push(String(e)); + } + } + return message; + }, + + toJSON(message: EnumDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + if (message.value) { + obj.value = message.value.map((e) => + e ? EnumValueDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.value = []; + } + message.options !== undefined && + (obj.options = message.options + ? EnumOptions.toJSON(message.options) + : undefined); + if (message.reserved_range) { + obj.reserved_range = message.reserved_range.map((e) => + e ? EnumDescriptorProto_EnumReservedRange.toJSON(e) : undefined + ); + } else { + obj.reserved_range = []; + } + if (message.reserved_name) { + obj.reserved_name = message.reserved_name.map((e) => e); + } else { + obj.reserved_name = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): EnumDescriptorProto { + const message = { ...baseEnumDescriptorProto } as EnumDescriptorProto; + message.value = []; + message.reserved_range = []; + message.reserved_name = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.value !== undefined && object.value !== null) { + for (const e of object.value) { + message.value.push(EnumValueDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.reserved_range !== undefined && object.reserved_range !== null) { + for (const e of object.reserved_range) { + message.reserved_range.push( + EnumDescriptorProto_EnumReservedRange.fromPartial(e) + ); + } + } + if (object.reserved_name !== undefined && object.reserved_name !== null) { + for (const e of object.reserved_name) { + message.reserved_name.push(e); + } + } + return message; + }, +}; + +const baseEnumDescriptorProto_EnumReservedRange: object = { start: 0, end: 0 }; + +export const EnumDescriptorProto_EnumReservedRange = { + encode( + message: EnumDescriptorProto_EnumReservedRange, + writer: Writer = Writer.create() + ): Writer { + if (message.start !== 0) { + writer.uint32(8).int32(message.start); + } + if (message.end !== 0) { + writer.uint32(16).int32(message.end); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): EnumDescriptorProto_EnumReservedRange { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseEnumDescriptorProto_EnumReservedRange, + } as EnumDescriptorProto_EnumReservedRange; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.start = reader.int32(); + break; + case 2: + message.end = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumDescriptorProto_EnumReservedRange { + const message = { + ...baseEnumDescriptorProto_EnumReservedRange, + } as EnumDescriptorProto_EnumReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = Number(object.start); + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + return message; + }, + + toJSON(message: EnumDescriptorProto_EnumReservedRange): unknown { + const obj: any = {}; + message.start !== undefined && (obj.start = message.start); + message.end !== undefined && (obj.end = message.end); + return obj; + }, + + fromPartial( + object: DeepPartial + ): EnumDescriptorProto_EnumReservedRange { + const message = { + ...baseEnumDescriptorProto_EnumReservedRange, + } as EnumDescriptorProto_EnumReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = object.start; + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + return message; + }, +}; + +const baseEnumValueDescriptorProto: object = { name: "", number: 0 }; + +export const EnumValueDescriptorProto = { + encode( + message: EnumValueDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.number !== 0) { + writer.uint32(16).int32(message.number); + } + if (message.options !== undefined) { + EnumValueOptions.encode( + message.options, + writer.uint32(26).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): EnumValueDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseEnumValueDescriptorProto, + } as EnumValueDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.number = reader.int32(); + break; + case 3: + message.options = EnumValueOptions.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumValueDescriptorProto { + const message = { + ...baseEnumValueDescriptorProto, + } as EnumValueDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = Number(object.number); + } else { + message.number = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumValueOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: EnumValueDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.number !== undefined && (obj.number = message.number); + message.options !== undefined && + (obj.options = message.options + ? EnumValueOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): EnumValueDescriptorProto { + const message = { + ...baseEnumValueDescriptorProto, + } as EnumValueDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = object.number; + } else { + message.number = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumValueOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseServiceDescriptorProto: object = { name: "" }; + +export const ServiceDescriptorProto = { + encode( + message: ServiceDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + for (const v of message.method) { + MethodDescriptorProto.encode(v!, writer.uint32(18).fork()).ldelim(); + } + if (message.options !== undefined) { + ServiceOptions.encode(message.options, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ServiceDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseServiceDescriptorProto } as ServiceDescriptorProto; + message.method = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.method.push( + MethodDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 3: + message.options = ServiceOptions.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ServiceDescriptorProto { + const message = { ...baseServiceDescriptorProto } as ServiceDescriptorProto; + message.method = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.method !== undefined && object.method !== null) { + for (const e of object.method) { + message.method.push(MethodDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = ServiceOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: ServiceDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + if (message.method) { + obj.method = message.method.map((e) => + e ? MethodDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.method = []; + } + message.options !== undefined && + (obj.options = message.options + ? ServiceOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): ServiceDescriptorProto { + const message = { ...baseServiceDescriptorProto } as ServiceDescriptorProto; + message.method = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.method !== undefined && object.method !== null) { + for (const e of object.method) { + message.method.push(MethodDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = ServiceOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseMethodDescriptorProto: object = { + name: "", + input_type: "", + output_type: "", + client_streaming: false, + server_streaming: false, +}; + +export const MethodDescriptorProto = { + encode( + message: MethodDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.input_type !== "") { + writer.uint32(18).string(message.input_type); + } + if (message.output_type !== "") { + writer.uint32(26).string(message.output_type); + } + if (message.options !== undefined) { + MethodOptions.encode(message.options, writer.uint32(34).fork()).ldelim(); + } + if (message.client_streaming === true) { + writer.uint32(40).bool(message.client_streaming); + } + if (message.server_streaming === true) { + writer.uint32(48).bool(message.server_streaming); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MethodDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMethodDescriptorProto } as MethodDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.input_type = reader.string(); + break; + case 3: + message.output_type = reader.string(); + break; + case 4: + message.options = MethodOptions.decode(reader, reader.uint32()); + break; + case 5: + message.client_streaming = reader.bool(); + break; + case 6: + message.server_streaming = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MethodDescriptorProto { + const message = { ...baseMethodDescriptorProto } as MethodDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.input_type !== undefined && object.input_type !== null) { + message.input_type = String(object.input_type); + } else { + message.input_type = ""; + } + if (object.output_type !== undefined && object.output_type !== null) { + message.output_type = String(object.output_type); + } else { + message.output_type = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = MethodOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if ( + object.client_streaming !== undefined && + object.client_streaming !== null + ) { + message.client_streaming = Boolean(object.client_streaming); + } else { + message.client_streaming = false; + } + if ( + object.server_streaming !== undefined && + object.server_streaming !== null + ) { + message.server_streaming = Boolean(object.server_streaming); + } else { + message.server_streaming = false; + } + return message; + }, + + toJSON(message: MethodDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.input_type !== undefined && (obj.input_type = message.input_type); + message.output_type !== undefined && + (obj.output_type = message.output_type); + message.options !== undefined && + (obj.options = message.options + ? MethodOptions.toJSON(message.options) + : undefined); + message.client_streaming !== undefined && + (obj.client_streaming = message.client_streaming); + message.server_streaming !== undefined && + (obj.server_streaming = message.server_streaming); + return obj; + }, + + fromPartial( + object: DeepPartial + ): MethodDescriptorProto { + const message = { ...baseMethodDescriptorProto } as MethodDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.input_type !== undefined && object.input_type !== null) { + message.input_type = object.input_type; + } else { + message.input_type = ""; + } + if (object.output_type !== undefined && object.output_type !== null) { + message.output_type = object.output_type; + } else { + message.output_type = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = MethodOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if ( + object.client_streaming !== undefined && + object.client_streaming !== null + ) { + message.client_streaming = object.client_streaming; + } else { + message.client_streaming = false; + } + if ( + object.server_streaming !== undefined && + object.server_streaming !== null + ) { + message.server_streaming = object.server_streaming; + } else { + message.server_streaming = false; + } + return message; + }, +}; + +const baseFileOptions: object = { + java_package: "", + java_outer_classname: "", + java_multiple_files: false, + java_generate_equals_and_hash: false, + java_string_check_utf8: false, + optimize_for: 1, + go_package: "", + cc_generic_services: false, + java_generic_services: false, + py_generic_services: false, + php_generic_services: false, + deprecated: false, + cc_enable_arenas: false, + objc_class_prefix: "", + csharp_namespace: "", + swift_prefix: "", + php_class_prefix: "", + php_namespace: "", + php_metadata_namespace: "", + ruby_package: "", +}; + +export const FileOptions = { + encode(message: FileOptions, writer: Writer = Writer.create()): Writer { + if (message.java_package !== "") { + writer.uint32(10).string(message.java_package); + } + if (message.java_outer_classname !== "") { + writer.uint32(66).string(message.java_outer_classname); + } + if (message.java_multiple_files === true) { + writer.uint32(80).bool(message.java_multiple_files); + } + if (message.java_generate_equals_and_hash === true) { + writer.uint32(160).bool(message.java_generate_equals_and_hash); + } + if (message.java_string_check_utf8 === true) { + writer.uint32(216).bool(message.java_string_check_utf8); + } + if (message.optimize_for !== 1) { + writer.uint32(72).int32(message.optimize_for); + } + if (message.go_package !== "") { + writer.uint32(90).string(message.go_package); + } + if (message.cc_generic_services === true) { + writer.uint32(128).bool(message.cc_generic_services); + } + if (message.java_generic_services === true) { + writer.uint32(136).bool(message.java_generic_services); + } + if (message.py_generic_services === true) { + writer.uint32(144).bool(message.py_generic_services); + } + if (message.php_generic_services === true) { + writer.uint32(336).bool(message.php_generic_services); + } + if (message.deprecated === true) { + writer.uint32(184).bool(message.deprecated); + } + if (message.cc_enable_arenas === true) { + writer.uint32(248).bool(message.cc_enable_arenas); + } + if (message.objc_class_prefix !== "") { + writer.uint32(290).string(message.objc_class_prefix); + } + if (message.csharp_namespace !== "") { + writer.uint32(298).string(message.csharp_namespace); + } + if (message.swift_prefix !== "") { + writer.uint32(314).string(message.swift_prefix); + } + if (message.php_class_prefix !== "") { + writer.uint32(322).string(message.php_class_prefix); + } + if (message.php_namespace !== "") { + writer.uint32(330).string(message.php_namespace); + } + if (message.php_metadata_namespace !== "") { + writer.uint32(354).string(message.php_metadata_namespace); + } + if (message.ruby_package !== "") { + writer.uint32(362).string(message.ruby_package); + } + for (const v of message.uninterpreted_option) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FileOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFileOptions } as FileOptions; + message.uninterpreted_option = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.java_package = reader.string(); + break; + case 8: + message.java_outer_classname = reader.string(); + break; + case 10: + message.java_multiple_files = reader.bool(); + break; + case 20: + message.java_generate_equals_and_hash = reader.bool(); + break; + case 27: + message.java_string_check_utf8 = reader.bool(); + break; + case 9: + message.optimize_for = reader.int32() as any; + break; + case 11: + message.go_package = reader.string(); + break; + case 16: + message.cc_generic_services = reader.bool(); + break; + case 17: + message.java_generic_services = reader.bool(); + break; + case 18: + message.py_generic_services = reader.bool(); + break; + case 42: + message.php_generic_services = reader.bool(); + break; + case 23: + message.deprecated = reader.bool(); + break; + case 31: + message.cc_enable_arenas = reader.bool(); + break; + case 36: + message.objc_class_prefix = reader.string(); + break; + case 37: + message.csharp_namespace = reader.string(); + break; + case 39: + message.swift_prefix = reader.string(); + break; + case 40: + message.php_class_prefix = reader.string(); + break; + case 41: + message.php_namespace = reader.string(); + break; + case 44: + message.php_metadata_namespace = reader.string(); + break; + case 45: + message.ruby_package = reader.string(); + break; + case 999: + message.uninterpreted_option.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FileOptions { + const message = { ...baseFileOptions } as FileOptions; + message.uninterpreted_option = []; + if (object.java_package !== undefined && object.java_package !== null) { + message.java_package = String(object.java_package); + } else { + message.java_package = ""; + } + if ( + object.java_outer_classname !== undefined && + object.java_outer_classname !== null + ) { + message.java_outer_classname = String(object.java_outer_classname); + } else { + message.java_outer_classname = ""; + } + if ( + object.java_multiple_files !== undefined && + object.java_multiple_files !== null + ) { + message.java_multiple_files = Boolean(object.java_multiple_files); + } else { + message.java_multiple_files = false; + } + if ( + object.java_generate_equals_and_hash !== undefined && + object.java_generate_equals_and_hash !== null + ) { + message.java_generate_equals_and_hash = Boolean( + object.java_generate_equals_and_hash + ); + } else { + message.java_generate_equals_and_hash = false; + } + if ( + object.java_string_check_utf8 !== undefined && + object.java_string_check_utf8 !== null + ) { + message.java_string_check_utf8 = Boolean(object.java_string_check_utf8); + } else { + message.java_string_check_utf8 = false; + } + if (object.optimize_for !== undefined && object.optimize_for !== null) { + message.optimize_for = fileOptions_OptimizeModeFromJSON( + object.optimize_for + ); + } else { + message.optimize_for = 1; + } + if (object.go_package !== undefined && object.go_package !== null) { + message.go_package = String(object.go_package); + } else { + message.go_package = ""; + } + if ( + object.cc_generic_services !== undefined && + object.cc_generic_services !== null + ) { + message.cc_generic_services = Boolean(object.cc_generic_services); + } else { + message.cc_generic_services = false; + } + if ( + object.java_generic_services !== undefined && + object.java_generic_services !== null + ) { + message.java_generic_services = Boolean(object.java_generic_services); + } else { + message.java_generic_services = false; + } + if ( + object.py_generic_services !== undefined && + object.py_generic_services !== null + ) { + message.py_generic_services = Boolean(object.py_generic_services); + } else { + message.py_generic_services = false; + } + if ( + object.php_generic_services !== undefined && + object.php_generic_services !== null + ) { + message.php_generic_services = Boolean(object.php_generic_services); + } else { + message.php_generic_services = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.cc_enable_arenas !== undefined && + object.cc_enable_arenas !== null + ) { + message.cc_enable_arenas = Boolean(object.cc_enable_arenas); + } else { + message.cc_enable_arenas = false; + } + if ( + object.objc_class_prefix !== undefined && + object.objc_class_prefix !== null + ) { + message.objc_class_prefix = String(object.objc_class_prefix); + } else { + message.objc_class_prefix = ""; + } + if ( + object.csharp_namespace !== undefined && + object.csharp_namespace !== null + ) { + message.csharp_namespace = String(object.csharp_namespace); + } else { + message.csharp_namespace = ""; + } + if (object.swift_prefix !== undefined && object.swift_prefix !== null) { + message.swift_prefix = String(object.swift_prefix); + } else { + message.swift_prefix = ""; + } + if ( + object.php_class_prefix !== undefined && + object.php_class_prefix !== null + ) { + message.php_class_prefix = String(object.php_class_prefix); + } else { + message.php_class_prefix = ""; + } + if (object.php_namespace !== undefined && object.php_namespace !== null) { + message.php_namespace = String(object.php_namespace); + } else { + message.php_namespace = ""; + } + if ( + object.php_metadata_namespace !== undefined && + object.php_metadata_namespace !== null + ) { + message.php_metadata_namespace = String(object.php_metadata_namespace); + } else { + message.php_metadata_namespace = ""; + } + if (object.ruby_package !== undefined && object.ruby_package !== null) { + message.ruby_package = String(object.ruby_package); + } else { + message.ruby_package = ""; + } + if ( + object.uninterpreted_option !== undefined && + object.uninterpreted_option !== null + ) { + for (const e of object.uninterpreted_option) { + message.uninterpreted_option.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: FileOptions): unknown { + const obj: any = {}; + message.java_package !== undefined && + (obj.java_package = message.java_package); + message.java_outer_classname !== undefined && + (obj.java_outer_classname = message.java_outer_classname); + message.java_multiple_files !== undefined && + (obj.java_multiple_files = message.java_multiple_files); + message.java_generate_equals_and_hash !== undefined && + (obj.java_generate_equals_and_hash = + message.java_generate_equals_and_hash); + message.java_string_check_utf8 !== undefined && + (obj.java_string_check_utf8 = message.java_string_check_utf8); + message.optimize_for !== undefined && + (obj.optimize_for = fileOptions_OptimizeModeToJSON(message.optimize_for)); + message.go_package !== undefined && (obj.go_package = message.go_package); + message.cc_generic_services !== undefined && + (obj.cc_generic_services = message.cc_generic_services); + message.java_generic_services !== undefined && + (obj.java_generic_services = message.java_generic_services); + message.py_generic_services !== undefined && + (obj.py_generic_services = message.py_generic_services); + message.php_generic_services !== undefined && + (obj.php_generic_services = message.php_generic_services); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.cc_enable_arenas !== undefined && + (obj.cc_enable_arenas = message.cc_enable_arenas); + message.objc_class_prefix !== undefined && + (obj.objc_class_prefix = message.objc_class_prefix); + message.csharp_namespace !== undefined && + (obj.csharp_namespace = message.csharp_namespace); + message.swift_prefix !== undefined && + (obj.swift_prefix = message.swift_prefix); + message.php_class_prefix !== undefined && + (obj.php_class_prefix = message.php_class_prefix); + message.php_namespace !== undefined && + (obj.php_namespace = message.php_namespace); + message.php_metadata_namespace !== undefined && + (obj.php_metadata_namespace = message.php_metadata_namespace); + message.ruby_package !== undefined && + (obj.ruby_package = message.ruby_package); + if (message.uninterpreted_option) { + obj.uninterpreted_option = message.uninterpreted_option.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpreted_option = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): FileOptions { + const message = { ...baseFileOptions } as FileOptions; + message.uninterpreted_option = []; + if (object.java_package !== undefined && object.java_package !== null) { + message.java_package = object.java_package; + } else { + message.java_package = ""; + } + if ( + object.java_outer_classname !== undefined && + object.java_outer_classname !== null + ) { + message.java_outer_classname = object.java_outer_classname; + } else { + message.java_outer_classname = ""; + } + if ( + object.java_multiple_files !== undefined && + object.java_multiple_files !== null + ) { + message.java_multiple_files = object.java_multiple_files; + } else { + message.java_multiple_files = false; + } + if ( + object.java_generate_equals_and_hash !== undefined && + object.java_generate_equals_and_hash !== null + ) { + message.java_generate_equals_and_hash = + object.java_generate_equals_and_hash; + } else { + message.java_generate_equals_and_hash = false; + } + if ( + object.java_string_check_utf8 !== undefined && + object.java_string_check_utf8 !== null + ) { + message.java_string_check_utf8 = object.java_string_check_utf8; + } else { + message.java_string_check_utf8 = false; + } + if (object.optimize_for !== undefined && object.optimize_for !== null) { + message.optimize_for = object.optimize_for; + } else { + message.optimize_for = 1; + } + if (object.go_package !== undefined && object.go_package !== null) { + message.go_package = object.go_package; + } else { + message.go_package = ""; + } + if ( + object.cc_generic_services !== undefined && + object.cc_generic_services !== null + ) { + message.cc_generic_services = object.cc_generic_services; + } else { + message.cc_generic_services = false; + } + if ( + object.java_generic_services !== undefined && + object.java_generic_services !== null + ) { + message.java_generic_services = object.java_generic_services; + } else { + message.java_generic_services = false; + } + if ( + object.py_generic_services !== undefined && + object.py_generic_services !== null + ) { + message.py_generic_services = object.py_generic_services; + } else { + message.py_generic_services = false; + } + if ( + object.php_generic_services !== undefined && + object.php_generic_services !== null + ) { + message.php_generic_services = object.php_generic_services; + } else { + message.php_generic_services = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.cc_enable_arenas !== undefined && + object.cc_enable_arenas !== null + ) { + message.cc_enable_arenas = object.cc_enable_arenas; + } else { + message.cc_enable_arenas = false; + } + if ( + object.objc_class_prefix !== undefined && + object.objc_class_prefix !== null + ) { + message.objc_class_prefix = object.objc_class_prefix; + } else { + message.objc_class_prefix = ""; + } + if ( + object.csharp_namespace !== undefined && + object.csharp_namespace !== null + ) { + message.csharp_namespace = object.csharp_namespace; + } else { + message.csharp_namespace = ""; + } + if (object.swift_prefix !== undefined && object.swift_prefix !== null) { + message.swift_prefix = object.swift_prefix; + } else { + message.swift_prefix = ""; + } + if ( + object.php_class_prefix !== undefined && + object.php_class_prefix !== null + ) { + message.php_class_prefix = object.php_class_prefix; + } else { + message.php_class_prefix = ""; + } + if (object.php_namespace !== undefined && object.php_namespace !== null) { + message.php_namespace = object.php_namespace; + } else { + message.php_namespace = ""; + } + if ( + object.php_metadata_namespace !== undefined && + object.php_metadata_namespace !== null + ) { + message.php_metadata_namespace = object.php_metadata_namespace; + } else { + message.php_metadata_namespace = ""; + } + if (object.ruby_package !== undefined && object.ruby_package !== null) { + message.ruby_package = object.ruby_package; + } else { + message.ruby_package = ""; + } + if ( + object.uninterpreted_option !== undefined && + object.uninterpreted_option !== null + ) { + for (const e of object.uninterpreted_option) { + message.uninterpreted_option.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseMessageOptions: object = { + message_set_wire_format: false, + no_standard_descriptor_accessor: false, + deprecated: false, + map_entry: false, +}; + +export const MessageOptions = { + encode(message: MessageOptions, writer: Writer = Writer.create()): Writer { + if (message.message_set_wire_format === true) { + writer.uint32(8).bool(message.message_set_wire_format); + } + if (message.no_standard_descriptor_accessor === true) { + writer.uint32(16).bool(message.no_standard_descriptor_accessor); + } + if (message.deprecated === true) { + writer.uint32(24).bool(message.deprecated); + } + if (message.map_entry === true) { + writer.uint32(56).bool(message.map_entry); + } + for (const v of message.uninterpreted_option) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MessageOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMessageOptions } as MessageOptions; + message.uninterpreted_option = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.message_set_wire_format = reader.bool(); + break; + case 2: + message.no_standard_descriptor_accessor = reader.bool(); + break; + case 3: + message.deprecated = reader.bool(); + break; + case 7: + message.map_entry = reader.bool(); + break; + case 999: + message.uninterpreted_option.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MessageOptions { + const message = { ...baseMessageOptions } as MessageOptions; + message.uninterpreted_option = []; + if ( + object.message_set_wire_format !== undefined && + object.message_set_wire_format !== null + ) { + message.message_set_wire_format = Boolean(object.message_set_wire_format); + } else { + message.message_set_wire_format = false; + } + if ( + object.no_standard_descriptor_accessor !== undefined && + object.no_standard_descriptor_accessor !== null + ) { + message.no_standard_descriptor_accessor = Boolean( + object.no_standard_descriptor_accessor + ); + } else { + message.no_standard_descriptor_accessor = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if (object.map_entry !== undefined && object.map_entry !== null) { + message.map_entry = Boolean(object.map_entry); + } else { + message.map_entry = false; + } + if ( + object.uninterpreted_option !== undefined && + object.uninterpreted_option !== null + ) { + for (const e of object.uninterpreted_option) { + message.uninterpreted_option.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: MessageOptions): unknown { + const obj: any = {}; + message.message_set_wire_format !== undefined && + (obj.message_set_wire_format = message.message_set_wire_format); + message.no_standard_descriptor_accessor !== undefined && + (obj.no_standard_descriptor_accessor = + message.no_standard_descriptor_accessor); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.map_entry !== undefined && (obj.map_entry = message.map_entry); + if (message.uninterpreted_option) { + obj.uninterpreted_option = message.uninterpreted_option.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpreted_option = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): MessageOptions { + const message = { ...baseMessageOptions } as MessageOptions; + message.uninterpreted_option = []; + if ( + object.message_set_wire_format !== undefined && + object.message_set_wire_format !== null + ) { + message.message_set_wire_format = object.message_set_wire_format; + } else { + message.message_set_wire_format = false; + } + if ( + object.no_standard_descriptor_accessor !== undefined && + object.no_standard_descriptor_accessor !== null + ) { + message.no_standard_descriptor_accessor = + object.no_standard_descriptor_accessor; + } else { + message.no_standard_descriptor_accessor = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if (object.map_entry !== undefined && object.map_entry !== null) { + message.map_entry = object.map_entry; + } else { + message.map_entry = false; + } + if ( + object.uninterpreted_option !== undefined && + object.uninterpreted_option !== null + ) { + for (const e of object.uninterpreted_option) { + message.uninterpreted_option.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseFieldOptions: object = { + ctype: 0, + packed: false, + jstype: 0, + lazy: false, + deprecated: false, + weak: false, +}; + +export const FieldOptions = { + encode(message: FieldOptions, writer: Writer = Writer.create()): Writer { + if (message.ctype !== 0) { + writer.uint32(8).int32(message.ctype); + } + if (message.packed === true) { + writer.uint32(16).bool(message.packed); + } + if (message.jstype !== 0) { + writer.uint32(48).int32(message.jstype); + } + if (message.lazy === true) { + writer.uint32(40).bool(message.lazy); + } + if (message.deprecated === true) { + writer.uint32(24).bool(message.deprecated); + } + if (message.weak === true) { + writer.uint32(80).bool(message.weak); + } + for (const v of message.uninterpreted_option) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FieldOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFieldOptions } as FieldOptions; + message.uninterpreted_option = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.ctype = reader.int32() as any; + break; + case 2: + message.packed = reader.bool(); + break; + case 6: + message.jstype = reader.int32() as any; + break; + case 5: + message.lazy = reader.bool(); + break; + case 3: + message.deprecated = reader.bool(); + break; + case 10: + message.weak = reader.bool(); + break; + case 999: + message.uninterpreted_option.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FieldOptions { + const message = { ...baseFieldOptions } as FieldOptions; + message.uninterpreted_option = []; + if (object.ctype !== undefined && object.ctype !== null) { + message.ctype = fieldOptions_CTypeFromJSON(object.ctype); + } else { + message.ctype = 0; + } + if (object.packed !== undefined && object.packed !== null) { + message.packed = Boolean(object.packed); + } else { + message.packed = false; + } + if (object.jstype !== undefined && object.jstype !== null) { + message.jstype = fieldOptions_JSTypeFromJSON(object.jstype); + } else { + message.jstype = 0; + } + if (object.lazy !== undefined && object.lazy !== null) { + message.lazy = Boolean(object.lazy); + } else { + message.lazy = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if (object.weak !== undefined && object.weak !== null) { + message.weak = Boolean(object.weak); + } else { + message.weak = false; + } + if ( + object.uninterpreted_option !== undefined && + object.uninterpreted_option !== null + ) { + for (const e of object.uninterpreted_option) { + message.uninterpreted_option.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: FieldOptions): unknown { + const obj: any = {}; + message.ctype !== undefined && + (obj.ctype = fieldOptions_CTypeToJSON(message.ctype)); + message.packed !== undefined && (obj.packed = message.packed); + message.jstype !== undefined && + (obj.jstype = fieldOptions_JSTypeToJSON(message.jstype)); + message.lazy !== undefined && (obj.lazy = message.lazy); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.weak !== undefined && (obj.weak = message.weak); + if (message.uninterpreted_option) { + obj.uninterpreted_option = message.uninterpreted_option.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpreted_option = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): FieldOptions { + const message = { ...baseFieldOptions } as FieldOptions; + message.uninterpreted_option = []; + if (object.ctype !== undefined && object.ctype !== null) { + message.ctype = object.ctype; + } else { + message.ctype = 0; + } + if (object.packed !== undefined && object.packed !== null) { + message.packed = object.packed; + } else { + message.packed = false; + } + if (object.jstype !== undefined && object.jstype !== null) { + message.jstype = object.jstype; + } else { + message.jstype = 0; + } + if (object.lazy !== undefined && object.lazy !== null) { + message.lazy = object.lazy; + } else { + message.lazy = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if (object.weak !== undefined && object.weak !== null) { + message.weak = object.weak; + } else { + message.weak = false; + } + if ( + object.uninterpreted_option !== undefined && + object.uninterpreted_option !== null + ) { + for (const e of object.uninterpreted_option) { + message.uninterpreted_option.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseOneofOptions: object = {}; + +export const OneofOptions = { + encode(message: OneofOptions, writer: Writer = Writer.create()): Writer { + for (const v of message.uninterpreted_option) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): OneofOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseOneofOptions } as OneofOptions; + message.uninterpreted_option = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 999: + message.uninterpreted_option.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): OneofOptions { + const message = { ...baseOneofOptions } as OneofOptions; + message.uninterpreted_option = []; + if ( + object.uninterpreted_option !== undefined && + object.uninterpreted_option !== null + ) { + for (const e of object.uninterpreted_option) { + message.uninterpreted_option.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: OneofOptions): unknown { + const obj: any = {}; + if (message.uninterpreted_option) { + obj.uninterpreted_option = message.uninterpreted_option.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpreted_option = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): OneofOptions { + const message = { ...baseOneofOptions } as OneofOptions; + message.uninterpreted_option = []; + if ( + object.uninterpreted_option !== undefined && + object.uninterpreted_option !== null + ) { + for (const e of object.uninterpreted_option) { + message.uninterpreted_option.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseEnumOptions: object = { allow_alias: false, deprecated: false }; + +export const EnumOptions = { + encode(message: EnumOptions, writer: Writer = Writer.create()): Writer { + if (message.allow_alias === true) { + writer.uint32(16).bool(message.allow_alias); + } + if (message.deprecated === true) { + writer.uint32(24).bool(message.deprecated); + } + for (const v of message.uninterpreted_option) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): EnumOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseEnumOptions } as EnumOptions; + message.uninterpreted_option = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + message.allow_alias = reader.bool(); + break; + case 3: + message.deprecated = reader.bool(); + break; + case 999: + message.uninterpreted_option.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumOptions { + const message = { ...baseEnumOptions } as EnumOptions; + message.uninterpreted_option = []; + if (object.allow_alias !== undefined && object.allow_alias !== null) { + message.allow_alias = Boolean(object.allow_alias); + } else { + message.allow_alias = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.uninterpreted_option !== undefined && + object.uninterpreted_option !== null + ) { + for (const e of object.uninterpreted_option) { + message.uninterpreted_option.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: EnumOptions): unknown { + const obj: any = {}; + message.allow_alias !== undefined && + (obj.allow_alias = message.allow_alias); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + if (message.uninterpreted_option) { + obj.uninterpreted_option = message.uninterpreted_option.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpreted_option = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): EnumOptions { + const message = { ...baseEnumOptions } as EnumOptions; + message.uninterpreted_option = []; + if (object.allow_alias !== undefined && object.allow_alias !== null) { + message.allow_alias = object.allow_alias; + } else { + message.allow_alias = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.uninterpreted_option !== undefined && + object.uninterpreted_option !== null + ) { + for (const e of object.uninterpreted_option) { + message.uninterpreted_option.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseEnumValueOptions: object = { deprecated: false }; + +export const EnumValueOptions = { + encode(message: EnumValueOptions, writer: Writer = Writer.create()): Writer { + if (message.deprecated === true) { + writer.uint32(8).bool(message.deprecated); + } + for (const v of message.uninterpreted_option) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): EnumValueOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseEnumValueOptions } as EnumValueOptions; + message.uninterpreted_option = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.deprecated = reader.bool(); + break; + case 999: + message.uninterpreted_option.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumValueOptions { + const message = { ...baseEnumValueOptions } as EnumValueOptions; + message.uninterpreted_option = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.uninterpreted_option !== undefined && + object.uninterpreted_option !== null + ) { + for (const e of object.uninterpreted_option) { + message.uninterpreted_option.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: EnumValueOptions): unknown { + const obj: any = {}; + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + if (message.uninterpreted_option) { + obj.uninterpreted_option = message.uninterpreted_option.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpreted_option = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): EnumValueOptions { + const message = { ...baseEnumValueOptions } as EnumValueOptions; + message.uninterpreted_option = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.uninterpreted_option !== undefined && + object.uninterpreted_option !== null + ) { + for (const e of object.uninterpreted_option) { + message.uninterpreted_option.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseServiceOptions: object = { deprecated: false }; + +export const ServiceOptions = { + encode(message: ServiceOptions, writer: Writer = Writer.create()): Writer { + if (message.deprecated === true) { + writer.uint32(264).bool(message.deprecated); + } + for (const v of message.uninterpreted_option) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ServiceOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseServiceOptions } as ServiceOptions; + message.uninterpreted_option = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 33: + message.deprecated = reader.bool(); + break; + case 999: + message.uninterpreted_option.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ServiceOptions { + const message = { ...baseServiceOptions } as ServiceOptions; + message.uninterpreted_option = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.uninterpreted_option !== undefined && + object.uninterpreted_option !== null + ) { + for (const e of object.uninterpreted_option) { + message.uninterpreted_option.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: ServiceOptions): unknown { + const obj: any = {}; + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + if (message.uninterpreted_option) { + obj.uninterpreted_option = message.uninterpreted_option.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpreted_option = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): ServiceOptions { + const message = { ...baseServiceOptions } as ServiceOptions; + message.uninterpreted_option = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.uninterpreted_option !== undefined && + object.uninterpreted_option !== null + ) { + for (const e of object.uninterpreted_option) { + message.uninterpreted_option.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseMethodOptions: object = { deprecated: false, idempotency_level: 0 }; + +export const MethodOptions = { + encode(message: MethodOptions, writer: Writer = Writer.create()): Writer { + if (message.deprecated === true) { + writer.uint32(264).bool(message.deprecated); + } + if (message.idempotency_level !== 0) { + writer.uint32(272).int32(message.idempotency_level); + } + for (const v of message.uninterpreted_option) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MethodOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMethodOptions } as MethodOptions; + message.uninterpreted_option = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 33: + message.deprecated = reader.bool(); + break; + case 34: + message.idempotency_level = reader.int32() as any; + break; + case 999: + message.uninterpreted_option.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MethodOptions { + const message = { ...baseMethodOptions } as MethodOptions; + message.uninterpreted_option = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.idempotency_level !== undefined && + object.idempotency_level !== null + ) { + message.idempotency_level = methodOptions_IdempotencyLevelFromJSON( + object.idempotency_level + ); + } else { + message.idempotency_level = 0; + } + if ( + object.uninterpreted_option !== undefined && + object.uninterpreted_option !== null + ) { + for (const e of object.uninterpreted_option) { + message.uninterpreted_option.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: MethodOptions): unknown { + const obj: any = {}; + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.idempotency_level !== undefined && + (obj.idempotency_level = methodOptions_IdempotencyLevelToJSON( + message.idempotency_level + )); + if (message.uninterpreted_option) { + obj.uninterpreted_option = message.uninterpreted_option.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpreted_option = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): MethodOptions { + const message = { ...baseMethodOptions } as MethodOptions; + message.uninterpreted_option = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.idempotency_level !== undefined && + object.idempotency_level !== null + ) { + message.idempotency_level = object.idempotency_level; + } else { + message.idempotency_level = 0; + } + if ( + object.uninterpreted_option !== undefined && + object.uninterpreted_option !== null + ) { + for (const e of object.uninterpreted_option) { + message.uninterpreted_option.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseUninterpretedOption: object = { + identifier_value: "", + positive_int_value: 0, + negative_int_value: 0, + double_value: 0, + aggregate_value: "", +}; + +export const UninterpretedOption = { + encode( + message: UninterpretedOption, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.name) { + UninterpretedOption_NamePart.encode( + v!, + writer.uint32(18).fork() + ).ldelim(); + } + if (message.identifier_value !== "") { + writer.uint32(26).string(message.identifier_value); + } + if (message.positive_int_value !== 0) { + writer.uint32(32).uint64(message.positive_int_value); + } + if (message.negative_int_value !== 0) { + writer.uint32(40).int64(message.negative_int_value); + } + if (message.double_value !== 0) { + writer.uint32(49).double(message.double_value); + } + if (message.string_value.length !== 0) { + writer.uint32(58).bytes(message.string_value); + } + if (message.aggregate_value !== "") { + writer.uint32(66).string(message.aggregate_value); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): UninterpretedOption { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseUninterpretedOption } as UninterpretedOption; + message.name = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + message.name.push( + UninterpretedOption_NamePart.decode(reader, reader.uint32()) + ); + break; + case 3: + message.identifier_value = reader.string(); + break; + case 4: + message.positive_int_value = longToNumber(reader.uint64() as Long); + break; + case 5: + message.negative_int_value = longToNumber(reader.int64() as Long); + break; + case 6: + message.double_value = reader.double(); + break; + case 7: + message.string_value = reader.bytes(); + break; + case 8: + message.aggregate_value = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): UninterpretedOption { + const message = { ...baseUninterpretedOption } as UninterpretedOption; + message.name = []; + if (object.name !== undefined && object.name !== null) { + for (const e of object.name) { + message.name.push(UninterpretedOption_NamePart.fromJSON(e)); + } + } + if ( + object.identifier_value !== undefined && + object.identifier_value !== null + ) { + message.identifier_value = String(object.identifier_value); + } else { + message.identifier_value = ""; + } + if ( + object.positive_int_value !== undefined && + object.positive_int_value !== null + ) { + message.positive_int_value = Number(object.positive_int_value); + } else { + message.positive_int_value = 0; + } + if ( + object.negative_int_value !== undefined && + object.negative_int_value !== null + ) { + message.negative_int_value = Number(object.negative_int_value); + } else { + message.negative_int_value = 0; + } + if (object.double_value !== undefined && object.double_value !== null) { + message.double_value = Number(object.double_value); + } else { + message.double_value = 0; + } + if (object.string_value !== undefined && object.string_value !== null) { + message.string_value = bytesFromBase64(object.string_value); + } + if ( + object.aggregate_value !== undefined && + object.aggregate_value !== null + ) { + message.aggregate_value = String(object.aggregate_value); + } else { + message.aggregate_value = ""; + } + return message; + }, + + toJSON(message: UninterpretedOption): unknown { + const obj: any = {}; + if (message.name) { + obj.name = message.name.map((e) => + e ? UninterpretedOption_NamePart.toJSON(e) : undefined + ); + } else { + obj.name = []; + } + message.identifier_value !== undefined && + (obj.identifier_value = message.identifier_value); + message.positive_int_value !== undefined && + (obj.positive_int_value = message.positive_int_value); + message.negative_int_value !== undefined && + (obj.negative_int_value = message.negative_int_value); + message.double_value !== undefined && + (obj.double_value = message.double_value); + message.string_value !== undefined && + (obj.string_value = base64FromBytes( + message.string_value !== undefined + ? message.string_value + : new Uint8Array() + )); + message.aggregate_value !== undefined && + (obj.aggregate_value = message.aggregate_value); + return obj; + }, + + fromPartial(object: DeepPartial): UninterpretedOption { + const message = { ...baseUninterpretedOption } as UninterpretedOption; + message.name = []; + if (object.name !== undefined && object.name !== null) { + for (const e of object.name) { + message.name.push(UninterpretedOption_NamePart.fromPartial(e)); + } + } + if ( + object.identifier_value !== undefined && + object.identifier_value !== null + ) { + message.identifier_value = object.identifier_value; + } else { + message.identifier_value = ""; + } + if ( + object.positive_int_value !== undefined && + object.positive_int_value !== null + ) { + message.positive_int_value = object.positive_int_value; + } else { + message.positive_int_value = 0; + } + if ( + object.negative_int_value !== undefined && + object.negative_int_value !== null + ) { + message.negative_int_value = object.negative_int_value; + } else { + message.negative_int_value = 0; + } + if (object.double_value !== undefined && object.double_value !== null) { + message.double_value = object.double_value; + } else { + message.double_value = 0; + } + if (object.string_value !== undefined && object.string_value !== null) { + message.string_value = object.string_value; + } else { + message.string_value = new Uint8Array(); + } + if ( + object.aggregate_value !== undefined && + object.aggregate_value !== null + ) { + message.aggregate_value = object.aggregate_value; + } else { + message.aggregate_value = ""; + } + return message; + }, +}; + +const baseUninterpretedOption_NamePart: object = { + name_part: "", + is_extension: false, +}; + +export const UninterpretedOption_NamePart = { + encode( + message: UninterpretedOption_NamePart, + writer: Writer = Writer.create() + ): Writer { + if (message.name_part !== "") { + writer.uint32(10).string(message.name_part); + } + if (message.is_extension === true) { + writer.uint32(16).bool(message.is_extension); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): UninterpretedOption_NamePart { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseUninterpretedOption_NamePart, + } as UninterpretedOption_NamePart; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name_part = reader.string(); + break; + case 2: + message.is_extension = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): UninterpretedOption_NamePart { + const message = { + ...baseUninterpretedOption_NamePart, + } as UninterpretedOption_NamePart; + if (object.name_part !== undefined && object.name_part !== null) { + message.name_part = String(object.name_part); + } else { + message.name_part = ""; + } + if (object.is_extension !== undefined && object.is_extension !== null) { + message.is_extension = Boolean(object.is_extension); + } else { + message.is_extension = false; + } + return message; + }, + + toJSON(message: UninterpretedOption_NamePart): unknown { + const obj: any = {}; + message.name_part !== undefined && (obj.name_part = message.name_part); + message.is_extension !== undefined && + (obj.is_extension = message.is_extension); + return obj; + }, + + fromPartial( + object: DeepPartial + ): UninterpretedOption_NamePart { + const message = { + ...baseUninterpretedOption_NamePart, + } as UninterpretedOption_NamePart; + if (object.name_part !== undefined && object.name_part !== null) { + message.name_part = object.name_part; + } else { + message.name_part = ""; + } + if (object.is_extension !== undefined && object.is_extension !== null) { + message.is_extension = object.is_extension; + } else { + message.is_extension = false; + } + return message; + }, +}; + +const baseSourceCodeInfo: object = {}; + +export const SourceCodeInfo = { + encode(message: SourceCodeInfo, writer: Writer = Writer.create()): Writer { + for (const v of message.location) { + SourceCodeInfo_Location.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): SourceCodeInfo { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseSourceCodeInfo } as SourceCodeInfo; + message.location = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.location.push( + SourceCodeInfo_Location.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): SourceCodeInfo { + const message = { ...baseSourceCodeInfo } as SourceCodeInfo; + message.location = []; + if (object.location !== undefined && object.location !== null) { + for (const e of object.location) { + message.location.push(SourceCodeInfo_Location.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: SourceCodeInfo): unknown { + const obj: any = {}; + if (message.location) { + obj.location = message.location.map((e) => + e ? SourceCodeInfo_Location.toJSON(e) : undefined + ); + } else { + obj.location = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): SourceCodeInfo { + const message = { ...baseSourceCodeInfo } as SourceCodeInfo; + message.location = []; + if (object.location !== undefined && object.location !== null) { + for (const e of object.location) { + message.location.push(SourceCodeInfo_Location.fromPartial(e)); + } + } + return message; + }, +}; + +const baseSourceCodeInfo_Location: object = { + path: 0, + span: 0, + leading_comments: "", + trailing_comments: "", + leading_detached_comments: "", +}; + +export const SourceCodeInfo_Location = { + encode( + message: SourceCodeInfo_Location, + writer: Writer = Writer.create() + ): Writer { + writer.uint32(10).fork(); + for (const v of message.path) { + writer.int32(v); + } + writer.ldelim(); + writer.uint32(18).fork(); + for (const v of message.span) { + writer.int32(v); + } + writer.ldelim(); + if (message.leading_comments !== "") { + writer.uint32(26).string(message.leading_comments); + } + if (message.trailing_comments !== "") { + writer.uint32(34).string(message.trailing_comments); + } + for (const v of message.leading_detached_comments) { + writer.uint32(50).string(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): SourceCodeInfo_Location { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseSourceCodeInfo_Location, + } as SourceCodeInfo_Location; + message.path = []; + message.span = []; + message.leading_detached_comments = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.path.push(reader.int32()); + } + } else { + message.path.push(reader.int32()); + } + break; + case 2: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.span.push(reader.int32()); + } + } else { + message.span.push(reader.int32()); + } + break; + case 3: + message.leading_comments = reader.string(); + break; + case 4: + message.trailing_comments = reader.string(); + break; + case 6: + message.leading_detached_comments.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): SourceCodeInfo_Location { + const message = { + ...baseSourceCodeInfo_Location, + } as SourceCodeInfo_Location; + message.path = []; + message.span = []; + message.leading_detached_comments = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(Number(e)); + } + } + if (object.span !== undefined && object.span !== null) { + for (const e of object.span) { + message.span.push(Number(e)); + } + } + if ( + object.leading_comments !== undefined && + object.leading_comments !== null + ) { + message.leading_comments = String(object.leading_comments); + } else { + message.leading_comments = ""; + } + if ( + object.trailing_comments !== undefined && + object.trailing_comments !== null + ) { + message.trailing_comments = String(object.trailing_comments); + } else { + message.trailing_comments = ""; + } + if ( + object.leading_detached_comments !== undefined && + object.leading_detached_comments !== null + ) { + for (const e of object.leading_detached_comments) { + message.leading_detached_comments.push(String(e)); + } + } + return message; + }, + + toJSON(message: SourceCodeInfo_Location): unknown { + const obj: any = {}; + if (message.path) { + obj.path = message.path.map((e) => e); + } else { + obj.path = []; + } + if (message.span) { + obj.span = message.span.map((e) => e); + } else { + obj.span = []; + } + message.leading_comments !== undefined && + (obj.leading_comments = message.leading_comments); + message.trailing_comments !== undefined && + (obj.trailing_comments = message.trailing_comments); + if (message.leading_detached_comments) { + obj.leading_detached_comments = message.leading_detached_comments.map( + (e) => e + ); + } else { + obj.leading_detached_comments = []; + } + return obj; + }, + + fromPartial( + object: DeepPartial + ): SourceCodeInfo_Location { + const message = { + ...baseSourceCodeInfo_Location, + } as SourceCodeInfo_Location; + message.path = []; + message.span = []; + message.leading_detached_comments = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(e); + } + } + if (object.span !== undefined && object.span !== null) { + for (const e of object.span) { + message.span.push(e); + } + } + if ( + object.leading_comments !== undefined && + object.leading_comments !== null + ) { + message.leading_comments = object.leading_comments; + } else { + message.leading_comments = ""; + } + if ( + object.trailing_comments !== undefined && + object.trailing_comments !== null + ) { + message.trailing_comments = object.trailing_comments; + } else { + message.trailing_comments = ""; + } + if ( + object.leading_detached_comments !== undefined && + object.leading_detached_comments !== null + ) { + for (const e of object.leading_detached_comments) { + message.leading_detached_comments.push(e); + } + } + return message; + }, +}; + +const baseGeneratedCodeInfo: object = {}; + +export const GeneratedCodeInfo = { + encode(message: GeneratedCodeInfo, writer: Writer = Writer.create()): Writer { + for (const v of message.annotation) { + GeneratedCodeInfo_Annotation.encode( + v!, + writer.uint32(10).fork() + ).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): GeneratedCodeInfo { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseGeneratedCodeInfo } as GeneratedCodeInfo; + message.annotation = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.annotation.push( + GeneratedCodeInfo_Annotation.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GeneratedCodeInfo { + const message = { ...baseGeneratedCodeInfo } as GeneratedCodeInfo; + message.annotation = []; + if (object.annotation !== undefined && object.annotation !== null) { + for (const e of object.annotation) { + message.annotation.push(GeneratedCodeInfo_Annotation.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: GeneratedCodeInfo): unknown { + const obj: any = {}; + if (message.annotation) { + obj.annotation = message.annotation.map((e) => + e ? GeneratedCodeInfo_Annotation.toJSON(e) : undefined + ); + } else { + obj.annotation = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): GeneratedCodeInfo { + const message = { ...baseGeneratedCodeInfo } as GeneratedCodeInfo; + message.annotation = []; + if (object.annotation !== undefined && object.annotation !== null) { + for (const e of object.annotation) { + message.annotation.push(GeneratedCodeInfo_Annotation.fromPartial(e)); + } + } + return message; + }, +}; + +const baseGeneratedCodeInfo_Annotation: object = { + path: 0, + source_file: "", + begin: 0, + end: 0, +}; + +export const GeneratedCodeInfo_Annotation = { + encode( + message: GeneratedCodeInfo_Annotation, + writer: Writer = Writer.create() + ): Writer { + writer.uint32(10).fork(); + for (const v of message.path) { + writer.int32(v); + } + writer.ldelim(); + if (message.source_file !== "") { + writer.uint32(18).string(message.source_file); + } + if (message.begin !== 0) { + writer.uint32(24).int32(message.begin); + } + if (message.end !== 0) { + writer.uint32(32).int32(message.end); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): GeneratedCodeInfo_Annotation { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseGeneratedCodeInfo_Annotation, + } as GeneratedCodeInfo_Annotation; + message.path = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.path.push(reader.int32()); + } + } else { + message.path.push(reader.int32()); + } + break; + case 2: + message.source_file = reader.string(); + break; + case 3: + message.begin = reader.int32(); + break; + case 4: + message.end = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GeneratedCodeInfo_Annotation { + const message = { + ...baseGeneratedCodeInfo_Annotation, + } as GeneratedCodeInfo_Annotation; + message.path = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(Number(e)); + } + } + if (object.source_file !== undefined && object.source_file !== null) { + message.source_file = String(object.source_file); + } else { + message.source_file = ""; + } + if (object.begin !== undefined && object.begin !== null) { + message.begin = Number(object.begin); + } else { + message.begin = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + return message; + }, + + toJSON(message: GeneratedCodeInfo_Annotation): unknown { + const obj: any = {}; + if (message.path) { + obj.path = message.path.map((e) => e); + } else { + obj.path = []; + } + message.source_file !== undefined && + (obj.source_file = message.source_file); + message.begin !== undefined && (obj.begin = message.begin); + message.end !== undefined && (obj.end = message.end); + return obj; + }, + + fromPartial( + object: DeepPartial + ): GeneratedCodeInfo_Annotation { + const message = { + ...baseGeneratedCodeInfo_Annotation, + } as GeneratedCodeInfo_Annotation; + message.path = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(e); + } + } + if (object.source_file !== undefined && object.source_file !== null) { + message.source_file = object.source_file; + } else { + message.source_file = ""; + } + if (object.begin !== undefined && object.begin !== null) { + message.begin = object.begin; + } else { + message.begin = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/vue/src/store/generated/bze-alphateam/bze/bzealphateam.bze.rewards/module/types/rewards/genesis.ts b/vue/src/store/generated/bze-alphateam/bze/bzealphateam.bze.rewards/module/types/rewards/genesis.ts new file mode 100644 index 00000000..659a7da9 --- /dev/null +++ b/vue/src/store/generated/bze-alphateam/bze/bzealphateam.bze.rewards/module/types/rewards/genesis.ts @@ -0,0 +1,78 @@ +/* eslint-disable */ +import { Params } from "../rewards/params"; +import { Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "bzealphateam.bze.rewards"; + +/** GenesisState defines the rewards module's genesis state. */ +export interface GenesisState { + /** this line is used by starport scaffolding # genesis/proto/state */ + params: Params | undefined; +} + +const baseGenesisState: object = {}; + +export const GenesisState = { + encode(message: GenesisState, writer: Writer = Writer.create()): Writer { + if (message.params !== undefined) { + Params.encode(message.params, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): GenesisState { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseGenesisState } as GenesisState; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.params = Params.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GenesisState { + const message = { ...baseGenesisState } as GenesisState; + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromJSON(object.params); + } else { + message.params = undefined; + } + return message; + }, + + toJSON(message: GenesisState): unknown { + const obj: any = {}; + message.params !== undefined && + (obj.params = message.params ? Params.toJSON(message.params) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): GenesisState { + const message = { ...baseGenesisState } as GenesisState; + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromPartial(object.params); + } else { + message.params = undefined; + } + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/vue/src/store/generated/bze-alphateam/bze/bzealphateam.bze.rewards/module/types/rewards/params.ts b/vue/src/store/generated/bze-alphateam/bze/bzealphateam.bze.rewards/module/types/rewards/params.ts new file mode 100644 index 00000000..1290c835 --- /dev/null +++ b/vue/src/store/generated/bze-alphateam/bze/bzealphateam.bze.rewards/module/types/rewards/params.ts @@ -0,0 +1,110 @@ +/* eslint-disable */ +import { Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "bzealphateam.bze.rewards"; + +/** Params defines the parameters for the module. */ +export interface Params { + createStakingRewardFee: string; + createTradingRewardFee: string; +} + +const baseParams: object = { + createStakingRewardFee: "", + createTradingRewardFee: "", +}; + +export const Params = { + encode(message: Params, writer: Writer = Writer.create()): Writer { + if (message.createStakingRewardFee !== "") { + writer.uint32(10).string(message.createStakingRewardFee); + } + if (message.createTradingRewardFee !== "") { + writer.uint32(18).string(message.createTradingRewardFee); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Params { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseParams } as Params; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.createStakingRewardFee = reader.string(); + break; + case 2: + message.createTradingRewardFee = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Params { + const message = { ...baseParams } as Params; + if ( + object.createStakingRewardFee !== undefined && + object.createStakingRewardFee !== null + ) { + message.createStakingRewardFee = String(object.createStakingRewardFee); + } else { + message.createStakingRewardFee = ""; + } + if ( + object.createTradingRewardFee !== undefined && + object.createTradingRewardFee !== null + ) { + message.createTradingRewardFee = String(object.createTradingRewardFee); + } else { + message.createTradingRewardFee = ""; + } + return message; + }, + + toJSON(message: Params): unknown { + const obj: any = {}; + message.createStakingRewardFee !== undefined && + (obj.createStakingRewardFee = message.createStakingRewardFee); + message.createTradingRewardFee !== undefined && + (obj.createTradingRewardFee = message.createTradingRewardFee); + return obj; + }, + + fromPartial(object: DeepPartial): Params { + const message = { ...baseParams } as Params; + if ( + object.createStakingRewardFee !== undefined && + object.createStakingRewardFee !== null + ) { + message.createStakingRewardFee = object.createStakingRewardFee; + } else { + message.createStakingRewardFee = ""; + } + if ( + object.createTradingRewardFee !== undefined && + object.createTradingRewardFee !== null + ) { + message.createTradingRewardFee = object.createTradingRewardFee; + } else { + message.createTradingRewardFee = ""; + } + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/vue/src/store/generated/bze-alphateam/bze/bzealphateam.bze.rewards/module/types/rewards/query.ts b/vue/src/store/generated/bze-alphateam/bze/bzealphateam.bze.rewards/module/types/rewards/query.ts new file mode 100644 index 00000000..41c9edf8 --- /dev/null +++ b/vue/src/store/generated/bze-alphateam/bze/bzealphateam.bze.rewards/module/types/rewards/query.ts @@ -0,0 +1,152 @@ +/* eslint-disable */ +import { Reader, Writer } from "protobufjs/minimal"; +import { Params } from "../rewards/params"; + +export const protobufPackage = "bzealphateam.bze.rewards"; + +/** QueryParamsRequest is request type for the Query/Params RPC method. */ +export interface QueryParamsRequest {} + +/** QueryParamsResponse is response type for the Query/Params RPC method. */ +export interface QueryParamsResponse { + /** params holds all the parameters of this module. */ + params: Params | undefined; +} + +const baseQueryParamsRequest: object = {}; + +export const QueryParamsRequest = { + encode(_: QueryParamsRequest, writer: Writer = Writer.create()): Writer { + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QueryParamsRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryParamsRequest } as QueryParamsRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): QueryParamsRequest { + const message = { ...baseQueryParamsRequest } as QueryParamsRequest; + return message; + }, + + toJSON(_: QueryParamsRequest): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial(_: DeepPartial): QueryParamsRequest { + const message = { ...baseQueryParamsRequest } as QueryParamsRequest; + return message; + }, +}; + +const baseQueryParamsResponse: object = {}; + +export const QueryParamsResponse = { + encode( + message: QueryParamsResponse, + writer: Writer = Writer.create() + ): Writer { + if (message.params !== undefined) { + Params.encode(message.params, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QueryParamsResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryParamsResponse } as QueryParamsResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.params = Params.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryParamsResponse { + const message = { ...baseQueryParamsResponse } as QueryParamsResponse; + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromJSON(object.params); + } else { + message.params = undefined; + } + return message; + }, + + toJSON(message: QueryParamsResponse): unknown { + const obj: any = {}; + message.params !== undefined && + (obj.params = message.params ? Params.toJSON(message.params) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): QueryParamsResponse { + const message = { ...baseQueryParamsResponse } as QueryParamsResponse; + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromPartial(object.params); + } else { + message.params = undefined; + } + return message; + }, +}; + +/** Query defines the gRPC querier service. */ +export interface Query { + /** Parameters queries the parameters of the module. */ + Params(request: QueryParamsRequest): Promise; +} + +export class QueryClientImpl implements Query { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + } + Params(request: QueryParamsRequest): Promise { + const data = QueryParamsRequest.encode(request).finish(); + const promise = this.rpc.request( + "bzealphateam.bze.rewards.Query", + "Params", + data + ); + return promise.then((data) => QueryParamsResponse.decode(new Reader(data))); + } +} + +interface Rpc { + request( + service: string, + method: string, + data: Uint8Array + ): Promise; +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/vue/src/store/generated/bze-alphateam/bze/bzealphateam.bze.rewards/module/types/rewards/tx.ts b/vue/src/store/generated/bze-alphateam/bze/bzealphateam.bze.rewards/module/types/rewards/tx.ts new file mode 100644 index 00000000..dbe94e7c --- /dev/null +++ b/vue/src/store/generated/bze-alphateam/bze/bzealphateam.bze.rewards/module/types/rewards/tx.ts @@ -0,0 +1,20 @@ +/* eslint-disable */ +export const protobufPackage = "bzealphateam.bze.rewards"; + +/** Msg defines the Msg service. */ +export interface Msg {} + +export class MsgClientImpl implements Msg { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + } +} + +interface Rpc { + request( + service: string, + method: string, + data: Uint8Array + ): Promise; +} diff --git a/vue/src/store/generated/bze-alphateam/bze/bzealphateam.bze.rewards/package.json b/vue/src/store/generated/bze-alphateam/bze/bzealphateam.bze.rewards/package.json new file mode 100755 index 00000000..e9610178 --- /dev/null +++ b/vue/src/store/generated/bze-alphateam/bze/bzealphateam.bze.rewards/package.json @@ -0,0 +1,18 @@ +{ + "name": "bzealphateam-bze-rewards-js", + "version": "0.1.0", + "description": "Autogenerated vuex store for Cosmos module bzealphateam.bze.rewards", + "author": "Starport Codegen ", + "homepage": "http://github.com/bze-alphateam/bze/x/rewards/types", + "license": "Apache-2.0", + "licenses": [ + { + "type": "Apache-2.0", + "url": "http://www.apache.org/licenses/LICENSE-2.0" + } + ], + "main": "index.js", + "publishConfig": { + "access": "public" + } +} \ No newline at end of file diff --git a/vue/src/store/generated/bze-alphateam/bze/bzealphateam.bze.rewards/vuex-root b/vue/src/store/generated/bze-alphateam/bze/bzealphateam.bze.rewards/vuex-root new file mode 100755 index 00000000..0fcc121a --- /dev/null +++ b/vue/src/store/generated/bze-alphateam/bze/bzealphateam.bze.rewards/vuex-root @@ -0,0 +1 @@ +THIS FILE IS GENERATED AUTOMATICALLY. DO NOT DELETE. diff --git a/vue/src/store/generated/index.ts b/vue/src/store/generated/index.ts index 00546619..44ca0f46 100755 --- a/vue/src/store/generated/index.ts +++ b/vue/src/store/generated/index.ts @@ -7,9 +7,11 @@ import BzeAlphateamBzeBzeEpochsV1 from './bze-alphateam/bze/bze.epochs.v1' import BzeAlphateamBzeBzeScavenge from './bze-alphateam/bze/bze.scavenge' import BzeAlphateamBzeBzeTokenfactoryV1 from './bze-alphateam/bze/bze.tokenfactory.v1' import BzeAlphateamBzeBzeTradebinV1 from './bze-alphateam/bze/bze.tradebin.v1' +import BzeAlphateamBzeBzeV1Rewards from './bze-alphateam/bze/bze.v1.rewards' import BzeAlphateamBzeBzealphateamBzeBurner from './bze-alphateam/bze/bzealphateam.bze.burner' import BzeAlphateamBzeBzealphateamBzeCointrunk from './bze-alphateam/bze/bzealphateam.bze.cointrunk' import BzeAlphateamBzeBzealphateamBzeEpochs from './bze-alphateam/bze/bzealphateam.bze.epochs' +import BzeAlphateamBzeBzealphateamBzeRewards from './bze-alphateam/bze/bzealphateam.bze.rewards' import BzeAlphateamBzeBzealphateamBzeTokenfactory from './bze-alphateam/bze/bzealphateam.bze.tokenfactory' import BzeAlphateamBzeBzealphateamBzeTradebin from './bze-alphateam/bze/bzealphateam.bze.tradebin' import CosmosCosmosSdkCosmosAuthzV1Beta1 from './cosmos/cosmos-sdk/cosmos.authz.v1beta1' @@ -33,9 +35,11 @@ export default { BzeAlphateamBzeBzeScavenge: load(BzeAlphateamBzeBzeScavenge, 'bze.scavenge'), BzeAlphateamBzeBzeTokenfactoryV1: load(BzeAlphateamBzeBzeTokenfactoryV1, 'bze.tokenfactory.v1'), BzeAlphateamBzeBzeTradebinV1: load(BzeAlphateamBzeBzeTradebinV1, 'bze.tradebin.v1'), + BzeAlphateamBzeBzeV1Rewards: load(BzeAlphateamBzeBzeV1Rewards, 'bze.v1.rewards'), BzeAlphateamBzeBzealphateamBzeBurner: load(BzeAlphateamBzeBzealphateamBzeBurner, 'bzealphateam.bze.burner'), BzeAlphateamBzeBzealphateamBzeCointrunk: load(BzeAlphateamBzeBzealphateamBzeCointrunk, 'bzealphateam.bze.cointrunk'), BzeAlphateamBzeBzealphateamBzeEpochs: load(BzeAlphateamBzeBzealphateamBzeEpochs, 'bzealphateam.bze.epochs'), + BzeAlphateamBzeBzealphateamBzeRewards: load(BzeAlphateamBzeBzealphateamBzeRewards, 'bzealphateam.bze.rewards'), BzeAlphateamBzeBzealphateamBzeTokenfactory: load(BzeAlphateamBzeBzealphateamBzeTokenfactory, 'bzealphateam.bze.tokenfactory'), BzeAlphateamBzeBzealphateamBzeTradebin: load(BzeAlphateamBzeBzealphateamBzeTradebin, 'bzealphateam.bze.tradebin'), CosmosCosmosSdkCosmosAuthzV1Beta1: load(CosmosCosmosSdkCosmosAuthzV1Beta1, 'cosmos.authz.v1beta1'), diff --git a/x/rewards/client/cli/query.go b/x/rewards/client/cli/query.go new file mode 100644 index 00000000..17de0956 --- /dev/null +++ b/x/rewards/client/cli/query.go @@ -0,0 +1,31 @@ +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/bze-alphateam/bze/x/rewards/types" +) + +// GetQueryCmd returns the cli query commands for this module +func GetQueryCmd(queryRoute string) *cobra.Command { + // Group rewards 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/rewards/client/cli/query_params.go b/x/rewards/client/cli/query_params.go new file mode 100644 index 00000000..21861b76 --- /dev/null +++ b/x/rewards/client/cli/query_params.go @@ -0,0 +1,34 @@ +package cli + +import ( + "context" + + "github.com/bze-alphateam/bze/x/rewards/types" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/spf13/cobra" +) + +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/rewards/client/cli/tx.go b/x/rewards/client/cli/tx.go new file mode 100644 index 00000000..14b420bb --- /dev/null +++ b/x/rewards/client/cli/tx.go @@ -0,0 +1,36 @@ +package cli + +import ( + "fmt" + "time" + + "github.com/spf13/cobra" + + "github.com/cosmos/cosmos-sdk/client" + // "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/bze-alphateam/bze/x/rewards/types" +) + +var ( + DefaultRelativePacketTimeoutTimestamp = uint64((time.Duration(10) * time.Minute).Nanoseconds()) +) + +const ( + flagPacketTimeoutTimestamp = "packet-timeout-timestamp" + listSeparator = "," +) + +// 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/rewards/genesis.go b/x/rewards/genesis.go new file mode 100644 index 00000000..9aeb823a --- /dev/null +++ b/x/rewards/genesis.go @@ -0,0 +1,24 @@ +package rewards + +import ( + "github.com/bze-alphateam/bze/x/rewards/keeper" + "github.com/bze-alphateam/bze/x/rewards/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// InitGenesis initializes the capability 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 capability 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/rewards/genesis_test.go b/x/rewards/genesis_test.go new file mode 100644 index 00000000..f360aff3 --- /dev/null +++ b/x/rewards/genesis_test.go @@ -0,0 +1,29 @@ +package rewards_test + +import ( + "testing" + + keepertest "github.com/bze-alphateam/bze/testutil/keeper" + "github.com/bze-alphateam/bze/testutil/nullify" + "github.com/bze-alphateam/bze/x/rewards" + "github.com/bze-alphateam/bze/x/rewards/types" + "github.com/stretchr/testify/require" +) + +func TestGenesis(t *testing.T) { + genesisState := types.GenesisState{ + Params: types.DefaultParams(), + + // this line is used by starport scaffolding # genesis/test/state + } + + k, ctx := keepertest.RewardsKeeper(t) + rewards.InitGenesis(ctx, *k, genesisState) + got := rewards.ExportGenesis(ctx, *k) + require.NotNil(t, got) + + nullify.Fill(&genesisState) + nullify.Fill(got) + + // this line is used by starport scaffolding # genesis/test/assert +} diff --git a/x/rewards/handler.go b/x/rewards/handler.go new file mode 100644 index 00000000..ee1a6c39 --- /dev/null +++ b/x/rewards/handler.go @@ -0,0 +1,26 @@ +package rewards + +import ( + "fmt" + + "github.com/bze-alphateam/bze/x/rewards/keeper" + "github.com/bze-alphateam/bze/x/rewards/types" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +// NewHandler ... +func NewHandler(k keeper.Keeper) sdk.Handler { + // this line is used by starport scaffolding # handler/msgServer + + return func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) { + ctx = ctx.WithEventManager(sdk.NewEventManager()) + + switch msg := msg.(type) { + // this line is used by starport scaffolding # 1 + default: + errMsg := fmt.Sprintf("unrecognized %s message type: %T", types.ModuleName, msg) + return nil, sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, errMsg) + } + } +} diff --git a/x/rewards/keeper/grpc_query.go b/x/rewards/keeper/grpc_query.go new file mode 100644 index 00000000..a05704b0 --- /dev/null +++ b/x/rewards/keeper/grpc_query.go @@ -0,0 +1,7 @@ +package keeper + +import ( + "github.com/bze-alphateam/bze/x/rewards/types" +) + +var _ types.QueryServer = Keeper{} diff --git a/x/rewards/keeper/grpc_query_params.go b/x/rewards/keeper/grpc_query_params.go new file mode 100644 index 00000000..0ee68a18 --- /dev/null +++ b/x/rewards/keeper/grpc_query_params.go @@ -0,0 +1,19 @@ +package keeper + +import ( + "context" + + "github.com/bze-alphateam/bze/x/rewards/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +func (k Keeper) Params(c context.Context, req *types.QueryParamsRequest) (*types.QueryParamsResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + ctx := sdk.UnwrapSDKContext(c) + + return &types.QueryParamsResponse{Params: k.GetParams(ctx)}, nil +} diff --git a/x/rewards/keeper/grpc_query_params_test.go b/x/rewards/keeper/grpc_query_params_test.go new file mode 100644 index 00000000..ed10f4e8 --- /dev/null +++ b/x/rewards/keeper/grpc_query_params_test.go @@ -0,0 +1,21 @@ +package keeper_test + +import ( + "testing" + + testkeeper "github.com/bze-alphateam/bze/testutil/keeper" + "github.com/bze-alphateam/bze/x/rewards/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" +) + +func TestParamsQuery(t *testing.T) { + keeper, ctx := testkeeper.RewardsKeeper(t) + wctx := sdk.WrapSDKContext(ctx) + params := types.DefaultParams() + keeper.SetParams(ctx, params) + + response, err := keeper.Params(wctx, &types.QueryParamsRequest{}) + require.NoError(t, err) + require.Equal(t, &types.QueryParamsResponse{Params: params}, response) +} diff --git a/x/rewards/keeper/keeper.go b/x/rewards/keeper/keeper.go new file mode 100644 index 00000000..30343699 --- /dev/null +++ b/x/rewards/keeper/keeper.go @@ -0,0 +1,51 @@ +package keeper + +import ( + "fmt" + + "github.com/tendermint/tendermint/libs/log" + + "github.com/bze-alphateam/bze/x/rewards/types" + "github.com/cosmos/cosmos-sdk/codec" + sdk "github.com/cosmos/cosmos-sdk/types" + paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" +) + +type ( + Keeper struct { + cdc codec.BinaryCodec + storeKey sdk.StoreKey + memKey sdk.StoreKey + paramstore paramtypes.Subspace + + bankKeeper types.BankKeeper + distrKeeper types.DistrKeeper + } +) + +func NewKeeper( + cdc codec.BinaryCodec, + storeKey, + memKey sdk.StoreKey, + ps paramtypes.Subspace, + + bankKeeper types.BankKeeper, distrKeeper types.DistrKeeper, +) *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, + bankKeeper: bankKeeper, distrKeeper: distrKeeper, + } +} + +func (k Keeper) Logger(ctx sdk.Context) log.Logger { + return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName)) +} diff --git a/x/rewards/keeper/msg_server.go b/x/rewards/keeper/msg_server.go new file mode 100644 index 00000000..177ad542 --- /dev/null +++ b/x/rewards/keeper/msg_server.go @@ -0,0 +1,17 @@ +package keeper + +import ( + "github.com/bze-alphateam/bze/x/rewards/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/rewards/keeper/msg_server_test.go b/x/rewards/keeper/msg_server_test.go new file mode 100644 index 00000000..cfb4eb52 --- /dev/null +++ b/x/rewards/keeper/msg_server_test.go @@ -0,0 +1,16 @@ +package keeper_test + +import ( + "context" + "testing" + + keepertest "github.com/bze-alphateam/bze/testutil/keeper" + "github.com/bze-alphateam/bze/x/rewards/keeper" + "github.com/bze-alphateam/bze/x/rewards/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +func setupMsgServer(t testing.TB) (types.MsgServer, context.Context) { + k, ctx := keepertest.RewardsKeeper(t) + return keeper.NewMsgServerImpl(*k), sdk.WrapSDKContext(ctx) +} diff --git a/x/rewards/keeper/params.go b/x/rewards/keeper/params.go new file mode 100644 index 00000000..93c79108 --- /dev/null +++ b/x/rewards/keeper/params.go @@ -0,0 +1,31 @@ +package keeper + +import ( + "github.com/bze-alphateam/bze/x/rewards/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// GetParams get all parameters as types.Params +func (k Keeper) GetParams(ctx sdk.Context) types.Params { + return types.NewParams( + k.CreateStakingRewardFee(ctx), + k.CreateTradingRewardFee(ctx), + ) +} + +// SetParams set the params +func (k Keeper) SetParams(ctx sdk.Context, params types.Params) { + k.paramstore.SetParamSet(ctx, ¶ms) +} + +// CreateStakingRewardFee returns the CreateStakingRewardFee param +func (k Keeper) CreateStakingRewardFee(ctx sdk.Context) (res string) { + k.paramstore.Get(ctx, types.KeyCreateStakingRewardFee, &res) + return +} + +// CreateTradingRewardFee returns the CreateTradingRewardFee param +func (k Keeper) CreateTradingRewardFee(ctx sdk.Context) (res string) { + k.paramstore.Get(ctx, types.KeyCreateTradingRewardFee, &res) + return +} diff --git a/x/rewards/keeper/params_test.go b/x/rewards/keeper/params_test.go new file mode 100644 index 00000000..593375bb --- /dev/null +++ b/x/rewards/keeper/params_test.go @@ -0,0 +1,20 @@ +package keeper_test + +import ( + "testing" + + testkeeper "github.com/bze-alphateam/bze/testutil/keeper" + "github.com/bze-alphateam/bze/x/rewards/types" + "github.com/stretchr/testify/require" +) + +func TestGetParams(t *testing.T) { + k, ctx := testkeeper.RewardsKeeper(t) + params := types.DefaultParams() + + k.SetParams(ctx, params) + + require.EqualValues(t, params, k.GetParams(ctx)) + require.EqualValues(t, params.CreateStakingRewardFee, k.CreateStakingRewardFee(ctx)) + require.EqualValues(t, params.CreateTradingRewardFee, k.CreateTradingRewardFee(ctx)) +} diff --git a/x/rewards/module.go b/x/rewards/module.go new file mode 100644 index 00000000..bbcb1be0 --- /dev/null +++ b/x/rewards/module.go @@ -0,0 +1,177 @@ +package rewards + +import ( + "context" + "encoding/json" + "fmt" + // this line is used by starport scaffolding # 1 + + "github.com/gorilla/mux" + "github.com/grpc-ecosystem/grpc-gateway/runtime" + "github.com/spf13/cobra" + + abci "github.com/tendermint/tendermint/abci/types" + + "github.com/bze-alphateam/bze/x/rewards/client/cli" + "github.com/bze-alphateam/bze/x/rewards/keeper" + "github.com/bze-alphateam/bze/x/rewards/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" +) + +var ( + _ module.AppModule = AppModule{} + _ module.AppModuleBasic = AppModuleBasic{} +) + +// ---------------------------------------------------------------------------- +// AppModuleBasic +// ---------------------------------------------------------------------------- + +// AppModuleBasic implements the AppModuleBasic interface for the capability module. +type AppModuleBasic struct { + cdc codec.BinaryCodec +} + +func NewAppModuleBasic(cdc codec.BinaryCodec) AppModuleBasic { + return AppModuleBasic{cdc: cdc} +} + +// Name returns the capability module's name. +func (AppModuleBasic) Name() string { + return types.ModuleName +} + +func (AppModuleBasic) RegisterCodec(cdc *codec.LegacyAmino) { + types.RegisterCodec(cdc) +} + +func (AppModuleBasic) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino) { + types.RegisterCodec(cdc) +} + +// RegisterInterfaces registers the module's interface types +func (a AppModuleBasic) RegisterInterfaces(reg cdctypes.InterfaceRegistry) { + types.RegisterInterfaces(reg) +} + +// DefaultGenesis returns the capability module's default genesis state. +func (AppModuleBasic) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage { + return cdc.MustMarshalJSON(types.DefaultGenesis()) +} + +// ValidateGenesis performs genesis state validation for the capability module. +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() +} + +// RegisterRESTRoutes registers the capability module's REST service handlers. +func (AppModuleBasic) RegisterRESTRoutes(clientCtx client.Context, rtr *mux.Router) { +} + +// 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)) + // this line is used by starport scaffolding # 2 +} + +// GetTxCmd returns the capability module's root tx command. +func (a AppModuleBasic) GetTxCmd() *cobra.Command { + return cli.GetTxCmd() +} + +// GetQueryCmd returns the capability module's root query command. +func (AppModuleBasic) GetQueryCmd() *cobra.Command { + return cli.GetQueryCmd(types.StoreKey) +} + +// ---------------------------------------------------------------------------- +// AppModule +// ---------------------------------------------------------------------------- + +// AppModule implements the AppModule interface for the capability module. +type AppModule struct { + AppModuleBasic + + keeper keeper.Keeper + accountKeeper types.AccountKeeper + bankKeeper types.BankKeeper +} + +func NewAppModule( + cdc codec.Codec, + keeper keeper.Keeper, + accountKeeper types.AccountKeeper, + bankKeeper types.BankKeeper, +) AppModule { + return AppModule{ + AppModuleBasic: NewAppModuleBasic(cdc), + keeper: keeper, + accountKeeper: accountKeeper, + bankKeeper: bankKeeper, + } +} + +// Name returns the capability module's name. +func (am AppModule) Name() string { + return am.AppModuleBasic.Name() +} + +// Route returns the capability module's message routing key. +func (am AppModule) Route() sdk.Route { + return sdk.NewRoute(types.RouterKey, NewHandler(am.keeper)) +} + +// QuerierRoute returns the capability module's query routing key. +func (AppModule) QuerierRoute() string { return types.QuerierRoute } + +// LegacyQuerierHandler returns the capability module's Querier. +func (am AppModule) LegacyQuerierHandler(legacyQuerierCdc *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.RegisterQueryServer(cfg.QueryServer(), am.keeper) +} + +// RegisterInvariants registers the capability module's invariants. +func (am AppModule) RegisterInvariants(_ sdk.InvariantRegistry) {} + +// InitGenesis performs the capability 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 capability 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 implements ConsensusVersion. +func (AppModule) ConsensusVersion() uint64 { return 2 } + +// BeginBlock executes all ABCI BeginBlock logic respective to the capability module. +func (am AppModule) BeginBlock(_ sdk.Context, _ abci.RequestBeginBlock) {} + +// EndBlock executes all ABCI EndBlock logic respective to the capability module. It +// returns no validator updates. +func (am AppModule) EndBlock(_ sdk.Context, _ abci.RequestEndBlock) []abci.ValidatorUpdate { + return []abci.ValidatorUpdate{} +} diff --git a/x/rewards/module_simulation.go b/x/rewards/module_simulation.go new file mode 100644 index 00000000..391463e9 --- /dev/null +++ b/x/rewards/module_simulation.go @@ -0,0 +1,71 @@ +package rewards + +import ( + "math/rand" + + "github.com/bze-alphateam/bze/testutil/sample" + rewardssimulation "github.com/bze-alphateam/bze/x/rewards/simulation" + "github.com/bze-alphateam/bze/x/rewards/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 + _ = rewardssimulation.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() + } + rewardsGenesis := types.GenesisState{ + Params: types.DefaultParams(), + // this line is used by starport scaffolding # simapp/module/genesisState + } + simState.GenState[types.ModuleName] = simState.Cdc.MustMarshalJSON(&rewardsGenesis) +} + +// 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 { + rewardsParams := types.DefaultParams() + return []simtypes.ParamChange{ + simulation.NewSimParamChange(types.ModuleName, string(types.KeyCreateStakingRewardFee), func(r *rand.Rand) string { + return string(types.Amino.MustMarshalJSON(rewardsParams.CreateStakingRewardFee)) + }), + simulation.NewSimParamChange(types.ModuleName, string(types.KeyCreateTradingRewardFee), func(r *rand.Rand) string { + return string(types.Amino.MustMarshalJSON(rewardsParams.CreateTradingRewardFee)) + }), + } +} + +// 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/rewards/simulation/simap.go b/x/rewards/simulation/simap.go new file mode 100644 index 00000000..92c437c0 --- /dev/null +++ b/x/rewards/simulation/simap.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/rewards/types/codec.go b/x/rewards/types/codec.go new file mode 100644 index 00000000..844157a8 --- /dev/null +++ b/x/rewards/types/codec.go @@ -0,0 +1,23 @@ +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 ( + Amino = codec.NewLegacyAmino() + ModuleCdc = codec.NewProtoCodec(cdctypes.NewInterfaceRegistry()) +) diff --git a/x/rewards/types/errors.go b/x/rewards/types/errors.go new file mode 100644 index 00000000..6933be85 --- /dev/null +++ b/x/rewards/types/errors.go @@ -0,0 +1,12 @@ +package types + +// DONTCOVER + +import ( + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +// x/rewards module sentinel errors +var ( + ErrSample = sdkerrors.Register(ModuleName, 1100, "sample error") +) diff --git a/x/rewards/types/expected_keepers.go b/x/rewards/types/expected_keepers.go new file mode 100644 index 00000000..d3f91662 --- /dev/null +++ b/x/rewards/types/expected_keepers.go @@ -0,0 +1,22 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/x/auth/types" +) + +type DistrKeeper interface { + // Methods imported from distr should be defined here +} + +// AccountKeeper defines the expected account keeper used for simulations (noalias) +type AccountKeeper interface { + GetAccount(ctx sdk.Context, addr sdk.AccAddress) types.AccountI + // Methods imported from account should be defined here +} + +// BankKeeper defines the expected interface needed to retrieve account balances. +type BankKeeper interface { + SpendableCoins(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins + // Methods imported from bank should be defined here +} diff --git a/x/rewards/types/genesis.go b/x/rewards/types/genesis.go new file mode 100644 index 00000000..56921182 --- /dev/null +++ b/x/rewards/types/genesis.go @@ -0,0 +1,20 @@ +package types + +// DefaultIndex is the default capability global index +const DefaultIndex uint64 = 1 + +// DefaultGenesis returns the default Capability 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/rewards/types/genesis.pb.go b/x/rewards/types/genesis.pb.go new file mode 100644 index 00000000..90647d22 --- /dev/null +++ b/x/rewards/types/genesis.pb.go @@ -0,0 +1,321 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: rewards/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 rewards 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_04e261dd19d07881, []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), "bze.v1.rewards.GenesisState") +} + +func init() { proto.RegisterFile("rewards/genesis.proto", fileDescriptor_04e261dd19d07881) } + +var fileDescriptor_04e261dd19d07881 = []byte{ + // 194 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x2d, 0x4a, 0x2d, 0x4f, + 0x2c, 0x4a, 0x29, 0xd6, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, + 0xc9, 0x17, 0xe2, 0x4b, 0xaa, 0x4a, 0xd5, 0x2b, 0x33, 0xd4, 0x83, 0xca, 0x4a, 0x89, 0xa4, 0xe7, + 0xa7, 0xe7, 0x83, 0xa5, 0xf4, 0x41, 0x2c, 0x88, 0x2a, 0x29, 0x11, 0x98, 0xe6, 0x82, 0xc4, 0xa2, + 0xc4, 0x5c, 0xa8, 0x5e, 0x25, 0x17, 0x2e, 0x1e, 0x77, 0x88, 0x61, 0xc1, 0x25, 0x89, 0x25, 0xa9, + 0x42, 0x26, 0x5c, 0x6c, 0x10, 0x79, 0x09, 0x46, 0x05, 0x46, 0x0d, 0x6e, 0x23, 0x31, 0x3d, 0x54, + 0xc3, 0xf5, 0x02, 0xc0, 0xb2, 0x4e, 0x2c, 0x27, 0xee, 0xc9, 0x33, 0x04, 0x41, 0xd5, 0x3a, 0xb9, + 0x9d, 0x78, 0x24, 0xc7, 0x78, 0xe1, 0x91, 0x1c, 0xe3, 0x83, 0x47, 0x72, 0x8c, 0x13, 0x1e, 0xcb, + 0x31, 0x5c, 0x78, 0x2c, 0xc7, 0x70, 0xe3, 0xb1, 0x1c, 0x43, 0x94, 0x4e, 0x7a, 0x66, 0x49, 0x46, + 0x69, 0x92, 0x5e, 0x72, 0x7e, 0xae, 0x7e, 0x52, 0x55, 0xaa, 0x6e, 0x62, 0x4e, 0x41, 0x46, 0x62, + 0x49, 0x6a, 0x22, 0x98, 0xa7, 0x5f, 0xa1, 0x0f, 0x73, 0x54, 0x49, 0x65, 0x41, 0x6a, 0x71, 0x12, + 0x1b, 0xd8, 0x51, 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0xbc, 0x2b, 0x3c, 0x82, 0xe9, 0x00, + 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/rewards/types/genesis_test.go b/x/rewards/types/genesis_test.go new file mode 100644 index 00000000..1ad2960b --- /dev/null +++ b/x/rewards/types/genesis_test.go @@ -0,0 +1,40 @@ +package types_test + +import ( + "testing" + + "github.com/bze-alphateam/bze/x/rewards/types" + "github.com/stretchr/testify/require" +) + +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) + } + }) + } +} diff --git a/x/rewards/types/keys.go b/x/rewards/types/keys.go new file mode 100644 index 00000000..27a725bc --- /dev/null +++ b/x/rewards/types/keys.go @@ -0,0 +1,22 @@ +package types + +const ( + // ModuleName defines the module name + ModuleName = "rewards" + + // StoreKey defines the primary module store key + StoreKey = ModuleName + + // RouterKey is the message route for slashing + RouterKey = ModuleName + + // QuerierRoute defines the module's query routing key + QuerierRoute = ModuleName + + // MemStoreKey defines the in-memory store key + MemStoreKey = "mem_rewards" +) + +func KeyPrefix(p string) []byte { + return []byte(p) +} diff --git a/x/rewards/types/params.go b/x/rewards/types/params.go new file mode 100644 index 00000000..ff0a854b --- /dev/null +++ b/x/rewards/types/params.go @@ -0,0 +1,97 @@ +package types + +import ( + "fmt" + + paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" + "gopkg.in/yaml.v2" +) + +var _ paramtypes.ParamSet = (*Params)(nil) + +var ( + KeyCreateStakingRewardFee = []byte("CreateStakingRewardFee") + DefaultCreateStakingRewardFee = "10000000000ubze" +) + +var ( + KeyCreateTradingRewardFee = []byte("CreateTradingRewardFee") + DefaultCreateTradingRewardFee = "10000000000ubze" +) + +// 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( + createStakingRewardFee string, + createTradingRewardFee string, +) Params { + return Params{ + CreateStakingRewardFee: createStakingRewardFee, + CreateTradingRewardFee: createTradingRewardFee, + } +} + +// DefaultParams returns a default set of parameters +func DefaultParams() Params { + return NewParams( + DefaultCreateStakingRewardFee, + DefaultCreateTradingRewardFee, + ) +} + +// ParamSetPairs get the params.ParamSet +func (p *Params) ParamSetPairs() paramtypes.ParamSetPairs { + return paramtypes.ParamSetPairs{ + paramtypes.NewParamSetPair(KeyCreateStakingRewardFee, &p.CreateStakingRewardFee, validateCreateStakingRewardFee), + paramtypes.NewParamSetPair(KeyCreateTradingRewardFee, &p.CreateTradingRewardFee, validateCreateTradingRewardFee), + } +} + +// Validate validates the set of params +func (p Params) Validate() error { + if err := validateCreateStakingRewardFee(p.CreateStakingRewardFee); err != nil { + return err + } + + if err := validateCreateTradingRewardFee(p.CreateTradingRewardFee); err != nil { + return err + } + + return nil +} + +// String implements the Stringer interface. +func (p Params) String() string { + out, _ := yaml.Marshal(p) + return string(out) +} + +// validateCreateStakingRewardFee validates the CreateStakingRewardFee param +func validateCreateStakingRewardFee(v interface{}) error { + createStakingRewardFee, ok := v.(string) + if !ok { + return fmt.Errorf("invalid parameter type: %T", v) + } + + // TODO implement validation + _ = createStakingRewardFee + + return nil +} + +// validateCreateTradingRewardFee validates the CreateTradingRewardFee param +func validateCreateTradingRewardFee(v interface{}) error { + createTradingRewardFee, ok := v.(string) + if !ok { + return fmt.Errorf("invalid parameter type: %T", v) + } + + // TODO implement validation + _ = createTradingRewardFee + + return nil +} diff --git a/x/rewards/types/params.pb.go b/x/rewards/types/params.pb.go new file mode 100644 index 00000000..daa8e660 --- /dev/null +++ b/x/rewards/types/params.pb.go @@ -0,0 +1,371 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: rewards/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 { + CreateStakingRewardFee string `protobuf:"bytes,1,opt,name=createStakingRewardFee,proto3" json:"createStakingRewardFee,omitempty" yaml:"create_staking_reward_fee"` + CreateTradingRewardFee string `protobuf:"bytes,2,opt,name=createTradingRewardFee,proto3" json:"createTradingRewardFee,omitempty" yaml:"create_trading_reward_fee"` +} + +func (m *Params) Reset() { *m = Params{} } +func (*Params) ProtoMessage() {} +func (*Params) Descriptor() ([]byte, []int) { + return fileDescriptor_d4f6e2be212d3b23, []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) GetCreateStakingRewardFee() string { + if m != nil { + return m.CreateStakingRewardFee + } + return "" +} + +func (m *Params) GetCreateTradingRewardFee() string { + if m != nil { + return m.CreateTradingRewardFee + } + return "" +} + +func init() { + proto.RegisterType((*Params)(nil), "bze.v1.rewards.Params") +} + +func init() { proto.RegisterFile("rewards/params.proto", fileDescriptor_d4f6e2be212d3b23) } + +var fileDescriptor_d4f6e2be212d3b23 = []byte{ + // 232 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x29, 0x4a, 0x2d, 0x4f, + 0x2c, 0x4a, 0x29, 0xd6, 0x2f, 0x48, 0x2c, 0x4a, 0xcc, 0x2d, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, + 0x17, 0xe2, 0x4b, 0xaa, 0x4a, 0xd5, 0x2b, 0x33, 0xd4, 0x83, 0x4a, 0x4a, 0x89, 0xa4, 0xe7, 0xa7, + 0xe7, 0x83, 0xa5, 0xf4, 0x41, 0x2c, 0x88, 0x2a, 0xa5, 0x53, 0x8c, 0x5c, 0x6c, 0x01, 0x60, 0x6d, + 0x42, 0x31, 0x5c, 0x62, 0xc9, 0x45, 0xa9, 0x89, 0x25, 0xa9, 0xc1, 0x25, 0x89, 0xd9, 0x99, 0x79, + 0xe9, 0x41, 0x60, 0x8d, 0x6e, 0xa9, 0xa9, 0x12, 0x8c, 0x0a, 0x8c, 0x1a, 0x9c, 0x4e, 0x2a, 0x9f, + 0xee, 0xc9, 0x2b, 0x54, 0x26, 0xe6, 0xe6, 0x58, 0x29, 0x41, 0xd4, 0xc5, 0x17, 0x43, 0x14, 0xc6, + 0x43, 0xac, 0x88, 0x4f, 0x4b, 0x4d, 0x55, 0x0a, 0xc2, 0x61, 0x06, 0xc2, 0xf4, 0x90, 0xa2, 0xc4, + 0x14, 0x14, 0xd3, 0x99, 0x70, 0x98, 0x5e, 0x02, 0x51, 0x88, 0xcd, 0x74, 0x74, 0x33, 0xac, 0x58, + 0x66, 0x2c, 0x90, 0x67, 0x70, 0x72, 0x3b, 0xf1, 0x48, 0x8e, 0xf1, 0xc2, 0x23, 0x39, 0xc6, 0x07, + 0x8f, 0xe4, 0x18, 0x27, 0x3c, 0x96, 0x63, 0xb8, 0xf0, 0x58, 0x8e, 0xe1, 0xc6, 0x63, 0x39, 0x86, + 0x28, 0x9d, 0xf4, 0xcc, 0x92, 0x8c, 0xd2, 0x24, 0xbd, 0xe4, 0xfc, 0x5c, 0xfd, 0xa4, 0xaa, 0x54, + 0xdd, 0xc4, 0x9c, 0x82, 0x8c, 0xc4, 0x92, 0xd4, 0x44, 0x30, 0x4f, 0xbf, 0x42, 0x1f, 0x16, 0x82, + 0x25, 0x95, 0x05, 0xa9, 0xc5, 0x49, 0x6c, 0xe0, 0xb0, 0x31, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, + 0x73, 0x59, 0x23, 0x96, 0x59, 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 len(m.CreateTradingRewardFee) > 0 { + i -= len(m.CreateTradingRewardFee) + copy(dAtA[i:], m.CreateTradingRewardFee) + i = encodeVarintParams(dAtA, i, uint64(len(m.CreateTradingRewardFee))) + i-- + dAtA[i] = 0x12 + } + if len(m.CreateStakingRewardFee) > 0 { + i -= len(m.CreateStakingRewardFee) + copy(dAtA[i:], m.CreateStakingRewardFee) + i = encodeVarintParams(dAtA, i, uint64(len(m.CreateStakingRewardFee))) + 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.CreateStakingRewardFee) + if l > 0 { + n += 1 + l + sovParams(uint64(l)) + } + l = len(m.CreateTradingRewardFee) + if l > 0 { + n += 1 + l + sovParams(uint64(l)) + } + 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 CreateStakingRewardFee", 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.CreateStakingRewardFee = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field CreateTradingRewardFee", 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.CreateTradingRewardFee = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + 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/rewards/types/query.pb.go b/x/rewards/types/query.pb.go new file mode 100644 index 00000000..ff5d9a1e --- /dev/null +++ b/x/rewards/types/query.pb.go @@ -0,0 +1,538 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: rewards/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_5ddc078ee02fb5e8, []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_5ddc078ee02fb5e8, []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), "bze.v1.rewards.QueryParamsRequest") + proto.RegisterType((*QueryParamsResponse)(nil), "bze.v1.rewards.QueryParamsResponse") +} + +func init() { proto.RegisterFile("rewards/query.proto", fileDescriptor_5ddc078ee02fb5e8) } + +var fileDescriptor_5ddc078ee02fb5e8 = []byte{ + // 306 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x90, 0xb1, 0x4a, 0x03, 0x41, + 0x18, 0x84, 0xef, 0x44, 0x53, 0x9c, 0x60, 0x71, 0x09, 0x21, 0x04, 0x59, 0xe5, 0x6c, 0x44, 0xf4, + 0x96, 0x8b, 0x3e, 0x41, 0x0a, 0x1b, 0x1b, 0x4d, 0x69, 0xf7, 0x6f, 0xfc, 0xd9, 0x1c, 0x24, 0xf7, + 0x6f, 0x6e, 0x37, 0xd1, 0xa4, 0xf4, 0x09, 0x04, 0x5f, 0x2a, 0x65, 0xc0, 0xc6, 0x4a, 0x24, 0xf1, + 0x41, 0xe4, 0x76, 0x37, 0x42, 0x14, 0xec, 0xee, 0xfe, 0xf9, 0x66, 0x98, 0xd9, 0xa8, 0x5e, 0xe2, + 0x23, 0x94, 0x0f, 0x9a, 0x8f, 0x27, 0x58, 0xce, 0x52, 0x55, 0x92, 0xa1, 0xf8, 0x40, 0xcc, 0x31, + 0x9d, 0x66, 0xa9, 0xd7, 0xda, 0x0d, 0x49, 0x92, 0xac, 0xc4, 0xab, 0x2f, 0x47, 0xb5, 0x0f, 0x25, + 0x91, 0x1c, 0x22, 0x07, 0x95, 0x73, 0x28, 0x0a, 0x32, 0x60, 0x72, 0x2a, 0xb4, 0x57, 0xcf, 0xfa, + 0xa4, 0x47, 0xa4, 0xb9, 0x00, 0x8d, 0x2e, 0x9c, 0x4f, 0x33, 0x81, 0x06, 0x32, 0xae, 0x40, 0xe6, + 0x85, 0x85, 0x3d, 0xdb, 0xd8, 0x94, 0x50, 0x50, 0xc2, 0xc8, 0x27, 0x24, 0x8d, 0x28, 0xbe, 0xab, + 0x7c, 0xb7, 0xf6, 0xd8, 0xc3, 0xf1, 0x04, 0xb5, 0x49, 0x6e, 0xa2, 0xfa, 0xd6, 0x55, 0x2b, 0x2a, + 0x34, 0xc6, 0x57, 0x51, 0xcd, 0x99, 0x5b, 0xe1, 0x71, 0x78, 0xba, 0xdf, 0x69, 0xa6, 0xdb, 0x1b, + 0x52, 0xc7, 0x77, 0x77, 0x17, 0x1f, 0x47, 0x41, 0xcf, 0xb3, 0x9d, 0x79, 0xb4, 0x67, 0xc3, 0xe2, + 0x71, 0x54, 0x73, 0x40, 0x9c, 0xfc, 0x36, 0xfe, 0xed, 0xd0, 0x3e, 0xf9, 0x97, 0x71, 0x8d, 0x12, + 0xf6, 0xfc, 0xf6, 0xf5, 0xba, 0xd3, 0x8a, 0x9b, 0x5c, 0xcc, 0x91, 0x6f, 0x16, 0x4e, 0x33, 0x3f, + 0xb2, 0x7b, 0xbd, 0x58, 0xb1, 0x70, 0xb9, 0x62, 0xe1, 0xe7, 0x8a, 0x85, 0x2f, 0x6b, 0x16, 0x2c, + 0xd7, 0x2c, 0x78, 0x5f, 0xb3, 0xe0, 0xfe, 0x5c, 0xe6, 0x66, 0x30, 0x11, 0x69, 0x9f, 0x46, 0x95, + 0xf7, 0x02, 0x86, 0x6a, 0x00, 0x06, 0xc1, 0xfe, 0xf1, 0xa7, 0x9f, 0x2c, 0x33, 0x53, 0xa8, 0x45, + 0xcd, 0xbe, 0xd6, 0xe5, 0x77, 0x00, 0x00, 0x00, 0xff, 0xff, 0xf1, 0x02, 0xea, 0x3e, 0xca, 0x01, + 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, "/bze.v1.rewards.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: "/bze.v1.rewards.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: "bze.v1.rewards.Query", + HandlerType: (*QueryServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "Params", + Handler: _Query_Params_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "rewards/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/rewards/types/query.pb.gw.go b/x/rewards/types/query.pb.gw.go new file mode 100644 index 00000000..bb90c452 --- /dev/null +++ b/x/rewards/types/query.pb.gw.go @@ -0,0 +1,153 @@ +// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT. +// source: rewards/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{"bze", "rewards", "v1", "params"}, "", runtime.AssumeColonVerbOpt(true))) +) + +var ( + forward_Query_Params_0 = runtime.ForwardResponseMessage +) diff --git a/x/rewards/types/tx.pb.go b/x/rewards/types/tx.pb.go new file mode 100644 index 00000000..fb73bb6a --- /dev/null +++ b/x/rewards/types/tx.pb.go @@ -0,0 +1,80 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: rewards/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("rewards/tx.proto", fileDescriptor_4c0d543e6be8610a) } + +var fileDescriptor_4c0d543e6be8610a = []byte{ + // 128 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x28, 0x4a, 0x2d, 0x4f, + 0x2c, 0x4a, 0x29, 0xd6, 0x2f, 0xa9, 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x4b, 0xaa, + 0x4a, 0xd5, 0x2b, 0x33, 0xd4, 0x83, 0x4a, 0x18, 0xb1, 0x72, 0x31, 0xfb, 0x16, 0xa7, 0x3b, 0xb9, + 0x9d, 0x78, 0x24, 0xc7, 0x78, 0xe1, 0x91, 0x1c, 0xe3, 0x83, 0x47, 0x72, 0x8c, 0x13, 0x1e, 0xcb, + 0x31, 0x5c, 0x78, 0x2c, 0xc7, 0x70, 0xe3, 0xb1, 0x1c, 0x43, 0x94, 0x4e, 0x7a, 0x66, 0x49, 0x46, + 0x69, 0x92, 0x5e, 0x72, 0x7e, 0xae, 0x7e, 0x52, 0x55, 0xaa, 0x6e, 0x62, 0x4e, 0x41, 0x46, 0x62, + 0x49, 0x6a, 0x22, 0x98, 0xa7, 0x5f, 0xa1, 0x0f, 0xb7, 0xa1, 0xb2, 0x20, 0xb5, 0x38, 0x89, 0x0d, + 0x6c, 0x8b, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0xda, 0xb6, 0x9c, 0x53, 0x79, 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: "bze.v1.rewards.Msg", + HandlerType: (*MsgServer)(nil), + Methods: []grpc.MethodDesc{}, + Streams: []grpc.StreamDesc{}, + Metadata: "rewards/tx.proto", +} diff --git a/x/rewards/types/types.go b/x/rewards/types/types.go new file mode 100644 index 00000000..ab1254f4 --- /dev/null +++ b/x/rewards/types/types.go @@ -0,0 +1 @@ +package types diff --git a/x/tradebin/module.go b/x/tradebin/module.go index 21956ab2..87a91505 100644 --- a/x/tradebin/module.go +++ b/x/tradebin/module.go @@ -99,21 +99,18 @@ func (AppModuleBasic) GetQueryCmd() *cobra.Command { type AppModule struct { AppModuleBasic - keeper keeper.Keeper - accountKeeper types.AccountKeeper - bankKeeper types.BankKeeper + keeper keeper.Keeper + bankKeeper types.BankKeeper } func NewAppModule( cdc codec.Codec, keeper keeper.Keeper, - accountKeeper types.AccountKeeper, bankKeeper types.BankKeeper, ) AppModule { return AppModule{ AppModuleBasic: NewAppModuleBasic(cdc), keeper: keeper, - accountKeeper: accountKeeper, bankKeeper: bankKeeper, } } diff --git a/x/tradebin/module_simulation.go b/x/tradebin/module_simulation.go index 68fd07c6..ebefc355 100644 --- a/x/tradebin/module_simulation.go +++ b/x/tradebin/module_simulation.go @@ -94,7 +94,7 @@ func (am AppModule) WeightedOperations(simState module.SimulationState) []simtyp ) operations = append(operations, simulation.NewWeightedOperation( weightMsgCreateMarket, - tradebinsimulation.SimulateMsgCreateMarket(am.accountKeeper, am.bankKeeper, am.keeper), + tradebinsimulation.SimulateMsgCreateMarket(am.bankKeeper, am.keeper), )) var weightMsgCreateOrder int @@ -105,7 +105,7 @@ func (am AppModule) WeightedOperations(simState module.SimulationState) []simtyp ) operations = append(operations, simulation.NewWeightedOperation( weightMsgCreateOrder, - tradebinsimulation.SimulateMsgCreateOrder(am.accountKeeper, am.bankKeeper, am.keeper), + tradebinsimulation.SimulateMsgCreateOrder(am.bankKeeper, am.keeper), )) var weightMsgCancelOrder int @@ -116,7 +116,7 @@ func (am AppModule) WeightedOperations(simState module.SimulationState) []simtyp ) operations = append(operations, simulation.NewWeightedOperation( weightMsgCancelOrder, - tradebinsimulation.SimulateMsgCancelOrder(am.accountKeeper, am.bankKeeper, am.keeper), + tradebinsimulation.SimulateMsgCancelOrder(am.bankKeeper, am.keeper), )) // this line is used by starport scaffolding # simapp/module/operation diff --git a/x/tradebin/simulation/cancel_order.go b/x/tradebin/simulation/cancel_order.go index c0030eb2..6275f366 100644 --- a/x/tradebin/simulation/cancel_order.go +++ b/x/tradebin/simulation/cancel_order.go @@ -11,7 +11,6 @@ import ( ) func SimulateMsgCancelOrder( - ak types.AccountKeeper, bk types.BankKeeper, k keeper.Keeper, ) simtypes.Operation { diff --git a/x/tradebin/simulation/create_market.go b/x/tradebin/simulation/create_market.go index 4fb4ceba..15fb6588 100644 --- a/x/tradebin/simulation/create_market.go +++ b/x/tradebin/simulation/create_market.go @@ -11,7 +11,6 @@ import ( ) func SimulateMsgCreateMarket( - ak types.AccountKeeper, bk types.BankKeeper, k keeper.Keeper, ) simtypes.Operation { diff --git a/x/tradebin/simulation/create_order.go b/x/tradebin/simulation/create_order.go index 383adce2..ca1df1e7 100644 --- a/x/tradebin/simulation/create_order.go +++ b/x/tradebin/simulation/create_order.go @@ -11,7 +11,6 @@ import ( ) func SimulateMsgCreateOrder( - ak types.AccountKeeper, bk types.BankKeeper, k keeper.Keeper, ) simtypes.Operation { From f397312ac57a3d1b7a7eb498c996c9563a0f66c5 Mon Sep 17 00:00:00 2001 From: faneaatiku Date: Thu, 14 Mar 2024 18:40:30 +0200 Subject: [PATCH 03/35] add and update staking reward --- docs/static/openapi.yml | 311 ++++ proto/rewards/genesis.proto | 5 + proto/rewards/query.proto | 30 +- proto/rewards/staking_reward.proto | 16 + proto/rewards/tx.proto | 25 +- .../bze-alphateam/bze/bze.v1.rewards/index.ts | 122 +- .../bze/bze.v1.rewards/module/index.ts | 6 + .../bze/bze.v1.rewards/module/rest.ts | 151 ++ .../module/types/rewards/genesis.ts | 121 +- .../module/types/rewards/query.ts | 378 +++++ .../module/types/rewards/staking_reward.ts | 235 +++ .../bze.v1.rewards/module/types/rewards/tx.ts | 472 +++++- x/rewards/client/cli/query.go | 4 +- x/rewards/client/cli/query_staking_reward.go | 74 + .../client/cli/query_staking_reward_test.go | 163 +++ x/rewards/client/cli/tx.go | 2 + x/rewards/client/cli/tx_staking_reward.go | 81 ++ .../client/cli/tx_staking_reward_test.go | 191 +++ x/rewards/genesis.go | 9 + x/rewards/genesis_test.go | 13 +- x/rewards/handler.go | 8 +- x/rewards/keeper/counter.go | 65 + x/rewards/keeper/grpc_query_staking_reward.go | 57 + .../keeper/grpc_query_staking_reward_test.go | 129 ++ x/rewards/keeper/keeper.go | 4 + x/rewards/keeper/msg_server_staking_reward.go | 99 ++ .../keeper/msg_server_staking_reward_test.go | 154 ++ x/rewards/keeper/staking_reward.go | 51 + x/rewards/keeper/staking_reward_test.go | 66 + x/rewards/module_simulation.go | 55 +- x/rewards/simulation/staking_reward.go | 117 ++ x/rewards/types/codec.go | 8 +- x/rewards/types/errors.go | 7 +- x/rewards/types/expected_keepers.go | 4 + x/rewards/types/genesis.go | 18 + x/rewards/types/genesis.pb.go | 160 ++- x/rewards/types/genesis_test.go | 26 +- x/rewards/types/key_staking_reward.go | 25 + x/rewards/types/messages_staking_reward.go | 175 +++ .../types/messages_staking_reward_test.go | 102 ++ x/rewards/types/params.go | 21 +- x/rewards/types/query.pb.go | 897 +++++++++++- x/rewards/types/query.pb.gw.go | 184 +++ x/rewards/types/staking_reward.pb.go | 599 ++++++++ x/rewards/types/tx.pb.go | 1260 ++++++++++++++++- 45 files changed, 6634 insertions(+), 66 deletions(-) create mode 100644 proto/rewards/staking_reward.proto create mode 100644 vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/staking_reward.ts create mode 100644 x/rewards/client/cli/query_staking_reward.go create mode 100644 x/rewards/client/cli/query_staking_reward_test.go create mode 100644 x/rewards/client/cli/tx_staking_reward.go create mode 100644 x/rewards/client/cli/tx_staking_reward_test.go create mode 100644 x/rewards/keeper/counter.go create mode 100644 x/rewards/keeper/grpc_query_staking_reward.go create mode 100644 x/rewards/keeper/grpc_query_staking_reward_test.go create mode 100644 x/rewards/keeper/msg_server_staking_reward.go create mode 100644 x/rewards/keeper/msg_server_staking_reward_test.go create mode 100644 x/rewards/keeper/staking_reward.go create mode 100644 x/rewards/keeper/staking_reward_test.go create mode 100644 x/rewards/simulation/staking_reward.go create mode 100644 x/rewards/types/key_staking_reward.go create mode 100644 x/rewards/types/messages_staking_reward.go create mode 100644 x/rewards/types/messages_staking_reward_test.go create mode 100644 x/rewards/types/staking_reward.pb.go diff --git a/docs/static/openapi.yml b/docs/static/openapi.yml index 5494fc4c..72065648 100644 --- a/docs/static/openapi.yml +++ b/docs/static/openapi.yml @@ -2192,6 +2192,205 @@ paths: additionalProperties: {} tags: - Query + /bze/rewards/v1/staking_reward: + get: + summary: Queries a list of StakingReward items. + operationId: BzeV1RewardsStakingRewardAll + responses: + '200': + description: A successful response. + schema: + type: object + properties: + list: + type: array + items: + type: object + properties: + reward_id: + type: string + prize_amount: + type: string + format: int64 + prize_denom: + type: string + staking_denom: + type: string + duration: + type: integer + format: int64 + payouts: + type: integer + format: int64 + minStake: + type: string + format: uint64 + lock: + type: integer + format: int64 + pagination: + type: object + properties: + next_key: + type: string + format: byte + title: |- + next_key is the key to be passed to PageRequest.key to + query the next page most efficiently + total: + type: string + format: uint64 + title: >- + total is total number of results available if + PageRequest.count_total + + was set, its value is undefined otherwise + description: >- + PageResponse is to be embedded in gRPC response messages where + the + + corresponding request message has used PageRequest. + + message SomeResponse { + repeated Bar results = 1; + PageResponse page = 2; + } + 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: {} + parameters: + - name: pagination.key + description: |- + key is a value returned in PageResponse.next_key to begin + querying the next page most efficiently. Only one of offset or key + should be set. + in: query + required: false + type: string + format: byte + - name: pagination.offset + description: >- + offset is a numeric offset that can be used when key is unavailable. + + It is less efficient than using key. Only one of offset or key + should + + be set. + in: query + required: false + type: string + format: uint64 + - name: pagination.limit + description: >- + limit is the total number of results to be returned in the result + page. + + If left empty it will default to a value to be set by each app. + in: query + required: false + type: string + format: uint64 + - name: pagination.count_total + description: >- + count_total is set to true to indicate that the result set should + include + + a count of the total number of items available for pagination in + UIs. + + count_total is only respected when offset is used. It is ignored + when key + + is set. + in: query + required: false + type: boolean + - name: pagination.reverse + description: >- + reverse is set to true if results are to be returned in the + descending order. + + + Since: cosmos-sdk 0.43 + in: query + required: false + type: boolean + tags: + - Query + '/bze/rewards/v1/staking_reward/{reward_id}': + get: + summary: Queries a StakingReward by index. + operationId: BzeV1RewardsStakingReward + responses: + '200': + description: A successful response. + schema: + type: object + properties: + staking_reward: + type: object + properties: + reward_id: + type: string + prize_amount: + type: string + format: int64 + prize_denom: + type: string + staking_denom: + type: string + duration: + type: integer + format: int64 + payouts: + type: integer + format: int64 + minStake: + type: string + format: uint64 + lock: + type: integer + format: int64 + 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: {} + parameters: + - name: reward_id + in: path + required: true + type: string + tags: + - Query /cosmos/auth/v1beta1/accounts: get: summary: Accounts returns all the existing accounts @@ -33961,6 +34160,13 @@ definitions: repeated Bar results = 1; PageResponse page = 2; } + bze.v1.rewards.MsgCreateStakingRewardResponse: + type: object + properties: + reward_id: + type: string + bze.v1.rewards.MsgUpdateStakingRewardResponse: + type: object bze.v1.rewards.Params: type: object properties: @@ -33969,6 +34175,87 @@ definitions: createTradingRewardFee: type: string description: Params defines the parameters for the module. + bze.v1.rewards.QueryAllStakingRewardResponse: + type: object + properties: + list: + type: array + items: + type: object + properties: + reward_id: + type: string + prize_amount: + type: string + format: int64 + prize_denom: + type: string + staking_denom: + type: string + duration: + type: integer + format: int64 + payouts: + type: integer + format: int64 + minStake: + type: string + format: uint64 + lock: + type: integer + format: int64 + pagination: + type: object + properties: + next_key: + type: string + format: byte + title: |- + next_key is the key to be passed to PageRequest.key to + query the next page most efficiently + total: + type: string + format: uint64 + title: >- + total is total number of results available if + PageRequest.count_total + + was set, its value is undefined otherwise + description: |- + PageResponse is to be embedded in gRPC response messages where the + corresponding request message has used PageRequest. + + message SomeResponse { + repeated Bar results = 1; + PageResponse page = 2; + } + bze.v1.rewards.QueryGetStakingRewardResponse: + type: object + properties: + staking_reward: + type: object + properties: + reward_id: + type: string + prize_amount: + type: string + format: int64 + prize_denom: + type: string + staking_denom: + type: string + duration: + type: integer + format: int64 + payouts: + type: integer + format: int64 + minStake: + type: string + format: uint64 + lock: + type: integer + format: int64 bze.v1.rewards.QueryParamsResponse: type: object properties: @@ -33981,6 +34268,30 @@ definitions: createTradingRewardFee: type: string description: QueryParamsResponse is response type for the Query/Params RPC method. + bze.v1.rewards.StakingReward: + type: object + properties: + reward_id: + type: string + prize_amount: + type: string + format: int64 + prize_denom: + type: string + staking_denom: + type: string + duration: + type: integer + format: int64 + payouts: + type: integer + format: int64 + minStake: + type: string + format: uint64 + lock: + type: integer + format: int64 cosmos.auth.v1beta1.Params: type: object properties: diff --git a/proto/rewards/genesis.proto b/proto/rewards/genesis.proto index e592b6ab..250aa889 100644 --- a/proto/rewards/genesis.proto +++ b/proto/rewards/genesis.proto @@ -3,6 +3,7 @@ package bze.v1.rewards; import "gogoproto/gogo.proto"; import "rewards/params.proto"; +import "rewards/staking_reward.proto"; // this line is used by starport scaffolding # genesis/proto/import option go_package = "github.com/bze-alphateam/bze/x/rewards/types"; @@ -10,5 +11,9 @@ option go_package = "github.com/bze-alphateam/bze/x/rewards/types"; // GenesisState defines the rewards module's genesis state. message GenesisState { Params params = 1 [(gogoproto.nullable) = false]; + repeated StakingReward staking_reward_list = 2 [(gogoproto.nullable) = false]; + uint64 staking_rewards_counter = 3; + uint64 trading_rewards_counter = 4; + // this line is used by starport scaffolding # genesis/proto/state } diff --git a/proto/rewards/query.proto b/proto/rewards/query.proto index 36bf9fcf..8fa1da84 100644 --- a/proto/rewards/query.proto +++ b/proto/rewards/query.proto @@ -5,6 +5,7 @@ import "gogoproto/gogo.proto"; import "google/api/annotations.proto"; import "cosmos/base/query/v1beta1/pagination.proto"; import "rewards/params.proto"; +import "rewards/staking_reward.proto"; // this line is used by starport scaffolding # 1 option go_package = "github.com/bze-alphateam/bze/x/rewards/types"; @@ -15,7 +16,17 @@ service Query { rpc Params(QueryParamsRequest) returns (QueryParamsResponse) { option (google.api.http).get = "/bze/rewards/v1/params"; } - // this line is used by starport scaffolding # 2 + // Queries a StakingReward by index. + rpc StakingReward(QueryGetStakingRewardRequest) returns (QueryGetStakingRewardResponse) { + option (google.api.http).get = "/bze/rewards/v1/staking_reward/{reward_id}"; + } + + // Queries a list of StakingReward items. + rpc StakingRewardAll(QueryAllStakingRewardRequest) returns (QueryAllStakingRewardResponse) { + option (google.api.http).get = "/bze/rewards/v1/staking_reward"; + } + +// this line is used by starport scaffolding # 2 } // QueryParamsRequest is request type for the Query/Params RPC method. @@ -27,4 +38,21 @@ message QueryParamsResponse { Params params = 1 [(gogoproto.nullable) = false]; } +message QueryGetStakingRewardRequest { + string reward_id = 1; +} + +message QueryGetStakingRewardResponse { + StakingReward staking_reward = 1 [(gogoproto.nullable) = false]; +} + +message QueryAllStakingRewardRequest { + cosmos.base.query.v1beta1.PageRequest pagination = 1; +} + +message QueryAllStakingRewardResponse { + repeated StakingReward list = 1 [(gogoproto.nullable) = false]; + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} + // this line is used by starport scaffolding # 3 diff --git a/proto/rewards/staking_reward.proto b/proto/rewards/staking_reward.proto new file mode 100644 index 00000000..438c0200 --- /dev/null +++ b/proto/rewards/staking_reward.proto @@ -0,0 +1,16 @@ +syntax = "proto3"; +package bze.v1.rewards; + +option go_package = "github.com/bze-alphateam/bze/x/rewards/types"; + +message StakingReward { + string reward_id = 1; + int64 prize_amount = 2; + string prize_denom = 3; + string staking_denom = 4; + uint32 duration = 5; + uint32 payouts = 6; + uint64 minStake = 7; + uint32 lock = 8; +} + diff --git a/proto/rewards/tx.proto b/proto/rewards/tx.proto index 8ddfe6bf..b1e62bd2 100644 --- a/proto/rewards/tx.proto +++ b/proto/rewards/tx.proto @@ -7,7 +7,30 @@ option go_package = "github.com/bze-alphateam/bze/x/rewards/types"; // Msg defines the Msg service. service Msg { - // this line is used by starport scaffolding # proto/tx/rpc + rpc CreateStakingReward(MsgCreateStakingReward) returns (MsgCreateStakingRewardResponse); + rpc UpdateStakingReward(MsgUpdateStakingReward) returns (MsgUpdateStakingRewardResponse); +// this line is used by starport scaffolding # proto/tx/rpc } +message MsgCreateStakingReward { + string creator = 1; //msg creator + string prize_amount = 2; //the amount paid as prize + string prize_denom = 3; //the denom paid as prize + string staking_denom = 4; //the denom a user has to stake in order to qualify + string duration = 5; // the number of days the rewards are paid + string min_stake = 6; // the minimum amount of staking denom a user has to stake in order to qualify + string lock = 7; // the number of days the funds are locked upon exiting stake +} + +message MsgCreateStakingRewardResponse { + string reward_id = 1; +} + +message MsgUpdateStakingReward { + string creator = 1; + string reward_id = 2; + string duration = 3; // the number of days the rewards are paid +} +message MsgUpdateStakingRewardResponse {} + // this line is used by starport scaffolding # proto/tx/message diff --git a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/index.ts b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/index.ts index b921b54f..c1606760 100755 --- a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/index.ts +++ b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/index.ts @@ -1,9 +1,10 @@ import { txClient, queryClient, MissingWalletError , registry} from './module' import { Params } from "./module/types/rewards/params" +import { StakingReward } from "./module/types/rewards/staking_reward" -export { Params }; +export { Params, StakingReward }; async function initTxClient(vuexGetters) { return await txClient(vuexGetters['common/wallet/signer'], { @@ -42,9 +43,12 @@ function getStructure(template) { const getDefaultState = () => { return { Params: {}, + StakingReward: {}, + StakingRewardAll: {}, _Structure: { Params: getStructure(Params.fromPartial({})), + StakingReward: getStructure(StakingReward.fromPartial({})), }, _Registry: registry, @@ -79,6 +83,18 @@ export default { } return state.Params[JSON.stringify(params)] ?? {} }, + getStakingReward: (state) => (params = { params: {}}) => { + if (!( params).query) { + ( params).query=null + } + return state.StakingReward[JSON.stringify(params)] ?? {} + }, + getStakingRewardAll: (state) => (params = { params: {}}) => { + if (!( params).query) { + ( params).query=null + } + return state.StakingRewardAll[JSON.stringify(params)] ?? {} + }, getTypeStructure: (state) => (type) => { return state._Structure[type].fields @@ -137,5 +153,109 @@ export default { + + + + async QueryStakingReward({ commit, rootGetters, getters }, { options: { subscribe, all} = { subscribe:false, all:false}, params, query=null }) { + try { + const key = params ?? {}; + const queryClient=await initQueryClient(rootGetters) + let value= (await queryClient.queryStakingReward( key.reward_id)).data + + + commit('QUERY', { query: 'StakingReward', key: { params: {...key}, query}, value }) + if (subscribe) commit('SUBSCRIBE', { action: 'QueryStakingReward', payload: { options: { all }, params: {...key},query }}) + return getters['getStakingReward']( { params: {...key}, query}) ?? {} + } catch (e) { + throw new Error('QueryClient:QueryStakingReward API Node Unavailable. Could not perform query: ' + e.message) + + } + }, + + + + + + + + async QueryStakingRewardAll({ commit, rootGetters, getters }, { options: { subscribe, all} = { subscribe:false, all:false}, params, query=null }) { + try { + const key = params ?? {}; + const queryClient=await initQueryClient(rootGetters) + let value= (await queryClient.queryStakingRewardAll(query)).data + + + while (all && ( value).pagination && ( value).pagination.next_key!=null) { + let next_values=(await queryClient.queryStakingRewardAll({...query, 'pagination.key':( value).pagination.next_key})).data + value = mergeResults(value, next_values); + } + commit('QUERY', { query: 'StakingRewardAll', key: { params: {...key}, query}, value }) + if (subscribe) commit('SUBSCRIBE', { action: 'QueryStakingRewardAll', payload: { options: { all }, params: {...key},query }}) + return getters['getStakingRewardAll']( { params: {...key}, query}) ?? {} + } catch (e) { + throw new Error('QueryClient:QueryStakingRewardAll API Node Unavailable. Could not perform query: ' + e.message) + + } + }, + + + async sendMsgUpdateStakingReward({ rootGetters }, { value, fee = [], memo = '' }) { + try { + const txClient=await initTxClient(rootGetters) + const msg = await txClient.msgUpdateStakingReward(value) + const result = await txClient.signAndBroadcast([msg], {fee: { amount: fee, + gas: "200000" }, memo}) + return result + } catch (e) { + if (e == MissingWalletError) { + throw new Error('TxClient:MsgUpdateStakingReward:Init Could not initialize signing client. Wallet is required.') + }else{ + throw new Error('TxClient:MsgUpdateStakingReward:Send Could not broadcast Tx: '+ e.message) + } + } + }, + async sendMsgCreateStakingReward({ rootGetters }, { value, fee = [], memo = '' }) { + try { + const txClient=await initTxClient(rootGetters) + const msg = await txClient.msgCreateStakingReward(value) + const result = await txClient.signAndBroadcast([msg], {fee: { amount: fee, + gas: "200000" }, memo}) + return result + } catch (e) { + if (e == MissingWalletError) { + throw new Error('TxClient:MsgCreateStakingReward:Init Could not initialize signing client. Wallet is required.') + }else{ + throw new Error('TxClient:MsgCreateStakingReward:Send Could not broadcast Tx: '+ e.message) + } + } + }, + + async MsgUpdateStakingReward({ rootGetters }, { value }) { + try { + const txClient=await initTxClient(rootGetters) + const msg = await txClient.msgUpdateStakingReward(value) + return msg + } catch (e) { + if (e == MissingWalletError) { + throw new Error('TxClient:MsgUpdateStakingReward:Init Could not initialize signing client. Wallet is required.') + } else{ + throw new Error('TxClient:MsgUpdateStakingReward:Create Could not create message: ' + e.message) + } + } + }, + async MsgCreateStakingReward({ rootGetters }, { value }) { + try { + const txClient=await initTxClient(rootGetters) + const msg = await txClient.msgCreateStakingReward(value) + return msg + } catch (e) { + if (e == MissingWalletError) { + throw new Error('TxClient:MsgCreateStakingReward:Init Could not initialize signing client. Wallet is required.') + } else{ + throw new Error('TxClient:MsgCreateStakingReward:Create Could not create message: ' + e.message) + } + } + }, + } } diff --git a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/index.ts b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/index.ts index 67d4b093..c220683c 100755 --- a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/index.ts +++ b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/index.ts @@ -4,9 +4,13 @@ import { StdFee } from "@cosmjs/launchpad"; import { SigningStargateClient } from "@cosmjs/stargate"; import { Registry, OfflineSigner, EncodeObject, DirectSecp256k1HdWallet } from "@cosmjs/proto-signing"; import { Api } from "./rest"; +import { MsgUpdateStakingReward } from "./types/rewards/tx"; +import { MsgCreateStakingReward } from "./types/rewards/tx"; const types = [ + ["/bze.v1.rewards.MsgUpdateStakingReward", MsgUpdateStakingReward], + ["/bze.v1.rewards.MsgCreateStakingReward", MsgCreateStakingReward], ]; export const MissingWalletError = new Error("wallet is required"); @@ -39,6 +43,8 @@ const txClient = async (wallet: OfflineSigner, { addr: addr }: TxClientOptions = return { signAndBroadcast: (msgs: EncodeObject[], { fee, memo }: SignAndBroadcastOptions = {fee: defaultFee, memo: ""}) => client.signAndBroadcast(address, msgs, fee,memo), + msgUpdateStakingReward: (data: MsgUpdateStakingReward): EncodeObject => ({ typeUrl: "/bze.v1.rewards.MsgUpdateStakingReward", value: MsgUpdateStakingReward.fromPartial( data ) }), + msgCreateStakingReward: (data: MsgCreateStakingReward): EncodeObject => ({ typeUrl: "/bze.v1.rewards.MsgCreateStakingReward", value: MsgCreateStakingReward.fromPartial( data ) }), }; }; diff --git a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/rest.ts b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/rest.ts index 7d83cbdb..0867c357 100644 --- a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/rest.ts +++ b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/rest.ts @@ -13,6 +13,31 @@ export interface ProtobufAny { "@type"?: string; } +export interface RewardsMsgCreateStakingRewardResponse { + reward_id?: string; +} + +export type RewardsMsgUpdateStakingRewardResponse = object; + +export interface RewardsQueryAllStakingRewardResponse { + list?: V1RewardsStakingReward[]; + + /** + * PageResponse is to be embedded in gRPC response messages where the + * corresponding request message has used PageRequest. + * + * message SomeResponse { + * repeated Bar results = 1; + * PageResponse page = 2; + * } + */ + pagination?: V1Beta1PageResponse; +} + +export interface RewardsQueryGetStakingRewardResponse { + staking_reward?: V1RewardsStakingReward; +} + /** * QueryParamsResponse is response type for the Query/Params RPC method. */ @@ -28,6 +53,69 @@ export interface RpcStatus { details?: ProtobufAny[]; } +/** +* message SomeRequest { + Foo some_parameter = 1; + PageRequest pagination = 2; + } +*/ +export interface V1Beta1PageRequest { + /** + * key is a value returned in PageResponse.next_key to begin + * querying the next page most efficiently. Only one of offset or key + * should be set. + * @format byte + */ + key?: string; + + /** + * offset is a numeric offset that can be used when key is unavailable. + * It is less efficient than using key. Only one of offset or key should + * be set. + * @format uint64 + */ + offset?: string; + + /** + * limit is the total number of results to be returned in the result page. + * If left empty it will default to a value to be set by each app. + * @format uint64 + */ + limit?: string; + + /** + * count_total is set to true to indicate that the result set should include + * a count of the total number of items available for pagination in UIs. + * count_total is only respected when offset is used. It is ignored when key + * is set. + */ + count_total?: boolean; + + /** + * reverse is set to true if results are to be returned in the descending order. + * + * Since: cosmos-sdk 0.43 + */ + reverse?: boolean; +} + +/** +* PageResponse is to be embedded in gRPC response messages where the +corresponding request message has used PageRequest. + + message SomeResponse { + repeated Bar results = 1; + PageResponse page = 2; + } +*/ +export interface V1Beta1PageResponse { + /** @format byte */ + next_key?: string; + + /** @format uint64 */ + total?: string; +} + /** * Params defines the parameters for the module. */ @@ -36,6 +124,27 @@ export interface V1RewardsParams { createTradingRewardFee?: string; } +export interface V1RewardsStakingReward { + reward_id?: string; + + /** @format int64 */ + prize_amount?: string; + prize_denom?: string; + staking_denom?: string; + + /** @format int64 */ + duration?: number; + + /** @format int64 */ + payouts?: number; + + /** @format uint64 */ + minStake?: string; + + /** @format int64 */ + lock?: number; +} + export type QueryParamsType = Record; export type ResponseFormat = keyof Omit; @@ -247,4 +356,46 @@ export class Api extends HttpClient + this.request({ + path: `/bze/rewards/v1/staking_reward`, + method: "GET", + query: query, + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Query + * @name QueryStakingReward + * @summary Queries a StakingReward by index. + * @request GET:/bze/rewards/v1/staking_reward/{reward_id} + */ + queryStakingReward = (reward_id: string, params: RequestParams = {}) => + this.request({ + path: `/bze/rewards/v1/staking_reward/${reward_id}`, + method: "GET", + format: "json", + ...params, + }); } diff --git a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/genesis.ts b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/genesis.ts index 3c128f61..fb45139d 100644 --- a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/genesis.ts +++ b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/genesis.ts @@ -1,22 +1,38 @@ /* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; import { Params } from "../rewards/params"; -import { Writer, Reader } from "protobufjs/minimal"; +import { StakingReward } from "../rewards/staking_reward"; export const protobufPackage = "bze.v1.rewards"; /** GenesisState defines the rewards module's genesis state. */ export interface GenesisState { - /** this line is used by starport scaffolding # genesis/proto/state */ params: Params | undefined; + staking_reward_list: StakingReward[]; + staking_rewards_counter: number; + trading_rewards_counter: number; } -const baseGenesisState: object = {}; +const baseGenesisState: object = { + staking_rewards_counter: 0, + trading_rewards_counter: 0, +}; export const GenesisState = { encode(message: GenesisState, writer: Writer = Writer.create()): Writer { if (message.params !== undefined) { Params.encode(message.params, writer.uint32(10).fork()).ldelim(); } + for (const v of message.staking_reward_list) { + StakingReward.encode(v!, writer.uint32(18).fork()).ldelim(); + } + if (message.staking_rewards_counter !== 0) { + writer.uint32(24).uint64(message.staking_rewards_counter); + } + if (message.trading_rewards_counter !== 0) { + writer.uint32(32).uint64(message.trading_rewards_counter); + } return writer; }, @@ -24,12 +40,28 @@ export const GenesisState = { const reader = input instanceof Uint8Array ? new Reader(input) : input; let end = length === undefined ? reader.len : reader.pos + length; const message = { ...baseGenesisState } as GenesisState; + message.staking_reward_list = []; while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: message.params = Params.decode(reader, reader.uint32()); break; + case 2: + message.staking_reward_list.push( + StakingReward.decode(reader, reader.uint32()) + ); + break; + case 3: + message.staking_rewards_counter = longToNumber( + reader.uint64() as Long + ); + break; + case 4: + message.trading_rewards_counter = longToNumber( + reader.uint64() as Long + ); + break; default: reader.skipType(tag & 7); break; @@ -40,11 +72,36 @@ export const GenesisState = { fromJSON(object: any): GenesisState { const message = { ...baseGenesisState } as GenesisState; + message.staking_reward_list = []; if (object.params !== undefined && object.params !== null) { message.params = Params.fromJSON(object.params); } else { message.params = undefined; } + if ( + object.staking_reward_list !== undefined && + object.staking_reward_list !== null + ) { + for (const e of object.staking_reward_list) { + message.staking_reward_list.push(StakingReward.fromJSON(e)); + } + } + if ( + object.staking_rewards_counter !== undefined && + object.staking_rewards_counter !== null + ) { + message.staking_rewards_counter = Number(object.staking_rewards_counter); + } else { + message.staking_rewards_counter = 0; + } + if ( + object.trading_rewards_counter !== undefined && + object.trading_rewards_counter !== null + ) { + message.trading_rewards_counter = Number(object.trading_rewards_counter); + } else { + message.trading_rewards_counter = 0; + } return message; }, @@ -52,20 +109,66 @@ export const GenesisState = { const obj: any = {}; message.params !== undefined && (obj.params = message.params ? Params.toJSON(message.params) : undefined); + if (message.staking_reward_list) { + obj.staking_reward_list = message.staking_reward_list.map((e) => + e ? StakingReward.toJSON(e) : undefined + ); + } else { + obj.staking_reward_list = []; + } + message.staking_rewards_counter !== undefined && + (obj.staking_rewards_counter = message.staking_rewards_counter); + message.trading_rewards_counter !== undefined && + (obj.trading_rewards_counter = message.trading_rewards_counter); return obj; }, fromPartial(object: DeepPartial): GenesisState { const message = { ...baseGenesisState } as GenesisState; + message.staking_reward_list = []; if (object.params !== undefined && object.params !== null) { message.params = Params.fromPartial(object.params); } else { message.params = undefined; } + if ( + object.staking_reward_list !== undefined && + object.staking_reward_list !== null + ) { + for (const e of object.staking_reward_list) { + message.staking_reward_list.push(StakingReward.fromPartial(e)); + } + } + if ( + object.staking_rewards_counter !== undefined && + object.staking_rewards_counter !== null + ) { + message.staking_rewards_counter = object.staking_rewards_counter; + } else { + message.staking_rewards_counter = 0; + } + if ( + object.trading_rewards_counter !== undefined && + object.trading_rewards_counter !== null + ) { + message.trading_rewards_counter = object.trading_rewards_counter; + } else { + message.trading_rewards_counter = 0; + } return message; }, }; +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + type Builtin = Date | Function | Uint8Array | string | number | undefined; export type DeepPartial = T extends Builtin ? T @@ -76,3 +179,15 @@ export type DeepPartial = T extends Builtin : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/query.ts b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/query.ts index b07f4653..dc2922b3 100644 --- a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/query.ts +++ b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/query.ts @@ -1,6 +1,11 @@ /* eslint-disable */ import { Reader, Writer } from "protobufjs/minimal"; import { Params } from "../rewards/params"; +import { StakingReward } from "../rewards/staking_reward"; +import { + PageRequest, + PageResponse, +} from "../cosmos/base/query/v1beta1/pagination"; export const protobufPackage = "bze.v1.rewards"; @@ -13,6 +18,23 @@ export interface QueryParamsResponse { params: Params | undefined; } +export interface QueryGetStakingRewardRequest { + reward_id: string; +} + +export interface QueryGetStakingRewardResponse { + staking_reward: StakingReward | undefined; +} + +export interface QueryAllStakingRewardRequest { + pagination: PageRequest | undefined; +} + +export interface QueryAllStakingRewardResponse { + list: StakingReward[]; + pagination: PageResponse | undefined; +} + const baseQueryParamsRequest: object = {}; export const QueryParamsRequest = { @@ -110,10 +132,338 @@ export const QueryParamsResponse = { }, }; +const baseQueryGetStakingRewardRequest: object = { reward_id: "" }; + +export const QueryGetStakingRewardRequest = { + encode( + message: QueryGetStakingRewardRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.reward_id !== "") { + writer.uint32(10).string(message.reward_id); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryGetStakingRewardRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryGetStakingRewardRequest, + } as QueryGetStakingRewardRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.reward_id = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryGetStakingRewardRequest { + const message = { + ...baseQueryGetStakingRewardRequest, + } as QueryGetStakingRewardRequest; + if (object.reward_id !== undefined && object.reward_id !== null) { + message.reward_id = String(object.reward_id); + } else { + message.reward_id = ""; + } + return message; + }, + + toJSON(message: QueryGetStakingRewardRequest): unknown { + const obj: any = {}; + message.reward_id !== undefined && (obj.reward_id = message.reward_id); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryGetStakingRewardRequest { + const message = { + ...baseQueryGetStakingRewardRequest, + } as QueryGetStakingRewardRequest; + if (object.reward_id !== undefined && object.reward_id !== null) { + message.reward_id = object.reward_id; + } else { + message.reward_id = ""; + } + return message; + }, +}; + +const baseQueryGetStakingRewardResponse: object = {}; + +export const QueryGetStakingRewardResponse = { + encode( + message: QueryGetStakingRewardResponse, + writer: Writer = Writer.create() + ): Writer { + if (message.staking_reward !== undefined) { + StakingReward.encode( + message.staking_reward, + writer.uint32(10).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryGetStakingRewardResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryGetStakingRewardResponse, + } as QueryGetStakingRewardResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.staking_reward = StakingReward.decode( + reader, + reader.uint32() + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryGetStakingRewardResponse { + const message = { + ...baseQueryGetStakingRewardResponse, + } as QueryGetStakingRewardResponse; + if (object.staking_reward !== undefined && object.staking_reward !== null) { + message.staking_reward = StakingReward.fromJSON(object.staking_reward); + } else { + message.staking_reward = undefined; + } + return message; + }, + + toJSON(message: QueryGetStakingRewardResponse): unknown { + const obj: any = {}; + message.staking_reward !== undefined && + (obj.staking_reward = message.staking_reward + ? StakingReward.toJSON(message.staking_reward) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryGetStakingRewardResponse { + const message = { + ...baseQueryGetStakingRewardResponse, + } as QueryGetStakingRewardResponse; + if (object.staking_reward !== undefined && object.staking_reward !== null) { + message.staking_reward = StakingReward.fromPartial(object.staking_reward); + } else { + message.staking_reward = undefined; + } + return message; + }, +}; + +const baseQueryAllStakingRewardRequest: object = {}; + +export const QueryAllStakingRewardRequest = { + encode( + message: QueryAllStakingRewardRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryAllStakingRewardRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryAllStakingRewardRequest, + } as QueryAllStakingRewardRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryAllStakingRewardRequest { + const message = { + ...baseQueryAllStakingRewardRequest, + } as QueryAllStakingRewardRequest; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryAllStakingRewardRequest): unknown { + const obj: any = {}; + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageRequest.toJSON(message.pagination) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryAllStakingRewardRequest { + const message = { + ...baseQueryAllStakingRewardRequest, + } as QueryAllStakingRewardRequest; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseQueryAllStakingRewardResponse: object = {}; + +export const QueryAllStakingRewardResponse = { + encode( + message: QueryAllStakingRewardResponse, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.list) { + StakingReward.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode( + message.pagination, + writer.uint32(18).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryAllStakingRewardResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryAllStakingRewardResponse, + } as QueryAllStakingRewardResponse; + message.list = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.list.push(StakingReward.decode(reader, reader.uint32())); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryAllStakingRewardResponse { + const message = { + ...baseQueryAllStakingRewardResponse, + } as QueryAllStakingRewardResponse; + message.list = []; + if (object.list !== undefined && object.list !== null) { + for (const e of object.list) { + message.list.push(StakingReward.fromJSON(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryAllStakingRewardResponse): unknown { + const obj: any = {}; + if (message.list) { + obj.list = message.list.map((e) => + e ? StakingReward.toJSON(e) : undefined + ); + } else { + obj.list = []; + } + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageResponse.toJSON(message.pagination) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryAllStakingRewardResponse { + const message = { + ...baseQueryAllStakingRewardResponse, + } as QueryAllStakingRewardResponse; + message.list = []; + if (object.list !== undefined && object.list !== null) { + for (const e of object.list) { + message.list.push(StakingReward.fromPartial(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + /** Query defines the gRPC querier service. */ export interface Query { /** Parameters queries the parameters of the module. */ Params(request: QueryParamsRequest): Promise; + /** Queries a StakingReward by index. */ + StakingReward( + request: QueryGetStakingRewardRequest + ): Promise; + /** Queries a list of StakingReward items. */ + StakingRewardAll( + request: QueryAllStakingRewardRequest + ): Promise; } export class QueryClientImpl implements Query { @@ -126,6 +476,34 @@ export class QueryClientImpl implements Query { const promise = this.rpc.request("bze.v1.rewards.Query", "Params", data); return promise.then((data) => QueryParamsResponse.decode(new Reader(data))); } + + StakingReward( + request: QueryGetStakingRewardRequest + ): Promise { + const data = QueryGetStakingRewardRequest.encode(request).finish(); + const promise = this.rpc.request( + "bze.v1.rewards.Query", + "StakingReward", + data + ); + return promise.then((data) => + QueryGetStakingRewardResponse.decode(new Reader(data)) + ); + } + + StakingRewardAll( + request: QueryAllStakingRewardRequest + ): Promise { + const data = QueryAllStakingRewardRequest.encode(request).finish(); + const promise = this.rpc.request( + "bze.v1.rewards.Query", + "StakingRewardAll", + data + ); + return promise.then((data) => + QueryAllStakingRewardResponse.decode(new Reader(data)) + ); + } } interface Rpc { diff --git a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/staking_reward.ts b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/staking_reward.ts new file mode 100644 index 00000000..86afd298 --- /dev/null +++ b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/staking_reward.ts @@ -0,0 +1,235 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "bze.v1.rewards"; + +export interface StakingReward { + reward_id: string; + prize_amount: number; + prize_denom: string; + staking_denom: string; + duration: number; + payouts: number; + minStake: number; + lock: number; +} + +const baseStakingReward: object = { + reward_id: "", + prize_amount: 0, + prize_denom: "", + staking_denom: "", + duration: 0, + payouts: 0, + minStake: 0, + lock: 0, +}; + +export const StakingReward = { + encode(message: StakingReward, writer: Writer = Writer.create()): Writer { + if (message.reward_id !== "") { + writer.uint32(10).string(message.reward_id); + } + if (message.prize_amount !== 0) { + writer.uint32(16).int64(message.prize_amount); + } + if (message.prize_denom !== "") { + writer.uint32(26).string(message.prize_denom); + } + if (message.staking_denom !== "") { + writer.uint32(34).string(message.staking_denom); + } + if (message.duration !== 0) { + writer.uint32(40).uint32(message.duration); + } + if (message.payouts !== 0) { + writer.uint32(48).uint32(message.payouts); + } + if (message.minStake !== 0) { + writer.uint32(56).uint64(message.minStake); + } + if (message.lock !== 0) { + writer.uint32(64).uint32(message.lock); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): StakingReward { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseStakingReward } as StakingReward; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.reward_id = reader.string(); + break; + case 2: + message.prize_amount = longToNumber(reader.int64() as Long); + break; + case 3: + message.prize_denom = reader.string(); + break; + case 4: + message.staking_denom = reader.string(); + break; + case 5: + message.duration = reader.uint32(); + break; + case 6: + message.payouts = reader.uint32(); + break; + case 7: + message.minStake = longToNumber(reader.uint64() as Long); + break; + case 8: + message.lock = reader.uint32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): StakingReward { + const message = { ...baseStakingReward } as StakingReward; + if (object.reward_id !== undefined && object.reward_id !== null) { + message.reward_id = String(object.reward_id); + } else { + message.reward_id = ""; + } + if (object.prize_amount !== undefined && object.prize_amount !== null) { + message.prize_amount = Number(object.prize_amount); + } else { + message.prize_amount = 0; + } + if (object.prize_denom !== undefined && object.prize_denom !== null) { + message.prize_denom = String(object.prize_denom); + } else { + message.prize_denom = ""; + } + if (object.staking_denom !== undefined && object.staking_denom !== null) { + message.staking_denom = String(object.staking_denom); + } else { + message.staking_denom = ""; + } + if (object.duration !== undefined && object.duration !== null) { + message.duration = Number(object.duration); + } else { + message.duration = 0; + } + if (object.payouts !== undefined && object.payouts !== null) { + message.payouts = Number(object.payouts); + } else { + message.payouts = 0; + } + if (object.minStake !== undefined && object.minStake !== null) { + message.minStake = Number(object.minStake); + } else { + message.minStake = 0; + } + if (object.lock !== undefined && object.lock !== null) { + message.lock = Number(object.lock); + } else { + message.lock = 0; + } + return message; + }, + + toJSON(message: StakingReward): unknown { + const obj: any = {}; + message.reward_id !== undefined && (obj.reward_id = message.reward_id); + message.prize_amount !== undefined && + (obj.prize_amount = message.prize_amount); + message.prize_denom !== undefined && + (obj.prize_denom = message.prize_denom); + message.staking_denom !== undefined && + (obj.staking_denom = message.staking_denom); + message.duration !== undefined && (obj.duration = message.duration); + message.payouts !== undefined && (obj.payouts = message.payouts); + message.minStake !== undefined && (obj.minStake = message.minStake); + message.lock !== undefined && (obj.lock = message.lock); + return obj; + }, + + fromPartial(object: DeepPartial): StakingReward { + const message = { ...baseStakingReward } as StakingReward; + if (object.reward_id !== undefined && object.reward_id !== null) { + message.reward_id = object.reward_id; + } else { + message.reward_id = ""; + } + if (object.prize_amount !== undefined && object.prize_amount !== null) { + message.prize_amount = object.prize_amount; + } else { + message.prize_amount = 0; + } + if (object.prize_denom !== undefined && object.prize_denom !== null) { + message.prize_denom = object.prize_denom; + } else { + message.prize_denom = ""; + } + if (object.staking_denom !== undefined && object.staking_denom !== null) { + message.staking_denom = object.staking_denom; + } else { + message.staking_denom = ""; + } + if (object.duration !== undefined && object.duration !== null) { + message.duration = object.duration; + } else { + message.duration = 0; + } + if (object.payouts !== undefined && object.payouts !== null) { + message.payouts = object.payouts; + } else { + message.payouts = 0; + } + if (object.minStake !== undefined && object.minStake !== null) { + message.minStake = object.minStake; + } else { + message.minStake = 0; + } + if (object.lock !== undefined && object.lock !== null) { + message.lock = object.lock; + } else { + message.lock = 0; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/tx.ts b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/tx.ts index 0e007f76..1d97f229 100644 --- a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/tx.ts +++ b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/tx.ts @@ -1,14 +1,473 @@ /* eslint-disable */ +import { Reader, Writer } from "protobufjs/minimal"; + export const protobufPackage = "bze.v1.rewards"; +export interface MsgCreateStakingReward { + /** msg creator */ + creator: string; + /** the amount paid as prize */ + prize_amount: string; + /** the denom paid as prize */ + prize_denom: string; + /** the denom a user has to stake in order to qualify */ + staking_denom: string; + /** the number of days the rewards are paid */ + duration: string; + /** the minimum amount of staking denom a user has to stake in order to qualify */ + min_stake: string; + /** the number of days the funds are locked upon exiting stake */ + lock: string; +} + +export interface MsgCreateStakingRewardResponse { + reward_id: string; +} + +export interface MsgUpdateStakingReward { + creator: string; + reward_id: string; + /** the number of days the rewards are paid */ + duration: string; +} + +export interface MsgUpdateStakingRewardResponse {} + +const baseMsgCreateStakingReward: object = { + creator: "", + prize_amount: "", + prize_denom: "", + staking_denom: "", + duration: "", + min_stake: "", + lock: "", +}; + +export const MsgCreateStakingReward = { + encode( + message: MsgCreateStakingReward, + writer: Writer = Writer.create() + ): Writer { + if (message.creator !== "") { + writer.uint32(10).string(message.creator); + } + if (message.prize_amount !== "") { + writer.uint32(18).string(message.prize_amount); + } + if (message.prize_denom !== "") { + writer.uint32(26).string(message.prize_denom); + } + if (message.staking_denom !== "") { + writer.uint32(34).string(message.staking_denom); + } + if (message.duration !== "") { + writer.uint32(42).string(message.duration); + } + if (message.min_stake !== "") { + writer.uint32(50).string(message.min_stake); + } + if (message.lock !== "") { + writer.uint32(58).string(message.lock); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MsgCreateStakingReward { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgCreateStakingReward } as MsgCreateStakingReward; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.creator = reader.string(); + break; + case 2: + message.prize_amount = reader.string(); + break; + case 3: + message.prize_denom = reader.string(); + break; + case 4: + message.staking_denom = reader.string(); + break; + case 5: + message.duration = reader.string(); + break; + case 6: + message.min_stake = reader.string(); + break; + case 7: + message.lock = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgCreateStakingReward { + const message = { ...baseMsgCreateStakingReward } as MsgCreateStakingReward; + if (object.creator !== undefined && object.creator !== null) { + message.creator = String(object.creator); + } else { + message.creator = ""; + } + if (object.prize_amount !== undefined && object.prize_amount !== null) { + message.prize_amount = String(object.prize_amount); + } else { + message.prize_amount = ""; + } + if (object.prize_denom !== undefined && object.prize_denom !== null) { + message.prize_denom = String(object.prize_denom); + } else { + message.prize_denom = ""; + } + if (object.staking_denom !== undefined && object.staking_denom !== null) { + message.staking_denom = String(object.staking_denom); + } else { + message.staking_denom = ""; + } + if (object.duration !== undefined && object.duration !== null) { + message.duration = String(object.duration); + } else { + message.duration = ""; + } + if (object.min_stake !== undefined && object.min_stake !== null) { + message.min_stake = String(object.min_stake); + } else { + message.min_stake = ""; + } + if (object.lock !== undefined && object.lock !== null) { + message.lock = String(object.lock); + } else { + message.lock = ""; + } + return message; + }, + + toJSON(message: MsgCreateStakingReward): unknown { + const obj: any = {}; + message.creator !== undefined && (obj.creator = message.creator); + message.prize_amount !== undefined && + (obj.prize_amount = message.prize_amount); + message.prize_denom !== undefined && + (obj.prize_denom = message.prize_denom); + message.staking_denom !== undefined && + (obj.staking_denom = message.staking_denom); + message.duration !== undefined && (obj.duration = message.duration); + message.min_stake !== undefined && (obj.min_stake = message.min_stake); + message.lock !== undefined && (obj.lock = message.lock); + return obj; + }, + + fromPartial( + object: DeepPartial + ): MsgCreateStakingReward { + const message = { ...baseMsgCreateStakingReward } as MsgCreateStakingReward; + if (object.creator !== undefined && object.creator !== null) { + message.creator = object.creator; + } else { + message.creator = ""; + } + if (object.prize_amount !== undefined && object.prize_amount !== null) { + message.prize_amount = object.prize_amount; + } else { + message.prize_amount = ""; + } + if (object.prize_denom !== undefined && object.prize_denom !== null) { + message.prize_denom = object.prize_denom; + } else { + message.prize_denom = ""; + } + if (object.staking_denom !== undefined && object.staking_denom !== null) { + message.staking_denom = object.staking_denom; + } else { + message.staking_denom = ""; + } + if (object.duration !== undefined && object.duration !== null) { + message.duration = object.duration; + } else { + message.duration = ""; + } + if (object.min_stake !== undefined && object.min_stake !== null) { + message.min_stake = object.min_stake; + } else { + message.min_stake = ""; + } + if (object.lock !== undefined && object.lock !== null) { + message.lock = object.lock; + } else { + message.lock = ""; + } + return message; + }, +}; + +const baseMsgCreateStakingRewardResponse: object = { reward_id: "" }; + +export const MsgCreateStakingRewardResponse = { + encode( + message: MsgCreateStakingRewardResponse, + writer: Writer = Writer.create() + ): Writer { + if (message.reward_id !== "") { + writer.uint32(10).string(message.reward_id); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): MsgCreateStakingRewardResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseMsgCreateStakingRewardResponse, + } as MsgCreateStakingRewardResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.reward_id = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgCreateStakingRewardResponse { + const message = { + ...baseMsgCreateStakingRewardResponse, + } as MsgCreateStakingRewardResponse; + if (object.reward_id !== undefined && object.reward_id !== null) { + message.reward_id = String(object.reward_id); + } else { + message.reward_id = ""; + } + return message; + }, + + toJSON(message: MsgCreateStakingRewardResponse): unknown { + const obj: any = {}; + message.reward_id !== undefined && (obj.reward_id = message.reward_id); + return obj; + }, + + fromPartial( + object: DeepPartial + ): MsgCreateStakingRewardResponse { + const message = { + ...baseMsgCreateStakingRewardResponse, + } as MsgCreateStakingRewardResponse; + if (object.reward_id !== undefined && object.reward_id !== null) { + message.reward_id = object.reward_id; + } else { + message.reward_id = ""; + } + return message; + }, +}; + +const baseMsgUpdateStakingReward: object = { + creator: "", + reward_id: "", + duration: "", +}; + +export const MsgUpdateStakingReward = { + encode( + message: MsgUpdateStakingReward, + writer: Writer = Writer.create() + ): Writer { + if (message.creator !== "") { + writer.uint32(10).string(message.creator); + } + if (message.reward_id !== "") { + writer.uint32(18).string(message.reward_id); + } + if (message.duration !== "") { + writer.uint32(26).string(message.duration); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MsgUpdateStakingReward { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgUpdateStakingReward } as MsgUpdateStakingReward; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.creator = reader.string(); + break; + case 2: + message.reward_id = reader.string(); + break; + case 3: + message.duration = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgUpdateStakingReward { + const message = { ...baseMsgUpdateStakingReward } as MsgUpdateStakingReward; + if (object.creator !== undefined && object.creator !== null) { + message.creator = String(object.creator); + } else { + message.creator = ""; + } + if (object.reward_id !== undefined && object.reward_id !== null) { + message.reward_id = String(object.reward_id); + } else { + message.reward_id = ""; + } + if (object.duration !== undefined && object.duration !== null) { + message.duration = String(object.duration); + } else { + message.duration = ""; + } + return message; + }, + + toJSON(message: MsgUpdateStakingReward): unknown { + const obj: any = {}; + message.creator !== undefined && (obj.creator = message.creator); + message.reward_id !== undefined && (obj.reward_id = message.reward_id); + message.duration !== undefined && (obj.duration = message.duration); + return obj; + }, + + fromPartial( + object: DeepPartial + ): MsgUpdateStakingReward { + const message = { ...baseMsgUpdateStakingReward } as MsgUpdateStakingReward; + if (object.creator !== undefined && object.creator !== null) { + message.creator = object.creator; + } else { + message.creator = ""; + } + if (object.reward_id !== undefined && object.reward_id !== null) { + message.reward_id = object.reward_id; + } else { + message.reward_id = ""; + } + if (object.duration !== undefined && object.duration !== null) { + message.duration = object.duration; + } else { + message.duration = ""; + } + return message; + }, +}; + +const baseMsgUpdateStakingRewardResponse: object = {}; + +export const MsgUpdateStakingRewardResponse = { + encode( + _: MsgUpdateStakingRewardResponse, + writer: Writer = Writer.create() + ): Writer { + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): MsgUpdateStakingRewardResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseMsgUpdateStakingRewardResponse, + } as MsgUpdateStakingRewardResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): MsgUpdateStakingRewardResponse { + const message = { + ...baseMsgUpdateStakingRewardResponse, + } as MsgUpdateStakingRewardResponse; + return message; + }, + + toJSON(_: MsgUpdateStakingRewardResponse): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial( + _: DeepPartial + ): MsgUpdateStakingRewardResponse { + const message = { + ...baseMsgUpdateStakingRewardResponse, + } as MsgUpdateStakingRewardResponse; + return message; + }, +}; + /** Msg defines the Msg service. */ -export interface Msg {} +export interface Msg { + CreateStakingReward( + request: MsgCreateStakingReward + ): Promise; + /** this line is used by starport scaffolding # proto/tx/rpc */ + UpdateStakingReward( + request: MsgUpdateStakingReward + ): Promise; +} export class MsgClientImpl implements Msg { private readonly rpc: Rpc; constructor(rpc: Rpc) { this.rpc = rpc; } + CreateStakingReward( + request: MsgCreateStakingReward + ): Promise { + const data = MsgCreateStakingReward.encode(request).finish(); + const promise = this.rpc.request( + "bze.v1.rewards.Msg", + "CreateStakingReward", + data + ); + return promise.then((data) => + MsgCreateStakingRewardResponse.decode(new Reader(data)) + ); + } + + UpdateStakingReward( + request: MsgUpdateStakingReward + ): Promise { + const data = MsgUpdateStakingReward.encode(request).finish(); + const promise = this.rpc.request( + "bze.v1.rewards.Msg", + "UpdateStakingReward", + data + ); + return promise.then((data) => + MsgUpdateStakingRewardResponse.decode(new Reader(data)) + ); + } } interface Rpc { @@ -18,3 +477,14 @@ interface Rpc { data: Uint8Array ): Promise; } + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/x/rewards/client/cli/query.go b/x/rewards/client/cli/query.go index 17de0956..068f6e0c 100644 --- a/x/rewards/client/cli/query.go +++ b/x/rewards/client/cli/query.go @@ -25,7 +25,9 @@ func GetQueryCmd(queryRoute string) *cobra.Command { } cmd.AddCommand(CmdQueryParams()) - // this line is used by starport scaffolding # 1 + cmd.AddCommand(CmdListStakingReward()) + cmd.AddCommand(CmdShowStakingReward()) +// this line is used by starport scaffolding # 1 return cmd } diff --git a/x/rewards/client/cli/query_staking_reward.go b/x/rewards/client/cli/query_staking_reward.go new file mode 100644 index 00000000..d11d1ecd --- /dev/null +++ b/x/rewards/client/cli/query_staking_reward.go @@ -0,0 +1,74 @@ +package cli + +import ( + "context" + + "github.com/spf13/cobra" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/bze-alphateam/bze/x/rewards/types" +) + +func CmdListStakingReward() *cobra.Command { + cmd := &cobra.Command{ + Use: "list-staking-reward", + Short: "list all StakingReward", + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx := client.GetClientContextFromCmd(cmd) + + pageReq, err := client.ReadPageRequest(cmd.Flags()) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + + params := &types.QueryAllStakingRewardRequest{ + Pagination: pageReq, + } + + res, err := queryClient.StakingRewardAll(context.Background(), params) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddPaginationFlagsToCmd(cmd, cmd.Use) + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +func CmdShowStakingReward() *cobra.Command { + cmd := &cobra.Command{ + Use: "show-staking-reward [reward-id]", + Short: "shows a StakingReward", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) (err error) { + clientCtx := client.GetClientContextFromCmd(cmd) + + queryClient := types.NewQueryClient(clientCtx) + + argRewardId := args[0] + + params := &types.QueryGetStakingRewardRequest{ + RewardId: argRewardId, + + } + + res, err := queryClient.StakingReward(context.Background(), params) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/rewards/client/cli/query_staking_reward_test.go b/x/rewards/client/cli/query_staking_reward_test.go new file mode 100644 index 00000000..7fb899fb --- /dev/null +++ b/x/rewards/client/cli/query_staking_reward_test.go @@ -0,0 +1,163 @@ +package cli_test + +import ( + "fmt" + "strconv" + "testing" + + "github.com/cosmos/cosmos-sdk/client/flags" + clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" + "github.com/stretchr/testify/require" + tmcli "github.com/tendermint/tendermint/libs/cli" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + + "github.com/bze-alphateam/bze/testutil/network" + "github.com/bze-alphateam/bze/testutil/nullify" + "github.com/bze-alphateam/bze/x/rewards/client/cli" + "github.com/bze-alphateam/bze/x/rewards/types" +) + +// Prevent strconv unused error +var _ = strconv.IntSize + +func networkWithStakingRewardObjects(t *testing.T, n int) (*network.Network, []types.StakingReward) { + t.Helper() + cfg := network.DefaultConfig() + state := types.GenesisState{} + require.NoError(t, cfg.Codec.UnmarshalJSON(cfg.GenesisState[types.ModuleName], &state)) + + for i := 0; i < n; i++ { + stakingReward := types.StakingReward{ + RewardId: strconv.Itoa(i), + + } + nullify.Fill(&stakingReward) + state.StakingRewardList = append(state.StakingRewardList, stakingReward) + } + buf, err := cfg.Codec.MarshalJSON(&state) + require.NoError(t, err) + cfg.GenesisState[types.ModuleName] = buf + return network.New(t, cfg), state.StakingRewardList +} + +func TestShowStakingReward(t *testing.T) { + net, objs := networkWithStakingRewardObjects(t, 2) + + ctx := net.Validators[0].ClientCtx + common := []string{ + fmt.Sprintf("--%s=json", tmcli.OutputFlag), + } + for _, tc := range []struct { + desc string + idRewardId string + + args []string + err error + obj types.StakingReward + }{ + { + desc: "found", + idRewardId: objs[0].RewardId, + + args: common, + obj: objs[0], + }, + { + desc: "not found", + idRewardId: strconv.Itoa(100000), + + args: common, + err: status.Error(codes.NotFound, "not found"), + }, + } { + t.Run(tc.desc, func(t *testing.T) { + args := []string{ + tc.idRewardId, + + } + args = append(args, tc.args...) + out, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdShowStakingReward(), args) + if tc.err != nil { + stat, ok := status.FromError(tc.err) + require.True(t, ok) + require.ErrorIs(t, stat.Err(), tc.err) + } else { + require.NoError(t, err) + var resp types.QueryGetStakingRewardResponse + require.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp)) + require.NotNil(t, resp.StakingReward) + require.Equal(t, + nullify.Fill(&tc.obj), + nullify.Fill(&resp.StakingReward), + ) + } + }) + } +} + +func TestListStakingReward(t *testing.T) { + net, objs := networkWithStakingRewardObjects(t, 5) + + ctx := net.Validators[0].ClientCtx + request := func(next []byte, offset, limit uint64, total bool) []string { + args := []string{ + fmt.Sprintf("--%s=json", tmcli.OutputFlag), + } + if next == nil { + args = append(args, fmt.Sprintf("--%s=%d", flags.FlagOffset, offset)) + } else { + args = append(args, fmt.Sprintf("--%s=%s", flags.FlagPageKey, next)) + } + args = append(args, fmt.Sprintf("--%s=%d", flags.FlagLimit, limit)) + if total { + args = append(args, fmt.Sprintf("--%s", flags.FlagCountTotal)) + } + return args + } + t.Run("ByOffset", func(t *testing.T) { + step := 2 + for i := 0; i < len(objs); i += step { + args := request(nil, uint64(i), uint64(step), false) + out, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdListStakingReward(), args) + require.NoError(t, err) + var resp types.QueryAllStakingRewardResponse + require.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp)) + require.LessOrEqual(t, len(resp.StakingReward), step) + require.Subset(t, + nullify.Fill(objs), + nullify.Fill(resp.StakingReward), + ) + } + }) + t.Run("ByKey", func(t *testing.T) { + step := 2 + var next []byte + for i := 0; i < len(objs); i += step { + args := request(next, 0, uint64(step), false) + out, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdListStakingReward(), args) + require.NoError(t, err) + var resp types.QueryAllStakingRewardResponse + require.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp)) + require.LessOrEqual(t, len(resp.StakingReward), step) + require.Subset(t, + nullify.Fill(objs), + nullify.Fill(resp.StakingReward), + ) + next = resp.Pagination.NextKey + } + }) + t.Run("Total", func(t *testing.T) { + args := request(nil, 0, uint64(len(objs)), true) + out, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdListStakingReward(), args) + require.NoError(t, err) + var resp types.QueryAllStakingRewardResponse + require.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp)) + require.NoError(t, err) + require.Equal(t, len(objs), int(resp.Pagination.Total)) + require.ElementsMatch(t, + nullify.Fill(objs), + nullify.Fill(resp.StakingReward), + ) + }) +} diff --git a/x/rewards/client/cli/tx.go b/x/rewards/client/cli/tx.go index 14b420bb..9976f1d0 100644 --- a/x/rewards/client/cli/tx.go +++ b/x/rewards/client/cli/tx.go @@ -30,6 +30,8 @@ func GetTxCmd() *cobra.Command { RunE: client.ValidateCmd, } + cmd.AddCommand(CmdCreateStakingReward()) + cmd.AddCommand(CmdUpdateStakingReward()) // this line is used by starport scaffolding # 1 return cmd diff --git a/x/rewards/client/cli/tx_staking_reward.go b/x/rewards/client/cli/tx_staking_reward.go new file mode 100644 index 00000000..484e8ce8 --- /dev/null +++ b/x/rewards/client/cli/tx_staking_reward.go @@ -0,0 +1,81 @@ +package cli + +import ( + "github.com/bze-alphateam/bze/x/rewards/types" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/client/tx" + "github.com/spf13/cobra" +) + +func CmdCreateStakingReward() *cobra.Command { + cmd := &cobra.Command{ + Use: "create-staking-reward [prize-amount] [prize-denom] [staking-denom] [duration] [min-stake] [lock]", + Short: "Create a new staking reward", + Args: cobra.ExactArgs(6), + RunE: func(cmd *cobra.Command, args []string) (err error) { + // Get indexes + amount := args[0] + denom := args[1] + stakingDenom := args[2] + duration := args[3] + minStake := args[4] + lock := args[4] + + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + msg := types.NewMsgCreateStakingReward( + clientCtx.GetFromAddress().String(), + amount, + denom, + stakingDenom, + duration, + minStake, + lock, + ) + if err := msg.ValidateBasic(); err != nil { + return err + } + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} + +func CmdUpdateStakingReward() *cobra.Command { + cmd := &cobra.Command{ + Use: "update-staking-reward [reward-id] [duration]", + Short: "Adds new funds to a staking reward for the specified duration", + Args: cobra.ExactArgs(2), + RunE: func(cmd *cobra.Command, args []string) (err error) { + // Get indexes + indexRewardId := args[0] + argDuration := args[1] + + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + msg := types.NewMsgUpdateStakingReward( + clientCtx.GetFromAddress().String(), + indexRewardId, + argDuration, + ) + if err := msg.ValidateBasic(); err != nil { + return err + } + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} diff --git a/x/rewards/client/cli/tx_staking_reward_test.go b/x/rewards/client/cli/tx_staking_reward_test.go new file mode 100644 index 00000000..a907f5d4 --- /dev/null +++ b/x/rewards/client/cli/tx_staking_reward_test.go @@ -0,0 +1,191 @@ +package cli_test + +import ( + "fmt" + "strconv" + "testing" + + "github.com/cosmos/cosmos-sdk/client/flags" + clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/stretchr/testify/require" + + "github.com/bze-alphateam/bze/testutil/network" + "github.com/bze-alphateam/bze/x/rewards/client/cli" +) + +// Prevent strconv unused error +var _ = strconv.IntSize + +func TestCreateStakingReward(t *testing.T) { + net := network.New(t) + val := net.Validators[0] + ctx := val.ClientCtx + + fields := []string{ "xyz", "xyz", "xyz", "xyz", "xyz", } + for _, tc := range []struct { + desc string + idRewardId string + + args []string + err error + code uint32 + }{ + { + idRewardId: strconv.Itoa(0), + + desc: "valid", + args: []string{ + fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(net.Config.BondDenom, sdk.NewInt(10))).String()), + }, + }, + } { + t.Run(tc.desc, func(t *testing.T) { + args := []string{ + tc.idRewardId, + + } + args = append(args, fields...) + args = append(args, tc.args...) + out, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdCreateStakingReward(), args) + if tc.err != nil { + require.ErrorIs(t, err, tc.err) + } else { + require.NoError(t, err) + var resp sdk.TxResponse + require.NoError(t, ctx.Codec.UnmarshalJSON(out.Bytes(), &resp)) + require.Equal(t, tc.code, resp.Code) + } + }) + } +} + +func TestUpdateStakingReward(t *testing.T) { + net := network.New(t) + val := net.Validators[0] + ctx := val.ClientCtx + + fields := []string{ "xyz", "xyz", "xyz", "xyz", "xyz", } + common := []string{ + fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(net.Config.BondDenom, sdk.NewInt(10))).String()), + } + args := []string{ + "0", + + } + args = append(args, fields...) + args = append(args, common...) + _, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdCreateStakingReward(), args) + require.NoError(t, err) + + for _, tc := range []struct { + desc string + idRewardId string + + args []string + code uint32 + err error + }{ + { + desc: "valid", + idRewardId: strconv.Itoa(0), + + args: common, + }, + { + desc: "key not found", + idRewardId: strconv.Itoa(100000), + + args: common, + code: sdkerrors.ErrKeyNotFound.ABCICode(), + }, + } { + t.Run(tc.desc, func(t *testing.T) { + args := []string{ + tc.idRewardId, + + } + args = append(args, fields...) + args = append(args, tc.args...) + out, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdUpdateStakingReward(), args) + if tc.err != nil { + require.ErrorIs(t, err, tc.err) + } else { + require.NoError(t, err) + var resp sdk.TxResponse + require.NoError(t, ctx.Codec.UnmarshalJSON(out.Bytes(), &resp)) + require.Equal(t, tc.code, resp.Code) + } + }) + } +} + +func TestDeleteStakingReward(t *testing.T) { + net := network.New(t) + + val := net.Validators[0] + ctx := val.ClientCtx + + fields := []string{ "xyz", "xyz", "xyz", "xyz", "xyz", } + common := []string{ + fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(net.Config.BondDenom, sdk.NewInt(10))).String()), + } + args := []string{ + "0", + + } + args = append(args, fields...) + args = append(args, common...) + _, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdCreateStakingReward(), args) + require.NoError(t, err) + + for _, tc := range []struct { + desc string + idRewardId string + + args []string + code uint32 + err error + }{ + { + desc: "valid", + idRewardId: strconv.Itoa(0), + + args: common, + }, + { + desc: "key not found", + idRewardId: strconv.Itoa(100000), + + args: common, + code: sdkerrors.ErrKeyNotFound.ABCICode(), + }, + } { + t.Run(tc.desc, func(t *testing.T) { + args := []string{ + tc.idRewardId, + + } + args = append(args, tc.args...) + out, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdDeleteStakingReward(), args) + if tc.err != nil { + require.ErrorIs(t, err, tc.err) + } else { + require.NoError(t, err) + var resp sdk.TxResponse + require.NoError(t, ctx.Codec.UnmarshalJSON(out.Bytes(), &resp)) + require.Equal(t, tc.code, resp.Code) + } + }) + } +} diff --git a/x/rewards/genesis.go b/x/rewards/genesis.go index 9aeb823a..df70b7e4 100644 --- a/x/rewards/genesis.go +++ b/x/rewards/genesis.go @@ -9,8 +9,14 @@ import ( // InitGenesis initializes the capability module's state from a provided genesis // state. func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) { + // Set all the stakingReward + for _, elem := range genState.StakingRewardList { + k.SetStakingReward(ctx, elem) + } // this line is used by starport scaffolding # genesis/module/init k.SetParams(ctx, genState.Params) + k.SetTradingRewardsCounter(ctx, genState.TradingRewardsCounter) + k.SetStakingRewardsCounter(ctx, genState.StakingRewardsCounter) } // ExportGenesis returns the capability module's exported genesis. @@ -18,6 +24,9 @@ func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState { genesis := types.DefaultGenesis() genesis.Params = k.GetParams(ctx) + genesis.StakingRewardList = k.GetAllStakingReward(ctx) + genesis.StakingRewardsCounter = k.GetStakingRewardsCounter(ctx) + genesis.TradingRewardsCounter = k.GetTradingRewardsCounter(ctx) // this line is used by starport scaffolding # genesis/module/export return genesis diff --git a/x/rewards/genesis_test.go b/x/rewards/genesis_test.go index f360aff3..4abbb02e 100644 --- a/x/rewards/genesis_test.go +++ b/x/rewards/genesis_test.go @@ -14,7 +14,15 @@ func TestGenesis(t *testing.T) { genesisState := types.GenesisState{ Params: types.DefaultParams(), - // this line is used by starport scaffolding # genesis/test/state + StakingRewardList: []types.StakingReward{ + { + RewardId: "0", +}, + { + RewardId: "1", +}, + }, + // this line is used by starport scaffolding # genesis/test/state } k, ctx := keepertest.RewardsKeeper(t) @@ -25,5 +33,6 @@ func TestGenesis(t *testing.T) { nullify.Fill(&genesisState) nullify.Fill(got) - // this line is used by starport scaffolding # genesis/test/assert + require.ElementsMatch(t, genesisState.StakingRewardList, got.StakingRewardList) +// this line is used by starport scaffolding # genesis/test/assert } diff --git a/x/rewards/handler.go b/x/rewards/handler.go index ee1a6c39..1f9b937a 100644 --- a/x/rewards/handler.go +++ b/x/rewards/handler.go @@ -11,12 +11,18 @@ import ( // NewHandler ... func NewHandler(k keeper.Keeper) sdk.Handler { - // this line is used by starport scaffolding # handler/msgServer + msgServer := keeper.NewMsgServerImpl(k) return func(ctx sdk.Context, msg sdk.Msg) (*sdk.Result, error) { ctx = ctx.WithEventManager(sdk.NewEventManager()) switch msg := msg.(type) { + case *types.MsgCreateStakingReward: + res, err := msgServer.CreateStakingReward(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) + case *types.MsgUpdateStakingReward: + res, err := msgServer.UpdateStakingReward(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) // this line is used by starport scaffolding # 1 default: errMsg := fmt.Sprintf("unrecognized %s message type: %T", types.ModuleName, msg) diff --git a/x/rewards/keeper/counter.go b/x/rewards/keeper/counter.go new file mode 100644 index 00000000..0a785c31 --- /dev/null +++ b/x/rewards/keeper/counter.go @@ -0,0 +1,65 @@ +package keeper + +import ( + "encoding/binary" + "github.com/bze-alphateam/bze/x/rewards/types" + "github.com/cosmos/cosmos-sdk/store/prefix" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +func (k Keeper) getCounterStore(ctx sdk.Context) sdk.KVStore { + return prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.CounterKey)) +} + +// GetCounter - returns a counter by key +func (k Keeper) GetCounter(ctx sdk.Context, key []byte) uint64 { + counterStore := k.getCounterStore(ctx) + counter := counterStore.Get(key) + if counter == nil { + return 0 + } + + return binary.BigEndian.Uint64(counter) +} + +// SetCounter - sets counter in storage on specified key +func (k Keeper) SetCounter(ctx sdk.Context, key []byte, counter uint64) { + counterStore := k.getCounterStore(ctx) + record := make([]byte, 8) + binary.BigEndian.PutUint64(record, counter) + + counterStore.Set(key, record) +} + +// incrementCounter - increments the specified counter and returns the new value +func (k Keeper) incrementCounter(ctx sdk.Context, key []byte) uint64 { + counter := k.GetCounter(ctx, key) + counter++ + k.SetCounter(ctx, key, counter) + + return counter +} + +func (k Keeper) GetStakingRewardsCounter(ctx sdk.Context) uint64 { + return k.GetCounter(ctx, types.StakingRewardCounterKey()) +} + +func (k Keeper) SetStakingRewardsCounter(ctx sdk.Context, counter uint64) { + k.SetCounter(ctx, types.StakingRewardCounterKey(), counter) +} + +func (k Keeper) incrementStakingRewardsCounter(ctx sdk.Context) uint64 { + return k.incrementCounter(ctx, types.StakingRewardCounterKey()) +} + +func (k Keeper) GetTradingRewardsCounter(ctx sdk.Context) uint64 { + return k.GetCounter(ctx, types.TradingRewardCounterKey()) +} + +func (k Keeper) SetTradingRewardsCounter(ctx sdk.Context, counter uint64) { + k.SetCounter(ctx, types.TradingRewardCounterKey(), counter) +} + +func (k Keeper) incrementTradingRewardsCounter(ctx sdk.Context) uint64 { + return k.incrementCounter(ctx, types.TradingRewardCounterKey()) +} diff --git a/x/rewards/keeper/grpc_query_staking_reward.go b/x/rewards/keeper/grpc_query_staking_reward.go new file mode 100644 index 00000000..bb78e5ae --- /dev/null +++ b/x/rewards/keeper/grpc_query_staking_reward.go @@ -0,0 +1,57 @@ +package keeper + +import ( + "context" + + "github.com/bze-alphateam/bze/x/rewards/types" + "github.com/cosmos/cosmos-sdk/store/prefix" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/query" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +func (k Keeper) StakingRewardAll(c context.Context, req *types.QueryAllStakingRewardRequest) (*types.QueryAllStakingRewardResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + + var stakingRewards []types.StakingReward + ctx := sdk.UnwrapSDKContext(c) + + store := ctx.KVStore(k.storeKey) + stakingRewardStore := prefix.NewStore(store, types.KeyPrefix(types.StakingRewardKeyPrefix)) + + pageRes, err := query.Paginate(stakingRewardStore, req.Pagination, func(key []byte, value []byte) error { + var stakingReward types.StakingReward + if err := k.cdc.Unmarshal(value, &stakingReward); err != nil { + return err + } + + stakingRewards = append(stakingRewards, stakingReward) + return nil + }) + + if err != nil { + return nil, status.Error(codes.Internal, err.Error()) + } + + return &types.QueryAllStakingRewardResponse{List: stakingRewards, Pagination: pageRes}, nil +} + +func (k Keeper) StakingReward(c context.Context, req *types.QueryGetStakingRewardRequest) (*types.QueryGetStakingRewardResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + ctx := sdk.UnwrapSDKContext(c) + + val, found := k.GetStakingReward( + ctx, + req.RewardId, + ) + if !found { + return nil, status.Error(codes.NotFound, "not found") + } + + return &types.QueryGetStakingRewardResponse{StakingReward: val}, nil +} diff --git a/x/rewards/keeper/grpc_query_staking_reward_test.go b/x/rewards/keeper/grpc_query_staking_reward_test.go new file mode 100644 index 00000000..d8488735 --- /dev/null +++ b/x/rewards/keeper/grpc_query_staking_reward_test.go @@ -0,0 +1,129 @@ +package keeper_test + +import ( + "strconv" + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/query" + "github.com/stretchr/testify/require" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + + "github.com/bze-alphateam/bze/x/rewards/types" + "github.com/bze-alphateam/bze/testutil/nullify" + keepertest "github.com/bze-alphateam/bze/testutil/keeper" +) + +// Prevent strconv unused error +var _ = strconv.IntSize + +func TestStakingRewardQuerySingle(t *testing.T) { + keeper, ctx := keepertest.RewardsKeeper(t) + wctx := sdk.WrapSDKContext(ctx) + msgs := createNStakingReward(keeper, ctx, 2) + for _, tc := range []struct { + desc string + request *types.QueryGetStakingRewardRequest + response *types.QueryGetStakingRewardResponse + err error + }{ + { + desc: "First", + request: &types.QueryGetStakingRewardRequest{ + RewardId: msgs[0].RewardId, + + }, + response: &types.QueryGetStakingRewardResponse{StakingReward: msgs[0]}, + }, + { + desc: "Second", + request: &types.QueryGetStakingRewardRequest{ + RewardId: msgs[1].RewardId, + + }, + response: &types.QueryGetStakingRewardResponse{StakingReward: msgs[1]}, + }, + { + desc: "KeyNotFound", + request: &types.QueryGetStakingRewardRequest{ + RewardId:strconv.Itoa(100000), + + }, + err: status.Error(codes.NotFound, "not found"), + }, + { + desc: "InvalidRequest", + err: status.Error(codes.InvalidArgument, "invalid request"), + }, + } { + t.Run(tc.desc, func(t *testing.T) { + response, err := keeper.StakingReward(wctx, tc.request) + if tc.err != nil { + require.ErrorIs(t, err, tc.err) + } else { + require.NoError(t, err) + require.Equal(t, + nullify.Fill(tc.response), + nullify.Fill(response), + ) + } + }) + } +} + +func TestStakingRewardQueryPaginated(t *testing.T) { + keeper, ctx := keepertest.RewardsKeeper(t) + wctx := sdk.WrapSDKContext(ctx) + msgs := createNStakingReward(keeper, ctx, 5) + + request := func(next []byte, offset, limit uint64, total bool) *types.QueryAllStakingRewardRequest { + return &types.QueryAllStakingRewardRequest{ + Pagination: &query.PageRequest{ + Key: next, + Offset: offset, + Limit: limit, + CountTotal: total, + }, + } + } + t.Run("ByOffset", func(t *testing.T) { + step := 2 + for i := 0; i < len(msgs); i += step { + resp, err := keeper.StakingRewardAll(wctx, request(nil, uint64(i), uint64(step), false)) + require.NoError(t, err) + require.LessOrEqual(t, len(resp.StakingReward), step) + require.Subset(t, + nullify.Fill(msgs), + nullify.Fill(resp.StakingReward), + ) + } + }) + t.Run("ByKey", func(t *testing.T) { + step := 2 + var next []byte + for i := 0; i < len(msgs); i += step { + resp, err := keeper.StakingRewardAll(wctx, request(next, 0, uint64(step), false)) + require.NoError(t, err) + require.LessOrEqual(t, len(resp.StakingReward), step) + require.Subset(t, + nullify.Fill(msgs), + nullify.Fill(resp.StakingReward), + ) + next = resp.Pagination.NextKey + } + }) + t.Run("Total", func(t *testing.T) { + resp, err := keeper.StakingRewardAll(wctx, request(nil, 0, 0, true)) + require.NoError(t, err) + require.Equal(t, len(msgs), int(resp.Pagination.Total)) + require.ElementsMatch(t, + nullify.Fill(msgs), + nullify.Fill(resp.StakingReward), + ) + }) + t.Run("InvalidRequest", func(t *testing.T) { + _, err := keeper.StakingRewardAll(wctx, nil) + require.ErrorIs(t, err, status.Error(codes.InvalidArgument, "invalid request")) + }) +} diff --git a/x/rewards/keeper/keeper.go b/x/rewards/keeper/keeper.go index 30343699..3c756721 100644 --- a/x/rewards/keeper/keeper.go +++ b/x/rewards/keeper/keeper.go @@ -49,3 +49,7 @@ func NewKeeper( func (k Keeper) Logger(ctx sdk.Context) log.Logger { return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName)) } + +func (k Keeper) smallZeroFillId(id uint64) string { + return fmt.Sprintf("%012d", id) +} diff --git a/x/rewards/keeper/msg_server_staking_reward.go b/x/rewards/keeper/msg_server_staking_reward.go new file mode 100644 index 00000000..a7734059 --- /dev/null +++ b/x/rewards/keeper/msg_server_staking_reward.go @@ -0,0 +1,99 @@ +package keeper + +import ( + "context" + "github.com/bze-alphateam/bze/x/rewards/types" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "strconv" +) + +func (k msgServer) CreateStakingReward(goCtx context.Context, msg *types.MsgCreateStakingReward) (*types.MsgCreateStakingRewardResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + if msg == nil { + return nil, sdkerrors.ErrInvalidRequest + } + + stakingReward, err := msg.ToStakingReward() + if err != nil { + return nil, err + } + + //check denoms + ok := k.bankKeeper.HasSupply(ctx, stakingReward.StakingDenom) + if !ok { + return nil, types.ErrInvalidStakingDenom + } + ok = k.bankKeeper.HasSupply(ctx, stakingReward.PrizeDenom) + if !ok { + return nil, types.ErrInvalidPrizeDenom + } + + //capture the total value of prizes + //the prize amount needs to be multiplied by duration + err = k.captureStakingRewardCoins(ctx, msg.Creator, stakingReward.PrizeDenom, stakingReward.PrizeAmount, int64(stakingReward.Duration)) + if err != nil { + return nil, err + } + + //add ID + stakingReward.RewardId = k.smallZeroFillId(k.GetStakingRewardsCounter(ctx)) + k.SetStakingReward( + ctx, + stakingReward, + ) + + return &types.MsgCreateStakingRewardResponse{RewardId: stakingReward.RewardId}, nil +} + +func (k msgServer) UpdateStakingReward(goCtx context.Context, msg *types.MsgUpdateStakingReward) (*types.MsgUpdateStakingRewardResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + if msg == nil { + return nil, sdkerrors.ErrInvalidRequest + } + + stakingReward, isFound := k.GetStakingReward(ctx, msg.RewardId) + if !isFound { + return nil, sdkerrors.Wrap(sdkerrors.ErrKeyNotFound, "staking reward not found") + } + + durationInt, err := strconv.ParseInt(msg.Duration, 10, 32) + if err != nil { + return nil, sdkerrors.Wrapf(types.ErrInvalidDuration, "could not convert duration to int: %s", err.Error()) + } + + if durationInt <= 0 { + return nil, types.ErrInvalidDuration + } + + err = k.captureStakingRewardCoins(ctx, msg.Creator, stakingReward.PrizeDenom, stakingReward.PrizeAmount, durationInt) + if err != nil { + return nil, err + } + + stakingReward.Duration += uint32(durationInt) + k.SetStakingReward(ctx, stakingReward) + + return &types.MsgUpdateStakingRewardResponse{}, nil +} + +func (k msgServer) captureStakingRewardCoins(ctx sdk.Context, creator, denom string, amount, duration int64) error { + acc, err := sdk.AccAddressFromBech32(creator) + if err != nil { + return err + } + + toCapture := sdk.NewCoin(denom, sdk.NewInt(amount)) + toCapture.Amount.MulRaw(duration) + if !toCapture.IsPositive() { + //should never happen + return sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "calculated amount to capture is not positive") + } + + err = k.bankKeeper.SendCoinsFromAccountToModule(ctx, acc, types.ModuleName, sdk.NewCoins(toCapture)) + if err != nil { + return err + } + + return nil +} diff --git a/x/rewards/keeper/msg_server_staking_reward_test.go b/x/rewards/keeper/msg_server_staking_reward_test.go new file mode 100644 index 00000000..a6bf514c --- /dev/null +++ b/x/rewards/keeper/msg_server_staking_reward_test.go @@ -0,0 +1,154 @@ +package keeper_test + +import ( + "strconv" + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/stretchr/testify/require" + + keepertest "github.com/bze-alphateam/bze/testutil/keeper" + "github.com/bze-alphateam/bze/x/rewards/keeper" + "github.com/bze-alphateam/bze/x/rewards/types" +) + +// Prevent strconv unused error +var _ = strconv.IntSize + +func TestStakingRewardMsgServerCreate(t *testing.T) { + k, ctx := keepertest.RewardsKeeper(t) + srv := keeper.NewMsgServerImpl(*k) + wctx := sdk.WrapSDKContext(ctx) + creator := "A" + for i := 0; i < 5; i++ { + expected := &types.MsgCreateStakingReward{Creator: creator, + RewardId: strconv.Itoa(i), + + } + _, err := srv.CreateStakingReward(wctx, expected) + require.NoError(t, err) + rst, found := k.GetStakingReward(ctx, + expected.RewardId, + + ) + require.True(t, found) + require.Equal(t, expected.Creator, rst.Creator) + } +} + +func TestStakingRewardMsgServerUpdate(t *testing.T) { + creator := "A" + + for _, tc := range []struct { + desc string + request *types.MsgUpdateStakingReward + err error + }{ + { + desc: "Completed", + request: &types.MsgUpdateStakingReward{Creator: creator, + RewardId: strconv.Itoa(0), + + }, + }, + { + desc: "Unauthorized", + request: &types.MsgUpdateStakingReward{Creator: "B", + RewardId: strconv.Itoa(0), + + }, + err: sdkerrors.ErrUnauthorized, + }, + { + desc: "KeyNotFound", + request: &types.MsgUpdateStakingReward{Creator: creator, + RewardId: strconv.Itoa(100000), + + }, + err: sdkerrors.ErrKeyNotFound, + }, + } { + t.Run(tc.desc, func(t *testing.T) { + k, ctx := keepertest.RewardsKeeper(t) + srv := keeper.NewMsgServerImpl(*k) + wctx := sdk.WrapSDKContext(ctx) + expected := &types.MsgCreateStakingReward{Creator: creator, + RewardId: strconv.Itoa(0), + + } + _, err := srv.CreateStakingReward(wctx, expected) + require.NoError(t, err) + + _, err = srv.UpdateStakingReward(wctx, tc.request) + if tc.err != nil { + require.ErrorIs(t, err, tc.err) + } else { + require.NoError(t, err) + rst, found := k.GetStakingReward(ctx, + expected.RewardId, + + ) + require.True(t, found) + require.Equal(t, expected.Creator, rst.Creator) + } + }) + } +} + +func TestStakingRewardMsgServerDelete(t *testing.T) { + creator := "A" + + for _, tc := range []struct { + desc string + request *types.MsgDeleteStakingReward + err error + }{ + { + desc: "Completed", + request: &types.MsgDeleteStakingReward{Creator: creator, + RewardId: strconv.Itoa(0), + + }, + }, + { + desc: "Unauthorized", + request: &types.MsgDeleteStakingReward{Creator: "B", + RewardId: strconv.Itoa(0), + + }, + err: sdkerrors.ErrUnauthorized, + }, + { + desc: "KeyNotFound", + request: &types.MsgDeleteStakingReward{Creator: creator, + RewardId: strconv.Itoa(100000), + + }, + err: sdkerrors.ErrKeyNotFound, + }, + } { + t.Run(tc.desc, func(t *testing.T) { + k, ctx := keepertest.RewardsKeeper(t) + srv := keeper.NewMsgServerImpl(*k) + wctx := sdk.WrapSDKContext(ctx) + + _, err := srv.CreateStakingReward(wctx, &types.MsgCreateStakingReward{Creator: creator, + RewardId: strconv.Itoa(0), + + }) + require.NoError(t, err) + _, err = srv.DeleteStakingReward(wctx, tc.request) + if tc.err != nil { + require.ErrorIs(t, err, tc.err) + } else { + require.NoError(t, err) + _, found := k.GetStakingReward(ctx, + tc.request.RewardId, + + ) + require.False(t, found) + } + }) + } +} diff --git a/x/rewards/keeper/staking_reward.go b/x/rewards/keeper/staking_reward.go new file mode 100644 index 00000000..304c2fa1 --- /dev/null +++ b/x/rewards/keeper/staking_reward.go @@ -0,0 +1,51 @@ +package keeper + +import ( + "github.com/bze-alphateam/bze/x/rewards/types" + "github.com/cosmos/cosmos-sdk/store/prefix" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// SetStakingReward set a specific stakingReward in the store from its index +func (k Keeper) SetStakingReward(ctx sdk.Context, stakingReward types.StakingReward) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.StakingRewardKeyPrefix)) + b := k.cdc.MustMarshal(&stakingReward) + store.Set(types.StakingRewardKey(stakingReward.RewardId), b) + + k.incrementStakingRewardsCounter(ctx) +} + +// GetStakingReward returns a stakingReward from its index +func (k Keeper) GetStakingReward(ctx sdk.Context, rewardId string) (val types.StakingReward, found bool) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.StakingRewardKeyPrefix)) + + b := store.Get(types.StakingRewardKey(rewardId)) + if b == nil { + return val, false + } + + k.cdc.MustUnmarshal(b, &val) + return val, true +} + +// RemoveStakingReward removes a stakingReward from the store +func (k Keeper) RemoveStakingReward(ctx sdk.Context, rewardId string) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.StakingRewardKeyPrefix)) + store.Delete(types.StakingRewardKey(rewardId)) +} + +// GetAllStakingReward returns all stakingReward +func (k Keeper) GetAllStakingReward(ctx sdk.Context) (list []types.StakingReward) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.StakingRewardKeyPrefix)) + iterator := sdk.KVStorePrefixIterator(store, []byte{}) + + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + var val types.StakingReward + k.cdc.MustUnmarshal(iterator.Value(), &val) + list = append(list, val) + } + + return +} diff --git a/x/rewards/keeper/staking_reward_test.go b/x/rewards/keeper/staking_reward_test.go new file mode 100644 index 00000000..4aea0099 --- /dev/null +++ b/x/rewards/keeper/staking_reward_test.go @@ -0,0 +1,66 @@ +package keeper_test + +import ( + "strconv" + "testing" + + "github.com/bze-alphateam/bze/x/rewards/keeper" + "github.com/bze-alphateam/bze/x/rewards/types" + keepertest "github.com/bze-alphateam/bze/testutil/keeper" + "github.com/bze-alphateam/bze/testutil/nullify" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" +) + +// Prevent strconv unused error +var _ = strconv.IntSize + +func createNStakingReward(keeper *keeper.Keeper, ctx sdk.Context, n int) []types.StakingReward { + items := make([]types.StakingReward, n) + for i := range items { + items[i].RewardId = strconv.Itoa(i) + + keeper.SetStakingReward(ctx, items[i]) + } + return items +} + +func TestStakingRewardGet(t *testing.T) { + keeper, ctx := keepertest.RewardsKeeper(t) + items := createNStakingReward(keeper, ctx, 10) + for _, item := range items { + rst, found := keeper.GetStakingReward(ctx, + item.RewardId, + + ) + require.True(t, found) + require.Equal(t, + nullify.Fill(&item), + nullify.Fill(&rst), + ) + } +} +func TestStakingRewardRemove(t *testing.T) { + keeper, ctx := keepertest.RewardsKeeper(t) + items := createNStakingReward(keeper, ctx, 10) + for _, item := range items { + keeper.RemoveStakingReward(ctx, + item.RewardId, + + ) + _, found := keeper.GetStakingReward(ctx, + item.RewardId, + + ) + require.False(t, found) + } +} + +func TestStakingRewardGetAll(t *testing.T) { + keeper, ctx := keepertest.RewardsKeeper(t) + items := createNStakingReward(keeper, ctx, 10) + require.ElementsMatch(t, + nullify.Fill(items), + nullify.Fill(keeper.GetAllStakingReward(ctx)), + ) +} diff --git a/x/rewards/module_simulation.go b/x/rewards/module_simulation.go index 391463e9..76cf8eae 100644 --- a/x/rewards/module_simulation.go +++ b/x/rewards/module_simulation.go @@ -24,7 +24,19 @@ var ( ) const ( -// this line is used by starport scaffolding # simapp/module/const + opWeightMsgCreateStakingReward = "op_weight_msg_staking_reward" + // TODO: Determine the simulation weight value + defaultWeightMsgCreateStakingReward int = 100 + + opWeightMsgUpdateStakingReward = "op_weight_msg_staking_reward" + // TODO: Determine the simulation weight value + defaultWeightMsgUpdateStakingReward int = 100 + + opWeightMsgDeleteStakingReward = "op_weight_msg_staking_reward" + // TODO: Determine the simulation weight value + defaultWeightMsgDeleteStakingReward int = 100 + + // this line is used by starport scaffolding # simapp/module/const ) // GenerateGenesisState creates a randomized GenState of the module @@ -35,6 +47,14 @@ func (AppModule) GenerateGenesisState(simState *module.SimulationState) { } rewardsGenesis := types.GenesisState{ Params: types.DefaultParams(), + StakingRewardList: []types.StakingReward{ + { + RewardId: "0", + }, + { + RewardId: "1", + }, + }, // this line is used by starport scaffolding # simapp/module/genesisState } simState.GenState[types.ModuleName] = simState.Cdc.MustMarshalJSON(&rewardsGenesis) @@ -65,6 +85,39 @@ func (am AppModule) RegisterStoreDecoder(_ sdk.StoreDecoderRegistry) {} func (am AppModule) WeightedOperations(simState module.SimulationState) []simtypes.WeightedOperation { operations := make([]simtypes.WeightedOperation, 0) + var weightMsgCreateStakingReward int + simState.AppParams.GetOrGenerate(simState.Cdc, opWeightMsgCreateStakingReward, &weightMsgCreateStakingReward, nil, + func(_ *rand.Rand) { + weightMsgCreateStakingReward = defaultWeightMsgCreateStakingReward + }, + ) + operations = append(operations, simulation.NewWeightedOperation( + weightMsgCreateStakingReward, + rewardssimulation.SimulateMsgCreateStakingReward(am.accountKeeper, am.bankKeeper, am.keeper), + )) + + var weightMsgUpdateStakingReward int + simState.AppParams.GetOrGenerate(simState.Cdc, opWeightMsgUpdateStakingReward, &weightMsgUpdateStakingReward, nil, + func(_ *rand.Rand) { + weightMsgUpdateStakingReward = defaultWeightMsgUpdateStakingReward + }, + ) + operations = append(operations, simulation.NewWeightedOperation( + weightMsgUpdateStakingReward, + rewardssimulation.SimulateMsgUpdateStakingReward(am.accountKeeper, am.bankKeeper, am.keeper), + )) + + var weightMsgDeleteStakingReward int + simState.AppParams.GetOrGenerate(simState.Cdc, opWeightMsgDeleteStakingReward, &weightMsgDeleteStakingReward, nil, + func(_ *rand.Rand) { + weightMsgDeleteStakingReward = defaultWeightMsgDeleteStakingReward + }, + ) + operations = append(operations, simulation.NewWeightedOperation( + weightMsgDeleteStakingReward, + rewardssimulation.SimulateMsgDeleteStakingReward(am.accountKeeper, am.bankKeeper, am.keeper), + )) + // this line is used by starport scaffolding # simapp/module/operation return operations diff --git a/x/rewards/simulation/staking_reward.go b/x/rewards/simulation/staking_reward.go new file mode 100644 index 00000000..8b788775 --- /dev/null +++ b/x/rewards/simulation/staking_reward.go @@ -0,0 +1,117 @@ +package simulation + +import ( + "math/rand" + "strconv" + + "github.com/bze-alphateam/bze/x/rewards/keeper" + "github.com/bze-alphateam/bze/x/rewards/types" + "github.com/cosmos/cosmos-sdk/baseapp" + simappparams "github.com/cosmos/cosmos-sdk/simapp/params" + sdk "github.com/cosmos/cosmos-sdk/types" + simtypes "github.com/cosmos/cosmos-sdk/types/simulation" + "github.com/cosmos/cosmos-sdk/x/simulation" +) + +// Prevent strconv unused error +var _ = strconv.IntSize + +func SimulateMsgCreateStakingReward( + ak types.AccountKeeper, + bk types.BankKeeper, + k keeper.Keeper, +) simtypes.Operation { + return func(r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, + ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { + simAccount, _ := simtypes.RandomAcc(r, accs) + + msg := &types.MsgCreateStakingReward{ + Creator: simAccount.Address.String(), + } + + txCtx := simulation.OperationInput{ + R: r, + App: app, + TxGen: simappparams.MakeTestEncodingConfig().TxConfig, + Cdc: nil, + Msg: msg, + MsgType: msg.Type(), + Context: ctx, + SimAccount: simAccount, + ModuleName: types.ModuleName, + CoinsSpentInMsg: sdk.NewCoins(), + AccountKeeper: ak, + Bankkeeper: bk, + } + return simulation.GenAndDeliverTxWithRandFees(txCtx) + } +} + +func SimulateMsgUpdateStakingReward( + ak types.AccountKeeper, + bk types.BankKeeper, + k keeper.Keeper, +) simtypes.Operation { + return func(r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, + ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { + var ( + simAccount = simtypes.Account{} + stakingReward = types.StakingReward{} + msg = &types.MsgUpdateStakingReward{} + ) + msg.Creator = simAccount.Address.String() + + msg.RewardId = stakingReward.RewardId + + txCtx := simulation.OperationInput{ + R: r, + App: app, + TxGen: simappparams.MakeTestEncodingConfig().TxConfig, + Cdc: nil, + Msg: msg, + MsgType: msg.Type(), + Context: ctx, + SimAccount: simAccount, + ModuleName: types.ModuleName, + CoinsSpentInMsg: sdk.NewCoins(), + AccountKeeper: ak, + Bankkeeper: bk, + } + return simulation.GenAndDeliverTxWithRandFees(txCtx) + } +} + +func SimulateMsgDeleteStakingReward( + ak types.AccountKeeper, + bk types.BankKeeper, + k keeper.Keeper, +) simtypes.Operation { + return func(r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, + ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { + var ( + simAccount = simtypes.Account{} + stakingReward = types.StakingReward{} + msg = &types.MsgUpdateStakingReward{} + ) + + msg.Creator = simAccount.Address.String() + + msg.RewardId = stakingReward.RewardId + + txCtx := simulation.OperationInput{ + R: r, + App: app, + TxGen: simappparams.MakeTestEncodingConfig().TxConfig, + Cdc: nil, + Msg: msg, + MsgType: msg.Type(), + Context: ctx, + SimAccount: simAccount, + ModuleName: types.ModuleName, + CoinsSpentInMsg: sdk.NewCoins(), + AccountKeeper: ak, + Bankkeeper: bk, + } + return simulation.GenAndDeliverTxWithRandFees(txCtx) + } +} diff --git a/x/rewards/types/codec.go b/x/rewards/types/codec.go index 844157a8..45c14fcc 100644 --- a/x/rewards/types/codec.go +++ b/x/rewards/types/codec.go @@ -3,15 +3,21 @@ 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 + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/msgservice" ) func RegisterCodec(cdc *codec.LegacyAmino) { + cdc.RegisterConcrete(&MsgCreateStakingReward{}, "rewards/CreateStakingReward", nil) + cdc.RegisterConcrete(&MsgUpdateStakingReward{}, "rewards/UpdateStakingReward", nil) // this line is used by starport scaffolding # 2 } func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { + registry.RegisterImplementations((*sdk.Msg)(nil), + &MsgCreateStakingReward{}, + &MsgUpdateStakingReward{}, + ) // this line is used by starport scaffolding # 3 msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) diff --git a/x/rewards/types/errors.go b/x/rewards/types/errors.go index 6933be85..e650fb25 100644 --- a/x/rewards/types/errors.go +++ b/x/rewards/types/errors.go @@ -8,5 +8,10 @@ import ( // x/rewards module sentinel errors var ( - ErrSample = sdkerrors.Register(ModuleName, 1100, "sample error") + ErrInvalidPrizeAmount = sdkerrors.Register(ModuleName, 5000, "invalid prize amount") + ErrInvalidPrizeDenom = sdkerrors.Register(ModuleName, 5002, "invalid prize denom") + ErrInvalidStakingDenom = sdkerrors.Register(ModuleName, 5003, "invalid staking denom") + ErrInvalidMinStake = sdkerrors.Register(ModuleName, 5004, "invalid min stake") + ErrInvalidDuration = sdkerrors.Register(ModuleName, 5005, "invalid duration") + ErrInvalidLockingTime = sdkerrors.Register(ModuleName, 5006, "invalid staking reward lock") ) diff --git a/x/rewards/types/expected_keepers.go b/x/rewards/types/expected_keepers.go index d3f91662..2b07b802 100644 --- a/x/rewards/types/expected_keepers.go +++ b/x/rewards/types/expected_keepers.go @@ -18,5 +18,9 @@ type AccountKeeper interface { // BankKeeper defines the expected interface needed to retrieve account balances. type BankKeeper interface { SpendableCoins(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins + HasSupply(ctx sdk.Context, denom string) bool + + SendCoinsFromModuleToAccount(ctx sdk.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error + SendCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error // Methods imported from bank should be defined here } diff --git a/x/rewards/types/genesis.go b/x/rewards/types/genesis.go index 56921182..6e942730 100644 --- a/x/rewards/types/genesis.go +++ b/x/rewards/types/genesis.go @@ -1,11 +1,19 @@ package types +import ( + "fmt" + _ "github.com/cosmos/cosmos-sdk/x/auth/types" +) + // DefaultIndex is the default capability global index const DefaultIndex uint64 = 1 // DefaultGenesis returns the default Capability genesis state func DefaultGenesis() *GenesisState { return &GenesisState{ + StakingRewardList: []StakingReward{}, + StakingRewardsCounter: 0, + TradingRewardsCounter: 0, // this line is used by starport scaffolding # genesis/types/default Params: DefaultParams(), } @@ -14,6 +22,16 @@ func DefaultGenesis() *GenesisState { // Validate performs basic genesis state validation returning an error upon any // failure. func (gs GenesisState) Validate() error { + // Check for duplicated index in stakingReward + stakingRewardIndexMap := make(map[string]struct{}) + + for _, elem := range gs.StakingRewardList { + index := string(StakingRewardKey(elem.RewardId)) + if _, ok := stakingRewardIndexMap[index]; ok { + return fmt.Errorf("duplicated index for stakingReward") + } + stakingRewardIndexMap[index] = struct{}{} + } // this line is used by starport scaffolding # genesis/types/validate return gs.Params.Validate() diff --git a/x/rewards/types/genesis.pb.go b/x/rewards/types/genesis.pb.go index 90647d22..635ce7cc 100644 --- a/x/rewards/types/genesis.pb.go +++ b/x/rewards/types/genesis.pb.go @@ -25,7 +25,10 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // GenesisState defines the rewards module's genesis state. type GenesisState struct { - Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` + StakingRewardList []StakingReward `protobuf:"bytes,2,rep,name=staking_reward_list,json=stakingRewardList,proto3" json:"staking_reward_list"` + StakingRewardsCounter uint64 `protobuf:"varint,3,opt,name=staking_rewards_counter,json=stakingRewardsCounter,proto3" json:"staking_rewards_counter,omitempty"` + TradingRewardsCounter uint64 `protobuf:"varint,4,opt,name=trading_rewards_counter,json=tradingRewardsCounter,proto3" json:"trading_rewards_counter,omitempty"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -68,6 +71,27 @@ func (m *GenesisState) GetParams() Params { return Params{} } +func (m *GenesisState) GetStakingRewardList() []StakingReward { + if m != nil { + return m.StakingRewardList + } + return nil +} + +func (m *GenesisState) GetStakingRewardsCounter() uint64 { + if m != nil { + return m.StakingRewardsCounter + } + return 0 +} + +func (m *GenesisState) GetTradingRewardsCounter() uint64 { + if m != nil { + return m.TradingRewardsCounter + } + return 0 +} + func init() { proto.RegisterType((*GenesisState)(nil), "bze.v1.rewards.GenesisState") } @@ -75,20 +99,26 @@ func init() { func init() { proto.RegisterFile("rewards/genesis.proto", fileDescriptor_04e261dd19d07881) } var fileDescriptor_04e261dd19d07881 = []byte{ - // 194 bytes of a gzipped FileDescriptorProto + // 292 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x2d, 0x4a, 0x2d, 0x4f, 0x2c, 0x4a, 0x29, 0xd6, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x4b, 0xaa, 0x4a, 0xd5, 0x2b, 0x33, 0xd4, 0x83, 0xca, 0x4a, 0x89, 0xa4, 0xe7, 0xa7, 0xe7, 0x83, 0xa5, 0xf4, 0x41, 0x2c, 0x88, 0x2a, 0x29, 0x11, 0x98, 0xe6, 0x82, 0xc4, 0xa2, - 0xc4, 0x5c, 0xa8, 0x5e, 0x25, 0x17, 0x2e, 0x1e, 0x77, 0x88, 0x61, 0xc1, 0x25, 0x89, 0x25, 0xa9, - 0x42, 0x26, 0x5c, 0x6c, 0x10, 0x79, 0x09, 0x46, 0x05, 0x46, 0x0d, 0x6e, 0x23, 0x31, 0x3d, 0x54, - 0xc3, 0xf5, 0x02, 0xc0, 0xb2, 0x4e, 0x2c, 0x27, 0xee, 0xc9, 0x33, 0x04, 0x41, 0xd5, 0x3a, 0xb9, - 0x9d, 0x78, 0x24, 0xc7, 0x78, 0xe1, 0x91, 0x1c, 0xe3, 0x83, 0x47, 0x72, 0x8c, 0x13, 0x1e, 0xcb, - 0x31, 0x5c, 0x78, 0x2c, 0xc7, 0x70, 0xe3, 0xb1, 0x1c, 0x43, 0x94, 0x4e, 0x7a, 0x66, 0x49, 0x46, - 0x69, 0x92, 0x5e, 0x72, 0x7e, 0xae, 0x7e, 0x52, 0x55, 0xaa, 0x6e, 0x62, 0x4e, 0x41, 0x46, 0x62, - 0x49, 0x6a, 0x22, 0x98, 0xa7, 0x5f, 0xa1, 0x0f, 0x73, 0x54, 0x49, 0x65, 0x41, 0x6a, 0x71, 0x12, - 0x1b, 0xd8, 0x51, 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0xbc, 0x2b, 0x3c, 0x82, 0xe9, 0x00, - 0x00, 0x00, + 0xc4, 0x5c, 0xa8, 0x5e, 0x29, 0x19, 0x98, 0x68, 0x71, 0x49, 0x62, 0x76, 0x66, 0x5e, 0x7a, 0x3c, + 0x84, 0x0f, 0x91, 0x55, 0xea, 0x64, 0xe2, 0xe2, 0x71, 0x87, 0xd8, 0x15, 0x5c, 0x92, 0x58, 0x92, + 0x2a, 0x64, 0xc2, 0xc5, 0x06, 0xd1, 0x2e, 0xc1, 0xa8, 0xc0, 0xa8, 0xc1, 0x6d, 0x24, 0xa6, 0x87, + 0x6a, 0xb7, 0x5e, 0x00, 0x58, 0xd6, 0x89, 0xe5, 0xc4, 0x3d, 0x79, 0x86, 0x20, 0xa8, 0x5a, 0xa1, + 0x60, 0x2e, 0x61, 0x54, 0xe3, 0xe3, 0x73, 0x32, 0x8b, 0x4b, 0x24, 0x98, 0x14, 0x98, 0x35, 0xb8, + 0x8d, 0x64, 0xd1, 0x8d, 0x08, 0x86, 0x28, 0x0d, 0x02, 0x73, 0xa1, 0x26, 0x09, 0x16, 0x23, 0x0b, + 0xfa, 0x64, 0x16, 0x97, 0x08, 0x99, 0x71, 0x89, 0xa3, 0x1a, 0x5a, 0x1c, 0x9f, 0x9c, 0x5f, 0x9a, + 0x57, 0x92, 0x5a, 0x24, 0xc1, 0xac, 0xc0, 0xa8, 0xc1, 0x12, 0x24, 0x8a, 0xa2, 0xa7, 0xd8, 0x19, + 0x22, 0x09, 0xd2, 0x57, 0x52, 0x94, 0x98, 0x82, 0x4d, 0x1f, 0x0b, 0x44, 0x1f, 0x54, 0x1a, 0x55, + 0x9f, 0x93, 0xdb, 0x89, 0x47, 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, 0xc7, 0x38, + 0xe1, 0xb1, 0x1c, 0xc3, 0x85, 0xc7, 0x72, 0x0c, 0x37, 0x1e, 0xcb, 0x31, 0x44, 0xe9, 0xa4, 0x67, + 0x96, 0x64, 0x94, 0x26, 0xe9, 0x25, 0xe7, 0xe7, 0xea, 0x27, 0x55, 0xa5, 0xea, 0x26, 0xe6, 0x14, + 0x64, 0x24, 0x96, 0xa4, 0x26, 0x82, 0x79, 0xfa, 0x15, 0xfa, 0xb0, 0x20, 0x2e, 0xa9, 0x2c, 0x48, + 0x2d, 0x4e, 0x62, 0x03, 0x07, 0xad, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0xc3, 0xb1, 0x6e, 0x4a, + 0xcd, 0x01, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -111,6 +141,30 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.TradingRewardsCounter != 0 { + i = encodeVarintGenesis(dAtA, i, uint64(m.TradingRewardsCounter)) + i-- + dAtA[i] = 0x20 + } + if m.StakingRewardsCounter != 0 { + i = encodeVarintGenesis(dAtA, i, uint64(m.StakingRewardsCounter)) + i-- + dAtA[i] = 0x18 + } + if len(m.StakingRewardList) > 0 { + for iNdEx := len(m.StakingRewardList) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.StakingRewardList[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } { size, err := m.Params.MarshalToSizedBuffer(dAtA[:i]) if err != nil { @@ -143,6 +197,18 @@ func (m *GenesisState) Size() (n int) { _ = l l = m.Params.Size() n += 1 + l + sovGenesis(uint64(l)) + if len(m.StakingRewardList) > 0 { + for _, e := range m.StakingRewardList { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if m.StakingRewardsCounter != 0 { + n += 1 + sovGenesis(uint64(m.StakingRewardsCounter)) + } + if m.TradingRewardsCounter != 0 { + n += 1 + sovGenesis(uint64(m.TradingRewardsCounter)) + } return n } @@ -214,6 +280,78 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field StakingRewardList", 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 + } + m.StakingRewardList = append(m.StakingRewardList, StakingReward{}) + if err := m.StakingRewardList[len(m.StakingRewardList)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field StakingRewardsCounter", wireType) + } + m.StakingRewardsCounter = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.StakingRewardsCounter |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field TradingRewardsCounter", wireType) + } + m.TradingRewardsCounter = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGenesis + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.TradingRewardsCounter |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipGenesis(dAtA[iNdEx:]) diff --git a/x/rewards/types/genesis_test.go b/x/rewards/types/genesis_test.go index 1ad2960b..057f6b88 100644 --- a/x/rewards/types/genesis_test.go +++ b/x/rewards/types/genesis_test.go @@ -22,11 +22,33 @@ func TestGenesisState_Validate(t *testing.T) { desc: "valid genesis state", genState: &types.GenesisState{ - // this line is used by starport scaffolding # types/genesis/validField + StakingRewardList: []types.StakingReward{ + { + RewardId: "0", +}, + { + RewardId: "1", +}, +}, +// this line is used by starport scaffolding # types/genesis/validField }, valid: true, }, - // this line is used by starport scaffolding # types/genesis/testcase + { + desc: "duplicated stakingReward", + genState: &types.GenesisState{ + StakingRewardList: []types.StakingReward{ + { + RewardId: "0", +}, + { + RewardId: "0", +}, + }, + }, + valid: false, +}, +// this line is used by starport scaffolding # types/genesis/testcase } { t.Run(tc.desc, func(t *testing.T) { err := tc.genState.Validate() diff --git a/x/rewards/types/key_staking_reward.go b/x/rewards/types/key_staking_reward.go new file mode 100644 index 00000000..b927071f --- /dev/null +++ b/x/rewards/types/key_staking_reward.go @@ -0,0 +1,25 @@ +package types + +import "encoding/binary" + +var _ binary.ByteOrder + +const ( + // StakingRewardKeyPrefix is the prefix to retrieve all StakingReward + StakingRewardKeyPrefix = "sr/value/" + TradingRewardKeyPrefix = "tr/value/" + CounterKey = "sr/c/" +) + +// StakingRewardKey returns the store key to retrieve a StakingReward from the index fields +func StakingRewardKey(rewardId string) []byte { + return []byte(rewardId) +} + +func StakingRewardCounterKey() []byte { + return []byte{1} +} + +func TradingRewardCounterKey() []byte { + return []byte{2} +} diff --git a/x/rewards/types/messages_staking_reward.go b/x/rewards/types/messages_staking_reward.go new file mode 100644 index 00000000..0ed13095 --- /dev/null +++ b/x/rewards/types/messages_staking_reward.go @@ -0,0 +1,175 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "strconv" +) + +const ( + TypeMsgCreateStakingReward = "create_staking_reward" + TypeMsgUpdateStakingReward = "update_staking_reward" + + tenYearsInDays = 365 * 10 +) + +var _ sdk.Msg = &MsgCreateStakingReward{} + +func NewMsgCreateStakingReward( + creator string, + prizeAmount string, + prizeDenom string, + stakingDenom string, + duration string, + minStake string, + lock string, + +) *MsgCreateStakingReward { + return &MsgCreateStakingReward{ + Creator: creator, + PrizeAmount: prizeAmount, + PrizeDenom: prizeDenom, + StakingDenom: stakingDenom, + Duration: duration, + MinStake: minStake, + Lock: lock, + } +} + +func (msg *MsgCreateStakingReward) Route() string { + return RouterKey +} + +func (msg *MsgCreateStakingReward) Type() string { + return TypeMsgCreateStakingReward +} + +func (msg *MsgCreateStakingReward) GetSigners() []sdk.AccAddress { + creator, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + panic(err) + } + return []sdk.AccAddress{creator} +} + +func (msg *MsgCreateStakingReward) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(msg) + return sdk.MustSortJSON(bz) +} + +func (msg *MsgCreateStakingReward) ToStakingReward() (StakingReward, error) { + sr := StakingReward{} + + amtInt, ok := sdk.NewIntFromString(msg.PrizeAmount) + if !ok { + return sr, sdkerrors.Wrapf(ErrInvalidPrizeAmount, "could not convert order amount") + } + if !amtInt.IsPositive() { + return sr, sdkerrors.Wrapf(ErrInvalidPrizeAmount, "amount should be greater than 0") + } + sr.PrizeAmount = amtInt.Int64() + + if msg.PrizeDenom == "" { + return sr, ErrInvalidPrizeDenom + } + sr.PrizeDenom = msg.PrizeDenom + + if msg.StakingDenom == "" { + return sr, ErrInvalidStakingDenom + } + sr.StakingDenom = msg.StakingDenom + + minStake, ok := sdk.NewIntFromString(msg.MinStake) + if minStake.IsNegative() { + return sr, ErrInvalidMinStake + } + sr.MinStake = minStake.Uint64() + + durationInt, err := strconv.Atoi(msg.Duration) + if err != nil { + return sr, sdkerrors.Wrapf(ErrInvalidDuration, "could not convert duration to int: %s", err.Error()) + } + if durationInt <= 0 || durationInt > tenYearsInDays { + return sr, ErrInvalidDuration + } + sr.Duration = uint32(durationInt) + + lockInt, err := strconv.Atoi(msg.Lock) + if err != nil { + return sr, sdkerrors.Wrapf(ErrInvalidLockingTime, "could not convert string to int: %s", err.Error()) + } + if lockInt <= 0 || lockInt > tenYearsInDays { + return sr, ErrInvalidLockingTime + } + sr.Lock = uint32(lockInt) + + return sr, nil +} + +func (msg *MsgCreateStakingReward) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err) + } + + _, err = msg.ToStakingReward() + if err != nil { + return err + } + + return nil +} + +var _ sdk.Msg = &MsgUpdateStakingReward{} + +func NewMsgUpdateStakingReward( + creator string, + rewardId string, + duration string, + +) *MsgUpdateStakingReward { + return &MsgUpdateStakingReward{ + Creator: creator, + RewardId: rewardId, + Duration: duration, + } +} + +func (msg *MsgUpdateStakingReward) Route() string { + return RouterKey +} + +func (msg *MsgUpdateStakingReward) Type() string { + return TypeMsgUpdateStakingReward +} + +func (msg *MsgUpdateStakingReward) GetSigners() []sdk.AccAddress { + creator, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + panic(err) + } + return []sdk.AccAddress{creator} +} + +func (msg *MsgUpdateStakingReward) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(msg) + return sdk.MustSortJSON(bz) +} + +func (msg *MsgUpdateStakingReward) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err) + } + + durationInt, err := strconv.ParseUint(msg.Duration, 10, 32) + if err != nil { + return sdkerrors.Wrapf(ErrInvalidDuration, "could not convert duration to int: %s", err.Error()) + } + + if durationInt <= 0 { + return ErrInvalidDuration + } + + return nil +} diff --git a/x/rewards/types/messages_staking_reward_test.go b/x/rewards/types/messages_staking_reward_test.go new file mode 100644 index 00000000..c95d5358 --- /dev/null +++ b/x/rewards/types/messages_staking_reward_test.go @@ -0,0 +1,102 @@ +package types + +import ( + "testing" + + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/stretchr/testify/require" + "github.com/bze-alphateam/bze/testutil/sample" +) + +func TestMsgCreateStakingReward_ValidateBasic(t *testing.T) { + tests := []struct { + name string + msg MsgCreateStakingReward + err error + }{ + { + name: "invalid address", + msg: MsgCreateStakingReward{ + Creator: "invalid_address", + }, + err: sdkerrors.ErrInvalidAddress, + }, { + name: "valid address", + msg: MsgCreateStakingReward{ + Creator: sample.AccAddress(), + }, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + err := tt.msg.ValidateBasic() + if tt.err != nil { + require.ErrorIs(t, err, tt.err) + return + } + require.NoError(t, err) + }) + } +} + +func TestMsgUpdateStakingReward_ValidateBasic(t *testing.T) { + tests := []struct { + name string + msg MsgUpdateStakingReward + err error + }{ + { + name: "invalid address", + msg: MsgUpdateStakingReward{ + Creator: "invalid_address", + }, + err: sdkerrors.ErrInvalidAddress, + }, { + name: "valid address", + msg: MsgUpdateStakingReward{ + Creator: sample.AccAddress(), + }, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + err := tt.msg.ValidateBasic() + if tt.err != nil { + require.ErrorIs(t, err, tt.err) + return + } + require.NoError(t, err) + }) + } +} + +func TestMsgDeleteStakingReward_ValidateBasic(t *testing.T) { + tests := []struct { + name string + msg MsgDeleteStakingReward + err error + }{ + { + name: "invalid address", + msg: MsgDeleteStakingReward{ + Creator: "invalid_address", + }, + err: sdkerrors.ErrInvalidAddress, + }, { + name: "valid address", + msg: MsgDeleteStakingReward{ + Creator: sample.AccAddress(), + }, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + err := tt.msg.ValidateBasic() + if tt.err != nil { + require.ErrorIs(t, err, tt.err) + return + } + require.NoError(t, err) + }) + } +} diff --git a/x/rewards/types/params.go b/x/rewards/types/params.go index ff0a854b..5e642c42 100644 --- a/x/rewards/types/params.go +++ b/x/rewards/types/params.go @@ -2,6 +2,7 @@ package types import ( "fmt" + sdk "github.com/cosmos/cosmos-sdk/types" paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" "gopkg.in/yaml.v2" @@ -77,8 +78,14 @@ func validateCreateStakingRewardFee(v interface{}) error { return fmt.Errorf("invalid parameter type: %T", v) } - // TODO implement validation - _ = createStakingRewardFee + normCoins, err := sdk.ParseCoinNormalized(createStakingRewardFee) + if err != nil { + return err + } + + if normCoins.IsNegative() { + return fmt.Errorf("negative amount provided") + } return nil } @@ -90,8 +97,14 @@ func validateCreateTradingRewardFee(v interface{}) error { return fmt.Errorf("invalid parameter type: %T", v) } - // TODO implement validation - _ = createTradingRewardFee + normCoins, err := sdk.ParseCoinNormalized(createTradingRewardFee) + if err != nil { + return err + } + + if normCoins.IsNegative() { + return fmt.Errorf("negative amount provided") + } return nil } diff --git a/x/rewards/types/query.pb.go b/x/rewards/types/query.pb.go index ff5d9a1e..d481faf9 100644 --- a/x/rewards/types/query.pb.go +++ b/x/rewards/types/query.pb.go @@ -6,7 +6,7 @@ package types import ( context "context" fmt "fmt" - _ "github.com/cosmos/cosmos-sdk/types/query" + query "github.com/cosmos/cosmos-sdk/types/query" _ "github.com/gogo/protobuf/gogoproto" grpc1 "github.com/gogo/protobuf/grpc" proto "github.com/gogo/protobuf/proto" @@ -113,35 +113,236 @@ func (m *QueryParamsResponse) GetParams() Params { return Params{} } +type QueryGetStakingRewardRequest struct { + RewardId string `protobuf:"bytes,1,opt,name=reward_id,json=rewardId,proto3" json:"reward_id,omitempty"` +} + +func (m *QueryGetStakingRewardRequest) Reset() { *m = QueryGetStakingRewardRequest{} } +func (m *QueryGetStakingRewardRequest) String() string { return proto.CompactTextString(m) } +func (*QueryGetStakingRewardRequest) ProtoMessage() {} +func (*QueryGetStakingRewardRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_5ddc078ee02fb5e8, []int{2} +} +func (m *QueryGetStakingRewardRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryGetStakingRewardRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryGetStakingRewardRequest.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 *QueryGetStakingRewardRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryGetStakingRewardRequest.Merge(m, src) +} +func (m *QueryGetStakingRewardRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryGetStakingRewardRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryGetStakingRewardRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryGetStakingRewardRequest proto.InternalMessageInfo + +func (m *QueryGetStakingRewardRequest) GetRewardId() string { + if m != nil { + return m.RewardId + } + return "" +} + +type QueryGetStakingRewardResponse struct { + StakingReward StakingReward `protobuf:"bytes,1,opt,name=staking_reward,json=stakingReward,proto3" json:"staking_reward"` +} + +func (m *QueryGetStakingRewardResponse) Reset() { *m = QueryGetStakingRewardResponse{} } +func (m *QueryGetStakingRewardResponse) String() string { return proto.CompactTextString(m) } +func (*QueryGetStakingRewardResponse) ProtoMessage() {} +func (*QueryGetStakingRewardResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_5ddc078ee02fb5e8, []int{3} +} +func (m *QueryGetStakingRewardResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryGetStakingRewardResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryGetStakingRewardResponse.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 *QueryGetStakingRewardResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryGetStakingRewardResponse.Merge(m, src) +} +func (m *QueryGetStakingRewardResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryGetStakingRewardResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryGetStakingRewardResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryGetStakingRewardResponse proto.InternalMessageInfo + +func (m *QueryGetStakingRewardResponse) GetStakingReward() StakingReward { + if m != nil { + return m.StakingReward + } + return StakingReward{} +} + +type QueryAllStakingRewardRequest struct { + Pagination *query.PageRequest `protobuf:"bytes,1,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryAllStakingRewardRequest) Reset() { *m = QueryAllStakingRewardRequest{} } +func (m *QueryAllStakingRewardRequest) String() string { return proto.CompactTextString(m) } +func (*QueryAllStakingRewardRequest) ProtoMessage() {} +func (*QueryAllStakingRewardRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_5ddc078ee02fb5e8, []int{4} +} +func (m *QueryAllStakingRewardRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryAllStakingRewardRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryAllStakingRewardRequest.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 *QueryAllStakingRewardRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryAllStakingRewardRequest.Merge(m, src) +} +func (m *QueryAllStakingRewardRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryAllStakingRewardRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryAllStakingRewardRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryAllStakingRewardRequest proto.InternalMessageInfo + +func (m *QueryAllStakingRewardRequest) GetPagination() *query.PageRequest { + if m != nil { + return m.Pagination + } + return nil +} + +type QueryAllStakingRewardResponse struct { + List []StakingReward `protobuf:"bytes,1,rep,name=list,proto3" json:"list"` + Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryAllStakingRewardResponse) Reset() { *m = QueryAllStakingRewardResponse{} } +func (m *QueryAllStakingRewardResponse) String() string { return proto.CompactTextString(m) } +func (*QueryAllStakingRewardResponse) ProtoMessage() {} +func (*QueryAllStakingRewardResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_5ddc078ee02fb5e8, []int{5} +} +func (m *QueryAllStakingRewardResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryAllStakingRewardResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryAllStakingRewardResponse.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 *QueryAllStakingRewardResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryAllStakingRewardResponse.Merge(m, src) +} +func (m *QueryAllStakingRewardResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryAllStakingRewardResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryAllStakingRewardResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryAllStakingRewardResponse proto.InternalMessageInfo + +func (m *QueryAllStakingRewardResponse) GetList() []StakingReward { + if m != nil { + return m.List + } + return nil +} + +func (m *QueryAllStakingRewardResponse) GetPagination() *query.PageResponse { + if m != nil { + return m.Pagination + } + return nil +} + func init() { proto.RegisterType((*QueryParamsRequest)(nil), "bze.v1.rewards.QueryParamsRequest") proto.RegisterType((*QueryParamsResponse)(nil), "bze.v1.rewards.QueryParamsResponse") + proto.RegisterType((*QueryGetStakingRewardRequest)(nil), "bze.v1.rewards.QueryGetStakingRewardRequest") + proto.RegisterType((*QueryGetStakingRewardResponse)(nil), "bze.v1.rewards.QueryGetStakingRewardResponse") + proto.RegisterType((*QueryAllStakingRewardRequest)(nil), "bze.v1.rewards.QueryAllStakingRewardRequest") + proto.RegisterType((*QueryAllStakingRewardResponse)(nil), "bze.v1.rewards.QueryAllStakingRewardResponse") } func init() { proto.RegisterFile("rewards/query.proto", fileDescriptor_5ddc078ee02fb5e8) } var fileDescriptor_5ddc078ee02fb5e8 = []byte{ - // 306 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x90, 0xb1, 0x4a, 0x03, 0x41, - 0x18, 0x84, 0xef, 0x44, 0x53, 0x9c, 0x60, 0x71, 0x09, 0x21, 0x04, 0x59, 0xe5, 0x6c, 0x44, 0xf4, - 0x96, 0x8b, 0x3e, 0x41, 0x0a, 0x1b, 0x1b, 0x4d, 0x69, 0xf7, 0x6f, 0xfc, 0xd9, 0x1c, 0x24, 0xf7, - 0x6f, 0x6e, 0x37, 0xd1, 0xa4, 0xf4, 0x09, 0x04, 0x5f, 0x2a, 0x65, 0xc0, 0xc6, 0x4a, 0x24, 0xf1, - 0x41, 0xe4, 0x76, 0x37, 0x42, 0x14, 0xec, 0xee, 0xfe, 0xf9, 0x66, 0x98, 0xd9, 0xa8, 0x5e, 0xe2, - 0x23, 0x94, 0x0f, 0x9a, 0x8f, 0x27, 0x58, 0xce, 0x52, 0x55, 0x92, 0xa1, 0xf8, 0x40, 0xcc, 0x31, - 0x9d, 0x66, 0xa9, 0xd7, 0xda, 0x0d, 0x49, 0x92, 0xac, 0xc4, 0xab, 0x2f, 0x47, 0xb5, 0x0f, 0x25, - 0x91, 0x1c, 0x22, 0x07, 0x95, 0x73, 0x28, 0x0a, 0x32, 0x60, 0x72, 0x2a, 0xb4, 0x57, 0xcf, 0xfa, - 0xa4, 0x47, 0xa4, 0xb9, 0x00, 0x8d, 0x2e, 0x9c, 0x4f, 0x33, 0x81, 0x06, 0x32, 0xae, 0x40, 0xe6, - 0x85, 0x85, 0x3d, 0xdb, 0xd8, 0x94, 0x50, 0x50, 0xc2, 0xc8, 0x27, 0x24, 0x8d, 0x28, 0xbe, 0xab, - 0x7c, 0xb7, 0xf6, 0xd8, 0xc3, 0xf1, 0x04, 0xb5, 0x49, 0x6e, 0xa2, 0xfa, 0xd6, 0x55, 0x2b, 0x2a, - 0x34, 0xc6, 0x57, 0x51, 0xcd, 0x99, 0x5b, 0xe1, 0x71, 0x78, 0xba, 0xdf, 0x69, 0xa6, 0xdb, 0x1b, - 0x52, 0xc7, 0x77, 0x77, 0x17, 0x1f, 0x47, 0x41, 0xcf, 0xb3, 0x9d, 0x79, 0xb4, 0x67, 0xc3, 0xe2, - 0x71, 0x54, 0x73, 0x40, 0x9c, 0xfc, 0x36, 0xfe, 0xed, 0xd0, 0x3e, 0xf9, 0x97, 0x71, 0x8d, 0x12, - 0xf6, 0xfc, 0xf6, 0xf5, 0xba, 0xd3, 0x8a, 0x9b, 0x5c, 0xcc, 0x91, 0x6f, 0x16, 0x4e, 0x33, 0x3f, - 0xb2, 0x7b, 0xbd, 0x58, 0xb1, 0x70, 0xb9, 0x62, 0xe1, 0xe7, 0x8a, 0x85, 0x2f, 0x6b, 0x16, 0x2c, - 0xd7, 0x2c, 0x78, 0x5f, 0xb3, 0xe0, 0xfe, 0x5c, 0xe6, 0x66, 0x30, 0x11, 0x69, 0x9f, 0x46, 0x95, - 0xf7, 0x02, 0x86, 0x6a, 0x00, 0x06, 0xc1, 0xfe, 0xf1, 0xa7, 0x9f, 0x2c, 0x33, 0x53, 0xa8, 0x45, - 0xcd, 0xbe, 0xd6, 0xe5, 0x77, 0x00, 0x00, 0x00, 0xff, 0xff, 0xf1, 0x02, 0xea, 0x3e, 0xca, 0x01, - 0x00, 0x00, + // 526 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x94, 0x41, 0x4f, 0x13, 0x41, + 0x14, 0xc7, 0x3b, 0x80, 0x8d, 0x8c, 0x81, 0x98, 0xa1, 0x21, 0x4d, 0x2d, 0x6b, 0x33, 0x26, 0x68, + 0x48, 0x99, 0x49, 0xab, 0x89, 0x07, 0x4f, 0x70, 0x80, 0xa8, 0x17, 0x5c, 0x6f, 0x5e, 0xc8, 0x2c, + 0x1d, 0x97, 0x0d, 0xdb, 0x9d, 0xed, 0xce, 0xb4, 0x0a, 0xc6, 0x8b, 0x9f, 0xc0, 0xc4, 0x83, 0x57, + 0xfd, 0x14, 0x7e, 0x05, 0x8e, 0x24, 0x5e, 0x3c, 0x19, 0xd3, 0xfa, 0x41, 0x4c, 0x67, 0x5e, 0xb1, + 0x5b, 0x58, 0xe0, 0xd6, 0x99, 0xf9, 0xbf, 0xff, 0xfb, 0xbd, 0xbe, 0x7f, 0x16, 0xaf, 0x64, 0xf2, + 0x9d, 0xc8, 0x3a, 0x9a, 0xf7, 0xfa, 0x32, 0x3b, 0x66, 0x69, 0xa6, 0x8c, 0x22, 0xcb, 0xc1, 0x89, + 0x64, 0x83, 0x16, 0x83, 0xb7, 0x5a, 0x25, 0x54, 0xa1, 0xb2, 0x4f, 0x7c, 0xfc, 0xcb, 0xa9, 0x6a, + 0xf5, 0x50, 0xa9, 0x30, 0x96, 0x5c, 0xa4, 0x11, 0x17, 0x49, 0xa2, 0x8c, 0x30, 0x91, 0x4a, 0x34, + 0xbc, 0x6e, 0x1c, 0x28, 0xdd, 0x55, 0x9a, 0x07, 0x42, 0x4b, 0x67, 0xce, 0x07, 0xad, 0x40, 0x1a, + 0xd1, 0xe2, 0xa9, 0x08, 0xa3, 0xc4, 0x8a, 0x41, 0x5b, 0x99, 0x40, 0xa4, 0x22, 0x13, 0xdd, 0x89, + 0x43, 0x7d, 0x72, 0xab, 0x8d, 0x38, 0x8a, 0x92, 0x70, 0xdf, 0x9d, 0xdd, 0x2b, 0xad, 0x60, 0xf2, + 0x6a, 0xec, 0xba, 0x67, 0x4b, 0x7c, 0xd9, 0xeb, 0x4b, 0x6d, 0xe8, 0x4b, 0xbc, 0x92, 0xbb, 0xd5, + 0xa9, 0x4a, 0xb4, 0x24, 0x4f, 0x70, 0xd9, 0x59, 0x57, 0x51, 0x03, 0x3d, 0xba, 0xd3, 0x5e, 0x65, + 0xf9, 0x09, 0x99, 0xd3, 0x6f, 0x2f, 0x9c, 0xfe, 0xbe, 0x5f, 0xf2, 0x41, 0x4b, 0x9f, 0xe1, 0xba, + 0x35, 0xdb, 0x95, 0xe6, 0xb5, 0x43, 0xf0, 0xad, 0x1c, 0x9a, 0x91, 0x7b, 0x78, 0xd1, 0xd5, 0xef, + 0x47, 0x1d, 0x6b, 0xbc, 0xe8, 0xdf, 0x76, 0x17, 0xcf, 0x3b, 0xf4, 0x08, 0xaf, 0x15, 0x14, 0x03, + 0xd3, 0x0b, 0xbc, 0x9c, 0x1f, 0x0c, 0xd8, 0xd6, 0x66, 0xd9, 0x72, 0xe5, 0x80, 0xb8, 0xa4, 0xa7, + 0x2f, 0xe9, 0x5b, 0x20, 0xdd, 0x8a, 0xe3, 0x4b, 0x49, 0x77, 0x30, 0xfe, 0xff, 0xa7, 0x43, 0x9f, + 0x75, 0xe6, 0x36, 0xc4, 0xc6, 0x1b, 0x62, 0x6e, 0xfd, 0xb0, 0x21, 0xb6, 0x27, 0x42, 0x09, 0xb5, + 0xfe, 0x54, 0x25, 0xfd, 0x8e, 0x60, 0xaa, 0x8b, 0x8d, 0x60, 0xaa, 0xa7, 0x78, 0x21, 0x8e, 0xb4, + 0xa9, 0xa2, 0xc6, 0xfc, 0x4d, 0x67, 0xb1, 0x05, 0x64, 0x37, 0x87, 0x38, 0x67, 0x11, 0x1f, 0x5e, + 0x8b, 0xe8, 0xba, 0x4e, 0x33, 0xb6, 0x7f, 0xcc, 0xe3, 0x5b, 0x96, 0x91, 0xf4, 0x70, 0xd9, 0xed, + 0x95, 0xd0, 0x59, 0x8e, 0x8b, 0xd1, 0xa9, 0x3d, 0xb8, 0x52, 0xe3, 0x1a, 0x51, 0xef, 0xd3, 0xcf, + 0xbf, 0x5f, 0xe6, 0xaa, 0x64, 0x95, 0x07, 0x27, 0x92, 0x4f, 0x02, 0x3a, 0x68, 0x41, 0x72, 0xc9, + 0x37, 0x84, 0x97, 0x72, 0x33, 0x92, 0xe6, 0xa5, 0xb6, 0x05, 0x91, 0xaa, 0x6d, 0xde, 0x50, 0x0d, + 0x38, 0x6d, 0x8b, 0xd3, 0x24, 0x1b, 0xb3, 0x38, 0xf9, 0x64, 0xf1, 0x0f, 0xe7, 0x39, 0xfd, 0x48, + 0xbe, 0x22, 0x7c, 0x37, 0xe7, 0xb6, 0x15, 0xc7, 0x05, 0x94, 0x05, 0x71, 0x2a, 0xa0, 0x2c, 0xca, + 0x04, 0x5d, 0xb7, 0x94, 0x0d, 0xe2, 0x5d, 0x4d, 0xb9, 0xbd, 0x73, 0x3a, 0xf4, 0xd0, 0xd9, 0xd0, + 0x43, 0x7f, 0x86, 0x1e, 0xfa, 0x3c, 0xf2, 0x4a, 0x67, 0x23, 0xaf, 0xf4, 0x6b, 0xe4, 0x95, 0xde, + 0x34, 0xc3, 0xc8, 0x1c, 0xf6, 0x03, 0x76, 0xa0, 0xba, 0x63, 0x8f, 0x4d, 0x11, 0xa7, 0x87, 0xc2, + 0x48, 0x61, 0x4f, 0xfc, 0xfd, 0xb9, 0xa7, 0x39, 0x4e, 0xa5, 0x0e, 0xca, 0xf6, 0x0b, 0xf1, 0xf8, + 0x5f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x52, 0x97, 0x4b, 0xe2, 0xdc, 0x04, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -158,6 +359,10 @@ const _ = grpc.SupportPackageIsVersion4 type QueryClient interface { // Parameters queries the parameters of the module. Params(ctx context.Context, in *QueryParamsRequest, opts ...grpc.CallOption) (*QueryParamsResponse, error) + // Queries a StakingReward by index. + StakingReward(ctx context.Context, in *QueryGetStakingRewardRequest, opts ...grpc.CallOption) (*QueryGetStakingRewardResponse, error) + // Queries a list of StakingReward items. + StakingRewardAll(ctx context.Context, in *QueryAllStakingRewardRequest, opts ...grpc.CallOption) (*QueryAllStakingRewardResponse, error) } type queryClient struct { @@ -177,10 +382,32 @@ func (c *queryClient) Params(ctx context.Context, in *QueryParamsRequest, opts . return out, nil } +func (c *queryClient) StakingReward(ctx context.Context, in *QueryGetStakingRewardRequest, opts ...grpc.CallOption) (*QueryGetStakingRewardResponse, error) { + out := new(QueryGetStakingRewardResponse) + err := c.cc.Invoke(ctx, "/bze.v1.rewards.Query/StakingReward", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) StakingRewardAll(ctx context.Context, in *QueryAllStakingRewardRequest, opts ...grpc.CallOption) (*QueryAllStakingRewardResponse, error) { + out := new(QueryAllStakingRewardResponse) + err := c.cc.Invoke(ctx, "/bze.v1.rewards.Query/StakingRewardAll", 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) + // Queries a StakingReward by index. + StakingReward(context.Context, *QueryGetStakingRewardRequest) (*QueryGetStakingRewardResponse, error) + // Queries a list of StakingReward items. + StakingRewardAll(context.Context, *QueryAllStakingRewardRequest) (*QueryAllStakingRewardResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -190,6 +417,12 @@ type UnimplementedQueryServer struct { func (*UnimplementedQueryServer) Params(ctx context.Context, req *QueryParamsRequest) (*QueryParamsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Params not implemented") } +func (*UnimplementedQueryServer) StakingReward(ctx context.Context, req *QueryGetStakingRewardRequest) (*QueryGetStakingRewardResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method StakingReward not implemented") +} +func (*UnimplementedQueryServer) StakingRewardAll(ctx context.Context, req *QueryAllStakingRewardRequest) (*QueryAllStakingRewardResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method StakingRewardAll not implemented") +} func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) @@ -213,6 +446,42 @@ func _Query_Params_Handler(srv interface{}, ctx context.Context, dec func(interf return interceptor(ctx, in, info, handler) } +func _Query_StakingReward_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryGetStakingRewardRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).StakingReward(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/bze.v1.rewards.Query/StakingReward", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).StakingReward(ctx, req.(*QueryGetStakingRewardRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_StakingRewardAll_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryAllStakingRewardRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).StakingRewardAll(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/bze.v1.rewards.Query/StakingRewardAll", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).StakingRewardAll(ctx, req.(*QueryAllStakingRewardRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "bze.v1.rewards.Query", HandlerType: (*QueryServer)(nil), @@ -221,6 +490,14 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "Params", Handler: _Query_Params_Handler, }, + { + MethodName: "StakingReward", + Handler: _Query_StakingReward_Handler, + }, + { + MethodName: "StakingRewardAll", + Handler: _Query_StakingRewardAll_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "rewards/query.proto", @@ -282,6 +559,153 @@ func (m *QueryParamsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *QueryGetStakingRewardRequest) 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 *QueryGetStakingRewardRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryGetStakingRewardRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.RewardId) > 0 { + i -= len(m.RewardId) + copy(dAtA[i:], m.RewardId) + i = encodeVarintQuery(dAtA, i, uint64(len(m.RewardId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryGetStakingRewardResponse) 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 *QueryGetStakingRewardResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryGetStakingRewardResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + { + size, err := m.StakingReward.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 (m *QueryAllStakingRewardRequest) 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 *QueryAllStakingRewardRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryAllStakingRewardRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.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 (m *QueryAllStakingRewardResponse) 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 *QueryAllStakingRewardResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryAllStakingRewardResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.List) > 0 { + for iNdEx := len(m.List) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.List[iNdEx].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 @@ -313,7 +737,63 @@ func (m *QueryParamsResponse) Size() (n int) { return n } -func sovQuery(x uint64) (n int) { +func (m *QueryGetStakingRewardRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.RewardId) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryGetStakingRewardResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.StakingReward.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *QueryAllStakingRewardRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryAllStakingRewardResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.List) > 0 { + for _, e := range m.List { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if m.Pagination != nil { + l = m.Pagination.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) { @@ -452,6 +932,377 @@ func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *QueryGetStakingRewardRequest) 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: QueryGetStakingRewardRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGetStakingRewardRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RewardId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.RewardId = string(dAtA[iNdEx:postIndex]) + 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 (m *QueryGetStakingRewardResponse) 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: QueryGetStakingRewardResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGetStakingRewardResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field StakingReward", 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.StakingReward.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 (m *QueryAllStakingRewardRequest) 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: QueryAllStakingRewardRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryAllStakingRewardRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", 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 m.Pagination == nil { + m.Pagination = &query.PageRequest{} + } + if err := m.Pagination.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 (m *QueryAllStakingRewardResponse) 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: QueryAllStakingRewardResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryAllStakingRewardResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field List", 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 + } + m.List = append(m.List, StakingReward{}) + if err := m.List[len(m.List)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", 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 m.Pagination == nil { + m.Pagination = &query.PageResponse{} + } + if err := m.Pagination.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 diff --git a/x/rewards/types/query.pb.gw.go b/x/rewards/types/query.pb.gw.go index bb90c452..ee0af6e7 100644 --- a/x/rewards/types/query.pb.gw.go +++ b/x/rewards/types/query.pb.gw.go @@ -51,6 +51,96 @@ func local_request_Query_Params_0(ctx context.Context, marshaler runtime.Marshal } +func request_Query_StakingReward_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryGetStakingRewardRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["reward_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "reward_id") + } + + protoReq.RewardId, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "reward_id", err) + } + + msg, err := client.StakingReward(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_StakingReward_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryGetStakingRewardRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["reward_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "reward_id") + } + + protoReq.RewardId, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "reward_id", err) + } + + msg, err := server.StakingReward(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_Query_StakingRewardAll_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_Query_StakingRewardAll_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryAllStakingRewardRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_StakingRewardAll_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.StakingRewardAll(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_StakingRewardAll_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryAllStakingRewardRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_StakingRewardAll_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.StakingRewardAll(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. @@ -80,6 +170,52 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_StakingReward_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_StakingReward_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_StakingReward_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_StakingRewardAll_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_StakingRewardAll_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_StakingRewardAll_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -141,13 +277,61 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_StakingReward_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_StakingReward_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_StakingReward_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_StakingRewardAll_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_StakingRewardAll_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_StakingRewardAll_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{"bze", "rewards", "v1", "params"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_StakingReward_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"bze", "rewards", "v1", "staking_reward", "reward_id"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_StakingRewardAll_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"bze", "rewards", "v1", "staking_reward"}, "", runtime.AssumeColonVerbOpt(true))) ) var ( forward_Query_Params_0 = runtime.ForwardResponseMessage + + forward_Query_StakingReward_0 = runtime.ForwardResponseMessage + + forward_Query_StakingRewardAll_0 = runtime.ForwardResponseMessage ) diff --git a/x/rewards/types/staking_reward.pb.go b/x/rewards/types/staking_reward.pb.go new file mode 100644 index 00000000..3d6e7aa8 --- /dev/null +++ b/x/rewards/types/staking_reward.pb.go @@ -0,0 +1,599 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: rewards/staking_reward.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 StakingReward struct { + RewardId string `protobuf:"bytes,1,opt,name=reward_id,json=rewardId,proto3" json:"reward_id,omitempty"` + PrizeAmount int64 `protobuf:"varint,2,opt,name=prize_amount,json=prizeAmount,proto3" json:"prize_amount,omitempty"` + PrizeDenom string `protobuf:"bytes,3,opt,name=prize_denom,json=prizeDenom,proto3" json:"prize_denom,omitempty"` + StakingDenom string `protobuf:"bytes,4,opt,name=staking_denom,json=stakingDenom,proto3" json:"staking_denom,omitempty"` + Duration uint32 `protobuf:"varint,5,opt,name=duration,proto3" json:"duration,omitempty"` + Payouts uint32 `protobuf:"varint,6,opt,name=payouts,proto3" json:"payouts,omitempty"` + MinStake uint64 `protobuf:"varint,7,opt,name=minStake,proto3" json:"minStake,omitempty"` + Lock uint32 `protobuf:"varint,8,opt,name=lock,proto3" json:"lock,omitempty"` +} + +func (m *StakingReward) Reset() { *m = StakingReward{} } +func (m *StakingReward) String() string { return proto.CompactTextString(m) } +func (*StakingReward) ProtoMessage() {} +func (*StakingReward) Descriptor() ([]byte, []int) { + return fileDescriptor_a8c582f9c980c2bd, []int{0} +} +func (m *StakingReward) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *StakingReward) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_StakingReward.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 *StakingReward) XXX_Merge(src proto.Message) { + xxx_messageInfo_StakingReward.Merge(m, src) +} +func (m *StakingReward) XXX_Size() int { + return m.Size() +} +func (m *StakingReward) XXX_DiscardUnknown() { + xxx_messageInfo_StakingReward.DiscardUnknown(m) +} + +var xxx_messageInfo_StakingReward proto.InternalMessageInfo + +func (m *StakingReward) GetRewardId() string { + if m != nil { + return m.RewardId + } + return "" +} + +func (m *StakingReward) GetPrizeAmount() int64 { + if m != nil { + return m.PrizeAmount + } + return 0 +} + +func (m *StakingReward) GetPrizeDenom() string { + if m != nil { + return m.PrizeDenom + } + return "" +} + +func (m *StakingReward) GetStakingDenom() string { + if m != nil { + return m.StakingDenom + } + return "" +} + +func (m *StakingReward) GetDuration() uint32 { + if m != nil { + return m.Duration + } + return 0 +} + +func (m *StakingReward) GetPayouts() uint32 { + if m != nil { + return m.Payouts + } + return 0 +} + +func (m *StakingReward) GetMinStake() uint64 { + if m != nil { + return m.MinStake + } + return 0 +} + +func (m *StakingReward) GetLock() uint32 { + if m != nil { + return m.Lock + } + return 0 +} + +func init() { + proto.RegisterType((*StakingReward)(nil), "bze.v1.rewards.StakingReward") +} + +func init() { proto.RegisterFile("rewards/staking_reward.proto", fileDescriptor_a8c582f9c980c2bd) } + +var fileDescriptor_a8c582f9c980c2bd = []byte{ + // 287 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x3c, 0x90, 0xc1, 0x4e, 0x83, 0x30, + 0x18, 0xc7, 0xa9, 0xc3, 0x8d, 0xd5, 0xe1, 0xa1, 0xa7, 0x46, 0x4d, 0x45, 0xbd, 0x70, 0x50, 0x88, + 0xf1, 0x09, 0x34, 0xc6, 0xc4, 0x2b, 0xde, 0xbc, 0x90, 0x32, 0x9a, 0xad, 0xd9, 0xa0, 0x04, 0x8a, + 0x3a, 0x9e, 0xc2, 0xc7, 0xf2, 0xb8, 0xa3, 0x47, 0x03, 0x8f, 0xe1, 0x65, 0xe1, 0xeb, 0xd8, 0xad, + 0xbf, 0xdf, 0xf7, 0xff, 0x9a, 0xf6, 0x8f, 0x2f, 0x4a, 0xf1, 0xc9, 0xcb, 0xb4, 0x0a, 0x2b, 0xcd, + 0x57, 0x32, 0x5f, 0xc4, 0x86, 0x83, 0xa2, 0x54, 0x5a, 0x91, 0xd3, 0xa4, 0x11, 0xc1, 0xc7, 0x7d, + 0xb0, 0x0f, 0x5d, 0xff, 0x23, 0xec, 0xbe, 0x99, 0x60, 0x04, 0x8a, 0x9c, 0xe3, 0xa9, 0x19, 0xc6, + 0x32, 0xa5, 0xc8, 0x43, 0xfe, 0x34, 0x72, 0x8c, 0x78, 0x4d, 0xc9, 0x15, 0x9e, 0x15, 0xa5, 0x6c, + 0x44, 0xcc, 0x33, 0x55, 0xe7, 0x9a, 0x1e, 0x79, 0xc8, 0x1f, 0x45, 0x27, 0xe0, 0x1e, 0x41, 0x91, + 0x4b, 0x6c, 0x30, 0x4e, 0x45, 0xae, 0x32, 0x3a, 0x82, 0x1b, 0x30, 0xa8, 0xe7, 0xde, 0x90, 0x1b, + 0xec, 0x0e, 0x4f, 0x33, 0x11, 0x1b, 0x22, 0xb3, 0xbd, 0x34, 0xa1, 0x33, 0xec, 0xa4, 0x75, 0xc9, + 0xb5, 0x54, 0x39, 0x3d, 0xf6, 0x90, 0xef, 0x46, 0x07, 0x26, 0x14, 0x4f, 0x0a, 0xbe, 0x51, 0xb5, + 0xae, 0xe8, 0x18, 0x46, 0x03, 0xf6, 0x5b, 0x99, 0xcc, 0xfb, 0xff, 0x08, 0x3a, 0xf1, 0x90, 0x6f, + 0x47, 0x07, 0x26, 0x04, 0xdb, 0x6b, 0x35, 0x5f, 0x51, 0x07, 0x56, 0xe0, 0xfc, 0xf4, 0xf2, 0xd3, + 0x32, 0xb4, 0x6d, 0x19, 0xfa, 0x6b, 0x19, 0xfa, 0xee, 0x98, 0xb5, 0xed, 0x98, 0xf5, 0xdb, 0x31, + 0xeb, 0xfd, 0x76, 0x21, 0xf5, 0xb2, 0x4e, 0x82, 0xb9, 0xca, 0xc2, 0xa4, 0x11, 0x77, 0x7c, 0x5d, + 0x2c, 0xb9, 0x16, 0x1c, 0x28, 0xfc, 0x0a, 0x87, 0x92, 0xf5, 0xa6, 0x10, 0x55, 0x32, 0x86, 0x72, + 0x1f, 0x76, 0x01, 0x00, 0x00, 0xff, 0xff, 0x07, 0x26, 0x4a, 0x15, 0x7c, 0x01, 0x00, 0x00, +} + +func (m *StakingReward) 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 *StakingReward) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *StakingReward) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Lock != 0 { + i = encodeVarintStakingReward(dAtA, i, uint64(m.Lock)) + i-- + dAtA[i] = 0x40 + } + if m.MinStake != 0 { + i = encodeVarintStakingReward(dAtA, i, uint64(m.MinStake)) + i-- + dAtA[i] = 0x38 + } + if m.Payouts != 0 { + i = encodeVarintStakingReward(dAtA, i, uint64(m.Payouts)) + i-- + dAtA[i] = 0x30 + } + if m.Duration != 0 { + i = encodeVarintStakingReward(dAtA, i, uint64(m.Duration)) + i-- + dAtA[i] = 0x28 + } + if len(m.StakingDenom) > 0 { + i -= len(m.StakingDenom) + copy(dAtA[i:], m.StakingDenom) + i = encodeVarintStakingReward(dAtA, i, uint64(len(m.StakingDenom))) + i-- + dAtA[i] = 0x22 + } + if len(m.PrizeDenom) > 0 { + i -= len(m.PrizeDenom) + copy(dAtA[i:], m.PrizeDenom) + i = encodeVarintStakingReward(dAtA, i, uint64(len(m.PrizeDenom))) + i-- + dAtA[i] = 0x1a + } + if m.PrizeAmount != 0 { + i = encodeVarintStakingReward(dAtA, i, uint64(m.PrizeAmount)) + i-- + dAtA[i] = 0x10 + } + if len(m.RewardId) > 0 { + i -= len(m.RewardId) + copy(dAtA[i:], m.RewardId) + i = encodeVarintStakingReward(dAtA, i, uint64(len(m.RewardId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintStakingReward(dAtA []byte, offset int, v uint64) int { + offset -= sovStakingReward(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *StakingReward) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.RewardId) + if l > 0 { + n += 1 + l + sovStakingReward(uint64(l)) + } + if m.PrizeAmount != 0 { + n += 1 + sovStakingReward(uint64(m.PrizeAmount)) + } + l = len(m.PrizeDenom) + if l > 0 { + n += 1 + l + sovStakingReward(uint64(l)) + } + l = len(m.StakingDenom) + if l > 0 { + n += 1 + l + sovStakingReward(uint64(l)) + } + if m.Duration != 0 { + n += 1 + sovStakingReward(uint64(m.Duration)) + } + if m.Payouts != 0 { + n += 1 + sovStakingReward(uint64(m.Payouts)) + } + if m.MinStake != 0 { + n += 1 + sovStakingReward(uint64(m.MinStake)) + } + if m.Lock != 0 { + n += 1 + sovStakingReward(uint64(m.Lock)) + } + return n +} + +func sovStakingReward(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozStakingReward(x uint64) (n int) { + return sovStakingReward(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *StakingReward) 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 ErrIntOverflowStakingReward + } + 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: StakingReward: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: StakingReward: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RewardId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowStakingReward + } + 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 ErrInvalidLengthStakingReward + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthStakingReward + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.RewardId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field PrizeAmount", wireType) + } + m.PrizeAmount = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowStakingReward + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.PrizeAmount |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PrizeDenom", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowStakingReward + } + 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 ErrInvalidLengthStakingReward + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthStakingReward + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PrizeDenom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field StakingDenom", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowStakingReward + } + 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 ErrInvalidLengthStakingReward + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthStakingReward + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.StakingDenom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Duration", wireType) + } + m.Duration = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowStakingReward + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Duration |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Payouts", wireType) + } + m.Payouts = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowStakingReward + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Payouts |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 7: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MinStake", wireType) + } + m.MinStake = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowStakingReward + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MinStake |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 8: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Lock", wireType) + } + m.Lock = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowStakingReward + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Lock |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipStakingReward(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthStakingReward + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipStakingReward(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, ErrIntOverflowStakingReward + } + 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, ErrIntOverflowStakingReward + } + 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, ErrIntOverflowStakingReward + } + 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, ErrInvalidLengthStakingReward + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupStakingReward + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthStakingReward + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthStakingReward = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowStakingReward = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupStakingReward = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/rewards/types/tx.pb.go b/x/rewards/types/tx.pb.go index fb73bb6a..e05e8d64 100644 --- a/x/rewards/types/tx.pb.go +++ b/x/rewards/types/tx.pb.go @@ -9,7 +9,11 @@ import ( grpc1 "github.com/gogo/protobuf/grpc" proto "github.com/gogo/protobuf/proto" 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. @@ -23,18 +27,273 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package +type MsgCreateStakingReward struct { + Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` + PrizeAmount string `protobuf:"bytes,2,opt,name=prize_amount,json=prizeAmount,proto3" json:"prize_amount,omitempty"` + PrizeDenom string `protobuf:"bytes,3,opt,name=prize_denom,json=prizeDenom,proto3" json:"prize_denom,omitempty"` + StakingDenom string `protobuf:"bytes,4,opt,name=staking_denom,json=stakingDenom,proto3" json:"staking_denom,omitempty"` + Duration string `protobuf:"bytes,5,opt,name=duration,proto3" json:"duration,omitempty"` + MinStake string `protobuf:"bytes,6,opt,name=min_stake,json=minStake,proto3" json:"min_stake,omitempty"` + Lock string `protobuf:"bytes,7,opt,name=lock,proto3" json:"lock,omitempty"` +} + +func (m *MsgCreateStakingReward) Reset() { *m = MsgCreateStakingReward{} } +func (m *MsgCreateStakingReward) String() string { return proto.CompactTextString(m) } +func (*MsgCreateStakingReward) ProtoMessage() {} +func (*MsgCreateStakingReward) Descriptor() ([]byte, []int) { + return fileDescriptor_4c0d543e6be8610a, []int{0} +} +func (m *MsgCreateStakingReward) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgCreateStakingReward) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgCreateStakingReward.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 *MsgCreateStakingReward) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgCreateStakingReward.Merge(m, src) +} +func (m *MsgCreateStakingReward) XXX_Size() int { + return m.Size() +} +func (m *MsgCreateStakingReward) XXX_DiscardUnknown() { + xxx_messageInfo_MsgCreateStakingReward.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgCreateStakingReward proto.InternalMessageInfo + +func (m *MsgCreateStakingReward) GetCreator() string { + if m != nil { + return m.Creator + } + return "" +} + +func (m *MsgCreateStakingReward) GetPrizeAmount() string { + if m != nil { + return m.PrizeAmount + } + return "" +} + +func (m *MsgCreateStakingReward) GetPrizeDenom() string { + if m != nil { + return m.PrizeDenom + } + return "" +} + +func (m *MsgCreateStakingReward) GetStakingDenom() string { + if m != nil { + return m.StakingDenom + } + return "" +} + +func (m *MsgCreateStakingReward) GetDuration() string { + if m != nil { + return m.Duration + } + return "" +} + +func (m *MsgCreateStakingReward) GetMinStake() string { + if m != nil { + return m.MinStake + } + return "" +} + +func (m *MsgCreateStakingReward) GetLock() string { + if m != nil { + return m.Lock + } + return "" +} + +type MsgCreateStakingRewardResponse struct { + RewardId string `protobuf:"bytes,1,opt,name=reward_id,json=rewardId,proto3" json:"reward_id,omitempty"` +} + +func (m *MsgCreateStakingRewardResponse) Reset() { *m = MsgCreateStakingRewardResponse{} } +func (m *MsgCreateStakingRewardResponse) String() string { return proto.CompactTextString(m) } +func (*MsgCreateStakingRewardResponse) ProtoMessage() {} +func (*MsgCreateStakingRewardResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_4c0d543e6be8610a, []int{1} +} +func (m *MsgCreateStakingRewardResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgCreateStakingRewardResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgCreateStakingRewardResponse.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 *MsgCreateStakingRewardResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgCreateStakingRewardResponse.Merge(m, src) +} +func (m *MsgCreateStakingRewardResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgCreateStakingRewardResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgCreateStakingRewardResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgCreateStakingRewardResponse proto.InternalMessageInfo + +func (m *MsgCreateStakingRewardResponse) GetRewardId() string { + if m != nil { + return m.RewardId + } + return "" +} + +type MsgUpdateStakingReward struct { + Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` + RewardId string `protobuf:"bytes,2,opt,name=reward_id,json=rewardId,proto3" json:"reward_id,omitempty"` + Duration string `protobuf:"bytes,3,opt,name=duration,proto3" json:"duration,omitempty"` +} + +func (m *MsgUpdateStakingReward) Reset() { *m = MsgUpdateStakingReward{} } +func (m *MsgUpdateStakingReward) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateStakingReward) ProtoMessage() {} +func (*MsgUpdateStakingReward) Descriptor() ([]byte, []int) { + return fileDescriptor_4c0d543e6be8610a, []int{2} +} +func (m *MsgUpdateStakingReward) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateStakingReward) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateStakingReward.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 *MsgUpdateStakingReward) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateStakingReward.Merge(m, src) +} +func (m *MsgUpdateStakingReward) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateStakingReward) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateStakingReward.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateStakingReward proto.InternalMessageInfo + +func (m *MsgUpdateStakingReward) GetCreator() string { + if m != nil { + return m.Creator + } + return "" +} + +func (m *MsgUpdateStakingReward) GetRewardId() string { + if m != nil { + return m.RewardId + } + return "" +} + +func (m *MsgUpdateStakingReward) GetDuration() string { + if m != nil { + return m.Duration + } + return "" +} + +type MsgUpdateStakingRewardResponse struct { +} + +func (m *MsgUpdateStakingRewardResponse) Reset() { *m = MsgUpdateStakingRewardResponse{} } +func (m *MsgUpdateStakingRewardResponse) String() string { return proto.CompactTextString(m) } +func (*MsgUpdateStakingRewardResponse) ProtoMessage() {} +func (*MsgUpdateStakingRewardResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_4c0d543e6be8610a, []int{3} +} +func (m *MsgUpdateStakingRewardResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgUpdateStakingRewardResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgUpdateStakingRewardResponse.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 *MsgUpdateStakingRewardResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgUpdateStakingRewardResponse.Merge(m, src) +} +func (m *MsgUpdateStakingRewardResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgUpdateStakingRewardResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgUpdateStakingRewardResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgUpdateStakingRewardResponse proto.InternalMessageInfo + +func init() { + proto.RegisterType((*MsgCreateStakingReward)(nil), "bze.v1.rewards.MsgCreateStakingReward") + proto.RegisterType((*MsgCreateStakingRewardResponse)(nil), "bze.v1.rewards.MsgCreateStakingRewardResponse") + proto.RegisterType((*MsgUpdateStakingReward)(nil), "bze.v1.rewards.MsgUpdateStakingReward") + proto.RegisterType((*MsgUpdateStakingRewardResponse)(nil), "bze.v1.rewards.MsgUpdateStakingRewardResponse") +} + func init() { proto.RegisterFile("rewards/tx.proto", fileDescriptor_4c0d543e6be8610a) } var fileDescriptor_4c0d543e6be8610a = []byte{ - // 128 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x28, 0x4a, 0x2d, 0x4f, - 0x2c, 0x4a, 0x29, 0xd6, 0x2f, 0xa9, 0xd0, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x4b, 0xaa, - 0x4a, 0xd5, 0x2b, 0x33, 0xd4, 0x83, 0x4a, 0x18, 0xb1, 0x72, 0x31, 0xfb, 0x16, 0xa7, 0x3b, 0xb9, - 0x9d, 0x78, 0x24, 0xc7, 0x78, 0xe1, 0x91, 0x1c, 0xe3, 0x83, 0x47, 0x72, 0x8c, 0x13, 0x1e, 0xcb, - 0x31, 0x5c, 0x78, 0x2c, 0xc7, 0x70, 0xe3, 0xb1, 0x1c, 0x43, 0x94, 0x4e, 0x7a, 0x66, 0x49, 0x46, - 0x69, 0x92, 0x5e, 0x72, 0x7e, 0xae, 0x7e, 0x52, 0x55, 0xaa, 0x6e, 0x62, 0x4e, 0x41, 0x46, 0x62, - 0x49, 0x6a, 0x22, 0x98, 0xa7, 0x5f, 0xa1, 0x0f, 0xb7, 0xa1, 0xb2, 0x20, 0xb5, 0x38, 0x89, 0x0d, - 0x6c, 0x8b, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0xda, 0xb6, 0x9c, 0x53, 0x79, 0x00, 0x00, 0x00, + // 373 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x52, 0xcd, 0x4a, 0xf3, 0x40, + 0x14, 0x6d, 0xda, 0x7e, 0xfd, 0xb9, 0x5f, 0x15, 0x99, 0x82, 0x84, 0x0a, 0xb1, 0x46, 0x10, 0x17, + 0x9a, 0xa0, 0xae, 0x5d, 0xf8, 0x83, 0xe0, 0xa2, 0x9b, 0x8a, 0x1b, 0x37, 0x61, 0xd2, 0x0c, 0x69, + 0x68, 0x93, 0x09, 0x99, 0xa9, 0xd6, 0x3e, 0x85, 0x8f, 0xe5, 0xb2, 0x4b, 0x97, 0xd2, 0x6c, 0x7c, + 0x0c, 0xc9, 0x4d, 0x5a, 0x08, 0x0c, 0xa2, 0xbb, 0xb9, 0xe7, 0x1c, 0xee, 0x99, 0x73, 0x66, 0x60, + 0x27, 0x61, 0x2f, 0x34, 0xf1, 0x84, 0x2d, 0xe7, 0x56, 0x9c, 0x70, 0xc9, 0xc9, 0xb6, 0xbb, 0x60, + 0xd6, 0xf3, 0x99, 0x55, 0x10, 0xe6, 0x97, 0x06, 0xbb, 0x03, 0xe1, 0xdf, 0x24, 0x8c, 0x4a, 0xf6, + 0x20, 0xe9, 0x24, 0x88, 0xfc, 0x21, 0x72, 0x44, 0x87, 0xe6, 0x28, 0x83, 0x79, 0xa2, 0x6b, 0x7d, + 0xed, 0xb8, 0x3d, 0x5c, 0x8f, 0xe4, 0x00, 0x3a, 0x71, 0x12, 0x2c, 0x98, 0x43, 0x43, 0x3e, 0x8b, + 0xa4, 0x5e, 0x45, 0xfa, 0x3f, 0x62, 0x57, 0x08, 0x91, 0x7d, 0xc8, 0x47, 0xc7, 0x63, 0x11, 0x0f, + 0xf5, 0x1a, 0x2a, 0x00, 0xa1, 0xdb, 0x0c, 0x21, 0x87, 0xb0, 0x25, 0x72, 0xbb, 0x42, 0x52, 0x47, + 0x49, 0xa7, 0x00, 0x73, 0x51, 0x0f, 0x5a, 0xde, 0x2c, 0xa1, 0x32, 0xe0, 0x91, 0xfe, 0x0f, 0xf9, + 0xcd, 0x4c, 0xf6, 0xa0, 0x1d, 0x06, 0x91, 0x93, 0xe9, 0x99, 0xde, 0xc8, 0xc9, 0x30, 0x88, 0xb2, + 0x0c, 0x8c, 0x10, 0xa8, 0x4f, 0xf9, 0x68, 0xa2, 0x37, 0x11, 0xc7, 0xb3, 0x79, 0x09, 0x86, 0x3a, + 0xe9, 0x90, 0x89, 0x98, 0x47, 0x82, 0x65, 0x2b, 0xf3, 0x5e, 0x9c, 0xc0, 0x2b, 0x32, 0xb7, 0x72, + 0xe0, 0xde, 0x33, 0x27, 0x58, 0xd4, 0x63, 0xec, 0xfd, 0xa1, 0xa8, 0xd2, 0xc2, 0x6a, 0x79, 0x61, + 0x29, 0x5c, 0xad, 0x1c, 0xce, 0xec, 0xe3, 0x5d, 0x15, 0x66, 0xeb, 0xbb, 0x9e, 0xa7, 0x1a, 0xd4, + 0x06, 0xc2, 0x27, 0x21, 0x74, 0x55, 0x8f, 0x77, 0x64, 0x95, 0x1f, 0xda, 0x52, 0x47, 0xef, 0x59, + 0xbf, 0xd3, 0x6d, 0x2a, 0x0a, 0xa1, 0xab, 0xaa, 0x40, 0x65, 0xa7, 0xd0, 0x29, 0xed, 0x7e, 0x48, + 0x79, 0x7d, 0xf7, 0xbe, 0x32, 0xb4, 0xe5, 0xca, 0xd0, 0x3e, 0x57, 0x86, 0xf6, 0x96, 0x1a, 0x95, + 0x65, 0x6a, 0x54, 0x3e, 0x52, 0xa3, 0xf2, 0x74, 0xe2, 0x07, 0x72, 0x3c, 0x73, 0xad, 0x11, 0x0f, + 0x6d, 0x77, 0xc1, 0x4e, 0xe9, 0x34, 0x1e, 0x53, 0xc9, 0x28, 0x4e, 0xf6, 0xdc, 0xde, 0xfc, 0xfc, + 0xd7, 0x98, 0x09, 0xb7, 0x81, 0xbf, 0xff, 0xe2, 0x3b, 0x00, 0x00, 0xff, 0xff, 0x2e, 0xc5, 0x07, + 0x37, 0x11, 0x03, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -49,6 +308,8 @@ const _ = grpc.SupportPackageIsVersion4 // // 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 { + CreateStakingReward(ctx context.Context, in *MsgCreateStakingReward, opts ...grpc.CallOption) (*MsgCreateStakingRewardResponse, error) + UpdateStakingReward(ctx context.Context, in *MsgUpdateStakingReward, opts ...grpc.CallOption) (*MsgUpdateStakingRewardResponse, error) } type msgClient struct { @@ -59,22 +320,997 @@ func NewMsgClient(cc grpc1.ClientConn) MsgClient { return &msgClient{cc} } +func (c *msgClient) CreateStakingReward(ctx context.Context, in *MsgCreateStakingReward, opts ...grpc.CallOption) (*MsgCreateStakingRewardResponse, error) { + out := new(MsgCreateStakingRewardResponse) + err := c.cc.Invoke(ctx, "/bze.v1.rewards.Msg/CreateStakingReward", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) UpdateStakingReward(ctx context.Context, in *MsgUpdateStakingReward, opts ...grpc.CallOption) (*MsgUpdateStakingRewardResponse, error) { + out := new(MsgUpdateStakingRewardResponse) + err := c.cc.Invoke(ctx, "/bze.v1.rewards.Msg/UpdateStakingReward", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // MsgServer is the server API for Msg service. type MsgServer interface { + CreateStakingReward(context.Context, *MsgCreateStakingReward) (*MsgCreateStakingRewardResponse, error) + UpdateStakingReward(context.Context, *MsgUpdateStakingReward) (*MsgUpdateStakingRewardResponse, error) } // UnimplementedMsgServer can be embedded to have forward compatible implementations. type UnimplementedMsgServer struct { } +func (*UnimplementedMsgServer) CreateStakingReward(ctx context.Context, req *MsgCreateStakingReward) (*MsgCreateStakingRewardResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method CreateStakingReward not implemented") +} +func (*UnimplementedMsgServer) UpdateStakingReward(ctx context.Context, req *MsgUpdateStakingReward) (*MsgUpdateStakingRewardResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method UpdateStakingReward not implemented") +} + func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) } +func _Msg_CreateStakingReward_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgCreateStakingReward) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).CreateStakingReward(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/bze.v1.rewards.Msg/CreateStakingReward", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).CreateStakingReward(ctx, req.(*MsgCreateStakingReward)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_UpdateStakingReward_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgUpdateStakingReward) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).UpdateStakingReward(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/bze.v1.rewards.Msg/UpdateStakingReward", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).UpdateStakingReward(ctx, req.(*MsgUpdateStakingReward)) + } + return interceptor(ctx, in, info, handler) +} + var _Msg_serviceDesc = grpc.ServiceDesc{ ServiceName: "bze.v1.rewards.Msg", HandlerType: (*MsgServer)(nil), - Methods: []grpc.MethodDesc{}, - Streams: []grpc.StreamDesc{}, - Metadata: "rewards/tx.proto", + Methods: []grpc.MethodDesc{ + { + MethodName: "CreateStakingReward", + Handler: _Msg_CreateStakingReward_Handler, + }, + { + MethodName: "UpdateStakingReward", + Handler: _Msg_UpdateStakingReward_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "rewards/tx.proto", +} + +func (m *MsgCreateStakingReward) 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 *MsgCreateStakingReward) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgCreateStakingReward) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Lock) > 0 { + i -= len(m.Lock) + copy(dAtA[i:], m.Lock) + i = encodeVarintTx(dAtA, i, uint64(len(m.Lock))) + i-- + dAtA[i] = 0x3a + } + if len(m.MinStake) > 0 { + i -= len(m.MinStake) + copy(dAtA[i:], m.MinStake) + i = encodeVarintTx(dAtA, i, uint64(len(m.MinStake))) + i-- + dAtA[i] = 0x32 + } + if len(m.Duration) > 0 { + i -= len(m.Duration) + copy(dAtA[i:], m.Duration) + i = encodeVarintTx(dAtA, i, uint64(len(m.Duration))) + i-- + dAtA[i] = 0x2a + } + if len(m.StakingDenom) > 0 { + i -= len(m.StakingDenom) + copy(dAtA[i:], m.StakingDenom) + i = encodeVarintTx(dAtA, i, uint64(len(m.StakingDenom))) + i-- + dAtA[i] = 0x22 + } + if len(m.PrizeDenom) > 0 { + i -= len(m.PrizeDenom) + copy(dAtA[i:], m.PrizeDenom) + i = encodeVarintTx(dAtA, i, uint64(len(m.PrizeDenom))) + i-- + dAtA[i] = 0x1a + } + if len(m.PrizeAmount) > 0 { + i -= len(m.PrizeAmount) + copy(dAtA[i:], m.PrizeAmount) + i = encodeVarintTx(dAtA, i, uint64(len(m.PrizeAmount))) + i-- + dAtA[i] = 0x12 + } + if len(m.Creator) > 0 { + i -= len(m.Creator) + copy(dAtA[i:], m.Creator) + i = encodeVarintTx(dAtA, i, uint64(len(m.Creator))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgCreateStakingRewardResponse) 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 *MsgCreateStakingRewardResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgCreateStakingRewardResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.RewardId) > 0 { + i -= len(m.RewardId) + copy(dAtA[i:], m.RewardId) + i = encodeVarintTx(dAtA, i, uint64(len(m.RewardId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgUpdateStakingReward) 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 *MsgUpdateStakingReward) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateStakingReward) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Duration) > 0 { + i -= len(m.Duration) + copy(dAtA[i:], m.Duration) + i = encodeVarintTx(dAtA, i, uint64(len(m.Duration))) + i-- + dAtA[i] = 0x1a + } + if len(m.RewardId) > 0 { + i -= len(m.RewardId) + copy(dAtA[i:], m.RewardId) + i = encodeVarintTx(dAtA, i, uint64(len(m.RewardId))) + i-- + dAtA[i] = 0x12 + } + if len(m.Creator) > 0 { + i -= len(m.Creator) + copy(dAtA[i:], m.Creator) + i = encodeVarintTx(dAtA, i, uint64(len(m.Creator))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgUpdateStakingRewardResponse) 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 *MsgUpdateStakingRewardResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgUpdateStakingRewardResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func encodeVarintTx(dAtA []byte, offset int, v uint64) int { + offset -= sovTx(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *MsgCreateStakingReward) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Creator) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.PrizeAmount) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.PrizeDenom) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.StakingDenom) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Duration) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.MinStake) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Lock) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgCreateStakingRewardResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.RewardId) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgUpdateStakingReward) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Creator) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.RewardId) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Duration) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgUpdateStakingRewardResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func sovTx(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozTx(x uint64) (n int) { + return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *MsgCreateStakingReward) 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 ErrIntOverflowTx + } + 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: MsgCreateStakingReward: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgCreateStakingReward: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Creator", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Creator = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PrizeAmount", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PrizeAmount = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PrizeDenom", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PrizeDenom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field StakingDenom", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.StakingDenom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Duration", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Duration = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MinStake", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.MinStake = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Lock", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Lock = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgCreateStakingRewardResponse) 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 ErrIntOverflowTx + } + 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: MsgCreateStakingRewardResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgCreateStakingRewardResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RewardId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.RewardId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgUpdateStakingReward) 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 ErrIntOverflowTx + } + 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: MsgUpdateStakingReward: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateStakingReward: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Creator", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Creator = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RewardId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.RewardId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Duration", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Duration = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgUpdateStakingRewardResponse) 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 ErrIntOverflowTx + } + 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: MsgUpdateStakingRewardResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateStakingRewardResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipTx(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, ErrIntOverflowTx + } + 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, ErrIntOverflowTx + } + 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, ErrIntOverflowTx + } + 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, ErrInvalidLengthTx + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupTx + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthTx + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthTx = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowTx = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupTx = fmt.Errorf("proto: unexpected end of group") +) From 6e0d90b19a94182b87d083c2e0969b3ece6130f6 Mon Sep 17 00:00:00 2001 From: faneaatiku Date: Thu, 14 Mar 2024 18:54:47 +0200 Subject: [PATCH 04/35] updated submit tx --- x/rewards/client/cli/tx_staking_reward.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/x/rewards/client/cli/tx_staking_reward.go b/x/rewards/client/cli/tx_staking_reward.go index 484e8ce8..97467b9d 100644 --- a/x/rewards/client/cli/tx_staking_reward.go +++ b/x/rewards/client/cli/tx_staking_reward.go @@ -20,7 +20,7 @@ func CmdCreateStakingReward() *cobra.Command { stakingDenom := args[2] duration := args[3] minStake := args[4] - lock := args[4] + lock := args[5] clientCtx, err := client.GetClientTxContext(cmd) if err != nil { @@ -50,7 +50,7 @@ func CmdCreateStakingReward() *cobra.Command { func CmdUpdateStakingReward() *cobra.Command { cmd := &cobra.Command{ - Use: "update-staking-reward [reward-id] [duration]", + Use: "update-staking-reward [reward-id] [duration-to-add]", Short: "Adds new funds to a staking reward for the specified duration", Args: cobra.ExactArgs(2), RunE: func(cmd *cobra.Command, args []string) (err error) { From 86c1c1dbf70839164bc92f81d5d8d46b2e3ec43b Mon Sep 17 00:00:00 2001 From: faneaatiku Date: Fri, 15 Mar 2024 00:40:07 +0200 Subject: [PATCH 05/35] rollback tradebin orders in case of disaster --- x/tradebin/keeper/queue_message_processor.go | 90 +++++++++++--------- 1 file changed, 52 insertions(+), 38 deletions(-) diff --git a/x/tradebin/keeper/queue_message_processor.go b/x/tradebin/keeper/queue_message_processor.go index 0f8d5b9f..c61def55 100644 --- a/x/tradebin/keeper/queue_message_processor.go +++ b/x/tradebin/keeper/queue_message_processor.go @@ -2,6 +2,7 @@ package keeper import ( "fmt" + "github.com/bze-alphateam/bze/bzeutils" "github.com/bze-alphateam/bze/x/tradebin/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/tendermint/tendermint/libs/log" @@ -83,75 +84,88 @@ func (pe *ProcessingEngine) ProcessQueueMessages(ctx sdk.Context) { func (pe *ProcessingEngine) getMessageHandler() func(ctx sdk.Context, message types.QueueMessage) { return func(ctx sdk.Context, message types.QueueMessage) { + var wrappingFn func(ctx sdk.Context) error + switch message.MessageType { case types.OrderTypeCancel: - pe.cancelOrder(ctx, message) + wrappingFn = func(ctx sdk.Context) error { + return pe.cancelOrder(ctx, message) + } default: - pe.addOrder(ctx, message) + wrappingFn = func(ctx sdk.Context) error { + return pe.addOrder(ctx, message) + } + } + + err := bzeutils.ApplyFuncIfNoError(ctx, wrappingFn) + if err != nil { + //leave the message on queue until we discover what the issue was. + pe.logger.Error("error on handling queue message", "message", message) + return } pe.msgsToDelete = append(pe.msgsToDelete, message.MessageId) } } -func (pe *ProcessingEngine) cancelOrder(ctx sdk.Context, message types.QueueMessage) { +func (pe *ProcessingEngine) cancelOrder(ctx sdk.Context, message types.QueueMessage) error { logger := pe.logger.With( "message", message, + "func", "cancelOrder", ) - logger.Info("cancelling order") + order, found := pe.k.GetOrder(ctx, message.MarketId, message.OrderType, message.OrderId) if !found { - return + logger.Error("could not find order") + return nil } pe.k.RemoveOrder(ctx, order) market, _ := pe.k.GetMarketById(ctx, order.MarketId) orderAmountInt, ok := sdk.NewIntFromString(order.Amount) if !ok { - //should never happen - logger.Error("could not convert order amount", "order", order) - return + + return fmt.Errorf("could not convert order amount") } coin, err := pe.k.GetOrderCoins(order.OrderType, order.Price, orderAmountInt, &market) if err != nil { - logger.Error("could not get order coins", "order", order, "error", err) - return + + return fmt.Errorf("could not get order coins: %v", err) } accAddr, err := sdk.AccAddressFromBech32(order.Owner) if err != nil { - logger. - Error("error on getting account address for order owner", "order", order, "error", err) - return + + return fmt.Errorf("error on getting account address for order owner: %v", err) } err = pe.bank.SendCoinsFromModuleToAccount(ctx, types.ModuleName, accAddr, sdk.NewCoins(coin)) if err != nil { - logger. - Error("error on sending funds to order owner", "error", err) - return + + return fmt.Errorf("error on sending funds to order owner: %v", err) } pe.removeOrderFromAggregate(ctx, &order) + pe.emitOrderCanceledEvent(ctx, &order) logger.Info("order cancelled") - pe.emitOrderCanceledEvent(ctx, &order) + return nil } -func (pe *ProcessingEngine) addOrder(ctx sdk.Context, message types.QueueMessage) { +func (pe *ProcessingEngine) addOrder(ctx sdk.Context, message types.QueueMessage) error { logger := pe.logger.With( "message", message, + "func", "addOrder", ) - logger.Info("adding new order on market") + zeroInt := sdk.ZeroInt() msgAmountInt, ok := sdk.NewIntFromString(message.Amount) if !ok { - //should never happen - logger.Error("could not convert queue message amount") - return + + return fmt.Errorf("could not convert queue message amount") } //find opposite orders if they exist @@ -160,16 +174,15 @@ func (pe *ProcessingEngine) addOrder(ctx sdk.Context, message types.QueueMessage if !found { order := pe.saveOrder(ctx, message, message.Amount) pe.addOrderToAggregate(ctx, order) - logger.Info("no orders to fill. saving as new order", "order", *order) - return + + return nil } aggAmountInt, ok := sdk.NewIntFromString(agg.Amount) if !ok { - //should never happen - logger.Error("could not convert agg amount", "agg_amount", agg.Amount) - return + + return fmt.Errorf("could not convert agg amount") } oppositeOrderRefs := pe.k.GetPriceOrderByPrice(ctx, message.MarketId, types.TheOtherOrderType(message.OrderType), message.Price) @@ -187,9 +200,8 @@ func (pe *ProcessingEngine) addOrder(ctx sdk.Context, message types.QueueMessage orderToFill, _ := pe.k.GetOrder(ctx, orderRef.MarketId, orderRef.OrderType, orderRef.Id) orderAmountInt, ok := sdk.NewIntFromString(orderToFill.Amount) if !ok { - //should never happen - logger.Error("could not convert order amount") - continue + + return fmt.Errorf("could not convert order to fill amount") } //find how much to send to the found order's owner @@ -209,8 +221,8 @@ func (pe *ProcessingEngine) addOrder(ctx sdk.Context, message types.QueueMessage err := pe.fundUsersAccounts(ctx, &orderToFill, &market, amountToExecute, msgOwnerAddr) if err != nil { - logger.Error(err.Error()) - return + + return err } if orderAmountInt.GT(zeroInt) { @@ -233,7 +245,7 @@ func (pe *ProcessingEngine) addOrder(ctx sdk.Context, message types.QueueMessage if msgAmountInt.Equal(zeroInt) { logger.Info("message was completely filled") - return + return nil } //if min amount condition is met and all orders were filled we can proceed to place the order @@ -243,22 +255,24 @@ func (pe *ProcessingEngine) addOrder(ctx sdk.Context, message types.QueueMessage pe.addOrderToAggregate(ctx, order) logger.Info("message has been saved as order", "order", *order) - return + return nil } logger.Info("message remaining amount is too low, returning dust") //we have a remaining amount smaller than min amount. We should send it back to the msg owner coinsForMsgOwner, err := pe.k.GetOrderCoins(message.OrderType, message.Price, msgAmountInt, &market) if err != nil { - logger.Error("error when creating funds to return to message owner", "error", err.Error()) - return + + return fmt.Errorf("error when creating funds to return to message owner: %v", err) } err = pe.bank.SendCoinsFromModuleToAccount(ctx, types.ModuleName, msgOwnerAddr, sdk.NewCoins(coinsForMsgOwner)) if err != nil { - logger.Error("error when returning funds to message owner", "error", err.Error()) - return + + return fmt.Errorf("error when returning funds to message owner: %v", err) } + + return nil } func (pe *ProcessingEngine) fundUsersAccounts(ctx sdk.Context, order *types.Order, market *types.Market, amount sdk.Int, taker sdk.AccAddress) error { From e7eaac4f809d464f70bc1673374383f1201b1083 Mon Sep 17 00:00:00 2001 From: faneaatiku Date: Fri, 15 Mar 2024 16:27:33 +0200 Subject: [PATCH 06/35] add rewards messages, queries and cli --- app/app.go | 1 + docs/static/openapi.yml | 289 ++++- proto/rewards/genesis.proto | 2 + proto/rewards/query.proto | 29 + proto/rewards/staking_reward.proto | 4 +- proto/rewards/trading_reward.proto | 14 + proto/rewards/tx.proto | 16 +- testutil/keeper/rewards.go | 1 + .../bze-alphateam/bze/bze.v1.rewards/index.ts | 94 +- .../bze/bze.v1.rewards/module/index.ts | 3 + .../bze/bze.v1.rewards/module/rest.ts | 82 +- .../module/types/rewards/genesis.ts | 37 + .../module/types/rewards/query.ts | 373 ++++++ .../module/types/rewards/staking_reward.ts | 40 +- .../module/types/rewards/trading_reward.ts | 173 +++ .../bze.v1.rewards/module/types/rewards/tx.ts | 259 +++- x/rewards/client/cli/query.go | 4 +- x/rewards/client/cli/query_trading_reward.go | 73 ++ .../client/cli/query_trading_reward_test.go | 163 +++ x/rewards/client/cli/tx.go | 1 + x/rewards/client/cli/tx_trading_reward.go | 47 + .../client/cli/tx_trading_reward_test.go | 191 +++ x/rewards/genesis.go | 6 + x/rewards/genesis_test.go | 9 + x/rewards/handler.go | 5 +- x/rewards/keeper/grpc_query_trading_reward.go | 54 + .../keeper/grpc_query_trading_reward_test.go | 129 ++ x/rewards/keeper/keeper.go | 21 +- x/rewards/keeper/msg_server_staking_reward.go | 59 +- x/rewards/keeper/msg_server_trading_reward.go | 106 ++ .../keeper/msg_server_trading_reward_test.go | 154 +++ x/rewards/keeper/trading_reward.go | 49 + x/rewards/keeper/trading_reward_test.go | 66 + x/rewards/module_simulation.go | 23 + x/rewards/simulation/trading_reward.go | 48 + x/rewards/types/codec.go | 4 + x/rewards/types/errors.go | 2 + x/rewards/types/expected_keepers.go | 4 + x/rewards/types/genesis.go | 15 +- x/rewards/types/genesis.pb.go | 93 +- x/rewards/types/genesis_test.go | 22 + x/rewards/types/key_staking_reward.go | 5 - x/rewards/types/key_trading_reward.go | 19 + x/rewards/types/messages_staking_reward.go | 2 +- x/rewards/types/messages_trading_reward.go | 112 ++ .../types/messages_trading_reward_test.go | 102 ++ x/rewards/types/query.pb.go | 1098 +++++++++++++++-- x/rewards/types/query.pb.gw.go | 184 +++ x/rewards/types/staking_reward.pb.go | 79 +- x/rewards/types/trading_reward.pb.go | 544 ++++++++ x/rewards/types/tx.pb.go | 686 +++++++++- x/tradebin/keeper/market.go | 6 + 52 files changed, 5320 insertions(+), 282 deletions(-) create mode 100644 proto/rewards/trading_reward.proto create mode 100644 vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/trading_reward.ts create mode 100644 x/rewards/client/cli/query_trading_reward.go create mode 100644 x/rewards/client/cli/query_trading_reward_test.go create mode 100644 x/rewards/client/cli/tx_trading_reward.go create mode 100644 x/rewards/client/cli/tx_trading_reward_test.go create mode 100644 x/rewards/keeper/grpc_query_trading_reward.go create mode 100644 x/rewards/keeper/grpc_query_trading_reward_test.go create mode 100644 x/rewards/keeper/msg_server_trading_reward.go create mode 100644 x/rewards/keeper/msg_server_trading_reward_test.go create mode 100644 x/rewards/keeper/trading_reward.go create mode 100644 x/rewards/keeper/trading_reward_test.go create mode 100644 x/rewards/simulation/trading_reward.go create mode 100644 x/rewards/types/key_trading_reward.go create mode 100644 x/rewards/types/messages_trading_reward.go create mode 100644 x/rewards/types/messages_trading_reward_test.go create mode 100644 x/rewards/types/trading_reward.pb.go diff --git a/app/app.go b/app/app.go index feebcf65..e3e21c0f 100644 --- a/app/app.go +++ b/app/app.go @@ -474,6 +474,7 @@ func New( app.GetSubspace(rewardstypes.ModuleName), app.BankKeeper, app.DistrKeeper, + app.TradebinKeeper, ) scavengeModule := scavengemodule.NewAppModule(appCodec, app.ScavengeKeeper) diff --git a/docs/static/openapi.yml b/docs/static/openapi.yml index 72065648..3f9b011f 100644 --- a/docs/static/openapi.yml +++ b/docs/static/openapi.yml @@ -2211,7 +2211,6 @@ paths: type: string prize_amount: type: string - format: int64 prize_denom: type: string staking_denom: @@ -2222,7 +2221,7 @@ paths: payouts: type: integer format: int64 - minStake: + min_stake: type: string format: uint64 lock: @@ -2349,7 +2348,6 @@ paths: type: string prize_amount: type: string - format: int64 prize_denom: type: string staking_denom: @@ -2360,7 +2358,7 @@ paths: payouts: type: integer format: int64 - minStake: + min_stake: type: string format: uint64 lock: @@ -2391,6 +2389,191 @@ paths: type: string tags: - Query + /bze/rewards/v1/trading_reward: + get: + summary: Queries a list of TradingReward items. + operationId: BzeV1RewardsTradingRewardAll + responses: + '200': + description: A successful response. + schema: + type: object + properties: + tradingReward: + type: array + items: + type: object + properties: + reward_id: + type: string + prize_amount: + type: string + prize_denom: + type: string + duration: + type: integer + format: int64 + market_id: + type: string + slots: + type: integer + format: int64 + pagination: + type: object + properties: + next_key: + type: string + format: byte + title: |- + next_key is the key to be passed to PageRequest.key to + query the next page most efficiently + total: + type: string + format: uint64 + title: >- + total is total number of results available if + PageRequest.count_total + + was set, its value is undefined otherwise + description: >- + PageResponse is to be embedded in gRPC response messages where + the + + corresponding request message has used PageRequest. + + message SomeResponse { + repeated Bar results = 1; + PageResponse page = 2; + } + 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: {} + parameters: + - name: pagination.key + description: |- + key is a value returned in PageResponse.next_key to begin + querying the next page most efficiently. Only one of offset or key + should be set. + in: query + required: false + type: string + format: byte + - name: pagination.offset + description: >- + offset is a numeric offset that can be used when key is unavailable. + + It is less efficient than using key. Only one of offset or key + should + + be set. + in: query + required: false + type: string + format: uint64 + - name: pagination.limit + description: >- + limit is the total number of results to be returned in the result + page. + + If left empty it will default to a value to be set by each app. + in: query + required: false + type: string + format: uint64 + - name: pagination.count_total + description: >- + count_total is set to true to indicate that the result set should + include + + a count of the total number of items available for pagination in + UIs. + + count_total is only respected when offset is used. It is ignored + when key + + is set. + in: query + required: false + type: boolean + - name: pagination.reverse + description: >- + reverse is set to true if results are to be returned in the + descending order. + + + Since: cosmos-sdk 0.43 + in: query + required: false + type: boolean + tags: + - Query + '/bze/rewards/v1/trading_reward/{rewardId}': + get: + summary: Queries a TradingReward by index. + operationId: BzeV1RewardsTradingReward + responses: + '200': + description: A successful response. + schema: + type: object + properties: + tradingReward: + type: object + properties: + reward_id: + type: string + prize_amount: + type: string + prize_denom: + type: string + duration: + type: integer + format: int64 + market_id: + type: string + slots: + type: integer + format: int64 + 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: {} + parameters: + - name: rewardId + in: path + required: true + type: string + tags: + - Query /cosmos/auth/v1beta1/accounts: get: summary: Accounts returns all the existing accounts @@ -34165,6 +34348,11 @@ definitions: properties: reward_id: type: string + bze.v1.rewards.MsgCreateTradingRewardResponse: + type: object + properties: + reward_id: + type: string bze.v1.rewards.MsgUpdateStakingRewardResponse: type: object bze.v1.rewards.Params: @@ -34187,7 +34375,6 @@ definitions: type: string prize_amount: type: string - format: int64 prize_denom: type: string staking_denom: @@ -34198,7 +34385,7 @@ definitions: payouts: type: integer format: int64 - minStake: + min_stake: type: string format: uint64 lock: @@ -34229,6 +34416,53 @@ definitions: repeated Bar results = 1; PageResponse page = 2; } + bze.v1.rewards.QueryAllTradingRewardResponse: + type: object + properties: + tradingReward: + type: array + items: + type: object + properties: + reward_id: + type: string + prize_amount: + type: string + prize_denom: + type: string + duration: + type: integer + format: int64 + market_id: + type: string + slots: + type: integer + format: int64 + pagination: + type: object + properties: + next_key: + type: string + format: byte + title: |- + next_key is the key to be passed to PageRequest.key to + query the next page most efficiently + total: + type: string + format: uint64 + title: >- + total is total number of results available if + PageRequest.count_total + + was set, its value is undefined otherwise + description: |- + PageResponse is to be embedded in gRPC response messages where the + corresponding request message has used PageRequest. + + message SomeResponse { + repeated Bar results = 1; + PageResponse page = 2; + } bze.v1.rewards.QueryGetStakingRewardResponse: type: object properties: @@ -34239,7 +34473,6 @@ definitions: type: string prize_amount: type: string - format: int64 prize_denom: type: string staking_denom: @@ -34250,12 +34483,32 @@ definitions: payouts: type: integer format: int64 - minStake: + min_stake: type: string format: uint64 lock: type: integer format: int64 + bze.v1.rewards.QueryGetTradingRewardResponse: + type: object + properties: + tradingReward: + type: object + properties: + reward_id: + type: string + prize_amount: + type: string + prize_denom: + type: string + duration: + type: integer + format: int64 + market_id: + type: string + slots: + type: integer + format: int64 bze.v1.rewards.QueryParamsResponse: type: object properties: @@ -34275,7 +34528,6 @@ definitions: type: string prize_amount: type: string - format: int64 prize_denom: type: string staking_denom: @@ -34286,12 +34538,29 @@ definitions: payouts: type: integer format: int64 - minStake: + min_stake: type: string format: uint64 lock: type: integer format: int64 + bze.v1.rewards.TradingReward: + type: object + properties: + reward_id: + type: string + prize_amount: + type: string + prize_denom: + type: string + duration: + type: integer + format: int64 + market_id: + type: string + slots: + type: integer + format: int64 cosmos.auth.v1beta1.Params: type: object properties: diff --git a/proto/rewards/genesis.proto b/proto/rewards/genesis.proto index 250aa889..19637dee 100644 --- a/proto/rewards/genesis.proto +++ b/proto/rewards/genesis.proto @@ -4,6 +4,7 @@ package bze.v1.rewards; import "gogoproto/gogo.proto"; import "rewards/params.proto"; import "rewards/staking_reward.proto"; +import "rewards/trading_reward.proto"; // this line is used by starport scaffolding # genesis/proto/import option go_package = "github.com/bze-alphateam/bze/x/rewards/types"; @@ -15,5 +16,6 @@ message GenesisState { uint64 staking_rewards_counter = 3; uint64 trading_rewards_counter = 4; + repeated TradingReward tradingRewardList = 5 [(gogoproto.nullable) = false]; // this line is used by starport scaffolding # genesis/proto/state } diff --git a/proto/rewards/query.proto b/proto/rewards/query.proto index 8fa1da84..81202599 100644 --- a/proto/rewards/query.proto +++ b/proto/rewards/query.proto @@ -6,6 +6,7 @@ import "google/api/annotations.proto"; import "cosmos/base/query/v1beta1/pagination.proto"; import "rewards/params.proto"; import "rewards/staking_reward.proto"; +import "rewards/trading_reward.proto"; // this line is used by starport scaffolding # 1 option go_package = "github.com/bze-alphateam/bze/x/rewards/types"; @@ -26,6 +27,16 @@ service Query { option (google.api.http).get = "/bze/rewards/v1/staking_reward"; } +// Queries a TradingReward by index. + rpc TradingReward(QueryGetTradingRewardRequest) returns (QueryGetTradingRewardResponse) { + option (google.api.http).get = "/bze/rewards/v1/trading_reward/{rewardId}"; + } + + // Queries a list of TradingReward items. + rpc TradingRewardAll(QueryAllTradingRewardRequest) returns (QueryAllTradingRewardResponse) { + option (google.api.http).get = "/bze/rewards/v1/trading_reward"; + } + // this line is used by starport scaffolding # 2 } @@ -55,4 +66,22 @@ message QueryAllStakingRewardResponse { cosmos.base.query.v1beta1.PageResponse pagination = 2; } +message QueryGetTradingRewardRequest { + string rewardId = 1; + +} + +message QueryGetTradingRewardResponse { + TradingReward tradingReward = 1 [(gogoproto.nullable) = false]; +} + +message QueryAllTradingRewardRequest { + cosmos.base.query.v1beta1.PageRequest pagination = 1; +} + +message QueryAllTradingRewardResponse { + repeated TradingReward tradingReward = 1 [(gogoproto.nullable) = false]; + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} + // this line is used by starport scaffolding # 3 diff --git a/proto/rewards/staking_reward.proto b/proto/rewards/staking_reward.proto index 438c0200..b8bbf527 100644 --- a/proto/rewards/staking_reward.proto +++ b/proto/rewards/staking_reward.proto @@ -5,12 +5,12 @@ option go_package = "github.com/bze-alphateam/bze/x/rewards/types"; message StakingReward { string reward_id = 1; - int64 prize_amount = 2; + string prize_amount = 2; string prize_denom = 3; string staking_denom = 4; uint32 duration = 5; uint32 payouts = 6; - uint64 minStake = 7; + uint64 min_stake = 7; uint32 lock = 8; } diff --git a/proto/rewards/trading_reward.proto b/proto/rewards/trading_reward.proto new file mode 100644 index 00000000..da24e318 --- /dev/null +++ b/proto/rewards/trading_reward.proto @@ -0,0 +1,14 @@ +syntax = "proto3"; +package bze.v1.rewards; + +option go_package = "github.com/bze-alphateam/bze/x/rewards/types"; + +message TradingReward { + string reward_id = 1; + string prize_amount = 2; + string prize_denom = 3; + uint32 duration = 4; + string market_id = 5; + uint32 slots = 6; +} + diff --git a/proto/rewards/tx.proto b/proto/rewards/tx.proto index b1e62bd2..939dff65 100644 --- a/proto/rewards/tx.proto +++ b/proto/rewards/tx.proto @@ -1,6 +1,7 @@ syntax = "proto3"; package bze.v1.rewards; +import "rewards/trading_reward.proto"; // this line is used by starport scaffolding # proto/tx/import option go_package = "github.com/bze-alphateam/bze/x/rewards/types"; @@ -9,12 +10,13 @@ option go_package = "github.com/bze-alphateam/bze/x/rewards/types"; service Msg { rpc CreateStakingReward(MsgCreateStakingReward) returns (MsgCreateStakingRewardResponse); rpc UpdateStakingReward(MsgUpdateStakingReward) returns (MsgUpdateStakingRewardResponse); + rpc CreateTradingReward(MsgCreateTradingReward) returns (MsgCreateTradingRewardResponse); // this line is used by starport scaffolding # proto/tx/rpc } message MsgCreateStakingReward { string creator = 1; //msg creator - string prize_amount = 2; //the amount paid as prize + string prize_amount = 2; //the amount paid as prize for each epoch (duration) string prize_denom = 3; //the denom paid as prize string staking_denom = 4; //the denom a user has to stake in order to qualify string duration = 5; // the number of days the rewards are paid @@ -33,4 +35,16 @@ message MsgUpdateStakingReward { } message MsgUpdateStakingRewardResponse {} +message MsgCreateTradingReward { + string creator = 1; + string prize_amount = 2; //the amount paid as prize for each slot + string prize_denom = 3; //the denom paid as prize + string duration = 4; + string market_id = 5; + string slots = 6; +} +message MsgCreateTradingRewardResponse { + string reward_id = 1; +} + // this line is used by starport scaffolding # proto/tx/message diff --git a/testutil/keeper/rewards.go b/testutil/keeper/rewards.go index c10a70d9..6d9a808a 100644 --- a/testutil/keeper/rewards.go +++ b/testutil/keeper/rewards.go @@ -43,6 +43,7 @@ func RewardsKeeper(t testing.TB) (*keeper.Keeper, sdk.Context) { paramsSubspace, nil, nil, + nil, ) ctx := sdk.NewContext(stateStore, tmproto.Header{}, false, log.NewNopLogger()) diff --git a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/index.ts b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/index.ts index c1606760..ec509211 100755 --- a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/index.ts +++ b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/index.ts @@ -2,9 +2,10 @@ import { txClient, queryClient, MissingWalletError , registry} from './module' import { Params } from "./module/types/rewards/params" import { StakingReward } from "./module/types/rewards/staking_reward" +import { TradingReward } from "./module/types/rewards/trading_reward" -export { Params, StakingReward }; +export { Params, StakingReward, TradingReward }; async function initTxClient(vuexGetters) { return await txClient(vuexGetters['common/wallet/signer'], { @@ -45,10 +46,13 @@ const getDefaultState = () => { Params: {}, StakingReward: {}, StakingRewardAll: {}, + TradingReward: {}, + TradingRewardAll: {}, _Structure: { Params: getStructure(Params.fromPartial({})), StakingReward: getStructure(StakingReward.fromPartial({})), + TradingReward: getStructure(TradingReward.fromPartial({})), }, _Registry: registry, @@ -95,6 +99,18 @@ export default { } return state.StakingRewardAll[JSON.stringify(params)] ?? {} }, + getTradingReward: (state) => (params = { params: {}}) => { + if (!( params).query) { + ( params).query=null + } + return state.TradingReward[JSON.stringify(params)] ?? {} + }, + getTradingRewardAll: (state) => (params = { params: {}}) => { + if (!( params).query) { + ( params).query=null + } + return state.TradingRewardAll[JSON.stringify(params)] ?? {} + }, getTypeStructure: (state) => (type) => { return state._Structure[type].fields @@ -199,6 +215,54 @@ export default { }, + + + + + + async QueryTradingReward({ commit, rootGetters, getters }, { options: { subscribe, all} = { subscribe:false, all:false}, params, query=null }) { + try { + const key = params ?? {}; + const queryClient=await initQueryClient(rootGetters) + let value= (await queryClient.queryTradingReward( key.rewardId)).data + + + commit('QUERY', { query: 'TradingReward', key: { params: {...key}, query}, value }) + if (subscribe) commit('SUBSCRIBE', { action: 'QueryTradingReward', payload: { options: { all }, params: {...key},query }}) + return getters['getTradingReward']( { params: {...key}, query}) ?? {} + } catch (e) { + throw new Error('QueryClient:QueryTradingReward API Node Unavailable. Could not perform query: ' + e.message) + + } + }, + + + + + + + + async QueryTradingRewardAll({ commit, rootGetters, getters }, { options: { subscribe, all} = { subscribe:false, all:false}, params, query=null }) { + try { + const key = params ?? {}; + const queryClient=await initQueryClient(rootGetters) + let value= (await queryClient.queryTradingRewardAll(query)).data + + + while (all && ( value).pagination && ( value).pagination.next_key!=null) { + let next_values=(await queryClient.queryTradingRewardAll({...query, 'pagination.key':( value).pagination.next_key})).data + value = mergeResults(value, next_values); + } + commit('QUERY', { query: 'TradingRewardAll', key: { params: {...key}, query}, value }) + if (subscribe) commit('SUBSCRIBE', { action: 'QueryTradingRewardAll', payload: { options: { all }, params: {...key},query }}) + return getters['getTradingRewardAll']( { params: {...key}, query}) ?? {} + } catch (e) { + throw new Error('QueryClient:QueryTradingRewardAll API Node Unavailable. Could not perform query: ' + e.message) + + } + }, + + async sendMsgUpdateStakingReward({ rootGetters }, { value, fee = [], memo = '' }) { try { const txClient=await initTxClient(rootGetters) @@ -214,6 +278,21 @@ export default { } } }, + async sendMsgCreateTradingReward({ rootGetters }, { value, fee = [], memo = '' }) { + try { + const txClient=await initTxClient(rootGetters) + const msg = await txClient.msgCreateTradingReward(value) + const result = await txClient.signAndBroadcast([msg], {fee: { amount: fee, + gas: "200000" }, memo}) + return result + } catch (e) { + if (e == MissingWalletError) { + throw new Error('TxClient:MsgCreateTradingReward:Init Could not initialize signing client. Wallet is required.') + }else{ + throw new Error('TxClient:MsgCreateTradingReward:Send Could not broadcast Tx: '+ e.message) + } + } + }, async sendMsgCreateStakingReward({ rootGetters }, { value, fee = [], memo = '' }) { try { const txClient=await initTxClient(rootGetters) @@ -243,6 +322,19 @@ export default { } } }, + async MsgCreateTradingReward({ rootGetters }, { value }) { + try { + const txClient=await initTxClient(rootGetters) + const msg = await txClient.msgCreateTradingReward(value) + return msg + } catch (e) { + if (e == MissingWalletError) { + throw new Error('TxClient:MsgCreateTradingReward:Init Could not initialize signing client. Wallet is required.') + } else{ + throw new Error('TxClient:MsgCreateTradingReward:Create Could not create message: ' + e.message) + } + } + }, async MsgCreateStakingReward({ rootGetters }, { value }) { try { const txClient=await initTxClient(rootGetters) diff --git a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/index.ts b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/index.ts index c220683c..d5dab190 100755 --- a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/index.ts +++ b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/index.ts @@ -5,11 +5,13 @@ import { SigningStargateClient } from "@cosmjs/stargate"; import { Registry, OfflineSigner, EncodeObject, DirectSecp256k1HdWallet } from "@cosmjs/proto-signing"; import { Api } from "./rest"; import { MsgUpdateStakingReward } from "./types/rewards/tx"; +import { MsgCreateTradingReward } from "./types/rewards/tx"; import { MsgCreateStakingReward } from "./types/rewards/tx"; const types = [ ["/bze.v1.rewards.MsgUpdateStakingReward", MsgUpdateStakingReward], + ["/bze.v1.rewards.MsgCreateTradingReward", MsgCreateTradingReward], ["/bze.v1.rewards.MsgCreateStakingReward", MsgCreateStakingReward], ]; @@ -44,6 +46,7 @@ const txClient = async (wallet: OfflineSigner, { addr: addr }: TxClientOptions = return { signAndBroadcast: (msgs: EncodeObject[], { fee, memo }: SignAndBroadcastOptions = {fee: defaultFee, memo: ""}) => client.signAndBroadcast(address, msgs, fee,memo), msgUpdateStakingReward: (data: MsgUpdateStakingReward): EncodeObject => ({ typeUrl: "/bze.v1.rewards.MsgUpdateStakingReward", value: MsgUpdateStakingReward.fromPartial( data ) }), + msgCreateTradingReward: (data: MsgCreateTradingReward): EncodeObject => ({ typeUrl: "/bze.v1.rewards.MsgCreateTradingReward", value: MsgCreateTradingReward.fromPartial( data ) }), msgCreateStakingReward: (data: MsgCreateStakingReward): EncodeObject => ({ typeUrl: "/bze.v1.rewards.MsgCreateStakingReward", value: MsgCreateStakingReward.fromPartial( data ) }), }; diff --git a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/rest.ts b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/rest.ts index 0867c357..c83ed530 100644 --- a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/rest.ts +++ b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/rest.ts @@ -17,6 +17,10 @@ export interface RewardsMsgCreateStakingRewardResponse { reward_id?: string; } +export interface RewardsMsgCreateTradingRewardResponse { + reward_id?: string; +} + export type RewardsMsgUpdateStakingRewardResponse = object; export interface RewardsQueryAllStakingRewardResponse { @@ -34,10 +38,29 @@ export interface RewardsQueryAllStakingRewardResponse { pagination?: V1Beta1PageResponse; } +export interface RewardsQueryAllTradingRewardResponse { + tradingReward?: V1RewardsTradingReward[]; + + /** + * PageResponse is to be embedded in gRPC response messages where the + * corresponding request message has used PageRequest. + * + * message SomeResponse { + * repeated Bar results = 1; + * PageResponse page = 2; + * } + */ + pagination?: V1Beta1PageResponse; +} + export interface RewardsQueryGetStakingRewardResponse { staking_reward?: V1RewardsStakingReward; } +export interface RewardsQueryGetTradingRewardResponse { + tradingReward?: V1RewardsTradingReward; +} + /** * QueryParamsResponse is response type for the Query/Params RPC method. */ @@ -126,8 +149,6 @@ export interface V1RewardsParams { export interface V1RewardsStakingReward { reward_id?: string; - - /** @format int64 */ prize_amount?: string; prize_denom?: string; staking_denom?: string; @@ -139,12 +160,25 @@ export interface V1RewardsStakingReward { payouts?: number; /** @format uint64 */ - minStake?: string; + min_stake?: string; /** @format int64 */ lock?: number; } +export interface V1RewardsTradingReward { + reward_id?: string; + prize_amount?: string; + prize_denom?: string; + + /** @format int64 */ + duration?: number; + market_id?: string; + + /** @format int64 */ + slots?: number; +} + export type QueryParamsType = Record; export type ResponseFormat = keyof Omit; @@ -398,4 +432,46 @@ export class Api extends HttpClient + this.request({ + path: `/bze/rewards/v1/trading_reward`, + method: "GET", + query: query, + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Query + * @name QueryTradingReward + * @summary Queries a TradingReward by index. + * @request GET:/bze/rewards/v1/trading_reward/{rewardId} + */ + queryTradingReward = (rewardId: string, params: RequestParams = {}) => + this.request({ + path: `/bze/rewards/v1/trading_reward/${rewardId}`, + method: "GET", + format: "json", + ...params, + }); } diff --git a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/genesis.ts b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/genesis.ts index fb45139d..99afb632 100644 --- a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/genesis.ts +++ b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/genesis.ts @@ -3,6 +3,7 @@ import * as Long from "long"; import { util, configure, Writer, Reader } from "protobufjs/minimal"; import { Params } from "../rewards/params"; import { StakingReward } from "../rewards/staking_reward"; +import { TradingReward } from "../rewards/trading_reward"; export const protobufPackage = "bze.v1.rewards"; @@ -12,6 +13,8 @@ export interface GenesisState { staking_reward_list: StakingReward[]; staking_rewards_counter: number; trading_rewards_counter: number; + /** this line is used by starport scaffolding # genesis/proto/state */ + tradingRewardList: TradingReward[]; } const baseGenesisState: object = { @@ -33,6 +36,9 @@ export const GenesisState = { if (message.trading_rewards_counter !== 0) { writer.uint32(32).uint64(message.trading_rewards_counter); } + for (const v of message.tradingRewardList) { + TradingReward.encode(v!, writer.uint32(42).fork()).ldelim(); + } return writer; }, @@ -41,6 +47,7 @@ export const GenesisState = { let end = length === undefined ? reader.len : reader.pos + length; const message = { ...baseGenesisState } as GenesisState; message.staking_reward_list = []; + message.tradingRewardList = []; while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { @@ -62,6 +69,11 @@ export const GenesisState = { reader.uint64() as Long ); break; + case 5: + message.tradingRewardList.push( + TradingReward.decode(reader, reader.uint32()) + ); + break; default: reader.skipType(tag & 7); break; @@ -73,6 +85,7 @@ export const GenesisState = { fromJSON(object: any): GenesisState { const message = { ...baseGenesisState } as GenesisState; message.staking_reward_list = []; + message.tradingRewardList = []; if (object.params !== undefined && object.params !== null) { message.params = Params.fromJSON(object.params); } else { @@ -102,6 +115,14 @@ export const GenesisState = { } else { message.trading_rewards_counter = 0; } + if ( + object.tradingRewardList !== undefined && + object.tradingRewardList !== null + ) { + for (const e of object.tradingRewardList) { + message.tradingRewardList.push(TradingReward.fromJSON(e)); + } + } return message; }, @@ -120,12 +141,20 @@ export const GenesisState = { (obj.staking_rewards_counter = message.staking_rewards_counter); message.trading_rewards_counter !== undefined && (obj.trading_rewards_counter = message.trading_rewards_counter); + if (message.tradingRewardList) { + obj.tradingRewardList = message.tradingRewardList.map((e) => + e ? TradingReward.toJSON(e) : undefined + ); + } else { + obj.tradingRewardList = []; + } return obj; }, fromPartial(object: DeepPartial): GenesisState { const message = { ...baseGenesisState } as GenesisState; message.staking_reward_list = []; + message.tradingRewardList = []; if (object.params !== undefined && object.params !== null) { message.params = Params.fromPartial(object.params); } else { @@ -155,6 +184,14 @@ export const GenesisState = { } else { message.trading_rewards_counter = 0; } + if ( + object.tradingRewardList !== undefined && + object.tradingRewardList !== null + ) { + for (const e of object.tradingRewardList) { + message.tradingRewardList.push(TradingReward.fromPartial(e)); + } + } return message; }, }; diff --git a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/query.ts b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/query.ts index dc2922b3..67d92646 100644 --- a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/query.ts +++ b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/query.ts @@ -6,6 +6,7 @@ import { PageRequest, PageResponse, } from "../cosmos/base/query/v1beta1/pagination"; +import { TradingReward } from "../rewards/trading_reward"; export const protobufPackage = "bze.v1.rewards"; @@ -35,6 +36,23 @@ export interface QueryAllStakingRewardResponse { pagination: PageResponse | undefined; } +export interface QueryGetTradingRewardRequest { + rewardId: string; +} + +export interface QueryGetTradingRewardResponse { + tradingReward: TradingReward | undefined; +} + +export interface QueryAllTradingRewardRequest { + pagination: PageRequest | undefined; +} + +export interface QueryAllTradingRewardResponse { + tradingReward: TradingReward[]; + pagination: PageResponse | undefined; +} + const baseQueryParamsRequest: object = {}; export const QueryParamsRequest = { @@ -452,6 +470,325 @@ export const QueryAllStakingRewardResponse = { }, }; +const baseQueryGetTradingRewardRequest: object = { rewardId: "" }; + +export const QueryGetTradingRewardRequest = { + encode( + message: QueryGetTradingRewardRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.rewardId !== "") { + writer.uint32(10).string(message.rewardId); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryGetTradingRewardRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryGetTradingRewardRequest, + } as QueryGetTradingRewardRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.rewardId = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryGetTradingRewardRequest { + const message = { + ...baseQueryGetTradingRewardRequest, + } as QueryGetTradingRewardRequest; + if (object.rewardId !== undefined && object.rewardId !== null) { + message.rewardId = String(object.rewardId); + } else { + message.rewardId = ""; + } + return message; + }, + + toJSON(message: QueryGetTradingRewardRequest): unknown { + const obj: any = {}; + message.rewardId !== undefined && (obj.rewardId = message.rewardId); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryGetTradingRewardRequest { + const message = { + ...baseQueryGetTradingRewardRequest, + } as QueryGetTradingRewardRequest; + if (object.rewardId !== undefined && object.rewardId !== null) { + message.rewardId = object.rewardId; + } else { + message.rewardId = ""; + } + return message; + }, +}; + +const baseQueryGetTradingRewardResponse: object = {}; + +export const QueryGetTradingRewardResponse = { + encode( + message: QueryGetTradingRewardResponse, + writer: Writer = Writer.create() + ): Writer { + if (message.tradingReward !== undefined) { + TradingReward.encode( + message.tradingReward, + writer.uint32(10).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryGetTradingRewardResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryGetTradingRewardResponse, + } as QueryGetTradingRewardResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.tradingReward = TradingReward.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryGetTradingRewardResponse { + const message = { + ...baseQueryGetTradingRewardResponse, + } as QueryGetTradingRewardResponse; + if (object.tradingReward !== undefined && object.tradingReward !== null) { + message.tradingReward = TradingReward.fromJSON(object.tradingReward); + } else { + message.tradingReward = undefined; + } + return message; + }, + + toJSON(message: QueryGetTradingRewardResponse): unknown { + const obj: any = {}; + message.tradingReward !== undefined && + (obj.tradingReward = message.tradingReward + ? TradingReward.toJSON(message.tradingReward) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryGetTradingRewardResponse { + const message = { + ...baseQueryGetTradingRewardResponse, + } as QueryGetTradingRewardResponse; + if (object.tradingReward !== undefined && object.tradingReward !== null) { + message.tradingReward = TradingReward.fromPartial(object.tradingReward); + } else { + message.tradingReward = undefined; + } + return message; + }, +}; + +const baseQueryAllTradingRewardRequest: object = {}; + +export const QueryAllTradingRewardRequest = { + encode( + message: QueryAllTradingRewardRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryAllTradingRewardRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryAllTradingRewardRequest, + } as QueryAllTradingRewardRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryAllTradingRewardRequest { + const message = { + ...baseQueryAllTradingRewardRequest, + } as QueryAllTradingRewardRequest; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryAllTradingRewardRequest): unknown { + const obj: any = {}; + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageRequest.toJSON(message.pagination) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryAllTradingRewardRequest { + const message = { + ...baseQueryAllTradingRewardRequest, + } as QueryAllTradingRewardRequest; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseQueryAllTradingRewardResponse: object = {}; + +export const QueryAllTradingRewardResponse = { + encode( + message: QueryAllTradingRewardResponse, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.tradingReward) { + TradingReward.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode( + message.pagination, + writer.uint32(18).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryAllTradingRewardResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryAllTradingRewardResponse, + } as QueryAllTradingRewardResponse; + message.tradingReward = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.tradingReward.push( + TradingReward.decode(reader, reader.uint32()) + ); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryAllTradingRewardResponse { + const message = { + ...baseQueryAllTradingRewardResponse, + } as QueryAllTradingRewardResponse; + message.tradingReward = []; + if (object.tradingReward !== undefined && object.tradingReward !== null) { + for (const e of object.tradingReward) { + message.tradingReward.push(TradingReward.fromJSON(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryAllTradingRewardResponse): unknown { + const obj: any = {}; + if (message.tradingReward) { + obj.tradingReward = message.tradingReward.map((e) => + e ? TradingReward.toJSON(e) : undefined + ); + } else { + obj.tradingReward = []; + } + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageResponse.toJSON(message.pagination) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryAllTradingRewardResponse { + const message = { + ...baseQueryAllTradingRewardResponse, + } as QueryAllTradingRewardResponse; + message.tradingReward = []; + if (object.tradingReward !== undefined && object.tradingReward !== null) { + for (const e of object.tradingReward) { + message.tradingReward.push(TradingReward.fromPartial(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + /** Query defines the gRPC querier service. */ export interface Query { /** Parameters queries the parameters of the module. */ @@ -464,6 +801,14 @@ export interface Query { StakingRewardAll( request: QueryAllStakingRewardRequest ): Promise; + /** Queries a TradingReward by index. */ + TradingReward( + request: QueryGetTradingRewardRequest + ): Promise; + /** Queries a list of TradingReward items. */ + TradingRewardAll( + request: QueryAllTradingRewardRequest + ): Promise; } export class QueryClientImpl implements Query { @@ -504,6 +849,34 @@ export class QueryClientImpl implements Query { QueryAllStakingRewardResponse.decode(new Reader(data)) ); } + + TradingReward( + request: QueryGetTradingRewardRequest + ): Promise { + const data = QueryGetTradingRewardRequest.encode(request).finish(); + const promise = this.rpc.request( + "bze.v1.rewards.Query", + "TradingReward", + data + ); + return promise.then((data) => + QueryGetTradingRewardResponse.decode(new Reader(data)) + ); + } + + TradingRewardAll( + request: QueryAllTradingRewardRequest + ): Promise { + const data = QueryAllTradingRewardRequest.encode(request).finish(); + const promise = this.rpc.request( + "bze.v1.rewards.Query", + "TradingRewardAll", + data + ); + return promise.then((data) => + QueryAllTradingRewardResponse.decode(new Reader(data)) + ); + } } interface Rpc { diff --git a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/staking_reward.ts b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/staking_reward.ts index 86afd298..ffdfe627 100644 --- a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/staking_reward.ts +++ b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/staking_reward.ts @@ -6,23 +6,23 @@ export const protobufPackage = "bze.v1.rewards"; export interface StakingReward { reward_id: string; - prize_amount: number; + prize_amount: string; prize_denom: string; staking_denom: string; duration: number; payouts: number; - minStake: number; + min_stake: number; lock: number; } const baseStakingReward: object = { reward_id: "", - prize_amount: 0, + prize_amount: "", prize_denom: "", staking_denom: "", duration: 0, payouts: 0, - minStake: 0, + min_stake: 0, lock: 0, }; @@ -31,8 +31,8 @@ export const StakingReward = { if (message.reward_id !== "") { writer.uint32(10).string(message.reward_id); } - if (message.prize_amount !== 0) { - writer.uint32(16).int64(message.prize_amount); + if (message.prize_amount !== "") { + writer.uint32(18).string(message.prize_amount); } if (message.prize_denom !== "") { writer.uint32(26).string(message.prize_denom); @@ -46,8 +46,8 @@ export const StakingReward = { if (message.payouts !== 0) { writer.uint32(48).uint32(message.payouts); } - if (message.minStake !== 0) { - writer.uint32(56).uint64(message.minStake); + if (message.min_stake !== 0) { + writer.uint32(56).uint64(message.min_stake); } if (message.lock !== 0) { writer.uint32(64).uint32(message.lock); @@ -66,7 +66,7 @@ export const StakingReward = { message.reward_id = reader.string(); break; case 2: - message.prize_amount = longToNumber(reader.int64() as Long); + message.prize_amount = reader.string(); break; case 3: message.prize_denom = reader.string(); @@ -81,7 +81,7 @@ export const StakingReward = { message.payouts = reader.uint32(); break; case 7: - message.minStake = longToNumber(reader.uint64() as Long); + message.min_stake = longToNumber(reader.uint64() as Long); break; case 8: message.lock = reader.uint32(); @@ -102,9 +102,9 @@ export const StakingReward = { message.reward_id = ""; } if (object.prize_amount !== undefined && object.prize_amount !== null) { - message.prize_amount = Number(object.prize_amount); + message.prize_amount = String(object.prize_amount); } else { - message.prize_amount = 0; + message.prize_amount = ""; } if (object.prize_denom !== undefined && object.prize_denom !== null) { message.prize_denom = String(object.prize_denom); @@ -126,10 +126,10 @@ export const StakingReward = { } else { message.payouts = 0; } - if (object.minStake !== undefined && object.minStake !== null) { - message.minStake = Number(object.minStake); + if (object.min_stake !== undefined && object.min_stake !== null) { + message.min_stake = Number(object.min_stake); } else { - message.minStake = 0; + message.min_stake = 0; } if (object.lock !== undefined && object.lock !== null) { message.lock = Number(object.lock); @@ -150,7 +150,7 @@ export const StakingReward = { (obj.staking_denom = message.staking_denom); message.duration !== undefined && (obj.duration = message.duration); message.payouts !== undefined && (obj.payouts = message.payouts); - message.minStake !== undefined && (obj.minStake = message.minStake); + message.min_stake !== undefined && (obj.min_stake = message.min_stake); message.lock !== undefined && (obj.lock = message.lock); return obj; }, @@ -165,7 +165,7 @@ export const StakingReward = { if (object.prize_amount !== undefined && object.prize_amount !== null) { message.prize_amount = object.prize_amount; } else { - message.prize_amount = 0; + message.prize_amount = ""; } if (object.prize_denom !== undefined && object.prize_denom !== null) { message.prize_denom = object.prize_denom; @@ -187,10 +187,10 @@ export const StakingReward = { } else { message.payouts = 0; } - if (object.minStake !== undefined && object.minStake !== null) { - message.minStake = object.minStake; + if (object.min_stake !== undefined && object.min_stake !== null) { + message.min_stake = object.min_stake; } else { - message.minStake = 0; + message.min_stake = 0; } if (object.lock !== undefined && object.lock !== null) { message.lock = object.lock; diff --git a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/trading_reward.ts b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/trading_reward.ts new file mode 100644 index 00000000..48b20ae9 --- /dev/null +++ b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/trading_reward.ts @@ -0,0 +1,173 @@ +/* eslint-disable */ +import { Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "bze.v1.rewards"; + +export interface TradingReward { + reward_id: string; + prize_amount: string; + prize_denom: string; + duration: number; + market_id: string; + slots: number; +} + +const baseTradingReward: object = { + reward_id: "", + prize_amount: "", + prize_denom: "", + duration: 0, + market_id: "", + slots: 0, +}; + +export const TradingReward = { + encode(message: TradingReward, writer: Writer = Writer.create()): Writer { + if (message.reward_id !== "") { + writer.uint32(10).string(message.reward_id); + } + if (message.prize_amount !== "") { + writer.uint32(18).string(message.prize_amount); + } + if (message.prize_denom !== "") { + writer.uint32(26).string(message.prize_denom); + } + if (message.duration !== 0) { + writer.uint32(32).uint32(message.duration); + } + if (message.market_id !== "") { + writer.uint32(42).string(message.market_id); + } + if (message.slots !== 0) { + writer.uint32(48).uint32(message.slots); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): TradingReward { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseTradingReward } as TradingReward; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.reward_id = reader.string(); + break; + case 2: + message.prize_amount = reader.string(); + break; + case 3: + message.prize_denom = reader.string(); + break; + case 4: + message.duration = reader.uint32(); + break; + case 5: + message.market_id = reader.string(); + break; + case 6: + message.slots = reader.uint32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): TradingReward { + const message = { ...baseTradingReward } as TradingReward; + if (object.reward_id !== undefined && object.reward_id !== null) { + message.reward_id = String(object.reward_id); + } else { + message.reward_id = ""; + } + if (object.prize_amount !== undefined && object.prize_amount !== null) { + message.prize_amount = String(object.prize_amount); + } else { + message.prize_amount = ""; + } + if (object.prize_denom !== undefined && object.prize_denom !== null) { + message.prize_denom = String(object.prize_denom); + } else { + message.prize_denom = ""; + } + if (object.duration !== undefined && object.duration !== null) { + message.duration = Number(object.duration); + } else { + message.duration = 0; + } + if (object.market_id !== undefined && object.market_id !== null) { + message.market_id = String(object.market_id); + } else { + message.market_id = ""; + } + if (object.slots !== undefined && object.slots !== null) { + message.slots = Number(object.slots); + } else { + message.slots = 0; + } + return message; + }, + + toJSON(message: TradingReward): unknown { + const obj: any = {}; + message.reward_id !== undefined && (obj.reward_id = message.reward_id); + message.prize_amount !== undefined && + (obj.prize_amount = message.prize_amount); + message.prize_denom !== undefined && + (obj.prize_denom = message.prize_denom); + message.duration !== undefined && (obj.duration = message.duration); + message.market_id !== undefined && (obj.market_id = message.market_id); + message.slots !== undefined && (obj.slots = message.slots); + return obj; + }, + + fromPartial(object: DeepPartial): TradingReward { + const message = { ...baseTradingReward } as TradingReward; + if (object.reward_id !== undefined && object.reward_id !== null) { + message.reward_id = object.reward_id; + } else { + message.reward_id = ""; + } + if (object.prize_amount !== undefined && object.prize_amount !== null) { + message.prize_amount = object.prize_amount; + } else { + message.prize_amount = ""; + } + if (object.prize_denom !== undefined && object.prize_denom !== null) { + message.prize_denom = object.prize_denom; + } else { + message.prize_denom = ""; + } + if (object.duration !== undefined && object.duration !== null) { + message.duration = object.duration; + } else { + message.duration = 0; + } + if (object.market_id !== undefined && object.market_id !== null) { + message.market_id = object.market_id; + } else { + message.market_id = ""; + } + if (object.slots !== undefined && object.slots !== null) { + message.slots = object.slots; + } else { + message.slots = 0; + } + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/tx.ts b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/tx.ts index 1d97f229..edf19ada 100644 --- a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/tx.ts +++ b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/tx.ts @@ -6,7 +6,7 @@ export const protobufPackage = "bze.v1.rewards"; export interface MsgCreateStakingReward { /** msg creator */ creator: string; - /** the amount paid as prize */ + /** the amount paid as prize for each epoch (duration) */ prize_amount: string; /** the denom paid as prize */ prize_denom: string; @@ -33,6 +33,21 @@ export interface MsgUpdateStakingReward { export interface MsgUpdateStakingRewardResponse {} +export interface MsgCreateTradingReward { + creator: string; + /** the amount paid as prize for each slot */ + prize_amount: string; + /** the denom paid as prize */ + prize_denom: string; + duration: string; + market_id: string; + slots: string; +} + +export interface MsgCreateTradingRewardResponse { + reward_id: string; +} + const baseMsgCreateStakingReward: object = { creator: "", prize_amount: "", @@ -425,15 +440,241 @@ export const MsgUpdateStakingRewardResponse = { }, }; +const baseMsgCreateTradingReward: object = { + creator: "", + prize_amount: "", + prize_denom: "", + duration: "", + market_id: "", + slots: "", +}; + +export const MsgCreateTradingReward = { + encode( + message: MsgCreateTradingReward, + writer: Writer = Writer.create() + ): Writer { + if (message.creator !== "") { + writer.uint32(10).string(message.creator); + } + if (message.prize_amount !== "") { + writer.uint32(18).string(message.prize_amount); + } + if (message.prize_denom !== "") { + writer.uint32(26).string(message.prize_denom); + } + if (message.duration !== "") { + writer.uint32(34).string(message.duration); + } + if (message.market_id !== "") { + writer.uint32(42).string(message.market_id); + } + if (message.slots !== "") { + writer.uint32(50).string(message.slots); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MsgCreateTradingReward { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgCreateTradingReward } as MsgCreateTradingReward; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.creator = reader.string(); + break; + case 2: + message.prize_amount = reader.string(); + break; + case 3: + message.prize_denom = reader.string(); + break; + case 4: + message.duration = reader.string(); + break; + case 5: + message.market_id = reader.string(); + break; + case 6: + message.slots = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgCreateTradingReward { + const message = { ...baseMsgCreateTradingReward } as MsgCreateTradingReward; + if (object.creator !== undefined && object.creator !== null) { + message.creator = String(object.creator); + } else { + message.creator = ""; + } + if (object.prize_amount !== undefined && object.prize_amount !== null) { + message.prize_amount = String(object.prize_amount); + } else { + message.prize_amount = ""; + } + if (object.prize_denom !== undefined && object.prize_denom !== null) { + message.prize_denom = String(object.prize_denom); + } else { + message.prize_denom = ""; + } + if (object.duration !== undefined && object.duration !== null) { + message.duration = String(object.duration); + } else { + message.duration = ""; + } + if (object.market_id !== undefined && object.market_id !== null) { + message.market_id = String(object.market_id); + } else { + message.market_id = ""; + } + if (object.slots !== undefined && object.slots !== null) { + message.slots = String(object.slots); + } else { + message.slots = ""; + } + return message; + }, + + toJSON(message: MsgCreateTradingReward): unknown { + const obj: any = {}; + message.creator !== undefined && (obj.creator = message.creator); + message.prize_amount !== undefined && + (obj.prize_amount = message.prize_amount); + message.prize_denom !== undefined && + (obj.prize_denom = message.prize_denom); + message.duration !== undefined && (obj.duration = message.duration); + message.market_id !== undefined && (obj.market_id = message.market_id); + message.slots !== undefined && (obj.slots = message.slots); + return obj; + }, + + fromPartial( + object: DeepPartial + ): MsgCreateTradingReward { + const message = { ...baseMsgCreateTradingReward } as MsgCreateTradingReward; + if (object.creator !== undefined && object.creator !== null) { + message.creator = object.creator; + } else { + message.creator = ""; + } + if (object.prize_amount !== undefined && object.prize_amount !== null) { + message.prize_amount = object.prize_amount; + } else { + message.prize_amount = ""; + } + if (object.prize_denom !== undefined && object.prize_denom !== null) { + message.prize_denom = object.prize_denom; + } else { + message.prize_denom = ""; + } + if (object.duration !== undefined && object.duration !== null) { + message.duration = object.duration; + } else { + message.duration = ""; + } + if (object.market_id !== undefined && object.market_id !== null) { + message.market_id = object.market_id; + } else { + message.market_id = ""; + } + if (object.slots !== undefined && object.slots !== null) { + message.slots = object.slots; + } else { + message.slots = ""; + } + return message; + }, +}; + +const baseMsgCreateTradingRewardResponse: object = { reward_id: "" }; + +export const MsgCreateTradingRewardResponse = { + encode( + message: MsgCreateTradingRewardResponse, + writer: Writer = Writer.create() + ): Writer { + if (message.reward_id !== "") { + writer.uint32(10).string(message.reward_id); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): MsgCreateTradingRewardResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseMsgCreateTradingRewardResponse, + } as MsgCreateTradingRewardResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.reward_id = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgCreateTradingRewardResponse { + const message = { + ...baseMsgCreateTradingRewardResponse, + } as MsgCreateTradingRewardResponse; + if (object.reward_id !== undefined && object.reward_id !== null) { + message.reward_id = String(object.reward_id); + } else { + message.reward_id = ""; + } + return message; + }, + + toJSON(message: MsgCreateTradingRewardResponse): unknown { + const obj: any = {}; + message.reward_id !== undefined && (obj.reward_id = message.reward_id); + return obj; + }, + + fromPartial( + object: DeepPartial + ): MsgCreateTradingRewardResponse { + const message = { + ...baseMsgCreateTradingRewardResponse, + } as MsgCreateTradingRewardResponse; + if (object.reward_id !== undefined && object.reward_id !== null) { + message.reward_id = object.reward_id; + } else { + message.reward_id = ""; + } + return message; + }, +}; + /** Msg defines the Msg service. */ export interface Msg { CreateStakingReward( request: MsgCreateStakingReward ): Promise; - /** this line is used by starport scaffolding # proto/tx/rpc */ UpdateStakingReward( request: MsgUpdateStakingReward ): Promise; + /** this line is used by starport scaffolding # proto/tx/rpc */ + CreateTradingReward( + request: MsgCreateTradingReward + ): Promise; } export class MsgClientImpl implements Msg { @@ -468,6 +709,20 @@ export class MsgClientImpl implements Msg { MsgUpdateStakingRewardResponse.decode(new Reader(data)) ); } + + CreateTradingReward( + request: MsgCreateTradingReward + ): Promise { + const data = MsgCreateTradingReward.encode(request).finish(); + const promise = this.rpc.request( + "bze.v1.rewards.Msg", + "CreateTradingReward", + data + ); + return promise.then((data) => + MsgCreateTradingRewardResponse.decode(new Reader(data)) + ); + } } interface Rpc { diff --git a/x/rewards/client/cli/query.go b/x/rewards/client/cli/query.go index 068f6e0c..1cf312c7 100644 --- a/x/rewards/client/cli/query.go +++ b/x/rewards/client/cli/query.go @@ -27,7 +27,9 @@ func GetQueryCmd(queryRoute string) *cobra.Command { cmd.AddCommand(CmdQueryParams()) cmd.AddCommand(CmdListStakingReward()) cmd.AddCommand(CmdShowStakingReward()) -// this line is used by starport scaffolding # 1 + cmd.AddCommand(CmdListTradingReward()) + cmd.AddCommand(CmdShowTradingReward()) + // this line is used by starport scaffolding # 1 return cmd } diff --git a/x/rewards/client/cli/query_trading_reward.go b/x/rewards/client/cli/query_trading_reward.go new file mode 100644 index 00000000..0915587f --- /dev/null +++ b/x/rewards/client/cli/query_trading_reward.go @@ -0,0 +1,73 @@ +package cli + +import ( + "context" + + "github.com/bze-alphateam/bze/x/rewards/types" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/spf13/cobra" +) + +func CmdListTradingReward() *cobra.Command { + cmd := &cobra.Command{ + Use: "list-trading-reward", + Short: "list all TradingReward", + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx := client.GetClientContextFromCmd(cmd) + + pageReq, err := client.ReadPageRequest(cmd.Flags()) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + + params := &types.QueryAllTradingRewardRequest{ + Pagination: pageReq, + } + + res, err := queryClient.TradingRewardAll(context.Background(), params) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddPaginationFlagsToCmd(cmd, cmd.Use) + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +func CmdShowTradingReward() *cobra.Command { + cmd := &cobra.Command{ + Use: "show-trading-reward [reward-id]", + Short: "shows a TradingReward", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) (err error) { + clientCtx := client.GetClientContextFromCmd(cmd) + + queryClient := types.NewQueryClient(clientCtx) + + argRewardId := args[0] + + params := &types.QueryGetTradingRewardRequest{ + RewardId: argRewardId, + } + + res, err := queryClient.TradingReward(context.Background(), params) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/rewards/client/cli/query_trading_reward_test.go b/x/rewards/client/cli/query_trading_reward_test.go new file mode 100644 index 00000000..9596b03e --- /dev/null +++ b/x/rewards/client/cli/query_trading_reward_test.go @@ -0,0 +1,163 @@ +package cli_test + +import ( + "fmt" + "strconv" + "testing" + + "github.com/cosmos/cosmos-sdk/client/flags" + clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" + "github.com/stretchr/testify/require" + tmcli "github.com/tendermint/tendermint/libs/cli" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + + "github.com/bze-alphateam/bze/testutil/network" + "github.com/bze-alphateam/bze/testutil/nullify" + "github.com/bze-alphateam/bze/x/rewards/client/cli" + "github.com/bze-alphateam/bze/x/rewards/types" +) + +// Prevent strconv unused error +var _ = strconv.IntSize + +func networkWithTradingRewardObjects(t *testing.T, n int) (*network.Network, []types.TradingReward) { + t.Helper() + cfg := network.DefaultConfig() + state := types.GenesisState{} + require.NoError(t, cfg.Codec.UnmarshalJSON(cfg.GenesisState[types.ModuleName], &state)) + + for i := 0; i < n; i++ { + tradingReward := types.TradingReward{ + RewardId: strconv.Itoa(i), + + } + nullify.Fill(&tradingReward) + state.TradingRewardList = append(state.TradingRewardList, tradingReward) + } + buf, err := cfg.Codec.MarshalJSON(&state) + require.NoError(t, err) + cfg.GenesisState[types.ModuleName] = buf + return network.New(t, cfg), state.TradingRewardList +} + +func TestShowTradingReward(t *testing.T) { + net, objs := networkWithTradingRewardObjects(t, 2) + + ctx := net.Validators[0].ClientCtx + common := []string{ + fmt.Sprintf("--%s=json", tmcli.OutputFlag), + } + for _, tc := range []struct { + desc string + idRewardId string + + args []string + err error + obj types.TradingReward + }{ + { + desc: "found", + idRewardId: objs[0].RewardId, + + args: common, + obj: objs[0], + }, + { + desc: "not found", + idRewardId: strconv.Itoa(100000), + + args: common, + err: status.Error(codes.NotFound, "not found"), + }, + } { + t.Run(tc.desc, func(t *testing.T) { + args := []string{ + tc.idRewardId, + + } + args = append(args, tc.args...) + out, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdShowTradingReward(), args) + if tc.err != nil { + stat, ok := status.FromError(tc.err) + require.True(t, ok) + require.ErrorIs(t, stat.Err(), tc.err) + } else { + require.NoError(t, err) + var resp types.QueryGetTradingRewardResponse + require.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp)) + require.NotNil(t, resp.TradingReward) + require.Equal(t, + nullify.Fill(&tc.obj), + nullify.Fill(&resp.TradingReward), + ) + } + }) + } +} + +func TestListTradingReward(t *testing.T) { + net, objs := networkWithTradingRewardObjects(t, 5) + + ctx := net.Validators[0].ClientCtx + request := func(next []byte, offset, limit uint64, total bool) []string { + args := []string{ + fmt.Sprintf("--%s=json", tmcli.OutputFlag), + } + if next == nil { + args = append(args, fmt.Sprintf("--%s=%d", flags.FlagOffset, offset)) + } else { + args = append(args, fmt.Sprintf("--%s=%s", flags.FlagPageKey, next)) + } + args = append(args, fmt.Sprintf("--%s=%d", flags.FlagLimit, limit)) + if total { + args = append(args, fmt.Sprintf("--%s", flags.FlagCountTotal)) + } + return args + } + t.Run("ByOffset", func(t *testing.T) { + step := 2 + for i := 0; i < len(objs); i += step { + args := request(nil, uint64(i), uint64(step), false) + out, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdListTradingReward(), args) + require.NoError(t, err) + var resp types.QueryAllTradingRewardResponse + require.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp)) + require.LessOrEqual(t, len(resp.TradingReward), step) + require.Subset(t, + nullify.Fill(objs), + nullify.Fill(resp.TradingReward), + ) + } + }) + t.Run("ByKey", func(t *testing.T) { + step := 2 + var next []byte + for i := 0; i < len(objs); i += step { + args := request(next, 0, uint64(step), false) + out, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdListTradingReward(), args) + require.NoError(t, err) + var resp types.QueryAllTradingRewardResponse + require.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp)) + require.LessOrEqual(t, len(resp.TradingReward), step) + require.Subset(t, + nullify.Fill(objs), + nullify.Fill(resp.TradingReward), + ) + next = resp.Pagination.NextKey + } + }) + t.Run("Total", func(t *testing.T) { + args := request(nil, 0, uint64(len(objs)), true) + out, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdListTradingReward(), args) + require.NoError(t, err) + var resp types.QueryAllTradingRewardResponse + require.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp)) + require.NoError(t, err) + require.Equal(t, len(objs), int(resp.Pagination.Total)) + require.ElementsMatch(t, + nullify.Fill(objs), + nullify.Fill(resp.TradingReward), + ) + }) +} diff --git a/x/rewards/client/cli/tx.go b/x/rewards/client/cli/tx.go index 9976f1d0..6ba19c62 100644 --- a/x/rewards/client/cli/tx.go +++ b/x/rewards/client/cli/tx.go @@ -32,6 +32,7 @@ func GetTxCmd() *cobra.Command { cmd.AddCommand(CmdCreateStakingReward()) cmd.AddCommand(CmdUpdateStakingReward()) + cmd.AddCommand(CmdCreateTradingReward()) // this line is used by starport scaffolding # 1 return cmd diff --git a/x/rewards/client/cli/tx_trading_reward.go b/x/rewards/client/cli/tx_trading_reward.go new file mode 100644 index 00000000..93ea3817 --- /dev/null +++ b/x/rewards/client/cli/tx_trading_reward.go @@ -0,0 +1,47 @@ +package cli + +import ( + "github.com/bze-alphateam/bze/x/rewards/types" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/client/tx" + "github.com/spf13/cobra" +) + +func CmdCreateTradingReward() *cobra.Command { + cmd := &cobra.Command{ + Use: "create-trading-reward [prize-amount] [prize-denom] [duration] [market-id] [slots]", + Short: "Create a new TradingReward", + Args: cobra.ExactArgs(5), + RunE: func(cmd *cobra.Command, args []string) (err error) { + // Get value arguments + argPrizeAmount := args[0] + argPrizeDenom := args[1] + argDuration := args[2] + argMarketId := args[3] + argSlots := args[4] + + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + msg := types.NewMsgCreateTradingReward( + clientCtx.GetFromAddress().String(), + argPrizeAmount, + argPrizeDenom, + argDuration, + argMarketId, + argSlots, + ) + if err := msg.ValidateBasic(); err != nil { + return err + } + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} diff --git a/x/rewards/client/cli/tx_trading_reward_test.go b/x/rewards/client/cli/tx_trading_reward_test.go new file mode 100644 index 00000000..8a693b0f --- /dev/null +++ b/x/rewards/client/cli/tx_trading_reward_test.go @@ -0,0 +1,191 @@ +package cli_test + +import ( + "fmt" + "strconv" + "testing" + + "github.com/cosmos/cosmos-sdk/client/flags" + clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/stretchr/testify/require" + + "github.com/bze-alphateam/bze/testutil/network" + "github.com/bze-alphateam/bze/x/rewards/client/cli" +) + +// Prevent strconv unused error +var _ = strconv.IntSize + +func TestCreateTradingReward(t *testing.T) { + net := network.New(t) + val := net.Validators[0] + ctx := val.ClientCtx + + fields := []string{ "111", "xyz", "111", "xyz", "xyz", } + for _, tc := range []struct { + desc string + idRewardId string + + args []string + err error + code uint32 + }{ + { + idRewardId: strconv.Itoa(0), + + desc: "valid", + args: []string{ + fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(net.Config.BondDenom, sdk.NewInt(10))).String()), + }, + }, + } { + t.Run(tc.desc, func(t *testing.T) { + args := []string{ + tc.idRewardId, + + } + args = append(args, fields...) + args = append(args, tc.args...) + out, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdCreateTradingReward(), args) + if tc.err != nil { + require.ErrorIs(t, err, tc.err) + } else { + require.NoError(t, err) + var resp sdk.TxResponse + require.NoError(t, ctx.Codec.UnmarshalJSON(out.Bytes(), &resp)) + require.Equal(t, tc.code, resp.Code) + } + }) + } +} + +func TestUpdateTradingReward(t *testing.T) { + net := network.New(t) + val := net.Validators[0] + ctx := val.ClientCtx + + fields := []string{ "111", "xyz", "111", "xyz", "xyz", } + common := []string{ + fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(net.Config.BondDenom, sdk.NewInt(10))).String()), + } + args := []string{ + "0", + + } + args = append(args, fields...) + args = append(args, common...) + _, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdCreateTradingReward(), args) + require.NoError(t, err) + + for _, tc := range []struct { + desc string + idRewardId string + + args []string + code uint32 + err error + }{ + { + desc: "valid", + idRewardId: strconv.Itoa(0), + + args: common, + }, + { + desc: "key not found", + idRewardId: strconv.Itoa(100000), + + args: common, + code: sdkerrors.ErrKeyNotFound.ABCICode(), + }, + } { + t.Run(tc.desc, func(t *testing.T) { + args := []string{ + tc.idRewardId, + + } + args = append(args, fields...) + args = append(args, tc.args...) + out, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdUpdateTradingReward(), args) + if tc.err != nil { + require.ErrorIs(t, err, tc.err) + } else { + require.NoError(t, err) + var resp sdk.TxResponse + require.NoError(t, ctx.Codec.UnmarshalJSON(out.Bytes(), &resp)) + require.Equal(t, tc.code, resp.Code) + } + }) + } +} + +func TestDeleteTradingReward(t *testing.T) { + net := network.New(t) + + val := net.Validators[0] + ctx := val.ClientCtx + + fields := []string{ "111", "xyz", "111", "xyz", "xyz", } + common := []string{ + fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), + fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), + fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), + fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(net.Config.BondDenom, sdk.NewInt(10))).String()), + } + args := []string{ + "0", + + } + args = append(args, fields...) + args = append(args, common...) + _, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdCreateTradingReward(), args) + require.NoError(t, err) + + for _, tc := range []struct { + desc string + idRewardId string + + args []string + code uint32 + err error + }{ + { + desc: "valid", + idRewardId: strconv.Itoa(0), + + args: common, + }, + { + desc: "key not found", + idRewardId: strconv.Itoa(100000), + + args: common, + code: sdkerrors.ErrKeyNotFound.ABCICode(), + }, + } { + t.Run(tc.desc, func(t *testing.T) { + args := []string{ + tc.idRewardId, + + } + args = append(args, tc.args...) + out, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdDeleteTradingReward(), args) + if tc.err != nil { + require.ErrorIs(t, err, tc.err) + } else { + require.NoError(t, err) + var resp sdk.TxResponse + require.NoError(t, ctx.Codec.UnmarshalJSON(out.Bytes(), &resp)) + require.Equal(t, tc.code, resp.Code) + } + }) + } +} diff --git a/x/rewards/genesis.go b/x/rewards/genesis.go index df70b7e4..bb141c5a 100644 --- a/x/rewards/genesis.go +++ b/x/rewards/genesis.go @@ -13,6 +13,11 @@ func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) for _, elem := range genState.StakingRewardList { k.SetStakingReward(ctx, elem) } + // Set all the tradingReward + for _, elem := range genState.TradingRewardList { + k.SetTradingReward(ctx, elem) + } + // this line is used by starport scaffolding # genesis/module/init k.SetParams(ctx, genState.Params) k.SetTradingRewardsCounter(ctx, genState.TradingRewardsCounter) @@ -27,6 +32,7 @@ func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState { genesis.StakingRewardList = k.GetAllStakingReward(ctx) genesis.StakingRewardsCounter = k.GetStakingRewardsCounter(ctx) genesis.TradingRewardsCounter = k.GetTradingRewardsCounter(ctx) + genesis.TradingRewardList = k.GetAllTradingReward(ctx) // this line is used by starport scaffolding # genesis/module/export return genesis diff --git a/x/rewards/genesis_test.go b/x/rewards/genesis_test.go index 4abbb02e..3ef75fa3 100644 --- a/x/rewards/genesis_test.go +++ b/x/rewards/genesis_test.go @@ -20,6 +20,14 @@ func TestGenesis(t *testing.T) { }, { RewardId: "1", +}, + }, + TradingRewardList: []types.TradingReward{ + { + RewardId: "0", +}, + { + RewardId: "1", }, }, // this line is used by starport scaffolding # genesis/test/state @@ -34,5 +42,6 @@ func TestGenesis(t *testing.T) { nullify.Fill(got) require.ElementsMatch(t, genesisState.StakingRewardList, got.StakingRewardList) +require.ElementsMatch(t, genesisState.TradingRewardList, got.TradingRewardList) // this line is used by starport scaffolding # genesis/test/assert } diff --git a/x/rewards/handler.go b/x/rewards/handler.go index 1f9b937a..aea4335b 100644 --- a/x/rewards/handler.go +++ b/x/rewards/handler.go @@ -23,7 +23,10 @@ func NewHandler(k keeper.Keeper) sdk.Handler { case *types.MsgUpdateStakingReward: res, err := msgServer.UpdateStakingReward(sdk.WrapSDKContext(ctx), msg) return sdk.WrapServiceResult(ctx, res, err) - // this line is used by starport scaffolding # 1 + case *types.MsgCreateTradingReward: + res, err := msgServer.CreateTradingReward(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) + // this line is used by starport scaffolding # 1 default: errMsg := fmt.Sprintf("unrecognized %s message type: %T", types.ModuleName, msg) return nil, sdkerrors.Wrap(sdkerrors.ErrUnknownRequest, errMsg) diff --git a/x/rewards/keeper/grpc_query_trading_reward.go b/x/rewards/keeper/grpc_query_trading_reward.go new file mode 100644 index 00000000..4abdd62c --- /dev/null +++ b/x/rewards/keeper/grpc_query_trading_reward.go @@ -0,0 +1,54 @@ +package keeper + +import ( + "context" + + "github.com/bze-alphateam/bze/x/rewards/types" + "github.com/cosmos/cosmos-sdk/store/prefix" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/query" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +func (k Keeper) TradingRewardAll(c context.Context, req *types.QueryAllTradingRewardRequest) (*types.QueryAllTradingRewardResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + + var tradingRewards []types.TradingReward + ctx := sdk.UnwrapSDKContext(c) + + store := ctx.KVStore(k.storeKey) + tradingRewardStore := prefix.NewStore(store, types.KeyPrefix(types.TradingRewardKeyPrefix)) + + pageRes, err := query.Paginate(tradingRewardStore, req.Pagination, func(key []byte, value []byte) error { + var tradingReward types.TradingReward + if err := k.cdc.Unmarshal(value, &tradingReward); err != nil { + return err + } + + tradingRewards = append(tradingRewards, tradingReward) + return nil + }) + + if err != nil { + return nil, status.Error(codes.Internal, err.Error()) + } + + return &types.QueryAllTradingRewardResponse{TradingReward: tradingRewards, Pagination: pageRes}, nil +} + +func (k Keeper) TradingReward(c context.Context, req *types.QueryGetTradingRewardRequest) (*types.QueryGetTradingRewardResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + ctx := sdk.UnwrapSDKContext(c) + + val, found := k.GetTradingReward(ctx, req.RewardId) + if !found { + return nil, status.Error(codes.NotFound, "not found") + } + + return &types.QueryGetTradingRewardResponse{TradingReward: val}, nil +} diff --git a/x/rewards/keeper/grpc_query_trading_reward_test.go b/x/rewards/keeper/grpc_query_trading_reward_test.go new file mode 100644 index 00000000..277f8098 --- /dev/null +++ b/x/rewards/keeper/grpc_query_trading_reward_test.go @@ -0,0 +1,129 @@ +package keeper_test + +import ( + "strconv" + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/query" + "github.com/stretchr/testify/require" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + + "github.com/bze-alphateam/bze/x/rewards/types" + "github.com/bze-alphateam/bze/testutil/nullify" + keepertest "github.com/bze-alphateam/bze/testutil/keeper" +) + +// Prevent strconv unused error +var _ = strconv.IntSize + +func TestTradingRewardQuerySingle(t *testing.T) { + keeper, ctx := keepertest.RewardsKeeper(t) + wctx := sdk.WrapSDKContext(ctx) + msgs := createNTradingReward(keeper, ctx, 2) + for _, tc := range []struct { + desc string + request *types.QueryGetTradingRewardRequest + response *types.QueryGetTradingRewardResponse + err error + }{ + { + desc: "First", + request: &types.QueryGetTradingRewardRequest{ + RewardId: msgs[0].RewardId, + + }, + response: &types.QueryGetTradingRewardResponse{TradingReward: msgs[0]}, + }, + { + desc: "Second", + request: &types.QueryGetTradingRewardRequest{ + RewardId: msgs[1].RewardId, + + }, + response: &types.QueryGetTradingRewardResponse{TradingReward: msgs[1]}, + }, + { + desc: "KeyNotFound", + request: &types.QueryGetTradingRewardRequest{ + RewardId:strconv.Itoa(100000), + + }, + err: status.Error(codes.NotFound, "not found"), + }, + { + desc: "InvalidRequest", + err: status.Error(codes.InvalidArgument, "invalid request"), + }, + } { + t.Run(tc.desc, func(t *testing.T) { + response, err := keeper.TradingReward(wctx, tc.request) + if tc.err != nil { + require.ErrorIs(t, err, tc.err) + } else { + require.NoError(t, err) + require.Equal(t, + nullify.Fill(tc.response), + nullify.Fill(response), + ) + } + }) + } +} + +func TestTradingRewardQueryPaginated(t *testing.T) { + keeper, ctx := keepertest.RewardsKeeper(t) + wctx := sdk.WrapSDKContext(ctx) + msgs := createNTradingReward(keeper, ctx, 5) + + request := func(next []byte, offset, limit uint64, total bool) *types.QueryAllTradingRewardRequest { + return &types.QueryAllTradingRewardRequest{ + Pagination: &query.PageRequest{ + Key: next, + Offset: offset, + Limit: limit, + CountTotal: total, + }, + } + } + t.Run("ByOffset", func(t *testing.T) { + step := 2 + for i := 0; i < len(msgs); i += step { + resp, err := keeper.TradingRewardAll(wctx, request(nil, uint64(i), uint64(step), false)) + require.NoError(t, err) + require.LessOrEqual(t, len(resp.TradingReward), step) + require.Subset(t, + nullify.Fill(msgs), + nullify.Fill(resp.TradingReward), + ) + } + }) + t.Run("ByKey", func(t *testing.T) { + step := 2 + var next []byte + for i := 0; i < len(msgs); i += step { + resp, err := keeper.TradingRewardAll(wctx, request(next, 0, uint64(step), false)) + require.NoError(t, err) + require.LessOrEqual(t, len(resp.TradingReward), step) + require.Subset(t, + nullify.Fill(msgs), + nullify.Fill(resp.TradingReward), + ) + next = resp.Pagination.NextKey + } + }) + t.Run("Total", func(t *testing.T) { + resp, err := keeper.TradingRewardAll(wctx, request(nil, 0, 0, true)) + require.NoError(t, err) + require.Equal(t, len(msgs), int(resp.Pagination.Total)) + require.ElementsMatch(t, + nullify.Fill(msgs), + nullify.Fill(resp.TradingReward), + ) + }) + t.Run("InvalidRequest", func(t *testing.T) { + _, err := keeper.TradingRewardAll(wctx, nil) + require.ErrorIs(t, err, status.Error(codes.InvalidArgument, "invalid request")) + }) +} diff --git a/x/rewards/keeper/keeper.go b/x/rewards/keeper/keeper.go index 3c756721..58b2912a 100644 --- a/x/rewards/keeper/keeper.go +++ b/x/rewards/keeper/keeper.go @@ -18,8 +18,9 @@ type ( memKey sdk.StoreKey paramstore paramtypes.Subspace - bankKeeper types.BankKeeper - distrKeeper types.DistrKeeper + bankKeeper types.BankKeeper + distrKeeper types.DistrKeeper + tradingKeeper types.TradingKeeper } ) @@ -29,7 +30,9 @@ func NewKeeper( memKey sdk.StoreKey, ps paramtypes.Subspace, - bankKeeper types.BankKeeper, distrKeeper types.DistrKeeper, + bankKeeper types.BankKeeper, + distrKeeper types.DistrKeeper, + tradingKeeper types.TradingKeeper, ) *Keeper { // set KeyTable if it has not already been set if !ps.HasKeyTable() { @@ -38,11 +41,13 @@ func NewKeeper( return &Keeper{ - cdc: cdc, - storeKey: storeKey, - memKey: memKey, - paramstore: ps, - bankKeeper: bankKeeper, distrKeeper: distrKeeper, + cdc: cdc, + storeKey: storeKey, + memKey: memKey, + paramstore: ps, + bankKeeper: bankKeeper, + distrKeeper: distrKeeper, + tradingKeeper: tradingKeeper, } } diff --git a/x/rewards/keeper/msg_server_staking_reward.go b/x/rewards/keeper/msg_server_staking_reward.go index a7734059..8a66e054 100644 --- a/x/rewards/keeper/msg_server_staking_reward.go +++ b/x/rewards/keeper/msg_server_staking_reward.go @@ -14,6 +14,11 @@ func (k msgServer) CreateStakingReward(goCtx context.Context, msg *types.MsgCrea return nil, sdkerrors.ErrInvalidRequest } + acc, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + return nil, err + } + stakingReward, err := msg.ToStakingReward() if err != nil { return nil, err @@ -29,9 +34,18 @@ func (k msgServer) CreateStakingReward(goCtx context.Context, msg *types.MsgCrea return nil, types.ErrInvalidPrizeDenom } - //capture the total value of prizes - //the prize amount needs to be multiplied by duration - err = k.captureStakingRewardCoins(ctx, msg.Creator, stakingReward.PrizeDenom, stakingReward.PrizeAmount, int64(stakingReward.Duration)) + feeParam := k.GetParams(ctx).CreateStakingRewardFee + toCapture, err := k.getAmountToCapture(feeParam, stakingReward.PrizeDenom, stakingReward.PrizeAmount, int64(stakingReward.Duration)) + if err != nil { + return nil, sdkerrors.Wrapf(err, "could not calculate amount needed to create the reward") + } + + err = k.checkUserBalances(ctx, toCapture, acc) + if err != nil { + return nil, err + } + + err = k.bankKeeper.SendCoinsFromAccountToModule(ctx, acc, types.ModuleName, toCapture) if err != nil { return nil, err } @@ -52,9 +66,9 @@ func (k msgServer) UpdateStakingReward(goCtx context.Context, msg *types.MsgUpda return nil, sdkerrors.ErrInvalidRequest } - stakingReward, isFound := k.GetStakingReward(ctx, msg.RewardId) - if !isFound { - return nil, sdkerrors.Wrap(sdkerrors.ErrKeyNotFound, "staking reward not found") + acc, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + return nil, err } durationInt, err := strconv.ParseInt(msg.Duration, 10, 32) @@ -66,34 +80,23 @@ func (k msgServer) UpdateStakingReward(goCtx context.Context, msg *types.MsgUpda return nil, types.ErrInvalidDuration } - err = k.captureStakingRewardCoins(ctx, msg.Creator, stakingReward.PrizeDenom, stakingReward.PrizeAmount, durationInt) - if err != nil { - return nil, err + stakingReward, isFound := k.GetStakingReward(ctx, msg.RewardId) + if !isFound { + return nil, sdkerrors.Wrap(sdkerrors.ErrKeyNotFound, "staking reward not found") } - stakingReward.Duration += uint32(durationInt) - k.SetStakingReward(ctx, stakingReward) - - return &types.MsgUpdateStakingRewardResponse{}, nil -} - -func (k msgServer) captureStakingRewardCoins(ctx sdk.Context, creator, denom string, amount, duration int64) error { - acc, err := sdk.AccAddressFromBech32(creator) + toCapture, err := k.getAmountToCapture("", stakingReward.PrizeDenom, stakingReward.PrizeAmount, durationInt) if err != nil { - return err - } - - toCapture := sdk.NewCoin(denom, sdk.NewInt(amount)) - toCapture.Amount.MulRaw(duration) - if !toCapture.IsPositive() { - //should never happen - return sdkerrors.Wrapf(sdkerrors.ErrInvalidRequest, "calculated amount to capture is not positive") + return nil, sdkerrors.Wrapf(err, "could not calculate amount needed to create the reward") } - err = k.bankKeeper.SendCoinsFromAccountToModule(ctx, acc, types.ModuleName, sdk.NewCoins(toCapture)) + err = k.bankKeeper.SendCoinsFromAccountToModule(ctx, acc, types.ModuleName, toCapture) if err != nil { - return err + return nil, err } - return nil + stakingReward.Duration += uint32(durationInt) + k.SetStakingReward(ctx, stakingReward) + + return &types.MsgUpdateStakingRewardResponse{}, nil } diff --git a/x/rewards/keeper/msg_server_trading_reward.go b/x/rewards/keeper/msg_server_trading_reward.go new file mode 100644 index 00000000..6fdc931b --- /dev/null +++ b/x/rewards/keeper/msg_server_trading_reward.go @@ -0,0 +1,106 @@ +package keeper + +import ( + "context" + "fmt" + "github.com/bze-alphateam/bze/x/rewards/types" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +func (k msgServer) CreateTradingReward(goCtx context.Context, msg *types.MsgCreateTradingReward) (*types.MsgCreateTradingRewardResponse, error) { + ctx := sdk.UnwrapSDKContext(goCtx) + if msg == nil { + return nil, sdkerrors.ErrInvalidRequest + } + + acc, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + return nil, err + } + + tradingReward, err := msg.ToTradingReward() + if err != nil { + return nil, err + } + + //check denom + ok := k.bankKeeper.HasSupply(ctx, tradingReward.PrizeDenom) + if !ok { + return nil, types.ErrInvalidPrizeDenom + } + + if !k.tradingKeeper.MarketExists(ctx, tradingReward.MarketId) { + return nil, types.ErrInvalidMarketId + } + + feeParam := k.GetParams(ctx).CreateTradingRewardFee + toCapture, err := k.getAmountToCapture(feeParam, tradingReward.PrizeDenom, tradingReward.PrizeAmount, int64(tradingReward.Slots)) + if err != nil { + return nil, sdkerrors.Wrapf(err, "could not calculate amount needed to create the reward") + } + + err = k.checkUserBalances(ctx, toCapture, acc) + if err != nil { + return nil, err + } + + err = k.bankKeeper.SendCoinsFromAccountToModule(ctx, acc, types.ModuleName, toCapture) + if err != nil { + return nil, err + } + + //add ID + tradingReward.RewardId = k.smallZeroFillId(k.GetTradingRewardsCounter(ctx)) + k.SetTradingReward( + ctx, + tradingReward, + ) + + return &types.MsgCreateTradingRewardResponse{}, nil +} + +func (k msgServer) checkUserBalances(ctx sdk.Context, neededCoins sdk.Coins, address sdk.AccAddress) error { + spendable := k.bankKeeper.SpendableCoins(ctx, address) + if !spendable.IsAllGTE(neededCoins) { + return fmt.Errorf("user balance is too low") + } + + return nil +} + +func (k msgServer) getAmountToCapture(feeParam, denom, amount string, prizeMultiplier int64) (sdk.Coins, error) { + amtInt, ok := sdk.NewIntFromString(amount) + if !ok { + return nil, fmt.Errorf("could not convert povided amount to int: %s", amount) + } + + toCapture := sdk.NewCoin(denom, amtInt) + toCapture.Amount = toCapture.Amount.MulRaw(prizeMultiplier) + if !toCapture.IsPositive() { + //should never happen + return nil, fmt.Errorf("calculated amount to capture is not positive") + } + + result := sdk.NewCoins(toCapture) + if feeParam == "" { + return result, nil + } + + fee, err := sdk.ParseCoinNormalized(feeParam) + if err != nil { + return nil, fmt.Errorf("could not parse fee param") + } + + if !fee.IsPositive() { + return result, nil + } + + result = result.Add(fee) + //just avoid any accidental panic + if !result.IsValid() { + return nil, fmt.Errorf("invalid amount to capture") + } + + return result, nil +} diff --git a/x/rewards/keeper/msg_server_trading_reward_test.go b/x/rewards/keeper/msg_server_trading_reward_test.go new file mode 100644 index 00000000..50c57f74 --- /dev/null +++ b/x/rewards/keeper/msg_server_trading_reward_test.go @@ -0,0 +1,154 @@ +package keeper_test + +import ( + "strconv" + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/stretchr/testify/require" + + keepertest "github.com/bze-alphateam/bze/testutil/keeper" + "github.com/bze-alphateam/bze/x/rewards/keeper" + "github.com/bze-alphateam/bze/x/rewards/types" +) + +// Prevent strconv unused error +var _ = strconv.IntSize + +func TestTradingRewardMsgServerCreate(t *testing.T) { + k, ctx := keepertest.RewardsKeeper(t) + srv := keeper.NewMsgServerImpl(*k) + wctx := sdk.WrapSDKContext(ctx) + creator := "A" + for i := 0; i < 5; i++ { + expected := &types.MsgCreateTradingReward{Creator: creator, + RewardId: strconv.Itoa(i), + + } + _, err := srv.CreateTradingReward(wctx, expected) + require.NoError(t, err) + rst, found := k.GetTradingReward(ctx, + expected.RewardId, + + ) + require.True(t, found) + require.Equal(t, expected.Creator, rst.Creator) + } +} + +func TestTradingRewardMsgServerUpdate(t *testing.T) { + creator := "A" + + for _, tc := range []struct { + desc string + request *types.MsgUpdateTradingReward + err error + }{ + { + desc: "Completed", + request: &types.MsgUpdateTradingReward{Creator: creator, + RewardId: strconv.Itoa(0), + + }, + }, + { + desc: "Unauthorized", + request: &types.MsgUpdateTradingReward{Creator: "B", + RewardId: strconv.Itoa(0), + + }, + err: sdkerrors.ErrUnauthorized, + }, + { + desc: "KeyNotFound", + request: &types.MsgUpdateTradingReward{Creator: creator, + RewardId: strconv.Itoa(100000), + + }, + err: sdkerrors.ErrKeyNotFound, + }, + } { + t.Run(tc.desc, func(t *testing.T) { + k, ctx := keepertest.RewardsKeeper(t) + srv := keeper.NewMsgServerImpl(*k) + wctx := sdk.WrapSDKContext(ctx) + expected := &types.MsgCreateTradingReward{Creator: creator, + RewardId: strconv.Itoa(0), + + } + _, err := srv.CreateTradingReward(wctx, expected) + require.NoError(t, err) + + _, err = srv.UpdateTradingReward(wctx, tc.request) + if tc.err != nil { + require.ErrorIs(t, err, tc.err) + } else { + require.NoError(t, err) + rst, found := k.GetTradingReward(ctx, + expected.RewardId, + + ) + require.True(t, found) + require.Equal(t, expected.Creator, rst.Creator) + } + }) + } +} + +func TestTradingRewardMsgServerDelete(t *testing.T) { + creator := "A" + + for _, tc := range []struct { + desc string + request *types.MsgDeleteTradingReward + err error + }{ + { + desc: "Completed", + request: &types.MsgDeleteTradingReward{Creator: creator, + RewardId: strconv.Itoa(0), + + }, + }, + { + desc: "Unauthorized", + request: &types.MsgDeleteTradingReward{Creator: "B", + RewardId: strconv.Itoa(0), + + }, + err: sdkerrors.ErrUnauthorized, + }, + { + desc: "KeyNotFound", + request: &types.MsgDeleteTradingReward{Creator: creator, + RewardId: strconv.Itoa(100000), + + }, + err: sdkerrors.ErrKeyNotFound, + }, + } { + t.Run(tc.desc, func(t *testing.T) { + k, ctx := keepertest.RewardsKeeper(t) + srv := keeper.NewMsgServerImpl(*k) + wctx := sdk.WrapSDKContext(ctx) + + _, err := srv.CreateTradingReward(wctx, &types.MsgCreateTradingReward{Creator: creator, + RewardId: strconv.Itoa(0), + + }) + require.NoError(t, err) + _, err = srv.DeleteTradingReward(wctx, tc.request) + if tc.err != nil { + require.ErrorIs(t, err, tc.err) + } else { + require.NoError(t, err) + _, found := k.GetTradingReward(ctx, + tc.request.RewardId, + + ) + require.False(t, found) + } + }) + } +} diff --git a/x/rewards/keeper/trading_reward.go b/x/rewards/keeper/trading_reward.go new file mode 100644 index 00000000..74e434e8 --- /dev/null +++ b/x/rewards/keeper/trading_reward.go @@ -0,0 +1,49 @@ +package keeper + +import ( + "github.com/bze-alphateam/bze/x/rewards/types" + "github.com/cosmos/cosmos-sdk/store/prefix" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// SetTradingReward set a specific tradingReward in the store from its index +func (k Keeper) SetTradingReward(ctx sdk.Context, tradingReward types.TradingReward) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.TradingRewardKeyPrefix)) + b := k.cdc.MustMarshal(&tradingReward) + store.Set(types.TradingRewardKey(tradingReward.RewardId), b) +} + +// GetTradingReward returns a tradingReward from its index +func (k Keeper) GetTradingReward(ctx sdk.Context, rewardId string) (val types.TradingReward, found bool) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.TradingRewardKeyPrefix)) + + b := store.Get(types.TradingRewardKey(rewardId)) + if b == nil { + return val, false + } + + k.cdc.MustUnmarshal(b, &val) + return val, true +} + +// RemoveTradingReward removes a tradingReward from the store +func (k Keeper) RemoveTradingReward(ctx sdk.Context, rewardId string) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.TradingRewardKeyPrefix)) + store.Delete(types.TradingRewardKey(rewardId)) +} + +// GetAllTradingReward returns all tradingReward +func (k Keeper) GetAllTradingReward(ctx sdk.Context) (list []types.TradingReward) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.TradingRewardKeyPrefix)) + iterator := sdk.KVStorePrefixIterator(store, []byte{}) + + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + var val types.TradingReward + k.cdc.MustUnmarshal(iterator.Value(), &val) + list = append(list, val) + } + + return +} diff --git a/x/rewards/keeper/trading_reward_test.go b/x/rewards/keeper/trading_reward_test.go new file mode 100644 index 00000000..af60e2db --- /dev/null +++ b/x/rewards/keeper/trading_reward_test.go @@ -0,0 +1,66 @@ +package keeper_test + +import ( + "strconv" + "testing" + + "github.com/bze-alphateam/bze/x/rewards/keeper" + "github.com/bze-alphateam/bze/x/rewards/types" + keepertest "github.com/bze-alphateam/bze/testutil/keeper" + "github.com/bze-alphateam/bze/testutil/nullify" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" +) + +// Prevent strconv unused error +var _ = strconv.IntSize + +func createNTradingReward(keeper *keeper.Keeper, ctx sdk.Context, n int) []types.TradingReward { + items := make([]types.TradingReward, n) + for i := range items { + items[i].RewardId = strconv.Itoa(i) + + keeper.SetTradingReward(ctx, items[i]) + } + return items +} + +func TestTradingRewardGet(t *testing.T) { + keeper, ctx := keepertest.RewardsKeeper(t) + items := createNTradingReward(keeper, ctx, 10) + for _, item := range items { + rst, found := keeper.GetTradingReward(ctx, + item.RewardId, + + ) + require.True(t, found) + require.Equal(t, + nullify.Fill(&item), + nullify.Fill(&rst), + ) + } +} +func TestTradingRewardRemove(t *testing.T) { + keeper, ctx := keepertest.RewardsKeeper(t) + items := createNTradingReward(keeper, ctx, 10) + for _, item := range items { + keeper.RemoveTradingReward(ctx, + item.RewardId, + + ) + _, found := keeper.GetTradingReward(ctx, + item.RewardId, + + ) + require.False(t, found) + } +} + +func TestTradingRewardGetAll(t *testing.T) { + keeper, ctx := keepertest.RewardsKeeper(t) + items := createNTradingReward(keeper, ctx, 10) + require.ElementsMatch(t, + nullify.Fill(items), + nullify.Fill(keeper.GetAllTradingReward(ctx)), + ) +} diff --git a/x/rewards/module_simulation.go b/x/rewards/module_simulation.go index 76cf8eae..719a4629 100644 --- a/x/rewards/module_simulation.go +++ b/x/rewards/module_simulation.go @@ -36,6 +36,10 @@ const ( // TODO: Determine the simulation weight value defaultWeightMsgDeleteStakingReward int = 100 + opWeightMsgCreateTradingReward = "op_weight_msg_trading_reward" + // TODO: Determine the simulation weight value + defaultWeightMsgCreateTradingReward int = 100 + // this line is used by starport scaffolding # simapp/module/const ) @@ -55,6 +59,14 @@ func (AppModule) GenerateGenesisState(simState *module.SimulationState) { RewardId: "1", }, }, + TradingRewardList: []types.TradingReward{ + { + RewardId: "0", + }, + { + RewardId: "1", + }, + }, // this line is used by starport scaffolding # simapp/module/genesisState } simState.GenState[types.ModuleName] = simState.Cdc.MustMarshalJSON(&rewardsGenesis) @@ -118,6 +130,17 @@ func (am AppModule) WeightedOperations(simState module.SimulationState) []simtyp rewardssimulation.SimulateMsgDeleteStakingReward(am.accountKeeper, am.bankKeeper, am.keeper), )) + var weightMsgCreateTradingReward int + simState.AppParams.GetOrGenerate(simState.Cdc, opWeightMsgCreateTradingReward, &weightMsgCreateTradingReward, nil, + func(_ *rand.Rand) { + weightMsgCreateTradingReward = defaultWeightMsgCreateTradingReward + }, + ) + operations = append(operations, simulation.NewWeightedOperation( + weightMsgCreateTradingReward, + rewardssimulation.SimulateMsgCreateTradingReward(am.accountKeeper, am.bankKeeper, am.keeper), + )) + // this line is used by starport scaffolding # simapp/module/operation return operations diff --git a/x/rewards/simulation/trading_reward.go b/x/rewards/simulation/trading_reward.go new file mode 100644 index 00000000..55b05675 --- /dev/null +++ b/x/rewards/simulation/trading_reward.go @@ -0,0 +1,48 @@ +package simulation + +import ( + "math/rand" + "strconv" + + "github.com/bze-alphateam/bze/x/rewards/keeper" + "github.com/bze-alphateam/bze/x/rewards/types" + "github.com/cosmos/cosmos-sdk/baseapp" + simappparams "github.com/cosmos/cosmos-sdk/simapp/params" + sdk "github.com/cosmos/cosmos-sdk/types" + simtypes "github.com/cosmos/cosmos-sdk/types/simulation" + "github.com/cosmos/cosmos-sdk/x/simulation" +) + +// Prevent strconv unused error +var _ = strconv.IntSize + +func SimulateMsgCreateTradingReward( + ak types.AccountKeeper, + bk types.BankKeeper, + k keeper.Keeper, +) simtypes.Operation { + return func(r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, + ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { + simAccount, _ := simtypes.RandomAcc(r, accs) + + msg := &types.MsgCreateTradingReward{ + Creator: simAccount.Address.String(), + } + + txCtx := simulation.OperationInput{ + R: r, + App: app, + TxGen: simappparams.MakeTestEncodingConfig().TxConfig, + Cdc: nil, + Msg: msg, + MsgType: msg.Type(), + Context: ctx, + SimAccount: simAccount, + ModuleName: types.ModuleName, + CoinsSpentInMsg: sdk.NewCoins(), + AccountKeeper: ak, + Bankkeeper: bk, + } + return simulation.GenAndDeliverTxWithRandFees(txCtx) + } +} diff --git a/x/rewards/types/codec.go b/x/rewards/types/codec.go index 45c14fcc..c8830319 100644 --- a/x/rewards/types/codec.go +++ b/x/rewards/types/codec.go @@ -10,6 +10,7 @@ import ( func RegisterCodec(cdc *codec.LegacyAmino) { cdc.RegisterConcrete(&MsgCreateStakingReward{}, "rewards/CreateStakingReward", nil) cdc.RegisterConcrete(&MsgUpdateStakingReward{}, "rewards/UpdateStakingReward", nil) + cdc.RegisterConcrete(&MsgCreateTradingReward{}, "rewards/CreateTradingReward", nil) // this line is used by starport scaffolding # 2 } @@ -18,6 +19,9 @@ func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { &MsgCreateStakingReward{}, &MsgUpdateStakingReward{}, ) + registry.RegisterImplementations((*sdk.Msg)(nil), + &MsgCreateTradingReward{}, + ) // this line is used by starport scaffolding # 3 msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) diff --git a/x/rewards/types/errors.go b/x/rewards/types/errors.go index e650fb25..1dcc46c6 100644 --- a/x/rewards/types/errors.go +++ b/x/rewards/types/errors.go @@ -14,4 +14,6 @@ var ( ErrInvalidMinStake = sdkerrors.Register(ModuleName, 5004, "invalid min stake") ErrInvalidDuration = sdkerrors.Register(ModuleName, 5005, "invalid duration") ErrInvalidLockingTime = sdkerrors.Register(ModuleName, 5006, "invalid staking reward lock") + ErrInvalidMarketId = sdkerrors.Register(ModuleName, 5007, "invalid market_id") + ErrInvalidSlots = sdkerrors.Register(ModuleName, 5008, "invalid slots") ) diff --git a/x/rewards/types/expected_keepers.go b/x/rewards/types/expected_keepers.go index 2b07b802..052ed4e0 100644 --- a/x/rewards/types/expected_keepers.go +++ b/x/rewards/types/expected_keepers.go @@ -24,3 +24,7 @@ type BankKeeper interface { SendCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error // Methods imported from bank should be defined here } + +type TradingKeeper interface { + MarketExists(ctx sdk.Context, marketId string) bool +} diff --git a/x/rewards/types/genesis.go b/x/rewards/types/genesis.go index 6e942730..c892e897 100644 --- a/x/rewards/types/genesis.go +++ b/x/rewards/types/genesis.go @@ -14,7 +14,8 @@ func DefaultGenesis() *GenesisState { StakingRewardList: []StakingReward{}, StakingRewardsCounter: 0, TradingRewardsCounter: 0, - // this line is used by starport scaffolding # genesis/types/default + TradingRewardList: []TradingReward{}, +// this line is used by starport scaffolding # genesis/types/default Params: DefaultParams(), } } @@ -32,7 +33,17 @@ func (gs GenesisState) Validate() error { } stakingRewardIndexMap[index] = struct{}{} } - // this line is used by starport scaffolding # genesis/types/validate + // Check for duplicated index in tradingReward +tradingRewardIndexMap := make(map[string]struct{}) + +for _, elem := range gs.TradingRewardList { + index := string(TradingRewardKey(elem.RewardId)) + if _, ok := tradingRewardIndexMap[index]; ok { + return fmt.Errorf("duplicated index for tradingReward") + } + tradingRewardIndexMap[index] = struct{}{} +} +// this line is used by starport scaffolding # genesis/types/validate return gs.Params.Validate() } diff --git a/x/rewards/types/genesis.pb.go b/x/rewards/types/genesis.pb.go index 635ce7cc..2c1122ac 100644 --- a/x/rewards/types/genesis.pb.go +++ b/x/rewards/types/genesis.pb.go @@ -29,6 +29,7 @@ type GenesisState struct { StakingRewardList []StakingReward `protobuf:"bytes,2,rep,name=staking_reward_list,json=stakingRewardList,proto3" json:"staking_reward_list"` StakingRewardsCounter uint64 `protobuf:"varint,3,opt,name=staking_rewards_counter,json=stakingRewardsCounter,proto3" json:"staking_rewards_counter,omitempty"` TradingRewardsCounter uint64 `protobuf:"varint,4,opt,name=trading_rewards_counter,json=tradingRewardsCounter,proto3" json:"trading_rewards_counter,omitempty"` + TradingRewardList []TradingReward `protobuf:"bytes,5,rep,name=tradingRewardList,proto3" json:"tradingRewardList"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -92,6 +93,13 @@ func (m *GenesisState) GetTradingRewardsCounter() uint64 { return 0 } +func (m *GenesisState) GetTradingRewardList() []TradingReward { + if m != nil { + return m.TradingRewardList + } + return nil +} + func init() { proto.RegisterType((*GenesisState)(nil), "bze.v1.rewards.GenesisState") } @@ -99,26 +107,27 @@ func init() { func init() { proto.RegisterFile("rewards/genesis.proto", fileDescriptor_04e261dd19d07881) } var fileDescriptor_04e261dd19d07881 = []byte{ - // 292 bytes of a gzipped FileDescriptorProto + // 315 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x2d, 0x4a, 0x2d, 0x4f, 0x2c, 0x4a, 0x29, 0xd6, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x4b, 0xaa, 0x4a, 0xd5, 0x2b, 0x33, 0xd4, 0x83, 0xca, 0x4a, 0x89, 0xa4, 0xe7, 0xa7, 0xe7, 0x83, 0xa5, 0xf4, 0x41, 0x2c, 0x88, 0x2a, 0x29, 0x11, 0x98, 0xe6, 0x82, 0xc4, 0xa2, 0xc4, 0x5c, 0xa8, 0x5e, 0x29, 0x19, 0x98, 0x68, 0x71, 0x49, 0x62, 0x76, 0x66, 0x5e, 0x7a, 0x3c, - 0x84, 0x0f, 0x91, 0x55, 0xea, 0x64, 0xe2, 0xe2, 0x71, 0x87, 0xd8, 0x15, 0x5c, 0x92, 0x58, 0x92, - 0x2a, 0x64, 0xc2, 0xc5, 0x06, 0xd1, 0x2e, 0xc1, 0xa8, 0xc0, 0xa8, 0xc1, 0x6d, 0x24, 0xa6, 0x87, - 0x6a, 0xb7, 0x5e, 0x00, 0x58, 0xd6, 0x89, 0xe5, 0xc4, 0x3d, 0x79, 0x86, 0x20, 0xa8, 0x5a, 0xa1, - 0x60, 0x2e, 0x61, 0x54, 0xe3, 0xe3, 0x73, 0x32, 0x8b, 0x4b, 0x24, 0x98, 0x14, 0x98, 0x35, 0xb8, - 0x8d, 0x64, 0xd1, 0x8d, 0x08, 0x86, 0x28, 0x0d, 0x02, 0x73, 0xa1, 0x26, 0x09, 0x16, 0x23, 0x0b, - 0xfa, 0x64, 0x16, 0x97, 0x08, 0x99, 0x71, 0x89, 0xa3, 0x1a, 0x5a, 0x1c, 0x9f, 0x9c, 0x5f, 0x9a, - 0x57, 0x92, 0x5a, 0x24, 0xc1, 0xac, 0xc0, 0xa8, 0xc1, 0x12, 0x24, 0x8a, 0xa2, 0xa7, 0xd8, 0x19, - 0x22, 0x09, 0xd2, 0x57, 0x52, 0x94, 0x98, 0x82, 0x4d, 0x1f, 0x0b, 0x44, 0x1f, 0x54, 0x1a, 0x55, - 0x9f, 0x93, 0xdb, 0x89, 0x47, 0x72, 0x8c, 0x17, 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, 0xc7, 0x38, - 0xe1, 0xb1, 0x1c, 0xc3, 0x85, 0xc7, 0x72, 0x0c, 0x37, 0x1e, 0xcb, 0x31, 0x44, 0xe9, 0xa4, 0x67, - 0x96, 0x64, 0x94, 0x26, 0xe9, 0x25, 0xe7, 0xe7, 0xea, 0x27, 0x55, 0xa5, 0xea, 0x26, 0xe6, 0x14, - 0x64, 0x24, 0x96, 0xa4, 0x26, 0x82, 0x79, 0xfa, 0x15, 0xfa, 0xb0, 0x20, 0x2e, 0xa9, 0x2c, 0x48, - 0x2d, 0x4e, 0x62, 0x03, 0x07, 0xad, 0x31, 0x20, 0x00, 0x00, 0xff, 0xff, 0xc3, 0xb1, 0x6e, 0x4a, - 0xcd, 0x01, 0x00, 0x00, + 0x84, 0x8f, 0x2e, 0x5b, 0x52, 0x94, 0x98, 0x82, 0x2e, 0xab, 0x74, 0x87, 0x89, 0x8b, 0xc7, 0x1d, + 0xe2, 0x92, 0xe0, 0x92, 0xc4, 0x92, 0x54, 0x21, 0x13, 0x2e, 0x36, 0x88, 0xe1, 0x12, 0x8c, 0x0a, + 0x8c, 0x1a, 0xdc, 0x46, 0x62, 0x7a, 0xa8, 0x2e, 0xd3, 0x0b, 0x00, 0xcb, 0x3a, 0xb1, 0x9c, 0xb8, + 0x27, 0xcf, 0x10, 0x04, 0x55, 0x2b, 0x14, 0xcc, 0x25, 0x8c, 0x6a, 0x79, 0x7c, 0x4e, 0x66, 0x71, + 0x89, 0x04, 0x93, 0x02, 0xb3, 0x06, 0xb7, 0x91, 0x2c, 0xba, 0x11, 0xc1, 0x10, 0xa5, 0x41, 0x60, + 0x2e, 0xd4, 0x24, 0xc1, 0x62, 0x64, 0x41, 0x9f, 0xcc, 0xe2, 0x12, 0x21, 0x33, 0x2e, 0x71, 0x54, + 0x43, 0x8b, 0xe3, 0x93, 0xf3, 0x4b, 0xf3, 0x4a, 0x52, 0x8b, 0x24, 0x98, 0x15, 0x18, 0x35, 0x58, + 0x82, 0x44, 0x51, 0xf4, 0x14, 0x3b, 0x43, 0x24, 0x41, 0xfa, 0x50, 0xfd, 0x8a, 0xd0, 0xc7, 0x02, + 0xd1, 0x07, 0x95, 0x46, 0xd3, 0x17, 0xc8, 0x25, 0x88, 0x22, 0x01, 0x72, 0x84, 0x04, 0x2b, 0x76, + 0x2f, 0x84, 0x20, 0x2b, 0x84, 0x79, 0x01, 0x43, 0xb7, 0x93, 0xdb, 0x89, 0x47, 0x72, 0x8c, 0x17, + 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, 0xc7, 0x38, 0xe1, 0xb1, 0x1c, 0xc3, 0x85, 0xc7, 0x72, 0x0c, + 0x37, 0x1e, 0xcb, 0x31, 0x44, 0xe9, 0xa4, 0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, 0x25, 0xe7, 0xe7, + 0xea, 0x27, 0x55, 0xa5, 0xea, 0x26, 0xe6, 0x14, 0x64, 0x24, 0x96, 0xa4, 0x26, 0x82, 0x79, 0xfa, + 0x15, 0xfa, 0xf0, 0x58, 0xab, 0x2c, 0x48, 0x2d, 0x4e, 0x62, 0x03, 0xc7, 0x96, 0x31, 0x20, 0x00, + 0x00, 0xff, 0xff, 0x52, 0x00, 0x82, 0xda, 0x3e, 0x02, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -141,6 +150,20 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.TradingRewardList) > 0 { + for iNdEx := len(m.TradingRewardList) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.TradingRewardList[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x2a + } + } if m.TradingRewardsCounter != 0 { i = encodeVarintGenesis(dAtA, i, uint64(m.TradingRewardsCounter)) i-- @@ -209,6 +232,12 @@ func (m *GenesisState) Size() (n int) { if m.TradingRewardsCounter != 0 { n += 1 + sovGenesis(uint64(m.TradingRewardsCounter)) } + if len(m.TradingRewardList) > 0 { + for _, e := range m.TradingRewardList { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } return n } @@ -352,6 +381,40 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { break } } + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TradingRewardList", 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 + } + m.TradingRewardList = append(m.TradingRewardList, TradingReward{}) + if err := m.TradingRewardList[len(m.TradingRewardList)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipGenesis(dAtA[iNdEx:]) diff --git a/x/rewards/types/genesis_test.go b/x/rewards/types/genesis_test.go index 057f6b88..5592c345 100644 --- a/x/rewards/types/genesis_test.go +++ b/x/rewards/types/genesis_test.go @@ -30,6 +30,14 @@ func TestGenesisState_Validate(t *testing.T) { RewardId: "1", }, }, +TradingRewardList: []types.TradingReward{ + { + RewardId: "0", +}, + { + RewardId: "1", +}, +}, // this line is used by starport scaffolding # types/genesis/validField }, valid: true, @@ -48,6 +56,20 @@ func TestGenesisState_Validate(t *testing.T) { }, valid: false, }, +{ + desc: "duplicated tradingReward", + genState: &types.GenesisState{ + TradingRewardList: []types.TradingReward{ + { + RewardId: "0", +}, + { + RewardId: "0", +}, + }, + }, + valid: false, +}, // this line is used by starport scaffolding # types/genesis/testcase } { t.Run(tc.desc, func(t *testing.T) { diff --git a/x/rewards/types/key_staking_reward.go b/x/rewards/types/key_staking_reward.go index b927071f..d701a274 100644 --- a/x/rewards/types/key_staking_reward.go +++ b/x/rewards/types/key_staking_reward.go @@ -7,7 +7,6 @@ var _ binary.ByteOrder const ( // StakingRewardKeyPrefix is the prefix to retrieve all StakingReward StakingRewardKeyPrefix = "sr/value/" - TradingRewardKeyPrefix = "tr/value/" CounterKey = "sr/c/" ) @@ -19,7 +18,3 @@ func StakingRewardKey(rewardId string) []byte { func StakingRewardCounterKey() []byte { return []byte{1} } - -func TradingRewardCounterKey() []byte { - return []byte{2} -} diff --git a/x/rewards/types/key_trading_reward.go b/x/rewards/types/key_trading_reward.go new file mode 100644 index 00000000..e397d7f8 --- /dev/null +++ b/x/rewards/types/key_trading_reward.go @@ -0,0 +1,19 @@ +package types + +import "encoding/binary" + +var _ binary.ByteOrder + +const ( + // TradingRewardKeyPrefix is the prefix to retrieve all TradingReward + TradingRewardKeyPrefix = "tr/value/" +) + +// TradingRewardKey returns the store key to retrieve a TradingReward from the index fields +func TradingRewardKey(rewardId string) []byte { + return []byte(rewardId) +} + +func TradingRewardCounterKey() []byte { + return []byte{2} +} diff --git a/x/rewards/types/messages_staking_reward.go b/x/rewards/types/messages_staking_reward.go index 0ed13095..58c1e8f3 100644 --- a/x/rewards/types/messages_staking_reward.go +++ b/x/rewards/types/messages_staking_reward.go @@ -67,7 +67,7 @@ func (msg *MsgCreateStakingReward) ToStakingReward() (StakingReward, error) { if !amtInt.IsPositive() { return sr, sdkerrors.Wrapf(ErrInvalidPrizeAmount, "amount should be greater than 0") } - sr.PrizeAmount = amtInt.Int64() + sr.PrizeAmount = msg.PrizeAmount if msg.PrizeDenom == "" { return sr, ErrInvalidPrizeDenom diff --git a/x/rewards/types/messages_trading_reward.go b/x/rewards/types/messages_trading_reward.go new file mode 100644 index 00000000..33c191b8 --- /dev/null +++ b/x/rewards/types/messages_trading_reward.go @@ -0,0 +1,112 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "strconv" +) + +const ( + TypeMsgCreateTradingReward = "create_trading_reward" + + maxAllowedSlots = 100 +) + +var _ sdk.Msg = &MsgCreateTradingReward{} + +func NewMsgCreateTradingReward( + creator string, + prizeAmount string, + prizeDenom string, + duration string, + marketId string, + slots string, + +) *MsgCreateTradingReward { + return &MsgCreateTradingReward{ + Creator: creator, + PrizeAmount: prizeAmount, + PrizeDenom: prizeDenom, + Duration: duration, + MarketId: marketId, + Slots: slots, + } +} + +func (msg *MsgCreateTradingReward) Route() string { + return RouterKey +} + +func (msg *MsgCreateTradingReward) Type() string { + return TypeMsgCreateTradingReward +} + +func (msg *MsgCreateTradingReward) GetSigners() []sdk.AccAddress { + creator, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + panic(err) + } + return []sdk.AccAddress{creator} +} + +func (msg *MsgCreateTradingReward) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(msg) + return sdk.MustSortJSON(bz) +} + +func (msg *MsgCreateTradingReward) ToTradingReward() (TradingReward, error) { + tr := TradingReward{} + + amtInt, ok := sdk.NewIntFromString(msg.PrizeAmount) + if !ok { + return tr, sdkerrors.Wrapf(ErrInvalidPrizeAmount, "could not convert order amount") + } + if !amtInt.IsPositive() { + return tr, sdkerrors.Wrapf(ErrInvalidPrizeAmount, "amount should be greater than 0") + } + tr.PrizeAmount = amtInt.String() + + if msg.PrizeDenom == "" { + return tr, ErrInvalidPrizeDenom + } + tr.PrizeDenom = msg.PrizeDenom + + if msg.MarketId == "" { + return tr, ErrInvalidMarketId + } + tr.MarketId = msg.MarketId + + durationInt, err := strconv.Atoi(msg.Duration) + if err != nil { + return tr, sdkerrors.Wrapf(ErrInvalidDuration, "could not convert duration to int: %s", err.Error()) + } + if durationInt <= 0 || durationInt > tenYearsInDays { + return tr, ErrInvalidDuration + } + tr.Duration = uint32(durationInt) + + slotsInt, err := strconv.Atoi(msg.Slots) + if err != nil { + return tr, sdkerrors.Wrapf(ErrInvalidSlots, "could not convert slots to int: %s", err.Error()) + } + if slotsInt <= 0 || slotsInt > maxAllowedSlots { + return tr, ErrInvalidSlots + } + tr.Slots = uint32(slotsInt) + + return tr, nil +} + +func (msg *MsgCreateTradingReward) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err) + } + + _, err = msg.ToTradingReward() + if err != nil { + return err + } + + return nil +} diff --git a/x/rewards/types/messages_trading_reward_test.go b/x/rewards/types/messages_trading_reward_test.go new file mode 100644 index 00000000..9fe28f38 --- /dev/null +++ b/x/rewards/types/messages_trading_reward_test.go @@ -0,0 +1,102 @@ +package types + +import ( + "testing" + + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/stretchr/testify/require" + "github.com/bze-alphateam/bze/testutil/sample" +) + +func TestMsgCreateTradingReward_ValidateBasic(t *testing.T) { + tests := []struct { + name string + msg MsgCreateTradingReward + err error + }{ + { + name: "invalid address", + msg: MsgCreateTradingReward{ + Creator: "invalid_address", + }, + err: sdkerrors.ErrInvalidAddress, + }, { + name: "valid address", + msg: MsgCreateTradingReward{ + Creator: sample.AccAddress(), + }, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + err := tt.msg.ValidateBasic() + if tt.err != nil { + require.ErrorIs(t, err, tt.err) + return + } + require.NoError(t, err) + }) + } +} + +func TestMsgUpdateTradingReward_ValidateBasic(t *testing.T) { + tests := []struct { + name string + msg MsgUpdateTradingReward + err error + }{ + { + name: "invalid address", + msg: MsgUpdateTradingReward{ + Creator: "invalid_address", + }, + err: sdkerrors.ErrInvalidAddress, + }, { + name: "valid address", + msg: MsgUpdateTradingReward{ + Creator: sample.AccAddress(), + }, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + err := tt.msg.ValidateBasic() + if tt.err != nil { + require.ErrorIs(t, err, tt.err) + return + } + require.NoError(t, err) + }) + } +} + +func TestMsgDeleteTradingReward_ValidateBasic(t *testing.T) { + tests := []struct { + name string + msg MsgDeleteTradingReward + err error + }{ + { + name: "invalid address", + msg: MsgDeleteTradingReward{ + Creator: "invalid_address", + }, + err: sdkerrors.ErrInvalidAddress, + }, { + name: "valid address", + msg: MsgDeleteTradingReward{ + Creator: sample.AccAddress(), + }, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + err := tt.msg.ValidateBasic() + if tt.err != nil { + require.ErrorIs(t, err, tt.err) + return + } + require.NoError(t, err) + }) + } +} diff --git a/x/rewards/types/query.pb.go b/x/rewards/types/query.pb.go index d481faf9..d1eea5b5 100644 --- a/x/rewards/types/query.pb.go +++ b/x/rewards/types/query.pb.go @@ -297,6 +297,190 @@ func (m *QueryAllStakingRewardResponse) GetPagination() *query.PageResponse { return nil } +type QueryGetTradingRewardRequest struct { + RewardId string `protobuf:"bytes,1,opt,name=rewardId,proto3" json:"rewardId,omitempty"` +} + +func (m *QueryGetTradingRewardRequest) Reset() { *m = QueryGetTradingRewardRequest{} } +func (m *QueryGetTradingRewardRequest) String() string { return proto.CompactTextString(m) } +func (*QueryGetTradingRewardRequest) ProtoMessage() {} +func (*QueryGetTradingRewardRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_5ddc078ee02fb5e8, []int{6} +} +func (m *QueryGetTradingRewardRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryGetTradingRewardRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryGetTradingRewardRequest.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 *QueryGetTradingRewardRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryGetTradingRewardRequest.Merge(m, src) +} +func (m *QueryGetTradingRewardRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryGetTradingRewardRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryGetTradingRewardRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryGetTradingRewardRequest proto.InternalMessageInfo + +func (m *QueryGetTradingRewardRequest) GetRewardId() string { + if m != nil { + return m.RewardId + } + return "" +} + +type QueryGetTradingRewardResponse struct { + TradingReward TradingReward `protobuf:"bytes,1,opt,name=tradingReward,proto3" json:"tradingReward"` +} + +func (m *QueryGetTradingRewardResponse) Reset() { *m = QueryGetTradingRewardResponse{} } +func (m *QueryGetTradingRewardResponse) String() string { return proto.CompactTextString(m) } +func (*QueryGetTradingRewardResponse) ProtoMessage() {} +func (*QueryGetTradingRewardResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_5ddc078ee02fb5e8, []int{7} +} +func (m *QueryGetTradingRewardResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryGetTradingRewardResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryGetTradingRewardResponse.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 *QueryGetTradingRewardResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryGetTradingRewardResponse.Merge(m, src) +} +func (m *QueryGetTradingRewardResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryGetTradingRewardResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryGetTradingRewardResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryGetTradingRewardResponse proto.InternalMessageInfo + +func (m *QueryGetTradingRewardResponse) GetTradingReward() TradingReward { + if m != nil { + return m.TradingReward + } + return TradingReward{} +} + +type QueryAllTradingRewardRequest struct { + Pagination *query.PageRequest `protobuf:"bytes,1,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryAllTradingRewardRequest) Reset() { *m = QueryAllTradingRewardRequest{} } +func (m *QueryAllTradingRewardRequest) String() string { return proto.CompactTextString(m) } +func (*QueryAllTradingRewardRequest) ProtoMessage() {} +func (*QueryAllTradingRewardRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_5ddc078ee02fb5e8, []int{8} +} +func (m *QueryAllTradingRewardRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryAllTradingRewardRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryAllTradingRewardRequest.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 *QueryAllTradingRewardRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryAllTradingRewardRequest.Merge(m, src) +} +func (m *QueryAllTradingRewardRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryAllTradingRewardRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryAllTradingRewardRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryAllTradingRewardRequest proto.InternalMessageInfo + +func (m *QueryAllTradingRewardRequest) GetPagination() *query.PageRequest { + if m != nil { + return m.Pagination + } + return nil +} + +type QueryAllTradingRewardResponse struct { + TradingReward []TradingReward `protobuf:"bytes,1,rep,name=tradingReward,proto3" json:"tradingReward"` + Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryAllTradingRewardResponse) Reset() { *m = QueryAllTradingRewardResponse{} } +func (m *QueryAllTradingRewardResponse) String() string { return proto.CompactTextString(m) } +func (*QueryAllTradingRewardResponse) ProtoMessage() {} +func (*QueryAllTradingRewardResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_5ddc078ee02fb5e8, []int{9} +} +func (m *QueryAllTradingRewardResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryAllTradingRewardResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryAllTradingRewardResponse.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 *QueryAllTradingRewardResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryAllTradingRewardResponse.Merge(m, src) +} +func (m *QueryAllTradingRewardResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryAllTradingRewardResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryAllTradingRewardResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryAllTradingRewardResponse proto.InternalMessageInfo + +func (m *QueryAllTradingRewardResponse) GetTradingReward() []TradingReward { + if m != nil { + return m.TradingReward + } + return nil +} + +func (m *QueryAllTradingRewardResponse) GetPagination() *query.PageResponse { + if m != nil { + return m.Pagination + } + return nil +} + func init() { proto.RegisterType((*QueryParamsRequest)(nil), "bze.v1.rewards.QueryParamsRequest") proto.RegisterType((*QueryParamsResponse)(nil), "bze.v1.rewards.QueryParamsResponse") @@ -304,45 +488,57 @@ func init() { proto.RegisterType((*QueryGetStakingRewardResponse)(nil), "bze.v1.rewards.QueryGetStakingRewardResponse") proto.RegisterType((*QueryAllStakingRewardRequest)(nil), "bze.v1.rewards.QueryAllStakingRewardRequest") proto.RegisterType((*QueryAllStakingRewardResponse)(nil), "bze.v1.rewards.QueryAllStakingRewardResponse") + proto.RegisterType((*QueryGetTradingRewardRequest)(nil), "bze.v1.rewards.QueryGetTradingRewardRequest") + proto.RegisterType((*QueryGetTradingRewardResponse)(nil), "bze.v1.rewards.QueryGetTradingRewardResponse") + proto.RegisterType((*QueryAllTradingRewardRequest)(nil), "bze.v1.rewards.QueryAllTradingRewardRequest") + proto.RegisterType((*QueryAllTradingRewardResponse)(nil), "bze.v1.rewards.QueryAllTradingRewardResponse") } func init() { proto.RegisterFile("rewards/query.proto", fileDescriptor_5ddc078ee02fb5e8) } var fileDescriptor_5ddc078ee02fb5e8 = []byte{ - // 526 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x94, 0x41, 0x4f, 0x13, 0x41, - 0x14, 0xc7, 0x3b, 0x80, 0x8d, 0x8c, 0x81, 0x98, 0xa1, 0x21, 0x4d, 0x2d, 0x6b, 0x33, 0x26, 0x68, - 0x48, 0x99, 0x49, 0xab, 0x89, 0x07, 0x4f, 0x70, 0x80, 0xa8, 0x17, 0x5c, 0x6f, 0x5e, 0xc8, 0x2c, - 0x1d, 0x97, 0x0d, 0xdb, 0x9d, 0xed, 0xce, 0xb4, 0x0a, 0xc6, 0x8b, 0x9f, 0xc0, 0xc4, 0x83, 0x57, - 0xfd, 0x14, 0x7e, 0x05, 0x8e, 0x24, 0x5e, 0x3c, 0x19, 0xd3, 0xfa, 0x41, 0x4c, 0x67, 0x5e, 0xb1, - 0x5b, 0x58, 0xe0, 0xd6, 0x99, 0xf9, 0xbf, 0xff, 0xfb, 0xbd, 0xbe, 0x7f, 0x16, 0xaf, 0x64, 0xf2, - 0x9d, 0xc8, 0x3a, 0x9a, 0xf7, 0xfa, 0x32, 0x3b, 0x66, 0x69, 0xa6, 0x8c, 0x22, 0xcb, 0xc1, 0x89, - 0x64, 0x83, 0x16, 0x83, 0xb7, 0x5a, 0x25, 0x54, 0xa1, 0xb2, 0x4f, 0x7c, 0xfc, 0xcb, 0xa9, 0x6a, - 0xf5, 0x50, 0xa9, 0x30, 0x96, 0x5c, 0xa4, 0x11, 0x17, 0x49, 0xa2, 0x8c, 0x30, 0x91, 0x4a, 0x34, - 0xbc, 0x6e, 0x1c, 0x28, 0xdd, 0x55, 0x9a, 0x07, 0x42, 0x4b, 0x67, 0xce, 0x07, 0xad, 0x40, 0x1a, - 0xd1, 0xe2, 0xa9, 0x08, 0xa3, 0xc4, 0x8a, 0x41, 0x5b, 0x99, 0x40, 0xa4, 0x22, 0x13, 0xdd, 0x89, - 0x43, 0x7d, 0x72, 0xab, 0x8d, 0x38, 0x8a, 0x92, 0x70, 0xdf, 0x9d, 0xdd, 0x2b, 0xad, 0x60, 0xf2, - 0x6a, 0xec, 0xba, 0x67, 0x4b, 0x7c, 0xd9, 0xeb, 0x4b, 0x6d, 0xe8, 0x4b, 0xbc, 0x92, 0xbb, 0xd5, - 0xa9, 0x4a, 0xb4, 0x24, 0x4f, 0x70, 0xd9, 0x59, 0x57, 0x51, 0x03, 0x3d, 0xba, 0xd3, 0x5e, 0x65, - 0xf9, 0x09, 0x99, 0xd3, 0x6f, 0x2f, 0x9c, 0xfe, 0xbe, 0x5f, 0xf2, 0x41, 0x4b, 0x9f, 0xe1, 0xba, - 0x35, 0xdb, 0x95, 0xe6, 0xb5, 0x43, 0xf0, 0xad, 0x1c, 0x9a, 0x91, 0x7b, 0x78, 0xd1, 0xd5, 0xef, - 0x47, 0x1d, 0x6b, 0xbc, 0xe8, 0xdf, 0x76, 0x17, 0xcf, 0x3b, 0xf4, 0x08, 0xaf, 0x15, 0x14, 0x03, - 0xd3, 0x0b, 0xbc, 0x9c, 0x1f, 0x0c, 0xd8, 0xd6, 0x66, 0xd9, 0x72, 0xe5, 0x80, 0xb8, 0xa4, 0xa7, - 0x2f, 0xe9, 0x5b, 0x20, 0xdd, 0x8a, 0xe3, 0x4b, 0x49, 0x77, 0x30, 0xfe, 0xff, 0xa7, 0x43, 0x9f, - 0x75, 0xe6, 0x36, 0xc4, 0xc6, 0x1b, 0x62, 0x6e, 0xfd, 0xb0, 0x21, 0xb6, 0x27, 0x42, 0x09, 0xb5, - 0xfe, 0x54, 0x25, 0xfd, 0x8e, 0x60, 0xaa, 0x8b, 0x8d, 0x60, 0xaa, 0xa7, 0x78, 0x21, 0x8e, 0xb4, - 0xa9, 0xa2, 0xc6, 0xfc, 0x4d, 0x67, 0xb1, 0x05, 0x64, 0x37, 0x87, 0x38, 0x67, 0x11, 0x1f, 0x5e, - 0x8b, 0xe8, 0xba, 0x4e, 0x33, 0xb6, 0x7f, 0xcc, 0xe3, 0x5b, 0x96, 0x91, 0xf4, 0x70, 0xd9, 0xed, - 0x95, 0xd0, 0x59, 0x8e, 0x8b, 0xd1, 0xa9, 0x3d, 0xb8, 0x52, 0xe3, 0x1a, 0x51, 0xef, 0xd3, 0xcf, - 0xbf, 0x5f, 0xe6, 0xaa, 0x64, 0x95, 0x07, 0x27, 0x92, 0x4f, 0x02, 0x3a, 0x68, 0x41, 0x72, 0xc9, - 0x37, 0x84, 0x97, 0x72, 0x33, 0x92, 0xe6, 0xa5, 0xb6, 0x05, 0x91, 0xaa, 0x6d, 0xde, 0x50, 0x0d, - 0x38, 0x6d, 0x8b, 0xd3, 0x24, 0x1b, 0xb3, 0x38, 0xf9, 0x64, 0xf1, 0x0f, 0xe7, 0x39, 0xfd, 0x48, - 0xbe, 0x22, 0x7c, 0x37, 0xe7, 0xb6, 0x15, 0xc7, 0x05, 0x94, 0x05, 0x71, 0x2a, 0xa0, 0x2c, 0xca, - 0x04, 0x5d, 0xb7, 0x94, 0x0d, 0xe2, 0x5d, 0x4d, 0xb9, 0xbd, 0x73, 0x3a, 0xf4, 0xd0, 0xd9, 0xd0, - 0x43, 0x7f, 0x86, 0x1e, 0xfa, 0x3c, 0xf2, 0x4a, 0x67, 0x23, 0xaf, 0xf4, 0x6b, 0xe4, 0x95, 0xde, - 0x34, 0xc3, 0xc8, 0x1c, 0xf6, 0x03, 0x76, 0xa0, 0xba, 0x63, 0x8f, 0x4d, 0x11, 0xa7, 0x87, 0xc2, - 0x48, 0x61, 0x4f, 0xfc, 0xfd, 0xb9, 0xa7, 0x39, 0x4e, 0xa5, 0x0e, 0xca, 0xf6, 0x0b, 0xf1, 0xf8, - 0x5f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x52, 0x97, 0x4b, 0xe2, 0xdc, 0x04, 0x00, 0x00, + // 642 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x95, 0xcb, 0x6e, 0xd3, 0x4c, + 0x14, 0xc7, 0xe3, 0x5e, 0xa2, 0xaf, 0xf3, 0x29, 0x15, 0x9a, 0x46, 0x55, 0x14, 0x52, 0x13, 0x19, + 0xa9, 0x40, 0x49, 0x6d, 0x25, 0x20, 0x21, 0xc1, 0xaa, 0x5d, 0xb4, 0x0a, 0x6c, 0x4a, 0x60, 0xc5, + 0xa6, 0x1a, 0x37, 0x83, 0x6b, 0xea, 0x78, 0x1c, 0xcf, 0x24, 0xd0, 0x22, 0x36, 0x3c, 0x01, 0x12, + 0x0b, 0x96, 0xc0, 0x33, 0xf0, 0x12, 0x5d, 0x56, 0x62, 0xc3, 0x0a, 0xa1, 0x84, 0x37, 0xe0, 0x05, + 0x50, 0x66, 0xc6, 0x49, 0xc6, 0xc9, 0x84, 0x80, 0xba, 0x4b, 0x66, 0xce, 0xe5, 0x77, 0xce, 0xff, + 0xcc, 0x31, 0x58, 0x8b, 0xf1, 0x4b, 0x14, 0x37, 0xa9, 0xd3, 0xee, 0xe0, 0xf8, 0xd4, 0x8e, 0x62, + 0xc2, 0x08, 0x5c, 0x75, 0xcf, 0xb0, 0xdd, 0xad, 0xda, 0xf2, 0xae, 0x98, 0xf7, 0x88, 0x47, 0xf8, + 0x95, 0x33, 0xf8, 0x25, 0xac, 0x8a, 0x25, 0x8f, 0x10, 0x2f, 0xc0, 0x0e, 0x8a, 0x7c, 0x07, 0x85, + 0x21, 0x61, 0x88, 0xf9, 0x24, 0xa4, 0xf2, 0x76, 0xeb, 0x88, 0xd0, 0x16, 0xa1, 0x8e, 0x8b, 0x28, + 0x16, 0xc1, 0x9d, 0x6e, 0xd5, 0xc5, 0x0c, 0x55, 0x9d, 0x08, 0x79, 0x7e, 0xc8, 0x8d, 0xa5, 0x6d, + 0x3e, 0x81, 0x88, 0x50, 0x8c, 0x5a, 0x49, 0x84, 0x52, 0x72, 0x4a, 0x19, 0x3a, 0xf1, 0x43, 0xef, + 0x50, 0xfc, 0x4f, 0xdf, 0xb2, 0x18, 0x35, 0xd3, 0xb7, 0x56, 0x1e, 0xc0, 0xc7, 0x83, 0x9c, 0x07, + 0x3c, 0x60, 0x03, 0xb7, 0x3b, 0x98, 0x32, 0xeb, 0x11, 0x58, 0x53, 0x4e, 0x69, 0x44, 0x42, 0x8a, + 0xe1, 0x5d, 0x90, 0x15, 0x89, 0x0b, 0x46, 0xd9, 0xb8, 0xf9, 0x7f, 0x6d, 0xdd, 0x56, 0xeb, 0xb7, + 0x85, 0xfd, 0xee, 0xd2, 0xf9, 0xf7, 0x6b, 0x99, 0x86, 0xb4, 0xb5, 0x1e, 0x80, 0x12, 0x0f, 0xb6, + 0x8f, 0xd9, 0x13, 0x01, 0xd8, 0xe0, 0xe6, 0x32, 0x19, 0xbc, 0x0a, 0x56, 0x84, 0xff, 0xa1, 0xdf, + 0xe4, 0x81, 0x57, 0x1a, 0xff, 0x89, 0x83, 0x7a, 0xd3, 0x3a, 0x01, 0x1b, 0x1a, 0x67, 0xc9, 0xf4, + 0x10, 0xac, 0xaa, 0x65, 0x4b, 0xb6, 0x8d, 0x34, 0x9b, 0xe2, 0x2e, 0x11, 0x73, 0x74, 0xfc, 0xd0, + 0x7a, 0x2e, 0x49, 0x77, 0x82, 0x60, 0x2a, 0xe9, 0x1e, 0x00, 0x23, 0x49, 0x64, 0x9e, 0x4d, 0x5b, + 0xe8, 0x67, 0x0f, 0xf4, 0xb3, 0xc5, 0x70, 0x48, 0xfd, 0xec, 0x03, 0xe4, 0x61, 0xe9, 0xdb, 0x18, + 0xf3, 0xb4, 0x3e, 0x1b, 0xb2, 0xaa, 0xc9, 0x44, 0xb2, 0xaa, 0x7b, 0x60, 0x29, 0xf0, 0x29, 0x2b, + 0x18, 0xe5, 0xc5, 0x79, 0x6b, 0xe1, 0x0e, 0x70, 0x5f, 0x41, 0x5c, 0xe0, 0x88, 0x37, 0xfe, 0x88, + 0x28, 0xb2, 0x2a, 0x8c, 0xf7, 0x47, 0xaa, 0x3d, 0x15, 0x83, 0xa3, 0xf6, 0xa2, 0x08, 0x86, 0x22, + 0x4d, 0x88, 0xf6, 0x62, 0x24, 0x5a, 0xca, 0x57, 0x96, 0x57, 0x07, 0x39, 0x36, 0x7e, 0xa1, 0xd3, + 0x4c, 0xf1, 0x4e, 0x34, 0x53, 0x3c, 0xc7, 0x35, 0x9b, 0xca, 0x79, 0x59, 0x9a, 0x7d, 0x19, 0xd3, + 0x6c, 0xee, 0xa2, 0x16, 0xff, 0xad, 0xa8, 0x4b, 0x53, 0xb1, 0xf6, 0x6b, 0x19, 0x2c, 0x73, 0x6a, + 0xd8, 0x06, 0x59, 0xf1, 0x3a, 0xa1, 0x95, 0x06, 0x9a, 0x5c, 0x00, 0xc5, 0xeb, 0x33, 0x6d, 0x44, + 0x22, 0xcb, 0x7c, 0xfb, 0xf5, 0xe7, 0xfb, 0x85, 0x02, 0x5c, 0x77, 0xdc, 0x33, 0xec, 0x24, 0x6b, + 0xa6, 0x5b, 0x95, 0xdb, 0x09, 0x7e, 0x32, 0x40, 0x4e, 0x99, 0x54, 0x58, 0x99, 0x1a, 0x56, 0xb3, + 0x18, 0x8a, 0xdb, 0x73, 0x5a, 0x4b, 0x9c, 0x1a, 0xc7, 0xa9, 0xc0, 0xad, 0x34, 0x8e, 0xba, 0x1f, + 0x9c, 0xd7, 0xc3, 0x6d, 0xf3, 0x06, 0x7e, 0x30, 0xc0, 0x15, 0x25, 0xda, 0x4e, 0x10, 0x68, 0x28, + 0x35, 0x4b, 0x41, 0x43, 0xa9, 0x7b, 0xd9, 0xd6, 0x26, 0xa7, 0x2c, 0x43, 0x73, 0x36, 0x25, 0xfc, + 0x68, 0x80, 0x9c, 0x32, 0x29, 0xfa, 0xe6, 0x4d, 0x9b, 0x7b, 0x7d, 0xf3, 0xa6, 0x0e, 0xaf, 0x55, + 0xe5, 0x58, 0xb7, 0xe1, 0xad, 0x34, 0x96, 0xfa, 0xd5, 0x48, 0x9a, 0x57, 0x97, 0xbd, 0x53, 0x82, + 0xcd, 0xec, 0xdd, 0x5f, 0x40, 0xea, 0x5e, 0x98, 0xbe, 0x77, 0x2a, 0xe4, 0xee, 0xde, 0x79, 0xcf, + 0x34, 0x2e, 0x7a, 0xa6, 0xf1, 0xa3, 0x67, 0x1a, 0xef, 0xfa, 0x66, 0xe6, 0xa2, 0x6f, 0x66, 0xbe, + 0xf5, 0xcd, 0xcc, 0xb3, 0x8a, 0xe7, 0xb3, 0xe3, 0x8e, 0x6b, 0x1f, 0x91, 0xd6, 0x20, 0xc6, 0x36, + 0x0a, 0xa2, 0x63, 0xc4, 0x30, 0xe2, 0xff, 0x9c, 0x57, 0xc3, 0x98, 0xec, 0x34, 0xc2, 0xd4, 0xcd, + 0xf2, 0x6f, 0xe4, 0x9d, 0xdf, 0x01, 0x00, 0x00, 0xff, 0xff, 0x35, 0xb1, 0xa0, 0x24, 0xfc, 0x07, + 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -363,6 +559,10 @@ type QueryClient interface { StakingReward(ctx context.Context, in *QueryGetStakingRewardRequest, opts ...grpc.CallOption) (*QueryGetStakingRewardResponse, error) // Queries a list of StakingReward items. StakingRewardAll(ctx context.Context, in *QueryAllStakingRewardRequest, opts ...grpc.CallOption) (*QueryAllStakingRewardResponse, error) + // Queries a TradingReward by index. + TradingReward(ctx context.Context, in *QueryGetTradingRewardRequest, opts ...grpc.CallOption) (*QueryGetTradingRewardResponse, error) + // Queries a list of TradingReward items. + TradingRewardAll(ctx context.Context, in *QueryAllTradingRewardRequest, opts ...grpc.CallOption) (*QueryAllTradingRewardResponse, error) } type queryClient struct { @@ -400,6 +600,24 @@ func (c *queryClient) StakingRewardAll(ctx context.Context, in *QueryAllStakingR return out, nil } +func (c *queryClient) TradingReward(ctx context.Context, in *QueryGetTradingRewardRequest, opts ...grpc.CallOption) (*QueryGetTradingRewardResponse, error) { + out := new(QueryGetTradingRewardResponse) + err := c.cc.Invoke(ctx, "/bze.v1.rewards.Query/TradingReward", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) TradingRewardAll(ctx context.Context, in *QueryAllTradingRewardRequest, opts ...grpc.CallOption) (*QueryAllTradingRewardResponse, error) { + out := new(QueryAllTradingRewardResponse) + err := c.cc.Invoke(ctx, "/bze.v1.rewards.Query/TradingRewardAll", 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. @@ -408,6 +626,10 @@ type QueryServer interface { StakingReward(context.Context, *QueryGetStakingRewardRequest) (*QueryGetStakingRewardResponse, error) // Queries a list of StakingReward items. StakingRewardAll(context.Context, *QueryAllStakingRewardRequest) (*QueryAllStakingRewardResponse, error) + // Queries a TradingReward by index. + TradingReward(context.Context, *QueryGetTradingRewardRequest) (*QueryGetTradingRewardResponse, error) + // Queries a list of TradingReward items. + TradingRewardAll(context.Context, *QueryAllTradingRewardRequest) (*QueryAllTradingRewardResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -423,6 +645,12 @@ func (*UnimplementedQueryServer) StakingReward(ctx context.Context, req *QueryGe func (*UnimplementedQueryServer) StakingRewardAll(ctx context.Context, req *QueryAllStakingRewardRequest) (*QueryAllStakingRewardResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method StakingRewardAll not implemented") } +func (*UnimplementedQueryServer) TradingReward(ctx context.Context, req *QueryGetTradingRewardRequest) (*QueryGetTradingRewardResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method TradingReward not implemented") +} +func (*UnimplementedQueryServer) TradingRewardAll(ctx context.Context, req *QueryAllTradingRewardRequest) (*QueryAllTradingRewardResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method TradingRewardAll not implemented") +} func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) @@ -482,6 +710,42 @@ func _Query_StakingRewardAll_Handler(srv interface{}, ctx context.Context, dec f return interceptor(ctx, in, info, handler) } +func _Query_TradingReward_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryGetTradingRewardRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).TradingReward(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/bze.v1.rewards.Query/TradingReward", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).TradingReward(ctx, req.(*QueryGetTradingRewardRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_TradingRewardAll_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryAllTradingRewardRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).TradingRewardAll(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/bze.v1.rewards.Query/TradingRewardAll", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).TradingRewardAll(ctx, req.(*QueryAllTradingRewardRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "bze.v1.rewards.Query", HandlerType: (*QueryServer)(nil), @@ -498,6 +762,14 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "StakingRewardAll", Handler: _Query_StakingRewardAll_Handler, }, + { + MethodName: "TradingReward", + Handler: _Query_TradingReward_Handler, + }, + { + MethodName: "TradingRewardAll", + Handler: _Query_TradingRewardAll_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "rewards/query.proto", @@ -706,100 +978,601 @@ func (m *QueryAllStakingRewardResponse) MarshalToSizedBuffer(dAtA []byte) (int, 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++ +func (m *QueryGetTradingRewardRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err } - dAtA[offset] = uint8(v) - return base + return dAtA[:n], nil } -func (m *QueryParamsRequest) Size() (n int) { - if m == nil { - return 0 - } + +func (m *QueryGetTradingRewardRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryGetTradingRewardRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - return n + if len(m.RewardId) > 0 { + i -= len(m.RewardId) + copy(dAtA[i:], m.RewardId) + i = encodeVarintQuery(dAtA, i, uint64(len(m.RewardId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil } -func (m *QueryParamsResponse) Size() (n int) { - if m == nil { - return 0 +func (m *QueryGetTradingRewardResponse) 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 *QueryGetTradingRewardResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryGetTradingRewardResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - l = m.Params.Size() - n += 1 + l + sovQuery(uint64(l)) - return n + { + size, err := m.TradingReward.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 (m *QueryGetStakingRewardRequest) Size() (n int) { - if m == nil { - return 0 +func (m *QueryAllTradingRewardRequest) 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 *QueryAllTradingRewardRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryAllTradingRewardRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - l = len(m.RewardId) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa } - return n + return len(dAtA) - i, nil } -func (m *QueryGetStakingRewardResponse) Size() (n int) { - if m == nil { +func (m *QueryAllTradingRewardResponse) 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 *QueryAllTradingRewardResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryAllTradingRewardResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.TradingReward) > 0 { + for iNdEx := len(m.TradingReward) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.TradingReward[iNdEx].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 - l = m.StakingReward.Size() - n += 1 + l + sovQuery(uint64(l)) - return n -} + 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 (m *QueryGetStakingRewardRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.RewardId) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryGetStakingRewardResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.StakingReward.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *QueryAllStakingRewardRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryAllStakingRewardResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.List) > 0 { + for _, e := range m.List { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryGetTradingRewardRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.RewardId) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryGetTradingRewardResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.TradingReward.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *QueryAllTradingRewardRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryAllTradingRewardResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.TradingReward) > 0 { + for _, e := range m.TradingReward { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if m.Pagination != nil { + l = m.Pagination.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 (m *QueryGetStakingRewardRequest) 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: QueryGetStakingRewardRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGetStakingRewardRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RewardId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.RewardId = string(dAtA[iNdEx:postIndex]) + 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 + } + } -func (m *QueryAllStakingRewardRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Pagination != nil { - l = m.Pagination.Size() - n += 1 + l + sovQuery(uint64(l)) + if iNdEx > l { + return io.ErrUnexpectedEOF } - return n + return nil } - -func (m *QueryAllStakingRewardResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.List) > 0 { - for _, e := range m.List { - l = e.Size() - n += 1 + l + sovQuery(uint64(l)) +func (m *QueryGetStakingRewardResponse) 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: QueryGetStakingRewardResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGetStakingRewardResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field StakingReward", 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.StakingReward.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 m.Pagination != nil { - l = m.Pagination.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)))) + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil } -func (m *QueryParamsRequest) Unmarshal(dAtA []byte) error { +func (m *QueryAllStakingRewardRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -822,12 +1595,48 @@ func (m *QueryParamsRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryParamsRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryAllStakingRewardRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryParamsRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryAllStakingRewardRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", 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 m.Pagination == nil { + m.Pagination = &query.PageRequest{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) @@ -849,7 +1658,7 @@ func (m *QueryParamsRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error { +func (m *QueryAllStakingRewardResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -872,15 +1681,15 @@ func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryParamsResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryAllStakingRewardResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryParamsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryAllStakingRewardResponse: 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) + return fmt.Errorf("proto: wrong wireType = %d for field List", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -907,7 +1716,44 @@ func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.Params.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.List = append(m.List, StakingReward{}) + if err := m.List[len(m.List)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", 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 m.Pagination == nil { + m.Pagination = &query.PageResponse{} + } + if err := m.Pagination.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -932,7 +1778,7 @@ func (m *QueryParamsResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryGetStakingRewardRequest) Unmarshal(dAtA []byte) error { +func (m *QueryGetTradingRewardRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -955,10 +1801,10 @@ func (m *QueryGetStakingRewardRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryGetStakingRewardRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryGetTradingRewardRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryGetStakingRewardRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryGetTradingRewardRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -1014,7 +1860,7 @@ func (m *QueryGetStakingRewardRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryGetStakingRewardResponse) Unmarshal(dAtA []byte) error { +func (m *QueryGetTradingRewardResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1037,15 +1883,15 @@ func (m *QueryGetStakingRewardResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryGetStakingRewardResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryGetTradingRewardResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryGetStakingRewardResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryGetTradingRewardResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field StakingReward", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field TradingReward", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -1072,7 +1918,7 @@ func (m *QueryGetStakingRewardResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if err := m.StakingReward.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.TradingReward.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex @@ -1097,7 +1943,7 @@ func (m *QueryGetStakingRewardResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryAllStakingRewardRequest) Unmarshal(dAtA []byte) error { +func (m *QueryAllTradingRewardRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1120,10 +1966,10 @@ func (m *QueryAllStakingRewardRequest) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryAllStakingRewardRequest: wiretype end group for non-group") + return fmt.Errorf("proto: QueryAllTradingRewardRequest: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryAllStakingRewardRequest: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryAllTradingRewardRequest: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -1183,7 +2029,7 @@ func (m *QueryAllStakingRewardRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *QueryAllStakingRewardResponse) Unmarshal(dAtA []byte) error { +func (m *QueryAllTradingRewardResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1206,15 +2052,15 @@ func (m *QueryAllStakingRewardResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: QueryAllStakingRewardResponse: wiretype end group for non-group") + return fmt.Errorf("proto: QueryAllTradingRewardResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: QueryAllStakingRewardResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: QueryAllTradingRewardResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field List", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field TradingReward", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -1241,8 +2087,8 @@ func (m *QueryAllStakingRewardResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.List = append(m.List, StakingReward{}) - if err := m.List[len(m.List)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.TradingReward = append(m.TradingReward, TradingReward{}) + if err := m.TradingReward[len(m.TradingReward)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex diff --git a/x/rewards/types/query.pb.gw.go b/x/rewards/types/query.pb.gw.go index ee0af6e7..e7208d32 100644 --- a/x/rewards/types/query.pb.gw.go +++ b/x/rewards/types/query.pb.gw.go @@ -141,6 +141,96 @@ func local_request_Query_StakingRewardAll_0(ctx context.Context, marshaler runti } +func request_Query_TradingReward_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryGetTradingRewardRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["rewardId"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "rewardId") + } + + protoReq.RewardId, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "rewardId", err) + } + + msg, err := client.TradingReward(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_TradingReward_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryGetTradingRewardRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["rewardId"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "rewardId") + } + + protoReq.RewardId, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "rewardId", err) + } + + msg, err := server.TradingReward(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_Query_TradingRewardAll_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_Query_TradingRewardAll_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryAllTradingRewardRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_TradingRewardAll_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.TradingRewardAll(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_TradingRewardAll_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryAllTradingRewardRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_TradingRewardAll_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.TradingRewardAll(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. @@ -216,6 +306,52 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_TradingReward_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_TradingReward_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_TradingReward_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_TradingRewardAll_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_TradingRewardAll_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_TradingRewardAll_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -317,6 +453,46 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_TradingReward_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_TradingReward_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_TradingReward_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_TradingRewardAll_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_TradingRewardAll_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_TradingRewardAll_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -326,6 +502,10 @@ var ( pattern_Query_StakingReward_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"bze", "rewards", "v1", "staking_reward", "reward_id"}, "", runtime.AssumeColonVerbOpt(true))) pattern_Query_StakingRewardAll_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"bze", "rewards", "v1", "staking_reward"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_TradingReward_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"bze", "rewards", "v1", "trading_reward", "rewardId"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_TradingRewardAll_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"bze", "rewards", "v1", "trading_reward"}, "", runtime.AssumeColonVerbOpt(true))) ) var ( @@ -334,4 +514,8 @@ var ( forward_Query_StakingReward_0 = runtime.ForwardResponseMessage forward_Query_StakingRewardAll_0 = runtime.ForwardResponseMessage + + forward_Query_TradingReward_0 = runtime.ForwardResponseMessage + + forward_Query_TradingRewardAll_0 = runtime.ForwardResponseMessage ) diff --git a/x/rewards/types/staking_reward.pb.go b/x/rewards/types/staking_reward.pb.go index 3d6e7aa8..00e18835 100644 --- a/x/rewards/types/staking_reward.pb.go +++ b/x/rewards/types/staking_reward.pb.go @@ -24,12 +24,12 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type StakingReward struct { RewardId string `protobuf:"bytes,1,opt,name=reward_id,json=rewardId,proto3" json:"reward_id,omitempty"` - PrizeAmount int64 `protobuf:"varint,2,opt,name=prize_amount,json=prizeAmount,proto3" json:"prize_amount,omitempty"` + PrizeAmount string `protobuf:"bytes,2,opt,name=prize_amount,json=prizeAmount,proto3" json:"prize_amount,omitempty"` PrizeDenom string `protobuf:"bytes,3,opt,name=prize_denom,json=prizeDenom,proto3" json:"prize_denom,omitempty"` StakingDenom string `protobuf:"bytes,4,opt,name=staking_denom,json=stakingDenom,proto3" json:"staking_denom,omitempty"` Duration uint32 `protobuf:"varint,5,opt,name=duration,proto3" json:"duration,omitempty"` Payouts uint32 `protobuf:"varint,6,opt,name=payouts,proto3" json:"payouts,omitempty"` - MinStake uint64 `protobuf:"varint,7,opt,name=minStake,proto3" json:"minStake,omitempty"` + MinStake uint64 `protobuf:"varint,7,opt,name=min_stake,json=minStake,proto3" json:"min_stake,omitempty"` Lock uint32 `protobuf:"varint,8,opt,name=lock,proto3" json:"lock,omitempty"` } @@ -73,11 +73,11 @@ func (m *StakingReward) GetRewardId() string { return "" } -func (m *StakingReward) GetPrizeAmount() int64 { +func (m *StakingReward) GetPrizeAmount() string { if m != nil { return m.PrizeAmount } - return 0 + return "" } func (m *StakingReward) GetPrizeDenom() string { @@ -129,25 +129,26 @@ func init() { func init() { proto.RegisterFile("rewards/staking_reward.proto", fileDescriptor_a8c582f9c980c2bd) } var fileDescriptor_a8c582f9c980c2bd = []byte{ - // 287 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x3c, 0x90, 0xc1, 0x4e, 0x83, 0x30, - 0x18, 0xc7, 0xa9, 0xc3, 0x8d, 0xd5, 0xe1, 0xa1, 0xa7, 0x46, 0x4d, 0x45, 0xbd, 0x70, 0x50, 0x88, - 0xf1, 0x09, 0x34, 0xc6, 0xc4, 0x2b, 0xde, 0xbc, 0x90, 0x32, 0x9a, 0xad, 0xd9, 0xa0, 0x04, 0x8a, - 0x3a, 0x9e, 0xc2, 0xc7, 0xf2, 0xb8, 0xa3, 0x47, 0x03, 0x8f, 0xe1, 0x65, 0xe1, 0xeb, 0xd8, 0xad, - 0xbf, 0xdf, 0xf7, 0xff, 0x9a, 0xf6, 0x8f, 0x2f, 0x4a, 0xf1, 0xc9, 0xcb, 0xb4, 0x0a, 0x2b, 0xcd, - 0x57, 0x32, 0x5f, 0xc4, 0x86, 0x83, 0xa2, 0x54, 0x5a, 0x91, 0xd3, 0xa4, 0x11, 0xc1, 0xc7, 0x7d, - 0xb0, 0x0f, 0x5d, 0xff, 0x23, 0xec, 0xbe, 0x99, 0x60, 0x04, 0x8a, 0x9c, 0xe3, 0xa9, 0x19, 0xc6, - 0x32, 0xa5, 0xc8, 0x43, 0xfe, 0x34, 0x72, 0x8c, 0x78, 0x4d, 0xc9, 0x15, 0x9e, 0x15, 0xa5, 0x6c, - 0x44, 0xcc, 0x33, 0x55, 0xe7, 0x9a, 0x1e, 0x79, 0xc8, 0x1f, 0x45, 0x27, 0xe0, 0x1e, 0x41, 0x91, - 0x4b, 0x6c, 0x30, 0x4e, 0x45, 0xae, 0x32, 0x3a, 0x82, 0x1b, 0x30, 0xa8, 0xe7, 0xde, 0x90, 0x1b, - 0xec, 0x0e, 0x4f, 0x33, 0x11, 0x1b, 0x22, 0xb3, 0xbd, 0x34, 0xa1, 0x33, 0xec, 0xa4, 0x75, 0xc9, - 0xb5, 0x54, 0x39, 0x3d, 0xf6, 0x90, 0xef, 0x46, 0x07, 0x26, 0x14, 0x4f, 0x0a, 0xbe, 0x51, 0xb5, - 0xae, 0xe8, 0x18, 0x46, 0x03, 0xf6, 0x5b, 0x99, 0xcc, 0xfb, 0xff, 0x08, 0x3a, 0xf1, 0x90, 0x6f, - 0x47, 0x07, 0x26, 0x04, 0xdb, 0x6b, 0x35, 0x5f, 0x51, 0x07, 0x56, 0xe0, 0xfc, 0xf4, 0xf2, 0xd3, - 0x32, 0xb4, 0x6d, 0x19, 0xfa, 0x6b, 0x19, 0xfa, 0xee, 0x98, 0xb5, 0xed, 0x98, 0xf5, 0xdb, 0x31, - 0xeb, 0xfd, 0x76, 0x21, 0xf5, 0xb2, 0x4e, 0x82, 0xb9, 0xca, 0xc2, 0xa4, 0x11, 0x77, 0x7c, 0x5d, - 0x2c, 0xb9, 0x16, 0x1c, 0x28, 0xfc, 0x0a, 0x87, 0x92, 0xf5, 0xa6, 0x10, 0x55, 0x32, 0x86, 0x72, - 0x1f, 0x76, 0x01, 0x00, 0x00, 0xff, 0xff, 0x07, 0x26, 0x4a, 0x15, 0x7c, 0x01, 0x00, 0x00, + // 290 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x3c, 0x90, 0xb1, 0x4e, 0xeb, 0x30, + 0x14, 0x86, 0xe3, 0x7b, 0x43, 0x9b, 0x9a, 0x86, 0xc1, 0x93, 0x05, 0xc8, 0x04, 0x58, 0x32, 0x40, + 0x22, 0xc4, 0x13, 0x80, 0x10, 0x12, 0x6b, 0xd8, 0x58, 0x22, 0xa7, 0xb1, 0x5a, 0xab, 0x8d, 0x1d, + 0x25, 0x0e, 0xd0, 0x3c, 0x05, 0x8f, 0xc5, 0xd8, 0x91, 0x11, 0x25, 0xaf, 0xc1, 0x80, 0x72, 0xdc, + 0xb0, 0xf9, 0xff, 0xfe, 0xcf, 0xd6, 0xf1, 0xc1, 0xa7, 0x95, 0x78, 0xe3, 0x55, 0x5e, 0xc7, 0xb5, + 0xe1, 0x6b, 0xa9, 0x96, 0xa9, 0xcd, 0x51, 0x59, 0x69, 0xa3, 0xc9, 0x51, 0xd6, 0x8a, 0xe8, 0xf5, + 0x26, 0xda, 0x4b, 0x17, 0x3f, 0x08, 0xfb, 0xcf, 0x56, 0x4c, 0x00, 0x91, 0x13, 0x3c, 0xb3, 0x65, + 0x2a, 0x73, 0x8a, 0x02, 0x14, 0xce, 0x12, 0xcf, 0x82, 0xa7, 0x9c, 0x9c, 0xe3, 0x79, 0x59, 0xc9, + 0x56, 0xa4, 0xbc, 0xd0, 0x8d, 0x32, 0xf4, 0x1f, 0xf4, 0x87, 0xc0, 0xee, 0x00, 0x91, 0x33, 0x6c, + 0x63, 0x9a, 0x0b, 0xa5, 0x0b, 0xfa, 0x1f, 0x0c, 0x0c, 0xe8, 0x61, 0x20, 0xe4, 0x12, 0xfb, 0xe3, + 0x68, 0x56, 0x71, 0x41, 0x99, 0xef, 0xa1, 0x95, 0x8e, 0xb1, 0x97, 0x37, 0x15, 0x37, 0x52, 0x2b, + 0x7a, 0x10, 0xa0, 0xd0, 0x4f, 0xfe, 0x32, 0xa1, 0x78, 0x5a, 0xf2, 0xad, 0x6e, 0x4c, 0x4d, 0x27, + 0x50, 0x8d, 0x71, 0x98, 0xbd, 0x90, 0x2a, 0x1d, 0x5e, 0x12, 0x74, 0x1a, 0xa0, 0xd0, 0x4d, 0xbc, + 0x42, 0xaa, 0xe1, 0x83, 0x82, 0x10, 0xec, 0x6e, 0xf4, 0x62, 0x4d, 0x3d, 0xb8, 0x03, 0xe7, 0xfb, + 0xc7, 0xcf, 0x8e, 0xa1, 0x5d, 0xc7, 0xd0, 0x77, 0xc7, 0xd0, 0x47, 0xcf, 0x9c, 0x5d, 0xcf, 0x9c, + 0xaf, 0x9e, 0x39, 0x2f, 0x57, 0x4b, 0x69, 0x56, 0x4d, 0x16, 0x2d, 0x74, 0x11, 0x67, 0xad, 0xb8, + 0xe6, 0x9b, 0x72, 0xc5, 0x8d, 0xe0, 0x90, 0xe2, 0xf7, 0x78, 0xdc, 0xb2, 0xd9, 0x96, 0xa2, 0xce, + 0x26, 0xb0, 0xdd, 0xdb, 0xdf, 0x00, 0x00, 0x00, 0xff, 0xff, 0xb6, 0x69, 0xca, 0xc4, 0x7d, 0x01, + 0x00, 0x00, } func (m *StakingReward) Marshal() (dAtA []byte, err error) { @@ -204,10 +205,12 @@ func (m *StakingReward) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x1a } - if m.PrizeAmount != 0 { - i = encodeVarintStakingReward(dAtA, i, uint64(m.PrizeAmount)) + if len(m.PrizeAmount) > 0 { + i -= len(m.PrizeAmount) + copy(dAtA[i:], m.PrizeAmount) + i = encodeVarintStakingReward(dAtA, i, uint64(len(m.PrizeAmount))) i-- - dAtA[i] = 0x10 + dAtA[i] = 0x12 } if len(m.RewardId) > 0 { i -= len(m.RewardId) @@ -240,8 +243,9 @@ func (m *StakingReward) Size() (n int) { if l > 0 { n += 1 + l + sovStakingReward(uint64(l)) } - if m.PrizeAmount != 0 { - n += 1 + sovStakingReward(uint64(m.PrizeAmount)) + l = len(m.PrizeAmount) + if l > 0 { + n += 1 + l + sovStakingReward(uint64(l)) } l = len(m.PrizeDenom) if l > 0 { @@ -334,10 +338,10 @@ func (m *StakingReward) Unmarshal(dAtA []byte) error { m.RewardId = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: - if wireType != 0 { + if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field PrizeAmount", wireType) } - m.PrizeAmount = 0 + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowStakingReward @@ -347,11 +351,24 @@ func (m *StakingReward) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.PrizeAmount |= int64(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthStakingReward + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthStakingReward + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PrizeAmount = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field PrizeDenom", wireType) diff --git a/x/rewards/types/trading_reward.pb.go b/x/rewards/types/trading_reward.pb.go new file mode 100644 index 00000000..af70f821 --- /dev/null +++ b/x/rewards/types/trading_reward.pb.go @@ -0,0 +1,544 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: rewards/trading_reward.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 TradingReward struct { + RewardId string `protobuf:"bytes,1,opt,name=reward_id,json=rewardId,proto3" json:"reward_id,omitempty"` + PrizeAmount string `protobuf:"bytes,2,opt,name=prize_amount,json=prizeAmount,proto3" json:"prize_amount,omitempty"` + PrizeDenom string `protobuf:"bytes,3,opt,name=prize_denom,json=prizeDenom,proto3" json:"prize_denom,omitempty"` + Duration uint32 `protobuf:"varint,4,opt,name=duration,proto3" json:"duration,omitempty"` + MarketId string `protobuf:"bytes,5,opt,name=market_id,json=marketId,proto3" json:"market_id,omitempty"` + Slots uint32 `protobuf:"varint,6,opt,name=slots,proto3" json:"slots,omitempty"` +} + +func (m *TradingReward) Reset() { *m = TradingReward{} } +func (m *TradingReward) String() string { return proto.CompactTextString(m) } +func (*TradingReward) ProtoMessage() {} +func (*TradingReward) Descriptor() ([]byte, []int) { + return fileDescriptor_e96afcb90471b82d, []int{0} +} +func (m *TradingReward) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *TradingReward) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_TradingReward.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 *TradingReward) XXX_Merge(src proto.Message) { + xxx_messageInfo_TradingReward.Merge(m, src) +} +func (m *TradingReward) XXX_Size() int { + return m.Size() +} +func (m *TradingReward) XXX_DiscardUnknown() { + xxx_messageInfo_TradingReward.DiscardUnknown(m) +} + +var xxx_messageInfo_TradingReward proto.InternalMessageInfo + +func (m *TradingReward) GetRewardId() string { + if m != nil { + return m.RewardId + } + return "" +} + +func (m *TradingReward) GetPrizeAmount() string { + if m != nil { + return m.PrizeAmount + } + return "" +} + +func (m *TradingReward) GetPrizeDenom() string { + if m != nil { + return m.PrizeDenom + } + return "" +} + +func (m *TradingReward) GetDuration() uint32 { + if m != nil { + return m.Duration + } + return 0 +} + +func (m *TradingReward) GetMarketId() string { + if m != nil { + return m.MarketId + } + return "" +} + +func (m *TradingReward) GetSlots() uint32 { + if m != nil { + return m.Slots + } + return 0 +} + +func init() { + proto.RegisterType((*TradingReward)(nil), "bze.v1.rewards.TradingReward") +} + +func init() { proto.RegisterFile("rewards/trading_reward.proto", fileDescriptor_e96afcb90471b82d) } + +var fileDescriptor_e96afcb90471b82d = []byte{ + // 259 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x3c, 0x90, 0xbd, 0x4e, 0xc3, 0x30, + 0x14, 0x85, 0x63, 0xa0, 0x55, 0x6b, 0x28, 0x83, 0xc5, 0x60, 0x01, 0x32, 0x85, 0xa9, 0x03, 0x24, + 0x42, 0x3c, 0x01, 0x08, 0x21, 0x75, 0x8d, 0x98, 0x58, 0x22, 0x07, 0x5b, 0xad, 0x45, 0x13, 0x47, + 0xb6, 0xc3, 0x4f, 0x9e, 0x82, 0x37, 0x62, 0x65, 0xec, 0xc8, 0x88, 0x92, 0x17, 0x41, 0xb9, 0x17, + 0x65, 0xfc, 0xbe, 0x7b, 0xae, 0x8e, 0x74, 0xe8, 0xa9, 0xd3, 0x6f, 0xd2, 0x29, 0x9f, 0x04, 0x27, + 0x95, 0x29, 0x57, 0x19, 0x72, 0x5c, 0x39, 0x1b, 0x2c, 0x3b, 0xcc, 0x1b, 0x1d, 0xbf, 0x5e, 0xc7, + 0xff, 0xa1, 0x8b, 0x2f, 0x42, 0x67, 0x8f, 0x18, 0x4c, 0x41, 0xb1, 0x13, 0x3a, 0xc5, 0x63, 0x66, + 0x14, 0x27, 0x73, 0xb2, 0x98, 0xa6, 0x13, 0x14, 0x4b, 0xc5, 0xce, 0xe9, 0x41, 0xe5, 0x4c, 0xa3, + 0x33, 0x59, 0xd8, 0xba, 0x0c, 0x7c, 0x07, 0xee, 0xfb, 0xe0, 0x6e, 0x41, 0xb1, 0x33, 0x8a, 0x98, + 0x29, 0x5d, 0xda, 0x82, 0xef, 0x42, 0x82, 0x82, 0xba, 0xef, 0x0d, 0x3b, 0xa6, 0x13, 0x55, 0x3b, + 0x19, 0x8c, 0x2d, 0xf9, 0xde, 0x9c, 0x2c, 0x66, 0xe9, 0xc0, 0x7d, 0x79, 0x21, 0xdd, 0x8b, 0x0e, + 0x7d, 0xf9, 0x08, 0xcb, 0x51, 0x2c, 0x15, 0x3b, 0xa2, 0x23, 0xbf, 0xb1, 0xc1, 0xf3, 0x31, 0x7c, + 0x21, 0xdc, 0x3d, 0x7c, 0xb7, 0x82, 0x6c, 0x5b, 0x41, 0x7e, 0x5b, 0x41, 0x3e, 0x3b, 0x11, 0x6d, + 0x3b, 0x11, 0xfd, 0x74, 0x22, 0x7a, 0xba, 0x5c, 0x99, 0xb0, 0xae, 0xf3, 0xf8, 0xd9, 0x16, 0x49, + 0xde, 0xe8, 0x2b, 0xb9, 0xa9, 0xd6, 0x32, 0x68, 0x09, 0x94, 0xbc, 0x27, 0xc3, 0x50, 0x1f, 0x95, + 0xf6, 0xf9, 0x18, 0x06, 0xba, 0xf9, 0x0b, 0x00, 0x00, 0xff, 0xff, 0x98, 0xd8, 0x03, 0xb5, 0x40, + 0x01, 0x00, 0x00, +} + +func (m *TradingReward) 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 *TradingReward) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *TradingReward) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Slots != 0 { + i = encodeVarintTradingReward(dAtA, i, uint64(m.Slots)) + i-- + dAtA[i] = 0x30 + } + if len(m.MarketId) > 0 { + i -= len(m.MarketId) + copy(dAtA[i:], m.MarketId) + i = encodeVarintTradingReward(dAtA, i, uint64(len(m.MarketId))) + i-- + dAtA[i] = 0x2a + } + if m.Duration != 0 { + i = encodeVarintTradingReward(dAtA, i, uint64(m.Duration)) + i-- + dAtA[i] = 0x20 + } + if len(m.PrizeDenom) > 0 { + i -= len(m.PrizeDenom) + copy(dAtA[i:], m.PrizeDenom) + i = encodeVarintTradingReward(dAtA, i, uint64(len(m.PrizeDenom))) + i-- + dAtA[i] = 0x1a + } + if len(m.PrizeAmount) > 0 { + i -= len(m.PrizeAmount) + copy(dAtA[i:], m.PrizeAmount) + i = encodeVarintTradingReward(dAtA, i, uint64(len(m.PrizeAmount))) + i-- + dAtA[i] = 0x12 + } + if len(m.RewardId) > 0 { + i -= len(m.RewardId) + copy(dAtA[i:], m.RewardId) + i = encodeVarintTradingReward(dAtA, i, uint64(len(m.RewardId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintTradingReward(dAtA []byte, offset int, v uint64) int { + offset -= sovTradingReward(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *TradingReward) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.RewardId) + if l > 0 { + n += 1 + l + sovTradingReward(uint64(l)) + } + l = len(m.PrizeAmount) + if l > 0 { + n += 1 + l + sovTradingReward(uint64(l)) + } + l = len(m.PrizeDenom) + if l > 0 { + n += 1 + l + sovTradingReward(uint64(l)) + } + if m.Duration != 0 { + n += 1 + sovTradingReward(uint64(m.Duration)) + } + l = len(m.MarketId) + if l > 0 { + n += 1 + l + sovTradingReward(uint64(l)) + } + if m.Slots != 0 { + n += 1 + sovTradingReward(uint64(m.Slots)) + } + return n +} + +func sovTradingReward(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozTradingReward(x uint64) (n int) { + return sovTradingReward(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *TradingReward) 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 ErrIntOverflowTradingReward + } + 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: TradingReward: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: TradingReward: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RewardId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTradingReward + } + 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 ErrInvalidLengthTradingReward + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTradingReward + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.RewardId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PrizeAmount", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTradingReward + } + 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 ErrInvalidLengthTradingReward + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTradingReward + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PrizeAmount = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PrizeDenom", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTradingReward + } + 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 ErrInvalidLengthTradingReward + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTradingReward + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PrizeDenom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Duration", wireType) + } + m.Duration = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTradingReward + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Duration |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MarketId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTradingReward + } + 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 ErrInvalidLengthTradingReward + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTradingReward + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.MarketId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Slots", wireType) + } + m.Slots = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTradingReward + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Slots |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipTradingReward(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTradingReward + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipTradingReward(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, ErrIntOverflowTradingReward + } + 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, ErrIntOverflowTradingReward + } + 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, ErrIntOverflowTradingReward + } + 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, ErrInvalidLengthTradingReward + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupTradingReward + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthTradingReward + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthTradingReward = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowTradingReward = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupTradingReward = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/rewards/types/tx.pb.go b/x/rewards/types/tx.pb.go index e05e8d64..716d5abd 100644 --- a/x/rewards/types/tx.pb.go +++ b/x/rewards/types/tx.pb.go @@ -259,41 +259,176 @@ func (m *MsgUpdateStakingRewardResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgUpdateStakingRewardResponse proto.InternalMessageInfo +type MsgCreateTradingReward struct { + Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` + PrizeAmount string `protobuf:"bytes,2,opt,name=prize_amount,json=prizeAmount,proto3" json:"prize_amount,omitempty"` + PrizeDenom string `protobuf:"bytes,3,opt,name=prize_denom,json=prizeDenom,proto3" json:"prize_denom,omitempty"` + Duration string `protobuf:"bytes,4,opt,name=duration,proto3" json:"duration,omitempty"` + MarketId string `protobuf:"bytes,5,opt,name=market_id,json=marketId,proto3" json:"market_id,omitempty"` + Slots string `protobuf:"bytes,6,opt,name=slots,proto3" json:"slots,omitempty"` +} + +func (m *MsgCreateTradingReward) Reset() { *m = MsgCreateTradingReward{} } +func (m *MsgCreateTradingReward) String() string { return proto.CompactTextString(m) } +func (*MsgCreateTradingReward) ProtoMessage() {} +func (*MsgCreateTradingReward) Descriptor() ([]byte, []int) { + return fileDescriptor_4c0d543e6be8610a, []int{4} +} +func (m *MsgCreateTradingReward) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgCreateTradingReward) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgCreateTradingReward.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 *MsgCreateTradingReward) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgCreateTradingReward.Merge(m, src) +} +func (m *MsgCreateTradingReward) XXX_Size() int { + return m.Size() +} +func (m *MsgCreateTradingReward) XXX_DiscardUnknown() { + xxx_messageInfo_MsgCreateTradingReward.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgCreateTradingReward proto.InternalMessageInfo + +func (m *MsgCreateTradingReward) GetCreator() string { + if m != nil { + return m.Creator + } + return "" +} + +func (m *MsgCreateTradingReward) GetPrizeAmount() string { + if m != nil { + return m.PrizeAmount + } + return "" +} + +func (m *MsgCreateTradingReward) GetPrizeDenom() string { + if m != nil { + return m.PrizeDenom + } + return "" +} + +func (m *MsgCreateTradingReward) GetDuration() string { + if m != nil { + return m.Duration + } + return "" +} + +func (m *MsgCreateTradingReward) GetMarketId() string { + if m != nil { + return m.MarketId + } + return "" +} + +func (m *MsgCreateTradingReward) GetSlots() string { + if m != nil { + return m.Slots + } + return "" +} + +type MsgCreateTradingRewardResponse struct { + RewardId string `protobuf:"bytes,1,opt,name=reward_id,json=rewardId,proto3" json:"reward_id,omitempty"` +} + +func (m *MsgCreateTradingRewardResponse) Reset() { *m = MsgCreateTradingRewardResponse{} } +func (m *MsgCreateTradingRewardResponse) String() string { return proto.CompactTextString(m) } +func (*MsgCreateTradingRewardResponse) ProtoMessage() {} +func (*MsgCreateTradingRewardResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_4c0d543e6be8610a, []int{5} +} +func (m *MsgCreateTradingRewardResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgCreateTradingRewardResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgCreateTradingRewardResponse.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 *MsgCreateTradingRewardResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgCreateTradingRewardResponse.Merge(m, src) +} +func (m *MsgCreateTradingRewardResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgCreateTradingRewardResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgCreateTradingRewardResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgCreateTradingRewardResponse proto.InternalMessageInfo + +func (m *MsgCreateTradingRewardResponse) GetRewardId() string { + if m != nil { + return m.RewardId + } + return "" +} + func init() { proto.RegisterType((*MsgCreateStakingReward)(nil), "bze.v1.rewards.MsgCreateStakingReward") proto.RegisterType((*MsgCreateStakingRewardResponse)(nil), "bze.v1.rewards.MsgCreateStakingRewardResponse") proto.RegisterType((*MsgUpdateStakingReward)(nil), "bze.v1.rewards.MsgUpdateStakingReward") proto.RegisterType((*MsgUpdateStakingRewardResponse)(nil), "bze.v1.rewards.MsgUpdateStakingRewardResponse") + proto.RegisterType((*MsgCreateTradingReward)(nil), "bze.v1.rewards.MsgCreateTradingReward") + proto.RegisterType((*MsgCreateTradingRewardResponse)(nil), "bze.v1.rewards.MsgCreateTradingRewardResponse") } func init() { proto.RegisterFile("rewards/tx.proto", fileDescriptor_4c0d543e6be8610a) } var fileDescriptor_4c0d543e6be8610a = []byte{ - // 373 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x52, 0xcd, 0x4a, 0xf3, 0x40, - 0x14, 0x6d, 0xda, 0x7e, 0xfd, 0xb9, 0x5f, 0x15, 0x99, 0x82, 0x84, 0x0a, 0xb1, 0x46, 0x10, 0x17, - 0x9a, 0xa0, 0xae, 0x5d, 0xf8, 0x83, 0xe0, 0xa2, 0x9b, 0x8a, 0x1b, 0x37, 0x61, 0xd2, 0x0c, 0x69, - 0x68, 0x93, 0x09, 0x99, 0xa9, 0xd6, 0x3e, 0x85, 0x8f, 0xe5, 0xb2, 0x4b, 0x97, 0xd2, 0x6c, 0x7c, - 0x0c, 0xc9, 0x4d, 0x5a, 0x08, 0x0c, 0xa2, 0xbb, 0xb9, 0xe7, 0x1c, 0xee, 0x99, 0x73, 0x66, 0x60, - 0x27, 0x61, 0x2f, 0x34, 0xf1, 0x84, 0x2d, 0xe7, 0x56, 0x9c, 0x70, 0xc9, 0xc9, 0xb6, 0xbb, 0x60, - 0xd6, 0xf3, 0x99, 0x55, 0x10, 0xe6, 0x97, 0x06, 0xbb, 0x03, 0xe1, 0xdf, 0x24, 0x8c, 0x4a, 0xf6, - 0x20, 0xe9, 0x24, 0x88, 0xfc, 0x21, 0x72, 0x44, 0x87, 0xe6, 0x28, 0x83, 0x79, 0xa2, 0x6b, 0x7d, - 0xed, 0xb8, 0x3d, 0x5c, 0x8f, 0xe4, 0x00, 0x3a, 0x71, 0x12, 0x2c, 0x98, 0x43, 0x43, 0x3e, 0x8b, - 0xa4, 0x5e, 0x45, 0xfa, 0x3f, 0x62, 0x57, 0x08, 0x91, 0x7d, 0xc8, 0x47, 0xc7, 0x63, 0x11, 0x0f, - 0xf5, 0x1a, 0x2a, 0x00, 0xa1, 0xdb, 0x0c, 0x21, 0x87, 0xb0, 0x25, 0x72, 0xbb, 0x42, 0x52, 0x47, - 0x49, 0xa7, 0x00, 0x73, 0x51, 0x0f, 0x5a, 0xde, 0x2c, 0xa1, 0x32, 0xe0, 0x91, 0xfe, 0x0f, 0xf9, - 0xcd, 0x4c, 0xf6, 0xa0, 0x1d, 0x06, 0x91, 0x93, 0xe9, 0x99, 0xde, 0xc8, 0xc9, 0x30, 0x88, 0xb2, - 0x0c, 0x8c, 0x10, 0xa8, 0x4f, 0xf9, 0x68, 0xa2, 0x37, 0x11, 0xc7, 0xb3, 0x79, 0x09, 0x86, 0x3a, - 0xe9, 0x90, 0x89, 0x98, 0x47, 0x82, 0x65, 0x2b, 0xf3, 0x5e, 0x9c, 0xc0, 0x2b, 0x32, 0xb7, 0x72, - 0xe0, 0xde, 0x33, 0x27, 0x58, 0xd4, 0x63, 0xec, 0xfd, 0xa1, 0xa8, 0xd2, 0xc2, 0x6a, 0x79, 0x61, - 0x29, 0x5c, 0xad, 0x1c, 0xce, 0xec, 0xe3, 0x5d, 0x15, 0x66, 0xeb, 0xbb, 0x9e, 0xa7, 0x1a, 0xd4, - 0x06, 0xc2, 0x27, 0x21, 0x74, 0x55, 0x8f, 0x77, 0x64, 0x95, 0x1f, 0xda, 0x52, 0x47, 0xef, 0x59, - 0xbf, 0xd3, 0x6d, 0x2a, 0x0a, 0xa1, 0xab, 0xaa, 0x40, 0x65, 0xa7, 0xd0, 0x29, 0xed, 0x7e, 0x48, - 0x79, 0x7d, 0xf7, 0xbe, 0x32, 0xb4, 0xe5, 0xca, 0xd0, 0x3e, 0x57, 0x86, 0xf6, 0x96, 0x1a, 0x95, - 0x65, 0x6a, 0x54, 0x3e, 0x52, 0xa3, 0xf2, 0x74, 0xe2, 0x07, 0x72, 0x3c, 0x73, 0xad, 0x11, 0x0f, - 0x6d, 0x77, 0xc1, 0x4e, 0xe9, 0x34, 0x1e, 0x53, 0xc9, 0x28, 0x4e, 0xf6, 0xdc, 0xde, 0xfc, 0xfc, - 0xd7, 0x98, 0x09, 0xb7, 0x81, 0xbf, 0xff, 0xe2, 0x3b, 0x00, 0x00, 0xff, 0xff, 0x2e, 0xc5, 0x07, - 0x37, 0x11, 0x03, 0x00, 0x00, + // 449 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x54, 0xbd, 0xce, 0xd3, 0x30, + 0x14, 0x6d, 0xda, 0x7e, 0x3f, 0x35, 0x05, 0x21, 0x17, 0xa1, 0xa8, 0xa0, 0x50, 0x82, 0x84, 0x18, + 0x20, 0x11, 0x30, 0x33, 0xf0, 0x23, 0xa4, 0x0e, 0x5d, 0x0a, 0x2c, 0x2c, 0x91, 0x53, 0x5b, 0xa9, + 0x95, 0xc6, 0x8e, 0x6c, 0x17, 0x4a, 0x9f, 0x82, 0x97, 0x42, 0x62, 0xac, 0x98, 0x18, 0x51, 0xbb, + 0xf0, 0x18, 0x28, 0x76, 0x1a, 0x6a, 0xc9, 0x54, 0x65, 0xf9, 0xb6, 0x9c, 0x73, 0x8f, 0x7c, 0xef, + 0xb9, 0xc7, 0x31, 0xb8, 0x29, 0xc8, 0x67, 0x24, 0xb0, 0x8c, 0xd5, 0x2a, 0x2a, 0x05, 0x57, 0x1c, + 0xde, 0x48, 0xd7, 0x24, 0xfa, 0xf4, 0x34, 0xaa, 0x0b, 0xc3, 0xbb, 0x8d, 0x42, 0x20, 0x4c, 0x59, + 0x96, 0x18, 0x6c, 0xd4, 0xe1, 0x6f, 0x0f, 0xdc, 0x9e, 0xc8, 0xec, 0xb5, 0x20, 0x48, 0x91, 0x77, + 0x0a, 0xe5, 0x94, 0x65, 0x53, 0x2d, 0x80, 0x3e, 0xb8, 0x98, 0x55, 0x34, 0x17, 0xbe, 0x37, 0xf2, + 0x1e, 0xf5, 0xa6, 0x7b, 0x08, 0xef, 0x83, 0x7e, 0x29, 0xe8, 0x9a, 0x24, 0xa8, 0xe0, 0x4b, 0xa6, + 0xfc, 0xb6, 0x2e, 0x5f, 0xd3, 0xdc, 0x4b, 0x4d, 0xc1, 0x7b, 0xc0, 0xc0, 0x04, 0x13, 0xc6, 0x0b, + 0xbf, 0xa3, 0x15, 0x40, 0x53, 0x6f, 0x2a, 0x06, 0x3e, 0x00, 0xd7, 0xa5, 0x69, 0x57, 0x4b, 0xba, + 0x5a, 0xd2, 0xaf, 0x49, 0x23, 0x1a, 0x82, 0x4b, 0xbc, 0x14, 0x48, 0x51, 0xce, 0xfc, 0x33, 0x5d, + 0x6f, 0x30, 0xbc, 0x03, 0x7a, 0x05, 0x65, 0x49, 0xa5, 0x27, 0xfe, 0xb9, 0x29, 0x16, 0x94, 0x55, + 0x1e, 0x08, 0x84, 0xa0, 0xbb, 0xe0, 0xb3, 0xdc, 0xbf, 0xd0, 0xbc, 0xfe, 0x0e, 0x5f, 0x80, 0xc0, + 0xed, 0x74, 0x4a, 0x64, 0xc9, 0x99, 0x24, 0xd5, 0x91, 0x66, 0x39, 0x09, 0xc5, 0xb5, 0xe7, 0x4b, + 0x43, 0x8c, 0x71, 0x98, 0xeb, 0x45, 0x7d, 0x28, 0xf1, 0x7f, 0x2c, 0xca, 0x3a, 0xb0, 0x6d, 0x1f, + 0x68, 0x99, 0xeb, 0xd8, 0xe6, 0xc2, 0x91, 0x9e, 0xd5, 0xd1, 0x6c, 0x3f, 0x6b, 0xf8, 0xed, 0x30, + 0xb8, 0xf7, 0x26, 0xda, 0x2b, 0x09, 0xee, 0x70, 0xec, 0xae, 0x23, 0x13, 0x24, 0x72, 0xa2, 0x2a, + 0xbf, 0x75, 0x60, 0x86, 0x18, 0x63, 0x78, 0x0b, 0x9c, 0xc9, 0x05, 0x57, 0xb2, 0x0e, 0xcb, 0x00, + 0x2b, 0x15, 0xcb, 0xc6, 0x49, 0xa9, 0x3c, 0xfb, 0xd1, 0x06, 0x9d, 0x89, 0xcc, 0x60, 0x01, 0x06, + 0xae, 0x3b, 0xfc, 0x30, 0xb2, 0xff, 0x86, 0xc8, 0x7d, 0x03, 0x86, 0xd1, 0x69, 0xba, 0x66, 0xa6, + 0x02, 0x0c, 0x5c, 0x37, 0xc1, 0xd5, 0xce, 0xa1, 0x73, 0xb6, 0x3b, 0x12, 0xf6, 0x5f, 0x77, 0x76, + 0xd0, 0xff, 0x76, 0x67, 0xe9, 0x8e, 0xb8, 0x73, 0x6e, 0xfc, 0xd5, 0xdb, 0xef, 0xdb, 0xc0, 0xdb, + 0x6c, 0x03, 0xef, 0xd7, 0x36, 0xf0, 0xbe, 0xee, 0x82, 0xd6, 0x66, 0x17, 0xb4, 0x7e, 0xee, 0x82, + 0xd6, 0xc7, 0xc7, 0x19, 0x55, 0xf3, 0x65, 0x1a, 0xcd, 0x78, 0x11, 0xa7, 0x6b, 0xf2, 0x04, 0x2d, + 0xca, 0x39, 0x52, 0x04, 0x69, 0x14, 0xaf, 0xe2, 0xe6, 0xad, 0xf9, 0x52, 0x12, 0x99, 0x9e, 0xeb, + 0x37, 0xe6, 0xf9, 0x9f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x54, 0x90, 0x77, 0x30, 0xa5, 0x04, 0x00, + 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -310,6 +445,7 @@ const _ = grpc.SupportPackageIsVersion4 type MsgClient interface { CreateStakingReward(ctx context.Context, in *MsgCreateStakingReward, opts ...grpc.CallOption) (*MsgCreateStakingRewardResponse, error) UpdateStakingReward(ctx context.Context, in *MsgUpdateStakingReward, opts ...grpc.CallOption) (*MsgUpdateStakingRewardResponse, error) + CreateTradingReward(ctx context.Context, in *MsgCreateTradingReward, opts ...grpc.CallOption) (*MsgCreateTradingRewardResponse, error) } type msgClient struct { @@ -338,10 +474,20 @@ func (c *msgClient) UpdateStakingReward(ctx context.Context, in *MsgUpdateStakin return out, nil } +func (c *msgClient) CreateTradingReward(ctx context.Context, in *MsgCreateTradingReward, opts ...grpc.CallOption) (*MsgCreateTradingRewardResponse, error) { + out := new(MsgCreateTradingRewardResponse) + err := c.cc.Invoke(ctx, "/bze.v1.rewards.Msg/CreateTradingReward", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // MsgServer is the server API for Msg service. type MsgServer interface { CreateStakingReward(context.Context, *MsgCreateStakingReward) (*MsgCreateStakingRewardResponse, error) UpdateStakingReward(context.Context, *MsgUpdateStakingReward) (*MsgUpdateStakingRewardResponse, error) + CreateTradingReward(context.Context, *MsgCreateTradingReward) (*MsgCreateTradingRewardResponse, error) } // UnimplementedMsgServer can be embedded to have forward compatible implementations. @@ -354,6 +500,9 @@ func (*UnimplementedMsgServer) CreateStakingReward(ctx context.Context, req *Msg func (*UnimplementedMsgServer) UpdateStakingReward(ctx context.Context, req *MsgUpdateStakingReward) (*MsgUpdateStakingRewardResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method UpdateStakingReward not implemented") } +func (*UnimplementedMsgServer) CreateTradingReward(ctx context.Context, req *MsgCreateTradingReward) (*MsgCreateTradingRewardResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method CreateTradingReward not implemented") +} func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) @@ -395,6 +544,24 @@ func _Msg_UpdateStakingReward_Handler(srv interface{}, ctx context.Context, dec return interceptor(ctx, in, info, handler) } +func _Msg_CreateTradingReward_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgCreateTradingReward) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).CreateTradingReward(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/bze.v1.rewards.Msg/CreateTradingReward", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).CreateTradingReward(ctx, req.(*MsgCreateTradingReward)) + } + return interceptor(ctx, in, info, handler) +} + var _Msg_serviceDesc = grpc.ServiceDesc{ ServiceName: "bze.v1.rewards.Msg", HandlerType: (*MsgServer)(nil), @@ -407,6 +574,10 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ MethodName: "UpdateStakingReward", Handler: _Msg_UpdateStakingReward_Handler, }, + { + MethodName: "CreateTradingReward", + Handler: _Msg_CreateTradingReward_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "rewards/tx.proto", @@ -581,6 +752,101 @@ func (m *MsgUpdateStakingRewardResponse) MarshalToSizedBuffer(dAtA []byte) (int, return len(dAtA) - i, nil } +func (m *MsgCreateTradingReward) 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 *MsgCreateTradingReward) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgCreateTradingReward) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Slots) > 0 { + i -= len(m.Slots) + copy(dAtA[i:], m.Slots) + i = encodeVarintTx(dAtA, i, uint64(len(m.Slots))) + i-- + dAtA[i] = 0x32 + } + if len(m.MarketId) > 0 { + i -= len(m.MarketId) + copy(dAtA[i:], m.MarketId) + i = encodeVarintTx(dAtA, i, uint64(len(m.MarketId))) + i-- + dAtA[i] = 0x2a + } + if len(m.Duration) > 0 { + i -= len(m.Duration) + copy(dAtA[i:], m.Duration) + i = encodeVarintTx(dAtA, i, uint64(len(m.Duration))) + i-- + dAtA[i] = 0x22 + } + if len(m.PrizeDenom) > 0 { + i -= len(m.PrizeDenom) + copy(dAtA[i:], m.PrizeDenom) + i = encodeVarintTx(dAtA, i, uint64(len(m.PrizeDenom))) + i-- + dAtA[i] = 0x1a + } + if len(m.PrizeAmount) > 0 { + i -= len(m.PrizeAmount) + copy(dAtA[i:], m.PrizeAmount) + i = encodeVarintTx(dAtA, i, uint64(len(m.PrizeAmount))) + i-- + dAtA[i] = 0x12 + } + if len(m.Creator) > 0 { + i -= len(m.Creator) + copy(dAtA[i:], m.Creator) + i = encodeVarintTx(dAtA, i, uint64(len(m.Creator))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgCreateTradingRewardResponse) 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 *MsgCreateTradingRewardResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgCreateTradingRewardResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.RewardId) > 0 { + i -= len(m.RewardId) + copy(dAtA[i:], m.RewardId) + i = encodeVarintTx(dAtA, i, uint64(len(m.RewardId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func encodeVarintTx(dAtA []byte, offset int, v uint64) int { offset -= sovTx(v) base := offset @@ -672,6 +938,52 @@ func (m *MsgUpdateStakingRewardResponse) Size() (n int) { return n } +func (m *MsgCreateTradingReward) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Creator) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.PrizeAmount) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.PrizeDenom) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Duration) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.MarketId) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Slots) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgCreateTradingRewardResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.RewardId) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + func sovTx(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -1230,6 +1542,330 @@ func (m *MsgUpdateStakingRewardResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *MsgCreateTradingReward) 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 ErrIntOverflowTx + } + 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: MsgCreateTradingReward: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgCreateTradingReward: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Creator", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Creator = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PrizeAmount", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PrizeAmount = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PrizeDenom", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PrizeDenom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Duration", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Duration = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MarketId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.MarketId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Slots", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Slots = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgCreateTradingRewardResponse) 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 ErrIntOverflowTx + } + 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: MsgCreateTradingRewardResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgCreateTradingRewardResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RewardId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.RewardId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipTx(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/tradebin/keeper/market.go b/x/tradebin/keeper/market.go index bced1e92..2e19e46b 100644 --- a/x/tradebin/keeper/market.go +++ b/x/tradebin/keeper/market.go @@ -129,3 +129,9 @@ func (k Keeper) GetAllAssetMarketAliases(ctx sdk.Context, asset string) (list [] return } + +func (k Keeper) MarketExists(ctx sdk.Context, marketId string) bool { + _, ok := k.GetMarketById(ctx, marketId) + + return ok +} From bd0295aec4658e7ec152ac260d8f6bf7df5826e3 Mon Sep 17 00:00:00 2001 From: faneaatiku Date: Fri, 15 Mar 2024 22:30:07 +0200 Subject: [PATCH 07/35] updated simapp --- testutil/simapp/app.go | 27 +++++++++++++++++++++++++-- x/rewards/keeper/keeper_test.go | 1 + 2 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 x/rewards/keeper/keeper_test.go diff --git a/testutil/simapp/app.go b/testutil/simapp/app.go index 55caf10d..67722f7b 100644 --- a/testutil/simapp/app.go +++ b/testutil/simapp/app.go @@ -7,6 +7,9 @@ import ( "github.com/bze-alphateam/bze/x/epochs" epochskeeper "github.com/bze-alphateam/bze/x/epochs/keeper" epochstypes "github.com/bze-alphateam/bze/x/epochs/types" + "github.com/bze-alphateam/bze/x/rewards" + rewardskeeper "github.com/bze-alphateam/bze/x/rewards/keeper" + rewardstypes "github.com/bze-alphateam/bze/x/rewards/types" "github.com/bze-alphateam/bze/x/tradebin" tradebinkeeper "github.com/bze-alphateam/bze/x/tradebin/keeper" tradebintypes "github.com/bze-alphateam/bze/x/tradebin/types" @@ -179,6 +182,7 @@ var ( tokenfactory.AppModuleBasic{}, tradebin.AppModuleBasic{}, epochs.AppModuleBasic{}, + rewards.AppModuleBasic{}, // this line is used by starport scaffolding # stargate/app/moduleBasic ) @@ -196,6 +200,8 @@ var ( burnermoduletypes.ModuleName: {authtypes.Burner}, tokenfactorytypes.ModuleName: {authtypes.Minter, authtypes.Burner}, tradebintypes.ModuleName: nil, + epochstypes.ModuleName: nil, + rewardstypes.ModuleName: nil, // this line is used by starport scaffolding # stargate/app/maccPerms } @@ -264,6 +270,7 @@ type SimApp struct { TokenFactoryKeeper tokenfactorykeeper.Keeper TradebinKeeper tradebinkeeper.Keeper EpochsKeeper epochskeeper.Keeper + RewardsKeeper rewardskeeper.Keeper // this line is used by starport scaffolding # stargate/app/keeperDeclaration // the module manager @@ -314,6 +321,7 @@ func New( tokenfactorytypes.StoreKey, tradebintypes.StoreKey, epochstypes.StoreKey, + rewardstypes.StoreKey, // this line is used by starport scaffolding # stargate/app/storeKey ) tkeys := sdk.NewTransientStoreKeys(paramstypes.TStoreKey) @@ -460,13 +468,23 @@ func New( nil, //no hooks registered ) + app.RewardsKeeper = *rewardskeeper.NewKeeper( + appCodec, + keys[rewardstypes.StoreKey], + keys[rewardstypes.MemStoreKey], + app.GetSubspace(rewardstypes.ModuleName), + app.BankKeeper, + app.DistrKeeper, + app.TradebinKeeper, + ) + scavengeModule := scavengemodule.NewAppModule(appCodec, app.ScavengeKeeper) cointrunkModule := cointrunkmodule.NewAppModule(appCodec, app.CointrunkKeeper, app.AccountKeeper, app.BankKeeper, app.DistrKeeper) burnerModule := burnermodule.NewAppModule(appCodec, app.BurnerKeeper, app.AccountKeeper, app.BankKeeper) tokenfactoryModule := tokenfactory.NewAppModule(appCodec, app.TokenFactoryKeeper, app.AccountKeeper, app.BankKeeper) tradebinModule := tradebin.NewAppModule(appCodec, app.TradebinKeeper, app.BankKeeper) epochsModule := epochs.NewAppModule(appCodec, app.EpochsKeeper) - + rewardsModule := rewards.NewAppModule(appCodec, app.RewardsKeeper, app.AccountKeeper, app.BankKeeper) // this line is used by starport scaffolding # stargate/app/keeperDefinition // register the proposal types @@ -528,6 +546,7 @@ func New( tokenfactoryModule, tradebinModule, epochsModule, + rewardsModule, // this line is used by starport scaffolding # stargate/app/appModule ) @@ -560,6 +579,7 @@ func New( tokenfactorytypes.ModuleName, tradebintypes.ModuleName, epochstypes.ModuleName, + rewardstypes.ModuleName, ) app.mm.SetOrderEndBlockers( @@ -587,6 +607,7 @@ func New( tokenfactorytypes.ModuleName, tradebintypes.ModuleName, epochstypes.ModuleName, + rewardstypes.ModuleName, ) // NOTE: The genutils module must occur after staking so that pools are @@ -619,6 +640,7 @@ func New( tokenfactorytypes.ModuleName, tradebintypes.ModuleName, epochstypes.ModuleName, + rewardstypes.ModuleName, // this line is used by starport scaffolding # stargate/app/initGenesis ) @@ -692,7 +714,7 @@ func (app *SimApp) setupUpgradeHandlers() { if upgradeInfo.Name == v700.UpgradeName { storeUpgrades := storetypes.StoreUpgrades{ - Added: []string{tokenfactorytypes.StoreKey, tradebintypes.StoreKey, epochstypes.StoreKey}, + Added: []string{tokenfactorytypes.StoreKey, tradebintypes.StoreKey, epochstypes.StoreKey, rewardstypes.StoreKey}, } // configure store loader that checks if version == upgradeHeight and applies store upgrades @@ -847,6 +869,7 @@ func initParamsKeeper(appCodec codec.BinaryCodec, legacyAmino *codec.LegacyAmino paramsKeeper.Subspace(burnermoduletypes.ModuleName) paramsKeeper.Subspace(tokenfactorytypes.ModuleName) paramsKeeper.Subspace(tradebintypes.ModuleName) + paramsKeeper.Subspace(rewardstypes.ModuleName) // this line is used by starport scaffolding # stargate/app/paramSubspace return paramsKeeper diff --git a/x/rewards/keeper/keeper_test.go b/x/rewards/keeper/keeper_test.go new file mode 100644 index 00000000..b55569d4 --- /dev/null +++ b/x/rewards/keeper/keeper_test.go @@ -0,0 +1 @@ +package keeper From cc533ea513a0e01d2455431d9dfa3d1f37b66055 Mon Sep 17 00:00:00 2001 From: faneaatiku Date: Sat, 16 Mar 2024 23:30:54 +0200 Subject: [PATCH 08/35] added msg server staking reward test suite --- .../keeper/grpc_query_staking_reward_test.go | 128 ----- x/rewards/keeper/keeper_test.go | 39 +- .../keeper/msg_server_staking_reward_test.go | 490 +++++++++++++----- .../keeper/msg_server_trading_reward_test.go | 153 ------ x/rewards/types/messages_staking_reward.go | 4 +- 5 files changed, 395 insertions(+), 419 deletions(-) diff --git a/x/rewards/keeper/grpc_query_staking_reward_test.go b/x/rewards/keeper/grpc_query_staking_reward_test.go index d8488735..94292649 100644 --- a/x/rewards/keeper/grpc_query_staking_reward_test.go +++ b/x/rewards/keeper/grpc_query_staking_reward_test.go @@ -1,129 +1 @@ package keeper_test - -import ( - "strconv" - "testing" - - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/query" - "github.com/stretchr/testify/require" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/status" - - "github.com/bze-alphateam/bze/x/rewards/types" - "github.com/bze-alphateam/bze/testutil/nullify" - keepertest "github.com/bze-alphateam/bze/testutil/keeper" -) - -// Prevent strconv unused error -var _ = strconv.IntSize - -func TestStakingRewardQuerySingle(t *testing.T) { - keeper, ctx := keepertest.RewardsKeeper(t) - wctx := sdk.WrapSDKContext(ctx) - msgs := createNStakingReward(keeper, ctx, 2) - for _, tc := range []struct { - desc string - request *types.QueryGetStakingRewardRequest - response *types.QueryGetStakingRewardResponse - err error - }{ - { - desc: "First", - request: &types.QueryGetStakingRewardRequest{ - RewardId: msgs[0].RewardId, - - }, - response: &types.QueryGetStakingRewardResponse{StakingReward: msgs[0]}, - }, - { - desc: "Second", - request: &types.QueryGetStakingRewardRequest{ - RewardId: msgs[1].RewardId, - - }, - response: &types.QueryGetStakingRewardResponse{StakingReward: msgs[1]}, - }, - { - desc: "KeyNotFound", - request: &types.QueryGetStakingRewardRequest{ - RewardId:strconv.Itoa(100000), - - }, - err: status.Error(codes.NotFound, "not found"), - }, - { - desc: "InvalidRequest", - err: status.Error(codes.InvalidArgument, "invalid request"), - }, - } { - t.Run(tc.desc, func(t *testing.T) { - response, err := keeper.StakingReward(wctx, tc.request) - if tc.err != nil { - require.ErrorIs(t, err, tc.err) - } else { - require.NoError(t, err) - require.Equal(t, - nullify.Fill(tc.response), - nullify.Fill(response), - ) - } - }) - } -} - -func TestStakingRewardQueryPaginated(t *testing.T) { - keeper, ctx := keepertest.RewardsKeeper(t) - wctx := sdk.WrapSDKContext(ctx) - msgs := createNStakingReward(keeper, ctx, 5) - - request := func(next []byte, offset, limit uint64, total bool) *types.QueryAllStakingRewardRequest { - return &types.QueryAllStakingRewardRequest{ - Pagination: &query.PageRequest{ - Key: next, - Offset: offset, - Limit: limit, - CountTotal: total, - }, - } - } - t.Run("ByOffset", func(t *testing.T) { - step := 2 - for i := 0; i < len(msgs); i += step { - resp, err := keeper.StakingRewardAll(wctx, request(nil, uint64(i), uint64(step), false)) - require.NoError(t, err) - require.LessOrEqual(t, len(resp.StakingReward), step) - require.Subset(t, - nullify.Fill(msgs), - nullify.Fill(resp.StakingReward), - ) - } - }) - t.Run("ByKey", func(t *testing.T) { - step := 2 - var next []byte - for i := 0; i < len(msgs); i += step { - resp, err := keeper.StakingRewardAll(wctx, request(next, 0, uint64(step), false)) - require.NoError(t, err) - require.LessOrEqual(t, len(resp.StakingReward), step) - require.Subset(t, - nullify.Fill(msgs), - nullify.Fill(resp.StakingReward), - ) - next = resp.Pagination.NextKey - } - }) - t.Run("Total", func(t *testing.T) { - resp, err := keeper.StakingRewardAll(wctx, request(nil, 0, 0, true)) - require.NoError(t, err) - require.Equal(t, len(msgs), int(resp.Pagination.Total)) - require.ElementsMatch(t, - nullify.Fill(msgs), - nullify.Fill(resp.StakingReward), - ) - }) - t.Run("InvalidRequest", func(t *testing.T) { - _, err := keeper.StakingRewardAll(wctx, nil) - require.ErrorIs(t, err, status.Error(codes.InvalidArgument, "invalid request")) - }) -} diff --git a/x/rewards/keeper/keeper_test.go b/x/rewards/keeper/keeper_test.go index b55569d4..91eebd2b 100644 --- a/x/rewards/keeper/keeper_test.go +++ b/x/rewards/keeper/keeper_test.go @@ -1 +1,38 @@ -package keeper +package keeper_test + +import ( + "github.com/bze-alphateam/bze/testutil/simapp" + "github.com/bze-alphateam/bze/x/rewards/keeper" + "github.com/bze-alphateam/bze/x/rewards/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/suite" + tmproto "github.com/tendermint/tendermint/proto/tendermint/types" + "testing" + "time" +) + +const someRandomAddress = "bze1m33n82r5x3eyjmjtwjkl82zzdlrnv8pevd8u9r" + +type IntegrationTestSuite struct { + suite.Suite + + app *simapp.SimApp + ctx sdk.Context + k *keeper.Keeper + msgServer types.MsgServer +} + +func (suite *IntegrationTestSuite) SetupTest() { + app := simapp.Setup(false, true) + ctx := app.BaseApp.NewContext(false, tmproto.Header{Time: time.Now()}) + + suite.app = app + suite.ctx = ctx + + suite.k = &app.RewardsKeeper + suite.msgServer = keeper.NewMsgServerImpl(app.RewardsKeeper) +} + +func TestKeeperSuite(t *testing.T) { + suite.Run(t, new(IntegrationTestSuite)) +} diff --git a/x/rewards/keeper/msg_server_staking_reward_test.go b/x/rewards/keeper/msg_server_staking_reward_test.go index a6bf514c..25de119a 100644 --- a/x/rewards/keeper/msg_server_staking_reward_test.go +++ b/x/rewards/keeper/msg_server_staking_reward_test.go @@ -1,154 +1,374 @@ package keeper_test import ( - "strconv" - "testing" - + "github.com/bze-alphateam/bze/testutil/simapp" + "github.com/bze-alphateam/bze/x/rewards/types" sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/stretchr/testify/require" - - keepertest "github.com/bze-alphateam/bze/testutil/keeper" - "github.com/bze-alphateam/bze/x/rewards/keeper" - "github.com/bze-alphateam/bze/x/rewards/types" ) -// Prevent strconv unused error -var _ = strconv.IntSize - -func TestStakingRewardMsgServerCreate(t *testing.T) { - k, ctx := keepertest.RewardsKeeper(t) - srv := keeper.NewMsgServerImpl(*k) - wctx := sdk.WrapSDKContext(ctx) - creator := "A" - for i := 0; i < 5; i++ { - expected := &types.MsgCreateStakingReward{Creator: creator, - RewardId: strconv.Itoa(i), - - } - _, err := srv.CreateStakingReward(wctx, expected) - require.NoError(t, err) - rst, found := k.GetStakingReward(ctx, - expected.RewardId, - - ) - require.True(t, found) - require.Equal(t, expected.Creator, rst.Creator) - } +func (suite *IntegrationTestSuite) TestCreateStakingReward_InvalidRequest() { + goCtx := sdk.WrapSDKContext(suite.ctx) + + _, err := suite.msgServer.CreateStakingReward(goCtx, nil) + suite.Require().NotNil(err) +} + +func (suite *IntegrationTestSuite) TestUpdateStakingReward_InvalidRequest() { + goCtx := sdk.WrapSDKContext(suite.ctx) + + _, err := suite.msgServer.UpdateStakingReward(goCtx, nil) + suite.Require().NotNil(err) } -func TestStakingRewardMsgServerUpdate(t *testing.T) { - creator := "A" +func (suite *IntegrationTestSuite) TestCreateStakingReward_InvalidCreator() { + goCtx := sdk.WrapSDKContext(suite.ctx) + + req := &types.MsgCreateStakingReward{Creator: ""} + + _, err := suite.msgServer.CreateStakingReward(goCtx, req) + suite.Require().NotNil(err) +} + +func (suite *IntegrationTestSuite) TestUpdateStakingReward_InvalidCreator() { + goCtx := sdk.WrapSDKContext(suite.ctx) + + req := &types.MsgUpdateStakingReward{Creator: ""} + + _, err := suite.msgServer.UpdateStakingReward(goCtx, req) + suite.Require().NotNil(err) +} - for _, tc := range []struct { - desc string - request *types.MsgUpdateStakingReward - err error +func (suite *IntegrationTestSuite) TestCreateStakingReward_InvalidStakingReward() { + goCtx := sdk.WrapSDKContext(suite.ctx) + + tests := []struct { + name string + msg types.MsgCreateStakingReward }{ { - desc: "Completed", - request: &types.MsgUpdateStakingReward{Creator: creator, - RewardId: strconv.Itoa(0), - - }, - }, - { - desc: "Unauthorized", - request: &types.MsgUpdateStakingReward{Creator: "B", - RewardId: strconv.Itoa(0), - - }, - err: sdkerrors.ErrUnauthorized, - }, - { - desc: "KeyNotFound", - request: &types.MsgUpdateStakingReward{Creator: creator, - RewardId: strconv.Itoa(100000), - - }, - err: sdkerrors.ErrKeyNotFound, - }, - } { - t.Run(tc.desc, func(t *testing.T) { - k, ctx := keepertest.RewardsKeeper(t) - srv := keeper.NewMsgServerImpl(*k) - wctx := sdk.WrapSDKContext(ctx) - expected := &types.MsgCreateStakingReward{Creator: creator, - RewardId: strconv.Itoa(0), - - } - _, err := srv.CreateStakingReward(wctx, expected) - require.NoError(t, err) - - _, err = srv.UpdateStakingReward(wctx, tc.request) - if tc.err != nil { - require.ErrorIs(t, err, tc.err) - } else { - require.NoError(t, err) - rst, found := k.GetStakingReward(ctx, - expected.RewardId, - - ) - require.True(t, found) - require.Equal(t, expected.Creator, rst.Creator) - } - }) + name: "empty prize amount", + msg: types.MsgCreateStakingReward{ + Creator: someRandomAddress, + PrizeAmount: "", + }, + }, + { + name: "zero prize amount", + msg: types.MsgCreateStakingReward{ + Creator: someRandomAddress, + PrizeAmount: "0", + }, + }, + { + name: "negative prize amount", + msg: types.MsgCreateStakingReward{ + Creator: someRandomAddress, + PrizeAmount: "-10", + }, + }, + { + name: "empty prize denom", + msg: types.MsgCreateStakingReward{ + Creator: someRandomAddress, + PrizeAmount: "10", + PrizeDenom: "", + }, + }, + { + name: "empty staking denom", + msg: types.MsgCreateStakingReward{ + Creator: someRandomAddress, + PrizeAmount: "10", + PrizeDenom: "ubze", + StakingDenom: "", + }, + }, + { + name: "invalid min stake", + msg: types.MsgCreateStakingReward{ + Creator: someRandomAddress, + PrizeAmount: "10", + PrizeDenom: "ubze", + StakingDenom: "ubze", + MinStake: "", + }, + }, + { + name: "negative min stake", + msg: types.MsgCreateStakingReward{ + Creator: someRandomAddress, + PrizeAmount: "10", + PrizeDenom: "ubze", + StakingDenom: "ubze", + MinStake: "-10", + }, + }, + { + name: "invalid duration", + msg: types.MsgCreateStakingReward{ + Creator: someRandomAddress, + PrizeAmount: "10", + PrizeDenom: "ubze", + StakingDenom: "ubze", + MinStake: "10", + Duration: "", + }, + }, + { + name: "duration too low", + msg: types.MsgCreateStakingReward{ + Creator: someRandomAddress, + PrizeAmount: "10", + PrizeDenom: "ubze", + StakingDenom: "ubze", + MinStake: "10", + Duration: "0", + }, + }, + { + name: "duration too high", + msg: types.MsgCreateStakingReward{ + Creator: someRandomAddress, + PrizeAmount: "10", + PrizeDenom: "ubze", + StakingDenom: "ubze", + MinStake: "10", + Duration: "3213132131231", + }, + }, + { + name: "invalid lock", + msg: types.MsgCreateStakingReward{ + Creator: someRandomAddress, + PrizeAmount: "10", + PrizeDenom: "ubze", + StakingDenom: "ubze", + MinStake: "10", + Duration: "100", + Lock: "asd", + }, + }, + { + name: "negative lock", + msg: types.MsgCreateStakingReward{ + Creator: someRandomAddress, + PrizeAmount: "10", + PrizeDenom: "ubze", + StakingDenom: "ubze", + MinStake: "10", + Duration: "100", + Lock: "-33", + }, + }, + { + name: "lock too high", + msg: types.MsgCreateStakingReward{ + Creator: someRandomAddress, + PrizeAmount: "10", + PrizeDenom: "ubze", + StakingDenom: "ubze", + MinStake: "10", + Duration: "100", + Lock: "7899", + }, + }, + } + for _, tt := range tests { + _, err := suite.msgServer.CreateStakingReward(goCtx, &tt.msg) + suite.Require().NotNil(err) } } -func TestStakingRewardMsgServerDelete(t *testing.T) { - creator := "A" +func (suite *IntegrationTestSuite) TestUpdateStakingReward_InvalidStakingReward() { + goCtx := sdk.WrapSDKContext(suite.ctx) - for _, tc := range []struct { - desc string - request *types.MsgDeleteStakingReward - err error + tests := []struct { + name string + msg types.MsgUpdateStakingReward + addStakingReward bool }{ { - desc: "Completed", - request: &types.MsgDeleteStakingReward{Creator: creator, - RewardId: strconv.Itoa(0), - - }, - }, - { - desc: "Unauthorized", - request: &types.MsgDeleteStakingReward{Creator: "B", - RewardId: strconv.Itoa(0), - - }, - err: sdkerrors.ErrUnauthorized, - }, - { - desc: "KeyNotFound", - request: &types.MsgDeleteStakingReward{Creator: creator, - RewardId: strconv.Itoa(100000), - - }, - err: sdkerrors.ErrKeyNotFound, - }, - } { - t.Run(tc.desc, func(t *testing.T) { - k, ctx := keepertest.RewardsKeeper(t) - srv := keeper.NewMsgServerImpl(*k) - wctx := sdk.WrapSDKContext(ctx) - - _, err := srv.CreateStakingReward(wctx, &types.MsgCreateStakingReward{Creator: creator, - RewardId: strconv.Itoa(0), - - }) - require.NoError(t, err) - _, err = srv.DeleteStakingReward(wctx, tc.request) - if tc.err != nil { - require.ErrorIs(t, err, tc.err) - } else { - require.NoError(t, err) - _, found := k.GetStakingReward(ctx, - tc.request.RewardId, - - ) - require.False(t, found) - } - }) + name: "invalid duration", + msg: types.MsgUpdateStakingReward{ + Creator: someRandomAddress, + Duration: "", + }, + }, + { + name: "zero duration", + msg: types.MsgUpdateStakingReward{ + Creator: someRandomAddress, + Duration: "0", + }, + }, + { + name: "negative duration", + msg: types.MsgUpdateStakingReward{ + Creator: someRandomAddress, + Duration: "-220", + }, + }, + { + name: "missing staking reward", + msg: types.MsgUpdateStakingReward{ + Creator: someRandomAddress, + Duration: "10", + RewardId: "notastakingrewardid", + }, + }, + { + name: "not enough balance", + msg: types.MsgUpdateStakingReward{ + Creator: someRandomAddress, + Duration: "10", + RewardId: "001", + }, + addStakingReward: true, + }, + } + stakingReward := types.StakingReward{RewardId: "001", PrizeDenom: "ubze", PrizeAmount: "10"} + suite.k.SetStakingReward(suite.ctx, stakingReward) + + for _, tt := range tests { + _, err := suite.msgServer.UpdateStakingReward(goCtx, &tt.msg) + suite.Require().NotNil(err) } } + +func (suite *IntegrationTestSuite) TestCreateStakingReward_MissingSupply() { + goCtx := sdk.WrapSDKContext(suite.ctx) + msg := types.MsgCreateStakingReward{ + Creator: someRandomAddress, + PrizeAmount: "10", + PrizeDenom: "ubze", + StakingDenom: "ubze", + MinStake: "10", + Duration: "100", + Lock: "1", + } + + _, err := suite.msgServer.CreateStakingReward(goCtx, &msg) + suite.Require().NotNil(err) +} + +func (suite *IntegrationTestSuite) TestCreateStakingReward_NotEnoughBalance() { + goCtx := sdk.WrapSDKContext(suite.ctx) + + addr1 := sdk.AccAddress("addr1_______________") + acc1 := suite.app.AccountKeeper.NewAccountWithAddress(suite.ctx, addr1) + suite.app.AccountKeeper.SetAccount(suite.ctx, acc1) + + //initial balances need to be 0 + initialUserBalances := suite.app.BankKeeper.GetAllBalances(suite.ctx, addr1) + suite.Require().True(initialUserBalances.IsZero()) + + balances := sdk.NewCoins(sdk.NewInt64Coin("ubze", 1)) + suite.Require().NoError(simapp.FundAccount(suite.app.BankKeeper, suite.ctx, addr1, balances)) + + msg := types.MsgCreateStakingReward{ + Creator: addr1.String(), + PrizeAmount: "10", + PrizeDenom: "ubze", + StakingDenom: "ubze", + MinStake: "10", + Duration: "100", + Lock: "1", + } + + _, err := suite.msgServer.CreateStakingReward(goCtx, &msg) + suite.Require().Error(err) +} + +func (suite *IntegrationTestSuite) TestCreateStakingReward_Success() { + goCtx := sdk.WrapSDKContext(suite.ctx) + + addr1 := sdk.AccAddress("addr1_______________") + acc1 := suite.app.AccountKeeper.NewAccountWithAddress(suite.ctx, addr1) + suite.app.AccountKeeper.SetAccount(suite.ctx, acc1) + + //initial balances need to be 0 + initialUserBalances := suite.app.BankKeeper.GetAllBalances(suite.ctx, addr1) + suite.Require().True(initialUserBalances.IsZero()) + + balances := sdk.NewCoins(sdk.NewInt64Coin("ubze", 20000000000)) + suite.Require().NoError(simapp.FundAccount(suite.app.BankKeeper, suite.ctx, addr1, balances)) + + msg := types.MsgCreateStakingReward{ + Creator: addr1.String(), + PrizeAmount: "10", + PrizeDenom: "ubze", + StakingDenom: "ubze", + MinStake: "10", + Duration: "100", + Lock: "1", + } + + res, err := suite.msgServer.CreateStakingReward(goCtx, &msg) + suite.Require().NoError(err) + + storeStakingReward, ok := suite.k.GetStakingReward(suite.ctx, res.RewardId) + suite.Require().True(ok) + + suite.Require().EqualValues(msg.PrizeAmount, storeStakingReward.PrizeAmount) + suite.Require().EqualValues(msg.PrizeDenom, storeStakingReward.PrizeDenom) + suite.Require().EqualValues(msg.StakingDenom, storeStakingReward.StakingDenom) + suite.Require().EqualValues(10, storeStakingReward.MinStake) + suite.Require().EqualValues(100, storeStakingReward.Duration) + suite.Require().EqualValues(1, storeStakingReward.Lock) + suite.Require().EqualValues(0, storeStakingReward.Payouts) + + expectedRemainingBalance := sdk.NewCoins(sdk.NewInt64Coin("ubze", 9999999000)) + actualRemainingBalance := suite.app.BankKeeper.GetAllBalances(suite.ctx, addr1) + suite.Require().True(actualRemainingBalance.IsEqual(expectedRemainingBalance)) +} + +func (suite *IntegrationTestSuite) TestUpdateStakingReward_Success() { + goCtx := sdk.WrapSDKContext(suite.ctx) + + addr1 := sdk.AccAddress("addr1_______________") + acc1 := suite.app.AccountKeeper.NewAccountWithAddress(suite.ctx, addr1) + suite.app.AccountKeeper.SetAccount(suite.ctx, acc1) + + //initial balances need to be 0 + initialUserBalances := suite.app.BankKeeper.GetAllBalances(suite.ctx, addr1) + suite.Require().True(initialUserBalances.IsZero()) + + balances := sdk.NewCoins(sdk.NewInt64Coin("ubze", 20000000000)) + suite.Require().NoError(simapp.FundAccount(suite.app.BankKeeper, suite.ctx, addr1, balances)) + + stakingReward := types.StakingReward{ + RewardId: "001", + PrizeAmount: "10", + PrizeDenom: "ubze", + StakingDenom: "ubze", + MinStake: 10, + Duration: 100, + Lock: 1, + } + suite.k.SetStakingReward(suite.ctx, stakingReward) + + msg := types.MsgUpdateStakingReward{ + Creator: addr1.String(), + Duration: "200", + RewardId: "001", + } + + _, err := suite.msgServer.UpdateStakingReward(goCtx, &msg) + suite.Require().NoError(err) + + storeStakingReward, ok := suite.k.GetStakingReward(suite.ctx, stakingReward.RewardId) + suite.Require().True(ok) + + //check duration was updated + suite.Require().EqualValues(uint32(300), storeStakingReward.Duration) + //check other fields were not changed + suite.Require().EqualValues(stakingReward.PrizeAmount, storeStakingReward.PrizeAmount) + suite.Require().EqualValues(stakingReward.PrizeDenom, storeStakingReward.PrizeDenom) + suite.Require().EqualValues(stakingReward.StakingDenom, storeStakingReward.StakingDenom) + suite.Require().EqualValues(stakingReward.MinStake, storeStakingReward.MinStake) + suite.Require().EqualValues(stakingReward.Lock, storeStakingReward.Lock) + + expectedRemainingBalance := sdk.NewCoins(sdk.NewInt64Coin("ubze", 19999998000)) + actualRemainingBalance := suite.app.BankKeeper.GetAllBalances(suite.ctx, addr1) + suite.Require().True(actualRemainingBalance.IsEqual(expectedRemainingBalance)) +} diff --git a/x/rewards/keeper/msg_server_trading_reward_test.go b/x/rewards/keeper/msg_server_trading_reward_test.go index 50c57f74..94292649 100644 --- a/x/rewards/keeper/msg_server_trading_reward_test.go +++ b/x/rewards/keeper/msg_server_trading_reward_test.go @@ -1,154 +1 @@ package keeper_test - -import ( - "strconv" - "testing" - - sdk "github.com/cosmos/cosmos-sdk/types" - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/stretchr/testify/require" - - keepertest "github.com/bze-alphateam/bze/testutil/keeper" - "github.com/bze-alphateam/bze/x/rewards/keeper" - "github.com/bze-alphateam/bze/x/rewards/types" -) - -// Prevent strconv unused error -var _ = strconv.IntSize - -func TestTradingRewardMsgServerCreate(t *testing.T) { - k, ctx := keepertest.RewardsKeeper(t) - srv := keeper.NewMsgServerImpl(*k) - wctx := sdk.WrapSDKContext(ctx) - creator := "A" - for i := 0; i < 5; i++ { - expected := &types.MsgCreateTradingReward{Creator: creator, - RewardId: strconv.Itoa(i), - - } - _, err := srv.CreateTradingReward(wctx, expected) - require.NoError(t, err) - rst, found := k.GetTradingReward(ctx, - expected.RewardId, - - ) - require.True(t, found) - require.Equal(t, expected.Creator, rst.Creator) - } -} - -func TestTradingRewardMsgServerUpdate(t *testing.T) { - creator := "A" - - for _, tc := range []struct { - desc string - request *types.MsgUpdateTradingReward - err error - }{ - { - desc: "Completed", - request: &types.MsgUpdateTradingReward{Creator: creator, - RewardId: strconv.Itoa(0), - - }, - }, - { - desc: "Unauthorized", - request: &types.MsgUpdateTradingReward{Creator: "B", - RewardId: strconv.Itoa(0), - - }, - err: sdkerrors.ErrUnauthorized, - }, - { - desc: "KeyNotFound", - request: &types.MsgUpdateTradingReward{Creator: creator, - RewardId: strconv.Itoa(100000), - - }, - err: sdkerrors.ErrKeyNotFound, - }, - } { - t.Run(tc.desc, func(t *testing.T) { - k, ctx := keepertest.RewardsKeeper(t) - srv := keeper.NewMsgServerImpl(*k) - wctx := sdk.WrapSDKContext(ctx) - expected := &types.MsgCreateTradingReward{Creator: creator, - RewardId: strconv.Itoa(0), - - } - _, err := srv.CreateTradingReward(wctx, expected) - require.NoError(t, err) - - _, err = srv.UpdateTradingReward(wctx, tc.request) - if tc.err != nil { - require.ErrorIs(t, err, tc.err) - } else { - require.NoError(t, err) - rst, found := k.GetTradingReward(ctx, - expected.RewardId, - - ) - require.True(t, found) - require.Equal(t, expected.Creator, rst.Creator) - } - }) - } -} - -func TestTradingRewardMsgServerDelete(t *testing.T) { - creator := "A" - - for _, tc := range []struct { - desc string - request *types.MsgDeleteTradingReward - err error - }{ - { - desc: "Completed", - request: &types.MsgDeleteTradingReward{Creator: creator, - RewardId: strconv.Itoa(0), - - }, - }, - { - desc: "Unauthorized", - request: &types.MsgDeleteTradingReward{Creator: "B", - RewardId: strconv.Itoa(0), - - }, - err: sdkerrors.ErrUnauthorized, - }, - { - desc: "KeyNotFound", - request: &types.MsgDeleteTradingReward{Creator: creator, - RewardId: strconv.Itoa(100000), - - }, - err: sdkerrors.ErrKeyNotFound, - }, - } { - t.Run(tc.desc, func(t *testing.T) { - k, ctx := keepertest.RewardsKeeper(t) - srv := keeper.NewMsgServerImpl(*k) - wctx := sdk.WrapSDKContext(ctx) - - _, err := srv.CreateTradingReward(wctx, &types.MsgCreateTradingReward{Creator: creator, - RewardId: strconv.Itoa(0), - - }) - require.NoError(t, err) - _, err = srv.DeleteTradingReward(wctx, tc.request) - if tc.err != nil { - require.ErrorIs(t, err, tc.err) - } else { - require.NoError(t, err) - _, found := k.GetTradingReward(ctx, - tc.request.RewardId, - - ) - require.False(t, found) - } - }) - } -} diff --git a/x/rewards/types/messages_staking_reward.go b/x/rewards/types/messages_staking_reward.go index 58c1e8f3..60f9575c 100644 --- a/x/rewards/types/messages_staking_reward.go +++ b/x/rewards/types/messages_staking_reward.go @@ -80,7 +80,7 @@ func (msg *MsgCreateStakingReward) ToStakingReward() (StakingReward, error) { sr.StakingDenom = msg.StakingDenom minStake, ok := sdk.NewIntFromString(msg.MinStake) - if minStake.IsNegative() { + if !ok || minStake.IsNegative() { return sr, ErrInvalidMinStake } sr.MinStake = minStake.Uint64() @@ -98,7 +98,7 @@ func (msg *MsgCreateStakingReward) ToStakingReward() (StakingReward, error) { if err != nil { return sr, sdkerrors.Wrapf(ErrInvalidLockingTime, "could not convert string to int: %s", err.Error()) } - if lockInt <= 0 || lockInt > tenYearsInDays { + if lockInt < 0 || lockInt > tenYearsInDays { return sr, ErrInvalidLockingTime } sr.Lock = uint32(lockInt) From 8efa3651fea0e45eab5fc442b4c5f2dcbe944536 Mon Sep 17 00:00:00 2001 From: faneaatiku Date: Sun, 17 Mar 2024 00:12:50 +0200 Subject: [PATCH 09/35] updated msg create and update tests --- .../keeper/msg_server_staking_reward_test.go | 55 ++-- x/rewards/keeper/msg_server_trading_reward.go | 2 +- .../keeper/msg_server_trading_reward_test.go | 261 ++++++++++++++++++ .../types/messages_trading_reward_test.go | 101 ------- 4 files changed, 296 insertions(+), 123 deletions(-) diff --git a/x/rewards/keeper/msg_server_staking_reward_test.go b/x/rewards/keeper/msg_server_staking_reward_test.go index 25de119a..c726cd3b 100644 --- a/x/rewards/keeper/msg_server_staking_reward_test.go +++ b/x/rewards/keeper/msg_server_staking_reward_test.go @@ -4,20 +4,21 @@ import ( "github.com/bze-alphateam/bze/testutil/simapp" "github.com/bze-alphateam/bze/x/rewards/types" sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) func (suite *IntegrationTestSuite) TestCreateStakingReward_InvalidRequest() { goCtx := sdk.WrapSDKContext(suite.ctx) _, err := suite.msgServer.CreateStakingReward(goCtx, nil) - suite.Require().NotNil(err) + suite.Require().ErrorIs(err, sdkerrors.ErrInvalidRequest) } func (suite *IntegrationTestSuite) TestUpdateStakingReward_InvalidRequest() { goCtx := sdk.WrapSDKContext(suite.ctx) _, err := suite.msgServer.UpdateStakingReward(goCtx, nil) - suite.Require().NotNil(err) + suite.Require().ErrorIs(err, sdkerrors.ErrInvalidRequest) } func (suite *IntegrationTestSuite) TestCreateStakingReward_InvalidCreator() { @@ -41,6 +42,10 @@ func (suite *IntegrationTestSuite) TestUpdateStakingReward_InvalidCreator() { func (suite *IntegrationTestSuite) TestCreateStakingReward_InvalidStakingReward() { goCtx := sdk.WrapSDKContext(suite.ctx) + addr1 := sdk.AccAddress("addr1_______________") + acc1 := suite.app.AccountKeeper.NewAccountWithAddress(suite.ctx, addr1) + suite.app.AccountKeeper.SetAccount(suite.ctx, acc1) + tests := []struct { name string msg types.MsgCreateStakingReward @@ -48,28 +53,28 @@ func (suite *IntegrationTestSuite) TestCreateStakingReward_InvalidStakingReward( { name: "empty prize amount", msg: types.MsgCreateStakingReward{ - Creator: someRandomAddress, + Creator: addr1.String(), PrizeAmount: "", }, }, { name: "zero prize amount", msg: types.MsgCreateStakingReward{ - Creator: someRandomAddress, + Creator: addr1.String(), PrizeAmount: "0", }, }, { name: "negative prize amount", msg: types.MsgCreateStakingReward{ - Creator: someRandomAddress, + Creator: addr1.String(), PrizeAmount: "-10", }, }, { name: "empty prize denom", msg: types.MsgCreateStakingReward{ - Creator: someRandomAddress, + Creator: addr1.String(), PrizeAmount: "10", PrizeDenom: "", }, @@ -77,7 +82,7 @@ func (suite *IntegrationTestSuite) TestCreateStakingReward_InvalidStakingReward( { name: "empty staking denom", msg: types.MsgCreateStakingReward{ - Creator: someRandomAddress, + Creator: addr1.String(), PrizeAmount: "10", PrizeDenom: "ubze", StakingDenom: "", @@ -86,7 +91,7 @@ func (suite *IntegrationTestSuite) TestCreateStakingReward_InvalidStakingReward( { name: "invalid min stake", msg: types.MsgCreateStakingReward{ - Creator: someRandomAddress, + Creator: addr1.String(), PrizeAmount: "10", PrizeDenom: "ubze", StakingDenom: "ubze", @@ -96,7 +101,7 @@ func (suite *IntegrationTestSuite) TestCreateStakingReward_InvalidStakingReward( { name: "negative min stake", msg: types.MsgCreateStakingReward{ - Creator: someRandomAddress, + Creator: addr1.String(), PrizeAmount: "10", PrizeDenom: "ubze", StakingDenom: "ubze", @@ -106,7 +111,7 @@ func (suite *IntegrationTestSuite) TestCreateStakingReward_InvalidStakingReward( { name: "invalid duration", msg: types.MsgCreateStakingReward{ - Creator: someRandomAddress, + Creator: addr1.String(), PrizeAmount: "10", PrizeDenom: "ubze", StakingDenom: "ubze", @@ -117,7 +122,7 @@ func (suite *IntegrationTestSuite) TestCreateStakingReward_InvalidStakingReward( { name: "duration too low", msg: types.MsgCreateStakingReward{ - Creator: someRandomAddress, + Creator: addr1.String(), PrizeAmount: "10", PrizeDenom: "ubze", StakingDenom: "ubze", @@ -128,7 +133,7 @@ func (suite *IntegrationTestSuite) TestCreateStakingReward_InvalidStakingReward( { name: "duration too high", msg: types.MsgCreateStakingReward{ - Creator: someRandomAddress, + Creator: addr1.String(), PrizeAmount: "10", PrizeDenom: "ubze", StakingDenom: "ubze", @@ -139,7 +144,7 @@ func (suite *IntegrationTestSuite) TestCreateStakingReward_InvalidStakingReward( { name: "invalid lock", msg: types.MsgCreateStakingReward{ - Creator: someRandomAddress, + Creator: addr1.String(), PrizeAmount: "10", PrizeDenom: "ubze", StakingDenom: "ubze", @@ -151,7 +156,7 @@ func (suite *IntegrationTestSuite) TestCreateStakingReward_InvalidStakingReward( { name: "negative lock", msg: types.MsgCreateStakingReward{ - Creator: someRandomAddress, + Creator: addr1.String(), PrizeAmount: "10", PrizeDenom: "ubze", StakingDenom: "ubze", @@ -163,7 +168,7 @@ func (suite *IntegrationTestSuite) TestCreateStakingReward_InvalidStakingReward( { name: "lock too high", msg: types.MsgCreateStakingReward{ - Creator: someRandomAddress, + Creator: addr1.String(), PrizeAmount: "10", PrizeDenom: "ubze", StakingDenom: "ubze", @@ -182,6 +187,10 @@ func (suite *IntegrationTestSuite) TestCreateStakingReward_InvalidStakingReward( func (suite *IntegrationTestSuite) TestUpdateStakingReward_InvalidStakingReward() { goCtx := sdk.WrapSDKContext(suite.ctx) + addr1 := sdk.AccAddress("addr1_______________") + acc1 := suite.app.AccountKeeper.NewAccountWithAddress(suite.ctx, addr1) + suite.app.AccountKeeper.SetAccount(suite.ctx, acc1) + tests := []struct { name string msg types.MsgUpdateStakingReward @@ -190,28 +199,28 @@ func (suite *IntegrationTestSuite) TestUpdateStakingReward_InvalidStakingReward( { name: "invalid duration", msg: types.MsgUpdateStakingReward{ - Creator: someRandomAddress, + Creator: addr1.String(), Duration: "", }, }, { name: "zero duration", msg: types.MsgUpdateStakingReward{ - Creator: someRandomAddress, + Creator: addr1.String(), Duration: "0", }, }, { name: "negative duration", msg: types.MsgUpdateStakingReward{ - Creator: someRandomAddress, + Creator: addr1.String(), Duration: "-220", }, }, { name: "missing staking reward", msg: types.MsgUpdateStakingReward{ - Creator: someRandomAddress, + Creator: addr1.String(), Duration: "10", RewardId: "notastakingrewardid", }, @@ -219,7 +228,7 @@ func (suite *IntegrationTestSuite) TestUpdateStakingReward_InvalidStakingReward( { name: "not enough balance", msg: types.MsgUpdateStakingReward{ - Creator: someRandomAddress, + Creator: addr1.String(), Duration: "10", RewardId: "001", }, @@ -237,8 +246,12 @@ func (suite *IntegrationTestSuite) TestUpdateStakingReward_InvalidStakingReward( func (suite *IntegrationTestSuite) TestCreateStakingReward_MissingSupply() { goCtx := sdk.WrapSDKContext(suite.ctx) + addr1 := sdk.AccAddress("addr1_______________") + acc1 := suite.app.AccountKeeper.NewAccountWithAddress(suite.ctx, addr1) + suite.app.AccountKeeper.SetAccount(suite.ctx, acc1) + msg := types.MsgCreateStakingReward{ - Creator: someRandomAddress, + Creator: addr1.String(), PrizeAmount: "10", PrizeDenom: "ubze", StakingDenom: "ubze", diff --git a/x/rewards/keeper/msg_server_trading_reward.go b/x/rewards/keeper/msg_server_trading_reward.go index 6fdc931b..c7b3ef05 100644 --- a/x/rewards/keeper/msg_server_trading_reward.go +++ b/x/rewards/keeper/msg_server_trading_reward.go @@ -57,7 +57,7 @@ func (k msgServer) CreateTradingReward(goCtx context.Context, msg *types.MsgCrea tradingReward, ) - return &types.MsgCreateTradingRewardResponse{}, nil + return &types.MsgCreateTradingRewardResponse{RewardId: tradingReward.RewardId}, nil } func (k msgServer) checkUserBalances(ctx sdk.Context, neededCoins sdk.Coins, address sdk.AccAddress) error { diff --git a/x/rewards/keeper/msg_server_trading_reward_test.go b/x/rewards/keeper/msg_server_trading_reward_test.go index 94292649..977f77b8 100644 --- a/x/rewards/keeper/msg_server_trading_reward_test.go +++ b/x/rewards/keeper/msg_server_trading_reward_test.go @@ -1 +1,262 @@ package keeper_test + +import ( + "github.com/bze-alphateam/bze/testutil/simapp" + "github.com/bze-alphateam/bze/x/rewards/types" + types2 "github.com/bze-alphateam/bze/x/tradebin/types" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +func (suite *IntegrationTestSuite) TestCreateTradingReward_InvalidRequest() { + goCtx := sdk.WrapSDKContext(suite.ctx) + + _, err := suite.msgServer.CreateTradingReward(goCtx, nil) + suite.Require().ErrorIs(err, sdkerrors.ErrInvalidRequest) +} + +func (suite *IntegrationTestSuite) TestCreateTradingReward_InvalidCreator() { + goCtx := sdk.WrapSDKContext(suite.ctx) + + req := &types.MsgCreateTradingReward{Creator: ""} + + _, err := suite.msgServer.CreateTradingReward(goCtx, req) + suite.Require().NotNil(err) +} + +func (suite *IntegrationTestSuite) TestCreateTradingReward_InvalidTradingReward() { + goCtx := sdk.WrapSDKContext(suite.ctx) + addr1 := sdk.AccAddress("addr1_______________") + acc1 := suite.app.AccountKeeper.NewAccountWithAddress(suite.ctx, addr1) + suite.app.AccountKeeper.SetAccount(suite.ctx, acc1) + + tests := []struct { + name string + msg types.MsgCreateTradingReward + }{ + { + name: "empty prize amount", + msg: types.MsgCreateTradingReward{ + Creator: addr1.String(), + PrizeAmount: "", + }, + }, + { + name: "zero prize amount", + msg: types.MsgCreateTradingReward{ + Creator: addr1.String(), + PrizeAmount: "0", + }, + }, + { + name: "negative prize amount", + msg: types.MsgCreateTradingReward{ + Creator: addr1.String(), + PrizeAmount: "-10", + }, + }, + { + name: "empty prize denom", + msg: types.MsgCreateTradingReward{ + Creator: addr1.String(), + PrizeAmount: "10", + PrizeDenom: "", + }, + }, + { + name: "missing market id", + msg: types.MsgCreateTradingReward{ + Creator: addr1.String(), + PrizeAmount: "10", + PrizeDenom: "ubze", + MarketId: "not_a_market_id", + }, + }, + { + name: "invalid duration", + msg: types.MsgCreateTradingReward{ + Creator: addr1.String(), + PrizeAmount: "10", + PrizeDenom: "ubze", + MarketId: "stake/ubze", + Duration: "", + }, + }, + { + name: "zero duration", + msg: types.MsgCreateTradingReward{ + Creator: addr1.String(), + PrizeAmount: "10", + PrizeDenom: "ubze", + Duration: "0", + MarketId: "stake/ubze", + }, + }, + { + name: "negative duration", + msg: types.MsgCreateTradingReward{ + Creator: addr1.String(), + PrizeAmount: "10", + PrizeDenom: "ubze", + Duration: "-11", + MarketId: "stake/ubze", + }, + }, + { + name: "duration too high", + msg: types.MsgCreateTradingReward{ + Creator: addr1.String(), + PrizeAmount: "10", + PrizeDenom: "ubze", + Duration: "3213132131231", + MarketId: "stake/ubze", + }, + }, + { + name: "invalid slots", + msg: types.MsgCreateTradingReward{ + Creator: addr1.String(), + PrizeAmount: "10", + PrizeDenom: "ubze", + Duration: "100", + MarketId: "stake/ubze", + Slots: "", + }, + }, + { + name: "zero slots", + msg: types.MsgCreateTradingReward{ + Creator: addr1.String(), + PrizeAmount: "10", + PrizeDenom: "ubze", + Duration: "100", + MarketId: "stake/ubze", + Slots: "0", + }, + }, + { + name: "negative slots", + msg: types.MsgCreateTradingReward{ + Creator: addr1.String(), + PrizeAmount: "10", + PrizeDenom: "ubze", + Duration: "100", + MarketId: "stake/ubze", + Slots: "-3", + }, + }, + { + name: "too many slots slots", + msg: types.MsgCreateTradingReward{ + Creator: addr1.String(), + PrizeAmount: "10", + PrizeDenom: "ubze", + Duration: "100", + MarketId: "stake/ubze", + Slots: "101", + }, + }, + } + + for _, tt := range tests { + _, err := suite.msgServer.CreateTradingReward(goCtx, &tt.msg) + suite.Require().NotNil(err, tt.name) + } +} + +func (suite *IntegrationTestSuite) TestCreateTradingReward_MissingSupply() { + goCtx := sdk.WrapSDKContext(suite.ctx) + addr1 := sdk.AccAddress("addr1_______________") + acc1 := suite.app.AccountKeeper.NewAccountWithAddress(suite.ctx, addr1) + suite.app.AccountKeeper.SetAccount(suite.ctx, acc1) + + msg := types.MsgCreateTradingReward{ + Creator: addr1.String(), + PrizeAmount: "10", + PrizeDenom: "ubzesd", + Duration: "100", + MarketId: "stake/ubze", + Slots: "99", + } + + _, err := suite.msgServer.CreateTradingReward(goCtx, &msg) + suite.Require().ErrorIs(err, types.ErrInvalidPrizeDenom) +} + +func (suite *IntegrationTestSuite) TestCreateTradingReward_NotEnoughBalance() { + goCtx := sdk.WrapSDKContext(suite.ctx) + + addr1 := sdk.AccAddress("addr1_______________") + acc1 := suite.app.AccountKeeper.NewAccountWithAddress(suite.ctx, addr1) + suite.app.AccountKeeper.SetAccount(suite.ctx, acc1) + + //initial balances need to be 0 + initialUserBalances := suite.app.BankKeeper.GetAllBalances(suite.ctx, addr1) + suite.Require().True(initialUserBalances.IsZero()) + + balances := sdk.NewCoins(sdk.NewInt64Coin("ubze", 1)) + suite.Require().NoError(simapp.FundAccount(suite.app.BankKeeper, suite.ctx, addr1, balances)) + //create market + suite.app.TradebinKeeper.SetMarket(suite.ctx, types2.Market{ + Base: "stake", + Quote: "ubze", + Creator: "", + }) + + msg := types.MsgCreateTradingReward{ + Creator: addr1.String(), + PrizeAmount: "10", + PrizeDenom: "ubze", + Duration: "100", + MarketId: "stake/ubze", + Slots: "100", + } + + _, err := suite.msgServer.CreateTradingReward(goCtx, &msg) + suite.Require().Error(err) +} + +func (suite *IntegrationTestSuite) TestCreateTradingReward_Success() { + goCtx := sdk.WrapSDKContext(suite.ctx) + + addr1 := sdk.AccAddress("addr1_______________") + acc1 := suite.app.AccountKeeper.NewAccountWithAddress(suite.ctx, addr1) + suite.app.AccountKeeper.SetAccount(suite.ctx, acc1) + + //initial balances need to be 0 + initialUserBalances := suite.app.BankKeeper.GetAllBalances(suite.ctx, addr1) + suite.Require().True(initialUserBalances.IsZero()) + + balances := sdk.NewCoins(sdk.NewInt64Coin("ubze", 10000020000)) + suite.Require().NoError(simapp.FundAccount(suite.app.BankKeeper, suite.ctx, addr1, balances)) + suite.app.TradebinKeeper.SetMarket(suite.ctx, types2.Market{ + Base: "stake", + Quote: "ubze", + Creator: "", + }) + + msg := types.MsgCreateTradingReward{ + Creator: addr1.String(), + PrizeAmount: "200", + PrizeDenom: "ubze", + Duration: "100", + MarketId: "stake/ubze", + Slots: "100", + } + + res, err := suite.msgServer.CreateTradingReward(goCtx, &msg) + suite.Require().NoError(err) + + storeTradingReward, ok := suite.k.GetTradingReward(suite.ctx, res.RewardId) + suite.Require().True(ok) + + suite.Require().EqualValues(msg.PrizeAmount, storeTradingReward.PrizeAmount) + suite.Require().EqualValues(msg.PrizeDenom, storeTradingReward.PrizeDenom) + suite.Require().EqualValues(uint32(100), storeTradingReward.Duration) + suite.Require().EqualValues(msg.MarketId, storeTradingReward.MarketId) + suite.Require().EqualValues(uint32(100), storeTradingReward.Slots) + + expectedRemainingBalance := sdk.NewCoins(sdk.NewInt64Coin("ubze", 0)) + actualRemainingBalance := suite.app.BankKeeper.GetAllBalances(suite.ctx, addr1) + suite.Require().True(actualRemainingBalance.IsEqual(expectedRemainingBalance)) +} diff --git a/x/rewards/types/messages_trading_reward_test.go b/x/rewards/types/messages_trading_reward_test.go index 9fe28f38..ab1254f4 100644 --- a/x/rewards/types/messages_trading_reward_test.go +++ b/x/rewards/types/messages_trading_reward_test.go @@ -1,102 +1 @@ package types - -import ( - "testing" - - sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" - "github.com/stretchr/testify/require" - "github.com/bze-alphateam/bze/testutil/sample" -) - -func TestMsgCreateTradingReward_ValidateBasic(t *testing.T) { - tests := []struct { - name string - msg MsgCreateTradingReward - err error - }{ - { - name: "invalid address", - msg: MsgCreateTradingReward{ - Creator: "invalid_address", - }, - err: sdkerrors.ErrInvalidAddress, - }, { - name: "valid address", - msg: MsgCreateTradingReward{ - Creator: sample.AccAddress(), - }, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - err := tt.msg.ValidateBasic() - if tt.err != nil { - require.ErrorIs(t, err, tt.err) - return - } - require.NoError(t, err) - }) - } -} - -func TestMsgUpdateTradingReward_ValidateBasic(t *testing.T) { - tests := []struct { - name string - msg MsgUpdateTradingReward - err error - }{ - { - name: "invalid address", - msg: MsgUpdateTradingReward{ - Creator: "invalid_address", - }, - err: sdkerrors.ErrInvalidAddress, - }, { - name: "valid address", - msg: MsgUpdateTradingReward{ - Creator: sample.AccAddress(), - }, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - err := tt.msg.ValidateBasic() - if tt.err != nil { - require.ErrorIs(t, err, tt.err) - return - } - require.NoError(t, err) - }) - } -} - -func TestMsgDeleteTradingReward_ValidateBasic(t *testing.T) { - tests := []struct { - name string - msg MsgDeleteTradingReward - err error - }{ - { - name: "invalid address", - msg: MsgDeleteTradingReward{ - Creator: "invalid_address", - }, - err: sdkerrors.ErrInvalidAddress, - }, { - name: "valid address", - msg: MsgDeleteTradingReward{ - Creator: sample.AccAddress(), - }, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - err := tt.msg.ValidateBasic() - if tt.err != nil { - require.ErrorIs(t, err, tt.err) - return - } - require.NoError(t, err) - }) - } -} From f1dd003fe6dca11fa127de06bd8b9bd681b97e59 Mon Sep 17 00:00:00 2001 From: faneaatiku Date: Sun, 17 Mar 2024 22:00:50 +0200 Subject: [PATCH 10/35] added join/exit stake messages --- docs/static/openapi.yml | 367 ++++- proto/rewards/genesis.proto | 4 +- proto/rewards/query.proto | 39 +- proto/rewards/staking_reward.proto | 2 +- .../rewards/staking_reward_participant.proto | 10 + proto/rewards/tx.proto | 20 +- .../bze/bze.tradebin.v1/index.ts | 32 +- .../bze/bze.tradebin.v1/module/index.ts | 6 +- .../bze-alphateam/bze/bze.v1.rewards/index.ts | 144 +- .../bze/bze.v1.rewards/module/index.ts | 12 +- .../bze/bze.v1.rewards/module/rest.ts | 104 +- .../module/types/rewards/genesis.ts | 74 +- .../module/types/rewards/query.ts | 512 +++++- .../module/types/rewards/staking_reward.ts | 20 + .../rewards/staking_reward_participant.ts | 128 ++ .../bze.v1.rewards/module/types/rewards/tx.ts | 272 ++- x/rewards/client/cli/query.go | 2 + x/rewards/client/cli/query_staking_reward.go | 65 +- .../cli/query_staking_reward_participant.go | 79 + .../query_staking_reward_participant_test.go | 161 ++ .../client/cli/query_staking_reward_test.go | 32 +- .../client/cli/query_trading_reward_test.go | 32 +- x/rewards/client/cli/tx.go | 2 + x/rewards/client/cli/tx_exit_staking.go | 42 + x/rewards/client/cli/tx_join_staking.go | 44 + .../client/cli/tx_staking_reward_test.go | 87 +- .../client/cli/tx_trading_reward_test.go | 87 +- x/rewards/genesis.go | 5 + x/rewards/genesis_test.go | 45 +- x/rewards/handler.go | 6 + .../grpc_query_staking_reward_participant.go | 67 + ...c_query_staking_reward_participant_test.go | 126 ++ x/rewards/keeper/grpc_query_trading_reward.go | 2 +- .../keeper/grpc_query_trading_reward_test.go | 39 +- x/rewards/keeper/keeper_test.go | 2 - x/rewards/keeper/msg_server_exit_staking.go | 52 + x/rewards/keeper/msg_server_join_staking.go | 74 + x/rewards/keeper/msg_server_trading_reward.go | 4 +- .../keeper/staking_reward_participant.go | 49 + .../keeper/staking_reward_participant_test.go | 63 + x/rewards/keeper/staking_reward_test.go | 15 +- x/rewards/keeper/trading_reward_test.go | 15 +- x/rewards/module_simulation.go | 30 + x/rewards/simulation/exit_staking.go | 29 + x/rewards/simulation/join_staking.go | 29 + x/rewards/types/codec.go | 8 + x/rewards/types/errors.go | 3 +- x/rewards/types/genesis.go | 37 +- x/rewards/types/genesis.pb.go | 117 +- x/rewards/types/genesis_test.go | 108 +- .../types/key_staking_reward_participant.go | 20 + x/rewards/types/message_exit_staking.go | 51 + x/rewards/types/message_exit_staking_test.go | 40 + x/rewards/types/message_join_staking.go | 64 + x/rewards/types/message_join_staking_test.go | 40 + x/rewards/types/messages_staking_reward.go | 4 +- .../types/messages_staking_reward_test.go | 2 +- x/rewards/types/messages_trading_reward.go | 4 +- x/rewards/types/query.pb.go | 1182 +++++++++++-- x/rewards/types/query.pb.gw.go | 216 ++- x/rewards/types/staking_reward.pb.go | 91 +- .../types/staking_reward_participant.pb.go | 421 +++++ x/rewards/types/tx.pb.go | 1457 +++++++++++++---- 63 files changed, 6024 insertions(+), 872 deletions(-) create mode 100644 proto/rewards/staking_reward_participant.proto create mode 100644 vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/staking_reward_participant.ts create mode 100644 x/rewards/client/cli/query_staking_reward_participant.go create mode 100644 x/rewards/client/cli/query_staking_reward_participant_test.go create mode 100644 x/rewards/client/cli/tx_exit_staking.go create mode 100644 x/rewards/client/cli/tx_join_staking.go create mode 100644 x/rewards/keeper/grpc_query_staking_reward_participant.go create mode 100644 x/rewards/keeper/grpc_query_staking_reward_participant_test.go create mode 100644 x/rewards/keeper/msg_server_exit_staking.go create mode 100644 x/rewards/keeper/msg_server_join_staking.go create mode 100644 x/rewards/keeper/staking_reward_participant.go create mode 100644 x/rewards/keeper/staking_reward_participant_test.go create mode 100644 x/rewards/simulation/exit_staking.go create mode 100644 x/rewards/simulation/join_staking.go create mode 100644 x/rewards/types/key_staking_reward_participant.go create mode 100644 x/rewards/types/message_exit_staking.go create mode 100644 x/rewards/types/message_exit_staking_test.go create mode 100644 x/rewards/types/message_join_staking.go create mode 100644 x/rewards/types/message_join_staking_test.go create mode 100644 x/rewards/types/staking_reward_participant.pb.go diff --git a/docs/static/openapi.yml b/docs/static/openapi.yml index 3f9b011f..891ffb36 100644 --- a/docs/static/openapi.yml +++ b/docs/static/openapi.yml @@ -2227,6 +2227,8 @@ paths: lock: type: integer format: int64 + staked_amount: + type: string pagination: type: object properties: @@ -2364,6 +2366,8 @@ paths: lock: type: integer format: int64 + staked_amount: + type: string default: description: An unexpected error response. schema: @@ -2389,6 +2393,260 @@ paths: type: string tags: - Query + '/bze/rewards/v1/staking_reward_participant/{address}': + get: + summary: Queries a StakingRewardParticipant by index. + operationId: BzeV1RewardsStakingRewardParticipant + responses: + '200': + description: A successful response. + schema: + type: object + properties: + list: + type: array + items: + type: object + properties: + address: + type: string + reward_id: + type: string + amount: + type: string + pagination: + type: object + properties: + next_key: + type: string + format: byte + title: |- + next_key is the key to be passed to PageRequest.key to + query the next page most efficiently + total: + type: string + format: uint64 + title: >- + total is total number of results available if + PageRequest.count_total + + was set, its value is undefined otherwise + description: >- + PageResponse is to be embedded in gRPC response messages where + the + + corresponding request message has used PageRequest. + + message SomeResponse { + repeated Bar results = 1; + PageResponse page = 2; + } + 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: {} + parameters: + - name: address + in: path + required: true + type: string + - name: pagination.key + description: |- + key is a value returned in PageResponse.next_key to begin + querying the next page most efficiently. Only one of offset or key + should be set. + in: query + required: false + type: string + format: byte + - name: pagination.offset + description: >- + offset is a numeric offset that can be used when key is unavailable. + + It is less efficient than using key. Only one of offset or key + should + + be set. + in: query + required: false + type: string + format: uint64 + - name: pagination.limit + description: >- + limit is the total number of results to be returned in the result + page. + + If left empty it will default to a value to be set by each app. + in: query + required: false + type: string + format: uint64 + - name: pagination.count_total + description: >- + count_total is set to true to indicate that the result set should + include + + a count of the total number of items available for pagination in + UIs. + + count_total is only respected when offset is used. It is ignored + when key + + is set. + in: query + required: false + type: boolean + - name: pagination.reverse + description: >- + reverse is set to true if results are to be returned in the + descending order. + + + Since: cosmos-sdk 0.43 + in: query + required: false + type: boolean + tags: + - Query + /bze/rewards/v1/staking_reward_participants: + get: + summary: Queries a list of StakingRewardParticipant items. + operationId: BzeV1RewardsStakingRewardParticipantAll + responses: + '200': + description: A successful response. + schema: + type: object + properties: + list: + type: array + items: + type: object + properties: + address: + type: string + reward_id: + type: string + amount: + type: string + pagination: + type: object + properties: + next_key: + type: string + format: byte + title: |- + next_key is the key to be passed to PageRequest.key to + query the next page most efficiently + total: + type: string + format: uint64 + title: >- + total is total number of results available if + PageRequest.count_total + + was set, its value is undefined otherwise + description: >- + PageResponse is to be embedded in gRPC response messages where + the + + corresponding request message has used PageRequest. + + message SomeResponse { + repeated Bar results = 1; + PageResponse page = 2; + } + 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: {} + parameters: + - name: pagination.key + description: |- + key is a value returned in PageResponse.next_key to begin + querying the next page most efficiently. Only one of offset or key + should be set. + in: query + required: false + type: string + format: byte + - name: pagination.offset + description: >- + offset is a numeric offset that can be used when key is unavailable. + + It is less efficient than using key. Only one of offset or key + should + + be set. + in: query + required: false + type: string + format: uint64 + - name: pagination.limit + description: >- + limit is the total number of results to be returned in the result + page. + + If left empty it will default to a value to be set by each app. + in: query + required: false + type: string + format: uint64 + - name: pagination.count_total + description: >- + count_total is set to true to indicate that the result set should + include + + a count of the total number of items available for pagination in + UIs. + + count_total is only respected when offset is used. It is ignored + when key + + is set. + in: query + required: false + type: boolean + - name: pagination.reverse + description: >- + reverse is set to true if results are to be returned in the + descending order. + + + Since: cosmos-sdk 0.43 + in: query + required: false + type: boolean + tags: + - Query /bze/rewards/v1/trading_reward: get: summary: Queries a list of TradingReward items. @@ -2399,7 +2657,7 @@ paths: schema: type: object properties: - tradingReward: + list: type: array items: type: object @@ -2522,7 +2780,7 @@ paths: type: boolean tags: - Query - '/bze/rewards/v1/trading_reward/{rewardId}': + '/bze/rewards/v1/trading_reward/{reward_id}': get: summary: Queries a TradingReward by index. operationId: BzeV1RewardsTradingReward @@ -2532,7 +2790,7 @@ paths: schema: type: object properties: - tradingReward: + trading_reward: type: object properties: reward_id: @@ -2568,7 +2826,7 @@ paths: type: string additionalProperties: {} parameters: - - name: rewardId + - name: reward_id in: path required: true type: string @@ -34353,6 +34611,10 @@ definitions: properties: reward_id: type: string + bze.v1.rewards.MsgExitStakingResponse: + type: object + bze.v1.rewards.MsgJoinStakingResponse: + type: object bze.v1.rewards.MsgUpdateStakingRewardResponse: type: object bze.v1.rewards.Params: @@ -34363,6 +34625,45 @@ definitions: createTradingRewardFee: type: string description: Params defines the parameters for the module. + bze.v1.rewards.QueryAllStakingRewardParticipantResponse: + type: object + properties: + list: + type: array + items: + type: object + properties: + address: + type: string + reward_id: + type: string + amount: + type: string + pagination: + type: object + properties: + next_key: + type: string + format: byte + title: |- + next_key is the key to be passed to PageRequest.key to + query the next page most efficiently + total: + type: string + format: uint64 + title: >- + total is total number of results available if + PageRequest.count_total + + was set, its value is undefined otherwise + description: |- + PageResponse is to be embedded in gRPC response messages where the + corresponding request message has used PageRequest. + + message SomeResponse { + repeated Bar results = 1; + PageResponse page = 2; + } bze.v1.rewards.QueryAllStakingRewardResponse: type: object properties: @@ -34391,6 +34692,8 @@ definitions: lock: type: integer format: int64 + staked_amount: + type: string pagination: type: object properties: @@ -34419,7 +34722,7 @@ definitions: bze.v1.rewards.QueryAllTradingRewardResponse: type: object properties: - tradingReward: + list: type: array items: type: object @@ -34463,6 +34766,45 @@ definitions: repeated Bar results = 1; PageResponse page = 2; } + bze.v1.rewards.QueryGetStakingRewardParticipantResponse: + type: object + properties: + list: + type: array + items: + type: object + properties: + address: + type: string + reward_id: + type: string + amount: + type: string + pagination: + type: object + properties: + next_key: + type: string + format: byte + title: |- + next_key is the key to be passed to PageRequest.key to + query the next page most efficiently + total: + type: string + format: uint64 + title: >- + total is total number of results available if + PageRequest.count_total + + was set, its value is undefined otherwise + description: |- + PageResponse is to be embedded in gRPC response messages where the + corresponding request message has used PageRequest. + + message SomeResponse { + repeated Bar results = 1; + PageResponse page = 2; + } bze.v1.rewards.QueryGetStakingRewardResponse: type: object properties: @@ -34489,10 +34831,12 @@ definitions: lock: type: integer format: int64 + staked_amount: + type: string bze.v1.rewards.QueryGetTradingRewardResponse: type: object properties: - tradingReward: + trading_reward: type: object properties: reward_id: @@ -34544,6 +34888,17 @@ definitions: lock: type: integer format: int64 + staked_amount: + type: string + bze.v1.rewards.StakingRewardParticipant: + type: object + properties: + address: + type: string + reward_id: + type: string + amount: + type: string bze.v1.rewards.TradingReward: type: object properties: diff --git a/proto/rewards/genesis.proto b/proto/rewards/genesis.proto index 19637dee..5abe691b 100644 --- a/proto/rewards/genesis.proto +++ b/proto/rewards/genesis.proto @@ -5,6 +5,7 @@ import "gogoproto/gogo.proto"; import "rewards/params.proto"; import "rewards/staking_reward.proto"; import "rewards/trading_reward.proto"; +import "rewards/staking_reward_participant.proto"; // this line is used by starport scaffolding # genesis/proto/import option go_package = "github.com/bze-alphateam/bze/x/rewards/types"; @@ -16,6 +17,7 @@ message GenesisState { uint64 staking_rewards_counter = 3; uint64 trading_rewards_counter = 4; - repeated TradingReward tradingRewardList = 5 [(gogoproto.nullable) = false]; + repeated TradingReward trading_reward_list = 5 [(gogoproto.nullable) = false]; + repeated StakingRewardParticipant staking_reward_participant_list = 6 [(gogoproto.nullable) = false]; // this line is used by starport scaffolding # genesis/proto/state } diff --git a/proto/rewards/query.proto b/proto/rewards/query.proto index 81202599..06a0fd52 100644 --- a/proto/rewards/query.proto +++ b/proto/rewards/query.proto @@ -7,6 +7,7 @@ import "cosmos/base/query/v1beta1/pagination.proto"; import "rewards/params.proto"; import "rewards/staking_reward.proto"; import "rewards/trading_reward.proto"; +import "rewards/staking_reward_participant.proto"; // this line is used by starport scaffolding # 1 option go_package = "github.com/bze-alphateam/bze/x/rewards/types"; @@ -29,7 +30,7 @@ service Query { // Queries a TradingReward by index. rpc TradingReward(QueryGetTradingRewardRequest) returns (QueryGetTradingRewardResponse) { - option (google.api.http).get = "/bze/rewards/v1/trading_reward/{rewardId}"; + option (google.api.http).get = "/bze/rewards/v1/trading_reward/{reward_id}"; } // Queries a list of TradingReward items. @@ -37,6 +38,16 @@ service Query { option (google.api.http).get = "/bze/rewards/v1/trading_reward"; } + // Queries a StakingRewardParticipant by index. + rpc StakingRewardParticipant(QueryGetStakingRewardParticipantRequest) returns (QueryGetStakingRewardParticipantResponse) { + option (google.api.http).get = "/bze/rewards/v1/staking_reward_participant/{address}"; + } + + // Queries a list of StakingRewardParticipant items. + rpc StakingRewardParticipantAll(QueryAllStakingRewardParticipantRequest) returns (QueryAllStakingRewardParticipantResponse) { + option (google.api.http).get = "/bze/rewards/v1/staking_reward_participants"; + } + // this line is used by starport scaffolding # 2 } @@ -67,12 +78,11 @@ message QueryAllStakingRewardResponse { } message QueryGetTradingRewardRequest { - string rewardId = 1; - + string reward_id = 1; } message QueryGetTradingRewardResponse { - TradingReward tradingReward = 1 [(gogoproto.nullable) = false]; + TradingReward trading_reward = 1 [(gogoproto.nullable) = false]; } message QueryAllTradingRewardRequest { @@ -80,7 +90,26 @@ message QueryAllTradingRewardRequest { } message QueryAllTradingRewardResponse { - repeated TradingReward tradingReward = 1 [(gogoproto.nullable) = false]; + repeated TradingReward list = 1 [(gogoproto.nullable) = false]; + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} + +message QueryGetStakingRewardParticipantRequest { + string address = 1; + cosmos.base.query.v1beta1.PageRequest pagination = 2; +} + +message QueryGetStakingRewardParticipantResponse { + repeated StakingRewardParticipant list = 1 [(gogoproto.nullable) = false]; + cosmos.base.query.v1beta1.PageResponse pagination = 2; +} + +message QueryAllStakingRewardParticipantRequest { + cosmos.base.query.v1beta1.PageRequest pagination = 1; +} + +message QueryAllStakingRewardParticipantResponse { + repeated StakingRewardParticipant list = 1 [(gogoproto.nullable) = false]; cosmos.base.query.v1beta1.PageResponse pagination = 2; } diff --git a/proto/rewards/staking_reward.proto b/proto/rewards/staking_reward.proto index b8bbf527..6158e499 100644 --- a/proto/rewards/staking_reward.proto +++ b/proto/rewards/staking_reward.proto @@ -12,5 +12,5 @@ message StakingReward { uint32 payouts = 6; uint64 min_stake = 7; uint32 lock = 8; + string staked_amount = 9; } - diff --git a/proto/rewards/staking_reward_participant.proto b/proto/rewards/staking_reward_participant.proto new file mode 100644 index 00000000..047990ef --- /dev/null +++ b/proto/rewards/staking_reward_participant.proto @@ -0,0 +1,10 @@ +syntax = "proto3"; +package bze.v1.rewards; + +option go_package = "github.com/bze-alphateam/bze/x/rewards/types"; + +message StakingRewardParticipant { + string address = 1; + string reward_id = 2; + string amount = 3; +} diff --git a/proto/rewards/tx.proto b/proto/rewards/tx.proto index 939dff65..9c84fb32 100644 --- a/proto/rewards/tx.proto +++ b/proto/rewards/tx.proto @@ -1,7 +1,6 @@ syntax = "proto3"; package bze.v1.rewards; -import "rewards/trading_reward.proto"; // this line is used by starport scaffolding # proto/tx/import option go_package = "github.com/bze-alphateam/bze/x/rewards/types"; @@ -11,6 +10,8 @@ service Msg { rpc CreateStakingReward(MsgCreateStakingReward) returns (MsgCreateStakingRewardResponse); rpc UpdateStakingReward(MsgUpdateStakingReward) returns (MsgUpdateStakingRewardResponse); rpc CreateTradingReward(MsgCreateTradingReward) returns (MsgCreateTradingRewardResponse); + rpc JoinStaking(MsgJoinStaking) returns (MsgJoinStakingResponse); + rpc ExitStaking(MsgExitStaking) returns (MsgExitStakingResponse); // this line is used by starport scaffolding # proto/tx/rpc } @@ -47,4 +48,21 @@ message MsgCreateTradingRewardResponse { string reward_id = 1; } +message MsgJoinStaking { + string creator = 1; + string reward_id = 2; + string amount = 3; +} + +message MsgJoinStakingResponse { +} + +message MsgExitStaking { + string creator = 1; + string rewardId = 2; +} + +message MsgExitStakingResponse { +} + // this line is used by starport scaffolding # proto/tx/message diff --git a/vue/src/store/generated/bze-alphateam/bze/bze.tradebin.v1/index.ts b/vue/src/store/generated/bze-alphateam/bze/bze.tradebin.v1/index.ts index 12653609..9e560694 100755 --- a/vue/src/store/generated/bze-alphateam/bze/bze.tradebin.v1/index.ts +++ b/vue/src/store/generated/bze-alphateam/bze/bze.tradebin.v1/index.ts @@ -390,33 +390,33 @@ export default { }, - async sendMsgCreateMarket({ rootGetters }, { value, fee = [], memo = '' }) { + async sendMsgCancelOrder({ rootGetters }, { value, fee = [], memo = '' }) { try { const txClient=await initTxClient(rootGetters) - const msg = await txClient.msgCreateMarket(value) + const msg = await txClient.msgCancelOrder(value) const result = await txClient.signAndBroadcast([msg], {fee: { amount: fee, gas: "200000" }, memo}) return result } catch (e) { if (e == MissingWalletError) { - throw new Error('TxClient:MsgCreateMarket:Init Could not initialize signing client. Wallet is required.') + throw new Error('TxClient:MsgCancelOrder:Init Could not initialize signing client. Wallet is required.') }else{ - throw new Error('TxClient:MsgCreateMarket:Send Could not broadcast Tx: '+ e.message) + throw new Error('TxClient:MsgCancelOrder:Send Could not broadcast Tx: '+ e.message) } } }, - async sendMsgCancelOrder({ rootGetters }, { value, fee = [], memo = '' }) { + async sendMsgCreateMarket({ rootGetters }, { value, fee = [], memo = '' }) { try { const txClient=await initTxClient(rootGetters) - const msg = await txClient.msgCancelOrder(value) + const msg = await txClient.msgCreateMarket(value) const result = await txClient.signAndBroadcast([msg], {fee: { amount: fee, gas: "200000" }, memo}) return result } catch (e) { if (e == MissingWalletError) { - throw new Error('TxClient:MsgCancelOrder:Init Could not initialize signing client. Wallet is required.') + throw new Error('TxClient:MsgCreateMarket:Init Could not initialize signing client. Wallet is required.') }else{ - throw new Error('TxClient:MsgCancelOrder:Send Could not broadcast Tx: '+ e.message) + throw new Error('TxClient:MsgCreateMarket:Send Could not broadcast Tx: '+ e.message) } } }, @@ -436,29 +436,29 @@ export default { } }, - async MsgCreateMarket({ rootGetters }, { value }) { + async MsgCancelOrder({ rootGetters }, { value }) { try { const txClient=await initTxClient(rootGetters) - const msg = await txClient.msgCreateMarket(value) + const msg = await txClient.msgCancelOrder(value) return msg } catch (e) { if (e == MissingWalletError) { - throw new Error('TxClient:MsgCreateMarket:Init Could not initialize signing client. Wallet is required.') + throw new Error('TxClient:MsgCancelOrder:Init Could not initialize signing client. Wallet is required.') } else{ - throw new Error('TxClient:MsgCreateMarket:Create Could not create message: ' + e.message) + throw new Error('TxClient:MsgCancelOrder:Create Could not create message: ' + e.message) } } }, - async MsgCancelOrder({ rootGetters }, { value }) { + async MsgCreateMarket({ rootGetters }, { value }) { try { const txClient=await initTxClient(rootGetters) - const msg = await txClient.msgCancelOrder(value) + const msg = await txClient.msgCreateMarket(value) return msg } catch (e) { if (e == MissingWalletError) { - throw new Error('TxClient:MsgCancelOrder:Init Could not initialize signing client. Wallet is required.') + throw new Error('TxClient:MsgCreateMarket:Init Could not initialize signing client. Wallet is required.') } else{ - throw new Error('TxClient:MsgCancelOrder:Create Could not create message: ' + e.message) + throw new Error('TxClient:MsgCreateMarket:Create Could not create message: ' + e.message) } } }, diff --git a/vue/src/store/generated/bze-alphateam/bze/bze.tradebin.v1/module/index.ts b/vue/src/store/generated/bze-alphateam/bze/bze.tradebin.v1/module/index.ts index 45b5ea24..6a85db94 100755 --- a/vue/src/store/generated/bze-alphateam/bze/bze.tradebin.v1/module/index.ts +++ b/vue/src/store/generated/bze-alphateam/bze/bze.tradebin.v1/module/index.ts @@ -4,14 +4,14 @@ import { StdFee } from "@cosmjs/launchpad"; import { SigningStargateClient } from "@cosmjs/stargate"; import { Registry, OfflineSigner, EncodeObject, DirectSecp256k1HdWallet } from "@cosmjs/proto-signing"; import { Api } from "./rest"; -import { MsgCreateMarket } from "./types/tradebin/tx"; import { MsgCancelOrder } from "./types/tradebin/tx"; +import { MsgCreateMarket } from "./types/tradebin/tx"; import { MsgCreateOrder } from "./types/tradebin/tx"; const types = [ - ["/bze.tradebin.v1.MsgCreateMarket", MsgCreateMarket], ["/bze.tradebin.v1.MsgCancelOrder", MsgCancelOrder], + ["/bze.tradebin.v1.MsgCreateMarket", MsgCreateMarket], ["/bze.tradebin.v1.MsgCreateOrder", MsgCreateOrder], ]; @@ -45,8 +45,8 @@ const txClient = async (wallet: OfflineSigner, { addr: addr }: TxClientOptions = return { signAndBroadcast: (msgs: EncodeObject[], { fee, memo }: SignAndBroadcastOptions = {fee: defaultFee, memo: ""}) => client.signAndBroadcast(address, msgs, fee,memo), - msgCreateMarket: (data: MsgCreateMarket): EncodeObject => ({ typeUrl: "/bze.tradebin.v1.MsgCreateMarket", value: MsgCreateMarket.fromPartial( data ) }), msgCancelOrder: (data: MsgCancelOrder): EncodeObject => ({ typeUrl: "/bze.tradebin.v1.MsgCancelOrder", value: MsgCancelOrder.fromPartial( data ) }), + msgCreateMarket: (data: MsgCreateMarket): EncodeObject => ({ typeUrl: "/bze.tradebin.v1.MsgCreateMarket", value: MsgCreateMarket.fromPartial( data ) }), msgCreateOrder: (data: MsgCreateOrder): EncodeObject => ({ typeUrl: "/bze.tradebin.v1.MsgCreateOrder", value: MsgCreateOrder.fromPartial( data ) }), }; diff --git a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/index.ts b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/index.ts index ec509211..85831387 100755 --- a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/index.ts +++ b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/index.ts @@ -2,10 +2,11 @@ import { txClient, queryClient, MissingWalletError , registry} from './module' import { Params } from "./module/types/rewards/params" import { StakingReward } from "./module/types/rewards/staking_reward" +import { StakingRewardParticipant } from "./module/types/rewards/staking_reward_participant" import { TradingReward } from "./module/types/rewards/trading_reward" -export { Params, StakingReward, TradingReward }; +export { Params, StakingReward, StakingRewardParticipant, TradingReward }; async function initTxClient(vuexGetters) { return await txClient(vuexGetters['common/wallet/signer'], { @@ -48,10 +49,13 @@ const getDefaultState = () => { StakingRewardAll: {}, TradingReward: {}, TradingRewardAll: {}, + StakingRewardParticipant: {}, + StakingRewardParticipantAll: {}, _Structure: { Params: getStructure(Params.fromPartial({})), StakingReward: getStructure(StakingReward.fromPartial({})), + StakingRewardParticipant: getStructure(StakingRewardParticipant.fromPartial({})), TradingReward: getStructure(TradingReward.fromPartial({})), }, @@ -111,6 +115,18 @@ export default { } return state.TradingRewardAll[JSON.stringify(params)] ?? {} }, + getStakingRewardParticipant: (state) => (params = { params: {}}) => { + if (!( params).query) { + ( params).query=null + } + return state.StakingRewardParticipant[JSON.stringify(params)] ?? {} + }, + getStakingRewardParticipantAll: (state) => (params = { params: {}}) => { + if (!( params).query) { + ( params).query=null + } + return state.StakingRewardParticipantAll[JSON.stringify(params)] ?? {} + }, getTypeStructure: (state) => (type) => { return state._Structure[type].fields @@ -224,7 +240,7 @@ export default { try { const key = params ?? {}; const queryClient=await initQueryClient(rootGetters) - let value= (await queryClient.queryTradingReward( key.rewardId)).data + let value= (await queryClient.queryTradingReward( key.reward_id)).data commit('QUERY', { query: 'TradingReward', key: { params: {...key}, query}, value }) @@ -263,6 +279,73 @@ export default { }, + + + + + + async QueryStakingRewardParticipant({ commit, rootGetters, getters }, { options: { subscribe, all} = { subscribe:false, all:false}, params, query=null }) { + try { + const key = params ?? {}; + const queryClient=await initQueryClient(rootGetters) + let value= (await queryClient.queryStakingRewardParticipant( key.address, query)).data + + + while (all && ( value).pagination && ( value).pagination.next_key!=null) { + let next_values=(await queryClient.queryStakingRewardParticipant( key.address, {...query, 'pagination.key':( value).pagination.next_key})).data + value = mergeResults(value, next_values); + } + commit('QUERY', { query: 'StakingRewardParticipant', key: { params: {...key}, query}, value }) + if (subscribe) commit('SUBSCRIBE', { action: 'QueryStakingRewardParticipant', payload: { options: { all }, params: {...key},query }}) + return getters['getStakingRewardParticipant']( { params: {...key}, query}) ?? {} + } catch (e) { + throw new Error('QueryClient:QueryStakingRewardParticipant API Node Unavailable. Could not perform query: ' + e.message) + + } + }, + + + + + + + + async QueryStakingRewardParticipantAll({ commit, rootGetters, getters }, { options: { subscribe, all} = { subscribe:false, all:false}, params, query=null }) { + try { + const key = params ?? {}; + const queryClient=await initQueryClient(rootGetters) + let value= (await queryClient.queryStakingRewardParticipantAll(query)).data + + + while (all && ( value).pagination && ( value).pagination.next_key!=null) { + let next_values=(await queryClient.queryStakingRewardParticipantAll({...query, 'pagination.key':( value).pagination.next_key})).data + value = mergeResults(value, next_values); + } + commit('QUERY', { query: 'StakingRewardParticipantAll', key: { params: {...key}, query}, value }) + if (subscribe) commit('SUBSCRIBE', { action: 'QueryStakingRewardParticipantAll', payload: { options: { all }, params: {...key},query }}) + return getters['getStakingRewardParticipantAll']( { params: {...key}, query}) ?? {} + } catch (e) { + throw new Error('QueryClient:QueryStakingRewardParticipantAll API Node Unavailable. Could not perform query: ' + e.message) + + } + }, + + + async sendMsgExitStaking({ rootGetters }, { value, fee = [], memo = '' }) { + try { + const txClient=await initTxClient(rootGetters) + const msg = await txClient.msgExitStaking(value) + const result = await txClient.signAndBroadcast([msg], {fee: { amount: fee, + gas: "200000" }, memo}) + return result + } catch (e) { + if (e == MissingWalletError) { + throw new Error('TxClient:MsgExitStaking:Init Could not initialize signing client. Wallet is required.') + }else{ + throw new Error('TxClient:MsgExitStaking:Send Could not broadcast Tx: '+ e.message) + } + } + }, async sendMsgUpdateStakingReward({ rootGetters }, { value, fee = [], memo = '' }) { try { const txClient=await initTxClient(rootGetters) @@ -278,6 +361,21 @@ export default { } } }, + async sendMsgCreateStakingReward({ rootGetters }, { value, fee = [], memo = '' }) { + try { + const txClient=await initTxClient(rootGetters) + const msg = await txClient.msgCreateStakingReward(value) + const result = await txClient.signAndBroadcast([msg], {fee: { amount: fee, + gas: "200000" }, memo}) + return result + } catch (e) { + if (e == MissingWalletError) { + throw new Error('TxClient:MsgCreateStakingReward:Init Could not initialize signing client. Wallet is required.') + }else{ + throw new Error('TxClient:MsgCreateStakingReward:Send Could not broadcast Tx: '+ e.message) + } + } + }, async sendMsgCreateTradingReward({ rootGetters }, { value, fee = [], memo = '' }) { try { const txClient=await initTxClient(rootGetters) @@ -293,22 +391,35 @@ export default { } } }, - async sendMsgCreateStakingReward({ rootGetters }, { value, fee = [], memo = '' }) { + async sendMsgJoinStaking({ rootGetters }, { value, fee = [], memo = '' }) { try { const txClient=await initTxClient(rootGetters) - const msg = await txClient.msgCreateStakingReward(value) + const msg = await txClient.msgJoinStaking(value) const result = await txClient.signAndBroadcast([msg], {fee: { amount: fee, gas: "200000" }, memo}) return result } catch (e) { if (e == MissingWalletError) { - throw new Error('TxClient:MsgCreateStakingReward:Init Could not initialize signing client. Wallet is required.') + throw new Error('TxClient:MsgJoinStaking:Init Could not initialize signing client. Wallet is required.') }else{ - throw new Error('TxClient:MsgCreateStakingReward:Send Could not broadcast Tx: '+ e.message) + throw new Error('TxClient:MsgJoinStaking:Send Could not broadcast Tx: '+ e.message) } } }, + async MsgExitStaking({ rootGetters }, { value }) { + try { + const txClient=await initTxClient(rootGetters) + const msg = await txClient.msgExitStaking(value) + return msg + } catch (e) { + if (e == MissingWalletError) { + throw new Error('TxClient:MsgExitStaking:Init Could not initialize signing client. Wallet is required.') + } else{ + throw new Error('TxClient:MsgExitStaking:Create Could not create message: ' + e.message) + } + } + }, async MsgUpdateStakingReward({ rootGetters }, { value }) { try { const txClient=await initTxClient(rootGetters) @@ -322,6 +433,19 @@ export default { } } }, + async MsgCreateStakingReward({ rootGetters }, { value }) { + try { + const txClient=await initTxClient(rootGetters) + const msg = await txClient.msgCreateStakingReward(value) + return msg + } catch (e) { + if (e == MissingWalletError) { + throw new Error('TxClient:MsgCreateStakingReward:Init Could not initialize signing client. Wallet is required.') + } else{ + throw new Error('TxClient:MsgCreateStakingReward:Create Could not create message: ' + e.message) + } + } + }, async MsgCreateTradingReward({ rootGetters }, { value }) { try { const txClient=await initTxClient(rootGetters) @@ -335,16 +459,16 @@ export default { } } }, - async MsgCreateStakingReward({ rootGetters }, { value }) { + async MsgJoinStaking({ rootGetters }, { value }) { try { const txClient=await initTxClient(rootGetters) - const msg = await txClient.msgCreateStakingReward(value) + const msg = await txClient.msgJoinStaking(value) return msg } catch (e) { if (e == MissingWalletError) { - throw new Error('TxClient:MsgCreateStakingReward:Init Could not initialize signing client. Wallet is required.') + throw new Error('TxClient:MsgJoinStaking:Init Could not initialize signing client. Wallet is required.') } else{ - throw new Error('TxClient:MsgCreateStakingReward:Create Could not create message: ' + e.message) + throw new Error('TxClient:MsgJoinStaking:Create Could not create message: ' + e.message) } } }, diff --git a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/index.ts b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/index.ts index d5dab190..8f98d77c 100755 --- a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/index.ts +++ b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/index.ts @@ -4,15 +4,19 @@ import { StdFee } from "@cosmjs/launchpad"; import { SigningStargateClient } from "@cosmjs/stargate"; import { Registry, OfflineSigner, EncodeObject, DirectSecp256k1HdWallet } from "@cosmjs/proto-signing"; import { Api } from "./rest"; +import { MsgExitStaking } from "./types/rewards/tx"; import { MsgUpdateStakingReward } from "./types/rewards/tx"; -import { MsgCreateTradingReward } from "./types/rewards/tx"; import { MsgCreateStakingReward } from "./types/rewards/tx"; +import { MsgCreateTradingReward } from "./types/rewards/tx"; +import { MsgJoinStaking } from "./types/rewards/tx"; const types = [ + ["/bze.v1.rewards.MsgExitStaking", MsgExitStaking], ["/bze.v1.rewards.MsgUpdateStakingReward", MsgUpdateStakingReward], - ["/bze.v1.rewards.MsgCreateTradingReward", MsgCreateTradingReward], ["/bze.v1.rewards.MsgCreateStakingReward", MsgCreateStakingReward], + ["/bze.v1.rewards.MsgCreateTradingReward", MsgCreateTradingReward], + ["/bze.v1.rewards.MsgJoinStaking", MsgJoinStaking], ]; export const MissingWalletError = new Error("wallet is required"); @@ -45,9 +49,11 @@ const txClient = async (wallet: OfflineSigner, { addr: addr }: TxClientOptions = return { signAndBroadcast: (msgs: EncodeObject[], { fee, memo }: SignAndBroadcastOptions = {fee: defaultFee, memo: ""}) => client.signAndBroadcast(address, msgs, fee,memo), + msgExitStaking: (data: MsgExitStaking): EncodeObject => ({ typeUrl: "/bze.v1.rewards.MsgExitStaking", value: MsgExitStaking.fromPartial( data ) }), msgUpdateStakingReward: (data: MsgUpdateStakingReward): EncodeObject => ({ typeUrl: "/bze.v1.rewards.MsgUpdateStakingReward", value: MsgUpdateStakingReward.fromPartial( data ) }), - msgCreateTradingReward: (data: MsgCreateTradingReward): EncodeObject => ({ typeUrl: "/bze.v1.rewards.MsgCreateTradingReward", value: MsgCreateTradingReward.fromPartial( data ) }), msgCreateStakingReward: (data: MsgCreateStakingReward): EncodeObject => ({ typeUrl: "/bze.v1.rewards.MsgCreateStakingReward", value: MsgCreateStakingReward.fromPartial( data ) }), + msgCreateTradingReward: (data: MsgCreateTradingReward): EncodeObject => ({ typeUrl: "/bze.v1.rewards.MsgCreateTradingReward", value: MsgCreateTradingReward.fromPartial( data ) }), + msgJoinStaking: (data: MsgJoinStaking): EncodeObject => ({ typeUrl: "/bze.v1.rewards.MsgJoinStaking", value: MsgJoinStaking.fromPartial( data ) }), }; }; diff --git a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/rest.ts b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/rest.ts index c83ed530..b91c7d88 100644 --- a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/rest.ts +++ b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/rest.ts @@ -21,8 +21,27 @@ export interface RewardsMsgCreateTradingRewardResponse { reward_id?: string; } +export type RewardsMsgExitStakingResponse = object; + +export type RewardsMsgJoinStakingResponse = object; + export type RewardsMsgUpdateStakingRewardResponse = object; +export interface RewardsQueryAllStakingRewardParticipantResponse { + list?: V1RewardsStakingRewardParticipant[]; + + /** + * PageResponse is to be embedded in gRPC response messages where the + * corresponding request message has used PageRequest. + * + * message SomeResponse { + * repeated Bar results = 1; + * PageResponse page = 2; + * } + */ + pagination?: V1Beta1PageResponse; +} + export interface RewardsQueryAllStakingRewardResponse { list?: V1RewardsStakingReward[]; @@ -39,7 +58,22 @@ export interface RewardsQueryAllStakingRewardResponse { } export interface RewardsQueryAllTradingRewardResponse { - tradingReward?: V1RewardsTradingReward[]; + list?: V1RewardsTradingReward[]; + + /** + * PageResponse is to be embedded in gRPC response messages where the + * corresponding request message has used PageRequest. + * + * message SomeResponse { + * repeated Bar results = 1; + * PageResponse page = 2; + * } + */ + pagination?: V1Beta1PageResponse; +} + +export interface RewardsQueryGetStakingRewardParticipantResponse { + list?: V1RewardsStakingRewardParticipant[]; /** * PageResponse is to be embedded in gRPC response messages where the @@ -58,7 +92,7 @@ export interface RewardsQueryGetStakingRewardResponse { } export interface RewardsQueryGetTradingRewardResponse { - tradingReward?: V1RewardsTradingReward; + trading_reward?: V1RewardsTradingReward; } /** @@ -164,6 +198,13 @@ export interface V1RewardsStakingReward { /** @format int64 */ lock?: number; + staked_amount?: string; +} + +export interface V1RewardsStakingRewardParticipant { + address?: string; + reward_id?: string; + amount?: string; } export interface V1RewardsTradingReward { @@ -433,6 +474,59 @@ export class Api extends HttpClient + this.request({ + path: `/bze/rewards/v1/staking_reward_participant/${address}`, + method: "GET", + query: query, + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Query + * @name QueryStakingRewardParticipantAll + * @summary Queries a list of StakingRewardParticipant items. + * @request GET:/bze/rewards/v1/staking_reward_participants + */ + queryStakingRewardParticipantAll = ( + query?: { + "pagination.key"?: string; + "pagination.offset"?: string; + "pagination.limit"?: string; + "pagination.count_total"?: boolean; + "pagination.reverse"?: boolean; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/bze/rewards/v1/staking_reward_participants`, + method: "GET", + query: query, + format: "json", + ...params, + }); + /** * No description * @@ -465,11 +559,11 @@ export class Api extends HttpClient + queryTradingReward = (reward_id: string, params: RequestParams = {}) => this.request({ - path: `/bze/rewards/v1/trading_reward/${rewardId}`, + path: `/bze/rewards/v1/trading_reward/${reward_id}`, method: "GET", format: "json", ...params, diff --git a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/genesis.ts b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/genesis.ts index 99afb632..87bcb32d 100644 --- a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/genesis.ts +++ b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/genesis.ts @@ -4,6 +4,7 @@ import { util, configure, Writer, Reader } from "protobufjs/minimal"; import { Params } from "../rewards/params"; import { StakingReward } from "../rewards/staking_reward"; import { TradingReward } from "../rewards/trading_reward"; +import { StakingRewardParticipant } from "../rewards/staking_reward_participant"; export const protobufPackage = "bze.v1.rewards"; @@ -13,8 +14,9 @@ export interface GenesisState { staking_reward_list: StakingReward[]; staking_rewards_counter: number; trading_rewards_counter: number; + trading_reward_list: TradingReward[]; /** this line is used by starport scaffolding # genesis/proto/state */ - tradingRewardList: TradingReward[]; + staking_reward_participant_list: StakingRewardParticipant[]; } const baseGenesisState: object = { @@ -36,9 +38,12 @@ export const GenesisState = { if (message.trading_rewards_counter !== 0) { writer.uint32(32).uint64(message.trading_rewards_counter); } - for (const v of message.tradingRewardList) { + for (const v of message.trading_reward_list) { TradingReward.encode(v!, writer.uint32(42).fork()).ldelim(); } + for (const v of message.staking_reward_participant_list) { + StakingRewardParticipant.encode(v!, writer.uint32(50).fork()).ldelim(); + } return writer; }, @@ -47,7 +52,8 @@ export const GenesisState = { let end = length === undefined ? reader.len : reader.pos + length; const message = { ...baseGenesisState } as GenesisState; message.staking_reward_list = []; - message.tradingRewardList = []; + message.trading_reward_list = []; + message.staking_reward_participant_list = []; while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { @@ -70,10 +76,15 @@ export const GenesisState = { ); break; case 5: - message.tradingRewardList.push( + message.trading_reward_list.push( TradingReward.decode(reader, reader.uint32()) ); break; + case 6: + message.staking_reward_participant_list.push( + StakingRewardParticipant.decode(reader, reader.uint32()) + ); + break; default: reader.skipType(tag & 7); break; @@ -85,7 +96,8 @@ export const GenesisState = { fromJSON(object: any): GenesisState { const message = { ...baseGenesisState } as GenesisState; message.staking_reward_list = []; - message.tradingRewardList = []; + message.trading_reward_list = []; + message.staking_reward_participant_list = []; if (object.params !== undefined && object.params !== null) { message.params = Params.fromJSON(object.params); } else { @@ -116,11 +128,21 @@ export const GenesisState = { message.trading_rewards_counter = 0; } if ( - object.tradingRewardList !== undefined && - object.tradingRewardList !== null + object.trading_reward_list !== undefined && + object.trading_reward_list !== null + ) { + for (const e of object.trading_reward_list) { + message.trading_reward_list.push(TradingReward.fromJSON(e)); + } + } + if ( + object.staking_reward_participant_list !== undefined && + object.staking_reward_participant_list !== null ) { - for (const e of object.tradingRewardList) { - message.tradingRewardList.push(TradingReward.fromJSON(e)); + for (const e of object.staking_reward_participant_list) { + message.staking_reward_participant_list.push( + StakingRewardParticipant.fromJSON(e) + ); } } return message; @@ -141,12 +163,19 @@ export const GenesisState = { (obj.staking_rewards_counter = message.staking_rewards_counter); message.trading_rewards_counter !== undefined && (obj.trading_rewards_counter = message.trading_rewards_counter); - if (message.tradingRewardList) { - obj.tradingRewardList = message.tradingRewardList.map((e) => + if (message.trading_reward_list) { + obj.trading_reward_list = message.trading_reward_list.map((e) => e ? TradingReward.toJSON(e) : undefined ); } else { - obj.tradingRewardList = []; + obj.trading_reward_list = []; + } + if (message.staking_reward_participant_list) { + obj.staking_reward_participant_list = message.staking_reward_participant_list.map( + (e) => (e ? StakingRewardParticipant.toJSON(e) : undefined) + ); + } else { + obj.staking_reward_participant_list = []; } return obj; }, @@ -154,7 +183,8 @@ export const GenesisState = { fromPartial(object: DeepPartial): GenesisState { const message = { ...baseGenesisState } as GenesisState; message.staking_reward_list = []; - message.tradingRewardList = []; + message.trading_reward_list = []; + message.staking_reward_participant_list = []; if (object.params !== undefined && object.params !== null) { message.params = Params.fromPartial(object.params); } else { @@ -185,11 +215,21 @@ export const GenesisState = { message.trading_rewards_counter = 0; } if ( - object.tradingRewardList !== undefined && - object.tradingRewardList !== null + object.trading_reward_list !== undefined && + object.trading_reward_list !== null + ) { + for (const e of object.trading_reward_list) { + message.trading_reward_list.push(TradingReward.fromPartial(e)); + } + } + if ( + object.staking_reward_participant_list !== undefined && + object.staking_reward_participant_list !== null ) { - for (const e of object.tradingRewardList) { - message.tradingRewardList.push(TradingReward.fromPartial(e)); + for (const e of object.staking_reward_participant_list) { + message.staking_reward_participant_list.push( + StakingRewardParticipant.fromPartial(e) + ); } } return message; diff --git a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/query.ts b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/query.ts index 67d92646..e3e87501 100644 --- a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/query.ts +++ b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/query.ts @@ -7,6 +7,7 @@ import { PageResponse, } from "../cosmos/base/query/v1beta1/pagination"; import { TradingReward } from "../rewards/trading_reward"; +import { StakingRewardParticipant } from "../rewards/staking_reward_participant"; export const protobufPackage = "bze.v1.rewards"; @@ -37,11 +38,11 @@ export interface QueryAllStakingRewardResponse { } export interface QueryGetTradingRewardRequest { - rewardId: string; + reward_id: string; } export interface QueryGetTradingRewardResponse { - tradingReward: TradingReward | undefined; + trading_reward: TradingReward | undefined; } export interface QueryAllTradingRewardRequest { @@ -49,7 +50,26 @@ export interface QueryAllTradingRewardRequest { } export interface QueryAllTradingRewardResponse { - tradingReward: TradingReward[]; + list: TradingReward[]; + pagination: PageResponse | undefined; +} + +export interface QueryGetStakingRewardParticipantRequest { + address: string; + pagination: PageRequest | undefined; +} + +export interface QueryGetStakingRewardParticipantResponse { + list: StakingRewardParticipant[]; + pagination: PageResponse | undefined; +} + +export interface QueryAllStakingRewardParticipantRequest { + pagination: PageRequest | undefined; +} + +export interface QueryAllStakingRewardParticipantResponse { + list: StakingRewardParticipant[]; pagination: PageResponse | undefined; } @@ -470,15 +490,15 @@ export const QueryAllStakingRewardResponse = { }, }; -const baseQueryGetTradingRewardRequest: object = { rewardId: "" }; +const baseQueryGetTradingRewardRequest: object = { reward_id: "" }; export const QueryGetTradingRewardRequest = { encode( message: QueryGetTradingRewardRequest, writer: Writer = Writer.create() ): Writer { - if (message.rewardId !== "") { - writer.uint32(10).string(message.rewardId); + if (message.reward_id !== "") { + writer.uint32(10).string(message.reward_id); } return writer; }, @@ -496,7 +516,7 @@ export const QueryGetTradingRewardRequest = { const tag = reader.uint32(); switch (tag >>> 3) { case 1: - message.rewardId = reader.string(); + message.reward_id = reader.string(); break; default: reader.skipType(tag & 7); @@ -510,17 +530,17 @@ export const QueryGetTradingRewardRequest = { const message = { ...baseQueryGetTradingRewardRequest, } as QueryGetTradingRewardRequest; - if (object.rewardId !== undefined && object.rewardId !== null) { - message.rewardId = String(object.rewardId); + if (object.reward_id !== undefined && object.reward_id !== null) { + message.reward_id = String(object.reward_id); } else { - message.rewardId = ""; + message.reward_id = ""; } return message; }, toJSON(message: QueryGetTradingRewardRequest): unknown { const obj: any = {}; - message.rewardId !== undefined && (obj.rewardId = message.rewardId); + message.reward_id !== undefined && (obj.reward_id = message.reward_id); return obj; }, @@ -530,10 +550,10 @@ export const QueryGetTradingRewardRequest = { const message = { ...baseQueryGetTradingRewardRequest, } as QueryGetTradingRewardRequest; - if (object.rewardId !== undefined && object.rewardId !== null) { - message.rewardId = object.rewardId; + if (object.reward_id !== undefined && object.reward_id !== null) { + message.reward_id = object.reward_id; } else { - message.rewardId = ""; + message.reward_id = ""; } return message; }, @@ -546,9 +566,9 @@ export const QueryGetTradingRewardResponse = { message: QueryGetTradingRewardResponse, writer: Writer = Writer.create() ): Writer { - if (message.tradingReward !== undefined) { + if (message.trading_reward !== undefined) { TradingReward.encode( - message.tradingReward, + message.trading_reward, writer.uint32(10).fork() ).ldelim(); } @@ -568,7 +588,10 @@ export const QueryGetTradingRewardResponse = { const tag = reader.uint32(); switch (tag >>> 3) { case 1: - message.tradingReward = TradingReward.decode(reader, reader.uint32()); + message.trading_reward = TradingReward.decode( + reader, + reader.uint32() + ); break; default: reader.skipType(tag & 7); @@ -582,19 +605,19 @@ export const QueryGetTradingRewardResponse = { const message = { ...baseQueryGetTradingRewardResponse, } as QueryGetTradingRewardResponse; - if (object.tradingReward !== undefined && object.tradingReward !== null) { - message.tradingReward = TradingReward.fromJSON(object.tradingReward); + if (object.trading_reward !== undefined && object.trading_reward !== null) { + message.trading_reward = TradingReward.fromJSON(object.trading_reward); } else { - message.tradingReward = undefined; + message.trading_reward = undefined; } return message; }, toJSON(message: QueryGetTradingRewardResponse): unknown { const obj: any = {}; - message.tradingReward !== undefined && - (obj.tradingReward = message.tradingReward - ? TradingReward.toJSON(message.tradingReward) + message.trading_reward !== undefined && + (obj.trading_reward = message.trading_reward + ? TradingReward.toJSON(message.trading_reward) : undefined); return obj; }, @@ -605,10 +628,10 @@ export const QueryGetTradingRewardResponse = { const message = { ...baseQueryGetTradingRewardResponse, } as QueryGetTradingRewardResponse; - if (object.tradingReward !== undefined && object.tradingReward !== null) { - message.tradingReward = TradingReward.fromPartial(object.tradingReward); + if (object.trading_reward !== undefined && object.trading_reward !== null) { + message.trading_reward = TradingReward.fromPartial(object.trading_reward); } else { - message.tradingReward = undefined; + message.trading_reward = undefined; } return message; }, @@ -693,7 +716,7 @@ export const QueryAllTradingRewardResponse = { message: QueryAllTradingRewardResponse, writer: Writer = Writer.create() ): Writer { - for (const v of message.tradingReward) { + for (const v of message.list) { TradingReward.encode(v!, writer.uint32(10).fork()).ldelim(); } if (message.pagination !== undefined) { @@ -714,14 +737,12 @@ export const QueryAllTradingRewardResponse = { const message = { ...baseQueryAllTradingRewardResponse, } as QueryAllTradingRewardResponse; - message.tradingReward = []; + message.list = []; while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { case 1: - message.tradingReward.push( - TradingReward.decode(reader, reader.uint32()) - ); + message.list.push(TradingReward.decode(reader, reader.uint32())); break; case 2: message.pagination = PageResponse.decode(reader, reader.uint32()); @@ -738,10 +759,10 @@ export const QueryAllTradingRewardResponse = { const message = { ...baseQueryAllTradingRewardResponse, } as QueryAllTradingRewardResponse; - message.tradingReward = []; - if (object.tradingReward !== undefined && object.tradingReward !== null) { - for (const e of object.tradingReward) { - message.tradingReward.push(TradingReward.fromJSON(e)); + message.list = []; + if (object.list !== undefined && object.list !== null) { + for (const e of object.list) { + message.list.push(TradingReward.fromJSON(e)); } } if (object.pagination !== undefined && object.pagination !== null) { @@ -754,12 +775,12 @@ export const QueryAllTradingRewardResponse = { toJSON(message: QueryAllTradingRewardResponse): unknown { const obj: any = {}; - if (message.tradingReward) { - obj.tradingReward = message.tradingReward.map((e) => + if (message.list) { + obj.list = message.list.map((e) => e ? TradingReward.toJSON(e) : undefined ); } else { - obj.tradingReward = []; + obj.list = []; } message.pagination !== undefined && (obj.pagination = message.pagination @@ -774,10 +795,377 @@ export const QueryAllTradingRewardResponse = { const message = { ...baseQueryAllTradingRewardResponse, } as QueryAllTradingRewardResponse; - message.tradingReward = []; - if (object.tradingReward !== undefined && object.tradingReward !== null) { - for (const e of object.tradingReward) { - message.tradingReward.push(TradingReward.fromPartial(e)); + message.list = []; + if (object.list !== undefined && object.list !== null) { + for (const e of object.list) { + message.list.push(TradingReward.fromPartial(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseQueryGetStakingRewardParticipantRequest: object = { address: "" }; + +export const QueryGetStakingRewardParticipantRequest = { + encode( + message: QueryGetStakingRewardParticipantRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.address !== "") { + writer.uint32(10).string(message.address); + } + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryGetStakingRewardParticipantRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryGetStakingRewardParticipantRequest, + } as QueryGetStakingRewardParticipantRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.address = reader.string(); + break; + case 2: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryGetStakingRewardParticipantRequest { + const message = { + ...baseQueryGetStakingRewardParticipantRequest, + } as QueryGetStakingRewardParticipantRequest; + if (object.address !== undefined && object.address !== null) { + message.address = String(object.address); + } else { + message.address = ""; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryGetStakingRewardParticipantRequest): unknown { + const obj: any = {}; + message.address !== undefined && (obj.address = message.address); + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageRequest.toJSON(message.pagination) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryGetStakingRewardParticipantRequest { + const message = { + ...baseQueryGetStakingRewardParticipantRequest, + } as QueryGetStakingRewardParticipantRequest; + if (object.address !== undefined && object.address !== null) { + message.address = object.address; + } else { + message.address = ""; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseQueryGetStakingRewardParticipantResponse: object = {}; + +export const QueryGetStakingRewardParticipantResponse = { + encode( + message: QueryGetStakingRewardParticipantResponse, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.list) { + StakingRewardParticipant.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode( + message.pagination, + writer.uint32(18).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryGetStakingRewardParticipantResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryGetStakingRewardParticipantResponse, + } as QueryGetStakingRewardParticipantResponse; + message.list = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.list.push( + StakingRewardParticipant.decode(reader, reader.uint32()) + ); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryGetStakingRewardParticipantResponse { + const message = { + ...baseQueryGetStakingRewardParticipantResponse, + } as QueryGetStakingRewardParticipantResponse; + message.list = []; + if (object.list !== undefined && object.list !== null) { + for (const e of object.list) { + message.list.push(StakingRewardParticipant.fromJSON(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryGetStakingRewardParticipantResponse): unknown { + const obj: any = {}; + if (message.list) { + obj.list = message.list.map((e) => + e ? StakingRewardParticipant.toJSON(e) : undefined + ); + } else { + obj.list = []; + } + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageResponse.toJSON(message.pagination) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryGetStakingRewardParticipantResponse { + const message = { + ...baseQueryGetStakingRewardParticipantResponse, + } as QueryGetStakingRewardParticipantResponse; + message.list = []; + if (object.list !== undefined && object.list !== null) { + for (const e of object.list) { + message.list.push(StakingRewardParticipant.fromPartial(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseQueryAllStakingRewardParticipantRequest: object = {}; + +export const QueryAllStakingRewardParticipantRequest = { + encode( + message: QueryAllStakingRewardParticipantRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryAllStakingRewardParticipantRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryAllStakingRewardParticipantRequest, + } as QueryAllStakingRewardParticipantRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryAllStakingRewardParticipantRequest { + const message = { + ...baseQueryAllStakingRewardParticipantRequest, + } as QueryAllStakingRewardParticipantRequest; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryAllStakingRewardParticipantRequest): unknown { + const obj: any = {}; + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageRequest.toJSON(message.pagination) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryAllStakingRewardParticipantRequest { + const message = { + ...baseQueryAllStakingRewardParticipantRequest, + } as QueryAllStakingRewardParticipantRequest; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseQueryAllStakingRewardParticipantResponse: object = {}; + +export const QueryAllStakingRewardParticipantResponse = { + encode( + message: QueryAllStakingRewardParticipantResponse, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.list) { + StakingRewardParticipant.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode( + message.pagination, + writer.uint32(18).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryAllStakingRewardParticipantResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryAllStakingRewardParticipantResponse, + } as QueryAllStakingRewardParticipantResponse; + message.list = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.list.push( + StakingRewardParticipant.decode(reader, reader.uint32()) + ); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryAllStakingRewardParticipantResponse { + const message = { + ...baseQueryAllStakingRewardParticipantResponse, + } as QueryAllStakingRewardParticipantResponse; + message.list = []; + if (object.list !== undefined && object.list !== null) { + for (const e of object.list) { + message.list.push(StakingRewardParticipant.fromJSON(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryAllStakingRewardParticipantResponse): unknown { + const obj: any = {}; + if (message.list) { + obj.list = message.list.map((e) => + e ? StakingRewardParticipant.toJSON(e) : undefined + ); + } else { + obj.list = []; + } + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageResponse.toJSON(message.pagination) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryAllStakingRewardParticipantResponse { + const message = { + ...baseQueryAllStakingRewardParticipantResponse, + } as QueryAllStakingRewardParticipantResponse; + message.list = []; + if (object.list !== undefined && object.list !== null) { + for (const e of object.list) { + message.list.push(StakingRewardParticipant.fromPartial(e)); } } if (object.pagination !== undefined && object.pagination !== null) { @@ -809,6 +1197,14 @@ export interface Query { TradingRewardAll( request: QueryAllTradingRewardRequest ): Promise; + /** Queries a StakingRewardParticipant by index. */ + StakingRewardParticipant( + request: QueryGetStakingRewardParticipantRequest + ): Promise; + /** Queries a list of StakingRewardParticipant items. */ + StakingRewardParticipantAll( + request: QueryAllStakingRewardParticipantRequest + ): Promise; } export class QueryClientImpl implements Query { @@ -877,6 +1273,38 @@ export class QueryClientImpl implements Query { QueryAllTradingRewardResponse.decode(new Reader(data)) ); } + + StakingRewardParticipant( + request: QueryGetStakingRewardParticipantRequest + ): Promise { + const data = QueryGetStakingRewardParticipantRequest.encode( + request + ).finish(); + const promise = this.rpc.request( + "bze.v1.rewards.Query", + "StakingRewardParticipant", + data + ); + return promise.then((data) => + QueryGetStakingRewardParticipantResponse.decode(new Reader(data)) + ); + } + + StakingRewardParticipantAll( + request: QueryAllStakingRewardParticipantRequest + ): Promise { + const data = QueryAllStakingRewardParticipantRequest.encode( + request + ).finish(); + const promise = this.rpc.request( + "bze.v1.rewards.Query", + "StakingRewardParticipantAll", + data + ); + return promise.then((data) => + QueryAllStakingRewardParticipantResponse.decode(new Reader(data)) + ); + } } interface Rpc { diff --git a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/staking_reward.ts b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/staking_reward.ts index ffdfe627..b568bcfd 100644 --- a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/staking_reward.ts +++ b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/staking_reward.ts @@ -13,6 +13,7 @@ export interface StakingReward { payouts: number; min_stake: number; lock: number; + staked_amount: string; } const baseStakingReward: object = { @@ -24,6 +25,7 @@ const baseStakingReward: object = { payouts: 0, min_stake: 0, lock: 0, + staked_amount: "", }; export const StakingReward = { @@ -52,6 +54,9 @@ export const StakingReward = { if (message.lock !== 0) { writer.uint32(64).uint32(message.lock); } + if (message.staked_amount !== "") { + writer.uint32(74).string(message.staked_amount); + } return writer; }, @@ -86,6 +91,9 @@ export const StakingReward = { case 8: message.lock = reader.uint32(); break; + case 9: + message.staked_amount = reader.string(); + break; default: reader.skipType(tag & 7); break; @@ -136,6 +144,11 @@ export const StakingReward = { } else { message.lock = 0; } + if (object.staked_amount !== undefined && object.staked_amount !== null) { + message.staked_amount = String(object.staked_amount); + } else { + message.staked_amount = ""; + } return message; }, @@ -152,6 +165,8 @@ export const StakingReward = { message.payouts !== undefined && (obj.payouts = message.payouts); message.min_stake !== undefined && (obj.min_stake = message.min_stake); message.lock !== undefined && (obj.lock = message.lock); + message.staked_amount !== undefined && + (obj.staked_amount = message.staked_amount); return obj; }, @@ -197,6 +212,11 @@ export const StakingReward = { } else { message.lock = 0; } + if (object.staked_amount !== undefined && object.staked_amount !== null) { + message.staked_amount = object.staked_amount; + } else { + message.staked_amount = ""; + } return message; }, }; diff --git a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/staking_reward_participant.ts b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/staking_reward_participant.ts new file mode 100644 index 00000000..c488825e --- /dev/null +++ b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/staking_reward_participant.ts @@ -0,0 +1,128 @@ +/* eslint-disable */ +import { Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "bze.v1.rewards"; + +export interface StakingRewardParticipant { + address: string; + reward_id: string; + amount: string; +} + +const baseStakingRewardParticipant: object = { + address: "", + reward_id: "", + amount: "", +}; + +export const StakingRewardParticipant = { + encode( + message: StakingRewardParticipant, + writer: Writer = Writer.create() + ): Writer { + if (message.address !== "") { + writer.uint32(10).string(message.address); + } + if (message.reward_id !== "") { + writer.uint32(18).string(message.reward_id); + } + if (message.amount !== "") { + writer.uint32(26).string(message.amount); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): StakingRewardParticipant { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseStakingRewardParticipant, + } as StakingRewardParticipant; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.address = reader.string(); + break; + case 2: + message.reward_id = reader.string(); + break; + case 3: + message.amount = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): StakingRewardParticipant { + const message = { + ...baseStakingRewardParticipant, + } as StakingRewardParticipant; + if (object.address !== undefined && object.address !== null) { + message.address = String(object.address); + } else { + message.address = ""; + } + if (object.reward_id !== undefined && object.reward_id !== null) { + message.reward_id = String(object.reward_id); + } else { + message.reward_id = ""; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = String(object.amount); + } else { + message.amount = ""; + } + return message; + }, + + toJSON(message: StakingRewardParticipant): unknown { + const obj: any = {}; + message.address !== undefined && (obj.address = message.address); + message.reward_id !== undefined && (obj.reward_id = message.reward_id); + message.amount !== undefined && (obj.amount = message.amount); + return obj; + }, + + fromPartial( + object: DeepPartial + ): StakingRewardParticipant { + const message = { + ...baseStakingRewardParticipant, + } as StakingRewardParticipant; + if (object.address !== undefined && object.address !== null) { + message.address = object.address; + } else { + message.address = ""; + } + if (object.reward_id !== undefined && object.reward_id !== null) { + message.reward_id = object.reward_id; + } else { + message.reward_id = ""; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = object.amount; + } else { + message.amount = ""; + } + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/tx.ts b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/tx.ts index edf19ada..8bf3c322 100644 --- a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/tx.ts +++ b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/tx.ts @@ -48,6 +48,21 @@ export interface MsgCreateTradingRewardResponse { reward_id: string; } +export interface MsgJoinStaking { + creator: string; + reward_id: string; + amount: string; +} + +export interface MsgJoinStakingResponse {} + +export interface MsgExitStaking { + creator: string; + rewardId: string; +} + +export interface MsgExitStakingResponse {} + const baseMsgCreateStakingReward: object = { creator: "", prize_amount: "", @@ -663,6 +678,243 @@ export const MsgCreateTradingRewardResponse = { }, }; +const baseMsgJoinStaking: object = { creator: "", reward_id: "", amount: "" }; + +export const MsgJoinStaking = { + encode(message: MsgJoinStaking, writer: Writer = Writer.create()): Writer { + if (message.creator !== "") { + writer.uint32(10).string(message.creator); + } + if (message.reward_id !== "") { + writer.uint32(18).string(message.reward_id); + } + if (message.amount !== "") { + writer.uint32(26).string(message.amount); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MsgJoinStaking { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgJoinStaking } as MsgJoinStaking; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.creator = reader.string(); + break; + case 2: + message.reward_id = reader.string(); + break; + case 3: + message.amount = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgJoinStaking { + const message = { ...baseMsgJoinStaking } as MsgJoinStaking; + if (object.creator !== undefined && object.creator !== null) { + message.creator = String(object.creator); + } else { + message.creator = ""; + } + if (object.reward_id !== undefined && object.reward_id !== null) { + message.reward_id = String(object.reward_id); + } else { + message.reward_id = ""; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = String(object.amount); + } else { + message.amount = ""; + } + return message; + }, + + toJSON(message: MsgJoinStaking): unknown { + const obj: any = {}; + message.creator !== undefined && (obj.creator = message.creator); + message.reward_id !== undefined && (obj.reward_id = message.reward_id); + message.amount !== undefined && (obj.amount = message.amount); + return obj; + }, + + fromPartial(object: DeepPartial): MsgJoinStaking { + const message = { ...baseMsgJoinStaking } as MsgJoinStaking; + if (object.creator !== undefined && object.creator !== null) { + message.creator = object.creator; + } else { + message.creator = ""; + } + if (object.reward_id !== undefined && object.reward_id !== null) { + message.reward_id = object.reward_id; + } else { + message.reward_id = ""; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = object.amount; + } else { + message.amount = ""; + } + return message; + }, +}; + +const baseMsgJoinStakingResponse: object = {}; + +export const MsgJoinStakingResponse = { + encode(_: MsgJoinStakingResponse, writer: Writer = Writer.create()): Writer { + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MsgJoinStakingResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgJoinStakingResponse } as MsgJoinStakingResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): MsgJoinStakingResponse { + const message = { ...baseMsgJoinStakingResponse } as MsgJoinStakingResponse; + return message; + }, + + toJSON(_: MsgJoinStakingResponse): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial(_: DeepPartial): MsgJoinStakingResponse { + const message = { ...baseMsgJoinStakingResponse } as MsgJoinStakingResponse; + return message; + }, +}; + +const baseMsgExitStaking: object = { creator: "", rewardId: "" }; + +export const MsgExitStaking = { + encode(message: MsgExitStaking, writer: Writer = Writer.create()): Writer { + if (message.creator !== "") { + writer.uint32(10).string(message.creator); + } + if (message.rewardId !== "") { + writer.uint32(18).string(message.rewardId); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MsgExitStaking { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgExitStaking } as MsgExitStaking; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.creator = reader.string(); + break; + case 2: + message.rewardId = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgExitStaking { + const message = { ...baseMsgExitStaking } as MsgExitStaking; + if (object.creator !== undefined && object.creator !== null) { + message.creator = String(object.creator); + } else { + message.creator = ""; + } + if (object.rewardId !== undefined && object.rewardId !== null) { + message.rewardId = String(object.rewardId); + } else { + message.rewardId = ""; + } + return message; + }, + + toJSON(message: MsgExitStaking): unknown { + const obj: any = {}; + message.creator !== undefined && (obj.creator = message.creator); + message.rewardId !== undefined && (obj.rewardId = message.rewardId); + return obj; + }, + + fromPartial(object: DeepPartial): MsgExitStaking { + const message = { ...baseMsgExitStaking } as MsgExitStaking; + if (object.creator !== undefined && object.creator !== null) { + message.creator = object.creator; + } else { + message.creator = ""; + } + if (object.rewardId !== undefined && object.rewardId !== null) { + message.rewardId = object.rewardId; + } else { + message.rewardId = ""; + } + return message; + }, +}; + +const baseMsgExitStakingResponse: object = {}; + +export const MsgExitStakingResponse = { + encode(_: MsgExitStakingResponse, writer: Writer = Writer.create()): Writer { + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MsgExitStakingResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgExitStakingResponse } as MsgExitStakingResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): MsgExitStakingResponse { + const message = { ...baseMsgExitStakingResponse } as MsgExitStakingResponse; + return message; + }, + + toJSON(_: MsgExitStakingResponse): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial(_: DeepPartial): MsgExitStakingResponse { + const message = { ...baseMsgExitStakingResponse } as MsgExitStakingResponse; + return message; + }, +}; + /** Msg defines the Msg service. */ export interface Msg { CreateStakingReward( @@ -671,10 +923,12 @@ export interface Msg { UpdateStakingReward( request: MsgUpdateStakingReward ): Promise; - /** this line is used by starport scaffolding # proto/tx/rpc */ CreateTradingReward( request: MsgCreateTradingReward ): Promise; + JoinStaking(request: MsgJoinStaking): Promise; + /** this line is used by starport scaffolding # proto/tx/rpc */ + ExitStaking(request: MsgExitStaking): Promise; } export class MsgClientImpl implements Msg { @@ -723,6 +977,22 @@ export class MsgClientImpl implements Msg { MsgCreateTradingRewardResponse.decode(new Reader(data)) ); } + + JoinStaking(request: MsgJoinStaking): Promise { + const data = MsgJoinStaking.encode(request).finish(); + const promise = this.rpc.request("bze.v1.rewards.Msg", "JoinStaking", data); + return promise.then((data) => + MsgJoinStakingResponse.decode(new Reader(data)) + ); + } + + ExitStaking(request: MsgExitStaking): Promise { + const data = MsgExitStaking.encode(request).finish(); + const promise = this.rpc.request("bze.v1.rewards.Msg", "ExitStaking", data); + return promise.then((data) => + MsgExitStakingResponse.decode(new Reader(data)) + ); + } } interface Rpc { diff --git a/x/rewards/client/cli/query.go b/x/rewards/client/cli/query.go index 1cf312c7..834f8f3e 100644 --- a/x/rewards/client/cli/query.go +++ b/x/rewards/client/cli/query.go @@ -29,6 +29,8 @@ func GetQueryCmd(queryRoute string) *cobra.Command { cmd.AddCommand(CmdShowStakingReward()) cmd.AddCommand(CmdListTradingReward()) cmd.AddCommand(CmdShowTradingReward()) + cmd.AddCommand(CmdListStakingRewardParticipant()) + cmd.AddCommand(CmdShowStakingRewardParticipant()) // this line is used by starport scaffolding # 1 return cmd diff --git a/x/rewards/client/cli/query_staking_reward.go b/x/rewards/client/cli/query_staking_reward.go index d11d1ecd..3a9ad149 100644 --- a/x/rewards/client/cli/query_staking_reward.go +++ b/x/rewards/client/cli/query_staking_reward.go @@ -1,12 +1,12 @@ package cli import ( - "context" - - "github.com/spf13/cobra" + "context" + + "github.com/bze-alphateam/bze/x/rewards/types" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" - "github.com/bze-alphateam/bze/x/rewards/types" + "github.com/spf13/cobra" ) func CmdListStakingReward() *cobra.Command { @@ -14,32 +14,32 @@ func CmdListStakingReward() *cobra.Command { Use: "list-staking-reward", Short: "list all StakingReward", RunE: func(cmd *cobra.Command, args []string) error { - clientCtx := client.GetClientContextFromCmd(cmd) + clientCtx := client.GetClientContextFromCmd(cmd) - pageReq, err := client.ReadPageRequest(cmd.Flags()) - if err != nil { - return err - } + pageReq, err := client.ReadPageRequest(cmd.Flags()) + if err != nil { + return err + } - queryClient := types.NewQueryClient(clientCtx) + queryClient := types.NewQueryClient(clientCtx) - params := &types.QueryAllStakingRewardRequest{ - Pagination: pageReq, - } + params := &types.QueryAllStakingRewardRequest{ + Pagination: pageReq, + } - res, err := queryClient.StakingRewardAll(context.Background(), params) - if err != nil { - return err - } + res, err := queryClient.StakingRewardAll(context.Background(), params) + if err != nil { + return err + } - return clientCtx.PrintProto(res) + return clientCtx.PrintProto(res) }, } flags.AddPaginationFlagsToCmd(cmd, cmd.Use) flags.AddQueryFlagsToCmd(cmd) - return cmd + return cmd } func CmdShowStakingReward() *cobra.Command { @@ -48,27 +48,26 @@ func CmdShowStakingReward() *cobra.Command { Short: "shows a StakingReward", Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) (err error) { - clientCtx := client.GetClientContextFromCmd(cmd) + clientCtx := client.GetClientContextFromCmd(cmd) + + queryClient := types.NewQueryClient(clientCtx) - queryClient := types.NewQueryClient(clientCtx) + argRewardId := args[0] - argRewardId := args[0] - - params := &types.QueryGetStakingRewardRequest{ - RewardId: argRewardId, - - } + params := &types.QueryGetStakingRewardRequest{ + RewardId: argRewardId, + } - res, err := queryClient.StakingReward(context.Background(), params) - if err != nil { - return err - } + res, err := queryClient.StakingReward(context.Background(), params) + if err != nil { + return err + } - return clientCtx.PrintProto(res) + return clientCtx.PrintProto(res) }, } flags.AddQueryFlagsToCmd(cmd) - return cmd + return cmd } diff --git a/x/rewards/client/cli/query_staking_reward_participant.go b/x/rewards/client/cli/query_staking_reward_participant.go new file mode 100644 index 00000000..ee12a4cb --- /dev/null +++ b/x/rewards/client/cli/query_staking_reward_participant.go @@ -0,0 +1,79 @@ +package cli + +import ( + "context" + + "github.com/bze-alphateam/bze/x/rewards/types" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/spf13/cobra" +) + +func CmdListStakingRewardParticipant() *cobra.Command { + cmd := &cobra.Command{ + Use: "staking-reward-participants", + Short: "list all StakingRewardParticipant", + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx := client.GetClientContextFromCmd(cmd) + + pageReq, err := client.ReadPageRequest(cmd.Flags()) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + + params := &types.QueryAllStakingRewardParticipantRequest{ + Pagination: pageReq, + } + + res, err := queryClient.StakingRewardParticipantAll(context.Background(), params) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddPaginationFlagsToCmd(cmd, cmd.Use) + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} + +func CmdShowStakingRewardParticipant() *cobra.Command { + cmd := &cobra.Command{ + Use: "staking-reward-participant [address]", + Short: "shows a StakingRewardParticipant", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) (err error) { + clientCtx := client.GetClientContextFromCmd(cmd) + + pageReq, err := client.ReadPageRequest(cmd.Flags()) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + + argIndex := args[0] + + params := &types.QueryGetStakingRewardParticipantRequest{ + Address: argIndex, + Pagination: pageReq, + } + + res, err := queryClient.StakingRewardParticipant(context.Background(), params) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/rewards/client/cli/query_staking_reward_participant_test.go b/x/rewards/client/cli/query_staking_reward_participant_test.go new file mode 100644 index 00000000..c3807bcb --- /dev/null +++ b/x/rewards/client/cli/query_staking_reward_participant_test.go @@ -0,0 +1,161 @@ +package cli_test + +import ( + "fmt" + "strconv" + "testing" + + "github.com/cosmos/cosmos-sdk/client/flags" + clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" + "github.com/stretchr/testify/require" + tmcli "github.com/tendermint/tendermint/libs/cli" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + + "github.com/bze-alphateam/bze/testutil/network" + "github.com/bze-alphateam/bze/testutil/nullify" + "github.com/bze-alphateam/bze/x/rewards/client/cli" + "github.com/bze-alphateam/bze/x/rewards/types" +) + +// Prevent strconv unused error +var _ = strconv.IntSize + +func networkWithStakingRewardParticipantObjects(t *testing.T, n int) (*network.Network, []types.StakingRewardParticipant) { + t.Helper() + cfg := network.DefaultConfig() + state := types.GenesisState{} + require.NoError(t, cfg.Codec.UnmarshalJSON(cfg.GenesisState[types.ModuleName], &state)) + + for i := 0; i < n; i++ { + stakingRewardParticipant := types.StakingRewardParticipant{ + Index: strconv.Itoa(i), + } + nullify.Fill(&stakingRewardParticipant) + state.StakingRewardParticipantList = append(state.StakingRewardParticipantList, stakingRewardParticipant) + } + buf, err := cfg.Codec.MarshalJSON(&state) + require.NoError(t, err) + cfg.GenesisState[types.ModuleName] = buf + return network.New(t, cfg), state.StakingRewardParticipantList +} + +func TestShowStakingRewardParticipant(t *testing.T) { + net, objs := networkWithStakingRewardParticipantObjects(t, 2) + + ctx := net.Validators[0].ClientCtx + common := []string{ + fmt.Sprintf("--%s=json", tmcli.OutputFlag), + } + for _, tc := range []struct { + desc string + idIndex string + + args []string + err error + obj types.StakingRewardParticipant + }{ + { + desc: "found", + idIndex: objs[0].Index, + + args: common, + obj: objs[0], + }, + { + desc: "not found", + idIndex: strconv.Itoa(100000), + + args: common, + err: status.Error(codes.NotFound, "not found"), + }, + } { + t.Run(tc.desc, func(t *testing.T) { + args := []string{ + tc.idIndex, + } + args = append(args, tc.args...) + out, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdShowStakingRewardParticipant(), args) + if tc.err != nil { + stat, ok := status.FromError(tc.err) + require.True(t, ok) + require.ErrorIs(t, stat.Err(), tc.err) + } else { + require.NoError(t, err) + var resp types.QueryGetStakingRewardParticipantResponse + require.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp)) + require.NotNil(t, resp.StakingRewardParticipant) + require.Equal(t, + nullify.Fill(&tc.obj), + nullify.Fill(&resp.StakingRewardParticipant), + ) + } + }) + } +} + +func TestListStakingRewardParticipant(t *testing.T) { + net, objs := networkWithStakingRewardParticipantObjects(t, 5) + + ctx := net.Validators[0].ClientCtx + request := func(next []byte, offset, limit uint64, total bool) []string { + args := []string{ + fmt.Sprintf("--%s=json", tmcli.OutputFlag), + } + if next == nil { + args = append(args, fmt.Sprintf("--%s=%d", flags.FlagOffset, offset)) + } else { + args = append(args, fmt.Sprintf("--%s=%s", flags.FlagPageKey, next)) + } + args = append(args, fmt.Sprintf("--%s=%d", flags.FlagLimit, limit)) + if total { + args = append(args, fmt.Sprintf("--%s", flags.FlagCountTotal)) + } + return args + } + t.Run("ByOffset", func(t *testing.T) { + step := 2 + for i := 0; i < len(objs); i += step { + args := request(nil, uint64(i), uint64(step), false) + out, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdListStakingRewardParticipant(), args) + require.NoError(t, err) + var resp types.QueryAllStakingRewardParticipantResponse + require.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp)) + require.LessOrEqual(t, len(resp.StakingRewardParticipant), step) + require.Subset(t, + nullify.Fill(objs), + nullify.Fill(resp.StakingRewardParticipant), + ) + } + }) + t.Run("ByKey", func(t *testing.T) { + step := 2 + var next []byte + for i := 0; i < len(objs); i += step { + args := request(next, 0, uint64(step), false) + out, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdListStakingRewardParticipant(), args) + require.NoError(t, err) + var resp types.QueryAllStakingRewardParticipantResponse + require.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp)) + require.LessOrEqual(t, len(resp.StakingRewardParticipant), step) + require.Subset(t, + nullify.Fill(objs), + nullify.Fill(resp.StakingRewardParticipant), + ) + next = resp.Pagination.NextKey + } + }) + t.Run("Total", func(t *testing.T) { + args := request(nil, 0, uint64(len(objs)), true) + out, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdListStakingRewardParticipant(), args) + require.NoError(t, err) + var resp types.QueryAllStakingRewardParticipantResponse + require.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp)) + require.NoError(t, err) + require.Equal(t, len(objs), int(resp.Pagination.Total)) + require.ElementsMatch(t, + nullify.Fill(objs), + nullify.Fill(resp.StakingRewardParticipant), + ) + }) +} diff --git a/x/rewards/client/cli/query_staking_reward_test.go b/x/rewards/client/cli/query_staking_reward_test.go index 7fb899fb..c8d02273 100644 --- a/x/rewards/client/cli/query_staking_reward_test.go +++ b/x/rewards/client/cli/query_staking_reward_test.go @@ -15,7 +15,7 @@ import ( "github.com/bze-alphateam/bze/testutil/network" "github.com/bze-alphateam/bze/testutil/nullify" "github.com/bze-alphateam/bze/x/rewards/client/cli" - "github.com/bze-alphateam/bze/x/rewards/types" + "github.com/bze-alphateam/bze/x/rewards/types" ) // Prevent strconv unused error @@ -25,12 +25,11 @@ func networkWithStakingRewardObjects(t *testing.T, n int) (*network.Network, []t t.Helper() cfg := network.DefaultConfig() state := types.GenesisState{} - require.NoError(t, cfg.Codec.UnmarshalJSON(cfg.GenesisState[types.ModuleName], &state)) + require.NoError(t, cfg.Codec.UnmarshalJSON(cfg.GenesisState[types.ModuleName], &state)) for i := 0; i < n; i++ { stakingReward := types.StakingReward{ RewardId: strconv.Itoa(i), - } nullify.Fill(&stakingReward) state.StakingRewardList = append(state.StakingRewardList, stakingReward) @@ -49,32 +48,31 @@ func TestShowStakingReward(t *testing.T) { fmt.Sprintf("--%s=json", tmcli.OutputFlag), } for _, tc := range []struct { - desc string + desc string idRewardId string - + args []string err error obj types.StakingReward }{ { - desc: "found", + desc: "found", idRewardId: objs[0].RewardId, - + args: common, obj: objs[0], }, { - desc: "not found", + desc: "not found", idRewardId: strconv.Itoa(100000), - + args: common, err: status.Error(codes.NotFound, "not found"), }, } { t.Run(tc.desc, func(t *testing.T) { args := []string{ - tc.idRewardId, - + tc.idRewardId, } args = append(args, tc.args...) out, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdShowStakingReward(), args) @@ -125,9 +123,9 @@ func TestListStakingReward(t *testing.T) { require.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp)) require.LessOrEqual(t, len(resp.StakingReward), step) require.Subset(t, - nullify.Fill(objs), - nullify.Fill(resp.StakingReward), - ) + nullify.Fill(objs), + nullify.Fill(resp.StakingReward), + ) } }) t.Run("ByKey", func(t *testing.T) { @@ -141,9 +139,9 @@ func TestListStakingReward(t *testing.T) { require.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp)) require.LessOrEqual(t, len(resp.StakingReward), step) require.Subset(t, - nullify.Fill(objs), - nullify.Fill(resp.StakingReward), - ) + nullify.Fill(objs), + nullify.Fill(resp.StakingReward), + ) next = resp.Pagination.NextKey } }) diff --git a/x/rewards/client/cli/query_trading_reward_test.go b/x/rewards/client/cli/query_trading_reward_test.go index 9596b03e..8aed6bea 100644 --- a/x/rewards/client/cli/query_trading_reward_test.go +++ b/x/rewards/client/cli/query_trading_reward_test.go @@ -15,7 +15,7 @@ import ( "github.com/bze-alphateam/bze/testutil/network" "github.com/bze-alphateam/bze/testutil/nullify" "github.com/bze-alphateam/bze/x/rewards/client/cli" - "github.com/bze-alphateam/bze/x/rewards/types" + "github.com/bze-alphateam/bze/x/rewards/types" ) // Prevent strconv unused error @@ -25,12 +25,11 @@ func networkWithTradingRewardObjects(t *testing.T, n int) (*network.Network, []t t.Helper() cfg := network.DefaultConfig() state := types.GenesisState{} - require.NoError(t, cfg.Codec.UnmarshalJSON(cfg.GenesisState[types.ModuleName], &state)) + require.NoError(t, cfg.Codec.UnmarshalJSON(cfg.GenesisState[types.ModuleName], &state)) for i := 0; i < n; i++ { tradingReward := types.TradingReward{ RewardId: strconv.Itoa(i), - } nullify.Fill(&tradingReward) state.TradingRewardList = append(state.TradingRewardList, tradingReward) @@ -49,32 +48,31 @@ func TestShowTradingReward(t *testing.T) { fmt.Sprintf("--%s=json", tmcli.OutputFlag), } for _, tc := range []struct { - desc string + desc string idRewardId string - + args []string err error obj types.TradingReward }{ { - desc: "found", + desc: "found", idRewardId: objs[0].RewardId, - + args: common, obj: objs[0], }, { - desc: "not found", + desc: "not found", idRewardId: strconv.Itoa(100000), - + args: common, err: status.Error(codes.NotFound, "not found"), }, } { t.Run(tc.desc, func(t *testing.T) { args := []string{ - tc.idRewardId, - + tc.idRewardId, } args = append(args, tc.args...) out, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdShowTradingReward(), args) @@ -125,9 +123,9 @@ func TestListTradingReward(t *testing.T) { require.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp)) require.LessOrEqual(t, len(resp.TradingReward), step) require.Subset(t, - nullify.Fill(objs), - nullify.Fill(resp.TradingReward), - ) + nullify.Fill(objs), + nullify.Fill(resp.TradingReward), + ) } }) t.Run("ByKey", func(t *testing.T) { @@ -141,9 +139,9 @@ func TestListTradingReward(t *testing.T) { require.NoError(t, net.Config.Codec.UnmarshalJSON(out.Bytes(), &resp)) require.LessOrEqual(t, len(resp.TradingReward), step) require.Subset(t, - nullify.Fill(objs), - nullify.Fill(resp.TradingReward), - ) + nullify.Fill(objs), + nullify.Fill(resp.TradingReward), + ) next = resp.Pagination.NextKey } }) diff --git a/x/rewards/client/cli/tx.go b/x/rewards/client/cli/tx.go index 6ba19c62..83f0d451 100644 --- a/x/rewards/client/cli/tx.go +++ b/x/rewards/client/cli/tx.go @@ -33,6 +33,8 @@ func GetTxCmd() *cobra.Command { cmd.AddCommand(CmdCreateStakingReward()) cmd.AddCommand(CmdUpdateStakingReward()) cmd.AddCommand(CmdCreateTradingReward()) + cmd.AddCommand(CmdJoinStaking()) + cmd.AddCommand(CmdExitStaking()) // this line is used by starport scaffolding # 1 return cmd diff --git a/x/rewards/client/cli/tx_exit_staking.go b/x/rewards/client/cli/tx_exit_staking.go new file mode 100644 index 00000000..00232d6f --- /dev/null +++ b/x/rewards/client/cli/tx_exit_staking.go @@ -0,0 +1,42 @@ +package cli + +import ( + "strconv" + + "github.com/bze-alphateam/bze/x/rewards/types" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/client/tx" + "github.com/spf13/cobra" +) + +var _ = strconv.Itoa(0) + +func CmdExitStaking() *cobra.Command { + cmd := &cobra.Command{ + Use: "exit-staking [reward-id]", + Short: "Broadcast message ExitStaking", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) (err error) { + argRewardId := args[0] + + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + msg := types.NewMsgExitStaking( + clientCtx.GetFromAddress().String(), + argRewardId, + ) + if err := msg.ValidateBasic(); err != nil { + return err + } + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} diff --git a/x/rewards/client/cli/tx_join_staking.go b/x/rewards/client/cli/tx_join_staking.go new file mode 100644 index 00000000..f40c4d79 --- /dev/null +++ b/x/rewards/client/cli/tx_join_staking.go @@ -0,0 +1,44 @@ +package cli + +import ( + "strconv" + + "github.com/bze-alphateam/bze/x/rewards/types" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/client/tx" + "github.com/spf13/cobra" +) + +var _ = strconv.Itoa(0) + +func CmdJoinStaking() *cobra.Command { + cmd := &cobra.Command{ + Use: "join-staking [reward-id] [amount]", + Short: "Broadcast message JoinStaking", + Args: cobra.ExactArgs(2), + RunE: func(cmd *cobra.Command, args []string) (err error) { + argRewardId := args[0] + argAmount := args[1] + + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + msg := types.NewMsgJoinStaking( + clientCtx.GetFromAddress().String(), + argRewardId, + argAmount, + ) + if err := msg.ValidateBasic(); err != nil { + return err + } + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} diff --git a/x/rewards/client/cli/tx_staking_reward_test.go b/x/rewards/client/cli/tx_staking_reward_test.go index a907f5d4..efb08fa2 100644 --- a/x/rewards/client/cli/tx_staking_reward_test.go +++ b/x/rewards/client/cli/tx_staking_reward_test.go @@ -2,7 +2,7 @@ package cli_test import ( "fmt" - "strconv" + "strconv" "testing" "github.com/cosmos/cosmos-sdk/client/flags" @@ -23,18 +23,18 @@ func TestCreateStakingReward(t *testing.T) { val := net.Validators[0] ctx := val.ClientCtx - fields := []string{ "xyz", "xyz", "xyz", "xyz", "xyz", } + fields := []string{"xyz", "xyz", "xyz", "xyz", "xyz"} for _, tc := range []struct { - desc string - idRewardId string - + desc string + idRewardId string + args []string err error code uint32 }{ { - idRewardId: strconv.Itoa(0), - + idRewardId: strconv.Itoa(0), + desc: "valid", args: []string{ fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), @@ -45,12 +45,11 @@ func TestCreateStakingReward(t *testing.T) { }, } { t.Run(tc.desc, func(t *testing.T) { - args := []string{ - tc.idRewardId, - - } - args = append(args, fields...) - args = append(args, tc.args...) + args := []string{ + tc.idRewardId, + } + args = append(args, fields...) + args = append(args, tc.args...) out, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdCreateStakingReward(), args) if tc.err != nil { require.ErrorIs(t, err, tc.err) @@ -69,51 +68,49 @@ func TestUpdateStakingReward(t *testing.T) { val := net.Validators[0] ctx := val.ClientCtx - fields := []string{ "xyz", "xyz", "xyz", "xyz", "xyz", } + fields := []string{"xyz", "xyz", "xyz", "xyz", "xyz"} common := []string{ fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(net.Config.BondDenom, sdk.NewInt(10))).String()), } - args := []string{ - "0", - - } + args := []string{ + "0", + } args = append(args, fields...) args = append(args, common...) _, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdCreateStakingReward(), args) require.NoError(t, err) for _, tc := range []struct { - desc string + desc string idRewardId string - + args []string code uint32 err error }{ { - desc: "valid", + desc: "valid", idRewardId: strconv.Itoa(0), - + args: common, }, { - desc: "key not found", + desc: "key not found", idRewardId: strconv.Itoa(100000), - + args: common, code: sdkerrors.ErrKeyNotFound.ABCICode(), }, } { t.Run(tc.desc, func(t *testing.T) { - args := []string{ - tc.idRewardId, - - } - args = append(args, fields...) - args = append(args, tc.args...) + args := []string{ + tc.idRewardId, + } + args = append(args, fields...) + args = append(args, tc.args...) out, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdUpdateStakingReward(), args) if tc.err != nil { require.ErrorIs(t, err, tc.err) @@ -133,50 +130,48 @@ func TestDeleteStakingReward(t *testing.T) { val := net.Validators[0] ctx := val.ClientCtx - fields := []string{ "xyz", "xyz", "xyz", "xyz", "xyz", } + fields := []string{"xyz", "xyz", "xyz", "xyz", "xyz"} common := []string{ fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(net.Config.BondDenom, sdk.NewInt(10))).String()), } - args := []string{ - "0", - - } + args := []string{ + "0", + } args = append(args, fields...) args = append(args, common...) _, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdCreateStakingReward(), args) require.NoError(t, err) for _, tc := range []struct { - desc string + desc string idRewardId string - + args []string code uint32 err error }{ { - desc: "valid", + desc: "valid", idRewardId: strconv.Itoa(0), - + args: common, }, { - desc: "key not found", + desc: "key not found", idRewardId: strconv.Itoa(100000), - + args: common, code: sdkerrors.ErrKeyNotFound.ABCICode(), }, } { t.Run(tc.desc, func(t *testing.T) { - args := []string{ - tc.idRewardId, - - } - args = append(args, tc.args...) + args := []string{ + tc.idRewardId, + } + args = append(args, tc.args...) out, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdDeleteStakingReward(), args) if tc.err != nil { require.ErrorIs(t, err, tc.err) diff --git a/x/rewards/client/cli/tx_trading_reward_test.go b/x/rewards/client/cli/tx_trading_reward_test.go index 8a693b0f..94935b96 100644 --- a/x/rewards/client/cli/tx_trading_reward_test.go +++ b/x/rewards/client/cli/tx_trading_reward_test.go @@ -2,7 +2,7 @@ package cli_test import ( "fmt" - "strconv" + "strconv" "testing" "github.com/cosmos/cosmos-sdk/client/flags" @@ -23,18 +23,18 @@ func TestCreateTradingReward(t *testing.T) { val := net.Validators[0] ctx := val.ClientCtx - fields := []string{ "111", "xyz", "111", "xyz", "xyz", } + fields := []string{"111", "xyz", "111", "xyz", "xyz"} for _, tc := range []struct { - desc string - idRewardId string - + desc string + idRewardId string + args []string err error code uint32 }{ { - idRewardId: strconv.Itoa(0), - + idRewardId: strconv.Itoa(0), + desc: "valid", args: []string{ fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), @@ -45,12 +45,11 @@ func TestCreateTradingReward(t *testing.T) { }, } { t.Run(tc.desc, func(t *testing.T) { - args := []string{ - tc.idRewardId, - - } - args = append(args, fields...) - args = append(args, tc.args...) + args := []string{ + tc.idRewardId, + } + args = append(args, fields...) + args = append(args, tc.args...) out, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdCreateTradingReward(), args) if tc.err != nil { require.ErrorIs(t, err, tc.err) @@ -69,51 +68,49 @@ func TestUpdateTradingReward(t *testing.T) { val := net.Validators[0] ctx := val.ClientCtx - fields := []string{ "111", "xyz", "111", "xyz", "xyz", } + fields := []string{"111", "xyz", "111", "xyz", "xyz"} common := []string{ fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(net.Config.BondDenom, sdk.NewInt(10))).String()), } - args := []string{ - "0", - - } + args := []string{ + "0", + } args = append(args, fields...) args = append(args, common...) _, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdCreateTradingReward(), args) require.NoError(t, err) for _, tc := range []struct { - desc string + desc string idRewardId string - + args []string code uint32 err error }{ { - desc: "valid", + desc: "valid", idRewardId: strconv.Itoa(0), - + args: common, }, { - desc: "key not found", + desc: "key not found", idRewardId: strconv.Itoa(100000), - + args: common, code: sdkerrors.ErrKeyNotFound.ABCICode(), }, } { t.Run(tc.desc, func(t *testing.T) { - args := []string{ - tc.idRewardId, - - } - args = append(args, fields...) - args = append(args, tc.args...) + args := []string{ + tc.idRewardId, + } + args = append(args, fields...) + args = append(args, tc.args...) out, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdUpdateTradingReward(), args) if tc.err != nil { require.ErrorIs(t, err, tc.err) @@ -133,50 +130,48 @@ func TestDeleteTradingReward(t *testing.T) { val := net.Validators[0] ctx := val.ClientCtx - fields := []string{ "111", "xyz", "111", "xyz", "xyz", } + fields := []string{"111", "xyz", "111", "xyz", "xyz"} common := []string{ fmt.Sprintf("--%s=%s", flags.FlagFrom, val.Address.String()), fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation), fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock), fmt.Sprintf("--%s=%s", flags.FlagFees, sdk.NewCoins(sdk.NewCoin(net.Config.BondDenom, sdk.NewInt(10))).String()), } - args := []string{ - "0", - - } + args := []string{ + "0", + } args = append(args, fields...) args = append(args, common...) _, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdCreateTradingReward(), args) require.NoError(t, err) for _, tc := range []struct { - desc string + desc string idRewardId string - + args []string code uint32 err error }{ { - desc: "valid", + desc: "valid", idRewardId: strconv.Itoa(0), - + args: common, }, { - desc: "key not found", + desc: "key not found", idRewardId: strconv.Itoa(100000), - + args: common, code: sdkerrors.ErrKeyNotFound.ABCICode(), }, } { t.Run(tc.desc, func(t *testing.T) { - args := []string{ - tc.idRewardId, - - } - args = append(args, tc.args...) + args := []string{ + tc.idRewardId, + } + args = append(args, tc.args...) out, err := clitestutil.ExecTestCLICmd(ctx, cli.CmdDeleteTradingReward(), args) if tc.err != nil { require.ErrorIs(t, err, tc.err) diff --git a/x/rewards/genesis.go b/x/rewards/genesis.go index bb141c5a..99208f34 100644 --- a/x/rewards/genesis.go +++ b/x/rewards/genesis.go @@ -18,6 +18,10 @@ func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) k.SetTradingReward(ctx, elem) } + // Set all the stakingRewardParticipant + for _, elem := range genState.StakingRewardParticipantList { + k.SetStakingRewardParticipant(ctx, elem) + } // this line is used by starport scaffolding # genesis/module/init k.SetParams(ctx, genState.Params) k.SetTradingRewardsCounter(ctx, genState.TradingRewardsCounter) @@ -33,6 +37,7 @@ func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState { genesis.StakingRewardsCounter = k.GetStakingRewardsCounter(ctx) genesis.TradingRewardsCounter = k.GetTradingRewardsCounter(ctx) genesis.TradingRewardList = k.GetAllTradingReward(ctx) + genesis.StakingRewardParticipantList = k.GetAllStakingRewardParticipant(ctx) // this line is used by starport scaffolding # genesis/module/export return genesis diff --git a/x/rewards/genesis_test.go b/x/rewards/genesis_test.go index 3ef75fa3..2b0d0779 100644 --- a/x/rewards/genesis_test.go +++ b/x/rewards/genesis_test.go @@ -15,22 +15,30 @@ func TestGenesis(t *testing.T) { Params: types.DefaultParams(), StakingRewardList: []types.StakingReward{ - { - RewardId: "0", -}, - { - RewardId: "1", -}, - }, - TradingRewardList: []types.TradingReward{ - { - RewardId: "0", -}, - { - RewardId: "1", -}, - }, - // this line is used by starport scaffolding # genesis/test/state + { + RewardId: "0", + }, + { + RewardId: "1", + }, + }, + TradingRewardList: []types.TradingReward{ + { + RewardId: "0", + }, + { + RewardId: "1", + }, + }, + StakingRewardParticipantList: []types.StakingRewardParticipant{ + { + Index: "0", + }, + { + Index: "1", + }, + }, + // this line is used by starport scaffolding # genesis/test/state } k, ctx := keepertest.RewardsKeeper(t) @@ -42,6 +50,7 @@ func TestGenesis(t *testing.T) { nullify.Fill(got) require.ElementsMatch(t, genesisState.StakingRewardList, got.StakingRewardList) -require.ElementsMatch(t, genesisState.TradingRewardList, got.TradingRewardList) -// this line is used by starport scaffolding # genesis/test/assert + require.ElementsMatch(t, genesisState.TradingRewardList, got.TradingRewardList) + require.ElementsMatch(t, genesisState.StakingRewardParticipantList, got.StakingRewardParticipantList) + // this line is used by starport scaffolding # genesis/test/assert } diff --git a/x/rewards/handler.go b/x/rewards/handler.go index aea4335b..720831d3 100644 --- a/x/rewards/handler.go +++ b/x/rewards/handler.go @@ -26,6 +26,12 @@ func NewHandler(k keeper.Keeper) sdk.Handler { case *types.MsgCreateTradingReward: res, err := msgServer.CreateTradingReward(sdk.WrapSDKContext(ctx), msg) return sdk.WrapServiceResult(ctx, res, err) + case *types.MsgJoinStaking: + res, err := msgServer.JoinStaking(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) + case *types.MsgExitStaking: + res, err := msgServer.ExitStaking(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) // this line is used by starport scaffolding # 1 default: errMsg := fmt.Sprintf("unrecognized %s message type: %T", types.ModuleName, msg) diff --git a/x/rewards/keeper/grpc_query_staking_reward_participant.go b/x/rewards/keeper/grpc_query_staking_reward_participant.go new file mode 100644 index 00000000..0f76c4f7 --- /dev/null +++ b/x/rewards/keeper/grpc_query_staking_reward_participant.go @@ -0,0 +1,67 @@ +package keeper + +import ( + "context" + + "github.com/bze-alphateam/bze/x/rewards/types" + "github.com/cosmos/cosmos-sdk/store/prefix" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/query" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +func (k Keeper) StakingRewardParticipantAll(c context.Context, req *types.QueryAllStakingRewardParticipantRequest) (*types.QueryAllStakingRewardParticipantResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + + var stakingRewardParticipants []types.StakingRewardParticipant + ctx := sdk.UnwrapSDKContext(c) + + store := ctx.KVStore(k.storeKey) + stakingRewardParticipantStore := prefix.NewStore(store, types.KeyPrefix(types.StakingRewardParticipantKeyPrefix)) + + pageRes, err := query.Paginate(stakingRewardParticipantStore, req.Pagination, func(key []byte, value []byte) error { + var stakingRewardParticipant types.StakingRewardParticipant + if err := k.cdc.Unmarshal(value, &stakingRewardParticipant); err != nil { + return err + } + + stakingRewardParticipants = append(stakingRewardParticipants, stakingRewardParticipant) + return nil + }) + + if err != nil { + return nil, status.Error(codes.Internal, err.Error()) + } + + return &types.QueryAllStakingRewardParticipantResponse{List: stakingRewardParticipants, Pagination: pageRes}, nil +} + +func (k Keeper) StakingRewardParticipant(c context.Context, req *types.QueryGetStakingRewardParticipantRequest) (*types.QueryGetStakingRewardParticipantResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + var list []types.StakingRewardParticipant + ctx := sdk.UnwrapSDKContext(c) + + store := ctx.KVStore(k.storeKey) + stakingRewardParticipantStore := prefix.NewStore(store, types.StakingRewardParticipantPrefix(req.Address)) + + pageRes, err := query.Paginate(stakingRewardParticipantStore, req.Pagination, func(key []byte, value []byte) error { + var stakingRewardParticipant types.StakingRewardParticipant + if err := k.cdc.Unmarshal(value, &stakingRewardParticipant); err != nil { + return err + } + + list = append(list, stakingRewardParticipant) + return nil + }) + + if err != nil { + return nil, status.Error(codes.Internal, err.Error()) + } + + return &types.QueryGetStakingRewardParticipantResponse{List: list, Pagination: pageRes}, nil +} diff --git a/x/rewards/keeper/grpc_query_staking_reward_participant_test.go b/x/rewards/keeper/grpc_query_staking_reward_participant_test.go new file mode 100644 index 00000000..b1b6d370 --- /dev/null +++ b/x/rewards/keeper/grpc_query_staking_reward_participant_test.go @@ -0,0 +1,126 @@ +package keeper_test + +import ( + "strconv" + "testing" + + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/query" + "github.com/stretchr/testify/require" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + + keepertest "github.com/bze-alphateam/bze/testutil/keeper" + "github.com/bze-alphateam/bze/testutil/nullify" + "github.com/bze-alphateam/bze/x/rewards/types" +) + +// Prevent strconv unused error +var _ = strconv.IntSize + +func TestStakingRewardParticipantQuerySingle(t *testing.T) { + keeper, ctx := keepertest.RewardsKeeper(t) + wctx := sdk.WrapSDKContext(ctx) + msgs := createNStakingRewardParticipant(keeper, ctx, 2) + for _, tc := range []struct { + desc string + request *types.QueryGetStakingRewardParticipantRequest + response *types.QueryGetStakingRewardParticipantResponse + err error + }{ + { + desc: "First", + request: &types.QueryGetStakingRewardParticipantRequest{ + Index: msgs[0].Index, + }, + response: &types.QueryGetStakingRewardParticipantResponse{StakingRewardParticipant: msgs[0]}, + }, + { + desc: "Second", + request: &types.QueryGetStakingRewardParticipantRequest{ + Index: msgs[1].Index, + }, + response: &types.QueryGetStakingRewardParticipantResponse{StakingRewardParticipant: msgs[1]}, + }, + { + desc: "KeyNotFound", + request: &types.QueryGetStakingRewardParticipantRequest{ + Index: strconv.Itoa(100000), + }, + err: status.Error(codes.NotFound, "not found"), + }, + { + desc: "InvalidRequest", + err: status.Error(codes.InvalidArgument, "invalid request"), + }, + } { + t.Run(tc.desc, func(t *testing.T) { + response, err := keeper.StakingRewardParticipant(wctx, tc.request) + if tc.err != nil { + require.ErrorIs(t, err, tc.err) + } else { + require.NoError(t, err) + require.Equal(t, + nullify.Fill(tc.response), + nullify.Fill(response), + ) + } + }) + } +} + +func TestStakingRewardParticipantQueryPaginated(t *testing.T) { + keeper, ctx := keepertest.RewardsKeeper(t) + wctx := sdk.WrapSDKContext(ctx) + msgs := createNStakingRewardParticipant(keeper, ctx, 5) + + request := func(next []byte, offset, limit uint64, total bool) *types.QueryAllStakingRewardParticipantRequest { + return &types.QueryAllStakingRewardParticipantRequest{ + Pagination: &query.PageRequest{ + Key: next, + Offset: offset, + Limit: limit, + CountTotal: total, + }, + } + } + t.Run("ByOffset", func(t *testing.T) { + step := 2 + for i := 0; i < len(msgs); i += step { + resp, err := keeper.StakingRewardParticipantAll(wctx, request(nil, uint64(i), uint64(step), false)) + require.NoError(t, err) + require.LessOrEqual(t, len(resp.StakingRewardParticipant), step) + require.Subset(t, + nullify.Fill(msgs), + nullify.Fill(resp.StakingRewardParticipant), + ) + } + }) + t.Run("ByKey", func(t *testing.T) { + step := 2 + var next []byte + for i := 0; i < len(msgs); i += step { + resp, err := keeper.StakingRewardParticipantAll(wctx, request(next, 0, uint64(step), false)) + require.NoError(t, err) + require.LessOrEqual(t, len(resp.StakingRewardParticipant), step) + require.Subset(t, + nullify.Fill(msgs), + nullify.Fill(resp.StakingRewardParticipant), + ) + next = resp.Pagination.NextKey + } + }) + t.Run("Total", func(t *testing.T) { + resp, err := keeper.StakingRewardParticipantAll(wctx, request(nil, 0, 0, true)) + require.NoError(t, err) + require.Equal(t, len(msgs), int(resp.Pagination.Total)) + require.ElementsMatch(t, + nullify.Fill(msgs), + nullify.Fill(resp.StakingRewardParticipant), + ) + }) + t.Run("InvalidRequest", func(t *testing.T) { + _, err := keeper.StakingRewardParticipantAll(wctx, nil) + require.ErrorIs(t, err, status.Error(codes.InvalidArgument, "invalid request")) + }) +} diff --git a/x/rewards/keeper/grpc_query_trading_reward.go b/x/rewards/keeper/grpc_query_trading_reward.go index 4abdd62c..05baa235 100644 --- a/x/rewards/keeper/grpc_query_trading_reward.go +++ b/x/rewards/keeper/grpc_query_trading_reward.go @@ -36,7 +36,7 @@ func (k Keeper) TradingRewardAll(c context.Context, req *types.QueryAllTradingRe return nil, status.Error(codes.Internal, err.Error()) } - return &types.QueryAllTradingRewardResponse{TradingReward: tradingRewards, Pagination: pageRes}, nil + return &types.QueryAllTradingRewardResponse{List: tradingRewards, Pagination: pageRes}, nil } func (k Keeper) TradingReward(c context.Context, req *types.QueryGetTradingRewardRequest) (*types.QueryGetTradingRewardResponse, error) { diff --git a/x/rewards/keeper/grpc_query_trading_reward_test.go b/x/rewards/keeper/grpc_query_trading_reward_test.go index 277f8098..3733af92 100644 --- a/x/rewards/keeper/grpc_query_trading_reward_test.go +++ b/x/rewards/keeper/grpc_query_trading_reward_test.go @@ -1,7 +1,7 @@ package keeper_test import ( - "strconv" + "strconv" "testing" sdk "github.com/cosmos/cosmos-sdk/types" @@ -10,9 +10,9 @@ import ( "google.golang.org/grpc/codes" "google.golang.org/grpc/status" - "github.com/bze-alphateam/bze/x/rewards/types" - "github.com/bze-alphateam/bze/testutil/nullify" keepertest "github.com/bze-alphateam/bze/testutil/keeper" + "github.com/bze-alphateam/bze/testutil/nullify" + "github.com/bze-alphateam/bze/x/rewards/types" ) // Prevent strconv unused error @@ -29,28 +29,25 @@ func TestTradingRewardQuerySingle(t *testing.T) { err error }{ { - desc: "First", - request: &types.QueryGetTradingRewardRequest{ - RewardId: msgs[0].RewardId, - + desc: "First", + request: &types.QueryGetTradingRewardRequest{ + RewardId: msgs[0].RewardId, }, response: &types.QueryGetTradingRewardResponse{TradingReward: msgs[0]}, }, { - desc: "Second", - request: &types.QueryGetTradingRewardRequest{ - RewardId: msgs[1].RewardId, - + desc: "Second", + request: &types.QueryGetTradingRewardRequest{ + RewardId: msgs[1].RewardId, }, response: &types.QueryGetTradingRewardResponse{TradingReward: msgs[1]}, }, { - desc: "KeyNotFound", + desc: "KeyNotFound", request: &types.QueryGetTradingRewardRequest{ - RewardId:strconv.Itoa(100000), - + RewardId: strconv.Itoa(100000), }, - err: status.Error(codes.NotFound, "not found"), + err: status.Error(codes.NotFound, "not found"), }, { desc: "InvalidRequest", @@ -94,9 +91,9 @@ func TestTradingRewardQueryPaginated(t *testing.T) { require.NoError(t, err) require.LessOrEqual(t, len(resp.TradingReward), step) require.Subset(t, - nullify.Fill(msgs), - nullify.Fill(resp.TradingReward), - ) + nullify.Fill(msgs), + nullify.Fill(resp.TradingReward), + ) } }) t.Run("ByKey", func(t *testing.T) { @@ -107,9 +104,9 @@ func TestTradingRewardQueryPaginated(t *testing.T) { require.NoError(t, err) require.LessOrEqual(t, len(resp.TradingReward), step) require.Subset(t, - nullify.Fill(msgs), - nullify.Fill(resp.TradingReward), - ) + nullify.Fill(msgs), + nullify.Fill(resp.TradingReward), + ) next = resp.Pagination.NextKey } }) diff --git a/x/rewards/keeper/keeper_test.go b/x/rewards/keeper/keeper_test.go index 91eebd2b..31dafdd5 100644 --- a/x/rewards/keeper/keeper_test.go +++ b/x/rewards/keeper/keeper_test.go @@ -11,8 +11,6 @@ import ( "time" ) -const someRandomAddress = "bze1m33n82r5x3eyjmjtwjkl82zzdlrnv8pevd8u9r" - type IntegrationTestSuite struct { suite.Suite diff --git a/x/rewards/keeper/msg_server_exit_staking.go b/x/rewards/keeper/msg_server_exit_staking.go new file mode 100644 index 00000000..6e66b812 --- /dev/null +++ b/x/rewards/keeper/msg_server_exit_staking.go @@ -0,0 +1,52 @@ +package keeper + +import ( + "context" + "fmt" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + + "github.com/bze-alphateam/bze/x/rewards/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +func (k msgServer) ExitStaking(goCtx context.Context, msg *types.MsgExitStaking) (*types.MsgExitStakingResponse, error) { + if msg == nil { + return nil, sdkerrors.ErrInvalidRequest + } + acc, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + return nil, err + } + + ctx := sdk.UnwrapSDKContext(goCtx) + stakingReward, found := k.GetStakingReward(ctx, msg.RewardId) + if !found { + return nil, sdkerrors.Wrapf(types.ErrInvalidRewardId, "reward with provided id not found") + } + + participation, found := k.GetStakingRewardParticipant(ctx, msg.Creator, msg.RewardId) + if !found { + return nil, sdkerrors.Wrapf(types.ErrInvalidRewardId, "you are not a participant in this staking reward") + } + + partCoins, err := k.getAmountToCapture("", stakingReward.StakingDenom, participation.Amount, int64(1)) + if err != nil { + return nil, err + } + stakedAmountInt, ok := sdk.NewIntFromString(stakingReward.StakedAmount) + if !ok { + return nil, fmt.Errorf("could not transform amount from storage into int") + } + + //TODO: Pay pending rewards here + err = k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, acc, partCoins) + if err != nil { + return nil, err + } + + k.RemoveStakingRewardParticipant(ctx, participation.Address, participation.RewardId) + stakingReward.StakedAmount = stakedAmountInt.Sub(partCoins.AmountOf(stakingReward.StakingDenom)).String() + k.SetStakingReward(ctx, stakingReward) + + return &types.MsgExitStakingResponse{}, nil +} diff --git a/x/rewards/keeper/msg_server_join_staking.go b/x/rewards/keeper/msg_server_join_staking.go new file mode 100644 index 00000000..c9abf101 --- /dev/null +++ b/x/rewards/keeper/msg_server_join_staking.go @@ -0,0 +1,74 @@ +package keeper + +import ( + "context" + "fmt" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + + "github.com/bze-alphateam/bze/x/rewards/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +func (k msgServer) JoinStaking(goCtx context.Context, msg *types.MsgJoinStaking) (*types.MsgJoinStakingResponse, error) { + if msg == nil { + return nil, sdkerrors.ErrInvalidRequest + } + acc, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + return nil, err + } + + ctx := sdk.UnwrapSDKContext(goCtx) + stakingReward, found := k.GetStakingReward(ctx, msg.RewardId) + if !found { + return nil, sdkerrors.Wrapf(types.ErrInvalidRewardId, "reward with provided id not found") + } + + stakedAmount := sdk.NewInt(int64(0)) + if stakingReward.StakedAmount != "" { + ok := false + stakedAmount, ok = sdk.NewIntFromString(stakingReward.StakedAmount) + if !ok { + return nil, fmt.Errorf("could not transform staked amount from storage into int") + } + } + + toCapture, err := k.getAmountToCapture("", stakingReward.StakingDenom, msg.Amount, int64(1)) + if err != nil { + return nil, err + } + + if err = k.checkUserBalances(ctx, toCapture, acc); err != nil { + return nil, err + } + + participant, found := k.GetStakingRewardParticipant(ctx, msg.Creator, msg.RewardId) + if found { + //TODO: claim already pending rewards here + } else { + participant = types.StakingRewardParticipant{ + Address: msg.Creator, + RewardId: msg.RewardId, + Amount: "0", + } + } + + amtInt, ok := sdk.NewIntFromString(participant.Amount) + if !ok { + return nil, fmt.Errorf("could not transform amount from storage into int") + } + amtInt = amtInt.Add(toCapture.AmountOf(stakingReward.StakingDenom)) + participant.Amount = amtInt.String() + + stakedAmount = stakedAmount.Add(toCapture.AmountOf(stakingReward.StakingDenom)) + stakingReward.StakedAmount = stakedAmount.String() + + err = k.bankKeeper.SendCoinsFromAccountToModule(ctx, acc, types.ModuleName, toCapture) + if err != nil { + return nil, err + } + k.SetStakingRewardParticipant(ctx, participant) + k.SetStakingReward(ctx, stakingReward) + + return &types.MsgJoinStakingResponse{}, nil +} diff --git a/x/rewards/keeper/msg_server_trading_reward.go b/x/rewards/keeper/msg_server_trading_reward.go index c7b3ef05..15433927 100644 --- a/x/rewards/keeper/msg_server_trading_reward.go +++ b/x/rewards/keeper/msg_server_trading_reward.go @@ -69,14 +69,14 @@ func (k msgServer) checkUserBalances(ctx sdk.Context, neededCoins sdk.Coins, add return nil } -func (k msgServer) getAmountToCapture(feeParam, denom, amount string, prizeMultiplier int64) (sdk.Coins, error) { +func (k msgServer) getAmountToCapture(feeParam, denom, amount string, multiplier int64) (sdk.Coins, error) { amtInt, ok := sdk.NewIntFromString(amount) if !ok { return nil, fmt.Errorf("could not convert povided amount to int: %s", amount) } toCapture := sdk.NewCoin(denom, amtInt) - toCapture.Amount = toCapture.Amount.MulRaw(prizeMultiplier) + toCapture.Amount = toCapture.Amount.MulRaw(multiplier) if !toCapture.IsPositive() { //should never happen return nil, fmt.Errorf("calculated amount to capture is not positive") diff --git a/x/rewards/keeper/staking_reward_participant.go b/x/rewards/keeper/staking_reward_participant.go new file mode 100644 index 00000000..7457732b --- /dev/null +++ b/x/rewards/keeper/staking_reward_participant.go @@ -0,0 +1,49 @@ +package keeper + +import ( + "github.com/bze-alphateam/bze/x/rewards/types" + "github.com/cosmos/cosmos-sdk/store/prefix" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// SetStakingRewardParticipant set a specific stakingRewardParticipant in the store from its index +func (k Keeper) SetStakingRewardParticipant(ctx sdk.Context, stakingRewardParticipant types.StakingRewardParticipant) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.StakingRewardParticipantKeyPrefix)) + b := k.cdc.MustMarshal(&stakingRewardParticipant) + store.Set(types.StakingRewardParticipantKey(stakingRewardParticipant.Address, stakingRewardParticipant.RewardId), b) +} + +// GetStakingRewardParticipant returns a stakingRewardParticipant from its index +func (k Keeper) GetStakingRewardParticipant(ctx sdk.Context, address, rewardId string) (val types.StakingRewardParticipant, found bool) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.StakingRewardParticipantKeyPrefix)) + + b := store.Get(types.StakingRewardParticipantKey(address, rewardId)) + if b == nil { + return val, false + } + + k.cdc.MustUnmarshal(b, &val) + return val, true +} + +// RemoveStakingRewardParticipant removes a stakingRewardParticipant from the store +func (k Keeper) RemoveStakingRewardParticipant(ctx sdk.Context, address, rewardId string) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.StakingRewardParticipantKeyPrefix)) + store.Delete(types.StakingRewardParticipantKey(address, rewardId)) +} + +// GetAllStakingRewardParticipant returns all stakingRewardParticipant +func (k Keeper) GetAllStakingRewardParticipant(ctx sdk.Context) (list []types.StakingRewardParticipant) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.StakingRewardParticipantKeyPrefix)) + iterator := sdk.KVStorePrefixIterator(store, []byte{}) + + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + var val types.StakingRewardParticipant + k.cdc.MustUnmarshal(iterator.Value(), &val) + list = append(list, val) + } + + return +} diff --git a/x/rewards/keeper/staking_reward_participant_test.go b/x/rewards/keeper/staking_reward_participant_test.go new file mode 100644 index 00000000..9bb84f06 --- /dev/null +++ b/x/rewards/keeper/staking_reward_participant_test.go @@ -0,0 +1,63 @@ +package keeper_test + +import ( + "strconv" + "testing" + + keepertest "github.com/bze-alphateam/bze/testutil/keeper" + "github.com/bze-alphateam/bze/testutil/nullify" + "github.com/bze-alphateam/bze/x/rewards/keeper" + "github.com/bze-alphateam/bze/x/rewards/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/stretchr/testify/require" +) + +// Prevent strconv unused error +var _ = strconv.IntSize + +func createNStakingRewardParticipant(keeper *keeper.Keeper, ctx sdk.Context, n int) []types.StakingRewardParticipant { + items := make([]types.StakingRewardParticipant, n) + for i := range items { + items[i].Index = strconv.Itoa(i) + + keeper.SetStakingRewardParticipant(ctx, items[i]) + } + return items +} + +func TestStakingRewardParticipantGet(t *testing.T) { + keeper, ctx := keepertest.RewardsKeeper(t) + items := createNStakingRewardParticipant(keeper, ctx, 10) + for _, item := range items { + rst, found := keeper.GetStakingRewardParticipant(ctx, + item.Index, + ) + require.True(t, found) + require.Equal(t, + nullify.Fill(&item), + nullify.Fill(&rst), + ) + } +} +func TestStakingRewardParticipantRemove(t *testing.T) { + keeper, ctx := keepertest.RewardsKeeper(t) + items := createNStakingRewardParticipant(keeper, ctx, 10) + for _, item := range items { + keeper.RemoveStakingRewardParticipant(ctx, + item.Index, + ) + _, found := keeper.GetStakingRewardParticipant(ctx, + item.Index, + ) + require.False(t, found) + } +} + +func TestStakingRewardParticipantGetAll(t *testing.T) { + keeper, ctx := keepertest.RewardsKeeper(t) + items := createNStakingRewardParticipant(keeper, ctx, 10) + require.ElementsMatch(t, + nullify.Fill(items), + nullify.Fill(keeper.GetAllStakingRewardParticipant(ctx)), + ) +} diff --git a/x/rewards/keeper/staking_reward_test.go b/x/rewards/keeper/staking_reward_test.go index 4aea0099..ba855045 100644 --- a/x/rewards/keeper/staking_reward_test.go +++ b/x/rewards/keeper/staking_reward_test.go @@ -4,10 +4,10 @@ import ( "strconv" "testing" - "github.com/bze-alphateam/bze/x/rewards/keeper" - "github.com/bze-alphateam/bze/x/rewards/types" keepertest "github.com/bze-alphateam/bze/testutil/keeper" "github.com/bze-alphateam/bze/testutil/nullify" + "github.com/bze-alphateam/bze/x/rewards/keeper" + "github.com/bze-alphateam/bze/x/rewards/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" ) @@ -19,7 +19,7 @@ func createNStakingReward(keeper *keeper.Keeper, ctx sdk.Context, n int) []types items := make([]types.StakingReward, n) for i := range items { items[i].RewardId = strconv.Itoa(i) - + keeper.SetStakingReward(ctx, items[i]) } return items @@ -30,8 +30,7 @@ func TestStakingRewardGet(t *testing.T) { items := createNStakingReward(keeper, ctx, 10) for _, item := range items { rst, found := keeper.GetStakingReward(ctx, - item.RewardId, - + item.RewardId, ) require.True(t, found) require.Equal(t, @@ -45,12 +44,10 @@ func TestStakingRewardRemove(t *testing.T) { items := createNStakingReward(keeper, ctx, 10) for _, item := range items { keeper.RemoveStakingReward(ctx, - item.RewardId, - + item.RewardId, ) _, found := keeper.GetStakingReward(ctx, - item.RewardId, - + item.RewardId, ) require.False(t, found) } diff --git a/x/rewards/keeper/trading_reward_test.go b/x/rewards/keeper/trading_reward_test.go index af60e2db..b228ce97 100644 --- a/x/rewards/keeper/trading_reward_test.go +++ b/x/rewards/keeper/trading_reward_test.go @@ -4,10 +4,10 @@ import ( "strconv" "testing" - "github.com/bze-alphateam/bze/x/rewards/keeper" - "github.com/bze-alphateam/bze/x/rewards/types" keepertest "github.com/bze-alphateam/bze/testutil/keeper" "github.com/bze-alphateam/bze/testutil/nullify" + "github.com/bze-alphateam/bze/x/rewards/keeper" + "github.com/bze-alphateam/bze/x/rewards/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" ) @@ -19,7 +19,7 @@ func createNTradingReward(keeper *keeper.Keeper, ctx sdk.Context, n int) []types items := make([]types.TradingReward, n) for i := range items { items[i].RewardId = strconv.Itoa(i) - + keeper.SetTradingReward(ctx, items[i]) } return items @@ -30,8 +30,7 @@ func TestTradingRewardGet(t *testing.T) { items := createNTradingReward(keeper, ctx, 10) for _, item := range items { rst, found := keeper.GetTradingReward(ctx, - item.RewardId, - + item.RewardId, ) require.True(t, found) require.Equal(t, @@ -45,12 +44,10 @@ func TestTradingRewardRemove(t *testing.T) { items := createNTradingReward(keeper, ctx, 10) for _, item := range items { keeper.RemoveTradingReward(ctx, - item.RewardId, - + item.RewardId, ) _, found := keeper.GetTradingReward(ctx, - item.RewardId, - + item.RewardId, ) require.False(t, found) } diff --git a/x/rewards/module_simulation.go b/x/rewards/module_simulation.go index 719a4629..1a994d27 100644 --- a/x/rewards/module_simulation.go +++ b/x/rewards/module_simulation.go @@ -40,6 +40,14 @@ const ( // TODO: Determine the simulation weight value defaultWeightMsgCreateTradingReward int = 100 + opWeightMsgJoinStaking = "op_weight_msg_join_staking" + // TODO: Determine the simulation weight value + defaultWeightMsgJoinStaking int = 100 + + opWeightMsgExitStaking = "op_weight_msg_exit_staking" + // TODO: Determine the simulation weight value + defaultWeightMsgExitStaking int = 100 + // this line is used by starport scaffolding # simapp/module/const ) @@ -141,6 +149,28 @@ func (am AppModule) WeightedOperations(simState module.SimulationState) []simtyp rewardssimulation.SimulateMsgCreateTradingReward(am.accountKeeper, am.bankKeeper, am.keeper), )) + var weightMsgJoinStaking int + simState.AppParams.GetOrGenerate(simState.Cdc, opWeightMsgJoinStaking, &weightMsgJoinStaking, nil, + func(_ *rand.Rand) { + weightMsgJoinStaking = defaultWeightMsgJoinStaking + }, + ) + operations = append(operations, simulation.NewWeightedOperation( + weightMsgJoinStaking, + rewardssimulation.SimulateMsgJoinStaking(am.accountKeeper, am.bankKeeper, am.keeper), + )) + + var weightMsgExitStaking int + simState.AppParams.GetOrGenerate(simState.Cdc, opWeightMsgExitStaking, &weightMsgExitStaking, nil, + func(_ *rand.Rand) { + weightMsgExitStaking = defaultWeightMsgExitStaking + }, + ) + operations = append(operations, simulation.NewWeightedOperation( + weightMsgExitStaking, + rewardssimulation.SimulateMsgExitStaking(am.accountKeeper, am.bankKeeper, am.keeper), + )) + // this line is used by starport scaffolding # simapp/module/operation return operations diff --git a/x/rewards/simulation/exit_staking.go b/x/rewards/simulation/exit_staking.go new file mode 100644 index 00000000..76f68ad5 --- /dev/null +++ b/x/rewards/simulation/exit_staking.go @@ -0,0 +1,29 @@ +package simulation + +import ( + "math/rand" + + "github.com/bze-alphateam/bze/x/rewards/keeper" + "github.com/bze-alphateam/bze/x/rewards/types" + "github.com/cosmos/cosmos-sdk/baseapp" + sdk "github.com/cosmos/cosmos-sdk/types" + simtypes "github.com/cosmos/cosmos-sdk/types/simulation" +) + +func SimulateMsgExitStaking( + ak types.AccountKeeper, + bk types.BankKeeper, + k keeper.Keeper, +) simtypes.Operation { + return func(r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, + ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { + simAccount, _ := simtypes.RandomAcc(r, accs) + msg := &types.MsgExitStaking{ + Creator: simAccount.Address.String(), + } + + // TODO: Handling the ExitStaking simulation + + return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "ExitStaking simulation not implemented"), nil, nil + } +} diff --git a/x/rewards/simulation/join_staking.go b/x/rewards/simulation/join_staking.go new file mode 100644 index 00000000..e5a22233 --- /dev/null +++ b/x/rewards/simulation/join_staking.go @@ -0,0 +1,29 @@ +package simulation + +import ( + "math/rand" + + "github.com/bze-alphateam/bze/x/rewards/keeper" + "github.com/bze-alphateam/bze/x/rewards/types" + "github.com/cosmos/cosmos-sdk/baseapp" + sdk "github.com/cosmos/cosmos-sdk/types" + simtypes "github.com/cosmos/cosmos-sdk/types/simulation" +) + +func SimulateMsgJoinStaking( + ak types.AccountKeeper, + bk types.BankKeeper, + k keeper.Keeper, +) simtypes.Operation { + return func(r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, + ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { + simAccount, _ := simtypes.RandomAcc(r, accs) + msg := &types.MsgJoinStaking{ + Creator: simAccount.Address.String(), + } + + // TODO: Handling the JoinStaking simulation + + return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "JoinStaking simulation not implemented"), nil, nil + } +} diff --git a/x/rewards/types/codec.go b/x/rewards/types/codec.go index c8830319..0375d32e 100644 --- a/x/rewards/types/codec.go +++ b/x/rewards/types/codec.go @@ -11,6 +11,8 @@ func RegisterCodec(cdc *codec.LegacyAmino) { cdc.RegisterConcrete(&MsgCreateStakingReward{}, "rewards/CreateStakingReward", nil) cdc.RegisterConcrete(&MsgUpdateStakingReward{}, "rewards/UpdateStakingReward", nil) cdc.RegisterConcrete(&MsgCreateTradingReward{}, "rewards/CreateTradingReward", nil) + cdc.RegisterConcrete(&MsgJoinStaking{}, "rewards/JoinStaking", nil) + cdc.RegisterConcrete(&MsgExitStaking{}, "rewards/ExitStaking", nil) // this line is used by starport scaffolding # 2 } @@ -22,6 +24,12 @@ func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { registry.RegisterImplementations((*sdk.Msg)(nil), &MsgCreateTradingReward{}, ) + registry.RegisterImplementations((*sdk.Msg)(nil), + &MsgJoinStaking{}, + ) + registry.RegisterImplementations((*sdk.Msg)(nil), + &MsgExitStaking{}, + ) // this line is used by starport scaffolding # 3 msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) diff --git a/x/rewards/types/errors.go b/x/rewards/types/errors.go index 1dcc46c6..b4c78d2d 100644 --- a/x/rewards/types/errors.go +++ b/x/rewards/types/errors.go @@ -8,7 +8,7 @@ import ( // x/rewards module sentinel errors var ( - ErrInvalidPrizeAmount = sdkerrors.Register(ModuleName, 5000, "invalid prize amount") + ErrInvalidAmount = sdkerrors.Register(ModuleName, 5000, "invalid amount") ErrInvalidPrizeDenom = sdkerrors.Register(ModuleName, 5002, "invalid prize denom") ErrInvalidStakingDenom = sdkerrors.Register(ModuleName, 5003, "invalid staking denom") ErrInvalidMinStake = sdkerrors.Register(ModuleName, 5004, "invalid min stake") @@ -16,4 +16,5 @@ var ( ErrInvalidLockingTime = sdkerrors.Register(ModuleName, 5006, "invalid staking reward lock") ErrInvalidMarketId = sdkerrors.Register(ModuleName, 5007, "invalid market_id") ErrInvalidSlots = sdkerrors.Register(ModuleName, 5008, "invalid slots") + ErrInvalidRewardId = sdkerrors.Register(ModuleName, 5009, "invalid reward_id") ) diff --git a/x/rewards/types/genesis.go b/x/rewards/types/genesis.go index c892e897..7573c747 100644 --- a/x/rewards/types/genesis.go +++ b/x/rewards/types/genesis.go @@ -11,11 +11,12 @@ const DefaultIndex uint64 = 1 // DefaultGenesis returns the default Capability genesis state func DefaultGenesis() *GenesisState { return &GenesisState{ - StakingRewardList: []StakingReward{}, - StakingRewardsCounter: 0, - TradingRewardsCounter: 0, - TradingRewardList: []TradingReward{}, -// this line is used by starport scaffolding # genesis/types/default + StakingRewardList: []StakingReward{}, + StakingRewardsCounter: 0, + TradingRewardsCounter: 0, + TradingRewardList: []TradingReward{}, + StakingRewardParticipantList: []StakingRewardParticipant{}, + // this line is used by starport scaffolding # genesis/types/default Params: DefaultParams(), } } @@ -34,16 +35,26 @@ func (gs GenesisState) Validate() error { stakingRewardIndexMap[index] = struct{}{} } // Check for duplicated index in tradingReward -tradingRewardIndexMap := make(map[string]struct{}) + tradingRewardIndexMap := make(map[string]struct{}) -for _, elem := range gs.TradingRewardList { - index := string(TradingRewardKey(elem.RewardId)) - if _, ok := tradingRewardIndexMap[index]; ok { - return fmt.Errorf("duplicated index for tradingReward") + for _, elem := range gs.TradingRewardList { + index := string(TradingRewardKey(elem.RewardId)) + if _, ok := tradingRewardIndexMap[index]; ok { + return fmt.Errorf("duplicated index for tradingReward") + } + tradingRewardIndexMap[index] = struct{}{} } - tradingRewardIndexMap[index] = struct{}{} -} -// this line is used by starport scaffolding # genesis/types/validate + // Check for duplicated index in stakingRewardParticipant + stakingRewardParticipantIndexMap := make(map[string]struct{}) + + for _, elem := range gs.StakingRewardParticipantList { + index := string(StakingRewardParticipantKey(elem.Address, elem.RewardId)) + if _, ok := stakingRewardParticipantIndexMap[index]; ok { + return fmt.Errorf("duplicated index for stakingRewardParticipant") + } + stakingRewardParticipantIndexMap[index] = struct{}{} + } + // this line is used by starport scaffolding # genesis/types/validate return gs.Params.Validate() } diff --git a/x/rewards/types/genesis.pb.go b/x/rewards/types/genesis.pb.go index 2c1122ac..7ea6c01d 100644 --- a/x/rewards/types/genesis.pb.go +++ b/x/rewards/types/genesis.pb.go @@ -25,11 +25,12 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // GenesisState defines the rewards module's genesis state. type GenesisState struct { - Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` - StakingRewardList []StakingReward `protobuf:"bytes,2,rep,name=staking_reward_list,json=stakingRewardList,proto3" json:"staking_reward_list"` - StakingRewardsCounter uint64 `protobuf:"varint,3,opt,name=staking_rewards_counter,json=stakingRewardsCounter,proto3" json:"staking_rewards_counter,omitempty"` - TradingRewardsCounter uint64 `protobuf:"varint,4,opt,name=trading_rewards_counter,json=tradingRewardsCounter,proto3" json:"trading_rewards_counter,omitempty"` - TradingRewardList []TradingReward `protobuf:"bytes,5,rep,name=tradingRewardList,proto3" json:"tradingRewardList"` + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` + StakingRewardList []StakingReward `protobuf:"bytes,2,rep,name=staking_reward_list,json=stakingRewardList,proto3" json:"staking_reward_list"` + StakingRewardsCounter uint64 `protobuf:"varint,3,opt,name=staking_rewards_counter,json=stakingRewardsCounter,proto3" json:"staking_rewards_counter,omitempty"` + TradingRewardsCounter uint64 `protobuf:"varint,4,opt,name=trading_rewards_counter,json=tradingRewardsCounter,proto3" json:"trading_rewards_counter,omitempty"` + TradingRewardList []TradingReward `protobuf:"bytes,5,rep,name=trading_reward_list,json=tradingRewardList,proto3" json:"trading_reward_list"` + StakingRewardParticipantList []StakingRewardParticipant `protobuf:"bytes,6,rep,name=staking_reward_participant_list,json=stakingRewardParticipantList,proto3" json:"staking_reward_participant_list"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -100,6 +101,13 @@ func (m *GenesisState) GetTradingRewardList() []TradingReward { return nil } +func (m *GenesisState) GetStakingRewardParticipantList() []StakingRewardParticipant { + if m != nil { + return m.StakingRewardParticipantList + } + return nil +} + func init() { proto.RegisterType((*GenesisState)(nil), "bze.v1.rewards.GenesisState") } @@ -107,27 +115,30 @@ func init() { func init() { proto.RegisterFile("rewards/genesis.proto", fileDescriptor_04e261dd19d07881) } var fileDescriptor_04e261dd19d07881 = []byte{ - // 315 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x2d, 0x4a, 0x2d, 0x4f, - 0x2c, 0x4a, 0x29, 0xd6, 0x4f, 0x4f, 0xcd, 0x4b, 0x2d, 0xce, 0x2c, 0xd6, 0x2b, 0x28, 0xca, 0x2f, - 0xc9, 0x17, 0xe2, 0x4b, 0xaa, 0x4a, 0xd5, 0x2b, 0x33, 0xd4, 0x83, 0xca, 0x4a, 0x89, 0xa4, 0xe7, - 0xa7, 0xe7, 0x83, 0xa5, 0xf4, 0x41, 0x2c, 0x88, 0x2a, 0x29, 0x11, 0x98, 0xe6, 0x82, 0xc4, 0xa2, - 0xc4, 0x5c, 0xa8, 0x5e, 0x29, 0x19, 0x98, 0x68, 0x71, 0x49, 0x62, 0x76, 0x66, 0x5e, 0x7a, 0x3c, - 0x84, 0x8f, 0x2e, 0x5b, 0x52, 0x94, 0x98, 0x82, 0x2e, 0xab, 0x74, 0x87, 0x89, 0x8b, 0xc7, 0x1d, - 0xe2, 0x92, 0xe0, 0x92, 0xc4, 0x92, 0x54, 0x21, 0x13, 0x2e, 0x36, 0x88, 0xe1, 0x12, 0x8c, 0x0a, - 0x8c, 0x1a, 0xdc, 0x46, 0x62, 0x7a, 0xa8, 0x2e, 0xd3, 0x0b, 0x00, 0xcb, 0x3a, 0xb1, 0x9c, 0xb8, - 0x27, 0xcf, 0x10, 0x04, 0x55, 0x2b, 0x14, 0xcc, 0x25, 0x8c, 0x6a, 0x79, 0x7c, 0x4e, 0x66, 0x71, - 0x89, 0x04, 0x93, 0x02, 0xb3, 0x06, 0xb7, 0x91, 0x2c, 0xba, 0x11, 0xc1, 0x10, 0xa5, 0x41, 0x60, - 0x2e, 0xd4, 0x24, 0xc1, 0x62, 0x64, 0x41, 0x9f, 0xcc, 0xe2, 0x12, 0x21, 0x33, 0x2e, 0x71, 0x54, - 0x43, 0x8b, 0xe3, 0x93, 0xf3, 0x4b, 0xf3, 0x4a, 0x52, 0x8b, 0x24, 0x98, 0x15, 0x18, 0x35, 0x58, - 0x82, 0x44, 0x51, 0xf4, 0x14, 0x3b, 0x43, 0x24, 0x41, 0xfa, 0x50, 0xfd, 0x8a, 0xd0, 0xc7, 0x02, - 0xd1, 0x07, 0x95, 0x46, 0xd3, 0x17, 0xc8, 0x25, 0x88, 0x22, 0x01, 0x72, 0x84, 0x04, 0x2b, 0x76, - 0x2f, 0x84, 0x20, 0x2b, 0x84, 0x79, 0x01, 0x43, 0xb7, 0x93, 0xdb, 0x89, 0x47, 0x72, 0x8c, 0x17, - 0x1e, 0xc9, 0x31, 0x3e, 0x78, 0x24, 0xc7, 0x38, 0xe1, 0xb1, 0x1c, 0xc3, 0x85, 0xc7, 0x72, 0x0c, - 0x37, 0x1e, 0xcb, 0x31, 0x44, 0xe9, 0xa4, 0x67, 0x96, 0x64, 0x94, 0x26, 0xe9, 0x25, 0xe7, 0xe7, - 0xea, 0x27, 0x55, 0xa5, 0xea, 0x26, 0xe6, 0x14, 0x64, 0x24, 0x96, 0xa4, 0x26, 0x82, 0x79, 0xfa, - 0x15, 0xfa, 0xf0, 0x58, 0xab, 0x2c, 0x48, 0x2d, 0x4e, 0x62, 0x03, 0xc7, 0x96, 0x31, 0x20, 0x00, - 0x00, 0xff, 0xff, 0x52, 0x00, 0x82, 0xda, 0x3e, 0x02, 0x00, 0x00, + // 358 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x92, 0x4f, 0x4f, 0xfa, 0x30, + 0x1c, 0xc6, 0xb7, 0x1f, 0xfc, 0x38, 0x14, 0x63, 0xe2, 0x00, 0x25, 0x04, 0x07, 0xf1, 0xb4, 0x83, + 0x6e, 0x11, 0x8d, 0x2f, 0x00, 0x13, 0xbd, 0x78, 0x20, 0xcc, 0x93, 0x17, 0xd2, 0x41, 0x33, 0x1a, + 0x61, 0x5b, 0xda, 0x2f, 0xfe, 0xe1, 0x55, 0xf8, 0xb2, 0x38, 0x72, 0x31, 0xf1, 0x64, 0x0c, 0xbc, + 0x11, 0x43, 0xdb, 0x09, 0x9d, 0xe0, 0x6d, 0xed, 0xf3, 0xfd, 0x3c, 0x4f, 0x9f, 0xae, 0xa8, 0xc2, + 0xc8, 0x33, 0x66, 0x03, 0xee, 0x85, 0x24, 0x22, 0x9c, 0x72, 0x37, 0x61, 0x31, 0xc4, 0xd6, 0x7e, + 0x30, 0x25, 0xee, 0xd3, 0xb9, 0xab, 0xd4, 0x5a, 0x39, 0x8c, 0xc3, 0x58, 0x48, 0xde, 0xea, 0x4b, + 0x4e, 0xd5, 0xca, 0x29, 0x9c, 0x60, 0x86, 0xc7, 0x8a, 0xad, 0xd5, 0xd3, 0x5d, 0x0e, 0xf8, 0x91, + 0x46, 0x61, 0x4f, 0xae, 0xb3, 0x2a, 0x30, 0x3c, 0xf8, 0xa5, 0x3a, 0xdb, 0xd9, 0x5e, 0x82, 0x19, + 0xd0, 0x3e, 0x4d, 0x70, 0x04, 0x72, 0xf2, 0xe4, 0x3d, 0x87, 0xf6, 0x6e, 0xe5, 0x99, 0x7d, 0xc0, + 0x40, 0xac, 0x4b, 0x54, 0x90, 0xc7, 0xa8, 0x9a, 0x4d, 0xd3, 0x29, 0xb6, 0x0e, 0x5d, 0xbd, 0x83, + 0xdb, 0x11, 0x6a, 0x3b, 0x3f, 0xfb, 0x6c, 0x18, 0x5d, 0x35, 0x6b, 0xf9, 0xa8, 0x94, 0x89, 0x1a, + 0x51, 0x0e, 0xd5, 0x7f, 0xcd, 0x9c, 0x53, 0x6c, 0x1d, 0x67, 0x2d, 0x7c, 0x39, 0xda, 0x15, 0x4b, + 0xe5, 0x74, 0xc0, 0x37, 0x37, 0xef, 0x28, 0x07, 0xeb, 0x0a, 0x1d, 0xe9, 0xa6, 0xbc, 0xd7, 0x8f, + 0x27, 0x11, 0x10, 0x56, 0xcd, 0x35, 0x4d, 0x27, 0xdf, 0xad, 0x68, 0x0c, 0xbf, 0x96, 0xe2, 0x8a, + 0xd3, 0x6f, 0x65, 0xcd, 0xe5, 0x25, 0xa7, 0xe4, 0x0c, 0xe7, 0xa3, 0x92, 0xce, 0xc9, 0x12, 0xff, + 0xb7, 0x97, 0xb8, 0xdf, 0xf4, 0x48, 0x4b, 0x68, 0xc6, 0xa2, 0xc4, 0x04, 0x35, 0x76, 0xff, 0x04, + 0x19, 0x50, 0x10, 0x01, 0xce, 0x9f, 0xb7, 0xd4, 0x59, 0x43, 0x2a, 0xab, 0xce, 0x77, 0xe8, 0xab, + 0xd8, 0xf6, 0xcd, 0x6c, 0x61, 0x9b, 0xf3, 0x85, 0x6d, 0x7e, 0x2d, 0x6c, 0xf3, 0x6d, 0x69, 0x1b, + 0xf3, 0xa5, 0x6d, 0x7c, 0x2c, 0x6d, 0xe3, 0xe1, 0x34, 0xa4, 0x30, 0x9c, 0x04, 0x6e, 0x3f, 0x1e, + 0x7b, 0xc1, 0x94, 0x9c, 0xe1, 0x51, 0x32, 0xc4, 0x40, 0xb0, 0x58, 0x79, 0x2f, 0xde, 0xcf, 0xc3, + 0x7a, 0x4d, 0x08, 0x0f, 0x0a, 0xe2, 0x99, 0x5c, 0x7c, 0x07, 0x00, 0x00, 0xff, 0xff, 0x17, 0x61, + 0x8d, 0x84, 0xe1, 0x02, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -150,6 +161,20 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.StakingRewardParticipantList) > 0 { + for iNdEx := len(m.StakingRewardParticipantList) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.StakingRewardParticipantList[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x32 + } + } if len(m.TradingRewardList) > 0 { for iNdEx := len(m.TradingRewardList) - 1; iNdEx >= 0; iNdEx-- { { @@ -238,6 +263,12 @@ func (m *GenesisState) Size() (n int) { n += 1 + l + sovGenesis(uint64(l)) } } + if len(m.StakingRewardParticipantList) > 0 { + for _, e := range m.StakingRewardParticipantList { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } return n } @@ -415,6 +446,40 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field StakingRewardParticipantList", 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 + } + m.StakingRewardParticipantList = append(m.StakingRewardParticipantList, StakingRewardParticipant{}) + if err := m.StakingRewardParticipantList[len(m.StakingRewardParticipantList)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipGenesis(dAtA[iNdEx:]) diff --git a/x/rewards/types/genesis_test.go b/x/rewards/types/genesis_test.go index 5592c345..c962ab94 100644 --- a/x/rewards/types/genesis_test.go +++ b/x/rewards/types/genesis_test.go @@ -19,58 +19,80 @@ func TestGenesisState_Validate(t *testing.T) { valid: true, }, { - desc: "valid genesis state", + desc: "valid genesis state", genState: &types.GenesisState{ StakingRewardList: []types.StakingReward{ - { - RewardId: "0", -}, - { - RewardId: "1", -}, -}, -TradingRewardList: []types.TradingReward{ - { - RewardId: "0", -}, - { - RewardId: "1", -}, -}, -// this line is used by starport scaffolding # types/genesis/validField + { + RewardId: "0", + }, + { + RewardId: "1", + }, + }, + TradingRewardList: []types.TradingReward{ + { + RewardId: "0", + }, + { + RewardId: "1", + }, + }, + StakingRewardParticipantList: []types.StakingRewardParticipant{ + { + Index: "0", + }, + { + Index: "1", + }, + }, + // this line is used by starport scaffolding # types/genesis/validField }, valid: true, }, { - desc: "duplicated stakingReward", - genState: &types.GenesisState{ - StakingRewardList: []types.StakingReward{ - { - RewardId: "0", -}, - { - RewardId: "0", -}, + desc: "duplicated stakingReward", + genState: &types.GenesisState{ + StakingRewardList: []types.StakingReward{ + { + RewardId: "0", + }, + { + RewardId: "0", + }, + }, + }, + valid: false, + }, + { + desc: "duplicated tradingReward", + genState: &types.GenesisState{ + TradingRewardList: []types.TradingReward{ + { + RewardId: "0", + }, + { + RewardId: "0", + }, + }, + }, + valid: false, }, - }, - valid: false, -}, -{ - desc: "duplicated tradingReward", - genState: &types.GenesisState{ - TradingRewardList: []types.TradingReward{ - { - RewardId: "0", -}, - { - RewardId: "0", -}, + { + desc: "duplicated stakingRewardParticipant", + genState: &types.GenesisState{ + StakingRewardParticipantList: []types.StakingRewardParticipant{ + { + Index: "0", + }, + { + Index: "0", + }, + }, + }, + valid: false, }, - }, - valid: false, -}, -// this line is used by starport scaffolding # types/genesis/testcase + // this line is used by starport scaffolding # types/genesis/testcase } { t.Run(tc.desc, func(t *testing.T) { err := tc.genState.Validate() diff --git a/x/rewards/types/key_staking_reward_participant.go b/x/rewards/types/key_staking_reward_participant.go new file mode 100644 index 00000000..c42b8894 --- /dev/null +++ b/x/rewards/types/key_staking_reward_participant.go @@ -0,0 +1,20 @@ +package types + +import "encoding/binary" + +var _ binary.ByteOrder + +const ( + // StakingRewardParticipantKeyPrefix is the prefix to retrieve all StakingRewardParticipant + StakingRewardParticipantKeyPrefix = "srp/v/" +) + +// StakingRewardParticipantKey returns the store key to retrieve a StakingRewardParticipant from the index fields +func StakingRewardParticipantKey(address, rewardId string) []byte { + return []byte(address + "/" + rewardId) +} + +// StakingRewardParticipantPrefix returns the store prefix key to retrieve a StakingRewardParticipant for an address +func StakingRewardParticipantPrefix(address string) []byte { + return []byte(StakingRewardParticipantKeyPrefix + address + "/") +} diff --git a/x/rewards/types/message_exit_staking.go b/x/rewards/types/message_exit_staking.go new file mode 100644 index 00000000..498b1ebf --- /dev/null +++ b/x/rewards/types/message_exit_staking.go @@ -0,0 +1,51 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +const TypeMsgExitStaking = "exit_staking" + +var _ sdk.Msg = &MsgExitStaking{} + +func NewMsgExitStaking(creator string, rewardId string) *MsgExitStaking { + return &MsgExitStaking{ + Creator: creator, + RewardId: rewardId, + } +} + +func (msg *MsgExitStaking) Route() string { + return RouterKey +} + +func (msg *MsgExitStaking) Type() string { + return TypeMsgExitStaking +} + +func (msg *MsgExitStaking) GetSigners() []sdk.AccAddress { + creator, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + panic(err) + } + return []sdk.AccAddress{creator} +} + +func (msg *MsgExitStaking) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(msg) + return sdk.MustSortJSON(bz) +} + +func (msg *MsgExitStaking) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err) + } + + if msg.RewardId == "" { + return sdkerrors.Wrapf(ErrInvalidRewardId, "empty reward id") + } + + return nil +} diff --git a/x/rewards/types/message_exit_staking_test.go b/x/rewards/types/message_exit_staking_test.go new file mode 100644 index 00000000..a6dd3075 --- /dev/null +++ b/x/rewards/types/message_exit_staking_test.go @@ -0,0 +1,40 @@ +package types + +import ( + "testing" + + "github.com/bze-alphateam/bze/testutil/sample" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/stretchr/testify/require" +) + +func TestMsgExitStaking_ValidateBasic(t *testing.T) { + tests := []struct { + name string + msg MsgExitStaking + err error + }{ + { + name: "invalid address", + msg: MsgExitStaking{ + Creator: "invalid_address", + }, + err: sdkerrors.ErrInvalidAddress, + }, { + name: "valid address", + msg: MsgExitStaking{ + Creator: sample.AccAddress(), + }, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + err := tt.msg.ValidateBasic() + if tt.err != nil { + require.ErrorIs(t, err, tt.err) + return + } + require.NoError(t, err) + }) + } +} diff --git a/x/rewards/types/message_join_staking.go b/x/rewards/types/message_join_staking.go new file mode 100644 index 00000000..3565c54a --- /dev/null +++ b/x/rewards/types/message_join_staking.go @@ -0,0 +1,64 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +const TypeMsgJoinStaking = "join_staking" + +var _ sdk.Msg = &MsgJoinStaking{} + +func NewMsgJoinStaking(creator string, rewardId string, amount string) *MsgJoinStaking { + return &MsgJoinStaking{ + Creator: creator, + RewardId: rewardId, + Amount: amount, + } +} + +func (msg *MsgJoinStaking) Route() string { + return RouterKey +} + +func (msg *MsgJoinStaking) Type() string { + return TypeMsgJoinStaking +} + +func (msg *MsgJoinStaking) GetSigners() []sdk.AccAddress { + creator, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + panic(err) + } + return []sdk.AccAddress{creator} +} + +func (msg *MsgJoinStaking) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(msg) + return sdk.MustSortJSON(bz) +} + +func (msg *MsgJoinStaking) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err) + } + + if msg.RewardId == "" { + return sdkerrors.Wrapf(ErrInvalidRewardId, "empty reward id") + } + + if msg.Amount == "" { + return sdkerrors.Wrapf(ErrInvalidAmount, "empty amount provided") + } + + amtInt, ok := sdk.NewIntFromString(msg.Amount) + if !ok { + return sdkerrors.Wrapf(ErrInvalidAmount, "could not convert amount") + } + if !amtInt.IsPositive() { + return sdkerrors.Wrapf(ErrInvalidAmount, "amount should be greater than 0") + } + + return nil +} diff --git a/x/rewards/types/message_join_staking_test.go b/x/rewards/types/message_join_staking_test.go new file mode 100644 index 00000000..8da814ed --- /dev/null +++ b/x/rewards/types/message_join_staking_test.go @@ -0,0 +1,40 @@ +package types + +import ( + "testing" + + "github.com/bze-alphateam/bze/testutil/sample" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/stretchr/testify/require" +) + +func TestMsgJoinStaking_ValidateBasic(t *testing.T) { + tests := []struct { + name string + msg MsgJoinStaking + err error + }{ + { + name: "invalid address", + msg: MsgJoinStaking{ + Creator: "invalid_address", + }, + err: sdkerrors.ErrInvalidAddress, + }, { + name: "valid address", + msg: MsgJoinStaking{ + Creator: sample.AccAddress(), + }, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + err := tt.msg.ValidateBasic() + if tt.err != nil { + require.ErrorIs(t, err, tt.err) + return + } + require.NoError(t, err) + }) + } +} diff --git a/x/rewards/types/messages_staking_reward.go b/x/rewards/types/messages_staking_reward.go index 60f9575c..7c57a10a 100644 --- a/x/rewards/types/messages_staking_reward.go +++ b/x/rewards/types/messages_staking_reward.go @@ -62,10 +62,10 @@ func (msg *MsgCreateStakingReward) ToStakingReward() (StakingReward, error) { amtInt, ok := sdk.NewIntFromString(msg.PrizeAmount) if !ok { - return sr, sdkerrors.Wrapf(ErrInvalidPrizeAmount, "could not convert order amount") + return sr, sdkerrors.Wrapf(ErrInvalidAmount, "could not convert order amount") } if !amtInt.IsPositive() { - return sr, sdkerrors.Wrapf(ErrInvalidPrizeAmount, "amount should be greater than 0") + return sr, sdkerrors.Wrapf(ErrInvalidAmount, "amount should be greater than 0") } sr.PrizeAmount = msg.PrizeAmount diff --git a/x/rewards/types/messages_staking_reward_test.go b/x/rewards/types/messages_staking_reward_test.go index c95d5358..17c60435 100644 --- a/x/rewards/types/messages_staking_reward_test.go +++ b/x/rewards/types/messages_staking_reward_test.go @@ -3,9 +3,9 @@ package types import ( "testing" + "github.com/bze-alphateam/bze/testutil/sample" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/stretchr/testify/require" - "github.com/bze-alphateam/bze/testutil/sample" ) func TestMsgCreateStakingReward_ValidateBasic(t *testing.T) { diff --git a/x/rewards/types/messages_trading_reward.go b/x/rewards/types/messages_trading_reward.go index 33c191b8..3e17a9b7 100644 --- a/x/rewards/types/messages_trading_reward.go +++ b/x/rewards/types/messages_trading_reward.go @@ -59,10 +59,10 @@ func (msg *MsgCreateTradingReward) ToTradingReward() (TradingReward, error) { amtInt, ok := sdk.NewIntFromString(msg.PrizeAmount) if !ok { - return tr, sdkerrors.Wrapf(ErrInvalidPrizeAmount, "could not convert order amount") + return tr, sdkerrors.Wrapf(ErrInvalidAmount, "could not convert order amount") } if !amtInt.IsPositive() { - return tr, sdkerrors.Wrapf(ErrInvalidPrizeAmount, "amount should be greater than 0") + return tr, sdkerrors.Wrapf(ErrInvalidAmount, "amount should be greater than 0") } tr.PrizeAmount = amtInt.String() diff --git a/x/rewards/types/query.pb.go b/x/rewards/types/query.pb.go index d1eea5b5..672195fd 100644 --- a/x/rewards/types/query.pb.go +++ b/x/rewards/types/query.pb.go @@ -298,7 +298,7 @@ func (m *QueryAllStakingRewardResponse) GetPagination() *query.PageResponse { } type QueryGetTradingRewardRequest struct { - RewardId string `protobuf:"bytes,1,opt,name=rewardId,proto3" json:"rewardId,omitempty"` + RewardId string `protobuf:"bytes,1,opt,name=reward_id,json=rewardId,proto3" json:"reward_id,omitempty"` } func (m *QueryGetTradingRewardRequest) Reset() { *m = QueryGetTradingRewardRequest{} } @@ -342,7 +342,7 @@ func (m *QueryGetTradingRewardRequest) GetRewardId() string { } type QueryGetTradingRewardResponse struct { - TradingReward TradingReward `protobuf:"bytes,1,opt,name=tradingReward,proto3" json:"tradingReward"` + TradingReward TradingReward `protobuf:"bytes,1,opt,name=trading_reward,json=tradingReward,proto3" json:"trading_reward"` } func (m *QueryGetTradingRewardResponse) Reset() { *m = QueryGetTradingRewardResponse{} } @@ -430,8 +430,8 @@ func (m *QueryAllTradingRewardRequest) GetPagination() *query.PageRequest { } type QueryAllTradingRewardResponse struct { - TradingReward []TradingReward `protobuf:"bytes,1,rep,name=tradingReward,proto3" json:"tradingReward"` - Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` + List []TradingReward `protobuf:"bytes,1,rep,name=list,proto3" json:"list"` + Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` } func (m *QueryAllTradingRewardResponse) Reset() { *m = QueryAllTradingRewardResponse{} } @@ -467,9 +467,9 @@ func (m *QueryAllTradingRewardResponse) XXX_DiscardUnknown() { var xxx_messageInfo_QueryAllTradingRewardResponse proto.InternalMessageInfo -func (m *QueryAllTradingRewardResponse) GetTradingReward() []TradingReward { +func (m *QueryAllTradingRewardResponse) GetList() []TradingReward { if m != nil { - return m.TradingReward + return m.List } return nil } @@ -481,6 +481,214 @@ func (m *QueryAllTradingRewardResponse) GetPagination() *query.PageResponse { return nil } +type QueryGetStakingRewardParticipantRequest struct { + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` + Pagination *query.PageRequest `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryGetStakingRewardParticipantRequest) Reset() { + *m = QueryGetStakingRewardParticipantRequest{} +} +func (m *QueryGetStakingRewardParticipantRequest) String() string { return proto.CompactTextString(m) } +func (*QueryGetStakingRewardParticipantRequest) ProtoMessage() {} +func (*QueryGetStakingRewardParticipantRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_5ddc078ee02fb5e8, []int{10} +} +func (m *QueryGetStakingRewardParticipantRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryGetStakingRewardParticipantRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryGetStakingRewardParticipantRequest.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 *QueryGetStakingRewardParticipantRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryGetStakingRewardParticipantRequest.Merge(m, src) +} +func (m *QueryGetStakingRewardParticipantRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryGetStakingRewardParticipantRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryGetStakingRewardParticipantRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryGetStakingRewardParticipantRequest proto.InternalMessageInfo + +func (m *QueryGetStakingRewardParticipantRequest) GetAddress() string { + if m != nil { + return m.Address + } + return "" +} + +func (m *QueryGetStakingRewardParticipantRequest) GetPagination() *query.PageRequest { + if m != nil { + return m.Pagination + } + return nil +} + +type QueryGetStakingRewardParticipantResponse struct { + List []StakingRewardParticipant `protobuf:"bytes,1,rep,name=list,proto3" json:"list"` + Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryGetStakingRewardParticipantResponse) Reset() { + *m = QueryGetStakingRewardParticipantResponse{} +} +func (m *QueryGetStakingRewardParticipantResponse) String() string { return proto.CompactTextString(m) } +func (*QueryGetStakingRewardParticipantResponse) ProtoMessage() {} +func (*QueryGetStakingRewardParticipantResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_5ddc078ee02fb5e8, []int{11} +} +func (m *QueryGetStakingRewardParticipantResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryGetStakingRewardParticipantResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryGetStakingRewardParticipantResponse.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 *QueryGetStakingRewardParticipantResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryGetStakingRewardParticipantResponse.Merge(m, src) +} +func (m *QueryGetStakingRewardParticipantResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryGetStakingRewardParticipantResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryGetStakingRewardParticipantResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryGetStakingRewardParticipantResponse proto.InternalMessageInfo + +func (m *QueryGetStakingRewardParticipantResponse) GetList() []StakingRewardParticipant { + if m != nil { + return m.List + } + return nil +} + +func (m *QueryGetStakingRewardParticipantResponse) GetPagination() *query.PageResponse { + if m != nil { + return m.Pagination + } + return nil +} + +type QueryAllStakingRewardParticipantRequest struct { + Pagination *query.PageRequest `protobuf:"bytes,1,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryAllStakingRewardParticipantRequest) Reset() { + *m = QueryAllStakingRewardParticipantRequest{} +} +func (m *QueryAllStakingRewardParticipantRequest) String() string { return proto.CompactTextString(m) } +func (*QueryAllStakingRewardParticipantRequest) ProtoMessage() {} +func (*QueryAllStakingRewardParticipantRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_5ddc078ee02fb5e8, []int{12} +} +func (m *QueryAllStakingRewardParticipantRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryAllStakingRewardParticipantRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryAllStakingRewardParticipantRequest.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 *QueryAllStakingRewardParticipantRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryAllStakingRewardParticipantRequest.Merge(m, src) +} +func (m *QueryAllStakingRewardParticipantRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryAllStakingRewardParticipantRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryAllStakingRewardParticipantRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryAllStakingRewardParticipantRequest proto.InternalMessageInfo + +func (m *QueryAllStakingRewardParticipantRequest) GetPagination() *query.PageRequest { + if m != nil { + return m.Pagination + } + return nil +} + +type QueryAllStakingRewardParticipantResponse struct { + List []StakingRewardParticipant `protobuf:"bytes,1,rep,name=list,proto3" json:"list"` + Pagination *query.PageResponse `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` +} + +func (m *QueryAllStakingRewardParticipantResponse) Reset() { + *m = QueryAllStakingRewardParticipantResponse{} +} +func (m *QueryAllStakingRewardParticipantResponse) String() string { return proto.CompactTextString(m) } +func (*QueryAllStakingRewardParticipantResponse) ProtoMessage() {} +func (*QueryAllStakingRewardParticipantResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_5ddc078ee02fb5e8, []int{13} +} +func (m *QueryAllStakingRewardParticipantResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryAllStakingRewardParticipantResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryAllStakingRewardParticipantResponse.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 *QueryAllStakingRewardParticipantResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryAllStakingRewardParticipantResponse.Merge(m, src) +} +func (m *QueryAllStakingRewardParticipantResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryAllStakingRewardParticipantResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryAllStakingRewardParticipantResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryAllStakingRewardParticipantResponse proto.InternalMessageInfo + +func (m *QueryAllStakingRewardParticipantResponse) GetList() []StakingRewardParticipant { + if m != nil { + return m.List + } + return nil +} + +func (m *QueryAllStakingRewardParticipantResponse) GetPagination() *query.PageResponse { + if m != nil { + return m.Pagination + } + return nil +} + func init() { proto.RegisterType((*QueryParamsRequest)(nil), "bze.v1.rewards.QueryParamsRequest") proto.RegisterType((*QueryParamsResponse)(nil), "bze.v1.rewards.QueryParamsResponse") @@ -492,53 +700,64 @@ func init() { proto.RegisterType((*QueryGetTradingRewardResponse)(nil), "bze.v1.rewards.QueryGetTradingRewardResponse") proto.RegisterType((*QueryAllTradingRewardRequest)(nil), "bze.v1.rewards.QueryAllTradingRewardRequest") proto.RegisterType((*QueryAllTradingRewardResponse)(nil), "bze.v1.rewards.QueryAllTradingRewardResponse") + proto.RegisterType((*QueryGetStakingRewardParticipantRequest)(nil), "bze.v1.rewards.QueryGetStakingRewardParticipantRequest") + proto.RegisterType((*QueryGetStakingRewardParticipantResponse)(nil), "bze.v1.rewards.QueryGetStakingRewardParticipantResponse") + proto.RegisterType((*QueryAllStakingRewardParticipantRequest)(nil), "bze.v1.rewards.QueryAllStakingRewardParticipantRequest") + proto.RegisterType((*QueryAllStakingRewardParticipantResponse)(nil), "bze.v1.rewards.QueryAllStakingRewardParticipantResponse") } func init() { proto.RegisterFile("rewards/query.proto", fileDescriptor_5ddc078ee02fb5e8) } var fileDescriptor_5ddc078ee02fb5e8 = []byte{ - // 642 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x95, 0xcb, 0x6e, 0xd3, 0x4c, - 0x14, 0xc7, 0xe3, 0x5e, 0xa2, 0xaf, 0xf3, 0x29, 0x15, 0x9a, 0x46, 0x55, 0x14, 0x52, 0x13, 0x19, - 0xa9, 0x40, 0x49, 0x6d, 0x25, 0x20, 0x21, 0xc1, 0xaa, 0x5d, 0xb4, 0x0a, 0x6c, 0x4a, 0x60, 0xc5, - 0xa6, 0x1a, 0x37, 0x83, 0x6b, 0xea, 0x78, 0x1c, 0xcf, 0x24, 0xd0, 0x22, 0x36, 0x3c, 0x01, 0x12, - 0x0b, 0x96, 0xc0, 0x33, 0xf0, 0x12, 0x5d, 0x56, 0x62, 0xc3, 0x0a, 0xa1, 0x84, 0x37, 0xe0, 0x05, - 0x50, 0x66, 0xc6, 0x49, 0xc6, 0xc9, 0x84, 0x80, 0xba, 0x4b, 0x66, 0xce, 0xe5, 0x77, 0xce, 0xff, - 0xcc, 0x31, 0x58, 0x8b, 0xf1, 0x4b, 0x14, 0x37, 0xa9, 0xd3, 0xee, 0xe0, 0xf8, 0xd4, 0x8e, 0x62, - 0xc2, 0x08, 0x5c, 0x75, 0xcf, 0xb0, 0xdd, 0xad, 0xda, 0xf2, 0xae, 0x98, 0xf7, 0x88, 0x47, 0xf8, - 0x95, 0x33, 0xf8, 0x25, 0xac, 0x8a, 0x25, 0x8f, 0x10, 0x2f, 0xc0, 0x0e, 0x8a, 0x7c, 0x07, 0x85, - 0x21, 0x61, 0x88, 0xf9, 0x24, 0xa4, 0xf2, 0x76, 0xeb, 0x88, 0xd0, 0x16, 0xa1, 0x8e, 0x8b, 0x28, - 0x16, 0xc1, 0x9d, 0x6e, 0xd5, 0xc5, 0x0c, 0x55, 0x9d, 0x08, 0x79, 0x7e, 0xc8, 0x8d, 0xa5, 0x6d, - 0x3e, 0x81, 0x88, 0x50, 0x8c, 0x5a, 0x49, 0x84, 0x52, 0x72, 0x4a, 0x19, 0x3a, 0xf1, 0x43, 0xef, - 0x50, 0xfc, 0x4f, 0xdf, 0xb2, 0x18, 0x35, 0xd3, 0xb7, 0x56, 0x1e, 0xc0, 0xc7, 0x83, 0x9c, 0x07, - 0x3c, 0x60, 0x03, 0xb7, 0x3b, 0x98, 0x32, 0xeb, 0x11, 0x58, 0x53, 0x4e, 0x69, 0x44, 0x42, 0x8a, - 0xe1, 0x5d, 0x90, 0x15, 0x89, 0x0b, 0x46, 0xd9, 0xb8, 0xf9, 0x7f, 0x6d, 0xdd, 0x56, 0xeb, 0xb7, - 0x85, 0xfd, 0xee, 0xd2, 0xf9, 0xf7, 0x6b, 0x99, 0x86, 0xb4, 0xb5, 0x1e, 0x80, 0x12, 0x0f, 0xb6, - 0x8f, 0xd9, 0x13, 0x01, 0xd8, 0xe0, 0xe6, 0x32, 0x19, 0xbc, 0x0a, 0x56, 0x84, 0xff, 0xa1, 0xdf, - 0xe4, 0x81, 0x57, 0x1a, 0xff, 0x89, 0x83, 0x7a, 0xd3, 0x3a, 0x01, 0x1b, 0x1a, 0x67, 0xc9, 0xf4, - 0x10, 0xac, 0xaa, 0x65, 0x4b, 0xb6, 0x8d, 0x34, 0x9b, 0xe2, 0x2e, 0x11, 0x73, 0x74, 0xfc, 0xd0, - 0x7a, 0x2e, 0x49, 0x77, 0x82, 0x60, 0x2a, 0xe9, 0x1e, 0x00, 0x23, 0x49, 0x64, 0x9e, 0x4d, 0x5b, - 0xe8, 0x67, 0x0f, 0xf4, 0xb3, 0xc5, 0x70, 0x48, 0xfd, 0xec, 0x03, 0xe4, 0x61, 0xe9, 0xdb, 0x18, - 0xf3, 0xb4, 0x3e, 0x1b, 0xb2, 0xaa, 0xc9, 0x44, 0xb2, 0xaa, 0x7b, 0x60, 0x29, 0xf0, 0x29, 0x2b, - 0x18, 0xe5, 0xc5, 0x79, 0x6b, 0xe1, 0x0e, 0x70, 0x5f, 0x41, 0x5c, 0xe0, 0x88, 0x37, 0xfe, 0x88, - 0x28, 0xb2, 0x2a, 0x8c, 0xf7, 0x47, 0xaa, 0x3d, 0x15, 0x83, 0xa3, 0xf6, 0xa2, 0x08, 0x86, 0x22, - 0x4d, 0x88, 0xf6, 0x62, 0x24, 0x5a, 0xca, 0x57, 0x96, 0x57, 0x07, 0x39, 0x36, 0x7e, 0xa1, 0xd3, - 0x4c, 0xf1, 0x4e, 0x34, 0x53, 0x3c, 0xc7, 0x35, 0x9b, 0xca, 0x79, 0x59, 0x9a, 0x7d, 0x19, 0xd3, - 0x6c, 0xee, 0xa2, 0x16, 0xff, 0xad, 0xa8, 0x4b, 0x53, 0xb1, 0xf6, 0x6b, 0x19, 0x2c, 0x73, 0x6a, - 0xd8, 0x06, 0x59, 0xf1, 0x3a, 0xa1, 0x95, 0x06, 0x9a, 0x5c, 0x00, 0xc5, 0xeb, 0x33, 0x6d, 0x44, - 0x22, 0xcb, 0x7c, 0xfb, 0xf5, 0xe7, 0xfb, 0x85, 0x02, 0x5c, 0x77, 0xdc, 0x33, 0xec, 0x24, 0x6b, - 0xa6, 0x5b, 0x95, 0xdb, 0x09, 0x7e, 0x32, 0x40, 0x4e, 0x99, 0x54, 0x58, 0x99, 0x1a, 0x56, 0xb3, - 0x18, 0x8a, 0xdb, 0x73, 0x5a, 0x4b, 0x9c, 0x1a, 0xc7, 0xa9, 0xc0, 0xad, 0x34, 0x8e, 0xba, 0x1f, - 0x9c, 0xd7, 0xc3, 0x6d, 0xf3, 0x06, 0x7e, 0x30, 0xc0, 0x15, 0x25, 0xda, 0x4e, 0x10, 0x68, 0x28, - 0x35, 0x4b, 0x41, 0x43, 0xa9, 0x7b, 0xd9, 0xd6, 0x26, 0xa7, 0x2c, 0x43, 0x73, 0x36, 0x25, 0xfc, - 0x68, 0x80, 0x9c, 0x32, 0x29, 0xfa, 0xe6, 0x4d, 0x9b, 0x7b, 0x7d, 0xf3, 0xa6, 0x0e, 0xaf, 0x55, - 0xe5, 0x58, 0xb7, 0xe1, 0xad, 0x34, 0x96, 0xfa, 0xd5, 0x48, 0x9a, 0x57, 0x97, 0xbd, 0x53, 0x82, - 0xcd, 0xec, 0xdd, 0x5f, 0x40, 0xea, 0x5e, 0x98, 0xbe, 0x77, 0x2a, 0xe4, 0xee, 0xde, 0x79, 0xcf, - 0x34, 0x2e, 0x7a, 0xa6, 0xf1, 0xa3, 0x67, 0x1a, 0xef, 0xfa, 0x66, 0xe6, 0xa2, 0x6f, 0x66, 0xbe, - 0xf5, 0xcd, 0xcc, 0xb3, 0x8a, 0xe7, 0xb3, 0xe3, 0x8e, 0x6b, 0x1f, 0x91, 0xd6, 0x20, 0xc6, 0x36, - 0x0a, 0xa2, 0x63, 0xc4, 0x30, 0xe2, 0xff, 0x9c, 0x57, 0xc3, 0x98, 0xec, 0x34, 0xc2, 0xd4, 0xcd, - 0xf2, 0x6f, 0xe4, 0x9d, 0xdf, 0x01, 0x00, 0x00, 0xff, 0xff, 0x35, 0xb1, 0xa0, 0x24, 0xfc, 0x07, - 0x00, 0x00, + // 763 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x96, 0xc1, 0x4f, 0xd4, 0x4e, + 0x14, 0xc7, 0x77, 0xf8, 0xf1, 0x43, 0x19, 0x03, 0x31, 0x03, 0x21, 0x9b, 0x05, 0x2a, 0xa9, 0x09, + 0x6c, 0x10, 0xda, 0x2c, 0x10, 0x31, 0xd1, 0x0b, 0x1c, 0x20, 0xea, 0x05, 0x57, 0x4f, 0x5e, 0xc8, + 0x2c, 0x3b, 0x96, 0x86, 0xd2, 0x76, 0x3b, 0x03, 0x0a, 0x84, 0x8b, 0x47, 0xbd, 0x98, 0x78, 0xf0, + 0xaa, 0x7f, 0x85, 0x7f, 0x81, 0x09, 0x89, 0x17, 0x12, 0x2f, 0x9e, 0x8c, 0x01, 0xff, 0x10, 0xb3, + 0x33, 0x53, 0xe8, 0x74, 0x3b, 0xdd, 0x42, 0x20, 0xf1, 0xb6, 0x9d, 0x79, 0x6f, 0xde, 0xe7, 0x7d, + 0xdf, 0xcc, 0x7b, 0x0b, 0x87, 0x22, 0xf2, 0x1a, 0x47, 0x4d, 0x6a, 0xb7, 0x76, 0x48, 0xb4, 0x67, + 0x85, 0x51, 0xc0, 0x02, 0x34, 0xd8, 0xd8, 0x27, 0xd6, 0x6e, 0xcd, 0x92, 0x7b, 0x95, 0x61, 0x27, + 0x70, 0x02, 0xbe, 0x65, 0xb7, 0x7f, 0x09, 0xab, 0xca, 0x98, 0x13, 0x04, 0x8e, 0x47, 0x6c, 0x1c, + 0xba, 0x36, 0xf6, 0xfd, 0x80, 0x61, 0xe6, 0x06, 0x3e, 0x95, 0xbb, 0xd3, 0x1b, 0x01, 0xdd, 0x0e, + 0xa8, 0xdd, 0xc0, 0x94, 0x88, 0xc3, 0xed, 0xdd, 0x5a, 0x83, 0x30, 0x5c, 0xb3, 0x43, 0xec, 0xb8, + 0x3e, 0x37, 0x96, 0xb6, 0xc3, 0x31, 0x44, 0x88, 0x23, 0xbc, 0x1d, 0x9f, 0x30, 0x16, 0xaf, 0x52, + 0x86, 0xb7, 0x5c, 0xdf, 0x59, 0x17, 0xdf, 0xe9, 0x5d, 0x16, 0xe1, 0x66, 0xc7, 0x6e, 0x35, 0xdb, + 0x77, 0x3d, 0xc4, 0x11, 0x73, 0x37, 0xdc, 0x10, 0xfb, 0x4c, 0x58, 0x9a, 0xc3, 0x10, 0x3d, 0x6b, + 0xd3, 0xad, 0xf1, 0xd0, 0x75, 0xd2, 0xda, 0x21, 0x94, 0x99, 0x4f, 0xe1, 0x90, 0xb2, 0x4a, 0xc3, + 0xc0, 0xa7, 0x04, 0x2d, 0xc0, 0x3e, 0x81, 0x58, 0x06, 0x13, 0xa0, 0x7a, 0x6b, 0x6e, 0xc4, 0x52, + 0x95, 0xb2, 0x84, 0xfd, 0x72, 0xef, 0xd1, 0xaf, 0x3b, 0xa5, 0xba, 0xb4, 0x35, 0x1f, 0xc2, 0x31, + 0x7e, 0xd8, 0x2a, 0x61, 0xcf, 0x05, 0x4e, 0x9d, 0x9b, 0xcb, 0x60, 0x68, 0x14, 0xf6, 0x4b, 0x3c, + 0xb7, 0xc9, 0x0f, 0xee, 0xaf, 0xdf, 0x14, 0x0b, 0x8f, 0x9b, 0xe6, 0x16, 0x1c, 0xd7, 0x38, 0x4b, + 0xa6, 0x27, 0x70, 0x50, 0x4d, 0x52, 0xb2, 0x8d, 0xa7, 0xd9, 0x14, 0x77, 0x89, 0x38, 0x40, 0x93, + 0x8b, 0xe6, 0x2b, 0x49, 0xba, 0xe4, 0x79, 0x99, 0xa4, 0x2b, 0x10, 0x9e, 0x17, 0x4f, 0xc6, 0x99, + 0xb4, 0x44, 0xa5, 0xad, 0x76, 0xa5, 0x2d, 0x71, 0x8d, 0x64, 0xa5, 0xad, 0x35, 0xec, 0x10, 0xe9, + 0x5b, 0x4f, 0x78, 0x9a, 0x5f, 0x80, 0xcc, 0xaa, 0x33, 0x90, 0xcc, 0x6a, 0x11, 0xf6, 0x7a, 0x2e, + 0x65, 0x65, 0x30, 0xf1, 0x5f, 0xd1, 0x5c, 0xb8, 0x03, 0x5a, 0x55, 0x10, 0x7b, 0x38, 0xe2, 0x54, + 0x57, 0x44, 0x11, 0x55, 0x61, 0x4c, 0x54, 0xed, 0x85, 0xb8, 0x62, 0x97, 0xab, 0x5a, 0xca, 0xf9, + 0xbc, 0x6a, 0xea, 0xc5, 0xd5, 0x55, 0x4d, 0x71, 0x8f, 0xab, 0xc6, 0x92, 0x8b, 0xc9, 0xaa, 0x65, + 0x92, 0x5e, 0x47, 0xd5, 0xb2, 0xb3, 0xea, 0x52, 0xb5, 0xac, 0x5c, 0xae, 0xb8, 0x6a, 0xef, 0x01, + 0x9c, 0xca, 0x7c, 0x2f, 0x6b, 0xe7, 0x2f, 0x3f, 0xd6, 0xa5, 0x0c, 0x6f, 0xe0, 0x66, 0x33, 0x22, + 0x94, 0xca, 0xfa, 0xc5, 0x9f, 0x29, 0xc5, 0x7a, 0x2e, 0xad, 0xd8, 0x57, 0x00, 0xab, 0xdd, 0x69, + 0xa4, 0x78, 0xcb, 0x8a, 0x78, 0xd5, 0xdc, 0x2b, 0x9f, 0xf0, 0xbf, 0x1e, 0x1d, 0x5b, 0x52, 0xc6, + 0xf4, 0x03, 0xcd, 0x90, 0xf1, 0xaa, 0xae, 0xd7, 0x99, 0x58, 0xb9, 0x31, 0xff, 0x41, 0xb1, 0xe6, + 0xde, 0xf5, 0xc3, 0xff, 0x39, 0x39, 0x6a, 0xc1, 0x3e, 0x31, 0x02, 0x90, 0x99, 0x46, 0xea, 0x9c, + 0x32, 0x95, 0xbb, 0xb9, 0x36, 0x22, 0x90, 0x69, 0xbc, 0xfd, 0xf1, 0xe7, 0x63, 0x4f, 0x19, 0x8d, + 0xd8, 0x8d, 0x7d, 0x62, 0xc7, 0x73, 0x6d, 0xb7, 0x26, 0x87, 0x25, 0xfa, 0x0c, 0xe0, 0x80, 0x92, + 0x2e, 0x9a, 0xc9, 0x3c, 0x56, 0x33, 0x7d, 0x2a, 0xb3, 0x05, 0xad, 0x25, 0xce, 0x1c, 0xc7, 0x99, + 0x41, 0xd3, 0x69, 0x1c, 0x75, 0x08, 0xd9, 0x07, 0x67, 0xcd, 0xf1, 0x10, 0x7d, 0x02, 0xf0, 0xb6, + 0x72, 0xda, 0x92, 0xe7, 0x69, 0x28, 0x35, 0x93, 0x47, 0x43, 0xa9, 0x1b, 0x1f, 0xe6, 0x24, 0xa7, + 0x9c, 0x40, 0x46, 0x3e, 0x25, 0x17, 0x4f, 0xe9, 0x4a, 0x7a, 0xf1, 0xb2, 0x5a, 0xab, 0x5e, 0xbc, + 0xcc, 0xfe, 0xa8, 0x17, 0x4f, 0x9d, 0x05, 0x1d, 0xe2, 0x29, 0xa7, 0xe5, 0x8a, 0x77, 0x01, 0x4a, + 0x5d, 0x17, 0xd7, 0x8b, 0xa7, 0x52, 0xa2, 0xef, 0x00, 0x96, 0x75, 0x0f, 0x0d, 0x2d, 0x16, 0xba, + 0x56, 0x9d, 0xed, 0xa4, 0xf2, 0xe0, 0xe2, 0x8e, 0x92, 0xfb, 0x11, 0xe7, 0xbe, 0x8f, 0x16, 0xf2, + 0x8b, 0x9e, 0xfc, 0x13, 0x68, 0x1f, 0xc8, 0x96, 0x7f, 0x88, 0xbe, 0x01, 0x38, 0xaa, 0x0b, 0xd1, + 0x96, 0x7c, 0xb1, 0xd0, 0x0d, 0x2c, 0x9c, 0x50, 0x81, 0x26, 0x67, 0xce, 0xf3, 0x84, 0x66, 0xd1, + 0xbd, 0xe2, 0x09, 0xd1, 0xe5, 0x95, 0xa3, 0x13, 0x03, 0x1c, 0x9f, 0x18, 0xe0, 0xf7, 0x89, 0x01, + 0x3e, 0x9c, 0x1a, 0xa5, 0xe3, 0x53, 0xa3, 0xf4, 0xf3, 0xd4, 0x28, 0xbd, 0x9c, 0x71, 0x5c, 0xb6, + 0xb9, 0xd3, 0xb0, 0x36, 0x82, 0xed, 0xf6, 0x81, 0xb3, 0xd8, 0x0b, 0x37, 0x31, 0x23, 0x98, 0x7f, + 0xd9, 0x6f, 0xce, 0x02, 0xb0, 0xbd, 0x90, 0xd0, 0x46, 0x1f, 0xff, 0x7f, 0x3c, 0xff, 0x37, 0x00, + 0x00, 0xff, 0xff, 0xf0, 0x0c, 0xec, 0x8c, 0x22, 0x0c, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -563,6 +782,10 @@ type QueryClient interface { TradingReward(ctx context.Context, in *QueryGetTradingRewardRequest, opts ...grpc.CallOption) (*QueryGetTradingRewardResponse, error) // Queries a list of TradingReward items. TradingRewardAll(ctx context.Context, in *QueryAllTradingRewardRequest, opts ...grpc.CallOption) (*QueryAllTradingRewardResponse, error) + // Queries a StakingRewardParticipant by index. + StakingRewardParticipant(ctx context.Context, in *QueryGetStakingRewardParticipantRequest, opts ...grpc.CallOption) (*QueryGetStakingRewardParticipantResponse, error) + // Queries a list of StakingRewardParticipant items. + StakingRewardParticipantAll(ctx context.Context, in *QueryAllStakingRewardParticipantRequest, opts ...grpc.CallOption) (*QueryAllStakingRewardParticipantResponse, error) } type queryClient struct { @@ -618,6 +841,24 @@ func (c *queryClient) TradingRewardAll(ctx context.Context, in *QueryAllTradingR return out, nil } +func (c *queryClient) StakingRewardParticipant(ctx context.Context, in *QueryGetStakingRewardParticipantRequest, opts ...grpc.CallOption) (*QueryGetStakingRewardParticipantResponse, error) { + out := new(QueryGetStakingRewardParticipantResponse) + err := c.cc.Invoke(ctx, "/bze.v1.rewards.Query/StakingRewardParticipant", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) StakingRewardParticipantAll(ctx context.Context, in *QueryAllStakingRewardParticipantRequest, opts ...grpc.CallOption) (*QueryAllStakingRewardParticipantResponse, error) { + out := new(QueryAllStakingRewardParticipantResponse) + err := c.cc.Invoke(ctx, "/bze.v1.rewards.Query/StakingRewardParticipantAll", 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. @@ -630,6 +871,10 @@ type QueryServer interface { TradingReward(context.Context, *QueryGetTradingRewardRequest) (*QueryGetTradingRewardResponse, error) // Queries a list of TradingReward items. TradingRewardAll(context.Context, *QueryAllTradingRewardRequest) (*QueryAllTradingRewardResponse, error) + // Queries a StakingRewardParticipant by index. + StakingRewardParticipant(context.Context, *QueryGetStakingRewardParticipantRequest) (*QueryGetStakingRewardParticipantResponse, error) + // Queries a list of StakingRewardParticipant items. + StakingRewardParticipantAll(context.Context, *QueryAllStakingRewardParticipantRequest) (*QueryAllStakingRewardParticipantResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -651,6 +896,12 @@ func (*UnimplementedQueryServer) TradingReward(ctx context.Context, req *QueryGe func (*UnimplementedQueryServer) TradingRewardAll(ctx context.Context, req *QueryAllTradingRewardRequest) (*QueryAllTradingRewardResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method TradingRewardAll not implemented") } +func (*UnimplementedQueryServer) StakingRewardParticipant(ctx context.Context, req *QueryGetStakingRewardParticipantRequest) (*QueryGetStakingRewardParticipantResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method StakingRewardParticipant not implemented") +} +func (*UnimplementedQueryServer) StakingRewardParticipantAll(ctx context.Context, req *QueryAllStakingRewardParticipantRequest) (*QueryAllStakingRewardParticipantResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method StakingRewardParticipantAll not implemented") +} func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) @@ -746,6 +997,42 @@ func _Query_TradingRewardAll_Handler(srv interface{}, ctx context.Context, dec f return interceptor(ctx, in, info, handler) } +func _Query_StakingRewardParticipant_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryGetStakingRewardParticipantRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).StakingRewardParticipant(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/bze.v1.rewards.Query/StakingRewardParticipant", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).StakingRewardParticipant(ctx, req.(*QueryGetStakingRewardParticipantRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_StakingRewardParticipantAll_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryAllStakingRewardParticipantRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).StakingRewardParticipantAll(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/bze.v1.rewards.Query/StakingRewardParticipantAll", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).StakingRewardParticipantAll(ctx, req.(*QueryAllStakingRewardParticipantRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "bze.v1.rewards.Query", HandlerType: (*QueryServer)(nil), @@ -770,6 +1057,14 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "TradingRewardAll", Handler: _Query_TradingRewardAll_Handler, }, + { + MethodName: "StakingRewardParticipant", + Handler: _Query_StakingRewardParticipant_Handler, + }, + { + MethodName: "StakingRewardParticipantAll", + Handler: _Query_StakingRewardParticipantAll_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "rewards/query.proto", @@ -1108,10 +1403,10 @@ func (m *QueryAllTradingRewardResponse) MarshalToSizedBuffer(dAtA []byte) (int, i-- dAtA[i] = 0x12 } - if len(m.TradingReward) > 0 { - for iNdEx := len(m.TradingReward) - 1; iNdEx >= 0; iNdEx-- { + if len(m.List) > 0 { + for iNdEx := len(m.List) - 1; iNdEx >= 0; iNdEx-- { { - size, err := m.TradingReward[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + size, err := m.List[iNdEx].MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -1125,63 +1420,238 @@ func (m *QueryAllTradingRewardResponse) MarshalToSizedBuffer(dAtA []byte) (int, 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 +func (m *QueryGetStakingRewardParticipantRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err } - var l int - _ = l - return n + return dAtA[:n], nil } -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 (m *QueryGetStakingRewardParticipantRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryGetStakingRewardRequest) Size() (n int) { - if m == nil { - return 0 - } +func (m *QueryGetStakingRewardParticipantRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - l = len(m.RewardId) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 } - return n + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintQuery(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil } -func (m *QueryGetStakingRewardResponse) Size() (n int) { - if m == nil { - return 0 +func (m *QueryGetStakingRewardParticipantResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err } - var l int - _ = l - l = m.StakingReward.Size() - n += 1 + l + sovQuery(uint64(l)) - return n + return dAtA[:n], nil } -func (m *QueryAllStakingRewardRequest) Size() (n int) { - if m == nil { +func (m *QueryGetStakingRewardParticipantResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryGetStakingRewardParticipantResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.List) > 0 { + for iNdEx := len(m.List) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.List[iNdEx].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 (m *QueryAllStakingRewardParticipantRequest) 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 *QueryAllStakingRewardParticipantRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryAllStakingRewardParticipantRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.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 (m *QueryAllStakingRewardParticipantResponse) 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 *QueryAllStakingRewardParticipantResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryAllStakingRewardParticipantResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Pagination != nil { + { + size, err := m.Pagination.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintQuery(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.List) > 0 { + for iNdEx := len(m.List) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.List[iNdEx].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 (m *QueryGetStakingRewardRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.RewardId) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryGetStakingRewardResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.StakingReward.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *QueryAllStakingRewardRequest) Size() (n int) { + if m == nil { return 0 } var l int @@ -1255,8 +1725,76 @@ func (m *QueryAllTradingRewardResponse) Size() (n int) { } var l int _ = l - if len(m.TradingReward) > 0 { - for _, e := range m.TradingReward { + if len(m.List) > 0 { + for _, e := range m.List { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryGetStakingRewardParticipantRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryGetStakingRewardParticipantResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.List) > 0 { + for _, e := range m.List { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryAllStakingRewardParticipantRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryAllStakingRewardParticipantResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.List) > 0 { + for _, e := range m.List { l = e.Size() n += 1 + l + sovQuery(uint64(l)) } @@ -2060,7 +2598,7 @@ func (m *QueryAllTradingRewardResponse) Unmarshal(dAtA []byte) error { switch fieldNum { case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field TradingReward", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field List", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -2087,8 +2625,452 @@ func (m *QueryAllTradingRewardResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.TradingReward = append(m.TradingReward, TradingReward{}) - if err := m.TradingReward[len(m.TradingReward)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.List = append(m.List, TradingReward{}) + if err := m.List[len(m.List)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", 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 m.Pagination == nil { + m.Pagination = &query.PageResponse{} + } + if err := m.Pagination.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 (m *QueryGetStakingRewardParticipantRequest) 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: QueryGetStakingRewardParticipantRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGetStakingRewardParticipantRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", 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 m.Pagination == nil { + m.Pagination = &query.PageRequest{} + } + if err := m.Pagination.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 (m *QueryGetStakingRewardParticipantResponse) 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: QueryGetStakingRewardParticipantResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGetStakingRewardParticipantResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field List", 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 + } + m.List = append(m.List, StakingRewardParticipant{}) + if err := m.List[len(m.List)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", 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 m.Pagination == nil { + m.Pagination = &query.PageResponse{} + } + if err := m.Pagination.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 (m *QueryAllStakingRewardParticipantRequest) 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: QueryAllStakingRewardParticipantRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryAllStakingRewardParticipantRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Pagination", 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 m.Pagination == nil { + m.Pagination = &query.PageRequest{} + } + if err := m.Pagination.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 (m *QueryAllStakingRewardParticipantResponse) 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: QueryAllStakingRewardParticipantResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryAllStakingRewardParticipantResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field List", 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 + } + m.List = append(m.List, StakingRewardParticipant{}) + if err := m.List[len(m.List)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex diff --git a/x/rewards/types/query.pb.gw.go b/x/rewards/types/query.pb.gw.go index e7208d32..149a2535 100644 --- a/x/rewards/types/query.pb.gw.go +++ b/x/rewards/types/query.pb.gw.go @@ -152,15 +152,15 @@ func request_Query_TradingReward_0(ctx context.Context, marshaler runtime.Marsha _ = err ) - val, ok = pathParams["rewardId"] + val, ok = pathParams["reward_id"] if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "rewardId") + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "reward_id") } protoReq.RewardId, err = runtime.String(val) if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "rewardId", err) + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "reward_id", err) } msg, err := client.TradingReward(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) @@ -179,15 +179,15 @@ func local_request_Query_TradingReward_0(ctx context.Context, marshaler runtime. _ = err ) - val, ok = pathParams["rewardId"] + val, ok = pathParams["reward_id"] if !ok { - return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "rewardId") + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "reward_id") } protoReq.RewardId, err = runtime.String(val) if err != nil { - return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "rewardId", err) + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "reward_id", err) } msg, err := server.TradingReward(ctx, &protoReq) @@ -231,6 +231,114 @@ func local_request_Query_TradingRewardAll_0(ctx context.Context, marshaler runti } +var ( + filter_Query_StakingRewardParticipant_0 = &utilities.DoubleArray{Encoding: map[string]int{"address": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} +) + +func request_Query_StakingRewardParticipant_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryGetStakingRewardParticipantRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["address"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "address") + } + + protoReq.Address, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "address", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_StakingRewardParticipant_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.StakingRewardParticipant(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_StakingRewardParticipant_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryGetStakingRewardParticipantRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["address"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "address") + } + + protoReq.Address, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "address", err) + } + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_StakingRewardParticipant_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.StakingRewardParticipant(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_Query_StakingRewardParticipantAll_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_Query_StakingRewardParticipantAll_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryAllStakingRewardParticipantRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_StakingRewardParticipantAll_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.StakingRewardParticipantAll(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_StakingRewardParticipantAll_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryAllStakingRewardParticipantRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_StakingRewardParticipantAll_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.StakingRewardParticipantAll(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. @@ -352,6 +460,52 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_StakingRewardParticipant_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_StakingRewardParticipant_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_StakingRewardParticipant_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_StakingRewardParticipantAll_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_StakingRewardParticipantAll_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_StakingRewardParticipantAll_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -493,6 +647,46 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_StakingRewardParticipant_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_StakingRewardParticipant_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_StakingRewardParticipant_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_StakingRewardParticipantAll_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_StakingRewardParticipantAll_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_StakingRewardParticipantAll_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -503,9 +697,13 @@ var ( pattern_Query_StakingRewardAll_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"bze", "rewards", "v1", "staking_reward"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_Query_TradingReward_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"bze", "rewards", "v1", "trading_reward", "rewardId"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_TradingReward_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"bze", "rewards", "v1", "trading_reward", "reward_id"}, "", runtime.AssumeColonVerbOpt(true))) pattern_Query_TradingRewardAll_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"bze", "rewards", "v1", "trading_reward"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_StakingRewardParticipant_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"bze", "rewards", "v1", "staking_reward_participant", "address"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_StakingRewardParticipantAll_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"bze", "rewards", "v1", "staking_reward_participants"}, "", runtime.AssumeColonVerbOpt(true))) ) var ( @@ -518,4 +716,8 @@ var ( forward_Query_TradingReward_0 = runtime.ForwardResponseMessage forward_Query_TradingRewardAll_0 = runtime.ForwardResponseMessage + + forward_Query_StakingRewardParticipant_0 = runtime.ForwardResponseMessage + + forward_Query_StakingRewardParticipantAll_0 = runtime.ForwardResponseMessage ) diff --git a/x/rewards/types/staking_reward.pb.go b/x/rewards/types/staking_reward.pb.go index 00e18835..82304cc4 100644 --- a/x/rewards/types/staking_reward.pb.go +++ b/x/rewards/types/staking_reward.pb.go @@ -31,6 +31,7 @@ type StakingReward struct { Payouts uint32 `protobuf:"varint,6,opt,name=payouts,proto3" json:"payouts,omitempty"` MinStake uint64 `protobuf:"varint,7,opt,name=min_stake,json=minStake,proto3" json:"min_stake,omitempty"` Lock uint32 `protobuf:"varint,8,opt,name=lock,proto3" json:"lock,omitempty"` + StakedAmount string `protobuf:"bytes,9,opt,name=staked_amount,json=stakedAmount,proto3" json:"staked_amount,omitempty"` } func (m *StakingReward) Reset() { *m = StakingReward{} } @@ -122,6 +123,13 @@ func (m *StakingReward) GetLock() uint32 { return 0 } +func (m *StakingReward) GetStakedAmount() string { + if m != nil { + return m.StakedAmount + } + return "" +} + func init() { proto.RegisterType((*StakingReward)(nil), "bze.v1.rewards.StakingReward") } @@ -129,26 +137,26 @@ func init() { func init() { proto.RegisterFile("rewards/staking_reward.proto", fileDescriptor_a8c582f9c980c2bd) } var fileDescriptor_a8c582f9c980c2bd = []byte{ - // 290 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x3c, 0x90, 0xb1, 0x4e, 0xeb, 0x30, - 0x14, 0x86, 0xe3, 0x7b, 0x43, 0x9b, 0x9a, 0x86, 0xc1, 0x93, 0x05, 0xc8, 0x04, 0x58, 0x32, 0x40, - 0x22, 0xc4, 0x13, 0x80, 0x10, 0x12, 0x6b, 0xd8, 0x58, 0x22, 0xa7, 0xb1, 0x5a, 0xab, 0x8d, 0x1d, - 0x25, 0x0e, 0xd0, 0x3c, 0x05, 0x8f, 0xc5, 0xd8, 0x91, 0x11, 0x25, 0xaf, 0xc1, 0x80, 0x72, 0xdc, - 0xb0, 0xf9, 0xff, 0xfe, 0xcf, 0xd6, 0xf1, 0xc1, 0xa7, 0x95, 0x78, 0xe3, 0x55, 0x5e, 0xc7, 0xb5, - 0xe1, 0x6b, 0xa9, 0x96, 0xa9, 0xcd, 0x51, 0x59, 0x69, 0xa3, 0xc9, 0x51, 0xd6, 0x8a, 0xe8, 0xf5, - 0x26, 0xda, 0x4b, 0x17, 0x3f, 0x08, 0xfb, 0xcf, 0x56, 0x4c, 0x00, 0x91, 0x13, 0x3c, 0xb3, 0x65, - 0x2a, 0x73, 0x8a, 0x02, 0x14, 0xce, 0x12, 0xcf, 0x82, 0xa7, 0x9c, 0x9c, 0xe3, 0x79, 0x59, 0xc9, - 0x56, 0xa4, 0xbc, 0xd0, 0x8d, 0x32, 0xf4, 0x1f, 0xf4, 0x87, 0xc0, 0xee, 0x00, 0x91, 0x33, 0x6c, - 0x63, 0x9a, 0x0b, 0xa5, 0x0b, 0xfa, 0x1f, 0x0c, 0x0c, 0xe8, 0x61, 0x20, 0xe4, 0x12, 0xfb, 0xe3, - 0x68, 0x56, 0x71, 0x41, 0x99, 0xef, 0xa1, 0x95, 0x8e, 0xb1, 0x97, 0x37, 0x15, 0x37, 0x52, 0x2b, - 0x7a, 0x10, 0xa0, 0xd0, 0x4f, 0xfe, 0x32, 0xa1, 0x78, 0x5a, 0xf2, 0xad, 0x6e, 0x4c, 0x4d, 0x27, - 0x50, 0x8d, 0x71, 0x98, 0xbd, 0x90, 0x2a, 0x1d, 0x5e, 0x12, 0x74, 0x1a, 0xa0, 0xd0, 0x4d, 0xbc, - 0x42, 0xaa, 0xe1, 0x83, 0x82, 0x10, 0xec, 0x6e, 0xf4, 0x62, 0x4d, 0x3d, 0xb8, 0x03, 0xe7, 0xfb, - 0xc7, 0xcf, 0x8e, 0xa1, 0x5d, 0xc7, 0xd0, 0x77, 0xc7, 0xd0, 0x47, 0xcf, 0x9c, 0x5d, 0xcf, 0x9c, - 0xaf, 0x9e, 0x39, 0x2f, 0x57, 0x4b, 0x69, 0x56, 0x4d, 0x16, 0x2d, 0x74, 0x11, 0x67, 0xad, 0xb8, - 0xe6, 0x9b, 0x72, 0xc5, 0x8d, 0xe0, 0x90, 0xe2, 0xf7, 0x78, 0xdc, 0xb2, 0xd9, 0x96, 0xa2, 0xce, - 0x26, 0xb0, 0xdd, 0xdb, 0xdf, 0x00, 0x00, 0x00, 0xff, 0xff, 0xb6, 0x69, 0xca, 0xc4, 0x7d, 0x01, - 0x00, 0x00, + // 304 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x44, 0x91, 0xb1, 0x4e, 0xeb, 0x30, + 0x14, 0x86, 0xeb, 0xde, 0xde, 0x36, 0x35, 0x2d, 0x83, 0x27, 0x0b, 0x90, 0x09, 0xb0, 0x64, 0x80, + 0x44, 0x88, 0x27, 0x00, 0x21, 0x24, 0xd6, 0xb0, 0xb1, 0x44, 0x4e, 0x6d, 0xb5, 0x56, 0x1b, 0x3b, + 0x4a, 0x1c, 0xa0, 0x79, 0x0a, 0x5e, 0x81, 0xb7, 0x61, 0xec, 0xc8, 0x88, 0x92, 0x17, 0x41, 0x39, + 0x6e, 0x60, 0xcb, 0xff, 0x9d, 0x2f, 0xd6, 0x7f, 0x74, 0xf0, 0x49, 0x21, 0x5f, 0x79, 0x21, 0xca, + 0xa8, 0xb4, 0x7c, 0xad, 0xf4, 0x32, 0x71, 0x39, 0xcc, 0x0b, 0x63, 0x0d, 0x39, 0x4c, 0x6b, 0x19, + 0xbe, 0x5c, 0x87, 0x7b, 0xe9, 0xfc, 0x63, 0x88, 0xe7, 0x4f, 0x4e, 0x8c, 0x01, 0x91, 0x63, 0x3c, + 0x75, 0xc3, 0x44, 0x09, 0x8a, 0x7c, 0x14, 0x4c, 0x63, 0xcf, 0x81, 0x47, 0x41, 0xce, 0xf0, 0x2c, + 0x2f, 0x54, 0x2d, 0x13, 0x9e, 0x99, 0x4a, 0x5b, 0x3a, 0x84, 0xf9, 0x01, 0xb0, 0x5b, 0x40, 0xe4, + 0x14, 0xbb, 0x98, 0x08, 0xa9, 0x4d, 0x46, 0xff, 0x81, 0x81, 0x01, 0xdd, 0x77, 0x84, 0x5c, 0xe0, + 0x79, 0x5f, 0xcd, 0x29, 0x23, 0x50, 0x66, 0x7b, 0xe8, 0xa4, 0x23, 0xec, 0x89, 0xaa, 0xe0, 0x56, + 0x19, 0x4d, 0xff, 0xfb, 0x28, 0x98, 0xc7, 0xbf, 0x99, 0x50, 0x3c, 0xc9, 0xf9, 0xd6, 0x54, 0xb6, + 0xa4, 0x63, 0x18, 0xf5, 0xb1, 0xeb, 0x9e, 0x29, 0x9d, 0x74, 0x2f, 0x49, 0x3a, 0xf1, 0x51, 0x30, + 0x8a, 0xbd, 0x4c, 0xe9, 0x6e, 0x41, 0x49, 0x08, 0x1e, 0x6d, 0xcc, 0x62, 0x4d, 0x3d, 0xf8, 0x07, + 0xbe, 0xfb, 0x2e, 0x52, 0xf4, 0x0b, 0x4d, 0xff, 0xba, 0x48, 0xe1, 0x36, 0xba, 0x7b, 0xf8, 0x6c, + 0x18, 0xda, 0x35, 0x0c, 0x7d, 0x37, 0x0c, 0xbd, 0xb7, 0x6c, 0xb0, 0x6b, 0xd9, 0xe0, 0xab, 0x65, + 0x83, 0xe7, 0xcb, 0xa5, 0xb2, 0xab, 0x2a, 0x0d, 0x17, 0x26, 0x8b, 0xd2, 0x5a, 0x5e, 0xf1, 0x4d, + 0xbe, 0xe2, 0x56, 0x72, 0x48, 0xd1, 0x5b, 0xd4, 0x9f, 0xc2, 0x6e, 0x73, 0x59, 0xa6, 0x63, 0x38, + 0xc1, 0xcd, 0x4f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x62, 0x6c, 0x40, 0x77, 0xa2, 0x01, 0x00, 0x00, } func (m *StakingReward) Marshal() (dAtA []byte, err error) { @@ -171,6 +179,13 @@ func (m *StakingReward) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.StakedAmount) > 0 { + i -= len(m.StakedAmount) + copy(dAtA[i:], m.StakedAmount) + i = encodeVarintStakingReward(dAtA, i, uint64(len(m.StakedAmount))) + i-- + dAtA[i] = 0x4a + } if m.Lock != 0 { i = encodeVarintStakingReward(dAtA, i, uint64(m.Lock)) i-- @@ -267,6 +282,10 @@ func (m *StakingReward) Size() (n int) { if m.Lock != 0 { n += 1 + sovStakingReward(uint64(m.Lock)) } + l = len(m.StakedAmount) + if l > 0 { + n += 1 + l + sovStakingReward(uint64(l)) + } return n } @@ -509,6 +528,38 @@ func (m *StakingReward) Unmarshal(dAtA []byte) error { break } } + case 9: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field StakedAmount", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowStakingReward + } + 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 ErrInvalidLengthStakingReward + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthStakingReward + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.StakedAmount = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipStakingReward(dAtA[iNdEx:]) diff --git a/x/rewards/types/staking_reward_participant.pb.go b/x/rewards/types/staking_reward_participant.pb.go new file mode 100644 index 00000000..306db584 --- /dev/null +++ b/x/rewards/types/staking_reward_participant.pb.go @@ -0,0 +1,421 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: rewards/staking_reward_participant.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 StakingRewardParticipant struct { + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` + RewardId string `protobuf:"bytes,2,opt,name=reward_id,json=rewardId,proto3" json:"reward_id,omitempty"` + Amount string `protobuf:"bytes,3,opt,name=amount,proto3" json:"amount,omitempty"` +} + +func (m *StakingRewardParticipant) Reset() { *m = StakingRewardParticipant{} } +func (m *StakingRewardParticipant) String() string { return proto.CompactTextString(m) } +func (*StakingRewardParticipant) ProtoMessage() {} +func (*StakingRewardParticipant) Descriptor() ([]byte, []int) { + return fileDescriptor_c38d5e7e7b44d312, []int{0} +} +func (m *StakingRewardParticipant) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *StakingRewardParticipant) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_StakingRewardParticipant.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 *StakingRewardParticipant) XXX_Merge(src proto.Message) { + xxx_messageInfo_StakingRewardParticipant.Merge(m, src) +} +func (m *StakingRewardParticipant) XXX_Size() int { + return m.Size() +} +func (m *StakingRewardParticipant) XXX_DiscardUnknown() { + xxx_messageInfo_StakingRewardParticipant.DiscardUnknown(m) +} + +var xxx_messageInfo_StakingRewardParticipant proto.InternalMessageInfo + +func (m *StakingRewardParticipant) GetAddress() string { + if m != nil { + return m.Address + } + return "" +} + +func (m *StakingRewardParticipant) GetRewardId() string { + if m != nil { + return m.RewardId + } + return "" +} + +func (m *StakingRewardParticipant) GetAmount() string { + if m != nil { + return m.Amount + } + return "" +} + +func init() { + proto.RegisterType((*StakingRewardParticipant)(nil), "bze.v1.rewards.StakingRewardParticipant") +} + +func init() { + proto.RegisterFile("rewards/staking_reward_participant.proto", fileDescriptor_c38d5e7e7b44d312) +} + +var fileDescriptor_c38d5e7e7b44d312 = []byte{ + // 208 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xd2, 0x28, 0x4a, 0x2d, 0x4f, + 0x2c, 0x4a, 0x29, 0xd6, 0x2f, 0x2e, 0x49, 0xcc, 0xce, 0xcc, 0x4b, 0x8f, 0x87, 0xf0, 0xe3, 0x0b, + 0x12, 0x8b, 0x4a, 0x32, 0x93, 0x33, 0x0b, 0x12, 0xf3, 0x4a, 0xf4, 0x0a, 0x8a, 0xf2, 0x4b, 0xf2, + 0x85, 0xf8, 0x92, 0xaa, 0x52, 0xf5, 0xca, 0x0c, 0xf5, 0xa0, 0x1a, 0x94, 0x32, 0xb9, 0x24, 0x82, + 0x21, 0x7a, 0x82, 0xc0, 0x22, 0x01, 0x08, 0x1d, 0x42, 0x12, 0x5c, 0xec, 0x89, 0x29, 0x29, 0x45, + 0xa9, 0xc5, 0xc5, 0x12, 0x8c, 0x0a, 0x8c, 0x1a, 0x9c, 0x41, 0x30, 0xae, 0x90, 0x34, 0x17, 0x27, + 0xd4, 0x86, 0xcc, 0x14, 0x09, 0x26, 0xb0, 0x1c, 0x07, 0x44, 0xc0, 0x33, 0x45, 0x48, 0x8c, 0x8b, + 0x2d, 0x31, 0x37, 0xbf, 0x34, 0xaf, 0x44, 0x82, 0x19, 0x2c, 0x03, 0xe5, 0x39, 0xb9, 0x9d, 0x78, + 0x24, 0xc7, 0x78, 0xe1, 0x91, 0x1c, 0xe3, 0x83, 0x47, 0x72, 0x8c, 0x13, 0x1e, 0xcb, 0x31, 0x5c, + 0x78, 0x2c, 0xc7, 0x70, 0xe3, 0xb1, 0x1c, 0x43, 0x94, 0x4e, 0x7a, 0x66, 0x49, 0x46, 0x69, 0x92, + 0x5e, 0x72, 0x7e, 0xae, 0x7e, 0x52, 0x55, 0xaa, 0x6e, 0x62, 0x4e, 0x41, 0x46, 0x62, 0x49, 0x6a, + 0x22, 0x98, 0xa7, 0x5f, 0xa1, 0x0f, 0xf3, 0x5d, 0x49, 0x65, 0x41, 0x6a, 0x71, 0x12, 0x1b, 0xd8, + 0x27, 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0x8f, 0xf5, 0x58, 0xfb, 0xf5, 0x00, 0x00, 0x00, +} + +func (m *StakingRewardParticipant) 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 *StakingRewardParticipant) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *StakingRewardParticipant) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Amount) > 0 { + i -= len(m.Amount) + copy(dAtA[i:], m.Amount) + i = encodeVarintStakingRewardParticipant(dAtA, i, uint64(len(m.Amount))) + i-- + dAtA[i] = 0x1a + } + if len(m.RewardId) > 0 { + i -= len(m.RewardId) + copy(dAtA[i:], m.RewardId) + i = encodeVarintStakingRewardParticipant(dAtA, i, uint64(len(m.RewardId))) + i-- + dAtA[i] = 0x12 + } + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintStakingRewardParticipant(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintStakingRewardParticipant(dAtA []byte, offset int, v uint64) int { + offset -= sovStakingRewardParticipant(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *StakingRewardParticipant) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Address) + if l > 0 { + n += 1 + l + sovStakingRewardParticipant(uint64(l)) + } + l = len(m.RewardId) + if l > 0 { + n += 1 + l + sovStakingRewardParticipant(uint64(l)) + } + l = len(m.Amount) + if l > 0 { + n += 1 + l + sovStakingRewardParticipant(uint64(l)) + } + return n +} + +func sovStakingRewardParticipant(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozStakingRewardParticipant(x uint64) (n int) { + return sovStakingRewardParticipant(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *StakingRewardParticipant) 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 ErrIntOverflowStakingRewardParticipant + } + 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: StakingRewardParticipant: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: StakingRewardParticipant: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowStakingRewardParticipant + } + 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 ErrInvalidLengthStakingRewardParticipant + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthStakingRewardParticipant + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RewardId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowStakingRewardParticipant + } + 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 ErrInvalidLengthStakingRewardParticipant + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthStakingRewardParticipant + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.RewardId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowStakingRewardParticipant + } + 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 ErrInvalidLengthStakingRewardParticipant + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthStakingRewardParticipant + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Amount = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipStakingRewardParticipant(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthStakingRewardParticipant + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipStakingRewardParticipant(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, ErrIntOverflowStakingRewardParticipant + } + 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, ErrIntOverflowStakingRewardParticipant + } + 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, ErrIntOverflowStakingRewardParticipant + } + 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, ErrInvalidLengthStakingRewardParticipant + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupStakingRewardParticipant + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthStakingRewardParticipant + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthStakingRewardParticipant = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowStakingRewardParticipant = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupStakingRewardParticipant = fmt.Errorf("proto: unexpected end of group") +) diff --git a/x/rewards/types/tx.pb.go b/x/rewards/types/tx.pb.go index 716d5abd..2501c9b2 100644 --- a/x/rewards/types/tx.pb.go +++ b/x/rewards/types/tx.pb.go @@ -387,6 +387,190 @@ func (m *MsgCreateTradingRewardResponse) GetRewardId() string { return "" } +type MsgJoinStaking struct { + Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` + RewardId string `protobuf:"bytes,2,opt,name=reward_id,json=rewardId,proto3" json:"reward_id,omitempty"` + Amount string `protobuf:"bytes,3,opt,name=amount,proto3" json:"amount,omitempty"` +} + +func (m *MsgJoinStaking) Reset() { *m = MsgJoinStaking{} } +func (m *MsgJoinStaking) String() string { return proto.CompactTextString(m) } +func (*MsgJoinStaking) ProtoMessage() {} +func (*MsgJoinStaking) Descriptor() ([]byte, []int) { + return fileDescriptor_4c0d543e6be8610a, []int{6} +} +func (m *MsgJoinStaking) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgJoinStaking) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgJoinStaking.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 *MsgJoinStaking) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgJoinStaking.Merge(m, src) +} +func (m *MsgJoinStaking) XXX_Size() int { + return m.Size() +} +func (m *MsgJoinStaking) XXX_DiscardUnknown() { + xxx_messageInfo_MsgJoinStaking.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgJoinStaking proto.InternalMessageInfo + +func (m *MsgJoinStaking) GetCreator() string { + if m != nil { + return m.Creator + } + return "" +} + +func (m *MsgJoinStaking) GetRewardId() string { + if m != nil { + return m.RewardId + } + return "" +} + +func (m *MsgJoinStaking) GetAmount() string { + if m != nil { + return m.Amount + } + return "" +} + +type MsgJoinStakingResponse struct { +} + +func (m *MsgJoinStakingResponse) Reset() { *m = MsgJoinStakingResponse{} } +func (m *MsgJoinStakingResponse) String() string { return proto.CompactTextString(m) } +func (*MsgJoinStakingResponse) ProtoMessage() {} +func (*MsgJoinStakingResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_4c0d543e6be8610a, []int{7} +} +func (m *MsgJoinStakingResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgJoinStakingResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgJoinStakingResponse.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 *MsgJoinStakingResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgJoinStakingResponse.Merge(m, src) +} +func (m *MsgJoinStakingResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgJoinStakingResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgJoinStakingResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgJoinStakingResponse proto.InternalMessageInfo + +type MsgExitStaking struct { + Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` + RewardId string `protobuf:"bytes,2,opt,name=rewardId,proto3" json:"rewardId,omitempty"` +} + +func (m *MsgExitStaking) Reset() { *m = MsgExitStaking{} } +func (m *MsgExitStaking) String() string { return proto.CompactTextString(m) } +func (*MsgExitStaking) ProtoMessage() {} +func (*MsgExitStaking) Descriptor() ([]byte, []int) { + return fileDescriptor_4c0d543e6be8610a, []int{8} +} +func (m *MsgExitStaking) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgExitStaking) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgExitStaking.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 *MsgExitStaking) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgExitStaking.Merge(m, src) +} +func (m *MsgExitStaking) XXX_Size() int { + return m.Size() +} +func (m *MsgExitStaking) XXX_DiscardUnknown() { + xxx_messageInfo_MsgExitStaking.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgExitStaking proto.InternalMessageInfo + +func (m *MsgExitStaking) GetCreator() string { + if m != nil { + return m.Creator + } + return "" +} + +func (m *MsgExitStaking) GetRewardId() string { + if m != nil { + return m.RewardId + } + return "" +} + +type MsgExitStakingResponse struct { +} + +func (m *MsgExitStakingResponse) Reset() { *m = MsgExitStakingResponse{} } +func (m *MsgExitStakingResponse) String() string { return proto.CompactTextString(m) } +func (*MsgExitStakingResponse) ProtoMessage() {} +func (*MsgExitStakingResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_4c0d543e6be8610a, []int{9} +} +func (m *MsgExitStakingResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgExitStakingResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgExitStakingResponse.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 *MsgExitStakingResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgExitStakingResponse.Merge(m, src) +} +func (m *MsgExitStakingResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgExitStakingResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgExitStakingResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgExitStakingResponse proto.InternalMessageInfo + func init() { proto.RegisterType((*MsgCreateStakingReward)(nil), "bze.v1.rewards.MsgCreateStakingReward") proto.RegisterType((*MsgCreateStakingRewardResponse)(nil), "bze.v1.rewards.MsgCreateStakingRewardResponse") @@ -394,41 +578,49 @@ func init() { proto.RegisterType((*MsgUpdateStakingRewardResponse)(nil), "bze.v1.rewards.MsgUpdateStakingRewardResponse") proto.RegisterType((*MsgCreateTradingReward)(nil), "bze.v1.rewards.MsgCreateTradingReward") proto.RegisterType((*MsgCreateTradingRewardResponse)(nil), "bze.v1.rewards.MsgCreateTradingRewardResponse") + proto.RegisterType((*MsgJoinStaking)(nil), "bze.v1.rewards.MsgJoinStaking") + proto.RegisterType((*MsgJoinStakingResponse)(nil), "bze.v1.rewards.MsgJoinStakingResponse") + proto.RegisterType((*MsgExitStaking)(nil), "bze.v1.rewards.MsgExitStaking") + proto.RegisterType((*MsgExitStakingResponse)(nil), "bze.v1.rewards.MsgExitStakingResponse") } func init() { proto.RegisterFile("rewards/tx.proto", fileDescriptor_4c0d543e6be8610a) } var fileDescriptor_4c0d543e6be8610a = []byte{ - // 449 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x54, 0xbd, 0xce, 0xd3, 0x30, - 0x14, 0x6d, 0xda, 0x7e, 0x3f, 0x35, 0x05, 0x21, 0x17, 0xa1, 0xa8, 0xa0, 0x50, 0x82, 0x84, 0x18, - 0x20, 0x11, 0x30, 0x33, 0xf0, 0x23, 0xa4, 0x0e, 0x5d, 0x0a, 0x2c, 0x2c, 0x91, 0x53, 0x5b, 0xa9, - 0x95, 0xc6, 0x8e, 0x6c, 0x17, 0x4a, 0x9f, 0x82, 0x97, 0x42, 0x62, 0xac, 0x98, 0x18, 0x51, 0xbb, - 0xf0, 0x18, 0x28, 0x76, 0x1a, 0x6a, 0xc9, 0x54, 0x65, 0xf9, 0xb6, 0x9c, 0x73, 0x8f, 0x7c, 0xef, - 0xb9, 0xc7, 0x31, 0xb8, 0x29, 0xc8, 0x67, 0x24, 0xb0, 0x8c, 0xd5, 0x2a, 0x2a, 0x05, 0x57, 0x1c, - 0xde, 0x48, 0xd7, 0x24, 0xfa, 0xf4, 0x34, 0xaa, 0x0b, 0xc3, 0xbb, 0x8d, 0x42, 0x20, 0x4c, 0x59, - 0x96, 0x18, 0x6c, 0xd4, 0xe1, 0x6f, 0x0f, 0xdc, 0x9e, 0xc8, 0xec, 0xb5, 0x20, 0x48, 0x91, 0x77, - 0x0a, 0xe5, 0x94, 0x65, 0x53, 0x2d, 0x80, 0x3e, 0xb8, 0x98, 0x55, 0x34, 0x17, 0xbe, 0x37, 0xf2, - 0x1e, 0xf5, 0xa6, 0x7b, 0x08, 0xef, 0x83, 0x7e, 0x29, 0xe8, 0x9a, 0x24, 0xa8, 0xe0, 0x4b, 0xa6, - 0xfc, 0xb6, 0x2e, 0x5f, 0xd3, 0xdc, 0x4b, 0x4d, 0xc1, 0x7b, 0xc0, 0xc0, 0x04, 0x13, 0xc6, 0x0b, - 0xbf, 0xa3, 0x15, 0x40, 0x53, 0x6f, 0x2a, 0x06, 0x3e, 0x00, 0xd7, 0xa5, 0x69, 0x57, 0x4b, 0xba, - 0x5a, 0xd2, 0xaf, 0x49, 0x23, 0x1a, 0x82, 0x4b, 0xbc, 0x14, 0x48, 0x51, 0xce, 0xfc, 0x33, 0x5d, - 0x6f, 0x30, 0xbc, 0x03, 0x7a, 0x05, 0x65, 0x49, 0xa5, 0x27, 0xfe, 0xb9, 0x29, 0x16, 0x94, 0x55, - 0x1e, 0x08, 0x84, 0xa0, 0xbb, 0xe0, 0xb3, 0xdc, 0xbf, 0xd0, 0xbc, 0xfe, 0x0e, 0x5f, 0x80, 0xc0, - 0xed, 0x74, 0x4a, 0x64, 0xc9, 0x99, 0x24, 0xd5, 0x91, 0x66, 0x39, 0x09, 0xc5, 0xb5, 0xe7, 0x4b, - 0x43, 0x8c, 0x71, 0x98, 0xeb, 0x45, 0x7d, 0x28, 0xf1, 0x7f, 0x2c, 0xca, 0x3a, 0xb0, 0x6d, 0x1f, - 0x68, 0x99, 0xeb, 0xd8, 0xe6, 0xc2, 0x91, 0x9e, 0xd5, 0xd1, 0x6c, 0x3f, 0x6b, 0xf8, 0xed, 0x30, - 0xb8, 0xf7, 0x26, 0xda, 0x2b, 0x09, 0xee, 0x70, 0xec, 0xae, 0x23, 0x13, 0x24, 0x72, 0xa2, 0x2a, - 0xbf, 0x75, 0x60, 0x86, 0x18, 0x63, 0x78, 0x0b, 0x9c, 0xc9, 0x05, 0x57, 0xb2, 0x0e, 0xcb, 0x00, - 0x2b, 0x15, 0xcb, 0xc6, 0x49, 0xa9, 0x3c, 0xfb, 0xd1, 0x06, 0x9d, 0x89, 0xcc, 0x60, 0x01, 0x06, - 0xae, 0x3b, 0xfc, 0x30, 0xb2, 0xff, 0x86, 0xc8, 0x7d, 0x03, 0x86, 0xd1, 0x69, 0xba, 0x66, 0xa6, - 0x02, 0x0c, 0x5c, 0x37, 0xc1, 0xd5, 0xce, 0xa1, 0x73, 0xb6, 0x3b, 0x12, 0xf6, 0x5f, 0x77, 0x76, - 0xd0, 0xff, 0x76, 0x67, 0xe9, 0x8e, 0xb8, 0x73, 0x6e, 0xfc, 0xd5, 0xdb, 0xef, 0xdb, 0xc0, 0xdb, - 0x6c, 0x03, 0xef, 0xd7, 0x36, 0xf0, 0xbe, 0xee, 0x82, 0xd6, 0x66, 0x17, 0xb4, 0x7e, 0xee, 0x82, - 0xd6, 0xc7, 0xc7, 0x19, 0x55, 0xf3, 0x65, 0x1a, 0xcd, 0x78, 0x11, 0xa7, 0x6b, 0xf2, 0x04, 0x2d, - 0xca, 0x39, 0x52, 0x04, 0x69, 0x14, 0xaf, 0xe2, 0xe6, 0xad, 0xf9, 0x52, 0x12, 0x99, 0x9e, 0xeb, - 0x37, 0xe6, 0xf9, 0x9f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x54, 0x90, 0x77, 0x30, 0xa5, 0x04, 0x00, - 0x00, + // 518 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x54, 0x4f, 0x6f, 0x13, 0x3f, + 0x10, 0xcd, 0x36, 0x69, 0xda, 0x4e, 0xfb, 0xab, 0x7e, 0x72, 0x51, 0xb5, 0x0a, 0xd2, 0x52, 0x16, + 0xa9, 0xe2, 0x00, 0x1b, 0x01, 0x67, 0x0e, 0xfc, 0xab, 0x54, 0xa4, 0x5c, 0x02, 0xbd, 0x70, 0x59, + 0x39, 0x59, 0x6b, 0x6b, 0x25, 0xbb, 0x5e, 0xd9, 0x0e, 0x84, 0x9c, 0xf8, 0x08, 0x7c, 0x29, 0x24, + 0x8e, 0x3d, 0x72, 0x44, 0xc9, 0x85, 0x8f, 0x81, 0xd6, 0x76, 0x16, 0x1b, 0x99, 0x50, 0x38, 0x70, + 0xdb, 0x79, 0x33, 0x3b, 0xcf, 0x6f, 0xde, 0xd8, 0xf0, 0x3f, 0x27, 0xef, 0x30, 0xcf, 0x44, 0x5f, + 0xce, 0x93, 0x8a, 0x33, 0xc9, 0xd0, 0xe1, 0x68, 0x41, 0x92, 0xb7, 0x0f, 0x12, 0x93, 0x88, 0xbf, + 0x05, 0x70, 0x3c, 0x10, 0xf9, 0x33, 0x4e, 0xb0, 0x24, 0xaf, 0x24, 0x9e, 0xd0, 0x32, 0x1f, 0xaa, + 0x1c, 0x0a, 0x61, 0x67, 0x5c, 0xc3, 0x8c, 0x87, 0xc1, 0x49, 0x70, 0x77, 0x6f, 0xb8, 0x0e, 0xd1, + 0x6d, 0x38, 0xa8, 0x38, 0x5d, 0x90, 0x14, 0x17, 0x6c, 0x56, 0xca, 0x70, 0x4b, 0xa5, 0xf7, 0x15, + 0xf6, 0x44, 0x41, 0xe8, 0x16, 0xe8, 0x30, 0xcd, 0x48, 0xc9, 0x8a, 0xb0, 0xad, 0x2a, 0x40, 0x41, + 0xcf, 0x6b, 0x04, 0xdd, 0x81, 0xff, 0x84, 0xa6, 0x33, 0x25, 0x1d, 0x55, 0x72, 0x60, 0x40, 0x5d, + 0xd4, 0x83, 0xdd, 0x6c, 0xc6, 0xb1, 0xa4, 0xac, 0x0c, 0xb7, 0x55, 0xbe, 0x89, 0xd1, 0x4d, 0xd8, + 0x2b, 0x68, 0x99, 0xd6, 0xf5, 0x24, 0xec, 0xea, 0x64, 0x41, 0xcb, 0x5a, 0x03, 0x41, 0x08, 0x3a, + 0x53, 0x36, 0x9e, 0x84, 0x3b, 0x0a, 0x57, 0xdf, 0xf1, 0x63, 0x88, 0xfc, 0x4a, 0x87, 0x44, 0x54, + 0xac, 0x14, 0xa4, 0x6e, 0xa9, 0xe7, 0x92, 0xd2, 0xcc, 0x68, 0xde, 0xd5, 0xc0, 0x79, 0x16, 0x4f, + 0xd4, 0xa0, 0x2e, 0xaa, 0xec, 0x0f, 0x06, 0xe5, 0x34, 0xdc, 0x72, 0x1b, 0x3a, 0xe2, 0xda, 0xae, + 0xb8, 0xf8, 0x44, 0x9d, 0xd5, 0x43, 0xb6, 0x3e, 0x6b, 0xfc, 0xc9, 0x36, 0xee, 0x35, 0xc7, 0xd9, + 0xbf, 0x32, 0xce, 0x3e, 0x76, 0xc7, 0xe3, 0x09, 0xe6, 0x13, 0x22, 0x6b, 0xbd, 0xc6, 0x30, 0x0d, + 0x9c, 0x67, 0xe8, 0x06, 0x6c, 0x8b, 0x29, 0x93, 0xc2, 0x98, 0xa5, 0x03, 0xc7, 0x15, 0x47, 0xc6, + 0xf5, 0x5c, 0x49, 0xe1, 0x70, 0x20, 0xf2, 0x97, 0x4c, 0x1b, 0x4f, 0xcb, 0xfc, 0x6f, 0xdd, 0x38, + 0x86, 0xae, 0x19, 0x8a, 0x96, 0x6c, 0xa2, 0x38, 0x54, 0x63, 0xb6, 0x08, 0x1a, 0x07, 0xce, 0x14, + 0xf5, 0x8b, 0x39, 0x95, 0xbf, 0xa7, 0xee, 0x41, 0xc3, 0xf4, 0x33, 0xb3, 0x61, 0xb0, 0xfa, 0xac, + 0x19, 0x1e, 0x7e, 0xe8, 0x40, 0x7b, 0x20, 0x72, 0x54, 0xc0, 0x91, 0xef, 0x82, 0x9e, 0x26, 0xee, + 0x65, 0x4e, 0xfc, 0xeb, 0xdd, 0x4b, 0xae, 0x57, 0xd7, 0x0c, 0xbc, 0x80, 0x23, 0xdf, 0x9a, 0xfb, + 0xe8, 0x3c, 0x75, 0x5e, 0xba, 0x0d, 0x9b, 0xfc, 0x43, 0x9d, 0xbb, 0xc5, 0xbf, 0x56, 0xe7, 0xd4, + 0x6d, 0x50, 0xe7, 0x5f, 0xa7, 0x0b, 0xd8, 0xb7, 0xd7, 0x25, 0xf2, 0xfc, 0x6e, 0xe5, 0x7b, 0xa7, + 0x9b, 0xf3, 0x76, 0x5b, 0x7b, 0x15, 0x7c, 0x6d, 0xad, 0xbc, 0xb7, 0xad, 0x67, 0x05, 0x9e, 0x9e, + 0x7d, 0x5e, 0x46, 0xc1, 0xd5, 0x32, 0x0a, 0xbe, 0x2e, 0xa3, 0xe0, 0xe3, 0x2a, 0x6a, 0x5d, 0xad, + 0xa2, 0xd6, 0x97, 0x55, 0xd4, 0x7a, 0x73, 0x2f, 0xa7, 0xf2, 0x72, 0x36, 0x4a, 0xc6, 0xac, 0xe8, + 0x8f, 0x16, 0xe4, 0x3e, 0x9e, 0x56, 0x97, 0x58, 0x12, 0xac, 0xa2, 0xfe, 0xbc, 0xdf, 0x3c, 0xfd, + 0xef, 0x2b, 0x22, 0x46, 0x5d, 0xf5, 0xfc, 0x3f, 0xfa, 0x1e, 0x00, 0x00, 0xff, 0xff, 0x65, 0xf6, + 0x35, 0x33, 0x12, 0x06, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -446,6 +638,8 @@ type MsgClient interface { CreateStakingReward(ctx context.Context, in *MsgCreateStakingReward, opts ...grpc.CallOption) (*MsgCreateStakingRewardResponse, error) UpdateStakingReward(ctx context.Context, in *MsgUpdateStakingReward, opts ...grpc.CallOption) (*MsgUpdateStakingRewardResponse, error) CreateTradingReward(ctx context.Context, in *MsgCreateTradingReward, opts ...grpc.CallOption) (*MsgCreateTradingRewardResponse, error) + JoinStaking(ctx context.Context, in *MsgJoinStaking, opts ...grpc.CallOption) (*MsgJoinStakingResponse, error) + ExitStaking(ctx context.Context, in *MsgExitStaking, opts ...grpc.CallOption) (*MsgExitStakingResponse, error) } type msgClient struct { @@ -483,11 +677,31 @@ func (c *msgClient) CreateTradingReward(ctx context.Context, in *MsgCreateTradin return out, nil } +func (c *msgClient) JoinStaking(ctx context.Context, in *MsgJoinStaking, opts ...grpc.CallOption) (*MsgJoinStakingResponse, error) { + out := new(MsgJoinStakingResponse) + err := c.cc.Invoke(ctx, "/bze.v1.rewards.Msg/JoinStaking", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *msgClient) ExitStaking(ctx context.Context, in *MsgExitStaking, opts ...grpc.CallOption) (*MsgExitStakingResponse, error) { + out := new(MsgExitStakingResponse) + err := c.cc.Invoke(ctx, "/bze.v1.rewards.Msg/ExitStaking", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // MsgServer is the server API for Msg service. type MsgServer interface { CreateStakingReward(context.Context, *MsgCreateStakingReward) (*MsgCreateStakingRewardResponse, error) UpdateStakingReward(context.Context, *MsgUpdateStakingReward) (*MsgUpdateStakingRewardResponse, error) CreateTradingReward(context.Context, *MsgCreateTradingReward) (*MsgCreateTradingRewardResponse, error) + JoinStaking(context.Context, *MsgJoinStaking) (*MsgJoinStakingResponse, error) + ExitStaking(context.Context, *MsgExitStaking) (*MsgExitStakingResponse, error) } // UnimplementedMsgServer can be embedded to have forward compatible implementations. @@ -503,6 +717,12 @@ func (*UnimplementedMsgServer) UpdateStakingReward(ctx context.Context, req *Msg func (*UnimplementedMsgServer) CreateTradingReward(ctx context.Context, req *MsgCreateTradingReward) (*MsgCreateTradingRewardResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method CreateTradingReward not implemented") } +func (*UnimplementedMsgServer) JoinStaking(ctx context.Context, req *MsgJoinStaking) (*MsgJoinStakingResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method JoinStaking not implemented") +} +func (*UnimplementedMsgServer) ExitStaking(ctx context.Context, req *MsgExitStaking) (*MsgExitStakingResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ExitStaking not implemented") +} func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) @@ -562,6 +782,42 @@ func _Msg_CreateTradingReward_Handler(srv interface{}, ctx context.Context, dec return interceptor(ctx, in, info, handler) } +func _Msg_JoinStaking_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgJoinStaking) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).JoinStaking(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/bze.v1.rewards.Msg/JoinStaking", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).JoinStaking(ctx, req.(*MsgJoinStaking)) + } + return interceptor(ctx, in, info, handler) +} + +func _Msg_ExitStaking_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgExitStaking) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).ExitStaking(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/bze.v1.rewards.Msg/ExitStaking", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).ExitStaking(ctx, req.(*MsgExitStaking)) + } + return interceptor(ctx, in, info, handler) +} + var _Msg_serviceDesc = grpc.ServiceDesc{ ServiceName: "bze.v1.rewards.Msg", HandlerType: (*MsgServer)(nil), @@ -578,6 +834,14 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ MethodName: "CreateTradingReward", Handler: _Msg_CreateTradingReward_Handler, }, + { + MethodName: "JoinStaking", + Handler: _Msg_JoinStaking_Handler, + }, + { + MethodName: "ExitStaking", + Handler: _Msg_ExitStaking_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "rewards/tx.proto", @@ -847,76 +1111,203 @@ func (m *MsgCreateTradingRewardResponse) MarshalToSizedBuffer(dAtA []byte) (int, return len(dAtA) - i, nil } -func encodeVarintTx(dAtA []byte, offset int, v uint64) int { - offset -= sovTx(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ +func (m *MsgJoinStaking) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err } - dAtA[offset] = uint8(v) - return base + return dAtA[:n], nil } -func (m *MsgCreateStakingReward) Size() (n int) { - if m == nil { - return 0 - } + +func (m *MsgJoinStaking) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgJoinStaking) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - l = len(m.Creator) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = len(m.PrizeAmount) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = len(m.PrizeDenom) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = len(m.StakingDenom) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) - } - l = len(m.Duration) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) + if len(m.Amount) > 0 { + i -= len(m.Amount) + copy(dAtA[i:], m.Amount) + i = encodeVarintTx(dAtA, i, uint64(len(m.Amount))) + i-- + dAtA[i] = 0x1a } - l = len(m.MinStake) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) + if len(m.RewardId) > 0 { + i -= len(m.RewardId) + copy(dAtA[i:], m.RewardId) + i = encodeVarintTx(dAtA, i, uint64(len(m.RewardId))) + i-- + dAtA[i] = 0x12 } - l = len(m.Lock) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) + if len(m.Creator) > 0 { + i -= len(m.Creator) + copy(dAtA[i:], m.Creator) + i = encodeVarintTx(dAtA, i, uint64(len(m.Creator))) + i-- + dAtA[i] = 0xa } - return n + return len(dAtA) - i, nil } -func (m *MsgCreateStakingRewardResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.RewardId) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) +func (m *MsgJoinStakingResponse) 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 n + return dAtA[:n], nil } -func (m *MsgUpdateStakingReward) Size() (n int) { - if m == nil { - return 0 - } +func (m *MsgJoinStakingResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgJoinStakingResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - l = len(m.Creator) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) + return len(dAtA) - i, nil +} + +func (m *MsgExitStaking) 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 *MsgExitStaking) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgExitStaking) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.RewardId) > 0 { + i -= len(m.RewardId) + copy(dAtA[i:], m.RewardId) + i = encodeVarintTx(dAtA, i, uint64(len(m.RewardId))) + i-- + dAtA[i] = 0x12 + } + if len(m.Creator) > 0 { + i -= len(m.Creator) + copy(dAtA[i:], m.Creator) + i = encodeVarintTx(dAtA, i, uint64(len(m.Creator))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgExitStakingResponse) 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 *MsgExitStakingResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgExitStakingResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func encodeVarintTx(dAtA []byte, offset int, v uint64) int { + offset -= sovTx(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *MsgCreateStakingReward) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Creator) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.PrizeAmount) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.PrizeDenom) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.StakingDenom) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Duration) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.MinStake) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Lock) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgCreateStakingRewardResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.RewardId) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgUpdateStakingReward) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Creator) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) } l = len(m.RewardId) if l > 0 { @@ -968,29 +1359,637 @@ func (m *MsgCreateTradingReward) Size() (n int) { if l > 0 { n += 1 + l + sovTx(uint64(l)) } - return n -} + return n +} + +func (m *MsgCreateTradingRewardResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.RewardId) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgJoinStaking) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Creator) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.RewardId) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Amount) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgJoinStakingResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *MsgExitStaking) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Creator) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.RewardId) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgExitStakingResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func sovTx(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozTx(x uint64) (n int) { + return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *MsgCreateStakingReward) 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 ErrIntOverflowTx + } + 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: MsgCreateStakingReward: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgCreateStakingReward: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Creator", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Creator = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PrizeAmount", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PrizeAmount = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PrizeDenom", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PrizeDenom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field StakingDenom", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.StakingDenom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Duration", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Duration = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MinStake", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.MinStake = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Lock", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Lock = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgCreateStakingRewardResponse) 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 ErrIntOverflowTx + } + 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: MsgCreateStakingRewardResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgCreateStakingRewardResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RewardId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.RewardId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgUpdateStakingReward) 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 ErrIntOverflowTx + } + 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: MsgUpdateStakingReward: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateStakingReward: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Creator", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Creator = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RewardId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.RewardId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Duration", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Duration = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgUpdateStakingRewardResponse) 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 ErrIntOverflowTx + } + 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: MsgUpdateStakingRewardResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgUpdateStakingRewardResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } -func (m *MsgCreateTradingRewardResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.RewardId) - if l > 0 { - n += 1 + l + sovTx(uint64(l)) + if iNdEx > l { + return io.ErrUnexpectedEOF } - return n -} - -func sovTx(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozTx(x uint64) (n int) { - return sovTx(uint64((x << 1) ^ uint64((int64(x) >> 63)))) + return nil } -func (m *MsgCreateStakingReward) Unmarshal(dAtA []byte) error { +func (m *MsgCreateTradingReward) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1013,10 +2012,10 @@ func (m *MsgCreateStakingReward) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgCreateStakingReward: wiretype end group for non-group") + return fmt.Errorf("proto: MsgCreateTradingReward: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgCreateStakingReward: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgCreateTradingReward: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -1116,38 +2115,6 @@ func (m *MsgCreateStakingReward) Unmarshal(dAtA []byte) error { m.PrizeDenom = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field StakingDenom", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - 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 ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.StakingDenom = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 5: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Duration", wireType) } @@ -1179,9 +2146,9 @@ func (m *MsgCreateStakingReward) Unmarshal(dAtA []byte) error { } m.Duration = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 6: + case 5: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field MinStake", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field MarketId", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -1209,11 +2176,11 @@ func (m *MsgCreateStakingReward) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.MinStake = string(dAtA[iNdEx:postIndex]) + m.MarketId = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 7: + case 6: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Lock", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Slots", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -1241,7 +2208,7 @@ func (m *MsgCreateStakingReward) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Lock = string(dAtA[iNdEx:postIndex]) + m.Slots = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex @@ -1264,7 +2231,7 @@ func (m *MsgCreateStakingReward) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgCreateStakingRewardResponse) Unmarshal(dAtA []byte) error { +func (m *MsgCreateTradingRewardResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1287,10 +2254,10 @@ func (m *MsgCreateStakingRewardResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgCreateStakingRewardResponse: wiretype end group for non-group") + return fmt.Errorf("proto: MsgCreateTradingRewardResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgCreateStakingRewardResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgCreateTradingRewardResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -1346,7 +2313,7 @@ func (m *MsgCreateStakingRewardResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgUpdateStakingReward) Unmarshal(dAtA []byte) error { +func (m *MsgJoinStaking) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1369,10 +2336,10 @@ func (m *MsgUpdateStakingReward) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgUpdateStakingReward: wiretype end group for non-group") + return fmt.Errorf("proto: MsgJoinStaking: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgUpdateStakingReward: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgJoinStaking: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -1441,7 +2408,7 @@ func (m *MsgUpdateStakingReward) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Duration", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -1469,7 +2436,7 @@ func (m *MsgUpdateStakingReward) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Duration = string(dAtA[iNdEx:postIndex]) + m.Amount = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex @@ -1492,7 +2459,7 @@ func (m *MsgUpdateStakingReward) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgUpdateStakingRewardResponse) Unmarshal(dAtA []byte) error { +func (m *MsgJoinStakingResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1515,10 +2482,10 @@ func (m *MsgUpdateStakingRewardResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgUpdateStakingRewardResponse: wiretype end group for non-group") + return fmt.Errorf("proto: MsgJoinStakingResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgUpdateStakingRewardResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgJoinStakingResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { default: @@ -1542,7 +2509,7 @@ func (m *MsgUpdateStakingRewardResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgCreateTradingReward) Unmarshal(dAtA []byte) error { +func (m *MsgExitStaking) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1565,10 +2532,10 @@ func (m *MsgCreateTradingReward) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgCreateTradingReward: wiretype end group for non-group") + return fmt.Errorf("proto: MsgExitStaking: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgCreateTradingReward: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgExitStaking: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -1605,135 +2572,7 @@ func (m *MsgCreateTradingReward) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PrizeAmount", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - 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 ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.PrizeAmount = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PrizeDenom", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - 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 ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.PrizeDenom = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Duration", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - 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 ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Duration = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field MarketId", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - 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 ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.MarketId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 6: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Slots", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field RewardId", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -1761,7 +2600,7 @@ func (m *MsgCreateTradingReward) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Slots = string(dAtA[iNdEx:postIndex]) + m.RewardId = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex @@ -1784,7 +2623,7 @@ func (m *MsgCreateTradingReward) Unmarshal(dAtA []byte) error { } return nil } -func (m *MsgCreateTradingRewardResponse) Unmarshal(dAtA []byte) error { +func (m *MsgExitStakingResponse) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1807,44 +2646,12 @@ func (m *MsgCreateTradingRewardResponse) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: MsgCreateTradingRewardResponse: wiretype end group for non-group") + return fmt.Errorf("proto: MsgExitStakingResponse: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: MsgCreateTradingRewardResponse: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: MsgExitStakingResponse: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RewardId", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowTx - } - 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 ErrInvalidLengthTx - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthTx - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.RewardId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipTx(dAtA[iNdEx:]) From bde7b09c1346e17e366648769a8d5a3776390396 Mon Sep 17 00:00:00 2001 From: faneaatiku Date: Mon, 18 Mar 2024 00:40:56 +0200 Subject: [PATCH 11/35] added staking rewards claim, join and exit --- docs/static/openapi.yml | 42 ++ go.mod | 3 + go.sum | 12 + proto/rewards/staking_reward.proto | 3 +- .../rewards/staking_reward_participant.proto | 3 +- proto/rewards/tx.proto | 10 + .../bze-alphateam/bze/bze.v1.rewards/index.ts | 96 ++-- .../bze/bze.v1.rewards/module/index.ts | 15 +- .../bze/bze.v1.rewards/module/rest.ts | 4 + .../module/types/rewards/staking_reward.ts | 28 + .../rewards/staking_reward_participant.ts | 21 + .../bze.v1.rewards/module/types/rewards/tx.ts | 155 +++++- x/rewards/README.md | 7 + x/rewards/client/cli/tx.go | 1 + .../client/cli/tx_claim_staking_rewards.go | 42 ++ .../scalable-reward-distribution-paper.pdf | Bin 0 -> 150541 bytes x/rewards/handler.go | 3 + .../msg_server_claim_staking_rewards.go | 34 ++ x/rewards/keeper/msg_server_exit_staking.go | 7 +- x/rewards/keeper/msg_server_join_staking.go | 43 +- x/rewards/module_simulation.go | 15 + x/rewards/simulation/claim_staking_rewards.go | 29 + x/rewards/types/codec.go | 4 + .../types/message_claim_staking_rewards.go | 51 ++ .../message_claim_staking_rewards_test.go | 40 ++ x/rewards/types/messages_staking_reward.go | 6 + x/rewards/types/staking_reward.pb.go | 111 +++- .../types/staking_reward_participant.pb.go | 75 ++- x/rewards/types/tx.pb.go | 497 ++++++++++++++++-- 29 files changed, 1238 insertions(+), 119 deletions(-) create mode 100644 x/rewards/README.md create mode 100644 x/rewards/client/cli/tx_claim_staking_rewards.go create mode 100644 x/rewards/docs/scalable-reward-distribution-paper.pdf create mode 100644 x/rewards/keeper/msg_server_claim_staking_rewards.go create mode 100644 x/rewards/simulation/claim_staking_rewards.go create mode 100644 x/rewards/types/message_claim_staking_rewards.go create mode 100644 x/rewards/types/message_claim_staking_rewards_test.go diff --git a/docs/static/openapi.yml b/docs/static/openapi.yml index 891ffb36..15e0f853 100644 --- a/docs/static/openapi.yml +++ b/docs/static/openapi.yml @@ -2229,6 +2229,10 @@ paths: format: int64 staked_amount: type: string + title: T + distributed_stake: + type: string + title: S pagination: type: object properties: @@ -2368,6 +2372,10 @@ paths: format: int64 staked_amount: type: string + title: T + distributed_stake: + type: string + title: S default: description: An unexpected error response. schema: @@ -2414,6 +2422,10 @@ paths: type: string amount: type: string + title: 'stake[address]' + joined_at: + type: string + title: 'S0[address]' pagination: type: object properties: @@ -2543,6 +2555,10 @@ paths: type: string amount: type: string + title: 'stake[address]' + joined_at: + type: string + title: 'S0[address]' pagination: type: object properties: @@ -34601,6 +34617,8 @@ definitions: repeated Bar results = 1; PageResponse page = 2; } + bze.v1.rewards.MsgClaimStakingRewardsResponse: + type: object bze.v1.rewards.MsgCreateStakingRewardResponse: type: object properties: @@ -34639,6 +34657,10 @@ definitions: type: string amount: type: string + title: 'stake[address]' + joined_at: + type: string + title: 'S0[address]' pagination: type: object properties: @@ -34694,6 +34716,10 @@ definitions: format: int64 staked_amount: type: string + title: T + distributed_stake: + type: string + title: S pagination: type: object properties: @@ -34780,6 +34806,10 @@ definitions: type: string amount: type: string + title: 'stake[address]' + joined_at: + type: string + title: 'S0[address]' pagination: type: object properties: @@ -34833,6 +34863,10 @@ definitions: format: int64 staked_amount: type: string + title: T + distributed_stake: + type: string + title: S bze.v1.rewards.QueryGetTradingRewardResponse: type: object properties: @@ -34890,6 +34924,10 @@ definitions: format: int64 staked_amount: type: string + title: T + distributed_stake: + type: string + title: S bze.v1.rewards.StakingRewardParticipant: type: object properties: @@ -34899,6 +34937,10 @@ definitions: type: string amount: type: string + title: 'stake[address]' + joined_at: + type: string + title: 'S0[address]' bze.v1.rewards.TradingReward: type: object properties: diff --git a/go.mod b/go.mod index 23080d06..0519be13 100644 --- a/go.mod +++ b/go.mod @@ -99,6 +99,7 @@ require ( github.com/fsnotify/fsnotify v1.6.0 // indirect github.com/fzipp/gocyclo v0.6.0 // indirect github.com/getsentry/sentry-go v0.17.0 // indirect + github.com/ghodss/yaml v1.0.0 // indirect github.com/go-critic/go-critic v0.6.5 // indirect github.com/go-kit/kit v0.12.0 // indirect github.com/go-kit/log v0.2.1 // indirect @@ -115,6 +116,7 @@ require ( github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect github.com/gofrs/flock v0.8.1 // indirect github.com/gogo/gateway v1.1.0 // indirect + github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b // indirect github.com/golang/snappy v0.0.4 // indirect github.com/golangci/check v0.0.0-20180506172741-cfe4005ccda2 // indirect github.com/golangci/dupl v0.0.0-20180902072040-3e9179ac440a // indirect @@ -137,6 +139,7 @@ require ( github.com/gostaticanalysis/forcetypeassert v0.1.0 // indirect github.com/gostaticanalysis/nilerr v0.1.1 // indirect github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 // indirect + github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1 // 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 diff --git a/go.sum b/go.sum index bd2604ca..5fd2428c 100644 --- a/go.sum +++ b/go.sum @@ -154,6 +154,7 @@ github.com/aymerick/douceur v0.2.0 h1:Mv+mAeH1Q+n9Fr+oyamOlAkUNPWPlA8PPGR0QAaYuP github.com/aymerick/douceur v0.2.0/go.mod h1:wlT5vV2O3h55X9m7iVYN0TBM0NH/MmbLnd30/FjWUq4= github.com/aymerick/raymond v2.0.3-0.20180322193309-b565731e1464+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g= github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= +github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= @@ -261,6 +262,7 @@ github.com/containerd/continuity v0.3.0 h1:nisirsYROK15TAMVukJOUyGJjz4BNQJBVsNvA github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= +github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= github.com/coreos/go-systemd v0.0.0-20180511133405-39ca1b05acc7/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/coreos/go-systemd/v22 v22.3.3-0.20220203105225-a9a7ef127534/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= @@ -395,6 +397,7 @@ github.com/getsentry/sentry-go v0.12.0/go.mod h1:NSap0JBYWzHND8oMbyi0+XZhUalc1TB github.com/getsentry/sentry-go v0.17.0 h1:UustVWnOoDFHBS7IJUB2QK/nB5pap748ZEp0swnQJak= github.com/getsentry/sentry-go v0.17.0/go.mod h1:B82dxtBvxG0KaPD8/hfSV+VcHD+Lg/xUS4JuQn1P4cM= github.com/ghemawat/stream v0.0.0-20171120220530-696b145b53b9/go.mod h1:106OIgooyS7OzLDOpUGgm9fA3bQENb/cFSyyBmMoJDs= +github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/gin-contrib/sse v0.0.0-20190301062529-5545eab6dad3/go.mod h1:VJ0WA2NBN22VlZ2dKZQPAPnyWw5XTlK1KymzLKsr59s= github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= @@ -487,11 +490,13 @@ github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzq github.com/golang-jwt/jwt/v4 v4.3.0/go.mod h1:/xlHOz8bRuivTWchD4jCa+NbatV+wEUSzwAxVc6locg= github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k= github.com/golang/geo v0.0.0-20190916061304-5b978397cfec/go.mod h1:QZ0nwyI2jOfgRAoBvP+ab5aRr7c9x7lhGEJrKvBwjWI= +github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= @@ -499,6 +504,7 @@ github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= +github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.0/go.mod h1:Qd/q+1AKNOZr9uGQzbzCmRO6sUih6GTPZv6a1/R87v0= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= @@ -633,6 +639,8 @@ github.com/grpc-ecosystem/grpc-gateway v1.8.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4M0+kPpLofRdBo= github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1 h1:/c3QmbOGMGTOumP2iT/rCwB7b0QDGLKzqOmktBjT+Is= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1/go.mod h1:5SN9VR2LTsRFsrEC6FHgRbTWrTHu6tqPeKxEQv15giM= 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= @@ -648,6 +656,7 @@ github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brv github.com/hashicorp/go-bexpr v0.1.10/go.mod h1:oxlubA2vC/gFVfX1A6JGp7ls7uCDlfJn732ehYYg+g0= github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= +github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48= github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= github.com/hashicorp/go-immutable-radix v1.3.1 h1:DKHmCUm2hRBK510BaiZlwvpD40f8bJFeZnpfm2KLowc= github.com/hashicorp/go-immutable-radix v1.3.1/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= @@ -657,6 +666,7 @@ github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+l github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= github.com/hashicorp/go-retryablehttp v0.5.3/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs= github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU= +github.com/hashicorp/go-rootcerts v1.0.2/go.mod h1:pqUvnprVnM5bf7AOirdbb01K4ccR319Vf4pU3K5EGc8= github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU= github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4= github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= @@ -1314,6 +1324,7 @@ go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= +go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= @@ -1321,6 +1332,7 @@ go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/atomic v1.10.0 h1:9qC72Qh0+3MqyJbAn8YU5xVq1frD8bn3JtD2oXtafVQ= go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= go.uber.org/goleak v1.1.11 h1:wy28qYRKZgnJTxGxvye5/wgWr1EKjmUDGYox5mGlRlI= +go.uber.org/goleak v1.1.11/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4= go.uber.org/multierr v1.8.0 h1:dg6GjLku4EH+249NNmoIciG9N/jURbDG+pFlTkhzIC8= diff --git a/proto/rewards/staking_reward.proto b/proto/rewards/staking_reward.proto index 6158e499..db05fc7d 100644 --- a/proto/rewards/staking_reward.proto +++ b/proto/rewards/staking_reward.proto @@ -12,5 +12,6 @@ message StakingReward { uint32 payouts = 6; uint64 min_stake = 7; uint32 lock = 8; - string staked_amount = 9; + string staked_amount = 9; // T + string distributed_stake = 10; // S } diff --git a/proto/rewards/staking_reward_participant.proto b/proto/rewards/staking_reward_participant.proto index 047990ef..66c7c1f3 100644 --- a/proto/rewards/staking_reward_participant.proto +++ b/proto/rewards/staking_reward_participant.proto @@ -6,5 +6,6 @@ option go_package = "github.com/bze-alphateam/bze/x/rewards/types"; message StakingRewardParticipant { string address = 1; string reward_id = 2; - string amount = 3; + string amount = 3; // stake[address] + string joined_at = 4; // S0[address] } diff --git a/proto/rewards/tx.proto b/proto/rewards/tx.proto index 9c84fb32..4db9362f 100644 --- a/proto/rewards/tx.proto +++ b/proto/rewards/tx.proto @@ -12,6 +12,7 @@ service Msg { rpc CreateTradingReward(MsgCreateTradingReward) returns (MsgCreateTradingRewardResponse); rpc JoinStaking(MsgJoinStaking) returns (MsgJoinStakingResponse); rpc ExitStaking(MsgExitStaking) returns (MsgExitStakingResponse); + rpc ClaimStakingRewards(MsgClaimStakingRewards) returns (MsgClaimStakingRewardsResponse); // this line is used by starport scaffolding # proto/tx/rpc } @@ -65,4 +66,13 @@ message MsgExitStaking { message MsgExitStakingResponse { } +message MsgClaimStakingRewards { + string creator = 1; + string rewardId = 2; +} + +message MsgClaimStakingRewardsResponse { + string amount = 1; +} + // this line is used by starport scaffolding # proto/tx/message diff --git a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/index.ts b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/index.ts index 85831387..2f5f16f3 100755 --- a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/index.ts +++ b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/index.ts @@ -331,6 +331,36 @@ export default { }, + async sendMsgCreateTradingReward({ rootGetters }, { value, fee = [], memo = '' }) { + try { + const txClient=await initTxClient(rootGetters) + const msg = await txClient.msgCreateTradingReward(value) + const result = await txClient.signAndBroadcast([msg], {fee: { amount: fee, + gas: "200000" }, memo}) + return result + } catch (e) { + if (e == MissingWalletError) { + throw new Error('TxClient:MsgCreateTradingReward:Init Could not initialize signing client. Wallet is required.') + }else{ + throw new Error('TxClient:MsgCreateTradingReward:Send Could not broadcast Tx: '+ e.message) + } + } + }, + async sendMsgJoinStaking({ rootGetters }, { value, fee = [], memo = '' }) { + try { + const txClient=await initTxClient(rootGetters) + const msg = await txClient.msgJoinStaking(value) + const result = await txClient.signAndBroadcast([msg], {fee: { amount: fee, + gas: "200000" }, memo}) + return result + } catch (e) { + if (e == MissingWalletError) { + throw new Error('TxClient:MsgJoinStaking:Init Could not initialize signing client. Wallet is required.') + }else{ + throw new Error('TxClient:MsgJoinStaking:Send Could not broadcast Tx: '+ e.message) + } + } + }, async sendMsgExitStaking({ rootGetters }, { value, fee = [], memo = '' }) { try { const txClient=await initTxClient(rootGetters) @@ -361,6 +391,21 @@ export default { } } }, + async sendMsgClaimStakingRewards({ rootGetters }, { value, fee = [], memo = '' }) { + try { + const txClient=await initTxClient(rootGetters) + const msg = await txClient.msgClaimStakingRewards(value) + const result = await txClient.signAndBroadcast([msg], {fee: { amount: fee, + gas: "200000" }, memo}) + return result + } catch (e) { + if (e == MissingWalletError) { + throw new Error('TxClient:MsgClaimStakingRewards:Init Could not initialize signing client. Wallet is required.') + }else{ + throw new Error('TxClient:MsgClaimStakingRewards:Send Could not broadcast Tx: '+ e.message) + } + } + }, async sendMsgCreateStakingReward({ rootGetters }, { value, fee = [], memo = '' }) { try { const txClient=await initTxClient(rootGetters) @@ -376,37 +421,33 @@ export default { } } }, - async sendMsgCreateTradingReward({ rootGetters }, { value, fee = [], memo = '' }) { + + async MsgCreateTradingReward({ rootGetters }, { value }) { try { const txClient=await initTxClient(rootGetters) const msg = await txClient.msgCreateTradingReward(value) - const result = await txClient.signAndBroadcast([msg], {fee: { amount: fee, - gas: "200000" }, memo}) - return result + return msg } catch (e) { if (e == MissingWalletError) { throw new Error('TxClient:MsgCreateTradingReward:Init Could not initialize signing client. Wallet is required.') - }else{ - throw new Error('TxClient:MsgCreateTradingReward:Send Could not broadcast Tx: '+ e.message) + } else{ + throw new Error('TxClient:MsgCreateTradingReward:Create Could not create message: ' + e.message) } } }, - async sendMsgJoinStaking({ rootGetters }, { value, fee = [], memo = '' }) { + async MsgJoinStaking({ rootGetters }, { value }) { try { const txClient=await initTxClient(rootGetters) const msg = await txClient.msgJoinStaking(value) - const result = await txClient.signAndBroadcast([msg], {fee: { amount: fee, - gas: "200000" }, memo}) - return result + return msg } catch (e) { if (e == MissingWalletError) { throw new Error('TxClient:MsgJoinStaking:Init Could not initialize signing client. Wallet is required.') - }else{ - throw new Error('TxClient:MsgJoinStaking:Send Could not broadcast Tx: '+ e.message) + } else{ + throw new Error('TxClient:MsgJoinStaking:Create Could not create message: ' + e.message) } } }, - async MsgExitStaking({ rootGetters }, { value }) { try { const txClient=await initTxClient(rootGetters) @@ -433,42 +474,29 @@ export default { } } }, - async MsgCreateStakingReward({ rootGetters }, { value }) { - try { - const txClient=await initTxClient(rootGetters) - const msg = await txClient.msgCreateStakingReward(value) - return msg - } catch (e) { - if (e == MissingWalletError) { - throw new Error('TxClient:MsgCreateStakingReward:Init Could not initialize signing client. Wallet is required.') - } else{ - throw new Error('TxClient:MsgCreateStakingReward:Create Could not create message: ' + e.message) - } - } - }, - async MsgCreateTradingReward({ rootGetters }, { value }) { + async MsgClaimStakingRewards({ rootGetters }, { value }) { try { const txClient=await initTxClient(rootGetters) - const msg = await txClient.msgCreateTradingReward(value) + const msg = await txClient.msgClaimStakingRewards(value) return msg } catch (e) { if (e == MissingWalletError) { - throw new Error('TxClient:MsgCreateTradingReward:Init Could not initialize signing client. Wallet is required.') + throw new Error('TxClient:MsgClaimStakingRewards:Init Could not initialize signing client. Wallet is required.') } else{ - throw new Error('TxClient:MsgCreateTradingReward:Create Could not create message: ' + e.message) + throw new Error('TxClient:MsgClaimStakingRewards:Create Could not create message: ' + e.message) } } }, - async MsgJoinStaking({ rootGetters }, { value }) { + async MsgCreateStakingReward({ rootGetters }, { value }) { try { const txClient=await initTxClient(rootGetters) - const msg = await txClient.msgJoinStaking(value) + const msg = await txClient.msgCreateStakingReward(value) return msg } catch (e) { if (e == MissingWalletError) { - throw new Error('TxClient:MsgJoinStaking:Init Could not initialize signing client. Wallet is required.') + throw new Error('TxClient:MsgCreateStakingReward:Init Could not initialize signing client. Wallet is required.') } else{ - throw new Error('TxClient:MsgJoinStaking:Create Could not create message: ' + e.message) + throw new Error('TxClient:MsgCreateStakingReward:Create Could not create message: ' + e.message) } } }, diff --git a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/index.ts b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/index.ts index 8f98d77c..d48bcf93 100755 --- a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/index.ts +++ b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/index.ts @@ -4,19 +4,21 @@ import { StdFee } from "@cosmjs/launchpad"; import { SigningStargateClient } from "@cosmjs/stargate"; import { Registry, OfflineSigner, EncodeObject, DirectSecp256k1HdWallet } from "@cosmjs/proto-signing"; import { Api } from "./rest"; +import { MsgCreateTradingReward } from "./types/rewards/tx"; +import { MsgJoinStaking } from "./types/rewards/tx"; import { MsgExitStaking } from "./types/rewards/tx"; import { MsgUpdateStakingReward } from "./types/rewards/tx"; +import { MsgClaimStakingRewards } from "./types/rewards/tx"; import { MsgCreateStakingReward } from "./types/rewards/tx"; -import { MsgCreateTradingReward } from "./types/rewards/tx"; -import { MsgJoinStaking } from "./types/rewards/tx"; const types = [ + ["/bze.v1.rewards.MsgCreateTradingReward", MsgCreateTradingReward], + ["/bze.v1.rewards.MsgJoinStaking", MsgJoinStaking], ["/bze.v1.rewards.MsgExitStaking", MsgExitStaking], ["/bze.v1.rewards.MsgUpdateStakingReward", MsgUpdateStakingReward], + ["/bze.v1.rewards.MsgClaimStakingRewards", MsgClaimStakingRewards], ["/bze.v1.rewards.MsgCreateStakingReward", MsgCreateStakingReward], - ["/bze.v1.rewards.MsgCreateTradingReward", MsgCreateTradingReward], - ["/bze.v1.rewards.MsgJoinStaking", MsgJoinStaking], ]; export const MissingWalletError = new Error("wallet is required"); @@ -49,11 +51,12 @@ const txClient = async (wallet: OfflineSigner, { addr: addr }: TxClientOptions = return { signAndBroadcast: (msgs: EncodeObject[], { fee, memo }: SignAndBroadcastOptions = {fee: defaultFee, memo: ""}) => client.signAndBroadcast(address, msgs, fee,memo), + msgCreateTradingReward: (data: MsgCreateTradingReward): EncodeObject => ({ typeUrl: "/bze.v1.rewards.MsgCreateTradingReward", value: MsgCreateTradingReward.fromPartial( data ) }), + msgJoinStaking: (data: MsgJoinStaking): EncodeObject => ({ typeUrl: "/bze.v1.rewards.MsgJoinStaking", value: MsgJoinStaking.fromPartial( data ) }), msgExitStaking: (data: MsgExitStaking): EncodeObject => ({ typeUrl: "/bze.v1.rewards.MsgExitStaking", value: MsgExitStaking.fromPartial( data ) }), msgUpdateStakingReward: (data: MsgUpdateStakingReward): EncodeObject => ({ typeUrl: "/bze.v1.rewards.MsgUpdateStakingReward", value: MsgUpdateStakingReward.fromPartial( data ) }), + msgClaimStakingRewards: (data: MsgClaimStakingRewards): EncodeObject => ({ typeUrl: "/bze.v1.rewards.MsgClaimStakingRewards", value: MsgClaimStakingRewards.fromPartial( data ) }), msgCreateStakingReward: (data: MsgCreateStakingReward): EncodeObject => ({ typeUrl: "/bze.v1.rewards.MsgCreateStakingReward", value: MsgCreateStakingReward.fromPartial( data ) }), - msgCreateTradingReward: (data: MsgCreateTradingReward): EncodeObject => ({ typeUrl: "/bze.v1.rewards.MsgCreateTradingReward", value: MsgCreateTradingReward.fromPartial( data ) }), - msgJoinStaking: (data: MsgJoinStaking): EncodeObject => ({ typeUrl: "/bze.v1.rewards.MsgJoinStaking", value: MsgJoinStaking.fromPartial( data ) }), }; }; diff --git a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/rest.ts b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/rest.ts index b91c7d88..6f34eb38 100644 --- a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/rest.ts +++ b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/rest.ts @@ -13,6 +13,8 @@ export interface ProtobufAny { "@type"?: string; } +export type RewardsMsgClaimStakingRewardsResponse = object; + export interface RewardsMsgCreateStakingRewardResponse { reward_id?: string; } @@ -199,12 +201,14 @@ export interface V1RewardsStakingReward { /** @format int64 */ lock?: number; staked_amount?: string; + distributed_stake?: string; } export interface V1RewardsStakingRewardParticipant { address?: string; reward_id?: string; amount?: string; + joined_at?: string; } export interface V1RewardsTradingReward { diff --git a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/staking_reward.ts b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/staking_reward.ts index b568bcfd..250c061a 100644 --- a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/staking_reward.ts +++ b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/staking_reward.ts @@ -13,7 +13,10 @@ export interface StakingReward { payouts: number; min_stake: number; lock: number; + /** T */ staked_amount: string; + /** S */ + distributed_stake: string; } const baseStakingReward: object = { @@ -26,6 +29,7 @@ const baseStakingReward: object = { min_stake: 0, lock: 0, staked_amount: "", + distributed_stake: "", }; export const StakingReward = { @@ -57,6 +61,9 @@ export const StakingReward = { if (message.staked_amount !== "") { writer.uint32(74).string(message.staked_amount); } + if (message.distributed_stake !== "") { + writer.uint32(82).string(message.distributed_stake); + } return writer; }, @@ -94,6 +101,9 @@ export const StakingReward = { case 9: message.staked_amount = reader.string(); break; + case 10: + message.distributed_stake = reader.string(); + break; default: reader.skipType(tag & 7); break; @@ -149,6 +159,14 @@ export const StakingReward = { } else { message.staked_amount = ""; } + if ( + object.distributed_stake !== undefined && + object.distributed_stake !== null + ) { + message.distributed_stake = String(object.distributed_stake); + } else { + message.distributed_stake = ""; + } return message; }, @@ -167,6 +185,8 @@ export const StakingReward = { message.lock !== undefined && (obj.lock = message.lock); message.staked_amount !== undefined && (obj.staked_amount = message.staked_amount); + message.distributed_stake !== undefined && + (obj.distributed_stake = message.distributed_stake); return obj; }, @@ -217,6 +237,14 @@ export const StakingReward = { } else { message.staked_amount = ""; } + if ( + object.distributed_stake !== undefined && + object.distributed_stake !== null + ) { + message.distributed_stake = object.distributed_stake; + } else { + message.distributed_stake = ""; + } return message; }, }; diff --git a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/staking_reward_participant.ts b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/staking_reward_participant.ts index c488825e..236481aa 100644 --- a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/staking_reward_participant.ts +++ b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/staking_reward_participant.ts @@ -6,13 +6,17 @@ export const protobufPackage = "bze.v1.rewards"; export interface StakingRewardParticipant { address: string; reward_id: string; + /** stake[address] */ amount: string; + /** S0[address] */ + joined_at: string; } const baseStakingRewardParticipant: object = { address: "", reward_id: "", amount: "", + joined_at: "", }; export const StakingRewardParticipant = { @@ -29,6 +33,9 @@ export const StakingRewardParticipant = { if (message.amount !== "") { writer.uint32(26).string(message.amount); } + if (message.joined_at !== "") { + writer.uint32(34).string(message.joined_at); + } return writer; }, @@ -53,6 +60,9 @@ export const StakingRewardParticipant = { case 3: message.amount = reader.string(); break; + case 4: + message.joined_at = reader.string(); + break; default: reader.skipType(tag & 7); break; @@ -80,6 +90,11 @@ export const StakingRewardParticipant = { } else { message.amount = ""; } + if (object.joined_at !== undefined && object.joined_at !== null) { + message.joined_at = String(object.joined_at); + } else { + message.joined_at = ""; + } return message; }, @@ -88,6 +103,7 @@ export const StakingRewardParticipant = { message.address !== undefined && (obj.address = message.address); message.reward_id !== undefined && (obj.reward_id = message.reward_id); message.amount !== undefined && (obj.amount = message.amount); + message.joined_at !== undefined && (obj.joined_at = message.joined_at); return obj; }, @@ -112,6 +128,11 @@ export const StakingRewardParticipant = { } else { message.amount = ""; } + if (object.joined_at !== undefined && object.joined_at !== null) { + message.joined_at = object.joined_at; + } else { + message.joined_at = ""; + } return message; }, }; diff --git a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/tx.ts b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/tx.ts index 8bf3c322..93a900a3 100644 --- a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/tx.ts +++ b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/tx.ts @@ -63,6 +63,13 @@ export interface MsgExitStaking { export interface MsgExitStakingResponse {} +export interface MsgClaimStakingRewards { + creator: string; + rewardId: string; +} + +export interface MsgClaimStakingRewardsResponse {} + const baseMsgCreateStakingReward: object = { creator: "", prize_amount: "", @@ -915,6 +922,135 @@ export const MsgExitStakingResponse = { }, }; +const baseMsgClaimStakingRewards: object = { creator: "", rewardId: "" }; + +export const MsgClaimStakingRewards = { + encode( + message: MsgClaimStakingRewards, + writer: Writer = Writer.create() + ): Writer { + if (message.creator !== "") { + writer.uint32(10).string(message.creator); + } + if (message.rewardId !== "") { + writer.uint32(18).string(message.rewardId); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MsgClaimStakingRewards { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgClaimStakingRewards } as MsgClaimStakingRewards; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.creator = reader.string(); + break; + case 2: + message.rewardId = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgClaimStakingRewards { + const message = { ...baseMsgClaimStakingRewards } as MsgClaimStakingRewards; + if (object.creator !== undefined && object.creator !== null) { + message.creator = String(object.creator); + } else { + message.creator = ""; + } + if (object.rewardId !== undefined && object.rewardId !== null) { + message.rewardId = String(object.rewardId); + } else { + message.rewardId = ""; + } + return message; + }, + + toJSON(message: MsgClaimStakingRewards): unknown { + const obj: any = {}; + message.creator !== undefined && (obj.creator = message.creator); + message.rewardId !== undefined && (obj.rewardId = message.rewardId); + return obj; + }, + + fromPartial( + object: DeepPartial + ): MsgClaimStakingRewards { + const message = { ...baseMsgClaimStakingRewards } as MsgClaimStakingRewards; + if (object.creator !== undefined && object.creator !== null) { + message.creator = object.creator; + } else { + message.creator = ""; + } + if (object.rewardId !== undefined && object.rewardId !== null) { + message.rewardId = object.rewardId; + } else { + message.rewardId = ""; + } + return message; + }, +}; + +const baseMsgClaimStakingRewardsResponse: object = {}; + +export const MsgClaimStakingRewardsResponse = { + encode( + _: MsgClaimStakingRewardsResponse, + writer: Writer = Writer.create() + ): Writer { + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): MsgClaimStakingRewardsResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseMsgClaimStakingRewardsResponse, + } as MsgClaimStakingRewardsResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): MsgClaimStakingRewardsResponse { + const message = { + ...baseMsgClaimStakingRewardsResponse, + } as MsgClaimStakingRewardsResponse; + return message; + }, + + toJSON(_: MsgClaimStakingRewardsResponse): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial( + _: DeepPartial + ): MsgClaimStakingRewardsResponse { + const message = { + ...baseMsgClaimStakingRewardsResponse, + } as MsgClaimStakingRewardsResponse; + return message; + }, +}; + /** Msg defines the Msg service. */ export interface Msg { CreateStakingReward( @@ -927,8 +1063,11 @@ export interface Msg { request: MsgCreateTradingReward ): Promise; JoinStaking(request: MsgJoinStaking): Promise; - /** this line is used by starport scaffolding # proto/tx/rpc */ ExitStaking(request: MsgExitStaking): Promise; + /** this line is used by starport scaffolding # proto/tx/rpc */ + ClaimStakingRewards( + request: MsgClaimStakingRewards + ): Promise; } export class MsgClientImpl implements Msg { @@ -993,6 +1132,20 @@ export class MsgClientImpl implements Msg { MsgExitStakingResponse.decode(new Reader(data)) ); } + + ClaimStakingRewards( + request: MsgClaimStakingRewards + ): Promise { + const data = MsgClaimStakingRewards.encode(request).finish(); + const promise = this.rpc.request( + "bze.v1.rewards.Msg", + "ClaimStakingRewards", + data + ); + return promise.then((data) => + MsgClaimStakingRewardsResponse.decode(new Reader(data)) + ); + } } interface Rpc { diff --git a/x/rewards/README.md b/x/rewards/README.md new file mode 100644 index 00000000..5f767d55 --- /dev/null +++ b/x/rewards/README.md @@ -0,0 +1,7 @@ +# Rewards module + +This module was developed to give users the ability to create rewarding programs for blockchain participants. + +### Staking Rewards +The rewards distribution is distributed using [Constant Time Algorithm](docs/scalable-reward-distribution-paper.pdf). Special thanks to the authors of this paper. + diff --git a/x/rewards/client/cli/tx.go b/x/rewards/client/cli/tx.go index 83f0d451..74b0f597 100644 --- a/x/rewards/client/cli/tx.go +++ b/x/rewards/client/cli/tx.go @@ -35,6 +35,7 @@ func GetTxCmd() *cobra.Command { cmd.AddCommand(CmdCreateTradingReward()) cmd.AddCommand(CmdJoinStaking()) cmd.AddCommand(CmdExitStaking()) + cmd.AddCommand(CmdClaimStakingRewards()) // this line is used by starport scaffolding # 1 return cmd diff --git a/x/rewards/client/cli/tx_claim_staking_rewards.go b/x/rewards/client/cli/tx_claim_staking_rewards.go new file mode 100644 index 00000000..7a9a399a --- /dev/null +++ b/x/rewards/client/cli/tx_claim_staking_rewards.go @@ -0,0 +1,42 @@ +package cli + +import ( + "strconv" + + "github.com/bze-alphateam/bze/x/rewards/types" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/client/tx" + "github.com/spf13/cobra" +) + +var _ = strconv.Itoa(0) + +func CmdClaimStakingRewards() *cobra.Command { + cmd := &cobra.Command{ + Use: "claim-staking-rewards [reward-id]", + Short: "Broadcast message ClaimStakingRewards", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) (err error) { + argRewardId := args[0] + + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + msg := types.NewMsgClaimStakingRewards( + clientCtx.GetFromAddress().String(), + argRewardId, + ) + if err := msg.ValidateBasic(); err != nil { + return err + } + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} diff --git a/x/rewards/docs/scalable-reward-distribution-paper.pdf b/x/rewards/docs/scalable-reward-distribution-paper.pdf new file mode 100644 index 0000000000000000000000000000000000000000..82ae635448db3142c0d0ede389604eafdd936832 GIT binary patch literal 150541 zcma&MLy#_9v~8KTZQHhO=SkbPZJe}i+jizj+qP|eiT77U-PWzf+pV=DR(r;pBL=yW zm;^mD13L`){PMqb7*--CA_rq@7(PB2MmaNk3s*}bHdYR9qW|~7FiKe2x|%r?F-q7P zxtfWYnK+o5!3YSzxVSo-8QH;jZpP}!CU0?|^qpx;+f`N}iw5u0a{3&pcNKblKhLxak}ZTpfAPT;MU;PwVtmR_ zB3fkttdIow)DiQ0@~4WZ-D5Xwi@ELvvSOoq&*ZT@#SNHm0Nz*t?{?)N&RDlKmKA}q z;+{_k?cPj<>^Vh2{?N)-(o{iP^-Bw{>3r`U*OT-|&1L$>`NN@sxg)x?pirok?R+) zUo~mLTcP?p1fKi0pIz0LNj~2c(|k{Gj|5WgI`B;)jP@>?AvF%y_fi=a)j|FHW1Uwx z_6w4UD$gc*t7k>{Vdx_>q|b%7+b_P+QXyUknMc&C{K?^s@4KI1Ib$-B^CmMF-Y*vllNKB zP#juHCmaM3xxBy@y$L)S^gTnt zP>VK~P2f?F^b=+=AVC}U+}C+#!NH-Yfa-|QUOxS*I+dB-A_$>D95N-F@5wG zg6O@Xz{18W7dk6h@-^DuuD8dlngzk&KoDFzYP|ew(E@fI;xA_VV+ke29TkSKoeS}S z^Z}GJNgR~S?e;y@#vA_8k6Q;KVXE#*Sni)?#~g0Zs5R;R(2yaX zj1&O)_fN{$rtQ!=Komn>0E6%Q-`Hp(;$oY?YltIVulr>+S$3`?5+v~#H2y75jGv=r z8Y%~^Lgw=LmsULEx+3FGRN6Y5+(|78uS1#-pt6-BOqa;QdD-d^a${3*3DC(-O2|9u z!;^#w&f>}LZVaA<9|ynx5EHWqOr!xA3b}FJ%*=~&?GQS0!xxH(X+7Us%FBIkw4qrl z9=z1N#>RDYtWncBD84E z>ff_93R1l1d=?0XR4sUy`pBdDEqoQkoT+j_G#)a zcT!8d4@LRlxw>X4hYC%?5maixy1f>dIoRqdfL{{1;f%uK7*bgsB!NNXP_-?DYBy9c zuB!o2aw#-%#`MG$FjlNM*35}qesG7-Xo2;}?-P}+x9J96`&BA5Ld5gInIBWkQY$tz z4@1nT1cuxf#hDBbi8ZWZmet5DbO>zM1M!8+&cx;BQ7MKM_#txzF(@1+`m`!lcX6V{ znS?Ti;@X`bai=AV6mz+$@^)c}OPPOc93=4u4)!_L^SSRB(oqUp2%frV8?D$D9`xI? zfK*H4J+eSv8lsVHGEs6#;dM#mV8taanwTKmxf(~++|*gWX;`ViSzfQok1}n$LXLcl zGZFYayKYl^dO{FNbrTWc9byl85o@sMX~GGq+ZYIV7d*)Azx|F^RjMR zBA`r(G~Ca2TwlLIFUH^i(;ZCWHAWg%!qJN&V4jDnzm?sQuZ22wgI*a#+Eo${JW+pL zt5xK!4DX|XUP+*R7$tP+K5jAxxN@H^E3V`m^%7$OrXY}JX|HnsG1A^y#2{+tJow!9 zK!A=1VwwkNcia$OoN&IH9UmXWv)xZB3^ucff2Yn_C`6pCMb#HC+hH~$Jlq2kv%4|< z-Ivyd%m)#oTVrs5eBpSr!OxB2M9Qe%oy@>IVoRM@5l{I*H*1+!8aRAK6HFCiaUPKO zQIu!;b$mkb+!;?|$mymrNmM2kAJ_97%?9L`Ne`u3V4FRy&`(qar$hiKS<^QoMi9(9 zO`7L%sC${LQ9@UA{a`!u5LmeKOM&h!D8;7FiGS$GViP;)sbVE?EbiBJGkBcom$dQf zbjny?h5ZMsp6!sAFPAQ_LMPAQf}q>?P=k9&Lzx2I+meE#ZK;C7SvhFvg(0zK6Udq? zJj+&`J@5`UrmT@hTDw;Z)h+CvtjK1-@x?~jOTpIs^|(51QMR9Erf{ZPHI+5~iR=|c z%t1LF6w_M+SHXqXr`1M#L8 z{dwB|>%5UTld%v(dg7;&PuQs*|GPfYNcr4`+X*b}SG<( z8nU$?i6Y-Hv=-tCj~;uFT@XbdFVwV-IxAKuocG0rZjrx{ABWnXDdo16v+(bb5?$;B zNa;_FaOE?}M5!UE*)NlMKj^nNTd;fLrfOA)S@w_FOn_daB3MpDBbeKmKXBtwIuCu<*;W@NgH9(n&N=zfQo zJszfRk+ZM|C~K_llu{?Xz;0-RJ&uqAQq5oc15`%whWE?D^+cfz&^+I?b(;4e0T5sb zDskqL7l_5lRwmtS!9>f(9EU`(*AC+-wIH`kic8XD`e)i~@OfN(#M|S4v_ktb;@Dzk zg@#D?pSzA^?QtVjtfBx!uvF6cZw`2q-hcyTeIg}jCj>dV?w~qc6|w1)<>b48pj=g$ z8X~eX=cK7Dv;Cn>5yqRrfkL<|qSajK0A3y3i%ojM#S)t@6XRKNVu%U61 z&2tk6?H)S z>?h*~fM(^aXb=}C!v^|NMOKJ_fx1Ue?xDrd_|v9E{NraS_$TN+H*BBlIa#hYmukm! zL7i%4eEiJ}w5-k#MOf5bd~>tvhf1Xbl?j zM%iN>Qn{5_tOdH@FU-U<4Z39FV9u0S+10h(YrD@1sQWcBonjKSz{9_Ux-i0ZQ^3(tU!1#6;y4eHn- zpG9T8i-8cNnXgb*Wdwsz&{)9hvx4z2{Vo0WAW?dUOxTBEjfd~YcfZq<&vskQ{9!R2 zW@%^wCWW@1`RHZJMlvjAiA1M+wX6uT0tiQ{w9>T{;rT;i5v;0xr1D9q(HEKG(z!_9 zZAuUcrar|f_sAgZk4mRH z(-BBD=Gk9eklKf{Zi(pyt~jQJf@^Rig3mH4J!xn_vSX35Vg7Abi))=c2FxmQvGW05mq#a&+2av(+Dqdlh z{F4u7p63ce6a}zJV#==WrJ@MAEgnGH)IN{}>LWq=$|MXLLr>_`N`LXa^oF0i$erN$ zB=Ur{LZQJbOAzDVRu(U?kS!duvLR;)M~*cb;<%|POhRm+uuoNEnP|iy-)TXNQyjL1 zK{Oo-K~=nhHHaN;!+9-7#B7yA8r89-=oQ^$-w8i?3td(d_R6GLfN?U}-kxwnKD5EE z1QhW-*-yPYd~yRB2_WnjCI*rNuomv`bX}ugREk0eXD(}E+2~I7b2*QV}C-AP4-&xchZxMKqj)3lA55&smGiFdBx`Wl3)m{ zZ@vsn=%1N+0ntzA8887$Kt7Qn^LML}D_fxHX5v^8eO zUp7+b1Q-kzC&*5_2x1rzn{!E8K*diOM1NRA1_p zj-DuR!9G ze`lE8v^<$1qjz(3eQbXdiHzTu)b|!2wXh0G7uWOJ-9V=MB(7LJ)i-T-;IwG!8M-Ng zLqEls(bN|>XJ~Mj;8F`lvi;TA!*mc^Gk`4{`-eF4$4qSvo7SMTnfdFqOZV;RuQxQz z$VP1uHIlO{{jt%x%rp&cIun~-EyP~~ArSX$hs`t;CFI;`6_7geU_?~#CHG8@RIUu= zBv}9FxPYAVSJ&*Pne1|hA4Efc=581>d(;1qjr=$LKU{^G`~L^9aI>=f-vX8u-K*py z4(H##fUrkum7d{Y+ycGqs+Vf(I~DiCt&vLSuOLz!=__$1+%*bk?0Gyi}@Z~e*zF%aWvNJz5no zzpMJp)2@p9fwk7=1lR-6st5?T$}|N{T|aoXx1U4OJfv_E@Ehw4|Ei*9-1RTpYTaBA zmi5-#x1UTY>6M!je#l+wzxNA{BEf!f28xc9vgW;_7z6V3T4`Cm?-friF6}o;0Pt&p zK_rkEXGFfjG5uoN` zE`4u8$Bm3t@h$bM%f^asG`rfFW1+5ova(bQ znb#YS4mG^3DU>(?7#v{`k@#$A6T{h&C1lc6KZ+{JX7K6YD{0C(OQ3ap6%~*_cZj@I zR=4Mb?|?=tC)I=@O;lA+#kay3!{WWQe(z2?&K7G>tXtEb^X|5wGpJ&yp3sFU`PMri zzRgQ_^7Tidp+NW(C@XdpjJr#M=s1}fZ$C?&ZM`1vUnSzYLpy(I%{9~vo_DMAL?V&7 zIaJ)>;}D-mIWR8DK3QAHsnDqQ;?iDR^kUOq<7rHqDg5*w1tfDLOirfyZ3)~9lA9df zZX_n2_}E~RY#^*-7*E==lm1!w5T zU_Hx1ijbn4dn1l2JgA0DRzj9zFHdlk@Dd2N-GAPv&o<=^;h~8ZrtMK&x}n|WkBi}Y z0;slFgr&}lxd_?*9C{&W7C0cfqZvk;e{3fNAIzLL2zJ6Gkj z45tZyHAKG@GV3Wxl6338+%}z^{v*!=f%aXif%2xV=Yu+h3+eG3&oS0kB|0X$qrSEK z3=C4@#@0|C4xW1e42`e5M+|<=`Nzj!Oh@mLX-|+6%8q6B5iNe~oNj7Th>Eln+++%hT9}SHTO?1wxhuST@N_0$kI( z7xGk+LZGZP_%9~n@K!axA`dF3lgLb>%|kcVCf}U70(AQz8(mD zf*v_gI)ufI7Dk6!CU{07LJS0Ho=q@qI(NgFMVErSYp!vov!zEt9>N@`vIgA#O-35d z9CeOhR^lzroaQ$^-%)=y>_wdJ_=L3XShhxvcy=Zs4Q6VyFhIBlO%atJ>d0MBR#UgC!VhlaWV}l=}W*Ain2ZU&3Ur)-I zpE3b)V686Tk+J%~#wJ?x$eeO)`C65;@CcSnzPprZuB2F4O;0XOKKSY-@jeZ z49L3JcU-+C;UunP8^=~HimIP{J^v$DGtuW$>K|ce+;%bto?g)d#R`wv` zS>Z(dPx}V+dI{sK=W_Y4CN`QK-La&&B0zT{tR3Es4%$lExaik#Dva{+K0?pu%f)3Nv`LSA|}|}T1RDf{%b6pwv9veh_t?RS5cE4 z(svcPuLzf4$`KZ-9YV@GhsbiAleFpkZL=89w2yv`{GMsY;|cCVetNf zwLlPCYyXaZ3NOy1XPFz=0?cnTz)RoGXOyU0UQkZBQCf^w5HaX%9e>zRACl~+cH>@| z>pH>p<_S^C`J*E|1r)=D{B^kr$5cmwyWWwo-UE+qv7(&^_Ub(4{@DZn=4K<$=YhMY z4P9qKKC8m;4EQ^-0`_uQeghOF8Ah-&tu3{P+Jave6#5;V>k6!zGCea*3-D}_%jQ^+ z=8m!U9t5fi4W;MV_D!@fUpHcnSl0)1A&>)yyza(_@sGo9BI7R5*8B-&8?ZI z)7)`<--t(Flj=n8mLdhJ1??rT}KbsdS4>1wvb?;y^)E@1)UUl zfy{=EH4F_l_uzT1T?$Bt@{SjR2cFcwff1&g6)~pK5vBzje_0?`&b9XaPEp$gE?goN z2lQW;oY$y5Mu6g~sP(4RZzILPO@F~(8|I&uT;?mvZIi|@8zq*f@4VAg`V+NPT>fH?w z@{(j6oAg697qutHlw`|TF_5PkLG6kie5F22bc6V+zD!0;2}sxz3*=%c2YX-6DcLUJ znR0Vn$Gl1Z0W*D0a7n=}H{=*uY$B0?ePHSFBauLc7sTl`u2tMKA1R8G+32vGMuI($&Dtb(|$jL>}i2DA8got$&fTg<{R&trf zB$)#6@ctT|``k}4W1kvHvJ=qJeMXp$z5o3#yo3P(%Z8L3>JljWW+U6PWN&U{!k>xI z9CYb)_&a$fA)Wa~i*>k_ubMBfYzLVbVUIXdNWK?I|E*eR-$i2mFeB|$RA$9Lha?x86`uO)!@Pnv;l`Etk$j4% zH_D9(R$|pc?j*BWj^`fHR@Q`Rj8BR23XQgz_2W3>k!c1QKA1ca)N*)ZB*=?JyLvTz z+W_C$Az3mNcZ8C}8vtfQRw3(^f^Aw@87~VJt4xRvNf8spf)?8j1+O_zG5`J|=2@fv zIH&45eIOi?h&6S$mAX7793CL`AI4&0rUs@x9%7PPyF|r8eDR)M z^HbH(15aDni$;CI4rj`kbE3dF9&kIepeSY<88uH9riG|YU<9d@Cxh@G*-&2gOU)tg zxHr5pUc@@H5dC9YI3SU9YC0}MldfgR7)wk$R-CZ%6*C*7rBEN4cm1~{Oj1vkGG8(Z z`gIezQ~r3=z^t%GCQt#Pht0L4Tao7lb&i6Y`ko@xal*{M!w%A0a!ZY2(RcOpu;#>e zl{tIRpO&{da?(2)3wEV&HU))R`qO*a#|n9Ie}RU6mbn}_&ZBv|aJ<|ECIQ0}wJrHY z`NpP4YrctCs%I~t5oE?V?Oz@DaugmDtbVL3rf%r?jFd{MO&)jb7M!tz$o{qbcVyOL zuy`Jb1~kE}=XEb*GB&mlFn^s*Q{;zI@s0j;>fAFs%H)A88M912dn%Ekcjx?02BHWp zI7Q*nA)mH1a7i2H0!#^+$#!YtfH?BUMd!f3kgy}S?srS|xU=p`Qo3n$HJ9y!a>ui0 z_o^6JFAU#%F(v1phx4Zz&!ff z>!n-3w9L5h{m9dSk9AgRxw0;G#-f(!covd3H~1kQ9!wCaQM9f9x06Elp{mUXx@PTM z5))=-4!)otlFFRijw_VJ{RYn|^e#_6K+|uZ`SI2#!06L^?$ye%l`0w<*7U_TF!?IWSIdAcX58<2i6vC?Kogu-X&}iJ;P41Ph;k#QBS{9_6k!@Q4DU zsTmA?fFr9TmUw_ehp(a!FGlv_<^^`tgXmP+4T6Dhl-vyAJELz?r7w^XQ?escsoc}O zV1`hI0?f7H%y3a*xI=oOB@o${BKySMAa4UgwBa#m3+b;%KfGa~p;Ecv8s6M+S92cj z0G)^-OtR?F6EI*bRnY)TG>np1N9I(%(Gc@)Zu)g_e0wXi zN%Dp)6u}&e$bG06Zv?;zfuBz@NSg-@wtk_cV|}LW3m^)K+GA|3k@@aq?C%W|9e|Z( zvWm62e0G5661Xf5&;{b!6yS99y(7*fvb=s7e?>IClnlvbTCk(Iu|=IFV;tM671nsD zhIZkP{f+f}3uOxdSns?-q2XBztaA}pYOC+;|{0q4b%g5LPm%jcyJV4@*2FbtNUFs{%rj&;;a1({`!mN z`iE*k;c>9tpX94tOkmIv)S?aw&#XKz!!lmvavBC6d4#VxYw#%_a6Ahv3-H7L#X1=S zbQ$d%W6J1>Dpn|-*$~a9ZTLx85&Uj=4(&sVX59#oc?lpWW>MRf`ElgSz7FUUJsTYHZ1U0dt*$^CQifG-=cnl`#0I_Te0iD($l)27Ob zE~O?Pr2amQs0S-fd$@3w7YiRcJ@+*d2x}^$vw?TF+ra#Ikfd!uiRu6jSfvZ7<;Xx3 zN*OMr*j|e%7EgxpAnb~MG-vxago?V!;kl;T_|JYwYQ4DX_N$ns1}VkqBHJ7{NPVgN zu=Q6T9s|MWw-E=A$oEo&BI&0HyK^Dxjc{$;Y#lza8foj*e}bpy3n)j*fTXDJY2!rT zpnF#o{FKQM(^tNmj$=6zFD@00P`;mHD(PW1eoV>rD2@XCBr@Gk%}uuDS~ z93R@tZuqDZh9{!($Vn8ZgQlk$Nq(c9Vbc+!e5t@`ktA)z`iN}&S+?o3!G+c3x?b~+ z3QwG%tVw5n(s4=%aJnCY#Nh%1>S6Sktz&X2^U{|sR@>bB7-d+jDL-~Jz8`PUiAfR< zC&=vvY4`y$S(Zhm;mhO}p?UGbYKnX1KISh#UHL_*HK-(wr4lb}oT+ zvqP=Skax~>?CLj}9pp)S+~yr~vi_v~D>I|r*J{@d?n>2c1x=TZ0c0da1}3#HG=muP ziPF|laOf2k@_|uB_fE;0UgeEfF@>M)i6KSfaxS*%MXQ8+cgS`nayOB9T;(|E2$zDY z!C9=Hlc#CNI8>{rX$A!!(Ng#nR4H3eu)*m`cJcI3{H*iObkpMtQV@4Xa~Qfb%STtK z2XYM($PW;lEqY#9fLIE8;clflTb0%F{zk<%<-pNQgRj5L{$4IWgY|W_ zHhzT4C{?o#*zoU3!`E?%%~YhXhKEh1*ydI!1$b163YE997h{M{Jt5VCwnbn~;PWPC zuhvQt9DQFePgo8(y-_;QT8OI+(ds*-5{^0>+s>F#(X5yua<{DUBjt6Kye~(ticNGY zTp;K<5(}xDfw)ZEid)1sv50cF-jDXP!7u&i`OzIFR*$9bXz5r zZf|v)h0ji}nbAmyGJlkON~e(5c>d_=Rz^nM%ZiCt;OvaCGbw6BEQSk7kdDc?7QJQ` zlkR4>eHgKM1H~2nY4!FLb5w=`A?|2;Brrr1(L`gVESn2#hLzmU6MqoLQ=Z-xOPr(9 z2kOSMp!7@=liWct%OHSX@(OZE%f2iQ}^18^}HgK=y;`5Bw*OM|Bp3~NMSt@iX ztMg|S?ux~PLT>Ty4O^a+`$Ck@`oZ!8^KSIBwsLrDOxT;a#LV#FEJT%Im&zZ(_OLNV zY=HqDD)>7)bQyp2l^lgYaOPVENEAT_vCF_=C*7TVB!givh#?fB`8*wUwgQhxFp1a) ztsel!7Y0Y=YZ2yne`A7a`+h2oMQ8tE-2M2kr1Qkm&RP)A9Tc5eki7FdK?YR7=r+8HYbaL{C*9<#&GN zGwU_?TmRyBrFG?%=eM_}=VP#TddkFtt`bCoZ(2LIDjVGZR*65+V{p zgG%|pjTD;zS^iH}q7pK|a)gWu^h$QBCgulKaDtb-Nh{O1@I?0s;7 z0SGmN6Yc~y1jIiUjtR(T;3tMcZWNx$CCKOZgh`yI@Oyv?YkzVdAz}b&SA$ppiV6GzVD0(F1Eh zNmUW+CLRMU5P9A}sG*zlk%r(JHoQ9ozaFSx2NIM`JqCEc8v1wo3|@GUe_?lM*YVAO zHTp}&rF8}essd+m7&KhSC;9tQ5kD?ixbBr-=y>j+i#Wj_YI={Bk_+VW*#@p6zC4l} zl98Dlq`^?NF^x=C<7Dd6wwL!Lw$g50QGeX`qQj0ix}%D>KTkn zFBTX!oOiHJz!b}&fe|iH;$t9~`S;@eEE*0BMCbsCZ2k}A2xCf z2&BJ{_9p_mUwf(-1ki^6M?&5L1BL?#8zWmE@Ks-UK>{Rx(pA;bFAxWyqM|`V#mvZp zfD$@FxrAh7(2&07#3T&g^Cf;rH6af|!N$KQAf+~)Ubxhsfrc79tE9UbI51mUc~Bt><9jHeCUpA58J zB1jD-q#WMsx4?P=F)~2Y^jA z#(Z0ofDDB+qCP3Jwj=({45~!LCENJNAkse+j?%(|eg%5V~ZubKX zpqc{Ig5C?1G@Jo5q16~a`oF6jaHohN2{UrU#Lmifb45J<%hlV@s6%m7zWbxv0>`LB z(*-GLs~xWjzG0x9FzGx8ZxyTW%5E^HY*pixnBK5eE5b0VV+_+ua$|H4omo zCAY23lTL-EPh{QqkI=UyV?ELo3M4H^w9tYxeZMbJ#Yc#2;CGB0ciWgmu)ES2w8QIk zf6H>@AQ;rLqrCf#`~KMuk3%RNY@C)3%|C-3n%to;#}Zky|gYS!tN~* z=w~T9d8&9gx>B*ji$m?$zAxYBb%Y5*)p(CEs+*r2UA=Y0lT`XroJKs|RE}6bHS_ZT zzu?HGHvOEGMoF~kt+ozI7xM*lqS*VW5wtpAurNHB$pE`0VmO)KIIlBsj9i@IKUCOV zT%g7{gqQsoJ;cuw=I6PbhN=Zn$n8D)T>Qi-gGK7|3v$~hS`EC`k}od#y)fL}Vsd{v^+%$6O}U6xd(kYyK+G{+jRjH_aYOVM z4aU<>BHj~kD0;b`kGZq@yDy+Y@*z5$pXs>XFHjf$nZP4;m$-FAB_wWYsMOuIkn{DH zaBD4sb7I7sy1QZ8upp%aqxAPLH;cMY!mjW%>3!;&_6TXzH7MMu?<1e`wJr`M-@$)`ER`xd0}7c_q*I~zlD3TfLQS!=|h7beG>2=50tg2PlH@jFyFnKv2tiprth=3Y=<4x@K0dLIJ&|VA$&;PtzDcy=;h6?bMWzlX4?HQ-kPo) zdOdMpn`sY%&CVG5u%V)9rC!)%xN=BPwEiv)2{rp(v1Rw9R9JTzMcr$U#A)WYU{ycM z>{hT-4tFh0TUjfr)Q`Sk;0mx01zbDG2?kQ{@(D0o#wq|ZK0?Yqp#dKCF!L>y_gj_5 zLCXmHSMN$6sdp!@^mo2bHsySgc71oL=zYXhdyRw5 zc7aKzeoG0L8M^0xycv_MUN6>ZCd|LV{}cbK%Q?d}+Pw6s$CyJP&NW7|m{S0sU9eV0 zZ*huuGtX8*nA2Tq_xMf`DB(dI=v5i5izG1TXl=<-&$CW{Zn6%kg(i37=GRxN_Pb;rdqto3>NM^Ap*Z{S*^ z+KZG9cs=fvAbkU{eLJjlUeZLZ(r?lR>BX`|d22p@C#3zQK&2MzZrUxIYtOgUb~$V0 z)kY2Bj5(!J4hANr4OH{=yvcB1`#xXOlxXU`$&lWC`;GS|8U^t&o*8S_r$Hz$$!;7;_e`_~8EInsOauPqrsf1MMI+z1S2(+KD4&E~ zr{Kn+L6Ctj99j=(qn}p2a*;hbYn;KY_u}nW*6`vb`(pw&=&wdJ&BSZ>`1?h*&<15y z34$qL9uzOPxI)#S)OajKZ|gr6olaq54qa+^>&y0=yHuGcoVx8|T2vgx$@pJ)4#;9X z2l>l?TOx$W^_*!&flzV2v%2Y*1Tv++pEENEnX~w>t^>hx~_R2+}{7pa8%BdVehSGajylpiGi12M2H2Yh&-;*}t!1JoePdFF67Y z07=-As@?sKwb+{JJb%LWJZ z%d2SV4Zc&Nup5G{=w0eL7Ro{&WESo}|0Pl?<-Q>0Kd+u`)QRkc>b|0T5YS)#m-Z)t z^W{;n`DxTJzbxwONgbBh+ z>bf(6dX6aACQ^;Ct4CbNy9nE6l|M$ev3u@06CNTH%{7JhB=$RCyqP8ZSl56L+cdhM z3aWlt2qE{_zx*fSSH#xKJI=f@g~c-{<8q!1n12GY_9{wpZ3o`*n)y1q9_q9CCRjj0(LV}5pZ*S@Q^w1@~fIL z_$3}(KS=#lP*(FI-O?)ibdU_5wmdexZ;CFSsXc69X6Wpe=J~z3rmg^-DEiD(=GF^Z z^#pm6t$r)kBkAzds)mL zv%=1bTW*l!9U??*N@yKmSxu51>X@xZIONGz#!KW`*swq~RM#zo!NsGwS#jvjBzN$6 z$7NwHbL28gpTbKr>622v$>lH@{N7tgmI?bDbfSm5Dn_~fTFQq}iu0%7sg72))WFxYt zc6e8iWTvT+%~id&wEW+@TMN9{a@eM9IiAv+7G2Bd^^;|Nj6tU>Zom92i~iK)fBuc^ z0!$x)shQ?Z!$Ey9+z&pf+@`{I|- z+N-INY^Z(&bi(|#Xsl*`H=oM3sT)qfd@BBQNHR{6)2X^F+xME3pWSP&QZJX5F^wYFHm9UykUwn3HXBz?(bW=ATQ`^C-g9P5J)D&Yg8G&dvR z*X&)6=kJUd47g-V;M(Pg*^k=sEK@2?&%v72n^YX-k_N2%c5$zwdGGEZs6rINIjA;( zw|W?`o-8oIT312a{U_W7FY6C6C#6wWGQyxz*x!tgcL+2RgklZ{axR~q#vgc42L z#)r=8Vs`ztMQ^k-CS|PX2KNu3FjH%;2-0e#FSR#lCr+>ER&DAf?y}ySin2ITp|Y{y z{pGY`u3~1ug0u49_hwjCHt;fgbYUv>e-rDo#}v*(6gYc(?hH{oYs?M@%+oID+KPAR z`;y)gE#S&*L=Kd=32)OV?|ZBhz04A$H`y&q)vXCSx9jW-#g4^M^CkSoyi%lm`CL6* zI>B6qGM};M0*?bd4`$OhtPW;E975kCri!n%rM8ZMwD-aRLp)w(_#jpxENahnq^I)U zNV>MaP6 z&<5Sx%jf#q4yDGZo~E8?+3Rav@Jh>|@4(R3aXU+xaO7hD#0FXJd4;|BYe{M?@!auO zuPIuwV1JP%Nl7=a$h&*aUCum@YXhe2QV`=Olgbfe{_NktL)sXN*JA~qXwcRoNS~*7 z+%ei!EK+wNU{z5Wp>=9*uFEDx#uSI-cbeAppTl&R}VJJsK6>zrv z7x}u~8A>dQ6BTguiayjBROL}1^=c}}DUjt++r{I^+63y1`@#Z8hRnLGr_y-V^SIo9 z{H1nNJgEzBo1$-aJvn>yD6zEjf2 zJcbpK2tg~UxObxqW~Y<$_T>dOP|vPBn0@o=6l)M~aLcUq6cKwfNcJG22-%}Fb4LZ= zAl6ucx!<7Fs@kfvA>$1zBx&g{ZmHj^Al6V}l))FhOkiJD^F@__S)v%CzGZZf(lfv4 z;_{WRkyv!gr=pn}YG? zmgZ(IidO6&=DOCc!`>W^qA4A)M)CTNQK;ZO6UZmHt1OL4#OSA9MrGo=r+D)FxNc&- z`C6(Z=G_y|Yr5Jv{xq-KRyVNm&3@FPlNq-ZR;#w9U{kYVWm`pT{H@yPzji!$P31lm zW<_GmXs%pLWlzO^v)GOMs`R?p5LD*iB&M>lgs4t`$AIMn3?T4>L zcZQW8ZHwUf@fsf%Ua3nh?jPQfH@7qp-O(*;aj>NAn#1tw@{eicXd;9qD@L<&dnddq zrF#!3iZ;ea=*L0ha`QEVA;dpK`u_#4Q=B=9dC&XogxwlO*&&RT2)%8}qic9|S=P3& zfIO9R>f?`J)^%pZ_Frb<4o0u>y54Ua%6(TF8$u96Q}&>C~VthaI!)uc@W>{==)Vawf5+)M&}@R?GDmS!~k?MW_`whaTUzD_e)A zqnrO0R^m+US&-MGHXlwLuky?&(#Y#D{Xmwh)MC)UJemQ=uuv+Q{ONocdOPWy(0>{T$x<3R|5RQ(gY~Hjyt1Z@@ZD$P7+RCfl z!{Z}=PBvH8NuOL-?9YCEE+?4fE;~>uF{tZ%yhW|(H7y`bDz>ZEwknE2XsuUqF`zI& z__FQYsnxyi`*;7)EvNZ)Dt5%Z;P#ZhCa-)RhGhd%vHYwYF6y6O1`w189< zH_`i;^|tdgq)M4*#i+yJ6u1y|4Wm)POACAC^04QQtanpz4 zV>H;@^eQ9e|1fq=J)%Hewk_MXt4`UrZQFL8vTfV8ZQHhO+g11U!|im^-$TFbKd_UP ztc}($(d7=3Kb_r;qqof^95OJrbQx9#GY_+Nq=*fsMv*7BFqC!1 zywj&-6POI%P1D35W+g=%%75z;gF zPbPgzXpLWUEfRWvcOFj=saMt}v^M!O94qRgfBGbURgmNsx)c19dSzmY&`ado)}h)c zoW`2G{B{j^i~gGarTd8gHAX9W>)uJ`>S#5c*-Dl^Deini+6QV8b|TxBxUnO(F?qxk z;wartPVMPppN7hYjw#{bj@=URZ2DNUNRHbV;lFG0z}G>)F>yb=N9Wl1C!T#ofiGEG zPPO7i4_#|y%7G8Rdhtzl9;UU;OU3P+^De)jrkQ)Nj3i;YZ};W?zL~C24ly);Nfh5q zph`PssIbR`gK{BKCqZPc51j7d$pwB+(=!H1)Xd!{V8A`QTzlqPSY=)Uy)dJJsrKdW zb$Hgq+gydFhbmA5raryE#6K1hXL}Wgdoz3bt4~4mQ4t*z8VV&Q(_d=`xv)69SYu^E zWt^t}tq&w>D*Ynos5<{D{I7dVP||kF^07cLO#87o*&>4YPFViLM!>S-ba~2tW#E2j zKN`rf4b&35ZBImDc!Y`&41@zHSWO;O>SJ8uu=IT`neZ#h#Yp|Fc)CsNOtQSYRe!AI z<3#C(s7R}G+xq*LRVK3z!zc5jb{O^-PqqvoJD~~0mLF;7ZOC<(z5#GI zPA~=9AoIWR3`1*_trm@iXVCH`T zfO)iY{{x3(`Cr8UABSUO{2v^Sfu4zt_5ahi{|Vw47?|0a|F1ffR#5rOOEg+(3Rwq9 zhX6Ekgs!$uw9o=TAP{Jzt?li|7ITNz1NpqR+|Lo%Y^h+cfCjEO&R*& zVh~FyxA4#o{}|*8Ng_ah4h(933joI-D*$Y8zv#@^YZ`niD!=UHo09M_dR%zdMU}2j+I0WQ48h%8OMu1Ij z6J|gS;H5k=1p2A#UcotN^*((UFaEs9NNDJ>k$BJxecGWu5PSbVYJduTvARH}HI%zf zV?U%ZurE0aYV#%lXXvoQT_~0^%qh?#05ERIDnc@Sta)`yplm9|X{@;(YXi{t1Xx=h0(#@}@5sb`qa)q4yH|qM#dDG8@>^HJ)Tax> zd^-o99z;BX0qeub>eI#ZrToFpudfG`CM2WxV_3s6jC{#GlQXPa-+e3pg+oyDqrF^w zs|Qr~_5JxS`eimKk=L?n{Z0E_Hq2{T@pP70X8TS0vMWx*SVGEyHzOsNt z$(Nhd|LiT%-0O8!L$ro+Xn5DFriOWHf-7h_kt3d-8W|s$cyGlyAP02-&Fl&6lcxT` z%j`YI>P4TyGKBU4cMkgMG0f>w*Z38CZ89NKm0JxvT(thF2IAnY#<{8${TbOSE&i~> zOK2gJU)Hy?N(;~kb2fb5nMDK&S@O$Z; zw{r*JFWxQaMWh2L`?4Dv1O%w~26q7RyZ9CDvIFFw>qT5m++7sWf5acZ-S8{%?Gea@`{g5(gQWiP(*__of**qg(EI_+ebD*_%$=zF0p`80e~0(Vu+F>2 zzYB+cf`1bpx%u}T!mC=#G2{ID$uaBu_Wi+<_3bO|qV?_nwM+<43>;KK|J|r5h5Ld2 zb=C{$uhBxJP89haJWcj<$4s)0ff4$JPO*k?9wzH$?~dS zvWCx0@;B*BNc&bP851#qNx95o}z88Lx=}n<#BGFT!%2v0|y1GCfdk8_G!R#dUo)TTO^T`0H_goTMC#_tCNMwh6 zKaib%V=XHjICuyXNwYREvU=-wXjZM`{{GDS-FZ{BOqA_R577WC6x)J#v1$LK(9US4 z5$j&7W@1x?xPvQt<}&mw)T)YiFfX=wk6OBCB<$+`1bo(+I61x_(dDDAr<*Eg;y1YcD$nO_;fmczdcF&1={tqxev?`)>POo`IlC#i(flqfXqu;2(te`h$ zA%sN1*6Fx|`8Pz%w}(=Ua?_m$nc821zu)0#sKbPaU!vZo9;;Ai#^@iq6ABzLg!Bxt zFKbEPMdPH3=ThrMQFHA4p2nnh51AAl?N+Pxk}Op87d!Oqr|zezv8s z^F0abjvZDvIX7z+IWwrerFQM3Efyn~!`6_uv=b%CbhTc$}t zJa&$#SoEKSN{)q6`L(p}^A_&{&3s$fZzpKpMuGbO_$#XCe1_Sejwj(x%?C9Xk5Y)@ z4<+#gAwv-sW&Gn8N|)U+mZU)Ul0t)V3Q8RX;U%%EU=p zyYR5h>g$fmHo9jaYy5f(Kz(#$;1Rw5UZEt@i}n-}_Vjg8aEbA_>;hO?u14<$Ldy zRUy4&>^g}6do6u-vzg85q)i_ik5YTTxfiXKb4%Tfi-#nWF##~a zUlgFX2EMsm7+ylHaO`O7Ap|Z`QAw{JS6*w^XIQ`BL*Lm03DV@z@BTsVCe3;k z_cFY0(=#yOSFa@M(=wrSYc2X`3bZyx-GMJPFucCz&sO?mWHEbg>z;}UD=J%AF&a2> zRpVzr)eFa~nG4-JzzVU@v}8a$UHsUiP@mup+-*Po3Nlsw+uRQLB{5;@8|gKVKMQ7d z*@P~Ln%R~rH{C8Qg=vOUg_Dt&PHCDJgC_^3DT+a z#`@psfx=>PqmKA@;V?-D6&6bGe%9YSy<(^kFp<2r?E9HIh+mafb{smlR9VSXUZCqm zojK<#Xa740gCt<>Hv>zl#(fQU1jd=5bjFC41&l8b1(*0mmdgVZ?IcwCo~)XH%dg?q z@Pf;ZTc$D}m8nT6&Wzj0Xn6MKMyF8q>=0_mAd=Fm3hzpa=3W=_p_XMm@2ki~@$xQl zJ#g|6_1&_`xR*^??zZArKNb&9{9BwrVMH{>fqVfR6ylr@6hEl%rf3?ZSF&D_;=dgv z2g2vKSk^?&{nY%rZa+N^>t>#XiZ|iRpf){NO#JR|rz?C@Z93O#f5+sv=PGo%D!xpN z{aB)!*d9kDR3TAaIaO@sSL;0{9|}=cw=A1imQFovoncyPgEAYLUB8Ym!pCakcjTWE z)%^qhIzeushfFC}dO0Zhq>VGuUSuFb4p1E+*-JCdwS0YO$7Jj4Y3tTX$F9|ke&sMG zgmGKx)nLnn_%8_@6Sc%h2VWAcie=BK_d}C2510gd^1D%#9Xv?9@6!OT>X5TQ>Mg*R z$YF(mK-~r%UVMP*QiP}4l~d??h2r>*rXfoX44vb4!)$xizefh%hmtm{x|R&#&B}sI zj~AUvpqT_JzdiKHyBz}G-((2__2$E8luI^bQOkHc{%w`z`-UO(kFNNJ+cBxhqBZDh zU1xrA)Gawey2)r(3$bQvPu!sec%u8vl~_(g2wpb~0+yeXD-|j2q3zUI{H&$ow!#Yb z9?y64sX~nObgB#75KuNGX6zTY$F7W-#pa@02g$81ww~cm<=(~&SD|RMY845COb{R{ z6`XgR?YtcTla)>Ym(;W*@-S`)&TfDOEmI@4pxlzPZ?_ot?D&+;sww??%Bl<{Jk^Lu zzX7v=O6i>aJLOy^H|gGLeXiQN%;R-R-{CsrUf1XhG3S8+7u7JeG?Nd+Wp zeKPo|lW(}{tsPixH^gk;}o)Y_jBQ)_oFd5EfjJzCC0L; zq~NQ&hO$^v_Uqp4L$1M@_y#m&!7Ddw!A;}oCMHCQjpUayw#816_~E^XjmsnrIt3ke z_)sx4y*F~wNCQ=&X9~|d;KP{M)*5cXWU7+4s3^8giWk4ro0|Qtm7y0tJ~Na#rd^xF zld0_GaEmJP$pHx13+t}P!WvI2_2c!~w)1%iXtzHKjljg?QABA2)=ddOHP*WxxG(3; z8MB!tn7g;&;$^^i*exMGymn$K;5>;c8=xMTJP*NM&NI5jtQ07(YFyKG^p2-Xy<1V5 za)`QKz36Gk0y@&vdstyn4+j>R4N125?wh_CaNcJyEagx|aXfWQYC?E}zmd96bJD24 zI+T{`c2JSlV%HYh|jV*Qzz3+X)gDM94IxqG007eqp6$5#F+PYC)g}7Zn z-UEi*h)y^=R#(U0WFO;jXwm+SKgvBYKX<$bV-1EnPbW`|aW!(i1OjmLpVj7`l^dz%#P=!RZ6{Uo}!z8f;=UbWG!beWkuT*(o8a}{iQ zyT`xR4%e!vFf4y#^lV({y-ogj(Q~Tk#v8oocpZ@{{*(NW(F{R%?v*Q170Ce-e;06| ztUWb;L|_Z^+1JU}-_xNP!hTJR^ius%(V&ZoX@^Y6LB(uylo0(uY+vMlgU`UBt%uVr z58fPZiueg?C3mtHhPQ-e5lq6Cb*qaox4=qBX-X^DMD)Q#02v$BqWHrgIiZcdADt&1 zd=XAg;FCj9F>xFsIl%Q~ z2bN|<`d&?Y=IQ$l$S!?b2@8{@AlAmN$B*L?pFpYx(!{y^Z`fghpkrT6=fa&{t>@j^#W z;luW0U^wk0d&`&Ufjshc<3TiZsd!?&Odov6UKmezd8_6+XHT1ENZy+f;H}QDNhV2p z$(t`crYIT@FmafxNG3E0SxNP_)(%ix4{GA;m_LGxVt?;|j6ytfYw?dB#TO5P)}x!e zHg9d@zlPb;os2wpMT`ngI^_mLG;ng4r!r7_SpOgir)%GK6Z&&XOb`AJoE}PCAC?mX zX|(j~7U#9U&B{46`$P_`a((h`#lIKAJR@u3bmjiAPm(AH0UEfTZI^Ow9pvsxW{R;D z>-rM!4|bp-9~EmdQQ+)SP zrgv}#K&7^l474cZ;vYkm!>m%b_#(0`sVgL?hw#|6+T@fzO%2QVx@*!I^~Z1ToSX@; zN1Bl7_57R!>>hq;cZVCB+*Z_xtD2Y}}UoW!CClxb2{ezFl`?ZxwZ=>c?md_3@_f4@nfS#QJwh&2|*3Aw$DZ zYIft0Fpq||LM(}@gI|i+-KNQ1MdtIOt;~_x!@YK&sewxKJy5+JHq-@!%7tr4*{H+b z@m23?l6L=r30|C+cvL=NYX}AP-4g`h8*O4T%Re~%P<3^}(n-v_UixvYHLv-oe;#B& z+T3HGsQXghd4dnuM%^EIY1bPmh8-4pTqSy?d;m?$ITV9Un!9JFzL`4TcuCh%O5rcT zc?9iy(8^92kxJw}hc<-^8+(RP(OwMjs&78V0`w)7;3TFHZ z+Nx5}2vIAUtyJi%!Xdsz$kptKWf{0k$}LRo-*$UN^1h)B z#@ILlNg`uEkKE8H)d^}c>pBQ^{1N5jBei5I@64kcu^a8Za~LtfGQ()5ARN6wO(@iq z$}_nEZ>M;=y)I0U`fJG3cE3iKJB#O^*Sb3(<5T}45TVC^%HThs^!^fpd)E@?KAQLcy!&CO>i%(9j>HX>vL}`rJnGST5&yO zg0#F-f%8r>G|iTH1|(Z_Hj=2ith zij(6K2O3$Gz+9J^om**y6xxk@gf=W97N7lmYkSo1RdK8t1p2G@`#bWX{JbIqTYcphJU=e;(fcIXW28fiHTc&Sl6b8PR zk{*2!vo%RVkg9KY#@i>@@4J?P9HLXOcPQ$ZH?u_wZ@eC3)dUS$x*tKz8#R_g2gA`Q zM6GJDg@8DMyl}QQF^!*8ZY?}GLr2Zu{EKYCL!zGf1WrT<+V4std4@DHv zM^)v*%}nY@E&8cNi;0~KwrnbLiioyVXy-g|4=)>8y^ID`u#*?j(VaLg&}jh@pFCic zcO-3R8>?!@5d?{2$FD&FhY5dP7Fz7mE9F#++lH!a%h#v@i8eW|Ci`$IDD_}e%OKY$ z2FY2jAl@^^Z})sX-0L&rP9Wbx0PoG7piA_5>@lL(qHeI{=<=4ULky0$9h3XEfsFk( zH>sU3h9vDeofXmHhbKKEE^4cz(f+o=f@X6R<(|1kAB z$52^?;({_~>g-8=u8|?p@hQ?P4v8azW);z+JI}6aAHKB-wF7-TqDxvzOXV6#eUNOy z%{d=_&JsMMo#?!iGuJ~juFx|2>g6giA^8HH{;uFv{Se0H$@j72Z_mJ~Zr3p@Kq{>& zvO#i&1H${V(s3AHHR$NVR@YB=Aqs>nj;LXh88V9 zoPZFD^pq5T+iK$Wn|wAFdWU&fWCruK4sPv)3j*QhrpUU#9i<$0?!;#x;m?k02dthzbb?NjV+}~bU@KLOG#$1&&W(ZXF5%|e+eSU-@Y;na zD<8WxCCqwn&}t9zSM;mMRW=cM&?Cae*-O+E$zXLmkotGsb}>aJsodj8+8D6a^hj+w zHoQk^u!QQ8=QP&{~KR?;EI43=>5q+wO+m3Y}ced%ED7I!@lT%;N8D zw0W%8NlQIu9KaoWzBo9e&TU~`D_9M4URZR9=pqNh+21N!Uf1SD5ABHeRNW@qaGvxS zb|kCZ7D0x4U^qzS!g5HuktJG#TWokNG1reR{Anu5)cYY{?jBoR3a-v-l@i*x+yJj3V>Dq@*H{~&1^}Uqzotv@<)%}Sn z4USI&?N5)So^+T~-{bBO)e|61drrHr(EXu5AI$_qB&3Ia#A$M4G(8o_D$9a^CVV%l zt$hY~aky>EVT-@WOl6+go-+>rYT|g@Gf4tx>%HvG!bRBWDz$L|3PjL)7?pgOZ66C+ z%|V+%MABYXrrYf=)5`_A2&<95hwDzEvDBD)9o@-Y%@juL3P;2hcysMx9@!dNe>|K!m9YC74LvXA-4|xCzoSy= zod4E`YsrA^4Y8?)X4J`h2J4ZlK{2QNzSY+;7~85`Hj@#J8oNP~RTlF?Q9IpngY!~x zwlyh!cLrF+HI`;bC`@FaTLQfI9CNl@hNhrDYBtV-EN&wfuOt)GvWrI^aR}IILi(KW z@>N?U+l4<(pmzhg%#NJSg_+j{zUY9buT?o#%kQ!k(m|1m4bjZ=Ws)X}%2#4xOXS1(=E0u0Wp zGE?$=H_s*{Oxa@2x&0TrC7#~!H-jH!V;uz3?hY9E0XoNU;1QxKXr-*OJ#dsFe0Pv; z>CAhte8x15)t$%APq#;={N60=^ne+-rJ9b&p&xQn&?VOUp4W`t$^2nVM#6uU%Bx3f zydw(D3MZ+Et!o+noSg_tE-YoIY@#u)jicDuHMv$2I!4KX#<;c%OL!{XzlEpwVIFvAx$W`K_W<{Do>O8o zg>?cYaBamX4Gj_r#pEIg!P`z@hdc;*>njoquuGJmkz{TRA%Run@HYDR+L=_mM`x~Vg z6>c)ifhY~k@#Z(zedaSgfoxSjvtZcJbUjxAL*&h-9p9K82*Tgzy~~Z$TW_}T2K0SR zH)oddZd%FfU({?5MhT|uW)yRpT8mA63|nlBE9@gZLC{U<+04v7Wy{;g!2-!eCf3wm z1f}ylh_S3#Ke1zpRZrI3gKRj;dqC69uhWtjMUSgq^8$#GUK&g?Me7~iTRA9%fwi7f zygBCD6-mN)p)VOfbG!H`8X4Aczw$aZldX1Xc<(VTT|i*dB;h zu^u~go!Skp_dy-ILGh!=Ulu?YRSK>t@iya=egqpIhH!ut=R&5NvHXJyHE-aiLzE!4 zc!}7N8>c;|7A8J@jO48W2Hwla97+s9A%YumXbXLkILF=~+BSuQwKSBp%5_t7n#l10 zE^OaCGSeI2C&RW9A#j%R<)Kp?3)Lk#o!?04`R0ntaod7WvX9=yE?c897SE8XiwfpX05fm z;;{&JJ~~c4b3)|(Ab3DZg$MkMOr_(j!S93L!IffXXZ(FD3po!a0$xcu@0Set*mVH9qY=- z(}*e1A6`FhfCB}`G`2YTP(W&A)JZ-V3M%X{)nYj--=eFW3mKdRH=y!v*g|~3Wa{Hy zmBEXXDVSpsapOLoGOk^I$s;o2(6q$IWUW}#VROT{8ZW-sokV@2m(Vn;E2xvI0s0~C zm5CNM+x}p^z&5x5MUI7Fm*ascNPKcF0W0m zMajZ>m>qC#nLj(X@3zAi&YwOdSQK&cQ{>-tLZ>U*dRL`Ud7*j(JN@7aH}ISzxZF5o zz77I2X~KMqx^e_SDz-xQSwG$FU1HjeXnH#3s6y81#b2qpY6_kG;Iub%j8O4oKB)MGoTSp=l#*Jq;gQ>x;j1`#TE*H~OwPu$jc#N#@lrptw!!(;s zlAn7=hwFG0EYZ&VvBtIex8?Wi*TcHy24Lx<3$qE>NGCtAFM(W@NowS-6K`H3e<94| zc_~H@iABUlVg?Y!laOu?$5JyEi}ewlWX3*pWbI} znPICFf9{Bqq0wo|>4r1HJ=+?@{~gKv1}M6E`G!GSY$0DAC&7Qji-JrDA6FJ+J(qLU z0YPOPG5`#^Vd9c4er{cI7hH+{lP>XI-?mp$Ft^)+sD2AxXXK<2cc=gaJ~Ckp;*`SD znZEG2b3K=Uu5-5}a*l>&sU;ct`BT$23fMfqkGitg+9G)9GvQO*P|NNe6+gA1&j;5? zzbNG|q@muM2kzIh?8GsW>8vk?o}jUPQ-3?(geU1d}`&Q-4d^y6yBNoBgvK0(|Y-Z|Y zEizTlt^m85RUZb0iS~6pyeRB*CgIwR3Wv2AzvJZRBTNGvj_QXa_Op8L{b}OrcO&Tx z4}=?jy>rzAUP`{doKJ{mIMxCZ6B-kfno3SEWKjME5nk9|?W$bF{}H z%=L1#huO8?N*{446_Op-4S8 z1h-7k^N?aLM70RWcIKt4HJwpM=nHB-Bhj3m+=c&>Z=Bd6ILfP{=NuQM=qk4#w7Ra5 zS}NT}+PhaY8?>pfMrXpoZoOHFZ7C-~Gq)lYt*39!^MR}3%7qDOWFIKyKmPiaSFrHs>c*>DLcBdOXo^a^zn0b#ZoM) zTcMrf*<0HCscGEH#P-(Uw8PzvOKvB-Jkba3Jwi@1w0^D{c6~r4?JkmbP+PX2auRfg zu}Grj^#YA<Ur+)hbw`xBI z{KDTEo_6`-xEpp}MWra?(MOLd6^vrnRS~T<=@D!zh;qNFysUlE>(jVr77dMfx3`!P zvE#vwT>Pw>=7RUQ9rEUWH$l*j)|$V*UEth8d_+#s>AHxWw8`FApwPxd)U~B>55btH z_F=L~A;lc0k%`#HD$&Q-nl4|DDwkc-j6x(eIAs~_Jgzi$fq`&!VTTcUq&_Wb7m>Wd zprLZS_q+^$#geC>rb#ZZcFM@1e(gsye73N(bY)aplEIT*e5fPv`q zDd1&+XN=gM_N`oIn4rm?rjV66mL4c;Q@nNkZvDWaC}twMfqezxQG@ooa1GCU{3^jR zTi)wapHm;_&xnm_QyBWvJm9k2M@QCw3$m4Ju9NfDwG1u4tgAPVz#}fnQh0U)!CQwk zb>G7@Z0nc6!%tn*n+n5&*ZpE9AlIb&8IrPZ8?)P!*0P7s$roIOx+~R5bkZ~+7U0VU zWph#C8s`}d`GD;3GVm87r(%_=!u#{<%Hw#uP>I#Hn+;${a>ttwuGww=>dTmYM$U|@ zm=Oeod0zvn_O27RS0BJ%iQivSW$8U(RDUSp0YO0Wsy8m;lQmWKFDc#dHj9mb{pabhiw3jR=#LkORfHY0rV{3_4}= zVqJmHPG1$7LE%`A+1&zR1mvp(7_qKi*+(j7ytaif*NzXarfvrJy-o{tA#-Lasxc8` z#wr%-@sw+&BM-qr#N8k(GQj!Fi(hMnwFvI$$zZ;9)NB{-%8k>qRI*0p8utWF$}Ct` z2m1-_7Bi@U%{ob}Ep$HCtDE<8MX;cIVHRGhm5ec~KeAZA*f#!jbrsID#UlYk}9$m)0xuSd9jdctVOI>G1F5TIL!KxO?q}qQ;H~>=wrb4 zDGHHEQ0Bx#!90)0d9kQ-;@d|GNi62I_f5XyP=fg$}p)H;~`?R57Ao4aLeuyMF#326tragMUj#4H+ zJ%m0wqJBC`KoB4hKmL1P!2KH}0FgL!6qvaK(6T`T1b8nr(6-82uB9D7f6f!VS^yU< zIDp=^HuBe7C%-J{AzVx70Kg`G2=FlI3t_D|rak~$=wJe`Uxfgj2|$1Q_Rq#^zh0de_&u7!1Lh1G0H4}oU{q+`1Ggw0BrkqI|1(=AAUQxcCYk;^XhiT3AD7@ zBB>xwpo7YdM>JdMDQwDaJkYcC<-W&k=6LR1AK9@o`hprXWY^UDNnr7?U+ok>L z4Z=YIZ+>F|U7b&ufdqEA3ofDj3d+-d{k~lh{uA2DODoI6K=`!*67aUbdG$_Ue{=}? zfWP~;DbPnhMx|9(T_{(!aT)^+{0v~|_5^V7h`v3fL-N`}c=Hdf{Y!CskB6yO+ z{PHa;*oJN6V>f%bmcjSogdO1V0lZzl-m*!dbobe(HQxH}^}bG)+LjbnmP|dH9r%tO z9q;o3_zEZh#QM=Ah^P@d_>o_b-sP$|3C#8C0Q@FafHejJzxn%ii0CZ#a=v^>0lf4c z>;Zf=rm^A-YeM*a^O3XyKmpq*!2kT(Rs71n_cDB`CI6z2|8^3Z$eEq)8ocb@{}RLe z_2>Nj0nHP?4CjaBhmJ`Ayz0#-i{mR;4)Dv*q5Z{G5%QB4j0;>Z9Ge=X8-hmpI1Ke5 z7xE_1*C8KR*@rjzd5iXun8t((JR9K2>+PW_qb9iPH6-_5=gjZH$0OJMf%NB=Hx&BP zJ*2}9NLb|iln+=R=yyOakC3}N1$K8oum_!*{Xa(a~85_ag(ol>gh{8;K2c@4t31D?MOCI*4O6z)Mhh zWZvbz5?WLT&lDF6>J|c3Wsj&MStysH1k<25ZP}%gbAF`O^7pHV<~GEuoBny*w>l+% zM(r#rRKR^Qr=QH?;RVKhq*jK*(xT=jLq-I1zxYWvw(L&t2 zt55E}hD7J${GT>|Q(_hEQ+k`q`1{NN<`Lm&O zuckpHhS@m!C46vWyoQvxRO|E-tU`9HTTmuBsWiPE(wm|oa9m|Kk%nxN*Z|s?_e&@j zuOF-qLrkM{fe89*S@Tiy1JlHSj+@$ zr_}GZa8_zFX#i;Qd#T**NKvPV{%Dkl;7beJ?taH?N^~tJe!6&V2D^(y=@B%pzxwRW z_0T2=Bnlthm8efN#pRhB-RnSh$l+wd*|JJsS!Hl|k)Yqq0$1LyYhRXYG@dN%&R5Zo zO~26sM(ScunnD5Wc8|4Ed+UKE8hDz31qEMXS&qIDV=gQU zPxrtiU-+pBDfwktz?FiDQ@C>+Pv7|O{E-TT;=f{Eosm5P#IwNg`6l&gF`2EaH-o1| zO^q>u__dRY%; zLuazs#NF4`F{qGQPI!sa;B*Db-lC0hpA;SxB)!b{Cb1V&abZ`5{J7fdx+eVKrdCnEtqf+hGDg0 zZ?lX2@`;^|AqN>kFE1%@vq7eDrY%q;zRpzJN^!l4he|kSDGn??d1VVm z&civi>7OypqIhD44+<^R8V+8L$7RWe)@R8%bSc}&Aa#lXPT}FmYgyIfy>7x{e>zNT z3q#wm}+W5Z<`f5_2-Xc22Vrh!OCF+3Ql_w0Koe8*m+0I_2=1`a%eSIqn z%JVwM{{Vul3o`a1Ylc~vs#XHT?Y$a8PMfURKRviqK0VWF{W*qMN>r=kd9vfsPHf%4 zM{RT@&I{!1&SA9SB!Lzr7>C|SSu0~lcGdRI^lCNCOtX(~PkXi{s%TkWh>u7U<0daV zPMZWMlFy{y@U-Jr-5kaGSK^6*LBfEw+NjB=z)w?YcrkXZ2YrV(Vr2b0BNnj{iiaJG z6l-vPu?`;=L~bE_kkfOCeUcx3h}M^ZWj7WnaXkH>9mo=fxyrelDSgv@s&7VNmj7n(C2@r@0OLqSd=I86KT3 z-=YNO)}rUOhH~p7s4$le{jI42ePR^v1_h^W)Dv6}^31pB1Sr=nZs?zwZo9B90r>gI zb7|&QC+cvXiSLM1&SO5Z=OOoM#{`X(PyG53kj5Tu)r>dG%EC;8O62cr-{v1^1LVQtS3m<79rt1VcN%atrOiuZ-t}vY0>J{`)7nr z#mBDEBhS~Dxs-)+t(?q5=*uJcB?CZj>Sbj><|96?hQ~q<5siaTo#E_)E*|r#V;For zOC?mvnZ_4RR3N)y_Oq2rNmCG5`T|tw;QOVClFf71j>A?};_8eCay{pe7bm*su(`d4 zNvQI8EW(GPdSpw9DB}J3ELhB_hJ3w(X%!+xdzpDzHGfIzH)<;T=dQ*)uz%+sxPP^0 zN|M`r&$Y|%v(3%ObEv)7VfB3%634cQa;C-~Z#USCl$rU6%zMRaS#lKk&`{6u zDuKqAelet}pnA()TMI9N{pw!1KI{{2+^!#z!+*j~Vf!s~RM9+nsZ3OTk^cnD_tIBvUUChl6i8H6!PYQQ`G!A$e%ckhoX zccUrJ9A&97P!23kD99}I+?dg)cdYj|{=7LYVo1-?L(oGmZ{dsK~AAx+C1rm-~{;ed~B5E=V zNy1kv!Bpxy3F7KIYZA?moQC~r6x+2pAHj}xafF&+hLM_Vi#-8~o|s)vC+nF>!5X8C9Z zL4UN8g?uZ{`sH_rUJSSAP?8>NednVrRVS}PBTNK(n9DT@uV1>{F}TTo&D=DH&AQ2%vkeXeQM{G+l?rB{byQ&pIqDib&0sk(hAommLv(E+3ojm(-c#Q~G_ugu}1 zG@D-Fc*2WS5LKeK=}$pW($MRFdezDDUt_Js9mi`8WSKEEe3}x>n{Lw-t2PG((~`Rq za!iGOpFsJQ{j4otG-Qf2LL&9+Fixu{850i0owuR67d3ihYH?J>C%&`=VYN-I86_wU z!o1mexf`@lUgSe?seKqh;=h$;Y4|@wAV9k!gT7dDLOOq>p5+NfraZYo4gz>F78_)m^LmWGuy%= zV=_`5Mkd0MxyOJnZkI_S*{wPh{xP0_o3 z5V0x}n%O`GR6j#PZX4Biq)%C2Vli7U{mgc>6r2zWc0;}LM`2!)rgndE5HVRCB;zda zlE;0`-wVek)&C!5=hP$!&|ulJZQEV8ZQEv-ZQHhO+qP}nwzt1|+K8Er*!d0lkQsT; zxmUGhHb)~-)-vLuBi2#(+IB;RZQKKSg{`M=%e1_i|8m#p6(d{ew9lmH0lBzp7G}$~ z2BYn;GG$_|pyH96{p-H%*~&qc(TXJ1M( z=OOn*}zH0wmDiMPsY$eY+_cni^*dK5O3!;4)@}$FE%O>Zat&o$eY^Z6! zIi;LMrap77or<6n@(-lOZ1LeFL-=?1exbR<+lGR~71-C_y^l5$27|?*vqmgl)5%ku z@`j+l%eGMg7cErxAiE54Fs}e-<-mWBbn&!Yh20oZj;HbAm$8>`AnRyVn2HBobjd!> zCvn%SDr2c-ZyGDS#+BWod#%M|vahfa>3_qHv~RiAy}R&-{)+Hi8w6OIS>ThIMjmzH zBOAH)u;1O{yFG*}S1Jb8ZD0F<3}rnVN?UV2wQ+H zc+Sy=x7ow%uSc;k-DET5+3UFad9{=<{-0sfi0a$3p>z4WsWyu6^@qGncYeA@Mq__R z%$=k|Ax4&I0cHL;lWHG|hnz$5f2+wS-VO5W!gw?PSKjVyO0rA^Y4 zi$dY`s?hPJ=-dzkKFO6ajbbl{g4?k+Z&@;nQDp^LSev$z-Dn*AjE{JD%~(+H{2toL z*1oPg^Nt0!^E`SE`Q>GlmNm)lct#|Cr%CTi;l+C9Sg++~K9>Om#3Kh|x7lSM!T_q! zKIYbN;gaP%6^4$s{Z8(k|GM!wS&eY+qtmd0 zEKBf4u^FtLuV@pm1v#Q*sBgtN97zWnJmcM$Zn2qbIQ0WZF!KkoS9m#aFU2tZhB?XR zT5gd7UUmbrWoebMu6?g%)0_Rs7_CfbH!bg!RH5JH3y)40@|J&qIL_R1rc4uZcpnXq zgsiUDF|U;LDl7wRvYB~cqaWL=4pwy)rS-aM`6rfztJvD7ho{M3Z?i|0>QKnJj|3pv zy*;NWuon^PRl5>tx+HOI2tXeqdg$G~hH(jIF5e@FJ@uDqH~LM=9c_|TWMqU}-~Bsa zZB}KwEt@ZiZC2%m#47RMD(TOzeU|R(Wg>91;xxp~?55_@&@vKr8SqJ;^5rX_0zEPfJT@cH z-%mJlhRW>|tz&GWsN21gfe)=;9O@TjOx1StRDj9_7}LL4+;jc&$e&A-Z6@l6wm1Z8 zGVw1i=Qy-BmUspwR3GLF&`aMb5q-!?H6T7N=i4)XXr(>|kbUT$=pr{iiMb|Ni&~4< zNW~w+*P>FHxnj}9z+Pz@>~xO6SwT$A#=VXczKIiuQz`wTxR>pYty@9a6}`B72vr-MY+ri| z>~uBL1rjYrFm{VsJvW6?Zi~QjA0AHwqgdh;zn7BNQoM)8DLdkC?|ewqA1V*3X6=>;1(+K;lxqDc zlK0sJ)$Vr8QgWTD^4r85U4%B0?$&ydK}Om34zNK6K$W1if5&pN0Q}PMocXdkPjpa%g7nQDQ4HomgJ;bv(HDIDsvTm>t$iZ5v*El^Crka@wgFk(d0~$2i4~tz z%G+y*eRLwVYLFH-I8n-%99CWpX!kmghqhivS9x%_N6G%D1&a5KL|9aXqEx-5>y!vT zWlpLIvcU{xX0gGlVx4E`qPYgcw8WMnk=q$FZS6>_GWT>%GEk8Ng>DRRXPc7E-8gEq zERD29;?s21@MZonl#r_j&&5?I-l_XO6|Hxf0sd2m$6;^OMLxplfS}t<9zU?1p<*WIx1>kS+i*bJS3=!TiHa@848o z3*=DR84uswYiUZhO8nS9GS;PcB6RB?WU}<)sG2Oe@Uo<DrDeLO{`H! zRJY0_>yGpMhN*K?AoD?T`V5X!v4gTtx;uNvz(Hau93v7Q?v#+*0Uwf6yeA!aqPWGPo;Hz?s1gJ<{cstnW^P#cCU8ZK?*z}uNaCUZ!BL? zjh7d0=P4D7DG%5fh11o2h0U-E$k{0>4yTxD7JQ3=vLf&u!A*#67JK<=`hjEOZ3gt~ zK*VcxxhCuS%4m0C@nDRM9W!3b_)sP9rAAbGXYZ#er_MQjGa$$%604{s;X%VN-6Z~r ze9f0c-*Jt%6H>;9_kQX5LgJh^_Rb**`9)|jT_=(*%Z=4(a0ANB=A18bd~c7VmY6;0 zksDhVFUv&kLbWFkOTgCa=54-TJ#SunsCMWs;XyxcDH}qk9%H#R-jJB=Zf83Y1p~w@ zC0#!jjBMds8G&9Hs$V0e9GA9+wuz#zX28r?K{bZ5HCn7d)(sNv?J~*?&R0|W;4RUO z_xukJKFj7ZY31oTT9K*5=*f<>q3~t0Db%=R-wKiYopH4x{l@XidAm;!Q-_Sini9++ z5N?NK%{w~>Tf!UF`3NYblR<{+{S`H?WI#p#YHq%c*XQVqA^I$s@VK?(vUng5&8Q*X zg5Z}zRc9$Cmr!!x*&sVOl&cyYVNkNxiLQb zJV{kYm|d-QGj5N~0uhL4LdIEMHm?u!s#mif#L0atYRxDm`tz~w6RsZ{esZW^=8Fwj z>n$J9*exOkfr+o6?H$(mKhJ@Vp znXV}yj65{M?6KRxi7Jh`(|H0lq%35CfANKxcBp0O7vjRWQfl_U;iU`0J^qJ??!S+Z z|EoP>q5r>XkJwmPIsT{CBX$;chW|}Ox1{w+OUb^F&B!c1J-59LOT_{M48tGVRm9QmuWOgYBaeRq=lB@34&aLjW+9Yi;G1?2r0yT`V)x4D0$fBh z0et`lyn~gsCyz1k%{mBd0PG07WApFZV-e({tq;LBfaMp&4)~W7n;;GStM~Y4;ztD{ z<}Dk>Uod`#79j{8#{j%3n5*B9b0VXQ!WM-MA)xLZ6~f*@Z0AIXo6wFt?Af~Sc7~AO zgoB6RC}mIYX)E8x4n2vhmTT)AU8G0P#70g7(xA}K$t8qP{>D%5n{r@Ve{R$0b^p_` zF$SUtec+Z(A6jf}?T5(VaDTuo$gk6*?_WR%)y@L=)3V+#&rcXv7UoC6hj0QF+Wbgm&65yL|i~081PN3u0(n_NLW2d!tjo&wmdjJVsu*I$axJp9hN* z0i-#2wFl9+yKFm6zsdLZ^02+P(>I!@b?xt;r`P+dlfFAK2^Mbm@Xq!1`u#ADZ8=sx z>G*B%)ywPdUc@#R3l4L%j}8Rbua8JCf8?_NdrQ@U@TRBZ_amz!v_|BwKbLD`8+*=& z>-j?p5YrnHi2QbIxG|=+Jm81p8@UBT0ur#})Azfp_?!LUtMpb&^-CB3>nb#XCo9{# zjnn)68;X4ZC!1v0|)ufGWN)$aNVB3iVSieKu^{uw`m=zl2gKqcQO90n)7yeaC z=f_@P%Qh7D`4h|6VC|ayyAz%i1jYQ(^5!i#$RB}?Eew9|<-#@|VGiDlE02}_c6S2o z;hre2Y!hXV#>_X5W&!r@GGkcS&nr%^WLI1qX3UjqV#Zg?=XuQR5gr2Uq5lUk*xw88 z*RORM=Ql)OfFO61Z_k?k0{_m1sdo2HFX|tgVAGo93w@t*<9l~&1`75VA^^CEEM6vD zCM5HB(mWZb8hv)6j^xGWqnwg&)~*MXwnEE%$$@a3fXh;}P}#i$y2@&Qu7>8;c^FYLA`)|h+gYfO`#M+uO zb{!J0LG5{#r63Nr`$14+}?aWqwaVUylRi>(T=9AUA%LDh4Ul&#e{P7edYRO&z7{W;0_ z&CB2dju)XYY~RXh0#L0jBi-? zqf9;NSG6EjFsuu&1?X1D(6iSK*J+F!+`if$%q5Go@0S0TeFdB{wpR)*g|H>lIe)>G z6&_M!^ddghi-E;Z!14?Nx#Jz$H8quF-V0o*567_HhlZT$8=rR>wj4KFrz=l5ni$~8 z+CEP#dbG#OGG8ht9fBUpuhl}Xs=-g;$c>N9X7BVwc$zH^?7U8BJ7@eqiSF|+HlGtd z##no!k-o&C$6CX>U(1VlBf7JUK^LEk3E#IFritIpsti=v z|Q|&PLB_K15b8_xfWWimuJ4$2jcOw*a$*8BizT$ ztq&%TeBRIas~Y4;;;)6_PiZ({u}7XS$mKc~rFbWeePDW_IsMc760-ekZwm&(-PgIQ z6XFUGh299cuGvhp5p=q)7l$|~5r#eh8Puhfbovo~l#ZZpxs8Cba z=g+y{_a|>(l67qj-y^-qpSEbdl`l*dV4JTJFeSROLGMh{WF_tZWJIDYl7EL`KDZ0F zQqvDP(=@3v!Vo)B<9N0KQsa|fxTi(NeF~1e)q2a1a~k_{MeYT-yvpO9NRHIQ^NlI7 z(ABgGba=lrm86+?L~Cnr9ZX(IrovKNL%@!B$r1%RNoG7A<~0NzbR%s|2jCv8JkjyZ zb3w-t*zR$vKG{c|9!o;v774$f%XBA2w@k*<)V?EEqv}S=Fv2ynC{1)24VJNJve?a% z#Y)%=J#sKuYgR3Zpkk#!J{xp1(wL4l$pZ@;^EOiFE!4cKxcPJ!rVDk%k(XFa8(?vI zt<5JqxRbp6%Qc)LG+yn_4n0R)1Z8$ufr>%XOlk%udD+hVu@+$(<06&Vp#>%%LLp2O zCuJkTsw)S_Zz8l0!HbwR(70ojucwh`YlxaTt$FKJ+}DYOQZDhAH9gF_mdC4q9V!Bt zWp(v~byGatSU~M7ES>9yVJ5NXV@50rDehsb^K1n$m#ol6*Mq-LjgUunn_wU0` z<8?CXT6eUr4=p)X+wyC}r7`|$y*G2+OtY{nZ2^3v3E@3-TElfvV0YCv(F_c-kK-N^ zP*hN(HK4&H?%6(=t(O)ST@ZljQ^j>E#%X!g3u2G5);zWxr9+Qo$T>1x=1~6of8~S! z>@xea#dfpiC-Npz&N*XjUaJ;Yo9C{2F-eu~AuJ$Hr)N zCD9fa07+wJW2I>)F!w$?mM^gnBlj!RASmGTE^ZDKb#pM^54_4&^(mK1GCA2D3R3-X z9G5*14Wq=SCimSXV!YR)eE7cZNKUdk#nsF&0mL z^3Mg(46QH8995Ks5ANge#b>9~C^#b;*oq=7h6GA`BW+buC3#qE4X+p0um!NNQ7Ru9HyKo}#yAn^Y6!$Fo^nVL%{qTL9rV)L}L?yZ` zLCZvrvWiHqmlaGb#lKz-#jQ>F)PQ1i!JCe*?TGmenx?0uup%66A&Qf8e`2?b^CiX%04fOs}?3~m0Q#2l{WE`=?~5YBD2*)F*}VbTpcM9cJ^ruBc)S&v9(!^{aU zsPqNX8Ca`et-%N!T?t+p_=IBl&|`0SLLv*Jt*12@j+Z}q(jr?%^bX}7HbFdje^5X& zz?#Ta?N@wuP6z4_`?1nWu+nOL5RSX{X5)>8 z8(LRJ(-z`uBd1NgM9A zURT#$7@&L&FB#G?*VGbq>?oITK2R&vLkUx^so*ZlU>$j;I1uwjLDHm>-YTU`x#Oxt zTQ9H(Sb{MRPYwlIcHPhi1`oQlx8i1@M>|x@#nGU&ym6UUxGM7CWWaBPzBSv4EJx*$ ziRo9%woQc2K^mW8stu46MS||bJD72UhoP+%et4JP%(w+)EtZ?tp;4_$@BzzSb;?7m zL~2Rg4J$%!BODrts*ABp0p^w z;_mG$Jc1&OroAe&q;)<1<{Sior9J1%mCU}w1>Rx9!yN}ApTIx8zerC=i;e;~0UhR^ z`g(VEQ?2lJl;cM_@~>^Wr|2*1L7|{`GxFUX7f8(T$rzl)woI+u=7`i<^@A5ixD$%e zWiAqX4QVC9K`!Gps&gj})EYgyE-;^b!I1dyzqUtbm|;)WO-skoh|z81@|*N!u$1+` zFrKr|BYm=e4htN%-^4?#o6EcggRY&_SG5tr$u+G_z!G)0Tvaa-H7ab>YDl2BT?ZU; zQ+Y5XJHL93f-fQ}?eq<}f~LxN`m|{pJ&q0N*N?k)=cX~>)iwNj82N;0mSoL-$Xh`o@WaF7smz?=U&Xy-tND;7QBVz2a%)_x2~Kj6WuxVF7uEWdMR}Pl8{8bgg^k2Y8d!6DwHBf{W3|K}C!t?Z{C{#!WO7T69gL{cxY2&o;sSy1dQ!8nY0(%Y_$ z|MK~HTV#xc_qLsphE#(g7ei`k{Ud((m*a2YrG<@g1F8z%GgNYVmipR&@K7k!@gkHY zZ7u=kokb1@CvYF{LZscg{(L$;_cTw#3Bu13HYF2mGmgs`4|v*a3s&r=)cp~dqqgRY zX3_{_nASV&ILgjgE4I#_^g&&>jbLvhqpKUYi?^$$bo1nL*zYOkEEpC$tR}{qVPomr zi!N{Tz=Y?w5}{nQO0i?xJ=@4*NOR*zhXv#+%0SU)P+Mi$kQA;eBJ%E0U=wa==`wDo zs0+M~mY|x;3eo{A?_BZ9^lds!yu?OKZNIZ7m}?QVG|K^t>w9`f@i3J}LBsiQ?@h84 zHR#qjfF>y?P*TucawTuxqQW>Ay9pAX0!#*XD)n=jhS?;UYCVU zLmJV^Hqw`upn0-L_lI^r+xfZp(gAM9S^XkgBM@$y4>i6-bViOYidmo9h&yO{=zyzd z=x&3=JUjW$Kb*>uaWcBQ1)YnCWl2H%B|w-kbAZTo9`M)jx$~hwXWA!lckqX))MG7( zJa@HA%C&8Ge&;S_xzzOcWXegv-vjIzo+TRy$4Gr^F3?z$rDUHmJ&T)iEaytwEn7ye z7b)AOr0b=8fktlMR&bVXndS z7U@u@yeAC*FZUeszp9{w92i?%=KI6!1Gc+^f)F=0xYQ-m(S7A3)3S3&L>~>E=Dr1# zSWNA(@$$L~XhsbLXtUSli?O8jejdjwR^WEac5Q>~v9&3ldvy7l-Jy*mlpO;ES> zbZT65HLxmNtX%bpaH%MR2DIbf(cQOAjK=<0bM(LJ_;pap@yGU$HC3QPDDW8Mgx0Zx zd0j~F_`JV=!+ONPISwPsoeZwEpzWx9oS8gd{lSrwSMt8o?Koc_ObD$}((PVbfq2Zp zH-)?p3W%`=;rWJ-oxvX!`5FaR zKFq<5?D3QaU%0QtcWabLNG2QU6mztgLL4MZLPY5&UU(3Ib57+PO93I=gJwwWslElh zw|7dbG!%m!>YmpN!98I8>q*hCj!t}@Qhc*ety`GUBz%PC;XUidz1n;WI!_gCrVBHy zFtLxm9rJ3gGo+c>9bz*%7OzSrhxbs_ArR^r$%m(e>QoW8#>e@p7lOOz{cJ-3{)8N5 z!$@e(d@KkH?zYpB2^V#>ofuExQC6kI5$JJ{$@mc2=~Q4(Tq3BqdH}tA+Lyl|iF@JP z4oIg;LnMb>&Rpp8EJ>5L*p>UM9QC$0lHKxXl3xzeut$x2?FmHQ2>o;xN3LU{dixKK z@#NXghU!#)s#+2!04*j5S=(z8b|!hCF<-TQaa(^z|7G0l8q*j@&MjE zuCXpLPV~#zmaZL)CxlL9C0FEl=@s#{1fp!T}P4Sx(%(jOZ&Uh)qlX*xnKE<@?B-%TTa$^N+YwK-4JE` z!Cw=uxm=#oX(yZbmrWHYQNd{0gMC)ca_Hs7?Zu-cpWUzX^CJSFKkc0Yxss=vJ z4P}4#aCIIUH$?svhm#+6!8$GSawaZz+BJ>$%KDvr8Qht75N#J~)4NVcK=l@QVAtaH zH@>IY@w7vDKI@aU(d67SBRJtLCZ)05A3}!?D+5sr6!%OE2}z419;kqwrs<+@s&tAkweYbe(@9Y8D})fMar2 z^CmUCp$6k(UgUQeufUstsf_o*_D>{XV&~cQ2MG0G;l!vh6B(_1yjHU3jR_~{>o$zN zhrW`@3i_2_t#fBab1hAewijyLx+lA9CeLh$`cIz8oBI(-u%0}jR8nmPdRD7BhUVzm zgbk(B`O3p)2d6LpPwe@|Fy1;h$VUpXtyB2~XsAP*^8b22Jqi z!cEY|j2a1pwNY$15fq$<#vhx{HG;Kx+xcGURm)_(ij*YwR7_1@R2LLz3@rwOBrRwl zmL+n-qLG=^Sfh7+^5&-3c;|gtG&W_#Hxbo&Jfws0;|QwO{H&c8^{fzZ6z++|<=d+) zhOhMkXW(MyYLioYJjJ}eY zj|Kq>nhLEon_VA!g&^-)gZ&@I%{pCvO8|cu^IL)EwC5v9O^K*tAw8!VtF$cZ!e`n1 z+?~PG`Dovvd|!=!|6U5jwf#KJ?)CBe+ZGl^Ef5@%$4C1^QkJ^NE`eHrgEZST^??8! zV-dIO2|+JK^)7fNqf&ulk;%N@dD(jnW$ip8vf$UG%`bxTymHOZZBCr2Hu;`lrXnA+ z*EO@W`(i0m?@xvYFVHw8&&-c)LkChK{+Y9RtP6-8F?&b@%6w9hSTivzhdMgVKnO%c z$=hR`MGcea>4hm(S3MU2mhrxJv`_)+o-@SqG@%=*HcJpd+HLak6evu^%#O?C0hHk4 zeUvEMW%r8rTA*4MOQO!Oxwvjo|XJApbrynNM zc|U@vIp9$jp5WdBCGVvL&8PDYlY;%cCloG?!AC zt&ghquiW-u{V}B9VFBff5{alNo;tT~jkmHyM$;GBw8Pr?Xs7%!3VZRoU4T;AM+C^m z{biBCelNrbQB19U(^)A#fPBy^&qk+b=I2w+rNIkcAAwiKMFlW?ne)c6OJl-+Aj`9L zK9D%ZaW8_eS3$A=C~Z4b$t*~@$M6RyL77l2PWrdj9z|t{a1ni9JI_! zfE+;^hfw zI`x@K=H+XU7o?(kB}uy=LAc~k=BtriOm*qy?HFZ+e0SXPbK^%)XAVU2AYr5{l6Dk^Xy@%7A=KW?VY{bmDNt8_GK@&K%^KSDQ3W2_&6_ud z+nYnuNh(6Cgi&JE+1l|f+HzRE1FTxR8bnSy4$YSy@1yO?mzvptBApMdVR+R0Jp@Mo z@E4z$3ZLJ3ATC+%^#3%p8P3n_Cp8DF z2_)?>A~IvaDd6H(my}U~0sMiu`3d+Su`_v5jv?MJ$qbl+2;$_~rN4Xuj}Q?MpbnJ) z^6A-S*kSTcE+F=h0q!6pAH&0d{Q-Ok_5d7#-iC&R@xEoj$2bKLnzUx3^|U)|UM`0%^Eli$<- z_z$ShY#5-xec2g;G;$PE=sJH+L4XZOEN%+;C1L;w({E@92jKyRcLFwqB}C(3z^@w| z5cz~2R$m@%4T4H=FG5u05g)G>1QY=X3MwK3DhR(e00Mj+ z?rrVEN6t*#u0W5T%@jz_&WxRzAFL@v7~K+Bz&r81XuuW$0LlRB!R2=^@Nbj&+Z(`& zJUx^?XnpX2_>U6qVaVE7J;S6JKMz0&Kg{bJK%ZW(Z*RKMnF(wthsO{2k7sX}T=Fr@ zl1kf;^w(`#7S0y%-t;sb*xm^`5YU?+kstu#ROBt+ZIl80V zuf_T`9WeV(MIiFstf8hIj5Q%Z%x~Qm3|Jkc6c93KEcr zT9@rwewhf-dwiJTN6^!6eWc#~V?O{1K!A=U0yKC=kbvAC4Nxp#@84vs0qEdiVg`x; z=$Sr&to9%h^eoX3f$uDS9pb+Vsn<~b`?5YWVbhp?O@7hXKn?%_6TQ-d0`b8&)xg-Y zlO}hZPj#^q`gWx_8U9r#PI&(lj#P1))nitrd_hwS(4NH}>!=Q1RXv$s>?ZGi7;7`NY4^SaStWY)ZbT zOtm<>-v1LdB#Kw^aX;)fv(EFS)I@Q0(C1}yLL9yxldjHw+|v8o9&YVT6G`*yKrP^V z@>R`4t$bq{KLEe)&KA+#zX=_HF1%#^?zwZ&T)sS{F6b1=UvP1Yy*T^`#opxPC8!!{ z?Spm}1>$M(Fv%91`R>n}~qKNFrV0nt_}{OsC3HTUj8O{Uecthc3o! z;@>oq*ASx6cT|TKc)5kid8xH4vZ1&~(T^HLL%cuTA>Yw zX(WG2+LE@zBkE{?e04a_z-fbe{wt2#&X-`DG@>v>C&Y)GW<2^b9IPQMv=n!U*_5Qx zQ7eMK%$*!5mdp}$6VBHY!CIa2Knp2P-KP)f)kvUe@1$&;Zx?&sNj&H`uSQF6g2^nA z5b|)~oZb!wblf3pNLTc&>LGUFTi#@qH0hEXbygf1V#kGiQCwvyW;^pHkmKV~-*eY( zLrw38*#Uoblz&$WAfl=zcU>sk=1+eO;K?rx70DFdiKi+7cG3K)vI6KZ9)~>ChGUJF zSjSf48IJXd0YAU0Ku7hDpU?diW}kE3ayf7!1(K_jy$#W5^WK)h`P1eMv0>NgT>8uU zyn2~*BbT?CdLzcK6|+kB0bU61R5g3W>&Q^6AG&S0;L#3(=*6O^r|~Ic%BX0YcR?;&H1Yaabsd%c2euGR>mTt6il0)aS=^2a^S6>$2BFoP6jiWuRif;Z zwD~6RRQ>ZVJ0Bc`~S?4Au?M`vqOIigg6;rV-Mk{~?~<&T@8r4}t};oIEOOS!MFwlfJ{(b(EIf1&!$ zH;?}F=6((6RZ($GD@(4-IJ2-rR75G6Sjt6dY{_UzI$<;EUh~OZqjCqnK+04#Q<+Dl z(sosNHuwQRbdOQZh_B%;E^E}HxPS@qQa=ar33hfP2o@;;O$ByX7*-7l(*ZPwu4+7< zuX;6eUQAiaHv8@^M zAR+PFJD+t7t&rkoD#MuOT6wIjeuwdpqhWU(wmV2mINm9T2+2QO*1yA2ddcOmLmq?q zfmsRFU2N3WyGCEAKV^w61YAwIjd~u)L5~%fx zz!rOamI9JRX5KMx%jaKk{HqJ%3X!7)Q$XRA5Mif-U7U7=c=?)Kp<2CO&G&LdwJA+G zG_RQCQ<>lm_Mu5x(`H-2v~%^sZ_Pp*jxSZ>`9ZE}M&28FjzA6CCe*SyN7~Wps!Pa2 zy2<8fD|aU#KqJ6cr47w#$K<9|;@p}?S#_ht|96mJ2DGi&t|t=w-nFo_)1^QMji)R4 zZbA!c>zw{lT8cjco1&1QYto-sOP+WmXe~LIyFkF0L0qD*=?pNAI?LGlk<+lWTw z9CqU*HHjreKLMyHZRVLXh8=>vQJW%8 z2M%+a2#VzWa^j&CTEC}sf|R)9<6>-Xn;e|tj%Ru-$Ke=F_(YNN`RnR}!s?^)Zv%+A z_r%Z-*KBVUthS%C)R@8MdE3>?HaYUmil~#yT|aXwNj+v6FR#unhL0TSDsOA z?918Z%$^Pf?U%ju0k%_O1?v`~P+N;*Z$E3+K$SRN;ED0^SICzjRsQU1#V9sZx*Vn4 zu@T>tgF~OBy|scEhe*?{)u^f}M4=v^g&4U*3PM!MG~zGQVR$aBceJK3arZKw)aLB% zo|?#%Bp;R#cn?%tN_lp1ZJxJC;b2@~z5IpuoofeAJ!6Nnt43uZY;r*VXb@Ku!M4J0 z{Wv_b8Bumzmm2^|h%-uuZ+#!;whIVA$lIwPxnKHBYWnc60@=(s-OYKgFJ<{W!y#RU z%gWl5VAz|F)pY|E9t_8g|BTT(@t$Gx8Osx09nJ}J)Ub2j37;lG(R&dsmqOEtt`$u} z@-=K-V#tk;D^*$BI;e%PZK>-wty$L_A(DLf+Z&%X4N9}86aSJJo0F<@qSI_QEvjL0 zyM?+u(tc2(>TSER=gj6FkeIvXTQ9dHW4k0)5TB)BXpm;7_ABee>&hOtLMB5>|!?Kbtm^F2D%;qvP6GF#4pslpqqo(1E=dd^O`Uz9SA`A#6;W1AImH-Ifuf$&7FHerL%cZ< z`WsGTg!*rrIc>aHlD2ynNVkQ%!YL|u(`9Yfy~E;+f52PRYuC~+C@WHd)rjSTl!^xEJZVYYCeX&t`}{x8XsjZC2U>r`thLKQQ(T9*g+a3duV7gtQVC19ZD9T@01Sm3YN@k2Dbwt}86Fp?t6A2hZG9ZVTm}?>rF7W%VWknY-qcGi-d4ql)V#uPj|mv*~MQM!8FuS z105aBs(+M{Lh3;WuNSCH;>D;=YgsOp!fK9lM)lC$)A;n|bE}m|JFk@?bh(;4s>%?m z+u+B$!b^B2>O8JA4CEvoh*AmcJ2g>k`1c*5-D$P@rO0sGl8hzM4m^~ID(}uc^AmLA zqi8`BOO52d_SlI5Z9 za%kCuq&2sRs~0rxD&X4bgNLN0L}UHrNUJ==Z{XdqF1Y7MD3Vl_XNQ53;e9P_96Fgk#ceeIKne zrnGLXbXm-#X62&-Y*6W4*CL-1ex##%!1`+Ll(`bo^+n~U{hDvAdCusdgKydJ6skrdIY+&-nTCm zb9c=&avTc>r$MlywrOj&XOP37dK_rUjmRi5@A+ciGdY1Li6{0w zeTX!e?$*gn`wf{XcCF&VXFCUAKg=#u@z2he<{zcEsF4I$6}0M_l8nzTxs5YW8EB#O zDzJbL@cHyt%QM}n?lQJKCN8Yw2yP1Ryw5)S^91Cu5A&$ROq(bAD(CApN*xBarLN)O zHJ^TnQAc-uL^^I0i>VPwJWC9*$+vRhDU_uuD%9g1g=DjYlyhT zQfrBgH;`{qe#q-)ilH{~ST?^cJ_J1x{iCbFYCt?nG=U6}r%P1|a|NqovR>Z0Hei;< zkC-{Kf|uD}C~jV#UOG3h@TW)Ju4cQosH(Tp5s$T|W2y3S`%lDao4Y%cEBG9j+$=OV z(NjPo!gH^G^uUf3S-LOUvT#tP@{$tj zQ)t6kab);t()Z+ul*WG}iX#dM1l@~S=;E`e`))88S$C^i{D^G5(1)#nC`8tiJT(o6 z_h3Q6r)UxNIL}|FYK{EqZaJ^n_KrbSbe7g`P}#?wA2+Q@b~XN_`kIVOAU+ii8tAah zyG|CH@!FYI3TNyXP;V}W0P0JAPF#tJ?B{I;y8RQ}$hwkP$vDY^-OM{{N#P$D|%I=>!IYa|CQz3MH6?8Ic?VCS*% z?aO8v^IU~;PeyJFwvTlqh;%nZbXU~|>VK0#A7=WEiLi$V?weQyL?d1^K z3XgjYR-ihi;ooRLZ7D)rlFxABq{|Fb9?X&nMtfap4`J6mHR+)tEPU`j?XD8SV=Yih z#<_tCSLY?(P~~8&jNt=c26cR_f|Sf>d0a>lPenJH;0uDxiT0sIT=+ri{pF-Hp-zMqRSegvAZycMNA)SxW)9dn6S=)Ku2AD;VVo)SQ0YqVV~6>^#zNv8UZFGeJ3F)!LM zSKaL3EiBIZgBLUQq=Nc~gNQ>~x59+!en6ke@8Q$X3^%DF$u;M)hhup)R;w6GmR^-~ zKkcnUhb9<0`gPDAP~a(XP@6QGpkZgeD^95~Rb>b9+qkuYVyO^rq2*Wq2PVs7n91?o z-}Z8y`&4$=5RPxf(Fg0(>vWzH9a$Q^klo68Dj$rF;)iu*i5ZhX6k9<0X5nPZ|ZSF~4tIwdO)?(Ca{`QMNem>{{_eKDklT6cqF9{*Q7NhM1Tz znz?3qc+bS1w;vrIk*k2*bESTM$T}!l+bh&zOzoEiEDUV7=()#aqVcsho#2Lu*<<;Q zEJl}DyeM-+DaS9U8PV0h1a`1w;T4DbC&nmFv+BhelNsSP%hzQLnLIppa_eyum31$b z?$hAn-K94{;2unzYe>v&R@!&{0WNu{a)j%2ifRDWFs2dCsR%SsOJ60^^JBCzXSWS% zWG+cq;QV8@g`^{bdAW3MiuQD-7~*@pm_=NucDj~ysMgBd7!j*Sue}~J1@QU0QeawL zHSNCL+ckW5NNgbm$BkXXJ7>ddL_9upADWW{HrSP@cBkaAr6*%pC0C6sj-WDxk#UpR zcl1njKJjvMXs5_1iT6 zpjb*5DY-w^xm)!m+L8fvyS;ddtrCU(g}m@|t14z@$f-?s423o2A$nkszxtZ&KVN$# zw-Rh_h#o$c>^#XUwlOnHuq}usSzg?JZPws5el;s4tN5S>ADN6sE-BqwO3h!YwXr@A zXEnCycs{xd&jocf98UJ$*Wk~#m{sBW^7L+AJ6@5ogMuBIdzCABS-o@(SMLsDNUvYpc%g;cD0u%zRSP|l3HReoq~D-Tq$tqOQdyUPi| zW49TWsQVXXQR|^)p#PG}m{j$54L?bH%?NrDD;DQLN`CptF291K8gTIZj3xL~mO4g_ z0|r_rZLl3&AQM=^L;**$rFUBZOOSaS0yP^M7ysGh;&wrdgvVGH7US2iH zyT;XeIye~~{q8}zS)a+8{qFR_iIU*`lg@N}FQlZ&62uXd>?7Q@ncgw6I1`zqaf-P9 zno3P6gJAhwu^fc0Fh@L?)jf8?ni{>&26e?mTD16*F6{gM#Yq4ud z!JfPzP=S-4va&nTK|^`X7RAT%$Kh@XY^>L(QLw5>y7hdTz4NQb0*64a9@hQs(V<>X zMiaJ0kPJ_Gyq!Nf$b*75>;#7`n<3qC2$+vK$%9gJ;_VqUyvxr$-mAMqp3G0Q^37 zbb?oM-H_2_e%5(o2+8=IqSTJ-pw}EPMR&m&lY)nZa}I>gmI&C5RsF$n_f@B@ZrvI! z#X)gHKRh!vUU#wOdCzej_M4*|Y5BsoCy&LG@r`l5LM!T}ej^*i9iMr-`_6x1b4>q@ z&9N{r{D;Q7Y$(+eE%JylevtQqM zie8kAGa`W;QlSux2qJ=9UKcXTnEiyVL+&6HdW4eIC4n48p2_KBI zygUSERJq`sI+qSHP~I^xxW6zUJ|xE9A{Yb+1VEtTUq;~qV}J?-y)-6%HHf?rVg7E3 zcICf0faGbFSeRbZdSU>z$anz6G&B@Y2m*f~Xz7C+Cua$>e7Hko5b5dg%1SQqkg0_~;7_1LfQJJ3^NO0t z0WLuOKe*ZKJ1Nxv0kFbP@xlkVJH5S4q)E}85eMPk!+X^G zMr{G0qRK40`>lDi%Why?_(!(L!9XA)!+`_P_k z?A_^E?&y8|ioxFd_XGc+>q}e)jllWSB5{F*|FW`#{orcqlrc?>9`-h8m_xWCBq7w? z_2wd;z=pmHWy9*5leO+zzsF?$WHGYC0J89V4*J%h`s25-{Qi?;q%7iGUEGZ*KBPiL zW@q{7m5163a{gj7AUZ$-fP@5s{58ysP96djz`vsA6#DjyN5`iQ<}awH1+exY06-&- zd@>U&76331Lm4`UL+Sk1p5sgIb(rtH-^KZoA_#Et_k7pKdPXB8g+&;-Y4tP4=U+qa zR7UuPA_w~j`r*n#f5DY&i+knsN8x8jh!p$*`cbJ!gonC}{Sgtp;`$=_)ufRx<6DYw zw!}Us#yZwTUUvQxJnzWeI}O+*($1aEy@Ldk$o ze4|BE!%c@*ZUqL)JnEZ$@k7^1&*Z~!mHBZWSAaNS(E$IcA;0GCheM{o&Tc>zj&@gTorYS99Lmg;d+y88Ax;73nu)a{U_Fx zq`9Lib_I7hUrz0Lgf|CFhsG0pqG9KtfP2;1eC6aI$Ja>n<8V@{kG#EjQ&inYYc5Vr z*Qxt<7ZP{4hz<93rCZMynt@K?OtEeM0=%R6#1w~(>z}nKK{j0A^{_cZh{b{ew8RHb zDjQL-;5d-bHCZlQAUD#VpNe7tZmS1tcjz(D4KG-E>E^7NI#yAp@4L)~h>nQli56$K z-vQH&!Y0} z8@IwbmKieQo-d&e`O|dOz>`dZdp^PEglU)lucwWBoTIUG=~MpWN9o{$qX}0Bop@tn zHdL?IL^phjG;!g>Z7X^RkInPSth`#}sF!OK_lm%QyVIobdg^xJ4M9lz`1RuP&x)Cu zFA%zn3T@5-#Ww9Vonw8!QcGgRFpf0c0Lu9--cm@!67wbAx}hlpvHSg{kTK_be~98Y((7mb{D$ z5xnCDIhe$Y@I88Ety5D)A3a*QV|r;LO-y5Y}0H?5Hl#*Pwq8E!EDZ$Nevz znJsNP``U3mbt*!m>D{g^2_RZ zrw(kE5vZ+7SeVZXQhW{kLHI$ms0#!P;JZai*#Wht@ z@1P>BH}xc2@$@;c942a|IvT5R?q}!i(ALzD^tuPq7Lj&UELJ6;UQE+R z8Uu)Ttg~ZQgcAe!)JKu=!BC9E)}*KXIl8MdyUY7c@#C8RJW$Xq|AoktjCTY+NKA^A zt43}fbqmU55+01J_m>|b-TIBCw1(B;gyV9(Y{?82R{9bz7M}7?X4G3_wUkHwCA(jh zc2De9TPF}Bvh0~cPqq5@w{sLu+Jb3%91QpV7AFSh1>E69l{?p#)M+boFR@|NkTW#^ z<@GEo^ER*iTh%F*mp3pn!`M<_4We8L2Xg8&h&Z-Llk6<8df!p8LNq6Y!yymf4P$>y zJeo@TMZjqBf*yw5>s?XR-Agu`MNa#9b`K`J=6orbwinRA>b(o*V;)iPGOyL~&Hmi> z*TsCfx*6{urG9ngeTK_1&@4|u_sb;$r$b3I-wVNtx=8^sxUTd`ei>rD&}Hd}S#=FD zcNI9HUzseh!h}lYHv1&t)M}WIImr>PMu&w!1VB>Bef-!_k3eJ+RAc4{>3qveW`jMQ zdbZtuC*=-^WjN7`g!RSfxS~uY8tpA{TT*!Sd7a)Q2&&o27AxMsJg4<=)Mo*#_W=&} zJ)IV@S`lD%J5y>dg|iD;m~uCb>{*RNFYaDz7;I^PFr;|-K?bs8>}$=3Wcfe|rsJ@a z2{yr%ska0O(-<#PeQBWg&HYD`P0^*N=cnOmyS|9+w=~lr?EGg_oWOnhU!y>?=$94X zKc=r`=pC=USSKp+ndsWMZ=xsJe+74;i`;dknZybNw-x0sm3+?J5(|*9-}VKjhQ#Fm z1(}JxM9{z>6-;A5fx~a@@e?ihvcIEBzngBWCIqTl>8Z9OmQ>(f-aB!41`UmaPUwAz z_fbO&o-R#I8xr4TzF$Ra;+51cpwCZf2S754iY7)ih}gIc3v_aKTH3qI#sGD>m%;Ed zkGOu^6SfTh`~b{AyH#6Hrn`Qr$Fq;>_QqmJVSVa1I{N}4GJ!C3opnN!r~Vw7sA}si zsKJQew{$kD>|KB1Lp#vWx5vCmitKB~PrborZ}F3Ef-7^OqiAS50Fo}K$u*Pcs_7_Z zC@F!v_GecxpL_a10;WRr#ViwgK&;emCoYn{cNxs-75(x{MBI1VNn4(MiMa#5YF^hL zpGK&0D*>~gEDGfkwQE89?{D}+lXgfOphH?;6v9Us(K>ZPl`FfMnlsU3b4{M~q2?!3g7voXtBRKAK!bL|azXrj^qRa=Ph1Ll~P z{D8Rey8qk4J?zjyN7qS&fVuW*nHGieUSdfwi`NVOHpCTZ*%cPCferG4_r=gIkR8ajp3fk&^@&1RvW_|MncMQXx~t&3{gz&lbZ;qU{|h~55##b zY?Os+hnp<953@ZVg%h*t8<5FHsI~Ut!i=P`8hy; zU=|yQ9x`;9_|+3{9i7*<7p^BHJtTeZmb7N`91t%18rlViFv>8xU0U~o#Zrp5itvPO z0)4kh6xA&ISsmAT-de*`Kq#Yv%ubsomM^0znuYyamJ?uvMTKf@t5~Yw3$&EJ8v#aQ`iZ$M!UqMRWtQL!qu@g>$n{j-?2uO$*2AZBRim}m-T$@xSl^G zmev@8=n66JzS;TVd_3G^5k@()fqH#XJ6ntWTeYMGpuPuf-_d%H?oSC~wiw#ibL9Iv z)jEdDii4)46egU)@$G@qr&;Bw6ecS+(eaA#XkJr5G!21$?Rj(?L>8a^7)|+XbThIC!N=Dt-v%U{QlS)N3 zHdikZ;I;QQ>!fP3wjAZJInK|@91}-qdl$ZQa4pM;%Z!B0eU5#>6{-I3txg zP_?DoaBb7iF&)ved%(r52{`7tDNOerZjuXMhta@dU7{34CROT@3l2m30dj2UWtqPs z4JY8i_tbfj?l^L`E?(3is_H=)kO1Y#S2Y_HEI*E$Mt-;Z2;sMJ!Lg=A$Kq`v?x2U8 zm?cMq23CG|Xl@7(_w!IQiNo}4zC*t^4pZXeU-p=$NRi6WcuIy`;l;nLI@wk@yHXM6 zGJu0ucnj2ccD}ldFyfT}Y1|!0GM19lW z@uHNiRz54C44k&;QvI`tZZQgI|0a+8YXXWr*Vq11S27D6z-k3H7=TG(f4rHC+}9QoCs` z%d|J2Poa6u5%Z?*quT4I2l%}C?d}sJb+GdTZv8@5duXz1 zWCivjn8;_b{CT2R3E7(6Eiu920xHBXSa?u^K$}B=W-{eI^I&>87}cUPyaY9Zogh8- zsAdq@gdv$P>%gG5C+@VR*3sn!A0f}~Lc(T-O&W@jB5=b5SI}?It(PJhCW`UOKHh5Yd#RjT7OU3+2Xi*V2u?)-fAOq3f&bPwOs9dUD_%e}2s zvZ_s?@Ql)3_ja9UnOzj_z33PP#^j#8isSyaiOERXIJ#!n+R7!Lq3h+w8thfsfSm6< zerU4j1RZM97oQCR9h6Qz*b4rw#@~EOyaS1$-ittoWY>bEe_B_45#;0MYGulc0+f1v3D8Fm+!fx|h5A+QuI~5v4J48G5RvCS`4fYK zCZCHipYvZ;Z7LC z{`P~@jm!^CzJ(9u9KSD@+MBTf03ey2rb$vaNr!BtXwyn18}T|UD=IU`ybChS#r_xK zUbd8ouj$j-YGbgLRZj4zjs^j{SIhl;rMZ>M?KU{x(Mb2HevnzV^|KMP+v?s4Z!0505Wbi(1yW zL0v-Iy`cQ|?5w!PfU$Lx9h#S=QyGTVHNkG#~Ha`OYkCx)%4 ztK}1p-jIqgjflyp19?}kFMfOvzTY+0;-Sg?d<^1lIrhA&^w`e4Y zt`j}EM0C591s$fWMAsiRuUJT}P#$1i25;Ul9Z_%Ll_sq;*F2=w?s#q9g{FCCe7p!` z=>C|=LhfQ3nIcP7e6pFLQ@JeA4TDMcR8tu5!#rTy;<{u72V!JRFS(3>zO9~hpXXHS zq0nqVuBLi)U*Mnd47o_16}bEUqcI=c^pedm)$S@!5R%#H&(1n-iV8c~ax+`g1|qHJ zIbX-Z0=LK8BxeUH=@l#L_MS$Cpdw@T5m1yhVf)zClH9JBb5HVqgRf!4B9& zG8#24bjugmO+JNAPOqbS;VyNriTVx#tl3e~$;rY+6_RCe>*L7Ov$9wAxxLgjf|v*x9s$b1^tNHJKV zx?K0*SY(Ax#{xlIWP+0Y3e%2SCf4$_Gfj>eE;foK+SENDHFV_Q9N}uz>!``}w#d+` zccNyxB_z$*uWlcP6u%?#^zE7vLreYJfo&sJIT~AWRtH0!LKVAj%3nN5$zfHY?S{~U zhAT*U2G^Gi(ew_mTX@D5H@Wi1sAn0khGvYJ!A#fsYaPF*R}r#s26S5L0US-(rfXZCdQU^HzQ(_}t;T??L6gLOazop~STGxe%{)Yj&HC$- zACi~PeK0AXhDI{QaWujSaXHC^x~m;j9kqP17w*}g-yh%QSF1d>R3h8QB=fSbdS`x9 zo0cwVlw3CkMk`p{vB<*~#O6IpAhP;CqLd6s(Exvtr*DsE&U$HgEe%c(+t1BEbeYT+ z0=jP_Z$&=N;|>uy+}JuBp|QBsA(z)6iR%v?p6|dNv`{S;Jw+3l7mqN*bl5q&Guw`y0Q!zteVs7{w zb5`2#RYY4C?2A0Ln%ka8cpA7T&l{@GVk?A+YKqzc+#WQ9m8sMoB2P>c9(z}?1+fHg zzZ3>|v9NO%Z@i0{C}-GKC_k@v{b^CTyT2f#Y8Xkc!IVu(_>^9}3{-ZUYyHyUO^!2$ z1sFZyjN(D*3`^xIITv``j)T}5G@)5k<|LW`rQ=!4a_mAiqv>c!kcMRfu_!txaXUm_ zw!m?{JtKiXfFd30-3}c;S&?yynbEssVcBb31-7%I@oyKe1pcNa4&xEhv&Lc_&ocnk zD2R;S-!XjMjYXj?>D(9bsJ^8f)pS};7Bi0OM$e15Sz_eMq>g>GqeK^4C&3Y2vcVk@pMHf~ng`?Ike%T#0w>=IAmaR;^g1Hc)8qrLrgHi!WDA$*~!1YfR=v%YrkS zz)#oRx|_A(Vv1GCkd1CMs>FS7+4{*kA>CHBP=E^lg%EwB&B%t4_Gk`QtQB zivGic|K~ohXm0*$Mmh3V$9=$IO~15z6aViG`$m*PMKhfo<86k!t#q$5XS02dhc6qZ^^X_piQ!6p*Sh z>t9GBt!NJ`_gBaF&X8WAY}EC$yRn7-xZ-Nr_WpIMn%m{|%4#*PDc*2aaG6w?6>13? z3Du2aVz7yqk&3giVkOfCHJ4b%Ax$hq7L$|&^|n0|WW9&zGN=0B@We8t5RNAZ4ysc) z(qd=66w^|30`E*HDpZh)Mli9R8==@?Y1DGBw@1VtS^K%>y+_S5+R?5!8Pi!L{!N#0qxk`5t3dGR?sTP=|rXNE2rWgD#D_57I zMYq?>lxvA8#iQhgn`lcHIcQgh2)o#7VMo^ej3aX59wL(jPqnHpV6to1e5aTRPv;h3C)0YW&Y7W0V z*f}U%Jc#+wcN=^B@jeZpxOt_cuJNdH)3nQ5CB8iW(A%g`7 zZr;WP3=#quSdb8Cn81(E4*`+%mP#}rgOmsI;J*Rb^bUv#!HzC5_Jh8Ea1G|-pEsxS z;{sy8?g$J*LOkUD8w`x1ug_LS0|7S&mXEKG-cdj^hN16Y7ZRwj^DEv@0xOWOO$-Xc z&BOC9Ku^p!FfEXhiM9tRA^`BAPrNn_Yz_X#L%RnF0rta$&PTx2hX5q&=2 zs}G>L57P`f7=H%f)`qhN>t6#)FTVh^RiEdQ3P z|F@b3=maRxOK2Ysz^jZ2J+H7}IPO949*Ez*b2k>>j2H+9{sBNBTY%L(j4vh#fD-Co zpRZ?6Z>i8mhk%Z}xG(Y2`)e>z?_wUE28Qh`I$%)1J~{FJ?N3skt-jV%wHNf4MkO-# zKIH57r8RuW=K3#g|ID^X9|W9>3wR~f_jQ0O;*Z!VfGD7_KYw0Y8#}-i6oA*dAc!v+ z+mkEcF9Xz%YT@VWtBXJzz|}mF|9Ae2{u6vY9nujXSl-rF|4+~F=AB%GygY(Fc(Vwg zbswBO`@Ua8;j;c`ukq8#cAhQ(6F#PUAi&=3Y_HrObL(}2y_ua~hu=nRKpz$&795ux zKH%TYqO$NiptlD|AV6rT)@9?l^Rbp-<1Y& zy{)s)Yz%FHzf;d30ix9Ceb0FQnZP3cEoXH7zyG?6A>VuRKiyJ(!TWwY@lf5&PWe=8 zc29l>p#lZ6yMJ2>?=NBnjr6brOaZ=nb#eoL3o2RH;4a`k?J7B;f=~Q`w))?9Qz1ku z_`CaDJLHpSj_At1irGG7=*`HntD^V?{rJcMo&x=UO@taJRv^F4@#o#YjDQLy9%mCK z?6rco?OY)v!h!g0ZSm~{pCacIAo|o0WQ4ftR`Ec9LEiQuP&h&SacA-L*75N3I^R;i!WQ-G(AHAyZ7~g~P%qSRHXL=! z`}W3L87LpqeGV-!*>Z2Qv?@PID0CU!L`?4*Hp>Mc_|eu6Iv7_YzP^I2cC$y|-3??S zJg3!sd#etfN7*tU&G-~vV~?-Nm!9a6woaLneox%4FU+uyg15uhYx;ApFKA^eGKD;D z)~hd67L^+4zZ^Y=nGD-{2{HJ-4&DIliUu zU9VmOM7iPfe{GxWduq=k<)?;|W);ix5gLMGV`h?45I=(r-LnSO9GFCcOh;PD{p#IT zDit_?`?ZjEmPB|Ne`NAkQRTnY?mpsFa0i`i0`(db0rRt9x|8&fD%S0&R>T_Acx+5!-F8ZyfX{y0AeT* zb2Rg|U#RGUkG;C@$LXO~bAR};;B)-swz@CqKZmjJ`{3##9zC`TTbM;t1qF_ex-!2T z!t>Z~XEsg?3o8}ibA`I<6^2NX>0Pk(pwBsUkMZ3msI_lnsX5=TB8p_h%QZk3PEcYYlQf$$^D@3j)=y*gV~ z+bQet`^T4D=y!~8hy;`9my$*@#gG|=O7i!PgmfMEZu-k(ST6C~b*HA9k{kQ%WS5=t zTp=Hi?;o}zW2A5UWACp9PuFh$EezH&q@+_7j7}82)cyYWbGsaFSuP!F8a(&a@$AOM zSSyx9D9zB;MkVw~tb@<%$2n?NyYj-$?uxO@+>6C4h_IAr_&#SvWU|A1YK-D+EEwqV ze2P&nAw?iT$P^`aXv$I5j`V<4*=5GjiCw>wjkZ+UGQ3sZmpvfu9x1b{n(AbZ!8O7Q zIs*41KleFJMiQJ)PDQBwb7s{y84=vJf@z*5Y$Y2DnyDQroGfFb?_m9q8TzJfp{aO9 zmNRcjxy_pjSz{1KpNF(tC%Sx!U4Leys|e8&hc9Uv!Qc3L$bvKdc}Kg2{G*yztuUx7 z<*xd%QJDG@D;9!*!+5u5QCWA@J5vw#`Y=ru30zce_h~hIWUYmr1rl5tn8WnN%`^7v z?*++JE$7bP>3`K%rti?hXfErKCijEWCW$j_#EmIG*3W;CcBkK82(kxVaCaYG!C%S6 z!b%ET0C+fCAhCGf80&~v8l`A_STSj+V~7!oYvMeNAL+)Wax9QKShkJXeFjYS>C9_# zKf@tb!*iFt7<)g)y%07EM5})2KnW-4G}>O=%`{+=jF1c&KLdo@j`8Sw+EYdKe~ec# z%BY*)n&Q_77+0UsJrGqaz?5{fuq8=y{R4E6qP;}!fGn9TZc}g?jHBTGg4nDG+tF-i zF&dlpX*xXI!H|HvI(~xbk18I6rbrTOIVaf2xYO9*p4=gzGo*%m#F8$q@z^kScEQWh zW<#~>HILV}s^P6+DGNt+`Nm2hIZ(Is5;QmW$>e#lqSCM{ZdjJ=q$plLYhP|GZvFk( z;SLx=(-vBpWlCiZaDKHD_qg8Tr`Sq!N$0h1NtR_Pxjcw6)FOfNj#py|gJb@?bp*To z(umR^bOOjZ(^*p*5A`Wmr+vRck^~{TzgJNcx=C;7LzcSJeiPrWgKRX+RZoSab;id- z@r4HGk-cJR@n&~Wp>^K^K{sfdwn8wWa|6$I2-a;o%M+ez$R$zR4FgNvu;yl=(Y%w^ z*wYm0>M8t$VsL_L>8Q5Ez>zpLm|zhOkHq83+t4h}TN|-2{8f>MeD38@7RGhv$+ZZs z6qKnkhu_YTPOHAdbNu1?y|7gf!3eprjIL)+0sGanu>DX1J=ykn_(z<_fH;I#wk|h& z2$6}(0O}~wFT#YVFZMv8^GKb+ZA%XglexFC>2N_EZwgei;GYw9q`gk`4#zSZPq>or zuU7}&z}~WRmWN`+``Y#MB6dDNR;p`7jIGr_y`xQi9}$(IkxObVJa#HsFsQDX47r8! zrJ)^yHv&k&l<&baZ8y~mAYC!qxQx;O$-~o;qp=s zO7FXin#|ea{W0?FThzko5yV16t_C#vGlLwKNWoYn&{SGf+LnABv?1(C#$9~bdt#YI zJzEF0mPIzQZDHIu;{>L}xHVG@c@9td=%Jr0oI!1;JZ33>tiEFNR`M6KD$b~iXRnt` zWpRi9&%FU!NsOLqKo(&2`X0Ad+PQ>ahP#dl(aTYj`4MOEFd9EM0nY5>N+_wr={(D8 zPG?RD)&3)NC1A>-6U~ddV+~!iJ(NuM#cDiW(qb2atG-JBq^Y_KrrdU35q_Uomz0iy^s*CyTi8+HL|3r0SNpAk9U*Gz&P_Oe)h&2LlpDDOshc9W zQOI$G$UhhyF3sMWNZVk=~Rvf>y_%y zl|(#A+ID_1c2w%0^&XH&7VSY)&fX#iL0(|09yS&ivF{$^Gos#nSMM5Sa-<*Ywc)5~i9!YBk|n&U>wd$Rc#EuP>1c%@495%z z>5bf<9PY;D)TPE&&LOWW1^1|C4v!_<6+G;;>>zv}J)S#(7U1{nkgo25*OWf8LyN$! zKZU-f;6-0EPU1yL59-G}9VkQ%;V&L49Ya01^(D=)(RAHKP;s$sOC{~-Y!{W;z9J;Z z2prUHTb%-sixCKDJG~h}P5SB;&rcaWM76CFbS4=@J>07X15=J}j(2I#@{qp{M$7m) zlnIB~l&pj$K-}+ZE_S~uD<*ne1fSFO3aUxfeM32CeR8Kh)0yh4+j@<;OI~v5l&NR> zwQmbWv#f50B+_etYV3(fm#s?z7k7|DJDsF{e?KR^zQER8WI+uZp&^ ztebqgZ*)qLAir2`{gLf*NJ>6^T)68;0}4N* z+bisN%UYeMkW{1Q#$TPcuJX5;XFf+@r>Axljvx0DS|FDY(uu!L5A3E-%F zZu-}~HZ)rECk;qhrsAe-=y0C^d8>4+p4;1bD;VXG{%L^pVcQC^jq0qR~k zW|gmkGZ$DfV&63-y|YR08%cX+GOh32Y))JT*XduV4Ij?dw^IZX9S{tBMcNt_^iqH*{d{YlB zMFQ%imDP*PGU;bWnv-bUVJr}(@88b$w-6H@k=DZPSZ%Q~WoIBb1?L9D35rJ_EbvDOsU=Os>mLAIOk&<5oIiB#zpZ8?z z#9)4fmm+T>dRP=+$Wgq)2X^&T1gaxN9!tXQ;*($LtyM!|Xolc&NN*1|hL`^KsPHEd zw!-g?poQbVvT#E0J4PGcS;{1k5pA>GVuw0gp~OeROo~v(_-s_9%TyHM><`yfRvy+$ zIA$8pD#lQ)iK2_Sx=Ho~SM8Kqu2r2Yx}l8Ew$$)Tg7A4+cD$I1#M;gA3eo+nAlc&! z`r)oR54o;7g(8gZ$miRai%10;hTWL*;`x~x=FLPAOy*kaP2(qrS`C$etH@AEV7J(po`#_Hcj*a(5Ri;$%R6+bJ`_I5 zIVcwwzIfGbJ{CD=7Te(s=_q+QmF6gP>W*PRH1!{!QPaEgr~*EicsgOb?ek1e?ZSv0 zK0;?T-3Ltw$vDDXJYvlby>Vt`7_b<#4`sAIbqxT{a#_0^&txHkp(XDizCvW!DC*|5J_5CWeXmp>}J zY?mr_iq)p9Gq%PAyDy%}0&5zB9qB3@2k>vX9;7maAX z#hn(BOgbTdcQiyae|B*?tL3I#mMwp>>%=x#KylG19rfR62@#zm+ok3?M|L^)9jgBM z$lO6|rtNa=UyGuw{T!%!SxMubBHd|03U&ICoGELq?~<%lraP&$jz1vc7X=QDs5lU~9FV!(8UuW*J934#(ptbo*_CEP!xyH3gNen97@)rXCr0qtelt z)q2F8s-z?rgEXpjvyj1r`E$=xTFbcE^Cba&fy-Fe^ECk&dkF@fJ#aYDaO@1>IPyU*!wlVw6vR)E@T zAY2dCA3W_Nw%9oWm|85qXiRVhLubxr&sjp?xi&Z^@8vv*mWjUmv-lIMiPAE#xwx@Z z6Do&|MB-JS?}AfH^igbmkIuVr9da-Qg99VcYx||?zUFJuSSyD9dk5Rs_X_7YkyLH` zXR?{k#8}=k@>pKBORdcVu~B-PAx)?Xe(ao;1G_cUX$uwr*T3t9`y!1hSlp?ShX=5Q*ub zy5Bk1fQZvTK%_AdI3ebOhlJ+(YFXD*?W{{K9cNaO-wP&Y zxU&)=rA2Jo`6YTp26ZAnnan;%dfKa{ni7c8LfQ zOSS|9huc=kEZ#%Cy3IV0df?Cv<5y)7hr7@jqcSzqJ#l$p zS>@8sFw=pM=adjAU^Mz$^}VBflsqIxjo*QjCQi6`L9=`?O=f{5vw=e?zm*q0ac0Ff zdW|b3&hU|ZGnLCgwx!(8Ss-=WzPnD$Hii^@H9kZ{g=Fff-t6B=FXrj!LN4g?+w+RH zY^$P6P?jH(=9=OP^9#@H&C+29@!8Rwi|thTyC8X>&M?Xk+Qf0^kkl$Kf(kO*>#lFM zMbM=tJVtmo&@^!|fS-lxu_SqnPowDFYsUWmYx`#K6{lV=6)dCG{Vb^*%_-1zQ5bIR z5gGI3pXr1lnTxVcx&LhxgF!D66J@~j@&Y3hbv(e78jr0t>Dd=lr}XtWm&Ob=ZQS)a zzo#;Thr^ab(+Oh(!7#PoL*?Sl@s-gfz{U`^kZ&fIfoV93|9x|mi82N!-G8Vj6}MJm z5F2Hu(#&{Gfu~Ey4`6AReGzt)$lts9){ml}CEUUOx{UU^R`0MfhK>aJRtVVLL2cV* z|Cy72(!{SVaJ+3_%NYcH*Gl8eJJ06Rys7!$zG*8UQ>}f^jmGY~f6aQ6?9^fcPIf@* z#(ID5m{HW@Y>b!G)3t>qd8M2h#=#qcr2s;=eeLXke0=GblE_E8m%*ho8c}Ahl)l8a zHG_Gb0)TzA;x6h@?55mYjL~wwtlbn-n&5!I{znun1-`YW<1Qsz80hAHtXSwo_Fg?3 zSUt0c2a12WcHR&Eo)sHuaK0H%0?)`U@9a`0`uS8}G4M_D(qzow@VKWO`BJ)d)ij;r zL6L1HXbkNsPdBMI4k9!r_O5aMJSKU@LUBV!(#R9n$jbo_`+8T28DQ5zb9&E;ce;cU z^0oNnAwD|_ZfgMnN5<8Mt;WNC&M08;-cl)e|4e7t%ptLf;=452+HSQ}7#+9oSSJbB z#%~cYk?dNzw3)^g#`G;z&u^p}Mj9Wg#;C0hZD)X<2kz>kC*$So98$)N2GvM{tmCI$ z=qs&ILHcRfYLQMF=kzE>)iZ8p;pUU~iq5!BX5{2D1H?BKdUvgPH+3-M9?Lg#6Y19) zyz)fkPEMnMX3ECRZR-tyF=z_v`R%8iY^Hd<>u7yZjXWGmpF#RIy>!?i#2ef9xU{aY z1U$@x>c{z(#FGhEBhu9 z(hRez-z&0|ii^3!Fkwk8cPlydxk5m71SqOx3YQr;;%0s%&Y+s zB((LIJsYJ#&ah;EDC&9?E!UBxT3Na1RvVBvUHZxxlA1LkS9vp9eyjn9nNu~;nC~hB z3F(l9o_Et&HnX`Esy7i$2w|^Nebp1Bx#d|C4R2pKWgj?$z-w^oI-_v(anGRe|4{Z$ zL81U#n`POyZQHhO+qP}nK4rU3*|u%l)|{S+8!>afUiZ`S93=#pj zPk93csejuuUYI7oaL$7K);NXF$Dz$0@gW{XHN_o)HY26QfMa1|XEw8rHf-aw^qI-3 zEKj+M^F~A-=pwZqqmX*!KnB**22Cj%1tKQl8a0ndt@DKj9};Zt`GYRK=gY{r^dZz|zc;u@&ilHeiT8z@qcHQJs*NLv;c_&fYe~zn^c=35yzj zbn;WHuWeJ3iQJOsq<<=OE7Oe3QVmN>V%($%Lhl``k%q(oCJSc!CpvQ-QqaBDxCQ$UDPQ2;~) z0cA}D64C+zff5pul$2y;0LyR1>?hCf>35HF&+S#tb&sF=mikxir_5edWc%MN>J8A^ zSh4*fLL>vxg0R9&90ZuOB!FO2Kp-GAh#dAWcqoMWAme%n7O8vxb5;fiinstvAx98q zVHT+J(^J?G2|&WeCA^w-I(63L07iLFf?3!9t33{4s^P8!UqOm++(R!a5LO{K(-zt*SDC z3PV1AD&e39349zhAZZ3Z)k6#P4IyM#gxakN5+yjG!a=_#+~@dDdc&a`Sy`GGSJ1z8?{=wN zU0nze=;yVvwq#)dmBF0Q+~nwf4T8(`R#9awF>nweube$ ziMoP+7LeaA!igPr5oFf@mi)7|27jxo2)9u8!@uln=-{N*09jKyUw36i3|bHa9n_IQ z;7;ztsr(%#^`TE<1^Q*@G=}QHK`Gz>gMX#P*Qhek_vibN-rlr9$!Vs0>z0K2=W2Uf zrIp0cAchSJ1OWyjAd_Ga;0db>sd?_$g98a5QLw}v0Ffr3K|2Z=1N0wLLIDIF^!bHW zA@A%(v;ZN9cvODJlmrsu+wfoP0}`Mh&;x!(1@IuC!i;|aex=|}!ut`_9@#x1GJnN? zzTx`z10667oN!<}-8LVWui3# zcHF|`qqT&*E0uZ5-kv|KqB6oz7Do;fkjqS(_DjV2h7c|{`^zq^RCUwK{|?itqzlXW z3Re?#NnA#1KmB7K-$&;%51H^lT&_S>9TTOy;_>vEbiE17Wqg#M1b(wj{d`3pDg?8~ z;~3oZoN`}CB@l~p1m9;nKM=|@dz|rljT8hfhj}W5J9cspKl>VYr{-u$Yie+QaNIA_ z#ojWv;dKYg>Wfcndr_@)*;3|KTzNj-m}1I z*nS*!3JSFxx~kHcu1k{g9DZxs(_AsxLrIzTS{O`mv59hUliFU!wK7i4K5x3eSU=Bmcf&4LWb=@yn{Gok3Q7mZp53 zU*Nd?dqMjxuvD#+23|Xh!ag<)iiNMvIw27t>)@k3*qn4L9j}SGFkhyE{*_Y`7PkW= z11U?VVVVh*9;AD?go4TWoZ)4dKdwSzH<7~BX@PpeDzJvX+EB>-7ow9pY{Onfeu>!g z?PDl4E^J%rL*}EnIgf~BPh$Zj zsoAQ=7`fK^#OL8zSp5~fa6MP{$PGAL8yI{Tl+3Q_Gs(d1H1qE&8rYaF!u=1r^2sL{ z{Enme0@$TIhMrK*(K)@3W=4xMlOXBEUp4ldI<;r8fRzjGMaUz{$J3p)X3rYzalSujwuGsrNQlMYCuooIBQCla2n*?P~;!@(0?iHCBs9|MElpf zJ25P13Y7s<2WadIsyEhZ?*qP@3mcgEThyne)kw3Gw1qHB8(TmRx4vF3@vM~kB2eFE zJqL=#*X0x#^j0K}E?UStB|I3|)a5DI_Z`~mw;7$ldnb2%V!`N_!BN#ysWBl6`z3KH z&2ptY)GLz3uVU9RJCZ;VdROP+ksu;02hvqDv1G~=hh44EKeGJ7m-0!Z`;=cAud4UF1Lk0P$@}4bF$LFpX za1UvnJuW>rHfr(DHbvT=$h(F=W1QnViFuD-_YD?>!fgD_lVWosgOB?uaG_W_Cm0`9^IA(Yu4t-aFa*W)ri;P^H#_+<*4jyTha*fKi z!TxgQg1IF{o7A;#L^#_SqaEtO72{F(QwO0r$X_) z)3{7b*=b8G9R>o$YrALFkY&wQA-pr2fo5zA_g_$)ufA-ZXI#jVlst-+9{ z%)d`*3gQy<*7m=;k2-v36K7jbi*6qxj-vy5K~?{&8?#tu?}u!*)p7p?J6xUxJD#%Q zbvQWlc#xlV!@1gR zi)+=yLhizQj8U={o(XtrQ)A8MoT^Rfvmx`(X=$qLi(91#V(oe8OXrEgl!mQBx2=Yq zAZzEQitOTCM&EE=d9XoVH#b+9bE)AUsaM&LR#x!t$et@K2CX-j&7S9Z?X9x?2-l$L z3_iuJEYb%VO>LS?RUB?0xD@l#5ytA5^+^hkFwQ zbnHR=w&y}IF(+1u{AxS!d$Uo++TMpFDYU<(VB1|+Rwbi#T8NFluTIJ=+CVL1t4K2^Qw0II zE6QMESl>7w{nWdUqi21nRhLTO#XUbJ=SUlKm15IBZWTV>qd` zOkE?FY}@$+ie`TJE{3EJs9q9(J|4wT;goep>j=No!PPY}d~pKR0whGv@~ERxWF+oW0X6qvD=WqZkF3^sW!x_Z&ED7Qhp*_L&bx6txV-<{=|a zdn-Yi^~jE~#^TG4EZ;igOF8*AX9$JbO4_7}1KPJeIhKT_aJuT6?HK0ER&qaLp?KB$ z#(@-|9g8-~|Fw-QhVvxdiX2!eo?0f)(><5}-HFdl^cN=Os(<6mVxvX9FSm1&Rj%zx zSA8tLuRj3aU5M^JS8HBrD1`I?xl)dz^7dDsa2` zX1(72el#=sp+CA=ux>{Xb)#ip8?UEuyrFbA!7EiZxpIj$Z@@vh)3teGFlSP(+E7Tl z${~y|V!>0sFFk$EMJ&Q!`Le>nZ8|+|5vRIFnPA?|omQ6;Ryng-Lh=S-qbiFqv2a# zdraKiC$RR=B>8;2um54{9r5T+&jZW~zCsAi#q$-n<_vZ=D$IhX)nivXX4Gw4V`CA3 ztlmD7OL3oA4MVSESY+9b3;XN-Z!K2e-{IY@aD_g$^2MWn0@YUWR;6|rUl#`!$Be0d zQ6t{rU5b5_At7UkPG{=W9gJS%n@7BX%8550P;v)#Le$TXljY{-S=(*7j?iV+4PFWN z$Z8Q?vC3UeIbHiK1;ga{P!!2F}rkKJbn{wl*AE|aWMwEq=X8< zwxRB`aa@;@;Ai z_c8tgo4+Pm9kNUvx1(poBTj{K`{wVrM`8DkOYyK9b#9HS-PAl1&f@p>Mq0=}2}Xk8^3CT#;p)mas8|dzHnn%#TZJ? zX7NKNBKUj(zgUkSOG@Nn+tY)LX={LGD(l!;U;gd`5?lKzMjn}kef`z!t1WC*N!_S zF`SltL{Twsx;_g7{BK=7cIS=YCzrBx-G$vf&Kjg^-;rx+wD+R32^x<2dV=Jaonvm% zM1t=ldihIbKLR#Zj1d$h32fe_>1zWATho z+tLPh`Q)?dYg8|+u;JIzF{Jw3TC%63%XFh)gPP$~XMEf`cgSh3^{=!Bl35lPN@epH zGJ6`Fot?|pJ&_p5Sx~0d@kX*6;xN8BA+t4a&3pHc`F_tfn~}=x^^(!9 zgUAnhqg+uOJN*A@fp%On+Wuy`X6M6tF3${71RY?Bs?zGWWW`l?NYToxvqzlc+<1f@ zTOpp0*IMK#pN|-DZ5L}HJ8s4nwbDjwKkWv>=I)uQTqfa^G&&=-%@ssL<&k9 zE)EN#Aj2<=a`m9DfWcQ}VAUA!+=FGEcU$SYMUY0!@^$RLF@K=mH;;VaOB7`{J_B00_z(@5 z@Wi&)qkWxJzd|MS4f4EdBi)flt$Qjj4nzM_7&p)n@A&WIGJfHX&xs+@O+~v1mDh3e zU{!!4^-WCS!DJRFopO%4&p+dNx0gI`nb7JYwQ!-gjIxY&NBPwJj3ohOC%K|$3WS9 z*kiGXoH8?XU~(#)j>>nGf)nJClVHpma8LD}$v&nYBn?G}S-n#3>^b4evi8SC0W8bU z=Y{o1w~3Bs!inWF;X?NN|v+&u1S@hmRBf{!l$~e;E*Nbh33RBpCt^l?SB?&DO&?}kQZ)~i)tuW z6+SeZpj^QaZKohniD-^zU=LmiSoVwPB{zG@%Q;__~9Dp!=Jh!yrpuSy{5T&VyT2Kj4t$Wi9?UTF9R~C~zrMVX0y9cAEn-fre z&xXq>B_*OAh+JRJb8%M5G?^edufgbJP3LeBO@!n}Se-L*^GX))nQkJOC)gW_YWQ-@ z^TzlWf~;Fz**43)9au${dn5y%Xhm6c1}%l#gEM!{y5;6z<&`snCm6fGCT7lP z!zQY!5L1;=tX5J$G7A;pOLg@o4VtJsrN0k&cHy11|r_ zG@SBDFcDs@7fo&t@zz9fL-8BEZ!|9^v@VuV8xo3T@y#yM{-rg!2I;|t-!2GZ%yHT0 znd||VJ~okE*9VE>F)0TM#QqD7Iz_iV<&#an%m|hhTq7wTmu^djd_J4gQVwRcc{NTFiB`nvIZaC0t&<1G(FUU*k%C+_A6x=8Asi`_rV>3%$r z6DhFbO6V{G(G|K1+{A`ms?2s>MBDdCXd1AoyDoum+6zZ%p0vBwU9Rw5BWsrP+Ju$p zq_htD}<^IM+R^eef@a^o{)%j1RwT76cJ7%9i`DF@o zFelJ1qpS=4JM8m2hZ|d!+1)!RjBdJ~iy=a10171Sqvwv_Cf$+@Y4Gn9`Ell#q=UUs~lTLmd3 zzd(w|wo~cQzaMum=>T(xU&SsXk1om4u@0u+(*rA0OtaFx0VC9wYri*||L?v}Z%VZX zOq2V2Ih6L$j7iEMFH#ocLG1;;`k^r)|HY>(=@cyURc!J;ecO7%(pk7_jy{|Edyjtx z+oZ3@W%-i$!AUypWV%nDq0bW)fi|J2Quuv?Cg#r{c}E{#ZCeGubzlr{Ye2QH`MZ%o zSos-_DT;^rit5sYg0E^UJiNhq2Bhot-C<%GtB) z``%}~2vn_`SLZQFECzp^s{Fm3Vm3|R1O9y-mf9dCs#!o9Aiq7fQ3npwmrPY-_e4NN z7a<$|*Ma=O@ia6rykj%A3>N`qcXE!({hFe)eRDi%r_zeJb)u%Q@iBjJw7iwhibv00 ze@9j3_6w(tyM4Ig;jH1F1A|&bGW2246(~h%?Z_LbN>9aDo+}Y)*Fy&l_nb1s=ZayZ zX$9LL&*fFEYn169ARjXs7?+*_!*g%fCw);B<-=(4xT_H~x4xyj0@YM|Yx9~VgH1Xv8lV`pU+(QIB>lLCWkKEj&b?VBI4rBZ{?c9isBMFynrF)7K*$& z{a`=H!d~T2yPn#`jNutSPh(%chT+pOJ;*LM$^fL_wnQsJk?bj;#qD$uDec(ipg)bl zVK}arKs(#$Xk>*_V?`ZuIAQ$s=M;nox3DpJH*?|^_wPL4aoPHGJ9u9Y5mWv?MVbW% z#aFwRR&xYW1C0*O0B7aRiP2vOP*Ee|-{1%~)~=HM8>FKw%9+@M%8(bL7hCJX_Db>k zy?+1H4gkJG%cUV`RD6rX|IVG;o#u{;m@i~MV;*NcS>n?3jxT#EY4u+yE9ZZutPD*5 z;i~`3vE*d=&-6biDgT0WTKB0IguZ`2PL8`Q6dFtuc6OY-T}Ja0TKX zV9{qN0ca?g03)C}tAPao6bTh1KqR80Q>su5egrQyWC|zvCa}+t`8!fYL|{MyrVLEX zXy)aBA+Wg$Oh5yLkd}a$mI4?EKtz!6)C;o@ff<0c27duEhYVsdXo!GMM5p>!odD?K zAZjS*p^g;bYz!D7EiLWn_Zm*&C4`_L&HzIIKE@@~!${5r#2Y|nFHQl1=?iweB}{w3s#P9`A&+Ta4}`5idB zFE{bW00blekf$IHAp?G-AN>SG5P-oPSf<$p5KIqY4c~a1AM7ijw-$_mhT`l0!>k~o z-)>;sTm!t_ef0tqQ=oe=&jA21EH0plfD(QH7$;AY2v_^Sqi@0AeG2gPz$1I^2L=IQ zjfem-6}NR4J~)U9^u_T7@Jom4p+da_26URZC&f^&Pa%B?d?LLM%E3egaT(h1C?DHu z?igG6XkX^nFrl2Bzf}F>tI}gIV9zh178T#7fq@Y}BRT{U0UQt@NhxT60$qR!0OIO} z`u(!N-2}ao`}z!IzjFrkf6@Cem4Qf5E@1k75J5i!z6k(G2GEhPzIG%1Zz4iM0p%3L zN%{Z}fI<7$j7H2qHB@ewd>OF+SAM3VMB83}zexp7Ko?+n(w| zzJD(G?&|vY0Kb^i_;CJcKmfe8_1y*!3C3mc5B%C^{$s7XOW)KJzl3+cQ{scGgNN+U zU!uS8XjhQW5MR-wXUpi3^F4St%z*X3EG+?FnCiR{$V;n_{F<~R7|g&E4CwLx`b10O zz*qo|Od&+Ly1x>~@OCfOeLMvW5rkXdAD4oF5D>uvzx{@#6Z5!_7Hh@9b1x=pSY2y?g#9`)AR831hod{l#x}-?xF`0zd?D zB9Hj{agB<0u8Ov0tP?RmK;?|@lyoV>$asN!o+6#M@=9Mac^6#~s6+0@Q-ydB!>+Cb zT9$#&Ode$=fcz)69g3HpW1+g0_aK$27B|4xo%cz&#~*%XLS%r-C9w(8w+N38?pJBq zxf?pOUA`p}u=&clAFq~RORwsFSdl*wOdI8CbA&zRIVciL(p~s^eAB8&3H-vdap5Qi zWP2q%Fa+6R{`o~TIK5`ea>v9_+pR^^UB)fH_k_9i{TZ<9?j0!z3f?kf5V z*7_`pn}lny7M0r9NaYDFMK=g1b+|KB(zd(Pow?hMnP|o2mvw;5NjB&IwuTPA#M5ua zT@oYEP}3|v@nh1iO8Dj%3SG6i-OcL%7IZFkbW@+*lyUJG8Mcw=Wvkpgj1NHN+TL&P z9rPE$X2W^+8Qk{iY=I28t9y5_C@LDe2pXNraR2MGx(Nev8&8a~y$@mjr`RXPse~`l zTgs5t-3M7bI--PVZK<>MUFU~$!RR-2;y#Cz(Jm0H3)fJhb67Oibh9Zbx|z5Qy?Kkz zR;0Aj+`pbw^ftk^HC9)^kJ?qfnQC8>*u2L(6?*2*{6&Z`NZgdG%mi&m`}v z{CRP9H;52Xab@Bo-l3_=je?Y)_J6x_pw>Nev_BE?*{Cv-wAqD0PP|0!T`6g}(@g?z zzz!U{9psX`x>cO9QF}j(M*(fyg@H-Ai7$}l#m=wN@v_46?ibS4TEbP?)M4#enQl_Pv+INC1c!?6w%Em{ym*s3@&m-}fS>GDjIu&VteLkos8x#jZNu&k!~iS;LzMIR;9l zr+@v5(m4tl(f!odVqJwZHT(Me`m(1D>XI)#JE2-I{ilUMhwW#0gtQQ5caV%MFnht? zM|e?+up(9~@b96Xvb_&SW^yiDCb;=?YzUu>WN(r&6-jP0|5=ZzIsWsKvYX)4E8|)s z9y!2$R*iF{fO@D%OVxD)J+~zcXm{L(TO%PSk9E=XJ&nZ7_R=3_$wWf?>9A{`^Ybh6 z(9*Qy=YQ%}aXY&rog(J2a{Sg2YDS3lAX76>iGSmIzP2NJCaU6GhQ>wdZc|X^{ z`b-@O!88+SpQ&wa(Nyi;ycnZ_^zONCqAZ&1X@zE%$MdAr`!`aiWDaH^dW`g+Hm3P#KTW znNw={rj0yTZ@8KT%-z@37h)Xtmk&MX5Fow?K7hZI2jb9E>Z!~Ny{YbOu ziw>6hUjLJO#BQ(LxTm9VrfSw%fr2a;kI#?pUO$A>iPl+I7nBJ;Zh}d}{#0O4b@$lk zWqQx{Q+>e; zPT7g3GY!Swb`PKmyQuCvjCN%^;3xCGwSIo$B2`GGgo$>1Ji7}=n7=Q@jr{ko&fd3% z-so#4sm_Aoi-{Z|9BjQ9d_AOAMF$NfdY-S>FjvqBUt;nLwz(p(97nrU{9_YIpDWoA zACJma7kEQS9-MTc>A5ohnNq~0NAM{mYgQ4y8pT|9?bxJg`xk#~xS5J}oDS9W zb!cluR&~;+(dhJE-mRu@Mun)jy_(k?(|yF4UZ`s-GNnl+F%)`cG|lwKp#%x!dhqjm--smM%6n)=1M;gbHN^Ay6* z$;mm**Bphi#M8$I#$To#rWKiU6@99Yn@&dVo>Lj#EqV`X1sj2Wza zMn&is0^i1Atuntdbx6FdKz_@9d{s^FnK0B}Fy*K%XWOX#Lg=*)|-OP-9<70%P^ZrTU*TTi#}(3x{8p|e_%ei;1i{e7Ue?gZn8hR?L-Sb^Rvl+FYNS15r=Pu6ELF=?1(I;LMWZ4;e*rvw z{#PvJlH_yY{vwstFZb~qQo%OKw69OCw>-pHQ=~+x!_Qqb|BK}hO+pf(-Qv*Aui@ts z9q8zbY2E(Ds8brw&AJVzfkC(3jItd1R8`Lp`7~>>Ad3!Ci&)x6iPjq@>CPe1eSUS0 zY;?T9Mi@;M^H(d%p2@h2I(!;r!gcD7DJ)qll{9lv{$m@b!cPmPtR>QKs?ZgGaC0)1P#Wf1+xb>8?eSj;| zr(&%5-wM#gtgh}T0_JuA(N@O1F|?C4<=2WO8wPV=)%Po?i{nUBiw&ijBe(MCusgLH z!jmZur1MpWQ#--ztw`FXs}vBa*yreyp*-tb zXY)K5dUlzZ=d2aL-2q=(ziL}Pbux6 zW_VWd`LO#K&=Fn?9d09025JX(+4Kn>sP0}SZ@uysnNZ+$d9qC#o9JHVG_}GG5)%M^ zbW7Y3!J`o7kdUSvrtp|DI!aD-{`g5m_()VLWhQ6txefhqURW z7~kTq962O$Wt!Kcc?}$ekbTsm&3TQjE&7vqylgU%>6ZBTBw8lI$egRJNFFTa$Oq?F zBO)=f7P-^PCl}i1`;HqpOPGCMx5TB1ep}hq<;6X)z(PZ^^k@o+8hFXH|9%f6K3^O! zcQ_T0sMC#2#<|?vW!;*DW1rS@&C~nj(<+;rawXh%Y(2ZMvJ-a}YS~#f|M%F6bYu^= zbbS#OL--ZrHs*^GZROOeH+2d%ak6jjaiz%pSf@WlAF7+j63?R``UK)Y9QUF|?oVVkiA2zz!B;IixBnAGv+xt99m z6Gy6e&nbO$4Lv92z&NM&E%C4sUy~O<3$$ww(sLu8iSE&f?5Jf4W2Q@5bop4=OPe4m zB9+~!>5qOMf3PwPy9K!D1>W(V-`G(ZMwM+P9*9=E`Ki%Bk4?u?#SUXG-$mDu)BN2K zQ+CF9h}*6nS3Hk*Vb2gaH2;3u>T|^(o!`$WPSKXgyL061i>6yn3LzD8+nJV$fKnpc zToi9$Zw*iQm`dNRFIZe0`#$OC-%NjRY&2k>Nn+J2K;l&_Q#o5{0zH&vYImjtN8U80cmTq z)=^G!2c;M(fUnG-`Z!6UurKeYI9lsuZ=gfVpE)c6as|WrN6Qk=L~loTB7pD>2)?qa z?F#)+Gv6cF(o(iE)2B}@(YySQ>wV^rPP68)l<*sIspPe#o-cC3%{?F|sbQ?g3{>-o zy#78lQ>iJyLG6MNMmuAq(UpuF393mK$K<7pvBT`sdU$d>vOoP>lP84x zp}cTBzBbj3#{0D!IV>Kq2z-3gUA9ky0+CK&y? zhDls$M|5k*7LQE&e4C_&XC&5Us7Jbce{yrArnqlZmqS%}y(_EIff5N&D!D@YMOS`U z#+wo`m>xJxbOl4Zje8V>1G5WBX$bdtOpw4{-%NU6B#(ykia4hHo<4S`X`^LM|S zKNs_o6XD0jvb|{@Z-}{(d&c@gvMpInd!q9w^SGha(@$ zdp?KqrElZ;Y;&d%lkM}<3|66q$k5k(lvYj}=4EFGg+oXmtoj=(p;c|!W7nEDC@0S? zVy6}#tl;uT{vg#{&{5zXilUj}WhaWKPmRSPmXnydCs}deSWc;!mrCV^%^2@%g_UwvH9~Ns^z2AT>>^^$dNQh1`5$W`8Eqi_u zik6BXw@p-dEqf!52esSW5fX>TnE+Y;JiW};1&`QOc-|0Av_nzYl}c=Ol+?kD2qHhs zpg3x4@|4lpO-P@+0~z6{z~mlPu1edIC%>1ijd?|XnJMHs4{g{~v~)SCwg{2AY6SCY zJa`c=6uxHE@MA{TeygDEFUGrU82(d6qX-5b$LZP{1u|eo8Wz^o8T&j+3uoar{vcY>LUw{}MDc+ucZNX{QC2eT&lU z`w1dqWTqp2wqQxEY1Sb)0^L~CfhQC^8ERRXBDH05eP8kV zNoLdWfJ>tmwU&2DpYAoi7~uUXXgNb^i$^J4zd}jm+Cq{9M*me;36c3H%h(KR>8Tcx zGtTEe9lJumff%=fu!ll)hq*7qjm85Zc1xOuI(hYef__MC~ zP5O9ervaii#Uq-`IL_B+eXBS960-sHsL0k!LZ@L9Z-nTHXeYg+U0{#sTBFhVbxb2gM{S)zPm18jaE_#NtnH4K z3jX?pJA}A-6DL{5Fq1P@FkJGO)!6ogG&fcz7VUCPg{wPQfd6YLk*9<4Q;;EP-T2wC+bhfLu?_B17VGfAp~*j1flN5S_9Yr zDt_kvs`bOMO%-!)I6v>IZT`+o1(+r;OOq%QqL}?s;^|;5D0b1-qlCQoRrC2mY@@Xg z<;XeP8}LNwRvd1_(IM5>tW4Dir?IKwU+P!@hv|%#G7)iVURy)^T)|8QG%5YOqxnX{A0cN{R#et3w>xjJc~V!cKT(_a7TU3sH|e;bjr%~vZ@bZkgALXkxrcpR2+#OE@6=#f zfMA!1EXb|QYDgcVtRjN{ODh{coeWpCP-hNNRrGFicu(rAFV4Ti`+i-~bdsJbQ86N(7BA8&^bdk8o{QUb!^Kh&7u9@sHRzy=YJ20MXx5wwG71PqQrK*&Hb z@rqCQ_m;azp*BfKXlG|9h>Z>}NWvW)6VESz9p)HfF5F9CySuG+!egQ9UPs#Q z014!qdJF$nKhPjzcZLlCVqth0Y#&M`NjKfAC}@k|}#iIJN43MG+_P61>h_)gtV ziou-%#P_C0$Uo~cM!<{s>sN1m5W(%GccT8$1(ivtZ;PkUO3I(ZBI0g00~iGq0Z=L; zDk=a#fgNB8{D9)g8dz9g{mlN*9z$2SpqF|9)gYb@7z?5)yoev-o7bkR03fB4oMrBp zANE%VF-QP_8v_KiK9s8uA>=nMF0Amyzh?g1J^USjCcxr75TH-L&YxGa2-PfHq|f(P z_IKNeP?VWf)fTyjpY(UKyddBS@C_P58UTbuBoF`rf&>Zy85t1dhdHhm_DUY_cfTsE zUL1(zM+)6n&cE#HSsZxFA1nm?ZdPMMqS>hs;Km>Nn@|A+La;aRXV&TW`r%jky^i9y zYVMbt7*(F*t1b7Fe&E-*%`vdw_m^RA;#s7yOaMAE4|K?1S+>AGwiay(?&SPoSB*6V z)(h(h5zaysI^YHp==M8wkVnOUPk~z(1M1){-Rfr`)^8dcCoJHCh}WRk4xF@{#PZd8EkslVknQG%ttaG6?~ghWfIos4)pY@1?=TDk zk_dsK1v)^-h(G}ELhhZqaX$bdHoVI;1H8ElK8`=8{~j-VA1H79x5|2(aoh}eo`_=Rz3eA0%cH$=(GDv9%IYS@{LmbN7tyKLDg)s zI~_jhQE5O3EpzeyfiQkPWyHlmrmpyvY+CJ&IRM2uCxz>BeY0ln3Xk~B1GJwn8$cDC zsibg@ZClU3h2B^$p+Y}KPr_KbQ z-kh$9rM3)JCkR{bmE2vV6D7J1!vrreh@%9tXJ(t!yx(>ezfzm*LzT-JdWH{*NUG0tC38;d5IRf6!wjWu3l6?eZbf2+<(Ilk#P~(d!Hosx`fBO zv(?OOXQT-E*K#11wWCeTA7f2Q&nBITOUt&R%D32!wp)*8+oijt7U3O#AP-Ual2KaZ z*)_DXbRmg8A3)N}^JiN)GgzEgmF=t4nzxk766En3#OyAmnM{e3w`gobIM;F8txBQ0 z=p>oBEhhK$3*6fKrxM))__tUIaBT9N5A|)pch+B>DMrf2fJlEqyNPaPywjwc=_5&_ z!6%(+8e=29B?3)ptX-3ZG7P#;1c09EG ze@!eVr|WHmUSLCFo&RE9f3c2IjPafkMZk^CT5?3cguL|XlE`QxH+^Xs+WtA7qfFeK z@<2q%6t(viPNkIpTAOf=Q=6vx#rH(aER^d=zg9b_yVB02xc!$gi89Gm^VCE?Mr<#T z$|O@S%%L)J0htYF{9dN8-NS>-e_NrBg0fmVfV3m>g+s~u;F%Fb5=5w#QhDT6-Mhm) zxv2O-|0|cIb|f8pGk;@``f+kxMP(9mJq7CP!_uL-M`%4$;(5{4tZTyaWPB2uMH-~Z zRg23ieZ$Ld0)F@Fhi!7V^jxYqUK5}e5RfH@a9o$X?jfakILv~QXyJc94^jI zRX-LA0K?|VYLk?uAS*8yo8BfCKICOx?)7sWS;JGV_YV$u!0Rr;nq_s!?h5W&KV(33ctaF_vLpF<8NTI<>{T;E+@`j`nx(aKkJ zPrq7{i0|Rjnh}u6ag!&YSZmlDFRSb$|5>+d^s8wp6)5+*&fON&`)LY+c`rJkA$D=F zTRS*;RjcS>Ee_-u>%kvow0#Xm$NU5NCFv}MA}F$rwAi%~|5CQ1fwE(0dXVUoKD$LW zb4Kr`ie`IH4Z?c*`*6E`JFKm;Z?1=h+mN)oUl43Kxvz8A3G%K#9H0CL2;Lr2c(!|^ zs$0D5tsKOd)~C=CSJCx!1pj>vo3iXya%_V5>@!;yZYky_M!u*6KAQ47_=S zV#f%tn_S@22DZHWZWBq`&i20NMa9>G_L9@r`6!FEGeqrU=DBrEm%`oc=RN3(2pVPx z0YA>6#;6ox2V=LiOu@obDZ@vTJ+$pfX&Lu)3Y-9s@jH?PLwnF<&ya#U-txd)LfIv+ zfu=evkZAPIS=!s4Aiqpy^mcS&je(u8xNc+J^xSC`D@XgIJm`=?chYk5V6f_STN}xj z12+$*2vt2W_){@%OBt+@*kLk3ru$11=^^MAx#^#Ss6?4okxz`16nwjq0c7rsZ zw!)6i5TjzA7M_melfoPhG>+p!A+^6iu1l`7!%iN{mDWfI)OA2Go#Y|(h|r-&is-G` zhA3_t0W$LsEozm?x}Q-6!aHZZoY)heaI5k3KF3He^87DiBflD#S`ZJSJl6dEs?&S? ze&!r>V<8D7YIanNFVk+9wtTTA&eQw#%*;v&G$ZP^S@wEj&_DV3nrlTz@sbzlo-~G0 zf=}5s^)ujz=^=M_yoz+9-oR2rNsZ_wV|w>ker7amv>W5(oUH&BsHmK(Dskf+J`h#( zBW41B-~Wmh>C;y=wvF`2ZZ=gi&wUQ=q4PS5cIR6Sw1o7xp~WgbfWEr&AdTj>V=(I_ zy0iyTN}bg|bS)~YtZJa_Tt?PDQ>^QR-EuIy9D*?pT_HbMQhP)&>}ZE_D~{K0X)_9D zbtHEiP-V%yrW-&m`65*0vQ)?^`N;e(;S5j!=Z+J-D~0uQ!0zP2E5zte8y%q2_6k2P z%6XQM-~kW!y$@ZFstwJ#JoM!r8&BVRaE=Wm5|-6T*u=*(tgw0}^> zq{T?d+G$&v2rzB>}%sm?Y`w{&<>=$Gj}Wemf(yd+Wx1O2+{; zJ!}}i5<{LGx@MY?TMlwaYYM!)BKz58Ygs8F-iuaD1`Nr_AN7z!ac*UKcs-)7pjheJ z!Xk?k7t>VLsg>Tc9*r=Gr;y0w`Rko;?sYCsp~Bo3Zjz z+tjA%Ce~FAY!}krZU15XJiOU7%*?{g~6ksau`^UA2Zk+e>VZBy1-U?tFCa}SSLw57U<3x#HnZ{eD% z(iD4`|EHS>)`EfJ*ULDiBf_#2Mz()=N;30bZ;Tcx6KsjSuHZ3)#M+&XL$5csy`PJB zKFL*KmPe#-U+kfoc|#;Uu80s z7TlVBqp1V~IMt{grzV>sf!shT)1|0yW0cg_z~W{aVq2#*;;;Z!_3Z3*>YJ-oMME6HYmMlh)dUwxgDlgDoS2-Se_pnEM`QoX zzr4~5pV^3kR^6(6G)LZ^74OgF1%{a#ZBr?ntM(CO>vAhJugzfHz;dYM-2O9n&Q|B zKhZ5Ohthjp+t@8}9I4+`7~_+g+%M@*A^zETReUz)ui8*6-gD+VM{p_X@U#lb(r{c@ z(U6{V>wQh^63PpHFgbH+I}J&|!tUcV1FFv%B-~BWO&B=cS^@AFU*}G}$!HRko4ndn zqaIhco1*IAg^rzcDuiX^R}rBi?hFM?uc{q%tEl*9tzC}>Yxmhlzte4I6QuN~6?rGN zU%Bd=-rCYtIrSZk+3Pm*QB5VT??MhQ$Qsy1qD$LF3tI|nOZ*|DMNK}1w@PgUvGV(p zvZe`&I%++W>P6DJt#C09;}X4>vzAS^BBq#gP(4DxK6gRExL;J;FgyitT4nXQGu@(4Da{aV=RiS`90qHExAL zs1I>4mfvcnH;}Cmw{s??WBMW6p3d+;HPtYg%4e6|dSCs&6bg9&X)Gvql;?(`3?H4X z^-VqvGn9+Ux-j1);nrmr!&WwBXEYMV8^iqiR%W0y+L_cS5f;qv}wSmnCfM1c)7YXD7~i3Faz7L z)Qhr5D8dC2jB~uIKgBFKx3oEOqzuwM&&P&eixe+EJ%VCpb?R&53oGg)V=;}qmxj1P z6;#%RVu3CK8MHdn%)M_|p3DaVT&)Kgmy{Pf@y2oV)L({t5-w9MA5^P~chrhG@PPpi zpabPQ2?U6bMMg(236o;IXU8SVge-5MIE0r^#4}sOVhlN@?v~}`T+j7n2kM%LC01po$ zjEC<0bB^1N0`N}D$8y25LQp=<&=CgTO~aYQKt55nn-kW>uRdj6c@KV$A+|4Wf&VDb zCG;dg8{_drd6uC(fijL#b^OUzrgFtaY!x!kwvAWAUBd@!an|WBYPN|=lB4F>y>sEx zPZ~MRk1&=Y+>6T)-y7a%MkC6UOnkLqB=;%J?_K)ZgZE!_JjPOKd(wb{=_NYCWfnM zmC>sB7k7t8<{F~V-|*{sBHS#!h)_h`yzbMh^NsluI+tU2qv&Q~n32|Kp1#SW*cVeC zuchIvVjcT#kr`1nk8>h?$#sp&H~5$H38C;F0EvQL3L4ovD`k_dMNE zZG*6fco1TwdBkDo|DvwS=t3$4_@ZC zaxOYgwWm$IVzV?-8%$fpc|q3nxm+u2+=B1qbz@E89u1Rj3NXB?E@{XfuZk{~qkPpa z$5ZSrO3FiOy$QuqSn1slLPcl!itUgachWDp7nsxv@W3Lsqn|jde2~}@;v42*s=Xlz zvbwMBIDv}_wJPm4qp~ZBrapnzC$sqSa7pG6(cpSo@^crWU1)}7Sc>v(k2M7%!#S1f zer39*5QEI*p!s+Fr}ZW7zJgCNN&5aT8Q`X6*0yt|l-{4QQ%Hp*YMO zgJ&+6mf6AE@{syHy-oyeDb?97@`hgHJqCEpRpWj%M-q18V>Ezr?8ds{C_*2mbd{Ta zwAHDXMJ!R7S!+=ng1fJB+Z7H}`|#P^$9{$Gz@L%}PcLtO$yM66-8fjLrw629u?P=kK3(^~`D>cQQCc8mJ z=lUd#iEkE|E&Z@coqk-XPVnkt_u^ayC9W!vNqRP;pZ>l43=V>rF7C!Y*J6lvZscT_ zK25QUbALY)g&Vf0rmVvhcyClKtY@bV_q{zceDz+MdaG;H=FU_-%dtHyLD&mc{A(TS)qxb!@xWikq_I z3m5yaAIv+_gW0vQTB&;Q#*BN*%S*TNoOnj-aEjc?@L0L$yP}3n1)E^T9sq6BBjoxQ zy-unhsX$Xem!Q=MIeZwSec$;OuRVtCLZIilF%WLLFgRSTT1B8Zyo50u2p_xOhma@uaT((WZ&H^4gl1iKSO=aqSc1{SJuo>6i&Ofl0(mzkh}ck}LCmKhOw$ zWm7|7$$AL>&~RmiGl)r3htckXGB=dE?kIT_s>r)^xHkU09YxUJqnT>15_Q}#T4p%v zP+3o((Vu;ZnElL-PeN}N+J_p^pm#g|R8q;a;O+#hql-V$Y~tv;9Cd_L&7qqO(8+wF zo5vf<;+-Z3#@tu5*zR~G8Tq%|dcEduHyGbg^I@qV_D5heE}mYcoy~TeGajmSj%j1i zj97PNu9)}!{m8eIr)2E1CR2yek<(h#_!vUKuC4tHh|f*AS^qrrDQE{GhDlxsH$ay7 zGI-UZv7k7`qL!2~Ruh394JHq()vq7xx+GJ_=tuX5U>1bd80J&a{Dj?wM1w(*-lOX4 zAz&`SKqp^Tl%IH;|2`xSozLx&$EoDbS)jC?#)cQh2-=N@d!R-yZYUFR4+mSzz-(P; z>3&dBJ7!=p77bimxMJs{za>6Q)=xLVZz-}@XPkXZ%%Ap2%=z-n@Ky*)Oh>Yn&UJ<`mlT z?iPC-YYFg3j7sc~ON$)bi2Uq%!_4bE%k3DZ(0!id?Stg6PEHrrL_4I8fjVU+U z5{FMq4(~-bp2ut^ARz5&lU)Xj5cf(7WHNVUNo@?1?0Z1`e#=#iarp~H57SA#iY{if zHmH-*G==Gc>uyJV9I4ry;xRjlL`PgeZXm9WcO=uQN(tln5Xa27_snYckiee$KFcrE zh2R>UyufU()HnTdM`jtIUEAunSzUxMP~JN&QI%jp!+BVcc%dNH(1rz)Ll1>HSe+_EoZ%-R?cjq3}Z8cdJ39^k;_@>LzJe} zoiRVxy?wj3OW3@nJm=2)jI;giu%+NVdCOE==CtzZTT8OihlN%{M1OYM8XIe?oopK2 z4)b-RSqe(SdZ_(S7+%dww}dbz@#0vn0Cc3vJq8)FH&vOUW??4Xdm+=o^4{s*58y*( zNArJKI{&vuCa^R52gSqlKZ|8X0!B8*|0mwc&d&6|##=d9S^mG5&Nb?$8p*nCU?NIF zLh(4AT_AuLiC~bF;AUW8VHt)P@wNyT$#jr{N=izd3GrZpSe7KD@SnMNU$ZZ{PQTet zKkl_x8&)+wbzU`IH$J@Z*h#g3c{~t?uxf(+3*JKCfl2^2NV}!3F)&PKW)XNbf)ZfU@Ha zu+MMU>Z@QeKDI`n1p*b}6v)fA+yIs#4WfVs7ut9QhyfJZVW%;lv-)dr1K))qB80ZZ zIJQ4+2b>Y*EXc7@P$Iy#%~n*EKBCAs;lh7&wje#Pzz7K15(t80p6(KV-)#+Tdn^c0 zZb1ZsbQk)ZG=l&M%8`-4oV#XxphHCj|K{yo0|#yXM*PwJfwq7Y2{6_tF3?WVzTDh? zRmu1JRNzI33~l{fiGM|Yl7LZeKtcuIA%lbMoHq0AoVJ7xK!EzdMRDN-0fIsP8iTSE z{_Z>c75%V=KfKJ^Z6yH&AvmUC0f2-dK$;QHw~_&7|FR~(|M(LAV3Gc`L4MoDzy6Tl z?y!E+gunlI=lsId96|@01K`?#@7F+q+j|TV0A%~`xWT|ge%kEwfl*Fh`K{l*@)_Uh z6aS!Nxv<=~U_9DyY6$*oQuV_ukfTyiXOKXTY;6D*@UP#J`)S}03hJl8K!NL3eU@kb zuTV5F(C-OzQ_x0l(63GJnjRek?vwjNJKVChAH^6(42npa}D>yDVxcfKE+Rq^Pw`CQmP*FkMf5T=XP{Vr=6`LK~Dyzeq<*(GP|o$T?S zXpmP+*$H6u(UbPQEn5ycwE9)o*WNldiM!elD9s)+sU2pR*L92~odG{OI*XPr&iqo_ zbl-5n-y%Wa;1>7Eqp5?(ne>2XAj#{0w!rX0Ym%Bl0_wSq|0MZa9J~krS*dO>zrF3- zTtZUGiJ|gt7~?0o4U;JGZeD?0R4ko*-nK;#R}PJP02U9qzqKFo275f`qrFOV9#`5GqtXLPf=3EgQVDiy2 zr<=OhRjVp_KRCfdhn)D~{VOyR^}kA|-5385A_oPo#IHi<;Wrm?ih)e#iQy~CI$Gd4 z9f4m3^zw}4{FF*Z4g@fmL{(WMfvp?Kk%MxGKCp|Nkc6a9+TCSgTmEcbUDsly01;8< zIYD~EGu@f4U%W~~mBlYm+s}Y(($^@QGy-HPO3anXZn_`s)jaVW4G0Uh?4&urc2j?6 zF&lHc*d#M((@EU{mK@_ZZ`x4Ah4E}=Cj0YXx0U-10or-q)#|%PktO*t3Y$zd)%Klh zLM;&~z|FXRtr5F`t{0rLTozj=^G+pdE5~Z-z%&-W%CVe_2`d0cBK;@pdH7vnu~Qi$ z{Gzmj8aS>GpAL->@wBm2(mce!}lgV7xcd;0WNIt-!gO*3-4-YXn#-hYcgoBxz8^Qr9C3lO)wwCink#b=$m;uz9d z__p*mN4M+X<7h@F4XdfLX0jlIm~pe@!~3Iq;f<~|S84Q2=1{2eEeQLF!oRD18^dzP zND%Sdb$+d04bsvuni5cGh~!nk_2+eKnp-OmN?k;ve>9;l%bdRy>MEx;sB~F6FI*gA zcZbR+tsW^KVWxP>z1n*CmP=u3v(lyCsVFDL(vrOTQ1~F`sl1mk|3{87M4p?Kh??v6 z$Orpm^7>LQ`wvSsSkhu*)cxPtV>9P+(aGAS+cxQlnBnob$)QTGLU+Uv1gx3jP|vUB z!M0qbr##KfOFBL_naq|U8!_unYsYD?Y~@AQYFJLzYz9!GScEwe=Upr};}lAJ2wv5! zO_wp*uI?qQ9*i~0uhu5EHZTQ@`}36NJ>YZIi$J31syL)cGTbfR@;xNygm#kT9`_4y z&&tlT`@+XzEAZSJp{HU*!p>sV2Cxw;)yUADUe#JXX`QyE(6E={jMz~g7xErGm%2LR zR25Z^R8IPmG3Kk8eOwG$@z!kGTFs%a8JZeR-@!uUNkY}URe7;pM*ZVk4!BeWo1V*Bn5|t40uyBUt+uczx_wJ_mDy~yIHtkcXzl4$Ito+SlbCV+ zWci@hI!#Bk?h2g8?29e1?Q|#QndWaj8-xAYe@JDOAgIrsH9ffJ&d?uPQ>_q;JGTfc zV(QR+6Brq-E^84GMm{fO1<67%q7}+*i)}eK)3K<$s=f*QcQ3MtAn7LjrV`$%1V~yi z52cs{@r3Jj6H=|7=8UDbf8M-r%N89{&>YA2u5)s;;`2UGZ55n}JOPkiM(Alhm%57^ zLq$}()iUaPO+1_G;=S^w7i!SvpwfV^nwhA!M|umMG-))(s{=u@fP%7?<+C%BP|>@L(n@_2B3=|siIt`6u6NopKyJA5N-mt1kEZ;b8)5BuDIj)@u4BkmK?&Jo(g{2orgAxyFoEXCg2}^IVZqDV0C9s>0vC zOC#T1^%x+s=w@c6?hSqqD^}51v=XsJRwO1@yq^awqpiY)e42T4ED7_V>r$o;Rn#VVogue1JrM0-$SCv9_MIQx{!-V^ zK3}Wc=NH=~Kd<5jve^iSGed#~GINusRZ7e!7T}w5fM90rk^nCYOkX@zz!ds2nYPhxScM9f2OY(>^!i zdnrk*sg$s8LdbS!;T(wQOG`z*T z+NX1M_~6~-VLD1(ZmK8j<-POB-#1(Mh6@T}{(aP{p z*Y{?|y!t9)w8`cFRCGBpk$huPZSWmRXIqOpTcIoi*!5iiJMDJ^qRgKpm)jkrdXF=e z5Sg6*kX={=)z_+8US{S4*ofDo-P^n0hL%R+A<3Rlc6e21$8AmEooUnFA-}IAxqn?^ zXy_x{SBu!8=90PKVOL##c}4;;j`9iU%A=gL^EXVT>@dlnzS3sk+Vw$A#;saai3I)(htZo3D! zNqBsf8J$}7L|h2Viq7Rhv8rU;2Wf)Uj;~Z!&Lt&!b&2m&)C99!_^`rGK&oZ!I&Bio z*QgsIzZA#}rd!{<7FLkfjC{0hCyr<-nF*x_gIU|bxJSFn*WN(cuQ^4@J~j?BgZ8Ri z$C|Amorc4RUGQ<`TNky3h%0igl3MFN{(wBMRf2YIIhCt7(J@f+(YucRV=SKqQgCQ! zcTQNbQ=iEo$e5;a=O__ zNS{-T1Nrv*G$PnBT=zILN{$k{{hce?}WZz6DWt65XMk?;n zEa(v>jwpRpkJPkqNX7D7gzVHGf-{&|ixf`hEUTxfa2XUhYsk-a1+z9iT$__CMDEj~ zrZlGjh2Q11eaPkkcaS5ErHX8BRixiATjCSxFueEC-QL|>KxhPm4anw&jUx7b-1x(Eec3N>9>sH;(kS$X> zgTSFGo$Fdq6uh=sFw$#W#LVRMTr=&#n;k<7)uG;#UhQD7!e^7Wp_|ViOuM%W)QHe0 zZ%;tzXRa~>bE&iTV;9}3&>o#!#@Y&skItDoPe!4BY*dxk{O6z|n=UeVy6m2PxyCmB z`GZegoE!~Xf!8ywnR*6RMVDV>`p{KMGcsg|UT{#eL$QALOc7`%n8u4y2oGHO{l{#w z{3!`$5h7%*$buo|4AbnXBpYWutzqauWVCIL9iKckp-x$Ptij+4!#(=DkN9$blTsy$ zx<`Q`dRYPi!j}xWS^@7C7qcXld?Ji(t&YBfQ1)+6qe)T#y@&GqFMsB)U1#Te#%q4z z)h6+92tMDs)L;yzk?G{tAbx7BGsqq+fm-xOeiWXyb0O22H!af-V%vd)=dU|U+N!s2 zu|3WWMyi%?w95oUp?Yovkq6KT;l~6I8rlKQj2s7ZyQ;N3U!_NyF^W;hvOi`>XkKkO zufi3E8_f}HLR$WO_4)a1F?g zRAXe{PqQ8VOp>SRw|YP5U!gZ*PJd{rgC{{9E*$eLktvX)jUUH8 zB@z%n4U@=zKY^G6kPpM$^qrDAV3G5gcPR*O^gNt$WDhli)?^2LF!O%+{g}V$V<_s3 zj{r6L01ONJXS#;XYkDHY3_b#3%95GKSTg?=3|X`ZYOL6VwVLug-X4{Fkyn<2_&k%% z;c^|>Yhk#=Vcu>@c3whv~R8rk;)<)d}leWEN-4Kr7=~gBl^kPaDZnH;-SDmjWm_UPai% z-&)yN@$(Gg7iayt!U~{6Im)RimFi7hiQLv@30_;GZF#cPlKFpIRsUtKAsrDJ0Z>L` z#6*cat@>nayjA_jeJ!w|bF>bOHiO+5*raKHutLxD5TZNPD)5a+f%q^#W}xS=ayRZ; zK5p}1#>Y{sK*l(=wp@`caF{$DC8Q}8t_yK85q00V@s8s~DAiNHCj6N5>SA((BmU0s zynfMuxdC#tnjFZh7;4J*rBW59inbFyE04Q70;Orc_es4hd}GIV($Tl@oB>DkxRq}< zW;fTNxDN4D7&-xb>K~;K8nkqRlTw|qj>m3F5nz6j5o|V>Cl{f~X=znRR~-Z+TGr~u z0G|gH&`UjnwmT*1ve9o#Kk_vELD+m?do9f5J4V;W$;m=2iEQ|h@km5(>`!hEqHhD;)zdsZTvd#~n6;=dkC_+@ zfu|iYXixDJOcftMiR=AFgD;z)D*6V6r>YuWdmn#J%q=jB=@p)U{v0l1)W_~!Z|C7w zvx_H|ZoSi@<&u_WNZ`dK2lS5U4Cf%B8|pB0E`bdqvjI!6AHWv_B;}W3@i>?oYjl#? zYFPB%cgsm1Lf9ph-W~enw2vt!gk#@!h6vTM{^l(&25y_WukNT~EXY)pB3CB0k8PH< zq#oh9qj)+4@HXO%|KO!&@193y#XYIAun5qTkw!!VTZg7*aHaNCBEkKyYh_ zR^S&H*Q)uD*KR9go%sf+S9f+E;WLkc8@Ky}_94SZc^=gA;Q)liDjp5wJJOV`0B->D zWtLb57@{Qf{)+$Rt}1SjO#c8PS@*+&jIM2sv9#y{0zQa$Y$;eJn*sRt>Xh{pe2XCo z%;r(a1KJ;q#s$APhzg#J@h;>;ac0dy>zSUZ^P_#r^?Mkfx&_V~cCNVR*hHrCvTT?& zWl2;g5K9m~<63B%(iD3-nfB4-5iU7kShcF;=^n*x@${v5=%05djp-&pZQ`XP}WpPx0y7*9ccc7G#EBK-1pR;;)rpN z1wk0V4q_3Sq57II8MlOv9h(6=fBxKksZP;PPL^JjMSxEIi~FHgm~Cq}vcn@;848XI z1%Zw+fEmO`#a!_nj|Z=jIlj~=O!G=Bp_dur4{fl6)@|cWJRBUy`Hr8vnhQBeqxs?IS5lQ8H{U ze)lF*K@AK*cNlvVTwU)x9__f;JnVTjEg%n>4i7K^Y*;|$MMDgHsHPOyln@q67-H`^ zQFIwyKt@;BgkCFXA0=$0P=x-e1LNf;@d9Iafsq;f%t1`_+^iVG0`R!5fO|;ZRE|OE z+99B9aA=&%s_^Z4vj06-94yw=pG)>d%{9@nojE5bb_Xo zA;T&rI3Zkq7t1RTR-6YjQo^lTpyzP!6Y21^DUQ!B7{M?e$mixajDnaW5b-(Ie_s1z zqD6Fu(#VMOkrt3b>+7*~IoL^mS~AUlAKn5hO6N1Y?0!!|=kF(%i87YQMgJiTi&wJ# zsD85`Bsmh-D5v|VE3S~*ti5ULh~q-?T;gwVEaq9quhV+i#lejtC9)2rvpxl6^&7C$0mn=w_ygO~wtttGtcHeS8@?@=bbQ`5=` z`?}NxW<)xC0SQ1g$pNN!ego|t)V;fHO47F!?X!UpuWt%ZqG31kK(fE$ex`3_@0Tr`b?y3SSf$fd$F+<`@&?FkR#4!Xzt>HOB$7&I zpz0`Dk|Q1RT%@#meKWIY4bQdX*_J?>Vkg&$(j(3EGGu~~_HG2C-rAX+pVZ)3wIZJ2 zPM9(5LL}Fw_u+(hG?TUnlPLlbQ+Y3q-OZ>KAq&|1E7~ihTdd;T<(mjYM3TPgcgL7a z(G3Bj1>&oV&cBqgnk;Rjv7b_AmK~4#dq1Ql=VomfYO`_|sB2FgpRX*VEh{FS!TQSS zcxK~NL-ktQ=VB&a)YG7o=b3b1Yem~{vdd<3deug;OsZ@)Ur~f*voe*w!@*V=QX-#R zM96IZmBMwJH`WxB`WDVkN<+ASc4_AxPli~Rpa1V)0~k|EKwcc&(OjkiPQ}eh5n>KD zqmz6$^AMYeJgfh`z$9TToN{UriFV2J*yzgpno^H4)~a~6InHR*1sk*-++uo=g? zNE~@a>#A}!X3pZtL=PpOIi=Bog|}a4v8;Vq-GaS6Fh1udkbU3jEkagZj+Z31qdGmc zSaCx4bD}j6y-bnIo|Yz+NN1qk$d~74V?$Gj7eiP+;r#M;;E%E>i3f?ki-Nx1Lq{&0XDBj~QGLK!&+%WU$5d0p$t8yjtf}a;Z5}b?((9B!q zxGw%%yq|{slg9!U1}jS-Tyl!kZU9(T975su`T-SNXNmB4;oDf;rL#uM@QjXcg|4pY zJBir?>j&>O4$<CKjB(aIn*mvzQI(-4bIqgu)uFBxCpO9R9PrFjFt=&>9#Cb$aC#3juOiEtbW=Ubw2kD0DMkn^wQl)%I|H{^q@51vcMu(A)DrI`v6vcD>_u6el&z7Md|wXgdQ zb+JWvN;1uwJc#QksVOLEB%(sfA?$A$;iv7jpb@Y~o~wz8(cO|C_~8Uma-p0XnYeul zz1G-_>|<%jv5=E>UwHC6^9gLJ0znm2)&a(0`y%HaZG=Q?^>ruI;3)Nl%A*||!-t91$Mn!YJpIC$K|g{23h?@q(IQnuw1ZjD&U=>}yZn%6j+eM7FY4$n7+qI>?bQW<-zMIa*0H>T!;15da)`632L#rDPD& z;=pIr6_dXUSXt);RbMDqkhOQV<{i=o{5z6r27&R(BC?`~etI3#ZsX^x1$*yZTxv!u zcD-KX`q-Q1CzMeomZg<5d6cf$;eg;vZ8lmnaL(C=>-6h0_gF{R;xu`b7fVLCZh<30 zY=geT@MKvyb3)$plli177sJg^XyVUzIq4dAHVkrKdZ_j(5-xD#-D#A5wS=KFk7?OSj_WpM?X1)0t87 zri{@NdHryHLbCZvGY2kjw{triCj@b@TV`hz);7Flr_D$2FjN(?ePxmd>VJknk|RG+ z^jooZM7VRfBakOdIsIn5Ikpr!UYA?qNYS=R&U*6kf+FZ@2y=VRH{=WN(yAGKWzwyF z{6|x8kK;`uBK~b9L=pagSD4*i(`Y*TZ~Df#0eUBW_qHC&CN+&*Shu$Irr?MF8PK+{ zZy;US8z3ZGj_4UpY5EYa`&qCmM-IcnLS4lJX>_zF)G$QPmfBPvs)0kgwvoz^5WnK4 z9HRrIQcXMzyc8(gFA`EaNgcLz3W?}Sc zO*40qlHUl4ndX3QVNDa!>@m=qTY+Eqs)*AH|04<_7Xio9kcNFJUB+GMaYu5SL@VqW z1E6;_{ggqyfHjQRr|XC>$c_F}+wxK;g~~5Dg@k>Mm|=Q*35KmN(d>M--wFZaQRjBJ zStuBqU8rQ!8(h^8eeBDg@x(NnHM>21VHs}1wbwzA@nsI`|%XB_6}Te2g|VxV}6lUD?@aBDu^SnuSS zK~FWb;FGRO>dIEsAA?Q$U>iIEnSALl_*~TUbW0=T?>zhTk%2FvtWLf>QqeiG}*^Ony7yzT*H91)`s93fKbR3AB{4xEje+UU{n!9(GZThm(@mzn~qg|0~+T#P&a+2NMA!BNHRz{~Z5cp#UQj11snMH3~q{i&rHEi&+~wn~Ink+nJa`@$o@9IXjvf+CaH)*0`Cf=-edI4G^|-!w&2S*|+V}5lSqv z%xfGC?C1t{b#)2bhwaPx6AT1`^?2`PWH4WCcle#=;(OKnr1GiC_q4p0mME%+#VNTYKSAwvG0O+0EDOy^R;`R%WLoBO7or9nOocqfH zDj6X7M?v>b%+19~LB|Jgc5n(z(`Ey}XkBtePfyeQC4ZX&F*tn5&s3EW4{xIhynP-5 zwT5nP_}k>@34hn&vi2MJCxK!ZfHi;tlc=h^@KH?xVVI<}05lqC*8|UEcDyVeJA zaP{^A6T|{If#=sOS;1%L1BBC#Z*Dx(1JpS(pYQo!fR{|37KV11N_V z<*?4*u)bL_aD$KUF=XQswx0fp^aI%gWC7#K)C|PN)*0#<|E=WstwO%rtpML#SMU73 zhW^^T=wlGb#Tr;Kv#H3{u4NOHt!h#0;v4^vJ^bDI z{I1P2&91Ia3S_MTzK_KMcGF?z)9$;>0iXc-(PEir{Y`;d05`b)Xa4`GYJq#lw;;`5 zE&Z$fItTH#iD<9+pr*yK#`!}K!Z9VNHBeR!M;-?<0BiQWS=)1@)mE+#VjV{Np1j(l z1+8~k{iRm*3o=jpFAAZuV*HDrdbJl?Stq<-d|~z$ zdBZQI7?}CHc2LKFg!CWG0ZvU$kMEz7754OU+XHlXc5?rTuk?!>{*-4a#I(WA%sdS*zk%<8Yd`)tluBRbc!8u`NERo4Oe7nwfn zb@#PBv(s>anCQcVyAAkpgSP07JB>%5Cli|+#!kUe7seM{4H!mF_IH6%cW~ea_NOhO zU?AYX*6&?irPFE*6fHr50=Gp()xxB#h9OnnbIgO?lOWva)$pbr@()wVR*t37Rupbafeum99?d#4kIm&QxwQi!)L zMqai>SULN`Vy|`zW&HNt=5>PcXSL;)h7inm1F+n|h9$xDiuNZFxDM#2o_Q>)`|4JQ zKYAaE!z4EJK-(TGUhiT8MCpGZdh|0s7u$9iOCSy<3T-kFAAw9#odrG%85V)N9?46ENBL4R6_n};W4#e92E&o0ZMvz8eQ|yr% z8~xKd+a6TkCc6V&eniusO&R^uZLa6A8}CAxBd5ue=a|wH_Z{i{imYP6Ee#);C^|ED zFp&E`F1`Hu@R{TS3wnf@4_W+-=?(w51Xr_cAas8f9HnL@9VZD#+*30aNVB7mdCyHe$d~!A%~c@AbdbtZ@U4Xmh*yjGEP9QPFy5 z+jD%!cQ6ez$*oN~nUfYl9Hxz$E{*UIIBkcJQHEaDQLZl1Fo8MSPVHC$0~=DE*qKU| zNCFkDPd4#mqWR}Gtw?o=clVybsv93p2sua0xbRxC3JRV#T;rl>{MvZk*SiB4-G5Ph zP}j~g5VdUC5j@83yNkS0oW4I3VW9V}CNkd+Y%*?Q-iPg)kP{$b&5}>zbqwe>(V1!i&qId{1IS`whgbbfaD@8MqB_rh#8(ivg zEwIh?P){49TDE+?$&OvzdWYNIC(rw@G8M+`MKj+9WC`6I-x#eGQeZJ{{JW!vF30tm zQqR%A(o>@^4KY4$aZ=mkgVT&BR)qJn7&x&8IpE9R)}f5MmS5*r+68jA)c-|wmXFr zv(q&@iIuOMH(kc8N#jMr-wu1bu%gx87#2=EjemBpkwpxm8DCzJ!SHEVcxfvX6AKz3 z;IGNX{)ohwmR%P^x7R-y4>a|bcE>Q&9nuU8%4G$CNp)OJA#Pgl~`4GH~ zJBjSTZtTc7`iq0JZxO2QdO!)IXsXC1HMTA4h;PfjC8s)F;&~Bn74$)l8Khw;O*PRt zE{i5xxM#!O2Z0CCluNK9FN~(ao?A)kYqoY!aHSe8$1NB)SnipmATSg)@=mrA5lCbi zeRM4L{8*s`w-uoAf$pz}mgJDALY8pG$)iUXNz28TiOTi3Ye1!hZ;ay0(lm^6&fTNj z!E*_aR6v8hA+p&b&OUZDdZlEDtwnDHF;c};_geNT?y%P(wpV$?j&g!DgR6jk6Hc1u zOX>X!80X31VhN3ufX{TSoSMKB*_0-dk7gp29>s6O4pHnjg>8vc@D#_pcEjNl+XhWI z{;mBqi6?l@ujOX_@aLV(m32ma!Aa)K<++8sFRdk^&@Tx;E*?>(PPolu7px%BcLe>p zobKcf&$!sr58h2o5lN>v!3Cxx*R`twGV^Oa62h8S(nO=C<>wS9Q@G6H%r_{RPd_~n zi6HmR;?Ui8M9P1-h|9|;Ntl3%Fv9KZZ{5Ru4fh!RRqkGsag;7m%M#xglWJ3m4v@Yg zyNTZITB|Z!Qk(YBoc^h8xq&77ON(sZV1mjQr3#`UR*-At{9mcbt@{&g#<^>J4(ODb zKoB9DkqHl#$j{JEQ^v1q`4guleQive5hWsJFz;V*1XX0oAcy{(VQq|HeoTP^1B(J4 zP_qMa2M`c++IdTNWcW@WA zFqhUtYfo5wVAcR7Q8^>wgpRIxC(o$Y^gqU`ciHct2s^Y(ksC)6P_Rq<;~9>?5{hzk z?!KXkYx_UIq?N-j8&$*;|A`0SDmyUnS4UPPR}yg;q>D-~dkDfkq0P*Sws~G-syV!x zmc5eJoeF$!NN+fz1;Nh)k{EbA?KUz?!$Mo$r9CLD3eQ- z7Ai0j2`!YKh!k)+u&jxVjGri%1UzthK3J5AINxrj0*cQufnch9tyJ$_i*^IVH@ zxj2G6BW?wQS&AK2is!d-fnxxNdkd*zznztW>_^CILMrM*sK5z_wSSr>PmDIFyUq8- z9e(R8Gg(!LPCkH(&J3K#u8JO+OUAbv)x|L0@CGHEV1>heF^HwXRw^1^I+c;PR;w z?^rKrk5x}zEmP3Rn@&Jq`r^$ZeKuxddx!6iTjjX&BwjC-4oF{GLP_#O5k1Lus$60XHK%?7nn}=%6;u7tB}}0<^P7!0 zZL)_b)IIxPw}&CH-ZV+S$LsNd8YPdutYJMYEe<&VgkT)%Bxz)tt*6*HCeS4A;j>>1 z(-ht0^E!*2vKP($Qh)PdIbX86hb{HmdoIfLX`8CJ;^?^cLdC-^*@6@spX5u;Ma|R= z$6rLJLihIKqvv3-b3k0KI^fnad`JuPF*6iHX`MTfw6VU5?OzzfKoH>nB&8C3k|3t_~U0X@zPM% zKsz)@?oTDMp~k{Xxc#zvD|vtALJ@lp_mX?Hyj*w}+EOSYeT&4R{=Gg*bJB5|2e$gS zwZL5Gdk!UCh^d?FH5K2nY!vr4L%e0)v3ND1SA9~>2!9?*a}$GrkE4-%=-nDI1{9vb ziGN{>>FY@ze}8QQT>1S^pm#?y#=^NlpI>GIf$h?!0B37ab9dI%0LA2Yjj^2-oHdl< z!z_Q~a?dG9%2dvVGLZ@_{qIeJQk}z&#onACyD`TiJaXEOhJEHt?pt%C?$AkY_pnBU zH3a!66bz+`($20r)Sr^x%<^%SW=#ia%l)}Fv6w?lpF3<(L*;6X4Io`gnHjXJJz&YU zZV$ZK3?-_46B<*0pZFl9uyqOBl)@t;d1uWHd5MaHk$PF2KmZF@zh?i^2hzB28CbChE6$Kh;66?zqvQ+1N9e;s8zKabnJe{!EPnSN%BIk#H!*slFI9fj*vOSA%4$UL!N1($a>0oU)wl5u>h zjCfO#uA8l?o)g>($O*qyW0%@9eAy)Z`^rE{W;JfyKn44Y^wbBxl`h}@@sAoAa#NYm zV$2*rs04d`9&&-x#`xJCU_HL}RKogV z4B9Jr7~83)Pck5q`pc_Cs*FUite4P#r?rF)$EORd4$SL|5#`1QkhlpE-8b;u&qx*O zdv2~55h4pf{&*R*=i_8;Zeop4q8agv-bX0&&~Qr zto%NMt?2SrCvMzwN?Y&BC1`QeyW#T7T3!^1MHor?PV2n%jmI4pz6}2A1-GUt$?pzKCrp3Dcq%Tc zyIB#GFbhXc9&6w(CUgv>k~Xn6C&VfG@*-NnOUgB`~S}(39D>~?M3L4UhbhCC`HWILLq~fFUbe5m#eZIB4S9!)R zs*@tctxleP>>G|sV^(XtmSixX47D@->zCj5J6D$b+a{5b%t2~zL?zoL-%drjyP`ra zKf5B3m?!t78%XpxLk<7sfFF|kFvy=T>2`8V5oam5*qjPvGd)QTBDdKWsbE2Zo~Q&u_Z6|Y%>eJSLu$|dc$XM1|KFbW=g$I4{!M}PoUlhd3LAINHR$70Z%C|A`*pP(KxDOiU?4k^$4&Fw0LDr#aG%8QjF+CPOwx_FzOi0dLqO>+s&TcSlxDwuJOdZ8%XUi}7(x^Q&O3}yXie)FH5+V?i;YYH88a$^c#AR zc)mNp+8J}sXbgS>Acx#ld|+~ryJHEqNv&HBV@MdRebK7Ny6z73<$&-2SiNVEGr;jf zP{QF8Ai-M5L%XxR)^kv*yw`uihrVH{Y0o>cPLwkFEA@Q_9n}5M5tzZX7@8ESG0!=} zZoErMXg^SwI;37dZOah(8UO3yL)^-;d0Nq21g7m7)b9?Zjj39g<4)ldM{q^D_Zej|zv=nS?<% z@}@%q4uIfzXvOKfduX0(=77OmQp~5=vAx!V5aU8FS{Z`a&lSAT>~Ff4V=v}A`p=|O z&dPK{7?M?wbhwR6f|Q}thN_R*0?`1Wy&?>*b6F~_z8PdbW?G~pp-bWc|GLkMu-C39 ztgT^Y*=lH12tCAaZex3>G6_P0vK;_WO4)|hnO1lxgL9{x+j)Lq&KDIkmB%laf`p`& z+EZkV*K(X8XAZ> zJNTV4sv<6M3$I33{K0uJ({rC>-j`(Rq|sSZSl!UB4V5gL6GV!052eE|6&uzeM#-}G z9cA@%iAPTeJt8#nB;Bwx3;Kaxm<~E#xuvDVi}*%r zg$85ZXEP1khlhju{hEO9HQyj^eMDYGS%6_faoLV!MWNt)>iK+dxtvUb?}kkd4AcDI z90rn?$}|(mw(?U-N7)T4sHRB7*TQDJV(uo&L_8T!RsC7ckL4*(i=f6VOHPG$Pgq5* z!ShH$Ut@!6d9fd(`Ig1+O5&y1`WJJG17!jTwn(O+_q5A^+_xo}0tYFOnTu=NU55Cj zY7Tz^kH&O!_3+~r`IC&cIfTU~{>1ptI8_0Z%4cULA4|JCFPEJ85|thF(mK+LMZBMQ zCDt9s#bgmSPfl%wo<@!m*cLdsP0{1)0rB`Qa3# zSg$f7x{$SwSlE$|d=)MY8@$#l(8)$^YGDl;EOR1Rnd+}DUU?^~dwkVTZ;B*n6_Ja* zegO03VqrD2B_5Bf5_cj0ug%ik94gcM~54&zg;Wg%J0 zSxEmlaKu$Ev#`7@?EOJh0>?X zwmFh*LyEkUO}N|e{;18+vVx9rRv)ans$VnD*e2+XyY!_jH$g|}qp!eFrDJ_GsE&UavBaCrZgG!jBmXUY zhPhEUE!}!5rB%Nr8g`R0*C>pft`Q_WKvj9wEXuq_SuD|pfZSHRYQ#N}z2Dvmt;Ym# z6ormE(Z`YO2WCkHJ zypoz-su`h0#S=>MqAa!tlgrMul75B3T&eiFLn(S63x5npbz2?!H29f)yrM$aHklhZ zhIveztkF6I{!xK9w(9JP?E(-tDI?K*xA50b2HjwKK&|<}EOkbbyDo{M19MzB^a55R zF=DOow<5x^5b!xlqln4*q&yZgyiHdF^`&)LM)I&(ht0-Jo_YOqFh)1c{e%w|JcfIk z6imuT@Ld)K%>66x%^pVu4Jl=Pv3C;jJzKkUm3In(Ni9JQFyUh=wS5UTbq`S4-WHs z5X%L^w z=(eO=OIKy|(BnoWe3Ty0oq)SYnyvU@DI=$7=;b8YotWP&2936jFPh@ye)}qn%rQ15 z<(jk=%91#*OHzN8eypZwxvdVl&8OF}hZxYI&gM3QP1LsppIFMr3 z_i=DON9gys+Y4TcR@z}0doy0=pF;!6kY#Xsj5Rf{+{n9$RP^k{GNqgJJEb6+uP zyZ_t>07}QQbn9tJI^X&G!Pw)&k4MvjmmW6bP%Nd!2HYTVS1^cmXyi(|Dyc#JC0V9N zZ#oj|(7&R{^bRgWXGcinUY2=xq7GmRlQsndZ~6gsXo>#gH2*thV3hKkv!VTO>OJ0+ z&nq6Q&ropA?wVATzY-}sjw{Mr$C@7V-$M7Qtnsr&ZmBN>wQvQkY%I$rAvhccUcqbQ z14~`?#`d;llfC?SKhsGUu&li&a|q;vFMb}8$2=vMhvjiR2F5uU?&Z)?C6>3c4p!ei z%kO2#A0s^r2Tqadbl0>QjME;gR3afl-3`x#@8c4TMG=`bVe{&6xfnO`+NKIKkvSr>YzegVNwAxwng&TYofwE(!x2L zQ$DB<*^cy0XDoU1KqQa}3C-wm5tAvz=-B+qiCI2(`or zEKv%zf262EKtTo`XzxW+7cCC|^+vEW3NUZGY6goeAn(vkOxy@Lic4Ak>IB#1jViBN ztF8^-@5(wnJ%`*4XSEA8Hsv9>N`%779Y1RPi>US z4zX8;(tt6B|94nT;3|WDHV>Gv?lDi$u7-G>({S$;K4@!dmjR z>?JlHr9D7oEm$YS{=Ao3u3OFDoOd7j3kaTQ;;?OxvYQNcu6WOD&lGO9p&wpdr%k&d zuN998dhD8n`g#4$wegzZwm>5lofmYIckAc+g@Uju1y!8G_|qxsmdOjaCXBC00BS)No1d0cH%N|z09B*$hQ^lava?5T?hKo;n5 z{pW1RAz)W$yD+?}Xqh|Zcz%|74xySm{x0n2t3L9|-g!UTIIwDNc6MySgJC7O4!29~ z6(J9v%70Pi_tj)B3_LZ|6h>lYN$3MZ4O86){U-#nR0j&po0y0a^`0(>q)k85)@0fA z>XO<=_*e<8F8WOE@P5z(*N0 zFboLg3rMsmi~BA`#sijSCiZODpcAlQmu%9iPs`bDl`ElG!=x_w^5|#(Sq=6{RAh#9 zHL>Sa!2-%cFgw#Ittl(D$1=4ycjC7}5PW?i)Y_~Ai;P$mDZ50(M;VQZDgkXAF-S*{ z^eo(5@mf9!s-Re?-oK!j)o^-$74PAJS%QZQBD`l}-=>9m5O@;HuN=H^r8rIUEibU$ zyJedUko6k@CvJJxv}cI7W}+&^SJhFmklH)5s`Vs$c@Y#5V)Sdodgx7G0?w?IIytg! zC@(pBGTM;rno2a<3f1PC+m0~N`eWtvv6+2G zQyUe9>q&xt*IU|otW$fc*YD}x9X%9zG=eR^q8X#k-9aS>X6FPRrT@0?^pIPubhQ|! zR?G%ay_nv_)j9XM<@TVFIQYN$!pIV^@=@y!YoOlHDfEND(~ho)LVZ_-Lv1ye{HA3w zx8G*7ya1DJ=1rO?a3WzSJWU|ST|$(uQIrJKy7o1nRd<`46P_y*?CbqZcA--fXnkNS zY?tS`+VBVH_qntNQZHnGuRQsu)2eGD2^tL73>)O~)cRP9&2be$tkMP% z!r_paNKwfY*ed-Y@3151#z&hLZVsufdOP8l0Mme9<-C3nsrF z+36*f49pTEJVOD|zTXxyh)L+OYs;~$zV!7(X1~_M9MP`G&qVpUV0q>TDM{_5 zfSKnDGkRCoX9T4+`7@!wp#*6q5<9)ypb8!uUa>q274 z#zq+wSn5;k3){I$&ZqZCz`<;b+;PkHaQB{XzsceS4)h#{67Na=PW6iF4TzcMI@`ck zC~`}v3^pQmpM?FT=}@#Q_$oqtvMoziM+I;u9fk-@%R?2IfFn~rTV$!pR2EbzMH#^kxX z0aE0ti?J*MG?hhqgKLZL5Na-W-e+%Q4mWn4H@ zz!oCI@*L-BPFhc~$!Rg~xse?2;njUlJ_WuTJxgB^9f6TD(18u@te~udL9ayO-T7V` zV>nKGoTq};=q`rOfs5bZJo%T>fk9u^hEP9bHO2hZ&b>tmkE)vkCT~j{EVeaK&w%D3 zC#)u&hWSOvq+@Dpwy{-_)>cZY4z5nLn%7@HpIa?rk%VDWULp~* zXVFZRw@j(FkRIEfX59m2zq{bLuxU*m-qXg1ZQtp-iDaWs2_A!jxN#8+?NR33sf@81 z&MgrNT^A@*f{&N^UogLK7O}k<)92`aGiolJYb!20X*5Q<$xvD_V<$c?!qxfF79xYVN+O#X2HNR@TQuP{xOt?u!Wwd2hVY3k}8Zm(b?W*Ra zZ6A{<8=O;>N77KDr5%kN(%e=-tnM@X0jaD9X_2QKj^P3%x``p)Mng4Ch~GLkq0Cv* z%>4-`EuLTYvj(8+^!^Mc2#9EDM)vEk#tk_!>0VD8WXsjFV=F(UHx|KA{L6mU!7-qw z^SWKHKUIWvrKRz_2|&b_H9nO;HD>Eb(d8Li5r2yK9=S= z%tfHXk&kvo_h$32`@u-A{QdI$KwE(R{cqG_RiTZE?Blko@KCd zoA)-LUz6Q(7oGRPQ(>6t<2ZXUeW#LqN ztBCux55iaf%S@zcD`U6&OfIF+4y@5ykORhAt{9d3yO*J`2<%OHXqf3khvWo}AaM%|mZIP9k^*?QkY>XTX|KG%4jheYe(nX^v z@EIXxm*|;l`=cJ%Sr=3=sQ@8(qJQu zOD_LOHo@3KSCiTDWT$nvWSbpUCS-+wLM);zDF_KE6%8@WY*;@Y@7%CN8=sPxxO zsFkrl0}y-?>CwKDu%JICC2|4$pnwT5IwFGr9tcQy1h9yy$-fRFkd=fx4fOeCAnd0+YyMv;CI9>@tlG=m_N?TE_eXZ)*d1lg!rBPuS@|#plBGdU9b>AAS;Ma zwe@!`AU#?iW`A@rV8OjihDVoRK|vs0O2|L~;a4Cz2~?ox5nv!8;@(;Pnt~8V9V!bT zM1Qw1|NJ(FaCXT3Zy02-Hem$^O6(Xf2!S~ub5z8DzAaz~D1TxB2Kn1M5C=Dk!<)cO zMTzWRxM6#vun88h*ujDA#z1Y=q34-?ixG~%M!rX4!j23;XTc9(B!am;TJJG?77mmU zkfQm(nBnZl>U83eK(L}61O6I1cDNbb(C;0v@+_!(pX%U&K&XRQ;UEKq7A&z4BVQM8 z-{&Z|@>`%=TZXGUbE7+YKjpxYg2D!J{l$ewZP|pdbgj&&f}STUofah7@j!|R{Fesu zFZ_)3kmoPpci)*E zKecoGU4uVoAD`}4vhtWR1dtL*uPyfZ`9CO7!NP{C zerO-=_AsLaqE*C(yFJE!w^fAMj^~gOQqWO9hM|S51>1=AM5v%nz#PDaZBZY#?85#; z|D=n+eNdktc8-F?#C`)Zy7`3cgY;yiKmLS}w>vn!md_oZ++xR8ndoL9KSm4RZft|H zV8f^v@W7w;^Vp9D-KV$D%;*bAYPl!Q* zo}e}&|2ljkz->4D{C+w3pD|*fz(Rq3G4W6k;Xnta*94*Z45KI^{SjYYNW0iS51(G& zM2Pl~;g18T$fOv@nW+h}zsvmAc+2e;wy7d_@UHa~Of$1kR3dGlWTHN4lrJ6h(CKt| zY5wI_>kTG2i~*m4CbHX;8P>y>+pFeF_cPaZlpows2^NE9#V>H)xJf7_ zICT^xF2hV1&-<4xk;w*Y*(S^(@QGBdR{L(AULdwmEiSdpKpx>X-6uEkBX)uqd@D_N%(v zN+#5~C2aVzm61pc{AOk~DY{74&yMqKv>aY>`wZ}p3;QJN%A1d(q36j~^VqBDG02AB z~i_i`=tZ zQ7|s)IKI~TytNyM=<8PUu1OiwIn3Axf5jQ_%lPBG!Y#0^_G#Ez^fM{XC1>3;M7Fnf zAKxR~c4k`>j=NjDgKm@a@$=xK3F$chYLvWgL5oR4Yntg!jbASCfij3tj242R@z|H#;bKlI^`0|*YmcyJu6v$o zr9GVA!X|Y~ZBicZDetW!DY@z?ZH$+Wey|eU7dr~jQoaKWJ}${$esmH)k|R6 z+1A*EKk$cLucwsEj-jEI&DNB~o}UCHccGYvK9Rl1bEM$~CPtagI;Y4TcvDlhkh#8Z z#p&tDL-HO6=SZ=nzxj(D?! zaqu5<9Ul9Qdb zj>05fB%^*?V2=@3c8Q?srSG?B^|BNy5?6piqw*^xtSNH-RHL$|?6sVRkD+AzL8+Ni zxnjh4bh=ySmOQ1vR)I_ZJRFV5?df^%gC@UKE@_J@YPAZ6N&6-ds%~qo3SF6gb@BDr zECtP)EH$+dPa{BM#FJ$`&}4rvB5oZ!M1^VP#v*;~HbX7%WFIrt*^DoW#*&_%ro~u; zSel2>Sb|??8MC##4_)|(L=;a=VqDfq1~f;{)=PsZw`Rpo&C-K!#1aMEM8og>CQypB zwW-?l**w@}84X93T%?~5ddWy@&CpjmAKT9(mmryWF=P~XSz}k(yV3QF^Kxyt7*mCu zaGd&CqH~O2*5fJp2zAv60fTFKbu7b9TaVP3@5im9SS@pM`J=H*=Q0j}3JKJ87J ze%o$=7A?Bv4Ji7qtl)ILd>s_yg#yUE4u28Fc4vCu3$|V9x62qEBE#$Y_9ewfwwvau zAu5DwAD@i8HiTiI^($q#?0W7B=Ngm>KBo~E5$w(reDoz^7z9r;_N{g6=rWg{R13Rs zEmACeBQlmR`aK@5GsJX(4IGB0dR`k=K7`gV4~U?re$xeztb^L z2mk)N%wF?#55Mc|S>FU6?pdVv6zC`Hgw_jL4k*1Qt)>G#E4q4APrN#HDcxJXeNk0u zT(xJO3Y>9KC;lSY(dloL{tT3!q~n(kc=QuF-Y$qk@jLm7c+ltvZ>dd@Ntcvr>LI=w zZQ`IxTOLDNC)UC_fhIn)?(D~EvO)j*P)x)WiyP0{mTlK>Z%}a~DF@QOq85MkR@lVK zbS(Ro;Nj*UksTm=@b&8#iv42vyIpUmXEufJ&~2|jQCQ&A_NLV}VK=23I6^P3$lvz1Qs&om7Ec?2z&omhPTwaZgjz6#xbKY z-1n`IArX{9%Y<372Efax1`X_{3xB>>q}0C?xIb(hG*QmIQ($FR z&)(|wQafpV@(BPaaM$24mhlSl;dhv8DyT?`{RkE+aD!o0`#=d9QSxan&7=C18N;s7 zn}v=aWA~C_#K`}-MF6l%)JDYsD zuHQ%cCrK*wp`$Q+Q`vcOPyLzoDM?B)ltz2g6?BD~7nLBW-EFH5%7LEHgTcT3YNV|2 zVp~S0eBgNRKcei%J)Y>^z$HXu3 zYC}KPe-x*`NI`!HBOZYuStRl|=p^*L7_Sl@n%`e0kTnns}wyE(F- ze#qM$OeLJH~ zf7~vQ=8leTLC6sJY3t?I1k^>w%DmZKw=j#{G_ClQDv6nHpB*8Ks!D6oz+>_2-!b2H zG~?H>0{+NYH*r3|t+BFJkH4?2^9@G(VMK5A%!d5XlubBFR=2}pH8`sR@6r{U98nQ>k4`g_Oq|M5%e`b^B(~i>>ZRWKv-p5!y_FI4 zj{6!hL8Nbnp0DHAP{dTTNYkY?`FhYHpcQf6xBav{Ag=v93?))0hap95@-GMS< zof_XW`(u?D+TOW1@Zwzn49S0XmoZ>*HopPlA$J$vsQ8PWDC^mBk03?XaVfc=FnXSddy?A4dz4gcjoi(V9HYB zZLj#U7!DlwJ$@B$#xeKP1nXzG8`CpXts=|GpXxzUEU^3A)QwE1(rDa~1P-C=jn`+AJb zm^S0{lq-mFrQ_pw&7Nx(4a$;i=5*pug_H3}PRi)0!`q#Vih^aaU$F<0G=Fe?87sGo zYbTvHJdh|kg)>CndL@0!5U5@>61?4Wzi44e#lM7??}6fW05f_CrSZOYtv(xe+O7Ct`K zu38-odC#t-DPp`f-YxB-y4p-z=Ze%`J#))4o!{Uo#;cZK*WZ^tE_qxXDLxN|4_)jj zH^3!l$L^RmFyHwA)U!Jhv0b%fZ$f&PY6ZJVReFpP)-ihP1(VxVu7G>1RzvJ|W z2}n^a+Yi~MD(IvUxO(T7CyF**Giu9ers8wiEHJ{5iC^(SrL59lf;!-B&Yz#>=t%Ww z)7kMEG7V_RGzOY&PxD5VGW><{GHg*Zr?8#(*F`J-V@9IaX0V9dJyg zVZnBK@VEFwb)BTJV}rmjuKUlKR?AHe>CWXA_;Sl>oCB6eT#V~7Uf3_NOb;kW+=t+@ zSfEMafMBGMDL}==bn53yS)3N{zP42cFQu8`*5Dg1#BoUar&g8ZBQ9!cQdWE^~hCVQS!Z;G5g4T<`QmbaA$ z!82JAiD4tKtb>Wjk+^gUo-lgP+<3?PFCgF*5K%^Kw{BavBqfE{$N@wlz%e$^$EuvO z&=cb6sBY|jiU5cCO{%n`^v0EAdGT?p&e;Yup|!ga*U(|C4iN*WMcJabW*y+!a;_CH z6kR$808(^;eN^;W|EryYR+8st*(X`uyL6X!+6sm@?RFI{){MJK+%A%M;(S2vy}QN< zY(8Uya8Ls0^S>#aAZ$#(W)U-?m!iu~v}Q%R$=YNQMI1H8uLe6x4N;hN#fFTdZjedy zB4@XPW3-OZhr=5MQJF+M?TuJIjh=lpK{d*Z@Zo{GsJ>XJk@FdND8VpJz5bKmZ;(n@ z{~|ZUR*oOKg89nfLV3$zq^v;B8@u@vjnS>1v$w(^8-vnuE{TW4Q-S-r)~GX{nX<#@ zQJ6n0{$qE0XcRrf#i^;N&QD!<=)S(H-vrE~fQLHdt&~vHZgi7Dy&WVA>wt?*y? zzcMMmzi0CX7jk9@YrQ*!^*bdeyYT(Jzak0rYhFTbw={-Qg-cZPE8=`YBeD~?-8sSE zb2VD^242c=ftR=rf?Luv#h+D9+-93nLV{q$J}<3id;XmC z5biYyiGk!}AMn&YaU=pOx6r7nV1J&Pa5tL|hRmuF*uq?L95`orx2lSAW?+636B5gX@ZIVfAK*7(Sq0+S=s*g z`+w1bI2aiIe`!J0twzozH?5@DTM{LQ)$6S`TM{E04K`b%BmX^HRU{~@+4Xw7-Y%Ao zym$OM=i*pKnOtPFpK^^75Gg9>Av4x7G9tG&IF}d}m>hwR16W0AWhY(#(?4i8I!~6K z()#y#va&NWB8n*qndRrylovEnu>I%y2En(qgwZzzqjzv{7)SsVzP{$c4md@f1(0Mh zfu+R6-27YqJ_4eDe21Uf6DP~>pz;5{3#+PV$?1uysCm*0|GVNxQBv}63ZdwSF}Hz2 zP>^3vOiTlimmIGGB$l?3!GWy-jHDG^|7`=HZ*5`${9VdK z`q85%AoC~apV(bSe`lLs-dSJ%#Y3X$-(6k+J3oGY!vb&yO6S7dFfSAgXK3PQ?g?6WG6lC zrL!}k~Os$Py zA)u{3nbKC$zm}jr=btKHFi=Dp8XAerznOraw4%d35qs5_`ai9$zjM*q+2j8bpZX!7 zw>p5k&(qgA0G+3^rTzBy_5$0}HGF>ADE>f)pYs~C3z~@Laq^$q>_kibT>kic|0phg z(9jvQjJT5gRK-R%=2wsJT7Tq5_)Lw^#K!uF|E>VOZ$9~s{cd_HD!M8dwm&0t806|r zJXJ%TcHXuVC=_x6cuDUQ5WW^gR|blIdDyAU?7qc6w4lq4rVN$%v| znR2LO>Dm0sza_MxzZt~yt`odtmM{-{T?&{3@>fuFwG+v5emn}%G4XIPZhJzm`36fq zFuj;pA`lvW&Ft3+Wf6Em~OZnq+#2`-GTaXFPnQJ@1p z(h$xGiuNNFvZJ?L)XBZ6ofHW9XbytMt1Fv*ebyqEPcXkm>%e?(ovW%@YSr<-C6tyU zg*hbyHfIf=+5LlaXyk@u*m(D8k^#pt|QQ^j338_YQIpbEB#MU*; z-cr?$_)CBh-WPTMA{6Dxe_Ms0hR+3vVVP$U%7VeQ9Ztp*`+32CAba6cyHgaY6|jG) z0w<)zX!SlDkHQof)vUSoj_ixK2bAU!tn?N*?o;IXJaZ*=WTJl+Cw!t4kLK6`t<7R~&rSk(>QAa-93kYv%CCY?Z#uOP z^By#R|>?Up{ZVHZ!;|!k11%*4L*F@P6s5? zMQZ6D-1TAR$Hz?UGXH$*Ik;4g^uoxq3jfi?VO}q`iw#mU<>=eGf3AI@qdm1q40U~m zoY0QCo#Bw8UYVGz=M1JaLc(Frn<8ZKzsz?Y$K%K`M>(;TP7q7#IgComshvV=Jg(M@ z$zn@W7E(CZ+`v689K66fhdSGTX&N){OZm#}KC;w%>8x$E-k8Qr0|TQ()DPxo^$x3r z>Zh0M=Ihl-i#}_x8~{zsVK1aaA|coJ@a`St)=BGo=di-P9G-bb#}bU*QN!qWU|T_O z`|X7X=QU-P1Xmn1qS-(3S?c>u9H~t8hGJ(EJ}q<_nWUIV?VP=L4aJWH`izB(Ya=lW z6D!5G1FFZqzM?SVLEZ76um1d)r9OD;bQdg|qJKvn8aQ>KiCWIc&9>`(SkdB&Uo>sO z%)5b22Bg`G0L@)BR zV8I#+oQ_yN5rZf4NSH}IzubxT&6e#!gmH#5(8*Kkgy9I6*+&YVaR@Kz{p=9NjN9bN7lUOOBByL1{2NIn&Rf(+cIR)jxO z5I##a`Fy3JDSKy*`feyrW8=Cr-cTbRisqt`3gB5e0uwP_%1u z(e_fHNEb_Y8A|5I<*R)8A%N<*XAP;8r2o|+rBj-h)BW3^pk;}!N(UbcBb-t451&HR zNy-sV>p~K9D31&ZCH*`B_CN4J4;EEg_kTkBA57lzh|XFX>b}P#J`2&z# z#OcCTwxY#k286by_DQa_#+uF;Bh7?_os37G15mjwbs{r93P+#yX3N>d*GCakZ>-z( zE&6hVFWod;0vV1!n3q~}qA4))`00ZUp zUj!0;d%CpX3Ne^YM!VeAAuKb7+C$#l$mD1(V%XNS7hwx00>!+n?9-11(gOmeri0O1 z-J6)7L3?|5H4ju{Wa|g>Jg%pxuAQLJTEj;SMgyB3Ml=~VfVle7yq<*wz}>b>$xYbM zfA8A~5R?a$8{+JGFd+O+7XO)cisKr!jv^qdWj9FSlMq&QoKJV6YIUF4*EeJ7j4l{;i7fh>fA8Mcjx=@ zEt$43g@PO2N2uB!)mL!wvq8RH`~_8g=B|><#j{IxWI=mVU%JTPLwUoB^>+gqZoaG9 z(F!yw41w*}SBe+us)3RyS!mY5cIW(_rqJ_3h@f7N0lAnc_L%>oQVf| zg-m{jyT_Sl=W0C8h_At~VNm5_{*l#N!1L}FUAN#sDV>@$kKU07{91KITOlRqG9y61 z`Mp1E5rkaP-c1?|Yvj;!hKApErNo*@nwB+%91Vq^>*xyR*($k=rcVWC2;bz}tuH9M zLsNgDk;Jb!M55#RdpQYtVkqHNGF~F<=9^Re+cE?)TR8tX6&(bZ9@~^Dw`de~bhKme zQC5Dn2_EbJ_85N@ytTB@-%)95I3YG%%VYwIOPd&ti)-OS*eXgBoa#;b969T27ZA|9 zKfx74?f|(cX?N>`lB{=}NuVS*J3~0bt&f;-zu<$MvxpwlYfF^E5r_XrO5v#xYa80@ zw`{cV0TEW|&6|JO6E3nrm;B?sZnq$1Z?*e0)cY55hU~y68~3lfh|NW_7lPe13VlE{}j0>Ooa^Ie-0|+Ys{=9arO2Rnd|) zu>0$YdfRjxRj=v7V}0!RU6wBBYk06Jm4K@yCj7wiwtFlQtRpr9U%QXpVW?=#yB^_{ zem}^~z%~)JWJaA}n7r3pT4%aG3h$<3=u3^ZZ?7N-TK!8{%dQ3y`=55|0rut67VOSA zEQ>PoD0{`*$Zx2@5_zw8UT=W0u-rteZu8GpvYR>MsDib2QKhQawxu=}ezJ&>ov z7WG9T7OJOoWt*S@@>~9OZO?fI#=4MBBPYF1nO>vlPHc&l@~|KgP+FXhqDrgCHSp$e zl0NO!my;5fqI{kDUMfYW{Zrzgfk|ll?Ky39Z7(km(WCup5D@{4 z{j(P?dw1x{S~TiuVA6r_yyLHw$dphUE%kT<0VP+F3B!=gL^(M-I`5PdYzgQs*Wfwy z5YF^jaiiHpf{I1;MYA0i)9X~&j%Fsj-EQFXR!T5H?((YHcmg3Ua#=|TZQ}T$dM)RY zE4HyXVoZ-WQL4dVn`q0=i4I#*Nr{~IESYG0l8qz6_78jpSGLJHi=JtLq;~t!%{AiI znJvP9WwUG=WMC3O4L*h^H)tY5nR>Tdcbcy$5+$c*hT-hRLfO zFK=+vP###cndW^gD?weXb%9c}`LG$~Y!Sft)zMnv_N2e&;BTd@{xlN?dF- zSYjhpU^*nPrOMD9JU2@)@VZCb-wWpic5&)N2yp!l-aMkp$=i@-d4U5n*25U9m}n&}7H}Lh6b}Me4c) z)KK15yh&9g1elbqwed;lc^(ccpD%-ZU@U%DqUKekIO|;=qhnP5@J2HXXXSSDydYg) zGJ+3m2-&_4c*Tjx+o$1RLPF`2?})T29(dvLukVH16nVTvN$yeTc~S#H=yaDCZ*WZO z;*ug;Y=oG1Dn%%y_$G0*d3NQ{`0f|;KqCzvZ)I9X(=t||@+W%9p6}{CMV`S4mLlu2 zpWya$%U@1nUo@qNdm>`1nsG77PpIrqp%_)_#@E#lFX*w>mKLl4fK}Rh{SsEX#_@eD zSe_-(lDYlw{HYEAZ%gGqL86$9LA~r$g=;Bc!L8?Pg&xy5icj{yMOp5dWYUzDrfXC3 zwYTIiY5Te(zD-wj{UH$ZT9JeH=o?|OKdWo=s8nPC3(ERU9#uPL*qV8p{fC~8@B_Z! zhC`CG*IU-9BP#h6-&hWvcCtMEg(C{;ZUJMzcbj#~m%q}$0&5^Tdpu5dc7e+mrIJSx zD9w1Si*cKKp~r?ID>!o8eC^Z=>AO@oPLhfYRJ4NM_JJ?`8Q)gI77uX+r4V1s4oh;| z+n`lPTC1$;;oae|*M0KCWIn@6?I*j3_6&tO)J= zMQAr-Z>xmapPM0b1>E49pJfcwe_H&&5yr#bVp|&M(ebAA2z#lVTRsu;hqS7b+Ofw$6!ix~Gz`0p+(uMG# z@M5&|ffyrv({xFL3buREwj2)j7%glm_ngc!to|!XN-d^=thLwi{bQKIP4h+w4&gmC zc_c16+YydF-~nKo**jQJejViu&L!nhmKsMOdBgcF6g@PKI@W-^Hf~x^NvV-$Z3kuX zMnsSyC5EVm;V22cF|+I%O8?lGGS`CLHBO?8|MlFv@E_PbGUYo1Nd}g}dw)YAhEZ zu(4&3bl~%VY|V|>@Bl}Qso5kbGtVta^W1Y-Aq2k3$Hpjs7J60c_I!E ze7T}*m6;zmVgFbgMTj1JW-6pX?Gw5Jl!w2R zLLxsyu>exUf4OSvU1`UPmX}k!@W2y2qH?k5;^Cz*UWi_QEEyInGMmKNxE|fK)=?_d zbcG&ov#K?7zKMSPrJ7ULO%!BM;E-uhqYzc4hq9US!3CwK?V(qd%df$kv;~?&A}O;< zh8TllZ#y}X6qTf^B&1yQ55)e7fE(Nu<$R_j)XG<;dTkoLCpFUG@`({Aj1&ysx%{r&`oKk;h zI*#>}ZRzk7zc*i12#7l5)}vqYkfA!r}8Nv}`)Rx>S-L^2_K8VrlrKN~M*y^(;! zUK@R=+1+#OGnW@Z`k%fS;npOqrm!s2&ETIDHz95uHsCw%l8bBu`};$mEl|Qo=i%R< zskbqL%y|84oP2U}lcwB@QgIxiS&=X3drNIe@3&ch`AFXxb|i;523*x?zM^xK0)Re8 zo12O=R*7hO0ne+bBiOVmi)#y`ycazBIpn-6n$q4yr63DFpFn#V@}KC#x?{;4hCCYxE^dt>*cobW2fM#X4hEMWJ8vi zDfKGcJ)oEgD~?3JcaeiY#T3Y{Z+F|D6l>88nCP&@(ec7*GvU->>g#M)gUFhjeEt6d z*ws&8RFq+|Q=a|A#fjE3fmf9Y7xnO(?Y)V^5hDt`y~r~6`vm%eelVp!z5#^s$GIR5 zI5tv3z)9Vq^N`D5JWeZ(>f(&xNK+o+I*%jsgy~Q zjzM(Cmy)7^-fi=fSko(l;Bv`lEE>7$VK35T{FkHCbs}R(*49G3*QV1$JriZ(=wu2y z6l12vOXPmyr*#~yODK;LF-GLD(;Jy;0ktn>{D;CKzjWNYZhzdH6fSjW6h4a^?C^FzVstzx;-j%+)gB8#kgr*hG<_MBT9YTlFxU zVJbd4$PypnPp|Du+r94AHy>~;XNHxGdpCUu1-zj_zfvwOuZzWrf|J&`t4juQ}rD4W?f! zL^f+z#u0qE_K)LLPicGjzf98gAP(7~D4}DO`Ydrem29UD9dVPN_5QX# z#c|n^br^Z^K@XqNJPMIQQU(+wO@VF9GmqL?BW&}buqE$MOhGRE&FtZsq7Pg-YzbWY z<;*QO8s=(nlMUj0D+2Fotpc;F*e440L~KxA#?{X6RnKJTxfV7pKe?6r;HklE%i1ORKePy9&C*Y3A#+)kpOVO;Q_Q#6Wy(rv#m zcN`0YuJo7$=c+@4!W;}B3C%!yqncEZUuB{`7WYo+0A|_v5!jRKq8WTDlIB5^Z8R$uF2V#Mw z)kJ83lShBTnCHX^pQXqU1_>m?;ahuSYgvB5d|umqSQu%f<;^txa61 z=0nP1(xB1^_MhOL7Y!l5qpfZ;f+I zl6UHC)@)ca*J@SHNxLMlZ=EOJ>Q`vI#RtJ;MI@QW{F65~d95-SxyLx+lm5jRyDX!s z;EuEGl4{t9Kp!JW(iw%J9tExIDvilGz*s%pj1T#)@`|FNN~a@z>r)c>wJc}|sF z!b5?{67mQ`v^X((=Oy5vw?dFT0u&T~A9-@~4j>H{L?!vLM=?4lZp_YVzkr&iu#8>a zx524EHc_Ly=L2XYl?zoe%BVq-z}SZlRXhe&*I7m?AFY?E`j;PqeW{r1!C1F{NwAbF z-ltXRIstfqU*Q;Py+~(jJ$>Yu6zg~pIfoTb3~FJt!tVvQyUaGPkP#h^@{W<;n^iZi zoLe+u(u^4^Wx0y(6GUbU>H1zPGa37f2TKwKizetC>RXqOTPsv9F(yUXO=+_vJ)nu(V$ympNb8Gudyv8G!J zWuf`agaPA?Zb|t%P;w;*hxn&44y^2vw1WI+^qfDpmh_+W*;R%xVOIA2-kOk2Zs$5O z?awkdpH z3?{6N87+u*Xa?9aQ7z%}7vijOA2T24H4GE>)v11CHUa8Hzt27fwhXpV{T=D(yxCoS zRsZ{8{`4cA(M>Kq(YJ8*o=?OHN1*b#=4P%YGMN|Ysv)A4R}G%-SmMW%7HmgKqZERx*n^lPqS`L!WiIwv@Z5{d*?rFcJ9xvcNjBu zV1_(Ka4sx7b*YO1uyNHUv8c-LKvP_OcCal`4Hx?;w8iq{qXk(f_+ltptu2Jdn3kJ6 zS<~xyap*V*3vu}wTq+)OlEuMoGxoKZHAXDmk{;=LR(76*q77ltcrdBX5jos&TRLaE zhIemY-KC@w1HPo)n;40PAPS&9=a3grEqaG!|3mMVP&8aNuH+HX>9q(wBGdMjS?Z>L zDr6VI7TT5F_Eb0Deo&0=JrB+i0mAD)%_RJNlj4crL#BN8J8O})xhT~PW{Mf;{G`Ak zqoMJAc3b^M(mSb%?}!(0{8NgZa<5gA*?xty{_?>&+c&NW!F0=2CV*K9Rc)W2hxxLl z(EX`QHB!>d^3x0bZ19xv&Hv^RmKl9xT5^+NK4Z3PxA4p# zFx=y|k&>F`U2o{lkAKM9GpSz~Eyb%OCbu9oSKpKzMF$0TGR8q5o9=4x(V!(pSbQ3- z`$y>0nI4by*W}>1Y>;As1ro>BP#zA`3lI$Sg1Ud-3lLn`Z83@|#ITw3s-pUbi9)0UfFbn;= z;vbNZ^`}1t`2ei1H(|KjgJjRn8XsTDMC6N_$_&I+7p=trUL_=^p^6z_iM<$9%~>zt z%g8rz4ebK}ZcmeGYGi05DW40_!On;wn6$DrkL|sq(6+&t_k+c+&mHH;&WZU8X3Q$D z7e)i4MW9q$0o9V-Mr~Kj?3h0CzKIg#DkxpIKmm-aP&~}BmT~=}u2LHYdKLEXWZQy2 zch`LBVCeh*2#JppBZ~Mbw6h0h)mM8Y?<8!Wes+%^Whulejd~SrPUxV`m1)P`Mcz>{ z1@L^9_W7y=sLeh>BNeFI2|rSfW8qB?ZA`KV#k;AJBcUReNT(dQ`uJntjKOcbarb#a zl#=afIoL*f_10psslJ1k6itsGn3)9ei&ju2I&+(f&&vVuAj|Ih53uJ;(6L?2RljJ6 z@F4#U#={au*GRBgZy*FS3HAvI%!I5eF7Bw!g{px$8dV>&Qx}rhNXxg#6!hx4+B1S{ zg3%YoyyPe}jZTJA5I#dK*rDzv4;hJ)HY@J6>pN{3Q!h}-T0T~vG>%o`hfFTrv*+q6 zx;13e^wu3E^93xMX)@qSP6ba7&c!FJb7`C8c^}^PiDQ2ud(=R zL~H)1t+VfRPB59YzFP4m+sY2Oxe$aGPGN&&UZ0k1GHK!%YdhcL<_|GIKgYIJ^|ke5 zkD%R15dBHI@;pF)yt3q&;%e7!4FNuhb*jvJ?SOXvFauu#+UX8}hI0%`+z2Y5nfla$ zJ8CX8iV}jZ8Re#O~<6|Xeq8R$SB8a^X)+6;qR!wZs(OHW{6(p`paJQy=x=*Q)!$5 z*rLdp@J=vbnjmYi1{><^jOLZx-r%F#IfDP5vKXZH^ zLxDC0TbaOV6OHl?M86#$`?|HK(=;?Iv#>yJ&POjYHwC&kOvm7zBq@}ZxAS49QB4eS zNEbijgxJ*)%`aRGRcO8U2UVw6o9m!-%G=C?^_M=Nzgk`_4}v-NK>5RmiUvKEc>Y

#k}h^pvYm|vewd?YD>(i3ga?n$K(on9Nm~(@o<>?F8nwG z7ek)M%zyH%jp8{z86En*cZfJUosqPA_fx{9QRyS@lSEnZes$$WXmM&-Si*I?7(G49 zMqT7}$bQ+E5U3Q5lOFRk^5GX`8OhaG!QtB1gy-GQCmcx%KHh@n_PK`fx&;ujewKX? z90|?i?1LUg*< zP4&M5IrxT{1hss`{o)g$^82bK<6#g}DC>s%_#uDr`h|Qnpv^vbx0ry9T)i_nS*beJ z1MaGV7*V&hA%ptbr=RczIA0lY%E+sru<_VVA?n*VVUWTL>A2mL zUqdCX8Qwn?Jm*y)JK-a@E}VrjzP;Z7MqS3VrT3i|dS^%26CLkN1%SW{sJa}TdFH0Rj>4t{r`i)(v$ZU>pU)gN zZ2FZYqtG*&)i*TAsnufeB)0>@W7?md5Mg?gwr2Tsf1m;K2XmC{KdL{^k8$1~#PVO! zpbkbxxaG4wwpE2@rB8X%wMo#2tY;e>ujpX6-h46dE7)NRbHRA#yQnD;C2p56`uT>>(Skz%H}6#^ZJKt9M0)vrYw z$F;}I`Q$t4)M#c??NE2VcEoqS=Q9-b@m~qkzT|G~q=jx2P$`Cv#JK~vF^TVOYES7| zk6k1~aOeu)oxS!hP9QRU`l!CE@4Maoj?vv7gz_+25v-nNIr-QW!!=iLpb0LTn$?c= zdPX!$Hd5s1p_e_ukJGGahCG3EimA7}|t zL}RJ#^YkYan-VtL5NDdFDc$Y=6PK?G8o!?EkePJ2rNne*+7>mh{GDxfa(X{CpU80j3=GqUS~E#oob5`V`XpPxG{F#uFuZe^B#vakV)c zX;30wac^o@TYY5Ev%NjVodiv4&M994bWyXY0wCz%k(sp!o4`IDg2>gUUUB@*ddEuv zYsht_1-e;AYn%is{V}^+esjh6;Y==izGOE**04nTS#|oR?;BZD#;5vQQTc>dE}fP6NMV5ZziHP z1&jnc1W^hH=~ptU@WrE`2S*)VW1JY>QD2Oqn3x-_F1_0;G3f4=;_gD(%z+pJK%28w z0WlUcSjM!DMZ0%!6I%OHyA;YHgA=pIv&rLtxUDZq<5P-F2lw+TZ4H1NLnwuDo4){uoQBORttqgE!T^I*z!KCi_g|=JChOJN2khcg_VkKqN8x zjXy>BC?Svi(O@>SqhIEAnsB(lRw0VEi#dUfZQFqjA&!lQ)y)y_jzs$cm6Tm;><+kW z9;QOb>f^>bjUZP9b_K*Z+BVnm=-Tm~3(_hsOeFQ0yCww0suDJ2D? zahu(s5XALSaKzDGk6-$VMg4mRT|uYco6%$yrcmW)crB_BV{9Nqaz5jyt|Ai8-Je&E-i&q^khmkD?^z*)+aK4 zJUWMS+%DBH0)T>u@PxFyEaM?4*w5uwsrB-OXHx_vKAED-e-|C+Qe`03tr4vPc95`T z@Yy8sv%0G998aC`Tv;zX_fh(W3s6BHr0nCwP9Vk3!lI!WY)B-gSqSh!2gfo|++H$f zS9uP;WurEQPzkhqcEqVOb>-A$aqmzYCFBxq;=~+3T01&DMxxgN$+iL)8cXDU`Su1h zp(X4Nn>5iq*kP-I3-!snLVa1a$7}Phiw#GLN!CK&XxzZ+5-7Ol=~PG5sP3LAj%?&d zQVnAk%oq(dGvCNNj<2a;HLzPYu$ko65Z<&9TE?UND3*2aAT+eqc9k(PFCWiqO2W34 zjRuM}tr+Mu8y@g9-{5Abog7k;d7yqBf@qh6+_fl`oC+1S_50ZR)X8?E&7uvnU}kkx&DUgLCu*dG zPX`AqgHu4&gj=MX1qo!Zx{2Y|*+qJ2XV6JzwN37y8h5x(5kz4}RV0bea9xnFkj!y7 ziqVkgdyG5ciTN#|P)=8k9CArLrrQJnDXii9k2z#ks-zuoOiruOV6q{^&B$wvmdgqo zdrkhyk(nKvuk2LZ&+l}LwLFcuj|Eki)>??Bd(f`l<_z!nA zJX*K!4F}5pE`59Nv=9fi3RuAlNTZ;FA7&P;k3deCIYXq+Wx^-(iPOADF6QT0H(=sC z>4;#3y^9&*dXP8vC$Yg1aTZ!K*%gajT*U1a6)KBj&KcfZ;rMnDrLGk_3)YA!{TS|s z=hdoO5$hNZFvG94-WHn04{_q5)@TnVVdob|D&iMGiV5CB>tdH~vPEX7WrQ&H=XNjb_YY}cY!ZS7 z%p%6ZOsqH0yo5g`AaNPa19{Bl5jn7e_kJk@%RmbbS_%V*>h$$%rQ6g?2`iVsYSg=P z&k5w5*Z&|9a->;s4rQAR_b!>oA`5i)gpbR7(%p6l5r#pMrBMJ~56HM1=ZI*Tz@?6x z$c^V{C9EzkJK42aFK~@u#d5C7*7*Yf$=+hjJ&hb9!Qts$t#}T<#Nvriy94d9;tAxp zOwd+paol2-RRA0?n{663B;F<<`>rrW73N!8HBVBBx?3JJXh|!K=`PkN1I#SteNY}v zhKHT}!}KzP9A-ZKX0CTLG>AG58LC%(g7s{Wg>o*|A#~GhBSHaH^tsD~OzlhrI=IXA znwCwF=xW8-k`DoDta`YmL~_=mA`?%5JO!y6OL#08Hjmhskk_tfuu*9%36JLHrY8uQ z{C8MAtco}A+{>Dc2y+loWn-!W5#K2~x*EN711kD2=bfb`!1L(kvL@()e^x&m(QTU}oXb@EOZ$1*_KaOV_1A@hI zCj4-)$qmMBu8EcTcKnZ}ISejZC(wCMi!Q~~{l(#~uOsAuY|IuT93Rwm=o|r5_$O9g zDW_c~`mYhR|8aX(=Thgs0hJ{B)s3B;F275p=-*jU6C-;r2gO~(v0ay{7smUsw-%|Bx?22N*3M)q2UMOUHVUOtgs z8!$}mnl9le1xva$aUa#2T!Z7$B1h)?R z!L!smE!*+Xy6lqvznWev()(slFQULLJbR`bnY{yu`CP?u2{|RU4Z^Pll}FTVBHxl- z@8Kb#CPKR^2EC5=jsTh{iGe84Nk3Jb)~6l4>!AXJO;+>AeeC)94B?}>oNU5>vwYg8 z;R;H{j7NOWrwQWX(wppe0knX8Xx_ax67EZ4Mw6H*Nl|YjG#n6KUEZ98=hqG#IbsHk z3)?(BcW4Sy)EH$a!!KtoQ^x&!k72uQKM0r(GDioZ?@;ax<{9g>Z7JCB8?H2^JRej= z4-#NTF2=kV5Gv%o4h)B$yL<@{8`rzNFKi@(_7>o5KGSeDx7y*)+O(#U{~7Ie;u9LP zC~)oac0b@$9fPb;cW8CRvtHrH4d@S3)WqH9PES2FUYo*G^3c1?=Hcf&t^+}ANa#lF zNk>B{)z5`Kxd@6sccr#t4gIE>r3U*6^RLQuWq>p@u`xf~fLY&nH^!b(*q~g-8f|$L zwlCf5OGF`SgeCDJW*f+D&lNLBTRX$ilpn=`*ZqtOYO^8QEVXM3Bqca{g5WPUjFj@u zA(-23hfE)P@A(?;T!VJ;invPW89x-PmRk{RrL1YwcX!WkMY`C|AFTH7wBT61T!Qn7Y z0=5D=sGz8ok5PTh5IW&_N0!}B)*#voY2|u*UrqqT>l7}ymNpJlM;vh5_GLgZ?+uNS z{5t^D7ys)&90wvjeT{G*fCxOiYDqMycO8%!>s}CLCE-hd|a?v7$l6*@hkVd z$Pyr@no?x{Xc}8S3Ga(pYC(IR8kxdM=SHFh1ACXM=FE0;e=EXeRF6G$dRD}ztJ-NO zS>2I)3ta$P6Gp+h7u<(>RJhTF+v)>9oI45!qT{>{SHBo5wTZ#BFXZnSMlts*@q*>f zxfzEs)!o~C2rpdFZjdLr z?{?`!GVzm1`;2Z>pS+s=xdCTl_nVe&p+(#VWR-VNpT@t{;K25ss^JTjqpftnS)`IR zC$WAl7=n^e4}|Br8rAG9R)OzfmUNd729r(2)W3-ucWl!2GHB`wIV;B=S$xndk%RIY_FC5^L3siG{w#qQ_JjBVhNwrSIiDL-Jf6e)Nb ze)0qk>bb5p2pn54fj?e6I3S=~WmHzSr7L`Y>+iubg;-~;%jgkE-J^1+cCknp76?Dn zhY?^Dp>nSjD}3n^-X`=q`aTMogdlSzvVsUq9wlogmuo{cvb6QT2!9C2sP zH_q*`sbw>3&Ze43t%w~{Fm408IdC>6#bR%~3-fRCOgju>OXRmz@V(=hASB8>*{da( z>?){EcfH!e;+{E$A#i!;-0L$fFF&gF;G*p|4(_y`nd<%YG(+d8RcFtWPMVfK7Tk7Ifxjoym zC#~b64gaY~k$Cm@z1sZ2uRA7xa)7j8FEh!oL1q*Ch)!|8T|nT&t0%Q1UvSflOU^89 zuj7J$+3$0W(JZYww8r^YeIuq}PA&bn-k~AFo*opFuN1w|&ILbN0Lk`YUmdsjX)Tf9 z7X!8x3=R6@x~RO9yl*dt&xo0fuWK?|Ufc%wT+R~F!EcLj2gElh%AG(%(ciToEDnBe zRSCjPYpiP8*d)lGGCo+#b1!=PV+w1o9_24nwYF6R7eYVO9Y38TACjzvJ^-$^22vE7 zs11u&hNJzRaIYcny{6wg#(({%gs`0e8>(t76$;BuavlBFrmOBq zzOL{U&zZTYnG4cE2H^ICTmWlx%WA*;uhby6a@QJ8E!o&->9jEC+1r)M_wV}rUb&K@ zpe!WD?oYEq3&d5~Xk@51H4ABEL#cY+L812>F1j}uCXdB4%FfK>z)K%#lZi1-j~Fl` z(5T;^`N8f z94$t?-9^F-TU4uY>5J8-8Lno+q0Oaer*L2MhLE0EdGx4kJ*kser431S8PksLTLyY` zwcR^`r?0fsw@Uqiy2kPkVP{SmnU0fktoEIU7bAN-))5lAiCvrGG!~}4=p8W+z#(+$>unf%j zdJA#x284jYwf*Y z{{YEf7Ka!R8IjV&@USe>Z8tNCrIv4}5eh2RH~vBa?KSXo6TAP1uyYI&9SYNQ+qP}n zwrzLc?%TGF+qP}nwr$(CjqRD;*_x`Is;$bOBqx>c)FO{~nZijqqU9bPNrD@R?4I z2b>fZzMOL>vWtvEPFTjrnYQdDLxAlTGti_{wWj>vH;{qT%gAR7HIET3x}`)gn9C0@ z`iIDWO9OpnB{)EgLD-6W2m*O0O3QjyVpwCTX#=aS(M%4TW{KrIQn?*0>U~i z>C-R589Sy&161ws@zwb5U&_bEWDPn2-`<5QWj_EW@N9}Xp&!CjF6!?DLW4L=NhRf# z`*Q3zrvxksjb;Vt50@c5bmf27v64P@VSpl_;a{zC6DuZ4kX`WVVku3!0n}LzbHtnw z$Mi%0g2nvk1Jpn&Jk!>@MHZ#07cYT4vlU9-y(*Bmv=yj@L08d0;3SL6g_^L2H8Oq# zip7D1_5UprhMZ^wd%@FJE%sQ5_-Q&$;mzSK!tybCl2u1X&mF3rm|)%|>wZYOUn>Gl z_)xFBU`N~J&tz7e(Sw5a2hc8fP6 zi)JaB_Mj365z~Oqe@F$9P$(17JzF#i1`CNyy#zbqElPvttUzS}} z?lB9`<+Y6ki}V5-3T{$3<$Shi*UYXo8x}f|`WBA<5kk3Ws$*T=HjsP{p-X@Ya*kX_ z_%=vusvP5Ai`nST#p#XhD0$qsWE&SDrY_wA&GKdN}}(2su$6dh-@$1rjgUl%QeJ;e#F; zw#1O=&hNE_6U4mogs$Csm;Q}bj@&gClI}S)6j79g0Yr+eTO`iOW=(n~wYdBF#~(eN zYvJY09u{BIfX&3t5HINuz{b>CK5G)Ykqqz2(RED<3b)#uL0H=i`a1kOu^@sFhZtMj6b5^QF2&jj9yB_S zHoTm)j~)o?(7p>gyGbVX_i=vRg(3=jHZV8|XjZU|Mu;aJ5bDJ7Jm&lcs?3g5YP6Ls z{uvN%`)C_kylM&MVhX1-@VT|Bp7@VH5`zQ!d_MEQRGFw1hF(eVYaZ2m9E#WB$>ciR zg=HvRmlLTgtx=XmuJS{vTOBZ_YWp8M$J!`9KGTVECeE4?6PX^C3Yj-(12@3_#R7j@ zLsZ>iojB3v>VrZ{-}K8#*b>X#lp~zW}X+}W3I@bQ6LYYo(0#56AdqNKxClY<8M-TFe&vW!GF1>Qt;)v<8KYX zkP8JTjKj7s^ac7e7-6`VQ)Z+y=$bs!=pu~M@u>y&*@bN8QpFloxO z^JvYLYnicpLOuYFUaiAW|FAk0hRStbzwPf9R0gA}E>oF?~^3 zVI_V}(gM?wB#V9Uy5F}_`n|o%(2kED)0aQ7 z98nL$^WVK!zR)S3D}xzDiGixQ_m->dZs@+GCC3y&<*xdbFHTp4Rrz`{H4U^T_S)Pv zgI6l#%rsTD9eEvA?ACVbeik7;#I9Gcs^u!V`b%SibJg$EhltY&xuQ_FS#JMOpsb=A zk2Y`(u;!+q(ey_5y8~bmYcYI1Jy8YbM^o|28YT}ymSj|(O#&ozQekiD2%-HZXY%BH z^A|D+*2XFD@7FGYzpjY4i{5#Gjf5!0_}AO>xWtL!*v}^4;is*M znMsEoMB}gP*7mkQqRi(zbhJK&<<2_yWoDJ+MYa0~6VcJTGnuhlsG(wEq%tr} z3a&k|7<^+}ny!5-4)8BUK1?)BVl54%(f0c=3`1Mq%VeIa>dYMv-%U+FTA2=5mbd}E-}ZecF;iEU!z zde>dKDl#P4VGOkkZq(KbO_zMtoI9w+J6lYjW)iYZK(;kJuK`kuIp5smow#uOuGrs| zLqh_Z4&1sW7shRsfHL={2W}lL{iNxl(@>?!$&7s<#XmSBldt4f>8b+;y#CqhI*`UUyqV_qUyxH7>lKW9DUGn@L-zNjJWk&zfVgFBB5nS}*^1xdpF$ zqc-+E+q-eld(sV=!rG4C{gudoP6r@Gh!1SeBMDuyH($Kn5AwEv{+Q4op~s;1)~(+* z@=C<%8dO2-yGZNu$rk;c0=8JHfl!mBG7!Q9d*3MK3j2oGW4l-x=>)W!ir63E@2(fk zKChB9(0?CizA)#|r?RA9BZ8Dd7OIkxB)yw=psg-zgyyicy`3Xu*X?&RG?20{)XiMSLcc4~f*ie@3H!~<%^j;MVGeb* zsk~*~K-bSAy=Qp<$Kv$EVz6zLkKYF(H8T0ua7mX*M0~oY0HivZ3A1+;29(Hfbd-p$tUzy(n~600$4y17`>c&cm4x zD5Tgs>9Z|;>eMG=lXc=7f#0=tTVG}Q&&Q6$OW+jjvDu_z0Y2fH zv?VIt_lB?b%mXH{Fjher#L5`Q?=l{B*o8L(X#qtsdZ2=hl$=xFSAw#ie+7wUWOGh0 zWV1?CB#qd1GytpLQfynPQ< zuJ^3+8w$HeTJx%bFBR@_D|pYjS9|#(9UfgEaT*dA?D=#%i<-59f#FB))okhtHAb1U z=TCn6p0tu0Om4fIW`s3*BbJ1(5G<;Jcf^-}5W{|92o*y@Tl#WcIM~`hJ#vl9B|Hui z@i6A@aAHDNj~qqFR20GRtX$qFnF2Zh%737&fuFKl3tO2ss<`pi)DxG2O!!56PDk%j ztn&YAve+5_M@<&X|Mg-q5pc3{vi^^jECv=9_Wz9VfT9;Ow{kLZAfOksGITN#G5KR_ zYy!o{2j%GGU}9(u<+fhsYNDaD70-H&M`LzyjmFcrwUtq9Z)T?RPuh;W6|@Ba@*2c7 zg#Zw!ZwnH}eW%Uwq-}@Y_wRL#V|Ih(m6mFg`jtofS?MCn+P0>^WFHfPxH=o1iyWa} zc+|hPj0mtnK~SR7!D7H>hXhy9bznUPJ{B%6NeYZp3t;<1p!R?ufOZ3DKNJj*-CrCE z5(+AR4v>UUPEP@w+EN{$pgEWh85;V6pVqe-V6yAmztgRKRf7}gRG)9N?-_v{ytd#1 zdgy0e5g7)oRqG#MGTXC(UtxKAcV{?_pQ4&5HUYE?h_HURf+KTF3m{;km4JabIsPZxk6K{Ohhuau*q@1DmA5CD))W-mboI(scS#N{Kn5h#a$9vmAT9sLdfHo6}w z%IWF516VbJUlj4^_SC*S5WS1^s6Hg8AR#?Bj$SP~6KiNh1vG@k!6B4eSUDN#gKKv6 zvcL*|ovxLh0l?tBNeL*(;d4o0Pc3>n`XZ{?!6}d(sAv0kmvg;m;#~r%6pC`T_>ZZtyt}dwA zy&}NxY-Ya{L0~74&Pgmkq}`d?I&dLCU$AJ{(;s_KuGLk~FZt=8c5U=e*X5tFx0>4> z!fj5iE{eh7p^@pAmbKr{)L~?+yuSxf^^x>vuT1%4@qtBMzYeJ#s@{9%(1AjbhXa3`#+k9od9DCJ{*vh#{DN~V zvY{A>!-Fawg~SBxVgRg{006IbOL7`t1ub11L2Nl-7(MH~Z$R()nheX}?mYi*+bq-2 zt&Kt&PWw`)egUGNMDKEAb$aGg6W&wEyKUWG*e&3NlckXz8y5fQ#WRGlne7GFO~A-1 zQuMw9F(h-kC+TI_%x&_ol;!w*7C*cC*%27P9f35hbPa{oH_B<3m|Ijfa?Nq9hyWL{ zjt;$E)h{Ee;u;umV)@~`&J#`sdGyi|%Pk6;hRM=8q3p0~ciO$;@23?{q|d?6OVE|M z@6WMmjPZ1?q3d_~=y@2(9z3KtsNiKtUY{}44=Q-GsJz?V^^n;;ck;vS8%2G5AySrd zR$9)%XZ{)#J2drGI?)_Y{$)+*(YF}OUDwWWU)C$rd2)To3vRn%`-Rb`rgnkx&wNL9 zhpMbr8q+jirp9pmYYs~Bz_%;m@b{w`UXZQT)P?hX{8A1_fC3Qwv-L6QqWc)5p_ogN zk9b+5W7H=Rktby6z6C8q3aKMww8?Svnu99hCC0BQFzwl+bkn_3Q!7KsaIm`qzAkbW zD-yC@UGaq%OyZu1jFfj;vOp~XE$L0jd-jodbxsJxIo8i>7|ZA%Vr*p;yf0xnXLFDz z`*ouUNA3`?4278>9$_j_dor**h#tuc?$l6T-~sbg+~hX;9^-ZT4om}nvm}uyZWxIt zXLZ-SS6wdJ+KE_Dx2&)Cz>}g&e@Y1;_K8;xo$7UVIu|DY7g5JMMSXgzI5-`}*(=o) zUcT=zId{QNS(SzW-?=niH9X--A3o9v`H=EptuZAsA zArqX#QdSf;Q#OEG58e4*p$fJtS@9&IZgteM4f!Z6QXw`#j-Df@SjZ!DVO#0t@s6(S zL0%2Yke0Vni2;m#v^KqE*qMc2kn@qthUV&HMY2u`$mYb*9gL$DIb{PFJ>5FWhpMbq z-^dKMV11|g9ABxarz+Jtd0MG7oVq4X;8KPQ11F=3Pa?_o2Vvigy&%n( zFMlV3H!GM8npPj=i<)j2{n)qzd{%wSg{KN+2<(wehddVCQ> z<;|bQV9tC)k$k6%X(DZZpSQKTJAdjJq<^Xgk}>ei2Rw4XEj&9#7jvO@qrsc;PfL80 z?{X(a6PZ^wRvs7o$urG&OdC*J!5G8+3>T=h*Y&MIv~y7W&)bORFf~0PrMG*b?fd2~ z#k!-FkAGrxB4BKTw(IgZ;9e=+B9LErFnG@78bE*KXoGKvM)5USoT0@oGaf_y=R$p%u=BW z;I-SL>rmwN-gJ-GJfpqMwV+02in+-&rusy$RZ+QVcV7;%8RyX80;2lSj-4br>G^GZ z<%#p8R*7=7RjjX}C6vdAjDg~i0()S!NO~9e5ybRh-fLJGzlf&RL)L=r}KbDk{UU(fx3Ep+z=FK8B7Gwq>Z^#)p5MRFmN_y^rbH4@P0q841n~rMOs_Z zqZ+De5Yoh%-;WibdEqUi<@B|x3(<{znjm^w6p z^7Uyp5yO2v=lHpYujBmjj(DNY*E*lCP6gkdiEvf_Hw(JRT`xcsHC44qd7CxF0g!a= z2mKGQa9ap7X#6ijZ4t4Hz3CaXnms%ssRq(48w_;9;fXV&4O_r(f~%_FXWSV{Q?A79 zHIf+w3wHAR%9+Qgu~uX+Fi!N6NO#(qV@-MggtID8%2j*{TGPB#YH?lcJibt$+B8_+ zz_)j4hMBVa;3<6-v~hufYo{%Tj=IDEv(`e zMZ_pgjrs{`G}upEvDpNVr46-A7)1bnkdw%&t1o5WQeRogbqNG6CQ8!zEuYXaS>X3k zg`45K!gl(`znf()yGv%Glgs+vhE(Uv8rT7)o$Hgpjr_ZpIYG47isZCG`|7YphD;0$ z;S6n5q*}Byh()+`VbncP=)XKdflp5^O!J@+0uw%*u+ii|O1R=|W#RD9ew~%LABC99 zO)NE<%;|Mn0fZFQL#WMOo5MF;QbNRmcp$klQTcpC#c{+8SV7eo8E>uq8=qQk&2ip2 zU6jEiSKFpe=b#Q^5MM-v< zIbJAFzSw9vg%amNG0gec7DKGS!7L)|m6zipUSeqKz3r{MzSC$tQ}j=t*{4|MPe!FZ ztCzBgxE0Abs1Xs|`ZPajQZm0Gk@y6cQZQ+hkxqpc7oX%B<6#w!TAt5UhWqbpNo=Bw z_m8DoL3X8eh^U2S81AifTk@^!ln?YmdlFEj*Vi(~&vb7|(PqAAHPDUWhQIGah zyhIp9qL@KmTS_xDUuCcM{1gl=OA(P{9G4}blQKWWHRd46oLk~bnQP6@$n#=%YIhk5 zkSg=!&3J)}RQS_+Q>L(g8qbIT#5g7h9R5m3oiL`*GCItIp+y;C!)^u)OZy!fvIJj( zdiblN@j(W8X}?f(+Hqd279@ zx#lxdna7`N3LRrh%dt9pP_YiR5>tsaN<*ueXVbI`NY<%XK-wH=smB6O&GkQeo0Eqm ziXi$os>QknU7AFpj=E>}miCkq_@YDl2oV9=VFUw|pM*D;E|2d|!hNsKJ(GBbE`fbz z0i27D%JI^w57aUmvDUiKz*3Ka);ga^V|D=?oZYzGADDbEgUUu$`_$!!yd&J?A)0-0 zV{ybAwfAdi4T~4L+-u;5fU)KD-LW-oM#@`SOXZb{Q7Levx>1%97wY47EYz%N7#R6q zns!#zwzJ|hWepyky2xjh90cXddD?5znP7Mw7n!LtKH$sqTr5-dC^yV1;TH_iAWvGn zl!^7}$ZjD(Ekx`RBwPfODOMhQi5%Fq!@k_d#@(^Cx%`Wr?C0gH$RCaT>cW`tjO{WB&~g5x)4y*Q9=y zq?Lb6XJ>yb{;AXO>S&{;XmMTI0M%>Xnv@RlAERg$@@Dg84G`=UI*5fY8 zY5z3i#?)CQb!fA#^UX=5tNgxsD{o2rO&Ft#LE(S@pZ=O(kTGamFOKTNvp&o#%@%IZ z05?%Tt#6Zc3H%x(pQ zb_jis5T&YsA}5#d`qqIPH_q-%`cG{{F>Xo7z+&utVu)q+yKj4rpj&m@ha-&;)?{S0CD{(c@F zPKB!yg+7}P=bBJN165A^?aqurR>}o!MC_WrFe4~&V*ja_9<$ez0h^hQRbYjKWs2kr@XJc&1*3tSm8{_-UKPA+6h&OyyOJ;JgqVbk zEoK{Gw?lHQBp};*EtlF8Kv&r)aD0m0kxj8mf5R2D` zlOF?zvo6fxf`+>3LEfb$_GUTs4r2!ReTkEz7TzQxA*gqh>XeeEV!SR> z7Rq0vskR%fCp4s~6%QU0q+kFNZXy0C!yNBAR>Ztf2x6hPyD@97#8DRIBdx$Sozc?Z zsA_VWA2FC=vd1rimc(+%%$gxOmzHH@Ety!`5NMppZS`Ak^Z^u>ZX0XecYjk+T5R=! ziYKXn9mDjtPp~)GQNaT`>TTBX%A<95`_0jJ7+iyg{zm7_O zQHqBs=~WyI^CW-&`F9j=P3*oOnvX>3?_E0gzPR};sTUEhKhQR~{uaGzs5GYDM=IeC zl#HvV60#zB6IEh7X5xH~1NF#N7hQ%68tijhN`kA}CN_O=Gfhg#*taiRUX4C?W8qYi z^=%Qs)OwbJuPu}|Eqxg5Thas!qL89Cb3~m2(Zx8`>MU~JITta?Z3!mcb&|BUJcD>z zK8fVIMKjl`SD<{P*m3C!HF)1xOK>VBm+nl;MP}U}CZQA-1JnLp-5qrkk=YA*)RV_g z9Ip6uTafUpSFFr4F8O=c7x^RXO>mK1eW{wPOq=?OUhtPxeE>`tHTeoq$ku)v`P?>x z0tL%SMss*HCtVmZV;hM(-t!is>BVP;;;bLiVraA2me;QPIjpp>r#neAiV}oRR<8%V z0tK{HY$I7YLYTY8Y0m(h62itMxX;u3OU>M#+{e zgu;|&2x}Nbr(AnHl&QwZveYv6Cldl(cEVi+zVbM6WvnKozyTpALg|weJYhVMMP;wU z14>iv0$LL0K6ipG`a~GNBHlH0fVmMQ8BO(uKGj&JT4_ak22yDhsh0 z**uzdS+#=H&a~^$@7to8xYq*!Auo4=?|c0dNDT+VLLB*4UDF1p2QQ3h z5=CcTs#K-pu2J_yoOjcKJ4Xt(-kwYs_ns?~dCf1T2(dAy=-s=p*sb>5;vyd!KPq zL-|~S=SsaaKUyN0I@eZ&%vV+1BV?lD$NgajX?R?Vy?3k(-0d=X=wpLh++>kZOd^b1 z9E15XEyo7Au9djH^rHCpEkl)rKl2TiiY7hxIsJz!^l^52Sut5hN9Pc_r~a;~ z20CHKxOm&2y$Kg3p+tJm%lJg#gS6e?$~)w)RD_7Q>a_f)xTp#5p)g`oZ8)9QuW+5$ z@rB7zZ-B1EYN5IiZd^~CzKY2@n~-qknM%Cs5b-=l$L5bsKF_j+H23T6T^5r4btmJC zc`fle@)Yuz>zsGh&BOx7jcT|3BvHC#To8%g+`LgqB){)rOt)F%dv-Adw3GQ^g{*M> zXTJO>t>v*v=IXx?i|pXR6x@^~2XNz#gEuW+xv3j6*Ne<@>i)(F`e#F&lx=2JcDZ8W z`^mix&z@9^SHyN)>7bSj5`9ijLlJj8A;Wa1cGUK@P0l_ZC6iCQGAQMxK|S@?6|0OR&3P^ud{cK4>y!tBDy+i}?*Ps)Biczw3Crn<}GeDJ4?@=``L+ zgDIzl2O2Y3=#Xer-`!7hUmX|A6Ee%0(Gc7Q`-I<~X}JgnYipN#ig|uiobVujvCO8t zllK+j%k>G!2a_c@dTPo4Czi74dBnS3PylJ&fZY%h1)R{XG z)UTUXR}Wdfgy&dwpq-DmCxkwMDTcmScKfsc6CvtxKJVkAwD`o^XEY~ccYvRjt-chi z(T+ip-pO@hd5S@~(UnY6}HmGr!+BWauJMs{-G>%q*Zn5r3!;3k` znRISwZ)K?|*s7Rul4X`UYP5sn$G5Fq27U6}4?^vPxI?*oq)WleBskO|T|6$HqA2r}3nbspNu$+r*?SgKAK6AV!W-aTCadk%? zIm)Pf{j{4-37)G|PqhxNa%Yofwqc%R3u-|`QjvEDQT2!xsX!iFMe;WpR1KSLbX)v8 zO*FKA3;*SmbA2rsd&hQ*CH=WHu1$#2RXC2&j!d7ghaMm&0j13S=1u4LR+N3T-`UHK zxpH?V!9sUbLGq*WUH(0-kOH@U%M=Lhl@Kcl1?7zV5^?`0Rll>-#@j*=Lp{aVHdugf zdvuuL1Mu3yG3&e`o8c3>4AULZXuYDFll3^$cEuu||8CCIkoHbl6u5Kc7>>~c;KK-!ORGje^4*u76JJ(oi zt4QEYNu)46=F_-nOk&8krl2{4B86%pOvzm2MaQcm)t1Et*DuGlPaOT$E=YXuW~VT6 zcymq~!YIv#v|bh~T2@<0-+G1|u|xeF#Es};vi)%vSnvH#_JurP)g7vCfm<{(7Kv!8 zlL{nwX(Xe_YB6Iz8fg1gHbnM?yV6vJX*%qv%6ZTr6UU3rbZmK%h#AZLmGG8Mh~Ooi zW0EQ_W#fI)VcjRt@~)R!;k7EH*25OS3r_a;W0v{dBNlX&#l*f5U`M=H-ckBI1iU9` z?&yiKm1_1ZN64`r`2>U&kM``dzwQf5=`9(vJo_CB8tUSGBaHU!*XwBN06wG5nI0=Ijv@IYgV0<-ZRbG<8f=>nWycdIu8kD8 z#2}$plxCM&DHbiGO~^%F^_bJ8m~N zGx$$_{JkcBK7JOXTvcngRdJIq#|Qjk%1x7uBm0y1fk<#=TrZ`L;Gq1n`Zs#%>dDq6eTvH7xG268MQgyer z;uMk33V(ZTSxhSBWtvR{|s-r`{o1*0i8F}7QDz9QYZ5sHwfxh>m=K3oYEI0$6G ztM#zS;^!l#jQ}~KCNoSsYACK(z|a&!Y2ER_);i0NspPk zveMQUj(4dF(iOC|k9)HnY}}@C)I=uj(M;5|L6~QMmCF}ql{NmzkZT>0sX98fY-tnt zzFNLRO1^WE8TmXTnGz2-+cHQLxg&=_d4-q}O5?pchkCXGpKr+)z4Sm#fjN!13wFhY z*oL-+fY@S`psg0ubh44+o=_q7thI40j+VmRU=fOXfg*(;Sl>sUWYrwV!9!TlXnuo$XHQ)`RFOA~TNJ{Zl=L z!I~CyV^;erU@P81p>(7;z-k!&L`IfPDFg{^QM&jV<(hgK_V-5FdsN%rJE)dSQ#h<< zs96POW{3QNULmT_6C;DI_L*%{Y@J&}-Uw_&W%0Yw&boLw5mRDdrOrPymd@RkR1@*Xmne!CB6v?Hvfy`#*DF@@?5vI_C6UGF z)2!Ca<$gChES2I0#>iA$xQjQ!$YJu0mD&oq#-k9yeiC@S-OW8QogmAdQ` z)+GltsO+|H@**a6~180}oJ+w>V(shh4uB2fj z#$Ki>AA0+T6WF;6ogM;xTDHQ5=Cn9FC~MG9;Cw{^2Ug)A--ci@XS_o;rg})PqXO=P zuYt!9@5XEQy%+%M-m63^&Q?6$8>T{U0O5as$GWRRxQ_^w=^N*5_fEt|p}+`9x$Mme zVx^E$wP8O8A29jPy$7JA%24;_4DFEst2LKLM-OL?({9z$K_Y3Em>6;V7hY+TVGs8k z+`i^=GTaYWWpu`JLPY;L50dL;^)ryii6y(%;vm2jGr;x>KN&$wFonYBCr^2VY+gq% z>;+amLSz}1tniJwGo*AHQY!I@%Z4N|d?da!2(yzx|)^YYGlU5jB zJjd)JJ+VWB6MD0@F6Mm@oY|TV{A#2{zZaUykCKLjGBQT16ytuL5Q~ilr=2KJtVdNW zge8+agtdH|z;?XSKSrLpqftKQLJfy(^2J{d=mPKJ#wtw78wDkERr8L=2WFd`SeHWpSuCTrg#1Dw z1-h0|BW`~>anT*NV&OJZ65SKP9aRsSHMHQcC@v5jxD^mxoakC!07Po2lL8;w%&hDw zwVm<8E+*zsJ;X6=W5&PnsoK9O+N)1gl^))(r7W|#&^v}@xkxQcD7#(r3*fbxb{9IA z8%OxG24Zh$CES4*;&MT&d3ltHZCePL!u4_ld4rirS_PqEc>=$Z$;5+51S9>3g-NB; z%4-3{F%=aYz?}D{#g=9N-9=Brk2`-Ex)h47jr#4uikdjOHfe+)(`oSJT~qsc+lP=U z+jpf8d|1jNFCs}!Fge9U^|g!({ZphPt)UjC7WOe``pcbpM|@d4)EOE zzRqp|09w-@E6d)iYZ}nwv#Obtqn+%^TuXYVG`&u8mV?}n+q#7aL!zu`{E`d4bu!)V zVK4HkDv8&vGV}9Cq&hdN;s8zJG8|KgR3JPsiKe`-QEC`hr*=`g`6@-R`ou~pQ+&^UZ**+t-coy$J zG{{cU9;hHK&svYDDW|9hqNHRa`i{obhqj!G9QRQ~EO`E?87=ZzV{4cLSufpwMb3sn zB#;l+Bo95nKEf1yE#8tZe@vnzyAnx+b0^(Z&=zeN;HYwh(rzUZw@C`Mc%te^pF0Xc_5P80Z)|D52aIEnn2MjsEBINi8)(Y85!Ex{6{S+X6B9rzuW(=iH1P!SC#yGYXW9E zMixd^P9`>1S|&QS|El#rD1Q$zJOa^ zTFuyG^Ql4@u#B|EVMgn;c#X2UZHdSOhMU?5wt&px#Kv$;ry}G@2^z(6QjiG@1w`67^fJP}Zbq)sJyFh!b;s|6?# zaK=Cp+lE**ga)+Jh#D8Slzm8lK?ZLGHT&I4;eLXYQ;SjYJPHL7BTsof77s@FZJ>sC zVCW+7b}}MQhTQo6U?p>(-xV0KY0AumV@{@m!9_gm8MxkOc_U%i8T5%iwS`@xskwomgWnUOu+c28u6Pzahh{Q+VIk|M4Iu-*RZ7l};k)|32)v#Zolqs&$sg}?v zQ$vm{M+J$pz|S+0^^}&~QN|u`YRa1&0N8g4=4&H(-_2T|>5?aW`%N7__;)r^ZmWB_ zp>I*a+<=xSAdmIu9Ss*-2w%y2p6hwfSJA%}wt2}_>2Yt3P3gi3f18dNE@FK)6wW(W zXHNu8h|`8J6E*soh)v{DWEP@bJ}*y)NMd>yNR}c8LQDo++~ZDYpCK@t4=5TuqAaI# zv+x18nNvQ(3`=o_5+|-j$%3ono#BWuUP2>JqAeEEB0N|Ofgcf`5V{HF8VCZrHZ=Ae zRgFXNU|o_+QvzvFn8)fLmxQdypwIwGF~I|isxZACu7 z8-$=ax35`_XQHamN4cEv{AL7Kk8{V<$oIUvQi$1lFPt8Zkh_$c zDt=_z$(0*(+$d#>z5-zxo`sUW^z@o^@q9(!<9fxMY>!QKPwe}>$@kB9nEkmz7Kv_@ zJoCc>zN{nU7 z&1BjjPRoRY;%1#V5!LdVbGASAg~8>)UQ1l_DLk`m&iBGjay;10~QdAY!*%wsJJ zG^kkqnMzcIW?@7%k8^PhajOtaj21lBNMXFfdA*bw8VY8AC?wCuU7f?lx(UyN*_1Jd zgd6gz8s*_K5>=Yn7O0v4Sj@^v3$NcxFC%esQ5;p4)SyBxJQbyq#gtde;zLPsb3gNP zMe_RNMAYWP#}z1K{>=a3D#4NVtXOE0u8V2Z&XT{N0hFK}+rToR7F32GKYOMN53XC6 z=eUbsh2cOg-~u%%fE4wQ7o9~hfHfk|V<1Hl4l6Tedru4wEOx|!yn-n@A_8n>2FN*%&OStyS@J{ts4Jdn^NLnr}T+wd3% z<1*Y3kUrv~`Vby(S22L*B2F8F$`Uw%FjJd%lj2M|GjP+cdYpfz4ClPx{NaD`9`#rD zR%}jk6e$-$k-|}t3cgi%o>;3aq5Dey|(-y9%$VSSyoFa90rom{sRh$}pQRbEukM^Fg`yp@2q_7wtuM#80pTL;s@krSNp|c7#_BSKrndAo0+;Lq$4YqS{7_ z)js2_2B)B^+;jMoOnqg+?M_Eo>yZpqg_=OwsKz37nv{JmRZ-r5@2aJKlUI@_Pj6Gz zxc*+*S3pHf|J0^uZha3($^PcYTv^F{a}LZ@NnkDVYHlrqa(w|LU6!TEH)yKjFeT;8 zo3S$7Uaz!aG@;dM!swA)t#ma(`&UOti>75UeaKr*4s;qSQ}4( z+U5lyp1Z|R)zx>pdc%p)M`?1pcp&4=SW7QaAGVs&@&4qYMLzqd+4c3Y03{UzmdIyTl-mQ-0-Uq=C8J2is~5dy|JcI7Qtt7@bH6nH%Dn*M|W=GT1a` zB&8sLY-c*+;zeSC_q%T0KLQi36-(yK;~Sq(TSp)Mcwp?+i=zV**5|Y3@Q-ikm)HsW zS5DZ|-GKgxdulX+@VohE^{A=>~X-AgmT2OYKd9RtL1kx z{sSO?hJb|6G_(&VE!cz6c+G3<&s5JXV$bm(zCCuYaZ|5p^v|4NuuC>9x9^n;cJL2L zV3z`*#+t*D8X0`CZwjuXpAN#X9kKYW7kWJY9ohKTsp7;WlHW0HJjtk>qyu#PQgN-y zf}B0}ncVlP_shO!Je|v{ex-kS#{n?ll2iB#7y8h6Ri=%v>x&zFK92KSCSnuCehNbi z3>lpZlmi!TrZ?qr!M>5+OG#rix<2|p#GFWIA7Oo>V$d>mxt&Nf=5JfZEEbeH)kjW` z=j*i#V5Pt-0IMo++DZ9Gg6qPN*(z`(r*C=X^eUpUvAwyG6?%zuxEEz-k~k^eP*v|1 zmbAN3IRvXMwGGh}{+MiEH~D$z)*QX|92a=vthOb!41qNS+lt$ISBKk?3V4K@D@jwI z5I@Q;X~`Xt)g-^zXP>(vC-Q(k7)o1?j{p(hq|bT{4>Lus-7_N=s^d=&4!uc-zAd%B z)7`Iyfq&#ZU08ZKbbmt@VQbsCDJrC)^q@u-*o_0#;oY1_c&pH*_Wq`RB>YgjGI+dn#(Xgfj+Ca4b!n0j3cZY|X(zDuLL3a5euyYp_Kc^MA!Gc-yjBSC%(6)ev^*h0X>HyW!XLhF-o#u(LM4E<-*YT z1ffnRKd>4T=K)A|1Gb=f*GBcJYyEuOCc-VM?Hu11TVs7A zum-1MT~3JvXECEf&47YOnqUwfQ}-d)fxLj`kdVaef=2iN9OXO&YYdt-uRd&8I_$E| z?Y}gt2H1*A;4L=OwR|g>jG54$Xr=KKs1Lq+h1E+tuB83m^-8hzA2IFmR+8#pZ-zGd zH`>)~F>TO9*n+mKj+K0;v$!o%%l>u1#FcrA%`EMDx$MSCqqo>QADHd7n|9$!tr+NB zJWEhddgE5M(?j%HerGUC0<sjn+Xvi%CReL5&@>A!VV*hLQGI#DtY`>!)HD~QX z;3n~#q8dFF49Duic5a^$?Yw3)@7A?Uizo6QxSRX5Y_hR_Ug+$|r&^2U8aB?KTBrN$ zn!@^G_vv11FD!e1K=!Xff!ltLm^PLc@OX&ey45zcOe_&Q#`V<^uDbZ>F-R z>}UTYAL6Qg14~~Ev!4+Wl$yq+@0pj9TA>hapkQtm%cUQjS(OT8ap{LEL>np?D;NUB zg7WiA6wHl*{gfb(^0a&fb5O?(#BouGwsCbaG%_uEi z!2G*_<@tu^C7&g?i%)1w5uKmBja%2EfzRhq%hgjyyu_9zNEI0{`_5>!oYBsD!kMva z1Ba?c^xNeXyHf7{bJLC1FAvlX`>(z#iFe=eG9dO|Ou%d3)T}-oE?4 zoA>ue#jMM9ySr{}Vn4hh_xED)&~mM>i=_%)me@|ZTpM1$bdHP@X0#QTBo>ua6agd3 R(A2=d+>%RG)z#mP3jjC0jn@DG literal 0 HcmV?d00001 diff --git a/x/rewards/handler.go b/x/rewards/handler.go index 720831d3..a1ee96f4 100644 --- a/x/rewards/handler.go +++ b/x/rewards/handler.go @@ -32,6 +32,9 @@ func NewHandler(k keeper.Keeper) sdk.Handler { case *types.MsgExitStaking: res, err := msgServer.ExitStaking(sdk.WrapSDKContext(ctx), msg) return sdk.WrapServiceResult(ctx, res, err) + case *types.MsgClaimStakingRewards: + res, err := msgServer.ClaimStakingRewards(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) // this line is used by starport scaffolding # 1 default: errMsg := fmt.Sprintf("unrecognized %s message type: %T", types.ModuleName, msg) diff --git a/x/rewards/keeper/msg_server_claim_staking_rewards.go b/x/rewards/keeper/msg_server_claim_staking_rewards.go new file mode 100644 index 00000000..3ed59b30 --- /dev/null +++ b/x/rewards/keeper/msg_server_claim_staking_rewards.go @@ -0,0 +1,34 @@ +package keeper + +import ( + "context" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + + "github.com/bze-alphateam/bze/x/rewards/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +func (k msgServer) ClaimStakingRewards(goCtx context.Context, msg *types.MsgClaimStakingRewards) (*types.MsgClaimStakingRewardsResponse, error) { + if msg == nil { + return nil, sdkerrors.ErrInvalidRequest + } + ctx := sdk.UnwrapSDKContext(goCtx) + stakingReward, found := k.GetStakingReward(ctx, msg.RewardId) + if !found { + return nil, sdkerrors.Wrapf(types.ErrInvalidRewardId, "reward with provided id not found") + } + + participant, found := k.GetStakingRewardParticipant(ctx, msg.Creator, msg.RewardId) + if !found { + return nil, sdkerrors.Wrapf(types.ErrInvalidRewardId, "you are not a participant in this staking reward") + } + + paid, err := k.claimPending(ctx, stakingReward, &participant) + if err != nil { + return nil, err + } + + k.SetStakingRewardParticipant(ctx, participant) + + return &types.MsgClaimStakingRewardsResponse{Amount: paid.Amount.String()}, nil +} diff --git a/x/rewards/keeper/msg_server_exit_staking.go b/x/rewards/keeper/msg_server_exit_staking.go index 6e66b812..42053e4a 100644 --- a/x/rewards/keeper/msg_server_exit_staking.go +++ b/x/rewards/keeper/msg_server_exit_staking.go @@ -38,7 +38,12 @@ func (k msgServer) ExitStaking(goCtx context.Context, msg *types.MsgExitStaking) return nil, fmt.Errorf("could not transform amount from storage into int") } - //TODO: Pay pending rewards here + //send pending rewards + _, err = k.claimPending(ctx, stakingReward, &participation) + if err != nil { + return nil, err + } + err = k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, acc, partCoins) if err != nil { return nil, err diff --git a/x/rewards/keeper/msg_server_join_staking.go b/x/rewards/keeper/msg_server_join_staking.go index c9abf101..7e945b73 100644 --- a/x/rewards/keeper/msg_server_join_staking.go +++ b/x/rewards/keeper/msg_server_join_staking.go @@ -44,7 +44,10 @@ func (k msgServer) JoinStaking(goCtx context.Context, msg *types.MsgJoinStaking) participant, found := k.GetStakingRewardParticipant(ctx, msg.Creator, msg.RewardId) if found { - //TODO: claim already pending rewards here + _, err = k.claimPending(ctx, stakingReward, &participant) + if err != nil { + return nil, err + } } else { participant = types.StakingRewardParticipant{ Address: msg.Creator, @@ -52,6 +55,7 @@ func (k msgServer) JoinStaking(goCtx context.Context, msg *types.MsgJoinStaking) Amount: "0", } } + participant.JoinedAt = stakingReward.DistributedStake amtInt, ok := sdk.NewIntFromString(participant.Amount) if !ok { @@ -72,3 +76,40 @@ func (k msgServer) JoinStaking(goCtx context.Context, msg *types.MsgJoinStaking) return &types.MsgJoinStakingResponse{}, nil } + +// claimPending - sends the pending rewards to the participant and updates the participant.JoinedAt field with current +// StakingReward.DistributedStake +func (k msgServer) claimPending(ctx sdk.Context, sr types.StakingReward, participant *types.StakingRewardParticipant) (*sdk.Coin, error) { + deposited, ok := sdk.NewIntFromString(participant.Amount) + if !ok { + return nil, fmt.Errorf("could not transform participant amount from storage into int") + } + distributedStake, ok := sdk.NewIntFromString(sr.DistributedStake) + if !ok { + return nil, fmt.Errorf("could not transform distributed stake from storage into int") + } + joinedAt, ok := sdk.NewIntFromString(participant.JoinedAt) + if !ok { + return nil, fmt.Errorf("could not transform joined at from storage into int") + } + + reward := deposited.Mul(distributedStake.Sub(joinedAt)) + if !reward.IsPositive() { + return nil, fmt.Errorf("no rewards to claim") + } + + acc, err := sdk.AccAddressFromBech32(participant.Address) + if err != nil { + return nil, err + } + + toSend := sdk.NewCoin(sr.PrizeDenom, reward) + err = k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, acc, sdk.NewCoins(toSend)) + if err != nil { + return nil, err + } + + participant.JoinedAt = sr.DistributedStake + + return &toSend, nil +} diff --git a/x/rewards/module_simulation.go b/x/rewards/module_simulation.go index 1a994d27..e65e5270 100644 --- a/x/rewards/module_simulation.go +++ b/x/rewards/module_simulation.go @@ -48,6 +48,10 @@ const ( // TODO: Determine the simulation weight value defaultWeightMsgExitStaking int = 100 + opWeightMsgClaimStakingRewards = "op_weight_msg_claim_staking_rewards" + // TODO: Determine the simulation weight value + defaultWeightMsgClaimStakingRewards int = 100 + // this line is used by starport scaffolding # simapp/module/const ) @@ -171,6 +175,17 @@ func (am AppModule) WeightedOperations(simState module.SimulationState) []simtyp rewardssimulation.SimulateMsgExitStaking(am.accountKeeper, am.bankKeeper, am.keeper), )) + var weightMsgClaimStakingRewards int + simState.AppParams.GetOrGenerate(simState.Cdc, opWeightMsgClaimStakingRewards, &weightMsgClaimStakingRewards, nil, + func(_ *rand.Rand) { + weightMsgClaimStakingRewards = defaultWeightMsgClaimStakingRewards + }, + ) + operations = append(operations, simulation.NewWeightedOperation( + weightMsgClaimStakingRewards, + rewardssimulation.SimulateMsgClaimStakingRewards(am.accountKeeper, am.bankKeeper, am.keeper), + )) + // this line is used by starport scaffolding # simapp/module/operation return operations diff --git a/x/rewards/simulation/claim_staking_rewards.go b/x/rewards/simulation/claim_staking_rewards.go new file mode 100644 index 00000000..df5cd6f2 --- /dev/null +++ b/x/rewards/simulation/claim_staking_rewards.go @@ -0,0 +1,29 @@ +package simulation + +import ( + "math/rand" + + "github.com/bze-alphateam/bze/x/rewards/keeper" + "github.com/bze-alphateam/bze/x/rewards/types" + "github.com/cosmos/cosmos-sdk/baseapp" + sdk "github.com/cosmos/cosmos-sdk/types" + simtypes "github.com/cosmos/cosmos-sdk/types/simulation" +) + +func SimulateMsgClaimStakingRewards( + ak types.AccountKeeper, + bk types.BankKeeper, + k keeper.Keeper, +) simtypes.Operation { + return func(r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, + ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { + simAccount, _ := simtypes.RandomAcc(r, accs) + msg := &types.MsgClaimStakingRewards{ + Creator: simAccount.Address.String(), + } + + // TODO: Handling the ClaimStakingRewards simulation + + return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "ClaimStakingRewards simulation not implemented"), nil, nil + } +} diff --git a/x/rewards/types/codec.go b/x/rewards/types/codec.go index 0375d32e..bf0bffcc 100644 --- a/x/rewards/types/codec.go +++ b/x/rewards/types/codec.go @@ -13,6 +13,7 @@ func RegisterCodec(cdc *codec.LegacyAmino) { cdc.RegisterConcrete(&MsgCreateTradingReward{}, "rewards/CreateTradingReward", nil) cdc.RegisterConcrete(&MsgJoinStaking{}, "rewards/JoinStaking", nil) cdc.RegisterConcrete(&MsgExitStaking{}, "rewards/ExitStaking", nil) + cdc.RegisterConcrete(&MsgClaimStakingRewards{}, "rewards/ClaimStakingRewards", nil) // this line is used by starport scaffolding # 2 } @@ -30,6 +31,9 @@ func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { registry.RegisterImplementations((*sdk.Msg)(nil), &MsgExitStaking{}, ) + registry.RegisterImplementations((*sdk.Msg)(nil), + &MsgClaimStakingRewards{}, + ) // this line is used by starport scaffolding # 3 msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) diff --git a/x/rewards/types/message_claim_staking_rewards.go b/x/rewards/types/message_claim_staking_rewards.go new file mode 100644 index 00000000..8a737809 --- /dev/null +++ b/x/rewards/types/message_claim_staking_rewards.go @@ -0,0 +1,51 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +const TypeMsgClaimStakingRewards = "claim_staking_rewards" + +var _ sdk.Msg = &MsgClaimStakingRewards{} + +func NewMsgClaimStakingRewards(creator string, rewardId string) *MsgClaimStakingRewards { + return &MsgClaimStakingRewards{ + Creator: creator, + RewardId: rewardId, + } +} + +func (msg *MsgClaimStakingRewards) Route() string { + return RouterKey +} + +func (msg *MsgClaimStakingRewards) Type() string { + return TypeMsgClaimStakingRewards +} + +func (msg *MsgClaimStakingRewards) GetSigners() []sdk.AccAddress { + creator, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + panic(err) + } + return []sdk.AccAddress{creator} +} + +func (msg *MsgClaimStakingRewards) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(msg) + return sdk.MustSortJSON(bz) +} + +func (msg *MsgClaimStakingRewards) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err) + } + + if msg.RewardId == "" { + return sdkerrors.Wrapf(ErrInvalidRewardId, "empty reward id") + } + + return nil +} diff --git a/x/rewards/types/message_claim_staking_rewards_test.go b/x/rewards/types/message_claim_staking_rewards_test.go new file mode 100644 index 00000000..8f2f6500 --- /dev/null +++ b/x/rewards/types/message_claim_staking_rewards_test.go @@ -0,0 +1,40 @@ +package types + +import ( + "testing" + + "github.com/bze-alphateam/bze/testutil/sample" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/stretchr/testify/require" +) + +func TestMsgClaimStakingRewards_ValidateBasic(t *testing.T) { + tests := []struct { + name string + msg MsgClaimStakingRewards + err error + }{ + { + name: "invalid address", + msg: MsgClaimStakingRewards{ + Creator: "invalid_address", + }, + err: sdkerrors.ErrInvalidAddress, + }, { + name: "valid address", + msg: MsgClaimStakingRewards{ + Creator: sample.AccAddress(), + }, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + err := tt.msg.ValidateBasic() + if tt.err != nil { + require.ErrorIs(t, err, tt.err) + return + } + require.NoError(t, err) + }) + } +} diff --git a/x/rewards/types/messages_staking_reward.go b/x/rewards/types/messages_staking_reward.go index 7c57a10a..7de7aefa 100644 --- a/x/rewards/types/messages_staking_reward.go +++ b/x/rewards/types/messages_staking_reward.go @@ -11,6 +11,9 @@ const ( TypeMsgUpdateStakingReward = "update_staking_reward" tenYearsInDays = 365 * 10 + + defaultStakedAmount = "0" + defaultDistributedStake = "0" ) var _ sdk.Msg = &MsgCreateStakingReward{} @@ -103,6 +106,9 @@ func (msg *MsgCreateStakingReward) ToStakingReward() (StakingReward, error) { } sr.Lock = uint32(lockInt) + sr.StakedAmount = defaultStakedAmount + sr.DistributedStake = defaultDistributedStake + return sr, nil } diff --git a/x/rewards/types/staking_reward.pb.go b/x/rewards/types/staking_reward.pb.go index 82304cc4..17b0440f 100644 --- a/x/rewards/types/staking_reward.pb.go +++ b/x/rewards/types/staking_reward.pb.go @@ -23,15 +23,16 @@ var _ = math.Inf const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type StakingReward struct { - RewardId string `protobuf:"bytes,1,opt,name=reward_id,json=rewardId,proto3" json:"reward_id,omitempty"` - PrizeAmount string `protobuf:"bytes,2,opt,name=prize_amount,json=prizeAmount,proto3" json:"prize_amount,omitempty"` - PrizeDenom string `protobuf:"bytes,3,opt,name=prize_denom,json=prizeDenom,proto3" json:"prize_denom,omitempty"` - StakingDenom string `protobuf:"bytes,4,opt,name=staking_denom,json=stakingDenom,proto3" json:"staking_denom,omitempty"` - Duration uint32 `protobuf:"varint,5,opt,name=duration,proto3" json:"duration,omitempty"` - Payouts uint32 `protobuf:"varint,6,opt,name=payouts,proto3" json:"payouts,omitempty"` - MinStake uint64 `protobuf:"varint,7,opt,name=min_stake,json=minStake,proto3" json:"min_stake,omitempty"` - Lock uint32 `protobuf:"varint,8,opt,name=lock,proto3" json:"lock,omitempty"` - StakedAmount string `protobuf:"bytes,9,opt,name=staked_amount,json=stakedAmount,proto3" json:"staked_amount,omitempty"` + RewardId string `protobuf:"bytes,1,opt,name=reward_id,json=rewardId,proto3" json:"reward_id,omitempty"` + PrizeAmount string `protobuf:"bytes,2,opt,name=prize_amount,json=prizeAmount,proto3" json:"prize_amount,omitempty"` + PrizeDenom string `protobuf:"bytes,3,opt,name=prize_denom,json=prizeDenom,proto3" json:"prize_denom,omitempty"` + StakingDenom string `protobuf:"bytes,4,opt,name=staking_denom,json=stakingDenom,proto3" json:"staking_denom,omitempty"` + Duration uint32 `protobuf:"varint,5,opt,name=duration,proto3" json:"duration,omitempty"` + Payouts uint32 `protobuf:"varint,6,opt,name=payouts,proto3" json:"payouts,omitempty"` + MinStake uint64 `protobuf:"varint,7,opt,name=min_stake,json=minStake,proto3" json:"min_stake,omitempty"` + Lock uint32 `protobuf:"varint,8,opt,name=lock,proto3" json:"lock,omitempty"` + StakedAmount string `protobuf:"bytes,9,opt,name=staked_amount,json=stakedAmount,proto3" json:"staked_amount,omitempty"` + DistributedStake string `protobuf:"bytes,10,opt,name=distributed_stake,json=distributedStake,proto3" json:"distributed_stake,omitempty"` } func (m *StakingReward) Reset() { *m = StakingReward{} } @@ -130,6 +131,13 @@ func (m *StakingReward) GetStakedAmount() string { return "" } +func (m *StakingReward) GetDistributedStake() string { + if m != nil { + return m.DistributedStake + } + return "" +} + func init() { proto.RegisterType((*StakingReward)(nil), "bze.v1.rewards.StakingReward") } @@ -137,26 +145,28 @@ func init() { func init() { proto.RegisterFile("rewards/staking_reward.proto", fileDescriptor_a8c582f9c980c2bd) } var fileDescriptor_a8c582f9c980c2bd = []byte{ - // 304 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x44, 0x91, 0xb1, 0x4e, 0xeb, 0x30, - 0x14, 0x86, 0xeb, 0xde, 0xde, 0x36, 0x35, 0x2d, 0x83, 0x27, 0x0b, 0x90, 0x09, 0xb0, 0x64, 0x80, - 0x44, 0x88, 0x27, 0x00, 0x21, 0x24, 0xd6, 0xb0, 0xb1, 0x44, 0x4e, 0x6d, 0xb5, 0x56, 0x1b, 0x3b, - 0x4a, 0x1c, 0xa0, 0x79, 0x0a, 0x5e, 0x81, 0xb7, 0x61, 0xec, 0xc8, 0x88, 0x92, 0x17, 0x41, 0x39, - 0x6e, 0x60, 0xcb, 0xff, 0x9d, 0x2f, 0xd6, 0x7f, 0x74, 0xf0, 0x49, 0x21, 0x5f, 0x79, 0x21, 0xca, - 0xa8, 0xb4, 0x7c, 0xad, 0xf4, 0x32, 0x71, 0x39, 0xcc, 0x0b, 0x63, 0x0d, 0x39, 0x4c, 0x6b, 0x19, - 0xbe, 0x5c, 0x87, 0x7b, 0xe9, 0xfc, 0x63, 0x88, 0xe7, 0x4f, 0x4e, 0x8c, 0x01, 0x91, 0x63, 0x3c, - 0x75, 0xc3, 0x44, 0x09, 0x8a, 0x7c, 0x14, 0x4c, 0x63, 0xcf, 0x81, 0x47, 0x41, 0xce, 0xf0, 0x2c, - 0x2f, 0x54, 0x2d, 0x13, 0x9e, 0x99, 0x4a, 0x5b, 0x3a, 0x84, 0xf9, 0x01, 0xb0, 0x5b, 0x40, 0xe4, - 0x14, 0xbb, 0x98, 0x08, 0xa9, 0x4d, 0x46, 0xff, 0x81, 0x81, 0x01, 0xdd, 0x77, 0x84, 0x5c, 0xe0, - 0x79, 0x5f, 0xcd, 0x29, 0x23, 0x50, 0x66, 0x7b, 0xe8, 0xa4, 0x23, 0xec, 0x89, 0xaa, 0xe0, 0x56, - 0x19, 0x4d, 0xff, 0xfb, 0x28, 0x98, 0xc7, 0xbf, 0x99, 0x50, 0x3c, 0xc9, 0xf9, 0xd6, 0x54, 0xb6, - 0xa4, 0x63, 0x18, 0xf5, 0xb1, 0xeb, 0x9e, 0x29, 0x9d, 0x74, 0x2f, 0x49, 0x3a, 0xf1, 0x51, 0x30, - 0x8a, 0xbd, 0x4c, 0xe9, 0x6e, 0x41, 0x49, 0x08, 0x1e, 0x6d, 0xcc, 0x62, 0x4d, 0x3d, 0xf8, 0x07, - 0xbe, 0xfb, 0x2e, 0x52, 0xf4, 0x0b, 0x4d, 0xff, 0xba, 0x48, 0xe1, 0x36, 0xba, 0x7b, 0xf8, 0x6c, - 0x18, 0xda, 0x35, 0x0c, 0x7d, 0x37, 0x0c, 0xbd, 0xb7, 0x6c, 0xb0, 0x6b, 0xd9, 0xe0, 0xab, 0x65, - 0x83, 0xe7, 0xcb, 0xa5, 0xb2, 0xab, 0x2a, 0x0d, 0x17, 0x26, 0x8b, 0xd2, 0x5a, 0x5e, 0xf1, 0x4d, - 0xbe, 0xe2, 0x56, 0x72, 0x48, 0xd1, 0x5b, 0xd4, 0x9f, 0xc2, 0x6e, 0x73, 0x59, 0xa6, 0x63, 0x38, - 0xc1, 0xcd, 0x4f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x62, 0x6c, 0x40, 0x77, 0xa2, 0x01, 0x00, 0x00, + // 323 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x4c, 0x91, 0xb1, 0x4e, 0xf3, 0x30, + 0x14, 0x85, 0xeb, 0xfe, 0xfd, 0xdb, 0xd4, 0xb4, 0x08, 0x3c, 0x59, 0x80, 0x42, 0x81, 0xa5, 0x12, + 0x90, 0x08, 0xf1, 0x04, 0x20, 0x84, 0xc4, 0x1a, 0x36, 0x96, 0xc8, 0xa9, 0xaf, 0x5a, 0xab, 0x4d, + 0x1c, 0x39, 0x0e, 0xd0, 0x3e, 0x05, 0x8f, 0xc5, 0x84, 0x3a, 0x32, 0xa2, 0xf6, 0x45, 0x50, 0xae, + 0x13, 0x60, 0xcb, 0x39, 0xe7, 0xcb, 0xf5, 0xb9, 0xba, 0xf4, 0xc8, 0xc0, 0x8b, 0x30, 0xb2, 0x08, + 0x0b, 0x2b, 0xe6, 0x2a, 0x9b, 0xc6, 0x4e, 0x07, 0xb9, 0xd1, 0x56, 0xb3, 0xdd, 0x64, 0x05, 0xc1, + 0xf3, 0x55, 0x50, 0x43, 0xa7, 0x1f, 0x6d, 0x3a, 0x7c, 0x74, 0x60, 0x84, 0x16, 0x3b, 0xa4, 0x7d, + 0x17, 0xc6, 0x4a, 0x72, 0x32, 0x22, 0xe3, 0x7e, 0xe4, 0x39, 0xe3, 0x41, 0xb2, 0x13, 0x3a, 0xc8, + 0x8d, 0x5a, 0x41, 0x2c, 0x52, 0x5d, 0x66, 0x96, 0xb7, 0x31, 0xdf, 0x41, 0xef, 0x06, 0x2d, 0x76, + 0x4c, 0x9d, 0x8c, 0x25, 0x64, 0x3a, 0xe5, 0xff, 0x90, 0xa0, 0x68, 0xdd, 0x55, 0x0e, 0x3b, 0xa3, + 0xc3, 0xa6, 0x9a, 0x43, 0x3a, 0x88, 0x0c, 0x6a, 0xd3, 0x41, 0x07, 0xd4, 0x93, 0xa5, 0x11, 0x56, + 0xe9, 0x8c, 0xff, 0x1f, 0x91, 0xf1, 0x30, 0xfa, 0xd1, 0x8c, 0xd3, 0x5e, 0x2e, 0x96, 0xba, 0xb4, + 0x05, 0xef, 0x62, 0xd4, 0xc8, 0xaa, 0x7b, 0xaa, 0xb2, 0xb8, 0x9a, 0x04, 0xbc, 0x37, 0x22, 0xe3, + 0x4e, 0xe4, 0xa5, 0x2a, 0xab, 0x16, 0x04, 0xc6, 0x68, 0x67, 0xa1, 0x27, 0x73, 0xee, 0xe1, 0x3f, + 0xf8, 0xdd, 0x74, 0x01, 0xd9, 0x2c, 0xd4, 0xff, 0xed, 0x02, 0xb2, 0xde, 0xe8, 0x9c, 0xee, 0x4b, + 0x55, 0x58, 0xa3, 0x92, 0xd2, 0x82, 0xac, 0xa7, 0x53, 0x04, 0xf7, 0xfe, 0x04, 0xf8, 0xca, 0xed, + 0xfd, 0xfb, 0xc6, 0x27, 0xeb, 0x8d, 0x4f, 0xbe, 0x36, 0x3e, 0x79, 0xdb, 0xfa, 0xad, 0xf5, 0xd6, + 0x6f, 0x7d, 0x6e, 0xfd, 0xd6, 0xd3, 0xc5, 0x54, 0xd9, 0x59, 0x99, 0x04, 0x13, 0x9d, 0x86, 0xc9, + 0x0a, 0x2e, 0xc5, 0x22, 0x9f, 0x09, 0x0b, 0x02, 0x55, 0xf8, 0x1a, 0x36, 0x77, 0xb3, 0xcb, 0x1c, + 0x8a, 0xa4, 0x8b, 0xf7, 0xba, 0xfe, 0x0e, 0x00, 0x00, 0xff, 0xff, 0x56, 0x6a, 0x3d, 0x03, 0xcf, + 0x01, 0x00, 0x00, } func (m *StakingReward) Marshal() (dAtA []byte, err error) { @@ -179,6 +189,13 @@ func (m *StakingReward) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.DistributedStake) > 0 { + i -= len(m.DistributedStake) + copy(dAtA[i:], m.DistributedStake) + i = encodeVarintStakingReward(dAtA, i, uint64(len(m.DistributedStake))) + i-- + dAtA[i] = 0x52 + } if len(m.StakedAmount) > 0 { i -= len(m.StakedAmount) copy(dAtA[i:], m.StakedAmount) @@ -286,6 +303,10 @@ func (m *StakingReward) Size() (n int) { if l > 0 { n += 1 + l + sovStakingReward(uint64(l)) } + l = len(m.DistributedStake) + if l > 0 { + n += 1 + l + sovStakingReward(uint64(l)) + } return n } @@ -560,6 +581,38 @@ func (m *StakingReward) Unmarshal(dAtA []byte) error { } m.StakedAmount = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 10: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DistributedStake", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowStakingReward + } + 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 ErrInvalidLengthStakingReward + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthStakingReward + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.DistributedStake = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipStakingReward(dAtA[iNdEx:]) diff --git a/x/rewards/types/staking_reward_participant.pb.go b/x/rewards/types/staking_reward_participant.pb.go index 306db584..5841647f 100644 --- a/x/rewards/types/staking_reward_participant.pb.go +++ b/x/rewards/types/staking_reward_participant.pb.go @@ -26,6 +26,7 @@ type StakingRewardParticipant struct { Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` RewardId string `protobuf:"bytes,2,opt,name=reward_id,json=rewardId,proto3" json:"reward_id,omitempty"` Amount string `protobuf:"bytes,3,opt,name=amount,proto3" json:"amount,omitempty"` + JoinedAt string `protobuf:"bytes,4,opt,name=joined_at,json=joinedAt,proto3" json:"joined_at,omitempty"` } func (m *StakingRewardParticipant) Reset() { *m = StakingRewardParticipant{} } @@ -82,6 +83,13 @@ func (m *StakingRewardParticipant) GetAmount() string { return "" } +func (m *StakingRewardParticipant) GetJoinedAt() string { + if m != nil { + return m.JoinedAt + } + return "" +} + func init() { proto.RegisterType((*StakingRewardParticipant)(nil), "bze.v1.rewards.StakingRewardParticipant") } @@ -91,20 +99,22 @@ func init() { } var fileDescriptor_c38d5e7e7b44d312 = []byte{ - // 208 bytes of a gzipped FileDescriptorProto + // 228 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xd2, 0x28, 0x4a, 0x2d, 0x4f, 0x2c, 0x4a, 0x29, 0xd6, 0x2f, 0x2e, 0x49, 0xcc, 0xce, 0xcc, 0x4b, 0x8f, 0x87, 0xf0, 0xe3, 0x0b, 0x12, 0x8b, 0x4a, 0x32, 0x93, 0x33, 0x0b, 0x12, 0xf3, 0x4a, 0xf4, 0x0a, 0x8a, 0xf2, 0x4b, 0xf2, - 0x85, 0xf8, 0x92, 0xaa, 0x52, 0xf5, 0xca, 0x0c, 0xf5, 0xa0, 0x1a, 0x94, 0x32, 0xb9, 0x24, 0x82, - 0x21, 0x7a, 0x82, 0xc0, 0x22, 0x01, 0x08, 0x1d, 0x42, 0x12, 0x5c, 0xec, 0x89, 0x29, 0x29, 0x45, - 0xa9, 0xc5, 0xc5, 0x12, 0x8c, 0x0a, 0x8c, 0x1a, 0x9c, 0x41, 0x30, 0xae, 0x90, 0x34, 0x17, 0x27, - 0xd4, 0x86, 0xcc, 0x14, 0x09, 0x26, 0xb0, 0x1c, 0x07, 0x44, 0xc0, 0x33, 0x45, 0x48, 0x8c, 0x8b, - 0x2d, 0x31, 0x37, 0xbf, 0x34, 0xaf, 0x44, 0x82, 0x19, 0x2c, 0x03, 0xe5, 0x39, 0xb9, 0x9d, 0x78, - 0x24, 0xc7, 0x78, 0xe1, 0x91, 0x1c, 0xe3, 0x83, 0x47, 0x72, 0x8c, 0x13, 0x1e, 0xcb, 0x31, 0x5c, - 0x78, 0x2c, 0xc7, 0x70, 0xe3, 0xb1, 0x1c, 0x43, 0x94, 0x4e, 0x7a, 0x66, 0x49, 0x46, 0x69, 0x92, - 0x5e, 0x72, 0x7e, 0xae, 0x7e, 0x52, 0x55, 0xaa, 0x6e, 0x62, 0x4e, 0x41, 0x46, 0x62, 0x49, 0x6a, - 0x22, 0x98, 0xa7, 0x5f, 0xa1, 0x0f, 0xf3, 0x5d, 0x49, 0x65, 0x41, 0x6a, 0x71, 0x12, 0x1b, 0xd8, - 0x27, 0xc6, 0x80, 0x00, 0x00, 0x00, 0xff, 0xff, 0x8f, 0xf5, 0x58, 0xfb, 0xf5, 0x00, 0x00, 0x00, + 0x85, 0xf8, 0x92, 0xaa, 0x52, 0xf5, 0xca, 0x0c, 0xf5, 0xa0, 0x1a, 0x94, 0xda, 0x18, 0xb9, 0x24, + 0x82, 0x21, 0x9a, 0x82, 0xc0, 0x42, 0x01, 0x08, 0x2d, 0x42, 0x12, 0x5c, 0xec, 0x89, 0x29, 0x29, + 0x45, 0xa9, 0xc5, 0xc5, 0x12, 0x8c, 0x0a, 0x8c, 0x1a, 0x9c, 0x41, 0x30, 0xae, 0x90, 0x34, 0x17, + 0x27, 0xd4, 0x8a, 0xcc, 0x14, 0x09, 0x26, 0xb0, 0x1c, 0x07, 0x44, 0xc0, 0x33, 0x45, 0x48, 0x8c, + 0x8b, 0x2d, 0x31, 0x37, 0xbf, 0x34, 0xaf, 0x44, 0x82, 0x19, 0x2c, 0x03, 0xe5, 0x81, 0x34, 0x65, + 0xe5, 0x67, 0xe6, 0xa5, 0xa6, 0xc4, 0x27, 0x96, 0x48, 0xb0, 0x40, 0x34, 0x41, 0x04, 0x1c, 0x4b, + 0x9c, 0xdc, 0x4e, 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, 0x4a, 0x27, 0x3d, 0xb3, + 0x24, 0xa3, 0x34, 0x49, 0x2f, 0x39, 0x3f, 0x57, 0x3f, 0xa9, 0x2a, 0x55, 0x37, 0x31, 0xa7, 0x20, + 0x23, 0xb1, 0x24, 0x35, 0x11, 0xcc, 0xd3, 0xaf, 0xd0, 0x87, 0xf9, 0xbd, 0xa4, 0xb2, 0x20, 0xb5, + 0x38, 0x89, 0x0d, 0xec, 0x4f, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0xbf, 0xc9, 0x2f, 0xb0, + 0x13, 0x01, 0x00, 0x00, } func (m *StakingRewardParticipant) Marshal() (dAtA []byte, err error) { @@ -127,6 +137,13 @@ func (m *StakingRewardParticipant) MarshalToSizedBuffer(dAtA []byte) (int, error _ = i var l int _ = l + if len(m.JoinedAt) > 0 { + i -= len(m.JoinedAt) + copy(dAtA[i:], m.JoinedAt) + i = encodeVarintStakingRewardParticipant(dAtA, i, uint64(len(m.JoinedAt))) + i-- + dAtA[i] = 0x22 + } if len(m.Amount) > 0 { i -= len(m.Amount) copy(dAtA[i:], m.Amount) @@ -180,6 +197,10 @@ func (m *StakingRewardParticipant) Size() (n int) { if l > 0 { n += 1 + l + sovStakingRewardParticipant(uint64(l)) } + l = len(m.JoinedAt) + if l > 0 { + n += 1 + l + sovStakingRewardParticipant(uint64(l)) + } return n } @@ -314,6 +335,38 @@ func (m *StakingRewardParticipant) Unmarshal(dAtA []byte) error { } m.Amount = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field JoinedAt", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowStakingRewardParticipant + } + 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 ErrInvalidLengthStakingRewardParticipant + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthStakingRewardParticipant + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.JoinedAt = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipStakingRewardParticipant(dAtA[iNdEx:]) diff --git a/x/rewards/types/tx.pb.go b/x/rewards/types/tx.pb.go index 2501c9b2..a30c2ee8 100644 --- a/x/rewards/types/tx.pb.go +++ b/x/rewards/types/tx.pb.go @@ -571,6 +571,102 @@ func (m *MsgExitStakingResponse) XXX_DiscardUnknown() { var xxx_messageInfo_MsgExitStakingResponse proto.InternalMessageInfo +type MsgClaimStakingRewards struct { + Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` + RewardId string `protobuf:"bytes,2,opt,name=rewardId,proto3" json:"rewardId,omitempty"` +} + +func (m *MsgClaimStakingRewards) Reset() { *m = MsgClaimStakingRewards{} } +func (m *MsgClaimStakingRewards) String() string { return proto.CompactTextString(m) } +func (*MsgClaimStakingRewards) ProtoMessage() {} +func (*MsgClaimStakingRewards) Descriptor() ([]byte, []int) { + return fileDescriptor_4c0d543e6be8610a, []int{10} +} +func (m *MsgClaimStakingRewards) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgClaimStakingRewards) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgClaimStakingRewards.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 *MsgClaimStakingRewards) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgClaimStakingRewards.Merge(m, src) +} +func (m *MsgClaimStakingRewards) XXX_Size() int { + return m.Size() +} +func (m *MsgClaimStakingRewards) XXX_DiscardUnknown() { + xxx_messageInfo_MsgClaimStakingRewards.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgClaimStakingRewards proto.InternalMessageInfo + +func (m *MsgClaimStakingRewards) GetCreator() string { + if m != nil { + return m.Creator + } + return "" +} + +func (m *MsgClaimStakingRewards) GetRewardId() string { + if m != nil { + return m.RewardId + } + return "" +} + +type MsgClaimStakingRewardsResponse struct { + Amount string `protobuf:"bytes,1,opt,name=amount,proto3" json:"amount,omitempty"` +} + +func (m *MsgClaimStakingRewardsResponse) Reset() { *m = MsgClaimStakingRewardsResponse{} } +func (m *MsgClaimStakingRewardsResponse) String() string { return proto.CompactTextString(m) } +func (*MsgClaimStakingRewardsResponse) ProtoMessage() {} +func (*MsgClaimStakingRewardsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_4c0d543e6be8610a, []int{11} +} +func (m *MsgClaimStakingRewardsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgClaimStakingRewardsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgClaimStakingRewardsResponse.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 *MsgClaimStakingRewardsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgClaimStakingRewardsResponse.Merge(m, src) +} +func (m *MsgClaimStakingRewardsResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgClaimStakingRewardsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgClaimStakingRewardsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgClaimStakingRewardsResponse proto.InternalMessageInfo + +func (m *MsgClaimStakingRewardsResponse) GetAmount() string { + if m != nil { + return m.Amount + } + return "" +} + func init() { proto.RegisterType((*MsgCreateStakingReward)(nil), "bze.v1.rewards.MsgCreateStakingReward") proto.RegisterType((*MsgCreateStakingRewardResponse)(nil), "bze.v1.rewards.MsgCreateStakingRewardResponse") @@ -582,45 +678,49 @@ func init() { proto.RegisterType((*MsgJoinStakingResponse)(nil), "bze.v1.rewards.MsgJoinStakingResponse") proto.RegisterType((*MsgExitStaking)(nil), "bze.v1.rewards.MsgExitStaking") proto.RegisterType((*MsgExitStakingResponse)(nil), "bze.v1.rewards.MsgExitStakingResponse") + proto.RegisterType((*MsgClaimStakingRewards)(nil), "bze.v1.rewards.MsgClaimStakingRewards") + proto.RegisterType((*MsgClaimStakingRewardsResponse)(nil), "bze.v1.rewards.MsgClaimStakingRewardsResponse") } func init() { proto.RegisterFile("rewards/tx.proto", fileDescriptor_4c0d543e6be8610a) } var fileDescriptor_4c0d543e6be8610a = []byte{ - // 518 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x54, 0x4f, 0x6f, 0x13, 0x3f, - 0x10, 0xcd, 0x36, 0x69, 0xda, 0x4e, 0xfb, 0xab, 0x7e, 0x72, 0x51, 0xb5, 0x0a, 0xd2, 0x52, 0x16, - 0xa9, 0xe2, 0x00, 0x1b, 0x01, 0x67, 0x0e, 0xfc, 0xab, 0x54, 0xa4, 0x5c, 0x02, 0xbd, 0x70, 0x59, - 0x39, 0x59, 0x6b, 0x6b, 0x25, 0xbb, 0x5e, 0xd9, 0x0e, 0x84, 0x9c, 0xf8, 0x08, 0x7c, 0x29, 0x24, - 0x8e, 0x3d, 0x72, 0x44, 0xc9, 0x85, 0x8f, 0x81, 0xd6, 0x76, 0x16, 0x1b, 0x99, 0x50, 0x38, 0x70, - 0xdb, 0x79, 0x33, 0x3b, 0xcf, 0x6f, 0xde, 0xd8, 0xf0, 0x3f, 0x27, 0xef, 0x30, 0xcf, 0x44, 0x5f, - 0xce, 0x93, 0x8a, 0x33, 0xc9, 0xd0, 0xe1, 0x68, 0x41, 0x92, 0xb7, 0x0f, 0x12, 0x93, 0x88, 0xbf, - 0x05, 0x70, 0x3c, 0x10, 0xf9, 0x33, 0x4e, 0xb0, 0x24, 0xaf, 0x24, 0x9e, 0xd0, 0x32, 0x1f, 0xaa, - 0x1c, 0x0a, 0x61, 0x67, 0x5c, 0xc3, 0x8c, 0x87, 0xc1, 0x49, 0x70, 0x77, 0x6f, 0xb8, 0x0e, 0xd1, - 0x6d, 0x38, 0xa8, 0x38, 0x5d, 0x90, 0x14, 0x17, 0x6c, 0x56, 0xca, 0x70, 0x4b, 0xa5, 0xf7, 0x15, - 0xf6, 0x44, 0x41, 0xe8, 0x16, 0xe8, 0x30, 0xcd, 0x48, 0xc9, 0x8a, 0xb0, 0xad, 0x2a, 0x40, 0x41, - 0xcf, 0x6b, 0x04, 0xdd, 0x81, 0xff, 0x84, 0xa6, 0x33, 0x25, 0x1d, 0x55, 0x72, 0x60, 0x40, 0x5d, - 0xd4, 0x83, 0xdd, 0x6c, 0xc6, 0xb1, 0xa4, 0xac, 0x0c, 0xb7, 0x55, 0xbe, 0x89, 0xd1, 0x4d, 0xd8, - 0x2b, 0x68, 0x99, 0xd6, 0xf5, 0x24, 0xec, 0xea, 0x64, 0x41, 0xcb, 0x5a, 0x03, 0x41, 0x08, 0x3a, - 0x53, 0x36, 0x9e, 0x84, 0x3b, 0x0a, 0x57, 0xdf, 0xf1, 0x63, 0x88, 0xfc, 0x4a, 0x87, 0x44, 0x54, - 0xac, 0x14, 0xa4, 0x6e, 0xa9, 0xe7, 0x92, 0xd2, 0xcc, 0x68, 0xde, 0xd5, 0xc0, 0x79, 0x16, 0x4f, - 0xd4, 0xa0, 0x2e, 0xaa, 0xec, 0x0f, 0x06, 0xe5, 0x34, 0xdc, 0x72, 0x1b, 0x3a, 0xe2, 0xda, 0xae, - 0xb8, 0xf8, 0x44, 0x9d, 0xd5, 0x43, 0xb6, 0x3e, 0x6b, 0xfc, 0xc9, 0x36, 0xee, 0x35, 0xc7, 0xd9, - 0xbf, 0x32, 0xce, 0x3e, 0x76, 0xc7, 0xe3, 0x09, 0xe6, 0x13, 0x22, 0x6b, 0xbd, 0xc6, 0x30, 0x0d, - 0x9c, 0x67, 0xe8, 0x06, 0x6c, 0x8b, 0x29, 0x93, 0xc2, 0x98, 0xa5, 0x03, 0xc7, 0x15, 0x47, 0xc6, - 0xf5, 0x5c, 0x49, 0xe1, 0x70, 0x20, 0xf2, 0x97, 0x4c, 0x1b, 0x4f, 0xcb, 0xfc, 0x6f, 0xdd, 0x38, - 0x86, 0xae, 0x19, 0x8a, 0x96, 0x6c, 0xa2, 0x38, 0x54, 0x63, 0xb6, 0x08, 0x1a, 0x07, 0xce, 0x14, - 0xf5, 0x8b, 0x39, 0x95, 0xbf, 0xa7, 0xee, 0x41, 0xc3, 0xf4, 0x33, 0xb3, 0x61, 0xb0, 0xfa, 0xac, - 0x19, 0x1e, 0x7e, 0xe8, 0x40, 0x7b, 0x20, 0x72, 0x54, 0xc0, 0x91, 0xef, 0x82, 0x9e, 0x26, 0xee, - 0x65, 0x4e, 0xfc, 0xeb, 0xdd, 0x4b, 0xae, 0x57, 0xd7, 0x0c, 0xbc, 0x80, 0x23, 0xdf, 0x9a, 0xfb, - 0xe8, 0x3c, 0x75, 0x5e, 0xba, 0x0d, 0x9b, 0xfc, 0x43, 0x9d, 0xbb, 0xc5, 0xbf, 0x56, 0xe7, 0xd4, - 0x6d, 0x50, 0xe7, 0x5f, 0xa7, 0x0b, 0xd8, 0xb7, 0xd7, 0x25, 0xf2, 0xfc, 0x6e, 0xe5, 0x7b, 0xa7, - 0x9b, 0xf3, 0x76, 0x5b, 0x7b, 0x15, 0x7c, 0x6d, 0xad, 0xbc, 0xb7, 0xad, 0x67, 0x05, 0x9e, 0x9e, - 0x7d, 0x5e, 0x46, 0xc1, 0xd5, 0x32, 0x0a, 0xbe, 0x2e, 0xa3, 0xe0, 0xe3, 0x2a, 0x6a, 0x5d, 0xad, - 0xa2, 0xd6, 0x97, 0x55, 0xd4, 0x7a, 0x73, 0x2f, 0xa7, 0xf2, 0x72, 0x36, 0x4a, 0xc6, 0xac, 0xe8, - 0x8f, 0x16, 0xe4, 0x3e, 0x9e, 0x56, 0x97, 0x58, 0x12, 0xac, 0xa2, 0xfe, 0xbc, 0xdf, 0x3c, 0xfd, - 0xef, 0x2b, 0x22, 0x46, 0x5d, 0xf5, 0xfc, 0x3f, 0xfa, 0x1e, 0x00, 0x00, 0xff, 0xff, 0x65, 0xf6, - 0x35, 0x33, 0x12, 0x06, 0x00, 0x00, + // 557 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x55, 0x4d, 0x6f, 0xd3, 0x30, + 0x18, 0x6e, 0xd6, 0xae, 0xdb, 0xde, 0x8d, 0x09, 0x79, 0x68, 0x8a, 0x8a, 0x14, 0x46, 0x90, 0x26, + 0x0e, 0x90, 0x0a, 0xb8, 0x70, 0xe1, 0xc0, 0xd7, 0xa4, 0x21, 0x95, 0x43, 0x61, 0x17, 0x2e, 0x91, + 0xdb, 0x58, 0x99, 0xd5, 0x26, 0x8e, 0x62, 0x17, 0x4a, 0x7f, 0x05, 0x7f, 0x0a, 0x89, 0xe3, 0x8e, + 0x1c, 0x51, 0x7b, 0xe1, 0xc6, 0x5f, 0x40, 0xb1, 0xbd, 0xcc, 0x66, 0x5e, 0x19, 0x3d, 0x70, 0xeb, + 0xfb, 0xd1, 0xf7, 0xf1, 0xf3, 0x3c, 0xaf, 0x63, 0xb8, 0x59, 0x92, 0x4f, 0xb8, 0x4c, 0x78, 0x57, + 0x4c, 0xa3, 0xa2, 0x64, 0x82, 0xa1, 0xdd, 0xc1, 0x8c, 0x44, 0x1f, 0x1f, 0x45, 0xba, 0x10, 0xfe, + 0xf4, 0x60, 0xbf, 0xc7, 0xd3, 0x97, 0x25, 0xc1, 0x82, 0xbc, 0x13, 0x78, 0x44, 0xf3, 0xb4, 0x2f, + 0x6b, 0xc8, 0x87, 0x8d, 0x61, 0x95, 0x66, 0xa5, 0xef, 0x1d, 0x78, 0xf7, 0xb7, 0xfa, 0xe7, 0x21, + 0xba, 0x0b, 0x3b, 0x45, 0x49, 0x67, 0x24, 0xc6, 0x19, 0x9b, 0xe4, 0xc2, 0x5f, 0x93, 0xe5, 0x6d, + 0x99, 0x7b, 0x2e, 0x53, 0xe8, 0x0e, 0xa8, 0x30, 0x4e, 0x48, 0xce, 0x32, 0xbf, 0x29, 0x3b, 0x40, + 0xa6, 0x5e, 0x55, 0x19, 0x74, 0x0f, 0x6e, 0x70, 0x05, 0xa7, 0x5b, 0x5a, 0xb2, 0x65, 0x47, 0x27, + 0x55, 0x53, 0x07, 0x36, 0x93, 0x49, 0x89, 0x05, 0x65, 0xb9, 0xbf, 0x2e, 0xeb, 0x75, 0x8c, 0x6e, + 0xc3, 0x56, 0x46, 0xf3, 0xb8, 0xea, 0x27, 0x7e, 0x5b, 0x15, 0x33, 0x9a, 0x57, 0x1c, 0x08, 0x42, + 0xd0, 0x1a, 0xb3, 0xe1, 0xc8, 0xdf, 0x90, 0x79, 0xf9, 0x3b, 0x7c, 0x06, 0x81, 0x9b, 0x69, 0x9f, + 0xf0, 0x82, 0xe5, 0x9c, 0x54, 0x23, 0x95, 0x2e, 0x31, 0x4d, 0x34, 0xe7, 0x4d, 0x95, 0x38, 0x4e, + 0xc2, 0x91, 0x14, 0xea, 0xa4, 0x48, 0xfe, 0x41, 0x28, 0x6b, 0xe0, 0x9a, 0x3d, 0xd0, 0x22, 0xd7, + 0xb4, 0xc9, 0x85, 0x07, 0xf2, 0xac, 0x0e, 0xb0, 0xf3, 0xb3, 0x86, 0x5f, 0x4d, 0xe3, 0xde, 0x97, + 0x38, 0xf9, 0x5f, 0xc6, 0x99, 0xc7, 0x6e, 0x39, 0x3c, 0xc1, 0xe5, 0x88, 0x88, 0x8a, 0xaf, 0x36, + 0x4c, 0x25, 0x8e, 0x13, 0x74, 0x0b, 0xd6, 0xf9, 0x98, 0x09, 0xae, 0xcd, 0x52, 0x81, 0xe5, 0x8a, + 0x45, 0xe3, 0x7a, 0xae, 0xc4, 0xb0, 0xdb, 0xe3, 0xe9, 0x1b, 0xa6, 0x8c, 0xa7, 0x79, 0xba, 0xaa, + 0x1b, 0xfb, 0xd0, 0xd6, 0xa2, 0x28, 0xca, 0x3a, 0x0a, 0x7d, 0x29, 0xb3, 0x01, 0x50, 0x3b, 0x70, + 0x24, 0xa1, 0x5f, 0x4f, 0xa9, 0xf8, 0x3b, 0x74, 0x07, 0x6a, 0xa4, 0x3f, 0x91, 0x35, 0x82, 0x31, + 0xa7, 0x46, 0x78, 0xab, 0x2c, 0x1e, 0x63, 0x9a, 0x59, 0x4b, 0xc0, 0x57, 0x44, 0x7a, 0xaa, 0xb4, + 0xbe, 0x3c, 0xaf, 0xd6, 0xfa, 0x42, 0x05, 0xcf, 0x54, 0xe1, 0xf1, 0xaf, 0x16, 0x34, 0x7b, 0x3c, + 0x45, 0x19, 0xec, 0xb9, 0x3e, 0x15, 0x87, 0x91, 0xfd, 0x59, 0x89, 0xdc, 0x17, 0xad, 0x13, 0x5d, + 0xaf, 0xaf, 0x3e, 0x4e, 0x06, 0x7b, 0xae, 0x0b, 0xe7, 0x82, 0x73, 0xf4, 0x39, 0xe1, 0x96, 0xdc, + 0xa9, 0x0b, 0x76, 0xf6, 0x7d, 0xba, 0x9a, 0x9d, 0xd5, 0xb7, 0x84, 0x9d, 0x7b, 0xb1, 0x4f, 0x60, + 0xdb, 0x5c, 0xdc, 0xc0, 0xf1, 0x77, 0xa3, 0xde, 0x39, 0x5c, 0x5e, 0x37, 0xc7, 0x9a, 0x4b, 0xe9, + 0x1a, 0x6b, 0xd4, 0x9d, 0x63, 0x1d, 0xcb, 0x28, 0xc5, 0x71, 0x6c, 0xa2, 0x53, 0x9c, 0xcb, 0x7d, + 0x6e, 0x71, 0xae, 0xde, 0xc4, 0x17, 0x47, 0xdf, 0xe6, 0x81, 0x77, 0x36, 0x0f, 0xbc, 0x1f, 0xf3, + 0xc0, 0xfb, 0xb2, 0x08, 0x1a, 0x67, 0x8b, 0xa0, 0xf1, 0x7d, 0x11, 0x34, 0x3e, 0x3c, 0x48, 0xa9, + 0x38, 0x9d, 0x0c, 0xa2, 0x21, 0xcb, 0xba, 0x83, 0x19, 0x79, 0x88, 0xc7, 0xc5, 0x29, 0x16, 0x04, + 0xcb, 0xa8, 0x3b, 0xed, 0xd6, 0x6f, 0xde, 0xe7, 0x82, 0xf0, 0x41, 0x5b, 0xbe, 0x7b, 0x4f, 0x7e, + 0x07, 0x00, 0x00, 0xff, 0xff, 0x17, 0x12, 0xfe, 0xbb, 0x0b, 0x07, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -640,6 +740,7 @@ type MsgClient interface { CreateTradingReward(ctx context.Context, in *MsgCreateTradingReward, opts ...grpc.CallOption) (*MsgCreateTradingRewardResponse, error) JoinStaking(ctx context.Context, in *MsgJoinStaking, opts ...grpc.CallOption) (*MsgJoinStakingResponse, error) ExitStaking(ctx context.Context, in *MsgExitStaking, opts ...grpc.CallOption) (*MsgExitStakingResponse, error) + ClaimStakingRewards(ctx context.Context, in *MsgClaimStakingRewards, opts ...grpc.CallOption) (*MsgClaimStakingRewardsResponse, error) } type msgClient struct { @@ -695,6 +796,15 @@ func (c *msgClient) ExitStaking(ctx context.Context, in *MsgExitStaking, opts .. return out, nil } +func (c *msgClient) ClaimStakingRewards(ctx context.Context, in *MsgClaimStakingRewards, opts ...grpc.CallOption) (*MsgClaimStakingRewardsResponse, error) { + out := new(MsgClaimStakingRewardsResponse) + err := c.cc.Invoke(ctx, "/bze.v1.rewards.Msg/ClaimStakingRewards", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // MsgServer is the server API for Msg service. type MsgServer interface { CreateStakingReward(context.Context, *MsgCreateStakingReward) (*MsgCreateStakingRewardResponse, error) @@ -702,6 +812,7 @@ type MsgServer interface { CreateTradingReward(context.Context, *MsgCreateTradingReward) (*MsgCreateTradingRewardResponse, error) JoinStaking(context.Context, *MsgJoinStaking) (*MsgJoinStakingResponse, error) ExitStaking(context.Context, *MsgExitStaking) (*MsgExitStakingResponse, error) + ClaimStakingRewards(context.Context, *MsgClaimStakingRewards) (*MsgClaimStakingRewardsResponse, error) } // UnimplementedMsgServer can be embedded to have forward compatible implementations. @@ -723,6 +834,9 @@ func (*UnimplementedMsgServer) JoinStaking(ctx context.Context, req *MsgJoinStak func (*UnimplementedMsgServer) ExitStaking(ctx context.Context, req *MsgExitStaking) (*MsgExitStakingResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method ExitStaking not implemented") } +func (*UnimplementedMsgServer) ClaimStakingRewards(ctx context.Context, req *MsgClaimStakingRewards) (*MsgClaimStakingRewardsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method ClaimStakingRewards not implemented") +} func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) @@ -818,6 +932,24 @@ func _Msg_ExitStaking_Handler(srv interface{}, ctx context.Context, dec func(int return interceptor(ctx, in, info, handler) } +func _Msg_ClaimStakingRewards_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgClaimStakingRewards) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).ClaimStakingRewards(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/bze.v1.rewards.Msg/ClaimStakingRewards", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).ClaimStakingRewards(ctx, req.(*MsgClaimStakingRewards)) + } + return interceptor(ctx, in, info, handler) +} + var _Msg_serviceDesc = grpc.ServiceDesc{ ServiceName: "bze.v1.rewards.Msg", HandlerType: (*MsgServer)(nil), @@ -842,6 +974,10 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ MethodName: "ExitStaking", Handler: _Msg_ExitStaking_Handler, }, + { + MethodName: "ClaimStakingRewards", + Handler: _Msg_ClaimStakingRewards_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "rewards/tx.proto", @@ -1238,6 +1374,73 @@ func (m *MsgExitStakingResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) return len(dAtA) - i, nil } +func (m *MsgClaimStakingRewards) 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 *MsgClaimStakingRewards) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgClaimStakingRewards) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.RewardId) > 0 { + i -= len(m.RewardId) + copy(dAtA[i:], m.RewardId) + i = encodeVarintTx(dAtA, i, uint64(len(m.RewardId))) + i-- + dAtA[i] = 0x12 + } + if len(m.Creator) > 0 { + i -= len(m.Creator) + copy(dAtA[i:], m.Creator) + i = encodeVarintTx(dAtA, i, uint64(len(m.Creator))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgClaimStakingRewardsResponse) 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 *MsgClaimStakingRewardsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgClaimStakingRewardsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Amount) > 0 { + i -= len(m.Amount) + copy(dAtA[i:], m.Amount) + i = encodeVarintTx(dAtA, i, uint64(len(m.Amount))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func encodeVarintTx(dAtA []byte, offset int, v uint64) int { offset -= sovTx(v) base := offset @@ -1431,6 +1634,36 @@ func (m *MsgExitStakingResponse) Size() (n int) { return n } +func (m *MsgClaimStakingRewards) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Creator) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.RewardId) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgClaimStakingRewardsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Amount) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + func sovTx(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -2673,6 +2906,202 @@ func (m *MsgExitStakingResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *MsgClaimStakingRewards) 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 ErrIntOverflowTx + } + 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: MsgClaimStakingRewards: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgClaimStakingRewards: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Creator", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Creator = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RewardId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.RewardId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgClaimStakingRewardsResponse) 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 ErrIntOverflowTx + } + 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: MsgClaimStakingRewardsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgClaimStakingRewardsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Amount = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipTx(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 From 29d9dbb09536fc0143955ad4e1732f390860d1e1 Mon Sep 17 00:00:00 2001 From: faneaatiku Date: Tue, 19 Mar 2024 03:12:27 +0200 Subject: [PATCH 12/35] distribute staking rewards and implemented locking period --- app/app.go | 9 +- docs/static/openapi.yml | 3 + go.mod | 3 - go.sum | 12 - .../rewards/staking_reward_participant.proto | 7 + .../bze-alphateam/bze/bze.v1.rewards/index.ts | 100 ++--- .../bze/bze.v1.rewards/module/index.ts | 18 +- .../bze/bze.v1.rewards/module/rest.ts | 4 +- .../rewards/staking_reward_participant.ts | 132 +++++++ .../bze.v1.rewards/module/types/rewards/tx.ts | 31 +- x/epochs/keeper/epoch.go | 6 + x/epochs/keeper/keeper.go | 6 +- x/rewards/keeper/keeper.go | 45 +++ x/rewards/keeper/msg_server_exit_staking.go | 33 +- x/rewards/keeper/msg_server_trading_reward.go | 36 -- .../keeper/pending_unlock_participant.go | 36 ++ x/rewards/keeper/staking_reward.go | 15 + .../keeper/staking_reward_distribution.go | 92 +++++ x/rewards/keeper/unlock.go | 44 +++ x/rewards/types/expected_keepers.go | 4 + x/rewards/types/hook.go | 27 ++ .../types/key_pending_unlock_participant.go | 27 ++ .../types/staking_reward_participant.pb.go | 358 +++++++++++++++++- 23 files changed, 901 insertions(+), 147 deletions(-) create mode 100644 x/rewards/keeper/pending_unlock_participant.go create mode 100644 x/rewards/keeper/staking_reward_distribution.go create mode 100644 x/rewards/keeper/unlock.go create mode 100644 x/rewards/types/hook.go create mode 100644 x/rewards/types/key_pending_unlock_participant.go diff --git a/app/app.go b/app/app.go index e3e21c0f..ea038dc6 100644 --- a/app/app.go +++ b/app/app.go @@ -464,7 +464,6 @@ func New( appCodec, keys[epochstypes.StoreKey], keys[epochstypes.MemStoreKey], - nil, //no hooks registered ) app.RewardsKeeper = *rewardskeeper.NewKeeper( @@ -475,6 +474,14 @@ func New( app.BankKeeper, app.DistrKeeper, app.TradebinKeeper, + app.EpochsKeeper, + ) + + app.EpochsKeeper.SetHooks( + []epochstypes.EpochHook{ + app.RewardsKeeper.GetDistributeAllStakingRewardsHook(), + app.RewardsKeeper.GetUnlockPendingUnlockParticipantsHook(), + }, ) scavengeModule := scavengemodule.NewAppModule(appCodec, app.ScavengeKeeper) diff --git a/docs/static/openapi.yml b/docs/static/openapi.yml index 15e0f853..06f7bc43 100644 --- a/docs/static/openapi.yml +++ b/docs/static/openapi.yml @@ -34619,6 +34619,9 @@ definitions: } bze.v1.rewards.MsgClaimStakingRewardsResponse: type: object + properties: + amount: + type: string bze.v1.rewards.MsgCreateStakingRewardResponse: type: object properties: diff --git a/go.mod b/go.mod index 0519be13..23080d06 100644 --- a/go.mod +++ b/go.mod @@ -99,7 +99,6 @@ require ( github.com/fsnotify/fsnotify v1.6.0 // indirect github.com/fzipp/gocyclo v0.6.0 // indirect github.com/getsentry/sentry-go v0.17.0 // indirect - github.com/ghodss/yaml v1.0.0 // indirect github.com/go-critic/go-critic v0.6.5 // indirect github.com/go-kit/kit v0.12.0 // indirect github.com/go-kit/log v0.2.1 // indirect @@ -116,7 +115,6 @@ require ( github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect github.com/gofrs/flock v0.8.1 // indirect github.com/gogo/gateway v1.1.0 // indirect - github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b // indirect github.com/golang/snappy v0.0.4 // indirect github.com/golangci/check v0.0.0-20180506172741-cfe4005ccda2 // indirect github.com/golangci/dupl v0.0.0-20180902072040-3e9179ac440a // indirect @@ -139,7 +137,6 @@ require ( github.com/gostaticanalysis/forcetypeassert v0.1.0 // indirect github.com/gostaticanalysis/nilerr v0.1.1 // indirect github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 // indirect - github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1 // 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 diff --git a/go.sum b/go.sum index 5fd2428c..bd2604ca 100644 --- a/go.sum +++ b/go.sum @@ -154,7 +154,6 @@ github.com/aymerick/douceur v0.2.0 h1:Mv+mAeH1Q+n9Fr+oyamOlAkUNPWPlA8PPGR0QAaYuP github.com/aymerick/douceur v0.2.0/go.mod h1:wlT5vV2O3h55X9m7iVYN0TBM0NH/MmbLnd30/FjWUq4= github.com/aymerick/raymond v2.0.3-0.20180322193309-b565731e1464+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g= github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= -github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= @@ -262,7 +261,6 @@ github.com/containerd/continuity v0.3.0 h1:nisirsYROK15TAMVukJOUyGJjz4BNQJBVsNvA github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= -github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= github.com/coreos/go-systemd v0.0.0-20180511133405-39ca1b05acc7/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/coreos/go-systemd/v22 v22.3.3-0.20220203105225-a9a7ef127534/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= @@ -397,7 +395,6 @@ github.com/getsentry/sentry-go v0.12.0/go.mod h1:NSap0JBYWzHND8oMbyi0+XZhUalc1TB github.com/getsentry/sentry-go v0.17.0 h1:UustVWnOoDFHBS7IJUB2QK/nB5pap748ZEp0swnQJak= github.com/getsentry/sentry-go v0.17.0/go.mod h1:B82dxtBvxG0KaPD8/hfSV+VcHD+Lg/xUS4JuQn1P4cM= github.com/ghemawat/stream v0.0.0-20171120220530-696b145b53b9/go.mod h1:106OIgooyS7OzLDOpUGgm9fA3bQENb/cFSyyBmMoJDs= -github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/gin-contrib/sse v0.0.0-20190301062529-5545eab6dad3/go.mod h1:VJ0WA2NBN22VlZ2dKZQPAPnyWw5XTlK1KymzLKsr59s= github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= @@ -490,13 +487,11 @@ github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzq github.com/golang-jwt/jwt/v4 v4.3.0/go.mod h1:/xlHOz8bRuivTWchD4jCa+NbatV+wEUSzwAxVc6locg= github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k= github.com/golang/geo v0.0.0-20190916061304-5b978397cfec/go.mod h1:QZ0nwyI2jOfgRAoBvP+ab5aRr7c9x7lhGEJrKvBwjWI= -github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= @@ -504,7 +499,6 @@ github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= -github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.0/go.mod h1:Qd/q+1AKNOZr9uGQzbzCmRO6sUih6GTPZv6a1/R87v0= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= @@ -639,8 +633,6 @@ github.com/grpc-ecosystem/grpc-gateway v1.8.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4M0+kPpLofRdBo= github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1 h1:/c3QmbOGMGTOumP2iT/rCwB7b0QDGLKzqOmktBjT+Is= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1/go.mod h1:5SN9VR2LTsRFsrEC6FHgRbTWrTHu6tqPeKxEQv15giM= 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= @@ -656,7 +648,6 @@ github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brv github.com/hashicorp/go-bexpr v0.1.10/go.mod h1:oxlubA2vC/gFVfX1A6JGp7ls7uCDlfJn732ehYYg+g0= github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= -github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48= github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= github.com/hashicorp/go-immutable-radix v1.3.1 h1:DKHmCUm2hRBK510BaiZlwvpD40f8bJFeZnpfm2KLowc= github.com/hashicorp/go-immutable-radix v1.3.1/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= @@ -666,7 +657,6 @@ github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+l github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= github.com/hashicorp/go-retryablehttp v0.5.3/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs= github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU= -github.com/hashicorp/go-rootcerts v1.0.2/go.mod h1:pqUvnprVnM5bf7AOirdbb01K4ccR319Vf4pU3K5EGc8= github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU= github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4= github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= @@ -1324,7 +1314,6 @@ go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= -go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= @@ -1332,7 +1321,6 @@ go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/atomic v1.10.0 h1:9qC72Qh0+3MqyJbAn8YU5xVq1frD8bn3JtD2oXtafVQ= go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= go.uber.org/goleak v1.1.11 h1:wy28qYRKZgnJTxGxvye5/wgWr1EKjmUDGYox5mGlRlI= -go.uber.org/goleak v1.1.11/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4= go.uber.org/multierr v1.8.0 h1:dg6GjLku4EH+249NNmoIciG9N/jURbDG+pFlTkhzIC8= diff --git a/proto/rewards/staking_reward_participant.proto b/proto/rewards/staking_reward_participant.proto index 66c7c1f3..07327a73 100644 --- a/proto/rewards/staking_reward_participant.proto +++ b/proto/rewards/staking_reward_participant.proto @@ -9,3 +9,10 @@ message StakingRewardParticipant { string amount = 3; // stake[address] string joined_at = 4; // S0[address] } + +message PendingUnlockParticipant { + string index = 1; + string address = 2; + string amount = 3; + string denom = 4; +} diff --git a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/index.ts b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/index.ts index 2f5f16f3..442ab5bc 100755 --- a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/index.ts +++ b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/index.ts @@ -3,10 +3,11 @@ import { txClient, queryClient, MissingWalletError , registry} from './module' import { Params } from "./module/types/rewards/params" import { StakingReward } from "./module/types/rewards/staking_reward" import { StakingRewardParticipant } from "./module/types/rewards/staking_reward_participant" +import { PendingUnlockParticipant } from "./module/types/rewards/staking_reward_participant" import { TradingReward } from "./module/types/rewards/trading_reward" -export { Params, StakingReward, StakingRewardParticipant, TradingReward }; +export { Params, StakingReward, StakingRewardParticipant, PendingUnlockParticipant, TradingReward }; async function initTxClient(vuexGetters) { return await txClient(vuexGetters['common/wallet/signer'], { @@ -56,6 +57,7 @@ const getDefaultState = () => { Params: getStructure(Params.fromPartial({})), StakingReward: getStructure(StakingReward.fromPartial({})), StakingRewardParticipant: getStructure(StakingRewardParticipant.fromPartial({})), + PendingUnlockParticipant: getStructure(PendingUnlockParticipant.fromPartial({})), TradingReward: getStructure(TradingReward.fromPartial({})), }, @@ -331,172 +333,172 @@ export default { }, - async sendMsgCreateTradingReward({ rootGetters }, { value, fee = [], memo = '' }) { + async sendMsgCreateStakingReward({ rootGetters }, { value, fee = [], memo = '' }) { try { const txClient=await initTxClient(rootGetters) - const msg = await txClient.msgCreateTradingReward(value) + const msg = await txClient.msgCreateStakingReward(value) const result = await txClient.signAndBroadcast([msg], {fee: { amount: fee, gas: "200000" }, memo}) return result } catch (e) { if (e == MissingWalletError) { - throw new Error('TxClient:MsgCreateTradingReward:Init Could not initialize signing client. Wallet is required.') + throw new Error('TxClient:MsgCreateStakingReward:Init Could not initialize signing client. Wallet is required.') }else{ - throw new Error('TxClient:MsgCreateTradingReward:Send Could not broadcast Tx: '+ e.message) + throw new Error('TxClient:MsgCreateStakingReward:Send Could not broadcast Tx: '+ e.message) } } }, - async sendMsgJoinStaking({ rootGetters }, { value, fee = [], memo = '' }) { + async sendMsgExitStaking({ rootGetters }, { value, fee = [], memo = '' }) { try { const txClient=await initTxClient(rootGetters) - const msg = await txClient.msgJoinStaking(value) + const msg = await txClient.msgExitStaking(value) const result = await txClient.signAndBroadcast([msg], {fee: { amount: fee, gas: "200000" }, memo}) return result } catch (e) { if (e == MissingWalletError) { - throw new Error('TxClient:MsgJoinStaking:Init Could not initialize signing client. Wallet is required.') + throw new Error('TxClient:MsgExitStaking:Init Could not initialize signing client. Wallet is required.') }else{ - throw new Error('TxClient:MsgJoinStaking:Send Could not broadcast Tx: '+ e.message) + throw new Error('TxClient:MsgExitStaking:Send Could not broadcast Tx: '+ e.message) } } }, - async sendMsgExitStaking({ rootGetters }, { value, fee = [], memo = '' }) { + async sendMsgClaimStakingRewards({ rootGetters }, { value, fee = [], memo = '' }) { try { const txClient=await initTxClient(rootGetters) - const msg = await txClient.msgExitStaking(value) + const msg = await txClient.msgClaimStakingRewards(value) const result = await txClient.signAndBroadcast([msg], {fee: { amount: fee, gas: "200000" }, memo}) return result } catch (e) { if (e == MissingWalletError) { - throw new Error('TxClient:MsgExitStaking:Init Could not initialize signing client. Wallet is required.') + throw new Error('TxClient:MsgClaimStakingRewards:Init Could not initialize signing client. Wallet is required.') }else{ - throw new Error('TxClient:MsgExitStaking:Send Could not broadcast Tx: '+ e.message) + throw new Error('TxClient:MsgClaimStakingRewards:Send Could not broadcast Tx: '+ e.message) } } }, - async sendMsgUpdateStakingReward({ rootGetters }, { value, fee = [], memo = '' }) { + async sendMsgCreateTradingReward({ rootGetters }, { value, fee = [], memo = '' }) { try { const txClient=await initTxClient(rootGetters) - const msg = await txClient.msgUpdateStakingReward(value) + const msg = await txClient.msgCreateTradingReward(value) const result = await txClient.signAndBroadcast([msg], {fee: { amount: fee, gas: "200000" }, memo}) return result } catch (e) { if (e == MissingWalletError) { - throw new Error('TxClient:MsgUpdateStakingReward:Init Could not initialize signing client. Wallet is required.') + throw new Error('TxClient:MsgCreateTradingReward:Init Could not initialize signing client. Wallet is required.') }else{ - throw new Error('TxClient:MsgUpdateStakingReward:Send Could not broadcast Tx: '+ e.message) + throw new Error('TxClient:MsgCreateTradingReward:Send Could not broadcast Tx: '+ e.message) } } }, - async sendMsgClaimStakingRewards({ rootGetters }, { value, fee = [], memo = '' }) { + async sendMsgJoinStaking({ rootGetters }, { value, fee = [], memo = '' }) { try { const txClient=await initTxClient(rootGetters) - const msg = await txClient.msgClaimStakingRewards(value) + const msg = await txClient.msgJoinStaking(value) const result = await txClient.signAndBroadcast([msg], {fee: { amount: fee, gas: "200000" }, memo}) return result } catch (e) { if (e == MissingWalletError) { - throw new Error('TxClient:MsgClaimStakingRewards:Init Could not initialize signing client. Wallet is required.') + throw new Error('TxClient:MsgJoinStaking:Init Could not initialize signing client. Wallet is required.') }else{ - throw new Error('TxClient:MsgClaimStakingRewards:Send Could not broadcast Tx: '+ e.message) + throw new Error('TxClient:MsgJoinStaking:Send Could not broadcast Tx: '+ e.message) } } }, - async sendMsgCreateStakingReward({ rootGetters }, { value, fee = [], memo = '' }) { + async sendMsgUpdateStakingReward({ rootGetters }, { value, fee = [], memo = '' }) { try { const txClient=await initTxClient(rootGetters) - const msg = await txClient.msgCreateStakingReward(value) + const msg = await txClient.msgUpdateStakingReward(value) const result = await txClient.signAndBroadcast([msg], {fee: { amount: fee, gas: "200000" }, memo}) return result } catch (e) { if (e == MissingWalletError) { - throw new Error('TxClient:MsgCreateStakingReward:Init Could not initialize signing client. Wallet is required.') + throw new Error('TxClient:MsgUpdateStakingReward:Init Could not initialize signing client. Wallet is required.') }else{ - throw new Error('TxClient:MsgCreateStakingReward:Send Could not broadcast Tx: '+ e.message) + throw new Error('TxClient:MsgUpdateStakingReward:Send Could not broadcast Tx: '+ e.message) } } }, - async MsgCreateTradingReward({ rootGetters }, { value }) { + async MsgCreateStakingReward({ rootGetters }, { value }) { try { const txClient=await initTxClient(rootGetters) - const msg = await txClient.msgCreateTradingReward(value) + const msg = await txClient.msgCreateStakingReward(value) return msg } catch (e) { if (e == MissingWalletError) { - throw new Error('TxClient:MsgCreateTradingReward:Init Could not initialize signing client. Wallet is required.') + throw new Error('TxClient:MsgCreateStakingReward:Init Could not initialize signing client. Wallet is required.') } else{ - throw new Error('TxClient:MsgCreateTradingReward:Create Could not create message: ' + e.message) + throw new Error('TxClient:MsgCreateStakingReward:Create Could not create message: ' + e.message) } } }, - async MsgJoinStaking({ rootGetters }, { value }) { + async MsgExitStaking({ rootGetters }, { value }) { try { const txClient=await initTxClient(rootGetters) - const msg = await txClient.msgJoinStaking(value) + const msg = await txClient.msgExitStaking(value) return msg } catch (e) { if (e == MissingWalletError) { - throw new Error('TxClient:MsgJoinStaking:Init Could not initialize signing client. Wallet is required.') + throw new Error('TxClient:MsgExitStaking:Init Could not initialize signing client. Wallet is required.') } else{ - throw new Error('TxClient:MsgJoinStaking:Create Could not create message: ' + e.message) + throw new Error('TxClient:MsgExitStaking:Create Could not create message: ' + e.message) } } }, - async MsgExitStaking({ rootGetters }, { value }) { + async MsgClaimStakingRewards({ rootGetters }, { value }) { try { const txClient=await initTxClient(rootGetters) - const msg = await txClient.msgExitStaking(value) + const msg = await txClient.msgClaimStakingRewards(value) return msg } catch (e) { if (e == MissingWalletError) { - throw new Error('TxClient:MsgExitStaking:Init Could not initialize signing client. Wallet is required.') + throw new Error('TxClient:MsgClaimStakingRewards:Init Could not initialize signing client. Wallet is required.') } else{ - throw new Error('TxClient:MsgExitStaking:Create Could not create message: ' + e.message) + throw new Error('TxClient:MsgClaimStakingRewards:Create Could not create message: ' + e.message) } } }, - async MsgUpdateStakingReward({ rootGetters }, { value }) { + async MsgCreateTradingReward({ rootGetters }, { value }) { try { const txClient=await initTxClient(rootGetters) - const msg = await txClient.msgUpdateStakingReward(value) + const msg = await txClient.msgCreateTradingReward(value) return msg } catch (e) { if (e == MissingWalletError) { - throw new Error('TxClient:MsgUpdateStakingReward:Init Could not initialize signing client. Wallet is required.') + throw new Error('TxClient:MsgCreateTradingReward:Init Could not initialize signing client. Wallet is required.') } else{ - throw new Error('TxClient:MsgUpdateStakingReward:Create Could not create message: ' + e.message) + throw new Error('TxClient:MsgCreateTradingReward:Create Could not create message: ' + e.message) } } }, - async MsgClaimStakingRewards({ rootGetters }, { value }) { + async MsgJoinStaking({ rootGetters }, { value }) { try { const txClient=await initTxClient(rootGetters) - const msg = await txClient.msgClaimStakingRewards(value) + const msg = await txClient.msgJoinStaking(value) return msg } catch (e) { if (e == MissingWalletError) { - throw new Error('TxClient:MsgClaimStakingRewards:Init Could not initialize signing client. Wallet is required.') + throw new Error('TxClient:MsgJoinStaking:Init Could not initialize signing client. Wallet is required.') } else{ - throw new Error('TxClient:MsgClaimStakingRewards:Create Could not create message: ' + e.message) + throw new Error('TxClient:MsgJoinStaking:Create Could not create message: ' + e.message) } } }, - async MsgCreateStakingReward({ rootGetters }, { value }) { + async MsgUpdateStakingReward({ rootGetters }, { value }) { try { const txClient=await initTxClient(rootGetters) - const msg = await txClient.msgCreateStakingReward(value) + const msg = await txClient.msgUpdateStakingReward(value) return msg } catch (e) { if (e == MissingWalletError) { - throw new Error('TxClient:MsgCreateStakingReward:Init Could not initialize signing client. Wallet is required.') + throw new Error('TxClient:MsgUpdateStakingReward:Init Could not initialize signing client. Wallet is required.') } else{ - throw new Error('TxClient:MsgCreateStakingReward:Create Could not create message: ' + e.message) + throw new Error('TxClient:MsgUpdateStakingReward:Create Could not create message: ' + e.message) } } }, diff --git a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/index.ts b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/index.ts index d48bcf93..80a2439e 100755 --- a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/index.ts +++ b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/index.ts @@ -4,21 +4,21 @@ import { StdFee } from "@cosmjs/launchpad"; import { SigningStargateClient } from "@cosmjs/stargate"; import { Registry, OfflineSigner, EncodeObject, DirectSecp256k1HdWallet } from "@cosmjs/proto-signing"; import { Api } from "./rest"; +import { MsgCreateStakingReward } from "./types/rewards/tx"; +import { MsgExitStaking } from "./types/rewards/tx"; +import { MsgClaimStakingRewards } from "./types/rewards/tx"; import { MsgCreateTradingReward } from "./types/rewards/tx"; import { MsgJoinStaking } from "./types/rewards/tx"; -import { MsgExitStaking } from "./types/rewards/tx"; import { MsgUpdateStakingReward } from "./types/rewards/tx"; -import { MsgClaimStakingRewards } from "./types/rewards/tx"; -import { MsgCreateStakingReward } from "./types/rewards/tx"; const types = [ + ["/bze.v1.rewards.MsgCreateStakingReward", MsgCreateStakingReward], + ["/bze.v1.rewards.MsgExitStaking", MsgExitStaking], + ["/bze.v1.rewards.MsgClaimStakingRewards", MsgClaimStakingRewards], ["/bze.v1.rewards.MsgCreateTradingReward", MsgCreateTradingReward], ["/bze.v1.rewards.MsgJoinStaking", MsgJoinStaking], - ["/bze.v1.rewards.MsgExitStaking", MsgExitStaking], ["/bze.v1.rewards.MsgUpdateStakingReward", MsgUpdateStakingReward], - ["/bze.v1.rewards.MsgClaimStakingRewards", MsgClaimStakingRewards], - ["/bze.v1.rewards.MsgCreateStakingReward", MsgCreateStakingReward], ]; export const MissingWalletError = new Error("wallet is required"); @@ -51,12 +51,12 @@ const txClient = async (wallet: OfflineSigner, { addr: addr }: TxClientOptions = return { signAndBroadcast: (msgs: EncodeObject[], { fee, memo }: SignAndBroadcastOptions = {fee: defaultFee, memo: ""}) => client.signAndBroadcast(address, msgs, fee,memo), + msgCreateStakingReward: (data: MsgCreateStakingReward): EncodeObject => ({ typeUrl: "/bze.v1.rewards.MsgCreateStakingReward", value: MsgCreateStakingReward.fromPartial( data ) }), + msgExitStaking: (data: MsgExitStaking): EncodeObject => ({ typeUrl: "/bze.v1.rewards.MsgExitStaking", value: MsgExitStaking.fromPartial( data ) }), + msgClaimStakingRewards: (data: MsgClaimStakingRewards): EncodeObject => ({ typeUrl: "/bze.v1.rewards.MsgClaimStakingRewards", value: MsgClaimStakingRewards.fromPartial( data ) }), msgCreateTradingReward: (data: MsgCreateTradingReward): EncodeObject => ({ typeUrl: "/bze.v1.rewards.MsgCreateTradingReward", value: MsgCreateTradingReward.fromPartial( data ) }), msgJoinStaking: (data: MsgJoinStaking): EncodeObject => ({ typeUrl: "/bze.v1.rewards.MsgJoinStaking", value: MsgJoinStaking.fromPartial( data ) }), - msgExitStaking: (data: MsgExitStaking): EncodeObject => ({ typeUrl: "/bze.v1.rewards.MsgExitStaking", value: MsgExitStaking.fromPartial( data ) }), msgUpdateStakingReward: (data: MsgUpdateStakingReward): EncodeObject => ({ typeUrl: "/bze.v1.rewards.MsgUpdateStakingReward", value: MsgUpdateStakingReward.fromPartial( data ) }), - msgClaimStakingRewards: (data: MsgClaimStakingRewards): EncodeObject => ({ typeUrl: "/bze.v1.rewards.MsgClaimStakingRewards", value: MsgClaimStakingRewards.fromPartial( data ) }), - msgCreateStakingReward: (data: MsgCreateStakingReward): EncodeObject => ({ typeUrl: "/bze.v1.rewards.MsgCreateStakingReward", value: MsgCreateStakingReward.fromPartial( data ) }), }; }; diff --git a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/rest.ts b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/rest.ts index 6f34eb38..c95a8286 100644 --- a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/rest.ts +++ b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/rest.ts @@ -13,7 +13,9 @@ export interface ProtobufAny { "@type"?: string; } -export type RewardsMsgClaimStakingRewardsResponse = object; +export interface RewardsMsgClaimStakingRewardsResponse { + amount?: string; +} export interface RewardsMsgCreateStakingRewardResponse { reward_id?: string; diff --git a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/staking_reward_participant.ts b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/staking_reward_participant.ts index 236481aa..dd1b1793 100644 --- a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/staking_reward_participant.ts +++ b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/staking_reward_participant.ts @@ -12,6 +12,13 @@ export interface StakingRewardParticipant { joined_at: string; } +export interface PendingUnlockParticipant { + index: string; + address: string; + amount: string; + denom: string; +} + const baseStakingRewardParticipant: object = { address: "", reward_id: "", @@ -137,6 +144,131 @@ export const StakingRewardParticipant = { }, }; +const basePendingUnlockParticipant: object = { + index: "", + address: "", + amount: "", + denom: "", +}; + +export const PendingUnlockParticipant = { + encode( + message: PendingUnlockParticipant, + writer: Writer = Writer.create() + ): Writer { + if (message.index !== "") { + writer.uint32(10).string(message.index); + } + if (message.address !== "") { + writer.uint32(18).string(message.address); + } + if (message.amount !== "") { + writer.uint32(26).string(message.amount); + } + if (message.denom !== "") { + writer.uint32(34).string(message.denom); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): PendingUnlockParticipant { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...basePendingUnlockParticipant, + } as PendingUnlockParticipant; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.index = reader.string(); + break; + case 2: + message.address = reader.string(); + break; + case 3: + message.amount = reader.string(); + break; + case 4: + message.denom = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): PendingUnlockParticipant { + const message = { + ...basePendingUnlockParticipant, + } as PendingUnlockParticipant; + if (object.index !== undefined && object.index !== null) { + message.index = String(object.index); + } else { + message.index = ""; + } + if (object.address !== undefined && object.address !== null) { + message.address = String(object.address); + } else { + message.address = ""; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = String(object.amount); + } else { + message.amount = ""; + } + if (object.denom !== undefined && object.denom !== null) { + message.denom = String(object.denom); + } else { + message.denom = ""; + } + return message; + }, + + toJSON(message: PendingUnlockParticipant): unknown { + const obj: any = {}; + message.index !== undefined && (obj.index = message.index); + message.address !== undefined && (obj.address = message.address); + message.amount !== undefined && (obj.amount = message.amount); + message.denom !== undefined && (obj.denom = message.denom); + return obj; + }, + + fromPartial( + object: DeepPartial + ): PendingUnlockParticipant { + const message = { + ...basePendingUnlockParticipant, + } as PendingUnlockParticipant; + if (object.index !== undefined && object.index !== null) { + message.index = object.index; + } else { + message.index = ""; + } + if (object.address !== undefined && object.address !== null) { + message.address = object.address; + } else { + message.address = ""; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = object.amount; + } else { + message.amount = ""; + } + if (object.denom !== undefined && object.denom !== null) { + message.denom = object.denom; + } else { + message.denom = ""; + } + return message; + }, +}; + type Builtin = Date | Function | Uint8Array | string | number | undefined; export type DeepPartial = T extends Builtin ? T diff --git a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/tx.ts b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/tx.ts index 93a900a3..cbdc9ea8 100644 --- a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/tx.ts +++ b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/tx.ts @@ -68,7 +68,9 @@ export interface MsgClaimStakingRewards { rewardId: string; } -export interface MsgClaimStakingRewardsResponse {} +export interface MsgClaimStakingRewardsResponse { + amount: string; +} const baseMsgCreateStakingReward: object = { creator: "", @@ -999,13 +1001,16 @@ export const MsgClaimStakingRewards = { }, }; -const baseMsgClaimStakingRewardsResponse: object = {}; +const baseMsgClaimStakingRewardsResponse: object = { amount: "" }; export const MsgClaimStakingRewardsResponse = { encode( - _: MsgClaimStakingRewardsResponse, + message: MsgClaimStakingRewardsResponse, writer: Writer = Writer.create() ): Writer { + if (message.amount !== "") { + writer.uint32(10).string(message.amount); + } return writer; }, @@ -1021,6 +1026,9 @@ export const MsgClaimStakingRewardsResponse = { while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { + case 1: + message.amount = reader.string(); + break; default: reader.skipType(tag & 7); break; @@ -1029,24 +1037,35 @@ export const MsgClaimStakingRewardsResponse = { return message; }, - fromJSON(_: any): MsgClaimStakingRewardsResponse { + fromJSON(object: any): MsgClaimStakingRewardsResponse { const message = { ...baseMsgClaimStakingRewardsResponse, } as MsgClaimStakingRewardsResponse; + if (object.amount !== undefined && object.amount !== null) { + message.amount = String(object.amount); + } else { + message.amount = ""; + } return message; }, - toJSON(_: MsgClaimStakingRewardsResponse): unknown { + toJSON(message: MsgClaimStakingRewardsResponse): unknown { const obj: any = {}; + message.amount !== undefined && (obj.amount = message.amount); return obj; }, fromPartial( - _: DeepPartial + object: DeepPartial ): MsgClaimStakingRewardsResponse { const message = { ...baseMsgClaimStakingRewardsResponse, } as MsgClaimStakingRewardsResponse; + if (object.amount !== undefined && object.amount !== null) { + message.amount = object.amount; + } else { + message.amount = ""; + } return message; }, }; diff --git a/x/epochs/keeper/epoch.go b/x/epochs/keeper/epoch.go index 665037eb..3b70031e 100644 --- a/x/epochs/keeper/epoch.go +++ b/x/epochs/keeper/epoch.go @@ -98,3 +98,9 @@ func (k Keeper) NumBlocksSinceEpochStart(ctx sdk.Context, identifier string) (in } return ctx.BlockHeight() - epoch.CurrentEpochStartHeight, nil } + +func (k Keeper) GetEpochCountByIdentifier(ctx sdk.Context, identifier string) int64 { + e := k.GetEpochInfo(ctx, identifier) + + return e.CurrentEpoch +} diff --git a/x/epochs/keeper/keeper.go b/x/epochs/keeper/keeper.go index d3e81301..86b4e925 100644 --- a/x/epochs/keeper/keeper.go +++ b/x/epochs/keeper/keeper.go @@ -24,17 +24,19 @@ func NewKeeper( cdc codec.BinaryCodec, storeKey, memKey sdk.StoreKey, - hooks []types.EpochHook, ) *Keeper { return &Keeper{ cdc: cdc, storeKey: storeKey, memKey: memKey, - hooks: hooks, } } +func (k *Keeper) SetHooks(h []types.EpochHook) { + k.hooks = h +} + func (k Keeper) Logger(ctx sdk.Context) log.Logger { return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName)) } diff --git a/x/rewards/keeper/keeper.go b/x/rewards/keeper/keeper.go index 58b2912a..a884cb90 100644 --- a/x/rewards/keeper/keeper.go +++ b/x/rewards/keeper/keeper.go @@ -11,6 +11,12 @@ import ( paramtypes "github.com/cosmos/cosmos-sdk/x/params/types" ) +const ( + epochIdentifierDay = "day" + + distributionEpoch = epochIdentifierDay +) + type ( Keeper struct { cdc codec.BinaryCodec @@ -21,6 +27,7 @@ type ( bankKeeper types.BankKeeper distrKeeper types.DistrKeeper tradingKeeper types.TradingKeeper + epochKeeper types.EpochKeeper } ) @@ -33,6 +40,7 @@ func NewKeeper( bankKeeper types.BankKeeper, distrKeeper types.DistrKeeper, tradingKeeper types.TradingKeeper, + epochKeeper types.EpochKeeper, ) *Keeper { // set KeyTable if it has not already been set if !ps.HasKeyTable() { @@ -48,6 +56,7 @@ func NewKeeper( bankKeeper: bankKeeper, distrKeeper: distrKeeper, tradingKeeper: tradingKeeper, + epochKeeper: epochKeeper, } } @@ -58,3 +67,39 @@ func (k Keeper) Logger(ctx sdk.Context) log.Logger { func (k Keeper) smallZeroFillId(id uint64) string { return fmt.Sprintf("%012d", id) } + +func (k Keeper) getAmountToCapture(feeParam, denom, amount string, multiplier int64) (sdk.Coins, error) { + amtInt, ok := sdk.NewIntFromString(amount) + if !ok { + return nil, fmt.Errorf("could not convert povided amount to int: %s", amount) + } + + toCapture := sdk.NewCoin(denom, amtInt) + toCapture.Amount = toCapture.Amount.MulRaw(multiplier) + if !toCapture.IsPositive() { + //should never happen + return nil, fmt.Errorf("calculated amount to capture is not positive") + } + + result := sdk.NewCoins(toCapture) + if feeParam == "" { + return result, nil + } + + fee, err := sdk.ParseCoinNormalized(feeParam) + if err != nil { + return nil, fmt.Errorf("could not parse fee param") + } + + if !fee.IsPositive() { + return result, nil + } + + result = result.Add(fee) + //just avoid any accidental panic + if !result.IsValid() { + return nil, fmt.Errorf("invalid amount to capture") + } + + return result, nil +} diff --git a/x/rewards/keeper/msg_server_exit_staking.go b/x/rewards/keeper/msg_server_exit_staking.go index 42053e4a..6e213ab7 100644 --- a/x/rewards/keeper/msg_server_exit_staking.go +++ b/x/rewards/keeper/msg_server_exit_staking.go @@ -13,11 +13,6 @@ func (k msgServer) ExitStaking(goCtx context.Context, msg *types.MsgExitStaking) if msg == nil { return nil, sdkerrors.ErrInvalidRequest } - acc, err := sdk.AccAddressFromBech32(msg.Creator) - if err != nil { - return nil, err - } - ctx := sdk.UnwrapSDKContext(goCtx) stakingReward, found := k.GetStakingReward(ctx, msg.RewardId) if !found { @@ -44,14 +39,28 @@ func (k msgServer) ExitStaking(goCtx context.Context, msg *types.MsgExitStaking) return nil, err } - err = k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, acc, partCoins) - if err != nil { - return nil, err - } - + k.beginUnlock(ctx, participation, stakingReward) k.RemoveStakingRewardParticipant(ctx, participation.Address, participation.RewardId) - stakingReward.StakedAmount = stakedAmountInt.Sub(partCoins.AmountOf(stakingReward.StakingDenom)).String() - k.SetStakingReward(ctx, stakingReward) + remainingStakedAmount := stakedAmountInt.Sub(partCoins.AmountOf(stakingReward.StakingDenom)) + if remainingStakedAmount.IsPositive() { + stakingReward.StakedAmount = remainingStakedAmount.String() + k.SetStakingReward(ctx, stakingReward) + } else { + k.RemoveStakingReward(ctx, stakingReward.RewardId) + } return &types.MsgExitStakingResponse{}, nil } + +func (k msgServer) beginUnlock(ctx sdk.Context, p types.StakingRewardParticipant, sr types.StakingReward) { + lockedUntil := k.epochKeeper.GetEpochCountByIdentifier(ctx, distributionEpoch) + lockedUntil += int64(sr.Lock) + pending := types.PendingUnlockParticipant{ + Index: types.CreatePendingUnlockParticipantKey(lockedUntil, sr.RewardId), + Address: p.Address, + Amount: p.Amount, + Denom: sr.StakingDenom, + } + + k.SetPendingUnlockParticipant(ctx, pending) +} diff --git a/x/rewards/keeper/msg_server_trading_reward.go b/x/rewards/keeper/msg_server_trading_reward.go index 15433927..b5cd2b76 100644 --- a/x/rewards/keeper/msg_server_trading_reward.go +++ b/x/rewards/keeper/msg_server_trading_reward.go @@ -68,39 +68,3 @@ func (k msgServer) checkUserBalances(ctx sdk.Context, neededCoins sdk.Coins, add return nil } - -func (k msgServer) getAmountToCapture(feeParam, denom, amount string, multiplier int64) (sdk.Coins, error) { - amtInt, ok := sdk.NewIntFromString(amount) - if !ok { - return nil, fmt.Errorf("could not convert povided amount to int: %s", amount) - } - - toCapture := sdk.NewCoin(denom, amtInt) - toCapture.Amount = toCapture.Amount.MulRaw(multiplier) - if !toCapture.IsPositive() { - //should never happen - return nil, fmt.Errorf("calculated amount to capture is not positive") - } - - result := sdk.NewCoins(toCapture) - if feeParam == "" { - return result, nil - } - - fee, err := sdk.ParseCoinNormalized(feeParam) - if err != nil { - return nil, fmt.Errorf("could not parse fee param") - } - - if !fee.IsPositive() { - return result, nil - } - - result = result.Add(fee) - //just avoid any accidental panic - if !result.IsValid() { - return nil, fmt.Errorf("invalid amount to capture") - } - - return result, nil -} diff --git a/x/rewards/keeper/pending_unlock_participant.go b/x/rewards/keeper/pending_unlock_participant.go new file mode 100644 index 00000000..82031411 --- /dev/null +++ b/x/rewards/keeper/pending_unlock_participant.go @@ -0,0 +1,36 @@ +package keeper + +import ( + "github.com/bze-alphateam/bze/x/rewards/types" + "github.com/cosmos/cosmos-sdk/store/prefix" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// SetPendingUnlockParticipant set a specific types.PendingUnlockParticipant in the store on its index +func (k Keeper) SetPendingUnlockParticipant(ctx sdk.Context, p types.PendingUnlockParticipant) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.PendingUnlockParticipantKeyPrefix)) + b := k.cdc.MustMarshal(&p) + store.Set(types.PendingUnlockParticipantKey(p.Index), b) +} + +// RemovePendingUnlockParticipant removes a types.PendingUnlockParticipant from the store +func (k Keeper) RemovePendingUnlockParticipant(ctx sdk.Context, p types.PendingUnlockParticipant) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.PendingUnlockParticipantKeyPrefix)) + store.Delete(types.PendingUnlockParticipantKey(p.Index)) +} + +// GetAllEpochPendingUnlockParticipant returns all types.PendingUnlockParticipant for a certain epoch +func (k Keeper) GetAllEpochPendingUnlockParticipant(ctx sdk.Context, epoch int64) (list []types.PendingUnlockParticipant) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.PendingUnlockParticipantPrefix(epoch))) + iterator := sdk.KVStorePrefixIterator(store, []byte{}) + + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + var val types.PendingUnlockParticipant + k.cdc.MustUnmarshal(iterator.Value(), &val) + list = append(list, val) + } + + return +} diff --git a/x/rewards/keeper/staking_reward.go b/x/rewards/keeper/staking_reward.go index 304c2fa1..f578b9bd 100644 --- a/x/rewards/keeper/staking_reward.go +++ b/x/rewards/keeper/staking_reward.go @@ -49,3 +49,18 @@ func (k Keeper) GetAllStakingReward(ctx sdk.Context) (list []types.StakingReward return } + +func (k Keeper) IterateAllStakingRewards(ctx sdk.Context, msgHandler func(ctx sdk.Context, sr types.StakingReward) (stop bool)) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.StakingRewardKeyPrefix)) + iterator := sdk.KVStorePrefixIterator(store, []byte{}) + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + var sr types.StakingReward + k.cdc.MustUnmarshal(iterator.Value(), &sr) + s := msgHandler(ctx, sr) + if s { + break + } + } +} diff --git a/x/rewards/keeper/staking_reward_distribution.go b/x/rewards/keeper/staking_reward_distribution.go new file mode 100644 index 00000000..9fc97be6 --- /dev/null +++ b/x/rewards/keeper/staking_reward_distribution.go @@ -0,0 +1,92 @@ +package keeper + +import ( + "fmt" + "github.com/bze-alphateam/bze/x/rewards/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +func (k Keeper) GetDistributeAllStakingRewardsHook() types.EpochHook { + hookName := "distribution_hook" + return types.NewBeforeEpochHook(hookName, func(ctx sdk.Context, epochIdentifier string, epochNumber int64) error { + k.Logger(ctx). + With("epoch", epochIdentifier, "epoch_number", epochNumber, "hook_name", hookName). + Debug("preparing to execute hook") + + k.DistributeAllStakingRewards(ctx) + + return nil + }) +} + +func (k Keeper) DistributeAllStakingRewards(ctx sdk.Context) { + k.IterateAllStakingRewards(ctx, k.getDistributeRewardHandler()) +} + +func (k Keeper) getDistributeRewardHandler() func(ctx sdk.Context, reward types.StakingReward) (stop bool) { + return func(ctx sdk.Context, sr types.StakingReward) (stop bool) { + logger := k.Logger(ctx).With("reward_id", sr.RewardId, "type", "staking") + if sr.Payouts >= sr.Duration { + logger.Debug("stake finished. skipping distribution") + stop = false + return + } + + stakedAmount, ok := sdk.NewIntFromString(sr.StakedAmount) + if !ok { + logger.Error("could not transform staked amount from storage into int") + stop = true + return + } + + if !stakedAmount.IsPositive() { + logger.Debug("no stakers found. skipping distribution") + stop = false + return + } + + err := k.distributeStakingRewards(&sr, sr.PrizeAmount) + if err != nil { + logger.Error(err.Error()) + stop = true + return + } + + //increment payouts to skip when the reward finished (a.k.a. all payouts calculated) + sr.Payouts++ + k.SetStakingReward(ctx, sr) + + return + } +} + +func (k Keeper) distributeStakingRewards(sr *types.StakingReward, rewardAmount string) error { + stakedAmount, ok := sdk.NewIntFromString(sr.StakedAmount) + if !ok { + return fmt.Errorf("could not transform staked amount from storage into int") + } + + if !stakedAmount.IsPositive() { + return fmt.Errorf("no stakers found") + } + + reward, ok := sdk.NewIntFromString(rewardAmount) + if !ok { + return fmt.Errorf("could not transform reward amount to int") + } + + if !reward.IsPositive() { + return fmt.Errorf("reward amount should be positive") + } + + sFloat, err := sdk.NewDecFromStr(sr.DistributedStake) + if err != nil { + return err + } + + //S = S + r / T; + sFloat = sFloat.Add(reward.ToDec().Quo(stakedAmount.ToDec())) + sr.DistributedStake = sFloat.String() + + return nil +} diff --git a/x/rewards/keeper/unlock.go b/x/rewards/keeper/unlock.go new file mode 100644 index 00000000..2d24d423 --- /dev/null +++ b/x/rewards/keeper/unlock.go @@ -0,0 +1,44 @@ +package keeper + +import ( + "github.com/bze-alphateam/bze/x/rewards/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +func (k Keeper) GetUnlockPendingUnlockParticipantsHook() types.EpochHook { + hookName := "pending_unlock_hook" + return types.NewBeforeEpochHook(hookName, func(ctx sdk.Context, epochIdentifier string, epochNumber int64) error { + k.Logger(ctx). + With("epoch", epochIdentifier, "epoch_number", epochNumber, "hook_name", hookName). + Debug("preparing to execute hook") + k.UnlockAllPendingUnlockParticipants(ctx, epochNumber) + + return nil + }) +} + +func (k Keeper) UnlockAllPendingUnlockParticipants(ctx sdk.Context, epochNumber int64) { + pending := k.GetAllEpochPendingUnlockParticipant(ctx, epochNumber) + for _, p := range pending { + logger := k.Logger(ctx).With("pending", p) + partCoins, err := k.getAmountToCapture("", p.Denom, p.Amount, int64(1)) + if err != nil { + logger.Error(err.Error()) + continue + } + + acc, err := sdk.AccAddressFromBech32(p.Address) + if err != nil { + logger.Error(err.Error()) + continue + } + + err = k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, acc, partCoins) + if err != nil { + logger.Error(err.Error()) + continue + } + + k.RemovePendingUnlockParticipant(ctx, p) + } +} diff --git a/x/rewards/types/expected_keepers.go b/x/rewards/types/expected_keepers.go index 052ed4e0..47d534a8 100644 --- a/x/rewards/types/expected_keepers.go +++ b/x/rewards/types/expected_keepers.go @@ -28,3 +28,7 @@ type BankKeeper interface { type TradingKeeper interface { MarketExists(ctx sdk.Context, marketId string) bool } + +type EpochKeeper interface { + GetEpochCountByIdentifier(ctx sdk.Context, identifier string) int64 +} diff --git a/x/rewards/types/hook.go b/x/rewards/types/hook.go new file mode 100644 index 00000000..49997085 --- /dev/null +++ b/x/rewards/types/hook.go @@ -0,0 +1,27 @@ +package types + +import sdk "github.com/cosmos/cosmos-sdk/types" + +type EpochHook struct { + before func(ctx sdk.Context, epochIdentifier string, epochNumber int64) error + Name string +} + +func NewBeforeEpochHook(name string, before func(ctx sdk.Context, epochIdentifier string, epochNumber int64) error) EpochHook { + return EpochHook{ + Name: name, + before: before, + } +} + +func (e EpochHook) BeforeEpochStart(ctx sdk.Context, epochIdentifier string, epochNumber int64) error { + return e.before(ctx, epochIdentifier, epochNumber) +} + +func (e EpochHook) AfterEpochEnd(_ sdk.Context, _ string, _ int64) error { + return nil +} + +func (e EpochHook) GetName() string { + return e.Name +} diff --git a/x/rewards/types/key_pending_unlock_participant.go b/x/rewards/types/key_pending_unlock_participant.go new file mode 100644 index 00000000..32467db4 --- /dev/null +++ b/x/rewards/types/key_pending_unlock_participant.go @@ -0,0 +1,27 @@ +package types + +import ( + "encoding/binary" + "fmt" +) + +var _ binary.ByteOrder + +const ( + // PendingUnlockParticipantKeyPrefix is the prefix to retrieve all PendingUnlockParticipant + PendingUnlockParticipantKeyPrefix = "pup/v/" +) + +// PendingUnlockParticipantKey returns the store key to retrieve a PendingUnlockParticipant from the index fields +func PendingUnlockParticipantKey(key string) []byte { + return []byte(key + "/") +} + +func CreatePendingUnlockParticipantKey(epoch int64, key string) string { + return fmt.Sprintf("%d/%s/", epoch, key) +} + +// PendingUnlockParticipantPrefix returns the store key to retrieve all PendingUnlockParticipant for an epoch +func PendingUnlockParticipantPrefix(epoch int64) string { + return fmt.Sprintf("%s/%d/", PendingUnlockParticipantKeyPrefix, epoch) +} diff --git a/x/rewards/types/staking_reward_participant.pb.go b/x/rewards/types/staking_reward_participant.pb.go index 5841647f..f76cf120 100644 --- a/x/rewards/types/staking_reward_participant.pb.go +++ b/x/rewards/types/staking_reward_participant.pb.go @@ -90,8 +90,77 @@ func (m *StakingRewardParticipant) GetJoinedAt() string { return "" } +type PendingUnlockParticipant struct { + Index string `protobuf:"bytes,1,opt,name=index,proto3" json:"index,omitempty"` + Address string `protobuf:"bytes,2,opt,name=address,proto3" json:"address,omitempty"` + Amount string `protobuf:"bytes,3,opt,name=amount,proto3" json:"amount,omitempty"` + Denom string `protobuf:"bytes,4,opt,name=denom,proto3" json:"denom,omitempty"` +} + +func (m *PendingUnlockParticipant) Reset() { *m = PendingUnlockParticipant{} } +func (m *PendingUnlockParticipant) String() string { return proto.CompactTextString(m) } +func (*PendingUnlockParticipant) ProtoMessage() {} +func (*PendingUnlockParticipant) Descriptor() ([]byte, []int) { + return fileDescriptor_c38d5e7e7b44d312, []int{1} +} +func (m *PendingUnlockParticipant) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *PendingUnlockParticipant) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_PendingUnlockParticipant.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 *PendingUnlockParticipant) XXX_Merge(src proto.Message) { + xxx_messageInfo_PendingUnlockParticipant.Merge(m, src) +} +func (m *PendingUnlockParticipant) XXX_Size() int { + return m.Size() +} +func (m *PendingUnlockParticipant) XXX_DiscardUnknown() { + xxx_messageInfo_PendingUnlockParticipant.DiscardUnknown(m) +} + +var xxx_messageInfo_PendingUnlockParticipant proto.InternalMessageInfo + +func (m *PendingUnlockParticipant) GetIndex() string { + if m != nil { + return m.Index + } + return "" +} + +func (m *PendingUnlockParticipant) GetAddress() string { + if m != nil { + return m.Address + } + return "" +} + +func (m *PendingUnlockParticipant) GetAmount() string { + if m != nil { + return m.Amount + } + return "" +} + +func (m *PendingUnlockParticipant) GetDenom() string { + if m != nil { + return m.Denom + } + return "" +} + func init() { proto.RegisterType((*StakingRewardParticipant)(nil), "bze.v1.rewards.StakingRewardParticipant") + proto.RegisterType((*PendingUnlockParticipant)(nil), "bze.v1.rewards.PendingUnlockParticipant") } func init() { @@ -99,22 +168,25 @@ func init() { } var fileDescriptor_c38d5e7e7b44d312 = []byte{ - // 228 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0xd2, 0x28, 0x4a, 0x2d, 0x4f, - 0x2c, 0x4a, 0x29, 0xd6, 0x2f, 0x2e, 0x49, 0xcc, 0xce, 0xcc, 0x4b, 0x8f, 0x87, 0xf0, 0xe3, 0x0b, - 0x12, 0x8b, 0x4a, 0x32, 0x93, 0x33, 0x0b, 0x12, 0xf3, 0x4a, 0xf4, 0x0a, 0x8a, 0xf2, 0x4b, 0xf2, - 0x85, 0xf8, 0x92, 0xaa, 0x52, 0xf5, 0xca, 0x0c, 0xf5, 0xa0, 0x1a, 0x94, 0xda, 0x18, 0xb9, 0x24, - 0x82, 0x21, 0x9a, 0x82, 0xc0, 0x42, 0x01, 0x08, 0x2d, 0x42, 0x12, 0x5c, 0xec, 0x89, 0x29, 0x29, - 0x45, 0xa9, 0xc5, 0xc5, 0x12, 0x8c, 0x0a, 0x8c, 0x1a, 0x9c, 0x41, 0x30, 0xae, 0x90, 0x34, 0x17, - 0x27, 0xd4, 0x8a, 0xcc, 0x14, 0x09, 0x26, 0xb0, 0x1c, 0x07, 0x44, 0xc0, 0x33, 0x45, 0x48, 0x8c, - 0x8b, 0x2d, 0x31, 0x37, 0xbf, 0x34, 0xaf, 0x44, 0x82, 0x19, 0x2c, 0x03, 0xe5, 0x81, 0x34, 0x65, - 0xe5, 0x67, 0xe6, 0xa5, 0xa6, 0xc4, 0x27, 0x96, 0x48, 0xb0, 0x40, 0x34, 0x41, 0x04, 0x1c, 0x4b, - 0x9c, 0xdc, 0x4e, 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, 0x4a, 0x27, 0x3d, 0xb3, - 0x24, 0xa3, 0x34, 0x49, 0x2f, 0x39, 0x3f, 0x57, 0x3f, 0xa9, 0x2a, 0x55, 0x37, 0x31, 0xa7, 0x20, - 0x23, 0xb1, 0x24, 0x35, 0x11, 0xcc, 0xd3, 0xaf, 0xd0, 0x87, 0xf9, 0xbd, 0xa4, 0xb2, 0x20, 0xb5, - 0x38, 0x89, 0x0d, 0xec, 0x4f, 0x63, 0x40, 0x00, 0x00, 0x00, 0xff, 0xff, 0xbf, 0xc9, 0x2f, 0xb0, - 0x13, 0x01, 0x00, 0x00, + // 276 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x90, 0x31, 0x4b, 0xc3, 0x40, + 0x14, 0x80, 0x73, 0xd5, 0x56, 0x7b, 0x83, 0x43, 0x28, 0x72, 0x20, 0x1c, 0xd2, 0xa9, 0x83, 0x26, + 0x88, 0xbf, 0x40, 0x07, 0xc1, 0xad, 0x54, 0x5c, 0x5c, 0xc2, 0x4b, 0xee, 0x91, 0x9e, 0x6d, 0xee, + 0x42, 0xf2, 0xaa, 0xb1, 0x3f, 0xc0, 0xd9, 0x9f, 0xe5, 0xd8, 0xd1, 0x51, 0x92, 0x3f, 0x22, 0xe6, + 0x52, 0xac, 0x43, 0xc7, 0xef, 0x3d, 0x3e, 0xde, 0xc7, 0xe3, 0x93, 0x02, 0x5f, 0xa1, 0x50, 0x65, + 0x58, 0x12, 0x2c, 0xb4, 0x49, 0x23, 0xc7, 0x51, 0x0e, 0x05, 0xe9, 0x44, 0xe7, 0x60, 0x28, 0xc8, + 0x0b, 0x4b, 0xd6, 0x3f, 0x89, 0xd7, 0x18, 0xbc, 0x5c, 0x05, 0x9d, 0x30, 0x7e, 0x67, 0x5c, 0x3c, + 0x38, 0x69, 0xd6, 0x8e, 0xa6, 0x7f, 0x8a, 0x2f, 0xf8, 0x11, 0x28, 0x55, 0x60, 0x59, 0x0a, 0x76, + 0xce, 0x26, 0xc3, 0xd9, 0x16, 0xfd, 0x33, 0x3e, 0xec, 0x4e, 0x68, 0x25, 0x7a, 0xed, 0xee, 0xd8, + 0x0d, 0xee, 0x95, 0x7f, 0xca, 0x07, 0x90, 0xd9, 0x95, 0x21, 0x71, 0xd0, 0x6e, 0x3a, 0xfa, 0x95, + 0x9e, 0xad, 0x36, 0xa8, 0x22, 0x20, 0x71, 0xe8, 0x24, 0x37, 0xb8, 0xa1, 0x71, 0xc5, 0xc5, 0x14, + 0x8d, 0xd2, 0x26, 0x7d, 0x34, 0x4b, 0x9b, 0x2c, 0x76, 0x3b, 0x46, 0xbc, 0xaf, 0x8d, 0xc2, 0xaa, + 0xab, 0x70, 0xb0, 0x5b, 0xd7, 0xfb, 0x5f, 0xb7, 0x2f, 0x60, 0xc4, 0xfb, 0x0a, 0x8d, 0xcd, 0xba, + 0xe3, 0x0e, 0x6e, 0xef, 0x3e, 0x6b, 0xc9, 0x36, 0xb5, 0x64, 0xdf, 0xb5, 0x64, 0x1f, 0x8d, 0xf4, + 0x36, 0x8d, 0xf4, 0xbe, 0x1a, 0xe9, 0x3d, 0x5d, 0xa4, 0x9a, 0xe6, 0xab, 0x38, 0x48, 0x6c, 0x16, + 0xc6, 0x6b, 0xbc, 0x84, 0x65, 0x3e, 0x07, 0x42, 0x68, 0x29, 0xac, 0xc2, 0xed, 0xd7, 0xe9, 0x2d, + 0xc7, 0x32, 0x1e, 0xb4, 0x1f, 0xbe, 0xfe, 0x09, 0x00, 0x00, 0xff, 0xff, 0x1a, 0xa1, 0x9f, 0xd7, + 0x8d, 0x01, 0x00, 0x00, } func (m *StakingRewardParticipant) Marshal() (dAtA []byte, err error) { @@ -168,6 +240,57 @@ func (m *StakingRewardParticipant) MarshalToSizedBuffer(dAtA []byte) (int, error return len(dAtA) - i, nil } +func (m *PendingUnlockParticipant) 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 *PendingUnlockParticipant) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *PendingUnlockParticipant) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Denom) > 0 { + i -= len(m.Denom) + copy(dAtA[i:], m.Denom) + i = encodeVarintStakingRewardParticipant(dAtA, i, uint64(len(m.Denom))) + i-- + dAtA[i] = 0x22 + } + if len(m.Amount) > 0 { + i -= len(m.Amount) + copy(dAtA[i:], m.Amount) + i = encodeVarintStakingRewardParticipant(dAtA, i, uint64(len(m.Amount))) + i-- + dAtA[i] = 0x1a + } + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintStakingRewardParticipant(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0x12 + } + if len(m.Index) > 0 { + i -= len(m.Index) + copy(dAtA[i:], m.Index) + i = encodeVarintStakingRewardParticipant(dAtA, i, uint64(len(m.Index))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func encodeVarintStakingRewardParticipant(dAtA []byte, offset int, v uint64) int { offset -= sovStakingRewardParticipant(v) base := offset @@ -204,6 +327,31 @@ func (m *StakingRewardParticipant) Size() (n int) { return n } +func (m *PendingUnlockParticipant) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Index) + if l > 0 { + n += 1 + l + sovStakingRewardParticipant(uint64(l)) + } + l = len(m.Address) + if l > 0 { + n += 1 + l + sovStakingRewardParticipant(uint64(l)) + } + l = len(m.Amount) + if l > 0 { + n += 1 + l + sovStakingRewardParticipant(uint64(l)) + } + l = len(m.Denom) + if l > 0 { + n += 1 + l + sovStakingRewardParticipant(uint64(l)) + } + return n +} + func sovStakingRewardParticipant(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -388,6 +536,184 @@ func (m *StakingRewardParticipant) Unmarshal(dAtA []byte) error { } return nil } +func (m *PendingUnlockParticipant) 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 ErrIntOverflowStakingRewardParticipant + } + 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: PendingUnlockParticipant: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PendingUnlockParticipant: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Index", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowStakingRewardParticipant + } + 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 ErrInvalidLengthStakingRewardParticipant + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthStakingRewardParticipant + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Index = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowStakingRewardParticipant + } + 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 ErrInvalidLengthStakingRewardParticipant + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthStakingRewardParticipant + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowStakingRewardParticipant + } + 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 ErrInvalidLengthStakingRewardParticipant + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthStakingRewardParticipant + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Amount = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Denom", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowStakingRewardParticipant + } + 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 ErrInvalidLengthStakingRewardParticipant + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthStakingRewardParticipant + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Denom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipStakingRewardParticipant(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthStakingRewardParticipant + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipStakingRewardParticipant(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 From 8538a8dcf8948274b64051716dbc6f7fcde6370a Mon Sep 17 00:00:00 2001 From: faneaatiku Date: Tue, 19 Mar 2024 12:15:41 +0200 Subject: [PATCH 13/35] added epochs hooks to rewards --- testutil/simapp/app.go | 9 ++++- x/rewards/keeper/hooks.go | 40 +++++++++++++++++++ x/rewards/keeper/msg_server_join_staking.go | 20 +++++----- .../keeper/staking_reward_distribution.go | 35 ++++------------ x/rewards/keeper/unlock.go | 14 +------ x/rewards/types/hook.go | 16 ++++---- .../types/key_pending_unlock_participant.go | 2 +- 7 files changed, 75 insertions(+), 61 deletions(-) create mode 100644 x/rewards/keeper/hooks.go diff --git a/testutil/simapp/app.go b/testutil/simapp/app.go index 67722f7b..4d7ab989 100644 --- a/testutil/simapp/app.go +++ b/testutil/simapp/app.go @@ -465,7 +465,6 @@ func New( appCodec, keys[epochstypes.StoreKey], keys[epochstypes.MemStoreKey], - nil, //no hooks registered ) app.RewardsKeeper = *rewardskeeper.NewKeeper( @@ -476,6 +475,14 @@ func New( app.BankKeeper, app.DistrKeeper, app.TradebinKeeper, + app.EpochsKeeper, + ) + + app.EpochsKeeper.SetHooks( + []epochstypes.EpochHook{ + app.RewardsKeeper.GetDistributeAllStakingRewardsHook(), + app.RewardsKeeper.GetUnlockPendingUnlockParticipantsHook(), + }, ) scavengeModule := scavengemodule.NewAppModule(appCodec, app.ScavengeKeeper) diff --git a/x/rewards/keeper/hooks.go b/x/rewards/keeper/hooks.go new file mode 100644 index 00000000..e4d811ac --- /dev/null +++ b/x/rewards/keeper/hooks.go @@ -0,0 +1,40 @@ +package keeper + +import ( + "github.com/bze-alphateam/bze/x/rewards/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +func (k Keeper) GetDistributeAllStakingRewardsHook() types.EpochHook { + hookName := "distribution_hook" + return types.NewBeforeEpochHook(hookName, func(ctx sdk.Context, epochIdentifier string, epochNumber int64) error { + if epochIdentifier != distributionEpoch { + return nil + } + + k.Logger(ctx). + With("epoch", epochIdentifier, "epoch_number", epochNumber, "hook_name", hookName). + Debug("preparing to execute hook") + + k.DistributeAllStakingRewards(ctx) + + return nil + }) +} + +func (k Keeper) GetUnlockPendingUnlockParticipantsHook() types.EpochHook { + hookName := "pending_unlock_hook" + return types.NewBeforeEpochHook(hookName, func(ctx sdk.Context, epochIdentifier string, epochNumber int64) error { + if epochIdentifier != distributionEpoch { + return nil + } + + k.Logger(ctx). + With("epoch", epochIdentifier, "epoch_number", epochNumber, "hook_name", hookName). + Debug("preparing to execute hook") + + k.UnlockAllPendingUnlockParticipants(ctx, epochNumber) + + return nil + }) +} diff --git a/x/rewards/keeper/msg_server_join_staking.go b/x/rewards/keeper/msg_server_join_staking.go index 7e945b73..0d3f33b3 100644 --- a/x/rewards/keeper/msg_server_join_staking.go +++ b/x/rewards/keeper/msg_server_join_staking.go @@ -80,20 +80,20 @@ func (k msgServer) JoinStaking(goCtx context.Context, msg *types.MsgJoinStaking) // claimPending - sends the pending rewards to the participant and updates the participant.JoinedAt field with current // StakingReward.DistributedStake func (k msgServer) claimPending(ctx sdk.Context, sr types.StakingReward, participant *types.StakingRewardParticipant) (*sdk.Coin, error) { - deposited, ok := sdk.NewIntFromString(participant.Amount) - if !ok { - return nil, fmt.Errorf("could not transform participant amount from storage into int") + deposited, err := sdk.NewDecFromStr(participant.Amount) + if err != nil { + return nil, err } - distributedStake, ok := sdk.NewIntFromString(sr.DistributedStake) - if !ok { - return nil, fmt.Errorf("could not transform distributed stake from storage into int") + distributedStake, err := sdk.NewDecFromStr(sr.DistributedStake) + if err != nil { + return nil, err } - joinedAt, ok := sdk.NewIntFromString(participant.JoinedAt) - if !ok { - return nil, fmt.Errorf("could not transform joined at from storage into int") + joinedAt, err := sdk.NewDecFromStr(participant.JoinedAt) + if err != nil { + return nil, err } - reward := deposited.Mul(distributedStake.Sub(joinedAt)) + reward := deposited.Mul(distributedStake.Sub(joinedAt)).TruncateInt() if !reward.IsPositive() { return nil, fmt.Errorf("no rewards to claim") } diff --git a/x/rewards/keeper/staking_reward_distribution.go b/x/rewards/keeper/staking_reward_distribution.go index 9fc97be6..1cfe8616 100644 --- a/x/rewards/keeper/staking_reward_distribution.go +++ b/x/rewards/keeper/staking_reward_distribution.go @@ -6,41 +6,18 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ) -func (k Keeper) GetDistributeAllStakingRewardsHook() types.EpochHook { - hookName := "distribution_hook" - return types.NewBeforeEpochHook(hookName, func(ctx sdk.Context, epochIdentifier string, epochNumber int64) error { - k.Logger(ctx). - With("epoch", epochIdentifier, "epoch_number", epochNumber, "hook_name", hookName). - Debug("preparing to execute hook") - - k.DistributeAllStakingRewards(ctx) - - return nil - }) -} - func (k Keeper) DistributeAllStakingRewards(ctx sdk.Context) { k.IterateAllStakingRewards(ctx, k.getDistributeRewardHandler()) } func (k Keeper) getDistributeRewardHandler() func(ctx sdk.Context, reward types.StakingReward) (stop bool) { return func(ctx sdk.Context, sr types.StakingReward) (stop bool) { - logger := k.Logger(ctx).With("reward_id", sr.RewardId, "type", "staking") - if sr.Payouts >= sr.Duration { - logger.Debug("stake finished. skipping distribution") - stop = false - return - } + logger := k.Logger(ctx).With("staking_reward", sr) - stakedAmount, ok := sdk.NewIntFromString(sr.StakedAmount) - if !ok { - logger.Error("could not transform staked amount from storage into int") - stop = true - return - } + logger.Debug("preparing to distribute staking reward") - if !stakedAmount.IsPositive() { - logger.Debug("no stakers found. skipping distribution") + if sr.Payouts >= sr.Duration { + logger.Debug("staking reward finished. skipping distribution") stop = false return } @@ -52,10 +29,12 @@ func (k Keeper) getDistributeRewardHandler() func(ctx sdk.Context, reward types. return } - //increment payouts to skip when the reward finished (a.k.a. all payouts calculated) + //increment payouts to know when the reward finished (a.k.a. all payouts calculated) sr.Payouts++ k.SetStakingReward(ctx, sr) + logger.Debug("staking reward distributed") + return } } diff --git a/x/rewards/keeper/unlock.go b/x/rewards/keeper/unlock.go index 2d24d423..48a57a45 100644 --- a/x/rewards/keeper/unlock.go +++ b/x/rewards/keeper/unlock.go @@ -5,22 +5,10 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ) -func (k Keeper) GetUnlockPendingUnlockParticipantsHook() types.EpochHook { - hookName := "pending_unlock_hook" - return types.NewBeforeEpochHook(hookName, func(ctx sdk.Context, epochIdentifier string, epochNumber int64) error { - k.Logger(ctx). - With("epoch", epochIdentifier, "epoch_number", epochNumber, "hook_name", hookName). - Debug("preparing to execute hook") - k.UnlockAllPendingUnlockParticipants(ctx, epochNumber) - - return nil - }) -} - func (k Keeper) UnlockAllPendingUnlockParticipants(ctx sdk.Context, epochNumber int64) { pending := k.GetAllEpochPendingUnlockParticipant(ctx, epochNumber) for _, p := range pending { - logger := k.Logger(ctx).With("pending", p) + logger := k.Logger(ctx).With("pending_unlock", p) partCoins, err := k.getAmountToCapture("", p.Denom, p.Amount, int64(1)) if err != nil { logger.Error(err.Error()) diff --git a/x/rewards/types/hook.go b/x/rewards/types/hook.go index 49997085..ea2b6386 100644 --- a/x/rewards/types/hook.go +++ b/x/rewards/types/hook.go @@ -3,22 +3,22 @@ package types import sdk "github.com/cosmos/cosmos-sdk/types" type EpochHook struct { - before func(ctx sdk.Context, epochIdentifier string, epochNumber int64) error - Name string + after func(ctx sdk.Context, epochIdentifier string, epochNumber int64) error + Name string } -func NewBeforeEpochHook(name string, before func(ctx sdk.Context, epochIdentifier string, epochNumber int64) error) EpochHook { +func NewBeforeEpochHook(name string, after func(ctx sdk.Context, epochIdentifier string, epochNumber int64) error) EpochHook { return EpochHook{ - Name: name, - before: before, + Name: name, + after: after, } } -func (e EpochHook) BeforeEpochStart(ctx sdk.Context, epochIdentifier string, epochNumber int64) error { - return e.before(ctx, epochIdentifier, epochNumber) +func (e EpochHook) AfterEpochEnd(ctx sdk.Context, epochIdentifier string, epochNumber int64) error { + return e.after(ctx, epochIdentifier, epochNumber) } -func (e EpochHook) AfterEpochEnd(_ sdk.Context, _ string, _ int64) error { +func (e EpochHook) BeforeEpochStart(_ sdk.Context, _ string, _ int64) error { return nil } diff --git a/x/rewards/types/key_pending_unlock_participant.go b/x/rewards/types/key_pending_unlock_participant.go index 32467db4..d8f1186b 100644 --- a/x/rewards/types/key_pending_unlock_participant.go +++ b/x/rewards/types/key_pending_unlock_participant.go @@ -23,5 +23,5 @@ func CreatePendingUnlockParticipantKey(epoch int64, key string) string { // PendingUnlockParticipantPrefix returns the store key to retrieve all PendingUnlockParticipant for an epoch func PendingUnlockParticipantPrefix(epoch int64) string { - return fmt.Sprintf("%s/%d/", PendingUnlockParticipantKeyPrefix, epoch) + return fmt.Sprintf("%s%d/", PendingUnlockParticipantKeyPrefix, epoch) } From 28b70831af75298cf7d0408e3bafa833ca5ed858 Mon Sep 17 00:00:00 2001 From: faneaatiku Date: Tue, 19 Mar 2024 12:27:33 +0200 Subject: [PATCH 14/35] added pending unlock to genesis --- proto/rewards/genesis.proto | 1 + .../bze-alphateam/bze/bze.v1.rewards/index.ts | 64 +++++----- .../bze/bze.v1.rewards/module/index.ts | 24 ++-- .../module/types/rewards/genesis.ts | 46 +++++++- x/rewards/genesis.go | 7 ++ x/rewards/keeper/hooks.go | 4 +- .../keeper/pending_unlock_participant.go | 16 +++ x/rewards/types/genesis.pb.go | 109 ++++++++++++++---- x/rewards/types/hook.go | 2 +- 9 files changed, 201 insertions(+), 72 deletions(-) diff --git a/proto/rewards/genesis.proto b/proto/rewards/genesis.proto index 5abe691b..eaa541fc 100644 --- a/proto/rewards/genesis.proto +++ b/proto/rewards/genesis.proto @@ -19,5 +19,6 @@ message GenesisState { repeated TradingReward trading_reward_list = 5 [(gogoproto.nullable) = false]; repeated StakingRewardParticipant staking_reward_participant_list = 6 [(gogoproto.nullable) = false]; + repeated PendingUnlockParticipant pending_unlock_participant_list = 7 [(gogoproto.nullable) = false]; // this line is used by starport scaffolding # genesis/proto/state } diff --git a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/index.ts b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/index.ts index 442ab5bc..a52629a2 100755 --- a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/index.ts +++ b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/index.ts @@ -333,18 +333,18 @@ export default { }, - async sendMsgCreateStakingReward({ rootGetters }, { value, fee = [], memo = '' }) { + async sendMsgJoinStaking({ rootGetters }, { value, fee = [], memo = '' }) { try { const txClient=await initTxClient(rootGetters) - const msg = await txClient.msgCreateStakingReward(value) + const msg = await txClient.msgJoinStaking(value) const result = await txClient.signAndBroadcast([msg], {fee: { amount: fee, gas: "200000" }, memo}) return result } catch (e) { if (e == MissingWalletError) { - throw new Error('TxClient:MsgCreateStakingReward:Init Could not initialize signing client. Wallet is required.') + throw new Error('TxClient:MsgJoinStaking:Init Could not initialize signing client. Wallet is required.') }else{ - throw new Error('TxClient:MsgCreateStakingReward:Send Could not broadcast Tx: '+ e.message) + throw new Error('TxClient:MsgJoinStaking:Send Could not broadcast Tx: '+ e.message) } } }, @@ -363,18 +363,18 @@ export default { } } }, - async sendMsgClaimStakingRewards({ rootGetters }, { value, fee = [], memo = '' }) { + async sendMsgUpdateStakingReward({ rootGetters }, { value, fee = [], memo = '' }) { try { const txClient=await initTxClient(rootGetters) - const msg = await txClient.msgClaimStakingRewards(value) + const msg = await txClient.msgUpdateStakingReward(value) const result = await txClient.signAndBroadcast([msg], {fee: { amount: fee, gas: "200000" }, memo}) return result } catch (e) { if (e == MissingWalletError) { - throw new Error('TxClient:MsgClaimStakingRewards:Init Could not initialize signing client. Wallet is required.') + throw new Error('TxClient:MsgUpdateStakingReward:Init Could not initialize signing client. Wallet is required.') }else{ - throw new Error('TxClient:MsgClaimStakingRewards:Send Could not broadcast Tx: '+ e.message) + throw new Error('TxClient:MsgUpdateStakingReward:Send Could not broadcast Tx: '+ e.message) } } }, @@ -393,47 +393,47 @@ export default { } } }, - async sendMsgJoinStaking({ rootGetters }, { value, fee = [], memo = '' }) { + async sendMsgCreateStakingReward({ rootGetters }, { value, fee = [], memo = '' }) { try { const txClient=await initTxClient(rootGetters) - const msg = await txClient.msgJoinStaking(value) + const msg = await txClient.msgCreateStakingReward(value) const result = await txClient.signAndBroadcast([msg], {fee: { amount: fee, gas: "200000" }, memo}) return result } catch (e) { if (e == MissingWalletError) { - throw new Error('TxClient:MsgJoinStaking:Init Could not initialize signing client. Wallet is required.') + throw new Error('TxClient:MsgCreateStakingReward:Init Could not initialize signing client. Wallet is required.') }else{ - throw new Error('TxClient:MsgJoinStaking:Send Could not broadcast Tx: '+ e.message) + throw new Error('TxClient:MsgCreateStakingReward:Send Could not broadcast Tx: '+ e.message) } } }, - async sendMsgUpdateStakingReward({ rootGetters }, { value, fee = [], memo = '' }) { + async sendMsgClaimStakingRewards({ rootGetters }, { value, fee = [], memo = '' }) { try { const txClient=await initTxClient(rootGetters) - const msg = await txClient.msgUpdateStakingReward(value) + const msg = await txClient.msgClaimStakingRewards(value) const result = await txClient.signAndBroadcast([msg], {fee: { amount: fee, gas: "200000" }, memo}) return result } catch (e) { if (e == MissingWalletError) { - throw new Error('TxClient:MsgUpdateStakingReward:Init Could not initialize signing client. Wallet is required.') + throw new Error('TxClient:MsgClaimStakingRewards:Init Could not initialize signing client. Wallet is required.') }else{ - throw new Error('TxClient:MsgUpdateStakingReward:Send Could not broadcast Tx: '+ e.message) + throw new Error('TxClient:MsgClaimStakingRewards:Send Could not broadcast Tx: '+ e.message) } } }, - async MsgCreateStakingReward({ rootGetters }, { value }) { + async MsgJoinStaking({ rootGetters }, { value }) { try { const txClient=await initTxClient(rootGetters) - const msg = await txClient.msgCreateStakingReward(value) + const msg = await txClient.msgJoinStaking(value) return msg } catch (e) { if (e == MissingWalletError) { - throw new Error('TxClient:MsgCreateStakingReward:Init Could not initialize signing client. Wallet is required.') + throw new Error('TxClient:MsgJoinStaking:Init Could not initialize signing client. Wallet is required.') } else{ - throw new Error('TxClient:MsgCreateStakingReward:Create Could not create message: ' + e.message) + throw new Error('TxClient:MsgJoinStaking:Create Could not create message: ' + e.message) } } }, @@ -450,16 +450,16 @@ export default { } } }, - async MsgClaimStakingRewards({ rootGetters }, { value }) { + async MsgUpdateStakingReward({ rootGetters }, { value }) { try { const txClient=await initTxClient(rootGetters) - const msg = await txClient.msgClaimStakingRewards(value) + const msg = await txClient.msgUpdateStakingReward(value) return msg } catch (e) { if (e == MissingWalletError) { - throw new Error('TxClient:MsgClaimStakingRewards:Init Could not initialize signing client. Wallet is required.') + throw new Error('TxClient:MsgUpdateStakingReward:Init Could not initialize signing client. Wallet is required.') } else{ - throw new Error('TxClient:MsgClaimStakingRewards:Create Could not create message: ' + e.message) + throw new Error('TxClient:MsgUpdateStakingReward:Create Could not create message: ' + e.message) } } }, @@ -476,29 +476,29 @@ export default { } } }, - async MsgJoinStaking({ rootGetters }, { value }) { + async MsgCreateStakingReward({ rootGetters }, { value }) { try { const txClient=await initTxClient(rootGetters) - const msg = await txClient.msgJoinStaking(value) + const msg = await txClient.msgCreateStakingReward(value) return msg } catch (e) { if (e == MissingWalletError) { - throw new Error('TxClient:MsgJoinStaking:Init Could not initialize signing client. Wallet is required.') + throw new Error('TxClient:MsgCreateStakingReward:Init Could not initialize signing client. Wallet is required.') } else{ - throw new Error('TxClient:MsgJoinStaking:Create Could not create message: ' + e.message) + throw new Error('TxClient:MsgCreateStakingReward:Create Could not create message: ' + e.message) } } }, - async MsgUpdateStakingReward({ rootGetters }, { value }) { + async MsgClaimStakingRewards({ rootGetters }, { value }) { try { const txClient=await initTxClient(rootGetters) - const msg = await txClient.msgUpdateStakingReward(value) + const msg = await txClient.msgClaimStakingRewards(value) return msg } catch (e) { if (e == MissingWalletError) { - throw new Error('TxClient:MsgUpdateStakingReward:Init Could not initialize signing client. Wallet is required.') + throw new Error('TxClient:MsgClaimStakingRewards:Init Could not initialize signing client. Wallet is required.') } else{ - throw new Error('TxClient:MsgUpdateStakingReward:Create Could not create message: ' + e.message) + throw new Error('TxClient:MsgClaimStakingRewards:Create Could not create message: ' + e.message) } } }, diff --git a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/index.ts b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/index.ts index 80a2439e..ad7f8f00 100755 --- a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/index.ts +++ b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/index.ts @@ -4,21 +4,21 @@ import { StdFee } from "@cosmjs/launchpad"; import { SigningStargateClient } from "@cosmjs/stargate"; import { Registry, OfflineSigner, EncodeObject, DirectSecp256k1HdWallet } from "@cosmjs/proto-signing"; import { Api } from "./rest"; -import { MsgCreateStakingReward } from "./types/rewards/tx"; -import { MsgExitStaking } from "./types/rewards/tx"; -import { MsgClaimStakingRewards } from "./types/rewards/tx"; -import { MsgCreateTradingReward } from "./types/rewards/tx"; import { MsgJoinStaking } from "./types/rewards/tx"; +import { MsgExitStaking } from "./types/rewards/tx"; import { MsgUpdateStakingReward } from "./types/rewards/tx"; +import { MsgCreateTradingReward } from "./types/rewards/tx"; +import { MsgCreateStakingReward } from "./types/rewards/tx"; +import { MsgClaimStakingRewards } from "./types/rewards/tx"; const types = [ - ["/bze.v1.rewards.MsgCreateStakingReward", MsgCreateStakingReward], - ["/bze.v1.rewards.MsgExitStaking", MsgExitStaking], - ["/bze.v1.rewards.MsgClaimStakingRewards", MsgClaimStakingRewards], - ["/bze.v1.rewards.MsgCreateTradingReward", MsgCreateTradingReward], ["/bze.v1.rewards.MsgJoinStaking", MsgJoinStaking], + ["/bze.v1.rewards.MsgExitStaking", MsgExitStaking], ["/bze.v1.rewards.MsgUpdateStakingReward", MsgUpdateStakingReward], + ["/bze.v1.rewards.MsgCreateTradingReward", MsgCreateTradingReward], + ["/bze.v1.rewards.MsgCreateStakingReward", MsgCreateStakingReward], + ["/bze.v1.rewards.MsgClaimStakingRewards", MsgClaimStakingRewards], ]; export const MissingWalletError = new Error("wallet is required"); @@ -51,12 +51,12 @@ const txClient = async (wallet: OfflineSigner, { addr: addr }: TxClientOptions = return { signAndBroadcast: (msgs: EncodeObject[], { fee, memo }: SignAndBroadcastOptions = {fee: defaultFee, memo: ""}) => client.signAndBroadcast(address, msgs, fee,memo), - msgCreateStakingReward: (data: MsgCreateStakingReward): EncodeObject => ({ typeUrl: "/bze.v1.rewards.MsgCreateStakingReward", value: MsgCreateStakingReward.fromPartial( data ) }), - msgExitStaking: (data: MsgExitStaking): EncodeObject => ({ typeUrl: "/bze.v1.rewards.MsgExitStaking", value: MsgExitStaking.fromPartial( data ) }), - msgClaimStakingRewards: (data: MsgClaimStakingRewards): EncodeObject => ({ typeUrl: "/bze.v1.rewards.MsgClaimStakingRewards", value: MsgClaimStakingRewards.fromPartial( data ) }), - msgCreateTradingReward: (data: MsgCreateTradingReward): EncodeObject => ({ typeUrl: "/bze.v1.rewards.MsgCreateTradingReward", value: MsgCreateTradingReward.fromPartial( data ) }), msgJoinStaking: (data: MsgJoinStaking): EncodeObject => ({ typeUrl: "/bze.v1.rewards.MsgJoinStaking", value: MsgJoinStaking.fromPartial( data ) }), + msgExitStaking: (data: MsgExitStaking): EncodeObject => ({ typeUrl: "/bze.v1.rewards.MsgExitStaking", value: MsgExitStaking.fromPartial( data ) }), msgUpdateStakingReward: (data: MsgUpdateStakingReward): EncodeObject => ({ typeUrl: "/bze.v1.rewards.MsgUpdateStakingReward", value: MsgUpdateStakingReward.fromPartial( data ) }), + msgCreateTradingReward: (data: MsgCreateTradingReward): EncodeObject => ({ typeUrl: "/bze.v1.rewards.MsgCreateTradingReward", value: MsgCreateTradingReward.fromPartial( data ) }), + msgCreateStakingReward: (data: MsgCreateStakingReward): EncodeObject => ({ typeUrl: "/bze.v1.rewards.MsgCreateStakingReward", value: MsgCreateStakingReward.fromPartial( data ) }), + msgClaimStakingRewards: (data: MsgClaimStakingRewards): EncodeObject => ({ typeUrl: "/bze.v1.rewards.MsgClaimStakingRewards", value: MsgClaimStakingRewards.fromPartial( data ) }), }; }; diff --git a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/genesis.ts b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/genesis.ts index 87bcb32d..75e96d25 100644 --- a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/genesis.ts +++ b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/genesis.ts @@ -4,7 +4,10 @@ import { util, configure, Writer, Reader } from "protobufjs/minimal"; import { Params } from "../rewards/params"; import { StakingReward } from "../rewards/staking_reward"; import { TradingReward } from "../rewards/trading_reward"; -import { StakingRewardParticipant } from "../rewards/staking_reward_participant"; +import { + StakingRewardParticipant, + PendingUnlockParticipant, +} from "../rewards/staking_reward_participant"; export const protobufPackage = "bze.v1.rewards"; @@ -15,8 +18,9 @@ export interface GenesisState { staking_rewards_counter: number; trading_rewards_counter: number; trading_reward_list: TradingReward[]; - /** this line is used by starport scaffolding # genesis/proto/state */ staking_reward_participant_list: StakingRewardParticipant[]; + /** this line is used by starport scaffolding # genesis/proto/state */ + pending_unlock_participant_list: PendingUnlockParticipant[]; } const baseGenesisState: object = { @@ -44,6 +48,9 @@ export const GenesisState = { for (const v of message.staking_reward_participant_list) { StakingRewardParticipant.encode(v!, writer.uint32(50).fork()).ldelim(); } + for (const v of message.pending_unlock_participant_list) { + PendingUnlockParticipant.encode(v!, writer.uint32(58).fork()).ldelim(); + } return writer; }, @@ -54,6 +61,7 @@ export const GenesisState = { message.staking_reward_list = []; message.trading_reward_list = []; message.staking_reward_participant_list = []; + message.pending_unlock_participant_list = []; while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { @@ -85,6 +93,11 @@ export const GenesisState = { StakingRewardParticipant.decode(reader, reader.uint32()) ); break; + case 7: + message.pending_unlock_participant_list.push( + PendingUnlockParticipant.decode(reader, reader.uint32()) + ); + break; default: reader.skipType(tag & 7); break; @@ -98,6 +111,7 @@ export const GenesisState = { message.staking_reward_list = []; message.trading_reward_list = []; message.staking_reward_participant_list = []; + message.pending_unlock_participant_list = []; if (object.params !== undefined && object.params !== null) { message.params = Params.fromJSON(object.params); } else { @@ -145,6 +159,16 @@ export const GenesisState = { ); } } + if ( + object.pending_unlock_participant_list !== undefined && + object.pending_unlock_participant_list !== null + ) { + for (const e of object.pending_unlock_participant_list) { + message.pending_unlock_participant_list.push( + PendingUnlockParticipant.fromJSON(e) + ); + } + } return message; }, @@ -177,6 +201,13 @@ export const GenesisState = { } else { obj.staking_reward_participant_list = []; } + if (message.pending_unlock_participant_list) { + obj.pending_unlock_participant_list = message.pending_unlock_participant_list.map( + (e) => (e ? PendingUnlockParticipant.toJSON(e) : undefined) + ); + } else { + obj.pending_unlock_participant_list = []; + } return obj; }, @@ -185,6 +216,7 @@ export const GenesisState = { message.staking_reward_list = []; message.trading_reward_list = []; message.staking_reward_participant_list = []; + message.pending_unlock_participant_list = []; if (object.params !== undefined && object.params !== null) { message.params = Params.fromPartial(object.params); } else { @@ -232,6 +264,16 @@ export const GenesisState = { ); } } + if ( + object.pending_unlock_participant_list !== undefined && + object.pending_unlock_participant_list !== null + ) { + for (const e of object.pending_unlock_participant_list) { + message.pending_unlock_participant_list.push( + PendingUnlockParticipant.fromPartial(e) + ); + } + } return message; }, }; diff --git a/x/rewards/genesis.go b/x/rewards/genesis.go index 99208f34..5e849342 100644 --- a/x/rewards/genesis.go +++ b/x/rewards/genesis.go @@ -22,6 +22,12 @@ func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) for _, elem := range genState.StakingRewardParticipantList { k.SetStakingRewardParticipant(ctx, elem) } + + // Set all the stakingRewardParticipant + for _, elem := range genState.PendingUnlockParticipantList { + k.SetPendingUnlockParticipant(ctx, elem) + } + // this line is used by starport scaffolding # genesis/module/init k.SetParams(ctx, genState.Params) k.SetTradingRewardsCounter(ctx, genState.TradingRewardsCounter) @@ -38,6 +44,7 @@ func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState { genesis.TradingRewardsCounter = k.GetTradingRewardsCounter(ctx) genesis.TradingRewardList = k.GetAllTradingReward(ctx) genesis.StakingRewardParticipantList = k.GetAllStakingRewardParticipant(ctx) + genesis.PendingUnlockParticipantList = k.GetAllPendingUnlockParticipant(ctx) // this line is used by starport scaffolding # genesis/module/export return genesis diff --git a/x/rewards/keeper/hooks.go b/x/rewards/keeper/hooks.go index e4d811ac..8b1a3ad9 100644 --- a/x/rewards/keeper/hooks.go +++ b/x/rewards/keeper/hooks.go @@ -7,7 +7,7 @@ import ( func (k Keeper) GetDistributeAllStakingRewardsHook() types.EpochHook { hookName := "distribution_hook" - return types.NewBeforeEpochHook(hookName, func(ctx sdk.Context, epochIdentifier string, epochNumber int64) error { + return types.NewAfterEpochHook(hookName, func(ctx sdk.Context, epochIdentifier string, epochNumber int64) error { if epochIdentifier != distributionEpoch { return nil } @@ -24,7 +24,7 @@ func (k Keeper) GetDistributeAllStakingRewardsHook() types.EpochHook { func (k Keeper) GetUnlockPendingUnlockParticipantsHook() types.EpochHook { hookName := "pending_unlock_hook" - return types.NewBeforeEpochHook(hookName, func(ctx sdk.Context, epochIdentifier string, epochNumber int64) error { + return types.NewAfterEpochHook(hookName, func(ctx sdk.Context, epochIdentifier string, epochNumber int64) error { if epochIdentifier != distributionEpoch { return nil } diff --git a/x/rewards/keeper/pending_unlock_participant.go b/x/rewards/keeper/pending_unlock_participant.go index 82031411..c93d91c1 100644 --- a/x/rewards/keeper/pending_unlock_participant.go +++ b/x/rewards/keeper/pending_unlock_participant.go @@ -34,3 +34,19 @@ func (k Keeper) GetAllEpochPendingUnlockParticipant(ctx sdk.Context, epoch int64 return } + +// GetAllPendingUnlockParticipant returns all types.PendingUnlockParticipant +func (k Keeper) GetAllPendingUnlockParticipant(ctx sdk.Context) (list []types.PendingUnlockParticipant) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.PendingUnlockParticipantKeyPrefix)) + iterator := sdk.KVStorePrefixIterator(store, []byte{}) + + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + var val types.PendingUnlockParticipant + k.cdc.MustUnmarshal(iterator.Value(), &val) + list = append(list, val) + } + + return +} diff --git a/x/rewards/types/genesis.pb.go b/x/rewards/types/genesis.pb.go index 7ea6c01d..0fb6d557 100644 --- a/x/rewards/types/genesis.pb.go +++ b/x/rewards/types/genesis.pb.go @@ -31,6 +31,7 @@ type GenesisState struct { TradingRewardsCounter uint64 `protobuf:"varint,4,opt,name=trading_rewards_counter,json=tradingRewardsCounter,proto3" json:"trading_rewards_counter,omitempty"` TradingRewardList []TradingReward `protobuf:"bytes,5,rep,name=trading_reward_list,json=tradingRewardList,proto3" json:"trading_reward_list"` StakingRewardParticipantList []StakingRewardParticipant `protobuf:"bytes,6,rep,name=staking_reward_participant_list,json=stakingRewardParticipantList,proto3" json:"staking_reward_participant_list"` + PendingUnlockParticipantList []PendingUnlockParticipant `protobuf:"bytes,7,rep,name=pending_unlock_participant_list,json=pendingUnlockParticipantList,proto3" json:"pending_unlock_participant_list"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -108,6 +109,13 @@ func (m *GenesisState) GetStakingRewardParticipantList() []StakingRewardParticip return nil } +func (m *GenesisState) GetPendingUnlockParticipantList() []PendingUnlockParticipant { + if m != nil { + return m.PendingUnlockParticipantList + } + return nil +} + func init() { proto.RegisterType((*GenesisState)(nil), "bze.v1.rewards.GenesisState") } @@ -115,30 +123,31 @@ func init() { func init() { proto.RegisterFile("rewards/genesis.proto", fileDescriptor_04e261dd19d07881) } var fileDescriptor_04e261dd19d07881 = []byte{ - // 358 bytes of a gzipped FileDescriptorProto + // 383 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x92, 0x4f, 0x4f, 0xfa, 0x30, - 0x1c, 0xc6, 0xb7, 0x1f, 0xfc, 0x38, 0x14, 0x63, 0xe2, 0x00, 0x25, 0x04, 0x07, 0xf1, 0xb4, 0x83, - 0x6e, 0x11, 0x8d, 0x2f, 0x00, 0x13, 0xbd, 0x78, 0x20, 0xcc, 0x93, 0x17, 0xd2, 0x41, 0x33, 0x1a, - 0x61, 0x5b, 0xda, 0x2f, 0xfe, 0xe1, 0x55, 0xf8, 0xb2, 0x38, 0x72, 0x31, 0xf1, 0x64, 0x0c, 0xbc, - 0x11, 0x43, 0xdb, 0x09, 0x9d, 0xe0, 0x6d, 0xed, 0xf3, 0xfd, 0x3c, 0x4f, 0x9f, 0xae, 0xa8, 0xc2, - 0xc8, 0x33, 0x66, 0x03, 0xee, 0x85, 0x24, 0x22, 0x9c, 0x72, 0x37, 0x61, 0x31, 0xc4, 0xd6, 0x7e, - 0x30, 0x25, 0xee, 0xd3, 0xb9, 0xab, 0xd4, 0x5a, 0x39, 0x8c, 0xc3, 0x58, 0x48, 0xde, 0xea, 0x4b, - 0x4e, 0xd5, 0xca, 0x29, 0x9c, 0x60, 0x86, 0xc7, 0x8a, 0xad, 0xd5, 0xd3, 0x5d, 0x0e, 0xf8, 0x91, - 0x46, 0x61, 0x4f, 0xae, 0xb3, 0x2a, 0x30, 0x3c, 0xf8, 0xa5, 0x3a, 0xdb, 0xd9, 0x5e, 0x82, 0x19, - 0xd0, 0x3e, 0x4d, 0x70, 0x04, 0x72, 0xf2, 0xe4, 0x3d, 0x87, 0xf6, 0x6e, 0xe5, 0x99, 0x7d, 0xc0, - 0x40, 0xac, 0x4b, 0x54, 0x90, 0xc7, 0xa8, 0x9a, 0x4d, 0xd3, 0x29, 0xb6, 0x0e, 0x5d, 0xbd, 0x83, - 0xdb, 0x11, 0x6a, 0x3b, 0x3f, 0xfb, 0x6c, 0x18, 0x5d, 0x35, 0x6b, 0xf9, 0xa8, 0x94, 0x89, 0x1a, - 0x51, 0x0e, 0xd5, 0x7f, 0xcd, 0x9c, 0x53, 0x6c, 0x1d, 0x67, 0x2d, 0x7c, 0x39, 0xda, 0x15, 0x4b, - 0xe5, 0x74, 0xc0, 0x37, 0x37, 0xef, 0x28, 0x07, 0xeb, 0x0a, 0x1d, 0xe9, 0xa6, 0xbc, 0xd7, 0x8f, - 0x27, 0x11, 0x10, 0x56, 0xcd, 0x35, 0x4d, 0x27, 0xdf, 0xad, 0x68, 0x0c, 0xbf, 0x96, 0xe2, 0x8a, - 0xd3, 0x6f, 0x65, 0xcd, 0xe5, 0x25, 0xa7, 0xe4, 0x0c, 0xe7, 0xa3, 0x92, 0xce, 0xc9, 0x12, 0xff, - 0xb7, 0x97, 0xb8, 0xdf, 0xf4, 0x48, 0x4b, 0x68, 0xc6, 0xa2, 0xc4, 0x04, 0x35, 0x76, 0xff, 0x04, - 0x19, 0x50, 0x10, 0x01, 0xce, 0x9f, 0xb7, 0xd4, 0x59, 0x43, 0x2a, 0xab, 0xce, 0x77, 0xe8, 0xab, - 0xd8, 0xf6, 0xcd, 0x6c, 0x61, 0x9b, 0xf3, 0x85, 0x6d, 0x7e, 0x2d, 0x6c, 0xf3, 0x6d, 0x69, 0x1b, - 0xf3, 0xa5, 0x6d, 0x7c, 0x2c, 0x6d, 0xe3, 0xe1, 0x34, 0xa4, 0x30, 0x9c, 0x04, 0x6e, 0x3f, 0x1e, - 0x7b, 0xc1, 0x94, 0x9c, 0xe1, 0x51, 0x32, 0xc4, 0x40, 0xb0, 0x58, 0x79, 0x2f, 0xde, 0xcf, 0xc3, - 0x7a, 0x4d, 0x08, 0x0f, 0x0a, 0xe2, 0x99, 0x5c, 0x7c, 0x07, 0x00, 0x00, 0xff, 0xff, 0x17, 0x61, - 0x8d, 0x84, 0xe1, 0x02, 0x00, 0x00, + 0x1c, 0xc6, 0xb7, 0x1f, 0xfb, 0x61, 0x32, 0x8c, 0x89, 0x03, 0x94, 0x10, 0x1c, 0xc4, 0xd3, 0x0e, + 0xba, 0x45, 0x34, 0xbe, 0x00, 0x4c, 0xf4, 0xe2, 0x81, 0x30, 0xbd, 0x78, 0x21, 0xdd, 0x68, 0x46, + 0x03, 0xac, 0x4d, 0xdb, 0xf9, 0x87, 0x57, 0xe1, 0xcb, 0xe2, 0xe0, 0x81, 0xa3, 0x27, 0x63, 0xe0, + 0x8d, 0x18, 0xda, 0x4d, 0xd8, 0x18, 0xde, 0xd6, 0x3e, 0xdf, 0xcf, 0xf3, 0xf4, 0xe9, 0xaa, 0x57, + 0x29, 0x7c, 0x01, 0x74, 0xc0, 0x9c, 0x00, 0x86, 0x90, 0x21, 0x66, 0x13, 0x8a, 0x39, 0x36, 0x0e, + 0xbc, 0x29, 0xb4, 0x9f, 0x2f, 0xec, 0x58, 0xad, 0x57, 0x02, 0x1c, 0x60, 0x21, 0x39, 0xab, 0x2f, + 0x39, 0x55, 0xaf, 0x24, 0x30, 0x01, 0x14, 0x4c, 0x62, 0xb6, 0xde, 0x48, 0x76, 0x19, 0x07, 0x23, + 0x14, 0x06, 0x7d, 0xb9, 0xce, 0xaa, 0x9c, 0x82, 0xc1, 0x96, 0x6a, 0xe5, 0xb3, 0x7d, 0x02, 0x28, + 0x47, 0x3e, 0x22, 0x20, 0xe4, 0x72, 0xf2, 0xf4, 0x43, 0xd3, 0xf7, 0xef, 0xe4, 0x99, 0x5d, 0x0e, + 0x38, 0x34, 0xae, 0xf4, 0xa2, 0x3c, 0x46, 0x4d, 0x6d, 0xa9, 0x56, 0xa9, 0x7d, 0x64, 0xa7, 0x3b, + 0xd8, 0x5d, 0xa1, 0x76, 0xb4, 0xd9, 0x57, 0x53, 0xe9, 0xc5, 0xb3, 0x86, 0xab, 0x97, 0x33, 0x51, + 0x63, 0xc4, 0x78, 0xed, 0x5f, 0xab, 0x60, 0x95, 0xda, 0x27, 0x59, 0x0b, 0x57, 0x8e, 0xf6, 0xc4, + 0x32, 0x76, 0x3a, 0x64, 0x9b, 0x9b, 0xf7, 0x88, 0x71, 0xe3, 0x5a, 0x3f, 0x4e, 0x9b, 0xb2, 0xbe, + 0x8f, 0xa3, 0x90, 0x43, 0x5a, 0x2b, 0xb4, 0x54, 0x4b, 0xeb, 0x55, 0x53, 0x0c, 0xbb, 0x91, 0xe2, + 0x8a, 0x4b, 0xdf, 0xca, 0x9a, 0xd3, 0x24, 0x17, 0xcb, 0x19, 0xce, 0xd5, 0xcb, 0x69, 0x4e, 0x96, + 0xf8, 0x9f, 0x5f, 0xe2, 0x61, 0xd3, 0x23, 0x29, 0x91, 0x32, 0x16, 0x25, 0x22, 0xbd, 0xb9, 0xfb, + 0x27, 0xc8, 0x80, 0xa2, 0x08, 0xb0, 0xfe, 0xbc, 0xa5, 0xee, 0x1a, 0x8a, 0xb3, 0x1a, 0x6c, 0x87, + 0x9e, 0xc4, 0x12, 0x18, 0x8a, 0x2e, 0x51, 0x38, 0xc6, 0xfe, 0x68, 0x3b, 0x76, 0x2f, 0x3f, 0xb6, + 0x2b, 0xb1, 0x47, 0x41, 0xe5, 0xc4, 0x92, 0x1d, 0xfa, 0x2a, 0xb6, 0x73, 0x3b, 0x5b, 0x98, 0xea, + 0x7c, 0x61, 0xaa, 0xdf, 0x0b, 0x53, 0x7d, 0x5f, 0x9a, 0xca, 0x7c, 0x69, 0x2a, 0x9f, 0x4b, 0x53, + 0x79, 0x3a, 0x0b, 0x10, 0x1f, 0x46, 0x9e, 0xed, 0xe3, 0x89, 0xe3, 0x4d, 0xe1, 0x39, 0x18, 0x93, + 0x21, 0xe0, 0x10, 0x88, 0x95, 0xf3, 0xea, 0xfc, 0xbe, 0xe7, 0x37, 0x02, 0x99, 0x57, 0x14, 0xaf, + 0xf3, 0xf2, 0x27, 0x00, 0x00, 0xff, 0xff, 0x4d, 0x32, 0xae, 0x81, 0x58, 0x03, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -161,6 +170,20 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.PendingUnlockParticipantList) > 0 { + for iNdEx := len(m.PendingUnlockParticipantList) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.PendingUnlockParticipantList[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x3a + } + } if len(m.StakingRewardParticipantList) > 0 { for iNdEx := len(m.StakingRewardParticipantList) - 1; iNdEx >= 0; iNdEx-- { { @@ -269,6 +292,12 @@ func (m *GenesisState) Size() (n int) { n += 1 + l + sovGenesis(uint64(l)) } } + if len(m.PendingUnlockParticipantList) > 0 { + for _, e := range m.PendingUnlockParticipantList { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } return n } @@ -480,6 +509,40 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PendingUnlockParticipantList", 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 + } + m.PendingUnlockParticipantList = append(m.PendingUnlockParticipantList, PendingUnlockParticipant{}) + if err := m.PendingUnlockParticipantList[len(m.PendingUnlockParticipantList)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipGenesis(dAtA[iNdEx:]) diff --git a/x/rewards/types/hook.go b/x/rewards/types/hook.go index ea2b6386..f4d982ef 100644 --- a/x/rewards/types/hook.go +++ b/x/rewards/types/hook.go @@ -7,7 +7,7 @@ type EpochHook struct { Name string } -func NewBeforeEpochHook(name string, after func(ctx sdk.Context, epochIdentifier string, epochNumber int64) error) EpochHook { +func NewAfterEpochHook(name string, after func(ctx sdk.Context, epochIdentifier string, epochNumber int64) error) EpochHook { return EpochHook{ Name: name, after: after, From b3c1b79f80361e7a079b622c23ba200a75d1b99f Mon Sep 17 00:00:00 2001 From: faneaatiku Date: Tue, 19 Mar 2024 18:34:35 +0200 Subject: [PATCH 15/35] added dex hook to rewards module --- go.mod | 3 + go.sum | 12 + proto/rewards/genesis.proto | 2 + proto/rewards/trading_reward.proto | 18 + testutil/simapp/app.go | 6 + x/rewards/genesis.go | 11 + x/rewards/keeper/hooks.go | 107 +++ x/rewards/keeper/msg_server_trading_reward.go | 1 + x/rewards/keeper/trading_reward.go | 24 + .../keeper/trading_reward_leaderboard.go | 78 ++ x/rewards/types/genesis.pb.go | 178 +++- x/rewards/types/key_trading_reward.go | 16 + x/rewards/types/messages_trading_reward.go | 2 +- x/rewards/types/trading_reward.pb.go | 805 +++++++++++++++++- x/tradebin/keeper/keeper.go | 10 + x/tradebin/keeper/queue_message_processor.go | 20 +- x/tradebin/types/hooks.go | 5 + 17 files changed, 1252 insertions(+), 46 deletions(-) create mode 100644 x/rewards/keeper/trading_reward_leaderboard.go create mode 100644 x/tradebin/types/hooks.go diff --git a/go.mod b/go.mod index 23080d06..0519be13 100644 --- a/go.mod +++ b/go.mod @@ -99,6 +99,7 @@ require ( github.com/fsnotify/fsnotify v1.6.0 // indirect github.com/fzipp/gocyclo v0.6.0 // indirect github.com/getsentry/sentry-go v0.17.0 // indirect + github.com/ghodss/yaml v1.0.0 // indirect github.com/go-critic/go-critic v0.6.5 // indirect github.com/go-kit/kit v0.12.0 // indirect github.com/go-kit/log v0.2.1 // indirect @@ -115,6 +116,7 @@ require ( github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect github.com/gofrs/flock v0.8.1 // indirect github.com/gogo/gateway v1.1.0 // indirect + github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b // indirect github.com/golang/snappy v0.0.4 // indirect github.com/golangci/check v0.0.0-20180506172741-cfe4005ccda2 // indirect github.com/golangci/dupl v0.0.0-20180902072040-3e9179ac440a // indirect @@ -137,6 +139,7 @@ require ( github.com/gostaticanalysis/forcetypeassert v0.1.0 // indirect github.com/gostaticanalysis/nilerr v0.1.1 // indirect github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 // indirect + github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1 // 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 diff --git a/go.sum b/go.sum index bd2604ca..5fd2428c 100644 --- a/go.sum +++ b/go.sum @@ -154,6 +154,7 @@ github.com/aymerick/douceur v0.2.0 h1:Mv+mAeH1Q+n9Fr+oyamOlAkUNPWPlA8PPGR0QAaYuP github.com/aymerick/douceur v0.2.0/go.mod h1:wlT5vV2O3h55X9m7iVYN0TBM0NH/MmbLnd30/FjWUq4= github.com/aymerick/raymond v2.0.3-0.20180322193309-b565731e1464+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g= github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= +github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= @@ -261,6 +262,7 @@ github.com/containerd/continuity v0.3.0 h1:nisirsYROK15TAMVukJOUyGJjz4BNQJBVsNvA github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= +github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= github.com/coreos/go-systemd v0.0.0-20180511133405-39ca1b05acc7/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/coreos/go-systemd/v22 v22.3.3-0.20220203105225-a9a7ef127534/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= @@ -395,6 +397,7 @@ github.com/getsentry/sentry-go v0.12.0/go.mod h1:NSap0JBYWzHND8oMbyi0+XZhUalc1TB github.com/getsentry/sentry-go v0.17.0 h1:UustVWnOoDFHBS7IJUB2QK/nB5pap748ZEp0swnQJak= github.com/getsentry/sentry-go v0.17.0/go.mod h1:B82dxtBvxG0KaPD8/hfSV+VcHD+Lg/xUS4JuQn1P4cM= github.com/ghemawat/stream v0.0.0-20171120220530-696b145b53b9/go.mod h1:106OIgooyS7OzLDOpUGgm9fA3bQENb/cFSyyBmMoJDs= +github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/gin-contrib/sse v0.0.0-20190301062529-5545eab6dad3/go.mod h1:VJ0WA2NBN22VlZ2dKZQPAPnyWw5XTlK1KymzLKsr59s= github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= @@ -487,11 +490,13 @@ github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzq github.com/golang-jwt/jwt/v4 v4.3.0/go.mod h1:/xlHOz8bRuivTWchD4jCa+NbatV+wEUSzwAxVc6locg= github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k= github.com/golang/geo v0.0.0-20190916061304-5b978397cfec/go.mod h1:QZ0nwyI2jOfgRAoBvP+ab5aRr7c9x7lhGEJrKvBwjWI= +github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= @@ -499,6 +504,7 @@ github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= +github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.0/go.mod h1:Qd/q+1AKNOZr9uGQzbzCmRO6sUih6GTPZv6a1/R87v0= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= @@ -633,6 +639,8 @@ github.com/grpc-ecosystem/grpc-gateway v1.8.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4M0+kPpLofRdBo= github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1 h1:/c3QmbOGMGTOumP2iT/rCwB7b0QDGLKzqOmktBjT+Is= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1/go.mod h1:5SN9VR2LTsRFsrEC6FHgRbTWrTHu6tqPeKxEQv15giM= 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= @@ -648,6 +656,7 @@ github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brv github.com/hashicorp/go-bexpr v0.1.10/go.mod h1:oxlubA2vC/gFVfX1A6JGp7ls7uCDlfJn732ehYYg+g0= github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= +github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48= github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= github.com/hashicorp/go-immutable-radix v1.3.1 h1:DKHmCUm2hRBK510BaiZlwvpD40f8bJFeZnpfm2KLowc= github.com/hashicorp/go-immutable-radix v1.3.1/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= @@ -657,6 +666,7 @@ github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+l github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= github.com/hashicorp/go-retryablehttp v0.5.3/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs= github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU= +github.com/hashicorp/go-rootcerts v1.0.2/go.mod h1:pqUvnprVnM5bf7AOirdbb01K4ccR319Vf4pU3K5EGc8= github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU= github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4= github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= @@ -1314,6 +1324,7 @@ go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= +go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= @@ -1321,6 +1332,7 @@ go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/atomic v1.10.0 h1:9qC72Qh0+3MqyJbAn8YU5xVq1frD8bn3JtD2oXtafVQ= go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= go.uber.org/goleak v1.1.11 h1:wy28qYRKZgnJTxGxvye5/wgWr1EKjmUDGYox5mGlRlI= +go.uber.org/goleak v1.1.11/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4= go.uber.org/multierr v1.8.0 h1:dg6GjLku4EH+249NNmoIciG9N/jURbDG+pFlTkhzIC8= diff --git a/proto/rewards/genesis.proto b/proto/rewards/genesis.proto index eaa541fc..166fb651 100644 --- a/proto/rewards/genesis.proto +++ b/proto/rewards/genesis.proto @@ -20,5 +20,7 @@ message GenesisState { repeated TradingReward trading_reward_list = 5 [(gogoproto.nullable) = false]; repeated StakingRewardParticipant staking_reward_participant_list = 6 [(gogoproto.nullable) = false]; repeated PendingUnlockParticipant pending_unlock_participant_list = 7 [(gogoproto.nullable) = false]; + repeated TradingRewardLeaderboard trading_reward_leaderboard_list = 8 [(gogoproto.nullable) = false]; + repeated TradingRewardCandidate trading_reward_candidate_list = 9 [(gogoproto.nullable) = false]; // this line is used by starport scaffolding # genesis/proto/state } diff --git a/proto/rewards/trading_reward.proto b/proto/rewards/trading_reward.proto index da24e318..e5101c57 100644 --- a/proto/rewards/trading_reward.proto +++ b/proto/rewards/trading_reward.proto @@ -1,6 +1,8 @@ syntax = "proto3"; package bze.v1.rewards; +import "gogoproto/gogo.proto"; + option go_package = "github.com/bze-alphateam/bze/x/rewards/types"; message TradingReward { @@ -12,3 +14,19 @@ message TradingReward { uint32 slots = 6; } +message TradingRewardLeaderboard { + string reward_id = 1; + repeated TradingRewardLeaderboardEntry list = 2 [(gogoproto.nullable) = false]; +} + +message TradingRewardLeaderboardEntry { + string amount = 1; + string address = 2; + int64 created_at = 3; +} + +message TradingRewardCandidate { + string reward_id = 1; + string amount = 2; + string address = 3; +} diff --git a/testutil/simapp/app.go b/testutil/simapp/app.go index 4d7ab989..7568bb8e 100644 --- a/testutil/simapp/app.go +++ b/testutil/simapp/app.go @@ -478,6 +478,12 @@ func New( app.EpochsKeeper, ) + app.TradebinKeeper.SetOnOrderFillHooks( + []tradebintypes.OnMarketOrderFill{ + app.RewardsKeeper.GetOnOrderFillHook(), + }, + ) + app.EpochsKeeper.SetHooks( []epochstypes.EpochHook{ app.RewardsKeeper.GetDistributeAllStakingRewardsHook(), diff --git a/x/rewards/genesis.go b/x/rewards/genesis.go index 5e849342..90aa8a9c 100644 --- a/x/rewards/genesis.go +++ b/x/rewards/genesis.go @@ -16,6 +16,15 @@ func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) // Set all the tradingReward for _, elem := range genState.TradingRewardList { k.SetTradingReward(ctx, elem) + k.SetMarketIdRewardId(ctx, elem) + } + + for _, elem := range genState.TradingRewardLeaderboardList { + k.SetTradingRewardLeaderboard(ctx, elem) + } + + for _, elem := range genState.TradingRewardCandidateList { + k.SetTradingRewardCandidate(ctx, elem) } // Set all the stakingRewardParticipant @@ -45,6 +54,8 @@ func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState { genesis.TradingRewardList = k.GetAllTradingReward(ctx) genesis.StakingRewardParticipantList = k.GetAllStakingRewardParticipant(ctx) genesis.PendingUnlockParticipantList = k.GetAllPendingUnlockParticipant(ctx) + genesis.TradingRewardLeaderboardList = k.GetAllTradingRewardLeaderboard(ctx) + genesis.TradingRewardCandidateList = k.GetAllTradingRewardCandidate(ctx) // this line is used by starport scaffolding # genesis/module/export return genesis diff --git a/x/rewards/keeper/hooks.go b/x/rewards/keeper/hooks.go index 8b1a3ad9..c48a0e17 100644 --- a/x/rewards/keeper/hooks.go +++ b/x/rewards/keeper/hooks.go @@ -3,6 +3,7 @@ package keeper import ( "github.com/bze-alphateam/bze/x/rewards/types" sdk "github.com/cosmos/cosmos-sdk/types" + "sort" ) func (k Keeper) GetDistributeAllStakingRewardsHook() types.EpochHook { @@ -38,3 +39,109 @@ func (k Keeper) GetUnlockPendingUnlockParticipantsHook() types.EpochHook { return nil }) } + +func (k Keeper) GetOnOrderFillHook() func(ctx sdk.Context, marketId, amountTraded, userAddress string) { + return func(ctx sdk.Context, marketId, amountTraded, userAddress string) { + logger := ctx.Logger().With("market_id", marketId) + existingRewardId, found := k.GetMarketIdRewardId(ctx, marketId) + if !found { + logger.Debug("no rewards found for this market id") + return + } + + reward, found := k.GetTradingReward(ctx, existingRewardId) + if !found { + logger.With("reward_id", existingRewardId). + Error("the reward id found for this market does not exist in trading reward store") + return + } + logger = logger.With("reward", reward) + + candidate, found := k.GetTradingRewardCandidate(ctx, reward.RewardId, userAddress) + if !found { + logger.Debug("candidate not found. creating a new one") + candidate = types.TradingRewardCandidate{ + RewardId: reward.RewardId, + Amount: "0", + Address: userAddress, + } + } + candidateAmount, ok := sdk.NewIntFromString(candidate.Amount) + if !ok { + logger.Error("could not parse candidate amount") + + return + } + + tradedAmount, ok := sdk.NewIntFromString(amountTraded) + if !ok { + logger.Error("could not parse traded amount") + + return + } + + candidateAmount = candidateAmount.Add(tradedAmount) + candidate.Amount = candidateAmount.String() + k.SetTradingRewardCandidate(ctx, candidate) + logger.Debug("trading reward candidate saved") + + //try to add to leaderboard + leaderboard, found := k.GetTradingRewardLeaderboard(ctx, reward.RewardId) + if !found { + logger.Debug("leaderboard does not exist. creating new one") + leaderboard = types.TradingRewardLeaderboard{ + RewardId: reward.RewardId, + List: []types.TradingRewardLeaderboardEntry{}, + } + } + + addedToList := false + for i, entry := range leaderboard.List { + if candidate.Address != entry.Address { + continue + } + + entry.Amount = candidateAmount.String() + leaderboard.List[i] = entry + addedToList = true + + logger.Debug("candidate already exists in leaderboard") + + break + } + + //not found in leaderboard, let's add it + if !addedToList { + logger.Debug("candidate does not exists in leaderboard. creating new entry") + newEntry := types.TradingRewardLeaderboardEntry{ + Amount: candidate.Amount, + Address: candidate.Address, + CreatedAt: ctx.BlockTime().Unix(), + } + leaderboard.List = append(leaderboard.List, newEntry) + } + + //sort the slice + sort.SliceStable(leaderboard.List[:], func(i, j int) bool { + iAmt, _ := sdk.NewIntFromString(amountTraded) + jAmt, _ := sdk.NewIntFromString(amountTraded) + if iAmt.GT(jAmt) { + return true + } + if iAmt.LT(jAmt) { + return false + } + + return leaderboard.List[i].CreatedAt < leaderboard.List[j].CreatedAt + }) + + //trim slice if it's longer than the rewarded slots + if reward.Slots < uint32(len(leaderboard.List)) { + logger.Debug("trimming leaderboard list") + leaderboard.List = leaderboard.List[:reward.Slots] + } + + k.SetTradingRewardLeaderboard(ctx, leaderboard) + logger.Debug("leaderboard set into storage") + } +} diff --git a/x/rewards/keeper/msg_server_trading_reward.go b/x/rewards/keeper/msg_server_trading_reward.go index b5cd2b76..a38e7247 100644 --- a/x/rewards/keeper/msg_server_trading_reward.go +++ b/x/rewards/keeper/msg_server_trading_reward.go @@ -56,6 +56,7 @@ func (k msgServer) CreateTradingReward(goCtx context.Context, msg *types.MsgCrea ctx, tradingReward, ) + k.SetMarketIdRewardId(ctx, tradingReward) return &types.MsgCreateTradingRewardResponse{RewardId: tradingReward.RewardId}, nil } diff --git a/x/rewards/keeper/trading_reward.go b/x/rewards/keeper/trading_reward.go index 74e434e8..e1e80b6d 100644 --- a/x/rewards/keeper/trading_reward.go +++ b/x/rewards/keeper/trading_reward.go @@ -47,3 +47,27 @@ func (k Keeper) GetAllTradingReward(ctx sdk.Context) (list []types.TradingReward return } + +// SetMarketIdRewardId save a reward id on a market id key +func (k Keeper) SetMarketIdRewardId(ctx sdk.Context, tradingReward types.TradingReward) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.MarketIdRewardIdKeyPrefix)) + val := []byte(tradingReward.RewardId) + store.Set(types.MarketIdRewardIdKey(tradingReward.MarketId), val) +} + +// GetMarketIdRewardId get a reward id for a market id key +func (k Keeper) GetMarketIdRewardId(ctx sdk.Context, marketId string) (string, bool) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.MarketIdRewardIdKeyPrefix)) + val := store.Get(types.MarketIdRewardIdKey(marketId)) + if val == nil { + return "", false + } + + return string(val), true +} + +// RemoveMarketIdRewardId removes the reward id stored for a market id +func (k Keeper) RemoveMarketIdRewardId(ctx sdk.Context, marketId string) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.MarketIdRewardIdKeyPrefix)) + store.Delete(types.MarketIdRewardIdKey(marketId)) +} diff --git a/x/rewards/keeper/trading_reward_leaderboard.go b/x/rewards/keeper/trading_reward_leaderboard.go new file mode 100644 index 00000000..304c561c --- /dev/null +++ b/x/rewards/keeper/trading_reward_leaderboard.go @@ -0,0 +1,78 @@ +package keeper + +import ( + "github.com/bze-alphateam/bze/x/rewards/types" + "github.com/cosmos/cosmos-sdk/store/prefix" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +// SetTradingRewardLeaderboard set a specific types.TradingRewardLeaderboard in the store from its index +func (k Keeper) SetTradingRewardLeaderboard(ctx sdk.Context, leaderboard types.TradingRewardLeaderboard) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.LeaderboardKeyPrefix)) + b := k.cdc.MustMarshal(&leaderboard) + store.Set(types.TradingRewardKey(leaderboard.RewardId), b) +} + +// GetTradingRewardLeaderboard returns a types.TradingRewardLeaderboard from its index +func (k Keeper) GetTradingRewardLeaderboard(ctx sdk.Context, rewardId string) (val types.TradingRewardLeaderboard, found bool) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.LeaderboardKeyPrefix)) + + b := store.Get(types.TradingRewardKey(rewardId)) + if b == nil { + return val, false + } + + k.cdc.MustUnmarshal(b, &val) + return val, true +} + +// GetAllTradingRewardLeaderboard returns all []types.TradingRewardLeaderboard +func (k Keeper) GetAllTradingRewardLeaderboard(ctx sdk.Context) (list []types.TradingRewardLeaderboard) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.LeaderboardKeyPrefix)) + iterator := sdk.KVStorePrefixIterator(store, []byte{}) + + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + var val types.TradingRewardLeaderboard + k.cdc.MustUnmarshal(iterator.Value(), &val) + list = append(list, val) + } + + return +} + +// SetTradingRewardCandidate set a specific types.TradingRewardCandidate in the store from its index +func (k Keeper) SetTradingRewardCandidate(ctx sdk.Context, entry types.TradingRewardCandidate) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.RewardCandidateKeyPrefix)) + b := k.cdc.MustMarshal(&entry) + store.Set(types.TradingRewardCandidateKey(entry.RewardId, entry.Address), b) +} + +func (k Keeper) GetTradingRewardCandidate(ctx sdk.Context, rewardId, address string) (val types.TradingRewardCandidate, found bool) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.RewardCandidateKeyPrefix)) + + b := store.Get(types.TradingRewardCandidateKey(rewardId, address)) + if b == nil { + return val, false + } + + k.cdc.MustUnmarshal(b, &val) + return val, true +} + +// GetAllTradingRewardCandidate returns all []types.TradingRewardCandidate +func (k Keeper) GetAllTradingRewardCandidate(ctx sdk.Context) (list []types.TradingRewardCandidate) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.RewardCandidateKeyPrefix)) + iterator := sdk.KVStorePrefixIterator(store, []byte{}) + + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + var val types.TradingRewardCandidate + k.cdc.MustUnmarshal(iterator.Value(), &val) + list = append(list, val) + } + + return +} diff --git a/x/rewards/types/genesis.pb.go b/x/rewards/types/genesis.pb.go index 0fb6d557..84cf279a 100644 --- a/x/rewards/types/genesis.pb.go +++ b/x/rewards/types/genesis.pb.go @@ -32,6 +32,8 @@ type GenesisState struct { TradingRewardList []TradingReward `protobuf:"bytes,5,rep,name=trading_reward_list,json=tradingRewardList,proto3" json:"trading_reward_list"` StakingRewardParticipantList []StakingRewardParticipant `protobuf:"bytes,6,rep,name=staking_reward_participant_list,json=stakingRewardParticipantList,proto3" json:"staking_reward_participant_list"` PendingUnlockParticipantList []PendingUnlockParticipant `protobuf:"bytes,7,rep,name=pending_unlock_participant_list,json=pendingUnlockParticipantList,proto3" json:"pending_unlock_participant_list"` + TradingRewardLeaderboardList []TradingRewardLeaderboard `protobuf:"bytes,8,rep,name=trading_reward_leaderboard_list,json=tradingRewardLeaderboardList,proto3" json:"trading_reward_leaderboard_list"` + TradingRewardCandidateList []TradingRewardCandidate `protobuf:"bytes,9,rep,name=trading_reward_candidate_list,json=tradingRewardCandidateList,proto3" json:"trading_reward_candidate_list"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -116,6 +118,20 @@ func (m *GenesisState) GetPendingUnlockParticipantList() []PendingUnlockParticip return nil } +func (m *GenesisState) GetTradingRewardLeaderboardList() []TradingRewardLeaderboard { + if m != nil { + return m.TradingRewardLeaderboardList + } + return nil +} + +func (m *GenesisState) GetTradingRewardCandidateList() []TradingRewardCandidate { + if m != nil { + return m.TradingRewardCandidateList + } + return nil +} + func init() { proto.RegisterType((*GenesisState)(nil), "bze.v1.rewards.GenesisState") } @@ -123,31 +139,35 @@ func init() { func init() { proto.RegisterFile("rewards/genesis.proto", fileDescriptor_04e261dd19d07881) } var fileDescriptor_04e261dd19d07881 = []byte{ - // 383 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x92, 0x4f, 0x4f, 0xfa, 0x30, - 0x1c, 0xc6, 0xb7, 0x1f, 0xfb, 0x61, 0x32, 0x8c, 0x89, 0x03, 0x94, 0x10, 0x1c, 0xc4, 0xd3, 0x0e, - 0xba, 0x45, 0x34, 0xbe, 0x00, 0x4c, 0xf4, 0xe2, 0x81, 0x30, 0xbd, 0x78, 0x21, 0xdd, 0x68, 0x46, - 0x03, 0xac, 0x4d, 0xdb, 0xf9, 0x87, 0x57, 0xe1, 0xcb, 0xe2, 0xe0, 0x81, 0xa3, 0x27, 0x63, 0xe0, - 0x8d, 0x18, 0xda, 0x4d, 0xd8, 0x18, 0xde, 0xd6, 0x3e, 0xdf, 0xcf, 0xf3, 0xf4, 0xe9, 0xaa, 0x57, - 0x29, 0x7c, 0x01, 0x74, 0xc0, 0x9c, 0x00, 0x86, 0x90, 0x21, 0x66, 0x13, 0x8a, 0x39, 0x36, 0x0e, - 0xbc, 0x29, 0xb4, 0x9f, 0x2f, 0xec, 0x58, 0xad, 0x57, 0x02, 0x1c, 0x60, 0x21, 0x39, 0xab, 0x2f, - 0x39, 0x55, 0xaf, 0x24, 0x30, 0x01, 0x14, 0x4c, 0x62, 0xb6, 0xde, 0x48, 0x76, 0x19, 0x07, 0x23, - 0x14, 0x06, 0x7d, 0xb9, 0xce, 0xaa, 0x9c, 0x82, 0xc1, 0x96, 0x6a, 0xe5, 0xb3, 0x7d, 0x02, 0x28, - 0x47, 0x3e, 0x22, 0x20, 0xe4, 0x72, 0xf2, 0xf4, 0x43, 0xd3, 0xf7, 0xef, 0xe4, 0x99, 0x5d, 0x0e, - 0x38, 0x34, 0xae, 0xf4, 0xa2, 0x3c, 0x46, 0x4d, 0x6d, 0xa9, 0x56, 0xa9, 0x7d, 0x64, 0xa7, 0x3b, - 0xd8, 0x5d, 0xa1, 0x76, 0xb4, 0xd9, 0x57, 0x53, 0xe9, 0xc5, 0xb3, 0x86, 0xab, 0x97, 0x33, 0x51, - 0x63, 0xc4, 0x78, 0xed, 0x5f, 0xab, 0x60, 0x95, 0xda, 0x27, 0x59, 0x0b, 0x57, 0x8e, 0xf6, 0xc4, - 0x32, 0x76, 0x3a, 0x64, 0x9b, 0x9b, 0xf7, 0x88, 0x71, 0xe3, 0x5a, 0x3f, 0x4e, 0x9b, 0xb2, 0xbe, - 0x8f, 0xa3, 0x90, 0x43, 0x5a, 0x2b, 0xb4, 0x54, 0x4b, 0xeb, 0x55, 0x53, 0x0c, 0xbb, 0x91, 0xe2, - 0x8a, 0x4b, 0xdf, 0xca, 0x9a, 0xd3, 0x24, 0x17, 0xcb, 0x19, 0xce, 0xd5, 0xcb, 0x69, 0x4e, 0x96, - 0xf8, 0x9f, 0x5f, 0xe2, 0x61, 0xd3, 0x23, 0x29, 0x91, 0x32, 0x16, 0x25, 0x22, 0xbd, 0xb9, 0xfb, - 0x27, 0xc8, 0x80, 0xa2, 0x08, 0xb0, 0xfe, 0xbc, 0xa5, 0xee, 0x1a, 0x8a, 0xb3, 0x1a, 0x6c, 0x87, - 0x9e, 0xc4, 0x12, 0x18, 0x8a, 0x2e, 0x51, 0x38, 0xc6, 0xfe, 0x68, 0x3b, 0x76, 0x2f, 0x3f, 0xb6, - 0x2b, 0xb1, 0x47, 0x41, 0xe5, 0xc4, 0x92, 0x1d, 0xfa, 0x2a, 0xb6, 0x73, 0x3b, 0x5b, 0x98, 0xea, - 0x7c, 0x61, 0xaa, 0xdf, 0x0b, 0x53, 0x7d, 0x5f, 0x9a, 0xca, 0x7c, 0x69, 0x2a, 0x9f, 0x4b, 0x53, - 0x79, 0x3a, 0x0b, 0x10, 0x1f, 0x46, 0x9e, 0xed, 0xe3, 0x89, 0xe3, 0x4d, 0xe1, 0x39, 0x18, 0x93, - 0x21, 0xe0, 0x10, 0x88, 0x95, 0xf3, 0xea, 0xfc, 0xbe, 0xe7, 0x37, 0x02, 0x99, 0x57, 0x14, 0xaf, - 0xf3, 0xf2, 0x27, 0x00, 0x00, 0xff, 0xff, 0x4d, 0x32, 0xae, 0x81, 0x58, 0x03, 0x00, 0x00, + // 437 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x93, 0xcf, 0xae, 0xd2, 0x40, + 0x14, 0x87, 0x5b, 0x2f, 0x56, 0x9d, 0x6b, 0x4c, 0xec, 0x05, 0x25, 0x0d, 0x14, 0xe2, 0xc2, 0x74, + 0xa1, 0x6d, 0x44, 0xe3, 0x03, 0x40, 0xa2, 0x1b, 0x16, 0x84, 0xea, 0xc6, 0x0d, 0x99, 0xb6, 0x93, + 0x32, 0x01, 0x3a, 0x93, 0x99, 0xa9, 0x7f, 0x78, 0x0a, 0x1f, 0xc6, 0x87, 0x60, 0xc9, 0xd2, 0x95, + 0x31, 0xf0, 0x22, 0x37, 0xcc, 0xb4, 0x40, 0x4b, 0xcb, 0x8e, 0xe9, 0xef, 0x7c, 0xe7, 0x9b, 0x73, + 0xc8, 0x80, 0x16, 0x43, 0x3f, 0x20, 0x8b, 0xb8, 0x17, 0xa3, 0x04, 0x71, 0xcc, 0x5d, 0xca, 0x88, + 0x20, 0xe6, 0xb3, 0x60, 0x8d, 0xdc, 0xef, 0xef, 0xdc, 0x2c, 0xb5, 0x9a, 0x31, 0x89, 0x89, 0x8c, + 0xbc, 0xc3, 0x2f, 0x55, 0x65, 0x35, 0x73, 0x98, 0x42, 0x06, 0x57, 0x19, 0x6b, 0x75, 0xf2, 0xaf, + 0x5c, 0xc0, 0x05, 0x4e, 0xe2, 0x99, 0x3a, 0x97, 0x53, 0xc1, 0x60, 0x74, 0x91, 0x3a, 0xd5, 0xec, + 0x8c, 0x42, 0x26, 0x70, 0x88, 0x29, 0x4c, 0x84, 0xaa, 0x7c, 0xf5, 0xc7, 0x00, 0x4f, 0x3f, 0xab, + 0x3b, 0xfb, 0x02, 0x0a, 0x64, 0x7e, 0x00, 0x86, 0xba, 0x46, 0x5b, 0xef, 0xeb, 0xce, 0xed, 0xe0, + 0x85, 0x5b, 0x9c, 0xc1, 0x9d, 0xc8, 0x74, 0xd8, 0xd8, 0xfc, 0xeb, 0x69, 0xd3, 0xac, 0xd6, 0xf4, + 0xc1, 0x5d, 0x49, 0xb5, 0xc4, 0x5c, 0xb4, 0x1f, 0xf4, 0x6f, 0x9c, 0xdb, 0x41, 0xb7, 0xdc, 0xc2, + 0x57, 0xa5, 0x53, 0x79, 0xcc, 0x3a, 0x3d, 0xe7, 0xe7, 0x1f, 0xc7, 0x98, 0x0b, 0xf3, 0x23, 0x78, + 0x59, 0x6c, 0xca, 0x67, 0x21, 0x49, 0x13, 0x81, 0x58, 0xfb, 0xa6, 0xaf, 0x3b, 0x8d, 0x69, 0xab, + 0xc0, 0xf0, 0x91, 0x0a, 0x0f, 0x5c, 0x71, 0x2b, 0x27, 0xae, 0xa1, 0xb8, 0x2c, 0x2e, 0x71, 0x3e, + 0xb8, 0x2b, 0x72, 0x6a, 0x88, 0x87, 0xd5, 0x43, 0x7c, 0x39, 0xef, 0x91, 0x0f, 0x51, 0x68, 0x2c, + 0x87, 0x48, 0x41, 0xaf, 0xfe, 0x4f, 0x50, 0x02, 0x43, 0x0a, 0x9c, 0xab, 0x5b, 0x9a, 0x9c, 0xa0, + 0xcc, 0xd5, 0xe1, 0x35, 0x79, 0xae, 0xa5, 0x28, 0x91, 0xb3, 0xa4, 0xc9, 0x92, 0x84, 0x8b, 0x4b, + 0xed, 0xa3, 0x6a, 0xed, 0x44, 0x61, 0x5f, 0x25, 0x55, 0xa1, 0xa5, 0x35, 0x79, 0xae, 0x2d, 0xaf, + 0x10, 0xc1, 0x08, 0xb1, 0x80, 0x1c, 0xd7, 0xf9, 0xb8, 0x5a, 0x5b, 0x58, 0xe7, 0xf8, 0x04, 0xe5, + 0x5a, 0x51, 0x93, 0x4b, 0x2d, 0x01, 0xdd, 0x92, 0x36, 0x84, 0x49, 0x84, 0x23, 0x28, 0x90, 0x92, + 0x3e, 0x91, 0xd2, 0xd7, 0x57, 0xa5, 0xa3, 0x1c, 0xc9, 0x94, 0x96, 0xa8, 0x4c, 0x0f, 0xc2, 0xe1, + 0xa7, 0xcd, 0xce, 0xd6, 0xb7, 0x3b, 0x5b, 0xff, 0xbf, 0xb3, 0xf5, 0xdf, 0x7b, 0x5b, 0xdb, 0xee, + 0x6d, 0xed, 0xef, 0xde, 0xd6, 0xbe, 0xbd, 0x89, 0xb1, 0x98, 0xa7, 0x81, 0x1b, 0x92, 0x95, 0x17, + 0xac, 0xd1, 0x5b, 0xb8, 0xa4, 0x73, 0x28, 0x10, 0x94, 0x27, 0xef, 0xa7, 0x77, 0x7c, 0xb7, 0xbf, + 0x28, 0xe2, 0x81, 0x21, 0x5f, 0xe1, 0xfb, 0xfb, 0x00, 0x00, 0x00, 0xff, 0xff, 0x07, 0xd5, 0x14, + 0x50, 0x40, 0x04, 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -170,6 +190,34 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.TradingRewardCandidateList) > 0 { + for iNdEx := len(m.TradingRewardCandidateList) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.TradingRewardCandidateList[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x4a + } + } + if len(m.TradingRewardLeaderboardList) > 0 { + for iNdEx := len(m.TradingRewardLeaderboardList) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.TradingRewardLeaderboardList[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x42 + } + } if len(m.PendingUnlockParticipantList) > 0 { for iNdEx := len(m.PendingUnlockParticipantList) - 1; iNdEx >= 0; iNdEx-- { { @@ -298,6 +346,18 @@ func (m *GenesisState) Size() (n int) { n += 1 + l + sovGenesis(uint64(l)) } } + if len(m.TradingRewardLeaderboardList) > 0 { + for _, e := range m.TradingRewardLeaderboardList { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if len(m.TradingRewardCandidateList) > 0 { + for _, e := range m.TradingRewardCandidateList { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } return n } @@ -543,6 +603,74 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 8: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TradingRewardLeaderboardList", 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 + } + m.TradingRewardLeaderboardList = append(m.TradingRewardLeaderboardList, TradingRewardLeaderboard{}) + if err := m.TradingRewardLeaderboardList[len(m.TradingRewardLeaderboardList)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 9: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TradingRewardCandidateList", 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 + } + m.TradingRewardCandidateList = append(m.TradingRewardCandidateList, TradingRewardCandidate{}) + if err := m.TradingRewardCandidateList[len(m.TradingRewardCandidateList)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipGenesis(dAtA[iNdEx:]) diff --git a/x/rewards/types/key_trading_reward.go b/x/rewards/types/key_trading_reward.go index e397d7f8..46fd95ba 100644 --- a/x/rewards/types/key_trading_reward.go +++ b/x/rewards/types/key_trading_reward.go @@ -7,8 +7,24 @@ var _ binary.ByteOrder const ( // TradingRewardKeyPrefix is the prefix to retrieve all TradingReward TradingRewardKeyPrefix = "tr/value/" + // MarketIdRewardIdKeyPrefix is the prefix to retrieve a reward id for a market id + MarketIdRewardIdKeyPrefix = "tr/mr/" + // LeaderboardKeyPrefix is the prefix of a leaderboard for a trading reward + LeaderboardKeyPrefix = "tr/lb/" + // RewardCandidateKeyPrefix prefix that holds entries/participants for trading rewards + RewardCandidateKeyPrefix = "tr/r/" ) +// TradingRewardCandidateKey returns the store key to retrieve a reward candidate +func TradingRewardCandidateKey(rewardId, address string) []byte { + return []byte(rewardId + "/" + address) +} + +// MarketIdRewardIdKey returns the store key to retrieve a TradingReward.RewardId from the index fields +func MarketIdRewardIdKey(marketId string) []byte { + return []byte(marketId) +} + // TradingRewardKey returns the store key to retrieve a TradingReward from the index fields func TradingRewardKey(rewardId string) []byte { return []byte(rewardId) diff --git a/x/rewards/types/messages_trading_reward.go b/x/rewards/types/messages_trading_reward.go index 3e17a9b7..6a70ee85 100644 --- a/x/rewards/types/messages_trading_reward.go +++ b/x/rewards/types/messages_trading_reward.go @@ -9,7 +9,7 @@ import ( const ( TypeMsgCreateTradingReward = "create_trading_reward" - maxAllowedSlots = 100 + maxAllowedSlots = 10 ) var _ sdk.Msg = &MsgCreateTradingReward{} diff --git a/x/rewards/types/trading_reward.pb.go b/x/rewards/types/trading_reward.pb.go index af70f821..feacf296 100644 --- a/x/rewards/types/trading_reward.pb.go +++ b/x/rewards/types/trading_reward.pb.go @@ -5,6 +5,7 @@ package types import ( fmt "fmt" + _ "github.com/gogo/protobuf/gogoproto" proto "github.com/gogo/protobuf/proto" io "io" math "math" @@ -106,31 +107,214 @@ func (m *TradingReward) GetSlots() uint32 { return 0 } +type TradingRewardLeaderboard struct { + RewardId string `protobuf:"bytes,1,opt,name=reward_id,json=rewardId,proto3" json:"reward_id,omitempty"` + List []TradingRewardLeaderboardEntry `protobuf:"bytes,2,rep,name=list,proto3" json:"list"` +} + +func (m *TradingRewardLeaderboard) Reset() { *m = TradingRewardLeaderboard{} } +func (m *TradingRewardLeaderboard) String() string { return proto.CompactTextString(m) } +func (*TradingRewardLeaderboard) ProtoMessage() {} +func (*TradingRewardLeaderboard) Descriptor() ([]byte, []int) { + return fileDescriptor_e96afcb90471b82d, []int{1} +} +func (m *TradingRewardLeaderboard) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *TradingRewardLeaderboard) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_TradingRewardLeaderboard.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 *TradingRewardLeaderboard) XXX_Merge(src proto.Message) { + xxx_messageInfo_TradingRewardLeaderboard.Merge(m, src) +} +func (m *TradingRewardLeaderboard) XXX_Size() int { + return m.Size() +} +func (m *TradingRewardLeaderboard) XXX_DiscardUnknown() { + xxx_messageInfo_TradingRewardLeaderboard.DiscardUnknown(m) +} + +var xxx_messageInfo_TradingRewardLeaderboard proto.InternalMessageInfo + +func (m *TradingRewardLeaderboard) GetRewardId() string { + if m != nil { + return m.RewardId + } + return "" +} + +func (m *TradingRewardLeaderboard) GetList() []TradingRewardLeaderboardEntry { + if m != nil { + return m.List + } + return nil +} + +type TradingRewardLeaderboardEntry struct { + Amount string `protobuf:"bytes,1,opt,name=amount,proto3" json:"amount,omitempty"` + Address string `protobuf:"bytes,2,opt,name=address,proto3" json:"address,omitempty"` + CreatedAt int64 `protobuf:"varint,3,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"` +} + +func (m *TradingRewardLeaderboardEntry) Reset() { *m = TradingRewardLeaderboardEntry{} } +func (m *TradingRewardLeaderboardEntry) String() string { return proto.CompactTextString(m) } +func (*TradingRewardLeaderboardEntry) ProtoMessage() {} +func (*TradingRewardLeaderboardEntry) Descriptor() ([]byte, []int) { + return fileDescriptor_e96afcb90471b82d, []int{2} +} +func (m *TradingRewardLeaderboardEntry) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *TradingRewardLeaderboardEntry) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_TradingRewardLeaderboardEntry.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 *TradingRewardLeaderboardEntry) XXX_Merge(src proto.Message) { + xxx_messageInfo_TradingRewardLeaderboardEntry.Merge(m, src) +} +func (m *TradingRewardLeaderboardEntry) XXX_Size() int { + return m.Size() +} +func (m *TradingRewardLeaderboardEntry) XXX_DiscardUnknown() { + xxx_messageInfo_TradingRewardLeaderboardEntry.DiscardUnknown(m) +} + +var xxx_messageInfo_TradingRewardLeaderboardEntry proto.InternalMessageInfo + +func (m *TradingRewardLeaderboardEntry) GetAmount() string { + if m != nil { + return m.Amount + } + return "" +} + +func (m *TradingRewardLeaderboardEntry) GetAddress() string { + if m != nil { + return m.Address + } + return "" +} + +func (m *TradingRewardLeaderboardEntry) GetCreatedAt() int64 { + if m != nil { + return m.CreatedAt + } + return 0 +} + +type TradingRewardCandidate struct { + RewardId string `protobuf:"bytes,1,opt,name=reward_id,json=rewardId,proto3" json:"reward_id,omitempty"` + Amount string `protobuf:"bytes,2,opt,name=amount,proto3" json:"amount,omitempty"` + Address string `protobuf:"bytes,3,opt,name=address,proto3" json:"address,omitempty"` +} + +func (m *TradingRewardCandidate) Reset() { *m = TradingRewardCandidate{} } +func (m *TradingRewardCandidate) String() string { return proto.CompactTextString(m) } +func (*TradingRewardCandidate) ProtoMessage() {} +func (*TradingRewardCandidate) Descriptor() ([]byte, []int) { + return fileDescriptor_e96afcb90471b82d, []int{3} +} +func (m *TradingRewardCandidate) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *TradingRewardCandidate) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_TradingRewardCandidate.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 *TradingRewardCandidate) XXX_Merge(src proto.Message) { + xxx_messageInfo_TradingRewardCandidate.Merge(m, src) +} +func (m *TradingRewardCandidate) XXX_Size() int { + return m.Size() +} +func (m *TradingRewardCandidate) XXX_DiscardUnknown() { + xxx_messageInfo_TradingRewardCandidate.DiscardUnknown(m) +} + +var xxx_messageInfo_TradingRewardCandidate proto.InternalMessageInfo + +func (m *TradingRewardCandidate) GetRewardId() string { + if m != nil { + return m.RewardId + } + return "" +} + +func (m *TradingRewardCandidate) GetAmount() string { + if m != nil { + return m.Amount + } + return "" +} + +func (m *TradingRewardCandidate) GetAddress() string { + if m != nil { + return m.Address + } + return "" +} + func init() { proto.RegisterType((*TradingReward)(nil), "bze.v1.rewards.TradingReward") + proto.RegisterType((*TradingRewardLeaderboard)(nil), "bze.v1.rewards.TradingRewardLeaderboard") + proto.RegisterType((*TradingRewardLeaderboardEntry)(nil), "bze.v1.rewards.TradingRewardLeaderboardEntry") + proto.RegisterType((*TradingRewardCandidate)(nil), "bze.v1.rewards.TradingRewardCandidate") } func init() { proto.RegisterFile("rewards/trading_reward.proto", fileDescriptor_e96afcb90471b82d) } var fileDescriptor_e96afcb90471b82d = []byte{ - // 259 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x3c, 0x90, 0xbd, 0x4e, 0xc3, 0x30, - 0x14, 0x85, 0x63, 0xa0, 0x55, 0x6b, 0x28, 0x83, 0xc5, 0x60, 0x01, 0x32, 0x85, 0xa9, 0x03, 0x24, - 0x42, 0x3c, 0x01, 0x08, 0x21, 0x75, 0x8d, 0x98, 0x58, 0x22, 0x07, 0x5b, 0xad, 0x45, 0x13, 0x47, - 0xb6, 0xc3, 0x4f, 0x9e, 0x82, 0x37, 0x62, 0x65, 0xec, 0xc8, 0x88, 0x92, 0x17, 0x41, 0xb9, 0x17, - 0x65, 0xfc, 0xbe, 0x7b, 0xae, 0x8e, 0x74, 0xe8, 0xa9, 0xd3, 0x6f, 0xd2, 0x29, 0x9f, 0x04, 0x27, - 0x95, 0x29, 0x57, 0x19, 0x72, 0x5c, 0x39, 0x1b, 0x2c, 0x3b, 0xcc, 0x1b, 0x1d, 0xbf, 0x5e, 0xc7, - 0xff, 0xa1, 0x8b, 0x2f, 0x42, 0x67, 0x8f, 0x18, 0x4c, 0x41, 0xb1, 0x13, 0x3a, 0xc5, 0x63, 0x66, - 0x14, 0x27, 0x73, 0xb2, 0x98, 0xa6, 0x13, 0x14, 0x4b, 0xc5, 0xce, 0xe9, 0x41, 0xe5, 0x4c, 0xa3, - 0x33, 0x59, 0xd8, 0xba, 0x0c, 0x7c, 0x07, 0xee, 0xfb, 0xe0, 0x6e, 0x41, 0xb1, 0x33, 0x8a, 0x98, - 0x29, 0x5d, 0xda, 0x82, 0xef, 0x42, 0x82, 0x82, 0xba, 0xef, 0x0d, 0x3b, 0xa6, 0x13, 0x55, 0x3b, - 0x19, 0x8c, 0x2d, 0xf9, 0xde, 0x9c, 0x2c, 0x66, 0xe9, 0xc0, 0x7d, 0x79, 0x21, 0xdd, 0x8b, 0x0e, - 0x7d, 0xf9, 0x08, 0xcb, 0x51, 0x2c, 0x15, 0x3b, 0xa2, 0x23, 0xbf, 0xb1, 0xc1, 0xf3, 0x31, 0x7c, - 0x21, 0xdc, 0x3d, 0x7c, 0xb7, 0x82, 0x6c, 0x5b, 0x41, 0x7e, 0x5b, 0x41, 0x3e, 0x3b, 0x11, 0x6d, - 0x3b, 0x11, 0xfd, 0x74, 0x22, 0x7a, 0xba, 0x5c, 0x99, 0xb0, 0xae, 0xf3, 0xf8, 0xd9, 0x16, 0x49, - 0xde, 0xe8, 0x2b, 0xb9, 0xa9, 0xd6, 0x32, 0x68, 0x09, 0x94, 0xbc, 0x27, 0xc3, 0x50, 0x1f, 0x95, - 0xf6, 0xf9, 0x18, 0x06, 0xba, 0xf9, 0x0b, 0x00, 0x00, 0xff, 0xff, 0x98, 0xd8, 0x03, 0xb5, 0x40, - 0x01, 0x00, 0x00, + // 391 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x52, 0xcd, 0x8e, 0xda, 0x30, + 0x18, 0x8c, 0x09, 0x50, 0xf8, 0x28, 0x3d, 0x58, 0x08, 0x45, 0xb4, 0x04, 0x9a, 0x13, 0x87, 0x92, + 0xa8, 0xed, 0x13, 0x40, 0xff, 0x84, 0xd4, 0x53, 0xd4, 0x53, 0x2f, 0x91, 0x83, 0xad, 0x10, 0x95, + 0xc4, 0x91, 0x63, 0xda, 0xc2, 0xa9, 0x8f, 0xd0, 0x37, 0xda, 0x2b, 0x47, 0x8e, 0x7b, 0x5a, 0xad, + 0xe0, 0x45, 0x56, 0xb1, 0xb3, 0xac, 0x72, 0x80, 0xbd, 0x79, 0xc6, 0xf3, 0xf9, 0x9b, 0x19, 0x19, + 0xde, 0x08, 0xf6, 0x87, 0x08, 0x9a, 0x7b, 0x52, 0x10, 0x1a, 0xa7, 0x51, 0xa0, 0xb1, 0x9b, 0x09, + 0x2e, 0x39, 0x7e, 0x15, 0xee, 0x98, 0xfb, 0xfb, 0xbd, 0x5b, 0x8a, 0x06, 0xbd, 0x88, 0x47, 0x5c, + 0x5d, 0x79, 0xc5, 0x49, 0xab, 0x9c, 0x1b, 0x04, 0xdd, 0x1f, 0x7a, 0xdc, 0x57, 0x42, 0xfc, 0x1a, + 0xda, 0x7a, 0x24, 0x88, 0xa9, 0x85, 0xc6, 0x68, 0xd2, 0xf6, 0x5b, 0x9a, 0x58, 0x50, 0xfc, 0x16, + 0x5e, 0x66, 0x22, 0xde, 0xb1, 0x80, 0x24, 0x7c, 0x93, 0x4a, 0xab, 0xa6, 0xee, 0x3b, 0x8a, 0x9b, + 0x29, 0x0a, 0x8f, 0x40, 0xc3, 0x80, 0xb2, 0x94, 0x27, 0x96, 0xa9, 0x14, 0xa0, 0xa8, 0xcf, 0x05, + 0x83, 0x07, 0xd0, 0xa2, 0x1b, 0x41, 0x64, 0xcc, 0x53, 0xab, 0x3e, 0x46, 0x93, 0xae, 0x7f, 0xc6, + 0xc5, 0xf2, 0x84, 0x88, 0x5f, 0x4c, 0x16, 0xcb, 0x1b, 0x7a, 0xb9, 0x26, 0x16, 0x14, 0xf7, 0xa0, + 0x91, 0xaf, 0xb9, 0xcc, 0xad, 0xa6, 0x9a, 0xd2, 0xc0, 0xf9, 0x87, 0xc0, 0xaa, 0x24, 0xf8, 0xce, + 0x08, 0x65, 0x22, 0xe4, 0xcf, 0x86, 0xf9, 0x06, 0xf5, 0x75, 0x9c, 0x17, 0x21, 0xcc, 0x49, 0xe7, + 0xc3, 0xd4, 0xad, 0x16, 0xe6, 0x5e, 0x7a, 0xf4, 0x4b, 0x2a, 0xc5, 0x76, 0x5e, 0xdf, 0xdf, 0x8d, + 0x0c, 0x5f, 0x3d, 0xe0, 0x64, 0x30, 0xbc, 0x2a, 0xc6, 0x7d, 0x68, 0x96, 0x85, 0x69, 0x0f, 0x25, + 0xc2, 0x16, 0xbc, 0x20, 0x94, 0x0a, 0x96, 0xe7, 0x65, 0x93, 0x8f, 0x10, 0x0f, 0x01, 0x96, 0x82, + 0x11, 0xc9, 0x68, 0x40, 0xa4, 0x2a, 0xd1, 0xf4, 0xdb, 0x25, 0x33, 0x93, 0x4e, 0x04, 0xfd, 0xca, + 0xc6, 0x4f, 0x24, 0xa5, 0x31, 0x25, 0x92, 0x5d, 0x4f, 0xfc, 0xe4, 0xa3, 0x76, 0xc9, 0x87, 0x59, + 0xf1, 0x31, 0xff, 0xba, 0x3f, 0xda, 0xe8, 0x70, 0xb4, 0xd1, 0xfd, 0xd1, 0x46, 0xff, 0x4f, 0xb6, + 0x71, 0x38, 0xd9, 0xc6, 0xed, 0xc9, 0x36, 0x7e, 0xbe, 0x8b, 0x62, 0xb9, 0xda, 0x84, 0xee, 0x92, + 0x27, 0x5e, 0xb8, 0x63, 0x53, 0xb2, 0xce, 0x56, 0x44, 0x32, 0xa2, 0x90, 0xf7, 0xd7, 0x3b, 0x7f, + 0xce, 0x6d, 0xc6, 0xf2, 0xb0, 0xa9, 0xbe, 0xdb, 0xc7, 0x87, 0x00, 0x00, 0x00, 0xff, 0xff, 0x49, + 0xda, 0x67, 0xaf, 0xb4, 0x02, 0x00, 0x00, } func (m *TradingReward) Marshal() (dAtA []byte, err error) { @@ -194,6 +378,136 @@ func (m *TradingReward) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *TradingRewardLeaderboard) 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 *TradingRewardLeaderboard) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *TradingRewardLeaderboard) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.List) > 0 { + for iNdEx := len(m.List) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.List[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintTradingReward(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if len(m.RewardId) > 0 { + i -= len(m.RewardId) + copy(dAtA[i:], m.RewardId) + i = encodeVarintTradingReward(dAtA, i, uint64(len(m.RewardId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *TradingRewardLeaderboardEntry) 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 *TradingRewardLeaderboardEntry) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *TradingRewardLeaderboardEntry) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.CreatedAt != 0 { + i = encodeVarintTradingReward(dAtA, i, uint64(m.CreatedAt)) + i-- + dAtA[i] = 0x18 + } + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintTradingReward(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0x12 + } + if len(m.Amount) > 0 { + i -= len(m.Amount) + copy(dAtA[i:], m.Amount) + i = encodeVarintTradingReward(dAtA, i, uint64(len(m.Amount))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *TradingRewardCandidate) 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 *TradingRewardCandidate) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *TradingRewardCandidate) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintTradingReward(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0x1a + } + if len(m.Amount) > 0 { + i -= len(m.Amount) + copy(dAtA[i:], m.Amount) + i = encodeVarintTradingReward(dAtA, i, uint64(len(m.Amount))) + i-- + dAtA[i] = 0x12 + } + if len(m.RewardId) > 0 { + i -= len(m.RewardId) + copy(dAtA[i:], m.RewardId) + i = encodeVarintTradingReward(dAtA, i, uint64(len(m.RewardId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func encodeVarintTradingReward(dAtA []byte, offset int, v uint64) int { offset -= sovTradingReward(v) base := offset @@ -236,6 +550,66 @@ func (m *TradingReward) Size() (n int) { return n } +func (m *TradingRewardLeaderboard) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.RewardId) + if l > 0 { + n += 1 + l + sovTradingReward(uint64(l)) + } + if len(m.List) > 0 { + for _, e := range m.List { + l = e.Size() + n += 1 + l + sovTradingReward(uint64(l)) + } + } + return n +} + +func (m *TradingRewardLeaderboardEntry) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Amount) + if l > 0 { + n += 1 + l + sovTradingReward(uint64(l)) + } + l = len(m.Address) + if l > 0 { + n += 1 + l + sovTradingReward(uint64(l)) + } + if m.CreatedAt != 0 { + n += 1 + sovTradingReward(uint64(m.CreatedAt)) + } + return n +} + +func (m *TradingRewardCandidate) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.RewardId) + if l > 0 { + n += 1 + l + sovTradingReward(uint64(l)) + } + l = len(m.Amount) + if l > 0 { + n += 1 + l + sovTradingReward(uint64(l)) + } + l = len(m.Address) + if l > 0 { + n += 1 + l + sovTradingReward(uint64(l)) + } + return n +} + func sovTradingReward(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -458,6 +832,401 @@ func (m *TradingReward) Unmarshal(dAtA []byte) error { } return nil } +func (m *TradingRewardLeaderboard) 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 ErrIntOverflowTradingReward + } + 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: TradingRewardLeaderboard: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: TradingRewardLeaderboard: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RewardId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTradingReward + } + 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 ErrInvalidLengthTradingReward + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTradingReward + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.RewardId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field List", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTradingReward + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthTradingReward + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthTradingReward + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.List = append(m.List, TradingRewardLeaderboardEntry{}) + if err := m.List[len(m.List)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTradingReward(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTradingReward + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *TradingRewardLeaderboardEntry) 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 ErrIntOverflowTradingReward + } + 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: TradingRewardLeaderboardEntry: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: TradingRewardLeaderboardEntry: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTradingReward + } + 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 ErrInvalidLengthTradingReward + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTradingReward + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Amount = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTradingReward + } + 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 ErrInvalidLengthTradingReward + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTradingReward + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field CreatedAt", wireType) + } + m.CreatedAt = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTradingReward + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.CreatedAt |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipTradingReward(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTradingReward + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *TradingRewardCandidate) 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 ErrIntOverflowTradingReward + } + 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: TradingRewardCandidate: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: TradingRewardCandidate: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RewardId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTradingReward + } + 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 ErrInvalidLengthTradingReward + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTradingReward + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.RewardId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTradingReward + } + 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 ErrInvalidLengthTradingReward + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTradingReward + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Amount = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTradingReward + } + 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 ErrInvalidLengthTradingReward + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTradingReward + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTradingReward(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTradingReward + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipTradingReward(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/x/tradebin/keeper/keeper.go b/x/tradebin/keeper/keeper.go index b6c376e9..ceade6db 100644 --- a/x/tradebin/keeper/keeper.go +++ b/x/tradebin/keeper/keeper.go @@ -20,6 +20,8 @@ type ( bankKeeper types.BankKeeper distrKeeper types.DistrKeeper + + onOrderFillHooks []types.OnMarketOrderFill } ) @@ -47,6 +49,14 @@ func NewKeeper( } } +func (k *Keeper) SetOnOrderFillHooks(hooks []types.OnMarketOrderFill) { + k.onOrderFillHooks = hooks +} + +func (k Keeper) GetOnOrderFillHooks() []types.OnMarketOrderFill { + return k.onOrderFillHooks +} + func (k Keeper) Logger(ctx sdk.Context) log.Logger { return ctx.Logger().With("module", fmt.Sprintf("x/%s", types.ModuleName)) } diff --git a/x/tradebin/keeper/queue_message_processor.go b/x/tradebin/keeper/queue_message_processor.go index c61def55..5ed48dfe 100644 --- a/x/tradebin/keeper/queue_message_processor.go +++ b/x/tradebin/keeper/queue_message_processor.go @@ -35,6 +35,8 @@ type ProcessingKeeper interface { GetOrderCoins(orderType, orderPrice string, orderAmount sdk.Int, market *types.Market) (sdk.Coin, error) Logger(ctx sdk.Context) log.Logger + + GetOnOrderFillHooks() []types.OnMarketOrderFill } type BankKeeper interface { @@ -232,7 +234,7 @@ func (pe *ProcessingEngine) addOrder(ctx sdk.Context, message types.QueueMessage } pe.addHistoryOrder(ctx, &orderToFill, amountToExecute, &message) - pe.emitOrderExecutedEvent(ctx, &orderToFill, amountToExecute.String()) + pe.emitOrderExecutedEvent(ctx, &orderToFill, amountToExecute.String(), message.Owner) } if aggAmountInt.GT(zeroInt) { @@ -416,7 +418,7 @@ func (pe *ProcessingEngine) addOrderToAggregate(ctx sdk.Context, order *types.Or pe.k.SetAggregatedOrder(ctx, agg) } -func (pe *ProcessingEngine) emitOrderExecutedEvent(ctx sdk.Context, order *types.Order, amount string) { +func (pe *ProcessingEngine) emitOrderExecutedEvent(ctx sdk.Context, order *types.Order, amount, userAddress string) { err := ctx.EventManager().EmitTypedEvent( &types.OrderExecutedEvent{ Id: order.Id, @@ -430,6 +432,20 @@ func (pe *ProcessingEngine) emitOrderExecutedEvent(ctx sdk.Context, order *types if err != nil { pe.logger.Error(err.Error()) } + + //call hooks for the filled order + for _, h := range pe.k.GetOnOrderFillHooks() { + wrappedFn := func(ctx sdk.Context) error { + h(ctx, order.MarketId, amount, userAddress) + + return nil + } + + err = bzeutils.ApplyFuncIfNoError(ctx, wrappedFn) + if err != nil { + pe.k.Logger(ctx).Error(err.Error()) + } + } } func (pe *ProcessingEngine) emitOrderCanceledEvent(ctx sdk.Context, order *types.Order) { diff --git a/x/tradebin/types/hooks.go b/x/tradebin/types/hooks.go new file mode 100644 index 00000000..80c7d4ac --- /dev/null +++ b/x/tradebin/types/hooks.go @@ -0,0 +1,5 @@ +package types + +import sdk "github.com/cosmos/cosmos-sdk/types" + +type OnMarketOrderFill func(ctx sdk.Context, marketId, amountTraded, userAddress string) From 1dc515c15fce3423456c2fd86a820a3bf52454c2 Mon Sep 17 00:00:00 2001 From: faneaatiku Date: Tue, 26 Mar 2024 02:20:39 +0200 Subject: [PATCH 16/35] added expiration for trading rewards, moved staking pending unlock from day epoch to hour epoch --- app/app.go | 17 +- proto/rewards/events.proto | 8 + proto/rewards/trading_reward.proto | 6 + readme.md | 7 +- x/rewards/genesis.go | 1 + x/rewards/keeper/cleanup.go | 35 ++ x/rewards/keeper/hooks.go | 21 +- x/rewards/keeper/keeper.go | 4 +- x/rewards/keeper/msg_server_exit_staking.go | 4 +- x/rewards/keeper/msg_server_trading_reward.go | 25 +- x/rewards/keeper/trading_reward.go | 55 ++++ x/rewards/keeper/unlock.go | 2 +- x/rewards/types/errors.go | 1 + x/rewards/types/events.pb.go | 37 +++ x/rewards/types/expected_keepers.go | 1 + x/rewards/types/key_trading_reward.go | 21 +- x/rewards/types/messages_trading_reward.go | 5 +- x/rewards/types/trading_reward.pb.go | 300 ++++++++++++++++-- 18 files changed, 500 insertions(+), 50 deletions(-) create mode 100644 proto/rewards/events.proto create mode 100644 x/rewards/keeper/cleanup.go create mode 100644 x/rewards/types/events.pb.go diff --git a/app/app.go b/app/app.go index ea038dc6..695786b0 100644 --- a/app/app.go +++ b/app/app.go @@ -200,7 +200,7 @@ var ( tokenfactorytypes.ModuleName: {authtypes.Minter, authtypes.Burner}, tradebintypes.ModuleName: nil, epochstypes.ModuleName: nil, - rewardstypes.ModuleName: nil, + rewardstypes.ModuleName: {authtypes.Burner}, // this line is used by starport scaffolding # stargate/app/maccPerms } @@ -477,10 +477,17 @@ func New( app.EpochsKeeper, ) + app.TradebinKeeper.SetOnOrderFillHooks( + []tradebintypes.OnMarketOrderFill{ + app.RewardsKeeper.GetOnOrderFillHook(), + }, + ) + app.EpochsKeeper.SetHooks( []epochstypes.EpochHook{ app.RewardsKeeper.GetDistributeAllStakingRewardsHook(), app.RewardsKeeper.GetUnlockPendingUnlockParticipantsHook(), + //TODO: add here call to distribute trading rewards hook }, ) @@ -652,7 +659,8 @@ func New( app.mm.RegisterInvariants(&app.CrisisKeeper) app.mm.RegisterRoutes(app.Router(), app.QueryRouter(), encodingConfig.Amino) - app.mm.RegisterServices(module.NewConfigurator(app.appCodec, app.MsgServiceRouter(), app.GRPCQueryRouter())) + cfg := module.NewConfigurator(app.appCodec, app.MsgServiceRouter(), app.GRPCQueryRouter()) + app.mm.RegisterServices(cfg) // initialize stores app.MountKVStores(keys) @@ -678,7 +686,7 @@ func New( app.SetAnteHandler(anteHandler) app.SetEndBlocker(app.EndBlocker) - app.setupUpgradeHandlers() + app.setupUpgradeHandlers(cfg) if loadLatest { if err := app.LoadLatestVersion(); err != nil { @@ -693,8 +701,7 @@ func New( return app } -func (app *App) setupUpgradeHandlers() { - cfg := module.NewConfigurator(app.appCodec, app.MsgServiceRouter(), app.GRPCQueryRouter()) +func (app *App) setupUpgradeHandlers(cfg module.Configurator) { app.UpgradeKeeper.SetUpgradeHandler( v700.UpgradeName, v700.CreateUpgradeHandler(cfg, app.mm), diff --git a/proto/rewards/events.proto b/proto/rewards/events.proto new file mode 100644 index 00000000..7337c04b --- /dev/null +++ b/proto/rewards/events.proto @@ -0,0 +1,8 @@ +syntax = "proto3"; +package bze.rewards.v1; + +import "gogoproto/gogo.proto"; + +option go_package = "github.com/bze-alphateam/bze/x/rewards/types"; + + diff --git a/proto/rewards/trading_reward.proto b/proto/rewards/trading_reward.proto index e5101c57..0e7261c7 100644 --- a/proto/rewards/trading_reward.proto +++ b/proto/rewards/trading_reward.proto @@ -12,6 +12,12 @@ message TradingReward { uint32 duration = 4; string market_id = 5; uint32 slots = 6; + uint32 expire_at = 7; +} + +message TradingRewardExpiration { + string reward_id = 1; + uint32 expire_at = 2; } message TradingRewardLeaderboard { diff --git a/readme.md b/readme.md index 32f3cfc8..4aba3fd6 100644 --- a/readme.md +++ b/readme.md @@ -9,13 +9,11 @@ Zcash codebase in 2022 with the help of the community. ### Wallets: [Vidulum App](https://vidulum.app/) -[Keplr Browser Extension](https://keplr.getbze.com/) +[Keplr Browser Extension](https://chains.keplr.app/) ### Explorers: https://exporer.getbze.com/beezee https://ping.pub/beezee -https://explorer.erialos.me/beezee -https://explorers.vidulum.app/beezee ### Trading: [Osmosis Pool](https://frontier.osmosis.zone/pool/856) @@ -49,3 +47,6 @@ This will build binaries for all supported platforms and compress them in ./buil #### Build for specific platform: `make build-linux` This will build the binary for linux amd64 - check Makefile for more details and platforms + +#### Epochs hooks + diff --git a/x/rewards/genesis.go b/x/rewards/genesis.go index 90aa8a9c..38896a1d 100644 --- a/x/rewards/genesis.go +++ b/x/rewards/genesis.go @@ -16,6 +16,7 @@ func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) // Set all the tradingReward for _, elem := range genState.TradingRewardList { k.SetTradingReward(ctx, elem) + //TODO: move this to its own genesis export/import k.SetMarketIdRewardId(ctx, elem) } diff --git a/x/rewards/keeper/cleanup.go b/x/rewards/keeper/cleanup.go new file mode 100644 index 00000000..bdb7a359 --- /dev/null +++ b/x/rewards/keeper/cleanup.go @@ -0,0 +1,35 @@ +package keeper + +import ( + "github.com/bze-alphateam/bze/x/rewards/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +func (k Keeper) removeExpiredTradingRewards(ctx sdk.Context, epochNumber int64) { + logger := k.Logger(ctx).With("epoch_number", epochNumber) + toRemove := k.GetAllTradingRewardExpirationByExpireAt(ctx, uint32(epochNumber)) + for _, exp := range toRemove { + k.RemoveTradingRewardExpiration(ctx, exp.ExpireAt, exp.RewardId) + tr, found := k.GetTradingReward(ctx, exp.RewardId) + if !found { + logger.With("trading_reward_expiration", exp).Error("trading reward not found for this trading reward expiration") + continue + } + k.RemoveTradingReward(ctx, exp.RewardId) + + //burn coins that were captured + toBurn, err := k.getAmountToCapture("", tr.PrizeDenom, tr.PrizeAmount, int64(tr.Slots)) + if err != nil { + logger.With("trading_reward", tr).Error("could not create amount to capture") + continue + } + + err = k.bankKeeper.BurnCoins(ctx, types.ModuleName, toBurn) + if err != nil { + logger.With("trading_reward", tr, "to_burn", toBurn).Error("could not burn coins for trading reward") + continue + } + + logger.With("trading_reward_expiration", exp).Debug("removed expired trading reward") + } +} diff --git a/x/rewards/keeper/hooks.go b/x/rewards/keeper/hooks.go index c48a0e17..d6eefc8e 100644 --- a/x/rewards/keeper/hooks.go +++ b/x/rewards/keeper/hooks.go @@ -26,7 +26,24 @@ func (k Keeper) GetDistributeAllStakingRewardsHook() types.EpochHook { func (k Keeper) GetUnlockPendingUnlockParticipantsHook() types.EpochHook { hookName := "pending_unlock_hook" return types.NewAfterEpochHook(hookName, func(ctx sdk.Context, epochIdentifier string, epochNumber int64) error { - if epochIdentifier != distributionEpoch { + if epochIdentifier != expirationEpoch { + return nil + } + + k.Logger(ctx). + With("epoch", epochIdentifier, "epoch_number", epochNumber, "hook_name", hookName). + Debug("preparing to execute hook") + + k.UnlockAllPendingUnlockParticipantsByEpoch(ctx, epochNumber) + + return nil + }) +} + +func (k Keeper) GetRemoveExpiredTradingRewardsHook() types.EpochHook { + hookName := "remove_expired_trading_rewards" + return types.NewAfterEpochHook(hookName, func(ctx sdk.Context, epochIdentifier string, epochNumber int64) error { + if epochIdentifier != expirationEpoch { return nil } @@ -34,7 +51,7 @@ func (k Keeper) GetUnlockPendingUnlockParticipantsHook() types.EpochHook { With("epoch", epochIdentifier, "epoch_number", epochNumber, "hook_name", hookName). Debug("preparing to execute hook") - k.UnlockAllPendingUnlockParticipants(ctx, epochNumber) + k.removeExpiredTradingRewards(ctx, epochNumber) return nil }) diff --git a/x/rewards/keeper/keeper.go b/x/rewards/keeper/keeper.go index a884cb90..760caa26 100644 --- a/x/rewards/keeper/keeper.go +++ b/x/rewards/keeper/keeper.go @@ -12,9 +12,11 @@ import ( ) const ( - epochIdentifierDay = "day" + epochIdentifierDay = "day" + epochIdentifierHour = "hour" distributionEpoch = epochIdentifierDay + expirationEpoch = epochIdentifierHour ) type ( diff --git a/x/rewards/keeper/msg_server_exit_staking.go b/x/rewards/keeper/msg_server_exit_staking.go index 6e213ab7..35e3d759 100644 --- a/x/rewards/keeper/msg_server_exit_staking.go +++ b/x/rewards/keeper/msg_server_exit_staking.go @@ -53,8 +53,8 @@ func (k msgServer) ExitStaking(goCtx context.Context, msg *types.MsgExitStaking) } func (k msgServer) beginUnlock(ctx sdk.Context, p types.StakingRewardParticipant, sr types.StakingReward) { - lockedUntil := k.epochKeeper.GetEpochCountByIdentifier(ctx, distributionEpoch) - lockedUntil += int64(sr.Lock) + lockedUntil := k.epochKeeper.GetEpochCountByIdentifier(ctx, expirationEpoch) + lockedUntil += int64(sr.Lock) * 24 pending := types.PendingUnlockParticipant{ Index: types.CreatePendingUnlockParticipantKey(lockedUntil, sr.RewardId), Address: p.Address, diff --git a/x/rewards/keeper/msg_server_trading_reward.go b/x/rewards/keeper/msg_server_trading_reward.go index a38e7247..34e3fb39 100644 --- a/x/rewards/keeper/msg_server_trading_reward.go +++ b/x/rewards/keeper/msg_server_trading_reward.go @@ -8,6 +8,10 @@ import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" ) +const ( + expirationPeriodInHours uint32 = 30 * 24 +) + func (k msgServer) CreateTradingReward(goCtx context.Context, msg *types.MsgCreateTradingReward) (*types.MsgCreateTradingRewardResponse, error) { ctx := sdk.UnwrapSDKContext(goCtx) if msg == nil { @@ -34,6 +38,12 @@ func (k msgServer) CreateTradingReward(goCtx context.Context, msg *types.MsgCrea return nil, types.ErrInvalidMarketId } + //if there is already an active reward for this market id do not allow adding another one + _, found := k.GetMarketIdRewardId(ctx, tradingReward.MarketId) + if found { + return nil, types.ErrRewardAlreadyExists + } + feeParam := k.GetParams(ctx).CreateTradingRewardFee toCapture, err := k.getAmountToCapture(feeParam, tradingReward.PrizeDenom, tradingReward.PrizeAmount, int64(tradingReward.Slots)) if err != nil { @@ -52,11 +62,18 @@ func (k msgServer) CreateTradingReward(goCtx context.Context, msg *types.MsgCrea //add ID tradingReward.RewardId = k.smallZeroFillId(k.GetTradingRewardsCounter(ctx)) + tradingReward.ExpireAt = k.getNewTradingRewardExpireAt(ctx) k.SetTradingReward( ctx, tradingReward, ) - k.SetMarketIdRewardId(ctx, tradingReward) + + //save expiration + exp := types.TradingRewardExpiration{ + RewardId: tradingReward.RewardId, + ExpireAt: tradingReward.ExpireAt, + } + k.SetTradingRewardExpiration(ctx, exp) return &types.MsgCreateTradingRewardResponse{RewardId: tradingReward.RewardId}, nil } @@ -69,3 +86,9 @@ func (k msgServer) checkUserBalances(ctx sdk.Context, neededCoins sdk.Coins, add return nil } + +func (k msgServer) getNewTradingRewardExpireAt(ctx sdk.Context) uint32 { + cnt := uint32(k.epochKeeper.GetEpochCountByIdentifier(ctx, expirationEpoch)) + + return cnt + expirationPeriodInHours +} diff --git a/x/rewards/keeper/trading_reward.go b/x/rewards/keeper/trading_reward.go index e1e80b6d..23e3a8ed 100644 --- a/x/rewards/keeper/trading_reward.go +++ b/x/rewards/keeper/trading_reward.go @@ -71,3 +71,58 @@ func (k Keeper) RemoveMarketIdRewardId(ctx sdk.Context, marketId string) { store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.MarketIdRewardIdKeyPrefix)) store.Delete(types.MarketIdRewardIdKey(marketId)) } + +func (k Keeper) GetAllMarketIdRewardId(ctx sdk.Context) (list []string) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.MarketIdRewardIdKeyPrefix)) + iterator := sdk.KVStorePrefixIterator(store, []byte{}) + + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + list = append(list, string(iterator.Value())) + } + + return +} + +// SetTradingRewardExpiration save the reward id on the expiration key +func (k Keeper) SetTradingRewardExpiration(ctx sdk.Context, expiration types.TradingRewardExpiration) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.TradingRewardExpirationKeyPrefix)) + b := k.cdc.MustMarshal(&expiration) + store.Set(types.TradingRewardExpirationKey(expiration.ExpireAt, expiration.RewardId), b) +} + +func (k Keeper) RemoveTradingRewardExpiration(ctx sdk.Context, expireAt uint32, rewardId string) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.TradingRewardExpirationKeyPrefix)) + store.Delete(types.TradingRewardExpirationKey(expireAt, rewardId)) +} + +func (k Keeper) GetAllTradingRewardExpiration(ctx sdk.Context) (list []types.TradingRewardExpiration) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.TradingRewardExpirationKeyPrefix)) + iterator := sdk.KVStorePrefixIterator(store, []byte{}) + + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + var val types.TradingRewardExpiration + k.cdc.MustUnmarshal(iterator.Value(), &val) + list = append(list, val) + } + + return +} + +func (k Keeper) GetAllTradingRewardExpirationByExpireAt(ctx sdk.Context, expireAt uint32) (list []types.TradingRewardExpiration) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.TradingRewardExpirationKeyPrefix)) + iterator := sdk.KVStorePrefixIterator(store, []byte(types.TradingRewardExpirationByExpireAtPrefix(expireAt))) + + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + var val types.TradingRewardExpiration + k.cdc.MustUnmarshal(iterator.Value(), &val) + list = append(list, val) + } + + return +} diff --git a/x/rewards/keeper/unlock.go b/x/rewards/keeper/unlock.go index 48a57a45..e09619f5 100644 --- a/x/rewards/keeper/unlock.go +++ b/x/rewards/keeper/unlock.go @@ -5,7 +5,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ) -func (k Keeper) UnlockAllPendingUnlockParticipants(ctx sdk.Context, epochNumber int64) { +func (k Keeper) UnlockAllPendingUnlockParticipantsByEpoch(ctx sdk.Context, epochNumber int64) { pending := k.GetAllEpochPendingUnlockParticipant(ctx, epochNumber) for _, p := range pending { logger := k.Logger(ctx).With("pending_unlock", p) diff --git a/x/rewards/types/errors.go b/x/rewards/types/errors.go index b4c78d2d..df995c54 100644 --- a/x/rewards/types/errors.go +++ b/x/rewards/types/errors.go @@ -17,4 +17,5 @@ var ( ErrInvalidMarketId = sdkerrors.Register(ModuleName, 5007, "invalid market_id") ErrInvalidSlots = sdkerrors.Register(ModuleName, 5008, "invalid slots") ErrInvalidRewardId = sdkerrors.Register(ModuleName, 5009, "invalid reward_id") + ErrRewardAlreadyExists = sdkerrors.Register(ModuleName, 5009, "a reward is already running for this market") ) diff --git a/x/rewards/types/events.pb.go b/x/rewards/types/events.pb.go new file mode 100644 index 00000000..84fc2f8c --- /dev/null +++ b/x/rewards/types/events.pb.go @@ -0,0 +1,37 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: rewards/events.proto + +package types + +import ( + fmt "fmt" + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + 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("rewards/events.proto", fileDescriptor_d74b3d0352ba8267) } + +var fileDescriptor_d74b3d0352ba8267 = []byte{ + // 139 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x29, 0x4a, 0x2d, 0x4f, + 0x2c, 0x4a, 0x29, 0xd6, 0x4f, 0x2d, 0x4b, 0xcd, 0x2b, 0x29, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, + 0x17, 0xe2, 0x4b, 0xaa, 0x4a, 0xd5, 0x83, 0xca, 0xe8, 0x95, 0x19, 0x4a, 0x89, 0xa4, 0xe7, 0xa7, + 0xe7, 0x83, 0xa5, 0xf4, 0x41, 0x2c, 0x88, 0x2a, 0x27, 0xb7, 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, 0xd2, 0x49, 0xcf, 0x2c, 0xc9, 0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, + 0x4f, 0xaa, 0x4a, 0xd5, 0x4d, 0xcc, 0x29, 0xc8, 0x48, 0x2c, 0x49, 0x4d, 0x04, 0xf3, 0xf4, 0x2b, + 0xf4, 0x61, 0x96, 0x96, 0x54, 0x16, 0xa4, 0x16, 0x27, 0xb1, 0x81, 0x8d, 0x33, 0x06, 0x04, 0x00, + 0x00, 0xff, 0xff, 0x9f, 0x97, 0x71, 0x1d, 0x8c, 0x00, 0x00, 0x00, +} diff --git a/x/rewards/types/expected_keepers.go b/x/rewards/types/expected_keepers.go index 47d534a8..4662e61f 100644 --- a/x/rewards/types/expected_keepers.go +++ b/x/rewards/types/expected_keepers.go @@ -18,6 +18,7 @@ type AccountKeeper interface { // BankKeeper defines the expected interface needed to retrieve account balances. type BankKeeper interface { SpendableCoins(ctx sdk.Context, addr sdk.AccAddress) sdk.Coins + BurnCoins(ctx sdk.Context, moduleName string, amounts sdk.Coins) error HasSupply(ctx sdk.Context, denom string) bool SendCoinsFromModuleToAccount(ctx sdk.Context, senderModule string, recipientAddr sdk.AccAddress, amt sdk.Coins) error diff --git a/x/rewards/types/key_trading_reward.go b/x/rewards/types/key_trading_reward.go index 46fd95ba..df38a8a9 100644 --- a/x/rewards/types/key_trading_reward.go +++ b/x/rewards/types/key_trading_reward.go @@ -1,6 +1,9 @@ package types -import "encoding/binary" +import ( + "encoding/binary" + "fmt" +) var _ binary.ByteOrder @@ -13,21 +16,31 @@ const ( LeaderboardKeyPrefix = "tr/lb/" // RewardCandidateKeyPrefix prefix that holds entries/participants for trading rewards RewardCandidateKeyPrefix = "tr/r/" + // TradingRewardExpirationKeyPrefix - the prefix used to save trading reward expiration + TradingRewardExpirationKeyPrefix = "tr/exp/" ) // TradingRewardCandidateKey returns the store key to retrieve a reward candidate func TradingRewardCandidateKey(rewardId, address string) []byte { - return []byte(rewardId + "/" + address) + return []byte(rewardId + "/" + address + "/") } // MarketIdRewardIdKey returns the store key to retrieve a TradingReward.RewardId from the index fields func MarketIdRewardIdKey(marketId string) []byte { - return []byte(marketId) + return []byte(marketId + "/") } // TradingRewardKey returns the store key to retrieve a TradingReward from the index fields func TradingRewardKey(rewardId string) []byte { - return []byte(rewardId) + return []byte(rewardId + "/") +} + +func TradingRewardExpirationKey(expireAt uint32, rewardId string) []byte { + return []byte(TradingRewardExpirationByExpireAtPrefix(expireAt) + rewardId + "/") +} + +func TradingRewardExpirationByExpireAtPrefix(expireAt uint32) string { + return fmt.Sprintf("%d/", expireAt) } func TradingRewardCounterKey() []byte { diff --git a/x/rewards/types/messages_trading_reward.go b/x/rewards/types/messages_trading_reward.go index 6a70ee85..784841f5 100644 --- a/x/rewards/types/messages_trading_reward.go +++ b/x/rewards/types/messages_trading_reward.go @@ -9,7 +9,8 @@ import ( const ( TypeMsgCreateTradingReward = "create_trading_reward" - maxAllowedSlots = 10 + maxAllowedSlots = 10 + maxAllowedDuration = 365 ) var _ sdk.Msg = &MsgCreateTradingReward{} @@ -80,7 +81,7 @@ func (msg *MsgCreateTradingReward) ToTradingReward() (TradingReward, error) { if err != nil { return tr, sdkerrors.Wrapf(ErrInvalidDuration, "could not convert duration to int: %s", err.Error()) } - if durationInt <= 0 || durationInt > tenYearsInDays { + if durationInt <= 0 || durationInt > maxAllowedDuration { return tr, ErrInvalidDuration } tr.Duration = uint32(durationInt) diff --git a/x/rewards/types/trading_reward.pb.go b/x/rewards/types/trading_reward.pb.go index feacf296..93de07ea 100644 --- a/x/rewards/types/trading_reward.pb.go +++ b/x/rewards/types/trading_reward.pb.go @@ -30,6 +30,7 @@ type TradingReward struct { Duration uint32 `protobuf:"varint,4,opt,name=duration,proto3" json:"duration,omitempty"` MarketId string `protobuf:"bytes,5,opt,name=market_id,json=marketId,proto3" json:"market_id,omitempty"` Slots uint32 `protobuf:"varint,6,opt,name=slots,proto3" json:"slots,omitempty"` + ExpireAt uint32 `protobuf:"varint,7,opt,name=expire_at,json=expireAt,proto3" json:"expire_at,omitempty"` } func (m *TradingReward) Reset() { *m = TradingReward{} } @@ -107,6 +108,65 @@ func (m *TradingReward) GetSlots() uint32 { return 0 } +func (m *TradingReward) GetExpireAt() uint32 { + if m != nil { + return m.ExpireAt + } + return 0 +} + +type TradingRewardExpiration struct { + RewardId string `protobuf:"bytes,1,opt,name=reward_id,json=rewardId,proto3" json:"reward_id,omitempty"` + ExpireAt uint32 `protobuf:"varint,2,opt,name=expire_at,json=expireAt,proto3" json:"expire_at,omitempty"` +} + +func (m *TradingRewardExpiration) Reset() { *m = TradingRewardExpiration{} } +func (m *TradingRewardExpiration) String() string { return proto.CompactTextString(m) } +func (*TradingRewardExpiration) ProtoMessage() {} +func (*TradingRewardExpiration) Descriptor() ([]byte, []int) { + return fileDescriptor_e96afcb90471b82d, []int{1} +} +func (m *TradingRewardExpiration) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *TradingRewardExpiration) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_TradingRewardExpiration.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 *TradingRewardExpiration) XXX_Merge(src proto.Message) { + xxx_messageInfo_TradingRewardExpiration.Merge(m, src) +} +func (m *TradingRewardExpiration) XXX_Size() int { + return m.Size() +} +func (m *TradingRewardExpiration) XXX_DiscardUnknown() { + xxx_messageInfo_TradingRewardExpiration.DiscardUnknown(m) +} + +var xxx_messageInfo_TradingRewardExpiration proto.InternalMessageInfo + +func (m *TradingRewardExpiration) GetRewardId() string { + if m != nil { + return m.RewardId + } + return "" +} + +func (m *TradingRewardExpiration) GetExpireAt() uint32 { + if m != nil { + return m.ExpireAt + } + return 0 +} + type TradingRewardLeaderboard struct { RewardId string `protobuf:"bytes,1,opt,name=reward_id,json=rewardId,proto3" json:"reward_id,omitempty"` List []TradingRewardLeaderboardEntry `protobuf:"bytes,2,rep,name=list,proto3" json:"list"` @@ -116,7 +176,7 @@ func (m *TradingRewardLeaderboard) Reset() { *m = TradingRewardLeaderboa func (m *TradingRewardLeaderboard) String() string { return proto.CompactTextString(m) } func (*TradingRewardLeaderboard) ProtoMessage() {} func (*TradingRewardLeaderboard) Descriptor() ([]byte, []int) { - return fileDescriptor_e96afcb90471b82d, []int{1} + return fileDescriptor_e96afcb90471b82d, []int{2} } func (m *TradingRewardLeaderboard) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -169,7 +229,7 @@ func (m *TradingRewardLeaderboardEntry) Reset() { *m = TradingRewardLead func (m *TradingRewardLeaderboardEntry) String() string { return proto.CompactTextString(m) } func (*TradingRewardLeaderboardEntry) ProtoMessage() {} func (*TradingRewardLeaderboardEntry) Descriptor() ([]byte, []int) { - return fileDescriptor_e96afcb90471b82d, []int{2} + return fileDescriptor_e96afcb90471b82d, []int{3} } func (m *TradingRewardLeaderboardEntry) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -229,7 +289,7 @@ func (m *TradingRewardCandidate) Reset() { *m = TradingRewardCandidate{} func (m *TradingRewardCandidate) String() string { return proto.CompactTextString(m) } func (*TradingRewardCandidate) ProtoMessage() {} func (*TradingRewardCandidate) Descriptor() ([]byte, []int) { - return fileDescriptor_e96afcb90471b82d, []int{3} + return fileDescriptor_e96afcb90471b82d, []int{4} } func (m *TradingRewardCandidate) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -281,6 +341,7 @@ func (m *TradingRewardCandidate) GetAddress() string { func init() { proto.RegisterType((*TradingReward)(nil), "bze.v1.rewards.TradingReward") + proto.RegisterType((*TradingRewardExpiration)(nil), "bze.v1.rewards.TradingRewardExpiration") proto.RegisterType((*TradingRewardLeaderboard)(nil), "bze.v1.rewards.TradingRewardLeaderboard") proto.RegisterType((*TradingRewardLeaderboardEntry)(nil), "bze.v1.rewards.TradingRewardLeaderboardEntry") proto.RegisterType((*TradingRewardCandidate)(nil), "bze.v1.rewards.TradingRewardCandidate") @@ -289,32 +350,34 @@ func init() { func init() { proto.RegisterFile("rewards/trading_reward.proto", fileDescriptor_e96afcb90471b82d) } var fileDescriptor_e96afcb90471b82d = []byte{ - // 391 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x52, 0xcd, 0x8e, 0xda, 0x30, - 0x18, 0x8c, 0x09, 0x50, 0xf8, 0x28, 0x3d, 0x58, 0x08, 0x45, 0xb4, 0x04, 0x9a, 0x13, 0x87, 0x92, - 0xa8, 0xed, 0x13, 0x40, 0xff, 0x84, 0xd4, 0x53, 0xd4, 0x53, 0x2f, 0x91, 0x83, 0xad, 0x10, 0x95, - 0xc4, 0x91, 0x63, 0xda, 0xc2, 0xa9, 0x8f, 0xd0, 0x37, 0xda, 0x2b, 0x47, 0x8e, 0x7b, 0x5a, 0xad, - 0xe0, 0x45, 0x56, 0xb1, 0xb3, 0xac, 0x72, 0x80, 0xbd, 0x79, 0xc6, 0xf3, 0xf9, 0x9b, 0x19, 0x19, - 0xde, 0x08, 0xf6, 0x87, 0x08, 0x9a, 0x7b, 0x52, 0x10, 0x1a, 0xa7, 0x51, 0xa0, 0xb1, 0x9b, 0x09, - 0x2e, 0x39, 0x7e, 0x15, 0xee, 0x98, 0xfb, 0xfb, 0xbd, 0x5b, 0x8a, 0x06, 0xbd, 0x88, 0x47, 0x5c, - 0x5d, 0x79, 0xc5, 0x49, 0xab, 0x9c, 0x1b, 0x04, 0xdd, 0x1f, 0x7a, 0xdc, 0x57, 0x42, 0xfc, 0x1a, - 0xda, 0x7a, 0x24, 0x88, 0xa9, 0x85, 0xc6, 0x68, 0xd2, 0xf6, 0x5b, 0x9a, 0x58, 0x50, 0xfc, 0x16, - 0x5e, 0x66, 0x22, 0xde, 0xb1, 0x80, 0x24, 0x7c, 0x93, 0x4a, 0xab, 0xa6, 0xee, 0x3b, 0x8a, 0x9b, - 0x29, 0x0a, 0x8f, 0x40, 0xc3, 0x80, 0xb2, 0x94, 0x27, 0x96, 0xa9, 0x14, 0xa0, 0xa8, 0xcf, 0x05, - 0x83, 0x07, 0xd0, 0xa2, 0x1b, 0x41, 0x64, 0xcc, 0x53, 0xab, 0x3e, 0x46, 0x93, 0xae, 0x7f, 0xc6, - 0xc5, 0xf2, 0x84, 0x88, 0x5f, 0x4c, 0x16, 0xcb, 0x1b, 0x7a, 0xb9, 0x26, 0x16, 0x14, 0xf7, 0xa0, - 0x91, 0xaf, 0xb9, 0xcc, 0xad, 0xa6, 0x9a, 0xd2, 0xc0, 0xf9, 0x87, 0xc0, 0xaa, 0x24, 0xf8, 0xce, - 0x08, 0x65, 0x22, 0xe4, 0xcf, 0x86, 0xf9, 0x06, 0xf5, 0x75, 0x9c, 0x17, 0x21, 0xcc, 0x49, 0xe7, - 0xc3, 0xd4, 0xad, 0x16, 0xe6, 0x5e, 0x7a, 0xf4, 0x4b, 0x2a, 0xc5, 0x76, 0x5e, 0xdf, 0xdf, 0x8d, - 0x0c, 0x5f, 0x3d, 0xe0, 0x64, 0x30, 0xbc, 0x2a, 0xc6, 0x7d, 0x68, 0x96, 0x85, 0x69, 0x0f, 0x25, - 0xc2, 0x16, 0xbc, 0x20, 0x94, 0x0a, 0x96, 0xe7, 0x65, 0x93, 0x8f, 0x10, 0x0f, 0x01, 0x96, 0x82, - 0x11, 0xc9, 0x68, 0x40, 0xa4, 0x2a, 0xd1, 0xf4, 0xdb, 0x25, 0x33, 0x93, 0x4e, 0x04, 0xfd, 0xca, - 0xc6, 0x4f, 0x24, 0xa5, 0x31, 0x25, 0x92, 0x5d, 0x4f, 0xfc, 0xe4, 0xa3, 0x76, 0xc9, 0x87, 0x59, - 0xf1, 0x31, 0xff, 0xba, 0x3f, 0xda, 0xe8, 0x70, 0xb4, 0xd1, 0xfd, 0xd1, 0x46, 0xff, 0x4f, 0xb6, - 0x71, 0x38, 0xd9, 0xc6, 0xed, 0xc9, 0x36, 0x7e, 0xbe, 0x8b, 0x62, 0xb9, 0xda, 0x84, 0xee, 0x92, - 0x27, 0x5e, 0xb8, 0x63, 0x53, 0xb2, 0xce, 0x56, 0x44, 0x32, 0xa2, 0x90, 0xf7, 0xd7, 0x3b, 0x7f, - 0xce, 0x6d, 0xc6, 0xf2, 0xb0, 0xa9, 0xbe, 0xdb, 0xc7, 0x87, 0x00, 0x00, 0x00, 0xff, 0xff, 0x49, - 0xda, 0x67, 0xaf, 0xb4, 0x02, 0x00, 0x00, + // 424 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x53, 0xc1, 0x6e, 0xd3, 0x40, + 0x10, 0xf5, 0xc6, 0x69, 0xda, 0x4c, 0x29, 0x87, 0x55, 0x55, 0x56, 0x85, 0xba, 0xc5, 0xa7, 0x1c, + 0xa8, 0x2d, 0xe0, 0x0b, 0x52, 0x28, 0xa8, 0x12, 0x27, 0xc3, 0x89, 0x8b, 0xb5, 0xee, 0x8e, 0xdc, + 0x15, 0xb1, 0xd7, 0x5a, 0x6f, 0xa0, 0xcd, 0x89, 0x4f, 0xe0, 0xb3, 0x7a, 0xec, 0x91, 0x03, 0x42, + 0x28, 0xf9, 0x11, 0xb4, 0xbb, 0x26, 0xc8, 0x48, 0x29, 0x37, 0xbf, 0x37, 0x6f, 0xde, 0x9b, 0xf1, + 0xd8, 0xf0, 0x44, 0xe3, 0x17, 0xae, 0x45, 0x9b, 0x1a, 0xcd, 0x85, 0xac, 0xcb, 0xdc, 0xe3, 0xa4, + 0xd1, 0xca, 0x28, 0xfa, 0xb0, 0x58, 0x60, 0xf2, 0xf9, 0x79, 0xd2, 0x89, 0x0e, 0xf7, 0x4b, 0x55, + 0x2a, 0x57, 0x4a, 0xed, 0x93, 0x57, 0xc5, 0x3f, 0x08, 0xec, 0x7d, 0xf0, 0xed, 0x99, 0x13, 0xd2, + 0xc7, 0x30, 0xf6, 0x2d, 0xb9, 0x14, 0x8c, 0x9c, 0x90, 0xc9, 0x38, 0xdb, 0xf1, 0xc4, 0x85, 0xa0, + 0x4f, 0xe1, 0x41, 0xa3, 0xe5, 0x02, 0x73, 0x5e, 0xa9, 0x79, 0x6d, 0xd8, 0xc0, 0xd5, 0x77, 0x1d, + 0x37, 0x75, 0x14, 0x3d, 0x06, 0x0f, 0x73, 0x81, 0xb5, 0xaa, 0x58, 0xe8, 0x14, 0xe0, 0xa8, 0xd7, + 0x96, 0xa1, 0x87, 0xb0, 0x23, 0xe6, 0x9a, 0x1b, 0xa9, 0x6a, 0x36, 0x3c, 0x21, 0x93, 0xbd, 0x6c, + 0x8d, 0x6d, 0x78, 0xc5, 0xf5, 0x27, 0x34, 0x36, 0x7c, 0xcb, 0x87, 0x7b, 0xe2, 0x42, 0xd0, 0x7d, + 0xd8, 0x6a, 0x67, 0xca, 0xb4, 0x6c, 0xe4, 0xba, 0x3c, 0xb0, 0x2d, 0x78, 0xdd, 0x48, 0x8d, 0x39, + 0x37, 0x6c, 0xdb, 0xfb, 0x79, 0x62, 0x6a, 0xe2, 0xf7, 0xf0, 0xa8, 0xb7, 0xdd, 0xb9, 0x2d, 0xac, + 0xa3, 0x36, 0xef, 0xd9, 0x33, 0x1d, 0xfc, 0x63, 0xfa, 0x95, 0x00, 0xeb, 0xb9, 0xbe, 0x43, 0x2e, + 0x50, 0x17, 0xea, 0xbf, 0xaf, 0xef, 0x2d, 0x0c, 0x67, 0xb2, 0xb5, 0x8e, 0xe1, 0x64, 0xf7, 0xc5, + 0x69, 0xd2, 0x3f, 0x51, 0xb2, 0xc9, 0xf4, 0xbc, 0x36, 0xfa, 0xe6, 0x6c, 0x78, 0xfb, 0xf3, 0x38, + 0xc8, 0x9c, 0x41, 0xdc, 0xc0, 0xd1, 0xbd, 0x62, 0x7a, 0x00, 0xa3, 0xee, 0x44, 0x7e, 0x86, 0x0e, + 0x51, 0x06, 0xdb, 0x5c, 0x08, 0x8d, 0x6d, 0xdb, 0xdd, 0xee, 0x0f, 0xa4, 0x47, 0x00, 0x97, 0x1a, + 0xb9, 0x41, 0x61, 0x77, 0xb6, 0x67, 0x0b, 0xb3, 0x71, 0xc7, 0x4c, 0x4d, 0x5c, 0xc2, 0x41, 0x2f, + 0xf1, 0x15, 0xaf, 0x85, 0x14, 0xdc, 0xe0, 0xfd, 0x1b, 0xff, 0x9d, 0x63, 0xb0, 0x69, 0x8e, 0xb0, + 0x37, 0xc7, 0xd9, 0x9b, 0xdb, 0x65, 0x44, 0xee, 0x96, 0x11, 0xf9, 0xb5, 0x8c, 0xc8, 0xb7, 0x55, + 0x14, 0xdc, 0xad, 0xa2, 0xe0, 0xfb, 0x2a, 0x0a, 0x3e, 0x3e, 0x2b, 0xa5, 0xb9, 0x9a, 0x17, 0xc9, + 0xa5, 0xaa, 0xd2, 0x62, 0x81, 0xa7, 0x7c, 0xd6, 0x5c, 0x71, 0x83, 0xdc, 0xa1, 0xf4, 0x3a, 0x5d, + 0xff, 0x0e, 0x37, 0x0d, 0xb6, 0xc5, 0xc8, 0x7d, 0xe0, 0x2f, 0x7f, 0x07, 0x00, 0x00, 0xff, 0xff, + 0x32, 0x24, 0xaa, 0x45, 0x26, 0x03, 0x00, 0x00, } func (m *TradingReward) Marshal() (dAtA []byte, err error) { @@ -337,6 +400,11 @@ func (m *TradingReward) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.ExpireAt != 0 { + i = encodeVarintTradingReward(dAtA, i, uint64(m.ExpireAt)) + i-- + dAtA[i] = 0x38 + } if m.Slots != 0 { i = encodeVarintTradingReward(dAtA, i, uint64(m.Slots)) i-- @@ -378,6 +446,41 @@ func (m *TradingReward) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *TradingRewardExpiration) 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 *TradingRewardExpiration) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *TradingRewardExpiration) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.ExpireAt != 0 { + i = encodeVarintTradingReward(dAtA, i, uint64(m.ExpireAt)) + i-- + dAtA[i] = 0x10 + } + if len(m.RewardId) > 0 { + i -= len(m.RewardId) + copy(dAtA[i:], m.RewardId) + i = encodeVarintTradingReward(dAtA, i, uint64(len(m.RewardId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func (m *TradingRewardLeaderboard) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -547,6 +650,25 @@ func (m *TradingReward) Size() (n int) { if m.Slots != 0 { n += 1 + sovTradingReward(uint64(m.Slots)) } + if m.ExpireAt != 0 { + n += 1 + sovTradingReward(uint64(m.ExpireAt)) + } + return n +} + +func (m *TradingRewardExpiration) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.RewardId) + if l > 0 { + n += 1 + l + sovTradingReward(uint64(l)) + } + if m.ExpireAt != 0 { + n += 1 + sovTradingReward(uint64(m.ExpireAt)) + } return n } @@ -811,6 +933,126 @@ func (m *TradingReward) Unmarshal(dAtA []byte) error { break } } + case 7: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ExpireAt", wireType) + } + m.ExpireAt = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTradingReward + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ExpireAt |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipTradingReward(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTradingReward + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *TradingRewardExpiration) 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 ErrIntOverflowTradingReward + } + 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: TradingRewardExpiration: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: TradingRewardExpiration: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RewardId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTradingReward + } + 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 ErrInvalidLengthTradingReward + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTradingReward + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.RewardId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ExpireAt", wireType) + } + m.ExpireAt = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTradingReward + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ExpireAt |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipTradingReward(dAtA[iNdEx:]) From 5366796669d1e9040fadd8a7a80c44ead028450e Mon Sep 17 00:00:00 2001 From: faneaatiku Date: Tue, 26 Mar 2024 23:44:02 +0200 Subject: [PATCH 17/35] added trading reward distribution --- app/app.go | 3 +- docs/static/openapi.yml | 15 + go.mod | 3 - go.sum | 12 - proto/rewards/genesis.proto | 14 +- proto/rewards/trading_reward.proto | 5 + ts-client/bze.burner.v1/index.ts | 6 + ts-client/bze.burner.v1/module.ts | 99 + ts-client/bze.burner.v1/registry.ts | 9 + ts-client/bze.burner.v1/rest.ts | 357 ++ ts-client/bze.burner.v1/types.ts | 15 + .../types/burner/burn_coins_proposal.ts | 93 + .../types/burner/burned_coins.ts | 92 + .../bze.burner.v1/types/burner/events.ts | 151 + .../bze.burner.v1/types/burner/genesis.ts | 114 + .../bze.burner.v1/types/burner/params.ts | 56 + ts-client/bze.burner.v1/types/burner/query.ts | 352 + ts-client/bze.burner.v1/types/burner/tx.ts | 160 + .../cosmos/base/query/v1beta1/pagination.ts | 327 + .../bze.burner.v1/types/gogoproto/gogo.ts | 2 + .../types/google/api/annotations.ts | 2 + .../bze.burner.v1/types/google/api/http.ts | 705 ++ .../types/google/protobuf/descriptor.ts | 5261 +++++++++++++++ ts-client/bze.cointrunk.v1/index.ts | 6 + ts-client/bze.cointrunk.v1/module.ts | 132 + ts-client/bze.cointrunk.v1/registry.ts | 11 + ts-client/bze.cointrunk.v1/rest.ts | 577 ++ ts-client/bze.cointrunk.v1/types.ts | 33 + .../types/cointrunk/accepted_domain.ts | 92 + .../cointrunk/accepted_domain_proposal.ts | 139 + .../types/cointrunk/anon_articles_counter.ts | 118 + .../types/cointrunk/article.ts | 213 + .../types/cointrunk/events.ts | 586 ++ .../types/cointrunk/genesis.ts | 218 + .../types/cointrunk/params.ts | 252 + .../types/cointrunk/publisher.ts | 195 + .../types/cointrunk/publisher_proposal.ts | 153 + .../bze.cointrunk.v1/types/cointrunk/query.ts | 1108 ++++ .../bze.cointrunk.v1/types/cointrunk/tx.ts | 477 ++ .../cosmos/base/query/v1beta1/pagination.ts | 327 + .../types/cosmos/base/v1beta1/coin.ts | 301 + .../bze.cointrunk.v1/types/gogoproto/gogo.ts | 2 + .../types/google/api/annotations.ts | 2 + .../bze.cointrunk.v1/types/google/api/http.ts | 705 ++ .../types/google/protobuf/descriptor.ts | 5261 +++++++++++++++ ts-client/bze.epochs.v1/index.ts | 6 + ts-client/bze.epochs.v1/module.ts | 66 + ts-client/bze.epochs.v1/registry.ts | 7 + ts-client/bze.epochs.v1/rest.ts | 325 + ts-client/bze.epochs.v1/types.ts | 11 + .../bze.epochs.v1/types/epochs/events.ts | 169 + .../bze.epochs.v1/types/epochs/genesis.ts | 398 ++ ts-client/bze.epochs.v1/types/epochs/query.ts | 353 + .../bze.epochs.v1/types/gogoproto/gogo.ts | 2 + .../types/google/api/annotations.ts | 2 + .../bze.epochs.v1/types/google/api/http.ts | 705 ++ .../types/google/protobuf/descriptor.ts | 5261 +++++++++++++++ .../types/google/protobuf/duration.ts | 188 + .../types/google/protobuf/timestamp.ts | 219 + ts-client/bze.scavenge/index.ts | 6 + ts-client/bze.scavenge/module.ts | 165 + ts-client/bze.scavenge/registry.ts | 13 + ts-client/bze.scavenge/rest.ts | 424 ++ ts-client/bze.scavenge/types.ts | 9 + .../cosmos/base/query/v1beta1/pagination.ts | 327 + .../bze.scavenge/types/gogoproto/gogo.ts | 2 + .../types/google/api/annotations.ts | 2 + .../bze.scavenge/types/google/api/http.ts | 705 ++ .../types/google/protobuf/descriptor.ts | 5261 +++++++++++++++ .../bze.scavenge/types/scavenge/commit.ts | 122 + .../bze.scavenge/types/scavenge/genesis.ts | 114 + .../bze.scavenge/types/scavenge/query.ts | 703 ++ .../bze.scavenge/types/scavenge/scavenge.ts | 173 + ts-client/bze.scavenge/types/scavenge/tx.ts | 574 ++ ts-client/bze.tokenfactory.v1/index.ts | 6 + ts-client/bze.tokenfactory.v1/module.ts | 231 + ts-client/bze.tokenfactory.v1/registry.ts | 17 + ts-client/bze.tokenfactory.v1/rest.ts | 335 + ts-client/bze.tokenfactory.v1/types.ts | 11 + .../types/cosmos/bank/v1beta1/bank.ts | 735 +++ .../cosmos/base/query/v1beta1/pagination.ts | 327 + .../types/cosmos/base/v1beta1/coin.ts | 301 + .../types/cosmos_proto/cosmos.ts | 2 + .../types/gogoproto/gogo.ts | 2 + .../types/google/api/annotations.ts | 2 + .../types/google/api/http.ts | 705 ++ .../types/google/protobuf/descriptor.ts | 5261 +++++++++++++++ .../types/tokenfactory/denom_authority.ts | 75 + .../types/tokenfactory/genesis.ts | 200 + .../types/tokenfactory/params.ts | 76 + .../types/tokenfactory/query.ts | 328 + .../types/tokenfactory/tx.ts | 739 +++ ts-client/bze.tradebin.v1/index.ts | 6 + ts-client/bze.tradebin.v1/module.ts | 165 + ts-client/bze.tradebin.v1/registry.ts | 13 + ts-client/bze.tradebin.v1/rest.ts | 601 ++ ts-client/bze.tradebin.v1/types.ts | 31 + .../cosmos/base/query/v1beta1/pagination.ts | 327 + .../bze.tradebin.v1/types/gogoproto/gogo.ts | 2 + .../types/google/api/annotations.ts | 2 + .../bze.tradebin.v1/types/google/api/http.ts | 705 ++ .../types/google/protobuf/descriptor.ts | 5261 +++++++++++++++ .../bze.tradebin.v1/types/tradebin/events.ts | 807 +++ .../bze.tradebin.v1/types/tradebin/genesis.ts | 281 + .../bze.tradebin.v1/types/tradebin/market.ts | 110 + .../bze.tradebin.v1/types/tradebin/order.ts | 601 ++ .../bze.tradebin.v1/types/tradebin/params.ts | 176 + .../bze.tradebin.v1/types/tradebin/query.ts | 1585 +++++ .../types/tradebin/queue_message.ts | 252 + .../bze.tradebin.v1/types/tradebin/tx.ts | 551 ++ ts-client/bze.v1.rewards/index.ts | 6 + ts-client/bze.v1.rewards/module.ts | 264 + ts-client/bze.v1.rewards/registry.ts | 19 + ts-client/bze.v1.rewards/rest.ts | 580 ++ ts-client/bze.v1.rewards/types.ts | 25 + .../cosmos/base/query/v1beta1/pagination.ts | 327 + .../bze.v1.rewards/types/gogoproto/gogo.ts | 2 + .../types/google/api/annotations.ts | 2 + .../bze.v1.rewards/types/google/api/http.ts | 705 ++ .../types/google/protobuf/descriptor.ts | 5261 +++++++++++++++ .../bze.v1.rewards/types/rewards/events.ts | 2 + .../bze.v1.rewards/types/rewards/genesis.ts | 544 ++ .../bze.v1.rewards/types/rewards/params.ts | 110 + .../bze.v1.rewards/types/rewards/query.ts | 1321 ++++ .../types/rewards/staking_reward.ts | 282 + .../rewards/staking_reward_participant.ts | 281 + .../types/rewards/trading_reward.ts | 712 +++ ts-client/bze.v1.rewards/types/rewards/tx.ts | 1185 ++++ ts-client/client.ts | 51 + ts-client/cosmos.auth.v1beta1/index.ts | 6 + ts-client/cosmos.auth.v1beta1/module.ts | 66 + ts-client/cosmos.auth.v1beta1/registry.ts | 7 + ts-client/cosmos.auth.v1beta1/rest.ts | 607 ++ ts-client/cosmos.auth.v1beta1/types.ts | 11 + .../types/cosmos/auth/v1beta1/auth.ts | 436 ++ .../types/cosmos/auth/v1beta1/genesis.ts | 107 + .../types/cosmos/auth/v1beta1/query.ts | 660 ++ .../cosmos/base/query/v1beta1/pagination.ts | 327 + .../types/cosmos_proto/cosmos.ts | 2 + .../types/gogoproto/gogo.ts | 2 + .../types/google/api/annotations.ts | 2 + .../types/google/api/http.ts | 705 ++ .../types/google/protobuf/any.ts | 240 + .../types/google/protobuf/descriptor.ts | 5261 +++++++++++++++ ts-client/cosmos.authz.v1beta1/index.ts | 6 + ts-client/cosmos.authz.v1beta1/module.ts | 165 + ts-client/cosmos.authz.v1beta1/registry.ts | 13 + ts-client/cosmos.authz.v1beta1/rest.ts | 719 +++ ts-client/cosmos.authz.v1beta1/types.ts | 15 + .../types/cosmos/authz/v1beta1/authz.ts | 335 + .../types/cosmos/authz/v1beta1/event.ts | 215 + .../types/cosmos/authz/v1beta1/genesis.ts | 89 + .../types/cosmos/authz/v1beta1/query.ts | 732 +++ .../types/cosmos/authz/v1beta1/tx.ts | 554 ++ .../types/cosmos/base/abci/v1beta1/abci.ts | 1279 ++++ .../cosmos/base/query/v1beta1/pagination.ts | 327 + .../types/cosmos_proto/cosmos.ts | 2 + .../types/gogoproto/gogo.ts | 2 + .../types/google/api/annotations.ts | 2 + .../types/google/api/http.ts | 705 ++ .../types/google/protobuf/any.ts | 240 + .../types/google/protobuf/descriptor.ts | 5261 +++++++++++++++ .../types/google/protobuf/duration.ts | 188 + .../types/google/protobuf/timestamp.ts | 219 + .../types/tendermint/abci/types.ts | 5687 +++++++++++++++++ .../types/tendermint/crypto/keys.ts | 130 + .../types/tendermint/crypto/proof.ts | 529 ++ .../types/tendermint/types/params.ts | 625 ++ .../types/tendermint/types/types.ts | 1912 ++++++ .../types/tendermint/types/validator.ts | 382 ++ .../types/tendermint/version/types.ts | 202 + ts-client/cosmos.bank.v1beta1/index.ts | 6 + ts-client/cosmos.bank.v1beta1/module.ts | 132 + ts-client/cosmos.bank.v1beta1/registry.ts | 11 + ts-client/cosmos.bank.v1beta1/rest.ts | 636 ++ ts-client/cosmos.bank.v1beta1/types.ts | 23 + .../types/cosmos/bank/v1beta1/authz.ts | 90 + .../types/cosmos/bank/v1beta1/bank.ts | 735 +++ .../types/cosmos/bank/v1beta1/genesis.ts | 254 + .../types/cosmos/bank/v1beta1/query.ts | 1518 +++++ .../types/cosmos/bank/v1beta1/tx.ts | 337 + .../cosmos/base/query/v1beta1/pagination.ts | 327 + .../types/cosmos/base/v1beta1/coin.ts | 301 + .../types/cosmos_proto/cosmos.ts | 2 + .../types/gogoproto/gogo.ts | 2 + .../types/google/api/annotations.ts | 2 + .../types/google/api/http.ts | 705 ++ .../types/google/protobuf/descriptor.ts | 5261 +++++++++++++++ .../cosmos.base.tendermint.v1beta1/index.ts | 6 + .../cosmos.base.tendermint.v1beta1/module.ts | 66 + .../registry.ts | 7 + .../cosmos.base.tendermint.v1beta1/rest.ts | 998 +++ .../cosmos.base.tendermint.v1beta1/types.ts | 11 + .../cosmos/base/query/v1beta1/pagination.ts | 327 + .../cosmos/base/tendermint/v1beta1/query.ts | 1584 +++++ .../types/gogoproto/gogo.ts | 2 + .../types/google/api/annotations.ts | 2 + .../types/google/api/http.ts | 705 ++ .../types/google/protobuf/any.ts | 240 + .../types/google/protobuf/descriptor.ts | 5261 +++++++++++++++ .../types/google/protobuf/timestamp.ts | 219 + .../types/tendermint/crypto/keys.ts | 130 + .../types/tendermint/crypto/proof.ts | 529 ++ .../types/tendermint/p2p/types.ts | 549 ++ .../types/tendermint/types/block.ts | 138 + .../types/tendermint/types/evidence.ts | 602 ++ .../types/tendermint/types/types.ts | 1912 ++++++ .../types/tendermint/types/validator.ts | 382 ++ .../types/tendermint/version/types.ts | 202 + ts-client/cosmos.crisis.v1beta1/index.ts | 6 + ts-client/cosmos.crisis.v1beta1/module.ts | 99 + ts-client/cosmos.crisis.v1beta1/registry.ts | 9 + ts-client/cosmos.crisis.v1beta1/rest.ts | 223 + ts-client/cosmos.crisis.v1beta1/types.ts | 5 + .../types/cosmos/base/v1beta1/coin.ts | 301 + .../types/cosmos/crisis/v1beta1/genesis.ts | 83 + .../types/cosmos/crisis/v1beta1/tx.ts | 217 + .../types/gogoproto/gogo.ts | 2 + .../types/google/protobuf/descriptor.ts | 5261 +++++++++++++++ .../cosmos.distribution.v1beta1/index.ts | 6 + .../cosmos.distribution.v1beta1/module.ts | 198 + .../cosmos.distribution.v1beta1/registry.ts | 15 + ts-client/cosmos.distribution.v1beta1/rest.ts | 613 ++ .../cosmos.distribution.v1beta1/types.ts | 43 + .../cosmos/base/query/v1beta1/pagination.ts | 327 + .../types/cosmos/base/v1beta1/coin.ts | 301 + .../distribution/v1beta1/distribution.ts | 1343 ++++ .../cosmos/distribution/v1beta1/genesis.ts | 1341 ++++ .../cosmos/distribution/v1beta1/query.ts | 1837 ++++++ .../types/cosmos/distribution/v1beta1/tx.ts | 728 +++ .../types/gogoproto/gogo.ts | 2 + .../types/google/api/annotations.ts | 2 + .../types/google/api/http.ts | 705 ++ .../types/google/protobuf/descriptor.ts | 5261 +++++++++++++++ ts-client/cosmos.evidence.v1beta1/index.ts | 6 + ts-client/cosmos.evidence.v1beta1/module.ts | 99 + ts-client/cosmos.evidence.v1beta1/registry.ts | 9 + ts-client/cosmos.evidence.v1beta1/rest.ts | 467 ++ ts-client/cosmos.evidence.v1beta1/types.ts | 7 + .../cosmos/base/query/v1beta1/pagination.ts | 327 + .../types/cosmos/evidence/v1beta1/evidence.ts | 192 + .../types/cosmos/evidence/v1beta1/genesis.ts | 86 + .../types/cosmos/evidence/v1beta1/query.ts | 429 ++ .../types/cosmos/evidence/v1beta1/tx.ts | 248 + .../types/cosmos_proto/cosmos.ts | 2 + .../types/gogoproto/gogo.ts | 2 + .../types/google/api/annotations.ts | 2 + .../types/google/api/http.ts | 705 ++ .../types/google/protobuf/any.ts | 240 + .../types/google/protobuf/descriptor.ts | 5261 +++++++++++++++ .../types/google/protobuf/timestamp.ts | 219 + ts-client/cosmos.feegrant.v1beta1/index.ts | 6 + ts-client/cosmos.feegrant.v1beta1/module.ts | 132 + ts-client/cosmos.feegrant.v1beta1/registry.ts | 11 + ts-client/cosmos.feegrant.v1beta1/rest.ts | 516 ++ ts-client/cosmos.feegrant.v1beta1/types.ts | 13 + .../cosmos/base/query/v1beta1/pagination.ts | 327 + .../types/cosmos/base/v1beta1/coin.ts | 301 + .../types/cosmos/feegrant/v1beta1/feegrant.ts | 538 ++ .../types/cosmos/feegrant/v1beta1/genesis.ts | 87 + .../types/cosmos/feegrant/v1beta1/query.ts | 643 ++ .../types/cosmos/feegrant/v1beta1/tx.ts | 376 ++ .../types/cosmos_proto/cosmos.ts | 2 + .../types/gogoproto/gogo.ts | 2 + .../types/google/api/annotations.ts | 2 + .../types/google/api/http.ts | 705 ++ .../types/google/protobuf/any.ts | 240 + .../types/google/protobuf/descriptor.ts | 5261 +++++++++++++++ .../types/google/protobuf/duration.ts | 188 + .../types/google/protobuf/timestamp.ts | 219 + ts-client/cosmos.gov.v1beta1/index.ts | 6 + ts-client/cosmos.gov.v1beta1/module.ts | 198 + ts-client/cosmos.gov.v1beta1/registry.ts | 15 + ts-client/cosmos.gov.v1beta1/rest.ts | 950 +++ ts-client/cosmos.gov.v1beta1/types.ts | 23 + .../cosmos/base/query/v1beta1/pagination.ts | 327 + .../types/cosmos/base/v1beta1/coin.ts | 301 + .../types/cosmos/gov/v1beta1/genesis.ts | 271 + .../types/cosmos/gov/v1beta1/gov.ts | 1303 ++++ .../types/cosmos/gov/v1beta1/query.ts | 1532 +++++ .../types/cosmos/gov/v1beta1/tx.ts | 745 +++ .../types/cosmos_proto/cosmos.ts | 2 + .../types/gogoproto/gogo.ts | 2 + .../types/google/api/annotations.ts | 2 + .../types/google/api/http.ts | 705 ++ .../types/google/protobuf/any.ts | 240 + .../types/google/protobuf/descriptor.ts | 5261 +++++++++++++++ .../types/google/protobuf/duration.ts | 188 + .../types/google/protobuf/timestamp.ts | 219 + ts-client/cosmos.mint.v1beta1/index.ts | 6 + ts-client/cosmos.mint.v1beta1/module.ts | 66 + ts-client/cosmos.mint.v1beta1/registry.ts | 7 + ts-client/cosmos.mint.v1beta1/rest.ts | 312 + ts-client/cosmos.mint.v1beta1/types.ts | 9 + .../types/cosmos/mint/v1beta1/genesis.ts | 98 + .../types/cosmos/mint/v1beta1/mint.ts | 298 + .../types/cosmos/mint/v1beta1/query.ts | 473 ++ .../types/gogoproto/gogo.ts | 2 + .../types/google/api/annotations.ts | 2 + .../types/google/api/http.ts | 705 ++ .../types/google/protobuf/descriptor.ts | 5261 +++++++++++++++ ts-client/cosmos.params.v1beta1/index.ts | 6 + ts-client/cosmos.params.v1beta1/module.ts | 66 + ts-client/cosmos.params.v1beta1/registry.ts | 7 + ts-client/cosmos.params.v1beta1/rest.ts | 254 + ts-client/cosmos.params.v1beta1/types.ts | 9 + .../types/cosmos/params/v1beta1/params.ts | 231 + .../types/cosmos/params/v1beta1/query.ts | 199 + .../types/gogoproto/gogo.ts | 2 + .../types/google/api/annotations.ts | 2 + .../types/google/api/http.ts | 705 ++ .../types/google/protobuf/descriptor.ts | 5261 +++++++++++++++ ts-client/cosmos.slashing.v1beta1/index.ts | 6 + ts-client/cosmos.slashing.v1beta1/module.ts | 99 + ts-client/cosmos.slashing.v1beta1/registry.ts | 9 + ts-client/cosmos.slashing.v1beta1/rest.ts | 425 ++ ts-client/cosmos.slashing.v1beta1/types.ts | 15 + .../cosmos/base/query/v1beta1/pagination.ts | 327 + .../types/cosmos/slashing/v1beta1/genesis.ts | 448 ++ .../types/cosmos/slashing/v1beta1/query.ts | 554 ++ .../types/cosmos/slashing/v1beta1/slashing.ts | 469 ++ .../types/cosmos/slashing/v1beta1/tx.ts | 151 + .../types/gogoproto/gogo.ts | 2 + .../types/google/api/annotations.ts | 2 + .../types/google/api/http.ts | 705 ++ .../types/google/protobuf/descriptor.ts | 5261 +++++++++++++++ .../types/google/protobuf/duration.ts | 188 + .../types/google/protobuf/timestamp.ts | 219 + ts-client/cosmos.staking.v1beta1/index.ts | 6 + ts-client/cosmos.staking.v1beta1/module.ts | 231 + ts-client/cosmos.staking.v1beta1/registry.ts | 17 + ts-client/cosmos.staking.v1beta1/rest.ts | 1268 ++++ ts-client/cosmos.staking.v1beta1/types.ts | 51 + .../cosmos/base/query/v1beta1/pagination.ts | 327 + .../types/cosmos/base/v1beta1/coin.ts | 301 + .../types/cosmos/staking/v1beta1/authz.ts | 321 + .../types/cosmos/staking/v1beta1/genesis.ts | 417 ++ .../types/cosmos/staking/v1beta1/query.ts | 2939 +++++++++ .../types/cosmos/staking/v1beta1/staking.ts | 2561 ++++++++ .../types/cosmos/staking/v1beta1/tx.ts | 1187 ++++ .../types/cosmos_proto/cosmos.ts | 2 + .../types/gogoproto/gogo.ts | 2 + .../types/google/api/annotations.ts | 2 + .../types/google/api/http.ts | 705 ++ .../types/google/protobuf/any.ts | 240 + .../types/google/protobuf/descriptor.ts | 5261 +++++++++++++++ .../types/google/protobuf/duration.ts | 188 + .../types/google/protobuf/timestamp.ts | 219 + .../types/tendermint/crypto/keys.ts | 130 + .../types/tendermint/crypto/proof.ts | 529 ++ .../types/tendermint/types/types.ts | 1912 ++++++ .../types/tendermint/types/validator.ts | 382 ++ .../types/tendermint/version/types.ts | 202 + ts-client/cosmos.tx.v1beta1/index.ts | 6 + ts-client/cosmos.tx.v1beta1/module.ts | 66 + ts-client/cosmos.tx.v1beta1/registry.ts | 7 + ts-client/cosmos.tx.v1beta1/rest.ts | 1295 ++++ ts-client/cosmos.tx.v1beta1/types.ts | 25 + .../types/cosmos/base/abci/v1beta1/abci.ts | 1279 ++++ .../cosmos/base/query/v1beta1/pagination.ts | 327 + .../types/cosmos/base/v1beta1/coin.ts | 301 + .../crypto/multisig/v1beta1/multisig.ts | 212 + .../cosmos/tx/signing/v1beta1/signing.ts | 660 ++ .../types/cosmos/tx/v1beta1/service.ts | 1230 ++++ .../types/cosmos/tx/v1beta1/tx.ts | 1262 ++++ .../cosmos.tx.v1beta1/types/gogoproto/gogo.ts | 2 + .../types/google/api/annotations.ts | 2 + .../types/google/api/http.ts | 705 ++ .../types/google/protobuf/any.ts | 240 + .../types/google/protobuf/descriptor.ts | 5261 +++++++++++++++ .../types/google/protobuf/duration.ts | 188 + .../types/google/protobuf/timestamp.ts | 219 + .../types/tendermint/abci/types.ts | 5687 +++++++++++++++++ .../types/tendermint/crypto/keys.ts | 130 + .../types/tendermint/crypto/proof.ts | 529 ++ .../types/tendermint/types/block.ts | 138 + .../types/tendermint/types/evidence.ts | 602 ++ .../types/tendermint/types/params.ts | 625 ++ .../types/tendermint/types/types.ts | 1912 ++++++ .../types/tendermint/types/validator.ts | 382 ++ .../types/tendermint/version/types.ts | 202 + ts-client/cosmos.upgrade.v1beta1/index.ts | 6 + ts-client/cosmos.upgrade.v1beta1/module.ts | 66 + ts-client/cosmos.upgrade.v1beta1/registry.ts | 7 + ts-client/cosmos.upgrade.v1beta1/rest.ts | 493 ++ ts-client/cosmos.upgrade.v1beta1/types.ts | 13 + .../types/cosmos/upgrade/v1beta1/query.ts | 798 +++ .../types/cosmos/upgrade/v1beta1/upgrade.ts | 539 ++ .../types/gogoproto/gogo.ts | 2 + .../types/google/api/annotations.ts | 2 + .../types/google/api/http.ts | 705 ++ .../types/google/protobuf/any.ts | 240 + .../types/google/protobuf/descriptor.ts | 5261 +++++++++++++++ .../types/google/protobuf/timestamp.ts | 219 + ts-client/cosmos.vesting.v1beta1/index.ts | 6 + ts-client/cosmos.vesting.v1beta1/module.ts | 99 + ts-client/cosmos.vesting.v1beta1/registry.ts | 9 + ts-client/cosmos.vesting.v1beta1/rest.ts | 347 + ts-client/cosmos.vesting.v1beta1/types.ts | 17 + .../types/cosmos/auth/v1beta1/auth.ts | 436 ++ .../types/cosmos/base/v1beta1/coin.ts | 301 + .../types/cosmos/vesting/v1beta1/tx.ts | 292 + .../types/cosmos/vesting/v1beta1/vesting.ts | 732 +++ .../types/cosmos_proto/cosmos.ts | 2 + .../types/gogoproto/gogo.ts | 2 + .../types/google/protobuf/any.ts | 240 + .../types/google/protobuf/descriptor.ts | 5261 +++++++++++++++ ts-client/env.ts | 7 + ts-client/helpers.ts | 32 + .../index.ts | 6 + .../module.ts | 66 + .../registry.ts | 7 + .../rest.ts | 254 + .../types.ts | 7 + .../types/gogoproto/gogo.ts | 2 + .../types/google/api/annotations.ts | 2 + .../types/google/api/http.ts | 705 ++ .../types/google/protobuf/descriptor.ts | 5261 +++++++++++++++ .../interchain_accounts/host/v1/host.ts | 106 + .../interchain_accounts/host/v1/query.ts | 152 + .../ibc.applications.transfer.v1/index.ts | 6 + .../ibc.applications.transfer.v1/module.ts | 99 + .../ibc.applications.transfer.v1/registry.ts | 9 + .../ibc.applications.transfer.v1/rest.ts | 599 ++ .../ibc.applications.transfer.v1/types.ts | 9 + .../cosmos/base/query/v1beta1/pagination.ts | 327 + .../types/cosmos/base/v1beta1/coin.ts | 301 + .../types/cosmos/upgrade/v1beta1/upgrade.ts | 539 ++ .../types/cosmos_proto/cosmos.ts | 2 + .../types/gogoproto/gogo.ts | 2 + .../types/google/api/annotations.ts | 2 + .../types/google/api/http.ts | 705 ++ .../types/google/protobuf/any.ts | 240 + .../types/google/protobuf/descriptor.ts | 5261 +++++++++++++++ .../types/google/protobuf/timestamp.ts | 219 + .../ibc/applications/transfer/v1/genesis.ts | 125 + .../ibc/applications/transfer/v1/query.ts | 870 +++ .../ibc/applications/transfer/v1/transfer.ts | 194 + .../types/ibc/applications/transfer/v1/tx.ts | 357 ++ .../types/ibc/core/client/v1/client.ts | 786 +++ ts-client/ibc.core.channel.v1/index.ts | 6 + ts-client/ibc.core.channel.v1/module.ts | 66 + ts-client/ibc.core.channel.v1/registry.ts | 7 + ts-client/ibc.core.channel.v1/rest.ts | 1399 ++++ ts-client/ibc.core.channel.v1/types.ts | 21 + .../cosmos/base/query/v1beta1/pagination.ts | 327 + .../types/cosmos/upgrade/v1beta1/upgrade.ts | 539 ++ .../types/cosmos_proto/cosmos.ts | 2 + .../types/gogoproto/gogo.ts | 2 + .../types/google/api/annotations.ts | 2 + .../types/google/api/http.ts | 705 ++ .../types/google/protobuf/any.ts | 240 + .../types/google/protobuf/descriptor.ts | 5261 +++++++++++++++ .../types/google/protobuf/timestamp.ts | 219 + .../types/ibc/core/channel/v1/channel.ts | 1163 ++++ .../types/ibc/core/channel/v1/genesis.ts | 414 ++ .../types/ibc/core/channel/v1/query.ts | 3526 ++++++++++ .../types/ibc/core/channel/v1/tx.ts | 2473 +++++++ .../types/ibc/core/client/v1/client.ts | 786 +++ ts-client/ibc.core.client.v1/index.ts | 6 + ts-client/ibc.core.client.v1/module.ts | 66 + ts-client/ibc.core.client.v1/registry.ts | 7 + ts-client/ibc.core.client.v1/rest.ts | 1278 ++++ ts-client/ibc.core.client.v1/types.ts | 23 + .../cosmos/base/query/v1beta1/pagination.ts | 327 + .../types/cosmos/upgrade/v1beta1/upgrade.ts | 539 ++ .../types/cosmos_proto/cosmos.ts | 2 + .../types/gogoproto/gogo.ts | 2 + .../types/google/api/annotations.ts | 2 + .../types/google/api/http.ts | 705 ++ .../types/google/protobuf/any.ts | 240 + .../types/google/protobuf/descriptor.ts | 5261 +++++++++++++++ .../types/google/protobuf/timestamp.ts | 219 + .../types/ibc/core/client/v1/client.ts | 786 +++ .../types/ibc/core/client/v1/genesis.ts | 475 ++ .../types/ibc/core/client/v1/query.ts | 1954 ++++++ .../types/ibc/core/client/v1/tx.ts | 847 +++ ts-client/ibc.core.connection.v1/index.ts | 6 + ts-client/ibc.core.connection.v1/module.ts | 66 + ts-client/ibc.core.connection.v1/registry.ts | 7 + ts-client/ibc.core.connection.v1/rest.ts | 930 +++ ts-client/ibc.core.connection.v1/types.ts | 19 + .../cosmos/base/query/v1beta1/pagination.ts | 327 + .../types/cosmos/upgrade/v1beta1/upgrade.ts | 539 ++ .../types/cosmos_proto/cosmos.ts | 2 + .../types/gogoproto/gogo.ts | 2 + .../types/google/api/annotations.ts | 2 + .../types/google/api/http.ts | 705 ++ .../types/google/protobuf/any.ts | 240 + .../types/google/protobuf/descriptor.ts | 5261 +++++++++++++++ .../types/google/protobuf/timestamp.ts | 219 + .../types/ibc/core/client/v1/client.ts | 786 +++ .../ibc/core/commitment/v1/commitment.ts | 324 + .../ibc/core/connection/v1/connection.ts | 873 +++ .../types/ibc/core/connection/v1/genesis.ts | 196 + .../types/ibc/core/connection/v1/query.ts | 1286 ++++ .../types/ibc/core/connection/v1/tx.ts | 1283 ++++ .../ibc.core.connection.v1/types/proofs.ts | 1871 ++++++ ts-client/index.ts | 75 + ts-client/modules.ts | 5 + ts-client/package.json | 28 + vue/package.json | 27 +- .../store/generated/bze.burner.v1/index.ts | 201 + .../store/generated/bze.cointrunk.v1/index.ts | 373 ++ .../store/generated/bze.epochs.v1/index.ts | 171 + vue/src/store/generated/bze.scavenge/index.ts | 309 + .../generated/bze.tokenfactory.v1/index.ts | 301 + .../store/generated/bze.tradebin.v1/index.ts | 467 ++ .../store/generated/bze.v1.rewards/index.ts | 498 ++ vue/src/store/generated/index.ts | 66 +- vue/src/store/generated/package.json | 19 +- x/rewards/genesis.go | 30 +- x/rewards/keeper/cleanup.go | 13 +- x/rewards/keeper/grpc_query_trading_reward.go | 4 +- x/rewards/keeper/hooks.go | 25 +- x/rewards/keeper/msg_server_staking_reward.go | 5 + x/rewards/keeper/msg_server_trading_reward.go | 4 +- .../keeper/msg_server_trading_reward_test.go | 2 +- x/rewards/keeper/trading_reward.go | 135 +- .../keeper/trading_reward_distribution.go | 59 + x/rewards/keeper/trading_reward_expiration.go | 97 + .../keeper/trading_reward_leaderboard.go | 5 + x/rewards/keeper/trading_reward_test.go | 10 +- x/rewards/module_simulation.go | 8 - x/rewards/types/errors.go | 2 +- x/rewards/types/genesis.go | 26 +- x/rewards/types/genesis.pb.go | 363 +- x/rewards/types/key_staking_reward.go | 2 +- .../types/key_staking_reward_participant.go | 2 +- x/rewards/types/key_trading_reward.go | 11 +- x/rewards/types/trading_reward.pb.go | 278 +- 531 files changed, 317146 insertions(+), 282 deletions(-) create mode 100755 ts-client/bze.burner.v1/index.ts create mode 100755 ts-client/bze.burner.v1/module.ts create mode 100755 ts-client/bze.burner.v1/registry.ts create mode 100644 ts-client/bze.burner.v1/rest.ts create mode 100755 ts-client/bze.burner.v1/types.ts create mode 100644 ts-client/bze.burner.v1/types/burner/burn_coins_proposal.ts create mode 100644 ts-client/bze.burner.v1/types/burner/burned_coins.ts create mode 100644 ts-client/bze.burner.v1/types/burner/events.ts create mode 100644 ts-client/bze.burner.v1/types/burner/genesis.ts create mode 100644 ts-client/bze.burner.v1/types/burner/params.ts create mode 100644 ts-client/bze.burner.v1/types/burner/query.ts create mode 100644 ts-client/bze.burner.v1/types/burner/tx.ts create mode 100644 ts-client/bze.burner.v1/types/cosmos/base/query/v1beta1/pagination.ts create mode 100644 ts-client/bze.burner.v1/types/gogoproto/gogo.ts create mode 100644 ts-client/bze.burner.v1/types/google/api/annotations.ts create mode 100644 ts-client/bze.burner.v1/types/google/api/http.ts create mode 100644 ts-client/bze.burner.v1/types/google/protobuf/descriptor.ts create mode 100755 ts-client/bze.cointrunk.v1/index.ts create mode 100755 ts-client/bze.cointrunk.v1/module.ts create mode 100755 ts-client/bze.cointrunk.v1/registry.ts create mode 100644 ts-client/bze.cointrunk.v1/rest.ts create mode 100755 ts-client/bze.cointrunk.v1/types.ts create mode 100644 ts-client/bze.cointrunk.v1/types/cointrunk/accepted_domain.ts create mode 100644 ts-client/bze.cointrunk.v1/types/cointrunk/accepted_domain_proposal.ts create mode 100644 ts-client/bze.cointrunk.v1/types/cointrunk/anon_articles_counter.ts create mode 100644 ts-client/bze.cointrunk.v1/types/cointrunk/article.ts create mode 100644 ts-client/bze.cointrunk.v1/types/cointrunk/events.ts create mode 100644 ts-client/bze.cointrunk.v1/types/cointrunk/genesis.ts create mode 100644 ts-client/bze.cointrunk.v1/types/cointrunk/params.ts create mode 100644 ts-client/bze.cointrunk.v1/types/cointrunk/publisher.ts create mode 100644 ts-client/bze.cointrunk.v1/types/cointrunk/publisher_proposal.ts create mode 100644 ts-client/bze.cointrunk.v1/types/cointrunk/query.ts create mode 100644 ts-client/bze.cointrunk.v1/types/cointrunk/tx.ts create mode 100644 ts-client/bze.cointrunk.v1/types/cosmos/base/query/v1beta1/pagination.ts create mode 100644 ts-client/bze.cointrunk.v1/types/cosmos/base/v1beta1/coin.ts create mode 100644 ts-client/bze.cointrunk.v1/types/gogoproto/gogo.ts create mode 100644 ts-client/bze.cointrunk.v1/types/google/api/annotations.ts create mode 100644 ts-client/bze.cointrunk.v1/types/google/api/http.ts create mode 100644 ts-client/bze.cointrunk.v1/types/google/protobuf/descriptor.ts create mode 100755 ts-client/bze.epochs.v1/index.ts create mode 100755 ts-client/bze.epochs.v1/module.ts create mode 100755 ts-client/bze.epochs.v1/registry.ts create mode 100644 ts-client/bze.epochs.v1/rest.ts create mode 100755 ts-client/bze.epochs.v1/types.ts create mode 100644 ts-client/bze.epochs.v1/types/epochs/events.ts create mode 100644 ts-client/bze.epochs.v1/types/epochs/genesis.ts create mode 100644 ts-client/bze.epochs.v1/types/epochs/query.ts create mode 100644 ts-client/bze.epochs.v1/types/gogoproto/gogo.ts create mode 100644 ts-client/bze.epochs.v1/types/google/api/annotations.ts create mode 100644 ts-client/bze.epochs.v1/types/google/api/http.ts create mode 100644 ts-client/bze.epochs.v1/types/google/protobuf/descriptor.ts create mode 100644 ts-client/bze.epochs.v1/types/google/protobuf/duration.ts create mode 100644 ts-client/bze.epochs.v1/types/google/protobuf/timestamp.ts create mode 100755 ts-client/bze.scavenge/index.ts create mode 100755 ts-client/bze.scavenge/module.ts create mode 100755 ts-client/bze.scavenge/registry.ts create mode 100644 ts-client/bze.scavenge/rest.ts create mode 100755 ts-client/bze.scavenge/types.ts create mode 100644 ts-client/bze.scavenge/types/cosmos/base/query/v1beta1/pagination.ts create mode 100644 ts-client/bze.scavenge/types/gogoproto/gogo.ts create mode 100644 ts-client/bze.scavenge/types/google/api/annotations.ts create mode 100644 ts-client/bze.scavenge/types/google/api/http.ts create mode 100644 ts-client/bze.scavenge/types/google/protobuf/descriptor.ts create mode 100644 ts-client/bze.scavenge/types/scavenge/commit.ts create mode 100644 ts-client/bze.scavenge/types/scavenge/genesis.ts create mode 100644 ts-client/bze.scavenge/types/scavenge/query.ts create mode 100644 ts-client/bze.scavenge/types/scavenge/scavenge.ts create mode 100644 ts-client/bze.scavenge/types/scavenge/tx.ts create mode 100755 ts-client/bze.tokenfactory.v1/index.ts create mode 100755 ts-client/bze.tokenfactory.v1/module.ts create mode 100755 ts-client/bze.tokenfactory.v1/registry.ts create mode 100644 ts-client/bze.tokenfactory.v1/rest.ts create mode 100755 ts-client/bze.tokenfactory.v1/types.ts create mode 100644 ts-client/bze.tokenfactory.v1/types/cosmos/bank/v1beta1/bank.ts create mode 100644 ts-client/bze.tokenfactory.v1/types/cosmos/base/query/v1beta1/pagination.ts create mode 100644 ts-client/bze.tokenfactory.v1/types/cosmos/base/v1beta1/coin.ts create mode 100644 ts-client/bze.tokenfactory.v1/types/cosmos_proto/cosmos.ts create mode 100644 ts-client/bze.tokenfactory.v1/types/gogoproto/gogo.ts create mode 100644 ts-client/bze.tokenfactory.v1/types/google/api/annotations.ts create mode 100644 ts-client/bze.tokenfactory.v1/types/google/api/http.ts create mode 100644 ts-client/bze.tokenfactory.v1/types/google/protobuf/descriptor.ts create mode 100644 ts-client/bze.tokenfactory.v1/types/tokenfactory/denom_authority.ts create mode 100644 ts-client/bze.tokenfactory.v1/types/tokenfactory/genesis.ts create mode 100644 ts-client/bze.tokenfactory.v1/types/tokenfactory/params.ts create mode 100644 ts-client/bze.tokenfactory.v1/types/tokenfactory/query.ts create mode 100644 ts-client/bze.tokenfactory.v1/types/tokenfactory/tx.ts create mode 100755 ts-client/bze.tradebin.v1/index.ts create mode 100755 ts-client/bze.tradebin.v1/module.ts create mode 100755 ts-client/bze.tradebin.v1/registry.ts create mode 100644 ts-client/bze.tradebin.v1/rest.ts create mode 100755 ts-client/bze.tradebin.v1/types.ts create mode 100644 ts-client/bze.tradebin.v1/types/cosmos/base/query/v1beta1/pagination.ts create mode 100644 ts-client/bze.tradebin.v1/types/gogoproto/gogo.ts create mode 100644 ts-client/bze.tradebin.v1/types/google/api/annotations.ts create mode 100644 ts-client/bze.tradebin.v1/types/google/api/http.ts create mode 100644 ts-client/bze.tradebin.v1/types/google/protobuf/descriptor.ts create mode 100644 ts-client/bze.tradebin.v1/types/tradebin/events.ts create mode 100644 ts-client/bze.tradebin.v1/types/tradebin/genesis.ts create mode 100644 ts-client/bze.tradebin.v1/types/tradebin/market.ts create mode 100644 ts-client/bze.tradebin.v1/types/tradebin/order.ts create mode 100644 ts-client/bze.tradebin.v1/types/tradebin/params.ts create mode 100644 ts-client/bze.tradebin.v1/types/tradebin/query.ts create mode 100644 ts-client/bze.tradebin.v1/types/tradebin/queue_message.ts create mode 100644 ts-client/bze.tradebin.v1/types/tradebin/tx.ts create mode 100755 ts-client/bze.v1.rewards/index.ts create mode 100755 ts-client/bze.v1.rewards/module.ts create mode 100755 ts-client/bze.v1.rewards/registry.ts create mode 100644 ts-client/bze.v1.rewards/rest.ts create mode 100755 ts-client/bze.v1.rewards/types.ts create mode 100644 ts-client/bze.v1.rewards/types/cosmos/base/query/v1beta1/pagination.ts create mode 100644 ts-client/bze.v1.rewards/types/gogoproto/gogo.ts create mode 100644 ts-client/bze.v1.rewards/types/google/api/annotations.ts create mode 100644 ts-client/bze.v1.rewards/types/google/api/http.ts create mode 100644 ts-client/bze.v1.rewards/types/google/protobuf/descriptor.ts create mode 100644 ts-client/bze.v1.rewards/types/rewards/events.ts create mode 100644 ts-client/bze.v1.rewards/types/rewards/genesis.ts create mode 100644 ts-client/bze.v1.rewards/types/rewards/params.ts create mode 100644 ts-client/bze.v1.rewards/types/rewards/query.ts create mode 100644 ts-client/bze.v1.rewards/types/rewards/staking_reward.ts create mode 100644 ts-client/bze.v1.rewards/types/rewards/staking_reward_participant.ts create mode 100644 ts-client/bze.v1.rewards/types/rewards/trading_reward.ts create mode 100644 ts-client/bze.v1.rewards/types/rewards/tx.ts create mode 100755 ts-client/client.ts create mode 100755 ts-client/cosmos.auth.v1beta1/index.ts create mode 100755 ts-client/cosmos.auth.v1beta1/module.ts create mode 100755 ts-client/cosmos.auth.v1beta1/registry.ts create mode 100644 ts-client/cosmos.auth.v1beta1/rest.ts create mode 100755 ts-client/cosmos.auth.v1beta1/types.ts create mode 100644 ts-client/cosmos.auth.v1beta1/types/cosmos/auth/v1beta1/auth.ts create mode 100644 ts-client/cosmos.auth.v1beta1/types/cosmos/auth/v1beta1/genesis.ts create mode 100644 ts-client/cosmos.auth.v1beta1/types/cosmos/auth/v1beta1/query.ts create mode 100644 ts-client/cosmos.auth.v1beta1/types/cosmos/base/query/v1beta1/pagination.ts create mode 100644 ts-client/cosmos.auth.v1beta1/types/cosmos_proto/cosmos.ts create mode 100644 ts-client/cosmos.auth.v1beta1/types/gogoproto/gogo.ts create mode 100644 ts-client/cosmos.auth.v1beta1/types/google/api/annotations.ts create mode 100644 ts-client/cosmos.auth.v1beta1/types/google/api/http.ts create mode 100644 ts-client/cosmos.auth.v1beta1/types/google/protobuf/any.ts create mode 100644 ts-client/cosmos.auth.v1beta1/types/google/protobuf/descriptor.ts create mode 100755 ts-client/cosmos.authz.v1beta1/index.ts create mode 100755 ts-client/cosmos.authz.v1beta1/module.ts create mode 100755 ts-client/cosmos.authz.v1beta1/registry.ts create mode 100644 ts-client/cosmos.authz.v1beta1/rest.ts create mode 100755 ts-client/cosmos.authz.v1beta1/types.ts create mode 100644 ts-client/cosmos.authz.v1beta1/types/cosmos/authz/v1beta1/authz.ts create mode 100644 ts-client/cosmos.authz.v1beta1/types/cosmos/authz/v1beta1/event.ts create mode 100644 ts-client/cosmos.authz.v1beta1/types/cosmos/authz/v1beta1/genesis.ts create mode 100644 ts-client/cosmos.authz.v1beta1/types/cosmos/authz/v1beta1/query.ts create mode 100644 ts-client/cosmos.authz.v1beta1/types/cosmos/authz/v1beta1/tx.ts create mode 100644 ts-client/cosmos.authz.v1beta1/types/cosmos/base/abci/v1beta1/abci.ts create mode 100644 ts-client/cosmos.authz.v1beta1/types/cosmos/base/query/v1beta1/pagination.ts create mode 100644 ts-client/cosmos.authz.v1beta1/types/cosmos_proto/cosmos.ts create mode 100644 ts-client/cosmos.authz.v1beta1/types/gogoproto/gogo.ts create mode 100644 ts-client/cosmos.authz.v1beta1/types/google/api/annotations.ts create mode 100644 ts-client/cosmos.authz.v1beta1/types/google/api/http.ts create mode 100644 ts-client/cosmos.authz.v1beta1/types/google/protobuf/any.ts create mode 100644 ts-client/cosmos.authz.v1beta1/types/google/protobuf/descriptor.ts create mode 100644 ts-client/cosmos.authz.v1beta1/types/google/protobuf/duration.ts create mode 100644 ts-client/cosmos.authz.v1beta1/types/google/protobuf/timestamp.ts create mode 100644 ts-client/cosmos.authz.v1beta1/types/tendermint/abci/types.ts create mode 100644 ts-client/cosmos.authz.v1beta1/types/tendermint/crypto/keys.ts create mode 100644 ts-client/cosmos.authz.v1beta1/types/tendermint/crypto/proof.ts create mode 100644 ts-client/cosmos.authz.v1beta1/types/tendermint/types/params.ts create mode 100644 ts-client/cosmos.authz.v1beta1/types/tendermint/types/types.ts create mode 100644 ts-client/cosmos.authz.v1beta1/types/tendermint/types/validator.ts create mode 100644 ts-client/cosmos.authz.v1beta1/types/tendermint/version/types.ts create mode 100755 ts-client/cosmos.bank.v1beta1/index.ts create mode 100755 ts-client/cosmos.bank.v1beta1/module.ts create mode 100755 ts-client/cosmos.bank.v1beta1/registry.ts create mode 100644 ts-client/cosmos.bank.v1beta1/rest.ts create mode 100755 ts-client/cosmos.bank.v1beta1/types.ts create mode 100644 ts-client/cosmos.bank.v1beta1/types/cosmos/bank/v1beta1/authz.ts create mode 100644 ts-client/cosmos.bank.v1beta1/types/cosmos/bank/v1beta1/bank.ts create mode 100644 ts-client/cosmos.bank.v1beta1/types/cosmos/bank/v1beta1/genesis.ts create mode 100644 ts-client/cosmos.bank.v1beta1/types/cosmos/bank/v1beta1/query.ts create mode 100644 ts-client/cosmos.bank.v1beta1/types/cosmos/bank/v1beta1/tx.ts create mode 100644 ts-client/cosmos.bank.v1beta1/types/cosmos/base/query/v1beta1/pagination.ts create mode 100644 ts-client/cosmos.bank.v1beta1/types/cosmos/base/v1beta1/coin.ts create mode 100644 ts-client/cosmos.bank.v1beta1/types/cosmos_proto/cosmos.ts create mode 100644 ts-client/cosmos.bank.v1beta1/types/gogoproto/gogo.ts create mode 100644 ts-client/cosmos.bank.v1beta1/types/google/api/annotations.ts create mode 100644 ts-client/cosmos.bank.v1beta1/types/google/api/http.ts create mode 100644 ts-client/cosmos.bank.v1beta1/types/google/protobuf/descriptor.ts create mode 100755 ts-client/cosmos.base.tendermint.v1beta1/index.ts create mode 100755 ts-client/cosmos.base.tendermint.v1beta1/module.ts create mode 100755 ts-client/cosmos.base.tendermint.v1beta1/registry.ts create mode 100644 ts-client/cosmos.base.tendermint.v1beta1/rest.ts create mode 100755 ts-client/cosmos.base.tendermint.v1beta1/types.ts create mode 100644 ts-client/cosmos.base.tendermint.v1beta1/types/cosmos/base/query/v1beta1/pagination.ts create mode 100644 ts-client/cosmos.base.tendermint.v1beta1/types/cosmos/base/tendermint/v1beta1/query.ts create mode 100644 ts-client/cosmos.base.tendermint.v1beta1/types/gogoproto/gogo.ts create mode 100644 ts-client/cosmos.base.tendermint.v1beta1/types/google/api/annotations.ts create mode 100644 ts-client/cosmos.base.tendermint.v1beta1/types/google/api/http.ts create mode 100644 ts-client/cosmos.base.tendermint.v1beta1/types/google/protobuf/any.ts create mode 100644 ts-client/cosmos.base.tendermint.v1beta1/types/google/protobuf/descriptor.ts create mode 100644 ts-client/cosmos.base.tendermint.v1beta1/types/google/protobuf/timestamp.ts create mode 100644 ts-client/cosmos.base.tendermint.v1beta1/types/tendermint/crypto/keys.ts create mode 100644 ts-client/cosmos.base.tendermint.v1beta1/types/tendermint/crypto/proof.ts create mode 100644 ts-client/cosmos.base.tendermint.v1beta1/types/tendermint/p2p/types.ts create mode 100644 ts-client/cosmos.base.tendermint.v1beta1/types/tendermint/types/block.ts create mode 100644 ts-client/cosmos.base.tendermint.v1beta1/types/tendermint/types/evidence.ts create mode 100644 ts-client/cosmos.base.tendermint.v1beta1/types/tendermint/types/types.ts create mode 100644 ts-client/cosmos.base.tendermint.v1beta1/types/tendermint/types/validator.ts create mode 100644 ts-client/cosmos.base.tendermint.v1beta1/types/tendermint/version/types.ts create mode 100755 ts-client/cosmos.crisis.v1beta1/index.ts create mode 100755 ts-client/cosmos.crisis.v1beta1/module.ts create mode 100755 ts-client/cosmos.crisis.v1beta1/registry.ts create mode 100644 ts-client/cosmos.crisis.v1beta1/rest.ts create mode 100755 ts-client/cosmos.crisis.v1beta1/types.ts create mode 100644 ts-client/cosmos.crisis.v1beta1/types/cosmos/base/v1beta1/coin.ts create mode 100644 ts-client/cosmos.crisis.v1beta1/types/cosmos/crisis/v1beta1/genesis.ts create mode 100644 ts-client/cosmos.crisis.v1beta1/types/cosmos/crisis/v1beta1/tx.ts create mode 100644 ts-client/cosmos.crisis.v1beta1/types/gogoproto/gogo.ts create mode 100644 ts-client/cosmos.crisis.v1beta1/types/google/protobuf/descriptor.ts create mode 100755 ts-client/cosmos.distribution.v1beta1/index.ts create mode 100755 ts-client/cosmos.distribution.v1beta1/module.ts create mode 100755 ts-client/cosmos.distribution.v1beta1/registry.ts create mode 100644 ts-client/cosmos.distribution.v1beta1/rest.ts create mode 100755 ts-client/cosmos.distribution.v1beta1/types.ts create mode 100644 ts-client/cosmos.distribution.v1beta1/types/cosmos/base/query/v1beta1/pagination.ts create mode 100644 ts-client/cosmos.distribution.v1beta1/types/cosmos/base/v1beta1/coin.ts create mode 100644 ts-client/cosmos.distribution.v1beta1/types/cosmos/distribution/v1beta1/distribution.ts create mode 100644 ts-client/cosmos.distribution.v1beta1/types/cosmos/distribution/v1beta1/genesis.ts create mode 100644 ts-client/cosmos.distribution.v1beta1/types/cosmos/distribution/v1beta1/query.ts create mode 100644 ts-client/cosmos.distribution.v1beta1/types/cosmos/distribution/v1beta1/tx.ts create mode 100644 ts-client/cosmos.distribution.v1beta1/types/gogoproto/gogo.ts create mode 100644 ts-client/cosmos.distribution.v1beta1/types/google/api/annotations.ts create mode 100644 ts-client/cosmos.distribution.v1beta1/types/google/api/http.ts create mode 100644 ts-client/cosmos.distribution.v1beta1/types/google/protobuf/descriptor.ts create mode 100755 ts-client/cosmos.evidence.v1beta1/index.ts create mode 100755 ts-client/cosmos.evidence.v1beta1/module.ts create mode 100755 ts-client/cosmos.evidence.v1beta1/registry.ts create mode 100644 ts-client/cosmos.evidence.v1beta1/rest.ts create mode 100755 ts-client/cosmos.evidence.v1beta1/types.ts create mode 100644 ts-client/cosmos.evidence.v1beta1/types/cosmos/base/query/v1beta1/pagination.ts create mode 100644 ts-client/cosmos.evidence.v1beta1/types/cosmos/evidence/v1beta1/evidence.ts create mode 100644 ts-client/cosmos.evidence.v1beta1/types/cosmos/evidence/v1beta1/genesis.ts create mode 100644 ts-client/cosmos.evidence.v1beta1/types/cosmos/evidence/v1beta1/query.ts create mode 100644 ts-client/cosmos.evidence.v1beta1/types/cosmos/evidence/v1beta1/tx.ts create mode 100644 ts-client/cosmos.evidence.v1beta1/types/cosmos_proto/cosmos.ts create mode 100644 ts-client/cosmos.evidence.v1beta1/types/gogoproto/gogo.ts create mode 100644 ts-client/cosmos.evidence.v1beta1/types/google/api/annotations.ts create mode 100644 ts-client/cosmos.evidence.v1beta1/types/google/api/http.ts create mode 100644 ts-client/cosmos.evidence.v1beta1/types/google/protobuf/any.ts create mode 100644 ts-client/cosmos.evidence.v1beta1/types/google/protobuf/descriptor.ts create mode 100644 ts-client/cosmos.evidence.v1beta1/types/google/protobuf/timestamp.ts create mode 100755 ts-client/cosmos.feegrant.v1beta1/index.ts create mode 100755 ts-client/cosmos.feegrant.v1beta1/module.ts create mode 100755 ts-client/cosmos.feegrant.v1beta1/registry.ts create mode 100644 ts-client/cosmos.feegrant.v1beta1/rest.ts create mode 100755 ts-client/cosmos.feegrant.v1beta1/types.ts create mode 100644 ts-client/cosmos.feegrant.v1beta1/types/cosmos/base/query/v1beta1/pagination.ts create mode 100644 ts-client/cosmos.feegrant.v1beta1/types/cosmos/base/v1beta1/coin.ts create mode 100644 ts-client/cosmos.feegrant.v1beta1/types/cosmos/feegrant/v1beta1/feegrant.ts create mode 100644 ts-client/cosmos.feegrant.v1beta1/types/cosmos/feegrant/v1beta1/genesis.ts create mode 100644 ts-client/cosmos.feegrant.v1beta1/types/cosmos/feegrant/v1beta1/query.ts create mode 100644 ts-client/cosmos.feegrant.v1beta1/types/cosmos/feegrant/v1beta1/tx.ts create mode 100644 ts-client/cosmos.feegrant.v1beta1/types/cosmos_proto/cosmos.ts create mode 100644 ts-client/cosmos.feegrant.v1beta1/types/gogoproto/gogo.ts create mode 100644 ts-client/cosmos.feegrant.v1beta1/types/google/api/annotations.ts create mode 100644 ts-client/cosmos.feegrant.v1beta1/types/google/api/http.ts create mode 100644 ts-client/cosmos.feegrant.v1beta1/types/google/protobuf/any.ts create mode 100644 ts-client/cosmos.feegrant.v1beta1/types/google/protobuf/descriptor.ts create mode 100644 ts-client/cosmos.feegrant.v1beta1/types/google/protobuf/duration.ts create mode 100644 ts-client/cosmos.feegrant.v1beta1/types/google/protobuf/timestamp.ts create mode 100755 ts-client/cosmos.gov.v1beta1/index.ts create mode 100755 ts-client/cosmos.gov.v1beta1/module.ts create mode 100755 ts-client/cosmos.gov.v1beta1/registry.ts create mode 100644 ts-client/cosmos.gov.v1beta1/rest.ts create mode 100755 ts-client/cosmos.gov.v1beta1/types.ts create mode 100644 ts-client/cosmos.gov.v1beta1/types/cosmos/base/query/v1beta1/pagination.ts create mode 100644 ts-client/cosmos.gov.v1beta1/types/cosmos/base/v1beta1/coin.ts create mode 100644 ts-client/cosmos.gov.v1beta1/types/cosmos/gov/v1beta1/genesis.ts create mode 100644 ts-client/cosmos.gov.v1beta1/types/cosmos/gov/v1beta1/gov.ts create mode 100644 ts-client/cosmos.gov.v1beta1/types/cosmos/gov/v1beta1/query.ts create mode 100644 ts-client/cosmos.gov.v1beta1/types/cosmos/gov/v1beta1/tx.ts create mode 100644 ts-client/cosmos.gov.v1beta1/types/cosmos_proto/cosmos.ts create mode 100644 ts-client/cosmos.gov.v1beta1/types/gogoproto/gogo.ts create mode 100644 ts-client/cosmos.gov.v1beta1/types/google/api/annotations.ts create mode 100644 ts-client/cosmos.gov.v1beta1/types/google/api/http.ts create mode 100644 ts-client/cosmos.gov.v1beta1/types/google/protobuf/any.ts create mode 100644 ts-client/cosmos.gov.v1beta1/types/google/protobuf/descriptor.ts create mode 100644 ts-client/cosmos.gov.v1beta1/types/google/protobuf/duration.ts create mode 100644 ts-client/cosmos.gov.v1beta1/types/google/protobuf/timestamp.ts create mode 100755 ts-client/cosmos.mint.v1beta1/index.ts create mode 100755 ts-client/cosmos.mint.v1beta1/module.ts create mode 100755 ts-client/cosmos.mint.v1beta1/registry.ts create mode 100644 ts-client/cosmos.mint.v1beta1/rest.ts create mode 100755 ts-client/cosmos.mint.v1beta1/types.ts create mode 100644 ts-client/cosmos.mint.v1beta1/types/cosmos/mint/v1beta1/genesis.ts create mode 100644 ts-client/cosmos.mint.v1beta1/types/cosmos/mint/v1beta1/mint.ts create mode 100644 ts-client/cosmos.mint.v1beta1/types/cosmos/mint/v1beta1/query.ts create mode 100644 ts-client/cosmos.mint.v1beta1/types/gogoproto/gogo.ts create mode 100644 ts-client/cosmos.mint.v1beta1/types/google/api/annotations.ts create mode 100644 ts-client/cosmos.mint.v1beta1/types/google/api/http.ts create mode 100644 ts-client/cosmos.mint.v1beta1/types/google/protobuf/descriptor.ts create mode 100755 ts-client/cosmos.params.v1beta1/index.ts create mode 100755 ts-client/cosmos.params.v1beta1/module.ts create mode 100755 ts-client/cosmos.params.v1beta1/registry.ts create mode 100644 ts-client/cosmos.params.v1beta1/rest.ts create mode 100755 ts-client/cosmos.params.v1beta1/types.ts create mode 100644 ts-client/cosmos.params.v1beta1/types/cosmos/params/v1beta1/params.ts create mode 100644 ts-client/cosmos.params.v1beta1/types/cosmos/params/v1beta1/query.ts create mode 100644 ts-client/cosmos.params.v1beta1/types/gogoproto/gogo.ts create mode 100644 ts-client/cosmos.params.v1beta1/types/google/api/annotations.ts create mode 100644 ts-client/cosmos.params.v1beta1/types/google/api/http.ts create mode 100644 ts-client/cosmos.params.v1beta1/types/google/protobuf/descriptor.ts create mode 100755 ts-client/cosmos.slashing.v1beta1/index.ts create mode 100755 ts-client/cosmos.slashing.v1beta1/module.ts create mode 100755 ts-client/cosmos.slashing.v1beta1/registry.ts create mode 100644 ts-client/cosmos.slashing.v1beta1/rest.ts create mode 100755 ts-client/cosmos.slashing.v1beta1/types.ts create mode 100644 ts-client/cosmos.slashing.v1beta1/types/cosmos/base/query/v1beta1/pagination.ts create mode 100644 ts-client/cosmos.slashing.v1beta1/types/cosmos/slashing/v1beta1/genesis.ts create mode 100644 ts-client/cosmos.slashing.v1beta1/types/cosmos/slashing/v1beta1/query.ts create mode 100644 ts-client/cosmos.slashing.v1beta1/types/cosmos/slashing/v1beta1/slashing.ts create mode 100644 ts-client/cosmos.slashing.v1beta1/types/cosmos/slashing/v1beta1/tx.ts create mode 100644 ts-client/cosmos.slashing.v1beta1/types/gogoproto/gogo.ts create mode 100644 ts-client/cosmos.slashing.v1beta1/types/google/api/annotations.ts create mode 100644 ts-client/cosmos.slashing.v1beta1/types/google/api/http.ts create mode 100644 ts-client/cosmos.slashing.v1beta1/types/google/protobuf/descriptor.ts create mode 100644 ts-client/cosmos.slashing.v1beta1/types/google/protobuf/duration.ts create mode 100644 ts-client/cosmos.slashing.v1beta1/types/google/protobuf/timestamp.ts create mode 100755 ts-client/cosmos.staking.v1beta1/index.ts create mode 100755 ts-client/cosmos.staking.v1beta1/module.ts create mode 100755 ts-client/cosmos.staking.v1beta1/registry.ts create mode 100644 ts-client/cosmos.staking.v1beta1/rest.ts create mode 100755 ts-client/cosmos.staking.v1beta1/types.ts create mode 100644 ts-client/cosmos.staking.v1beta1/types/cosmos/base/query/v1beta1/pagination.ts create mode 100644 ts-client/cosmos.staking.v1beta1/types/cosmos/base/v1beta1/coin.ts create mode 100644 ts-client/cosmos.staking.v1beta1/types/cosmos/staking/v1beta1/authz.ts create mode 100644 ts-client/cosmos.staking.v1beta1/types/cosmos/staking/v1beta1/genesis.ts create mode 100644 ts-client/cosmos.staking.v1beta1/types/cosmos/staking/v1beta1/query.ts create mode 100644 ts-client/cosmos.staking.v1beta1/types/cosmos/staking/v1beta1/staking.ts create mode 100644 ts-client/cosmos.staking.v1beta1/types/cosmos/staking/v1beta1/tx.ts create mode 100644 ts-client/cosmos.staking.v1beta1/types/cosmos_proto/cosmos.ts create mode 100644 ts-client/cosmos.staking.v1beta1/types/gogoproto/gogo.ts create mode 100644 ts-client/cosmos.staking.v1beta1/types/google/api/annotations.ts create mode 100644 ts-client/cosmos.staking.v1beta1/types/google/api/http.ts create mode 100644 ts-client/cosmos.staking.v1beta1/types/google/protobuf/any.ts create mode 100644 ts-client/cosmos.staking.v1beta1/types/google/protobuf/descriptor.ts create mode 100644 ts-client/cosmos.staking.v1beta1/types/google/protobuf/duration.ts create mode 100644 ts-client/cosmos.staking.v1beta1/types/google/protobuf/timestamp.ts create mode 100644 ts-client/cosmos.staking.v1beta1/types/tendermint/crypto/keys.ts create mode 100644 ts-client/cosmos.staking.v1beta1/types/tendermint/crypto/proof.ts create mode 100644 ts-client/cosmos.staking.v1beta1/types/tendermint/types/types.ts create mode 100644 ts-client/cosmos.staking.v1beta1/types/tendermint/types/validator.ts create mode 100644 ts-client/cosmos.staking.v1beta1/types/tendermint/version/types.ts create mode 100755 ts-client/cosmos.tx.v1beta1/index.ts create mode 100755 ts-client/cosmos.tx.v1beta1/module.ts create mode 100755 ts-client/cosmos.tx.v1beta1/registry.ts create mode 100644 ts-client/cosmos.tx.v1beta1/rest.ts create mode 100755 ts-client/cosmos.tx.v1beta1/types.ts create mode 100644 ts-client/cosmos.tx.v1beta1/types/cosmos/base/abci/v1beta1/abci.ts create mode 100644 ts-client/cosmos.tx.v1beta1/types/cosmos/base/query/v1beta1/pagination.ts create mode 100644 ts-client/cosmos.tx.v1beta1/types/cosmos/base/v1beta1/coin.ts create mode 100644 ts-client/cosmos.tx.v1beta1/types/cosmos/crypto/multisig/v1beta1/multisig.ts create mode 100644 ts-client/cosmos.tx.v1beta1/types/cosmos/tx/signing/v1beta1/signing.ts create mode 100644 ts-client/cosmos.tx.v1beta1/types/cosmos/tx/v1beta1/service.ts create mode 100644 ts-client/cosmos.tx.v1beta1/types/cosmos/tx/v1beta1/tx.ts create mode 100644 ts-client/cosmos.tx.v1beta1/types/gogoproto/gogo.ts create mode 100644 ts-client/cosmos.tx.v1beta1/types/google/api/annotations.ts create mode 100644 ts-client/cosmos.tx.v1beta1/types/google/api/http.ts create mode 100644 ts-client/cosmos.tx.v1beta1/types/google/protobuf/any.ts create mode 100644 ts-client/cosmos.tx.v1beta1/types/google/protobuf/descriptor.ts create mode 100644 ts-client/cosmos.tx.v1beta1/types/google/protobuf/duration.ts create mode 100644 ts-client/cosmos.tx.v1beta1/types/google/protobuf/timestamp.ts create mode 100644 ts-client/cosmos.tx.v1beta1/types/tendermint/abci/types.ts create mode 100644 ts-client/cosmos.tx.v1beta1/types/tendermint/crypto/keys.ts create mode 100644 ts-client/cosmos.tx.v1beta1/types/tendermint/crypto/proof.ts create mode 100644 ts-client/cosmos.tx.v1beta1/types/tendermint/types/block.ts create mode 100644 ts-client/cosmos.tx.v1beta1/types/tendermint/types/evidence.ts create mode 100644 ts-client/cosmos.tx.v1beta1/types/tendermint/types/params.ts create mode 100644 ts-client/cosmos.tx.v1beta1/types/tendermint/types/types.ts create mode 100644 ts-client/cosmos.tx.v1beta1/types/tendermint/types/validator.ts create mode 100644 ts-client/cosmos.tx.v1beta1/types/tendermint/version/types.ts create mode 100755 ts-client/cosmos.upgrade.v1beta1/index.ts create mode 100755 ts-client/cosmos.upgrade.v1beta1/module.ts create mode 100755 ts-client/cosmos.upgrade.v1beta1/registry.ts create mode 100644 ts-client/cosmos.upgrade.v1beta1/rest.ts create mode 100755 ts-client/cosmos.upgrade.v1beta1/types.ts create mode 100644 ts-client/cosmos.upgrade.v1beta1/types/cosmos/upgrade/v1beta1/query.ts create mode 100644 ts-client/cosmos.upgrade.v1beta1/types/cosmos/upgrade/v1beta1/upgrade.ts create mode 100644 ts-client/cosmos.upgrade.v1beta1/types/gogoproto/gogo.ts create mode 100644 ts-client/cosmos.upgrade.v1beta1/types/google/api/annotations.ts create mode 100644 ts-client/cosmos.upgrade.v1beta1/types/google/api/http.ts create mode 100644 ts-client/cosmos.upgrade.v1beta1/types/google/protobuf/any.ts create mode 100644 ts-client/cosmos.upgrade.v1beta1/types/google/protobuf/descriptor.ts create mode 100644 ts-client/cosmos.upgrade.v1beta1/types/google/protobuf/timestamp.ts create mode 100755 ts-client/cosmos.vesting.v1beta1/index.ts create mode 100755 ts-client/cosmos.vesting.v1beta1/module.ts create mode 100755 ts-client/cosmos.vesting.v1beta1/registry.ts create mode 100644 ts-client/cosmos.vesting.v1beta1/rest.ts create mode 100755 ts-client/cosmos.vesting.v1beta1/types.ts create mode 100644 ts-client/cosmos.vesting.v1beta1/types/cosmos/auth/v1beta1/auth.ts create mode 100644 ts-client/cosmos.vesting.v1beta1/types/cosmos/base/v1beta1/coin.ts create mode 100644 ts-client/cosmos.vesting.v1beta1/types/cosmos/vesting/v1beta1/tx.ts create mode 100644 ts-client/cosmos.vesting.v1beta1/types/cosmos/vesting/v1beta1/vesting.ts create mode 100644 ts-client/cosmos.vesting.v1beta1/types/cosmos_proto/cosmos.ts create mode 100644 ts-client/cosmos.vesting.v1beta1/types/gogoproto/gogo.ts create mode 100644 ts-client/cosmos.vesting.v1beta1/types/google/protobuf/any.ts create mode 100644 ts-client/cosmos.vesting.v1beta1/types/google/protobuf/descriptor.ts create mode 100755 ts-client/env.ts create mode 100755 ts-client/helpers.ts create mode 100755 ts-client/ibc.applications.interchain_accounts.host.v1/index.ts create mode 100755 ts-client/ibc.applications.interchain_accounts.host.v1/module.ts create mode 100755 ts-client/ibc.applications.interchain_accounts.host.v1/registry.ts create mode 100644 ts-client/ibc.applications.interchain_accounts.host.v1/rest.ts create mode 100755 ts-client/ibc.applications.interchain_accounts.host.v1/types.ts create mode 100644 ts-client/ibc.applications.interchain_accounts.host.v1/types/gogoproto/gogo.ts create mode 100644 ts-client/ibc.applications.interchain_accounts.host.v1/types/google/api/annotations.ts create mode 100644 ts-client/ibc.applications.interchain_accounts.host.v1/types/google/api/http.ts create mode 100644 ts-client/ibc.applications.interchain_accounts.host.v1/types/google/protobuf/descriptor.ts create mode 100644 ts-client/ibc.applications.interchain_accounts.host.v1/types/ibc/applications/interchain_accounts/host/v1/host.ts create mode 100644 ts-client/ibc.applications.interchain_accounts.host.v1/types/ibc/applications/interchain_accounts/host/v1/query.ts create mode 100755 ts-client/ibc.applications.transfer.v1/index.ts create mode 100755 ts-client/ibc.applications.transfer.v1/module.ts create mode 100755 ts-client/ibc.applications.transfer.v1/registry.ts create mode 100644 ts-client/ibc.applications.transfer.v1/rest.ts create mode 100755 ts-client/ibc.applications.transfer.v1/types.ts create mode 100644 ts-client/ibc.applications.transfer.v1/types/cosmos/base/query/v1beta1/pagination.ts create mode 100644 ts-client/ibc.applications.transfer.v1/types/cosmos/base/v1beta1/coin.ts create mode 100644 ts-client/ibc.applications.transfer.v1/types/cosmos/upgrade/v1beta1/upgrade.ts create mode 100644 ts-client/ibc.applications.transfer.v1/types/cosmos_proto/cosmos.ts create mode 100644 ts-client/ibc.applications.transfer.v1/types/gogoproto/gogo.ts create mode 100644 ts-client/ibc.applications.transfer.v1/types/google/api/annotations.ts create mode 100644 ts-client/ibc.applications.transfer.v1/types/google/api/http.ts create mode 100644 ts-client/ibc.applications.transfer.v1/types/google/protobuf/any.ts create mode 100644 ts-client/ibc.applications.transfer.v1/types/google/protobuf/descriptor.ts create mode 100644 ts-client/ibc.applications.transfer.v1/types/google/protobuf/timestamp.ts create mode 100644 ts-client/ibc.applications.transfer.v1/types/ibc/applications/transfer/v1/genesis.ts create mode 100644 ts-client/ibc.applications.transfer.v1/types/ibc/applications/transfer/v1/query.ts create mode 100644 ts-client/ibc.applications.transfer.v1/types/ibc/applications/transfer/v1/transfer.ts create mode 100644 ts-client/ibc.applications.transfer.v1/types/ibc/applications/transfer/v1/tx.ts create mode 100644 ts-client/ibc.applications.transfer.v1/types/ibc/core/client/v1/client.ts create mode 100755 ts-client/ibc.core.channel.v1/index.ts create mode 100755 ts-client/ibc.core.channel.v1/module.ts create mode 100755 ts-client/ibc.core.channel.v1/registry.ts create mode 100644 ts-client/ibc.core.channel.v1/rest.ts create mode 100755 ts-client/ibc.core.channel.v1/types.ts create mode 100644 ts-client/ibc.core.channel.v1/types/cosmos/base/query/v1beta1/pagination.ts create mode 100644 ts-client/ibc.core.channel.v1/types/cosmos/upgrade/v1beta1/upgrade.ts create mode 100644 ts-client/ibc.core.channel.v1/types/cosmos_proto/cosmos.ts create mode 100644 ts-client/ibc.core.channel.v1/types/gogoproto/gogo.ts create mode 100644 ts-client/ibc.core.channel.v1/types/google/api/annotations.ts create mode 100644 ts-client/ibc.core.channel.v1/types/google/api/http.ts create mode 100644 ts-client/ibc.core.channel.v1/types/google/protobuf/any.ts create mode 100644 ts-client/ibc.core.channel.v1/types/google/protobuf/descriptor.ts create mode 100644 ts-client/ibc.core.channel.v1/types/google/protobuf/timestamp.ts create mode 100644 ts-client/ibc.core.channel.v1/types/ibc/core/channel/v1/channel.ts create mode 100644 ts-client/ibc.core.channel.v1/types/ibc/core/channel/v1/genesis.ts create mode 100644 ts-client/ibc.core.channel.v1/types/ibc/core/channel/v1/query.ts create mode 100644 ts-client/ibc.core.channel.v1/types/ibc/core/channel/v1/tx.ts create mode 100644 ts-client/ibc.core.channel.v1/types/ibc/core/client/v1/client.ts create mode 100755 ts-client/ibc.core.client.v1/index.ts create mode 100755 ts-client/ibc.core.client.v1/module.ts create mode 100755 ts-client/ibc.core.client.v1/registry.ts create mode 100644 ts-client/ibc.core.client.v1/rest.ts create mode 100755 ts-client/ibc.core.client.v1/types.ts create mode 100644 ts-client/ibc.core.client.v1/types/cosmos/base/query/v1beta1/pagination.ts create mode 100644 ts-client/ibc.core.client.v1/types/cosmos/upgrade/v1beta1/upgrade.ts create mode 100644 ts-client/ibc.core.client.v1/types/cosmos_proto/cosmos.ts create mode 100644 ts-client/ibc.core.client.v1/types/gogoproto/gogo.ts create mode 100644 ts-client/ibc.core.client.v1/types/google/api/annotations.ts create mode 100644 ts-client/ibc.core.client.v1/types/google/api/http.ts create mode 100644 ts-client/ibc.core.client.v1/types/google/protobuf/any.ts create mode 100644 ts-client/ibc.core.client.v1/types/google/protobuf/descriptor.ts create mode 100644 ts-client/ibc.core.client.v1/types/google/protobuf/timestamp.ts create mode 100644 ts-client/ibc.core.client.v1/types/ibc/core/client/v1/client.ts create mode 100644 ts-client/ibc.core.client.v1/types/ibc/core/client/v1/genesis.ts create mode 100644 ts-client/ibc.core.client.v1/types/ibc/core/client/v1/query.ts create mode 100644 ts-client/ibc.core.client.v1/types/ibc/core/client/v1/tx.ts create mode 100755 ts-client/ibc.core.connection.v1/index.ts create mode 100755 ts-client/ibc.core.connection.v1/module.ts create mode 100755 ts-client/ibc.core.connection.v1/registry.ts create mode 100644 ts-client/ibc.core.connection.v1/rest.ts create mode 100755 ts-client/ibc.core.connection.v1/types.ts create mode 100644 ts-client/ibc.core.connection.v1/types/cosmos/base/query/v1beta1/pagination.ts create mode 100644 ts-client/ibc.core.connection.v1/types/cosmos/upgrade/v1beta1/upgrade.ts create mode 100644 ts-client/ibc.core.connection.v1/types/cosmos_proto/cosmos.ts create mode 100644 ts-client/ibc.core.connection.v1/types/gogoproto/gogo.ts create mode 100644 ts-client/ibc.core.connection.v1/types/google/api/annotations.ts create mode 100644 ts-client/ibc.core.connection.v1/types/google/api/http.ts create mode 100644 ts-client/ibc.core.connection.v1/types/google/protobuf/any.ts create mode 100644 ts-client/ibc.core.connection.v1/types/google/protobuf/descriptor.ts create mode 100644 ts-client/ibc.core.connection.v1/types/google/protobuf/timestamp.ts create mode 100644 ts-client/ibc.core.connection.v1/types/ibc/core/client/v1/client.ts create mode 100644 ts-client/ibc.core.connection.v1/types/ibc/core/commitment/v1/commitment.ts create mode 100644 ts-client/ibc.core.connection.v1/types/ibc/core/connection/v1/connection.ts create mode 100644 ts-client/ibc.core.connection.v1/types/ibc/core/connection/v1/genesis.ts create mode 100644 ts-client/ibc.core.connection.v1/types/ibc/core/connection/v1/query.ts create mode 100644 ts-client/ibc.core.connection.v1/types/ibc/core/connection/v1/tx.ts create mode 100644 ts-client/ibc.core.connection.v1/types/proofs.ts create mode 100755 ts-client/index.ts create mode 100755 ts-client/modules.ts create mode 100755 ts-client/package.json create mode 100755 vue/src/store/generated/bze.burner.v1/index.ts create mode 100755 vue/src/store/generated/bze.cointrunk.v1/index.ts create mode 100755 vue/src/store/generated/bze.epochs.v1/index.ts create mode 100755 vue/src/store/generated/bze.scavenge/index.ts create mode 100755 vue/src/store/generated/bze.tokenfactory.v1/index.ts create mode 100755 vue/src/store/generated/bze.tradebin.v1/index.ts create mode 100755 vue/src/store/generated/bze.v1.rewards/index.ts create mode 100644 x/rewards/keeper/trading_reward_distribution.go create mode 100644 x/rewards/keeper/trading_reward_expiration.go diff --git a/app/app.go b/app/app.go index 695786b0..2b3b8b7e 100644 --- a/app/app.go +++ b/app/app.go @@ -487,7 +487,8 @@ func New( []epochstypes.EpochHook{ app.RewardsKeeper.GetDistributeAllStakingRewardsHook(), app.RewardsKeeper.GetUnlockPendingUnlockParticipantsHook(), - //TODO: add here call to distribute trading rewards hook + app.RewardsKeeper.GetRemoveExpiredTradingRewardsHook(), + app.RewardsKeeper.GetTradingRewardsDistributionHook(), }, ) diff --git a/docs/static/openapi.yml b/docs/static/openapi.yml index 06f7bc43..d60329a9 100644 --- a/docs/static/openapi.yml +++ b/docs/static/openapi.yml @@ -2692,6 +2692,9 @@ paths: slots: type: integer format: int64 + expire_at: + type: integer + format: int64 pagination: type: object properties: @@ -2823,6 +2826,9 @@ paths: slots: type: integer format: int64 + expire_at: + type: integer + format: int64 default: description: An unexpected error response. schema: @@ -34770,6 +34776,9 @@ definitions: slots: type: integer format: int64 + expire_at: + type: integer + format: int64 pagination: type: object properties: @@ -34890,6 +34899,9 @@ definitions: slots: type: integer format: int64 + expire_at: + type: integer + format: int64 bze.v1.rewards.QueryParamsResponse: type: object properties: @@ -34961,6 +34973,9 @@ definitions: slots: type: integer format: int64 + expire_at: + type: integer + format: int64 cosmos.auth.v1beta1.Params: type: object properties: diff --git a/go.mod b/go.mod index 0519be13..23080d06 100644 --- a/go.mod +++ b/go.mod @@ -99,7 +99,6 @@ require ( github.com/fsnotify/fsnotify v1.6.0 // indirect github.com/fzipp/gocyclo v0.6.0 // indirect github.com/getsentry/sentry-go v0.17.0 // indirect - github.com/ghodss/yaml v1.0.0 // indirect github.com/go-critic/go-critic v0.6.5 // indirect github.com/go-kit/kit v0.12.0 // indirect github.com/go-kit/log v0.2.1 // indirect @@ -116,7 +115,6 @@ require ( github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect github.com/gofrs/flock v0.8.1 // indirect github.com/gogo/gateway v1.1.0 // indirect - github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b // indirect github.com/golang/snappy v0.0.4 // indirect github.com/golangci/check v0.0.0-20180506172741-cfe4005ccda2 // indirect github.com/golangci/dupl v0.0.0-20180902072040-3e9179ac440a // indirect @@ -139,7 +137,6 @@ require ( github.com/gostaticanalysis/forcetypeassert v0.1.0 // indirect github.com/gostaticanalysis/nilerr v0.1.1 // indirect github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 // indirect - github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1 // 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 diff --git a/go.sum b/go.sum index 5fd2428c..bd2604ca 100644 --- a/go.sum +++ b/go.sum @@ -154,7 +154,6 @@ github.com/aymerick/douceur v0.2.0 h1:Mv+mAeH1Q+n9Fr+oyamOlAkUNPWPlA8PPGR0QAaYuP github.com/aymerick/douceur v0.2.0/go.mod h1:wlT5vV2O3h55X9m7iVYN0TBM0NH/MmbLnd30/FjWUq4= github.com/aymerick/raymond v2.0.3-0.20180322193309-b565731e1464+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g= github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= -github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= @@ -262,7 +261,6 @@ github.com/containerd/continuity v0.3.0 h1:nisirsYROK15TAMVukJOUyGJjz4BNQJBVsNvA github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= -github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= github.com/coreos/go-systemd v0.0.0-20180511133405-39ca1b05acc7/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/coreos/go-systemd/v22 v22.3.3-0.20220203105225-a9a7ef127534/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= @@ -397,7 +395,6 @@ github.com/getsentry/sentry-go v0.12.0/go.mod h1:NSap0JBYWzHND8oMbyi0+XZhUalc1TB github.com/getsentry/sentry-go v0.17.0 h1:UustVWnOoDFHBS7IJUB2QK/nB5pap748ZEp0swnQJak= github.com/getsentry/sentry-go v0.17.0/go.mod h1:B82dxtBvxG0KaPD8/hfSV+VcHD+Lg/xUS4JuQn1P4cM= github.com/ghemawat/stream v0.0.0-20171120220530-696b145b53b9/go.mod h1:106OIgooyS7OzLDOpUGgm9fA3bQENb/cFSyyBmMoJDs= -github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/gin-contrib/sse v0.0.0-20190301062529-5545eab6dad3/go.mod h1:VJ0WA2NBN22VlZ2dKZQPAPnyWw5XTlK1KymzLKsr59s= github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= @@ -490,13 +487,11 @@ github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzq github.com/golang-jwt/jwt/v4 v4.3.0/go.mod h1:/xlHOz8bRuivTWchD4jCa+NbatV+wEUSzwAxVc6locg= github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k= github.com/golang/geo v0.0.0-20190916061304-5b978397cfec/go.mod h1:QZ0nwyI2jOfgRAoBvP+ab5aRr7c9x7lhGEJrKvBwjWI= -github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= @@ -504,7 +499,6 @@ github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= -github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.0/go.mod h1:Qd/q+1AKNOZr9uGQzbzCmRO6sUih6GTPZv6a1/R87v0= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= @@ -639,8 +633,6 @@ github.com/grpc-ecosystem/grpc-gateway v1.8.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4M0+kPpLofRdBo= github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1 h1:/c3QmbOGMGTOumP2iT/rCwB7b0QDGLKzqOmktBjT+Is= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1/go.mod h1:5SN9VR2LTsRFsrEC6FHgRbTWrTHu6tqPeKxEQv15giM= 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= @@ -656,7 +648,6 @@ github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brv github.com/hashicorp/go-bexpr v0.1.10/go.mod h1:oxlubA2vC/gFVfX1A6JGp7ls7uCDlfJn732ehYYg+g0= github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= -github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48= github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= github.com/hashicorp/go-immutable-radix v1.3.1 h1:DKHmCUm2hRBK510BaiZlwvpD40f8bJFeZnpfm2KLowc= github.com/hashicorp/go-immutable-radix v1.3.1/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= @@ -666,7 +657,6 @@ github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+l github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= github.com/hashicorp/go-retryablehttp v0.5.3/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs= github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU= -github.com/hashicorp/go-rootcerts v1.0.2/go.mod h1:pqUvnprVnM5bf7AOirdbb01K4ccR319Vf4pU3K5EGc8= github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU= github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4= github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= @@ -1324,7 +1314,6 @@ go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= -go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= @@ -1332,7 +1321,6 @@ go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/atomic v1.10.0 h1:9qC72Qh0+3MqyJbAn8YU5xVq1frD8bn3JtD2oXtafVQ= go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= go.uber.org/goleak v1.1.11 h1:wy28qYRKZgnJTxGxvye5/wgWr1EKjmUDGYox5mGlRlI= -go.uber.org/goleak v1.1.11/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4= go.uber.org/multierr v1.8.0 h1:dg6GjLku4EH+249NNmoIciG9N/jURbDG+pFlTkhzIC8= diff --git a/proto/rewards/genesis.proto b/proto/rewards/genesis.proto index 166fb651..6bd1bb92 100644 --- a/proto/rewards/genesis.proto +++ b/proto/rewards/genesis.proto @@ -17,10 +17,14 @@ message GenesisState { uint64 staking_rewards_counter = 3; uint64 trading_rewards_counter = 4; - repeated TradingReward trading_reward_list = 5 [(gogoproto.nullable) = false]; - repeated StakingRewardParticipant staking_reward_participant_list = 6 [(gogoproto.nullable) = false]; - repeated PendingUnlockParticipant pending_unlock_participant_list = 7 [(gogoproto.nullable) = false]; - repeated TradingRewardLeaderboard trading_reward_leaderboard_list = 8 [(gogoproto.nullable) = false]; - repeated TradingRewardCandidate trading_reward_candidate_list = 9 [(gogoproto.nullable) = false]; + repeated TradingReward active_trading_reward_list = 5 [(gogoproto.nullable) = false]; + repeated TradingReward pending_trading_reward_list = 6 [(gogoproto.nullable) = false]; + repeated StakingRewardParticipant staking_reward_participant_list = 7 [(gogoproto.nullable) = false]; + repeated PendingUnlockParticipant pending_unlock_participant_list = 8 [(gogoproto.nullable) = false]; + repeated TradingRewardLeaderboard trading_reward_leaderboard_list = 9 [(gogoproto.nullable) = false]; + repeated TradingRewardCandidate trading_reward_candidate_list = 10 [(gogoproto.nullable) = false]; + repeated MarketIdTradingRewardId market_id_trading_reward_id_list = 11 [(gogoproto.nullable) = false]; + repeated TradingRewardExpiration pending_trading_reward_expiration_list = 12 [(gogoproto.nullable) = false]; + repeated TradingRewardExpiration active_trading_reward_expiration_list = 13 [(gogoproto.nullable) = false]; // this line is used by starport scaffolding # genesis/proto/state } diff --git a/proto/rewards/trading_reward.proto b/proto/rewards/trading_reward.proto index 0e7261c7..fba95c4c 100644 --- a/proto/rewards/trading_reward.proto +++ b/proto/rewards/trading_reward.proto @@ -36,3 +36,8 @@ message TradingRewardCandidate { string amount = 2; string address = 3; } + +message MarketIdTradingRewardId { + string reward_id = 1; + string market_id = 2; +} diff --git a/ts-client/bze.burner.v1/index.ts b/ts-client/bze.burner.v1/index.ts new file mode 100755 index 00000000..c9dfa159 --- /dev/null +++ b/ts-client/bze.burner.v1/index.ts @@ -0,0 +1,6 @@ +import Module from './module'; +import { txClient, queryClient, registry } from './module'; +import { msgTypes } from './registry'; + +export * from "./types"; +export { Module, msgTypes, txClient, queryClient, registry }; diff --git a/ts-client/bze.burner.v1/module.ts b/ts-client/bze.burner.v1/module.ts new file mode 100755 index 00000000..28ed383b --- /dev/null +++ b/ts-client/bze.burner.v1/module.ts @@ -0,0 +1,99 @@ +// Generated by Ignite ignite.com/cli + +import { StdFee } from "@cosmjs/launchpad"; +import { SigningStargateClient, DeliverTxResponse } from "@cosmjs/stargate"; +import { EncodeObject, GeneratedType, OfflineSigner, Registry } from "@cosmjs/proto-signing"; +import { msgTypes } from './registry'; +import { IgniteClient } from "../client" +import { MissingWalletError } from "../helpers" +import { Api } from "./rest"; +import { MsgFundBurner } from "./types/burner/tx"; + + +export { MsgFundBurner }; + +type sendMsgFundBurnerParams = { + value: MsgFundBurner, + fee?: StdFee, + memo?: string +}; + + +type msgFundBurnerParams = { + value: MsgFundBurner, +}; + + +export const registry = new Registry(msgTypes); + +const defaultFee = { + amount: [], + gas: "200000", +}; + +interface TxClientOptions { + addr: string + prefix: string + signer?: OfflineSigner +} + +export const txClient = ({ signer, prefix, addr }: TxClientOptions = { addr: "http://localhost:26657", prefix: "cosmos" }) => { + + return { + + async sendMsgFundBurner({ value, fee, memo }: sendMsgFundBurnerParams): Promise { + if (!signer) { + throw new Error('TxClient:sendMsgFundBurner: Unable to sign Tx. Signer is not present.') + } + try { + const { address } = (await signer.getAccounts())[0]; + const signingClient = await SigningStargateClient.connectWithSigner(addr,signer,{registry, prefix}); + let msg = this.msgFundBurner({ value: MsgFundBurner.fromPartial(value) }) + return await signingClient.signAndBroadcast(address, [msg], fee ? fee : defaultFee, memo) + } catch (e: any) { + throw new Error('TxClient:sendMsgFundBurner: Could not broadcast Tx: '+ e.message) + } + }, + + + msgFundBurner({ value }: msgFundBurnerParams): EncodeObject { + try { + return { typeUrl: "/bze.burner.v1.MsgFundBurner", value: MsgFundBurner.fromPartial( value ) } + } catch (e: any) { + throw new Error('TxClient:MsgFundBurner: Could not create message: ' + e.message) + } + }, + + } +}; + +interface QueryClientOptions { + addr: string +} + +export const queryClient = ({ addr: addr }: QueryClientOptions = { addr: "http://localhost:1317" }) => { + return new Api({ baseUrl: addr }); +}; + +class SDKModule { + public query: ReturnType; + public tx: ReturnType; + + public registry: Array<[string, GeneratedType]>; + + constructor(client: IgniteClient) { + + this.query = queryClient({ addr: client.env.apiURL }); + this.tx = txClient({ signer: client.signer, addr: client.env.rpcURL, prefix: client.env.prefix ?? "cosmos" }); + } +}; + +const Module = (test: IgniteClient) => { + return { + module: { + BzeBurnerV1: new SDKModule(test) + }, + registry: msgTypes + } +} +export default Module; \ No newline at end of file diff --git a/ts-client/bze.burner.v1/registry.ts b/ts-client/bze.burner.v1/registry.ts new file mode 100755 index 00000000..ca1df956 --- /dev/null +++ b/ts-client/bze.burner.v1/registry.ts @@ -0,0 +1,9 @@ +import { GeneratedType } from "@cosmjs/proto-signing"; +import { MsgFundBurner } from "./types/burner/tx"; + +const msgTypes: Array<[string, GeneratedType]> = [ + ["/bze.burner.v1.MsgFundBurner", MsgFundBurner], + +]; + +export { msgTypes } \ No newline at end of file diff --git a/ts-client/bze.burner.v1/rest.ts b/ts-client/bze.burner.v1/rest.ts new file mode 100644 index 00000000..fc2f29e2 --- /dev/null +++ b/ts-client/bze.burner.v1/rest.ts @@ -0,0 +1,357 @@ +/* eslint-disable */ +/* tslint:disable */ +/* + * --------------------------------------------------------------- + * ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ## + * ## ## + * ## AUTHOR: acacode ## + * ## SOURCE: https://github.com/acacode/swagger-typescript-api ## + * --------------------------------------------------------------- + */ + +/** + * Params defines the parameters for the module. + */ +export type Burnerv1Params = object; + +export interface ProtobufAny { + "@type"?: string; +} + +export interface RpcStatus { + /** @format int32 */ + code?: number; + message?: string; + details?: ProtobufAny[]; +} + +export interface V1BurnedCoins { + burned?: string; + height?: string; +} + +export type V1MsgFundBurnerResponse = object; + +export interface V1QueryAllBurnedCoinsResponse { + burnedCoins?: V1BurnedCoins[]; + + /** + * PageResponse is to be embedded in gRPC response messages where the + * corresponding request message has used PageRequest. + * + * message SomeResponse { + * repeated Bar results = 1; + * PageResponse page = 2; + * } + */ + pagination?: V1Beta1PageResponse; +} + +/** + * QueryParamsResponse is response type for the Query/Params RPC method. + */ +export interface V1QueryParamsResponse { + /** params holds all the parameters of this module. */ + params?: Burnerv1Params; +} + +/** +* message SomeRequest { + Foo some_parameter = 1; + PageRequest pagination = 2; + } +*/ +export interface V1Beta1PageRequest { + /** + * key is a value returned in PageResponse.next_key to begin + * querying the next page most efficiently. Only one of offset or key + * should be set. + * @format byte + */ + key?: string; + + /** + * offset is a numeric offset that can be used when key is unavailable. + * It is less efficient than using key. Only one of offset or key should + * be set. + * @format uint64 + */ + offset?: string; + + /** + * limit is the total number of results to be returned in the result page. + * If left empty it will default to a value to be set by each app. + * @format uint64 + */ + limit?: string; + + /** + * count_total is set to true to indicate that the result set should include + * a count of the total number of items available for pagination in UIs. + * count_total is only respected when offset is used. It is ignored when key + * is set. + */ + count_total?: boolean; + + /** + * reverse is set to true if results are to be returned in the descending order. + * + * Since: cosmos-sdk 0.43 + */ + reverse?: boolean; +} + +/** +* PageResponse is to be embedded in gRPC response messages where the +corresponding request message has used PageRequest. + + message SomeResponse { + repeated Bar results = 1; + PageResponse page = 2; + } +*/ +export interface V1Beta1PageResponse { + /** @format byte */ + next_key?: string; + + /** @format uint64 */ + total?: string; +} + +export type QueryParamsType = Record; +export type ResponseFormat = keyof Omit; + +export interface FullRequestParams extends Omit { + /** set parameter to `true` for call `securityWorker` for this request */ + secure?: boolean; + /** request path */ + path: string; + /** content type of request body */ + type?: ContentType; + /** query params */ + query?: QueryParamsType; + /** format of response (i.e. response.json() -> format: "json") */ + format?: keyof Omit; + /** request body */ + body?: unknown; + /** base url */ + baseUrl?: string; + /** request cancellation token */ + cancelToken?: CancelToken; +} + +export type RequestParams = Omit; + +export interface ApiConfig { + baseUrl?: string; + baseApiParams?: Omit; + securityWorker?: (securityData: SecurityDataType) => RequestParams | void; +} + +export interface HttpResponse extends Response { + data: D; + error: E; +} + +type CancelToken = Symbol | string | number; + +export enum ContentType { + Json = "application/json", + FormData = "multipart/form-data", + UrlEncoded = "application/x-www-form-urlencoded", +} + +export class HttpClient { + public baseUrl: string = ""; + private securityData: SecurityDataType = null as any; + private securityWorker: null | ApiConfig["securityWorker"] = null; + private abortControllers = new Map(); + + private baseApiParams: RequestParams = { + credentials: "same-origin", + headers: {}, + redirect: "follow", + referrerPolicy: "no-referrer", + }; + + constructor(apiConfig: ApiConfig = {}) { + Object.assign(this, apiConfig); + } + + public setSecurityData = (data: SecurityDataType) => { + this.securityData = data; + }; + + private addQueryParam(query: QueryParamsType, key: string) { + const value = query[key]; + + return ( + encodeURIComponent(key) + + "=" + + encodeURIComponent(Array.isArray(value) ? value.join(",") : typeof value === "number" ? value : `${value}`) + ); + } + + protected toQueryString(rawQuery?: QueryParamsType): string { + const query = rawQuery || {}; + const keys = Object.keys(query).filter((key) => "undefined" !== typeof query[key]); + return keys + .map((key) => + typeof query[key] === "object" && !Array.isArray(query[key]) + ? this.toQueryString(query[key] as QueryParamsType) + : this.addQueryParam(query, key), + ) + .join("&"); + } + + protected addQueryParams(rawQuery?: QueryParamsType): string { + const queryString = this.toQueryString(rawQuery); + return queryString ? `?${queryString}` : ""; + } + + private contentFormatters: Record any> = { + [ContentType.Json]: (input: any) => + input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input, + [ContentType.FormData]: (input: any) => + Object.keys(input || {}).reduce((data, key) => { + data.append(key, input[key]); + return data; + }, new FormData()), + [ContentType.UrlEncoded]: (input: any) => this.toQueryString(input), + }; + + private mergeRequestParams(params1: RequestParams, params2?: RequestParams): RequestParams { + return { + ...this.baseApiParams, + ...params1, + ...(params2 || {}), + headers: { + ...(this.baseApiParams.headers || {}), + ...(params1.headers || {}), + ...((params2 && params2.headers) || {}), + }, + }; + } + + private createAbortSignal = (cancelToken: CancelToken): AbortSignal | undefined => { + if (this.abortControllers.has(cancelToken)) { + const abortController = this.abortControllers.get(cancelToken); + if (abortController) { + return abortController.signal; + } + return void 0; + } + + const abortController = new AbortController(); + this.abortControllers.set(cancelToken, abortController); + return abortController.signal; + }; + + public abortRequest = (cancelToken: CancelToken) => { + const abortController = this.abortControllers.get(cancelToken); + + if (abortController) { + abortController.abort(); + this.abortControllers.delete(cancelToken); + } + }; + + public request = ({ + body, + secure, + path, + type, + query, + format = "json", + baseUrl, + cancelToken, + ...params + }: FullRequestParams): Promise> => { + const secureParams = (secure && this.securityWorker && this.securityWorker(this.securityData)) || {}; + const requestParams = this.mergeRequestParams(params, secureParams); + const queryString = query && this.toQueryString(query); + const payloadFormatter = this.contentFormatters[type || ContentType.Json]; + + return fetch(`${baseUrl || this.baseUrl || ""}${path}${queryString ? `?${queryString}` : ""}`, { + ...requestParams, + headers: { + ...(type && type !== ContentType.FormData ? { "Content-Type": type } : {}), + ...(requestParams.headers || {}), + }, + signal: cancelToken ? this.createAbortSignal(cancelToken) : void 0, + body: typeof body === "undefined" || body === null ? null : payloadFormatter(body), + }).then(async (response) => { + const r = response as HttpResponse; + r.data = (null as unknown) as T; + r.error = (null as unknown) as E; + + const data = await response[format]() + .then((data) => { + if (r.ok) { + r.data = data; + } else { + r.error = data; + } + return r; + }) + .catch((e) => { + r.error = e; + return r; + }); + + if (cancelToken) { + this.abortControllers.delete(cancelToken); + } + + if (!response.ok) throw data; + return data; + }); + }; +} + +/** + * @title burner/burn_coins_proposal.proto + * @version version not set + */ +export class Api extends HttpClient { + /** + * No description + * + * @tags Query + * @name QueryAllBurnedCoins + * @request GET:/bze/burner/v1/all_burned_coins + */ + queryAllBurnedCoins = ( + query?: { + "pagination.key"?: string; + "pagination.offset"?: string; + "pagination.limit"?: string; + "pagination.count_total"?: boolean; + "pagination.reverse"?: boolean; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/bze/burner/v1/all_burned_coins`, + method: "GET", + query: query, + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Query + * @name QueryParams + * @summary Parameters queries the parameters of the module. + * @request GET:/bze/burner/v1/params + */ + queryParams = (params: RequestParams = {}) => + this.request({ + path: `/bze/burner/v1/params`, + method: "GET", + format: "json", + ...params, + }); +} diff --git a/ts-client/bze.burner.v1/types.ts b/ts-client/bze.burner.v1/types.ts new file mode 100755 index 00000000..56e04498 --- /dev/null +++ b/ts-client/bze.burner.v1/types.ts @@ -0,0 +1,15 @@ +import { BurnCoinsProposal } from "./types/burner/burn_coins_proposal" +import { BurnedCoins } from "./types/burner/burned_coins" +import { CoinsBurnedEvent } from "./types/burner/events" +import { FundBurnerEvent } from "./types/burner/events" +import { Params } from "./types/burner/params" + + +export { + BurnCoinsProposal, + BurnedCoins, + CoinsBurnedEvent, + FundBurnerEvent, + Params, + + } \ No newline at end of file diff --git a/ts-client/bze.burner.v1/types/burner/burn_coins_proposal.ts b/ts-client/bze.burner.v1/types/burner/burn_coins_proposal.ts new file mode 100644 index 00000000..a71afdbc --- /dev/null +++ b/ts-client/bze.burner.v1/types/burner/burn_coins_proposal.ts @@ -0,0 +1,93 @@ +/* eslint-disable */ +import { Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "bze.burner.v1"; + +export interface BurnCoinsProposal { + title: string; + description: string; +} + +const baseBurnCoinsProposal: object = { title: "", description: "" }; + +export const BurnCoinsProposal = { + encode(message: BurnCoinsProposal, writer: Writer = Writer.create()): Writer { + if (message.title !== "") { + writer.uint32(10).string(message.title); + } + if (message.description !== "") { + writer.uint32(18).string(message.description); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): BurnCoinsProposal { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseBurnCoinsProposal } as BurnCoinsProposal; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.title = reader.string(); + break; + case 2: + message.description = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): BurnCoinsProposal { + const message = { ...baseBurnCoinsProposal } as BurnCoinsProposal; + if (object.title !== undefined && object.title !== null) { + message.title = String(object.title); + } else { + message.title = ""; + } + if (object.description !== undefined && object.description !== null) { + message.description = String(object.description); + } else { + message.description = ""; + } + return message; + }, + + toJSON(message: BurnCoinsProposal): unknown { + const obj: any = {}; + message.title !== undefined && (obj.title = message.title); + message.description !== undefined && + (obj.description = message.description); + return obj; + }, + + fromPartial(object: DeepPartial): BurnCoinsProposal { + const message = { ...baseBurnCoinsProposal } as BurnCoinsProposal; + if (object.title !== undefined && object.title !== null) { + message.title = object.title; + } else { + message.title = ""; + } + if (object.description !== undefined && object.description !== null) { + message.description = object.description; + } else { + message.description = ""; + } + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/bze.burner.v1/types/burner/burned_coins.ts b/ts-client/bze.burner.v1/types/burner/burned_coins.ts new file mode 100644 index 00000000..15152ea3 --- /dev/null +++ b/ts-client/bze.burner.v1/types/burner/burned_coins.ts @@ -0,0 +1,92 @@ +/* eslint-disable */ +import { Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "bze.burner.v1"; + +export interface BurnedCoins { + burned: string; + height: string; +} + +const baseBurnedCoins: object = { burned: "", height: "" }; + +export const BurnedCoins = { + encode(message: BurnedCoins, writer: Writer = Writer.create()): Writer { + if (message.burned !== "") { + writer.uint32(10).string(message.burned); + } + if (message.height !== "") { + writer.uint32(18).string(message.height); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): BurnedCoins { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseBurnedCoins } as BurnedCoins; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.burned = reader.string(); + break; + case 2: + message.height = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): BurnedCoins { + const message = { ...baseBurnedCoins } as BurnedCoins; + if (object.burned !== undefined && object.burned !== null) { + message.burned = String(object.burned); + } else { + message.burned = ""; + } + if (object.height !== undefined && object.height !== null) { + message.height = String(object.height); + } else { + message.height = ""; + } + return message; + }, + + toJSON(message: BurnedCoins): unknown { + const obj: any = {}; + message.burned !== undefined && (obj.burned = message.burned); + message.height !== undefined && (obj.height = message.height); + return obj; + }, + + fromPartial(object: DeepPartial): BurnedCoins { + const message = { ...baseBurnedCoins } as BurnedCoins; + if (object.burned !== undefined && object.burned !== null) { + message.burned = object.burned; + } else { + message.burned = ""; + } + if (object.height !== undefined && object.height !== null) { + message.height = object.height; + } else { + message.height = ""; + } + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/bze.burner.v1/types/burner/events.ts b/ts-client/bze.burner.v1/types/burner/events.ts new file mode 100644 index 00000000..32869ff7 --- /dev/null +++ b/ts-client/bze.burner.v1/types/burner/events.ts @@ -0,0 +1,151 @@ +/* eslint-disable */ +import { Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "bze.burner.v1"; + +export interface CoinsBurnedEvent { + burned: string; +} + +export interface FundBurnerEvent { + from: string; + amount: string; +} + +const baseCoinsBurnedEvent: object = { burned: "" }; + +export const CoinsBurnedEvent = { + encode(message: CoinsBurnedEvent, writer: Writer = Writer.create()): Writer { + if (message.burned !== "") { + writer.uint32(10).string(message.burned); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): CoinsBurnedEvent { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseCoinsBurnedEvent } as CoinsBurnedEvent; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.burned = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): CoinsBurnedEvent { + const message = { ...baseCoinsBurnedEvent } as CoinsBurnedEvent; + if (object.burned !== undefined && object.burned !== null) { + message.burned = String(object.burned); + } else { + message.burned = ""; + } + return message; + }, + + toJSON(message: CoinsBurnedEvent): unknown { + const obj: any = {}; + message.burned !== undefined && (obj.burned = message.burned); + return obj; + }, + + fromPartial(object: DeepPartial): CoinsBurnedEvent { + const message = { ...baseCoinsBurnedEvent } as CoinsBurnedEvent; + if (object.burned !== undefined && object.burned !== null) { + message.burned = object.burned; + } else { + message.burned = ""; + } + return message; + }, +}; + +const baseFundBurnerEvent: object = { from: "", amount: "" }; + +export const FundBurnerEvent = { + encode(message: FundBurnerEvent, writer: Writer = Writer.create()): Writer { + if (message.from !== "") { + writer.uint32(10).string(message.from); + } + if (message.amount !== "") { + writer.uint32(18).string(message.amount); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FundBurnerEvent { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFundBurnerEvent } as FundBurnerEvent; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.from = reader.string(); + break; + case 2: + message.amount = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FundBurnerEvent { + const message = { ...baseFundBurnerEvent } as FundBurnerEvent; + if (object.from !== undefined && object.from !== null) { + message.from = String(object.from); + } else { + message.from = ""; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = String(object.amount); + } else { + message.amount = ""; + } + return message; + }, + + toJSON(message: FundBurnerEvent): unknown { + const obj: any = {}; + message.from !== undefined && (obj.from = message.from); + message.amount !== undefined && (obj.amount = message.amount); + return obj; + }, + + fromPartial(object: DeepPartial): FundBurnerEvent { + const message = { ...baseFundBurnerEvent } as FundBurnerEvent; + if (object.from !== undefined && object.from !== null) { + message.from = object.from; + } else { + message.from = ""; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = object.amount; + } else { + message.amount = ""; + } + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/bze.burner.v1/types/burner/genesis.ts b/ts-client/bze.burner.v1/types/burner/genesis.ts new file mode 100644 index 00000000..c619f296 --- /dev/null +++ b/ts-client/bze.burner.v1/types/burner/genesis.ts @@ -0,0 +1,114 @@ +/* eslint-disable */ +import { Params } from "../burner/params"; +import { BurnedCoins } from "../burner/burned_coins"; +import { Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "bze.burner.v1"; + +/** GenesisState defines the burner module's genesis state. */ +export interface GenesisState { + params: Params | undefined; + /** this line is used by starport scaffolding # genesis/proto/state */ + burnedCoinsList: BurnedCoins[]; +} + +const baseGenesisState: object = {}; + +export const GenesisState = { + encode(message: GenesisState, writer: Writer = Writer.create()): Writer { + if (message.params !== undefined) { + Params.encode(message.params, writer.uint32(10).fork()).ldelim(); + } + for (const v of message.burnedCoinsList) { + BurnedCoins.encode(v!, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): GenesisState { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseGenesisState } as GenesisState; + message.burnedCoinsList = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.params = Params.decode(reader, reader.uint32()); + break; + case 2: + message.burnedCoinsList.push( + BurnedCoins.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GenesisState { + const message = { ...baseGenesisState } as GenesisState; + message.burnedCoinsList = []; + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromJSON(object.params); + } else { + message.params = undefined; + } + if ( + object.burnedCoinsList !== undefined && + object.burnedCoinsList !== null + ) { + for (const e of object.burnedCoinsList) { + message.burnedCoinsList.push(BurnedCoins.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: GenesisState): unknown { + const obj: any = {}; + message.params !== undefined && + (obj.params = message.params ? Params.toJSON(message.params) : undefined); + if (message.burnedCoinsList) { + obj.burnedCoinsList = message.burnedCoinsList.map((e) => + e ? BurnedCoins.toJSON(e) : undefined + ); + } else { + obj.burnedCoinsList = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): GenesisState { + const message = { ...baseGenesisState } as GenesisState; + message.burnedCoinsList = []; + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromPartial(object.params); + } else { + message.params = undefined; + } + if ( + object.burnedCoinsList !== undefined && + object.burnedCoinsList !== null + ) { + for (const e of object.burnedCoinsList) { + message.burnedCoinsList.push(BurnedCoins.fromPartial(e)); + } + } + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/bze.burner.v1/types/burner/params.ts b/ts-client/bze.burner.v1/types/burner/params.ts new file mode 100644 index 00000000..425a5cc7 --- /dev/null +++ b/ts-client/bze.burner.v1/types/burner/params.ts @@ -0,0 +1,56 @@ +/* eslint-disable */ +import { Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "bze.burner.v1"; + +/** Params defines the parameters for the module. */ +export interface Params {} + +const baseParams: object = {}; + +export const Params = { + encode(_: Params, writer: Writer = Writer.create()): Writer { + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Params { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseParams } as Params; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): Params { + const message = { ...baseParams } as Params; + return message; + }, + + toJSON(_: Params): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial(_: DeepPartial): Params { + const message = { ...baseParams } as Params; + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/bze.burner.v1/types/burner/query.ts b/ts-client/bze.burner.v1/types/burner/query.ts new file mode 100644 index 00000000..1d0a7544 --- /dev/null +++ b/ts-client/bze.burner.v1/types/burner/query.ts @@ -0,0 +1,352 @@ +/* eslint-disable */ +import { Reader, Writer } from "protobufjs/minimal"; +import { Params } from "../burner/params"; +import { + PageRequest, + PageResponse, +} from "../cosmos/base/query/v1beta1/pagination"; +import { BurnedCoins } from "../burner/burned_coins"; + +export const protobufPackage = "bze.burner.v1"; + +/** QueryParamsRequest is request type for the Query/Params RPC method. */ +export interface QueryParamsRequest {} + +/** QueryParamsResponse is response type for the Query/Params RPC method. */ +export interface QueryParamsResponse { + /** params holds all the parameters of this module. */ + params: Params | undefined; +} + +export interface QueryAllBurnedCoinsRequest { + pagination: PageRequest | undefined; +} + +export interface QueryAllBurnedCoinsResponse { + burnedCoins: BurnedCoins[]; + pagination: PageResponse | undefined; +} + +const baseQueryParamsRequest: object = {}; + +export const QueryParamsRequest = { + encode(_: QueryParamsRequest, writer: Writer = Writer.create()): Writer { + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QueryParamsRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryParamsRequest } as QueryParamsRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): QueryParamsRequest { + const message = { ...baseQueryParamsRequest } as QueryParamsRequest; + return message; + }, + + toJSON(_: QueryParamsRequest): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial(_: DeepPartial): QueryParamsRequest { + const message = { ...baseQueryParamsRequest } as QueryParamsRequest; + return message; + }, +}; + +const baseQueryParamsResponse: object = {}; + +export const QueryParamsResponse = { + encode( + message: QueryParamsResponse, + writer: Writer = Writer.create() + ): Writer { + if (message.params !== undefined) { + Params.encode(message.params, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QueryParamsResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryParamsResponse } as QueryParamsResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.params = Params.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryParamsResponse { + const message = { ...baseQueryParamsResponse } as QueryParamsResponse; + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromJSON(object.params); + } else { + message.params = undefined; + } + return message; + }, + + toJSON(message: QueryParamsResponse): unknown { + const obj: any = {}; + message.params !== undefined && + (obj.params = message.params ? Params.toJSON(message.params) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): QueryParamsResponse { + const message = { ...baseQueryParamsResponse } as QueryParamsResponse; + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromPartial(object.params); + } else { + message.params = undefined; + } + return message; + }, +}; + +const baseQueryAllBurnedCoinsRequest: object = {}; + +export const QueryAllBurnedCoinsRequest = { + encode( + message: QueryAllBurnedCoinsRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryAllBurnedCoinsRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryAllBurnedCoinsRequest, + } as QueryAllBurnedCoinsRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryAllBurnedCoinsRequest { + const message = { + ...baseQueryAllBurnedCoinsRequest, + } as QueryAllBurnedCoinsRequest; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryAllBurnedCoinsRequest): unknown { + const obj: any = {}; + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageRequest.toJSON(message.pagination) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryAllBurnedCoinsRequest { + const message = { + ...baseQueryAllBurnedCoinsRequest, + } as QueryAllBurnedCoinsRequest; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseQueryAllBurnedCoinsResponse: object = {}; + +export const QueryAllBurnedCoinsResponse = { + encode( + message: QueryAllBurnedCoinsResponse, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.burnedCoins) { + BurnedCoins.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode( + message.pagination, + writer.uint32(18).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryAllBurnedCoinsResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryAllBurnedCoinsResponse, + } as QueryAllBurnedCoinsResponse; + message.burnedCoins = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.burnedCoins.push(BurnedCoins.decode(reader, reader.uint32())); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryAllBurnedCoinsResponse { + const message = { + ...baseQueryAllBurnedCoinsResponse, + } as QueryAllBurnedCoinsResponse; + message.burnedCoins = []; + if (object.burnedCoins !== undefined && object.burnedCoins !== null) { + for (const e of object.burnedCoins) { + message.burnedCoins.push(BurnedCoins.fromJSON(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryAllBurnedCoinsResponse): unknown { + const obj: any = {}; + if (message.burnedCoins) { + obj.burnedCoins = message.burnedCoins.map((e) => + e ? BurnedCoins.toJSON(e) : undefined + ); + } else { + obj.burnedCoins = []; + } + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageResponse.toJSON(message.pagination) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryAllBurnedCoinsResponse { + const message = { + ...baseQueryAllBurnedCoinsResponse, + } as QueryAllBurnedCoinsResponse; + message.burnedCoins = []; + if (object.burnedCoins !== undefined && object.burnedCoins !== null) { + for (const e of object.burnedCoins) { + message.burnedCoins.push(BurnedCoins.fromPartial(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +/** Query defines the gRPC querier service. */ +export interface Query { + /** Parameters queries the parameters of the module. */ + Params(request: QueryParamsRequest): Promise; + AllBurnedCoins( + request: QueryAllBurnedCoinsRequest + ): Promise; +} + +export class QueryClientImpl implements Query { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + } + Params(request: QueryParamsRequest): Promise { + const data = QueryParamsRequest.encode(request).finish(); + const promise = this.rpc.request("bze.burner.v1.Query", "Params", data); + return promise.then((data) => QueryParamsResponse.decode(new Reader(data))); + } + + AllBurnedCoins( + request: QueryAllBurnedCoinsRequest + ): Promise { + const data = QueryAllBurnedCoinsRequest.encode(request).finish(); + const promise = this.rpc.request( + "bze.burner.v1.Query", + "AllBurnedCoins", + data + ); + return promise.then((data) => + QueryAllBurnedCoinsResponse.decode(new Reader(data)) + ); + } +} + +interface Rpc { + request( + service: string, + method: string, + data: Uint8Array + ): Promise; +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/bze.burner.v1/types/burner/tx.ts b/ts-client/bze.burner.v1/types/burner/tx.ts new file mode 100644 index 00000000..74a3b426 --- /dev/null +++ b/ts-client/bze.burner.v1/types/burner/tx.ts @@ -0,0 +1,160 @@ +/* eslint-disable */ +import { Reader, Writer } from "protobufjs/minimal"; + +export const protobufPackage = "bze.burner.v1"; + +export interface MsgFundBurner { + creator: string; + amount: string; +} + +export interface MsgFundBurnerResponse {} + +const baseMsgFundBurner: object = { creator: "", amount: "" }; + +export const MsgFundBurner = { + encode(message: MsgFundBurner, writer: Writer = Writer.create()): Writer { + if (message.creator !== "") { + writer.uint32(10).string(message.creator); + } + if (message.amount !== "") { + writer.uint32(18).string(message.amount); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MsgFundBurner { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgFundBurner } as MsgFundBurner; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.creator = reader.string(); + break; + case 2: + message.amount = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgFundBurner { + const message = { ...baseMsgFundBurner } as MsgFundBurner; + if (object.creator !== undefined && object.creator !== null) { + message.creator = String(object.creator); + } else { + message.creator = ""; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = String(object.amount); + } else { + message.amount = ""; + } + return message; + }, + + toJSON(message: MsgFundBurner): unknown { + const obj: any = {}; + message.creator !== undefined && (obj.creator = message.creator); + message.amount !== undefined && (obj.amount = message.amount); + return obj; + }, + + fromPartial(object: DeepPartial): MsgFundBurner { + const message = { ...baseMsgFundBurner } as MsgFundBurner; + if (object.creator !== undefined && object.creator !== null) { + message.creator = object.creator; + } else { + message.creator = ""; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = object.amount; + } else { + message.amount = ""; + } + return message; + }, +}; + +const baseMsgFundBurnerResponse: object = {}; + +export const MsgFundBurnerResponse = { + encode(_: MsgFundBurnerResponse, writer: Writer = Writer.create()): Writer { + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MsgFundBurnerResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgFundBurnerResponse } as MsgFundBurnerResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): MsgFundBurnerResponse { + const message = { ...baseMsgFundBurnerResponse } as MsgFundBurnerResponse; + return message; + }, + + toJSON(_: MsgFundBurnerResponse): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial(_: DeepPartial): MsgFundBurnerResponse { + const message = { ...baseMsgFundBurnerResponse } as MsgFundBurnerResponse; + return message; + }, +}; + +/** Msg defines the Msg service. */ +export interface Msg { + /** this line is used by starport scaffolding # proto/tx/rpc */ + FundBurner(request: MsgFundBurner): Promise; +} + +export class MsgClientImpl implements Msg { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + } + FundBurner(request: MsgFundBurner): Promise { + const data = MsgFundBurner.encode(request).finish(); + const promise = this.rpc.request("bze.burner.v1.Msg", "FundBurner", data); + return promise.then((data) => + MsgFundBurnerResponse.decode(new Reader(data)) + ); + } +} + +interface Rpc { + request( + service: string, + method: string, + data: Uint8Array + ): Promise; +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/bze.burner.v1/types/cosmos/base/query/v1beta1/pagination.ts b/ts-client/bze.burner.v1/types/cosmos/base/query/v1beta1/pagination.ts new file mode 100644 index 00000000..cd4b2d78 --- /dev/null +++ b/ts-client/bze.burner.v1/types/cosmos/base/query/v1beta1/pagination.ts @@ -0,0 +1,327 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "cosmos.base.query.v1beta1"; + +/** + * PageRequest is to be embedded in gRPC request messages for efficient + * pagination. Ex: + * + * message SomeRequest { + * Foo some_parameter = 1; + * PageRequest pagination = 2; + * } + */ +export interface PageRequest { + /** + * key is a value returned in PageResponse.next_key to begin + * querying the next page most efficiently. Only one of offset or key + * should be set. + */ + key: Uint8Array; + /** + * offset is a numeric offset that can be used when key is unavailable. + * It is less efficient than using key. Only one of offset or key should + * be set. + */ + offset: number; + /** + * limit is the total number of results to be returned in the result page. + * If left empty it will default to a value to be set by each app. + */ + limit: number; + /** + * count_total is set to true to indicate that the result set should include + * a count of the total number of items available for pagination in UIs. + * count_total is only respected when offset is used. It is ignored when key + * is set. + */ + countTotal: boolean; + /** + * reverse is set to true if results are to be returned in the descending order. + * + * Since: cosmos-sdk 0.43 + */ + reverse: boolean; +} + +/** + * PageResponse is to be embedded in gRPC response messages where the + * corresponding request message has used PageRequest. + * + * message SomeResponse { + * repeated Bar results = 1; + * PageResponse page = 2; + * } + */ +export interface PageResponse { + /** + * next_key is the key to be passed to PageRequest.key to + * query the next page most efficiently + */ + nextKey: Uint8Array; + /** + * total is total number of results available if PageRequest.count_total + * was set, its value is undefined otherwise + */ + total: number; +} + +const basePageRequest: object = { + offset: 0, + limit: 0, + countTotal: false, + reverse: false, +}; + +export const PageRequest = { + encode(message: PageRequest, writer: Writer = Writer.create()): Writer { + if (message.key.length !== 0) { + writer.uint32(10).bytes(message.key); + } + if (message.offset !== 0) { + writer.uint32(16).uint64(message.offset); + } + if (message.limit !== 0) { + writer.uint32(24).uint64(message.limit); + } + if (message.countTotal === true) { + writer.uint32(32).bool(message.countTotal); + } + if (message.reverse === true) { + writer.uint32(40).bool(message.reverse); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): PageRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...basePageRequest } as PageRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.key = reader.bytes(); + break; + case 2: + message.offset = longToNumber(reader.uint64() as Long); + break; + case 3: + message.limit = longToNumber(reader.uint64() as Long); + break; + case 4: + message.countTotal = reader.bool(); + break; + case 5: + message.reverse = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): PageRequest { + const message = { ...basePageRequest } as PageRequest; + if (object.key !== undefined && object.key !== null) { + message.key = bytesFromBase64(object.key); + } + if (object.offset !== undefined && object.offset !== null) { + message.offset = Number(object.offset); + } else { + message.offset = 0; + } + if (object.limit !== undefined && object.limit !== null) { + message.limit = Number(object.limit); + } else { + message.limit = 0; + } + if (object.countTotal !== undefined && object.countTotal !== null) { + message.countTotal = Boolean(object.countTotal); + } else { + message.countTotal = false; + } + if (object.reverse !== undefined && object.reverse !== null) { + message.reverse = Boolean(object.reverse); + } else { + message.reverse = false; + } + return message; + }, + + toJSON(message: PageRequest): unknown { + const obj: any = {}; + message.key !== undefined && + (obj.key = base64FromBytes( + message.key !== undefined ? message.key : new Uint8Array() + )); + message.offset !== undefined && (obj.offset = message.offset); + message.limit !== undefined && (obj.limit = message.limit); + message.countTotal !== undefined && (obj.countTotal = message.countTotal); + message.reverse !== undefined && (obj.reverse = message.reverse); + return obj; + }, + + fromPartial(object: DeepPartial): PageRequest { + const message = { ...basePageRequest } as PageRequest; + if (object.key !== undefined && object.key !== null) { + message.key = object.key; + } else { + message.key = new Uint8Array(); + } + if (object.offset !== undefined && object.offset !== null) { + message.offset = object.offset; + } else { + message.offset = 0; + } + if (object.limit !== undefined && object.limit !== null) { + message.limit = object.limit; + } else { + message.limit = 0; + } + if (object.countTotal !== undefined && object.countTotal !== null) { + message.countTotal = object.countTotal; + } else { + message.countTotal = false; + } + if (object.reverse !== undefined && object.reverse !== null) { + message.reverse = object.reverse; + } else { + message.reverse = false; + } + return message; + }, +}; + +const basePageResponse: object = { total: 0 }; + +export const PageResponse = { + encode(message: PageResponse, writer: Writer = Writer.create()): Writer { + if (message.nextKey.length !== 0) { + writer.uint32(10).bytes(message.nextKey); + } + if (message.total !== 0) { + writer.uint32(16).uint64(message.total); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): PageResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...basePageResponse } as PageResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.nextKey = reader.bytes(); + break; + case 2: + message.total = longToNumber(reader.uint64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): PageResponse { + const message = { ...basePageResponse } as PageResponse; + if (object.nextKey !== undefined && object.nextKey !== null) { + message.nextKey = bytesFromBase64(object.nextKey); + } + if (object.total !== undefined && object.total !== null) { + message.total = Number(object.total); + } else { + message.total = 0; + } + return message; + }, + + toJSON(message: PageResponse): unknown { + const obj: any = {}; + message.nextKey !== undefined && + (obj.nextKey = base64FromBytes( + message.nextKey !== undefined ? message.nextKey : new Uint8Array() + )); + message.total !== undefined && (obj.total = message.total); + return obj; + }, + + fromPartial(object: DeepPartial): PageResponse { + const message = { ...basePageResponse } as PageResponse; + if (object.nextKey !== undefined && object.nextKey !== null) { + message.nextKey = object.nextKey; + } else { + message.nextKey = new Uint8Array(); + } + if (object.total !== undefined && object.total !== null) { + message.total = object.total; + } else { + message.total = 0; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/bze.burner.v1/types/gogoproto/gogo.ts b/ts-client/bze.burner.v1/types/gogoproto/gogo.ts new file mode 100644 index 00000000..3f41a047 --- /dev/null +++ b/ts-client/bze.burner.v1/types/gogoproto/gogo.ts @@ -0,0 +1,2 @@ +/* eslint-disable */ +export const protobufPackage = "gogoproto"; diff --git a/ts-client/bze.burner.v1/types/google/api/annotations.ts b/ts-client/bze.burner.v1/types/google/api/annotations.ts new file mode 100644 index 00000000..aace4787 --- /dev/null +++ b/ts-client/bze.burner.v1/types/google/api/annotations.ts @@ -0,0 +1,2 @@ +/* eslint-disable */ +export const protobufPackage = "google.api"; diff --git a/ts-client/bze.burner.v1/types/google/api/http.ts b/ts-client/bze.burner.v1/types/google/api/http.ts new file mode 100644 index 00000000..ddc00f8b --- /dev/null +++ b/ts-client/bze.burner.v1/types/google/api/http.ts @@ -0,0 +1,705 @@ +/* eslint-disable */ +import { Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "google.api"; + +/** + * Defines the HTTP configuration for an API service. It contains a list of + * [HttpRule][google.api.HttpRule], each specifying the mapping of an RPC method + * to one or more HTTP REST API methods. + */ +export interface Http { + /** + * A list of HTTP configuration rules that apply to individual API methods. + * + * **NOTE:** All service configuration rules follow "last one wins" order. + */ + rules: HttpRule[]; + /** + * When set to true, URL path parmeters will be fully URI-decoded except in + * cases of single segment matches in reserved expansion, where "%2F" will be + * left encoded. + * + * The default behavior is to not decode RFC 6570 reserved characters in multi + * segment matches. + */ + fullyDecodeReservedExpansion: boolean; +} + +/** + * `HttpRule` defines the mapping of an RPC method to one or more HTTP + * REST API methods. The mapping specifies how different portions of the RPC + * request message are mapped to URL path, URL query parameters, and + * HTTP request body. The mapping is typically specified as an + * `google.api.http` annotation on the RPC method, + * see "google/api/annotations.proto" for details. + * + * The mapping consists of a field specifying the path template and + * method kind. The path template can refer to fields in the request + * message, as in the example below which describes a REST GET + * operation on a resource collection of messages: + * + * + * service Messaging { + * rpc GetMessage(GetMessageRequest) returns (Message) { + * option (google.api.http).get = "/v1/messages/{message_id}/{sub.subfield}"; + * } + * } + * message GetMessageRequest { + * message SubMessage { + * string subfield = 1; + * } + * string message_id = 1; // mapped to the URL + * SubMessage sub = 2; // `sub.subfield` is url-mapped + * } + * message Message { + * string text = 1; // content of the resource + * } + * + * The same http annotation can alternatively be expressed inside the + * `GRPC API Configuration` YAML file. + * + * http: + * rules: + * - selector: .Messaging.GetMessage + * get: /v1/messages/{message_id}/{sub.subfield} + * + * This definition enables an automatic, bidrectional mapping of HTTP + * JSON to RPC. Example: + * + * HTTP | RPC + * -----|----- + * `GET /v1/messages/123456/foo` | `GetMessage(message_id: "123456" sub: SubMessage(subfield: "foo"))` + * + * In general, not only fields but also field paths can be referenced + * from a path pattern. Fields mapped to the path pattern cannot be + * repeated and must have a primitive (non-message) type. + * + * Any fields in the request message which are not bound by the path + * pattern automatically become (optional) HTTP query + * parameters. Assume the following definition of the request message: + * + * + * service Messaging { + * rpc GetMessage(GetMessageRequest) returns (Message) { + * option (google.api.http).get = "/v1/messages/{message_id}"; + * } + * } + * message GetMessageRequest { + * message SubMessage { + * string subfield = 1; + * } + * string message_id = 1; // mapped to the URL + * int64 revision = 2; // becomes a parameter + * SubMessage sub = 3; // `sub.subfield` becomes a parameter + * } + * + * + * This enables a HTTP JSON to RPC mapping as below: + * + * HTTP | RPC + * -----|----- + * `GET /v1/messages/123456?revision=2&sub.subfield=foo` | `GetMessage(message_id: "123456" revision: 2 sub: SubMessage(subfield: "foo"))` + * + * Note that fields which are mapped to HTTP parameters must have a + * primitive type or a repeated primitive type. Message types are not + * allowed. In the case of a repeated type, the parameter can be + * repeated in the URL, as in `...?param=A¶m=B`. + * + * For HTTP method kinds which allow a request body, the `body` field + * specifies the mapping. Consider a REST update method on the + * message resource collection: + * + * + * service Messaging { + * rpc UpdateMessage(UpdateMessageRequest) returns (Message) { + * option (google.api.http) = { + * put: "/v1/messages/{message_id}" + * body: "message" + * }; + * } + * } + * message UpdateMessageRequest { + * string message_id = 1; // mapped to the URL + * Message message = 2; // mapped to the body + * } + * + * + * The following HTTP JSON to RPC mapping is enabled, where the + * representation of the JSON in the request body is determined by + * protos JSON encoding: + * + * HTTP | RPC + * -----|----- + * `PUT /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: "123456" message { text: "Hi!" })` + * + * The special name `*` can be used in the body mapping to define that + * every field not bound by the path template should be mapped to the + * request body. This enables the following alternative definition of + * the update method: + * + * service Messaging { + * rpc UpdateMessage(Message) returns (Message) { + * option (google.api.http) = { + * put: "/v1/messages/{message_id}" + * body: "*" + * }; + * } + * } + * message Message { + * string message_id = 1; + * string text = 2; + * } + * + * + * The following HTTP JSON to RPC mapping is enabled: + * + * HTTP | RPC + * -----|----- + * `PUT /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: "123456" text: "Hi!")` + * + * Note that when using `*` in the body mapping, it is not possible to + * have HTTP parameters, as all fields not bound by the path end in + * the body. This makes this option more rarely used in practice of + * defining REST APIs. The common usage of `*` is in custom methods + * which don't use the URL at all for transferring data. + * + * It is possible to define multiple HTTP methods for one RPC by using + * the `additional_bindings` option. Example: + * + * service Messaging { + * rpc GetMessage(GetMessageRequest) returns (Message) { + * option (google.api.http) = { + * get: "/v1/messages/{message_id}" + * additional_bindings { + * get: "/v1/users/{user_id}/messages/{message_id}" + * } + * }; + * } + * } + * message GetMessageRequest { + * string message_id = 1; + * string user_id = 2; + * } + * + * + * This enables the following two alternative HTTP JSON to RPC + * mappings: + * + * HTTP | RPC + * -----|----- + * `GET /v1/messages/123456` | `GetMessage(message_id: "123456")` + * `GET /v1/users/me/messages/123456` | `GetMessage(user_id: "me" message_id: "123456")` + * + * # Rules for HTTP mapping + * + * The rules for mapping HTTP path, query parameters, and body fields + * to the request message are as follows: + * + * 1. The `body` field specifies either `*` or a field path, or is + * omitted. If omitted, it indicates there is no HTTP request body. + * 2. Leaf fields (recursive expansion of nested messages in the + * request) can be classified into three types: + * (a) Matched in the URL template. + * (b) Covered by body (if body is `*`, everything except (a) fields; + * else everything under the body field) + * (c) All other fields. + * 3. URL query parameters found in the HTTP request are mapped to (c) fields. + * 4. Any body sent with an HTTP request can contain only (b) fields. + * + * The syntax of the path template is as follows: + * + * Template = "/" Segments [ Verb ] ; + * Segments = Segment { "/" Segment } ; + * Segment = "*" | "**" | LITERAL | Variable ; + * Variable = "{" FieldPath [ "=" Segments ] "}" ; + * FieldPath = IDENT { "." IDENT } ; + * Verb = ":" LITERAL ; + * + * The syntax `*` matches a single path segment. The syntax `**` matches zero + * or more path segments, which must be the last part of the path except the + * `Verb`. The syntax `LITERAL` matches literal text in the path. + * + * The syntax `Variable` matches part of the URL path as specified by its + * template. A variable template must not contain other variables. If a variable + * matches a single path segment, its template may be omitted, e.g. `{var}` + * is equivalent to `{var=*}`. + * + * If a variable contains exactly one path segment, such as `"{var}"` or + * `"{var=*}"`, when such a variable is expanded into a URL path, all characters + * except `[-_.~0-9a-zA-Z]` are percent-encoded. Such variables show up in the + * Discovery Document as `{var}`. + * + * If a variable contains one or more path segments, such as `"{var=foo/*}"` + * or `"{var=**}"`, when such a variable is expanded into a URL path, all + * characters except `[-_.~/0-9a-zA-Z]` are percent-encoded. Such variables + * show up in the Discovery Document as `{+var}`. + * + * NOTE: While the single segment variable matches the semantics of + * [RFC 6570](https://tools.ietf.org/html/rfc6570) Section 3.2.2 + * Simple String Expansion, the multi segment variable **does not** match + * RFC 6570 Reserved Expansion. The reason is that the Reserved Expansion + * does not expand special characters like `?` and `#`, which would lead + * to invalid URLs. + * + * NOTE: the field paths in variables and in the `body` must not refer to + * repeated fields or map fields. + */ +export interface HttpRule { + /** + * Selects methods to which this rule applies. + * + * Refer to [selector][google.api.DocumentationRule.selector] for syntax details. + */ + selector: string; + /** Used for listing and getting information about resources. */ + get: string | undefined; + /** Used for updating a resource. */ + put: string | undefined; + /** Used for creating a resource. */ + post: string | undefined; + /** Used for deleting a resource. */ + delete: string | undefined; + /** Used for updating a resource. */ + patch: string | undefined; + /** + * The custom pattern is used for specifying an HTTP method that is not + * included in the `pattern` field, such as HEAD, or "*" to leave the + * HTTP method unspecified for this rule. The wild-card rule is useful + * for services that provide content to Web (HTML) clients. + */ + custom: CustomHttpPattern | undefined; + /** + * The name of the request field whose value is mapped to the HTTP body, or + * `*` for mapping all fields not captured by the path pattern to the HTTP + * body. NOTE: the referred field must not be a repeated field and must be + * present at the top-level of request message type. + */ + body: string; + /** + * Optional. The name of the response field whose value is mapped to the HTTP + * body of response. Other response fields are ignored. When + * not set, the response message will be used as HTTP body of response. + */ + responseBody: string; + /** + * Additional HTTP bindings for the selector. Nested bindings must + * not contain an `additional_bindings` field themselves (that is, + * the nesting may only be one level deep). + */ + additionalBindings: HttpRule[]; +} + +/** A custom pattern is used for defining custom HTTP verb. */ +export interface CustomHttpPattern { + /** The name of this custom HTTP verb. */ + kind: string; + /** The path matched by this custom verb. */ + path: string; +} + +const baseHttp: object = { fullyDecodeReservedExpansion: false }; + +export const Http = { + encode(message: Http, writer: Writer = Writer.create()): Writer { + for (const v of message.rules) { + HttpRule.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.fullyDecodeReservedExpansion === true) { + writer.uint32(16).bool(message.fullyDecodeReservedExpansion); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Http { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseHttp } as Http; + message.rules = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.rules.push(HttpRule.decode(reader, reader.uint32())); + break; + case 2: + message.fullyDecodeReservedExpansion = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Http { + const message = { ...baseHttp } as Http; + message.rules = []; + if (object.rules !== undefined && object.rules !== null) { + for (const e of object.rules) { + message.rules.push(HttpRule.fromJSON(e)); + } + } + if ( + object.fullyDecodeReservedExpansion !== undefined && + object.fullyDecodeReservedExpansion !== null + ) { + message.fullyDecodeReservedExpansion = Boolean( + object.fullyDecodeReservedExpansion + ); + } else { + message.fullyDecodeReservedExpansion = false; + } + return message; + }, + + toJSON(message: Http): unknown { + const obj: any = {}; + if (message.rules) { + obj.rules = message.rules.map((e) => + e ? HttpRule.toJSON(e) : undefined + ); + } else { + obj.rules = []; + } + message.fullyDecodeReservedExpansion !== undefined && + (obj.fullyDecodeReservedExpansion = message.fullyDecodeReservedExpansion); + return obj; + }, + + fromPartial(object: DeepPartial): Http { + const message = { ...baseHttp } as Http; + message.rules = []; + if (object.rules !== undefined && object.rules !== null) { + for (const e of object.rules) { + message.rules.push(HttpRule.fromPartial(e)); + } + } + if ( + object.fullyDecodeReservedExpansion !== undefined && + object.fullyDecodeReservedExpansion !== null + ) { + message.fullyDecodeReservedExpansion = + object.fullyDecodeReservedExpansion; + } else { + message.fullyDecodeReservedExpansion = false; + } + return message; + }, +}; + +const baseHttpRule: object = { selector: "", body: "", responseBody: "" }; + +export const HttpRule = { + encode(message: HttpRule, writer: Writer = Writer.create()): Writer { + if (message.selector !== "") { + writer.uint32(10).string(message.selector); + } + if (message.get !== undefined) { + writer.uint32(18).string(message.get); + } + if (message.put !== undefined) { + writer.uint32(26).string(message.put); + } + if (message.post !== undefined) { + writer.uint32(34).string(message.post); + } + if (message.delete !== undefined) { + writer.uint32(42).string(message.delete); + } + if (message.patch !== undefined) { + writer.uint32(50).string(message.patch); + } + if (message.custom !== undefined) { + CustomHttpPattern.encode( + message.custom, + writer.uint32(66).fork() + ).ldelim(); + } + if (message.body !== "") { + writer.uint32(58).string(message.body); + } + if (message.responseBody !== "") { + writer.uint32(98).string(message.responseBody); + } + for (const v of message.additionalBindings) { + HttpRule.encode(v!, writer.uint32(90).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): HttpRule { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseHttpRule } as HttpRule; + message.additionalBindings = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.selector = reader.string(); + break; + case 2: + message.get = reader.string(); + break; + case 3: + message.put = reader.string(); + break; + case 4: + message.post = reader.string(); + break; + case 5: + message.delete = reader.string(); + break; + case 6: + message.patch = reader.string(); + break; + case 8: + message.custom = CustomHttpPattern.decode(reader, reader.uint32()); + break; + case 7: + message.body = reader.string(); + break; + case 12: + message.responseBody = reader.string(); + break; + case 11: + message.additionalBindings.push( + HttpRule.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): HttpRule { + const message = { ...baseHttpRule } as HttpRule; + message.additionalBindings = []; + if (object.selector !== undefined && object.selector !== null) { + message.selector = String(object.selector); + } else { + message.selector = ""; + } + if (object.get !== undefined && object.get !== null) { + message.get = String(object.get); + } else { + message.get = undefined; + } + if (object.put !== undefined && object.put !== null) { + message.put = String(object.put); + } else { + message.put = undefined; + } + if (object.post !== undefined && object.post !== null) { + message.post = String(object.post); + } else { + message.post = undefined; + } + if (object.delete !== undefined && object.delete !== null) { + message.delete = String(object.delete); + } else { + message.delete = undefined; + } + if (object.patch !== undefined && object.patch !== null) { + message.patch = String(object.patch); + } else { + message.patch = undefined; + } + if (object.custom !== undefined && object.custom !== null) { + message.custom = CustomHttpPattern.fromJSON(object.custom); + } else { + message.custom = undefined; + } + if (object.body !== undefined && object.body !== null) { + message.body = String(object.body); + } else { + message.body = ""; + } + if (object.responseBody !== undefined && object.responseBody !== null) { + message.responseBody = String(object.responseBody); + } else { + message.responseBody = ""; + } + if ( + object.additionalBindings !== undefined && + object.additionalBindings !== null + ) { + for (const e of object.additionalBindings) { + message.additionalBindings.push(HttpRule.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: HttpRule): unknown { + const obj: any = {}; + message.selector !== undefined && (obj.selector = message.selector); + message.get !== undefined && (obj.get = message.get); + message.put !== undefined && (obj.put = message.put); + message.post !== undefined && (obj.post = message.post); + message.delete !== undefined && (obj.delete = message.delete); + message.patch !== undefined && (obj.patch = message.patch); + message.custom !== undefined && + (obj.custom = message.custom + ? CustomHttpPattern.toJSON(message.custom) + : undefined); + message.body !== undefined && (obj.body = message.body); + message.responseBody !== undefined && + (obj.responseBody = message.responseBody); + if (message.additionalBindings) { + obj.additionalBindings = message.additionalBindings.map((e) => + e ? HttpRule.toJSON(e) : undefined + ); + } else { + obj.additionalBindings = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): HttpRule { + const message = { ...baseHttpRule } as HttpRule; + message.additionalBindings = []; + if (object.selector !== undefined && object.selector !== null) { + message.selector = object.selector; + } else { + message.selector = ""; + } + if (object.get !== undefined && object.get !== null) { + message.get = object.get; + } else { + message.get = undefined; + } + if (object.put !== undefined && object.put !== null) { + message.put = object.put; + } else { + message.put = undefined; + } + if (object.post !== undefined && object.post !== null) { + message.post = object.post; + } else { + message.post = undefined; + } + if (object.delete !== undefined && object.delete !== null) { + message.delete = object.delete; + } else { + message.delete = undefined; + } + if (object.patch !== undefined && object.patch !== null) { + message.patch = object.patch; + } else { + message.patch = undefined; + } + if (object.custom !== undefined && object.custom !== null) { + message.custom = CustomHttpPattern.fromPartial(object.custom); + } else { + message.custom = undefined; + } + if (object.body !== undefined && object.body !== null) { + message.body = object.body; + } else { + message.body = ""; + } + if (object.responseBody !== undefined && object.responseBody !== null) { + message.responseBody = object.responseBody; + } else { + message.responseBody = ""; + } + if ( + object.additionalBindings !== undefined && + object.additionalBindings !== null + ) { + for (const e of object.additionalBindings) { + message.additionalBindings.push(HttpRule.fromPartial(e)); + } + } + return message; + }, +}; + +const baseCustomHttpPattern: object = { kind: "", path: "" }; + +export const CustomHttpPattern = { + encode(message: CustomHttpPattern, writer: Writer = Writer.create()): Writer { + if (message.kind !== "") { + writer.uint32(10).string(message.kind); + } + if (message.path !== "") { + writer.uint32(18).string(message.path); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): CustomHttpPattern { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseCustomHttpPattern } as CustomHttpPattern; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.kind = reader.string(); + break; + case 2: + message.path = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): CustomHttpPattern { + const message = { ...baseCustomHttpPattern } as CustomHttpPattern; + if (object.kind !== undefined && object.kind !== null) { + message.kind = String(object.kind); + } else { + message.kind = ""; + } + if (object.path !== undefined && object.path !== null) { + message.path = String(object.path); + } else { + message.path = ""; + } + return message; + }, + + toJSON(message: CustomHttpPattern): unknown { + const obj: any = {}; + message.kind !== undefined && (obj.kind = message.kind); + message.path !== undefined && (obj.path = message.path); + return obj; + }, + + fromPartial(object: DeepPartial): CustomHttpPattern { + const message = { ...baseCustomHttpPattern } as CustomHttpPattern; + if (object.kind !== undefined && object.kind !== null) { + message.kind = object.kind; + } else { + message.kind = ""; + } + if (object.path !== undefined && object.path !== null) { + message.path = object.path; + } else { + message.path = ""; + } + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/bze.burner.v1/types/google/protobuf/descriptor.ts b/ts-client/bze.burner.v1/types/google/protobuf/descriptor.ts new file mode 100644 index 00000000..9e508660 --- /dev/null +++ b/ts-client/bze.burner.v1/types/google/protobuf/descriptor.ts @@ -0,0 +1,5261 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "google.protobuf"; + +/** + * The protocol compiler can output a FileDescriptorSet containing the .proto + * files it parses. + */ +export interface FileDescriptorSet { + file: FileDescriptorProto[]; +} + +/** Describes a complete .proto file. */ +export interface FileDescriptorProto { + /** file name, relative to root of source tree */ + name: string; + /** e.g. "foo", "foo.bar", etc. */ + package: string; + /** Names of files imported by this file. */ + dependency: string[]; + /** Indexes of the public imported files in the dependency list above. */ + publicDependency: number[]; + /** + * Indexes of the weak imported files in the dependency list. + * For Google-internal migration only. Do not use. + */ + weakDependency: number[]; + /** All top-level definitions in this file. */ + messageType: DescriptorProto[]; + enumType: EnumDescriptorProto[]; + service: ServiceDescriptorProto[]; + extension: FieldDescriptorProto[]; + options: FileOptions | undefined; + /** + * This field contains optional information about the original source code. + * You may safely remove this entire field without harming runtime + * functionality of the descriptors -- the information is needed only by + * development tools. + */ + sourceCodeInfo: SourceCodeInfo | undefined; + /** + * The syntax of the proto file. + * The supported values are "proto2" and "proto3". + */ + syntax: string; +} + +/** Describes a message type. */ +export interface DescriptorProto { + name: string; + field: FieldDescriptorProto[]; + extension: FieldDescriptorProto[]; + nestedType: DescriptorProto[]; + enumType: EnumDescriptorProto[]; + extensionRange: DescriptorProto_ExtensionRange[]; + oneofDecl: OneofDescriptorProto[]; + options: MessageOptions | undefined; + reservedRange: DescriptorProto_ReservedRange[]; + /** + * Reserved field names, which may not be used by fields in the same message. + * A given name may only be reserved once. + */ + reservedName: string[]; +} + +export interface DescriptorProto_ExtensionRange { + /** Inclusive. */ + start: number; + /** Exclusive. */ + end: number; + options: ExtensionRangeOptions | undefined; +} + +/** + * Range of reserved tag numbers. Reserved tag numbers may not be used by + * fields or extension ranges in the same message. Reserved ranges may + * not overlap. + */ +export interface DescriptorProto_ReservedRange { + /** Inclusive. */ + start: number; + /** Exclusive. */ + end: number; +} + +export interface ExtensionRangeOptions { + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +/** Describes a field within a message. */ +export interface FieldDescriptorProto { + name: string; + number: number; + label: FieldDescriptorProto_Label; + /** + * If type_name is set, this need not be set. If both this and type_name + * are set, this must be one of TYPE_ENUM, TYPE_MESSAGE or TYPE_GROUP. + */ + type: FieldDescriptorProto_Type; + /** + * For message and enum types, this is the name of the type. If the name + * starts with a '.', it is fully-qualified. Otherwise, C++-like scoping + * rules are used to find the type (i.e. first the nested types within this + * message are searched, then within the parent, on up to the root + * namespace). + */ + typeName: string; + /** + * For extensions, this is the name of the type being extended. It is + * resolved in the same manner as type_name. + */ + extendee: string; + /** + * For numeric types, contains the original text representation of the value. + * For booleans, "true" or "false". + * For strings, contains the default text contents (not escaped in any way). + * For bytes, contains the C escaped value. All bytes >= 128 are escaped. + * TODO(kenton): Base-64 encode? + */ + defaultValue: string; + /** + * If set, gives the index of a oneof in the containing type's oneof_decl + * list. This field is a member of that oneof. + */ + oneofIndex: number; + /** + * JSON name of this field. The value is set by protocol compiler. If the + * user has set a "json_name" option on this field, that option's value + * will be used. Otherwise, it's deduced from the field's name by converting + * it to camelCase. + */ + jsonName: string; + options: FieldOptions | undefined; + /** + * If true, this is a proto3 "optional". When a proto3 field is optional, it + * tracks presence regardless of field type. + * + * When proto3_optional is true, this field must be belong to a oneof to + * signal to old proto3 clients that presence is tracked for this field. This + * oneof is known as a "synthetic" oneof, and this field must be its sole + * member (each proto3 optional field gets its own synthetic oneof). Synthetic + * oneofs exist in the descriptor only, and do not generate any API. Synthetic + * oneofs must be ordered after all "real" oneofs. + * + * For message fields, proto3_optional doesn't create any semantic change, + * since non-repeated message fields always track presence. However it still + * indicates the semantic detail of whether the user wrote "optional" or not. + * This can be useful for round-tripping the .proto file. For consistency we + * give message fields a synthetic oneof also, even though it is not required + * to track presence. This is especially important because the parser can't + * tell if a field is a message or an enum, so it must always create a + * synthetic oneof. + * + * Proto2 optional fields do not set this flag, because they already indicate + * optional with `LABEL_OPTIONAL`. + */ + proto3Optional: boolean; +} + +export enum FieldDescriptorProto_Type { + /** + * TYPE_DOUBLE - 0 is reserved for errors. + * Order is weird for historical reasons. + */ + TYPE_DOUBLE = 1, + TYPE_FLOAT = 2, + /** + * TYPE_INT64 - Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT64 if + * negative values are likely. + */ + TYPE_INT64 = 3, + TYPE_UINT64 = 4, + /** + * TYPE_INT32 - Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT32 if + * negative values are likely. + */ + TYPE_INT32 = 5, + TYPE_FIXED64 = 6, + TYPE_FIXED32 = 7, + TYPE_BOOL = 8, + TYPE_STRING = 9, + /** + * TYPE_GROUP - Tag-delimited aggregate. + * Group type is deprecated and not supported in proto3. However, Proto3 + * implementations should still be able to parse the group wire format and + * treat group fields as unknown fields. + */ + TYPE_GROUP = 10, + /** TYPE_MESSAGE - Length-delimited aggregate. */ + TYPE_MESSAGE = 11, + /** TYPE_BYTES - New in version 2. */ + TYPE_BYTES = 12, + TYPE_UINT32 = 13, + TYPE_ENUM = 14, + TYPE_SFIXED32 = 15, + TYPE_SFIXED64 = 16, + /** TYPE_SINT32 - Uses ZigZag encoding. */ + TYPE_SINT32 = 17, + /** TYPE_SINT64 - Uses ZigZag encoding. */ + TYPE_SINT64 = 18, + UNRECOGNIZED = -1, +} + +export function fieldDescriptorProto_TypeFromJSON( + object: any +): FieldDescriptorProto_Type { + switch (object) { + case 1: + case "TYPE_DOUBLE": + return FieldDescriptorProto_Type.TYPE_DOUBLE; + case 2: + case "TYPE_FLOAT": + return FieldDescriptorProto_Type.TYPE_FLOAT; + case 3: + case "TYPE_INT64": + return FieldDescriptorProto_Type.TYPE_INT64; + case 4: + case "TYPE_UINT64": + return FieldDescriptorProto_Type.TYPE_UINT64; + case 5: + case "TYPE_INT32": + return FieldDescriptorProto_Type.TYPE_INT32; + case 6: + case "TYPE_FIXED64": + return FieldDescriptorProto_Type.TYPE_FIXED64; + case 7: + case "TYPE_FIXED32": + return FieldDescriptorProto_Type.TYPE_FIXED32; + case 8: + case "TYPE_BOOL": + return FieldDescriptorProto_Type.TYPE_BOOL; + case 9: + case "TYPE_STRING": + return FieldDescriptorProto_Type.TYPE_STRING; + case 10: + case "TYPE_GROUP": + return FieldDescriptorProto_Type.TYPE_GROUP; + case 11: + case "TYPE_MESSAGE": + return FieldDescriptorProto_Type.TYPE_MESSAGE; + case 12: + case "TYPE_BYTES": + return FieldDescriptorProto_Type.TYPE_BYTES; + case 13: + case "TYPE_UINT32": + return FieldDescriptorProto_Type.TYPE_UINT32; + case 14: + case "TYPE_ENUM": + return FieldDescriptorProto_Type.TYPE_ENUM; + case 15: + case "TYPE_SFIXED32": + return FieldDescriptorProto_Type.TYPE_SFIXED32; + case 16: + case "TYPE_SFIXED64": + return FieldDescriptorProto_Type.TYPE_SFIXED64; + case 17: + case "TYPE_SINT32": + return FieldDescriptorProto_Type.TYPE_SINT32; + case 18: + case "TYPE_SINT64": + return FieldDescriptorProto_Type.TYPE_SINT64; + case -1: + case "UNRECOGNIZED": + default: + return FieldDescriptorProto_Type.UNRECOGNIZED; + } +} + +export function fieldDescriptorProto_TypeToJSON( + object: FieldDescriptorProto_Type +): string { + switch (object) { + case FieldDescriptorProto_Type.TYPE_DOUBLE: + return "TYPE_DOUBLE"; + case FieldDescriptorProto_Type.TYPE_FLOAT: + return "TYPE_FLOAT"; + case FieldDescriptorProto_Type.TYPE_INT64: + return "TYPE_INT64"; + case FieldDescriptorProto_Type.TYPE_UINT64: + return "TYPE_UINT64"; + case FieldDescriptorProto_Type.TYPE_INT32: + return "TYPE_INT32"; + case FieldDescriptorProto_Type.TYPE_FIXED64: + return "TYPE_FIXED64"; + case FieldDescriptorProto_Type.TYPE_FIXED32: + return "TYPE_FIXED32"; + case FieldDescriptorProto_Type.TYPE_BOOL: + return "TYPE_BOOL"; + case FieldDescriptorProto_Type.TYPE_STRING: + return "TYPE_STRING"; + case FieldDescriptorProto_Type.TYPE_GROUP: + return "TYPE_GROUP"; + case FieldDescriptorProto_Type.TYPE_MESSAGE: + return "TYPE_MESSAGE"; + case FieldDescriptorProto_Type.TYPE_BYTES: + return "TYPE_BYTES"; + case FieldDescriptorProto_Type.TYPE_UINT32: + return "TYPE_UINT32"; + case FieldDescriptorProto_Type.TYPE_ENUM: + return "TYPE_ENUM"; + case FieldDescriptorProto_Type.TYPE_SFIXED32: + return "TYPE_SFIXED32"; + case FieldDescriptorProto_Type.TYPE_SFIXED64: + return "TYPE_SFIXED64"; + case FieldDescriptorProto_Type.TYPE_SINT32: + return "TYPE_SINT32"; + case FieldDescriptorProto_Type.TYPE_SINT64: + return "TYPE_SINT64"; + default: + return "UNKNOWN"; + } +} + +export enum FieldDescriptorProto_Label { + /** LABEL_OPTIONAL - 0 is reserved for errors */ + LABEL_OPTIONAL = 1, + LABEL_REQUIRED = 2, + LABEL_REPEATED = 3, + UNRECOGNIZED = -1, +} + +export function fieldDescriptorProto_LabelFromJSON( + object: any +): FieldDescriptorProto_Label { + switch (object) { + case 1: + case "LABEL_OPTIONAL": + return FieldDescriptorProto_Label.LABEL_OPTIONAL; + case 2: + case "LABEL_REQUIRED": + return FieldDescriptorProto_Label.LABEL_REQUIRED; + case 3: + case "LABEL_REPEATED": + return FieldDescriptorProto_Label.LABEL_REPEATED; + case -1: + case "UNRECOGNIZED": + default: + return FieldDescriptorProto_Label.UNRECOGNIZED; + } +} + +export function fieldDescriptorProto_LabelToJSON( + object: FieldDescriptorProto_Label +): string { + switch (object) { + case FieldDescriptorProto_Label.LABEL_OPTIONAL: + return "LABEL_OPTIONAL"; + case FieldDescriptorProto_Label.LABEL_REQUIRED: + return "LABEL_REQUIRED"; + case FieldDescriptorProto_Label.LABEL_REPEATED: + return "LABEL_REPEATED"; + default: + return "UNKNOWN"; + } +} + +/** Describes a oneof. */ +export interface OneofDescriptorProto { + name: string; + options: OneofOptions | undefined; +} + +/** Describes an enum type. */ +export interface EnumDescriptorProto { + name: string; + value: EnumValueDescriptorProto[]; + options: EnumOptions | undefined; + /** + * Range of reserved numeric values. Reserved numeric values may not be used + * by enum values in the same enum declaration. Reserved ranges may not + * overlap. + */ + reservedRange: EnumDescriptorProto_EnumReservedRange[]; + /** + * Reserved enum value names, which may not be reused. A given name may only + * be reserved once. + */ + reservedName: string[]; +} + +/** + * Range of reserved numeric values. Reserved values may not be used by + * entries in the same enum. Reserved ranges may not overlap. + * + * Note that this is distinct from DescriptorProto.ReservedRange in that it + * is inclusive such that it can appropriately represent the entire int32 + * domain. + */ +export interface EnumDescriptorProto_EnumReservedRange { + /** Inclusive. */ + start: number; + /** Inclusive. */ + end: number; +} + +/** Describes a value within an enum. */ +export interface EnumValueDescriptorProto { + name: string; + number: number; + options: EnumValueOptions | undefined; +} + +/** Describes a service. */ +export interface ServiceDescriptorProto { + name: string; + method: MethodDescriptorProto[]; + options: ServiceOptions | undefined; +} + +/** Describes a method of a service. */ +export interface MethodDescriptorProto { + name: string; + /** + * Input and output type names. These are resolved in the same way as + * FieldDescriptorProto.type_name, but must refer to a message type. + */ + inputType: string; + outputType: string; + options: MethodOptions | undefined; + /** Identifies if client streams multiple client messages */ + clientStreaming: boolean; + /** Identifies if server streams multiple server messages */ + serverStreaming: boolean; +} + +export interface FileOptions { + /** + * Sets the Java package where classes generated from this .proto will be + * placed. By default, the proto package is used, but this is often + * inappropriate because proto packages do not normally start with backwards + * domain names. + */ + javaPackage: string; + /** + * Controls the name of the wrapper Java class generated for the .proto file. + * That class will always contain the .proto file's getDescriptor() method as + * well as any top-level extensions defined in the .proto file. + * If java_multiple_files is disabled, then all the other classes from the + * .proto file will be nested inside the single wrapper outer class. + */ + javaOuterClassname: string; + /** + * If enabled, then the Java code generator will generate a separate .java + * file for each top-level message, enum, and service defined in the .proto + * file. Thus, these types will *not* be nested inside the wrapper class + * named by java_outer_classname. However, the wrapper class will still be + * generated to contain the file's getDescriptor() method as well as any + * top-level extensions defined in the file. + */ + javaMultipleFiles: boolean; + /** + * This option does nothing. + * + * @deprecated + */ + javaGenerateEqualsAndHash: boolean; + /** + * If set true, then the Java2 code generator will generate code that + * throws an exception whenever an attempt is made to assign a non-UTF-8 + * byte sequence to a string field. + * Message reflection will do the same. + * However, an extension field still accepts non-UTF-8 byte sequences. + * This option has no effect on when used with the lite runtime. + */ + javaStringCheckUtf8: boolean; + optimizeFor: FileOptions_OptimizeMode; + /** + * Sets the Go package where structs generated from this .proto will be + * placed. If omitted, the Go package will be derived from the following: + * - The basename of the package import path, if provided. + * - Otherwise, the package statement in the .proto file, if present. + * - Otherwise, the basename of the .proto file, without extension. + */ + goPackage: string; + /** + * Should generic services be generated in each language? "Generic" services + * are not specific to any particular RPC system. They are generated by the + * main code generators in each language (without additional plugins). + * Generic services were the only kind of service generation supported by + * early versions of google.protobuf. + * + * Generic services are now considered deprecated in favor of using plugins + * that generate code specific to your particular RPC system. Therefore, + * these default to false. Old code which depends on generic services should + * explicitly set them to true. + */ + ccGenericServices: boolean; + javaGenericServices: boolean; + pyGenericServices: boolean; + phpGenericServices: boolean; + /** + * Is this file deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for everything in the file, or it will be completely ignored; in the very + * least, this is a formalization for deprecating files. + */ + deprecated: boolean; + /** + * Enables the use of arenas for the proto messages in this file. This applies + * only to generated classes for C++. + */ + ccEnableArenas: boolean; + /** + * Sets the objective c class prefix which is prepended to all objective c + * generated classes from this .proto. There is no default. + */ + objcClassPrefix: string; + /** Namespace for generated classes; defaults to the package. */ + csharpNamespace: string; + /** + * By default Swift generators will take the proto package and CamelCase it + * replacing '.' with underscore and use that to prefix the types/symbols + * defined. When this options is provided, they will use this value instead + * to prefix the types/symbols defined. + */ + swiftPrefix: string; + /** + * Sets the php class prefix which is prepended to all php generated classes + * from this .proto. Default is empty. + */ + phpClassPrefix: string; + /** + * Use this option to change the namespace of php generated classes. Default + * is empty. When this option is empty, the package name will be used for + * determining the namespace. + */ + phpNamespace: string; + /** + * Use this option to change the namespace of php generated metadata classes. + * Default is empty. When this option is empty, the proto file name will be + * used for determining the namespace. + */ + phpMetadataNamespace: string; + /** + * Use this option to change the package of ruby generated classes. Default + * is empty. When this option is not set, the package name will be used for + * determining the ruby package. + */ + rubyPackage: string; + /** + * The parser stores options it doesn't recognize here. + * See the documentation for the "Options" section above. + */ + uninterpretedOption: UninterpretedOption[]; +} + +/** Generated classes can be optimized for speed or code size. */ +export enum FileOptions_OptimizeMode { + /** SPEED - Generate complete code for parsing, serialization, */ + SPEED = 1, + /** CODE_SIZE - etc. */ + CODE_SIZE = 2, + /** LITE_RUNTIME - Generate code using MessageLite and the lite runtime. */ + LITE_RUNTIME = 3, + UNRECOGNIZED = -1, +} + +export function fileOptions_OptimizeModeFromJSON( + object: any +): FileOptions_OptimizeMode { + switch (object) { + case 1: + case "SPEED": + return FileOptions_OptimizeMode.SPEED; + case 2: + case "CODE_SIZE": + return FileOptions_OptimizeMode.CODE_SIZE; + case 3: + case "LITE_RUNTIME": + return FileOptions_OptimizeMode.LITE_RUNTIME; + case -1: + case "UNRECOGNIZED": + default: + return FileOptions_OptimizeMode.UNRECOGNIZED; + } +} + +export function fileOptions_OptimizeModeToJSON( + object: FileOptions_OptimizeMode +): string { + switch (object) { + case FileOptions_OptimizeMode.SPEED: + return "SPEED"; + case FileOptions_OptimizeMode.CODE_SIZE: + return "CODE_SIZE"; + case FileOptions_OptimizeMode.LITE_RUNTIME: + return "LITE_RUNTIME"; + default: + return "UNKNOWN"; + } +} + +export interface MessageOptions { + /** + * Set true to use the old proto1 MessageSet wire format for extensions. + * This is provided for backwards-compatibility with the MessageSet wire + * format. You should not use this for any other reason: It's less + * efficient, has fewer features, and is more complicated. + * + * The message must be defined exactly as follows: + * message Foo { + * option message_set_wire_format = true; + * extensions 4 to max; + * } + * Note that the message cannot have any defined fields; MessageSets only + * have extensions. + * + * All extensions of your type must be singular messages; e.g. they cannot + * be int32s, enums, or repeated messages. + * + * Because this is an option, the above two restrictions are not enforced by + * the protocol compiler. + */ + messageSetWireFormat: boolean; + /** + * Disables the generation of the standard "descriptor()" accessor, which can + * conflict with a field of the same name. This is meant to make migration + * from proto1 easier; new code should avoid fields named "descriptor". + */ + noStandardDescriptorAccessor: boolean; + /** + * Is this message deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the message, or it will be completely ignored; in the very least, + * this is a formalization for deprecating messages. + */ + deprecated: boolean; + /** + * Whether the message is an automatically generated map entry type for the + * maps field. + * + * For maps fields: + * map map_field = 1; + * The parsed descriptor looks like: + * message MapFieldEntry { + * option map_entry = true; + * optional KeyType key = 1; + * optional ValueType value = 2; + * } + * repeated MapFieldEntry map_field = 1; + * + * Implementations may choose not to generate the map_entry=true message, but + * use a native map in the target language to hold the keys and values. + * The reflection APIs in such implementations still need to work as + * if the field is a repeated message field. + * + * NOTE: Do not set the option in .proto files. Always use the maps syntax + * instead. The option should only be implicitly set by the proto compiler + * parser. + */ + mapEntry: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface FieldOptions { + /** + * The ctype option instructs the C++ code generator to use a different + * representation of the field than it normally would. See the specific + * options below. This option is not yet implemented in the open source + * release -- sorry, we'll try to include it in a future version! + */ + ctype: FieldOptions_CType; + /** + * The packed option can be enabled for repeated primitive fields to enable + * a more efficient representation on the wire. Rather than repeatedly + * writing the tag and type for each element, the entire array is encoded as + * a single length-delimited blob. In proto3, only explicit setting it to + * false will avoid using packed encoding. + */ + packed: boolean; + /** + * The jstype option determines the JavaScript type used for values of the + * field. The option is permitted only for 64 bit integral and fixed types + * (int64, uint64, sint64, fixed64, sfixed64). A field with jstype JS_STRING + * is represented as JavaScript string, which avoids loss of precision that + * can happen when a large value is converted to a floating point JavaScript. + * Specifying JS_NUMBER for the jstype causes the generated JavaScript code to + * use the JavaScript "number" type. The behavior of the default option + * JS_NORMAL is implementation dependent. + * + * This option is an enum to permit additional types to be added, e.g. + * goog.math.Integer. + */ + jstype: FieldOptions_JSType; + /** + * Should this field be parsed lazily? Lazy applies only to message-type + * fields. It means that when the outer message is initially parsed, the + * inner message's contents will not be parsed but instead stored in encoded + * form. The inner message will actually be parsed when it is first accessed. + * + * This is only a hint. Implementations are free to choose whether to use + * eager or lazy parsing regardless of the value of this option. However, + * setting this option true suggests that the protocol author believes that + * using lazy parsing on this field is worth the additional bookkeeping + * overhead typically needed to implement it. + * + * This option does not affect the public interface of any generated code; + * all method signatures remain the same. Furthermore, thread-safety of the + * interface is not affected by this option; const methods remain safe to + * call from multiple threads concurrently, while non-const methods continue + * to require exclusive access. + * + * + * Note that implementations may choose not to check required fields within + * a lazy sub-message. That is, calling IsInitialized() on the outer message + * may return true even if the inner message has missing required fields. + * This is necessary because otherwise the inner message would have to be + * parsed in order to perform the check, defeating the purpose of lazy + * parsing. An implementation which chooses not to check required fields + * must be consistent about it. That is, for any particular sub-message, the + * implementation must either *always* check its required fields, or *never* + * check its required fields, regardless of whether or not the message has + * been parsed. + */ + lazy: boolean; + /** + * Is this field deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for accessors, or it will be completely ignored; in the very least, this + * is a formalization for deprecating fields. + */ + deprecated: boolean; + /** For Google-internal migration only. Do not use. */ + weak: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export enum FieldOptions_CType { + /** STRING - Default mode. */ + STRING = 0, + CORD = 1, + STRING_PIECE = 2, + UNRECOGNIZED = -1, +} + +export function fieldOptions_CTypeFromJSON(object: any): FieldOptions_CType { + switch (object) { + case 0: + case "STRING": + return FieldOptions_CType.STRING; + case 1: + case "CORD": + return FieldOptions_CType.CORD; + case 2: + case "STRING_PIECE": + return FieldOptions_CType.STRING_PIECE; + case -1: + case "UNRECOGNIZED": + default: + return FieldOptions_CType.UNRECOGNIZED; + } +} + +export function fieldOptions_CTypeToJSON(object: FieldOptions_CType): string { + switch (object) { + case FieldOptions_CType.STRING: + return "STRING"; + case FieldOptions_CType.CORD: + return "CORD"; + case FieldOptions_CType.STRING_PIECE: + return "STRING_PIECE"; + default: + return "UNKNOWN"; + } +} + +export enum FieldOptions_JSType { + /** JS_NORMAL - Use the default type. */ + JS_NORMAL = 0, + /** JS_STRING - Use JavaScript strings. */ + JS_STRING = 1, + /** JS_NUMBER - Use JavaScript numbers. */ + JS_NUMBER = 2, + UNRECOGNIZED = -1, +} + +export function fieldOptions_JSTypeFromJSON(object: any): FieldOptions_JSType { + switch (object) { + case 0: + case "JS_NORMAL": + return FieldOptions_JSType.JS_NORMAL; + case 1: + case "JS_STRING": + return FieldOptions_JSType.JS_STRING; + case 2: + case "JS_NUMBER": + return FieldOptions_JSType.JS_NUMBER; + case -1: + case "UNRECOGNIZED": + default: + return FieldOptions_JSType.UNRECOGNIZED; + } +} + +export function fieldOptions_JSTypeToJSON(object: FieldOptions_JSType): string { + switch (object) { + case FieldOptions_JSType.JS_NORMAL: + return "JS_NORMAL"; + case FieldOptions_JSType.JS_STRING: + return "JS_STRING"; + case FieldOptions_JSType.JS_NUMBER: + return "JS_NUMBER"; + default: + return "UNKNOWN"; + } +} + +export interface OneofOptions { + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface EnumOptions { + /** + * Set this option to true to allow mapping different tag names to the same + * value. + */ + allowAlias: boolean; + /** + * Is this enum deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the enum, or it will be completely ignored; in the very least, this + * is a formalization for deprecating enums. + */ + deprecated: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface EnumValueOptions { + /** + * Is this enum value deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the enum value, or it will be completely ignored; in the very least, + * this is a formalization for deprecating enum values. + */ + deprecated: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface ServiceOptions { + /** + * Is this service deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the service, or it will be completely ignored; in the very least, + * this is a formalization for deprecating services. + */ + deprecated: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface MethodOptions { + /** + * Is this method deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the method, or it will be completely ignored; in the very least, + * this is a formalization for deprecating methods. + */ + deprecated: boolean; + idempotencyLevel: MethodOptions_IdempotencyLevel; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +/** + * Is this method side-effect-free (or safe in HTTP parlance), or idempotent, + * or neither? HTTP based RPC implementation may choose GET verb for safe + * methods, and PUT verb for idempotent methods instead of the default POST. + */ +export enum MethodOptions_IdempotencyLevel { + IDEMPOTENCY_UNKNOWN = 0, + /** NO_SIDE_EFFECTS - implies idempotent */ + NO_SIDE_EFFECTS = 1, + /** IDEMPOTENT - idempotent, but may have side effects */ + IDEMPOTENT = 2, + UNRECOGNIZED = -1, +} + +export function methodOptions_IdempotencyLevelFromJSON( + object: any +): MethodOptions_IdempotencyLevel { + switch (object) { + case 0: + case "IDEMPOTENCY_UNKNOWN": + return MethodOptions_IdempotencyLevel.IDEMPOTENCY_UNKNOWN; + case 1: + case "NO_SIDE_EFFECTS": + return MethodOptions_IdempotencyLevel.NO_SIDE_EFFECTS; + case 2: + case "IDEMPOTENT": + return MethodOptions_IdempotencyLevel.IDEMPOTENT; + case -1: + case "UNRECOGNIZED": + default: + return MethodOptions_IdempotencyLevel.UNRECOGNIZED; + } +} + +export function methodOptions_IdempotencyLevelToJSON( + object: MethodOptions_IdempotencyLevel +): string { + switch (object) { + case MethodOptions_IdempotencyLevel.IDEMPOTENCY_UNKNOWN: + return "IDEMPOTENCY_UNKNOWN"; + case MethodOptions_IdempotencyLevel.NO_SIDE_EFFECTS: + return "NO_SIDE_EFFECTS"; + case MethodOptions_IdempotencyLevel.IDEMPOTENT: + return "IDEMPOTENT"; + default: + return "UNKNOWN"; + } +} + +/** + * A message representing a option the parser does not recognize. This only + * appears in options protos created by the compiler::Parser class. + * DescriptorPool resolves these when building Descriptor objects. Therefore, + * options protos in descriptor objects (e.g. returned by Descriptor::options(), + * or produced by Descriptor::CopyTo()) will never have UninterpretedOptions + * in them. + */ +export interface UninterpretedOption { + name: UninterpretedOption_NamePart[]; + /** + * The value of the uninterpreted option, in whatever type the tokenizer + * identified it as during parsing. Exactly one of these should be set. + */ + identifierValue: string; + positiveIntValue: number; + negativeIntValue: number; + doubleValue: number; + stringValue: Uint8Array; + aggregateValue: string; +} + +/** + * The name of the uninterpreted option. Each string represents a segment in + * a dot-separated name. is_extension is true iff a segment represents an + * extension (denoted with parentheses in options specs in .proto files). + * E.g.,{ ["foo", false], ["bar.baz", true], ["qux", false] } represents + * "foo.(bar.baz).qux". + */ +export interface UninterpretedOption_NamePart { + namePart: string; + isExtension: boolean; +} + +/** + * Encapsulates information about the original source file from which a + * FileDescriptorProto was generated. + */ +export interface SourceCodeInfo { + /** + * A Location identifies a piece of source code in a .proto file which + * corresponds to a particular definition. This information is intended + * to be useful to IDEs, code indexers, documentation generators, and similar + * tools. + * + * For example, say we have a file like: + * message Foo { + * optional string foo = 1; + * } + * Let's look at just the field definition: + * optional string foo = 1; + * ^ ^^ ^^ ^ ^^^ + * a bc de f ghi + * We have the following locations: + * span path represents + * [a,i) [ 4, 0, 2, 0 ] The whole field definition. + * [a,b) [ 4, 0, 2, 0, 4 ] The label (optional). + * [c,d) [ 4, 0, 2, 0, 5 ] The type (string). + * [e,f) [ 4, 0, 2, 0, 1 ] The name (foo). + * [g,h) [ 4, 0, 2, 0, 3 ] The number (1). + * + * Notes: + * - A location may refer to a repeated field itself (i.e. not to any + * particular index within it). This is used whenever a set of elements are + * logically enclosed in a single code segment. For example, an entire + * extend block (possibly containing multiple extension definitions) will + * have an outer location whose path refers to the "extensions" repeated + * field without an index. + * - Multiple locations may have the same path. This happens when a single + * logical declaration is spread out across multiple places. The most + * obvious example is the "extend" block again -- there may be multiple + * extend blocks in the same scope, each of which will have the same path. + * - A location's span is not always a subset of its parent's span. For + * example, the "extendee" of an extension declaration appears at the + * beginning of the "extend" block and is shared by all extensions within + * the block. + * - Just because a location's span is a subset of some other location's span + * does not mean that it is a descendant. For example, a "group" defines + * both a type and a field in a single declaration. Thus, the locations + * corresponding to the type and field and their components will overlap. + * - Code which tries to interpret locations should probably be designed to + * ignore those that it doesn't understand, as more types of locations could + * be recorded in the future. + */ + location: SourceCodeInfo_Location[]; +} + +export interface SourceCodeInfo_Location { + /** + * Identifies which part of the FileDescriptorProto was defined at this + * location. + * + * Each element is a field number or an index. They form a path from + * the root FileDescriptorProto to the place where the definition. For + * example, this path: + * [ 4, 3, 2, 7, 1 ] + * refers to: + * file.message_type(3) // 4, 3 + * .field(7) // 2, 7 + * .name() // 1 + * This is because FileDescriptorProto.message_type has field number 4: + * repeated DescriptorProto message_type = 4; + * and DescriptorProto.field has field number 2: + * repeated FieldDescriptorProto field = 2; + * and FieldDescriptorProto.name has field number 1: + * optional string name = 1; + * + * Thus, the above path gives the location of a field name. If we removed + * the last element: + * [ 4, 3, 2, 7 ] + * this path refers to the whole field declaration (from the beginning + * of the label to the terminating semicolon). + */ + path: number[]; + /** + * Always has exactly three or four elements: start line, start column, + * end line (optional, otherwise assumed same as start line), end column. + * These are packed into a single field for efficiency. Note that line + * and column numbers are zero-based -- typically you will want to add + * 1 to each before displaying to a user. + */ + span: number[]; + /** + * If this SourceCodeInfo represents a complete declaration, these are any + * comments appearing before and after the declaration which appear to be + * attached to the declaration. + * + * A series of line comments appearing on consecutive lines, with no other + * tokens appearing on those lines, will be treated as a single comment. + * + * leading_detached_comments will keep paragraphs of comments that appear + * before (but not connected to) the current element. Each paragraph, + * separated by empty lines, will be one comment element in the repeated + * field. + * + * Only the comment content is provided; comment markers (e.g. //) are + * stripped out. For block comments, leading whitespace and an asterisk + * will be stripped from the beginning of each line other than the first. + * Newlines are included in the output. + * + * Examples: + * + * optional int32 foo = 1; // Comment attached to foo. + * // Comment attached to bar. + * optional int32 bar = 2; + * + * optional string baz = 3; + * // Comment attached to baz. + * // Another line attached to baz. + * + * // Comment attached to qux. + * // + * // Another line attached to qux. + * optional double qux = 4; + * + * // Detached comment for corge. This is not leading or trailing comments + * // to qux or corge because there are blank lines separating it from + * // both. + * + * // Detached comment for corge paragraph 2. + * + * optional string corge = 5; + * /* Block comment attached + * * to corge. Leading asterisks + * * will be removed. * / + * /* Block comment attached to + * * grault. * / + * optional int32 grault = 6; + * + * // ignored detached comments. + */ + leadingComments: string; + trailingComments: string; + leadingDetachedComments: string[]; +} + +/** + * Describes the relationship between generated code and its original source + * file. A GeneratedCodeInfo message is associated with only one generated + * source file, but may contain references to different source .proto files. + */ +export interface GeneratedCodeInfo { + /** + * An Annotation connects some span of text in generated code to an element + * of its generating .proto file. + */ + annotation: GeneratedCodeInfo_Annotation[]; +} + +export interface GeneratedCodeInfo_Annotation { + /** + * Identifies the element in the original source .proto file. This field + * is formatted the same as SourceCodeInfo.Location.path. + */ + path: number[]; + /** Identifies the filesystem path to the original source .proto. */ + sourceFile: string; + /** + * Identifies the starting offset in bytes in the generated code + * that relates to the identified object. + */ + begin: number; + /** + * Identifies the ending offset in bytes in the generated code that + * relates to the identified offset. The end offset should be one past + * the last relevant byte (so the length of the text = end - begin). + */ + end: number; +} + +const baseFileDescriptorSet: object = {}; + +export const FileDescriptorSet = { + encode(message: FileDescriptorSet, writer: Writer = Writer.create()): Writer { + for (const v of message.file) { + FileDescriptorProto.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FileDescriptorSet { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFileDescriptorSet } as FileDescriptorSet; + message.file = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.file.push( + FileDescriptorProto.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FileDescriptorSet { + const message = { ...baseFileDescriptorSet } as FileDescriptorSet; + message.file = []; + if (object.file !== undefined && object.file !== null) { + for (const e of object.file) { + message.file.push(FileDescriptorProto.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: FileDescriptorSet): unknown { + const obj: any = {}; + if (message.file) { + obj.file = message.file.map((e) => + e ? FileDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.file = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): FileDescriptorSet { + const message = { ...baseFileDescriptorSet } as FileDescriptorSet; + message.file = []; + if (object.file !== undefined && object.file !== null) { + for (const e of object.file) { + message.file.push(FileDescriptorProto.fromPartial(e)); + } + } + return message; + }, +}; + +const baseFileDescriptorProto: object = { + name: "", + package: "", + dependency: "", + publicDependency: 0, + weakDependency: 0, + syntax: "", +}; + +export const FileDescriptorProto = { + encode( + message: FileDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.package !== "") { + writer.uint32(18).string(message.package); + } + for (const v of message.dependency) { + writer.uint32(26).string(v!); + } + writer.uint32(82).fork(); + for (const v of message.publicDependency) { + writer.int32(v); + } + writer.ldelim(); + writer.uint32(90).fork(); + for (const v of message.weakDependency) { + writer.int32(v); + } + writer.ldelim(); + for (const v of message.messageType) { + DescriptorProto.encode(v!, writer.uint32(34).fork()).ldelim(); + } + for (const v of message.enumType) { + EnumDescriptorProto.encode(v!, writer.uint32(42).fork()).ldelim(); + } + for (const v of message.service) { + ServiceDescriptorProto.encode(v!, writer.uint32(50).fork()).ldelim(); + } + for (const v of message.extension) { + FieldDescriptorProto.encode(v!, writer.uint32(58).fork()).ldelim(); + } + if (message.options !== undefined) { + FileOptions.encode(message.options, writer.uint32(66).fork()).ldelim(); + } + if (message.sourceCodeInfo !== undefined) { + SourceCodeInfo.encode( + message.sourceCodeInfo, + writer.uint32(74).fork() + ).ldelim(); + } + if (message.syntax !== "") { + writer.uint32(98).string(message.syntax); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FileDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFileDescriptorProto } as FileDescriptorProto; + message.dependency = []; + message.publicDependency = []; + message.weakDependency = []; + message.messageType = []; + message.enumType = []; + message.service = []; + message.extension = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.package = reader.string(); + break; + case 3: + message.dependency.push(reader.string()); + break; + case 10: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.publicDependency.push(reader.int32()); + } + } else { + message.publicDependency.push(reader.int32()); + } + break; + case 11: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.weakDependency.push(reader.int32()); + } + } else { + message.weakDependency.push(reader.int32()); + } + break; + case 4: + message.messageType.push( + DescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 5: + message.enumType.push( + EnumDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 6: + message.service.push( + ServiceDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 7: + message.extension.push( + FieldDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 8: + message.options = FileOptions.decode(reader, reader.uint32()); + break; + case 9: + message.sourceCodeInfo = SourceCodeInfo.decode( + reader, + reader.uint32() + ); + break; + case 12: + message.syntax = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FileDescriptorProto { + const message = { ...baseFileDescriptorProto } as FileDescriptorProto; + message.dependency = []; + message.publicDependency = []; + message.weakDependency = []; + message.messageType = []; + message.enumType = []; + message.service = []; + message.extension = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.package !== undefined && object.package !== null) { + message.package = String(object.package); + } else { + message.package = ""; + } + if (object.dependency !== undefined && object.dependency !== null) { + for (const e of object.dependency) { + message.dependency.push(String(e)); + } + } + if ( + object.publicDependency !== undefined && + object.publicDependency !== null + ) { + for (const e of object.publicDependency) { + message.publicDependency.push(Number(e)); + } + } + if (object.weakDependency !== undefined && object.weakDependency !== null) { + for (const e of object.weakDependency) { + message.weakDependency.push(Number(e)); + } + } + if (object.messageType !== undefined && object.messageType !== null) { + for (const e of object.messageType) { + message.messageType.push(DescriptorProto.fromJSON(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromJSON(e)); + } + } + if (object.service !== undefined && object.service !== null) { + for (const e of object.service) { + message.service.push(ServiceDescriptorProto.fromJSON(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = FileOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.sourceCodeInfo !== undefined && object.sourceCodeInfo !== null) { + message.sourceCodeInfo = SourceCodeInfo.fromJSON(object.sourceCodeInfo); + } else { + message.sourceCodeInfo = undefined; + } + if (object.syntax !== undefined && object.syntax !== null) { + message.syntax = String(object.syntax); + } else { + message.syntax = ""; + } + return message; + }, + + toJSON(message: FileDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.package !== undefined && (obj.package = message.package); + if (message.dependency) { + obj.dependency = message.dependency.map((e) => e); + } else { + obj.dependency = []; + } + if (message.publicDependency) { + obj.publicDependency = message.publicDependency.map((e) => e); + } else { + obj.publicDependency = []; + } + if (message.weakDependency) { + obj.weakDependency = message.weakDependency.map((e) => e); + } else { + obj.weakDependency = []; + } + if (message.messageType) { + obj.messageType = message.messageType.map((e) => + e ? DescriptorProto.toJSON(e) : undefined + ); + } else { + obj.messageType = []; + } + if (message.enumType) { + obj.enumType = message.enumType.map((e) => + e ? EnumDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.enumType = []; + } + if (message.service) { + obj.service = message.service.map((e) => + e ? ServiceDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.service = []; + } + if (message.extension) { + obj.extension = message.extension.map((e) => + e ? FieldDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.extension = []; + } + message.options !== undefined && + (obj.options = message.options + ? FileOptions.toJSON(message.options) + : undefined); + message.sourceCodeInfo !== undefined && + (obj.sourceCodeInfo = message.sourceCodeInfo + ? SourceCodeInfo.toJSON(message.sourceCodeInfo) + : undefined); + message.syntax !== undefined && (obj.syntax = message.syntax); + return obj; + }, + + fromPartial(object: DeepPartial): FileDescriptorProto { + const message = { ...baseFileDescriptorProto } as FileDescriptorProto; + message.dependency = []; + message.publicDependency = []; + message.weakDependency = []; + message.messageType = []; + message.enumType = []; + message.service = []; + message.extension = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.package !== undefined && object.package !== null) { + message.package = object.package; + } else { + message.package = ""; + } + if (object.dependency !== undefined && object.dependency !== null) { + for (const e of object.dependency) { + message.dependency.push(e); + } + } + if ( + object.publicDependency !== undefined && + object.publicDependency !== null + ) { + for (const e of object.publicDependency) { + message.publicDependency.push(e); + } + } + if (object.weakDependency !== undefined && object.weakDependency !== null) { + for (const e of object.weakDependency) { + message.weakDependency.push(e); + } + } + if (object.messageType !== undefined && object.messageType !== null) { + for (const e of object.messageType) { + message.messageType.push(DescriptorProto.fromPartial(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromPartial(e)); + } + } + if (object.service !== undefined && object.service !== null) { + for (const e of object.service) { + message.service.push(ServiceDescriptorProto.fromPartial(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = FileOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.sourceCodeInfo !== undefined && object.sourceCodeInfo !== null) { + message.sourceCodeInfo = SourceCodeInfo.fromPartial( + object.sourceCodeInfo + ); + } else { + message.sourceCodeInfo = undefined; + } + if (object.syntax !== undefined && object.syntax !== null) { + message.syntax = object.syntax; + } else { + message.syntax = ""; + } + return message; + }, +}; + +const baseDescriptorProto: object = { name: "", reservedName: "" }; + +export const DescriptorProto = { + encode(message: DescriptorProto, writer: Writer = Writer.create()): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + for (const v of message.field) { + FieldDescriptorProto.encode(v!, writer.uint32(18).fork()).ldelim(); + } + for (const v of message.extension) { + FieldDescriptorProto.encode(v!, writer.uint32(50).fork()).ldelim(); + } + for (const v of message.nestedType) { + DescriptorProto.encode(v!, writer.uint32(26).fork()).ldelim(); + } + for (const v of message.enumType) { + EnumDescriptorProto.encode(v!, writer.uint32(34).fork()).ldelim(); + } + for (const v of message.extensionRange) { + DescriptorProto_ExtensionRange.encode( + v!, + writer.uint32(42).fork() + ).ldelim(); + } + for (const v of message.oneofDecl) { + OneofDescriptorProto.encode(v!, writer.uint32(66).fork()).ldelim(); + } + if (message.options !== undefined) { + MessageOptions.encode(message.options, writer.uint32(58).fork()).ldelim(); + } + for (const v of message.reservedRange) { + DescriptorProto_ReservedRange.encode( + v!, + writer.uint32(74).fork() + ).ldelim(); + } + for (const v of message.reservedName) { + writer.uint32(82).string(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): DescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseDescriptorProto } as DescriptorProto; + message.field = []; + message.extension = []; + message.nestedType = []; + message.enumType = []; + message.extensionRange = []; + message.oneofDecl = []; + message.reservedRange = []; + message.reservedName = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.field.push( + FieldDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 6: + message.extension.push( + FieldDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 3: + message.nestedType.push( + DescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 4: + message.enumType.push( + EnumDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 5: + message.extensionRange.push( + DescriptorProto_ExtensionRange.decode(reader, reader.uint32()) + ); + break; + case 8: + message.oneofDecl.push( + OneofDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 7: + message.options = MessageOptions.decode(reader, reader.uint32()); + break; + case 9: + message.reservedRange.push( + DescriptorProto_ReservedRange.decode(reader, reader.uint32()) + ); + break; + case 10: + message.reservedName.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DescriptorProto { + const message = { ...baseDescriptorProto } as DescriptorProto; + message.field = []; + message.extension = []; + message.nestedType = []; + message.enumType = []; + message.extensionRange = []; + message.oneofDecl = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.field !== undefined && object.field !== null) { + for (const e of object.field) { + message.field.push(FieldDescriptorProto.fromJSON(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromJSON(e)); + } + } + if (object.nestedType !== undefined && object.nestedType !== null) { + for (const e of object.nestedType) { + message.nestedType.push(DescriptorProto.fromJSON(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromJSON(e)); + } + } + if (object.extensionRange !== undefined && object.extensionRange !== null) { + for (const e of object.extensionRange) { + message.extensionRange.push(DescriptorProto_ExtensionRange.fromJSON(e)); + } + } + if (object.oneofDecl !== undefined && object.oneofDecl !== null) { + for (const e of object.oneofDecl) { + message.oneofDecl.push(OneofDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = MessageOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push(DescriptorProto_ReservedRange.fromJSON(e)); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(String(e)); + } + } + return message; + }, + + toJSON(message: DescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + if (message.field) { + obj.field = message.field.map((e) => + e ? FieldDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.field = []; + } + if (message.extension) { + obj.extension = message.extension.map((e) => + e ? FieldDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.extension = []; + } + if (message.nestedType) { + obj.nestedType = message.nestedType.map((e) => + e ? DescriptorProto.toJSON(e) : undefined + ); + } else { + obj.nestedType = []; + } + if (message.enumType) { + obj.enumType = message.enumType.map((e) => + e ? EnumDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.enumType = []; + } + if (message.extensionRange) { + obj.extensionRange = message.extensionRange.map((e) => + e ? DescriptorProto_ExtensionRange.toJSON(e) : undefined + ); + } else { + obj.extensionRange = []; + } + if (message.oneofDecl) { + obj.oneofDecl = message.oneofDecl.map((e) => + e ? OneofDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.oneofDecl = []; + } + message.options !== undefined && + (obj.options = message.options + ? MessageOptions.toJSON(message.options) + : undefined); + if (message.reservedRange) { + obj.reservedRange = message.reservedRange.map((e) => + e ? DescriptorProto_ReservedRange.toJSON(e) : undefined + ); + } else { + obj.reservedRange = []; + } + if (message.reservedName) { + obj.reservedName = message.reservedName.map((e) => e); + } else { + obj.reservedName = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): DescriptorProto { + const message = { ...baseDescriptorProto } as DescriptorProto; + message.field = []; + message.extension = []; + message.nestedType = []; + message.enumType = []; + message.extensionRange = []; + message.oneofDecl = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.field !== undefined && object.field !== null) { + for (const e of object.field) { + message.field.push(FieldDescriptorProto.fromPartial(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromPartial(e)); + } + } + if (object.nestedType !== undefined && object.nestedType !== null) { + for (const e of object.nestedType) { + message.nestedType.push(DescriptorProto.fromPartial(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromPartial(e)); + } + } + if (object.extensionRange !== undefined && object.extensionRange !== null) { + for (const e of object.extensionRange) { + message.extensionRange.push( + DescriptorProto_ExtensionRange.fromPartial(e) + ); + } + } + if (object.oneofDecl !== undefined && object.oneofDecl !== null) { + for (const e of object.oneofDecl) { + message.oneofDecl.push(OneofDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = MessageOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push( + DescriptorProto_ReservedRange.fromPartial(e) + ); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(e); + } + } + return message; + }, +}; + +const baseDescriptorProto_ExtensionRange: object = { start: 0, end: 0 }; + +export const DescriptorProto_ExtensionRange = { + encode( + message: DescriptorProto_ExtensionRange, + writer: Writer = Writer.create() + ): Writer { + if (message.start !== 0) { + writer.uint32(8).int32(message.start); + } + if (message.end !== 0) { + writer.uint32(16).int32(message.end); + } + if (message.options !== undefined) { + ExtensionRangeOptions.encode( + message.options, + writer.uint32(26).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): DescriptorProto_ExtensionRange { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseDescriptorProto_ExtensionRange, + } as DescriptorProto_ExtensionRange; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.start = reader.int32(); + break; + case 2: + message.end = reader.int32(); + break; + case 3: + message.options = ExtensionRangeOptions.decode( + reader, + reader.uint32() + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DescriptorProto_ExtensionRange { + const message = { + ...baseDescriptorProto_ExtensionRange, + } as DescriptorProto_ExtensionRange; + if (object.start !== undefined && object.start !== null) { + message.start = Number(object.start); + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = ExtensionRangeOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: DescriptorProto_ExtensionRange): unknown { + const obj: any = {}; + message.start !== undefined && (obj.start = message.start); + message.end !== undefined && (obj.end = message.end); + message.options !== undefined && + (obj.options = message.options + ? ExtensionRangeOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): DescriptorProto_ExtensionRange { + const message = { + ...baseDescriptorProto_ExtensionRange, + } as DescriptorProto_ExtensionRange; + if (object.start !== undefined && object.start !== null) { + message.start = object.start; + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = ExtensionRangeOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseDescriptorProto_ReservedRange: object = { start: 0, end: 0 }; + +export const DescriptorProto_ReservedRange = { + encode( + message: DescriptorProto_ReservedRange, + writer: Writer = Writer.create() + ): Writer { + if (message.start !== 0) { + writer.uint32(8).int32(message.start); + } + if (message.end !== 0) { + writer.uint32(16).int32(message.end); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): DescriptorProto_ReservedRange { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseDescriptorProto_ReservedRange, + } as DescriptorProto_ReservedRange; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.start = reader.int32(); + break; + case 2: + message.end = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DescriptorProto_ReservedRange { + const message = { + ...baseDescriptorProto_ReservedRange, + } as DescriptorProto_ReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = Number(object.start); + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + return message; + }, + + toJSON(message: DescriptorProto_ReservedRange): unknown { + const obj: any = {}; + message.start !== undefined && (obj.start = message.start); + message.end !== undefined && (obj.end = message.end); + return obj; + }, + + fromPartial( + object: DeepPartial + ): DescriptorProto_ReservedRange { + const message = { + ...baseDescriptorProto_ReservedRange, + } as DescriptorProto_ReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = object.start; + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + return message; + }, +}; + +const baseExtensionRangeOptions: object = {}; + +export const ExtensionRangeOptions = { + encode( + message: ExtensionRangeOptions, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ExtensionRangeOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseExtensionRangeOptions } as ExtensionRangeOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ExtensionRangeOptions { + const message = { ...baseExtensionRangeOptions } as ExtensionRangeOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: ExtensionRangeOptions): unknown { + const obj: any = {}; + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial( + object: DeepPartial + ): ExtensionRangeOptions { + const message = { ...baseExtensionRangeOptions } as ExtensionRangeOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseFieldDescriptorProto: object = { + name: "", + number: 0, + label: 1, + type: 1, + typeName: "", + extendee: "", + defaultValue: "", + oneofIndex: 0, + jsonName: "", + proto3Optional: false, +}; + +export const FieldDescriptorProto = { + encode( + message: FieldDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.number !== 0) { + writer.uint32(24).int32(message.number); + } + if (message.label !== 1) { + writer.uint32(32).int32(message.label); + } + if (message.type !== 1) { + writer.uint32(40).int32(message.type); + } + if (message.typeName !== "") { + writer.uint32(50).string(message.typeName); + } + if (message.extendee !== "") { + writer.uint32(18).string(message.extendee); + } + if (message.defaultValue !== "") { + writer.uint32(58).string(message.defaultValue); + } + if (message.oneofIndex !== 0) { + writer.uint32(72).int32(message.oneofIndex); + } + if (message.jsonName !== "") { + writer.uint32(82).string(message.jsonName); + } + if (message.options !== undefined) { + FieldOptions.encode(message.options, writer.uint32(66).fork()).ldelim(); + } + if (message.proto3Optional === true) { + writer.uint32(136).bool(message.proto3Optional); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FieldDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFieldDescriptorProto } as FieldDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 3: + message.number = reader.int32(); + break; + case 4: + message.label = reader.int32() as any; + break; + case 5: + message.type = reader.int32() as any; + break; + case 6: + message.typeName = reader.string(); + break; + case 2: + message.extendee = reader.string(); + break; + case 7: + message.defaultValue = reader.string(); + break; + case 9: + message.oneofIndex = reader.int32(); + break; + case 10: + message.jsonName = reader.string(); + break; + case 8: + message.options = FieldOptions.decode(reader, reader.uint32()); + break; + case 17: + message.proto3Optional = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FieldDescriptorProto { + const message = { ...baseFieldDescriptorProto } as FieldDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = Number(object.number); + } else { + message.number = 0; + } + if (object.label !== undefined && object.label !== null) { + message.label = fieldDescriptorProto_LabelFromJSON(object.label); + } else { + message.label = 1; + } + if (object.type !== undefined && object.type !== null) { + message.type = fieldDescriptorProto_TypeFromJSON(object.type); + } else { + message.type = 1; + } + if (object.typeName !== undefined && object.typeName !== null) { + message.typeName = String(object.typeName); + } else { + message.typeName = ""; + } + if (object.extendee !== undefined && object.extendee !== null) { + message.extendee = String(object.extendee); + } else { + message.extendee = ""; + } + if (object.defaultValue !== undefined && object.defaultValue !== null) { + message.defaultValue = String(object.defaultValue); + } else { + message.defaultValue = ""; + } + if (object.oneofIndex !== undefined && object.oneofIndex !== null) { + message.oneofIndex = Number(object.oneofIndex); + } else { + message.oneofIndex = 0; + } + if (object.jsonName !== undefined && object.jsonName !== null) { + message.jsonName = String(object.jsonName); + } else { + message.jsonName = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = FieldOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.proto3Optional !== undefined && object.proto3Optional !== null) { + message.proto3Optional = Boolean(object.proto3Optional); + } else { + message.proto3Optional = false; + } + return message; + }, + + toJSON(message: FieldDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.number !== undefined && (obj.number = message.number); + message.label !== undefined && + (obj.label = fieldDescriptorProto_LabelToJSON(message.label)); + message.type !== undefined && + (obj.type = fieldDescriptorProto_TypeToJSON(message.type)); + message.typeName !== undefined && (obj.typeName = message.typeName); + message.extendee !== undefined && (obj.extendee = message.extendee); + message.defaultValue !== undefined && + (obj.defaultValue = message.defaultValue); + message.oneofIndex !== undefined && (obj.oneofIndex = message.oneofIndex); + message.jsonName !== undefined && (obj.jsonName = message.jsonName); + message.options !== undefined && + (obj.options = message.options + ? FieldOptions.toJSON(message.options) + : undefined); + message.proto3Optional !== undefined && + (obj.proto3Optional = message.proto3Optional); + return obj; + }, + + fromPartial(object: DeepPartial): FieldDescriptorProto { + const message = { ...baseFieldDescriptorProto } as FieldDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = object.number; + } else { + message.number = 0; + } + if (object.label !== undefined && object.label !== null) { + message.label = object.label; + } else { + message.label = 1; + } + if (object.type !== undefined && object.type !== null) { + message.type = object.type; + } else { + message.type = 1; + } + if (object.typeName !== undefined && object.typeName !== null) { + message.typeName = object.typeName; + } else { + message.typeName = ""; + } + if (object.extendee !== undefined && object.extendee !== null) { + message.extendee = object.extendee; + } else { + message.extendee = ""; + } + if (object.defaultValue !== undefined && object.defaultValue !== null) { + message.defaultValue = object.defaultValue; + } else { + message.defaultValue = ""; + } + if (object.oneofIndex !== undefined && object.oneofIndex !== null) { + message.oneofIndex = object.oneofIndex; + } else { + message.oneofIndex = 0; + } + if (object.jsonName !== undefined && object.jsonName !== null) { + message.jsonName = object.jsonName; + } else { + message.jsonName = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = FieldOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.proto3Optional !== undefined && object.proto3Optional !== null) { + message.proto3Optional = object.proto3Optional; + } else { + message.proto3Optional = false; + } + return message; + }, +}; + +const baseOneofDescriptorProto: object = { name: "" }; + +export const OneofDescriptorProto = { + encode( + message: OneofDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.options !== undefined) { + OneofOptions.encode(message.options, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): OneofDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseOneofDescriptorProto } as OneofDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.options = OneofOptions.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): OneofDescriptorProto { + const message = { ...baseOneofDescriptorProto } as OneofDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = OneofOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: OneofDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.options !== undefined && + (obj.options = message.options + ? OneofOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): OneofDescriptorProto { + const message = { ...baseOneofDescriptorProto } as OneofDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = OneofOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseEnumDescriptorProto: object = { name: "", reservedName: "" }; + +export const EnumDescriptorProto = { + encode( + message: EnumDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + for (const v of message.value) { + EnumValueDescriptorProto.encode(v!, writer.uint32(18).fork()).ldelim(); + } + if (message.options !== undefined) { + EnumOptions.encode(message.options, writer.uint32(26).fork()).ldelim(); + } + for (const v of message.reservedRange) { + EnumDescriptorProto_EnumReservedRange.encode( + v!, + writer.uint32(34).fork() + ).ldelim(); + } + for (const v of message.reservedName) { + writer.uint32(42).string(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): EnumDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseEnumDescriptorProto } as EnumDescriptorProto; + message.value = []; + message.reservedRange = []; + message.reservedName = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.value.push( + EnumValueDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 3: + message.options = EnumOptions.decode(reader, reader.uint32()); + break; + case 4: + message.reservedRange.push( + EnumDescriptorProto_EnumReservedRange.decode( + reader, + reader.uint32() + ) + ); + break; + case 5: + message.reservedName.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumDescriptorProto { + const message = { ...baseEnumDescriptorProto } as EnumDescriptorProto; + message.value = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.value !== undefined && object.value !== null) { + for (const e of object.value) { + message.value.push(EnumValueDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push( + EnumDescriptorProto_EnumReservedRange.fromJSON(e) + ); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(String(e)); + } + } + return message; + }, + + toJSON(message: EnumDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + if (message.value) { + obj.value = message.value.map((e) => + e ? EnumValueDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.value = []; + } + message.options !== undefined && + (obj.options = message.options + ? EnumOptions.toJSON(message.options) + : undefined); + if (message.reservedRange) { + obj.reservedRange = message.reservedRange.map((e) => + e ? EnumDescriptorProto_EnumReservedRange.toJSON(e) : undefined + ); + } else { + obj.reservedRange = []; + } + if (message.reservedName) { + obj.reservedName = message.reservedName.map((e) => e); + } else { + obj.reservedName = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): EnumDescriptorProto { + const message = { ...baseEnumDescriptorProto } as EnumDescriptorProto; + message.value = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.value !== undefined && object.value !== null) { + for (const e of object.value) { + message.value.push(EnumValueDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push( + EnumDescriptorProto_EnumReservedRange.fromPartial(e) + ); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(e); + } + } + return message; + }, +}; + +const baseEnumDescriptorProto_EnumReservedRange: object = { start: 0, end: 0 }; + +export const EnumDescriptorProto_EnumReservedRange = { + encode( + message: EnumDescriptorProto_EnumReservedRange, + writer: Writer = Writer.create() + ): Writer { + if (message.start !== 0) { + writer.uint32(8).int32(message.start); + } + if (message.end !== 0) { + writer.uint32(16).int32(message.end); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): EnumDescriptorProto_EnumReservedRange { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseEnumDescriptorProto_EnumReservedRange, + } as EnumDescriptorProto_EnumReservedRange; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.start = reader.int32(); + break; + case 2: + message.end = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumDescriptorProto_EnumReservedRange { + const message = { + ...baseEnumDescriptorProto_EnumReservedRange, + } as EnumDescriptorProto_EnumReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = Number(object.start); + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + return message; + }, + + toJSON(message: EnumDescriptorProto_EnumReservedRange): unknown { + const obj: any = {}; + message.start !== undefined && (obj.start = message.start); + message.end !== undefined && (obj.end = message.end); + return obj; + }, + + fromPartial( + object: DeepPartial + ): EnumDescriptorProto_EnumReservedRange { + const message = { + ...baseEnumDescriptorProto_EnumReservedRange, + } as EnumDescriptorProto_EnumReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = object.start; + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + return message; + }, +}; + +const baseEnumValueDescriptorProto: object = { name: "", number: 0 }; + +export const EnumValueDescriptorProto = { + encode( + message: EnumValueDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.number !== 0) { + writer.uint32(16).int32(message.number); + } + if (message.options !== undefined) { + EnumValueOptions.encode( + message.options, + writer.uint32(26).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): EnumValueDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseEnumValueDescriptorProto, + } as EnumValueDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.number = reader.int32(); + break; + case 3: + message.options = EnumValueOptions.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumValueDescriptorProto { + const message = { + ...baseEnumValueDescriptorProto, + } as EnumValueDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = Number(object.number); + } else { + message.number = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumValueOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: EnumValueDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.number !== undefined && (obj.number = message.number); + message.options !== undefined && + (obj.options = message.options + ? EnumValueOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): EnumValueDescriptorProto { + const message = { + ...baseEnumValueDescriptorProto, + } as EnumValueDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = object.number; + } else { + message.number = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumValueOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseServiceDescriptorProto: object = { name: "" }; + +export const ServiceDescriptorProto = { + encode( + message: ServiceDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + for (const v of message.method) { + MethodDescriptorProto.encode(v!, writer.uint32(18).fork()).ldelim(); + } + if (message.options !== undefined) { + ServiceOptions.encode(message.options, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ServiceDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseServiceDescriptorProto } as ServiceDescriptorProto; + message.method = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.method.push( + MethodDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 3: + message.options = ServiceOptions.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ServiceDescriptorProto { + const message = { ...baseServiceDescriptorProto } as ServiceDescriptorProto; + message.method = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.method !== undefined && object.method !== null) { + for (const e of object.method) { + message.method.push(MethodDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = ServiceOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: ServiceDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + if (message.method) { + obj.method = message.method.map((e) => + e ? MethodDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.method = []; + } + message.options !== undefined && + (obj.options = message.options + ? ServiceOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): ServiceDescriptorProto { + const message = { ...baseServiceDescriptorProto } as ServiceDescriptorProto; + message.method = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.method !== undefined && object.method !== null) { + for (const e of object.method) { + message.method.push(MethodDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = ServiceOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseMethodDescriptorProto: object = { + name: "", + inputType: "", + outputType: "", + clientStreaming: false, + serverStreaming: false, +}; + +export const MethodDescriptorProto = { + encode( + message: MethodDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.inputType !== "") { + writer.uint32(18).string(message.inputType); + } + if (message.outputType !== "") { + writer.uint32(26).string(message.outputType); + } + if (message.options !== undefined) { + MethodOptions.encode(message.options, writer.uint32(34).fork()).ldelim(); + } + if (message.clientStreaming === true) { + writer.uint32(40).bool(message.clientStreaming); + } + if (message.serverStreaming === true) { + writer.uint32(48).bool(message.serverStreaming); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MethodDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMethodDescriptorProto } as MethodDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.inputType = reader.string(); + break; + case 3: + message.outputType = reader.string(); + break; + case 4: + message.options = MethodOptions.decode(reader, reader.uint32()); + break; + case 5: + message.clientStreaming = reader.bool(); + break; + case 6: + message.serverStreaming = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MethodDescriptorProto { + const message = { ...baseMethodDescriptorProto } as MethodDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.inputType !== undefined && object.inputType !== null) { + message.inputType = String(object.inputType); + } else { + message.inputType = ""; + } + if (object.outputType !== undefined && object.outputType !== null) { + message.outputType = String(object.outputType); + } else { + message.outputType = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = MethodOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if ( + object.clientStreaming !== undefined && + object.clientStreaming !== null + ) { + message.clientStreaming = Boolean(object.clientStreaming); + } else { + message.clientStreaming = false; + } + if ( + object.serverStreaming !== undefined && + object.serverStreaming !== null + ) { + message.serverStreaming = Boolean(object.serverStreaming); + } else { + message.serverStreaming = false; + } + return message; + }, + + toJSON(message: MethodDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.inputType !== undefined && (obj.inputType = message.inputType); + message.outputType !== undefined && (obj.outputType = message.outputType); + message.options !== undefined && + (obj.options = message.options + ? MethodOptions.toJSON(message.options) + : undefined); + message.clientStreaming !== undefined && + (obj.clientStreaming = message.clientStreaming); + message.serverStreaming !== undefined && + (obj.serverStreaming = message.serverStreaming); + return obj; + }, + + fromPartial( + object: DeepPartial + ): MethodDescriptorProto { + const message = { ...baseMethodDescriptorProto } as MethodDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.inputType !== undefined && object.inputType !== null) { + message.inputType = object.inputType; + } else { + message.inputType = ""; + } + if (object.outputType !== undefined && object.outputType !== null) { + message.outputType = object.outputType; + } else { + message.outputType = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = MethodOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if ( + object.clientStreaming !== undefined && + object.clientStreaming !== null + ) { + message.clientStreaming = object.clientStreaming; + } else { + message.clientStreaming = false; + } + if ( + object.serverStreaming !== undefined && + object.serverStreaming !== null + ) { + message.serverStreaming = object.serverStreaming; + } else { + message.serverStreaming = false; + } + return message; + }, +}; + +const baseFileOptions: object = { + javaPackage: "", + javaOuterClassname: "", + javaMultipleFiles: false, + javaGenerateEqualsAndHash: false, + javaStringCheckUtf8: false, + optimizeFor: 1, + goPackage: "", + ccGenericServices: false, + javaGenericServices: false, + pyGenericServices: false, + phpGenericServices: false, + deprecated: false, + ccEnableArenas: false, + objcClassPrefix: "", + csharpNamespace: "", + swiftPrefix: "", + phpClassPrefix: "", + phpNamespace: "", + phpMetadataNamespace: "", + rubyPackage: "", +}; + +export const FileOptions = { + encode(message: FileOptions, writer: Writer = Writer.create()): Writer { + if (message.javaPackage !== "") { + writer.uint32(10).string(message.javaPackage); + } + if (message.javaOuterClassname !== "") { + writer.uint32(66).string(message.javaOuterClassname); + } + if (message.javaMultipleFiles === true) { + writer.uint32(80).bool(message.javaMultipleFiles); + } + if (message.javaGenerateEqualsAndHash === true) { + writer.uint32(160).bool(message.javaGenerateEqualsAndHash); + } + if (message.javaStringCheckUtf8 === true) { + writer.uint32(216).bool(message.javaStringCheckUtf8); + } + if (message.optimizeFor !== 1) { + writer.uint32(72).int32(message.optimizeFor); + } + if (message.goPackage !== "") { + writer.uint32(90).string(message.goPackage); + } + if (message.ccGenericServices === true) { + writer.uint32(128).bool(message.ccGenericServices); + } + if (message.javaGenericServices === true) { + writer.uint32(136).bool(message.javaGenericServices); + } + if (message.pyGenericServices === true) { + writer.uint32(144).bool(message.pyGenericServices); + } + if (message.phpGenericServices === true) { + writer.uint32(336).bool(message.phpGenericServices); + } + if (message.deprecated === true) { + writer.uint32(184).bool(message.deprecated); + } + if (message.ccEnableArenas === true) { + writer.uint32(248).bool(message.ccEnableArenas); + } + if (message.objcClassPrefix !== "") { + writer.uint32(290).string(message.objcClassPrefix); + } + if (message.csharpNamespace !== "") { + writer.uint32(298).string(message.csharpNamespace); + } + if (message.swiftPrefix !== "") { + writer.uint32(314).string(message.swiftPrefix); + } + if (message.phpClassPrefix !== "") { + writer.uint32(322).string(message.phpClassPrefix); + } + if (message.phpNamespace !== "") { + writer.uint32(330).string(message.phpNamespace); + } + if (message.phpMetadataNamespace !== "") { + writer.uint32(354).string(message.phpMetadataNamespace); + } + if (message.rubyPackage !== "") { + writer.uint32(362).string(message.rubyPackage); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FileOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFileOptions } as FileOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.javaPackage = reader.string(); + break; + case 8: + message.javaOuterClassname = reader.string(); + break; + case 10: + message.javaMultipleFiles = reader.bool(); + break; + case 20: + message.javaGenerateEqualsAndHash = reader.bool(); + break; + case 27: + message.javaStringCheckUtf8 = reader.bool(); + break; + case 9: + message.optimizeFor = reader.int32() as any; + break; + case 11: + message.goPackage = reader.string(); + break; + case 16: + message.ccGenericServices = reader.bool(); + break; + case 17: + message.javaGenericServices = reader.bool(); + break; + case 18: + message.pyGenericServices = reader.bool(); + break; + case 42: + message.phpGenericServices = reader.bool(); + break; + case 23: + message.deprecated = reader.bool(); + break; + case 31: + message.ccEnableArenas = reader.bool(); + break; + case 36: + message.objcClassPrefix = reader.string(); + break; + case 37: + message.csharpNamespace = reader.string(); + break; + case 39: + message.swiftPrefix = reader.string(); + break; + case 40: + message.phpClassPrefix = reader.string(); + break; + case 41: + message.phpNamespace = reader.string(); + break; + case 44: + message.phpMetadataNamespace = reader.string(); + break; + case 45: + message.rubyPackage = reader.string(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FileOptions { + const message = { ...baseFileOptions } as FileOptions; + message.uninterpretedOption = []; + if (object.javaPackage !== undefined && object.javaPackage !== null) { + message.javaPackage = String(object.javaPackage); + } else { + message.javaPackage = ""; + } + if ( + object.javaOuterClassname !== undefined && + object.javaOuterClassname !== null + ) { + message.javaOuterClassname = String(object.javaOuterClassname); + } else { + message.javaOuterClassname = ""; + } + if ( + object.javaMultipleFiles !== undefined && + object.javaMultipleFiles !== null + ) { + message.javaMultipleFiles = Boolean(object.javaMultipleFiles); + } else { + message.javaMultipleFiles = false; + } + if ( + object.javaGenerateEqualsAndHash !== undefined && + object.javaGenerateEqualsAndHash !== null + ) { + message.javaGenerateEqualsAndHash = Boolean( + object.javaGenerateEqualsAndHash + ); + } else { + message.javaGenerateEqualsAndHash = false; + } + if ( + object.javaStringCheckUtf8 !== undefined && + object.javaStringCheckUtf8 !== null + ) { + message.javaStringCheckUtf8 = Boolean(object.javaStringCheckUtf8); + } else { + message.javaStringCheckUtf8 = false; + } + if (object.optimizeFor !== undefined && object.optimizeFor !== null) { + message.optimizeFor = fileOptions_OptimizeModeFromJSON( + object.optimizeFor + ); + } else { + message.optimizeFor = 1; + } + if (object.goPackage !== undefined && object.goPackage !== null) { + message.goPackage = String(object.goPackage); + } else { + message.goPackage = ""; + } + if ( + object.ccGenericServices !== undefined && + object.ccGenericServices !== null + ) { + message.ccGenericServices = Boolean(object.ccGenericServices); + } else { + message.ccGenericServices = false; + } + if ( + object.javaGenericServices !== undefined && + object.javaGenericServices !== null + ) { + message.javaGenericServices = Boolean(object.javaGenericServices); + } else { + message.javaGenericServices = false; + } + if ( + object.pyGenericServices !== undefined && + object.pyGenericServices !== null + ) { + message.pyGenericServices = Boolean(object.pyGenericServices); + } else { + message.pyGenericServices = false; + } + if ( + object.phpGenericServices !== undefined && + object.phpGenericServices !== null + ) { + message.phpGenericServices = Boolean(object.phpGenericServices); + } else { + message.phpGenericServices = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if (object.ccEnableArenas !== undefined && object.ccEnableArenas !== null) { + message.ccEnableArenas = Boolean(object.ccEnableArenas); + } else { + message.ccEnableArenas = false; + } + if ( + object.objcClassPrefix !== undefined && + object.objcClassPrefix !== null + ) { + message.objcClassPrefix = String(object.objcClassPrefix); + } else { + message.objcClassPrefix = ""; + } + if ( + object.csharpNamespace !== undefined && + object.csharpNamespace !== null + ) { + message.csharpNamespace = String(object.csharpNamespace); + } else { + message.csharpNamespace = ""; + } + if (object.swiftPrefix !== undefined && object.swiftPrefix !== null) { + message.swiftPrefix = String(object.swiftPrefix); + } else { + message.swiftPrefix = ""; + } + if (object.phpClassPrefix !== undefined && object.phpClassPrefix !== null) { + message.phpClassPrefix = String(object.phpClassPrefix); + } else { + message.phpClassPrefix = ""; + } + if (object.phpNamespace !== undefined && object.phpNamespace !== null) { + message.phpNamespace = String(object.phpNamespace); + } else { + message.phpNamespace = ""; + } + if ( + object.phpMetadataNamespace !== undefined && + object.phpMetadataNamespace !== null + ) { + message.phpMetadataNamespace = String(object.phpMetadataNamespace); + } else { + message.phpMetadataNamespace = ""; + } + if (object.rubyPackage !== undefined && object.rubyPackage !== null) { + message.rubyPackage = String(object.rubyPackage); + } else { + message.rubyPackage = ""; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: FileOptions): unknown { + const obj: any = {}; + message.javaPackage !== undefined && + (obj.javaPackage = message.javaPackage); + message.javaOuterClassname !== undefined && + (obj.javaOuterClassname = message.javaOuterClassname); + message.javaMultipleFiles !== undefined && + (obj.javaMultipleFiles = message.javaMultipleFiles); + message.javaGenerateEqualsAndHash !== undefined && + (obj.javaGenerateEqualsAndHash = message.javaGenerateEqualsAndHash); + message.javaStringCheckUtf8 !== undefined && + (obj.javaStringCheckUtf8 = message.javaStringCheckUtf8); + message.optimizeFor !== undefined && + (obj.optimizeFor = fileOptions_OptimizeModeToJSON(message.optimizeFor)); + message.goPackage !== undefined && (obj.goPackage = message.goPackage); + message.ccGenericServices !== undefined && + (obj.ccGenericServices = message.ccGenericServices); + message.javaGenericServices !== undefined && + (obj.javaGenericServices = message.javaGenericServices); + message.pyGenericServices !== undefined && + (obj.pyGenericServices = message.pyGenericServices); + message.phpGenericServices !== undefined && + (obj.phpGenericServices = message.phpGenericServices); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.ccEnableArenas !== undefined && + (obj.ccEnableArenas = message.ccEnableArenas); + message.objcClassPrefix !== undefined && + (obj.objcClassPrefix = message.objcClassPrefix); + message.csharpNamespace !== undefined && + (obj.csharpNamespace = message.csharpNamespace); + message.swiftPrefix !== undefined && + (obj.swiftPrefix = message.swiftPrefix); + message.phpClassPrefix !== undefined && + (obj.phpClassPrefix = message.phpClassPrefix); + message.phpNamespace !== undefined && + (obj.phpNamespace = message.phpNamespace); + message.phpMetadataNamespace !== undefined && + (obj.phpMetadataNamespace = message.phpMetadataNamespace); + message.rubyPackage !== undefined && + (obj.rubyPackage = message.rubyPackage); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): FileOptions { + const message = { ...baseFileOptions } as FileOptions; + message.uninterpretedOption = []; + if (object.javaPackage !== undefined && object.javaPackage !== null) { + message.javaPackage = object.javaPackage; + } else { + message.javaPackage = ""; + } + if ( + object.javaOuterClassname !== undefined && + object.javaOuterClassname !== null + ) { + message.javaOuterClassname = object.javaOuterClassname; + } else { + message.javaOuterClassname = ""; + } + if ( + object.javaMultipleFiles !== undefined && + object.javaMultipleFiles !== null + ) { + message.javaMultipleFiles = object.javaMultipleFiles; + } else { + message.javaMultipleFiles = false; + } + if ( + object.javaGenerateEqualsAndHash !== undefined && + object.javaGenerateEqualsAndHash !== null + ) { + message.javaGenerateEqualsAndHash = object.javaGenerateEqualsAndHash; + } else { + message.javaGenerateEqualsAndHash = false; + } + if ( + object.javaStringCheckUtf8 !== undefined && + object.javaStringCheckUtf8 !== null + ) { + message.javaStringCheckUtf8 = object.javaStringCheckUtf8; + } else { + message.javaStringCheckUtf8 = false; + } + if (object.optimizeFor !== undefined && object.optimizeFor !== null) { + message.optimizeFor = object.optimizeFor; + } else { + message.optimizeFor = 1; + } + if (object.goPackage !== undefined && object.goPackage !== null) { + message.goPackage = object.goPackage; + } else { + message.goPackage = ""; + } + if ( + object.ccGenericServices !== undefined && + object.ccGenericServices !== null + ) { + message.ccGenericServices = object.ccGenericServices; + } else { + message.ccGenericServices = false; + } + if ( + object.javaGenericServices !== undefined && + object.javaGenericServices !== null + ) { + message.javaGenericServices = object.javaGenericServices; + } else { + message.javaGenericServices = false; + } + if ( + object.pyGenericServices !== undefined && + object.pyGenericServices !== null + ) { + message.pyGenericServices = object.pyGenericServices; + } else { + message.pyGenericServices = false; + } + if ( + object.phpGenericServices !== undefined && + object.phpGenericServices !== null + ) { + message.phpGenericServices = object.phpGenericServices; + } else { + message.phpGenericServices = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if (object.ccEnableArenas !== undefined && object.ccEnableArenas !== null) { + message.ccEnableArenas = object.ccEnableArenas; + } else { + message.ccEnableArenas = false; + } + if ( + object.objcClassPrefix !== undefined && + object.objcClassPrefix !== null + ) { + message.objcClassPrefix = object.objcClassPrefix; + } else { + message.objcClassPrefix = ""; + } + if ( + object.csharpNamespace !== undefined && + object.csharpNamespace !== null + ) { + message.csharpNamespace = object.csharpNamespace; + } else { + message.csharpNamespace = ""; + } + if (object.swiftPrefix !== undefined && object.swiftPrefix !== null) { + message.swiftPrefix = object.swiftPrefix; + } else { + message.swiftPrefix = ""; + } + if (object.phpClassPrefix !== undefined && object.phpClassPrefix !== null) { + message.phpClassPrefix = object.phpClassPrefix; + } else { + message.phpClassPrefix = ""; + } + if (object.phpNamespace !== undefined && object.phpNamespace !== null) { + message.phpNamespace = object.phpNamespace; + } else { + message.phpNamespace = ""; + } + if ( + object.phpMetadataNamespace !== undefined && + object.phpMetadataNamespace !== null + ) { + message.phpMetadataNamespace = object.phpMetadataNamespace; + } else { + message.phpMetadataNamespace = ""; + } + if (object.rubyPackage !== undefined && object.rubyPackage !== null) { + message.rubyPackage = object.rubyPackage; + } else { + message.rubyPackage = ""; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseMessageOptions: object = { + messageSetWireFormat: false, + noStandardDescriptorAccessor: false, + deprecated: false, + mapEntry: false, +}; + +export const MessageOptions = { + encode(message: MessageOptions, writer: Writer = Writer.create()): Writer { + if (message.messageSetWireFormat === true) { + writer.uint32(8).bool(message.messageSetWireFormat); + } + if (message.noStandardDescriptorAccessor === true) { + writer.uint32(16).bool(message.noStandardDescriptorAccessor); + } + if (message.deprecated === true) { + writer.uint32(24).bool(message.deprecated); + } + if (message.mapEntry === true) { + writer.uint32(56).bool(message.mapEntry); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MessageOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMessageOptions } as MessageOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.messageSetWireFormat = reader.bool(); + break; + case 2: + message.noStandardDescriptorAccessor = reader.bool(); + break; + case 3: + message.deprecated = reader.bool(); + break; + case 7: + message.mapEntry = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MessageOptions { + const message = { ...baseMessageOptions } as MessageOptions; + message.uninterpretedOption = []; + if ( + object.messageSetWireFormat !== undefined && + object.messageSetWireFormat !== null + ) { + message.messageSetWireFormat = Boolean(object.messageSetWireFormat); + } else { + message.messageSetWireFormat = false; + } + if ( + object.noStandardDescriptorAccessor !== undefined && + object.noStandardDescriptorAccessor !== null + ) { + message.noStandardDescriptorAccessor = Boolean( + object.noStandardDescriptorAccessor + ); + } else { + message.noStandardDescriptorAccessor = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if (object.mapEntry !== undefined && object.mapEntry !== null) { + message.mapEntry = Boolean(object.mapEntry); + } else { + message.mapEntry = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: MessageOptions): unknown { + const obj: any = {}; + message.messageSetWireFormat !== undefined && + (obj.messageSetWireFormat = message.messageSetWireFormat); + message.noStandardDescriptorAccessor !== undefined && + (obj.noStandardDescriptorAccessor = message.noStandardDescriptorAccessor); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.mapEntry !== undefined && (obj.mapEntry = message.mapEntry); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): MessageOptions { + const message = { ...baseMessageOptions } as MessageOptions; + message.uninterpretedOption = []; + if ( + object.messageSetWireFormat !== undefined && + object.messageSetWireFormat !== null + ) { + message.messageSetWireFormat = object.messageSetWireFormat; + } else { + message.messageSetWireFormat = false; + } + if ( + object.noStandardDescriptorAccessor !== undefined && + object.noStandardDescriptorAccessor !== null + ) { + message.noStandardDescriptorAccessor = + object.noStandardDescriptorAccessor; + } else { + message.noStandardDescriptorAccessor = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if (object.mapEntry !== undefined && object.mapEntry !== null) { + message.mapEntry = object.mapEntry; + } else { + message.mapEntry = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseFieldOptions: object = { + ctype: 0, + packed: false, + jstype: 0, + lazy: false, + deprecated: false, + weak: false, +}; + +export const FieldOptions = { + encode(message: FieldOptions, writer: Writer = Writer.create()): Writer { + if (message.ctype !== 0) { + writer.uint32(8).int32(message.ctype); + } + if (message.packed === true) { + writer.uint32(16).bool(message.packed); + } + if (message.jstype !== 0) { + writer.uint32(48).int32(message.jstype); + } + if (message.lazy === true) { + writer.uint32(40).bool(message.lazy); + } + if (message.deprecated === true) { + writer.uint32(24).bool(message.deprecated); + } + if (message.weak === true) { + writer.uint32(80).bool(message.weak); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FieldOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFieldOptions } as FieldOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.ctype = reader.int32() as any; + break; + case 2: + message.packed = reader.bool(); + break; + case 6: + message.jstype = reader.int32() as any; + break; + case 5: + message.lazy = reader.bool(); + break; + case 3: + message.deprecated = reader.bool(); + break; + case 10: + message.weak = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FieldOptions { + const message = { ...baseFieldOptions } as FieldOptions; + message.uninterpretedOption = []; + if (object.ctype !== undefined && object.ctype !== null) { + message.ctype = fieldOptions_CTypeFromJSON(object.ctype); + } else { + message.ctype = 0; + } + if (object.packed !== undefined && object.packed !== null) { + message.packed = Boolean(object.packed); + } else { + message.packed = false; + } + if (object.jstype !== undefined && object.jstype !== null) { + message.jstype = fieldOptions_JSTypeFromJSON(object.jstype); + } else { + message.jstype = 0; + } + if (object.lazy !== undefined && object.lazy !== null) { + message.lazy = Boolean(object.lazy); + } else { + message.lazy = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if (object.weak !== undefined && object.weak !== null) { + message.weak = Boolean(object.weak); + } else { + message.weak = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: FieldOptions): unknown { + const obj: any = {}; + message.ctype !== undefined && + (obj.ctype = fieldOptions_CTypeToJSON(message.ctype)); + message.packed !== undefined && (obj.packed = message.packed); + message.jstype !== undefined && + (obj.jstype = fieldOptions_JSTypeToJSON(message.jstype)); + message.lazy !== undefined && (obj.lazy = message.lazy); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.weak !== undefined && (obj.weak = message.weak); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): FieldOptions { + const message = { ...baseFieldOptions } as FieldOptions; + message.uninterpretedOption = []; + if (object.ctype !== undefined && object.ctype !== null) { + message.ctype = object.ctype; + } else { + message.ctype = 0; + } + if (object.packed !== undefined && object.packed !== null) { + message.packed = object.packed; + } else { + message.packed = false; + } + if (object.jstype !== undefined && object.jstype !== null) { + message.jstype = object.jstype; + } else { + message.jstype = 0; + } + if (object.lazy !== undefined && object.lazy !== null) { + message.lazy = object.lazy; + } else { + message.lazy = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if (object.weak !== undefined && object.weak !== null) { + message.weak = object.weak; + } else { + message.weak = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseOneofOptions: object = {}; + +export const OneofOptions = { + encode(message: OneofOptions, writer: Writer = Writer.create()): Writer { + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): OneofOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseOneofOptions } as OneofOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): OneofOptions { + const message = { ...baseOneofOptions } as OneofOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: OneofOptions): unknown { + const obj: any = {}; + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): OneofOptions { + const message = { ...baseOneofOptions } as OneofOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseEnumOptions: object = { allowAlias: false, deprecated: false }; + +export const EnumOptions = { + encode(message: EnumOptions, writer: Writer = Writer.create()): Writer { + if (message.allowAlias === true) { + writer.uint32(16).bool(message.allowAlias); + } + if (message.deprecated === true) { + writer.uint32(24).bool(message.deprecated); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): EnumOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseEnumOptions } as EnumOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + message.allowAlias = reader.bool(); + break; + case 3: + message.deprecated = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumOptions { + const message = { ...baseEnumOptions } as EnumOptions; + message.uninterpretedOption = []; + if (object.allowAlias !== undefined && object.allowAlias !== null) { + message.allowAlias = Boolean(object.allowAlias); + } else { + message.allowAlias = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: EnumOptions): unknown { + const obj: any = {}; + message.allowAlias !== undefined && (obj.allowAlias = message.allowAlias); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): EnumOptions { + const message = { ...baseEnumOptions } as EnumOptions; + message.uninterpretedOption = []; + if (object.allowAlias !== undefined && object.allowAlias !== null) { + message.allowAlias = object.allowAlias; + } else { + message.allowAlias = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseEnumValueOptions: object = { deprecated: false }; + +export const EnumValueOptions = { + encode(message: EnumValueOptions, writer: Writer = Writer.create()): Writer { + if (message.deprecated === true) { + writer.uint32(8).bool(message.deprecated); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): EnumValueOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseEnumValueOptions } as EnumValueOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.deprecated = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumValueOptions { + const message = { ...baseEnumValueOptions } as EnumValueOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: EnumValueOptions): unknown { + const obj: any = {}; + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): EnumValueOptions { + const message = { ...baseEnumValueOptions } as EnumValueOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseServiceOptions: object = { deprecated: false }; + +export const ServiceOptions = { + encode(message: ServiceOptions, writer: Writer = Writer.create()): Writer { + if (message.deprecated === true) { + writer.uint32(264).bool(message.deprecated); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ServiceOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseServiceOptions } as ServiceOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 33: + message.deprecated = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ServiceOptions { + const message = { ...baseServiceOptions } as ServiceOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: ServiceOptions): unknown { + const obj: any = {}; + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): ServiceOptions { + const message = { ...baseServiceOptions } as ServiceOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseMethodOptions: object = { deprecated: false, idempotencyLevel: 0 }; + +export const MethodOptions = { + encode(message: MethodOptions, writer: Writer = Writer.create()): Writer { + if (message.deprecated === true) { + writer.uint32(264).bool(message.deprecated); + } + if (message.idempotencyLevel !== 0) { + writer.uint32(272).int32(message.idempotencyLevel); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MethodOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMethodOptions } as MethodOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 33: + message.deprecated = reader.bool(); + break; + case 34: + message.idempotencyLevel = reader.int32() as any; + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MethodOptions { + const message = { ...baseMethodOptions } as MethodOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.idempotencyLevel !== undefined && + object.idempotencyLevel !== null + ) { + message.idempotencyLevel = methodOptions_IdempotencyLevelFromJSON( + object.idempotencyLevel + ); + } else { + message.idempotencyLevel = 0; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: MethodOptions): unknown { + const obj: any = {}; + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.idempotencyLevel !== undefined && + (obj.idempotencyLevel = methodOptions_IdempotencyLevelToJSON( + message.idempotencyLevel + )); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): MethodOptions { + const message = { ...baseMethodOptions } as MethodOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.idempotencyLevel !== undefined && + object.idempotencyLevel !== null + ) { + message.idempotencyLevel = object.idempotencyLevel; + } else { + message.idempotencyLevel = 0; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseUninterpretedOption: object = { + identifierValue: "", + positiveIntValue: 0, + negativeIntValue: 0, + doubleValue: 0, + aggregateValue: "", +}; + +export const UninterpretedOption = { + encode( + message: UninterpretedOption, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.name) { + UninterpretedOption_NamePart.encode( + v!, + writer.uint32(18).fork() + ).ldelim(); + } + if (message.identifierValue !== "") { + writer.uint32(26).string(message.identifierValue); + } + if (message.positiveIntValue !== 0) { + writer.uint32(32).uint64(message.positiveIntValue); + } + if (message.negativeIntValue !== 0) { + writer.uint32(40).int64(message.negativeIntValue); + } + if (message.doubleValue !== 0) { + writer.uint32(49).double(message.doubleValue); + } + if (message.stringValue.length !== 0) { + writer.uint32(58).bytes(message.stringValue); + } + if (message.aggregateValue !== "") { + writer.uint32(66).string(message.aggregateValue); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): UninterpretedOption { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseUninterpretedOption } as UninterpretedOption; + message.name = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + message.name.push( + UninterpretedOption_NamePart.decode(reader, reader.uint32()) + ); + break; + case 3: + message.identifierValue = reader.string(); + break; + case 4: + message.positiveIntValue = longToNumber(reader.uint64() as Long); + break; + case 5: + message.negativeIntValue = longToNumber(reader.int64() as Long); + break; + case 6: + message.doubleValue = reader.double(); + break; + case 7: + message.stringValue = reader.bytes(); + break; + case 8: + message.aggregateValue = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): UninterpretedOption { + const message = { ...baseUninterpretedOption } as UninterpretedOption; + message.name = []; + if (object.name !== undefined && object.name !== null) { + for (const e of object.name) { + message.name.push(UninterpretedOption_NamePart.fromJSON(e)); + } + } + if ( + object.identifierValue !== undefined && + object.identifierValue !== null + ) { + message.identifierValue = String(object.identifierValue); + } else { + message.identifierValue = ""; + } + if ( + object.positiveIntValue !== undefined && + object.positiveIntValue !== null + ) { + message.positiveIntValue = Number(object.positiveIntValue); + } else { + message.positiveIntValue = 0; + } + if ( + object.negativeIntValue !== undefined && + object.negativeIntValue !== null + ) { + message.negativeIntValue = Number(object.negativeIntValue); + } else { + message.negativeIntValue = 0; + } + if (object.doubleValue !== undefined && object.doubleValue !== null) { + message.doubleValue = Number(object.doubleValue); + } else { + message.doubleValue = 0; + } + if (object.stringValue !== undefined && object.stringValue !== null) { + message.stringValue = bytesFromBase64(object.stringValue); + } + if (object.aggregateValue !== undefined && object.aggregateValue !== null) { + message.aggregateValue = String(object.aggregateValue); + } else { + message.aggregateValue = ""; + } + return message; + }, + + toJSON(message: UninterpretedOption): unknown { + const obj: any = {}; + if (message.name) { + obj.name = message.name.map((e) => + e ? UninterpretedOption_NamePart.toJSON(e) : undefined + ); + } else { + obj.name = []; + } + message.identifierValue !== undefined && + (obj.identifierValue = message.identifierValue); + message.positiveIntValue !== undefined && + (obj.positiveIntValue = message.positiveIntValue); + message.negativeIntValue !== undefined && + (obj.negativeIntValue = message.negativeIntValue); + message.doubleValue !== undefined && + (obj.doubleValue = message.doubleValue); + message.stringValue !== undefined && + (obj.stringValue = base64FromBytes( + message.stringValue !== undefined + ? message.stringValue + : new Uint8Array() + )); + message.aggregateValue !== undefined && + (obj.aggregateValue = message.aggregateValue); + return obj; + }, + + fromPartial(object: DeepPartial): UninterpretedOption { + const message = { ...baseUninterpretedOption } as UninterpretedOption; + message.name = []; + if (object.name !== undefined && object.name !== null) { + for (const e of object.name) { + message.name.push(UninterpretedOption_NamePart.fromPartial(e)); + } + } + if ( + object.identifierValue !== undefined && + object.identifierValue !== null + ) { + message.identifierValue = object.identifierValue; + } else { + message.identifierValue = ""; + } + if ( + object.positiveIntValue !== undefined && + object.positiveIntValue !== null + ) { + message.positiveIntValue = object.positiveIntValue; + } else { + message.positiveIntValue = 0; + } + if ( + object.negativeIntValue !== undefined && + object.negativeIntValue !== null + ) { + message.negativeIntValue = object.negativeIntValue; + } else { + message.negativeIntValue = 0; + } + if (object.doubleValue !== undefined && object.doubleValue !== null) { + message.doubleValue = object.doubleValue; + } else { + message.doubleValue = 0; + } + if (object.stringValue !== undefined && object.stringValue !== null) { + message.stringValue = object.stringValue; + } else { + message.stringValue = new Uint8Array(); + } + if (object.aggregateValue !== undefined && object.aggregateValue !== null) { + message.aggregateValue = object.aggregateValue; + } else { + message.aggregateValue = ""; + } + return message; + }, +}; + +const baseUninterpretedOption_NamePart: object = { + namePart: "", + isExtension: false, +}; + +export const UninterpretedOption_NamePart = { + encode( + message: UninterpretedOption_NamePart, + writer: Writer = Writer.create() + ): Writer { + if (message.namePart !== "") { + writer.uint32(10).string(message.namePart); + } + if (message.isExtension === true) { + writer.uint32(16).bool(message.isExtension); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): UninterpretedOption_NamePart { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseUninterpretedOption_NamePart, + } as UninterpretedOption_NamePart; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.namePart = reader.string(); + break; + case 2: + message.isExtension = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): UninterpretedOption_NamePart { + const message = { + ...baseUninterpretedOption_NamePart, + } as UninterpretedOption_NamePart; + if (object.namePart !== undefined && object.namePart !== null) { + message.namePart = String(object.namePart); + } else { + message.namePart = ""; + } + if (object.isExtension !== undefined && object.isExtension !== null) { + message.isExtension = Boolean(object.isExtension); + } else { + message.isExtension = false; + } + return message; + }, + + toJSON(message: UninterpretedOption_NamePart): unknown { + const obj: any = {}; + message.namePart !== undefined && (obj.namePart = message.namePart); + message.isExtension !== undefined && + (obj.isExtension = message.isExtension); + return obj; + }, + + fromPartial( + object: DeepPartial + ): UninterpretedOption_NamePart { + const message = { + ...baseUninterpretedOption_NamePart, + } as UninterpretedOption_NamePart; + if (object.namePart !== undefined && object.namePart !== null) { + message.namePart = object.namePart; + } else { + message.namePart = ""; + } + if (object.isExtension !== undefined && object.isExtension !== null) { + message.isExtension = object.isExtension; + } else { + message.isExtension = false; + } + return message; + }, +}; + +const baseSourceCodeInfo: object = {}; + +export const SourceCodeInfo = { + encode(message: SourceCodeInfo, writer: Writer = Writer.create()): Writer { + for (const v of message.location) { + SourceCodeInfo_Location.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): SourceCodeInfo { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseSourceCodeInfo } as SourceCodeInfo; + message.location = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.location.push( + SourceCodeInfo_Location.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): SourceCodeInfo { + const message = { ...baseSourceCodeInfo } as SourceCodeInfo; + message.location = []; + if (object.location !== undefined && object.location !== null) { + for (const e of object.location) { + message.location.push(SourceCodeInfo_Location.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: SourceCodeInfo): unknown { + const obj: any = {}; + if (message.location) { + obj.location = message.location.map((e) => + e ? SourceCodeInfo_Location.toJSON(e) : undefined + ); + } else { + obj.location = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): SourceCodeInfo { + const message = { ...baseSourceCodeInfo } as SourceCodeInfo; + message.location = []; + if (object.location !== undefined && object.location !== null) { + for (const e of object.location) { + message.location.push(SourceCodeInfo_Location.fromPartial(e)); + } + } + return message; + }, +}; + +const baseSourceCodeInfo_Location: object = { + path: 0, + span: 0, + leadingComments: "", + trailingComments: "", + leadingDetachedComments: "", +}; + +export const SourceCodeInfo_Location = { + encode( + message: SourceCodeInfo_Location, + writer: Writer = Writer.create() + ): Writer { + writer.uint32(10).fork(); + for (const v of message.path) { + writer.int32(v); + } + writer.ldelim(); + writer.uint32(18).fork(); + for (const v of message.span) { + writer.int32(v); + } + writer.ldelim(); + if (message.leadingComments !== "") { + writer.uint32(26).string(message.leadingComments); + } + if (message.trailingComments !== "") { + writer.uint32(34).string(message.trailingComments); + } + for (const v of message.leadingDetachedComments) { + writer.uint32(50).string(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): SourceCodeInfo_Location { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseSourceCodeInfo_Location, + } as SourceCodeInfo_Location; + message.path = []; + message.span = []; + message.leadingDetachedComments = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.path.push(reader.int32()); + } + } else { + message.path.push(reader.int32()); + } + break; + case 2: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.span.push(reader.int32()); + } + } else { + message.span.push(reader.int32()); + } + break; + case 3: + message.leadingComments = reader.string(); + break; + case 4: + message.trailingComments = reader.string(); + break; + case 6: + message.leadingDetachedComments.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): SourceCodeInfo_Location { + const message = { + ...baseSourceCodeInfo_Location, + } as SourceCodeInfo_Location; + message.path = []; + message.span = []; + message.leadingDetachedComments = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(Number(e)); + } + } + if (object.span !== undefined && object.span !== null) { + for (const e of object.span) { + message.span.push(Number(e)); + } + } + if ( + object.leadingComments !== undefined && + object.leadingComments !== null + ) { + message.leadingComments = String(object.leadingComments); + } else { + message.leadingComments = ""; + } + if ( + object.trailingComments !== undefined && + object.trailingComments !== null + ) { + message.trailingComments = String(object.trailingComments); + } else { + message.trailingComments = ""; + } + if ( + object.leadingDetachedComments !== undefined && + object.leadingDetachedComments !== null + ) { + for (const e of object.leadingDetachedComments) { + message.leadingDetachedComments.push(String(e)); + } + } + return message; + }, + + toJSON(message: SourceCodeInfo_Location): unknown { + const obj: any = {}; + if (message.path) { + obj.path = message.path.map((e) => e); + } else { + obj.path = []; + } + if (message.span) { + obj.span = message.span.map((e) => e); + } else { + obj.span = []; + } + message.leadingComments !== undefined && + (obj.leadingComments = message.leadingComments); + message.trailingComments !== undefined && + (obj.trailingComments = message.trailingComments); + if (message.leadingDetachedComments) { + obj.leadingDetachedComments = message.leadingDetachedComments.map( + (e) => e + ); + } else { + obj.leadingDetachedComments = []; + } + return obj; + }, + + fromPartial( + object: DeepPartial + ): SourceCodeInfo_Location { + const message = { + ...baseSourceCodeInfo_Location, + } as SourceCodeInfo_Location; + message.path = []; + message.span = []; + message.leadingDetachedComments = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(e); + } + } + if (object.span !== undefined && object.span !== null) { + for (const e of object.span) { + message.span.push(e); + } + } + if ( + object.leadingComments !== undefined && + object.leadingComments !== null + ) { + message.leadingComments = object.leadingComments; + } else { + message.leadingComments = ""; + } + if ( + object.trailingComments !== undefined && + object.trailingComments !== null + ) { + message.trailingComments = object.trailingComments; + } else { + message.trailingComments = ""; + } + if ( + object.leadingDetachedComments !== undefined && + object.leadingDetachedComments !== null + ) { + for (const e of object.leadingDetachedComments) { + message.leadingDetachedComments.push(e); + } + } + return message; + }, +}; + +const baseGeneratedCodeInfo: object = {}; + +export const GeneratedCodeInfo = { + encode(message: GeneratedCodeInfo, writer: Writer = Writer.create()): Writer { + for (const v of message.annotation) { + GeneratedCodeInfo_Annotation.encode( + v!, + writer.uint32(10).fork() + ).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): GeneratedCodeInfo { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseGeneratedCodeInfo } as GeneratedCodeInfo; + message.annotation = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.annotation.push( + GeneratedCodeInfo_Annotation.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GeneratedCodeInfo { + const message = { ...baseGeneratedCodeInfo } as GeneratedCodeInfo; + message.annotation = []; + if (object.annotation !== undefined && object.annotation !== null) { + for (const e of object.annotation) { + message.annotation.push(GeneratedCodeInfo_Annotation.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: GeneratedCodeInfo): unknown { + const obj: any = {}; + if (message.annotation) { + obj.annotation = message.annotation.map((e) => + e ? GeneratedCodeInfo_Annotation.toJSON(e) : undefined + ); + } else { + obj.annotation = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): GeneratedCodeInfo { + const message = { ...baseGeneratedCodeInfo } as GeneratedCodeInfo; + message.annotation = []; + if (object.annotation !== undefined && object.annotation !== null) { + for (const e of object.annotation) { + message.annotation.push(GeneratedCodeInfo_Annotation.fromPartial(e)); + } + } + return message; + }, +}; + +const baseGeneratedCodeInfo_Annotation: object = { + path: 0, + sourceFile: "", + begin: 0, + end: 0, +}; + +export const GeneratedCodeInfo_Annotation = { + encode( + message: GeneratedCodeInfo_Annotation, + writer: Writer = Writer.create() + ): Writer { + writer.uint32(10).fork(); + for (const v of message.path) { + writer.int32(v); + } + writer.ldelim(); + if (message.sourceFile !== "") { + writer.uint32(18).string(message.sourceFile); + } + if (message.begin !== 0) { + writer.uint32(24).int32(message.begin); + } + if (message.end !== 0) { + writer.uint32(32).int32(message.end); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): GeneratedCodeInfo_Annotation { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseGeneratedCodeInfo_Annotation, + } as GeneratedCodeInfo_Annotation; + message.path = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.path.push(reader.int32()); + } + } else { + message.path.push(reader.int32()); + } + break; + case 2: + message.sourceFile = reader.string(); + break; + case 3: + message.begin = reader.int32(); + break; + case 4: + message.end = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GeneratedCodeInfo_Annotation { + const message = { + ...baseGeneratedCodeInfo_Annotation, + } as GeneratedCodeInfo_Annotation; + message.path = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(Number(e)); + } + } + if (object.sourceFile !== undefined && object.sourceFile !== null) { + message.sourceFile = String(object.sourceFile); + } else { + message.sourceFile = ""; + } + if (object.begin !== undefined && object.begin !== null) { + message.begin = Number(object.begin); + } else { + message.begin = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + return message; + }, + + toJSON(message: GeneratedCodeInfo_Annotation): unknown { + const obj: any = {}; + if (message.path) { + obj.path = message.path.map((e) => e); + } else { + obj.path = []; + } + message.sourceFile !== undefined && (obj.sourceFile = message.sourceFile); + message.begin !== undefined && (obj.begin = message.begin); + message.end !== undefined && (obj.end = message.end); + return obj; + }, + + fromPartial( + object: DeepPartial + ): GeneratedCodeInfo_Annotation { + const message = { + ...baseGeneratedCodeInfo_Annotation, + } as GeneratedCodeInfo_Annotation; + message.path = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(e); + } + } + if (object.sourceFile !== undefined && object.sourceFile !== null) { + message.sourceFile = object.sourceFile; + } else { + message.sourceFile = ""; + } + if (object.begin !== undefined && object.begin !== null) { + message.begin = object.begin; + } else { + message.begin = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/bze.cointrunk.v1/index.ts b/ts-client/bze.cointrunk.v1/index.ts new file mode 100755 index 00000000..c9dfa159 --- /dev/null +++ b/ts-client/bze.cointrunk.v1/index.ts @@ -0,0 +1,6 @@ +import Module from './module'; +import { txClient, queryClient, registry } from './module'; +import { msgTypes } from './registry'; + +export * from "./types"; +export { Module, msgTypes, txClient, queryClient, registry }; diff --git a/ts-client/bze.cointrunk.v1/module.ts b/ts-client/bze.cointrunk.v1/module.ts new file mode 100755 index 00000000..23244fb2 --- /dev/null +++ b/ts-client/bze.cointrunk.v1/module.ts @@ -0,0 +1,132 @@ +// Generated by Ignite ignite.com/cli + +import { StdFee } from "@cosmjs/launchpad"; +import { SigningStargateClient, DeliverTxResponse } from "@cosmjs/stargate"; +import { EncodeObject, GeneratedType, OfflineSigner, Registry } from "@cosmjs/proto-signing"; +import { msgTypes } from './registry'; +import { IgniteClient } from "../client" +import { MissingWalletError } from "../helpers" +import { Api } from "./rest"; +import { MsgPayPublisherRespect } from "./types/cointrunk/tx"; +import { MsgAddArticle } from "./types/cointrunk/tx"; + + +export { MsgPayPublisherRespect, MsgAddArticle }; + +type sendMsgPayPublisherRespectParams = { + value: MsgPayPublisherRespect, + fee?: StdFee, + memo?: string +}; + +type sendMsgAddArticleParams = { + value: MsgAddArticle, + fee?: StdFee, + memo?: string +}; + + +type msgPayPublisherRespectParams = { + value: MsgPayPublisherRespect, +}; + +type msgAddArticleParams = { + value: MsgAddArticle, +}; + + +export const registry = new Registry(msgTypes); + +const defaultFee = { + amount: [], + gas: "200000", +}; + +interface TxClientOptions { + addr: string + prefix: string + signer?: OfflineSigner +} + +export const txClient = ({ signer, prefix, addr }: TxClientOptions = { addr: "http://localhost:26657", prefix: "cosmos" }) => { + + return { + + async sendMsgPayPublisherRespect({ value, fee, memo }: sendMsgPayPublisherRespectParams): Promise { + if (!signer) { + throw new Error('TxClient:sendMsgPayPublisherRespect: Unable to sign Tx. Signer is not present.') + } + try { + const { address } = (await signer.getAccounts())[0]; + const signingClient = await SigningStargateClient.connectWithSigner(addr,signer,{registry, prefix}); + let msg = this.msgPayPublisherRespect({ value: MsgPayPublisherRespect.fromPartial(value) }) + return await signingClient.signAndBroadcast(address, [msg], fee ? fee : defaultFee, memo) + } catch (e: any) { + throw new Error('TxClient:sendMsgPayPublisherRespect: Could not broadcast Tx: '+ e.message) + } + }, + + async sendMsgAddArticle({ value, fee, memo }: sendMsgAddArticleParams): Promise { + if (!signer) { + throw new Error('TxClient:sendMsgAddArticle: Unable to sign Tx. Signer is not present.') + } + try { + const { address } = (await signer.getAccounts())[0]; + const signingClient = await SigningStargateClient.connectWithSigner(addr,signer,{registry, prefix}); + let msg = this.msgAddArticle({ value: MsgAddArticle.fromPartial(value) }) + return await signingClient.signAndBroadcast(address, [msg], fee ? fee : defaultFee, memo) + } catch (e: any) { + throw new Error('TxClient:sendMsgAddArticle: Could not broadcast Tx: '+ e.message) + } + }, + + + msgPayPublisherRespect({ value }: msgPayPublisherRespectParams): EncodeObject { + try { + return { typeUrl: "/bze.cointrunk.v1.MsgPayPublisherRespect", value: MsgPayPublisherRespect.fromPartial( value ) } + } catch (e: any) { + throw new Error('TxClient:MsgPayPublisherRespect: Could not create message: ' + e.message) + } + }, + + msgAddArticle({ value }: msgAddArticleParams): EncodeObject { + try { + return { typeUrl: "/bze.cointrunk.v1.MsgAddArticle", value: MsgAddArticle.fromPartial( value ) } + } catch (e: any) { + throw new Error('TxClient:MsgAddArticle: Could not create message: ' + e.message) + } + }, + + } +}; + +interface QueryClientOptions { + addr: string +} + +export const queryClient = ({ addr: addr }: QueryClientOptions = { addr: "http://localhost:1317" }) => { + return new Api({ baseUrl: addr }); +}; + +class SDKModule { + public query: ReturnType; + public tx: ReturnType; + + public registry: Array<[string, GeneratedType]>; + + constructor(client: IgniteClient) { + + this.query = queryClient({ addr: client.env.apiURL }); + this.tx = txClient({ signer: client.signer, addr: client.env.rpcURL, prefix: client.env.prefix ?? "cosmos" }); + } +}; + +const Module = (test: IgniteClient) => { + return { + module: { + BzeCointrunkV1: new SDKModule(test) + }, + registry: msgTypes + } +} +export default Module; \ No newline at end of file diff --git a/ts-client/bze.cointrunk.v1/registry.ts b/ts-client/bze.cointrunk.v1/registry.ts new file mode 100755 index 00000000..c5b91fe3 --- /dev/null +++ b/ts-client/bze.cointrunk.v1/registry.ts @@ -0,0 +1,11 @@ +import { GeneratedType } from "@cosmjs/proto-signing"; +import { MsgPayPublisherRespect } from "./types/cointrunk/tx"; +import { MsgAddArticle } from "./types/cointrunk/tx"; + +const msgTypes: Array<[string, GeneratedType]> = [ + ["/bze.cointrunk.v1.MsgPayPublisherRespect", MsgPayPublisherRespect], + ["/bze.cointrunk.v1.MsgAddArticle", MsgAddArticle], + +]; + +export { msgTypes } \ No newline at end of file diff --git a/ts-client/bze.cointrunk.v1/rest.ts b/ts-client/bze.cointrunk.v1/rest.ts new file mode 100644 index 00000000..aa0513e4 --- /dev/null +++ b/ts-client/bze.cointrunk.v1/rest.ts @@ -0,0 +1,577 @@ +/* eslint-disable */ +/* tslint:disable */ +/* + * --------------------------------------------------------------- + * ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ## + * ## ## + * ## AUTHOR: acacode ## + * ## SOURCE: https://github.com/acacode/swagger-typescript-api ## + * --------------------------------------------------------------- + */ + +export interface Cointrunkv1AcceptedDomain { + domain?: string; + active?: boolean; +} + +export interface Cointrunkv1Params { + /** @format uint64 */ + anon_article_limit?: string; + + /** + * Coin defines a token with a denomination and an amount. + * + * NOTE: The amount field is an Int which implements the custom method + * signatures required by gogoproto. + */ + anon_article_cost?: V1Beta1Coin; + + /** Params defines the parameters for the module. */ + publisher_respect_params?: V1PublisherRespectParams; +} + +export interface Cointrunkv1Publisher { + name?: string; + address?: string; + active?: boolean; + + /** @format int64 */ + articles_count?: number; + + /** @format int64 */ + created_at?: string; + + /** @format int64 */ + respect?: string; +} + +export interface ProtobufAny { + "@type"?: string; +} + +export interface RpcStatus { + /** @format int32 */ + code?: number; + message?: string; + details?: ProtobufAny[]; +} + +export interface V1AnonArticlesCounter { + key?: string; + + /** @format uint64 */ + counter?: string; +} + +export interface V1Article { + /** @format uint64 */ + id?: string; + title?: string; + url?: string; + picture?: string; + publisher?: string; + paid?: boolean; + + /** @format int64 */ + created_at?: string; +} + +export type V1MsgAddArticleResponse = object; + +export interface V1MsgPayPublisherRespectResponse { + /** @format uint64 */ + respect_paid?: string; + + /** @format uint64 */ + publisher_reward?: string; + + /** @format uint64 */ + community_pool_funds?: string; +} + +/** + * Params defines the parameters for the module. + */ +export interface V1PublisherRespectParams { + tax?: string; + denom?: string; +} + +export interface V1QueryAcceptedDomainResponse { + acceptedDomain?: Cointrunkv1AcceptedDomain[]; + + /** + * PageResponse is to be embedded in gRPC response messages where the + * corresponding request message has used PageRequest. + * + * message SomeResponse { + * repeated Bar results = 1; + * PageResponse page = 2; + * } + */ + pagination?: V1Beta1PageResponse; +} + +export interface V1QueryAllAnonArticlesCountersResponse { + AnonArticlesCounters?: V1AnonArticlesCounter[]; + + /** + * PageResponse is to be embedded in gRPC response messages where the + * corresponding request message has used PageRequest. + * + * message SomeResponse { + * repeated Bar results = 1; + * PageResponse page = 2; + * } + */ + pagination?: V1Beta1PageResponse; +} + +export interface V1QueryAllArticlesResponse { + article?: V1Article[]; + + /** + * PageResponse is to be embedded in gRPC response messages where the + * corresponding request message has used PageRequest. + * + * message SomeResponse { + * repeated Bar results = 1; + * PageResponse page = 2; + * } + */ + pagination?: V1Beta1PageResponse; +} + +/** + * QueryParamsResponse is response type for the Query/Params RPC method. + */ +export interface V1QueryParamsResponse { + /** params holds all the parameters of this module. */ + params?: Cointrunkv1Params; +} + +export interface V1QueryPublisherByIndexResponse { + publisher?: Cointrunkv1Publisher; +} + +export interface V1QueryPublisherResponse { + publisher?: Cointrunkv1Publisher[]; + + /** + * PageResponse is to be embedded in gRPC response messages where the + * corresponding request message has used PageRequest. + * + * message SomeResponse { + * repeated Bar results = 1; + * PageResponse page = 2; + * } + */ + pagination?: V1Beta1PageResponse; +} + +/** +* Coin defines a token with a denomination and an amount. + +NOTE: The amount field is an Int which implements the custom method +signatures required by gogoproto. +*/ +export interface V1Beta1Coin { + denom?: string; + amount?: string; +} + +/** +* message SomeRequest { + Foo some_parameter = 1; + PageRequest pagination = 2; + } +*/ +export interface V1Beta1PageRequest { + /** + * key is a value returned in PageResponse.next_key to begin + * querying the next page most efficiently. Only one of offset or key + * should be set. + * @format byte + */ + key?: string; + + /** + * offset is a numeric offset that can be used when key is unavailable. + * It is less efficient than using key. Only one of offset or key should + * be set. + * @format uint64 + */ + offset?: string; + + /** + * limit is the total number of results to be returned in the result page. + * If left empty it will default to a value to be set by each app. + * @format uint64 + */ + limit?: string; + + /** + * count_total is set to true to indicate that the result set should include + * a count of the total number of items available for pagination in UIs. + * count_total is only respected when offset is used. It is ignored when key + * is set. + */ + count_total?: boolean; + + /** + * reverse is set to true if results are to be returned in the descending order. + * + * Since: cosmos-sdk 0.43 + */ + reverse?: boolean; +} + +/** +* PageResponse is to be embedded in gRPC response messages where the +corresponding request message has used PageRequest. + + message SomeResponse { + repeated Bar results = 1; + PageResponse page = 2; + } +*/ +export interface V1Beta1PageResponse { + /** @format byte */ + next_key?: string; + + /** @format uint64 */ + total?: string; +} + +export type QueryParamsType = Record; +export type ResponseFormat = keyof Omit; + +export interface FullRequestParams extends Omit { + /** set parameter to `true` for call `securityWorker` for this request */ + secure?: boolean; + /** request path */ + path: string; + /** content type of request body */ + type?: ContentType; + /** query params */ + query?: QueryParamsType; + /** format of response (i.e. response.json() -> format: "json") */ + format?: keyof Omit; + /** request body */ + body?: unknown; + /** base url */ + baseUrl?: string; + /** request cancellation token */ + cancelToken?: CancelToken; +} + +export type RequestParams = Omit; + +export interface ApiConfig { + baseUrl?: string; + baseApiParams?: Omit; + securityWorker?: (securityData: SecurityDataType) => RequestParams | void; +} + +export interface HttpResponse extends Response { + data: D; + error: E; +} + +type CancelToken = Symbol | string | number; + +export enum ContentType { + Json = "application/json", + FormData = "multipart/form-data", + UrlEncoded = "application/x-www-form-urlencoded", +} + +export class HttpClient { + public baseUrl: string = ""; + private securityData: SecurityDataType = null as any; + private securityWorker: null | ApiConfig["securityWorker"] = null; + private abortControllers = new Map(); + + private baseApiParams: RequestParams = { + credentials: "same-origin", + headers: {}, + redirect: "follow", + referrerPolicy: "no-referrer", + }; + + constructor(apiConfig: ApiConfig = {}) { + Object.assign(this, apiConfig); + } + + public setSecurityData = (data: SecurityDataType) => { + this.securityData = data; + }; + + private addQueryParam(query: QueryParamsType, key: string) { + const value = query[key]; + + return ( + encodeURIComponent(key) + + "=" + + encodeURIComponent(Array.isArray(value) ? value.join(",") : typeof value === "number" ? value : `${value}`) + ); + } + + protected toQueryString(rawQuery?: QueryParamsType): string { + const query = rawQuery || {}; + const keys = Object.keys(query).filter((key) => "undefined" !== typeof query[key]); + return keys + .map((key) => + typeof query[key] === "object" && !Array.isArray(query[key]) + ? this.toQueryString(query[key] as QueryParamsType) + : this.addQueryParam(query, key), + ) + .join("&"); + } + + protected addQueryParams(rawQuery?: QueryParamsType): string { + const queryString = this.toQueryString(rawQuery); + return queryString ? `?${queryString}` : ""; + } + + private contentFormatters: Record any> = { + [ContentType.Json]: (input: any) => + input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input, + [ContentType.FormData]: (input: any) => + Object.keys(input || {}).reduce((data, key) => { + data.append(key, input[key]); + return data; + }, new FormData()), + [ContentType.UrlEncoded]: (input: any) => this.toQueryString(input), + }; + + private mergeRequestParams(params1: RequestParams, params2?: RequestParams): RequestParams { + return { + ...this.baseApiParams, + ...params1, + ...(params2 || {}), + headers: { + ...(this.baseApiParams.headers || {}), + ...(params1.headers || {}), + ...((params2 && params2.headers) || {}), + }, + }; + } + + private createAbortSignal = (cancelToken: CancelToken): AbortSignal | undefined => { + if (this.abortControllers.has(cancelToken)) { + const abortController = this.abortControllers.get(cancelToken); + if (abortController) { + return abortController.signal; + } + return void 0; + } + + const abortController = new AbortController(); + this.abortControllers.set(cancelToken, abortController); + return abortController.signal; + }; + + public abortRequest = (cancelToken: CancelToken) => { + const abortController = this.abortControllers.get(cancelToken); + + if (abortController) { + abortController.abort(); + this.abortControllers.delete(cancelToken); + } + }; + + public request = ({ + body, + secure, + path, + type, + query, + format = "json", + baseUrl, + cancelToken, + ...params + }: FullRequestParams): Promise> => { + const secureParams = (secure && this.securityWorker && this.securityWorker(this.securityData)) || {}; + const requestParams = this.mergeRequestParams(params, secureParams); + const queryString = query && this.toQueryString(query); + const payloadFormatter = this.contentFormatters[type || ContentType.Json]; + + return fetch(`${baseUrl || this.baseUrl || ""}${path}${queryString ? `?${queryString}` : ""}`, { + ...requestParams, + headers: { + ...(type && type !== ContentType.FormData ? { "Content-Type": type } : {}), + ...(requestParams.headers || {}), + }, + signal: cancelToken ? this.createAbortSignal(cancelToken) : void 0, + body: typeof body === "undefined" || body === null ? null : payloadFormatter(body), + }).then(async (response) => { + const r = response as HttpResponse; + r.data = (null as unknown) as T; + r.error = (null as unknown) as E; + + const data = await response[format]() + .then((data) => { + if (r.ok) { + r.data = data; + } else { + r.error = data; + } + return r; + }) + .catch((e) => { + r.error = e; + return r; + }); + + if (cancelToken) { + this.abortControllers.delete(cancelToken); + } + + if (!response.ok) throw data; + return data; + }); + }; +} + +/** + * @title cointrunk/accepted_domain.proto + * @version version not set + */ +export class Api extends HttpClient { + /** + * No description + * + * @tags Query + * @name QueryAcceptedDomain + * @summary Queries a list of AcceptedDomain items. + * @request GET:/bze/cointrunk/v1/accepted_domain + */ + queryAcceptedDomain = ( + query?: { + "pagination.key"?: string; + "pagination.offset"?: string; + "pagination.limit"?: string; + "pagination.count_total"?: boolean; + "pagination.reverse"?: boolean; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/bze/cointrunk/v1/accepted_domain`, + method: "GET", + query: query, + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Query + * @name QueryAllAnonArticlesCounters + * @summary Queries a list of AllAnonArticlesCounters items. + * @request GET:/bze/cointrunk/v1/all_anon_articles_counters + */ + queryAllAnonArticlesCounters = ( + query?: { + "pagination.key"?: string; + "pagination.offset"?: string; + "pagination.limit"?: string; + "pagination.count_total"?: boolean; + "pagination.reverse"?: boolean; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/bze/cointrunk/v1/all_anon_articles_counters`, + method: "GET", + query: query, + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Query + * @name QueryAllArticles + * @summary Queries a list of Article items. + * @request GET:/bze/cointrunk/v1/articles + */ + queryAllArticles = ( + query?: { + "pagination.key"?: string; + "pagination.offset"?: string; + "pagination.limit"?: string; + "pagination.count_total"?: boolean; + "pagination.reverse"?: boolean; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/bze/cointrunk/v1/articles`, + method: "GET", + query: query, + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Query + * @name QueryParams + * @summary Parameters queries the parameters of the module. + * @request GET:/bze/cointrunk/v1/params + */ + queryParams = (params: RequestParams = {}) => + this.request({ + path: `/bze/cointrunk/v1/params`, + method: "GET", + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Query + * @name QueryPublisherByIndex + * @summary Queries publisher by index/address. + * @request GET:/bze/cointrunk/v1/publisher/{index} + */ + queryPublisherByIndex = (index: string, params: RequestParams = {}) => + this.request({ + path: `/bze/cointrunk/v1/publisher/${index}`, + method: "GET", + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Query + * @name QueryPublisher + * @summary Queries a list of Publisher items. + * @request GET:/bze/cointrunk/v1/publishers + */ + queryPublisher = ( + query?: { + "pagination.key"?: string; + "pagination.offset"?: string; + "pagination.limit"?: string; + "pagination.count_total"?: boolean; + "pagination.reverse"?: boolean; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/bze/cointrunk/v1/publishers`, + method: "GET", + query: query, + format: "json", + ...params, + }); +} diff --git a/ts-client/bze.cointrunk.v1/types.ts b/ts-client/bze.cointrunk.v1/types.ts new file mode 100755 index 00000000..1857e15f --- /dev/null +++ b/ts-client/bze.cointrunk.v1/types.ts @@ -0,0 +1,33 @@ +import { AcceptedDomain } from "./types/cointrunk/accepted_domain" +import { AcceptedDomainProposal } from "./types/cointrunk/accepted_domain_proposal" +import { AnonArticlesCounter } from "./types/cointrunk/anon_articles_counter" +import { Article } from "./types/cointrunk/article" +import { ArticleAddedEvent } from "./types/cointrunk/events" +import { PublisherAddedEvent } from "./types/cointrunk/events" +import { PublisherUpdatedEvent } from "./types/cointrunk/events" +import { AcceptedDomainAddedEvent } from "./types/cointrunk/events" +import { AcceptedDomainUpdatedEvent } from "./types/cointrunk/events" +import { PublisherRespectPaidEvent } from "./types/cointrunk/events" +import { PublisherRespectParams } from "./types/cointrunk/params" +import { Params } from "./types/cointrunk/params" +import { Publisher } from "./types/cointrunk/publisher" +import { PublisherProposal } from "./types/cointrunk/publisher_proposal" + + +export { + AcceptedDomain, + AcceptedDomainProposal, + AnonArticlesCounter, + Article, + ArticleAddedEvent, + PublisherAddedEvent, + PublisherUpdatedEvent, + AcceptedDomainAddedEvent, + AcceptedDomainUpdatedEvent, + PublisherRespectPaidEvent, + PublisherRespectParams, + Params, + Publisher, + PublisherProposal, + + } \ No newline at end of file diff --git a/ts-client/bze.cointrunk.v1/types/cointrunk/accepted_domain.ts b/ts-client/bze.cointrunk.v1/types/cointrunk/accepted_domain.ts new file mode 100644 index 00000000..9c2aa6e9 --- /dev/null +++ b/ts-client/bze.cointrunk.v1/types/cointrunk/accepted_domain.ts @@ -0,0 +1,92 @@ +/* eslint-disable */ +import { Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "bze.cointrunk.v1"; + +export interface AcceptedDomain { + domain: string; + active: boolean; +} + +const baseAcceptedDomain: object = { domain: "", active: false }; + +export const AcceptedDomain = { + encode(message: AcceptedDomain, writer: Writer = Writer.create()): Writer { + if (message.domain !== "") { + writer.uint32(10).string(message.domain); + } + if (message.active === true) { + writer.uint32(16).bool(message.active); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): AcceptedDomain { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseAcceptedDomain } as AcceptedDomain; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.domain = reader.string(); + break; + case 2: + message.active = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): AcceptedDomain { + const message = { ...baseAcceptedDomain } as AcceptedDomain; + if (object.domain !== undefined && object.domain !== null) { + message.domain = String(object.domain); + } else { + message.domain = ""; + } + if (object.active !== undefined && object.active !== null) { + message.active = Boolean(object.active); + } else { + message.active = false; + } + return message; + }, + + toJSON(message: AcceptedDomain): unknown { + const obj: any = {}; + message.domain !== undefined && (obj.domain = message.domain); + message.active !== undefined && (obj.active = message.active); + return obj; + }, + + fromPartial(object: DeepPartial): AcceptedDomain { + const message = { ...baseAcceptedDomain } as AcceptedDomain; + if (object.domain !== undefined && object.domain !== null) { + message.domain = object.domain; + } else { + message.domain = ""; + } + if (object.active !== undefined && object.active !== null) { + message.active = object.active; + } else { + message.active = false; + } + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/bze.cointrunk.v1/types/cointrunk/accepted_domain_proposal.ts b/ts-client/bze.cointrunk.v1/types/cointrunk/accepted_domain_proposal.ts new file mode 100644 index 00000000..67d69889 --- /dev/null +++ b/ts-client/bze.cointrunk.v1/types/cointrunk/accepted_domain_proposal.ts @@ -0,0 +1,139 @@ +/* eslint-disable */ +import { Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "bze.cointrunk.v1"; + +export interface AcceptedDomainProposal { + title: string; + description: string; + domain: string; + active: boolean; +} + +const baseAcceptedDomainProposal: object = { + title: "", + description: "", + domain: "", + active: false, +}; + +export const AcceptedDomainProposal = { + encode( + message: AcceptedDomainProposal, + writer: Writer = Writer.create() + ): Writer { + if (message.title !== "") { + writer.uint32(10).string(message.title); + } + if (message.description !== "") { + writer.uint32(18).string(message.description); + } + if (message.domain !== "") { + writer.uint32(26).string(message.domain); + } + if (message.active === true) { + writer.uint32(32).bool(message.active); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): AcceptedDomainProposal { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseAcceptedDomainProposal } as AcceptedDomainProposal; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.title = reader.string(); + break; + case 2: + message.description = reader.string(); + break; + case 3: + message.domain = reader.string(); + break; + case 4: + message.active = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): AcceptedDomainProposal { + const message = { ...baseAcceptedDomainProposal } as AcceptedDomainProposal; + if (object.title !== undefined && object.title !== null) { + message.title = String(object.title); + } else { + message.title = ""; + } + if (object.description !== undefined && object.description !== null) { + message.description = String(object.description); + } else { + message.description = ""; + } + if (object.domain !== undefined && object.domain !== null) { + message.domain = String(object.domain); + } else { + message.domain = ""; + } + if (object.active !== undefined && object.active !== null) { + message.active = Boolean(object.active); + } else { + message.active = false; + } + return message; + }, + + toJSON(message: AcceptedDomainProposal): unknown { + const obj: any = {}; + message.title !== undefined && (obj.title = message.title); + message.description !== undefined && + (obj.description = message.description); + message.domain !== undefined && (obj.domain = message.domain); + message.active !== undefined && (obj.active = message.active); + return obj; + }, + + fromPartial( + object: DeepPartial + ): AcceptedDomainProposal { + const message = { ...baseAcceptedDomainProposal } as AcceptedDomainProposal; + if (object.title !== undefined && object.title !== null) { + message.title = object.title; + } else { + message.title = ""; + } + if (object.description !== undefined && object.description !== null) { + message.description = object.description; + } else { + message.description = ""; + } + if (object.domain !== undefined && object.domain !== null) { + message.domain = object.domain; + } else { + message.domain = ""; + } + if (object.active !== undefined && object.active !== null) { + message.active = object.active; + } else { + message.active = false; + } + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/bze.cointrunk.v1/types/cointrunk/anon_articles_counter.ts b/ts-client/bze.cointrunk.v1/types/cointrunk/anon_articles_counter.ts new file mode 100644 index 00000000..3c6da0c8 --- /dev/null +++ b/ts-client/bze.cointrunk.v1/types/cointrunk/anon_articles_counter.ts @@ -0,0 +1,118 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "bze.cointrunk.v1"; + +export interface AnonArticlesCounter { + key: string; + counter: number; +} + +const baseAnonArticlesCounter: object = { key: "", counter: 0 }; + +export const AnonArticlesCounter = { + encode( + message: AnonArticlesCounter, + writer: Writer = Writer.create() + ): Writer { + if (message.key !== "") { + writer.uint32(10).string(message.key); + } + if (message.counter !== 0) { + writer.uint32(16).uint64(message.counter); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): AnonArticlesCounter { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseAnonArticlesCounter } as AnonArticlesCounter; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.key = reader.string(); + break; + case 2: + message.counter = longToNumber(reader.uint64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): AnonArticlesCounter { + const message = { ...baseAnonArticlesCounter } as AnonArticlesCounter; + if (object.key !== undefined && object.key !== null) { + message.key = String(object.key); + } else { + message.key = ""; + } + if (object.counter !== undefined && object.counter !== null) { + message.counter = Number(object.counter); + } else { + message.counter = 0; + } + return message; + }, + + toJSON(message: AnonArticlesCounter): unknown { + const obj: any = {}; + message.key !== undefined && (obj.key = message.key); + message.counter !== undefined && (obj.counter = message.counter); + return obj; + }, + + fromPartial(object: DeepPartial): AnonArticlesCounter { + const message = { ...baseAnonArticlesCounter } as AnonArticlesCounter; + if (object.key !== undefined && object.key !== null) { + message.key = object.key; + } else { + message.key = ""; + } + if (object.counter !== undefined && object.counter !== null) { + message.counter = object.counter; + } else { + message.counter = 0; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/bze.cointrunk.v1/types/cointrunk/article.ts b/ts-client/bze.cointrunk.v1/types/cointrunk/article.ts new file mode 100644 index 00000000..b89854cc --- /dev/null +++ b/ts-client/bze.cointrunk.v1/types/cointrunk/article.ts @@ -0,0 +1,213 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "bze.cointrunk.v1"; + +export interface Article { + id: number; + title: string; + url: string; + picture: string; + publisher: string; + paid: boolean; + createdAt: number; +} + +const baseArticle: object = { + id: 0, + title: "", + url: "", + picture: "", + publisher: "", + paid: false, + createdAt: 0, +}; + +export const Article = { + encode(message: Article, writer: Writer = Writer.create()): Writer { + if (message.id !== 0) { + writer.uint32(8).uint64(message.id); + } + if (message.title !== "") { + writer.uint32(18).string(message.title); + } + if (message.url !== "") { + writer.uint32(26).string(message.url); + } + if (message.picture !== "") { + writer.uint32(34).string(message.picture); + } + if (message.publisher !== "") { + writer.uint32(42).string(message.publisher); + } + if (message.paid === true) { + writer.uint32(48).bool(message.paid); + } + if (message.createdAt !== 0) { + writer.uint32(56).int64(message.createdAt); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Article { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseArticle } as Article; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.id = longToNumber(reader.uint64() as Long); + break; + case 2: + message.title = reader.string(); + break; + case 3: + message.url = reader.string(); + break; + case 4: + message.picture = reader.string(); + break; + case 5: + message.publisher = reader.string(); + break; + case 6: + message.paid = reader.bool(); + break; + case 7: + message.createdAt = longToNumber(reader.int64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Article { + const message = { ...baseArticle } as Article; + if (object.id !== undefined && object.id !== null) { + message.id = Number(object.id); + } else { + message.id = 0; + } + if (object.title !== undefined && object.title !== null) { + message.title = String(object.title); + } else { + message.title = ""; + } + if (object.url !== undefined && object.url !== null) { + message.url = String(object.url); + } else { + message.url = ""; + } + if (object.picture !== undefined && object.picture !== null) { + message.picture = String(object.picture); + } else { + message.picture = ""; + } + if (object.publisher !== undefined && object.publisher !== null) { + message.publisher = String(object.publisher); + } else { + message.publisher = ""; + } + if (object.paid !== undefined && object.paid !== null) { + message.paid = Boolean(object.paid); + } else { + message.paid = false; + } + if (object.createdAt !== undefined && object.createdAt !== null) { + message.createdAt = Number(object.createdAt); + } else { + message.createdAt = 0; + } + return message; + }, + + toJSON(message: Article): unknown { + const obj: any = {}; + message.id !== undefined && (obj.id = message.id); + message.title !== undefined && (obj.title = message.title); + message.url !== undefined && (obj.url = message.url); + message.picture !== undefined && (obj.picture = message.picture); + message.publisher !== undefined && (obj.publisher = message.publisher); + message.paid !== undefined && (obj.paid = message.paid); + message.createdAt !== undefined && (obj.createdAt = message.createdAt); + return obj; + }, + + fromPartial(object: DeepPartial

): Article { + const message = { ...baseArticle } as Article; + if (object.id !== undefined && object.id !== null) { + message.id = object.id; + } else { + message.id = 0; + } + if (object.title !== undefined && object.title !== null) { + message.title = object.title; + } else { + message.title = ""; + } + if (object.url !== undefined && object.url !== null) { + message.url = object.url; + } else { + message.url = ""; + } + if (object.picture !== undefined && object.picture !== null) { + message.picture = object.picture; + } else { + message.picture = ""; + } + if (object.publisher !== undefined && object.publisher !== null) { + message.publisher = object.publisher; + } else { + message.publisher = ""; + } + if (object.paid !== undefined && object.paid !== null) { + message.paid = object.paid; + } else { + message.paid = false; + } + if (object.createdAt !== undefined && object.createdAt !== null) { + message.createdAt = object.createdAt; + } else { + message.createdAt = 0; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/bze.cointrunk.v1/types/cointrunk/events.ts b/ts-client/bze.cointrunk.v1/types/cointrunk/events.ts new file mode 100644 index 00000000..cf1c0a6e --- /dev/null +++ b/ts-client/bze.cointrunk.v1/types/cointrunk/events.ts @@ -0,0 +1,586 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; +import { Publisher } from "../cointrunk/publisher"; +import { AcceptedDomain } from "../cointrunk/accepted_domain"; + +export const protobufPackage = "bze.cointrunk.v1"; + +export interface ArticleAddedEvent { + publisher: string; + articleId: number; + paid: boolean; +} + +export interface PublisherAddedEvent { + publisher: Publisher | undefined; +} + +export interface PublisherUpdatedEvent { + publisher: Publisher | undefined; +} + +export interface AcceptedDomainAddedEvent { + acceptedDomain: AcceptedDomain | undefined; +} + +export interface AcceptedDomainUpdatedEvent { + acceptedDomain: AcceptedDomain | undefined; +} + +export interface PublisherRespectPaidEvent { + respectPaid: number; + publisherReward: number; + communityPoolFunds: number; + publisher: string; +} + +const baseArticleAddedEvent: object = { + publisher: "", + articleId: 0, + paid: false, +}; + +export const ArticleAddedEvent = { + encode(message: ArticleAddedEvent, writer: Writer = Writer.create()): Writer { + if (message.publisher !== "") { + writer.uint32(10).string(message.publisher); + } + if (message.articleId !== 0) { + writer.uint32(16).uint64(message.articleId); + } + if (message.paid === true) { + writer.uint32(24).bool(message.paid); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ArticleAddedEvent { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseArticleAddedEvent } as ArticleAddedEvent; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.publisher = reader.string(); + break; + case 2: + message.articleId = longToNumber(reader.uint64() as Long); + break; + case 3: + message.paid = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ArticleAddedEvent { + const message = { ...baseArticleAddedEvent } as ArticleAddedEvent; + if (object.publisher !== undefined && object.publisher !== null) { + message.publisher = String(object.publisher); + } else { + message.publisher = ""; + } + if (object.articleId !== undefined && object.articleId !== null) { + message.articleId = Number(object.articleId); + } else { + message.articleId = 0; + } + if (object.paid !== undefined && object.paid !== null) { + message.paid = Boolean(object.paid); + } else { + message.paid = false; + } + return message; + }, + + toJSON(message: ArticleAddedEvent): unknown { + const obj: any = {}; + message.publisher !== undefined && (obj.publisher = message.publisher); + message.articleId !== undefined && (obj.articleId = message.articleId); + message.paid !== undefined && (obj.paid = message.paid); + return obj; + }, + + fromPartial(object: DeepPartial): ArticleAddedEvent { + const message = { ...baseArticleAddedEvent } as ArticleAddedEvent; + if (object.publisher !== undefined && object.publisher !== null) { + message.publisher = object.publisher; + } else { + message.publisher = ""; + } + if (object.articleId !== undefined && object.articleId !== null) { + message.articleId = object.articleId; + } else { + message.articleId = 0; + } + if (object.paid !== undefined && object.paid !== null) { + message.paid = object.paid; + } else { + message.paid = false; + } + return message; + }, +}; + +const basePublisherAddedEvent: object = {}; + +export const PublisherAddedEvent = { + encode( + message: PublisherAddedEvent, + writer: Writer = Writer.create() + ): Writer { + if (message.publisher !== undefined) { + Publisher.encode(message.publisher, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): PublisherAddedEvent { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...basePublisherAddedEvent } as PublisherAddedEvent; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.publisher = Publisher.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): PublisherAddedEvent { + const message = { ...basePublisherAddedEvent } as PublisherAddedEvent; + if (object.publisher !== undefined && object.publisher !== null) { + message.publisher = Publisher.fromJSON(object.publisher); + } else { + message.publisher = undefined; + } + return message; + }, + + toJSON(message: PublisherAddedEvent): unknown { + const obj: any = {}; + message.publisher !== undefined && + (obj.publisher = message.publisher + ? Publisher.toJSON(message.publisher) + : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): PublisherAddedEvent { + const message = { ...basePublisherAddedEvent } as PublisherAddedEvent; + if (object.publisher !== undefined && object.publisher !== null) { + message.publisher = Publisher.fromPartial(object.publisher); + } else { + message.publisher = undefined; + } + return message; + }, +}; + +const basePublisherUpdatedEvent: object = {}; + +export const PublisherUpdatedEvent = { + encode( + message: PublisherUpdatedEvent, + writer: Writer = Writer.create() + ): Writer { + if (message.publisher !== undefined) { + Publisher.encode(message.publisher, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): PublisherUpdatedEvent { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...basePublisherUpdatedEvent } as PublisherUpdatedEvent; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.publisher = Publisher.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): PublisherUpdatedEvent { + const message = { ...basePublisherUpdatedEvent } as PublisherUpdatedEvent; + if (object.publisher !== undefined && object.publisher !== null) { + message.publisher = Publisher.fromJSON(object.publisher); + } else { + message.publisher = undefined; + } + return message; + }, + + toJSON(message: PublisherUpdatedEvent): unknown { + const obj: any = {}; + message.publisher !== undefined && + (obj.publisher = message.publisher + ? Publisher.toJSON(message.publisher) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): PublisherUpdatedEvent { + const message = { ...basePublisherUpdatedEvent } as PublisherUpdatedEvent; + if (object.publisher !== undefined && object.publisher !== null) { + message.publisher = Publisher.fromPartial(object.publisher); + } else { + message.publisher = undefined; + } + return message; + }, +}; + +const baseAcceptedDomainAddedEvent: object = {}; + +export const AcceptedDomainAddedEvent = { + encode( + message: AcceptedDomainAddedEvent, + writer: Writer = Writer.create() + ): Writer { + if (message.acceptedDomain !== undefined) { + AcceptedDomain.encode( + message.acceptedDomain, + writer.uint32(10).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): AcceptedDomainAddedEvent { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseAcceptedDomainAddedEvent, + } as AcceptedDomainAddedEvent; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.acceptedDomain = AcceptedDomain.decode( + reader, + reader.uint32() + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): AcceptedDomainAddedEvent { + const message = { + ...baseAcceptedDomainAddedEvent, + } as AcceptedDomainAddedEvent; + if (object.acceptedDomain !== undefined && object.acceptedDomain !== null) { + message.acceptedDomain = AcceptedDomain.fromJSON(object.acceptedDomain); + } else { + message.acceptedDomain = undefined; + } + return message; + }, + + toJSON(message: AcceptedDomainAddedEvent): unknown { + const obj: any = {}; + message.acceptedDomain !== undefined && + (obj.acceptedDomain = message.acceptedDomain + ? AcceptedDomain.toJSON(message.acceptedDomain) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): AcceptedDomainAddedEvent { + const message = { + ...baseAcceptedDomainAddedEvent, + } as AcceptedDomainAddedEvent; + if (object.acceptedDomain !== undefined && object.acceptedDomain !== null) { + message.acceptedDomain = AcceptedDomain.fromPartial( + object.acceptedDomain + ); + } else { + message.acceptedDomain = undefined; + } + return message; + }, +}; + +const baseAcceptedDomainUpdatedEvent: object = {}; + +export const AcceptedDomainUpdatedEvent = { + encode( + message: AcceptedDomainUpdatedEvent, + writer: Writer = Writer.create() + ): Writer { + if (message.acceptedDomain !== undefined) { + AcceptedDomain.encode( + message.acceptedDomain, + writer.uint32(10).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): AcceptedDomainUpdatedEvent { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseAcceptedDomainUpdatedEvent, + } as AcceptedDomainUpdatedEvent; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.acceptedDomain = AcceptedDomain.decode( + reader, + reader.uint32() + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): AcceptedDomainUpdatedEvent { + const message = { + ...baseAcceptedDomainUpdatedEvent, + } as AcceptedDomainUpdatedEvent; + if (object.acceptedDomain !== undefined && object.acceptedDomain !== null) { + message.acceptedDomain = AcceptedDomain.fromJSON(object.acceptedDomain); + } else { + message.acceptedDomain = undefined; + } + return message; + }, + + toJSON(message: AcceptedDomainUpdatedEvent): unknown { + const obj: any = {}; + message.acceptedDomain !== undefined && + (obj.acceptedDomain = message.acceptedDomain + ? AcceptedDomain.toJSON(message.acceptedDomain) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): AcceptedDomainUpdatedEvent { + const message = { + ...baseAcceptedDomainUpdatedEvent, + } as AcceptedDomainUpdatedEvent; + if (object.acceptedDomain !== undefined && object.acceptedDomain !== null) { + message.acceptedDomain = AcceptedDomain.fromPartial( + object.acceptedDomain + ); + } else { + message.acceptedDomain = undefined; + } + return message; + }, +}; + +const basePublisherRespectPaidEvent: object = { + respectPaid: 0, + publisherReward: 0, + communityPoolFunds: 0, + publisher: "", +}; + +export const PublisherRespectPaidEvent = { + encode( + message: PublisherRespectPaidEvent, + writer: Writer = Writer.create() + ): Writer { + if (message.respectPaid !== 0) { + writer.uint32(8).uint64(message.respectPaid); + } + if (message.publisherReward !== 0) { + writer.uint32(16).uint64(message.publisherReward); + } + if (message.communityPoolFunds !== 0) { + writer.uint32(24).uint64(message.communityPoolFunds); + } + if (message.publisher !== "") { + writer.uint32(34).string(message.publisher); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): PublisherRespectPaidEvent { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...basePublisherRespectPaidEvent, + } as PublisherRespectPaidEvent; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.respectPaid = longToNumber(reader.uint64() as Long); + break; + case 2: + message.publisherReward = longToNumber(reader.uint64() as Long); + break; + case 3: + message.communityPoolFunds = longToNumber(reader.uint64() as Long); + break; + case 4: + message.publisher = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): PublisherRespectPaidEvent { + const message = { + ...basePublisherRespectPaidEvent, + } as PublisherRespectPaidEvent; + if (object.respectPaid !== undefined && object.respectPaid !== null) { + message.respectPaid = Number(object.respectPaid); + } else { + message.respectPaid = 0; + } + if ( + object.publisherReward !== undefined && + object.publisherReward !== null + ) { + message.publisherReward = Number(object.publisherReward); + } else { + message.publisherReward = 0; + } + if ( + object.communityPoolFunds !== undefined && + object.communityPoolFunds !== null + ) { + message.communityPoolFunds = Number(object.communityPoolFunds); + } else { + message.communityPoolFunds = 0; + } + if (object.publisher !== undefined && object.publisher !== null) { + message.publisher = String(object.publisher); + } else { + message.publisher = ""; + } + return message; + }, + + toJSON(message: PublisherRespectPaidEvent): unknown { + const obj: any = {}; + message.respectPaid !== undefined && + (obj.respectPaid = message.respectPaid); + message.publisherReward !== undefined && + (obj.publisherReward = message.publisherReward); + message.communityPoolFunds !== undefined && + (obj.communityPoolFunds = message.communityPoolFunds); + message.publisher !== undefined && (obj.publisher = message.publisher); + return obj; + }, + + fromPartial( + object: DeepPartial + ): PublisherRespectPaidEvent { + const message = { + ...basePublisherRespectPaidEvent, + } as PublisherRespectPaidEvent; + if (object.respectPaid !== undefined && object.respectPaid !== null) { + message.respectPaid = object.respectPaid; + } else { + message.respectPaid = 0; + } + if ( + object.publisherReward !== undefined && + object.publisherReward !== null + ) { + message.publisherReward = object.publisherReward; + } else { + message.publisherReward = 0; + } + if ( + object.communityPoolFunds !== undefined && + object.communityPoolFunds !== null + ) { + message.communityPoolFunds = object.communityPoolFunds; + } else { + message.communityPoolFunds = 0; + } + if (object.publisher !== undefined && object.publisher !== null) { + message.publisher = object.publisher; + } else { + message.publisher = ""; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/bze.cointrunk.v1/types/cointrunk/genesis.ts b/ts-client/bze.cointrunk.v1/types/cointrunk/genesis.ts new file mode 100644 index 00000000..d3462fe9 --- /dev/null +++ b/ts-client/bze.cointrunk.v1/types/cointrunk/genesis.ts @@ -0,0 +1,218 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; +import { Params } from "../cointrunk/params"; +import { Publisher } from "../cointrunk/publisher"; +import { AcceptedDomain } from "../cointrunk/accepted_domain"; +import { Article } from "../cointrunk/article"; + +export const protobufPackage = "bze.cointrunk.v1"; + +/** GenesisState defines the cointrunk module's genesis state. */ +export interface GenesisState { + params: Params | undefined; + publisherList: Publisher[]; + acceptedDomainList: AcceptedDomain[]; + articleList: Article[]; + /** this line is used by starport scaffolding # genesis/proto/state */ + articlesCounter: number; +} + +const baseGenesisState: object = { articlesCounter: 0 }; + +export const GenesisState = { + encode(message: GenesisState, writer: Writer = Writer.create()): Writer { + if (message.params !== undefined) { + Params.encode(message.params, writer.uint32(10).fork()).ldelim(); + } + for (const v of message.publisherList) { + Publisher.encode(v!, writer.uint32(18).fork()).ldelim(); + } + for (const v of message.acceptedDomainList) { + AcceptedDomain.encode(v!, writer.uint32(26).fork()).ldelim(); + } + for (const v of message.articleList) { + Article.encode(v!, writer.uint32(34).fork()).ldelim(); + } + if (message.articlesCounter !== 0) { + writer.uint32(40).uint64(message.articlesCounter); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): GenesisState { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseGenesisState } as GenesisState; + message.publisherList = []; + message.acceptedDomainList = []; + message.articleList = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.params = Params.decode(reader, reader.uint32()); + break; + case 2: + message.publisherList.push(Publisher.decode(reader, reader.uint32())); + break; + case 3: + message.acceptedDomainList.push( + AcceptedDomain.decode(reader, reader.uint32()) + ); + break; + case 4: + message.articleList.push(Article.decode(reader, reader.uint32())); + break; + case 5: + message.articlesCounter = longToNumber(reader.uint64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GenesisState { + const message = { ...baseGenesisState } as GenesisState; + message.publisherList = []; + message.acceptedDomainList = []; + message.articleList = []; + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromJSON(object.params); + } else { + message.params = undefined; + } + if (object.publisherList !== undefined && object.publisherList !== null) { + for (const e of object.publisherList) { + message.publisherList.push(Publisher.fromJSON(e)); + } + } + if ( + object.acceptedDomainList !== undefined && + object.acceptedDomainList !== null + ) { + for (const e of object.acceptedDomainList) { + message.acceptedDomainList.push(AcceptedDomain.fromJSON(e)); + } + } + if (object.articleList !== undefined && object.articleList !== null) { + for (const e of object.articleList) { + message.articleList.push(Article.fromJSON(e)); + } + } + if ( + object.articlesCounter !== undefined && + object.articlesCounter !== null + ) { + message.articlesCounter = Number(object.articlesCounter); + } else { + message.articlesCounter = 0; + } + return message; + }, + + toJSON(message: GenesisState): unknown { + const obj: any = {}; + message.params !== undefined && + (obj.params = message.params ? Params.toJSON(message.params) : undefined); + if (message.publisherList) { + obj.publisherList = message.publisherList.map((e) => + e ? Publisher.toJSON(e) : undefined + ); + } else { + obj.publisherList = []; + } + if (message.acceptedDomainList) { + obj.acceptedDomainList = message.acceptedDomainList.map((e) => + e ? AcceptedDomain.toJSON(e) : undefined + ); + } else { + obj.acceptedDomainList = []; + } + if (message.articleList) { + obj.articleList = message.articleList.map((e) => + e ? Article.toJSON(e) : undefined + ); + } else { + obj.articleList = []; + } + message.articlesCounter !== undefined && + (obj.articlesCounter = message.articlesCounter); + return obj; + }, + + fromPartial(object: DeepPartial): GenesisState { + const message = { ...baseGenesisState } as GenesisState; + message.publisherList = []; + message.acceptedDomainList = []; + message.articleList = []; + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromPartial(object.params); + } else { + message.params = undefined; + } + if (object.publisherList !== undefined && object.publisherList !== null) { + for (const e of object.publisherList) { + message.publisherList.push(Publisher.fromPartial(e)); + } + } + if ( + object.acceptedDomainList !== undefined && + object.acceptedDomainList !== null + ) { + for (const e of object.acceptedDomainList) { + message.acceptedDomainList.push(AcceptedDomain.fromPartial(e)); + } + } + if (object.articleList !== undefined && object.articleList !== null) { + for (const e of object.articleList) { + message.articleList.push(Article.fromPartial(e)); + } + } + if ( + object.articlesCounter !== undefined && + object.articlesCounter !== null + ) { + message.articlesCounter = object.articlesCounter; + } else { + message.articlesCounter = 0; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/bze.cointrunk.v1/types/cointrunk/params.ts b/ts-client/bze.cointrunk.v1/types/cointrunk/params.ts new file mode 100644 index 00000000..b5a20b00 --- /dev/null +++ b/ts-client/bze.cointrunk.v1/types/cointrunk/params.ts @@ -0,0 +1,252 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; +import { Coin } from "../cosmos/base/v1beta1/coin"; + +export const protobufPackage = "bze.cointrunk.v1"; + +/** Params defines the parameters for the module. */ +export interface PublisherRespectParams { + tax: string; + denom: string; +} + +export interface Params { + anonArticleLimit: number; + anonArticleCost: Coin | undefined; + publisherRespectParams: PublisherRespectParams | undefined; +} + +const basePublisherRespectParams: object = { tax: "", denom: "" }; + +export const PublisherRespectParams = { + encode( + message: PublisherRespectParams, + writer: Writer = Writer.create() + ): Writer { + if (message.tax !== "") { + writer.uint32(10).string(message.tax); + } + if (message.denom !== "") { + writer.uint32(42).string(message.denom); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): PublisherRespectParams { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...basePublisherRespectParams } as PublisherRespectParams; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.tax = reader.string(); + break; + case 5: + message.denom = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): PublisherRespectParams { + const message = { ...basePublisherRespectParams } as PublisherRespectParams; + if (object.tax !== undefined && object.tax !== null) { + message.tax = String(object.tax); + } else { + message.tax = ""; + } + if (object.denom !== undefined && object.denom !== null) { + message.denom = String(object.denom); + } else { + message.denom = ""; + } + return message; + }, + + toJSON(message: PublisherRespectParams): unknown { + const obj: any = {}; + message.tax !== undefined && (obj.tax = message.tax); + message.denom !== undefined && (obj.denom = message.denom); + return obj; + }, + + fromPartial( + object: DeepPartial + ): PublisherRespectParams { + const message = { ...basePublisherRespectParams } as PublisherRespectParams; + if (object.tax !== undefined && object.tax !== null) { + message.tax = object.tax; + } else { + message.tax = ""; + } + if (object.denom !== undefined && object.denom !== null) { + message.denom = object.denom; + } else { + message.denom = ""; + } + return message; + }, +}; + +const baseParams: object = { anonArticleLimit: 0 }; + +export const Params = { + encode(message: Params, writer: Writer = Writer.create()): Writer { + if (message.anonArticleLimit !== 0) { + writer.uint32(8).uint64(message.anonArticleLimit); + } + if (message.anonArticleCost !== undefined) { + Coin.encode(message.anonArticleCost, writer.uint32(18).fork()).ldelim(); + } + if (message.publisherRespectParams !== undefined) { + PublisherRespectParams.encode( + message.publisherRespectParams, + writer.uint32(26).fork() + ).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Params { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseParams } as Params; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.anonArticleLimit = longToNumber(reader.uint64() as Long); + break; + case 2: + message.anonArticleCost = Coin.decode(reader, reader.uint32()); + break; + case 3: + message.publisherRespectParams = PublisherRespectParams.decode( + reader, + reader.uint32() + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Params { + const message = { ...baseParams } as Params; + if ( + object.anonArticleLimit !== undefined && + object.anonArticleLimit !== null + ) { + message.anonArticleLimit = Number(object.anonArticleLimit); + } else { + message.anonArticleLimit = 0; + } + if ( + object.anonArticleCost !== undefined && + object.anonArticleCost !== null + ) { + message.anonArticleCost = Coin.fromJSON(object.anonArticleCost); + } else { + message.anonArticleCost = undefined; + } + if ( + object.publisherRespectParams !== undefined && + object.publisherRespectParams !== null + ) { + message.publisherRespectParams = PublisherRespectParams.fromJSON( + object.publisherRespectParams + ); + } else { + message.publisherRespectParams = undefined; + } + return message; + }, + + toJSON(message: Params): unknown { + const obj: any = {}; + message.anonArticleLimit !== undefined && + (obj.anonArticleLimit = message.anonArticleLimit); + message.anonArticleCost !== undefined && + (obj.anonArticleCost = message.anonArticleCost + ? Coin.toJSON(message.anonArticleCost) + : undefined); + message.publisherRespectParams !== undefined && + (obj.publisherRespectParams = message.publisherRespectParams + ? PublisherRespectParams.toJSON(message.publisherRespectParams) + : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): Params { + const message = { ...baseParams } as Params; + if ( + object.anonArticleLimit !== undefined && + object.anonArticleLimit !== null + ) { + message.anonArticleLimit = object.anonArticleLimit; + } else { + message.anonArticleLimit = 0; + } + if ( + object.anonArticleCost !== undefined && + object.anonArticleCost !== null + ) { + message.anonArticleCost = Coin.fromPartial(object.anonArticleCost); + } else { + message.anonArticleCost = undefined; + } + if ( + object.publisherRespectParams !== undefined && + object.publisherRespectParams !== null + ) { + message.publisherRespectParams = PublisherRespectParams.fromPartial( + object.publisherRespectParams + ); + } else { + message.publisherRespectParams = undefined; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/bze.cointrunk.v1/types/cointrunk/publisher.ts b/ts-client/bze.cointrunk.v1/types/cointrunk/publisher.ts new file mode 100644 index 00000000..e3741382 --- /dev/null +++ b/ts-client/bze.cointrunk.v1/types/cointrunk/publisher.ts @@ -0,0 +1,195 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "bze.cointrunk.v1"; + +export interface Publisher { + name: string; + address: string; + active: boolean; + articlesCount: number; + createdAt: number; + respect: number; +} + +const basePublisher: object = { + name: "", + address: "", + active: false, + articlesCount: 0, + createdAt: 0, + respect: 0, +}; + +export const Publisher = { + encode(message: Publisher, writer: Writer = Writer.create()): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.address !== "") { + writer.uint32(18).string(message.address); + } + if (message.active === true) { + writer.uint32(24).bool(message.active); + } + if (message.articlesCount !== 0) { + writer.uint32(32).uint32(message.articlesCount); + } + if (message.createdAt !== 0) { + writer.uint32(40).int64(message.createdAt); + } + if (message.respect !== 0) { + writer.uint32(48).int64(message.respect); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Publisher { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...basePublisher } as Publisher; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.address = reader.string(); + break; + case 3: + message.active = reader.bool(); + break; + case 4: + message.articlesCount = reader.uint32(); + break; + case 5: + message.createdAt = longToNumber(reader.int64() as Long); + break; + case 6: + message.respect = longToNumber(reader.int64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Publisher { + const message = { ...basePublisher } as Publisher; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.address !== undefined && object.address !== null) { + message.address = String(object.address); + } else { + message.address = ""; + } + if (object.active !== undefined && object.active !== null) { + message.active = Boolean(object.active); + } else { + message.active = false; + } + if (object.articlesCount !== undefined && object.articlesCount !== null) { + message.articlesCount = Number(object.articlesCount); + } else { + message.articlesCount = 0; + } + if (object.createdAt !== undefined && object.createdAt !== null) { + message.createdAt = Number(object.createdAt); + } else { + message.createdAt = 0; + } + if (object.respect !== undefined && object.respect !== null) { + message.respect = Number(object.respect); + } else { + message.respect = 0; + } + return message; + }, + + toJSON(message: Publisher): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.address !== undefined && (obj.address = message.address); + message.active !== undefined && (obj.active = message.active); + message.articlesCount !== undefined && + (obj.articlesCount = message.articlesCount); + message.createdAt !== undefined && (obj.createdAt = message.createdAt); + message.respect !== undefined && (obj.respect = message.respect); + return obj; + }, + + fromPartial(object: DeepPartial): Publisher { + const message = { ...basePublisher } as Publisher; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.address !== undefined && object.address !== null) { + message.address = object.address; + } else { + message.address = ""; + } + if (object.active !== undefined && object.active !== null) { + message.active = object.active; + } else { + message.active = false; + } + if (object.articlesCount !== undefined && object.articlesCount !== null) { + message.articlesCount = object.articlesCount; + } else { + message.articlesCount = 0; + } + if (object.createdAt !== undefined && object.createdAt !== null) { + message.createdAt = object.createdAt; + } else { + message.createdAt = 0; + } + if (object.respect !== undefined && object.respect !== null) { + message.respect = object.respect; + } else { + message.respect = 0; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/bze.cointrunk.v1/types/cointrunk/publisher_proposal.ts b/ts-client/bze.cointrunk.v1/types/cointrunk/publisher_proposal.ts new file mode 100644 index 00000000..5598a245 --- /dev/null +++ b/ts-client/bze.cointrunk.v1/types/cointrunk/publisher_proposal.ts @@ -0,0 +1,153 @@ +/* eslint-disable */ +import { Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "bze.cointrunk.v1"; + +export interface PublisherProposal { + title: string; + description: string; + name: string; + address: string; + active: boolean; +} + +const basePublisherProposal: object = { + title: "", + description: "", + name: "", + address: "", + active: false, +}; + +export const PublisherProposal = { + encode(message: PublisherProposal, writer: Writer = Writer.create()): Writer { + if (message.title !== "") { + writer.uint32(10).string(message.title); + } + if (message.description !== "") { + writer.uint32(18).string(message.description); + } + if (message.name !== "") { + writer.uint32(26).string(message.name); + } + if (message.address !== "") { + writer.uint32(34).string(message.address); + } + if (message.active === true) { + writer.uint32(40).bool(message.active); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): PublisherProposal { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...basePublisherProposal } as PublisherProposal; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.title = reader.string(); + break; + case 2: + message.description = reader.string(); + break; + case 3: + message.name = reader.string(); + break; + case 4: + message.address = reader.string(); + break; + case 5: + message.active = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): PublisherProposal { + const message = { ...basePublisherProposal } as PublisherProposal; + if (object.title !== undefined && object.title !== null) { + message.title = String(object.title); + } else { + message.title = ""; + } + if (object.description !== undefined && object.description !== null) { + message.description = String(object.description); + } else { + message.description = ""; + } + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.address !== undefined && object.address !== null) { + message.address = String(object.address); + } else { + message.address = ""; + } + if (object.active !== undefined && object.active !== null) { + message.active = Boolean(object.active); + } else { + message.active = false; + } + return message; + }, + + toJSON(message: PublisherProposal): unknown { + const obj: any = {}; + message.title !== undefined && (obj.title = message.title); + message.description !== undefined && + (obj.description = message.description); + message.name !== undefined && (obj.name = message.name); + message.address !== undefined && (obj.address = message.address); + message.active !== undefined && (obj.active = message.active); + return obj; + }, + + fromPartial(object: DeepPartial): PublisherProposal { + const message = { ...basePublisherProposal } as PublisherProposal; + if (object.title !== undefined && object.title !== null) { + message.title = object.title; + } else { + message.title = ""; + } + if (object.description !== undefined && object.description !== null) { + message.description = object.description; + } else { + message.description = ""; + } + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.address !== undefined && object.address !== null) { + message.address = object.address; + } else { + message.address = ""; + } + if (object.active !== undefined && object.active !== null) { + message.active = object.active; + } else { + message.active = false; + } + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/bze.cointrunk.v1/types/cointrunk/query.ts b/ts-client/bze.cointrunk.v1/types/cointrunk/query.ts new file mode 100644 index 00000000..e4ad6c08 --- /dev/null +++ b/ts-client/bze.cointrunk.v1/types/cointrunk/query.ts @@ -0,0 +1,1108 @@ +/* eslint-disable */ +import { Reader, Writer } from "protobufjs/minimal"; +import { Params } from "../cointrunk/params"; +import { + PageRequest, + PageResponse, +} from "../cosmos/base/query/v1beta1/pagination"; +import { AcceptedDomain } from "../cointrunk/accepted_domain"; +import { Publisher } from "../cointrunk/publisher"; +import { Article } from "../cointrunk/article"; +import { AnonArticlesCounter } from "../cointrunk/anon_articles_counter"; + +export const protobufPackage = "bze.cointrunk.v1"; + +/** QueryParamsRequest is request type for the Query/Params RPC method. */ +export interface QueryParamsRequest {} + +/** QueryParamsResponse is response type for the Query/Params RPC method. */ +export interface QueryParamsResponse { + /** params holds all the parameters of this module. */ + params: Params | undefined; +} + +export interface QueryAcceptedDomainRequest { + pagination: PageRequest | undefined; +} + +export interface QueryAcceptedDomainResponse { + acceptedDomain: AcceptedDomain[]; + pagination: PageResponse | undefined; +} + +export interface QueryPublisherRequest { + pagination: PageRequest | undefined; +} + +export interface QueryPublisherResponse { + publisher: Publisher[]; + pagination: PageResponse | undefined; +} + +export interface QueryPublisherByIndexRequest { + index: string; +} + +export interface QueryPublisherByIndexResponse { + publisher: Publisher | undefined; +} + +export interface QueryAllArticlesRequest { + pagination: PageRequest | undefined; +} + +export interface QueryAllArticlesResponse { + article: Article[]; + pagination: PageResponse | undefined; +} + +export interface QueryAllAnonArticlesCountersRequest { + pagination: PageRequest | undefined; +} + +export interface QueryAllAnonArticlesCountersResponse { + AnonArticlesCounters: AnonArticlesCounter[]; + pagination: PageResponse | undefined; +} + +const baseQueryParamsRequest: object = {}; + +export const QueryParamsRequest = { + encode(_: QueryParamsRequest, writer: Writer = Writer.create()): Writer { + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QueryParamsRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryParamsRequest } as QueryParamsRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): QueryParamsRequest { + const message = { ...baseQueryParamsRequest } as QueryParamsRequest; + return message; + }, + + toJSON(_: QueryParamsRequest): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial(_: DeepPartial): QueryParamsRequest { + const message = { ...baseQueryParamsRequest } as QueryParamsRequest; + return message; + }, +}; + +const baseQueryParamsResponse: object = {}; + +export const QueryParamsResponse = { + encode( + message: QueryParamsResponse, + writer: Writer = Writer.create() + ): Writer { + if (message.params !== undefined) { + Params.encode(message.params, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QueryParamsResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryParamsResponse } as QueryParamsResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.params = Params.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryParamsResponse { + const message = { ...baseQueryParamsResponse } as QueryParamsResponse; + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromJSON(object.params); + } else { + message.params = undefined; + } + return message; + }, + + toJSON(message: QueryParamsResponse): unknown { + const obj: any = {}; + message.params !== undefined && + (obj.params = message.params ? Params.toJSON(message.params) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): QueryParamsResponse { + const message = { ...baseQueryParamsResponse } as QueryParamsResponse; + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromPartial(object.params); + } else { + message.params = undefined; + } + return message; + }, +}; + +const baseQueryAcceptedDomainRequest: object = {}; + +export const QueryAcceptedDomainRequest = { + encode( + message: QueryAcceptedDomainRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryAcceptedDomainRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryAcceptedDomainRequest, + } as QueryAcceptedDomainRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryAcceptedDomainRequest { + const message = { + ...baseQueryAcceptedDomainRequest, + } as QueryAcceptedDomainRequest; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryAcceptedDomainRequest): unknown { + const obj: any = {}; + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageRequest.toJSON(message.pagination) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryAcceptedDomainRequest { + const message = { + ...baseQueryAcceptedDomainRequest, + } as QueryAcceptedDomainRequest; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseQueryAcceptedDomainResponse: object = {}; + +export const QueryAcceptedDomainResponse = { + encode( + message: QueryAcceptedDomainResponse, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.acceptedDomain) { + AcceptedDomain.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode( + message.pagination, + writer.uint32(18).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryAcceptedDomainResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryAcceptedDomainResponse, + } as QueryAcceptedDomainResponse; + message.acceptedDomain = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.acceptedDomain.push( + AcceptedDomain.decode(reader, reader.uint32()) + ); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryAcceptedDomainResponse { + const message = { + ...baseQueryAcceptedDomainResponse, + } as QueryAcceptedDomainResponse; + message.acceptedDomain = []; + if (object.acceptedDomain !== undefined && object.acceptedDomain !== null) { + for (const e of object.acceptedDomain) { + message.acceptedDomain.push(AcceptedDomain.fromJSON(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryAcceptedDomainResponse): unknown { + const obj: any = {}; + if (message.acceptedDomain) { + obj.acceptedDomain = message.acceptedDomain.map((e) => + e ? AcceptedDomain.toJSON(e) : undefined + ); + } else { + obj.acceptedDomain = []; + } + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageResponse.toJSON(message.pagination) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryAcceptedDomainResponse { + const message = { + ...baseQueryAcceptedDomainResponse, + } as QueryAcceptedDomainResponse; + message.acceptedDomain = []; + if (object.acceptedDomain !== undefined && object.acceptedDomain !== null) { + for (const e of object.acceptedDomain) { + message.acceptedDomain.push(AcceptedDomain.fromPartial(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseQueryPublisherRequest: object = {}; + +export const QueryPublisherRequest = { + encode( + message: QueryPublisherRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QueryPublisherRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryPublisherRequest } as QueryPublisherRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryPublisherRequest { + const message = { ...baseQueryPublisherRequest } as QueryPublisherRequest; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryPublisherRequest): unknown { + const obj: any = {}; + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageRequest.toJSON(message.pagination) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryPublisherRequest { + const message = { ...baseQueryPublisherRequest } as QueryPublisherRequest; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseQueryPublisherResponse: object = {}; + +export const QueryPublisherResponse = { + encode( + message: QueryPublisherResponse, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.publisher) { + Publisher.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode( + message.pagination, + writer.uint32(18).fork() + ).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QueryPublisherResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryPublisherResponse } as QueryPublisherResponse; + message.publisher = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.publisher.push(Publisher.decode(reader, reader.uint32())); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryPublisherResponse { + const message = { ...baseQueryPublisherResponse } as QueryPublisherResponse; + message.publisher = []; + if (object.publisher !== undefined && object.publisher !== null) { + for (const e of object.publisher) { + message.publisher.push(Publisher.fromJSON(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryPublisherResponse): unknown { + const obj: any = {}; + if (message.publisher) { + obj.publisher = message.publisher.map((e) => + e ? Publisher.toJSON(e) : undefined + ); + } else { + obj.publisher = []; + } + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageResponse.toJSON(message.pagination) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryPublisherResponse { + const message = { ...baseQueryPublisherResponse } as QueryPublisherResponse; + message.publisher = []; + if (object.publisher !== undefined && object.publisher !== null) { + for (const e of object.publisher) { + message.publisher.push(Publisher.fromPartial(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseQueryPublisherByIndexRequest: object = { index: "" }; + +export const QueryPublisherByIndexRequest = { + encode( + message: QueryPublisherByIndexRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.index !== "") { + writer.uint32(10).string(message.index); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryPublisherByIndexRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryPublisherByIndexRequest, + } as QueryPublisherByIndexRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.index = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryPublisherByIndexRequest { + const message = { + ...baseQueryPublisherByIndexRequest, + } as QueryPublisherByIndexRequest; + if (object.index !== undefined && object.index !== null) { + message.index = String(object.index); + } else { + message.index = ""; + } + return message; + }, + + toJSON(message: QueryPublisherByIndexRequest): unknown { + const obj: any = {}; + message.index !== undefined && (obj.index = message.index); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryPublisherByIndexRequest { + const message = { + ...baseQueryPublisherByIndexRequest, + } as QueryPublisherByIndexRequest; + if (object.index !== undefined && object.index !== null) { + message.index = object.index; + } else { + message.index = ""; + } + return message; + }, +}; + +const baseQueryPublisherByIndexResponse: object = {}; + +export const QueryPublisherByIndexResponse = { + encode( + message: QueryPublisherByIndexResponse, + writer: Writer = Writer.create() + ): Writer { + if (message.publisher !== undefined) { + Publisher.encode(message.publisher, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryPublisherByIndexResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryPublisherByIndexResponse, + } as QueryPublisherByIndexResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.publisher = Publisher.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryPublisherByIndexResponse { + const message = { + ...baseQueryPublisherByIndexResponse, + } as QueryPublisherByIndexResponse; + if (object.publisher !== undefined && object.publisher !== null) { + message.publisher = Publisher.fromJSON(object.publisher); + } else { + message.publisher = undefined; + } + return message; + }, + + toJSON(message: QueryPublisherByIndexResponse): unknown { + const obj: any = {}; + message.publisher !== undefined && + (obj.publisher = message.publisher + ? Publisher.toJSON(message.publisher) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryPublisherByIndexResponse { + const message = { + ...baseQueryPublisherByIndexResponse, + } as QueryPublisherByIndexResponse; + if (object.publisher !== undefined && object.publisher !== null) { + message.publisher = Publisher.fromPartial(object.publisher); + } else { + message.publisher = undefined; + } + return message; + }, +}; + +const baseQueryAllArticlesRequest: object = {}; + +export const QueryAllArticlesRequest = { + encode( + message: QueryAllArticlesRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QueryAllArticlesRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryAllArticlesRequest, + } as QueryAllArticlesRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryAllArticlesRequest { + const message = { + ...baseQueryAllArticlesRequest, + } as QueryAllArticlesRequest; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryAllArticlesRequest): unknown { + const obj: any = {}; + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageRequest.toJSON(message.pagination) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryAllArticlesRequest { + const message = { + ...baseQueryAllArticlesRequest, + } as QueryAllArticlesRequest; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseQueryAllArticlesResponse: object = {}; + +export const QueryAllArticlesResponse = { + encode( + message: QueryAllArticlesResponse, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.article) { + Article.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode( + message.pagination, + writer.uint32(18).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryAllArticlesResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryAllArticlesResponse, + } as QueryAllArticlesResponse; + message.article = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.article.push(Article.decode(reader, reader.uint32())); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryAllArticlesResponse { + const message = { + ...baseQueryAllArticlesResponse, + } as QueryAllArticlesResponse; + message.article = []; + if (object.article !== undefined && object.article !== null) { + for (const e of object.article) { + message.article.push(Article.fromJSON(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryAllArticlesResponse): unknown { + const obj: any = {}; + if (message.article) { + obj.article = message.article.map((e) => + e ? Article.toJSON(e) : undefined + ); + } else { + obj.article = []; + } + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageResponse.toJSON(message.pagination) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryAllArticlesResponse { + const message = { + ...baseQueryAllArticlesResponse, + } as QueryAllArticlesResponse; + message.article = []; + if (object.article !== undefined && object.article !== null) { + for (const e of object.article) { + message.article.push(Article.fromPartial(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseQueryAllAnonArticlesCountersRequest: object = {}; + +export const QueryAllAnonArticlesCountersRequest = { + encode( + message: QueryAllAnonArticlesCountersRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryAllAnonArticlesCountersRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryAllAnonArticlesCountersRequest, + } as QueryAllAnonArticlesCountersRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryAllAnonArticlesCountersRequest { + const message = { + ...baseQueryAllAnonArticlesCountersRequest, + } as QueryAllAnonArticlesCountersRequest; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryAllAnonArticlesCountersRequest): unknown { + const obj: any = {}; + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageRequest.toJSON(message.pagination) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryAllAnonArticlesCountersRequest { + const message = { + ...baseQueryAllAnonArticlesCountersRequest, + } as QueryAllAnonArticlesCountersRequest; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseQueryAllAnonArticlesCountersResponse: object = {}; + +export const QueryAllAnonArticlesCountersResponse = { + encode( + message: QueryAllAnonArticlesCountersResponse, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.AnonArticlesCounters) { + AnonArticlesCounter.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode( + message.pagination, + writer.uint32(18).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryAllAnonArticlesCountersResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryAllAnonArticlesCountersResponse, + } as QueryAllAnonArticlesCountersResponse; + message.AnonArticlesCounters = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.AnonArticlesCounters.push( + AnonArticlesCounter.decode(reader, reader.uint32()) + ); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryAllAnonArticlesCountersResponse { + const message = { + ...baseQueryAllAnonArticlesCountersResponse, + } as QueryAllAnonArticlesCountersResponse; + message.AnonArticlesCounters = []; + if ( + object.AnonArticlesCounters !== undefined && + object.AnonArticlesCounters !== null + ) { + for (const e of object.AnonArticlesCounters) { + message.AnonArticlesCounters.push(AnonArticlesCounter.fromJSON(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryAllAnonArticlesCountersResponse): unknown { + const obj: any = {}; + if (message.AnonArticlesCounters) { + obj.AnonArticlesCounters = message.AnonArticlesCounters.map((e) => + e ? AnonArticlesCounter.toJSON(e) : undefined + ); + } else { + obj.AnonArticlesCounters = []; + } + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageResponse.toJSON(message.pagination) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryAllAnonArticlesCountersResponse { + const message = { + ...baseQueryAllAnonArticlesCountersResponse, + } as QueryAllAnonArticlesCountersResponse; + message.AnonArticlesCounters = []; + if ( + object.AnonArticlesCounters !== undefined && + object.AnonArticlesCounters !== null + ) { + for (const e of object.AnonArticlesCounters) { + message.AnonArticlesCounters.push(AnonArticlesCounter.fromPartial(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +/** Query defines the gRPC querier service. */ +export interface Query { + /** Parameters queries the parameters of the module. */ + Params(request: QueryParamsRequest): Promise; + /** Queries a list of AcceptedDomain items. */ + AcceptedDomain( + request: QueryAcceptedDomainRequest + ): Promise; + /** Queries a list of Publisher items. */ + Publisher(request: QueryPublisherRequest): Promise; + /** Queries publisher by index/address. */ + PublisherByIndex( + request: QueryPublisherByIndexRequest + ): Promise; + /** Queries a list of Article items. */ + AllArticles( + request: QueryAllArticlesRequest + ): Promise; + /** Queries a list of AllAnonArticlesCounters items. */ + AllAnonArticlesCounters( + request: QueryAllAnonArticlesCountersRequest + ): Promise; +} + +export class QueryClientImpl implements Query { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + } + Params(request: QueryParamsRequest): Promise { + const data = QueryParamsRequest.encode(request).finish(); + const promise = this.rpc.request("bze.cointrunk.v1.Query", "Params", data); + return promise.then((data) => QueryParamsResponse.decode(new Reader(data))); + } + + AcceptedDomain( + request: QueryAcceptedDomainRequest + ): Promise { + const data = QueryAcceptedDomainRequest.encode(request).finish(); + const promise = this.rpc.request( + "bze.cointrunk.v1.Query", + "AcceptedDomain", + data + ); + return promise.then((data) => + QueryAcceptedDomainResponse.decode(new Reader(data)) + ); + } + + Publisher(request: QueryPublisherRequest): Promise { + const data = QueryPublisherRequest.encode(request).finish(); + const promise = this.rpc.request( + "bze.cointrunk.v1.Query", + "Publisher", + data + ); + return promise.then((data) => + QueryPublisherResponse.decode(new Reader(data)) + ); + } + + PublisherByIndex( + request: QueryPublisherByIndexRequest + ): Promise { + const data = QueryPublisherByIndexRequest.encode(request).finish(); + const promise = this.rpc.request( + "bze.cointrunk.v1.Query", + "PublisherByIndex", + data + ); + return promise.then((data) => + QueryPublisherByIndexResponse.decode(new Reader(data)) + ); + } + + AllArticles( + request: QueryAllArticlesRequest + ): Promise { + const data = QueryAllArticlesRequest.encode(request).finish(); + const promise = this.rpc.request( + "bze.cointrunk.v1.Query", + "AllArticles", + data + ); + return promise.then((data) => + QueryAllArticlesResponse.decode(new Reader(data)) + ); + } + + AllAnonArticlesCounters( + request: QueryAllAnonArticlesCountersRequest + ): Promise { + const data = QueryAllAnonArticlesCountersRequest.encode(request).finish(); + const promise = this.rpc.request( + "bze.cointrunk.v1.Query", + "AllAnonArticlesCounters", + data + ); + return promise.then((data) => + QueryAllAnonArticlesCountersResponse.decode(new Reader(data)) + ); + } +} + +interface Rpc { + request( + service: string, + method: string, + data: Uint8Array + ): Promise; +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/bze.cointrunk.v1/types/cointrunk/tx.ts b/ts-client/bze.cointrunk.v1/types/cointrunk/tx.ts new file mode 100644 index 00000000..474e7625 --- /dev/null +++ b/ts-client/bze.cointrunk.v1/types/cointrunk/tx.ts @@ -0,0 +1,477 @@ +/* eslint-disable */ +import { Reader, util, configure, Writer } from "protobufjs/minimal"; +import * as Long from "long"; + +export const protobufPackage = "bze.cointrunk.v1"; + +export interface MsgAddArticle { + publisher: string; + title: string; + url: string; + picture: string; +} + +export interface MsgAddArticleResponse {} + +export interface MsgPayPublisherRespect { + creator: string; + address: string; + amount: string; +} + +export interface MsgPayPublisherRespectResponse { + respectPaid: number; + publisherReward: number; + communityPoolFunds: number; +} + +const baseMsgAddArticle: object = { + publisher: "", + title: "", + url: "", + picture: "", +}; + +export const MsgAddArticle = { + encode(message: MsgAddArticle, writer: Writer = Writer.create()): Writer { + if (message.publisher !== "") { + writer.uint32(10).string(message.publisher); + } + if (message.title !== "") { + writer.uint32(18).string(message.title); + } + if (message.url !== "") { + writer.uint32(26).string(message.url); + } + if (message.picture !== "") { + writer.uint32(34).string(message.picture); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MsgAddArticle { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgAddArticle } as MsgAddArticle; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.publisher = reader.string(); + break; + case 2: + message.title = reader.string(); + break; + case 3: + message.url = reader.string(); + break; + case 4: + message.picture = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgAddArticle { + const message = { ...baseMsgAddArticle } as MsgAddArticle; + if (object.publisher !== undefined && object.publisher !== null) { + message.publisher = String(object.publisher); + } else { + message.publisher = ""; + } + if (object.title !== undefined && object.title !== null) { + message.title = String(object.title); + } else { + message.title = ""; + } + if (object.url !== undefined && object.url !== null) { + message.url = String(object.url); + } else { + message.url = ""; + } + if (object.picture !== undefined && object.picture !== null) { + message.picture = String(object.picture); + } else { + message.picture = ""; + } + return message; + }, + + toJSON(message: MsgAddArticle): unknown { + const obj: any = {}; + message.publisher !== undefined && (obj.publisher = message.publisher); + message.title !== undefined && (obj.title = message.title); + message.url !== undefined && (obj.url = message.url); + message.picture !== undefined && (obj.picture = message.picture); + return obj; + }, + + fromPartial(object: DeepPartial): MsgAddArticle { + const message = { ...baseMsgAddArticle } as MsgAddArticle; + if (object.publisher !== undefined && object.publisher !== null) { + message.publisher = object.publisher; + } else { + message.publisher = ""; + } + if (object.title !== undefined && object.title !== null) { + message.title = object.title; + } else { + message.title = ""; + } + if (object.url !== undefined && object.url !== null) { + message.url = object.url; + } else { + message.url = ""; + } + if (object.picture !== undefined && object.picture !== null) { + message.picture = object.picture; + } else { + message.picture = ""; + } + return message; + }, +}; + +const baseMsgAddArticleResponse: object = {}; + +export const MsgAddArticleResponse = { + encode(_: MsgAddArticleResponse, writer: Writer = Writer.create()): Writer { + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MsgAddArticleResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgAddArticleResponse } as MsgAddArticleResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): MsgAddArticleResponse { + const message = { ...baseMsgAddArticleResponse } as MsgAddArticleResponse; + return message; + }, + + toJSON(_: MsgAddArticleResponse): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial(_: DeepPartial): MsgAddArticleResponse { + const message = { ...baseMsgAddArticleResponse } as MsgAddArticleResponse; + return message; + }, +}; + +const baseMsgPayPublisherRespect: object = { + creator: "", + address: "", + amount: "", +}; + +export const MsgPayPublisherRespect = { + encode( + message: MsgPayPublisherRespect, + writer: Writer = Writer.create() + ): Writer { + if (message.creator !== "") { + writer.uint32(10).string(message.creator); + } + if (message.address !== "") { + writer.uint32(18).string(message.address); + } + if (message.amount !== "") { + writer.uint32(26).string(message.amount); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MsgPayPublisherRespect { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgPayPublisherRespect } as MsgPayPublisherRespect; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.creator = reader.string(); + break; + case 2: + message.address = reader.string(); + break; + case 3: + message.amount = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgPayPublisherRespect { + const message = { ...baseMsgPayPublisherRespect } as MsgPayPublisherRespect; + if (object.creator !== undefined && object.creator !== null) { + message.creator = String(object.creator); + } else { + message.creator = ""; + } + if (object.address !== undefined && object.address !== null) { + message.address = String(object.address); + } else { + message.address = ""; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = String(object.amount); + } else { + message.amount = ""; + } + return message; + }, + + toJSON(message: MsgPayPublisherRespect): unknown { + const obj: any = {}; + message.creator !== undefined && (obj.creator = message.creator); + message.address !== undefined && (obj.address = message.address); + message.amount !== undefined && (obj.amount = message.amount); + return obj; + }, + + fromPartial( + object: DeepPartial + ): MsgPayPublisherRespect { + const message = { ...baseMsgPayPublisherRespect } as MsgPayPublisherRespect; + if (object.creator !== undefined && object.creator !== null) { + message.creator = object.creator; + } else { + message.creator = ""; + } + if (object.address !== undefined && object.address !== null) { + message.address = object.address; + } else { + message.address = ""; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = object.amount; + } else { + message.amount = ""; + } + return message; + }, +}; + +const baseMsgPayPublisherRespectResponse: object = { + respectPaid: 0, + publisherReward: 0, + communityPoolFunds: 0, +}; + +export const MsgPayPublisherRespectResponse = { + encode( + message: MsgPayPublisherRespectResponse, + writer: Writer = Writer.create() + ): Writer { + if (message.respectPaid !== 0) { + writer.uint32(8).uint64(message.respectPaid); + } + if (message.publisherReward !== 0) { + writer.uint32(16).uint64(message.publisherReward); + } + if (message.communityPoolFunds !== 0) { + writer.uint32(24).uint64(message.communityPoolFunds); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): MsgPayPublisherRespectResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseMsgPayPublisherRespectResponse, + } as MsgPayPublisherRespectResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.respectPaid = longToNumber(reader.uint64() as Long); + break; + case 2: + message.publisherReward = longToNumber(reader.uint64() as Long); + break; + case 3: + message.communityPoolFunds = longToNumber(reader.uint64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgPayPublisherRespectResponse { + const message = { + ...baseMsgPayPublisherRespectResponse, + } as MsgPayPublisherRespectResponse; + if (object.respectPaid !== undefined && object.respectPaid !== null) { + message.respectPaid = Number(object.respectPaid); + } else { + message.respectPaid = 0; + } + if ( + object.publisherReward !== undefined && + object.publisherReward !== null + ) { + message.publisherReward = Number(object.publisherReward); + } else { + message.publisherReward = 0; + } + if ( + object.communityPoolFunds !== undefined && + object.communityPoolFunds !== null + ) { + message.communityPoolFunds = Number(object.communityPoolFunds); + } else { + message.communityPoolFunds = 0; + } + return message; + }, + + toJSON(message: MsgPayPublisherRespectResponse): unknown { + const obj: any = {}; + message.respectPaid !== undefined && + (obj.respectPaid = message.respectPaid); + message.publisherReward !== undefined && + (obj.publisherReward = message.publisherReward); + message.communityPoolFunds !== undefined && + (obj.communityPoolFunds = message.communityPoolFunds); + return obj; + }, + + fromPartial( + object: DeepPartial + ): MsgPayPublisherRespectResponse { + const message = { + ...baseMsgPayPublisherRespectResponse, + } as MsgPayPublisherRespectResponse; + if (object.respectPaid !== undefined && object.respectPaid !== null) { + message.respectPaid = object.respectPaid; + } else { + message.respectPaid = 0; + } + if ( + object.publisherReward !== undefined && + object.publisherReward !== null + ) { + message.publisherReward = object.publisherReward; + } else { + message.publisherReward = 0; + } + if ( + object.communityPoolFunds !== undefined && + object.communityPoolFunds !== null + ) { + message.communityPoolFunds = object.communityPoolFunds; + } else { + message.communityPoolFunds = 0; + } + return message; + }, +}; + +/** Msg defines the Msg service. */ +export interface Msg { + AddArticle(request: MsgAddArticle): Promise; + /** this line is used by starport scaffolding # proto/tx/rpc */ + PayPublisherRespect( + request: MsgPayPublisherRespect + ): Promise; +} + +export class MsgClientImpl implements Msg { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + } + AddArticle(request: MsgAddArticle): Promise { + const data = MsgAddArticle.encode(request).finish(); + const promise = this.rpc.request( + "bze.cointrunk.v1.Msg", + "AddArticle", + data + ); + return promise.then((data) => + MsgAddArticleResponse.decode(new Reader(data)) + ); + } + + PayPublisherRespect( + request: MsgPayPublisherRespect + ): Promise { + const data = MsgPayPublisherRespect.encode(request).finish(); + const promise = this.rpc.request( + "bze.cointrunk.v1.Msg", + "PayPublisherRespect", + data + ); + return promise.then((data) => + MsgPayPublisherRespectResponse.decode(new Reader(data)) + ); + } +} + +interface Rpc { + request( + service: string, + method: string, + data: Uint8Array + ): Promise; +} + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/bze.cointrunk.v1/types/cosmos/base/query/v1beta1/pagination.ts b/ts-client/bze.cointrunk.v1/types/cosmos/base/query/v1beta1/pagination.ts new file mode 100644 index 00000000..cd4b2d78 --- /dev/null +++ b/ts-client/bze.cointrunk.v1/types/cosmos/base/query/v1beta1/pagination.ts @@ -0,0 +1,327 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "cosmos.base.query.v1beta1"; + +/** + * PageRequest is to be embedded in gRPC request messages for efficient + * pagination. Ex: + * + * message SomeRequest { + * Foo some_parameter = 1; + * PageRequest pagination = 2; + * } + */ +export interface PageRequest { + /** + * key is a value returned in PageResponse.next_key to begin + * querying the next page most efficiently. Only one of offset or key + * should be set. + */ + key: Uint8Array; + /** + * offset is a numeric offset that can be used when key is unavailable. + * It is less efficient than using key. Only one of offset or key should + * be set. + */ + offset: number; + /** + * limit is the total number of results to be returned in the result page. + * If left empty it will default to a value to be set by each app. + */ + limit: number; + /** + * count_total is set to true to indicate that the result set should include + * a count of the total number of items available for pagination in UIs. + * count_total is only respected when offset is used. It is ignored when key + * is set. + */ + countTotal: boolean; + /** + * reverse is set to true if results are to be returned in the descending order. + * + * Since: cosmos-sdk 0.43 + */ + reverse: boolean; +} + +/** + * PageResponse is to be embedded in gRPC response messages where the + * corresponding request message has used PageRequest. + * + * message SomeResponse { + * repeated Bar results = 1; + * PageResponse page = 2; + * } + */ +export interface PageResponse { + /** + * next_key is the key to be passed to PageRequest.key to + * query the next page most efficiently + */ + nextKey: Uint8Array; + /** + * total is total number of results available if PageRequest.count_total + * was set, its value is undefined otherwise + */ + total: number; +} + +const basePageRequest: object = { + offset: 0, + limit: 0, + countTotal: false, + reverse: false, +}; + +export const PageRequest = { + encode(message: PageRequest, writer: Writer = Writer.create()): Writer { + if (message.key.length !== 0) { + writer.uint32(10).bytes(message.key); + } + if (message.offset !== 0) { + writer.uint32(16).uint64(message.offset); + } + if (message.limit !== 0) { + writer.uint32(24).uint64(message.limit); + } + if (message.countTotal === true) { + writer.uint32(32).bool(message.countTotal); + } + if (message.reverse === true) { + writer.uint32(40).bool(message.reverse); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): PageRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...basePageRequest } as PageRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.key = reader.bytes(); + break; + case 2: + message.offset = longToNumber(reader.uint64() as Long); + break; + case 3: + message.limit = longToNumber(reader.uint64() as Long); + break; + case 4: + message.countTotal = reader.bool(); + break; + case 5: + message.reverse = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): PageRequest { + const message = { ...basePageRequest } as PageRequest; + if (object.key !== undefined && object.key !== null) { + message.key = bytesFromBase64(object.key); + } + if (object.offset !== undefined && object.offset !== null) { + message.offset = Number(object.offset); + } else { + message.offset = 0; + } + if (object.limit !== undefined && object.limit !== null) { + message.limit = Number(object.limit); + } else { + message.limit = 0; + } + if (object.countTotal !== undefined && object.countTotal !== null) { + message.countTotal = Boolean(object.countTotal); + } else { + message.countTotal = false; + } + if (object.reverse !== undefined && object.reverse !== null) { + message.reverse = Boolean(object.reverse); + } else { + message.reverse = false; + } + return message; + }, + + toJSON(message: PageRequest): unknown { + const obj: any = {}; + message.key !== undefined && + (obj.key = base64FromBytes( + message.key !== undefined ? message.key : new Uint8Array() + )); + message.offset !== undefined && (obj.offset = message.offset); + message.limit !== undefined && (obj.limit = message.limit); + message.countTotal !== undefined && (obj.countTotal = message.countTotal); + message.reverse !== undefined && (obj.reverse = message.reverse); + return obj; + }, + + fromPartial(object: DeepPartial): PageRequest { + const message = { ...basePageRequest } as PageRequest; + if (object.key !== undefined && object.key !== null) { + message.key = object.key; + } else { + message.key = new Uint8Array(); + } + if (object.offset !== undefined && object.offset !== null) { + message.offset = object.offset; + } else { + message.offset = 0; + } + if (object.limit !== undefined && object.limit !== null) { + message.limit = object.limit; + } else { + message.limit = 0; + } + if (object.countTotal !== undefined && object.countTotal !== null) { + message.countTotal = object.countTotal; + } else { + message.countTotal = false; + } + if (object.reverse !== undefined && object.reverse !== null) { + message.reverse = object.reverse; + } else { + message.reverse = false; + } + return message; + }, +}; + +const basePageResponse: object = { total: 0 }; + +export const PageResponse = { + encode(message: PageResponse, writer: Writer = Writer.create()): Writer { + if (message.nextKey.length !== 0) { + writer.uint32(10).bytes(message.nextKey); + } + if (message.total !== 0) { + writer.uint32(16).uint64(message.total); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): PageResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...basePageResponse } as PageResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.nextKey = reader.bytes(); + break; + case 2: + message.total = longToNumber(reader.uint64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): PageResponse { + const message = { ...basePageResponse } as PageResponse; + if (object.nextKey !== undefined && object.nextKey !== null) { + message.nextKey = bytesFromBase64(object.nextKey); + } + if (object.total !== undefined && object.total !== null) { + message.total = Number(object.total); + } else { + message.total = 0; + } + return message; + }, + + toJSON(message: PageResponse): unknown { + const obj: any = {}; + message.nextKey !== undefined && + (obj.nextKey = base64FromBytes( + message.nextKey !== undefined ? message.nextKey : new Uint8Array() + )); + message.total !== undefined && (obj.total = message.total); + return obj; + }, + + fromPartial(object: DeepPartial): PageResponse { + const message = { ...basePageResponse } as PageResponse; + if (object.nextKey !== undefined && object.nextKey !== null) { + message.nextKey = object.nextKey; + } else { + message.nextKey = new Uint8Array(); + } + if (object.total !== undefined && object.total !== null) { + message.total = object.total; + } else { + message.total = 0; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/bze.cointrunk.v1/types/cosmos/base/v1beta1/coin.ts b/ts-client/bze.cointrunk.v1/types/cosmos/base/v1beta1/coin.ts new file mode 100644 index 00000000..ce2ac984 --- /dev/null +++ b/ts-client/bze.cointrunk.v1/types/cosmos/base/v1beta1/coin.ts @@ -0,0 +1,301 @@ +/* eslint-disable */ +import { Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "cosmos.base.v1beta1"; + +/** + * Coin defines a token with a denomination and an amount. + * + * NOTE: The amount field is an Int which implements the custom method + * signatures required by gogoproto. + */ +export interface Coin { + denom: string; + amount: string; +} + +/** + * DecCoin defines a token with a denomination and a decimal amount. + * + * NOTE: The amount field is an Dec which implements the custom method + * signatures required by gogoproto. + */ +export interface DecCoin { + denom: string; + amount: string; +} + +/** IntProto defines a Protobuf wrapper around an Int object. */ +export interface IntProto { + int: string; +} + +/** DecProto defines a Protobuf wrapper around a Dec object. */ +export interface DecProto { + dec: string; +} + +const baseCoin: object = { denom: "", amount: "" }; + +export const Coin = { + encode(message: Coin, writer: Writer = Writer.create()): Writer { + if (message.denom !== "") { + writer.uint32(10).string(message.denom); + } + if (message.amount !== "") { + writer.uint32(18).string(message.amount); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Coin { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseCoin } as Coin; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.denom = reader.string(); + break; + case 2: + message.amount = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Coin { + const message = { ...baseCoin } as Coin; + if (object.denom !== undefined && object.denom !== null) { + message.denom = String(object.denom); + } else { + message.denom = ""; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = String(object.amount); + } else { + message.amount = ""; + } + return message; + }, + + toJSON(message: Coin): unknown { + const obj: any = {}; + message.denom !== undefined && (obj.denom = message.denom); + message.amount !== undefined && (obj.amount = message.amount); + return obj; + }, + + fromPartial(object: DeepPartial): Coin { + const message = { ...baseCoin } as Coin; + if (object.denom !== undefined && object.denom !== null) { + message.denom = object.denom; + } else { + message.denom = ""; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = object.amount; + } else { + message.amount = ""; + } + return message; + }, +}; + +const baseDecCoin: object = { denom: "", amount: "" }; + +export const DecCoin = { + encode(message: DecCoin, writer: Writer = Writer.create()): Writer { + if (message.denom !== "") { + writer.uint32(10).string(message.denom); + } + if (message.amount !== "") { + writer.uint32(18).string(message.amount); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): DecCoin { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseDecCoin } as DecCoin; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.denom = reader.string(); + break; + case 2: + message.amount = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DecCoin { + const message = { ...baseDecCoin } as DecCoin; + if (object.denom !== undefined && object.denom !== null) { + message.denom = String(object.denom); + } else { + message.denom = ""; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = String(object.amount); + } else { + message.amount = ""; + } + return message; + }, + + toJSON(message: DecCoin): unknown { + const obj: any = {}; + message.denom !== undefined && (obj.denom = message.denom); + message.amount !== undefined && (obj.amount = message.amount); + return obj; + }, + + fromPartial(object: DeepPartial): DecCoin { + const message = { ...baseDecCoin } as DecCoin; + if (object.denom !== undefined && object.denom !== null) { + message.denom = object.denom; + } else { + message.denom = ""; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = object.amount; + } else { + message.amount = ""; + } + return message; + }, +}; + +const baseIntProto: object = { int: "" }; + +export const IntProto = { + encode(message: IntProto, writer: Writer = Writer.create()): Writer { + if (message.int !== "") { + writer.uint32(10).string(message.int); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): IntProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseIntProto } as IntProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.int = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): IntProto { + const message = { ...baseIntProto } as IntProto; + if (object.int !== undefined && object.int !== null) { + message.int = String(object.int); + } else { + message.int = ""; + } + return message; + }, + + toJSON(message: IntProto): unknown { + const obj: any = {}; + message.int !== undefined && (obj.int = message.int); + return obj; + }, + + fromPartial(object: DeepPartial): IntProto { + const message = { ...baseIntProto } as IntProto; + if (object.int !== undefined && object.int !== null) { + message.int = object.int; + } else { + message.int = ""; + } + return message; + }, +}; + +const baseDecProto: object = { dec: "" }; + +export const DecProto = { + encode(message: DecProto, writer: Writer = Writer.create()): Writer { + if (message.dec !== "") { + writer.uint32(10).string(message.dec); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): DecProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseDecProto } as DecProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.dec = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DecProto { + const message = { ...baseDecProto } as DecProto; + if (object.dec !== undefined && object.dec !== null) { + message.dec = String(object.dec); + } else { + message.dec = ""; + } + return message; + }, + + toJSON(message: DecProto): unknown { + const obj: any = {}; + message.dec !== undefined && (obj.dec = message.dec); + return obj; + }, + + fromPartial(object: DeepPartial): DecProto { + const message = { ...baseDecProto } as DecProto; + if (object.dec !== undefined && object.dec !== null) { + message.dec = object.dec; + } else { + message.dec = ""; + } + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/bze.cointrunk.v1/types/gogoproto/gogo.ts b/ts-client/bze.cointrunk.v1/types/gogoproto/gogo.ts new file mode 100644 index 00000000..3f41a047 --- /dev/null +++ b/ts-client/bze.cointrunk.v1/types/gogoproto/gogo.ts @@ -0,0 +1,2 @@ +/* eslint-disable */ +export const protobufPackage = "gogoproto"; diff --git a/ts-client/bze.cointrunk.v1/types/google/api/annotations.ts b/ts-client/bze.cointrunk.v1/types/google/api/annotations.ts new file mode 100644 index 00000000..aace4787 --- /dev/null +++ b/ts-client/bze.cointrunk.v1/types/google/api/annotations.ts @@ -0,0 +1,2 @@ +/* eslint-disable */ +export const protobufPackage = "google.api"; diff --git a/ts-client/bze.cointrunk.v1/types/google/api/http.ts b/ts-client/bze.cointrunk.v1/types/google/api/http.ts new file mode 100644 index 00000000..ddc00f8b --- /dev/null +++ b/ts-client/bze.cointrunk.v1/types/google/api/http.ts @@ -0,0 +1,705 @@ +/* eslint-disable */ +import { Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "google.api"; + +/** + * Defines the HTTP configuration for an API service. It contains a list of + * [HttpRule][google.api.HttpRule], each specifying the mapping of an RPC method + * to one or more HTTP REST API methods. + */ +export interface Http { + /** + * A list of HTTP configuration rules that apply to individual API methods. + * + * **NOTE:** All service configuration rules follow "last one wins" order. + */ + rules: HttpRule[]; + /** + * When set to true, URL path parmeters will be fully URI-decoded except in + * cases of single segment matches in reserved expansion, where "%2F" will be + * left encoded. + * + * The default behavior is to not decode RFC 6570 reserved characters in multi + * segment matches. + */ + fullyDecodeReservedExpansion: boolean; +} + +/** + * `HttpRule` defines the mapping of an RPC method to one or more HTTP + * REST API methods. The mapping specifies how different portions of the RPC + * request message are mapped to URL path, URL query parameters, and + * HTTP request body. The mapping is typically specified as an + * `google.api.http` annotation on the RPC method, + * see "google/api/annotations.proto" for details. + * + * The mapping consists of a field specifying the path template and + * method kind. The path template can refer to fields in the request + * message, as in the example below which describes a REST GET + * operation on a resource collection of messages: + * + * + * service Messaging { + * rpc GetMessage(GetMessageRequest) returns (Message) { + * option (google.api.http).get = "/v1/messages/{message_id}/{sub.subfield}"; + * } + * } + * message GetMessageRequest { + * message SubMessage { + * string subfield = 1; + * } + * string message_id = 1; // mapped to the URL + * SubMessage sub = 2; // `sub.subfield` is url-mapped + * } + * message Message { + * string text = 1; // content of the resource + * } + * + * The same http annotation can alternatively be expressed inside the + * `GRPC API Configuration` YAML file. + * + * http: + * rules: + * - selector: .Messaging.GetMessage + * get: /v1/messages/{message_id}/{sub.subfield} + * + * This definition enables an automatic, bidrectional mapping of HTTP + * JSON to RPC. Example: + * + * HTTP | RPC + * -----|----- + * `GET /v1/messages/123456/foo` | `GetMessage(message_id: "123456" sub: SubMessage(subfield: "foo"))` + * + * In general, not only fields but also field paths can be referenced + * from a path pattern. Fields mapped to the path pattern cannot be + * repeated and must have a primitive (non-message) type. + * + * Any fields in the request message which are not bound by the path + * pattern automatically become (optional) HTTP query + * parameters. Assume the following definition of the request message: + * + * + * service Messaging { + * rpc GetMessage(GetMessageRequest) returns (Message) { + * option (google.api.http).get = "/v1/messages/{message_id}"; + * } + * } + * message GetMessageRequest { + * message SubMessage { + * string subfield = 1; + * } + * string message_id = 1; // mapped to the URL + * int64 revision = 2; // becomes a parameter + * SubMessage sub = 3; // `sub.subfield` becomes a parameter + * } + * + * + * This enables a HTTP JSON to RPC mapping as below: + * + * HTTP | RPC + * -----|----- + * `GET /v1/messages/123456?revision=2&sub.subfield=foo` | `GetMessage(message_id: "123456" revision: 2 sub: SubMessage(subfield: "foo"))` + * + * Note that fields which are mapped to HTTP parameters must have a + * primitive type or a repeated primitive type. Message types are not + * allowed. In the case of a repeated type, the parameter can be + * repeated in the URL, as in `...?param=A¶m=B`. + * + * For HTTP method kinds which allow a request body, the `body` field + * specifies the mapping. Consider a REST update method on the + * message resource collection: + * + * + * service Messaging { + * rpc UpdateMessage(UpdateMessageRequest) returns (Message) { + * option (google.api.http) = { + * put: "/v1/messages/{message_id}" + * body: "message" + * }; + * } + * } + * message UpdateMessageRequest { + * string message_id = 1; // mapped to the URL + * Message message = 2; // mapped to the body + * } + * + * + * The following HTTP JSON to RPC mapping is enabled, where the + * representation of the JSON in the request body is determined by + * protos JSON encoding: + * + * HTTP | RPC + * -----|----- + * `PUT /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: "123456" message { text: "Hi!" })` + * + * The special name `*` can be used in the body mapping to define that + * every field not bound by the path template should be mapped to the + * request body. This enables the following alternative definition of + * the update method: + * + * service Messaging { + * rpc UpdateMessage(Message) returns (Message) { + * option (google.api.http) = { + * put: "/v1/messages/{message_id}" + * body: "*" + * }; + * } + * } + * message Message { + * string message_id = 1; + * string text = 2; + * } + * + * + * The following HTTP JSON to RPC mapping is enabled: + * + * HTTP | RPC + * -----|----- + * `PUT /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: "123456" text: "Hi!")` + * + * Note that when using `*` in the body mapping, it is not possible to + * have HTTP parameters, as all fields not bound by the path end in + * the body. This makes this option more rarely used in practice of + * defining REST APIs. The common usage of `*` is in custom methods + * which don't use the URL at all for transferring data. + * + * It is possible to define multiple HTTP methods for one RPC by using + * the `additional_bindings` option. Example: + * + * service Messaging { + * rpc GetMessage(GetMessageRequest) returns (Message) { + * option (google.api.http) = { + * get: "/v1/messages/{message_id}" + * additional_bindings { + * get: "/v1/users/{user_id}/messages/{message_id}" + * } + * }; + * } + * } + * message GetMessageRequest { + * string message_id = 1; + * string user_id = 2; + * } + * + * + * This enables the following two alternative HTTP JSON to RPC + * mappings: + * + * HTTP | RPC + * -----|----- + * `GET /v1/messages/123456` | `GetMessage(message_id: "123456")` + * `GET /v1/users/me/messages/123456` | `GetMessage(user_id: "me" message_id: "123456")` + * + * # Rules for HTTP mapping + * + * The rules for mapping HTTP path, query parameters, and body fields + * to the request message are as follows: + * + * 1. The `body` field specifies either `*` or a field path, or is + * omitted. If omitted, it indicates there is no HTTP request body. + * 2. Leaf fields (recursive expansion of nested messages in the + * request) can be classified into three types: + * (a) Matched in the URL template. + * (b) Covered by body (if body is `*`, everything except (a) fields; + * else everything under the body field) + * (c) All other fields. + * 3. URL query parameters found in the HTTP request are mapped to (c) fields. + * 4. Any body sent with an HTTP request can contain only (b) fields. + * + * The syntax of the path template is as follows: + * + * Template = "/" Segments [ Verb ] ; + * Segments = Segment { "/" Segment } ; + * Segment = "*" | "**" | LITERAL | Variable ; + * Variable = "{" FieldPath [ "=" Segments ] "}" ; + * FieldPath = IDENT { "." IDENT } ; + * Verb = ":" LITERAL ; + * + * The syntax `*` matches a single path segment. The syntax `**` matches zero + * or more path segments, which must be the last part of the path except the + * `Verb`. The syntax `LITERAL` matches literal text in the path. + * + * The syntax `Variable` matches part of the URL path as specified by its + * template. A variable template must not contain other variables. If a variable + * matches a single path segment, its template may be omitted, e.g. `{var}` + * is equivalent to `{var=*}`. + * + * If a variable contains exactly one path segment, such as `"{var}"` or + * `"{var=*}"`, when such a variable is expanded into a URL path, all characters + * except `[-_.~0-9a-zA-Z]` are percent-encoded. Such variables show up in the + * Discovery Document as `{var}`. + * + * If a variable contains one or more path segments, such as `"{var=foo/*}"` + * or `"{var=**}"`, when such a variable is expanded into a URL path, all + * characters except `[-_.~/0-9a-zA-Z]` are percent-encoded. Such variables + * show up in the Discovery Document as `{+var}`. + * + * NOTE: While the single segment variable matches the semantics of + * [RFC 6570](https://tools.ietf.org/html/rfc6570) Section 3.2.2 + * Simple String Expansion, the multi segment variable **does not** match + * RFC 6570 Reserved Expansion. The reason is that the Reserved Expansion + * does not expand special characters like `?` and `#`, which would lead + * to invalid URLs. + * + * NOTE: the field paths in variables and in the `body` must not refer to + * repeated fields or map fields. + */ +export interface HttpRule { + /** + * Selects methods to which this rule applies. + * + * Refer to [selector][google.api.DocumentationRule.selector] for syntax details. + */ + selector: string; + /** Used for listing and getting information about resources. */ + get: string | undefined; + /** Used for updating a resource. */ + put: string | undefined; + /** Used for creating a resource. */ + post: string | undefined; + /** Used for deleting a resource. */ + delete: string | undefined; + /** Used for updating a resource. */ + patch: string | undefined; + /** + * The custom pattern is used for specifying an HTTP method that is not + * included in the `pattern` field, such as HEAD, or "*" to leave the + * HTTP method unspecified for this rule. The wild-card rule is useful + * for services that provide content to Web (HTML) clients. + */ + custom: CustomHttpPattern | undefined; + /** + * The name of the request field whose value is mapped to the HTTP body, or + * `*` for mapping all fields not captured by the path pattern to the HTTP + * body. NOTE: the referred field must not be a repeated field and must be + * present at the top-level of request message type. + */ + body: string; + /** + * Optional. The name of the response field whose value is mapped to the HTTP + * body of response. Other response fields are ignored. When + * not set, the response message will be used as HTTP body of response. + */ + responseBody: string; + /** + * Additional HTTP bindings for the selector. Nested bindings must + * not contain an `additional_bindings` field themselves (that is, + * the nesting may only be one level deep). + */ + additionalBindings: HttpRule[]; +} + +/** A custom pattern is used for defining custom HTTP verb. */ +export interface CustomHttpPattern { + /** The name of this custom HTTP verb. */ + kind: string; + /** The path matched by this custom verb. */ + path: string; +} + +const baseHttp: object = { fullyDecodeReservedExpansion: false }; + +export const Http = { + encode(message: Http, writer: Writer = Writer.create()): Writer { + for (const v of message.rules) { + HttpRule.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.fullyDecodeReservedExpansion === true) { + writer.uint32(16).bool(message.fullyDecodeReservedExpansion); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Http { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseHttp } as Http; + message.rules = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.rules.push(HttpRule.decode(reader, reader.uint32())); + break; + case 2: + message.fullyDecodeReservedExpansion = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Http { + const message = { ...baseHttp } as Http; + message.rules = []; + if (object.rules !== undefined && object.rules !== null) { + for (const e of object.rules) { + message.rules.push(HttpRule.fromJSON(e)); + } + } + if ( + object.fullyDecodeReservedExpansion !== undefined && + object.fullyDecodeReservedExpansion !== null + ) { + message.fullyDecodeReservedExpansion = Boolean( + object.fullyDecodeReservedExpansion + ); + } else { + message.fullyDecodeReservedExpansion = false; + } + return message; + }, + + toJSON(message: Http): unknown { + const obj: any = {}; + if (message.rules) { + obj.rules = message.rules.map((e) => + e ? HttpRule.toJSON(e) : undefined + ); + } else { + obj.rules = []; + } + message.fullyDecodeReservedExpansion !== undefined && + (obj.fullyDecodeReservedExpansion = message.fullyDecodeReservedExpansion); + return obj; + }, + + fromPartial(object: DeepPartial): Http { + const message = { ...baseHttp } as Http; + message.rules = []; + if (object.rules !== undefined && object.rules !== null) { + for (const e of object.rules) { + message.rules.push(HttpRule.fromPartial(e)); + } + } + if ( + object.fullyDecodeReservedExpansion !== undefined && + object.fullyDecodeReservedExpansion !== null + ) { + message.fullyDecodeReservedExpansion = + object.fullyDecodeReservedExpansion; + } else { + message.fullyDecodeReservedExpansion = false; + } + return message; + }, +}; + +const baseHttpRule: object = { selector: "", body: "", responseBody: "" }; + +export const HttpRule = { + encode(message: HttpRule, writer: Writer = Writer.create()): Writer { + if (message.selector !== "") { + writer.uint32(10).string(message.selector); + } + if (message.get !== undefined) { + writer.uint32(18).string(message.get); + } + if (message.put !== undefined) { + writer.uint32(26).string(message.put); + } + if (message.post !== undefined) { + writer.uint32(34).string(message.post); + } + if (message.delete !== undefined) { + writer.uint32(42).string(message.delete); + } + if (message.patch !== undefined) { + writer.uint32(50).string(message.patch); + } + if (message.custom !== undefined) { + CustomHttpPattern.encode( + message.custom, + writer.uint32(66).fork() + ).ldelim(); + } + if (message.body !== "") { + writer.uint32(58).string(message.body); + } + if (message.responseBody !== "") { + writer.uint32(98).string(message.responseBody); + } + for (const v of message.additionalBindings) { + HttpRule.encode(v!, writer.uint32(90).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): HttpRule { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseHttpRule } as HttpRule; + message.additionalBindings = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.selector = reader.string(); + break; + case 2: + message.get = reader.string(); + break; + case 3: + message.put = reader.string(); + break; + case 4: + message.post = reader.string(); + break; + case 5: + message.delete = reader.string(); + break; + case 6: + message.patch = reader.string(); + break; + case 8: + message.custom = CustomHttpPattern.decode(reader, reader.uint32()); + break; + case 7: + message.body = reader.string(); + break; + case 12: + message.responseBody = reader.string(); + break; + case 11: + message.additionalBindings.push( + HttpRule.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): HttpRule { + const message = { ...baseHttpRule } as HttpRule; + message.additionalBindings = []; + if (object.selector !== undefined && object.selector !== null) { + message.selector = String(object.selector); + } else { + message.selector = ""; + } + if (object.get !== undefined && object.get !== null) { + message.get = String(object.get); + } else { + message.get = undefined; + } + if (object.put !== undefined && object.put !== null) { + message.put = String(object.put); + } else { + message.put = undefined; + } + if (object.post !== undefined && object.post !== null) { + message.post = String(object.post); + } else { + message.post = undefined; + } + if (object.delete !== undefined && object.delete !== null) { + message.delete = String(object.delete); + } else { + message.delete = undefined; + } + if (object.patch !== undefined && object.patch !== null) { + message.patch = String(object.patch); + } else { + message.patch = undefined; + } + if (object.custom !== undefined && object.custom !== null) { + message.custom = CustomHttpPattern.fromJSON(object.custom); + } else { + message.custom = undefined; + } + if (object.body !== undefined && object.body !== null) { + message.body = String(object.body); + } else { + message.body = ""; + } + if (object.responseBody !== undefined && object.responseBody !== null) { + message.responseBody = String(object.responseBody); + } else { + message.responseBody = ""; + } + if ( + object.additionalBindings !== undefined && + object.additionalBindings !== null + ) { + for (const e of object.additionalBindings) { + message.additionalBindings.push(HttpRule.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: HttpRule): unknown { + const obj: any = {}; + message.selector !== undefined && (obj.selector = message.selector); + message.get !== undefined && (obj.get = message.get); + message.put !== undefined && (obj.put = message.put); + message.post !== undefined && (obj.post = message.post); + message.delete !== undefined && (obj.delete = message.delete); + message.patch !== undefined && (obj.patch = message.patch); + message.custom !== undefined && + (obj.custom = message.custom + ? CustomHttpPattern.toJSON(message.custom) + : undefined); + message.body !== undefined && (obj.body = message.body); + message.responseBody !== undefined && + (obj.responseBody = message.responseBody); + if (message.additionalBindings) { + obj.additionalBindings = message.additionalBindings.map((e) => + e ? HttpRule.toJSON(e) : undefined + ); + } else { + obj.additionalBindings = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): HttpRule { + const message = { ...baseHttpRule } as HttpRule; + message.additionalBindings = []; + if (object.selector !== undefined && object.selector !== null) { + message.selector = object.selector; + } else { + message.selector = ""; + } + if (object.get !== undefined && object.get !== null) { + message.get = object.get; + } else { + message.get = undefined; + } + if (object.put !== undefined && object.put !== null) { + message.put = object.put; + } else { + message.put = undefined; + } + if (object.post !== undefined && object.post !== null) { + message.post = object.post; + } else { + message.post = undefined; + } + if (object.delete !== undefined && object.delete !== null) { + message.delete = object.delete; + } else { + message.delete = undefined; + } + if (object.patch !== undefined && object.patch !== null) { + message.patch = object.patch; + } else { + message.patch = undefined; + } + if (object.custom !== undefined && object.custom !== null) { + message.custom = CustomHttpPattern.fromPartial(object.custom); + } else { + message.custom = undefined; + } + if (object.body !== undefined && object.body !== null) { + message.body = object.body; + } else { + message.body = ""; + } + if (object.responseBody !== undefined && object.responseBody !== null) { + message.responseBody = object.responseBody; + } else { + message.responseBody = ""; + } + if ( + object.additionalBindings !== undefined && + object.additionalBindings !== null + ) { + for (const e of object.additionalBindings) { + message.additionalBindings.push(HttpRule.fromPartial(e)); + } + } + return message; + }, +}; + +const baseCustomHttpPattern: object = { kind: "", path: "" }; + +export const CustomHttpPattern = { + encode(message: CustomHttpPattern, writer: Writer = Writer.create()): Writer { + if (message.kind !== "") { + writer.uint32(10).string(message.kind); + } + if (message.path !== "") { + writer.uint32(18).string(message.path); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): CustomHttpPattern { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseCustomHttpPattern } as CustomHttpPattern; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.kind = reader.string(); + break; + case 2: + message.path = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): CustomHttpPattern { + const message = { ...baseCustomHttpPattern } as CustomHttpPattern; + if (object.kind !== undefined && object.kind !== null) { + message.kind = String(object.kind); + } else { + message.kind = ""; + } + if (object.path !== undefined && object.path !== null) { + message.path = String(object.path); + } else { + message.path = ""; + } + return message; + }, + + toJSON(message: CustomHttpPattern): unknown { + const obj: any = {}; + message.kind !== undefined && (obj.kind = message.kind); + message.path !== undefined && (obj.path = message.path); + return obj; + }, + + fromPartial(object: DeepPartial): CustomHttpPattern { + const message = { ...baseCustomHttpPattern } as CustomHttpPattern; + if (object.kind !== undefined && object.kind !== null) { + message.kind = object.kind; + } else { + message.kind = ""; + } + if (object.path !== undefined && object.path !== null) { + message.path = object.path; + } else { + message.path = ""; + } + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/bze.cointrunk.v1/types/google/protobuf/descriptor.ts b/ts-client/bze.cointrunk.v1/types/google/protobuf/descriptor.ts new file mode 100644 index 00000000..9e508660 --- /dev/null +++ b/ts-client/bze.cointrunk.v1/types/google/protobuf/descriptor.ts @@ -0,0 +1,5261 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "google.protobuf"; + +/** + * The protocol compiler can output a FileDescriptorSet containing the .proto + * files it parses. + */ +export interface FileDescriptorSet { + file: FileDescriptorProto[]; +} + +/** Describes a complete .proto file. */ +export interface FileDescriptorProto { + /** file name, relative to root of source tree */ + name: string; + /** e.g. "foo", "foo.bar", etc. */ + package: string; + /** Names of files imported by this file. */ + dependency: string[]; + /** Indexes of the public imported files in the dependency list above. */ + publicDependency: number[]; + /** + * Indexes of the weak imported files in the dependency list. + * For Google-internal migration only. Do not use. + */ + weakDependency: number[]; + /** All top-level definitions in this file. */ + messageType: DescriptorProto[]; + enumType: EnumDescriptorProto[]; + service: ServiceDescriptorProto[]; + extension: FieldDescriptorProto[]; + options: FileOptions | undefined; + /** + * This field contains optional information about the original source code. + * You may safely remove this entire field without harming runtime + * functionality of the descriptors -- the information is needed only by + * development tools. + */ + sourceCodeInfo: SourceCodeInfo | undefined; + /** + * The syntax of the proto file. + * The supported values are "proto2" and "proto3". + */ + syntax: string; +} + +/** Describes a message type. */ +export interface DescriptorProto { + name: string; + field: FieldDescriptorProto[]; + extension: FieldDescriptorProto[]; + nestedType: DescriptorProto[]; + enumType: EnumDescriptorProto[]; + extensionRange: DescriptorProto_ExtensionRange[]; + oneofDecl: OneofDescriptorProto[]; + options: MessageOptions | undefined; + reservedRange: DescriptorProto_ReservedRange[]; + /** + * Reserved field names, which may not be used by fields in the same message. + * A given name may only be reserved once. + */ + reservedName: string[]; +} + +export interface DescriptorProto_ExtensionRange { + /** Inclusive. */ + start: number; + /** Exclusive. */ + end: number; + options: ExtensionRangeOptions | undefined; +} + +/** + * Range of reserved tag numbers. Reserved tag numbers may not be used by + * fields or extension ranges in the same message. Reserved ranges may + * not overlap. + */ +export interface DescriptorProto_ReservedRange { + /** Inclusive. */ + start: number; + /** Exclusive. */ + end: number; +} + +export interface ExtensionRangeOptions { + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +/** Describes a field within a message. */ +export interface FieldDescriptorProto { + name: string; + number: number; + label: FieldDescriptorProto_Label; + /** + * If type_name is set, this need not be set. If both this and type_name + * are set, this must be one of TYPE_ENUM, TYPE_MESSAGE or TYPE_GROUP. + */ + type: FieldDescriptorProto_Type; + /** + * For message and enum types, this is the name of the type. If the name + * starts with a '.', it is fully-qualified. Otherwise, C++-like scoping + * rules are used to find the type (i.e. first the nested types within this + * message are searched, then within the parent, on up to the root + * namespace). + */ + typeName: string; + /** + * For extensions, this is the name of the type being extended. It is + * resolved in the same manner as type_name. + */ + extendee: string; + /** + * For numeric types, contains the original text representation of the value. + * For booleans, "true" or "false". + * For strings, contains the default text contents (not escaped in any way). + * For bytes, contains the C escaped value. All bytes >= 128 are escaped. + * TODO(kenton): Base-64 encode? + */ + defaultValue: string; + /** + * If set, gives the index of a oneof in the containing type's oneof_decl + * list. This field is a member of that oneof. + */ + oneofIndex: number; + /** + * JSON name of this field. The value is set by protocol compiler. If the + * user has set a "json_name" option on this field, that option's value + * will be used. Otherwise, it's deduced from the field's name by converting + * it to camelCase. + */ + jsonName: string; + options: FieldOptions | undefined; + /** + * If true, this is a proto3 "optional". When a proto3 field is optional, it + * tracks presence regardless of field type. + * + * When proto3_optional is true, this field must be belong to a oneof to + * signal to old proto3 clients that presence is tracked for this field. This + * oneof is known as a "synthetic" oneof, and this field must be its sole + * member (each proto3 optional field gets its own synthetic oneof). Synthetic + * oneofs exist in the descriptor only, and do not generate any API. Synthetic + * oneofs must be ordered after all "real" oneofs. + * + * For message fields, proto3_optional doesn't create any semantic change, + * since non-repeated message fields always track presence. However it still + * indicates the semantic detail of whether the user wrote "optional" or not. + * This can be useful for round-tripping the .proto file. For consistency we + * give message fields a synthetic oneof also, even though it is not required + * to track presence. This is especially important because the parser can't + * tell if a field is a message or an enum, so it must always create a + * synthetic oneof. + * + * Proto2 optional fields do not set this flag, because they already indicate + * optional with `LABEL_OPTIONAL`. + */ + proto3Optional: boolean; +} + +export enum FieldDescriptorProto_Type { + /** + * TYPE_DOUBLE - 0 is reserved for errors. + * Order is weird for historical reasons. + */ + TYPE_DOUBLE = 1, + TYPE_FLOAT = 2, + /** + * TYPE_INT64 - Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT64 if + * negative values are likely. + */ + TYPE_INT64 = 3, + TYPE_UINT64 = 4, + /** + * TYPE_INT32 - Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT32 if + * negative values are likely. + */ + TYPE_INT32 = 5, + TYPE_FIXED64 = 6, + TYPE_FIXED32 = 7, + TYPE_BOOL = 8, + TYPE_STRING = 9, + /** + * TYPE_GROUP - Tag-delimited aggregate. + * Group type is deprecated and not supported in proto3. However, Proto3 + * implementations should still be able to parse the group wire format and + * treat group fields as unknown fields. + */ + TYPE_GROUP = 10, + /** TYPE_MESSAGE - Length-delimited aggregate. */ + TYPE_MESSAGE = 11, + /** TYPE_BYTES - New in version 2. */ + TYPE_BYTES = 12, + TYPE_UINT32 = 13, + TYPE_ENUM = 14, + TYPE_SFIXED32 = 15, + TYPE_SFIXED64 = 16, + /** TYPE_SINT32 - Uses ZigZag encoding. */ + TYPE_SINT32 = 17, + /** TYPE_SINT64 - Uses ZigZag encoding. */ + TYPE_SINT64 = 18, + UNRECOGNIZED = -1, +} + +export function fieldDescriptorProto_TypeFromJSON( + object: any +): FieldDescriptorProto_Type { + switch (object) { + case 1: + case "TYPE_DOUBLE": + return FieldDescriptorProto_Type.TYPE_DOUBLE; + case 2: + case "TYPE_FLOAT": + return FieldDescriptorProto_Type.TYPE_FLOAT; + case 3: + case "TYPE_INT64": + return FieldDescriptorProto_Type.TYPE_INT64; + case 4: + case "TYPE_UINT64": + return FieldDescriptorProto_Type.TYPE_UINT64; + case 5: + case "TYPE_INT32": + return FieldDescriptorProto_Type.TYPE_INT32; + case 6: + case "TYPE_FIXED64": + return FieldDescriptorProto_Type.TYPE_FIXED64; + case 7: + case "TYPE_FIXED32": + return FieldDescriptorProto_Type.TYPE_FIXED32; + case 8: + case "TYPE_BOOL": + return FieldDescriptorProto_Type.TYPE_BOOL; + case 9: + case "TYPE_STRING": + return FieldDescriptorProto_Type.TYPE_STRING; + case 10: + case "TYPE_GROUP": + return FieldDescriptorProto_Type.TYPE_GROUP; + case 11: + case "TYPE_MESSAGE": + return FieldDescriptorProto_Type.TYPE_MESSAGE; + case 12: + case "TYPE_BYTES": + return FieldDescriptorProto_Type.TYPE_BYTES; + case 13: + case "TYPE_UINT32": + return FieldDescriptorProto_Type.TYPE_UINT32; + case 14: + case "TYPE_ENUM": + return FieldDescriptorProto_Type.TYPE_ENUM; + case 15: + case "TYPE_SFIXED32": + return FieldDescriptorProto_Type.TYPE_SFIXED32; + case 16: + case "TYPE_SFIXED64": + return FieldDescriptorProto_Type.TYPE_SFIXED64; + case 17: + case "TYPE_SINT32": + return FieldDescriptorProto_Type.TYPE_SINT32; + case 18: + case "TYPE_SINT64": + return FieldDescriptorProto_Type.TYPE_SINT64; + case -1: + case "UNRECOGNIZED": + default: + return FieldDescriptorProto_Type.UNRECOGNIZED; + } +} + +export function fieldDescriptorProto_TypeToJSON( + object: FieldDescriptorProto_Type +): string { + switch (object) { + case FieldDescriptorProto_Type.TYPE_DOUBLE: + return "TYPE_DOUBLE"; + case FieldDescriptorProto_Type.TYPE_FLOAT: + return "TYPE_FLOAT"; + case FieldDescriptorProto_Type.TYPE_INT64: + return "TYPE_INT64"; + case FieldDescriptorProto_Type.TYPE_UINT64: + return "TYPE_UINT64"; + case FieldDescriptorProto_Type.TYPE_INT32: + return "TYPE_INT32"; + case FieldDescriptorProto_Type.TYPE_FIXED64: + return "TYPE_FIXED64"; + case FieldDescriptorProto_Type.TYPE_FIXED32: + return "TYPE_FIXED32"; + case FieldDescriptorProto_Type.TYPE_BOOL: + return "TYPE_BOOL"; + case FieldDescriptorProto_Type.TYPE_STRING: + return "TYPE_STRING"; + case FieldDescriptorProto_Type.TYPE_GROUP: + return "TYPE_GROUP"; + case FieldDescriptorProto_Type.TYPE_MESSAGE: + return "TYPE_MESSAGE"; + case FieldDescriptorProto_Type.TYPE_BYTES: + return "TYPE_BYTES"; + case FieldDescriptorProto_Type.TYPE_UINT32: + return "TYPE_UINT32"; + case FieldDescriptorProto_Type.TYPE_ENUM: + return "TYPE_ENUM"; + case FieldDescriptorProto_Type.TYPE_SFIXED32: + return "TYPE_SFIXED32"; + case FieldDescriptorProto_Type.TYPE_SFIXED64: + return "TYPE_SFIXED64"; + case FieldDescriptorProto_Type.TYPE_SINT32: + return "TYPE_SINT32"; + case FieldDescriptorProto_Type.TYPE_SINT64: + return "TYPE_SINT64"; + default: + return "UNKNOWN"; + } +} + +export enum FieldDescriptorProto_Label { + /** LABEL_OPTIONAL - 0 is reserved for errors */ + LABEL_OPTIONAL = 1, + LABEL_REQUIRED = 2, + LABEL_REPEATED = 3, + UNRECOGNIZED = -1, +} + +export function fieldDescriptorProto_LabelFromJSON( + object: any +): FieldDescriptorProto_Label { + switch (object) { + case 1: + case "LABEL_OPTIONAL": + return FieldDescriptorProto_Label.LABEL_OPTIONAL; + case 2: + case "LABEL_REQUIRED": + return FieldDescriptorProto_Label.LABEL_REQUIRED; + case 3: + case "LABEL_REPEATED": + return FieldDescriptorProto_Label.LABEL_REPEATED; + case -1: + case "UNRECOGNIZED": + default: + return FieldDescriptorProto_Label.UNRECOGNIZED; + } +} + +export function fieldDescriptorProto_LabelToJSON( + object: FieldDescriptorProto_Label +): string { + switch (object) { + case FieldDescriptorProto_Label.LABEL_OPTIONAL: + return "LABEL_OPTIONAL"; + case FieldDescriptorProto_Label.LABEL_REQUIRED: + return "LABEL_REQUIRED"; + case FieldDescriptorProto_Label.LABEL_REPEATED: + return "LABEL_REPEATED"; + default: + return "UNKNOWN"; + } +} + +/** Describes a oneof. */ +export interface OneofDescriptorProto { + name: string; + options: OneofOptions | undefined; +} + +/** Describes an enum type. */ +export interface EnumDescriptorProto { + name: string; + value: EnumValueDescriptorProto[]; + options: EnumOptions | undefined; + /** + * Range of reserved numeric values. Reserved numeric values may not be used + * by enum values in the same enum declaration. Reserved ranges may not + * overlap. + */ + reservedRange: EnumDescriptorProto_EnumReservedRange[]; + /** + * Reserved enum value names, which may not be reused. A given name may only + * be reserved once. + */ + reservedName: string[]; +} + +/** + * Range of reserved numeric values. Reserved values may not be used by + * entries in the same enum. Reserved ranges may not overlap. + * + * Note that this is distinct from DescriptorProto.ReservedRange in that it + * is inclusive such that it can appropriately represent the entire int32 + * domain. + */ +export interface EnumDescriptorProto_EnumReservedRange { + /** Inclusive. */ + start: number; + /** Inclusive. */ + end: number; +} + +/** Describes a value within an enum. */ +export interface EnumValueDescriptorProto { + name: string; + number: number; + options: EnumValueOptions | undefined; +} + +/** Describes a service. */ +export interface ServiceDescriptorProto { + name: string; + method: MethodDescriptorProto[]; + options: ServiceOptions | undefined; +} + +/** Describes a method of a service. */ +export interface MethodDescriptorProto { + name: string; + /** + * Input and output type names. These are resolved in the same way as + * FieldDescriptorProto.type_name, but must refer to a message type. + */ + inputType: string; + outputType: string; + options: MethodOptions | undefined; + /** Identifies if client streams multiple client messages */ + clientStreaming: boolean; + /** Identifies if server streams multiple server messages */ + serverStreaming: boolean; +} + +export interface FileOptions { + /** + * Sets the Java package where classes generated from this .proto will be + * placed. By default, the proto package is used, but this is often + * inappropriate because proto packages do not normally start with backwards + * domain names. + */ + javaPackage: string; + /** + * Controls the name of the wrapper Java class generated for the .proto file. + * That class will always contain the .proto file's getDescriptor() method as + * well as any top-level extensions defined in the .proto file. + * If java_multiple_files is disabled, then all the other classes from the + * .proto file will be nested inside the single wrapper outer class. + */ + javaOuterClassname: string; + /** + * If enabled, then the Java code generator will generate a separate .java + * file for each top-level message, enum, and service defined in the .proto + * file. Thus, these types will *not* be nested inside the wrapper class + * named by java_outer_classname. However, the wrapper class will still be + * generated to contain the file's getDescriptor() method as well as any + * top-level extensions defined in the file. + */ + javaMultipleFiles: boolean; + /** + * This option does nothing. + * + * @deprecated + */ + javaGenerateEqualsAndHash: boolean; + /** + * If set true, then the Java2 code generator will generate code that + * throws an exception whenever an attempt is made to assign a non-UTF-8 + * byte sequence to a string field. + * Message reflection will do the same. + * However, an extension field still accepts non-UTF-8 byte sequences. + * This option has no effect on when used with the lite runtime. + */ + javaStringCheckUtf8: boolean; + optimizeFor: FileOptions_OptimizeMode; + /** + * Sets the Go package where structs generated from this .proto will be + * placed. If omitted, the Go package will be derived from the following: + * - The basename of the package import path, if provided. + * - Otherwise, the package statement in the .proto file, if present. + * - Otherwise, the basename of the .proto file, without extension. + */ + goPackage: string; + /** + * Should generic services be generated in each language? "Generic" services + * are not specific to any particular RPC system. They are generated by the + * main code generators in each language (without additional plugins). + * Generic services were the only kind of service generation supported by + * early versions of google.protobuf. + * + * Generic services are now considered deprecated in favor of using plugins + * that generate code specific to your particular RPC system. Therefore, + * these default to false. Old code which depends on generic services should + * explicitly set them to true. + */ + ccGenericServices: boolean; + javaGenericServices: boolean; + pyGenericServices: boolean; + phpGenericServices: boolean; + /** + * Is this file deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for everything in the file, or it will be completely ignored; in the very + * least, this is a formalization for deprecating files. + */ + deprecated: boolean; + /** + * Enables the use of arenas for the proto messages in this file. This applies + * only to generated classes for C++. + */ + ccEnableArenas: boolean; + /** + * Sets the objective c class prefix which is prepended to all objective c + * generated classes from this .proto. There is no default. + */ + objcClassPrefix: string; + /** Namespace for generated classes; defaults to the package. */ + csharpNamespace: string; + /** + * By default Swift generators will take the proto package and CamelCase it + * replacing '.' with underscore and use that to prefix the types/symbols + * defined. When this options is provided, they will use this value instead + * to prefix the types/symbols defined. + */ + swiftPrefix: string; + /** + * Sets the php class prefix which is prepended to all php generated classes + * from this .proto. Default is empty. + */ + phpClassPrefix: string; + /** + * Use this option to change the namespace of php generated classes. Default + * is empty. When this option is empty, the package name will be used for + * determining the namespace. + */ + phpNamespace: string; + /** + * Use this option to change the namespace of php generated metadata classes. + * Default is empty. When this option is empty, the proto file name will be + * used for determining the namespace. + */ + phpMetadataNamespace: string; + /** + * Use this option to change the package of ruby generated classes. Default + * is empty. When this option is not set, the package name will be used for + * determining the ruby package. + */ + rubyPackage: string; + /** + * The parser stores options it doesn't recognize here. + * See the documentation for the "Options" section above. + */ + uninterpretedOption: UninterpretedOption[]; +} + +/** Generated classes can be optimized for speed or code size. */ +export enum FileOptions_OptimizeMode { + /** SPEED - Generate complete code for parsing, serialization, */ + SPEED = 1, + /** CODE_SIZE - etc. */ + CODE_SIZE = 2, + /** LITE_RUNTIME - Generate code using MessageLite and the lite runtime. */ + LITE_RUNTIME = 3, + UNRECOGNIZED = -1, +} + +export function fileOptions_OptimizeModeFromJSON( + object: any +): FileOptions_OptimizeMode { + switch (object) { + case 1: + case "SPEED": + return FileOptions_OptimizeMode.SPEED; + case 2: + case "CODE_SIZE": + return FileOptions_OptimizeMode.CODE_SIZE; + case 3: + case "LITE_RUNTIME": + return FileOptions_OptimizeMode.LITE_RUNTIME; + case -1: + case "UNRECOGNIZED": + default: + return FileOptions_OptimizeMode.UNRECOGNIZED; + } +} + +export function fileOptions_OptimizeModeToJSON( + object: FileOptions_OptimizeMode +): string { + switch (object) { + case FileOptions_OptimizeMode.SPEED: + return "SPEED"; + case FileOptions_OptimizeMode.CODE_SIZE: + return "CODE_SIZE"; + case FileOptions_OptimizeMode.LITE_RUNTIME: + return "LITE_RUNTIME"; + default: + return "UNKNOWN"; + } +} + +export interface MessageOptions { + /** + * Set true to use the old proto1 MessageSet wire format for extensions. + * This is provided for backwards-compatibility with the MessageSet wire + * format. You should not use this for any other reason: It's less + * efficient, has fewer features, and is more complicated. + * + * The message must be defined exactly as follows: + * message Foo { + * option message_set_wire_format = true; + * extensions 4 to max; + * } + * Note that the message cannot have any defined fields; MessageSets only + * have extensions. + * + * All extensions of your type must be singular messages; e.g. they cannot + * be int32s, enums, or repeated messages. + * + * Because this is an option, the above two restrictions are not enforced by + * the protocol compiler. + */ + messageSetWireFormat: boolean; + /** + * Disables the generation of the standard "descriptor()" accessor, which can + * conflict with a field of the same name. This is meant to make migration + * from proto1 easier; new code should avoid fields named "descriptor". + */ + noStandardDescriptorAccessor: boolean; + /** + * Is this message deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the message, or it will be completely ignored; in the very least, + * this is a formalization for deprecating messages. + */ + deprecated: boolean; + /** + * Whether the message is an automatically generated map entry type for the + * maps field. + * + * For maps fields: + * map map_field = 1; + * The parsed descriptor looks like: + * message MapFieldEntry { + * option map_entry = true; + * optional KeyType key = 1; + * optional ValueType value = 2; + * } + * repeated MapFieldEntry map_field = 1; + * + * Implementations may choose not to generate the map_entry=true message, but + * use a native map in the target language to hold the keys and values. + * The reflection APIs in such implementations still need to work as + * if the field is a repeated message field. + * + * NOTE: Do not set the option in .proto files. Always use the maps syntax + * instead. The option should only be implicitly set by the proto compiler + * parser. + */ + mapEntry: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface FieldOptions { + /** + * The ctype option instructs the C++ code generator to use a different + * representation of the field than it normally would. See the specific + * options below. This option is not yet implemented in the open source + * release -- sorry, we'll try to include it in a future version! + */ + ctype: FieldOptions_CType; + /** + * The packed option can be enabled for repeated primitive fields to enable + * a more efficient representation on the wire. Rather than repeatedly + * writing the tag and type for each element, the entire array is encoded as + * a single length-delimited blob. In proto3, only explicit setting it to + * false will avoid using packed encoding. + */ + packed: boolean; + /** + * The jstype option determines the JavaScript type used for values of the + * field. The option is permitted only for 64 bit integral and fixed types + * (int64, uint64, sint64, fixed64, sfixed64). A field with jstype JS_STRING + * is represented as JavaScript string, which avoids loss of precision that + * can happen when a large value is converted to a floating point JavaScript. + * Specifying JS_NUMBER for the jstype causes the generated JavaScript code to + * use the JavaScript "number" type. The behavior of the default option + * JS_NORMAL is implementation dependent. + * + * This option is an enum to permit additional types to be added, e.g. + * goog.math.Integer. + */ + jstype: FieldOptions_JSType; + /** + * Should this field be parsed lazily? Lazy applies only to message-type + * fields. It means that when the outer message is initially parsed, the + * inner message's contents will not be parsed but instead stored in encoded + * form. The inner message will actually be parsed when it is first accessed. + * + * This is only a hint. Implementations are free to choose whether to use + * eager or lazy parsing regardless of the value of this option. However, + * setting this option true suggests that the protocol author believes that + * using lazy parsing on this field is worth the additional bookkeeping + * overhead typically needed to implement it. + * + * This option does not affect the public interface of any generated code; + * all method signatures remain the same. Furthermore, thread-safety of the + * interface is not affected by this option; const methods remain safe to + * call from multiple threads concurrently, while non-const methods continue + * to require exclusive access. + * + * + * Note that implementations may choose not to check required fields within + * a lazy sub-message. That is, calling IsInitialized() on the outer message + * may return true even if the inner message has missing required fields. + * This is necessary because otherwise the inner message would have to be + * parsed in order to perform the check, defeating the purpose of lazy + * parsing. An implementation which chooses not to check required fields + * must be consistent about it. That is, for any particular sub-message, the + * implementation must either *always* check its required fields, or *never* + * check its required fields, regardless of whether or not the message has + * been parsed. + */ + lazy: boolean; + /** + * Is this field deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for accessors, or it will be completely ignored; in the very least, this + * is a formalization for deprecating fields. + */ + deprecated: boolean; + /** For Google-internal migration only. Do not use. */ + weak: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export enum FieldOptions_CType { + /** STRING - Default mode. */ + STRING = 0, + CORD = 1, + STRING_PIECE = 2, + UNRECOGNIZED = -1, +} + +export function fieldOptions_CTypeFromJSON(object: any): FieldOptions_CType { + switch (object) { + case 0: + case "STRING": + return FieldOptions_CType.STRING; + case 1: + case "CORD": + return FieldOptions_CType.CORD; + case 2: + case "STRING_PIECE": + return FieldOptions_CType.STRING_PIECE; + case -1: + case "UNRECOGNIZED": + default: + return FieldOptions_CType.UNRECOGNIZED; + } +} + +export function fieldOptions_CTypeToJSON(object: FieldOptions_CType): string { + switch (object) { + case FieldOptions_CType.STRING: + return "STRING"; + case FieldOptions_CType.CORD: + return "CORD"; + case FieldOptions_CType.STRING_PIECE: + return "STRING_PIECE"; + default: + return "UNKNOWN"; + } +} + +export enum FieldOptions_JSType { + /** JS_NORMAL - Use the default type. */ + JS_NORMAL = 0, + /** JS_STRING - Use JavaScript strings. */ + JS_STRING = 1, + /** JS_NUMBER - Use JavaScript numbers. */ + JS_NUMBER = 2, + UNRECOGNIZED = -1, +} + +export function fieldOptions_JSTypeFromJSON(object: any): FieldOptions_JSType { + switch (object) { + case 0: + case "JS_NORMAL": + return FieldOptions_JSType.JS_NORMAL; + case 1: + case "JS_STRING": + return FieldOptions_JSType.JS_STRING; + case 2: + case "JS_NUMBER": + return FieldOptions_JSType.JS_NUMBER; + case -1: + case "UNRECOGNIZED": + default: + return FieldOptions_JSType.UNRECOGNIZED; + } +} + +export function fieldOptions_JSTypeToJSON(object: FieldOptions_JSType): string { + switch (object) { + case FieldOptions_JSType.JS_NORMAL: + return "JS_NORMAL"; + case FieldOptions_JSType.JS_STRING: + return "JS_STRING"; + case FieldOptions_JSType.JS_NUMBER: + return "JS_NUMBER"; + default: + return "UNKNOWN"; + } +} + +export interface OneofOptions { + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface EnumOptions { + /** + * Set this option to true to allow mapping different tag names to the same + * value. + */ + allowAlias: boolean; + /** + * Is this enum deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the enum, or it will be completely ignored; in the very least, this + * is a formalization for deprecating enums. + */ + deprecated: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface EnumValueOptions { + /** + * Is this enum value deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the enum value, or it will be completely ignored; in the very least, + * this is a formalization for deprecating enum values. + */ + deprecated: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface ServiceOptions { + /** + * Is this service deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the service, or it will be completely ignored; in the very least, + * this is a formalization for deprecating services. + */ + deprecated: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface MethodOptions { + /** + * Is this method deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the method, or it will be completely ignored; in the very least, + * this is a formalization for deprecating methods. + */ + deprecated: boolean; + idempotencyLevel: MethodOptions_IdempotencyLevel; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +/** + * Is this method side-effect-free (or safe in HTTP parlance), or idempotent, + * or neither? HTTP based RPC implementation may choose GET verb for safe + * methods, and PUT verb for idempotent methods instead of the default POST. + */ +export enum MethodOptions_IdempotencyLevel { + IDEMPOTENCY_UNKNOWN = 0, + /** NO_SIDE_EFFECTS - implies idempotent */ + NO_SIDE_EFFECTS = 1, + /** IDEMPOTENT - idempotent, but may have side effects */ + IDEMPOTENT = 2, + UNRECOGNIZED = -1, +} + +export function methodOptions_IdempotencyLevelFromJSON( + object: any +): MethodOptions_IdempotencyLevel { + switch (object) { + case 0: + case "IDEMPOTENCY_UNKNOWN": + return MethodOptions_IdempotencyLevel.IDEMPOTENCY_UNKNOWN; + case 1: + case "NO_SIDE_EFFECTS": + return MethodOptions_IdempotencyLevel.NO_SIDE_EFFECTS; + case 2: + case "IDEMPOTENT": + return MethodOptions_IdempotencyLevel.IDEMPOTENT; + case -1: + case "UNRECOGNIZED": + default: + return MethodOptions_IdempotencyLevel.UNRECOGNIZED; + } +} + +export function methodOptions_IdempotencyLevelToJSON( + object: MethodOptions_IdempotencyLevel +): string { + switch (object) { + case MethodOptions_IdempotencyLevel.IDEMPOTENCY_UNKNOWN: + return "IDEMPOTENCY_UNKNOWN"; + case MethodOptions_IdempotencyLevel.NO_SIDE_EFFECTS: + return "NO_SIDE_EFFECTS"; + case MethodOptions_IdempotencyLevel.IDEMPOTENT: + return "IDEMPOTENT"; + default: + return "UNKNOWN"; + } +} + +/** + * A message representing a option the parser does not recognize. This only + * appears in options protos created by the compiler::Parser class. + * DescriptorPool resolves these when building Descriptor objects. Therefore, + * options protos in descriptor objects (e.g. returned by Descriptor::options(), + * or produced by Descriptor::CopyTo()) will never have UninterpretedOptions + * in them. + */ +export interface UninterpretedOption { + name: UninterpretedOption_NamePart[]; + /** + * The value of the uninterpreted option, in whatever type the tokenizer + * identified it as during parsing. Exactly one of these should be set. + */ + identifierValue: string; + positiveIntValue: number; + negativeIntValue: number; + doubleValue: number; + stringValue: Uint8Array; + aggregateValue: string; +} + +/** + * The name of the uninterpreted option. Each string represents a segment in + * a dot-separated name. is_extension is true iff a segment represents an + * extension (denoted with parentheses in options specs in .proto files). + * E.g.,{ ["foo", false], ["bar.baz", true], ["qux", false] } represents + * "foo.(bar.baz).qux". + */ +export interface UninterpretedOption_NamePart { + namePart: string; + isExtension: boolean; +} + +/** + * Encapsulates information about the original source file from which a + * FileDescriptorProto was generated. + */ +export interface SourceCodeInfo { + /** + * A Location identifies a piece of source code in a .proto file which + * corresponds to a particular definition. This information is intended + * to be useful to IDEs, code indexers, documentation generators, and similar + * tools. + * + * For example, say we have a file like: + * message Foo { + * optional string foo = 1; + * } + * Let's look at just the field definition: + * optional string foo = 1; + * ^ ^^ ^^ ^ ^^^ + * a bc de f ghi + * We have the following locations: + * span path represents + * [a,i) [ 4, 0, 2, 0 ] The whole field definition. + * [a,b) [ 4, 0, 2, 0, 4 ] The label (optional). + * [c,d) [ 4, 0, 2, 0, 5 ] The type (string). + * [e,f) [ 4, 0, 2, 0, 1 ] The name (foo). + * [g,h) [ 4, 0, 2, 0, 3 ] The number (1). + * + * Notes: + * - A location may refer to a repeated field itself (i.e. not to any + * particular index within it). This is used whenever a set of elements are + * logically enclosed in a single code segment. For example, an entire + * extend block (possibly containing multiple extension definitions) will + * have an outer location whose path refers to the "extensions" repeated + * field without an index. + * - Multiple locations may have the same path. This happens when a single + * logical declaration is spread out across multiple places. The most + * obvious example is the "extend" block again -- there may be multiple + * extend blocks in the same scope, each of which will have the same path. + * - A location's span is not always a subset of its parent's span. For + * example, the "extendee" of an extension declaration appears at the + * beginning of the "extend" block and is shared by all extensions within + * the block. + * - Just because a location's span is a subset of some other location's span + * does not mean that it is a descendant. For example, a "group" defines + * both a type and a field in a single declaration. Thus, the locations + * corresponding to the type and field and their components will overlap. + * - Code which tries to interpret locations should probably be designed to + * ignore those that it doesn't understand, as more types of locations could + * be recorded in the future. + */ + location: SourceCodeInfo_Location[]; +} + +export interface SourceCodeInfo_Location { + /** + * Identifies which part of the FileDescriptorProto was defined at this + * location. + * + * Each element is a field number or an index. They form a path from + * the root FileDescriptorProto to the place where the definition. For + * example, this path: + * [ 4, 3, 2, 7, 1 ] + * refers to: + * file.message_type(3) // 4, 3 + * .field(7) // 2, 7 + * .name() // 1 + * This is because FileDescriptorProto.message_type has field number 4: + * repeated DescriptorProto message_type = 4; + * and DescriptorProto.field has field number 2: + * repeated FieldDescriptorProto field = 2; + * and FieldDescriptorProto.name has field number 1: + * optional string name = 1; + * + * Thus, the above path gives the location of a field name. If we removed + * the last element: + * [ 4, 3, 2, 7 ] + * this path refers to the whole field declaration (from the beginning + * of the label to the terminating semicolon). + */ + path: number[]; + /** + * Always has exactly three or four elements: start line, start column, + * end line (optional, otherwise assumed same as start line), end column. + * These are packed into a single field for efficiency. Note that line + * and column numbers are zero-based -- typically you will want to add + * 1 to each before displaying to a user. + */ + span: number[]; + /** + * If this SourceCodeInfo represents a complete declaration, these are any + * comments appearing before and after the declaration which appear to be + * attached to the declaration. + * + * A series of line comments appearing on consecutive lines, with no other + * tokens appearing on those lines, will be treated as a single comment. + * + * leading_detached_comments will keep paragraphs of comments that appear + * before (but not connected to) the current element. Each paragraph, + * separated by empty lines, will be one comment element in the repeated + * field. + * + * Only the comment content is provided; comment markers (e.g. //) are + * stripped out. For block comments, leading whitespace and an asterisk + * will be stripped from the beginning of each line other than the first. + * Newlines are included in the output. + * + * Examples: + * + * optional int32 foo = 1; // Comment attached to foo. + * // Comment attached to bar. + * optional int32 bar = 2; + * + * optional string baz = 3; + * // Comment attached to baz. + * // Another line attached to baz. + * + * // Comment attached to qux. + * // + * // Another line attached to qux. + * optional double qux = 4; + * + * // Detached comment for corge. This is not leading or trailing comments + * // to qux or corge because there are blank lines separating it from + * // both. + * + * // Detached comment for corge paragraph 2. + * + * optional string corge = 5; + * /* Block comment attached + * * to corge. Leading asterisks + * * will be removed. * / + * /* Block comment attached to + * * grault. * / + * optional int32 grault = 6; + * + * // ignored detached comments. + */ + leadingComments: string; + trailingComments: string; + leadingDetachedComments: string[]; +} + +/** + * Describes the relationship between generated code and its original source + * file. A GeneratedCodeInfo message is associated with only one generated + * source file, but may contain references to different source .proto files. + */ +export interface GeneratedCodeInfo { + /** + * An Annotation connects some span of text in generated code to an element + * of its generating .proto file. + */ + annotation: GeneratedCodeInfo_Annotation[]; +} + +export interface GeneratedCodeInfo_Annotation { + /** + * Identifies the element in the original source .proto file. This field + * is formatted the same as SourceCodeInfo.Location.path. + */ + path: number[]; + /** Identifies the filesystem path to the original source .proto. */ + sourceFile: string; + /** + * Identifies the starting offset in bytes in the generated code + * that relates to the identified object. + */ + begin: number; + /** + * Identifies the ending offset in bytes in the generated code that + * relates to the identified offset. The end offset should be one past + * the last relevant byte (so the length of the text = end - begin). + */ + end: number; +} + +const baseFileDescriptorSet: object = {}; + +export const FileDescriptorSet = { + encode(message: FileDescriptorSet, writer: Writer = Writer.create()): Writer { + for (const v of message.file) { + FileDescriptorProto.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FileDescriptorSet { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFileDescriptorSet } as FileDescriptorSet; + message.file = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.file.push( + FileDescriptorProto.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FileDescriptorSet { + const message = { ...baseFileDescriptorSet } as FileDescriptorSet; + message.file = []; + if (object.file !== undefined && object.file !== null) { + for (const e of object.file) { + message.file.push(FileDescriptorProto.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: FileDescriptorSet): unknown { + const obj: any = {}; + if (message.file) { + obj.file = message.file.map((e) => + e ? FileDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.file = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): FileDescriptorSet { + const message = { ...baseFileDescriptorSet } as FileDescriptorSet; + message.file = []; + if (object.file !== undefined && object.file !== null) { + for (const e of object.file) { + message.file.push(FileDescriptorProto.fromPartial(e)); + } + } + return message; + }, +}; + +const baseFileDescriptorProto: object = { + name: "", + package: "", + dependency: "", + publicDependency: 0, + weakDependency: 0, + syntax: "", +}; + +export const FileDescriptorProto = { + encode( + message: FileDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.package !== "") { + writer.uint32(18).string(message.package); + } + for (const v of message.dependency) { + writer.uint32(26).string(v!); + } + writer.uint32(82).fork(); + for (const v of message.publicDependency) { + writer.int32(v); + } + writer.ldelim(); + writer.uint32(90).fork(); + for (const v of message.weakDependency) { + writer.int32(v); + } + writer.ldelim(); + for (const v of message.messageType) { + DescriptorProto.encode(v!, writer.uint32(34).fork()).ldelim(); + } + for (const v of message.enumType) { + EnumDescriptorProto.encode(v!, writer.uint32(42).fork()).ldelim(); + } + for (const v of message.service) { + ServiceDescriptorProto.encode(v!, writer.uint32(50).fork()).ldelim(); + } + for (const v of message.extension) { + FieldDescriptorProto.encode(v!, writer.uint32(58).fork()).ldelim(); + } + if (message.options !== undefined) { + FileOptions.encode(message.options, writer.uint32(66).fork()).ldelim(); + } + if (message.sourceCodeInfo !== undefined) { + SourceCodeInfo.encode( + message.sourceCodeInfo, + writer.uint32(74).fork() + ).ldelim(); + } + if (message.syntax !== "") { + writer.uint32(98).string(message.syntax); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FileDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFileDescriptorProto } as FileDescriptorProto; + message.dependency = []; + message.publicDependency = []; + message.weakDependency = []; + message.messageType = []; + message.enumType = []; + message.service = []; + message.extension = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.package = reader.string(); + break; + case 3: + message.dependency.push(reader.string()); + break; + case 10: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.publicDependency.push(reader.int32()); + } + } else { + message.publicDependency.push(reader.int32()); + } + break; + case 11: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.weakDependency.push(reader.int32()); + } + } else { + message.weakDependency.push(reader.int32()); + } + break; + case 4: + message.messageType.push( + DescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 5: + message.enumType.push( + EnumDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 6: + message.service.push( + ServiceDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 7: + message.extension.push( + FieldDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 8: + message.options = FileOptions.decode(reader, reader.uint32()); + break; + case 9: + message.sourceCodeInfo = SourceCodeInfo.decode( + reader, + reader.uint32() + ); + break; + case 12: + message.syntax = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FileDescriptorProto { + const message = { ...baseFileDescriptorProto } as FileDescriptorProto; + message.dependency = []; + message.publicDependency = []; + message.weakDependency = []; + message.messageType = []; + message.enumType = []; + message.service = []; + message.extension = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.package !== undefined && object.package !== null) { + message.package = String(object.package); + } else { + message.package = ""; + } + if (object.dependency !== undefined && object.dependency !== null) { + for (const e of object.dependency) { + message.dependency.push(String(e)); + } + } + if ( + object.publicDependency !== undefined && + object.publicDependency !== null + ) { + for (const e of object.publicDependency) { + message.publicDependency.push(Number(e)); + } + } + if (object.weakDependency !== undefined && object.weakDependency !== null) { + for (const e of object.weakDependency) { + message.weakDependency.push(Number(e)); + } + } + if (object.messageType !== undefined && object.messageType !== null) { + for (const e of object.messageType) { + message.messageType.push(DescriptorProto.fromJSON(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromJSON(e)); + } + } + if (object.service !== undefined && object.service !== null) { + for (const e of object.service) { + message.service.push(ServiceDescriptorProto.fromJSON(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = FileOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.sourceCodeInfo !== undefined && object.sourceCodeInfo !== null) { + message.sourceCodeInfo = SourceCodeInfo.fromJSON(object.sourceCodeInfo); + } else { + message.sourceCodeInfo = undefined; + } + if (object.syntax !== undefined && object.syntax !== null) { + message.syntax = String(object.syntax); + } else { + message.syntax = ""; + } + return message; + }, + + toJSON(message: FileDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.package !== undefined && (obj.package = message.package); + if (message.dependency) { + obj.dependency = message.dependency.map((e) => e); + } else { + obj.dependency = []; + } + if (message.publicDependency) { + obj.publicDependency = message.publicDependency.map((e) => e); + } else { + obj.publicDependency = []; + } + if (message.weakDependency) { + obj.weakDependency = message.weakDependency.map((e) => e); + } else { + obj.weakDependency = []; + } + if (message.messageType) { + obj.messageType = message.messageType.map((e) => + e ? DescriptorProto.toJSON(e) : undefined + ); + } else { + obj.messageType = []; + } + if (message.enumType) { + obj.enumType = message.enumType.map((e) => + e ? EnumDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.enumType = []; + } + if (message.service) { + obj.service = message.service.map((e) => + e ? ServiceDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.service = []; + } + if (message.extension) { + obj.extension = message.extension.map((e) => + e ? FieldDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.extension = []; + } + message.options !== undefined && + (obj.options = message.options + ? FileOptions.toJSON(message.options) + : undefined); + message.sourceCodeInfo !== undefined && + (obj.sourceCodeInfo = message.sourceCodeInfo + ? SourceCodeInfo.toJSON(message.sourceCodeInfo) + : undefined); + message.syntax !== undefined && (obj.syntax = message.syntax); + return obj; + }, + + fromPartial(object: DeepPartial): FileDescriptorProto { + const message = { ...baseFileDescriptorProto } as FileDescriptorProto; + message.dependency = []; + message.publicDependency = []; + message.weakDependency = []; + message.messageType = []; + message.enumType = []; + message.service = []; + message.extension = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.package !== undefined && object.package !== null) { + message.package = object.package; + } else { + message.package = ""; + } + if (object.dependency !== undefined && object.dependency !== null) { + for (const e of object.dependency) { + message.dependency.push(e); + } + } + if ( + object.publicDependency !== undefined && + object.publicDependency !== null + ) { + for (const e of object.publicDependency) { + message.publicDependency.push(e); + } + } + if (object.weakDependency !== undefined && object.weakDependency !== null) { + for (const e of object.weakDependency) { + message.weakDependency.push(e); + } + } + if (object.messageType !== undefined && object.messageType !== null) { + for (const e of object.messageType) { + message.messageType.push(DescriptorProto.fromPartial(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromPartial(e)); + } + } + if (object.service !== undefined && object.service !== null) { + for (const e of object.service) { + message.service.push(ServiceDescriptorProto.fromPartial(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = FileOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.sourceCodeInfo !== undefined && object.sourceCodeInfo !== null) { + message.sourceCodeInfo = SourceCodeInfo.fromPartial( + object.sourceCodeInfo + ); + } else { + message.sourceCodeInfo = undefined; + } + if (object.syntax !== undefined && object.syntax !== null) { + message.syntax = object.syntax; + } else { + message.syntax = ""; + } + return message; + }, +}; + +const baseDescriptorProto: object = { name: "", reservedName: "" }; + +export const DescriptorProto = { + encode(message: DescriptorProto, writer: Writer = Writer.create()): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + for (const v of message.field) { + FieldDescriptorProto.encode(v!, writer.uint32(18).fork()).ldelim(); + } + for (const v of message.extension) { + FieldDescriptorProto.encode(v!, writer.uint32(50).fork()).ldelim(); + } + for (const v of message.nestedType) { + DescriptorProto.encode(v!, writer.uint32(26).fork()).ldelim(); + } + for (const v of message.enumType) { + EnumDescriptorProto.encode(v!, writer.uint32(34).fork()).ldelim(); + } + for (const v of message.extensionRange) { + DescriptorProto_ExtensionRange.encode( + v!, + writer.uint32(42).fork() + ).ldelim(); + } + for (const v of message.oneofDecl) { + OneofDescriptorProto.encode(v!, writer.uint32(66).fork()).ldelim(); + } + if (message.options !== undefined) { + MessageOptions.encode(message.options, writer.uint32(58).fork()).ldelim(); + } + for (const v of message.reservedRange) { + DescriptorProto_ReservedRange.encode( + v!, + writer.uint32(74).fork() + ).ldelim(); + } + for (const v of message.reservedName) { + writer.uint32(82).string(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): DescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseDescriptorProto } as DescriptorProto; + message.field = []; + message.extension = []; + message.nestedType = []; + message.enumType = []; + message.extensionRange = []; + message.oneofDecl = []; + message.reservedRange = []; + message.reservedName = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.field.push( + FieldDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 6: + message.extension.push( + FieldDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 3: + message.nestedType.push( + DescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 4: + message.enumType.push( + EnumDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 5: + message.extensionRange.push( + DescriptorProto_ExtensionRange.decode(reader, reader.uint32()) + ); + break; + case 8: + message.oneofDecl.push( + OneofDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 7: + message.options = MessageOptions.decode(reader, reader.uint32()); + break; + case 9: + message.reservedRange.push( + DescriptorProto_ReservedRange.decode(reader, reader.uint32()) + ); + break; + case 10: + message.reservedName.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DescriptorProto { + const message = { ...baseDescriptorProto } as DescriptorProto; + message.field = []; + message.extension = []; + message.nestedType = []; + message.enumType = []; + message.extensionRange = []; + message.oneofDecl = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.field !== undefined && object.field !== null) { + for (const e of object.field) { + message.field.push(FieldDescriptorProto.fromJSON(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromJSON(e)); + } + } + if (object.nestedType !== undefined && object.nestedType !== null) { + for (const e of object.nestedType) { + message.nestedType.push(DescriptorProto.fromJSON(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromJSON(e)); + } + } + if (object.extensionRange !== undefined && object.extensionRange !== null) { + for (const e of object.extensionRange) { + message.extensionRange.push(DescriptorProto_ExtensionRange.fromJSON(e)); + } + } + if (object.oneofDecl !== undefined && object.oneofDecl !== null) { + for (const e of object.oneofDecl) { + message.oneofDecl.push(OneofDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = MessageOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push(DescriptorProto_ReservedRange.fromJSON(e)); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(String(e)); + } + } + return message; + }, + + toJSON(message: DescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + if (message.field) { + obj.field = message.field.map((e) => + e ? FieldDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.field = []; + } + if (message.extension) { + obj.extension = message.extension.map((e) => + e ? FieldDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.extension = []; + } + if (message.nestedType) { + obj.nestedType = message.nestedType.map((e) => + e ? DescriptorProto.toJSON(e) : undefined + ); + } else { + obj.nestedType = []; + } + if (message.enumType) { + obj.enumType = message.enumType.map((e) => + e ? EnumDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.enumType = []; + } + if (message.extensionRange) { + obj.extensionRange = message.extensionRange.map((e) => + e ? DescriptorProto_ExtensionRange.toJSON(e) : undefined + ); + } else { + obj.extensionRange = []; + } + if (message.oneofDecl) { + obj.oneofDecl = message.oneofDecl.map((e) => + e ? OneofDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.oneofDecl = []; + } + message.options !== undefined && + (obj.options = message.options + ? MessageOptions.toJSON(message.options) + : undefined); + if (message.reservedRange) { + obj.reservedRange = message.reservedRange.map((e) => + e ? DescriptorProto_ReservedRange.toJSON(e) : undefined + ); + } else { + obj.reservedRange = []; + } + if (message.reservedName) { + obj.reservedName = message.reservedName.map((e) => e); + } else { + obj.reservedName = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): DescriptorProto { + const message = { ...baseDescriptorProto } as DescriptorProto; + message.field = []; + message.extension = []; + message.nestedType = []; + message.enumType = []; + message.extensionRange = []; + message.oneofDecl = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.field !== undefined && object.field !== null) { + for (const e of object.field) { + message.field.push(FieldDescriptorProto.fromPartial(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromPartial(e)); + } + } + if (object.nestedType !== undefined && object.nestedType !== null) { + for (const e of object.nestedType) { + message.nestedType.push(DescriptorProto.fromPartial(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromPartial(e)); + } + } + if (object.extensionRange !== undefined && object.extensionRange !== null) { + for (const e of object.extensionRange) { + message.extensionRange.push( + DescriptorProto_ExtensionRange.fromPartial(e) + ); + } + } + if (object.oneofDecl !== undefined && object.oneofDecl !== null) { + for (const e of object.oneofDecl) { + message.oneofDecl.push(OneofDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = MessageOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push( + DescriptorProto_ReservedRange.fromPartial(e) + ); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(e); + } + } + return message; + }, +}; + +const baseDescriptorProto_ExtensionRange: object = { start: 0, end: 0 }; + +export const DescriptorProto_ExtensionRange = { + encode( + message: DescriptorProto_ExtensionRange, + writer: Writer = Writer.create() + ): Writer { + if (message.start !== 0) { + writer.uint32(8).int32(message.start); + } + if (message.end !== 0) { + writer.uint32(16).int32(message.end); + } + if (message.options !== undefined) { + ExtensionRangeOptions.encode( + message.options, + writer.uint32(26).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): DescriptorProto_ExtensionRange { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseDescriptorProto_ExtensionRange, + } as DescriptorProto_ExtensionRange; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.start = reader.int32(); + break; + case 2: + message.end = reader.int32(); + break; + case 3: + message.options = ExtensionRangeOptions.decode( + reader, + reader.uint32() + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DescriptorProto_ExtensionRange { + const message = { + ...baseDescriptorProto_ExtensionRange, + } as DescriptorProto_ExtensionRange; + if (object.start !== undefined && object.start !== null) { + message.start = Number(object.start); + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = ExtensionRangeOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: DescriptorProto_ExtensionRange): unknown { + const obj: any = {}; + message.start !== undefined && (obj.start = message.start); + message.end !== undefined && (obj.end = message.end); + message.options !== undefined && + (obj.options = message.options + ? ExtensionRangeOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): DescriptorProto_ExtensionRange { + const message = { + ...baseDescriptorProto_ExtensionRange, + } as DescriptorProto_ExtensionRange; + if (object.start !== undefined && object.start !== null) { + message.start = object.start; + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = ExtensionRangeOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseDescriptorProto_ReservedRange: object = { start: 0, end: 0 }; + +export const DescriptorProto_ReservedRange = { + encode( + message: DescriptorProto_ReservedRange, + writer: Writer = Writer.create() + ): Writer { + if (message.start !== 0) { + writer.uint32(8).int32(message.start); + } + if (message.end !== 0) { + writer.uint32(16).int32(message.end); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): DescriptorProto_ReservedRange { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseDescriptorProto_ReservedRange, + } as DescriptorProto_ReservedRange; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.start = reader.int32(); + break; + case 2: + message.end = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DescriptorProto_ReservedRange { + const message = { + ...baseDescriptorProto_ReservedRange, + } as DescriptorProto_ReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = Number(object.start); + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + return message; + }, + + toJSON(message: DescriptorProto_ReservedRange): unknown { + const obj: any = {}; + message.start !== undefined && (obj.start = message.start); + message.end !== undefined && (obj.end = message.end); + return obj; + }, + + fromPartial( + object: DeepPartial + ): DescriptorProto_ReservedRange { + const message = { + ...baseDescriptorProto_ReservedRange, + } as DescriptorProto_ReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = object.start; + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + return message; + }, +}; + +const baseExtensionRangeOptions: object = {}; + +export const ExtensionRangeOptions = { + encode( + message: ExtensionRangeOptions, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ExtensionRangeOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseExtensionRangeOptions } as ExtensionRangeOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ExtensionRangeOptions { + const message = { ...baseExtensionRangeOptions } as ExtensionRangeOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: ExtensionRangeOptions): unknown { + const obj: any = {}; + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial( + object: DeepPartial + ): ExtensionRangeOptions { + const message = { ...baseExtensionRangeOptions } as ExtensionRangeOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseFieldDescriptorProto: object = { + name: "", + number: 0, + label: 1, + type: 1, + typeName: "", + extendee: "", + defaultValue: "", + oneofIndex: 0, + jsonName: "", + proto3Optional: false, +}; + +export const FieldDescriptorProto = { + encode( + message: FieldDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.number !== 0) { + writer.uint32(24).int32(message.number); + } + if (message.label !== 1) { + writer.uint32(32).int32(message.label); + } + if (message.type !== 1) { + writer.uint32(40).int32(message.type); + } + if (message.typeName !== "") { + writer.uint32(50).string(message.typeName); + } + if (message.extendee !== "") { + writer.uint32(18).string(message.extendee); + } + if (message.defaultValue !== "") { + writer.uint32(58).string(message.defaultValue); + } + if (message.oneofIndex !== 0) { + writer.uint32(72).int32(message.oneofIndex); + } + if (message.jsonName !== "") { + writer.uint32(82).string(message.jsonName); + } + if (message.options !== undefined) { + FieldOptions.encode(message.options, writer.uint32(66).fork()).ldelim(); + } + if (message.proto3Optional === true) { + writer.uint32(136).bool(message.proto3Optional); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FieldDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFieldDescriptorProto } as FieldDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 3: + message.number = reader.int32(); + break; + case 4: + message.label = reader.int32() as any; + break; + case 5: + message.type = reader.int32() as any; + break; + case 6: + message.typeName = reader.string(); + break; + case 2: + message.extendee = reader.string(); + break; + case 7: + message.defaultValue = reader.string(); + break; + case 9: + message.oneofIndex = reader.int32(); + break; + case 10: + message.jsonName = reader.string(); + break; + case 8: + message.options = FieldOptions.decode(reader, reader.uint32()); + break; + case 17: + message.proto3Optional = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FieldDescriptorProto { + const message = { ...baseFieldDescriptorProto } as FieldDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = Number(object.number); + } else { + message.number = 0; + } + if (object.label !== undefined && object.label !== null) { + message.label = fieldDescriptorProto_LabelFromJSON(object.label); + } else { + message.label = 1; + } + if (object.type !== undefined && object.type !== null) { + message.type = fieldDescriptorProto_TypeFromJSON(object.type); + } else { + message.type = 1; + } + if (object.typeName !== undefined && object.typeName !== null) { + message.typeName = String(object.typeName); + } else { + message.typeName = ""; + } + if (object.extendee !== undefined && object.extendee !== null) { + message.extendee = String(object.extendee); + } else { + message.extendee = ""; + } + if (object.defaultValue !== undefined && object.defaultValue !== null) { + message.defaultValue = String(object.defaultValue); + } else { + message.defaultValue = ""; + } + if (object.oneofIndex !== undefined && object.oneofIndex !== null) { + message.oneofIndex = Number(object.oneofIndex); + } else { + message.oneofIndex = 0; + } + if (object.jsonName !== undefined && object.jsonName !== null) { + message.jsonName = String(object.jsonName); + } else { + message.jsonName = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = FieldOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.proto3Optional !== undefined && object.proto3Optional !== null) { + message.proto3Optional = Boolean(object.proto3Optional); + } else { + message.proto3Optional = false; + } + return message; + }, + + toJSON(message: FieldDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.number !== undefined && (obj.number = message.number); + message.label !== undefined && + (obj.label = fieldDescriptorProto_LabelToJSON(message.label)); + message.type !== undefined && + (obj.type = fieldDescriptorProto_TypeToJSON(message.type)); + message.typeName !== undefined && (obj.typeName = message.typeName); + message.extendee !== undefined && (obj.extendee = message.extendee); + message.defaultValue !== undefined && + (obj.defaultValue = message.defaultValue); + message.oneofIndex !== undefined && (obj.oneofIndex = message.oneofIndex); + message.jsonName !== undefined && (obj.jsonName = message.jsonName); + message.options !== undefined && + (obj.options = message.options + ? FieldOptions.toJSON(message.options) + : undefined); + message.proto3Optional !== undefined && + (obj.proto3Optional = message.proto3Optional); + return obj; + }, + + fromPartial(object: DeepPartial): FieldDescriptorProto { + const message = { ...baseFieldDescriptorProto } as FieldDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = object.number; + } else { + message.number = 0; + } + if (object.label !== undefined && object.label !== null) { + message.label = object.label; + } else { + message.label = 1; + } + if (object.type !== undefined && object.type !== null) { + message.type = object.type; + } else { + message.type = 1; + } + if (object.typeName !== undefined && object.typeName !== null) { + message.typeName = object.typeName; + } else { + message.typeName = ""; + } + if (object.extendee !== undefined && object.extendee !== null) { + message.extendee = object.extendee; + } else { + message.extendee = ""; + } + if (object.defaultValue !== undefined && object.defaultValue !== null) { + message.defaultValue = object.defaultValue; + } else { + message.defaultValue = ""; + } + if (object.oneofIndex !== undefined && object.oneofIndex !== null) { + message.oneofIndex = object.oneofIndex; + } else { + message.oneofIndex = 0; + } + if (object.jsonName !== undefined && object.jsonName !== null) { + message.jsonName = object.jsonName; + } else { + message.jsonName = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = FieldOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.proto3Optional !== undefined && object.proto3Optional !== null) { + message.proto3Optional = object.proto3Optional; + } else { + message.proto3Optional = false; + } + return message; + }, +}; + +const baseOneofDescriptorProto: object = { name: "" }; + +export const OneofDescriptorProto = { + encode( + message: OneofDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.options !== undefined) { + OneofOptions.encode(message.options, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): OneofDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseOneofDescriptorProto } as OneofDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.options = OneofOptions.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): OneofDescriptorProto { + const message = { ...baseOneofDescriptorProto } as OneofDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = OneofOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: OneofDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.options !== undefined && + (obj.options = message.options + ? OneofOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): OneofDescriptorProto { + const message = { ...baseOneofDescriptorProto } as OneofDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = OneofOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseEnumDescriptorProto: object = { name: "", reservedName: "" }; + +export const EnumDescriptorProto = { + encode( + message: EnumDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + for (const v of message.value) { + EnumValueDescriptorProto.encode(v!, writer.uint32(18).fork()).ldelim(); + } + if (message.options !== undefined) { + EnumOptions.encode(message.options, writer.uint32(26).fork()).ldelim(); + } + for (const v of message.reservedRange) { + EnumDescriptorProto_EnumReservedRange.encode( + v!, + writer.uint32(34).fork() + ).ldelim(); + } + for (const v of message.reservedName) { + writer.uint32(42).string(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): EnumDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseEnumDescriptorProto } as EnumDescriptorProto; + message.value = []; + message.reservedRange = []; + message.reservedName = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.value.push( + EnumValueDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 3: + message.options = EnumOptions.decode(reader, reader.uint32()); + break; + case 4: + message.reservedRange.push( + EnumDescriptorProto_EnumReservedRange.decode( + reader, + reader.uint32() + ) + ); + break; + case 5: + message.reservedName.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumDescriptorProto { + const message = { ...baseEnumDescriptorProto } as EnumDescriptorProto; + message.value = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.value !== undefined && object.value !== null) { + for (const e of object.value) { + message.value.push(EnumValueDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push( + EnumDescriptorProto_EnumReservedRange.fromJSON(e) + ); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(String(e)); + } + } + return message; + }, + + toJSON(message: EnumDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + if (message.value) { + obj.value = message.value.map((e) => + e ? EnumValueDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.value = []; + } + message.options !== undefined && + (obj.options = message.options + ? EnumOptions.toJSON(message.options) + : undefined); + if (message.reservedRange) { + obj.reservedRange = message.reservedRange.map((e) => + e ? EnumDescriptorProto_EnumReservedRange.toJSON(e) : undefined + ); + } else { + obj.reservedRange = []; + } + if (message.reservedName) { + obj.reservedName = message.reservedName.map((e) => e); + } else { + obj.reservedName = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): EnumDescriptorProto { + const message = { ...baseEnumDescriptorProto } as EnumDescriptorProto; + message.value = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.value !== undefined && object.value !== null) { + for (const e of object.value) { + message.value.push(EnumValueDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push( + EnumDescriptorProto_EnumReservedRange.fromPartial(e) + ); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(e); + } + } + return message; + }, +}; + +const baseEnumDescriptorProto_EnumReservedRange: object = { start: 0, end: 0 }; + +export const EnumDescriptorProto_EnumReservedRange = { + encode( + message: EnumDescriptorProto_EnumReservedRange, + writer: Writer = Writer.create() + ): Writer { + if (message.start !== 0) { + writer.uint32(8).int32(message.start); + } + if (message.end !== 0) { + writer.uint32(16).int32(message.end); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): EnumDescriptorProto_EnumReservedRange { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseEnumDescriptorProto_EnumReservedRange, + } as EnumDescriptorProto_EnumReservedRange; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.start = reader.int32(); + break; + case 2: + message.end = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumDescriptorProto_EnumReservedRange { + const message = { + ...baseEnumDescriptorProto_EnumReservedRange, + } as EnumDescriptorProto_EnumReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = Number(object.start); + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + return message; + }, + + toJSON(message: EnumDescriptorProto_EnumReservedRange): unknown { + const obj: any = {}; + message.start !== undefined && (obj.start = message.start); + message.end !== undefined && (obj.end = message.end); + return obj; + }, + + fromPartial( + object: DeepPartial + ): EnumDescriptorProto_EnumReservedRange { + const message = { + ...baseEnumDescriptorProto_EnumReservedRange, + } as EnumDescriptorProto_EnumReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = object.start; + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + return message; + }, +}; + +const baseEnumValueDescriptorProto: object = { name: "", number: 0 }; + +export const EnumValueDescriptorProto = { + encode( + message: EnumValueDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.number !== 0) { + writer.uint32(16).int32(message.number); + } + if (message.options !== undefined) { + EnumValueOptions.encode( + message.options, + writer.uint32(26).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): EnumValueDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseEnumValueDescriptorProto, + } as EnumValueDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.number = reader.int32(); + break; + case 3: + message.options = EnumValueOptions.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumValueDescriptorProto { + const message = { + ...baseEnumValueDescriptorProto, + } as EnumValueDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = Number(object.number); + } else { + message.number = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumValueOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: EnumValueDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.number !== undefined && (obj.number = message.number); + message.options !== undefined && + (obj.options = message.options + ? EnumValueOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): EnumValueDescriptorProto { + const message = { + ...baseEnumValueDescriptorProto, + } as EnumValueDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = object.number; + } else { + message.number = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumValueOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseServiceDescriptorProto: object = { name: "" }; + +export const ServiceDescriptorProto = { + encode( + message: ServiceDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + for (const v of message.method) { + MethodDescriptorProto.encode(v!, writer.uint32(18).fork()).ldelim(); + } + if (message.options !== undefined) { + ServiceOptions.encode(message.options, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ServiceDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseServiceDescriptorProto } as ServiceDescriptorProto; + message.method = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.method.push( + MethodDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 3: + message.options = ServiceOptions.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ServiceDescriptorProto { + const message = { ...baseServiceDescriptorProto } as ServiceDescriptorProto; + message.method = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.method !== undefined && object.method !== null) { + for (const e of object.method) { + message.method.push(MethodDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = ServiceOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: ServiceDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + if (message.method) { + obj.method = message.method.map((e) => + e ? MethodDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.method = []; + } + message.options !== undefined && + (obj.options = message.options + ? ServiceOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): ServiceDescriptorProto { + const message = { ...baseServiceDescriptorProto } as ServiceDescriptorProto; + message.method = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.method !== undefined && object.method !== null) { + for (const e of object.method) { + message.method.push(MethodDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = ServiceOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseMethodDescriptorProto: object = { + name: "", + inputType: "", + outputType: "", + clientStreaming: false, + serverStreaming: false, +}; + +export const MethodDescriptorProto = { + encode( + message: MethodDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.inputType !== "") { + writer.uint32(18).string(message.inputType); + } + if (message.outputType !== "") { + writer.uint32(26).string(message.outputType); + } + if (message.options !== undefined) { + MethodOptions.encode(message.options, writer.uint32(34).fork()).ldelim(); + } + if (message.clientStreaming === true) { + writer.uint32(40).bool(message.clientStreaming); + } + if (message.serverStreaming === true) { + writer.uint32(48).bool(message.serverStreaming); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MethodDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMethodDescriptorProto } as MethodDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.inputType = reader.string(); + break; + case 3: + message.outputType = reader.string(); + break; + case 4: + message.options = MethodOptions.decode(reader, reader.uint32()); + break; + case 5: + message.clientStreaming = reader.bool(); + break; + case 6: + message.serverStreaming = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MethodDescriptorProto { + const message = { ...baseMethodDescriptorProto } as MethodDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.inputType !== undefined && object.inputType !== null) { + message.inputType = String(object.inputType); + } else { + message.inputType = ""; + } + if (object.outputType !== undefined && object.outputType !== null) { + message.outputType = String(object.outputType); + } else { + message.outputType = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = MethodOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if ( + object.clientStreaming !== undefined && + object.clientStreaming !== null + ) { + message.clientStreaming = Boolean(object.clientStreaming); + } else { + message.clientStreaming = false; + } + if ( + object.serverStreaming !== undefined && + object.serverStreaming !== null + ) { + message.serverStreaming = Boolean(object.serverStreaming); + } else { + message.serverStreaming = false; + } + return message; + }, + + toJSON(message: MethodDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.inputType !== undefined && (obj.inputType = message.inputType); + message.outputType !== undefined && (obj.outputType = message.outputType); + message.options !== undefined && + (obj.options = message.options + ? MethodOptions.toJSON(message.options) + : undefined); + message.clientStreaming !== undefined && + (obj.clientStreaming = message.clientStreaming); + message.serverStreaming !== undefined && + (obj.serverStreaming = message.serverStreaming); + return obj; + }, + + fromPartial( + object: DeepPartial + ): MethodDescriptorProto { + const message = { ...baseMethodDescriptorProto } as MethodDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.inputType !== undefined && object.inputType !== null) { + message.inputType = object.inputType; + } else { + message.inputType = ""; + } + if (object.outputType !== undefined && object.outputType !== null) { + message.outputType = object.outputType; + } else { + message.outputType = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = MethodOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if ( + object.clientStreaming !== undefined && + object.clientStreaming !== null + ) { + message.clientStreaming = object.clientStreaming; + } else { + message.clientStreaming = false; + } + if ( + object.serverStreaming !== undefined && + object.serverStreaming !== null + ) { + message.serverStreaming = object.serverStreaming; + } else { + message.serverStreaming = false; + } + return message; + }, +}; + +const baseFileOptions: object = { + javaPackage: "", + javaOuterClassname: "", + javaMultipleFiles: false, + javaGenerateEqualsAndHash: false, + javaStringCheckUtf8: false, + optimizeFor: 1, + goPackage: "", + ccGenericServices: false, + javaGenericServices: false, + pyGenericServices: false, + phpGenericServices: false, + deprecated: false, + ccEnableArenas: false, + objcClassPrefix: "", + csharpNamespace: "", + swiftPrefix: "", + phpClassPrefix: "", + phpNamespace: "", + phpMetadataNamespace: "", + rubyPackage: "", +}; + +export const FileOptions = { + encode(message: FileOptions, writer: Writer = Writer.create()): Writer { + if (message.javaPackage !== "") { + writer.uint32(10).string(message.javaPackage); + } + if (message.javaOuterClassname !== "") { + writer.uint32(66).string(message.javaOuterClassname); + } + if (message.javaMultipleFiles === true) { + writer.uint32(80).bool(message.javaMultipleFiles); + } + if (message.javaGenerateEqualsAndHash === true) { + writer.uint32(160).bool(message.javaGenerateEqualsAndHash); + } + if (message.javaStringCheckUtf8 === true) { + writer.uint32(216).bool(message.javaStringCheckUtf8); + } + if (message.optimizeFor !== 1) { + writer.uint32(72).int32(message.optimizeFor); + } + if (message.goPackage !== "") { + writer.uint32(90).string(message.goPackage); + } + if (message.ccGenericServices === true) { + writer.uint32(128).bool(message.ccGenericServices); + } + if (message.javaGenericServices === true) { + writer.uint32(136).bool(message.javaGenericServices); + } + if (message.pyGenericServices === true) { + writer.uint32(144).bool(message.pyGenericServices); + } + if (message.phpGenericServices === true) { + writer.uint32(336).bool(message.phpGenericServices); + } + if (message.deprecated === true) { + writer.uint32(184).bool(message.deprecated); + } + if (message.ccEnableArenas === true) { + writer.uint32(248).bool(message.ccEnableArenas); + } + if (message.objcClassPrefix !== "") { + writer.uint32(290).string(message.objcClassPrefix); + } + if (message.csharpNamespace !== "") { + writer.uint32(298).string(message.csharpNamespace); + } + if (message.swiftPrefix !== "") { + writer.uint32(314).string(message.swiftPrefix); + } + if (message.phpClassPrefix !== "") { + writer.uint32(322).string(message.phpClassPrefix); + } + if (message.phpNamespace !== "") { + writer.uint32(330).string(message.phpNamespace); + } + if (message.phpMetadataNamespace !== "") { + writer.uint32(354).string(message.phpMetadataNamespace); + } + if (message.rubyPackage !== "") { + writer.uint32(362).string(message.rubyPackage); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FileOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFileOptions } as FileOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.javaPackage = reader.string(); + break; + case 8: + message.javaOuterClassname = reader.string(); + break; + case 10: + message.javaMultipleFiles = reader.bool(); + break; + case 20: + message.javaGenerateEqualsAndHash = reader.bool(); + break; + case 27: + message.javaStringCheckUtf8 = reader.bool(); + break; + case 9: + message.optimizeFor = reader.int32() as any; + break; + case 11: + message.goPackage = reader.string(); + break; + case 16: + message.ccGenericServices = reader.bool(); + break; + case 17: + message.javaGenericServices = reader.bool(); + break; + case 18: + message.pyGenericServices = reader.bool(); + break; + case 42: + message.phpGenericServices = reader.bool(); + break; + case 23: + message.deprecated = reader.bool(); + break; + case 31: + message.ccEnableArenas = reader.bool(); + break; + case 36: + message.objcClassPrefix = reader.string(); + break; + case 37: + message.csharpNamespace = reader.string(); + break; + case 39: + message.swiftPrefix = reader.string(); + break; + case 40: + message.phpClassPrefix = reader.string(); + break; + case 41: + message.phpNamespace = reader.string(); + break; + case 44: + message.phpMetadataNamespace = reader.string(); + break; + case 45: + message.rubyPackage = reader.string(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FileOptions { + const message = { ...baseFileOptions } as FileOptions; + message.uninterpretedOption = []; + if (object.javaPackage !== undefined && object.javaPackage !== null) { + message.javaPackage = String(object.javaPackage); + } else { + message.javaPackage = ""; + } + if ( + object.javaOuterClassname !== undefined && + object.javaOuterClassname !== null + ) { + message.javaOuterClassname = String(object.javaOuterClassname); + } else { + message.javaOuterClassname = ""; + } + if ( + object.javaMultipleFiles !== undefined && + object.javaMultipleFiles !== null + ) { + message.javaMultipleFiles = Boolean(object.javaMultipleFiles); + } else { + message.javaMultipleFiles = false; + } + if ( + object.javaGenerateEqualsAndHash !== undefined && + object.javaGenerateEqualsAndHash !== null + ) { + message.javaGenerateEqualsAndHash = Boolean( + object.javaGenerateEqualsAndHash + ); + } else { + message.javaGenerateEqualsAndHash = false; + } + if ( + object.javaStringCheckUtf8 !== undefined && + object.javaStringCheckUtf8 !== null + ) { + message.javaStringCheckUtf8 = Boolean(object.javaStringCheckUtf8); + } else { + message.javaStringCheckUtf8 = false; + } + if (object.optimizeFor !== undefined && object.optimizeFor !== null) { + message.optimizeFor = fileOptions_OptimizeModeFromJSON( + object.optimizeFor + ); + } else { + message.optimizeFor = 1; + } + if (object.goPackage !== undefined && object.goPackage !== null) { + message.goPackage = String(object.goPackage); + } else { + message.goPackage = ""; + } + if ( + object.ccGenericServices !== undefined && + object.ccGenericServices !== null + ) { + message.ccGenericServices = Boolean(object.ccGenericServices); + } else { + message.ccGenericServices = false; + } + if ( + object.javaGenericServices !== undefined && + object.javaGenericServices !== null + ) { + message.javaGenericServices = Boolean(object.javaGenericServices); + } else { + message.javaGenericServices = false; + } + if ( + object.pyGenericServices !== undefined && + object.pyGenericServices !== null + ) { + message.pyGenericServices = Boolean(object.pyGenericServices); + } else { + message.pyGenericServices = false; + } + if ( + object.phpGenericServices !== undefined && + object.phpGenericServices !== null + ) { + message.phpGenericServices = Boolean(object.phpGenericServices); + } else { + message.phpGenericServices = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if (object.ccEnableArenas !== undefined && object.ccEnableArenas !== null) { + message.ccEnableArenas = Boolean(object.ccEnableArenas); + } else { + message.ccEnableArenas = false; + } + if ( + object.objcClassPrefix !== undefined && + object.objcClassPrefix !== null + ) { + message.objcClassPrefix = String(object.objcClassPrefix); + } else { + message.objcClassPrefix = ""; + } + if ( + object.csharpNamespace !== undefined && + object.csharpNamespace !== null + ) { + message.csharpNamespace = String(object.csharpNamespace); + } else { + message.csharpNamespace = ""; + } + if (object.swiftPrefix !== undefined && object.swiftPrefix !== null) { + message.swiftPrefix = String(object.swiftPrefix); + } else { + message.swiftPrefix = ""; + } + if (object.phpClassPrefix !== undefined && object.phpClassPrefix !== null) { + message.phpClassPrefix = String(object.phpClassPrefix); + } else { + message.phpClassPrefix = ""; + } + if (object.phpNamespace !== undefined && object.phpNamespace !== null) { + message.phpNamespace = String(object.phpNamespace); + } else { + message.phpNamespace = ""; + } + if ( + object.phpMetadataNamespace !== undefined && + object.phpMetadataNamespace !== null + ) { + message.phpMetadataNamespace = String(object.phpMetadataNamespace); + } else { + message.phpMetadataNamespace = ""; + } + if (object.rubyPackage !== undefined && object.rubyPackage !== null) { + message.rubyPackage = String(object.rubyPackage); + } else { + message.rubyPackage = ""; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: FileOptions): unknown { + const obj: any = {}; + message.javaPackage !== undefined && + (obj.javaPackage = message.javaPackage); + message.javaOuterClassname !== undefined && + (obj.javaOuterClassname = message.javaOuterClassname); + message.javaMultipleFiles !== undefined && + (obj.javaMultipleFiles = message.javaMultipleFiles); + message.javaGenerateEqualsAndHash !== undefined && + (obj.javaGenerateEqualsAndHash = message.javaGenerateEqualsAndHash); + message.javaStringCheckUtf8 !== undefined && + (obj.javaStringCheckUtf8 = message.javaStringCheckUtf8); + message.optimizeFor !== undefined && + (obj.optimizeFor = fileOptions_OptimizeModeToJSON(message.optimizeFor)); + message.goPackage !== undefined && (obj.goPackage = message.goPackage); + message.ccGenericServices !== undefined && + (obj.ccGenericServices = message.ccGenericServices); + message.javaGenericServices !== undefined && + (obj.javaGenericServices = message.javaGenericServices); + message.pyGenericServices !== undefined && + (obj.pyGenericServices = message.pyGenericServices); + message.phpGenericServices !== undefined && + (obj.phpGenericServices = message.phpGenericServices); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.ccEnableArenas !== undefined && + (obj.ccEnableArenas = message.ccEnableArenas); + message.objcClassPrefix !== undefined && + (obj.objcClassPrefix = message.objcClassPrefix); + message.csharpNamespace !== undefined && + (obj.csharpNamespace = message.csharpNamespace); + message.swiftPrefix !== undefined && + (obj.swiftPrefix = message.swiftPrefix); + message.phpClassPrefix !== undefined && + (obj.phpClassPrefix = message.phpClassPrefix); + message.phpNamespace !== undefined && + (obj.phpNamespace = message.phpNamespace); + message.phpMetadataNamespace !== undefined && + (obj.phpMetadataNamespace = message.phpMetadataNamespace); + message.rubyPackage !== undefined && + (obj.rubyPackage = message.rubyPackage); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): FileOptions { + const message = { ...baseFileOptions } as FileOptions; + message.uninterpretedOption = []; + if (object.javaPackage !== undefined && object.javaPackage !== null) { + message.javaPackage = object.javaPackage; + } else { + message.javaPackage = ""; + } + if ( + object.javaOuterClassname !== undefined && + object.javaOuterClassname !== null + ) { + message.javaOuterClassname = object.javaOuterClassname; + } else { + message.javaOuterClassname = ""; + } + if ( + object.javaMultipleFiles !== undefined && + object.javaMultipleFiles !== null + ) { + message.javaMultipleFiles = object.javaMultipleFiles; + } else { + message.javaMultipleFiles = false; + } + if ( + object.javaGenerateEqualsAndHash !== undefined && + object.javaGenerateEqualsAndHash !== null + ) { + message.javaGenerateEqualsAndHash = object.javaGenerateEqualsAndHash; + } else { + message.javaGenerateEqualsAndHash = false; + } + if ( + object.javaStringCheckUtf8 !== undefined && + object.javaStringCheckUtf8 !== null + ) { + message.javaStringCheckUtf8 = object.javaStringCheckUtf8; + } else { + message.javaStringCheckUtf8 = false; + } + if (object.optimizeFor !== undefined && object.optimizeFor !== null) { + message.optimizeFor = object.optimizeFor; + } else { + message.optimizeFor = 1; + } + if (object.goPackage !== undefined && object.goPackage !== null) { + message.goPackage = object.goPackage; + } else { + message.goPackage = ""; + } + if ( + object.ccGenericServices !== undefined && + object.ccGenericServices !== null + ) { + message.ccGenericServices = object.ccGenericServices; + } else { + message.ccGenericServices = false; + } + if ( + object.javaGenericServices !== undefined && + object.javaGenericServices !== null + ) { + message.javaGenericServices = object.javaGenericServices; + } else { + message.javaGenericServices = false; + } + if ( + object.pyGenericServices !== undefined && + object.pyGenericServices !== null + ) { + message.pyGenericServices = object.pyGenericServices; + } else { + message.pyGenericServices = false; + } + if ( + object.phpGenericServices !== undefined && + object.phpGenericServices !== null + ) { + message.phpGenericServices = object.phpGenericServices; + } else { + message.phpGenericServices = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if (object.ccEnableArenas !== undefined && object.ccEnableArenas !== null) { + message.ccEnableArenas = object.ccEnableArenas; + } else { + message.ccEnableArenas = false; + } + if ( + object.objcClassPrefix !== undefined && + object.objcClassPrefix !== null + ) { + message.objcClassPrefix = object.objcClassPrefix; + } else { + message.objcClassPrefix = ""; + } + if ( + object.csharpNamespace !== undefined && + object.csharpNamespace !== null + ) { + message.csharpNamespace = object.csharpNamespace; + } else { + message.csharpNamespace = ""; + } + if (object.swiftPrefix !== undefined && object.swiftPrefix !== null) { + message.swiftPrefix = object.swiftPrefix; + } else { + message.swiftPrefix = ""; + } + if (object.phpClassPrefix !== undefined && object.phpClassPrefix !== null) { + message.phpClassPrefix = object.phpClassPrefix; + } else { + message.phpClassPrefix = ""; + } + if (object.phpNamespace !== undefined && object.phpNamespace !== null) { + message.phpNamespace = object.phpNamespace; + } else { + message.phpNamespace = ""; + } + if ( + object.phpMetadataNamespace !== undefined && + object.phpMetadataNamespace !== null + ) { + message.phpMetadataNamespace = object.phpMetadataNamespace; + } else { + message.phpMetadataNamespace = ""; + } + if (object.rubyPackage !== undefined && object.rubyPackage !== null) { + message.rubyPackage = object.rubyPackage; + } else { + message.rubyPackage = ""; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseMessageOptions: object = { + messageSetWireFormat: false, + noStandardDescriptorAccessor: false, + deprecated: false, + mapEntry: false, +}; + +export const MessageOptions = { + encode(message: MessageOptions, writer: Writer = Writer.create()): Writer { + if (message.messageSetWireFormat === true) { + writer.uint32(8).bool(message.messageSetWireFormat); + } + if (message.noStandardDescriptorAccessor === true) { + writer.uint32(16).bool(message.noStandardDescriptorAccessor); + } + if (message.deprecated === true) { + writer.uint32(24).bool(message.deprecated); + } + if (message.mapEntry === true) { + writer.uint32(56).bool(message.mapEntry); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MessageOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMessageOptions } as MessageOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.messageSetWireFormat = reader.bool(); + break; + case 2: + message.noStandardDescriptorAccessor = reader.bool(); + break; + case 3: + message.deprecated = reader.bool(); + break; + case 7: + message.mapEntry = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MessageOptions { + const message = { ...baseMessageOptions } as MessageOptions; + message.uninterpretedOption = []; + if ( + object.messageSetWireFormat !== undefined && + object.messageSetWireFormat !== null + ) { + message.messageSetWireFormat = Boolean(object.messageSetWireFormat); + } else { + message.messageSetWireFormat = false; + } + if ( + object.noStandardDescriptorAccessor !== undefined && + object.noStandardDescriptorAccessor !== null + ) { + message.noStandardDescriptorAccessor = Boolean( + object.noStandardDescriptorAccessor + ); + } else { + message.noStandardDescriptorAccessor = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if (object.mapEntry !== undefined && object.mapEntry !== null) { + message.mapEntry = Boolean(object.mapEntry); + } else { + message.mapEntry = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: MessageOptions): unknown { + const obj: any = {}; + message.messageSetWireFormat !== undefined && + (obj.messageSetWireFormat = message.messageSetWireFormat); + message.noStandardDescriptorAccessor !== undefined && + (obj.noStandardDescriptorAccessor = message.noStandardDescriptorAccessor); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.mapEntry !== undefined && (obj.mapEntry = message.mapEntry); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): MessageOptions { + const message = { ...baseMessageOptions } as MessageOptions; + message.uninterpretedOption = []; + if ( + object.messageSetWireFormat !== undefined && + object.messageSetWireFormat !== null + ) { + message.messageSetWireFormat = object.messageSetWireFormat; + } else { + message.messageSetWireFormat = false; + } + if ( + object.noStandardDescriptorAccessor !== undefined && + object.noStandardDescriptorAccessor !== null + ) { + message.noStandardDescriptorAccessor = + object.noStandardDescriptorAccessor; + } else { + message.noStandardDescriptorAccessor = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if (object.mapEntry !== undefined && object.mapEntry !== null) { + message.mapEntry = object.mapEntry; + } else { + message.mapEntry = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseFieldOptions: object = { + ctype: 0, + packed: false, + jstype: 0, + lazy: false, + deprecated: false, + weak: false, +}; + +export const FieldOptions = { + encode(message: FieldOptions, writer: Writer = Writer.create()): Writer { + if (message.ctype !== 0) { + writer.uint32(8).int32(message.ctype); + } + if (message.packed === true) { + writer.uint32(16).bool(message.packed); + } + if (message.jstype !== 0) { + writer.uint32(48).int32(message.jstype); + } + if (message.lazy === true) { + writer.uint32(40).bool(message.lazy); + } + if (message.deprecated === true) { + writer.uint32(24).bool(message.deprecated); + } + if (message.weak === true) { + writer.uint32(80).bool(message.weak); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FieldOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFieldOptions } as FieldOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.ctype = reader.int32() as any; + break; + case 2: + message.packed = reader.bool(); + break; + case 6: + message.jstype = reader.int32() as any; + break; + case 5: + message.lazy = reader.bool(); + break; + case 3: + message.deprecated = reader.bool(); + break; + case 10: + message.weak = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FieldOptions { + const message = { ...baseFieldOptions } as FieldOptions; + message.uninterpretedOption = []; + if (object.ctype !== undefined && object.ctype !== null) { + message.ctype = fieldOptions_CTypeFromJSON(object.ctype); + } else { + message.ctype = 0; + } + if (object.packed !== undefined && object.packed !== null) { + message.packed = Boolean(object.packed); + } else { + message.packed = false; + } + if (object.jstype !== undefined && object.jstype !== null) { + message.jstype = fieldOptions_JSTypeFromJSON(object.jstype); + } else { + message.jstype = 0; + } + if (object.lazy !== undefined && object.lazy !== null) { + message.lazy = Boolean(object.lazy); + } else { + message.lazy = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if (object.weak !== undefined && object.weak !== null) { + message.weak = Boolean(object.weak); + } else { + message.weak = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: FieldOptions): unknown { + const obj: any = {}; + message.ctype !== undefined && + (obj.ctype = fieldOptions_CTypeToJSON(message.ctype)); + message.packed !== undefined && (obj.packed = message.packed); + message.jstype !== undefined && + (obj.jstype = fieldOptions_JSTypeToJSON(message.jstype)); + message.lazy !== undefined && (obj.lazy = message.lazy); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.weak !== undefined && (obj.weak = message.weak); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): FieldOptions { + const message = { ...baseFieldOptions } as FieldOptions; + message.uninterpretedOption = []; + if (object.ctype !== undefined && object.ctype !== null) { + message.ctype = object.ctype; + } else { + message.ctype = 0; + } + if (object.packed !== undefined && object.packed !== null) { + message.packed = object.packed; + } else { + message.packed = false; + } + if (object.jstype !== undefined && object.jstype !== null) { + message.jstype = object.jstype; + } else { + message.jstype = 0; + } + if (object.lazy !== undefined && object.lazy !== null) { + message.lazy = object.lazy; + } else { + message.lazy = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if (object.weak !== undefined && object.weak !== null) { + message.weak = object.weak; + } else { + message.weak = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseOneofOptions: object = {}; + +export const OneofOptions = { + encode(message: OneofOptions, writer: Writer = Writer.create()): Writer { + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): OneofOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseOneofOptions } as OneofOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): OneofOptions { + const message = { ...baseOneofOptions } as OneofOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: OneofOptions): unknown { + const obj: any = {}; + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): OneofOptions { + const message = { ...baseOneofOptions } as OneofOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseEnumOptions: object = { allowAlias: false, deprecated: false }; + +export const EnumOptions = { + encode(message: EnumOptions, writer: Writer = Writer.create()): Writer { + if (message.allowAlias === true) { + writer.uint32(16).bool(message.allowAlias); + } + if (message.deprecated === true) { + writer.uint32(24).bool(message.deprecated); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): EnumOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseEnumOptions } as EnumOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + message.allowAlias = reader.bool(); + break; + case 3: + message.deprecated = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumOptions { + const message = { ...baseEnumOptions } as EnumOptions; + message.uninterpretedOption = []; + if (object.allowAlias !== undefined && object.allowAlias !== null) { + message.allowAlias = Boolean(object.allowAlias); + } else { + message.allowAlias = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: EnumOptions): unknown { + const obj: any = {}; + message.allowAlias !== undefined && (obj.allowAlias = message.allowAlias); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): EnumOptions { + const message = { ...baseEnumOptions } as EnumOptions; + message.uninterpretedOption = []; + if (object.allowAlias !== undefined && object.allowAlias !== null) { + message.allowAlias = object.allowAlias; + } else { + message.allowAlias = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseEnumValueOptions: object = { deprecated: false }; + +export const EnumValueOptions = { + encode(message: EnumValueOptions, writer: Writer = Writer.create()): Writer { + if (message.deprecated === true) { + writer.uint32(8).bool(message.deprecated); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): EnumValueOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseEnumValueOptions } as EnumValueOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.deprecated = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumValueOptions { + const message = { ...baseEnumValueOptions } as EnumValueOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: EnumValueOptions): unknown { + const obj: any = {}; + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): EnumValueOptions { + const message = { ...baseEnumValueOptions } as EnumValueOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseServiceOptions: object = { deprecated: false }; + +export const ServiceOptions = { + encode(message: ServiceOptions, writer: Writer = Writer.create()): Writer { + if (message.deprecated === true) { + writer.uint32(264).bool(message.deprecated); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ServiceOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseServiceOptions } as ServiceOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 33: + message.deprecated = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ServiceOptions { + const message = { ...baseServiceOptions } as ServiceOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: ServiceOptions): unknown { + const obj: any = {}; + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): ServiceOptions { + const message = { ...baseServiceOptions } as ServiceOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseMethodOptions: object = { deprecated: false, idempotencyLevel: 0 }; + +export const MethodOptions = { + encode(message: MethodOptions, writer: Writer = Writer.create()): Writer { + if (message.deprecated === true) { + writer.uint32(264).bool(message.deprecated); + } + if (message.idempotencyLevel !== 0) { + writer.uint32(272).int32(message.idempotencyLevel); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MethodOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMethodOptions } as MethodOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 33: + message.deprecated = reader.bool(); + break; + case 34: + message.idempotencyLevel = reader.int32() as any; + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MethodOptions { + const message = { ...baseMethodOptions } as MethodOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.idempotencyLevel !== undefined && + object.idempotencyLevel !== null + ) { + message.idempotencyLevel = methodOptions_IdempotencyLevelFromJSON( + object.idempotencyLevel + ); + } else { + message.idempotencyLevel = 0; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: MethodOptions): unknown { + const obj: any = {}; + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.idempotencyLevel !== undefined && + (obj.idempotencyLevel = methodOptions_IdempotencyLevelToJSON( + message.idempotencyLevel + )); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): MethodOptions { + const message = { ...baseMethodOptions } as MethodOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.idempotencyLevel !== undefined && + object.idempotencyLevel !== null + ) { + message.idempotencyLevel = object.idempotencyLevel; + } else { + message.idempotencyLevel = 0; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseUninterpretedOption: object = { + identifierValue: "", + positiveIntValue: 0, + negativeIntValue: 0, + doubleValue: 0, + aggregateValue: "", +}; + +export const UninterpretedOption = { + encode( + message: UninterpretedOption, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.name) { + UninterpretedOption_NamePart.encode( + v!, + writer.uint32(18).fork() + ).ldelim(); + } + if (message.identifierValue !== "") { + writer.uint32(26).string(message.identifierValue); + } + if (message.positiveIntValue !== 0) { + writer.uint32(32).uint64(message.positiveIntValue); + } + if (message.negativeIntValue !== 0) { + writer.uint32(40).int64(message.negativeIntValue); + } + if (message.doubleValue !== 0) { + writer.uint32(49).double(message.doubleValue); + } + if (message.stringValue.length !== 0) { + writer.uint32(58).bytes(message.stringValue); + } + if (message.aggregateValue !== "") { + writer.uint32(66).string(message.aggregateValue); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): UninterpretedOption { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseUninterpretedOption } as UninterpretedOption; + message.name = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + message.name.push( + UninterpretedOption_NamePart.decode(reader, reader.uint32()) + ); + break; + case 3: + message.identifierValue = reader.string(); + break; + case 4: + message.positiveIntValue = longToNumber(reader.uint64() as Long); + break; + case 5: + message.negativeIntValue = longToNumber(reader.int64() as Long); + break; + case 6: + message.doubleValue = reader.double(); + break; + case 7: + message.stringValue = reader.bytes(); + break; + case 8: + message.aggregateValue = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): UninterpretedOption { + const message = { ...baseUninterpretedOption } as UninterpretedOption; + message.name = []; + if (object.name !== undefined && object.name !== null) { + for (const e of object.name) { + message.name.push(UninterpretedOption_NamePart.fromJSON(e)); + } + } + if ( + object.identifierValue !== undefined && + object.identifierValue !== null + ) { + message.identifierValue = String(object.identifierValue); + } else { + message.identifierValue = ""; + } + if ( + object.positiveIntValue !== undefined && + object.positiveIntValue !== null + ) { + message.positiveIntValue = Number(object.positiveIntValue); + } else { + message.positiveIntValue = 0; + } + if ( + object.negativeIntValue !== undefined && + object.negativeIntValue !== null + ) { + message.negativeIntValue = Number(object.negativeIntValue); + } else { + message.negativeIntValue = 0; + } + if (object.doubleValue !== undefined && object.doubleValue !== null) { + message.doubleValue = Number(object.doubleValue); + } else { + message.doubleValue = 0; + } + if (object.stringValue !== undefined && object.stringValue !== null) { + message.stringValue = bytesFromBase64(object.stringValue); + } + if (object.aggregateValue !== undefined && object.aggregateValue !== null) { + message.aggregateValue = String(object.aggregateValue); + } else { + message.aggregateValue = ""; + } + return message; + }, + + toJSON(message: UninterpretedOption): unknown { + const obj: any = {}; + if (message.name) { + obj.name = message.name.map((e) => + e ? UninterpretedOption_NamePart.toJSON(e) : undefined + ); + } else { + obj.name = []; + } + message.identifierValue !== undefined && + (obj.identifierValue = message.identifierValue); + message.positiveIntValue !== undefined && + (obj.positiveIntValue = message.positiveIntValue); + message.negativeIntValue !== undefined && + (obj.negativeIntValue = message.negativeIntValue); + message.doubleValue !== undefined && + (obj.doubleValue = message.doubleValue); + message.stringValue !== undefined && + (obj.stringValue = base64FromBytes( + message.stringValue !== undefined + ? message.stringValue + : new Uint8Array() + )); + message.aggregateValue !== undefined && + (obj.aggregateValue = message.aggregateValue); + return obj; + }, + + fromPartial(object: DeepPartial): UninterpretedOption { + const message = { ...baseUninterpretedOption } as UninterpretedOption; + message.name = []; + if (object.name !== undefined && object.name !== null) { + for (const e of object.name) { + message.name.push(UninterpretedOption_NamePart.fromPartial(e)); + } + } + if ( + object.identifierValue !== undefined && + object.identifierValue !== null + ) { + message.identifierValue = object.identifierValue; + } else { + message.identifierValue = ""; + } + if ( + object.positiveIntValue !== undefined && + object.positiveIntValue !== null + ) { + message.positiveIntValue = object.positiveIntValue; + } else { + message.positiveIntValue = 0; + } + if ( + object.negativeIntValue !== undefined && + object.negativeIntValue !== null + ) { + message.negativeIntValue = object.negativeIntValue; + } else { + message.negativeIntValue = 0; + } + if (object.doubleValue !== undefined && object.doubleValue !== null) { + message.doubleValue = object.doubleValue; + } else { + message.doubleValue = 0; + } + if (object.stringValue !== undefined && object.stringValue !== null) { + message.stringValue = object.stringValue; + } else { + message.stringValue = new Uint8Array(); + } + if (object.aggregateValue !== undefined && object.aggregateValue !== null) { + message.aggregateValue = object.aggregateValue; + } else { + message.aggregateValue = ""; + } + return message; + }, +}; + +const baseUninterpretedOption_NamePart: object = { + namePart: "", + isExtension: false, +}; + +export const UninterpretedOption_NamePart = { + encode( + message: UninterpretedOption_NamePart, + writer: Writer = Writer.create() + ): Writer { + if (message.namePart !== "") { + writer.uint32(10).string(message.namePart); + } + if (message.isExtension === true) { + writer.uint32(16).bool(message.isExtension); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): UninterpretedOption_NamePart { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseUninterpretedOption_NamePart, + } as UninterpretedOption_NamePart; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.namePart = reader.string(); + break; + case 2: + message.isExtension = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): UninterpretedOption_NamePart { + const message = { + ...baseUninterpretedOption_NamePart, + } as UninterpretedOption_NamePart; + if (object.namePart !== undefined && object.namePart !== null) { + message.namePart = String(object.namePart); + } else { + message.namePart = ""; + } + if (object.isExtension !== undefined && object.isExtension !== null) { + message.isExtension = Boolean(object.isExtension); + } else { + message.isExtension = false; + } + return message; + }, + + toJSON(message: UninterpretedOption_NamePart): unknown { + const obj: any = {}; + message.namePart !== undefined && (obj.namePart = message.namePart); + message.isExtension !== undefined && + (obj.isExtension = message.isExtension); + return obj; + }, + + fromPartial( + object: DeepPartial + ): UninterpretedOption_NamePart { + const message = { + ...baseUninterpretedOption_NamePart, + } as UninterpretedOption_NamePart; + if (object.namePart !== undefined && object.namePart !== null) { + message.namePart = object.namePart; + } else { + message.namePart = ""; + } + if (object.isExtension !== undefined && object.isExtension !== null) { + message.isExtension = object.isExtension; + } else { + message.isExtension = false; + } + return message; + }, +}; + +const baseSourceCodeInfo: object = {}; + +export const SourceCodeInfo = { + encode(message: SourceCodeInfo, writer: Writer = Writer.create()): Writer { + for (const v of message.location) { + SourceCodeInfo_Location.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): SourceCodeInfo { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseSourceCodeInfo } as SourceCodeInfo; + message.location = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.location.push( + SourceCodeInfo_Location.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): SourceCodeInfo { + const message = { ...baseSourceCodeInfo } as SourceCodeInfo; + message.location = []; + if (object.location !== undefined && object.location !== null) { + for (const e of object.location) { + message.location.push(SourceCodeInfo_Location.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: SourceCodeInfo): unknown { + const obj: any = {}; + if (message.location) { + obj.location = message.location.map((e) => + e ? SourceCodeInfo_Location.toJSON(e) : undefined + ); + } else { + obj.location = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): SourceCodeInfo { + const message = { ...baseSourceCodeInfo } as SourceCodeInfo; + message.location = []; + if (object.location !== undefined && object.location !== null) { + for (const e of object.location) { + message.location.push(SourceCodeInfo_Location.fromPartial(e)); + } + } + return message; + }, +}; + +const baseSourceCodeInfo_Location: object = { + path: 0, + span: 0, + leadingComments: "", + trailingComments: "", + leadingDetachedComments: "", +}; + +export const SourceCodeInfo_Location = { + encode( + message: SourceCodeInfo_Location, + writer: Writer = Writer.create() + ): Writer { + writer.uint32(10).fork(); + for (const v of message.path) { + writer.int32(v); + } + writer.ldelim(); + writer.uint32(18).fork(); + for (const v of message.span) { + writer.int32(v); + } + writer.ldelim(); + if (message.leadingComments !== "") { + writer.uint32(26).string(message.leadingComments); + } + if (message.trailingComments !== "") { + writer.uint32(34).string(message.trailingComments); + } + for (const v of message.leadingDetachedComments) { + writer.uint32(50).string(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): SourceCodeInfo_Location { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseSourceCodeInfo_Location, + } as SourceCodeInfo_Location; + message.path = []; + message.span = []; + message.leadingDetachedComments = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.path.push(reader.int32()); + } + } else { + message.path.push(reader.int32()); + } + break; + case 2: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.span.push(reader.int32()); + } + } else { + message.span.push(reader.int32()); + } + break; + case 3: + message.leadingComments = reader.string(); + break; + case 4: + message.trailingComments = reader.string(); + break; + case 6: + message.leadingDetachedComments.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): SourceCodeInfo_Location { + const message = { + ...baseSourceCodeInfo_Location, + } as SourceCodeInfo_Location; + message.path = []; + message.span = []; + message.leadingDetachedComments = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(Number(e)); + } + } + if (object.span !== undefined && object.span !== null) { + for (const e of object.span) { + message.span.push(Number(e)); + } + } + if ( + object.leadingComments !== undefined && + object.leadingComments !== null + ) { + message.leadingComments = String(object.leadingComments); + } else { + message.leadingComments = ""; + } + if ( + object.trailingComments !== undefined && + object.trailingComments !== null + ) { + message.trailingComments = String(object.trailingComments); + } else { + message.trailingComments = ""; + } + if ( + object.leadingDetachedComments !== undefined && + object.leadingDetachedComments !== null + ) { + for (const e of object.leadingDetachedComments) { + message.leadingDetachedComments.push(String(e)); + } + } + return message; + }, + + toJSON(message: SourceCodeInfo_Location): unknown { + const obj: any = {}; + if (message.path) { + obj.path = message.path.map((e) => e); + } else { + obj.path = []; + } + if (message.span) { + obj.span = message.span.map((e) => e); + } else { + obj.span = []; + } + message.leadingComments !== undefined && + (obj.leadingComments = message.leadingComments); + message.trailingComments !== undefined && + (obj.trailingComments = message.trailingComments); + if (message.leadingDetachedComments) { + obj.leadingDetachedComments = message.leadingDetachedComments.map( + (e) => e + ); + } else { + obj.leadingDetachedComments = []; + } + return obj; + }, + + fromPartial( + object: DeepPartial + ): SourceCodeInfo_Location { + const message = { + ...baseSourceCodeInfo_Location, + } as SourceCodeInfo_Location; + message.path = []; + message.span = []; + message.leadingDetachedComments = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(e); + } + } + if (object.span !== undefined && object.span !== null) { + for (const e of object.span) { + message.span.push(e); + } + } + if ( + object.leadingComments !== undefined && + object.leadingComments !== null + ) { + message.leadingComments = object.leadingComments; + } else { + message.leadingComments = ""; + } + if ( + object.trailingComments !== undefined && + object.trailingComments !== null + ) { + message.trailingComments = object.trailingComments; + } else { + message.trailingComments = ""; + } + if ( + object.leadingDetachedComments !== undefined && + object.leadingDetachedComments !== null + ) { + for (const e of object.leadingDetachedComments) { + message.leadingDetachedComments.push(e); + } + } + return message; + }, +}; + +const baseGeneratedCodeInfo: object = {}; + +export const GeneratedCodeInfo = { + encode(message: GeneratedCodeInfo, writer: Writer = Writer.create()): Writer { + for (const v of message.annotation) { + GeneratedCodeInfo_Annotation.encode( + v!, + writer.uint32(10).fork() + ).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): GeneratedCodeInfo { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseGeneratedCodeInfo } as GeneratedCodeInfo; + message.annotation = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.annotation.push( + GeneratedCodeInfo_Annotation.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GeneratedCodeInfo { + const message = { ...baseGeneratedCodeInfo } as GeneratedCodeInfo; + message.annotation = []; + if (object.annotation !== undefined && object.annotation !== null) { + for (const e of object.annotation) { + message.annotation.push(GeneratedCodeInfo_Annotation.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: GeneratedCodeInfo): unknown { + const obj: any = {}; + if (message.annotation) { + obj.annotation = message.annotation.map((e) => + e ? GeneratedCodeInfo_Annotation.toJSON(e) : undefined + ); + } else { + obj.annotation = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): GeneratedCodeInfo { + const message = { ...baseGeneratedCodeInfo } as GeneratedCodeInfo; + message.annotation = []; + if (object.annotation !== undefined && object.annotation !== null) { + for (const e of object.annotation) { + message.annotation.push(GeneratedCodeInfo_Annotation.fromPartial(e)); + } + } + return message; + }, +}; + +const baseGeneratedCodeInfo_Annotation: object = { + path: 0, + sourceFile: "", + begin: 0, + end: 0, +}; + +export const GeneratedCodeInfo_Annotation = { + encode( + message: GeneratedCodeInfo_Annotation, + writer: Writer = Writer.create() + ): Writer { + writer.uint32(10).fork(); + for (const v of message.path) { + writer.int32(v); + } + writer.ldelim(); + if (message.sourceFile !== "") { + writer.uint32(18).string(message.sourceFile); + } + if (message.begin !== 0) { + writer.uint32(24).int32(message.begin); + } + if (message.end !== 0) { + writer.uint32(32).int32(message.end); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): GeneratedCodeInfo_Annotation { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseGeneratedCodeInfo_Annotation, + } as GeneratedCodeInfo_Annotation; + message.path = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.path.push(reader.int32()); + } + } else { + message.path.push(reader.int32()); + } + break; + case 2: + message.sourceFile = reader.string(); + break; + case 3: + message.begin = reader.int32(); + break; + case 4: + message.end = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GeneratedCodeInfo_Annotation { + const message = { + ...baseGeneratedCodeInfo_Annotation, + } as GeneratedCodeInfo_Annotation; + message.path = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(Number(e)); + } + } + if (object.sourceFile !== undefined && object.sourceFile !== null) { + message.sourceFile = String(object.sourceFile); + } else { + message.sourceFile = ""; + } + if (object.begin !== undefined && object.begin !== null) { + message.begin = Number(object.begin); + } else { + message.begin = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + return message; + }, + + toJSON(message: GeneratedCodeInfo_Annotation): unknown { + const obj: any = {}; + if (message.path) { + obj.path = message.path.map((e) => e); + } else { + obj.path = []; + } + message.sourceFile !== undefined && (obj.sourceFile = message.sourceFile); + message.begin !== undefined && (obj.begin = message.begin); + message.end !== undefined && (obj.end = message.end); + return obj; + }, + + fromPartial( + object: DeepPartial + ): GeneratedCodeInfo_Annotation { + const message = { + ...baseGeneratedCodeInfo_Annotation, + } as GeneratedCodeInfo_Annotation; + message.path = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(e); + } + } + if (object.sourceFile !== undefined && object.sourceFile !== null) { + message.sourceFile = object.sourceFile; + } else { + message.sourceFile = ""; + } + if (object.begin !== undefined && object.begin !== null) { + message.begin = object.begin; + } else { + message.begin = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/bze.epochs.v1/index.ts b/ts-client/bze.epochs.v1/index.ts new file mode 100755 index 00000000..c9dfa159 --- /dev/null +++ b/ts-client/bze.epochs.v1/index.ts @@ -0,0 +1,6 @@ +import Module from './module'; +import { txClient, queryClient, registry } from './module'; +import { msgTypes } from './registry'; + +export * from "./types"; +export { Module, msgTypes, txClient, queryClient, registry }; diff --git a/ts-client/bze.epochs.v1/module.ts b/ts-client/bze.epochs.v1/module.ts new file mode 100755 index 00000000..78768d4c --- /dev/null +++ b/ts-client/bze.epochs.v1/module.ts @@ -0,0 +1,66 @@ +// Generated by Ignite ignite.com/cli + +import { StdFee } from "@cosmjs/launchpad"; +import { SigningStargateClient, DeliverTxResponse } from "@cosmjs/stargate"; +import { EncodeObject, GeneratedType, OfflineSigner, Registry } from "@cosmjs/proto-signing"; +import { msgTypes } from './registry'; +import { IgniteClient } from "../client" +import { MissingWalletError } from "../helpers" +import { Api } from "./rest"; + + +export { }; + + + +export const registry = new Registry(msgTypes); + +const defaultFee = { + amount: [], + gas: "200000", +}; + +interface TxClientOptions { + addr: string + prefix: string + signer?: OfflineSigner +} + +export const txClient = ({ signer, prefix, addr }: TxClientOptions = { addr: "http://localhost:26657", prefix: "cosmos" }) => { + + return { + + + } +}; + +interface QueryClientOptions { + addr: string +} + +export const queryClient = ({ addr: addr }: QueryClientOptions = { addr: "http://localhost:1317" }) => { + return new Api({ baseUrl: addr }); +}; + +class SDKModule { + public query: ReturnType; + public tx: ReturnType; + + public registry: Array<[string, GeneratedType]>; + + constructor(client: IgniteClient) { + + this.query = queryClient({ addr: client.env.apiURL }); + this.tx = txClient({ signer: client.signer, addr: client.env.rpcURL, prefix: client.env.prefix ?? "cosmos" }); + } +}; + +const Module = (test: IgniteClient) => { + return { + module: { + BzeEpochsV1: new SDKModule(test) + }, + registry: msgTypes + } +} +export default Module; \ No newline at end of file diff --git a/ts-client/bze.epochs.v1/registry.ts b/ts-client/bze.epochs.v1/registry.ts new file mode 100755 index 00000000..26157e4f --- /dev/null +++ b/ts-client/bze.epochs.v1/registry.ts @@ -0,0 +1,7 @@ +import { GeneratedType } from "@cosmjs/proto-signing"; + +const msgTypes: Array<[string, GeneratedType]> = [ + +]; + +export { msgTypes } \ No newline at end of file diff --git a/ts-client/bze.epochs.v1/rest.ts b/ts-client/bze.epochs.v1/rest.ts new file mode 100644 index 00000000..d870243d --- /dev/null +++ b/ts-client/bze.epochs.v1/rest.ts @@ -0,0 +1,325 @@ +/* eslint-disable */ +/* tslint:disable */ +/* + * --------------------------------------------------------------- + * ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ## + * ## ## + * ## AUTHOR: acacode ## + * ## SOURCE: https://github.com/acacode/swagger-typescript-api ## + * --------------------------------------------------------------- + */ + +export interface ProtobufAny { + "@type"?: string; +} + +export interface RpcStatus { + /** @format int32 */ + code?: number; + message?: string; + details?: ProtobufAny[]; +} + +/** +* EpochInfo is a struct that describes the data going into +a timer defined by the x/epochs module. +*/ +export interface V1EpochInfo { + /** identifier is a unique reference to this particular timer. */ + identifier?: string; + + /** + * start_time is the time at which the timer first ever ticks. + * If start_time is in the future, the epoch will not begin until the start + * time. + * @format date-time + */ + start_time?: string; + + /** + * duration is the time in between epoch ticks. + * In order for intended behavior to be met, duration should + * be greater than the chains expected block time. + * Duration must be non-zero. + */ + duration?: string; + + /** + * current_epoch is the current epoch number, or in other words, + * how many times has the timer 'ticked'. + * The first tick (current_epoch=1) is defined as + * the first block whose blocktime is greater than the EpochInfo start_time. + * @format int64 + */ + current_epoch?: string; + + /** + * current_epoch_start_time describes the start time of the current timer + * interval. The interval is (current_epoch_start_time, + * current_epoch_start_time + duration] When the timer ticks, this is set to + * current_epoch_start_time = last_epoch_start_time + duration only one timer + * tick for a given identifier can occur per block. + * + * NOTE! The current_epoch_start_time may diverge significantly from the + * wall-clock time the epoch began at. Wall-clock time of epoch start may be + * >> current_epoch_start_time. Suppose current_epoch_start_time = 10, + * duration = 5. Suppose the chain goes offline at t=14, and comes back online + * at t=30, and produces blocks at every successive time. (t=31, 32, etc.) + * * The t=30 block will start the epoch for (10, 15] + * * The t=31 block will start the epoch for (15, 20] + * * The t=32 block will start the epoch for (20, 25] + * * The t=33 block will start the epoch for (25, 30] + * * The t=34 block will start the epoch for (30, 35] + * * The **t=36** block will start the epoch for (35, 40] + * @format date-time + */ + current_epoch_start_time?: string; + + /** + * epoch_counting_started is a boolean, that indicates whether this + * epoch timer has began yet. + */ + epoch_counting_started?: boolean; + + /** @format int64 */ + current_epoch_start_height?: string; +} + +export interface V1QueryCurrentEpochResponse { + /** @format int64 */ + current_epoch?: string; +} + +export interface V1QueryEpochsInfoResponse { + epochs?: V1EpochInfo[]; +} + +export type QueryParamsType = Record; +export type ResponseFormat = keyof Omit; + +export interface FullRequestParams extends Omit { + /** set parameter to `true` for call `securityWorker` for this request */ + secure?: boolean; + /** request path */ + path: string; + /** content type of request body */ + type?: ContentType; + /** query params */ + query?: QueryParamsType; + /** format of response (i.e. response.json() -> format: "json") */ + format?: keyof Omit; + /** request body */ + body?: unknown; + /** base url */ + baseUrl?: string; + /** request cancellation token */ + cancelToken?: CancelToken; +} + +export type RequestParams = Omit; + +export interface ApiConfig { + baseUrl?: string; + baseApiParams?: Omit; + securityWorker?: (securityData: SecurityDataType) => RequestParams | void; +} + +export interface HttpResponse extends Response { + data: D; + error: E; +} + +type CancelToken = Symbol | string | number; + +export enum ContentType { + Json = "application/json", + FormData = "multipart/form-data", + UrlEncoded = "application/x-www-form-urlencoded", +} + +export class HttpClient { + public baseUrl: string = ""; + private securityData: SecurityDataType = null as any; + private securityWorker: null | ApiConfig["securityWorker"] = null; + private abortControllers = new Map(); + + private baseApiParams: RequestParams = { + credentials: "same-origin", + headers: {}, + redirect: "follow", + referrerPolicy: "no-referrer", + }; + + constructor(apiConfig: ApiConfig = {}) { + Object.assign(this, apiConfig); + } + + public setSecurityData = (data: SecurityDataType) => { + this.securityData = data; + }; + + private addQueryParam(query: QueryParamsType, key: string) { + const value = query[key]; + + return ( + encodeURIComponent(key) + + "=" + + encodeURIComponent(Array.isArray(value) ? value.join(",") : typeof value === "number" ? value : `${value}`) + ); + } + + protected toQueryString(rawQuery?: QueryParamsType): string { + const query = rawQuery || {}; + const keys = Object.keys(query).filter((key) => "undefined" !== typeof query[key]); + return keys + .map((key) => + typeof query[key] === "object" && !Array.isArray(query[key]) + ? this.toQueryString(query[key] as QueryParamsType) + : this.addQueryParam(query, key), + ) + .join("&"); + } + + protected addQueryParams(rawQuery?: QueryParamsType): string { + const queryString = this.toQueryString(rawQuery); + return queryString ? `?${queryString}` : ""; + } + + private contentFormatters: Record any> = { + [ContentType.Json]: (input: any) => + input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input, + [ContentType.FormData]: (input: any) => + Object.keys(input || {}).reduce((data, key) => { + data.append(key, input[key]); + return data; + }, new FormData()), + [ContentType.UrlEncoded]: (input: any) => this.toQueryString(input), + }; + + private mergeRequestParams(params1: RequestParams, params2?: RequestParams): RequestParams { + return { + ...this.baseApiParams, + ...params1, + ...(params2 || {}), + headers: { + ...(this.baseApiParams.headers || {}), + ...(params1.headers || {}), + ...((params2 && params2.headers) || {}), + }, + }; + } + + private createAbortSignal = (cancelToken: CancelToken): AbortSignal | undefined => { + if (this.abortControllers.has(cancelToken)) { + const abortController = this.abortControllers.get(cancelToken); + if (abortController) { + return abortController.signal; + } + return void 0; + } + + const abortController = new AbortController(); + this.abortControllers.set(cancelToken, abortController); + return abortController.signal; + }; + + public abortRequest = (cancelToken: CancelToken) => { + const abortController = this.abortControllers.get(cancelToken); + + if (abortController) { + abortController.abort(); + this.abortControllers.delete(cancelToken); + } + }; + + public request = ({ + body, + secure, + path, + type, + query, + format = "json", + baseUrl, + cancelToken, + ...params + }: FullRequestParams): Promise> => { + const secureParams = (secure && this.securityWorker && this.securityWorker(this.securityData)) || {}; + const requestParams = this.mergeRequestParams(params, secureParams); + const queryString = query && this.toQueryString(query); + const payloadFormatter = this.contentFormatters[type || ContentType.Json]; + + return fetch(`${baseUrl || this.baseUrl || ""}${path}${queryString ? `?${queryString}` : ""}`, { + ...requestParams, + headers: { + ...(type && type !== ContentType.FormData ? { "Content-Type": type } : {}), + ...(requestParams.headers || {}), + }, + signal: cancelToken ? this.createAbortSignal(cancelToken) : void 0, + body: typeof body === "undefined" || body === null ? null : payloadFormatter(body), + }).then(async (response) => { + const r = response as HttpResponse; + r.data = (null as unknown) as T; + r.error = (null as unknown) as E; + + const data = await response[format]() + .then((data) => { + if (r.ok) { + r.data = data; + } else { + r.error = data; + } + return r; + }) + .catch((e) => { + r.error = e; + return r; + }); + + if (cancelToken) { + this.abortControllers.delete(cancelToken); + } + + if (!response.ok) throw data; + return data; + }); + }; +} + +/** + * @title epochs/events.proto + * @version version not set + */ +export class Api extends HttpClient { + /** + * No description + * + * @tags Query + * @name QueryCurrentEpoch + * @summary CurrentEpoch provide current epoch of specified identifier + * @request GET:/bze/epochs/v1/current_epoch + */ + queryCurrentEpoch = (query?: { identifier?: string }, params: RequestParams = {}) => + this.request({ + path: `/bze/epochs/v1/current_epoch`, + method: "GET", + query: query, + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Query + * @name QueryEpochInfos + * @summary EpochInfos provide running epochInfos + * @request GET:/bze/epochs/v1/epochs + */ + queryEpochInfos = (params: RequestParams = {}) => + this.request({ + path: `/bze/epochs/v1/epochs`, + method: "GET", + format: "json", + ...params, + }); +} diff --git a/ts-client/bze.epochs.v1/types.ts b/ts-client/bze.epochs.v1/types.ts new file mode 100755 index 00000000..3afc3e0d --- /dev/null +++ b/ts-client/bze.epochs.v1/types.ts @@ -0,0 +1,11 @@ +import { EpochStartEvent } from "./types/epochs/events" +import { EpochEndEvent } from "./types/epochs/events" +import { EpochInfo } from "./types/epochs/genesis" + + +export { + EpochStartEvent, + EpochEndEvent, + EpochInfo, + + } \ No newline at end of file diff --git a/ts-client/bze.epochs.v1/types/epochs/events.ts b/ts-client/bze.epochs.v1/types/epochs/events.ts new file mode 100644 index 00000000..2a5a4b3a --- /dev/null +++ b/ts-client/bze.epochs.v1/types/epochs/events.ts @@ -0,0 +1,169 @@ +/* eslint-disable */ +import { Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "bze.epochs.v1"; + +export interface EpochStartEvent { + identifier: string; + epoch: string; +} + +export interface EpochEndEvent { + identifier: string; + epoch: string; +} + +const baseEpochStartEvent: object = { identifier: "", epoch: "" }; + +export const EpochStartEvent = { + encode(message: EpochStartEvent, writer: Writer = Writer.create()): Writer { + if (message.identifier !== "") { + writer.uint32(10).string(message.identifier); + } + if (message.epoch !== "") { + writer.uint32(18).string(message.epoch); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): EpochStartEvent { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseEpochStartEvent } as EpochStartEvent; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.identifier = reader.string(); + break; + case 2: + message.epoch = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EpochStartEvent { + const message = { ...baseEpochStartEvent } as EpochStartEvent; + if (object.identifier !== undefined && object.identifier !== null) { + message.identifier = String(object.identifier); + } else { + message.identifier = ""; + } + if (object.epoch !== undefined && object.epoch !== null) { + message.epoch = String(object.epoch); + } else { + message.epoch = ""; + } + return message; + }, + + toJSON(message: EpochStartEvent): unknown { + const obj: any = {}; + message.identifier !== undefined && (obj.identifier = message.identifier); + message.epoch !== undefined && (obj.epoch = message.epoch); + return obj; + }, + + fromPartial(object: DeepPartial): EpochStartEvent { + const message = { ...baseEpochStartEvent } as EpochStartEvent; + if (object.identifier !== undefined && object.identifier !== null) { + message.identifier = object.identifier; + } else { + message.identifier = ""; + } + if (object.epoch !== undefined && object.epoch !== null) { + message.epoch = object.epoch; + } else { + message.epoch = ""; + } + return message; + }, +}; + +const baseEpochEndEvent: object = { identifier: "", epoch: "" }; + +export const EpochEndEvent = { + encode(message: EpochEndEvent, writer: Writer = Writer.create()): Writer { + if (message.identifier !== "") { + writer.uint32(10).string(message.identifier); + } + if (message.epoch !== "") { + writer.uint32(18).string(message.epoch); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): EpochEndEvent { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseEpochEndEvent } as EpochEndEvent; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.identifier = reader.string(); + break; + case 2: + message.epoch = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EpochEndEvent { + const message = { ...baseEpochEndEvent } as EpochEndEvent; + if (object.identifier !== undefined && object.identifier !== null) { + message.identifier = String(object.identifier); + } else { + message.identifier = ""; + } + if (object.epoch !== undefined && object.epoch !== null) { + message.epoch = String(object.epoch); + } else { + message.epoch = ""; + } + return message; + }, + + toJSON(message: EpochEndEvent): unknown { + const obj: any = {}; + message.identifier !== undefined && (obj.identifier = message.identifier); + message.epoch !== undefined && (obj.epoch = message.epoch); + return obj; + }, + + fromPartial(object: DeepPartial): EpochEndEvent { + const message = { ...baseEpochEndEvent } as EpochEndEvent; + if (object.identifier !== undefined && object.identifier !== null) { + message.identifier = object.identifier; + } else { + message.identifier = ""; + } + if (object.epoch !== undefined && object.epoch !== null) { + message.epoch = object.epoch; + } else { + message.epoch = ""; + } + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/bze.epochs.v1/types/epochs/genesis.ts b/ts-client/bze.epochs.v1/types/epochs/genesis.ts new file mode 100644 index 00000000..832ac665 --- /dev/null +++ b/ts-client/bze.epochs.v1/types/epochs/genesis.ts @@ -0,0 +1,398 @@ +/* eslint-disable */ +import { Timestamp } from "../google/protobuf/timestamp"; +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; +import { Duration } from "../google/protobuf/duration"; + +export const protobufPackage = "bze.epochs.v1"; + +/** + * EpochInfo is a struct that describes the data going into + * a timer defined by the x/epochs module. + */ +export interface EpochInfo { + /** identifier is a unique reference to this particular timer. */ + identifier: string; + /** + * start_time is the time at which the timer first ever ticks. + * If start_time is in the future, the epoch will not begin until the start + * time. + */ + startTime: Date | undefined; + /** + * duration is the time in between epoch ticks. + * In order for intended behavior to be met, duration should + * be greater than the chains expected block time. + * Duration must be non-zero. + */ + duration: Duration | undefined; + /** + * current_epoch is the current epoch number, or in other words, + * how many times has the timer 'ticked'. + * The first tick (current_epoch=1) is defined as + * the first block whose blocktime is greater than the EpochInfo start_time. + */ + currentEpoch: number; + /** + * current_epoch_start_time describes the start time of the current timer + * interval. The interval is (current_epoch_start_time, + * current_epoch_start_time + duration] When the timer ticks, this is set to + * current_epoch_start_time = last_epoch_start_time + duration only one timer + * tick for a given identifier can occur per block. + * + * NOTE! The current_epoch_start_time may diverge significantly from the + * wall-clock time the epoch began at. Wall-clock time of epoch start may be + * >> current_epoch_start_time. Suppose current_epoch_start_time = 10, + * duration = 5. Suppose the chain goes offline at t=14, and comes back online + * at t=30, and produces blocks at every successive time. (t=31, 32, etc.) + * * The t=30 block will start the epoch for (10, 15] + * * The t=31 block will start the epoch for (15, 20] + * * The t=32 block will start the epoch for (20, 25] + * * The t=33 block will start the epoch for (25, 30] + * * The t=34 block will start the epoch for (30, 35] + * * The **t=36** block will start the epoch for (35, 40] + */ + currentEpochStartTime: Date | undefined; + /** + * epoch_counting_started is a boolean, that indicates whether this + * epoch timer has began yet. + */ + epochCountingStarted: boolean; + /** + * current_epoch_start_height is the block height at which the current epoch + * started. (The block height at which the timer last ticked) + */ + currentEpochStartHeight: number; +} + +/** GenesisState defines the epochs module's genesis state. */ +export interface GenesisState { + epochs: EpochInfo[]; +} + +const baseEpochInfo: object = { + identifier: "", + currentEpoch: 0, + epochCountingStarted: false, + currentEpochStartHeight: 0, +}; + +export const EpochInfo = { + encode(message: EpochInfo, writer: Writer = Writer.create()): Writer { + if (message.identifier !== "") { + writer.uint32(10).string(message.identifier); + } + if (message.startTime !== undefined) { + Timestamp.encode( + toTimestamp(message.startTime), + writer.uint32(18).fork() + ).ldelim(); + } + if (message.duration !== undefined) { + Duration.encode(message.duration, writer.uint32(26).fork()).ldelim(); + } + if (message.currentEpoch !== 0) { + writer.uint32(32).int64(message.currentEpoch); + } + if (message.currentEpochStartTime !== undefined) { + Timestamp.encode( + toTimestamp(message.currentEpochStartTime), + writer.uint32(42).fork() + ).ldelim(); + } + if (message.epochCountingStarted === true) { + writer.uint32(48).bool(message.epochCountingStarted); + } + if (message.currentEpochStartHeight !== 0) { + writer.uint32(64).int64(message.currentEpochStartHeight); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): EpochInfo { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseEpochInfo } as EpochInfo; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.identifier = reader.string(); + break; + case 2: + message.startTime = fromTimestamp( + Timestamp.decode(reader, reader.uint32()) + ); + break; + case 3: + message.duration = Duration.decode(reader, reader.uint32()); + break; + case 4: + message.currentEpoch = longToNumber(reader.int64() as Long); + break; + case 5: + message.currentEpochStartTime = fromTimestamp( + Timestamp.decode(reader, reader.uint32()) + ); + break; + case 6: + message.epochCountingStarted = reader.bool(); + break; + case 8: + message.currentEpochStartHeight = longToNumber( + reader.int64() as Long + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EpochInfo { + const message = { ...baseEpochInfo } as EpochInfo; + if (object.identifier !== undefined && object.identifier !== null) { + message.identifier = String(object.identifier); + } else { + message.identifier = ""; + } + if (object.startTime !== undefined && object.startTime !== null) { + message.startTime = fromJsonTimestamp(object.startTime); + } else { + message.startTime = undefined; + } + if (object.duration !== undefined && object.duration !== null) { + message.duration = Duration.fromJSON(object.duration); + } else { + message.duration = undefined; + } + if (object.currentEpoch !== undefined && object.currentEpoch !== null) { + message.currentEpoch = Number(object.currentEpoch); + } else { + message.currentEpoch = 0; + } + if ( + object.currentEpochStartTime !== undefined && + object.currentEpochStartTime !== null + ) { + message.currentEpochStartTime = fromJsonTimestamp( + object.currentEpochStartTime + ); + } else { + message.currentEpochStartTime = undefined; + } + if ( + object.epochCountingStarted !== undefined && + object.epochCountingStarted !== null + ) { + message.epochCountingStarted = Boolean(object.epochCountingStarted); + } else { + message.epochCountingStarted = false; + } + if ( + object.currentEpochStartHeight !== undefined && + object.currentEpochStartHeight !== null + ) { + message.currentEpochStartHeight = Number(object.currentEpochStartHeight); + } else { + message.currentEpochStartHeight = 0; + } + return message; + }, + + toJSON(message: EpochInfo): unknown { + const obj: any = {}; + message.identifier !== undefined && (obj.identifier = message.identifier); + message.startTime !== undefined && + (obj.startTime = + message.startTime !== undefined + ? message.startTime.toISOString() + : null); + message.duration !== undefined && + (obj.duration = message.duration + ? Duration.toJSON(message.duration) + : undefined); + message.currentEpoch !== undefined && + (obj.currentEpoch = message.currentEpoch); + message.currentEpochStartTime !== undefined && + (obj.currentEpochStartTime = + message.currentEpochStartTime !== undefined + ? message.currentEpochStartTime.toISOString() + : null); + message.epochCountingStarted !== undefined && + (obj.epochCountingStarted = message.epochCountingStarted); + message.currentEpochStartHeight !== undefined && + (obj.currentEpochStartHeight = message.currentEpochStartHeight); + return obj; + }, + + fromPartial(object: DeepPartial): EpochInfo { + const message = { ...baseEpochInfo } as EpochInfo; + if (object.identifier !== undefined && object.identifier !== null) { + message.identifier = object.identifier; + } else { + message.identifier = ""; + } + if (object.startTime !== undefined && object.startTime !== null) { + message.startTime = object.startTime; + } else { + message.startTime = undefined; + } + if (object.duration !== undefined && object.duration !== null) { + message.duration = Duration.fromPartial(object.duration); + } else { + message.duration = undefined; + } + if (object.currentEpoch !== undefined && object.currentEpoch !== null) { + message.currentEpoch = object.currentEpoch; + } else { + message.currentEpoch = 0; + } + if ( + object.currentEpochStartTime !== undefined && + object.currentEpochStartTime !== null + ) { + message.currentEpochStartTime = object.currentEpochStartTime; + } else { + message.currentEpochStartTime = undefined; + } + if ( + object.epochCountingStarted !== undefined && + object.epochCountingStarted !== null + ) { + message.epochCountingStarted = object.epochCountingStarted; + } else { + message.epochCountingStarted = false; + } + if ( + object.currentEpochStartHeight !== undefined && + object.currentEpochStartHeight !== null + ) { + message.currentEpochStartHeight = object.currentEpochStartHeight; + } else { + message.currentEpochStartHeight = 0; + } + return message; + }, +}; + +const baseGenesisState: object = {}; + +export const GenesisState = { + encode(message: GenesisState, writer: Writer = Writer.create()): Writer { + for (const v of message.epochs) { + EpochInfo.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): GenesisState { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseGenesisState } as GenesisState; + message.epochs = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.epochs.push(EpochInfo.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GenesisState { + const message = { ...baseGenesisState } as GenesisState; + message.epochs = []; + if (object.epochs !== undefined && object.epochs !== null) { + for (const e of object.epochs) { + message.epochs.push(EpochInfo.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: GenesisState): unknown { + const obj: any = {}; + if (message.epochs) { + obj.epochs = message.epochs.map((e) => + e ? EpochInfo.toJSON(e) : undefined + ); + } else { + obj.epochs = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): GenesisState { + const message = { ...baseGenesisState } as GenesisState; + message.epochs = []; + if (object.epochs !== undefined && object.epochs !== null) { + for (const e of object.epochs) { + message.epochs.push(EpochInfo.fromPartial(e)); + } + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function toTimestamp(date: Date): Timestamp { + const seconds = date.getTime() / 1_000; + const nanos = (date.getTime() % 1_000) * 1_000_000; + return { seconds, nanos }; +} + +function fromTimestamp(t: Timestamp): Date { + let millis = t.seconds * 1_000; + millis += t.nanos / 1_000_000; + return new Date(millis); +} + +function fromJsonTimestamp(o: any): Date { + if (o instanceof Date) { + return o; + } else if (typeof o === "string") { + return new Date(o); + } else { + return fromTimestamp(Timestamp.fromJSON(o)); + } +} + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/bze.epochs.v1/types/epochs/query.ts b/ts-client/bze.epochs.v1/types/epochs/query.ts new file mode 100644 index 00000000..ed7d9f60 --- /dev/null +++ b/ts-client/bze.epochs.v1/types/epochs/query.ts @@ -0,0 +1,353 @@ +/* eslint-disable */ +import { Reader, util, configure, Writer } from "protobufjs/minimal"; +import * as Long from "long"; +import { EpochInfo } from "../epochs/genesis"; + +export const protobufPackage = "bze.epochs.v1"; + +export interface QueryEpochsInfoRequest {} + +export interface QueryEpochsInfoResponse { + epochs: EpochInfo[]; +} + +export interface QueryCurrentEpochRequest { + identifier: string; +} + +export interface QueryCurrentEpochResponse { + currentEpoch: number; +} + +const baseQueryEpochsInfoRequest: object = {}; + +export const QueryEpochsInfoRequest = { + encode(_: QueryEpochsInfoRequest, writer: Writer = Writer.create()): Writer { + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QueryEpochsInfoRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryEpochsInfoRequest } as QueryEpochsInfoRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): QueryEpochsInfoRequest { + const message = { ...baseQueryEpochsInfoRequest } as QueryEpochsInfoRequest; + return message; + }, + + toJSON(_: QueryEpochsInfoRequest): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial(_: DeepPartial): QueryEpochsInfoRequest { + const message = { ...baseQueryEpochsInfoRequest } as QueryEpochsInfoRequest; + return message; + }, +}; + +const baseQueryEpochsInfoResponse: object = {}; + +export const QueryEpochsInfoResponse = { + encode( + message: QueryEpochsInfoResponse, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.epochs) { + EpochInfo.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QueryEpochsInfoResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryEpochsInfoResponse, + } as QueryEpochsInfoResponse; + message.epochs = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.epochs.push(EpochInfo.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryEpochsInfoResponse { + const message = { + ...baseQueryEpochsInfoResponse, + } as QueryEpochsInfoResponse; + message.epochs = []; + if (object.epochs !== undefined && object.epochs !== null) { + for (const e of object.epochs) { + message.epochs.push(EpochInfo.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: QueryEpochsInfoResponse): unknown { + const obj: any = {}; + if (message.epochs) { + obj.epochs = message.epochs.map((e) => + e ? EpochInfo.toJSON(e) : undefined + ); + } else { + obj.epochs = []; + } + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryEpochsInfoResponse { + const message = { + ...baseQueryEpochsInfoResponse, + } as QueryEpochsInfoResponse; + message.epochs = []; + if (object.epochs !== undefined && object.epochs !== null) { + for (const e of object.epochs) { + message.epochs.push(EpochInfo.fromPartial(e)); + } + } + return message; + }, +}; + +const baseQueryCurrentEpochRequest: object = { identifier: "" }; + +export const QueryCurrentEpochRequest = { + encode( + message: QueryCurrentEpochRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.identifier !== "") { + writer.uint32(10).string(message.identifier); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryCurrentEpochRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryCurrentEpochRequest, + } as QueryCurrentEpochRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.identifier = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryCurrentEpochRequest { + const message = { + ...baseQueryCurrentEpochRequest, + } as QueryCurrentEpochRequest; + if (object.identifier !== undefined && object.identifier !== null) { + message.identifier = String(object.identifier); + } else { + message.identifier = ""; + } + return message; + }, + + toJSON(message: QueryCurrentEpochRequest): unknown { + const obj: any = {}; + message.identifier !== undefined && (obj.identifier = message.identifier); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryCurrentEpochRequest { + const message = { + ...baseQueryCurrentEpochRequest, + } as QueryCurrentEpochRequest; + if (object.identifier !== undefined && object.identifier !== null) { + message.identifier = object.identifier; + } else { + message.identifier = ""; + } + return message; + }, +}; + +const baseQueryCurrentEpochResponse: object = { currentEpoch: 0 }; + +export const QueryCurrentEpochResponse = { + encode( + message: QueryCurrentEpochResponse, + writer: Writer = Writer.create() + ): Writer { + if (message.currentEpoch !== 0) { + writer.uint32(8).int64(message.currentEpoch); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryCurrentEpochResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryCurrentEpochResponse, + } as QueryCurrentEpochResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.currentEpoch = longToNumber(reader.int64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryCurrentEpochResponse { + const message = { + ...baseQueryCurrentEpochResponse, + } as QueryCurrentEpochResponse; + if (object.currentEpoch !== undefined && object.currentEpoch !== null) { + message.currentEpoch = Number(object.currentEpoch); + } else { + message.currentEpoch = 0; + } + return message; + }, + + toJSON(message: QueryCurrentEpochResponse): unknown { + const obj: any = {}; + message.currentEpoch !== undefined && + (obj.currentEpoch = message.currentEpoch); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryCurrentEpochResponse { + const message = { + ...baseQueryCurrentEpochResponse, + } as QueryCurrentEpochResponse; + if (object.currentEpoch !== undefined && object.currentEpoch !== null) { + message.currentEpoch = object.currentEpoch; + } else { + message.currentEpoch = 0; + } + return message; + }, +}; + +/** Query defines the gRPC querier service. */ +export interface Query { + /** EpochInfos provide running epochInfos */ + EpochInfos(request: QueryEpochsInfoRequest): Promise; + /** CurrentEpoch provide current epoch of specified identifier */ + CurrentEpoch( + request: QueryCurrentEpochRequest + ): Promise; +} + +export class QueryClientImpl implements Query { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + } + EpochInfos( + request: QueryEpochsInfoRequest + ): Promise { + const data = QueryEpochsInfoRequest.encode(request).finish(); + const promise = this.rpc.request("bze.epochs.v1.Query", "EpochInfos", data); + return promise.then((data) => + QueryEpochsInfoResponse.decode(new Reader(data)) + ); + } + + CurrentEpoch( + request: QueryCurrentEpochRequest + ): Promise { + const data = QueryCurrentEpochRequest.encode(request).finish(); + const promise = this.rpc.request( + "bze.epochs.v1.Query", + "CurrentEpoch", + data + ); + return promise.then((data) => + QueryCurrentEpochResponse.decode(new Reader(data)) + ); + } +} + +interface Rpc { + request( + service: string, + method: string, + data: Uint8Array + ): Promise; +} + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/bze.epochs.v1/types/gogoproto/gogo.ts b/ts-client/bze.epochs.v1/types/gogoproto/gogo.ts new file mode 100644 index 00000000..3f41a047 --- /dev/null +++ b/ts-client/bze.epochs.v1/types/gogoproto/gogo.ts @@ -0,0 +1,2 @@ +/* eslint-disable */ +export const protobufPackage = "gogoproto"; diff --git a/ts-client/bze.epochs.v1/types/google/api/annotations.ts b/ts-client/bze.epochs.v1/types/google/api/annotations.ts new file mode 100644 index 00000000..aace4787 --- /dev/null +++ b/ts-client/bze.epochs.v1/types/google/api/annotations.ts @@ -0,0 +1,2 @@ +/* eslint-disable */ +export const protobufPackage = "google.api"; diff --git a/ts-client/bze.epochs.v1/types/google/api/http.ts b/ts-client/bze.epochs.v1/types/google/api/http.ts new file mode 100644 index 00000000..ddc00f8b --- /dev/null +++ b/ts-client/bze.epochs.v1/types/google/api/http.ts @@ -0,0 +1,705 @@ +/* eslint-disable */ +import { Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "google.api"; + +/** + * Defines the HTTP configuration for an API service. It contains a list of + * [HttpRule][google.api.HttpRule], each specifying the mapping of an RPC method + * to one or more HTTP REST API methods. + */ +export interface Http { + /** + * A list of HTTP configuration rules that apply to individual API methods. + * + * **NOTE:** All service configuration rules follow "last one wins" order. + */ + rules: HttpRule[]; + /** + * When set to true, URL path parmeters will be fully URI-decoded except in + * cases of single segment matches in reserved expansion, where "%2F" will be + * left encoded. + * + * The default behavior is to not decode RFC 6570 reserved characters in multi + * segment matches. + */ + fullyDecodeReservedExpansion: boolean; +} + +/** + * `HttpRule` defines the mapping of an RPC method to one or more HTTP + * REST API methods. The mapping specifies how different portions of the RPC + * request message are mapped to URL path, URL query parameters, and + * HTTP request body. The mapping is typically specified as an + * `google.api.http` annotation on the RPC method, + * see "google/api/annotations.proto" for details. + * + * The mapping consists of a field specifying the path template and + * method kind. The path template can refer to fields in the request + * message, as in the example below which describes a REST GET + * operation on a resource collection of messages: + * + * + * service Messaging { + * rpc GetMessage(GetMessageRequest) returns (Message) { + * option (google.api.http).get = "/v1/messages/{message_id}/{sub.subfield}"; + * } + * } + * message GetMessageRequest { + * message SubMessage { + * string subfield = 1; + * } + * string message_id = 1; // mapped to the URL + * SubMessage sub = 2; // `sub.subfield` is url-mapped + * } + * message Message { + * string text = 1; // content of the resource + * } + * + * The same http annotation can alternatively be expressed inside the + * `GRPC API Configuration` YAML file. + * + * http: + * rules: + * - selector: .Messaging.GetMessage + * get: /v1/messages/{message_id}/{sub.subfield} + * + * This definition enables an automatic, bidrectional mapping of HTTP + * JSON to RPC. Example: + * + * HTTP | RPC + * -----|----- + * `GET /v1/messages/123456/foo` | `GetMessage(message_id: "123456" sub: SubMessage(subfield: "foo"))` + * + * In general, not only fields but also field paths can be referenced + * from a path pattern. Fields mapped to the path pattern cannot be + * repeated and must have a primitive (non-message) type. + * + * Any fields in the request message which are not bound by the path + * pattern automatically become (optional) HTTP query + * parameters. Assume the following definition of the request message: + * + * + * service Messaging { + * rpc GetMessage(GetMessageRequest) returns (Message) { + * option (google.api.http).get = "/v1/messages/{message_id}"; + * } + * } + * message GetMessageRequest { + * message SubMessage { + * string subfield = 1; + * } + * string message_id = 1; // mapped to the URL + * int64 revision = 2; // becomes a parameter + * SubMessage sub = 3; // `sub.subfield` becomes a parameter + * } + * + * + * This enables a HTTP JSON to RPC mapping as below: + * + * HTTP | RPC + * -----|----- + * `GET /v1/messages/123456?revision=2&sub.subfield=foo` | `GetMessage(message_id: "123456" revision: 2 sub: SubMessage(subfield: "foo"))` + * + * Note that fields which are mapped to HTTP parameters must have a + * primitive type or a repeated primitive type. Message types are not + * allowed. In the case of a repeated type, the parameter can be + * repeated in the URL, as in `...?param=A¶m=B`. + * + * For HTTP method kinds which allow a request body, the `body` field + * specifies the mapping. Consider a REST update method on the + * message resource collection: + * + * + * service Messaging { + * rpc UpdateMessage(UpdateMessageRequest) returns (Message) { + * option (google.api.http) = { + * put: "/v1/messages/{message_id}" + * body: "message" + * }; + * } + * } + * message UpdateMessageRequest { + * string message_id = 1; // mapped to the URL + * Message message = 2; // mapped to the body + * } + * + * + * The following HTTP JSON to RPC mapping is enabled, where the + * representation of the JSON in the request body is determined by + * protos JSON encoding: + * + * HTTP | RPC + * -----|----- + * `PUT /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: "123456" message { text: "Hi!" })` + * + * The special name `*` can be used in the body mapping to define that + * every field not bound by the path template should be mapped to the + * request body. This enables the following alternative definition of + * the update method: + * + * service Messaging { + * rpc UpdateMessage(Message) returns (Message) { + * option (google.api.http) = { + * put: "/v1/messages/{message_id}" + * body: "*" + * }; + * } + * } + * message Message { + * string message_id = 1; + * string text = 2; + * } + * + * + * The following HTTP JSON to RPC mapping is enabled: + * + * HTTP | RPC + * -----|----- + * `PUT /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: "123456" text: "Hi!")` + * + * Note that when using `*` in the body mapping, it is not possible to + * have HTTP parameters, as all fields not bound by the path end in + * the body. This makes this option more rarely used in practice of + * defining REST APIs. The common usage of `*` is in custom methods + * which don't use the URL at all for transferring data. + * + * It is possible to define multiple HTTP methods for one RPC by using + * the `additional_bindings` option. Example: + * + * service Messaging { + * rpc GetMessage(GetMessageRequest) returns (Message) { + * option (google.api.http) = { + * get: "/v1/messages/{message_id}" + * additional_bindings { + * get: "/v1/users/{user_id}/messages/{message_id}" + * } + * }; + * } + * } + * message GetMessageRequest { + * string message_id = 1; + * string user_id = 2; + * } + * + * + * This enables the following two alternative HTTP JSON to RPC + * mappings: + * + * HTTP | RPC + * -----|----- + * `GET /v1/messages/123456` | `GetMessage(message_id: "123456")` + * `GET /v1/users/me/messages/123456` | `GetMessage(user_id: "me" message_id: "123456")` + * + * # Rules for HTTP mapping + * + * The rules for mapping HTTP path, query parameters, and body fields + * to the request message are as follows: + * + * 1. The `body` field specifies either `*` or a field path, or is + * omitted. If omitted, it indicates there is no HTTP request body. + * 2. Leaf fields (recursive expansion of nested messages in the + * request) can be classified into three types: + * (a) Matched in the URL template. + * (b) Covered by body (if body is `*`, everything except (a) fields; + * else everything under the body field) + * (c) All other fields. + * 3. URL query parameters found in the HTTP request are mapped to (c) fields. + * 4. Any body sent with an HTTP request can contain only (b) fields. + * + * The syntax of the path template is as follows: + * + * Template = "/" Segments [ Verb ] ; + * Segments = Segment { "/" Segment } ; + * Segment = "*" | "**" | LITERAL | Variable ; + * Variable = "{" FieldPath [ "=" Segments ] "}" ; + * FieldPath = IDENT { "." IDENT } ; + * Verb = ":" LITERAL ; + * + * The syntax `*` matches a single path segment. The syntax `**` matches zero + * or more path segments, which must be the last part of the path except the + * `Verb`. The syntax `LITERAL` matches literal text in the path. + * + * The syntax `Variable` matches part of the URL path as specified by its + * template. A variable template must not contain other variables. If a variable + * matches a single path segment, its template may be omitted, e.g. `{var}` + * is equivalent to `{var=*}`. + * + * If a variable contains exactly one path segment, such as `"{var}"` or + * `"{var=*}"`, when such a variable is expanded into a URL path, all characters + * except `[-_.~0-9a-zA-Z]` are percent-encoded. Such variables show up in the + * Discovery Document as `{var}`. + * + * If a variable contains one or more path segments, such as `"{var=foo/*}"` + * or `"{var=**}"`, when such a variable is expanded into a URL path, all + * characters except `[-_.~/0-9a-zA-Z]` are percent-encoded. Such variables + * show up in the Discovery Document as `{+var}`. + * + * NOTE: While the single segment variable matches the semantics of + * [RFC 6570](https://tools.ietf.org/html/rfc6570) Section 3.2.2 + * Simple String Expansion, the multi segment variable **does not** match + * RFC 6570 Reserved Expansion. The reason is that the Reserved Expansion + * does not expand special characters like `?` and `#`, which would lead + * to invalid URLs. + * + * NOTE: the field paths in variables and in the `body` must not refer to + * repeated fields or map fields. + */ +export interface HttpRule { + /** + * Selects methods to which this rule applies. + * + * Refer to [selector][google.api.DocumentationRule.selector] for syntax details. + */ + selector: string; + /** Used for listing and getting information about resources. */ + get: string | undefined; + /** Used for updating a resource. */ + put: string | undefined; + /** Used for creating a resource. */ + post: string | undefined; + /** Used for deleting a resource. */ + delete: string | undefined; + /** Used for updating a resource. */ + patch: string | undefined; + /** + * The custom pattern is used for specifying an HTTP method that is not + * included in the `pattern` field, such as HEAD, or "*" to leave the + * HTTP method unspecified for this rule. The wild-card rule is useful + * for services that provide content to Web (HTML) clients. + */ + custom: CustomHttpPattern | undefined; + /** + * The name of the request field whose value is mapped to the HTTP body, or + * `*` for mapping all fields not captured by the path pattern to the HTTP + * body. NOTE: the referred field must not be a repeated field and must be + * present at the top-level of request message type. + */ + body: string; + /** + * Optional. The name of the response field whose value is mapped to the HTTP + * body of response. Other response fields are ignored. When + * not set, the response message will be used as HTTP body of response. + */ + responseBody: string; + /** + * Additional HTTP bindings for the selector. Nested bindings must + * not contain an `additional_bindings` field themselves (that is, + * the nesting may only be one level deep). + */ + additionalBindings: HttpRule[]; +} + +/** A custom pattern is used for defining custom HTTP verb. */ +export interface CustomHttpPattern { + /** The name of this custom HTTP verb. */ + kind: string; + /** The path matched by this custom verb. */ + path: string; +} + +const baseHttp: object = { fullyDecodeReservedExpansion: false }; + +export const Http = { + encode(message: Http, writer: Writer = Writer.create()): Writer { + for (const v of message.rules) { + HttpRule.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.fullyDecodeReservedExpansion === true) { + writer.uint32(16).bool(message.fullyDecodeReservedExpansion); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Http { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseHttp } as Http; + message.rules = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.rules.push(HttpRule.decode(reader, reader.uint32())); + break; + case 2: + message.fullyDecodeReservedExpansion = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Http { + const message = { ...baseHttp } as Http; + message.rules = []; + if (object.rules !== undefined && object.rules !== null) { + for (const e of object.rules) { + message.rules.push(HttpRule.fromJSON(e)); + } + } + if ( + object.fullyDecodeReservedExpansion !== undefined && + object.fullyDecodeReservedExpansion !== null + ) { + message.fullyDecodeReservedExpansion = Boolean( + object.fullyDecodeReservedExpansion + ); + } else { + message.fullyDecodeReservedExpansion = false; + } + return message; + }, + + toJSON(message: Http): unknown { + const obj: any = {}; + if (message.rules) { + obj.rules = message.rules.map((e) => + e ? HttpRule.toJSON(e) : undefined + ); + } else { + obj.rules = []; + } + message.fullyDecodeReservedExpansion !== undefined && + (obj.fullyDecodeReservedExpansion = message.fullyDecodeReservedExpansion); + return obj; + }, + + fromPartial(object: DeepPartial): Http { + const message = { ...baseHttp } as Http; + message.rules = []; + if (object.rules !== undefined && object.rules !== null) { + for (const e of object.rules) { + message.rules.push(HttpRule.fromPartial(e)); + } + } + if ( + object.fullyDecodeReservedExpansion !== undefined && + object.fullyDecodeReservedExpansion !== null + ) { + message.fullyDecodeReservedExpansion = + object.fullyDecodeReservedExpansion; + } else { + message.fullyDecodeReservedExpansion = false; + } + return message; + }, +}; + +const baseHttpRule: object = { selector: "", body: "", responseBody: "" }; + +export const HttpRule = { + encode(message: HttpRule, writer: Writer = Writer.create()): Writer { + if (message.selector !== "") { + writer.uint32(10).string(message.selector); + } + if (message.get !== undefined) { + writer.uint32(18).string(message.get); + } + if (message.put !== undefined) { + writer.uint32(26).string(message.put); + } + if (message.post !== undefined) { + writer.uint32(34).string(message.post); + } + if (message.delete !== undefined) { + writer.uint32(42).string(message.delete); + } + if (message.patch !== undefined) { + writer.uint32(50).string(message.patch); + } + if (message.custom !== undefined) { + CustomHttpPattern.encode( + message.custom, + writer.uint32(66).fork() + ).ldelim(); + } + if (message.body !== "") { + writer.uint32(58).string(message.body); + } + if (message.responseBody !== "") { + writer.uint32(98).string(message.responseBody); + } + for (const v of message.additionalBindings) { + HttpRule.encode(v!, writer.uint32(90).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): HttpRule { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseHttpRule } as HttpRule; + message.additionalBindings = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.selector = reader.string(); + break; + case 2: + message.get = reader.string(); + break; + case 3: + message.put = reader.string(); + break; + case 4: + message.post = reader.string(); + break; + case 5: + message.delete = reader.string(); + break; + case 6: + message.patch = reader.string(); + break; + case 8: + message.custom = CustomHttpPattern.decode(reader, reader.uint32()); + break; + case 7: + message.body = reader.string(); + break; + case 12: + message.responseBody = reader.string(); + break; + case 11: + message.additionalBindings.push( + HttpRule.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): HttpRule { + const message = { ...baseHttpRule } as HttpRule; + message.additionalBindings = []; + if (object.selector !== undefined && object.selector !== null) { + message.selector = String(object.selector); + } else { + message.selector = ""; + } + if (object.get !== undefined && object.get !== null) { + message.get = String(object.get); + } else { + message.get = undefined; + } + if (object.put !== undefined && object.put !== null) { + message.put = String(object.put); + } else { + message.put = undefined; + } + if (object.post !== undefined && object.post !== null) { + message.post = String(object.post); + } else { + message.post = undefined; + } + if (object.delete !== undefined && object.delete !== null) { + message.delete = String(object.delete); + } else { + message.delete = undefined; + } + if (object.patch !== undefined && object.patch !== null) { + message.patch = String(object.patch); + } else { + message.patch = undefined; + } + if (object.custom !== undefined && object.custom !== null) { + message.custom = CustomHttpPattern.fromJSON(object.custom); + } else { + message.custom = undefined; + } + if (object.body !== undefined && object.body !== null) { + message.body = String(object.body); + } else { + message.body = ""; + } + if (object.responseBody !== undefined && object.responseBody !== null) { + message.responseBody = String(object.responseBody); + } else { + message.responseBody = ""; + } + if ( + object.additionalBindings !== undefined && + object.additionalBindings !== null + ) { + for (const e of object.additionalBindings) { + message.additionalBindings.push(HttpRule.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: HttpRule): unknown { + const obj: any = {}; + message.selector !== undefined && (obj.selector = message.selector); + message.get !== undefined && (obj.get = message.get); + message.put !== undefined && (obj.put = message.put); + message.post !== undefined && (obj.post = message.post); + message.delete !== undefined && (obj.delete = message.delete); + message.patch !== undefined && (obj.patch = message.patch); + message.custom !== undefined && + (obj.custom = message.custom + ? CustomHttpPattern.toJSON(message.custom) + : undefined); + message.body !== undefined && (obj.body = message.body); + message.responseBody !== undefined && + (obj.responseBody = message.responseBody); + if (message.additionalBindings) { + obj.additionalBindings = message.additionalBindings.map((e) => + e ? HttpRule.toJSON(e) : undefined + ); + } else { + obj.additionalBindings = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): HttpRule { + const message = { ...baseHttpRule } as HttpRule; + message.additionalBindings = []; + if (object.selector !== undefined && object.selector !== null) { + message.selector = object.selector; + } else { + message.selector = ""; + } + if (object.get !== undefined && object.get !== null) { + message.get = object.get; + } else { + message.get = undefined; + } + if (object.put !== undefined && object.put !== null) { + message.put = object.put; + } else { + message.put = undefined; + } + if (object.post !== undefined && object.post !== null) { + message.post = object.post; + } else { + message.post = undefined; + } + if (object.delete !== undefined && object.delete !== null) { + message.delete = object.delete; + } else { + message.delete = undefined; + } + if (object.patch !== undefined && object.patch !== null) { + message.patch = object.patch; + } else { + message.patch = undefined; + } + if (object.custom !== undefined && object.custom !== null) { + message.custom = CustomHttpPattern.fromPartial(object.custom); + } else { + message.custom = undefined; + } + if (object.body !== undefined && object.body !== null) { + message.body = object.body; + } else { + message.body = ""; + } + if (object.responseBody !== undefined && object.responseBody !== null) { + message.responseBody = object.responseBody; + } else { + message.responseBody = ""; + } + if ( + object.additionalBindings !== undefined && + object.additionalBindings !== null + ) { + for (const e of object.additionalBindings) { + message.additionalBindings.push(HttpRule.fromPartial(e)); + } + } + return message; + }, +}; + +const baseCustomHttpPattern: object = { kind: "", path: "" }; + +export const CustomHttpPattern = { + encode(message: CustomHttpPattern, writer: Writer = Writer.create()): Writer { + if (message.kind !== "") { + writer.uint32(10).string(message.kind); + } + if (message.path !== "") { + writer.uint32(18).string(message.path); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): CustomHttpPattern { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseCustomHttpPattern } as CustomHttpPattern; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.kind = reader.string(); + break; + case 2: + message.path = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): CustomHttpPattern { + const message = { ...baseCustomHttpPattern } as CustomHttpPattern; + if (object.kind !== undefined && object.kind !== null) { + message.kind = String(object.kind); + } else { + message.kind = ""; + } + if (object.path !== undefined && object.path !== null) { + message.path = String(object.path); + } else { + message.path = ""; + } + return message; + }, + + toJSON(message: CustomHttpPattern): unknown { + const obj: any = {}; + message.kind !== undefined && (obj.kind = message.kind); + message.path !== undefined && (obj.path = message.path); + return obj; + }, + + fromPartial(object: DeepPartial): CustomHttpPattern { + const message = { ...baseCustomHttpPattern } as CustomHttpPattern; + if (object.kind !== undefined && object.kind !== null) { + message.kind = object.kind; + } else { + message.kind = ""; + } + if (object.path !== undefined && object.path !== null) { + message.path = object.path; + } else { + message.path = ""; + } + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/bze.epochs.v1/types/google/protobuf/descriptor.ts b/ts-client/bze.epochs.v1/types/google/protobuf/descriptor.ts new file mode 100644 index 00000000..9e508660 --- /dev/null +++ b/ts-client/bze.epochs.v1/types/google/protobuf/descriptor.ts @@ -0,0 +1,5261 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "google.protobuf"; + +/** + * The protocol compiler can output a FileDescriptorSet containing the .proto + * files it parses. + */ +export interface FileDescriptorSet { + file: FileDescriptorProto[]; +} + +/** Describes a complete .proto file. */ +export interface FileDescriptorProto { + /** file name, relative to root of source tree */ + name: string; + /** e.g. "foo", "foo.bar", etc. */ + package: string; + /** Names of files imported by this file. */ + dependency: string[]; + /** Indexes of the public imported files in the dependency list above. */ + publicDependency: number[]; + /** + * Indexes of the weak imported files in the dependency list. + * For Google-internal migration only. Do not use. + */ + weakDependency: number[]; + /** All top-level definitions in this file. */ + messageType: DescriptorProto[]; + enumType: EnumDescriptorProto[]; + service: ServiceDescriptorProto[]; + extension: FieldDescriptorProto[]; + options: FileOptions | undefined; + /** + * This field contains optional information about the original source code. + * You may safely remove this entire field without harming runtime + * functionality of the descriptors -- the information is needed only by + * development tools. + */ + sourceCodeInfo: SourceCodeInfo | undefined; + /** + * The syntax of the proto file. + * The supported values are "proto2" and "proto3". + */ + syntax: string; +} + +/** Describes a message type. */ +export interface DescriptorProto { + name: string; + field: FieldDescriptorProto[]; + extension: FieldDescriptorProto[]; + nestedType: DescriptorProto[]; + enumType: EnumDescriptorProto[]; + extensionRange: DescriptorProto_ExtensionRange[]; + oneofDecl: OneofDescriptorProto[]; + options: MessageOptions | undefined; + reservedRange: DescriptorProto_ReservedRange[]; + /** + * Reserved field names, which may not be used by fields in the same message. + * A given name may only be reserved once. + */ + reservedName: string[]; +} + +export interface DescriptorProto_ExtensionRange { + /** Inclusive. */ + start: number; + /** Exclusive. */ + end: number; + options: ExtensionRangeOptions | undefined; +} + +/** + * Range of reserved tag numbers. Reserved tag numbers may not be used by + * fields or extension ranges in the same message. Reserved ranges may + * not overlap. + */ +export interface DescriptorProto_ReservedRange { + /** Inclusive. */ + start: number; + /** Exclusive. */ + end: number; +} + +export interface ExtensionRangeOptions { + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +/** Describes a field within a message. */ +export interface FieldDescriptorProto { + name: string; + number: number; + label: FieldDescriptorProto_Label; + /** + * If type_name is set, this need not be set. If both this and type_name + * are set, this must be one of TYPE_ENUM, TYPE_MESSAGE or TYPE_GROUP. + */ + type: FieldDescriptorProto_Type; + /** + * For message and enum types, this is the name of the type. If the name + * starts with a '.', it is fully-qualified. Otherwise, C++-like scoping + * rules are used to find the type (i.e. first the nested types within this + * message are searched, then within the parent, on up to the root + * namespace). + */ + typeName: string; + /** + * For extensions, this is the name of the type being extended. It is + * resolved in the same manner as type_name. + */ + extendee: string; + /** + * For numeric types, contains the original text representation of the value. + * For booleans, "true" or "false". + * For strings, contains the default text contents (not escaped in any way). + * For bytes, contains the C escaped value. All bytes >= 128 are escaped. + * TODO(kenton): Base-64 encode? + */ + defaultValue: string; + /** + * If set, gives the index of a oneof in the containing type's oneof_decl + * list. This field is a member of that oneof. + */ + oneofIndex: number; + /** + * JSON name of this field. The value is set by protocol compiler. If the + * user has set a "json_name" option on this field, that option's value + * will be used. Otherwise, it's deduced from the field's name by converting + * it to camelCase. + */ + jsonName: string; + options: FieldOptions | undefined; + /** + * If true, this is a proto3 "optional". When a proto3 field is optional, it + * tracks presence regardless of field type. + * + * When proto3_optional is true, this field must be belong to a oneof to + * signal to old proto3 clients that presence is tracked for this field. This + * oneof is known as a "synthetic" oneof, and this field must be its sole + * member (each proto3 optional field gets its own synthetic oneof). Synthetic + * oneofs exist in the descriptor only, and do not generate any API. Synthetic + * oneofs must be ordered after all "real" oneofs. + * + * For message fields, proto3_optional doesn't create any semantic change, + * since non-repeated message fields always track presence. However it still + * indicates the semantic detail of whether the user wrote "optional" or not. + * This can be useful for round-tripping the .proto file. For consistency we + * give message fields a synthetic oneof also, even though it is not required + * to track presence. This is especially important because the parser can't + * tell if a field is a message or an enum, so it must always create a + * synthetic oneof. + * + * Proto2 optional fields do not set this flag, because they already indicate + * optional with `LABEL_OPTIONAL`. + */ + proto3Optional: boolean; +} + +export enum FieldDescriptorProto_Type { + /** + * TYPE_DOUBLE - 0 is reserved for errors. + * Order is weird for historical reasons. + */ + TYPE_DOUBLE = 1, + TYPE_FLOAT = 2, + /** + * TYPE_INT64 - Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT64 if + * negative values are likely. + */ + TYPE_INT64 = 3, + TYPE_UINT64 = 4, + /** + * TYPE_INT32 - Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT32 if + * negative values are likely. + */ + TYPE_INT32 = 5, + TYPE_FIXED64 = 6, + TYPE_FIXED32 = 7, + TYPE_BOOL = 8, + TYPE_STRING = 9, + /** + * TYPE_GROUP - Tag-delimited aggregate. + * Group type is deprecated and not supported in proto3. However, Proto3 + * implementations should still be able to parse the group wire format and + * treat group fields as unknown fields. + */ + TYPE_GROUP = 10, + /** TYPE_MESSAGE - Length-delimited aggregate. */ + TYPE_MESSAGE = 11, + /** TYPE_BYTES - New in version 2. */ + TYPE_BYTES = 12, + TYPE_UINT32 = 13, + TYPE_ENUM = 14, + TYPE_SFIXED32 = 15, + TYPE_SFIXED64 = 16, + /** TYPE_SINT32 - Uses ZigZag encoding. */ + TYPE_SINT32 = 17, + /** TYPE_SINT64 - Uses ZigZag encoding. */ + TYPE_SINT64 = 18, + UNRECOGNIZED = -1, +} + +export function fieldDescriptorProto_TypeFromJSON( + object: any +): FieldDescriptorProto_Type { + switch (object) { + case 1: + case "TYPE_DOUBLE": + return FieldDescriptorProto_Type.TYPE_DOUBLE; + case 2: + case "TYPE_FLOAT": + return FieldDescriptorProto_Type.TYPE_FLOAT; + case 3: + case "TYPE_INT64": + return FieldDescriptorProto_Type.TYPE_INT64; + case 4: + case "TYPE_UINT64": + return FieldDescriptorProto_Type.TYPE_UINT64; + case 5: + case "TYPE_INT32": + return FieldDescriptorProto_Type.TYPE_INT32; + case 6: + case "TYPE_FIXED64": + return FieldDescriptorProto_Type.TYPE_FIXED64; + case 7: + case "TYPE_FIXED32": + return FieldDescriptorProto_Type.TYPE_FIXED32; + case 8: + case "TYPE_BOOL": + return FieldDescriptorProto_Type.TYPE_BOOL; + case 9: + case "TYPE_STRING": + return FieldDescriptorProto_Type.TYPE_STRING; + case 10: + case "TYPE_GROUP": + return FieldDescriptorProto_Type.TYPE_GROUP; + case 11: + case "TYPE_MESSAGE": + return FieldDescriptorProto_Type.TYPE_MESSAGE; + case 12: + case "TYPE_BYTES": + return FieldDescriptorProto_Type.TYPE_BYTES; + case 13: + case "TYPE_UINT32": + return FieldDescriptorProto_Type.TYPE_UINT32; + case 14: + case "TYPE_ENUM": + return FieldDescriptorProto_Type.TYPE_ENUM; + case 15: + case "TYPE_SFIXED32": + return FieldDescriptorProto_Type.TYPE_SFIXED32; + case 16: + case "TYPE_SFIXED64": + return FieldDescriptorProto_Type.TYPE_SFIXED64; + case 17: + case "TYPE_SINT32": + return FieldDescriptorProto_Type.TYPE_SINT32; + case 18: + case "TYPE_SINT64": + return FieldDescriptorProto_Type.TYPE_SINT64; + case -1: + case "UNRECOGNIZED": + default: + return FieldDescriptorProto_Type.UNRECOGNIZED; + } +} + +export function fieldDescriptorProto_TypeToJSON( + object: FieldDescriptorProto_Type +): string { + switch (object) { + case FieldDescriptorProto_Type.TYPE_DOUBLE: + return "TYPE_DOUBLE"; + case FieldDescriptorProto_Type.TYPE_FLOAT: + return "TYPE_FLOAT"; + case FieldDescriptorProto_Type.TYPE_INT64: + return "TYPE_INT64"; + case FieldDescriptorProto_Type.TYPE_UINT64: + return "TYPE_UINT64"; + case FieldDescriptorProto_Type.TYPE_INT32: + return "TYPE_INT32"; + case FieldDescriptorProto_Type.TYPE_FIXED64: + return "TYPE_FIXED64"; + case FieldDescriptorProto_Type.TYPE_FIXED32: + return "TYPE_FIXED32"; + case FieldDescriptorProto_Type.TYPE_BOOL: + return "TYPE_BOOL"; + case FieldDescriptorProto_Type.TYPE_STRING: + return "TYPE_STRING"; + case FieldDescriptorProto_Type.TYPE_GROUP: + return "TYPE_GROUP"; + case FieldDescriptorProto_Type.TYPE_MESSAGE: + return "TYPE_MESSAGE"; + case FieldDescriptorProto_Type.TYPE_BYTES: + return "TYPE_BYTES"; + case FieldDescriptorProto_Type.TYPE_UINT32: + return "TYPE_UINT32"; + case FieldDescriptorProto_Type.TYPE_ENUM: + return "TYPE_ENUM"; + case FieldDescriptorProto_Type.TYPE_SFIXED32: + return "TYPE_SFIXED32"; + case FieldDescriptorProto_Type.TYPE_SFIXED64: + return "TYPE_SFIXED64"; + case FieldDescriptorProto_Type.TYPE_SINT32: + return "TYPE_SINT32"; + case FieldDescriptorProto_Type.TYPE_SINT64: + return "TYPE_SINT64"; + default: + return "UNKNOWN"; + } +} + +export enum FieldDescriptorProto_Label { + /** LABEL_OPTIONAL - 0 is reserved for errors */ + LABEL_OPTIONAL = 1, + LABEL_REQUIRED = 2, + LABEL_REPEATED = 3, + UNRECOGNIZED = -1, +} + +export function fieldDescriptorProto_LabelFromJSON( + object: any +): FieldDescriptorProto_Label { + switch (object) { + case 1: + case "LABEL_OPTIONAL": + return FieldDescriptorProto_Label.LABEL_OPTIONAL; + case 2: + case "LABEL_REQUIRED": + return FieldDescriptorProto_Label.LABEL_REQUIRED; + case 3: + case "LABEL_REPEATED": + return FieldDescriptorProto_Label.LABEL_REPEATED; + case -1: + case "UNRECOGNIZED": + default: + return FieldDescriptorProto_Label.UNRECOGNIZED; + } +} + +export function fieldDescriptorProto_LabelToJSON( + object: FieldDescriptorProto_Label +): string { + switch (object) { + case FieldDescriptorProto_Label.LABEL_OPTIONAL: + return "LABEL_OPTIONAL"; + case FieldDescriptorProto_Label.LABEL_REQUIRED: + return "LABEL_REQUIRED"; + case FieldDescriptorProto_Label.LABEL_REPEATED: + return "LABEL_REPEATED"; + default: + return "UNKNOWN"; + } +} + +/** Describes a oneof. */ +export interface OneofDescriptorProto { + name: string; + options: OneofOptions | undefined; +} + +/** Describes an enum type. */ +export interface EnumDescriptorProto { + name: string; + value: EnumValueDescriptorProto[]; + options: EnumOptions | undefined; + /** + * Range of reserved numeric values. Reserved numeric values may not be used + * by enum values in the same enum declaration. Reserved ranges may not + * overlap. + */ + reservedRange: EnumDescriptorProto_EnumReservedRange[]; + /** + * Reserved enum value names, which may not be reused. A given name may only + * be reserved once. + */ + reservedName: string[]; +} + +/** + * Range of reserved numeric values. Reserved values may not be used by + * entries in the same enum. Reserved ranges may not overlap. + * + * Note that this is distinct from DescriptorProto.ReservedRange in that it + * is inclusive such that it can appropriately represent the entire int32 + * domain. + */ +export interface EnumDescriptorProto_EnumReservedRange { + /** Inclusive. */ + start: number; + /** Inclusive. */ + end: number; +} + +/** Describes a value within an enum. */ +export interface EnumValueDescriptorProto { + name: string; + number: number; + options: EnumValueOptions | undefined; +} + +/** Describes a service. */ +export interface ServiceDescriptorProto { + name: string; + method: MethodDescriptorProto[]; + options: ServiceOptions | undefined; +} + +/** Describes a method of a service. */ +export interface MethodDescriptorProto { + name: string; + /** + * Input and output type names. These are resolved in the same way as + * FieldDescriptorProto.type_name, but must refer to a message type. + */ + inputType: string; + outputType: string; + options: MethodOptions | undefined; + /** Identifies if client streams multiple client messages */ + clientStreaming: boolean; + /** Identifies if server streams multiple server messages */ + serverStreaming: boolean; +} + +export interface FileOptions { + /** + * Sets the Java package where classes generated from this .proto will be + * placed. By default, the proto package is used, but this is often + * inappropriate because proto packages do not normally start with backwards + * domain names. + */ + javaPackage: string; + /** + * Controls the name of the wrapper Java class generated for the .proto file. + * That class will always contain the .proto file's getDescriptor() method as + * well as any top-level extensions defined in the .proto file. + * If java_multiple_files is disabled, then all the other classes from the + * .proto file will be nested inside the single wrapper outer class. + */ + javaOuterClassname: string; + /** + * If enabled, then the Java code generator will generate a separate .java + * file for each top-level message, enum, and service defined in the .proto + * file. Thus, these types will *not* be nested inside the wrapper class + * named by java_outer_classname. However, the wrapper class will still be + * generated to contain the file's getDescriptor() method as well as any + * top-level extensions defined in the file. + */ + javaMultipleFiles: boolean; + /** + * This option does nothing. + * + * @deprecated + */ + javaGenerateEqualsAndHash: boolean; + /** + * If set true, then the Java2 code generator will generate code that + * throws an exception whenever an attempt is made to assign a non-UTF-8 + * byte sequence to a string field. + * Message reflection will do the same. + * However, an extension field still accepts non-UTF-8 byte sequences. + * This option has no effect on when used with the lite runtime. + */ + javaStringCheckUtf8: boolean; + optimizeFor: FileOptions_OptimizeMode; + /** + * Sets the Go package where structs generated from this .proto will be + * placed. If omitted, the Go package will be derived from the following: + * - The basename of the package import path, if provided. + * - Otherwise, the package statement in the .proto file, if present. + * - Otherwise, the basename of the .proto file, without extension. + */ + goPackage: string; + /** + * Should generic services be generated in each language? "Generic" services + * are not specific to any particular RPC system. They are generated by the + * main code generators in each language (without additional plugins). + * Generic services were the only kind of service generation supported by + * early versions of google.protobuf. + * + * Generic services are now considered deprecated in favor of using plugins + * that generate code specific to your particular RPC system. Therefore, + * these default to false. Old code which depends on generic services should + * explicitly set them to true. + */ + ccGenericServices: boolean; + javaGenericServices: boolean; + pyGenericServices: boolean; + phpGenericServices: boolean; + /** + * Is this file deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for everything in the file, or it will be completely ignored; in the very + * least, this is a formalization for deprecating files. + */ + deprecated: boolean; + /** + * Enables the use of arenas for the proto messages in this file. This applies + * only to generated classes for C++. + */ + ccEnableArenas: boolean; + /** + * Sets the objective c class prefix which is prepended to all objective c + * generated classes from this .proto. There is no default. + */ + objcClassPrefix: string; + /** Namespace for generated classes; defaults to the package. */ + csharpNamespace: string; + /** + * By default Swift generators will take the proto package and CamelCase it + * replacing '.' with underscore and use that to prefix the types/symbols + * defined. When this options is provided, they will use this value instead + * to prefix the types/symbols defined. + */ + swiftPrefix: string; + /** + * Sets the php class prefix which is prepended to all php generated classes + * from this .proto. Default is empty. + */ + phpClassPrefix: string; + /** + * Use this option to change the namespace of php generated classes. Default + * is empty. When this option is empty, the package name will be used for + * determining the namespace. + */ + phpNamespace: string; + /** + * Use this option to change the namespace of php generated metadata classes. + * Default is empty. When this option is empty, the proto file name will be + * used for determining the namespace. + */ + phpMetadataNamespace: string; + /** + * Use this option to change the package of ruby generated classes. Default + * is empty. When this option is not set, the package name will be used for + * determining the ruby package. + */ + rubyPackage: string; + /** + * The parser stores options it doesn't recognize here. + * See the documentation for the "Options" section above. + */ + uninterpretedOption: UninterpretedOption[]; +} + +/** Generated classes can be optimized for speed or code size. */ +export enum FileOptions_OptimizeMode { + /** SPEED - Generate complete code for parsing, serialization, */ + SPEED = 1, + /** CODE_SIZE - etc. */ + CODE_SIZE = 2, + /** LITE_RUNTIME - Generate code using MessageLite and the lite runtime. */ + LITE_RUNTIME = 3, + UNRECOGNIZED = -1, +} + +export function fileOptions_OptimizeModeFromJSON( + object: any +): FileOptions_OptimizeMode { + switch (object) { + case 1: + case "SPEED": + return FileOptions_OptimizeMode.SPEED; + case 2: + case "CODE_SIZE": + return FileOptions_OptimizeMode.CODE_SIZE; + case 3: + case "LITE_RUNTIME": + return FileOptions_OptimizeMode.LITE_RUNTIME; + case -1: + case "UNRECOGNIZED": + default: + return FileOptions_OptimizeMode.UNRECOGNIZED; + } +} + +export function fileOptions_OptimizeModeToJSON( + object: FileOptions_OptimizeMode +): string { + switch (object) { + case FileOptions_OptimizeMode.SPEED: + return "SPEED"; + case FileOptions_OptimizeMode.CODE_SIZE: + return "CODE_SIZE"; + case FileOptions_OptimizeMode.LITE_RUNTIME: + return "LITE_RUNTIME"; + default: + return "UNKNOWN"; + } +} + +export interface MessageOptions { + /** + * Set true to use the old proto1 MessageSet wire format for extensions. + * This is provided for backwards-compatibility with the MessageSet wire + * format. You should not use this for any other reason: It's less + * efficient, has fewer features, and is more complicated. + * + * The message must be defined exactly as follows: + * message Foo { + * option message_set_wire_format = true; + * extensions 4 to max; + * } + * Note that the message cannot have any defined fields; MessageSets only + * have extensions. + * + * All extensions of your type must be singular messages; e.g. they cannot + * be int32s, enums, or repeated messages. + * + * Because this is an option, the above two restrictions are not enforced by + * the protocol compiler. + */ + messageSetWireFormat: boolean; + /** + * Disables the generation of the standard "descriptor()" accessor, which can + * conflict with a field of the same name. This is meant to make migration + * from proto1 easier; new code should avoid fields named "descriptor". + */ + noStandardDescriptorAccessor: boolean; + /** + * Is this message deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the message, or it will be completely ignored; in the very least, + * this is a formalization for deprecating messages. + */ + deprecated: boolean; + /** + * Whether the message is an automatically generated map entry type for the + * maps field. + * + * For maps fields: + * map map_field = 1; + * The parsed descriptor looks like: + * message MapFieldEntry { + * option map_entry = true; + * optional KeyType key = 1; + * optional ValueType value = 2; + * } + * repeated MapFieldEntry map_field = 1; + * + * Implementations may choose not to generate the map_entry=true message, but + * use a native map in the target language to hold the keys and values. + * The reflection APIs in such implementations still need to work as + * if the field is a repeated message field. + * + * NOTE: Do not set the option in .proto files. Always use the maps syntax + * instead. The option should only be implicitly set by the proto compiler + * parser. + */ + mapEntry: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface FieldOptions { + /** + * The ctype option instructs the C++ code generator to use a different + * representation of the field than it normally would. See the specific + * options below. This option is not yet implemented in the open source + * release -- sorry, we'll try to include it in a future version! + */ + ctype: FieldOptions_CType; + /** + * The packed option can be enabled for repeated primitive fields to enable + * a more efficient representation on the wire. Rather than repeatedly + * writing the tag and type for each element, the entire array is encoded as + * a single length-delimited blob. In proto3, only explicit setting it to + * false will avoid using packed encoding. + */ + packed: boolean; + /** + * The jstype option determines the JavaScript type used for values of the + * field. The option is permitted only for 64 bit integral and fixed types + * (int64, uint64, sint64, fixed64, sfixed64). A field with jstype JS_STRING + * is represented as JavaScript string, which avoids loss of precision that + * can happen when a large value is converted to a floating point JavaScript. + * Specifying JS_NUMBER for the jstype causes the generated JavaScript code to + * use the JavaScript "number" type. The behavior of the default option + * JS_NORMAL is implementation dependent. + * + * This option is an enum to permit additional types to be added, e.g. + * goog.math.Integer. + */ + jstype: FieldOptions_JSType; + /** + * Should this field be parsed lazily? Lazy applies only to message-type + * fields. It means that when the outer message is initially parsed, the + * inner message's contents will not be parsed but instead stored in encoded + * form. The inner message will actually be parsed when it is first accessed. + * + * This is only a hint. Implementations are free to choose whether to use + * eager or lazy parsing regardless of the value of this option. However, + * setting this option true suggests that the protocol author believes that + * using lazy parsing on this field is worth the additional bookkeeping + * overhead typically needed to implement it. + * + * This option does not affect the public interface of any generated code; + * all method signatures remain the same. Furthermore, thread-safety of the + * interface is not affected by this option; const methods remain safe to + * call from multiple threads concurrently, while non-const methods continue + * to require exclusive access. + * + * + * Note that implementations may choose not to check required fields within + * a lazy sub-message. That is, calling IsInitialized() on the outer message + * may return true even if the inner message has missing required fields. + * This is necessary because otherwise the inner message would have to be + * parsed in order to perform the check, defeating the purpose of lazy + * parsing. An implementation which chooses not to check required fields + * must be consistent about it. That is, for any particular sub-message, the + * implementation must either *always* check its required fields, or *never* + * check its required fields, regardless of whether or not the message has + * been parsed. + */ + lazy: boolean; + /** + * Is this field deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for accessors, or it will be completely ignored; in the very least, this + * is a formalization for deprecating fields. + */ + deprecated: boolean; + /** For Google-internal migration only. Do not use. */ + weak: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export enum FieldOptions_CType { + /** STRING - Default mode. */ + STRING = 0, + CORD = 1, + STRING_PIECE = 2, + UNRECOGNIZED = -1, +} + +export function fieldOptions_CTypeFromJSON(object: any): FieldOptions_CType { + switch (object) { + case 0: + case "STRING": + return FieldOptions_CType.STRING; + case 1: + case "CORD": + return FieldOptions_CType.CORD; + case 2: + case "STRING_PIECE": + return FieldOptions_CType.STRING_PIECE; + case -1: + case "UNRECOGNIZED": + default: + return FieldOptions_CType.UNRECOGNIZED; + } +} + +export function fieldOptions_CTypeToJSON(object: FieldOptions_CType): string { + switch (object) { + case FieldOptions_CType.STRING: + return "STRING"; + case FieldOptions_CType.CORD: + return "CORD"; + case FieldOptions_CType.STRING_PIECE: + return "STRING_PIECE"; + default: + return "UNKNOWN"; + } +} + +export enum FieldOptions_JSType { + /** JS_NORMAL - Use the default type. */ + JS_NORMAL = 0, + /** JS_STRING - Use JavaScript strings. */ + JS_STRING = 1, + /** JS_NUMBER - Use JavaScript numbers. */ + JS_NUMBER = 2, + UNRECOGNIZED = -1, +} + +export function fieldOptions_JSTypeFromJSON(object: any): FieldOptions_JSType { + switch (object) { + case 0: + case "JS_NORMAL": + return FieldOptions_JSType.JS_NORMAL; + case 1: + case "JS_STRING": + return FieldOptions_JSType.JS_STRING; + case 2: + case "JS_NUMBER": + return FieldOptions_JSType.JS_NUMBER; + case -1: + case "UNRECOGNIZED": + default: + return FieldOptions_JSType.UNRECOGNIZED; + } +} + +export function fieldOptions_JSTypeToJSON(object: FieldOptions_JSType): string { + switch (object) { + case FieldOptions_JSType.JS_NORMAL: + return "JS_NORMAL"; + case FieldOptions_JSType.JS_STRING: + return "JS_STRING"; + case FieldOptions_JSType.JS_NUMBER: + return "JS_NUMBER"; + default: + return "UNKNOWN"; + } +} + +export interface OneofOptions { + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface EnumOptions { + /** + * Set this option to true to allow mapping different tag names to the same + * value. + */ + allowAlias: boolean; + /** + * Is this enum deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the enum, or it will be completely ignored; in the very least, this + * is a formalization for deprecating enums. + */ + deprecated: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface EnumValueOptions { + /** + * Is this enum value deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the enum value, or it will be completely ignored; in the very least, + * this is a formalization for deprecating enum values. + */ + deprecated: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface ServiceOptions { + /** + * Is this service deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the service, or it will be completely ignored; in the very least, + * this is a formalization for deprecating services. + */ + deprecated: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface MethodOptions { + /** + * Is this method deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the method, or it will be completely ignored; in the very least, + * this is a formalization for deprecating methods. + */ + deprecated: boolean; + idempotencyLevel: MethodOptions_IdempotencyLevel; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +/** + * Is this method side-effect-free (or safe in HTTP parlance), or idempotent, + * or neither? HTTP based RPC implementation may choose GET verb for safe + * methods, and PUT verb for idempotent methods instead of the default POST. + */ +export enum MethodOptions_IdempotencyLevel { + IDEMPOTENCY_UNKNOWN = 0, + /** NO_SIDE_EFFECTS - implies idempotent */ + NO_SIDE_EFFECTS = 1, + /** IDEMPOTENT - idempotent, but may have side effects */ + IDEMPOTENT = 2, + UNRECOGNIZED = -1, +} + +export function methodOptions_IdempotencyLevelFromJSON( + object: any +): MethodOptions_IdempotencyLevel { + switch (object) { + case 0: + case "IDEMPOTENCY_UNKNOWN": + return MethodOptions_IdempotencyLevel.IDEMPOTENCY_UNKNOWN; + case 1: + case "NO_SIDE_EFFECTS": + return MethodOptions_IdempotencyLevel.NO_SIDE_EFFECTS; + case 2: + case "IDEMPOTENT": + return MethodOptions_IdempotencyLevel.IDEMPOTENT; + case -1: + case "UNRECOGNIZED": + default: + return MethodOptions_IdempotencyLevel.UNRECOGNIZED; + } +} + +export function methodOptions_IdempotencyLevelToJSON( + object: MethodOptions_IdempotencyLevel +): string { + switch (object) { + case MethodOptions_IdempotencyLevel.IDEMPOTENCY_UNKNOWN: + return "IDEMPOTENCY_UNKNOWN"; + case MethodOptions_IdempotencyLevel.NO_SIDE_EFFECTS: + return "NO_SIDE_EFFECTS"; + case MethodOptions_IdempotencyLevel.IDEMPOTENT: + return "IDEMPOTENT"; + default: + return "UNKNOWN"; + } +} + +/** + * A message representing a option the parser does not recognize. This only + * appears in options protos created by the compiler::Parser class. + * DescriptorPool resolves these when building Descriptor objects. Therefore, + * options protos in descriptor objects (e.g. returned by Descriptor::options(), + * or produced by Descriptor::CopyTo()) will never have UninterpretedOptions + * in them. + */ +export interface UninterpretedOption { + name: UninterpretedOption_NamePart[]; + /** + * The value of the uninterpreted option, in whatever type the tokenizer + * identified it as during parsing. Exactly one of these should be set. + */ + identifierValue: string; + positiveIntValue: number; + negativeIntValue: number; + doubleValue: number; + stringValue: Uint8Array; + aggregateValue: string; +} + +/** + * The name of the uninterpreted option. Each string represents a segment in + * a dot-separated name. is_extension is true iff a segment represents an + * extension (denoted with parentheses in options specs in .proto files). + * E.g.,{ ["foo", false], ["bar.baz", true], ["qux", false] } represents + * "foo.(bar.baz).qux". + */ +export interface UninterpretedOption_NamePart { + namePart: string; + isExtension: boolean; +} + +/** + * Encapsulates information about the original source file from which a + * FileDescriptorProto was generated. + */ +export interface SourceCodeInfo { + /** + * A Location identifies a piece of source code in a .proto file which + * corresponds to a particular definition. This information is intended + * to be useful to IDEs, code indexers, documentation generators, and similar + * tools. + * + * For example, say we have a file like: + * message Foo { + * optional string foo = 1; + * } + * Let's look at just the field definition: + * optional string foo = 1; + * ^ ^^ ^^ ^ ^^^ + * a bc de f ghi + * We have the following locations: + * span path represents + * [a,i) [ 4, 0, 2, 0 ] The whole field definition. + * [a,b) [ 4, 0, 2, 0, 4 ] The label (optional). + * [c,d) [ 4, 0, 2, 0, 5 ] The type (string). + * [e,f) [ 4, 0, 2, 0, 1 ] The name (foo). + * [g,h) [ 4, 0, 2, 0, 3 ] The number (1). + * + * Notes: + * - A location may refer to a repeated field itself (i.e. not to any + * particular index within it). This is used whenever a set of elements are + * logically enclosed in a single code segment. For example, an entire + * extend block (possibly containing multiple extension definitions) will + * have an outer location whose path refers to the "extensions" repeated + * field without an index. + * - Multiple locations may have the same path. This happens when a single + * logical declaration is spread out across multiple places. The most + * obvious example is the "extend" block again -- there may be multiple + * extend blocks in the same scope, each of which will have the same path. + * - A location's span is not always a subset of its parent's span. For + * example, the "extendee" of an extension declaration appears at the + * beginning of the "extend" block and is shared by all extensions within + * the block. + * - Just because a location's span is a subset of some other location's span + * does not mean that it is a descendant. For example, a "group" defines + * both a type and a field in a single declaration. Thus, the locations + * corresponding to the type and field and their components will overlap. + * - Code which tries to interpret locations should probably be designed to + * ignore those that it doesn't understand, as more types of locations could + * be recorded in the future. + */ + location: SourceCodeInfo_Location[]; +} + +export interface SourceCodeInfo_Location { + /** + * Identifies which part of the FileDescriptorProto was defined at this + * location. + * + * Each element is a field number or an index. They form a path from + * the root FileDescriptorProto to the place where the definition. For + * example, this path: + * [ 4, 3, 2, 7, 1 ] + * refers to: + * file.message_type(3) // 4, 3 + * .field(7) // 2, 7 + * .name() // 1 + * This is because FileDescriptorProto.message_type has field number 4: + * repeated DescriptorProto message_type = 4; + * and DescriptorProto.field has field number 2: + * repeated FieldDescriptorProto field = 2; + * and FieldDescriptorProto.name has field number 1: + * optional string name = 1; + * + * Thus, the above path gives the location of a field name. If we removed + * the last element: + * [ 4, 3, 2, 7 ] + * this path refers to the whole field declaration (from the beginning + * of the label to the terminating semicolon). + */ + path: number[]; + /** + * Always has exactly three or four elements: start line, start column, + * end line (optional, otherwise assumed same as start line), end column. + * These are packed into a single field for efficiency. Note that line + * and column numbers are zero-based -- typically you will want to add + * 1 to each before displaying to a user. + */ + span: number[]; + /** + * If this SourceCodeInfo represents a complete declaration, these are any + * comments appearing before and after the declaration which appear to be + * attached to the declaration. + * + * A series of line comments appearing on consecutive lines, with no other + * tokens appearing on those lines, will be treated as a single comment. + * + * leading_detached_comments will keep paragraphs of comments that appear + * before (but not connected to) the current element. Each paragraph, + * separated by empty lines, will be one comment element in the repeated + * field. + * + * Only the comment content is provided; comment markers (e.g. //) are + * stripped out. For block comments, leading whitespace and an asterisk + * will be stripped from the beginning of each line other than the first. + * Newlines are included in the output. + * + * Examples: + * + * optional int32 foo = 1; // Comment attached to foo. + * // Comment attached to bar. + * optional int32 bar = 2; + * + * optional string baz = 3; + * // Comment attached to baz. + * // Another line attached to baz. + * + * // Comment attached to qux. + * // + * // Another line attached to qux. + * optional double qux = 4; + * + * // Detached comment for corge. This is not leading or trailing comments + * // to qux or corge because there are blank lines separating it from + * // both. + * + * // Detached comment for corge paragraph 2. + * + * optional string corge = 5; + * /* Block comment attached + * * to corge. Leading asterisks + * * will be removed. * / + * /* Block comment attached to + * * grault. * / + * optional int32 grault = 6; + * + * // ignored detached comments. + */ + leadingComments: string; + trailingComments: string; + leadingDetachedComments: string[]; +} + +/** + * Describes the relationship between generated code and its original source + * file. A GeneratedCodeInfo message is associated with only one generated + * source file, but may contain references to different source .proto files. + */ +export interface GeneratedCodeInfo { + /** + * An Annotation connects some span of text in generated code to an element + * of its generating .proto file. + */ + annotation: GeneratedCodeInfo_Annotation[]; +} + +export interface GeneratedCodeInfo_Annotation { + /** + * Identifies the element in the original source .proto file. This field + * is formatted the same as SourceCodeInfo.Location.path. + */ + path: number[]; + /** Identifies the filesystem path to the original source .proto. */ + sourceFile: string; + /** + * Identifies the starting offset in bytes in the generated code + * that relates to the identified object. + */ + begin: number; + /** + * Identifies the ending offset in bytes in the generated code that + * relates to the identified offset. The end offset should be one past + * the last relevant byte (so the length of the text = end - begin). + */ + end: number; +} + +const baseFileDescriptorSet: object = {}; + +export const FileDescriptorSet = { + encode(message: FileDescriptorSet, writer: Writer = Writer.create()): Writer { + for (const v of message.file) { + FileDescriptorProto.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FileDescriptorSet { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFileDescriptorSet } as FileDescriptorSet; + message.file = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.file.push( + FileDescriptorProto.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FileDescriptorSet { + const message = { ...baseFileDescriptorSet } as FileDescriptorSet; + message.file = []; + if (object.file !== undefined && object.file !== null) { + for (const e of object.file) { + message.file.push(FileDescriptorProto.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: FileDescriptorSet): unknown { + const obj: any = {}; + if (message.file) { + obj.file = message.file.map((e) => + e ? FileDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.file = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): FileDescriptorSet { + const message = { ...baseFileDescriptorSet } as FileDescriptorSet; + message.file = []; + if (object.file !== undefined && object.file !== null) { + for (const e of object.file) { + message.file.push(FileDescriptorProto.fromPartial(e)); + } + } + return message; + }, +}; + +const baseFileDescriptorProto: object = { + name: "", + package: "", + dependency: "", + publicDependency: 0, + weakDependency: 0, + syntax: "", +}; + +export const FileDescriptorProto = { + encode( + message: FileDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.package !== "") { + writer.uint32(18).string(message.package); + } + for (const v of message.dependency) { + writer.uint32(26).string(v!); + } + writer.uint32(82).fork(); + for (const v of message.publicDependency) { + writer.int32(v); + } + writer.ldelim(); + writer.uint32(90).fork(); + for (const v of message.weakDependency) { + writer.int32(v); + } + writer.ldelim(); + for (const v of message.messageType) { + DescriptorProto.encode(v!, writer.uint32(34).fork()).ldelim(); + } + for (const v of message.enumType) { + EnumDescriptorProto.encode(v!, writer.uint32(42).fork()).ldelim(); + } + for (const v of message.service) { + ServiceDescriptorProto.encode(v!, writer.uint32(50).fork()).ldelim(); + } + for (const v of message.extension) { + FieldDescriptorProto.encode(v!, writer.uint32(58).fork()).ldelim(); + } + if (message.options !== undefined) { + FileOptions.encode(message.options, writer.uint32(66).fork()).ldelim(); + } + if (message.sourceCodeInfo !== undefined) { + SourceCodeInfo.encode( + message.sourceCodeInfo, + writer.uint32(74).fork() + ).ldelim(); + } + if (message.syntax !== "") { + writer.uint32(98).string(message.syntax); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FileDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFileDescriptorProto } as FileDescriptorProto; + message.dependency = []; + message.publicDependency = []; + message.weakDependency = []; + message.messageType = []; + message.enumType = []; + message.service = []; + message.extension = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.package = reader.string(); + break; + case 3: + message.dependency.push(reader.string()); + break; + case 10: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.publicDependency.push(reader.int32()); + } + } else { + message.publicDependency.push(reader.int32()); + } + break; + case 11: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.weakDependency.push(reader.int32()); + } + } else { + message.weakDependency.push(reader.int32()); + } + break; + case 4: + message.messageType.push( + DescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 5: + message.enumType.push( + EnumDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 6: + message.service.push( + ServiceDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 7: + message.extension.push( + FieldDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 8: + message.options = FileOptions.decode(reader, reader.uint32()); + break; + case 9: + message.sourceCodeInfo = SourceCodeInfo.decode( + reader, + reader.uint32() + ); + break; + case 12: + message.syntax = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FileDescriptorProto { + const message = { ...baseFileDescriptorProto } as FileDescriptorProto; + message.dependency = []; + message.publicDependency = []; + message.weakDependency = []; + message.messageType = []; + message.enumType = []; + message.service = []; + message.extension = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.package !== undefined && object.package !== null) { + message.package = String(object.package); + } else { + message.package = ""; + } + if (object.dependency !== undefined && object.dependency !== null) { + for (const e of object.dependency) { + message.dependency.push(String(e)); + } + } + if ( + object.publicDependency !== undefined && + object.publicDependency !== null + ) { + for (const e of object.publicDependency) { + message.publicDependency.push(Number(e)); + } + } + if (object.weakDependency !== undefined && object.weakDependency !== null) { + for (const e of object.weakDependency) { + message.weakDependency.push(Number(e)); + } + } + if (object.messageType !== undefined && object.messageType !== null) { + for (const e of object.messageType) { + message.messageType.push(DescriptorProto.fromJSON(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromJSON(e)); + } + } + if (object.service !== undefined && object.service !== null) { + for (const e of object.service) { + message.service.push(ServiceDescriptorProto.fromJSON(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = FileOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.sourceCodeInfo !== undefined && object.sourceCodeInfo !== null) { + message.sourceCodeInfo = SourceCodeInfo.fromJSON(object.sourceCodeInfo); + } else { + message.sourceCodeInfo = undefined; + } + if (object.syntax !== undefined && object.syntax !== null) { + message.syntax = String(object.syntax); + } else { + message.syntax = ""; + } + return message; + }, + + toJSON(message: FileDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.package !== undefined && (obj.package = message.package); + if (message.dependency) { + obj.dependency = message.dependency.map((e) => e); + } else { + obj.dependency = []; + } + if (message.publicDependency) { + obj.publicDependency = message.publicDependency.map((e) => e); + } else { + obj.publicDependency = []; + } + if (message.weakDependency) { + obj.weakDependency = message.weakDependency.map((e) => e); + } else { + obj.weakDependency = []; + } + if (message.messageType) { + obj.messageType = message.messageType.map((e) => + e ? DescriptorProto.toJSON(e) : undefined + ); + } else { + obj.messageType = []; + } + if (message.enumType) { + obj.enumType = message.enumType.map((e) => + e ? EnumDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.enumType = []; + } + if (message.service) { + obj.service = message.service.map((e) => + e ? ServiceDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.service = []; + } + if (message.extension) { + obj.extension = message.extension.map((e) => + e ? FieldDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.extension = []; + } + message.options !== undefined && + (obj.options = message.options + ? FileOptions.toJSON(message.options) + : undefined); + message.sourceCodeInfo !== undefined && + (obj.sourceCodeInfo = message.sourceCodeInfo + ? SourceCodeInfo.toJSON(message.sourceCodeInfo) + : undefined); + message.syntax !== undefined && (obj.syntax = message.syntax); + return obj; + }, + + fromPartial(object: DeepPartial): FileDescriptorProto { + const message = { ...baseFileDescriptorProto } as FileDescriptorProto; + message.dependency = []; + message.publicDependency = []; + message.weakDependency = []; + message.messageType = []; + message.enumType = []; + message.service = []; + message.extension = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.package !== undefined && object.package !== null) { + message.package = object.package; + } else { + message.package = ""; + } + if (object.dependency !== undefined && object.dependency !== null) { + for (const e of object.dependency) { + message.dependency.push(e); + } + } + if ( + object.publicDependency !== undefined && + object.publicDependency !== null + ) { + for (const e of object.publicDependency) { + message.publicDependency.push(e); + } + } + if (object.weakDependency !== undefined && object.weakDependency !== null) { + for (const e of object.weakDependency) { + message.weakDependency.push(e); + } + } + if (object.messageType !== undefined && object.messageType !== null) { + for (const e of object.messageType) { + message.messageType.push(DescriptorProto.fromPartial(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromPartial(e)); + } + } + if (object.service !== undefined && object.service !== null) { + for (const e of object.service) { + message.service.push(ServiceDescriptorProto.fromPartial(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = FileOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.sourceCodeInfo !== undefined && object.sourceCodeInfo !== null) { + message.sourceCodeInfo = SourceCodeInfo.fromPartial( + object.sourceCodeInfo + ); + } else { + message.sourceCodeInfo = undefined; + } + if (object.syntax !== undefined && object.syntax !== null) { + message.syntax = object.syntax; + } else { + message.syntax = ""; + } + return message; + }, +}; + +const baseDescriptorProto: object = { name: "", reservedName: "" }; + +export const DescriptorProto = { + encode(message: DescriptorProto, writer: Writer = Writer.create()): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + for (const v of message.field) { + FieldDescriptorProto.encode(v!, writer.uint32(18).fork()).ldelim(); + } + for (const v of message.extension) { + FieldDescriptorProto.encode(v!, writer.uint32(50).fork()).ldelim(); + } + for (const v of message.nestedType) { + DescriptorProto.encode(v!, writer.uint32(26).fork()).ldelim(); + } + for (const v of message.enumType) { + EnumDescriptorProto.encode(v!, writer.uint32(34).fork()).ldelim(); + } + for (const v of message.extensionRange) { + DescriptorProto_ExtensionRange.encode( + v!, + writer.uint32(42).fork() + ).ldelim(); + } + for (const v of message.oneofDecl) { + OneofDescriptorProto.encode(v!, writer.uint32(66).fork()).ldelim(); + } + if (message.options !== undefined) { + MessageOptions.encode(message.options, writer.uint32(58).fork()).ldelim(); + } + for (const v of message.reservedRange) { + DescriptorProto_ReservedRange.encode( + v!, + writer.uint32(74).fork() + ).ldelim(); + } + for (const v of message.reservedName) { + writer.uint32(82).string(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): DescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseDescriptorProto } as DescriptorProto; + message.field = []; + message.extension = []; + message.nestedType = []; + message.enumType = []; + message.extensionRange = []; + message.oneofDecl = []; + message.reservedRange = []; + message.reservedName = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.field.push( + FieldDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 6: + message.extension.push( + FieldDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 3: + message.nestedType.push( + DescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 4: + message.enumType.push( + EnumDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 5: + message.extensionRange.push( + DescriptorProto_ExtensionRange.decode(reader, reader.uint32()) + ); + break; + case 8: + message.oneofDecl.push( + OneofDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 7: + message.options = MessageOptions.decode(reader, reader.uint32()); + break; + case 9: + message.reservedRange.push( + DescriptorProto_ReservedRange.decode(reader, reader.uint32()) + ); + break; + case 10: + message.reservedName.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DescriptorProto { + const message = { ...baseDescriptorProto } as DescriptorProto; + message.field = []; + message.extension = []; + message.nestedType = []; + message.enumType = []; + message.extensionRange = []; + message.oneofDecl = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.field !== undefined && object.field !== null) { + for (const e of object.field) { + message.field.push(FieldDescriptorProto.fromJSON(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromJSON(e)); + } + } + if (object.nestedType !== undefined && object.nestedType !== null) { + for (const e of object.nestedType) { + message.nestedType.push(DescriptorProto.fromJSON(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromJSON(e)); + } + } + if (object.extensionRange !== undefined && object.extensionRange !== null) { + for (const e of object.extensionRange) { + message.extensionRange.push(DescriptorProto_ExtensionRange.fromJSON(e)); + } + } + if (object.oneofDecl !== undefined && object.oneofDecl !== null) { + for (const e of object.oneofDecl) { + message.oneofDecl.push(OneofDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = MessageOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push(DescriptorProto_ReservedRange.fromJSON(e)); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(String(e)); + } + } + return message; + }, + + toJSON(message: DescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + if (message.field) { + obj.field = message.field.map((e) => + e ? FieldDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.field = []; + } + if (message.extension) { + obj.extension = message.extension.map((e) => + e ? FieldDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.extension = []; + } + if (message.nestedType) { + obj.nestedType = message.nestedType.map((e) => + e ? DescriptorProto.toJSON(e) : undefined + ); + } else { + obj.nestedType = []; + } + if (message.enumType) { + obj.enumType = message.enumType.map((e) => + e ? EnumDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.enumType = []; + } + if (message.extensionRange) { + obj.extensionRange = message.extensionRange.map((e) => + e ? DescriptorProto_ExtensionRange.toJSON(e) : undefined + ); + } else { + obj.extensionRange = []; + } + if (message.oneofDecl) { + obj.oneofDecl = message.oneofDecl.map((e) => + e ? OneofDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.oneofDecl = []; + } + message.options !== undefined && + (obj.options = message.options + ? MessageOptions.toJSON(message.options) + : undefined); + if (message.reservedRange) { + obj.reservedRange = message.reservedRange.map((e) => + e ? DescriptorProto_ReservedRange.toJSON(e) : undefined + ); + } else { + obj.reservedRange = []; + } + if (message.reservedName) { + obj.reservedName = message.reservedName.map((e) => e); + } else { + obj.reservedName = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): DescriptorProto { + const message = { ...baseDescriptorProto } as DescriptorProto; + message.field = []; + message.extension = []; + message.nestedType = []; + message.enumType = []; + message.extensionRange = []; + message.oneofDecl = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.field !== undefined && object.field !== null) { + for (const e of object.field) { + message.field.push(FieldDescriptorProto.fromPartial(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromPartial(e)); + } + } + if (object.nestedType !== undefined && object.nestedType !== null) { + for (const e of object.nestedType) { + message.nestedType.push(DescriptorProto.fromPartial(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromPartial(e)); + } + } + if (object.extensionRange !== undefined && object.extensionRange !== null) { + for (const e of object.extensionRange) { + message.extensionRange.push( + DescriptorProto_ExtensionRange.fromPartial(e) + ); + } + } + if (object.oneofDecl !== undefined && object.oneofDecl !== null) { + for (const e of object.oneofDecl) { + message.oneofDecl.push(OneofDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = MessageOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push( + DescriptorProto_ReservedRange.fromPartial(e) + ); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(e); + } + } + return message; + }, +}; + +const baseDescriptorProto_ExtensionRange: object = { start: 0, end: 0 }; + +export const DescriptorProto_ExtensionRange = { + encode( + message: DescriptorProto_ExtensionRange, + writer: Writer = Writer.create() + ): Writer { + if (message.start !== 0) { + writer.uint32(8).int32(message.start); + } + if (message.end !== 0) { + writer.uint32(16).int32(message.end); + } + if (message.options !== undefined) { + ExtensionRangeOptions.encode( + message.options, + writer.uint32(26).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): DescriptorProto_ExtensionRange { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseDescriptorProto_ExtensionRange, + } as DescriptorProto_ExtensionRange; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.start = reader.int32(); + break; + case 2: + message.end = reader.int32(); + break; + case 3: + message.options = ExtensionRangeOptions.decode( + reader, + reader.uint32() + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DescriptorProto_ExtensionRange { + const message = { + ...baseDescriptorProto_ExtensionRange, + } as DescriptorProto_ExtensionRange; + if (object.start !== undefined && object.start !== null) { + message.start = Number(object.start); + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = ExtensionRangeOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: DescriptorProto_ExtensionRange): unknown { + const obj: any = {}; + message.start !== undefined && (obj.start = message.start); + message.end !== undefined && (obj.end = message.end); + message.options !== undefined && + (obj.options = message.options + ? ExtensionRangeOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): DescriptorProto_ExtensionRange { + const message = { + ...baseDescriptorProto_ExtensionRange, + } as DescriptorProto_ExtensionRange; + if (object.start !== undefined && object.start !== null) { + message.start = object.start; + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = ExtensionRangeOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseDescriptorProto_ReservedRange: object = { start: 0, end: 0 }; + +export const DescriptorProto_ReservedRange = { + encode( + message: DescriptorProto_ReservedRange, + writer: Writer = Writer.create() + ): Writer { + if (message.start !== 0) { + writer.uint32(8).int32(message.start); + } + if (message.end !== 0) { + writer.uint32(16).int32(message.end); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): DescriptorProto_ReservedRange { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseDescriptorProto_ReservedRange, + } as DescriptorProto_ReservedRange; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.start = reader.int32(); + break; + case 2: + message.end = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DescriptorProto_ReservedRange { + const message = { + ...baseDescriptorProto_ReservedRange, + } as DescriptorProto_ReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = Number(object.start); + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + return message; + }, + + toJSON(message: DescriptorProto_ReservedRange): unknown { + const obj: any = {}; + message.start !== undefined && (obj.start = message.start); + message.end !== undefined && (obj.end = message.end); + return obj; + }, + + fromPartial( + object: DeepPartial + ): DescriptorProto_ReservedRange { + const message = { + ...baseDescriptorProto_ReservedRange, + } as DescriptorProto_ReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = object.start; + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + return message; + }, +}; + +const baseExtensionRangeOptions: object = {}; + +export const ExtensionRangeOptions = { + encode( + message: ExtensionRangeOptions, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ExtensionRangeOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseExtensionRangeOptions } as ExtensionRangeOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ExtensionRangeOptions { + const message = { ...baseExtensionRangeOptions } as ExtensionRangeOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: ExtensionRangeOptions): unknown { + const obj: any = {}; + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial( + object: DeepPartial + ): ExtensionRangeOptions { + const message = { ...baseExtensionRangeOptions } as ExtensionRangeOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseFieldDescriptorProto: object = { + name: "", + number: 0, + label: 1, + type: 1, + typeName: "", + extendee: "", + defaultValue: "", + oneofIndex: 0, + jsonName: "", + proto3Optional: false, +}; + +export const FieldDescriptorProto = { + encode( + message: FieldDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.number !== 0) { + writer.uint32(24).int32(message.number); + } + if (message.label !== 1) { + writer.uint32(32).int32(message.label); + } + if (message.type !== 1) { + writer.uint32(40).int32(message.type); + } + if (message.typeName !== "") { + writer.uint32(50).string(message.typeName); + } + if (message.extendee !== "") { + writer.uint32(18).string(message.extendee); + } + if (message.defaultValue !== "") { + writer.uint32(58).string(message.defaultValue); + } + if (message.oneofIndex !== 0) { + writer.uint32(72).int32(message.oneofIndex); + } + if (message.jsonName !== "") { + writer.uint32(82).string(message.jsonName); + } + if (message.options !== undefined) { + FieldOptions.encode(message.options, writer.uint32(66).fork()).ldelim(); + } + if (message.proto3Optional === true) { + writer.uint32(136).bool(message.proto3Optional); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FieldDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFieldDescriptorProto } as FieldDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 3: + message.number = reader.int32(); + break; + case 4: + message.label = reader.int32() as any; + break; + case 5: + message.type = reader.int32() as any; + break; + case 6: + message.typeName = reader.string(); + break; + case 2: + message.extendee = reader.string(); + break; + case 7: + message.defaultValue = reader.string(); + break; + case 9: + message.oneofIndex = reader.int32(); + break; + case 10: + message.jsonName = reader.string(); + break; + case 8: + message.options = FieldOptions.decode(reader, reader.uint32()); + break; + case 17: + message.proto3Optional = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FieldDescriptorProto { + const message = { ...baseFieldDescriptorProto } as FieldDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = Number(object.number); + } else { + message.number = 0; + } + if (object.label !== undefined && object.label !== null) { + message.label = fieldDescriptorProto_LabelFromJSON(object.label); + } else { + message.label = 1; + } + if (object.type !== undefined && object.type !== null) { + message.type = fieldDescriptorProto_TypeFromJSON(object.type); + } else { + message.type = 1; + } + if (object.typeName !== undefined && object.typeName !== null) { + message.typeName = String(object.typeName); + } else { + message.typeName = ""; + } + if (object.extendee !== undefined && object.extendee !== null) { + message.extendee = String(object.extendee); + } else { + message.extendee = ""; + } + if (object.defaultValue !== undefined && object.defaultValue !== null) { + message.defaultValue = String(object.defaultValue); + } else { + message.defaultValue = ""; + } + if (object.oneofIndex !== undefined && object.oneofIndex !== null) { + message.oneofIndex = Number(object.oneofIndex); + } else { + message.oneofIndex = 0; + } + if (object.jsonName !== undefined && object.jsonName !== null) { + message.jsonName = String(object.jsonName); + } else { + message.jsonName = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = FieldOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.proto3Optional !== undefined && object.proto3Optional !== null) { + message.proto3Optional = Boolean(object.proto3Optional); + } else { + message.proto3Optional = false; + } + return message; + }, + + toJSON(message: FieldDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.number !== undefined && (obj.number = message.number); + message.label !== undefined && + (obj.label = fieldDescriptorProto_LabelToJSON(message.label)); + message.type !== undefined && + (obj.type = fieldDescriptorProto_TypeToJSON(message.type)); + message.typeName !== undefined && (obj.typeName = message.typeName); + message.extendee !== undefined && (obj.extendee = message.extendee); + message.defaultValue !== undefined && + (obj.defaultValue = message.defaultValue); + message.oneofIndex !== undefined && (obj.oneofIndex = message.oneofIndex); + message.jsonName !== undefined && (obj.jsonName = message.jsonName); + message.options !== undefined && + (obj.options = message.options + ? FieldOptions.toJSON(message.options) + : undefined); + message.proto3Optional !== undefined && + (obj.proto3Optional = message.proto3Optional); + return obj; + }, + + fromPartial(object: DeepPartial): FieldDescriptorProto { + const message = { ...baseFieldDescriptorProto } as FieldDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = object.number; + } else { + message.number = 0; + } + if (object.label !== undefined && object.label !== null) { + message.label = object.label; + } else { + message.label = 1; + } + if (object.type !== undefined && object.type !== null) { + message.type = object.type; + } else { + message.type = 1; + } + if (object.typeName !== undefined && object.typeName !== null) { + message.typeName = object.typeName; + } else { + message.typeName = ""; + } + if (object.extendee !== undefined && object.extendee !== null) { + message.extendee = object.extendee; + } else { + message.extendee = ""; + } + if (object.defaultValue !== undefined && object.defaultValue !== null) { + message.defaultValue = object.defaultValue; + } else { + message.defaultValue = ""; + } + if (object.oneofIndex !== undefined && object.oneofIndex !== null) { + message.oneofIndex = object.oneofIndex; + } else { + message.oneofIndex = 0; + } + if (object.jsonName !== undefined && object.jsonName !== null) { + message.jsonName = object.jsonName; + } else { + message.jsonName = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = FieldOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.proto3Optional !== undefined && object.proto3Optional !== null) { + message.proto3Optional = object.proto3Optional; + } else { + message.proto3Optional = false; + } + return message; + }, +}; + +const baseOneofDescriptorProto: object = { name: "" }; + +export const OneofDescriptorProto = { + encode( + message: OneofDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.options !== undefined) { + OneofOptions.encode(message.options, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): OneofDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseOneofDescriptorProto } as OneofDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.options = OneofOptions.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): OneofDescriptorProto { + const message = { ...baseOneofDescriptorProto } as OneofDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = OneofOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: OneofDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.options !== undefined && + (obj.options = message.options + ? OneofOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): OneofDescriptorProto { + const message = { ...baseOneofDescriptorProto } as OneofDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = OneofOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseEnumDescriptorProto: object = { name: "", reservedName: "" }; + +export const EnumDescriptorProto = { + encode( + message: EnumDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + for (const v of message.value) { + EnumValueDescriptorProto.encode(v!, writer.uint32(18).fork()).ldelim(); + } + if (message.options !== undefined) { + EnumOptions.encode(message.options, writer.uint32(26).fork()).ldelim(); + } + for (const v of message.reservedRange) { + EnumDescriptorProto_EnumReservedRange.encode( + v!, + writer.uint32(34).fork() + ).ldelim(); + } + for (const v of message.reservedName) { + writer.uint32(42).string(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): EnumDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseEnumDescriptorProto } as EnumDescriptorProto; + message.value = []; + message.reservedRange = []; + message.reservedName = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.value.push( + EnumValueDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 3: + message.options = EnumOptions.decode(reader, reader.uint32()); + break; + case 4: + message.reservedRange.push( + EnumDescriptorProto_EnumReservedRange.decode( + reader, + reader.uint32() + ) + ); + break; + case 5: + message.reservedName.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumDescriptorProto { + const message = { ...baseEnumDescriptorProto } as EnumDescriptorProto; + message.value = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.value !== undefined && object.value !== null) { + for (const e of object.value) { + message.value.push(EnumValueDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push( + EnumDescriptorProto_EnumReservedRange.fromJSON(e) + ); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(String(e)); + } + } + return message; + }, + + toJSON(message: EnumDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + if (message.value) { + obj.value = message.value.map((e) => + e ? EnumValueDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.value = []; + } + message.options !== undefined && + (obj.options = message.options + ? EnumOptions.toJSON(message.options) + : undefined); + if (message.reservedRange) { + obj.reservedRange = message.reservedRange.map((e) => + e ? EnumDescriptorProto_EnumReservedRange.toJSON(e) : undefined + ); + } else { + obj.reservedRange = []; + } + if (message.reservedName) { + obj.reservedName = message.reservedName.map((e) => e); + } else { + obj.reservedName = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): EnumDescriptorProto { + const message = { ...baseEnumDescriptorProto } as EnumDescriptorProto; + message.value = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.value !== undefined && object.value !== null) { + for (const e of object.value) { + message.value.push(EnumValueDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push( + EnumDescriptorProto_EnumReservedRange.fromPartial(e) + ); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(e); + } + } + return message; + }, +}; + +const baseEnumDescriptorProto_EnumReservedRange: object = { start: 0, end: 0 }; + +export const EnumDescriptorProto_EnumReservedRange = { + encode( + message: EnumDescriptorProto_EnumReservedRange, + writer: Writer = Writer.create() + ): Writer { + if (message.start !== 0) { + writer.uint32(8).int32(message.start); + } + if (message.end !== 0) { + writer.uint32(16).int32(message.end); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): EnumDescriptorProto_EnumReservedRange { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseEnumDescriptorProto_EnumReservedRange, + } as EnumDescriptorProto_EnumReservedRange; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.start = reader.int32(); + break; + case 2: + message.end = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumDescriptorProto_EnumReservedRange { + const message = { + ...baseEnumDescriptorProto_EnumReservedRange, + } as EnumDescriptorProto_EnumReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = Number(object.start); + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + return message; + }, + + toJSON(message: EnumDescriptorProto_EnumReservedRange): unknown { + const obj: any = {}; + message.start !== undefined && (obj.start = message.start); + message.end !== undefined && (obj.end = message.end); + return obj; + }, + + fromPartial( + object: DeepPartial + ): EnumDescriptorProto_EnumReservedRange { + const message = { + ...baseEnumDescriptorProto_EnumReservedRange, + } as EnumDescriptorProto_EnumReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = object.start; + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + return message; + }, +}; + +const baseEnumValueDescriptorProto: object = { name: "", number: 0 }; + +export const EnumValueDescriptorProto = { + encode( + message: EnumValueDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.number !== 0) { + writer.uint32(16).int32(message.number); + } + if (message.options !== undefined) { + EnumValueOptions.encode( + message.options, + writer.uint32(26).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): EnumValueDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseEnumValueDescriptorProto, + } as EnumValueDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.number = reader.int32(); + break; + case 3: + message.options = EnumValueOptions.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumValueDescriptorProto { + const message = { + ...baseEnumValueDescriptorProto, + } as EnumValueDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = Number(object.number); + } else { + message.number = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumValueOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: EnumValueDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.number !== undefined && (obj.number = message.number); + message.options !== undefined && + (obj.options = message.options + ? EnumValueOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): EnumValueDescriptorProto { + const message = { + ...baseEnumValueDescriptorProto, + } as EnumValueDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = object.number; + } else { + message.number = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumValueOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseServiceDescriptorProto: object = { name: "" }; + +export const ServiceDescriptorProto = { + encode( + message: ServiceDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + for (const v of message.method) { + MethodDescriptorProto.encode(v!, writer.uint32(18).fork()).ldelim(); + } + if (message.options !== undefined) { + ServiceOptions.encode(message.options, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ServiceDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseServiceDescriptorProto } as ServiceDescriptorProto; + message.method = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.method.push( + MethodDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 3: + message.options = ServiceOptions.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ServiceDescriptorProto { + const message = { ...baseServiceDescriptorProto } as ServiceDescriptorProto; + message.method = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.method !== undefined && object.method !== null) { + for (const e of object.method) { + message.method.push(MethodDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = ServiceOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: ServiceDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + if (message.method) { + obj.method = message.method.map((e) => + e ? MethodDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.method = []; + } + message.options !== undefined && + (obj.options = message.options + ? ServiceOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): ServiceDescriptorProto { + const message = { ...baseServiceDescriptorProto } as ServiceDescriptorProto; + message.method = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.method !== undefined && object.method !== null) { + for (const e of object.method) { + message.method.push(MethodDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = ServiceOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseMethodDescriptorProto: object = { + name: "", + inputType: "", + outputType: "", + clientStreaming: false, + serverStreaming: false, +}; + +export const MethodDescriptorProto = { + encode( + message: MethodDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.inputType !== "") { + writer.uint32(18).string(message.inputType); + } + if (message.outputType !== "") { + writer.uint32(26).string(message.outputType); + } + if (message.options !== undefined) { + MethodOptions.encode(message.options, writer.uint32(34).fork()).ldelim(); + } + if (message.clientStreaming === true) { + writer.uint32(40).bool(message.clientStreaming); + } + if (message.serverStreaming === true) { + writer.uint32(48).bool(message.serverStreaming); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MethodDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMethodDescriptorProto } as MethodDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.inputType = reader.string(); + break; + case 3: + message.outputType = reader.string(); + break; + case 4: + message.options = MethodOptions.decode(reader, reader.uint32()); + break; + case 5: + message.clientStreaming = reader.bool(); + break; + case 6: + message.serverStreaming = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MethodDescriptorProto { + const message = { ...baseMethodDescriptorProto } as MethodDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.inputType !== undefined && object.inputType !== null) { + message.inputType = String(object.inputType); + } else { + message.inputType = ""; + } + if (object.outputType !== undefined && object.outputType !== null) { + message.outputType = String(object.outputType); + } else { + message.outputType = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = MethodOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if ( + object.clientStreaming !== undefined && + object.clientStreaming !== null + ) { + message.clientStreaming = Boolean(object.clientStreaming); + } else { + message.clientStreaming = false; + } + if ( + object.serverStreaming !== undefined && + object.serverStreaming !== null + ) { + message.serverStreaming = Boolean(object.serverStreaming); + } else { + message.serverStreaming = false; + } + return message; + }, + + toJSON(message: MethodDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.inputType !== undefined && (obj.inputType = message.inputType); + message.outputType !== undefined && (obj.outputType = message.outputType); + message.options !== undefined && + (obj.options = message.options + ? MethodOptions.toJSON(message.options) + : undefined); + message.clientStreaming !== undefined && + (obj.clientStreaming = message.clientStreaming); + message.serverStreaming !== undefined && + (obj.serverStreaming = message.serverStreaming); + return obj; + }, + + fromPartial( + object: DeepPartial + ): MethodDescriptorProto { + const message = { ...baseMethodDescriptorProto } as MethodDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.inputType !== undefined && object.inputType !== null) { + message.inputType = object.inputType; + } else { + message.inputType = ""; + } + if (object.outputType !== undefined && object.outputType !== null) { + message.outputType = object.outputType; + } else { + message.outputType = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = MethodOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if ( + object.clientStreaming !== undefined && + object.clientStreaming !== null + ) { + message.clientStreaming = object.clientStreaming; + } else { + message.clientStreaming = false; + } + if ( + object.serverStreaming !== undefined && + object.serverStreaming !== null + ) { + message.serverStreaming = object.serverStreaming; + } else { + message.serverStreaming = false; + } + return message; + }, +}; + +const baseFileOptions: object = { + javaPackage: "", + javaOuterClassname: "", + javaMultipleFiles: false, + javaGenerateEqualsAndHash: false, + javaStringCheckUtf8: false, + optimizeFor: 1, + goPackage: "", + ccGenericServices: false, + javaGenericServices: false, + pyGenericServices: false, + phpGenericServices: false, + deprecated: false, + ccEnableArenas: false, + objcClassPrefix: "", + csharpNamespace: "", + swiftPrefix: "", + phpClassPrefix: "", + phpNamespace: "", + phpMetadataNamespace: "", + rubyPackage: "", +}; + +export const FileOptions = { + encode(message: FileOptions, writer: Writer = Writer.create()): Writer { + if (message.javaPackage !== "") { + writer.uint32(10).string(message.javaPackage); + } + if (message.javaOuterClassname !== "") { + writer.uint32(66).string(message.javaOuterClassname); + } + if (message.javaMultipleFiles === true) { + writer.uint32(80).bool(message.javaMultipleFiles); + } + if (message.javaGenerateEqualsAndHash === true) { + writer.uint32(160).bool(message.javaGenerateEqualsAndHash); + } + if (message.javaStringCheckUtf8 === true) { + writer.uint32(216).bool(message.javaStringCheckUtf8); + } + if (message.optimizeFor !== 1) { + writer.uint32(72).int32(message.optimizeFor); + } + if (message.goPackage !== "") { + writer.uint32(90).string(message.goPackage); + } + if (message.ccGenericServices === true) { + writer.uint32(128).bool(message.ccGenericServices); + } + if (message.javaGenericServices === true) { + writer.uint32(136).bool(message.javaGenericServices); + } + if (message.pyGenericServices === true) { + writer.uint32(144).bool(message.pyGenericServices); + } + if (message.phpGenericServices === true) { + writer.uint32(336).bool(message.phpGenericServices); + } + if (message.deprecated === true) { + writer.uint32(184).bool(message.deprecated); + } + if (message.ccEnableArenas === true) { + writer.uint32(248).bool(message.ccEnableArenas); + } + if (message.objcClassPrefix !== "") { + writer.uint32(290).string(message.objcClassPrefix); + } + if (message.csharpNamespace !== "") { + writer.uint32(298).string(message.csharpNamespace); + } + if (message.swiftPrefix !== "") { + writer.uint32(314).string(message.swiftPrefix); + } + if (message.phpClassPrefix !== "") { + writer.uint32(322).string(message.phpClassPrefix); + } + if (message.phpNamespace !== "") { + writer.uint32(330).string(message.phpNamespace); + } + if (message.phpMetadataNamespace !== "") { + writer.uint32(354).string(message.phpMetadataNamespace); + } + if (message.rubyPackage !== "") { + writer.uint32(362).string(message.rubyPackage); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FileOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFileOptions } as FileOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.javaPackage = reader.string(); + break; + case 8: + message.javaOuterClassname = reader.string(); + break; + case 10: + message.javaMultipleFiles = reader.bool(); + break; + case 20: + message.javaGenerateEqualsAndHash = reader.bool(); + break; + case 27: + message.javaStringCheckUtf8 = reader.bool(); + break; + case 9: + message.optimizeFor = reader.int32() as any; + break; + case 11: + message.goPackage = reader.string(); + break; + case 16: + message.ccGenericServices = reader.bool(); + break; + case 17: + message.javaGenericServices = reader.bool(); + break; + case 18: + message.pyGenericServices = reader.bool(); + break; + case 42: + message.phpGenericServices = reader.bool(); + break; + case 23: + message.deprecated = reader.bool(); + break; + case 31: + message.ccEnableArenas = reader.bool(); + break; + case 36: + message.objcClassPrefix = reader.string(); + break; + case 37: + message.csharpNamespace = reader.string(); + break; + case 39: + message.swiftPrefix = reader.string(); + break; + case 40: + message.phpClassPrefix = reader.string(); + break; + case 41: + message.phpNamespace = reader.string(); + break; + case 44: + message.phpMetadataNamespace = reader.string(); + break; + case 45: + message.rubyPackage = reader.string(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FileOptions { + const message = { ...baseFileOptions } as FileOptions; + message.uninterpretedOption = []; + if (object.javaPackage !== undefined && object.javaPackage !== null) { + message.javaPackage = String(object.javaPackage); + } else { + message.javaPackage = ""; + } + if ( + object.javaOuterClassname !== undefined && + object.javaOuterClassname !== null + ) { + message.javaOuterClassname = String(object.javaOuterClassname); + } else { + message.javaOuterClassname = ""; + } + if ( + object.javaMultipleFiles !== undefined && + object.javaMultipleFiles !== null + ) { + message.javaMultipleFiles = Boolean(object.javaMultipleFiles); + } else { + message.javaMultipleFiles = false; + } + if ( + object.javaGenerateEqualsAndHash !== undefined && + object.javaGenerateEqualsAndHash !== null + ) { + message.javaGenerateEqualsAndHash = Boolean( + object.javaGenerateEqualsAndHash + ); + } else { + message.javaGenerateEqualsAndHash = false; + } + if ( + object.javaStringCheckUtf8 !== undefined && + object.javaStringCheckUtf8 !== null + ) { + message.javaStringCheckUtf8 = Boolean(object.javaStringCheckUtf8); + } else { + message.javaStringCheckUtf8 = false; + } + if (object.optimizeFor !== undefined && object.optimizeFor !== null) { + message.optimizeFor = fileOptions_OptimizeModeFromJSON( + object.optimizeFor + ); + } else { + message.optimizeFor = 1; + } + if (object.goPackage !== undefined && object.goPackage !== null) { + message.goPackage = String(object.goPackage); + } else { + message.goPackage = ""; + } + if ( + object.ccGenericServices !== undefined && + object.ccGenericServices !== null + ) { + message.ccGenericServices = Boolean(object.ccGenericServices); + } else { + message.ccGenericServices = false; + } + if ( + object.javaGenericServices !== undefined && + object.javaGenericServices !== null + ) { + message.javaGenericServices = Boolean(object.javaGenericServices); + } else { + message.javaGenericServices = false; + } + if ( + object.pyGenericServices !== undefined && + object.pyGenericServices !== null + ) { + message.pyGenericServices = Boolean(object.pyGenericServices); + } else { + message.pyGenericServices = false; + } + if ( + object.phpGenericServices !== undefined && + object.phpGenericServices !== null + ) { + message.phpGenericServices = Boolean(object.phpGenericServices); + } else { + message.phpGenericServices = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if (object.ccEnableArenas !== undefined && object.ccEnableArenas !== null) { + message.ccEnableArenas = Boolean(object.ccEnableArenas); + } else { + message.ccEnableArenas = false; + } + if ( + object.objcClassPrefix !== undefined && + object.objcClassPrefix !== null + ) { + message.objcClassPrefix = String(object.objcClassPrefix); + } else { + message.objcClassPrefix = ""; + } + if ( + object.csharpNamespace !== undefined && + object.csharpNamespace !== null + ) { + message.csharpNamespace = String(object.csharpNamespace); + } else { + message.csharpNamespace = ""; + } + if (object.swiftPrefix !== undefined && object.swiftPrefix !== null) { + message.swiftPrefix = String(object.swiftPrefix); + } else { + message.swiftPrefix = ""; + } + if (object.phpClassPrefix !== undefined && object.phpClassPrefix !== null) { + message.phpClassPrefix = String(object.phpClassPrefix); + } else { + message.phpClassPrefix = ""; + } + if (object.phpNamespace !== undefined && object.phpNamespace !== null) { + message.phpNamespace = String(object.phpNamespace); + } else { + message.phpNamespace = ""; + } + if ( + object.phpMetadataNamespace !== undefined && + object.phpMetadataNamespace !== null + ) { + message.phpMetadataNamespace = String(object.phpMetadataNamespace); + } else { + message.phpMetadataNamespace = ""; + } + if (object.rubyPackage !== undefined && object.rubyPackage !== null) { + message.rubyPackage = String(object.rubyPackage); + } else { + message.rubyPackage = ""; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: FileOptions): unknown { + const obj: any = {}; + message.javaPackage !== undefined && + (obj.javaPackage = message.javaPackage); + message.javaOuterClassname !== undefined && + (obj.javaOuterClassname = message.javaOuterClassname); + message.javaMultipleFiles !== undefined && + (obj.javaMultipleFiles = message.javaMultipleFiles); + message.javaGenerateEqualsAndHash !== undefined && + (obj.javaGenerateEqualsAndHash = message.javaGenerateEqualsAndHash); + message.javaStringCheckUtf8 !== undefined && + (obj.javaStringCheckUtf8 = message.javaStringCheckUtf8); + message.optimizeFor !== undefined && + (obj.optimizeFor = fileOptions_OptimizeModeToJSON(message.optimizeFor)); + message.goPackage !== undefined && (obj.goPackage = message.goPackage); + message.ccGenericServices !== undefined && + (obj.ccGenericServices = message.ccGenericServices); + message.javaGenericServices !== undefined && + (obj.javaGenericServices = message.javaGenericServices); + message.pyGenericServices !== undefined && + (obj.pyGenericServices = message.pyGenericServices); + message.phpGenericServices !== undefined && + (obj.phpGenericServices = message.phpGenericServices); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.ccEnableArenas !== undefined && + (obj.ccEnableArenas = message.ccEnableArenas); + message.objcClassPrefix !== undefined && + (obj.objcClassPrefix = message.objcClassPrefix); + message.csharpNamespace !== undefined && + (obj.csharpNamespace = message.csharpNamespace); + message.swiftPrefix !== undefined && + (obj.swiftPrefix = message.swiftPrefix); + message.phpClassPrefix !== undefined && + (obj.phpClassPrefix = message.phpClassPrefix); + message.phpNamespace !== undefined && + (obj.phpNamespace = message.phpNamespace); + message.phpMetadataNamespace !== undefined && + (obj.phpMetadataNamespace = message.phpMetadataNamespace); + message.rubyPackage !== undefined && + (obj.rubyPackage = message.rubyPackage); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): FileOptions { + const message = { ...baseFileOptions } as FileOptions; + message.uninterpretedOption = []; + if (object.javaPackage !== undefined && object.javaPackage !== null) { + message.javaPackage = object.javaPackage; + } else { + message.javaPackage = ""; + } + if ( + object.javaOuterClassname !== undefined && + object.javaOuterClassname !== null + ) { + message.javaOuterClassname = object.javaOuterClassname; + } else { + message.javaOuterClassname = ""; + } + if ( + object.javaMultipleFiles !== undefined && + object.javaMultipleFiles !== null + ) { + message.javaMultipleFiles = object.javaMultipleFiles; + } else { + message.javaMultipleFiles = false; + } + if ( + object.javaGenerateEqualsAndHash !== undefined && + object.javaGenerateEqualsAndHash !== null + ) { + message.javaGenerateEqualsAndHash = object.javaGenerateEqualsAndHash; + } else { + message.javaGenerateEqualsAndHash = false; + } + if ( + object.javaStringCheckUtf8 !== undefined && + object.javaStringCheckUtf8 !== null + ) { + message.javaStringCheckUtf8 = object.javaStringCheckUtf8; + } else { + message.javaStringCheckUtf8 = false; + } + if (object.optimizeFor !== undefined && object.optimizeFor !== null) { + message.optimizeFor = object.optimizeFor; + } else { + message.optimizeFor = 1; + } + if (object.goPackage !== undefined && object.goPackage !== null) { + message.goPackage = object.goPackage; + } else { + message.goPackage = ""; + } + if ( + object.ccGenericServices !== undefined && + object.ccGenericServices !== null + ) { + message.ccGenericServices = object.ccGenericServices; + } else { + message.ccGenericServices = false; + } + if ( + object.javaGenericServices !== undefined && + object.javaGenericServices !== null + ) { + message.javaGenericServices = object.javaGenericServices; + } else { + message.javaGenericServices = false; + } + if ( + object.pyGenericServices !== undefined && + object.pyGenericServices !== null + ) { + message.pyGenericServices = object.pyGenericServices; + } else { + message.pyGenericServices = false; + } + if ( + object.phpGenericServices !== undefined && + object.phpGenericServices !== null + ) { + message.phpGenericServices = object.phpGenericServices; + } else { + message.phpGenericServices = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if (object.ccEnableArenas !== undefined && object.ccEnableArenas !== null) { + message.ccEnableArenas = object.ccEnableArenas; + } else { + message.ccEnableArenas = false; + } + if ( + object.objcClassPrefix !== undefined && + object.objcClassPrefix !== null + ) { + message.objcClassPrefix = object.objcClassPrefix; + } else { + message.objcClassPrefix = ""; + } + if ( + object.csharpNamespace !== undefined && + object.csharpNamespace !== null + ) { + message.csharpNamespace = object.csharpNamespace; + } else { + message.csharpNamespace = ""; + } + if (object.swiftPrefix !== undefined && object.swiftPrefix !== null) { + message.swiftPrefix = object.swiftPrefix; + } else { + message.swiftPrefix = ""; + } + if (object.phpClassPrefix !== undefined && object.phpClassPrefix !== null) { + message.phpClassPrefix = object.phpClassPrefix; + } else { + message.phpClassPrefix = ""; + } + if (object.phpNamespace !== undefined && object.phpNamespace !== null) { + message.phpNamespace = object.phpNamespace; + } else { + message.phpNamespace = ""; + } + if ( + object.phpMetadataNamespace !== undefined && + object.phpMetadataNamespace !== null + ) { + message.phpMetadataNamespace = object.phpMetadataNamespace; + } else { + message.phpMetadataNamespace = ""; + } + if (object.rubyPackage !== undefined && object.rubyPackage !== null) { + message.rubyPackage = object.rubyPackage; + } else { + message.rubyPackage = ""; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseMessageOptions: object = { + messageSetWireFormat: false, + noStandardDescriptorAccessor: false, + deprecated: false, + mapEntry: false, +}; + +export const MessageOptions = { + encode(message: MessageOptions, writer: Writer = Writer.create()): Writer { + if (message.messageSetWireFormat === true) { + writer.uint32(8).bool(message.messageSetWireFormat); + } + if (message.noStandardDescriptorAccessor === true) { + writer.uint32(16).bool(message.noStandardDescriptorAccessor); + } + if (message.deprecated === true) { + writer.uint32(24).bool(message.deprecated); + } + if (message.mapEntry === true) { + writer.uint32(56).bool(message.mapEntry); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MessageOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMessageOptions } as MessageOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.messageSetWireFormat = reader.bool(); + break; + case 2: + message.noStandardDescriptorAccessor = reader.bool(); + break; + case 3: + message.deprecated = reader.bool(); + break; + case 7: + message.mapEntry = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MessageOptions { + const message = { ...baseMessageOptions } as MessageOptions; + message.uninterpretedOption = []; + if ( + object.messageSetWireFormat !== undefined && + object.messageSetWireFormat !== null + ) { + message.messageSetWireFormat = Boolean(object.messageSetWireFormat); + } else { + message.messageSetWireFormat = false; + } + if ( + object.noStandardDescriptorAccessor !== undefined && + object.noStandardDescriptorAccessor !== null + ) { + message.noStandardDescriptorAccessor = Boolean( + object.noStandardDescriptorAccessor + ); + } else { + message.noStandardDescriptorAccessor = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if (object.mapEntry !== undefined && object.mapEntry !== null) { + message.mapEntry = Boolean(object.mapEntry); + } else { + message.mapEntry = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: MessageOptions): unknown { + const obj: any = {}; + message.messageSetWireFormat !== undefined && + (obj.messageSetWireFormat = message.messageSetWireFormat); + message.noStandardDescriptorAccessor !== undefined && + (obj.noStandardDescriptorAccessor = message.noStandardDescriptorAccessor); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.mapEntry !== undefined && (obj.mapEntry = message.mapEntry); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): MessageOptions { + const message = { ...baseMessageOptions } as MessageOptions; + message.uninterpretedOption = []; + if ( + object.messageSetWireFormat !== undefined && + object.messageSetWireFormat !== null + ) { + message.messageSetWireFormat = object.messageSetWireFormat; + } else { + message.messageSetWireFormat = false; + } + if ( + object.noStandardDescriptorAccessor !== undefined && + object.noStandardDescriptorAccessor !== null + ) { + message.noStandardDescriptorAccessor = + object.noStandardDescriptorAccessor; + } else { + message.noStandardDescriptorAccessor = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if (object.mapEntry !== undefined && object.mapEntry !== null) { + message.mapEntry = object.mapEntry; + } else { + message.mapEntry = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseFieldOptions: object = { + ctype: 0, + packed: false, + jstype: 0, + lazy: false, + deprecated: false, + weak: false, +}; + +export const FieldOptions = { + encode(message: FieldOptions, writer: Writer = Writer.create()): Writer { + if (message.ctype !== 0) { + writer.uint32(8).int32(message.ctype); + } + if (message.packed === true) { + writer.uint32(16).bool(message.packed); + } + if (message.jstype !== 0) { + writer.uint32(48).int32(message.jstype); + } + if (message.lazy === true) { + writer.uint32(40).bool(message.lazy); + } + if (message.deprecated === true) { + writer.uint32(24).bool(message.deprecated); + } + if (message.weak === true) { + writer.uint32(80).bool(message.weak); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FieldOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFieldOptions } as FieldOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.ctype = reader.int32() as any; + break; + case 2: + message.packed = reader.bool(); + break; + case 6: + message.jstype = reader.int32() as any; + break; + case 5: + message.lazy = reader.bool(); + break; + case 3: + message.deprecated = reader.bool(); + break; + case 10: + message.weak = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FieldOptions { + const message = { ...baseFieldOptions } as FieldOptions; + message.uninterpretedOption = []; + if (object.ctype !== undefined && object.ctype !== null) { + message.ctype = fieldOptions_CTypeFromJSON(object.ctype); + } else { + message.ctype = 0; + } + if (object.packed !== undefined && object.packed !== null) { + message.packed = Boolean(object.packed); + } else { + message.packed = false; + } + if (object.jstype !== undefined && object.jstype !== null) { + message.jstype = fieldOptions_JSTypeFromJSON(object.jstype); + } else { + message.jstype = 0; + } + if (object.lazy !== undefined && object.lazy !== null) { + message.lazy = Boolean(object.lazy); + } else { + message.lazy = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if (object.weak !== undefined && object.weak !== null) { + message.weak = Boolean(object.weak); + } else { + message.weak = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: FieldOptions): unknown { + const obj: any = {}; + message.ctype !== undefined && + (obj.ctype = fieldOptions_CTypeToJSON(message.ctype)); + message.packed !== undefined && (obj.packed = message.packed); + message.jstype !== undefined && + (obj.jstype = fieldOptions_JSTypeToJSON(message.jstype)); + message.lazy !== undefined && (obj.lazy = message.lazy); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.weak !== undefined && (obj.weak = message.weak); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): FieldOptions { + const message = { ...baseFieldOptions } as FieldOptions; + message.uninterpretedOption = []; + if (object.ctype !== undefined && object.ctype !== null) { + message.ctype = object.ctype; + } else { + message.ctype = 0; + } + if (object.packed !== undefined && object.packed !== null) { + message.packed = object.packed; + } else { + message.packed = false; + } + if (object.jstype !== undefined && object.jstype !== null) { + message.jstype = object.jstype; + } else { + message.jstype = 0; + } + if (object.lazy !== undefined && object.lazy !== null) { + message.lazy = object.lazy; + } else { + message.lazy = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if (object.weak !== undefined && object.weak !== null) { + message.weak = object.weak; + } else { + message.weak = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseOneofOptions: object = {}; + +export const OneofOptions = { + encode(message: OneofOptions, writer: Writer = Writer.create()): Writer { + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): OneofOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseOneofOptions } as OneofOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): OneofOptions { + const message = { ...baseOneofOptions } as OneofOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: OneofOptions): unknown { + const obj: any = {}; + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): OneofOptions { + const message = { ...baseOneofOptions } as OneofOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseEnumOptions: object = { allowAlias: false, deprecated: false }; + +export const EnumOptions = { + encode(message: EnumOptions, writer: Writer = Writer.create()): Writer { + if (message.allowAlias === true) { + writer.uint32(16).bool(message.allowAlias); + } + if (message.deprecated === true) { + writer.uint32(24).bool(message.deprecated); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): EnumOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseEnumOptions } as EnumOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + message.allowAlias = reader.bool(); + break; + case 3: + message.deprecated = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumOptions { + const message = { ...baseEnumOptions } as EnumOptions; + message.uninterpretedOption = []; + if (object.allowAlias !== undefined && object.allowAlias !== null) { + message.allowAlias = Boolean(object.allowAlias); + } else { + message.allowAlias = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: EnumOptions): unknown { + const obj: any = {}; + message.allowAlias !== undefined && (obj.allowAlias = message.allowAlias); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): EnumOptions { + const message = { ...baseEnumOptions } as EnumOptions; + message.uninterpretedOption = []; + if (object.allowAlias !== undefined && object.allowAlias !== null) { + message.allowAlias = object.allowAlias; + } else { + message.allowAlias = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseEnumValueOptions: object = { deprecated: false }; + +export const EnumValueOptions = { + encode(message: EnumValueOptions, writer: Writer = Writer.create()): Writer { + if (message.deprecated === true) { + writer.uint32(8).bool(message.deprecated); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): EnumValueOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseEnumValueOptions } as EnumValueOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.deprecated = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumValueOptions { + const message = { ...baseEnumValueOptions } as EnumValueOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: EnumValueOptions): unknown { + const obj: any = {}; + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): EnumValueOptions { + const message = { ...baseEnumValueOptions } as EnumValueOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseServiceOptions: object = { deprecated: false }; + +export const ServiceOptions = { + encode(message: ServiceOptions, writer: Writer = Writer.create()): Writer { + if (message.deprecated === true) { + writer.uint32(264).bool(message.deprecated); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ServiceOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseServiceOptions } as ServiceOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 33: + message.deprecated = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ServiceOptions { + const message = { ...baseServiceOptions } as ServiceOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: ServiceOptions): unknown { + const obj: any = {}; + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): ServiceOptions { + const message = { ...baseServiceOptions } as ServiceOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseMethodOptions: object = { deprecated: false, idempotencyLevel: 0 }; + +export const MethodOptions = { + encode(message: MethodOptions, writer: Writer = Writer.create()): Writer { + if (message.deprecated === true) { + writer.uint32(264).bool(message.deprecated); + } + if (message.idempotencyLevel !== 0) { + writer.uint32(272).int32(message.idempotencyLevel); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MethodOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMethodOptions } as MethodOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 33: + message.deprecated = reader.bool(); + break; + case 34: + message.idempotencyLevel = reader.int32() as any; + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MethodOptions { + const message = { ...baseMethodOptions } as MethodOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.idempotencyLevel !== undefined && + object.idempotencyLevel !== null + ) { + message.idempotencyLevel = methodOptions_IdempotencyLevelFromJSON( + object.idempotencyLevel + ); + } else { + message.idempotencyLevel = 0; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: MethodOptions): unknown { + const obj: any = {}; + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.idempotencyLevel !== undefined && + (obj.idempotencyLevel = methodOptions_IdempotencyLevelToJSON( + message.idempotencyLevel + )); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): MethodOptions { + const message = { ...baseMethodOptions } as MethodOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.idempotencyLevel !== undefined && + object.idempotencyLevel !== null + ) { + message.idempotencyLevel = object.idempotencyLevel; + } else { + message.idempotencyLevel = 0; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseUninterpretedOption: object = { + identifierValue: "", + positiveIntValue: 0, + negativeIntValue: 0, + doubleValue: 0, + aggregateValue: "", +}; + +export const UninterpretedOption = { + encode( + message: UninterpretedOption, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.name) { + UninterpretedOption_NamePart.encode( + v!, + writer.uint32(18).fork() + ).ldelim(); + } + if (message.identifierValue !== "") { + writer.uint32(26).string(message.identifierValue); + } + if (message.positiveIntValue !== 0) { + writer.uint32(32).uint64(message.positiveIntValue); + } + if (message.negativeIntValue !== 0) { + writer.uint32(40).int64(message.negativeIntValue); + } + if (message.doubleValue !== 0) { + writer.uint32(49).double(message.doubleValue); + } + if (message.stringValue.length !== 0) { + writer.uint32(58).bytes(message.stringValue); + } + if (message.aggregateValue !== "") { + writer.uint32(66).string(message.aggregateValue); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): UninterpretedOption { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseUninterpretedOption } as UninterpretedOption; + message.name = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + message.name.push( + UninterpretedOption_NamePart.decode(reader, reader.uint32()) + ); + break; + case 3: + message.identifierValue = reader.string(); + break; + case 4: + message.positiveIntValue = longToNumber(reader.uint64() as Long); + break; + case 5: + message.negativeIntValue = longToNumber(reader.int64() as Long); + break; + case 6: + message.doubleValue = reader.double(); + break; + case 7: + message.stringValue = reader.bytes(); + break; + case 8: + message.aggregateValue = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): UninterpretedOption { + const message = { ...baseUninterpretedOption } as UninterpretedOption; + message.name = []; + if (object.name !== undefined && object.name !== null) { + for (const e of object.name) { + message.name.push(UninterpretedOption_NamePart.fromJSON(e)); + } + } + if ( + object.identifierValue !== undefined && + object.identifierValue !== null + ) { + message.identifierValue = String(object.identifierValue); + } else { + message.identifierValue = ""; + } + if ( + object.positiveIntValue !== undefined && + object.positiveIntValue !== null + ) { + message.positiveIntValue = Number(object.positiveIntValue); + } else { + message.positiveIntValue = 0; + } + if ( + object.negativeIntValue !== undefined && + object.negativeIntValue !== null + ) { + message.negativeIntValue = Number(object.negativeIntValue); + } else { + message.negativeIntValue = 0; + } + if (object.doubleValue !== undefined && object.doubleValue !== null) { + message.doubleValue = Number(object.doubleValue); + } else { + message.doubleValue = 0; + } + if (object.stringValue !== undefined && object.stringValue !== null) { + message.stringValue = bytesFromBase64(object.stringValue); + } + if (object.aggregateValue !== undefined && object.aggregateValue !== null) { + message.aggregateValue = String(object.aggregateValue); + } else { + message.aggregateValue = ""; + } + return message; + }, + + toJSON(message: UninterpretedOption): unknown { + const obj: any = {}; + if (message.name) { + obj.name = message.name.map((e) => + e ? UninterpretedOption_NamePart.toJSON(e) : undefined + ); + } else { + obj.name = []; + } + message.identifierValue !== undefined && + (obj.identifierValue = message.identifierValue); + message.positiveIntValue !== undefined && + (obj.positiveIntValue = message.positiveIntValue); + message.negativeIntValue !== undefined && + (obj.negativeIntValue = message.negativeIntValue); + message.doubleValue !== undefined && + (obj.doubleValue = message.doubleValue); + message.stringValue !== undefined && + (obj.stringValue = base64FromBytes( + message.stringValue !== undefined + ? message.stringValue + : new Uint8Array() + )); + message.aggregateValue !== undefined && + (obj.aggregateValue = message.aggregateValue); + return obj; + }, + + fromPartial(object: DeepPartial): UninterpretedOption { + const message = { ...baseUninterpretedOption } as UninterpretedOption; + message.name = []; + if (object.name !== undefined && object.name !== null) { + for (const e of object.name) { + message.name.push(UninterpretedOption_NamePart.fromPartial(e)); + } + } + if ( + object.identifierValue !== undefined && + object.identifierValue !== null + ) { + message.identifierValue = object.identifierValue; + } else { + message.identifierValue = ""; + } + if ( + object.positiveIntValue !== undefined && + object.positiveIntValue !== null + ) { + message.positiveIntValue = object.positiveIntValue; + } else { + message.positiveIntValue = 0; + } + if ( + object.negativeIntValue !== undefined && + object.negativeIntValue !== null + ) { + message.negativeIntValue = object.negativeIntValue; + } else { + message.negativeIntValue = 0; + } + if (object.doubleValue !== undefined && object.doubleValue !== null) { + message.doubleValue = object.doubleValue; + } else { + message.doubleValue = 0; + } + if (object.stringValue !== undefined && object.stringValue !== null) { + message.stringValue = object.stringValue; + } else { + message.stringValue = new Uint8Array(); + } + if (object.aggregateValue !== undefined && object.aggregateValue !== null) { + message.aggregateValue = object.aggregateValue; + } else { + message.aggregateValue = ""; + } + return message; + }, +}; + +const baseUninterpretedOption_NamePart: object = { + namePart: "", + isExtension: false, +}; + +export const UninterpretedOption_NamePart = { + encode( + message: UninterpretedOption_NamePart, + writer: Writer = Writer.create() + ): Writer { + if (message.namePart !== "") { + writer.uint32(10).string(message.namePart); + } + if (message.isExtension === true) { + writer.uint32(16).bool(message.isExtension); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): UninterpretedOption_NamePart { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseUninterpretedOption_NamePart, + } as UninterpretedOption_NamePart; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.namePart = reader.string(); + break; + case 2: + message.isExtension = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): UninterpretedOption_NamePart { + const message = { + ...baseUninterpretedOption_NamePart, + } as UninterpretedOption_NamePart; + if (object.namePart !== undefined && object.namePart !== null) { + message.namePart = String(object.namePart); + } else { + message.namePart = ""; + } + if (object.isExtension !== undefined && object.isExtension !== null) { + message.isExtension = Boolean(object.isExtension); + } else { + message.isExtension = false; + } + return message; + }, + + toJSON(message: UninterpretedOption_NamePart): unknown { + const obj: any = {}; + message.namePart !== undefined && (obj.namePart = message.namePart); + message.isExtension !== undefined && + (obj.isExtension = message.isExtension); + return obj; + }, + + fromPartial( + object: DeepPartial + ): UninterpretedOption_NamePart { + const message = { + ...baseUninterpretedOption_NamePart, + } as UninterpretedOption_NamePart; + if (object.namePart !== undefined && object.namePart !== null) { + message.namePart = object.namePart; + } else { + message.namePart = ""; + } + if (object.isExtension !== undefined && object.isExtension !== null) { + message.isExtension = object.isExtension; + } else { + message.isExtension = false; + } + return message; + }, +}; + +const baseSourceCodeInfo: object = {}; + +export const SourceCodeInfo = { + encode(message: SourceCodeInfo, writer: Writer = Writer.create()): Writer { + for (const v of message.location) { + SourceCodeInfo_Location.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): SourceCodeInfo { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseSourceCodeInfo } as SourceCodeInfo; + message.location = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.location.push( + SourceCodeInfo_Location.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): SourceCodeInfo { + const message = { ...baseSourceCodeInfo } as SourceCodeInfo; + message.location = []; + if (object.location !== undefined && object.location !== null) { + for (const e of object.location) { + message.location.push(SourceCodeInfo_Location.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: SourceCodeInfo): unknown { + const obj: any = {}; + if (message.location) { + obj.location = message.location.map((e) => + e ? SourceCodeInfo_Location.toJSON(e) : undefined + ); + } else { + obj.location = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): SourceCodeInfo { + const message = { ...baseSourceCodeInfo } as SourceCodeInfo; + message.location = []; + if (object.location !== undefined && object.location !== null) { + for (const e of object.location) { + message.location.push(SourceCodeInfo_Location.fromPartial(e)); + } + } + return message; + }, +}; + +const baseSourceCodeInfo_Location: object = { + path: 0, + span: 0, + leadingComments: "", + trailingComments: "", + leadingDetachedComments: "", +}; + +export const SourceCodeInfo_Location = { + encode( + message: SourceCodeInfo_Location, + writer: Writer = Writer.create() + ): Writer { + writer.uint32(10).fork(); + for (const v of message.path) { + writer.int32(v); + } + writer.ldelim(); + writer.uint32(18).fork(); + for (const v of message.span) { + writer.int32(v); + } + writer.ldelim(); + if (message.leadingComments !== "") { + writer.uint32(26).string(message.leadingComments); + } + if (message.trailingComments !== "") { + writer.uint32(34).string(message.trailingComments); + } + for (const v of message.leadingDetachedComments) { + writer.uint32(50).string(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): SourceCodeInfo_Location { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseSourceCodeInfo_Location, + } as SourceCodeInfo_Location; + message.path = []; + message.span = []; + message.leadingDetachedComments = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.path.push(reader.int32()); + } + } else { + message.path.push(reader.int32()); + } + break; + case 2: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.span.push(reader.int32()); + } + } else { + message.span.push(reader.int32()); + } + break; + case 3: + message.leadingComments = reader.string(); + break; + case 4: + message.trailingComments = reader.string(); + break; + case 6: + message.leadingDetachedComments.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): SourceCodeInfo_Location { + const message = { + ...baseSourceCodeInfo_Location, + } as SourceCodeInfo_Location; + message.path = []; + message.span = []; + message.leadingDetachedComments = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(Number(e)); + } + } + if (object.span !== undefined && object.span !== null) { + for (const e of object.span) { + message.span.push(Number(e)); + } + } + if ( + object.leadingComments !== undefined && + object.leadingComments !== null + ) { + message.leadingComments = String(object.leadingComments); + } else { + message.leadingComments = ""; + } + if ( + object.trailingComments !== undefined && + object.trailingComments !== null + ) { + message.trailingComments = String(object.trailingComments); + } else { + message.trailingComments = ""; + } + if ( + object.leadingDetachedComments !== undefined && + object.leadingDetachedComments !== null + ) { + for (const e of object.leadingDetachedComments) { + message.leadingDetachedComments.push(String(e)); + } + } + return message; + }, + + toJSON(message: SourceCodeInfo_Location): unknown { + const obj: any = {}; + if (message.path) { + obj.path = message.path.map((e) => e); + } else { + obj.path = []; + } + if (message.span) { + obj.span = message.span.map((e) => e); + } else { + obj.span = []; + } + message.leadingComments !== undefined && + (obj.leadingComments = message.leadingComments); + message.trailingComments !== undefined && + (obj.trailingComments = message.trailingComments); + if (message.leadingDetachedComments) { + obj.leadingDetachedComments = message.leadingDetachedComments.map( + (e) => e + ); + } else { + obj.leadingDetachedComments = []; + } + return obj; + }, + + fromPartial( + object: DeepPartial + ): SourceCodeInfo_Location { + const message = { + ...baseSourceCodeInfo_Location, + } as SourceCodeInfo_Location; + message.path = []; + message.span = []; + message.leadingDetachedComments = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(e); + } + } + if (object.span !== undefined && object.span !== null) { + for (const e of object.span) { + message.span.push(e); + } + } + if ( + object.leadingComments !== undefined && + object.leadingComments !== null + ) { + message.leadingComments = object.leadingComments; + } else { + message.leadingComments = ""; + } + if ( + object.trailingComments !== undefined && + object.trailingComments !== null + ) { + message.trailingComments = object.trailingComments; + } else { + message.trailingComments = ""; + } + if ( + object.leadingDetachedComments !== undefined && + object.leadingDetachedComments !== null + ) { + for (const e of object.leadingDetachedComments) { + message.leadingDetachedComments.push(e); + } + } + return message; + }, +}; + +const baseGeneratedCodeInfo: object = {}; + +export const GeneratedCodeInfo = { + encode(message: GeneratedCodeInfo, writer: Writer = Writer.create()): Writer { + for (const v of message.annotation) { + GeneratedCodeInfo_Annotation.encode( + v!, + writer.uint32(10).fork() + ).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): GeneratedCodeInfo { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseGeneratedCodeInfo } as GeneratedCodeInfo; + message.annotation = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.annotation.push( + GeneratedCodeInfo_Annotation.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GeneratedCodeInfo { + const message = { ...baseGeneratedCodeInfo } as GeneratedCodeInfo; + message.annotation = []; + if (object.annotation !== undefined && object.annotation !== null) { + for (const e of object.annotation) { + message.annotation.push(GeneratedCodeInfo_Annotation.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: GeneratedCodeInfo): unknown { + const obj: any = {}; + if (message.annotation) { + obj.annotation = message.annotation.map((e) => + e ? GeneratedCodeInfo_Annotation.toJSON(e) : undefined + ); + } else { + obj.annotation = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): GeneratedCodeInfo { + const message = { ...baseGeneratedCodeInfo } as GeneratedCodeInfo; + message.annotation = []; + if (object.annotation !== undefined && object.annotation !== null) { + for (const e of object.annotation) { + message.annotation.push(GeneratedCodeInfo_Annotation.fromPartial(e)); + } + } + return message; + }, +}; + +const baseGeneratedCodeInfo_Annotation: object = { + path: 0, + sourceFile: "", + begin: 0, + end: 0, +}; + +export const GeneratedCodeInfo_Annotation = { + encode( + message: GeneratedCodeInfo_Annotation, + writer: Writer = Writer.create() + ): Writer { + writer.uint32(10).fork(); + for (const v of message.path) { + writer.int32(v); + } + writer.ldelim(); + if (message.sourceFile !== "") { + writer.uint32(18).string(message.sourceFile); + } + if (message.begin !== 0) { + writer.uint32(24).int32(message.begin); + } + if (message.end !== 0) { + writer.uint32(32).int32(message.end); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): GeneratedCodeInfo_Annotation { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseGeneratedCodeInfo_Annotation, + } as GeneratedCodeInfo_Annotation; + message.path = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.path.push(reader.int32()); + } + } else { + message.path.push(reader.int32()); + } + break; + case 2: + message.sourceFile = reader.string(); + break; + case 3: + message.begin = reader.int32(); + break; + case 4: + message.end = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GeneratedCodeInfo_Annotation { + const message = { + ...baseGeneratedCodeInfo_Annotation, + } as GeneratedCodeInfo_Annotation; + message.path = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(Number(e)); + } + } + if (object.sourceFile !== undefined && object.sourceFile !== null) { + message.sourceFile = String(object.sourceFile); + } else { + message.sourceFile = ""; + } + if (object.begin !== undefined && object.begin !== null) { + message.begin = Number(object.begin); + } else { + message.begin = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + return message; + }, + + toJSON(message: GeneratedCodeInfo_Annotation): unknown { + const obj: any = {}; + if (message.path) { + obj.path = message.path.map((e) => e); + } else { + obj.path = []; + } + message.sourceFile !== undefined && (obj.sourceFile = message.sourceFile); + message.begin !== undefined && (obj.begin = message.begin); + message.end !== undefined && (obj.end = message.end); + return obj; + }, + + fromPartial( + object: DeepPartial + ): GeneratedCodeInfo_Annotation { + const message = { + ...baseGeneratedCodeInfo_Annotation, + } as GeneratedCodeInfo_Annotation; + message.path = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(e); + } + } + if (object.sourceFile !== undefined && object.sourceFile !== null) { + message.sourceFile = object.sourceFile; + } else { + message.sourceFile = ""; + } + if (object.begin !== undefined && object.begin !== null) { + message.begin = object.begin; + } else { + message.begin = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/bze.epochs.v1/types/google/protobuf/duration.ts b/ts-client/bze.epochs.v1/types/google/protobuf/duration.ts new file mode 100644 index 00000000..fffd5b14 --- /dev/null +++ b/ts-client/bze.epochs.v1/types/google/protobuf/duration.ts @@ -0,0 +1,188 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "google.protobuf"; + +/** + * A Duration represents a signed, fixed-length span of time represented + * as a count of seconds and fractions of seconds at nanosecond + * resolution. It is independent of any calendar and concepts like "day" + * or "month". It is related to Timestamp in that the difference between + * two Timestamp values is a Duration and it can be added or subtracted + * from a Timestamp. Range is approximately +-10,000 years. + * + * # Examples + * + * Example 1: Compute Duration from two Timestamps in pseudo code. + * + * Timestamp start = ...; + * Timestamp end = ...; + * Duration duration = ...; + * + * duration.seconds = end.seconds - start.seconds; + * duration.nanos = end.nanos - start.nanos; + * + * if (duration.seconds < 0 && duration.nanos > 0) { + * duration.seconds += 1; + * duration.nanos -= 1000000000; + * } else if (duration.seconds > 0 && duration.nanos < 0) { + * duration.seconds -= 1; + * duration.nanos += 1000000000; + * } + * + * Example 2: Compute Timestamp from Timestamp + Duration in pseudo code. + * + * Timestamp start = ...; + * Duration duration = ...; + * Timestamp end = ...; + * + * end.seconds = start.seconds + duration.seconds; + * end.nanos = start.nanos + duration.nanos; + * + * if (end.nanos < 0) { + * end.seconds -= 1; + * end.nanos += 1000000000; + * } else if (end.nanos >= 1000000000) { + * end.seconds += 1; + * end.nanos -= 1000000000; + * } + * + * Example 3: Compute Duration from datetime.timedelta in Python. + * + * td = datetime.timedelta(days=3, minutes=10) + * duration = Duration() + * duration.FromTimedelta(td) + * + * # JSON Mapping + * + * In JSON format, the Duration type is encoded as a string rather than an + * object, where the string ends in the suffix "s" (indicating seconds) and + * is preceded by the number of seconds, with nanoseconds expressed as + * fractional seconds. For example, 3 seconds with 0 nanoseconds should be + * encoded in JSON format as "3s", while 3 seconds and 1 nanosecond should + * be expressed in JSON format as "3.000000001s", and 3 seconds and 1 + * microsecond should be expressed in JSON format as "3.000001s". + */ +export interface Duration { + /** + * Signed seconds of the span of time. Must be from -315,576,000,000 + * to +315,576,000,000 inclusive. Note: these bounds are computed from: + * 60 sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years + */ + seconds: number; + /** + * Signed fractions of a second at nanosecond resolution of the span + * of time. Durations less than one second are represented with a 0 + * `seconds` field and a positive or negative `nanos` field. For durations + * of one second or more, a non-zero value for the `nanos` field must be + * of the same sign as the `seconds` field. Must be from -999,999,999 + * to +999,999,999 inclusive. + */ + nanos: number; +} + +const baseDuration: object = { seconds: 0, nanos: 0 }; + +export const Duration = { + encode(message: Duration, writer: Writer = Writer.create()): Writer { + if (message.seconds !== 0) { + writer.uint32(8).int64(message.seconds); + } + if (message.nanos !== 0) { + writer.uint32(16).int32(message.nanos); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Duration { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseDuration } as Duration; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.seconds = longToNumber(reader.int64() as Long); + break; + case 2: + message.nanos = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Duration { + const message = { ...baseDuration } as Duration; + if (object.seconds !== undefined && object.seconds !== null) { + message.seconds = Number(object.seconds); + } else { + message.seconds = 0; + } + if (object.nanos !== undefined && object.nanos !== null) { + message.nanos = Number(object.nanos); + } else { + message.nanos = 0; + } + return message; + }, + + toJSON(message: Duration): unknown { + const obj: any = {}; + message.seconds !== undefined && (obj.seconds = message.seconds); + message.nanos !== undefined && (obj.nanos = message.nanos); + return obj; + }, + + fromPartial(object: DeepPartial): Duration { + const message = { ...baseDuration } as Duration; + if (object.seconds !== undefined && object.seconds !== null) { + message.seconds = object.seconds; + } else { + message.seconds = 0; + } + if (object.nanos !== undefined && object.nanos !== null) { + message.nanos = object.nanos; + } else { + message.nanos = 0; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/bze.epochs.v1/types/google/protobuf/timestamp.ts b/ts-client/bze.epochs.v1/types/google/protobuf/timestamp.ts new file mode 100644 index 00000000..11864afc --- /dev/null +++ b/ts-client/bze.epochs.v1/types/google/protobuf/timestamp.ts @@ -0,0 +1,219 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "google.protobuf"; + +/** + * A Timestamp represents a point in time independent of any time zone or local + * calendar, encoded as a count of seconds and fractions of seconds at + * nanosecond resolution. The count is relative to an epoch at UTC midnight on + * January 1, 1970, in the proleptic Gregorian calendar which extends the + * Gregorian calendar backwards to year one. + * + * All minutes are 60 seconds long. Leap seconds are "smeared" so that no leap + * second table is needed for interpretation, using a [24-hour linear + * smear](https://developers.google.com/time/smear). + * + * The range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. By + * restricting to that range, we ensure that we can convert to and from [RFC + * 3339](https://www.ietf.org/rfc/rfc3339.txt) date strings. + * + * # Examples + * + * Example 1: Compute Timestamp from POSIX `time()`. + * + * Timestamp timestamp; + * timestamp.set_seconds(time(NULL)); + * timestamp.set_nanos(0); + * + * Example 2: Compute Timestamp from POSIX `gettimeofday()`. + * + * struct timeval tv; + * gettimeofday(&tv, NULL); + * + * Timestamp timestamp; + * timestamp.set_seconds(tv.tv_sec); + * timestamp.set_nanos(tv.tv_usec * 1000); + * + * Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`. + * + * FILETIME ft; + * GetSystemTimeAsFileTime(&ft); + * UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime; + * + * // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z + * // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z. + * Timestamp timestamp; + * timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL)); + * timestamp.set_nanos((INT32) ((ticks % 10000000) * 100)); + * + * Example 4: Compute Timestamp from Java `System.currentTimeMillis()`. + * + * long millis = System.currentTimeMillis(); + * + * Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000) + * .setNanos((int) ((millis % 1000) * 1000000)).build(); + * + * + * Example 5: Compute Timestamp from Java `Instant.now()`. + * + * Instant now = Instant.now(); + * + * Timestamp timestamp = + * Timestamp.newBuilder().setSeconds(now.getEpochSecond()) + * .setNanos(now.getNano()).build(); + * + * + * Example 6: Compute Timestamp from current time in Python. + * + * timestamp = Timestamp() + * timestamp.GetCurrentTime() + * + * # JSON Mapping + * + * In JSON format, the Timestamp type is encoded as a string in the + * [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the + * format is "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z" + * where {year} is always expressed using four digits while {month}, {day}, + * {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional + * seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution), + * are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone + * is required. A proto3 JSON serializer should always use UTC (as indicated by + * "Z") when printing the Timestamp type and a proto3 JSON parser should be + * able to accept both UTC and other timezones (as indicated by an offset). + * + * For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past + * 01:30 UTC on January 15, 2017. + * + * In JavaScript, one can convert a Date object to this format using the + * standard + * [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString) + * method. In Python, a standard `datetime.datetime` object can be converted + * to this format using + * [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) with + * the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one can use + * the Joda Time's [`ISODateTimeFormat.dateTime()`]( + * http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime%2D%2D + * ) to obtain a formatter capable of generating timestamps in this format. + */ +export interface Timestamp { + /** + * Represents seconds of UTC time since Unix epoch + * 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to + * 9999-12-31T23:59:59Z inclusive. + */ + seconds: number; + /** + * Non-negative fractions of a second at nanosecond resolution. Negative + * second values with fractions must still have non-negative nanos values + * that count forward in time. Must be from 0 to 999,999,999 + * inclusive. + */ + nanos: number; +} + +const baseTimestamp: object = { seconds: 0, nanos: 0 }; + +export const Timestamp = { + encode(message: Timestamp, writer: Writer = Writer.create()): Writer { + if (message.seconds !== 0) { + writer.uint32(8).int64(message.seconds); + } + if (message.nanos !== 0) { + writer.uint32(16).int32(message.nanos); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Timestamp { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseTimestamp } as Timestamp; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.seconds = longToNumber(reader.int64() as Long); + break; + case 2: + message.nanos = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Timestamp { + const message = { ...baseTimestamp } as Timestamp; + if (object.seconds !== undefined && object.seconds !== null) { + message.seconds = Number(object.seconds); + } else { + message.seconds = 0; + } + if (object.nanos !== undefined && object.nanos !== null) { + message.nanos = Number(object.nanos); + } else { + message.nanos = 0; + } + return message; + }, + + toJSON(message: Timestamp): unknown { + const obj: any = {}; + message.seconds !== undefined && (obj.seconds = message.seconds); + message.nanos !== undefined && (obj.nanos = message.nanos); + return obj; + }, + + fromPartial(object: DeepPartial): Timestamp { + const message = { ...baseTimestamp } as Timestamp; + if (object.seconds !== undefined && object.seconds !== null) { + message.seconds = object.seconds; + } else { + message.seconds = 0; + } + if (object.nanos !== undefined && object.nanos !== null) { + message.nanos = object.nanos; + } else { + message.nanos = 0; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/bze.scavenge/index.ts b/ts-client/bze.scavenge/index.ts new file mode 100755 index 00000000..c9dfa159 --- /dev/null +++ b/ts-client/bze.scavenge/index.ts @@ -0,0 +1,6 @@ +import Module from './module'; +import { txClient, queryClient, registry } from './module'; +import { msgTypes } from './registry'; + +export * from "./types"; +export { Module, msgTypes, txClient, queryClient, registry }; diff --git a/ts-client/bze.scavenge/module.ts b/ts-client/bze.scavenge/module.ts new file mode 100755 index 00000000..4c85757e --- /dev/null +++ b/ts-client/bze.scavenge/module.ts @@ -0,0 +1,165 @@ +// Generated by Ignite ignite.com/cli + +import { StdFee } from "@cosmjs/launchpad"; +import { SigningStargateClient, DeliverTxResponse } from "@cosmjs/stargate"; +import { EncodeObject, GeneratedType, OfflineSigner, Registry } from "@cosmjs/proto-signing"; +import { msgTypes } from './registry'; +import { IgniteClient } from "../client" +import { MissingWalletError } from "../helpers" +import { Api } from "./rest"; +import { MsgSubmitScavenge } from "./types/scavenge/tx"; +import { MsgCommitSolution } from "./types/scavenge/tx"; +import { MsgRevealSolution } from "./types/scavenge/tx"; + + +export { MsgSubmitScavenge, MsgCommitSolution, MsgRevealSolution }; + +type sendMsgSubmitScavengeParams = { + value: MsgSubmitScavenge, + fee?: StdFee, + memo?: string +}; + +type sendMsgCommitSolutionParams = { + value: MsgCommitSolution, + fee?: StdFee, + memo?: string +}; + +type sendMsgRevealSolutionParams = { + value: MsgRevealSolution, + fee?: StdFee, + memo?: string +}; + + +type msgSubmitScavengeParams = { + value: MsgSubmitScavenge, +}; + +type msgCommitSolutionParams = { + value: MsgCommitSolution, +}; + +type msgRevealSolutionParams = { + value: MsgRevealSolution, +}; + + +export const registry = new Registry(msgTypes); + +const defaultFee = { + amount: [], + gas: "200000", +}; + +interface TxClientOptions { + addr: string + prefix: string + signer?: OfflineSigner +} + +export const txClient = ({ signer, prefix, addr }: TxClientOptions = { addr: "http://localhost:26657", prefix: "cosmos" }) => { + + return { + + async sendMsgSubmitScavenge({ value, fee, memo }: sendMsgSubmitScavengeParams): Promise { + if (!signer) { + throw new Error('TxClient:sendMsgSubmitScavenge: Unable to sign Tx. Signer is not present.') + } + try { + const { address } = (await signer.getAccounts())[0]; + const signingClient = await SigningStargateClient.connectWithSigner(addr,signer,{registry, prefix}); + let msg = this.msgSubmitScavenge({ value: MsgSubmitScavenge.fromPartial(value) }) + return await signingClient.signAndBroadcast(address, [msg], fee ? fee : defaultFee, memo) + } catch (e: any) { + throw new Error('TxClient:sendMsgSubmitScavenge: Could not broadcast Tx: '+ e.message) + } + }, + + async sendMsgCommitSolution({ value, fee, memo }: sendMsgCommitSolutionParams): Promise { + if (!signer) { + throw new Error('TxClient:sendMsgCommitSolution: Unable to sign Tx. Signer is not present.') + } + try { + const { address } = (await signer.getAccounts())[0]; + const signingClient = await SigningStargateClient.connectWithSigner(addr,signer,{registry, prefix}); + let msg = this.msgCommitSolution({ value: MsgCommitSolution.fromPartial(value) }) + return await signingClient.signAndBroadcast(address, [msg], fee ? fee : defaultFee, memo) + } catch (e: any) { + throw new Error('TxClient:sendMsgCommitSolution: Could not broadcast Tx: '+ e.message) + } + }, + + async sendMsgRevealSolution({ value, fee, memo }: sendMsgRevealSolutionParams): Promise { + if (!signer) { + throw new Error('TxClient:sendMsgRevealSolution: Unable to sign Tx. Signer is not present.') + } + try { + const { address } = (await signer.getAccounts())[0]; + const signingClient = await SigningStargateClient.connectWithSigner(addr,signer,{registry, prefix}); + let msg = this.msgRevealSolution({ value: MsgRevealSolution.fromPartial(value) }) + return await signingClient.signAndBroadcast(address, [msg], fee ? fee : defaultFee, memo) + } catch (e: any) { + throw new Error('TxClient:sendMsgRevealSolution: Could not broadcast Tx: '+ e.message) + } + }, + + + msgSubmitScavenge({ value }: msgSubmitScavengeParams): EncodeObject { + try { + return { typeUrl: "/bze.scavenge.MsgSubmitScavenge", value: MsgSubmitScavenge.fromPartial( value ) } + } catch (e: any) { + throw new Error('TxClient:MsgSubmitScavenge: Could not create message: ' + e.message) + } + }, + + msgCommitSolution({ value }: msgCommitSolutionParams): EncodeObject { + try { + return { typeUrl: "/bze.scavenge.MsgCommitSolution", value: MsgCommitSolution.fromPartial( value ) } + } catch (e: any) { + throw new Error('TxClient:MsgCommitSolution: Could not create message: ' + e.message) + } + }, + + msgRevealSolution({ value }: msgRevealSolutionParams): EncodeObject { + try { + return { typeUrl: "/bze.scavenge.MsgRevealSolution", value: MsgRevealSolution.fromPartial( value ) } + } catch (e: any) { + throw new Error('TxClient:MsgRevealSolution: Could not create message: ' + e.message) + } + }, + + } +}; + +interface QueryClientOptions { + addr: string +} + +export const queryClient = ({ addr: addr }: QueryClientOptions = { addr: "http://localhost:1317" }) => { + return new Api({ baseUrl: addr }); +}; + +class SDKModule { + public query: ReturnType; + public tx: ReturnType; + + public registry: Array<[string, GeneratedType]>; + + constructor(client: IgniteClient) { + + this.query = queryClient({ addr: client.env.apiURL }); + this.tx = txClient({ signer: client.signer, addr: client.env.rpcURL, prefix: client.env.prefix ?? "cosmos" }); + } +}; + +const Module = (test: IgniteClient) => { + return { + module: { + BzeScavenge: new SDKModule(test) + }, + registry: msgTypes + } +} +export default Module; \ No newline at end of file diff --git a/ts-client/bze.scavenge/registry.ts b/ts-client/bze.scavenge/registry.ts new file mode 100755 index 00000000..fb606ffa --- /dev/null +++ b/ts-client/bze.scavenge/registry.ts @@ -0,0 +1,13 @@ +import { GeneratedType } from "@cosmjs/proto-signing"; +import { MsgSubmitScavenge } from "./types/scavenge/tx"; +import { MsgCommitSolution } from "./types/scavenge/tx"; +import { MsgRevealSolution } from "./types/scavenge/tx"; + +const msgTypes: Array<[string, GeneratedType]> = [ + ["/bze.scavenge.MsgSubmitScavenge", MsgSubmitScavenge], + ["/bze.scavenge.MsgCommitSolution", MsgCommitSolution], + ["/bze.scavenge.MsgRevealSolution", MsgRevealSolution], + +]; + +export { msgTypes } \ No newline at end of file diff --git a/ts-client/bze.scavenge/rest.ts b/ts-client/bze.scavenge/rest.ts new file mode 100644 index 00000000..c58e0139 --- /dev/null +++ b/ts-client/bze.scavenge/rest.ts @@ -0,0 +1,424 @@ +/* eslint-disable */ +/* tslint:disable */ +/* + * --------------------------------------------------------------- + * ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ## + * ## ## + * ## AUTHOR: acacode ## + * ## SOURCE: https://github.com/acacode/swagger-typescript-api ## + * --------------------------------------------------------------- + */ + +export interface BzescavengeCommit { + index?: string; + solutionHash?: string; + solutionScavengerHash?: string; +} + +export interface BzescavengeScavenge { + index?: string; + solutionHash?: string; + solution?: string; + description?: string; + reward?: string; + scavenger?: string; +} + +export interface ProtobufAny { + "@type"?: string; +} + +export interface RpcStatus { + /** @format int32 */ + code?: number; + message?: string; + details?: ProtobufAny[]; +} + +export type ScavengeMsgCommitSolutionResponse = object; + +export type ScavengeMsgRevealSolutionResponse = object; + +export type ScavengeMsgSubmitScavengeResponse = object; + +export interface ScavengeQueryAllCommitResponse { + commit?: BzescavengeCommit[]; + + /** + * PageResponse is to be embedded in gRPC response messages where the + * corresponding request message has used PageRequest. + * + * message SomeResponse { + * repeated Bar results = 1; + * PageResponse page = 2; + * } + */ + pagination?: V1Beta1PageResponse; +} + +export interface ScavengeQueryAllScavengeResponse { + scavenge?: BzescavengeScavenge[]; + + /** + * PageResponse is to be embedded in gRPC response messages where the + * corresponding request message has used PageRequest. + * + * message SomeResponse { + * repeated Bar results = 1; + * PageResponse page = 2; + * } + */ + pagination?: V1Beta1PageResponse; +} + +export interface ScavengeQueryGetCommitResponse { + commit?: BzescavengeCommit; +} + +export interface ScavengeQueryGetScavengeResponse { + scavenge?: BzescavengeScavenge; +} + +/** +* message SomeRequest { + Foo some_parameter = 1; + PageRequest pagination = 2; + } +*/ +export interface V1Beta1PageRequest { + /** + * key is a value returned in PageResponse.next_key to begin + * querying the next page most efficiently. Only one of offset or key + * should be set. + * @format byte + */ + key?: string; + + /** + * offset is a numeric offset that can be used when key is unavailable. + * It is less efficient than using key. Only one of offset or key should + * be set. + * @format uint64 + */ + offset?: string; + + /** + * limit is the total number of results to be returned in the result page. + * If left empty it will default to a value to be set by each app. + * @format uint64 + */ + limit?: string; + + /** + * count_total is set to true to indicate that the result set should include + * a count of the total number of items available for pagination in UIs. + * count_total is only respected when offset is used. It is ignored when key + * is set. + */ + count_total?: boolean; + + /** + * reverse is set to true if results are to be returned in the descending order. + * + * Since: cosmos-sdk 0.43 + */ + reverse?: boolean; +} + +/** +* PageResponse is to be embedded in gRPC response messages where the +corresponding request message has used PageRequest. + + message SomeResponse { + repeated Bar results = 1; + PageResponse page = 2; + } +*/ +export interface V1Beta1PageResponse { + /** @format byte */ + next_key?: string; + + /** @format uint64 */ + total?: string; +} + +export type QueryParamsType = Record; +export type ResponseFormat = keyof Omit; + +export interface FullRequestParams extends Omit { + /** set parameter to `true` for call `securityWorker` for this request */ + secure?: boolean; + /** request path */ + path: string; + /** content type of request body */ + type?: ContentType; + /** query params */ + query?: QueryParamsType; + /** format of response (i.e. response.json() -> format: "json") */ + format?: keyof Omit; + /** request body */ + body?: unknown; + /** base url */ + baseUrl?: string; + /** request cancellation token */ + cancelToken?: CancelToken; +} + +export type RequestParams = Omit; + +export interface ApiConfig { + baseUrl?: string; + baseApiParams?: Omit; + securityWorker?: (securityData: SecurityDataType) => RequestParams | void; +} + +export interface HttpResponse extends Response { + data: D; + error: E; +} + +type CancelToken = Symbol | string | number; + +export enum ContentType { + Json = "application/json", + FormData = "multipart/form-data", + UrlEncoded = "application/x-www-form-urlencoded", +} + +export class HttpClient { + public baseUrl: string = ""; + private securityData: SecurityDataType = null as any; + private securityWorker: null | ApiConfig["securityWorker"] = null; + private abortControllers = new Map(); + + private baseApiParams: RequestParams = { + credentials: "same-origin", + headers: {}, + redirect: "follow", + referrerPolicy: "no-referrer", + }; + + constructor(apiConfig: ApiConfig = {}) { + Object.assign(this, apiConfig); + } + + public setSecurityData = (data: SecurityDataType) => { + this.securityData = data; + }; + + private addQueryParam(query: QueryParamsType, key: string) { + const value = query[key]; + + return ( + encodeURIComponent(key) + + "=" + + encodeURIComponent(Array.isArray(value) ? value.join(",") : typeof value === "number" ? value : `${value}`) + ); + } + + protected toQueryString(rawQuery?: QueryParamsType): string { + const query = rawQuery || {}; + const keys = Object.keys(query).filter((key) => "undefined" !== typeof query[key]); + return keys + .map((key) => + typeof query[key] === "object" && !Array.isArray(query[key]) + ? this.toQueryString(query[key] as QueryParamsType) + : this.addQueryParam(query, key), + ) + .join("&"); + } + + protected addQueryParams(rawQuery?: QueryParamsType): string { + const queryString = this.toQueryString(rawQuery); + return queryString ? `?${queryString}` : ""; + } + + private contentFormatters: Record any> = { + [ContentType.Json]: (input: any) => + input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input, + [ContentType.FormData]: (input: any) => + Object.keys(input || {}).reduce((data, key) => { + data.append(key, input[key]); + return data; + }, new FormData()), + [ContentType.UrlEncoded]: (input: any) => this.toQueryString(input), + }; + + private mergeRequestParams(params1: RequestParams, params2?: RequestParams): RequestParams { + return { + ...this.baseApiParams, + ...params1, + ...(params2 || {}), + headers: { + ...(this.baseApiParams.headers || {}), + ...(params1.headers || {}), + ...((params2 && params2.headers) || {}), + }, + }; + } + + private createAbortSignal = (cancelToken: CancelToken): AbortSignal | undefined => { + if (this.abortControllers.has(cancelToken)) { + const abortController = this.abortControllers.get(cancelToken); + if (abortController) { + return abortController.signal; + } + return void 0; + } + + const abortController = new AbortController(); + this.abortControllers.set(cancelToken, abortController); + return abortController.signal; + }; + + public abortRequest = (cancelToken: CancelToken) => { + const abortController = this.abortControllers.get(cancelToken); + + if (abortController) { + abortController.abort(); + this.abortControllers.delete(cancelToken); + } + }; + + public request = ({ + body, + secure, + path, + type, + query, + format = "json", + baseUrl, + cancelToken, + ...params + }: FullRequestParams): Promise> => { + const secureParams = (secure && this.securityWorker && this.securityWorker(this.securityData)) || {}; + const requestParams = this.mergeRequestParams(params, secureParams); + const queryString = query && this.toQueryString(query); + const payloadFormatter = this.contentFormatters[type || ContentType.Json]; + + return fetch(`${baseUrl || this.baseUrl || ""}${path}${queryString ? `?${queryString}` : ""}`, { + ...requestParams, + headers: { + ...(type && type !== ContentType.FormData ? { "Content-Type": type } : {}), + ...(requestParams.headers || {}), + }, + signal: cancelToken ? this.createAbortSignal(cancelToken) : void 0, + body: typeof body === "undefined" || body === null ? null : payloadFormatter(body), + }).then(async (response) => { + const r = response as HttpResponse; + r.data = (null as unknown) as T; + r.error = (null as unknown) as E; + + const data = await response[format]() + .then((data) => { + if (r.ok) { + r.data = data; + } else { + r.error = data; + } + return r; + }) + .catch((e) => { + r.error = e; + return r; + }); + + if (cancelToken) { + this.abortControllers.delete(cancelToken); + } + + if (!response.ok) throw data; + return data; + }); + }; +} + +/** + * @title scavenge/commit.proto + * @version version not set + */ +export class Api extends HttpClient { + /** + * No description + * + * @tags Query + * @name QueryCommitAll + * @summary Queries a list of commit items. + * @request GET:/bze/scavenge/commit + */ + queryCommitAll = ( + query?: { + "pagination.key"?: string; + "pagination.offset"?: string; + "pagination.limit"?: string; + "pagination.count_total"?: boolean; + "pagination.reverse"?: boolean; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/bze/scavenge/commit`, + method: "GET", + query: query, + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Query + * @name QueryCommit + * @summary Queries a commit by index. + * @request GET:/bze/scavenge/commit/{index} + */ + queryCommit = (index: string, params: RequestParams = {}) => + this.request({ + path: `/bze/scavenge/commit/${index}`, + method: "GET", + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Query + * @name QueryScavengeAll + * @summary Queries a list of scavenge items. + * @request GET:/bze/scavenge/scavenge + */ + queryScavengeAll = ( + query?: { + "pagination.key"?: string; + "pagination.offset"?: string; + "pagination.limit"?: string; + "pagination.count_total"?: boolean; + "pagination.reverse"?: boolean; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/bze/scavenge/scavenge`, + method: "GET", + query: query, + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Query + * @name QueryScavenge + * @summary Queries a scavenge by index. + * @request GET:/bze/scavenge/scavenge/{index} + */ + queryScavenge = (index: string, params: RequestParams = {}) => + this.request({ + path: `/bze/scavenge/scavenge/${index}`, + method: "GET", + format: "json", + ...params, + }); +} diff --git a/ts-client/bze.scavenge/types.ts b/ts-client/bze.scavenge/types.ts new file mode 100755 index 00000000..9d81ba6c --- /dev/null +++ b/ts-client/bze.scavenge/types.ts @@ -0,0 +1,9 @@ +import { Commit } from "./types/scavenge/commit" +import { Scavenge } from "./types/scavenge/scavenge" + + +export { + Commit, + Scavenge, + + } \ No newline at end of file diff --git a/ts-client/bze.scavenge/types/cosmos/base/query/v1beta1/pagination.ts b/ts-client/bze.scavenge/types/cosmos/base/query/v1beta1/pagination.ts new file mode 100644 index 00000000..cd4b2d78 --- /dev/null +++ b/ts-client/bze.scavenge/types/cosmos/base/query/v1beta1/pagination.ts @@ -0,0 +1,327 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "cosmos.base.query.v1beta1"; + +/** + * PageRequest is to be embedded in gRPC request messages for efficient + * pagination. Ex: + * + * message SomeRequest { + * Foo some_parameter = 1; + * PageRequest pagination = 2; + * } + */ +export interface PageRequest { + /** + * key is a value returned in PageResponse.next_key to begin + * querying the next page most efficiently. Only one of offset or key + * should be set. + */ + key: Uint8Array; + /** + * offset is a numeric offset that can be used when key is unavailable. + * It is less efficient than using key. Only one of offset or key should + * be set. + */ + offset: number; + /** + * limit is the total number of results to be returned in the result page. + * If left empty it will default to a value to be set by each app. + */ + limit: number; + /** + * count_total is set to true to indicate that the result set should include + * a count of the total number of items available for pagination in UIs. + * count_total is only respected when offset is used. It is ignored when key + * is set. + */ + countTotal: boolean; + /** + * reverse is set to true if results are to be returned in the descending order. + * + * Since: cosmos-sdk 0.43 + */ + reverse: boolean; +} + +/** + * PageResponse is to be embedded in gRPC response messages where the + * corresponding request message has used PageRequest. + * + * message SomeResponse { + * repeated Bar results = 1; + * PageResponse page = 2; + * } + */ +export interface PageResponse { + /** + * next_key is the key to be passed to PageRequest.key to + * query the next page most efficiently + */ + nextKey: Uint8Array; + /** + * total is total number of results available if PageRequest.count_total + * was set, its value is undefined otherwise + */ + total: number; +} + +const basePageRequest: object = { + offset: 0, + limit: 0, + countTotal: false, + reverse: false, +}; + +export const PageRequest = { + encode(message: PageRequest, writer: Writer = Writer.create()): Writer { + if (message.key.length !== 0) { + writer.uint32(10).bytes(message.key); + } + if (message.offset !== 0) { + writer.uint32(16).uint64(message.offset); + } + if (message.limit !== 0) { + writer.uint32(24).uint64(message.limit); + } + if (message.countTotal === true) { + writer.uint32(32).bool(message.countTotal); + } + if (message.reverse === true) { + writer.uint32(40).bool(message.reverse); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): PageRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...basePageRequest } as PageRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.key = reader.bytes(); + break; + case 2: + message.offset = longToNumber(reader.uint64() as Long); + break; + case 3: + message.limit = longToNumber(reader.uint64() as Long); + break; + case 4: + message.countTotal = reader.bool(); + break; + case 5: + message.reverse = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): PageRequest { + const message = { ...basePageRequest } as PageRequest; + if (object.key !== undefined && object.key !== null) { + message.key = bytesFromBase64(object.key); + } + if (object.offset !== undefined && object.offset !== null) { + message.offset = Number(object.offset); + } else { + message.offset = 0; + } + if (object.limit !== undefined && object.limit !== null) { + message.limit = Number(object.limit); + } else { + message.limit = 0; + } + if (object.countTotal !== undefined && object.countTotal !== null) { + message.countTotal = Boolean(object.countTotal); + } else { + message.countTotal = false; + } + if (object.reverse !== undefined && object.reverse !== null) { + message.reverse = Boolean(object.reverse); + } else { + message.reverse = false; + } + return message; + }, + + toJSON(message: PageRequest): unknown { + const obj: any = {}; + message.key !== undefined && + (obj.key = base64FromBytes( + message.key !== undefined ? message.key : new Uint8Array() + )); + message.offset !== undefined && (obj.offset = message.offset); + message.limit !== undefined && (obj.limit = message.limit); + message.countTotal !== undefined && (obj.countTotal = message.countTotal); + message.reverse !== undefined && (obj.reverse = message.reverse); + return obj; + }, + + fromPartial(object: DeepPartial): PageRequest { + const message = { ...basePageRequest } as PageRequest; + if (object.key !== undefined && object.key !== null) { + message.key = object.key; + } else { + message.key = new Uint8Array(); + } + if (object.offset !== undefined && object.offset !== null) { + message.offset = object.offset; + } else { + message.offset = 0; + } + if (object.limit !== undefined && object.limit !== null) { + message.limit = object.limit; + } else { + message.limit = 0; + } + if (object.countTotal !== undefined && object.countTotal !== null) { + message.countTotal = object.countTotal; + } else { + message.countTotal = false; + } + if (object.reverse !== undefined && object.reverse !== null) { + message.reverse = object.reverse; + } else { + message.reverse = false; + } + return message; + }, +}; + +const basePageResponse: object = { total: 0 }; + +export const PageResponse = { + encode(message: PageResponse, writer: Writer = Writer.create()): Writer { + if (message.nextKey.length !== 0) { + writer.uint32(10).bytes(message.nextKey); + } + if (message.total !== 0) { + writer.uint32(16).uint64(message.total); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): PageResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...basePageResponse } as PageResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.nextKey = reader.bytes(); + break; + case 2: + message.total = longToNumber(reader.uint64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): PageResponse { + const message = { ...basePageResponse } as PageResponse; + if (object.nextKey !== undefined && object.nextKey !== null) { + message.nextKey = bytesFromBase64(object.nextKey); + } + if (object.total !== undefined && object.total !== null) { + message.total = Number(object.total); + } else { + message.total = 0; + } + return message; + }, + + toJSON(message: PageResponse): unknown { + const obj: any = {}; + message.nextKey !== undefined && + (obj.nextKey = base64FromBytes( + message.nextKey !== undefined ? message.nextKey : new Uint8Array() + )); + message.total !== undefined && (obj.total = message.total); + return obj; + }, + + fromPartial(object: DeepPartial): PageResponse { + const message = { ...basePageResponse } as PageResponse; + if (object.nextKey !== undefined && object.nextKey !== null) { + message.nextKey = object.nextKey; + } else { + message.nextKey = new Uint8Array(); + } + if (object.total !== undefined && object.total !== null) { + message.total = object.total; + } else { + message.total = 0; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/bze.scavenge/types/gogoproto/gogo.ts b/ts-client/bze.scavenge/types/gogoproto/gogo.ts new file mode 100644 index 00000000..3f41a047 --- /dev/null +++ b/ts-client/bze.scavenge/types/gogoproto/gogo.ts @@ -0,0 +1,2 @@ +/* eslint-disable */ +export const protobufPackage = "gogoproto"; diff --git a/ts-client/bze.scavenge/types/google/api/annotations.ts b/ts-client/bze.scavenge/types/google/api/annotations.ts new file mode 100644 index 00000000..aace4787 --- /dev/null +++ b/ts-client/bze.scavenge/types/google/api/annotations.ts @@ -0,0 +1,2 @@ +/* eslint-disable */ +export const protobufPackage = "google.api"; diff --git a/ts-client/bze.scavenge/types/google/api/http.ts b/ts-client/bze.scavenge/types/google/api/http.ts new file mode 100644 index 00000000..ddc00f8b --- /dev/null +++ b/ts-client/bze.scavenge/types/google/api/http.ts @@ -0,0 +1,705 @@ +/* eslint-disable */ +import { Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "google.api"; + +/** + * Defines the HTTP configuration for an API service. It contains a list of + * [HttpRule][google.api.HttpRule], each specifying the mapping of an RPC method + * to one or more HTTP REST API methods. + */ +export interface Http { + /** + * A list of HTTP configuration rules that apply to individual API methods. + * + * **NOTE:** All service configuration rules follow "last one wins" order. + */ + rules: HttpRule[]; + /** + * When set to true, URL path parmeters will be fully URI-decoded except in + * cases of single segment matches in reserved expansion, where "%2F" will be + * left encoded. + * + * The default behavior is to not decode RFC 6570 reserved characters in multi + * segment matches. + */ + fullyDecodeReservedExpansion: boolean; +} + +/** + * `HttpRule` defines the mapping of an RPC method to one or more HTTP + * REST API methods. The mapping specifies how different portions of the RPC + * request message are mapped to URL path, URL query parameters, and + * HTTP request body. The mapping is typically specified as an + * `google.api.http` annotation on the RPC method, + * see "google/api/annotations.proto" for details. + * + * The mapping consists of a field specifying the path template and + * method kind. The path template can refer to fields in the request + * message, as in the example below which describes a REST GET + * operation on a resource collection of messages: + * + * + * service Messaging { + * rpc GetMessage(GetMessageRequest) returns (Message) { + * option (google.api.http).get = "/v1/messages/{message_id}/{sub.subfield}"; + * } + * } + * message GetMessageRequest { + * message SubMessage { + * string subfield = 1; + * } + * string message_id = 1; // mapped to the URL + * SubMessage sub = 2; // `sub.subfield` is url-mapped + * } + * message Message { + * string text = 1; // content of the resource + * } + * + * The same http annotation can alternatively be expressed inside the + * `GRPC API Configuration` YAML file. + * + * http: + * rules: + * - selector: .Messaging.GetMessage + * get: /v1/messages/{message_id}/{sub.subfield} + * + * This definition enables an automatic, bidrectional mapping of HTTP + * JSON to RPC. Example: + * + * HTTP | RPC + * -----|----- + * `GET /v1/messages/123456/foo` | `GetMessage(message_id: "123456" sub: SubMessage(subfield: "foo"))` + * + * In general, not only fields but also field paths can be referenced + * from a path pattern. Fields mapped to the path pattern cannot be + * repeated and must have a primitive (non-message) type. + * + * Any fields in the request message which are not bound by the path + * pattern automatically become (optional) HTTP query + * parameters. Assume the following definition of the request message: + * + * + * service Messaging { + * rpc GetMessage(GetMessageRequest) returns (Message) { + * option (google.api.http).get = "/v1/messages/{message_id}"; + * } + * } + * message GetMessageRequest { + * message SubMessage { + * string subfield = 1; + * } + * string message_id = 1; // mapped to the URL + * int64 revision = 2; // becomes a parameter + * SubMessage sub = 3; // `sub.subfield` becomes a parameter + * } + * + * + * This enables a HTTP JSON to RPC mapping as below: + * + * HTTP | RPC + * -----|----- + * `GET /v1/messages/123456?revision=2&sub.subfield=foo` | `GetMessage(message_id: "123456" revision: 2 sub: SubMessage(subfield: "foo"))` + * + * Note that fields which are mapped to HTTP parameters must have a + * primitive type or a repeated primitive type. Message types are not + * allowed. In the case of a repeated type, the parameter can be + * repeated in the URL, as in `...?param=A¶m=B`. + * + * For HTTP method kinds which allow a request body, the `body` field + * specifies the mapping. Consider a REST update method on the + * message resource collection: + * + * + * service Messaging { + * rpc UpdateMessage(UpdateMessageRequest) returns (Message) { + * option (google.api.http) = { + * put: "/v1/messages/{message_id}" + * body: "message" + * }; + * } + * } + * message UpdateMessageRequest { + * string message_id = 1; // mapped to the URL + * Message message = 2; // mapped to the body + * } + * + * + * The following HTTP JSON to RPC mapping is enabled, where the + * representation of the JSON in the request body is determined by + * protos JSON encoding: + * + * HTTP | RPC + * -----|----- + * `PUT /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: "123456" message { text: "Hi!" })` + * + * The special name `*` can be used in the body mapping to define that + * every field not bound by the path template should be mapped to the + * request body. This enables the following alternative definition of + * the update method: + * + * service Messaging { + * rpc UpdateMessage(Message) returns (Message) { + * option (google.api.http) = { + * put: "/v1/messages/{message_id}" + * body: "*" + * }; + * } + * } + * message Message { + * string message_id = 1; + * string text = 2; + * } + * + * + * The following HTTP JSON to RPC mapping is enabled: + * + * HTTP | RPC + * -----|----- + * `PUT /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: "123456" text: "Hi!")` + * + * Note that when using `*` in the body mapping, it is not possible to + * have HTTP parameters, as all fields not bound by the path end in + * the body. This makes this option more rarely used in practice of + * defining REST APIs. The common usage of `*` is in custom methods + * which don't use the URL at all for transferring data. + * + * It is possible to define multiple HTTP methods for one RPC by using + * the `additional_bindings` option. Example: + * + * service Messaging { + * rpc GetMessage(GetMessageRequest) returns (Message) { + * option (google.api.http) = { + * get: "/v1/messages/{message_id}" + * additional_bindings { + * get: "/v1/users/{user_id}/messages/{message_id}" + * } + * }; + * } + * } + * message GetMessageRequest { + * string message_id = 1; + * string user_id = 2; + * } + * + * + * This enables the following two alternative HTTP JSON to RPC + * mappings: + * + * HTTP | RPC + * -----|----- + * `GET /v1/messages/123456` | `GetMessage(message_id: "123456")` + * `GET /v1/users/me/messages/123456` | `GetMessage(user_id: "me" message_id: "123456")` + * + * # Rules for HTTP mapping + * + * The rules for mapping HTTP path, query parameters, and body fields + * to the request message are as follows: + * + * 1. The `body` field specifies either `*` or a field path, or is + * omitted. If omitted, it indicates there is no HTTP request body. + * 2. Leaf fields (recursive expansion of nested messages in the + * request) can be classified into three types: + * (a) Matched in the URL template. + * (b) Covered by body (if body is `*`, everything except (a) fields; + * else everything under the body field) + * (c) All other fields. + * 3. URL query parameters found in the HTTP request are mapped to (c) fields. + * 4. Any body sent with an HTTP request can contain only (b) fields. + * + * The syntax of the path template is as follows: + * + * Template = "/" Segments [ Verb ] ; + * Segments = Segment { "/" Segment } ; + * Segment = "*" | "**" | LITERAL | Variable ; + * Variable = "{" FieldPath [ "=" Segments ] "}" ; + * FieldPath = IDENT { "." IDENT } ; + * Verb = ":" LITERAL ; + * + * The syntax `*` matches a single path segment. The syntax `**` matches zero + * or more path segments, which must be the last part of the path except the + * `Verb`. The syntax `LITERAL` matches literal text in the path. + * + * The syntax `Variable` matches part of the URL path as specified by its + * template. A variable template must not contain other variables. If a variable + * matches a single path segment, its template may be omitted, e.g. `{var}` + * is equivalent to `{var=*}`. + * + * If a variable contains exactly one path segment, such as `"{var}"` or + * `"{var=*}"`, when such a variable is expanded into a URL path, all characters + * except `[-_.~0-9a-zA-Z]` are percent-encoded. Such variables show up in the + * Discovery Document as `{var}`. + * + * If a variable contains one or more path segments, such as `"{var=foo/*}"` + * or `"{var=**}"`, when such a variable is expanded into a URL path, all + * characters except `[-_.~/0-9a-zA-Z]` are percent-encoded. Such variables + * show up in the Discovery Document as `{+var}`. + * + * NOTE: While the single segment variable matches the semantics of + * [RFC 6570](https://tools.ietf.org/html/rfc6570) Section 3.2.2 + * Simple String Expansion, the multi segment variable **does not** match + * RFC 6570 Reserved Expansion. The reason is that the Reserved Expansion + * does not expand special characters like `?` and `#`, which would lead + * to invalid URLs. + * + * NOTE: the field paths in variables and in the `body` must not refer to + * repeated fields or map fields. + */ +export interface HttpRule { + /** + * Selects methods to which this rule applies. + * + * Refer to [selector][google.api.DocumentationRule.selector] for syntax details. + */ + selector: string; + /** Used for listing and getting information about resources. */ + get: string | undefined; + /** Used for updating a resource. */ + put: string | undefined; + /** Used for creating a resource. */ + post: string | undefined; + /** Used for deleting a resource. */ + delete: string | undefined; + /** Used for updating a resource. */ + patch: string | undefined; + /** + * The custom pattern is used for specifying an HTTP method that is not + * included in the `pattern` field, such as HEAD, or "*" to leave the + * HTTP method unspecified for this rule. The wild-card rule is useful + * for services that provide content to Web (HTML) clients. + */ + custom: CustomHttpPattern | undefined; + /** + * The name of the request field whose value is mapped to the HTTP body, or + * `*` for mapping all fields not captured by the path pattern to the HTTP + * body. NOTE: the referred field must not be a repeated field and must be + * present at the top-level of request message type. + */ + body: string; + /** + * Optional. The name of the response field whose value is mapped to the HTTP + * body of response. Other response fields are ignored. When + * not set, the response message will be used as HTTP body of response. + */ + responseBody: string; + /** + * Additional HTTP bindings for the selector. Nested bindings must + * not contain an `additional_bindings` field themselves (that is, + * the nesting may only be one level deep). + */ + additionalBindings: HttpRule[]; +} + +/** A custom pattern is used for defining custom HTTP verb. */ +export interface CustomHttpPattern { + /** The name of this custom HTTP verb. */ + kind: string; + /** The path matched by this custom verb. */ + path: string; +} + +const baseHttp: object = { fullyDecodeReservedExpansion: false }; + +export const Http = { + encode(message: Http, writer: Writer = Writer.create()): Writer { + for (const v of message.rules) { + HttpRule.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.fullyDecodeReservedExpansion === true) { + writer.uint32(16).bool(message.fullyDecodeReservedExpansion); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Http { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseHttp } as Http; + message.rules = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.rules.push(HttpRule.decode(reader, reader.uint32())); + break; + case 2: + message.fullyDecodeReservedExpansion = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Http { + const message = { ...baseHttp } as Http; + message.rules = []; + if (object.rules !== undefined && object.rules !== null) { + for (const e of object.rules) { + message.rules.push(HttpRule.fromJSON(e)); + } + } + if ( + object.fullyDecodeReservedExpansion !== undefined && + object.fullyDecodeReservedExpansion !== null + ) { + message.fullyDecodeReservedExpansion = Boolean( + object.fullyDecodeReservedExpansion + ); + } else { + message.fullyDecodeReservedExpansion = false; + } + return message; + }, + + toJSON(message: Http): unknown { + const obj: any = {}; + if (message.rules) { + obj.rules = message.rules.map((e) => + e ? HttpRule.toJSON(e) : undefined + ); + } else { + obj.rules = []; + } + message.fullyDecodeReservedExpansion !== undefined && + (obj.fullyDecodeReservedExpansion = message.fullyDecodeReservedExpansion); + return obj; + }, + + fromPartial(object: DeepPartial): Http { + const message = { ...baseHttp } as Http; + message.rules = []; + if (object.rules !== undefined && object.rules !== null) { + for (const e of object.rules) { + message.rules.push(HttpRule.fromPartial(e)); + } + } + if ( + object.fullyDecodeReservedExpansion !== undefined && + object.fullyDecodeReservedExpansion !== null + ) { + message.fullyDecodeReservedExpansion = + object.fullyDecodeReservedExpansion; + } else { + message.fullyDecodeReservedExpansion = false; + } + return message; + }, +}; + +const baseHttpRule: object = { selector: "", body: "", responseBody: "" }; + +export const HttpRule = { + encode(message: HttpRule, writer: Writer = Writer.create()): Writer { + if (message.selector !== "") { + writer.uint32(10).string(message.selector); + } + if (message.get !== undefined) { + writer.uint32(18).string(message.get); + } + if (message.put !== undefined) { + writer.uint32(26).string(message.put); + } + if (message.post !== undefined) { + writer.uint32(34).string(message.post); + } + if (message.delete !== undefined) { + writer.uint32(42).string(message.delete); + } + if (message.patch !== undefined) { + writer.uint32(50).string(message.patch); + } + if (message.custom !== undefined) { + CustomHttpPattern.encode( + message.custom, + writer.uint32(66).fork() + ).ldelim(); + } + if (message.body !== "") { + writer.uint32(58).string(message.body); + } + if (message.responseBody !== "") { + writer.uint32(98).string(message.responseBody); + } + for (const v of message.additionalBindings) { + HttpRule.encode(v!, writer.uint32(90).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): HttpRule { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseHttpRule } as HttpRule; + message.additionalBindings = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.selector = reader.string(); + break; + case 2: + message.get = reader.string(); + break; + case 3: + message.put = reader.string(); + break; + case 4: + message.post = reader.string(); + break; + case 5: + message.delete = reader.string(); + break; + case 6: + message.patch = reader.string(); + break; + case 8: + message.custom = CustomHttpPattern.decode(reader, reader.uint32()); + break; + case 7: + message.body = reader.string(); + break; + case 12: + message.responseBody = reader.string(); + break; + case 11: + message.additionalBindings.push( + HttpRule.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): HttpRule { + const message = { ...baseHttpRule } as HttpRule; + message.additionalBindings = []; + if (object.selector !== undefined && object.selector !== null) { + message.selector = String(object.selector); + } else { + message.selector = ""; + } + if (object.get !== undefined && object.get !== null) { + message.get = String(object.get); + } else { + message.get = undefined; + } + if (object.put !== undefined && object.put !== null) { + message.put = String(object.put); + } else { + message.put = undefined; + } + if (object.post !== undefined && object.post !== null) { + message.post = String(object.post); + } else { + message.post = undefined; + } + if (object.delete !== undefined && object.delete !== null) { + message.delete = String(object.delete); + } else { + message.delete = undefined; + } + if (object.patch !== undefined && object.patch !== null) { + message.patch = String(object.patch); + } else { + message.patch = undefined; + } + if (object.custom !== undefined && object.custom !== null) { + message.custom = CustomHttpPattern.fromJSON(object.custom); + } else { + message.custom = undefined; + } + if (object.body !== undefined && object.body !== null) { + message.body = String(object.body); + } else { + message.body = ""; + } + if (object.responseBody !== undefined && object.responseBody !== null) { + message.responseBody = String(object.responseBody); + } else { + message.responseBody = ""; + } + if ( + object.additionalBindings !== undefined && + object.additionalBindings !== null + ) { + for (const e of object.additionalBindings) { + message.additionalBindings.push(HttpRule.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: HttpRule): unknown { + const obj: any = {}; + message.selector !== undefined && (obj.selector = message.selector); + message.get !== undefined && (obj.get = message.get); + message.put !== undefined && (obj.put = message.put); + message.post !== undefined && (obj.post = message.post); + message.delete !== undefined && (obj.delete = message.delete); + message.patch !== undefined && (obj.patch = message.patch); + message.custom !== undefined && + (obj.custom = message.custom + ? CustomHttpPattern.toJSON(message.custom) + : undefined); + message.body !== undefined && (obj.body = message.body); + message.responseBody !== undefined && + (obj.responseBody = message.responseBody); + if (message.additionalBindings) { + obj.additionalBindings = message.additionalBindings.map((e) => + e ? HttpRule.toJSON(e) : undefined + ); + } else { + obj.additionalBindings = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): HttpRule { + const message = { ...baseHttpRule } as HttpRule; + message.additionalBindings = []; + if (object.selector !== undefined && object.selector !== null) { + message.selector = object.selector; + } else { + message.selector = ""; + } + if (object.get !== undefined && object.get !== null) { + message.get = object.get; + } else { + message.get = undefined; + } + if (object.put !== undefined && object.put !== null) { + message.put = object.put; + } else { + message.put = undefined; + } + if (object.post !== undefined && object.post !== null) { + message.post = object.post; + } else { + message.post = undefined; + } + if (object.delete !== undefined && object.delete !== null) { + message.delete = object.delete; + } else { + message.delete = undefined; + } + if (object.patch !== undefined && object.patch !== null) { + message.patch = object.patch; + } else { + message.patch = undefined; + } + if (object.custom !== undefined && object.custom !== null) { + message.custom = CustomHttpPattern.fromPartial(object.custom); + } else { + message.custom = undefined; + } + if (object.body !== undefined && object.body !== null) { + message.body = object.body; + } else { + message.body = ""; + } + if (object.responseBody !== undefined && object.responseBody !== null) { + message.responseBody = object.responseBody; + } else { + message.responseBody = ""; + } + if ( + object.additionalBindings !== undefined && + object.additionalBindings !== null + ) { + for (const e of object.additionalBindings) { + message.additionalBindings.push(HttpRule.fromPartial(e)); + } + } + return message; + }, +}; + +const baseCustomHttpPattern: object = { kind: "", path: "" }; + +export const CustomHttpPattern = { + encode(message: CustomHttpPattern, writer: Writer = Writer.create()): Writer { + if (message.kind !== "") { + writer.uint32(10).string(message.kind); + } + if (message.path !== "") { + writer.uint32(18).string(message.path); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): CustomHttpPattern { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseCustomHttpPattern } as CustomHttpPattern; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.kind = reader.string(); + break; + case 2: + message.path = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): CustomHttpPattern { + const message = { ...baseCustomHttpPattern } as CustomHttpPattern; + if (object.kind !== undefined && object.kind !== null) { + message.kind = String(object.kind); + } else { + message.kind = ""; + } + if (object.path !== undefined && object.path !== null) { + message.path = String(object.path); + } else { + message.path = ""; + } + return message; + }, + + toJSON(message: CustomHttpPattern): unknown { + const obj: any = {}; + message.kind !== undefined && (obj.kind = message.kind); + message.path !== undefined && (obj.path = message.path); + return obj; + }, + + fromPartial(object: DeepPartial): CustomHttpPattern { + const message = { ...baseCustomHttpPattern } as CustomHttpPattern; + if (object.kind !== undefined && object.kind !== null) { + message.kind = object.kind; + } else { + message.kind = ""; + } + if (object.path !== undefined && object.path !== null) { + message.path = object.path; + } else { + message.path = ""; + } + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/bze.scavenge/types/google/protobuf/descriptor.ts b/ts-client/bze.scavenge/types/google/protobuf/descriptor.ts new file mode 100644 index 00000000..9e508660 --- /dev/null +++ b/ts-client/bze.scavenge/types/google/protobuf/descriptor.ts @@ -0,0 +1,5261 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "google.protobuf"; + +/** + * The protocol compiler can output a FileDescriptorSet containing the .proto + * files it parses. + */ +export interface FileDescriptorSet { + file: FileDescriptorProto[]; +} + +/** Describes a complete .proto file. */ +export interface FileDescriptorProto { + /** file name, relative to root of source tree */ + name: string; + /** e.g. "foo", "foo.bar", etc. */ + package: string; + /** Names of files imported by this file. */ + dependency: string[]; + /** Indexes of the public imported files in the dependency list above. */ + publicDependency: number[]; + /** + * Indexes of the weak imported files in the dependency list. + * For Google-internal migration only. Do not use. + */ + weakDependency: number[]; + /** All top-level definitions in this file. */ + messageType: DescriptorProto[]; + enumType: EnumDescriptorProto[]; + service: ServiceDescriptorProto[]; + extension: FieldDescriptorProto[]; + options: FileOptions | undefined; + /** + * This field contains optional information about the original source code. + * You may safely remove this entire field without harming runtime + * functionality of the descriptors -- the information is needed only by + * development tools. + */ + sourceCodeInfo: SourceCodeInfo | undefined; + /** + * The syntax of the proto file. + * The supported values are "proto2" and "proto3". + */ + syntax: string; +} + +/** Describes a message type. */ +export interface DescriptorProto { + name: string; + field: FieldDescriptorProto[]; + extension: FieldDescriptorProto[]; + nestedType: DescriptorProto[]; + enumType: EnumDescriptorProto[]; + extensionRange: DescriptorProto_ExtensionRange[]; + oneofDecl: OneofDescriptorProto[]; + options: MessageOptions | undefined; + reservedRange: DescriptorProto_ReservedRange[]; + /** + * Reserved field names, which may not be used by fields in the same message. + * A given name may only be reserved once. + */ + reservedName: string[]; +} + +export interface DescriptorProto_ExtensionRange { + /** Inclusive. */ + start: number; + /** Exclusive. */ + end: number; + options: ExtensionRangeOptions | undefined; +} + +/** + * Range of reserved tag numbers. Reserved tag numbers may not be used by + * fields or extension ranges in the same message. Reserved ranges may + * not overlap. + */ +export interface DescriptorProto_ReservedRange { + /** Inclusive. */ + start: number; + /** Exclusive. */ + end: number; +} + +export interface ExtensionRangeOptions { + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +/** Describes a field within a message. */ +export interface FieldDescriptorProto { + name: string; + number: number; + label: FieldDescriptorProto_Label; + /** + * If type_name is set, this need not be set. If both this and type_name + * are set, this must be one of TYPE_ENUM, TYPE_MESSAGE or TYPE_GROUP. + */ + type: FieldDescriptorProto_Type; + /** + * For message and enum types, this is the name of the type. If the name + * starts with a '.', it is fully-qualified. Otherwise, C++-like scoping + * rules are used to find the type (i.e. first the nested types within this + * message are searched, then within the parent, on up to the root + * namespace). + */ + typeName: string; + /** + * For extensions, this is the name of the type being extended. It is + * resolved in the same manner as type_name. + */ + extendee: string; + /** + * For numeric types, contains the original text representation of the value. + * For booleans, "true" or "false". + * For strings, contains the default text contents (not escaped in any way). + * For bytes, contains the C escaped value. All bytes >= 128 are escaped. + * TODO(kenton): Base-64 encode? + */ + defaultValue: string; + /** + * If set, gives the index of a oneof in the containing type's oneof_decl + * list. This field is a member of that oneof. + */ + oneofIndex: number; + /** + * JSON name of this field. The value is set by protocol compiler. If the + * user has set a "json_name" option on this field, that option's value + * will be used. Otherwise, it's deduced from the field's name by converting + * it to camelCase. + */ + jsonName: string; + options: FieldOptions | undefined; + /** + * If true, this is a proto3 "optional". When a proto3 field is optional, it + * tracks presence regardless of field type. + * + * When proto3_optional is true, this field must be belong to a oneof to + * signal to old proto3 clients that presence is tracked for this field. This + * oneof is known as a "synthetic" oneof, and this field must be its sole + * member (each proto3 optional field gets its own synthetic oneof). Synthetic + * oneofs exist in the descriptor only, and do not generate any API. Synthetic + * oneofs must be ordered after all "real" oneofs. + * + * For message fields, proto3_optional doesn't create any semantic change, + * since non-repeated message fields always track presence. However it still + * indicates the semantic detail of whether the user wrote "optional" or not. + * This can be useful for round-tripping the .proto file. For consistency we + * give message fields a synthetic oneof also, even though it is not required + * to track presence. This is especially important because the parser can't + * tell if a field is a message or an enum, so it must always create a + * synthetic oneof. + * + * Proto2 optional fields do not set this flag, because they already indicate + * optional with `LABEL_OPTIONAL`. + */ + proto3Optional: boolean; +} + +export enum FieldDescriptorProto_Type { + /** + * TYPE_DOUBLE - 0 is reserved for errors. + * Order is weird for historical reasons. + */ + TYPE_DOUBLE = 1, + TYPE_FLOAT = 2, + /** + * TYPE_INT64 - Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT64 if + * negative values are likely. + */ + TYPE_INT64 = 3, + TYPE_UINT64 = 4, + /** + * TYPE_INT32 - Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT32 if + * negative values are likely. + */ + TYPE_INT32 = 5, + TYPE_FIXED64 = 6, + TYPE_FIXED32 = 7, + TYPE_BOOL = 8, + TYPE_STRING = 9, + /** + * TYPE_GROUP - Tag-delimited aggregate. + * Group type is deprecated and not supported in proto3. However, Proto3 + * implementations should still be able to parse the group wire format and + * treat group fields as unknown fields. + */ + TYPE_GROUP = 10, + /** TYPE_MESSAGE - Length-delimited aggregate. */ + TYPE_MESSAGE = 11, + /** TYPE_BYTES - New in version 2. */ + TYPE_BYTES = 12, + TYPE_UINT32 = 13, + TYPE_ENUM = 14, + TYPE_SFIXED32 = 15, + TYPE_SFIXED64 = 16, + /** TYPE_SINT32 - Uses ZigZag encoding. */ + TYPE_SINT32 = 17, + /** TYPE_SINT64 - Uses ZigZag encoding. */ + TYPE_SINT64 = 18, + UNRECOGNIZED = -1, +} + +export function fieldDescriptorProto_TypeFromJSON( + object: any +): FieldDescriptorProto_Type { + switch (object) { + case 1: + case "TYPE_DOUBLE": + return FieldDescriptorProto_Type.TYPE_DOUBLE; + case 2: + case "TYPE_FLOAT": + return FieldDescriptorProto_Type.TYPE_FLOAT; + case 3: + case "TYPE_INT64": + return FieldDescriptorProto_Type.TYPE_INT64; + case 4: + case "TYPE_UINT64": + return FieldDescriptorProto_Type.TYPE_UINT64; + case 5: + case "TYPE_INT32": + return FieldDescriptorProto_Type.TYPE_INT32; + case 6: + case "TYPE_FIXED64": + return FieldDescriptorProto_Type.TYPE_FIXED64; + case 7: + case "TYPE_FIXED32": + return FieldDescriptorProto_Type.TYPE_FIXED32; + case 8: + case "TYPE_BOOL": + return FieldDescriptorProto_Type.TYPE_BOOL; + case 9: + case "TYPE_STRING": + return FieldDescriptorProto_Type.TYPE_STRING; + case 10: + case "TYPE_GROUP": + return FieldDescriptorProto_Type.TYPE_GROUP; + case 11: + case "TYPE_MESSAGE": + return FieldDescriptorProto_Type.TYPE_MESSAGE; + case 12: + case "TYPE_BYTES": + return FieldDescriptorProto_Type.TYPE_BYTES; + case 13: + case "TYPE_UINT32": + return FieldDescriptorProto_Type.TYPE_UINT32; + case 14: + case "TYPE_ENUM": + return FieldDescriptorProto_Type.TYPE_ENUM; + case 15: + case "TYPE_SFIXED32": + return FieldDescriptorProto_Type.TYPE_SFIXED32; + case 16: + case "TYPE_SFIXED64": + return FieldDescriptorProto_Type.TYPE_SFIXED64; + case 17: + case "TYPE_SINT32": + return FieldDescriptorProto_Type.TYPE_SINT32; + case 18: + case "TYPE_SINT64": + return FieldDescriptorProto_Type.TYPE_SINT64; + case -1: + case "UNRECOGNIZED": + default: + return FieldDescriptorProto_Type.UNRECOGNIZED; + } +} + +export function fieldDescriptorProto_TypeToJSON( + object: FieldDescriptorProto_Type +): string { + switch (object) { + case FieldDescriptorProto_Type.TYPE_DOUBLE: + return "TYPE_DOUBLE"; + case FieldDescriptorProto_Type.TYPE_FLOAT: + return "TYPE_FLOAT"; + case FieldDescriptorProto_Type.TYPE_INT64: + return "TYPE_INT64"; + case FieldDescriptorProto_Type.TYPE_UINT64: + return "TYPE_UINT64"; + case FieldDescriptorProto_Type.TYPE_INT32: + return "TYPE_INT32"; + case FieldDescriptorProto_Type.TYPE_FIXED64: + return "TYPE_FIXED64"; + case FieldDescriptorProto_Type.TYPE_FIXED32: + return "TYPE_FIXED32"; + case FieldDescriptorProto_Type.TYPE_BOOL: + return "TYPE_BOOL"; + case FieldDescriptorProto_Type.TYPE_STRING: + return "TYPE_STRING"; + case FieldDescriptorProto_Type.TYPE_GROUP: + return "TYPE_GROUP"; + case FieldDescriptorProto_Type.TYPE_MESSAGE: + return "TYPE_MESSAGE"; + case FieldDescriptorProto_Type.TYPE_BYTES: + return "TYPE_BYTES"; + case FieldDescriptorProto_Type.TYPE_UINT32: + return "TYPE_UINT32"; + case FieldDescriptorProto_Type.TYPE_ENUM: + return "TYPE_ENUM"; + case FieldDescriptorProto_Type.TYPE_SFIXED32: + return "TYPE_SFIXED32"; + case FieldDescriptorProto_Type.TYPE_SFIXED64: + return "TYPE_SFIXED64"; + case FieldDescriptorProto_Type.TYPE_SINT32: + return "TYPE_SINT32"; + case FieldDescriptorProto_Type.TYPE_SINT64: + return "TYPE_SINT64"; + default: + return "UNKNOWN"; + } +} + +export enum FieldDescriptorProto_Label { + /** LABEL_OPTIONAL - 0 is reserved for errors */ + LABEL_OPTIONAL = 1, + LABEL_REQUIRED = 2, + LABEL_REPEATED = 3, + UNRECOGNIZED = -1, +} + +export function fieldDescriptorProto_LabelFromJSON( + object: any +): FieldDescriptorProto_Label { + switch (object) { + case 1: + case "LABEL_OPTIONAL": + return FieldDescriptorProto_Label.LABEL_OPTIONAL; + case 2: + case "LABEL_REQUIRED": + return FieldDescriptorProto_Label.LABEL_REQUIRED; + case 3: + case "LABEL_REPEATED": + return FieldDescriptorProto_Label.LABEL_REPEATED; + case -1: + case "UNRECOGNIZED": + default: + return FieldDescriptorProto_Label.UNRECOGNIZED; + } +} + +export function fieldDescriptorProto_LabelToJSON( + object: FieldDescriptorProto_Label +): string { + switch (object) { + case FieldDescriptorProto_Label.LABEL_OPTIONAL: + return "LABEL_OPTIONAL"; + case FieldDescriptorProto_Label.LABEL_REQUIRED: + return "LABEL_REQUIRED"; + case FieldDescriptorProto_Label.LABEL_REPEATED: + return "LABEL_REPEATED"; + default: + return "UNKNOWN"; + } +} + +/** Describes a oneof. */ +export interface OneofDescriptorProto { + name: string; + options: OneofOptions | undefined; +} + +/** Describes an enum type. */ +export interface EnumDescriptorProto { + name: string; + value: EnumValueDescriptorProto[]; + options: EnumOptions | undefined; + /** + * Range of reserved numeric values. Reserved numeric values may not be used + * by enum values in the same enum declaration. Reserved ranges may not + * overlap. + */ + reservedRange: EnumDescriptorProto_EnumReservedRange[]; + /** + * Reserved enum value names, which may not be reused. A given name may only + * be reserved once. + */ + reservedName: string[]; +} + +/** + * Range of reserved numeric values. Reserved values may not be used by + * entries in the same enum. Reserved ranges may not overlap. + * + * Note that this is distinct from DescriptorProto.ReservedRange in that it + * is inclusive such that it can appropriately represent the entire int32 + * domain. + */ +export interface EnumDescriptorProto_EnumReservedRange { + /** Inclusive. */ + start: number; + /** Inclusive. */ + end: number; +} + +/** Describes a value within an enum. */ +export interface EnumValueDescriptorProto { + name: string; + number: number; + options: EnumValueOptions | undefined; +} + +/** Describes a service. */ +export interface ServiceDescriptorProto { + name: string; + method: MethodDescriptorProto[]; + options: ServiceOptions | undefined; +} + +/** Describes a method of a service. */ +export interface MethodDescriptorProto { + name: string; + /** + * Input and output type names. These are resolved in the same way as + * FieldDescriptorProto.type_name, but must refer to a message type. + */ + inputType: string; + outputType: string; + options: MethodOptions | undefined; + /** Identifies if client streams multiple client messages */ + clientStreaming: boolean; + /** Identifies if server streams multiple server messages */ + serverStreaming: boolean; +} + +export interface FileOptions { + /** + * Sets the Java package where classes generated from this .proto will be + * placed. By default, the proto package is used, but this is often + * inappropriate because proto packages do not normally start with backwards + * domain names. + */ + javaPackage: string; + /** + * Controls the name of the wrapper Java class generated for the .proto file. + * That class will always contain the .proto file's getDescriptor() method as + * well as any top-level extensions defined in the .proto file. + * If java_multiple_files is disabled, then all the other classes from the + * .proto file will be nested inside the single wrapper outer class. + */ + javaOuterClassname: string; + /** + * If enabled, then the Java code generator will generate a separate .java + * file for each top-level message, enum, and service defined in the .proto + * file. Thus, these types will *not* be nested inside the wrapper class + * named by java_outer_classname. However, the wrapper class will still be + * generated to contain the file's getDescriptor() method as well as any + * top-level extensions defined in the file. + */ + javaMultipleFiles: boolean; + /** + * This option does nothing. + * + * @deprecated + */ + javaGenerateEqualsAndHash: boolean; + /** + * If set true, then the Java2 code generator will generate code that + * throws an exception whenever an attempt is made to assign a non-UTF-8 + * byte sequence to a string field. + * Message reflection will do the same. + * However, an extension field still accepts non-UTF-8 byte sequences. + * This option has no effect on when used with the lite runtime. + */ + javaStringCheckUtf8: boolean; + optimizeFor: FileOptions_OptimizeMode; + /** + * Sets the Go package where structs generated from this .proto will be + * placed. If omitted, the Go package will be derived from the following: + * - The basename of the package import path, if provided. + * - Otherwise, the package statement in the .proto file, if present. + * - Otherwise, the basename of the .proto file, without extension. + */ + goPackage: string; + /** + * Should generic services be generated in each language? "Generic" services + * are not specific to any particular RPC system. They are generated by the + * main code generators in each language (without additional plugins). + * Generic services were the only kind of service generation supported by + * early versions of google.protobuf. + * + * Generic services are now considered deprecated in favor of using plugins + * that generate code specific to your particular RPC system. Therefore, + * these default to false. Old code which depends on generic services should + * explicitly set them to true. + */ + ccGenericServices: boolean; + javaGenericServices: boolean; + pyGenericServices: boolean; + phpGenericServices: boolean; + /** + * Is this file deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for everything in the file, or it will be completely ignored; in the very + * least, this is a formalization for deprecating files. + */ + deprecated: boolean; + /** + * Enables the use of arenas for the proto messages in this file. This applies + * only to generated classes for C++. + */ + ccEnableArenas: boolean; + /** + * Sets the objective c class prefix which is prepended to all objective c + * generated classes from this .proto. There is no default. + */ + objcClassPrefix: string; + /** Namespace for generated classes; defaults to the package. */ + csharpNamespace: string; + /** + * By default Swift generators will take the proto package and CamelCase it + * replacing '.' with underscore and use that to prefix the types/symbols + * defined. When this options is provided, they will use this value instead + * to prefix the types/symbols defined. + */ + swiftPrefix: string; + /** + * Sets the php class prefix which is prepended to all php generated classes + * from this .proto. Default is empty. + */ + phpClassPrefix: string; + /** + * Use this option to change the namespace of php generated classes. Default + * is empty. When this option is empty, the package name will be used for + * determining the namespace. + */ + phpNamespace: string; + /** + * Use this option to change the namespace of php generated metadata classes. + * Default is empty. When this option is empty, the proto file name will be + * used for determining the namespace. + */ + phpMetadataNamespace: string; + /** + * Use this option to change the package of ruby generated classes. Default + * is empty. When this option is not set, the package name will be used for + * determining the ruby package. + */ + rubyPackage: string; + /** + * The parser stores options it doesn't recognize here. + * See the documentation for the "Options" section above. + */ + uninterpretedOption: UninterpretedOption[]; +} + +/** Generated classes can be optimized for speed or code size. */ +export enum FileOptions_OptimizeMode { + /** SPEED - Generate complete code for parsing, serialization, */ + SPEED = 1, + /** CODE_SIZE - etc. */ + CODE_SIZE = 2, + /** LITE_RUNTIME - Generate code using MessageLite and the lite runtime. */ + LITE_RUNTIME = 3, + UNRECOGNIZED = -1, +} + +export function fileOptions_OptimizeModeFromJSON( + object: any +): FileOptions_OptimizeMode { + switch (object) { + case 1: + case "SPEED": + return FileOptions_OptimizeMode.SPEED; + case 2: + case "CODE_SIZE": + return FileOptions_OptimizeMode.CODE_SIZE; + case 3: + case "LITE_RUNTIME": + return FileOptions_OptimizeMode.LITE_RUNTIME; + case -1: + case "UNRECOGNIZED": + default: + return FileOptions_OptimizeMode.UNRECOGNIZED; + } +} + +export function fileOptions_OptimizeModeToJSON( + object: FileOptions_OptimizeMode +): string { + switch (object) { + case FileOptions_OptimizeMode.SPEED: + return "SPEED"; + case FileOptions_OptimizeMode.CODE_SIZE: + return "CODE_SIZE"; + case FileOptions_OptimizeMode.LITE_RUNTIME: + return "LITE_RUNTIME"; + default: + return "UNKNOWN"; + } +} + +export interface MessageOptions { + /** + * Set true to use the old proto1 MessageSet wire format for extensions. + * This is provided for backwards-compatibility with the MessageSet wire + * format. You should not use this for any other reason: It's less + * efficient, has fewer features, and is more complicated. + * + * The message must be defined exactly as follows: + * message Foo { + * option message_set_wire_format = true; + * extensions 4 to max; + * } + * Note that the message cannot have any defined fields; MessageSets only + * have extensions. + * + * All extensions of your type must be singular messages; e.g. they cannot + * be int32s, enums, or repeated messages. + * + * Because this is an option, the above two restrictions are not enforced by + * the protocol compiler. + */ + messageSetWireFormat: boolean; + /** + * Disables the generation of the standard "descriptor()" accessor, which can + * conflict with a field of the same name. This is meant to make migration + * from proto1 easier; new code should avoid fields named "descriptor". + */ + noStandardDescriptorAccessor: boolean; + /** + * Is this message deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the message, or it will be completely ignored; in the very least, + * this is a formalization for deprecating messages. + */ + deprecated: boolean; + /** + * Whether the message is an automatically generated map entry type for the + * maps field. + * + * For maps fields: + * map map_field = 1; + * The parsed descriptor looks like: + * message MapFieldEntry { + * option map_entry = true; + * optional KeyType key = 1; + * optional ValueType value = 2; + * } + * repeated MapFieldEntry map_field = 1; + * + * Implementations may choose not to generate the map_entry=true message, but + * use a native map in the target language to hold the keys and values. + * The reflection APIs in such implementations still need to work as + * if the field is a repeated message field. + * + * NOTE: Do not set the option in .proto files. Always use the maps syntax + * instead. The option should only be implicitly set by the proto compiler + * parser. + */ + mapEntry: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface FieldOptions { + /** + * The ctype option instructs the C++ code generator to use a different + * representation of the field than it normally would. See the specific + * options below. This option is not yet implemented in the open source + * release -- sorry, we'll try to include it in a future version! + */ + ctype: FieldOptions_CType; + /** + * The packed option can be enabled for repeated primitive fields to enable + * a more efficient representation on the wire. Rather than repeatedly + * writing the tag and type for each element, the entire array is encoded as + * a single length-delimited blob. In proto3, only explicit setting it to + * false will avoid using packed encoding. + */ + packed: boolean; + /** + * The jstype option determines the JavaScript type used for values of the + * field. The option is permitted only for 64 bit integral and fixed types + * (int64, uint64, sint64, fixed64, sfixed64). A field with jstype JS_STRING + * is represented as JavaScript string, which avoids loss of precision that + * can happen when a large value is converted to a floating point JavaScript. + * Specifying JS_NUMBER for the jstype causes the generated JavaScript code to + * use the JavaScript "number" type. The behavior of the default option + * JS_NORMAL is implementation dependent. + * + * This option is an enum to permit additional types to be added, e.g. + * goog.math.Integer. + */ + jstype: FieldOptions_JSType; + /** + * Should this field be parsed lazily? Lazy applies only to message-type + * fields. It means that when the outer message is initially parsed, the + * inner message's contents will not be parsed but instead stored in encoded + * form. The inner message will actually be parsed when it is first accessed. + * + * This is only a hint. Implementations are free to choose whether to use + * eager or lazy parsing regardless of the value of this option. However, + * setting this option true suggests that the protocol author believes that + * using lazy parsing on this field is worth the additional bookkeeping + * overhead typically needed to implement it. + * + * This option does not affect the public interface of any generated code; + * all method signatures remain the same. Furthermore, thread-safety of the + * interface is not affected by this option; const methods remain safe to + * call from multiple threads concurrently, while non-const methods continue + * to require exclusive access. + * + * + * Note that implementations may choose not to check required fields within + * a lazy sub-message. That is, calling IsInitialized() on the outer message + * may return true even if the inner message has missing required fields. + * This is necessary because otherwise the inner message would have to be + * parsed in order to perform the check, defeating the purpose of lazy + * parsing. An implementation which chooses not to check required fields + * must be consistent about it. That is, for any particular sub-message, the + * implementation must either *always* check its required fields, or *never* + * check its required fields, regardless of whether or not the message has + * been parsed. + */ + lazy: boolean; + /** + * Is this field deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for accessors, or it will be completely ignored; in the very least, this + * is a formalization for deprecating fields. + */ + deprecated: boolean; + /** For Google-internal migration only. Do not use. */ + weak: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export enum FieldOptions_CType { + /** STRING - Default mode. */ + STRING = 0, + CORD = 1, + STRING_PIECE = 2, + UNRECOGNIZED = -1, +} + +export function fieldOptions_CTypeFromJSON(object: any): FieldOptions_CType { + switch (object) { + case 0: + case "STRING": + return FieldOptions_CType.STRING; + case 1: + case "CORD": + return FieldOptions_CType.CORD; + case 2: + case "STRING_PIECE": + return FieldOptions_CType.STRING_PIECE; + case -1: + case "UNRECOGNIZED": + default: + return FieldOptions_CType.UNRECOGNIZED; + } +} + +export function fieldOptions_CTypeToJSON(object: FieldOptions_CType): string { + switch (object) { + case FieldOptions_CType.STRING: + return "STRING"; + case FieldOptions_CType.CORD: + return "CORD"; + case FieldOptions_CType.STRING_PIECE: + return "STRING_PIECE"; + default: + return "UNKNOWN"; + } +} + +export enum FieldOptions_JSType { + /** JS_NORMAL - Use the default type. */ + JS_NORMAL = 0, + /** JS_STRING - Use JavaScript strings. */ + JS_STRING = 1, + /** JS_NUMBER - Use JavaScript numbers. */ + JS_NUMBER = 2, + UNRECOGNIZED = -1, +} + +export function fieldOptions_JSTypeFromJSON(object: any): FieldOptions_JSType { + switch (object) { + case 0: + case "JS_NORMAL": + return FieldOptions_JSType.JS_NORMAL; + case 1: + case "JS_STRING": + return FieldOptions_JSType.JS_STRING; + case 2: + case "JS_NUMBER": + return FieldOptions_JSType.JS_NUMBER; + case -1: + case "UNRECOGNIZED": + default: + return FieldOptions_JSType.UNRECOGNIZED; + } +} + +export function fieldOptions_JSTypeToJSON(object: FieldOptions_JSType): string { + switch (object) { + case FieldOptions_JSType.JS_NORMAL: + return "JS_NORMAL"; + case FieldOptions_JSType.JS_STRING: + return "JS_STRING"; + case FieldOptions_JSType.JS_NUMBER: + return "JS_NUMBER"; + default: + return "UNKNOWN"; + } +} + +export interface OneofOptions { + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface EnumOptions { + /** + * Set this option to true to allow mapping different tag names to the same + * value. + */ + allowAlias: boolean; + /** + * Is this enum deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the enum, or it will be completely ignored; in the very least, this + * is a formalization for deprecating enums. + */ + deprecated: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface EnumValueOptions { + /** + * Is this enum value deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the enum value, or it will be completely ignored; in the very least, + * this is a formalization for deprecating enum values. + */ + deprecated: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface ServiceOptions { + /** + * Is this service deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the service, or it will be completely ignored; in the very least, + * this is a formalization for deprecating services. + */ + deprecated: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface MethodOptions { + /** + * Is this method deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the method, or it will be completely ignored; in the very least, + * this is a formalization for deprecating methods. + */ + deprecated: boolean; + idempotencyLevel: MethodOptions_IdempotencyLevel; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +/** + * Is this method side-effect-free (or safe in HTTP parlance), or idempotent, + * or neither? HTTP based RPC implementation may choose GET verb for safe + * methods, and PUT verb for idempotent methods instead of the default POST. + */ +export enum MethodOptions_IdempotencyLevel { + IDEMPOTENCY_UNKNOWN = 0, + /** NO_SIDE_EFFECTS - implies idempotent */ + NO_SIDE_EFFECTS = 1, + /** IDEMPOTENT - idempotent, but may have side effects */ + IDEMPOTENT = 2, + UNRECOGNIZED = -1, +} + +export function methodOptions_IdempotencyLevelFromJSON( + object: any +): MethodOptions_IdempotencyLevel { + switch (object) { + case 0: + case "IDEMPOTENCY_UNKNOWN": + return MethodOptions_IdempotencyLevel.IDEMPOTENCY_UNKNOWN; + case 1: + case "NO_SIDE_EFFECTS": + return MethodOptions_IdempotencyLevel.NO_SIDE_EFFECTS; + case 2: + case "IDEMPOTENT": + return MethodOptions_IdempotencyLevel.IDEMPOTENT; + case -1: + case "UNRECOGNIZED": + default: + return MethodOptions_IdempotencyLevel.UNRECOGNIZED; + } +} + +export function methodOptions_IdempotencyLevelToJSON( + object: MethodOptions_IdempotencyLevel +): string { + switch (object) { + case MethodOptions_IdempotencyLevel.IDEMPOTENCY_UNKNOWN: + return "IDEMPOTENCY_UNKNOWN"; + case MethodOptions_IdempotencyLevel.NO_SIDE_EFFECTS: + return "NO_SIDE_EFFECTS"; + case MethodOptions_IdempotencyLevel.IDEMPOTENT: + return "IDEMPOTENT"; + default: + return "UNKNOWN"; + } +} + +/** + * A message representing a option the parser does not recognize. This only + * appears in options protos created by the compiler::Parser class. + * DescriptorPool resolves these when building Descriptor objects. Therefore, + * options protos in descriptor objects (e.g. returned by Descriptor::options(), + * or produced by Descriptor::CopyTo()) will never have UninterpretedOptions + * in them. + */ +export interface UninterpretedOption { + name: UninterpretedOption_NamePart[]; + /** + * The value of the uninterpreted option, in whatever type the tokenizer + * identified it as during parsing. Exactly one of these should be set. + */ + identifierValue: string; + positiveIntValue: number; + negativeIntValue: number; + doubleValue: number; + stringValue: Uint8Array; + aggregateValue: string; +} + +/** + * The name of the uninterpreted option. Each string represents a segment in + * a dot-separated name. is_extension is true iff a segment represents an + * extension (denoted with parentheses in options specs in .proto files). + * E.g.,{ ["foo", false], ["bar.baz", true], ["qux", false] } represents + * "foo.(bar.baz).qux". + */ +export interface UninterpretedOption_NamePart { + namePart: string; + isExtension: boolean; +} + +/** + * Encapsulates information about the original source file from which a + * FileDescriptorProto was generated. + */ +export interface SourceCodeInfo { + /** + * A Location identifies a piece of source code in a .proto file which + * corresponds to a particular definition. This information is intended + * to be useful to IDEs, code indexers, documentation generators, and similar + * tools. + * + * For example, say we have a file like: + * message Foo { + * optional string foo = 1; + * } + * Let's look at just the field definition: + * optional string foo = 1; + * ^ ^^ ^^ ^ ^^^ + * a bc de f ghi + * We have the following locations: + * span path represents + * [a,i) [ 4, 0, 2, 0 ] The whole field definition. + * [a,b) [ 4, 0, 2, 0, 4 ] The label (optional). + * [c,d) [ 4, 0, 2, 0, 5 ] The type (string). + * [e,f) [ 4, 0, 2, 0, 1 ] The name (foo). + * [g,h) [ 4, 0, 2, 0, 3 ] The number (1). + * + * Notes: + * - A location may refer to a repeated field itself (i.e. not to any + * particular index within it). This is used whenever a set of elements are + * logically enclosed in a single code segment. For example, an entire + * extend block (possibly containing multiple extension definitions) will + * have an outer location whose path refers to the "extensions" repeated + * field without an index. + * - Multiple locations may have the same path. This happens when a single + * logical declaration is spread out across multiple places. The most + * obvious example is the "extend" block again -- there may be multiple + * extend blocks in the same scope, each of which will have the same path. + * - A location's span is not always a subset of its parent's span. For + * example, the "extendee" of an extension declaration appears at the + * beginning of the "extend" block and is shared by all extensions within + * the block. + * - Just because a location's span is a subset of some other location's span + * does not mean that it is a descendant. For example, a "group" defines + * both a type and a field in a single declaration. Thus, the locations + * corresponding to the type and field and their components will overlap. + * - Code which tries to interpret locations should probably be designed to + * ignore those that it doesn't understand, as more types of locations could + * be recorded in the future. + */ + location: SourceCodeInfo_Location[]; +} + +export interface SourceCodeInfo_Location { + /** + * Identifies which part of the FileDescriptorProto was defined at this + * location. + * + * Each element is a field number or an index. They form a path from + * the root FileDescriptorProto to the place where the definition. For + * example, this path: + * [ 4, 3, 2, 7, 1 ] + * refers to: + * file.message_type(3) // 4, 3 + * .field(7) // 2, 7 + * .name() // 1 + * This is because FileDescriptorProto.message_type has field number 4: + * repeated DescriptorProto message_type = 4; + * and DescriptorProto.field has field number 2: + * repeated FieldDescriptorProto field = 2; + * and FieldDescriptorProto.name has field number 1: + * optional string name = 1; + * + * Thus, the above path gives the location of a field name. If we removed + * the last element: + * [ 4, 3, 2, 7 ] + * this path refers to the whole field declaration (from the beginning + * of the label to the terminating semicolon). + */ + path: number[]; + /** + * Always has exactly three or four elements: start line, start column, + * end line (optional, otherwise assumed same as start line), end column. + * These are packed into a single field for efficiency. Note that line + * and column numbers are zero-based -- typically you will want to add + * 1 to each before displaying to a user. + */ + span: number[]; + /** + * If this SourceCodeInfo represents a complete declaration, these are any + * comments appearing before and after the declaration which appear to be + * attached to the declaration. + * + * A series of line comments appearing on consecutive lines, with no other + * tokens appearing on those lines, will be treated as a single comment. + * + * leading_detached_comments will keep paragraphs of comments that appear + * before (but not connected to) the current element. Each paragraph, + * separated by empty lines, will be one comment element in the repeated + * field. + * + * Only the comment content is provided; comment markers (e.g. //) are + * stripped out. For block comments, leading whitespace and an asterisk + * will be stripped from the beginning of each line other than the first. + * Newlines are included in the output. + * + * Examples: + * + * optional int32 foo = 1; // Comment attached to foo. + * // Comment attached to bar. + * optional int32 bar = 2; + * + * optional string baz = 3; + * // Comment attached to baz. + * // Another line attached to baz. + * + * // Comment attached to qux. + * // + * // Another line attached to qux. + * optional double qux = 4; + * + * // Detached comment for corge. This is not leading or trailing comments + * // to qux or corge because there are blank lines separating it from + * // both. + * + * // Detached comment for corge paragraph 2. + * + * optional string corge = 5; + * /* Block comment attached + * * to corge. Leading asterisks + * * will be removed. * / + * /* Block comment attached to + * * grault. * / + * optional int32 grault = 6; + * + * // ignored detached comments. + */ + leadingComments: string; + trailingComments: string; + leadingDetachedComments: string[]; +} + +/** + * Describes the relationship between generated code and its original source + * file. A GeneratedCodeInfo message is associated with only one generated + * source file, but may contain references to different source .proto files. + */ +export interface GeneratedCodeInfo { + /** + * An Annotation connects some span of text in generated code to an element + * of its generating .proto file. + */ + annotation: GeneratedCodeInfo_Annotation[]; +} + +export interface GeneratedCodeInfo_Annotation { + /** + * Identifies the element in the original source .proto file. This field + * is formatted the same as SourceCodeInfo.Location.path. + */ + path: number[]; + /** Identifies the filesystem path to the original source .proto. */ + sourceFile: string; + /** + * Identifies the starting offset in bytes in the generated code + * that relates to the identified object. + */ + begin: number; + /** + * Identifies the ending offset in bytes in the generated code that + * relates to the identified offset. The end offset should be one past + * the last relevant byte (so the length of the text = end - begin). + */ + end: number; +} + +const baseFileDescriptorSet: object = {}; + +export const FileDescriptorSet = { + encode(message: FileDescriptorSet, writer: Writer = Writer.create()): Writer { + for (const v of message.file) { + FileDescriptorProto.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FileDescriptorSet { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFileDescriptorSet } as FileDescriptorSet; + message.file = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.file.push( + FileDescriptorProto.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FileDescriptorSet { + const message = { ...baseFileDescriptorSet } as FileDescriptorSet; + message.file = []; + if (object.file !== undefined && object.file !== null) { + for (const e of object.file) { + message.file.push(FileDescriptorProto.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: FileDescriptorSet): unknown { + const obj: any = {}; + if (message.file) { + obj.file = message.file.map((e) => + e ? FileDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.file = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): FileDescriptorSet { + const message = { ...baseFileDescriptorSet } as FileDescriptorSet; + message.file = []; + if (object.file !== undefined && object.file !== null) { + for (const e of object.file) { + message.file.push(FileDescriptorProto.fromPartial(e)); + } + } + return message; + }, +}; + +const baseFileDescriptorProto: object = { + name: "", + package: "", + dependency: "", + publicDependency: 0, + weakDependency: 0, + syntax: "", +}; + +export const FileDescriptorProto = { + encode( + message: FileDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.package !== "") { + writer.uint32(18).string(message.package); + } + for (const v of message.dependency) { + writer.uint32(26).string(v!); + } + writer.uint32(82).fork(); + for (const v of message.publicDependency) { + writer.int32(v); + } + writer.ldelim(); + writer.uint32(90).fork(); + for (const v of message.weakDependency) { + writer.int32(v); + } + writer.ldelim(); + for (const v of message.messageType) { + DescriptorProto.encode(v!, writer.uint32(34).fork()).ldelim(); + } + for (const v of message.enumType) { + EnumDescriptorProto.encode(v!, writer.uint32(42).fork()).ldelim(); + } + for (const v of message.service) { + ServiceDescriptorProto.encode(v!, writer.uint32(50).fork()).ldelim(); + } + for (const v of message.extension) { + FieldDescriptorProto.encode(v!, writer.uint32(58).fork()).ldelim(); + } + if (message.options !== undefined) { + FileOptions.encode(message.options, writer.uint32(66).fork()).ldelim(); + } + if (message.sourceCodeInfo !== undefined) { + SourceCodeInfo.encode( + message.sourceCodeInfo, + writer.uint32(74).fork() + ).ldelim(); + } + if (message.syntax !== "") { + writer.uint32(98).string(message.syntax); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FileDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFileDescriptorProto } as FileDescriptorProto; + message.dependency = []; + message.publicDependency = []; + message.weakDependency = []; + message.messageType = []; + message.enumType = []; + message.service = []; + message.extension = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.package = reader.string(); + break; + case 3: + message.dependency.push(reader.string()); + break; + case 10: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.publicDependency.push(reader.int32()); + } + } else { + message.publicDependency.push(reader.int32()); + } + break; + case 11: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.weakDependency.push(reader.int32()); + } + } else { + message.weakDependency.push(reader.int32()); + } + break; + case 4: + message.messageType.push( + DescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 5: + message.enumType.push( + EnumDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 6: + message.service.push( + ServiceDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 7: + message.extension.push( + FieldDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 8: + message.options = FileOptions.decode(reader, reader.uint32()); + break; + case 9: + message.sourceCodeInfo = SourceCodeInfo.decode( + reader, + reader.uint32() + ); + break; + case 12: + message.syntax = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FileDescriptorProto { + const message = { ...baseFileDescriptorProto } as FileDescriptorProto; + message.dependency = []; + message.publicDependency = []; + message.weakDependency = []; + message.messageType = []; + message.enumType = []; + message.service = []; + message.extension = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.package !== undefined && object.package !== null) { + message.package = String(object.package); + } else { + message.package = ""; + } + if (object.dependency !== undefined && object.dependency !== null) { + for (const e of object.dependency) { + message.dependency.push(String(e)); + } + } + if ( + object.publicDependency !== undefined && + object.publicDependency !== null + ) { + for (const e of object.publicDependency) { + message.publicDependency.push(Number(e)); + } + } + if (object.weakDependency !== undefined && object.weakDependency !== null) { + for (const e of object.weakDependency) { + message.weakDependency.push(Number(e)); + } + } + if (object.messageType !== undefined && object.messageType !== null) { + for (const e of object.messageType) { + message.messageType.push(DescriptorProto.fromJSON(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromJSON(e)); + } + } + if (object.service !== undefined && object.service !== null) { + for (const e of object.service) { + message.service.push(ServiceDescriptorProto.fromJSON(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = FileOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.sourceCodeInfo !== undefined && object.sourceCodeInfo !== null) { + message.sourceCodeInfo = SourceCodeInfo.fromJSON(object.sourceCodeInfo); + } else { + message.sourceCodeInfo = undefined; + } + if (object.syntax !== undefined && object.syntax !== null) { + message.syntax = String(object.syntax); + } else { + message.syntax = ""; + } + return message; + }, + + toJSON(message: FileDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.package !== undefined && (obj.package = message.package); + if (message.dependency) { + obj.dependency = message.dependency.map((e) => e); + } else { + obj.dependency = []; + } + if (message.publicDependency) { + obj.publicDependency = message.publicDependency.map((e) => e); + } else { + obj.publicDependency = []; + } + if (message.weakDependency) { + obj.weakDependency = message.weakDependency.map((e) => e); + } else { + obj.weakDependency = []; + } + if (message.messageType) { + obj.messageType = message.messageType.map((e) => + e ? DescriptorProto.toJSON(e) : undefined + ); + } else { + obj.messageType = []; + } + if (message.enumType) { + obj.enumType = message.enumType.map((e) => + e ? EnumDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.enumType = []; + } + if (message.service) { + obj.service = message.service.map((e) => + e ? ServiceDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.service = []; + } + if (message.extension) { + obj.extension = message.extension.map((e) => + e ? FieldDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.extension = []; + } + message.options !== undefined && + (obj.options = message.options + ? FileOptions.toJSON(message.options) + : undefined); + message.sourceCodeInfo !== undefined && + (obj.sourceCodeInfo = message.sourceCodeInfo + ? SourceCodeInfo.toJSON(message.sourceCodeInfo) + : undefined); + message.syntax !== undefined && (obj.syntax = message.syntax); + return obj; + }, + + fromPartial(object: DeepPartial): FileDescriptorProto { + const message = { ...baseFileDescriptorProto } as FileDescriptorProto; + message.dependency = []; + message.publicDependency = []; + message.weakDependency = []; + message.messageType = []; + message.enumType = []; + message.service = []; + message.extension = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.package !== undefined && object.package !== null) { + message.package = object.package; + } else { + message.package = ""; + } + if (object.dependency !== undefined && object.dependency !== null) { + for (const e of object.dependency) { + message.dependency.push(e); + } + } + if ( + object.publicDependency !== undefined && + object.publicDependency !== null + ) { + for (const e of object.publicDependency) { + message.publicDependency.push(e); + } + } + if (object.weakDependency !== undefined && object.weakDependency !== null) { + for (const e of object.weakDependency) { + message.weakDependency.push(e); + } + } + if (object.messageType !== undefined && object.messageType !== null) { + for (const e of object.messageType) { + message.messageType.push(DescriptorProto.fromPartial(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromPartial(e)); + } + } + if (object.service !== undefined && object.service !== null) { + for (const e of object.service) { + message.service.push(ServiceDescriptorProto.fromPartial(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = FileOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.sourceCodeInfo !== undefined && object.sourceCodeInfo !== null) { + message.sourceCodeInfo = SourceCodeInfo.fromPartial( + object.sourceCodeInfo + ); + } else { + message.sourceCodeInfo = undefined; + } + if (object.syntax !== undefined && object.syntax !== null) { + message.syntax = object.syntax; + } else { + message.syntax = ""; + } + return message; + }, +}; + +const baseDescriptorProto: object = { name: "", reservedName: "" }; + +export const DescriptorProto = { + encode(message: DescriptorProto, writer: Writer = Writer.create()): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + for (const v of message.field) { + FieldDescriptorProto.encode(v!, writer.uint32(18).fork()).ldelim(); + } + for (const v of message.extension) { + FieldDescriptorProto.encode(v!, writer.uint32(50).fork()).ldelim(); + } + for (const v of message.nestedType) { + DescriptorProto.encode(v!, writer.uint32(26).fork()).ldelim(); + } + for (const v of message.enumType) { + EnumDescriptorProto.encode(v!, writer.uint32(34).fork()).ldelim(); + } + for (const v of message.extensionRange) { + DescriptorProto_ExtensionRange.encode( + v!, + writer.uint32(42).fork() + ).ldelim(); + } + for (const v of message.oneofDecl) { + OneofDescriptorProto.encode(v!, writer.uint32(66).fork()).ldelim(); + } + if (message.options !== undefined) { + MessageOptions.encode(message.options, writer.uint32(58).fork()).ldelim(); + } + for (const v of message.reservedRange) { + DescriptorProto_ReservedRange.encode( + v!, + writer.uint32(74).fork() + ).ldelim(); + } + for (const v of message.reservedName) { + writer.uint32(82).string(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): DescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseDescriptorProto } as DescriptorProto; + message.field = []; + message.extension = []; + message.nestedType = []; + message.enumType = []; + message.extensionRange = []; + message.oneofDecl = []; + message.reservedRange = []; + message.reservedName = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.field.push( + FieldDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 6: + message.extension.push( + FieldDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 3: + message.nestedType.push( + DescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 4: + message.enumType.push( + EnumDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 5: + message.extensionRange.push( + DescriptorProto_ExtensionRange.decode(reader, reader.uint32()) + ); + break; + case 8: + message.oneofDecl.push( + OneofDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 7: + message.options = MessageOptions.decode(reader, reader.uint32()); + break; + case 9: + message.reservedRange.push( + DescriptorProto_ReservedRange.decode(reader, reader.uint32()) + ); + break; + case 10: + message.reservedName.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DescriptorProto { + const message = { ...baseDescriptorProto } as DescriptorProto; + message.field = []; + message.extension = []; + message.nestedType = []; + message.enumType = []; + message.extensionRange = []; + message.oneofDecl = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.field !== undefined && object.field !== null) { + for (const e of object.field) { + message.field.push(FieldDescriptorProto.fromJSON(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromJSON(e)); + } + } + if (object.nestedType !== undefined && object.nestedType !== null) { + for (const e of object.nestedType) { + message.nestedType.push(DescriptorProto.fromJSON(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromJSON(e)); + } + } + if (object.extensionRange !== undefined && object.extensionRange !== null) { + for (const e of object.extensionRange) { + message.extensionRange.push(DescriptorProto_ExtensionRange.fromJSON(e)); + } + } + if (object.oneofDecl !== undefined && object.oneofDecl !== null) { + for (const e of object.oneofDecl) { + message.oneofDecl.push(OneofDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = MessageOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push(DescriptorProto_ReservedRange.fromJSON(e)); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(String(e)); + } + } + return message; + }, + + toJSON(message: DescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + if (message.field) { + obj.field = message.field.map((e) => + e ? FieldDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.field = []; + } + if (message.extension) { + obj.extension = message.extension.map((e) => + e ? FieldDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.extension = []; + } + if (message.nestedType) { + obj.nestedType = message.nestedType.map((e) => + e ? DescriptorProto.toJSON(e) : undefined + ); + } else { + obj.nestedType = []; + } + if (message.enumType) { + obj.enumType = message.enumType.map((e) => + e ? EnumDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.enumType = []; + } + if (message.extensionRange) { + obj.extensionRange = message.extensionRange.map((e) => + e ? DescriptorProto_ExtensionRange.toJSON(e) : undefined + ); + } else { + obj.extensionRange = []; + } + if (message.oneofDecl) { + obj.oneofDecl = message.oneofDecl.map((e) => + e ? OneofDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.oneofDecl = []; + } + message.options !== undefined && + (obj.options = message.options + ? MessageOptions.toJSON(message.options) + : undefined); + if (message.reservedRange) { + obj.reservedRange = message.reservedRange.map((e) => + e ? DescriptorProto_ReservedRange.toJSON(e) : undefined + ); + } else { + obj.reservedRange = []; + } + if (message.reservedName) { + obj.reservedName = message.reservedName.map((e) => e); + } else { + obj.reservedName = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): DescriptorProto { + const message = { ...baseDescriptorProto } as DescriptorProto; + message.field = []; + message.extension = []; + message.nestedType = []; + message.enumType = []; + message.extensionRange = []; + message.oneofDecl = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.field !== undefined && object.field !== null) { + for (const e of object.field) { + message.field.push(FieldDescriptorProto.fromPartial(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromPartial(e)); + } + } + if (object.nestedType !== undefined && object.nestedType !== null) { + for (const e of object.nestedType) { + message.nestedType.push(DescriptorProto.fromPartial(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromPartial(e)); + } + } + if (object.extensionRange !== undefined && object.extensionRange !== null) { + for (const e of object.extensionRange) { + message.extensionRange.push( + DescriptorProto_ExtensionRange.fromPartial(e) + ); + } + } + if (object.oneofDecl !== undefined && object.oneofDecl !== null) { + for (const e of object.oneofDecl) { + message.oneofDecl.push(OneofDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = MessageOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push( + DescriptorProto_ReservedRange.fromPartial(e) + ); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(e); + } + } + return message; + }, +}; + +const baseDescriptorProto_ExtensionRange: object = { start: 0, end: 0 }; + +export const DescriptorProto_ExtensionRange = { + encode( + message: DescriptorProto_ExtensionRange, + writer: Writer = Writer.create() + ): Writer { + if (message.start !== 0) { + writer.uint32(8).int32(message.start); + } + if (message.end !== 0) { + writer.uint32(16).int32(message.end); + } + if (message.options !== undefined) { + ExtensionRangeOptions.encode( + message.options, + writer.uint32(26).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): DescriptorProto_ExtensionRange { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseDescriptorProto_ExtensionRange, + } as DescriptorProto_ExtensionRange; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.start = reader.int32(); + break; + case 2: + message.end = reader.int32(); + break; + case 3: + message.options = ExtensionRangeOptions.decode( + reader, + reader.uint32() + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DescriptorProto_ExtensionRange { + const message = { + ...baseDescriptorProto_ExtensionRange, + } as DescriptorProto_ExtensionRange; + if (object.start !== undefined && object.start !== null) { + message.start = Number(object.start); + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = ExtensionRangeOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: DescriptorProto_ExtensionRange): unknown { + const obj: any = {}; + message.start !== undefined && (obj.start = message.start); + message.end !== undefined && (obj.end = message.end); + message.options !== undefined && + (obj.options = message.options + ? ExtensionRangeOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): DescriptorProto_ExtensionRange { + const message = { + ...baseDescriptorProto_ExtensionRange, + } as DescriptorProto_ExtensionRange; + if (object.start !== undefined && object.start !== null) { + message.start = object.start; + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = ExtensionRangeOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseDescriptorProto_ReservedRange: object = { start: 0, end: 0 }; + +export const DescriptorProto_ReservedRange = { + encode( + message: DescriptorProto_ReservedRange, + writer: Writer = Writer.create() + ): Writer { + if (message.start !== 0) { + writer.uint32(8).int32(message.start); + } + if (message.end !== 0) { + writer.uint32(16).int32(message.end); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): DescriptorProto_ReservedRange { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseDescriptorProto_ReservedRange, + } as DescriptorProto_ReservedRange; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.start = reader.int32(); + break; + case 2: + message.end = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DescriptorProto_ReservedRange { + const message = { + ...baseDescriptorProto_ReservedRange, + } as DescriptorProto_ReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = Number(object.start); + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + return message; + }, + + toJSON(message: DescriptorProto_ReservedRange): unknown { + const obj: any = {}; + message.start !== undefined && (obj.start = message.start); + message.end !== undefined && (obj.end = message.end); + return obj; + }, + + fromPartial( + object: DeepPartial + ): DescriptorProto_ReservedRange { + const message = { + ...baseDescriptorProto_ReservedRange, + } as DescriptorProto_ReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = object.start; + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + return message; + }, +}; + +const baseExtensionRangeOptions: object = {}; + +export const ExtensionRangeOptions = { + encode( + message: ExtensionRangeOptions, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ExtensionRangeOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseExtensionRangeOptions } as ExtensionRangeOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ExtensionRangeOptions { + const message = { ...baseExtensionRangeOptions } as ExtensionRangeOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: ExtensionRangeOptions): unknown { + const obj: any = {}; + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial( + object: DeepPartial + ): ExtensionRangeOptions { + const message = { ...baseExtensionRangeOptions } as ExtensionRangeOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseFieldDescriptorProto: object = { + name: "", + number: 0, + label: 1, + type: 1, + typeName: "", + extendee: "", + defaultValue: "", + oneofIndex: 0, + jsonName: "", + proto3Optional: false, +}; + +export const FieldDescriptorProto = { + encode( + message: FieldDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.number !== 0) { + writer.uint32(24).int32(message.number); + } + if (message.label !== 1) { + writer.uint32(32).int32(message.label); + } + if (message.type !== 1) { + writer.uint32(40).int32(message.type); + } + if (message.typeName !== "") { + writer.uint32(50).string(message.typeName); + } + if (message.extendee !== "") { + writer.uint32(18).string(message.extendee); + } + if (message.defaultValue !== "") { + writer.uint32(58).string(message.defaultValue); + } + if (message.oneofIndex !== 0) { + writer.uint32(72).int32(message.oneofIndex); + } + if (message.jsonName !== "") { + writer.uint32(82).string(message.jsonName); + } + if (message.options !== undefined) { + FieldOptions.encode(message.options, writer.uint32(66).fork()).ldelim(); + } + if (message.proto3Optional === true) { + writer.uint32(136).bool(message.proto3Optional); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FieldDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFieldDescriptorProto } as FieldDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 3: + message.number = reader.int32(); + break; + case 4: + message.label = reader.int32() as any; + break; + case 5: + message.type = reader.int32() as any; + break; + case 6: + message.typeName = reader.string(); + break; + case 2: + message.extendee = reader.string(); + break; + case 7: + message.defaultValue = reader.string(); + break; + case 9: + message.oneofIndex = reader.int32(); + break; + case 10: + message.jsonName = reader.string(); + break; + case 8: + message.options = FieldOptions.decode(reader, reader.uint32()); + break; + case 17: + message.proto3Optional = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FieldDescriptorProto { + const message = { ...baseFieldDescriptorProto } as FieldDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = Number(object.number); + } else { + message.number = 0; + } + if (object.label !== undefined && object.label !== null) { + message.label = fieldDescriptorProto_LabelFromJSON(object.label); + } else { + message.label = 1; + } + if (object.type !== undefined && object.type !== null) { + message.type = fieldDescriptorProto_TypeFromJSON(object.type); + } else { + message.type = 1; + } + if (object.typeName !== undefined && object.typeName !== null) { + message.typeName = String(object.typeName); + } else { + message.typeName = ""; + } + if (object.extendee !== undefined && object.extendee !== null) { + message.extendee = String(object.extendee); + } else { + message.extendee = ""; + } + if (object.defaultValue !== undefined && object.defaultValue !== null) { + message.defaultValue = String(object.defaultValue); + } else { + message.defaultValue = ""; + } + if (object.oneofIndex !== undefined && object.oneofIndex !== null) { + message.oneofIndex = Number(object.oneofIndex); + } else { + message.oneofIndex = 0; + } + if (object.jsonName !== undefined && object.jsonName !== null) { + message.jsonName = String(object.jsonName); + } else { + message.jsonName = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = FieldOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.proto3Optional !== undefined && object.proto3Optional !== null) { + message.proto3Optional = Boolean(object.proto3Optional); + } else { + message.proto3Optional = false; + } + return message; + }, + + toJSON(message: FieldDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.number !== undefined && (obj.number = message.number); + message.label !== undefined && + (obj.label = fieldDescriptorProto_LabelToJSON(message.label)); + message.type !== undefined && + (obj.type = fieldDescriptorProto_TypeToJSON(message.type)); + message.typeName !== undefined && (obj.typeName = message.typeName); + message.extendee !== undefined && (obj.extendee = message.extendee); + message.defaultValue !== undefined && + (obj.defaultValue = message.defaultValue); + message.oneofIndex !== undefined && (obj.oneofIndex = message.oneofIndex); + message.jsonName !== undefined && (obj.jsonName = message.jsonName); + message.options !== undefined && + (obj.options = message.options + ? FieldOptions.toJSON(message.options) + : undefined); + message.proto3Optional !== undefined && + (obj.proto3Optional = message.proto3Optional); + return obj; + }, + + fromPartial(object: DeepPartial): FieldDescriptorProto { + const message = { ...baseFieldDescriptorProto } as FieldDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = object.number; + } else { + message.number = 0; + } + if (object.label !== undefined && object.label !== null) { + message.label = object.label; + } else { + message.label = 1; + } + if (object.type !== undefined && object.type !== null) { + message.type = object.type; + } else { + message.type = 1; + } + if (object.typeName !== undefined && object.typeName !== null) { + message.typeName = object.typeName; + } else { + message.typeName = ""; + } + if (object.extendee !== undefined && object.extendee !== null) { + message.extendee = object.extendee; + } else { + message.extendee = ""; + } + if (object.defaultValue !== undefined && object.defaultValue !== null) { + message.defaultValue = object.defaultValue; + } else { + message.defaultValue = ""; + } + if (object.oneofIndex !== undefined && object.oneofIndex !== null) { + message.oneofIndex = object.oneofIndex; + } else { + message.oneofIndex = 0; + } + if (object.jsonName !== undefined && object.jsonName !== null) { + message.jsonName = object.jsonName; + } else { + message.jsonName = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = FieldOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.proto3Optional !== undefined && object.proto3Optional !== null) { + message.proto3Optional = object.proto3Optional; + } else { + message.proto3Optional = false; + } + return message; + }, +}; + +const baseOneofDescriptorProto: object = { name: "" }; + +export const OneofDescriptorProto = { + encode( + message: OneofDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.options !== undefined) { + OneofOptions.encode(message.options, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): OneofDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseOneofDescriptorProto } as OneofDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.options = OneofOptions.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): OneofDescriptorProto { + const message = { ...baseOneofDescriptorProto } as OneofDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = OneofOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: OneofDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.options !== undefined && + (obj.options = message.options + ? OneofOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): OneofDescriptorProto { + const message = { ...baseOneofDescriptorProto } as OneofDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = OneofOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseEnumDescriptorProto: object = { name: "", reservedName: "" }; + +export const EnumDescriptorProto = { + encode( + message: EnumDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + for (const v of message.value) { + EnumValueDescriptorProto.encode(v!, writer.uint32(18).fork()).ldelim(); + } + if (message.options !== undefined) { + EnumOptions.encode(message.options, writer.uint32(26).fork()).ldelim(); + } + for (const v of message.reservedRange) { + EnumDescriptorProto_EnumReservedRange.encode( + v!, + writer.uint32(34).fork() + ).ldelim(); + } + for (const v of message.reservedName) { + writer.uint32(42).string(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): EnumDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseEnumDescriptorProto } as EnumDescriptorProto; + message.value = []; + message.reservedRange = []; + message.reservedName = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.value.push( + EnumValueDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 3: + message.options = EnumOptions.decode(reader, reader.uint32()); + break; + case 4: + message.reservedRange.push( + EnumDescriptorProto_EnumReservedRange.decode( + reader, + reader.uint32() + ) + ); + break; + case 5: + message.reservedName.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumDescriptorProto { + const message = { ...baseEnumDescriptorProto } as EnumDescriptorProto; + message.value = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.value !== undefined && object.value !== null) { + for (const e of object.value) { + message.value.push(EnumValueDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push( + EnumDescriptorProto_EnumReservedRange.fromJSON(e) + ); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(String(e)); + } + } + return message; + }, + + toJSON(message: EnumDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + if (message.value) { + obj.value = message.value.map((e) => + e ? EnumValueDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.value = []; + } + message.options !== undefined && + (obj.options = message.options + ? EnumOptions.toJSON(message.options) + : undefined); + if (message.reservedRange) { + obj.reservedRange = message.reservedRange.map((e) => + e ? EnumDescriptorProto_EnumReservedRange.toJSON(e) : undefined + ); + } else { + obj.reservedRange = []; + } + if (message.reservedName) { + obj.reservedName = message.reservedName.map((e) => e); + } else { + obj.reservedName = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): EnumDescriptorProto { + const message = { ...baseEnumDescriptorProto } as EnumDescriptorProto; + message.value = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.value !== undefined && object.value !== null) { + for (const e of object.value) { + message.value.push(EnumValueDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push( + EnumDescriptorProto_EnumReservedRange.fromPartial(e) + ); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(e); + } + } + return message; + }, +}; + +const baseEnumDescriptorProto_EnumReservedRange: object = { start: 0, end: 0 }; + +export const EnumDescriptorProto_EnumReservedRange = { + encode( + message: EnumDescriptorProto_EnumReservedRange, + writer: Writer = Writer.create() + ): Writer { + if (message.start !== 0) { + writer.uint32(8).int32(message.start); + } + if (message.end !== 0) { + writer.uint32(16).int32(message.end); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): EnumDescriptorProto_EnumReservedRange { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseEnumDescriptorProto_EnumReservedRange, + } as EnumDescriptorProto_EnumReservedRange; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.start = reader.int32(); + break; + case 2: + message.end = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumDescriptorProto_EnumReservedRange { + const message = { + ...baseEnumDescriptorProto_EnumReservedRange, + } as EnumDescriptorProto_EnumReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = Number(object.start); + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + return message; + }, + + toJSON(message: EnumDescriptorProto_EnumReservedRange): unknown { + const obj: any = {}; + message.start !== undefined && (obj.start = message.start); + message.end !== undefined && (obj.end = message.end); + return obj; + }, + + fromPartial( + object: DeepPartial + ): EnumDescriptorProto_EnumReservedRange { + const message = { + ...baseEnumDescriptorProto_EnumReservedRange, + } as EnumDescriptorProto_EnumReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = object.start; + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + return message; + }, +}; + +const baseEnumValueDescriptorProto: object = { name: "", number: 0 }; + +export const EnumValueDescriptorProto = { + encode( + message: EnumValueDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.number !== 0) { + writer.uint32(16).int32(message.number); + } + if (message.options !== undefined) { + EnumValueOptions.encode( + message.options, + writer.uint32(26).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): EnumValueDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseEnumValueDescriptorProto, + } as EnumValueDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.number = reader.int32(); + break; + case 3: + message.options = EnumValueOptions.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumValueDescriptorProto { + const message = { + ...baseEnumValueDescriptorProto, + } as EnumValueDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = Number(object.number); + } else { + message.number = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumValueOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: EnumValueDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.number !== undefined && (obj.number = message.number); + message.options !== undefined && + (obj.options = message.options + ? EnumValueOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): EnumValueDescriptorProto { + const message = { + ...baseEnumValueDescriptorProto, + } as EnumValueDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = object.number; + } else { + message.number = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumValueOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseServiceDescriptorProto: object = { name: "" }; + +export const ServiceDescriptorProto = { + encode( + message: ServiceDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + for (const v of message.method) { + MethodDescriptorProto.encode(v!, writer.uint32(18).fork()).ldelim(); + } + if (message.options !== undefined) { + ServiceOptions.encode(message.options, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ServiceDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseServiceDescriptorProto } as ServiceDescriptorProto; + message.method = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.method.push( + MethodDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 3: + message.options = ServiceOptions.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ServiceDescriptorProto { + const message = { ...baseServiceDescriptorProto } as ServiceDescriptorProto; + message.method = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.method !== undefined && object.method !== null) { + for (const e of object.method) { + message.method.push(MethodDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = ServiceOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: ServiceDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + if (message.method) { + obj.method = message.method.map((e) => + e ? MethodDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.method = []; + } + message.options !== undefined && + (obj.options = message.options + ? ServiceOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): ServiceDescriptorProto { + const message = { ...baseServiceDescriptorProto } as ServiceDescriptorProto; + message.method = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.method !== undefined && object.method !== null) { + for (const e of object.method) { + message.method.push(MethodDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = ServiceOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseMethodDescriptorProto: object = { + name: "", + inputType: "", + outputType: "", + clientStreaming: false, + serverStreaming: false, +}; + +export const MethodDescriptorProto = { + encode( + message: MethodDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.inputType !== "") { + writer.uint32(18).string(message.inputType); + } + if (message.outputType !== "") { + writer.uint32(26).string(message.outputType); + } + if (message.options !== undefined) { + MethodOptions.encode(message.options, writer.uint32(34).fork()).ldelim(); + } + if (message.clientStreaming === true) { + writer.uint32(40).bool(message.clientStreaming); + } + if (message.serverStreaming === true) { + writer.uint32(48).bool(message.serverStreaming); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MethodDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMethodDescriptorProto } as MethodDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.inputType = reader.string(); + break; + case 3: + message.outputType = reader.string(); + break; + case 4: + message.options = MethodOptions.decode(reader, reader.uint32()); + break; + case 5: + message.clientStreaming = reader.bool(); + break; + case 6: + message.serverStreaming = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MethodDescriptorProto { + const message = { ...baseMethodDescriptorProto } as MethodDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.inputType !== undefined && object.inputType !== null) { + message.inputType = String(object.inputType); + } else { + message.inputType = ""; + } + if (object.outputType !== undefined && object.outputType !== null) { + message.outputType = String(object.outputType); + } else { + message.outputType = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = MethodOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if ( + object.clientStreaming !== undefined && + object.clientStreaming !== null + ) { + message.clientStreaming = Boolean(object.clientStreaming); + } else { + message.clientStreaming = false; + } + if ( + object.serverStreaming !== undefined && + object.serverStreaming !== null + ) { + message.serverStreaming = Boolean(object.serverStreaming); + } else { + message.serverStreaming = false; + } + return message; + }, + + toJSON(message: MethodDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.inputType !== undefined && (obj.inputType = message.inputType); + message.outputType !== undefined && (obj.outputType = message.outputType); + message.options !== undefined && + (obj.options = message.options + ? MethodOptions.toJSON(message.options) + : undefined); + message.clientStreaming !== undefined && + (obj.clientStreaming = message.clientStreaming); + message.serverStreaming !== undefined && + (obj.serverStreaming = message.serverStreaming); + return obj; + }, + + fromPartial( + object: DeepPartial + ): MethodDescriptorProto { + const message = { ...baseMethodDescriptorProto } as MethodDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.inputType !== undefined && object.inputType !== null) { + message.inputType = object.inputType; + } else { + message.inputType = ""; + } + if (object.outputType !== undefined && object.outputType !== null) { + message.outputType = object.outputType; + } else { + message.outputType = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = MethodOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if ( + object.clientStreaming !== undefined && + object.clientStreaming !== null + ) { + message.clientStreaming = object.clientStreaming; + } else { + message.clientStreaming = false; + } + if ( + object.serverStreaming !== undefined && + object.serverStreaming !== null + ) { + message.serverStreaming = object.serverStreaming; + } else { + message.serverStreaming = false; + } + return message; + }, +}; + +const baseFileOptions: object = { + javaPackage: "", + javaOuterClassname: "", + javaMultipleFiles: false, + javaGenerateEqualsAndHash: false, + javaStringCheckUtf8: false, + optimizeFor: 1, + goPackage: "", + ccGenericServices: false, + javaGenericServices: false, + pyGenericServices: false, + phpGenericServices: false, + deprecated: false, + ccEnableArenas: false, + objcClassPrefix: "", + csharpNamespace: "", + swiftPrefix: "", + phpClassPrefix: "", + phpNamespace: "", + phpMetadataNamespace: "", + rubyPackage: "", +}; + +export const FileOptions = { + encode(message: FileOptions, writer: Writer = Writer.create()): Writer { + if (message.javaPackage !== "") { + writer.uint32(10).string(message.javaPackage); + } + if (message.javaOuterClassname !== "") { + writer.uint32(66).string(message.javaOuterClassname); + } + if (message.javaMultipleFiles === true) { + writer.uint32(80).bool(message.javaMultipleFiles); + } + if (message.javaGenerateEqualsAndHash === true) { + writer.uint32(160).bool(message.javaGenerateEqualsAndHash); + } + if (message.javaStringCheckUtf8 === true) { + writer.uint32(216).bool(message.javaStringCheckUtf8); + } + if (message.optimizeFor !== 1) { + writer.uint32(72).int32(message.optimizeFor); + } + if (message.goPackage !== "") { + writer.uint32(90).string(message.goPackage); + } + if (message.ccGenericServices === true) { + writer.uint32(128).bool(message.ccGenericServices); + } + if (message.javaGenericServices === true) { + writer.uint32(136).bool(message.javaGenericServices); + } + if (message.pyGenericServices === true) { + writer.uint32(144).bool(message.pyGenericServices); + } + if (message.phpGenericServices === true) { + writer.uint32(336).bool(message.phpGenericServices); + } + if (message.deprecated === true) { + writer.uint32(184).bool(message.deprecated); + } + if (message.ccEnableArenas === true) { + writer.uint32(248).bool(message.ccEnableArenas); + } + if (message.objcClassPrefix !== "") { + writer.uint32(290).string(message.objcClassPrefix); + } + if (message.csharpNamespace !== "") { + writer.uint32(298).string(message.csharpNamespace); + } + if (message.swiftPrefix !== "") { + writer.uint32(314).string(message.swiftPrefix); + } + if (message.phpClassPrefix !== "") { + writer.uint32(322).string(message.phpClassPrefix); + } + if (message.phpNamespace !== "") { + writer.uint32(330).string(message.phpNamespace); + } + if (message.phpMetadataNamespace !== "") { + writer.uint32(354).string(message.phpMetadataNamespace); + } + if (message.rubyPackage !== "") { + writer.uint32(362).string(message.rubyPackage); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FileOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFileOptions } as FileOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.javaPackage = reader.string(); + break; + case 8: + message.javaOuterClassname = reader.string(); + break; + case 10: + message.javaMultipleFiles = reader.bool(); + break; + case 20: + message.javaGenerateEqualsAndHash = reader.bool(); + break; + case 27: + message.javaStringCheckUtf8 = reader.bool(); + break; + case 9: + message.optimizeFor = reader.int32() as any; + break; + case 11: + message.goPackage = reader.string(); + break; + case 16: + message.ccGenericServices = reader.bool(); + break; + case 17: + message.javaGenericServices = reader.bool(); + break; + case 18: + message.pyGenericServices = reader.bool(); + break; + case 42: + message.phpGenericServices = reader.bool(); + break; + case 23: + message.deprecated = reader.bool(); + break; + case 31: + message.ccEnableArenas = reader.bool(); + break; + case 36: + message.objcClassPrefix = reader.string(); + break; + case 37: + message.csharpNamespace = reader.string(); + break; + case 39: + message.swiftPrefix = reader.string(); + break; + case 40: + message.phpClassPrefix = reader.string(); + break; + case 41: + message.phpNamespace = reader.string(); + break; + case 44: + message.phpMetadataNamespace = reader.string(); + break; + case 45: + message.rubyPackage = reader.string(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FileOptions { + const message = { ...baseFileOptions } as FileOptions; + message.uninterpretedOption = []; + if (object.javaPackage !== undefined && object.javaPackage !== null) { + message.javaPackage = String(object.javaPackage); + } else { + message.javaPackage = ""; + } + if ( + object.javaOuterClassname !== undefined && + object.javaOuterClassname !== null + ) { + message.javaOuterClassname = String(object.javaOuterClassname); + } else { + message.javaOuterClassname = ""; + } + if ( + object.javaMultipleFiles !== undefined && + object.javaMultipleFiles !== null + ) { + message.javaMultipleFiles = Boolean(object.javaMultipleFiles); + } else { + message.javaMultipleFiles = false; + } + if ( + object.javaGenerateEqualsAndHash !== undefined && + object.javaGenerateEqualsAndHash !== null + ) { + message.javaGenerateEqualsAndHash = Boolean( + object.javaGenerateEqualsAndHash + ); + } else { + message.javaGenerateEqualsAndHash = false; + } + if ( + object.javaStringCheckUtf8 !== undefined && + object.javaStringCheckUtf8 !== null + ) { + message.javaStringCheckUtf8 = Boolean(object.javaStringCheckUtf8); + } else { + message.javaStringCheckUtf8 = false; + } + if (object.optimizeFor !== undefined && object.optimizeFor !== null) { + message.optimizeFor = fileOptions_OptimizeModeFromJSON( + object.optimizeFor + ); + } else { + message.optimizeFor = 1; + } + if (object.goPackage !== undefined && object.goPackage !== null) { + message.goPackage = String(object.goPackage); + } else { + message.goPackage = ""; + } + if ( + object.ccGenericServices !== undefined && + object.ccGenericServices !== null + ) { + message.ccGenericServices = Boolean(object.ccGenericServices); + } else { + message.ccGenericServices = false; + } + if ( + object.javaGenericServices !== undefined && + object.javaGenericServices !== null + ) { + message.javaGenericServices = Boolean(object.javaGenericServices); + } else { + message.javaGenericServices = false; + } + if ( + object.pyGenericServices !== undefined && + object.pyGenericServices !== null + ) { + message.pyGenericServices = Boolean(object.pyGenericServices); + } else { + message.pyGenericServices = false; + } + if ( + object.phpGenericServices !== undefined && + object.phpGenericServices !== null + ) { + message.phpGenericServices = Boolean(object.phpGenericServices); + } else { + message.phpGenericServices = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if (object.ccEnableArenas !== undefined && object.ccEnableArenas !== null) { + message.ccEnableArenas = Boolean(object.ccEnableArenas); + } else { + message.ccEnableArenas = false; + } + if ( + object.objcClassPrefix !== undefined && + object.objcClassPrefix !== null + ) { + message.objcClassPrefix = String(object.objcClassPrefix); + } else { + message.objcClassPrefix = ""; + } + if ( + object.csharpNamespace !== undefined && + object.csharpNamespace !== null + ) { + message.csharpNamespace = String(object.csharpNamespace); + } else { + message.csharpNamespace = ""; + } + if (object.swiftPrefix !== undefined && object.swiftPrefix !== null) { + message.swiftPrefix = String(object.swiftPrefix); + } else { + message.swiftPrefix = ""; + } + if (object.phpClassPrefix !== undefined && object.phpClassPrefix !== null) { + message.phpClassPrefix = String(object.phpClassPrefix); + } else { + message.phpClassPrefix = ""; + } + if (object.phpNamespace !== undefined && object.phpNamespace !== null) { + message.phpNamespace = String(object.phpNamespace); + } else { + message.phpNamespace = ""; + } + if ( + object.phpMetadataNamespace !== undefined && + object.phpMetadataNamespace !== null + ) { + message.phpMetadataNamespace = String(object.phpMetadataNamespace); + } else { + message.phpMetadataNamespace = ""; + } + if (object.rubyPackage !== undefined && object.rubyPackage !== null) { + message.rubyPackage = String(object.rubyPackage); + } else { + message.rubyPackage = ""; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: FileOptions): unknown { + const obj: any = {}; + message.javaPackage !== undefined && + (obj.javaPackage = message.javaPackage); + message.javaOuterClassname !== undefined && + (obj.javaOuterClassname = message.javaOuterClassname); + message.javaMultipleFiles !== undefined && + (obj.javaMultipleFiles = message.javaMultipleFiles); + message.javaGenerateEqualsAndHash !== undefined && + (obj.javaGenerateEqualsAndHash = message.javaGenerateEqualsAndHash); + message.javaStringCheckUtf8 !== undefined && + (obj.javaStringCheckUtf8 = message.javaStringCheckUtf8); + message.optimizeFor !== undefined && + (obj.optimizeFor = fileOptions_OptimizeModeToJSON(message.optimizeFor)); + message.goPackage !== undefined && (obj.goPackage = message.goPackage); + message.ccGenericServices !== undefined && + (obj.ccGenericServices = message.ccGenericServices); + message.javaGenericServices !== undefined && + (obj.javaGenericServices = message.javaGenericServices); + message.pyGenericServices !== undefined && + (obj.pyGenericServices = message.pyGenericServices); + message.phpGenericServices !== undefined && + (obj.phpGenericServices = message.phpGenericServices); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.ccEnableArenas !== undefined && + (obj.ccEnableArenas = message.ccEnableArenas); + message.objcClassPrefix !== undefined && + (obj.objcClassPrefix = message.objcClassPrefix); + message.csharpNamespace !== undefined && + (obj.csharpNamespace = message.csharpNamespace); + message.swiftPrefix !== undefined && + (obj.swiftPrefix = message.swiftPrefix); + message.phpClassPrefix !== undefined && + (obj.phpClassPrefix = message.phpClassPrefix); + message.phpNamespace !== undefined && + (obj.phpNamespace = message.phpNamespace); + message.phpMetadataNamespace !== undefined && + (obj.phpMetadataNamespace = message.phpMetadataNamespace); + message.rubyPackage !== undefined && + (obj.rubyPackage = message.rubyPackage); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): FileOptions { + const message = { ...baseFileOptions } as FileOptions; + message.uninterpretedOption = []; + if (object.javaPackage !== undefined && object.javaPackage !== null) { + message.javaPackage = object.javaPackage; + } else { + message.javaPackage = ""; + } + if ( + object.javaOuterClassname !== undefined && + object.javaOuterClassname !== null + ) { + message.javaOuterClassname = object.javaOuterClassname; + } else { + message.javaOuterClassname = ""; + } + if ( + object.javaMultipleFiles !== undefined && + object.javaMultipleFiles !== null + ) { + message.javaMultipleFiles = object.javaMultipleFiles; + } else { + message.javaMultipleFiles = false; + } + if ( + object.javaGenerateEqualsAndHash !== undefined && + object.javaGenerateEqualsAndHash !== null + ) { + message.javaGenerateEqualsAndHash = object.javaGenerateEqualsAndHash; + } else { + message.javaGenerateEqualsAndHash = false; + } + if ( + object.javaStringCheckUtf8 !== undefined && + object.javaStringCheckUtf8 !== null + ) { + message.javaStringCheckUtf8 = object.javaStringCheckUtf8; + } else { + message.javaStringCheckUtf8 = false; + } + if (object.optimizeFor !== undefined && object.optimizeFor !== null) { + message.optimizeFor = object.optimizeFor; + } else { + message.optimizeFor = 1; + } + if (object.goPackage !== undefined && object.goPackage !== null) { + message.goPackage = object.goPackage; + } else { + message.goPackage = ""; + } + if ( + object.ccGenericServices !== undefined && + object.ccGenericServices !== null + ) { + message.ccGenericServices = object.ccGenericServices; + } else { + message.ccGenericServices = false; + } + if ( + object.javaGenericServices !== undefined && + object.javaGenericServices !== null + ) { + message.javaGenericServices = object.javaGenericServices; + } else { + message.javaGenericServices = false; + } + if ( + object.pyGenericServices !== undefined && + object.pyGenericServices !== null + ) { + message.pyGenericServices = object.pyGenericServices; + } else { + message.pyGenericServices = false; + } + if ( + object.phpGenericServices !== undefined && + object.phpGenericServices !== null + ) { + message.phpGenericServices = object.phpGenericServices; + } else { + message.phpGenericServices = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if (object.ccEnableArenas !== undefined && object.ccEnableArenas !== null) { + message.ccEnableArenas = object.ccEnableArenas; + } else { + message.ccEnableArenas = false; + } + if ( + object.objcClassPrefix !== undefined && + object.objcClassPrefix !== null + ) { + message.objcClassPrefix = object.objcClassPrefix; + } else { + message.objcClassPrefix = ""; + } + if ( + object.csharpNamespace !== undefined && + object.csharpNamespace !== null + ) { + message.csharpNamespace = object.csharpNamespace; + } else { + message.csharpNamespace = ""; + } + if (object.swiftPrefix !== undefined && object.swiftPrefix !== null) { + message.swiftPrefix = object.swiftPrefix; + } else { + message.swiftPrefix = ""; + } + if (object.phpClassPrefix !== undefined && object.phpClassPrefix !== null) { + message.phpClassPrefix = object.phpClassPrefix; + } else { + message.phpClassPrefix = ""; + } + if (object.phpNamespace !== undefined && object.phpNamespace !== null) { + message.phpNamespace = object.phpNamespace; + } else { + message.phpNamespace = ""; + } + if ( + object.phpMetadataNamespace !== undefined && + object.phpMetadataNamespace !== null + ) { + message.phpMetadataNamespace = object.phpMetadataNamespace; + } else { + message.phpMetadataNamespace = ""; + } + if (object.rubyPackage !== undefined && object.rubyPackage !== null) { + message.rubyPackage = object.rubyPackage; + } else { + message.rubyPackage = ""; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseMessageOptions: object = { + messageSetWireFormat: false, + noStandardDescriptorAccessor: false, + deprecated: false, + mapEntry: false, +}; + +export const MessageOptions = { + encode(message: MessageOptions, writer: Writer = Writer.create()): Writer { + if (message.messageSetWireFormat === true) { + writer.uint32(8).bool(message.messageSetWireFormat); + } + if (message.noStandardDescriptorAccessor === true) { + writer.uint32(16).bool(message.noStandardDescriptorAccessor); + } + if (message.deprecated === true) { + writer.uint32(24).bool(message.deprecated); + } + if (message.mapEntry === true) { + writer.uint32(56).bool(message.mapEntry); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MessageOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMessageOptions } as MessageOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.messageSetWireFormat = reader.bool(); + break; + case 2: + message.noStandardDescriptorAccessor = reader.bool(); + break; + case 3: + message.deprecated = reader.bool(); + break; + case 7: + message.mapEntry = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MessageOptions { + const message = { ...baseMessageOptions } as MessageOptions; + message.uninterpretedOption = []; + if ( + object.messageSetWireFormat !== undefined && + object.messageSetWireFormat !== null + ) { + message.messageSetWireFormat = Boolean(object.messageSetWireFormat); + } else { + message.messageSetWireFormat = false; + } + if ( + object.noStandardDescriptorAccessor !== undefined && + object.noStandardDescriptorAccessor !== null + ) { + message.noStandardDescriptorAccessor = Boolean( + object.noStandardDescriptorAccessor + ); + } else { + message.noStandardDescriptorAccessor = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if (object.mapEntry !== undefined && object.mapEntry !== null) { + message.mapEntry = Boolean(object.mapEntry); + } else { + message.mapEntry = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: MessageOptions): unknown { + const obj: any = {}; + message.messageSetWireFormat !== undefined && + (obj.messageSetWireFormat = message.messageSetWireFormat); + message.noStandardDescriptorAccessor !== undefined && + (obj.noStandardDescriptorAccessor = message.noStandardDescriptorAccessor); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.mapEntry !== undefined && (obj.mapEntry = message.mapEntry); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): MessageOptions { + const message = { ...baseMessageOptions } as MessageOptions; + message.uninterpretedOption = []; + if ( + object.messageSetWireFormat !== undefined && + object.messageSetWireFormat !== null + ) { + message.messageSetWireFormat = object.messageSetWireFormat; + } else { + message.messageSetWireFormat = false; + } + if ( + object.noStandardDescriptorAccessor !== undefined && + object.noStandardDescriptorAccessor !== null + ) { + message.noStandardDescriptorAccessor = + object.noStandardDescriptorAccessor; + } else { + message.noStandardDescriptorAccessor = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if (object.mapEntry !== undefined && object.mapEntry !== null) { + message.mapEntry = object.mapEntry; + } else { + message.mapEntry = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseFieldOptions: object = { + ctype: 0, + packed: false, + jstype: 0, + lazy: false, + deprecated: false, + weak: false, +}; + +export const FieldOptions = { + encode(message: FieldOptions, writer: Writer = Writer.create()): Writer { + if (message.ctype !== 0) { + writer.uint32(8).int32(message.ctype); + } + if (message.packed === true) { + writer.uint32(16).bool(message.packed); + } + if (message.jstype !== 0) { + writer.uint32(48).int32(message.jstype); + } + if (message.lazy === true) { + writer.uint32(40).bool(message.lazy); + } + if (message.deprecated === true) { + writer.uint32(24).bool(message.deprecated); + } + if (message.weak === true) { + writer.uint32(80).bool(message.weak); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FieldOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFieldOptions } as FieldOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.ctype = reader.int32() as any; + break; + case 2: + message.packed = reader.bool(); + break; + case 6: + message.jstype = reader.int32() as any; + break; + case 5: + message.lazy = reader.bool(); + break; + case 3: + message.deprecated = reader.bool(); + break; + case 10: + message.weak = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FieldOptions { + const message = { ...baseFieldOptions } as FieldOptions; + message.uninterpretedOption = []; + if (object.ctype !== undefined && object.ctype !== null) { + message.ctype = fieldOptions_CTypeFromJSON(object.ctype); + } else { + message.ctype = 0; + } + if (object.packed !== undefined && object.packed !== null) { + message.packed = Boolean(object.packed); + } else { + message.packed = false; + } + if (object.jstype !== undefined && object.jstype !== null) { + message.jstype = fieldOptions_JSTypeFromJSON(object.jstype); + } else { + message.jstype = 0; + } + if (object.lazy !== undefined && object.lazy !== null) { + message.lazy = Boolean(object.lazy); + } else { + message.lazy = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if (object.weak !== undefined && object.weak !== null) { + message.weak = Boolean(object.weak); + } else { + message.weak = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: FieldOptions): unknown { + const obj: any = {}; + message.ctype !== undefined && + (obj.ctype = fieldOptions_CTypeToJSON(message.ctype)); + message.packed !== undefined && (obj.packed = message.packed); + message.jstype !== undefined && + (obj.jstype = fieldOptions_JSTypeToJSON(message.jstype)); + message.lazy !== undefined && (obj.lazy = message.lazy); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.weak !== undefined && (obj.weak = message.weak); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): FieldOptions { + const message = { ...baseFieldOptions } as FieldOptions; + message.uninterpretedOption = []; + if (object.ctype !== undefined && object.ctype !== null) { + message.ctype = object.ctype; + } else { + message.ctype = 0; + } + if (object.packed !== undefined && object.packed !== null) { + message.packed = object.packed; + } else { + message.packed = false; + } + if (object.jstype !== undefined && object.jstype !== null) { + message.jstype = object.jstype; + } else { + message.jstype = 0; + } + if (object.lazy !== undefined && object.lazy !== null) { + message.lazy = object.lazy; + } else { + message.lazy = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if (object.weak !== undefined && object.weak !== null) { + message.weak = object.weak; + } else { + message.weak = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseOneofOptions: object = {}; + +export const OneofOptions = { + encode(message: OneofOptions, writer: Writer = Writer.create()): Writer { + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): OneofOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseOneofOptions } as OneofOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): OneofOptions { + const message = { ...baseOneofOptions } as OneofOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: OneofOptions): unknown { + const obj: any = {}; + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): OneofOptions { + const message = { ...baseOneofOptions } as OneofOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseEnumOptions: object = { allowAlias: false, deprecated: false }; + +export const EnumOptions = { + encode(message: EnumOptions, writer: Writer = Writer.create()): Writer { + if (message.allowAlias === true) { + writer.uint32(16).bool(message.allowAlias); + } + if (message.deprecated === true) { + writer.uint32(24).bool(message.deprecated); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): EnumOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseEnumOptions } as EnumOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + message.allowAlias = reader.bool(); + break; + case 3: + message.deprecated = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumOptions { + const message = { ...baseEnumOptions } as EnumOptions; + message.uninterpretedOption = []; + if (object.allowAlias !== undefined && object.allowAlias !== null) { + message.allowAlias = Boolean(object.allowAlias); + } else { + message.allowAlias = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: EnumOptions): unknown { + const obj: any = {}; + message.allowAlias !== undefined && (obj.allowAlias = message.allowAlias); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): EnumOptions { + const message = { ...baseEnumOptions } as EnumOptions; + message.uninterpretedOption = []; + if (object.allowAlias !== undefined && object.allowAlias !== null) { + message.allowAlias = object.allowAlias; + } else { + message.allowAlias = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseEnumValueOptions: object = { deprecated: false }; + +export const EnumValueOptions = { + encode(message: EnumValueOptions, writer: Writer = Writer.create()): Writer { + if (message.deprecated === true) { + writer.uint32(8).bool(message.deprecated); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): EnumValueOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseEnumValueOptions } as EnumValueOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.deprecated = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumValueOptions { + const message = { ...baseEnumValueOptions } as EnumValueOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: EnumValueOptions): unknown { + const obj: any = {}; + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): EnumValueOptions { + const message = { ...baseEnumValueOptions } as EnumValueOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseServiceOptions: object = { deprecated: false }; + +export const ServiceOptions = { + encode(message: ServiceOptions, writer: Writer = Writer.create()): Writer { + if (message.deprecated === true) { + writer.uint32(264).bool(message.deprecated); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ServiceOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseServiceOptions } as ServiceOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 33: + message.deprecated = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ServiceOptions { + const message = { ...baseServiceOptions } as ServiceOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: ServiceOptions): unknown { + const obj: any = {}; + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): ServiceOptions { + const message = { ...baseServiceOptions } as ServiceOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseMethodOptions: object = { deprecated: false, idempotencyLevel: 0 }; + +export const MethodOptions = { + encode(message: MethodOptions, writer: Writer = Writer.create()): Writer { + if (message.deprecated === true) { + writer.uint32(264).bool(message.deprecated); + } + if (message.idempotencyLevel !== 0) { + writer.uint32(272).int32(message.idempotencyLevel); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MethodOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMethodOptions } as MethodOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 33: + message.deprecated = reader.bool(); + break; + case 34: + message.idempotencyLevel = reader.int32() as any; + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MethodOptions { + const message = { ...baseMethodOptions } as MethodOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.idempotencyLevel !== undefined && + object.idempotencyLevel !== null + ) { + message.idempotencyLevel = methodOptions_IdempotencyLevelFromJSON( + object.idempotencyLevel + ); + } else { + message.idempotencyLevel = 0; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: MethodOptions): unknown { + const obj: any = {}; + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.idempotencyLevel !== undefined && + (obj.idempotencyLevel = methodOptions_IdempotencyLevelToJSON( + message.idempotencyLevel + )); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): MethodOptions { + const message = { ...baseMethodOptions } as MethodOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.idempotencyLevel !== undefined && + object.idempotencyLevel !== null + ) { + message.idempotencyLevel = object.idempotencyLevel; + } else { + message.idempotencyLevel = 0; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseUninterpretedOption: object = { + identifierValue: "", + positiveIntValue: 0, + negativeIntValue: 0, + doubleValue: 0, + aggregateValue: "", +}; + +export const UninterpretedOption = { + encode( + message: UninterpretedOption, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.name) { + UninterpretedOption_NamePart.encode( + v!, + writer.uint32(18).fork() + ).ldelim(); + } + if (message.identifierValue !== "") { + writer.uint32(26).string(message.identifierValue); + } + if (message.positiveIntValue !== 0) { + writer.uint32(32).uint64(message.positiveIntValue); + } + if (message.negativeIntValue !== 0) { + writer.uint32(40).int64(message.negativeIntValue); + } + if (message.doubleValue !== 0) { + writer.uint32(49).double(message.doubleValue); + } + if (message.stringValue.length !== 0) { + writer.uint32(58).bytes(message.stringValue); + } + if (message.aggregateValue !== "") { + writer.uint32(66).string(message.aggregateValue); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): UninterpretedOption { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseUninterpretedOption } as UninterpretedOption; + message.name = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + message.name.push( + UninterpretedOption_NamePart.decode(reader, reader.uint32()) + ); + break; + case 3: + message.identifierValue = reader.string(); + break; + case 4: + message.positiveIntValue = longToNumber(reader.uint64() as Long); + break; + case 5: + message.negativeIntValue = longToNumber(reader.int64() as Long); + break; + case 6: + message.doubleValue = reader.double(); + break; + case 7: + message.stringValue = reader.bytes(); + break; + case 8: + message.aggregateValue = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): UninterpretedOption { + const message = { ...baseUninterpretedOption } as UninterpretedOption; + message.name = []; + if (object.name !== undefined && object.name !== null) { + for (const e of object.name) { + message.name.push(UninterpretedOption_NamePart.fromJSON(e)); + } + } + if ( + object.identifierValue !== undefined && + object.identifierValue !== null + ) { + message.identifierValue = String(object.identifierValue); + } else { + message.identifierValue = ""; + } + if ( + object.positiveIntValue !== undefined && + object.positiveIntValue !== null + ) { + message.positiveIntValue = Number(object.positiveIntValue); + } else { + message.positiveIntValue = 0; + } + if ( + object.negativeIntValue !== undefined && + object.negativeIntValue !== null + ) { + message.negativeIntValue = Number(object.negativeIntValue); + } else { + message.negativeIntValue = 0; + } + if (object.doubleValue !== undefined && object.doubleValue !== null) { + message.doubleValue = Number(object.doubleValue); + } else { + message.doubleValue = 0; + } + if (object.stringValue !== undefined && object.stringValue !== null) { + message.stringValue = bytesFromBase64(object.stringValue); + } + if (object.aggregateValue !== undefined && object.aggregateValue !== null) { + message.aggregateValue = String(object.aggregateValue); + } else { + message.aggregateValue = ""; + } + return message; + }, + + toJSON(message: UninterpretedOption): unknown { + const obj: any = {}; + if (message.name) { + obj.name = message.name.map((e) => + e ? UninterpretedOption_NamePart.toJSON(e) : undefined + ); + } else { + obj.name = []; + } + message.identifierValue !== undefined && + (obj.identifierValue = message.identifierValue); + message.positiveIntValue !== undefined && + (obj.positiveIntValue = message.positiveIntValue); + message.negativeIntValue !== undefined && + (obj.negativeIntValue = message.negativeIntValue); + message.doubleValue !== undefined && + (obj.doubleValue = message.doubleValue); + message.stringValue !== undefined && + (obj.stringValue = base64FromBytes( + message.stringValue !== undefined + ? message.stringValue + : new Uint8Array() + )); + message.aggregateValue !== undefined && + (obj.aggregateValue = message.aggregateValue); + return obj; + }, + + fromPartial(object: DeepPartial): UninterpretedOption { + const message = { ...baseUninterpretedOption } as UninterpretedOption; + message.name = []; + if (object.name !== undefined && object.name !== null) { + for (const e of object.name) { + message.name.push(UninterpretedOption_NamePart.fromPartial(e)); + } + } + if ( + object.identifierValue !== undefined && + object.identifierValue !== null + ) { + message.identifierValue = object.identifierValue; + } else { + message.identifierValue = ""; + } + if ( + object.positiveIntValue !== undefined && + object.positiveIntValue !== null + ) { + message.positiveIntValue = object.positiveIntValue; + } else { + message.positiveIntValue = 0; + } + if ( + object.negativeIntValue !== undefined && + object.negativeIntValue !== null + ) { + message.negativeIntValue = object.negativeIntValue; + } else { + message.negativeIntValue = 0; + } + if (object.doubleValue !== undefined && object.doubleValue !== null) { + message.doubleValue = object.doubleValue; + } else { + message.doubleValue = 0; + } + if (object.stringValue !== undefined && object.stringValue !== null) { + message.stringValue = object.stringValue; + } else { + message.stringValue = new Uint8Array(); + } + if (object.aggregateValue !== undefined && object.aggregateValue !== null) { + message.aggregateValue = object.aggregateValue; + } else { + message.aggregateValue = ""; + } + return message; + }, +}; + +const baseUninterpretedOption_NamePart: object = { + namePart: "", + isExtension: false, +}; + +export const UninterpretedOption_NamePart = { + encode( + message: UninterpretedOption_NamePart, + writer: Writer = Writer.create() + ): Writer { + if (message.namePart !== "") { + writer.uint32(10).string(message.namePart); + } + if (message.isExtension === true) { + writer.uint32(16).bool(message.isExtension); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): UninterpretedOption_NamePart { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseUninterpretedOption_NamePart, + } as UninterpretedOption_NamePart; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.namePart = reader.string(); + break; + case 2: + message.isExtension = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): UninterpretedOption_NamePart { + const message = { + ...baseUninterpretedOption_NamePart, + } as UninterpretedOption_NamePart; + if (object.namePart !== undefined && object.namePart !== null) { + message.namePart = String(object.namePart); + } else { + message.namePart = ""; + } + if (object.isExtension !== undefined && object.isExtension !== null) { + message.isExtension = Boolean(object.isExtension); + } else { + message.isExtension = false; + } + return message; + }, + + toJSON(message: UninterpretedOption_NamePart): unknown { + const obj: any = {}; + message.namePart !== undefined && (obj.namePart = message.namePart); + message.isExtension !== undefined && + (obj.isExtension = message.isExtension); + return obj; + }, + + fromPartial( + object: DeepPartial + ): UninterpretedOption_NamePart { + const message = { + ...baseUninterpretedOption_NamePart, + } as UninterpretedOption_NamePart; + if (object.namePart !== undefined && object.namePart !== null) { + message.namePart = object.namePart; + } else { + message.namePart = ""; + } + if (object.isExtension !== undefined && object.isExtension !== null) { + message.isExtension = object.isExtension; + } else { + message.isExtension = false; + } + return message; + }, +}; + +const baseSourceCodeInfo: object = {}; + +export const SourceCodeInfo = { + encode(message: SourceCodeInfo, writer: Writer = Writer.create()): Writer { + for (const v of message.location) { + SourceCodeInfo_Location.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): SourceCodeInfo { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseSourceCodeInfo } as SourceCodeInfo; + message.location = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.location.push( + SourceCodeInfo_Location.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): SourceCodeInfo { + const message = { ...baseSourceCodeInfo } as SourceCodeInfo; + message.location = []; + if (object.location !== undefined && object.location !== null) { + for (const e of object.location) { + message.location.push(SourceCodeInfo_Location.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: SourceCodeInfo): unknown { + const obj: any = {}; + if (message.location) { + obj.location = message.location.map((e) => + e ? SourceCodeInfo_Location.toJSON(e) : undefined + ); + } else { + obj.location = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): SourceCodeInfo { + const message = { ...baseSourceCodeInfo } as SourceCodeInfo; + message.location = []; + if (object.location !== undefined && object.location !== null) { + for (const e of object.location) { + message.location.push(SourceCodeInfo_Location.fromPartial(e)); + } + } + return message; + }, +}; + +const baseSourceCodeInfo_Location: object = { + path: 0, + span: 0, + leadingComments: "", + trailingComments: "", + leadingDetachedComments: "", +}; + +export const SourceCodeInfo_Location = { + encode( + message: SourceCodeInfo_Location, + writer: Writer = Writer.create() + ): Writer { + writer.uint32(10).fork(); + for (const v of message.path) { + writer.int32(v); + } + writer.ldelim(); + writer.uint32(18).fork(); + for (const v of message.span) { + writer.int32(v); + } + writer.ldelim(); + if (message.leadingComments !== "") { + writer.uint32(26).string(message.leadingComments); + } + if (message.trailingComments !== "") { + writer.uint32(34).string(message.trailingComments); + } + for (const v of message.leadingDetachedComments) { + writer.uint32(50).string(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): SourceCodeInfo_Location { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseSourceCodeInfo_Location, + } as SourceCodeInfo_Location; + message.path = []; + message.span = []; + message.leadingDetachedComments = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.path.push(reader.int32()); + } + } else { + message.path.push(reader.int32()); + } + break; + case 2: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.span.push(reader.int32()); + } + } else { + message.span.push(reader.int32()); + } + break; + case 3: + message.leadingComments = reader.string(); + break; + case 4: + message.trailingComments = reader.string(); + break; + case 6: + message.leadingDetachedComments.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): SourceCodeInfo_Location { + const message = { + ...baseSourceCodeInfo_Location, + } as SourceCodeInfo_Location; + message.path = []; + message.span = []; + message.leadingDetachedComments = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(Number(e)); + } + } + if (object.span !== undefined && object.span !== null) { + for (const e of object.span) { + message.span.push(Number(e)); + } + } + if ( + object.leadingComments !== undefined && + object.leadingComments !== null + ) { + message.leadingComments = String(object.leadingComments); + } else { + message.leadingComments = ""; + } + if ( + object.trailingComments !== undefined && + object.trailingComments !== null + ) { + message.trailingComments = String(object.trailingComments); + } else { + message.trailingComments = ""; + } + if ( + object.leadingDetachedComments !== undefined && + object.leadingDetachedComments !== null + ) { + for (const e of object.leadingDetachedComments) { + message.leadingDetachedComments.push(String(e)); + } + } + return message; + }, + + toJSON(message: SourceCodeInfo_Location): unknown { + const obj: any = {}; + if (message.path) { + obj.path = message.path.map((e) => e); + } else { + obj.path = []; + } + if (message.span) { + obj.span = message.span.map((e) => e); + } else { + obj.span = []; + } + message.leadingComments !== undefined && + (obj.leadingComments = message.leadingComments); + message.trailingComments !== undefined && + (obj.trailingComments = message.trailingComments); + if (message.leadingDetachedComments) { + obj.leadingDetachedComments = message.leadingDetachedComments.map( + (e) => e + ); + } else { + obj.leadingDetachedComments = []; + } + return obj; + }, + + fromPartial( + object: DeepPartial + ): SourceCodeInfo_Location { + const message = { + ...baseSourceCodeInfo_Location, + } as SourceCodeInfo_Location; + message.path = []; + message.span = []; + message.leadingDetachedComments = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(e); + } + } + if (object.span !== undefined && object.span !== null) { + for (const e of object.span) { + message.span.push(e); + } + } + if ( + object.leadingComments !== undefined && + object.leadingComments !== null + ) { + message.leadingComments = object.leadingComments; + } else { + message.leadingComments = ""; + } + if ( + object.trailingComments !== undefined && + object.trailingComments !== null + ) { + message.trailingComments = object.trailingComments; + } else { + message.trailingComments = ""; + } + if ( + object.leadingDetachedComments !== undefined && + object.leadingDetachedComments !== null + ) { + for (const e of object.leadingDetachedComments) { + message.leadingDetachedComments.push(e); + } + } + return message; + }, +}; + +const baseGeneratedCodeInfo: object = {}; + +export const GeneratedCodeInfo = { + encode(message: GeneratedCodeInfo, writer: Writer = Writer.create()): Writer { + for (const v of message.annotation) { + GeneratedCodeInfo_Annotation.encode( + v!, + writer.uint32(10).fork() + ).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): GeneratedCodeInfo { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseGeneratedCodeInfo } as GeneratedCodeInfo; + message.annotation = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.annotation.push( + GeneratedCodeInfo_Annotation.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GeneratedCodeInfo { + const message = { ...baseGeneratedCodeInfo } as GeneratedCodeInfo; + message.annotation = []; + if (object.annotation !== undefined && object.annotation !== null) { + for (const e of object.annotation) { + message.annotation.push(GeneratedCodeInfo_Annotation.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: GeneratedCodeInfo): unknown { + const obj: any = {}; + if (message.annotation) { + obj.annotation = message.annotation.map((e) => + e ? GeneratedCodeInfo_Annotation.toJSON(e) : undefined + ); + } else { + obj.annotation = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): GeneratedCodeInfo { + const message = { ...baseGeneratedCodeInfo } as GeneratedCodeInfo; + message.annotation = []; + if (object.annotation !== undefined && object.annotation !== null) { + for (const e of object.annotation) { + message.annotation.push(GeneratedCodeInfo_Annotation.fromPartial(e)); + } + } + return message; + }, +}; + +const baseGeneratedCodeInfo_Annotation: object = { + path: 0, + sourceFile: "", + begin: 0, + end: 0, +}; + +export const GeneratedCodeInfo_Annotation = { + encode( + message: GeneratedCodeInfo_Annotation, + writer: Writer = Writer.create() + ): Writer { + writer.uint32(10).fork(); + for (const v of message.path) { + writer.int32(v); + } + writer.ldelim(); + if (message.sourceFile !== "") { + writer.uint32(18).string(message.sourceFile); + } + if (message.begin !== 0) { + writer.uint32(24).int32(message.begin); + } + if (message.end !== 0) { + writer.uint32(32).int32(message.end); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): GeneratedCodeInfo_Annotation { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseGeneratedCodeInfo_Annotation, + } as GeneratedCodeInfo_Annotation; + message.path = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.path.push(reader.int32()); + } + } else { + message.path.push(reader.int32()); + } + break; + case 2: + message.sourceFile = reader.string(); + break; + case 3: + message.begin = reader.int32(); + break; + case 4: + message.end = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GeneratedCodeInfo_Annotation { + const message = { + ...baseGeneratedCodeInfo_Annotation, + } as GeneratedCodeInfo_Annotation; + message.path = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(Number(e)); + } + } + if (object.sourceFile !== undefined && object.sourceFile !== null) { + message.sourceFile = String(object.sourceFile); + } else { + message.sourceFile = ""; + } + if (object.begin !== undefined && object.begin !== null) { + message.begin = Number(object.begin); + } else { + message.begin = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + return message; + }, + + toJSON(message: GeneratedCodeInfo_Annotation): unknown { + const obj: any = {}; + if (message.path) { + obj.path = message.path.map((e) => e); + } else { + obj.path = []; + } + message.sourceFile !== undefined && (obj.sourceFile = message.sourceFile); + message.begin !== undefined && (obj.begin = message.begin); + message.end !== undefined && (obj.end = message.end); + return obj; + }, + + fromPartial( + object: DeepPartial + ): GeneratedCodeInfo_Annotation { + const message = { + ...baseGeneratedCodeInfo_Annotation, + } as GeneratedCodeInfo_Annotation; + message.path = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(e); + } + } + if (object.sourceFile !== undefined && object.sourceFile !== null) { + message.sourceFile = object.sourceFile; + } else { + message.sourceFile = ""; + } + if (object.begin !== undefined && object.begin !== null) { + message.begin = object.begin; + } else { + message.begin = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/bze.scavenge/types/scavenge/commit.ts b/ts-client/bze.scavenge/types/scavenge/commit.ts new file mode 100644 index 00000000..8f9e8977 --- /dev/null +++ b/ts-client/bze.scavenge/types/scavenge/commit.ts @@ -0,0 +1,122 @@ +/* eslint-disable */ +import { Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "bze.scavenge"; + +export interface Commit { + index: string; + solutionHash: string; + solutionScavengerHash: string; +} + +const baseCommit: object = { + index: "", + solutionHash: "", + solutionScavengerHash: "", +}; + +export const Commit = { + encode(message: Commit, writer: Writer = Writer.create()): Writer { + if (message.index !== "") { + writer.uint32(10).string(message.index); + } + if (message.solutionHash !== "") { + writer.uint32(18).string(message.solutionHash); + } + if (message.solutionScavengerHash !== "") { + writer.uint32(26).string(message.solutionScavengerHash); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Commit { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseCommit } as Commit; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.index = reader.string(); + break; + case 2: + message.solutionHash = reader.string(); + break; + case 3: + message.solutionScavengerHash = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Commit { + const message = { ...baseCommit } as Commit; + if (object.index !== undefined && object.index !== null) { + message.index = String(object.index); + } else { + message.index = ""; + } + if (object.solutionHash !== undefined && object.solutionHash !== null) { + message.solutionHash = String(object.solutionHash); + } else { + message.solutionHash = ""; + } + if ( + object.solutionScavengerHash !== undefined && + object.solutionScavengerHash !== null + ) { + message.solutionScavengerHash = String(object.solutionScavengerHash); + } else { + message.solutionScavengerHash = ""; + } + return message; + }, + + toJSON(message: Commit): unknown { + const obj: any = {}; + message.index !== undefined && (obj.index = message.index); + message.solutionHash !== undefined && + (obj.solutionHash = message.solutionHash); + message.solutionScavengerHash !== undefined && + (obj.solutionScavengerHash = message.solutionScavengerHash); + return obj; + }, + + fromPartial(object: DeepPartial): Commit { + const message = { ...baseCommit } as Commit; + if (object.index !== undefined && object.index !== null) { + message.index = object.index; + } else { + message.index = ""; + } + if (object.solutionHash !== undefined && object.solutionHash !== null) { + message.solutionHash = object.solutionHash; + } else { + message.solutionHash = ""; + } + if ( + object.solutionScavengerHash !== undefined && + object.solutionScavengerHash !== null + ) { + message.solutionScavengerHash = object.solutionScavengerHash; + } else { + message.solutionScavengerHash = ""; + } + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/bze.scavenge/types/scavenge/genesis.ts b/ts-client/bze.scavenge/types/scavenge/genesis.ts new file mode 100644 index 00000000..a67b1d32 --- /dev/null +++ b/ts-client/bze.scavenge/types/scavenge/genesis.ts @@ -0,0 +1,114 @@ +/* eslint-disable */ +import { Scavenge } from "../scavenge/scavenge"; +import { Commit } from "../scavenge/commit"; +import { Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "bze.scavenge"; + +/** GenesisState defines the scavenge module's genesis state. */ +export interface GenesisState { + scavengeList: Scavenge[]; + /** this line is used by starport scaffolding # genesis/proto/state */ + commitList: Commit[]; +} + +const baseGenesisState: object = {}; + +export const GenesisState = { + encode(message: GenesisState, writer: Writer = Writer.create()): Writer { + for (const v of message.scavengeList) { + Scavenge.encode(v!, writer.uint32(10).fork()).ldelim(); + } + for (const v of message.commitList) { + Commit.encode(v!, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): GenesisState { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseGenesisState } as GenesisState; + message.scavengeList = []; + message.commitList = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.scavengeList.push(Scavenge.decode(reader, reader.uint32())); + break; + case 2: + message.commitList.push(Commit.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GenesisState { + const message = { ...baseGenesisState } as GenesisState; + message.scavengeList = []; + message.commitList = []; + if (object.scavengeList !== undefined && object.scavengeList !== null) { + for (const e of object.scavengeList) { + message.scavengeList.push(Scavenge.fromJSON(e)); + } + } + if (object.commitList !== undefined && object.commitList !== null) { + for (const e of object.commitList) { + message.commitList.push(Commit.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: GenesisState): unknown { + const obj: any = {}; + if (message.scavengeList) { + obj.scavengeList = message.scavengeList.map((e) => + e ? Scavenge.toJSON(e) : undefined + ); + } else { + obj.scavengeList = []; + } + if (message.commitList) { + obj.commitList = message.commitList.map((e) => + e ? Commit.toJSON(e) : undefined + ); + } else { + obj.commitList = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): GenesisState { + const message = { ...baseGenesisState } as GenesisState; + message.scavengeList = []; + message.commitList = []; + if (object.scavengeList !== undefined && object.scavengeList !== null) { + for (const e of object.scavengeList) { + message.scavengeList.push(Scavenge.fromPartial(e)); + } + } + if (object.commitList !== undefined && object.commitList !== null) { + for (const e of object.commitList) { + message.commitList.push(Commit.fromPartial(e)); + } + } + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/bze.scavenge/types/scavenge/query.ts b/ts-client/bze.scavenge/types/scavenge/query.ts new file mode 100644 index 00000000..d6b21050 --- /dev/null +++ b/ts-client/bze.scavenge/types/scavenge/query.ts @@ -0,0 +1,703 @@ +/* eslint-disable */ +import { Reader, Writer } from "protobufjs/minimal"; +import { Scavenge } from "../scavenge/scavenge"; +import { + PageRequest, + PageResponse, +} from "../cosmos/base/query/v1beta1/pagination"; +import { Commit } from "../scavenge/commit"; + +export const protobufPackage = "bze.scavenge"; + +export interface QueryGetScavengeRequest { + index: string; +} + +export interface QueryGetScavengeResponse { + scavenge: Scavenge | undefined; +} + +export interface QueryAllScavengeRequest { + pagination: PageRequest | undefined; +} + +export interface QueryAllScavengeResponse { + scavenge: Scavenge[]; + pagination: PageResponse | undefined; +} + +export interface QueryGetCommitRequest { + index: string; +} + +export interface QueryGetCommitResponse { + commit: Commit | undefined; +} + +export interface QueryAllCommitRequest { + pagination: PageRequest | undefined; +} + +export interface QueryAllCommitResponse { + commit: Commit[]; + pagination: PageResponse | undefined; +} + +const baseQueryGetScavengeRequest: object = { index: "" }; + +export const QueryGetScavengeRequest = { + encode( + message: QueryGetScavengeRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.index !== "") { + writer.uint32(10).string(message.index); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QueryGetScavengeRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryGetScavengeRequest, + } as QueryGetScavengeRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.index = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryGetScavengeRequest { + const message = { + ...baseQueryGetScavengeRequest, + } as QueryGetScavengeRequest; + if (object.index !== undefined && object.index !== null) { + message.index = String(object.index); + } else { + message.index = ""; + } + return message; + }, + + toJSON(message: QueryGetScavengeRequest): unknown { + const obj: any = {}; + message.index !== undefined && (obj.index = message.index); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryGetScavengeRequest { + const message = { + ...baseQueryGetScavengeRequest, + } as QueryGetScavengeRequest; + if (object.index !== undefined && object.index !== null) { + message.index = object.index; + } else { + message.index = ""; + } + return message; + }, +}; + +const baseQueryGetScavengeResponse: object = {}; + +export const QueryGetScavengeResponse = { + encode( + message: QueryGetScavengeResponse, + writer: Writer = Writer.create() + ): Writer { + if (message.scavenge !== undefined) { + Scavenge.encode(message.scavenge, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryGetScavengeResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryGetScavengeResponse, + } as QueryGetScavengeResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.scavenge = Scavenge.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryGetScavengeResponse { + const message = { + ...baseQueryGetScavengeResponse, + } as QueryGetScavengeResponse; + if (object.scavenge !== undefined && object.scavenge !== null) { + message.scavenge = Scavenge.fromJSON(object.scavenge); + } else { + message.scavenge = undefined; + } + return message; + }, + + toJSON(message: QueryGetScavengeResponse): unknown { + const obj: any = {}; + message.scavenge !== undefined && + (obj.scavenge = message.scavenge + ? Scavenge.toJSON(message.scavenge) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryGetScavengeResponse { + const message = { + ...baseQueryGetScavengeResponse, + } as QueryGetScavengeResponse; + if (object.scavenge !== undefined && object.scavenge !== null) { + message.scavenge = Scavenge.fromPartial(object.scavenge); + } else { + message.scavenge = undefined; + } + return message; + }, +}; + +const baseQueryAllScavengeRequest: object = {}; + +export const QueryAllScavengeRequest = { + encode( + message: QueryAllScavengeRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QueryAllScavengeRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryAllScavengeRequest, + } as QueryAllScavengeRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryAllScavengeRequest { + const message = { + ...baseQueryAllScavengeRequest, + } as QueryAllScavengeRequest; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryAllScavengeRequest): unknown { + const obj: any = {}; + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageRequest.toJSON(message.pagination) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryAllScavengeRequest { + const message = { + ...baseQueryAllScavengeRequest, + } as QueryAllScavengeRequest; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseQueryAllScavengeResponse: object = {}; + +export const QueryAllScavengeResponse = { + encode( + message: QueryAllScavengeResponse, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.scavenge) { + Scavenge.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode( + message.pagination, + writer.uint32(18).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryAllScavengeResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryAllScavengeResponse, + } as QueryAllScavengeResponse; + message.scavenge = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.scavenge.push(Scavenge.decode(reader, reader.uint32())); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryAllScavengeResponse { + const message = { + ...baseQueryAllScavengeResponse, + } as QueryAllScavengeResponse; + message.scavenge = []; + if (object.scavenge !== undefined && object.scavenge !== null) { + for (const e of object.scavenge) { + message.scavenge.push(Scavenge.fromJSON(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryAllScavengeResponse): unknown { + const obj: any = {}; + if (message.scavenge) { + obj.scavenge = message.scavenge.map((e) => + e ? Scavenge.toJSON(e) : undefined + ); + } else { + obj.scavenge = []; + } + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageResponse.toJSON(message.pagination) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryAllScavengeResponse { + const message = { + ...baseQueryAllScavengeResponse, + } as QueryAllScavengeResponse; + message.scavenge = []; + if (object.scavenge !== undefined && object.scavenge !== null) { + for (const e of object.scavenge) { + message.scavenge.push(Scavenge.fromPartial(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseQueryGetCommitRequest: object = { index: "" }; + +export const QueryGetCommitRequest = { + encode( + message: QueryGetCommitRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.index !== "") { + writer.uint32(10).string(message.index); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QueryGetCommitRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryGetCommitRequest } as QueryGetCommitRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.index = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryGetCommitRequest { + const message = { ...baseQueryGetCommitRequest } as QueryGetCommitRequest; + if (object.index !== undefined && object.index !== null) { + message.index = String(object.index); + } else { + message.index = ""; + } + return message; + }, + + toJSON(message: QueryGetCommitRequest): unknown { + const obj: any = {}; + message.index !== undefined && (obj.index = message.index); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryGetCommitRequest { + const message = { ...baseQueryGetCommitRequest } as QueryGetCommitRequest; + if (object.index !== undefined && object.index !== null) { + message.index = object.index; + } else { + message.index = ""; + } + return message; + }, +}; + +const baseQueryGetCommitResponse: object = {}; + +export const QueryGetCommitResponse = { + encode( + message: QueryGetCommitResponse, + writer: Writer = Writer.create() + ): Writer { + if (message.commit !== undefined) { + Commit.encode(message.commit, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QueryGetCommitResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryGetCommitResponse } as QueryGetCommitResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.commit = Commit.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryGetCommitResponse { + const message = { ...baseQueryGetCommitResponse } as QueryGetCommitResponse; + if (object.commit !== undefined && object.commit !== null) { + message.commit = Commit.fromJSON(object.commit); + } else { + message.commit = undefined; + } + return message; + }, + + toJSON(message: QueryGetCommitResponse): unknown { + const obj: any = {}; + message.commit !== undefined && + (obj.commit = message.commit ? Commit.toJSON(message.commit) : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryGetCommitResponse { + const message = { ...baseQueryGetCommitResponse } as QueryGetCommitResponse; + if (object.commit !== undefined && object.commit !== null) { + message.commit = Commit.fromPartial(object.commit); + } else { + message.commit = undefined; + } + return message; + }, +}; + +const baseQueryAllCommitRequest: object = {}; + +export const QueryAllCommitRequest = { + encode( + message: QueryAllCommitRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QueryAllCommitRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryAllCommitRequest } as QueryAllCommitRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryAllCommitRequest { + const message = { ...baseQueryAllCommitRequest } as QueryAllCommitRequest; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryAllCommitRequest): unknown { + const obj: any = {}; + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageRequest.toJSON(message.pagination) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryAllCommitRequest { + const message = { ...baseQueryAllCommitRequest } as QueryAllCommitRequest; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseQueryAllCommitResponse: object = {}; + +export const QueryAllCommitResponse = { + encode( + message: QueryAllCommitResponse, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.commit) { + Commit.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode( + message.pagination, + writer.uint32(18).fork() + ).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QueryAllCommitResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryAllCommitResponse } as QueryAllCommitResponse; + message.commit = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.commit.push(Commit.decode(reader, reader.uint32())); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryAllCommitResponse { + const message = { ...baseQueryAllCommitResponse } as QueryAllCommitResponse; + message.commit = []; + if (object.commit !== undefined && object.commit !== null) { + for (const e of object.commit) { + message.commit.push(Commit.fromJSON(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryAllCommitResponse): unknown { + const obj: any = {}; + if (message.commit) { + obj.commit = message.commit.map((e) => + e ? Commit.toJSON(e) : undefined + ); + } else { + obj.commit = []; + } + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageResponse.toJSON(message.pagination) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryAllCommitResponse { + const message = { ...baseQueryAllCommitResponse } as QueryAllCommitResponse; + message.commit = []; + if (object.commit !== undefined && object.commit !== null) { + for (const e of object.commit) { + message.commit.push(Commit.fromPartial(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +/** Query defines the gRPC querier service. */ +export interface Query { + /** Queries a scavenge by index. */ + Scavenge(request: QueryGetScavengeRequest): Promise; + /** Queries a list of scavenge items. */ + ScavengeAll( + request: QueryAllScavengeRequest + ): Promise; + /** Queries a commit by index. */ + Commit(request: QueryGetCommitRequest): Promise; + /** Queries a list of commit items. */ + CommitAll(request: QueryAllCommitRequest): Promise; +} + +export class QueryClientImpl implements Query { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + } + Scavenge( + request: QueryGetScavengeRequest + ): Promise { + const data = QueryGetScavengeRequest.encode(request).finish(); + const promise = this.rpc.request("bze.scavenge.Query", "Scavenge", data); + return promise.then((data) => + QueryGetScavengeResponse.decode(new Reader(data)) + ); + } + + ScavengeAll( + request: QueryAllScavengeRequest + ): Promise { + const data = QueryAllScavengeRequest.encode(request).finish(); + const promise = this.rpc.request("bze.scavenge.Query", "ScavengeAll", data); + return promise.then((data) => + QueryAllScavengeResponse.decode(new Reader(data)) + ); + } + + Commit(request: QueryGetCommitRequest): Promise { + const data = QueryGetCommitRequest.encode(request).finish(); + const promise = this.rpc.request("bze.scavenge.Query", "Commit", data); + return promise.then((data) => + QueryGetCommitResponse.decode(new Reader(data)) + ); + } + + CommitAll(request: QueryAllCommitRequest): Promise { + const data = QueryAllCommitRequest.encode(request).finish(); + const promise = this.rpc.request("bze.scavenge.Query", "CommitAll", data); + return promise.then((data) => + QueryAllCommitResponse.decode(new Reader(data)) + ); + } +} + +interface Rpc { + request( + service: string, + method: string, + data: Uint8Array + ): Promise; +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/bze.scavenge/types/scavenge/scavenge.ts b/ts-client/bze.scavenge/types/scavenge/scavenge.ts new file mode 100644 index 00000000..8c5b18b4 --- /dev/null +++ b/ts-client/bze.scavenge/types/scavenge/scavenge.ts @@ -0,0 +1,173 @@ +/* eslint-disable */ +import { Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "bze.scavenge"; + +export interface Scavenge { + index: string; + solutionHash: string; + solution: string; + description: string; + reward: string; + scavenger: string; +} + +const baseScavenge: object = { + index: "", + solutionHash: "", + solution: "", + description: "", + reward: "", + scavenger: "", +}; + +export const Scavenge = { + encode(message: Scavenge, writer: Writer = Writer.create()): Writer { + if (message.index !== "") { + writer.uint32(10).string(message.index); + } + if (message.solutionHash !== "") { + writer.uint32(18).string(message.solutionHash); + } + if (message.solution !== "") { + writer.uint32(26).string(message.solution); + } + if (message.description !== "") { + writer.uint32(34).string(message.description); + } + if (message.reward !== "") { + writer.uint32(42).string(message.reward); + } + if (message.scavenger !== "") { + writer.uint32(50).string(message.scavenger); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Scavenge { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseScavenge } as Scavenge; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.index = reader.string(); + break; + case 2: + message.solutionHash = reader.string(); + break; + case 3: + message.solution = reader.string(); + break; + case 4: + message.description = reader.string(); + break; + case 5: + message.reward = reader.string(); + break; + case 6: + message.scavenger = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Scavenge { + const message = { ...baseScavenge } as Scavenge; + if (object.index !== undefined && object.index !== null) { + message.index = String(object.index); + } else { + message.index = ""; + } + if (object.solutionHash !== undefined && object.solutionHash !== null) { + message.solutionHash = String(object.solutionHash); + } else { + message.solutionHash = ""; + } + if (object.solution !== undefined && object.solution !== null) { + message.solution = String(object.solution); + } else { + message.solution = ""; + } + if (object.description !== undefined && object.description !== null) { + message.description = String(object.description); + } else { + message.description = ""; + } + if (object.reward !== undefined && object.reward !== null) { + message.reward = String(object.reward); + } else { + message.reward = ""; + } + if (object.scavenger !== undefined && object.scavenger !== null) { + message.scavenger = String(object.scavenger); + } else { + message.scavenger = ""; + } + return message; + }, + + toJSON(message: Scavenge): unknown { + const obj: any = {}; + message.index !== undefined && (obj.index = message.index); + message.solutionHash !== undefined && + (obj.solutionHash = message.solutionHash); + message.solution !== undefined && (obj.solution = message.solution); + message.description !== undefined && + (obj.description = message.description); + message.reward !== undefined && (obj.reward = message.reward); + message.scavenger !== undefined && (obj.scavenger = message.scavenger); + return obj; + }, + + fromPartial(object: DeepPartial): Scavenge { + const message = { ...baseScavenge } as Scavenge; + if (object.index !== undefined && object.index !== null) { + message.index = object.index; + } else { + message.index = ""; + } + if (object.solutionHash !== undefined && object.solutionHash !== null) { + message.solutionHash = object.solutionHash; + } else { + message.solutionHash = ""; + } + if (object.solution !== undefined && object.solution !== null) { + message.solution = object.solution; + } else { + message.solution = ""; + } + if (object.description !== undefined && object.description !== null) { + message.description = object.description; + } else { + message.description = ""; + } + if (object.reward !== undefined && object.reward !== null) { + message.reward = object.reward; + } else { + message.reward = ""; + } + if (object.scavenger !== undefined && object.scavenger !== null) { + message.scavenger = object.scavenger; + } else { + message.scavenger = ""; + } + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/bze.scavenge/types/scavenge/tx.ts b/ts-client/bze.scavenge/types/scavenge/tx.ts new file mode 100644 index 00000000..8e29ae57 --- /dev/null +++ b/ts-client/bze.scavenge/types/scavenge/tx.ts @@ -0,0 +1,574 @@ +/* eslint-disable */ +import { Reader, Writer } from "protobufjs/minimal"; + +export const protobufPackage = "bze.scavenge"; + +export interface MsgSubmitScavenge { + creator: string; + solutionHash: string; + description: string; + reward: string; +} + +export interface MsgSubmitScavengeResponse {} + +export interface MsgCommitSolution { + creator: string; + solutionHash: string; + solutionScavengerHash: string; +} + +export interface MsgCommitSolutionResponse {} + +export interface MsgRevealSolution { + creator: string; + solution: string; + scavengeIndex: string; +} + +export interface MsgRevealSolutionResponse {} + +const baseMsgSubmitScavenge: object = { + creator: "", + solutionHash: "", + description: "", + reward: "", +}; + +export const MsgSubmitScavenge = { + encode(message: MsgSubmitScavenge, writer: Writer = Writer.create()): Writer { + if (message.creator !== "") { + writer.uint32(10).string(message.creator); + } + if (message.solutionHash !== "") { + writer.uint32(18).string(message.solutionHash); + } + if (message.description !== "") { + writer.uint32(26).string(message.description); + } + if (message.reward !== "") { + writer.uint32(34).string(message.reward); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MsgSubmitScavenge { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgSubmitScavenge } as MsgSubmitScavenge; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.creator = reader.string(); + break; + case 2: + message.solutionHash = reader.string(); + break; + case 3: + message.description = reader.string(); + break; + case 4: + message.reward = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgSubmitScavenge { + const message = { ...baseMsgSubmitScavenge } as MsgSubmitScavenge; + if (object.creator !== undefined && object.creator !== null) { + message.creator = String(object.creator); + } else { + message.creator = ""; + } + if (object.solutionHash !== undefined && object.solutionHash !== null) { + message.solutionHash = String(object.solutionHash); + } else { + message.solutionHash = ""; + } + if (object.description !== undefined && object.description !== null) { + message.description = String(object.description); + } else { + message.description = ""; + } + if (object.reward !== undefined && object.reward !== null) { + message.reward = String(object.reward); + } else { + message.reward = ""; + } + return message; + }, + + toJSON(message: MsgSubmitScavenge): unknown { + const obj: any = {}; + message.creator !== undefined && (obj.creator = message.creator); + message.solutionHash !== undefined && + (obj.solutionHash = message.solutionHash); + message.description !== undefined && + (obj.description = message.description); + message.reward !== undefined && (obj.reward = message.reward); + return obj; + }, + + fromPartial(object: DeepPartial): MsgSubmitScavenge { + const message = { ...baseMsgSubmitScavenge } as MsgSubmitScavenge; + if (object.creator !== undefined && object.creator !== null) { + message.creator = object.creator; + } else { + message.creator = ""; + } + if (object.solutionHash !== undefined && object.solutionHash !== null) { + message.solutionHash = object.solutionHash; + } else { + message.solutionHash = ""; + } + if (object.description !== undefined && object.description !== null) { + message.description = object.description; + } else { + message.description = ""; + } + if (object.reward !== undefined && object.reward !== null) { + message.reward = object.reward; + } else { + message.reward = ""; + } + return message; + }, +}; + +const baseMsgSubmitScavengeResponse: object = {}; + +export const MsgSubmitScavengeResponse = { + encode( + _: MsgSubmitScavengeResponse, + writer: Writer = Writer.create() + ): Writer { + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): MsgSubmitScavengeResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseMsgSubmitScavengeResponse, + } as MsgSubmitScavengeResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): MsgSubmitScavengeResponse { + const message = { + ...baseMsgSubmitScavengeResponse, + } as MsgSubmitScavengeResponse; + return message; + }, + + toJSON(_: MsgSubmitScavengeResponse): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial( + _: DeepPartial + ): MsgSubmitScavengeResponse { + const message = { + ...baseMsgSubmitScavengeResponse, + } as MsgSubmitScavengeResponse; + return message; + }, +}; + +const baseMsgCommitSolution: object = { + creator: "", + solutionHash: "", + solutionScavengerHash: "", +}; + +export const MsgCommitSolution = { + encode(message: MsgCommitSolution, writer: Writer = Writer.create()): Writer { + if (message.creator !== "") { + writer.uint32(10).string(message.creator); + } + if (message.solutionHash !== "") { + writer.uint32(18).string(message.solutionHash); + } + if (message.solutionScavengerHash !== "") { + writer.uint32(26).string(message.solutionScavengerHash); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MsgCommitSolution { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgCommitSolution } as MsgCommitSolution; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.creator = reader.string(); + break; + case 2: + message.solutionHash = reader.string(); + break; + case 3: + message.solutionScavengerHash = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgCommitSolution { + const message = { ...baseMsgCommitSolution } as MsgCommitSolution; + if (object.creator !== undefined && object.creator !== null) { + message.creator = String(object.creator); + } else { + message.creator = ""; + } + if (object.solutionHash !== undefined && object.solutionHash !== null) { + message.solutionHash = String(object.solutionHash); + } else { + message.solutionHash = ""; + } + if ( + object.solutionScavengerHash !== undefined && + object.solutionScavengerHash !== null + ) { + message.solutionScavengerHash = String(object.solutionScavengerHash); + } else { + message.solutionScavengerHash = ""; + } + return message; + }, + + toJSON(message: MsgCommitSolution): unknown { + const obj: any = {}; + message.creator !== undefined && (obj.creator = message.creator); + message.solutionHash !== undefined && + (obj.solutionHash = message.solutionHash); + message.solutionScavengerHash !== undefined && + (obj.solutionScavengerHash = message.solutionScavengerHash); + return obj; + }, + + fromPartial(object: DeepPartial): MsgCommitSolution { + const message = { ...baseMsgCommitSolution } as MsgCommitSolution; + if (object.creator !== undefined && object.creator !== null) { + message.creator = object.creator; + } else { + message.creator = ""; + } + if (object.solutionHash !== undefined && object.solutionHash !== null) { + message.solutionHash = object.solutionHash; + } else { + message.solutionHash = ""; + } + if ( + object.solutionScavengerHash !== undefined && + object.solutionScavengerHash !== null + ) { + message.solutionScavengerHash = object.solutionScavengerHash; + } else { + message.solutionScavengerHash = ""; + } + return message; + }, +}; + +const baseMsgCommitSolutionResponse: object = {}; + +export const MsgCommitSolutionResponse = { + encode( + _: MsgCommitSolutionResponse, + writer: Writer = Writer.create() + ): Writer { + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): MsgCommitSolutionResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseMsgCommitSolutionResponse, + } as MsgCommitSolutionResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): MsgCommitSolutionResponse { + const message = { + ...baseMsgCommitSolutionResponse, + } as MsgCommitSolutionResponse; + return message; + }, + + toJSON(_: MsgCommitSolutionResponse): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial( + _: DeepPartial + ): MsgCommitSolutionResponse { + const message = { + ...baseMsgCommitSolutionResponse, + } as MsgCommitSolutionResponse; + return message; + }, +}; + +const baseMsgRevealSolution: object = { + creator: "", + solution: "", + scavengeIndex: "", +}; + +export const MsgRevealSolution = { + encode(message: MsgRevealSolution, writer: Writer = Writer.create()): Writer { + if (message.creator !== "") { + writer.uint32(10).string(message.creator); + } + if (message.solution !== "") { + writer.uint32(18).string(message.solution); + } + if (message.scavengeIndex !== "") { + writer.uint32(26).string(message.scavengeIndex); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MsgRevealSolution { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgRevealSolution } as MsgRevealSolution; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.creator = reader.string(); + break; + case 2: + message.solution = reader.string(); + break; + case 3: + message.scavengeIndex = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgRevealSolution { + const message = { ...baseMsgRevealSolution } as MsgRevealSolution; + if (object.creator !== undefined && object.creator !== null) { + message.creator = String(object.creator); + } else { + message.creator = ""; + } + if (object.solution !== undefined && object.solution !== null) { + message.solution = String(object.solution); + } else { + message.solution = ""; + } + if (object.scavengeIndex !== undefined && object.scavengeIndex !== null) { + message.scavengeIndex = String(object.scavengeIndex); + } else { + message.scavengeIndex = ""; + } + return message; + }, + + toJSON(message: MsgRevealSolution): unknown { + const obj: any = {}; + message.creator !== undefined && (obj.creator = message.creator); + message.solution !== undefined && (obj.solution = message.solution); + message.scavengeIndex !== undefined && + (obj.scavengeIndex = message.scavengeIndex); + return obj; + }, + + fromPartial(object: DeepPartial): MsgRevealSolution { + const message = { ...baseMsgRevealSolution } as MsgRevealSolution; + if (object.creator !== undefined && object.creator !== null) { + message.creator = object.creator; + } else { + message.creator = ""; + } + if (object.solution !== undefined && object.solution !== null) { + message.solution = object.solution; + } else { + message.solution = ""; + } + if (object.scavengeIndex !== undefined && object.scavengeIndex !== null) { + message.scavengeIndex = object.scavengeIndex; + } else { + message.scavengeIndex = ""; + } + return message; + }, +}; + +const baseMsgRevealSolutionResponse: object = {}; + +export const MsgRevealSolutionResponse = { + encode( + _: MsgRevealSolutionResponse, + writer: Writer = Writer.create() + ): Writer { + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): MsgRevealSolutionResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseMsgRevealSolutionResponse, + } as MsgRevealSolutionResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): MsgRevealSolutionResponse { + const message = { + ...baseMsgRevealSolutionResponse, + } as MsgRevealSolutionResponse; + return message; + }, + + toJSON(_: MsgRevealSolutionResponse): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial( + _: DeepPartial + ): MsgRevealSolutionResponse { + const message = { + ...baseMsgRevealSolutionResponse, + } as MsgRevealSolutionResponse; + return message; + }, +}; + +/** Msg defines the Msg service. */ +export interface Msg { + SubmitScavenge( + request: MsgSubmitScavenge + ): Promise; + CommitSolution( + request: MsgCommitSolution + ): Promise; + /** this line is used by starport scaffolding # proto/tx/rpc */ + RevealSolution( + request: MsgRevealSolution + ): Promise; +} + +export class MsgClientImpl implements Msg { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + } + SubmitScavenge( + request: MsgSubmitScavenge + ): Promise { + const data = MsgSubmitScavenge.encode(request).finish(); + const promise = this.rpc.request( + "bze.scavenge.Msg", + "SubmitScavenge", + data + ); + return promise.then((data) => + MsgSubmitScavengeResponse.decode(new Reader(data)) + ); + } + + CommitSolution( + request: MsgCommitSolution + ): Promise { + const data = MsgCommitSolution.encode(request).finish(); + const promise = this.rpc.request( + "bze.scavenge.Msg", + "CommitSolution", + data + ); + return promise.then((data) => + MsgCommitSolutionResponse.decode(new Reader(data)) + ); + } + + RevealSolution( + request: MsgRevealSolution + ): Promise { + const data = MsgRevealSolution.encode(request).finish(); + const promise = this.rpc.request( + "bze.scavenge.Msg", + "RevealSolution", + data + ); + return promise.then((data) => + MsgRevealSolutionResponse.decode(new Reader(data)) + ); + } +} + +interface Rpc { + request( + service: string, + method: string, + data: Uint8Array + ): Promise; +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/bze.tokenfactory.v1/index.ts b/ts-client/bze.tokenfactory.v1/index.ts new file mode 100755 index 00000000..c9dfa159 --- /dev/null +++ b/ts-client/bze.tokenfactory.v1/index.ts @@ -0,0 +1,6 @@ +import Module from './module'; +import { txClient, queryClient, registry } from './module'; +import { msgTypes } from './registry'; + +export * from "./types"; +export { Module, msgTypes, txClient, queryClient, registry }; diff --git a/ts-client/bze.tokenfactory.v1/module.ts b/ts-client/bze.tokenfactory.v1/module.ts new file mode 100755 index 00000000..a18fea86 --- /dev/null +++ b/ts-client/bze.tokenfactory.v1/module.ts @@ -0,0 +1,231 @@ +// Generated by Ignite ignite.com/cli + +import { StdFee } from "@cosmjs/launchpad"; +import { SigningStargateClient, DeliverTxResponse } from "@cosmjs/stargate"; +import { EncodeObject, GeneratedType, OfflineSigner, Registry } from "@cosmjs/proto-signing"; +import { msgTypes } from './registry'; +import { IgniteClient } from "../client" +import { MissingWalletError } from "../helpers" +import { Api } from "./rest"; +import { MsgChangeAdmin } from "./types/tokenfactory/tx"; +import { MsgMint } from "./types/tokenfactory/tx"; +import { MsgSetDenomMetadata } from "./types/tokenfactory/tx"; +import { MsgBurn } from "./types/tokenfactory/tx"; +import { MsgCreateDenom } from "./types/tokenfactory/tx"; + + +export { MsgChangeAdmin, MsgMint, MsgSetDenomMetadata, MsgBurn, MsgCreateDenom }; + +type sendMsgChangeAdminParams = { + value: MsgChangeAdmin, + fee?: StdFee, + memo?: string +}; + +type sendMsgMintParams = { + value: MsgMint, + fee?: StdFee, + memo?: string +}; + +type sendMsgSetDenomMetadataParams = { + value: MsgSetDenomMetadata, + fee?: StdFee, + memo?: string +}; + +type sendMsgBurnParams = { + value: MsgBurn, + fee?: StdFee, + memo?: string +}; + +type sendMsgCreateDenomParams = { + value: MsgCreateDenom, + fee?: StdFee, + memo?: string +}; + + +type msgChangeAdminParams = { + value: MsgChangeAdmin, +}; + +type msgMintParams = { + value: MsgMint, +}; + +type msgSetDenomMetadataParams = { + value: MsgSetDenomMetadata, +}; + +type msgBurnParams = { + value: MsgBurn, +}; + +type msgCreateDenomParams = { + value: MsgCreateDenom, +}; + + +export const registry = new Registry(msgTypes); + +const defaultFee = { + amount: [], + gas: "200000", +}; + +interface TxClientOptions { + addr: string + prefix: string + signer?: OfflineSigner +} + +export const txClient = ({ signer, prefix, addr }: TxClientOptions = { addr: "http://localhost:26657", prefix: "cosmos" }) => { + + return { + + async sendMsgChangeAdmin({ value, fee, memo }: sendMsgChangeAdminParams): Promise { + if (!signer) { + throw new Error('TxClient:sendMsgChangeAdmin: Unable to sign Tx. Signer is not present.') + } + try { + const { address } = (await signer.getAccounts())[0]; + const signingClient = await SigningStargateClient.connectWithSigner(addr,signer,{registry, prefix}); + let msg = this.msgChangeAdmin({ value: MsgChangeAdmin.fromPartial(value) }) + return await signingClient.signAndBroadcast(address, [msg], fee ? fee : defaultFee, memo) + } catch (e: any) { + throw new Error('TxClient:sendMsgChangeAdmin: Could not broadcast Tx: '+ e.message) + } + }, + + async sendMsgMint({ value, fee, memo }: sendMsgMintParams): Promise { + if (!signer) { + throw new Error('TxClient:sendMsgMint: Unable to sign Tx. Signer is not present.') + } + try { + const { address } = (await signer.getAccounts())[0]; + const signingClient = await SigningStargateClient.connectWithSigner(addr,signer,{registry, prefix}); + let msg = this.msgMint({ value: MsgMint.fromPartial(value) }) + return await signingClient.signAndBroadcast(address, [msg], fee ? fee : defaultFee, memo) + } catch (e: any) { + throw new Error('TxClient:sendMsgMint: Could not broadcast Tx: '+ e.message) + } + }, + + async sendMsgSetDenomMetadata({ value, fee, memo }: sendMsgSetDenomMetadataParams): Promise { + if (!signer) { + throw new Error('TxClient:sendMsgSetDenomMetadata: Unable to sign Tx. Signer is not present.') + } + try { + const { address } = (await signer.getAccounts())[0]; + const signingClient = await SigningStargateClient.connectWithSigner(addr,signer,{registry, prefix}); + let msg = this.msgSetDenomMetadata({ value: MsgSetDenomMetadata.fromPartial(value) }) + return await signingClient.signAndBroadcast(address, [msg], fee ? fee : defaultFee, memo) + } catch (e: any) { + throw new Error('TxClient:sendMsgSetDenomMetadata: Could not broadcast Tx: '+ e.message) + } + }, + + async sendMsgBurn({ value, fee, memo }: sendMsgBurnParams): Promise { + if (!signer) { + throw new Error('TxClient:sendMsgBurn: Unable to sign Tx. Signer is not present.') + } + try { + const { address } = (await signer.getAccounts())[0]; + const signingClient = await SigningStargateClient.connectWithSigner(addr,signer,{registry, prefix}); + let msg = this.msgBurn({ value: MsgBurn.fromPartial(value) }) + return await signingClient.signAndBroadcast(address, [msg], fee ? fee : defaultFee, memo) + } catch (e: any) { + throw new Error('TxClient:sendMsgBurn: Could not broadcast Tx: '+ e.message) + } + }, + + async sendMsgCreateDenom({ value, fee, memo }: sendMsgCreateDenomParams): Promise { + if (!signer) { + throw new Error('TxClient:sendMsgCreateDenom: Unable to sign Tx. Signer is not present.') + } + try { + const { address } = (await signer.getAccounts())[0]; + const signingClient = await SigningStargateClient.connectWithSigner(addr,signer,{registry, prefix}); + let msg = this.msgCreateDenom({ value: MsgCreateDenom.fromPartial(value) }) + return await signingClient.signAndBroadcast(address, [msg], fee ? fee : defaultFee, memo) + } catch (e: any) { + throw new Error('TxClient:sendMsgCreateDenom: Could not broadcast Tx: '+ e.message) + } + }, + + + msgChangeAdmin({ value }: msgChangeAdminParams): EncodeObject { + try { + return { typeUrl: "/bze.tokenfactory.v1.MsgChangeAdmin", value: MsgChangeAdmin.fromPartial( value ) } + } catch (e: any) { + throw new Error('TxClient:MsgChangeAdmin: Could not create message: ' + e.message) + } + }, + + msgMint({ value }: msgMintParams): EncodeObject { + try { + return { typeUrl: "/bze.tokenfactory.v1.MsgMint", value: MsgMint.fromPartial( value ) } + } catch (e: any) { + throw new Error('TxClient:MsgMint: Could not create message: ' + e.message) + } + }, + + msgSetDenomMetadata({ value }: msgSetDenomMetadataParams): EncodeObject { + try { + return { typeUrl: "/bze.tokenfactory.v1.MsgSetDenomMetadata", value: MsgSetDenomMetadata.fromPartial( value ) } + } catch (e: any) { + throw new Error('TxClient:MsgSetDenomMetadata: Could not create message: ' + e.message) + } + }, + + msgBurn({ value }: msgBurnParams): EncodeObject { + try { + return { typeUrl: "/bze.tokenfactory.v1.MsgBurn", value: MsgBurn.fromPartial( value ) } + } catch (e: any) { + throw new Error('TxClient:MsgBurn: Could not create message: ' + e.message) + } + }, + + msgCreateDenom({ value }: msgCreateDenomParams): EncodeObject { + try { + return { typeUrl: "/bze.tokenfactory.v1.MsgCreateDenom", value: MsgCreateDenom.fromPartial( value ) } + } catch (e: any) { + throw new Error('TxClient:MsgCreateDenom: Could not create message: ' + e.message) + } + }, + + } +}; + +interface QueryClientOptions { + addr: string +} + +export const queryClient = ({ addr: addr }: QueryClientOptions = { addr: "http://localhost:1317" }) => { + return new Api({ baseUrl: addr }); +}; + +class SDKModule { + public query: ReturnType; + public tx: ReturnType; + + public registry: Array<[string, GeneratedType]>; + + constructor(client: IgniteClient) { + + this.query = queryClient({ addr: client.env.apiURL }); + this.tx = txClient({ signer: client.signer, addr: client.env.rpcURL, prefix: client.env.prefix ?? "cosmos" }); + } +}; + +const Module = (test: IgniteClient) => { + return { + module: { + BzeTokenfactoryV1: new SDKModule(test) + }, + registry: msgTypes + } +} +export default Module; \ No newline at end of file diff --git a/ts-client/bze.tokenfactory.v1/registry.ts b/ts-client/bze.tokenfactory.v1/registry.ts new file mode 100755 index 00000000..f55bba91 --- /dev/null +++ b/ts-client/bze.tokenfactory.v1/registry.ts @@ -0,0 +1,17 @@ +import { GeneratedType } from "@cosmjs/proto-signing"; +import { MsgChangeAdmin } from "./types/tokenfactory/tx"; +import { MsgMint } from "./types/tokenfactory/tx"; +import { MsgSetDenomMetadata } from "./types/tokenfactory/tx"; +import { MsgBurn } from "./types/tokenfactory/tx"; +import { MsgCreateDenom } from "./types/tokenfactory/tx"; + +const msgTypes: Array<[string, GeneratedType]> = [ + ["/bze.tokenfactory.v1.MsgChangeAdmin", MsgChangeAdmin], + ["/bze.tokenfactory.v1.MsgMint", MsgMint], + ["/bze.tokenfactory.v1.MsgSetDenomMetadata", MsgSetDenomMetadata], + ["/bze.tokenfactory.v1.MsgBurn", MsgBurn], + ["/bze.tokenfactory.v1.MsgCreateDenom", MsgCreateDenom], + +]; + +export { msgTypes } \ No newline at end of file diff --git a/ts-client/bze.tokenfactory.v1/rest.ts b/ts-client/bze.tokenfactory.v1/rest.ts new file mode 100644 index 00000000..023b36d9 --- /dev/null +++ b/ts-client/bze.tokenfactory.v1/rest.ts @@ -0,0 +1,335 @@ +/* eslint-disable */ +/* tslint:disable */ +/* + * --------------------------------------------------------------- + * ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ## + * ## ## + * ## AUTHOR: acacode ## + * ## SOURCE: https://github.com/acacode/swagger-typescript-api ## + * --------------------------------------------------------------- + */ + +export interface ProtobufAny { + "@type"?: string; +} + +export interface RpcStatus { + /** @format int32 */ + code?: number; + message?: string; + details?: ProtobufAny[]; +} + +export interface Tokenfactoryv1DenomAuthority { + admin?: string; +} + +/** + * Params defines the parameters for the module. + */ +export interface Tokenfactoryv1Params { + createDenomFee?: string; +} + +export type V1MsgBurnResponse = object; + +export type V1MsgChangeAdminResponse = object; + +export interface V1MsgCreateDenomResponse { + new_denom?: string; +} + +export type V1MsgMintResponse = object; + +export type V1MsgSetDenomMetadataResponse = object; + +export interface V1QueryDenomAuthorityResponse { + denomAuthority?: Tokenfactoryv1DenomAuthority; +} + +/** + * QueryParamsResponse is response type for the Query/Params RPC method. + */ +export interface V1QueryParamsResponse { + /** params holds all the parameters of this module. */ + params?: Tokenfactoryv1Params; +} + +/** +* DenomUnit represents a struct that describes a given +denomination unit of the basic token. +*/ +export interface V1Beta1DenomUnit { + /** denom represents the string name of the given denom unit (e.g uatom). */ + denom?: string; + + /** + * exponent represents power of 10 exponent that one must + * raise the base_denom to in order to equal the given DenomUnit's denom + * 1 denom = 1^exponent base_denom + * (e.g. with a base_denom of uatom, one can create a DenomUnit of 'atom' with + * exponent = 6, thus: 1 atom = 10^6 uatom). + * @format int64 + */ + exponent?: number; + aliases?: string[]; +} + +/** +* Metadata represents a struct that describes +a basic token. +*/ +export interface V1Beta1Metadata { + description?: string; + denom_units?: V1Beta1DenomUnit[]; + + /** base represents the base denom (should be the DenomUnit with exponent = 0). */ + base?: string; + + /** + * display indicates the suggested denom that should be + * displayed in clients. + */ + display?: string; + + /** Since: cosmos-sdk 0.43 */ + name?: string; + + /** + * symbol is the token symbol usually shown on exchanges (eg: ATOM). This can + * be the same as the display. + * + * Since: cosmos-sdk 0.43 + */ + symbol?: string; +} + +export type QueryParamsType = Record; +export type ResponseFormat = keyof Omit; + +export interface FullRequestParams extends Omit { + /** set parameter to `true` for call `securityWorker` for this request */ + secure?: boolean; + /** request path */ + path: string; + /** content type of request body */ + type?: ContentType; + /** query params */ + query?: QueryParamsType; + /** format of response (i.e. response.json() -> format: "json") */ + format?: keyof Omit; + /** request body */ + body?: unknown; + /** base url */ + baseUrl?: string; + /** request cancellation token */ + cancelToken?: CancelToken; +} + +export type RequestParams = Omit; + +export interface ApiConfig { + baseUrl?: string; + baseApiParams?: Omit; + securityWorker?: (securityData: SecurityDataType) => RequestParams | void; +} + +export interface HttpResponse extends Response { + data: D; + error: E; +} + +type CancelToken = Symbol | string | number; + +export enum ContentType { + Json = "application/json", + FormData = "multipart/form-data", + UrlEncoded = "application/x-www-form-urlencoded", +} + +export class HttpClient { + public baseUrl: string = ""; + private securityData: SecurityDataType = null as any; + private securityWorker: null | ApiConfig["securityWorker"] = null; + private abortControllers = new Map(); + + private baseApiParams: RequestParams = { + credentials: "same-origin", + headers: {}, + redirect: "follow", + referrerPolicy: "no-referrer", + }; + + constructor(apiConfig: ApiConfig = {}) { + Object.assign(this, apiConfig); + } + + public setSecurityData = (data: SecurityDataType) => { + this.securityData = data; + }; + + private addQueryParam(query: QueryParamsType, key: string) { + const value = query[key]; + + return ( + encodeURIComponent(key) + + "=" + + encodeURIComponent(Array.isArray(value) ? value.join(",") : typeof value === "number" ? value : `${value}`) + ); + } + + protected toQueryString(rawQuery?: QueryParamsType): string { + const query = rawQuery || {}; + const keys = Object.keys(query).filter((key) => "undefined" !== typeof query[key]); + return keys + .map((key) => + typeof query[key] === "object" && !Array.isArray(query[key]) + ? this.toQueryString(query[key] as QueryParamsType) + : this.addQueryParam(query, key), + ) + .join("&"); + } + + protected addQueryParams(rawQuery?: QueryParamsType): string { + const queryString = this.toQueryString(rawQuery); + return queryString ? `?${queryString}` : ""; + } + + private contentFormatters: Record any> = { + [ContentType.Json]: (input: any) => + input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input, + [ContentType.FormData]: (input: any) => + Object.keys(input || {}).reduce((data, key) => { + data.append(key, input[key]); + return data; + }, new FormData()), + [ContentType.UrlEncoded]: (input: any) => this.toQueryString(input), + }; + + private mergeRequestParams(params1: RequestParams, params2?: RequestParams): RequestParams { + return { + ...this.baseApiParams, + ...params1, + ...(params2 || {}), + headers: { + ...(this.baseApiParams.headers || {}), + ...(params1.headers || {}), + ...((params2 && params2.headers) || {}), + }, + }; + } + + private createAbortSignal = (cancelToken: CancelToken): AbortSignal | undefined => { + if (this.abortControllers.has(cancelToken)) { + const abortController = this.abortControllers.get(cancelToken); + if (abortController) { + return abortController.signal; + } + return void 0; + } + + const abortController = new AbortController(); + this.abortControllers.set(cancelToken, abortController); + return abortController.signal; + }; + + public abortRequest = (cancelToken: CancelToken) => { + const abortController = this.abortControllers.get(cancelToken); + + if (abortController) { + abortController.abort(); + this.abortControllers.delete(cancelToken); + } + }; + + public request = ({ + body, + secure, + path, + type, + query, + format = "json", + baseUrl, + cancelToken, + ...params + }: FullRequestParams): Promise> => { + const secureParams = (secure && this.securityWorker && this.securityWorker(this.securityData)) || {}; + const requestParams = this.mergeRequestParams(params, secureParams); + const queryString = query && this.toQueryString(query); + const payloadFormatter = this.contentFormatters[type || ContentType.Json]; + + return fetch(`${baseUrl || this.baseUrl || ""}${path}${queryString ? `?${queryString}` : ""}`, { + ...requestParams, + headers: { + ...(type && type !== ContentType.FormData ? { "Content-Type": type } : {}), + ...(requestParams.headers || {}), + }, + signal: cancelToken ? this.createAbortSignal(cancelToken) : void 0, + body: typeof body === "undefined" || body === null ? null : payloadFormatter(body), + }).then(async (response) => { + const r = response as HttpResponse; + r.data = (null as unknown) as T; + r.error = (null as unknown) as E; + + const data = await response[format]() + .then((data) => { + if (r.ok) { + r.data = data; + } else { + r.error = data; + } + return r; + }) + .catch((e) => { + r.error = e; + return r; + }); + + if (cancelToken) { + this.abortControllers.delete(cancelToken); + } + + if (!response.ok) throw data; + return data; + }); + }; +} + +/** + * @title tokenfactory/denom_authority.proto + * @version version not set + */ +export class Api extends HttpClient { + /** + * No description + * + * @tags Query + * @name QueryDenomAuthority + * @summary Queries a list of QueryDenomAuthority items. + * @request GET:/bze/tokenfactory/v1/denom_authority + */ + queryDenomAuthority = (query?: { denom?: string }, params: RequestParams = {}) => + this.request({ + path: `/bze/tokenfactory/v1/denom_authority`, + method: "GET", + query: query, + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Query + * @name QueryParams + * @summary Parameters queries the parameters of the module. + * @request GET:/bze/tokenfactory/v1/params + */ + queryParams = (params: RequestParams = {}) => + this.request({ + path: `/bze/tokenfactory/v1/params`, + method: "GET", + format: "json", + ...params, + }); +} diff --git a/ts-client/bze.tokenfactory.v1/types.ts b/ts-client/bze.tokenfactory.v1/types.ts new file mode 100755 index 00000000..9d32062b --- /dev/null +++ b/ts-client/bze.tokenfactory.v1/types.ts @@ -0,0 +1,11 @@ +import { DenomAuthority } from "./types/tokenfactory/denom_authority" +import { GenesisDenom } from "./types/tokenfactory/genesis" +import { Params } from "./types/tokenfactory/params" + + +export { + DenomAuthority, + GenesisDenom, + Params, + + } \ No newline at end of file diff --git a/ts-client/bze.tokenfactory.v1/types/cosmos/bank/v1beta1/bank.ts b/ts-client/bze.tokenfactory.v1/types/cosmos/bank/v1beta1/bank.ts new file mode 100644 index 00000000..7651c102 --- /dev/null +++ b/ts-client/bze.tokenfactory.v1/types/cosmos/bank/v1beta1/bank.ts @@ -0,0 +1,735 @@ +/* eslint-disable */ +import { Coin } from "../../../cosmos/base/v1beta1/coin"; +import { Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "cosmos.bank.v1beta1"; + +/** Params defines the parameters for the bank module. */ +export interface Params { + sendEnabled: SendEnabled[]; + defaultSendEnabled: boolean; +} + +/** + * SendEnabled maps coin denom to a send_enabled status (whether a denom is + * sendable). + */ +export interface SendEnabled { + denom: string; + enabled: boolean; +} + +/** Input models transaction input. */ +export interface Input { + address: string; + coins: Coin[]; +} + +/** Output models transaction outputs. */ +export interface Output { + address: string; + coins: Coin[]; +} + +/** + * Supply represents a struct that passively keeps track of the total supply + * amounts in the network. + * This message is deprecated now that supply is indexed by denom. + * + * @deprecated + */ +export interface Supply { + total: Coin[]; +} + +/** + * DenomUnit represents a struct that describes a given + * denomination unit of the basic token. + */ +export interface DenomUnit { + /** denom represents the string name of the given denom unit (e.g uatom). */ + denom: string; + /** + * exponent represents power of 10 exponent that one must + * raise the base_denom to in order to equal the given DenomUnit's denom + * 1 denom = 1^exponent base_denom + * (e.g. with a base_denom of uatom, one can create a DenomUnit of 'atom' with + * exponent = 6, thus: 1 atom = 10^6 uatom). + */ + exponent: number; + /** aliases is a list of string aliases for the given denom */ + aliases: string[]; +} + +/** + * Metadata represents a struct that describes + * a basic token. + */ +export interface Metadata { + description: string; + /** denom_units represents the list of DenomUnit's for a given coin */ + denomUnits: DenomUnit[]; + /** base represents the base denom (should be the DenomUnit with exponent = 0). */ + base: string; + /** + * display indicates the suggested denom that should be + * displayed in clients. + */ + display: string; + /** + * name defines the name of the token (eg: Cosmos Atom) + * + * Since: cosmos-sdk 0.43 + */ + name: string; + /** + * symbol is the token symbol usually shown on exchanges (eg: ATOM). This can + * be the same as the display. + * + * Since: cosmos-sdk 0.43 + */ + symbol: string; +} + +const baseParams: object = { defaultSendEnabled: false }; + +export const Params = { + encode(message: Params, writer: Writer = Writer.create()): Writer { + for (const v of message.sendEnabled) { + SendEnabled.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.defaultSendEnabled === true) { + writer.uint32(16).bool(message.defaultSendEnabled); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Params { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseParams } as Params; + message.sendEnabled = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.sendEnabled.push(SendEnabled.decode(reader, reader.uint32())); + break; + case 2: + message.defaultSendEnabled = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Params { + const message = { ...baseParams } as Params; + message.sendEnabled = []; + if (object.sendEnabled !== undefined && object.sendEnabled !== null) { + for (const e of object.sendEnabled) { + message.sendEnabled.push(SendEnabled.fromJSON(e)); + } + } + if ( + object.defaultSendEnabled !== undefined && + object.defaultSendEnabled !== null + ) { + message.defaultSendEnabled = Boolean(object.defaultSendEnabled); + } else { + message.defaultSendEnabled = false; + } + return message; + }, + + toJSON(message: Params): unknown { + const obj: any = {}; + if (message.sendEnabled) { + obj.sendEnabled = message.sendEnabled.map((e) => + e ? SendEnabled.toJSON(e) : undefined + ); + } else { + obj.sendEnabled = []; + } + message.defaultSendEnabled !== undefined && + (obj.defaultSendEnabled = message.defaultSendEnabled); + return obj; + }, + + fromPartial(object: DeepPartial): Params { + const message = { ...baseParams } as Params; + message.sendEnabled = []; + if (object.sendEnabled !== undefined && object.sendEnabled !== null) { + for (const e of object.sendEnabled) { + message.sendEnabled.push(SendEnabled.fromPartial(e)); + } + } + if ( + object.defaultSendEnabled !== undefined && + object.defaultSendEnabled !== null + ) { + message.defaultSendEnabled = object.defaultSendEnabled; + } else { + message.defaultSendEnabled = false; + } + return message; + }, +}; + +const baseSendEnabled: object = { denom: "", enabled: false }; + +export const SendEnabled = { + encode(message: SendEnabled, writer: Writer = Writer.create()): Writer { + if (message.denom !== "") { + writer.uint32(10).string(message.denom); + } + if (message.enabled === true) { + writer.uint32(16).bool(message.enabled); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): SendEnabled { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseSendEnabled } as SendEnabled; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.denom = reader.string(); + break; + case 2: + message.enabled = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): SendEnabled { + const message = { ...baseSendEnabled } as SendEnabled; + if (object.denom !== undefined && object.denom !== null) { + message.denom = String(object.denom); + } else { + message.denom = ""; + } + if (object.enabled !== undefined && object.enabled !== null) { + message.enabled = Boolean(object.enabled); + } else { + message.enabled = false; + } + return message; + }, + + toJSON(message: SendEnabled): unknown { + const obj: any = {}; + message.denom !== undefined && (obj.denom = message.denom); + message.enabled !== undefined && (obj.enabled = message.enabled); + return obj; + }, + + fromPartial(object: DeepPartial): SendEnabled { + const message = { ...baseSendEnabled } as SendEnabled; + if (object.denom !== undefined && object.denom !== null) { + message.denom = object.denom; + } else { + message.denom = ""; + } + if (object.enabled !== undefined && object.enabled !== null) { + message.enabled = object.enabled; + } else { + message.enabled = false; + } + return message; + }, +}; + +const baseInput: object = { address: "" }; + +export const Input = { + encode(message: Input, writer: Writer = Writer.create()): Writer { + if (message.address !== "") { + writer.uint32(10).string(message.address); + } + for (const v of message.coins) { + Coin.encode(v!, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Input { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseInput } as Input; + message.coins = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.address = reader.string(); + break; + case 2: + message.coins.push(Coin.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Input { + const message = { ...baseInput } as Input; + message.coins = []; + if (object.address !== undefined && object.address !== null) { + message.address = String(object.address); + } else { + message.address = ""; + } + if (object.coins !== undefined && object.coins !== null) { + for (const e of object.coins) { + message.coins.push(Coin.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: Input): unknown { + const obj: any = {}; + message.address !== undefined && (obj.address = message.address); + if (message.coins) { + obj.coins = message.coins.map((e) => (e ? Coin.toJSON(e) : undefined)); + } else { + obj.coins = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): Input { + const message = { ...baseInput } as Input; + message.coins = []; + if (object.address !== undefined && object.address !== null) { + message.address = object.address; + } else { + message.address = ""; + } + if (object.coins !== undefined && object.coins !== null) { + for (const e of object.coins) { + message.coins.push(Coin.fromPartial(e)); + } + } + return message; + }, +}; + +const baseOutput: object = { address: "" }; + +export const Output = { + encode(message: Output, writer: Writer = Writer.create()): Writer { + if (message.address !== "") { + writer.uint32(10).string(message.address); + } + for (const v of message.coins) { + Coin.encode(v!, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Output { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseOutput } as Output; + message.coins = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.address = reader.string(); + break; + case 2: + message.coins.push(Coin.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Output { + const message = { ...baseOutput } as Output; + message.coins = []; + if (object.address !== undefined && object.address !== null) { + message.address = String(object.address); + } else { + message.address = ""; + } + if (object.coins !== undefined && object.coins !== null) { + for (const e of object.coins) { + message.coins.push(Coin.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: Output): unknown { + const obj: any = {}; + message.address !== undefined && (obj.address = message.address); + if (message.coins) { + obj.coins = message.coins.map((e) => (e ? Coin.toJSON(e) : undefined)); + } else { + obj.coins = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): Output { + const message = { ...baseOutput } as Output; + message.coins = []; + if (object.address !== undefined && object.address !== null) { + message.address = object.address; + } else { + message.address = ""; + } + if (object.coins !== undefined && object.coins !== null) { + for (const e of object.coins) { + message.coins.push(Coin.fromPartial(e)); + } + } + return message; + }, +}; + +const baseSupply: object = {}; + +export const Supply = { + encode(message: Supply, writer: Writer = Writer.create()): Writer { + for (const v of message.total) { + Coin.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Supply { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseSupply } as Supply; + message.total = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.total.push(Coin.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Supply { + const message = { ...baseSupply } as Supply; + message.total = []; + if (object.total !== undefined && object.total !== null) { + for (const e of object.total) { + message.total.push(Coin.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: Supply): unknown { + const obj: any = {}; + if (message.total) { + obj.total = message.total.map((e) => (e ? Coin.toJSON(e) : undefined)); + } else { + obj.total = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): Supply { + const message = { ...baseSupply } as Supply; + message.total = []; + if (object.total !== undefined && object.total !== null) { + for (const e of object.total) { + message.total.push(Coin.fromPartial(e)); + } + } + return message; + }, +}; + +const baseDenomUnit: object = { denom: "", exponent: 0, aliases: "" }; + +export const DenomUnit = { + encode(message: DenomUnit, writer: Writer = Writer.create()): Writer { + if (message.denom !== "") { + writer.uint32(10).string(message.denom); + } + if (message.exponent !== 0) { + writer.uint32(16).uint32(message.exponent); + } + for (const v of message.aliases) { + writer.uint32(26).string(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): DenomUnit { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseDenomUnit } as DenomUnit; + message.aliases = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.denom = reader.string(); + break; + case 2: + message.exponent = reader.uint32(); + break; + case 3: + message.aliases.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DenomUnit { + const message = { ...baseDenomUnit } as DenomUnit; + message.aliases = []; + if (object.denom !== undefined && object.denom !== null) { + message.denom = String(object.denom); + } else { + message.denom = ""; + } + if (object.exponent !== undefined && object.exponent !== null) { + message.exponent = Number(object.exponent); + } else { + message.exponent = 0; + } + if (object.aliases !== undefined && object.aliases !== null) { + for (const e of object.aliases) { + message.aliases.push(String(e)); + } + } + return message; + }, + + toJSON(message: DenomUnit): unknown { + const obj: any = {}; + message.denom !== undefined && (obj.denom = message.denom); + message.exponent !== undefined && (obj.exponent = message.exponent); + if (message.aliases) { + obj.aliases = message.aliases.map((e) => e); + } else { + obj.aliases = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): DenomUnit { + const message = { ...baseDenomUnit } as DenomUnit; + message.aliases = []; + if (object.denom !== undefined && object.denom !== null) { + message.denom = object.denom; + } else { + message.denom = ""; + } + if (object.exponent !== undefined && object.exponent !== null) { + message.exponent = object.exponent; + } else { + message.exponent = 0; + } + if (object.aliases !== undefined && object.aliases !== null) { + for (const e of object.aliases) { + message.aliases.push(e); + } + } + return message; + }, +}; + +const baseMetadata: object = { + description: "", + base: "", + display: "", + name: "", + symbol: "", +}; + +export const Metadata = { + encode(message: Metadata, writer: Writer = Writer.create()): Writer { + if (message.description !== "") { + writer.uint32(10).string(message.description); + } + for (const v of message.denomUnits) { + DenomUnit.encode(v!, writer.uint32(18).fork()).ldelim(); + } + if (message.base !== "") { + writer.uint32(26).string(message.base); + } + if (message.display !== "") { + writer.uint32(34).string(message.display); + } + if (message.name !== "") { + writer.uint32(42).string(message.name); + } + if (message.symbol !== "") { + writer.uint32(50).string(message.symbol); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Metadata { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMetadata } as Metadata; + message.denomUnits = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.description = reader.string(); + break; + case 2: + message.denomUnits.push(DenomUnit.decode(reader, reader.uint32())); + break; + case 3: + message.base = reader.string(); + break; + case 4: + message.display = reader.string(); + break; + case 5: + message.name = reader.string(); + break; + case 6: + message.symbol = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Metadata { + const message = { ...baseMetadata } as Metadata; + message.denomUnits = []; + if (object.description !== undefined && object.description !== null) { + message.description = String(object.description); + } else { + message.description = ""; + } + if (object.denomUnits !== undefined && object.denomUnits !== null) { + for (const e of object.denomUnits) { + message.denomUnits.push(DenomUnit.fromJSON(e)); + } + } + if (object.base !== undefined && object.base !== null) { + message.base = String(object.base); + } else { + message.base = ""; + } + if (object.display !== undefined && object.display !== null) { + message.display = String(object.display); + } else { + message.display = ""; + } + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.symbol !== undefined && object.symbol !== null) { + message.symbol = String(object.symbol); + } else { + message.symbol = ""; + } + return message; + }, + + toJSON(message: Metadata): unknown { + const obj: any = {}; + message.description !== undefined && + (obj.description = message.description); + if (message.denomUnits) { + obj.denomUnits = message.denomUnits.map((e) => + e ? DenomUnit.toJSON(e) : undefined + ); + } else { + obj.denomUnits = []; + } + message.base !== undefined && (obj.base = message.base); + message.display !== undefined && (obj.display = message.display); + message.name !== undefined && (obj.name = message.name); + message.symbol !== undefined && (obj.symbol = message.symbol); + return obj; + }, + + fromPartial(object: DeepPartial): Metadata { + const message = { ...baseMetadata } as Metadata; + message.denomUnits = []; + if (object.description !== undefined && object.description !== null) { + message.description = object.description; + } else { + message.description = ""; + } + if (object.denomUnits !== undefined && object.denomUnits !== null) { + for (const e of object.denomUnits) { + message.denomUnits.push(DenomUnit.fromPartial(e)); + } + } + if (object.base !== undefined && object.base !== null) { + message.base = object.base; + } else { + message.base = ""; + } + if (object.display !== undefined && object.display !== null) { + message.display = object.display; + } else { + message.display = ""; + } + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.symbol !== undefined && object.symbol !== null) { + message.symbol = object.symbol; + } else { + message.symbol = ""; + } + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/bze.tokenfactory.v1/types/cosmos/base/query/v1beta1/pagination.ts b/ts-client/bze.tokenfactory.v1/types/cosmos/base/query/v1beta1/pagination.ts new file mode 100644 index 00000000..cd4b2d78 --- /dev/null +++ b/ts-client/bze.tokenfactory.v1/types/cosmos/base/query/v1beta1/pagination.ts @@ -0,0 +1,327 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "cosmos.base.query.v1beta1"; + +/** + * PageRequest is to be embedded in gRPC request messages for efficient + * pagination. Ex: + * + * message SomeRequest { + * Foo some_parameter = 1; + * PageRequest pagination = 2; + * } + */ +export interface PageRequest { + /** + * key is a value returned in PageResponse.next_key to begin + * querying the next page most efficiently. Only one of offset or key + * should be set. + */ + key: Uint8Array; + /** + * offset is a numeric offset that can be used when key is unavailable. + * It is less efficient than using key. Only one of offset or key should + * be set. + */ + offset: number; + /** + * limit is the total number of results to be returned in the result page. + * If left empty it will default to a value to be set by each app. + */ + limit: number; + /** + * count_total is set to true to indicate that the result set should include + * a count of the total number of items available for pagination in UIs. + * count_total is only respected when offset is used. It is ignored when key + * is set. + */ + countTotal: boolean; + /** + * reverse is set to true if results are to be returned in the descending order. + * + * Since: cosmos-sdk 0.43 + */ + reverse: boolean; +} + +/** + * PageResponse is to be embedded in gRPC response messages where the + * corresponding request message has used PageRequest. + * + * message SomeResponse { + * repeated Bar results = 1; + * PageResponse page = 2; + * } + */ +export interface PageResponse { + /** + * next_key is the key to be passed to PageRequest.key to + * query the next page most efficiently + */ + nextKey: Uint8Array; + /** + * total is total number of results available if PageRequest.count_total + * was set, its value is undefined otherwise + */ + total: number; +} + +const basePageRequest: object = { + offset: 0, + limit: 0, + countTotal: false, + reverse: false, +}; + +export const PageRequest = { + encode(message: PageRequest, writer: Writer = Writer.create()): Writer { + if (message.key.length !== 0) { + writer.uint32(10).bytes(message.key); + } + if (message.offset !== 0) { + writer.uint32(16).uint64(message.offset); + } + if (message.limit !== 0) { + writer.uint32(24).uint64(message.limit); + } + if (message.countTotal === true) { + writer.uint32(32).bool(message.countTotal); + } + if (message.reverse === true) { + writer.uint32(40).bool(message.reverse); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): PageRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...basePageRequest } as PageRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.key = reader.bytes(); + break; + case 2: + message.offset = longToNumber(reader.uint64() as Long); + break; + case 3: + message.limit = longToNumber(reader.uint64() as Long); + break; + case 4: + message.countTotal = reader.bool(); + break; + case 5: + message.reverse = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): PageRequest { + const message = { ...basePageRequest } as PageRequest; + if (object.key !== undefined && object.key !== null) { + message.key = bytesFromBase64(object.key); + } + if (object.offset !== undefined && object.offset !== null) { + message.offset = Number(object.offset); + } else { + message.offset = 0; + } + if (object.limit !== undefined && object.limit !== null) { + message.limit = Number(object.limit); + } else { + message.limit = 0; + } + if (object.countTotal !== undefined && object.countTotal !== null) { + message.countTotal = Boolean(object.countTotal); + } else { + message.countTotal = false; + } + if (object.reverse !== undefined && object.reverse !== null) { + message.reverse = Boolean(object.reverse); + } else { + message.reverse = false; + } + return message; + }, + + toJSON(message: PageRequest): unknown { + const obj: any = {}; + message.key !== undefined && + (obj.key = base64FromBytes( + message.key !== undefined ? message.key : new Uint8Array() + )); + message.offset !== undefined && (obj.offset = message.offset); + message.limit !== undefined && (obj.limit = message.limit); + message.countTotal !== undefined && (obj.countTotal = message.countTotal); + message.reverse !== undefined && (obj.reverse = message.reverse); + return obj; + }, + + fromPartial(object: DeepPartial): PageRequest { + const message = { ...basePageRequest } as PageRequest; + if (object.key !== undefined && object.key !== null) { + message.key = object.key; + } else { + message.key = new Uint8Array(); + } + if (object.offset !== undefined && object.offset !== null) { + message.offset = object.offset; + } else { + message.offset = 0; + } + if (object.limit !== undefined && object.limit !== null) { + message.limit = object.limit; + } else { + message.limit = 0; + } + if (object.countTotal !== undefined && object.countTotal !== null) { + message.countTotal = object.countTotal; + } else { + message.countTotal = false; + } + if (object.reverse !== undefined && object.reverse !== null) { + message.reverse = object.reverse; + } else { + message.reverse = false; + } + return message; + }, +}; + +const basePageResponse: object = { total: 0 }; + +export const PageResponse = { + encode(message: PageResponse, writer: Writer = Writer.create()): Writer { + if (message.nextKey.length !== 0) { + writer.uint32(10).bytes(message.nextKey); + } + if (message.total !== 0) { + writer.uint32(16).uint64(message.total); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): PageResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...basePageResponse } as PageResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.nextKey = reader.bytes(); + break; + case 2: + message.total = longToNumber(reader.uint64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): PageResponse { + const message = { ...basePageResponse } as PageResponse; + if (object.nextKey !== undefined && object.nextKey !== null) { + message.nextKey = bytesFromBase64(object.nextKey); + } + if (object.total !== undefined && object.total !== null) { + message.total = Number(object.total); + } else { + message.total = 0; + } + return message; + }, + + toJSON(message: PageResponse): unknown { + const obj: any = {}; + message.nextKey !== undefined && + (obj.nextKey = base64FromBytes( + message.nextKey !== undefined ? message.nextKey : new Uint8Array() + )); + message.total !== undefined && (obj.total = message.total); + return obj; + }, + + fromPartial(object: DeepPartial): PageResponse { + const message = { ...basePageResponse } as PageResponse; + if (object.nextKey !== undefined && object.nextKey !== null) { + message.nextKey = object.nextKey; + } else { + message.nextKey = new Uint8Array(); + } + if (object.total !== undefined && object.total !== null) { + message.total = object.total; + } else { + message.total = 0; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/bze.tokenfactory.v1/types/cosmos/base/v1beta1/coin.ts b/ts-client/bze.tokenfactory.v1/types/cosmos/base/v1beta1/coin.ts new file mode 100644 index 00000000..ce2ac984 --- /dev/null +++ b/ts-client/bze.tokenfactory.v1/types/cosmos/base/v1beta1/coin.ts @@ -0,0 +1,301 @@ +/* eslint-disable */ +import { Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "cosmos.base.v1beta1"; + +/** + * Coin defines a token with a denomination and an amount. + * + * NOTE: The amount field is an Int which implements the custom method + * signatures required by gogoproto. + */ +export interface Coin { + denom: string; + amount: string; +} + +/** + * DecCoin defines a token with a denomination and a decimal amount. + * + * NOTE: The amount field is an Dec which implements the custom method + * signatures required by gogoproto. + */ +export interface DecCoin { + denom: string; + amount: string; +} + +/** IntProto defines a Protobuf wrapper around an Int object. */ +export interface IntProto { + int: string; +} + +/** DecProto defines a Protobuf wrapper around a Dec object. */ +export interface DecProto { + dec: string; +} + +const baseCoin: object = { denom: "", amount: "" }; + +export const Coin = { + encode(message: Coin, writer: Writer = Writer.create()): Writer { + if (message.denom !== "") { + writer.uint32(10).string(message.denom); + } + if (message.amount !== "") { + writer.uint32(18).string(message.amount); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Coin { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseCoin } as Coin; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.denom = reader.string(); + break; + case 2: + message.amount = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Coin { + const message = { ...baseCoin } as Coin; + if (object.denom !== undefined && object.denom !== null) { + message.denom = String(object.denom); + } else { + message.denom = ""; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = String(object.amount); + } else { + message.amount = ""; + } + return message; + }, + + toJSON(message: Coin): unknown { + const obj: any = {}; + message.denom !== undefined && (obj.denom = message.denom); + message.amount !== undefined && (obj.amount = message.amount); + return obj; + }, + + fromPartial(object: DeepPartial): Coin { + const message = { ...baseCoin } as Coin; + if (object.denom !== undefined && object.denom !== null) { + message.denom = object.denom; + } else { + message.denom = ""; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = object.amount; + } else { + message.amount = ""; + } + return message; + }, +}; + +const baseDecCoin: object = { denom: "", amount: "" }; + +export const DecCoin = { + encode(message: DecCoin, writer: Writer = Writer.create()): Writer { + if (message.denom !== "") { + writer.uint32(10).string(message.denom); + } + if (message.amount !== "") { + writer.uint32(18).string(message.amount); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): DecCoin { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseDecCoin } as DecCoin; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.denom = reader.string(); + break; + case 2: + message.amount = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DecCoin { + const message = { ...baseDecCoin } as DecCoin; + if (object.denom !== undefined && object.denom !== null) { + message.denom = String(object.denom); + } else { + message.denom = ""; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = String(object.amount); + } else { + message.amount = ""; + } + return message; + }, + + toJSON(message: DecCoin): unknown { + const obj: any = {}; + message.denom !== undefined && (obj.denom = message.denom); + message.amount !== undefined && (obj.amount = message.amount); + return obj; + }, + + fromPartial(object: DeepPartial): DecCoin { + const message = { ...baseDecCoin } as DecCoin; + if (object.denom !== undefined && object.denom !== null) { + message.denom = object.denom; + } else { + message.denom = ""; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = object.amount; + } else { + message.amount = ""; + } + return message; + }, +}; + +const baseIntProto: object = { int: "" }; + +export const IntProto = { + encode(message: IntProto, writer: Writer = Writer.create()): Writer { + if (message.int !== "") { + writer.uint32(10).string(message.int); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): IntProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseIntProto } as IntProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.int = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): IntProto { + const message = { ...baseIntProto } as IntProto; + if (object.int !== undefined && object.int !== null) { + message.int = String(object.int); + } else { + message.int = ""; + } + return message; + }, + + toJSON(message: IntProto): unknown { + const obj: any = {}; + message.int !== undefined && (obj.int = message.int); + return obj; + }, + + fromPartial(object: DeepPartial): IntProto { + const message = { ...baseIntProto } as IntProto; + if (object.int !== undefined && object.int !== null) { + message.int = object.int; + } else { + message.int = ""; + } + return message; + }, +}; + +const baseDecProto: object = { dec: "" }; + +export const DecProto = { + encode(message: DecProto, writer: Writer = Writer.create()): Writer { + if (message.dec !== "") { + writer.uint32(10).string(message.dec); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): DecProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseDecProto } as DecProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.dec = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DecProto { + const message = { ...baseDecProto } as DecProto; + if (object.dec !== undefined && object.dec !== null) { + message.dec = String(object.dec); + } else { + message.dec = ""; + } + return message; + }, + + toJSON(message: DecProto): unknown { + const obj: any = {}; + message.dec !== undefined && (obj.dec = message.dec); + return obj; + }, + + fromPartial(object: DeepPartial): DecProto { + const message = { ...baseDecProto } as DecProto; + if (object.dec !== undefined && object.dec !== null) { + message.dec = object.dec; + } else { + message.dec = ""; + } + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/bze.tokenfactory.v1/types/cosmos_proto/cosmos.ts b/ts-client/bze.tokenfactory.v1/types/cosmos_proto/cosmos.ts new file mode 100644 index 00000000..9ec67a12 --- /dev/null +++ b/ts-client/bze.tokenfactory.v1/types/cosmos_proto/cosmos.ts @@ -0,0 +1,2 @@ +/* eslint-disable */ +export const protobufPackage = "cosmos_proto"; diff --git a/ts-client/bze.tokenfactory.v1/types/gogoproto/gogo.ts b/ts-client/bze.tokenfactory.v1/types/gogoproto/gogo.ts new file mode 100644 index 00000000..3f41a047 --- /dev/null +++ b/ts-client/bze.tokenfactory.v1/types/gogoproto/gogo.ts @@ -0,0 +1,2 @@ +/* eslint-disable */ +export const protobufPackage = "gogoproto"; diff --git a/ts-client/bze.tokenfactory.v1/types/google/api/annotations.ts b/ts-client/bze.tokenfactory.v1/types/google/api/annotations.ts new file mode 100644 index 00000000..aace4787 --- /dev/null +++ b/ts-client/bze.tokenfactory.v1/types/google/api/annotations.ts @@ -0,0 +1,2 @@ +/* eslint-disable */ +export const protobufPackage = "google.api"; diff --git a/ts-client/bze.tokenfactory.v1/types/google/api/http.ts b/ts-client/bze.tokenfactory.v1/types/google/api/http.ts new file mode 100644 index 00000000..ddc00f8b --- /dev/null +++ b/ts-client/bze.tokenfactory.v1/types/google/api/http.ts @@ -0,0 +1,705 @@ +/* eslint-disable */ +import { Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "google.api"; + +/** + * Defines the HTTP configuration for an API service. It contains a list of + * [HttpRule][google.api.HttpRule], each specifying the mapping of an RPC method + * to one or more HTTP REST API methods. + */ +export interface Http { + /** + * A list of HTTP configuration rules that apply to individual API methods. + * + * **NOTE:** All service configuration rules follow "last one wins" order. + */ + rules: HttpRule[]; + /** + * When set to true, URL path parmeters will be fully URI-decoded except in + * cases of single segment matches in reserved expansion, where "%2F" will be + * left encoded. + * + * The default behavior is to not decode RFC 6570 reserved characters in multi + * segment matches. + */ + fullyDecodeReservedExpansion: boolean; +} + +/** + * `HttpRule` defines the mapping of an RPC method to one or more HTTP + * REST API methods. The mapping specifies how different portions of the RPC + * request message are mapped to URL path, URL query parameters, and + * HTTP request body. The mapping is typically specified as an + * `google.api.http` annotation on the RPC method, + * see "google/api/annotations.proto" for details. + * + * The mapping consists of a field specifying the path template and + * method kind. The path template can refer to fields in the request + * message, as in the example below which describes a REST GET + * operation on a resource collection of messages: + * + * + * service Messaging { + * rpc GetMessage(GetMessageRequest) returns (Message) { + * option (google.api.http).get = "/v1/messages/{message_id}/{sub.subfield}"; + * } + * } + * message GetMessageRequest { + * message SubMessage { + * string subfield = 1; + * } + * string message_id = 1; // mapped to the URL + * SubMessage sub = 2; // `sub.subfield` is url-mapped + * } + * message Message { + * string text = 1; // content of the resource + * } + * + * The same http annotation can alternatively be expressed inside the + * `GRPC API Configuration` YAML file. + * + * http: + * rules: + * - selector: .Messaging.GetMessage + * get: /v1/messages/{message_id}/{sub.subfield} + * + * This definition enables an automatic, bidrectional mapping of HTTP + * JSON to RPC. Example: + * + * HTTP | RPC + * -----|----- + * `GET /v1/messages/123456/foo` | `GetMessage(message_id: "123456" sub: SubMessage(subfield: "foo"))` + * + * In general, not only fields but also field paths can be referenced + * from a path pattern. Fields mapped to the path pattern cannot be + * repeated and must have a primitive (non-message) type. + * + * Any fields in the request message which are not bound by the path + * pattern automatically become (optional) HTTP query + * parameters. Assume the following definition of the request message: + * + * + * service Messaging { + * rpc GetMessage(GetMessageRequest) returns (Message) { + * option (google.api.http).get = "/v1/messages/{message_id}"; + * } + * } + * message GetMessageRequest { + * message SubMessage { + * string subfield = 1; + * } + * string message_id = 1; // mapped to the URL + * int64 revision = 2; // becomes a parameter + * SubMessage sub = 3; // `sub.subfield` becomes a parameter + * } + * + * + * This enables a HTTP JSON to RPC mapping as below: + * + * HTTP | RPC + * -----|----- + * `GET /v1/messages/123456?revision=2&sub.subfield=foo` | `GetMessage(message_id: "123456" revision: 2 sub: SubMessage(subfield: "foo"))` + * + * Note that fields which are mapped to HTTP parameters must have a + * primitive type or a repeated primitive type. Message types are not + * allowed. In the case of a repeated type, the parameter can be + * repeated in the URL, as in `...?param=A¶m=B`. + * + * For HTTP method kinds which allow a request body, the `body` field + * specifies the mapping. Consider a REST update method on the + * message resource collection: + * + * + * service Messaging { + * rpc UpdateMessage(UpdateMessageRequest) returns (Message) { + * option (google.api.http) = { + * put: "/v1/messages/{message_id}" + * body: "message" + * }; + * } + * } + * message UpdateMessageRequest { + * string message_id = 1; // mapped to the URL + * Message message = 2; // mapped to the body + * } + * + * + * The following HTTP JSON to RPC mapping is enabled, where the + * representation of the JSON in the request body is determined by + * protos JSON encoding: + * + * HTTP | RPC + * -----|----- + * `PUT /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: "123456" message { text: "Hi!" })` + * + * The special name `*` can be used in the body mapping to define that + * every field not bound by the path template should be mapped to the + * request body. This enables the following alternative definition of + * the update method: + * + * service Messaging { + * rpc UpdateMessage(Message) returns (Message) { + * option (google.api.http) = { + * put: "/v1/messages/{message_id}" + * body: "*" + * }; + * } + * } + * message Message { + * string message_id = 1; + * string text = 2; + * } + * + * + * The following HTTP JSON to RPC mapping is enabled: + * + * HTTP | RPC + * -----|----- + * `PUT /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: "123456" text: "Hi!")` + * + * Note that when using `*` in the body mapping, it is not possible to + * have HTTP parameters, as all fields not bound by the path end in + * the body. This makes this option more rarely used in practice of + * defining REST APIs. The common usage of `*` is in custom methods + * which don't use the URL at all for transferring data. + * + * It is possible to define multiple HTTP methods for one RPC by using + * the `additional_bindings` option. Example: + * + * service Messaging { + * rpc GetMessage(GetMessageRequest) returns (Message) { + * option (google.api.http) = { + * get: "/v1/messages/{message_id}" + * additional_bindings { + * get: "/v1/users/{user_id}/messages/{message_id}" + * } + * }; + * } + * } + * message GetMessageRequest { + * string message_id = 1; + * string user_id = 2; + * } + * + * + * This enables the following two alternative HTTP JSON to RPC + * mappings: + * + * HTTP | RPC + * -----|----- + * `GET /v1/messages/123456` | `GetMessage(message_id: "123456")` + * `GET /v1/users/me/messages/123456` | `GetMessage(user_id: "me" message_id: "123456")` + * + * # Rules for HTTP mapping + * + * The rules for mapping HTTP path, query parameters, and body fields + * to the request message are as follows: + * + * 1. The `body` field specifies either `*` or a field path, or is + * omitted. If omitted, it indicates there is no HTTP request body. + * 2. Leaf fields (recursive expansion of nested messages in the + * request) can be classified into three types: + * (a) Matched in the URL template. + * (b) Covered by body (if body is `*`, everything except (a) fields; + * else everything under the body field) + * (c) All other fields. + * 3. URL query parameters found in the HTTP request are mapped to (c) fields. + * 4. Any body sent with an HTTP request can contain only (b) fields. + * + * The syntax of the path template is as follows: + * + * Template = "/" Segments [ Verb ] ; + * Segments = Segment { "/" Segment } ; + * Segment = "*" | "**" | LITERAL | Variable ; + * Variable = "{" FieldPath [ "=" Segments ] "}" ; + * FieldPath = IDENT { "." IDENT } ; + * Verb = ":" LITERAL ; + * + * The syntax `*` matches a single path segment. The syntax `**` matches zero + * or more path segments, which must be the last part of the path except the + * `Verb`. The syntax `LITERAL` matches literal text in the path. + * + * The syntax `Variable` matches part of the URL path as specified by its + * template. A variable template must not contain other variables. If a variable + * matches a single path segment, its template may be omitted, e.g. `{var}` + * is equivalent to `{var=*}`. + * + * If a variable contains exactly one path segment, such as `"{var}"` or + * `"{var=*}"`, when such a variable is expanded into a URL path, all characters + * except `[-_.~0-9a-zA-Z]` are percent-encoded. Such variables show up in the + * Discovery Document as `{var}`. + * + * If a variable contains one or more path segments, such as `"{var=foo/*}"` + * or `"{var=**}"`, when such a variable is expanded into a URL path, all + * characters except `[-_.~/0-9a-zA-Z]` are percent-encoded. Such variables + * show up in the Discovery Document as `{+var}`. + * + * NOTE: While the single segment variable matches the semantics of + * [RFC 6570](https://tools.ietf.org/html/rfc6570) Section 3.2.2 + * Simple String Expansion, the multi segment variable **does not** match + * RFC 6570 Reserved Expansion. The reason is that the Reserved Expansion + * does not expand special characters like `?` and `#`, which would lead + * to invalid URLs. + * + * NOTE: the field paths in variables and in the `body` must not refer to + * repeated fields or map fields. + */ +export interface HttpRule { + /** + * Selects methods to which this rule applies. + * + * Refer to [selector][google.api.DocumentationRule.selector] for syntax details. + */ + selector: string; + /** Used for listing and getting information about resources. */ + get: string | undefined; + /** Used for updating a resource. */ + put: string | undefined; + /** Used for creating a resource. */ + post: string | undefined; + /** Used for deleting a resource. */ + delete: string | undefined; + /** Used for updating a resource. */ + patch: string | undefined; + /** + * The custom pattern is used for specifying an HTTP method that is not + * included in the `pattern` field, such as HEAD, or "*" to leave the + * HTTP method unspecified for this rule. The wild-card rule is useful + * for services that provide content to Web (HTML) clients. + */ + custom: CustomHttpPattern | undefined; + /** + * The name of the request field whose value is mapped to the HTTP body, or + * `*` for mapping all fields not captured by the path pattern to the HTTP + * body. NOTE: the referred field must not be a repeated field and must be + * present at the top-level of request message type. + */ + body: string; + /** + * Optional. The name of the response field whose value is mapped to the HTTP + * body of response. Other response fields are ignored. When + * not set, the response message will be used as HTTP body of response. + */ + responseBody: string; + /** + * Additional HTTP bindings for the selector. Nested bindings must + * not contain an `additional_bindings` field themselves (that is, + * the nesting may only be one level deep). + */ + additionalBindings: HttpRule[]; +} + +/** A custom pattern is used for defining custom HTTP verb. */ +export interface CustomHttpPattern { + /** The name of this custom HTTP verb. */ + kind: string; + /** The path matched by this custom verb. */ + path: string; +} + +const baseHttp: object = { fullyDecodeReservedExpansion: false }; + +export const Http = { + encode(message: Http, writer: Writer = Writer.create()): Writer { + for (const v of message.rules) { + HttpRule.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.fullyDecodeReservedExpansion === true) { + writer.uint32(16).bool(message.fullyDecodeReservedExpansion); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Http { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseHttp } as Http; + message.rules = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.rules.push(HttpRule.decode(reader, reader.uint32())); + break; + case 2: + message.fullyDecodeReservedExpansion = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Http { + const message = { ...baseHttp } as Http; + message.rules = []; + if (object.rules !== undefined && object.rules !== null) { + for (const e of object.rules) { + message.rules.push(HttpRule.fromJSON(e)); + } + } + if ( + object.fullyDecodeReservedExpansion !== undefined && + object.fullyDecodeReservedExpansion !== null + ) { + message.fullyDecodeReservedExpansion = Boolean( + object.fullyDecodeReservedExpansion + ); + } else { + message.fullyDecodeReservedExpansion = false; + } + return message; + }, + + toJSON(message: Http): unknown { + const obj: any = {}; + if (message.rules) { + obj.rules = message.rules.map((e) => + e ? HttpRule.toJSON(e) : undefined + ); + } else { + obj.rules = []; + } + message.fullyDecodeReservedExpansion !== undefined && + (obj.fullyDecodeReservedExpansion = message.fullyDecodeReservedExpansion); + return obj; + }, + + fromPartial(object: DeepPartial): Http { + const message = { ...baseHttp } as Http; + message.rules = []; + if (object.rules !== undefined && object.rules !== null) { + for (const e of object.rules) { + message.rules.push(HttpRule.fromPartial(e)); + } + } + if ( + object.fullyDecodeReservedExpansion !== undefined && + object.fullyDecodeReservedExpansion !== null + ) { + message.fullyDecodeReservedExpansion = + object.fullyDecodeReservedExpansion; + } else { + message.fullyDecodeReservedExpansion = false; + } + return message; + }, +}; + +const baseHttpRule: object = { selector: "", body: "", responseBody: "" }; + +export const HttpRule = { + encode(message: HttpRule, writer: Writer = Writer.create()): Writer { + if (message.selector !== "") { + writer.uint32(10).string(message.selector); + } + if (message.get !== undefined) { + writer.uint32(18).string(message.get); + } + if (message.put !== undefined) { + writer.uint32(26).string(message.put); + } + if (message.post !== undefined) { + writer.uint32(34).string(message.post); + } + if (message.delete !== undefined) { + writer.uint32(42).string(message.delete); + } + if (message.patch !== undefined) { + writer.uint32(50).string(message.patch); + } + if (message.custom !== undefined) { + CustomHttpPattern.encode( + message.custom, + writer.uint32(66).fork() + ).ldelim(); + } + if (message.body !== "") { + writer.uint32(58).string(message.body); + } + if (message.responseBody !== "") { + writer.uint32(98).string(message.responseBody); + } + for (const v of message.additionalBindings) { + HttpRule.encode(v!, writer.uint32(90).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): HttpRule { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseHttpRule } as HttpRule; + message.additionalBindings = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.selector = reader.string(); + break; + case 2: + message.get = reader.string(); + break; + case 3: + message.put = reader.string(); + break; + case 4: + message.post = reader.string(); + break; + case 5: + message.delete = reader.string(); + break; + case 6: + message.patch = reader.string(); + break; + case 8: + message.custom = CustomHttpPattern.decode(reader, reader.uint32()); + break; + case 7: + message.body = reader.string(); + break; + case 12: + message.responseBody = reader.string(); + break; + case 11: + message.additionalBindings.push( + HttpRule.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): HttpRule { + const message = { ...baseHttpRule } as HttpRule; + message.additionalBindings = []; + if (object.selector !== undefined && object.selector !== null) { + message.selector = String(object.selector); + } else { + message.selector = ""; + } + if (object.get !== undefined && object.get !== null) { + message.get = String(object.get); + } else { + message.get = undefined; + } + if (object.put !== undefined && object.put !== null) { + message.put = String(object.put); + } else { + message.put = undefined; + } + if (object.post !== undefined && object.post !== null) { + message.post = String(object.post); + } else { + message.post = undefined; + } + if (object.delete !== undefined && object.delete !== null) { + message.delete = String(object.delete); + } else { + message.delete = undefined; + } + if (object.patch !== undefined && object.patch !== null) { + message.patch = String(object.patch); + } else { + message.patch = undefined; + } + if (object.custom !== undefined && object.custom !== null) { + message.custom = CustomHttpPattern.fromJSON(object.custom); + } else { + message.custom = undefined; + } + if (object.body !== undefined && object.body !== null) { + message.body = String(object.body); + } else { + message.body = ""; + } + if (object.responseBody !== undefined && object.responseBody !== null) { + message.responseBody = String(object.responseBody); + } else { + message.responseBody = ""; + } + if ( + object.additionalBindings !== undefined && + object.additionalBindings !== null + ) { + for (const e of object.additionalBindings) { + message.additionalBindings.push(HttpRule.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: HttpRule): unknown { + const obj: any = {}; + message.selector !== undefined && (obj.selector = message.selector); + message.get !== undefined && (obj.get = message.get); + message.put !== undefined && (obj.put = message.put); + message.post !== undefined && (obj.post = message.post); + message.delete !== undefined && (obj.delete = message.delete); + message.patch !== undefined && (obj.patch = message.patch); + message.custom !== undefined && + (obj.custom = message.custom + ? CustomHttpPattern.toJSON(message.custom) + : undefined); + message.body !== undefined && (obj.body = message.body); + message.responseBody !== undefined && + (obj.responseBody = message.responseBody); + if (message.additionalBindings) { + obj.additionalBindings = message.additionalBindings.map((e) => + e ? HttpRule.toJSON(e) : undefined + ); + } else { + obj.additionalBindings = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): HttpRule { + const message = { ...baseHttpRule } as HttpRule; + message.additionalBindings = []; + if (object.selector !== undefined && object.selector !== null) { + message.selector = object.selector; + } else { + message.selector = ""; + } + if (object.get !== undefined && object.get !== null) { + message.get = object.get; + } else { + message.get = undefined; + } + if (object.put !== undefined && object.put !== null) { + message.put = object.put; + } else { + message.put = undefined; + } + if (object.post !== undefined && object.post !== null) { + message.post = object.post; + } else { + message.post = undefined; + } + if (object.delete !== undefined && object.delete !== null) { + message.delete = object.delete; + } else { + message.delete = undefined; + } + if (object.patch !== undefined && object.patch !== null) { + message.patch = object.patch; + } else { + message.patch = undefined; + } + if (object.custom !== undefined && object.custom !== null) { + message.custom = CustomHttpPattern.fromPartial(object.custom); + } else { + message.custom = undefined; + } + if (object.body !== undefined && object.body !== null) { + message.body = object.body; + } else { + message.body = ""; + } + if (object.responseBody !== undefined && object.responseBody !== null) { + message.responseBody = object.responseBody; + } else { + message.responseBody = ""; + } + if ( + object.additionalBindings !== undefined && + object.additionalBindings !== null + ) { + for (const e of object.additionalBindings) { + message.additionalBindings.push(HttpRule.fromPartial(e)); + } + } + return message; + }, +}; + +const baseCustomHttpPattern: object = { kind: "", path: "" }; + +export const CustomHttpPattern = { + encode(message: CustomHttpPattern, writer: Writer = Writer.create()): Writer { + if (message.kind !== "") { + writer.uint32(10).string(message.kind); + } + if (message.path !== "") { + writer.uint32(18).string(message.path); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): CustomHttpPattern { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseCustomHttpPattern } as CustomHttpPattern; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.kind = reader.string(); + break; + case 2: + message.path = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): CustomHttpPattern { + const message = { ...baseCustomHttpPattern } as CustomHttpPattern; + if (object.kind !== undefined && object.kind !== null) { + message.kind = String(object.kind); + } else { + message.kind = ""; + } + if (object.path !== undefined && object.path !== null) { + message.path = String(object.path); + } else { + message.path = ""; + } + return message; + }, + + toJSON(message: CustomHttpPattern): unknown { + const obj: any = {}; + message.kind !== undefined && (obj.kind = message.kind); + message.path !== undefined && (obj.path = message.path); + return obj; + }, + + fromPartial(object: DeepPartial): CustomHttpPattern { + const message = { ...baseCustomHttpPattern } as CustomHttpPattern; + if (object.kind !== undefined && object.kind !== null) { + message.kind = object.kind; + } else { + message.kind = ""; + } + if (object.path !== undefined && object.path !== null) { + message.path = object.path; + } else { + message.path = ""; + } + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/bze.tokenfactory.v1/types/google/protobuf/descriptor.ts b/ts-client/bze.tokenfactory.v1/types/google/protobuf/descriptor.ts new file mode 100644 index 00000000..9e508660 --- /dev/null +++ b/ts-client/bze.tokenfactory.v1/types/google/protobuf/descriptor.ts @@ -0,0 +1,5261 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "google.protobuf"; + +/** + * The protocol compiler can output a FileDescriptorSet containing the .proto + * files it parses. + */ +export interface FileDescriptorSet { + file: FileDescriptorProto[]; +} + +/** Describes a complete .proto file. */ +export interface FileDescriptorProto { + /** file name, relative to root of source tree */ + name: string; + /** e.g. "foo", "foo.bar", etc. */ + package: string; + /** Names of files imported by this file. */ + dependency: string[]; + /** Indexes of the public imported files in the dependency list above. */ + publicDependency: number[]; + /** + * Indexes of the weak imported files in the dependency list. + * For Google-internal migration only. Do not use. + */ + weakDependency: number[]; + /** All top-level definitions in this file. */ + messageType: DescriptorProto[]; + enumType: EnumDescriptorProto[]; + service: ServiceDescriptorProto[]; + extension: FieldDescriptorProto[]; + options: FileOptions | undefined; + /** + * This field contains optional information about the original source code. + * You may safely remove this entire field without harming runtime + * functionality of the descriptors -- the information is needed only by + * development tools. + */ + sourceCodeInfo: SourceCodeInfo | undefined; + /** + * The syntax of the proto file. + * The supported values are "proto2" and "proto3". + */ + syntax: string; +} + +/** Describes a message type. */ +export interface DescriptorProto { + name: string; + field: FieldDescriptorProto[]; + extension: FieldDescriptorProto[]; + nestedType: DescriptorProto[]; + enumType: EnumDescriptorProto[]; + extensionRange: DescriptorProto_ExtensionRange[]; + oneofDecl: OneofDescriptorProto[]; + options: MessageOptions | undefined; + reservedRange: DescriptorProto_ReservedRange[]; + /** + * Reserved field names, which may not be used by fields in the same message. + * A given name may only be reserved once. + */ + reservedName: string[]; +} + +export interface DescriptorProto_ExtensionRange { + /** Inclusive. */ + start: number; + /** Exclusive. */ + end: number; + options: ExtensionRangeOptions | undefined; +} + +/** + * Range of reserved tag numbers. Reserved tag numbers may not be used by + * fields or extension ranges in the same message. Reserved ranges may + * not overlap. + */ +export interface DescriptorProto_ReservedRange { + /** Inclusive. */ + start: number; + /** Exclusive. */ + end: number; +} + +export interface ExtensionRangeOptions { + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +/** Describes a field within a message. */ +export interface FieldDescriptorProto { + name: string; + number: number; + label: FieldDescriptorProto_Label; + /** + * If type_name is set, this need not be set. If both this and type_name + * are set, this must be one of TYPE_ENUM, TYPE_MESSAGE or TYPE_GROUP. + */ + type: FieldDescriptorProto_Type; + /** + * For message and enum types, this is the name of the type. If the name + * starts with a '.', it is fully-qualified. Otherwise, C++-like scoping + * rules are used to find the type (i.e. first the nested types within this + * message are searched, then within the parent, on up to the root + * namespace). + */ + typeName: string; + /** + * For extensions, this is the name of the type being extended. It is + * resolved in the same manner as type_name. + */ + extendee: string; + /** + * For numeric types, contains the original text representation of the value. + * For booleans, "true" or "false". + * For strings, contains the default text contents (not escaped in any way). + * For bytes, contains the C escaped value. All bytes >= 128 are escaped. + * TODO(kenton): Base-64 encode? + */ + defaultValue: string; + /** + * If set, gives the index of a oneof in the containing type's oneof_decl + * list. This field is a member of that oneof. + */ + oneofIndex: number; + /** + * JSON name of this field. The value is set by protocol compiler. If the + * user has set a "json_name" option on this field, that option's value + * will be used. Otherwise, it's deduced from the field's name by converting + * it to camelCase. + */ + jsonName: string; + options: FieldOptions | undefined; + /** + * If true, this is a proto3 "optional". When a proto3 field is optional, it + * tracks presence regardless of field type. + * + * When proto3_optional is true, this field must be belong to a oneof to + * signal to old proto3 clients that presence is tracked for this field. This + * oneof is known as a "synthetic" oneof, and this field must be its sole + * member (each proto3 optional field gets its own synthetic oneof). Synthetic + * oneofs exist in the descriptor only, and do not generate any API. Synthetic + * oneofs must be ordered after all "real" oneofs. + * + * For message fields, proto3_optional doesn't create any semantic change, + * since non-repeated message fields always track presence. However it still + * indicates the semantic detail of whether the user wrote "optional" or not. + * This can be useful for round-tripping the .proto file. For consistency we + * give message fields a synthetic oneof also, even though it is not required + * to track presence. This is especially important because the parser can't + * tell if a field is a message or an enum, so it must always create a + * synthetic oneof. + * + * Proto2 optional fields do not set this flag, because they already indicate + * optional with `LABEL_OPTIONAL`. + */ + proto3Optional: boolean; +} + +export enum FieldDescriptorProto_Type { + /** + * TYPE_DOUBLE - 0 is reserved for errors. + * Order is weird for historical reasons. + */ + TYPE_DOUBLE = 1, + TYPE_FLOAT = 2, + /** + * TYPE_INT64 - Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT64 if + * negative values are likely. + */ + TYPE_INT64 = 3, + TYPE_UINT64 = 4, + /** + * TYPE_INT32 - Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT32 if + * negative values are likely. + */ + TYPE_INT32 = 5, + TYPE_FIXED64 = 6, + TYPE_FIXED32 = 7, + TYPE_BOOL = 8, + TYPE_STRING = 9, + /** + * TYPE_GROUP - Tag-delimited aggregate. + * Group type is deprecated and not supported in proto3. However, Proto3 + * implementations should still be able to parse the group wire format and + * treat group fields as unknown fields. + */ + TYPE_GROUP = 10, + /** TYPE_MESSAGE - Length-delimited aggregate. */ + TYPE_MESSAGE = 11, + /** TYPE_BYTES - New in version 2. */ + TYPE_BYTES = 12, + TYPE_UINT32 = 13, + TYPE_ENUM = 14, + TYPE_SFIXED32 = 15, + TYPE_SFIXED64 = 16, + /** TYPE_SINT32 - Uses ZigZag encoding. */ + TYPE_SINT32 = 17, + /** TYPE_SINT64 - Uses ZigZag encoding. */ + TYPE_SINT64 = 18, + UNRECOGNIZED = -1, +} + +export function fieldDescriptorProto_TypeFromJSON( + object: any +): FieldDescriptorProto_Type { + switch (object) { + case 1: + case "TYPE_DOUBLE": + return FieldDescriptorProto_Type.TYPE_DOUBLE; + case 2: + case "TYPE_FLOAT": + return FieldDescriptorProto_Type.TYPE_FLOAT; + case 3: + case "TYPE_INT64": + return FieldDescriptorProto_Type.TYPE_INT64; + case 4: + case "TYPE_UINT64": + return FieldDescriptorProto_Type.TYPE_UINT64; + case 5: + case "TYPE_INT32": + return FieldDescriptorProto_Type.TYPE_INT32; + case 6: + case "TYPE_FIXED64": + return FieldDescriptorProto_Type.TYPE_FIXED64; + case 7: + case "TYPE_FIXED32": + return FieldDescriptorProto_Type.TYPE_FIXED32; + case 8: + case "TYPE_BOOL": + return FieldDescriptorProto_Type.TYPE_BOOL; + case 9: + case "TYPE_STRING": + return FieldDescriptorProto_Type.TYPE_STRING; + case 10: + case "TYPE_GROUP": + return FieldDescriptorProto_Type.TYPE_GROUP; + case 11: + case "TYPE_MESSAGE": + return FieldDescriptorProto_Type.TYPE_MESSAGE; + case 12: + case "TYPE_BYTES": + return FieldDescriptorProto_Type.TYPE_BYTES; + case 13: + case "TYPE_UINT32": + return FieldDescriptorProto_Type.TYPE_UINT32; + case 14: + case "TYPE_ENUM": + return FieldDescriptorProto_Type.TYPE_ENUM; + case 15: + case "TYPE_SFIXED32": + return FieldDescriptorProto_Type.TYPE_SFIXED32; + case 16: + case "TYPE_SFIXED64": + return FieldDescriptorProto_Type.TYPE_SFIXED64; + case 17: + case "TYPE_SINT32": + return FieldDescriptorProto_Type.TYPE_SINT32; + case 18: + case "TYPE_SINT64": + return FieldDescriptorProto_Type.TYPE_SINT64; + case -1: + case "UNRECOGNIZED": + default: + return FieldDescriptorProto_Type.UNRECOGNIZED; + } +} + +export function fieldDescriptorProto_TypeToJSON( + object: FieldDescriptorProto_Type +): string { + switch (object) { + case FieldDescriptorProto_Type.TYPE_DOUBLE: + return "TYPE_DOUBLE"; + case FieldDescriptorProto_Type.TYPE_FLOAT: + return "TYPE_FLOAT"; + case FieldDescriptorProto_Type.TYPE_INT64: + return "TYPE_INT64"; + case FieldDescriptorProto_Type.TYPE_UINT64: + return "TYPE_UINT64"; + case FieldDescriptorProto_Type.TYPE_INT32: + return "TYPE_INT32"; + case FieldDescriptorProto_Type.TYPE_FIXED64: + return "TYPE_FIXED64"; + case FieldDescriptorProto_Type.TYPE_FIXED32: + return "TYPE_FIXED32"; + case FieldDescriptorProto_Type.TYPE_BOOL: + return "TYPE_BOOL"; + case FieldDescriptorProto_Type.TYPE_STRING: + return "TYPE_STRING"; + case FieldDescriptorProto_Type.TYPE_GROUP: + return "TYPE_GROUP"; + case FieldDescriptorProto_Type.TYPE_MESSAGE: + return "TYPE_MESSAGE"; + case FieldDescriptorProto_Type.TYPE_BYTES: + return "TYPE_BYTES"; + case FieldDescriptorProto_Type.TYPE_UINT32: + return "TYPE_UINT32"; + case FieldDescriptorProto_Type.TYPE_ENUM: + return "TYPE_ENUM"; + case FieldDescriptorProto_Type.TYPE_SFIXED32: + return "TYPE_SFIXED32"; + case FieldDescriptorProto_Type.TYPE_SFIXED64: + return "TYPE_SFIXED64"; + case FieldDescriptorProto_Type.TYPE_SINT32: + return "TYPE_SINT32"; + case FieldDescriptorProto_Type.TYPE_SINT64: + return "TYPE_SINT64"; + default: + return "UNKNOWN"; + } +} + +export enum FieldDescriptorProto_Label { + /** LABEL_OPTIONAL - 0 is reserved for errors */ + LABEL_OPTIONAL = 1, + LABEL_REQUIRED = 2, + LABEL_REPEATED = 3, + UNRECOGNIZED = -1, +} + +export function fieldDescriptorProto_LabelFromJSON( + object: any +): FieldDescriptorProto_Label { + switch (object) { + case 1: + case "LABEL_OPTIONAL": + return FieldDescriptorProto_Label.LABEL_OPTIONAL; + case 2: + case "LABEL_REQUIRED": + return FieldDescriptorProto_Label.LABEL_REQUIRED; + case 3: + case "LABEL_REPEATED": + return FieldDescriptorProto_Label.LABEL_REPEATED; + case -1: + case "UNRECOGNIZED": + default: + return FieldDescriptorProto_Label.UNRECOGNIZED; + } +} + +export function fieldDescriptorProto_LabelToJSON( + object: FieldDescriptorProto_Label +): string { + switch (object) { + case FieldDescriptorProto_Label.LABEL_OPTIONAL: + return "LABEL_OPTIONAL"; + case FieldDescriptorProto_Label.LABEL_REQUIRED: + return "LABEL_REQUIRED"; + case FieldDescriptorProto_Label.LABEL_REPEATED: + return "LABEL_REPEATED"; + default: + return "UNKNOWN"; + } +} + +/** Describes a oneof. */ +export interface OneofDescriptorProto { + name: string; + options: OneofOptions | undefined; +} + +/** Describes an enum type. */ +export interface EnumDescriptorProto { + name: string; + value: EnumValueDescriptorProto[]; + options: EnumOptions | undefined; + /** + * Range of reserved numeric values. Reserved numeric values may not be used + * by enum values in the same enum declaration. Reserved ranges may not + * overlap. + */ + reservedRange: EnumDescriptorProto_EnumReservedRange[]; + /** + * Reserved enum value names, which may not be reused. A given name may only + * be reserved once. + */ + reservedName: string[]; +} + +/** + * Range of reserved numeric values. Reserved values may not be used by + * entries in the same enum. Reserved ranges may not overlap. + * + * Note that this is distinct from DescriptorProto.ReservedRange in that it + * is inclusive such that it can appropriately represent the entire int32 + * domain. + */ +export interface EnumDescriptorProto_EnumReservedRange { + /** Inclusive. */ + start: number; + /** Inclusive. */ + end: number; +} + +/** Describes a value within an enum. */ +export interface EnumValueDescriptorProto { + name: string; + number: number; + options: EnumValueOptions | undefined; +} + +/** Describes a service. */ +export interface ServiceDescriptorProto { + name: string; + method: MethodDescriptorProto[]; + options: ServiceOptions | undefined; +} + +/** Describes a method of a service. */ +export interface MethodDescriptorProto { + name: string; + /** + * Input and output type names. These are resolved in the same way as + * FieldDescriptorProto.type_name, but must refer to a message type. + */ + inputType: string; + outputType: string; + options: MethodOptions | undefined; + /** Identifies if client streams multiple client messages */ + clientStreaming: boolean; + /** Identifies if server streams multiple server messages */ + serverStreaming: boolean; +} + +export interface FileOptions { + /** + * Sets the Java package where classes generated from this .proto will be + * placed. By default, the proto package is used, but this is often + * inappropriate because proto packages do not normally start with backwards + * domain names. + */ + javaPackage: string; + /** + * Controls the name of the wrapper Java class generated for the .proto file. + * That class will always contain the .proto file's getDescriptor() method as + * well as any top-level extensions defined in the .proto file. + * If java_multiple_files is disabled, then all the other classes from the + * .proto file will be nested inside the single wrapper outer class. + */ + javaOuterClassname: string; + /** + * If enabled, then the Java code generator will generate a separate .java + * file for each top-level message, enum, and service defined in the .proto + * file. Thus, these types will *not* be nested inside the wrapper class + * named by java_outer_classname. However, the wrapper class will still be + * generated to contain the file's getDescriptor() method as well as any + * top-level extensions defined in the file. + */ + javaMultipleFiles: boolean; + /** + * This option does nothing. + * + * @deprecated + */ + javaGenerateEqualsAndHash: boolean; + /** + * If set true, then the Java2 code generator will generate code that + * throws an exception whenever an attempt is made to assign a non-UTF-8 + * byte sequence to a string field. + * Message reflection will do the same. + * However, an extension field still accepts non-UTF-8 byte sequences. + * This option has no effect on when used with the lite runtime. + */ + javaStringCheckUtf8: boolean; + optimizeFor: FileOptions_OptimizeMode; + /** + * Sets the Go package where structs generated from this .proto will be + * placed. If omitted, the Go package will be derived from the following: + * - The basename of the package import path, if provided. + * - Otherwise, the package statement in the .proto file, if present. + * - Otherwise, the basename of the .proto file, without extension. + */ + goPackage: string; + /** + * Should generic services be generated in each language? "Generic" services + * are not specific to any particular RPC system. They are generated by the + * main code generators in each language (without additional plugins). + * Generic services were the only kind of service generation supported by + * early versions of google.protobuf. + * + * Generic services are now considered deprecated in favor of using plugins + * that generate code specific to your particular RPC system. Therefore, + * these default to false. Old code which depends on generic services should + * explicitly set them to true. + */ + ccGenericServices: boolean; + javaGenericServices: boolean; + pyGenericServices: boolean; + phpGenericServices: boolean; + /** + * Is this file deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for everything in the file, or it will be completely ignored; in the very + * least, this is a formalization for deprecating files. + */ + deprecated: boolean; + /** + * Enables the use of arenas for the proto messages in this file. This applies + * only to generated classes for C++. + */ + ccEnableArenas: boolean; + /** + * Sets the objective c class prefix which is prepended to all objective c + * generated classes from this .proto. There is no default. + */ + objcClassPrefix: string; + /** Namespace for generated classes; defaults to the package. */ + csharpNamespace: string; + /** + * By default Swift generators will take the proto package and CamelCase it + * replacing '.' with underscore and use that to prefix the types/symbols + * defined. When this options is provided, they will use this value instead + * to prefix the types/symbols defined. + */ + swiftPrefix: string; + /** + * Sets the php class prefix which is prepended to all php generated classes + * from this .proto. Default is empty. + */ + phpClassPrefix: string; + /** + * Use this option to change the namespace of php generated classes. Default + * is empty. When this option is empty, the package name will be used for + * determining the namespace. + */ + phpNamespace: string; + /** + * Use this option to change the namespace of php generated metadata classes. + * Default is empty. When this option is empty, the proto file name will be + * used for determining the namespace. + */ + phpMetadataNamespace: string; + /** + * Use this option to change the package of ruby generated classes. Default + * is empty. When this option is not set, the package name will be used for + * determining the ruby package. + */ + rubyPackage: string; + /** + * The parser stores options it doesn't recognize here. + * See the documentation for the "Options" section above. + */ + uninterpretedOption: UninterpretedOption[]; +} + +/** Generated classes can be optimized for speed or code size. */ +export enum FileOptions_OptimizeMode { + /** SPEED - Generate complete code for parsing, serialization, */ + SPEED = 1, + /** CODE_SIZE - etc. */ + CODE_SIZE = 2, + /** LITE_RUNTIME - Generate code using MessageLite and the lite runtime. */ + LITE_RUNTIME = 3, + UNRECOGNIZED = -1, +} + +export function fileOptions_OptimizeModeFromJSON( + object: any +): FileOptions_OptimizeMode { + switch (object) { + case 1: + case "SPEED": + return FileOptions_OptimizeMode.SPEED; + case 2: + case "CODE_SIZE": + return FileOptions_OptimizeMode.CODE_SIZE; + case 3: + case "LITE_RUNTIME": + return FileOptions_OptimizeMode.LITE_RUNTIME; + case -1: + case "UNRECOGNIZED": + default: + return FileOptions_OptimizeMode.UNRECOGNIZED; + } +} + +export function fileOptions_OptimizeModeToJSON( + object: FileOptions_OptimizeMode +): string { + switch (object) { + case FileOptions_OptimizeMode.SPEED: + return "SPEED"; + case FileOptions_OptimizeMode.CODE_SIZE: + return "CODE_SIZE"; + case FileOptions_OptimizeMode.LITE_RUNTIME: + return "LITE_RUNTIME"; + default: + return "UNKNOWN"; + } +} + +export interface MessageOptions { + /** + * Set true to use the old proto1 MessageSet wire format for extensions. + * This is provided for backwards-compatibility with the MessageSet wire + * format. You should not use this for any other reason: It's less + * efficient, has fewer features, and is more complicated. + * + * The message must be defined exactly as follows: + * message Foo { + * option message_set_wire_format = true; + * extensions 4 to max; + * } + * Note that the message cannot have any defined fields; MessageSets only + * have extensions. + * + * All extensions of your type must be singular messages; e.g. they cannot + * be int32s, enums, or repeated messages. + * + * Because this is an option, the above two restrictions are not enforced by + * the protocol compiler. + */ + messageSetWireFormat: boolean; + /** + * Disables the generation of the standard "descriptor()" accessor, which can + * conflict with a field of the same name. This is meant to make migration + * from proto1 easier; new code should avoid fields named "descriptor". + */ + noStandardDescriptorAccessor: boolean; + /** + * Is this message deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the message, or it will be completely ignored; in the very least, + * this is a formalization for deprecating messages. + */ + deprecated: boolean; + /** + * Whether the message is an automatically generated map entry type for the + * maps field. + * + * For maps fields: + * map map_field = 1; + * The parsed descriptor looks like: + * message MapFieldEntry { + * option map_entry = true; + * optional KeyType key = 1; + * optional ValueType value = 2; + * } + * repeated MapFieldEntry map_field = 1; + * + * Implementations may choose not to generate the map_entry=true message, but + * use a native map in the target language to hold the keys and values. + * The reflection APIs in such implementations still need to work as + * if the field is a repeated message field. + * + * NOTE: Do not set the option in .proto files. Always use the maps syntax + * instead. The option should only be implicitly set by the proto compiler + * parser. + */ + mapEntry: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface FieldOptions { + /** + * The ctype option instructs the C++ code generator to use a different + * representation of the field than it normally would. See the specific + * options below. This option is not yet implemented in the open source + * release -- sorry, we'll try to include it in a future version! + */ + ctype: FieldOptions_CType; + /** + * The packed option can be enabled for repeated primitive fields to enable + * a more efficient representation on the wire. Rather than repeatedly + * writing the tag and type for each element, the entire array is encoded as + * a single length-delimited blob. In proto3, only explicit setting it to + * false will avoid using packed encoding. + */ + packed: boolean; + /** + * The jstype option determines the JavaScript type used for values of the + * field. The option is permitted only for 64 bit integral and fixed types + * (int64, uint64, sint64, fixed64, sfixed64). A field with jstype JS_STRING + * is represented as JavaScript string, which avoids loss of precision that + * can happen when a large value is converted to a floating point JavaScript. + * Specifying JS_NUMBER for the jstype causes the generated JavaScript code to + * use the JavaScript "number" type. The behavior of the default option + * JS_NORMAL is implementation dependent. + * + * This option is an enum to permit additional types to be added, e.g. + * goog.math.Integer. + */ + jstype: FieldOptions_JSType; + /** + * Should this field be parsed lazily? Lazy applies only to message-type + * fields. It means that when the outer message is initially parsed, the + * inner message's contents will not be parsed but instead stored in encoded + * form. The inner message will actually be parsed when it is first accessed. + * + * This is only a hint. Implementations are free to choose whether to use + * eager or lazy parsing regardless of the value of this option. However, + * setting this option true suggests that the protocol author believes that + * using lazy parsing on this field is worth the additional bookkeeping + * overhead typically needed to implement it. + * + * This option does not affect the public interface of any generated code; + * all method signatures remain the same. Furthermore, thread-safety of the + * interface is not affected by this option; const methods remain safe to + * call from multiple threads concurrently, while non-const methods continue + * to require exclusive access. + * + * + * Note that implementations may choose not to check required fields within + * a lazy sub-message. That is, calling IsInitialized() on the outer message + * may return true even if the inner message has missing required fields. + * This is necessary because otherwise the inner message would have to be + * parsed in order to perform the check, defeating the purpose of lazy + * parsing. An implementation which chooses not to check required fields + * must be consistent about it. That is, for any particular sub-message, the + * implementation must either *always* check its required fields, or *never* + * check its required fields, regardless of whether or not the message has + * been parsed. + */ + lazy: boolean; + /** + * Is this field deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for accessors, or it will be completely ignored; in the very least, this + * is a formalization for deprecating fields. + */ + deprecated: boolean; + /** For Google-internal migration only. Do not use. */ + weak: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export enum FieldOptions_CType { + /** STRING - Default mode. */ + STRING = 0, + CORD = 1, + STRING_PIECE = 2, + UNRECOGNIZED = -1, +} + +export function fieldOptions_CTypeFromJSON(object: any): FieldOptions_CType { + switch (object) { + case 0: + case "STRING": + return FieldOptions_CType.STRING; + case 1: + case "CORD": + return FieldOptions_CType.CORD; + case 2: + case "STRING_PIECE": + return FieldOptions_CType.STRING_PIECE; + case -1: + case "UNRECOGNIZED": + default: + return FieldOptions_CType.UNRECOGNIZED; + } +} + +export function fieldOptions_CTypeToJSON(object: FieldOptions_CType): string { + switch (object) { + case FieldOptions_CType.STRING: + return "STRING"; + case FieldOptions_CType.CORD: + return "CORD"; + case FieldOptions_CType.STRING_PIECE: + return "STRING_PIECE"; + default: + return "UNKNOWN"; + } +} + +export enum FieldOptions_JSType { + /** JS_NORMAL - Use the default type. */ + JS_NORMAL = 0, + /** JS_STRING - Use JavaScript strings. */ + JS_STRING = 1, + /** JS_NUMBER - Use JavaScript numbers. */ + JS_NUMBER = 2, + UNRECOGNIZED = -1, +} + +export function fieldOptions_JSTypeFromJSON(object: any): FieldOptions_JSType { + switch (object) { + case 0: + case "JS_NORMAL": + return FieldOptions_JSType.JS_NORMAL; + case 1: + case "JS_STRING": + return FieldOptions_JSType.JS_STRING; + case 2: + case "JS_NUMBER": + return FieldOptions_JSType.JS_NUMBER; + case -1: + case "UNRECOGNIZED": + default: + return FieldOptions_JSType.UNRECOGNIZED; + } +} + +export function fieldOptions_JSTypeToJSON(object: FieldOptions_JSType): string { + switch (object) { + case FieldOptions_JSType.JS_NORMAL: + return "JS_NORMAL"; + case FieldOptions_JSType.JS_STRING: + return "JS_STRING"; + case FieldOptions_JSType.JS_NUMBER: + return "JS_NUMBER"; + default: + return "UNKNOWN"; + } +} + +export interface OneofOptions { + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface EnumOptions { + /** + * Set this option to true to allow mapping different tag names to the same + * value. + */ + allowAlias: boolean; + /** + * Is this enum deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the enum, or it will be completely ignored; in the very least, this + * is a formalization for deprecating enums. + */ + deprecated: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface EnumValueOptions { + /** + * Is this enum value deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the enum value, or it will be completely ignored; in the very least, + * this is a formalization for deprecating enum values. + */ + deprecated: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface ServiceOptions { + /** + * Is this service deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the service, or it will be completely ignored; in the very least, + * this is a formalization for deprecating services. + */ + deprecated: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface MethodOptions { + /** + * Is this method deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the method, or it will be completely ignored; in the very least, + * this is a formalization for deprecating methods. + */ + deprecated: boolean; + idempotencyLevel: MethodOptions_IdempotencyLevel; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +/** + * Is this method side-effect-free (or safe in HTTP parlance), or idempotent, + * or neither? HTTP based RPC implementation may choose GET verb for safe + * methods, and PUT verb for idempotent methods instead of the default POST. + */ +export enum MethodOptions_IdempotencyLevel { + IDEMPOTENCY_UNKNOWN = 0, + /** NO_SIDE_EFFECTS - implies idempotent */ + NO_SIDE_EFFECTS = 1, + /** IDEMPOTENT - idempotent, but may have side effects */ + IDEMPOTENT = 2, + UNRECOGNIZED = -1, +} + +export function methodOptions_IdempotencyLevelFromJSON( + object: any +): MethodOptions_IdempotencyLevel { + switch (object) { + case 0: + case "IDEMPOTENCY_UNKNOWN": + return MethodOptions_IdempotencyLevel.IDEMPOTENCY_UNKNOWN; + case 1: + case "NO_SIDE_EFFECTS": + return MethodOptions_IdempotencyLevel.NO_SIDE_EFFECTS; + case 2: + case "IDEMPOTENT": + return MethodOptions_IdempotencyLevel.IDEMPOTENT; + case -1: + case "UNRECOGNIZED": + default: + return MethodOptions_IdempotencyLevel.UNRECOGNIZED; + } +} + +export function methodOptions_IdempotencyLevelToJSON( + object: MethodOptions_IdempotencyLevel +): string { + switch (object) { + case MethodOptions_IdempotencyLevel.IDEMPOTENCY_UNKNOWN: + return "IDEMPOTENCY_UNKNOWN"; + case MethodOptions_IdempotencyLevel.NO_SIDE_EFFECTS: + return "NO_SIDE_EFFECTS"; + case MethodOptions_IdempotencyLevel.IDEMPOTENT: + return "IDEMPOTENT"; + default: + return "UNKNOWN"; + } +} + +/** + * A message representing a option the parser does not recognize. This only + * appears in options protos created by the compiler::Parser class. + * DescriptorPool resolves these when building Descriptor objects. Therefore, + * options protos in descriptor objects (e.g. returned by Descriptor::options(), + * or produced by Descriptor::CopyTo()) will never have UninterpretedOptions + * in them. + */ +export interface UninterpretedOption { + name: UninterpretedOption_NamePart[]; + /** + * The value of the uninterpreted option, in whatever type the tokenizer + * identified it as during parsing. Exactly one of these should be set. + */ + identifierValue: string; + positiveIntValue: number; + negativeIntValue: number; + doubleValue: number; + stringValue: Uint8Array; + aggregateValue: string; +} + +/** + * The name of the uninterpreted option. Each string represents a segment in + * a dot-separated name. is_extension is true iff a segment represents an + * extension (denoted with parentheses in options specs in .proto files). + * E.g.,{ ["foo", false], ["bar.baz", true], ["qux", false] } represents + * "foo.(bar.baz).qux". + */ +export interface UninterpretedOption_NamePart { + namePart: string; + isExtension: boolean; +} + +/** + * Encapsulates information about the original source file from which a + * FileDescriptorProto was generated. + */ +export interface SourceCodeInfo { + /** + * A Location identifies a piece of source code in a .proto file which + * corresponds to a particular definition. This information is intended + * to be useful to IDEs, code indexers, documentation generators, and similar + * tools. + * + * For example, say we have a file like: + * message Foo { + * optional string foo = 1; + * } + * Let's look at just the field definition: + * optional string foo = 1; + * ^ ^^ ^^ ^ ^^^ + * a bc de f ghi + * We have the following locations: + * span path represents + * [a,i) [ 4, 0, 2, 0 ] The whole field definition. + * [a,b) [ 4, 0, 2, 0, 4 ] The label (optional). + * [c,d) [ 4, 0, 2, 0, 5 ] The type (string). + * [e,f) [ 4, 0, 2, 0, 1 ] The name (foo). + * [g,h) [ 4, 0, 2, 0, 3 ] The number (1). + * + * Notes: + * - A location may refer to a repeated field itself (i.e. not to any + * particular index within it). This is used whenever a set of elements are + * logically enclosed in a single code segment. For example, an entire + * extend block (possibly containing multiple extension definitions) will + * have an outer location whose path refers to the "extensions" repeated + * field without an index. + * - Multiple locations may have the same path. This happens when a single + * logical declaration is spread out across multiple places. The most + * obvious example is the "extend" block again -- there may be multiple + * extend blocks in the same scope, each of which will have the same path. + * - A location's span is not always a subset of its parent's span. For + * example, the "extendee" of an extension declaration appears at the + * beginning of the "extend" block and is shared by all extensions within + * the block. + * - Just because a location's span is a subset of some other location's span + * does not mean that it is a descendant. For example, a "group" defines + * both a type and a field in a single declaration. Thus, the locations + * corresponding to the type and field and their components will overlap. + * - Code which tries to interpret locations should probably be designed to + * ignore those that it doesn't understand, as more types of locations could + * be recorded in the future. + */ + location: SourceCodeInfo_Location[]; +} + +export interface SourceCodeInfo_Location { + /** + * Identifies which part of the FileDescriptorProto was defined at this + * location. + * + * Each element is a field number or an index. They form a path from + * the root FileDescriptorProto to the place where the definition. For + * example, this path: + * [ 4, 3, 2, 7, 1 ] + * refers to: + * file.message_type(3) // 4, 3 + * .field(7) // 2, 7 + * .name() // 1 + * This is because FileDescriptorProto.message_type has field number 4: + * repeated DescriptorProto message_type = 4; + * and DescriptorProto.field has field number 2: + * repeated FieldDescriptorProto field = 2; + * and FieldDescriptorProto.name has field number 1: + * optional string name = 1; + * + * Thus, the above path gives the location of a field name. If we removed + * the last element: + * [ 4, 3, 2, 7 ] + * this path refers to the whole field declaration (from the beginning + * of the label to the terminating semicolon). + */ + path: number[]; + /** + * Always has exactly three or four elements: start line, start column, + * end line (optional, otherwise assumed same as start line), end column. + * These are packed into a single field for efficiency. Note that line + * and column numbers are zero-based -- typically you will want to add + * 1 to each before displaying to a user. + */ + span: number[]; + /** + * If this SourceCodeInfo represents a complete declaration, these are any + * comments appearing before and after the declaration which appear to be + * attached to the declaration. + * + * A series of line comments appearing on consecutive lines, with no other + * tokens appearing on those lines, will be treated as a single comment. + * + * leading_detached_comments will keep paragraphs of comments that appear + * before (but not connected to) the current element. Each paragraph, + * separated by empty lines, will be one comment element in the repeated + * field. + * + * Only the comment content is provided; comment markers (e.g. //) are + * stripped out. For block comments, leading whitespace and an asterisk + * will be stripped from the beginning of each line other than the first. + * Newlines are included in the output. + * + * Examples: + * + * optional int32 foo = 1; // Comment attached to foo. + * // Comment attached to bar. + * optional int32 bar = 2; + * + * optional string baz = 3; + * // Comment attached to baz. + * // Another line attached to baz. + * + * // Comment attached to qux. + * // + * // Another line attached to qux. + * optional double qux = 4; + * + * // Detached comment for corge. This is not leading or trailing comments + * // to qux or corge because there are blank lines separating it from + * // both. + * + * // Detached comment for corge paragraph 2. + * + * optional string corge = 5; + * /* Block comment attached + * * to corge. Leading asterisks + * * will be removed. * / + * /* Block comment attached to + * * grault. * / + * optional int32 grault = 6; + * + * // ignored detached comments. + */ + leadingComments: string; + trailingComments: string; + leadingDetachedComments: string[]; +} + +/** + * Describes the relationship between generated code and its original source + * file. A GeneratedCodeInfo message is associated with only one generated + * source file, but may contain references to different source .proto files. + */ +export interface GeneratedCodeInfo { + /** + * An Annotation connects some span of text in generated code to an element + * of its generating .proto file. + */ + annotation: GeneratedCodeInfo_Annotation[]; +} + +export interface GeneratedCodeInfo_Annotation { + /** + * Identifies the element in the original source .proto file. This field + * is formatted the same as SourceCodeInfo.Location.path. + */ + path: number[]; + /** Identifies the filesystem path to the original source .proto. */ + sourceFile: string; + /** + * Identifies the starting offset in bytes in the generated code + * that relates to the identified object. + */ + begin: number; + /** + * Identifies the ending offset in bytes in the generated code that + * relates to the identified offset. The end offset should be one past + * the last relevant byte (so the length of the text = end - begin). + */ + end: number; +} + +const baseFileDescriptorSet: object = {}; + +export const FileDescriptorSet = { + encode(message: FileDescriptorSet, writer: Writer = Writer.create()): Writer { + for (const v of message.file) { + FileDescriptorProto.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FileDescriptorSet { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFileDescriptorSet } as FileDescriptorSet; + message.file = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.file.push( + FileDescriptorProto.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FileDescriptorSet { + const message = { ...baseFileDescriptorSet } as FileDescriptorSet; + message.file = []; + if (object.file !== undefined && object.file !== null) { + for (const e of object.file) { + message.file.push(FileDescriptorProto.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: FileDescriptorSet): unknown { + const obj: any = {}; + if (message.file) { + obj.file = message.file.map((e) => + e ? FileDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.file = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): FileDescriptorSet { + const message = { ...baseFileDescriptorSet } as FileDescriptorSet; + message.file = []; + if (object.file !== undefined && object.file !== null) { + for (const e of object.file) { + message.file.push(FileDescriptorProto.fromPartial(e)); + } + } + return message; + }, +}; + +const baseFileDescriptorProto: object = { + name: "", + package: "", + dependency: "", + publicDependency: 0, + weakDependency: 0, + syntax: "", +}; + +export const FileDescriptorProto = { + encode( + message: FileDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.package !== "") { + writer.uint32(18).string(message.package); + } + for (const v of message.dependency) { + writer.uint32(26).string(v!); + } + writer.uint32(82).fork(); + for (const v of message.publicDependency) { + writer.int32(v); + } + writer.ldelim(); + writer.uint32(90).fork(); + for (const v of message.weakDependency) { + writer.int32(v); + } + writer.ldelim(); + for (const v of message.messageType) { + DescriptorProto.encode(v!, writer.uint32(34).fork()).ldelim(); + } + for (const v of message.enumType) { + EnumDescriptorProto.encode(v!, writer.uint32(42).fork()).ldelim(); + } + for (const v of message.service) { + ServiceDescriptorProto.encode(v!, writer.uint32(50).fork()).ldelim(); + } + for (const v of message.extension) { + FieldDescriptorProto.encode(v!, writer.uint32(58).fork()).ldelim(); + } + if (message.options !== undefined) { + FileOptions.encode(message.options, writer.uint32(66).fork()).ldelim(); + } + if (message.sourceCodeInfo !== undefined) { + SourceCodeInfo.encode( + message.sourceCodeInfo, + writer.uint32(74).fork() + ).ldelim(); + } + if (message.syntax !== "") { + writer.uint32(98).string(message.syntax); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FileDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFileDescriptorProto } as FileDescriptorProto; + message.dependency = []; + message.publicDependency = []; + message.weakDependency = []; + message.messageType = []; + message.enumType = []; + message.service = []; + message.extension = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.package = reader.string(); + break; + case 3: + message.dependency.push(reader.string()); + break; + case 10: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.publicDependency.push(reader.int32()); + } + } else { + message.publicDependency.push(reader.int32()); + } + break; + case 11: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.weakDependency.push(reader.int32()); + } + } else { + message.weakDependency.push(reader.int32()); + } + break; + case 4: + message.messageType.push( + DescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 5: + message.enumType.push( + EnumDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 6: + message.service.push( + ServiceDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 7: + message.extension.push( + FieldDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 8: + message.options = FileOptions.decode(reader, reader.uint32()); + break; + case 9: + message.sourceCodeInfo = SourceCodeInfo.decode( + reader, + reader.uint32() + ); + break; + case 12: + message.syntax = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FileDescriptorProto { + const message = { ...baseFileDescriptorProto } as FileDescriptorProto; + message.dependency = []; + message.publicDependency = []; + message.weakDependency = []; + message.messageType = []; + message.enumType = []; + message.service = []; + message.extension = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.package !== undefined && object.package !== null) { + message.package = String(object.package); + } else { + message.package = ""; + } + if (object.dependency !== undefined && object.dependency !== null) { + for (const e of object.dependency) { + message.dependency.push(String(e)); + } + } + if ( + object.publicDependency !== undefined && + object.publicDependency !== null + ) { + for (const e of object.publicDependency) { + message.publicDependency.push(Number(e)); + } + } + if (object.weakDependency !== undefined && object.weakDependency !== null) { + for (const e of object.weakDependency) { + message.weakDependency.push(Number(e)); + } + } + if (object.messageType !== undefined && object.messageType !== null) { + for (const e of object.messageType) { + message.messageType.push(DescriptorProto.fromJSON(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromJSON(e)); + } + } + if (object.service !== undefined && object.service !== null) { + for (const e of object.service) { + message.service.push(ServiceDescriptorProto.fromJSON(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = FileOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.sourceCodeInfo !== undefined && object.sourceCodeInfo !== null) { + message.sourceCodeInfo = SourceCodeInfo.fromJSON(object.sourceCodeInfo); + } else { + message.sourceCodeInfo = undefined; + } + if (object.syntax !== undefined && object.syntax !== null) { + message.syntax = String(object.syntax); + } else { + message.syntax = ""; + } + return message; + }, + + toJSON(message: FileDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.package !== undefined && (obj.package = message.package); + if (message.dependency) { + obj.dependency = message.dependency.map((e) => e); + } else { + obj.dependency = []; + } + if (message.publicDependency) { + obj.publicDependency = message.publicDependency.map((e) => e); + } else { + obj.publicDependency = []; + } + if (message.weakDependency) { + obj.weakDependency = message.weakDependency.map((e) => e); + } else { + obj.weakDependency = []; + } + if (message.messageType) { + obj.messageType = message.messageType.map((e) => + e ? DescriptorProto.toJSON(e) : undefined + ); + } else { + obj.messageType = []; + } + if (message.enumType) { + obj.enumType = message.enumType.map((e) => + e ? EnumDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.enumType = []; + } + if (message.service) { + obj.service = message.service.map((e) => + e ? ServiceDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.service = []; + } + if (message.extension) { + obj.extension = message.extension.map((e) => + e ? FieldDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.extension = []; + } + message.options !== undefined && + (obj.options = message.options + ? FileOptions.toJSON(message.options) + : undefined); + message.sourceCodeInfo !== undefined && + (obj.sourceCodeInfo = message.sourceCodeInfo + ? SourceCodeInfo.toJSON(message.sourceCodeInfo) + : undefined); + message.syntax !== undefined && (obj.syntax = message.syntax); + return obj; + }, + + fromPartial(object: DeepPartial): FileDescriptorProto { + const message = { ...baseFileDescriptorProto } as FileDescriptorProto; + message.dependency = []; + message.publicDependency = []; + message.weakDependency = []; + message.messageType = []; + message.enumType = []; + message.service = []; + message.extension = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.package !== undefined && object.package !== null) { + message.package = object.package; + } else { + message.package = ""; + } + if (object.dependency !== undefined && object.dependency !== null) { + for (const e of object.dependency) { + message.dependency.push(e); + } + } + if ( + object.publicDependency !== undefined && + object.publicDependency !== null + ) { + for (const e of object.publicDependency) { + message.publicDependency.push(e); + } + } + if (object.weakDependency !== undefined && object.weakDependency !== null) { + for (const e of object.weakDependency) { + message.weakDependency.push(e); + } + } + if (object.messageType !== undefined && object.messageType !== null) { + for (const e of object.messageType) { + message.messageType.push(DescriptorProto.fromPartial(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromPartial(e)); + } + } + if (object.service !== undefined && object.service !== null) { + for (const e of object.service) { + message.service.push(ServiceDescriptorProto.fromPartial(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = FileOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.sourceCodeInfo !== undefined && object.sourceCodeInfo !== null) { + message.sourceCodeInfo = SourceCodeInfo.fromPartial( + object.sourceCodeInfo + ); + } else { + message.sourceCodeInfo = undefined; + } + if (object.syntax !== undefined && object.syntax !== null) { + message.syntax = object.syntax; + } else { + message.syntax = ""; + } + return message; + }, +}; + +const baseDescriptorProto: object = { name: "", reservedName: "" }; + +export const DescriptorProto = { + encode(message: DescriptorProto, writer: Writer = Writer.create()): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + for (const v of message.field) { + FieldDescriptorProto.encode(v!, writer.uint32(18).fork()).ldelim(); + } + for (const v of message.extension) { + FieldDescriptorProto.encode(v!, writer.uint32(50).fork()).ldelim(); + } + for (const v of message.nestedType) { + DescriptorProto.encode(v!, writer.uint32(26).fork()).ldelim(); + } + for (const v of message.enumType) { + EnumDescriptorProto.encode(v!, writer.uint32(34).fork()).ldelim(); + } + for (const v of message.extensionRange) { + DescriptorProto_ExtensionRange.encode( + v!, + writer.uint32(42).fork() + ).ldelim(); + } + for (const v of message.oneofDecl) { + OneofDescriptorProto.encode(v!, writer.uint32(66).fork()).ldelim(); + } + if (message.options !== undefined) { + MessageOptions.encode(message.options, writer.uint32(58).fork()).ldelim(); + } + for (const v of message.reservedRange) { + DescriptorProto_ReservedRange.encode( + v!, + writer.uint32(74).fork() + ).ldelim(); + } + for (const v of message.reservedName) { + writer.uint32(82).string(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): DescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseDescriptorProto } as DescriptorProto; + message.field = []; + message.extension = []; + message.nestedType = []; + message.enumType = []; + message.extensionRange = []; + message.oneofDecl = []; + message.reservedRange = []; + message.reservedName = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.field.push( + FieldDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 6: + message.extension.push( + FieldDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 3: + message.nestedType.push( + DescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 4: + message.enumType.push( + EnumDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 5: + message.extensionRange.push( + DescriptorProto_ExtensionRange.decode(reader, reader.uint32()) + ); + break; + case 8: + message.oneofDecl.push( + OneofDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 7: + message.options = MessageOptions.decode(reader, reader.uint32()); + break; + case 9: + message.reservedRange.push( + DescriptorProto_ReservedRange.decode(reader, reader.uint32()) + ); + break; + case 10: + message.reservedName.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DescriptorProto { + const message = { ...baseDescriptorProto } as DescriptorProto; + message.field = []; + message.extension = []; + message.nestedType = []; + message.enumType = []; + message.extensionRange = []; + message.oneofDecl = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.field !== undefined && object.field !== null) { + for (const e of object.field) { + message.field.push(FieldDescriptorProto.fromJSON(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromJSON(e)); + } + } + if (object.nestedType !== undefined && object.nestedType !== null) { + for (const e of object.nestedType) { + message.nestedType.push(DescriptorProto.fromJSON(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromJSON(e)); + } + } + if (object.extensionRange !== undefined && object.extensionRange !== null) { + for (const e of object.extensionRange) { + message.extensionRange.push(DescriptorProto_ExtensionRange.fromJSON(e)); + } + } + if (object.oneofDecl !== undefined && object.oneofDecl !== null) { + for (const e of object.oneofDecl) { + message.oneofDecl.push(OneofDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = MessageOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push(DescriptorProto_ReservedRange.fromJSON(e)); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(String(e)); + } + } + return message; + }, + + toJSON(message: DescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + if (message.field) { + obj.field = message.field.map((e) => + e ? FieldDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.field = []; + } + if (message.extension) { + obj.extension = message.extension.map((e) => + e ? FieldDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.extension = []; + } + if (message.nestedType) { + obj.nestedType = message.nestedType.map((e) => + e ? DescriptorProto.toJSON(e) : undefined + ); + } else { + obj.nestedType = []; + } + if (message.enumType) { + obj.enumType = message.enumType.map((e) => + e ? EnumDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.enumType = []; + } + if (message.extensionRange) { + obj.extensionRange = message.extensionRange.map((e) => + e ? DescriptorProto_ExtensionRange.toJSON(e) : undefined + ); + } else { + obj.extensionRange = []; + } + if (message.oneofDecl) { + obj.oneofDecl = message.oneofDecl.map((e) => + e ? OneofDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.oneofDecl = []; + } + message.options !== undefined && + (obj.options = message.options + ? MessageOptions.toJSON(message.options) + : undefined); + if (message.reservedRange) { + obj.reservedRange = message.reservedRange.map((e) => + e ? DescriptorProto_ReservedRange.toJSON(e) : undefined + ); + } else { + obj.reservedRange = []; + } + if (message.reservedName) { + obj.reservedName = message.reservedName.map((e) => e); + } else { + obj.reservedName = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): DescriptorProto { + const message = { ...baseDescriptorProto } as DescriptorProto; + message.field = []; + message.extension = []; + message.nestedType = []; + message.enumType = []; + message.extensionRange = []; + message.oneofDecl = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.field !== undefined && object.field !== null) { + for (const e of object.field) { + message.field.push(FieldDescriptorProto.fromPartial(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromPartial(e)); + } + } + if (object.nestedType !== undefined && object.nestedType !== null) { + for (const e of object.nestedType) { + message.nestedType.push(DescriptorProto.fromPartial(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromPartial(e)); + } + } + if (object.extensionRange !== undefined && object.extensionRange !== null) { + for (const e of object.extensionRange) { + message.extensionRange.push( + DescriptorProto_ExtensionRange.fromPartial(e) + ); + } + } + if (object.oneofDecl !== undefined && object.oneofDecl !== null) { + for (const e of object.oneofDecl) { + message.oneofDecl.push(OneofDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = MessageOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push( + DescriptorProto_ReservedRange.fromPartial(e) + ); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(e); + } + } + return message; + }, +}; + +const baseDescriptorProto_ExtensionRange: object = { start: 0, end: 0 }; + +export const DescriptorProto_ExtensionRange = { + encode( + message: DescriptorProto_ExtensionRange, + writer: Writer = Writer.create() + ): Writer { + if (message.start !== 0) { + writer.uint32(8).int32(message.start); + } + if (message.end !== 0) { + writer.uint32(16).int32(message.end); + } + if (message.options !== undefined) { + ExtensionRangeOptions.encode( + message.options, + writer.uint32(26).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): DescriptorProto_ExtensionRange { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseDescriptorProto_ExtensionRange, + } as DescriptorProto_ExtensionRange; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.start = reader.int32(); + break; + case 2: + message.end = reader.int32(); + break; + case 3: + message.options = ExtensionRangeOptions.decode( + reader, + reader.uint32() + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DescriptorProto_ExtensionRange { + const message = { + ...baseDescriptorProto_ExtensionRange, + } as DescriptorProto_ExtensionRange; + if (object.start !== undefined && object.start !== null) { + message.start = Number(object.start); + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = ExtensionRangeOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: DescriptorProto_ExtensionRange): unknown { + const obj: any = {}; + message.start !== undefined && (obj.start = message.start); + message.end !== undefined && (obj.end = message.end); + message.options !== undefined && + (obj.options = message.options + ? ExtensionRangeOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): DescriptorProto_ExtensionRange { + const message = { + ...baseDescriptorProto_ExtensionRange, + } as DescriptorProto_ExtensionRange; + if (object.start !== undefined && object.start !== null) { + message.start = object.start; + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = ExtensionRangeOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseDescriptorProto_ReservedRange: object = { start: 0, end: 0 }; + +export const DescriptorProto_ReservedRange = { + encode( + message: DescriptorProto_ReservedRange, + writer: Writer = Writer.create() + ): Writer { + if (message.start !== 0) { + writer.uint32(8).int32(message.start); + } + if (message.end !== 0) { + writer.uint32(16).int32(message.end); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): DescriptorProto_ReservedRange { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseDescriptorProto_ReservedRange, + } as DescriptorProto_ReservedRange; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.start = reader.int32(); + break; + case 2: + message.end = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DescriptorProto_ReservedRange { + const message = { + ...baseDescriptorProto_ReservedRange, + } as DescriptorProto_ReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = Number(object.start); + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + return message; + }, + + toJSON(message: DescriptorProto_ReservedRange): unknown { + const obj: any = {}; + message.start !== undefined && (obj.start = message.start); + message.end !== undefined && (obj.end = message.end); + return obj; + }, + + fromPartial( + object: DeepPartial + ): DescriptorProto_ReservedRange { + const message = { + ...baseDescriptorProto_ReservedRange, + } as DescriptorProto_ReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = object.start; + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + return message; + }, +}; + +const baseExtensionRangeOptions: object = {}; + +export const ExtensionRangeOptions = { + encode( + message: ExtensionRangeOptions, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ExtensionRangeOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseExtensionRangeOptions } as ExtensionRangeOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ExtensionRangeOptions { + const message = { ...baseExtensionRangeOptions } as ExtensionRangeOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: ExtensionRangeOptions): unknown { + const obj: any = {}; + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial( + object: DeepPartial + ): ExtensionRangeOptions { + const message = { ...baseExtensionRangeOptions } as ExtensionRangeOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseFieldDescriptorProto: object = { + name: "", + number: 0, + label: 1, + type: 1, + typeName: "", + extendee: "", + defaultValue: "", + oneofIndex: 0, + jsonName: "", + proto3Optional: false, +}; + +export const FieldDescriptorProto = { + encode( + message: FieldDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.number !== 0) { + writer.uint32(24).int32(message.number); + } + if (message.label !== 1) { + writer.uint32(32).int32(message.label); + } + if (message.type !== 1) { + writer.uint32(40).int32(message.type); + } + if (message.typeName !== "") { + writer.uint32(50).string(message.typeName); + } + if (message.extendee !== "") { + writer.uint32(18).string(message.extendee); + } + if (message.defaultValue !== "") { + writer.uint32(58).string(message.defaultValue); + } + if (message.oneofIndex !== 0) { + writer.uint32(72).int32(message.oneofIndex); + } + if (message.jsonName !== "") { + writer.uint32(82).string(message.jsonName); + } + if (message.options !== undefined) { + FieldOptions.encode(message.options, writer.uint32(66).fork()).ldelim(); + } + if (message.proto3Optional === true) { + writer.uint32(136).bool(message.proto3Optional); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FieldDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFieldDescriptorProto } as FieldDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 3: + message.number = reader.int32(); + break; + case 4: + message.label = reader.int32() as any; + break; + case 5: + message.type = reader.int32() as any; + break; + case 6: + message.typeName = reader.string(); + break; + case 2: + message.extendee = reader.string(); + break; + case 7: + message.defaultValue = reader.string(); + break; + case 9: + message.oneofIndex = reader.int32(); + break; + case 10: + message.jsonName = reader.string(); + break; + case 8: + message.options = FieldOptions.decode(reader, reader.uint32()); + break; + case 17: + message.proto3Optional = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FieldDescriptorProto { + const message = { ...baseFieldDescriptorProto } as FieldDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = Number(object.number); + } else { + message.number = 0; + } + if (object.label !== undefined && object.label !== null) { + message.label = fieldDescriptorProto_LabelFromJSON(object.label); + } else { + message.label = 1; + } + if (object.type !== undefined && object.type !== null) { + message.type = fieldDescriptorProto_TypeFromJSON(object.type); + } else { + message.type = 1; + } + if (object.typeName !== undefined && object.typeName !== null) { + message.typeName = String(object.typeName); + } else { + message.typeName = ""; + } + if (object.extendee !== undefined && object.extendee !== null) { + message.extendee = String(object.extendee); + } else { + message.extendee = ""; + } + if (object.defaultValue !== undefined && object.defaultValue !== null) { + message.defaultValue = String(object.defaultValue); + } else { + message.defaultValue = ""; + } + if (object.oneofIndex !== undefined && object.oneofIndex !== null) { + message.oneofIndex = Number(object.oneofIndex); + } else { + message.oneofIndex = 0; + } + if (object.jsonName !== undefined && object.jsonName !== null) { + message.jsonName = String(object.jsonName); + } else { + message.jsonName = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = FieldOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.proto3Optional !== undefined && object.proto3Optional !== null) { + message.proto3Optional = Boolean(object.proto3Optional); + } else { + message.proto3Optional = false; + } + return message; + }, + + toJSON(message: FieldDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.number !== undefined && (obj.number = message.number); + message.label !== undefined && + (obj.label = fieldDescriptorProto_LabelToJSON(message.label)); + message.type !== undefined && + (obj.type = fieldDescriptorProto_TypeToJSON(message.type)); + message.typeName !== undefined && (obj.typeName = message.typeName); + message.extendee !== undefined && (obj.extendee = message.extendee); + message.defaultValue !== undefined && + (obj.defaultValue = message.defaultValue); + message.oneofIndex !== undefined && (obj.oneofIndex = message.oneofIndex); + message.jsonName !== undefined && (obj.jsonName = message.jsonName); + message.options !== undefined && + (obj.options = message.options + ? FieldOptions.toJSON(message.options) + : undefined); + message.proto3Optional !== undefined && + (obj.proto3Optional = message.proto3Optional); + return obj; + }, + + fromPartial(object: DeepPartial): FieldDescriptorProto { + const message = { ...baseFieldDescriptorProto } as FieldDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = object.number; + } else { + message.number = 0; + } + if (object.label !== undefined && object.label !== null) { + message.label = object.label; + } else { + message.label = 1; + } + if (object.type !== undefined && object.type !== null) { + message.type = object.type; + } else { + message.type = 1; + } + if (object.typeName !== undefined && object.typeName !== null) { + message.typeName = object.typeName; + } else { + message.typeName = ""; + } + if (object.extendee !== undefined && object.extendee !== null) { + message.extendee = object.extendee; + } else { + message.extendee = ""; + } + if (object.defaultValue !== undefined && object.defaultValue !== null) { + message.defaultValue = object.defaultValue; + } else { + message.defaultValue = ""; + } + if (object.oneofIndex !== undefined && object.oneofIndex !== null) { + message.oneofIndex = object.oneofIndex; + } else { + message.oneofIndex = 0; + } + if (object.jsonName !== undefined && object.jsonName !== null) { + message.jsonName = object.jsonName; + } else { + message.jsonName = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = FieldOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.proto3Optional !== undefined && object.proto3Optional !== null) { + message.proto3Optional = object.proto3Optional; + } else { + message.proto3Optional = false; + } + return message; + }, +}; + +const baseOneofDescriptorProto: object = { name: "" }; + +export const OneofDescriptorProto = { + encode( + message: OneofDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.options !== undefined) { + OneofOptions.encode(message.options, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): OneofDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseOneofDescriptorProto } as OneofDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.options = OneofOptions.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): OneofDescriptorProto { + const message = { ...baseOneofDescriptorProto } as OneofDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = OneofOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: OneofDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.options !== undefined && + (obj.options = message.options + ? OneofOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): OneofDescriptorProto { + const message = { ...baseOneofDescriptorProto } as OneofDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = OneofOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseEnumDescriptorProto: object = { name: "", reservedName: "" }; + +export const EnumDescriptorProto = { + encode( + message: EnumDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + for (const v of message.value) { + EnumValueDescriptorProto.encode(v!, writer.uint32(18).fork()).ldelim(); + } + if (message.options !== undefined) { + EnumOptions.encode(message.options, writer.uint32(26).fork()).ldelim(); + } + for (const v of message.reservedRange) { + EnumDescriptorProto_EnumReservedRange.encode( + v!, + writer.uint32(34).fork() + ).ldelim(); + } + for (const v of message.reservedName) { + writer.uint32(42).string(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): EnumDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseEnumDescriptorProto } as EnumDescriptorProto; + message.value = []; + message.reservedRange = []; + message.reservedName = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.value.push( + EnumValueDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 3: + message.options = EnumOptions.decode(reader, reader.uint32()); + break; + case 4: + message.reservedRange.push( + EnumDescriptorProto_EnumReservedRange.decode( + reader, + reader.uint32() + ) + ); + break; + case 5: + message.reservedName.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumDescriptorProto { + const message = { ...baseEnumDescriptorProto } as EnumDescriptorProto; + message.value = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.value !== undefined && object.value !== null) { + for (const e of object.value) { + message.value.push(EnumValueDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push( + EnumDescriptorProto_EnumReservedRange.fromJSON(e) + ); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(String(e)); + } + } + return message; + }, + + toJSON(message: EnumDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + if (message.value) { + obj.value = message.value.map((e) => + e ? EnumValueDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.value = []; + } + message.options !== undefined && + (obj.options = message.options + ? EnumOptions.toJSON(message.options) + : undefined); + if (message.reservedRange) { + obj.reservedRange = message.reservedRange.map((e) => + e ? EnumDescriptorProto_EnumReservedRange.toJSON(e) : undefined + ); + } else { + obj.reservedRange = []; + } + if (message.reservedName) { + obj.reservedName = message.reservedName.map((e) => e); + } else { + obj.reservedName = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): EnumDescriptorProto { + const message = { ...baseEnumDescriptorProto } as EnumDescriptorProto; + message.value = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.value !== undefined && object.value !== null) { + for (const e of object.value) { + message.value.push(EnumValueDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push( + EnumDescriptorProto_EnumReservedRange.fromPartial(e) + ); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(e); + } + } + return message; + }, +}; + +const baseEnumDescriptorProto_EnumReservedRange: object = { start: 0, end: 0 }; + +export const EnumDescriptorProto_EnumReservedRange = { + encode( + message: EnumDescriptorProto_EnumReservedRange, + writer: Writer = Writer.create() + ): Writer { + if (message.start !== 0) { + writer.uint32(8).int32(message.start); + } + if (message.end !== 0) { + writer.uint32(16).int32(message.end); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): EnumDescriptorProto_EnumReservedRange { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseEnumDescriptorProto_EnumReservedRange, + } as EnumDescriptorProto_EnumReservedRange; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.start = reader.int32(); + break; + case 2: + message.end = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumDescriptorProto_EnumReservedRange { + const message = { + ...baseEnumDescriptorProto_EnumReservedRange, + } as EnumDescriptorProto_EnumReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = Number(object.start); + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + return message; + }, + + toJSON(message: EnumDescriptorProto_EnumReservedRange): unknown { + const obj: any = {}; + message.start !== undefined && (obj.start = message.start); + message.end !== undefined && (obj.end = message.end); + return obj; + }, + + fromPartial( + object: DeepPartial + ): EnumDescriptorProto_EnumReservedRange { + const message = { + ...baseEnumDescriptorProto_EnumReservedRange, + } as EnumDescriptorProto_EnumReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = object.start; + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + return message; + }, +}; + +const baseEnumValueDescriptorProto: object = { name: "", number: 0 }; + +export const EnumValueDescriptorProto = { + encode( + message: EnumValueDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.number !== 0) { + writer.uint32(16).int32(message.number); + } + if (message.options !== undefined) { + EnumValueOptions.encode( + message.options, + writer.uint32(26).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): EnumValueDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseEnumValueDescriptorProto, + } as EnumValueDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.number = reader.int32(); + break; + case 3: + message.options = EnumValueOptions.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumValueDescriptorProto { + const message = { + ...baseEnumValueDescriptorProto, + } as EnumValueDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = Number(object.number); + } else { + message.number = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumValueOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: EnumValueDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.number !== undefined && (obj.number = message.number); + message.options !== undefined && + (obj.options = message.options + ? EnumValueOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): EnumValueDescriptorProto { + const message = { + ...baseEnumValueDescriptorProto, + } as EnumValueDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = object.number; + } else { + message.number = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumValueOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseServiceDescriptorProto: object = { name: "" }; + +export const ServiceDescriptorProto = { + encode( + message: ServiceDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + for (const v of message.method) { + MethodDescriptorProto.encode(v!, writer.uint32(18).fork()).ldelim(); + } + if (message.options !== undefined) { + ServiceOptions.encode(message.options, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ServiceDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseServiceDescriptorProto } as ServiceDescriptorProto; + message.method = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.method.push( + MethodDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 3: + message.options = ServiceOptions.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ServiceDescriptorProto { + const message = { ...baseServiceDescriptorProto } as ServiceDescriptorProto; + message.method = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.method !== undefined && object.method !== null) { + for (const e of object.method) { + message.method.push(MethodDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = ServiceOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: ServiceDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + if (message.method) { + obj.method = message.method.map((e) => + e ? MethodDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.method = []; + } + message.options !== undefined && + (obj.options = message.options + ? ServiceOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): ServiceDescriptorProto { + const message = { ...baseServiceDescriptorProto } as ServiceDescriptorProto; + message.method = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.method !== undefined && object.method !== null) { + for (const e of object.method) { + message.method.push(MethodDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = ServiceOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseMethodDescriptorProto: object = { + name: "", + inputType: "", + outputType: "", + clientStreaming: false, + serverStreaming: false, +}; + +export const MethodDescriptorProto = { + encode( + message: MethodDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.inputType !== "") { + writer.uint32(18).string(message.inputType); + } + if (message.outputType !== "") { + writer.uint32(26).string(message.outputType); + } + if (message.options !== undefined) { + MethodOptions.encode(message.options, writer.uint32(34).fork()).ldelim(); + } + if (message.clientStreaming === true) { + writer.uint32(40).bool(message.clientStreaming); + } + if (message.serverStreaming === true) { + writer.uint32(48).bool(message.serverStreaming); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MethodDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMethodDescriptorProto } as MethodDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.inputType = reader.string(); + break; + case 3: + message.outputType = reader.string(); + break; + case 4: + message.options = MethodOptions.decode(reader, reader.uint32()); + break; + case 5: + message.clientStreaming = reader.bool(); + break; + case 6: + message.serverStreaming = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MethodDescriptorProto { + const message = { ...baseMethodDescriptorProto } as MethodDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.inputType !== undefined && object.inputType !== null) { + message.inputType = String(object.inputType); + } else { + message.inputType = ""; + } + if (object.outputType !== undefined && object.outputType !== null) { + message.outputType = String(object.outputType); + } else { + message.outputType = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = MethodOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if ( + object.clientStreaming !== undefined && + object.clientStreaming !== null + ) { + message.clientStreaming = Boolean(object.clientStreaming); + } else { + message.clientStreaming = false; + } + if ( + object.serverStreaming !== undefined && + object.serverStreaming !== null + ) { + message.serverStreaming = Boolean(object.serverStreaming); + } else { + message.serverStreaming = false; + } + return message; + }, + + toJSON(message: MethodDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.inputType !== undefined && (obj.inputType = message.inputType); + message.outputType !== undefined && (obj.outputType = message.outputType); + message.options !== undefined && + (obj.options = message.options + ? MethodOptions.toJSON(message.options) + : undefined); + message.clientStreaming !== undefined && + (obj.clientStreaming = message.clientStreaming); + message.serverStreaming !== undefined && + (obj.serverStreaming = message.serverStreaming); + return obj; + }, + + fromPartial( + object: DeepPartial + ): MethodDescriptorProto { + const message = { ...baseMethodDescriptorProto } as MethodDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.inputType !== undefined && object.inputType !== null) { + message.inputType = object.inputType; + } else { + message.inputType = ""; + } + if (object.outputType !== undefined && object.outputType !== null) { + message.outputType = object.outputType; + } else { + message.outputType = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = MethodOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if ( + object.clientStreaming !== undefined && + object.clientStreaming !== null + ) { + message.clientStreaming = object.clientStreaming; + } else { + message.clientStreaming = false; + } + if ( + object.serverStreaming !== undefined && + object.serverStreaming !== null + ) { + message.serverStreaming = object.serverStreaming; + } else { + message.serverStreaming = false; + } + return message; + }, +}; + +const baseFileOptions: object = { + javaPackage: "", + javaOuterClassname: "", + javaMultipleFiles: false, + javaGenerateEqualsAndHash: false, + javaStringCheckUtf8: false, + optimizeFor: 1, + goPackage: "", + ccGenericServices: false, + javaGenericServices: false, + pyGenericServices: false, + phpGenericServices: false, + deprecated: false, + ccEnableArenas: false, + objcClassPrefix: "", + csharpNamespace: "", + swiftPrefix: "", + phpClassPrefix: "", + phpNamespace: "", + phpMetadataNamespace: "", + rubyPackage: "", +}; + +export const FileOptions = { + encode(message: FileOptions, writer: Writer = Writer.create()): Writer { + if (message.javaPackage !== "") { + writer.uint32(10).string(message.javaPackage); + } + if (message.javaOuterClassname !== "") { + writer.uint32(66).string(message.javaOuterClassname); + } + if (message.javaMultipleFiles === true) { + writer.uint32(80).bool(message.javaMultipleFiles); + } + if (message.javaGenerateEqualsAndHash === true) { + writer.uint32(160).bool(message.javaGenerateEqualsAndHash); + } + if (message.javaStringCheckUtf8 === true) { + writer.uint32(216).bool(message.javaStringCheckUtf8); + } + if (message.optimizeFor !== 1) { + writer.uint32(72).int32(message.optimizeFor); + } + if (message.goPackage !== "") { + writer.uint32(90).string(message.goPackage); + } + if (message.ccGenericServices === true) { + writer.uint32(128).bool(message.ccGenericServices); + } + if (message.javaGenericServices === true) { + writer.uint32(136).bool(message.javaGenericServices); + } + if (message.pyGenericServices === true) { + writer.uint32(144).bool(message.pyGenericServices); + } + if (message.phpGenericServices === true) { + writer.uint32(336).bool(message.phpGenericServices); + } + if (message.deprecated === true) { + writer.uint32(184).bool(message.deprecated); + } + if (message.ccEnableArenas === true) { + writer.uint32(248).bool(message.ccEnableArenas); + } + if (message.objcClassPrefix !== "") { + writer.uint32(290).string(message.objcClassPrefix); + } + if (message.csharpNamespace !== "") { + writer.uint32(298).string(message.csharpNamespace); + } + if (message.swiftPrefix !== "") { + writer.uint32(314).string(message.swiftPrefix); + } + if (message.phpClassPrefix !== "") { + writer.uint32(322).string(message.phpClassPrefix); + } + if (message.phpNamespace !== "") { + writer.uint32(330).string(message.phpNamespace); + } + if (message.phpMetadataNamespace !== "") { + writer.uint32(354).string(message.phpMetadataNamespace); + } + if (message.rubyPackage !== "") { + writer.uint32(362).string(message.rubyPackage); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FileOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFileOptions } as FileOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.javaPackage = reader.string(); + break; + case 8: + message.javaOuterClassname = reader.string(); + break; + case 10: + message.javaMultipleFiles = reader.bool(); + break; + case 20: + message.javaGenerateEqualsAndHash = reader.bool(); + break; + case 27: + message.javaStringCheckUtf8 = reader.bool(); + break; + case 9: + message.optimizeFor = reader.int32() as any; + break; + case 11: + message.goPackage = reader.string(); + break; + case 16: + message.ccGenericServices = reader.bool(); + break; + case 17: + message.javaGenericServices = reader.bool(); + break; + case 18: + message.pyGenericServices = reader.bool(); + break; + case 42: + message.phpGenericServices = reader.bool(); + break; + case 23: + message.deprecated = reader.bool(); + break; + case 31: + message.ccEnableArenas = reader.bool(); + break; + case 36: + message.objcClassPrefix = reader.string(); + break; + case 37: + message.csharpNamespace = reader.string(); + break; + case 39: + message.swiftPrefix = reader.string(); + break; + case 40: + message.phpClassPrefix = reader.string(); + break; + case 41: + message.phpNamespace = reader.string(); + break; + case 44: + message.phpMetadataNamespace = reader.string(); + break; + case 45: + message.rubyPackage = reader.string(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FileOptions { + const message = { ...baseFileOptions } as FileOptions; + message.uninterpretedOption = []; + if (object.javaPackage !== undefined && object.javaPackage !== null) { + message.javaPackage = String(object.javaPackage); + } else { + message.javaPackage = ""; + } + if ( + object.javaOuterClassname !== undefined && + object.javaOuterClassname !== null + ) { + message.javaOuterClassname = String(object.javaOuterClassname); + } else { + message.javaOuterClassname = ""; + } + if ( + object.javaMultipleFiles !== undefined && + object.javaMultipleFiles !== null + ) { + message.javaMultipleFiles = Boolean(object.javaMultipleFiles); + } else { + message.javaMultipleFiles = false; + } + if ( + object.javaGenerateEqualsAndHash !== undefined && + object.javaGenerateEqualsAndHash !== null + ) { + message.javaGenerateEqualsAndHash = Boolean( + object.javaGenerateEqualsAndHash + ); + } else { + message.javaGenerateEqualsAndHash = false; + } + if ( + object.javaStringCheckUtf8 !== undefined && + object.javaStringCheckUtf8 !== null + ) { + message.javaStringCheckUtf8 = Boolean(object.javaStringCheckUtf8); + } else { + message.javaStringCheckUtf8 = false; + } + if (object.optimizeFor !== undefined && object.optimizeFor !== null) { + message.optimizeFor = fileOptions_OptimizeModeFromJSON( + object.optimizeFor + ); + } else { + message.optimizeFor = 1; + } + if (object.goPackage !== undefined && object.goPackage !== null) { + message.goPackage = String(object.goPackage); + } else { + message.goPackage = ""; + } + if ( + object.ccGenericServices !== undefined && + object.ccGenericServices !== null + ) { + message.ccGenericServices = Boolean(object.ccGenericServices); + } else { + message.ccGenericServices = false; + } + if ( + object.javaGenericServices !== undefined && + object.javaGenericServices !== null + ) { + message.javaGenericServices = Boolean(object.javaGenericServices); + } else { + message.javaGenericServices = false; + } + if ( + object.pyGenericServices !== undefined && + object.pyGenericServices !== null + ) { + message.pyGenericServices = Boolean(object.pyGenericServices); + } else { + message.pyGenericServices = false; + } + if ( + object.phpGenericServices !== undefined && + object.phpGenericServices !== null + ) { + message.phpGenericServices = Boolean(object.phpGenericServices); + } else { + message.phpGenericServices = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if (object.ccEnableArenas !== undefined && object.ccEnableArenas !== null) { + message.ccEnableArenas = Boolean(object.ccEnableArenas); + } else { + message.ccEnableArenas = false; + } + if ( + object.objcClassPrefix !== undefined && + object.objcClassPrefix !== null + ) { + message.objcClassPrefix = String(object.objcClassPrefix); + } else { + message.objcClassPrefix = ""; + } + if ( + object.csharpNamespace !== undefined && + object.csharpNamespace !== null + ) { + message.csharpNamespace = String(object.csharpNamespace); + } else { + message.csharpNamespace = ""; + } + if (object.swiftPrefix !== undefined && object.swiftPrefix !== null) { + message.swiftPrefix = String(object.swiftPrefix); + } else { + message.swiftPrefix = ""; + } + if (object.phpClassPrefix !== undefined && object.phpClassPrefix !== null) { + message.phpClassPrefix = String(object.phpClassPrefix); + } else { + message.phpClassPrefix = ""; + } + if (object.phpNamespace !== undefined && object.phpNamespace !== null) { + message.phpNamespace = String(object.phpNamespace); + } else { + message.phpNamespace = ""; + } + if ( + object.phpMetadataNamespace !== undefined && + object.phpMetadataNamespace !== null + ) { + message.phpMetadataNamespace = String(object.phpMetadataNamespace); + } else { + message.phpMetadataNamespace = ""; + } + if (object.rubyPackage !== undefined && object.rubyPackage !== null) { + message.rubyPackage = String(object.rubyPackage); + } else { + message.rubyPackage = ""; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: FileOptions): unknown { + const obj: any = {}; + message.javaPackage !== undefined && + (obj.javaPackage = message.javaPackage); + message.javaOuterClassname !== undefined && + (obj.javaOuterClassname = message.javaOuterClassname); + message.javaMultipleFiles !== undefined && + (obj.javaMultipleFiles = message.javaMultipleFiles); + message.javaGenerateEqualsAndHash !== undefined && + (obj.javaGenerateEqualsAndHash = message.javaGenerateEqualsAndHash); + message.javaStringCheckUtf8 !== undefined && + (obj.javaStringCheckUtf8 = message.javaStringCheckUtf8); + message.optimizeFor !== undefined && + (obj.optimizeFor = fileOptions_OptimizeModeToJSON(message.optimizeFor)); + message.goPackage !== undefined && (obj.goPackage = message.goPackage); + message.ccGenericServices !== undefined && + (obj.ccGenericServices = message.ccGenericServices); + message.javaGenericServices !== undefined && + (obj.javaGenericServices = message.javaGenericServices); + message.pyGenericServices !== undefined && + (obj.pyGenericServices = message.pyGenericServices); + message.phpGenericServices !== undefined && + (obj.phpGenericServices = message.phpGenericServices); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.ccEnableArenas !== undefined && + (obj.ccEnableArenas = message.ccEnableArenas); + message.objcClassPrefix !== undefined && + (obj.objcClassPrefix = message.objcClassPrefix); + message.csharpNamespace !== undefined && + (obj.csharpNamespace = message.csharpNamespace); + message.swiftPrefix !== undefined && + (obj.swiftPrefix = message.swiftPrefix); + message.phpClassPrefix !== undefined && + (obj.phpClassPrefix = message.phpClassPrefix); + message.phpNamespace !== undefined && + (obj.phpNamespace = message.phpNamespace); + message.phpMetadataNamespace !== undefined && + (obj.phpMetadataNamespace = message.phpMetadataNamespace); + message.rubyPackage !== undefined && + (obj.rubyPackage = message.rubyPackage); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): FileOptions { + const message = { ...baseFileOptions } as FileOptions; + message.uninterpretedOption = []; + if (object.javaPackage !== undefined && object.javaPackage !== null) { + message.javaPackage = object.javaPackage; + } else { + message.javaPackage = ""; + } + if ( + object.javaOuterClassname !== undefined && + object.javaOuterClassname !== null + ) { + message.javaOuterClassname = object.javaOuterClassname; + } else { + message.javaOuterClassname = ""; + } + if ( + object.javaMultipleFiles !== undefined && + object.javaMultipleFiles !== null + ) { + message.javaMultipleFiles = object.javaMultipleFiles; + } else { + message.javaMultipleFiles = false; + } + if ( + object.javaGenerateEqualsAndHash !== undefined && + object.javaGenerateEqualsAndHash !== null + ) { + message.javaGenerateEqualsAndHash = object.javaGenerateEqualsAndHash; + } else { + message.javaGenerateEqualsAndHash = false; + } + if ( + object.javaStringCheckUtf8 !== undefined && + object.javaStringCheckUtf8 !== null + ) { + message.javaStringCheckUtf8 = object.javaStringCheckUtf8; + } else { + message.javaStringCheckUtf8 = false; + } + if (object.optimizeFor !== undefined && object.optimizeFor !== null) { + message.optimizeFor = object.optimizeFor; + } else { + message.optimizeFor = 1; + } + if (object.goPackage !== undefined && object.goPackage !== null) { + message.goPackage = object.goPackage; + } else { + message.goPackage = ""; + } + if ( + object.ccGenericServices !== undefined && + object.ccGenericServices !== null + ) { + message.ccGenericServices = object.ccGenericServices; + } else { + message.ccGenericServices = false; + } + if ( + object.javaGenericServices !== undefined && + object.javaGenericServices !== null + ) { + message.javaGenericServices = object.javaGenericServices; + } else { + message.javaGenericServices = false; + } + if ( + object.pyGenericServices !== undefined && + object.pyGenericServices !== null + ) { + message.pyGenericServices = object.pyGenericServices; + } else { + message.pyGenericServices = false; + } + if ( + object.phpGenericServices !== undefined && + object.phpGenericServices !== null + ) { + message.phpGenericServices = object.phpGenericServices; + } else { + message.phpGenericServices = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if (object.ccEnableArenas !== undefined && object.ccEnableArenas !== null) { + message.ccEnableArenas = object.ccEnableArenas; + } else { + message.ccEnableArenas = false; + } + if ( + object.objcClassPrefix !== undefined && + object.objcClassPrefix !== null + ) { + message.objcClassPrefix = object.objcClassPrefix; + } else { + message.objcClassPrefix = ""; + } + if ( + object.csharpNamespace !== undefined && + object.csharpNamespace !== null + ) { + message.csharpNamespace = object.csharpNamespace; + } else { + message.csharpNamespace = ""; + } + if (object.swiftPrefix !== undefined && object.swiftPrefix !== null) { + message.swiftPrefix = object.swiftPrefix; + } else { + message.swiftPrefix = ""; + } + if (object.phpClassPrefix !== undefined && object.phpClassPrefix !== null) { + message.phpClassPrefix = object.phpClassPrefix; + } else { + message.phpClassPrefix = ""; + } + if (object.phpNamespace !== undefined && object.phpNamespace !== null) { + message.phpNamespace = object.phpNamespace; + } else { + message.phpNamespace = ""; + } + if ( + object.phpMetadataNamespace !== undefined && + object.phpMetadataNamespace !== null + ) { + message.phpMetadataNamespace = object.phpMetadataNamespace; + } else { + message.phpMetadataNamespace = ""; + } + if (object.rubyPackage !== undefined && object.rubyPackage !== null) { + message.rubyPackage = object.rubyPackage; + } else { + message.rubyPackage = ""; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseMessageOptions: object = { + messageSetWireFormat: false, + noStandardDescriptorAccessor: false, + deprecated: false, + mapEntry: false, +}; + +export const MessageOptions = { + encode(message: MessageOptions, writer: Writer = Writer.create()): Writer { + if (message.messageSetWireFormat === true) { + writer.uint32(8).bool(message.messageSetWireFormat); + } + if (message.noStandardDescriptorAccessor === true) { + writer.uint32(16).bool(message.noStandardDescriptorAccessor); + } + if (message.deprecated === true) { + writer.uint32(24).bool(message.deprecated); + } + if (message.mapEntry === true) { + writer.uint32(56).bool(message.mapEntry); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MessageOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMessageOptions } as MessageOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.messageSetWireFormat = reader.bool(); + break; + case 2: + message.noStandardDescriptorAccessor = reader.bool(); + break; + case 3: + message.deprecated = reader.bool(); + break; + case 7: + message.mapEntry = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MessageOptions { + const message = { ...baseMessageOptions } as MessageOptions; + message.uninterpretedOption = []; + if ( + object.messageSetWireFormat !== undefined && + object.messageSetWireFormat !== null + ) { + message.messageSetWireFormat = Boolean(object.messageSetWireFormat); + } else { + message.messageSetWireFormat = false; + } + if ( + object.noStandardDescriptorAccessor !== undefined && + object.noStandardDescriptorAccessor !== null + ) { + message.noStandardDescriptorAccessor = Boolean( + object.noStandardDescriptorAccessor + ); + } else { + message.noStandardDescriptorAccessor = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if (object.mapEntry !== undefined && object.mapEntry !== null) { + message.mapEntry = Boolean(object.mapEntry); + } else { + message.mapEntry = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: MessageOptions): unknown { + const obj: any = {}; + message.messageSetWireFormat !== undefined && + (obj.messageSetWireFormat = message.messageSetWireFormat); + message.noStandardDescriptorAccessor !== undefined && + (obj.noStandardDescriptorAccessor = message.noStandardDescriptorAccessor); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.mapEntry !== undefined && (obj.mapEntry = message.mapEntry); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): MessageOptions { + const message = { ...baseMessageOptions } as MessageOptions; + message.uninterpretedOption = []; + if ( + object.messageSetWireFormat !== undefined && + object.messageSetWireFormat !== null + ) { + message.messageSetWireFormat = object.messageSetWireFormat; + } else { + message.messageSetWireFormat = false; + } + if ( + object.noStandardDescriptorAccessor !== undefined && + object.noStandardDescriptorAccessor !== null + ) { + message.noStandardDescriptorAccessor = + object.noStandardDescriptorAccessor; + } else { + message.noStandardDescriptorAccessor = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if (object.mapEntry !== undefined && object.mapEntry !== null) { + message.mapEntry = object.mapEntry; + } else { + message.mapEntry = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseFieldOptions: object = { + ctype: 0, + packed: false, + jstype: 0, + lazy: false, + deprecated: false, + weak: false, +}; + +export const FieldOptions = { + encode(message: FieldOptions, writer: Writer = Writer.create()): Writer { + if (message.ctype !== 0) { + writer.uint32(8).int32(message.ctype); + } + if (message.packed === true) { + writer.uint32(16).bool(message.packed); + } + if (message.jstype !== 0) { + writer.uint32(48).int32(message.jstype); + } + if (message.lazy === true) { + writer.uint32(40).bool(message.lazy); + } + if (message.deprecated === true) { + writer.uint32(24).bool(message.deprecated); + } + if (message.weak === true) { + writer.uint32(80).bool(message.weak); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FieldOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFieldOptions } as FieldOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.ctype = reader.int32() as any; + break; + case 2: + message.packed = reader.bool(); + break; + case 6: + message.jstype = reader.int32() as any; + break; + case 5: + message.lazy = reader.bool(); + break; + case 3: + message.deprecated = reader.bool(); + break; + case 10: + message.weak = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FieldOptions { + const message = { ...baseFieldOptions } as FieldOptions; + message.uninterpretedOption = []; + if (object.ctype !== undefined && object.ctype !== null) { + message.ctype = fieldOptions_CTypeFromJSON(object.ctype); + } else { + message.ctype = 0; + } + if (object.packed !== undefined && object.packed !== null) { + message.packed = Boolean(object.packed); + } else { + message.packed = false; + } + if (object.jstype !== undefined && object.jstype !== null) { + message.jstype = fieldOptions_JSTypeFromJSON(object.jstype); + } else { + message.jstype = 0; + } + if (object.lazy !== undefined && object.lazy !== null) { + message.lazy = Boolean(object.lazy); + } else { + message.lazy = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if (object.weak !== undefined && object.weak !== null) { + message.weak = Boolean(object.weak); + } else { + message.weak = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: FieldOptions): unknown { + const obj: any = {}; + message.ctype !== undefined && + (obj.ctype = fieldOptions_CTypeToJSON(message.ctype)); + message.packed !== undefined && (obj.packed = message.packed); + message.jstype !== undefined && + (obj.jstype = fieldOptions_JSTypeToJSON(message.jstype)); + message.lazy !== undefined && (obj.lazy = message.lazy); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.weak !== undefined && (obj.weak = message.weak); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): FieldOptions { + const message = { ...baseFieldOptions } as FieldOptions; + message.uninterpretedOption = []; + if (object.ctype !== undefined && object.ctype !== null) { + message.ctype = object.ctype; + } else { + message.ctype = 0; + } + if (object.packed !== undefined && object.packed !== null) { + message.packed = object.packed; + } else { + message.packed = false; + } + if (object.jstype !== undefined && object.jstype !== null) { + message.jstype = object.jstype; + } else { + message.jstype = 0; + } + if (object.lazy !== undefined && object.lazy !== null) { + message.lazy = object.lazy; + } else { + message.lazy = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if (object.weak !== undefined && object.weak !== null) { + message.weak = object.weak; + } else { + message.weak = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseOneofOptions: object = {}; + +export const OneofOptions = { + encode(message: OneofOptions, writer: Writer = Writer.create()): Writer { + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): OneofOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseOneofOptions } as OneofOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): OneofOptions { + const message = { ...baseOneofOptions } as OneofOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: OneofOptions): unknown { + const obj: any = {}; + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): OneofOptions { + const message = { ...baseOneofOptions } as OneofOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseEnumOptions: object = { allowAlias: false, deprecated: false }; + +export const EnumOptions = { + encode(message: EnumOptions, writer: Writer = Writer.create()): Writer { + if (message.allowAlias === true) { + writer.uint32(16).bool(message.allowAlias); + } + if (message.deprecated === true) { + writer.uint32(24).bool(message.deprecated); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): EnumOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseEnumOptions } as EnumOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + message.allowAlias = reader.bool(); + break; + case 3: + message.deprecated = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumOptions { + const message = { ...baseEnumOptions } as EnumOptions; + message.uninterpretedOption = []; + if (object.allowAlias !== undefined && object.allowAlias !== null) { + message.allowAlias = Boolean(object.allowAlias); + } else { + message.allowAlias = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: EnumOptions): unknown { + const obj: any = {}; + message.allowAlias !== undefined && (obj.allowAlias = message.allowAlias); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): EnumOptions { + const message = { ...baseEnumOptions } as EnumOptions; + message.uninterpretedOption = []; + if (object.allowAlias !== undefined && object.allowAlias !== null) { + message.allowAlias = object.allowAlias; + } else { + message.allowAlias = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseEnumValueOptions: object = { deprecated: false }; + +export const EnumValueOptions = { + encode(message: EnumValueOptions, writer: Writer = Writer.create()): Writer { + if (message.deprecated === true) { + writer.uint32(8).bool(message.deprecated); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): EnumValueOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseEnumValueOptions } as EnumValueOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.deprecated = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumValueOptions { + const message = { ...baseEnumValueOptions } as EnumValueOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: EnumValueOptions): unknown { + const obj: any = {}; + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): EnumValueOptions { + const message = { ...baseEnumValueOptions } as EnumValueOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseServiceOptions: object = { deprecated: false }; + +export const ServiceOptions = { + encode(message: ServiceOptions, writer: Writer = Writer.create()): Writer { + if (message.deprecated === true) { + writer.uint32(264).bool(message.deprecated); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ServiceOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseServiceOptions } as ServiceOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 33: + message.deprecated = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ServiceOptions { + const message = { ...baseServiceOptions } as ServiceOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: ServiceOptions): unknown { + const obj: any = {}; + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): ServiceOptions { + const message = { ...baseServiceOptions } as ServiceOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseMethodOptions: object = { deprecated: false, idempotencyLevel: 0 }; + +export const MethodOptions = { + encode(message: MethodOptions, writer: Writer = Writer.create()): Writer { + if (message.deprecated === true) { + writer.uint32(264).bool(message.deprecated); + } + if (message.idempotencyLevel !== 0) { + writer.uint32(272).int32(message.idempotencyLevel); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MethodOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMethodOptions } as MethodOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 33: + message.deprecated = reader.bool(); + break; + case 34: + message.idempotencyLevel = reader.int32() as any; + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MethodOptions { + const message = { ...baseMethodOptions } as MethodOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.idempotencyLevel !== undefined && + object.idempotencyLevel !== null + ) { + message.idempotencyLevel = methodOptions_IdempotencyLevelFromJSON( + object.idempotencyLevel + ); + } else { + message.idempotencyLevel = 0; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: MethodOptions): unknown { + const obj: any = {}; + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.idempotencyLevel !== undefined && + (obj.idempotencyLevel = methodOptions_IdempotencyLevelToJSON( + message.idempotencyLevel + )); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): MethodOptions { + const message = { ...baseMethodOptions } as MethodOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.idempotencyLevel !== undefined && + object.idempotencyLevel !== null + ) { + message.idempotencyLevel = object.idempotencyLevel; + } else { + message.idempotencyLevel = 0; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseUninterpretedOption: object = { + identifierValue: "", + positiveIntValue: 0, + negativeIntValue: 0, + doubleValue: 0, + aggregateValue: "", +}; + +export const UninterpretedOption = { + encode( + message: UninterpretedOption, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.name) { + UninterpretedOption_NamePart.encode( + v!, + writer.uint32(18).fork() + ).ldelim(); + } + if (message.identifierValue !== "") { + writer.uint32(26).string(message.identifierValue); + } + if (message.positiveIntValue !== 0) { + writer.uint32(32).uint64(message.positiveIntValue); + } + if (message.negativeIntValue !== 0) { + writer.uint32(40).int64(message.negativeIntValue); + } + if (message.doubleValue !== 0) { + writer.uint32(49).double(message.doubleValue); + } + if (message.stringValue.length !== 0) { + writer.uint32(58).bytes(message.stringValue); + } + if (message.aggregateValue !== "") { + writer.uint32(66).string(message.aggregateValue); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): UninterpretedOption { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseUninterpretedOption } as UninterpretedOption; + message.name = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + message.name.push( + UninterpretedOption_NamePart.decode(reader, reader.uint32()) + ); + break; + case 3: + message.identifierValue = reader.string(); + break; + case 4: + message.positiveIntValue = longToNumber(reader.uint64() as Long); + break; + case 5: + message.negativeIntValue = longToNumber(reader.int64() as Long); + break; + case 6: + message.doubleValue = reader.double(); + break; + case 7: + message.stringValue = reader.bytes(); + break; + case 8: + message.aggregateValue = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): UninterpretedOption { + const message = { ...baseUninterpretedOption } as UninterpretedOption; + message.name = []; + if (object.name !== undefined && object.name !== null) { + for (const e of object.name) { + message.name.push(UninterpretedOption_NamePart.fromJSON(e)); + } + } + if ( + object.identifierValue !== undefined && + object.identifierValue !== null + ) { + message.identifierValue = String(object.identifierValue); + } else { + message.identifierValue = ""; + } + if ( + object.positiveIntValue !== undefined && + object.positiveIntValue !== null + ) { + message.positiveIntValue = Number(object.positiveIntValue); + } else { + message.positiveIntValue = 0; + } + if ( + object.negativeIntValue !== undefined && + object.negativeIntValue !== null + ) { + message.negativeIntValue = Number(object.negativeIntValue); + } else { + message.negativeIntValue = 0; + } + if (object.doubleValue !== undefined && object.doubleValue !== null) { + message.doubleValue = Number(object.doubleValue); + } else { + message.doubleValue = 0; + } + if (object.stringValue !== undefined && object.stringValue !== null) { + message.stringValue = bytesFromBase64(object.stringValue); + } + if (object.aggregateValue !== undefined && object.aggregateValue !== null) { + message.aggregateValue = String(object.aggregateValue); + } else { + message.aggregateValue = ""; + } + return message; + }, + + toJSON(message: UninterpretedOption): unknown { + const obj: any = {}; + if (message.name) { + obj.name = message.name.map((e) => + e ? UninterpretedOption_NamePart.toJSON(e) : undefined + ); + } else { + obj.name = []; + } + message.identifierValue !== undefined && + (obj.identifierValue = message.identifierValue); + message.positiveIntValue !== undefined && + (obj.positiveIntValue = message.positiveIntValue); + message.negativeIntValue !== undefined && + (obj.negativeIntValue = message.negativeIntValue); + message.doubleValue !== undefined && + (obj.doubleValue = message.doubleValue); + message.stringValue !== undefined && + (obj.stringValue = base64FromBytes( + message.stringValue !== undefined + ? message.stringValue + : new Uint8Array() + )); + message.aggregateValue !== undefined && + (obj.aggregateValue = message.aggregateValue); + return obj; + }, + + fromPartial(object: DeepPartial): UninterpretedOption { + const message = { ...baseUninterpretedOption } as UninterpretedOption; + message.name = []; + if (object.name !== undefined && object.name !== null) { + for (const e of object.name) { + message.name.push(UninterpretedOption_NamePart.fromPartial(e)); + } + } + if ( + object.identifierValue !== undefined && + object.identifierValue !== null + ) { + message.identifierValue = object.identifierValue; + } else { + message.identifierValue = ""; + } + if ( + object.positiveIntValue !== undefined && + object.positiveIntValue !== null + ) { + message.positiveIntValue = object.positiveIntValue; + } else { + message.positiveIntValue = 0; + } + if ( + object.negativeIntValue !== undefined && + object.negativeIntValue !== null + ) { + message.negativeIntValue = object.negativeIntValue; + } else { + message.negativeIntValue = 0; + } + if (object.doubleValue !== undefined && object.doubleValue !== null) { + message.doubleValue = object.doubleValue; + } else { + message.doubleValue = 0; + } + if (object.stringValue !== undefined && object.stringValue !== null) { + message.stringValue = object.stringValue; + } else { + message.stringValue = new Uint8Array(); + } + if (object.aggregateValue !== undefined && object.aggregateValue !== null) { + message.aggregateValue = object.aggregateValue; + } else { + message.aggregateValue = ""; + } + return message; + }, +}; + +const baseUninterpretedOption_NamePart: object = { + namePart: "", + isExtension: false, +}; + +export const UninterpretedOption_NamePart = { + encode( + message: UninterpretedOption_NamePart, + writer: Writer = Writer.create() + ): Writer { + if (message.namePart !== "") { + writer.uint32(10).string(message.namePart); + } + if (message.isExtension === true) { + writer.uint32(16).bool(message.isExtension); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): UninterpretedOption_NamePart { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseUninterpretedOption_NamePart, + } as UninterpretedOption_NamePart; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.namePart = reader.string(); + break; + case 2: + message.isExtension = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): UninterpretedOption_NamePart { + const message = { + ...baseUninterpretedOption_NamePart, + } as UninterpretedOption_NamePart; + if (object.namePart !== undefined && object.namePart !== null) { + message.namePart = String(object.namePart); + } else { + message.namePart = ""; + } + if (object.isExtension !== undefined && object.isExtension !== null) { + message.isExtension = Boolean(object.isExtension); + } else { + message.isExtension = false; + } + return message; + }, + + toJSON(message: UninterpretedOption_NamePart): unknown { + const obj: any = {}; + message.namePart !== undefined && (obj.namePart = message.namePart); + message.isExtension !== undefined && + (obj.isExtension = message.isExtension); + return obj; + }, + + fromPartial( + object: DeepPartial + ): UninterpretedOption_NamePart { + const message = { + ...baseUninterpretedOption_NamePart, + } as UninterpretedOption_NamePart; + if (object.namePart !== undefined && object.namePart !== null) { + message.namePart = object.namePart; + } else { + message.namePart = ""; + } + if (object.isExtension !== undefined && object.isExtension !== null) { + message.isExtension = object.isExtension; + } else { + message.isExtension = false; + } + return message; + }, +}; + +const baseSourceCodeInfo: object = {}; + +export const SourceCodeInfo = { + encode(message: SourceCodeInfo, writer: Writer = Writer.create()): Writer { + for (const v of message.location) { + SourceCodeInfo_Location.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): SourceCodeInfo { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseSourceCodeInfo } as SourceCodeInfo; + message.location = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.location.push( + SourceCodeInfo_Location.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): SourceCodeInfo { + const message = { ...baseSourceCodeInfo } as SourceCodeInfo; + message.location = []; + if (object.location !== undefined && object.location !== null) { + for (const e of object.location) { + message.location.push(SourceCodeInfo_Location.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: SourceCodeInfo): unknown { + const obj: any = {}; + if (message.location) { + obj.location = message.location.map((e) => + e ? SourceCodeInfo_Location.toJSON(e) : undefined + ); + } else { + obj.location = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): SourceCodeInfo { + const message = { ...baseSourceCodeInfo } as SourceCodeInfo; + message.location = []; + if (object.location !== undefined && object.location !== null) { + for (const e of object.location) { + message.location.push(SourceCodeInfo_Location.fromPartial(e)); + } + } + return message; + }, +}; + +const baseSourceCodeInfo_Location: object = { + path: 0, + span: 0, + leadingComments: "", + trailingComments: "", + leadingDetachedComments: "", +}; + +export const SourceCodeInfo_Location = { + encode( + message: SourceCodeInfo_Location, + writer: Writer = Writer.create() + ): Writer { + writer.uint32(10).fork(); + for (const v of message.path) { + writer.int32(v); + } + writer.ldelim(); + writer.uint32(18).fork(); + for (const v of message.span) { + writer.int32(v); + } + writer.ldelim(); + if (message.leadingComments !== "") { + writer.uint32(26).string(message.leadingComments); + } + if (message.trailingComments !== "") { + writer.uint32(34).string(message.trailingComments); + } + for (const v of message.leadingDetachedComments) { + writer.uint32(50).string(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): SourceCodeInfo_Location { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseSourceCodeInfo_Location, + } as SourceCodeInfo_Location; + message.path = []; + message.span = []; + message.leadingDetachedComments = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.path.push(reader.int32()); + } + } else { + message.path.push(reader.int32()); + } + break; + case 2: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.span.push(reader.int32()); + } + } else { + message.span.push(reader.int32()); + } + break; + case 3: + message.leadingComments = reader.string(); + break; + case 4: + message.trailingComments = reader.string(); + break; + case 6: + message.leadingDetachedComments.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): SourceCodeInfo_Location { + const message = { + ...baseSourceCodeInfo_Location, + } as SourceCodeInfo_Location; + message.path = []; + message.span = []; + message.leadingDetachedComments = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(Number(e)); + } + } + if (object.span !== undefined && object.span !== null) { + for (const e of object.span) { + message.span.push(Number(e)); + } + } + if ( + object.leadingComments !== undefined && + object.leadingComments !== null + ) { + message.leadingComments = String(object.leadingComments); + } else { + message.leadingComments = ""; + } + if ( + object.trailingComments !== undefined && + object.trailingComments !== null + ) { + message.trailingComments = String(object.trailingComments); + } else { + message.trailingComments = ""; + } + if ( + object.leadingDetachedComments !== undefined && + object.leadingDetachedComments !== null + ) { + for (const e of object.leadingDetachedComments) { + message.leadingDetachedComments.push(String(e)); + } + } + return message; + }, + + toJSON(message: SourceCodeInfo_Location): unknown { + const obj: any = {}; + if (message.path) { + obj.path = message.path.map((e) => e); + } else { + obj.path = []; + } + if (message.span) { + obj.span = message.span.map((e) => e); + } else { + obj.span = []; + } + message.leadingComments !== undefined && + (obj.leadingComments = message.leadingComments); + message.trailingComments !== undefined && + (obj.trailingComments = message.trailingComments); + if (message.leadingDetachedComments) { + obj.leadingDetachedComments = message.leadingDetachedComments.map( + (e) => e + ); + } else { + obj.leadingDetachedComments = []; + } + return obj; + }, + + fromPartial( + object: DeepPartial + ): SourceCodeInfo_Location { + const message = { + ...baseSourceCodeInfo_Location, + } as SourceCodeInfo_Location; + message.path = []; + message.span = []; + message.leadingDetachedComments = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(e); + } + } + if (object.span !== undefined && object.span !== null) { + for (const e of object.span) { + message.span.push(e); + } + } + if ( + object.leadingComments !== undefined && + object.leadingComments !== null + ) { + message.leadingComments = object.leadingComments; + } else { + message.leadingComments = ""; + } + if ( + object.trailingComments !== undefined && + object.trailingComments !== null + ) { + message.trailingComments = object.trailingComments; + } else { + message.trailingComments = ""; + } + if ( + object.leadingDetachedComments !== undefined && + object.leadingDetachedComments !== null + ) { + for (const e of object.leadingDetachedComments) { + message.leadingDetachedComments.push(e); + } + } + return message; + }, +}; + +const baseGeneratedCodeInfo: object = {}; + +export const GeneratedCodeInfo = { + encode(message: GeneratedCodeInfo, writer: Writer = Writer.create()): Writer { + for (const v of message.annotation) { + GeneratedCodeInfo_Annotation.encode( + v!, + writer.uint32(10).fork() + ).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): GeneratedCodeInfo { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseGeneratedCodeInfo } as GeneratedCodeInfo; + message.annotation = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.annotation.push( + GeneratedCodeInfo_Annotation.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GeneratedCodeInfo { + const message = { ...baseGeneratedCodeInfo } as GeneratedCodeInfo; + message.annotation = []; + if (object.annotation !== undefined && object.annotation !== null) { + for (const e of object.annotation) { + message.annotation.push(GeneratedCodeInfo_Annotation.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: GeneratedCodeInfo): unknown { + const obj: any = {}; + if (message.annotation) { + obj.annotation = message.annotation.map((e) => + e ? GeneratedCodeInfo_Annotation.toJSON(e) : undefined + ); + } else { + obj.annotation = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): GeneratedCodeInfo { + const message = { ...baseGeneratedCodeInfo } as GeneratedCodeInfo; + message.annotation = []; + if (object.annotation !== undefined && object.annotation !== null) { + for (const e of object.annotation) { + message.annotation.push(GeneratedCodeInfo_Annotation.fromPartial(e)); + } + } + return message; + }, +}; + +const baseGeneratedCodeInfo_Annotation: object = { + path: 0, + sourceFile: "", + begin: 0, + end: 0, +}; + +export const GeneratedCodeInfo_Annotation = { + encode( + message: GeneratedCodeInfo_Annotation, + writer: Writer = Writer.create() + ): Writer { + writer.uint32(10).fork(); + for (const v of message.path) { + writer.int32(v); + } + writer.ldelim(); + if (message.sourceFile !== "") { + writer.uint32(18).string(message.sourceFile); + } + if (message.begin !== 0) { + writer.uint32(24).int32(message.begin); + } + if (message.end !== 0) { + writer.uint32(32).int32(message.end); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): GeneratedCodeInfo_Annotation { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseGeneratedCodeInfo_Annotation, + } as GeneratedCodeInfo_Annotation; + message.path = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.path.push(reader.int32()); + } + } else { + message.path.push(reader.int32()); + } + break; + case 2: + message.sourceFile = reader.string(); + break; + case 3: + message.begin = reader.int32(); + break; + case 4: + message.end = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GeneratedCodeInfo_Annotation { + const message = { + ...baseGeneratedCodeInfo_Annotation, + } as GeneratedCodeInfo_Annotation; + message.path = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(Number(e)); + } + } + if (object.sourceFile !== undefined && object.sourceFile !== null) { + message.sourceFile = String(object.sourceFile); + } else { + message.sourceFile = ""; + } + if (object.begin !== undefined && object.begin !== null) { + message.begin = Number(object.begin); + } else { + message.begin = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + return message; + }, + + toJSON(message: GeneratedCodeInfo_Annotation): unknown { + const obj: any = {}; + if (message.path) { + obj.path = message.path.map((e) => e); + } else { + obj.path = []; + } + message.sourceFile !== undefined && (obj.sourceFile = message.sourceFile); + message.begin !== undefined && (obj.begin = message.begin); + message.end !== undefined && (obj.end = message.end); + return obj; + }, + + fromPartial( + object: DeepPartial + ): GeneratedCodeInfo_Annotation { + const message = { + ...baseGeneratedCodeInfo_Annotation, + } as GeneratedCodeInfo_Annotation; + message.path = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(e); + } + } + if (object.sourceFile !== undefined && object.sourceFile !== null) { + message.sourceFile = object.sourceFile; + } else { + message.sourceFile = ""; + } + if (object.begin !== undefined && object.begin !== null) { + message.begin = object.begin; + } else { + message.begin = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/bze.tokenfactory.v1/types/tokenfactory/denom_authority.ts b/ts-client/bze.tokenfactory.v1/types/tokenfactory/denom_authority.ts new file mode 100644 index 00000000..1b013c8d --- /dev/null +++ b/ts-client/bze.tokenfactory.v1/types/tokenfactory/denom_authority.ts @@ -0,0 +1,75 @@ +/* eslint-disable */ +import { Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "bze.tokenfactory.v1"; + +export interface DenomAuthority { + /** Can be empty for no admin, or a valid osmosis address */ + admin: string; +} + +const baseDenomAuthority: object = { admin: "" }; + +export const DenomAuthority = { + encode(message: DenomAuthority, writer: Writer = Writer.create()): Writer { + if (message.admin !== "") { + writer.uint32(10).string(message.admin); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): DenomAuthority { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseDenomAuthority } as DenomAuthority; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.admin = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DenomAuthority { + const message = { ...baseDenomAuthority } as DenomAuthority; + if (object.admin !== undefined && object.admin !== null) { + message.admin = String(object.admin); + } else { + message.admin = ""; + } + return message; + }, + + toJSON(message: DenomAuthority): unknown { + const obj: any = {}; + message.admin !== undefined && (obj.admin = message.admin); + return obj; + }, + + fromPartial(object: DeepPartial): DenomAuthority { + const message = { ...baseDenomAuthority } as DenomAuthority; + if (object.admin !== undefined && object.admin !== null) { + message.admin = object.admin; + } else { + message.admin = ""; + } + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/bze.tokenfactory.v1/types/tokenfactory/genesis.ts b/ts-client/bze.tokenfactory.v1/types/tokenfactory/genesis.ts new file mode 100644 index 00000000..97c93fba --- /dev/null +++ b/ts-client/bze.tokenfactory.v1/types/tokenfactory/genesis.ts @@ -0,0 +1,200 @@ +/* eslint-disable */ +import { Params } from "../tokenfactory/params"; +import { DenomAuthority } from "../tokenfactory/denom_authority"; +import { Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "bze.tokenfactory.v1"; + +/** GenesisState defines the tokenfactory module's genesis state. */ +export interface GenesisState { + params: Params | undefined; + factoryDenoms: GenesisDenom[]; +} + +/** + * GenesisDenom defines a tokenfactory denom that is defined within genesis + * state. The structure contains DenomAuthorityMetadata which defines the + * denom's admin. + */ +export interface GenesisDenom { + denom: string; + denomAuthority: DenomAuthority | undefined; +} + +const baseGenesisState: object = {}; + +export const GenesisState = { + encode(message: GenesisState, writer: Writer = Writer.create()): Writer { + if (message.params !== undefined) { + Params.encode(message.params, writer.uint32(10).fork()).ldelim(); + } + for (const v of message.factoryDenoms) { + GenesisDenom.encode(v!, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): GenesisState { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseGenesisState } as GenesisState; + message.factoryDenoms = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.params = Params.decode(reader, reader.uint32()); + break; + case 2: + message.factoryDenoms.push( + GenesisDenom.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GenesisState { + const message = { ...baseGenesisState } as GenesisState; + message.factoryDenoms = []; + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromJSON(object.params); + } else { + message.params = undefined; + } + if (object.factoryDenoms !== undefined && object.factoryDenoms !== null) { + for (const e of object.factoryDenoms) { + message.factoryDenoms.push(GenesisDenom.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: GenesisState): unknown { + const obj: any = {}; + message.params !== undefined && + (obj.params = message.params ? Params.toJSON(message.params) : undefined); + if (message.factoryDenoms) { + obj.factoryDenoms = message.factoryDenoms.map((e) => + e ? GenesisDenom.toJSON(e) : undefined + ); + } else { + obj.factoryDenoms = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): GenesisState { + const message = { ...baseGenesisState } as GenesisState; + message.factoryDenoms = []; + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromPartial(object.params); + } else { + message.params = undefined; + } + if (object.factoryDenoms !== undefined && object.factoryDenoms !== null) { + for (const e of object.factoryDenoms) { + message.factoryDenoms.push(GenesisDenom.fromPartial(e)); + } + } + return message; + }, +}; + +const baseGenesisDenom: object = { denom: "" }; + +export const GenesisDenom = { + encode(message: GenesisDenom, writer: Writer = Writer.create()): Writer { + if (message.denom !== "") { + writer.uint32(10).string(message.denom); + } + if (message.denomAuthority !== undefined) { + DenomAuthority.encode( + message.denomAuthority, + writer.uint32(18).fork() + ).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): GenesisDenom { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseGenesisDenom } as GenesisDenom; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.denom = reader.string(); + break; + case 2: + message.denomAuthority = DenomAuthority.decode( + reader, + reader.uint32() + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GenesisDenom { + const message = { ...baseGenesisDenom } as GenesisDenom; + if (object.denom !== undefined && object.denom !== null) { + message.denom = String(object.denom); + } else { + message.denom = ""; + } + if (object.denomAuthority !== undefined && object.denomAuthority !== null) { + message.denomAuthority = DenomAuthority.fromJSON(object.denomAuthority); + } else { + message.denomAuthority = undefined; + } + return message; + }, + + toJSON(message: GenesisDenom): unknown { + const obj: any = {}; + message.denom !== undefined && (obj.denom = message.denom); + message.denomAuthority !== undefined && + (obj.denomAuthority = message.denomAuthority + ? DenomAuthority.toJSON(message.denomAuthority) + : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): GenesisDenom { + const message = { ...baseGenesisDenom } as GenesisDenom; + if (object.denom !== undefined && object.denom !== null) { + message.denom = object.denom; + } else { + message.denom = ""; + } + if (object.denomAuthority !== undefined && object.denomAuthority !== null) { + message.denomAuthority = DenomAuthority.fromPartial( + object.denomAuthority + ); + } else { + message.denomAuthority = undefined; + } + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/bze.tokenfactory.v1/types/tokenfactory/params.ts b/ts-client/bze.tokenfactory.v1/types/tokenfactory/params.ts new file mode 100644 index 00000000..e5a7daae --- /dev/null +++ b/ts-client/bze.tokenfactory.v1/types/tokenfactory/params.ts @@ -0,0 +1,76 @@ +/* eslint-disable */ +import { Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "bze.tokenfactory.v1"; + +/** Params defines the parameters for the module. */ +export interface Params { + createDenomFee: string; +} + +const baseParams: object = { createDenomFee: "" }; + +export const Params = { + encode(message: Params, writer: Writer = Writer.create()): Writer { + if (message.createDenomFee !== "") { + writer.uint32(10).string(message.createDenomFee); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Params { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseParams } as Params; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.createDenomFee = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Params { + const message = { ...baseParams } as Params; + if (object.createDenomFee !== undefined && object.createDenomFee !== null) { + message.createDenomFee = String(object.createDenomFee); + } else { + message.createDenomFee = ""; + } + return message; + }, + + toJSON(message: Params): unknown { + const obj: any = {}; + message.createDenomFee !== undefined && + (obj.createDenomFee = message.createDenomFee); + return obj; + }, + + fromPartial(object: DeepPartial): Params { + const message = { ...baseParams } as Params; + if (object.createDenomFee !== undefined && object.createDenomFee !== null) { + message.createDenomFee = object.createDenomFee; + } else { + message.createDenomFee = ""; + } + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/bze.tokenfactory.v1/types/tokenfactory/query.ts b/ts-client/bze.tokenfactory.v1/types/tokenfactory/query.ts new file mode 100644 index 00000000..30ce66fa --- /dev/null +++ b/ts-client/bze.tokenfactory.v1/types/tokenfactory/query.ts @@ -0,0 +1,328 @@ +/* eslint-disable */ +import { Reader, Writer } from "protobufjs/minimal"; +import { Params } from "../tokenfactory/params"; +import { DenomAuthority } from "../tokenfactory/denom_authority"; + +export const protobufPackage = "bze.tokenfactory.v1"; + +/** QueryParamsRequest is request type for the Query/Params RPC method. */ +export interface QueryParamsRequest {} + +/** QueryParamsResponse is response type for the Query/Params RPC method. */ +export interface QueryParamsResponse { + /** params holds all the parameters of this module. */ + params: Params | undefined; +} + +export interface QueryDenomAuthorityRequest { + denom: string; +} + +export interface QueryDenomAuthorityResponse { + denomAuthority: DenomAuthority | undefined; +} + +const baseQueryParamsRequest: object = {}; + +export const QueryParamsRequest = { + encode(_: QueryParamsRequest, writer: Writer = Writer.create()): Writer { + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QueryParamsRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryParamsRequest } as QueryParamsRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): QueryParamsRequest { + const message = { ...baseQueryParamsRequest } as QueryParamsRequest; + return message; + }, + + toJSON(_: QueryParamsRequest): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial(_: DeepPartial): QueryParamsRequest { + const message = { ...baseQueryParamsRequest } as QueryParamsRequest; + return message; + }, +}; + +const baseQueryParamsResponse: object = {}; + +export const QueryParamsResponse = { + encode( + message: QueryParamsResponse, + writer: Writer = Writer.create() + ): Writer { + if (message.params !== undefined) { + Params.encode(message.params, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QueryParamsResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryParamsResponse } as QueryParamsResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.params = Params.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryParamsResponse { + const message = { ...baseQueryParamsResponse } as QueryParamsResponse; + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromJSON(object.params); + } else { + message.params = undefined; + } + return message; + }, + + toJSON(message: QueryParamsResponse): unknown { + const obj: any = {}; + message.params !== undefined && + (obj.params = message.params ? Params.toJSON(message.params) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): QueryParamsResponse { + const message = { ...baseQueryParamsResponse } as QueryParamsResponse; + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromPartial(object.params); + } else { + message.params = undefined; + } + return message; + }, +}; + +const baseQueryDenomAuthorityRequest: object = { denom: "" }; + +export const QueryDenomAuthorityRequest = { + encode( + message: QueryDenomAuthorityRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.denom !== "") { + writer.uint32(10).string(message.denom); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryDenomAuthorityRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryDenomAuthorityRequest, + } as QueryDenomAuthorityRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.denom = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryDenomAuthorityRequest { + const message = { + ...baseQueryDenomAuthorityRequest, + } as QueryDenomAuthorityRequest; + if (object.denom !== undefined && object.denom !== null) { + message.denom = String(object.denom); + } else { + message.denom = ""; + } + return message; + }, + + toJSON(message: QueryDenomAuthorityRequest): unknown { + const obj: any = {}; + message.denom !== undefined && (obj.denom = message.denom); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryDenomAuthorityRequest { + const message = { + ...baseQueryDenomAuthorityRequest, + } as QueryDenomAuthorityRequest; + if (object.denom !== undefined && object.denom !== null) { + message.denom = object.denom; + } else { + message.denom = ""; + } + return message; + }, +}; + +const baseQueryDenomAuthorityResponse: object = {}; + +export const QueryDenomAuthorityResponse = { + encode( + message: QueryDenomAuthorityResponse, + writer: Writer = Writer.create() + ): Writer { + if (message.denomAuthority !== undefined) { + DenomAuthority.encode( + message.denomAuthority, + writer.uint32(10).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryDenomAuthorityResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryDenomAuthorityResponse, + } as QueryDenomAuthorityResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.denomAuthority = DenomAuthority.decode( + reader, + reader.uint32() + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryDenomAuthorityResponse { + const message = { + ...baseQueryDenomAuthorityResponse, + } as QueryDenomAuthorityResponse; + if (object.denomAuthority !== undefined && object.denomAuthority !== null) { + message.denomAuthority = DenomAuthority.fromJSON(object.denomAuthority); + } else { + message.denomAuthority = undefined; + } + return message; + }, + + toJSON(message: QueryDenomAuthorityResponse): unknown { + const obj: any = {}; + message.denomAuthority !== undefined && + (obj.denomAuthority = message.denomAuthority + ? DenomAuthority.toJSON(message.denomAuthority) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryDenomAuthorityResponse { + const message = { + ...baseQueryDenomAuthorityResponse, + } as QueryDenomAuthorityResponse; + if (object.denomAuthority !== undefined && object.denomAuthority !== null) { + message.denomAuthority = DenomAuthority.fromPartial( + object.denomAuthority + ); + } else { + message.denomAuthority = undefined; + } + return message; + }, +}; + +/** Query defines the gRPC querier service. */ +export interface Query { + /** Parameters queries the parameters of the module. */ + Params(request: QueryParamsRequest): Promise; + /** Queries a list of QueryDenomAuthority items. */ + DenomAuthority( + request: QueryDenomAuthorityRequest + ): Promise; +} + +export class QueryClientImpl implements Query { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + } + Params(request: QueryParamsRequest): Promise { + const data = QueryParamsRequest.encode(request).finish(); + const promise = this.rpc.request( + "bze.tokenfactory.v1.Query", + "Params", + data + ); + return promise.then((data) => QueryParamsResponse.decode(new Reader(data))); + } + + DenomAuthority( + request: QueryDenomAuthorityRequest + ): Promise { + const data = QueryDenomAuthorityRequest.encode(request).finish(); + const promise = this.rpc.request( + "bze.tokenfactory.v1.Query", + "DenomAuthority", + data + ); + return promise.then((data) => + QueryDenomAuthorityResponse.decode(new Reader(data)) + ); + } +} + +interface Rpc { + request( + service: string, + method: string, + data: Uint8Array + ): Promise; +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/bze.tokenfactory.v1/types/tokenfactory/tx.ts b/ts-client/bze.tokenfactory.v1/types/tokenfactory/tx.ts new file mode 100644 index 00000000..0f6ec95a --- /dev/null +++ b/ts-client/bze.tokenfactory.v1/types/tokenfactory/tx.ts @@ -0,0 +1,739 @@ +/* eslint-disable */ +import { Reader, Writer } from "protobufjs/minimal"; +import { Metadata } from "../cosmos/bank/v1beta1/bank"; + +export const protobufPackage = "bze.tokenfactory.v1"; + +export interface MsgCreateDenom { + creator: string; + subdenom: string; +} + +export interface MsgCreateDenomResponse { + newDenom: string; +} + +export interface MsgMint { + creator: string; + coins: string; +} + +export interface MsgMintResponse {} + +export interface MsgBurn { + creator: string; + coins: string; +} + +export interface MsgBurnResponse {} + +export interface MsgChangeAdmin { + creator: string; + denom: string; + newAdmin: string; +} + +export interface MsgChangeAdminResponse {} + +export interface MsgSetDenomMetadata { + creator: string; + metadata: Metadata | undefined; +} + +export interface MsgSetDenomMetadataResponse {} + +const baseMsgCreateDenom: object = { creator: "", subdenom: "" }; + +export const MsgCreateDenom = { + encode(message: MsgCreateDenom, writer: Writer = Writer.create()): Writer { + if (message.creator !== "") { + writer.uint32(10).string(message.creator); + } + if (message.subdenom !== "") { + writer.uint32(18).string(message.subdenom); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MsgCreateDenom { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgCreateDenom } as MsgCreateDenom; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.creator = reader.string(); + break; + case 2: + message.subdenom = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgCreateDenom { + const message = { ...baseMsgCreateDenom } as MsgCreateDenom; + if (object.creator !== undefined && object.creator !== null) { + message.creator = String(object.creator); + } else { + message.creator = ""; + } + if (object.subdenom !== undefined && object.subdenom !== null) { + message.subdenom = String(object.subdenom); + } else { + message.subdenom = ""; + } + return message; + }, + + toJSON(message: MsgCreateDenom): unknown { + const obj: any = {}; + message.creator !== undefined && (obj.creator = message.creator); + message.subdenom !== undefined && (obj.subdenom = message.subdenom); + return obj; + }, + + fromPartial(object: DeepPartial): MsgCreateDenom { + const message = { ...baseMsgCreateDenom } as MsgCreateDenom; + if (object.creator !== undefined && object.creator !== null) { + message.creator = object.creator; + } else { + message.creator = ""; + } + if (object.subdenom !== undefined && object.subdenom !== null) { + message.subdenom = object.subdenom; + } else { + message.subdenom = ""; + } + return message; + }, +}; + +const baseMsgCreateDenomResponse: object = { newDenom: "" }; + +export const MsgCreateDenomResponse = { + encode( + message: MsgCreateDenomResponse, + writer: Writer = Writer.create() + ): Writer { + if (message.newDenom !== "") { + writer.uint32(10).string(message.newDenom); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MsgCreateDenomResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgCreateDenomResponse } as MsgCreateDenomResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.newDenom = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgCreateDenomResponse { + const message = { ...baseMsgCreateDenomResponse } as MsgCreateDenomResponse; + if (object.newDenom !== undefined && object.newDenom !== null) { + message.newDenom = String(object.newDenom); + } else { + message.newDenom = ""; + } + return message; + }, + + toJSON(message: MsgCreateDenomResponse): unknown { + const obj: any = {}; + message.newDenom !== undefined && (obj.newDenom = message.newDenom); + return obj; + }, + + fromPartial( + object: DeepPartial + ): MsgCreateDenomResponse { + const message = { ...baseMsgCreateDenomResponse } as MsgCreateDenomResponse; + if (object.newDenom !== undefined && object.newDenom !== null) { + message.newDenom = object.newDenom; + } else { + message.newDenom = ""; + } + return message; + }, +}; + +const baseMsgMint: object = { creator: "", coins: "" }; + +export const MsgMint = { + encode(message: MsgMint, writer: Writer = Writer.create()): Writer { + if (message.creator !== "") { + writer.uint32(10).string(message.creator); + } + if (message.coins !== "") { + writer.uint32(18).string(message.coins); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MsgMint { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgMint } as MsgMint; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.creator = reader.string(); + break; + case 2: + message.coins = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgMint { + const message = { ...baseMsgMint } as MsgMint; + if (object.creator !== undefined && object.creator !== null) { + message.creator = String(object.creator); + } else { + message.creator = ""; + } + if (object.coins !== undefined && object.coins !== null) { + message.coins = String(object.coins); + } else { + message.coins = ""; + } + return message; + }, + + toJSON(message: MsgMint): unknown { + const obj: any = {}; + message.creator !== undefined && (obj.creator = message.creator); + message.coins !== undefined && (obj.coins = message.coins); + return obj; + }, + + fromPartial(object: DeepPartial): MsgMint { + const message = { ...baseMsgMint } as MsgMint; + if (object.creator !== undefined && object.creator !== null) { + message.creator = object.creator; + } else { + message.creator = ""; + } + if (object.coins !== undefined && object.coins !== null) { + message.coins = object.coins; + } else { + message.coins = ""; + } + return message; + }, +}; + +const baseMsgMintResponse: object = {}; + +export const MsgMintResponse = { + encode(_: MsgMintResponse, writer: Writer = Writer.create()): Writer { + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MsgMintResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgMintResponse } as MsgMintResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): MsgMintResponse { + const message = { ...baseMsgMintResponse } as MsgMintResponse; + return message; + }, + + toJSON(_: MsgMintResponse): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial(_: DeepPartial): MsgMintResponse { + const message = { ...baseMsgMintResponse } as MsgMintResponse; + return message; + }, +}; + +const baseMsgBurn: object = { creator: "", coins: "" }; + +export const MsgBurn = { + encode(message: MsgBurn, writer: Writer = Writer.create()): Writer { + if (message.creator !== "") { + writer.uint32(10).string(message.creator); + } + if (message.coins !== "") { + writer.uint32(18).string(message.coins); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MsgBurn { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgBurn } as MsgBurn; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.creator = reader.string(); + break; + case 2: + message.coins = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgBurn { + const message = { ...baseMsgBurn } as MsgBurn; + if (object.creator !== undefined && object.creator !== null) { + message.creator = String(object.creator); + } else { + message.creator = ""; + } + if (object.coins !== undefined && object.coins !== null) { + message.coins = String(object.coins); + } else { + message.coins = ""; + } + return message; + }, + + toJSON(message: MsgBurn): unknown { + const obj: any = {}; + message.creator !== undefined && (obj.creator = message.creator); + message.coins !== undefined && (obj.coins = message.coins); + return obj; + }, + + fromPartial(object: DeepPartial): MsgBurn { + const message = { ...baseMsgBurn } as MsgBurn; + if (object.creator !== undefined && object.creator !== null) { + message.creator = object.creator; + } else { + message.creator = ""; + } + if (object.coins !== undefined && object.coins !== null) { + message.coins = object.coins; + } else { + message.coins = ""; + } + return message; + }, +}; + +const baseMsgBurnResponse: object = {}; + +export const MsgBurnResponse = { + encode(_: MsgBurnResponse, writer: Writer = Writer.create()): Writer { + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MsgBurnResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgBurnResponse } as MsgBurnResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): MsgBurnResponse { + const message = { ...baseMsgBurnResponse } as MsgBurnResponse; + return message; + }, + + toJSON(_: MsgBurnResponse): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial(_: DeepPartial): MsgBurnResponse { + const message = { ...baseMsgBurnResponse } as MsgBurnResponse; + return message; + }, +}; + +const baseMsgChangeAdmin: object = { creator: "", denom: "", newAdmin: "" }; + +export const MsgChangeAdmin = { + encode(message: MsgChangeAdmin, writer: Writer = Writer.create()): Writer { + if (message.creator !== "") { + writer.uint32(10).string(message.creator); + } + if (message.denom !== "") { + writer.uint32(18).string(message.denom); + } + if (message.newAdmin !== "") { + writer.uint32(26).string(message.newAdmin); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MsgChangeAdmin { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgChangeAdmin } as MsgChangeAdmin; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.creator = reader.string(); + break; + case 2: + message.denom = reader.string(); + break; + case 3: + message.newAdmin = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgChangeAdmin { + const message = { ...baseMsgChangeAdmin } as MsgChangeAdmin; + if (object.creator !== undefined && object.creator !== null) { + message.creator = String(object.creator); + } else { + message.creator = ""; + } + if (object.denom !== undefined && object.denom !== null) { + message.denom = String(object.denom); + } else { + message.denom = ""; + } + if (object.newAdmin !== undefined && object.newAdmin !== null) { + message.newAdmin = String(object.newAdmin); + } else { + message.newAdmin = ""; + } + return message; + }, + + toJSON(message: MsgChangeAdmin): unknown { + const obj: any = {}; + message.creator !== undefined && (obj.creator = message.creator); + message.denom !== undefined && (obj.denom = message.denom); + message.newAdmin !== undefined && (obj.newAdmin = message.newAdmin); + return obj; + }, + + fromPartial(object: DeepPartial): MsgChangeAdmin { + const message = { ...baseMsgChangeAdmin } as MsgChangeAdmin; + if (object.creator !== undefined && object.creator !== null) { + message.creator = object.creator; + } else { + message.creator = ""; + } + if (object.denom !== undefined && object.denom !== null) { + message.denom = object.denom; + } else { + message.denom = ""; + } + if (object.newAdmin !== undefined && object.newAdmin !== null) { + message.newAdmin = object.newAdmin; + } else { + message.newAdmin = ""; + } + return message; + }, +}; + +const baseMsgChangeAdminResponse: object = {}; + +export const MsgChangeAdminResponse = { + encode(_: MsgChangeAdminResponse, writer: Writer = Writer.create()): Writer { + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MsgChangeAdminResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgChangeAdminResponse } as MsgChangeAdminResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): MsgChangeAdminResponse { + const message = { ...baseMsgChangeAdminResponse } as MsgChangeAdminResponse; + return message; + }, + + toJSON(_: MsgChangeAdminResponse): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial(_: DeepPartial): MsgChangeAdminResponse { + const message = { ...baseMsgChangeAdminResponse } as MsgChangeAdminResponse; + return message; + }, +}; + +const baseMsgSetDenomMetadata: object = { creator: "" }; + +export const MsgSetDenomMetadata = { + encode( + message: MsgSetDenomMetadata, + writer: Writer = Writer.create() + ): Writer { + if (message.creator !== "") { + writer.uint32(10).string(message.creator); + } + if (message.metadata !== undefined) { + Metadata.encode(message.metadata, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MsgSetDenomMetadata { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgSetDenomMetadata } as MsgSetDenomMetadata; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.creator = reader.string(); + break; + case 2: + message.metadata = Metadata.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgSetDenomMetadata { + const message = { ...baseMsgSetDenomMetadata } as MsgSetDenomMetadata; + if (object.creator !== undefined && object.creator !== null) { + message.creator = String(object.creator); + } else { + message.creator = ""; + } + if (object.metadata !== undefined && object.metadata !== null) { + message.metadata = Metadata.fromJSON(object.metadata); + } else { + message.metadata = undefined; + } + return message; + }, + + toJSON(message: MsgSetDenomMetadata): unknown { + const obj: any = {}; + message.creator !== undefined && (obj.creator = message.creator); + message.metadata !== undefined && + (obj.metadata = message.metadata + ? Metadata.toJSON(message.metadata) + : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): MsgSetDenomMetadata { + const message = { ...baseMsgSetDenomMetadata } as MsgSetDenomMetadata; + if (object.creator !== undefined && object.creator !== null) { + message.creator = object.creator; + } else { + message.creator = ""; + } + if (object.metadata !== undefined && object.metadata !== null) { + message.metadata = Metadata.fromPartial(object.metadata); + } else { + message.metadata = undefined; + } + return message; + }, +}; + +const baseMsgSetDenomMetadataResponse: object = {}; + +export const MsgSetDenomMetadataResponse = { + encode( + _: MsgSetDenomMetadataResponse, + writer: Writer = Writer.create() + ): Writer { + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): MsgSetDenomMetadataResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseMsgSetDenomMetadataResponse, + } as MsgSetDenomMetadataResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): MsgSetDenomMetadataResponse { + const message = { + ...baseMsgSetDenomMetadataResponse, + } as MsgSetDenomMetadataResponse; + return message; + }, + + toJSON(_: MsgSetDenomMetadataResponse): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial( + _: DeepPartial + ): MsgSetDenomMetadataResponse { + const message = { + ...baseMsgSetDenomMetadataResponse, + } as MsgSetDenomMetadataResponse; + return message; + }, +}; + +/** Msg defines the Msg service. */ +export interface Msg { + CreateDenom(request: MsgCreateDenom): Promise; + Mint(request: MsgMint): Promise; + Burn(request: MsgBurn): Promise; + ChangeAdmin(request: MsgChangeAdmin): Promise; + /** this line is used by starport scaffolding # proto/tx/rpc */ + SetDenomMetadata( + request: MsgSetDenomMetadata + ): Promise; +} + +export class MsgClientImpl implements Msg { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + } + CreateDenom(request: MsgCreateDenom): Promise { + const data = MsgCreateDenom.encode(request).finish(); + const promise = this.rpc.request( + "bze.tokenfactory.v1.Msg", + "CreateDenom", + data + ); + return promise.then((data) => + MsgCreateDenomResponse.decode(new Reader(data)) + ); + } + + Mint(request: MsgMint): Promise { + const data = MsgMint.encode(request).finish(); + const promise = this.rpc.request("bze.tokenfactory.v1.Msg", "Mint", data); + return promise.then((data) => MsgMintResponse.decode(new Reader(data))); + } + + Burn(request: MsgBurn): Promise { + const data = MsgBurn.encode(request).finish(); + const promise = this.rpc.request("bze.tokenfactory.v1.Msg", "Burn", data); + return promise.then((data) => MsgBurnResponse.decode(new Reader(data))); + } + + ChangeAdmin(request: MsgChangeAdmin): Promise { + const data = MsgChangeAdmin.encode(request).finish(); + const promise = this.rpc.request( + "bze.tokenfactory.v1.Msg", + "ChangeAdmin", + data + ); + return promise.then((data) => + MsgChangeAdminResponse.decode(new Reader(data)) + ); + } + + SetDenomMetadata( + request: MsgSetDenomMetadata + ): Promise { + const data = MsgSetDenomMetadata.encode(request).finish(); + const promise = this.rpc.request( + "bze.tokenfactory.v1.Msg", + "SetDenomMetadata", + data + ); + return promise.then((data) => + MsgSetDenomMetadataResponse.decode(new Reader(data)) + ); + } +} + +interface Rpc { + request( + service: string, + method: string, + data: Uint8Array + ): Promise; +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/bze.tradebin.v1/index.ts b/ts-client/bze.tradebin.v1/index.ts new file mode 100755 index 00000000..c9dfa159 --- /dev/null +++ b/ts-client/bze.tradebin.v1/index.ts @@ -0,0 +1,6 @@ +import Module from './module'; +import { txClient, queryClient, registry } from './module'; +import { msgTypes } from './registry'; + +export * from "./types"; +export { Module, msgTypes, txClient, queryClient, registry }; diff --git a/ts-client/bze.tradebin.v1/module.ts b/ts-client/bze.tradebin.v1/module.ts new file mode 100755 index 00000000..b1e2403b --- /dev/null +++ b/ts-client/bze.tradebin.v1/module.ts @@ -0,0 +1,165 @@ +// Generated by Ignite ignite.com/cli + +import { StdFee } from "@cosmjs/launchpad"; +import { SigningStargateClient, DeliverTxResponse } from "@cosmjs/stargate"; +import { EncodeObject, GeneratedType, OfflineSigner, Registry } from "@cosmjs/proto-signing"; +import { msgTypes } from './registry'; +import { IgniteClient } from "../client" +import { MissingWalletError } from "../helpers" +import { Api } from "./rest"; +import { MsgCreateMarket } from "./types/tradebin/tx"; +import { MsgCancelOrder } from "./types/tradebin/tx"; +import { MsgCreateOrder } from "./types/tradebin/tx"; + + +export { MsgCreateMarket, MsgCancelOrder, MsgCreateOrder }; + +type sendMsgCreateMarketParams = { + value: MsgCreateMarket, + fee?: StdFee, + memo?: string +}; + +type sendMsgCancelOrderParams = { + value: MsgCancelOrder, + fee?: StdFee, + memo?: string +}; + +type sendMsgCreateOrderParams = { + value: MsgCreateOrder, + fee?: StdFee, + memo?: string +}; + + +type msgCreateMarketParams = { + value: MsgCreateMarket, +}; + +type msgCancelOrderParams = { + value: MsgCancelOrder, +}; + +type msgCreateOrderParams = { + value: MsgCreateOrder, +}; + + +export const registry = new Registry(msgTypes); + +const defaultFee = { + amount: [], + gas: "200000", +}; + +interface TxClientOptions { + addr: string + prefix: string + signer?: OfflineSigner +} + +export const txClient = ({ signer, prefix, addr }: TxClientOptions = { addr: "http://localhost:26657", prefix: "cosmos" }) => { + + return { + + async sendMsgCreateMarket({ value, fee, memo }: sendMsgCreateMarketParams): Promise { + if (!signer) { + throw new Error('TxClient:sendMsgCreateMarket: Unable to sign Tx. Signer is not present.') + } + try { + const { address } = (await signer.getAccounts())[0]; + const signingClient = await SigningStargateClient.connectWithSigner(addr,signer,{registry, prefix}); + let msg = this.msgCreateMarket({ value: MsgCreateMarket.fromPartial(value) }) + return await signingClient.signAndBroadcast(address, [msg], fee ? fee : defaultFee, memo) + } catch (e: any) { + throw new Error('TxClient:sendMsgCreateMarket: Could not broadcast Tx: '+ e.message) + } + }, + + async sendMsgCancelOrder({ value, fee, memo }: sendMsgCancelOrderParams): Promise { + if (!signer) { + throw new Error('TxClient:sendMsgCancelOrder: Unable to sign Tx. Signer is not present.') + } + try { + const { address } = (await signer.getAccounts())[0]; + const signingClient = await SigningStargateClient.connectWithSigner(addr,signer,{registry, prefix}); + let msg = this.msgCancelOrder({ value: MsgCancelOrder.fromPartial(value) }) + return await signingClient.signAndBroadcast(address, [msg], fee ? fee : defaultFee, memo) + } catch (e: any) { + throw new Error('TxClient:sendMsgCancelOrder: Could not broadcast Tx: '+ e.message) + } + }, + + async sendMsgCreateOrder({ value, fee, memo }: sendMsgCreateOrderParams): Promise { + if (!signer) { + throw new Error('TxClient:sendMsgCreateOrder: Unable to sign Tx. Signer is not present.') + } + try { + const { address } = (await signer.getAccounts())[0]; + const signingClient = await SigningStargateClient.connectWithSigner(addr,signer,{registry, prefix}); + let msg = this.msgCreateOrder({ value: MsgCreateOrder.fromPartial(value) }) + return await signingClient.signAndBroadcast(address, [msg], fee ? fee : defaultFee, memo) + } catch (e: any) { + throw new Error('TxClient:sendMsgCreateOrder: Could not broadcast Tx: '+ e.message) + } + }, + + + msgCreateMarket({ value }: msgCreateMarketParams): EncodeObject { + try { + return { typeUrl: "/bze.tradebin.v1.MsgCreateMarket", value: MsgCreateMarket.fromPartial( value ) } + } catch (e: any) { + throw new Error('TxClient:MsgCreateMarket: Could not create message: ' + e.message) + } + }, + + msgCancelOrder({ value }: msgCancelOrderParams): EncodeObject { + try { + return { typeUrl: "/bze.tradebin.v1.MsgCancelOrder", value: MsgCancelOrder.fromPartial( value ) } + } catch (e: any) { + throw new Error('TxClient:MsgCancelOrder: Could not create message: ' + e.message) + } + }, + + msgCreateOrder({ value }: msgCreateOrderParams): EncodeObject { + try { + return { typeUrl: "/bze.tradebin.v1.MsgCreateOrder", value: MsgCreateOrder.fromPartial( value ) } + } catch (e: any) { + throw new Error('TxClient:MsgCreateOrder: Could not create message: ' + e.message) + } + }, + + } +}; + +interface QueryClientOptions { + addr: string +} + +export const queryClient = ({ addr: addr }: QueryClientOptions = { addr: "http://localhost:1317" }) => { + return new Api({ baseUrl: addr }); +}; + +class SDKModule { + public query: ReturnType; + public tx: ReturnType; + + public registry: Array<[string, GeneratedType]>; + + constructor(client: IgniteClient) { + + this.query = queryClient({ addr: client.env.apiURL }); + this.tx = txClient({ signer: client.signer, addr: client.env.rpcURL, prefix: client.env.prefix ?? "cosmos" }); + } +}; + +const Module = (test: IgniteClient) => { + return { + module: { + BzeTradebinV1: new SDKModule(test) + }, + registry: msgTypes + } +} +export default Module; \ No newline at end of file diff --git a/ts-client/bze.tradebin.v1/registry.ts b/ts-client/bze.tradebin.v1/registry.ts new file mode 100755 index 00000000..86d91676 --- /dev/null +++ b/ts-client/bze.tradebin.v1/registry.ts @@ -0,0 +1,13 @@ +import { GeneratedType } from "@cosmjs/proto-signing"; +import { MsgCreateMarket } from "./types/tradebin/tx"; +import { MsgCancelOrder } from "./types/tradebin/tx"; +import { MsgCreateOrder } from "./types/tradebin/tx"; + +const msgTypes: Array<[string, GeneratedType]> = [ + ["/bze.tradebin.v1.MsgCreateMarket", MsgCreateMarket], + ["/bze.tradebin.v1.MsgCancelOrder", MsgCancelOrder], + ["/bze.tradebin.v1.MsgCreateOrder", MsgCreateOrder], + +]; + +export { msgTypes } \ No newline at end of file diff --git a/ts-client/bze.tradebin.v1/rest.ts b/ts-client/bze.tradebin.v1/rest.ts new file mode 100644 index 00000000..398b245d --- /dev/null +++ b/ts-client/bze.tradebin.v1/rest.ts @@ -0,0 +1,601 @@ +/* eslint-disable */ +/* tslint:disable */ +/* + * --------------------------------------------------------------- + * ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ## + * ## ## + * ## AUTHOR: acacode ## + * ## SOURCE: https://github.com/acacode/swagger-typescript-api ## + * --------------------------------------------------------------- + */ + +export interface ProtobufAny { + "@type"?: string; +} + +export interface RpcStatus { + /** @format int32 */ + code?: number; + message?: string; + details?: ProtobufAny[]; +} + +export interface Tradebinv1Market { + base?: string; + quote?: string; + creator?: string; +} + +/** + * Params defines the parameters for the module. + */ +export interface Tradebinv1Params { + createMarketFee?: string; + marketMakerFee?: string; + marketTakerFee?: string; + makerFeeDestination?: string; + takerFeeDestination?: string; +} + +export interface V1AggregatedOrder { + market_id?: string; + order_type?: string; + amount?: string; + price?: string; +} + +export interface V1HistoryOrder { + market_id?: string; + order_type?: string; + amount?: string; + price?: string; + + /** @format int64 */ + executed_at?: string; + maker?: string; + taker?: string; +} + +export type V1MsgCancelOrderResponse = object; + +export type V1MsgCreateMarketResponse = object; + +export type V1MsgCreateOrderResponse = object; + +export interface V1Order { + id?: string; + market_id?: string; + order_type?: string; + amount?: string; + price?: string; + + /** @format int64 */ + created_at?: string; + owner?: string; +} + +export interface V1OrderReference { + id?: string; + market_id?: string; + order_type?: string; +} + +export interface V1QueryAllMarketResponse { + market?: Tradebinv1Market[]; + + /** + * PageResponse is to be embedded in gRPC response messages where the + * corresponding request message has used PageRequest. + * + * message SomeResponse { + * repeated Bar results = 1; + * PageResponse page = 2; + * } + */ + pagination?: V1Beta1PageResponse; +} + +export interface V1QueryAssetMarketsResponse { + base?: Tradebinv1Market[]; + quote?: Tradebinv1Market[]; +} + +export interface V1QueryGetMarketResponse { + market?: Tradebinv1Market; +} + +export interface V1QueryMarketAggregatedOrdersResponse { + list?: V1AggregatedOrder[]; + + /** + * PageResponse is to be embedded in gRPC response messages where the + * corresponding request message has used PageRequest. + * + * message SomeResponse { + * repeated Bar results = 1; + * PageResponse page = 2; + * } + */ + pagination?: V1Beta1PageResponse; +} + +export interface V1QueryMarketHistoryResponse { + list?: V1HistoryOrder[]; + + /** + * PageResponse is to be embedded in gRPC response messages where the + * corresponding request message has used PageRequest. + * + * message SomeResponse { + * repeated Bar results = 1; + * PageResponse page = 2; + * } + */ + pagination?: V1Beta1PageResponse; +} + +export interface V1QueryMarketOrderResponse { + order?: V1Order; +} + +/** + * QueryParamsResponse is response type for the Query/Params RPC method. + */ +export interface V1QueryParamsResponse { + /** params holds all the parameters of this module. */ + params?: Tradebinv1Params; +} + +export interface V1QueryUserMarketOrdersResponse { + list?: V1OrderReference[]; + + /** + * PageResponse is to be embedded in gRPC response messages where the + * corresponding request message has used PageRequest. + * + * message SomeResponse { + * repeated Bar results = 1; + * PageResponse page = 2; + * } + */ + pagination?: V1Beta1PageResponse; +} + +/** +* message SomeRequest { + Foo some_parameter = 1; + PageRequest pagination = 2; + } +*/ +export interface V1Beta1PageRequest { + /** + * key is a value returned in PageResponse.next_key to begin + * querying the next page most efficiently. Only one of offset or key + * should be set. + * @format byte + */ + key?: string; + + /** + * offset is a numeric offset that can be used when key is unavailable. + * It is less efficient than using key. Only one of offset or key should + * be set. + * @format uint64 + */ + offset?: string; + + /** + * limit is the total number of results to be returned in the result page. + * If left empty it will default to a value to be set by each app. + * @format uint64 + */ + limit?: string; + + /** + * count_total is set to true to indicate that the result set should include + * a count of the total number of items available for pagination in UIs. + * count_total is only respected when offset is used. It is ignored when key + * is set. + */ + count_total?: boolean; + + /** + * reverse is set to true if results are to be returned in the descending order. + * + * Since: cosmos-sdk 0.43 + */ + reverse?: boolean; +} + +/** +* PageResponse is to be embedded in gRPC response messages where the +corresponding request message has used PageRequest. + + message SomeResponse { + repeated Bar results = 1; + PageResponse page = 2; + } +*/ +export interface V1Beta1PageResponse { + /** @format byte */ + next_key?: string; + + /** @format uint64 */ + total?: string; +} + +export type QueryParamsType = Record; +export type ResponseFormat = keyof Omit; + +export interface FullRequestParams extends Omit { + /** set parameter to `true` for call `securityWorker` for this request */ + secure?: boolean; + /** request path */ + path: string; + /** content type of request body */ + type?: ContentType; + /** query params */ + query?: QueryParamsType; + /** format of response (i.e. response.json() -> format: "json") */ + format?: keyof Omit; + /** request body */ + body?: unknown; + /** base url */ + baseUrl?: string; + /** request cancellation token */ + cancelToken?: CancelToken; +} + +export type RequestParams = Omit; + +export interface ApiConfig { + baseUrl?: string; + baseApiParams?: Omit; + securityWorker?: (securityData: SecurityDataType) => RequestParams | void; +} + +export interface HttpResponse extends Response { + data: D; + error: E; +} + +type CancelToken = Symbol | string | number; + +export enum ContentType { + Json = "application/json", + FormData = "multipart/form-data", + UrlEncoded = "application/x-www-form-urlencoded", +} + +export class HttpClient { + public baseUrl: string = ""; + private securityData: SecurityDataType = null as any; + private securityWorker: null | ApiConfig["securityWorker"] = null; + private abortControllers = new Map(); + + private baseApiParams: RequestParams = { + credentials: "same-origin", + headers: {}, + redirect: "follow", + referrerPolicy: "no-referrer", + }; + + constructor(apiConfig: ApiConfig = {}) { + Object.assign(this, apiConfig); + } + + public setSecurityData = (data: SecurityDataType) => { + this.securityData = data; + }; + + private addQueryParam(query: QueryParamsType, key: string) { + const value = query[key]; + + return ( + encodeURIComponent(key) + + "=" + + encodeURIComponent(Array.isArray(value) ? value.join(",") : typeof value === "number" ? value : `${value}`) + ); + } + + protected toQueryString(rawQuery?: QueryParamsType): string { + const query = rawQuery || {}; + const keys = Object.keys(query).filter((key) => "undefined" !== typeof query[key]); + return keys + .map((key) => + typeof query[key] === "object" && !Array.isArray(query[key]) + ? this.toQueryString(query[key] as QueryParamsType) + : this.addQueryParam(query, key), + ) + .join("&"); + } + + protected addQueryParams(rawQuery?: QueryParamsType): string { + const queryString = this.toQueryString(rawQuery); + return queryString ? `?${queryString}` : ""; + } + + private contentFormatters: Record any> = { + [ContentType.Json]: (input: any) => + input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input, + [ContentType.FormData]: (input: any) => + Object.keys(input || {}).reduce((data, key) => { + data.append(key, input[key]); + return data; + }, new FormData()), + [ContentType.UrlEncoded]: (input: any) => this.toQueryString(input), + }; + + private mergeRequestParams(params1: RequestParams, params2?: RequestParams): RequestParams { + return { + ...this.baseApiParams, + ...params1, + ...(params2 || {}), + headers: { + ...(this.baseApiParams.headers || {}), + ...(params1.headers || {}), + ...((params2 && params2.headers) || {}), + }, + }; + } + + private createAbortSignal = (cancelToken: CancelToken): AbortSignal | undefined => { + if (this.abortControllers.has(cancelToken)) { + const abortController = this.abortControllers.get(cancelToken); + if (abortController) { + return abortController.signal; + } + return void 0; + } + + const abortController = new AbortController(); + this.abortControllers.set(cancelToken, abortController); + return abortController.signal; + }; + + public abortRequest = (cancelToken: CancelToken) => { + const abortController = this.abortControllers.get(cancelToken); + + if (abortController) { + abortController.abort(); + this.abortControllers.delete(cancelToken); + } + }; + + public request = ({ + body, + secure, + path, + type, + query, + format = "json", + baseUrl, + cancelToken, + ...params + }: FullRequestParams): Promise> => { + const secureParams = (secure && this.securityWorker && this.securityWorker(this.securityData)) || {}; + const requestParams = this.mergeRequestParams(params, secureParams); + const queryString = query && this.toQueryString(query); + const payloadFormatter = this.contentFormatters[type || ContentType.Json]; + + return fetch(`${baseUrl || this.baseUrl || ""}${path}${queryString ? `?${queryString}` : ""}`, { + ...requestParams, + headers: { + ...(type && type !== ContentType.FormData ? { "Content-Type": type } : {}), + ...(requestParams.headers || {}), + }, + signal: cancelToken ? this.createAbortSignal(cancelToken) : void 0, + body: typeof body === "undefined" || body === null ? null : payloadFormatter(body), + }).then(async (response) => { + const r = response as HttpResponse; + r.data = (null as unknown) as T; + r.error = (null as unknown) as E; + + const data = await response[format]() + .then((data) => { + if (r.ok) { + r.data = data; + } else { + r.error = data; + } + return r; + }) + .catch((e) => { + r.error = e; + return r; + }); + + if (cancelToken) { + this.abortControllers.delete(cancelToken); + } + + if (!response.ok) throw data; + return data; + }); + }; +} + +/** + * @title tradebin/events.proto + * @version version not set + */ +export class Api extends HttpClient { + /** + * No description + * + * @tags Query + * @name QueryMarketAll + * @summary Queries a list of Market items. + * @request GET:/bze/tradebin/v1/all_markets + */ + queryMarketAll = ( + query?: { + "pagination.key"?: string; + "pagination.offset"?: string; + "pagination.limit"?: string; + "pagination.count_total"?: boolean; + "pagination.reverse"?: boolean; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/bze/tradebin/v1/all_markets`, + method: "GET", + query: query, + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Query + * @name QueryAssetMarkets + * @summary Queries a list of AssetMarkets items. + * @request GET:/bze/tradebin/v1/asset_markets + */ + queryAssetMarkets = (query?: { asset?: string }, params: RequestParams = {}) => + this.request({ + path: `/bze/tradebin/v1/asset_markets`, + method: "GET", + query: query, + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Query + * @name QueryMarket + * @summary Queries a Market by index. + * @request GET:/bze/tradebin/v1/market + */ + queryMarket = (query?: { base?: string; quote?: string }, params: RequestParams = {}) => + this.request({ + path: `/bze/tradebin/v1/market`, + method: "GET", + query: query, + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Query + * @name QueryMarketAggregatedOrders + * @summary Queries a list of MarketAggregatedOrders items. + * @request GET:/bze/tradebin/v1/market_aggregated_orders + */ + queryMarketAggregatedOrders = ( + query?: { + market?: string; + order_type?: string; + "pagination.key"?: string; + "pagination.offset"?: string; + "pagination.limit"?: string; + "pagination.count_total"?: boolean; + "pagination.reverse"?: boolean; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/bze/tradebin/v1/market_aggregated_orders`, + method: "GET", + query: query, + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Query + * @name QueryMarketHistory + * @summary Queries a list of MarketHistory items. + * @request GET:/bze/tradebin/v1/market_history + */ + queryMarketHistory = ( + query?: { + market?: string; + "pagination.key"?: string; + "pagination.offset"?: string; + "pagination.limit"?: string; + "pagination.count_total"?: boolean; + "pagination.reverse"?: boolean; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/bze/tradebin/v1/market_history`, + method: "GET", + query: query, + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Query + * @name QueryMarketOrder + * @summary Queries a list of MarketOrder items. + * @request GET:/bze/tradebin/v1/market_order + */ + queryMarketOrder = ( + query?: { market?: string; order_type?: string; order_id?: string }, + params: RequestParams = {}, + ) => + this.request({ + path: `/bze/tradebin/v1/market_order`, + method: "GET", + query: query, + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Query + * @name QueryParams + * @summary Parameters queries the parameters of the module. + * @request GET:/bze/tradebin/v1/params + */ + queryParams = (params: RequestParams = {}) => + this.request({ + path: `/bze/tradebin/v1/params`, + method: "GET", + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Query + * @name QueryUserMarketOrders + * @summary Queries a list of UserMarketOrders items. + * @request GET:/bze/tradebin/v1/user_market_orders/{address} + */ + queryUserMarketOrders = ( + address: string, + query?: { + market?: string; + "pagination.key"?: string; + "pagination.offset"?: string; + "pagination.limit"?: string; + "pagination.count_total"?: boolean; + "pagination.reverse"?: boolean; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/bze/tradebin/v1/user_market_orders/${address}`, + method: "GET", + query: query, + format: "json", + ...params, + }); +} diff --git a/ts-client/bze.tradebin.v1/types.ts b/ts-client/bze.tradebin.v1/types.ts new file mode 100755 index 00000000..5e281b13 --- /dev/null +++ b/ts-client/bze.tradebin.v1/types.ts @@ -0,0 +1,31 @@ +import { OrderCreateMessageEvent } from "./types/tradebin/events" +import { OrderCancelMessageEvent } from "./types/tradebin/events" +import { MarketCreatedEvent } from "./types/tradebin/events" +import { OrderExecutedEvent } from "./types/tradebin/events" +import { OrderCanceledEvent } from "./types/tradebin/events" +import { OrderSavedEvent } from "./types/tradebin/events" +import { Market } from "./types/tradebin/market" +import { Order } from "./types/tradebin/order" +import { OrderReference } from "./types/tradebin/order" +import { AggregatedOrder } from "./types/tradebin/order" +import { HistoryOrder } from "./types/tradebin/order" +import { Params } from "./types/tradebin/params" +import { QueueMessage } from "./types/tradebin/queue_message" + + +export { + OrderCreateMessageEvent, + OrderCancelMessageEvent, + MarketCreatedEvent, + OrderExecutedEvent, + OrderCanceledEvent, + OrderSavedEvent, + Market, + Order, + OrderReference, + AggregatedOrder, + HistoryOrder, + Params, + QueueMessage, + + } \ No newline at end of file diff --git a/ts-client/bze.tradebin.v1/types/cosmos/base/query/v1beta1/pagination.ts b/ts-client/bze.tradebin.v1/types/cosmos/base/query/v1beta1/pagination.ts new file mode 100644 index 00000000..cd4b2d78 --- /dev/null +++ b/ts-client/bze.tradebin.v1/types/cosmos/base/query/v1beta1/pagination.ts @@ -0,0 +1,327 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "cosmos.base.query.v1beta1"; + +/** + * PageRequest is to be embedded in gRPC request messages for efficient + * pagination. Ex: + * + * message SomeRequest { + * Foo some_parameter = 1; + * PageRequest pagination = 2; + * } + */ +export interface PageRequest { + /** + * key is a value returned in PageResponse.next_key to begin + * querying the next page most efficiently. Only one of offset or key + * should be set. + */ + key: Uint8Array; + /** + * offset is a numeric offset that can be used when key is unavailable. + * It is less efficient than using key. Only one of offset or key should + * be set. + */ + offset: number; + /** + * limit is the total number of results to be returned in the result page. + * If left empty it will default to a value to be set by each app. + */ + limit: number; + /** + * count_total is set to true to indicate that the result set should include + * a count of the total number of items available for pagination in UIs. + * count_total is only respected when offset is used. It is ignored when key + * is set. + */ + countTotal: boolean; + /** + * reverse is set to true if results are to be returned in the descending order. + * + * Since: cosmos-sdk 0.43 + */ + reverse: boolean; +} + +/** + * PageResponse is to be embedded in gRPC response messages where the + * corresponding request message has used PageRequest. + * + * message SomeResponse { + * repeated Bar results = 1; + * PageResponse page = 2; + * } + */ +export interface PageResponse { + /** + * next_key is the key to be passed to PageRequest.key to + * query the next page most efficiently + */ + nextKey: Uint8Array; + /** + * total is total number of results available if PageRequest.count_total + * was set, its value is undefined otherwise + */ + total: number; +} + +const basePageRequest: object = { + offset: 0, + limit: 0, + countTotal: false, + reverse: false, +}; + +export const PageRequest = { + encode(message: PageRequest, writer: Writer = Writer.create()): Writer { + if (message.key.length !== 0) { + writer.uint32(10).bytes(message.key); + } + if (message.offset !== 0) { + writer.uint32(16).uint64(message.offset); + } + if (message.limit !== 0) { + writer.uint32(24).uint64(message.limit); + } + if (message.countTotal === true) { + writer.uint32(32).bool(message.countTotal); + } + if (message.reverse === true) { + writer.uint32(40).bool(message.reverse); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): PageRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...basePageRequest } as PageRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.key = reader.bytes(); + break; + case 2: + message.offset = longToNumber(reader.uint64() as Long); + break; + case 3: + message.limit = longToNumber(reader.uint64() as Long); + break; + case 4: + message.countTotal = reader.bool(); + break; + case 5: + message.reverse = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): PageRequest { + const message = { ...basePageRequest } as PageRequest; + if (object.key !== undefined && object.key !== null) { + message.key = bytesFromBase64(object.key); + } + if (object.offset !== undefined && object.offset !== null) { + message.offset = Number(object.offset); + } else { + message.offset = 0; + } + if (object.limit !== undefined && object.limit !== null) { + message.limit = Number(object.limit); + } else { + message.limit = 0; + } + if (object.countTotal !== undefined && object.countTotal !== null) { + message.countTotal = Boolean(object.countTotal); + } else { + message.countTotal = false; + } + if (object.reverse !== undefined && object.reverse !== null) { + message.reverse = Boolean(object.reverse); + } else { + message.reverse = false; + } + return message; + }, + + toJSON(message: PageRequest): unknown { + const obj: any = {}; + message.key !== undefined && + (obj.key = base64FromBytes( + message.key !== undefined ? message.key : new Uint8Array() + )); + message.offset !== undefined && (obj.offset = message.offset); + message.limit !== undefined && (obj.limit = message.limit); + message.countTotal !== undefined && (obj.countTotal = message.countTotal); + message.reverse !== undefined && (obj.reverse = message.reverse); + return obj; + }, + + fromPartial(object: DeepPartial): PageRequest { + const message = { ...basePageRequest } as PageRequest; + if (object.key !== undefined && object.key !== null) { + message.key = object.key; + } else { + message.key = new Uint8Array(); + } + if (object.offset !== undefined && object.offset !== null) { + message.offset = object.offset; + } else { + message.offset = 0; + } + if (object.limit !== undefined && object.limit !== null) { + message.limit = object.limit; + } else { + message.limit = 0; + } + if (object.countTotal !== undefined && object.countTotal !== null) { + message.countTotal = object.countTotal; + } else { + message.countTotal = false; + } + if (object.reverse !== undefined && object.reverse !== null) { + message.reverse = object.reverse; + } else { + message.reverse = false; + } + return message; + }, +}; + +const basePageResponse: object = { total: 0 }; + +export const PageResponse = { + encode(message: PageResponse, writer: Writer = Writer.create()): Writer { + if (message.nextKey.length !== 0) { + writer.uint32(10).bytes(message.nextKey); + } + if (message.total !== 0) { + writer.uint32(16).uint64(message.total); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): PageResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...basePageResponse } as PageResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.nextKey = reader.bytes(); + break; + case 2: + message.total = longToNumber(reader.uint64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): PageResponse { + const message = { ...basePageResponse } as PageResponse; + if (object.nextKey !== undefined && object.nextKey !== null) { + message.nextKey = bytesFromBase64(object.nextKey); + } + if (object.total !== undefined && object.total !== null) { + message.total = Number(object.total); + } else { + message.total = 0; + } + return message; + }, + + toJSON(message: PageResponse): unknown { + const obj: any = {}; + message.nextKey !== undefined && + (obj.nextKey = base64FromBytes( + message.nextKey !== undefined ? message.nextKey : new Uint8Array() + )); + message.total !== undefined && (obj.total = message.total); + return obj; + }, + + fromPartial(object: DeepPartial): PageResponse { + const message = { ...basePageResponse } as PageResponse; + if (object.nextKey !== undefined && object.nextKey !== null) { + message.nextKey = object.nextKey; + } else { + message.nextKey = new Uint8Array(); + } + if (object.total !== undefined && object.total !== null) { + message.total = object.total; + } else { + message.total = 0; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/bze.tradebin.v1/types/gogoproto/gogo.ts b/ts-client/bze.tradebin.v1/types/gogoproto/gogo.ts new file mode 100644 index 00000000..3f41a047 --- /dev/null +++ b/ts-client/bze.tradebin.v1/types/gogoproto/gogo.ts @@ -0,0 +1,2 @@ +/* eslint-disable */ +export const protobufPackage = "gogoproto"; diff --git a/ts-client/bze.tradebin.v1/types/google/api/annotations.ts b/ts-client/bze.tradebin.v1/types/google/api/annotations.ts new file mode 100644 index 00000000..aace4787 --- /dev/null +++ b/ts-client/bze.tradebin.v1/types/google/api/annotations.ts @@ -0,0 +1,2 @@ +/* eslint-disable */ +export const protobufPackage = "google.api"; diff --git a/ts-client/bze.tradebin.v1/types/google/api/http.ts b/ts-client/bze.tradebin.v1/types/google/api/http.ts new file mode 100644 index 00000000..ddc00f8b --- /dev/null +++ b/ts-client/bze.tradebin.v1/types/google/api/http.ts @@ -0,0 +1,705 @@ +/* eslint-disable */ +import { Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "google.api"; + +/** + * Defines the HTTP configuration for an API service. It contains a list of + * [HttpRule][google.api.HttpRule], each specifying the mapping of an RPC method + * to one or more HTTP REST API methods. + */ +export interface Http { + /** + * A list of HTTP configuration rules that apply to individual API methods. + * + * **NOTE:** All service configuration rules follow "last one wins" order. + */ + rules: HttpRule[]; + /** + * When set to true, URL path parmeters will be fully URI-decoded except in + * cases of single segment matches in reserved expansion, where "%2F" will be + * left encoded. + * + * The default behavior is to not decode RFC 6570 reserved characters in multi + * segment matches. + */ + fullyDecodeReservedExpansion: boolean; +} + +/** + * `HttpRule` defines the mapping of an RPC method to one or more HTTP + * REST API methods. The mapping specifies how different portions of the RPC + * request message are mapped to URL path, URL query parameters, and + * HTTP request body. The mapping is typically specified as an + * `google.api.http` annotation on the RPC method, + * see "google/api/annotations.proto" for details. + * + * The mapping consists of a field specifying the path template and + * method kind. The path template can refer to fields in the request + * message, as in the example below which describes a REST GET + * operation on a resource collection of messages: + * + * + * service Messaging { + * rpc GetMessage(GetMessageRequest) returns (Message) { + * option (google.api.http).get = "/v1/messages/{message_id}/{sub.subfield}"; + * } + * } + * message GetMessageRequest { + * message SubMessage { + * string subfield = 1; + * } + * string message_id = 1; // mapped to the URL + * SubMessage sub = 2; // `sub.subfield` is url-mapped + * } + * message Message { + * string text = 1; // content of the resource + * } + * + * The same http annotation can alternatively be expressed inside the + * `GRPC API Configuration` YAML file. + * + * http: + * rules: + * - selector: .Messaging.GetMessage + * get: /v1/messages/{message_id}/{sub.subfield} + * + * This definition enables an automatic, bidrectional mapping of HTTP + * JSON to RPC. Example: + * + * HTTP | RPC + * -----|----- + * `GET /v1/messages/123456/foo` | `GetMessage(message_id: "123456" sub: SubMessage(subfield: "foo"))` + * + * In general, not only fields but also field paths can be referenced + * from a path pattern. Fields mapped to the path pattern cannot be + * repeated and must have a primitive (non-message) type. + * + * Any fields in the request message which are not bound by the path + * pattern automatically become (optional) HTTP query + * parameters. Assume the following definition of the request message: + * + * + * service Messaging { + * rpc GetMessage(GetMessageRequest) returns (Message) { + * option (google.api.http).get = "/v1/messages/{message_id}"; + * } + * } + * message GetMessageRequest { + * message SubMessage { + * string subfield = 1; + * } + * string message_id = 1; // mapped to the URL + * int64 revision = 2; // becomes a parameter + * SubMessage sub = 3; // `sub.subfield` becomes a parameter + * } + * + * + * This enables a HTTP JSON to RPC mapping as below: + * + * HTTP | RPC + * -----|----- + * `GET /v1/messages/123456?revision=2&sub.subfield=foo` | `GetMessage(message_id: "123456" revision: 2 sub: SubMessage(subfield: "foo"))` + * + * Note that fields which are mapped to HTTP parameters must have a + * primitive type or a repeated primitive type. Message types are not + * allowed. In the case of a repeated type, the parameter can be + * repeated in the URL, as in `...?param=A¶m=B`. + * + * For HTTP method kinds which allow a request body, the `body` field + * specifies the mapping. Consider a REST update method on the + * message resource collection: + * + * + * service Messaging { + * rpc UpdateMessage(UpdateMessageRequest) returns (Message) { + * option (google.api.http) = { + * put: "/v1/messages/{message_id}" + * body: "message" + * }; + * } + * } + * message UpdateMessageRequest { + * string message_id = 1; // mapped to the URL + * Message message = 2; // mapped to the body + * } + * + * + * The following HTTP JSON to RPC mapping is enabled, where the + * representation of the JSON in the request body is determined by + * protos JSON encoding: + * + * HTTP | RPC + * -----|----- + * `PUT /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: "123456" message { text: "Hi!" })` + * + * The special name `*` can be used in the body mapping to define that + * every field not bound by the path template should be mapped to the + * request body. This enables the following alternative definition of + * the update method: + * + * service Messaging { + * rpc UpdateMessage(Message) returns (Message) { + * option (google.api.http) = { + * put: "/v1/messages/{message_id}" + * body: "*" + * }; + * } + * } + * message Message { + * string message_id = 1; + * string text = 2; + * } + * + * + * The following HTTP JSON to RPC mapping is enabled: + * + * HTTP | RPC + * -----|----- + * `PUT /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: "123456" text: "Hi!")` + * + * Note that when using `*` in the body mapping, it is not possible to + * have HTTP parameters, as all fields not bound by the path end in + * the body. This makes this option more rarely used in practice of + * defining REST APIs. The common usage of `*` is in custom methods + * which don't use the URL at all for transferring data. + * + * It is possible to define multiple HTTP methods for one RPC by using + * the `additional_bindings` option. Example: + * + * service Messaging { + * rpc GetMessage(GetMessageRequest) returns (Message) { + * option (google.api.http) = { + * get: "/v1/messages/{message_id}" + * additional_bindings { + * get: "/v1/users/{user_id}/messages/{message_id}" + * } + * }; + * } + * } + * message GetMessageRequest { + * string message_id = 1; + * string user_id = 2; + * } + * + * + * This enables the following two alternative HTTP JSON to RPC + * mappings: + * + * HTTP | RPC + * -----|----- + * `GET /v1/messages/123456` | `GetMessage(message_id: "123456")` + * `GET /v1/users/me/messages/123456` | `GetMessage(user_id: "me" message_id: "123456")` + * + * # Rules for HTTP mapping + * + * The rules for mapping HTTP path, query parameters, and body fields + * to the request message are as follows: + * + * 1. The `body` field specifies either `*` or a field path, or is + * omitted. If omitted, it indicates there is no HTTP request body. + * 2. Leaf fields (recursive expansion of nested messages in the + * request) can be classified into three types: + * (a) Matched in the URL template. + * (b) Covered by body (if body is `*`, everything except (a) fields; + * else everything under the body field) + * (c) All other fields. + * 3. URL query parameters found in the HTTP request are mapped to (c) fields. + * 4. Any body sent with an HTTP request can contain only (b) fields. + * + * The syntax of the path template is as follows: + * + * Template = "/" Segments [ Verb ] ; + * Segments = Segment { "/" Segment } ; + * Segment = "*" | "**" | LITERAL | Variable ; + * Variable = "{" FieldPath [ "=" Segments ] "}" ; + * FieldPath = IDENT { "." IDENT } ; + * Verb = ":" LITERAL ; + * + * The syntax `*` matches a single path segment. The syntax `**` matches zero + * or more path segments, which must be the last part of the path except the + * `Verb`. The syntax `LITERAL` matches literal text in the path. + * + * The syntax `Variable` matches part of the URL path as specified by its + * template. A variable template must not contain other variables. If a variable + * matches a single path segment, its template may be omitted, e.g. `{var}` + * is equivalent to `{var=*}`. + * + * If a variable contains exactly one path segment, such as `"{var}"` or + * `"{var=*}"`, when such a variable is expanded into a URL path, all characters + * except `[-_.~0-9a-zA-Z]` are percent-encoded. Such variables show up in the + * Discovery Document as `{var}`. + * + * If a variable contains one or more path segments, such as `"{var=foo/*}"` + * or `"{var=**}"`, when such a variable is expanded into a URL path, all + * characters except `[-_.~/0-9a-zA-Z]` are percent-encoded. Such variables + * show up in the Discovery Document as `{+var}`. + * + * NOTE: While the single segment variable matches the semantics of + * [RFC 6570](https://tools.ietf.org/html/rfc6570) Section 3.2.2 + * Simple String Expansion, the multi segment variable **does not** match + * RFC 6570 Reserved Expansion. The reason is that the Reserved Expansion + * does not expand special characters like `?` and `#`, which would lead + * to invalid URLs. + * + * NOTE: the field paths in variables and in the `body` must not refer to + * repeated fields or map fields. + */ +export interface HttpRule { + /** + * Selects methods to which this rule applies. + * + * Refer to [selector][google.api.DocumentationRule.selector] for syntax details. + */ + selector: string; + /** Used for listing and getting information about resources. */ + get: string | undefined; + /** Used for updating a resource. */ + put: string | undefined; + /** Used for creating a resource. */ + post: string | undefined; + /** Used for deleting a resource. */ + delete: string | undefined; + /** Used for updating a resource. */ + patch: string | undefined; + /** + * The custom pattern is used for specifying an HTTP method that is not + * included in the `pattern` field, such as HEAD, or "*" to leave the + * HTTP method unspecified for this rule. The wild-card rule is useful + * for services that provide content to Web (HTML) clients. + */ + custom: CustomHttpPattern | undefined; + /** + * The name of the request field whose value is mapped to the HTTP body, or + * `*` for mapping all fields not captured by the path pattern to the HTTP + * body. NOTE: the referred field must not be a repeated field and must be + * present at the top-level of request message type. + */ + body: string; + /** + * Optional. The name of the response field whose value is mapped to the HTTP + * body of response. Other response fields are ignored. When + * not set, the response message will be used as HTTP body of response. + */ + responseBody: string; + /** + * Additional HTTP bindings for the selector. Nested bindings must + * not contain an `additional_bindings` field themselves (that is, + * the nesting may only be one level deep). + */ + additionalBindings: HttpRule[]; +} + +/** A custom pattern is used for defining custom HTTP verb. */ +export interface CustomHttpPattern { + /** The name of this custom HTTP verb. */ + kind: string; + /** The path matched by this custom verb. */ + path: string; +} + +const baseHttp: object = { fullyDecodeReservedExpansion: false }; + +export const Http = { + encode(message: Http, writer: Writer = Writer.create()): Writer { + for (const v of message.rules) { + HttpRule.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.fullyDecodeReservedExpansion === true) { + writer.uint32(16).bool(message.fullyDecodeReservedExpansion); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Http { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseHttp } as Http; + message.rules = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.rules.push(HttpRule.decode(reader, reader.uint32())); + break; + case 2: + message.fullyDecodeReservedExpansion = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Http { + const message = { ...baseHttp } as Http; + message.rules = []; + if (object.rules !== undefined && object.rules !== null) { + for (const e of object.rules) { + message.rules.push(HttpRule.fromJSON(e)); + } + } + if ( + object.fullyDecodeReservedExpansion !== undefined && + object.fullyDecodeReservedExpansion !== null + ) { + message.fullyDecodeReservedExpansion = Boolean( + object.fullyDecodeReservedExpansion + ); + } else { + message.fullyDecodeReservedExpansion = false; + } + return message; + }, + + toJSON(message: Http): unknown { + const obj: any = {}; + if (message.rules) { + obj.rules = message.rules.map((e) => + e ? HttpRule.toJSON(e) : undefined + ); + } else { + obj.rules = []; + } + message.fullyDecodeReservedExpansion !== undefined && + (obj.fullyDecodeReservedExpansion = message.fullyDecodeReservedExpansion); + return obj; + }, + + fromPartial(object: DeepPartial): Http { + const message = { ...baseHttp } as Http; + message.rules = []; + if (object.rules !== undefined && object.rules !== null) { + for (const e of object.rules) { + message.rules.push(HttpRule.fromPartial(e)); + } + } + if ( + object.fullyDecodeReservedExpansion !== undefined && + object.fullyDecodeReservedExpansion !== null + ) { + message.fullyDecodeReservedExpansion = + object.fullyDecodeReservedExpansion; + } else { + message.fullyDecodeReservedExpansion = false; + } + return message; + }, +}; + +const baseHttpRule: object = { selector: "", body: "", responseBody: "" }; + +export const HttpRule = { + encode(message: HttpRule, writer: Writer = Writer.create()): Writer { + if (message.selector !== "") { + writer.uint32(10).string(message.selector); + } + if (message.get !== undefined) { + writer.uint32(18).string(message.get); + } + if (message.put !== undefined) { + writer.uint32(26).string(message.put); + } + if (message.post !== undefined) { + writer.uint32(34).string(message.post); + } + if (message.delete !== undefined) { + writer.uint32(42).string(message.delete); + } + if (message.patch !== undefined) { + writer.uint32(50).string(message.patch); + } + if (message.custom !== undefined) { + CustomHttpPattern.encode( + message.custom, + writer.uint32(66).fork() + ).ldelim(); + } + if (message.body !== "") { + writer.uint32(58).string(message.body); + } + if (message.responseBody !== "") { + writer.uint32(98).string(message.responseBody); + } + for (const v of message.additionalBindings) { + HttpRule.encode(v!, writer.uint32(90).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): HttpRule { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseHttpRule } as HttpRule; + message.additionalBindings = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.selector = reader.string(); + break; + case 2: + message.get = reader.string(); + break; + case 3: + message.put = reader.string(); + break; + case 4: + message.post = reader.string(); + break; + case 5: + message.delete = reader.string(); + break; + case 6: + message.patch = reader.string(); + break; + case 8: + message.custom = CustomHttpPattern.decode(reader, reader.uint32()); + break; + case 7: + message.body = reader.string(); + break; + case 12: + message.responseBody = reader.string(); + break; + case 11: + message.additionalBindings.push( + HttpRule.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): HttpRule { + const message = { ...baseHttpRule } as HttpRule; + message.additionalBindings = []; + if (object.selector !== undefined && object.selector !== null) { + message.selector = String(object.selector); + } else { + message.selector = ""; + } + if (object.get !== undefined && object.get !== null) { + message.get = String(object.get); + } else { + message.get = undefined; + } + if (object.put !== undefined && object.put !== null) { + message.put = String(object.put); + } else { + message.put = undefined; + } + if (object.post !== undefined && object.post !== null) { + message.post = String(object.post); + } else { + message.post = undefined; + } + if (object.delete !== undefined && object.delete !== null) { + message.delete = String(object.delete); + } else { + message.delete = undefined; + } + if (object.patch !== undefined && object.patch !== null) { + message.patch = String(object.patch); + } else { + message.patch = undefined; + } + if (object.custom !== undefined && object.custom !== null) { + message.custom = CustomHttpPattern.fromJSON(object.custom); + } else { + message.custom = undefined; + } + if (object.body !== undefined && object.body !== null) { + message.body = String(object.body); + } else { + message.body = ""; + } + if (object.responseBody !== undefined && object.responseBody !== null) { + message.responseBody = String(object.responseBody); + } else { + message.responseBody = ""; + } + if ( + object.additionalBindings !== undefined && + object.additionalBindings !== null + ) { + for (const e of object.additionalBindings) { + message.additionalBindings.push(HttpRule.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: HttpRule): unknown { + const obj: any = {}; + message.selector !== undefined && (obj.selector = message.selector); + message.get !== undefined && (obj.get = message.get); + message.put !== undefined && (obj.put = message.put); + message.post !== undefined && (obj.post = message.post); + message.delete !== undefined && (obj.delete = message.delete); + message.patch !== undefined && (obj.patch = message.patch); + message.custom !== undefined && + (obj.custom = message.custom + ? CustomHttpPattern.toJSON(message.custom) + : undefined); + message.body !== undefined && (obj.body = message.body); + message.responseBody !== undefined && + (obj.responseBody = message.responseBody); + if (message.additionalBindings) { + obj.additionalBindings = message.additionalBindings.map((e) => + e ? HttpRule.toJSON(e) : undefined + ); + } else { + obj.additionalBindings = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): HttpRule { + const message = { ...baseHttpRule } as HttpRule; + message.additionalBindings = []; + if (object.selector !== undefined && object.selector !== null) { + message.selector = object.selector; + } else { + message.selector = ""; + } + if (object.get !== undefined && object.get !== null) { + message.get = object.get; + } else { + message.get = undefined; + } + if (object.put !== undefined && object.put !== null) { + message.put = object.put; + } else { + message.put = undefined; + } + if (object.post !== undefined && object.post !== null) { + message.post = object.post; + } else { + message.post = undefined; + } + if (object.delete !== undefined && object.delete !== null) { + message.delete = object.delete; + } else { + message.delete = undefined; + } + if (object.patch !== undefined && object.patch !== null) { + message.patch = object.patch; + } else { + message.patch = undefined; + } + if (object.custom !== undefined && object.custom !== null) { + message.custom = CustomHttpPattern.fromPartial(object.custom); + } else { + message.custom = undefined; + } + if (object.body !== undefined && object.body !== null) { + message.body = object.body; + } else { + message.body = ""; + } + if (object.responseBody !== undefined && object.responseBody !== null) { + message.responseBody = object.responseBody; + } else { + message.responseBody = ""; + } + if ( + object.additionalBindings !== undefined && + object.additionalBindings !== null + ) { + for (const e of object.additionalBindings) { + message.additionalBindings.push(HttpRule.fromPartial(e)); + } + } + return message; + }, +}; + +const baseCustomHttpPattern: object = { kind: "", path: "" }; + +export const CustomHttpPattern = { + encode(message: CustomHttpPattern, writer: Writer = Writer.create()): Writer { + if (message.kind !== "") { + writer.uint32(10).string(message.kind); + } + if (message.path !== "") { + writer.uint32(18).string(message.path); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): CustomHttpPattern { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseCustomHttpPattern } as CustomHttpPattern; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.kind = reader.string(); + break; + case 2: + message.path = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): CustomHttpPattern { + const message = { ...baseCustomHttpPattern } as CustomHttpPattern; + if (object.kind !== undefined && object.kind !== null) { + message.kind = String(object.kind); + } else { + message.kind = ""; + } + if (object.path !== undefined && object.path !== null) { + message.path = String(object.path); + } else { + message.path = ""; + } + return message; + }, + + toJSON(message: CustomHttpPattern): unknown { + const obj: any = {}; + message.kind !== undefined && (obj.kind = message.kind); + message.path !== undefined && (obj.path = message.path); + return obj; + }, + + fromPartial(object: DeepPartial): CustomHttpPattern { + const message = { ...baseCustomHttpPattern } as CustomHttpPattern; + if (object.kind !== undefined && object.kind !== null) { + message.kind = object.kind; + } else { + message.kind = ""; + } + if (object.path !== undefined && object.path !== null) { + message.path = object.path; + } else { + message.path = ""; + } + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/bze.tradebin.v1/types/google/protobuf/descriptor.ts b/ts-client/bze.tradebin.v1/types/google/protobuf/descriptor.ts new file mode 100644 index 00000000..9e508660 --- /dev/null +++ b/ts-client/bze.tradebin.v1/types/google/protobuf/descriptor.ts @@ -0,0 +1,5261 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "google.protobuf"; + +/** + * The protocol compiler can output a FileDescriptorSet containing the .proto + * files it parses. + */ +export interface FileDescriptorSet { + file: FileDescriptorProto[]; +} + +/** Describes a complete .proto file. */ +export interface FileDescriptorProto { + /** file name, relative to root of source tree */ + name: string; + /** e.g. "foo", "foo.bar", etc. */ + package: string; + /** Names of files imported by this file. */ + dependency: string[]; + /** Indexes of the public imported files in the dependency list above. */ + publicDependency: number[]; + /** + * Indexes of the weak imported files in the dependency list. + * For Google-internal migration only. Do not use. + */ + weakDependency: number[]; + /** All top-level definitions in this file. */ + messageType: DescriptorProto[]; + enumType: EnumDescriptorProto[]; + service: ServiceDescriptorProto[]; + extension: FieldDescriptorProto[]; + options: FileOptions | undefined; + /** + * This field contains optional information about the original source code. + * You may safely remove this entire field without harming runtime + * functionality of the descriptors -- the information is needed only by + * development tools. + */ + sourceCodeInfo: SourceCodeInfo | undefined; + /** + * The syntax of the proto file. + * The supported values are "proto2" and "proto3". + */ + syntax: string; +} + +/** Describes a message type. */ +export interface DescriptorProto { + name: string; + field: FieldDescriptorProto[]; + extension: FieldDescriptorProto[]; + nestedType: DescriptorProto[]; + enumType: EnumDescriptorProto[]; + extensionRange: DescriptorProto_ExtensionRange[]; + oneofDecl: OneofDescriptorProto[]; + options: MessageOptions | undefined; + reservedRange: DescriptorProto_ReservedRange[]; + /** + * Reserved field names, which may not be used by fields in the same message. + * A given name may only be reserved once. + */ + reservedName: string[]; +} + +export interface DescriptorProto_ExtensionRange { + /** Inclusive. */ + start: number; + /** Exclusive. */ + end: number; + options: ExtensionRangeOptions | undefined; +} + +/** + * Range of reserved tag numbers. Reserved tag numbers may not be used by + * fields or extension ranges in the same message. Reserved ranges may + * not overlap. + */ +export interface DescriptorProto_ReservedRange { + /** Inclusive. */ + start: number; + /** Exclusive. */ + end: number; +} + +export interface ExtensionRangeOptions { + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +/** Describes a field within a message. */ +export interface FieldDescriptorProto { + name: string; + number: number; + label: FieldDescriptorProto_Label; + /** + * If type_name is set, this need not be set. If both this and type_name + * are set, this must be one of TYPE_ENUM, TYPE_MESSAGE or TYPE_GROUP. + */ + type: FieldDescriptorProto_Type; + /** + * For message and enum types, this is the name of the type. If the name + * starts with a '.', it is fully-qualified. Otherwise, C++-like scoping + * rules are used to find the type (i.e. first the nested types within this + * message are searched, then within the parent, on up to the root + * namespace). + */ + typeName: string; + /** + * For extensions, this is the name of the type being extended. It is + * resolved in the same manner as type_name. + */ + extendee: string; + /** + * For numeric types, contains the original text representation of the value. + * For booleans, "true" or "false". + * For strings, contains the default text contents (not escaped in any way). + * For bytes, contains the C escaped value. All bytes >= 128 are escaped. + * TODO(kenton): Base-64 encode? + */ + defaultValue: string; + /** + * If set, gives the index of a oneof in the containing type's oneof_decl + * list. This field is a member of that oneof. + */ + oneofIndex: number; + /** + * JSON name of this field. The value is set by protocol compiler. If the + * user has set a "json_name" option on this field, that option's value + * will be used. Otherwise, it's deduced from the field's name by converting + * it to camelCase. + */ + jsonName: string; + options: FieldOptions | undefined; + /** + * If true, this is a proto3 "optional". When a proto3 field is optional, it + * tracks presence regardless of field type. + * + * When proto3_optional is true, this field must be belong to a oneof to + * signal to old proto3 clients that presence is tracked for this field. This + * oneof is known as a "synthetic" oneof, and this field must be its sole + * member (each proto3 optional field gets its own synthetic oneof). Synthetic + * oneofs exist in the descriptor only, and do not generate any API. Synthetic + * oneofs must be ordered after all "real" oneofs. + * + * For message fields, proto3_optional doesn't create any semantic change, + * since non-repeated message fields always track presence. However it still + * indicates the semantic detail of whether the user wrote "optional" or not. + * This can be useful for round-tripping the .proto file. For consistency we + * give message fields a synthetic oneof also, even though it is not required + * to track presence. This is especially important because the parser can't + * tell if a field is a message or an enum, so it must always create a + * synthetic oneof. + * + * Proto2 optional fields do not set this flag, because they already indicate + * optional with `LABEL_OPTIONAL`. + */ + proto3Optional: boolean; +} + +export enum FieldDescriptorProto_Type { + /** + * TYPE_DOUBLE - 0 is reserved for errors. + * Order is weird for historical reasons. + */ + TYPE_DOUBLE = 1, + TYPE_FLOAT = 2, + /** + * TYPE_INT64 - Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT64 if + * negative values are likely. + */ + TYPE_INT64 = 3, + TYPE_UINT64 = 4, + /** + * TYPE_INT32 - Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT32 if + * negative values are likely. + */ + TYPE_INT32 = 5, + TYPE_FIXED64 = 6, + TYPE_FIXED32 = 7, + TYPE_BOOL = 8, + TYPE_STRING = 9, + /** + * TYPE_GROUP - Tag-delimited aggregate. + * Group type is deprecated and not supported in proto3. However, Proto3 + * implementations should still be able to parse the group wire format and + * treat group fields as unknown fields. + */ + TYPE_GROUP = 10, + /** TYPE_MESSAGE - Length-delimited aggregate. */ + TYPE_MESSAGE = 11, + /** TYPE_BYTES - New in version 2. */ + TYPE_BYTES = 12, + TYPE_UINT32 = 13, + TYPE_ENUM = 14, + TYPE_SFIXED32 = 15, + TYPE_SFIXED64 = 16, + /** TYPE_SINT32 - Uses ZigZag encoding. */ + TYPE_SINT32 = 17, + /** TYPE_SINT64 - Uses ZigZag encoding. */ + TYPE_SINT64 = 18, + UNRECOGNIZED = -1, +} + +export function fieldDescriptorProto_TypeFromJSON( + object: any +): FieldDescriptorProto_Type { + switch (object) { + case 1: + case "TYPE_DOUBLE": + return FieldDescriptorProto_Type.TYPE_DOUBLE; + case 2: + case "TYPE_FLOAT": + return FieldDescriptorProto_Type.TYPE_FLOAT; + case 3: + case "TYPE_INT64": + return FieldDescriptorProto_Type.TYPE_INT64; + case 4: + case "TYPE_UINT64": + return FieldDescriptorProto_Type.TYPE_UINT64; + case 5: + case "TYPE_INT32": + return FieldDescriptorProto_Type.TYPE_INT32; + case 6: + case "TYPE_FIXED64": + return FieldDescriptorProto_Type.TYPE_FIXED64; + case 7: + case "TYPE_FIXED32": + return FieldDescriptorProto_Type.TYPE_FIXED32; + case 8: + case "TYPE_BOOL": + return FieldDescriptorProto_Type.TYPE_BOOL; + case 9: + case "TYPE_STRING": + return FieldDescriptorProto_Type.TYPE_STRING; + case 10: + case "TYPE_GROUP": + return FieldDescriptorProto_Type.TYPE_GROUP; + case 11: + case "TYPE_MESSAGE": + return FieldDescriptorProto_Type.TYPE_MESSAGE; + case 12: + case "TYPE_BYTES": + return FieldDescriptorProto_Type.TYPE_BYTES; + case 13: + case "TYPE_UINT32": + return FieldDescriptorProto_Type.TYPE_UINT32; + case 14: + case "TYPE_ENUM": + return FieldDescriptorProto_Type.TYPE_ENUM; + case 15: + case "TYPE_SFIXED32": + return FieldDescriptorProto_Type.TYPE_SFIXED32; + case 16: + case "TYPE_SFIXED64": + return FieldDescriptorProto_Type.TYPE_SFIXED64; + case 17: + case "TYPE_SINT32": + return FieldDescriptorProto_Type.TYPE_SINT32; + case 18: + case "TYPE_SINT64": + return FieldDescriptorProto_Type.TYPE_SINT64; + case -1: + case "UNRECOGNIZED": + default: + return FieldDescriptorProto_Type.UNRECOGNIZED; + } +} + +export function fieldDescriptorProto_TypeToJSON( + object: FieldDescriptorProto_Type +): string { + switch (object) { + case FieldDescriptorProto_Type.TYPE_DOUBLE: + return "TYPE_DOUBLE"; + case FieldDescriptorProto_Type.TYPE_FLOAT: + return "TYPE_FLOAT"; + case FieldDescriptorProto_Type.TYPE_INT64: + return "TYPE_INT64"; + case FieldDescriptorProto_Type.TYPE_UINT64: + return "TYPE_UINT64"; + case FieldDescriptorProto_Type.TYPE_INT32: + return "TYPE_INT32"; + case FieldDescriptorProto_Type.TYPE_FIXED64: + return "TYPE_FIXED64"; + case FieldDescriptorProto_Type.TYPE_FIXED32: + return "TYPE_FIXED32"; + case FieldDescriptorProto_Type.TYPE_BOOL: + return "TYPE_BOOL"; + case FieldDescriptorProto_Type.TYPE_STRING: + return "TYPE_STRING"; + case FieldDescriptorProto_Type.TYPE_GROUP: + return "TYPE_GROUP"; + case FieldDescriptorProto_Type.TYPE_MESSAGE: + return "TYPE_MESSAGE"; + case FieldDescriptorProto_Type.TYPE_BYTES: + return "TYPE_BYTES"; + case FieldDescriptorProto_Type.TYPE_UINT32: + return "TYPE_UINT32"; + case FieldDescriptorProto_Type.TYPE_ENUM: + return "TYPE_ENUM"; + case FieldDescriptorProto_Type.TYPE_SFIXED32: + return "TYPE_SFIXED32"; + case FieldDescriptorProto_Type.TYPE_SFIXED64: + return "TYPE_SFIXED64"; + case FieldDescriptorProto_Type.TYPE_SINT32: + return "TYPE_SINT32"; + case FieldDescriptorProto_Type.TYPE_SINT64: + return "TYPE_SINT64"; + default: + return "UNKNOWN"; + } +} + +export enum FieldDescriptorProto_Label { + /** LABEL_OPTIONAL - 0 is reserved for errors */ + LABEL_OPTIONAL = 1, + LABEL_REQUIRED = 2, + LABEL_REPEATED = 3, + UNRECOGNIZED = -1, +} + +export function fieldDescriptorProto_LabelFromJSON( + object: any +): FieldDescriptorProto_Label { + switch (object) { + case 1: + case "LABEL_OPTIONAL": + return FieldDescriptorProto_Label.LABEL_OPTIONAL; + case 2: + case "LABEL_REQUIRED": + return FieldDescriptorProto_Label.LABEL_REQUIRED; + case 3: + case "LABEL_REPEATED": + return FieldDescriptorProto_Label.LABEL_REPEATED; + case -1: + case "UNRECOGNIZED": + default: + return FieldDescriptorProto_Label.UNRECOGNIZED; + } +} + +export function fieldDescriptorProto_LabelToJSON( + object: FieldDescriptorProto_Label +): string { + switch (object) { + case FieldDescriptorProto_Label.LABEL_OPTIONAL: + return "LABEL_OPTIONAL"; + case FieldDescriptorProto_Label.LABEL_REQUIRED: + return "LABEL_REQUIRED"; + case FieldDescriptorProto_Label.LABEL_REPEATED: + return "LABEL_REPEATED"; + default: + return "UNKNOWN"; + } +} + +/** Describes a oneof. */ +export interface OneofDescriptorProto { + name: string; + options: OneofOptions | undefined; +} + +/** Describes an enum type. */ +export interface EnumDescriptorProto { + name: string; + value: EnumValueDescriptorProto[]; + options: EnumOptions | undefined; + /** + * Range of reserved numeric values. Reserved numeric values may not be used + * by enum values in the same enum declaration. Reserved ranges may not + * overlap. + */ + reservedRange: EnumDescriptorProto_EnumReservedRange[]; + /** + * Reserved enum value names, which may not be reused. A given name may only + * be reserved once. + */ + reservedName: string[]; +} + +/** + * Range of reserved numeric values. Reserved values may not be used by + * entries in the same enum. Reserved ranges may not overlap. + * + * Note that this is distinct from DescriptorProto.ReservedRange in that it + * is inclusive such that it can appropriately represent the entire int32 + * domain. + */ +export interface EnumDescriptorProto_EnumReservedRange { + /** Inclusive. */ + start: number; + /** Inclusive. */ + end: number; +} + +/** Describes a value within an enum. */ +export interface EnumValueDescriptorProto { + name: string; + number: number; + options: EnumValueOptions | undefined; +} + +/** Describes a service. */ +export interface ServiceDescriptorProto { + name: string; + method: MethodDescriptorProto[]; + options: ServiceOptions | undefined; +} + +/** Describes a method of a service. */ +export interface MethodDescriptorProto { + name: string; + /** + * Input and output type names. These are resolved in the same way as + * FieldDescriptorProto.type_name, but must refer to a message type. + */ + inputType: string; + outputType: string; + options: MethodOptions | undefined; + /** Identifies if client streams multiple client messages */ + clientStreaming: boolean; + /** Identifies if server streams multiple server messages */ + serverStreaming: boolean; +} + +export interface FileOptions { + /** + * Sets the Java package where classes generated from this .proto will be + * placed. By default, the proto package is used, but this is often + * inappropriate because proto packages do not normally start with backwards + * domain names. + */ + javaPackage: string; + /** + * Controls the name of the wrapper Java class generated for the .proto file. + * That class will always contain the .proto file's getDescriptor() method as + * well as any top-level extensions defined in the .proto file. + * If java_multiple_files is disabled, then all the other classes from the + * .proto file will be nested inside the single wrapper outer class. + */ + javaOuterClassname: string; + /** + * If enabled, then the Java code generator will generate a separate .java + * file for each top-level message, enum, and service defined in the .proto + * file. Thus, these types will *not* be nested inside the wrapper class + * named by java_outer_classname. However, the wrapper class will still be + * generated to contain the file's getDescriptor() method as well as any + * top-level extensions defined in the file. + */ + javaMultipleFiles: boolean; + /** + * This option does nothing. + * + * @deprecated + */ + javaGenerateEqualsAndHash: boolean; + /** + * If set true, then the Java2 code generator will generate code that + * throws an exception whenever an attempt is made to assign a non-UTF-8 + * byte sequence to a string field. + * Message reflection will do the same. + * However, an extension field still accepts non-UTF-8 byte sequences. + * This option has no effect on when used with the lite runtime. + */ + javaStringCheckUtf8: boolean; + optimizeFor: FileOptions_OptimizeMode; + /** + * Sets the Go package where structs generated from this .proto will be + * placed. If omitted, the Go package will be derived from the following: + * - The basename of the package import path, if provided. + * - Otherwise, the package statement in the .proto file, if present. + * - Otherwise, the basename of the .proto file, without extension. + */ + goPackage: string; + /** + * Should generic services be generated in each language? "Generic" services + * are not specific to any particular RPC system. They are generated by the + * main code generators in each language (without additional plugins). + * Generic services were the only kind of service generation supported by + * early versions of google.protobuf. + * + * Generic services are now considered deprecated in favor of using plugins + * that generate code specific to your particular RPC system. Therefore, + * these default to false. Old code which depends on generic services should + * explicitly set them to true. + */ + ccGenericServices: boolean; + javaGenericServices: boolean; + pyGenericServices: boolean; + phpGenericServices: boolean; + /** + * Is this file deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for everything in the file, or it will be completely ignored; in the very + * least, this is a formalization for deprecating files. + */ + deprecated: boolean; + /** + * Enables the use of arenas for the proto messages in this file. This applies + * only to generated classes for C++. + */ + ccEnableArenas: boolean; + /** + * Sets the objective c class prefix which is prepended to all objective c + * generated classes from this .proto. There is no default. + */ + objcClassPrefix: string; + /** Namespace for generated classes; defaults to the package. */ + csharpNamespace: string; + /** + * By default Swift generators will take the proto package and CamelCase it + * replacing '.' with underscore and use that to prefix the types/symbols + * defined. When this options is provided, they will use this value instead + * to prefix the types/symbols defined. + */ + swiftPrefix: string; + /** + * Sets the php class prefix which is prepended to all php generated classes + * from this .proto. Default is empty. + */ + phpClassPrefix: string; + /** + * Use this option to change the namespace of php generated classes. Default + * is empty. When this option is empty, the package name will be used for + * determining the namespace. + */ + phpNamespace: string; + /** + * Use this option to change the namespace of php generated metadata classes. + * Default is empty. When this option is empty, the proto file name will be + * used for determining the namespace. + */ + phpMetadataNamespace: string; + /** + * Use this option to change the package of ruby generated classes. Default + * is empty. When this option is not set, the package name will be used for + * determining the ruby package. + */ + rubyPackage: string; + /** + * The parser stores options it doesn't recognize here. + * See the documentation for the "Options" section above. + */ + uninterpretedOption: UninterpretedOption[]; +} + +/** Generated classes can be optimized for speed or code size. */ +export enum FileOptions_OptimizeMode { + /** SPEED - Generate complete code for parsing, serialization, */ + SPEED = 1, + /** CODE_SIZE - etc. */ + CODE_SIZE = 2, + /** LITE_RUNTIME - Generate code using MessageLite and the lite runtime. */ + LITE_RUNTIME = 3, + UNRECOGNIZED = -1, +} + +export function fileOptions_OptimizeModeFromJSON( + object: any +): FileOptions_OptimizeMode { + switch (object) { + case 1: + case "SPEED": + return FileOptions_OptimizeMode.SPEED; + case 2: + case "CODE_SIZE": + return FileOptions_OptimizeMode.CODE_SIZE; + case 3: + case "LITE_RUNTIME": + return FileOptions_OptimizeMode.LITE_RUNTIME; + case -1: + case "UNRECOGNIZED": + default: + return FileOptions_OptimizeMode.UNRECOGNIZED; + } +} + +export function fileOptions_OptimizeModeToJSON( + object: FileOptions_OptimizeMode +): string { + switch (object) { + case FileOptions_OptimizeMode.SPEED: + return "SPEED"; + case FileOptions_OptimizeMode.CODE_SIZE: + return "CODE_SIZE"; + case FileOptions_OptimizeMode.LITE_RUNTIME: + return "LITE_RUNTIME"; + default: + return "UNKNOWN"; + } +} + +export interface MessageOptions { + /** + * Set true to use the old proto1 MessageSet wire format for extensions. + * This is provided for backwards-compatibility with the MessageSet wire + * format. You should not use this for any other reason: It's less + * efficient, has fewer features, and is more complicated. + * + * The message must be defined exactly as follows: + * message Foo { + * option message_set_wire_format = true; + * extensions 4 to max; + * } + * Note that the message cannot have any defined fields; MessageSets only + * have extensions. + * + * All extensions of your type must be singular messages; e.g. they cannot + * be int32s, enums, or repeated messages. + * + * Because this is an option, the above two restrictions are not enforced by + * the protocol compiler. + */ + messageSetWireFormat: boolean; + /** + * Disables the generation of the standard "descriptor()" accessor, which can + * conflict with a field of the same name. This is meant to make migration + * from proto1 easier; new code should avoid fields named "descriptor". + */ + noStandardDescriptorAccessor: boolean; + /** + * Is this message deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the message, or it will be completely ignored; in the very least, + * this is a formalization for deprecating messages. + */ + deprecated: boolean; + /** + * Whether the message is an automatically generated map entry type for the + * maps field. + * + * For maps fields: + * map map_field = 1; + * The parsed descriptor looks like: + * message MapFieldEntry { + * option map_entry = true; + * optional KeyType key = 1; + * optional ValueType value = 2; + * } + * repeated MapFieldEntry map_field = 1; + * + * Implementations may choose not to generate the map_entry=true message, but + * use a native map in the target language to hold the keys and values. + * The reflection APIs in such implementations still need to work as + * if the field is a repeated message field. + * + * NOTE: Do not set the option in .proto files. Always use the maps syntax + * instead. The option should only be implicitly set by the proto compiler + * parser. + */ + mapEntry: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface FieldOptions { + /** + * The ctype option instructs the C++ code generator to use a different + * representation of the field than it normally would. See the specific + * options below. This option is not yet implemented in the open source + * release -- sorry, we'll try to include it in a future version! + */ + ctype: FieldOptions_CType; + /** + * The packed option can be enabled for repeated primitive fields to enable + * a more efficient representation on the wire. Rather than repeatedly + * writing the tag and type for each element, the entire array is encoded as + * a single length-delimited blob. In proto3, only explicit setting it to + * false will avoid using packed encoding. + */ + packed: boolean; + /** + * The jstype option determines the JavaScript type used for values of the + * field. The option is permitted only for 64 bit integral and fixed types + * (int64, uint64, sint64, fixed64, sfixed64). A field with jstype JS_STRING + * is represented as JavaScript string, which avoids loss of precision that + * can happen when a large value is converted to a floating point JavaScript. + * Specifying JS_NUMBER for the jstype causes the generated JavaScript code to + * use the JavaScript "number" type. The behavior of the default option + * JS_NORMAL is implementation dependent. + * + * This option is an enum to permit additional types to be added, e.g. + * goog.math.Integer. + */ + jstype: FieldOptions_JSType; + /** + * Should this field be parsed lazily? Lazy applies only to message-type + * fields. It means that when the outer message is initially parsed, the + * inner message's contents will not be parsed but instead stored in encoded + * form. The inner message will actually be parsed when it is first accessed. + * + * This is only a hint. Implementations are free to choose whether to use + * eager or lazy parsing regardless of the value of this option. However, + * setting this option true suggests that the protocol author believes that + * using lazy parsing on this field is worth the additional bookkeeping + * overhead typically needed to implement it. + * + * This option does not affect the public interface of any generated code; + * all method signatures remain the same. Furthermore, thread-safety of the + * interface is not affected by this option; const methods remain safe to + * call from multiple threads concurrently, while non-const methods continue + * to require exclusive access. + * + * + * Note that implementations may choose not to check required fields within + * a lazy sub-message. That is, calling IsInitialized() on the outer message + * may return true even if the inner message has missing required fields. + * This is necessary because otherwise the inner message would have to be + * parsed in order to perform the check, defeating the purpose of lazy + * parsing. An implementation which chooses not to check required fields + * must be consistent about it. That is, for any particular sub-message, the + * implementation must either *always* check its required fields, or *never* + * check its required fields, regardless of whether or not the message has + * been parsed. + */ + lazy: boolean; + /** + * Is this field deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for accessors, or it will be completely ignored; in the very least, this + * is a formalization for deprecating fields. + */ + deprecated: boolean; + /** For Google-internal migration only. Do not use. */ + weak: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export enum FieldOptions_CType { + /** STRING - Default mode. */ + STRING = 0, + CORD = 1, + STRING_PIECE = 2, + UNRECOGNIZED = -1, +} + +export function fieldOptions_CTypeFromJSON(object: any): FieldOptions_CType { + switch (object) { + case 0: + case "STRING": + return FieldOptions_CType.STRING; + case 1: + case "CORD": + return FieldOptions_CType.CORD; + case 2: + case "STRING_PIECE": + return FieldOptions_CType.STRING_PIECE; + case -1: + case "UNRECOGNIZED": + default: + return FieldOptions_CType.UNRECOGNIZED; + } +} + +export function fieldOptions_CTypeToJSON(object: FieldOptions_CType): string { + switch (object) { + case FieldOptions_CType.STRING: + return "STRING"; + case FieldOptions_CType.CORD: + return "CORD"; + case FieldOptions_CType.STRING_PIECE: + return "STRING_PIECE"; + default: + return "UNKNOWN"; + } +} + +export enum FieldOptions_JSType { + /** JS_NORMAL - Use the default type. */ + JS_NORMAL = 0, + /** JS_STRING - Use JavaScript strings. */ + JS_STRING = 1, + /** JS_NUMBER - Use JavaScript numbers. */ + JS_NUMBER = 2, + UNRECOGNIZED = -1, +} + +export function fieldOptions_JSTypeFromJSON(object: any): FieldOptions_JSType { + switch (object) { + case 0: + case "JS_NORMAL": + return FieldOptions_JSType.JS_NORMAL; + case 1: + case "JS_STRING": + return FieldOptions_JSType.JS_STRING; + case 2: + case "JS_NUMBER": + return FieldOptions_JSType.JS_NUMBER; + case -1: + case "UNRECOGNIZED": + default: + return FieldOptions_JSType.UNRECOGNIZED; + } +} + +export function fieldOptions_JSTypeToJSON(object: FieldOptions_JSType): string { + switch (object) { + case FieldOptions_JSType.JS_NORMAL: + return "JS_NORMAL"; + case FieldOptions_JSType.JS_STRING: + return "JS_STRING"; + case FieldOptions_JSType.JS_NUMBER: + return "JS_NUMBER"; + default: + return "UNKNOWN"; + } +} + +export interface OneofOptions { + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface EnumOptions { + /** + * Set this option to true to allow mapping different tag names to the same + * value. + */ + allowAlias: boolean; + /** + * Is this enum deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the enum, or it will be completely ignored; in the very least, this + * is a formalization for deprecating enums. + */ + deprecated: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface EnumValueOptions { + /** + * Is this enum value deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the enum value, or it will be completely ignored; in the very least, + * this is a formalization for deprecating enum values. + */ + deprecated: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface ServiceOptions { + /** + * Is this service deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the service, or it will be completely ignored; in the very least, + * this is a formalization for deprecating services. + */ + deprecated: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface MethodOptions { + /** + * Is this method deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the method, or it will be completely ignored; in the very least, + * this is a formalization for deprecating methods. + */ + deprecated: boolean; + idempotencyLevel: MethodOptions_IdempotencyLevel; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +/** + * Is this method side-effect-free (or safe in HTTP parlance), or idempotent, + * or neither? HTTP based RPC implementation may choose GET verb for safe + * methods, and PUT verb for idempotent methods instead of the default POST. + */ +export enum MethodOptions_IdempotencyLevel { + IDEMPOTENCY_UNKNOWN = 0, + /** NO_SIDE_EFFECTS - implies idempotent */ + NO_SIDE_EFFECTS = 1, + /** IDEMPOTENT - idempotent, but may have side effects */ + IDEMPOTENT = 2, + UNRECOGNIZED = -1, +} + +export function methodOptions_IdempotencyLevelFromJSON( + object: any +): MethodOptions_IdempotencyLevel { + switch (object) { + case 0: + case "IDEMPOTENCY_UNKNOWN": + return MethodOptions_IdempotencyLevel.IDEMPOTENCY_UNKNOWN; + case 1: + case "NO_SIDE_EFFECTS": + return MethodOptions_IdempotencyLevel.NO_SIDE_EFFECTS; + case 2: + case "IDEMPOTENT": + return MethodOptions_IdempotencyLevel.IDEMPOTENT; + case -1: + case "UNRECOGNIZED": + default: + return MethodOptions_IdempotencyLevel.UNRECOGNIZED; + } +} + +export function methodOptions_IdempotencyLevelToJSON( + object: MethodOptions_IdempotencyLevel +): string { + switch (object) { + case MethodOptions_IdempotencyLevel.IDEMPOTENCY_UNKNOWN: + return "IDEMPOTENCY_UNKNOWN"; + case MethodOptions_IdempotencyLevel.NO_SIDE_EFFECTS: + return "NO_SIDE_EFFECTS"; + case MethodOptions_IdempotencyLevel.IDEMPOTENT: + return "IDEMPOTENT"; + default: + return "UNKNOWN"; + } +} + +/** + * A message representing a option the parser does not recognize. This only + * appears in options protos created by the compiler::Parser class. + * DescriptorPool resolves these when building Descriptor objects. Therefore, + * options protos in descriptor objects (e.g. returned by Descriptor::options(), + * or produced by Descriptor::CopyTo()) will never have UninterpretedOptions + * in them. + */ +export interface UninterpretedOption { + name: UninterpretedOption_NamePart[]; + /** + * The value of the uninterpreted option, in whatever type the tokenizer + * identified it as during parsing. Exactly one of these should be set. + */ + identifierValue: string; + positiveIntValue: number; + negativeIntValue: number; + doubleValue: number; + stringValue: Uint8Array; + aggregateValue: string; +} + +/** + * The name of the uninterpreted option. Each string represents a segment in + * a dot-separated name. is_extension is true iff a segment represents an + * extension (denoted with parentheses in options specs in .proto files). + * E.g.,{ ["foo", false], ["bar.baz", true], ["qux", false] } represents + * "foo.(bar.baz).qux". + */ +export interface UninterpretedOption_NamePart { + namePart: string; + isExtension: boolean; +} + +/** + * Encapsulates information about the original source file from which a + * FileDescriptorProto was generated. + */ +export interface SourceCodeInfo { + /** + * A Location identifies a piece of source code in a .proto file which + * corresponds to a particular definition. This information is intended + * to be useful to IDEs, code indexers, documentation generators, and similar + * tools. + * + * For example, say we have a file like: + * message Foo { + * optional string foo = 1; + * } + * Let's look at just the field definition: + * optional string foo = 1; + * ^ ^^ ^^ ^ ^^^ + * a bc de f ghi + * We have the following locations: + * span path represents + * [a,i) [ 4, 0, 2, 0 ] The whole field definition. + * [a,b) [ 4, 0, 2, 0, 4 ] The label (optional). + * [c,d) [ 4, 0, 2, 0, 5 ] The type (string). + * [e,f) [ 4, 0, 2, 0, 1 ] The name (foo). + * [g,h) [ 4, 0, 2, 0, 3 ] The number (1). + * + * Notes: + * - A location may refer to a repeated field itself (i.e. not to any + * particular index within it). This is used whenever a set of elements are + * logically enclosed in a single code segment. For example, an entire + * extend block (possibly containing multiple extension definitions) will + * have an outer location whose path refers to the "extensions" repeated + * field without an index. + * - Multiple locations may have the same path. This happens when a single + * logical declaration is spread out across multiple places. The most + * obvious example is the "extend" block again -- there may be multiple + * extend blocks in the same scope, each of which will have the same path. + * - A location's span is not always a subset of its parent's span. For + * example, the "extendee" of an extension declaration appears at the + * beginning of the "extend" block and is shared by all extensions within + * the block. + * - Just because a location's span is a subset of some other location's span + * does not mean that it is a descendant. For example, a "group" defines + * both a type and a field in a single declaration. Thus, the locations + * corresponding to the type and field and their components will overlap. + * - Code which tries to interpret locations should probably be designed to + * ignore those that it doesn't understand, as more types of locations could + * be recorded in the future. + */ + location: SourceCodeInfo_Location[]; +} + +export interface SourceCodeInfo_Location { + /** + * Identifies which part of the FileDescriptorProto was defined at this + * location. + * + * Each element is a field number or an index. They form a path from + * the root FileDescriptorProto to the place where the definition. For + * example, this path: + * [ 4, 3, 2, 7, 1 ] + * refers to: + * file.message_type(3) // 4, 3 + * .field(7) // 2, 7 + * .name() // 1 + * This is because FileDescriptorProto.message_type has field number 4: + * repeated DescriptorProto message_type = 4; + * and DescriptorProto.field has field number 2: + * repeated FieldDescriptorProto field = 2; + * and FieldDescriptorProto.name has field number 1: + * optional string name = 1; + * + * Thus, the above path gives the location of a field name. If we removed + * the last element: + * [ 4, 3, 2, 7 ] + * this path refers to the whole field declaration (from the beginning + * of the label to the terminating semicolon). + */ + path: number[]; + /** + * Always has exactly three or four elements: start line, start column, + * end line (optional, otherwise assumed same as start line), end column. + * These are packed into a single field for efficiency. Note that line + * and column numbers are zero-based -- typically you will want to add + * 1 to each before displaying to a user. + */ + span: number[]; + /** + * If this SourceCodeInfo represents a complete declaration, these are any + * comments appearing before and after the declaration which appear to be + * attached to the declaration. + * + * A series of line comments appearing on consecutive lines, with no other + * tokens appearing on those lines, will be treated as a single comment. + * + * leading_detached_comments will keep paragraphs of comments that appear + * before (but not connected to) the current element. Each paragraph, + * separated by empty lines, will be one comment element in the repeated + * field. + * + * Only the comment content is provided; comment markers (e.g. //) are + * stripped out. For block comments, leading whitespace and an asterisk + * will be stripped from the beginning of each line other than the first. + * Newlines are included in the output. + * + * Examples: + * + * optional int32 foo = 1; // Comment attached to foo. + * // Comment attached to bar. + * optional int32 bar = 2; + * + * optional string baz = 3; + * // Comment attached to baz. + * // Another line attached to baz. + * + * // Comment attached to qux. + * // + * // Another line attached to qux. + * optional double qux = 4; + * + * // Detached comment for corge. This is not leading or trailing comments + * // to qux or corge because there are blank lines separating it from + * // both. + * + * // Detached comment for corge paragraph 2. + * + * optional string corge = 5; + * /* Block comment attached + * * to corge. Leading asterisks + * * will be removed. * / + * /* Block comment attached to + * * grault. * / + * optional int32 grault = 6; + * + * // ignored detached comments. + */ + leadingComments: string; + trailingComments: string; + leadingDetachedComments: string[]; +} + +/** + * Describes the relationship between generated code and its original source + * file. A GeneratedCodeInfo message is associated with only one generated + * source file, but may contain references to different source .proto files. + */ +export interface GeneratedCodeInfo { + /** + * An Annotation connects some span of text in generated code to an element + * of its generating .proto file. + */ + annotation: GeneratedCodeInfo_Annotation[]; +} + +export interface GeneratedCodeInfo_Annotation { + /** + * Identifies the element in the original source .proto file. This field + * is formatted the same as SourceCodeInfo.Location.path. + */ + path: number[]; + /** Identifies the filesystem path to the original source .proto. */ + sourceFile: string; + /** + * Identifies the starting offset in bytes in the generated code + * that relates to the identified object. + */ + begin: number; + /** + * Identifies the ending offset in bytes in the generated code that + * relates to the identified offset. The end offset should be one past + * the last relevant byte (so the length of the text = end - begin). + */ + end: number; +} + +const baseFileDescriptorSet: object = {}; + +export const FileDescriptorSet = { + encode(message: FileDescriptorSet, writer: Writer = Writer.create()): Writer { + for (const v of message.file) { + FileDescriptorProto.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FileDescriptorSet { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFileDescriptorSet } as FileDescriptorSet; + message.file = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.file.push( + FileDescriptorProto.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FileDescriptorSet { + const message = { ...baseFileDescriptorSet } as FileDescriptorSet; + message.file = []; + if (object.file !== undefined && object.file !== null) { + for (const e of object.file) { + message.file.push(FileDescriptorProto.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: FileDescriptorSet): unknown { + const obj: any = {}; + if (message.file) { + obj.file = message.file.map((e) => + e ? FileDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.file = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): FileDescriptorSet { + const message = { ...baseFileDescriptorSet } as FileDescriptorSet; + message.file = []; + if (object.file !== undefined && object.file !== null) { + for (const e of object.file) { + message.file.push(FileDescriptorProto.fromPartial(e)); + } + } + return message; + }, +}; + +const baseFileDescriptorProto: object = { + name: "", + package: "", + dependency: "", + publicDependency: 0, + weakDependency: 0, + syntax: "", +}; + +export const FileDescriptorProto = { + encode( + message: FileDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.package !== "") { + writer.uint32(18).string(message.package); + } + for (const v of message.dependency) { + writer.uint32(26).string(v!); + } + writer.uint32(82).fork(); + for (const v of message.publicDependency) { + writer.int32(v); + } + writer.ldelim(); + writer.uint32(90).fork(); + for (const v of message.weakDependency) { + writer.int32(v); + } + writer.ldelim(); + for (const v of message.messageType) { + DescriptorProto.encode(v!, writer.uint32(34).fork()).ldelim(); + } + for (const v of message.enumType) { + EnumDescriptorProto.encode(v!, writer.uint32(42).fork()).ldelim(); + } + for (const v of message.service) { + ServiceDescriptorProto.encode(v!, writer.uint32(50).fork()).ldelim(); + } + for (const v of message.extension) { + FieldDescriptorProto.encode(v!, writer.uint32(58).fork()).ldelim(); + } + if (message.options !== undefined) { + FileOptions.encode(message.options, writer.uint32(66).fork()).ldelim(); + } + if (message.sourceCodeInfo !== undefined) { + SourceCodeInfo.encode( + message.sourceCodeInfo, + writer.uint32(74).fork() + ).ldelim(); + } + if (message.syntax !== "") { + writer.uint32(98).string(message.syntax); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FileDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFileDescriptorProto } as FileDescriptorProto; + message.dependency = []; + message.publicDependency = []; + message.weakDependency = []; + message.messageType = []; + message.enumType = []; + message.service = []; + message.extension = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.package = reader.string(); + break; + case 3: + message.dependency.push(reader.string()); + break; + case 10: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.publicDependency.push(reader.int32()); + } + } else { + message.publicDependency.push(reader.int32()); + } + break; + case 11: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.weakDependency.push(reader.int32()); + } + } else { + message.weakDependency.push(reader.int32()); + } + break; + case 4: + message.messageType.push( + DescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 5: + message.enumType.push( + EnumDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 6: + message.service.push( + ServiceDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 7: + message.extension.push( + FieldDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 8: + message.options = FileOptions.decode(reader, reader.uint32()); + break; + case 9: + message.sourceCodeInfo = SourceCodeInfo.decode( + reader, + reader.uint32() + ); + break; + case 12: + message.syntax = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FileDescriptorProto { + const message = { ...baseFileDescriptorProto } as FileDescriptorProto; + message.dependency = []; + message.publicDependency = []; + message.weakDependency = []; + message.messageType = []; + message.enumType = []; + message.service = []; + message.extension = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.package !== undefined && object.package !== null) { + message.package = String(object.package); + } else { + message.package = ""; + } + if (object.dependency !== undefined && object.dependency !== null) { + for (const e of object.dependency) { + message.dependency.push(String(e)); + } + } + if ( + object.publicDependency !== undefined && + object.publicDependency !== null + ) { + for (const e of object.publicDependency) { + message.publicDependency.push(Number(e)); + } + } + if (object.weakDependency !== undefined && object.weakDependency !== null) { + for (const e of object.weakDependency) { + message.weakDependency.push(Number(e)); + } + } + if (object.messageType !== undefined && object.messageType !== null) { + for (const e of object.messageType) { + message.messageType.push(DescriptorProto.fromJSON(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromJSON(e)); + } + } + if (object.service !== undefined && object.service !== null) { + for (const e of object.service) { + message.service.push(ServiceDescriptorProto.fromJSON(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = FileOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.sourceCodeInfo !== undefined && object.sourceCodeInfo !== null) { + message.sourceCodeInfo = SourceCodeInfo.fromJSON(object.sourceCodeInfo); + } else { + message.sourceCodeInfo = undefined; + } + if (object.syntax !== undefined && object.syntax !== null) { + message.syntax = String(object.syntax); + } else { + message.syntax = ""; + } + return message; + }, + + toJSON(message: FileDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.package !== undefined && (obj.package = message.package); + if (message.dependency) { + obj.dependency = message.dependency.map((e) => e); + } else { + obj.dependency = []; + } + if (message.publicDependency) { + obj.publicDependency = message.publicDependency.map((e) => e); + } else { + obj.publicDependency = []; + } + if (message.weakDependency) { + obj.weakDependency = message.weakDependency.map((e) => e); + } else { + obj.weakDependency = []; + } + if (message.messageType) { + obj.messageType = message.messageType.map((e) => + e ? DescriptorProto.toJSON(e) : undefined + ); + } else { + obj.messageType = []; + } + if (message.enumType) { + obj.enumType = message.enumType.map((e) => + e ? EnumDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.enumType = []; + } + if (message.service) { + obj.service = message.service.map((e) => + e ? ServiceDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.service = []; + } + if (message.extension) { + obj.extension = message.extension.map((e) => + e ? FieldDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.extension = []; + } + message.options !== undefined && + (obj.options = message.options + ? FileOptions.toJSON(message.options) + : undefined); + message.sourceCodeInfo !== undefined && + (obj.sourceCodeInfo = message.sourceCodeInfo + ? SourceCodeInfo.toJSON(message.sourceCodeInfo) + : undefined); + message.syntax !== undefined && (obj.syntax = message.syntax); + return obj; + }, + + fromPartial(object: DeepPartial): FileDescriptorProto { + const message = { ...baseFileDescriptorProto } as FileDescriptorProto; + message.dependency = []; + message.publicDependency = []; + message.weakDependency = []; + message.messageType = []; + message.enumType = []; + message.service = []; + message.extension = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.package !== undefined && object.package !== null) { + message.package = object.package; + } else { + message.package = ""; + } + if (object.dependency !== undefined && object.dependency !== null) { + for (const e of object.dependency) { + message.dependency.push(e); + } + } + if ( + object.publicDependency !== undefined && + object.publicDependency !== null + ) { + for (const e of object.publicDependency) { + message.publicDependency.push(e); + } + } + if (object.weakDependency !== undefined && object.weakDependency !== null) { + for (const e of object.weakDependency) { + message.weakDependency.push(e); + } + } + if (object.messageType !== undefined && object.messageType !== null) { + for (const e of object.messageType) { + message.messageType.push(DescriptorProto.fromPartial(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromPartial(e)); + } + } + if (object.service !== undefined && object.service !== null) { + for (const e of object.service) { + message.service.push(ServiceDescriptorProto.fromPartial(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = FileOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.sourceCodeInfo !== undefined && object.sourceCodeInfo !== null) { + message.sourceCodeInfo = SourceCodeInfo.fromPartial( + object.sourceCodeInfo + ); + } else { + message.sourceCodeInfo = undefined; + } + if (object.syntax !== undefined && object.syntax !== null) { + message.syntax = object.syntax; + } else { + message.syntax = ""; + } + return message; + }, +}; + +const baseDescriptorProto: object = { name: "", reservedName: "" }; + +export const DescriptorProto = { + encode(message: DescriptorProto, writer: Writer = Writer.create()): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + for (const v of message.field) { + FieldDescriptorProto.encode(v!, writer.uint32(18).fork()).ldelim(); + } + for (const v of message.extension) { + FieldDescriptorProto.encode(v!, writer.uint32(50).fork()).ldelim(); + } + for (const v of message.nestedType) { + DescriptorProto.encode(v!, writer.uint32(26).fork()).ldelim(); + } + for (const v of message.enumType) { + EnumDescriptorProto.encode(v!, writer.uint32(34).fork()).ldelim(); + } + for (const v of message.extensionRange) { + DescriptorProto_ExtensionRange.encode( + v!, + writer.uint32(42).fork() + ).ldelim(); + } + for (const v of message.oneofDecl) { + OneofDescriptorProto.encode(v!, writer.uint32(66).fork()).ldelim(); + } + if (message.options !== undefined) { + MessageOptions.encode(message.options, writer.uint32(58).fork()).ldelim(); + } + for (const v of message.reservedRange) { + DescriptorProto_ReservedRange.encode( + v!, + writer.uint32(74).fork() + ).ldelim(); + } + for (const v of message.reservedName) { + writer.uint32(82).string(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): DescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseDescriptorProto } as DescriptorProto; + message.field = []; + message.extension = []; + message.nestedType = []; + message.enumType = []; + message.extensionRange = []; + message.oneofDecl = []; + message.reservedRange = []; + message.reservedName = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.field.push( + FieldDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 6: + message.extension.push( + FieldDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 3: + message.nestedType.push( + DescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 4: + message.enumType.push( + EnumDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 5: + message.extensionRange.push( + DescriptorProto_ExtensionRange.decode(reader, reader.uint32()) + ); + break; + case 8: + message.oneofDecl.push( + OneofDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 7: + message.options = MessageOptions.decode(reader, reader.uint32()); + break; + case 9: + message.reservedRange.push( + DescriptorProto_ReservedRange.decode(reader, reader.uint32()) + ); + break; + case 10: + message.reservedName.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DescriptorProto { + const message = { ...baseDescriptorProto } as DescriptorProto; + message.field = []; + message.extension = []; + message.nestedType = []; + message.enumType = []; + message.extensionRange = []; + message.oneofDecl = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.field !== undefined && object.field !== null) { + for (const e of object.field) { + message.field.push(FieldDescriptorProto.fromJSON(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromJSON(e)); + } + } + if (object.nestedType !== undefined && object.nestedType !== null) { + for (const e of object.nestedType) { + message.nestedType.push(DescriptorProto.fromJSON(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromJSON(e)); + } + } + if (object.extensionRange !== undefined && object.extensionRange !== null) { + for (const e of object.extensionRange) { + message.extensionRange.push(DescriptorProto_ExtensionRange.fromJSON(e)); + } + } + if (object.oneofDecl !== undefined && object.oneofDecl !== null) { + for (const e of object.oneofDecl) { + message.oneofDecl.push(OneofDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = MessageOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push(DescriptorProto_ReservedRange.fromJSON(e)); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(String(e)); + } + } + return message; + }, + + toJSON(message: DescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + if (message.field) { + obj.field = message.field.map((e) => + e ? FieldDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.field = []; + } + if (message.extension) { + obj.extension = message.extension.map((e) => + e ? FieldDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.extension = []; + } + if (message.nestedType) { + obj.nestedType = message.nestedType.map((e) => + e ? DescriptorProto.toJSON(e) : undefined + ); + } else { + obj.nestedType = []; + } + if (message.enumType) { + obj.enumType = message.enumType.map((e) => + e ? EnumDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.enumType = []; + } + if (message.extensionRange) { + obj.extensionRange = message.extensionRange.map((e) => + e ? DescriptorProto_ExtensionRange.toJSON(e) : undefined + ); + } else { + obj.extensionRange = []; + } + if (message.oneofDecl) { + obj.oneofDecl = message.oneofDecl.map((e) => + e ? OneofDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.oneofDecl = []; + } + message.options !== undefined && + (obj.options = message.options + ? MessageOptions.toJSON(message.options) + : undefined); + if (message.reservedRange) { + obj.reservedRange = message.reservedRange.map((e) => + e ? DescriptorProto_ReservedRange.toJSON(e) : undefined + ); + } else { + obj.reservedRange = []; + } + if (message.reservedName) { + obj.reservedName = message.reservedName.map((e) => e); + } else { + obj.reservedName = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): DescriptorProto { + const message = { ...baseDescriptorProto } as DescriptorProto; + message.field = []; + message.extension = []; + message.nestedType = []; + message.enumType = []; + message.extensionRange = []; + message.oneofDecl = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.field !== undefined && object.field !== null) { + for (const e of object.field) { + message.field.push(FieldDescriptorProto.fromPartial(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromPartial(e)); + } + } + if (object.nestedType !== undefined && object.nestedType !== null) { + for (const e of object.nestedType) { + message.nestedType.push(DescriptorProto.fromPartial(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromPartial(e)); + } + } + if (object.extensionRange !== undefined && object.extensionRange !== null) { + for (const e of object.extensionRange) { + message.extensionRange.push( + DescriptorProto_ExtensionRange.fromPartial(e) + ); + } + } + if (object.oneofDecl !== undefined && object.oneofDecl !== null) { + for (const e of object.oneofDecl) { + message.oneofDecl.push(OneofDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = MessageOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push( + DescriptorProto_ReservedRange.fromPartial(e) + ); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(e); + } + } + return message; + }, +}; + +const baseDescriptorProto_ExtensionRange: object = { start: 0, end: 0 }; + +export const DescriptorProto_ExtensionRange = { + encode( + message: DescriptorProto_ExtensionRange, + writer: Writer = Writer.create() + ): Writer { + if (message.start !== 0) { + writer.uint32(8).int32(message.start); + } + if (message.end !== 0) { + writer.uint32(16).int32(message.end); + } + if (message.options !== undefined) { + ExtensionRangeOptions.encode( + message.options, + writer.uint32(26).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): DescriptorProto_ExtensionRange { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseDescriptorProto_ExtensionRange, + } as DescriptorProto_ExtensionRange; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.start = reader.int32(); + break; + case 2: + message.end = reader.int32(); + break; + case 3: + message.options = ExtensionRangeOptions.decode( + reader, + reader.uint32() + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DescriptorProto_ExtensionRange { + const message = { + ...baseDescriptorProto_ExtensionRange, + } as DescriptorProto_ExtensionRange; + if (object.start !== undefined && object.start !== null) { + message.start = Number(object.start); + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = ExtensionRangeOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: DescriptorProto_ExtensionRange): unknown { + const obj: any = {}; + message.start !== undefined && (obj.start = message.start); + message.end !== undefined && (obj.end = message.end); + message.options !== undefined && + (obj.options = message.options + ? ExtensionRangeOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): DescriptorProto_ExtensionRange { + const message = { + ...baseDescriptorProto_ExtensionRange, + } as DescriptorProto_ExtensionRange; + if (object.start !== undefined && object.start !== null) { + message.start = object.start; + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = ExtensionRangeOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseDescriptorProto_ReservedRange: object = { start: 0, end: 0 }; + +export const DescriptorProto_ReservedRange = { + encode( + message: DescriptorProto_ReservedRange, + writer: Writer = Writer.create() + ): Writer { + if (message.start !== 0) { + writer.uint32(8).int32(message.start); + } + if (message.end !== 0) { + writer.uint32(16).int32(message.end); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): DescriptorProto_ReservedRange { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseDescriptorProto_ReservedRange, + } as DescriptorProto_ReservedRange; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.start = reader.int32(); + break; + case 2: + message.end = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DescriptorProto_ReservedRange { + const message = { + ...baseDescriptorProto_ReservedRange, + } as DescriptorProto_ReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = Number(object.start); + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + return message; + }, + + toJSON(message: DescriptorProto_ReservedRange): unknown { + const obj: any = {}; + message.start !== undefined && (obj.start = message.start); + message.end !== undefined && (obj.end = message.end); + return obj; + }, + + fromPartial( + object: DeepPartial + ): DescriptorProto_ReservedRange { + const message = { + ...baseDescriptorProto_ReservedRange, + } as DescriptorProto_ReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = object.start; + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + return message; + }, +}; + +const baseExtensionRangeOptions: object = {}; + +export const ExtensionRangeOptions = { + encode( + message: ExtensionRangeOptions, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ExtensionRangeOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseExtensionRangeOptions } as ExtensionRangeOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ExtensionRangeOptions { + const message = { ...baseExtensionRangeOptions } as ExtensionRangeOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: ExtensionRangeOptions): unknown { + const obj: any = {}; + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial( + object: DeepPartial + ): ExtensionRangeOptions { + const message = { ...baseExtensionRangeOptions } as ExtensionRangeOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseFieldDescriptorProto: object = { + name: "", + number: 0, + label: 1, + type: 1, + typeName: "", + extendee: "", + defaultValue: "", + oneofIndex: 0, + jsonName: "", + proto3Optional: false, +}; + +export const FieldDescriptorProto = { + encode( + message: FieldDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.number !== 0) { + writer.uint32(24).int32(message.number); + } + if (message.label !== 1) { + writer.uint32(32).int32(message.label); + } + if (message.type !== 1) { + writer.uint32(40).int32(message.type); + } + if (message.typeName !== "") { + writer.uint32(50).string(message.typeName); + } + if (message.extendee !== "") { + writer.uint32(18).string(message.extendee); + } + if (message.defaultValue !== "") { + writer.uint32(58).string(message.defaultValue); + } + if (message.oneofIndex !== 0) { + writer.uint32(72).int32(message.oneofIndex); + } + if (message.jsonName !== "") { + writer.uint32(82).string(message.jsonName); + } + if (message.options !== undefined) { + FieldOptions.encode(message.options, writer.uint32(66).fork()).ldelim(); + } + if (message.proto3Optional === true) { + writer.uint32(136).bool(message.proto3Optional); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FieldDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFieldDescriptorProto } as FieldDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 3: + message.number = reader.int32(); + break; + case 4: + message.label = reader.int32() as any; + break; + case 5: + message.type = reader.int32() as any; + break; + case 6: + message.typeName = reader.string(); + break; + case 2: + message.extendee = reader.string(); + break; + case 7: + message.defaultValue = reader.string(); + break; + case 9: + message.oneofIndex = reader.int32(); + break; + case 10: + message.jsonName = reader.string(); + break; + case 8: + message.options = FieldOptions.decode(reader, reader.uint32()); + break; + case 17: + message.proto3Optional = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FieldDescriptorProto { + const message = { ...baseFieldDescriptorProto } as FieldDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = Number(object.number); + } else { + message.number = 0; + } + if (object.label !== undefined && object.label !== null) { + message.label = fieldDescriptorProto_LabelFromJSON(object.label); + } else { + message.label = 1; + } + if (object.type !== undefined && object.type !== null) { + message.type = fieldDescriptorProto_TypeFromJSON(object.type); + } else { + message.type = 1; + } + if (object.typeName !== undefined && object.typeName !== null) { + message.typeName = String(object.typeName); + } else { + message.typeName = ""; + } + if (object.extendee !== undefined && object.extendee !== null) { + message.extendee = String(object.extendee); + } else { + message.extendee = ""; + } + if (object.defaultValue !== undefined && object.defaultValue !== null) { + message.defaultValue = String(object.defaultValue); + } else { + message.defaultValue = ""; + } + if (object.oneofIndex !== undefined && object.oneofIndex !== null) { + message.oneofIndex = Number(object.oneofIndex); + } else { + message.oneofIndex = 0; + } + if (object.jsonName !== undefined && object.jsonName !== null) { + message.jsonName = String(object.jsonName); + } else { + message.jsonName = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = FieldOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.proto3Optional !== undefined && object.proto3Optional !== null) { + message.proto3Optional = Boolean(object.proto3Optional); + } else { + message.proto3Optional = false; + } + return message; + }, + + toJSON(message: FieldDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.number !== undefined && (obj.number = message.number); + message.label !== undefined && + (obj.label = fieldDescriptorProto_LabelToJSON(message.label)); + message.type !== undefined && + (obj.type = fieldDescriptorProto_TypeToJSON(message.type)); + message.typeName !== undefined && (obj.typeName = message.typeName); + message.extendee !== undefined && (obj.extendee = message.extendee); + message.defaultValue !== undefined && + (obj.defaultValue = message.defaultValue); + message.oneofIndex !== undefined && (obj.oneofIndex = message.oneofIndex); + message.jsonName !== undefined && (obj.jsonName = message.jsonName); + message.options !== undefined && + (obj.options = message.options + ? FieldOptions.toJSON(message.options) + : undefined); + message.proto3Optional !== undefined && + (obj.proto3Optional = message.proto3Optional); + return obj; + }, + + fromPartial(object: DeepPartial): FieldDescriptorProto { + const message = { ...baseFieldDescriptorProto } as FieldDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = object.number; + } else { + message.number = 0; + } + if (object.label !== undefined && object.label !== null) { + message.label = object.label; + } else { + message.label = 1; + } + if (object.type !== undefined && object.type !== null) { + message.type = object.type; + } else { + message.type = 1; + } + if (object.typeName !== undefined && object.typeName !== null) { + message.typeName = object.typeName; + } else { + message.typeName = ""; + } + if (object.extendee !== undefined && object.extendee !== null) { + message.extendee = object.extendee; + } else { + message.extendee = ""; + } + if (object.defaultValue !== undefined && object.defaultValue !== null) { + message.defaultValue = object.defaultValue; + } else { + message.defaultValue = ""; + } + if (object.oneofIndex !== undefined && object.oneofIndex !== null) { + message.oneofIndex = object.oneofIndex; + } else { + message.oneofIndex = 0; + } + if (object.jsonName !== undefined && object.jsonName !== null) { + message.jsonName = object.jsonName; + } else { + message.jsonName = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = FieldOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.proto3Optional !== undefined && object.proto3Optional !== null) { + message.proto3Optional = object.proto3Optional; + } else { + message.proto3Optional = false; + } + return message; + }, +}; + +const baseOneofDescriptorProto: object = { name: "" }; + +export const OneofDescriptorProto = { + encode( + message: OneofDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.options !== undefined) { + OneofOptions.encode(message.options, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): OneofDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseOneofDescriptorProto } as OneofDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.options = OneofOptions.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): OneofDescriptorProto { + const message = { ...baseOneofDescriptorProto } as OneofDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = OneofOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: OneofDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.options !== undefined && + (obj.options = message.options + ? OneofOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): OneofDescriptorProto { + const message = { ...baseOneofDescriptorProto } as OneofDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = OneofOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseEnumDescriptorProto: object = { name: "", reservedName: "" }; + +export const EnumDescriptorProto = { + encode( + message: EnumDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + for (const v of message.value) { + EnumValueDescriptorProto.encode(v!, writer.uint32(18).fork()).ldelim(); + } + if (message.options !== undefined) { + EnumOptions.encode(message.options, writer.uint32(26).fork()).ldelim(); + } + for (const v of message.reservedRange) { + EnumDescriptorProto_EnumReservedRange.encode( + v!, + writer.uint32(34).fork() + ).ldelim(); + } + for (const v of message.reservedName) { + writer.uint32(42).string(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): EnumDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseEnumDescriptorProto } as EnumDescriptorProto; + message.value = []; + message.reservedRange = []; + message.reservedName = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.value.push( + EnumValueDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 3: + message.options = EnumOptions.decode(reader, reader.uint32()); + break; + case 4: + message.reservedRange.push( + EnumDescriptorProto_EnumReservedRange.decode( + reader, + reader.uint32() + ) + ); + break; + case 5: + message.reservedName.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumDescriptorProto { + const message = { ...baseEnumDescriptorProto } as EnumDescriptorProto; + message.value = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.value !== undefined && object.value !== null) { + for (const e of object.value) { + message.value.push(EnumValueDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push( + EnumDescriptorProto_EnumReservedRange.fromJSON(e) + ); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(String(e)); + } + } + return message; + }, + + toJSON(message: EnumDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + if (message.value) { + obj.value = message.value.map((e) => + e ? EnumValueDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.value = []; + } + message.options !== undefined && + (obj.options = message.options + ? EnumOptions.toJSON(message.options) + : undefined); + if (message.reservedRange) { + obj.reservedRange = message.reservedRange.map((e) => + e ? EnumDescriptorProto_EnumReservedRange.toJSON(e) : undefined + ); + } else { + obj.reservedRange = []; + } + if (message.reservedName) { + obj.reservedName = message.reservedName.map((e) => e); + } else { + obj.reservedName = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): EnumDescriptorProto { + const message = { ...baseEnumDescriptorProto } as EnumDescriptorProto; + message.value = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.value !== undefined && object.value !== null) { + for (const e of object.value) { + message.value.push(EnumValueDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push( + EnumDescriptorProto_EnumReservedRange.fromPartial(e) + ); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(e); + } + } + return message; + }, +}; + +const baseEnumDescriptorProto_EnumReservedRange: object = { start: 0, end: 0 }; + +export const EnumDescriptorProto_EnumReservedRange = { + encode( + message: EnumDescriptorProto_EnumReservedRange, + writer: Writer = Writer.create() + ): Writer { + if (message.start !== 0) { + writer.uint32(8).int32(message.start); + } + if (message.end !== 0) { + writer.uint32(16).int32(message.end); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): EnumDescriptorProto_EnumReservedRange { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseEnumDescriptorProto_EnumReservedRange, + } as EnumDescriptorProto_EnumReservedRange; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.start = reader.int32(); + break; + case 2: + message.end = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumDescriptorProto_EnumReservedRange { + const message = { + ...baseEnumDescriptorProto_EnumReservedRange, + } as EnumDescriptorProto_EnumReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = Number(object.start); + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + return message; + }, + + toJSON(message: EnumDescriptorProto_EnumReservedRange): unknown { + const obj: any = {}; + message.start !== undefined && (obj.start = message.start); + message.end !== undefined && (obj.end = message.end); + return obj; + }, + + fromPartial( + object: DeepPartial + ): EnumDescriptorProto_EnumReservedRange { + const message = { + ...baseEnumDescriptorProto_EnumReservedRange, + } as EnumDescriptorProto_EnumReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = object.start; + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + return message; + }, +}; + +const baseEnumValueDescriptorProto: object = { name: "", number: 0 }; + +export const EnumValueDescriptorProto = { + encode( + message: EnumValueDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.number !== 0) { + writer.uint32(16).int32(message.number); + } + if (message.options !== undefined) { + EnumValueOptions.encode( + message.options, + writer.uint32(26).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): EnumValueDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseEnumValueDescriptorProto, + } as EnumValueDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.number = reader.int32(); + break; + case 3: + message.options = EnumValueOptions.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumValueDescriptorProto { + const message = { + ...baseEnumValueDescriptorProto, + } as EnumValueDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = Number(object.number); + } else { + message.number = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumValueOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: EnumValueDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.number !== undefined && (obj.number = message.number); + message.options !== undefined && + (obj.options = message.options + ? EnumValueOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): EnumValueDescriptorProto { + const message = { + ...baseEnumValueDescriptorProto, + } as EnumValueDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = object.number; + } else { + message.number = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumValueOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseServiceDescriptorProto: object = { name: "" }; + +export const ServiceDescriptorProto = { + encode( + message: ServiceDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + for (const v of message.method) { + MethodDescriptorProto.encode(v!, writer.uint32(18).fork()).ldelim(); + } + if (message.options !== undefined) { + ServiceOptions.encode(message.options, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ServiceDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseServiceDescriptorProto } as ServiceDescriptorProto; + message.method = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.method.push( + MethodDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 3: + message.options = ServiceOptions.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ServiceDescriptorProto { + const message = { ...baseServiceDescriptorProto } as ServiceDescriptorProto; + message.method = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.method !== undefined && object.method !== null) { + for (const e of object.method) { + message.method.push(MethodDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = ServiceOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: ServiceDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + if (message.method) { + obj.method = message.method.map((e) => + e ? MethodDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.method = []; + } + message.options !== undefined && + (obj.options = message.options + ? ServiceOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): ServiceDescriptorProto { + const message = { ...baseServiceDescriptorProto } as ServiceDescriptorProto; + message.method = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.method !== undefined && object.method !== null) { + for (const e of object.method) { + message.method.push(MethodDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = ServiceOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseMethodDescriptorProto: object = { + name: "", + inputType: "", + outputType: "", + clientStreaming: false, + serverStreaming: false, +}; + +export const MethodDescriptorProto = { + encode( + message: MethodDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.inputType !== "") { + writer.uint32(18).string(message.inputType); + } + if (message.outputType !== "") { + writer.uint32(26).string(message.outputType); + } + if (message.options !== undefined) { + MethodOptions.encode(message.options, writer.uint32(34).fork()).ldelim(); + } + if (message.clientStreaming === true) { + writer.uint32(40).bool(message.clientStreaming); + } + if (message.serverStreaming === true) { + writer.uint32(48).bool(message.serverStreaming); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MethodDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMethodDescriptorProto } as MethodDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.inputType = reader.string(); + break; + case 3: + message.outputType = reader.string(); + break; + case 4: + message.options = MethodOptions.decode(reader, reader.uint32()); + break; + case 5: + message.clientStreaming = reader.bool(); + break; + case 6: + message.serverStreaming = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MethodDescriptorProto { + const message = { ...baseMethodDescriptorProto } as MethodDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.inputType !== undefined && object.inputType !== null) { + message.inputType = String(object.inputType); + } else { + message.inputType = ""; + } + if (object.outputType !== undefined && object.outputType !== null) { + message.outputType = String(object.outputType); + } else { + message.outputType = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = MethodOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if ( + object.clientStreaming !== undefined && + object.clientStreaming !== null + ) { + message.clientStreaming = Boolean(object.clientStreaming); + } else { + message.clientStreaming = false; + } + if ( + object.serverStreaming !== undefined && + object.serverStreaming !== null + ) { + message.serverStreaming = Boolean(object.serverStreaming); + } else { + message.serverStreaming = false; + } + return message; + }, + + toJSON(message: MethodDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.inputType !== undefined && (obj.inputType = message.inputType); + message.outputType !== undefined && (obj.outputType = message.outputType); + message.options !== undefined && + (obj.options = message.options + ? MethodOptions.toJSON(message.options) + : undefined); + message.clientStreaming !== undefined && + (obj.clientStreaming = message.clientStreaming); + message.serverStreaming !== undefined && + (obj.serverStreaming = message.serverStreaming); + return obj; + }, + + fromPartial( + object: DeepPartial + ): MethodDescriptorProto { + const message = { ...baseMethodDescriptorProto } as MethodDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.inputType !== undefined && object.inputType !== null) { + message.inputType = object.inputType; + } else { + message.inputType = ""; + } + if (object.outputType !== undefined && object.outputType !== null) { + message.outputType = object.outputType; + } else { + message.outputType = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = MethodOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if ( + object.clientStreaming !== undefined && + object.clientStreaming !== null + ) { + message.clientStreaming = object.clientStreaming; + } else { + message.clientStreaming = false; + } + if ( + object.serverStreaming !== undefined && + object.serverStreaming !== null + ) { + message.serverStreaming = object.serverStreaming; + } else { + message.serverStreaming = false; + } + return message; + }, +}; + +const baseFileOptions: object = { + javaPackage: "", + javaOuterClassname: "", + javaMultipleFiles: false, + javaGenerateEqualsAndHash: false, + javaStringCheckUtf8: false, + optimizeFor: 1, + goPackage: "", + ccGenericServices: false, + javaGenericServices: false, + pyGenericServices: false, + phpGenericServices: false, + deprecated: false, + ccEnableArenas: false, + objcClassPrefix: "", + csharpNamespace: "", + swiftPrefix: "", + phpClassPrefix: "", + phpNamespace: "", + phpMetadataNamespace: "", + rubyPackage: "", +}; + +export const FileOptions = { + encode(message: FileOptions, writer: Writer = Writer.create()): Writer { + if (message.javaPackage !== "") { + writer.uint32(10).string(message.javaPackage); + } + if (message.javaOuterClassname !== "") { + writer.uint32(66).string(message.javaOuterClassname); + } + if (message.javaMultipleFiles === true) { + writer.uint32(80).bool(message.javaMultipleFiles); + } + if (message.javaGenerateEqualsAndHash === true) { + writer.uint32(160).bool(message.javaGenerateEqualsAndHash); + } + if (message.javaStringCheckUtf8 === true) { + writer.uint32(216).bool(message.javaStringCheckUtf8); + } + if (message.optimizeFor !== 1) { + writer.uint32(72).int32(message.optimizeFor); + } + if (message.goPackage !== "") { + writer.uint32(90).string(message.goPackage); + } + if (message.ccGenericServices === true) { + writer.uint32(128).bool(message.ccGenericServices); + } + if (message.javaGenericServices === true) { + writer.uint32(136).bool(message.javaGenericServices); + } + if (message.pyGenericServices === true) { + writer.uint32(144).bool(message.pyGenericServices); + } + if (message.phpGenericServices === true) { + writer.uint32(336).bool(message.phpGenericServices); + } + if (message.deprecated === true) { + writer.uint32(184).bool(message.deprecated); + } + if (message.ccEnableArenas === true) { + writer.uint32(248).bool(message.ccEnableArenas); + } + if (message.objcClassPrefix !== "") { + writer.uint32(290).string(message.objcClassPrefix); + } + if (message.csharpNamespace !== "") { + writer.uint32(298).string(message.csharpNamespace); + } + if (message.swiftPrefix !== "") { + writer.uint32(314).string(message.swiftPrefix); + } + if (message.phpClassPrefix !== "") { + writer.uint32(322).string(message.phpClassPrefix); + } + if (message.phpNamespace !== "") { + writer.uint32(330).string(message.phpNamespace); + } + if (message.phpMetadataNamespace !== "") { + writer.uint32(354).string(message.phpMetadataNamespace); + } + if (message.rubyPackage !== "") { + writer.uint32(362).string(message.rubyPackage); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FileOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFileOptions } as FileOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.javaPackage = reader.string(); + break; + case 8: + message.javaOuterClassname = reader.string(); + break; + case 10: + message.javaMultipleFiles = reader.bool(); + break; + case 20: + message.javaGenerateEqualsAndHash = reader.bool(); + break; + case 27: + message.javaStringCheckUtf8 = reader.bool(); + break; + case 9: + message.optimizeFor = reader.int32() as any; + break; + case 11: + message.goPackage = reader.string(); + break; + case 16: + message.ccGenericServices = reader.bool(); + break; + case 17: + message.javaGenericServices = reader.bool(); + break; + case 18: + message.pyGenericServices = reader.bool(); + break; + case 42: + message.phpGenericServices = reader.bool(); + break; + case 23: + message.deprecated = reader.bool(); + break; + case 31: + message.ccEnableArenas = reader.bool(); + break; + case 36: + message.objcClassPrefix = reader.string(); + break; + case 37: + message.csharpNamespace = reader.string(); + break; + case 39: + message.swiftPrefix = reader.string(); + break; + case 40: + message.phpClassPrefix = reader.string(); + break; + case 41: + message.phpNamespace = reader.string(); + break; + case 44: + message.phpMetadataNamespace = reader.string(); + break; + case 45: + message.rubyPackage = reader.string(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FileOptions { + const message = { ...baseFileOptions } as FileOptions; + message.uninterpretedOption = []; + if (object.javaPackage !== undefined && object.javaPackage !== null) { + message.javaPackage = String(object.javaPackage); + } else { + message.javaPackage = ""; + } + if ( + object.javaOuterClassname !== undefined && + object.javaOuterClassname !== null + ) { + message.javaOuterClassname = String(object.javaOuterClassname); + } else { + message.javaOuterClassname = ""; + } + if ( + object.javaMultipleFiles !== undefined && + object.javaMultipleFiles !== null + ) { + message.javaMultipleFiles = Boolean(object.javaMultipleFiles); + } else { + message.javaMultipleFiles = false; + } + if ( + object.javaGenerateEqualsAndHash !== undefined && + object.javaGenerateEqualsAndHash !== null + ) { + message.javaGenerateEqualsAndHash = Boolean( + object.javaGenerateEqualsAndHash + ); + } else { + message.javaGenerateEqualsAndHash = false; + } + if ( + object.javaStringCheckUtf8 !== undefined && + object.javaStringCheckUtf8 !== null + ) { + message.javaStringCheckUtf8 = Boolean(object.javaStringCheckUtf8); + } else { + message.javaStringCheckUtf8 = false; + } + if (object.optimizeFor !== undefined && object.optimizeFor !== null) { + message.optimizeFor = fileOptions_OptimizeModeFromJSON( + object.optimizeFor + ); + } else { + message.optimizeFor = 1; + } + if (object.goPackage !== undefined && object.goPackage !== null) { + message.goPackage = String(object.goPackage); + } else { + message.goPackage = ""; + } + if ( + object.ccGenericServices !== undefined && + object.ccGenericServices !== null + ) { + message.ccGenericServices = Boolean(object.ccGenericServices); + } else { + message.ccGenericServices = false; + } + if ( + object.javaGenericServices !== undefined && + object.javaGenericServices !== null + ) { + message.javaGenericServices = Boolean(object.javaGenericServices); + } else { + message.javaGenericServices = false; + } + if ( + object.pyGenericServices !== undefined && + object.pyGenericServices !== null + ) { + message.pyGenericServices = Boolean(object.pyGenericServices); + } else { + message.pyGenericServices = false; + } + if ( + object.phpGenericServices !== undefined && + object.phpGenericServices !== null + ) { + message.phpGenericServices = Boolean(object.phpGenericServices); + } else { + message.phpGenericServices = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if (object.ccEnableArenas !== undefined && object.ccEnableArenas !== null) { + message.ccEnableArenas = Boolean(object.ccEnableArenas); + } else { + message.ccEnableArenas = false; + } + if ( + object.objcClassPrefix !== undefined && + object.objcClassPrefix !== null + ) { + message.objcClassPrefix = String(object.objcClassPrefix); + } else { + message.objcClassPrefix = ""; + } + if ( + object.csharpNamespace !== undefined && + object.csharpNamespace !== null + ) { + message.csharpNamespace = String(object.csharpNamespace); + } else { + message.csharpNamespace = ""; + } + if (object.swiftPrefix !== undefined && object.swiftPrefix !== null) { + message.swiftPrefix = String(object.swiftPrefix); + } else { + message.swiftPrefix = ""; + } + if (object.phpClassPrefix !== undefined && object.phpClassPrefix !== null) { + message.phpClassPrefix = String(object.phpClassPrefix); + } else { + message.phpClassPrefix = ""; + } + if (object.phpNamespace !== undefined && object.phpNamespace !== null) { + message.phpNamespace = String(object.phpNamespace); + } else { + message.phpNamespace = ""; + } + if ( + object.phpMetadataNamespace !== undefined && + object.phpMetadataNamespace !== null + ) { + message.phpMetadataNamespace = String(object.phpMetadataNamespace); + } else { + message.phpMetadataNamespace = ""; + } + if (object.rubyPackage !== undefined && object.rubyPackage !== null) { + message.rubyPackage = String(object.rubyPackage); + } else { + message.rubyPackage = ""; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: FileOptions): unknown { + const obj: any = {}; + message.javaPackage !== undefined && + (obj.javaPackage = message.javaPackage); + message.javaOuterClassname !== undefined && + (obj.javaOuterClassname = message.javaOuterClassname); + message.javaMultipleFiles !== undefined && + (obj.javaMultipleFiles = message.javaMultipleFiles); + message.javaGenerateEqualsAndHash !== undefined && + (obj.javaGenerateEqualsAndHash = message.javaGenerateEqualsAndHash); + message.javaStringCheckUtf8 !== undefined && + (obj.javaStringCheckUtf8 = message.javaStringCheckUtf8); + message.optimizeFor !== undefined && + (obj.optimizeFor = fileOptions_OptimizeModeToJSON(message.optimizeFor)); + message.goPackage !== undefined && (obj.goPackage = message.goPackage); + message.ccGenericServices !== undefined && + (obj.ccGenericServices = message.ccGenericServices); + message.javaGenericServices !== undefined && + (obj.javaGenericServices = message.javaGenericServices); + message.pyGenericServices !== undefined && + (obj.pyGenericServices = message.pyGenericServices); + message.phpGenericServices !== undefined && + (obj.phpGenericServices = message.phpGenericServices); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.ccEnableArenas !== undefined && + (obj.ccEnableArenas = message.ccEnableArenas); + message.objcClassPrefix !== undefined && + (obj.objcClassPrefix = message.objcClassPrefix); + message.csharpNamespace !== undefined && + (obj.csharpNamespace = message.csharpNamespace); + message.swiftPrefix !== undefined && + (obj.swiftPrefix = message.swiftPrefix); + message.phpClassPrefix !== undefined && + (obj.phpClassPrefix = message.phpClassPrefix); + message.phpNamespace !== undefined && + (obj.phpNamespace = message.phpNamespace); + message.phpMetadataNamespace !== undefined && + (obj.phpMetadataNamespace = message.phpMetadataNamespace); + message.rubyPackage !== undefined && + (obj.rubyPackage = message.rubyPackage); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): FileOptions { + const message = { ...baseFileOptions } as FileOptions; + message.uninterpretedOption = []; + if (object.javaPackage !== undefined && object.javaPackage !== null) { + message.javaPackage = object.javaPackage; + } else { + message.javaPackage = ""; + } + if ( + object.javaOuterClassname !== undefined && + object.javaOuterClassname !== null + ) { + message.javaOuterClassname = object.javaOuterClassname; + } else { + message.javaOuterClassname = ""; + } + if ( + object.javaMultipleFiles !== undefined && + object.javaMultipleFiles !== null + ) { + message.javaMultipleFiles = object.javaMultipleFiles; + } else { + message.javaMultipleFiles = false; + } + if ( + object.javaGenerateEqualsAndHash !== undefined && + object.javaGenerateEqualsAndHash !== null + ) { + message.javaGenerateEqualsAndHash = object.javaGenerateEqualsAndHash; + } else { + message.javaGenerateEqualsAndHash = false; + } + if ( + object.javaStringCheckUtf8 !== undefined && + object.javaStringCheckUtf8 !== null + ) { + message.javaStringCheckUtf8 = object.javaStringCheckUtf8; + } else { + message.javaStringCheckUtf8 = false; + } + if (object.optimizeFor !== undefined && object.optimizeFor !== null) { + message.optimizeFor = object.optimizeFor; + } else { + message.optimizeFor = 1; + } + if (object.goPackage !== undefined && object.goPackage !== null) { + message.goPackage = object.goPackage; + } else { + message.goPackage = ""; + } + if ( + object.ccGenericServices !== undefined && + object.ccGenericServices !== null + ) { + message.ccGenericServices = object.ccGenericServices; + } else { + message.ccGenericServices = false; + } + if ( + object.javaGenericServices !== undefined && + object.javaGenericServices !== null + ) { + message.javaGenericServices = object.javaGenericServices; + } else { + message.javaGenericServices = false; + } + if ( + object.pyGenericServices !== undefined && + object.pyGenericServices !== null + ) { + message.pyGenericServices = object.pyGenericServices; + } else { + message.pyGenericServices = false; + } + if ( + object.phpGenericServices !== undefined && + object.phpGenericServices !== null + ) { + message.phpGenericServices = object.phpGenericServices; + } else { + message.phpGenericServices = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if (object.ccEnableArenas !== undefined && object.ccEnableArenas !== null) { + message.ccEnableArenas = object.ccEnableArenas; + } else { + message.ccEnableArenas = false; + } + if ( + object.objcClassPrefix !== undefined && + object.objcClassPrefix !== null + ) { + message.objcClassPrefix = object.objcClassPrefix; + } else { + message.objcClassPrefix = ""; + } + if ( + object.csharpNamespace !== undefined && + object.csharpNamespace !== null + ) { + message.csharpNamespace = object.csharpNamespace; + } else { + message.csharpNamespace = ""; + } + if (object.swiftPrefix !== undefined && object.swiftPrefix !== null) { + message.swiftPrefix = object.swiftPrefix; + } else { + message.swiftPrefix = ""; + } + if (object.phpClassPrefix !== undefined && object.phpClassPrefix !== null) { + message.phpClassPrefix = object.phpClassPrefix; + } else { + message.phpClassPrefix = ""; + } + if (object.phpNamespace !== undefined && object.phpNamespace !== null) { + message.phpNamespace = object.phpNamespace; + } else { + message.phpNamespace = ""; + } + if ( + object.phpMetadataNamespace !== undefined && + object.phpMetadataNamespace !== null + ) { + message.phpMetadataNamespace = object.phpMetadataNamespace; + } else { + message.phpMetadataNamespace = ""; + } + if (object.rubyPackage !== undefined && object.rubyPackage !== null) { + message.rubyPackage = object.rubyPackage; + } else { + message.rubyPackage = ""; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseMessageOptions: object = { + messageSetWireFormat: false, + noStandardDescriptorAccessor: false, + deprecated: false, + mapEntry: false, +}; + +export const MessageOptions = { + encode(message: MessageOptions, writer: Writer = Writer.create()): Writer { + if (message.messageSetWireFormat === true) { + writer.uint32(8).bool(message.messageSetWireFormat); + } + if (message.noStandardDescriptorAccessor === true) { + writer.uint32(16).bool(message.noStandardDescriptorAccessor); + } + if (message.deprecated === true) { + writer.uint32(24).bool(message.deprecated); + } + if (message.mapEntry === true) { + writer.uint32(56).bool(message.mapEntry); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MessageOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMessageOptions } as MessageOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.messageSetWireFormat = reader.bool(); + break; + case 2: + message.noStandardDescriptorAccessor = reader.bool(); + break; + case 3: + message.deprecated = reader.bool(); + break; + case 7: + message.mapEntry = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MessageOptions { + const message = { ...baseMessageOptions } as MessageOptions; + message.uninterpretedOption = []; + if ( + object.messageSetWireFormat !== undefined && + object.messageSetWireFormat !== null + ) { + message.messageSetWireFormat = Boolean(object.messageSetWireFormat); + } else { + message.messageSetWireFormat = false; + } + if ( + object.noStandardDescriptorAccessor !== undefined && + object.noStandardDescriptorAccessor !== null + ) { + message.noStandardDescriptorAccessor = Boolean( + object.noStandardDescriptorAccessor + ); + } else { + message.noStandardDescriptorAccessor = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if (object.mapEntry !== undefined && object.mapEntry !== null) { + message.mapEntry = Boolean(object.mapEntry); + } else { + message.mapEntry = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: MessageOptions): unknown { + const obj: any = {}; + message.messageSetWireFormat !== undefined && + (obj.messageSetWireFormat = message.messageSetWireFormat); + message.noStandardDescriptorAccessor !== undefined && + (obj.noStandardDescriptorAccessor = message.noStandardDescriptorAccessor); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.mapEntry !== undefined && (obj.mapEntry = message.mapEntry); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): MessageOptions { + const message = { ...baseMessageOptions } as MessageOptions; + message.uninterpretedOption = []; + if ( + object.messageSetWireFormat !== undefined && + object.messageSetWireFormat !== null + ) { + message.messageSetWireFormat = object.messageSetWireFormat; + } else { + message.messageSetWireFormat = false; + } + if ( + object.noStandardDescriptorAccessor !== undefined && + object.noStandardDescriptorAccessor !== null + ) { + message.noStandardDescriptorAccessor = + object.noStandardDescriptorAccessor; + } else { + message.noStandardDescriptorAccessor = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if (object.mapEntry !== undefined && object.mapEntry !== null) { + message.mapEntry = object.mapEntry; + } else { + message.mapEntry = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseFieldOptions: object = { + ctype: 0, + packed: false, + jstype: 0, + lazy: false, + deprecated: false, + weak: false, +}; + +export const FieldOptions = { + encode(message: FieldOptions, writer: Writer = Writer.create()): Writer { + if (message.ctype !== 0) { + writer.uint32(8).int32(message.ctype); + } + if (message.packed === true) { + writer.uint32(16).bool(message.packed); + } + if (message.jstype !== 0) { + writer.uint32(48).int32(message.jstype); + } + if (message.lazy === true) { + writer.uint32(40).bool(message.lazy); + } + if (message.deprecated === true) { + writer.uint32(24).bool(message.deprecated); + } + if (message.weak === true) { + writer.uint32(80).bool(message.weak); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FieldOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFieldOptions } as FieldOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.ctype = reader.int32() as any; + break; + case 2: + message.packed = reader.bool(); + break; + case 6: + message.jstype = reader.int32() as any; + break; + case 5: + message.lazy = reader.bool(); + break; + case 3: + message.deprecated = reader.bool(); + break; + case 10: + message.weak = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FieldOptions { + const message = { ...baseFieldOptions } as FieldOptions; + message.uninterpretedOption = []; + if (object.ctype !== undefined && object.ctype !== null) { + message.ctype = fieldOptions_CTypeFromJSON(object.ctype); + } else { + message.ctype = 0; + } + if (object.packed !== undefined && object.packed !== null) { + message.packed = Boolean(object.packed); + } else { + message.packed = false; + } + if (object.jstype !== undefined && object.jstype !== null) { + message.jstype = fieldOptions_JSTypeFromJSON(object.jstype); + } else { + message.jstype = 0; + } + if (object.lazy !== undefined && object.lazy !== null) { + message.lazy = Boolean(object.lazy); + } else { + message.lazy = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if (object.weak !== undefined && object.weak !== null) { + message.weak = Boolean(object.weak); + } else { + message.weak = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: FieldOptions): unknown { + const obj: any = {}; + message.ctype !== undefined && + (obj.ctype = fieldOptions_CTypeToJSON(message.ctype)); + message.packed !== undefined && (obj.packed = message.packed); + message.jstype !== undefined && + (obj.jstype = fieldOptions_JSTypeToJSON(message.jstype)); + message.lazy !== undefined && (obj.lazy = message.lazy); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.weak !== undefined && (obj.weak = message.weak); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): FieldOptions { + const message = { ...baseFieldOptions } as FieldOptions; + message.uninterpretedOption = []; + if (object.ctype !== undefined && object.ctype !== null) { + message.ctype = object.ctype; + } else { + message.ctype = 0; + } + if (object.packed !== undefined && object.packed !== null) { + message.packed = object.packed; + } else { + message.packed = false; + } + if (object.jstype !== undefined && object.jstype !== null) { + message.jstype = object.jstype; + } else { + message.jstype = 0; + } + if (object.lazy !== undefined && object.lazy !== null) { + message.lazy = object.lazy; + } else { + message.lazy = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if (object.weak !== undefined && object.weak !== null) { + message.weak = object.weak; + } else { + message.weak = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseOneofOptions: object = {}; + +export const OneofOptions = { + encode(message: OneofOptions, writer: Writer = Writer.create()): Writer { + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): OneofOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseOneofOptions } as OneofOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): OneofOptions { + const message = { ...baseOneofOptions } as OneofOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: OneofOptions): unknown { + const obj: any = {}; + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): OneofOptions { + const message = { ...baseOneofOptions } as OneofOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseEnumOptions: object = { allowAlias: false, deprecated: false }; + +export const EnumOptions = { + encode(message: EnumOptions, writer: Writer = Writer.create()): Writer { + if (message.allowAlias === true) { + writer.uint32(16).bool(message.allowAlias); + } + if (message.deprecated === true) { + writer.uint32(24).bool(message.deprecated); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): EnumOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseEnumOptions } as EnumOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + message.allowAlias = reader.bool(); + break; + case 3: + message.deprecated = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumOptions { + const message = { ...baseEnumOptions } as EnumOptions; + message.uninterpretedOption = []; + if (object.allowAlias !== undefined && object.allowAlias !== null) { + message.allowAlias = Boolean(object.allowAlias); + } else { + message.allowAlias = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: EnumOptions): unknown { + const obj: any = {}; + message.allowAlias !== undefined && (obj.allowAlias = message.allowAlias); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): EnumOptions { + const message = { ...baseEnumOptions } as EnumOptions; + message.uninterpretedOption = []; + if (object.allowAlias !== undefined && object.allowAlias !== null) { + message.allowAlias = object.allowAlias; + } else { + message.allowAlias = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseEnumValueOptions: object = { deprecated: false }; + +export const EnumValueOptions = { + encode(message: EnumValueOptions, writer: Writer = Writer.create()): Writer { + if (message.deprecated === true) { + writer.uint32(8).bool(message.deprecated); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): EnumValueOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseEnumValueOptions } as EnumValueOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.deprecated = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumValueOptions { + const message = { ...baseEnumValueOptions } as EnumValueOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: EnumValueOptions): unknown { + const obj: any = {}; + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): EnumValueOptions { + const message = { ...baseEnumValueOptions } as EnumValueOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseServiceOptions: object = { deprecated: false }; + +export const ServiceOptions = { + encode(message: ServiceOptions, writer: Writer = Writer.create()): Writer { + if (message.deprecated === true) { + writer.uint32(264).bool(message.deprecated); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ServiceOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseServiceOptions } as ServiceOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 33: + message.deprecated = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ServiceOptions { + const message = { ...baseServiceOptions } as ServiceOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: ServiceOptions): unknown { + const obj: any = {}; + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): ServiceOptions { + const message = { ...baseServiceOptions } as ServiceOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseMethodOptions: object = { deprecated: false, idempotencyLevel: 0 }; + +export const MethodOptions = { + encode(message: MethodOptions, writer: Writer = Writer.create()): Writer { + if (message.deprecated === true) { + writer.uint32(264).bool(message.deprecated); + } + if (message.idempotencyLevel !== 0) { + writer.uint32(272).int32(message.idempotencyLevel); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MethodOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMethodOptions } as MethodOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 33: + message.deprecated = reader.bool(); + break; + case 34: + message.idempotencyLevel = reader.int32() as any; + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MethodOptions { + const message = { ...baseMethodOptions } as MethodOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.idempotencyLevel !== undefined && + object.idempotencyLevel !== null + ) { + message.idempotencyLevel = methodOptions_IdempotencyLevelFromJSON( + object.idempotencyLevel + ); + } else { + message.idempotencyLevel = 0; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: MethodOptions): unknown { + const obj: any = {}; + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.idempotencyLevel !== undefined && + (obj.idempotencyLevel = methodOptions_IdempotencyLevelToJSON( + message.idempotencyLevel + )); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): MethodOptions { + const message = { ...baseMethodOptions } as MethodOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.idempotencyLevel !== undefined && + object.idempotencyLevel !== null + ) { + message.idempotencyLevel = object.idempotencyLevel; + } else { + message.idempotencyLevel = 0; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseUninterpretedOption: object = { + identifierValue: "", + positiveIntValue: 0, + negativeIntValue: 0, + doubleValue: 0, + aggregateValue: "", +}; + +export const UninterpretedOption = { + encode( + message: UninterpretedOption, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.name) { + UninterpretedOption_NamePart.encode( + v!, + writer.uint32(18).fork() + ).ldelim(); + } + if (message.identifierValue !== "") { + writer.uint32(26).string(message.identifierValue); + } + if (message.positiveIntValue !== 0) { + writer.uint32(32).uint64(message.positiveIntValue); + } + if (message.negativeIntValue !== 0) { + writer.uint32(40).int64(message.negativeIntValue); + } + if (message.doubleValue !== 0) { + writer.uint32(49).double(message.doubleValue); + } + if (message.stringValue.length !== 0) { + writer.uint32(58).bytes(message.stringValue); + } + if (message.aggregateValue !== "") { + writer.uint32(66).string(message.aggregateValue); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): UninterpretedOption { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseUninterpretedOption } as UninterpretedOption; + message.name = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + message.name.push( + UninterpretedOption_NamePart.decode(reader, reader.uint32()) + ); + break; + case 3: + message.identifierValue = reader.string(); + break; + case 4: + message.positiveIntValue = longToNumber(reader.uint64() as Long); + break; + case 5: + message.negativeIntValue = longToNumber(reader.int64() as Long); + break; + case 6: + message.doubleValue = reader.double(); + break; + case 7: + message.stringValue = reader.bytes(); + break; + case 8: + message.aggregateValue = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): UninterpretedOption { + const message = { ...baseUninterpretedOption } as UninterpretedOption; + message.name = []; + if (object.name !== undefined && object.name !== null) { + for (const e of object.name) { + message.name.push(UninterpretedOption_NamePart.fromJSON(e)); + } + } + if ( + object.identifierValue !== undefined && + object.identifierValue !== null + ) { + message.identifierValue = String(object.identifierValue); + } else { + message.identifierValue = ""; + } + if ( + object.positiveIntValue !== undefined && + object.positiveIntValue !== null + ) { + message.positiveIntValue = Number(object.positiveIntValue); + } else { + message.positiveIntValue = 0; + } + if ( + object.negativeIntValue !== undefined && + object.negativeIntValue !== null + ) { + message.negativeIntValue = Number(object.negativeIntValue); + } else { + message.negativeIntValue = 0; + } + if (object.doubleValue !== undefined && object.doubleValue !== null) { + message.doubleValue = Number(object.doubleValue); + } else { + message.doubleValue = 0; + } + if (object.stringValue !== undefined && object.stringValue !== null) { + message.stringValue = bytesFromBase64(object.stringValue); + } + if (object.aggregateValue !== undefined && object.aggregateValue !== null) { + message.aggregateValue = String(object.aggregateValue); + } else { + message.aggregateValue = ""; + } + return message; + }, + + toJSON(message: UninterpretedOption): unknown { + const obj: any = {}; + if (message.name) { + obj.name = message.name.map((e) => + e ? UninterpretedOption_NamePart.toJSON(e) : undefined + ); + } else { + obj.name = []; + } + message.identifierValue !== undefined && + (obj.identifierValue = message.identifierValue); + message.positiveIntValue !== undefined && + (obj.positiveIntValue = message.positiveIntValue); + message.negativeIntValue !== undefined && + (obj.negativeIntValue = message.negativeIntValue); + message.doubleValue !== undefined && + (obj.doubleValue = message.doubleValue); + message.stringValue !== undefined && + (obj.stringValue = base64FromBytes( + message.stringValue !== undefined + ? message.stringValue + : new Uint8Array() + )); + message.aggregateValue !== undefined && + (obj.aggregateValue = message.aggregateValue); + return obj; + }, + + fromPartial(object: DeepPartial): UninterpretedOption { + const message = { ...baseUninterpretedOption } as UninterpretedOption; + message.name = []; + if (object.name !== undefined && object.name !== null) { + for (const e of object.name) { + message.name.push(UninterpretedOption_NamePart.fromPartial(e)); + } + } + if ( + object.identifierValue !== undefined && + object.identifierValue !== null + ) { + message.identifierValue = object.identifierValue; + } else { + message.identifierValue = ""; + } + if ( + object.positiveIntValue !== undefined && + object.positiveIntValue !== null + ) { + message.positiveIntValue = object.positiveIntValue; + } else { + message.positiveIntValue = 0; + } + if ( + object.negativeIntValue !== undefined && + object.negativeIntValue !== null + ) { + message.negativeIntValue = object.negativeIntValue; + } else { + message.negativeIntValue = 0; + } + if (object.doubleValue !== undefined && object.doubleValue !== null) { + message.doubleValue = object.doubleValue; + } else { + message.doubleValue = 0; + } + if (object.stringValue !== undefined && object.stringValue !== null) { + message.stringValue = object.stringValue; + } else { + message.stringValue = new Uint8Array(); + } + if (object.aggregateValue !== undefined && object.aggregateValue !== null) { + message.aggregateValue = object.aggregateValue; + } else { + message.aggregateValue = ""; + } + return message; + }, +}; + +const baseUninterpretedOption_NamePart: object = { + namePart: "", + isExtension: false, +}; + +export const UninterpretedOption_NamePart = { + encode( + message: UninterpretedOption_NamePart, + writer: Writer = Writer.create() + ): Writer { + if (message.namePart !== "") { + writer.uint32(10).string(message.namePart); + } + if (message.isExtension === true) { + writer.uint32(16).bool(message.isExtension); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): UninterpretedOption_NamePart { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseUninterpretedOption_NamePart, + } as UninterpretedOption_NamePart; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.namePart = reader.string(); + break; + case 2: + message.isExtension = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): UninterpretedOption_NamePart { + const message = { + ...baseUninterpretedOption_NamePart, + } as UninterpretedOption_NamePart; + if (object.namePart !== undefined && object.namePart !== null) { + message.namePart = String(object.namePart); + } else { + message.namePart = ""; + } + if (object.isExtension !== undefined && object.isExtension !== null) { + message.isExtension = Boolean(object.isExtension); + } else { + message.isExtension = false; + } + return message; + }, + + toJSON(message: UninterpretedOption_NamePart): unknown { + const obj: any = {}; + message.namePart !== undefined && (obj.namePart = message.namePart); + message.isExtension !== undefined && + (obj.isExtension = message.isExtension); + return obj; + }, + + fromPartial( + object: DeepPartial + ): UninterpretedOption_NamePart { + const message = { + ...baseUninterpretedOption_NamePart, + } as UninterpretedOption_NamePart; + if (object.namePart !== undefined && object.namePart !== null) { + message.namePart = object.namePart; + } else { + message.namePart = ""; + } + if (object.isExtension !== undefined && object.isExtension !== null) { + message.isExtension = object.isExtension; + } else { + message.isExtension = false; + } + return message; + }, +}; + +const baseSourceCodeInfo: object = {}; + +export const SourceCodeInfo = { + encode(message: SourceCodeInfo, writer: Writer = Writer.create()): Writer { + for (const v of message.location) { + SourceCodeInfo_Location.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): SourceCodeInfo { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseSourceCodeInfo } as SourceCodeInfo; + message.location = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.location.push( + SourceCodeInfo_Location.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): SourceCodeInfo { + const message = { ...baseSourceCodeInfo } as SourceCodeInfo; + message.location = []; + if (object.location !== undefined && object.location !== null) { + for (const e of object.location) { + message.location.push(SourceCodeInfo_Location.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: SourceCodeInfo): unknown { + const obj: any = {}; + if (message.location) { + obj.location = message.location.map((e) => + e ? SourceCodeInfo_Location.toJSON(e) : undefined + ); + } else { + obj.location = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): SourceCodeInfo { + const message = { ...baseSourceCodeInfo } as SourceCodeInfo; + message.location = []; + if (object.location !== undefined && object.location !== null) { + for (const e of object.location) { + message.location.push(SourceCodeInfo_Location.fromPartial(e)); + } + } + return message; + }, +}; + +const baseSourceCodeInfo_Location: object = { + path: 0, + span: 0, + leadingComments: "", + trailingComments: "", + leadingDetachedComments: "", +}; + +export const SourceCodeInfo_Location = { + encode( + message: SourceCodeInfo_Location, + writer: Writer = Writer.create() + ): Writer { + writer.uint32(10).fork(); + for (const v of message.path) { + writer.int32(v); + } + writer.ldelim(); + writer.uint32(18).fork(); + for (const v of message.span) { + writer.int32(v); + } + writer.ldelim(); + if (message.leadingComments !== "") { + writer.uint32(26).string(message.leadingComments); + } + if (message.trailingComments !== "") { + writer.uint32(34).string(message.trailingComments); + } + for (const v of message.leadingDetachedComments) { + writer.uint32(50).string(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): SourceCodeInfo_Location { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseSourceCodeInfo_Location, + } as SourceCodeInfo_Location; + message.path = []; + message.span = []; + message.leadingDetachedComments = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.path.push(reader.int32()); + } + } else { + message.path.push(reader.int32()); + } + break; + case 2: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.span.push(reader.int32()); + } + } else { + message.span.push(reader.int32()); + } + break; + case 3: + message.leadingComments = reader.string(); + break; + case 4: + message.trailingComments = reader.string(); + break; + case 6: + message.leadingDetachedComments.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): SourceCodeInfo_Location { + const message = { + ...baseSourceCodeInfo_Location, + } as SourceCodeInfo_Location; + message.path = []; + message.span = []; + message.leadingDetachedComments = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(Number(e)); + } + } + if (object.span !== undefined && object.span !== null) { + for (const e of object.span) { + message.span.push(Number(e)); + } + } + if ( + object.leadingComments !== undefined && + object.leadingComments !== null + ) { + message.leadingComments = String(object.leadingComments); + } else { + message.leadingComments = ""; + } + if ( + object.trailingComments !== undefined && + object.trailingComments !== null + ) { + message.trailingComments = String(object.trailingComments); + } else { + message.trailingComments = ""; + } + if ( + object.leadingDetachedComments !== undefined && + object.leadingDetachedComments !== null + ) { + for (const e of object.leadingDetachedComments) { + message.leadingDetachedComments.push(String(e)); + } + } + return message; + }, + + toJSON(message: SourceCodeInfo_Location): unknown { + const obj: any = {}; + if (message.path) { + obj.path = message.path.map((e) => e); + } else { + obj.path = []; + } + if (message.span) { + obj.span = message.span.map((e) => e); + } else { + obj.span = []; + } + message.leadingComments !== undefined && + (obj.leadingComments = message.leadingComments); + message.trailingComments !== undefined && + (obj.trailingComments = message.trailingComments); + if (message.leadingDetachedComments) { + obj.leadingDetachedComments = message.leadingDetachedComments.map( + (e) => e + ); + } else { + obj.leadingDetachedComments = []; + } + return obj; + }, + + fromPartial( + object: DeepPartial + ): SourceCodeInfo_Location { + const message = { + ...baseSourceCodeInfo_Location, + } as SourceCodeInfo_Location; + message.path = []; + message.span = []; + message.leadingDetachedComments = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(e); + } + } + if (object.span !== undefined && object.span !== null) { + for (const e of object.span) { + message.span.push(e); + } + } + if ( + object.leadingComments !== undefined && + object.leadingComments !== null + ) { + message.leadingComments = object.leadingComments; + } else { + message.leadingComments = ""; + } + if ( + object.trailingComments !== undefined && + object.trailingComments !== null + ) { + message.trailingComments = object.trailingComments; + } else { + message.trailingComments = ""; + } + if ( + object.leadingDetachedComments !== undefined && + object.leadingDetachedComments !== null + ) { + for (const e of object.leadingDetachedComments) { + message.leadingDetachedComments.push(e); + } + } + return message; + }, +}; + +const baseGeneratedCodeInfo: object = {}; + +export const GeneratedCodeInfo = { + encode(message: GeneratedCodeInfo, writer: Writer = Writer.create()): Writer { + for (const v of message.annotation) { + GeneratedCodeInfo_Annotation.encode( + v!, + writer.uint32(10).fork() + ).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): GeneratedCodeInfo { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseGeneratedCodeInfo } as GeneratedCodeInfo; + message.annotation = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.annotation.push( + GeneratedCodeInfo_Annotation.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GeneratedCodeInfo { + const message = { ...baseGeneratedCodeInfo } as GeneratedCodeInfo; + message.annotation = []; + if (object.annotation !== undefined && object.annotation !== null) { + for (const e of object.annotation) { + message.annotation.push(GeneratedCodeInfo_Annotation.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: GeneratedCodeInfo): unknown { + const obj: any = {}; + if (message.annotation) { + obj.annotation = message.annotation.map((e) => + e ? GeneratedCodeInfo_Annotation.toJSON(e) : undefined + ); + } else { + obj.annotation = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): GeneratedCodeInfo { + const message = { ...baseGeneratedCodeInfo } as GeneratedCodeInfo; + message.annotation = []; + if (object.annotation !== undefined && object.annotation !== null) { + for (const e of object.annotation) { + message.annotation.push(GeneratedCodeInfo_Annotation.fromPartial(e)); + } + } + return message; + }, +}; + +const baseGeneratedCodeInfo_Annotation: object = { + path: 0, + sourceFile: "", + begin: 0, + end: 0, +}; + +export const GeneratedCodeInfo_Annotation = { + encode( + message: GeneratedCodeInfo_Annotation, + writer: Writer = Writer.create() + ): Writer { + writer.uint32(10).fork(); + for (const v of message.path) { + writer.int32(v); + } + writer.ldelim(); + if (message.sourceFile !== "") { + writer.uint32(18).string(message.sourceFile); + } + if (message.begin !== 0) { + writer.uint32(24).int32(message.begin); + } + if (message.end !== 0) { + writer.uint32(32).int32(message.end); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): GeneratedCodeInfo_Annotation { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseGeneratedCodeInfo_Annotation, + } as GeneratedCodeInfo_Annotation; + message.path = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.path.push(reader.int32()); + } + } else { + message.path.push(reader.int32()); + } + break; + case 2: + message.sourceFile = reader.string(); + break; + case 3: + message.begin = reader.int32(); + break; + case 4: + message.end = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GeneratedCodeInfo_Annotation { + const message = { + ...baseGeneratedCodeInfo_Annotation, + } as GeneratedCodeInfo_Annotation; + message.path = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(Number(e)); + } + } + if (object.sourceFile !== undefined && object.sourceFile !== null) { + message.sourceFile = String(object.sourceFile); + } else { + message.sourceFile = ""; + } + if (object.begin !== undefined && object.begin !== null) { + message.begin = Number(object.begin); + } else { + message.begin = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + return message; + }, + + toJSON(message: GeneratedCodeInfo_Annotation): unknown { + const obj: any = {}; + if (message.path) { + obj.path = message.path.map((e) => e); + } else { + obj.path = []; + } + message.sourceFile !== undefined && (obj.sourceFile = message.sourceFile); + message.begin !== undefined && (obj.begin = message.begin); + message.end !== undefined && (obj.end = message.end); + return obj; + }, + + fromPartial( + object: DeepPartial + ): GeneratedCodeInfo_Annotation { + const message = { + ...baseGeneratedCodeInfo_Annotation, + } as GeneratedCodeInfo_Annotation; + message.path = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(e); + } + } + if (object.sourceFile !== undefined && object.sourceFile !== null) { + message.sourceFile = object.sourceFile; + } else { + message.sourceFile = ""; + } + if (object.begin !== undefined && object.begin !== null) { + message.begin = object.begin; + } else { + message.begin = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/bze.tradebin.v1/types/tradebin/events.ts b/ts-client/bze.tradebin.v1/types/tradebin/events.ts new file mode 100644 index 00000000..dce90c2a --- /dev/null +++ b/ts-client/bze.tradebin.v1/types/tradebin/events.ts @@ -0,0 +1,807 @@ +/* eslint-disable */ +import { Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "bze.tradebin.v1"; + +export interface OrderCreateMessageEvent { + creator: string; + marketId: string; + orderType: string; + amount: string; + price: string; +} + +export interface OrderCancelMessageEvent { + creator: string; + marketId: string; + orderId: string; + orderType: string; +} + +export interface MarketCreatedEvent { + creator: string; + base: string; + quote: string; +} + +export interface OrderExecutedEvent { + id: string; + marketId: string; + orderType: string; + amount: string; + price: string; +} + +export interface OrderCanceledEvent { + id: string; + marketId: string; + orderType: string; + amount: string; + price: string; +} + +export interface OrderSavedEvent { + id: string; + marketId: string; + orderType: string; + amount: string; + price: string; +} + +const baseOrderCreateMessageEvent: object = { + creator: "", + marketId: "", + orderType: "", + amount: "", + price: "", +}; + +export const OrderCreateMessageEvent = { + encode( + message: OrderCreateMessageEvent, + writer: Writer = Writer.create() + ): Writer { + if (message.creator !== "") { + writer.uint32(10).string(message.creator); + } + if (message.marketId !== "") { + writer.uint32(18).string(message.marketId); + } + if (message.orderType !== "") { + writer.uint32(26).string(message.orderType); + } + if (message.amount !== "") { + writer.uint32(34).string(message.amount); + } + if (message.price !== "") { + writer.uint32(42).string(message.price); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): OrderCreateMessageEvent { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseOrderCreateMessageEvent, + } as OrderCreateMessageEvent; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.creator = reader.string(); + break; + case 2: + message.marketId = reader.string(); + break; + case 3: + message.orderType = reader.string(); + break; + case 4: + message.amount = reader.string(); + break; + case 5: + message.price = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): OrderCreateMessageEvent { + const message = { + ...baseOrderCreateMessageEvent, + } as OrderCreateMessageEvent; + if (object.creator !== undefined && object.creator !== null) { + message.creator = String(object.creator); + } else { + message.creator = ""; + } + if (object.marketId !== undefined && object.marketId !== null) { + message.marketId = String(object.marketId); + } else { + message.marketId = ""; + } + if (object.orderType !== undefined && object.orderType !== null) { + message.orderType = String(object.orderType); + } else { + message.orderType = ""; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = String(object.amount); + } else { + message.amount = ""; + } + if (object.price !== undefined && object.price !== null) { + message.price = String(object.price); + } else { + message.price = ""; + } + return message; + }, + + toJSON(message: OrderCreateMessageEvent): unknown { + const obj: any = {}; + message.creator !== undefined && (obj.creator = message.creator); + message.marketId !== undefined && (obj.marketId = message.marketId); + message.orderType !== undefined && (obj.orderType = message.orderType); + message.amount !== undefined && (obj.amount = message.amount); + message.price !== undefined && (obj.price = message.price); + return obj; + }, + + fromPartial( + object: DeepPartial + ): OrderCreateMessageEvent { + const message = { + ...baseOrderCreateMessageEvent, + } as OrderCreateMessageEvent; + if (object.creator !== undefined && object.creator !== null) { + message.creator = object.creator; + } else { + message.creator = ""; + } + if (object.marketId !== undefined && object.marketId !== null) { + message.marketId = object.marketId; + } else { + message.marketId = ""; + } + if (object.orderType !== undefined && object.orderType !== null) { + message.orderType = object.orderType; + } else { + message.orderType = ""; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = object.amount; + } else { + message.amount = ""; + } + if (object.price !== undefined && object.price !== null) { + message.price = object.price; + } else { + message.price = ""; + } + return message; + }, +}; + +const baseOrderCancelMessageEvent: object = { + creator: "", + marketId: "", + orderId: "", + orderType: "", +}; + +export const OrderCancelMessageEvent = { + encode( + message: OrderCancelMessageEvent, + writer: Writer = Writer.create() + ): Writer { + if (message.creator !== "") { + writer.uint32(10).string(message.creator); + } + if (message.marketId !== "") { + writer.uint32(18).string(message.marketId); + } + if (message.orderId !== "") { + writer.uint32(26).string(message.orderId); + } + if (message.orderType !== "") { + writer.uint32(34).string(message.orderType); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): OrderCancelMessageEvent { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseOrderCancelMessageEvent, + } as OrderCancelMessageEvent; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.creator = reader.string(); + break; + case 2: + message.marketId = reader.string(); + break; + case 3: + message.orderId = reader.string(); + break; + case 4: + message.orderType = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): OrderCancelMessageEvent { + const message = { + ...baseOrderCancelMessageEvent, + } as OrderCancelMessageEvent; + if (object.creator !== undefined && object.creator !== null) { + message.creator = String(object.creator); + } else { + message.creator = ""; + } + if (object.marketId !== undefined && object.marketId !== null) { + message.marketId = String(object.marketId); + } else { + message.marketId = ""; + } + if (object.orderId !== undefined && object.orderId !== null) { + message.orderId = String(object.orderId); + } else { + message.orderId = ""; + } + if (object.orderType !== undefined && object.orderType !== null) { + message.orderType = String(object.orderType); + } else { + message.orderType = ""; + } + return message; + }, + + toJSON(message: OrderCancelMessageEvent): unknown { + const obj: any = {}; + message.creator !== undefined && (obj.creator = message.creator); + message.marketId !== undefined && (obj.marketId = message.marketId); + message.orderId !== undefined && (obj.orderId = message.orderId); + message.orderType !== undefined && (obj.orderType = message.orderType); + return obj; + }, + + fromPartial( + object: DeepPartial + ): OrderCancelMessageEvent { + const message = { + ...baseOrderCancelMessageEvent, + } as OrderCancelMessageEvent; + if (object.creator !== undefined && object.creator !== null) { + message.creator = object.creator; + } else { + message.creator = ""; + } + if (object.marketId !== undefined && object.marketId !== null) { + message.marketId = object.marketId; + } else { + message.marketId = ""; + } + if (object.orderId !== undefined && object.orderId !== null) { + message.orderId = object.orderId; + } else { + message.orderId = ""; + } + if (object.orderType !== undefined && object.orderType !== null) { + message.orderType = object.orderType; + } else { + message.orderType = ""; + } + return message; + }, +}; + +const baseMarketCreatedEvent: object = { creator: "", base: "", quote: "" }; + +export const MarketCreatedEvent = { + encode( + message: MarketCreatedEvent, + writer: Writer = Writer.create() + ): Writer { + if (message.creator !== "") { + writer.uint32(10).string(message.creator); + } + if (message.base !== "") { + writer.uint32(18).string(message.base); + } + if (message.quote !== "") { + writer.uint32(26).string(message.quote); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MarketCreatedEvent { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMarketCreatedEvent } as MarketCreatedEvent; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.creator = reader.string(); + break; + case 2: + message.base = reader.string(); + break; + case 3: + message.quote = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MarketCreatedEvent { + const message = { ...baseMarketCreatedEvent } as MarketCreatedEvent; + if (object.creator !== undefined && object.creator !== null) { + message.creator = String(object.creator); + } else { + message.creator = ""; + } + if (object.base !== undefined && object.base !== null) { + message.base = String(object.base); + } else { + message.base = ""; + } + if (object.quote !== undefined && object.quote !== null) { + message.quote = String(object.quote); + } else { + message.quote = ""; + } + return message; + }, + + toJSON(message: MarketCreatedEvent): unknown { + const obj: any = {}; + message.creator !== undefined && (obj.creator = message.creator); + message.base !== undefined && (obj.base = message.base); + message.quote !== undefined && (obj.quote = message.quote); + return obj; + }, + + fromPartial(object: DeepPartial): MarketCreatedEvent { + const message = { ...baseMarketCreatedEvent } as MarketCreatedEvent; + if (object.creator !== undefined && object.creator !== null) { + message.creator = object.creator; + } else { + message.creator = ""; + } + if (object.base !== undefined && object.base !== null) { + message.base = object.base; + } else { + message.base = ""; + } + if (object.quote !== undefined && object.quote !== null) { + message.quote = object.quote; + } else { + message.quote = ""; + } + return message; + }, +}; + +const baseOrderExecutedEvent: object = { + id: "", + marketId: "", + orderType: "", + amount: "", + price: "", +}; + +export const OrderExecutedEvent = { + encode( + message: OrderExecutedEvent, + writer: Writer = Writer.create() + ): Writer { + if (message.id !== "") { + writer.uint32(10).string(message.id); + } + if (message.marketId !== "") { + writer.uint32(18).string(message.marketId); + } + if (message.orderType !== "") { + writer.uint32(26).string(message.orderType); + } + if (message.amount !== "") { + writer.uint32(34).string(message.amount); + } + if (message.price !== "") { + writer.uint32(42).string(message.price); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): OrderExecutedEvent { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseOrderExecutedEvent } as OrderExecutedEvent; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.id = reader.string(); + break; + case 2: + message.marketId = reader.string(); + break; + case 3: + message.orderType = reader.string(); + break; + case 4: + message.amount = reader.string(); + break; + case 5: + message.price = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): OrderExecutedEvent { + const message = { ...baseOrderExecutedEvent } as OrderExecutedEvent; + if (object.id !== undefined && object.id !== null) { + message.id = String(object.id); + } else { + message.id = ""; + } + if (object.marketId !== undefined && object.marketId !== null) { + message.marketId = String(object.marketId); + } else { + message.marketId = ""; + } + if (object.orderType !== undefined && object.orderType !== null) { + message.orderType = String(object.orderType); + } else { + message.orderType = ""; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = String(object.amount); + } else { + message.amount = ""; + } + if (object.price !== undefined && object.price !== null) { + message.price = String(object.price); + } else { + message.price = ""; + } + return message; + }, + + toJSON(message: OrderExecutedEvent): unknown { + const obj: any = {}; + message.id !== undefined && (obj.id = message.id); + message.marketId !== undefined && (obj.marketId = message.marketId); + message.orderType !== undefined && (obj.orderType = message.orderType); + message.amount !== undefined && (obj.amount = message.amount); + message.price !== undefined && (obj.price = message.price); + return obj; + }, + + fromPartial(object: DeepPartial): OrderExecutedEvent { + const message = { ...baseOrderExecutedEvent } as OrderExecutedEvent; + if (object.id !== undefined && object.id !== null) { + message.id = object.id; + } else { + message.id = ""; + } + if (object.marketId !== undefined && object.marketId !== null) { + message.marketId = object.marketId; + } else { + message.marketId = ""; + } + if (object.orderType !== undefined && object.orderType !== null) { + message.orderType = object.orderType; + } else { + message.orderType = ""; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = object.amount; + } else { + message.amount = ""; + } + if (object.price !== undefined && object.price !== null) { + message.price = object.price; + } else { + message.price = ""; + } + return message; + }, +}; + +const baseOrderCanceledEvent: object = { + id: "", + marketId: "", + orderType: "", + amount: "", + price: "", +}; + +export const OrderCanceledEvent = { + encode( + message: OrderCanceledEvent, + writer: Writer = Writer.create() + ): Writer { + if (message.id !== "") { + writer.uint32(10).string(message.id); + } + if (message.marketId !== "") { + writer.uint32(18).string(message.marketId); + } + if (message.orderType !== "") { + writer.uint32(26).string(message.orderType); + } + if (message.amount !== "") { + writer.uint32(34).string(message.amount); + } + if (message.price !== "") { + writer.uint32(42).string(message.price); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): OrderCanceledEvent { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseOrderCanceledEvent } as OrderCanceledEvent; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.id = reader.string(); + break; + case 2: + message.marketId = reader.string(); + break; + case 3: + message.orderType = reader.string(); + break; + case 4: + message.amount = reader.string(); + break; + case 5: + message.price = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): OrderCanceledEvent { + const message = { ...baseOrderCanceledEvent } as OrderCanceledEvent; + if (object.id !== undefined && object.id !== null) { + message.id = String(object.id); + } else { + message.id = ""; + } + if (object.marketId !== undefined && object.marketId !== null) { + message.marketId = String(object.marketId); + } else { + message.marketId = ""; + } + if (object.orderType !== undefined && object.orderType !== null) { + message.orderType = String(object.orderType); + } else { + message.orderType = ""; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = String(object.amount); + } else { + message.amount = ""; + } + if (object.price !== undefined && object.price !== null) { + message.price = String(object.price); + } else { + message.price = ""; + } + return message; + }, + + toJSON(message: OrderCanceledEvent): unknown { + const obj: any = {}; + message.id !== undefined && (obj.id = message.id); + message.marketId !== undefined && (obj.marketId = message.marketId); + message.orderType !== undefined && (obj.orderType = message.orderType); + message.amount !== undefined && (obj.amount = message.amount); + message.price !== undefined && (obj.price = message.price); + return obj; + }, + + fromPartial(object: DeepPartial): OrderCanceledEvent { + const message = { ...baseOrderCanceledEvent } as OrderCanceledEvent; + if (object.id !== undefined && object.id !== null) { + message.id = object.id; + } else { + message.id = ""; + } + if (object.marketId !== undefined && object.marketId !== null) { + message.marketId = object.marketId; + } else { + message.marketId = ""; + } + if (object.orderType !== undefined && object.orderType !== null) { + message.orderType = object.orderType; + } else { + message.orderType = ""; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = object.amount; + } else { + message.amount = ""; + } + if (object.price !== undefined && object.price !== null) { + message.price = object.price; + } else { + message.price = ""; + } + return message; + }, +}; + +const baseOrderSavedEvent: object = { + id: "", + marketId: "", + orderType: "", + amount: "", + price: "", +}; + +export const OrderSavedEvent = { + encode(message: OrderSavedEvent, writer: Writer = Writer.create()): Writer { + if (message.id !== "") { + writer.uint32(10).string(message.id); + } + if (message.marketId !== "") { + writer.uint32(18).string(message.marketId); + } + if (message.orderType !== "") { + writer.uint32(26).string(message.orderType); + } + if (message.amount !== "") { + writer.uint32(34).string(message.amount); + } + if (message.price !== "") { + writer.uint32(42).string(message.price); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): OrderSavedEvent { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseOrderSavedEvent } as OrderSavedEvent; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.id = reader.string(); + break; + case 2: + message.marketId = reader.string(); + break; + case 3: + message.orderType = reader.string(); + break; + case 4: + message.amount = reader.string(); + break; + case 5: + message.price = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): OrderSavedEvent { + const message = { ...baseOrderSavedEvent } as OrderSavedEvent; + if (object.id !== undefined && object.id !== null) { + message.id = String(object.id); + } else { + message.id = ""; + } + if (object.marketId !== undefined && object.marketId !== null) { + message.marketId = String(object.marketId); + } else { + message.marketId = ""; + } + if (object.orderType !== undefined && object.orderType !== null) { + message.orderType = String(object.orderType); + } else { + message.orderType = ""; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = String(object.amount); + } else { + message.amount = ""; + } + if (object.price !== undefined && object.price !== null) { + message.price = String(object.price); + } else { + message.price = ""; + } + return message; + }, + + toJSON(message: OrderSavedEvent): unknown { + const obj: any = {}; + message.id !== undefined && (obj.id = message.id); + message.marketId !== undefined && (obj.marketId = message.marketId); + message.orderType !== undefined && (obj.orderType = message.orderType); + message.amount !== undefined && (obj.amount = message.amount); + message.price !== undefined && (obj.price = message.price); + return obj; + }, + + fromPartial(object: DeepPartial): OrderSavedEvent { + const message = { ...baseOrderSavedEvent } as OrderSavedEvent; + if (object.id !== undefined && object.id !== null) { + message.id = object.id; + } else { + message.id = ""; + } + if (object.marketId !== undefined && object.marketId !== null) { + message.marketId = object.marketId; + } else { + message.marketId = ""; + } + if (object.orderType !== undefined && object.orderType !== null) { + message.orderType = object.orderType; + } else { + message.orderType = ""; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = object.amount; + } else { + message.amount = ""; + } + if (object.price !== undefined && object.price !== null) { + message.price = object.price; + } else { + message.price = ""; + } + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/bze.tradebin.v1/types/tradebin/genesis.ts b/ts-client/bze.tradebin.v1/types/tradebin/genesis.ts new file mode 100644 index 00000000..7740b880 --- /dev/null +++ b/ts-client/bze.tradebin.v1/types/tradebin/genesis.ts @@ -0,0 +1,281 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; +import { Params } from "../tradebin/params"; +import { Market } from "../tradebin/market"; +import { QueueMessage } from "../tradebin/queue_message"; +import { Order, AggregatedOrder, HistoryOrder } from "../tradebin/order"; + +export const protobufPackage = "bze.tradebin.v1"; + +/** GenesisState defines the tradebin module's genesis state. */ +export interface GenesisState { + params: Params | undefined; + marketList: Market[]; + queueMessageList: QueueMessage[]; + orderList: Order[]; + aggregatedOrderList: AggregatedOrder[]; + historyOrderList: HistoryOrder[]; + orderCounter: number; +} + +const baseGenesisState: object = { orderCounter: 0 }; + +export const GenesisState = { + encode(message: GenesisState, writer: Writer = Writer.create()): Writer { + if (message.params !== undefined) { + Params.encode(message.params, writer.uint32(10).fork()).ldelim(); + } + for (const v of message.marketList) { + Market.encode(v!, writer.uint32(18).fork()).ldelim(); + } + for (const v of message.queueMessageList) { + QueueMessage.encode(v!, writer.uint32(26).fork()).ldelim(); + } + for (const v of message.orderList) { + Order.encode(v!, writer.uint32(34).fork()).ldelim(); + } + for (const v of message.aggregatedOrderList) { + AggregatedOrder.encode(v!, writer.uint32(42).fork()).ldelim(); + } + for (const v of message.historyOrderList) { + HistoryOrder.encode(v!, writer.uint32(50).fork()).ldelim(); + } + if (message.orderCounter !== 0) { + writer.uint32(56).int64(message.orderCounter); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): GenesisState { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseGenesisState } as GenesisState; + message.marketList = []; + message.queueMessageList = []; + message.orderList = []; + message.aggregatedOrderList = []; + message.historyOrderList = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.params = Params.decode(reader, reader.uint32()); + break; + case 2: + message.marketList.push(Market.decode(reader, reader.uint32())); + break; + case 3: + message.queueMessageList.push( + QueueMessage.decode(reader, reader.uint32()) + ); + break; + case 4: + message.orderList.push(Order.decode(reader, reader.uint32())); + break; + case 5: + message.aggregatedOrderList.push( + AggregatedOrder.decode(reader, reader.uint32()) + ); + break; + case 6: + message.historyOrderList.push( + HistoryOrder.decode(reader, reader.uint32()) + ); + break; + case 7: + message.orderCounter = longToNumber(reader.int64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GenesisState { + const message = { ...baseGenesisState } as GenesisState; + message.marketList = []; + message.queueMessageList = []; + message.orderList = []; + message.aggregatedOrderList = []; + message.historyOrderList = []; + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromJSON(object.params); + } else { + message.params = undefined; + } + if (object.marketList !== undefined && object.marketList !== null) { + for (const e of object.marketList) { + message.marketList.push(Market.fromJSON(e)); + } + } + if ( + object.queueMessageList !== undefined && + object.queueMessageList !== null + ) { + for (const e of object.queueMessageList) { + message.queueMessageList.push(QueueMessage.fromJSON(e)); + } + } + if (object.orderList !== undefined && object.orderList !== null) { + for (const e of object.orderList) { + message.orderList.push(Order.fromJSON(e)); + } + } + if ( + object.aggregatedOrderList !== undefined && + object.aggregatedOrderList !== null + ) { + for (const e of object.aggregatedOrderList) { + message.aggregatedOrderList.push(AggregatedOrder.fromJSON(e)); + } + } + if ( + object.historyOrderList !== undefined && + object.historyOrderList !== null + ) { + for (const e of object.historyOrderList) { + message.historyOrderList.push(HistoryOrder.fromJSON(e)); + } + } + if (object.orderCounter !== undefined && object.orderCounter !== null) { + message.orderCounter = Number(object.orderCounter); + } else { + message.orderCounter = 0; + } + return message; + }, + + toJSON(message: GenesisState): unknown { + const obj: any = {}; + message.params !== undefined && + (obj.params = message.params ? Params.toJSON(message.params) : undefined); + if (message.marketList) { + obj.marketList = message.marketList.map((e) => + e ? Market.toJSON(e) : undefined + ); + } else { + obj.marketList = []; + } + if (message.queueMessageList) { + obj.queueMessageList = message.queueMessageList.map((e) => + e ? QueueMessage.toJSON(e) : undefined + ); + } else { + obj.queueMessageList = []; + } + if (message.orderList) { + obj.orderList = message.orderList.map((e) => + e ? Order.toJSON(e) : undefined + ); + } else { + obj.orderList = []; + } + if (message.aggregatedOrderList) { + obj.aggregatedOrderList = message.aggregatedOrderList.map((e) => + e ? AggregatedOrder.toJSON(e) : undefined + ); + } else { + obj.aggregatedOrderList = []; + } + if (message.historyOrderList) { + obj.historyOrderList = message.historyOrderList.map((e) => + e ? HistoryOrder.toJSON(e) : undefined + ); + } else { + obj.historyOrderList = []; + } + message.orderCounter !== undefined && + (obj.orderCounter = message.orderCounter); + return obj; + }, + + fromPartial(object: DeepPartial): GenesisState { + const message = { ...baseGenesisState } as GenesisState; + message.marketList = []; + message.queueMessageList = []; + message.orderList = []; + message.aggregatedOrderList = []; + message.historyOrderList = []; + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromPartial(object.params); + } else { + message.params = undefined; + } + if (object.marketList !== undefined && object.marketList !== null) { + for (const e of object.marketList) { + message.marketList.push(Market.fromPartial(e)); + } + } + if ( + object.queueMessageList !== undefined && + object.queueMessageList !== null + ) { + for (const e of object.queueMessageList) { + message.queueMessageList.push(QueueMessage.fromPartial(e)); + } + } + if (object.orderList !== undefined && object.orderList !== null) { + for (const e of object.orderList) { + message.orderList.push(Order.fromPartial(e)); + } + } + if ( + object.aggregatedOrderList !== undefined && + object.aggregatedOrderList !== null + ) { + for (const e of object.aggregatedOrderList) { + message.aggregatedOrderList.push(AggregatedOrder.fromPartial(e)); + } + } + if ( + object.historyOrderList !== undefined && + object.historyOrderList !== null + ) { + for (const e of object.historyOrderList) { + message.historyOrderList.push(HistoryOrder.fromPartial(e)); + } + } + if (object.orderCounter !== undefined && object.orderCounter !== null) { + message.orderCounter = object.orderCounter; + } else { + message.orderCounter = 0; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/bze.tradebin.v1/types/tradebin/market.ts b/ts-client/bze.tradebin.v1/types/tradebin/market.ts new file mode 100644 index 00000000..09e162b5 --- /dev/null +++ b/ts-client/bze.tradebin.v1/types/tradebin/market.ts @@ -0,0 +1,110 @@ +/* eslint-disable */ +import { Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "bze.tradebin.v1"; + +export interface Market { + base: string; + quote: string; + creator: string; +} + +const baseMarket: object = { base: "", quote: "", creator: "" }; + +export const Market = { + encode(message: Market, writer: Writer = Writer.create()): Writer { + if (message.base !== "") { + writer.uint32(10).string(message.base); + } + if (message.quote !== "") { + writer.uint32(18).string(message.quote); + } + if (message.creator !== "") { + writer.uint32(26).string(message.creator); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Market { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMarket } as Market; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.base = reader.string(); + break; + case 2: + message.quote = reader.string(); + break; + case 3: + message.creator = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Market { + const message = { ...baseMarket } as Market; + if (object.base !== undefined && object.base !== null) { + message.base = String(object.base); + } else { + message.base = ""; + } + if (object.quote !== undefined && object.quote !== null) { + message.quote = String(object.quote); + } else { + message.quote = ""; + } + if (object.creator !== undefined && object.creator !== null) { + message.creator = String(object.creator); + } else { + message.creator = ""; + } + return message; + }, + + toJSON(message: Market): unknown { + const obj: any = {}; + message.base !== undefined && (obj.base = message.base); + message.quote !== undefined && (obj.quote = message.quote); + message.creator !== undefined && (obj.creator = message.creator); + return obj; + }, + + fromPartial(object: DeepPartial): Market { + const message = { ...baseMarket } as Market; + if (object.base !== undefined && object.base !== null) { + message.base = object.base; + } else { + message.base = ""; + } + if (object.quote !== undefined && object.quote !== null) { + message.quote = object.quote; + } else { + message.quote = ""; + } + if (object.creator !== undefined && object.creator !== null) { + message.creator = object.creator; + } else { + message.creator = ""; + } + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/bze.tradebin.v1/types/tradebin/order.ts b/ts-client/bze.tradebin.v1/types/tradebin/order.ts new file mode 100644 index 00000000..be23bb3c --- /dev/null +++ b/ts-client/bze.tradebin.v1/types/tradebin/order.ts @@ -0,0 +1,601 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "bze.tradebin.v1"; + +export interface Order { + id: string; + marketId: string; + orderType: string; + amount: string; + price: string; + createdAt: number; + owner: string; +} + +export interface OrderReference { + id: string; + marketId: string; + orderType: string; +} + +export interface AggregatedOrder { + marketId: string; + orderType: string; + amount: string; + price: string; +} + +export interface HistoryOrder { + marketId: string; + orderType: string; + amount: string; + price: string; + executedAt: number; + maker: string; + taker: string; +} + +const baseOrder: object = { + id: "", + marketId: "", + orderType: "", + amount: "", + price: "", + createdAt: 0, + owner: "", +}; + +export const Order = { + encode(message: Order, writer: Writer = Writer.create()): Writer { + if (message.id !== "") { + writer.uint32(10).string(message.id); + } + if (message.marketId !== "") { + writer.uint32(18).string(message.marketId); + } + if (message.orderType !== "") { + writer.uint32(26).string(message.orderType); + } + if (message.amount !== "") { + writer.uint32(34).string(message.amount); + } + if (message.price !== "") { + writer.uint32(42).string(message.price); + } + if (message.createdAt !== 0) { + writer.uint32(48).int64(message.createdAt); + } + if (message.owner !== "") { + writer.uint32(58).string(message.owner); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Order { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseOrder } as Order; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.id = reader.string(); + break; + case 2: + message.marketId = reader.string(); + break; + case 3: + message.orderType = reader.string(); + break; + case 4: + message.amount = reader.string(); + break; + case 5: + message.price = reader.string(); + break; + case 6: + message.createdAt = longToNumber(reader.int64() as Long); + break; + case 7: + message.owner = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Order { + const message = { ...baseOrder } as Order; + if (object.id !== undefined && object.id !== null) { + message.id = String(object.id); + } else { + message.id = ""; + } + if (object.marketId !== undefined && object.marketId !== null) { + message.marketId = String(object.marketId); + } else { + message.marketId = ""; + } + if (object.orderType !== undefined && object.orderType !== null) { + message.orderType = String(object.orderType); + } else { + message.orderType = ""; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = String(object.amount); + } else { + message.amount = ""; + } + if (object.price !== undefined && object.price !== null) { + message.price = String(object.price); + } else { + message.price = ""; + } + if (object.createdAt !== undefined && object.createdAt !== null) { + message.createdAt = Number(object.createdAt); + } else { + message.createdAt = 0; + } + if (object.owner !== undefined && object.owner !== null) { + message.owner = String(object.owner); + } else { + message.owner = ""; + } + return message; + }, + + toJSON(message: Order): unknown { + const obj: any = {}; + message.id !== undefined && (obj.id = message.id); + message.marketId !== undefined && (obj.marketId = message.marketId); + message.orderType !== undefined && (obj.orderType = message.orderType); + message.amount !== undefined && (obj.amount = message.amount); + message.price !== undefined && (obj.price = message.price); + message.createdAt !== undefined && (obj.createdAt = message.createdAt); + message.owner !== undefined && (obj.owner = message.owner); + return obj; + }, + + fromPartial(object: DeepPartial): Order { + const message = { ...baseOrder } as Order; + if (object.id !== undefined && object.id !== null) { + message.id = object.id; + } else { + message.id = ""; + } + if (object.marketId !== undefined && object.marketId !== null) { + message.marketId = object.marketId; + } else { + message.marketId = ""; + } + if (object.orderType !== undefined && object.orderType !== null) { + message.orderType = object.orderType; + } else { + message.orderType = ""; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = object.amount; + } else { + message.amount = ""; + } + if (object.price !== undefined && object.price !== null) { + message.price = object.price; + } else { + message.price = ""; + } + if (object.createdAt !== undefined && object.createdAt !== null) { + message.createdAt = object.createdAt; + } else { + message.createdAt = 0; + } + if (object.owner !== undefined && object.owner !== null) { + message.owner = object.owner; + } else { + message.owner = ""; + } + return message; + }, +}; + +const baseOrderReference: object = { id: "", marketId: "", orderType: "" }; + +export const OrderReference = { + encode(message: OrderReference, writer: Writer = Writer.create()): Writer { + if (message.id !== "") { + writer.uint32(10).string(message.id); + } + if (message.marketId !== "") { + writer.uint32(18).string(message.marketId); + } + if (message.orderType !== "") { + writer.uint32(26).string(message.orderType); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): OrderReference { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseOrderReference } as OrderReference; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.id = reader.string(); + break; + case 2: + message.marketId = reader.string(); + break; + case 3: + message.orderType = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): OrderReference { + const message = { ...baseOrderReference } as OrderReference; + if (object.id !== undefined && object.id !== null) { + message.id = String(object.id); + } else { + message.id = ""; + } + if (object.marketId !== undefined && object.marketId !== null) { + message.marketId = String(object.marketId); + } else { + message.marketId = ""; + } + if (object.orderType !== undefined && object.orderType !== null) { + message.orderType = String(object.orderType); + } else { + message.orderType = ""; + } + return message; + }, + + toJSON(message: OrderReference): unknown { + const obj: any = {}; + message.id !== undefined && (obj.id = message.id); + message.marketId !== undefined && (obj.marketId = message.marketId); + message.orderType !== undefined && (obj.orderType = message.orderType); + return obj; + }, + + fromPartial(object: DeepPartial): OrderReference { + const message = { ...baseOrderReference } as OrderReference; + if (object.id !== undefined && object.id !== null) { + message.id = object.id; + } else { + message.id = ""; + } + if (object.marketId !== undefined && object.marketId !== null) { + message.marketId = object.marketId; + } else { + message.marketId = ""; + } + if (object.orderType !== undefined && object.orderType !== null) { + message.orderType = object.orderType; + } else { + message.orderType = ""; + } + return message; + }, +}; + +const baseAggregatedOrder: object = { + marketId: "", + orderType: "", + amount: "", + price: "", +}; + +export const AggregatedOrder = { + encode(message: AggregatedOrder, writer: Writer = Writer.create()): Writer { + if (message.marketId !== "") { + writer.uint32(10).string(message.marketId); + } + if (message.orderType !== "") { + writer.uint32(18).string(message.orderType); + } + if (message.amount !== "") { + writer.uint32(26).string(message.amount); + } + if (message.price !== "") { + writer.uint32(34).string(message.price); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): AggregatedOrder { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseAggregatedOrder } as AggregatedOrder; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.marketId = reader.string(); + break; + case 2: + message.orderType = reader.string(); + break; + case 3: + message.amount = reader.string(); + break; + case 4: + message.price = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): AggregatedOrder { + const message = { ...baseAggregatedOrder } as AggregatedOrder; + if (object.marketId !== undefined && object.marketId !== null) { + message.marketId = String(object.marketId); + } else { + message.marketId = ""; + } + if (object.orderType !== undefined && object.orderType !== null) { + message.orderType = String(object.orderType); + } else { + message.orderType = ""; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = String(object.amount); + } else { + message.amount = ""; + } + if (object.price !== undefined && object.price !== null) { + message.price = String(object.price); + } else { + message.price = ""; + } + return message; + }, + + toJSON(message: AggregatedOrder): unknown { + const obj: any = {}; + message.marketId !== undefined && (obj.marketId = message.marketId); + message.orderType !== undefined && (obj.orderType = message.orderType); + message.amount !== undefined && (obj.amount = message.amount); + message.price !== undefined && (obj.price = message.price); + return obj; + }, + + fromPartial(object: DeepPartial): AggregatedOrder { + const message = { ...baseAggregatedOrder } as AggregatedOrder; + if (object.marketId !== undefined && object.marketId !== null) { + message.marketId = object.marketId; + } else { + message.marketId = ""; + } + if (object.orderType !== undefined && object.orderType !== null) { + message.orderType = object.orderType; + } else { + message.orderType = ""; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = object.amount; + } else { + message.amount = ""; + } + if (object.price !== undefined && object.price !== null) { + message.price = object.price; + } else { + message.price = ""; + } + return message; + }, +}; + +const baseHistoryOrder: object = { + marketId: "", + orderType: "", + amount: "", + price: "", + executedAt: 0, + maker: "", + taker: "", +}; + +export const HistoryOrder = { + encode(message: HistoryOrder, writer: Writer = Writer.create()): Writer { + if (message.marketId !== "") { + writer.uint32(10).string(message.marketId); + } + if (message.orderType !== "") { + writer.uint32(18).string(message.orderType); + } + if (message.amount !== "") { + writer.uint32(26).string(message.amount); + } + if (message.price !== "") { + writer.uint32(34).string(message.price); + } + if (message.executedAt !== 0) { + writer.uint32(40).int64(message.executedAt); + } + if (message.maker !== "") { + writer.uint32(50).string(message.maker); + } + if (message.taker !== "") { + writer.uint32(58).string(message.taker); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): HistoryOrder { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseHistoryOrder } as HistoryOrder; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.marketId = reader.string(); + break; + case 2: + message.orderType = reader.string(); + break; + case 3: + message.amount = reader.string(); + break; + case 4: + message.price = reader.string(); + break; + case 5: + message.executedAt = longToNumber(reader.int64() as Long); + break; + case 6: + message.maker = reader.string(); + break; + case 7: + message.taker = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): HistoryOrder { + const message = { ...baseHistoryOrder } as HistoryOrder; + if (object.marketId !== undefined && object.marketId !== null) { + message.marketId = String(object.marketId); + } else { + message.marketId = ""; + } + if (object.orderType !== undefined && object.orderType !== null) { + message.orderType = String(object.orderType); + } else { + message.orderType = ""; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = String(object.amount); + } else { + message.amount = ""; + } + if (object.price !== undefined && object.price !== null) { + message.price = String(object.price); + } else { + message.price = ""; + } + if (object.executedAt !== undefined && object.executedAt !== null) { + message.executedAt = Number(object.executedAt); + } else { + message.executedAt = 0; + } + if (object.maker !== undefined && object.maker !== null) { + message.maker = String(object.maker); + } else { + message.maker = ""; + } + if (object.taker !== undefined && object.taker !== null) { + message.taker = String(object.taker); + } else { + message.taker = ""; + } + return message; + }, + + toJSON(message: HistoryOrder): unknown { + const obj: any = {}; + message.marketId !== undefined && (obj.marketId = message.marketId); + message.orderType !== undefined && (obj.orderType = message.orderType); + message.amount !== undefined && (obj.amount = message.amount); + message.price !== undefined && (obj.price = message.price); + message.executedAt !== undefined && (obj.executedAt = message.executedAt); + message.maker !== undefined && (obj.maker = message.maker); + message.taker !== undefined && (obj.taker = message.taker); + return obj; + }, + + fromPartial(object: DeepPartial): HistoryOrder { + const message = { ...baseHistoryOrder } as HistoryOrder; + if (object.marketId !== undefined && object.marketId !== null) { + message.marketId = object.marketId; + } else { + message.marketId = ""; + } + if (object.orderType !== undefined && object.orderType !== null) { + message.orderType = object.orderType; + } else { + message.orderType = ""; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = object.amount; + } else { + message.amount = ""; + } + if (object.price !== undefined && object.price !== null) { + message.price = object.price; + } else { + message.price = ""; + } + if (object.executedAt !== undefined && object.executedAt !== null) { + message.executedAt = object.executedAt; + } else { + message.executedAt = 0; + } + if (object.maker !== undefined && object.maker !== null) { + message.maker = object.maker; + } else { + message.maker = ""; + } + if (object.taker !== undefined && object.taker !== null) { + message.taker = object.taker; + } else { + message.taker = ""; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/bze.tradebin.v1/types/tradebin/params.ts b/ts-client/bze.tradebin.v1/types/tradebin/params.ts new file mode 100644 index 00000000..1e8b84cb --- /dev/null +++ b/ts-client/bze.tradebin.v1/types/tradebin/params.ts @@ -0,0 +1,176 @@ +/* eslint-disable */ +import { Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "bze.tradebin.v1"; + +/** Params defines the parameters for the module. */ +export interface Params { + createMarketFee: string; + marketMakerFee: string; + marketTakerFee: string; + makerFeeDestination: string; + takerFeeDestination: string; +} + +const baseParams: object = { + createMarketFee: "", + marketMakerFee: "", + marketTakerFee: "", + makerFeeDestination: "", + takerFeeDestination: "", +}; + +export const Params = { + encode(message: Params, writer: Writer = Writer.create()): Writer { + if (message.createMarketFee !== "") { + writer.uint32(10).string(message.createMarketFee); + } + if (message.marketMakerFee !== "") { + writer.uint32(18).string(message.marketMakerFee); + } + if (message.marketTakerFee !== "") { + writer.uint32(26).string(message.marketTakerFee); + } + if (message.makerFeeDestination !== "") { + writer.uint32(34).string(message.makerFeeDestination); + } + if (message.takerFeeDestination !== "") { + writer.uint32(42).string(message.takerFeeDestination); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Params { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseParams } as Params; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.createMarketFee = reader.string(); + break; + case 2: + message.marketMakerFee = reader.string(); + break; + case 3: + message.marketTakerFee = reader.string(); + break; + case 4: + message.makerFeeDestination = reader.string(); + break; + case 5: + message.takerFeeDestination = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Params { + const message = { ...baseParams } as Params; + if ( + object.createMarketFee !== undefined && + object.createMarketFee !== null + ) { + message.createMarketFee = String(object.createMarketFee); + } else { + message.createMarketFee = ""; + } + if (object.marketMakerFee !== undefined && object.marketMakerFee !== null) { + message.marketMakerFee = String(object.marketMakerFee); + } else { + message.marketMakerFee = ""; + } + if (object.marketTakerFee !== undefined && object.marketTakerFee !== null) { + message.marketTakerFee = String(object.marketTakerFee); + } else { + message.marketTakerFee = ""; + } + if ( + object.makerFeeDestination !== undefined && + object.makerFeeDestination !== null + ) { + message.makerFeeDestination = String(object.makerFeeDestination); + } else { + message.makerFeeDestination = ""; + } + if ( + object.takerFeeDestination !== undefined && + object.takerFeeDestination !== null + ) { + message.takerFeeDestination = String(object.takerFeeDestination); + } else { + message.takerFeeDestination = ""; + } + return message; + }, + + toJSON(message: Params): unknown { + const obj: any = {}; + message.createMarketFee !== undefined && + (obj.createMarketFee = message.createMarketFee); + message.marketMakerFee !== undefined && + (obj.marketMakerFee = message.marketMakerFee); + message.marketTakerFee !== undefined && + (obj.marketTakerFee = message.marketTakerFee); + message.makerFeeDestination !== undefined && + (obj.makerFeeDestination = message.makerFeeDestination); + message.takerFeeDestination !== undefined && + (obj.takerFeeDestination = message.takerFeeDestination); + return obj; + }, + + fromPartial(object: DeepPartial): Params { + const message = { ...baseParams } as Params; + if ( + object.createMarketFee !== undefined && + object.createMarketFee !== null + ) { + message.createMarketFee = object.createMarketFee; + } else { + message.createMarketFee = ""; + } + if (object.marketMakerFee !== undefined && object.marketMakerFee !== null) { + message.marketMakerFee = object.marketMakerFee; + } else { + message.marketMakerFee = ""; + } + if (object.marketTakerFee !== undefined && object.marketTakerFee !== null) { + message.marketTakerFee = object.marketTakerFee; + } else { + message.marketTakerFee = ""; + } + if ( + object.makerFeeDestination !== undefined && + object.makerFeeDestination !== null + ) { + message.makerFeeDestination = object.makerFeeDestination; + } else { + message.makerFeeDestination = ""; + } + if ( + object.takerFeeDestination !== undefined && + object.takerFeeDestination !== null + ) { + message.takerFeeDestination = object.takerFeeDestination; + } else { + message.takerFeeDestination = ""; + } + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/bze.tradebin.v1/types/tradebin/query.ts b/ts-client/bze.tradebin.v1/types/tradebin/query.ts new file mode 100644 index 00000000..19d719f1 --- /dev/null +++ b/ts-client/bze.tradebin.v1/types/tradebin/query.ts @@ -0,0 +1,1585 @@ +/* eslint-disable */ +import { Reader, Writer } from "protobufjs/minimal"; +import { Params } from "../tradebin/params"; +import { Market } from "../tradebin/market"; +import { + PageRequest, + PageResponse, +} from "../cosmos/base/query/v1beta1/pagination"; +import { + OrderReference, + AggregatedOrder, + HistoryOrder, + Order, +} from "../tradebin/order"; + +export const protobufPackage = "bze.tradebin.v1"; + +/** QueryParamsRequest is request type for the Query/Params RPC method. */ +export interface QueryParamsRequest {} + +/** QueryParamsResponse is response type for the Query/Params RPC method. */ +export interface QueryParamsResponse { + /** params holds all the parameters of this module. */ + params: Params | undefined; +} + +export interface QueryGetMarketRequest { + base: string; + quote: string; +} + +export interface QueryGetMarketResponse { + market: Market | undefined; +} + +export interface QueryAllMarketRequest { + pagination: PageRequest | undefined; +} + +export interface QueryAllMarketResponse { + market: Market[]; + pagination: PageResponse | undefined; +} + +export interface QueryAssetMarketsRequest { + asset: string; +} + +export interface QueryAssetMarketsResponse { + base: Market[]; + quote: Market[]; +} + +export interface QueryUserMarketOrdersRequest { + address: string; + market: string; + pagination: PageRequest | undefined; +} + +export interface QueryUserMarketOrdersResponse { + list: OrderReference[]; + pagination: PageResponse | undefined; +} + +export interface QueryMarketAggregatedOrdersRequest { + market: string; + orderType: string; + pagination: PageRequest | undefined; +} + +export interface QueryMarketAggregatedOrdersResponse { + list: AggregatedOrder[]; + pagination: PageResponse | undefined; +} + +export interface QueryMarketHistoryRequest { + market: string; + pagination: PageRequest | undefined; +} + +export interface QueryMarketHistoryResponse { + list: HistoryOrder[]; + pagination: PageResponse | undefined; +} + +export interface QueryMarketOrderRequest { + market: string; + orderType: string; + orderId: string; +} + +export interface QueryMarketOrderResponse { + order: Order | undefined; +} + +const baseQueryParamsRequest: object = {}; + +export const QueryParamsRequest = { + encode(_: QueryParamsRequest, writer: Writer = Writer.create()): Writer { + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QueryParamsRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryParamsRequest } as QueryParamsRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): QueryParamsRequest { + const message = { ...baseQueryParamsRequest } as QueryParamsRequest; + return message; + }, + + toJSON(_: QueryParamsRequest): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial(_: DeepPartial): QueryParamsRequest { + const message = { ...baseQueryParamsRequest } as QueryParamsRequest; + return message; + }, +}; + +const baseQueryParamsResponse: object = {}; + +export const QueryParamsResponse = { + encode( + message: QueryParamsResponse, + writer: Writer = Writer.create() + ): Writer { + if (message.params !== undefined) { + Params.encode(message.params, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QueryParamsResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryParamsResponse } as QueryParamsResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.params = Params.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryParamsResponse { + const message = { ...baseQueryParamsResponse } as QueryParamsResponse; + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromJSON(object.params); + } else { + message.params = undefined; + } + return message; + }, + + toJSON(message: QueryParamsResponse): unknown { + const obj: any = {}; + message.params !== undefined && + (obj.params = message.params ? Params.toJSON(message.params) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): QueryParamsResponse { + const message = { ...baseQueryParamsResponse } as QueryParamsResponse; + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromPartial(object.params); + } else { + message.params = undefined; + } + return message; + }, +}; + +const baseQueryGetMarketRequest: object = { base: "", quote: "" }; + +export const QueryGetMarketRequest = { + encode( + message: QueryGetMarketRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.base !== "") { + writer.uint32(10).string(message.base); + } + if (message.quote !== "") { + writer.uint32(18).string(message.quote); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QueryGetMarketRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryGetMarketRequest } as QueryGetMarketRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.base = reader.string(); + break; + case 2: + message.quote = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryGetMarketRequest { + const message = { ...baseQueryGetMarketRequest } as QueryGetMarketRequest; + if (object.base !== undefined && object.base !== null) { + message.base = String(object.base); + } else { + message.base = ""; + } + if (object.quote !== undefined && object.quote !== null) { + message.quote = String(object.quote); + } else { + message.quote = ""; + } + return message; + }, + + toJSON(message: QueryGetMarketRequest): unknown { + const obj: any = {}; + message.base !== undefined && (obj.base = message.base); + message.quote !== undefined && (obj.quote = message.quote); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryGetMarketRequest { + const message = { ...baseQueryGetMarketRequest } as QueryGetMarketRequest; + if (object.base !== undefined && object.base !== null) { + message.base = object.base; + } else { + message.base = ""; + } + if (object.quote !== undefined && object.quote !== null) { + message.quote = object.quote; + } else { + message.quote = ""; + } + return message; + }, +}; + +const baseQueryGetMarketResponse: object = {}; + +export const QueryGetMarketResponse = { + encode( + message: QueryGetMarketResponse, + writer: Writer = Writer.create() + ): Writer { + if (message.market !== undefined) { + Market.encode(message.market, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QueryGetMarketResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryGetMarketResponse } as QueryGetMarketResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.market = Market.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryGetMarketResponse { + const message = { ...baseQueryGetMarketResponse } as QueryGetMarketResponse; + if (object.market !== undefined && object.market !== null) { + message.market = Market.fromJSON(object.market); + } else { + message.market = undefined; + } + return message; + }, + + toJSON(message: QueryGetMarketResponse): unknown { + const obj: any = {}; + message.market !== undefined && + (obj.market = message.market ? Market.toJSON(message.market) : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryGetMarketResponse { + const message = { ...baseQueryGetMarketResponse } as QueryGetMarketResponse; + if (object.market !== undefined && object.market !== null) { + message.market = Market.fromPartial(object.market); + } else { + message.market = undefined; + } + return message; + }, +}; + +const baseQueryAllMarketRequest: object = {}; + +export const QueryAllMarketRequest = { + encode( + message: QueryAllMarketRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QueryAllMarketRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryAllMarketRequest } as QueryAllMarketRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryAllMarketRequest { + const message = { ...baseQueryAllMarketRequest } as QueryAllMarketRequest; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryAllMarketRequest): unknown { + const obj: any = {}; + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageRequest.toJSON(message.pagination) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryAllMarketRequest { + const message = { ...baseQueryAllMarketRequest } as QueryAllMarketRequest; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseQueryAllMarketResponse: object = {}; + +export const QueryAllMarketResponse = { + encode( + message: QueryAllMarketResponse, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.market) { + Market.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode( + message.pagination, + writer.uint32(18).fork() + ).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QueryAllMarketResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryAllMarketResponse } as QueryAllMarketResponse; + message.market = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.market.push(Market.decode(reader, reader.uint32())); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryAllMarketResponse { + const message = { ...baseQueryAllMarketResponse } as QueryAllMarketResponse; + message.market = []; + if (object.market !== undefined && object.market !== null) { + for (const e of object.market) { + message.market.push(Market.fromJSON(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryAllMarketResponse): unknown { + const obj: any = {}; + if (message.market) { + obj.market = message.market.map((e) => + e ? Market.toJSON(e) : undefined + ); + } else { + obj.market = []; + } + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageResponse.toJSON(message.pagination) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryAllMarketResponse { + const message = { ...baseQueryAllMarketResponse } as QueryAllMarketResponse; + message.market = []; + if (object.market !== undefined && object.market !== null) { + for (const e of object.market) { + message.market.push(Market.fromPartial(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseQueryAssetMarketsRequest: object = { asset: "" }; + +export const QueryAssetMarketsRequest = { + encode( + message: QueryAssetMarketsRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.asset !== "") { + writer.uint32(10).string(message.asset); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryAssetMarketsRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryAssetMarketsRequest, + } as QueryAssetMarketsRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.asset = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryAssetMarketsRequest { + const message = { + ...baseQueryAssetMarketsRequest, + } as QueryAssetMarketsRequest; + if (object.asset !== undefined && object.asset !== null) { + message.asset = String(object.asset); + } else { + message.asset = ""; + } + return message; + }, + + toJSON(message: QueryAssetMarketsRequest): unknown { + const obj: any = {}; + message.asset !== undefined && (obj.asset = message.asset); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryAssetMarketsRequest { + const message = { + ...baseQueryAssetMarketsRequest, + } as QueryAssetMarketsRequest; + if (object.asset !== undefined && object.asset !== null) { + message.asset = object.asset; + } else { + message.asset = ""; + } + return message; + }, +}; + +const baseQueryAssetMarketsResponse: object = {}; + +export const QueryAssetMarketsResponse = { + encode( + message: QueryAssetMarketsResponse, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.base) { + Market.encode(v!, writer.uint32(10).fork()).ldelim(); + } + for (const v of message.quote) { + Market.encode(v!, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryAssetMarketsResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryAssetMarketsResponse, + } as QueryAssetMarketsResponse; + message.base = []; + message.quote = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.base.push(Market.decode(reader, reader.uint32())); + break; + case 2: + message.quote.push(Market.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryAssetMarketsResponse { + const message = { + ...baseQueryAssetMarketsResponse, + } as QueryAssetMarketsResponse; + message.base = []; + message.quote = []; + if (object.base !== undefined && object.base !== null) { + for (const e of object.base) { + message.base.push(Market.fromJSON(e)); + } + } + if (object.quote !== undefined && object.quote !== null) { + for (const e of object.quote) { + message.quote.push(Market.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: QueryAssetMarketsResponse): unknown { + const obj: any = {}; + if (message.base) { + obj.base = message.base.map((e) => (e ? Market.toJSON(e) : undefined)); + } else { + obj.base = []; + } + if (message.quote) { + obj.quote = message.quote.map((e) => (e ? Market.toJSON(e) : undefined)); + } else { + obj.quote = []; + } + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryAssetMarketsResponse { + const message = { + ...baseQueryAssetMarketsResponse, + } as QueryAssetMarketsResponse; + message.base = []; + message.quote = []; + if (object.base !== undefined && object.base !== null) { + for (const e of object.base) { + message.base.push(Market.fromPartial(e)); + } + } + if (object.quote !== undefined && object.quote !== null) { + for (const e of object.quote) { + message.quote.push(Market.fromPartial(e)); + } + } + return message; + }, +}; + +const baseQueryUserMarketOrdersRequest: object = { address: "", market: "" }; + +export const QueryUserMarketOrdersRequest = { + encode( + message: QueryUserMarketOrdersRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.address !== "") { + writer.uint32(10).string(message.address); + } + if (message.market !== "") { + writer.uint32(18).string(message.market); + } + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryUserMarketOrdersRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryUserMarketOrdersRequest, + } as QueryUserMarketOrdersRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.address = reader.string(); + break; + case 2: + message.market = reader.string(); + break; + case 3: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryUserMarketOrdersRequest { + const message = { + ...baseQueryUserMarketOrdersRequest, + } as QueryUserMarketOrdersRequest; + if (object.address !== undefined && object.address !== null) { + message.address = String(object.address); + } else { + message.address = ""; + } + if (object.market !== undefined && object.market !== null) { + message.market = String(object.market); + } else { + message.market = ""; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryUserMarketOrdersRequest): unknown { + const obj: any = {}; + message.address !== undefined && (obj.address = message.address); + message.market !== undefined && (obj.market = message.market); + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageRequest.toJSON(message.pagination) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryUserMarketOrdersRequest { + const message = { + ...baseQueryUserMarketOrdersRequest, + } as QueryUserMarketOrdersRequest; + if (object.address !== undefined && object.address !== null) { + message.address = object.address; + } else { + message.address = ""; + } + if (object.market !== undefined && object.market !== null) { + message.market = object.market; + } else { + message.market = ""; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseQueryUserMarketOrdersResponse: object = {}; + +export const QueryUserMarketOrdersResponse = { + encode( + message: QueryUserMarketOrdersResponse, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.list) { + OrderReference.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode( + message.pagination, + writer.uint32(18).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryUserMarketOrdersResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryUserMarketOrdersResponse, + } as QueryUserMarketOrdersResponse; + message.list = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.list.push(OrderReference.decode(reader, reader.uint32())); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryUserMarketOrdersResponse { + const message = { + ...baseQueryUserMarketOrdersResponse, + } as QueryUserMarketOrdersResponse; + message.list = []; + if (object.list !== undefined && object.list !== null) { + for (const e of object.list) { + message.list.push(OrderReference.fromJSON(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryUserMarketOrdersResponse): unknown { + const obj: any = {}; + if (message.list) { + obj.list = message.list.map((e) => + e ? OrderReference.toJSON(e) : undefined + ); + } else { + obj.list = []; + } + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageResponse.toJSON(message.pagination) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryUserMarketOrdersResponse { + const message = { + ...baseQueryUserMarketOrdersResponse, + } as QueryUserMarketOrdersResponse; + message.list = []; + if (object.list !== undefined && object.list !== null) { + for (const e of object.list) { + message.list.push(OrderReference.fromPartial(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseQueryMarketAggregatedOrdersRequest: object = { + market: "", + orderType: "", +}; + +export const QueryMarketAggregatedOrdersRequest = { + encode( + message: QueryMarketAggregatedOrdersRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.market !== "") { + writer.uint32(10).string(message.market); + } + if (message.orderType !== "") { + writer.uint32(18).string(message.orderType); + } + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryMarketAggregatedOrdersRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryMarketAggregatedOrdersRequest, + } as QueryMarketAggregatedOrdersRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.market = reader.string(); + break; + case 2: + message.orderType = reader.string(); + break; + case 3: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryMarketAggregatedOrdersRequest { + const message = { + ...baseQueryMarketAggregatedOrdersRequest, + } as QueryMarketAggregatedOrdersRequest; + if (object.market !== undefined && object.market !== null) { + message.market = String(object.market); + } else { + message.market = ""; + } + if (object.orderType !== undefined && object.orderType !== null) { + message.orderType = String(object.orderType); + } else { + message.orderType = ""; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryMarketAggregatedOrdersRequest): unknown { + const obj: any = {}; + message.market !== undefined && (obj.market = message.market); + message.orderType !== undefined && (obj.orderType = message.orderType); + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageRequest.toJSON(message.pagination) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryMarketAggregatedOrdersRequest { + const message = { + ...baseQueryMarketAggregatedOrdersRequest, + } as QueryMarketAggregatedOrdersRequest; + if (object.market !== undefined && object.market !== null) { + message.market = object.market; + } else { + message.market = ""; + } + if (object.orderType !== undefined && object.orderType !== null) { + message.orderType = object.orderType; + } else { + message.orderType = ""; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseQueryMarketAggregatedOrdersResponse: object = {}; + +export const QueryMarketAggregatedOrdersResponse = { + encode( + message: QueryMarketAggregatedOrdersResponse, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.list) { + AggregatedOrder.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode( + message.pagination, + writer.uint32(18).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryMarketAggregatedOrdersResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryMarketAggregatedOrdersResponse, + } as QueryMarketAggregatedOrdersResponse; + message.list = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.list.push(AggregatedOrder.decode(reader, reader.uint32())); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryMarketAggregatedOrdersResponse { + const message = { + ...baseQueryMarketAggregatedOrdersResponse, + } as QueryMarketAggregatedOrdersResponse; + message.list = []; + if (object.list !== undefined && object.list !== null) { + for (const e of object.list) { + message.list.push(AggregatedOrder.fromJSON(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryMarketAggregatedOrdersResponse): unknown { + const obj: any = {}; + if (message.list) { + obj.list = message.list.map((e) => + e ? AggregatedOrder.toJSON(e) : undefined + ); + } else { + obj.list = []; + } + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageResponse.toJSON(message.pagination) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryMarketAggregatedOrdersResponse { + const message = { + ...baseQueryMarketAggregatedOrdersResponse, + } as QueryMarketAggregatedOrdersResponse; + message.list = []; + if (object.list !== undefined && object.list !== null) { + for (const e of object.list) { + message.list.push(AggregatedOrder.fromPartial(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseQueryMarketHistoryRequest: object = { market: "" }; + +export const QueryMarketHistoryRequest = { + encode( + message: QueryMarketHistoryRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.market !== "") { + writer.uint32(10).string(message.market); + } + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryMarketHistoryRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryMarketHistoryRequest, + } as QueryMarketHistoryRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.market = reader.string(); + break; + case 2: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryMarketHistoryRequest { + const message = { + ...baseQueryMarketHistoryRequest, + } as QueryMarketHistoryRequest; + if (object.market !== undefined && object.market !== null) { + message.market = String(object.market); + } else { + message.market = ""; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryMarketHistoryRequest): unknown { + const obj: any = {}; + message.market !== undefined && (obj.market = message.market); + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageRequest.toJSON(message.pagination) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryMarketHistoryRequest { + const message = { + ...baseQueryMarketHistoryRequest, + } as QueryMarketHistoryRequest; + if (object.market !== undefined && object.market !== null) { + message.market = object.market; + } else { + message.market = ""; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseQueryMarketHistoryResponse: object = {}; + +export const QueryMarketHistoryResponse = { + encode( + message: QueryMarketHistoryResponse, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.list) { + HistoryOrder.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode( + message.pagination, + writer.uint32(18).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryMarketHistoryResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryMarketHistoryResponse, + } as QueryMarketHistoryResponse; + message.list = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.list.push(HistoryOrder.decode(reader, reader.uint32())); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryMarketHistoryResponse { + const message = { + ...baseQueryMarketHistoryResponse, + } as QueryMarketHistoryResponse; + message.list = []; + if (object.list !== undefined && object.list !== null) { + for (const e of object.list) { + message.list.push(HistoryOrder.fromJSON(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryMarketHistoryResponse): unknown { + const obj: any = {}; + if (message.list) { + obj.list = message.list.map((e) => + e ? HistoryOrder.toJSON(e) : undefined + ); + } else { + obj.list = []; + } + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageResponse.toJSON(message.pagination) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryMarketHistoryResponse { + const message = { + ...baseQueryMarketHistoryResponse, + } as QueryMarketHistoryResponse; + message.list = []; + if (object.list !== undefined && object.list !== null) { + for (const e of object.list) { + message.list.push(HistoryOrder.fromPartial(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseQueryMarketOrderRequest: object = { + market: "", + orderType: "", + orderId: "", +}; + +export const QueryMarketOrderRequest = { + encode( + message: QueryMarketOrderRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.market !== "") { + writer.uint32(10).string(message.market); + } + if (message.orderType !== "") { + writer.uint32(18).string(message.orderType); + } + if (message.orderId !== "") { + writer.uint32(26).string(message.orderId); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QueryMarketOrderRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryMarketOrderRequest, + } as QueryMarketOrderRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.market = reader.string(); + break; + case 2: + message.orderType = reader.string(); + break; + case 3: + message.orderId = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryMarketOrderRequest { + const message = { + ...baseQueryMarketOrderRequest, + } as QueryMarketOrderRequest; + if (object.market !== undefined && object.market !== null) { + message.market = String(object.market); + } else { + message.market = ""; + } + if (object.orderType !== undefined && object.orderType !== null) { + message.orderType = String(object.orderType); + } else { + message.orderType = ""; + } + if (object.orderId !== undefined && object.orderId !== null) { + message.orderId = String(object.orderId); + } else { + message.orderId = ""; + } + return message; + }, + + toJSON(message: QueryMarketOrderRequest): unknown { + const obj: any = {}; + message.market !== undefined && (obj.market = message.market); + message.orderType !== undefined && (obj.orderType = message.orderType); + message.orderId !== undefined && (obj.orderId = message.orderId); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryMarketOrderRequest { + const message = { + ...baseQueryMarketOrderRequest, + } as QueryMarketOrderRequest; + if (object.market !== undefined && object.market !== null) { + message.market = object.market; + } else { + message.market = ""; + } + if (object.orderType !== undefined && object.orderType !== null) { + message.orderType = object.orderType; + } else { + message.orderType = ""; + } + if (object.orderId !== undefined && object.orderId !== null) { + message.orderId = object.orderId; + } else { + message.orderId = ""; + } + return message; + }, +}; + +const baseQueryMarketOrderResponse: object = {}; + +export const QueryMarketOrderResponse = { + encode( + message: QueryMarketOrderResponse, + writer: Writer = Writer.create() + ): Writer { + if (message.order !== undefined) { + Order.encode(message.order, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryMarketOrderResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryMarketOrderResponse, + } as QueryMarketOrderResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.order = Order.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryMarketOrderResponse { + const message = { + ...baseQueryMarketOrderResponse, + } as QueryMarketOrderResponse; + if (object.order !== undefined && object.order !== null) { + message.order = Order.fromJSON(object.order); + } else { + message.order = undefined; + } + return message; + }, + + toJSON(message: QueryMarketOrderResponse): unknown { + const obj: any = {}; + message.order !== undefined && + (obj.order = message.order ? Order.toJSON(message.order) : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryMarketOrderResponse { + const message = { + ...baseQueryMarketOrderResponse, + } as QueryMarketOrderResponse; + if (object.order !== undefined && object.order !== null) { + message.order = Order.fromPartial(object.order); + } else { + message.order = undefined; + } + return message; + }, +}; + +/** Query defines the gRPC querier service. */ +export interface Query { + /** Parameters queries the parameters of the module. */ + Params(request: QueryParamsRequest): Promise; + /** Queries a Market by index. */ + Market(request: QueryGetMarketRequest): Promise; + /** Queries a list of Market items. */ + MarketAll(request: QueryAllMarketRequest): Promise; + /** Queries a list of AssetMarkets items. */ + AssetMarkets( + request: QueryAssetMarketsRequest + ): Promise; + /** Queries a list of UserMarketOrders items. */ + UserMarketOrders( + request: QueryUserMarketOrdersRequest + ): Promise; + /** Queries a list of MarketAggregatedOrders items. */ + MarketAggregatedOrders( + request: QueryMarketAggregatedOrdersRequest + ): Promise; + /** Queries a list of MarketHistory items. */ + MarketHistory( + request: QueryMarketHistoryRequest + ): Promise; + /** Queries a list of MarketOrder items. */ + MarketOrder( + request: QueryMarketOrderRequest + ): Promise; +} + +export class QueryClientImpl implements Query { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + } + Params(request: QueryParamsRequest): Promise { + const data = QueryParamsRequest.encode(request).finish(); + const promise = this.rpc.request("bze.tradebin.v1.Query", "Params", data); + return promise.then((data) => QueryParamsResponse.decode(new Reader(data))); + } + + Market(request: QueryGetMarketRequest): Promise { + const data = QueryGetMarketRequest.encode(request).finish(); + const promise = this.rpc.request("bze.tradebin.v1.Query", "Market", data); + return promise.then((data) => + QueryGetMarketResponse.decode(new Reader(data)) + ); + } + + MarketAll(request: QueryAllMarketRequest): Promise { + const data = QueryAllMarketRequest.encode(request).finish(); + const promise = this.rpc.request( + "bze.tradebin.v1.Query", + "MarketAll", + data + ); + return promise.then((data) => + QueryAllMarketResponse.decode(new Reader(data)) + ); + } + + AssetMarkets( + request: QueryAssetMarketsRequest + ): Promise { + const data = QueryAssetMarketsRequest.encode(request).finish(); + const promise = this.rpc.request( + "bze.tradebin.v1.Query", + "AssetMarkets", + data + ); + return promise.then((data) => + QueryAssetMarketsResponse.decode(new Reader(data)) + ); + } + + UserMarketOrders( + request: QueryUserMarketOrdersRequest + ): Promise { + const data = QueryUserMarketOrdersRequest.encode(request).finish(); + const promise = this.rpc.request( + "bze.tradebin.v1.Query", + "UserMarketOrders", + data + ); + return promise.then((data) => + QueryUserMarketOrdersResponse.decode(new Reader(data)) + ); + } + + MarketAggregatedOrders( + request: QueryMarketAggregatedOrdersRequest + ): Promise { + const data = QueryMarketAggregatedOrdersRequest.encode(request).finish(); + const promise = this.rpc.request( + "bze.tradebin.v1.Query", + "MarketAggregatedOrders", + data + ); + return promise.then((data) => + QueryMarketAggregatedOrdersResponse.decode(new Reader(data)) + ); + } + + MarketHistory( + request: QueryMarketHistoryRequest + ): Promise { + const data = QueryMarketHistoryRequest.encode(request).finish(); + const promise = this.rpc.request( + "bze.tradebin.v1.Query", + "MarketHistory", + data + ); + return promise.then((data) => + QueryMarketHistoryResponse.decode(new Reader(data)) + ); + } + + MarketOrder( + request: QueryMarketOrderRequest + ): Promise { + const data = QueryMarketOrderRequest.encode(request).finish(); + const promise = this.rpc.request( + "bze.tradebin.v1.Query", + "MarketOrder", + data + ); + return promise.then((data) => + QueryMarketOrderResponse.decode(new Reader(data)) + ); + } +} + +interface Rpc { + request( + service: string, + method: string, + data: Uint8Array + ): Promise; +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/bze.tradebin.v1/types/tradebin/queue_message.ts b/ts-client/bze.tradebin.v1/types/tradebin/queue_message.ts new file mode 100644 index 00000000..20541efd --- /dev/null +++ b/ts-client/bze.tradebin.v1/types/tradebin/queue_message.ts @@ -0,0 +1,252 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "bze.tradebin.v1"; + +export interface QueueMessage { + messageId: string; + marketId: string; + messageType: string; + amount: string; + price: string; + createdAt: number; + orderId: string; + orderType: string; + owner: string; +} + +const baseQueueMessage: object = { + messageId: "", + marketId: "", + messageType: "", + amount: "", + price: "", + createdAt: 0, + orderId: "", + orderType: "", + owner: "", +}; + +export const QueueMessage = { + encode(message: QueueMessage, writer: Writer = Writer.create()): Writer { + if (message.messageId !== "") { + writer.uint32(10).string(message.messageId); + } + if (message.marketId !== "") { + writer.uint32(18).string(message.marketId); + } + if (message.messageType !== "") { + writer.uint32(26).string(message.messageType); + } + if (message.amount !== "") { + writer.uint32(34).string(message.amount); + } + if (message.price !== "") { + writer.uint32(42).string(message.price); + } + if (message.createdAt !== 0) { + writer.uint32(48).int64(message.createdAt); + } + if (message.orderId !== "") { + writer.uint32(58).string(message.orderId); + } + if (message.orderType !== "") { + writer.uint32(66).string(message.orderType); + } + if (message.owner !== "") { + writer.uint32(74).string(message.owner); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QueueMessage { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueueMessage } as QueueMessage; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.messageId = reader.string(); + break; + case 2: + message.marketId = reader.string(); + break; + case 3: + message.messageType = reader.string(); + break; + case 4: + message.amount = reader.string(); + break; + case 5: + message.price = reader.string(); + break; + case 6: + message.createdAt = longToNumber(reader.int64() as Long); + break; + case 7: + message.orderId = reader.string(); + break; + case 8: + message.orderType = reader.string(); + break; + case 9: + message.owner = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueueMessage { + const message = { ...baseQueueMessage } as QueueMessage; + if (object.messageId !== undefined && object.messageId !== null) { + message.messageId = String(object.messageId); + } else { + message.messageId = ""; + } + if (object.marketId !== undefined && object.marketId !== null) { + message.marketId = String(object.marketId); + } else { + message.marketId = ""; + } + if (object.messageType !== undefined && object.messageType !== null) { + message.messageType = String(object.messageType); + } else { + message.messageType = ""; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = String(object.amount); + } else { + message.amount = ""; + } + if (object.price !== undefined && object.price !== null) { + message.price = String(object.price); + } else { + message.price = ""; + } + if (object.createdAt !== undefined && object.createdAt !== null) { + message.createdAt = Number(object.createdAt); + } else { + message.createdAt = 0; + } + if (object.orderId !== undefined && object.orderId !== null) { + message.orderId = String(object.orderId); + } else { + message.orderId = ""; + } + if (object.orderType !== undefined && object.orderType !== null) { + message.orderType = String(object.orderType); + } else { + message.orderType = ""; + } + if (object.owner !== undefined && object.owner !== null) { + message.owner = String(object.owner); + } else { + message.owner = ""; + } + return message; + }, + + toJSON(message: QueueMessage): unknown { + const obj: any = {}; + message.messageId !== undefined && (obj.messageId = message.messageId); + message.marketId !== undefined && (obj.marketId = message.marketId); + message.messageType !== undefined && + (obj.messageType = message.messageType); + message.amount !== undefined && (obj.amount = message.amount); + message.price !== undefined && (obj.price = message.price); + message.createdAt !== undefined && (obj.createdAt = message.createdAt); + message.orderId !== undefined && (obj.orderId = message.orderId); + message.orderType !== undefined && (obj.orderType = message.orderType); + message.owner !== undefined && (obj.owner = message.owner); + return obj; + }, + + fromPartial(object: DeepPartial): QueueMessage { + const message = { ...baseQueueMessage } as QueueMessage; + if (object.messageId !== undefined && object.messageId !== null) { + message.messageId = object.messageId; + } else { + message.messageId = ""; + } + if (object.marketId !== undefined && object.marketId !== null) { + message.marketId = object.marketId; + } else { + message.marketId = ""; + } + if (object.messageType !== undefined && object.messageType !== null) { + message.messageType = object.messageType; + } else { + message.messageType = ""; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = object.amount; + } else { + message.amount = ""; + } + if (object.price !== undefined && object.price !== null) { + message.price = object.price; + } else { + message.price = ""; + } + if (object.createdAt !== undefined && object.createdAt !== null) { + message.createdAt = object.createdAt; + } else { + message.createdAt = 0; + } + if (object.orderId !== undefined && object.orderId !== null) { + message.orderId = object.orderId; + } else { + message.orderId = ""; + } + if (object.orderType !== undefined && object.orderType !== null) { + message.orderType = object.orderType; + } else { + message.orderType = ""; + } + if (object.owner !== undefined && object.owner !== null) { + message.owner = object.owner; + } else { + message.owner = ""; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/bze.tradebin.v1/types/tradebin/tx.ts b/ts-client/bze.tradebin.v1/types/tradebin/tx.ts new file mode 100644 index 00000000..8937283f --- /dev/null +++ b/ts-client/bze.tradebin.v1/types/tradebin/tx.ts @@ -0,0 +1,551 @@ +/* eslint-disable */ +import { Reader, Writer } from "protobufjs/minimal"; + +export const protobufPackage = "bze.tradebin.v1"; + +export interface MsgCreateMarket { + creator: string; + base: string; + quote: string; +} + +export interface MsgCreateMarketResponse {} + +export interface MsgCreateOrder { + creator: string; + orderType: string; + amount: string; + price: string; + marketId: string; +} + +export interface MsgCreateOrderResponse {} + +export interface MsgCancelOrder { + creator: string; + marketId: string; + orderId: string; + orderType: string; +} + +export interface MsgCancelOrderResponse {} + +const baseMsgCreateMarket: object = { creator: "", base: "", quote: "" }; + +export const MsgCreateMarket = { + encode(message: MsgCreateMarket, writer: Writer = Writer.create()): Writer { + if (message.creator !== "") { + writer.uint32(10).string(message.creator); + } + if (message.base !== "") { + writer.uint32(18).string(message.base); + } + if (message.quote !== "") { + writer.uint32(26).string(message.quote); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MsgCreateMarket { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgCreateMarket } as MsgCreateMarket; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.creator = reader.string(); + break; + case 2: + message.base = reader.string(); + break; + case 3: + message.quote = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgCreateMarket { + const message = { ...baseMsgCreateMarket } as MsgCreateMarket; + if (object.creator !== undefined && object.creator !== null) { + message.creator = String(object.creator); + } else { + message.creator = ""; + } + if (object.base !== undefined && object.base !== null) { + message.base = String(object.base); + } else { + message.base = ""; + } + if (object.quote !== undefined && object.quote !== null) { + message.quote = String(object.quote); + } else { + message.quote = ""; + } + return message; + }, + + toJSON(message: MsgCreateMarket): unknown { + const obj: any = {}; + message.creator !== undefined && (obj.creator = message.creator); + message.base !== undefined && (obj.base = message.base); + message.quote !== undefined && (obj.quote = message.quote); + return obj; + }, + + fromPartial(object: DeepPartial): MsgCreateMarket { + const message = { ...baseMsgCreateMarket } as MsgCreateMarket; + if (object.creator !== undefined && object.creator !== null) { + message.creator = object.creator; + } else { + message.creator = ""; + } + if (object.base !== undefined && object.base !== null) { + message.base = object.base; + } else { + message.base = ""; + } + if (object.quote !== undefined && object.quote !== null) { + message.quote = object.quote; + } else { + message.quote = ""; + } + return message; + }, +}; + +const baseMsgCreateMarketResponse: object = {}; + +export const MsgCreateMarketResponse = { + encode(_: MsgCreateMarketResponse, writer: Writer = Writer.create()): Writer { + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MsgCreateMarketResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseMsgCreateMarketResponse, + } as MsgCreateMarketResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): MsgCreateMarketResponse { + const message = { + ...baseMsgCreateMarketResponse, + } as MsgCreateMarketResponse; + return message; + }, + + toJSON(_: MsgCreateMarketResponse): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial( + _: DeepPartial + ): MsgCreateMarketResponse { + const message = { + ...baseMsgCreateMarketResponse, + } as MsgCreateMarketResponse; + return message; + }, +}; + +const baseMsgCreateOrder: object = { + creator: "", + orderType: "", + amount: "", + price: "", + marketId: "", +}; + +export const MsgCreateOrder = { + encode(message: MsgCreateOrder, writer: Writer = Writer.create()): Writer { + if (message.creator !== "") { + writer.uint32(10).string(message.creator); + } + if (message.orderType !== "") { + writer.uint32(18).string(message.orderType); + } + if (message.amount !== "") { + writer.uint32(26).string(message.amount); + } + if (message.price !== "") { + writer.uint32(34).string(message.price); + } + if (message.marketId !== "") { + writer.uint32(42).string(message.marketId); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MsgCreateOrder { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgCreateOrder } as MsgCreateOrder; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.creator = reader.string(); + break; + case 2: + message.orderType = reader.string(); + break; + case 3: + message.amount = reader.string(); + break; + case 4: + message.price = reader.string(); + break; + case 5: + message.marketId = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgCreateOrder { + const message = { ...baseMsgCreateOrder } as MsgCreateOrder; + if (object.creator !== undefined && object.creator !== null) { + message.creator = String(object.creator); + } else { + message.creator = ""; + } + if (object.orderType !== undefined && object.orderType !== null) { + message.orderType = String(object.orderType); + } else { + message.orderType = ""; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = String(object.amount); + } else { + message.amount = ""; + } + if (object.price !== undefined && object.price !== null) { + message.price = String(object.price); + } else { + message.price = ""; + } + if (object.marketId !== undefined && object.marketId !== null) { + message.marketId = String(object.marketId); + } else { + message.marketId = ""; + } + return message; + }, + + toJSON(message: MsgCreateOrder): unknown { + const obj: any = {}; + message.creator !== undefined && (obj.creator = message.creator); + message.orderType !== undefined && (obj.orderType = message.orderType); + message.amount !== undefined && (obj.amount = message.amount); + message.price !== undefined && (obj.price = message.price); + message.marketId !== undefined && (obj.marketId = message.marketId); + return obj; + }, + + fromPartial(object: DeepPartial): MsgCreateOrder { + const message = { ...baseMsgCreateOrder } as MsgCreateOrder; + if (object.creator !== undefined && object.creator !== null) { + message.creator = object.creator; + } else { + message.creator = ""; + } + if (object.orderType !== undefined && object.orderType !== null) { + message.orderType = object.orderType; + } else { + message.orderType = ""; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = object.amount; + } else { + message.amount = ""; + } + if (object.price !== undefined && object.price !== null) { + message.price = object.price; + } else { + message.price = ""; + } + if (object.marketId !== undefined && object.marketId !== null) { + message.marketId = object.marketId; + } else { + message.marketId = ""; + } + return message; + }, +}; + +const baseMsgCreateOrderResponse: object = {}; + +export const MsgCreateOrderResponse = { + encode(_: MsgCreateOrderResponse, writer: Writer = Writer.create()): Writer { + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MsgCreateOrderResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgCreateOrderResponse } as MsgCreateOrderResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): MsgCreateOrderResponse { + const message = { ...baseMsgCreateOrderResponse } as MsgCreateOrderResponse; + return message; + }, + + toJSON(_: MsgCreateOrderResponse): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial(_: DeepPartial): MsgCreateOrderResponse { + const message = { ...baseMsgCreateOrderResponse } as MsgCreateOrderResponse; + return message; + }, +}; + +const baseMsgCancelOrder: object = { + creator: "", + marketId: "", + orderId: "", + orderType: "", +}; + +export const MsgCancelOrder = { + encode(message: MsgCancelOrder, writer: Writer = Writer.create()): Writer { + if (message.creator !== "") { + writer.uint32(10).string(message.creator); + } + if (message.marketId !== "") { + writer.uint32(18).string(message.marketId); + } + if (message.orderId !== "") { + writer.uint32(26).string(message.orderId); + } + if (message.orderType !== "") { + writer.uint32(34).string(message.orderType); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MsgCancelOrder { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgCancelOrder } as MsgCancelOrder; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.creator = reader.string(); + break; + case 2: + message.marketId = reader.string(); + break; + case 3: + message.orderId = reader.string(); + break; + case 4: + message.orderType = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgCancelOrder { + const message = { ...baseMsgCancelOrder } as MsgCancelOrder; + if (object.creator !== undefined && object.creator !== null) { + message.creator = String(object.creator); + } else { + message.creator = ""; + } + if (object.marketId !== undefined && object.marketId !== null) { + message.marketId = String(object.marketId); + } else { + message.marketId = ""; + } + if (object.orderId !== undefined && object.orderId !== null) { + message.orderId = String(object.orderId); + } else { + message.orderId = ""; + } + if (object.orderType !== undefined && object.orderType !== null) { + message.orderType = String(object.orderType); + } else { + message.orderType = ""; + } + return message; + }, + + toJSON(message: MsgCancelOrder): unknown { + const obj: any = {}; + message.creator !== undefined && (obj.creator = message.creator); + message.marketId !== undefined && (obj.marketId = message.marketId); + message.orderId !== undefined && (obj.orderId = message.orderId); + message.orderType !== undefined && (obj.orderType = message.orderType); + return obj; + }, + + fromPartial(object: DeepPartial): MsgCancelOrder { + const message = { ...baseMsgCancelOrder } as MsgCancelOrder; + if (object.creator !== undefined && object.creator !== null) { + message.creator = object.creator; + } else { + message.creator = ""; + } + if (object.marketId !== undefined && object.marketId !== null) { + message.marketId = object.marketId; + } else { + message.marketId = ""; + } + if (object.orderId !== undefined && object.orderId !== null) { + message.orderId = object.orderId; + } else { + message.orderId = ""; + } + if (object.orderType !== undefined && object.orderType !== null) { + message.orderType = object.orderType; + } else { + message.orderType = ""; + } + return message; + }, +}; + +const baseMsgCancelOrderResponse: object = {}; + +export const MsgCancelOrderResponse = { + encode(_: MsgCancelOrderResponse, writer: Writer = Writer.create()): Writer { + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MsgCancelOrderResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgCancelOrderResponse } as MsgCancelOrderResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): MsgCancelOrderResponse { + const message = { ...baseMsgCancelOrderResponse } as MsgCancelOrderResponse; + return message; + }, + + toJSON(_: MsgCancelOrderResponse): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial(_: DeepPartial): MsgCancelOrderResponse { + const message = { ...baseMsgCancelOrderResponse } as MsgCancelOrderResponse; + return message; + }, +}; + +/** Msg defines the Msg service. */ +export interface Msg { + CreateMarket(request: MsgCreateMarket): Promise; + CreateOrder(request: MsgCreateOrder): Promise; + /** this line is used by starport scaffolding # proto/tx/rpc */ + CancelOrder(request: MsgCancelOrder): Promise; +} + +export class MsgClientImpl implements Msg { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + } + CreateMarket(request: MsgCreateMarket): Promise { + const data = MsgCreateMarket.encode(request).finish(); + const promise = this.rpc.request( + "bze.tradebin.v1.Msg", + "CreateMarket", + data + ); + return promise.then((data) => + MsgCreateMarketResponse.decode(new Reader(data)) + ); + } + + CreateOrder(request: MsgCreateOrder): Promise { + const data = MsgCreateOrder.encode(request).finish(); + const promise = this.rpc.request( + "bze.tradebin.v1.Msg", + "CreateOrder", + data + ); + return promise.then((data) => + MsgCreateOrderResponse.decode(new Reader(data)) + ); + } + + CancelOrder(request: MsgCancelOrder): Promise { + const data = MsgCancelOrder.encode(request).finish(); + const promise = this.rpc.request( + "bze.tradebin.v1.Msg", + "CancelOrder", + data + ); + return promise.then((data) => + MsgCancelOrderResponse.decode(new Reader(data)) + ); + } +} + +interface Rpc { + request( + service: string, + method: string, + data: Uint8Array + ): Promise; +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/bze.v1.rewards/index.ts b/ts-client/bze.v1.rewards/index.ts new file mode 100755 index 00000000..c9dfa159 --- /dev/null +++ b/ts-client/bze.v1.rewards/index.ts @@ -0,0 +1,6 @@ +import Module from './module'; +import { txClient, queryClient, registry } from './module'; +import { msgTypes } from './registry'; + +export * from "./types"; +export { Module, msgTypes, txClient, queryClient, registry }; diff --git a/ts-client/bze.v1.rewards/module.ts b/ts-client/bze.v1.rewards/module.ts new file mode 100755 index 00000000..9430b054 --- /dev/null +++ b/ts-client/bze.v1.rewards/module.ts @@ -0,0 +1,264 @@ +// Generated by Ignite ignite.com/cli + +import { StdFee } from "@cosmjs/launchpad"; +import { SigningStargateClient, DeliverTxResponse } from "@cosmjs/stargate"; +import { EncodeObject, GeneratedType, OfflineSigner, Registry } from "@cosmjs/proto-signing"; +import { msgTypes } from './registry'; +import { IgniteClient } from "../client" +import { MissingWalletError } from "../helpers" +import { Api } from "./rest"; +import { MsgCreateStakingReward } from "./types/rewards/tx"; +import { MsgCreateTradingReward } from "./types/rewards/tx"; +import { MsgJoinStaking } from "./types/rewards/tx"; +import { MsgUpdateStakingReward } from "./types/rewards/tx"; +import { MsgClaimStakingRewards } from "./types/rewards/tx"; +import { MsgExitStaking } from "./types/rewards/tx"; + + +export { MsgCreateStakingReward, MsgCreateTradingReward, MsgJoinStaking, MsgUpdateStakingReward, MsgClaimStakingRewards, MsgExitStaking }; + +type sendMsgCreateStakingRewardParams = { + value: MsgCreateStakingReward, + fee?: StdFee, + memo?: string +}; + +type sendMsgCreateTradingRewardParams = { + value: MsgCreateTradingReward, + fee?: StdFee, + memo?: string +}; + +type sendMsgJoinStakingParams = { + value: MsgJoinStaking, + fee?: StdFee, + memo?: string +}; + +type sendMsgUpdateStakingRewardParams = { + value: MsgUpdateStakingReward, + fee?: StdFee, + memo?: string +}; + +type sendMsgClaimStakingRewardsParams = { + value: MsgClaimStakingRewards, + fee?: StdFee, + memo?: string +}; + +type sendMsgExitStakingParams = { + value: MsgExitStaking, + fee?: StdFee, + memo?: string +}; + + +type msgCreateStakingRewardParams = { + value: MsgCreateStakingReward, +}; + +type msgCreateTradingRewardParams = { + value: MsgCreateTradingReward, +}; + +type msgJoinStakingParams = { + value: MsgJoinStaking, +}; + +type msgUpdateStakingRewardParams = { + value: MsgUpdateStakingReward, +}; + +type msgClaimStakingRewardsParams = { + value: MsgClaimStakingRewards, +}; + +type msgExitStakingParams = { + value: MsgExitStaking, +}; + + +export const registry = new Registry(msgTypes); + +const defaultFee = { + amount: [], + gas: "200000", +}; + +interface TxClientOptions { + addr: string + prefix: string + signer?: OfflineSigner +} + +export const txClient = ({ signer, prefix, addr }: TxClientOptions = { addr: "http://localhost:26657", prefix: "cosmos" }) => { + + return { + + async sendMsgCreateStakingReward({ value, fee, memo }: sendMsgCreateStakingRewardParams): Promise { + if (!signer) { + throw new Error('TxClient:sendMsgCreateStakingReward: Unable to sign Tx. Signer is not present.') + } + try { + const { address } = (await signer.getAccounts())[0]; + const signingClient = await SigningStargateClient.connectWithSigner(addr,signer,{registry, prefix}); + let msg = this.msgCreateStakingReward({ value: MsgCreateStakingReward.fromPartial(value) }) + return await signingClient.signAndBroadcast(address, [msg], fee ? fee : defaultFee, memo) + } catch (e: any) { + throw new Error('TxClient:sendMsgCreateStakingReward: Could not broadcast Tx: '+ e.message) + } + }, + + async sendMsgCreateTradingReward({ value, fee, memo }: sendMsgCreateTradingRewardParams): Promise { + if (!signer) { + throw new Error('TxClient:sendMsgCreateTradingReward: Unable to sign Tx. Signer is not present.') + } + try { + const { address } = (await signer.getAccounts())[0]; + const signingClient = await SigningStargateClient.connectWithSigner(addr,signer,{registry, prefix}); + let msg = this.msgCreateTradingReward({ value: MsgCreateTradingReward.fromPartial(value) }) + return await signingClient.signAndBroadcast(address, [msg], fee ? fee : defaultFee, memo) + } catch (e: any) { + throw new Error('TxClient:sendMsgCreateTradingReward: Could not broadcast Tx: '+ e.message) + } + }, + + async sendMsgJoinStaking({ value, fee, memo }: sendMsgJoinStakingParams): Promise { + if (!signer) { + throw new Error('TxClient:sendMsgJoinStaking: Unable to sign Tx. Signer is not present.') + } + try { + const { address } = (await signer.getAccounts())[0]; + const signingClient = await SigningStargateClient.connectWithSigner(addr,signer,{registry, prefix}); + let msg = this.msgJoinStaking({ value: MsgJoinStaking.fromPartial(value) }) + return await signingClient.signAndBroadcast(address, [msg], fee ? fee : defaultFee, memo) + } catch (e: any) { + throw new Error('TxClient:sendMsgJoinStaking: Could not broadcast Tx: '+ e.message) + } + }, + + async sendMsgUpdateStakingReward({ value, fee, memo }: sendMsgUpdateStakingRewardParams): Promise { + if (!signer) { + throw new Error('TxClient:sendMsgUpdateStakingReward: Unable to sign Tx. Signer is not present.') + } + try { + const { address } = (await signer.getAccounts())[0]; + const signingClient = await SigningStargateClient.connectWithSigner(addr,signer,{registry, prefix}); + let msg = this.msgUpdateStakingReward({ value: MsgUpdateStakingReward.fromPartial(value) }) + return await signingClient.signAndBroadcast(address, [msg], fee ? fee : defaultFee, memo) + } catch (e: any) { + throw new Error('TxClient:sendMsgUpdateStakingReward: Could not broadcast Tx: '+ e.message) + } + }, + + async sendMsgClaimStakingRewards({ value, fee, memo }: sendMsgClaimStakingRewardsParams): Promise { + if (!signer) { + throw new Error('TxClient:sendMsgClaimStakingRewards: Unable to sign Tx. Signer is not present.') + } + try { + const { address } = (await signer.getAccounts())[0]; + const signingClient = await SigningStargateClient.connectWithSigner(addr,signer,{registry, prefix}); + let msg = this.msgClaimStakingRewards({ value: MsgClaimStakingRewards.fromPartial(value) }) + return await signingClient.signAndBroadcast(address, [msg], fee ? fee : defaultFee, memo) + } catch (e: any) { + throw new Error('TxClient:sendMsgClaimStakingRewards: Could not broadcast Tx: '+ e.message) + } + }, + + async sendMsgExitStaking({ value, fee, memo }: sendMsgExitStakingParams): Promise { + if (!signer) { + throw new Error('TxClient:sendMsgExitStaking: Unable to sign Tx. Signer is not present.') + } + try { + const { address } = (await signer.getAccounts())[0]; + const signingClient = await SigningStargateClient.connectWithSigner(addr,signer,{registry, prefix}); + let msg = this.msgExitStaking({ value: MsgExitStaking.fromPartial(value) }) + return await signingClient.signAndBroadcast(address, [msg], fee ? fee : defaultFee, memo) + } catch (e: any) { + throw new Error('TxClient:sendMsgExitStaking: Could not broadcast Tx: '+ e.message) + } + }, + + + msgCreateStakingReward({ value }: msgCreateStakingRewardParams): EncodeObject { + try { + return { typeUrl: "/bze.v1.rewards.MsgCreateStakingReward", value: MsgCreateStakingReward.fromPartial( value ) } + } catch (e: any) { + throw new Error('TxClient:MsgCreateStakingReward: Could not create message: ' + e.message) + } + }, + + msgCreateTradingReward({ value }: msgCreateTradingRewardParams): EncodeObject { + try { + return { typeUrl: "/bze.v1.rewards.MsgCreateTradingReward", value: MsgCreateTradingReward.fromPartial( value ) } + } catch (e: any) { + throw new Error('TxClient:MsgCreateTradingReward: Could not create message: ' + e.message) + } + }, + + msgJoinStaking({ value }: msgJoinStakingParams): EncodeObject { + try { + return { typeUrl: "/bze.v1.rewards.MsgJoinStaking", value: MsgJoinStaking.fromPartial( value ) } + } catch (e: any) { + throw new Error('TxClient:MsgJoinStaking: Could not create message: ' + e.message) + } + }, + + msgUpdateStakingReward({ value }: msgUpdateStakingRewardParams): EncodeObject { + try { + return { typeUrl: "/bze.v1.rewards.MsgUpdateStakingReward", value: MsgUpdateStakingReward.fromPartial( value ) } + } catch (e: any) { + throw new Error('TxClient:MsgUpdateStakingReward: Could not create message: ' + e.message) + } + }, + + msgClaimStakingRewards({ value }: msgClaimStakingRewardsParams): EncodeObject { + try { + return { typeUrl: "/bze.v1.rewards.MsgClaimStakingRewards", value: MsgClaimStakingRewards.fromPartial( value ) } + } catch (e: any) { + throw new Error('TxClient:MsgClaimStakingRewards: Could not create message: ' + e.message) + } + }, + + msgExitStaking({ value }: msgExitStakingParams): EncodeObject { + try { + return { typeUrl: "/bze.v1.rewards.MsgExitStaking", value: MsgExitStaking.fromPartial( value ) } + } catch (e: any) { + throw new Error('TxClient:MsgExitStaking: Could not create message: ' + e.message) + } + }, + + } +}; + +interface QueryClientOptions { + addr: string +} + +export const queryClient = ({ addr: addr }: QueryClientOptions = { addr: "http://localhost:1317" }) => { + return new Api({ baseUrl: addr }); +}; + +class SDKModule { + public query: ReturnType; + public tx: ReturnType; + + public registry: Array<[string, GeneratedType]>; + + constructor(client: IgniteClient) { + + this.query = queryClient({ addr: client.env.apiURL }); + this.tx = txClient({ signer: client.signer, addr: client.env.rpcURL, prefix: client.env.prefix ?? "cosmos" }); + } +}; + +const Module = (test: IgniteClient) => { + return { + module: { + BzeV1Rewards: new SDKModule(test) + }, + registry: msgTypes + } +} +export default Module; \ No newline at end of file diff --git a/ts-client/bze.v1.rewards/registry.ts b/ts-client/bze.v1.rewards/registry.ts new file mode 100755 index 00000000..c45e97bf --- /dev/null +++ b/ts-client/bze.v1.rewards/registry.ts @@ -0,0 +1,19 @@ +import { GeneratedType } from "@cosmjs/proto-signing"; +import { MsgCreateStakingReward } from "./types/rewards/tx"; +import { MsgCreateTradingReward } from "./types/rewards/tx"; +import { MsgJoinStaking } from "./types/rewards/tx"; +import { MsgUpdateStakingReward } from "./types/rewards/tx"; +import { MsgClaimStakingRewards } from "./types/rewards/tx"; +import { MsgExitStaking } from "./types/rewards/tx"; + +const msgTypes: Array<[string, GeneratedType]> = [ + ["/bze.v1.rewards.MsgCreateStakingReward", MsgCreateStakingReward], + ["/bze.v1.rewards.MsgCreateTradingReward", MsgCreateTradingReward], + ["/bze.v1.rewards.MsgJoinStaking", MsgJoinStaking], + ["/bze.v1.rewards.MsgUpdateStakingReward", MsgUpdateStakingReward], + ["/bze.v1.rewards.MsgClaimStakingRewards", MsgClaimStakingRewards], + ["/bze.v1.rewards.MsgExitStaking", MsgExitStaking], + +]; + +export { msgTypes } \ No newline at end of file diff --git a/ts-client/bze.v1.rewards/rest.ts b/ts-client/bze.v1.rewards/rest.ts new file mode 100644 index 00000000..6354c0d0 --- /dev/null +++ b/ts-client/bze.v1.rewards/rest.ts @@ -0,0 +1,580 @@ +/* eslint-disable */ +/* tslint:disable */ +/* + * --------------------------------------------------------------- + * ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ## + * ## ## + * ## AUTHOR: acacode ## + * ## SOURCE: https://github.com/acacode/swagger-typescript-api ## + * --------------------------------------------------------------- + */ + +export interface ProtobufAny { + "@type"?: string; +} + +export interface RewardsMsgClaimStakingRewardsResponse { + amount?: string; +} + +export interface RewardsMsgCreateStakingRewardResponse { + reward_id?: string; +} + +export interface RewardsMsgCreateTradingRewardResponse { + reward_id?: string; +} + +export type RewardsMsgExitStakingResponse = object; + +export type RewardsMsgJoinStakingResponse = object; + +export type RewardsMsgUpdateStakingRewardResponse = object; + +export interface RewardsQueryAllStakingRewardParticipantResponse { + list?: V1RewardsStakingRewardParticipant[]; + + /** + * PageResponse is to be embedded in gRPC response messages where the + * corresponding request message has used PageRequest. + * + * message SomeResponse { + * repeated Bar results = 1; + * PageResponse page = 2; + * } + */ + pagination?: V1Beta1PageResponse; +} + +export interface RewardsQueryAllStakingRewardResponse { + list?: V1RewardsStakingReward[]; + + /** + * PageResponse is to be embedded in gRPC response messages where the + * corresponding request message has used PageRequest. + * + * message SomeResponse { + * repeated Bar results = 1; + * PageResponse page = 2; + * } + */ + pagination?: V1Beta1PageResponse; +} + +export interface RewardsQueryAllTradingRewardResponse { + list?: V1RewardsTradingReward[]; + + /** + * PageResponse is to be embedded in gRPC response messages where the + * corresponding request message has used PageRequest. + * + * message SomeResponse { + * repeated Bar results = 1; + * PageResponse page = 2; + * } + */ + pagination?: V1Beta1PageResponse; +} + +export interface RewardsQueryGetStakingRewardParticipantResponse { + list?: V1RewardsStakingRewardParticipant[]; + + /** + * PageResponse is to be embedded in gRPC response messages where the + * corresponding request message has used PageRequest. + * + * message SomeResponse { + * repeated Bar results = 1; + * PageResponse page = 2; + * } + */ + pagination?: V1Beta1PageResponse; +} + +export interface RewardsQueryGetStakingRewardResponse { + staking_reward?: V1RewardsStakingReward; +} + +export interface RewardsQueryGetTradingRewardResponse { + trading_reward?: V1RewardsTradingReward; +} + +/** + * QueryParamsResponse is response type for the Query/Params RPC method. + */ +export interface RewardsQueryParamsResponse { + /** params holds all the parameters of this module. */ + params?: V1RewardsParams; +} + +export interface RpcStatus { + /** @format int32 */ + code?: number; + message?: string; + details?: ProtobufAny[]; +} + +/** +* message SomeRequest { + Foo some_parameter = 1; + PageRequest pagination = 2; + } +*/ +export interface V1Beta1PageRequest { + /** + * key is a value returned in PageResponse.next_key to begin + * querying the next page most efficiently. Only one of offset or key + * should be set. + * @format byte + */ + key?: string; + + /** + * offset is a numeric offset that can be used when key is unavailable. + * It is less efficient than using key. Only one of offset or key should + * be set. + * @format uint64 + */ + offset?: string; + + /** + * limit is the total number of results to be returned in the result page. + * If left empty it will default to a value to be set by each app. + * @format uint64 + */ + limit?: string; + + /** + * count_total is set to true to indicate that the result set should include + * a count of the total number of items available for pagination in UIs. + * count_total is only respected when offset is used. It is ignored when key + * is set. + */ + count_total?: boolean; + + /** + * reverse is set to true if results are to be returned in the descending order. + * + * Since: cosmos-sdk 0.43 + */ + reverse?: boolean; +} + +/** +* PageResponse is to be embedded in gRPC response messages where the +corresponding request message has used PageRequest. + + message SomeResponse { + repeated Bar results = 1; + PageResponse page = 2; + } +*/ +export interface V1Beta1PageResponse { + /** @format byte */ + next_key?: string; + + /** @format uint64 */ + total?: string; +} + +/** + * Params defines the parameters for the module. + */ +export interface V1RewardsParams { + createStakingRewardFee?: string; + createTradingRewardFee?: string; +} + +export interface V1RewardsStakingReward { + reward_id?: string; + prize_amount?: string; + prize_denom?: string; + staking_denom?: string; + + /** @format int64 */ + duration?: number; + + /** @format int64 */ + payouts?: number; + + /** @format uint64 */ + min_stake?: string; + + /** @format int64 */ + lock?: number; + staked_amount?: string; + distributed_stake?: string; +} + +export interface V1RewardsStakingRewardParticipant { + address?: string; + reward_id?: string; + amount?: string; + joined_at?: string; +} + +export interface V1RewardsTradingReward { + reward_id?: string; + prize_amount?: string; + prize_denom?: string; + + /** @format int64 */ + duration?: number; + market_id?: string; + + /** @format int64 */ + slots?: number; + + /** @format int64 */ + expire_at?: number; +} + +export type QueryParamsType = Record; +export type ResponseFormat = keyof Omit; + +export interface FullRequestParams extends Omit { + /** set parameter to `true` for call `securityWorker` for this request */ + secure?: boolean; + /** request path */ + path: string; + /** content type of request body */ + type?: ContentType; + /** query params */ + query?: QueryParamsType; + /** format of response (i.e. response.json() -> format: "json") */ + format?: keyof Omit; + /** request body */ + body?: unknown; + /** base url */ + baseUrl?: string; + /** request cancellation token */ + cancelToken?: CancelToken; +} + +export type RequestParams = Omit; + +export interface ApiConfig { + baseUrl?: string; + baseApiParams?: Omit; + securityWorker?: (securityData: SecurityDataType) => RequestParams | void; +} + +export interface HttpResponse extends Response { + data: D; + error: E; +} + +type CancelToken = Symbol | string | number; + +export enum ContentType { + Json = "application/json", + FormData = "multipart/form-data", + UrlEncoded = "application/x-www-form-urlencoded", +} + +export class HttpClient { + public baseUrl: string = ""; + private securityData: SecurityDataType = null as any; + private securityWorker: null | ApiConfig["securityWorker"] = null; + private abortControllers = new Map(); + + private baseApiParams: RequestParams = { + credentials: "same-origin", + headers: {}, + redirect: "follow", + referrerPolicy: "no-referrer", + }; + + constructor(apiConfig: ApiConfig = {}) { + Object.assign(this, apiConfig); + } + + public setSecurityData = (data: SecurityDataType) => { + this.securityData = data; + }; + + private addQueryParam(query: QueryParamsType, key: string) { + const value = query[key]; + + return ( + encodeURIComponent(key) + + "=" + + encodeURIComponent(Array.isArray(value) ? value.join(",") : typeof value === "number" ? value : `${value}`) + ); + } + + protected toQueryString(rawQuery?: QueryParamsType): string { + const query = rawQuery || {}; + const keys = Object.keys(query).filter((key) => "undefined" !== typeof query[key]); + return keys + .map((key) => + typeof query[key] === "object" && !Array.isArray(query[key]) + ? this.toQueryString(query[key] as QueryParamsType) + : this.addQueryParam(query, key), + ) + .join("&"); + } + + protected addQueryParams(rawQuery?: QueryParamsType): string { + const queryString = this.toQueryString(rawQuery); + return queryString ? `?${queryString}` : ""; + } + + private contentFormatters: Record any> = { + [ContentType.Json]: (input: any) => + input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input, + [ContentType.FormData]: (input: any) => + Object.keys(input || {}).reduce((data, key) => { + data.append(key, input[key]); + return data; + }, new FormData()), + [ContentType.UrlEncoded]: (input: any) => this.toQueryString(input), + }; + + private mergeRequestParams(params1: RequestParams, params2?: RequestParams): RequestParams { + return { + ...this.baseApiParams, + ...params1, + ...(params2 || {}), + headers: { + ...(this.baseApiParams.headers || {}), + ...(params1.headers || {}), + ...((params2 && params2.headers) || {}), + }, + }; + } + + private createAbortSignal = (cancelToken: CancelToken): AbortSignal | undefined => { + if (this.abortControllers.has(cancelToken)) { + const abortController = this.abortControllers.get(cancelToken); + if (abortController) { + return abortController.signal; + } + return void 0; + } + + const abortController = new AbortController(); + this.abortControllers.set(cancelToken, abortController); + return abortController.signal; + }; + + public abortRequest = (cancelToken: CancelToken) => { + const abortController = this.abortControllers.get(cancelToken); + + if (abortController) { + abortController.abort(); + this.abortControllers.delete(cancelToken); + } + }; + + public request = ({ + body, + secure, + path, + type, + query, + format = "json", + baseUrl, + cancelToken, + ...params + }: FullRequestParams): Promise> => { + const secureParams = (secure && this.securityWorker && this.securityWorker(this.securityData)) || {}; + const requestParams = this.mergeRequestParams(params, secureParams); + const queryString = query && this.toQueryString(query); + const payloadFormatter = this.contentFormatters[type || ContentType.Json]; + + return fetch(`${baseUrl || this.baseUrl || ""}${path}${queryString ? `?${queryString}` : ""}`, { + ...requestParams, + headers: { + ...(type && type !== ContentType.FormData ? { "Content-Type": type } : {}), + ...(requestParams.headers || {}), + }, + signal: cancelToken ? this.createAbortSignal(cancelToken) : void 0, + body: typeof body === "undefined" || body === null ? null : payloadFormatter(body), + }).then(async (response) => { + const r = response as HttpResponse; + r.data = (null as unknown) as T; + r.error = (null as unknown) as E; + + const data = await response[format]() + .then((data) => { + if (r.ok) { + r.data = data; + } else { + r.error = data; + } + return r; + }) + .catch((e) => { + r.error = e; + return r; + }); + + if (cancelToken) { + this.abortControllers.delete(cancelToken); + } + + if (!response.ok) throw data; + return data; + }); + }; +} + +/** + * @title rewards/events.proto + * @version version not set + */ +export class Api extends HttpClient { + /** + * No description + * + * @tags Query + * @name QueryParams + * @summary Parameters queries the parameters of the module. + * @request GET:/bze/rewards/v1/params + */ + queryParams = (params: RequestParams = {}) => + this.request({ + path: `/bze/rewards/v1/params`, + method: "GET", + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Query + * @name QueryStakingRewardAll + * @summary Queries a list of StakingReward items. + * @request GET:/bze/rewards/v1/staking_reward + */ + queryStakingRewardAll = ( + query?: { + "pagination.key"?: string; + "pagination.offset"?: string; + "pagination.limit"?: string; + "pagination.count_total"?: boolean; + "pagination.reverse"?: boolean; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/bze/rewards/v1/staking_reward`, + method: "GET", + query: query, + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Query + * @name QueryStakingReward + * @summary Queries a StakingReward by index. + * @request GET:/bze/rewards/v1/staking_reward/{reward_id} + */ + queryStakingReward = (reward_id: string, params: RequestParams = {}) => + this.request({ + path: `/bze/rewards/v1/staking_reward/${reward_id}`, + method: "GET", + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Query + * @name QueryStakingRewardParticipant + * @summary Queries a StakingRewardParticipant by index. + * @request GET:/bze/rewards/v1/staking_reward_participant/{address} + */ + queryStakingRewardParticipant = ( + address: string, + query?: { + "pagination.key"?: string; + "pagination.offset"?: string; + "pagination.limit"?: string; + "pagination.count_total"?: boolean; + "pagination.reverse"?: boolean; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/bze/rewards/v1/staking_reward_participant/${address}`, + method: "GET", + query: query, + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Query + * @name QueryStakingRewardParticipantAll + * @summary Queries a list of StakingRewardParticipant items. + * @request GET:/bze/rewards/v1/staking_reward_participants + */ + queryStakingRewardParticipantAll = ( + query?: { + "pagination.key"?: string; + "pagination.offset"?: string; + "pagination.limit"?: string; + "pagination.count_total"?: boolean; + "pagination.reverse"?: boolean; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/bze/rewards/v1/staking_reward_participants`, + method: "GET", + query: query, + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Query + * @name QueryTradingRewardAll + * @summary Queries a list of TradingReward items. + * @request GET:/bze/rewards/v1/trading_reward + */ + queryTradingRewardAll = ( + query?: { + "pagination.key"?: string; + "pagination.offset"?: string; + "pagination.limit"?: string; + "pagination.count_total"?: boolean; + "pagination.reverse"?: boolean; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/bze/rewards/v1/trading_reward`, + method: "GET", + query: query, + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Query + * @name QueryTradingReward + * @summary Queries a TradingReward by index. + * @request GET:/bze/rewards/v1/trading_reward/{reward_id} + */ + queryTradingReward = (reward_id: string, params: RequestParams = {}) => + this.request({ + path: `/bze/rewards/v1/trading_reward/${reward_id}`, + method: "GET", + format: "json", + ...params, + }); +} diff --git a/ts-client/bze.v1.rewards/types.ts b/ts-client/bze.v1.rewards/types.ts new file mode 100755 index 00000000..157cb5ba --- /dev/null +++ b/ts-client/bze.v1.rewards/types.ts @@ -0,0 +1,25 @@ +import { Params } from "./types/rewards/params" +import { StakingReward } from "./types/rewards/staking_reward" +import { StakingRewardParticipant } from "./types/rewards/staking_reward_participant" +import { PendingUnlockParticipant } from "./types/rewards/staking_reward_participant" +import { TradingReward } from "./types/rewards/trading_reward" +import { TradingRewardExpiration } from "./types/rewards/trading_reward" +import { TradingRewardLeaderboard } from "./types/rewards/trading_reward" +import { TradingRewardLeaderboardEntry } from "./types/rewards/trading_reward" +import { TradingRewardCandidate } from "./types/rewards/trading_reward" +import { MarketIdTradingRewardId } from "./types/rewards/trading_reward" + + +export { + Params, + StakingReward, + StakingRewardParticipant, + PendingUnlockParticipant, + TradingReward, + TradingRewardExpiration, + TradingRewardLeaderboard, + TradingRewardLeaderboardEntry, + TradingRewardCandidate, + MarketIdTradingRewardId, + + } \ No newline at end of file diff --git a/ts-client/bze.v1.rewards/types/cosmos/base/query/v1beta1/pagination.ts b/ts-client/bze.v1.rewards/types/cosmos/base/query/v1beta1/pagination.ts new file mode 100644 index 00000000..cd4b2d78 --- /dev/null +++ b/ts-client/bze.v1.rewards/types/cosmos/base/query/v1beta1/pagination.ts @@ -0,0 +1,327 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "cosmos.base.query.v1beta1"; + +/** + * PageRequest is to be embedded in gRPC request messages for efficient + * pagination. Ex: + * + * message SomeRequest { + * Foo some_parameter = 1; + * PageRequest pagination = 2; + * } + */ +export interface PageRequest { + /** + * key is a value returned in PageResponse.next_key to begin + * querying the next page most efficiently. Only one of offset or key + * should be set. + */ + key: Uint8Array; + /** + * offset is a numeric offset that can be used when key is unavailable. + * It is less efficient than using key. Only one of offset or key should + * be set. + */ + offset: number; + /** + * limit is the total number of results to be returned in the result page. + * If left empty it will default to a value to be set by each app. + */ + limit: number; + /** + * count_total is set to true to indicate that the result set should include + * a count of the total number of items available for pagination in UIs. + * count_total is only respected when offset is used. It is ignored when key + * is set. + */ + countTotal: boolean; + /** + * reverse is set to true if results are to be returned in the descending order. + * + * Since: cosmos-sdk 0.43 + */ + reverse: boolean; +} + +/** + * PageResponse is to be embedded in gRPC response messages where the + * corresponding request message has used PageRequest. + * + * message SomeResponse { + * repeated Bar results = 1; + * PageResponse page = 2; + * } + */ +export interface PageResponse { + /** + * next_key is the key to be passed to PageRequest.key to + * query the next page most efficiently + */ + nextKey: Uint8Array; + /** + * total is total number of results available if PageRequest.count_total + * was set, its value is undefined otherwise + */ + total: number; +} + +const basePageRequest: object = { + offset: 0, + limit: 0, + countTotal: false, + reverse: false, +}; + +export const PageRequest = { + encode(message: PageRequest, writer: Writer = Writer.create()): Writer { + if (message.key.length !== 0) { + writer.uint32(10).bytes(message.key); + } + if (message.offset !== 0) { + writer.uint32(16).uint64(message.offset); + } + if (message.limit !== 0) { + writer.uint32(24).uint64(message.limit); + } + if (message.countTotal === true) { + writer.uint32(32).bool(message.countTotal); + } + if (message.reverse === true) { + writer.uint32(40).bool(message.reverse); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): PageRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...basePageRequest } as PageRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.key = reader.bytes(); + break; + case 2: + message.offset = longToNumber(reader.uint64() as Long); + break; + case 3: + message.limit = longToNumber(reader.uint64() as Long); + break; + case 4: + message.countTotal = reader.bool(); + break; + case 5: + message.reverse = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): PageRequest { + const message = { ...basePageRequest } as PageRequest; + if (object.key !== undefined && object.key !== null) { + message.key = bytesFromBase64(object.key); + } + if (object.offset !== undefined && object.offset !== null) { + message.offset = Number(object.offset); + } else { + message.offset = 0; + } + if (object.limit !== undefined && object.limit !== null) { + message.limit = Number(object.limit); + } else { + message.limit = 0; + } + if (object.countTotal !== undefined && object.countTotal !== null) { + message.countTotal = Boolean(object.countTotal); + } else { + message.countTotal = false; + } + if (object.reverse !== undefined && object.reverse !== null) { + message.reverse = Boolean(object.reverse); + } else { + message.reverse = false; + } + return message; + }, + + toJSON(message: PageRequest): unknown { + const obj: any = {}; + message.key !== undefined && + (obj.key = base64FromBytes( + message.key !== undefined ? message.key : new Uint8Array() + )); + message.offset !== undefined && (obj.offset = message.offset); + message.limit !== undefined && (obj.limit = message.limit); + message.countTotal !== undefined && (obj.countTotal = message.countTotal); + message.reverse !== undefined && (obj.reverse = message.reverse); + return obj; + }, + + fromPartial(object: DeepPartial): PageRequest { + const message = { ...basePageRequest } as PageRequest; + if (object.key !== undefined && object.key !== null) { + message.key = object.key; + } else { + message.key = new Uint8Array(); + } + if (object.offset !== undefined && object.offset !== null) { + message.offset = object.offset; + } else { + message.offset = 0; + } + if (object.limit !== undefined && object.limit !== null) { + message.limit = object.limit; + } else { + message.limit = 0; + } + if (object.countTotal !== undefined && object.countTotal !== null) { + message.countTotal = object.countTotal; + } else { + message.countTotal = false; + } + if (object.reverse !== undefined && object.reverse !== null) { + message.reverse = object.reverse; + } else { + message.reverse = false; + } + return message; + }, +}; + +const basePageResponse: object = { total: 0 }; + +export const PageResponse = { + encode(message: PageResponse, writer: Writer = Writer.create()): Writer { + if (message.nextKey.length !== 0) { + writer.uint32(10).bytes(message.nextKey); + } + if (message.total !== 0) { + writer.uint32(16).uint64(message.total); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): PageResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...basePageResponse } as PageResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.nextKey = reader.bytes(); + break; + case 2: + message.total = longToNumber(reader.uint64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): PageResponse { + const message = { ...basePageResponse } as PageResponse; + if (object.nextKey !== undefined && object.nextKey !== null) { + message.nextKey = bytesFromBase64(object.nextKey); + } + if (object.total !== undefined && object.total !== null) { + message.total = Number(object.total); + } else { + message.total = 0; + } + return message; + }, + + toJSON(message: PageResponse): unknown { + const obj: any = {}; + message.nextKey !== undefined && + (obj.nextKey = base64FromBytes( + message.nextKey !== undefined ? message.nextKey : new Uint8Array() + )); + message.total !== undefined && (obj.total = message.total); + return obj; + }, + + fromPartial(object: DeepPartial): PageResponse { + const message = { ...basePageResponse } as PageResponse; + if (object.nextKey !== undefined && object.nextKey !== null) { + message.nextKey = object.nextKey; + } else { + message.nextKey = new Uint8Array(); + } + if (object.total !== undefined && object.total !== null) { + message.total = object.total; + } else { + message.total = 0; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/bze.v1.rewards/types/gogoproto/gogo.ts b/ts-client/bze.v1.rewards/types/gogoproto/gogo.ts new file mode 100644 index 00000000..3f41a047 --- /dev/null +++ b/ts-client/bze.v1.rewards/types/gogoproto/gogo.ts @@ -0,0 +1,2 @@ +/* eslint-disable */ +export const protobufPackage = "gogoproto"; diff --git a/ts-client/bze.v1.rewards/types/google/api/annotations.ts b/ts-client/bze.v1.rewards/types/google/api/annotations.ts new file mode 100644 index 00000000..aace4787 --- /dev/null +++ b/ts-client/bze.v1.rewards/types/google/api/annotations.ts @@ -0,0 +1,2 @@ +/* eslint-disable */ +export const protobufPackage = "google.api"; diff --git a/ts-client/bze.v1.rewards/types/google/api/http.ts b/ts-client/bze.v1.rewards/types/google/api/http.ts new file mode 100644 index 00000000..ddc00f8b --- /dev/null +++ b/ts-client/bze.v1.rewards/types/google/api/http.ts @@ -0,0 +1,705 @@ +/* eslint-disable */ +import { Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "google.api"; + +/** + * Defines the HTTP configuration for an API service. It contains a list of + * [HttpRule][google.api.HttpRule], each specifying the mapping of an RPC method + * to one or more HTTP REST API methods. + */ +export interface Http { + /** + * A list of HTTP configuration rules that apply to individual API methods. + * + * **NOTE:** All service configuration rules follow "last one wins" order. + */ + rules: HttpRule[]; + /** + * When set to true, URL path parmeters will be fully URI-decoded except in + * cases of single segment matches in reserved expansion, where "%2F" will be + * left encoded. + * + * The default behavior is to not decode RFC 6570 reserved characters in multi + * segment matches. + */ + fullyDecodeReservedExpansion: boolean; +} + +/** + * `HttpRule` defines the mapping of an RPC method to one or more HTTP + * REST API methods. The mapping specifies how different portions of the RPC + * request message are mapped to URL path, URL query parameters, and + * HTTP request body. The mapping is typically specified as an + * `google.api.http` annotation on the RPC method, + * see "google/api/annotations.proto" for details. + * + * The mapping consists of a field specifying the path template and + * method kind. The path template can refer to fields in the request + * message, as in the example below which describes a REST GET + * operation on a resource collection of messages: + * + * + * service Messaging { + * rpc GetMessage(GetMessageRequest) returns (Message) { + * option (google.api.http).get = "/v1/messages/{message_id}/{sub.subfield}"; + * } + * } + * message GetMessageRequest { + * message SubMessage { + * string subfield = 1; + * } + * string message_id = 1; // mapped to the URL + * SubMessage sub = 2; // `sub.subfield` is url-mapped + * } + * message Message { + * string text = 1; // content of the resource + * } + * + * The same http annotation can alternatively be expressed inside the + * `GRPC API Configuration` YAML file. + * + * http: + * rules: + * - selector: .Messaging.GetMessage + * get: /v1/messages/{message_id}/{sub.subfield} + * + * This definition enables an automatic, bidrectional mapping of HTTP + * JSON to RPC. Example: + * + * HTTP | RPC + * -----|----- + * `GET /v1/messages/123456/foo` | `GetMessage(message_id: "123456" sub: SubMessage(subfield: "foo"))` + * + * In general, not only fields but also field paths can be referenced + * from a path pattern. Fields mapped to the path pattern cannot be + * repeated and must have a primitive (non-message) type. + * + * Any fields in the request message which are not bound by the path + * pattern automatically become (optional) HTTP query + * parameters. Assume the following definition of the request message: + * + * + * service Messaging { + * rpc GetMessage(GetMessageRequest) returns (Message) { + * option (google.api.http).get = "/v1/messages/{message_id}"; + * } + * } + * message GetMessageRequest { + * message SubMessage { + * string subfield = 1; + * } + * string message_id = 1; // mapped to the URL + * int64 revision = 2; // becomes a parameter + * SubMessage sub = 3; // `sub.subfield` becomes a parameter + * } + * + * + * This enables a HTTP JSON to RPC mapping as below: + * + * HTTP | RPC + * -----|----- + * `GET /v1/messages/123456?revision=2&sub.subfield=foo` | `GetMessage(message_id: "123456" revision: 2 sub: SubMessage(subfield: "foo"))` + * + * Note that fields which are mapped to HTTP parameters must have a + * primitive type or a repeated primitive type. Message types are not + * allowed. In the case of a repeated type, the parameter can be + * repeated in the URL, as in `...?param=A¶m=B`. + * + * For HTTP method kinds which allow a request body, the `body` field + * specifies the mapping. Consider a REST update method on the + * message resource collection: + * + * + * service Messaging { + * rpc UpdateMessage(UpdateMessageRequest) returns (Message) { + * option (google.api.http) = { + * put: "/v1/messages/{message_id}" + * body: "message" + * }; + * } + * } + * message UpdateMessageRequest { + * string message_id = 1; // mapped to the URL + * Message message = 2; // mapped to the body + * } + * + * + * The following HTTP JSON to RPC mapping is enabled, where the + * representation of the JSON in the request body is determined by + * protos JSON encoding: + * + * HTTP | RPC + * -----|----- + * `PUT /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: "123456" message { text: "Hi!" })` + * + * The special name `*` can be used in the body mapping to define that + * every field not bound by the path template should be mapped to the + * request body. This enables the following alternative definition of + * the update method: + * + * service Messaging { + * rpc UpdateMessage(Message) returns (Message) { + * option (google.api.http) = { + * put: "/v1/messages/{message_id}" + * body: "*" + * }; + * } + * } + * message Message { + * string message_id = 1; + * string text = 2; + * } + * + * + * The following HTTP JSON to RPC mapping is enabled: + * + * HTTP | RPC + * -----|----- + * `PUT /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: "123456" text: "Hi!")` + * + * Note that when using `*` in the body mapping, it is not possible to + * have HTTP parameters, as all fields not bound by the path end in + * the body. This makes this option more rarely used in practice of + * defining REST APIs. The common usage of `*` is in custom methods + * which don't use the URL at all for transferring data. + * + * It is possible to define multiple HTTP methods for one RPC by using + * the `additional_bindings` option. Example: + * + * service Messaging { + * rpc GetMessage(GetMessageRequest) returns (Message) { + * option (google.api.http) = { + * get: "/v1/messages/{message_id}" + * additional_bindings { + * get: "/v1/users/{user_id}/messages/{message_id}" + * } + * }; + * } + * } + * message GetMessageRequest { + * string message_id = 1; + * string user_id = 2; + * } + * + * + * This enables the following two alternative HTTP JSON to RPC + * mappings: + * + * HTTP | RPC + * -----|----- + * `GET /v1/messages/123456` | `GetMessage(message_id: "123456")` + * `GET /v1/users/me/messages/123456` | `GetMessage(user_id: "me" message_id: "123456")` + * + * # Rules for HTTP mapping + * + * The rules for mapping HTTP path, query parameters, and body fields + * to the request message are as follows: + * + * 1. The `body` field specifies either `*` or a field path, or is + * omitted. If omitted, it indicates there is no HTTP request body. + * 2. Leaf fields (recursive expansion of nested messages in the + * request) can be classified into three types: + * (a) Matched in the URL template. + * (b) Covered by body (if body is `*`, everything except (a) fields; + * else everything under the body field) + * (c) All other fields. + * 3. URL query parameters found in the HTTP request are mapped to (c) fields. + * 4. Any body sent with an HTTP request can contain only (b) fields. + * + * The syntax of the path template is as follows: + * + * Template = "/" Segments [ Verb ] ; + * Segments = Segment { "/" Segment } ; + * Segment = "*" | "**" | LITERAL | Variable ; + * Variable = "{" FieldPath [ "=" Segments ] "}" ; + * FieldPath = IDENT { "." IDENT } ; + * Verb = ":" LITERAL ; + * + * The syntax `*` matches a single path segment. The syntax `**` matches zero + * or more path segments, which must be the last part of the path except the + * `Verb`. The syntax `LITERAL` matches literal text in the path. + * + * The syntax `Variable` matches part of the URL path as specified by its + * template. A variable template must not contain other variables. If a variable + * matches a single path segment, its template may be omitted, e.g. `{var}` + * is equivalent to `{var=*}`. + * + * If a variable contains exactly one path segment, such as `"{var}"` or + * `"{var=*}"`, when such a variable is expanded into a URL path, all characters + * except `[-_.~0-9a-zA-Z]` are percent-encoded. Such variables show up in the + * Discovery Document as `{var}`. + * + * If a variable contains one or more path segments, such as `"{var=foo/*}"` + * or `"{var=**}"`, when such a variable is expanded into a URL path, all + * characters except `[-_.~/0-9a-zA-Z]` are percent-encoded. Such variables + * show up in the Discovery Document as `{+var}`. + * + * NOTE: While the single segment variable matches the semantics of + * [RFC 6570](https://tools.ietf.org/html/rfc6570) Section 3.2.2 + * Simple String Expansion, the multi segment variable **does not** match + * RFC 6570 Reserved Expansion. The reason is that the Reserved Expansion + * does not expand special characters like `?` and `#`, which would lead + * to invalid URLs. + * + * NOTE: the field paths in variables and in the `body` must not refer to + * repeated fields or map fields. + */ +export interface HttpRule { + /** + * Selects methods to which this rule applies. + * + * Refer to [selector][google.api.DocumentationRule.selector] for syntax details. + */ + selector: string; + /** Used for listing and getting information about resources. */ + get: string | undefined; + /** Used for updating a resource. */ + put: string | undefined; + /** Used for creating a resource. */ + post: string | undefined; + /** Used for deleting a resource. */ + delete: string | undefined; + /** Used for updating a resource. */ + patch: string | undefined; + /** + * The custom pattern is used for specifying an HTTP method that is not + * included in the `pattern` field, such as HEAD, or "*" to leave the + * HTTP method unspecified for this rule. The wild-card rule is useful + * for services that provide content to Web (HTML) clients. + */ + custom: CustomHttpPattern | undefined; + /** + * The name of the request field whose value is mapped to the HTTP body, or + * `*` for mapping all fields not captured by the path pattern to the HTTP + * body. NOTE: the referred field must not be a repeated field and must be + * present at the top-level of request message type. + */ + body: string; + /** + * Optional. The name of the response field whose value is mapped to the HTTP + * body of response. Other response fields are ignored. When + * not set, the response message will be used as HTTP body of response. + */ + responseBody: string; + /** + * Additional HTTP bindings for the selector. Nested bindings must + * not contain an `additional_bindings` field themselves (that is, + * the nesting may only be one level deep). + */ + additionalBindings: HttpRule[]; +} + +/** A custom pattern is used for defining custom HTTP verb. */ +export interface CustomHttpPattern { + /** The name of this custom HTTP verb. */ + kind: string; + /** The path matched by this custom verb. */ + path: string; +} + +const baseHttp: object = { fullyDecodeReservedExpansion: false }; + +export const Http = { + encode(message: Http, writer: Writer = Writer.create()): Writer { + for (const v of message.rules) { + HttpRule.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.fullyDecodeReservedExpansion === true) { + writer.uint32(16).bool(message.fullyDecodeReservedExpansion); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Http { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseHttp } as Http; + message.rules = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.rules.push(HttpRule.decode(reader, reader.uint32())); + break; + case 2: + message.fullyDecodeReservedExpansion = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Http { + const message = { ...baseHttp } as Http; + message.rules = []; + if (object.rules !== undefined && object.rules !== null) { + for (const e of object.rules) { + message.rules.push(HttpRule.fromJSON(e)); + } + } + if ( + object.fullyDecodeReservedExpansion !== undefined && + object.fullyDecodeReservedExpansion !== null + ) { + message.fullyDecodeReservedExpansion = Boolean( + object.fullyDecodeReservedExpansion + ); + } else { + message.fullyDecodeReservedExpansion = false; + } + return message; + }, + + toJSON(message: Http): unknown { + const obj: any = {}; + if (message.rules) { + obj.rules = message.rules.map((e) => + e ? HttpRule.toJSON(e) : undefined + ); + } else { + obj.rules = []; + } + message.fullyDecodeReservedExpansion !== undefined && + (obj.fullyDecodeReservedExpansion = message.fullyDecodeReservedExpansion); + return obj; + }, + + fromPartial(object: DeepPartial): Http { + const message = { ...baseHttp } as Http; + message.rules = []; + if (object.rules !== undefined && object.rules !== null) { + for (const e of object.rules) { + message.rules.push(HttpRule.fromPartial(e)); + } + } + if ( + object.fullyDecodeReservedExpansion !== undefined && + object.fullyDecodeReservedExpansion !== null + ) { + message.fullyDecodeReservedExpansion = + object.fullyDecodeReservedExpansion; + } else { + message.fullyDecodeReservedExpansion = false; + } + return message; + }, +}; + +const baseHttpRule: object = { selector: "", body: "", responseBody: "" }; + +export const HttpRule = { + encode(message: HttpRule, writer: Writer = Writer.create()): Writer { + if (message.selector !== "") { + writer.uint32(10).string(message.selector); + } + if (message.get !== undefined) { + writer.uint32(18).string(message.get); + } + if (message.put !== undefined) { + writer.uint32(26).string(message.put); + } + if (message.post !== undefined) { + writer.uint32(34).string(message.post); + } + if (message.delete !== undefined) { + writer.uint32(42).string(message.delete); + } + if (message.patch !== undefined) { + writer.uint32(50).string(message.patch); + } + if (message.custom !== undefined) { + CustomHttpPattern.encode( + message.custom, + writer.uint32(66).fork() + ).ldelim(); + } + if (message.body !== "") { + writer.uint32(58).string(message.body); + } + if (message.responseBody !== "") { + writer.uint32(98).string(message.responseBody); + } + for (const v of message.additionalBindings) { + HttpRule.encode(v!, writer.uint32(90).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): HttpRule { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseHttpRule } as HttpRule; + message.additionalBindings = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.selector = reader.string(); + break; + case 2: + message.get = reader.string(); + break; + case 3: + message.put = reader.string(); + break; + case 4: + message.post = reader.string(); + break; + case 5: + message.delete = reader.string(); + break; + case 6: + message.patch = reader.string(); + break; + case 8: + message.custom = CustomHttpPattern.decode(reader, reader.uint32()); + break; + case 7: + message.body = reader.string(); + break; + case 12: + message.responseBody = reader.string(); + break; + case 11: + message.additionalBindings.push( + HttpRule.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): HttpRule { + const message = { ...baseHttpRule } as HttpRule; + message.additionalBindings = []; + if (object.selector !== undefined && object.selector !== null) { + message.selector = String(object.selector); + } else { + message.selector = ""; + } + if (object.get !== undefined && object.get !== null) { + message.get = String(object.get); + } else { + message.get = undefined; + } + if (object.put !== undefined && object.put !== null) { + message.put = String(object.put); + } else { + message.put = undefined; + } + if (object.post !== undefined && object.post !== null) { + message.post = String(object.post); + } else { + message.post = undefined; + } + if (object.delete !== undefined && object.delete !== null) { + message.delete = String(object.delete); + } else { + message.delete = undefined; + } + if (object.patch !== undefined && object.patch !== null) { + message.patch = String(object.patch); + } else { + message.patch = undefined; + } + if (object.custom !== undefined && object.custom !== null) { + message.custom = CustomHttpPattern.fromJSON(object.custom); + } else { + message.custom = undefined; + } + if (object.body !== undefined && object.body !== null) { + message.body = String(object.body); + } else { + message.body = ""; + } + if (object.responseBody !== undefined && object.responseBody !== null) { + message.responseBody = String(object.responseBody); + } else { + message.responseBody = ""; + } + if ( + object.additionalBindings !== undefined && + object.additionalBindings !== null + ) { + for (const e of object.additionalBindings) { + message.additionalBindings.push(HttpRule.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: HttpRule): unknown { + const obj: any = {}; + message.selector !== undefined && (obj.selector = message.selector); + message.get !== undefined && (obj.get = message.get); + message.put !== undefined && (obj.put = message.put); + message.post !== undefined && (obj.post = message.post); + message.delete !== undefined && (obj.delete = message.delete); + message.patch !== undefined && (obj.patch = message.patch); + message.custom !== undefined && + (obj.custom = message.custom + ? CustomHttpPattern.toJSON(message.custom) + : undefined); + message.body !== undefined && (obj.body = message.body); + message.responseBody !== undefined && + (obj.responseBody = message.responseBody); + if (message.additionalBindings) { + obj.additionalBindings = message.additionalBindings.map((e) => + e ? HttpRule.toJSON(e) : undefined + ); + } else { + obj.additionalBindings = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): HttpRule { + const message = { ...baseHttpRule } as HttpRule; + message.additionalBindings = []; + if (object.selector !== undefined && object.selector !== null) { + message.selector = object.selector; + } else { + message.selector = ""; + } + if (object.get !== undefined && object.get !== null) { + message.get = object.get; + } else { + message.get = undefined; + } + if (object.put !== undefined && object.put !== null) { + message.put = object.put; + } else { + message.put = undefined; + } + if (object.post !== undefined && object.post !== null) { + message.post = object.post; + } else { + message.post = undefined; + } + if (object.delete !== undefined && object.delete !== null) { + message.delete = object.delete; + } else { + message.delete = undefined; + } + if (object.patch !== undefined && object.patch !== null) { + message.patch = object.patch; + } else { + message.patch = undefined; + } + if (object.custom !== undefined && object.custom !== null) { + message.custom = CustomHttpPattern.fromPartial(object.custom); + } else { + message.custom = undefined; + } + if (object.body !== undefined && object.body !== null) { + message.body = object.body; + } else { + message.body = ""; + } + if (object.responseBody !== undefined && object.responseBody !== null) { + message.responseBody = object.responseBody; + } else { + message.responseBody = ""; + } + if ( + object.additionalBindings !== undefined && + object.additionalBindings !== null + ) { + for (const e of object.additionalBindings) { + message.additionalBindings.push(HttpRule.fromPartial(e)); + } + } + return message; + }, +}; + +const baseCustomHttpPattern: object = { kind: "", path: "" }; + +export const CustomHttpPattern = { + encode(message: CustomHttpPattern, writer: Writer = Writer.create()): Writer { + if (message.kind !== "") { + writer.uint32(10).string(message.kind); + } + if (message.path !== "") { + writer.uint32(18).string(message.path); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): CustomHttpPattern { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseCustomHttpPattern } as CustomHttpPattern; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.kind = reader.string(); + break; + case 2: + message.path = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): CustomHttpPattern { + const message = { ...baseCustomHttpPattern } as CustomHttpPattern; + if (object.kind !== undefined && object.kind !== null) { + message.kind = String(object.kind); + } else { + message.kind = ""; + } + if (object.path !== undefined && object.path !== null) { + message.path = String(object.path); + } else { + message.path = ""; + } + return message; + }, + + toJSON(message: CustomHttpPattern): unknown { + const obj: any = {}; + message.kind !== undefined && (obj.kind = message.kind); + message.path !== undefined && (obj.path = message.path); + return obj; + }, + + fromPartial(object: DeepPartial): CustomHttpPattern { + const message = { ...baseCustomHttpPattern } as CustomHttpPattern; + if (object.kind !== undefined && object.kind !== null) { + message.kind = object.kind; + } else { + message.kind = ""; + } + if (object.path !== undefined && object.path !== null) { + message.path = object.path; + } else { + message.path = ""; + } + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/bze.v1.rewards/types/google/protobuf/descriptor.ts b/ts-client/bze.v1.rewards/types/google/protobuf/descriptor.ts new file mode 100644 index 00000000..9e508660 --- /dev/null +++ b/ts-client/bze.v1.rewards/types/google/protobuf/descriptor.ts @@ -0,0 +1,5261 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "google.protobuf"; + +/** + * The protocol compiler can output a FileDescriptorSet containing the .proto + * files it parses. + */ +export interface FileDescriptorSet { + file: FileDescriptorProto[]; +} + +/** Describes a complete .proto file. */ +export interface FileDescriptorProto { + /** file name, relative to root of source tree */ + name: string; + /** e.g. "foo", "foo.bar", etc. */ + package: string; + /** Names of files imported by this file. */ + dependency: string[]; + /** Indexes of the public imported files in the dependency list above. */ + publicDependency: number[]; + /** + * Indexes of the weak imported files in the dependency list. + * For Google-internal migration only. Do not use. + */ + weakDependency: number[]; + /** All top-level definitions in this file. */ + messageType: DescriptorProto[]; + enumType: EnumDescriptorProto[]; + service: ServiceDescriptorProto[]; + extension: FieldDescriptorProto[]; + options: FileOptions | undefined; + /** + * This field contains optional information about the original source code. + * You may safely remove this entire field without harming runtime + * functionality of the descriptors -- the information is needed only by + * development tools. + */ + sourceCodeInfo: SourceCodeInfo | undefined; + /** + * The syntax of the proto file. + * The supported values are "proto2" and "proto3". + */ + syntax: string; +} + +/** Describes a message type. */ +export interface DescriptorProto { + name: string; + field: FieldDescriptorProto[]; + extension: FieldDescriptorProto[]; + nestedType: DescriptorProto[]; + enumType: EnumDescriptorProto[]; + extensionRange: DescriptorProto_ExtensionRange[]; + oneofDecl: OneofDescriptorProto[]; + options: MessageOptions | undefined; + reservedRange: DescriptorProto_ReservedRange[]; + /** + * Reserved field names, which may not be used by fields in the same message. + * A given name may only be reserved once. + */ + reservedName: string[]; +} + +export interface DescriptorProto_ExtensionRange { + /** Inclusive. */ + start: number; + /** Exclusive. */ + end: number; + options: ExtensionRangeOptions | undefined; +} + +/** + * Range of reserved tag numbers. Reserved tag numbers may not be used by + * fields or extension ranges in the same message. Reserved ranges may + * not overlap. + */ +export interface DescriptorProto_ReservedRange { + /** Inclusive. */ + start: number; + /** Exclusive. */ + end: number; +} + +export interface ExtensionRangeOptions { + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +/** Describes a field within a message. */ +export interface FieldDescriptorProto { + name: string; + number: number; + label: FieldDescriptorProto_Label; + /** + * If type_name is set, this need not be set. If both this and type_name + * are set, this must be one of TYPE_ENUM, TYPE_MESSAGE or TYPE_GROUP. + */ + type: FieldDescriptorProto_Type; + /** + * For message and enum types, this is the name of the type. If the name + * starts with a '.', it is fully-qualified. Otherwise, C++-like scoping + * rules are used to find the type (i.e. first the nested types within this + * message are searched, then within the parent, on up to the root + * namespace). + */ + typeName: string; + /** + * For extensions, this is the name of the type being extended. It is + * resolved in the same manner as type_name. + */ + extendee: string; + /** + * For numeric types, contains the original text representation of the value. + * For booleans, "true" or "false". + * For strings, contains the default text contents (not escaped in any way). + * For bytes, contains the C escaped value. All bytes >= 128 are escaped. + * TODO(kenton): Base-64 encode? + */ + defaultValue: string; + /** + * If set, gives the index of a oneof in the containing type's oneof_decl + * list. This field is a member of that oneof. + */ + oneofIndex: number; + /** + * JSON name of this field. The value is set by protocol compiler. If the + * user has set a "json_name" option on this field, that option's value + * will be used. Otherwise, it's deduced from the field's name by converting + * it to camelCase. + */ + jsonName: string; + options: FieldOptions | undefined; + /** + * If true, this is a proto3 "optional". When a proto3 field is optional, it + * tracks presence regardless of field type. + * + * When proto3_optional is true, this field must be belong to a oneof to + * signal to old proto3 clients that presence is tracked for this field. This + * oneof is known as a "synthetic" oneof, and this field must be its sole + * member (each proto3 optional field gets its own synthetic oneof). Synthetic + * oneofs exist in the descriptor only, and do not generate any API. Synthetic + * oneofs must be ordered after all "real" oneofs. + * + * For message fields, proto3_optional doesn't create any semantic change, + * since non-repeated message fields always track presence. However it still + * indicates the semantic detail of whether the user wrote "optional" or not. + * This can be useful for round-tripping the .proto file. For consistency we + * give message fields a synthetic oneof also, even though it is not required + * to track presence. This is especially important because the parser can't + * tell if a field is a message or an enum, so it must always create a + * synthetic oneof. + * + * Proto2 optional fields do not set this flag, because they already indicate + * optional with `LABEL_OPTIONAL`. + */ + proto3Optional: boolean; +} + +export enum FieldDescriptorProto_Type { + /** + * TYPE_DOUBLE - 0 is reserved for errors. + * Order is weird for historical reasons. + */ + TYPE_DOUBLE = 1, + TYPE_FLOAT = 2, + /** + * TYPE_INT64 - Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT64 if + * negative values are likely. + */ + TYPE_INT64 = 3, + TYPE_UINT64 = 4, + /** + * TYPE_INT32 - Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT32 if + * negative values are likely. + */ + TYPE_INT32 = 5, + TYPE_FIXED64 = 6, + TYPE_FIXED32 = 7, + TYPE_BOOL = 8, + TYPE_STRING = 9, + /** + * TYPE_GROUP - Tag-delimited aggregate. + * Group type is deprecated and not supported in proto3. However, Proto3 + * implementations should still be able to parse the group wire format and + * treat group fields as unknown fields. + */ + TYPE_GROUP = 10, + /** TYPE_MESSAGE - Length-delimited aggregate. */ + TYPE_MESSAGE = 11, + /** TYPE_BYTES - New in version 2. */ + TYPE_BYTES = 12, + TYPE_UINT32 = 13, + TYPE_ENUM = 14, + TYPE_SFIXED32 = 15, + TYPE_SFIXED64 = 16, + /** TYPE_SINT32 - Uses ZigZag encoding. */ + TYPE_SINT32 = 17, + /** TYPE_SINT64 - Uses ZigZag encoding. */ + TYPE_SINT64 = 18, + UNRECOGNIZED = -1, +} + +export function fieldDescriptorProto_TypeFromJSON( + object: any +): FieldDescriptorProto_Type { + switch (object) { + case 1: + case "TYPE_DOUBLE": + return FieldDescriptorProto_Type.TYPE_DOUBLE; + case 2: + case "TYPE_FLOAT": + return FieldDescriptorProto_Type.TYPE_FLOAT; + case 3: + case "TYPE_INT64": + return FieldDescriptorProto_Type.TYPE_INT64; + case 4: + case "TYPE_UINT64": + return FieldDescriptorProto_Type.TYPE_UINT64; + case 5: + case "TYPE_INT32": + return FieldDescriptorProto_Type.TYPE_INT32; + case 6: + case "TYPE_FIXED64": + return FieldDescriptorProto_Type.TYPE_FIXED64; + case 7: + case "TYPE_FIXED32": + return FieldDescriptorProto_Type.TYPE_FIXED32; + case 8: + case "TYPE_BOOL": + return FieldDescriptorProto_Type.TYPE_BOOL; + case 9: + case "TYPE_STRING": + return FieldDescriptorProto_Type.TYPE_STRING; + case 10: + case "TYPE_GROUP": + return FieldDescriptorProto_Type.TYPE_GROUP; + case 11: + case "TYPE_MESSAGE": + return FieldDescriptorProto_Type.TYPE_MESSAGE; + case 12: + case "TYPE_BYTES": + return FieldDescriptorProto_Type.TYPE_BYTES; + case 13: + case "TYPE_UINT32": + return FieldDescriptorProto_Type.TYPE_UINT32; + case 14: + case "TYPE_ENUM": + return FieldDescriptorProto_Type.TYPE_ENUM; + case 15: + case "TYPE_SFIXED32": + return FieldDescriptorProto_Type.TYPE_SFIXED32; + case 16: + case "TYPE_SFIXED64": + return FieldDescriptorProto_Type.TYPE_SFIXED64; + case 17: + case "TYPE_SINT32": + return FieldDescriptorProto_Type.TYPE_SINT32; + case 18: + case "TYPE_SINT64": + return FieldDescriptorProto_Type.TYPE_SINT64; + case -1: + case "UNRECOGNIZED": + default: + return FieldDescriptorProto_Type.UNRECOGNIZED; + } +} + +export function fieldDescriptorProto_TypeToJSON( + object: FieldDescriptorProto_Type +): string { + switch (object) { + case FieldDescriptorProto_Type.TYPE_DOUBLE: + return "TYPE_DOUBLE"; + case FieldDescriptorProto_Type.TYPE_FLOAT: + return "TYPE_FLOAT"; + case FieldDescriptorProto_Type.TYPE_INT64: + return "TYPE_INT64"; + case FieldDescriptorProto_Type.TYPE_UINT64: + return "TYPE_UINT64"; + case FieldDescriptorProto_Type.TYPE_INT32: + return "TYPE_INT32"; + case FieldDescriptorProto_Type.TYPE_FIXED64: + return "TYPE_FIXED64"; + case FieldDescriptorProto_Type.TYPE_FIXED32: + return "TYPE_FIXED32"; + case FieldDescriptorProto_Type.TYPE_BOOL: + return "TYPE_BOOL"; + case FieldDescriptorProto_Type.TYPE_STRING: + return "TYPE_STRING"; + case FieldDescriptorProto_Type.TYPE_GROUP: + return "TYPE_GROUP"; + case FieldDescriptorProto_Type.TYPE_MESSAGE: + return "TYPE_MESSAGE"; + case FieldDescriptorProto_Type.TYPE_BYTES: + return "TYPE_BYTES"; + case FieldDescriptorProto_Type.TYPE_UINT32: + return "TYPE_UINT32"; + case FieldDescriptorProto_Type.TYPE_ENUM: + return "TYPE_ENUM"; + case FieldDescriptorProto_Type.TYPE_SFIXED32: + return "TYPE_SFIXED32"; + case FieldDescriptorProto_Type.TYPE_SFIXED64: + return "TYPE_SFIXED64"; + case FieldDescriptorProto_Type.TYPE_SINT32: + return "TYPE_SINT32"; + case FieldDescriptorProto_Type.TYPE_SINT64: + return "TYPE_SINT64"; + default: + return "UNKNOWN"; + } +} + +export enum FieldDescriptorProto_Label { + /** LABEL_OPTIONAL - 0 is reserved for errors */ + LABEL_OPTIONAL = 1, + LABEL_REQUIRED = 2, + LABEL_REPEATED = 3, + UNRECOGNIZED = -1, +} + +export function fieldDescriptorProto_LabelFromJSON( + object: any +): FieldDescriptorProto_Label { + switch (object) { + case 1: + case "LABEL_OPTIONAL": + return FieldDescriptorProto_Label.LABEL_OPTIONAL; + case 2: + case "LABEL_REQUIRED": + return FieldDescriptorProto_Label.LABEL_REQUIRED; + case 3: + case "LABEL_REPEATED": + return FieldDescriptorProto_Label.LABEL_REPEATED; + case -1: + case "UNRECOGNIZED": + default: + return FieldDescriptorProto_Label.UNRECOGNIZED; + } +} + +export function fieldDescriptorProto_LabelToJSON( + object: FieldDescriptorProto_Label +): string { + switch (object) { + case FieldDescriptorProto_Label.LABEL_OPTIONAL: + return "LABEL_OPTIONAL"; + case FieldDescriptorProto_Label.LABEL_REQUIRED: + return "LABEL_REQUIRED"; + case FieldDescriptorProto_Label.LABEL_REPEATED: + return "LABEL_REPEATED"; + default: + return "UNKNOWN"; + } +} + +/** Describes a oneof. */ +export interface OneofDescriptorProto { + name: string; + options: OneofOptions | undefined; +} + +/** Describes an enum type. */ +export interface EnumDescriptorProto { + name: string; + value: EnumValueDescriptorProto[]; + options: EnumOptions | undefined; + /** + * Range of reserved numeric values. Reserved numeric values may not be used + * by enum values in the same enum declaration. Reserved ranges may not + * overlap. + */ + reservedRange: EnumDescriptorProto_EnumReservedRange[]; + /** + * Reserved enum value names, which may not be reused. A given name may only + * be reserved once. + */ + reservedName: string[]; +} + +/** + * Range of reserved numeric values. Reserved values may not be used by + * entries in the same enum. Reserved ranges may not overlap. + * + * Note that this is distinct from DescriptorProto.ReservedRange in that it + * is inclusive such that it can appropriately represent the entire int32 + * domain. + */ +export interface EnumDescriptorProto_EnumReservedRange { + /** Inclusive. */ + start: number; + /** Inclusive. */ + end: number; +} + +/** Describes a value within an enum. */ +export interface EnumValueDescriptorProto { + name: string; + number: number; + options: EnumValueOptions | undefined; +} + +/** Describes a service. */ +export interface ServiceDescriptorProto { + name: string; + method: MethodDescriptorProto[]; + options: ServiceOptions | undefined; +} + +/** Describes a method of a service. */ +export interface MethodDescriptorProto { + name: string; + /** + * Input and output type names. These are resolved in the same way as + * FieldDescriptorProto.type_name, but must refer to a message type. + */ + inputType: string; + outputType: string; + options: MethodOptions | undefined; + /** Identifies if client streams multiple client messages */ + clientStreaming: boolean; + /** Identifies if server streams multiple server messages */ + serverStreaming: boolean; +} + +export interface FileOptions { + /** + * Sets the Java package where classes generated from this .proto will be + * placed. By default, the proto package is used, but this is often + * inappropriate because proto packages do not normally start with backwards + * domain names. + */ + javaPackage: string; + /** + * Controls the name of the wrapper Java class generated for the .proto file. + * That class will always contain the .proto file's getDescriptor() method as + * well as any top-level extensions defined in the .proto file. + * If java_multiple_files is disabled, then all the other classes from the + * .proto file will be nested inside the single wrapper outer class. + */ + javaOuterClassname: string; + /** + * If enabled, then the Java code generator will generate a separate .java + * file for each top-level message, enum, and service defined in the .proto + * file. Thus, these types will *not* be nested inside the wrapper class + * named by java_outer_classname. However, the wrapper class will still be + * generated to contain the file's getDescriptor() method as well as any + * top-level extensions defined in the file. + */ + javaMultipleFiles: boolean; + /** + * This option does nothing. + * + * @deprecated + */ + javaGenerateEqualsAndHash: boolean; + /** + * If set true, then the Java2 code generator will generate code that + * throws an exception whenever an attempt is made to assign a non-UTF-8 + * byte sequence to a string field. + * Message reflection will do the same. + * However, an extension field still accepts non-UTF-8 byte sequences. + * This option has no effect on when used with the lite runtime. + */ + javaStringCheckUtf8: boolean; + optimizeFor: FileOptions_OptimizeMode; + /** + * Sets the Go package where structs generated from this .proto will be + * placed. If omitted, the Go package will be derived from the following: + * - The basename of the package import path, if provided. + * - Otherwise, the package statement in the .proto file, if present. + * - Otherwise, the basename of the .proto file, without extension. + */ + goPackage: string; + /** + * Should generic services be generated in each language? "Generic" services + * are not specific to any particular RPC system. They are generated by the + * main code generators in each language (without additional plugins). + * Generic services were the only kind of service generation supported by + * early versions of google.protobuf. + * + * Generic services are now considered deprecated in favor of using plugins + * that generate code specific to your particular RPC system. Therefore, + * these default to false. Old code which depends on generic services should + * explicitly set them to true. + */ + ccGenericServices: boolean; + javaGenericServices: boolean; + pyGenericServices: boolean; + phpGenericServices: boolean; + /** + * Is this file deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for everything in the file, or it will be completely ignored; in the very + * least, this is a formalization for deprecating files. + */ + deprecated: boolean; + /** + * Enables the use of arenas for the proto messages in this file. This applies + * only to generated classes for C++. + */ + ccEnableArenas: boolean; + /** + * Sets the objective c class prefix which is prepended to all objective c + * generated classes from this .proto. There is no default. + */ + objcClassPrefix: string; + /** Namespace for generated classes; defaults to the package. */ + csharpNamespace: string; + /** + * By default Swift generators will take the proto package and CamelCase it + * replacing '.' with underscore and use that to prefix the types/symbols + * defined. When this options is provided, they will use this value instead + * to prefix the types/symbols defined. + */ + swiftPrefix: string; + /** + * Sets the php class prefix which is prepended to all php generated classes + * from this .proto. Default is empty. + */ + phpClassPrefix: string; + /** + * Use this option to change the namespace of php generated classes. Default + * is empty. When this option is empty, the package name will be used for + * determining the namespace. + */ + phpNamespace: string; + /** + * Use this option to change the namespace of php generated metadata classes. + * Default is empty. When this option is empty, the proto file name will be + * used for determining the namespace. + */ + phpMetadataNamespace: string; + /** + * Use this option to change the package of ruby generated classes. Default + * is empty. When this option is not set, the package name will be used for + * determining the ruby package. + */ + rubyPackage: string; + /** + * The parser stores options it doesn't recognize here. + * See the documentation for the "Options" section above. + */ + uninterpretedOption: UninterpretedOption[]; +} + +/** Generated classes can be optimized for speed or code size. */ +export enum FileOptions_OptimizeMode { + /** SPEED - Generate complete code for parsing, serialization, */ + SPEED = 1, + /** CODE_SIZE - etc. */ + CODE_SIZE = 2, + /** LITE_RUNTIME - Generate code using MessageLite and the lite runtime. */ + LITE_RUNTIME = 3, + UNRECOGNIZED = -1, +} + +export function fileOptions_OptimizeModeFromJSON( + object: any +): FileOptions_OptimizeMode { + switch (object) { + case 1: + case "SPEED": + return FileOptions_OptimizeMode.SPEED; + case 2: + case "CODE_SIZE": + return FileOptions_OptimizeMode.CODE_SIZE; + case 3: + case "LITE_RUNTIME": + return FileOptions_OptimizeMode.LITE_RUNTIME; + case -1: + case "UNRECOGNIZED": + default: + return FileOptions_OptimizeMode.UNRECOGNIZED; + } +} + +export function fileOptions_OptimizeModeToJSON( + object: FileOptions_OptimizeMode +): string { + switch (object) { + case FileOptions_OptimizeMode.SPEED: + return "SPEED"; + case FileOptions_OptimizeMode.CODE_SIZE: + return "CODE_SIZE"; + case FileOptions_OptimizeMode.LITE_RUNTIME: + return "LITE_RUNTIME"; + default: + return "UNKNOWN"; + } +} + +export interface MessageOptions { + /** + * Set true to use the old proto1 MessageSet wire format for extensions. + * This is provided for backwards-compatibility with the MessageSet wire + * format. You should not use this for any other reason: It's less + * efficient, has fewer features, and is more complicated. + * + * The message must be defined exactly as follows: + * message Foo { + * option message_set_wire_format = true; + * extensions 4 to max; + * } + * Note that the message cannot have any defined fields; MessageSets only + * have extensions. + * + * All extensions of your type must be singular messages; e.g. they cannot + * be int32s, enums, or repeated messages. + * + * Because this is an option, the above two restrictions are not enforced by + * the protocol compiler. + */ + messageSetWireFormat: boolean; + /** + * Disables the generation of the standard "descriptor()" accessor, which can + * conflict with a field of the same name. This is meant to make migration + * from proto1 easier; new code should avoid fields named "descriptor". + */ + noStandardDescriptorAccessor: boolean; + /** + * Is this message deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the message, or it will be completely ignored; in the very least, + * this is a formalization for deprecating messages. + */ + deprecated: boolean; + /** + * Whether the message is an automatically generated map entry type for the + * maps field. + * + * For maps fields: + * map map_field = 1; + * The parsed descriptor looks like: + * message MapFieldEntry { + * option map_entry = true; + * optional KeyType key = 1; + * optional ValueType value = 2; + * } + * repeated MapFieldEntry map_field = 1; + * + * Implementations may choose not to generate the map_entry=true message, but + * use a native map in the target language to hold the keys and values. + * The reflection APIs in such implementations still need to work as + * if the field is a repeated message field. + * + * NOTE: Do not set the option in .proto files. Always use the maps syntax + * instead. The option should only be implicitly set by the proto compiler + * parser. + */ + mapEntry: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface FieldOptions { + /** + * The ctype option instructs the C++ code generator to use a different + * representation of the field than it normally would. See the specific + * options below. This option is not yet implemented in the open source + * release -- sorry, we'll try to include it in a future version! + */ + ctype: FieldOptions_CType; + /** + * The packed option can be enabled for repeated primitive fields to enable + * a more efficient representation on the wire. Rather than repeatedly + * writing the tag and type for each element, the entire array is encoded as + * a single length-delimited blob. In proto3, only explicit setting it to + * false will avoid using packed encoding. + */ + packed: boolean; + /** + * The jstype option determines the JavaScript type used for values of the + * field. The option is permitted only for 64 bit integral and fixed types + * (int64, uint64, sint64, fixed64, sfixed64). A field with jstype JS_STRING + * is represented as JavaScript string, which avoids loss of precision that + * can happen when a large value is converted to a floating point JavaScript. + * Specifying JS_NUMBER for the jstype causes the generated JavaScript code to + * use the JavaScript "number" type. The behavior of the default option + * JS_NORMAL is implementation dependent. + * + * This option is an enum to permit additional types to be added, e.g. + * goog.math.Integer. + */ + jstype: FieldOptions_JSType; + /** + * Should this field be parsed lazily? Lazy applies only to message-type + * fields. It means that when the outer message is initially parsed, the + * inner message's contents will not be parsed but instead stored in encoded + * form. The inner message will actually be parsed when it is first accessed. + * + * This is only a hint. Implementations are free to choose whether to use + * eager or lazy parsing regardless of the value of this option. However, + * setting this option true suggests that the protocol author believes that + * using lazy parsing on this field is worth the additional bookkeeping + * overhead typically needed to implement it. + * + * This option does not affect the public interface of any generated code; + * all method signatures remain the same. Furthermore, thread-safety of the + * interface is not affected by this option; const methods remain safe to + * call from multiple threads concurrently, while non-const methods continue + * to require exclusive access. + * + * + * Note that implementations may choose not to check required fields within + * a lazy sub-message. That is, calling IsInitialized() on the outer message + * may return true even if the inner message has missing required fields. + * This is necessary because otherwise the inner message would have to be + * parsed in order to perform the check, defeating the purpose of lazy + * parsing. An implementation which chooses not to check required fields + * must be consistent about it. That is, for any particular sub-message, the + * implementation must either *always* check its required fields, or *never* + * check its required fields, regardless of whether or not the message has + * been parsed. + */ + lazy: boolean; + /** + * Is this field deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for accessors, or it will be completely ignored; in the very least, this + * is a formalization for deprecating fields. + */ + deprecated: boolean; + /** For Google-internal migration only. Do not use. */ + weak: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export enum FieldOptions_CType { + /** STRING - Default mode. */ + STRING = 0, + CORD = 1, + STRING_PIECE = 2, + UNRECOGNIZED = -1, +} + +export function fieldOptions_CTypeFromJSON(object: any): FieldOptions_CType { + switch (object) { + case 0: + case "STRING": + return FieldOptions_CType.STRING; + case 1: + case "CORD": + return FieldOptions_CType.CORD; + case 2: + case "STRING_PIECE": + return FieldOptions_CType.STRING_PIECE; + case -1: + case "UNRECOGNIZED": + default: + return FieldOptions_CType.UNRECOGNIZED; + } +} + +export function fieldOptions_CTypeToJSON(object: FieldOptions_CType): string { + switch (object) { + case FieldOptions_CType.STRING: + return "STRING"; + case FieldOptions_CType.CORD: + return "CORD"; + case FieldOptions_CType.STRING_PIECE: + return "STRING_PIECE"; + default: + return "UNKNOWN"; + } +} + +export enum FieldOptions_JSType { + /** JS_NORMAL - Use the default type. */ + JS_NORMAL = 0, + /** JS_STRING - Use JavaScript strings. */ + JS_STRING = 1, + /** JS_NUMBER - Use JavaScript numbers. */ + JS_NUMBER = 2, + UNRECOGNIZED = -1, +} + +export function fieldOptions_JSTypeFromJSON(object: any): FieldOptions_JSType { + switch (object) { + case 0: + case "JS_NORMAL": + return FieldOptions_JSType.JS_NORMAL; + case 1: + case "JS_STRING": + return FieldOptions_JSType.JS_STRING; + case 2: + case "JS_NUMBER": + return FieldOptions_JSType.JS_NUMBER; + case -1: + case "UNRECOGNIZED": + default: + return FieldOptions_JSType.UNRECOGNIZED; + } +} + +export function fieldOptions_JSTypeToJSON(object: FieldOptions_JSType): string { + switch (object) { + case FieldOptions_JSType.JS_NORMAL: + return "JS_NORMAL"; + case FieldOptions_JSType.JS_STRING: + return "JS_STRING"; + case FieldOptions_JSType.JS_NUMBER: + return "JS_NUMBER"; + default: + return "UNKNOWN"; + } +} + +export interface OneofOptions { + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface EnumOptions { + /** + * Set this option to true to allow mapping different tag names to the same + * value. + */ + allowAlias: boolean; + /** + * Is this enum deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the enum, or it will be completely ignored; in the very least, this + * is a formalization for deprecating enums. + */ + deprecated: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface EnumValueOptions { + /** + * Is this enum value deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the enum value, or it will be completely ignored; in the very least, + * this is a formalization for deprecating enum values. + */ + deprecated: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface ServiceOptions { + /** + * Is this service deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the service, or it will be completely ignored; in the very least, + * this is a formalization for deprecating services. + */ + deprecated: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface MethodOptions { + /** + * Is this method deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the method, or it will be completely ignored; in the very least, + * this is a formalization for deprecating methods. + */ + deprecated: boolean; + idempotencyLevel: MethodOptions_IdempotencyLevel; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +/** + * Is this method side-effect-free (or safe in HTTP parlance), or idempotent, + * or neither? HTTP based RPC implementation may choose GET verb for safe + * methods, and PUT verb for idempotent methods instead of the default POST. + */ +export enum MethodOptions_IdempotencyLevel { + IDEMPOTENCY_UNKNOWN = 0, + /** NO_SIDE_EFFECTS - implies idempotent */ + NO_SIDE_EFFECTS = 1, + /** IDEMPOTENT - idempotent, but may have side effects */ + IDEMPOTENT = 2, + UNRECOGNIZED = -1, +} + +export function methodOptions_IdempotencyLevelFromJSON( + object: any +): MethodOptions_IdempotencyLevel { + switch (object) { + case 0: + case "IDEMPOTENCY_UNKNOWN": + return MethodOptions_IdempotencyLevel.IDEMPOTENCY_UNKNOWN; + case 1: + case "NO_SIDE_EFFECTS": + return MethodOptions_IdempotencyLevel.NO_SIDE_EFFECTS; + case 2: + case "IDEMPOTENT": + return MethodOptions_IdempotencyLevel.IDEMPOTENT; + case -1: + case "UNRECOGNIZED": + default: + return MethodOptions_IdempotencyLevel.UNRECOGNIZED; + } +} + +export function methodOptions_IdempotencyLevelToJSON( + object: MethodOptions_IdempotencyLevel +): string { + switch (object) { + case MethodOptions_IdempotencyLevel.IDEMPOTENCY_UNKNOWN: + return "IDEMPOTENCY_UNKNOWN"; + case MethodOptions_IdempotencyLevel.NO_SIDE_EFFECTS: + return "NO_SIDE_EFFECTS"; + case MethodOptions_IdempotencyLevel.IDEMPOTENT: + return "IDEMPOTENT"; + default: + return "UNKNOWN"; + } +} + +/** + * A message representing a option the parser does not recognize. This only + * appears in options protos created by the compiler::Parser class. + * DescriptorPool resolves these when building Descriptor objects. Therefore, + * options protos in descriptor objects (e.g. returned by Descriptor::options(), + * or produced by Descriptor::CopyTo()) will never have UninterpretedOptions + * in them. + */ +export interface UninterpretedOption { + name: UninterpretedOption_NamePart[]; + /** + * The value of the uninterpreted option, in whatever type the tokenizer + * identified it as during parsing. Exactly one of these should be set. + */ + identifierValue: string; + positiveIntValue: number; + negativeIntValue: number; + doubleValue: number; + stringValue: Uint8Array; + aggregateValue: string; +} + +/** + * The name of the uninterpreted option. Each string represents a segment in + * a dot-separated name. is_extension is true iff a segment represents an + * extension (denoted with parentheses in options specs in .proto files). + * E.g.,{ ["foo", false], ["bar.baz", true], ["qux", false] } represents + * "foo.(bar.baz).qux". + */ +export interface UninterpretedOption_NamePart { + namePart: string; + isExtension: boolean; +} + +/** + * Encapsulates information about the original source file from which a + * FileDescriptorProto was generated. + */ +export interface SourceCodeInfo { + /** + * A Location identifies a piece of source code in a .proto file which + * corresponds to a particular definition. This information is intended + * to be useful to IDEs, code indexers, documentation generators, and similar + * tools. + * + * For example, say we have a file like: + * message Foo { + * optional string foo = 1; + * } + * Let's look at just the field definition: + * optional string foo = 1; + * ^ ^^ ^^ ^ ^^^ + * a bc de f ghi + * We have the following locations: + * span path represents + * [a,i) [ 4, 0, 2, 0 ] The whole field definition. + * [a,b) [ 4, 0, 2, 0, 4 ] The label (optional). + * [c,d) [ 4, 0, 2, 0, 5 ] The type (string). + * [e,f) [ 4, 0, 2, 0, 1 ] The name (foo). + * [g,h) [ 4, 0, 2, 0, 3 ] The number (1). + * + * Notes: + * - A location may refer to a repeated field itself (i.e. not to any + * particular index within it). This is used whenever a set of elements are + * logically enclosed in a single code segment. For example, an entire + * extend block (possibly containing multiple extension definitions) will + * have an outer location whose path refers to the "extensions" repeated + * field without an index. + * - Multiple locations may have the same path. This happens when a single + * logical declaration is spread out across multiple places. The most + * obvious example is the "extend" block again -- there may be multiple + * extend blocks in the same scope, each of which will have the same path. + * - A location's span is not always a subset of its parent's span. For + * example, the "extendee" of an extension declaration appears at the + * beginning of the "extend" block and is shared by all extensions within + * the block. + * - Just because a location's span is a subset of some other location's span + * does not mean that it is a descendant. For example, a "group" defines + * both a type and a field in a single declaration. Thus, the locations + * corresponding to the type and field and their components will overlap. + * - Code which tries to interpret locations should probably be designed to + * ignore those that it doesn't understand, as more types of locations could + * be recorded in the future. + */ + location: SourceCodeInfo_Location[]; +} + +export interface SourceCodeInfo_Location { + /** + * Identifies which part of the FileDescriptorProto was defined at this + * location. + * + * Each element is a field number or an index. They form a path from + * the root FileDescriptorProto to the place where the definition. For + * example, this path: + * [ 4, 3, 2, 7, 1 ] + * refers to: + * file.message_type(3) // 4, 3 + * .field(7) // 2, 7 + * .name() // 1 + * This is because FileDescriptorProto.message_type has field number 4: + * repeated DescriptorProto message_type = 4; + * and DescriptorProto.field has field number 2: + * repeated FieldDescriptorProto field = 2; + * and FieldDescriptorProto.name has field number 1: + * optional string name = 1; + * + * Thus, the above path gives the location of a field name. If we removed + * the last element: + * [ 4, 3, 2, 7 ] + * this path refers to the whole field declaration (from the beginning + * of the label to the terminating semicolon). + */ + path: number[]; + /** + * Always has exactly three or four elements: start line, start column, + * end line (optional, otherwise assumed same as start line), end column. + * These are packed into a single field for efficiency. Note that line + * and column numbers are zero-based -- typically you will want to add + * 1 to each before displaying to a user. + */ + span: number[]; + /** + * If this SourceCodeInfo represents a complete declaration, these are any + * comments appearing before and after the declaration which appear to be + * attached to the declaration. + * + * A series of line comments appearing on consecutive lines, with no other + * tokens appearing on those lines, will be treated as a single comment. + * + * leading_detached_comments will keep paragraphs of comments that appear + * before (but not connected to) the current element. Each paragraph, + * separated by empty lines, will be one comment element in the repeated + * field. + * + * Only the comment content is provided; comment markers (e.g. //) are + * stripped out. For block comments, leading whitespace and an asterisk + * will be stripped from the beginning of each line other than the first. + * Newlines are included in the output. + * + * Examples: + * + * optional int32 foo = 1; // Comment attached to foo. + * // Comment attached to bar. + * optional int32 bar = 2; + * + * optional string baz = 3; + * // Comment attached to baz. + * // Another line attached to baz. + * + * // Comment attached to qux. + * // + * // Another line attached to qux. + * optional double qux = 4; + * + * // Detached comment for corge. This is not leading or trailing comments + * // to qux or corge because there are blank lines separating it from + * // both. + * + * // Detached comment for corge paragraph 2. + * + * optional string corge = 5; + * /* Block comment attached + * * to corge. Leading asterisks + * * will be removed. * / + * /* Block comment attached to + * * grault. * / + * optional int32 grault = 6; + * + * // ignored detached comments. + */ + leadingComments: string; + trailingComments: string; + leadingDetachedComments: string[]; +} + +/** + * Describes the relationship between generated code and its original source + * file. A GeneratedCodeInfo message is associated with only one generated + * source file, but may contain references to different source .proto files. + */ +export interface GeneratedCodeInfo { + /** + * An Annotation connects some span of text in generated code to an element + * of its generating .proto file. + */ + annotation: GeneratedCodeInfo_Annotation[]; +} + +export interface GeneratedCodeInfo_Annotation { + /** + * Identifies the element in the original source .proto file. This field + * is formatted the same as SourceCodeInfo.Location.path. + */ + path: number[]; + /** Identifies the filesystem path to the original source .proto. */ + sourceFile: string; + /** + * Identifies the starting offset in bytes in the generated code + * that relates to the identified object. + */ + begin: number; + /** + * Identifies the ending offset in bytes in the generated code that + * relates to the identified offset. The end offset should be one past + * the last relevant byte (so the length of the text = end - begin). + */ + end: number; +} + +const baseFileDescriptorSet: object = {}; + +export const FileDescriptorSet = { + encode(message: FileDescriptorSet, writer: Writer = Writer.create()): Writer { + for (const v of message.file) { + FileDescriptorProto.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FileDescriptorSet { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFileDescriptorSet } as FileDescriptorSet; + message.file = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.file.push( + FileDescriptorProto.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FileDescriptorSet { + const message = { ...baseFileDescriptorSet } as FileDescriptorSet; + message.file = []; + if (object.file !== undefined && object.file !== null) { + for (const e of object.file) { + message.file.push(FileDescriptorProto.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: FileDescriptorSet): unknown { + const obj: any = {}; + if (message.file) { + obj.file = message.file.map((e) => + e ? FileDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.file = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): FileDescriptorSet { + const message = { ...baseFileDescriptorSet } as FileDescriptorSet; + message.file = []; + if (object.file !== undefined && object.file !== null) { + for (const e of object.file) { + message.file.push(FileDescriptorProto.fromPartial(e)); + } + } + return message; + }, +}; + +const baseFileDescriptorProto: object = { + name: "", + package: "", + dependency: "", + publicDependency: 0, + weakDependency: 0, + syntax: "", +}; + +export const FileDescriptorProto = { + encode( + message: FileDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.package !== "") { + writer.uint32(18).string(message.package); + } + for (const v of message.dependency) { + writer.uint32(26).string(v!); + } + writer.uint32(82).fork(); + for (const v of message.publicDependency) { + writer.int32(v); + } + writer.ldelim(); + writer.uint32(90).fork(); + for (const v of message.weakDependency) { + writer.int32(v); + } + writer.ldelim(); + for (const v of message.messageType) { + DescriptorProto.encode(v!, writer.uint32(34).fork()).ldelim(); + } + for (const v of message.enumType) { + EnumDescriptorProto.encode(v!, writer.uint32(42).fork()).ldelim(); + } + for (const v of message.service) { + ServiceDescriptorProto.encode(v!, writer.uint32(50).fork()).ldelim(); + } + for (const v of message.extension) { + FieldDescriptorProto.encode(v!, writer.uint32(58).fork()).ldelim(); + } + if (message.options !== undefined) { + FileOptions.encode(message.options, writer.uint32(66).fork()).ldelim(); + } + if (message.sourceCodeInfo !== undefined) { + SourceCodeInfo.encode( + message.sourceCodeInfo, + writer.uint32(74).fork() + ).ldelim(); + } + if (message.syntax !== "") { + writer.uint32(98).string(message.syntax); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FileDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFileDescriptorProto } as FileDescriptorProto; + message.dependency = []; + message.publicDependency = []; + message.weakDependency = []; + message.messageType = []; + message.enumType = []; + message.service = []; + message.extension = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.package = reader.string(); + break; + case 3: + message.dependency.push(reader.string()); + break; + case 10: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.publicDependency.push(reader.int32()); + } + } else { + message.publicDependency.push(reader.int32()); + } + break; + case 11: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.weakDependency.push(reader.int32()); + } + } else { + message.weakDependency.push(reader.int32()); + } + break; + case 4: + message.messageType.push( + DescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 5: + message.enumType.push( + EnumDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 6: + message.service.push( + ServiceDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 7: + message.extension.push( + FieldDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 8: + message.options = FileOptions.decode(reader, reader.uint32()); + break; + case 9: + message.sourceCodeInfo = SourceCodeInfo.decode( + reader, + reader.uint32() + ); + break; + case 12: + message.syntax = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FileDescriptorProto { + const message = { ...baseFileDescriptorProto } as FileDescriptorProto; + message.dependency = []; + message.publicDependency = []; + message.weakDependency = []; + message.messageType = []; + message.enumType = []; + message.service = []; + message.extension = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.package !== undefined && object.package !== null) { + message.package = String(object.package); + } else { + message.package = ""; + } + if (object.dependency !== undefined && object.dependency !== null) { + for (const e of object.dependency) { + message.dependency.push(String(e)); + } + } + if ( + object.publicDependency !== undefined && + object.publicDependency !== null + ) { + for (const e of object.publicDependency) { + message.publicDependency.push(Number(e)); + } + } + if (object.weakDependency !== undefined && object.weakDependency !== null) { + for (const e of object.weakDependency) { + message.weakDependency.push(Number(e)); + } + } + if (object.messageType !== undefined && object.messageType !== null) { + for (const e of object.messageType) { + message.messageType.push(DescriptorProto.fromJSON(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromJSON(e)); + } + } + if (object.service !== undefined && object.service !== null) { + for (const e of object.service) { + message.service.push(ServiceDescriptorProto.fromJSON(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = FileOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.sourceCodeInfo !== undefined && object.sourceCodeInfo !== null) { + message.sourceCodeInfo = SourceCodeInfo.fromJSON(object.sourceCodeInfo); + } else { + message.sourceCodeInfo = undefined; + } + if (object.syntax !== undefined && object.syntax !== null) { + message.syntax = String(object.syntax); + } else { + message.syntax = ""; + } + return message; + }, + + toJSON(message: FileDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.package !== undefined && (obj.package = message.package); + if (message.dependency) { + obj.dependency = message.dependency.map((e) => e); + } else { + obj.dependency = []; + } + if (message.publicDependency) { + obj.publicDependency = message.publicDependency.map((e) => e); + } else { + obj.publicDependency = []; + } + if (message.weakDependency) { + obj.weakDependency = message.weakDependency.map((e) => e); + } else { + obj.weakDependency = []; + } + if (message.messageType) { + obj.messageType = message.messageType.map((e) => + e ? DescriptorProto.toJSON(e) : undefined + ); + } else { + obj.messageType = []; + } + if (message.enumType) { + obj.enumType = message.enumType.map((e) => + e ? EnumDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.enumType = []; + } + if (message.service) { + obj.service = message.service.map((e) => + e ? ServiceDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.service = []; + } + if (message.extension) { + obj.extension = message.extension.map((e) => + e ? FieldDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.extension = []; + } + message.options !== undefined && + (obj.options = message.options + ? FileOptions.toJSON(message.options) + : undefined); + message.sourceCodeInfo !== undefined && + (obj.sourceCodeInfo = message.sourceCodeInfo + ? SourceCodeInfo.toJSON(message.sourceCodeInfo) + : undefined); + message.syntax !== undefined && (obj.syntax = message.syntax); + return obj; + }, + + fromPartial(object: DeepPartial): FileDescriptorProto { + const message = { ...baseFileDescriptorProto } as FileDescriptorProto; + message.dependency = []; + message.publicDependency = []; + message.weakDependency = []; + message.messageType = []; + message.enumType = []; + message.service = []; + message.extension = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.package !== undefined && object.package !== null) { + message.package = object.package; + } else { + message.package = ""; + } + if (object.dependency !== undefined && object.dependency !== null) { + for (const e of object.dependency) { + message.dependency.push(e); + } + } + if ( + object.publicDependency !== undefined && + object.publicDependency !== null + ) { + for (const e of object.publicDependency) { + message.publicDependency.push(e); + } + } + if (object.weakDependency !== undefined && object.weakDependency !== null) { + for (const e of object.weakDependency) { + message.weakDependency.push(e); + } + } + if (object.messageType !== undefined && object.messageType !== null) { + for (const e of object.messageType) { + message.messageType.push(DescriptorProto.fromPartial(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromPartial(e)); + } + } + if (object.service !== undefined && object.service !== null) { + for (const e of object.service) { + message.service.push(ServiceDescriptorProto.fromPartial(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = FileOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.sourceCodeInfo !== undefined && object.sourceCodeInfo !== null) { + message.sourceCodeInfo = SourceCodeInfo.fromPartial( + object.sourceCodeInfo + ); + } else { + message.sourceCodeInfo = undefined; + } + if (object.syntax !== undefined && object.syntax !== null) { + message.syntax = object.syntax; + } else { + message.syntax = ""; + } + return message; + }, +}; + +const baseDescriptorProto: object = { name: "", reservedName: "" }; + +export const DescriptorProto = { + encode(message: DescriptorProto, writer: Writer = Writer.create()): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + for (const v of message.field) { + FieldDescriptorProto.encode(v!, writer.uint32(18).fork()).ldelim(); + } + for (const v of message.extension) { + FieldDescriptorProto.encode(v!, writer.uint32(50).fork()).ldelim(); + } + for (const v of message.nestedType) { + DescriptorProto.encode(v!, writer.uint32(26).fork()).ldelim(); + } + for (const v of message.enumType) { + EnumDescriptorProto.encode(v!, writer.uint32(34).fork()).ldelim(); + } + for (const v of message.extensionRange) { + DescriptorProto_ExtensionRange.encode( + v!, + writer.uint32(42).fork() + ).ldelim(); + } + for (const v of message.oneofDecl) { + OneofDescriptorProto.encode(v!, writer.uint32(66).fork()).ldelim(); + } + if (message.options !== undefined) { + MessageOptions.encode(message.options, writer.uint32(58).fork()).ldelim(); + } + for (const v of message.reservedRange) { + DescriptorProto_ReservedRange.encode( + v!, + writer.uint32(74).fork() + ).ldelim(); + } + for (const v of message.reservedName) { + writer.uint32(82).string(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): DescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseDescriptorProto } as DescriptorProto; + message.field = []; + message.extension = []; + message.nestedType = []; + message.enumType = []; + message.extensionRange = []; + message.oneofDecl = []; + message.reservedRange = []; + message.reservedName = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.field.push( + FieldDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 6: + message.extension.push( + FieldDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 3: + message.nestedType.push( + DescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 4: + message.enumType.push( + EnumDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 5: + message.extensionRange.push( + DescriptorProto_ExtensionRange.decode(reader, reader.uint32()) + ); + break; + case 8: + message.oneofDecl.push( + OneofDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 7: + message.options = MessageOptions.decode(reader, reader.uint32()); + break; + case 9: + message.reservedRange.push( + DescriptorProto_ReservedRange.decode(reader, reader.uint32()) + ); + break; + case 10: + message.reservedName.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DescriptorProto { + const message = { ...baseDescriptorProto } as DescriptorProto; + message.field = []; + message.extension = []; + message.nestedType = []; + message.enumType = []; + message.extensionRange = []; + message.oneofDecl = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.field !== undefined && object.field !== null) { + for (const e of object.field) { + message.field.push(FieldDescriptorProto.fromJSON(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromJSON(e)); + } + } + if (object.nestedType !== undefined && object.nestedType !== null) { + for (const e of object.nestedType) { + message.nestedType.push(DescriptorProto.fromJSON(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromJSON(e)); + } + } + if (object.extensionRange !== undefined && object.extensionRange !== null) { + for (const e of object.extensionRange) { + message.extensionRange.push(DescriptorProto_ExtensionRange.fromJSON(e)); + } + } + if (object.oneofDecl !== undefined && object.oneofDecl !== null) { + for (const e of object.oneofDecl) { + message.oneofDecl.push(OneofDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = MessageOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push(DescriptorProto_ReservedRange.fromJSON(e)); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(String(e)); + } + } + return message; + }, + + toJSON(message: DescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + if (message.field) { + obj.field = message.field.map((e) => + e ? FieldDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.field = []; + } + if (message.extension) { + obj.extension = message.extension.map((e) => + e ? FieldDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.extension = []; + } + if (message.nestedType) { + obj.nestedType = message.nestedType.map((e) => + e ? DescriptorProto.toJSON(e) : undefined + ); + } else { + obj.nestedType = []; + } + if (message.enumType) { + obj.enumType = message.enumType.map((e) => + e ? EnumDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.enumType = []; + } + if (message.extensionRange) { + obj.extensionRange = message.extensionRange.map((e) => + e ? DescriptorProto_ExtensionRange.toJSON(e) : undefined + ); + } else { + obj.extensionRange = []; + } + if (message.oneofDecl) { + obj.oneofDecl = message.oneofDecl.map((e) => + e ? OneofDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.oneofDecl = []; + } + message.options !== undefined && + (obj.options = message.options + ? MessageOptions.toJSON(message.options) + : undefined); + if (message.reservedRange) { + obj.reservedRange = message.reservedRange.map((e) => + e ? DescriptorProto_ReservedRange.toJSON(e) : undefined + ); + } else { + obj.reservedRange = []; + } + if (message.reservedName) { + obj.reservedName = message.reservedName.map((e) => e); + } else { + obj.reservedName = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): DescriptorProto { + const message = { ...baseDescriptorProto } as DescriptorProto; + message.field = []; + message.extension = []; + message.nestedType = []; + message.enumType = []; + message.extensionRange = []; + message.oneofDecl = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.field !== undefined && object.field !== null) { + for (const e of object.field) { + message.field.push(FieldDescriptorProto.fromPartial(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromPartial(e)); + } + } + if (object.nestedType !== undefined && object.nestedType !== null) { + for (const e of object.nestedType) { + message.nestedType.push(DescriptorProto.fromPartial(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromPartial(e)); + } + } + if (object.extensionRange !== undefined && object.extensionRange !== null) { + for (const e of object.extensionRange) { + message.extensionRange.push( + DescriptorProto_ExtensionRange.fromPartial(e) + ); + } + } + if (object.oneofDecl !== undefined && object.oneofDecl !== null) { + for (const e of object.oneofDecl) { + message.oneofDecl.push(OneofDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = MessageOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push( + DescriptorProto_ReservedRange.fromPartial(e) + ); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(e); + } + } + return message; + }, +}; + +const baseDescriptorProto_ExtensionRange: object = { start: 0, end: 0 }; + +export const DescriptorProto_ExtensionRange = { + encode( + message: DescriptorProto_ExtensionRange, + writer: Writer = Writer.create() + ): Writer { + if (message.start !== 0) { + writer.uint32(8).int32(message.start); + } + if (message.end !== 0) { + writer.uint32(16).int32(message.end); + } + if (message.options !== undefined) { + ExtensionRangeOptions.encode( + message.options, + writer.uint32(26).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): DescriptorProto_ExtensionRange { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseDescriptorProto_ExtensionRange, + } as DescriptorProto_ExtensionRange; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.start = reader.int32(); + break; + case 2: + message.end = reader.int32(); + break; + case 3: + message.options = ExtensionRangeOptions.decode( + reader, + reader.uint32() + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DescriptorProto_ExtensionRange { + const message = { + ...baseDescriptorProto_ExtensionRange, + } as DescriptorProto_ExtensionRange; + if (object.start !== undefined && object.start !== null) { + message.start = Number(object.start); + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = ExtensionRangeOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: DescriptorProto_ExtensionRange): unknown { + const obj: any = {}; + message.start !== undefined && (obj.start = message.start); + message.end !== undefined && (obj.end = message.end); + message.options !== undefined && + (obj.options = message.options + ? ExtensionRangeOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): DescriptorProto_ExtensionRange { + const message = { + ...baseDescriptorProto_ExtensionRange, + } as DescriptorProto_ExtensionRange; + if (object.start !== undefined && object.start !== null) { + message.start = object.start; + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = ExtensionRangeOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseDescriptorProto_ReservedRange: object = { start: 0, end: 0 }; + +export const DescriptorProto_ReservedRange = { + encode( + message: DescriptorProto_ReservedRange, + writer: Writer = Writer.create() + ): Writer { + if (message.start !== 0) { + writer.uint32(8).int32(message.start); + } + if (message.end !== 0) { + writer.uint32(16).int32(message.end); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): DescriptorProto_ReservedRange { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseDescriptorProto_ReservedRange, + } as DescriptorProto_ReservedRange; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.start = reader.int32(); + break; + case 2: + message.end = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DescriptorProto_ReservedRange { + const message = { + ...baseDescriptorProto_ReservedRange, + } as DescriptorProto_ReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = Number(object.start); + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + return message; + }, + + toJSON(message: DescriptorProto_ReservedRange): unknown { + const obj: any = {}; + message.start !== undefined && (obj.start = message.start); + message.end !== undefined && (obj.end = message.end); + return obj; + }, + + fromPartial( + object: DeepPartial + ): DescriptorProto_ReservedRange { + const message = { + ...baseDescriptorProto_ReservedRange, + } as DescriptorProto_ReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = object.start; + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + return message; + }, +}; + +const baseExtensionRangeOptions: object = {}; + +export const ExtensionRangeOptions = { + encode( + message: ExtensionRangeOptions, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ExtensionRangeOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseExtensionRangeOptions } as ExtensionRangeOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ExtensionRangeOptions { + const message = { ...baseExtensionRangeOptions } as ExtensionRangeOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: ExtensionRangeOptions): unknown { + const obj: any = {}; + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial( + object: DeepPartial + ): ExtensionRangeOptions { + const message = { ...baseExtensionRangeOptions } as ExtensionRangeOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseFieldDescriptorProto: object = { + name: "", + number: 0, + label: 1, + type: 1, + typeName: "", + extendee: "", + defaultValue: "", + oneofIndex: 0, + jsonName: "", + proto3Optional: false, +}; + +export const FieldDescriptorProto = { + encode( + message: FieldDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.number !== 0) { + writer.uint32(24).int32(message.number); + } + if (message.label !== 1) { + writer.uint32(32).int32(message.label); + } + if (message.type !== 1) { + writer.uint32(40).int32(message.type); + } + if (message.typeName !== "") { + writer.uint32(50).string(message.typeName); + } + if (message.extendee !== "") { + writer.uint32(18).string(message.extendee); + } + if (message.defaultValue !== "") { + writer.uint32(58).string(message.defaultValue); + } + if (message.oneofIndex !== 0) { + writer.uint32(72).int32(message.oneofIndex); + } + if (message.jsonName !== "") { + writer.uint32(82).string(message.jsonName); + } + if (message.options !== undefined) { + FieldOptions.encode(message.options, writer.uint32(66).fork()).ldelim(); + } + if (message.proto3Optional === true) { + writer.uint32(136).bool(message.proto3Optional); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FieldDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFieldDescriptorProto } as FieldDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 3: + message.number = reader.int32(); + break; + case 4: + message.label = reader.int32() as any; + break; + case 5: + message.type = reader.int32() as any; + break; + case 6: + message.typeName = reader.string(); + break; + case 2: + message.extendee = reader.string(); + break; + case 7: + message.defaultValue = reader.string(); + break; + case 9: + message.oneofIndex = reader.int32(); + break; + case 10: + message.jsonName = reader.string(); + break; + case 8: + message.options = FieldOptions.decode(reader, reader.uint32()); + break; + case 17: + message.proto3Optional = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FieldDescriptorProto { + const message = { ...baseFieldDescriptorProto } as FieldDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = Number(object.number); + } else { + message.number = 0; + } + if (object.label !== undefined && object.label !== null) { + message.label = fieldDescriptorProto_LabelFromJSON(object.label); + } else { + message.label = 1; + } + if (object.type !== undefined && object.type !== null) { + message.type = fieldDescriptorProto_TypeFromJSON(object.type); + } else { + message.type = 1; + } + if (object.typeName !== undefined && object.typeName !== null) { + message.typeName = String(object.typeName); + } else { + message.typeName = ""; + } + if (object.extendee !== undefined && object.extendee !== null) { + message.extendee = String(object.extendee); + } else { + message.extendee = ""; + } + if (object.defaultValue !== undefined && object.defaultValue !== null) { + message.defaultValue = String(object.defaultValue); + } else { + message.defaultValue = ""; + } + if (object.oneofIndex !== undefined && object.oneofIndex !== null) { + message.oneofIndex = Number(object.oneofIndex); + } else { + message.oneofIndex = 0; + } + if (object.jsonName !== undefined && object.jsonName !== null) { + message.jsonName = String(object.jsonName); + } else { + message.jsonName = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = FieldOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.proto3Optional !== undefined && object.proto3Optional !== null) { + message.proto3Optional = Boolean(object.proto3Optional); + } else { + message.proto3Optional = false; + } + return message; + }, + + toJSON(message: FieldDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.number !== undefined && (obj.number = message.number); + message.label !== undefined && + (obj.label = fieldDescriptorProto_LabelToJSON(message.label)); + message.type !== undefined && + (obj.type = fieldDescriptorProto_TypeToJSON(message.type)); + message.typeName !== undefined && (obj.typeName = message.typeName); + message.extendee !== undefined && (obj.extendee = message.extendee); + message.defaultValue !== undefined && + (obj.defaultValue = message.defaultValue); + message.oneofIndex !== undefined && (obj.oneofIndex = message.oneofIndex); + message.jsonName !== undefined && (obj.jsonName = message.jsonName); + message.options !== undefined && + (obj.options = message.options + ? FieldOptions.toJSON(message.options) + : undefined); + message.proto3Optional !== undefined && + (obj.proto3Optional = message.proto3Optional); + return obj; + }, + + fromPartial(object: DeepPartial): FieldDescriptorProto { + const message = { ...baseFieldDescriptorProto } as FieldDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = object.number; + } else { + message.number = 0; + } + if (object.label !== undefined && object.label !== null) { + message.label = object.label; + } else { + message.label = 1; + } + if (object.type !== undefined && object.type !== null) { + message.type = object.type; + } else { + message.type = 1; + } + if (object.typeName !== undefined && object.typeName !== null) { + message.typeName = object.typeName; + } else { + message.typeName = ""; + } + if (object.extendee !== undefined && object.extendee !== null) { + message.extendee = object.extendee; + } else { + message.extendee = ""; + } + if (object.defaultValue !== undefined && object.defaultValue !== null) { + message.defaultValue = object.defaultValue; + } else { + message.defaultValue = ""; + } + if (object.oneofIndex !== undefined && object.oneofIndex !== null) { + message.oneofIndex = object.oneofIndex; + } else { + message.oneofIndex = 0; + } + if (object.jsonName !== undefined && object.jsonName !== null) { + message.jsonName = object.jsonName; + } else { + message.jsonName = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = FieldOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.proto3Optional !== undefined && object.proto3Optional !== null) { + message.proto3Optional = object.proto3Optional; + } else { + message.proto3Optional = false; + } + return message; + }, +}; + +const baseOneofDescriptorProto: object = { name: "" }; + +export const OneofDescriptorProto = { + encode( + message: OneofDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.options !== undefined) { + OneofOptions.encode(message.options, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): OneofDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseOneofDescriptorProto } as OneofDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.options = OneofOptions.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): OneofDescriptorProto { + const message = { ...baseOneofDescriptorProto } as OneofDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = OneofOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: OneofDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.options !== undefined && + (obj.options = message.options + ? OneofOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): OneofDescriptorProto { + const message = { ...baseOneofDescriptorProto } as OneofDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = OneofOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseEnumDescriptorProto: object = { name: "", reservedName: "" }; + +export const EnumDescriptorProto = { + encode( + message: EnumDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + for (const v of message.value) { + EnumValueDescriptorProto.encode(v!, writer.uint32(18).fork()).ldelim(); + } + if (message.options !== undefined) { + EnumOptions.encode(message.options, writer.uint32(26).fork()).ldelim(); + } + for (const v of message.reservedRange) { + EnumDescriptorProto_EnumReservedRange.encode( + v!, + writer.uint32(34).fork() + ).ldelim(); + } + for (const v of message.reservedName) { + writer.uint32(42).string(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): EnumDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseEnumDescriptorProto } as EnumDescriptorProto; + message.value = []; + message.reservedRange = []; + message.reservedName = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.value.push( + EnumValueDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 3: + message.options = EnumOptions.decode(reader, reader.uint32()); + break; + case 4: + message.reservedRange.push( + EnumDescriptorProto_EnumReservedRange.decode( + reader, + reader.uint32() + ) + ); + break; + case 5: + message.reservedName.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumDescriptorProto { + const message = { ...baseEnumDescriptorProto } as EnumDescriptorProto; + message.value = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.value !== undefined && object.value !== null) { + for (const e of object.value) { + message.value.push(EnumValueDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push( + EnumDescriptorProto_EnumReservedRange.fromJSON(e) + ); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(String(e)); + } + } + return message; + }, + + toJSON(message: EnumDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + if (message.value) { + obj.value = message.value.map((e) => + e ? EnumValueDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.value = []; + } + message.options !== undefined && + (obj.options = message.options + ? EnumOptions.toJSON(message.options) + : undefined); + if (message.reservedRange) { + obj.reservedRange = message.reservedRange.map((e) => + e ? EnumDescriptorProto_EnumReservedRange.toJSON(e) : undefined + ); + } else { + obj.reservedRange = []; + } + if (message.reservedName) { + obj.reservedName = message.reservedName.map((e) => e); + } else { + obj.reservedName = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): EnumDescriptorProto { + const message = { ...baseEnumDescriptorProto } as EnumDescriptorProto; + message.value = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.value !== undefined && object.value !== null) { + for (const e of object.value) { + message.value.push(EnumValueDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push( + EnumDescriptorProto_EnumReservedRange.fromPartial(e) + ); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(e); + } + } + return message; + }, +}; + +const baseEnumDescriptorProto_EnumReservedRange: object = { start: 0, end: 0 }; + +export const EnumDescriptorProto_EnumReservedRange = { + encode( + message: EnumDescriptorProto_EnumReservedRange, + writer: Writer = Writer.create() + ): Writer { + if (message.start !== 0) { + writer.uint32(8).int32(message.start); + } + if (message.end !== 0) { + writer.uint32(16).int32(message.end); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): EnumDescriptorProto_EnumReservedRange { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseEnumDescriptorProto_EnumReservedRange, + } as EnumDescriptorProto_EnumReservedRange; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.start = reader.int32(); + break; + case 2: + message.end = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumDescriptorProto_EnumReservedRange { + const message = { + ...baseEnumDescriptorProto_EnumReservedRange, + } as EnumDescriptorProto_EnumReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = Number(object.start); + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + return message; + }, + + toJSON(message: EnumDescriptorProto_EnumReservedRange): unknown { + const obj: any = {}; + message.start !== undefined && (obj.start = message.start); + message.end !== undefined && (obj.end = message.end); + return obj; + }, + + fromPartial( + object: DeepPartial + ): EnumDescriptorProto_EnumReservedRange { + const message = { + ...baseEnumDescriptorProto_EnumReservedRange, + } as EnumDescriptorProto_EnumReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = object.start; + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + return message; + }, +}; + +const baseEnumValueDescriptorProto: object = { name: "", number: 0 }; + +export const EnumValueDescriptorProto = { + encode( + message: EnumValueDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.number !== 0) { + writer.uint32(16).int32(message.number); + } + if (message.options !== undefined) { + EnumValueOptions.encode( + message.options, + writer.uint32(26).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): EnumValueDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseEnumValueDescriptorProto, + } as EnumValueDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.number = reader.int32(); + break; + case 3: + message.options = EnumValueOptions.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumValueDescriptorProto { + const message = { + ...baseEnumValueDescriptorProto, + } as EnumValueDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = Number(object.number); + } else { + message.number = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumValueOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: EnumValueDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.number !== undefined && (obj.number = message.number); + message.options !== undefined && + (obj.options = message.options + ? EnumValueOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): EnumValueDescriptorProto { + const message = { + ...baseEnumValueDescriptorProto, + } as EnumValueDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = object.number; + } else { + message.number = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumValueOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseServiceDescriptorProto: object = { name: "" }; + +export const ServiceDescriptorProto = { + encode( + message: ServiceDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + for (const v of message.method) { + MethodDescriptorProto.encode(v!, writer.uint32(18).fork()).ldelim(); + } + if (message.options !== undefined) { + ServiceOptions.encode(message.options, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ServiceDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseServiceDescriptorProto } as ServiceDescriptorProto; + message.method = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.method.push( + MethodDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 3: + message.options = ServiceOptions.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ServiceDescriptorProto { + const message = { ...baseServiceDescriptorProto } as ServiceDescriptorProto; + message.method = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.method !== undefined && object.method !== null) { + for (const e of object.method) { + message.method.push(MethodDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = ServiceOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: ServiceDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + if (message.method) { + obj.method = message.method.map((e) => + e ? MethodDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.method = []; + } + message.options !== undefined && + (obj.options = message.options + ? ServiceOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): ServiceDescriptorProto { + const message = { ...baseServiceDescriptorProto } as ServiceDescriptorProto; + message.method = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.method !== undefined && object.method !== null) { + for (const e of object.method) { + message.method.push(MethodDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = ServiceOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseMethodDescriptorProto: object = { + name: "", + inputType: "", + outputType: "", + clientStreaming: false, + serverStreaming: false, +}; + +export const MethodDescriptorProto = { + encode( + message: MethodDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.inputType !== "") { + writer.uint32(18).string(message.inputType); + } + if (message.outputType !== "") { + writer.uint32(26).string(message.outputType); + } + if (message.options !== undefined) { + MethodOptions.encode(message.options, writer.uint32(34).fork()).ldelim(); + } + if (message.clientStreaming === true) { + writer.uint32(40).bool(message.clientStreaming); + } + if (message.serverStreaming === true) { + writer.uint32(48).bool(message.serverStreaming); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MethodDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMethodDescriptorProto } as MethodDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.inputType = reader.string(); + break; + case 3: + message.outputType = reader.string(); + break; + case 4: + message.options = MethodOptions.decode(reader, reader.uint32()); + break; + case 5: + message.clientStreaming = reader.bool(); + break; + case 6: + message.serverStreaming = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MethodDescriptorProto { + const message = { ...baseMethodDescriptorProto } as MethodDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.inputType !== undefined && object.inputType !== null) { + message.inputType = String(object.inputType); + } else { + message.inputType = ""; + } + if (object.outputType !== undefined && object.outputType !== null) { + message.outputType = String(object.outputType); + } else { + message.outputType = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = MethodOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if ( + object.clientStreaming !== undefined && + object.clientStreaming !== null + ) { + message.clientStreaming = Boolean(object.clientStreaming); + } else { + message.clientStreaming = false; + } + if ( + object.serverStreaming !== undefined && + object.serverStreaming !== null + ) { + message.serverStreaming = Boolean(object.serverStreaming); + } else { + message.serverStreaming = false; + } + return message; + }, + + toJSON(message: MethodDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.inputType !== undefined && (obj.inputType = message.inputType); + message.outputType !== undefined && (obj.outputType = message.outputType); + message.options !== undefined && + (obj.options = message.options + ? MethodOptions.toJSON(message.options) + : undefined); + message.clientStreaming !== undefined && + (obj.clientStreaming = message.clientStreaming); + message.serverStreaming !== undefined && + (obj.serverStreaming = message.serverStreaming); + return obj; + }, + + fromPartial( + object: DeepPartial + ): MethodDescriptorProto { + const message = { ...baseMethodDescriptorProto } as MethodDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.inputType !== undefined && object.inputType !== null) { + message.inputType = object.inputType; + } else { + message.inputType = ""; + } + if (object.outputType !== undefined && object.outputType !== null) { + message.outputType = object.outputType; + } else { + message.outputType = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = MethodOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if ( + object.clientStreaming !== undefined && + object.clientStreaming !== null + ) { + message.clientStreaming = object.clientStreaming; + } else { + message.clientStreaming = false; + } + if ( + object.serverStreaming !== undefined && + object.serverStreaming !== null + ) { + message.serverStreaming = object.serverStreaming; + } else { + message.serverStreaming = false; + } + return message; + }, +}; + +const baseFileOptions: object = { + javaPackage: "", + javaOuterClassname: "", + javaMultipleFiles: false, + javaGenerateEqualsAndHash: false, + javaStringCheckUtf8: false, + optimizeFor: 1, + goPackage: "", + ccGenericServices: false, + javaGenericServices: false, + pyGenericServices: false, + phpGenericServices: false, + deprecated: false, + ccEnableArenas: false, + objcClassPrefix: "", + csharpNamespace: "", + swiftPrefix: "", + phpClassPrefix: "", + phpNamespace: "", + phpMetadataNamespace: "", + rubyPackage: "", +}; + +export const FileOptions = { + encode(message: FileOptions, writer: Writer = Writer.create()): Writer { + if (message.javaPackage !== "") { + writer.uint32(10).string(message.javaPackage); + } + if (message.javaOuterClassname !== "") { + writer.uint32(66).string(message.javaOuterClassname); + } + if (message.javaMultipleFiles === true) { + writer.uint32(80).bool(message.javaMultipleFiles); + } + if (message.javaGenerateEqualsAndHash === true) { + writer.uint32(160).bool(message.javaGenerateEqualsAndHash); + } + if (message.javaStringCheckUtf8 === true) { + writer.uint32(216).bool(message.javaStringCheckUtf8); + } + if (message.optimizeFor !== 1) { + writer.uint32(72).int32(message.optimizeFor); + } + if (message.goPackage !== "") { + writer.uint32(90).string(message.goPackage); + } + if (message.ccGenericServices === true) { + writer.uint32(128).bool(message.ccGenericServices); + } + if (message.javaGenericServices === true) { + writer.uint32(136).bool(message.javaGenericServices); + } + if (message.pyGenericServices === true) { + writer.uint32(144).bool(message.pyGenericServices); + } + if (message.phpGenericServices === true) { + writer.uint32(336).bool(message.phpGenericServices); + } + if (message.deprecated === true) { + writer.uint32(184).bool(message.deprecated); + } + if (message.ccEnableArenas === true) { + writer.uint32(248).bool(message.ccEnableArenas); + } + if (message.objcClassPrefix !== "") { + writer.uint32(290).string(message.objcClassPrefix); + } + if (message.csharpNamespace !== "") { + writer.uint32(298).string(message.csharpNamespace); + } + if (message.swiftPrefix !== "") { + writer.uint32(314).string(message.swiftPrefix); + } + if (message.phpClassPrefix !== "") { + writer.uint32(322).string(message.phpClassPrefix); + } + if (message.phpNamespace !== "") { + writer.uint32(330).string(message.phpNamespace); + } + if (message.phpMetadataNamespace !== "") { + writer.uint32(354).string(message.phpMetadataNamespace); + } + if (message.rubyPackage !== "") { + writer.uint32(362).string(message.rubyPackage); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FileOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFileOptions } as FileOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.javaPackage = reader.string(); + break; + case 8: + message.javaOuterClassname = reader.string(); + break; + case 10: + message.javaMultipleFiles = reader.bool(); + break; + case 20: + message.javaGenerateEqualsAndHash = reader.bool(); + break; + case 27: + message.javaStringCheckUtf8 = reader.bool(); + break; + case 9: + message.optimizeFor = reader.int32() as any; + break; + case 11: + message.goPackage = reader.string(); + break; + case 16: + message.ccGenericServices = reader.bool(); + break; + case 17: + message.javaGenericServices = reader.bool(); + break; + case 18: + message.pyGenericServices = reader.bool(); + break; + case 42: + message.phpGenericServices = reader.bool(); + break; + case 23: + message.deprecated = reader.bool(); + break; + case 31: + message.ccEnableArenas = reader.bool(); + break; + case 36: + message.objcClassPrefix = reader.string(); + break; + case 37: + message.csharpNamespace = reader.string(); + break; + case 39: + message.swiftPrefix = reader.string(); + break; + case 40: + message.phpClassPrefix = reader.string(); + break; + case 41: + message.phpNamespace = reader.string(); + break; + case 44: + message.phpMetadataNamespace = reader.string(); + break; + case 45: + message.rubyPackage = reader.string(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FileOptions { + const message = { ...baseFileOptions } as FileOptions; + message.uninterpretedOption = []; + if (object.javaPackage !== undefined && object.javaPackage !== null) { + message.javaPackage = String(object.javaPackage); + } else { + message.javaPackage = ""; + } + if ( + object.javaOuterClassname !== undefined && + object.javaOuterClassname !== null + ) { + message.javaOuterClassname = String(object.javaOuterClassname); + } else { + message.javaOuterClassname = ""; + } + if ( + object.javaMultipleFiles !== undefined && + object.javaMultipleFiles !== null + ) { + message.javaMultipleFiles = Boolean(object.javaMultipleFiles); + } else { + message.javaMultipleFiles = false; + } + if ( + object.javaGenerateEqualsAndHash !== undefined && + object.javaGenerateEqualsAndHash !== null + ) { + message.javaGenerateEqualsAndHash = Boolean( + object.javaGenerateEqualsAndHash + ); + } else { + message.javaGenerateEqualsAndHash = false; + } + if ( + object.javaStringCheckUtf8 !== undefined && + object.javaStringCheckUtf8 !== null + ) { + message.javaStringCheckUtf8 = Boolean(object.javaStringCheckUtf8); + } else { + message.javaStringCheckUtf8 = false; + } + if (object.optimizeFor !== undefined && object.optimizeFor !== null) { + message.optimizeFor = fileOptions_OptimizeModeFromJSON( + object.optimizeFor + ); + } else { + message.optimizeFor = 1; + } + if (object.goPackage !== undefined && object.goPackage !== null) { + message.goPackage = String(object.goPackage); + } else { + message.goPackage = ""; + } + if ( + object.ccGenericServices !== undefined && + object.ccGenericServices !== null + ) { + message.ccGenericServices = Boolean(object.ccGenericServices); + } else { + message.ccGenericServices = false; + } + if ( + object.javaGenericServices !== undefined && + object.javaGenericServices !== null + ) { + message.javaGenericServices = Boolean(object.javaGenericServices); + } else { + message.javaGenericServices = false; + } + if ( + object.pyGenericServices !== undefined && + object.pyGenericServices !== null + ) { + message.pyGenericServices = Boolean(object.pyGenericServices); + } else { + message.pyGenericServices = false; + } + if ( + object.phpGenericServices !== undefined && + object.phpGenericServices !== null + ) { + message.phpGenericServices = Boolean(object.phpGenericServices); + } else { + message.phpGenericServices = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if (object.ccEnableArenas !== undefined && object.ccEnableArenas !== null) { + message.ccEnableArenas = Boolean(object.ccEnableArenas); + } else { + message.ccEnableArenas = false; + } + if ( + object.objcClassPrefix !== undefined && + object.objcClassPrefix !== null + ) { + message.objcClassPrefix = String(object.objcClassPrefix); + } else { + message.objcClassPrefix = ""; + } + if ( + object.csharpNamespace !== undefined && + object.csharpNamespace !== null + ) { + message.csharpNamespace = String(object.csharpNamespace); + } else { + message.csharpNamespace = ""; + } + if (object.swiftPrefix !== undefined && object.swiftPrefix !== null) { + message.swiftPrefix = String(object.swiftPrefix); + } else { + message.swiftPrefix = ""; + } + if (object.phpClassPrefix !== undefined && object.phpClassPrefix !== null) { + message.phpClassPrefix = String(object.phpClassPrefix); + } else { + message.phpClassPrefix = ""; + } + if (object.phpNamespace !== undefined && object.phpNamespace !== null) { + message.phpNamespace = String(object.phpNamespace); + } else { + message.phpNamespace = ""; + } + if ( + object.phpMetadataNamespace !== undefined && + object.phpMetadataNamespace !== null + ) { + message.phpMetadataNamespace = String(object.phpMetadataNamespace); + } else { + message.phpMetadataNamespace = ""; + } + if (object.rubyPackage !== undefined && object.rubyPackage !== null) { + message.rubyPackage = String(object.rubyPackage); + } else { + message.rubyPackage = ""; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: FileOptions): unknown { + const obj: any = {}; + message.javaPackage !== undefined && + (obj.javaPackage = message.javaPackage); + message.javaOuterClassname !== undefined && + (obj.javaOuterClassname = message.javaOuterClassname); + message.javaMultipleFiles !== undefined && + (obj.javaMultipleFiles = message.javaMultipleFiles); + message.javaGenerateEqualsAndHash !== undefined && + (obj.javaGenerateEqualsAndHash = message.javaGenerateEqualsAndHash); + message.javaStringCheckUtf8 !== undefined && + (obj.javaStringCheckUtf8 = message.javaStringCheckUtf8); + message.optimizeFor !== undefined && + (obj.optimizeFor = fileOptions_OptimizeModeToJSON(message.optimizeFor)); + message.goPackage !== undefined && (obj.goPackage = message.goPackage); + message.ccGenericServices !== undefined && + (obj.ccGenericServices = message.ccGenericServices); + message.javaGenericServices !== undefined && + (obj.javaGenericServices = message.javaGenericServices); + message.pyGenericServices !== undefined && + (obj.pyGenericServices = message.pyGenericServices); + message.phpGenericServices !== undefined && + (obj.phpGenericServices = message.phpGenericServices); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.ccEnableArenas !== undefined && + (obj.ccEnableArenas = message.ccEnableArenas); + message.objcClassPrefix !== undefined && + (obj.objcClassPrefix = message.objcClassPrefix); + message.csharpNamespace !== undefined && + (obj.csharpNamespace = message.csharpNamespace); + message.swiftPrefix !== undefined && + (obj.swiftPrefix = message.swiftPrefix); + message.phpClassPrefix !== undefined && + (obj.phpClassPrefix = message.phpClassPrefix); + message.phpNamespace !== undefined && + (obj.phpNamespace = message.phpNamespace); + message.phpMetadataNamespace !== undefined && + (obj.phpMetadataNamespace = message.phpMetadataNamespace); + message.rubyPackage !== undefined && + (obj.rubyPackage = message.rubyPackage); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): FileOptions { + const message = { ...baseFileOptions } as FileOptions; + message.uninterpretedOption = []; + if (object.javaPackage !== undefined && object.javaPackage !== null) { + message.javaPackage = object.javaPackage; + } else { + message.javaPackage = ""; + } + if ( + object.javaOuterClassname !== undefined && + object.javaOuterClassname !== null + ) { + message.javaOuterClassname = object.javaOuterClassname; + } else { + message.javaOuterClassname = ""; + } + if ( + object.javaMultipleFiles !== undefined && + object.javaMultipleFiles !== null + ) { + message.javaMultipleFiles = object.javaMultipleFiles; + } else { + message.javaMultipleFiles = false; + } + if ( + object.javaGenerateEqualsAndHash !== undefined && + object.javaGenerateEqualsAndHash !== null + ) { + message.javaGenerateEqualsAndHash = object.javaGenerateEqualsAndHash; + } else { + message.javaGenerateEqualsAndHash = false; + } + if ( + object.javaStringCheckUtf8 !== undefined && + object.javaStringCheckUtf8 !== null + ) { + message.javaStringCheckUtf8 = object.javaStringCheckUtf8; + } else { + message.javaStringCheckUtf8 = false; + } + if (object.optimizeFor !== undefined && object.optimizeFor !== null) { + message.optimizeFor = object.optimizeFor; + } else { + message.optimizeFor = 1; + } + if (object.goPackage !== undefined && object.goPackage !== null) { + message.goPackage = object.goPackage; + } else { + message.goPackage = ""; + } + if ( + object.ccGenericServices !== undefined && + object.ccGenericServices !== null + ) { + message.ccGenericServices = object.ccGenericServices; + } else { + message.ccGenericServices = false; + } + if ( + object.javaGenericServices !== undefined && + object.javaGenericServices !== null + ) { + message.javaGenericServices = object.javaGenericServices; + } else { + message.javaGenericServices = false; + } + if ( + object.pyGenericServices !== undefined && + object.pyGenericServices !== null + ) { + message.pyGenericServices = object.pyGenericServices; + } else { + message.pyGenericServices = false; + } + if ( + object.phpGenericServices !== undefined && + object.phpGenericServices !== null + ) { + message.phpGenericServices = object.phpGenericServices; + } else { + message.phpGenericServices = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if (object.ccEnableArenas !== undefined && object.ccEnableArenas !== null) { + message.ccEnableArenas = object.ccEnableArenas; + } else { + message.ccEnableArenas = false; + } + if ( + object.objcClassPrefix !== undefined && + object.objcClassPrefix !== null + ) { + message.objcClassPrefix = object.objcClassPrefix; + } else { + message.objcClassPrefix = ""; + } + if ( + object.csharpNamespace !== undefined && + object.csharpNamespace !== null + ) { + message.csharpNamespace = object.csharpNamespace; + } else { + message.csharpNamespace = ""; + } + if (object.swiftPrefix !== undefined && object.swiftPrefix !== null) { + message.swiftPrefix = object.swiftPrefix; + } else { + message.swiftPrefix = ""; + } + if (object.phpClassPrefix !== undefined && object.phpClassPrefix !== null) { + message.phpClassPrefix = object.phpClassPrefix; + } else { + message.phpClassPrefix = ""; + } + if (object.phpNamespace !== undefined && object.phpNamespace !== null) { + message.phpNamespace = object.phpNamespace; + } else { + message.phpNamespace = ""; + } + if ( + object.phpMetadataNamespace !== undefined && + object.phpMetadataNamespace !== null + ) { + message.phpMetadataNamespace = object.phpMetadataNamespace; + } else { + message.phpMetadataNamespace = ""; + } + if (object.rubyPackage !== undefined && object.rubyPackage !== null) { + message.rubyPackage = object.rubyPackage; + } else { + message.rubyPackage = ""; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseMessageOptions: object = { + messageSetWireFormat: false, + noStandardDescriptorAccessor: false, + deprecated: false, + mapEntry: false, +}; + +export const MessageOptions = { + encode(message: MessageOptions, writer: Writer = Writer.create()): Writer { + if (message.messageSetWireFormat === true) { + writer.uint32(8).bool(message.messageSetWireFormat); + } + if (message.noStandardDescriptorAccessor === true) { + writer.uint32(16).bool(message.noStandardDescriptorAccessor); + } + if (message.deprecated === true) { + writer.uint32(24).bool(message.deprecated); + } + if (message.mapEntry === true) { + writer.uint32(56).bool(message.mapEntry); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MessageOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMessageOptions } as MessageOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.messageSetWireFormat = reader.bool(); + break; + case 2: + message.noStandardDescriptorAccessor = reader.bool(); + break; + case 3: + message.deprecated = reader.bool(); + break; + case 7: + message.mapEntry = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MessageOptions { + const message = { ...baseMessageOptions } as MessageOptions; + message.uninterpretedOption = []; + if ( + object.messageSetWireFormat !== undefined && + object.messageSetWireFormat !== null + ) { + message.messageSetWireFormat = Boolean(object.messageSetWireFormat); + } else { + message.messageSetWireFormat = false; + } + if ( + object.noStandardDescriptorAccessor !== undefined && + object.noStandardDescriptorAccessor !== null + ) { + message.noStandardDescriptorAccessor = Boolean( + object.noStandardDescriptorAccessor + ); + } else { + message.noStandardDescriptorAccessor = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if (object.mapEntry !== undefined && object.mapEntry !== null) { + message.mapEntry = Boolean(object.mapEntry); + } else { + message.mapEntry = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: MessageOptions): unknown { + const obj: any = {}; + message.messageSetWireFormat !== undefined && + (obj.messageSetWireFormat = message.messageSetWireFormat); + message.noStandardDescriptorAccessor !== undefined && + (obj.noStandardDescriptorAccessor = message.noStandardDescriptorAccessor); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.mapEntry !== undefined && (obj.mapEntry = message.mapEntry); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): MessageOptions { + const message = { ...baseMessageOptions } as MessageOptions; + message.uninterpretedOption = []; + if ( + object.messageSetWireFormat !== undefined && + object.messageSetWireFormat !== null + ) { + message.messageSetWireFormat = object.messageSetWireFormat; + } else { + message.messageSetWireFormat = false; + } + if ( + object.noStandardDescriptorAccessor !== undefined && + object.noStandardDescriptorAccessor !== null + ) { + message.noStandardDescriptorAccessor = + object.noStandardDescriptorAccessor; + } else { + message.noStandardDescriptorAccessor = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if (object.mapEntry !== undefined && object.mapEntry !== null) { + message.mapEntry = object.mapEntry; + } else { + message.mapEntry = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseFieldOptions: object = { + ctype: 0, + packed: false, + jstype: 0, + lazy: false, + deprecated: false, + weak: false, +}; + +export const FieldOptions = { + encode(message: FieldOptions, writer: Writer = Writer.create()): Writer { + if (message.ctype !== 0) { + writer.uint32(8).int32(message.ctype); + } + if (message.packed === true) { + writer.uint32(16).bool(message.packed); + } + if (message.jstype !== 0) { + writer.uint32(48).int32(message.jstype); + } + if (message.lazy === true) { + writer.uint32(40).bool(message.lazy); + } + if (message.deprecated === true) { + writer.uint32(24).bool(message.deprecated); + } + if (message.weak === true) { + writer.uint32(80).bool(message.weak); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FieldOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFieldOptions } as FieldOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.ctype = reader.int32() as any; + break; + case 2: + message.packed = reader.bool(); + break; + case 6: + message.jstype = reader.int32() as any; + break; + case 5: + message.lazy = reader.bool(); + break; + case 3: + message.deprecated = reader.bool(); + break; + case 10: + message.weak = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FieldOptions { + const message = { ...baseFieldOptions } as FieldOptions; + message.uninterpretedOption = []; + if (object.ctype !== undefined && object.ctype !== null) { + message.ctype = fieldOptions_CTypeFromJSON(object.ctype); + } else { + message.ctype = 0; + } + if (object.packed !== undefined && object.packed !== null) { + message.packed = Boolean(object.packed); + } else { + message.packed = false; + } + if (object.jstype !== undefined && object.jstype !== null) { + message.jstype = fieldOptions_JSTypeFromJSON(object.jstype); + } else { + message.jstype = 0; + } + if (object.lazy !== undefined && object.lazy !== null) { + message.lazy = Boolean(object.lazy); + } else { + message.lazy = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if (object.weak !== undefined && object.weak !== null) { + message.weak = Boolean(object.weak); + } else { + message.weak = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: FieldOptions): unknown { + const obj: any = {}; + message.ctype !== undefined && + (obj.ctype = fieldOptions_CTypeToJSON(message.ctype)); + message.packed !== undefined && (obj.packed = message.packed); + message.jstype !== undefined && + (obj.jstype = fieldOptions_JSTypeToJSON(message.jstype)); + message.lazy !== undefined && (obj.lazy = message.lazy); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.weak !== undefined && (obj.weak = message.weak); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): FieldOptions { + const message = { ...baseFieldOptions } as FieldOptions; + message.uninterpretedOption = []; + if (object.ctype !== undefined && object.ctype !== null) { + message.ctype = object.ctype; + } else { + message.ctype = 0; + } + if (object.packed !== undefined && object.packed !== null) { + message.packed = object.packed; + } else { + message.packed = false; + } + if (object.jstype !== undefined && object.jstype !== null) { + message.jstype = object.jstype; + } else { + message.jstype = 0; + } + if (object.lazy !== undefined && object.lazy !== null) { + message.lazy = object.lazy; + } else { + message.lazy = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if (object.weak !== undefined && object.weak !== null) { + message.weak = object.weak; + } else { + message.weak = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseOneofOptions: object = {}; + +export const OneofOptions = { + encode(message: OneofOptions, writer: Writer = Writer.create()): Writer { + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): OneofOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseOneofOptions } as OneofOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): OneofOptions { + const message = { ...baseOneofOptions } as OneofOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: OneofOptions): unknown { + const obj: any = {}; + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): OneofOptions { + const message = { ...baseOneofOptions } as OneofOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseEnumOptions: object = { allowAlias: false, deprecated: false }; + +export const EnumOptions = { + encode(message: EnumOptions, writer: Writer = Writer.create()): Writer { + if (message.allowAlias === true) { + writer.uint32(16).bool(message.allowAlias); + } + if (message.deprecated === true) { + writer.uint32(24).bool(message.deprecated); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): EnumOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseEnumOptions } as EnumOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + message.allowAlias = reader.bool(); + break; + case 3: + message.deprecated = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumOptions { + const message = { ...baseEnumOptions } as EnumOptions; + message.uninterpretedOption = []; + if (object.allowAlias !== undefined && object.allowAlias !== null) { + message.allowAlias = Boolean(object.allowAlias); + } else { + message.allowAlias = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: EnumOptions): unknown { + const obj: any = {}; + message.allowAlias !== undefined && (obj.allowAlias = message.allowAlias); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): EnumOptions { + const message = { ...baseEnumOptions } as EnumOptions; + message.uninterpretedOption = []; + if (object.allowAlias !== undefined && object.allowAlias !== null) { + message.allowAlias = object.allowAlias; + } else { + message.allowAlias = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseEnumValueOptions: object = { deprecated: false }; + +export const EnumValueOptions = { + encode(message: EnumValueOptions, writer: Writer = Writer.create()): Writer { + if (message.deprecated === true) { + writer.uint32(8).bool(message.deprecated); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): EnumValueOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseEnumValueOptions } as EnumValueOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.deprecated = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumValueOptions { + const message = { ...baseEnumValueOptions } as EnumValueOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: EnumValueOptions): unknown { + const obj: any = {}; + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): EnumValueOptions { + const message = { ...baseEnumValueOptions } as EnumValueOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseServiceOptions: object = { deprecated: false }; + +export const ServiceOptions = { + encode(message: ServiceOptions, writer: Writer = Writer.create()): Writer { + if (message.deprecated === true) { + writer.uint32(264).bool(message.deprecated); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ServiceOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseServiceOptions } as ServiceOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 33: + message.deprecated = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ServiceOptions { + const message = { ...baseServiceOptions } as ServiceOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: ServiceOptions): unknown { + const obj: any = {}; + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): ServiceOptions { + const message = { ...baseServiceOptions } as ServiceOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseMethodOptions: object = { deprecated: false, idempotencyLevel: 0 }; + +export const MethodOptions = { + encode(message: MethodOptions, writer: Writer = Writer.create()): Writer { + if (message.deprecated === true) { + writer.uint32(264).bool(message.deprecated); + } + if (message.idempotencyLevel !== 0) { + writer.uint32(272).int32(message.idempotencyLevel); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MethodOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMethodOptions } as MethodOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 33: + message.deprecated = reader.bool(); + break; + case 34: + message.idempotencyLevel = reader.int32() as any; + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MethodOptions { + const message = { ...baseMethodOptions } as MethodOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.idempotencyLevel !== undefined && + object.idempotencyLevel !== null + ) { + message.idempotencyLevel = methodOptions_IdempotencyLevelFromJSON( + object.idempotencyLevel + ); + } else { + message.idempotencyLevel = 0; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: MethodOptions): unknown { + const obj: any = {}; + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.idempotencyLevel !== undefined && + (obj.idempotencyLevel = methodOptions_IdempotencyLevelToJSON( + message.idempotencyLevel + )); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): MethodOptions { + const message = { ...baseMethodOptions } as MethodOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.idempotencyLevel !== undefined && + object.idempotencyLevel !== null + ) { + message.idempotencyLevel = object.idempotencyLevel; + } else { + message.idempotencyLevel = 0; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseUninterpretedOption: object = { + identifierValue: "", + positiveIntValue: 0, + negativeIntValue: 0, + doubleValue: 0, + aggregateValue: "", +}; + +export const UninterpretedOption = { + encode( + message: UninterpretedOption, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.name) { + UninterpretedOption_NamePart.encode( + v!, + writer.uint32(18).fork() + ).ldelim(); + } + if (message.identifierValue !== "") { + writer.uint32(26).string(message.identifierValue); + } + if (message.positiveIntValue !== 0) { + writer.uint32(32).uint64(message.positiveIntValue); + } + if (message.negativeIntValue !== 0) { + writer.uint32(40).int64(message.negativeIntValue); + } + if (message.doubleValue !== 0) { + writer.uint32(49).double(message.doubleValue); + } + if (message.stringValue.length !== 0) { + writer.uint32(58).bytes(message.stringValue); + } + if (message.aggregateValue !== "") { + writer.uint32(66).string(message.aggregateValue); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): UninterpretedOption { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseUninterpretedOption } as UninterpretedOption; + message.name = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + message.name.push( + UninterpretedOption_NamePart.decode(reader, reader.uint32()) + ); + break; + case 3: + message.identifierValue = reader.string(); + break; + case 4: + message.positiveIntValue = longToNumber(reader.uint64() as Long); + break; + case 5: + message.negativeIntValue = longToNumber(reader.int64() as Long); + break; + case 6: + message.doubleValue = reader.double(); + break; + case 7: + message.stringValue = reader.bytes(); + break; + case 8: + message.aggregateValue = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): UninterpretedOption { + const message = { ...baseUninterpretedOption } as UninterpretedOption; + message.name = []; + if (object.name !== undefined && object.name !== null) { + for (const e of object.name) { + message.name.push(UninterpretedOption_NamePart.fromJSON(e)); + } + } + if ( + object.identifierValue !== undefined && + object.identifierValue !== null + ) { + message.identifierValue = String(object.identifierValue); + } else { + message.identifierValue = ""; + } + if ( + object.positiveIntValue !== undefined && + object.positiveIntValue !== null + ) { + message.positiveIntValue = Number(object.positiveIntValue); + } else { + message.positiveIntValue = 0; + } + if ( + object.negativeIntValue !== undefined && + object.negativeIntValue !== null + ) { + message.negativeIntValue = Number(object.negativeIntValue); + } else { + message.negativeIntValue = 0; + } + if (object.doubleValue !== undefined && object.doubleValue !== null) { + message.doubleValue = Number(object.doubleValue); + } else { + message.doubleValue = 0; + } + if (object.stringValue !== undefined && object.stringValue !== null) { + message.stringValue = bytesFromBase64(object.stringValue); + } + if (object.aggregateValue !== undefined && object.aggregateValue !== null) { + message.aggregateValue = String(object.aggregateValue); + } else { + message.aggregateValue = ""; + } + return message; + }, + + toJSON(message: UninterpretedOption): unknown { + const obj: any = {}; + if (message.name) { + obj.name = message.name.map((e) => + e ? UninterpretedOption_NamePart.toJSON(e) : undefined + ); + } else { + obj.name = []; + } + message.identifierValue !== undefined && + (obj.identifierValue = message.identifierValue); + message.positiveIntValue !== undefined && + (obj.positiveIntValue = message.positiveIntValue); + message.negativeIntValue !== undefined && + (obj.negativeIntValue = message.negativeIntValue); + message.doubleValue !== undefined && + (obj.doubleValue = message.doubleValue); + message.stringValue !== undefined && + (obj.stringValue = base64FromBytes( + message.stringValue !== undefined + ? message.stringValue + : new Uint8Array() + )); + message.aggregateValue !== undefined && + (obj.aggregateValue = message.aggregateValue); + return obj; + }, + + fromPartial(object: DeepPartial): UninterpretedOption { + const message = { ...baseUninterpretedOption } as UninterpretedOption; + message.name = []; + if (object.name !== undefined && object.name !== null) { + for (const e of object.name) { + message.name.push(UninterpretedOption_NamePart.fromPartial(e)); + } + } + if ( + object.identifierValue !== undefined && + object.identifierValue !== null + ) { + message.identifierValue = object.identifierValue; + } else { + message.identifierValue = ""; + } + if ( + object.positiveIntValue !== undefined && + object.positiveIntValue !== null + ) { + message.positiveIntValue = object.positiveIntValue; + } else { + message.positiveIntValue = 0; + } + if ( + object.negativeIntValue !== undefined && + object.negativeIntValue !== null + ) { + message.negativeIntValue = object.negativeIntValue; + } else { + message.negativeIntValue = 0; + } + if (object.doubleValue !== undefined && object.doubleValue !== null) { + message.doubleValue = object.doubleValue; + } else { + message.doubleValue = 0; + } + if (object.stringValue !== undefined && object.stringValue !== null) { + message.stringValue = object.stringValue; + } else { + message.stringValue = new Uint8Array(); + } + if (object.aggregateValue !== undefined && object.aggregateValue !== null) { + message.aggregateValue = object.aggregateValue; + } else { + message.aggregateValue = ""; + } + return message; + }, +}; + +const baseUninterpretedOption_NamePart: object = { + namePart: "", + isExtension: false, +}; + +export const UninterpretedOption_NamePart = { + encode( + message: UninterpretedOption_NamePart, + writer: Writer = Writer.create() + ): Writer { + if (message.namePart !== "") { + writer.uint32(10).string(message.namePart); + } + if (message.isExtension === true) { + writer.uint32(16).bool(message.isExtension); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): UninterpretedOption_NamePart { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseUninterpretedOption_NamePart, + } as UninterpretedOption_NamePart; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.namePart = reader.string(); + break; + case 2: + message.isExtension = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): UninterpretedOption_NamePart { + const message = { + ...baseUninterpretedOption_NamePart, + } as UninterpretedOption_NamePart; + if (object.namePart !== undefined && object.namePart !== null) { + message.namePart = String(object.namePart); + } else { + message.namePart = ""; + } + if (object.isExtension !== undefined && object.isExtension !== null) { + message.isExtension = Boolean(object.isExtension); + } else { + message.isExtension = false; + } + return message; + }, + + toJSON(message: UninterpretedOption_NamePart): unknown { + const obj: any = {}; + message.namePart !== undefined && (obj.namePart = message.namePart); + message.isExtension !== undefined && + (obj.isExtension = message.isExtension); + return obj; + }, + + fromPartial( + object: DeepPartial + ): UninterpretedOption_NamePart { + const message = { + ...baseUninterpretedOption_NamePart, + } as UninterpretedOption_NamePart; + if (object.namePart !== undefined && object.namePart !== null) { + message.namePart = object.namePart; + } else { + message.namePart = ""; + } + if (object.isExtension !== undefined && object.isExtension !== null) { + message.isExtension = object.isExtension; + } else { + message.isExtension = false; + } + return message; + }, +}; + +const baseSourceCodeInfo: object = {}; + +export const SourceCodeInfo = { + encode(message: SourceCodeInfo, writer: Writer = Writer.create()): Writer { + for (const v of message.location) { + SourceCodeInfo_Location.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): SourceCodeInfo { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseSourceCodeInfo } as SourceCodeInfo; + message.location = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.location.push( + SourceCodeInfo_Location.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): SourceCodeInfo { + const message = { ...baseSourceCodeInfo } as SourceCodeInfo; + message.location = []; + if (object.location !== undefined && object.location !== null) { + for (const e of object.location) { + message.location.push(SourceCodeInfo_Location.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: SourceCodeInfo): unknown { + const obj: any = {}; + if (message.location) { + obj.location = message.location.map((e) => + e ? SourceCodeInfo_Location.toJSON(e) : undefined + ); + } else { + obj.location = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): SourceCodeInfo { + const message = { ...baseSourceCodeInfo } as SourceCodeInfo; + message.location = []; + if (object.location !== undefined && object.location !== null) { + for (const e of object.location) { + message.location.push(SourceCodeInfo_Location.fromPartial(e)); + } + } + return message; + }, +}; + +const baseSourceCodeInfo_Location: object = { + path: 0, + span: 0, + leadingComments: "", + trailingComments: "", + leadingDetachedComments: "", +}; + +export const SourceCodeInfo_Location = { + encode( + message: SourceCodeInfo_Location, + writer: Writer = Writer.create() + ): Writer { + writer.uint32(10).fork(); + for (const v of message.path) { + writer.int32(v); + } + writer.ldelim(); + writer.uint32(18).fork(); + for (const v of message.span) { + writer.int32(v); + } + writer.ldelim(); + if (message.leadingComments !== "") { + writer.uint32(26).string(message.leadingComments); + } + if (message.trailingComments !== "") { + writer.uint32(34).string(message.trailingComments); + } + for (const v of message.leadingDetachedComments) { + writer.uint32(50).string(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): SourceCodeInfo_Location { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseSourceCodeInfo_Location, + } as SourceCodeInfo_Location; + message.path = []; + message.span = []; + message.leadingDetachedComments = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.path.push(reader.int32()); + } + } else { + message.path.push(reader.int32()); + } + break; + case 2: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.span.push(reader.int32()); + } + } else { + message.span.push(reader.int32()); + } + break; + case 3: + message.leadingComments = reader.string(); + break; + case 4: + message.trailingComments = reader.string(); + break; + case 6: + message.leadingDetachedComments.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): SourceCodeInfo_Location { + const message = { + ...baseSourceCodeInfo_Location, + } as SourceCodeInfo_Location; + message.path = []; + message.span = []; + message.leadingDetachedComments = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(Number(e)); + } + } + if (object.span !== undefined && object.span !== null) { + for (const e of object.span) { + message.span.push(Number(e)); + } + } + if ( + object.leadingComments !== undefined && + object.leadingComments !== null + ) { + message.leadingComments = String(object.leadingComments); + } else { + message.leadingComments = ""; + } + if ( + object.trailingComments !== undefined && + object.trailingComments !== null + ) { + message.trailingComments = String(object.trailingComments); + } else { + message.trailingComments = ""; + } + if ( + object.leadingDetachedComments !== undefined && + object.leadingDetachedComments !== null + ) { + for (const e of object.leadingDetachedComments) { + message.leadingDetachedComments.push(String(e)); + } + } + return message; + }, + + toJSON(message: SourceCodeInfo_Location): unknown { + const obj: any = {}; + if (message.path) { + obj.path = message.path.map((e) => e); + } else { + obj.path = []; + } + if (message.span) { + obj.span = message.span.map((e) => e); + } else { + obj.span = []; + } + message.leadingComments !== undefined && + (obj.leadingComments = message.leadingComments); + message.trailingComments !== undefined && + (obj.trailingComments = message.trailingComments); + if (message.leadingDetachedComments) { + obj.leadingDetachedComments = message.leadingDetachedComments.map( + (e) => e + ); + } else { + obj.leadingDetachedComments = []; + } + return obj; + }, + + fromPartial( + object: DeepPartial + ): SourceCodeInfo_Location { + const message = { + ...baseSourceCodeInfo_Location, + } as SourceCodeInfo_Location; + message.path = []; + message.span = []; + message.leadingDetachedComments = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(e); + } + } + if (object.span !== undefined && object.span !== null) { + for (const e of object.span) { + message.span.push(e); + } + } + if ( + object.leadingComments !== undefined && + object.leadingComments !== null + ) { + message.leadingComments = object.leadingComments; + } else { + message.leadingComments = ""; + } + if ( + object.trailingComments !== undefined && + object.trailingComments !== null + ) { + message.trailingComments = object.trailingComments; + } else { + message.trailingComments = ""; + } + if ( + object.leadingDetachedComments !== undefined && + object.leadingDetachedComments !== null + ) { + for (const e of object.leadingDetachedComments) { + message.leadingDetachedComments.push(e); + } + } + return message; + }, +}; + +const baseGeneratedCodeInfo: object = {}; + +export const GeneratedCodeInfo = { + encode(message: GeneratedCodeInfo, writer: Writer = Writer.create()): Writer { + for (const v of message.annotation) { + GeneratedCodeInfo_Annotation.encode( + v!, + writer.uint32(10).fork() + ).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): GeneratedCodeInfo { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseGeneratedCodeInfo } as GeneratedCodeInfo; + message.annotation = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.annotation.push( + GeneratedCodeInfo_Annotation.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GeneratedCodeInfo { + const message = { ...baseGeneratedCodeInfo } as GeneratedCodeInfo; + message.annotation = []; + if (object.annotation !== undefined && object.annotation !== null) { + for (const e of object.annotation) { + message.annotation.push(GeneratedCodeInfo_Annotation.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: GeneratedCodeInfo): unknown { + const obj: any = {}; + if (message.annotation) { + obj.annotation = message.annotation.map((e) => + e ? GeneratedCodeInfo_Annotation.toJSON(e) : undefined + ); + } else { + obj.annotation = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): GeneratedCodeInfo { + const message = { ...baseGeneratedCodeInfo } as GeneratedCodeInfo; + message.annotation = []; + if (object.annotation !== undefined && object.annotation !== null) { + for (const e of object.annotation) { + message.annotation.push(GeneratedCodeInfo_Annotation.fromPartial(e)); + } + } + return message; + }, +}; + +const baseGeneratedCodeInfo_Annotation: object = { + path: 0, + sourceFile: "", + begin: 0, + end: 0, +}; + +export const GeneratedCodeInfo_Annotation = { + encode( + message: GeneratedCodeInfo_Annotation, + writer: Writer = Writer.create() + ): Writer { + writer.uint32(10).fork(); + for (const v of message.path) { + writer.int32(v); + } + writer.ldelim(); + if (message.sourceFile !== "") { + writer.uint32(18).string(message.sourceFile); + } + if (message.begin !== 0) { + writer.uint32(24).int32(message.begin); + } + if (message.end !== 0) { + writer.uint32(32).int32(message.end); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): GeneratedCodeInfo_Annotation { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseGeneratedCodeInfo_Annotation, + } as GeneratedCodeInfo_Annotation; + message.path = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.path.push(reader.int32()); + } + } else { + message.path.push(reader.int32()); + } + break; + case 2: + message.sourceFile = reader.string(); + break; + case 3: + message.begin = reader.int32(); + break; + case 4: + message.end = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GeneratedCodeInfo_Annotation { + const message = { + ...baseGeneratedCodeInfo_Annotation, + } as GeneratedCodeInfo_Annotation; + message.path = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(Number(e)); + } + } + if (object.sourceFile !== undefined && object.sourceFile !== null) { + message.sourceFile = String(object.sourceFile); + } else { + message.sourceFile = ""; + } + if (object.begin !== undefined && object.begin !== null) { + message.begin = Number(object.begin); + } else { + message.begin = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + return message; + }, + + toJSON(message: GeneratedCodeInfo_Annotation): unknown { + const obj: any = {}; + if (message.path) { + obj.path = message.path.map((e) => e); + } else { + obj.path = []; + } + message.sourceFile !== undefined && (obj.sourceFile = message.sourceFile); + message.begin !== undefined && (obj.begin = message.begin); + message.end !== undefined && (obj.end = message.end); + return obj; + }, + + fromPartial( + object: DeepPartial + ): GeneratedCodeInfo_Annotation { + const message = { + ...baseGeneratedCodeInfo_Annotation, + } as GeneratedCodeInfo_Annotation; + message.path = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(e); + } + } + if (object.sourceFile !== undefined && object.sourceFile !== null) { + message.sourceFile = object.sourceFile; + } else { + message.sourceFile = ""; + } + if (object.begin !== undefined && object.begin !== null) { + message.begin = object.begin; + } else { + message.begin = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/bze.v1.rewards/types/rewards/events.ts b/ts-client/bze.v1.rewards/types/rewards/events.ts new file mode 100644 index 00000000..069fc0b6 --- /dev/null +++ b/ts-client/bze.v1.rewards/types/rewards/events.ts @@ -0,0 +1,2 @@ +/* eslint-disable */ +export const protobufPackage = "bze.rewards.v1"; diff --git a/ts-client/bze.v1.rewards/types/rewards/genesis.ts b/ts-client/bze.v1.rewards/types/rewards/genesis.ts new file mode 100644 index 00000000..bae15eaa --- /dev/null +++ b/ts-client/bze.v1.rewards/types/rewards/genesis.ts @@ -0,0 +1,544 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; +import { Params } from "../rewards/params"; +import { StakingReward } from "../rewards/staking_reward"; +import { + TradingReward, + TradingRewardLeaderboard, + TradingRewardCandidate, + MarketIdTradingRewardId, + TradingRewardExpiration, +} from "../rewards/trading_reward"; +import { + StakingRewardParticipant, + PendingUnlockParticipant, +} from "../rewards/staking_reward_participant"; + +export const protobufPackage = "bze.v1.rewards"; + +/** GenesisState defines the rewards module's genesis state. */ +export interface GenesisState { + params: Params | undefined; + stakingRewardList: StakingReward[]; + stakingRewardsCounter: number; + tradingRewardsCounter: number; + activeTradingRewardList: TradingReward[]; + pendingTradingRewardList: TradingReward[]; + stakingRewardParticipantList: StakingRewardParticipant[]; + pendingUnlockParticipantList: PendingUnlockParticipant[]; + tradingRewardLeaderboardList: TradingRewardLeaderboard[]; + tradingRewardCandidateList: TradingRewardCandidate[]; + marketIdTradingRewardIdList: MarketIdTradingRewardId[]; + pendingTradingRewardExpirationList: TradingRewardExpiration[]; + /** this line is used by starport scaffolding # genesis/proto/state */ + activeTradingRewardExpirationList: TradingRewardExpiration[]; +} + +const baseGenesisState: object = { + stakingRewardsCounter: 0, + tradingRewardsCounter: 0, +}; + +export const GenesisState = { + encode(message: GenesisState, writer: Writer = Writer.create()): Writer { + if (message.params !== undefined) { + Params.encode(message.params, writer.uint32(10).fork()).ldelim(); + } + for (const v of message.stakingRewardList) { + StakingReward.encode(v!, writer.uint32(18).fork()).ldelim(); + } + if (message.stakingRewardsCounter !== 0) { + writer.uint32(24).uint64(message.stakingRewardsCounter); + } + if (message.tradingRewardsCounter !== 0) { + writer.uint32(32).uint64(message.tradingRewardsCounter); + } + for (const v of message.activeTradingRewardList) { + TradingReward.encode(v!, writer.uint32(42).fork()).ldelim(); + } + for (const v of message.pendingTradingRewardList) { + TradingReward.encode(v!, writer.uint32(50).fork()).ldelim(); + } + for (const v of message.stakingRewardParticipantList) { + StakingRewardParticipant.encode(v!, writer.uint32(58).fork()).ldelim(); + } + for (const v of message.pendingUnlockParticipantList) { + PendingUnlockParticipant.encode(v!, writer.uint32(66).fork()).ldelim(); + } + for (const v of message.tradingRewardLeaderboardList) { + TradingRewardLeaderboard.encode(v!, writer.uint32(74).fork()).ldelim(); + } + for (const v of message.tradingRewardCandidateList) { + TradingRewardCandidate.encode(v!, writer.uint32(82).fork()).ldelim(); + } + for (const v of message.marketIdTradingRewardIdList) { + MarketIdTradingRewardId.encode(v!, writer.uint32(90).fork()).ldelim(); + } + for (const v of message.pendingTradingRewardExpirationList) { + TradingRewardExpiration.encode(v!, writer.uint32(98).fork()).ldelim(); + } + for (const v of message.activeTradingRewardExpirationList) { + TradingRewardExpiration.encode(v!, writer.uint32(106).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): GenesisState { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseGenesisState } as GenesisState; + message.stakingRewardList = []; + message.activeTradingRewardList = []; + message.pendingTradingRewardList = []; + message.stakingRewardParticipantList = []; + message.pendingUnlockParticipantList = []; + message.tradingRewardLeaderboardList = []; + message.tradingRewardCandidateList = []; + message.marketIdTradingRewardIdList = []; + message.pendingTradingRewardExpirationList = []; + message.activeTradingRewardExpirationList = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.params = Params.decode(reader, reader.uint32()); + break; + case 2: + message.stakingRewardList.push( + StakingReward.decode(reader, reader.uint32()) + ); + break; + case 3: + message.stakingRewardsCounter = longToNumber(reader.uint64() as Long); + break; + case 4: + message.tradingRewardsCounter = longToNumber(reader.uint64() as Long); + break; + case 5: + message.activeTradingRewardList.push( + TradingReward.decode(reader, reader.uint32()) + ); + break; + case 6: + message.pendingTradingRewardList.push( + TradingReward.decode(reader, reader.uint32()) + ); + break; + case 7: + message.stakingRewardParticipantList.push( + StakingRewardParticipant.decode(reader, reader.uint32()) + ); + break; + case 8: + message.pendingUnlockParticipantList.push( + PendingUnlockParticipant.decode(reader, reader.uint32()) + ); + break; + case 9: + message.tradingRewardLeaderboardList.push( + TradingRewardLeaderboard.decode(reader, reader.uint32()) + ); + break; + case 10: + message.tradingRewardCandidateList.push( + TradingRewardCandidate.decode(reader, reader.uint32()) + ); + break; + case 11: + message.marketIdTradingRewardIdList.push( + MarketIdTradingRewardId.decode(reader, reader.uint32()) + ); + break; + case 12: + message.pendingTradingRewardExpirationList.push( + TradingRewardExpiration.decode(reader, reader.uint32()) + ); + break; + case 13: + message.activeTradingRewardExpirationList.push( + TradingRewardExpiration.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GenesisState { + const message = { ...baseGenesisState } as GenesisState; + message.stakingRewardList = []; + message.activeTradingRewardList = []; + message.pendingTradingRewardList = []; + message.stakingRewardParticipantList = []; + message.pendingUnlockParticipantList = []; + message.tradingRewardLeaderboardList = []; + message.tradingRewardCandidateList = []; + message.marketIdTradingRewardIdList = []; + message.pendingTradingRewardExpirationList = []; + message.activeTradingRewardExpirationList = []; + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromJSON(object.params); + } else { + message.params = undefined; + } + if ( + object.stakingRewardList !== undefined && + object.stakingRewardList !== null + ) { + for (const e of object.stakingRewardList) { + message.stakingRewardList.push(StakingReward.fromJSON(e)); + } + } + if ( + object.stakingRewardsCounter !== undefined && + object.stakingRewardsCounter !== null + ) { + message.stakingRewardsCounter = Number(object.stakingRewardsCounter); + } else { + message.stakingRewardsCounter = 0; + } + if ( + object.tradingRewardsCounter !== undefined && + object.tradingRewardsCounter !== null + ) { + message.tradingRewardsCounter = Number(object.tradingRewardsCounter); + } else { + message.tradingRewardsCounter = 0; + } + if ( + object.activeTradingRewardList !== undefined && + object.activeTradingRewardList !== null + ) { + for (const e of object.activeTradingRewardList) { + message.activeTradingRewardList.push(TradingReward.fromJSON(e)); + } + } + if ( + object.pendingTradingRewardList !== undefined && + object.pendingTradingRewardList !== null + ) { + for (const e of object.pendingTradingRewardList) { + message.pendingTradingRewardList.push(TradingReward.fromJSON(e)); + } + } + if ( + object.stakingRewardParticipantList !== undefined && + object.stakingRewardParticipantList !== null + ) { + for (const e of object.stakingRewardParticipantList) { + message.stakingRewardParticipantList.push( + StakingRewardParticipant.fromJSON(e) + ); + } + } + if ( + object.pendingUnlockParticipantList !== undefined && + object.pendingUnlockParticipantList !== null + ) { + for (const e of object.pendingUnlockParticipantList) { + message.pendingUnlockParticipantList.push( + PendingUnlockParticipant.fromJSON(e) + ); + } + } + if ( + object.tradingRewardLeaderboardList !== undefined && + object.tradingRewardLeaderboardList !== null + ) { + for (const e of object.tradingRewardLeaderboardList) { + message.tradingRewardLeaderboardList.push( + TradingRewardLeaderboard.fromJSON(e) + ); + } + } + if ( + object.tradingRewardCandidateList !== undefined && + object.tradingRewardCandidateList !== null + ) { + for (const e of object.tradingRewardCandidateList) { + message.tradingRewardCandidateList.push( + TradingRewardCandidate.fromJSON(e) + ); + } + } + if ( + object.marketIdTradingRewardIdList !== undefined && + object.marketIdTradingRewardIdList !== null + ) { + for (const e of object.marketIdTradingRewardIdList) { + message.marketIdTradingRewardIdList.push( + MarketIdTradingRewardId.fromJSON(e) + ); + } + } + if ( + object.pendingTradingRewardExpirationList !== undefined && + object.pendingTradingRewardExpirationList !== null + ) { + for (const e of object.pendingTradingRewardExpirationList) { + message.pendingTradingRewardExpirationList.push( + TradingRewardExpiration.fromJSON(e) + ); + } + } + if ( + object.activeTradingRewardExpirationList !== undefined && + object.activeTradingRewardExpirationList !== null + ) { + for (const e of object.activeTradingRewardExpirationList) { + message.activeTradingRewardExpirationList.push( + TradingRewardExpiration.fromJSON(e) + ); + } + } + return message; + }, + + toJSON(message: GenesisState): unknown { + const obj: any = {}; + message.params !== undefined && + (obj.params = message.params ? Params.toJSON(message.params) : undefined); + if (message.stakingRewardList) { + obj.stakingRewardList = message.stakingRewardList.map((e) => + e ? StakingReward.toJSON(e) : undefined + ); + } else { + obj.stakingRewardList = []; + } + message.stakingRewardsCounter !== undefined && + (obj.stakingRewardsCounter = message.stakingRewardsCounter); + message.tradingRewardsCounter !== undefined && + (obj.tradingRewardsCounter = message.tradingRewardsCounter); + if (message.activeTradingRewardList) { + obj.activeTradingRewardList = message.activeTradingRewardList.map((e) => + e ? TradingReward.toJSON(e) : undefined + ); + } else { + obj.activeTradingRewardList = []; + } + if (message.pendingTradingRewardList) { + obj.pendingTradingRewardList = message.pendingTradingRewardList.map((e) => + e ? TradingReward.toJSON(e) : undefined + ); + } else { + obj.pendingTradingRewardList = []; + } + if (message.stakingRewardParticipantList) { + obj.stakingRewardParticipantList = message.stakingRewardParticipantList.map( + (e) => (e ? StakingRewardParticipant.toJSON(e) : undefined) + ); + } else { + obj.stakingRewardParticipantList = []; + } + if (message.pendingUnlockParticipantList) { + obj.pendingUnlockParticipantList = message.pendingUnlockParticipantList.map( + (e) => (e ? PendingUnlockParticipant.toJSON(e) : undefined) + ); + } else { + obj.pendingUnlockParticipantList = []; + } + if (message.tradingRewardLeaderboardList) { + obj.tradingRewardLeaderboardList = message.tradingRewardLeaderboardList.map( + (e) => (e ? TradingRewardLeaderboard.toJSON(e) : undefined) + ); + } else { + obj.tradingRewardLeaderboardList = []; + } + if (message.tradingRewardCandidateList) { + obj.tradingRewardCandidateList = message.tradingRewardCandidateList.map( + (e) => (e ? TradingRewardCandidate.toJSON(e) : undefined) + ); + } else { + obj.tradingRewardCandidateList = []; + } + if (message.marketIdTradingRewardIdList) { + obj.marketIdTradingRewardIdList = message.marketIdTradingRewardIdList.map( + (e) => (e ? MarketIdTradingRewardId.toJSON(e) : undefined) + ); + } else { + obj.marketIdTradingRewardIdList = []; + } + if (message.pendingTradingRewardExpirationList) { + obj.pendingTradingRewardExpirationList = message.pendingTradingRewardExpirationList.map( + (e) => (e ? TradingRewardExpiration.toJSON(e) : undefined) + ); + } else { + obj.pendingTradingRewardExpirationList = []; + } + if (message.activeTradingRewardExpirationList) { + obj.activeTradingRewardExpirationList = message.activeTradingRewardExpirationList.map( + (e) => (e ? TradingRewardExpiration.toJSON(e) : undefined) + ); + } else { + obj.activeTradingRewardExpirationList = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): GenesisState { + const message = { ...baseGenesisState } as GenesisState; + message.stakingRewardList = []; + message.activeTradingRewardList = []; + message.pendingTradingRewardList = []; + message.stakingRewardParticipantList = []; + message.pendingUnlockParticipantList = []; + message.tradingRewardLeaderboardList = []; + message.tradingRewardCandidateList = []; + message.marketIdTradingRewardIdList = []; + message.pendingTradingRewardExpirationList = []; + message.activeTradingRewardExpirationList = []; + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromPartial(object.params); + } else { + message.params = undefined; + } + if ( + object.stakingRewardList !== undefined && + object.stakingRewardList !== null + ) { + for (const e of object.stakingRewardList) { + message.stakingRewardList.push(StakingReward.fromPartial(e)); + } + } + if ( + object.stakingRewardsCounter !== undefined && + object.stakingRewardsCounter !== null + ) { + message.stakingRewardsCounter = object.stakingRewardsCounter; + } else { + message.stakingRewardsCounter = 0; + } + if ( + object.tradingRewardsCounter !== undefined && + object.tradingRewardsCounter !== null + ) { + message.tradingRewardsCounter = object.tradingRewardsCounter; + } else { + message.tradingRewardsCounter = 0; + } + if ( + object.activeTradingRewardList !== undefined && + object.activeTradingRewardList !== null + ) { + for (const e of object.activeTradingRewardList) { + message.activeTradingRewardList.push(TradingReward.fromPartial(e)); + } + } + if ( + object.pendingTradingRewardList !== undefined && + object.pendingTradingRewardList !== null + ) { + for (const e of object.pendingTradingRewardList) { + message.pendingTradingRewardList.push(TradingReward.fromPartial(e)); + } + } + if ( + object.stakingRewardParticipantList !== undefined && + object.stakingRewardParticipantList !== null + ) { + for (const e of object.stakingRewardParticipantList) { + message.stakingRewardParticipantList.push( + StakingRewardParticipant.fromPartial(e) + ); + } + } + if ( + object.pendingUnlockParticipantList !== undefined && + object.pendingUnlockParticipantList !== null + ) { + for (const e of object.pendingUnlockParticipantList) { + message.pendingUnlockParticipantList.push( + PendingUnlockParticipant.fromPartial(e) + ); + } + } + if ( + object.tradingRewardLeaderboardList !== undefined && + object.tradingRewardLeaderboardList !== null + ) { + for (const e of object.tradingRewardLeaderboardList) { + message.tradingRewardLeaderboardList.push( + TradingRewardLeaderboard.fromPartial(e) + ); + } + } + if ( + object.tradingRewardCandidateList !== undefined && + object.tradingRewardCandidateList !== null + ) { + for (const e of object.tradingRewardCandidateList) { + message.tradingRewardCandidateList.push( + TradingRewardCandidate.fromPartial(e) + ); + } + } + if ( + object.marketIdTradingRewardIdList !== undefined && + object.marketIdTradingRewardIdList !== null + ) { + for (const e of object.marketIdTradingRewardIdList) { + message.marketIdTradingRewardIdList.push( + MarketIdTradingRewardId.fromPartial(e) + ); + } + } + if ( + object.pendingTradingRewardExpirationList !== undefined && + object.pendingTradingRewardExpirationList !== null + ) { + for (const e of object.pendingTradingRewardExpirationList) { + message.pendingTradingRewardExpirationList.push( + TradingRewardExpiration.fromPartial(e) + ); + } + } + if ( + object.activeTradingRewardExpirationList !== undefined && + object.activeTradingRewardExpirationList !== null + ) { + for (const e of object.activeTradingRewardExpirationList) { + message.activeTradingRewardExpirationList.push( + TradingRewardExpiration.fromPartial(e) + ); + } + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/bze.v1.rewards/types/rewards/params.ts b/ts-client/bze.v1.rewards/types/rewards/params.ts new file mode 100644 index 00000000..0d486868 --- /dev/null +++ b/ts-client/bze.v1.rewards/types/rewards/params.ts @@ -0,0 +1,110 @@ +/* eslint-disable */ +import { Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "bze.v1.rewards"; + +/** Params defines the parameters for the module. */ +export interface Params { + createStakingRewardFee: string; + createTradingRewardFee: string; +} + +const baseParams: object = { + createStakingRewardFee: "", + createTradingRewardFee: "", +}; + +export const Params = { + encode(message: Params, writer: Writer = Writer.create()): Writer { + if (message.createStakingRewardFee !== "") { + writer.uint32(10).string(message.createStakingRewardFee); + } + if (message.createTradingRewardFee !== "") { + writer.uint32(18).string(message.createTradingRewardFee); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Params { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseParams } as Params; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.createStakingRewardFee = reader.string(); + break; + case 2: + message.createTradingRewardFee = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Params { + const message = { ...baseParams } as Params; + if ( + object.createStakingRewardFee !== undefined && + object.createStakingRewardFee !== null + ) { + message.createStakingRewardFee = String(object.createStakingRewardFee); + } else { + message.createStakingRewardFee = ""; + } + if ( + object.createTradingRewardFee !== undefined && + object.createTradingRewardFee !== null + ) { + message.createTradingRewardFee = String(object.createTradingRewardFee); + } else { + message.createTradingRewardFee = ""; + } + return message; + }, + + toJSON(message: Params): unknown { + const obj: any = {}; + message.createStakingRewardFee !== undefined && + (obj.createStakingRewardFee = message.createStakingRewardFee); + message.createTradingRewardFee !== undefined && + (obj.createTradingRewardFee = message.createTradingRewardFee); + return obj; + }, + + fromPartial(object: DeepPartial): Params { + const message = { ...baseParams } as Params; + if ( + object.createStakingRewardFee !== undefined && + object.createStakingRewardFee !== null + ) { + message.createStakingRewardFee = object.createStakingRewardFee; + } else { + message.createStakingRewardFee = ""; + } + if ( + object.createTradingRewardFee !== undefined && + object.createTradingRewardFee !== null + ) { + message.createTradingRewardFee = object.createTradingRewardFee; + } else { + message.createTradingRewardFee = ""; + } + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/bze.v1.rewards/types/rewards/query.ts b/ts-client/bze.v1.rewards/types/rewards/query.ts new file mode 100644 index 00000000..95b575e2 --- /dev/null +++ b/ts-client/bze.v1.rewards/types/rewards/query.ts @@ -0,0 +1,1321 @@ +/* eslint-disable */ +import { Reader, Writer } from "protobufjs/minimal"; +import { Params } from "../rewards/params"; +import { StakingReward } from "../rewards/staking_reward"; +import { + PageRequest, + PageResponse, +} from "../cosmos/base/query/v1beta1/pagination"; +import { TradingReward } from "../rewards/trading_reward"; +import { StakingRewardParticipant } from "../rewards/staking_reward_participant"; + +export const protobufPackage = "bze.v1.rewards"; + +/** QueryParamsRequest is request type for the Query/Params RPC method. */ +export interface QueryParamsRequest {} + +/** QueryParamsResponse is response type for the Query/Params RPC method. */ +export interface QueryParamsResponse { + /** params holds all the parameters of this module. */ + params: Params | undefined; +} + +export interface QueryGetStakingRewardRequest { + rewardId: string; +} + +export interface QueryGetStakingRewardResponse { + stakingReward: StakingReward | undefined; +} + +export interface QueryAllStakingRewardRequest { + pagination: PageRequest | undefined; +} + +export interface QueryAllStakingRewardResponse { + list: StakingReward[]; + pagination: PageResponse | undefined; +} + +export interface QueryGetTradingRewardRequest { + rewardId: string; +} + +export interface QueryGetTradingRewardResponse { + tradingReward: TradingReward | undefined; +} + +export interface QueryAllTradingRewardRequest { + pagination: PageRequest | undefined; +} + +export interface QueryAllTradingRewardResponse { + list: TradingReward[]; + pagination: PageResponse | undefined; +} + +export interface QueryGetStakingRewardParticipantRequest { + address: string; + pagination: PageRequest | undefined; +} + +export interface QueryGetStakingRewardParticipantResponse { + list: StakingRewardParticipant[]; + pagination: PageResponse | undefined; +} + +export interface QueryAllStakingRewardParticipantRequest { + pagination: PageRequest | undefined; +} + +export interface QueryAllStakingRewardParticipantResponse { + list: StakingRewardParticipant[]; + pagination: PageResponse | undefined; +} + +const baseQueryParamsRequest: object = {}; + +export const QueryParamsRequest = { + encode(_: QueryParamsRequest, writer: Writer = Writer.create()): Writer { + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QueryParamsRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryParamsRequest } as QueryParamsRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): QueryParamsRequest { + const message = { ...baseQueryParamsRequest } as QueryParamsRequest; + return message; + }, + + toJSON(_: QueryParamsRequest): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial(_: DeepPartial): QueryParamsRequest { + const message = { ...baseQueryParamsRequest } as QueryParamsRequest; + return message; + }, +}; + +const baseQueryParamsResponse: object = {}; + +export const QueryParamsResponse = { + encode( + message: QueryParamsResponse, + writer: Writer = Writer.create() + ): Writer { + if (message.params !== undefined) { + Params.encode(message.params, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QueryParamsResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryParamsResponse } as QueryParamsResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.params = Params.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryParamsResponse { + const message = { ...baseQueryParamsResponse } as QueryParamsResponse; + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromJSON(object.params); + } else { + message.params = undefined; + } + return message; + }, + + toJSON(message: QueryParamsResponse): unknown { + const obj: any = {}; + message.params !== undefined && + (obj.params = message.params ? Params.toJSON(message.params) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): QueryParamsResponse { + const message = { ...baseQueryParamsResponse } as QueryParamsResponse; + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromPartial(object.params); + } else { + message.params = undefined; + } + return message; + }, +}; + +const baseQueryGetStakingRewardRequest: object = { rewardId: "" }; + +export const QueryGetStakingRewardRequest = { + encode( + message: QueryGetStakingRewardRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.rewardId !== "") { + writer.uint32(10).string(message.rewardId); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryGetStakingRewardRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryGetStakingRewardRequest, + } as QueryGetStakingRewardRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.rewardId = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryGetStakingRewardRequest { + const message = { + ...baseQueryGetStakingRewardRequest, + } as QueryGetStakingRewardRequest; + if (object.rewardId !== undefined && object.rewardId !== null) { + message.rewardId = String(object.rewardId); + } else { + message.rewardId = ""; + } + return message; + }, + + toJSON(message: QueryGetStakingRewardRequest): unknown { + const obj: any = {}; + message.rewardId !== undefined && (obj.rewardId = message.rewardId); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryGetStakingRewardRequest { + const message = { + ...baseQueryGetStakingRewardRequest, + } as QueryGetStakingRewardRequest; + if (object.rewardId !== undefined && object.rewardId !== null) { + message.rewardId = object.rewardId; + } else { + message.rewardId = ""; + } + return message; + }, +}; + +const baseQueryGetStakingRewardResponse: object = {}; + +export const QueryGetStakingRewardResponse = { + encode( + message: QueryGetStakingRewardResponse, + writer: Writer = Writer.create() + ): Writer { + if (message.stakingReward !== undefined) { + StakingReward.encode( + message.stakingReward, + writer.uint32(10).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryGetStakingRewardResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryGetStakingRewardResponse, + } as QueryGetStakingRewardResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.stakingReward = StakingReward.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryGetStakingRewardResponse { + const message = { + ...baseQueryGetStakingRewardResponse, + } as QueryGetStakingRewardResponse; + if (object.stakingReward !== undefined && object.stakingReward !== null) { + message.stakingReward = StakingReward.fromJSON(object.stakingReward); + } else { + message.stakingReward = undefined; + } + return message; + }, + + toJSON(message: QueryGetStakingRewardResponse): unknown { + const obj: any = {}; + message.stakingReward !== undefined && + (obj.stakingReward = message.stakingReward + ? StakingReward.toJSON(message.stakingReward) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryGetStakingRewardResponse { + const message = { + ...baseQueryGetStakingRewardResponse, + } as QueryGetStakingRewardResponse; + if (object.stakingReward !== undefined && object.stakingReward !== null) { + message.stakingReward = StakingReward.fromPartial(object.stakingReward); + } else { + message.stakingReward = undefined; + } + return message; + }, +}; + +const baseQueryAllStakingRewardRequest: object = {}; + +export const QueryAllStakingRewardRequest = { + encode( + message: QueryAllStakingRewardRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryAllStakingRewardRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryAllStakingRewardRequest, + } as QueryAllStakingRewardRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryAllStakingRewardRequest { + const message = { + ...baseQueryAllStakingRewardRequest, + } as QueryAllStakingRewardRequest; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryAllStakingRewardRequest): unknown { + const obj: any = {}; + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageRequest.toJSON(message.pagination) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryAllStakingRewardRequest { + const message = { + ...baseQueryAllStakingRewardRequest, + } as QueryAllStakingRewardRequest; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseQueryAllStakingRewardResponse: object = {}; + +export const QueryAllStakingRewardResponse = { + encode( + message: QueryAllStakingRewardResponse, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.list) { + StakingReward.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode( + message.pagination, + writer.uint32(18).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryAllStakingRewardResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryAllStakingRewardResponse, + } as QueryAllStakingRewardResponse; + message.list = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.list.push(StakingReward.decode(reader, reader.uint32())); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryAllStakingRewardResponse { + const message = { + ...baseQueryAllStakingRewardResponse, + } as QueryAllStakingRewardResponse; + message.list = []; + if (object.list !== undefined && object.list !== null) { + for (const e of object.list) { + message.list.push(StakingReward.fromJSON(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryAllStakingRewardResponse): unknown { + const obj: any = {}; + if (message.list) { + obj.list = message.list.map((e) => + e ? StakingReward.toJSON(e) : undefined + ); + } else { + obj.list = []; + } + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageResponse.toJSON(message.pagination) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryAllStakingRewardResponse { + const message = { + ...baseQueryAllStakingRewardResponse, + } as QueryAllStakingRewardResponse; + message.list = []; + if (object.list !== undefined && object.list !== null) { + for (const e of object.list) { + message.list.push(StakingReward.fromPartial(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseQueryGetTradingRewardRequest: object = { rewardId: "" }; + +export const QueryGetTradingRewardRequest = { + encode( + message: QueryGetTradingRewardRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.rewardId !== "") { + writer.uint32(10).string(message.rewardId); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryGetTradingRewardRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryGetTradingRewardRequest, + } as QueryGetTradingRewardRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.rewardId = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryGetTradingRewardRequest { + const message = { + ...baseQueryGetTradingRewardRequest, + } as QueryGetTradingRewardRequest; + if (object.rewardId !== undefined && object.rewardId !== null) { + message.rewardId = String(object.rewardId); + } else { + message.rewardId = ""; + } + return message; + }, + + toJSON(message: QueryGetTradingRewardRequest): unknown { + const obj: any = {}; + message.rewardId !== undefined && (obj.rewardId = message.rewardId); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryGetTradingRewardRequest { + const message = { + ...baseQueryGetTradingRewardRequest, + } as QueryGetTradingRewardRequest; + if (object.rewardId !== undefined && object.rewardId !== null) { + message.rewardId = object.rewardId; + } else { + message.rewardId = ""; + } + return message; + }, +}; + +const baseQueryGetTradingRewardResponse: object = {}; + +export const QueryGetTradingRewardResponse = { + encode( + message: QueryGetTradingRewardResponse, + writer: Writer = Writer.create() + ): Writer { + if (message.tradingReward !== undefined) { + TradingReward.encode( + message.tradingReward, + writer.uint32(10).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryGetTradingRewardResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryGetTradingRewardResponse, + } as QueryGetTradingRewardResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.tradingReward = TradingReward.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryGetTradingRewardResponse { + const message = { + ...baseQueryGetTradingRewardResponse, + } as QueryGetTradingRewardResponse; + if (object.tradingReward !== undefined && object.tradingReward !== null) { + message.tradingReward = TradingReward.fromJSON(object.tradingReward); + } else { + message.tradingReward = undefined; + } + return message; + }, + + toJSON(message: QueryGetTradingRewardResponse): unknown { + const obj: any = {}; + message.tradingReward !== undefined && + (obj.tradingReward = message.tradingReward + ? TradingReward.toJSON(message.tradingReward) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryGetTradingRewardResponse { + const message = { + ...baseQueryGetTradingRewardResponse, + } as QueryGetTradingRewardResponse; + if (object.tradingReward !== undefined && object.tradingReward !== null) { + message.tradingReward = TradingReward.fromPartial(object.tradingReward); + } else { + message.tradingReward = undefined; + } + return message; + }, +}; + +const baseQueryAllTradingRewardRequest: object = {}; + +export const QueryAllTradingRewardRequest = { + encode( + message: QueryAllTradingRewardRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryAllTradingRewardRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryAllTradingRewardRequest, + } as QueryAllTradingRewardRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryAllTradingRewardRequest { + const message = { + ...baseQueryAllTradingRewardRequest, + } as QueryAllTradingRewardRequest; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryAllTradingRewardRequest): unknown { + const obj: any = {}; + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageRequest.toJSON(message.pagination) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryAllTradingRewardRequest { + const message = { + ...baseQueryAllTradingRewardRequest, + } as QueryAllTradingRewardRequest; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseQueryAllTradingRewardResponse: object = {}; + +export const QueryAllTradingRewardResponse = { + encode( + message: QueryAllTradingRewardResponse, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.list) { + TradingReward.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode( + message.pagination, + writer.uint32(18).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryAllTradingRewardResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryAllTradingRewardResponse, + } as QueryAllTradingRewardResponse; + message.list = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.list.push(TradingReward.decode(reader, reader.uint32())); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryAllTradingRewardResponse { + const message = { + ...baseQueryAllTradingRewardResponse, + } as QueryAllTradingRewardResponse; + message.list = []; + if (object.list !== undefined && object.list !== null) { + for (const e of object.list) { + message.list.push(TradingReward.fromJSON(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryAllTradingRewardResponse): unknown { + const obj: any = {}; + if (message.list) { + obj.list = message.list.map((e) => + e ? TradingReward.toJSON(e) : undefined + ); + } else { + obj.list = []; + } + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageResponse.toJSON(message.pagination) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryAllTradingRewardResponse { + const message = { + ...baseQueryAllTradingRewardResponse, + } as QueryAllTradingRewardResponse; + message.list = []; + if (object.list !== undefined && object.list !== null) { + for (const e of object.list) { + message.list.push(TradingReward.fromPartial(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseQueryGetStakingRewardParticipantRequest: object = { address: "" }; + +export const QueryGetStakingRewardParticipantRequest = { + encode( + message: QueryGetStakingRewardParticipantRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.address !== "") { + writer.uint32(10).string(message.address); + } + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryGetStakingRewardParticipantRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryGetStakingRewardParticipantRequest, + } as QueryGetStakingRewardParticipantRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.address = reader.string(); + break; + case 2: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryGetStakingRewardParticipantRequest { + const message = { + ...baseQueryGetStakingRewardParticipantRequest, + } as QueryGetStakingRewardParticipantRequest; + if (object.address !== undefined && object.address !== null) { + message.address = String(object.address); + } else { + message.address = ""; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryGetStakingRewardParticipantRequest): unknown { + const obj: any = {}; + message.address !== undefined && (obj.address = message.address); + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageRequest.toJSON(message.pagination) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryGetStakingRewardParticipantRequest { + const message = { + ...baseQueryGetStakingRewardParticipantRequest, + } as QueryGetStakingRewardParticipantRequest; + if (object.address !== undefined && object.address !== null) { + message.address = object.address; + } else { + message.address = ""; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseQueryGetStakingRewardParticipantResponse: object = {}; + +export const QueryGetStakingRewardParticipantResponse = { + encode( + message: QueryGetStakingRewardParticipantResponse, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.list) { + StakingRewardParticipant.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode( + message.pagination, + writer.uint32(18).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryGetStakingRewardParticipantResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryGetStakingRewardParticipantResponse, + } as QueryGetStakingRewardParticipantResponse; + message.list = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.list.push( + StakingRewardParticipant.decode(reader, reader.uint32()) + ); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryGetStakingRewardParticipantResponse { + const message = { + ...baseQueryGetStakingRewardParticipantResponse, + } as QueryGetStakingRewardParticipantResponse; + message.list = []; + if (object.list !== undefined && object.list !== null) { + for (const e of object.list) { + message.list.push(StakingRewardParticipant.fromJSON(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryGetStakingRewardParticipantResponse): unknown { + const obj: any = {}; + if (message.list) { + obj.list = message.list.map((e) => + e ? StakingRewardParticipant.toJSON(e) : undefined + ); + } else { + obj.list = []; + } + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageResponse.toJSON(message.pagination) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryGetStakingRewardParticipantResponse { + const message = { + ...baseQueryGetStakingRewardParticipantResponse, + } as QueryGetStakingRewardParticipantResponse; + message.list = []; + if (object.list !== undefined && object.list !== null) { + for (const e of object.list) { + message.list.push(StakingRewardParticipant.fromPartial(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseQueryAllStakingRewardParticipantRequest: object = {}; + +export const QueryAllStakingRewardParticipantRequest = { + encode( + message: QueryAllStakingRewardParticipantRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryAllStakingRewardParticipantRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryAllStakingRewardParticipantRequest, + } as QueryAllStakingRewardParticipantRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryAllStakingRewardParticipantRequest { + const message = { + ...baseQueryAllStakingRewardParticipantRequest, + } as QueryAllStakingRewardParticipantRequest; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryAllStakingRewardParticipantRequest): unknown { + const obj: any = {}; + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageRequest.toJSON(message.pagination) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryAllStakingRewardParticipantRequest { + const message = { + ...baseQueryAllStakingRewardParticipantRequest, + } as QueryAllStakingRewardParticipantRequest; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseQueryAllStakingRewardParticipantResponse: object = {}; + +export const QueryAllStakingRewardParticipantResponse = { + encode( + message: QueryAllStakingRewardParticipantResponse, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.list) { + StakingRewardParticipant.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode( + message.pagination, + writer.uint32(18).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryAllStakingRewardParticipantResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryAllStakingRewardParticipantResponse, + } as QueryAllStakingRewardParticipantResponse; + message.list = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.list.push( + StakingRewardParticipant.decode(reader, reader.uint32()) + ); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryAllStakingRewardParticipantResponse { + const message = { + ...baseQueryAllStakingRewardParticipantResponse, + } as QueryAllStakingRewardParticipantResponse; + message.list = []; + if (object.list !== undefined && object.list !== null) { + for (const e of object.list) { + message.list.push(StakingRewardParticipant.fromJSON(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryAllStakingRewardParticipantResponse): unknown { + const obj: any = {}; + if (message.list) { + obj.list = message.list.map((e) => + e ? StakingRewardParticipant.toJSON(e) : undefined + ); + } else { + obj.list = []; + } + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageResponse.toJSON(message.pagination) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryAllStakingRewardParticipantResponse { + const message = { + ...baseQueryAllStakingRewardParticipantResponse, + } as QueryAllStakingRewardParticipantResponse; + message.list = []; + if (object.list !== undefined && object.list !== null) { + for (const e of object.list) { + message.list.push(StakingRewardParticipant.fromPartial(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +/** Query defines the gRPC querier service. */ +export interface Query { + /** Parameters queries the parameters of the module. */ + Params(request: QueryParamsRequest): Promise; + /** Queries a StakingReward by index. */ + StakingReward( + request: QueryGetStakingRewardRequest + ): Promise; + /** Queries a list of StakingReward items. */ + StakingRewardAll( + request: QueryAllStakingRewardRequest + ): Promise; + /** Queries a TradingReward by index. */ + TradingReward( + request: QueryGetTradingRewardRequest + ): Promise; + /** Queries a list of TradingReward items. */ + TradingRewardAll( + request: QueryAllTradingRewardRequest + ): Promise; + /** Queries a StakingRewardParticipant by index. */ + StakingRewardParticipant( + request: QueryGetStakingRewardParticipantRequest + ): Promise; + /** Queries a list of StakingRewardParticipant items. */ + StakingRewardParticipantAll( + request: QueryAllStakingRewardParticipantRequest + ): Promise; +} + +export class QueryClientImpl implements Query { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + } + Params(request: QueryParamsRequest): Promise { + const data = QueryParamsRequest.encode(request).finish(); + const promise = this.rpc.request("bze.v1.rewards.Query", "Params", data); + return promise.then((data) => QueryParamsResponse.decode(new Reader(data))); + } + + StakingReward( + request: QueryGetStakingRewardRequest + ): Promise { + const data = QueryGetStakingRewardRequest.encode(request).finish(); + const promise = this.rpc.request( + "bze.v1.rewards.Query", + "StakingReward", + data + ); + return promise.then((data) => + QueryGetStakingRewardResponse.decode(new Reader(data)) + ); + } + + StakingRewardAll( + request: QueryAllStakingRewardRequest + ): Promise { + const data = QueryAllStakingRewardRequest.encode(request).finish(); + const promise = this.rpc.request( + "bze.v1.rewards.Query", + "StakingRewardAll", + data + ); + return promise.then((data) => + QueryAllStakingRewardResponse.decode(new Reader(data)) + ); + } + + TradingReward( + request: QueryGetTradingRewardRequest + ): Promise { + const data = QueryGetTradingRewardRequest.encode(request).finish(); + const promise = this.rpc.request( + "bze.v1.rewards.Query", + "TradingReward", + data + ); + return promise.then((data) => + QueryGetTradingRewardResponse.decode(new Reader(data)) + ); + } + + TradingRewardAll( + request: QueryAllTradingRewardRequest + ): Promise { + const data = QueryAllTradingRewardRequest.encode(request).finish(); + const promise = this.rpc.request( + "bze.v1.rewards.Query", + "TradingRewardAll", + data + ); + return promise.then((data) => + QueryAllTradingRewardResponse.decode(new Reader(data)) + ); + } + + StakingRewardParticipant( + request: QueryGetStakingRewardParticipantRequest + ): Promise { + const data = QueryGetStakingRewardParticipantRequest.encode( + request + ).finish(); + const promise = this.rpc.request( + "bze.v1.rewards.Query", + "StakingRewardParticipant", + data + ); + return promise.then((data) => + QueryGetStakingRewardParticipantResponse.decode(new Reader(data)) + ); + } + + StakingRewardParticipantAll( + request: QueryAllStakingRewardParticipantRequest + ): Promise { + const data = QueryAllStakingRewardParticipantRequest.encode( + request + ).finish(); + const promise = this.rpc.request( + "bze.v1.rewards.Query", + "StakingRewardParticipantAll", + data + ); + return promise.then((data) => + QueryAllStakingRewardParticipantResponse.decode(new Reader(data)) + ); + } +} + +interface Rpc { + request( + service: string, + method: string, + data: Uint8Array + ): Promise; +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/bze.v1.rewards/types/rewards/staking_reward.ts b/ts-client/bze.v1.rewards/types/rewards/staking_reward.ts new file mode 100644 index 00000000..b342e1a5 --- /dev/null +++ b/ts-client/bze.v1.rewards/types/rewards/staking_reward.ts @@ -0,0 +1,282 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "bze.v1.rewards"; + +export interface StakingReward { + rewardId: string; + prizeAmount: string; + prizeDenom: string; + stakingDenom: string; + duration: number; + payouts: number; + minStake: number; + lock: number; + /** T */ + stakedAmount: string; + /** S */ + distributedStake: string; +} + +const baseStakingReward: object = { + rewardId: "", + prizeAmount: "", + prizeDenom: "", + stakingDenom: "", + duration: 0, + payouts: 0, + minStake: 0, + lock: 0, + stakedAmount: "", + distributedStake: "", +}; + +export const StakingReward = { + encode(message: StakingReward, writer: Writer = Writer.create()): Writer { + if (message.rewardId !== "") { + writer.uint32(10).string(message.rewardId); + } + if (message.prizeAmount !== "") { + writer.uint32(18).string(message.prizeAmount); + } + if (message.prizeDenom !== "") { + writer.uint32(26).string(message.prizeDenom); + } + if (message.stakingDenom !== "") { + writer.uint32(34).string(message.stakingDenom); + } + if (message.duration !== 0) { + writer.uint32(40).uint32(message.duration); + } + if (message.payouts !== 0) { + writer.uint32(48).uint32(message.payouts); + } + if (message.minStake !== 0) { + writer.uint32(56).uint64(message.minStake); + } + if (message.lock !== 0) { + writer.uint32(64).uint32(message.lock); + } + if (message.stakedAmount !== "") { + writer.uint32(74).string(message.stakedAmount); + } + if (message.distributedStake !== "") { + writer.uint32(82).string(message.distributedStake); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): StakingReward { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseStakingReward } as StakingReward; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.rewardId = reader.string(); + break; + case 2: + message.prizeAmount = reader.string(); + break; + case 3: + message.prizeDenom = reader.string(); + break; + case 4: + message.stakingDenom = reader.string(); + break; + case 5: + message.duration = reader.uint32(); + break; + case 6: + message.payouts = reader.uint32(); + break; + case 7: + message.minStake = longToNumber(reader.uint64() as Long); + break; + case 8: + message.lock = reader.uint32(); + break; + case 9: + message.stakedAmount = reader.string(); + break; + case 10: + message.distributedStake = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): StakingReward { + const message = { ...baseStakingReward } as StakingReward; + if (object.rewardId !== undefined && object.rewardId !== null) { + message.rewardId = String(object.rewardId); + } else { + message.rewardId = ""; + } + if (object.prizeAmount !== undefined && object.prizeAmount !== null) { + message.prizeAmount = String(object.prizeAmount); + } else { + message.prizeAmount = ""; + } + if (object.prizeDenom !== undefined && object.prizeDenom !== null) { + message.prizeDenom = String(object.prizeDenom); + } else { + message.prizeDenom = ""; + } + if (object.stakingDenom !== undefined && object.stakingDenom !== null) { + message.stakingDenom = String(object.stakingDenom); + } else { + message.stakingDenom = ""; + } + if (object.duration !== undefined && object.duration !== null) { + message.duration = Number(object.duration); + } else { + message.duration = 0; + } + if (object.payouts !== undefined && object.payouts !== null) { + message.payouts = Number(object.payouts); + } else { + message.payouts = 0; + } + if (object.minStake !== undefined && object.minStake !== null) { + message.minStake = Number(object.minStake); + } else { + message.minStake = 0; + } + if (object.lock !== undefined && object.lock !== null) { + message.lock = Number(object.lock); + } else { + message.lock = 0; + } + if (object.stakedAmount !== undefined && object.stakedAmount !== null) { + message.stakedAmount = String(object.stakedAmount); + } else { + message.stakedAmount = ""; + } + if ( + object.distributedStake !== undefined && + object.distributedStake !== null + ) { + message.distributedStake = String(object.distributedStake); + } else { + message.distributedStake = ""; + } + return message; + }, + + toJSON(message: StakingReward): unknown { + const obj: any = {}; + message.rewardId !== undefined && (obj.rewardId = message.rewardId); + message.prizeAmount !== undefined && + (obj.prizeAmount = message.prizeAmount); + message.prizeDenom !== undefined && (obj.prizeDenom = message.prizeDenom); + message.stakingDenom !== undefined && + (obj.stakingDenom = message.stakingDenom); + message.duration !== undefined && (obj.duration = message.duration); + message.payouts !== undefined && (obj.payouts = message.payouts); + message.minStake !== undefined && (obj.minStake = message.minStake); + message.lock !== undefined && (obj.lock = message.lock); + message.stakedAmount !== undefined && + (obj.stakedAmount = message.stakedAmount); + message.distributedStake !== undefined && + (obj.distributedStake = message.distributedStake); + return obj; + }, + + fromPartial(object: DeepPartial): StakingReward { + const message = { ...baseStakingReward } as StakingReward; + if (object.rewardId !== undefined && object.rewardId !== null) { + message.rewardId = object.rewardId; + } else { + message.rewardId = ""; + } + if (object.prizeAmount !== undefined && object.prizeAmount !== null) { + message.prizeAmount = object.prizeAmount; + } else { + message.prizeAmount = ""; + } + if (object.prizeDenom !== undefined && object.prizeDenom !== null) { + message.prizeDenom = object.prizeDenom; + } else { + message.prizeDenom = ""; + } + if (object.stakingDenom !== undefined && object.stakingDenom !== null) { + message.stakingDenom = object.stakingDenom; + } else { + message.stakingDenom = ""; + } + if (object.duration !== undefined && object.duration !== null) { + message.duration = object.duration; + } else { + message.duration = 0; + } + if (object.payouts !== undefined && object.payouts !== null) { + message.payouts = object.payouts; + } else { + message.payouts = 0; + } + if (object.minStake !== undefined && object.minStake !== null) { + message.minStake = object.minStake; + } else { + message.minStake = 0; + } + if (object.lock !== undefined && object.lock !== null) { + message.lock = object.lock; + } else { + message.lock = 0; + } + if (object.stakedAmount !== undefined && object.stakedAmount !== null) { + message.stakedAmount = object.stakedAmount; + } else { + message.stakedAmount = ""; + } + if ( + object.distributedStake !== undefined && + object.distributedStake !== null + ) { + message.distributedStake = object.distributedStake; + } else { + message.distributedStake = ""; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/bze.v1.rewards/types/rewards/staking_reward_participant.ts b/ts-client/bze.v1.rewards/types/rewards/staking_reward_participant.ts new file mode 100644 index 00000000..c5b390e9 --- /dev/null +++ b/ts-client/bze.v1.rewards/types/rewards/staking_reward_participant.ts @@ -0,0 +1,281 @@ +/* eslint-disable */ +import { Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "bze.v1.rewards"; + +export interface StakingRewardParticipant { + address: string; + rewardId: string; + /** stake[address] */ + amount: string; + /** S0[address] */ + joinedAt: string; +} + +export interface PendingUnlockParticipant { + index: string; + address: string; + amount: string; + denom: string; +} + +const baseStakingRewardParticipant: object = { + address: "", + rewardId: "", + amount: "", + joinedAt: "", +}; + +export const StakingRewardParticipant = { + encode( + message: StakingRewardParticipant, + writer: Writer = Writer.create() + ): Writer { + if (message.address !== "") { + writer.uint32(10).string(message.address); + } + if (message.rewardId !== "") { + writer.uint32(18).string(message.rewardId); + } + if (message.amount !== "") { + writer.uint32(26).string(message.amount); + } + if (message.joinedAt !== "") { + writer.uint32(34).string(message.joinedAt); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): StakingRewardParticipant { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseStakingRewardParticipant, + } as StakingRewardParticipant; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.address = reader.string(); + break; + case 2: + message.rewardId = reader.string(); + break; + case 3: + message.amount = reader.string(); + break; + case 4: + message.joinedAt = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): StakingRewardParticipant { + const message = { + ...baseStakingRewardParticipant, + } as StakingRewardParticipant; + if (object.address !== undefined && object.address !== null) { + message.address = String(object.address); + } else { + message.address = ""; + } + if (object.rewardId !== undefined && object.rewardId !== null) { + message.rewardId = String(object.rewardId); + } else { + message.rewardId = ""; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = String(object.amount); + } else { + message.amount = ""; + } + if (object.joinedAt !== undefined && object.joinedAt !== null) { + message.joinedAt = String(object.joinedAt); + } else { + message.joinedAt = ""; + } + return message; + }, + + toJSON(message: StakingRewardParticipant): unknown { + const obj: any = {}; + message.address !== undefined && (obj.address = message.address); + message.rewardId !== undefined && (obj.rewardId = message.rewardId); + message.amount !== undefined && (obj.amount = message.amount); + message.joinedAt !== undefined && (obj.joinedAt = message.joinedAt); + return obj; + }, + + fromPartial( + object: DeepPartial + ): StakingRewardParticipant { + const message = { + ...baseStakingRewardParticipant, + } as StakingRewardParticipant; + if (object.address !== undefined && object.address !== null) { + message.address = object.address; + } else { + message.address = ""; + } + if (object.rewardId !== undefined && object.rewardId !== null) { + message.rewardId = object.rewardId; + } else { + message.rewardId = ""; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = object.amount; + } else { + message.amount = ""; + } + if (object.joinedAt !== undefined && object.joinedAt !== null) { + message.joinedAt = object.joinedAt; + } else { + message.joinedAt = ""; + } + return message; + }, +}; + +const basePendingUnlockParticipant: object = { + index: "", + address: "", + amount: "", + denom: "", +}; + +export const PendingUnlockParticipant = { + encode( + message: PendingUnlockParticipant, + writer: Writer = Writer.create() + ): Writer { + if (message.index !== "") { + writer.uint32(10).string(message.index); + } + if (message.address !== "") { + writer.uint32(18).string(message.address); + } + if (message.amount !== "") { + writer.uint32(26).string(message.amount); + } + if (message.denom !== "") { + writer.uint32(34).string(message.denom); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): PendingUnlockParticipant { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...basePendingUnlockParticipant, + } as PendingUnlockParticipant; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.index = reader.string(); + break; + case 2: + message.address = reader.string(); + break; + case 3: + message.amount = reader.string(); + break; + case 4: + message.denom = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): PendingUnlockParticipant { + const message = { + ...basePendingUnlockParticipant, + } as PendingUnlockParticipant; + if (object.index !== undefined && object.index !== null) { + message.index = String(object.index); + } else { + message.index = ""; + } + if (object.address !== undefined && object.address !== null) { + message.address = String(object.address); + } else { + message.address = ""; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = String(object.amount); + } else { + message.amount = ""; + } + if (object.denom !== undefined && object.denom !== null) { + message.denom = String(object.denom); + } else { + message.denom = ""; + } + return message; + }, + + toJSON(message: PendingUnlockParticipant): unknown { + const obj: any = {}; + message.index !== undefined && (obj.index = message.index); + message.address !== undefined && (obj.address = message.address); + message.amount !== undefined && (obj.amount = message.amount); + message.denom !== undefined && (obj.denom = message.denom); + return obj; + }, + + fromPartial( + object: DeepPartial + ): PendingUnlockParticipant { + const message = { + ...basePendingUnlockParticipant, + } as PendingUnlockParticipant; + if (object.index !== undefined && object.index !== null) { + message.index = object.index; + } else { + message.index = ""; + } + if (object.address !== undefined && object.address !== null) { + message.address = object.address; + } else { + message.address = ""; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = object.amount; + } else { + message.amount = ""; + } + if (object.denom !== undefined && object.denom !== null) { + message.denom = object.denom; + } else { + message.denom = ""; + } + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/bze.v1.rewards/types/rewards/trading_reward.ts b/ts-client/bze.v1.rewards/types/rewards/trading_reward.ts new file mode 100644 index 00000000..28aa21cb --- /dev/null +++ b/ts-client/bze.v1.rewards/types/rewards/trading_reward.ts @@ -0,0 +1,712 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "bze.v1.rewards"; + +export interface TradingReward { + rewardId: string; + prizeAmount: string; + prizeDenom: string; + duration: number; + marketId: string; + slots: number; + expireAt: number; +} + +export interface TradingRewardExpiration { + rewardId: string; + expireAt: number; +} + +export interface TradingRewardLeaderboard { + rewardId: string; + list: TradingRewardLeaderboardEntry[]; +} + +export interface TradingRewardLeaderboardEntry { + amount: string; + address: string; + createdAt: number; +} + +export interface TradingRewardCandidate { + rewardId: string; + amount: string; + address: string; +} + +export interface MarketIdTradingRewardId { + rewardId: string; + marketId: string; +} + +const baseTradingReward: object = { + rewardId: "", + prizeAmount: "", + prizeDenom: "", + duration: 0, + marketId: "", + slots: 0, + expireAt: 0, +}; + +export const TradingReward = { + encode(message: TradingReward, writer: Writer = Writer.create()): Writer { + if (message.rewardId !== "") { + writer.uint32(10).string(message.rewardId); + } + if (message.prizeAmount !== "") { + writer.uint32(18).string(message.prizeAmount); + } + if (message.prizeDenom !== "") { + writer.uint32(26).string(message.prizeDenom); + } + if (message.duration !== 0) { + writer.uint32(32).uint32(message.duration); + } + if (message.marketId !== "") { + writer.uint32(42).string(message.marketId); + } + if (message.slots !== 0) { + writer.uint32(48).uint32(message.slots); + } + if (message.expireAt !== 0) { + writer.uint32(56).uint32(message.expireAt); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): TradingReward { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseTradingReward } as TradingReward; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.rewardId = reader.string(); + break; + case 2: + message.prizeAmount = reader.string(); + break; + case 3: + message.prizeDenom = reader.string(); + break; + case 4: + message.duration = reader.uint32(); + break; + case 5: + message.marketId = reader.string(); + break; + case 6: + message.slots = reader.uint32(); + break; + case 7: + message.expireAt = reader.uint32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): TradingReward { + const message = { ...baseTradingReward } as TradingReward; + if (object.rewardId !== undefined && object.rewardId !== null) { + message.rewardId = String(object.rewardId); + } else { + message.rewardId = ""; + } + if (object.prizeAmount !== undefined && object.prizeAmount !== null) { + message.prizeAmount = String(object.prizeAmount); + } else { + message.prizeAmount = ""; + } + if (object.prizeDenom !== undefined && object.prizeDenom !== null) { + message.prizeDenom = String(object.prizeDenom); + } else { + message.prizeDenom = ""; + } + if (object.duration !== undefined && object.duration !== null) { + message.duration = Number(object.duration); + } else { + message.duration = 0; + } + if (object.marketId !== undefined && object.marketId !== null) { + message.marketId = String(object.marketId); + } else { + message.marketId = ""; + } + if (object.slots !== undefined && object.slots !== null) { + message.slots = Number(object.slots); + } else { + message.slots = 0; + } + if (object.expireAt !== undefined && object.expireAt !== null) { + message.expireAt = Number(object.expireAt); + } else { + message.expireAt = 0; + } + return message; + }, + + toJSON(message: TradingReward): unknown { + const obj: any = {}; + message.rewardId !== undefined && (obj.rewardId = message.rewardId); + message.prizeAmount !== undefined && + (obj.prizeAmount = message.prizeAmount); + message.prizeDenom !== undefined && (obj.prizeDenom = message.prizeDenom); + message.duration !== undefined && (obj.duration = message.duration); + message.marketId !== undefined && (obj.marketId = message.marketId); + message.slots !== undefined && (obj.slots = message.slots); + message.expireAt !== undefined && (obj.expireAt = message.expireAt); + return obj; + }, + + fromPartial(object: DeepPartial): TradingReward { + const message = { ...baseTradingReward } as TradingReward; + if (object.rewardId !== undefined && object.rewardId !== null) { + message.rewardId = object.rewardId; + } else { + message.rewardId = ""; + } + if (object.prizeAmount !== undefined && object.prizeAmount !== null) { + message.prizeAmount = object.prizeAmount; + } else { + message.prizeAmount = ""; + } + if (object.prizeDenom !== undefined && object.prizeDenom !== null) { + message.prizeDenom = object.prizeDenom; + } else { + message.prizeDenom = ""; + } + if (object.duration !== undefined && object.duration !== null) { + message.duration = object.duration; + } else { + message.duration = 0; + } + if (object.marketId !== undefined && object.marketId !== null) { + message.marketId = object.marketId; + } else { + message.marketId = ""; + } + if (object.slots !== undefined && object.slots !== null) { + message.slots = object.slots; + } else { + message.slots = 0; + } + if (object.expireAt !== undefined && object.expireAt !== null) { + message.expireAt = object.expireAt; + } else { + message.expireAt = 0; + } + return message; + }, +}; + +const baseTradingRewardExpiration: object = { rewardId: "", expireAt: 0 }; + +export const TradingRewardExpiration = { + encode( + message: TradingRewardExpiration, + writer: Writer = Writer.create() + ): Writer { + if (message.rewardId !== "") { + writer.uint32(10).string(message.rewardId); + } + if (message.expireAt !== 0) { + writer.uint32(16).uint32(message.expireAt); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): TradingRewardExpiration { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseTradingRewardExpiration, + } as TradingRewardExpiration; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.rewardId = reader.string(); + break; + case 2: + message.expireAt = reader.uint32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): TradingRewardExpiration { + const message = { + ...baseTradingRewardExpiration, + } as TradingRewardExpiration; + if (object.rewardId !== undefined && object.rewardId !== null) { + message.rewardId = String(object.rewardId); + } else { + message.rewardId = ""; + } + if (object.expireAt !== undefined && object.expireAt !== null) { + message.expireAt = Number(object.expireAt); + } else { + message.expireAt = 0; + } + return message; + }, + + toJSON(message: TradingRewardExpiration): unknown { + const obj: any = {}; + message.rewardId !== undefined && (obj.rewardId = message.rewardId); + message.expireAt !== undefined && (obj.expireAt = message.expireAt); + return obj; + }, + + fromPartial( + object: DeepPartial + ): TradingRewardExpiration { + const message = { + ...baseTradingRewardExpiration, + } as TradingRewardExpiration; + if (object.rewardId !== undefined && object.rewardId !== null) { + message.rewardId = object.rewardId; + } else { + message.rewardId = ""; + } + if (object.expireAt !== undefined && object.expireAt !== null) { + message.expireAt = object.expireAt; + } else { + message.expireAt = 0; + } + return message; + }, +}; + +const baseTradingRewardLeaderboard: object = { rewardId: "" }; + +export const TradingRewardLeaderboard = { + encode( + message: TradingRewardLeaderboard, + writer: Writer = Writer.create() + ): Writer { + if (message.rewardId !== "") { + writer.uint32(10).string(message.rewardId); + } + for (const v of message.list) { + TradingRewardLeaderboardEntry.encode( + v!, + writer.uint32(18).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): TradingRewardLeaderboard { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseTradingRewardLeaderboard, + } as TradingRewardLeaderboard; + message.list = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.rewardId = reader.string(); + break; + case 2: + message.list.push( + TradingRewardLeaderboardEntry.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): TradingRewardLeaderboard { + const message = { + ...baseTradingRewardLeaderboard, + } as TradingRewardLeaderboard; + message.list = []; + if (object.rewardId !== undefined && object.rewardId !== null) { + message.rewardId = String(object.rewardId); + } else { + message.rewardId = ""; + } + if (object.list !== undefined && object.list !== null) { + for (const e of object.list) { + message.list.push(TradingRewardLeaderboardEntry.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: TradingRewardLeaderboard): unknown { + const obj: any = {}; + message.rewardId !== undefined && (obj.rewardId = message.rewardId); + if (message.list) { + obj.list = message.list.map((e) => + e ? TradingRewardLeaderboardEntry.toJSON(e) : undefined + ); + } else { + obj.list = []; + } + return obj; + }, + + fromPartial( + object: DeepPartial + ): TradingRewardLeaderboard { + const message = { + ...baseTradingRewardLeaderboard, + } as TradingRewardLeaderboard; + message.list = []; + if (object.rewardId !== undefined && object.rewardId !== null) { + message.rewardId = object.rewardId; + } else { + message.rewardId = ""; + } + if (object.list !== undefined && object.list !== null) { + for (const e of object.list) { + message.list.push(TradingRewardLeaderboardEntry.fromPartial(e)); + } + } + return message; + }, +}; + +const baseTradingRewardLeaderboardEntry: object = { + amount: "", + address: "", + createdAt: 0, +}; + +export const TradingRewardLeaderboardEntry = { + encode( + message: TradingRewardLeaderboardEntry, + writer: Writer = Writer.create() + ): Writer { + if (message.amount !== "") { + writer.uint32(10).string(message.amount); + } + if (message.address !== "") { + writer.uint32(18).string(message.address); + } + if (message.createdAt !== 0) { + writer.uint32(24).int64(message.createdAt); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): TradingRewardLeaderboardEntry { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseTradingRewardLeaderboardEntry, + } as TradingRewardLeaderboardEntry; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.amount = reader.string(); + break; + case 2: + message.address = reader.string(); + break; + case 3: + message.createdAt = longToNumber(reader.int64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): TradingRewardLeaderboardEntry { + const message = { + ...baseTradingRewardLeaderboardEntry, + } as TradingRewardLeaderboardEntry; + if (object.amount !== undefined && object.amount !== null) { + message.amount = String(object.amount); + } else { + message.amount = ""; + } + if (object.address !== undefined && object.address !== null) { + message.address = String(object.address); + } else { + message.address = ""; + } + if (object.createdAt !== undefined && object.createdAt !== null) { + message.createdAt = Number(object.createdAt); + } else { + message.createdAt = 0; + } + return message; + }, + + toJSON(message: TradingRewardLeaderboardEntry): unknown { + const obj: any = {}; + message.amount !== undefined && (obj.amount = message.amount); + message.address !== undefined && (obj.address = message.address); + message.createdAt !== undefined && (obj.createdAt = message.createdAt); + return obj; + }, + + fromPartial( + object: DeepPartial + ): TradingRewardLeaderboardEntry { + const message = { + ...baseTradingRewardLeaderboardEntry, + } as TradingRewardLeaderboardEntry; + if (object.amount !== undefined && object.amount !== null) { + message.amount = object.amount; + } else { + message.amount = ""; + } + if (object.address !== undefined && object.address !== null) { + message.address = object.address; + } else { + message.address = ""; + } + if (object.createdAt !== undefined && object.createdAt !== null) { + message.createdAt = object.createdAt; + } else { + message.createdAt = 0; + } + return message; + }, +}; + +const baseTradingRewardCandidate: object = { + rewardId: "", + amount: "", + address: "", +}; + +export const TradingRewardCandidate = { + encode( + message: TradingRewardCandidate, + writer: Writer = Writer.create() + ): Writer { + if (message.rewardId !== "") { + writer.uint32(10).string(message.rewardId); + } + if (message.amount !== "") { + writer.uint32(18).string(message.amount); + } + if (message.address !== "") { + writer.uint32(26).string(message.address); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): TradingRewardCandidate { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseTradingRewardCandidate } as TradingRewardCandidate; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.rewardId = reader.string(); + break; + case 2: + message.amount = reader.string(); + break; + case 3: + message.address = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): TradingRewardCandidate { + const message = { ...baseTradingRewardCandidate } as TradingRewardCandidate; + if (object.rewardId !== undefined && object.rewardId !== null) { + message.rewardId = String(object.rewardId); + } else { + message.rewardId = ""; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = String(object.amount); + } else { + message.amount = ""; + } + if (object.address !== undefined && object.address !== null) { + message.address = String(object.address); + } else { + message.address = ""; + } + return message; + }, + + toJSON(message: TradingRewardCandidate): unknown { + const obj: any = {}; + message.rewardId !== undefined && (obj.rewardId = message.rewardId); + message.amount !== undefined && (obj.amount = message.amount); + message.address !== undefined && (obj.address = message.address); + return obj; + }, + + fromPartial( + object: DeepPartial + ): TradingRewardCandidate { + const message = { ...baseTradingRewardCandidate } as TradingRewardCandidate; + if (object.rewardId !== undefined && object.rewardId !== null) { + message.rewardId = object.rewardId; + } else { + message.rewardId = ""; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = object.amount; + } else { + message.amount = ""; + } + if (object.address !== undefined && object.address !== null) { + message.address = object.address; + } else { + message.address = ""; + } + return message; + }, +}; + +const baseMarketIdTradingRewardId: object = { rewardId: "", marketId: "" }; + +export const MarketIdTradingRewardId = { + encode( + message: MarketIdTradingRewardId, + writer: Writer = Writer.create() + ): Writer { + if (message.rewardId !== "") { + writer.uint32(10).string(message.rewardId); + } + if (message.marketId !== "") { + writer.uint32(18).string(message.marketId); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MarketIdTradingRewardId { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseMarketIdTradingRewardId, + } as MarketIdTradingRewardId; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.rewardId = reader.string(); + break; + case 2: + message.marketId = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MarketIdTradingRewardId { + const message = { + ...baseMarketIdTradingRewardId, + } as MarketIdTradingRewardId; + if (object.rewardId !== undefined && object.rewardId !== null) { + message.rewardId = String(object.rewardId); + } else { + message.rewardId = ""; + } + if (object.marketId !== undefined && object.marketId !== null) { + message.marketId = String(object.marketId); + } else { + message.marketId = ""; + } + return message; + }, + + toJSON(message: MarketIdTradingRewardId): unknown { + const obj: any = {}; + message.rewardId !== undefined && (obj.rewardId = message.rewardId); + message.marketId !== undefined && (obj.marketId = message.marketId); + return obj; + }, + + fromPartial( + object: DeepPartial + ): MarketIdTradingRewardId { + const message = { + ...baseMarketIdTradingRewardId, + } as MarketIdTradingRewardId; + if (object.rewardId !== undefined && object.rewardId !== null) { + message.rewardId = object.rewardId; + } else { + message.rewardId = ""; + } + if (object.marketId !== undefined && object.marketId !== null) { + message.marketId = object.marketId; + } else { + message.marketId = ""; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/bze.v1.rewards/types/rewards/tx.ts b/ts-client/bze.v1.rewards/types/rewards/tx.ts new file mode 100644 index 00000000..73a013e0 --- /dev/null +++ b/ts-client/bze.v1.rewards/types/rewards/tx.ts @@ -0,0 +1,1185 @@ +/* eslint-disable */ +import { Reader, Writer } from "protobufjs/minimal"; + +export const protobufPackage = "bze.v1.rewards"; + +export interface MsgCreateStakingReward { + /** msg creator */ + creator: string; + /** the amount paid as prize for each epoch (duration) */ + prizeAmount: string; + /** the denom paid as prize */ + prizeDenom: string; + /** the denom a user has to stake in order to qualify */ + stakingDenom: string; + /** the number of days the rewards are paid */ + duration: string; + /** the minimum amount of staking denom a user has to stake in order to qualify */ + minStake: string; + /** the number of days the funds are locked upon exiting stake */ + lock: string; +} + +export interface MsgCreateStakingRewardResponse { + rewardId: string; +} + +export interface MsgUpdateStakingReward { + creator: string; + rewardId: string; + /** the number of days the rewards are paid */ + duration: string; +} + +export interface MsgUpdateStakingRewardResponse {} + +export interface MsgCreateTradingReward { + creator: string; + /** the amount paid as prize for each slot */ + prizeAmount: string; + /** the denom paid as prize */ + prizeDenom: string; + duration: string; + marketId: string; + slots: string; +} + +export interface MsgCreateTradingRewardResponse { + rewardId: string; +} + +export interface MsgJoinStaking { + creator: string; + rewardId: string; + amount: string; +} + +export interface MsgJoinStakingResponse {} + +export interface MsgExitStaking { + creator: string; + rewardId: string; +} + +export interface MsgExitStakingResponse {} + +export interface MsgClaimStakingRewards { + creator: string; + rewardId: string; +} + +export interface MsgClaimStakingRewardsResponse { + amount: string; +} + +const baseMsgCreateStakingReward: object = { + creator: "", + prizeAmount: "", + prizeDenom: "", + stakingDenom: "", + duration: "", + minStake: "", + lock: "", +}; + +export const MsgCreateStakingReward = { + encode( + message: MsgCreateStakingReward, + writer: Writer = Writer.create() + ): Writer { + if (message.creator !== "") { + writer.uint32(10).string(message.creator); + } + if (message.prizeAmount !== "") { + writer.uint32(18).string(message.prizeAmount); + } + if (message.prizeDenom !== "") { + writer.uint32(26).string(message.prizeDenom); + } + if (message.stakingDenom !== "") { + writer.uint32(34).string(message.stakingDenom); + } + if (message.duration !== "") { + writer.uint32(42).string(message.duration); + } + if (message.minStake !== "") { + writer.uint32(50).string(message.minStake); + } + if (message.lock !== "") { + writer.uint32(58).string(message.lock); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MsgCreateStakingReward { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgCreateStakingReward } as MsgCreateStakingReward; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.creator = reader.string(); + break; + case 2: + message.prizeAmount = reader.string(); + break; + case 3: + message.prizeDenom = reader.string(); + break; + case 4: + message.stakingDenom = reader.string(); + break; + case 5: + message.duration = reader.string(); + break; + case 6: + message.minStake = reader.string(); + break; + case 7: + message.lock = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgCreateStakingReward { + const message = { ...baseMsgCreateStakingReward } as MsgCreateStakingReward; + if (object.creator !== undefined && object.creator !== null) { + message.creator = String(object.creator); + } else { + message.creator = ""; + } + if (object.prizeAmount !== undefined && object.prizeAmount !== null) { + message.prizeAmount = String(object.prizeAmount); + } else { + message.prizeAmount = ""; + } + if (object.prizeDenom !== undefined && object.prizeDenom !== null) { + message.prizeDenom = String(object.prizeDenom); + } else { + message.prizeDenom = ""; + } + if (object.stakingDenom !== undefined && object.stakingDenom !== null) { + message.stakingDenom = String(object.stakingDenom); + } else { + message.stakingDenom = ""; + } + if (object.duration !== undefined && object.duration !== null) { + message.duration = String(object.duration); + } else { + message.duration = ""; + } + if (object.minStake !== undefined && object.minStake !== null) { + message.minStake = String(object.minStake); + } else { + message.minStake = ""; + } + if (object.lock !== undefined && object.lock !== null) { + message.lock = String(object.lock); + } else { + message.lock = ""; + } + return message; + }, + + toJSON(message: MsgCreateStakingReward): unknown { + const obj: any = {}; + message.creator !== undefined && (obj.creator = message.creator); + message.prizeAmount !== undefined && + (obj.prizeAmount = message.prizeAmount); + message.prizeDenom !== undefined && (obj.prizeDenom = message.prizeDenom); + message.stakingDenom !== undefined && + (obj.stakingDenom = message.stakingDenom); + message.duration !== undefined && (obj.duration = message.duration); + message.minStake !== undefined && (obj.minStake = message.minStake); + message.lock !== undefined && (obj.lock = message.lock); + return obj; + }, + + fromPartial( + object: DeepPartial + ): MsgCreateStakingReward { + const message = { ...baseMsgCreateStakingReward } as MsgCreateStakingReward; + if (object.creator !== undefined && object.creator !== null) { + message.creator = object.creator; + } else { + message.creator = ""; + } + if (object.prizeAmount !== undefined && object.prizeAmount !== null) { + message.prizeAmount = object.prizeAmount; + } else { + message.prizeAmount = ""; + } + if (object.prizeDenom !== undefined && object.prizeDenom !== null) { + message.prizeDenom = object.prizeDenom; + } else { + message.prizeDenom = ""; + } + if (object.stakingDenom !== undefined && object.stakingDenom !== null) { + message.stakingDenom = object.stakingDenom; + } else { + message.stakingDenom = ""; + } + if (object.duration !== undefined && object.duration !== null) { + message.duration = object.duration; + } else { + message.duration = ""; + } + if (object.minStake !== undefined && object.minStake !== null) { + message.minStake = object.minStake; + } else { + message.minStake = ""; + } + if (object.lock !== undefined && object.lock !== null) { + message.lock = object.lock; + } else { + message.lock = ""; + } + return message; + }, +}; + +const baseMsgCreateStakingRewardResponse: object = { rewardId: "" }; + +export const MsgCreateStakingRewardResponse = { + encode( + message: MsgCreateStakingRewardResponse, + writer: Writer = Writer.create() + ): Writer { + if (message.rewardId !== "") { + writer.uint32(10).string(message.rewardId); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): MsgCreateStakingRewardResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseMsgCreateStakingRewardResponse, + } as MsgCreateStakingRewardResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.rewardId = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgCreateStakingRewardResponse { + const message = { + ...baseMsgCreateStakingRewardResponse, + } as MsgCreateStakingRewardResponse; + if (object.rewardId !== undefined && object.rewardId !== null) { + message.rewardId = String(object.rewardId); + } else { + message.rewardId = ""; + } + return message; + }, + + toJSON(message: MsgCreateStakingRewardResponse): unknown { + const obj: any = {}; + message.rewardId !== undefined && (obj.rewardId = message.rewardId); + return obj; + }, + + fromPartial( + object: DeepPartial + ): MsgCreateStakingRewardResponse { + const message = { + ...baseMsgCreateStakingRewardResponse, + } as MsgCreateStakingRewardResponse; + if (object.rewardId !== undefined && object.rewardId !== null) { + message.rewardId = object.rewardId; + } else { + message.rewardId = ""; + } + return message; + }, +}; + +const baseMsgUpdateStakingReward: object = { + creator: "", + rewardId: "", + duration: "", +}; + +export const MsgUpdateStakingReward = { + encode( + message: MsgUpdateStakingReward, + writer: Writer = Writer.create() + ): Writer { + if (message.creator !== "") { + writer.uint32(10).string(message.creator); + } + if (message.rewardId !== "") { + writer.uint32(18).string(message.rewardId); + } + if (message.duration !== "") { + writer.uint32(26).string(message.duration); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MsgUpdateStakingReward { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgUpdateStakingReward } as MsgUpdateStakingReward; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.creator = reader.string(); + break; + case 2: + message.rewardId = reader.string(); + break; + case 3: + message.duration = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgUpdateStakingReward { + const message = { ...baseMsgUpdateStakingReward } as MsgUpdateStakingReward; + if (object.creator !== undefined && object.creator !== null) { + message.creator = String(object.creator); + } else { + message.creator = ""; + } + if (object.rewardId !== undefined && object.rewardId !== null) { + message.rewardId = String(object.rewardId); + } else { + message.rewardId = ""; + } + if (object.duration !== undefined && object.duration !== null) { + message.duration = String(object.duration); + } else { + message.duration = ""; + } + return message; + }, + + toJSON(message: MsgUpdateStakingReward): unknown { + const obj: any = {}; + message.creator !== undefined && (obj.creator = message.creator); + message.rewardId !== undefined && (obj.rewardId = message.rewardId); + message.duration !== undefined && (obj.duration = message.duration); + return obj; + }, + + fromPartial( + object: DeepPartial + ): MsgUpdateStakingReward { + const message = { ...baseMsgUpdateStakingReward } as MsgUpdateStakingReward; + if (object.creator !== undefined && object.creator !== null) { + message.creator = object.creator; + } else { + message.creator = ""; + } + if (object.rewardId !== undefined && object.rewardId !== null) { + message.rewardId = object.rewardId; + } else { + message.rewardId = ""; + } + if (object.duration !== undefined && object.duration !== null) { + message.duration = object.duration; + } else { + message.duration = ""; + } + return message; + }, +}; + +const baseMsgUpdateStakingRewardResponse: object = {}; + +export const MsgUpdateStakingRewardResponse = { + encode( + _: MsgUpdateStakingRewardResponse, + writer: Writer = Writer.create() + ): Writer { + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): MsgUpdateStakingRewardResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseMsgUpdateStakingRewardResponse, + } as MsgUpdateStakingRewardResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): MsgUpdateStakingRewardResponse { + const message = { + ...baseMsgUpdateStakingRewardResponse, + } as MsgUpdateStakingRewardResponse; + return message; + }, + + toJSON(_: MsgUpdateStakingRewardResponse): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial( + _: DeepPartial + ): MsgUpdateStakingRewardResponse { + const message = { + ...baseMsgUpdateStakingRewardResponse, + } as MsgUpdateStakingRewardResponse; + return message; + }, +}; + +const baseMsgCreateTradingReward: object = { + creator: "", + prizeAmount: "", + prizeDenom: "", + duration: "", + marketId: "", + slots: "", +}; + +export const MsgCreateTradingReward = { + encode( + message: MsgCreateTradingReward, + writer: Writer = Writer.create() + ): Writer { + if (message.creator !== "") { + writer.uint32(10).string(message.creator); + } + if (message.prizeAmount !== "") { + writer.uint32(18).string(message.prizeAmount); + } + if (message.prizeDenom !== "") { + writer.uint32(26).string(message.prizeDenom); + } + if (message.duration !== "") { + writer.uint32(34).string(message.duration); + } + if (message.marketId !== "") { + writer.uint32(42).string(message.marketId); + } + if (message.slots !== "") { + writer.uint32(50).string(message.slots); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MsgCreateTradingReward { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgCreateTradingReward } as MsgCreateTradingReward; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.creator = reader.string(); + break; + case 2: + message.prizeAmount = reader.string(); + break; + case 3: + message.prizeDenom = reader.string(); + break; + case 4: + message.duration = reader.string(); + break; + case 5: + message.marketId = reader.string(); + break; + case 6: + message.slots = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgCreateTradingReward { + const message = { ...baseMsgCreateTradingReward } as MsgCreateTradingReward; + if (object.creator !== undefined && object.creator !== null) { + message.creator = String(object.creator); + } else { + message.creator = ""; + } + if (object.prizeAmount !== undefined && object.prizeAmount !== null) { + message.prizeAmount = String(object.prizeAmount); + } else { + message.prizeAmount = ""; + } + if (object.prizeDenom !== undefined && object.prizeDenom !== null) { + message.prizeDenom = String(object.prizeDenom); + } else { + message.prizeDenom = ""; + } + if (object.duration !== undefined && object.duration !== null) { + message.duration = String(object.duration); + } else { + message.duration = ""; + } + if (object.marketId !== undefined && object.marketId !== null) { + message.marketId = String(object.marketId); + } else { + message.marketId = ""; + } + if (object.slots !== undefined && object.slots !== null) { + message.slots = String(object.slots); + } else { + message.slots = ""; + } + return message; + }, + + toJSON(message: MsgCreateTradingReward): unknown { + const obj: any = {}; + message.creator !== undefined && (obj.creator = message.creator); + message.prizeAmount !== undefined && + (obj.prizeAmount = message.prizeAmount); + message.prizeDenom !== undefined && (obj.prizeDenom = message.prizeDenom); + message.duration !== undefined && (obj.duration = message.duration); + message.marketId !== undefined && (obj.marketId = message.marketId); + message.slots !== undefined && (obj.slots = message.slots); + return obj; + }, + + fromPartial( + object: DeepPartial + ): MsgCreateTradingReward { + const message = { ...baseMsgCreateTradingReward } as MsgCreateTradingReward; + if (object.creator !== undefined && object.creator !== null) { + message.creator = object.creator; + } else { + message.creator = ""; + } + if (object.prizeAmount !== undefined && object.prizeAmount !== null) { + message.prizeAmount = object.prizeAmount; + } else { + message.prizeAmount = ""; + } + if (object.prizeDenom !== undefined && object.prizeDenom !== null) { + message.prizeDenom = object.prizeDenom; + } else { + message.prizeDenom = ""; + } + if (object.duration !== undefined && object.duration !== null) { + message.duration = object.duration; + } else { + message.duration = ""; + } + if (object.marketId !== undefined && object.marketId !== null) { + message.marketId = object.marketId; + } else { + message.marketId = ""; + } + if (object.slots !== undefined && object.slots !== null) { + message.slots = object.slots; + } else { + message.slots = ""; + } + return message; + }, +}; + +const baseMsgCreateTradingRewardResponse: object = { rewardId: "" }; + +export const MsgCreateTradingRewardResponse = { + encode( + message: MsgCreateTradingRewardResponse, + writer: Writer = Writer.create() + ): Writer { + if (message.rewardId !== "") { + writer.uint32(10).string(message.rewardId); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): MsgCreateTradingRewardResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseMsgCreateTradingRewardResponse, + } as MsgCreateTradingRewardResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.rewardId = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgCreateTradingRewardResponse { + const message = { + ...baseMsgCreateTradingRewardResponse, + } as MsgCreateTradingRewardResponse; + if (object.rewardId !== undefined && object.rewardId !== null) { + message.rewardId = String(object.rewardId); + } else { + message.rewardId = ""; + } + return message; + }, + + toJSON(message: MsgCreateTradingRewardResponse): unknown { + const obj: any = {}; + message.rewardId !== undefined && (obj.rewardId = message.rewardId); + return obj; + }, + + fromPartial( + object: DeepPartial + ): MsgCreateTradingRewardResponse { + const message = { + ...baseMsgCreateTradingRewardResponse, + } as MsgCreateTradingRewardResponse; + if (object.rewardId !== undefined && object.rewardId !== null) { + message.rewardId = object.rewardId; + } else { + message.rewardId = ""; + } + return message; + }, +}; + +const baseMsgJoinStaking: object = { creator: "", rewardId: "", amount: "" }; + +export const MsgJoinStaking = { + encode(message: MsgJoinStaking, writer: Writer = Writer.create()): Writer { + if (message.creator !== "") { + writer.uint32(10).string(message.creator); + } + if (message.rewardId !== "") { + writer.uint32(18).string(message.rewardId); + } + if (message.amount !== "") { + writer.uint32(26).string(message.amount); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MsgJoinStaking { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgJoinStaking } as MsgJoinStaking; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.creator = reader.string(); + break; + case 2: + message.rewardId = reader.string(); + break; + case 3: + message.amount = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgJoinStaking { + const message = { ...baseMsgJoinStaking } as MsgJoinStaking; + if (object.creator !== undefined && object.creator !== null) { + message.creator = String(object.creator); + } else { + message.creator = ""; + } + if (object.rewardId !== undefined && object.rewardId !== null) { + message.rewardId = String(object.rewardId); + } else { + message.rewardId = ""; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = String(object.amount); + } else { + message.amount = ""; + } + return message; + }, + + toJSON(message: MsgJoinStaking): unknown { + const obj: any = {}; + message.creator !== undefined && (obj.creator = message.creator); + message.rewardId !== undefined && (obj.rewardId = message.rewardId); + message.amount !== undefined && (obj.amount = message.amount); + return obj; + }, + + fromPartial(object: DeepPartial): MsgJoinStaking { + const message = { ...baseMsgJoinStaking } as MsgJoinStaking; + if (object.creator !== undefined && object.creator !== null) { + message.creator = object.creator; + } else { + message.creator = ""; + } + if (object.rewardId !== undefined && object.rewardId !== null) { + message.rewardId = object.rewardId; + } else { + message.rewardId = ""; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = object.amount; + } else { + message.amount = ""; + } + return message; + }, +}; + +const baseMsgJoinStakingResponse: object = {}; + +export const MsgJoinStakingResponse = { + encode(_: MsgJoinStakingResponse, writer: Writer = Writer.create()): Writer { + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MsgJoinStakingResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgJoinStakingResponse } as MsgJoinStakingResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): MsgJoinStakingResponse { + const message = { ...baseMsgJoinStakingResponse } as MsgJoinStakingResponse; + return message; + }, + + toJSON(_: MsgJoinStakingResponse): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial(_: DeepPartial): MsgJoinStakingResponse { + const message = { ...baseMsgJoinStakingResponse } as MsgJoinStakingResponse; + return message; + }, +}; + +const baseMsgExitStaking: object = { creator: "", rewardId: "" }; + +export const MsgExitStaking = { + encode(message: MsgExitStaking, writer: Writer = Writer.create()): Writer { + if (message.creator !== "") { + writer.uint32(10).string(message.creator); + } + if (message.rewardId !== "") { + writer.uint32(18).string(message.rewardId); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MsgExitStaking { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgExitStaking } as MsgExitStaking; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.creator = reader.string(); + break; + case 2: + message.rewardId = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgExitStaking { + const message = { ...baseMsgExitStaking } as MsgExitStaking; + if (object.creator !== undefined && object.creator !== null) { + message.creator = String(object.creator); + } else { + message.creator = ""; + } + if (object.rewardId !== undefined && object.rewardId !== null) { + message.rewardId = String(object.rewardId); + } else { + message.rewardId = ""; + } + return message; + }, + + toJSON(message: MsgExitStaking): unknown { + const obj: any = {}; + message.creator !== undefined && (obj.creator = message.creator); + message.rewardId !== undefined && (obj.rewardId = message.rewardId); + return obj; + }, + + fromPartial(object: DeepPartial): MsgExitStaking { + const message = { ...baseMsgExitStaking } as MsgExitStaking; + if (object.creator !== undefined && object.creator !== null) { + message.creator = object.creator; + } else { + message.creator = ""; + } + if (object.rewardId !== undefined && object.rewardId !== null) { + message.rewardId = object.rewardId; + } else { + message.rewardId = ""; + } + return message; + }, +}; + +const baseMsgExitStakingResponse: object = {}; + +export const MsgExitStakingResponse = { + encode(_: MsgExitStakingResponse, writer: Writer = Writer.create()): Writer { + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MsgExitStakingResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgExitStakingResponse } as MsgExitStakingResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): MsgExitStakingResponse { + const message = { ...baseMsgExitStakingResponse } as MsgExitStakingResponse; + return message; + }, + + toJSON(_: MsgExitStakingResponse): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial(_: DeepPartial): MsgExitStakingResponse { + const message = { ...baseMsgExitStakingResponse } as MsgExitStakingResponse; + return message; + }, +}; + +const baseMsgClaimStakingRewards: object = { creator: "", rewardId: "" }; + +export const MsgClaimStakingRewards = { + encode( + message: MsgClaimStakingRewards, + writer: Writer = Writer.create() + ): Writer { + if (message.creator !== "") { + writer.uint32(10).string(message.creator); + } + if (message.rewardId !== "") { + writer.uint32(18).string(message.rewardId); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MsgClaimStakingRewards { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgClaimStakingRewards } as MsgClaimStakingRewards; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.creator = reader.string(); + break; + case 2: + message.rewardId = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgClaimStakingRewards { + const message = { ...baseMsgClaimStakingRewards } as MsgClaimStakingRewards; + if (object.creator !== undefined && object.creator !== null) { + message.creator = String(object.creator); + } else { + message.creator = ""; + } + if (object.rewardId !== undefined && object.rewardId !== null) { + message.rewardId = String(object.rewardId); + } else { + message.rewardId = ""; + } + return message; + }, + + toJSON(message: MsgClaimStakingRewards): unknown { + const obj: any = {}; + message.creator !== undefined && (obj.creator = message.creator); + message.rewardId !== undefined && (obj.rewardId = message.rewardId); + return obj; + }, + + fromPartial( + object: DeepPartial + ): MsgClaimStakingRewards { + const message = { ...baseMsgClaimStakingRewards } as MsgClaimStakingRewards; + if (object.creator !== undefined && object.creator !== null) { + message.creator = object.creator; + } else { + message.creator = ""; + } + if (object.rewardId !== undefined && object.rewardId !== null) { + message.rewardId = object.rewardId; + } else { + message.rewardId = ""; + } + return message; + }, +}; + +const baseMsgClaimStakingRewardsResponse: object = { amount: "" }; + +export const MsgClaimStakingRewardsResponse = { + encode( + message: MsgClaimStakingRewardsResponse, + writer: Writer = Writer.create() + ): Writer { + if (message.amount !== "") { + writer.uint32(10).string(message.amount); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): MsgClaimStakingRewardsResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseMsgClaimStakingRewardsResponse, + } as MsgClaimStakingRewardsResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.amount = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgClaimStakingRewardsResponse { + const message = { + ...baseMsgClaimStakingRewardsResponse, + } as MsgClaimStakingRewardsResponse; + if (object.amount !== undefined && object.amount !== null) { + message.amount = String(object.amount); + } else { + message.amount = ""; + } + return message; + }, + + toJSON(message: MsgClaimStakingRewardsResponse): unknown { + const obj: any = {}; + message.amount !== undefined && (obj.amount = message.amount); + return obj; + }, + + fromPartial( + object: DeepPartial + ): MsgClaimStakingRewardsResponse { + const message = { + ...baseMsgClaimStakingRewardsResponse, + } as MsgClaimStakingRewardsResponse; + if (object.amount !== undefined && object.amount !== null) { + message.amount = object.amount; + } else { + message.amount = ""; + } + return message; + }, +}; + +/** Msg defines the Msg service. */ +export interface Msg { + CreateStakingReward( + request: MsgCreateStakingReward + ): Promise; + UpdateStakingReward( + request: MsgUpdateStakingReward + ): Promise; + CreateTradingReward( + request: MsgCreateTradingReward + ): Promise; + JoinStaking(request: MsgJoinStaking): Promise; + ExitStaking(request: MsgExitStaking): Promise; + /** this line is used by starport scaffolding # proto/tx/rpc */ + ClaimStakingRewards( + request: MsgClaimStakingRewards + ): Promise; +} + +export class MsgClientImpl implements Msg { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + } + CreateStakingReward( + request: MsgCreateStakingReward + ): Promise { + const data = MsgCreateStakingReward.encode(request).finish(); + const promise = this.rpc.request( + "bze.v1.rewards.Msg", + "CreateStakingReward", + data + ); + return promise.then((data) => + MsgCreateStakingRewardResponse.decode(new Reader(data)) + ); + } + + UpdateStakingReward( + request: MsgUpdateStakingReward + ): Promise { + const data = MsgUpdateStakingReward.encode(request).finish(); + const promise = this.rpc.request( + "bze.v1.rewards.Msg", + "UpdateStakingReward", + data + ); + return promise.then((data) => + MsgUpdateStakingRewardResponse.decode(new Reader(data)) + ); + } + + CreateTradingReward( + request: MsgCreateTradingReward + ): Promise { + const data = MsgCreateTradingReward.encode(request).finish(); + const promise = this.rpc.request( + "bze.v1.rewards.Msg", + "CreateTradingReward", + data + ); + return promise.then((data) => + MsgCreateTradingRewardResponse.decode(new Reader(data)) + ); + } + + JoinStaking(request: MsgJoinStaking): Promise { + const data = MsgJoinStaking.encode(request).finish(); + const promise = this.rpc.request("bze.v1.rewards.Msg", "JoinStaking", data); + return promise.then((data) => + MsgJoinStakingResponse.decode(new Reader(data)) + ); + } + + ExitStaking(request: MsgExitStaking): Promise { + const data = MsgExitStaking.encode(request).finish(); + const promise = this.rpc.request("bze.v1.rewards.Msg", "ExitStaking", data); + return promise.then((data) => + MsgExitStakingResponse.decode(new Reader(data)) + ); + } + + ClaimStakingRewards( + request: MsgClaimStakingRewards + ): Promise { + const data = MsgClaimStakingRewards.encode(request).finish(); + const promise = this.rpc.request( + "bze.v1.rewards.Msg", + "ClaimStakingRewards", + data + ); + return promise.then((data) => + MsgClaimStakingRewardsResponse.decode(new Reader(data)) + ); + } +} + +interface Rpc { + request( + service: string, + method: string, + data: Uint8Array + ): Promise; +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/client.ts b/ts-client/client.ts new file mode 100755 index 00000000..8badd9ce --- /dev/null +++ b/ts-client/client.ts @@ -0,0 +1,51 @@ +import { GeneratedType, OfflineSigner, EncodeObject, Registry } from "@cosmjs/proto-signing"; +import { StdFee } from "@cosmjs/launchpad"; +import { SigningStargateClient } from "@cosmjs/stargate"; +import { Env } from "./env"; +import { UnionToIntersection, Return, Constructor } from "./helpers"; +import { Module } from "./modules"; + +const defaultFee = { + amount: [], + gas: "200000", +}; + +export class IgniteClient { + static plugins: Module[] = []; + env: Env; + signer: OfflineSigner; + registry: Array<[string, GeneratedType]> = []; + static plugin(plugin: T) { + const currentPlugins = this.plugins; + + class AugmentedClient extends this { + static plugins = currentPlugins.concat(plugin); + } + + if (Array.isArray(plugin)) { + type Extension = UnionToIntersection['module']> + return AugmentedClient as typeof AugmentedClient & Constructor; + } + + type Extension = Return['module'] + return AugmentedClient as typeof AugmentedClient & Constructor; + } + async signAndBroadcast(msgs: EncodeObject[], fee: StdFee, memo: string) { + const { address } = (await this.signer.getAccounts())[0]; + const signingClient = await SigningStargateClient.connectWithSigner(this.env.rpcURL, this.signer, {registry: new Registry(this.registry), prefix: this.env.prefix}); + return await signingClient.signAndBroadcast(address, msgs, fee ? fee : defaultFee, memo) + } + constructor(env: Env, signer: OfflineSigner) { + this.env = env; + this.signer = signer; + const classConstructor = this.constructor as typeof IgniteClient; + classConstructor.plugins.forEach(plugin => { + const pluginInstance = plugin(this); + Object.assign(this, pluginInstance.module) + if (this.registry) { + this.registry = this.registry.concat(pluginInstance.registry) + } + }); + + } +} \ No newline at end of file diff --git a/ts-client/cosmos.auth.v1beta1/index.ts b/ts-client/cosmos.auth.v1beta1/index.ts new file mode 100755 index 00000000..c9dfa159 --- /dev/null +++ b/ts-client/cosmos.auth.v1beta1/index.ts @@ -0,0 +1,6 @@ +import Module from './module'; +import { txClient, queryClient, registry } from './module'; +import { msgTypes } from './registry'; + +export * from "./types"; +export { Module, msgTypes, txClient, queryClient, registry }; diff --git a/ts-client/cosmos.auth.v1beta1/module.ts b/ts-client/cosmos.auth.v1beta1/module.ts new file mode 100755 index 00000000..1078e697 --- /dev/null +++ b/ts-client/cosmos.auth.v1beta1/module.ts @@ -0,0 +1,66 @@ +// Generated by Ignite ignite.com/cli + +import { StdFee } from "@cosmjs/launchpad"; +import { SigningStargateClient, DeliverTxResponse } from "@cosmjs/stargate"; +import { EncodeObject, GeneratedType, OfflineSigner, Registry } from "@cosmjs/proto-signing"; +import { msgTypes } from './registry'; +import { IgniteClient } from "../client" +import { MissingWalletError } from "../helpers" +import { Api } from "./rest"; + + +export { }; + + + +export const registry = new Registry(msgTypes); + +const defaultFee = { + amount: [], + gas: "200000", +}; + +interface TxClientOptions { + addr: string + prefix: string + signer?: OfflineSigner +} + +export const txClient = ({ signer, prefix, addr }: TxClientOptions = { addr: "http://localhost:26657", prefix: "cosmos" }) => { + + return { + + + } +}; + +interface QueryClientOptions { + addr: string +} + +export const queryClient = ({ addr: addr }: QueryClientOptions = { addr: "http://localhost:1317" }) => { + return new Api({ baseUrl: addr }); +}; + +class SDKModule { + public query: ReturnType; + public tx: ReturnType; + + public registry: Array<[string, GeneratedType]>; + + constructor(client: IgniteClient) { + + this.query = queryClient({ addr: client.env.apiURL }); + this.tx = txClient({ signer: client.signer, addr: client.env.rpcURL, prefix: client.env.prefix ?? "cosmos" }); + } +}; + +const Module = (test: IgniteClient) => { + return { + module: { + CosmosAuthV1Beta1: new SDKModule(test) + }, + registry: msgTypes + } +} +export default Module; \ No newline at end of file diff --git a/ts-client/cosmos.auth.v1beta1/registry.ts b/ts-client/cosmos.auth.v1beta1/registry.ts new file mode 100755 index 00000000..26157e4f --- /dev/null +++ b/ts-client/cosmos.auth.v1beta1/registry.ts @@ -0,0 +1,7 @@ +import { GeneratedType } from "@cosmjs/proto-signing"; + +const msgTypes: Array<[string, GeneratedType]> = [ + +]; + +export { msgTypes } \ No newline at end of file diff --git a/ts-client/cosmos.auth.v1beta1/rest.ts b/ts-client/cosmos.auth.v1beta1/rest.ts new file mode 100644 index 00000000..83c49342 --- /dev/null +++ b/ts-client/cosmos.auth.v1beta1/rest.ts @@ -0,0 +1,607 @@ +/* eslint-disable */ +/* tslint:disable */ +/* + * --------------------------------------------------------------- + * ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ## + * ## ## + * ## AUTHOR: acacode ## + * ## SOURCE: https://github.com/acacode/swagger-typescript-api ## + * --------------------------------------------------------------- + */ + +/** + * Params defines the parameters for the auth module. + */ +export interface Authv1Beta1Params { + /** @format uint64 */ + max_memo_characters?: string; + + /** @format uint64 */ + tx_sig_limit?: string; + + /** @format uint64 */ + tx_size_cost_per_byte?: string; + + /** @format uint64 */ + sig_verify_cost_ed25519?: string; + + /** @format uint64 */ + sig_verify_cost_secp256k1?: string; +} + +/** +* `Any` contains an arbitrary serialized protocol buffer message along with a +URL that describes the type of the serialized message. + +Protobuf library provides support to pack/unpack Any values in the form +of utility functions or additional generated methods of the Any type. + +Example 1: Pack and unpack a message in C++. + + Foo foo = ...; + Any any; + any.PackFrom(foo); + ... + if (any.UnpackTo(&foo)) { + ... + } + +Example 2: Pack and unpack a message in Java. + + Foo foo = ...; + Any any = Any.pack(foo); + ... + if (any.is(Foo.class)) { + foo = any.unpack(Foo.class); + } + + Example 3: Pack and unpack a message in Python. + + foo = Foo(...) + any = Any() + any.Pack(foo) + ... + if any.Is(Foo.DESCRIPTOR): + any.Unpack(foo) + ... + + Example 4: Pack and unpack a message in Go + + foo := &pb.Foo{...} + any, err := anypb.New(foo) + if err != nil { + ... + } + ... + foo := &pb.Foo{} + if err := any.UnmarshalTo(foo); err != nil { + ... + } + +The pack methods provided by protobuf library will by default use +'type.googleapis.com/full.type.name' as the type URL and the unpack +methods only use the fully qualified type name after the last '/' +in the type URL, for example "foo.bar.com/x/y.z" will yield type +name "y.z". + + +JSON +==== +The JSON representation of an `Any` value uses the regular +representation of the deserialized, embedded message, with an +additional field `@type` which contains the type URL. Example: + + package google.profile; + message Person { + string first_name = 1; + string last_name = 2; + } + + { + "@type": "type.googleapis.com/google.profile.Person", + "firstName": , + "lastName": + } + +If the embedded message type is well-known and has a custom JSON +representation, that representation will be embedded adding a field +`value` which holds the custom JSON in addition to the `@type` +field. Example (for message [google.protobuf.Duration][]): + + { + "@type": "type.googleapis.com/google.protobuf.Duration", + "value": "1.212s" + } +*/ +export interface ProtobufAny { + /** + * A URL/resource name that uniquely identifies the type of the serialized + * protocol buffer message. This string must contain at least + * one "/" character. The last segment of the URL's path must represent + * the fully qualified name of the type (as in + * `path/google.protobuf.Duration`). The name should be in a canonical form + * (e.g., leading "." is not accepted). + * + * In practice, teams usually precompile into the binary all types that they + * expect it to use in the context of Any. However, for URLs which use the + * scheme `http`, `https`, or no scheme, one can optionally set up a type + * server that maps type URLs to message definitions as follows: + * + * * If no scheme is provided, `https` is assumed. + * * An HTTP GET on the URL must yield a [google.protobuf.Type][] + * value in binary format, or produce an error. + * * Applications are allowed to cache lookup results based on the + * URL, or have them precompiled into a binary to avoid any + * lookup. Therefore, binary compatibility needs to be preserved + * on changes to types. (Use versioned type names to manage + * breaking changes.) + * + * Note: this functionality is not currently available in the official + * protobuf release, and it is not used for type URLs beginning with + * type.googleapis.com. + * + * Schemes other than `http`, `https` (or the empty scheme) might be + * used with implementation specific semantics. + */ + "@type"?: string; +} + +export interface RpcStatus { + /** @format int32 */ + code?: number; + message?: string; + details?: ProtobufAny[]; +} + +/** +* message SomeRequest { + Foo some_parameter = 1; + PageRequest pagination = 2; + } +*/ +export interface V1Beta1PageRequest { + /** + * key is a value returned in PageResponse.next_key to begin + * querying the next page most efficiently. Only one of offset or key + * should be set. + * @format byte + */ + key?: string; + + /** + * offset is a numeric offset that can be used when key is unavailable. + * It is less efficient than using key. Only one of offset or key should + * be set. + * @format uint64 + */ + offset?: string; + + /** + * limit is the total number of results to be returned in the result page. + * If left empty it will default to a value to be set by each app. + * @format uint64 + */ + limit?: string; + + /** + * count_total is set to true to indicate that the result set should include + * a count of the total number of items available for pagination in UIs. + * count_total is only respected when offset is used. It is ignored when key + * is set. + */ + count_total?: boolean; + + /** + * reverse is set to true if results are to be returned in the descending order. + * + * Since: cosmos-sdk 0.43 + */ + reverse?: boolean; +} + +/** +* PageResponse is to be embedded in gRPC response messages where the +corresponding request message has used PageRequest. + + message SomeResponse { + repeated Bar results = 1; + PageResponse page = 2; + } +*/ +export interface V1Beta1PageResponse { + /** @format byte */ + next_key?: string; + + /** @format uint64 */ + total?: string; +} + +/** + * QueryAccountResponse is the response type for the Query/Account RPC method. + */ +export interface V1Beta1QueryAccountResponse { + /** account defines the account of the corresponding address. */ + account?: ProtobufAny; +} + +/** +* QueryAccountsResponse is the response type for the Query/Accounts RPC method. + +Since: cosmos-sdk 0.43 +*/ +export interface V1Beta1QueryAccountsResponse { + accounts?: ProtobufAny[]; + + /** pagination defines the pagination in the response. */ + pagination?: V1Beta1PageResponse; +} + +/** + * QueryModuleAccountByNameResponse is the response type for the Query/ModuleAccountByName RPC method. + */ +export interface V1Beta1QueryModuleAccountByNameResponse { + /** + * `Any` contains an arbitrary serialized protocol buffer message along with a + * URL that describes the type of the serialized message. + * + * Protobuf library provides support to pack/unpack Any values in the form + * of utility functions or additional generated methods of the Any type. + * + * Example 1: Pack and unpack a message in C++. + * + * Foo foo = ...; + * Any any; + * any.PackFrom(foo); + * ... + * if (any.UnpackTo(&foo)) { + * ... + * } + * + * Example 2: Pack and unpack a message in Java. + * + * Foo foo = ...; + * Any any = Any.pack(foo); + * ... + * if (any.is(Foo.class)) { + * foo = any.unpack(Foo.class); + * } + * + * Example 3: Pack and unpack a message in Python. + * + * foo = Foo(...) + * any = Any() + * any.Pack(foo) + * ... + * if any.Is(Foo.DESCRIPTOR): + * any.Unpack(foo) + * ... + * + * Example 4: Pack and unpack a message in Go + * + * foo := &pb.Foo{...} + * any, err := anypb.New(foo) + * if err != nil { + * ... + * } + * ... + * foo := &pb.Foo{} + * if err := any.UnmarshalTo(foo); err != nil { + * ... + * } + * + * The pack methods provided by protobuf library will by default use + * 'type.googleapis.com/full.type.name' as the type URL and the unpack + * methods only use the fully qualified type name after the last '/' + * in the type URL, for example "foo.bar.com/x/y.z" will yield type + * name "y.z". + * + * + * JSON + * ==== + * The JSON representation of an `Any` value uses the regular + * representation of the deserialized, embedded message, with an + * additional field `@type` which contains the type URL. Example: + * + * package google.profile; + * message Person { + * string first_name = 1; + * string last_name = 2; + * } + * + * { + * "@type": "type.googleapis.com/google.profile.Person", + * "firstName": , + * "lastName": + * } + * + * If the embedded message type is well-known and has a custom JSON + * representation, that representation will be embedded adding a field + * `value` which holds the custom JSON in addition to the `@type` + * field. Example (for message [google.protobuf.Duration][]): + * + * { + * "@type": "type.googleapis.com/google.protobuf.Duration", + * "value": "1.212s" + * } + */ + account?: ProtobufAny; +} + +/** + * QueryParamsResponse is the response type for the Query/Params RPC method. + */ +export interface V1Beta1QueryParamsResponse { + /** params defines the parameters of the module. */ + params?: Authv1Beta1Params; +} + +export type QueryParamsType = Record; +export type ResponseFormat = keyof Omit; + +export interface FullRequestParams extends Omit { + /** set parameter to `true` for call `securityWorker` for this request */ + secure?: boolean; + /** request path */ + path: string; + /** content type of request body */ + type?: ContentType; + /** query params */ + query?: QueryParamsType; + /** format of response (i.e. response.json() -> format: "json") */ + format?: keyof Omit; + /** request body */ + body?: unknown; + /** base url */ + baseUrl?: string; + /** request cancellation token */ + cancelToken?: CancelToken; +} + +export type RequestParams = Omit; + +export interface ApiConfig { + baseUrl?: string; + baseApiParams?: Omit; + securityWorker?: (securityData: SecurityDataType) => RequestParams | void; +} + +export interface HttpResponse extends Response { + data: D; + error: E; +} + +type CancelToken = Symbol | string | number; + +export enum ContentType { + Json = "application/json", + FormData = "multipart/form-data", + UrlEncoded = "application/x-www-form-urlencoded", +} + +export class HttpClient { + public baseUrl: string = ""; + private securityData: SecurityDataType = null as any; + private securityWorker: null | ApiConfig["securityWorker"] = null; + private abortControllers = new Map(); + + private baseApiParams: RequestParams = { + credentials: "same-origin", + headers: {}, + redirect: "follow", + referrerPolicy: "no-referrer", + }; + + constructor(apiConfig: ApiConfig = {}) { + Object.assign(this, apiConfig); + } + + public setSecurityData = (data: SecurityDataType) => { + this.securityData = data; + }; + + private addQueryParam(query: QueryParamsType, key: string) { + const value = query[key]; + + return ( + encodeURIComponent(key) + + "=" + + encodeURIComponent(Array.isArray(value) ? value.join(",") : typeof value === "number" ? value : `${value}`) + ); + } + + protected toQueryString(rawQuery?: QueryParamsType): string { + const query = rawQuery || {}; + const keys = Object.keys(query).filter((key) => "undefined" !== typeof query[key]); + return keys + .map((key) => + typeof query[key] === "object" && !Array.isArray(query[key]) + ? this.toQueryString(query[key] as QueryParamsType) + : this.addQueryParam(query, key), + ) + .join("&"); + } + + protected addQueryParams(rawQuery?: QueryParamsType): string { + const queryString = this.toQueryString(rawQuery); + return queryString ? `?${queryString}` : ""; + } + + private contentFormatters: Record any> = { + [ContentType.Json]: (input: any) => + input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input, + [ContentType.FormData]: (input: any) => + Object.keys(input || {}).reduce((data, key) => { + data.append(key, input[key]); + return data; + }, new FormData()), + [ContentType.UrlEncoded]: (input: any) => this.toQueryString(input), + }; + + private mergeRequestParams(params1: RequestParams, params2?: RequestParams): RequestParams { + return { + ...this.baseApiParams, + ...params1, + ...(params2 || {}), + headers: { + ...(this.baseApiParams.headers || {}), + ...(params1.headers || {}), + ...((params2 && params2.headers) || {}), + }, + }; + } + + private createAbortSignal = (cancelToken: CancelToken): AbortSignal | undefined => { + if (this.abortControllers.has(cancelToken)) { + const abortController = this.abortControllers.get(cancelToken); + if (abortController) { + return abortController.signal; + } + return void 0; + } + + const abortController = new AbortController(); + this.abortControllers.set(cancelToken, abortController); + return abortController.signal; + }; + + public abortRequest = (cancelToken: CancelToken) => { + const abortController = this.abortControllers.get(cancelToken); + + if (abortController) { + abortController.abort(); + this.abortControllers.delete(cancelToken); + } + }; + + public request = ({ + body, + secure, + path, + type, + query, + format = "json", + baseUrl, + cancelToken, + ...params + }: FullRequestParams): Promise> => { + const secureParams = (secure && this.securityWorker && this.securityWorker(this.securityData)) || {}; + const requestParams = this.mergeRequestParams(params, secureParams); + const queryString = query && this.toQueryString(query); + const payloadFormatter = this.contentFormatters[type || ContentType.Json]; + + return fetch(`${baseUrl || this.baseUrl || ""}${path}${queryString ? `?${queryString}` : ""}`, { + ...requestParams, + headers: { + ...(type && type !== ContentType.FormData ? { "Content-Type": type } : {}), + ...(requestParams.headers || {}), + }, + signal: cancelToken ? this.createAbortSignal(cancelToken) : void 0, + body: typeof body === "undefined" || body === null ? null : payloadFormatter(body), + }).then(async (response) => { + const r = response as HttpResponse; + r.data = (null as unknown) as T; + r.error = (null as unknown) as E; + + const data = await response[format]() + .then((data) => { + if (r.ok) { + r.data = data; + } else { + r.error = data; + } + return r; + }) + .catch((e) => { + r.error = e; + return r; + }); + + if (cancelToken) { + this.abortControllers.delete(cancelToken); + } + + if (!response.ok) throw data; + return data; + }); + }; +} + +/** + * @title cosmos/auth/v1beta1/auth.proto + * @version version not set + */ +export class Api extends HttpClient { + /** + * @description Since: cosmos-sdk 0.43 + * + * @tags Query + * @name QueryAccounts + * @summary Accounts returns all the existing accounts + * @request GET:/cosmos/auth/v1beta1/accounts + */ + queryAccounts = ( + query?: { + "pagination.key"?: string; + "pagination.offset"?: string; + "pagination.limit"?: string; + "pagination.count_total"?: boolean; + "pagination.reverse"?: boolean; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/cosmos/auth/v1beta1/accounts`, + method: "GET", + query: query, + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Query + * @name QueryAccount + * @summary Account returns account details based on address. + * @request GET:/cosmos/auth/v1beta1/accounts/{address} + */ + queryAccount = (address: string, params: RequestParams = {}) => + this.request({ + path: `/cosmos/auth/v1beta1/accounts/${address}`, + method: "GET", + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Query + * @name QueryModuleAccountByName + * @summary ModuleAccountByName returns the module account info by module name + * @request GET:/cosmos/auth/v1beta1/module_accounts/{name} + */ + queryModuleAccountByName = (name: string, params: RequestParams = {}) => + this.request({ + path: `/cosmos/auth/v1beta1/module_accounts/${name}`, + method: "GET", + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Query + * @name QueryParams + * @summary Params queries all parameters. + * @request GET:/cosmos/auth/v1beta1/params + */ + queryParams = (params: RequestParams = {}) => + this.request({ + path: `/cosmos/auth/v1beta1/params`, + method: "GET", + format: "json", + ...params, + }); +} diff --git a/ts-client/cosmos.auth.v1beta1/types.ts b/ts-client/cosmos.auth.v1beta1/types.ts new file mode 100755 index 00000000..3f44654b --- /dev/null +++ b/ts-client/cosmos.auth.v1beta1/types.ts @@ -0,0 +1,11 @@ +import { BaseAccount } from "./types/cosmos/auth/v1beta1/auth" +import { ModuleAccount } from "./types/cosmos/auth/v1beta1/auth" +import { Params } from "./types/cosmos/auth/v1beta1/auth" + + +export { + BaseAccount, + ModuleAccount, + Params, + + } \ No newline at end of file diff --git a/ts-client/cosmos.auth.v1beta1/types/cosmos/auth/v1beta1/auth.ts b/ts-client/cosmos.auth.v1beta1/types/cosmos/auth/v1beta1/auth.ts new file mode 100644 index 00000000..b09676a0 --- /dev/null +++ b/ts-client/cosmos.auth.v1beta1/types/cosmos/auth/v1beta1/auth.ts @@ -0,0 +1,436 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; +import { Any } from "../../../google/protobuf/any"; + +export const protobufPackage = "cosmos.auth.v1beta1"; + +/** + * BaseAccount defines a base account type. It contains all the necessary fields + * for basic account functionality. Any custom account type should extend this + * type for additional functionality (e.g. vesting). + */ +export interface BaseAccount { + address: string; + pubKey: Any | undefined; + accountNumber: number; + sequence: number; +} + +/** ModuleAccount defines an account for modules that holds coins on a pool. */ +export interface ModuleAccount { + baseAccount: BaseAccount | undefined; + name: string; + permissions: string[]; +} + +/** Params defines the parameters for the auth module. */ +export interface Params { + maxMemoCharacters: number; + txSigLimit: number; + txSizeCostPerByte: number; + sigVerifyCostEd25519: number; + sigVerifyCostSecp256k1: number; +} + +const baseBaseAccount: object = { address: "", accountNumber: 0, sequence: 0 }; + +export const BaseAccount = { + encode(message: BaseAccount, writer: Writer = Writer.create()): Writer { + if (message.address !== "") { + writer.uint32(10).string(message.address); + } + if (message.pubKey !== undefined) { + Any.encode(message.pubKey, writer.uint32(18).fork()).ldelim(); + } + if (message.accountNumber !== 0) { + writer.uint32(24).uint64(message.accountNumber); + } + if (message.sequence !== 0) { + writer.uint32(32).uint64(message.sequence); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): BaseAccount { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseBaseAccount } as BaseAccount; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.address = reader.string(); + break; + case 2: + message.pubKey = Any.decode(reader, reader.uint32()); + break; + case 3: + message.accountNumber = longToNumber(reader.uint64() as Long); + break; + case 4: + message.sequence = longToNumber(reader.uint64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): BaseAccount { + const message = { ...baseBaseAccount } as BaseAccount; + if (object.address !== undefined && object.address !== null) { + message.address = String(object.address); + } else { + message.address = ""; + } + if (object.pubKey !== undefined && object.pubKey !== null) { + message.pubKey = Any.fromJSON(object.pubKey); + } else { + message.pubKey = undefined; + } + if (object.accountNumber !== undefined && object.accountNumber !== null) { + message.accountNumber = Number(object.accountNumber); + } else { + message.accountNumber = 0; + } + if (object.sequence !== undefined && object.sequence !== null) { + message.sequence = Number(object.sequence); + } else { + message.sequence = 0; + } + return message; + }, + + toJSON(message: BaseAccount): unknown { + const obj: any = {}; + message.address !== undefined && (obj.address = message.address); + message.pubKey !== undefined && + (obj.pubKey = message.pubKey ? Any.toJSON(message.pubKey) : undefined); + message.accountNumber !== undefined && + (obj.accountNumber = message.accountNumber); + message.sequence !== undefined && (obj.sequence = message.sequence); + return obj; + }, + + fromPartial(object: DeepPartial): BaseAccount { + const message = { ...baseBaseAccount } as BaseAccount; + if (object.address !== undefined && object.address !== null) { + message.address = object.address; + } else { + message.address = ""; + } + if (object.pubKey !== undefined && object.pubKey !== null) { + message.pubKey = Any.fromPartial(object.pubKey); + } else { + message.pubKey = undefined; + } + if (object.accountNumber !== undefined && object.accountNumber !== null) { + message.accountNumber = object.accountNumber; + } else { + message.accountNumber = 0; + } + if (object.sequence !== undefined && object.sequence !== null) { + message.sequence = object.sequence; + } else { + message.sequence = 0; + } + return message; + }, +}; + +const baseModuleAccount: object = { name: "", permissions: "" }; + +export const ModuleAccount = { + encode(message: ModuleAccount, writer: Writer = Writer.create()): Writer { + if (message.baseAccount !== undefined) { + BaseAccount.encode( + message.baseAccount, + writer.uint32(10).fork() + ).ldelim(); + } + if (message.name !== "") { + writer.uint32(18).string(message.name); + } + for (const v of message.permissions) { + writer.uint32(26).string(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ModuleAccount { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseModuleAccount } as ModuleAccount; + message.permissions = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.baseAccount = BaseAccount.decode(reader, reader.uint32()); + break; + case 2: + message.name = reader.string(); + break; + case 3: + message.permissions.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ModuleAccount { + const message = { ...baseModuleAccount } as ModuleAccount; + message.permissions = []; + if (object.baseAccount !== undefined && object.baseAccount !== null) { + message.baseAccount = BaseAccount.fromJSON(object.baseAccount); + } else { + message.baseAccount = undefined; + } + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.permissions !== undefined && object.permissions !== null) { + for (const e of object.permissions) { + message.permissions.push(String(e)); + } + } + return message; + }, + + toJSON(message: ModuleAccount): unknown { + const obj: any = {}; + message.baseAccount !== undefined && + (obj.baseAccount = message.baseAccount + ? BaseAccount.toJSON(message.baseAccount) + : undefined); + message.name !== undefined && (obj.name = message.name); + if (message.permissions) { + obj.permissions = message.permissions.map((e) => e); + } else { + obj.permissions = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): ModuleAccount { + const message = { ...baseModuleAccount } as ModuleAccount; + message.permissions = []; + if (object.baseAccount !== undefined && object.baseAccount !== null) { + message.baseAccount = BaseAccount.fromPartial(object.baseAccount); + } else { + message.baseAccount = undefined; + } + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.permissions !== undefined && object.permissions !== null) { + for (const e of object.permissions) { + message.permissions.push(e); + } + } + return message; + }, +}; + +const baseParams: object = { + maxMemoCharacters: 0, + txSigLimit: 0, + txSizeCostPerByte: 0, + sigVerifyCostEd25519: 0, + sigVerifyCostSecp256k1: 0, +}; + +export const Params = { + encode(message: Params, writer: Writer = Writer.create()): Writer { + if (message.maxMemoCharacters !== 0) { + writer.uint32(8).uint64(message.maxMemoCharacters); + } + if (message.txSigLimit !== 0) { + writer.uint32(16).uint64(message.txSigLimit); + } + if (message.txSizeCostPerByte !== 0) { + writer.uint32(24).uint64(message.txSizeCostPerByte); + } + if (message.sigVerifyCostEd25519 !== 0) { + writer.uint32(32).uint64(message.sigVerifyCostEd25519); + } + if (message.sigVerifyCostSecp256k1 !== 0) { + writer.uint32(40).uint64(message.sigVerifyCostSecp256k1); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Params { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseParams } as Params; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.maxMemoCharacters = longToNumber(reader.uint64() as Long); + break; + case 2: + message.txSigLimit = longToNumber(reader.uint64() as Long); + break; + case 3: + message.txSizeCostPerByte = longToNumber(reader.uint64() as Long); + break; + case 4: + message.sigVerifyCostEd25519 = longToNumber(reader.uint64() as Long); + break; + case 5: + message.sigVerifyCostSecp256k1 = longToNumber( + reader.uint64() as Long + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Params { + const message = { ...baseParams } as Params; + if ( + object.maxMemoCharacters !== undefined && + object.maxMemoCharacters !== null + ) { + message.maxMemoCharacters = Number(object.maxMemoCharacters); + } else { + message.maxMemoCharacters = 0; + } + if (object.txSigLimit !== undefined && object.txSigLimit !== null) { + message.txSigLimit = Number(object.txSigLimit); + } else { + message.txSigLimit = 0; + } + if ( + object.txSizeCostPerByte !== undefined && + object.txSizeCostPerByte !== null + ) { + message.txSizeCostPerByte = Number(object.txSizeCostPerByte); + } else { + message.txSizeCostPerByte = 0; + } + if ( + object.sigVerifyCostEd25519 !== undefined && + object.sigVerifyCostEd25519 !== null + ) { + message.sigVerifyCostEd25519 = Number(object.sigVerifyCostEd25519); + } else { + message.sigVerifyCostEd25519 = 0; + } + if ( + object.sigVerifyCostSecp256k1 !== undefined && + object.sigVerifyCostSecp256k1 !== null + ) { + message.sigVerifyCostSecp256k1 = Number(object.sigVerifyCostSecp256k1); + } else { + message.sigVerifyCostSecp256k1 = 0; + } + return message; + }, + + toJSON(message: Params): unknown { + const obj: any = {}; + message.maxMemoCharacters !== undefined && + (obj.maxMemoCharacters = message.maxMemoCharacters); + message.txSigLimit !== undefined && (obj.txSigLimit = message.txSigLimit); + message.txSizeCostPerByte !== undefined && + (obj.txSizeCostPerByte = message.txSizeCostPerByte); + message.sigVerifyCostEd25519 !== undefined && + (obj.sigVerifyCostEd25519 = message.sigVerifyCostEd25519); + message.sigVerifyCostSecp256k1 !== undefined && + (obj.sigVerifyCostSecp256k1 = message.sigVerifyCostSecp256k1); + return obj; + }, + + fromPartial(object: DeepPartial): Params { + const message = { ...baseParams } as Params; + if ( + object.maxMemoCharacters !== undefined && + object.maxMemoCharacters !== null + ) { + message.maxMemoCharacters = object.maxMemoCharacters; + } else { + message.maxMemoCharacters = 0; + } + if (object.txSigLimit !== undefined && object.txSigLimit !== null) { + message.txSigLimit = object.txSigLimit; + } else { + message.txSigLimit = 0; + } + if ( + object.txSizeCostPerByte !== undefined && + object.txSizeCostPerByte !== null + ) { + message.txSizeCostPerByte = object.txSizeCostPerByte; + } else { + message.txSizeCostPerByte = 0; + } + if ( + object.sigVerifyCostEd25519 !== undefined && + object.sigVerifyCostEd25519 !== null + ) { + message.sigVerifyCostEd25519 = object.sigVerifyCostEd25519; + } else { + message.sigVerifyCostEd25519 = 0; + } + if ( + object.sigVerifyCostSecp256k1 !== undefined && + object.sigVerifyCostSecp256k1 !== null + ) { + message.sigVerifyCostSecp256k1 = object.sigVerifyCostSecp256k1; + } else { + message.sigVerifyCostSecp256k1 = 0; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/cosmos.auth.v1beta1/types/cosmos/auth/v1beta1/genesis.ts b/ts-client/cosmos.auth.v1beta1/types/cosmos/auth/v1beta1/genesis.ts new file mode 100644 index 00000000..f4571bfd --- /dev/null +++ b/ts-client/cosmos.auth.v1beta1/types/cosmos/auth/v1beta1/genesis.ts @@ -0,0 +1,107 @@ +/* eslint-disable */ +import { Params } from "../../../cosmos/auth/v1beta1/auth"; +import { Any } from "../../../google/protobuf/any"; +import { Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "cosmos.auth.v1beta1"; + +/** GenesisState defines the auth module's genesis state. */ +export interface GenesisState { + /** params defines all the paramaters of the module. */ + params: Params | undefined; + /** accounts are the accounts present at genesis. */ + accounts: Any[]; +} + +const baseGenesisState: object = {}; + +export const GenesisState = { + encode(message: GenesisState, writer: Writer = Writer.create()): Writer { + if (message.params !== undefined) { + Params.encode(message.params, writer.uint32(10).fork()).ldelim(); + } + for (const v of message.accounts) { + Any.encode(v!, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): GenesisState { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseGenesisState } as GenesisState; + message.accounts = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.params = Params.decode(reader, reader.uint32()); + break; + case 2: + message.accounts.push(Any.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GenesisState { + const message = { ...baseGenesisState } as GenesisState; + message.accounts = []; + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromJSON(object.params); + } else { + message.params = undefined; + } + if (object.accounts !== undefined && object.accounts !== null) { + for (const e of object.accounts) { + message.accounts.push(Any.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: GenesisState): unknown { + const obj: any = {}; + message.params !== undefined && + (obj.params = message.params ? Params.toJSON(message.params) : undefined); + if (message.accounts) { + obj.accounts = message.accounts.map((e) => + e ? Any.toJSON(e) : undefined + ); + } else { + obj.accounts = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): GenesisState { + const message = { ...baseGenesisState } as GenesisState; + message.accounts = []; + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromPartial(object.params); + } else { + message.params = undefined; + } + if (object.accounts !== undefined && object.accounts !== null) { + for (const e of object.accounts) { + message.accounts.push(Any.fromPartial(e)); + } + } + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/cosmos.auth.v1beta1/types/cosmos/auth/v1beta1/query.ts b/ts-client/cosmos.auth.v1beta1/types/cosmos/auth/v1beta1/query.ts new file mode 100644 index 00000000..f27ca3f1 --- /dev/null +++ b/ts-client/cosmos.auth.v1beta1/types/cosmos/auth/v1beta1/query.ts @@ -0,0 +1,660 @@ +/* eslint-disable */ +import { Reader, Writer } from "protobufjs/minimal"; +import { + PageRequest, + PageResponse, +} from "../../../cosmos/base/query/v1beta1/pagination"; +import { Any } from "../../../google/protobuf/any"; +import { Params } from "../../../cosmos/auth/v1beta1/auth"; + +export const protobufPackage = "cosmos.auth.v1beta1"; + +/** + * QueryAccountsRequest is the request type for the Query/Accounts RPC method. + * + * Since: cosmos-sdk 0.43 + */ +export interface QueryAccountsRequest { + /** pagination defines an optional pagination for the request. */ + pagination: PageRequest | undefined; +} + +/** + * QueryAccountsResponse is the response type for the Query/Accounts RPC method. + * + * Since: cosmos-sdk 0.43 + */ +export interface QueryAccountsResponse { + /** accounts are the existing accounts */ + accounts: Any[]; + /** pagination defines the pagination in the response. */ + pagination: PageResponse | undefined; +} + +/** QueryAccountRequest is the request type for the Query/Account RPC method. */ +export interface QueryAccountRequest { + /** address defines the address to query for. */ + address: string; +} + +/** QueryAccountResponse is the response type for the Query/Account RPC method. */ +export interface QueryAccountResponse { + /** account defines the account of the corresponding address. */ + account: Any | undefined; +} + +/** QueryParamsRequest is the request type for the Query/Params RPC method. */ +export interface QueryParamsRequest {} + +/** QueryParamsResponse is the response type for the Query/Params RPC method. */ +export interface QueryParamsResponse { + /** params defines the parameters of the module. */ + params: Params | undefined; +} + +/** QueryModuleAccountByNameRequest is the request type for the Query/ModuleAccountByName RPC method. */ +export interface QueryModuleAccountByNameRequest { + name: string; +} + +/** QueryModuleAccountByNameResponse is the response type for the Query/ModuleAccountByName RPC method. */ +export interface QueryModuleAccountByNameResponse { + account: Any | undefined; +} + +const baseQueryAccountsRequest: object = {}; + +export const QueryAccountsRequest = { + encode( + message: QueryAccountsRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QueryAccountsRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryAccountsRequest } as QueryAccountsRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryAccountsRequest { + const message = { ...baseQueryAccountsRequest } as QueryAccountsRequest; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryAccountsRequest): unknown { + const obj: any = {}; + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageRequest.toJSON(message.pagination) + : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): QueryAccountsRequest { + const message = { ...baseQueryAccountsRequest } as QueryAccountsRequest; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseQueryAccountsResponse: object = {}; + +export const QueryAccountsResponse = { + encode( + message: QueryAccountsResponse, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.accounts) { + Any.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode( + message.pagination, + writer.uint32(18).fork() + ).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QueryAccountsResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryAccountsResponse } as QueryAccountsResponse; + message.accounts = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.accounts.push(Any.decode(reader, reader.uint32())); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryAccountsResponse { + const message = { ...baseQueryAccountsResponse } as QueryAccountsResponse; + message.accounts = []; + if (object.accounts !== undefined && object.accounts !== null) { + for (const e of object.accounts) { + message.accounts.push(Any.fromJSON(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryAccountsResponse): unknown { + const obj: any = {}; + if (message.accounts) { + obj.accounts = message.accounts.map((e) => + e ? Any.toJSON(e) : undefined + ); + } else { + obj.accounts = []; + } + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageResponse.toJSON(message.pagination) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryAccountsResponse { + const message = { ...baseQueryAccountsResponse } as QueryAccountsResponse; + message.accounts = []; + if (object.accounts !== undefined && object.accounts !== null) { + for (const e of object.accounts) { + message.accounts.push(Any.fromPartial(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseQueryAccountRequest: object = { address: "" }; + +export const QueryAccountRequest = { + encode( + message: QueryAccountRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.address !== "") { + writer.uint32(10).string(message.address); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QueryAccountRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryAccountRequest } as QueryAccountRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.address = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryAccountRequest { + const message = { ...baseQueryAccountRequest } as QueryAccountRequest; + if (object.address !== undefined && object.address !== null) { + message.address = String(object.address); + } else { + message.address = ""; + } + return message; + }, + + toJSON(message: QueryAccountRequest): unknown { + const obj: any = {}; + message.address !== undefined && (obj.address = message.address); + return obj; + }, + + fromPartial(object: DeepPartial): QueryAccountRequest { + const message = { ...baseQueryAccountRequest } as QueryAccountRequest; + if (object.address !== undefined && object.address !== null) { + message.address = object.address; + } else { + message.address = ""; + } + return message; + }, +}; + +const baseQueryAccountResponse: object = {}; + +export const QueryAccountResponse = { + encode( + message: QueryAccountResponse, + writer: Writer = Writer.create() + ): Writer { + if (message.account !== undefined) { + Any.encode(message.account, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QueryAccountResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryAccountResponse } as QueryAccountResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.account = Any.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryAccountResponse { + const message = { ...baseQueryAccountResponse } as QueryAccountResponse; + if (object.account !== undefined && object.account !== null) { + message.account = Any.fromJSON(object.account); + } else { + message.account = undefined; + } + return message; + }, + + toJSON(message: QueryAccountResponse): unknown { + const obj: any = {}; + message.account !== undefined && + (obj.account = message.account ? Any.toJSON(message.account) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): QueryAccountResponse { + const message = { ...baseQueryAccountResponse } as QueryAccountResponse; + if (object.account !== undefined && object.account !== null) { + message.account = Any.fromPartial(object.account); + } else { + message.account = undefined; + } + return message; + }, +}; + +const baseQueryParamsRequest: object = {}; + +export const QueryParamsRequest = { + encode(_: QueryParamsRequest, writer: Writer = Writer.create()): Writer { + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QueryParamsRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryParamsRequest } as QueryParamsRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): QueryParamsRequest { + const message = { ...baseQueryParamsRequest } as QueryParamsRequest; + return message; + }, + + toJSON(_: QueryParamsRequest): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial(_: DeepPartial): QueryParamsRequest { + const message = { ...baseQueryParamsRequest } as QueryParamsRequest; + return message; + }, +}; + +const baseQueryParamsResponse: object = {}; + +export const QueryParamsResponse = { + encode( + message: QueryParamsResponse, + writer: Writer = Writer.create() + ): Writer { + if (message.params !== undefined) { + Params.encode(message.params, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QueryParamsResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryParamsResponse } as QueryParamsResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.params = Params.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryParamsResponse { + const message = { ...baseQueryParamsResponse } as QueryParamsResponse; + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromJSON(object.params); + } else { + message.params = undefined; + } + return message; + }, + + toJSON(message: QueryParamsResponse): unknown { + const obj: any = {}; + message.params !== undefined && + (obj.params = message.params ? Params.toJSON(message.params) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): QueryParamsResponse { + const message = { ...baseQueryParamsResponse } as QueryParamsResponse; + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromPartial(object.params); + } else { + message.params = undefined; + } + return message; + }, +}; + +const baseQueryModuleAccountByNameRequest: object = { name: "" }; + +export const QueryModuleAccountByNameRequest = { + encode( + message: QueryModuleAccountByNameRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryModuleAccountByNameRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryModuleAccountByNameRequest, + } as QueryModuleAccountByNameRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryModuleAccountByNameRequest { + const message = { + ...baseQueryModuleAccountByNameRequest, + } as QueryModuleAccountByNameRequest; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + return message; + }, + + toJSON(message: QueryModuleAccountByNameRequest): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryModuleAccountByNameRequest { + const message = { + ...baseQueryModuleAccountByNameRequest, + } as QueryModuleAccountByNameRequest; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + return message; + }, +}; + +const baseQueryModuleAccountByNameResponse: object = {}; + +export const QueryModuleAccountByNameResponse = { + encode( + message: QueryModuleAccountByNameResponse, + writer: Writer = Writer.create() + ): Writer { + if (message.account !== undefined) { + Any.encode(message.account, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryModuleAccountByNameResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryModuleAccountByNameResponse, + } as QueryModuleAccountByNameResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.account = Any.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryModuleAccountByNameResponse { + const message = { + ...baseQueryModuleAccountByNameResponse, + } as QueryModuleAccountByNameResponse; + if (object.account !== undefined && object.account !== null) { + message.account = Any.fromJSON(object.account); + } else { + message.account = undefined; + } + return message; + }, + + toJSON(message: QueryModuleAccountByNameResponse): unknown { + const obj: any = {}; + message.account !== undefined && + (obj.account = message.account ? Any.toJSON(message.account) : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryModuleAccountByNameResponse { + const message = { + ...baseQueryModuleAccountByNameResponse, + } as QueryModuleAccountByNameResponse; + if (object.account !== undefined && object.account !== null) { + message.account = Any.fromPartial(object.account); + } else { + message.account = undefined; + } + return message; + }, +}; + +/** Query defines the gRPC querier service. */ +export interface Query { + /** + * Accounts returns all the existing accounts + * + * Since: cosmos-sdk 0.43 + */ + Accounts(request: QueryAccountsRequest): Promise; + /** Account returns account details based on address. */ + Account(request: QueryAccountRequest): Promise; + /** Params queries all parameters. */ + Params(request: QueryParamsRequest): Promise; + /** ModuleAccountByName returns the module account info by module name */ + ModuleAccountByName( + request: QueryModuleAccountByNameRequest + ): Promise; +} + +export class QueryClientImpl implements Query { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + } + Accounts(request: QueryAccountsRequest): Promise { + const data = QueryAccountsRequest.encode(request).finish(); + const promise = this.rpc.request( + "cosmos.auth.v1beta1.Query", + "Accounts", + data + ); + return promise.then((data) => + QueryAccountsResponse.decode(new Reader(data)) + ); + } + + Account(request: QueryAccountRequest): Promise { + const data = QueryAccountRequest.encode(request).finish(); + const promise = this.rpc.request( + "cosmos.auth.v1beta1.Query", + "Account", + data + ); + return promise.then((data) => + QueryAccountResponse.decode(new Reader(data)) + ); + } + + Params(request: QueryParamsRequest): Promise { + const data = QueryParamsRequest.encode(request).finish(); + const promise = this.rpc.request( + "cosmos.auth.v1beta1.Query", + "Params", + data + ); + return promise.then((data) => QueryParamsResponse.decode(new Reader(data))); + } + + ModuleAccountByName( + request: QueryModuleAccountByNameRequest + ): Promise { + const data = QueryModuleAccountByNameRequest.encode(request).finish(); + const promise = this.rpc.request( + "cosmos.auth.v1beta1.Query", + "ModuleAccountByName", + data + ); + return promise.then((data) => + QueryModuleAccountByNameResponse.decode(new Reader(data)) + ); + } +} + +interface Rpc { + request( + service: string, + method: string, + data: Uint8Array + ): Promise; +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/cosmos.auth.v1beta1/types/cosmos/base/query/v1beta1/pagination.ts b/ts-client/cosmos.auth.v1beta1/types/cosmos/base/query/v1beta1/pagination.ts new file mode 100644 index 00000000..cd4b2d78 --- /dev/null +++ b/ts-client/cosmos.auth.v1beta1/types/cosmos/base/query/v1beta1/pagination.ts @@ -0,0 +1,327 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "cosmos.base.query.v1beta1"; + +/** + * PageRequest is to be embedded in gRPC request messages for efficient + * pagination. Ex: + * + * message SomeRequest { + * Foo some_parameter = 1; + * PageRequest pagination = 2; + * } + */ +export interface PageRequest { + /** + * key is a value returned in PageResponse.next_key to begin + * querying the next page most efficiently. Only one of offset or key + * should be set. + */ + key: Uint8Array; + /** + * offset is a numeric offset that can be used when key is unavailable. + * It is less efficient than using key. Only one of offset or key should + * be set. + */ + offset: number; + /** + * limit is the total number of results to be returned in the result page. + * If left empty it will default to a value to be set by each app. + */ + limit: number; + /** + * count_total is set to true to indicate that the result set should include + * a count of the total number of items available for pagination in UIs. + * count_total is only respected when offset is used. It is ignored when key + * is set. + */ + countTotal: boolean; + /** + * reverse is set to true if results are to be returned in the descending order. + * + * Since: cosmos-sdk 0.43 + */ + reverse: boolean; +} + +/** + * PageResponse is to be embedded in gRPC response messages where the + * corresponding request message has used PageRequest. + * + * message SomeResponse { + * repeated Bar results = 1; + * PageResponse page = 2; + * } + */ +export interface PageResponse { + /** + * next_key is the key to be passed to PageRequest.key to + * query the next page most efficiently + */ + nextKey: Uint8Array; + /** + * total is total number of results available if PageRequest.count_total + * was set, its value is undefined otherwise + */ + total: number; +} + +const basePageRequest: object = { + offset: 0, + limit: 0, + countTotal: false, + reverse: false, +}; + +export const PageRequest = { + encode(message: PageRequest, writer: Writer = Writer.create()): Writer { + if (message.key.length !== 0) { + writer.uint32(10).bytes(message.key); + } + if (message.offset !== 0) { + writer.uint32(16).uint64(message.offset); + } + if (message.limit !== 0) { + writer.uint32(24).uint64(message.limit); + } + if (message.countTotal === true) { + writer.uint32(32).bool(message.countTotal); + } + if (message.reverse === true) { + writer.uint32(40).bool(message.reverse); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): PageRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...basePageRequest } as PageRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.key = reader.bytes(); + break; + case 2: + message.offset = longToNumber(reader.uint64() as Long); + break; + case 3: + message.limit = longToNumber(reader.uint64() as Long); + break; + case 4: + message.countTotal = reader.bool(); + break; + case 5: + message.reverse = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): PageRequest { + const message = { ...basePageRequest } as PageRequest; + if (object.key !== undefined && object.key !== null) { + message.key = bytesFromBase64(object.key); + } + if (object.offset !== undefined && object.offset !== null) { + message.offset = Number(object.offset); + } else { + message.offset = 0; + } + if (object.limit !== undefined && object.limit !== null) { + message.limit = Number(object.limit); + } else { + message.limit = 0; + } + if (object.countTotal !== undefined && object.countTotal !== null) { + message.countTotal = Boolean(object.countTotal); + } else { + message.countTotal = false; + } + if (object.reverse !== undefined && object.reverse !== null) { + message.reverse = Boolean(object.reverse); + } else { + message.reverse = false; + } + return message; + }, + + toJSON(message: PageRequest): unknown { + const obj: any = {}; + message.key !== undefined && + (obj.key = base64FromBytes( + message.key !== undefined ? message.key : new Uint8Array() + )); + message.offset !== undefined && (obj.offset = message.offset); + message.limit !== undefined && (obj.limit = message.limit); + message.countTotal !== undefined && (obj.countTotal = message.countTotal); + message.reverse !== undefined && (obj.reverse = message.reverse); + return obj; + }, + + fromPartial(object: DeepPartial): PageRequest { + const message = { ...basePageRequest } as PageRequest; + if (object.key !== undefined && object.key !== null) { + message.key = object.key; + } else { + message.key = new Uint8Array(); + } + if (object.offset !== undefined && object.offset !== null) { + message.offset = object.offset; + } else { + message.offset = 0; + } + if (object.limit !== undefined && object.limit !== null) { + message.limit = object.limit; + } else { + message.limit = 0; + } + if (object.countTotal !== undefined && object.countTotal !== null) { + message.countTotal = object.countTotal; + } else { + message.countTotal = false; + } + if (object.reverse !== undefined && object.reverse !== null) { + message.reverse = object.reverse; + } else { + message.reverse = false; + } + return message; + }, +}; + +const basePageResponse: object = { total: 0 }; + +export const PageResponse = { + encode(message: PageResponse, writer: Writer = Writer.create()): Writer { + if (message.nextKey.length !== 0) { + writer.uint32(10).bytes(message.nextKey); + } + if (message.total !== 0) { + writer.uint32(16).uint64(message.total); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): PageResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...basePageResponse } as PageResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.nextKey = reader.bytes(); + break; + case 2: + message.total = longToNumber(reader.uint64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): PageResponse { + const message = { ...basePageResponse } as PageResponse; + if (object.nextKey !== undefined && object.nextKey !== null) { + message.nextKey = bytesFromBase64(object.nextKey); + } + if (object.total !== undefined && object.total !== null) { + message.total = Number(object.total); + } else { + message.total = 0; + } + return message; + }, + + toJSON(message: PageResponse): unknown { + const obj: any = {}; + message.nextKey !== undefined && + (obj.nextKey = base64FromBytes( + message.nextKey !== undefined ? message.nextKey : new Uint8Array() + )); + message.total !== undefined && (obj.total = message.total); + return obj; + }, + + fromPartial(object: DeepPartial): PageResponse { + const message = { ...basePageResponse } as PageResponse; + if (object.nextKey !== undefined && object.nextKey !== null) { + message.nextKey = object.nextKey; + } else { + message.nextKey = new Uint8Array(); + } + if (object.total !== undefined && object.total !== null) { + message.total = object.total; + } else { + message.total = 0; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/cosmos.auth.v1beta1/types/cosmos_proto/cosmos.ts b/ts-client/cosmos.auth.v1beta1/types/cosmos_proto/cosmos.ts new file mode 100644 index 00000000..9ec67a12 --- /dev/null +++ b/ts-client/cosmos.auth.v1beta1/types/cosmos_proto/cosmos.ts @@ -0,0 +1,2 @@ +/* eslint-disable */ +export const protobufPackage = "cosmos_proto"; diff --git a/ts-client/cosmos.auth.v1beta1/types/gogoproto/gogo.ts b/ts-client/cosmos.auth.v1beta1/types/gogoproto/gogo.ts new file mode 100644 index 00000000..3f41a047 --- /dev/null +++ b/ts-client/cosmos.auth.v1beta1/types/gogoproto/gogo.ts @@ -0,0 +1,2 @@ +/* eslint-disable */ +export const protobufPackage = "gogoproto"; diff --git a/ts-client/cosmos.auth.v1beta1/types/google/api/annotations.ts b/ts-client/cosmos.auth.v1beta1/types/google/api/annotations.ts new file mode 100644 index 00000000..aace4787 --- /dev/null +++ b/ts-client/cosmos.auth.v1beta1/types/google/api/annotations.ts @@ -0,0 +1,2 @@ +/* eslint-disable */ +export const protobufPackage = "google.api"; diff --git a/ts-client/cosmos.auth.v1beta1/types/google/api/http.ts b/ts-client/cosmos.auth.v1beta1/types/google/api/http.ts new file mode 100644 index 00000000..ddc00f8b --- /dev/null +++ b/ts-client/cosmos.auth.v1beta1/types/google/api/http.ts @@ -0,0 +1,705 @@ +/* eslint-disable */ +import { Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "google.api"; + +/** + * Defines the HTTP configuration for an API service. It contains a list of + * [HttpRule][google.api.HttpRule], each specifying the mapping of an RPC method + * to one or more HTTP REST API methods. + */ +export interface Http { + /** + * A list of HTTP configuration rules that apply to individual API methods. + * + * **NOTE:** All service configuration rules follow "last one wins" order. + */ + rules: HttpRule[]; + /** + * When set to true, URL path parmeters will be fully URI-decoded except in + * cases of single segment matches in reserved expansion, where "%2F" will be + * left encoded. + * + * The default behavior is to not decode RFC 6570 reserved characters in multi + * segment matches. + */ + fullyDecodeReservedExpansion: boolean; +} + +/** + * `HttpRule` defines the mapping of an RPC method to one or more HTTP + * REST API methods. The mapping specifies how different portions of the RPC + * request message are mapped to URL path, URL query parameters, and + * HTTP request body. The mapping is typically specified as an + * `google.api.http` annotation on the RPC method, + * see "google/api/annotations.proto" for details. + * + * The mapping consists of a field specifying the path template and + * method kind. The path template can refer to fields in the request + * message, as in the example below which describes a REST GET + * operation on a resource collection of messages: + * + * + * service Messaging { + * rpc GetMessage(GetMessageRequest) returns (Message) { + * option (google.api.http).get = "/v1/messages/{message_id}/{sub.subfield}"; + * } + * } + * message GetMessageRequest { + * message SubMessage { + * string subfield = 1; + * } + * string message_id = 1; // mapped to the URL + * SubMessage sub = 2; // `sub.subfield` is url-mapped + * } + * message Message { + * string text = 1; // content of the resource + * } + * + * The same http annotation can alternatively be expressed inside the + * `GRPC API Configuration` YAML file. + * + * http: + * rules: + * - selector: .Messaging.GetMessage + * get: /v1/messages/{message_id}/{sub.subfield} + * + * This definition enables an automatic, bidrectional mapping of HTTP + * JSON to RPC. Example: + * + * HTTP | RPC + * -----|----- + * `GET /v1/messages/123456/foo` | `GetMessage(message_id: "123456" sub: SubMessage(subfield: "foo"))` + * + * In general, not only fields but also field paths can be referenced + * from a path pattern. Fields mapped to the path pattern cannot be + * repeated and must have a primitive (non-message) type. + * + * Any fields in the request message which are not bound by the path + * pattern automatically become (optional) HTTP query + * parameters. Assume the following definition of the request message: + * + * + * service Messaging { + * rpc GetMessage(GetMessageRequest) returns (Message) { + * option (google.api.http).get = "/v1/messages/{message_id}"; + * } + * } + * message GetMessageRequest { + * message SubMessage { + * string subfield = 1; + * } + * string message_id = 1; // mapped to the URL + * int64 revision = 2; // becomes a parameter + * SubMessage sub = 3; // `sub.subfield` becomes a parameter + * } + * + * + * This enables a HTTP JSON to RPC mapping as below: + * + * HTTP | RPC + * -----|----- + * `GET /v1/messages/123456?revision=2&sub.subfield=foo` | `GetMessage(message_id: "123456" revision: 2 sub: SubMessage(subfield: "foo"))` + * + * Note that fields which are mapped to HTTP parameters must have a + * primitive type or a repeated primitive type. Message types are not + * allowed. In the case of a repeated type, the parameter can be + * repeated in the URL, as in `...?param=A¶m=B`. + * + * For HTTP method kinds which allow a request body, the `body` field + * specifies the mapping. Consider a REST update method on the + * message resource collection: + * + * + * service Messaging { + * rpc UpdateMessage(UpdateMessageRequest) returns (Message) { + * option (google.api.http) = { + * put: "/v1/messages/{message_id}" + * body: "message" + * }; + * } + * } + * message UpdateMessageRequest { + * string message_id = 1; // mapped to the URL + * Message message = 2; // mapped to the body + * } + * + * + * The following HTTP JSON to RPC mapping is enabled, where the + * representation of the JSON in the request body is determined by + * protos JSON encoding: + * + * HTTP | RPC + * -----|----- + * `PUT /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: "123456" message { text: "Hi!" })` + * + * The special name `*` can be used in the body mapping to define that + * every field not bound by the path template should be mapped to the + * request body. This enables the following alternative definition of + * the update method: + * + * service Messaging { + * rpc UpdateMessage(Message) returns (Message) { + * option (google.api.http) = { + * put: "/v1/messages/{message_id}" + * body: "*" + * }; + * } + * } + * message Message { + * string message_id = 1; + * string text = 2; + * } + * + * + * The following HTTP JSON to RPC mapping is enabled: + * + * HTTP | RPC + * -----|----- + * `PUT /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: "123456" text: "Hi!")` + * + * Note that when using `*` in the body mapping, it is not possible to + * have HTTP parameters, as all fields not bound by the path end in + * the body. This makes this option more rarely used in practice of + * defining REST APIs. The common usage of `*` is in custom methods + * which don't use the URL at all for transferring data. + * + * It is possible to define multiple HTTP methods for one RPC by using + * the `additional_bindings` option. Example: + * + * service Messaging { + * rpc GetMessage(GetMessageRequest) returns (Message) { + * option (google.api.http) = { + * get: "/v1/messages/{message_id}" + * additional_bindings { + * get: "/v1/users/{user_id}/messages/{message_id}" + * } + * }; + * } + * } + * message GetMessageRequest { + * string message_id = 1; + * string user_id = 2; + * } + * + * + * This enables the following two alternative HTTP JSON to RPC + * mappings: + * + * HTTP | RPC + * -----|----- + * `GET /v1/messages/123456` | `GetMessage(message_id: "123456")` + * `GET /v1/users/me/messages/123456` | `GetMessage(user_id: "me" message_id: "123456")` + * + * # Rules for HTTP mapping + * + * The rules for mapping HTTP path, query parameters, and body fields + * to the request message are as follows: + * + * 1. The `body` field specifies either `*` or a field path, or is + * omitted. If omitted, it indicates there is no HTTP request body. + * 2. Leaf fields (recursive expansion of nested messages in the + * request) can be classified into three types: + * (a) Matched in the URL template. + * (b) Covered by body (if body is `*`, everything except (a) fields; + * else everything under the body field) + * (c) All other fields. + * 3. URL query parameters found in the HTTP request are mapped to (c) fields. + * 4. Any body sent with an HTTP request can contain only (b) fields. + * + * The syntax of the path template is as follows: + * + * Template = "/" Segments [ Verb ] ; + * Segments = Segment { "/" Segment } ; + * Segment = "*" | "**" | LITERAL | Variable ; + * Variable = "{" FieldPath [ "=" Segments ] "}" ; + * FieldPath = IDENT { "." IDENT } ; + * Verb = ":" LITERAL ; + * + * The syntax `*` matches a single path segment. The syntax `**` matches zero + * or more path segments, which must be the last part of the path except the + * `Verb`. The syntax `LITERAL` matches literal text in the path. + * + * The syntax `Variable` matches part of the URL path as specified by its + * template. A variable template must not contain other variables. If a variable + * matches a single path segment, its template may be omitted, e.g. `{var}` + * is equivalent to `{var=*}`. + * + * If a variable contains exactly one path segment, such as `"{var}"` or + * `"{var=*}"`, when such a variable is expanded into a URL path, all characters + * except `[-_.~0-9a-zA-Z]` are percent-encoded. Such variables show up in the + * Discovery Document as `{var}`. + * + * If a variable contains one or more path segments, such as `"{var=foo/*}"` + * or `"{var=**}"`, when such a variable is expanded into a URL path, all + * characters except `[-_.~/0-9a-zA-Z]` are percent-encoded. Such variables + * show up in the Discovery Document as `{+var}`. + * + * NOTE: While the single segment variable matches the semantics of + * [RFC 6570](https://tools.ietf.org/html/rfc6570) Section 3.2.2 + * Simple String Expansion, the multi segment variable **does not** match + * RFC 6570 Reserved Expansion. The reason is that the Reserved Expansion + * does not expand special characters like `?` and `#`, which would lead + * to invalid URLs. + * + * NOTE: the field paths in variables and in the `body` must not refer to + * repeated fields or map fields. + */ +export interface HttpRule { + /** + * Selects methods to which this rule applies. + * + * Refer to [selector][google.api.DocumentationRule.selector] for syntax details. + */ + selector: string; + /** Used for listing and getting information about resources. */ + get: string | undefined; + /** Used for updating a resource. */ + put: string | undefined; + /** Used for creating a resource. */ + post: string | undefined; + /** Used for deleting a resource. */ + delete: string | undefined; + /** Used for updating a resource. */ + patch: string | undefined; + /** + * The custom pattern is used for specifying an HTTP method that is not + * included in the `pattern` field, such as HEAD, or "*" to leave the + * HTTP method unspecified for this rule. The wild-card rule is useful + * for services that provide content to Web (HTML) clients. + */ + custom: CustomHttpPattern | undefined; + /** + * The name of the request field whose value is mapped to the HTTP body, or + * `*` for mapping all fields not captured by the path pattern to the HTTP + * body. NOTE: the referred field must not be a repeated field and must be + * present at the top-level of request message type. + */ + body: string; + /** + * Optional. The name of the response field whose value is mapped to the HTTP + * body of response. Other response fields are ignored. When + * not set, the response message will be used as HTTP body of response. + */ + responseBody: string; + /** + * Additional HTTP bindings for the selector. Nested bindings must + * not contain an `additional_bindings` field themselves (that is, + * the nesting may only be one level deep). + */ + additionalBindings: HttpRule[]; +} + +/** A custom pattern is used for defining custom HTTP verb. */ +export interface CustomHttpPattern { + /** The name of this custom HTTP verb. */ + kind: string; + /** The path matched by this custom verb. */ + path: string; +} + +const baseHttp: object = { fullyDecodeReservedExpansion: false }; + +export const Http = { + encode(message: Http, writer: Writer = Writer.create()): Writer { + for (const v of message.rules) { + HttpRule.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.fullyDecodeReservedExpansion === true) { + writer.uint32(16).bool(message.fullyDecodeReservedExpansion); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Http { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseHttp } as Http; + message.rules = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.rules.push(HttpRule.decode(reader, reader.uint32())); + break; + case 2: + message.fullyDecodeReservedExpansion = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Http { + const message = { ...baseHttp } as Http; + message.rules = []; + if (object.rules !== undefined && object.rules !== null) { + for (const e of object.rules) { + message.rules.push(HttpRule.fromJSON(e)); + } + } + if ( + object.fullyDecodeReservedExpansion !== undefined && + object.fullyDecodeReservedExpansion !== null + ) { + message.fullyDecodeReservedExpansion = Boolean( + object.fullyDecodeReservedExpansion + ); + } else { + message.fullyDecodeReservedExpansion = false; + } + return message; + }, + + toJSON(message: Http): unknown { + const obj: any = {}; + if (message.rules) { + obj.rules = message.rules.map((e) => + e ? HttpRule.toJSON(e) : undefined + ); + } else { + obj.rules = []; + } + message.fullyDecodeReservedExpansion !== undefined && + (obj.fullyDecodeReservedExpansion = message.fullyDecodeReservedExpansion); + return obj; + }, + + fromPartial(object: DeepPartial): Http { + const message = { ...baseHttp } as Http; + message.rules = []; + if (object.rules !== undefined && object.rules !== null) { + for (const e of object.rules) { + message.rules.push(HttpRule.fromPartial(e)); + } + } + if ( + object.fullyDecodeReservedExpansion !== undefined && + object.fullyDecodeReservedExpansion !== null + ) { + message.fullyDecodeReservedExpansion = + object.fullyDecodeReservedExpansion; + } else { + message.fullyDecodeReservedExpansion = false; + } + return message; + }, +}; + +const baseHttpRule: object = { selector: "", body: "", responseBody: "" }; + +export const HttpRule = { + encode(message: HttpRule, writer: Writer = Writer.create()): Writer { + if (message.selector !== "") { + writer.uint32(10).string(message.selector); + } + if (message.get !== undefined) { + writer.uint32(18).string(message.get); + } + if (message.put !== undefined) { + writer.uint32(26).string(message.put); + } + if (message.post !== undefined) { + writer.uint32(34).string(message.post); + } + if (message.delete !== undefined) { + writer.uint32(42).string(message.delete); + } + if (message.patch !== undefined) { + writer.uint32(50).string(message.patch); + } + if (message.custom !== undefined) { + CustomHttpPattern.encode( + message.custom, + writer.uint32(66).fork() + ).ldelim(); + } + if (message.body !== "") { + writer.uint32(58).string(message.body); + } + if (message.responseBody !== "") { + writer.uint32(98).string(message.responseBody); + } + for (const v of message.additionalBindings) { + HttpRule.encode(v!, writer.uint32(90).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): HttpRule { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseHttpRule } as HttpRule; + message.additionalBindings = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.selector = reader.string(); + break; + case 2: + message.get = reader.string(); + break; + case 3: + message.put = reader.string(); + break; + case 4: + message.post = reader.string(); + break; + case 5: + message.delete = reader.string(); + break; + case 6: + message.patch = reader.string(); + break; + case 8: + message.custom = CustomHttpPattern.decode(reader, reader.uint32()); + break; + case 7: + message.body = reader.string(); + break; + case 12: + message.responseBody = reader.string(); + break; + case 11: + message.additionalBindings.push( + HttpRule.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): HttpRule { + const message = { ...baseHttpRule } as HttpRule; + message.additionalBindings = []; + if (object.selector !== undefined && object.selector !== null) { + message.selector = String(object.selector); + } else { + message.selector = ""; + } + if (object.get !== undefined && object.get !== null) { + message.get = String(object.get); + } else { + message.get = undefined; + } + if (object.put !== undefined && object.put !== null) { + message.put = String(object.put); + } else { + message.put = undefined; + } + if (object.post !== undefined && object.post !== null) { + message.post = String(object.post); + } else { + message.post = undefined; + } + if (object.delete !== undefined && object.delete !== null) { + message.delete = String(object.delete); + } else { + message.delete = undefined; + } + if (object.patch !== undefined && object.patch !== null) { + message.patch = String(object.patch); + } else { + message.patch = undefined; + } + if (object.custom !== undefined && object.custom !== null) { + message.custom = CustomHttpPattern.fromJSON(object.custom); + } else { + message.custom = undefined; + } + if (object.body !== undefined && object.body !== null) { + message.body = String(object.body); + } else { + message.body = ""; + } + if (object.responseBody !== undefined && object.responseBody !== null) { + message.responseBody = String(object.responseBody); + } else { + message.responseBody = ""; + } + if ( + object.additionalBindings !== undefined && + object.additionalBindings !== null + ) { + for (const e of object.additionalBindings) { + message.additionalBindings.push(HttpRule.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: HttpRule): unknown { + const obj: any = {}; + message.selector !== undefined && (obj.selector = message.selector); + message.get !== undefined && (obj.get = message.get); + message.put !== undefined && (obj.put = message.put); + message.post !== undefined && (obj.post = message.post); + message.delete !== undefined && (obj.delete = message.delete); + message.patch !== undefined && (obj.patch = message.patch); + message.custom !== undefined && + (obj.custom = message.custom + ? CustomHttpPattern.toJSON(message.custom) + : undefined); + message.body !== undefined && (obj.body = message.body); + message.responseBody !== undefined && + (obj.responseBody = message.responseBody); + if (message.additionalBindings) { + obj.additionalBindings = message.additionalBindings.map((e) => + e ? HttpRule.toJSON(e) : undefined + ); + } else { + obj.additionalBindings = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): HttpRule { + const message = { ...baseHttpRule } as HttpRule; + message.additionalBindings = []; + if (object.selector !== undefined && object.selector !== null) { + message.selector = object.selector; + } else { + message.selector = ""; + } + if (object.get !== undefined && object.get !== null) { + message.get = object.get; + } else { + message.get = undefined; + } + if (object.put !== undefined && object.put !== null) { + message.put = object.put; + } else { + message.put = undefined; + } + if (object.post !== undefined && object.post !== null) { + message.post = object.post; + } else { + message.post = undefined; + } + if (object.delete !== undefined && object.delete !== null) { + message.delete = object.delete; + } else { + message.delete = undefined; + } + if (object.patch !== undefined && object.patch !== null) { + message.patch = object.patch; + } else { + message.patch = undefined; + } + if (object.custom !== undefined && object.custom !== null) { + message.custom = CustomHttpPattern.fromPartial(object.custom); + } else { + message.custom = undefined; + } + if (object.body !== undefined && object.body !== null) { + message.body = object.body; + } else { + message.body = ""; + } + if (object.responseBody !== undefined && object.responseBody !== null) { + message.responseBody = object.responseBody; + } else { + message.responseBody = ""; + } + if ( + object.additionalBindings !== undefined && + object.additionalBindings !== null + ) { + for (const e of object.additionalBindings) { + message.additionalBindings.push(HttpRule.fromPartial(e)); + } + } + return message; + }, +}; + +const baseCustomHttpPattern: object = { kind: "", path: "" }; + +export const CustomHttpPattern = { + encode(message: CustomHttpPattern, writer: Writer = Writer.create()): Writer { + if (message.kind !== "") { + writer.uint32(10).string(message.kind); + } + if (message.path !== "") { + writer.uint32(18).string(message.path); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): CustomHttpPattern { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseCustomHttpPattern } as CustomHttpPattern; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.kind = reader.string(); + break; + case 2: + message.path = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): CustomHttpPattern { + const message = { ...baseCustomHttpPattern } as CustomHttpPattern; + if (object.kind !== undefined && object.kind !== null) { + message.kind = String(object.kind); + } else { + message.kind = ""; + } + if (object.path !== undefined && object.path !== null) { + message.path = String(object.path); + } else { + message.path = ""; + } + return message; + }, + + toJSON(message: CustomHttpPattern): unknown { + const obj: any = {}; + message.kind !== undefined && (obj.kind = message.kind); + message.path !== undefined && (obj.path = message.path); + return obj; + }, + + fromPartial(object: DeepPartial): CustomHttpPattern { + const message = { ...baseCustomHttpPattern } as CustomHttpPattern; + if (object.kind !== undefined && object.kind !== null) { + message.kind = object.kind; + } else { + message.kind = ""; + } + if (object.path !== undefined && object.path !== null) { + message.path = object.path; + } else { + message.path = ""; + } + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/cosmos.auth.v1beta1/types/google/protobuf/any.ts b/ts-client/cosmos.auth.v1beta1/types/google/protobuf/any.ts new file mode 100644 index 00000000..b137a629 --- /dev/null +++ b/ts-client/cosmos.auth.v1beta1/types/google/protobuf/any.ts @@ -0,0 +1,240 @@ +/* eslint-disable */ +import { Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "google.protobuf"; + +/** + * `Any` contains an arbitrary serialized protocol buffer message along with a + * URL that describes the type of the serialized message. + * + * Protobuf library provides support to pack/unpack Any values in the form + * of utility functions or additional generated methods of the Any type. + * + * Example 1: Pack and unpack a message in C++. + * + * Foo foo = ...; + * Any any; + * any.PackFrom(foo); + * ... + * if (any.UnpackTo(&foo)) { + * ... + * } + * + * Example 2: Pack and unpack a message in Java. + * + * Foo foo = ...; + * Any any = Any.pack(foo); + * ... + * if (any.is(Foo.class)) { + * foo = any.unpack(Foo.class); + * } + * + * Example 3: Pack and unpack a message in Python. + * + * foo = Foo(...) + * any = Any() + * any.Pack(foo) + * ... + * if any.Is(Foo.DESCRIPTOR): + * any.Unpack(foo) + * ... + * + * Example 4: Pack and unpack a message in Go + * + * foo := &pb.Foo{...} + * any, err := anypb.New(foo) + * if err != nil { + * ... + * } + * ... + * foo := &pb.Foo{} + * if err := any.UnmarshalTo(foo); err != nil { + * ... + * } + * + * The pack methods provided by protobuf library will by default use + * 'type.googleapis.com/full.type.name' as the type URL and the unpack + * methods only use the fully qualified type name after the last '/' + * in the type URL, for example "foo.bar.com/x/y.z" will yield type + * name "y.z". + * + * + * JSON + * ==== + * The JSON representation of an `Any` value uses the regular + * representation of the deserialized, embedded message, with an + * additional field `@type` which contains the type URL. Example: + * + * package google.profile; + * message Person { + * string first_name = 1; + * string last_name = 2; + * } + * + * { + * "@type": "type.googleapis.com/google.profile.Person", + * "firstName": , + * "lastName": + * } + * + * If the embedded message type is well-known and has a custom JSON + * representation, that representation will be embedded adding a field + * `value` which holds the custom JSON in addition to the `@type` + * field. Example (for message [google.protobuf.Duration][]): + * + * { + * "@type": "type.googleapis.com/google.protobuf.Duration", + * "value": "1.212s" + * } + */ +export interface Any { + /** + * A URL/resource name that uniquely identifies the type of the serialized + * protocol buffer message. This string must contain at least + * one "/" character. The last segment of the URL's path must represent + * the fully qualified name of the type (as in + * `path/google.protobuf.Duration`). The name should be in a canonical form + * (e.g., leading "." is not accepted). + * + * In practice, teams usually precompile into the binary all types that they + * expect it to use in the context of Any. However, for URLs which use the + * scheme `http`, `https`, or no scheme, one can optionally set up a type + * server that maps type URLs to message definitions as follows: + * + * * If no scheme is provided, `https` is assumed. + * * An HTTP GET on the URL must yield a [google.protobuf.Type][] + * value in binary format, or produce an error. + * * Applications are allowed to cache lookup results based on the + * URL, or have them precompiled into a binary to avoid any + * lookup. Therefore, binary compatibility needs to be preserved + * on changes to types. (Use versioned type names to manage + * breaking changes.) + * + * Note: this functionality is not currently available in the official + * protobuf release, and it is not used for type URLs beginning with + * type.googleapis.com. + * + * Schemes other than `http`, `https` (or the empty scheme) might be + * used with implementation specific semantics. + */ + typeUrl: string; + /** Must be a valid serialized protocol buffer of the above specified type. */ + value: Uint8Array; +} + +const baseAny: object = { typeUrl: "" }; + +export const Any = { + encode(message: Any, writer: Writer = Writer.create()): Writer { + if (message.typeUrl !== "") { + writer.uint32(10).string(message.typeUrl); + } + if (message.value.length !== 0) { + writer.uint32(18).bytes(message.value); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Any { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseAny } as Any; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.typeUrl = reader.string(); + break; + case 2: + message.value = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Any { + const message = { ...baseAny } as Any; + if (object.typeUrl !== undefined && object.typeUrl !== null) { + message.typeUrl = String(object.typeUrl); + } else { + message.typeUrl = ""; + } + if (object.value !== undefined && object.value !== null) { + message.value = bytesFromBase64(object.value); + } + return message; + }, + + toJSON(message: Any): unknown { + const obj: any = {}; + message.typeUrl !== undefined && (obj.typeUrl = message.typeUrl); + message.value !== undefined && + (obj.value = base64FromBytes( + message.value !== undefined ? message.value : new Uint8Array() + )); + return obj; + }, + + fromPartial(object: DeepPartial): Any { + const message = { ...baseAny } as Any; + if (object.typeUrl !== undefined && object.typeUrl !== null) { + message.typeUrl = object.typeUrl; + } else { + message.typeUrl = ""; + } + if (object.value !== undefined && object.value !== null) { + message.value = object.value; + } else { + message.value = new Uint8Array(); + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/cosmos.auth.v1beta1/types/google/protobuf/descriptor.ts b/ts-client/cosmos.auth.v1beta1/types/google/protobuf/descriptor.ts new file mode 100644 index 00000000..9e508660 --- /dev/null +++ b/ts-client/cosmos.auth.v1beta1/types/google/protobuf/descriptor.ts @@ -0,0 +1,5261 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "google.protobuf"; + +/** + * The protocol compiler can output a FileDescriptorSet containing the .proto + * files it parses. + */ +export interface FileDescriptorSet { + file: FileDescriptorProto[]; +} + +/** Describes a complete .proto file. */ +export interface FileDescriptorProto { + /** file name, relative to root of source tree */ + name: string; + /** e.g. "foo", "foo.bar", etc. */ + package: string; + /** Names of files imported by this file. */ + dependency: string[]; + /** Indexes of the public imported files in the dependency list above. */ + publicDependency: number[]; + /** + * Indexes of the weak imported files in the dependency list. + * For Google-internal migration only. Do not use. + */ + weakDependency: number[]; + /** All top-level definitions in this file. */ + messageType: DescriptorProto[]; + enumType: EnumDescriptorProto[]; + service: ServiceDescriptorProto[]; + extension: FieldDescriptorProto[]; + options: FileOptions | undefined; + /** + * This field contains optional information about the original source code. + * You may safely remove this entire field without harming runtime + * functionality of the descriptors -- the information is needed only by + * development tools. + */ + sourceCodeInfo: SourceCodeInfo | undefined; + /** + * The syntax of the proto file. + * The supported values are "proto2" and "proto3". + */ + syntax: string; +} + +/** Describes a message type. */ +export interface DescriptorProto { + name: string; + field: FieldDescriptorProto[]; + extension: FieldDescriptorProto[]; + nestedType: DescriptorProto[]; + enumType: EnumDescriptorProto[]; + extensionRange: DescriptorProto_ExtensionRange[]; + oneofDecl: OneofDescriptorProto[]; + options: MessageOptions | undefined; + reservedRange: DescriptorProto_ReservedRange[]; + /** + * Reserved field names, which may not be used by fields in the same message. + * A given name may only be reserved once. + */ + reservedName: string[]; +} + +export interface DescriptorProto_ExtensionRange { + /** Inclusive. */ + start: number; + /** Exclusive. */ + end: number; + options: ExtensionRangeOptions | undefined; +} + +/** + * Range of reserved tag numbers. Reserved tag numbers may not be used by + * fields or extension ranges in the same message. Reserved ranges may + * not overlap. + */ +export interface DescriptorProto_ReservedRange { + /** Inclusive. */ + start: number; + /** Exclusive. */ + end: number; +} + +export interface ExtensionRangeOptions { + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +/** Describes a field within a message. */ +export interface FieldDescriptorProto { + name: string; + number: number; + label: FieldDescriptorProto_Label; + /** + * If type_name is set, this need not be set. If both this and type_name + * are set, this must be one of TYPE_ENUM, TYPE_MESSAGE or TYPE_GROUP. + */ + type: FieldDescriptorProto_Type; + /** + * For message and enum types, this is the name of the type. If the name + * starts with a '.', it is fully-qualified. Otherwise, C++-like scoping + * rules are used to find the type (i.e. first the nested types within this + * message are searched, then within the parent, on up to the root + * namespace). + */ + typeName: string; + /** + * For extensions, this is the name of the type being extended. It is + * resolved in the same manner as type_name. + */ + extendee: string; + /** + * For numeric types, contains the original text representation of the value. + * For booleans, "true" or "false". + * For strings, contains the default text contents (not escaped in any way). + * For bytes, contains the C escaped value. All bytes >= 128 are escaped. + * TODO(kenton): Base-64 encode? + */ + defaultValue: string; + /** + * If set, gives the index of a oneof in the containing type's oneof_decl + * list. This field is a member of that oneof. + */ + oneofIndex: number; + /** + * JSON name of this field. The value is set by protocol compiler. If the + * user has set a "json_name" option on this field, that option's value + * will be used. Otherwise, it's deduced from the field's name by converting + * it to camelCase. + */ + jsonName: string; + options: FieldOptions | undefined; + /** + * If true, this is a proto3 "optional". When a proto3 field is optional, it + * tracks presence regardless of field type. + * + * When proto3_optional is true, this field must be belong to a oneof to + * signal to old proto3 clients that presence is tracked for this field. This + * oneof is known as a "synthetic" oneof, and this field must be its sole + * member (each proto3 optional field gets its own synthetic oneof). Synthetic + * oneofs exist in the descriptor only, and do not generate any API. Synthetic + * oneofs must be ordered after all "real" oneofs. + * + * For message fields, proto3_optional doesn't create any semantic change, + * since non-repeated message fields always track presence. However it still + * indicates the semantic detail of whether the user wrote "optional" or not. + * This can be useful for round-tripping the .proto file. For consistency we + * give message fields a synthetic oneof also, even though it is not required + * to track presence. This is especially important because the parser can't + * tell if a field is a message or an enum, so it must always create a + * synthetic oneof. + * + * Proto2 optional fields do not set this flag, because they already indicate + * optional with `LABEL_OPTIONAL`. + */ + proto3Optional: boolean; +} + +export enum FieldDescriptorProto_Type { + /** + * TYPE_DOUBLE - 0 is reserved for errors. + * Order is weird for historical reasons. + */ + TYPE_DOUBLE = 1, + TYPE_FLOAT = 2, + /** + * TYPE_INT64 - Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT64 if + * negative values are likely. + */ + TYPE_INT64 = 3, + TYPE_UINT64 = 4, + /** + * TYPE_INT32 - Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT32 if + * negative values are likely. + */ + TYPE_INT32 = 5, + TYPE_FIXED64 = 6, + TYPE_FIXED32 = 7, + TYPE_BOOL = 8, + TYPE_STRING = 9, + /** + * TYPE_GROUP - Tag-delimited aggregate. + * Group type is deprecated and not supported in proto3. However, Proto3 + * implementations should still be able to parse the group wire format and + * treat group fields as unknown fields. + */ + TYPE_GROUP = 10, + /** TYPE_MESSAGE - Length-delimited aggregate. */ + TYPE_MESSAGE = 11, + /** TYPE_BYTES - New in version 2. */ + TYPE_BYTES = 12, + TYPE_UINT32 = 13, + TYPE_ENUM = 14, + TYPE_SFIXED32 = 15, + TYPE_SFIXED64 = 16, + /** TYPE_SINT32 - Uses ZigZag encoding. */ + TYPE_SINT32 = 17, + /** TYPE_SINT64 - Uses ZigZag encoding. */ + TYPE_SINT64 = 18, + UNRECOGNIZED = -1, +} + +export function fieldDescriptorProto_TypeFromJSON( + object: any +): FieldDescriptorProto_Type { + switch (object) { + case 1: + case "TYPE_DOUBLE": + return FieldDescriptorProto_Type.TYPE_DOUBLE; + case 2: + case "TYPE_FLOAT": + return FieldDescriptorProto_Type.TYPE_FLOAT; + case 3: + case "TYPE_INT64": + return FieldDescriptorProto_Type.TYPE_INT64; + case 4: + case "TYPE_UINT64": + return FieldDescriptorProto_Type.TYPE_UINT64; + case 5: + case "TYPE_INT32": + return FieldDescriptorProto_Type.TYPE_INT32; + case 6: + case "TYPE_FIXED64": + return FieldDescriptorProto_Type.TYPE_FIXED64; + case 7: + case "TYPE_FIXED32": + return FieldDescriptorProto_Type.TYPE_FIXED32; + case 8: + case "TYPE_BOOL": + return FieldDescriptorProto_Type.TYPE_BOOL; + case 9: + case "TYPE_STRING": + return FieldDescriptorProto_Type.TYPE_STRING; + case 10: + case "TYPE_GROUP": + return FieldDescriptorProto_Type.TYPE_GROUP; + case 11: + case "TYPE_MESSAGE": + return FieldDescriptorProto_Type.TYPE_MESSAGE; + case 12: + case "TYPE_BYTES": + return FieldDescriptorProto_Type.TYPE_BYTES; + case 13: + case "TYPE_UINT32": + return FieldDescriptorProto_Type.TYPE_UINT32; + case 14: + case "TYPE_ENUM": + return FieldDescriptorProto_Type.TYPE_ENUM; + case 15: + case "TYPE_SFIXED32": + return FieldDescriptorProto_Type.TYPE_SFIXED32; + case 16: + case "TYPE_SFIXED64": + return FieldDescriptorProto_Type.TYPE_SFIXED64; + case 17: + case "TYPE_SINT32": + return FieldDescriptorProto_Type.TYPE_SINT32; + case 18: + case "TYPE_SINT64": + return FieldDescriptorProto_Type.TYPE_SINT64; + case -1: + case "UNRECOGNIZED": + default: + return FieldDescriptorProto_Type.UNRECOGNIZED; + } +} + +export function fieldDescriptorProto_TypeToJSON( + object: FieldDescriptorProto_Type +): string { + switch (object) { + case FieldDescriptorProto_Type.TYPE_DOUBLE: + return "TYPE_DOUBLE"; + case FieldDescriptorProto_Type.TYPE_FLOAT: + return "TYPE_FLOAT"; + case FieldDescriptorProto_Type.TYPE_INT64: + return "TYPE_INT64"; + case FieldDescriptorProto_Type.TYPE_UINT64: + return "TYPE_UINT64"; + case FieldDescriptorProto_Type.TYPE_INT32: + return "TYPE_INT32"; + case FieldDescriptorProto_Type.TYPE_FIXED64: + return "TYPE_FIXED64"; + case FieldDescriptorProto_Type.TYPE_FIXED32: + return "TYPE_FIXED32"; + case FieldDescriptorProto_Type.TYPE_BOOL: + return "TYPE_BOOL"; + case FieldDescriptorProto_Type.TYPE_STRING: + return "TYPE_STRING"; + case FieldDescriptorProto_Type.TYPE_GROUP: + return "TYPE_GROUP"; + case FieldDescriptorProto_Type.TYPE_MESSAGE: + return "TYPE_MESSAGE"; + case FieldDescriptorProto_Type.TYPE_BYTES: + return "TYPE_BYTES"; + case FieldDescriptorProto_Type.TYPE_UINT32: + return "TYPE_UINT32"; + case FieldDescriptorProto_Type.TYPE_ENUM: + return "TYPE_ENUM"; + case FieldDescriptorProto_Type.TYPE_SFIXED32: + return "TYPE_SFIXED32"; + case FieldDescriptorProto_Type.TYPE_SFIXED64: + return "TYPE_SFIXED64"; + case FieldDescriptorProto_Type.TYPE_SINT32: + return "TYPE_SINT32"; + case FieldDescriptorProto_Type.TYPE_SINT64: + return "TYPE_SINT64"; + default: + return "UNKNOWN"; + } +} + +export enum FieldDescriptorProto_Label { + /** LABEL_OPTIONAL - 0 is reserved for errors */ + LABEL_OPTIONAL = 1, + LABEL_REQUIRED = 2, + LABEL_REPEATED = 3, + UNRECOGNIZED = -1, +} + +export function fieldDescriptorProto_LabelFromJSON( + object: any +): FieldDescriptorProto_Label { + switch (object) { + case 1: + case "LABEL_OPTIONAL": + return FieldDescriptorProto_Label.LABEL_OPTIONAL; + case 2: + case "LABEL_REQUIRED": + return FieldDescriptorProto_Label.LABEL_REQUIRED; + case 3: + case "LABEL_REPEATED": + return FieldDescriptorProto_Label.LABEL_REPEATED; + case -1: + case "UNRECOGNIZED": + default: + return FieldDescriptorProto_Label.UNRECOGNIZED; + } +} + +export function fieldDescriptorProto_LabelToJSON( + object: FieldDescriptorProto_Label +): string { + switch (object) { + case FieldDescriptorProto_Label.LABEL_OPTIONAL: + return "LABEL_OPTIONAL"; + case FieldDescriptorProto_Label.LABEL_REQUIRED: + return "LABEL_REQUIRED"; + case FieldDescriptorProto_Label.LABEL_REPEATED: + return "LABEL_REPEATED"; + default: + return "UNKNOWN"; + } +} + +/** Describes a oneof. */ +export interface OneofDescriptorProto { + name: string; + options: OneofOptions | undefined; +} + +/** Describes an enum type. */ +export interface EnumDescriptorProto { + name: string; + value: EnumValueDescriptorProto[]; + options: EnumOptions | undefined; + /** + * Range of reserved numeric values. Reserved numeric values may not be used + * by enum values in the same enum declaration. Reserved ranges may not + * overlap. + */ + reservedRange: EnumDescriptorProto_EnumReservedRange[]; + /** + * Reserved enum value names, which may not be reused. A given name may only + * be reserved once. + */ + reservedName: string[]; +} + +/** + * Range of reserved numeric values. Reserved values may not be used by + * entries in the same enum. Reserved ranges may not overlap. + * + * Note that this is distinct from DescriptorProto.ReservedRange in that it + * is inclusive such that it can appropriately represent the entire int32 + * domain. + */ +export interface EnumDescriptorProto_EnumReservedRange { + /** Inclusive. */ + start: number; + /** Inclusive. */ + end: number; +} + +/** Describes a value within an enum. */ +export interface EnumValueDescriptorProto { + name: string; + number: number; + options: EnumValueOptions | undefined; +} + +/** Describes a service. */ +export interface ServiceDescriptorProto { + name: string; + method: MethodDescriptorProto[]; + options: ServiceOptions | undefined; +} + +/** Describes a method of a service. */ +export interface MethodDescriptorProto { + name: string; + /** + * Input and output type names. These are resolved in the same way as + * FieldDescriptorProto.type_name, but must refer to a message type. + */ + inputType: string; + outputType: string; + options: MethodOptions | undefined; + /** Identifies if client streams multiple client messages */ + clientStreaming: boolean; + /** Identifies if server streams multiple server messages */ + serverStreaming: boolean; +} + +export interface FileOptions { + /** + * Sets the Java package where classes generated from this .proto will be + * placed. By default, the proto package is used, but this is often + * inappropriate because proto packages do not normally start with backwards + * domain names. + */ + javaPackage: string; + /** + * Controls the name of the wrapper Java class generated for the .proto file. + * That class will always contain the .proto file's getDescriptor() method as + * well as any top-level extensions defined in the .proto file. + * If java_multiple_files is disabled, then all the other classes from the + * .proto file will be nested inside the single wrapper outer class. + */ + javaOuterClassname: string; + /** + * If enabled, then the Java code generator will generate a separate .java + * file for each top-level message, enum, and service defined in the .proto + * file. Thus, these types will *not* be nested inside the wrapper class + * named by java_outer_classname. However, the wrapper class will still be + * generated to contain the file's getDescriptor() method as well as any + * top-level extensions defined in the file. + */ + javaMultipleFiles: boolean; + /** + * This option does nothing. + * + * @deprecated + */ + javaGenerateEqualsAndHash: boolean; + /** + * If set true, then the Java2 code generator will generate code that + * throws an exception whenever an attempt is made to assign a non-UTF-8 + * byte sequence to a string field. + * Message reflection will do the same. + * However, an extension field still accepts non-UTF-8 byte sequences. + * This option has no effect on when used with the lite runtime. + */ + javaStringCheckUtf8: boolean; + optimizeFor: FileOptions_OptimizeMode; + /** + * Sets the Go package where structs generated from this .proto will be + * placed. If omitted, the Go package will be derived from the following: + * - The basename of the package import path, if provided. + * - Otherwise, the package statement in the .proto file, if present. + * - Otherwise, the basename of the .proto file, without extension. + */ + goPackage: string; + /** + * Should generic services be generated in each language? "Generic" services + * are not specific to any particular RPC system. They are generated by the + * main code generators in each language (without additional plugins). + * Generic services were the only kind of service generation supported by + * early versions of google.protobuf. + * + * Generic services are now considered deprecated in favor of using plugins + * that generate code specific to your particular RPC system. Therefore, + * these default to false. Old code which depends on generic services should + * explicitly set them to true. + */ + ccGenericServices: boolean; + javaGenericServices: boolean; + pyGenericServices: boolean; + phpGenericServices: boolean; + /** + * Is this file deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for everything in the file, or it will be completely ignored; in the very + * least, this is a formalization for deprecating files. + */ + deprecated: boolean; + /** + * Enables the use of arenas for the proto messages in this file. This applies + * only to generated classes for C++. + */ + ccEnableArenas: boolean; + /** + * Sets the objective c class prefix which is prepended to all objective c + * generated classes from this .proto. There is no default. + */ + objcClassPrefix: string; + /** Namespace for generated classes; defaults to the package. */ + csharpNamespace: string; + /** + * By default Swift generators will take the proto package and CamelCase it + * replacing '.' with underscore and use that to prefix the types/symbols + * defined. When this options is provided, they will use this value instead + * to prefix the types/symbols defined. + */ + swiftPrefix: string; + /** + * Sets the php class prefix which is prepended to all php generated classes + * from this .proto. Default is empty. + */ + phpClassPrefix: string; + /** + * Use this option to change the namespace of php generated classes. Default + * is empty. When this option is empty, the package name will be used for + * determining the namespace. + */ + phpNamespace: string; + /** + * Use this option to change the namespace of php generated metadata classes. + * Default is empty. When this option is empty, the proto file name will be + * used for determining the namespace. + */ + phpMetadataNamespace: string; + /** + * Use this option to change the package of ruby generated classes. Default + * is empty. When this option is not set, the package name will be used for + * determining the ruby package. + */ + rubyPackage: string; + /** + * The parser stores options it doesn't recognize here. + * See the documentation for the "Options" section above. + */ + uninterpretedOption: UninterpretedOption[]; +} + +/** Generated classes can be optimized for speed or code size. */ +export enum FileOptions_OptimizeMode { + /** SPEED - Generate complete code for parsing, serialization, */ + SPEED = 1, + /** CODE_SIZE - etc. */ + CODE_SIZE = 2, + /** LITE_RUNTIME - Generate code using MessageLite and the lite runtime. */ + LITE_RUNTIME = 3, + UNRECOGNIZED = -1, +} + +export function fileOptions_OptimizeModeFromJSON( + object: any +): FileOptions_OptimizeMode { + switch (object) { + case 1: + case "SPEED": + return FileOptions_OptimizeMode.SPEED; + case 2: + case "CODE_SIZE": + return FileOptions_OptimizeMode.CODE_SIZE; + case 3: + case "LITE_RUNTIME": + return FileOptions_OptimizeMode.LITE_RUNTIME; + case -1: + case "UNRECOGNIZED": + default: + return FileOptions_OptimizeMode.UNRECOGNIZED; + } +} + +export function fileOptions_OptimizeModeToJSON( + object: FileOptions_OptimizeMode +): string { + switch (object) { + case FileOptions_OptimizeMode.SPEED: + return "SPEED"; + case FileOptions_OptimizeMode.CODE_SIZE: + return "CODE_SIZE"; + case FileOptions_OptimizeMode.LITE_RUNTIME: + return "LITE_RUNTIME"; + default: + return "UNKNOWN"; + } +} + +export interface MessageOptions { + /** + * Set true to use the old proto1 MessageSet wire format for extensions. + * This is provided for backwards-compatibility with the MessageSet wire + * format. You should not use this for any other reason: It's less + * efficient, has fewer features, and is more complicated. + * + * The message must be defined exactly as follows: + * message Foo { + * option message_set_wire_format = true; + * extensions 4 to max; + * } + * Note that the message cannot have any defined fields; MessageSets only + * have extensions. + * + * All extensions of your type must be singular messages; e.g. they cannot + * be int32s, enums, or repeated messages. + * + * Because this is an option, the above two restrictions are not enforced by + * the protocol compiler. + */ + messageSetWireFormat: boolean; + /** + * Disables the generation of the standard "descriptor()" accessor, which can + * conflict with a field of the same name. This is meant to make migration + * from proto1 easier; new code should avoid fields named "descriptor". + */ + noStandardDescriptorAccessor: boolean; + /** + * Is this message deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the message, or it will be completely ignored; in the very least, + * this is a formalization for deprecating messages. + */ + deprecated: boolean; + /** + * Whether the message is an automatically generated map entry type for the + * maps field. + * + * For maps fields: + * map map_field = 1; + * The parsed descriptor looks like: + * message MapFieldEntry { + * option map_entry = true; + * optional KeyType key = 1; + * optional ValueType value = 2; + * } + * repeated MapFieldEntry map_field = 1; + * + * Implementations may choose not to generate the map_entry=true message, but + * use a native map in the target language to hold the keys and values. + * The reflection APIs in such implementations still need to work as + * if the field is a repeated message field. + * + * NOTE: Do not set the option in .proto files. Always use the maps syntax + * instead. The option should only be implicitly set by the proto compiler + * parser. + */ + mapEntry: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface FieldOptions { + /** + * The ctype option instructs the C++ code generator to use a different + * representation of the field than it normally would. See the specific + * options below. This option is not yet implemented in the open source + * release -- sorry, we'll try to include it in a future version! + */ + ctype: FieldOptions_CType; + /** + * The packed option can be enabled for repeated primitive fields to enable + * a more efficient representation on the wire. Rather than repeatedly + * writing the tag and type for each element, the entire array is encoded as + * a single length-delimited blob. In proto3, only explicit setting it to + * false will avoid using packed encoding. + */ + packed: boolean; + /** + * The jstype option determines the JavaScript type used for values of the + * field. The option is permitted only for 64 bit integral and fixed types + * (int64, uint64, sint64, fixed64, sfixed64). A field with jstype JS_STRING + * is represented as JavaScript string, which avoids loss of precision that + * can happen when a large value is converted to a floating point JavaScript. + * Specifying JS_NUMBER for the jstype causes the generated JavaScript code to + * use the JavaScript "number" type. The behavior of the default option + * JS_NORMAL is implementation dependent. + * + * This option is an enum to permit additional types to be added, e.g. + * goog.math.Integer. + */ + jstype: FieldOptions_JSType; + /** + * Should this field be parsed lazily? Lazy applies only to message-type + * fields. It means that when the outer message is initially parsed, the + * inner message's contents will not be parsed but instead stored in encoded + * form. The inner message will actually be parsed when it is first accessed. + * + * This is only a hint. Implementations are free to choose whether to use + * eager or lazy parsing regardless of the value of this option. However, + * setting this option true suggests that the protocol author believes that + * using lazy parsing on this field is worth the additional bookkeeping + * overhead typically needed to implement it. + * + * This option does not affect the public interface of any generated code; + * all method signatures remain the same. Furthermore, thread-safety of the + * interface is not affected by this option; const methods remain safe to + * call from multiple threads concurrently, while non-const methods continue + * to require exclusive access. + * + * + * Note that implementations may choose not to check required fields within + * a lazy sub-message. That is, calling IsInitialized() on the outer message + * may return true even if the inner message has missing required fields. + * This is necessary because otherwise the inner message would have to be + * parsed in order to perform the check, defeating the purpose of lazy + * parsing. An implementation which chooses not to check required fields + * must be consistent about it. That is, for any particular sub-message, the + * implementation must either *always* check its required fields, or *never* + * check its required fields, regardless of whether or not the message has + * been parsed. + */ + lazy: boolean; + /** + * Is this field deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for accessors, or it will be completely ignored; in the very least, this + * is a formalization for deprecating fields. + */ + deprecated: boolean; + /** For Google-internal migration only. Do not use. */ + weak: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export enum FieldOptions_CType { + /** STRING - Default mode. */ + STRING = 0, + CORD = 1, + STRING_PIECE = 2, + UNRECOGNIZED = -1, +} + +export function fieldOptions_CTypeFromJSON(object: any): FieldOptions_CType { + switch (object) { + case 0: + case "STRING": + return FieldOptions_CType.STRING; + case 1: + case "CORD": + return FieldOptions_CType.CORD; + case 2: + case "STRING_PIECE": + return FieldOptions_CType.STRING_PIECE; + case -1: + case "UNRECOGNIZED": + default: + return FieldOptions_CType.UNRECOGNIZED; + } +} + +export function fieldOptions_CTypeToJSON(object: FieldOptions_CType): string { + switch (object) { + case FieldOptions_CType.STRING: + return "STRING"; + case FieldOptions_CType.CORD: + return "CORD"; + case FieldOptions_CType.STRING_PIECE: + return "STRING_PIECE"; + default: + return "UNKNOWN"; + } +} + +export enum FieldOptions_JSType { + /** JS_NORMAL - Use the default type. */ + JS_NORMAL = 0, + /** JS_STRING - Use JavaScript strings. */ + JS_STRING = 1, + /** JS_NUMBER - Use JavaScript numbers. */ + JS_NUMBER = 2, + UNRECOGNIZED = -1, +} + +export function fieldOptions_JSTypeFromJSON(object: any): FieldOptions_JSType { + switch (object) { + case 0: + case "JS_NORMAL": + return FieldOptions_JSType.JS_NORMAL; + case 1: + case "JS_STRING": + return FieldOptions_JSType.JS_STRING; + case 2: + case "JS_NUMBER": + return FieldOptions_JSType.JS_NUMBER; + case -1: + case "UNRECOGNIZED": + default: + return FieldOptions_JSType.UNRECOGNIZED; + } +} + +export function fieldOptions_JSTypeToJSON(object: FieldOptions_JSType): string { + switch (object) { + case FieldOptions_JSType.JS_NORMAL: + return "JS_NORMAL"; + case FieldOptions_JSType.JS_STRING: + return "JS_STRING"; + case FieldOptions_JSType.JS_NUMBER: + return "JS_NUMBER"; + default: + return "UNKNOWN"; + } +} + +export interface OneofOptions { + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface EnumOptions { + /** + * Set this option to true to allow mapping different tag names to the same + * value. + */ + allowAlias: boolean; + /** + * Is this enum deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the enum, or it will be completely ignored; in the very least, this + * is a formalization for deprecating enums. + */ + deprecated: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface EnumValueOptions { + /** + * Is this enum value deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the enum value, or it will be completely ignored; in the very least, + * this is a formalization for deprecating enum values. + */ + deprecated: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface ServiceOptions { + /** + * Is this service deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the service, or it will be completely ignored; in the very least, + * this is a formalization for deprecating services. + */ + deprecated: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface MethodOptions { + /** + * Is this method deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the method, or it will be completely ignored; in the very least, + * this is a formalization for deprecating methods. + */ + deprecated: boolean; + idempotencyLevel: MethodOptions_IdempotencyLevel; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +/** + * Is this method side-effect-free (or safe in HTTP parlance), or idempotent, + * or neither? HTTP based RPC implementation may choose GET verb for safe + * methods, and PUT verb for idempotent methods instead of the default POST. + */ +export enum MethodOptions_IdempotencyLevel { + IDEMPOTENCY_UNKNOWN = 0, + /** NO_SIDE_EFFECTS - implies idempotent */ + NO_SIDE_EFFECTS = 1, + /** IDEMPOTENT - idempotent, but may have side effects */ + IDEMPOTENT = 2, + UNRECOGNIZED = -1, +} + +export function methodOptions_IdempotencyLevelFromJSON( + object: any +): MethodOptions_IdempotencyLevel { + switch (object) { + case 0: + case "IDEMPOTENCY_UNKNOWN": + return MethodOptions_IdempotencyLevel.IDEMPOTENCY_UNKNOWN; + case 1: + case "NO_SIDE_EFFECTS": + return MethodOptions_IdempotencyLevel.NO_SIDE_EFFECTS; + case 2: + case "IDEMPOTENT": + return MethodOptions_IdempotencyLevel.IDEMPOTENT; + case -1: + case "UNRECOGNIZED": + default: + return MethodOptions_IdempotencyLevel.UNRECOGNIZED; + } +} + +export function methodOptions_IdempotencyLevelToJSON( + object: MethodOptions_IdempotencyLevel +): string { + switch (object) { + case MethodOptions_IdempotencyLevel.IDEMPOTENCY_UNKNOWN: + return "IDEMPOTENCY_UNKNOWN"; + case MethodOptions_IdempotencyLevel.NO_SIDE_EFFECTS: + return "NO_SIDE_EFFECTS"; + case MethodOptions_IdempotencyLevel.IDEMPOTENT: + return "IDEMPOTENT"; + default: + return "UNKNOWN"; + } +} + +/** + * A message representing a option the parser does not recognize. This only + * appears in options protos created by the compiler::Parser class. + * DescriptorPool resolves these when building Descriptor objects. Therefore, + * options protos in descriptor objects (e.g. returned by Descriptor::options(), + * or produced by Descriptor::CopyTo()) will never have UninterpretedOptions + * in them. + */ +export interface UninterpretedOption { + name: UninterpretedOption_NamePart[]; + /** + * The value of the uninterpreted option, in whatever type the tokenizer + * identified it as during parsing. Exactly one of these should be set. + */ + identifierValue: string; + positiveIntValue: number; + negativeIntValue: number; + doubleValue: number; + stringValue: Uint8Array; + aggregateValue: string; +} + +/** + * The name of the uninterpreted option. Each string represents a segment in + * a dot-separated name. is_extension is true iff a segment represents an + * extension (denoted with parentheses in options specs in .proto files). + * E.g.,{ ["foo", false], ["bar.baz", true], ["qux", false] } represents + * "foo.(bar.baz).qux". + */ +export interface UninterpretedOption_NamePart { + namePart: string; + isExtension: boolean; +} + +/** + * Encapsulates information about the original source file from which a + * FileDescriptorProto was generated. + */ +export interface SourceCodeInfo { + /** + * A Location identifies a piece of source code in a .proto file which + * corresponds to a particular definition. This information is intended + * to be useful to IDEs, code indexers, documentation generators, and similar + * tools. + * + * For example, say we have a file like: + * message Foo { + * optional string foo = 1; + * } + * Let's look at just the field definition: + * optional string foo = 1; + * ^ ^^ ^^ ^ ^^^ + * a bc de f ghi + * We have the following locations: + * span path represents + * [a,i) [ 4, 0, 2, 0 ] The whole field definition. + * [a,b) [ 4, 0, 2, 0, 4 ] The label (optional). + * [c,d) [ 4, 0, 2, 0, 5 ] The type (string). + * [e,f) [ 4, 0, 2, 0, 1 ] The name (foo). + * [g,h) [ 4, 0, 2, 0, 3 ] The number (1). + * + * Notes: + * - A location may refer to a repeated field itself (i.e. not to any + * particular index within it). This is used whenever a set of elements are + * logically enclosed in a single code segment. For example, an entire + * extend block (possibly containing multiple extension definitions) will + * have an outer location whose path refers to the "extensions" repeated + * field without an index. + * - Multiple locations may have the same path. This happens when a single + * logical declaration is spread out across multiple places. The most + * obvious example is the "extend" block again -- there may be multiple + * extend blocks in the same scope, each of which will have the same path. + * - A location's span is not always a subset of its parent's span. For + * example, the "extendee" of an extension declaration appears at the + * beginning of the "extend" block and is shared by all extensions within + * the block. + * - Just because a location's span is a subset of some other location's span + * does not mean that it is a descendant. For example, a "group" defines + * both a type and a field in a single declaration. Thus, the locations + * corresponding to the type and field and their components will overlap. + * - Code which tries to interpret locations should probably be designed to + * ignore those that it doesn't understand, as more types of locations could + * be recorded in the future. + */ + location: SourceCodeInfo_Location[]; +} + +export interface SourceCodeInfo_Location { + /** + * Identifies which part of the FileDescriptorProto was defined at this + * location. + * + * Each element is a field number or an index. They form a path from + * the root FileDescriptorProto to the place where the definition. For + * example, this path: + * [ 4, 3, 2, 7, 1 ] + * refers to: + * file.message_type(3) // 4, 3 + * .field(7) // 2, 7 + * .name() // 1 + * This is because FileDescriptorProto.message_type has field number 4: + * repeated DescriptorProto message_type = 4; + * and DescriptorProto.field has field number 2: + * repeated FieldDescriptorProto field = 2; + * and FieldDescriptorProto.name has field number 1: + * optional string name = 1; + * + * Thus, the above path gives the location of a field name. If we removed + * the last element: + * [ 4, 3, 2, 7 ] + * this path refers to the whole field declaration (from the beginning + * of the label to the terminating semicolon). + */ + path: number[]; + /** + * Always has exactly three or four elements: start line, start column, + * end line (optional, otherwise assumed same as start line), end column. + * These are packed into a single field for efficiency. Note that line + * and column numbers are zero-based -- typically you will want to add + * 1 to each before displaying to a user. + */ + span: number[]; + /** + * If this SourceCodeInfo represents a complete declaration, these are any + * comments appearing before and after the declaration which appear to be + * attached to the declaration. + * + * A series of line comments appearing on consecutive lines, with no other + * tokens appearing on those lines, will be treated as a single comment. + * + * leading_detached_comments will keep paragraphs of comments that appear + * before (but not connected to) the current element. Each paragraph, + * separated by empty lines, will be one comment element in the repeated + * field. + * + * Only the comment content is provided; comment markers (e.g. //) are + * stripped out. For block comments, leading whitespace and an asterisk + * will be stripped from the beginning of each line other than the first. + * Newlines are included in the output. + * + * Examples: + * + * optional int32 foo = 1; // Comment attached to foo. + * // Comment attached to bar. + * optional int32 bar = 2; + * + * optional string baz = 3; + * // Comment attached to baz. + * // Another line attached to baz. + * + * // Comment attached to qux. + * // + * // Another line attached to qux. + * optional double qux = 4; + * + * // Detached comment for corge. This is not leading or trailing comments + * // to qux or corge because there are blank lines separating it from + * // both. + * + * // Detached comment for corge paragraph 2. + * + * optional string corge = 5; + * /* Block comment attached + * * to corge. Leading asterisks + * * will be removed. * / + * /* Block comment attached to + * * grault. * / + * optional int32 grault = 6; + * + * // ignored detached comments. + */ + leadingComments: string; + trailingComments: string; + leadingDetachedComments: string[]; +} + +/** + * Describes the relationship between generated code and its original source + * file. A GeneratedCodeInfo message is associated with only one generated + * source file, but may contain references to different source .proto files. + */ +export interface GeneratedCodeInfo { + /** + * An Annotation connects some span of text in generated code to an element + * of its generating .proto file. + */ + annotation: GeneratedCodeInfo_Annotation[]; +} + +export interface GeneratedCodeInfo_Annotation { + /** + * Identifies the element in the original source .proto file. This field + * is formatted the same as SourceCodeInfo.Location.path. + */ + path: number[]; + /** Identifies the filesystem path to the original source .proto. */ + sourceFile: string; + /** + * Identifies the starting offset in bytes in the generated code + * that relates to the identified object. + */ + begin: number; + /** + * Identifies the ending offset in bytes in the generated code that + * relates to the identified offset. The end offset should be one past + * the last relevant byte (so the length of the text = end - begin). + */ + end: number; +} + +const baseFileDescriptorSet: object = {}; + +export const FileDescriptorSet = { + encode(message: FileDescriptorSet, writer: Writer = Writer.create()): Writer { + for (const v of message.file) { + FileDescriptorProto.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FileDescriptorSet { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFileDescriptorSet } as FileDescriptorSet; + message.file = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.file.push( + FileDescriptorProto.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FileDescriptorSet { + const message = { ...baseFileDescriptorSet } as FileDescriptorSet; + message.file = []; + if (object.file !== undefined && object.file !== null) { + for (const e of object.file) { + message.file.push(FileDescriptorProto.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: FileDescriptorSet): unknown { + const obj: any = {}; + if (message.file) { + obj.file = message.file.map((e) => + e ? FileDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.file = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): FileDescriptorSet { + const message = { ...baseFileDescriptorSet } as FileDescriptorSet; + message.file = []; + if (object.file !== undefined && object.file !== null) { + for (const e of object.file) { + message.file.push(FileDescriptorProto.fromPartial(e)); + } + } + return message; + }, +}; + +const baseFileDescriptorProto: object = { + name: "", + package: "", + dependency: "", + publicDependency: 0, + weakDependency: 0, + syntax: "", +}; + +export const FileDescriptorProto = { + encode( + message: FileDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.package !== "") { + writer.uint32(18).string(message.package); + } + for (const v of message.dependency) { + writer.uint32(26).string(v!); + } + writer.uint32(82).fork(); + for (const v of message.publicDependency) { + writer.int32(v); + } + writer.ldelim(); + writer.uint32(90).fork(); + for (const v of message.weakDependency) { + writer.int32(v); + } + writer.ldelim(); + for (const v of message.messageType) { + DescriptorProto.encode(v!, writer.uint32(34).fork()).ldelim(); + } + for (const v of message.enumType) { + EnumDescriptorProto.encode(v!, writer.uint32(42).fork()).ldelim(); + } + for (const v of message.service) { + ServiceDescriptorProto.encode(v!, writer.uint32(50).fork()).ldelim(); + } + for (const v of message.extension) { + FieldDescriptorProto.encode(v!, writer.uint32(58).fork()).ldelim(); + } + if (message.options !== undefined) { + FileOptions.encode(message.options, writer.uint32(66).fork()).ldelim(); + } + if (message.sourceCodeInfo !== undefined) { + SourceCodeInfo.encode( + message.sourceCodeInfo, + writer.uint32(74).fork() + ).ldelim(); + } + if (message.syntax !== "") { + writer.uint32(98).string(message.syntax); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FileDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFileDescriptorProto } as FileDescriptorProto; + message.dependency = []; + message.publicDependency = []; + message.weakDependency = []; + message.messageType = []; + message.enumType = []; + message.service = []; + message.extension = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.package = reader.string(); + break; + case 3: + message.dependency.push(reader.string()); + break; + case 10: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.publicDependency.push(reader.int32()); + } + } else { + message.publicDependency.push(reader.int32()); + } + break; + case 11: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.weakDependency.push(reader.int32()); + } + } else { + message.weakDependency.push(reader.int32()); + } + break; + case 4: + message.messageType.push( + DescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 5: + message.enumType.push( + EnumDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 6: + message.service.push( + ServiceDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 7: + message.extension.push( + FieldDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 8: + message.options = FileOptions.decode(reader, reader.uint32()); + break; + case 9: + message.sourceCodeInfo = SourceCodeInfo.decode( + reader, + reader.uint32() + ); + break; + case 12: + message.syntax = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FileDescriptorProto { + const message = { ...baseFileDescriptorProto } as FileDescriptorProto; + message.dependency = []; + message.publicDependency = []; + message.weakDependency = []; + message.messageType = []; + message.enumType = []; + message.service = []; + message.extension = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.package !== undefined && object.package !== null) { + message.package = String(object.package); + } else { + message.package = ""; + } + if (object.dependency !== undefined && object.dependency !== null) { + for (const e of object.dependency) { + message.dependency.push(String(e)); + } + } + if ( + object.publicDependency !== undefined && + object.publicDependency !== null + ) { + for (const e of object.publicDependency) { + message.publicDependency.push(Number(e)); + } + } + if (object.weakDependency !== undefined && object.weakDependency !== null) { + for (const e of object.weakDependency) { + message.weakDependency.push(Number(e)); + } + } + if (object.messageType !== undefined && object.messageType !== null) { + for (const e of object.messageType) { + message.messageType.push(DescriptorProto.fromJSON(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromJSON(e)); + } + } + if (object.service !== undefined && object.service !== null) { + for (const e of object.service) { + message.service.push(ServiceDescriptorProto.fromJSON(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = FileOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.sourceCodeInfo !== undefined && object.sourceCodeInfo !== null) { + message.sourceCodeInfo = SourceCodeInfo.fromJSON(object.sourceCodeInfo); + } else { + message.sourceCodeInfo = undefined; + } + if (object.syntax !== undefined && object.syntax !== null) { + message.syntax = String(object.syntax); + } else { + message.syntax = ""; + } + return message; + }, + + toJSON(message: FileDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.package !== undefined && (obj.package = message.package); + if (message.dependency) { + obj.dependency = message.dependency.map((e) => e); + } else { + obj.dependency = []; + } + if (message.publicDependency) { + obj.publicDependency = message.publicDependency.map((e) => e); + } else { + obj.publicDependency = []; + } + if (message.weakDependency) { + obj.weakDependency = message.weakDependency.map((e) => e); + } else { + obj.weakDependency = []; + } + if (message.messageType) { + obj.messageType = message.messageType.map((e) => + e ? DescriptorProto.toJSON(e) : undefined + ); + } else { + obj.messageType = []; + } + if (message.enumType) { + obj.enumType = message.enumType.map((e) => + e ? EnumDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.enumType = []; + } + if (message.service) { + obj.service = message.service.map((e) => + e ? ServiceDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.service = []; + } + if (message.extension) { + obj.extension = message.extension.map((e) => + e ? FieldDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.extension = []; + } + message.options !== undefined && + (obj.options = message.options + ? FileOptions.toJSON(message.options) + : undefined); + message.sourceCodeInfo !== undefined && + (obj.sourceCodeInfo = message.sourceCodeInfo + ? SourceCodeInfo.toJSON(message.sourceCodeInfo) + : undefined); + message.syntax !== undefined && (obj.syntax = message.syntax); + return obj; + }, + + fromPartial(object: DeepPartial): FileDescriptorProto { + const message = { ...baseFileDescriptorProto } as FileDescriptorProto; + message.dependency = []; + message.publicDependency = []; + message.weakDependency = []; + message.messageType = []; + message.enumType = []; + message.service = []; + message.extension = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.package !== undefined && object.package !== null) { + message.package = object.package; + } else { + message.package = ""; + } + if (object.dependency !== undefined && object.dependency !== null) { + for (const e of object.dependency) { + message.dependency.push(e); + } + } + if ( + object.publicDependency !== undefined && + object.publicDependency !== null + ) { + for (const e of object.publicDependency) { + message.publicDependency.push(e); + } + } + if (object.weakDependency !== undefined && object.weakDependency !== null) { + for (const e of object.weakDependency) { + message.weakDependency.push(e); + } + } + if (object.messageType !== undefined && object.messageType !== null) { + for (const e of object.messageType) { + message.messageType.push(DescriptorProto.fromPartial(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromPartial(e)); + } + } + if (object.service !== undefined && object.service !== null) { + for (const e of object.service) { + message.service.push(ServiceDescriptorProto.fromPartial(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = FileOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.sourceCodeInfo !== undefined && object.sourceCodeInfo !== null) { + message.sourceCodeInfo = SourceCodeInfo.fromPartial( + object.sourceCodeInfo + ); + } else { + message.sourceCodeInfo = undefined; + } + if (object.syntax !== undefined && object.syntax !== null) { + message.syntax = object.syntax; + } else { + message.syntax = ""; + } + return message; + }, +}; + +const baseDescriptorProto: object = { name: "", reservedName: "" }; + +export const DescriptorProto = { + encode(message: DescriptorProto, writer: Writer = Writer.create()): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + for (const v of message.field) { + FieldDescriptorProto.encode(v!, writer.uint32(18).fork()).ldelim(); + } + for (const v of message.extension) { + FieldDescriptorProto.encode(v!, writer.uint32(50).fork()).ldelim(); + } + for (const v of message.nestedType) { + DescriptorProto.encode(v!, writer.uint32(26).fork()).ldelim(); + } + for (const v of message.enumType) { + EnumDescriptorProto.encode(v!, writer.uint32(34).fork()).ldelim(); + } + for (const v of message.extensionRange) { + DescriptorProto_ExtensionRange.encode( + v!, + writer.uint32(42).fork() + ).ldelim(); + } + for (const v of message.oneofDecl) { + OneofDescriptorProto.encode(v!, writer.uint32(66).fork()).ldelim(); + } + if (message.options !== undefined) { + MessageOptions.encode(message.options, writer.uint32(58).fork()).ldelim(); + } + for (const v of message.reservedRange) { + DescriptorProto_ReservedRange.encode( + v!, + writer.uint32(74).fork() + ).ldelim(); + } + for (const v of message.reservedName) { + writer.uint32(82).string(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): DescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseDescriptorProto } as DescriptorProto; + message.field = []; + message.extension = []; + message.nestedType = []; + message.enumType = []; + message.extensionRange = []; + message.oneofDecl = []; + message.reservedRange = []; + message.reservedName = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.field.push( + FieldDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 6: + message.extension.push( + FieldDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 3: + message.nestedType.push( + DescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 4: + message.enumType.push( + EnumDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 5: + message.extensionRange.push( + DescriptorProto_ExtensionRange.decode(reader, reader.uint32()) + ); + break; + case 8: + message.oneofDecl.push( + OneofDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 7: + message.options = MessageOptions.decode(reader, reader.uint32()); + break; + case 9: + message.reservedRange.push( + DescriptorProto_ReservedRange.decode(reader, reader.uint32()) + ); + break; + case 10: + message.reservedName.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DescriptorProto { + const message = { ...baseDescriptorProto } as DescriptorProto; + message.field = []; + message.extension = []; + message.nestedType = []; + message.enumType = []; + message.extensionRange = []; + message.oneofDecl = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.field !== undefined && object.field !== null) { + for (const e of object.field) { + message.field.push(FieldDescriptorProto.fromJSON(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromJSON(e)); + } + } + if (object.nestedType !== undefined && object.nestedType !== null) { + for (const e of object.nestedType) { + message.nestedType.push(DescriptorProto.fromJSON(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromJSON(e)); + } + } + if (object.extensionRange !== undefined && object.extensionRange !== null) { + for (const e of object.extensionRange) { + message.extensionRange.push(DescriptorProto_ExtensionRange.fromJSON(e)); + } + } + if (object.oneofDecl !== undefined && object.oneofDecl !== null) { + for (const e of object.oneofDecl) { + message.oneofDecl.push(OneofDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = MessageOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push(DescriptorProto_ReservedRange.fromJSON(e)); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(String(e)); + } + } + return message; + }, + + toJSON(message: DescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + if (message.field) { + obj.field = message.field.map((e) => + e ? FieldDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.field = []; + } + if (message.extension) { + obj.extension = message.extension.map((e) => + e ? FieldDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.extension = []; + } + if (message.nestedType) { + obj.nestedType = message.nestedType.map((e) => + e ? DescriptorProto.toJSON(e) : undefined + ); + } else { + obj.nestedType = []; + } + if (message.enumType) { + obj.enumType = message.enumType.map((e) => + e ? EnumDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.enumType = []; + } + if (message.extensionRange) { + obj.extensionRange = message.extensionRange.map((e) => + e ? DescriptorProto_ExtensionRange.toJSON(e) : undefined + ); + } else { + obj.extensionRange = []; + } + if (message.oneofDecl) { + obj.oneofDecl = message.oneofDecl.map((e) => + e ? OneofDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.oneofDecl = []; + } + message.options !== undefined && + (obj.options = message.options + ? MessageOptions.toJSON(message.options) + : undefined); + if (message.reservedRange) { + obj.reservedRange = message.reservedRange.map((e) => + e ? DescriptorProto_ReservedRange.toJSON(e) : undefined + ); + } else { + obj.reservedRange = []; + } + if (message.reservedName) { + obj.reservedName = message.reservedName.map((e) => e); + } else { + obj.reservedName = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): DescriptorProto { + const message = { ...baseDescriptorProto } as DescriptorProto; + message.field = []; + message.extension = []; + message.nestedType = []; + message.enumType = []; + message.extensionRange = []; + message.oneofDecl = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.field !== undefined && object.field !== null) { + for (const e of object.field) { + message.field.push(FieldDescriptorProto.fromPartial(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromPartial(e)); + } + } + if (object.nestedType !== undefined && object.nestedType !== null) { + for (const e of object.nestedType) { + message.nestedType.push(DescriptorProto.fromPartial(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromPartial(e)); + } + } + if (object.extensionRange !== undefined && object.extensionRange !== null) { + for (const e of object.extensionRange) { + message.extensionRange.push( + DescriptorProto_ExtensionRange.fromPartial(e) + ); + } + } + if (object.oneofDecl !== undefined && object.oneofDecl !== null) { + for (const e of object.oneofDecl) { + message.oneofDecl.push(OneofDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = MessageOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push( + DescriptorProto_ReservedRange.fromPartial(e) + ); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(e); + } + } + return message; + }, +}; + +const baseDescriptorProto_ExtensionRange: object = { start: 0, end: 0 }; + +export const DescriptorProto_ExtensionRange = { + encode( + message: DescriptorProto_ExtensionRange, + writer: Writer = Writer.create() + ): Writer { + if (message.start !== 0) { + writer.uint32(8).int32(message.start); + } + if (message.end !== 0) { + writer.uint32(16).int32(message.end); + } + if (message.options !== undefined) { + ExtensionRangeOptions.encode( + message.options, + writer.uint32(26).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): DescriptorProto_ExtensionRange { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseDescriptorProto_ExtensionRange, + } as DescriptorProto_ExtensionRange; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.start = reader.int32(); + break; + case 2: + message.end = reader.int32(); + break; + case 3: + message.options = ExtensionRangeOptions.decode( + reader, + reader.uint32() + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DescriptorProto_ExtensionRange { + const message = { + ...baseDescriptorProto_ExtensionRange, + } as DescriptorProto_ExtensionRange; + if (object.start !== undefined && object.start !== null) { + message.start = Number(object.start); + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = ExtensionRangeOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: DescriptorProto_ExtensionRange): unknown { + const obj: any = {}; + message.start !== undefined && (obj.start = message.start); + message.end !== undefined && (obj.end = message.end); + message.options !== undefined && + (obj.options = message.options + ? ExtensionRangeOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): DescriptorProto_ExtensionRange { + const message = { + ...baseDescriptorProto_ExtensionRange, + } as DescriptorProto_ExtensionRange; + if (object.start !== undefined && object.start !== null) { + message.start = object.start; + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = ExtensionRangeOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseDescriptorProto_ReservedRange: object = { start: 0, end: 0 }; + +export const DescriptorProto_ReservedRange = { + encode( + message: DescriptorProto_ReservedRange, + writer: Writer = Writer.create() + ): Writer { + if (message.start !== 0) { + writer.uint32(8).int32(message.start); + } + if (message.end !== 0) { + writer.uint32(16).int32(message.end); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): DescriptorProto_ReservedRange { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseDescriptorProto_ReservedRange, + } as DescriptorProto_ReservedRange; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.start = reader.int32(); + break; + case 2: + message.end = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DescriptorProto_ReservedRange { + const message = { + ...baseDescriptorProto_ReservedRange, + } as DescriptorProto_ReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = Number(object.start); + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + return message; + }, + + toJSON(message: DescriptorProto_ReservedRange): unknown { + const obj: any = {}; + message.start !== undefined && (obj.start = message.start); + message.end !== undefined && (obj.end = message.end); + return obj; + }, + + fromPartial( + object: DeepPartial + ): DescriptorProto_ReservedRange { + const message = { + ...baseDescriptorProto_ReservedRange, + } as DescriptorProto_ReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = object.start; + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + return message; + }, +}; + +const baseExtensionRangeOptions: object = {}; + +export const ExtensionRangeOptions = { + encode( + message: ExtensionRangeOptions, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ExtensionRangeOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseExtensionRangeOptions } as ExtensionRangeOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ExtensionRangeOptions { + const message = { ...baseExtensionRangeOptions } as ExtensionRangeOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: ExtensionRangeOptions): unknown { + const obj: any = {}; + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial( + object: DeepPartial + ): ExtensionRangeOptions { + const message = { ...baseExtensionRangeOptions } as ExtensionRangeOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseFieldDescriptorProto: object = { + name: "", + number: 0, + label: 1, + type: 1, + typeName: "", + extendee: "", + defaultValue: "", + oneofIndex: 0, + jsonName: "", + proto3Optional: false, +}; + +export const FieldDescriptorProto = { + encode( + message: FieldDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.number !== 0) { + writer.uint32(24).int32(message.number); + } + if (message.label !== 1) { + writer.uint32(32).int32(message.label); + } + if (message.type !== 1) { + writer.uint32(40).int32(message.type); + } + if (message.typeName !== "") { + writer.uint32(50).string(message.typeName); + } + if (message.extendee !== "") { + writer.uint32(18).string(message.extendee); + } + if (message.defaultValue !== "") { + writer.uint32(58).string(message.defaultValue); + } + if (message.oneofIndex !== 0) { + writer.uint32(72).int32(message.oneofIndex); + } + if (message.jsonName !== "") { + writer.uint32(82).string(message.jsonName); + } + if (message.options !== undefined) { + FieldOptions.encode(message.options, writer.uint32(66).fork()).ldelim(); + } + if (message.proto3Optional === true) { + writer.uint32(136).bool(message.proto3Optional); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FieldDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFieldDescriptorProto } as FieldDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 3: + message.number = reader.int32(); + break; + case 4: + message.label = reader.int32() as any; + break; + case 5: + message.type = reader.int32() as any; + break; + case 6: + message.typeName = reader.string(); + break; + case 2: + message.extendee = reader.string(); + break; + case 7: + message.defaultValue = reader.string(); + break; + case 9: + message.oneofIndex = reader.int32(); + break; + case 10: + message.jsonName = reader.string(); + break; + case 8: + message.options = FieldOptions.decode(reader, reader.uint32()); + break; + case 17: + message.proto3Optional = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FieldDescriptorProto { + const message = { ...baseFieldDescriptorProto } as FieldDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = Number(object.number); + } else { + message.number = 0; + } + if (object.label !== undefined && object.label !== null) { + message.label = fieldDescriptorProto_LabelFromJSON(object.label); + } else { + message.label = 1; + } + if (object.type !== undefined && object.type !== null) { + message.type = fieldDescriptorProto_TypeFromJSON(object.type); + } else { + message.type = 1; + } + if (object.typeName !== undefined && object.typeName !== null) { + message.typeName = String(object.typeName); + } else { + message.typeName = ""; + } + if (object.extendee !== undefined && object.extendee !== null) { + message.extendee = String(object.extendee); + } else { + message.extendee = ""; + } + if (object.defaultValue !== undefined && object.defaultValue !== null) { + message.defaultValue = String(object.defaultValue); + } else { + message.defaultValue = ""; + } + if (object.oneofIndex !== undefined && object.oneofIndex !== null) { + message.oneofIndex = Number(object.oneofIndex); + } else { + message.oneofIndex = 0; + } + if (object.jsonName !== undefined && object.jsonName !== null) { + message.jsonName = String(object.jsonName); + } else { + message.jsonName = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = FieldOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.proto3Optional !== undefined && object.proto3Optional !== null) { + message.proto3Optional = Boolean(object.proto3Optional); + } else { + message.proto3Optional = false; + } + return message; + }, + + toJSON(message: FieldDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.number !== undefined && (obj.number = message.number); + message.label !== undefined && + (obj.label = fieldDescriptorProto_LabelToJSON(message.label)); + message.type !== undefined && + (obj.type = fieldDescriptorProto_TypeToJSON(message.type)); + message.typeName !== undefined && (obj.typeName = message.typeName); + message.extendee !== undefined && (obj.extendee = message.extendee); + message.defaultValue !== undefined && + (obj.defaultValue = message.defaultValue); + message.oneofIndex !== undefined && (obj.oneofIndex = message.oneofIndex); + message.jsonName !== undefined && (obj.jsonName = message.jsonName); + message.options !== undefined && + (obj.options = message.options + ? FieldOptions.toJSON(message.options) + : undefined); + message.proto3Optional !== undefined && + (obj.proto3Optional = message.proto3Optional); + return obj; + }, + + fromPartial(object: DeepPartial): FieldDescriptorProto { + const message = { ...baseFieldDescriptorProto } as FieldDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = object.number; + } else { + message.number = 0; + } + if (object.label !== undefined && object.label !== null) { + message.label = object.label; + } else { + message.label = 1; + } + if (object.type !== undefined && object.type !== null) { + message.type = object.type; + } else { + message.type = 1; + } + if (object.typeName !== undefined && object.typeName !== null) { + message.typeName = object.typeName; + } else { + message.typeName = ""; + } + if (object.extendee !== undefined && object.extendee !== null) { + message.extendee = object.extendee; + } else { + message.extendee = ""; + } + if (object.defaultValue !== undefined && object.defaultValue !== null) { + message.defaultValue = object.defaultValue; + } else { + message.defaultValue = ""; + } + if (object.oneofIndex !== undefined && object.oneofIndex !== null) { + message.oneofIndex = object.oneofIndex; + } else { + message.oneofIndex = 0; + } + if (object.jsonName !== undefined && object.jsonName !== null) { + message.jsonName = object.jsonName; + } else { + message.jsonName = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = FieldOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.proto3Optional !== undefined && object.proto3Optional !== null) { + message.proto3Optional = object.proto3Optional; + } else { + message.proto3Optional = false; + } + return message; + }, +}; + +const baseOneofDescriptorProto: object = { name: "" }; + +export const OneofDescriptorProto = { + encode( + message: OneofDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.options !== undefined) { + OneofOptions.encode(message.options, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): OneofDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseOneofDescriptorProto } as OneofDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.options = OneofOptions.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): OneofDescriptorProto { + const message = { ...baseOneofDescriptorProto } as OneofDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = OneofOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: OneofDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.options !== undefined && + (obj.options = message.options + ? OneofOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): OneofDescriptorProto { + const message = { ...baseOneofDescriptorProto } as OneofDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = OneofOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseEnumDescriptorProto: object = { name: "", reservedName: "" }; + +export const EnumDescriptorProto = { + encode( + message: EnumDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + for (const v of message.value) { + EnumValueDescriptorProto.encode(v!, writer.uint32(18).fork()).ldelim(); + } + if (message.options !== undefined) { + EnumOptions.encode(message.options, writer.uint32(26).fork()).ldelim(); + } + for (const v of message.reservedRange) { + EnumDescriptorProto_EnumReservedRange.encode( + v!, + writer.uint32(34).fork() + ).ldelim(); + } + for (const v of message.reservedName) { + writer.uint32(42).string(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): EnumDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseEnumDescriptorProto } as EnumDescriptorProto; + message.value = []; + message.reservedRange = []; + message.reservedName = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.value.push( + EnumValueDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 3: + message.options = EnumOptions.decode(reader, reader.uint32()); + break; + case 4: + message.reservedRange.push( + EnumDescriptorProto_EnumReservedRange.decode( + reader, + reader.uint32() + ) + ); + break; + case 5: + message.reservedName.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumDescriptorProto { + const message = { ...baseEnumDescriptorProto } as EnumDescriptorProto; + message.value = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.value !== undefined && object.value !== null) { + for (const e of object.value) { + message.value.push(EnumValueDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push( + EnumDescriptorProto_EnumReservedRange.fromJSON(e) + ); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(String(e)); + } + } + return message; + }, + + toJSON(message: EnumDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + if (message.value) { + obj.value = message.value.map((e) => + e ? EnumValueDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.value = []; + } + message.options !== undefined && + (obj.options = message.options + ? EnumOptions.toJSON(message.options) + : undefined); + if (message.reservedRange) { + obj.reservedRange = message.reservedRange.map((e) => + e ? EnumDescriptorProto_EnumReservedRange.toJSON(e) : undefined + ); + } else { + obj.reservedRange = []; + } + if (message.reservedName) { + obj.reservedName = message.reservedName.map((e) => e); + } else { + obj.reservedName = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): EnumDescriptorProto { + const message = { ...baseEnumDescriptorProto } as EnumDescriptorProto; + message.value = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.value !== undefined && object.value !== null) { + for (const e of object.value) { + message.value.push(EnumValueDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push( + EnumDescriptorProto_EnumReservedRange.fromPartial(e) + ); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(e); + } + } + return message; + }, +}; + +const baseEnumDescriptorProto_EnumReservedRange: object = { start: 0, end: 0 }; + +export const EnumDescriptorProto_EnumReservedRange = { + encode( + message: EnumDescriptorProto_EnumReservedRange, + writer: Writer = Writer.create() + ): Writer { + if (message.start !== 0) { + writer.uint32(8).int32(message.start); + } + if (message.end !== 0) { + writer.uint32(16).int32(message.end); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): EnumDescriptorProto_EnumReservedRange { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseEnumDescriptorProto_EnumReservedRange, + } as EnumDescriptorProto_EnumReservedRange; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.start = reader.int32(); + break; + case 2: + message.end = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumDescriptorProto_EnumReservedRange { + const message = { + ...baseEnumDescriptorProto_EnumReservedRange, + } as EnumDescriptorProto_EnumReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = Number(object.start); + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + return message; + }, + + toJSON(message: EnumDescriptorProto_EnumReservedRange): unknown { + const obj: any = {}; + message.start !== undefined && (obj.start = message.start); + message.end !== undefined && (obj.end = message.end); + return obj; + }, + + fromPartial( + object: DeepPartial + ): EnumDescriptorProto_EnumReservedRange { + const message = { + ...baseEnumDescriptorProto_EnumReservedRange, + } as EnumDescriptorProto_EnumReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = object.start; + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + return message; + }, +}; + +const baseEnumValueDescriptorProto: object = { name: "", number: 0 }; + +export const EnumValueDescriptorProto = { + encode( + message: EnumValueDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.number !== 0) { + writer.uint32(16).int32(message.number); + } + if (message.options !== undefined) { + EnumValueOptions.encode( + message.options, + writer.uint32(26).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): EnumValueDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseEnumValueDescriptorProto, + } as EnumValueDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.number = reader.int32(); + break; + case 3: + message.options = EnumValueOptions.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumValueDescriptorProto { + const message = { + ...baseEnumValueDescriptorProto, + } as EnumValueDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = Number(object.number); + } else { + message.number = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumValueOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: EnumValueDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.number !== undefined && (obj.number = message.number); + message.options !== undefined && + (obj.options = message.options + ? EnumValueOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): EnumValueDescriptorProto { + const message = { + ...baseEnumValueDescriptorProto, + } as EnumValueDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = object.number; + } else { + message.number = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumValueOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseServiceDescriptorProto: object = { name: "" }; + +export const ServiceDescriptorProto = { + encode( + message: ServiceDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + for (const v of message.method) { + MethodDescriptorProto.encode(v!, writer.uint32(18).fork()).ldelim(); + } + if (message.options !== undefined) { + ServiceOptions.encode(message.options, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ServiceDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseServiceDescriptorProto } as ServiceDescriptorProto; + message.method = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.method.push( + MethodDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 3: + message.options = ServiceOptions.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ServiceDescriptorProto { + const message = { ...baseServiceDescriptorProto } as ServiceDescriptorProto; + message.method = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.method !== undefined && object.method !== null) { + for (const e of object.method) { + message.method.push(MethodDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = ServiceOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: ServiceDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + if (message.method) { + obj.method = message.method.map((e) => + e ? MethodDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.method = []; + } + message.options !== undefined && + (obj.options = message.options + ? ServiceOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): ServiceDescriptorProto { + const message = { ...baseServiceDescriptorProto } as ServiceDescriptorProto; + message.method = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.method !== undefined && object.method !== null) { + for (const e of object.method) { + message.method.push(MethodDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = ServiceOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseMethodDescriptorProto: object = { + name: "", + inputType: "", + outputType: "", + clientStreaming: false, + serverStreaming: false, +}; + +export const MethodDescriptorProto = { + encode( + message: MethodDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.inputType !== "") { + writer.uint32(18).string(message.inputType); + } + if (message.outputType !== "") { + writer.uint32(26).string(message.outputType); + } + if (message.options !== undefined) { + MethodOptions.encode(message.options, writer.uint32(34).fork()).ldelim(); + } + if (message.clientStreaming === true) { + writer.uint32(40).bool(message.clientStreaming); + } + if (message.serverStreaming === true) { + writer.uint32(48).bool(message.serverStreaming); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MethodDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMethodDescriptorProto } as MethodDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.inputType = reader.string(); + break; + case 3: + message.outputType = reader.string(); + break; + case 4: + message.options = MethodOptions.decode(reader, reader.uint32()); + break; + case 5: + message.clientStreaming = reader.bool(); + break; + case 6: + message.serverStreaming = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MethodDescriptorProto { + const message = { ...baseMethodDescriptorProto } as MethodDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.inputType !== undefined && object.inputType !== null) { + message.inputType = String(object.inputType); + } else { + message.inputType = ""; + } + if (object.outputType !== undefined && object.outputType !== null) { + message.outputType = String(object.outputType); + } else { + message.outputType = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = MethodOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if ( + object.clientStreaming !== undefined && + object.clientStreaming !== null + ) { + message.clientStreaming = Boolean(object.clientStreaming); + } else { + message.clientStreaming = false; + } + if ( + object.serverStreaming !== undefined && + object.serverStreaming !== null + ) { + message.serverStreaming = Boolean(object.serverStreaming); + } else { + message.serverStreaming = false; + } + return message; + }, + + toJSON(message: MethodDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.inputType !== undefined && (obj.inputType = message.inputType); + message.outputType !== undefined && (obj.outputType = message.outputType); + message.options !== undefined && + (obj.options = message.options + ? MethodOptions.toJSON(message.options) + : undefined); + message.clientStreaming !== undefined && + (obj.clientStreaming = message.clientStreaming); + message.serverStreaming !== undefined && + (obj.serverStreaming = message.serverStreaming); + return obj; + }, + + fromPartial( + object: DeepPartial + ): MethodDescriptorProto { + const message = { ...baseMethodDescriptorProto } as MethodDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.inputType !== undefined && object.inputType !== null) { + message.inputType = object.inputType; + } else { + message.inputType = ""; + } + if (object.outputType !== undefined && object.outputType !== null) { + message.outputType = object.outputType; + } else { + message.outputType = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = MethodOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if ( + object.clientStreaming !== undefined && + object.clientStreaming !== null + ) { + message.clientStreaming = object.clientStreaming; + } else { + message.clientStreaming = false; + } + if ( + object.serverStreaming !== undefined && + object.serverStreaming !== null + ) { + message.serverStreaming = object.serverStreaming; + } else { + message.serverStreaming = false; + } + return message; + }, +}; + +const baseFileOptions: object = { + javaPackage: "", + javaOuterClassname: "", + javaMultipleFiles: false, + javaGenerateEqualsAndHash: false, + javaStringCheckUtf8: false, + optimizeFor: 1, + goPackage: "", + ccGenericServices: false, + javaGenericServices: false, + pyGenericServices: false, + phpGenericServices: false, + deprecated: false, + ccEnableArenas: false, + objcClassPrefix: "", + csharpNamespace: "", + swiftPrefix: "", + phpClassPrefix: "", + phpNamespace: "", + phpMetadataNamespace: "", + rubyPackage: "", +}; + +export const FileOptions = { + encode(message: FileOptions, writer: Writer = Writer.create()): Writer { + if (message.javaPackage !== "") { + writer.uint32(10).string(message.javaPackage); + } + if (message.javaOuterClassname !== "") { + writer.uint32(66).string(message.javaOuterClassname); + } + if (message.javaMultipleFiles === true) { + writer.uint32(80).bool(message.javaMultipleFiles); + } + if (message.javaGenerateEqualsAndHash === true) { + writer.uint32(160).bool(message.javaGenerateEqualsAndHash); + } + if (message.javaStringCheckUtf8 === true) { + writer.uint32(216).bool(message.javaStringCheckUtf8); + } + if (message.optimizeFor !== 1) { + writer.uint32(72).int32(message.optimizeFor); + } + if (message.goPackage !== "") { + writer.uint32(90).string(message.goPackage); + } + if (message.ccGenericServices === true) { + writer.uint32(128).bool(message.ccGenericServices); + } + if (message.javaGenericServices === true) { + writer.uint32(136).bool(message.javaGenericServices); + } + if (message.pyGenericServices === true) { + writer.uint32(144).bool(message.pyGenericServices); + } + if (message.phpGenericServices === true) { + writer.uint32(336).bool(message.phpGenericServices); + } + if (message.deprecated === true) { + writer.uint32(184).bool(message.deprecated); + } + if (message.ccEnableArenas === true) { + writer.uint32(248).bool(message.ccEnableArenas); + } + if (message.objcClassPrefix !== "") { + writer.uint32(290).string(message.objcClassPrefix); + } + if (message.csharpNamespace !== "") { + writer.uint32(298).string(message.csharpNamespace); + } + if (message.swiftPrefix !== "") { + writer.uint32(314).string(message.swiftPrefix); + } + if (message.phpClassPrefix !== "") { + writer.uint32(322).string(message.phpClassPrefix); + } + if (message.phpNamespace !== "") { + writer.uint32(330).string(message.phpNamespace); + } + if (message.phpMetadataNamespace !== "") { + writer.uint32(354).string(message.phpMetadataNamespace); + } + if (message.rubyPackage !== "") { + writer.uint32(362).string(message.rubyPackage); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FileOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFileOptions } as FileOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.javaPackage = reader.string(); + break; + case 8: + message.javaOuterClassname = reader.string(); + break; + case 10: + message.javaMultipleFiles = reader.bool(); + break; + case 20: + message.javaGenerateEqualsAndHash = reader.bool(); + break; + case 27: + message.javaStringCheckUtf8 = reader.bool(); + break; + case 9: + message.optimizeFor = reader.int32() as any; + break; + case 11: + message.goPackage = reader.string(); + break; + case 16: + message.ccGenericServices = reader.bool(); + break; + case 17: + message.javaGenericServices = reader.bool(); + break; + case 18: + message.pyGenericServices = reader.bool(); + break; + case 42: + message.phpGenericServices = reader.bool(); + break; + case 23: + message.deprecated = reader.bool(); + break; + case 31: + message.ccEnableArenas = reader.bool(); + break; + case 36: + message.objcClassPrefix = reader.string(); + break; + case 37: + message.csharpNamespace = reader.string(); + break; + case 39: + message.swiftPrefix = reader.string(); + break; + case 40: + message.phpClassPrefix = reader.string(); + break; + case 41: + message.phpNamespace = reader.string(); + break; + case 44: + message.phpMetadataNamespace = reader.string(); + break; + case 45: + message.rubyPackage = reader.string(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FileOptions { + const message = { ...baseFileOptions } as FileOptions; + message.uninterpretedOption = []; + if (object.javaPackage !== undefined && object.javaPackage !== null) { + message.javaPackage = String(object.javaPackage); + } else { + message.javaPackage = ""; + } + if ( + object.javaOuterClassname !== undefined && + object.javaOuterClassname !== null + ) { + message.javaOuterClassname = String(object.javaOuterClassname); + } else { + message.javaOuterClassname = ""; + } + if ( + object.javaMultipleFiles !== undefined && + object.javaMultipleFiles !== null + ) { + message.javaMultipleFiles = Boolean(object.javaMultipleFiles); + } else { + message.javaMultipleFiles = false; + } + if ( + object.javaGenerateEqualsAndHash !== undefined && + object.javaGenerateEqualsAndHash !== null + ) { + message.javaGenerateEqualsAndHash = Boolean( + object.javaGenerateEqualsAndHash + ); + } else { + message.javaGenerateEqualsAndHash = false; + } + if ( + object.javaStringCheckUtf8 !== undefined && + object.javaStringCheckUtf8 !== null + ) { + message.javaStringCheckUtf8 = Boolean(object.javaStringCheckUtf8); + } else { + message.javaStringCheckUtf8 = false; + } + if (object.optimizeFor !== undefined && object.optimizeFor !== null) { + message.optimizeFor = fileOptions_OptimizeModeFromJSON( + object.optimizeFor + ); + } else { + message.optimizeFor = 1; + } + if (object.goPackage !== undefined && object.goPackage !== null) { + message.goPackage = String(object.goPackage); + } else { + message.goPackage = ""; + } + if ( + object.ccGenericServices !== undefined && + object.ccGenericServices !== null + ) { + message.ccGenericServices = Boolean(object.ccGenericServices); + } else { + message.ccGenericServices = false; + } + if ( + object.javaGenericServices !== undefined && + object.javaGenericServices !== null + ) { + message.javaGenericServices = Boolean(object.javaGenericServices); + } else { + message.javaGenericServices = false; + } + if ( + object.pyGenericServices !== undefined && + object.pyGenericServices !== null + ) { + message.pyGenericServices = Boolean(object.pyGenericServices); + } else { + message.pyGenericServices = false; + } + if ( + object.phpGenericServices !== undefined && + object.phpGenericServices !== null + ) { + message.phpGenericServices = Boolean(object.phpGenericServices); + } else { + message.phpGenericServices = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if (object.ccEnableArenas !== undefined && object.ccEnableArenas !== null) { + message.ccEnableArenas = Boolean(object.ccEnableArenas); + } else { + message.ccEnableArenas = false; + } + if ( + object.objcClassPrefix !== undefined && + object.objcClassPrefix !== null + ) { + message.objcClassPrefix = String(object.objcClassPrefix); + } else { + message.objcClassPrefix = ""; + } + if ( + object.csharpNamespace !== undefined && + object.csharpNamespace !== null + ) { + message.csharpNamespace = String(object.csharpNamespace); + } else { + message.csharpNamespace = ""; + } + if (object.swiftPrefix !== undefined && object.swiftPrefix !== null) { + message.swiftPrefix = String(object.swiftPrefix); + } else { + message.swiftPrefix = ""; + } + if (object.phpClassPrefix !== undefined && object.phpClassPrefix !== null) { + message.phpClassPrefix = String(object.phpClassPrefix); + } else { + message.phpClassPrefix = ""; + } + if (object.phpNamespace !== undefined && object.phpNamespace !== null) { + message.phpNamespace = String(object.phpNamespace); + } else { + message.phpNamespace = ""; + } + if ( + object.phpMetadataNamespace !== undefined && + object.phpMetadataNamespace !== null + ) { + message.phpMetadataNamespace = String(object.phpMetadataNamespace); + } else { + message.phpMetadataNamespace = ""; + } + if (object.rubyPackage !== undefined && object.rubyPackage !== null) { + message.rubyPackage = String(object.rubyPackage); + } else { + message.rubyPackage = ""; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: FileOptions): unknown { + const obj: any = {}; + message.javaPackage !== undefined && + (obj.javaPackage = message.javaPackage); + message.javaOuterClassname !== undefined && + (obj.javaOuterClassname = message.javaOuterClassname); + message.javaMultipleFiles !== undefined && + (obj.javaMultipleFiles = message.javaMultipleFiles); + message.javaGenerateEqualsAndHash !== undefined && + (obj.javaGenerateEqualsAndHash = message.javaGenerateEqualsAndHash); + message.javaStringCheckUtf8 !== undefined && + (obj.javaStringCheckUtf8 = message.javaStringCheckUtf8); + message.optimizeFor !== undefined && + (obj.optimizeFor = fileOptions_OptimizeModeToJSON(message.optimizeFor)); + message.goPackage !== undefined && (obj.goPackage = message.goPackage); + message.ccGenericServices !== undefined && + (obj.ccGenericServices = message.ccGenericServices); + message.javaGenericServices !== undefined && + (obj.javaGenericServices = message.javaGenericServices); + message.pyGenericServices !== undefined && + (obj.pyGenericServices = message.pyGenericServices); + message.phpGenericServices !== undefined && + (obj.phpGenericServices = message.phpGenericServices); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.ccEnableArenas !== undefined && + (obj.ccEnableArenas = message.ccEnableArenas); + message.objcClassPrefix !== undefined && + (obj.objcClassPrefix = message.objcClassPrefix); + message.csharpNamespace !== undefined && + (obj.csharpNamespace = message.csharpNamespace); + message.swiftPrefix !== undefined && + (obj.swiftPrefix = message.swiftPrefix); + message.phpClassPrefix !== undefined && + (obj.phpClassPrefix = message.phpClassPrefix); + message.phpNamespace !== undefined && + (obj.phpNamespace = message.phpNamespace); + message.phpMetadataNamespace !== undefined && + (obj.phpMetadataNamespace = message.phpMetadataNamespace); + message.rubyPackage !== undefined && + (obj.rubyPackage = message.rubyPackage); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): FileOptions { + const message = { ...baseFileOptions } as FileOptions; + message.uninterpretedOption = []; + if (object.javaPackage !== undefined && object.javaPackage !== null) { + message.javaPackage = object.javaPackage; + } else { + message.javaPackage = ""; + } + if ( + object.javaOuterClassname !== undefined && + object.javaOuterClassname !== null + ) { + message.javaOuterClassname = object.javaOuterClassname; + } else { + message.javaOuterClassname = ""; + } + if ( + object.javaMultipleFiles !== undefined && + object.javaMultipleFiles !== null + ) { + message.javaMultipleFiles = object.javaMultipleFiles; + } else { + message.javaMultipleFiles = false; + } + if ( + object.javaGenerateEqualsAndHash !== undefined && + object.javaGenerateEqualsAndHash !== null + ) { + message.javaGenerateEqualsAndHash = object.javaGenerateEqualsAndHash; + } else { + message.javaGenerateEqualsAndHash = false; + } + if ( + object.javaStringCheckUtf8 !== undefined && + object.javaStringCheckUtf8 !== null + ) { + message.javaStringCheckUtf8 = object.javaStringCheckUtf8; + } else { + message.javaStringCheckUtf8 = false; + } + if (object.optimizeFor !== undefined && object.optimizeFor !== null) { + message.optimizeFor = object.optimizeFor; + } else { + message.optimizeFor = 1; + } + if (object.goPackage !== undefined && object.goPackage !== null) { + message.goPackage = object.goPackage; + } else { + message.goPackage = ""; + } + if ( + object.ccGenericServices !== undefined && + object.ccGenericServices !== null + ) { + message.ccGenericServices = object.ccGenericServices; + } else { + message.ccGenericServices = false; + } + if ( + object.javaGenericServices !== undefined && + object.javaGenericServices !== null + ) { + message.javaGenericServices = object.javaGenericServices; + } else { + message.javaGenericServices = false; + } + if ( + object.pyGenericServices !== undefined && + object.pyGenericServices !== null + ) { + message.pyGenericServices = object.pyGenericServices; + } else { + message.pyGenericServices = false; + } + if ( + object.phpGenericServices !== undefined && + object.phpGenericServices !== null + ) { + message.phpGenericServices = object.phpGenericServices; + } else { + message.phpGenericServices = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if (object.ccEnableArenas !== undefined && object.ccEnableArenas !== null) { + message.ccEnableArenas = object.ccEnableArenas; + } else { + message.ccEnableArenas = false; + } + if ( + object.objcClassPrefix !== undefined && + object.objcClassPrefix !== null + ) { + message.objcClassPrefix = object.objcClassPrefix; + } else { + message.objcClassPrefix = ""; + } + if ( + object.csharpNamespace !== undefined && + object.csharpNamespace !== null + ) { + message.csharpNamespace = object.csharpNamespace; + } else { + message.csharpNamespace = ""; + } + if (object.swiftPrefix !== undefined && object.swiftPrefix !== null) { + message.swiftPrefix = object.swiftPrefix; + } else { + message.swiftPrefix = ""; + } + if (object.phpClassPrefix !== undefined && object.phpClassPrefix !== null) { + message.phpClassPrefix = object.phpClassPrefix; + } else { + message.phpClassPrefix = ""; + } + if (object.phpNamespace !== undefined && object.phpNamespace !== null) { + message.phpNamespace = object.phpNamespace; + } else { + message.phpNamespace = ""; + } + if ( + object.phpMetadataNamespace !== undefined && + object.phpMetadataNamespace !== null + ) { + message.phpMetadataNamespace = object.phpMetadataNamespace; + } else { + message.phpMetadataNamespace = ""; + } + if (object.rubyPackage !== undefined && object.rubyPackage !== null) { + message.rubyPackage = object.rubyPackage; + } else { + message.rubyPackage = ""; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseMessageOptions: object = { + messageSetWireFormat: false, + noStandardDescriptorAccessor: false, + deprecated: false, + mapEntry: false, +}; + +export const MessageOptions = { + encode(message: MessageOptions, writer: Writer = Writer.create()): Writer { + if (message.messageSetWireFormat === true) { + writer.uint32(8).bool(message.messageSetWireFormat); + } + if (message.noStandardDescriptorAccessor === true) { + writer.uint32(16).bool(message.noStandardDescriptorAccessor); + } + if (message.deprecated === true) { + writer.uint32(24).bool(message.deprecated); + } + if (message.mapEntry === true) { + writer.uint32(56).bool(message.mapEntry); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MessageOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMessageOptions } as MessageOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.messageSetWireFormat = reader.bool(); + break; + case 2: + message.noStandardDescriptorAccessor = reader.bool(); + break; + case 3: + message.deprecated = reader.bool(); + break; + case 7: + message.mapEntry = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MessageOptions { + const message = { ...baseMessageOptions } as MessageOptions; + message.uninterpretedOption = []; + if ( + object.messageSetWireFormat !== undefined && + object.messageSetWireFormat !== null + ) { + message.messageSetWireFormat = Boolean(object.messageSetWireFormat); + } else { + message.messageSetWireFormat = false; + } + if ( + object.noStandardDescriptorAccessor !== undefined && + object.noStandardDescriptorAccessor !== null + ) { + message.noStandardDescriptorAccessor = Boolean( + object.noStandardDescriptorAccessor + ); + } else { + message.noStandardDescriptorAccessor = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if (object.mapEntry !== undefined && object.mapEntry !== null) { + message.mapEntry = Boolean(object.mapEntry); + } else { + message.mapEntry = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: MessageOptions): unknown { + const obj: any = {}; + message.messageSetWireFormat !== undefined && + (obj.messageSetWireFormat = message.messageSetWireFormat); + message.noStandardDescriptorAccessor !== undefined && + (obj.noStandardDescriptorAccessor = message.noStandardDescriptorAccessor); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.mapEntry !== undefined && (obj.mapEntry = message.mapEntry); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): MessageOptions { + const message = { ...baseMessageOptions } as MessageOptions; + message.uninterpretedOption = []; + if ( + object.messageSetWireFormat !== undefined && + object.messageSetWireFormat !== null + ) { + message.messageSetWireFormat = object.messageSetWireFormat; + } else { + message.messageSetWireFormat = false; + } + if ( + object.noStandardDescriptorAccessor !== undefined && + object.noStandardDescriptorAccessor !== null + ) { + message.noStandardDescriptorAccessor = + object.noStandardDescriptorAccessor; + } else { + message.noStandardDescriptorAccessor = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if (object.mapEntry !== undefined && object.mapEntry !== null) { + message.mapEntry = object.mapEntry; + } else { + message.mapEntry = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseFieldOptions: object = { + ctype: 0, + packed: false, + jstype: 0, + lazy: false, + deprecated: false, + weak: false, +}; + +export const FieldOptions = { + encode(message: FieldOptions, writer: Writer = Writer.create()): Writer { + if (message.ctype !== 0) { + writer.uint32(8).int32(message.ctype); + } + if (message.packed === true) { + writer.uint32(16).bool(message.packed); + } + if (message.jstype !== 0) { + writer.uint32(48).int32(message.jstype); + } + if (message.lazy === true) { + writer.uint32(40).bool(message.lazy); + } + if (message.deprecated === true) { + writer.uint32(24).bool(message.deprecated); + } + if (message.weak === true) { + writer.uint32(80).bool(message.weak); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FieldOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFieldOptions } as FieldOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.ctype = reader.int32() as any; + break; + case 2: + message.packed = reader.bool(); + break; + case 6: + message.jstype = reader.int32() as any; + break; + case 5: + message.lazy = reader.bool(); + break; + case 3: + message.deprecated = reader.bool(); + break; + case 10: + message.weak = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FieldOptions { + const message = { ...baseFieldOptions } as FieldOptions; + message.uninterpretedOption = []; + if (object.ctype !== undefined && object.ctype !== null) { + message.ctype = fieldOptions_CTypeFromJSON(object.ctype); + } else { + message.ctype = 0; + } + if (object.packed !== undefined && object.packed !== null) { + message.packed = Boolean(object.packed); + } else { + message.packed = false; + } + if (object.jstype !== undefined && object.jstype !== null) { + message.jstype = fieldOptions_JSTypeFromJSON(object.jstype); + } else { + message.jstype = 0; + } + if (object.lazy !== undefined && object.lazy !== null) { + message.lazy = Boolean(object.lazy); + } else { + message.lazy = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if (object.weak !== undefined && object.weak !== null) { + message.weak = Boolean(object.weak); + } else { + message.weak = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: FieldOptions): unknown { + const obj: any = {}; + message.ctype !== undefined && + (obj.ctype = fieldOptions_CTypeToJSON(message.ctype)); + message.packed !== undefined && (obj.packed = message.packed); + message.jstype !== undefined && + (obj.jstype = fieldOptions_JSTypeToJSON(message.jstype)); + message.lazy !== undefined && (obj.lazy = message.lazy); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.weak !== undefined && (obj.weak = message.weak); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): FieldOptions { + const message = { ...baseFieldOptions } as FieldOptions; + message.uninterpretedOption = []; + if (object.ctype !== undefined && object.ctype !== null) { + message.ctype = object.ctype; + } else { + message.ctype = 0; + } + if (object.packed !== undefined && object.packed !== null) { + message.packed = object.packed; + } else { + message.packed = false; + } + if (object.jstype !== undefined && object.jstype !== null) { + message.jstype = object.jstype; + } else { + message.jstype = 0; + } + if (object.lazy !== undefined && object.lazy !== null) { + message.lazy = object.lazy; + } else { + message.lazy = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if (object.weak !== undefined && object.weak !== null) { + message.weak = object.weak; + } else { + message.weak = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseOneofOptions: object = {}; + +export const OneofOptions = { + encode(message: OneofOptions, writer: Writer = Writer.create()): Writer { + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): OneofOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseOneofOptions } as OneofOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): OneofOptions { + const message = { ...baseOneofOptions } as OneofOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: OneofOptions): unknown { + const obj: any = {}; + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): OneofOptions { + const message = { ...baseOneofOptions } as OneofOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseEnumOptions: object = { allowAlias: false, deprecated: false }; + +export const EnumOptions = { + encode(message: EnumOptions, writer: Writer = Writer.create()): Writer { + if (message.allowAlias === true) { + writer.uint32(16).bool(message.allowAlias); + } + if (message.deprecated === true) { + writer.uint32(24).bool(message.deprecated); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): EnumOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseEnumOptions } as EnumOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + message.allowAlias = reader.bool(); + break; + case 3: + message.deprecated = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumOptions { + const message = { ...baseEnumOptions } as EnumOptions; + message.uninterpretedOption = []; + if (object.allowAlias !== undefined && object.allowAlias !== null) { + message.allowAlias = Boolean(object.allowAlias); + } else { + message.allowAlias = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: EnumOptions): unknown { + const obj: any = {}; + message.allowAlias !== undefined && (obj.allowAlias = message.allowAlias); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): EnumOptions { + const message = { ...baseEnumOptions } as EnumOptions; + message.uninterpretedOption = []; + if (object.allowAlias !== undefined && object.allowAlias !== null) { + message.allowAlias = object.allowAlias; + } else { + message.allowAlias = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseEnumValueOptions: object = { deprecated: false }; + +export const EnumValueOptions = { + encode(message: EnumValueOptions, writer: Writer = Writer.create()): Writer { + if (message.deprecated === true) { + writer.uint32(8).bool(message.deprecated); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): EnumValueOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseEnumValueOptions } as EnumValueOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.deprecated = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumValueOptions { + const message = { ...baseEnumValueOptions } as EnumValueOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: EnumValueOptions): unknown { + const obj: any = {}; + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): EnumValueOptions { + const message = { ...baseEnumValueOptions } as EnumValueOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseServiceOptions: object = { deprecated: false }; + +export const ServiceOptions = { + encode(message: ServiceOptions, writer: Writer = Writer.create()): Writer { + if (message.deprecated === true) { + writer.uint32(264).bool(message.deprecated); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ServiceOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseServiceOptions } as ServiceOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 33: + message.deprecated = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ServiceOptions { + const message = { ...baseServiceOptions } as ServiceOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: ServiceOptions): unknown { + const obj: any = {}; + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): ServiceOptions { + const message = { ...baseServiceOptions } as ServiceOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseMethodOptions: object = { deprecated: false, idempotencyLevel: 0 }; + +export const MethodOptions = { + encode(message: MethodOptions, writer: Writer = Writer.create()): Writer { + if (message.deprecated === true) { + writer.uint32(264).bool(message.deprecated); + } + if (message.idempotencyLevel !== 0) { + writer.uint32(272).int32(message.idempotencyLevel); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MethodOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMethodOptions } as MethodOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 33: + message.deprecated = reader.bool(); + break; + case 34: + message.idempotencyLevel = reader.int32() as any; + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MethodOptions { + const message = { ...baseMethodOptions } as MethodOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.idempotencyLevel !== undefined && + object.idempotencyLevel !== null + ) { + message.idempotencyLevel = methodOptions_IdempotencyLevelFromJSON( + object.idempotencyLevel + ); + } else { + message.idempotencyLevel = 0; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: MethodOptions): unknown { + const obj: any = {}; + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.idempotencyLevel !== undefined && + (obj.idempotencyLevel = methodOptions_IdempotencyLevelToJSON( + message.idempotencyLevel + )); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): MethodOptions { + const message = { ...baseMethodOptions } as MethodOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.idempotencyLevel !== undefined && + object.idempotencyLevel !== null + ) { + message.idempotencyLevel = object.idempotencyLevel; + } else { + message.idempotencyLevel = 0; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseUninterpretedOption: object = { + identifierValue: "", + positiveIntValue: 0, + negativeIntValue: 0, + doubleValue: 0, + aggregateValue: "", +}; + +export const UninterpretedOption = { + encode( + message: UninterpretedOption, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.name) { + UninterpretedOption_NamePart.encode( + v!, + writer.uint32(18).fork() + ).ldelim(); + } + if (message.identifierValue !== "") { + writer.uint32(26).string(message.identifierValue); + } + if (message.positiveIntValue !== 0) { + writer.uint32(32).uint64(message.positiveIntValue); + } + if (message.negativeIntValue !== 0) { + writer.uint32(40).int64(message.negativeIntValue); + } + if (message.doubleValue !== 0) { + writer.uint32(49).double(message.doubleValue); + } + if (message.stringValue.length !== 0) { + writer.uint32(58).bytes(message.stringValue); + } + if (message.aggregateValue !== "") { + writer.uint32(66).string(message.aggregateValue); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): UninterpretedOption { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseUninterpretedOption } as UninterpretedOption; + message.name = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + message.name.push( + UninterpretedOption_NamePart.decode(reader, reader.uint32()) + ); + break; + case 3: + message.identifierValue = reader.string(); + break; + case 4: + message.positiveIntValue = longToNumber(reader.uint64() as Long); + break; + case 5: + message.negativeIntValue = longToNumber(reader.int64() as Long); + break; + case 6: + message.doubleValue = reader.double(); + break; + case 7: + message.stringValue = reader.bytes(); + break; + case 8: + message.aggregateValue = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): UninterpretedOption { + const message = { ...baseUninterpretedOption } as UninterpretedOption; + message.name = []; + if (object.name !== undefined && object.name !== null) { + for (const e of object.name) { + message.name.push(UninterpretedOption_NamePart.fromJSON(e)); + } + } + if ( + object.identifierValue !== undefined && + object.identifierValue !== null + ) { + message.identifierValue = String(object.identifierValue); + } else { + message.identifierValue = ""; + } + if ( + object.positiveIntValue !== undefined && + object.positiveIntValue !== null + ) { + message.positiveIntValue = Number(object.positiveIntValue); + } else { + message.positiveIntValue = 0; + } + if ( + object.negativeIntValue !== undefined && + object.negativeIntValue !== null + ) { + message.negativeIntValue = Number(object.negativeIntValue); + } else { + message.negativeIntValue = 0; + } + if (object.doubleValue !== undefined && object.doubleValue !== null) { + message.doubleValue = Number(object.doubleValue); + } else { + message.doubleValue = 0; + } + if (object.stringValue !== undefined && object.stringValue !== null) { + message.stringValue = bytesFromBase64(object.stringValue); + } + if (object.aggregateValue !== undefined && object.aggregateValue !== null) { + message.aggregateValue = String(object.aggregateValue); + } else { + message.aggregateValue = ""; + } + return message; + }, + + toJSON(message: UninterpretedOption): unknown { + const obj: any = {}; + if (message.name) { + obj.name = message.name.map((e) => + e ? UninterpretedOption_NamePart.toJSON(e) : undefined + ); + } else { + obj.name = []; + } + message.identifierValue !== undefined && + (obj.identifierValue = message.identifierValue); + message.positiveIntValue !== undefined && + (obj.positiveIntValue = message.positiveIntValue); + message.negativeIntValue !== undefined && + (obj.negativeIntValue = message.negativeIntValue); + message.doubleValue !== undefined && + (obj.doubleValue = message.doubleValue); + message.stringValue !== undefined && + (obj.stringValue = base64FromBytes( + message.stringValue !== undefined + ? message.stringValue + : new Uint8Array() + )); + message.aggregateValue !== undefined && + (obj.aggregateValue = message.aggregateValue); + return obj; + }, + + fromPartial(object: DeepPartial): UninterpretedOption { + const message = { ...baseUninterpretedOption } as UninterpretedOption; + message.name = []; + if (object.name !== undefined && object.name !== null) { + for (const e of object.name) { + message.name.push(UninterpretedOption_NamePart.fromPartial(e)); + } + } + if ( + object.identifierValue !== undefined && + object.identifierValue !== null + ) { + message.identifierValue = object.identifierValue; + } else { + message.identifierValue = ""; + } + if ( + object.positiveIntValue !== undefined && + object.positiveIntValue !== null + ) { + message.positiveIntValue = object.positiveIntValue; + } else { + message.positiveIntValue = 0; + } + if ( + object.negativeIntValue !== undefined && + object.negativeIntValue !== null + ) { + message.negativeIntValue = object.negativeIntValue; + } else { + message.negativeIntValue = 0; + } + if (object.doubleValue !== undefined && object.doubleValue !== null) { + message.doubleValue = object.doubleValue; + } else { + message.doubleValue = 0; + } + if (object.stringValue !== undefined && object.stringValue !== null) { + message.stringValue = object.stringValue; + } else { + message.stringValue = new Uint8Array(); + } + if (object.aggregateValue !== undefined && object.aggregateValue !== null) { + message.aggregateValue = object.aggregateValue; + } else { + message.aggregateValue = ""; + } + return message; + }, +}; + +const baseUninterpretedOption_NamePart: object = { + namePart: "", + isExtension: false, +}; + +export const UninterpretedOption_NamePart = { + encode( + message: UninterpretedOption_NamePart, + writer: Writer = Writer.create() + ): Writer { + if (message.namePart !== "") { + writer.uint32(10).string(message.namePart); + } + if (message.isExtension === true) { + writer.uint32(16).bool(message.isExtension); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): UninterpretedOption_NamePart { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseUninterpretedOption_NamePart, + } as UninterpretedOption_NamePart; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.namePart = reader.string(); + break; + case 2: + message.isExtension = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): UninterpretedOption_NamePart { + const message = { + ...baseUninterpretedOption_NamePart, + } as UninterpretedOption_NamePart; + if (object.namePart !== undefined && object.namePart !== null) { + message.namePart = String(object.namePart); + } else { + message.namePart = ""; + } + if (object.isExtension !== undefined && object.isExtension !== null) { + message.isExtension = Boolean(object.isExtension); + } else { + message.isExtension = false; + } + return message; + }, + + toJSON(message: UninterpretedOption_NamePart): unknown { + const obj: any = {}; + message.namePart !== undefined && (obj.namePart = message.namePart); + message.isExtension !== undefined && + (obj.isExtension = message.isExtension); + return obj; + }, + + fromPartial( + object: DeepPartial + ): UninterpretedOption_NamePart { + const message = { + ...baseUninterpretedOption_NamePart, + } as UninterpretedOption_NamePart; + if (object.namePart !== undefined && object.namePart !== null) { + message.namePart = object.namePart; + } else { + message.namePart = ""; + } + if (object.isExtension !== undefined && object.isExtension !== null) { + message.isExtension = object.isExtension; + } else { + message.isExtension = false; + } + return message; + }, +}; + +const baseSourceCodeInfo: object = {}; + +export const SourceCodeInfo = { + encode(message: SourceCodeInfo, writer: Writer = Writer.create()): Writer { + for (const v of message.location) { + SourceCodeInfo_Location.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): SourceCodeInfo { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseSourceCodeInfo } as SourceCodeInfo; + message.location = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.location.push( + SourceCodeInfo_Location.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): SourceCodeInfo { + const message = { ...baseSourceCodeInfo } as SourceCodeInfo; + message.location = []; + if (object.location !== undefined && object.location !== null) { + for (const e of object.location) { + message.location.push(SourceCodeInfo_Location.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: SourceCodeInfo): unknown { + const obj: any = {}; + if (message.location) { + obj.location = message.location.map((e) => + e ? SourceCodeInfo_Location.toJSON(e) : undefined + ); + } else { + obj.location = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): SourceCodeInfo { + const message = { ...baseSourceCodeInfo } as SourceCodeInfo; + message.location = []; + if (object.location !== undefined && object.location !== null) { + for (const e of object.location) { + message.location.push(SourceCodeInfo_Location.fromPartial(e)); + } + } + return message; + }, +}; + +const baseSourceCodeInfo_Location: object = { + path: 0, + span: 0, + leadingComments: "", + trailingComments: "", + leadingDetachedComments: "", +}; + +export const SourceCodeInfo_Location = { + encode( + message: SourceCodeInfo_Location, + writer: Writer = Writer.create() + ): Writer { + writer.uint32(10).fork(); + for (const v of message.path) { + writer.int32(v); + } + writer.ldelim(); + writer.uint32(18).fork(); + for (const v of message.span) { + writer.int32(v); + } + writer.ldelim(); + if (message.leadingComments !== "") { + writer.uint32(26).string(message.leadingComments); + } + if (message.trailingComments !== "") { + writer.uint32(34).string(message.trailingComments); + } + for (const v of message.leadingDetachedComments) { + writer.uint32(50).string(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): SourceCodeInfo_Location { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseSourceCodeInfo_Location, + } as SourceCodeInfo_Location; + message.path = []; + message.span = []; + message.leadingDetachedComments = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.path.push(reader.int32()); + } + } else { + message.path.push(reader.int32()); + } + break; + case 2: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.span.push(reader.int32()); + } + } else { + message.span.push(reader.int32()); + } + break; + case 3: + message.leadingComments = reader.string(); + break; + case 4: + message.trailingComments = reader.string(); + break; + case 6: + message.leadingDetachedComments.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): SourceCodeInfo_Location { + const message = { + ...baseSourceCodeInfo_Location, + } as SourceCodeInfo_Location; + message.path = []; + message.span = []; + message.leadingDetachedComments = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(Number(e)); + } + } + if (object.span !== undefined && object.span !== null) { + for (const e of object.span) { + message.span.push(Number(e)); + } + } + if ( + object.leadingComments !== undefined && + object.leadingComments !== null + ) { + message.leadingComments = String(object.leadingComments); + } else { + message.leadingComments = ""; + } + if ( + object.trailingComments !== undefined && + object.trailingComments !== null + ) { + message.trailingComments = String(object.trailingComments); + } else { + message.trailingComments = ""; + } + if ( + object.leadingDetachedComments !== undefined && + object.leadingDetachedComments !== null + ) { + for (const e of object.leadingDetachedComments) { + message.leadingDetachedComments.push(String(e)); + } + } + return message; + }, + + toJSON(message: SourceCodeInfo_Location): unknown { + const obj: any = {}; + if (message.path) { + obj.path = message.path.map((e) => e); + } else { + obj.path = []; + } + if (message.span) { + obj.span = message.span.map((e) => e); + } else { + obj.span = []; + } + message.leadingComments !== undefined && + (obj.leadingComments = message.leadingComments); + message.trailingComments !== undefined && + (obj.trailingComments = message.trailingComments); + if (message.leadingDetachedComments) { + obj.leadingDetachedComments = message.leadingDetachedComments.map( + (e) => e + ); + } else { + obj.leadingDetachedComments = []; + } + return obj; + }, + + fromPartial( + object: DeepPartial + ): SourceCodeInfo_Location { + const message = { + ...baseSourceCodeInfo_Location, + } as SourceCodeInfo_Location; + message.path = []; + message.span = []; + message.leadingDetachedComments = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(e); + } + } + if (object.span !== undefined && object.span !== null) { + for (const e of object.span) { + message.span.push(e); + } + } + if ( + object.leadingComments !== undefined && + object.leadingComments !== null + ) { + message.leadingComments = object.leadingComments; + } else { + message.leadingComments = ""; + } + if ( + object.trailingComments !== undefined && + object.trailingComments !== null + ) { + message.trailingComments = object.trailingComments; + } else { + message.trailingComments = ""; + } + if ( + object.leadingDetachedComments !== undefined && + object.leadingDetachedComments !== null + ) { + for (const e of object.leadingDetachedComments) { + message.leadingDetachedComments.push(e); + } + } + return message; + }, +}; + +const baseGeneratedCodeInfo: object = {}; + +export const GeneratedCodeInfo = { + encode(message: GeneratedCodeInfo, writer: Writer = Writer.create()): Writer { + for (const v of message.annotation) { + GeneratedCodeInfo_Annotation.encode( + v!, + writer.uint32(10).fork() + ).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): GeneratedCodeInfo { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseGeneratedCodeInfo } as GeneratedCodeInfo; + message.annotation = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.annotation.push( + GeneratedCodeInfo_Annotation.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GeneratedCodeInfo { + const message = { ...baseGeneratedCodeInfo } as GeneratedCodeInfo; + message.annotation = []; + if (object.annotation !== undefined && object.annotation !== null) { + for (const e of object.annotation) { + message.annotation.push(GeneratedCodeInfo_Annotation.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: GeneratedCodeInfo): unknown { + const obj: any = {}; + if (message.annotation) { + obj.annotation = message.annotation.map((e) => + e ? GeneratedCodeInfo_Annotation.toJSON(e) : undefined + ); + } else { + obj.annotation = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): GeneratedCodeInfo { + const message = { ...baseGeneratedCodeInfo } as GeneratedCodeInfo; + message.annotation = []; + if (object.annotation !== undefined && object.annotation !== null) { + for (const e of object.annotation) { + message.annotation.push(GeneratedCodeInfo_Annotation.fromPartial(e)); + } + } + return message; + }, +}; + +const baseGeneratedCodeInfo_Annotation: object = { + path: 0, + sourceFile: "", + begin: 0, + end: 0, +}; + +export const GeneratedCodeInfo_Annotation = { + encode( + message: GeneratedCodeInfo_Annotation, + writer: Writer = Writer.create() + ): Writer { + writer.uint32(10).fork(); + for (const v of message.path) { + writer.int32(v); + } + writer.ldelim(); + if (message.sourceFile !== "") { + writer.uint32(18).string(message.sourceFile); + } + if (message.begin !== 0) { + writer.uint32(24).int32(message.begin); + } + if (message.end !== 0) { + writer.uint32(32).int32(message.end); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): GeneratedCodeInfo_Annotation { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseGeneratedCodeInfo_Annotation, + } as GeneratedCodeInfo_Annotation; + message.path = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.path.push(reader.int32()); + } + } else { + message.path.push(reader.int32()); + } + break; + case 2: + message.sourceFile = reader.string(); + break; + case 3: + message.begin = reader.int32(); + break; + case 4: + message.end = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GeneratedCodeInfo_Annotation { + const message = { + ...baseGeneratedCodeInfo_Annotation, + } as GeneratedCodeInfo_Annotation; + message.path = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(Number(e)); + } + } + if (object.sourceFile !== undefined && object.sourceFile !== null) { + message.sourceFile = String(object.sourceFile); + } else { + message.sourceFile = ""; + } + if (object.begin !== undefined && object.begin !== null) { + message.begin = Number(object.begin); + } else { + message.begin = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + return message; + }, + + toJSON(message: GeneratedCodeInfo_Annotation): unknown { + const obj: any = {}; + if (message.path) { + obj.path = message.path.map((e) => e); + } else { + obj.path = []; + } + message.sourceFile !== undefined && (obj.sourceFile = message.sourceFile); + message.begin !== undefined && (obj.begin = message.begin); + message.end !== undefined && (obj.end = message.end); + return obj; + }, + + fromPartial( + object: DeepPartial + ): GeneratedCodeInfo_Annotation { + const message = { + ...baseGeneratedCodeInfo_Annotation, + } as GeneratedCodeInfo_Annotation; + message.path = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(e); + } + } + if (object.sourceFile !== undefined && object.sourceFile !== null) { + message.sourceFile = object.sourceFile; + } else { + message.sourceFile = ""; + } + if (object.begin !== undefined && object.begin !== null) { + message.begin = object.begin; + } else { + message.begin = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/cosmos.authz.v1beta1/index.ts b/ts-client/cosmos.authz.v1beta1/index.ts new file mode 100755 index 00000000..c9dfa159 --- /dev/null +++ b/ts-client/cosmos.authz.v1beta1/index.ts @@ -0,0 +1,6 @@ +import Module from './module'; +import { txClient, queryClient, registry } from './module'; +import { msgTypes } from './registry'; + +export * from "./types"; +export { Module, msgTypes, txClient, queryClient, registry }; diff --git a/ts-client/cosmos.authz.v1beta1/module.ts b/ts-client/cosmos.authz.v1beta1/module.ts new file mode 100755 index 00000000..80f7d9a8 --- /dev/null +++ b/ts-client/cosmos.authz.v1beta1/module.ts @@ -0,0 +1,165 @@ +// Generated by Ignite ignite.com/cli + +import { StdFee } from "@cosmjs/launchpad"; +import { SigningStargateClient, DeliverTxResponse } from "@cosmjs/stargate"; +import { EncodeObject, GeneratedType, OfflineSigner, Registry } from "@cosmjs/proto-signing"; +import { msgTypes } from './registry'; +import { IgniteClient } from "../client" +import { MissingWalletError } from "../helpers" +import { Api } from "./rest"; +import { MsgRevoke } from "./types/cosmos/authz/v1beta1/tx"; +import { MsgExec } from "./types/cosmos/authz/v1beta1/tx"; +import { MsgGrant } from "./types/cosmos/authz/v1beta1/tx"; + + +export { MsgRevoke, MsgExec, MsgGrant }; + +type sendMsgRevokeParams = { + value: MsgRevoke, + fee?: StdFee, + memo?: string +}; + +type sendMsgExecParams = { + value: MsgExec, + fee?: StdFee, + memo?: string +}; + +type sendMsgGrantParams = { + value: MsgGrant, + fee?: StdFee, + memo?: string +}; + + +type msgRevokeParams = { + value: MsgRevoke, +}; + +type msgExecParams = { + value: MsgExec, +}; + +type msgGrantParams = { + value: MsgGrant, +}; + + +export const registry = new Registry(msgTypes); + +const defaultFee = { + amount: [], + gas: "200000", +}; + +interface TxClientOptions { + addr: string + prefix: string + signer?: OfflineSigner +} + +export const txClient = ({ signer, prefix, addr }: TxClientOptions = { addr: "http://localhost:26657", prefix: "cosmos" }) => { + + return { + + async sendMsgRevoke({ value, fee, memo }: sendMsgRevokeParams): Promise { + if (!signer) { + throw new Error('TxClient:sendMsgRevoke: Unable to sign Tx. Signer is not present.') + } + try { + const { address } = (await signer.getAccounts())[0]; + const signingClient = await SigningStargateClient.connectWithSigner(addr,signer,{registry, prefix}); + let msg = this.msgRevoke({ value: MsgRevoke.fromPartial(value) }) + return await signingClient.signAndBroadcast(address, [msg], fee ? fee : defaultFee, memo) + } catch (e: any) { + throw new Error('TxClient:sendMsgRevoke: Could not broadcast Tx: '+ e.message) + } + }, + + async sendMsgExec({ value, fee, memo }: sendMsgExecParams): Promise { + if (!signer) { + throw new Error('TxClient:sendMsgExec: Unable to sign Tx. Signer is not present.') + } + try { + const { address } = (await signer.getAccounts())[0]; + const signingClient = await SigningStargateClient.connectWithSigner(addr,signer,{registry, prefix}); + let msg = this.msgExec({ value: MsgExec.fromPartial(value) }) + return await signingClient.signAndBroadcast(address, [msg], fee ? fee : defaultFee, memo) + } catch (e: any) { + throw new Error('TxClient:sendMsgExec: Could not broadcast Tx: '+ e.message) + } + }, + + async sendMsgGrant({ value, fee, memo }: sendMsgGrantParams): Promise { + if (!signer) { + throw new Error('TxClient:sendMsgGrant: Unable to sign Tx. Signer is not present.') + } + try { + const { address } = (await signer.getAccounts())[0]; + const signingClient = await SigningStargateClient.connectWithSigner(addr,signer,{registry, prefix}); + let msg = this.msgGrant({ value: MsgGrant.fromPartial(value) }) + return await signingClient.signAndBroadcast(address, [msg], fee ? fee : defaultFee, memo) + } catch (e: any) { + throw new Error('TxClient:sendMsgGrant: Could not broadcast Tx: '+ e.message) + } + }, + + + msgRevoke({ value }: msgRevokeParams): EncodeObject { + try { + return { typeUrl: "/cosmos.authz.v1beta1.MsgRevoke", value: MsgRevoke.fromPartial( value ) } + } catch (e: any) { + throw new Error('TxClient:MsgRevoke: Could not create message: ' + e.message) + } + }, + + msgExec({ value }: msgExecParams): EncodeObject { + try { + return { typeUrl: "/cosmos.authz.v1beta1.MsgExec", value: MsgExec.fromPartial( value ) } + } catch (e: any) { + throw new Error('TxClient:MsgExec: Could not create message: ' + e.message) + } + }, + + msgGrant({ value }: msgGrantParams): EncodeObject { + try { + return { typeUrl: "/cosmos.authz.v1beta1.MsgGrant", value: MsgGrant.fromPartial( value ) } + } catch (e: any) { + throw new Error('TxClient:MsgGrant: Could not create message: ' + e.message) + } + }, + + } +}; + +interface QueryClientOptions { + addr: string +} + +export const queryClient = ({ addr: addr }: QueryClientOptions = { addr: "http://localhost:1317" }) => { + return new Api({ baseUrl: addr }); +}; + +class SDKModule { + public query: ReturnType; + public tx: ReturnType; + + public registry: Array<[string, GeneratedType]>; + + constructor(client: IgniteClient) { + + this.query = queryClient({ addr: client.env.apiURL }); + this.tx = txClient({ signer: client.signer, addr: client.env.rpcURL, prefix: client.env.prefix ?? "cosmos" }); + } +}; + +const Module = (test: IgniteClient) => { + return { + module: { + CosmosAuthzV1Beta1: new SDKModule(test) + }, + registry: msgTypes + } +} +export default Module; \ No newline at end of file diff --git a/ts-client/cosmos.authz.v1beta1/registry.ts b/ts-client/cosmos.authz.v1beta1/registry.ts new file mode 100755 index 00000000..16f71067 --- /dev/null +++ b/ts-client/cosmos.authz.v1beta1/registry.ts @@ -0,0 +1,13 @@ +import { GeneratedType } from "@cosmjs/proto-signing"; +import { MsgRevoke } from "./types/cosmos/authz/v1beta1/tx"; +import { MsgExec } from "./types/cosmos/authz/v1beta1/tx"; +import { MsgGrant } from "./types/cosmos/authz/v1beta1/tx"; + +const msgTypes: Array<[string, GeneratedType]> = [ + ["/cosmos.authz.v1beta1.MsgRevoke", MsgRevoke], + ["/cosmos.authz.v1beta1.MsgExec", MsgExec], + ["/cosmos.authz.v1beta1.MsgGrant", MsgGrant], + +]; + +export { msgTypes } \ No newline at end of file diff --git a/ts-client/cosmos.authz.v1beta1/rest.ts b/ts-client/cosmos.authz.v1beta1/rest.ts new file mode 100644 index 00000000..6ba45736 --- /dev/null +++ b/ts-client/cosmos.authz.v1beta1/rest.ts @@ -0,0 +1,719 @@ +/* eslint-disable */ +/* tslint:disable */ +/* + * --------------------------------------------------------------- + * ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ## + * ## ## + * ## AUTHOR: acacode ## + * ## SOURCE: https://github.com/acacode/swagger-typescript-api ## + * --------------------------------------------------------------- + */ + +/** +* Grant gives permissions to execute +the provide method with expiration time. +*/ +export interface Authzv1Beta1Grant { + /** + * `Any` contains an arbitrary serialized protocol buffer message along with a + * URL that describes the type of the serialized message. + * + * Protobuf library provides support to pack/unpack Any values in the form + * of utility functions or additional generated methods of the Any type. + * + * Example 1: Pack and unpack a message in C++. + * + * Foo foo = ...; + * Any any; + * any.PackFrom(foo); + * ... + * if (any.UnpackTo(&foo)) { + * ... + * } + * + * Example 2: Pack and unpack a message in Java. + * + * Foo foo = ...; + * Any any = Any.pack(foo); + * ... + * if (any.is(Foo.class)) { + * foo = any.unpack(Foo.class); + * } + * + * Example 3: Pack and unpack a message in Python. + * + * foo = Foo(...) + * any = Any() + * any.Pack(foo) + * ... + * if any.Is(Foo.DESCRIPTOR): + * any.Unpack(foo) + * ... + * + * Example 4: Pack and unpack a message in Go + * + * foo := &pb.Foo{...} + * any, err := anypb.New(foo) + * if err != nil { + * ... + * } + * ... + * foo := &pb.Foo{} + * if err := any.UnmarshalTo(foo); err != nil { + * ... + * } + * + * The pack methods provided by protobuf library will by default use + * 'type.googleapis.com/full.type.name' as the type URL and the unpack + * methods only use the fully qualified type name after the last '/' + * in the type URL, for example "foo.bar.com/x/y.z" will yield type + * name "y.z". + * + * + * JSON + * ==== + * The JSON representation of an `Any` value uses the regular + * representation of the deserialized, embedded message, with an + * additional field `@type` which contains the type URL. Example: + * + * package google.profile; + * message Person { + * string first_name = 1; + * string last_name = 2; + * } + * + * { + * "@type": "type.googleapis.com/google.profile.Person", + * "firstName": , + * "lastName": + * } + * + * If the embedded message type is well-known and has a custom JSON + * representation, that representation will be embedded adding a field + * `value` which holds the custom JSON in addition to the `@type` + * field. Example (for message [google.protobuf.Duration][]): + * + * { + * "@type": "type.googleapis.com/google.protobuf.Duration", + * "value": "1.212s" + * } + */ + authorization?: ProtobufAny; + + /** @format date-time */ + expiration?: string; +} + +/** +* `Any` contains an arbitrary serialized protocol buffer message along with a +URL that describes the type of the serialized message. + +Protobuf library provides support to pack/unpack Any values in the form +of utility functions or additional generated methods of the Any type. + +Example 1: Pack and unpack a message in C++. + + Foo foo = ...; + Any any; + any.PackFrom(foo); + ... + if (any.UnpackTo(&foo)) { + ... + } + +Example 2: Pack and unpack a message in Java. + + Foo foo = ...; + Any any = Any.pack(foo); + ... + if (any.is(Foo.class)) { + foo = any.unpack(Foo.class); + } + + Example 3: Pack and unpack a message in Python. + + foo = Foo(...) + any = Any() + any.Pack(foo) + ... + if any.Is(Foo.DESCRIPTOR): + any.Unpack(foo) + ... + + Example 4: Pack and unpack a message in Go + + foo := &pb.Foo{...} + any, err := anypb.New(foo) + if err != nil { + ... + } + ... + foo := &pb.Foo{} + if err := any.UnmarshalTo(foo); err != nil { + ... + } + +The pack methods provided by protobuf library will by default use +'type.googleapis.com/full.type.name' as the type URL and the unpack +methods only use the fully qualified type name after the last '/' +in the type URL, for example "foo.bar.com/x/y.z" will yield type +name "y.z". + + +JSON +==== +The JSON representation of an `Any` value uses the regular +representation of the deserialized, embedded message, with an +additional field `@type` which contains the type URL. Example: + + package google.profile; + message Person { + string first_name = 1; + string last_name = 2; + } + + { + "@type": "type.googleapis.com/google.profile.Person", + "firstName": , + "lastName": + } + +If the embedded message type is well-known and has a custom JSON +representation, that representation will be embedded adding a field +`value` which holds the custom JSON in addition to the `@type` +field. Example (for message [google.protobuf.Duration][]): + + { + "@type": "type.googleapis.com/google.protobuf.Duration", + "value": "1.212s" + } +*/ +export interface ProtobufAny { + /** + * A URL/resource name that uniquely identifies the type of the serialized + * protocol buffer message. This string must contain at least + * one "/" character. The last segment of the URL's path must represent + * the fully qualified name of the type (as in + * `path/google.protobuf.Duration`). The name should be in a canonical form + * (e.g., leading "." is not accepted). + * + * In practice, teams usually precompile into the binary all types that they + * expect it to use in the context of Any. However, for URLs which use the + * scheme `http`, `https`, or no scheme, one can optionally set up a type + * server that maps type URLs to message definitions as follows: + * + * * If no scheme is provided, `https` is assumed. + * * An HTTP GET on the URL must yield a [google.protobuf.Type][] + * value in binary format, or produce an error. + * * Applications are allowed to cache lookup results based on the + * URL, or have them precompiled into a binary to avoid any + * lookup. Therefore, binary compatibility needs to be preserved + * on changes to types. (Use versioned type names to manage + * breaking changes.) + * + * Note: this functionality is not currently available in the official + * protobuf release, and it is not used for type URLs beginning with + * type.googleapis.com. + * + * Schemes other than `http`, `https` (or the empty scheme) might be + * used with implementation specific semantics. + */ + "@type"?: string; +} + +export interface RpcStatus { + /** @format int32 */ + code?: number; + message?: string; + details?: ProtobufAny[]; +} + +/** + * Since: cosmos-sdk 0.45.2 + */ +export interface V1Beta1GrantAuthorization { + granter?: string; + grantee?: string; + + /** + * `Any` contains an arbitrary serialized protocol buffer message along with a + * URL that describes the type of the serialized message. + * + * Protobuf library provides support to pack/unpack Any values in the form + * of utility functions or additional generated methods of the Any type. + * + * Example 1: Pack and unpack a message in C++. + * + * Foo foo = ...; + * Any any; + * any.PackFrom(foo); + * ... + * if (any.UnpackTo(&foo)) { + * ... + * } + * + * Example 2: Pack and unpack a message in Java. + * + * Foo foo = ...; + * Any any = Any.pack(foo); + * ... + * if (any.is(Foo.class)) { + * foo = any.unpack(Foo.class); + * } + * + * Example 3: Pack and unpack a message in Python. + * + * foo = Foo(...) + * any = Any() + * any.Pack(foo) + * ... + * if any.Is(Foo.DESCRIPTOR): + * any.Unpack(foo) + * ... + * + * Example 4: Pack and unpack a message in Go + * + * foo := &pb.Foo{...} + * any, err := anypb.New(foo) + * if err != nil { + * ... + * } + * ... + * foo := &pb.Foo{} + * if err := any.UnmarshalTo(foo); err != nil { + * ... + * } + * + * The pack methods provided by protobuf library will by default use + * 'type.googleapis.com/full.type.name' as the type URL and the unpack + * methods only use the fully qualified type name after the last '/' + * in the type URL, for example "foo.bar.com/x/y.z" will yield type + * name "y.z". + * + * + * JSON + * ==== + * The JSON representation of an `Any` value uses the regular + * representation of the deserialized, embedded message, with an + * additional field `@type` which contains the type URL. Example: + * + * package google.profile; + * message Person { + * string first_name = 1; + * string last_name = 2; + * } + * + * { + * "@type": "type.googleapis.com/google.profile.Person", + * "firstName": , + * "lastName": + * } + * + * If the embedded message type is well-known and has a custom JSON + * representation, that representation will be embedded adding a field + * `value` which holds the custom JSON in addition to the `@type` + * field. Example (for message [google.protobuf.Duration][]): + * + * { + * "@type": "type.googleapis.com/google.protobuf.Duration", + * "value": "1.212s" + * } + */ + authorization?: ProtobufAny; + + /** @format date-time */ + expiration?: string; +} + +/** + * MsgExecResponse defines the Msg/MsgExecResponse response type. + */ +export interface V1Beta1MsgExecResponse { + results?: string[]; +} + +/** + * MsgGrantResponse defines the Msg/MsgGrant response type. + */ +export type V1Beta1MsgGrantResponse = object; + +/** + * MsgRevokeResponse defines the Msg/MsgRevokeResponse response type. + */ +export type V1Beta1MsgRevokeResponse = object; + +/** +* message SomeRequest { + Foo some_parameter = 1; + PageRequest pagination = 2; + } +*/ +export interface V1Beta1PageRequest { + /** + * key is a value returned in PageResponse.next_key to begin + * querying the next page most efficiently. Only one of offset or key + * should be set. + * @format byte + */ + key?: string; + + /** + * offset is a numeric offset that can be used when key is unavailable. + * It is less efficient than using key. Only one of offset or key should + * be set. + * @format uint64 + */ + offset?: string; + + /** + * limit is the total number of results to be returned in the result page. + * If left empty it will default to a value to be set by each app. + * @format uint64 + */ + limit?: string; + + /** + * count_total is set to true to indicate that the result set should include + * a count of the total number of items available for pagination in UIs. + * count_total is only respected when offset is used. It is ignored when key + * is set. + */ + count_total?: boolean; + + /** + * reverse is set to true if results are to be returned in the descending order. + * + * Since: cosmos-sdk 0.43 + */ + reverse?: boolean; +} + +/** +* PageResponse is to be embedded in gRPC response messages where the +corresponding request message has used PageRequest. + + message SomeResponse { + repeated Bar results = 1; + PageResponse page = 2; + } +*/ +export interface V1Beta1PageResponse { + /** @format byte */ + next_key?: string; + + /** @format uint64 */ + total?: string; +} + +/** + * QueryGranteeGrantsResponse is the response type for the Query/GranteeGrants RPC method. + */ +export interface V1Beta1QueryGranteeGrantsResponse { + /** grants is a list of grants granted to the grantee. */ + grants?: V1Beta1GrantAuthorization[]; + + /** pagination defines an pagination for the response. */ + pagination?: V1Beta1PageResponse; +} + +/** + * QueryGranterGrantsResponse is the response type for the Query/GranterGrants RPC method. + */ +export interface V1Beta1QueryGranterGrantsResponse { + /** grants is a list of grants granted by the granter. */ + grants?: V1Beta1GrantAuthorization[]; + + /** pagination defines an pagination for the response. */ + pagination?: V1Beta1PageResponse; +} + +/** + * QueryGrantsResponse is the response type for the Query/Authorizations RPC method. + */ +export interface V1Beta1QueryGrantsResponse { + /** authorizations is a list of grants granted for grantee by granter. */ + grants?: Authzv1Beta1Grant[]; + + /** pagination defines an pagination for the response. */ + pagination?: V1Beta1PageResponse; +} + +export type QueryParamsType = Record; +export type ResponseFormat = keyof Omit; + +export interface FullRequestParams extends Omit { + /** set parameter to `true` for call `securityWorker` for this request */ + secure?: boolean; + /** request path */ + path: string; + /** content type of request body */ + type?: ContentType; + /** query params */ + query?: QueryParamsType; + /** format of response (i.e. response.json() -> format: "json") */ + format?: keyof Omit; + /** request body */ + body?: unknown; + /** base url */ + baseUrl?: string; + /** request cancellation token */ + cancelToken?: CancelToken; +} + +export type RequestParams = Omit; + +export interface ApiConfig { + baseUrl?: string; + baseApiParams?: Omit; + securityWorker?: (securityData: SecurityDataType) => RequestParams | void; +} + +export interface HttpResponse extends Response { + data: D; + error: E; +} + +type CancelToken = Symbol | string | number; + +export enum ContentType { + Json = "application/json", + FormData = "multipart/form-data", + UrlEncoded = "application/x-www-form-urlencoded", +} + +export class HttpClient { + public baseUrl: string = ""; + private securityData: SecurityDataType = null as any; + private securityWorker: null | ApiConfig["securityWorker"] = null; + private abortControllers = new Map(); + + private baseApiParams: RequestParams = { + credentials: "same-origin", + headers: {}, + redirect: "follow", + referrerPolicy: "no-referrer", + }; + + constructor(apiConfig: ApiConfig = {}) { + Object.assign(this, apiConfig); + } + + public setSecurityData = (data: SecurityDataType) => { + this.securityData = data; + }; + + private addQueryParam(query: QueryParamsType, key: string) { + const value = query[key]; + + return ( + encodeURIComponent(key) + + "=" + + encodeURIComponent(Array.isArray(value) ? value.join(",") : typeof value === "number" ? value : `${value}`) + ); + } + + protected toQueryString(rawQuery?: QueryParamsType): string { + const query = rawQuery || {}; + const keys = Object.keys(query).filter((key) => "undefined" !== typeof query[key]); + return keys + .map((key) => + typeof query[key] === "object" && !Array.isArray(query[key]) + ? this.toQueryString(query[key] as QueryParamsType) + : this.addQueryParam(query, key), + ) + .join("&"); + } + + protected addQueryParams(rawQuery?: QueryParamsType): string { + const queryString = this.toQueryString(rawQuery); + return queryString ? `?${queryString}` : ""; + } + + private contentFormatters: Record any> = { + [ContentType.Json]: (input: any) => + input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input, + [ContentType.FormData]: (input: any) => + Object.keys(input || {}).reduce((data, key) => { + data.append(key, input[key]); + return data; + }, new FormData()), + [ContentType.UrlEncoded]: (input: any) => this.toQueryString(input), + }; + + private mergeRequestParams(params1: RequestParams, params2?: RequestParams): RequestParams { + return { + ...this.baseApiParams, + ...params1, + ...(params2 || {}), + headers: { + ...(this.baseApiParams.headers || {}), + ...(params1.headers || {}), + ...((params2 && params2.headers) || {}), + }, + }; + } + + private createAbortSignal = (cancelToken: CancelToken): AbortSignal | undefined => { + if (this.abortControllers.has(cancelToken)) { + const abortController = this.abortControllers.get(cancelToken); + if (abortController) { + return abortController.signal; + } + return void 0; + } + + const abortController = new AbortController(); + this.abortControllers.set(cancelToken, abortController); + return abortController.signal; + }; + + public abortRequest = (cancelToken: CancelToken) => { + const abortController = this.abortControllers.get(cancelToken); + + if (abortController) { + abortController.abort(); + this.abortControllers.delete(cancelToken); + } + }; + + public request = ({ + body, + secure, + path, + type, + query, + format = "json", + baseUrl, + cancelToken, + ...params + }: FullRequestParams): Promise> => { + const secureParams = (secure && this.securityWorker && this.securityWorker(this.securityData)) || {}; + const requestParams = this.mergeRequestParams(params, secureParams); + const queryString = query && this.toQueryString(query); + const payloadFormatter = this.contentFormatters[type || ContentType.Json]; + + return fetch(`${baseUrl || this.baseUrl || ""}${path}${queryString ? `?${queryString}` : ""}`, { + ...requestParams, + headers: { + ...(type && type !== ContentType.FormData ? { "Content-Type": type } : {}), + ...(requestParams.headers || {}), + }, + signal: cancelToken ? this.createAbortSignal(cancelToken) : void 0, + body: typeof body === "undefined" || body === null ? null : payloadFormatter(body), + }).then(async (response) => { + const r = response as HttpResponse; + r.data = (null as unknown) as T; + r.error = (null as unknown) as E; + + const data = await response[format]() + .then((data) => { + if (r.ok) { + r.data = data; + } else { + r.error = data; + } + return r; + }) + .catch((e) => { + r.error = e; + return r; + }); + + if (cancelToken) { + this.abortControllers.delete(cancelToken); + } + + if (!response.ok) throw data; + return data; + }); + }; +} + +/** + * @title cosmos/authz/v1beta1/authz.proto + * @version version not set + */ +export class Api extends HttpClient { + /** + * No description + * + * @tags Query + * @name QueryGrants + * @summary Returns list of `Authorization`, granted to the grantee by the granter. + * @request GET:/cosmos/authz/v1beta1/grants + */ + queryGrants = ( + query?: { + granter?: string; + grantee?: string; + msg_type_url?: string; + "pagination.key"?: string; + "pagination.offset"?: string; + "pagination.limit"?: string; + "pagination.count_total"?: boolean; + "pagination.reverse"?: boolean; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/cosmos/authz/v1beta1/grants`, + method: "GET", + query: query, + format: "json", + ...params, + }); + + /** + * @description Since: cosmos-sdk 0.45.2 + * + * @tags Query + * @name QueryGranteeGrants + * @summary GranteeGrants returns a list of `GrantAuthorization` by grantee. + * @request GET:/cosmos/authz/v1beta1/grants/grantee/{grantee} + */ + queryGranteeGrants = ( + grantee: string, + query?: { + "pagination.key"?: string; + "pagination.offset"?: string; + "pagination.limit"?: string; + "pagination.count_total"?: boolean; + "pagination.reverse"?: boolean; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/cosmos/authz/v1beta1/grants/grantee/${grantee}`, + method: "GET", + query: query, + format: "json", + ...params, + }); + + /** + * @description Since: cosmos-sdk 0.45.2 + * + * @tags Query + * @name QueryGranterGrants + * @summary GranterGrants returns list of `GrantAuthorization`, granted by granter. + * @request GET:/cosmos/authz/v1beta1/grants/granter/{granter} + */ + queryGranterGrants = ( + granter: string, + query?: { + "pagination.key"?: string; + "pagination.offset"?: string; + "pagination.limit"?: string; + "pagination.count_total"?: boolean; + "pagination.reverse"?: boolean; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/cosmos/authz/v1beta1/grants/granter/${granter}`, + method: "GET", + query: query, + format: "json", + ...params, + }); +} diff --git a/ts-client/cosmos.authz.v1beta1/types.ts b/ts-client/cosmos.authz.v1beta1/types.ts new file mode 100755 index 00000000..1d7fad3c --- /dev/null +++ b/ts-client/cosmos.authz.v1beta1/types.ts @@ -0,0 +1,15 @@ +import { GenericAuthorization } from "./types/cosmos/authz/v1beta1/authz" +import { Grant } from "./types/cosmos/authz/v1beta1/authz" +import { GrantAuthorization } from "./types/cosmos/authz/v1beta1/authz" +import { EventGrant } from "./types/cosmos/authz/v1beta1/event" +import { EventRevoke } from "./types/cosmos/authz/v1beta1/event" + + +export { + GenericAuthorization, + Grant, + GrantAuthorization, + EventGrant, + EventRevoke, + + } \ No newline at end of file diff --git a/ts-client/cosmos.authz.v1beta1/types/cosmos/authz/v1beta1/authz.ts b/ts-client/cosmos.authz.v1beta1/types/cosmos/authz/v1beta1/authz.ts new file mode 100644 index 00000000..8cb25514 --- /dev/null +++ b/ts-client/cosmos.authz.v1beta1/types/cosmos/authz/v1beta1/authz.ts @@ -0,0 +1,335 @@ +/* eslint-disable */ +import { Timestamp } from "../../../google/protobuf/timestamp"; +import { Any } from "../../../google/protobuf/any"; +import { Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "cosmos.authz.v1beta1"; + +/** Since: cosmos-sdk 0.43 */ + +/** + * GenericAuthorization gives the grantee unrestricted permissions to execute + * the provided method on behalf of the granter's account. + */ +export interface GenericAuthorization { + /** Msg, identified by it's type URL, to grant unrestricted permissions to execute */ + msg: string; +} + +/** + * Grant gives permissions to execute + * the provide method with expiration time. + */ +export interface Grant { + authorization: Any | undefined; + expiration: Date | undefined; +} + +/** + * GrantAuthorization extends a grant with both the addresses of the grantee and granter. + * It is used in genesis.proto and query.proto + * + * Since: cosmos-sdk 0.45.2 + */ +export interface GrantAuthorization { + granter: string; + grantee: string; + authorization: Any | undefined; + expiration: Date | undefined; +} + +const baseGenericAuthorization: object = { msg: "" }; + +export const GenericAuthorization = { + encode( + message: GenericAuthorization, + writer: Writer = Writer.create() + ): Writer { + if (message.msg !== "") { + writer.uint32(10).string(message.msg); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): GenericAuthorization { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseGenericAuthorization } as GenericAuthorization; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.msg = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GenericAuthorization { + const message = { ...baseGenericAuthorization } as GenericAuthorization; + if (object.msg !== undefined && object.msg !== null) { + message.msg = String(object.msg); + } else { + message.msg = ""; + } + return message; + }, + + toJSON(message: GenericAuthorization): unknown { + const obj: any = {}; + message.msg !== undefined && (obj.msg = message.msg); + return obj; + }, + + fromPartial(object: DeepPartial): GenericAuthorization { + const message = { ...baseGenericAuthorization } as GenericAuthorization; + if (object.msg !== undefined && object.msg !== null) { + message.msg = object.msg; + } else { + message.msg = ""; + } + return message; + }, +}; + +const baseGrant: object = {}; + +export const Grant = { + encode(message: Grant, writer: Writer = Writer.create()): Writer { + if (message.authorization !== undefined) { + Any.encode(message.authorization, writer.uint32(10).fork()).ldelim(); + } + if (message.expiration !== undefined) { + Timestamp.encode( + toTimestamp(message.expiration), + writer.uint32(18).fork() + ).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Grant { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseGrant } as Grant; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.authorization = Any.decode(reader, reader.uint32()); + break; + case 2: + message.expiration = fromTimestamp( + Timestamp.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Grant { + const message = { ...baseGrant } as Grant; + if (object.authorization !== undefined && object.authorization !== null) { + message.authorization = Any.fromJSON(object.authorization); + } else { + message.authorization = undefined; + } + if (object.expiration !== undefined && object.expiration !== null) { + message.expiration = fromJsonTimestamp(object.expiration); + } else { + message.expiration = undefined; + } + return message; + }, + + toJSON(message: Grant): unknown { + const obj: any = {}; + message.authorization !== undefined && + (obj.authorization = message.authorization + ? Any.toJSON(message.authorization) + : undefined); + message.expiration !== undefined && + (obj.expiration = + message.expiration !== undefined + ? message.expiration.toISOString() + : null); + return obj; + }, + + fromPartial(object: DeepPartial): Grant { + const message = { ...baseGrant } as Grant; + if (object.authorization !== undefined && object.authorization !== null) { + message.authorization = Any.fromPartial(object.authorization); + } else { + message.authorization = undefined; + } + if (object.expiration !== undefined && object.expiration !== null) { + message.expiration = object.expiration; + } else { + message.expiration = undefined; + } + return message; + }, +}; + +const baseGrantAuthorization: object = { granter: "", grantee: "" }; + +export const GrantAuthorization = { + encode( + message: GrantAuthorization, + writer: Writer = Writer.create() + ): Writer { + if (message.granter !== "") { + writer.uint32(10).string(message.granter); + } + if (message.grantee !== "") { + writer.uint32(18).string(message.grantee); + } + if (message.authorization !== undefined) { + Any.encode(message.authorization, writer.uint32(26).fork()).ldelim(); + } + if (message.expiration !== undefined) { + Timestamp.encode( + toTimestamp(message.expiration), + writer.uint32(34).fork() + ).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): GrantAuthorization { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseGrantAuthorization } as GrantAuthorization; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.granter = reader.string(); + break; + case 2: + message.grantee = reader.string(); + break; + case 3: + message.authorization = Any.decode(reader, reader.uint32()); + break; + case 4: + message.expiration = fromTimestamp( + Timestamp.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GrantAuthorization { + const message = { ...baseGrantAuthorization } as GrantAuthorization; + if (object.granter !== undefined && object.granter !== null) { + message.granter = String(object.granter); + } else { + message.granter = ""; + } + if (object.grantee !== undefined && object.grantee !== null) { + message.grantee = String(object.grantee); + } else { + message.grantee = ""; + } + if (object.authorization !== undefined && object.authorization !== null) { + message.authorization = Any.fromJSON(object.authorization); + } else { + message.authorization = undefined; + } + if (object.expiration !== undefined && object.expiration !== null) { + message.expiration = fromJsonTimestamp(object.expiration); + } else { + message.expiration = undefined; + } + return message; + }, + + toJSON(message: GrantAuthorization): unknown { + const obj: any = {}; + message.granter !== undefined && (obj.granter = message.granter); + message.grantee !== undefined && (obj.grantee = message.grantee); + message.authorization !== undefined && + (obj.authorization = message.authorization + ? Any.toJSON(message.authorization) + : undefined); + message.expiration !== undefined && + (obj.expiration = + message.expiration !== undefined + ? message.expiration.toISOString() + : null); + return obj; + }, + + fromPartial(object: DeepPartial): GrantAuthorization { + const message = { ...baseGrantAuthorization } as GrantAuthorization; + if (object.granter !== undefined && object.granter !== null) { + message.granter = object.granter; + } else { + message.granter = ""; + } + if (object.grantee !== undefined && object.grantee !== null) { + message.grantee = object.grantee; + } else { + message.grantee = ""; + } + if (object.authorization !== undefined && object.authorization !== null) { + message.authorization = Any.fromPartial(object.authorization); + } else { + message.authorization = undefined; + } + if (object.expiration !== undefined && object.expiration !== null) { + message.expiration = object.expiration; + } else { + message.expiration = undefined; + } + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function toTimestamp(date: Date): Timestamp { + const seconds = date.getTime() / 1_000; + const nanos = (date.getTime() % 1_000) * 1_000_000; + return { seconds, nanos }; +} + +function fromTimestamp(t: Timestamp): Date { + let millis = t.seconds * 1_000; + millis += t.nanos / 1_000_000; + return new Date(millis); +} + +function fromJsonTimestamp(o: any): Date { + if (o instanceof Date) { + return o; + } else if (typeof o === "string") { + return new Date(o); + } else { + return fromTimestamp(Timestamp.fromJSON(o)); + } +} diff --git a/ts-client/cosmos.authz.v1beta1/types/cosmos/authz/v1beta1/event.ts b/ts-client/cosmos.authz.v1beta1/types/cosmos/authz/v1beta1/event.ts new file mode 100644 index 00000000..bc8aecd0 --- /dev/null +++ b/ts-client/cosmos.authz.v1beta1/types/cosmos/authz/v1beta1/event.ts @@ -0,0 +1,215 @@ +/* eslint-disable */ +import { Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "cosmos.authz.v1beta1"; + +/** Since: cosmos-sdk 0.43 */ + +/** EventGrant is emitted on Msg/Grant */ +export interface EventGrant { + /** Msg type URL for which an autorization is granted */ + msgTypeUrl: string; + /** Granter account address */ + granter: string; + /** Grantee account address */ + grantee: string; +} + +/** EventRevoke is emitted on Msg/Revoke */ +export interface EventRevoke { + /** Msg type URL for which an autorization is revoked */ + msgTypeUrl: string; + /** Granter account address */ + granter: string; + /** Grantee account address */ + grantee: string; +} + +const baseEventGrant: object = { msgTypeUrl: "", granter: "", grantee: "" }; + +export const EventGrant = { + encode(message: EventGrant, writer: Writer = Writer.create()): Writer { + if (message.msgTypeUrl !== "") { + writer.uint32(18).string(message.msgTypeUrl); + } + if (message.granter !== "") { + writer.uint32(26).string(message.granter); + } + if (message.grantee !== "") { + writer.uint32(34).string(message.grantee); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): EventGrant { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseEventGrant } as EventGrant; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + message.msgTypeUrl = reader.string(); + break; + case 3: + message.granter = reader.string(); + break; + case 4: + message.grantee = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EventGrant { + const message = { ...baseEventGrant } as EventGrant; + if (object.msgTypeUrl !== undefined && object.msgTypeUrl !== null) { + message.msgTypeUrl = String(object.msgTypeUrl); + } else { + message.msgTypeUrl = ""; + } + if (object.granter !== undefined && object.granter !== null) { + message.granter = String(object.granter); + } else { + message.granter = ""; + } + if (object.grantee !== undefined && object.grantee !== null) { + message.grantee = String(object.grantee); + } else { + message.grantee = ""; + } + return message; + }, + + toJSON(message: EventGrant): unknown { + const obj: any = {}; + message.msgTypeUrl !== undefined && (obj.msgTypeUrl = message.msgTypeUrl); + message.granter !== undefined && (obj.granter = message.granter); + message.grantee !== undefined && (obj.grantee = message.grantee); + return obj; + }, + + fromPartial(object: DeepPartial): EventGrant { + const message = { ...baseEventGrant } as EventGrant; + if (object.msgTypeUrl !== undefined && object.msgTypeUrl !== null) { + message.msgTypeUrl = object.msgTypeUrl; + } else { + message.msgTypeUrl = ""; + } + if (object.granter !== undefined && object.granter !== null) { + message.granter = object.granter; + } else { + message.granter = ""; + } + if (object.grantee !== undefined && object.grantee !== null) { + message.grantee = object.grantee; + } else { + message.grantee = ""; + } + return message; + }, +}; + +const baseEventRevoke: object = { msgTypeUrl: "", granter: "", grantee: "" }; + +export const EventRevoke = { + encode(message: EventRevoke, writer: Writer = Writer.create()): Writer { + if (message.msgTypeUrl !== "") { + writer.uint32(18).string(message.msgTypeUrl); + } + if (message.granter !== "") { + writer.uint32(26).string(message.granter); + } + if (message.grantee !== "") { + writer.uint32(34).string(message.grantee); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): EventRevoke { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseEventRevoke } as EventRevoke; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + message.msgTypeUrl = reader.string(); + break; + case 3: + message.granter = reader.string(); + break; + case 4: + message.grantee = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EventRevoke { + const message = { ...baseEventRevoke } as EventRevoke; + if (object.msgTypeUrl !== undefined && object.msgTypeUrl !== null) { + message.msgTypeUrl = String(object.msgTypeUrl); + } else { + message.msgTypeUrl = ""; + } + if (object.granter !== undefined && object.granter !== null) { + message.granter = String(object.granter); + } else { + message.granter = ""; + } + if (object.grantee !== undefined && object.grantee !== null) { + message.grantee = String(object.grantee); + } else { + message.grantee = ""; + } + return message; + }, + + toJSON(message: EventRevoke): unknown { + const obj: any = {}; + message.msgTypeUrl !== undefined && (obj.msgTypeUrl = message.msgTypeUrl); + message.granter !== undefined && (obj.granter = message.granter); + message.grantee !== undefined && (obj.grantee = message.grantee); + return obj; + }, + + fromPartial(object: DeepPartial): EventRevoke { + const message = { ...baseEventRevoke } as EventRevoke; + if (object.msgTypeUrl !== undefined && object.msgTypeUrl !== null) { + message.msgTypeUrl = object.msgTypeUrl; + } else { + message.msgTypeUrl = ""; + } + if (object.granter !== undefined && object.granter !== null) { + message.granter = object.granter; + } else { + message.granter = ""; + } + if (object.grantee !== undefined && object.grantee !== null) { + message.grantee = object.grantee; + } else { + message.grantee = ""; + } + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/cosmos.authz.v1beta1/types/cosmos/authz/v1beta1/genesis.ts b/ts-client/cosmos.authz.v1beta1/types/cosmos/authz/v1beta1/genesis.ts new file mode 100644 index 00000000..ae07db55 --- /dev/null +++ b/ts-client/cosmos.authz.v1beta1/types/cosmos/authz/v1beta1/genesis.ts @@ -0,0 +1,89 @@ +/* eslint-disable */ +import { GrantAuthorization } from "../../../cosmos/authz/v1beta1/authz"; +import { Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "cosmos.authz.v1beta1"; + +/** Since: cosmos-sdk 0.43 */ + +/** GenesisState defines the authz module's genesis state. */ +export interface GenesisState { + authorization: GrantAuthorization[]; +} + +const baseGenesisState: object = {}; + +export const GenesisState = { + encode(message: GenesisState, writer: Writer = Writer.create()): Writer { + for (const v of message.authorization) { + GrantAuthorization.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): GenesisState { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseGenesisState } as GenesisState; + message.authorization = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.authorization.push( + GrantAuthorization.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GenesisState { + const message = { ...baseGenesisState } as GenesisState; + message.authorization = []; + if (object.authorization !== undefined && object.authorization !== null) { + for (const e of object.authorization) { + message.authorization.push(GrantAuthorization.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: GenesisState): unknown { + const obj: any = {}; + if (message.authorization) { + obj.authorization = message.authorization.map((e) => + e ? GrantAuthorization.toJSON(e) : undefined + ); + } else { + obj.authorization = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): GenesisState { + const message = { ...baseGenesisState } as GenesisState; + message.authorization = []; + if (object.authorization !== undefined && object.authorization !== null) { + for (const e of object.authorization) { + message.authorization.push(GrantAuthorization.fromPartial(e)); + } + } + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/cosmos.authz.v1beta1/types/cosmos/authz/v1beta1/query.ts b/ts-client/cosmos.authz.v1beta1/types/cosmos/authz/v1beta1/query.ts new file mode 100644 index 00000000..0abee77d --- /dev/null +++ b/ts-client/cosmos.authz.v1beta1/types/cosmos/authz/v1beta1/query.ts @@ -0,0 +1,732 @@ +/* eslint-disable */ +import { Reader, Writer } from "protobufjs/minimal"; +import { + PageRequest, + PageResponse, +} from "../../../cosmos/base/query/v1beta1/pagination"; +import { Grant, GrantAuthorization } from "../../../cosmos/authz/v1beta1/authz"; + +export const protobufPackage = "cosmos.authz.v1beta1"; + +/** Since: cosmos-sdk 0.43 */ + +/** QueryGrantsRequest is the request type for the Query/Grants RPC method. */ +export interface QueryGrantsRequest { + granter: string; + grantee: string; + /** Optional, msg_type_url, when set, will query only grants matching given msg type. */ + msgTypeUrl: string; + /** pagination defines an pagination for the request. */ + pagination: PageRequest | undefined; +} + +/** QueryGrantsResponse is the response type for the Query/Authorizations RPC method. */ +export interface QueryGrantsResponse { + /** authorizations is a list of grants granted for grantee by granter. */ + grants: Grant[]; + /** pagination defines an pagination for the response. */ + pagination: PageResponse | undefined; +} + +/** QueryGranterGrantsRequest is the request type for the Query/GranterGrants RPC method. */ +export interface QueryGranterGrantsRequest { + granter: string; + /** pagination defines an pagination for the request. */ + pagination: PageRequest | undefined; +} + +/** QueryGranterGrantsResponse is the response type for the Query/GranterGrants RPC method. */ +export interface QueryGranterGrantsResponse { + /** grants is a list of grants granted by the granter. */ + grants: GrantAuthorization[]; + /** pagination defines an pagination for the response. */ + pagination: PageResponse | undefined; +} + +/** QueryGranteeGrantsRequest is the request type for the Query/IssuedGrants RPC method. */ +export interface QueryGranteeGrantsRequest { + grantee: string; + /** pagination defines an pagination for the request. */ + pagination: PageRequest | undefined; +} + +/** QueryGranteeGrantsResponse is the response type for the Query/GranteeGrants RPC method. */ +export interface QueryGranteeGrantsResponse { + /** grants is a list of grants granted to the grantee. */ + grants: GrantAuthorization[]; + /** pagination defines an pagination for the response. */ + pagination: PageResponse | undefined; +} + +const baseQueryGrantsRequest: object = { + granter: "", + grantee: "", + msgTypeUrl: "", +}; + +export const QueryGrantsRequest = { + encode( + message: QueryGrantsRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.granter !== "") { + writer.uint32(10).string(message.granter); + } + if (message.grantee !== "") { + writer.uint32(18).string(message.grantee); + } + if (message.msgTypeUrl !== "") { + writer.uint32(26).string(message.msgTypeUrl); + } + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(34).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QueryGrantsRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryGrantsRequest } as QueryGrantsRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.granter = reader.string(); + break; + case 2: + message.grantee = reader.string(); + break; + case 3: + message.msgTypeUrl = reader.string(); + break; + case 4: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryGrantsRequest { + const message = { ...baseQueryGrantsRequest } as QueryGrantsRequest; + if (object.granter !== undefined && object.granter !== null) { + message.granter = String(object.granter); + } else { + message.granter = ""; + } + if (object.grantee !== undefined && object.grantee !== null) { + message.grantee = String(object.grantee); + } else { + message.grantee = ""; + } + if (object.msgTypeUrl !== undefined && object.msgTypeUrl !== null) { + message.msgTypeUrl = String(object.msgTypeUrl); + } else { + message.msgTypeUrl = ""; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryGrantsRequest): unknown { + const obj: any = {}; + message.granter !== undefined && (obj.granter = message.granter); + message.grantee !== undefined && (obj.grantee = message.grantee); + message.msgTypeUrl !== undefined && (obj.msgTypeUrl = message.msgTypeUrl); + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageRequest.toJSON(message.pagination) + : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): QueryGrantsRequest { + const message = { ...baseQueryGrantsRequest } as QueryGrantsRequest; + if (object.granter !== undefined && object.granter !== null) { + message.granter = object.granter; + } else { + message.granter = ""; + } + if (object.grantee !== undefined && object.grantee !== null) { + message.grantee = object.grantee; + } else { + message.grantee = ""; + } + if (object.msgTypeUrl !== undefined && object.msgTypeUrl !== null) { + message.msgTypeUrl = object.msgTypeUrl; + } else { + message.msgTypeUrl = ""; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseQueryGrantsResponse: object = {}; + +export const QueryGrantsResponse = { + encode( + message: QueryGrantsResponse, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.grants) { + Grant.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode( + message.pagination, + writer.uint32(18).fork() + ).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QueryGrantsResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryGrantsResponse } as QueryGrantsResponse; + message.grants = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.grants.push(Grant.decode(reader, reader.uint32())); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryGrantsResponse { + const message = { ...baseQueryGrantsResponse } as QueryGrantsResponse; + message.grants = []; + if (object.grants !== undefined && object.grants !== null) { + for (const e of object.grants) { + message.grants.push(Grant.fromJSON(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryGrantsResponse): unknown { + const obj: any = {}; + if (message.grants) { + obj.grants = message.grants.map((e) => (e ? Grant.toJSON(e) : undefined)); + } else { + obj.grants = []; + } + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageResponse.toJSON(message.pagination) + : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): QueryGrantsResponse { + const message = { ...baseQueryGrantsResponse } as QueryGrantsResponse; + message.grants = []; + if (object.grants !== undefined && object.grants !== null) { + for (const e of object.grants) { + message.grants.push(Grant.fromPartial(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseQueryGranterGrantsRequest: object = { granter: "" }; + +export const QueryGranterGrantsRequest = { + encode( + message: QueryGranterGrantsRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.granter !== "") { + writer.uint32(10).string(message.granter); + } + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryGranterGrantsRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryGranterGrantsRequest, + } as QueryGranterGrantsRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.granter = reader.string(); + break; + case 2: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryGranterGrantsRequest { + const message = { + ...baseQueryGranterGrantsRequest, + } as QueryGranterGrantsRequest; + if (object.granter !== undefined && object.granter !== null) { + message.granter = String(object.granter); + } else { + message.granter = ""; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryGranterGrantsRequest): unknown { + const obj: any = {}; + message.granter !== undefined && (obj.granter = message.granter); + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageRequest.toJSON(message.pagination) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryGranterGrantsRequest { + const message = { + ...baseQueryGranterGrantsRequest, + } as QueryGranterGrantsRequest; + if (object.granter !== undefined && object.granter !== null) { + message.granter = object.granter; + } else { + message.granter = ""; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseQueryGranterGrantsResponse: object = {}; + +export const QueryGranterGrantsResponse = { + encode( + message: QueryGranterGrantsResponse, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.grants) { + GrantAuthorization.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode( + message.pagination, + writer.uint32(18).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryGranterGrantsResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryGranterGrantsResponse, + } as QueryGranterGrantsResponse; + message.grants = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.grants.push( + GrantAuthorization.decode(reader, reader.uint32()) + ); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryGranterGrantsResponse { + const message = { + ...baseQueryGranterGrantsResponse, + } as QueryGranterGrantsResponse; + message.grants = []; + if (object.grants !== undefined && object.grants !== null) { + for (const e of object.grants) { + message.grants.push(GrantAuthorization.fromJSON(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryGranterGrantsResponse): unknown { + const obj: any = {}; + if (message.grants) { + obj.grants = message.grants.map((e) => + e ? GrantAuthorization.toJSON(e) : undefined + ); + } else { + obj.grants = []; + } + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageResponse.toJSON(message.pagination) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryGranterGrantsResponse { + const message = { + ...baseQueryGranterGrantsResponse, + } as QueryGranterGrantsResponse; + message.grants = []; + if (object.grants !== undefined && object.grants !== null) { + for (const e of object.grants) { + message.grants.push(GrantAuthorization.fromPartial(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseQueryGranteeGrantsRequest: object = { grantee: "" }; + +export const QueryGranteeGrantsRequest = { + encode( + message: QueryGranteeGrantsRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.grantee !== "") { + writer.uint32(10).string(message.grantee); + } + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryGranteeGrantsRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryGranteeGrantsRequest, + } as QueryGranteeGrantsRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.grantee = reader.string(); + break; + case 2: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryGranteeGrantsRequest { + const message = { + ...baseQueryGranteeGrantsRequest, + } as QueryGranteeGrantsRequest; + if (object.grantee !== undefined && object.grantee !== null) { + message.grantee = String(object.grantee); + } else { + message.grantee = ""; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryGranteeGrantsRequest): unknown { + const obj: any = {}; + message.grantee !== undefined && (obj.grantee = message.grantee); + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageRequest.toJSON(message.pagination) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryGranteeGrantsRequest { + const message = { + ...baseQueryGranteeGrantsRequest, + } as QueryGranteeGrantsRequest; + if (object.grantee !== undefined && object.grantee !== null) { + message.grantee = object.grantee; + } else { + message.grantee = ""; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseQueryGranteeGrantsResponse: object = {}; + +export const QueryGranteeGrantsResponse = { + encode( + message: QueryGranteeGrantsResponse, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.grants) { + GrantAuthorization.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode( + message.pagination, + writer.uint32(18).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryGranteeGrantsResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryGranteeGrantsResponse, + } as QueryGranteeGrantsResponse; + message.grants = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.grants.push( + GrantAuthorization.decode(reader, reader.uint32()) + ); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryGranteeGrantsResponse { + const message = { + ...baseQueryGranteeGrantsResponse, + } as QueryGranteeGrantsResponse; + message.grants = []; + if (object.grants !== undefined && object.grants !== null) { + for (const e of object.grants) { + message.grants.push(GrantAuthorization.fromJSON(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryGranteeGrantsResponse): unknown { + const obj: any = {}; + if (message.grants) { + obj.grants = message.grants.map((e) => + e ? GrantAuthorization.toJSON(e) : undefined + ); + } else { + obj.grants = []; + } + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageResponse.toJSON(message.pagination) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryGranteeGrantsResponse { + const message = { + ...baseQueryGranteeGrantsResponse, + } as QueryGranteeGrantsResponse; + message.grants = []; + if (object.grants !== undefined && object.grants !== null) { + for (const e of object.grants) { + message.grants.push(GrantAuthorization.fromPartial(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +/** Query defines the gRPC querier service. */ +export interface Query { + /** Returns list of `Authorization`, granted to the grantee by the granter. */ + Grants(request: QueryGrantsRequest): Promise; + /** + * GranterGrants returns list of `GrantAuthorization`, granted by granter. + * + * Since: cosmos-sdk 0.45.2 + */ + GranterGrants( + request: QueryGranterGrantsRequest + ): Promise; + /** + * GranteeGrants returns a list of `GrantAuthorization` by grantee. + * + * Since: cosmos-sdk 0.45.2 + */ + GranteeGrants( + request: QueryGranteeGrantsRequest + ): Promise; +} + +export class QueryClientImpl implements Query { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + } + Grants(request: QueryGrantsRequest): Promise { + const data = QueryGrantsRequest.encode(request).finish(); + const promise = this.rpc.request( + "cosmos.authz.v1beta1.Query", + "Grants", + data + ); + return promise.then((data) => QueryGrantsResponse.decode(new Reader(data))); + } + + GranterGrants( + request: QueryGranterGrantsRequest + ): Promise { + const data = QueryGranterGrantsRequest.encode(request).finish(); + const promise = this.rpc.request( + "cosmos.authz.v1beta1.Query", + "GranterGrants", + data + ); + return promise.then((data) => + QueryGranterGrantsResponse.decode(new Reader(data)) + ); + } + + GranteeGrants( + request: QueryGranteeGrantsRequest + ): Promise { + const data = QueryGranteeGrantsRequest.encode(request).finish(); + const promise = this.rpc.request( + "cosmos.authz.v1beta1.Query", + "GranteeGrants", + data + ); + return promise.then((data) => + QueryGranteeGrantsResponse.decode(new Reader(data)) + ); + } +} + +interface Rpc { + request( + service: string, + method: string, + data: Uint8Array + ): Promise; +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/cosmos.authz.v1beta1/types/cosmos/authz/v1beta1/tx.ts b/ts-client/cosmos.authz.v1beta1/types/cosmos/authz/v1beta1/tx.ts new file mode 100644 index 00000000..7419f46d --- /dev/null +++ b/ts-client/cosmos.authz.v1beta1/types/cosmos/authz/v1beta1/tx.ts @@ -0,0 +1,554 @@ +/* eslint-disable */ +import { Reader, Writer } from "protobufjs/minimal"; +import { Grant } from "../../../cosmos/authz/v1beta1/authz"; +import { Any } from "../../../google/protobuf/any"; + +export const protobufPackage = "cosmos.authz.v1beta1"; + +/** Since: cosmos-sdk 0.43 */ + +/** + * MsgGrant is a request type for Grant method. It declares authorization to the grantee + * on behalf of the granter with the provided expiration time. + */ +export interface MsgGrant { + granter: string; + grantee: string; + grant: Grant | undefined; +} + +/** MsgExecResponse defines the Msg/MsgExecResponse response type. */ +export interface MsgExecResponse { + results: Uint8Array[]; +} + +/** + * MsgExec attempts to execute the provided messages using + * authorizations granted to the grantee. Each message should have only + * one signer corresponding to the granter of the authorization. + */ +export interface MsgExec { + grantee: string; + /** + * Authorization Msg requests to execute. Each msg must implement Authorization interface + * The x/authz will try to find a grant matching (msg.signers[0], grantee, MsgTypeURL(msg)) + * triple and validate it. + */ + msgs: Any[]; +} + +/** MsgGrantResponse defines the Msg/MsgGrant response type. */ +export interface MsgGrantResponse {} + +/** + * MsgRevoke revokes any authorization with the provided sdk.Msg type on the + * granter's account with that has been granted to the grantee. + */ +export interface MsgRevoke { + granter: string; + grantee: string; + msgTypeUrl: string; +} + +/** MsgRevokeResponse defines the Msg/MsgRevokeResponse response type. */ +export interface MsgRevokeResponse {} + +const baseMsgGrant: object = { granter: "", grantee: "" }; + +export const MsgGrant = { + encode(message: MsgGrant, writer: Writer = Writer.create()): Writer { + if (message.granter !== "") { + writer.uint32(10).string(message.granter); + } + if (message.grantee !== "") { + writer.uint32(18).string(message.grantee); + } + if (message.grant !== undefined) { + Grant.encode(message.grant, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MsgGrant { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgGrant } as MsgGrant; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.granter = reader.string(); + break; + case 2: + message.grantee = reader.string(); + break; + case 3: + message.grant = Grant.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgGrant { + const message = { ...baseMsgGrant } as MsgGrant; + if (object.granter !== undefined && object.granter !== null) { + message.granter = String(object.granter); + } else { + message.granter = ""; + } + if (object.grantee !== undefined && object.grantee !== null) { + message.grantee = String(object.grantee); + } else { + message.grantee = ""; + } + if (object.grant !== undefined && object.grant !== null) { + message.grant = Grant.fromJSON(object.grant); + } else { + message.grant = undefined; + } + return message; + }, + + toJSON(message: MsgGrant): unknown { + const obj: any = {}; + message.granter !== undefined && (obj.granter = message.granter); + message.grantee !== undefined && (obj.grantee = message.grantee); + message.grant !== undefined && + (obj.grant = message.grant ? Grant.toJSON(message.grant) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): MsgGrant { + const message = { ...baseMsgGrant } as MsgGrant; + if (object.granter !== undefined && object.granter !== null) { + message.granter = object.granter; + } else { + message.granter = ""; + } + if (object.grantee !== undefined && object.grantee !== null) { + message.grantee = object.grantee; + } else { + message.grantee = ""; + } + if (object.grant !== undefined && object.grant !== null) { + message.grant = Grant.fromPartial(object.grant); + } else { + message.grant = undefined; + } + return message; + }, +}; + +const baseMsgExecResponse: object = {}; + +export const MsgExecResponse = { + encode(message: MsgExecResponse, writer: Writer = Writer.create()): Writer { + for (const v of message.results) { + writer.uint32(10).bytes(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MsgExecResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgExecResponse } as MsgExecResponse; + message.results = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.results.push(reader.bytes()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgExecResponse { + const message = { ...baseMsgExecResponse } as MsgExecResponse; + message.results = []; + if (object.results !== undefined && object.results !== null) { + for (const e of object.results) { + message.results.push(bytesFromBase64(e)); + } + } + return message; + }, + + toJSON(message: MsgExecResponse): unknown { + const obj: any = {}; + if (message.results) { + obj.results = message.results.map((e) => + base64FromBytes(e !== undefined ? e : new Uint8Array()) + ); + } else { + obj.results = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): MsgExecResponse { + const message = { ...baseMsgExecResponse } as MsgExecResponse; + message.results = []; + if (object.results !== undefined && object.results !== null) { + for (const e of object.results) { + message.results.push(e); + } + } + return message; + }, +}; + +const baseMsgExec: object = { grantee: "" }; + +export const MsgExec = { + encode(message: MsgExec, writer: Writer = Writer.create()): Writer { + if (message.grantee !== "") { + writer.uint32(10).string(message.grantee); + } + for (const v of message.msgs) { + Any.encode(v!, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MsgExec { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgExec } as MsgExec; + message.msgs = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.grantee = reader.string(); + break; + case 2: + message.msgs.push(Any.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgExec { + const message = { ...baseMsgExec } as MsgExec; + message.msgs = []; + if (object.grantee !== undefined && object.grantee !== null) { + message.grantee = String(object.grantee); + } else { + message.grantee = ""; + } + if (object.msgs !== undefined && object.msgs !== null) { + for (const e of object.msgs) { + message.msgs.push(Any.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: MsgExec): unknown { + const obj: any = {}; + message.grantee !== undefined && (obj.grantee = message.grantee); + if (message.msgs) { + obj.msgs = message.msgs.map((e) => (e ? Any.toJSON(e) : undefined)); + } else { + obj.msgs = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): MsgExec { + const message = { ...baseMsgExec } as MsgExec; + message.msgs = []; + if (object.grantee !== undefined && object.grantee !== null) { + message.grantee = object.grantee; + } else { + message.grantee = ""; + } + if (object.msgs !== undefined && object.msgs !== null) { + for (const e of object.msgs) { + message.msgs.push(Any.fromPartial(e)); + } + } + return message; + }, +}; + +const baseMsgGrantResponse: object = {}; + +export const MsgGrantResponse = { + encode(_: MsgGrantResponse, writer: Writer = Writer.create()): Writer { + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MsgGrantResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgGrantResponse } as MsgGrantResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): MsgGrantResponse { + const message = { ...baseMsgGrantResponse } as MsgGrantResponse; + return message; + }, + + toJSON(_: MsgGrantResponse): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial(_: DeepPartial): MsgGrantResponse { + const message = { ...baseMsgGrantResponse } as MsgGrantResponse; + return message; + }, +}; + +const baseMsgRevoke: object = { granter: "", grantee: "", msgTypeUrl: "" }; + +export const MsgRevoke = { + encode(message: MsgRevoke, writer: Writer = Writer.create()): Writer { + if (message.granter !== "") { + writer.uint32(10).string(message.granter); + } + if (message.grantee !== "") { + writer.uint32(18).string(message.grantee); + } + if (message.msgTypeUrl !== "") { + writer.uint32(26).string(message.msgTypeUrl); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MsgRevoke { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgRevoke } as MsgRevoke; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.granter = reader.string(); + break; + case 2: + message.grantee = reader.string(); + break; + case 3: + message.msgTypeUrl = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgRevoke { + const message = { ...baseMsgRevoke } as MsgRevoke; + if (object.granter !== undefined && object.granter !== null) { + message.granter = String(object.granter); + } else { + message.granter = ""; + } + if (object.grantee !== undefined && object.grantee !== null) { + message.grantee = String(object.grantee); + } else { + message.grantee = ""; + } + if (object.msgTypeUrl !== undefined && object.msgTypeUrl !== null) { + message.msgTypeUrl = String(object.msgTypeUrl); + } else { + message.msgTypeUrl = ""; + } + return message; + }, + + toJSON(message: MsgRevoke): unknown { + const obj: any = {}; + message.granter !== undefined && (obj.granter = message.granter); + message.grantee !== undefined && (obj.grantee = message.grantee); + message.msgTypeUrl !== undefined && (obj.msgTypeUrl = message.msgTypeUrl); + return obj; + }, + + fromPartial(object: DeepPartial): MsgRevoke { + const message = { ...baseMsgRevoke } as MsgRevoke; + if (object.granter !== undefined && object.granter !== null) { + message.granter = object.granter; + } else { + message.granter = ""; + } + if (object.grantee !== undefined && object.grantee !== null) { + message.grantee = object.grantee; + } else { + message.grantee = ""; + } + if (object.msgTypeUrl !== undefined && object.msgTypeUrl !== null) { + message.msgTypeUrl = object.msgTypeUrl; + } else { + message.msgTypeUrl = ""; + } + return message; + }, +}; + +const baseMsgRevokeResponse: object = {}; + +export const MsgRevokeResponse = { + encode(_: MsgRevokeResponse, writer: Writer = Writer.create()): Writer { + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MsgRevokeResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgRevokeResponse } as MsgRevokeResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): MsgRevokeResponse { + const message = { ...baseMsgRevokeResponse } as MsgRevokeResponse; + return message; + }, + + toJSON(_: MsgRevokeResponse): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial(_: DeepPartial): MsgRevokeResponse { + const message = { ...baseMsgRevokeResponse } as MsgRevokeResponse; + return message; + }, +}; + +/** Msg defines the authz Msg service. */ +export interface Msg { + /** + * Grant grants the provided authorization to the grantee on the granter's + * account with the provided expiration time. If there is already a grant + * for the given (granter, grantee, Authorization) triple, then the grant + * will be overwritten. + */ + Grant(request: MsgGrant): Promise; + /** + * Exec attempts to execute the provided messages using + * authorizations granted to the grantee. Each message should have only + * one signer corresponding to the granter of the authorization. + */ + Exec(request: MsgExec): Promise; + /** + * Revoke revokes any authorization corresponding to the provided method name on the + * granter's account that has been granted to the grantee. + */ + Revoke(request: MsgRevoke): Promise; +} + +export class MsgClientImpl implements Msg { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + } + Grant(request: MsgGrant): Promise { + const data = MsgGrant.encode(request).finish(); + const promise = this.rpc.request("cosmos.authz.v1beta1.Msg", "Grant", data); + return promise.then((data) => MsgGrantResponse.decode(new Reader(data))); + } + + Exec(request: MsgExec): Promise { + const data = MsgExec.encode(request).finish(); + const promise = this.rpc.request("cosmos.authz.v1beta1.Msg", "Exec", data); + return promise.then((data) => MsgExecResponse.decode(new Reader(data))); + } + + Revoke(request: MsgRevoke): Promise { + const data = MsgRevoke.encode(request).finish(); + const promise = this.rpc.request( + "cosmos.authz.v1beta1.Msg", + "Revoke", + data + ); + return promise.then((data) => MsgRevokeResponse.decode(new Reader(data))); + } +} + +interface Rpc { + request( + service: string, + method: string, + data: Uint8Array + ): Promise; +} + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/cosmos.authz.v1beta1/types/cosmos/base/abci/v1beta1/abci.ts b/ts-client/cosmos.authz.v1beta1/types/cosmos/base/abci/v1beta1/abci.ts new file mode 100644 index 00000000..5f1e5e7e --- /dev/null +++ b/ts-client/cosmos.authz.v1beta1/types/cosmos/base/abci/v1beta1/abci.ts @@ -0,0 +1,1279 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; +import { Any } from "../../../../google/protobuf/any"; +import { Event } from "../../../../tendermint/abci/types"; + +export const protobufPackage = "cosmos.base.abci.v1beta1"; + +/** + * TxResponse defines a structure containing relevant tx data and metadata. The + * tags are stringified and the log is JSON decoded. + */ +export interface TxResponse { + /** The block height */ + height: number; + /** The transaction hash. */ + txhash: string; + /** Namespace for the Code */ + codespace: string; + /** Response code. */ + code: number; + /** Result bytes, if any. */ + data: string; + /** + * The output of the application's logger (raw string). May be + * non-deterministic. + */ + rawLog: string; + /** The output of the application's logger (typed). May be non-deterministic. */ + logs: ABCIMessageLog[]; + /** Additional information. May be non-deterministic. */ + info: string; + /** Amount of gas requested for transaction. */ + gasWanted: number; + /** Amount of gas consumed by transaction. */ + gasUsed: number; + /** The request transaction bytes. */ + tx: Any | undefined; + /** + * Time of the previous block. For heights > 1, it's the weighted median of + * the timestamps of the valid votes in the block.LastCommit. For height == 1, + * it's genesis time. + */ + timestamp: string; + /** + * Events defines all the events emitted by processing a transaction. Note, + * these events include those emitted by processing all the messages and those + * emitted from the ante handler. Whereas Logs contains the events, with + * additional metadata, emitted only by processing the messages. + * + * Since: cosmos-sdk 0.42.11, 0.44.5, 0.45 + */ + events: Event[]; +} + +/** ABCIMessageLog defines a structure containing an indexed tx ABCI message log. */ +export interface ABCIMessageLog { + msgIndex: number; + log: string; + /** + * Events contains a slice of Event objects that were emitted during some + * execution. + */ + events: StringEvent[]; +} + +/** + * StringEvent defines en Event object wrapper where all the attributes + * contain key/value pairs that are strings instead of raw bytes. + */ +export interface StringEvent { + type: string; + attributes: Attribute[]; +} + +/** + * Attribute defines an attribute wrapper where the key and value are + * strings instead of raw bytes. + */ +export interface Attribute { + key: string; + value: string; +} + +/** GasInfo defines tx execution gas context. */ +export interface GasInfo { + /** GasWanted is the maximum units of work we allow this tx to perform. */ + gasWanted: number; + /** GasUsed is the amount of gas actually consumed. */ + gasUsed: number; +} + +/** Result is the union of ResponseFormat and ResponseCheckTx. */ +export interface Result { + /** + * Data is any data returned from message or handler execution. It MUST be + * length prefixed in order to separate data from multiple message executions. + */ + data: Uint8Array; + /** Log contains the log information from message or handler execution. */ + log: string; + /** + * Events contains a slice of Event objects that were emitted during message + * or handler execution. + */ + events: Event[]; +} + +/** + * SimulationResponse defines the response generated when a transaction is + * successfully simulated. + */ +export interface SimulationResponse { + gasInfo: GasInfo | undefined; + result: Result | undefined; +} + +/** + * MsgData defines the data returned in a Result object during message + * execution. + */ +export interface MsgData { + msgType: string; + data: Uint8Array; +} + +/** + * TxMsgData defines a list of MsgData. A transaction will have a MsgData object + * for each message. + */ +export interface TxMsgData { + data: MsgData[]; +} + +/** SearchTxsResult defines a structure for querying txs pageable */ +export interface SearchTxsResult { + /** Count of all txs */ + totalCount: number; + /** Count of txs in current page */ + count: number; + /** Index of current page, start from 1 */ + pageNumber: number; + /** Count of total pages */ + pageTotal: number; + /** Max count txs per page */ + limit: number; + /** List of txs in current page */ + txs: TxResponse[]; +} + +const baseTxResponse: object = { + height: 0, + txhash: "", + codespace: "", + code: 0, + data: "", + rawLog: "", + info: "", + gasWanted: 0, + gasUsed: 0, + timestamp: "", +}; + +export const TxResponse = { + encode(message: TxResponse, writer: Writer = Writer.create()): Writer { + if (message.height !== 0) { + writer.uint32(8).int64(message.height); + } + if (message.txhash !== "") { + writer.uint32(18).string(message.txhash); + } + if (message.codespace !== "") { + writer.uint32(26).string(message.codespace); + } + if (message.code !== 0) { + writer.uint32(32).uint32(message.code); + } + if (message.data !== "") { + writer.uint32(42).string(message.data); + } + if (message.rawLog !== "") { + writer.uint32(50).string(message.rawLog); + } + for (const v of message.logs) { + ABCIMessageLog.encode(v!, writer.uint32(58).fork()).ldelim(); + } + if (message.info !== "") { + writer.uint32(66).string(message.info); + } + if (message.gasWanted !== 0) { + writer.uint32(72).int64(message.gasWanted); + } + if (message.gasUsed !== 0) { + writer.uint32(80).int64(message.gasUsed); + } + if (message.tx !== undefined) { + Any.encode(message.tx, writer.uint32(90).fork()).ldelim(); + } + if (message.timestamp !== "") { + writer.uint32(98).string(message.timestamp); + } + for (const v of message.events) { + Event.encode(v!, writer.uint32(106).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): TxResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseTxResponse } as TxResponse; + message.logs = []; + message.events = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.height = longToNumber(reader.int64() as Long); + break; + case 2: + message.txhash = reader.string(); + break; + case 3: + message.codespace = reader.string(); + break; + case 4: + message.code = reader.uint32(); + break; + case 5: + message.data = reader.string(); + break; + case 6: + message.rawLog = reader.string(); + break; + case 7: + message.logs.push(ABCIMessageLog.decode(reader, reader.uint32())); + break; + case 8: + message.info = reader.string(); + break; + case 9: + message.gasWanted = longToNumber(reader.int64() as Long); + break; + case 10: + message.gasUsed = longToNumber(reader.int64() as Long); + break; + case 11: + message.tx = Any.decode(reader, reader.uint32()); + break; + case 12: + message.timestamp = reader.string(); + break; + case 13: + message.events.push(Event.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): TxResponse { + const message = { ...baseTxResponse } as TxResponse; + message.logs = []; + message.events = []; + if (object.height !== undefined && object.height !== null) { + message.height = Number(object.height); + } else { + message.height = 0; + } + if (object.txhash !== undefined && object.txhash !== null) { + message.txhash = String(object.txhash); + } else { + message.txhash = ""; + } + if (object.codespace !== undefined && object.codespace !== null) { + message.codespace = String(object.codespace); + } else { + message.codespace = ""; + } + if (object.code !== undefined && object.code !== null) { + message.code = Number(object.code); + } else { + message.code = 0; + } + if (object.data !== undefined && object.data !== null) { + message.data = String(object.data); + } else { + message.data = ""; + } + if (object.rawLog !== undefined && object.rawLog !== null) { + message.rawLog = String(object.rawLog); + } else { + message.rawLog = ""; + } + if (object.logs !== undefined && object.logs !== null) { + for (const e of object.logs) { + message.logs.push(ABCIMessageLog.fromJSON(e)); + } + } + if (object.info !== undefined && object.info !== null) { + message.info = String(object.info); + } else { + message.info = ""; + } + if (object.gasWanted !== undefined && object.gasWanted !== null) { + message.gasWanted = Number(object.gasWanted); + } else { + message.gasWanted = 0; + } + if (object.gasUsed !== undefined && object.gasUsed !== null) { + message.gasUsed = Number(object.gasUsed); + } else { + message.gasUsed = 0; + } + if (object.tx !== undefined && object.tx !== null) { + message.tx = Any.fromJSON(object.tx); + } else { + message.tx = undefined; + } + if (object.timestamp !== undefined && object.timestamp !== null) { + message.timestamp = String(object.timestamp); + } else { + message.timestamp = ""; + } + if (object.events !== undefined && object.events !== null) { + for (const e of object.events) { + message.events.push(Event.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: TxResponse): unknown { + const obj: any = {}; + message.height !== undefined && (obj.height = message.height); + message.txhash !== undefined && (obj.txhash = message.txhash); + message.codespace !== undefined && (obj.codespace = message.codespace); + message.code !== undefined && (obj.code = message.code); + message.data !== undefined && (obj.data = message.data); + message.rawLog !== undefined && (obj.rawLog = message.rawLog); + if (message.logs) { + obj.logs = message.logs.map((e) => + e ? ABCIMessageLog.toJSON(e) : undefined + ); + } else { + obj.logs = []; + } + message.info !== undefined && (obj.info = message.info); + message.gasWanted !== undefined && (obj.gasWanted = message.gasWanted); + message.gasUsed !== undefined && (obj.gasUsed = message.gasUsed); + message.tx !== undefined && + (obj.tx = message.tx ? Any.toJSON(message.tx) : undefined); + message.timestamp !== undefined && (obj.timestamp = message.timestamp); + if (message.events) { + obj.events = message.events.map((e) => (e ? Event.toJSON(e) : undefined)); + } else { + obj.events = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): TxResponse { + const message = { ...baseTxResponse } as TxResponse; + message.logs = []; + message.events = []; + if (object.height !== undefined && object.height !== null) { + message.height = object.height; + } else { + message.height = 0; + } + if (object.txhash !== undefined && object.txhash !== null) { + message.txhash = object.txhash; + } else { + message.txhash = ""; + } + if (object.codespace !== undefined && object.codespace !== null) { + message.codespace = object.codespace; + } else { + message.codespace = ""; + } + if (object.code !== undefined && object.code !== null) { + message.code = object.code; + } else { + message.code = 0; + } + if (object.data !== undefined && object.data !== null) { + message.data = object.data; + } else { + message.data = ""; + } + if (object.rawLog !== undefined && object.rawLog !== null) { + message.rawLog = object.rawLog; + } else { + message.rawLog = ""; + } + if (object.logs !== undefined && object.logs !== null) { + for (const e of object.logs) { + message.logs.push(ABCIMessageLog.fromPartial(e)); + } + } + if (object.info !== undefined && object.info !== null) { + message.info = object.info; + } else { + message.info = ""; + } + if (object.gasWanted !== undefined && object.gasWanted !== null) { + message.gasWanted = object.gasWanted; + } else { + message.gasWanted = 0; + } + if (object.gasUsed !== undefined && object.gasUsed !== null) { + message.gasUsed = object.gasUsed; + } else { + message.gasUsed = 0; + } + if (object.tx !== undefined && object.tx !== null) { + message.tx = Any.fromPartial(object.tx); + } else { + message.tx = undefined; + } + if (object.timestamp !== undefined && object.timestamp !== null) { + message.timestamp = object.timestamp; + } else { + message.timestamp = ""; + } + if (object.events !== undefined && object.events !== null) { + for (const e of object.events) { + message.events.push(Event.fromPartial(e)); + } + } + return message; + }, +}; + +const baseABCIMessageLog: object = { msgIndex: 0, log: "" }; + +export const ABCIMessageLog = { + encode(message: ABCIMessageLog, writer: Writer = Writer.create()): Writer { + if (message.msgIndex !== 0) { + writer.uint32(8).uint32(message.msgIndex); + } + if (message.log !== "") { + writer.uint32(18).string(message.log); + } + for (const v of message.events) { + StringEvent.encode(v!, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ABCIMessageLog { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseABCIMessageLog } as ABCIMessageLog; + message.events = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.msgIndex = reader.uint32(); + break; + case 2: + message.log = reader.string(); + break; + case 3: + message.events.push(StringEvent.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ABCIMessageLog { + const message = { ...baseABCIMessageLog } as ABCIMessageLog; + message.events = []; + if (object.msgIndex !== undefined && object.msgIndex !== null) { + message.msgIndex = Number(object.msgIndex); + } else { + message.msgIndex = 0; + } + if (object.log !== undefined && object.log !== null) { + message.log = String(object.log); + } else { + message.log = ""; + } + if (object.events !== undefined && object.events !== null) { + for (const e of object.events) { + message.events.push(StringEvent.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: ABCIMessageLog): unknown { + const obj: any = {}; + message.msgIndex !== undefined && (obj.msgIndex = message.msgIndex); + message.log !== undefined && (obj.log = message.log); + if (message.events) { + obj.events = message.events.map((e) => + e ? StringEvent.toJSON(e) : undefined + ); + } else { + obj.events = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): ABCIMessageLog { + const message = { ...baseABCIMessageLog } as ABCIMessageLog; + message.events = []; + if (object.msgIndex !== undefined && object.msgIndex !== null) { + message.msgIndex = object.msgIndex; + } else { + message.msgIndex = 0; + } + if (object.log !== undefined && object.log !== null) { + message.log = object.log; + } else { + message.log = ""; + } + if (object.events !== undefined && object.events !== null) { + for (const e of object.events) { + message.events.push(StringEvent.fromPartial(e)); + } + } + return message; + }, +}; + +const baseStringEvent: object = { type: "" }; + +export const StringEvent = { + encode(message: StringEvent, writer: Writer = Writer.create()): Writer { + if (message.type !== "") { + writer.uint32(10).string(message.type); + } + for (const v of message.attributes) { + Attribute.encode(v!, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): StringEvent { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseStringEvent } as StringEvent; + message.attributes = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.type = reader.string(); + break; + case 2: + message.attributes.push(Attribute.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): StringEvent { + const message = { ...baseStringEvent } as StringEvent; + message.attributes = []; + if (object.type !== undefined && object.type !== null) { + message.type = String(object.type); + } else { + message.type = ""; + } + if (object.attributes !== undefined && object.attributes !== null) { + for (const e of object.attributes) { + message.attributes.push(Attribute.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: StringEvent): unknown { + const obj: any = {}; + message.type !== undefined && (obj.type = message.type); + if (message.attributes) { + obj.attributes = message.attributes.map((e) => + e ? Attribute.toJSON(e) : undefined + ); + } else { + obj.attributes = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): StringEvent { + const message = { ...baseStringEvent } as StringEvent; + message.attributes = []; + if (object.type !== undefined && object.type !== null) { + message.type = object.type; + } else { + message.type = ""; + } + if (object.attributes !== undefined && object.attributes !== null) { + for (const e of object.attributes) { + message.attributes.push(Attribute.fromPartial(e)); + } + } + return message; + }, +}; + +const baseAttribute: object = { key: "", value: "" }; + +export const Attribute = { + encode(message: Attribute, writer: Writer = Writer.create()): Writer { + if (message.key !== "") { + writer.uint32(10).string(message.key); + } + if (message.value !== "") { + writer.uint32(18).string(message.value); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Attribute { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseAttribute } as Attribute; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.key = reader.string(); + break; + case 2: + message.value = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Attribute { + const message = { ...baseAttribute } as Attribute; + if (object.key !== undefined && object.key !== null) { + message.key = String(object.key); + } else { + message.key = ""; + } + if (object.value !== undefined && object.value !== null) { + message.value = String(object.value); + } else { + message.value = ""; + } + return message; + }, + + toJSON(message: Attribute): unknown { + const obj: any = {}; + message.key !== undefined && (obj.key = message.key); + message.value !== undefined && (obj.value = message.value); + return obj; + }, + + fromPartial(object: DeepPartial): Attribute { + const message = { ...baseAttribute } as Attribute; + if (object.key !== undefined && object.key !== null) { + message.key = object.key; + } else { + message.key = ""; + } + if (object.value !== undefined && object.value !== null) { + message.value = object.value; + } else { + message.value = ""; + } + return message; + }, +}; + +const baseGasInfo: object = { gasWanted: 0, gasUsed: 0 }; + +export const GasInfo = { + encode(message: GasInfo, writer: Writer = Writer.create()): Writer { + if (message.gasWanted !== 0) { + writer.uint32(8).uint64(message.gasWanted); + } + if (message.gasUsed !== 0) { + writer.uint32(16).uint64(message.gasUsed); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): GasInfo { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseGasInfo } as GasInfo; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.gasWanted = longToNumber(reader.uint64() as Long); + break; + case 2: + message.gasUsed = longToNumber(reader.uint64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GasInfo { + const message = { ...baseGasInfo } as GasInfo; + if (object.gasWanted !== undefined && object.gasWanted !== null) { + message.gasWanted = Number(object.gasWanted); + } else { + message.gasWanted = 0; + } + if (object.gasUsed !== undefined && object.gasUsed !== null) { + message.gasUsed = Number(object.gasUsed); + } else { + message.gasUsed = 0; + } + return message; + }, + + toJSON(message: GasInfo): unknown { + const obj: any = {}; + message.gasWanted !== undefined && (obj.gasWanted = message.gasWanted); + message.gasUsed !== undefined && (obj.gasUsed = message.gasUsed); + return obj; + }, + + fromPartial(object: DeepPartial): GasInfo { + const message = { ...baseGasInfo } as GasInfo; + if (object.gasWanted !== undefined && object.gasWanted !== null) { + message.gasWanted = object.gasWanted; + } else { + message.gasWanted = 0; + } + if (object.gasUsed !== undefined && object.gasUsed !== null) { + message.gasUsed = object.gasUsed; + } else { + message.gasUsed = 0; + } + return message; + }, +}; + +const baseResult: object = { log: "" }; + +export const Result = { + encode(message: Result, writer: Writer = Writer.create()): Writer { + if (message.data.length !== 0) { + writer.uint32(10).bytes(message.data); + } + if (message.log !== "") { + writer.uint32(18).string(message.log); + } + for (const v of message.events) { + Event.encode(v!, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Result { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseResult } as Result; + message.events = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.data = reader.bytes(); + break; + case 2: + message.log = reader.string(); + break; + case 3: + message.events.push(Event.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Result { + const message = { ...baseResult } as Result; + message.events = []; + if (object.data !== undefined && object.data !== null) { + message.data = bytesFromBase64(object.data); + } + if (object.log !== undefined && object.log !== null) { + message.log = String(object.log); + } else { + message.log = ""; + } + if (object.events !== undefined && object.events !== null) { + for (const e of object.events) { + message.events.push(Event.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: Result): unknown { + const obj: any = {}; + message.data !== undefined && + (obj.data = base64FromBytes( + message.data !== undefined ? message.data : new Uint8Array() + )); + message.log !== undefined && (obj.log = message.log); + if (message.events) { + obj.events = message.events.map((e) => (e ? Event.toJSON(e) : undefined)); + } else { + obj.events = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): Result { + const message = { ...baseResult } as Result; + message.events = []; + if (object.data !== undefined && object.data !== null) { + message.data = object.data; + } else { + message.data = new Uint8Array(); + } + if (object.log !== undefined && object.log !== null) { + message.log = object.log; + } else { + message.log = ""; + } + if (object.events !== undefined && object.events !== null) { + for (const e of object.events) { + message.events.push(Event.fromPartial(e)); + } + } + return message; + }, +}; + +const baseSimulationResponse: object = {}; + +export const SimulationResponse = { + encode( + message: SimulationResponse, + writer: Writer = Writer.create() + ): Writer { + if (message.gasInfo !== undefined) { + GasInfo.encode(message.gasInfo, writer.uint32(10).fork()).ldelim(); + } + if (message.result !== undefined) { + Result.encode(message.result, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): SimulationResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseSimulationResponse } as SimulationResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.gasInfo = GasInfo.decode(reader, reader.uint32()); + break; + case 2: + message.result = Result.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): SimulationResponse { + const message = { ...baseSimulationResponse } as SimulationResponse; + if (object.gasInfo !== undefined && object.gasInfo !== null) { + message.gasInfo = GasInfo.fromJSON(object.gasInfo); + } else { + message.gasInfo = undefined; + } + if (object.result !== undefined && object.result !== null) { + message.result = Result.fromJSON(object.result); + } else { + message.result = undefined; + } + return message; + }, + + toJSON(message: SimulationResponse): unknown { + const obj: any = {}; + message.gasInfo !== undefined && + (obj.gasInfo = message.gasInfo + ? GasInfo.toJSON(message.gasInfo) + : undefined); + message.result !== undefined && + (obj.result = message.result ? Result.toJSON(message.result) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): SimulationResponse { + const message = { ...baseSimulationResponse } as SimulationResponse; + if (object.gasInfo !== undefined && object.gasInfo !== null) { + message.gasInfo = GasInfo.fromPartial(object.gasInfo); + } else { + message.gasInfo = undefined; + } + if (object.result !== undefined && object.result !== null) { + message.result = Result.fromPartial(object.result); + } else { + message.result = undefined; + } + return message; + }, +}; + +const baseMsgData: object = { msgType: "" }; + +export const MsgData = { + encode(message: MsgData, writer: Writer = Writer.create()): Writer { + if (message.msgType !== "") { + writer.uint32(10).string(message.msgType); + } + if (message.data.length !== 0) { + writer.uint32(18).bytes(message.data); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MsgData { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgData } as MsgData; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.msgType = reader.string(); + break; + case 2: + message.data = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgData { + const message = { ...baseMsgData } as MsgData; + if (object.msgType !== undefined && object.msgType !== null) { + message.msgType = String(object.msgType); + } else { + message.msgType = ""; + } + if (object.data !== undefined && object.data !== null) { + message.data = bytesFromBase64(object.data); + } + return message; + }, + + toJSON(message: MsgData): unknown { + const obj: any = {}; + message.msgType !== undefined && (obj.msgType = message.msgType); + message.data !== undefined && + (obj.data = base64FromBytes( + message.data !== undefined ? message.data : new Uint8Array() + )); + return obj; + }, + + fromPartial(object: DeepPartial): MsgData { + const message = { ...baseMsgData } as MsgData; + if (object.msgType !== undefined && object.msgType !== null) { + message.msgType = object.msgType; + } else { + message.msgType = ""; + } + if (object.data !== undefined && object.data !== null) { + message.data = object.data; + } else { + message.data = new Uint8Array(); + } + return message; + }, +}; + +const baseTxMsgData: object = {}; + +export const TxMsgData = { + encode(message: TxMsgData, writer: Writer = Writer.create()): Writer { + for (const v of message.data) { + MsgData.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): TxMsgData { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseTxMsgData } as TxMsgData; + message.data = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.data.push(MsgData.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): TxMsgData { + const message = { ...baseTxMsgData } as TxMsgData; + message.data = []; + if (object.data !== undefined && object.data !== null) { + for (const e of object.data) { + message.data.push(MsgData.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: TxMsgData): unknown { + const obj: any = {}; + if (message.data) { + obj.data = message.data.map((e) => (e ? MsgData.toJSON(e) : undefined)); + } else { + obj.data = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): TxMsgData { + const message = { ...baseTxMsgData } as TxMsgData; + message.data = []; + if (object.data !== undefined && object.data !== null) { + for (const e of object.data) { + message.data.push(MsgData.fromPartial(e)); + } + } + return message; + }, +}; + +const baseSearchTxsResult: object = { + totalCount: 0, + count: 0, + pageNumber: 0, + pageTotal: 0, + limit: 0, +}; + +export const SearchTxsResult = { + encode(message: SearchTxsResult, writer: Writer = Writer.create()): Writer { + if (message.totalCount !== 0) { + writer.uint32(8).uint64(message.totalCount); + } + if (message.count !== 0) { + writer.uint32(16).uint64(message.count); + } + if (message.pageNumber !== 0) { + writer.uint32(24).uint64(message.pageNumber); + } + if (message.pageTotal !== 0) { + writer.uint32(32).uint64(message.pageTotal); + } + if (message.limit !== 0) { + writer.uint32(40).uint64(message.limit); + } + for (const v of message.txs) { + TxResponse.encode(v!, writer.uint32(50).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): SearchTxsResult { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseSearchTxsResult } as SearchTxsResult; + message.txs = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.totalCount = longToNumber(reader.uint64() as Long); + break; + case 2: + message.count = longToNumber(reader.uint64() as Long); + break; + case 3: + message.pageNumber = longToNumber(reader.uint64() as Long); + break; + case 4: + message.pageTotal = longToNumber(reader.uint64() as Long); + break; + case 5: + message.limit = longToNumber(reader.uint64() as Long); + break; + case 6: + message.txs.push(TxResponse.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): SearchTxsResult { + const message = { ...baseSearchTxsResult } as SearchTxsResult; + message.txs = []; + if (object.totalCount !== undefined && object.totalCount !== null) { + message.totalCount = Number(object.totalCount); + } else { + message.totalCount = 0; + } + if (object.count !== undefined && object.count !== null) { + message.count = Number(object.count); + } else { + message.count = 0; + } + if (object.pageNumber !== undefined && object.pageNumber !== null) { + message.pageNumber = Number(object.pageNumber); + } else { + message.pageNumber = 0; + } + if (object.pageTotal !== undefined && object.pageTotal !== null) { + message.pageTotal = Number(object.pageTotal); + } else { + message.pageTotal = 0; + } + if (object.limit !== undefined && object.limit !== null) { + message.limit = Number(object.limit); + } else { + message.limit = 0; + } + if (object.txs !== undefined && object.txs !== null) { + for (const e of object.txs) { + message.txs.push(TxResponse.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: SearchTxsResult): unknown { + const obj: any = {}; + message.totalCount !== undefined && (obj.totalCount = message.totalCount); + message.count !== undefined && (obj.count = message.count); + message.pageNumber !== undefined && (obj.pageNumber = message.pageNumber); + message.pageTotal !== undefined && (obj.pageTotal = message.pageTotal); + message.limit !== undefined && (obj.limit = message.limit); + if (message.txs) { + obj.txs = message.txs.map((e) => (e ? TxResponse.toJSON(e) : undefined)); + } else { + obj.txs = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): SearchTxsResult { + const message = { ...baseSearchTxsResult } as SearchTxsResult; + message.txs = []; + if (object.totalCount !== undefined && object.totalCount !== null) { + message.totalCount = object.totalCount; + } else { + message.totalCount = 0; + } + if (object.count !== undefined && object.count !== null) { + message.count = object.count; + } else { + message.count = 0; + } + if (object.pageNumber !== undefined && object.pageNumber !== null) { + message.pageNumber = object.pageNumber; + } else { + message.pageNumber = 0; + } + if (object.pageTotal !== undefined && object.pageTotal !== null) { + message.pageTotal = object.pageTotal; + } else { + message.pageTotal = 0; + } + if (object.limit !== undefined && object.limit !== null) { + message.limit = object.limit; + } else { + message.limit = 0; + } + if (object.txs !== undefined && object.txs !== null) { + for (const e of object.txs) { + message.txs.push(TxResponse.fromPartial(e)); + } + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/cosmos.authz.v1beta1/types/cosmos/base/query/v1beta1/pagination.ts b/ts-client/cosmos.authz.v1beta1/types/cosmos/base/query/v1beta1/pagination.ts new file mode 100644 index 00000000..cd4b2d78 --- /dev/null +++ b/ts-client/cosmos.authz.v1beta1/types/cosmos/base/query/v1beta1/pagination.ts @@ -0,0 +1,327 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "cosmos.base.query.v1beta1"; + +/** + * PageRequest is to be embedded in gRPC request messages for efficient + * pagination. Ex: + * + * message SomeRequest { + * Foo some_parameter = 1; + * PageRequest pagination = 2; + * } + */ +export interface PageRequest { + /** + * key is a value returned in PageResponse.next_key to begin + * querying the next page most efficiently. Only one of offset or key + * should be set. + */ + key: Uint8Array; + /** + * offset is a numeric offset that can be used when key is unavailable. + * It is less efficient than using key. Only one of offset or key should + * be set. + */ + offset: number; + /** + * limit is the total number of results to be returned in the result page. + * If left empty it will default to a value to be set by each app. + */ + limit: number; + /** + * count_total is set to true to indicate that the result set should include + * a count of the total number of items available for pagination in UIs. + * count_total is only respected when offset is used. It is ignored when key + * is set. + */ + countTotal: boolean; + /** + * reverse is set to true if results are to be returned in the descending order. + * + * Since: cosmos-sdk 0.43 + */ + reverse: boolean; +} + +/** + * PageResponse is to be embedded in gRPC response messages where the + * corresponding request message has used PageRequest. + * + * message SomeResponse { + * repeated Bar results = 1; + * PageResponse page = 2; + * } + */ +export interface PageResponse { + /** + * next_key is the key to be passed to PageRequest.key to + * query the next page most efficiently + */ + nextKey: Uint8Array; + /** + * total is total number of results available if PageRequest.count_total + * was set, its value is undefined otherwise + */ + total: number; +} + +const basePageRequest: object = { + offset: 0, + limit: 0, + countTotal: false, + reverse: false, +}; + +export const PageRequest = { + encode(message: PageRequest, writer: Writer = Writer.create()): Writer { + if (message.key.length !== 0) { + writer.uint32(10).bytes(message.key); + } + if (message.offset !== 0) { + writer.uint32(16).uint64(message.offset); + } + if (message.limit !== 0) { + writer.uint32(24).uint64(message.limit); + } + if (message.countTotal === true) { + writer.uint32(32).bool(message.countTotal); + } + if (message.reverse === true) { + writer.uint32(40).bool(message.reverse); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): PageRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...basePageRequest } as PageRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.key = reader.bytes(); + break; + case 2: + message.offset = longToNumber(reader.uint64() as Long); + break; + case 3: + message.limit = longToNumber(reader.uint64() as Long); + break; + case 4: + message.countTotal = reader.bool(); + break; + case 5: + message.reverse = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): PageRequest { + const message = { ...basePageRequest } as PageRequest; + if (object.key !== undefined && object.key !== null) { + message.key = bytesFromBase64(object.key); + } + if (object.offset !== undefined && object.offset !== null) { + message.offset = Number(object.offset); + } else { + message.offset = 0; + } + if (object.limit !== undefined && object.limit !== null) { + message.limit = Number(object.limit); + } else { + message.limit = 0; + } + if (object.countTotal !== undefined && object.countTotal !== null) { + message.countTotal = Boolean(object.countTotal); + } else { + message.countTotal = false; + } + if (object.reverse !== undefined && object.reverse !== null) { + message.reverse = Boolean(object.reverse); + } else { + message.reverse = false; + } + return message; + }, + + toJSON(message: PageRequest): unknown { + const obj: any = {}; + message.key !== undefined && + (obj.key = base64FromBytes( + message.key !== undefined ? message.key : new Uint8Array() + )); + message.offset !== undefined && (obj.offset = message.offset); + message.limit !== undefined && (obj.limit = message.limit); + message.countTotal !== undefined && (obj.countTotal = message.countTotal); + message.reverse !== undefined && (obj.reverse = message.reverse); + return obj; + }, + + fromPartial(object: DeepPartial): PageRequest { + const message = { ...basePageRequest } as PageRequest; + if (object.key !== undefined && object.key !== null) { + message.key = object.key; + } else { + message.key = new Uint8Array(); + } + if (object.offset !== undefined && object.offset !== null) { + message.offset = object.offset; + } else { + message.offset = 0; + } + if (object.limit !== undefined && object.limit !== null) { + message.limit = object.limit; + } else { + message.limit = 0; + } + if (object.countTotal !== undefined && object.countTotal !== null) { + message.countTotal = object.countTotal; + } else { + message.countTotal = false; + } + if (object.reverse !== undefined && object.reverse !== null) { + message.reverse = object.reverse; + } else { + message.reverse = false; + } + return message; + }, +}; + +const basePageResponse: object = { total: 0 }; + +export const PageResponse = { + encode(message: PageResponse, writer: Writer = Writer.create()): Writer { + if (message.nextKey.length !== 0) { + writer.uint32(10).bytes(message.nextKey); + } + if (message.total !== 0) { + writer.uint32(16).uint64(message.total); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): PageResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...basePageResponse } as PageResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.nextKey = reader.bytes(); + break; + case 2: + message.total = longToNumber(reader.uint64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): PageResponse { + const message = { ...basePageResponse } as PageResponse; + if (object.nextKey !== undefined && object.nextKey !== null) { + message.nextKey = bytesFromBase64(object.nextKey); + } + if (object.total !== undefined && object.total !== null) { + message.total = Number(object.total); + } else { + message.total = 0; + } + return message; + }, + + toJSON(message: PageResponse): unknown { + const obj: any = {}; + message.nextKey !== undefined && + (obj.nextKey = base64FromBytes( + message.nextKey !== undefined ? message.nextKey : new Uint8Array() + )); + message.total !== undefined && (obj.total = message.total); + return obj; + }, + + fromPartial(object: DeepPartial): PageResponse { + const message = { ...basePageResponse } as PageResponse; + if (object.nextKey !== undefined && object.nextKey !== null) { + message.nextKey = object.nextKey; + } else { + message.nextKey = new Uint8Array(); + } + if (object.total !== undefined && object.total !== null) { + message.total = object.total; + } else { + message.total = 0; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/cosmos.authz.v1beta1/types/cosmos_proto/cosmos.ts b/ts-client/cosmos.authz.v1beta1/types/cosmos_proto/cosmos.ts new file mode 100644 index 00000000..9ec67a12 --- /dev/null +++ b/ts-client/cosmos.authz.v1beta1/types/cosmos_proto/cosmos.ts @@ -0,0 +1,2 @@ +/* eslint-disable */ +export const protobufPackage = "cosmos_proto"; diff --git a/ts-client/cosmos.authz.v1beta1/types/gogoproto/gogo.ts b/ts-client/cosmos.authz.v1beta1/types/gogoproto/gogo.ts new file mode 100644 index 00000000..3f41a047 --- /dev/null +++ b/ts-client/cosmos.authz.v1beta1/types/gogoproto/gogo.ts @@ -0,0 +1,2 @@ +/* eslint-disable */ +export const protobufPackage = "gogoproto"; diff --git a/ts-client/cosmos.authz.v1beta1/types/google/api/annotations.ts b/ts-client/cosmos.authz.v1beta1/types/google/api/annotations.ts new file mode 100644 index 00000000..aace4787 --- /dev/null +++ b/ts-client/cosmos.authz.v1beta1/types/google/api/annotations.ts @@ -0,0 +1,2 @@ +/* eslint-disable */ +export const protobufPackage = "google.api"; diff --git a/ts-client/cosmos.authz.v1beta1/types/google/api/http.ts b/ts-client/cosmos.authz.v1beta1/types/google/api/http.ts new file mode 100644 index 00000000..ddc00f8b --- /dev/null +++ b/ts-client/cosmos.authz.v1beta1/types/google/api/http.ts @@ -0,0 +1,705 @@ +/* eslint-disable */ +import { Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "google.api"; + +/** + * Defines the HTTP configuration for an API service. It contains a list of + * [HttpRule][google.api.HttpRule], each specifying the mapping of an RPC method + * to one or more HTTP REST API methods. + */ +export interface Http { + /** + * A list of HTTP configuration rules that apply to individual API methods. + * + * **NOTE:** All service configuration rules follow "last one wins" order. + */ + rules: HttpRule[]; + /** + * When set to true, URL path parmeters will be fully URI-decoded except in + * cases of single segment matches in reserved expansion, where "%2F" will be + * left encoded. + * + * The default behavior is to not decode RFC 6570 reserved characters in multi + * segment matches. + */ + fullyDecodeReservedExpansion: boolean; +} + +/** + * `HttpRule` defines the mapping of an RPC method to one or more HTTP + * REST API methods. The mapping specifies how different portions of the RPC + * request message are mapped to URL path, URL query parameters, and + * HTTP request body. The mapping is typically specified as an + * `google.api.http` annotation on the RPC method, + * see "google/api/annotations.proto" for details. + * + * The mapping consists of a field specifying the path template and + * method kind. The path template can refer to fields in the request + * message, as in the example below which describes a REST GET + * operation on a resource collection of messages: + * + * + * service Messaging { + * rpc GetMessage(GetMessageRequest) returns (Message) { + * option (google.api.http).get = "/v1/messages/{message_id}/{sub.subfield}"; + * } + * } + * message GetMessageRequest { + * message SubMessage { + * string subfield = 1; + * } + * string message_id = 1; // mapped to the URL + * SubMessage sub = 2; // `sub.subfield` is url-mapped + * } + * message Message { + * string text = 1; // content of the resource + * } + * + * The same http annotation can alternatively be expressed inside the + * `GRPC API Configuration` YAML file. + * + * http: + * rules: + * - selector: .Messaging.GetMessage + * get: /v1/messages/{message_id}/{sub.subfield} + * + * This definition enables an automatic, bidrectional mapping of HTTP + * JSON to RPC. Example: + * + * HTTP | RPC + * -----|----- + * `GET /v1/messages/123456/foo` | `GetMessage(message_id: "123456" sub: SubMessage(subfield: "foo"))` + * + * In general, not only fields but also field paths can be referenced + * from a path pattern. Fields mapped to the path pattern cannot be + * repeated and must have a primitive (non-message) type. + * + * Any fields in the request message which are not bound by the path + * pattern automatically become (optional) HTTP query + * parameters. Assume the following definition of the request message: + * + * + * service Messaging { + * rpc GetMessage(GetMessageRequest) returns (Message) { + * option (google.api.http).get = "/v1/messages/{message_id}"; + * } + * } + * message GetMessageRequest { + * message SubMessage { + * string subfield = 1; + * } + * string message_id = 1; // mapped to the URL + * int64 revision = 2; // becomes a parameter + * SubMessage sub = 3; // `sub.subfield` becomes a parameter + * } + * + * + * This enables a HTTP JSON to RPC mapping as below: + * + * HTTP | RPC + * -----|----- + * `GET /v1/messages/123456?revision=2&sub.subfield=foo` | `GetMessage(message_id: "123456" revision: 2 sub: SubMessage(subfield: "foo"))` + * + * Note that fields which are mapped to HTTP parameters must have a + * primitive type or a repeated primitive type. Message types are not + * allowed. In the case of a repeated type, the parameter can be + * repeated in the URL, as in `...?param=A¶m=B`. + * + * For HTTP method kinds which allow a request body, the `body` field + * specifies the mapping. Consider a REST update method on the + * message resource collection: + * + * + * service Messaging { + * rpc UpdateMessage(UpdateMessageRequest) returns (Message) { + * option (google.api.http) = { + * put: "/v1/messages/{message_id}" + * body: "message" + * }; + * } + * } + * message UpdateMessageRequest { + * string message_id = 1; // mapped to the URL + * Message message = 2; // mapped to the body + * } + * + * + * The following HTTP JSON to RPC mapping is enabled, where the + * representation of the JSON in the request body is determined by + * protos JSON encoding: + * + * HTTP | RPC + * -----|----- + * `PUT /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: "123456" message { text: "Hi!" })` + * + * The special name `*` can be used in the body mapping to define that + * every field not bound by the path template should be mapped to the + * request body. This enables the following alternative definition of + * the update method: + * + * service Messaging { + * rpc UpdateMessage(Message) returns (Message) { + * option (google.api.http) = { + * put: "/v1/messages/{message_id}" + * body: "*" + * }; + * } + * } + * message Message { + * string message_id = 1; + * string text = 2; + * } + * + * + * The following HTTP JSON to RPC mapping is enabled: + * + * HTTP | RPC + * -----|----- + * `PUT /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: "123456" text: "Hi!")` + * + * Note that when using `*` in the body mapping, it is not possible to + * have HTTP parameters, as all fields not bound by the path end in + * the body. This makes this option more rarely used in practice of + * defining REST APIs. The common usage of `*` is in custom methods + * which don't use the URL at all for transferring data. + * + * It is possible to define multiple HTTP methods for one RPC by using + * the `additional_bindings` option. Example: + * + * service Messaging { + * rpc GetMessage(GetMessageRequest) returns (Message) { + * option (google.api.http) = { + * get: "/v1/messages/{message_id}" + * additional_bindings { + * get: "/v1/users/{user_id}/messages/{message_id}" + * } + * }; + * } + * } + * message GetMessageRequest { + * string message_id = 1; + * string user_id = 2; + * } + * + * + * This enables the following two alternative HTTP JSON to RPC + * mappings: + * + * HTTP | RPC + * -----|----- + * `GET /v1/messages/123456` | `GetMessage(message_id: "123456")` + * `GET /v1/users/me/messages/123456` | `GetMessage(user_id: "me" message_id: "123456")` + * + * # Rules for HTTP mapping + * + * The rules for mapping HTTP path, query parameters, and body fields + * to the request message are as follows: + * + * 1. The `body` field specifies either `*` or a field path, or is + * omitted. If omitted, it indicates there is no HTTP request body. + * 2. Leaf fields (recursive expansion of nested messages in the + * request) can be classified into three types: + * (a) Matched in the URL template. + * (b) Covered by body (if body is `*`, everything except (a) fields; + * else everything under the body field) + * (c) All other fields. + * 3. URL query parameters found in the HTTP request are mapped to (c) fields. + * 4. Any body sent with an HTTP request can contain only (b) fields. + * + * The syntax of the path template is as follows: + * + * Template = "/" Segments [ Verb ] ; + * Segments = Segment { "/" Segment } ; + * Segment = "*" | "**" | LITERAL | Variable ; + * Variable = "{" FieldPath [ "=" Segments ] "}" ; + * FieldPath = IDENT { "." IDENT } ; + * Verb = ":" LITERAL ; + * + * The syntax `*` matches a single path segment. The syntax `**` matches zero + * or more path segments, which must be the last part of the path except the + * `Verb`. The syntax `LITERAL` matches literal text in the path. + * + * The syntax `Variable` matches part of the URL path as specified by its + * template. A variable template must not contain other variables. If a variable + * matches a single path segment, its template may be omitted, e.g. `{var}` + * is equivalent to `{var=*}`. + * + * If a variable contains exactly one path segment, such as `"{var}"` or + * `"{var=*}"`, when such a variable is expanded into a URL path, all characters + * except `[-_.~0-9a-zA-Z]` are percent-encoded. Such variables show up in the + * Discovery Document as `{var}`. + * + * If a variable contains one or more path segments, such as `"{var=foo/*}"` + * or `"{var=**}"`, when such a variable is expanded into a URL path, all + * characters except `[-_.~/0-9a-zA-Z]` are percent-encoded. Such variables + * show up in the Discovery Document as `{+var}`. + * + * NOTE: While the single segment variable matches the semantics of + * [RFC 6570](https://tools.ietf.org/html/rfc6570) Section 3.2.2 + * Simple String Expansion, the multi segment variable **does not** match + * RFC 6570 Reserved Expansion. The reason is that the Reserved Expansion + * does not expand special characters like `?` and `#`, which would lead + * to invalid URLs. + * + * NOTE: the field paths in variables and in the `body` must not refer to + * repeated fields or map fields. + */ +export interface HttpRule { + /** + * Selects methods to which this rule applies. + * + * Refer to [selector][google.api.DocumentationRule.selector] for syntax details. + */ + selector: string; + /** Used for listing and getting information about resources. */ + get: string | undefined; + /** Used for updating a resource. */ + put: string | undefined; + /** Used for creating a resource. */ + post: string | undefined; + /** Used for deleting a resource. */ + delete: string | undefined; + /** Used for updating a resource. */ + patch: string | undefined; + /** + * The custom pattern is used for specifying an HTTP method that is not + * included in the `pattern` field, such as HEAD, or "*" to leave the + * HTTP method unspecified for this rule. The wild-card rule is useful + * for services that provide content to Web (HTML) clients. + */ + custom: CustomHttpPattern | undefined; + /** + * The name of the request field whose value is mapped to the HTTP body, or + * `*` for mapping all fields not captured by the path pattern to the HTTP + * body. NOTE: the referred field must not be a repeated field and must be + * present at the top-level of request message type. + */ + body: string; + /** + * Optional. The name of the response field whose value is mapped to the HTTP + * body of response. Other response fields are ignored. When + * not set, the response message will be used as HTTP body of response. + */ + responseBody: string; + /** + * Additional HTTP bindings for the selector. Nested bindings must + * not contain an `additional_bindings` field themselves (that is, + * the nesting may only be one level deep). + */ + additionalBindings: HttpRule[]; +} + +/** A custom pattern is used for defining custom HTTP verb. */ +export interface CustomHttpPattern { + /** The name of this custom HTTP verb. */ + kind: string; + /** The path matched by this custom verb. */ + path: string; +} + +const baseHttp: object = { fullyDecodeReservedExpansion: false }; + +export const Http = { + encode(message: Http, writer: Writer = Writer.create()): Writer { + for (const v of message.rules) { + HttpRule.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.fullyDecodeReservedExpansion === true) { + writer.uint32(16).bool(message.fullyDecodeReservedExpansion); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Http { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseHttp } as Http; + message.rules = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.rules.push(HttpRule.decode(reader, reader.uint32())); + break; + case 2: + message.fullyDecodeReservedExpansion = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Http { + const message = { ...baseHttp } as Http; + message.rules = []; + if (object.rules !== undefined && object.rules !== null) { + for (const e of object.rules) { + message.rules.push(HttpRule.fromJSON(e)); + } + } + if ( + object.fullyDecodeReservedExpansion !== undefined && + object.fullyDecodeReservedExpansion !== null + ) { + message.fullyDecodeReservedExpansion = Boolean( + object.fullyDecodeReservedExpansion + ); + } else { + message.fullyDecodeReservedExpansion = false; + } + return message; + }, + + toJSON(message: Http): unknown { + const obj: any = {}; + if (message.rules) { + obj.rules = message.rules.map((e) => + e ? HttpRule.toJSON(e) : undefined + ); + } else { + obj.rules = []; + } + message.fullyDecodeReservedExpansion !== undefined && + (obj.fullyDecodeReservedExpansion = message.fullyDecodeReservedExpansion); + return obj; + }, + + fromPartial(object: DeepPartial): Http { + const message = { ...baseHttp } as Http; + message.rules = []; + if (object.rules !== undefined && object.rules !== null) { + for (const e of object.rules) { + message.rules.push(HttpRule.fromPartial(e)); + } + } + if ( + object.fullyDecodeReservedExpansion !== undefined && + object.fullyDecodeReservedExpansion !== null + ) { + message.fullyDecodeReservedExpansion = + object.fullyDecodeReservedExpansion; + } else { + message.fullyDecodeReservedExpansion = false; + } + return message; + }, +}; + +const baseHttpRule: object = { selector: "", body: "", responseBody: "" }; + +export const HttpRule = { + encode(message: HttpRule, writer: Writer = Writer.create()): Writer { + if (message.selector !== "") { + writer.uint32(10).string(message.selector); + } + if (message.get !== undefined) { + writer.uint32(18).string(message.get); + } + if (message.put !== undefined) { + writer.uint32(26).string(message.put); + } + if (message.post !== undefined) { + writer.uint32(34).string(message.post); + } + if (message.delete !== undefined) { + writer.uint32(42).string(message.delete); + } + if (message.patch !== undefined) { + writer.uint32(50).string(message.patch); + } + if (message.custom !== undefined) { + CustomHttpPattern.encode( + message.custom, + writer.uint32(66).fork() + ).ldelim(); + } + if (message.body !== "") { + writer.uint32(58).string(message.body); + } + if (message.responseBody !== "") { + writer.uint32(98).string(message.responseBody); + } + for (const v of message.additionalBindings) { + HttpRule.encode(v!, writer.uint32(90).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): HttpRule { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseHttpRule } as HttpRule; + message.additionalBindings = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.selector = reader.string(); + break; + case 2: + message.get = reader.string(); + break; + case 3: + message.put = reader.string(); + break; + case 4: + message.post = reader.string(); + break; + case 5: + message.delete = reader.string(); + break; + case 6: + message.patch = reader.string(); + break; + case 8: + message.custom = CustomHttpPattern.decode(reader, reader.uint32()); + break; + case 7: + message.body = reader.string(); + break; + case 12: + message.responseBody = reader.string(); + break; + case 11: + message.additionalBindings.push( + HttpRule.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): HttpRule { + const message = { ...baseHttpRule } as HttpRule; + message.additionalBindings = []; + if (object.selector !== undefined && object.selector !== null) { + message.selector = String(object.selector); + } else { + message.selector = ""; + } + if (object.get !== undefined && object.get !== null) { + message.get = String(object.get); + } else { + message.get = undefined; + } + if (object.put !== undefined && object.put !== null) { + message.put = String(object.put); + } else { + message.put = undefined; + } + if (object.post !== undefined && object.post !== null) { + message.post = String(object.post); + } else { + message.post = undefined; + } + if (object.delete !== undefined && object.delete !== null) { + message.delete = String(object.delete); + } else { + message.delete = undefined; + } + if (object.patch !== undefined && object.patch !== null) { + message.patch = String(object.patch); + } else { + message.patch = undefined; + } + if (object.custom !== undefined && object.custom !== null) { + message.custom = CustomHttpPattern.fromJSON(object.custom); + } else { + message.custom = undefined; + } + if (object.body !== undefined && object.body !== null) { + message.body = String(object.body); + } else { + message.body = ""; + } + if (object.responseBody !== undefined && object.responseBody !== null) { + message.responseBody = String(object.responseBody); + } else { + message.responseBody = ""; + } + if ( + object.additionalBindings !== undefined && + object.additionalBindings !== null + ) { + for (const e of object.additionalBindings) { + message.additionalBindings.push(HttpRule.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: HttpRule): unknown { + const obj: any = {}; + message.selector !== undefined && (obj.selector = message.selector); + message.get !== undefined && (obj.get = message.get); + message.put !== undefined && (obj.put = message.put); + message.post !== undefined && (obj.post = message.post); + message.delete !== undefined && (obj.delete = message.delete); + message.patch !== undefined && (obj.patch = message.patch); + message.custom !== undefined && + (obj.custom = message.custom + ? CustomHttpPattern.toJSON(message.custom) + : undefined); + message.body !== undefined && (obj.body = message.body); + message.responseBody !== undefined && + (obj.responseBody = message.responseBody); + if (message.additionalBindings) { + obj.additionalBindings = message.additionalBindings.map((e) => + e ? HttpRule.toJSON(e) : undefined + ); + } else { + obj.additionalBindings = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): HttpRule { + const message = { ...baseHttpRule } as HttpRule; + message.additionalBindings = []; + if (object.selector !== undefined && object.selector !== null) { + message.selector = object.selector; + } else { + message.selector = ""; + } + if (object.get !== undefined && object.get !== null) { + message.get = object.get; + } else { + message.get = undefined; + } + if (object.put !== undefined && object.put !== null) { + message.put = object.put; + } else { + message.put = undefined; + } + if (object.post !== undefined && object.post !== null) { + message.post = object.post; + } else { + message.post = undefined; + } + if (object.delete !== undefined && object.delete !== null) { + message.delete = object.delete; + } else { + message.delete = undefined; + } + if (object.patch !== undefined && object.patch !== null) { + message.patch = object.patch; + } else { + message.patch = undefined; + } + if (object.custom !== undefined && object.custom !== null) { + message.custom = CustomHttpPattern.fromPartial(object.custom); + } else { + message.custom = undefined; + } + if (object.body !== undefined && object.body !== null) { + message.body = object.body; + } else { + message.body = ""; + } + if (object.responseBody !== undefined && object.responseBody !== null) { + message.responseBody = object.responseBody; + } else { + message.responseBody = ""; + } + if ( + object.additionalBindings !== undefined && + object.additionalBindings !== null + ) { + for (const e of object.additionalBindings) { + message.additionalBindings.push(HttpRule.fromPartial(e)); + } + } + return message; + }, +}; + +const baseCustomHttpPattern: object = { kind: "", path: "" }; + +export const CustomHttpPattern = { + encode(message: CustomHttpPattern, writer: Writer = Writer.create()): Writer { + if (message.kind !== "") { + writer.uint32(10).string(message.kind); + } + if (message.path !== "") { + writer.uint32(18).string(message.path); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): CustomHttpPattern { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseCustomHttpPattern } as CustomHttpPattern; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.kind = reader.string(); + break; + case 2: + message.path = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): CustomHttpPattern { + const message = { ...baseCustomHttpPattern } as CustomHttpPattern; + if (object.kind !== undefined && object.kind !== null) { + message.kind = String(object.kind); + } else { + message.kind = ""; + } + if (object.path !== undefined && object.path !== null) { + message.path = String(object.path); + } else { + message.path = ""; + } + return message; + }, + + toJSON(message: CustomHttpPattern): unknown { + const obj: any = {}; + message.kind !== undefined && (obj.kind = message.kind); + message.path !== undefined && (obj.path = message.path); + return obj; + }, + + fromPartial(object: DeepPartial): CustomHttpPattern { + const message = { ...baseCustomHttpPattern } as CustomHttpPattern; + if (object.kind !== undefined && object.kind !== null) { + message.kind = object.kind; + } else { + message.kind = ""; + } + if (object.path !== undefined && object.path !== null) { + message.path = object.path; + } else { + message.path = ""; + } + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/cosmos.authz.v1beta1/types/google/protobuf/any.ts b/ts-client/cosmos.authz.v1beta1/types/google/protobuf/any.ts new file mode 100644 index 00000000..b137a629 --- /dev/null +++ b/ts-client/cosmos.authz.v1beta1/types/google/protobuf/any.ts @@ -0,0 +1,240 @@ +/* eslint-disable */ +import { Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "google.protobuf"; + +/** + * `Any` contains an arbitrary serialized protocol buffer message along with a + * URL that describes the type of the serialized message. + * + * Protobuf library provides support to pack/unpack Any values in the form + * of utility functions or additional generated methods of the Any type. + * + * Example 1: Pack and unpack a message in C++. + * + * Foo foo = ...; + * Any any; + * any.PackFrom(foo); + * ... + * if (any.UnpackTo(&foo)) { + * ... + * } + * + * Example 2: Pack and unpack a message in Java. + * + * Foo foo = ...; + * Any any = Any.pack(foo); + * ... + * if (any.is(Foo.class)) { + * foo = any.unpack(Foo.class); + * } + * + * Example 3: Pack and unpack a message in Python. + * + * foo = Foo(...) + * any = Any() + * any.Pack(foo) + * ... + * if any.Is(Foo.DESCRIPTOR): + * any.Unpack(foo) + * ... + * + * Example 4: Pack and unpack a message in Go + * + * foo := &pb.Foo{...} + * any, err := anypb.New(foo) + * if err != nil { + * ... + * } + * ... + * foo := &pb.Foo{} + * if err := any.UnmarshalTo(foo); err != nil { + * ... + * } + * + * The pack methods provided by protobuf library will by default use + * 'type.googleapis.com/full.type.name' as the type URL and the unpack + * methods only use the fully qualified type name after the last '/' + * in the type URL, for example "foo.bar.com/x/y.z" will yield type + * name "y.z". + * + * + * JSON + * ==== + * The JSON representation of an `Any` value uses the regular + * representation of the deserialized, embedded message, with an + * additional field `@type` which contains the type URL. Example: + * + * package google.profile; + * message Person { + * string first_name = 1; + * string last_name = 2; + * } + * + * { + * "@type": "type.googleapis.com/google.profile.Person", + * "firstName": , + * "lastName": + * } + * + * If the embedded message type is well-known and has a custom JSON + * representation, that representation will be embedded adding a field + * `value` which holds the custom JSON in addition to the `@type` + * field. Example (for message [google.protobuf.Duration][]): + * + * { + * "@type": "type.googleapis.com/google.protobuf.Duration", + * "value": "1.212s" + * } + */ +export interface Any { + /** + * A URL/resource name that uniquely identifies the type of the serialized + * protocol buffer message. This string must contain at least + * one "/" character. The last segment of the URL's path must represent + * the fully qualified name of the type (as in + * `path/google.protobuf.Duration`). The name should be in a canonical form + * (e.g., leading "." is not accepted). + * + * In practice, teams usually precompile into the binary all types that they + * expect it to use in the context of Any. However, for URLs which use the + * scheme `http`, `https`, or no scheme, one can optionally set up a type + * server that maps type URLs to message definitions as follows: + * + * * If no scheme is provided, `https` is assumed. + * * An HTTP GET on the URL must yield a [google.protobuf.Type][] + * value in binary format, or produce an error. + * * Applications are allowed to cache lookup results based on the + * URL, or have them precompiled into a binary to avoid any + * lookup. Therefore, binary compatibility needs to be preserved + * on changes to types. (Use versioned type names to manage + * breaking changes.) + * + * Note: this functionality is not currently available in the official + * protobuf release, and it is not used for type URLs beginning with + * type.googleapis.com. + * + * Schemes other than `http`, `https` (or the empty scheme) might be + * used with implementation specific semantics. + */ + typeUrl: string; + /** Must be a valid serialized protocol buffer of the above specified type. */ + value: Uint8Array; +} + +const baseAny: object = { typeUrl: "" }; + +export const Any = { + encode(message: Any, writer: Writer = Writer.create()): Writer { + if (message.typeUrl !== "") { + writer.uint32(10).string(message.typeUrl); + } + if (message.value.length !== 0) { + writer.uint32(18).bytes(message.value); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Any { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseAny } as Any; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.typeUrl = reader.string(); + break; + case 2: + message.value = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Any { + const message = { ...baseAny } as Any; + if (object.typeUrl !== undefined && object.typeUrl !== null) { + message.typeUrl = String(object.typeUrl); + } else { + message.typeUrl = ""; + } + if (object.value !== undefined && object.value !== null) { + message.value = bytesFromBase64(object.value); + } + return message; + }, + + toJSON(message: Any): unknown { + const obj: any = {}; + message.typeUrl !== undefined && (obj.typeUrl = message.typeUrl); + message.value !== undefined && + (obj.value = base64FromBytes( + message.value !== undefined ? message.value : new Uint8Array() + )); + return obj; + }, + + fromPartial(object: DeepPartial): Any { + const message = { ...baseAny } as Any; + if (object.typeUrl !== undefined && object.typeUrl !== null) { + message.typeUrl = object.typeUrl; + } else { + message.typeUrl = ""; + } + if (object.value !== undefined && object.value !== null) { + message.value = object.value; + } else { + message.value = new Uint8Array(); + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/cosmos.authz.v1beta1/types/google/protobuf/descriptor.ts b/ts-client/cosmos.authz.v1beta1/types/google/protobuf/descriptor.ts new file mode 100644 index 00000000..9e508660 --- /dev/null +++ b/ts-client/cosmos.authz.v1beta1/types/google/protobuf/descriptor.ts @@ -0,0 +1,5261 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "google.protobuf"; + +/** + * The protocol compiler can output a FileDescriptorSet containing the .proto + * files it parses. + */ +export interface FileDescriptorSet { + file: FileDescriptorProto[]; +} + +/** Describes a complete .proto file. */ +export interface FileDescriptorProto { + /** file name, relative to root of source tree */ + name: string; + /** e.g. "foo", "foo.bar", etc. */ + package: string; + /** Names of files imported by this file. */ + dependency: string[]; + /** Indexes of the public imported files in the dependency list above. */ + publicDependency: number[]; + /** + * Indexes of the weak imported files in the dependency list. + * For Google-internal migration only. Do not use. + */ + weakDependency: number[]; + /** All top-level definitions in this file. */ + messageType: DescriptorProto[]; + enumType: EnumDescriptorProto[]; + service: ServiceDescriptorProto[]; + extension: FieldDescriptorProto[]; + options: FileOptions | undefined; + /** + * This field contains optional information about the original source code. + * You may safely remove this entire field without harming runtime + * functionality of the descriptors -- the information is needed only by + * development tools. + */ + sourceCodeInfo: SourceCodeInfo | undefined; + /** + * The syntax of the proto file. + * The supported values are "proto2" and "proto3". + */ + syntax: string; +} + +/** Describes a message type. */ +export interface DescriptorProto { + name: string; + field: FieldDescriptorProto[]; + extension: FieldDescriptorProto[]; + nestedType: DescriptorProto[]; + enumType: EnumDescriptorProto[]; + extensionRange: DescriptorProto_ExtensionRange[]; + oneofDecl: OneofDescriptorProto[]; + options: MessageOptions | undefined; + reservedRange: DescriptorProto_ReservedRange[]; + /** + * Reserved field names, which may not be used by fields in the same message. + * A given name may only be reserved once. + */ + reservedName: string[]; +} + +export interface DescriptorProto_ExtensionRange { + /** Inclusive. */ + start: number; + /** Exclusive. */ + end: number; + options: ExtensionRangeOptions | undefined; +} + +/** + * Range of reserved tag numbers. Reserved tag numbers may not be used by + * fields or extension ranges in the same message. Reserved ranges may + * not overlap. + */ +export interface DescriptorProto_ReservedRange { + /** Inclusive. */ + start: number; + /** Exclusive. */ + end: number; +} + +export interface ExtensionRangeOptions { + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +/** Describes a field within a message. */ +export interface FieldDescriptorProto { + name: string; + number: number; + label: FieldDescriptorProto_Label; + /** + * If type_name is set, this need not be set. If both this and type_name + * are set, this must be one of TYPE_ENUM, TYPE_MESSAGE or TYPE_GROUP. + */ + type: FieldDescriptorProto_Type; + /** + * For message and enum types, this is the name of the type. If the name + * starts with a '.', it is fully-qualified. Otherwise, C++-like scoping + * rules are used to find the type (i.e. first the nested types within this + * message are searched, then within the parent, on up to the root + * namespace). + */ + typeName: string; + /** + * For extensions, this is the name of the type being extended. It is + * resolved in the same manner as type_name. + */ + extendee: string; + /** + * For numeric types, contains the original text representation of the value. + * For booleans, "true" or "false". + * For strings, contains the default text contents (not escaped in any way). + * For bytes, contains the C escaped value. All bytes >= 128 are escaped. + * TODO(kenton): Base-64 encode? + */ + defaultValue: string; + /** + * If set, gives the index of a oneof in the containing type's oneof_decl + * list. This field is a member of that oneof. + */ + oneofIndex: number; + /** + * JSON name of this field. The value is set by protocol compiler. If the + * user has set a "json_name" option on this field, that option's value + * will be used. Otherwise, it's deduced from the field's name by converting + * it to camelCase. + */ + jsonName: string; + options: FieldOptions | undefined; + /** + * If true, this is a proto3 "optional". When a proto3 field is optional, it + * tracks presence regardless of field type. + * + * When proto3_optional is true, this field must be belong to a oneof to + * signal to old proto3 clients that presence is tracked for this field. This + * oneof is known as a "synthetic" oneof, and this field must be its sole + * member (each proto3 optional field gets its own synthetic oneof). Synthetic + * oneofs exist in the descriptor only, and do not generate any API. Synthetic + * oneofs must be ordered after all "real" oneofs. + * + * For message fields, proto3_optional doesn't create any semantic change, + * since non-repeated message fields always track presence. However it still + * indicates the semantic detail of whether the user wrote "optional" or not. + * This can be useful for round-tripping the .proto file. For consistency we + * give message fields a synthetic oneof also, even though it is not required + * to track presence. This is especially important because the parser can't + * tell if a field is a message or an enum, so it must always create a + * synthetic oneof. + * + * Proto2 optional fields do not set this flag, because they already indicate + * optional with `LABEL_OPTIONAL`. + */ + proto3Optional: boolean; +} + +export enum FieldDescriptorProto_Type { + /** + * TYPE_DOUBLE - 0 is reserved for errors. + * Order is weird for historical reasons. + */ + TYPE_DOUBLE = 1, + TYPE_FLOAT = 2, + /** + * TYPE_INT64 - Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT64 if + * negative values are likely. + */ + TYPE_INT64 = 3, + TYPE_UINT64 = 4, + /** + * TYPE_INT32 - Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT32 if + * negative values are likely. + */ + TYPE_INT32 = 5, + TYPE_FIXED64 = 6, + TYPE_FIXED32 = 7, + TYPE_BOOL = 8, + TYPE_STRING = 9, + /** + * TYPE_GROUP - Tag-delimited aggregate. + * Group type is deprecated and not supported in proto3. However, Proto3 + * implementations should still be able to parse the group wire format and + * treat group fields as unknown fields. + */ + TYPE_GROUP = 10, + /** TYPE_MESSAGE - Length-delimited aggregate. */ + TYPE_MESSAGE = 11, + /** TYPE_BYTES - New in version 2. */ + TYPE_BYTES = 12, + TYPE_UINT32 = 13, + TYPE_ENUM = 14, + TYPE_SFIXED32 = 15, + TYPE_SFIXED64 = 16, + /** TYPE_SINT32 - Uses ZigZag encoding. */ + TYPE_SINT32 = 17, + /** TYPE_SINT64 - Uses ZigZag encoding. */ + TYPE_SINT64 = 18, + UNRECOGNIZED = -1, +} + +export function fieldDescriptorProto_TypeFromJSON( + object: any +): FieldDescriptorProto_Type { + switch (object) { + case 1: + case "TYPE_DOUBLE": + return FieldDescriptorProto_Type.TYPE_DOUBLE; + case 2: + case "TYPE_FLOAT": + return FieldDescriptorProto_Type.TYPE_FLOAT; + case 3: + case "TYPE_INT64": + return FieldDescriptorProto_Type.TYPE_INT64; + case 4: + case "TYPE_UINT64": + return FieldDescriptorProto_Type.TYPE_UINT64; + case 5: + case "TYPE_INT32": + return FieldDescriptorProto_Type.TYPE_INT32; + case 6: + case "TYPE_FIXED64": + return FieldDescriptorProto_Type.TYPE_FIXED64; + case 7: + case "TYPE_FIXED32": + return FieldDescriptorProto_Type.TYPE_FIXED32; + case 8: + case "TYPE_BOOL": + return FieldDescriptorProto_Type.TYPE_BOOL; + case 9: + case "TYPE_STRING": + return FieldDescriptorProto_Type.TYPE_STRING; + case 10: + case "TYPE_GROUP": + return FieldDescriptorProto_Type.TYPE_GROUP; + case 11: + case "TYPE_MESSAGE": + return FieldDescriptorProto_Type.TYPE_MESSAGE; + case 12: + case "TYPE_BYTES": + return FieldDescriptorProto_Type.TYPE_BYTES; + case 13: + case "TYPE_UINT32": + return FieldDescriptorProto_Type.TYPE_UINT32; + case 14: + case "TYPE_ENUM": + return FieldDescriptorProto_Type.TYPE_ENUM; + case 15: + case "TYPE_SFIXED32": + return FieldDescriptorProto_Type.TYPE_SFIXED32; + case 16: + case "TYPE_SFIXED64": + return FieldDescriptorProto_Type.TYPE_SFIXED64; + case 17: + case "TYPE_SINT32": + return FieldDescriptorProto_Type.TYPE_SINT32; + case 18: + case "TYPE_SINT64": + return FieldDescriptorProto_Type.TYPE_SINT64; + case -1: + case "UNRECOGNIZED": + default: + return FieldDescriptorProto_Type.UNRECOGNIZED; + } +} + +export function fieldDescriptorProto_TypeToJSON( + object: FieldDescriptorProto_Type +): string { + switch (object) { + case FieldDescriptorProto_Type.TYPE_DOUBLE: + return "TYPE_DOUBLE"; + case FieldDescriptorProto_Type.TYPE_FLOAT: + return "TYPE_FLOAT"; + case FieldDescriptorProto_Type.TYPE_INT64: + return "TYPE_INT64"; + case FieldDescriptorProto_Type.TYPE_UINT64: + return "TYPE_UINT64"; + case FieldDescriptorProto_Type.TYPE_INT32: + return "TYPE_INT32"; + case FieldDescriptorProto_Type.TYPE_FIXED64: + return "TYPE_FIXED64"; + case FieldDescriptorProto_Type.TYPE_FIXED32: + return "TYPE_FIXED32"; + case FieldDescriptorProto_Type.TYPE_BOOL: + return "TYPE_BOOL"; + case FieldDescriptorProto_Type.TYPE_STRING: + return "TYPE_STRING"; + case FieldDescriptorProto_Type.TYPE_GROUP: + return "TYPE_GROUP"; + case FieldDescriptorProto_Type.TYPE_MESSAGE: + return "TYPE_MESSAGE"; + case FieldDescriptorProto_Type.TYPE_BYTES: + return "TYPE_BYTES"; + case FieldDescriptorProto_Type.TYPE_UINT32: + return "TYPE_UINT32"; + case FieldDescriptorProto_Type.TYPE_ENUM: + return "TYPE_ENUM"; + case FieldDescriptorProto_Type.TYPE_SFIXED32: + return "TYPE_SFIXED32"; + case FieldDescriptorProto_Type.TYPE_SFIXED64: + return "TYPE_SFIXED64"; + case FieldDescriptorProto_Type.TYPE_SINT32: + return "TYPE_SINT32"; + case FieldDescriptorProto_Type.TYPE_SINT64: + return "TYPE_SINT64"; + default: + return "UNKNOWN"; + } +} + +export enum FieldDescriptorProto_Label { + /** LABEL_OPTIONAL - 0 is reserved for errors */ + LABEL_OPTIONAL = 1, + LABEL_REQUIRED = 2, + LABEL_REPEATED = 3, + UNRECOGNIZED = -1, +} + +export function fieldDescriptorProto_LabelFromJSON( + object: any +): FieldDescriptorProto_Label { + switch (object) { + case 1: + case "LABEL_OPTIONAL": + return FieldDescriptorProto_Label.LABEL_OPTIONAL; + case 2: + case "LABEL_REQUIRED": + return FieldDescriptorProto_Label.LABEL_REQUIRED; + case 3: + case "LABEL_REPEATED": + return FieldDescriptorProto_Label.LABEL_REPEATED; + case -1: + case "UNRECOGNIZED": + default: + return FieldDescriptorProto_Label.UNRECOGNIZED; + } +} + +export function fieldDescriptorProto_LabelToJSON( + object: FieldDescriptorProto_Label +): string { + switch (object) { + case FieldDescriptorProto_Label.LABEL_OPTIONAL: + return "LABEL_OPTIONAL"; + case FieldDescriptorProto_Label.LABEL_REQUIRED: + return "LABEL_REQUIRED"; + case FieldDescriptorProto_Label.LABEL_REPEATED: + return "LABEL_REPEATED"; + default: + return "UNKNOWN"; + } +} + +/** Describes a oneof. */ +export interface OneofDescriptorProto { + name: string; + options: OneofOptions | undefined; +} + +/** Describes an enum type. */ +export interface EnumDescriptorProto { + name: string; + value: EnumValueDescriptorProto[]; + options: EnumOptions | undefined; + /** + * Range of reserved numeric values. Reserved numeric values may not be used + * by enum values in the same enum declaration. Reserved ranges may not + * overlap. + */ + reservedRange: EnumDescriptorProto_EnumReservedRange[]; + /** + * Reserved enum value names, which may not be reused. A given name may only + * be reserved once. + */ + reservedName: string[]; +} + +/** + * Range of reserved numeric values. Reserved values may not be used by + * entries in the same enum. Reserved ranges may not overlap. + * + * Note that this is distinct from DescriptorProto.ReservedRange in that it + * is inclusive such that it can appropriately represent the entire int32 + * domain. + */ +export interface EnumDescriptorProto_EnumReservedRange { + /** Inclusive. */ + start: number; + /** Inclusive. */ + end: number; +} + +/** Describes a value within an enum. */ +export interface EnumValueDescriptorProto { + name: string; + number: number; + options: EnumValueOptions | undefined; +} + +/** Describes a service. */ +export interface ServiceDescriptorProto { + name: string; + method: MethodDescriptorProto[]; + options: ServiceOptions | undefined; +} + +/** Describes a method of a service. */ +export interface MethodDescriptorProto { + name: string; + /** + * Input and output type names. These are resolved in the same way as + * FieldDescriptorProto.type_name, but must refer to a message type. + */ + inputType: string; + outputType: string; + options: MethodOptions | undefined; + /** Identifies if client streams multiple client messages */ + clientStreaming: boolean; + /** Identifies if server streams multiple server messages */ + serverStreaming: boolean; +} + +export interface FileOptions { + /** + * Sets the Java package where classes generated from this .proto will be + * placed. By default, the proto package is used, but this is often + * inappropriate because proto packages do not normally start with backwards + * domain names. + */ + javaPackage: string; + /** + * Controls the name of the wrapper Java class generated for the .proto file. + * That class will always contain the .proto file's getDescriptor() method as + * well as any top-level extensions defined in the .proto file. + * If java_multiple_files is disabled, then all the other classes from the + * .proto file will be nested inside the single wrapper outer class. + */ + javaOuterClassname: string; + /** + * If enabled, then the Java code generator will generate a separate .java + * file for each top-level message, enum, and service defined in the .proto + * file. Thus, these types will *not* be nested inside the wrapper class + * named by java_outer_classname. However, the wrapper class will still be + * generated to contain the file's getDescriptor() method as well as any + * top-level extensions defined in the file. + */ + javaMultipleFiles: boolean; + /** + * This option does nothing. + * + * @deprecated + */ + javaGenerateEqualsAndHash: boolean; + /** + * If set true, then the Java2 code generator will generate code that + * throws an exception whenever an attempt is made to assign a non-UTF-8 + * byte sequence to a string field. + * Message reflection will do the same. + * However, an extension field still accepts non-UTF-8 byte sequences. + * This option has no effect on when used with the lite runtime. + */ + javaStringCheckUtf8: boolean; + optimizeFor: FileOptions_OptimizeMode; + /** + * Sets the Go package where structs generated from this .proto will be + * placed. If omitted, the Go package will be derived from the following: + * - The basename of the package import path, if provided. + * - Otherwise, the package statement in the .proto file, if present. + * - Otherwise, the basename of the .proto file, without extension. + */ + goPackage: string; + /** + * Should generic services be generated in each language? "Generic" services + * are not specific to any particular RPC system. They are generated by the + * main code generators in each language (without additional plugins). + * Generic services were the only kind of service generation supported by + * early versions of google.protobuf. + * + * Generic services are now considered deprecated in favor of using plugins + * that generate code specific to your particular RPC system. Therefore, + * these default to false. Old code which depends on generic services should + * explicitly set them to true. + */ + ccGenericServices: boolean; + javaGenericServices: boolean; + pyGenericServices: boolean; + phpGenericServices: boolean; + /** + * Is this file deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for everything in the file, or it will be completely ignored; in the very + * least, this is a formalization for deprecating files. + */ + deprecated: boolean; + /** + * Enables the use of arenas for the proto messages in this file. This applies + * only to generated classes for C++. + */ + ccEnableArenas: boolean; + /** + * Sets the objective c class prefix which is prepended to all objective c + * generated classes from this .proto. There is no default. + */ + objcClassPrefix: string; + /** Namespace for generated classes; defaults to the package. */ + csharpNamespace: string; + /** + * By default Swift generators will take the proto package and CamelCase it + * replacing '.' with underscore and use that to prefix the types/symbols + * defined. When this options is provided, they will use this value instead + * to prefix the types/symbols defined. + */ + swiftPrefix: string; + /** + * Sets the php class prefix which is prepended to all php generated classes + * from this .proto. Default is empty. + */ + phpClassPrefix: string; + /** + * Use this option to change the namespace of php generated classes. Default + * is empty. When this option is empty, the package name will be used for + * determining the namespace. + */ + phpNamespace: string; + /** + * Use this option to change the namespace of php generated metadata classes. + * Default is empty. When this option is empty, the proto file name will be + * used for determining the namespace. + */ + phpMetadataNamespace: string; + /** + * Use this option to change the package of ruby generated classes. Default + * is empty. When this option is not set, the package name will be used for + * determining the ruby package. + */ + rubyPackage: string; + /** + * The parser stores options it doesn't recognize here. + * See the documentation for the "Options" section above. + */ + uninterpretedOption: UninterpretedOption[]; +} + +/** Generated classes can be optimized for speed or code size. */ +export enum FileOptions_OptimizeMode { + /** SPEED - Generate complete code for parsing, serialization, */ + SPEED = 1, + /** CODE_SIZE - etc. */ + CODE_SIZE = 2, + /** LITE_RUNTIME - Generate code using MessageLite and the lite runtime. */ + LITE_RUNTIME = 3, + UNRECOGNIZED = -1, +} + +export function fileOptions_OptimizeModeFromJSON( + object: any +): FileOptions_OptimizeMode { + switch (object) { + case 1: + case "SPEED": + return FileOptions_OptimizeMode.SPEED; + case 2: + case "CODE_SIZE": + return FileOptions_OptimizeMode.CODE_SIZE; + case 3: + case "LITE_RUNTIME": + return FileOptions_OptimizeMode.LITE_RUNTIME; + case -1: + case "UNRECOGNIZED": + default: + return FileOptions_OptimizeMode.UNRECOGNIZED; + } +} + +export function fileOptions_OptimizeModeToJSON( + object: FileOptions_OptimizeMode +): string { + switch (object) { + case FileOptions_OptimizeMode.SPEED: + return "SPEED"; + case FileOptions_OptimizeMode.CODE_SIZE: + return "CODE_SIZE"; + case FileOptions_OptimizeMode.LITE_RUNTIME: + return "LITE_RUNTIME"; + default: + return "UNKNOWN"; + } +} + +export interface MessageOptions { + /** + * Set true to use the old proto1 MessageSet wire format for extensions. + * This is provided for backwards-compatibility with the MessageSet wire + * format. You should not use this for any other reason: It's less + * efficient, has fewer features, and is more complicated. + * + * The message must be defined exactly as follows: + * message Foo { + * option message_set_wire_format = true; + * extensions 4 to max; + * } + * Note that the message cannot have any defined fields; MessageSets only + * have extensions. + * + * All extensions of your type must be singular messages; e.g. they cannot + * be int32s, enums, or repeated messages. + * + * Because this is an option, the above two restrictions are not enforced by + * the protocol compiler. + */ + messageSetWireFormat: boolean; + /** + * Disables the generation of the standard "descriptor()" accessor, which can + * conflict with a field of the same name. This is meant to make migration + * from proto1 easier; new code should avoid fields named "descriptor". + */ + noStandardDescriptorAccessor: boolean; + /** + * Is this message deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the message, or it will be completely ignored; in the very least, + * this is a formalization for deprecating messages. + */ + deprecated: boolean; + /** + * Whether the message is an automatically generated map entry type for the + * maps field. + * + * For maps fields: + * map map_field = 1; + * The parsed descriptor looks like: + * message MapFieldEntry { + * option map_entry = true; + * optional KeyType key = 1; + * optional ValueType value = 2; + * } + * repeated MapFieldEntry map_field = 1; + * + * Implementations may choose not to generate the map_entry=true message, but + * use a native map in the target language to hold the keys and values. + * The reflection APIs in such implementations still need to work as + * if the field is a repeated message field. + * + * NOTE: Do not set the option in .proto files. Always use the maps syntax + * instead. The option should only be implicitly set by the proto compiler + * parser. + */ + mapEntry: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface FieldOptions { + /** + * The ctype option instructs the C++ code generator to use a different + * representation of the field than it normally would. See the specific + * options below. This option is not yet implemented in the open source + * release -- sorry, we'll try to include it in a future version! + */ + ctype: FieldOptions_CType; + /** + * The packed option can be enabled for repeated primitive fields to enable + * a more efficient representation on the wire. Rather than repeatedly + * writing the tag and type for each element, the entire array is encoded as + * a single length-delimited blob. In proto3, only explicit setting it to + * false will avoid using packed encoding. + */ + packed: boolean; + /** + * The jstype option determines the JavaScript type used for values of the + * field. The option is permitted only for 64 bit integral and fixed types + * (int64, uint64, sint64, fixed64, sfixed64). A field with jstype JS_STRING + * is represented as JavaScript string, which avoids loss of precision that + * can happen when a large value is converted to a floating point JavaScript. + * Specifying JS_NUMBER for the jstype causes the generated JavaScript code to + * use the JavaScript "number" type. The behavior of the default option + * JS_NORMAL is implementation dependent. + * + * This option is an enum to permit additional types to be added, e.g. + * goog.math.Integer. + */ + jstype: FieldOptions_JSType; + /** + * Should this field be parsed lazily? Lazy applies only to message-type + * fields. It means that when the outer message is initially parsed, the + * inner message's contents will not be parsed but instead stored in encoded + * form. The inner message will actually be parsed when it is first accessed. + * + * This is only a hint. Implementations are free to choose whether to use + * eager or lazy parsing regardless of the value of this option. However, + * setting this option true suggests that the protocol author believes that + * using lazy parsing on this field is worth the additional bookkeeping + * overhead typically needed to implement it. + * + * This option does not affect the public interface of any generated code; + * all method signatures remain the same. Furthermore, thread-safety of the + * interface is not affected by this option; const methods remain safe to + * call from multiple threads concurrently, while non-const methods continue + * to require exclusive access. + * + * + * Note that implementations may choose not to check required fields within + * a lazy sub-message. That is, calling IsInitialized() on the outer message + * may return true even if the inner message has missing required fields. + * This is necessary because otherwise the inner message would have to be + * parsed in order to perform the check, defeating the purpose of lazy + * parsing. An implementation which chooses not to check required fields + * must be consistent about it. That is, for any particular sub-message, the + * implementation must either *always* check its required fields, or *never* + * check its required fields, regardless of whether or not the message has + * been parsed. + */ + lazy: boolean; + /** + * Is this field deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for accessors, or it will be completely ignored; in the very least, this + * is a formalization for deprecating fields. + */ + deprecated: boolean; + /** For Google-internal migration only. Do not use. */ + weak: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export enum FieldOptions_CType { + /** STRING - Default mode. */ + STRING = 0, + CORD = 1, + STRING_PIECE = 2, + UNRECOGNIZED = -1, +} + +export function fieldOptions_CTypeFromJSON(object: any): FieldOptions_CType { + switch (object) { + case 0: + case "STRING": + return FieldOptions_CType.STRING; + case 1: + case "CORD": + return FieldOptions_CType.CORD; + case 2: + case "STRING_PIECE": + return FieldOptions_CType.STRING_PIECE; + case -1: + case "UNRECOGNIZED": + default: + return FieldOptions_CType.UNRECOGNIZED; + } +} + +export function fieldOptions_CTypeToJSON(object: FieldOptions_CType): string { + switch (object) { + case FieldOptions_CType.STRING: + return "STRING"; + case FieldOptions_CType.CORD: + return "CORD"; + case FieldOptions_CType.STRING_PIECE: + return "STRING_PIECE"; + default: + return "UNKNOWN"; + } +} + +export enum FieldOptions_JSType { + /** JS_NORMAL - Use the default type. */ + JS_NORMAL = 0, + /** JS_STRING - Use JavaScript strings. */ + JS_STRING = 1, + /** JS_NUMBER - Use JavaScript numbers. */ + JS_NUMBER = 2, + UNRECOGNIZED = -1, +} + +export function fieldOptions_JSTypeFromJSON(object: any): FieldOptions_JSType { + switch (object) { + case 0: + case "JS_NORMAL": + return FieldOptions_JSType.JS_NORMAL; + case 1: + case "JS_STRING": + return FieldOptions_JSType.JS_STRING; + case 2: + case "JS_NUMBER": + return FieldOptions_JSType.JS_NUMBER; + case -1: + case "UNRECOGNIZED": + default: + return FieldOptions_JSType.UNRECOGNIZED; + } +} + +export function fieldOptions_JSTypeToJSON(object: FieldOptions_JSType): string { + switch (object) { + case FieldOptions_JSType.JS_NORMAL: + return "JS_NORMAL"; + case FieldOptions_JSType.JS_STRING: + return "JS_STRING"; + case FieldOptions_JSType.JS_NUMBER: + return "JS_NUMBER"; + default: + return "UNKNOWN"; + } +} + +export interface OneofOptions { + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface EnumOptions { + /** + * Set this option to true to allow mapping different tag names to the same + * value. + */ + allowAlias: boolean; + /** + * Is this enum deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the enum, or it will be completely ignored; in the very least, this + * is a formalization for deprecating enums. + */ + deprecated: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface EnumValueOptions { + /** + * Is this enum value deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the enum value, or it will be completely ignored; in the very least, + * this is a formalization for deprecating enum values. + */ + deprecated: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface ServiceOptions { + /** + * Is this service deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the service, or it will be completely ignored; in the very least, + * this is a formalization for deprecating services. + */ + deprecated: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface MethodOptions { + /** + * Is this method deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the method, or it will be completely ignored; in the very least, + * this is a formalization for deprecating methods. + */ + deprecated: boolean; + idempotencyLevel: MethodOptions_IdempotencyLevel; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +/** + * Is this method side-effect-free (or safe in HTTP parlance), or idempotent, + * or neither? HTTP based RPC implementation may choose GET verb for safe + * methods, and PUT verb for idempotent methods instead of the default POST. + */ +export enum MethodOptions_IdempotencyLevel { + IDEMPOTENCY_UNKNOWN = 0, + /** NO_SIDE_EFFECTS - implies idempotent */ + NO_SIDE_EFFECTS = 1, + /** IDEMPOTENT - idempotent, but may have side effects */ + IDEMPOTENT = 2, + UNRECOGNIZED = -1, +} + +export function methodOptions_IdempotencyLevelFromJSON( + object: any +): MethodOptions_IdempotencyLevel { + switch (object) { + case 0: + case "IDEMPOTENCY_UNKNOWN": + return MethodOptions_IdempotencyLevel.IDEMPOTENCY_UNKNOWN; + case 1: + case "NO_SIDE_EFFECTS": + return MethodOptions_IdempotencyLevel.NO_SIDE_EFFECTS; + case 2: + case "IDEMPOTENT": + return MethodOptions_IdempotencyLevel.IDEMPOTENT; + case -1: + case "UNRECOGNIZED": + default: + return MethodOptions_IdempotencyLevel.UNRECOGNIZED; + } +} + +export function methodOptions_IdempotencyLevelToJSON( + object: MethodOptions_IdempotencyLevel +): string { + switch (object) { + case MethodOptions_IdempotencyLevel.IDEMPOTENCY_UNKNOWN: + return "IDEMPOTENCY_UNKNOWN"; + case MethodOptions_IdempotencyLevel.NO_SIDE_EFFECTS: + return "NO_SIDE_EFFECTS"; + case MethodOptions_IdempotencyLevel.IDEMPOTENT: + return "IDEMPOTENT"; + default: + return "UNKNOWN"; + } +} + +/** + * A message representing a option the parser does not recognize. This only + * appears in options protos created by the compiler::Parser class. + * DescriptorPool resolves these when building Descriptor objects. Therefore, + * options protos in descriptor objects (e.g. returned by Descriptor::options(), + * or produced by Descriptor::CopyTo()) will never have UninterpretedOptions + * in them. + */ +export interface UninterpretedOption { + name: UninterpretedOption_NamePart[]; + /** + * The value of the uninterpreted option, in whatever type the tokenizer + * identified it as during parsing. Exactly one of these should be set. + */ + identifierValue: string; + positiveIntValue: number; + negativeIntValue: number; + doubleValue: number; + stringValue: Uint8Array; + aggregateValue: string; +} + +/** + * The name of the uninterpreted option. Each string represents a segment in + * a dot-separated name. is_extension is true iff a segment represents an + * extension (denoted with parentheses in options specs in .proto files). + * E.g.,{ ["foo", false], ["bar.baz", true], ["qux", false] } represents + * "foo.(bar.baz).qux". + */ +export interface UninterpretedOption_NamePart { + namePart: string; + isExtension: boolean; +} + +/** + * Encapsulates information about the original source file from which a + * FileDescriptorProto was generated. + */ +export interface SourceCodeInfo { + /** + * A Location identifies a piece of source code in a .proto file which + * corresponds to a particular definition. This information is intended + * to be useful to IDEs, code indexers, documentation generators, and similar + * tools. + * + * For example, say we have a file like: + * message Foo { + * optional string foo = 1; + * } + * Let's look at just the field definition: + * optional string foo = 1; + * ^ ^^ ^^ ^ ^^^ + * a bc de f ghi + * We have the following locations: + * span path represents + * [a,i) [ 4, 0, 2, 0 ] The whole field definition. + * [a,b) [ 4, 0, 2, 0, 4 ] The label (optional). + * [c,d) [ 4, 0, 2, 0, 5 ] The type (string). + * [e,f) [ 4, 0, 2, 0, 1 ] The name (foo). + * [g,h) [ 4, 0, 2, 0, 3 ] The number (1). + * + * Notes: + * - A location may refer to a repeated field itself (i.e. not to any + * particular index within it). This is used whenever a set of elements are + * logically enclosed in a single code segment. For example, an entire + * extend block (possibly containing multiple extension definitions) will + * have an outer location whose path refers to the "extensions" repeated + * field without an index. + * - Multiple locations may have the same path. This happens when a single + * logical declaration is spread out across multiple places. The most + * obvious example is the "extend" block again -- there may be multiple + * extend blocks in the same scope, each of which will have the same path. + * - A location's span is not always a subset of its parent's span. For + * example, the "extendee" of an extension declaration appears at the + * beginning of the "extend" block and is shared by all extensions within + * the block. + * - Just because a location's span is a subset of some other location's span + * does not mean that it is a descendant. For example, a "group" defines + * both a type and a field in a single declaration. Thus, the locations + * corresponding to the type and field and their components will overlap. + * - Code which tries to interpret locations should probably be designed to + * ignore those that it doesn't understand, as more types of locations could + * be recorded in the future. + */ + location: SourceCodeInfo_Location[]; +} + +export interface SourceCodeInfo_Location { + /** + * Identifies which part of the FileDescriptorProto was defined at this + * location. + * + * Each element is a field number or an index. They form a path from + * the root FileDescriptorProto to the place where the definition. For + * example, this path: + * [ 4, 3, 2, 7, 1 ] + * refers to: + * file.message_type(3) // 4, 3 + * .field(7) // 2, 7 + * .name() // 1 + * This is because FileDescriptorProto.message_type has field number 4: + * repeated DescriptorProto message_type = 4; + * and DescriptorProto.field has field number 2: + * repeated FieldDescriptorProto field = 2; + * and FieldDescriptorProto.name has field number 1: + * optional string name = 1; + * + * Thus, the above path gives the location of a field name. If we removed + * the last element: + * [ 4, 3, 2, 7 ] + * this path refers to the whole field declaration (from the beginning + * of the label to the terminating semicolon). + */ + path: number[]; + /** + * Always has exactly three or four elements: start line, start column, + * end line (optional, otherwise assumed same as start line), end column. + * These are packed into a single field for efficiency. Note that line + * and column numbers are zero-based -- typically you will want to add + * 1 to each before displaying to a user. + */ + span: number[]; + /** + * If this SourceCodeInfo represents a complete declaration, these are any + * comments appearing before and after the declaration which appear to be + * attached to the declaration. + * + * A series of line comments appearing on consecutive lines, with no other + * tokens appearing on those lines, will be treated as a single comment. + * + * leading_detached_comments will keep paragraphs of comments that appear + * before (but not connected to) the current element. Each paragraph, + * separated by empty lines, will be one comment element in the repeated + * field. + * + * Only the comment content is provided; comment markers (e.g. //) are + * stripped out. For block comments, leading whitespace and an asterisk + * will be stripped from the beginning of each line other than the first. + * Newlines are included in the output. + * + * Examples: + * + * optional int32 foo = 1; // Comment attached to foo. + * // Comment attached to bar. + * optional int32 bar = 2; + * + * optional string baz = 3; + * // Comment attached to baz. + * // Another line attached to baz. + * + * // Comment attached to qux. + * // + * // Another line attached to qux. + * optional double qux = 4; + * + * // Detached comment for corge. This is not leading or trailing comments + * // to qux or corge because there are blank lines separating it from + * // both. + * + * // Detached comment for corge paragraph 2. + * + * optional string corge = 5; + * /* Block comment attached + * * to corge. Leading asterisks + * * will be removed. * / + * /* Block comment attached to + * * grault. * / + * optional int32 grault = 6; + * + * // ignored detached comments. + */ + leadingComments: string; + trailingComments: string; + leadingDetachedComments: string[]; +} + +/** + * Describes the relationship between generated code and its original source + * file. A GeneratedCodeInfo message is associated with only one generated + * source file, but may contain references to different source .proto files. + */ +export interface GeneratedCodeInfo { + /** + * An Annotation connects some span of text in generated code to an element + * of its generating .proto file. + */ + annotation: GeneratedCodeInfo_Annotation[]; +} + +export interface GeneratedCodeInfo_Annotation { + /** + * Identifies the element in the original source .proto file. This field + * is formatted the same as SourceCodeInfo.Location.path. + */ + path: number[]; + /** Identifies the filesystem path to the original source .proto. */ + sourceFile: string; + /** + * Identifies the starting offset in bytes in the generated code + * that relates to the identified object. + */ + begin: number; + /** + * Identifies the ending offset in bytes in the generated code that + * relates to the identified offset. The end offset should be one past + * the last relevant byte (so the length of the text = end - begin). + */ + end: number; +} + +const baseFileDescriptorSet: object = {}; + +export const FileDescriptorSet = { + encode(message: FileDescriptorSet, writer: Writer = Writer.create()): Writer { + for (const v of message.file) { + FileDescriptorProto.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FileDescriptorSet { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFileDescriptorSet } as FileDescriptorSet; + message.file = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.file.push( + FileDescriptorProto.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FileDescriptorSet { + const message = { ...baseFileDescriptorSet } as FileDescriptorSet; + message.file = []; + if (object.file !== undefined && object.file !== null) { + for (const e of object.file) { + message.file.push(FileDescriptorProto.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: FileDescriptorSet): unknown { + const obj: any = {}; + if (message.file) { + obj.file = message.file.map((e) => + e ? FileDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.file = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): FileDescriptorSet { + const message = { ...baseFileDescriptorSet } as FileDescriptorSet; + message.file = []; + if (object.file !== undefined && object.file !== null) { + for (const e of object.file) { + message.file.push(FileDescriptorProto.fromPartial(e)); + } + } + return message; + }, +}; + +const baseFileDescriptorProto: object = { + name: "", + package: "", + dependency: "", + publicDependency: 0, + weakDependency: 0, + syntax: "", +}; + +export const FileDescriptorProto = { + encode( + message: FileDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.package !== "") { + writer.uint32(18).string(message.package); + } + for (const v of message.dependency) { + writer.uint32(26).string(v!); + } + writer.uint32(82).fork(); + for (const v of message.publicDependency) { + writer.int32(v); + } + writer.ldelim(); + writer.uint32(90).fork(); + for (const v of message.weakDependency) { + writer.int32(v); + } + writer.ldelim(); + for (const v of message.messageType) { + DescriptorProto.encode(v!, writer.uint32(34).fork()).ldelim(); + } + for (const v of message.enumType) { + EnumDescriptorProto.encode(v!, writer.uint32(42).fork()).ldelim(); + } + for (const v of message.service) { + ServiceDescriptorProto.encode(v!, writer.uint32(50).fork()).ldelim(); + } + for (const v of message.extension) { + FieldDescriptorProto.encode(v!, writer.uint32(58).fork()).ldelim(); + } + if (message.options !== undefined) { + FileOptions.encode(message.options, writer.uint32(66).fork()).ldelim(); + } + if (message.sourceCodeInfo !== undefined) { + SourceCodeInfo.encode( + message.sourceCodeInfo, + writer.uint32(74).fork() + ).ldelim(); + } + if (message.syntax !== "") { + writer.uint32(98).string(message.syntax); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FileDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFileDescriptorProto } as FileDescriptorProto; + message.dependency = []; + message.publicDependency = []; + message.weakDependency = []; + message.messageType = []; + message.enumType = []; + message.service = []; + message.extension = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.package = reader.string(); + break; + case 3: + message.dependency.push(reader.string()); + break; + case 10: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.publicDependency.push(reader.int32()); + } + } else { + message.publicDependency.push(reader.int32()); + } + break; + case 11: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.weakDependency.push(reader.int32()); + } + } else { + message.weakDependency.push(reader.int32()); + } + break; + case 4: + message.messageType.push( + DescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 5: + message.enumType.push( + EnumDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 6: + message.service.push( + ServiceDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 7: + message.extension.push( + FieldDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 8: + message.options = FileOptions.decode(reader, reader.uint32()); + break; + case 9: + message.sourceCodeInfo = SourceCodeInfo.decode( + reader, + reader.uint32() + ); + break; + case 12: + message.syntax = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FileDescriptorProto { + const message = { ...baseFileDescriptorProto } as FileDescriptorProto; + message.dependency = []; + message.publicDependency = []; + message.weakDependency = []; + message.messageType = []; + message.enumType = []; + message.service = []; + message.extension = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.package !== undefined && object.package !== null) { + message.package = String(object.package); + } else { + message.package = ""; + } + if (object.dependency !== undefined && object.dependency !== null) { + for (const e of object.dependency) { + message.dependency.push(String(e)); + } + } + if ( + object.publicDependency !== undefined && + object.publicDependency !== null + ) { + for (const e of object.publicDependency) { + message.publicDependency.push(Number(e)); + } + } + if (object.weakDependency !== undefined && object.weakDependency !== null) { + for (const e of object.weakDependency) { + message.weakDependency.push(Number(e)); + } + } + if (object.messageType !== undefined && object.messageType !== null) { + for (const e of object.messageType) { + message.messageType.push(DescriptorProto.fromJSON(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromJSON(e)); + } + } + if (object.service !== undefined && object.service !== null) { + for (const e of object.service) { + message.service.push(ServiceDescriptorProto.fromJSON(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = FileOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.sourceCodeInfo !== undefined && object.sourceCodeInfo !== null) { + message.sourceCodeInfo = SourceCodeInfo.fromJSON(object.sourceCodeInfo); + } else { + message.sourceCodeInfo = undefined; + } + if (object.syntax !== undefined && object.syntax !== null) { + message.syntax = String(object.syntax); + } else { + message.syntax = ""; + } + return message; + }, + + toJSON(message: FileDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.package !== undefined && (obj.package = message.package); + if (message.dependency) { + obj.dependency = message.dependency.map((e) => e); + } else { + obj.dependency = []; + } + if (message.publicDependency) { + obj.publicDependency = message.publicDependency.map((e) => e); + } else { + obj.publicDependency = []; + } + if (message.weakDependency) { + obj.weakDependency = message.weakDependency.map((e) => e); + } else { + obj.weakDependency = []; + } + if (message.messageType) { + obj.messageType = message.messageType.map((e) => + e ? DescriptorProto.toJSON(e) : undefined + ); + } else { + obj.messageType = []; + } + if (message.enumType) { + obj.enumType = message.enumType.map((e) => + e ? EnumDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.enumType = []; + } + if (message.service) { + obj.service = message.service.map((e) => + e ? ServiceDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.service = []; + } + if (message.extension) { + obj.extension = message.extension.map((e) => + e ? FieldDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.extension = []; + } + message.options !== undefined && + (obj.options = message.options + ? FileOptions.toJSON(message.options) + : undefined); + message.sourceCodeInfo !== undefined && + (obj.sourceCodeInfo = message.sourceCodeInfo + ? SourceCodeInfo.toJSON(message.sourceCodeInfo) + : undefined); + message.syntax !== undefined && (obj.syntax = message.syntax); + return obj; + }, + + fromPartial(object: DeepPartial): FileDescriptorProto { + const message = { ...baseFileDescriptorProto } as FileDescriptorProto; + message.dependency = []; + message.publicDependency = []; + message.weakDependency = []; + message.messageType = []; + message.enumType = []; + message.service = []; + message.extension = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.package !== undefined && object.package !== null) { + message.package = object.package; + } else { + message.package = ""; + } + if (object.dependency !== undefined && object.dependency !== null) { + for (const e of object.dependency) { + message.dependency.push(e); + } + } + if ( + object.publicDependency !== undefined && + object.publicDependency !== null + ) { + for (const e of object.publicDependency) { + message.publicDependency.push(e); + } + } + if (object.weakDependency !== undefined && object.weakDependency !== null) { + for (const e of object.weakDependency) { + message.weakDependency.push(e); + } + } + if (object.messageType !== undefined && object.messageType !== null) { + for (const e of object.messageType) { + message.messageType.push(DescriptorProto.fromPartial(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromPartial(e)); + } + } + if (object.service !== undefined && object.service !== null) { + for (const e of object.service) { + message.service.push(ServiceDescriptorProto.fromPartial(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = FileOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.sourceCodeInfo !== undefined && object.sourceCodeInfo !== null) { + message.sourceCodeInfo = SourceCodeInfo.fromPartial( + object.sourceCodeInfo + ); + } else { + message.sourceCodeInfo = undefined; + } + if (object.syntax !== undefined && object.syntax !== null) { + message.syntax = object.syntax; + } else { + message.syntax = ""; + } + return message; + }, +}; + +const baseDescriptorProto: object = { name: "", reservedName: "" }; + +export const DescriptorProto = { + encode(message: DescriptorProto, writer: Writer = Writer.create()): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + for (const v of message.field) { + FieldDescriptorProto.encode(v!, writer.uint32(18).fork()).ldelim(); + } + for (const v of message.extension) { + FieldDescriptorProto.encode(v!, writer.uint32(50).fork()).ldelim(); + } + for (const v of message.nestedType) { + DescriptorProto.encode(v!, writer.uint32(26).fork()).ldelim(); + } + for (const v of message.enumType) { + EnumDescriptorProto.encode(v!, writer.uint32(34).fork()).ldelim(); + } + for (const v of message.extensionRange) { + DescriptorProto_ExtensionRange.encode( + v!, + writer.uint32(42).fork() + ).ldelim(); + } + for (const v of message.oneofDecl) { + OneofDescriptorProto.encode(v!, writer.uint32(66).fork()).ldelim(); + } + if (message.options !== undefined) { + MessageOptions.encode(message.options, writer.uint32(58).fork()).ldelim(); + } + for (const v of message.reservedRange) { + DescriptorProto_ReservedRange.encode( + v!, + writer.uint32(74).fork() + ).ldelim(); + } + for (const v of message.reservedName) { + writer.uint32(82).string(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): DescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseDescriptorProto } as DescriptorProto; + message.field = []; + message.extension = []; + message.nestedType = []; + message.enumType = []; + message.extensionRange = []; + message.oneofDecl = []; + message.reservedRange = []; + message.reservedName = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.field.push( + FieldDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 6: + message.extension.push( + FieldDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 3: + message.nestedType.push( + DescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 4: + message.enumType.push( + EnumDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 5: + message.extensionRange.push( + DescriptorProto_ExtensionRange.decode(reader, reader.uint32()) + ); + break; + case 8: + message.oneofDecl.push( + OneofDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 7: + message.options = MessageOptions.decode(reader, reader.uint32()); + break; + case 9: + message.reservedRange.push( + DescriptorProto_ReservedRange.decode(reader, reader.uint32()) + ); + break; + case 10: + message.reservedName.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DescriptorProto { + const message = { ...baseDescriptorProto } as DescriptorProto; + message.field = []; + message.extension = []; + message.nestedType = []; + message.enumType = []; + message.extensionRange = []; + message.oneofDecl = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.field !== undefined && object.field !== null) { + for (const e of object.field) { + message.field.push(FieldDescriptorProto.fromJSON(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromJSON(e)); + } + } + if (object.nestedType !== undefined && object.nestedType !== null) { + for (const e of object.nestedType) { + message.nestedType.push(DescriptorProto.fromJSON(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromJSON(e)); + } + } + if (object.extensionRange !== undefined && object.extensionRange !== null) { + for (const e of object.extensionRange) { + message.extensionRange.push(DescriptorProto_ExtensionRange.fromJSON(e)); + } + } + if (object.oneofDecl !== undefined && object.oneofDecl !== null) { + for (const e of object.oneofDecl) { + message.oneofDecl.push(OneofDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = MessageOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push(DescriptorProto_ReservedRange.fromJSON(e)); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(String(e)); + } + } + return message; + }, + + toJSON(message: DescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + if (message.field) { + obj.field = message.field.map((e) => + e ? FieldDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.field = []; + } + if (message.extension) { + obj.extension = message.extension.map((e) => + e ? FieldDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.extension = []; + } + if (message.nestedType) { + obj.nestedType = message.nestedType.map((e) => + e ? DescriptorProto.toJSON(e) : undefined + ); + } else { + obj.nestedType = []; + } + if (message.enumType) { + obj.enumType = message.enumType.map((e) => + e ? EnumDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.enumType = []; + } + if (message.extensionRange) { + obj.extensionRange = message.extensionRange.map((e) => + e ? DescriptorProto_ExtensionRange.toJSON(e) : undefined + ); + } else { + obj.extensionRange = []; + } + if (message.oneofDecl) { + obj.oneofDecl = message.oneofDecl.map((e) => + e ? OneofDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.oneofDecl = []; + } + message.options !== undefined && + (obj.options = message.options + ? MessageOptions.toJSON(message.options) + : undefined); + if (message.reservedRange) { + obj.reservedRange = message.reservedRange.map((e) => + e ? DescriptorProto_ReservedRange.toJSON(e) : undefined + ); + } else { + obj.reservedRange = []; + } + if (message.reservedName) { + obj.reservedName = message.reservedName.map((e) => e); + } else { + obj.reservedName = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): DescriptorProto { + const message = { ...baseDescriptorProto } as DescriptorProto; + message.field = []; + message.extension = []; + message.nestedType = []; + message.enumType = []; + message.extensionRange = []; + message.oneofDecl = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.field !== undefined && object.field !== null) { + for (const e of object.field) { + message.field.push(FieldDescriptorProto.fromPartial(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromPartial(e)); + } + } + if (object.nestedType !== undefined && object.nestedType !== null) { + for (const e of object.nestedType) { + message.nestedType.push(DescriptorProto.fromPartial(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromPartial(e)); + } + } + if (object.extensionRange !== undefined && object.extensionRange !== null) { + for (const e of object.extensionRange) { + message.extensionRange.push( + DescriptorProto_ExtensionRange.fromPartial(e) + ); + } + } + if (object.oneofDecl !== undefined && object.oneofDecl !== null) { + for (const e of object.oneofDecl) { + message.oneofDecl.push(OneofDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = MessageOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push( + DescriptorProto_ReservedRange.fromPartial(e) + ); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(e); + } + } + return message; + }, +}; + +const baseDescriptorProto_ExtensionRange: object = { start: 0, end: 0 }; + +export const DescriptorProto_ExtensionRange = { + encode( + message: DescriptorProto_ExtensionRange, + writer: Writer = Writer.create() + ): Writer { + if (message.start !== 0) { + writer.uint32(8).int32(message.start); + } + if (message.end !== 0) { + writer.uint32(16).int32(message.end); + } + if (message.options !== undefined) { + ExtensionRangeOptions.encode( + message.options, + writer.uint32(26).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): DescriptorProto_ExtensionRange { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseDescriptorProto_ExtensionRange, + } as DescriptorProto_ExtensionRange; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.start = reader.int32(); + break; + case 2: + message.end = reader.int32(); + break; + case 3: + message.options = ExtensionRangeOptions.decode( + reader, + reader.uint32() + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DescriptorProto_ExtensionRange { + const message = { + ...baseDescriptorProto_ExtensionRange, + } as DescriptorProto_ExtensionRange; + if (object.start !== undefined && object.start !== null) { + message.start = Number(object.start); + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = ExtensionRangeOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: DescriptorProto_ExtensionRange): unknown { + const obj: any = {}; + message.start !== undefined && (obj.start = message.start); + message.end !== undefined && (obj.end = message.end); + message.options !== undefined && + (obj.options = message.options + ? ExtensionRangeOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): DescriptorProto_ExtensionRange { + const message = { + ...baseDescriptorProto_ExtensionRange, + } as DescriptorProto_ExtensionRange; + if (object.start !== undefined && object.start !== null) { + message.start = object.start; + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = ExtensionRangeOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseDescriptorProto_ReservedRange: object = { start: 0, end: 0 }; + +export const DescriptorProto_ReservedRange = { + encode( + message: DescriptorProto_ReservedRange, + writer: Writer = Writer.create() + ): Writer { + if (message.start !== 0) { + writer.uint32(8).int32(message.start); + } + if (message.end !== 0) { + writer.uint32(16).int32(message.end); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): DescriptorProto_ReservedRange { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseDescriptorProto_ReservedRange, + } as DescriptorProto_ReservedRange; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.start = reader.int32(); + break; + case 2: + message.end = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DescriptorProto_ReservedRange { + const message = { + ...baseDescriptorProto_ReservedRange, + } as DescriptorProto_ReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = Number(object.start); + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + return message; + }, + + toJSON(message: DescriptorProto_ReservedRange): unknown { + const obj: any = {}; + message.start !== undefined && (obj.start = message.start); + message.end !== undefined && (obj.end = message.end); + return obj; + }, + + fromPartial( + object: DeepPartial + ): DescriptorProto_ReservedRange { + const message = { + ...baseDescriptorProto_ReservedRange, + } as DescriptorProto_ReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = object.start; + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + return message; + }, +}; + +const baseExtensionRangeOptions: object = {}; + +export const ExtensionRangeOptions = { + encode( + message: ExtensionRangeOptions, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ExtensionRangeOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseExtensionRangeOptions } as ExtensionRangeOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ExtensionRangeOptions { + const message = { ...baseExtensionRangeOptions } as ExtensionRangeOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: ExtensionRangeOptions): unknown { + const obj: any = {}; + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial( + object: DeepPartial + ): ExtensionRangeOptions { + const message = { ...baseExtensionRangeOptions } as ExtensionRangeOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseFieldDescriptorProto: object = { + name: "", + number: 0, + label: 1, + type: 1, + typeName: "", + extendee: "", + defaultValue: "", + oneofIndex: 0, + jsonName: "", + proto3Optional: false, +}; + +export const FieldDescriptorProto = { + encode( + message: FieldDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.number !== 0) { + writer.uint32(24).int32(message.number); + } + if (message.label !== 1) { + writer.uint32(32).int32(message.label); + } + if (message.type !== 1) { + writer.uint32(40).int32(message.type); + } + if (message.typeName !== "") { + writer.uint32(50).string(message.typeName); + } + if (message.extendee !== "") { + writer.uint32(18).string(message.extendee); + } + if (message.defaultValue !== "") { + writer.uint32(58).string(message.defaultValue); + } + if (message.oneofIndex !== 0) { + writer.uint32(72).int32(message.oneofIndex); + } + if (message.jsonName !== "") { + writer.uint32(82).string(message.jsonName); + } + if (message.options !== undefined) { + FieldOptions.encode(message.options, writer.uint32(66).fork()).ldelim(); + } + if (message.proto3Optional === true) { + writer.uint32(136).bool(message.proto3Optional); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FieldDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFieldDescriptorProto } as FieldDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 3: + message.number = reader.int32(); + break; + case 4: + message.label = reader.int32() as any; + break; + case 5: + message.type = reader.int32() as any; + break; + case 6: + message.typeName = reader.string(); + break; + case 2: + message.extendee = reader.string(); + break; + case 7: + message.defaultValue = reader.string(); + break; + case 9: + message.oneofIndex = reader.int32(); + break; + case 10: + message.jsonName = reader.string(); + break; + case 8: + message.options = FieldOptions.decode(reader, reader.uint32()); + break; + case 17: + message.proto3Optional = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FieldDescriptorProto { + const message = { ...baseFieldDescriptorProto } as FieldDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = Number(object.number); + } else { + message.number = 0; + } + if (object.label !== undefined && object.label !== null) { + message.label = fieldDescriptorProto_LabelFromJSON(object.label); + } else { + message.label = 1; + } + if (object.type !== undefined && object.type !== null) { + message.type = fieldDescriptorProto_TypeFromJSON(object.type); + } else { + message.type = 1; + } + if (object.typeName !== undefined && object.typeName !== null) { + message.typeName = String(object.typeName); + } else { + message.typeName = ""; + } + if (object.extendee !== undefined && object.extendee !== null) { + message.extendee = String(object.extendee); + } else { + message.extendee = ""; + } + if (object.defaultValue !== undefined && object.defaultValue !== null) { + message.defaultValue = String(object.defaultValue); + } else { + message.defaultValue = ""; + } + if (object.oneofIndex !== undefined && object.oneofIndex !== null) { + message.oneofIndex = Number(object.oneofIndex); + } else { + message.oneofIndex = 0; + } + if (object.jsonName !== undefined && object.jsonName !== null) { + message.jsonName = String(object.jsonName); + } else { + message.jsonName = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = FieldOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.proto3Optional !== undefined && object.proto3Optional !== null) { + message.proto3Optional = Boolean(object.proto3Optional); + } else { + message.proto3Optional = false; + } + return message; + }, + + toJSON(message: FieldDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.number !== undefined && (obj.number = message.number); + message.label !== undefined && + (obj.label = fieldDescriptorProto_LabelToJSON(message.label)); + message.type !== undefined && + (obj.type = fieldDescriptorProto_TypeToJSON(message.type)); + message.typeName !== undefined && (obj.typeName = message.typeName); + message.extendee !== undefined && (obj.extendee = message.extendee); + message.defaultValue !== undefined && + (obj.defaultValue = message.defaultValue); + message.oneofIndex !== undefined && (obj.oneofIndex = message.oneofIndex); + message.jsonName !== undefined && (obj.jsonName = message.jsonName); + message.options !== undefined && + (obj.options = message.options + ? FieldOptions.toJSON(message.options) + : undefined); + message.proto3Optional !== undefined && + (obj.proto3Optional = message.proto3Optional); + return obj; + }, + + fromPartial(object: DeepPartial): FieldDescriptorProto { + const message = { ...baseFieldDescriptorProto } as FieldDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = object.number; + } else { + message.number = 0; + } + if (object.label !== undefined && object.label !== null) { + message.label = object.label; + } else { + message.label = 1; + } + if (object.type !== undefined && object.type !== null) { + message.type = object.type; + } else { + message.type = 1; + } + if (object.typeName !== undefined && object.typeName !== null) { + message.typeName = object.typeName; + } else { + message.typeName = ""; + } + if (object.extendee !== undefined && object.extendee !== null) { + message.extendee = object.extendee; + } else { + message.extendee = ""; + } + if (object.defaultValue !== undefined && object.defaultValue !== null) { + message.defaultValue = object.defaultValue; + } else { + message.defaultValue = ""; + } + if (object.oneofIndex !== undefined && object.oneofIndex !== null) { + message.oneofIndex = object.oneofIndex; + } else { + message.oneofIndex = 0; + } + if (object.jsonName !== undefined && object.jsonName !== null) { + message.jsonName = object.jsonName; + } else { + message.jsonName = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = FieldOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.proto3Optional !== undefined && object.proto3Optional !== null) { + message.proto3Optional = object.proto3Optional; + } else { + message.proto3Optional = false; + } + return message; + }, +}; + +const baseOneofDescriptorProto: object = { name: "" }; + +export const OneofDescriptorProto = { + encode( + message: OneofDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.options !== undefined) { + OneofOptions.encode(message.options, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): OneofDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseOneofDescriptorProto } as OneofDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.options = OneofOptions.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): OneofDescriptorProto { + const message = { ...baseOneofDescriptorProto } as OneofDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = OneofOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: OneofDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.options !== undefined && + (obj.options = message.options + ? OneofOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): OneofDescriptorProto { + const message = { ...baseOneofDescriptorProto } as OneofDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = OneofOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseEnumDescriptorProto: object = { name: "", reservedName: "" }; + +export const EnumDescriptorProto = { + encode( + message: EnumDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + for (const v of message.value) { + EnumValueDescriptorProto.encode(v!, writer.uint32(18).fork()).ldelim(); + } + if (message.options !== undefined) { + EnumOptions.encode(message.options, writer.uint32(26).fork()).ldelim(); + } + for (const v of message.reservedRange) { + EnumDescriptorProto_EnumReservedRange.encode( + v!, + writer.uint32(34).fork() + ).ldelim(); + } + for (const v of message.reservedName) { + writer.uint32(42).string(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): EnumDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseEnumDescriptorProto } as EnumDescriptorProto; + message.value = []; + message.reservedRange = []; + message.reservedName = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.value.push( + EnumValueDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 3: + message.options = EnumOptions.decode(reader, reader.uint32()); + break; + case 4: + message.reservedRange.push( + EnumDescriptorProto_EnumReservedRange.decode( + reader, + reader.uint32() + ) + ); + break; + case 5: + message.reservedName.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumDescriptorProto { + const message = { ...baseEnumDescriptorProto } as EnumDescriptorProto; + message.value = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.value !== undefined && object.value !== null) { + for (const e of object.value) { + message.value.push(EnumValueDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push( + EnumDescriptorProto_EnumReservedRange.fromJSON(e) + ); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(String(e)); + } + } + return message; + }, + + toJSON(message: EnumDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + if (message.value) { + obj.value = message.value.map((e) => + e ? EnumValueDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.value = []; + } + message.options !== undefined && + (obj.options = message.options + ? EnumOptions.toJSON(message.options) + : undefined); + if (message.reservedRange) { + obj.reservedRange = message.reservedRange.map((e) => + e ? EnumDescriptorProto_EnumReservedRange.toJSON(e) : undefined + ); + } else { + obj.reservedRange = []; + } + if (message.reservedName) { + obj.reservedName = message.reservedName.map((e) => e); + } else { + obj.reservedName = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): EnumDescriptorProto { + const message = { ...baseEnumDescriptorProto } as EnumDescriptorProto; + message.value = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.value !== undefined && object.value !== null) { + for (const e of object.value) { + message.value.push(EnumValueDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push( + EnumDescriptorProto_EnumReservedRange.fromPartial(e) + ); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(e); + } + } + return message; + }, +}; + +const baseEnumDescriptorProto_EnumReservedRange: object = { start: 0, end: 0 }; + +export const EnumDescriptorProto_EnumReservedRange = { + encode( + message: EnumDescriptorProto_EnumReservedRange, + writer: Writer = Writer.create() + ): Writer { + if (message.start !== 0) { + writer.uint32(8).int32(message.start); + } + if (message.end !== 0) { + writer.uint32(16).int32(message.end); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): EnumDescriptorProto_EnumReservedRange { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseEnumDescriptorProto_EnumReservedRange, + } as EnumDescriptorProto_EnumReservedRange; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.start = reader.int32(); + break; + case 2: + message.end = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumDescriptorProto_EnumReservedRange { + const message = { + ...baseEnumDescriptorProto_EnumReservedRange, + } as EnumDescriptorProto_EnumReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = Number(object.start); + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + return message; + }, + + toJSON(message: EnumDescriptorProto_EnumReservedRange): unknown { + const obj: any = {}; + message.start !== undefined && (obj.start = message.start); + message.end !== undefined && (obj.end = message.end); + return obj; + }, + + fromPartial( + object: DeepPartial + ): EnumDescriptorProto_EnumReservedRange { + const message = { + ...baseEnumDescriptorProto_EnumReservedRange, + } as EnumDescriptorProto_EnumReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = object.start; + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + return message; + }, +}; + +const baseEnumValueDescriptorProto: object = { name: "", number: 0 }; + +export const EnumValueDescriptorProto = { + encode( + message: EnumValueDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.number !== 0) { + writer.uint32(16).int32(message.number); + } + if (message.options !== undefined) { + EnumValueOptions.encode( + message.options, + writer.uint32(26).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): EnumValueDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseEnumValueDescriptorProto, + } as EnumValueDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.number = reader.int32(); + break; + case 3: + message.options = EnumValueOptions.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumValueDescriptorProto { + const message = { + ...baseEnumValueDescriptorProto, + } as EnumValueDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = Number(object.number); + } else { + message.number = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumValueOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: EnumValueDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.number !== undefined && (obj.number = message.number); + message.options !== undefined && + (obj.options = message.options + ? EnumValueOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): EnumValueDescriptorProto { + const message = { + ...baseEnumValueDescriptorProto, + } as EnumValueDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = object.number; + } else { + message.number = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumValueOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseServiceDescriptorProto: object = { name: "" }; + +export const ServiceDescriptorProto = { + encode( + message: ServiceDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + for (const v of message.method) { + MethodDescriptorProto.encode(v!, writer.uint32(18).fork()).ldelim(); + } + if (message.options !== undefined) { + ServiceOptions.encode(message.options, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ServiceDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseServiceDescriptorProto } as ServiceDescriptorProto; + message.method = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.method.push( + MethodDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 3: + message.options = ServiceOptions.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ServiceDescriptorProto { + const message = { ...baseServiceDescriptorProto } as ServiceDescriptorProto; + message.method = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.method !== undefined && object.method !== null) { + for (const e of object.method) { + message.method.push(MethodDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = ServiceOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: ServiceDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + if (message.method) { + obj.method = message.method.map((e) => + e ? MethodDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.method = []; + } + message.options !== undefined && + (obj.options = message.options + ? ServiceOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): ServiceDescriptorProto { + const message = { ...baseServiceDescriptorProto } as ServiceDescriptorProto; + message.method = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.method !== undefined && object.method !== null) { + for (const e of object.method) { + message.method.push(MethodDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = ServiceOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseMethodDescriptorProto: object = { + name: "", + inputType: "", + outputType: "", + clientStreaming: false, + serverStreaming: false, +}; + +export const MethodDescriptorProto = { + encode( + message: MethodDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.inputType !== "") { + writer.uint32(18).string(message.inputType); + } + if (message.outputType !== "") { + writer.uint32(26).string(message.outputType); + } + if (message.options !== undefined) { + MethodOptions.encode(message.options, writer.uint32(34).fork()).ldelim(); + } + if (message.clientStreaming === true) { + writer.uint32(40).bool(message.clientStreaming); + } + if (message.serverStreaming === true) { + writer.uint32(48).bool(message.serverStreaming); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MethodDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMethodDescriptorProto } as MethodDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.inputType = reader.string(); + break; + case 3: + message.outputType = reader.string(); + break; + case 4: + message.options = MethodOptions.decode(reader, reader.uint32()); + break; + case 5: + message.clientStreaming = reader.bool(); + break; + case 6: + message.serverStreaming = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MethodDescriptorProto { + const message = { ...baseMethodDescriptorProto } as MethodDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.inputType !== undefined && object.inputType !== null) { + message.inputType = String(object.inputType); + } else { + message.inputType = ""; + } + if (object.outputType !== undefined && object.outputType !== null) { + message.outputType = String(object.outputType); + } else { + message.outputType = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = MethodOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if ( + object.clientStreaming !== undefined && + object.clientStreaming !== null + ) { + message.clientStreaming = Boolean(object.clientStreaming); + } else { + message.clientStreaming = false; + } + if ( + object.serverStreaming !== undefined && + object.serverStreaming !== null + ) { + message.serverStreaming = Boolean(object.serverStreaming); + } else { + message.serverStreaming = false; + } + return message; + }, + + toJSON(message: MethodDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.inputType !== undefined && (obj.inputType = message.inputType); + message.outputType !== undefined && (obj.outputType = message.outputType); + message.options !== undefined && + (obj.options = message.options + ? MethodOptions.toJSON(message.options) + : undefined); + message.clientStreaming !== undefined && + (obj.clientStreaming = message.clientStreaming); + message.serverStreaming !== undefined && + (obj.serverStreaming = message.serverStreaming); + return obj; + }, + + fromPartial( + object: DeepPartial + ): MethodDescriptorProto { + const message = { ...baseMethodDescriptorProto } as MethodDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.inputType !== undefined && object.inputType !== null) { + message.inputType = object.inputType; + } else { + message.inputType = ""; + } + if (object.outputType !== undefined && object.outputType !== null) { + message.outputType = object.outputType; + } else { + message.outputType = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = MethodOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if ( + object.clientStreaming !== undefined && + object.clientStreaming !== null + ) { + message.clientStreaming = object.clientStreaming; + } else { + message.clientStreaming = false; + } + if ( + object.serverStreaming !== undefined && + object.serverStreaming !== null + ) { + message.serverStreaming = object.serverStreaming; + } else { + message.serverStreaming = false; + } + return message; + }, +}; + +const baseFileOptions: object = { + javaPackage: "", + javaOuterClassname: "", + javaMultipleFiles: false, + javaGenerateEqualsAndHash: false, + javaStringCheckUtf8: false, + optimizeFor: 1, + goPackage: "", + ccGenericServices: false, + javaGenericServices: false, + pyGenericServices: false, + phpGenericServices: false, + deprecated: false, + ccEnableArenas: false, + objcClassPrefix: "", + csharpNamespace: "", + swiftPrefix: "", + phpClassPrefix: "", + phpNamespace: "", + phpMetadataNamespace: "", + rubyPackage: "", +}; + +export const FileOptions = { + encode(message: FileOptions, writer: Writer = Writer.create()): Writer { + if (message.javaPackage !== "") { + writer.uint32(10).string(message.javaPackage); + } + if (message.javaOuterClassname !== "") { + writer.uint32(66).string(message.javaOuterClassname); + } + if (message.javaMultipleFiles === true) { + writer.uint32(80).bool(message.javaMultipleFiles); + } + if (message.javaGenerateEqualsAndHash === true) { + writer.uint32(160).bool(message.javaGenerateEqualsAndHash); + } + if (message.javaStringCheckUtf8 === true) { + writer.uint32(216).bool(message.javaStringCheckUtf8); + } + if (message.optimizeFor !== 1) { + writer.uint32(72).int32(message.optimizeFor); + } + if (message.goPackage !== "") { + writer.uint32(90).string(message.goPackage); + } + if (message.ccGenericServices === true) { + writer.uint32(128).bool(message.ccGenericServices); + } + if (message.javaGenericServices === true) { + writer.uint32(136).bool(message.javaGenericServices); + } + if (message.pyGenericServices === true) { + writer.uint32(144).bool(message.pyGenericServices); + } + if (message.phpGenericServices === true) { + writer.uint32(336).bool(message.phpGenericServices); + } + if (message.deprecated === true) { + writer.uint32(184).bool(message.deprecated); + } + if (message.ccEnableArenas === true) { + writer.uint32(248).bool(message.ccEnableArenas); + } + if (message.objcClassPrefix !== "") { + writer.uint32(290).string(message.objcClassPrefix); + } + if (message.csharpNamespace !== "") { + writer.uint32(298).string(message.csharpNamespace); + } + if (message.swiftPrefix !== "") { + writer.uint32(314).string(message.swiftPrefix); + } + if (message.phpClassPrefix !== "") { + writer.uint32(322).string(message.phpClassPrefix); + } + if (message.phpNamespace !== "") { + writer.uint32(330).string(message.phpNamespace); + } + if (message.phpMetadataNamespace !== "") { + writer.uint32(354).string(message.phpMetadataNamespace); + } + if (message.rubyPackage !== "") { + writer.uint32(362).string(message.rubyPackage); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FileOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFileOptions } as FileOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.javaPackage = reader.string(); + break; + case 8: + message.javaOuterClassname = reader.string(); + break; + case 10: + message.javaMultipleFiles = reader.bool(); + break; + case 20: + message.javaGenerateEqualsAndHash = reader.bool(); + break; + case 27: + message.javaStringCheckUtf8 = reader.bool(); + break; + case 9: + message.optimizeFor = reader.int32() as any; + break; + case 11: + message.goPackage = reader.string(); + break; + case 16: + message.ccGenericServices = reader.bool(); + break; + case 17: + message.javaGenericServices = reader.bool(); + break; + case 18: + message.pyGenericServices = reader.bool(); + break; + case 42: + message.phpGenericServices = reader.bool(); + break; + case 23: + message.deprecated = reader.bool(); + break; + case 31: + message.ccEnableArenas = reader.bool(); + break; + case 36: + message.objcClassPrefix = reader.string(); + break; + case 37: + message.csharpNamespace = reader.string(); + break; + case 39: + message.swiftPrefix = reader.string(); + break; + case 40: + message.phpClassPrefix = reader.string(); + break; + case 41: + message.phpNamespace = reader.string(); + break; + case 44: + message.phpMetadataNamespace = reader.string(); + break; + case 45: + message.rubyPackage = reader.string(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FileOptions { + const message = { ...baseFileOptions } as FileOptions; + message.uninterpretedOption = []; + if (object.javaPackage !== undefined && object.javaPackage !== null) { + message.javaPackage = String(object.javaPackage); + } else { + message.javaPackage = ""; + } + if ( + object.javaOuterClassname !== undefined && + object.javaOuterClassname !== null + ) { + message.javaOuterClassname = String(object.javaOuterClassname); + } else { + message.javaOuterClassname = ""; + } + if ( + object.javaMultipleFiles !== undefined && + object.javaMultipleFiles !== null + ) { + message.javaMultipleFiles = Boolean(object.javaMultipleFiles); + } else { + message.javaMultipleFiles = false; + } + if ( + object.javaGenerateEqualsAndHash !== undefined && + object.javaGenerateEqualsAndHash !== null + ) { + message.javaGenerateEqualsAndHash = Boolean( + object.javaGenerateEqualsAndHash + ); + } else { + message.javaGenerateEqualsAndHash = false; + } + if ( + object.javaStringCheckUtf8 !== undefined && + object.javaStringCheckUtf8 !== null + ) { + message.javaStringCheckUtf8 = Boolean(object.javaStringCheckUtf8); + } else { + message.javaStringCheckUtf8 = false; + } + if (object.optimizeFor !== undefined && object.optimizeFor !== null) { + message.optimizeFor = fileOptions_OptimizeModeFromJSON( + object.optimizeFor + ); + } else { + message.optimizeFor = 1; + } + if (object.goPackage !== undefined && object.goPackage !== null) { + message.goPackage = String(object.goPackage); + } else { + message.goPackage = ""; + } + if ( + object.ccGenericServices !== undefined && + object.ccGenericServices !== null + ) { + message.ccGenericServices = Boolean(object.ccGenericServices); + } else { + message.ccGenericServices = false; + } + if ( + object.javaGenericServices !== undefined && + object.javaGenericServices !== null + ) { + message.javaGenericServices = Boolean(object.javaGenericServices); + } else { + message.javaGenericServices = false; + } + if ( + object.pyGenericServices !== undefined && + object.pyGenericServices !== null + ) { + message.pyGenericServices = Boolean(object.pyGenericServices); + } else { + message.pyGenericServices = false; + } + if ( + object.phpGenericServices !== undefined && + object.phpGenericServices !== null + ) { + message.phpGenericServices = Boolean(object.phpGenericServices); + } else { + message.phpGenericServices = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if (object.ccEnableArenas !== undefined && object.ccEnableArenas !== null) { + message.ccEnableArenas = Boolean(object.ccEnableArenas); + } else { + message.ccEnableArenas = false; + } + if ( + object.objcClassPrefix !== undefined && + object.objcClassPrefix !== null + ) { + message.objcClassPrefix = String(object.objcClassPrefix); + } else { + message.objcClassPrefix = ""; + } + if ( + object.csharpNamespace !== undefined && + object.csharpNamespace !== null + ) { + message.csharpNamespace = String(object.csharpNamespace); + } else { + message.csharpNamespace = ""; + } + if (object.swiftPrefix !== undefined && object.swiftPrefix !== null) { + message.swiftPrefix = String(object.swiftPrefix); + } else { + message.swiftPrefix = ""; + } + if (object.phpClassPrefix !== undefined && object.phpClassPrefix !== null) { + message.phpClassPrefix = String(object.phpClassPrefix); + } else { + message.phpClassPrefix = ""; + } + if (object.phpNamespace !== undefined && object.phpNamespace !== null) { + message.phpNamespace = String(object.phpNamespace); + } else { + message.phpNamespace = ""; + } + if ( + object.phpMetadataNamespace !== undefined && + object.phpMetadataNamespace !== null + ) { + message.phpMetadataNamespace = String(object.phpMetadataNamespace); + } else { + message.phpMetadataNamespace = ""; + } + if (object.rubyPackage !== undefined && object.rubyPackage !== null) { + message.rubyPackage = String(object.rubyPackage); + } else { + message.rubyPackage = ""; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: FileOptions): unknown { + const obj: any = {}; + message.javaPackage !== undefined && + (obj.javaPackage = message.javaPackage); + message.javaOuterClassname !== undefined && + (obj.javaOuterClassname = message.javaOuterClassname); + message.javaMultipleFiles !== undefined && + (obj.javaMultipleFiles = message.javaMultipleFiles); + message.javaGenerateEqualsAndHash !== undefined && + (obj.javaGenerateEqualsAndHash = message.javaGenerateEqualsAndHash); + message.javaStringCheckUtf8 !== undefined && + (obj.javaStringCheckUtf8 = message.javaStringCheckUtf8); + message.optimizeFor !== undefined && + (obj.optimizeFor = fileOptions_OptimizeModeToJSON(message.optimizeFor)); + message.goPackage !== undefined && (obj.goPackage = message.goPackage); + message.ccGenericServices !== undefined && + (obj.ccGenericServices = message.ccGenericServices); + message.javaGenericServices !== undefined && + (obj.javaGenericServices = message.javaGenericServices); + message.pyGenericServices !== undefined && + (obj.pyGenericServices = message.pyGenericServices); + message.phpGenericServices !== undefined && + (obj.phpGenericServices = message.phpGenericServices); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.ccEnableArenas !== undefined && + (obj.ccEnableArenas = message.ccEnableArenas); + message.objcClassPrefix !== undefined && + (obj.objcClassPrefix = message.objcClassPrefix); + message.csharpNamespace !== undefined && + (obj.csharpNamespace = message.csharpNamespace); + message.swiftPrefix !== undefined && + (obj.swiftPrefix = message.swiftPrefix); + message.phpClassPrefix !== undefined && + (obj.phpClassPrefix = message.phpClassPrefix); + message.phpNamespace !== undefined && + (obj.phpNamespace = message.phpNamespace); + message.phpMetadataNamespace !== undefined && + (obj.phpMetadataNamespace = message.phpMetadataNamespace); + message.rubyPackage !== undefined && + (obj.rubyPackage = message.rubyPackage); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): FileOptions { + const message = { ...baseFileOptions } as FileOptions; + message.uninterpretedOption = []; + if (object.javaPackage !== undefined && object.javaPackage !== null) { + message.javaPackage = object.javaPackage; + } else { + message.javaPackage = ""; + } + if ( + object.javaOuterClassname !== undefined && + object.javaOuterClassname !== null + ) { + message.javaOuterClassname = object.javaOuterClassname; + } else { + message.javaOuterClassname = ""; + } + if ( + object.javaMultipleFiles !== undefined && + object.javaMultipleFiles !== null + ) { + message.javaMultipleFiles = object.javaMultipleFiles; + } else { + message.javaMultipleFiles = false; + } + if ( + object.javaGenerateEqualsAndHash !== undefined && + object.javaGenerateEqualsAndHash !== null + ) { + message.javaGenerateEqualsAndHash = object.javaGenerateEqualsAndHash; + } else { + message.javaGenerateEqualsAndHash = false; + } + if ( + object.javaStringCheckUtf8 !== undefined && + object.javaStringCheckUtf8 !== null + ) { + message.javaStringCheckUtf8 = object.javaStringCheckUtf8; + } else { + message.javaStringCheckUtf8 = false; + } + if (object.optimizeFor !== undefined && object.optimizeFor !== null) { + message.optimizeFor = object.optimizeFor; + } else { + message.optimizeFor = 1; + } + if (object.goPackage !== undefined && object.goPackage !== null) { + message.goPackage = object.goPackage; + } else { + message.goPackage = ""; + } + if ( + object.ccGenericServices !== undefined && + object.ccGenericServices !== null + ) { + message.ccGenericServices = object.ccGenericServices; + } else { + message.ccGenericServices = false; + } + if ( + object.javaGenericServices !== undefined && + object.javaGenericServices !== null + ) { + message.javaGenericServices = object.javaGenericServices; + } else { + message.javaGenericServices = false; + } + if ( + object.pyGenericServices !== undefined && + object.pyGenericServices !== null + ) { + message.pyGenericServices = object.pyGenericServices; + } else { + message.pyGenericServices = false; + } + if ( + object.phpGenericServices !== undefined && + object.phpGenericServices !== null + ) { + message.phpGenericServices = object.phpGenericServices; + } else { + message.phpGenericServices = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if (object.ccEnableArenas !== undefined && object.ccEnableArenas !== null) { + message.ccEnableArenas = object.ccEnableArenas; + } else { + message.ccEnableArenas = false; + } + if ( + object.objcClassPrefix !== undefined && + object.objcClassPrefix !== null + ) { + message.objcClassPrefix = object.objcClassPrefix; + } else { + message.objcClassPrefix = ""; + } + if ( + object.csharpNamespace !== undefined && + object.csharpNamespace !== null + ) { + message.csharpNamespace = object.csharpNamespace; + } else { + message.csharpNamespace = ""; + } + if (object.swiftPrefix !== undefined && object.swiftPrefix !== null) { + message.swiftPrefix = object.swiftPrefix; + } else { + message.swiftPrefix = ""; + } + if (object.phpClassPrefix !== undefined && object.phpClassPrefix !== null) { + message.phpClassPrefix = object.phpClassPrefix; + } else { + message.phpClassPrefix = ""; + } + if (object.phpNamespace !== undefined && object.phpNamespace !== null) { + message.phpNamespace = object.phpNamespace; + } else { + message.phpNamespace = ""; + } + if ( + object.phpMetadataNamespace !== undefined && + object.phpMetadataNamespace !== null + ) { + message.phpMetadataNamespace = object.phpMetadataNamespace; + } else { + message.phpMetadataNamespace = ""; + } + if (object.rubyPackage !== undefined && object.rubyPackage !== null) { + message.rubyPackage = object.rubyPackage; + } else { + message.rubyPackage = ""; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseMessageOptions: object = { + messageSetWireFormat: false, + noStandardDescriptorAccessor: false, + deprecated: false, + mapEntry: false, +}; + +export const MessageOptions = { + encode(message: MessageOptions, writer: Writer = Writer.create()): Writer { + if (message.messageSetWireFormat === true) { + writer.uint32(8).bool(message.messageSetWireFormat); + } + if (message.noStandardDescriptorAccessor === true) { + writer.uint32(16).bool(message.noStandardDescriptorAccessor); + } + if (message.deprecated === true) { + writer.uint32(24).bool(message.deprecated); + } + if (message.mapEntry === true) { + writer.uint32(56).bool(message.mapEntry); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MessageOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMessageOptions } as MessageOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.messageSetWireFormat = reader.bool(); + break; + case 2: + message.noStandardDescriptorAccessor = reader.bool(); + break; + case 3: + message.deprecated = reader.bool(); + break; + case 7: + message.mapEntry = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MessageOptions { + const message = { ...baseMessageOptions } as MessageOptions; + message.uninterpretedOption = []; + if ( + object.messageSetWireFormat !== undefined && + object.messageSetWireFormat !== null + ) { + message.messageSetWireFormat = Boolean(object.messageSetWireFormat); + } else { + message.messageSetWireFormat = false; + } + if ( + object.noStandardDescriptorAccessor !== undefined && + object.noStandardDescriptorAccessor !== null + ) { + message.noStandardDescriptorAccessor = Boolean( + object.noStandardDescriptorAccessor + ); + } else { + message.noStandardDescriptorAccessor = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if (object.mapEntry !== undefined && object.mapEntry !== null) { + message.mapEntry = Boolean(object.mapEntry); + } else { + message.mapEntry = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: MessageOptions): unknown { + const obj: any = {}; + message.messageSetWireFormat !== undefined && + (obj.messageSetWireFormat = message.messageSetWireFormat); + message.noStandardDescriptorAccessor !== undefined && + (obj.noStandardDescriptorAccessor = message.noStandardDescriptorAccessor); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.mapEntry !== undefined && (obj.mapEntry = message.mapEntry); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): MessageOptions { + const message = { ...baseMessageOptions } as MessageOptions; + message.uninterpretedOption = []; + if ( + object.messageSetWireFormat !== undefined && + object.messageSetWireFormat !== null + ) { + message.messageSetWireFormat = object.messageSetWireFormat; + } else { + message.messageSetWireFormat = false; + } + if ( + object.noStandardDescriptorAccessor !== undefined && + object.noStandardDescriptorAccessor !== null + ) { + message.noStandardDescriptorAccessor = + object.noStandardDescriptorAccessor; + } else { + message.noStandardDescriptorAccessor = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if (object.mapEntry !== undefined && object.mapEntry !== null) { + message.mapEntry = object.mapEntry; + } else { + message.mapEntry = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseFieldOptions: object = { + ctype: 0, + packed: false, + jstype: 0, + lazy: false, + deprecated: false, + weak: false, +}; + +export const FieldOptions = { + encode(message: FieldOptions, writer: Writer = Writer.create()): Writer { + if (message.ctype !== 0) { + writer.uint32(8).int32(message.ctype); + } + if (message.packed === true) { + writer.uint32(16).bool(message.packed); + } + if (message.jstype !== 0) { + writer.uint32(48).int32(message.jstype); + } + if (message.lazy === true) { + writer.uint32(40).bool(message.lazy); + } + if (message.deprecated === true) { + writer.uint32(24).bool(message.deprecated); + } + if (message.weak === true) { + writer.uint32(80).bool(message.weak); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FieldOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFieldOptions } as FieldOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.ctype = reader.int32() as any; + break; + case 2: + message.packed = reader.bool(); + break; + case 6: + message.jstype = reader.int32() as any; + break; + case 5: + message.lazy = reader.bool(); + break; + case 3: + message.deprecated = reader.bool(); + break; + case 10: + message.weak = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FieldOptions { + const message = { ...baseFieldOptions } as FieldOptions; + message.uninterpretedOption = []; + if (object.ctype !== undefined && object.ctype !== null) { + message.ctype = fieldOptions_CTypeFromJSON(object.ctype); + } else { + message.ctype = 0; + } + if (object.packed !== undefined && object.packed !== null) { + message.packed = Boolean(object.packed); + } else { + message.packed = false; + } + if (object.jstype !== undefined && object.jstype !== null) { + message.jstype = fieldOptions_JSTypeFromJSON(object.jstype); + } else { + message.jstype = 0; + } + if (object.lazy !== undefined && object.lazy !== null) { + message.lazy = Boolean(object.lazy); + } else { + message.lazy = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if (object.weak !== undefined && object.weak !== null) { + message.weak = Boolean(object.weak); + } else { + message.weak = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: FieldOptions): unknown { + const obj: any = {}; + message.ctype !== undefined && + (obj.ctype = fieldOptions_CTypeToJSON(message.ctype)); + message.packed !== undefined && (obj.packed = message.packed); + message.jstype !== undefined && + (obj.jstype = fieldOptions_JSTypeToJSON(message.jstype)); + message.lazy !== undefined && (obj.lazy = message.lazy); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.weak !== undefined && (obj.weak = message.weak); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): FieldOptions { + const message = { ...baseFieldOptions } as FieldOptions; + message.uninterpretedOption = []; + if (object.ctype !== undefined && object.ctype !== null) { + message.ctype = object.ctype; + } else { + message.ctype = 0; + } + if (object.packed !== undefined && object.packed !== null) { + message.packed = object.packed; + } else { + message.packed = false; + } + if (object.jstype !== undefined && object.jstype !== null) { + message.jstype = object.jstype; + } else { + message.jstype = 0; + } + if (object.lazy !== undefined && object.lazy !== null) { + message.lazy = object.lazy; + } else { + message.lazy = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if (object.weak !== undefined && object.weak !== null) { + message.weak = object.weak; + } else { + message.weak = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseOneofOptions: object = {}; + +export const OneofOptions = { + encode(message: OneofOptions, writer: Writer = Writer.create()): Writer { + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): OneofOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseOneofOptions } as OneofOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): OneofOptions { + const message = { ...baseOneofOptions } as OneofOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: OneofOptions): unknown { + const obj: any = {}; + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): OneofOptions { + const message = { ...baseOneofOptions } as OneofOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseEnumOptions: object = { allowAlias: false, deprecated: false }; + +export const EnumOptions = { + encode(message: EnumOptions, writer: Writer = Writer.create()): Writer { + if (message.allowAlias === true) { + writer.uint32(16).bool(message.allowAlias); + } + if (message.deprecated === true) { + writer.uint32(24).bool(message.deprecated); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): EnumOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseEnumOptions } as EnumOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + message.allowAlias = reader.bool(); + break; + case 3: + message.deprecated = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumOptions { + const message = { ...baseEnumOptions } as EnumOptions; + message.uninterpretedOption = []; + if (object.allowAlias !== undefined && object.allowAlias !== null) { + message.allowAlias = Boolean(object.allowAlias); + } else { + message.allowAlias = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: EnumOptions): unknown { + const obj: any = {}; + message.allowAlias !== undefined && (obj.allowAlias = message.allowAlias); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): EnumOptions { + const message = { ...baseEnumOptions } as EnumOptions; + message.uninterpretedOption = []; + if (object.allowAlias !== undefined && object.allowAlias !== null) { + message.allowAlias = object.allowAlias; + } else { + message.allowAlias = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseEnumValueOptions: object = { deprecated: false }; + +export const EnumValueOptions = { + encode(message: EnumValueOptions, writer: Writer = Writer.create()): Writer { + if (message.deprecated === true) { + writer.uint32(8).bool(message.deprecated); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): EnumValueOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseEnumValueOptions } as EnumValueOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.deprecated = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumValueOptions { + const message = { ...baseEnumValueOptions } as EnumValueOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: EnumValueOptions): unknown { + const obj: any = {}; + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): EnumValueOptions { + const message = { ...baseEnumValueOptions } as EnumValueOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseServiceOptions: object = { deprecated: false }; + +export const ServiceOptions = { + encode(message: ServiceOptions, writer: Writer = Writer.create()): Writer { + if (message.deprecated === true) { + writer.uint32(264).bool(message.deprecated); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ServiceOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseServiceOptions } as ServiceOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 33: + message.deprecated = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ServiceOptions { + const message = { ...baseServiceOptions } as ServiceOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: ServiceOptions): unknown { + const obj: any = {}; + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): ServiceOptions { + const message = { ...baseServiceOptions } as ServiceOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseMethodOptions: object = { deprecated: false, idempotencyLevel: 0 }; + +export const MethodOptions = { + encode(message: MethodOptions, writer: Writer = Writer.create()): Writer { + if (message.deprecated === true) { + writer.uint32(264).bool(message.deprecated); + } + if (message.idempotencyLevel !== 0) { + writer.uint32(272).int32(message.idempotencyLevel); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MethodOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMethodOptions } as MethodOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 33: + message.deprecated = reader.bool(); + break; + case 34: + message.idempotencyLevel = reader.int32() as any; + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MethodOptions { + const message = { ...baseMethodOptions } as MethodOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.idempotencyLevel !== undefined && + object.idempotencyLevel !== null + ) { + message.idempotencyLevel = methodOptions_IdempotencyLevelFromJSON( + object.idempotencyLevel + ); + } else { + message.idempotencyLevel = 0; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: MethodOptions): unknown { + const obj: any = {}; + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.idempotencyLevel !== undefined && + (obj.idempotencyLevel = methodOptions_IdempotencyLevelToJSON( + message.idempotencyLevel + )); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): MethodOptions { + const message = { ...baseMethodOptions } as MethodOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.idempotencyLevel !== undefined && + object.idempotencyLevel !== null + ) { + message.idempotencyLevel = object.idempotencyLevel; + } else { + message.idempotencyLevel = 0; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseUninterpretedOption: object = { + identifierValue: "", + positiveIntValue: 0, + negativeIntValue: 0, + doubleValue: 0, + aggregateValue: "", +}; + +export const UninterpretedOption = { + encode( + message: UninterpretedOption, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.name) { + UninterpretedOption_NamePart.encode( + v!, + writer.uint32(18).fork() + ).ldelim(); + } + if (message.identifierValue !== "") { + writer.uint32(26).string(message.identifierValue); + } + if (message.positiveIntValue !== 0) { + writer.uint32(32).uint64(message.positiveIntValue); + } + if (message.negativeIntValue !== 0) { + writer.uint32(40).int64(message.negativeIntValue); + } + if (message.doubleValue !== 0) { + writer.uint32(49).double(message.doubleValue); + } + if (message.stringValue.length !== 0) { + writer.uint32(58).bytes(message.stringValue); + } + if (message.aggregateValue !== "") { + writer.uint32(66).string(message.aggregateValue); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): UninterpretedOption { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseUninterpretedOption } as UninterpretedOption; + message.name = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + message.name.push( + UninterpretedOption_NamePart.decode(reader, reader.uint32()) + ); + break; + case 3: + message.identifierValue = reader.string(); + break; + case 4: + message.positiveIntValue = longToNumber(reader.uint64() as Long); + break; + case 5: + message.negativeIntValue = longToNumber(reader.int64() as Long); + break; + case 6: + message.doubleValue = reader.double(); + break; + case 7: + message.stringValue = reader.bytes(); + break; + case 8: + message.aggregateValue = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): UninterpretedOption { + const message = { ...baseUninterpretedOption } as UninterpretedOption; + message.name = []; + if (object.name !== undefined && object.name !== null) { + for (const e of object.name) { + message.name.push(UninterpretedOption_NamePart.fromJSON(e)); + } + } + if ( + object.identifierValue !== undefined && + object.identifierValue !== null + ) { + message.identifierValue = String(object.identifierValue); + } else { + message.identifierValue = ""; + } + if ( + object.positiveIntValue !== undefined && + object.positiveIntValue !== null + ) { + message.positiveIntValue = Number(object.positiveIntValue); + } else { + message.positiveIntValue = 0; + } + if ( + object.negativeIntValue !== undefined && + object.negativeIntValue !== null + ) { + message.negativeIntValue = Number(object.negativeIntValue); + } else { + message.negativeIntValue = 0; + } + if (object.doubleValue !== undefined && object.doubleValue !== null) { + message.doubleValue = Number(object.doubleValue); + } else { + message.doubleValue = 0; + } + if (object.stringValue !== undefined && object.stringValue !== null) { + message.stringValue = bytesFromBase64(object.stringValue); + } + if (object.aggregateValue !== undefined && object.aggregateValue !== null) { + message.aggregateValue = String(object.aggregateValue); + } else { + message.aggregateValue = ""; + } + return message; + }, + + toJSON(message: UninterpretedOption): unknown { + const obj: any = {}; + if (message.name) { + obj.name = message.name.map((e) => + e ? UninterpretedOption_NamePart.toJSON(e) : undefined + ); + } else { + obj.name = []; + } + message.identifierValue !== undefined && + (obj.identifierValue = message.identifierValue); + message.positiveIntValue !== undefined && + (obj.positiveIntValue = message.positiveIntValue); + message.negativeIntValue !== undefined && + (obj.negativeIntValue = message.negativeIntValue); + message.doubleValue !== undefined && + (obj.doubleValue = message.doubleValue); + message.stringValue !== undefined && + (obj.stringValue = base64FromBytes( + message.stringValue !== undefined + ? message.stringValue + : new Uint8Array() + )); + message.aggregateValue !== undefined && + (obj.aggregateValue = message.aggregateValue); + return obj; + }, + + fromPartial(object: DeepPartial): UninterpretedOption { + const message = { ...baseUninterpretedOption } as UninterpretedOption; + message.name = []; + if (object.name !== undefined && object.name !== null) { + for (const e of object.name) { + message.name.push(UninterpretedOption_NamePart.fromPartial(e)); + } + } + if ( + object.identifierValue !== undefined && + object.identifierValue !== null + ) { + message.identifierValue = object.identifierValue; + } else { + message.identifierValue = ""; + } + if ( + object.positiveIntValue !== undefined && + object.positiveIntValue !== null + ) { + message.positiveIntValue = object.positiveIntValue; + } else { + message.positiveIntValue = 0; + } + if ( + object.negativeIntValue !== undefined && + object.negativeIntValue !== null + ) { + message.negativeIntValue = object.negativeIntValue; + } else { + message.negativeIntValue = 0; + } + if (object.doubleValue !== undefined && object.doubleValue !== null) { + message.doubleValue = object.doubleValue; + } else { + message.doubleValue = 0; + } + if (object.stringValue !== undefined && object.stringValue !== null) { + message.stringValue = object.stringValue; + } else { + message.stringValue = new Uint8Array(); + } + if (object.aggregateValue !== undefined && object.aggregateValue !== null) { + message.aggregateValue = object.aggregateValue; + } else { + message.aggregateValue = ""; + } + return message; + }, +}; + +const baseUninterpretedOption_NamePart: object = { + namePart: "", + isExtension: false, +}; + +export const UninterpretedOption_NamePart = { + encode( + message: UninterpretedOption_NamePart, + writer: Writer = Writer.create() + ): Writer { + if (message.namePart !== "") { + writer.uint32(10).string(message.namePart); + } + if (message.isExtension === true) { + writer.uint32(16).bool(message.isExtension); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): UninterpretedOption_NamePart { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseUninterpretedOption_NamePart, + } as UninterpretedOption_NamePart; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.namePart = reader.string(); + break; + case 2: + message.isExtension = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): UninterpretedOption_NamePart { + const message = { + ...baseUninterpretedOption_NamePart, + } as UninterpretedOption_NamePart; + if (object.namePart !== undefined && object.namePart !== null) { + message.namePart = String(object.namePart); + } else { + message.namePart = ""; + } + if (object.isExtension !== undefined && object.isExtension !== null) { + message.isExtension = Boolean(object.isExtension); + } else { + message.isExtension = false; + } + return message; + }, + + toJSON(message: UninterpretedOption_NamePart): unknown { + const obj: any = {}; + message.namePart !== undefined && (obj.namePart = message.namePart); + message.isExtension !== undefined && + (obj.isExtension = message.isExtension); + return obj; + }, + + fromPartial( + object: DeepPartial + ): UninterpretedOption_NamePart { + const message = { + ...baseUninterpretedOption_NamePart, + } as UninterpretedOption_NamePart; + if (object.namePart !== undefined && object.namePart !== null) { + message.namePart = object.namePart; + } else { + message.namePart = ""; + } + if (object.isExtension !== undefined && object.isExtension !== null) { + message.isExtension = object.isExtension; + } else { + message.isExtension = false; + } + return message; + }, +}; + +const baseSourceCodeInfo: object = {}; + +export const SourceCodeInfo = { + encode(message: SourceCodeInfo, writer: Writer = Writer.create()): Writer { + for (const v of message.location) { + SourceCodeInfo_Location.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): SourceCodeInfo { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseSourceCodeInfo } as SourceCodeInfo; + message.location = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.location.push( + SourceCodeInfo_Location.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): SourceCodeInfo { + const message = { ...baseSourceCodeInfo } as SourceCodeInfo; + message.location = []; + if (object.location !== undefined && object.location !== null) { + for (const e of object.location) { + message.location.push(SourceCodeInfo_Location.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: SourceCodeInfo): unknown { + const obj: any = {}; + if (message.location) { + obj.location = message.location.map((e) => + e ? SourceCodeInfo_Location.toJSON(e) : undefined + ); + } else { + obj.location = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): SourceCodeInfo { + const message = { ...baseSourceCodeInfo } as SourceCodeInfo; + message.location = []; + if (object.location !== undefined && object.location !== null) { + for (const e of object.location) { + message.location.push(SourceCodeInfo_Location.fromPartial(e)); + } + } + return message; + }, +}; + +const baseSourceCodeInfo_Location: object = { + path: 0, + span: 0, + leadingComments: "", + trailingComments: "", + leadingDetachedComments: "", +}; + +export const SourceCodeInfo_Location = { + encode( + message: SourceCodeInfo_Location, + writer: Writer = Writer.create() + ): Writer { + writer.uint32(10).fork(); + for (const v of message.path) { + writer.int32(v); + } + writer.ldelim(); + writer.uint32(18).fork(); + for (const v of message.span) { + writer.int32(v); + } + writer.ldelim(); + if (message.leadingComments !== "") { + writer.uint32(26).string(message.leadingComments); + } + if (message.trailingComments !== "") { + writer.uint32(34).string(message.trailingComments); + } + for (const v of message.leadingDetachedComments) { + writer.uint32(50).string(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): SourceCodeInfo_Location { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseSourceCodeInfo_Location, + } as SourceCodeInfo_Location; + message.path = []; + message.span = []; + message.leadingDetachedComments = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.path.push(reader.int32()); + } + } else { + message.path.push(reader.int32()); + } + break; + case 2: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.span.push(reader.int32()); + } + } else { + message.span.push(reader.int32()); + } + break; + case 3: + message.leadingComments = reader.string(); + break; + case 4: + message.trailingComments = reader.string(); + break; + case 6: + message.leadingDetachedComments.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): SourceCodeInfo_Location { + const message = { + ...baseSourceCodeInfo_Location, + } as SourceCodeInfo_Location; + message.path = []; + message.span = []; + message.leadingDetachedComments = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(Number(e)); + } + } + if (object.span !== undefined && object.span !== null) { + for (const e of object.span) { + message.span.push(Number(e)); + } + } + if ( + object.leadingComments !== undefined && + object.leadingComments !== null + ) { + message.leadingComments = String(object.leadingComments); + } else { + message.leadingComments = ""; + } + if ( + object.trailingComments !== undefined && + object.trailingComments !== null + ) { + message.trailingComments = String(object.trailingComments); + } else { + message.trailingComments = ""; + } + if ( + object.leadingDetachedComments !== undefined && + object.leadingDetachedComments !== null + ) { + for (const e of object.leadingDetachedComments) { + message.leadingDetachedComments.push(String(e)); + } + } + return message; + }, + + toJSON(message: SourceCodeInfo_Location): unknown { + const obj: any = {}; + if (message.path) { + obj.path = message.path.map((e) => e); + } else { + obj.path = []; + } + if (message.span) { + obj.span = message.span.map((e) => e); + } else { + obj.span = []; + } + message.leadingComments !== undefined && + (obj.leadingComments = message.leadingComments); + message.trailingComments !== undefined && + (obj.trailingComments = message.trailingComments); + if (message.leadingDetachedComments) { + obj.leadingDetachedComments = message.leadingDetachedComments.map( + (e) => e + ); + } else { + obj.leadingDetachedComments = []; + } + return obj; + }, + + fromPartial( + object: DeepPartial + ): SourceCodeInfo_Location { + const message = { + ...baseSourceCodeInfo_Location, + } as SourceCodeInfo_Location; + message.path = []; + message.span = []; + message.leadingDetachedComments = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(e); + } + } + if (object.span !== undefined && object.span !== null) { + for (const e of object.span) { + message.span.push(e); + } + } + if ( + object.leadingComments !== undefined && + object.leadingComments !== null + ) { + message.leadingComments = object.leadingComments; + } else { + message.leadingComments = ""; + } + if ( + object.trailingComments !== undefined && + object.trailingComments !== null + ) { + message.trailingComments = object.trailingComments; + } else { + message.trailingComments = ""; + } + if ( + object.leadingDetachedComments !== undefined && + object.leadingDetachedComments !== null + ) { + for (const e of object.leadingDetachedComments) { + message.leadingDetachedComments.push(e); + } + } + return message; + }, +}; + +const baseGeneratedCodeInfo: object = {}; + +export const GeneratedCodeInfo = { + encode(message: GeneratedCodeInfo, writer: Writer = Writer.create()): Writer { + for (const v of message.annotation) { + GeneratedCodeInfo_Annotation.encode( + v!, + writer.uint32(10).fork() + ).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): GeneratedCodeInfo { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseGeneratedCodeInfo } as GeneratedCodeInfo; + message.annotation = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.annotation.push( + GeneratedCodeInfo_Annotation.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GeneratedCodeInfo { + const message = { ...baseGeneratedCodeInfo } as GeneratedCodeInfo; + message.annotation = []; + if (object.annotation !== undefined && object.annotation !== null) { + for (const e of object.annotation) { + message.annotation.push(GeneratedCodeInfo_Annotation.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: GeneratedCodeInfo): unknown { + const obj: any = {}; + if (message.annotation) { + obj.annotation = message.annotation.map((e) => + e ? GeneratedCodeInfo_Annotation.toJSON(e) : undefined + ); + } else { + obj.annotation = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): GeneratedCodeInfo { + const message = { ...baseGeneratedCodeInfo } as GeneratedCodeInfo; + message.annotation = []; + if (object.annotation !== undefined && object.annotation !== null) { + for (const e of object.annotation) { + message.annotation.push(GeneratedCodeInfo_Annotation.fromPartial(e)); + } + } + return message; + }, +}; + +const baseGeneratedCodeInfo_Annotation: object = { + path: 0, + sourceFile: "", + begin: 0, + end: 0, +}; + +export const GeneratedCodeInfo_Annotation = { + encode( + message: GeneratedCodeInfo_Annotation, + writer: Writer = Writer.create() + ): Writer { + writer.uint32(10).fork(); + for (const v of message.path) { + writer.int32(v); + } + writer.ldelim(); + if (message.sourceFile !== "") { + writer.uint32(18).string(message.sourceFile); + } + if (message.begin !== 0) { + writer.uint32(24).int32(message.begin); + } + if (message.end !== 0) { + writer.uint32(32).int32(message.end); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): GeneratedCodeInfo_Annotation { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseGeneratedCodeInfo_Annotation, + } as GeneratedCodeInfo_Annotation; + message.path = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.path.push(reader.int32()); + } + } else { + message.path.push(reader.int32()); + } + break; + case 2: + message.sourceFile = reader.string(); + break; + case 3: + message.begin = reader.int32(); + break; + case 4: + message.end = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GeneratedCodeInfo_Annotation { + const message = { + ...baseGeneratedCodeInfo_Annotation, + } as GeneratedCodeInfo_Annotation; + message.path = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(Number(e)); + } + } + if (object.sourceFile !== undefined && object.sourceFile !== null) { + message.sourceFile = String(object.sourceFile); + } else { + message.sourceFile = ""; + } + if (object.begin !== undefined && object.begin !== null) { + message.begin = Number(object.begin); + } else { + message.begin = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + return message; + }, + + toJSON(message: GeneratedCodeInfo_Annotation): unknown { + const obj: any = {}; + if (message.path) { + obj.path = message.path.map((e) => e); + } else { + obj.path = []; + } + message.sourceFile !== undefined && (obj.sourceFile = message.sourceFile); + message.begin !== undefined && (obj.begin = message.begin); + message.end !== undefined && (obj.end = message.end); + return obj; + }, + + fromPartial( + object: DeepPartial + ): GeneratedCodeInfo_Annotation { + const message = { + ...baseGeneratedCodeInfo_Annotation, + } as GeneratedCodeInfo_Annotation; + message.path = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(e); + } + } + if (object.sourceFile !== undefined && object.sourceFile !== null) { + message.sourceFile = object.sourceFile; + } else { + message.sourceFile = ""; + } + if (object.begin !== undefined && object.begin !== null) { + message.begin = object.begin; + } else { + message.begin = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/cosmos.authz.v1beta1/types/google/protobuf/duration.ts b/ts-client/cosmos.authz.v1beta1/types/google/protobuf/duration.ts new file mode 100644 index 00000000..fffd5b14 --- /dev/null +++ b/ts-client/cosmos.authz.v1beta1/types/google/protobuf/duration.ts @@ -0,0 +1,188 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "google.protobuf"; + +/** + * A Duration represents a signed, fixed-length span of time represented + * as a count of seconds and fractions of seconds at nanosecond + * resolution. It is independent of any calendar and concepts like "day" + * or "month". It is related to Timestamp in that the difference between + * two Timestamp values is a Duration and it can be added or subtracted + * from a Timestamp. Range is approximately +-10,000 years. + * + * # Examples + * + * Example 1: Compute Duration from two Timestamps in pseudo code. + * + * Timestamp start = ...; + * Timestamp end = ...; + * Duration duration = ...; + * + * duration.seconds = end.seconds - start.seconds; + * duration.nanos = end.nanos - start.nanos; + * + * if (duration.seconds < 0 && duration.nanos > 0) { + * duration.seconds += 1; + * duration.nanos -= 1000000000; + * } else if (duration.seconds > 0 && duration.nanos < 0) { + * duration.seconds -= 1; + * duration.nanos += 1000000000; + * } + * + * Example 2: Compute Timestamp from Timestamp + Duration in pseudo code. + * + * Timestamp start = ...; + * Duration duration = ...; + * Timestamp end = ...; + * + * end.seconds = start.seconds + duration.seconds; + * end.nanos = start.nanos + duration.nanos; + * + * if (end.nanos < 0) { + * end.seconds -= 1; + * end.nanos += 1000000000; + * } else if (end.nanos >= 1000000000) { + * end.seconds += 1; + * end.nanos -= 1000000000; + * } + * + * Example 3: Compute Duration from datetime.timedelta in Python. + * + * td = datetime.timedelta(days=3, minutes=10) + * duration = Duration() + * duration.FromTimedelta(td) + * + * # JSON Mapping + * + * In JSON format, the Duration type is encoded as a string rather than an + * object, where the string ends in the suffix "s" (indicating seconds) and + * is preceded by the number of seconds, with nanoseconds expressed as + * fractional seconds. For example, 3 seconds with 0 nanoseconds should be + * encoded in JSON format as "3s", while 3 seconds and 1 nanosecond should + * be expressed in JSON format as "3.000000001s", and 3 seconds and 1 + * microsecond should be expressed in JSON format as "3.000001s". + */ +export interface Duration { + /** + * Signed seconds of the span of time. Must be from -315,576,000,000 + * to +315,576,000,000 inclusive. Note: these bounds are computed from: + * 60 sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years + */ + seconds: number; + /** + * Signed fractions of a second at nanosecond resolution of the span + * of time. Durations less than one second are represented with a 0 + * `seconds` field and a positive or negative `nanos` field. For durations + * of one second or more, a non-zero value for the `nanos` field must be + * of the same sign as the `seconds` field. Must be from -999,999,999 + * to +999,999,999 inclusive. + */ + nanos: number; +} + +const baseDuration: object = { seconds: 0, nanos: 0 }; + +export const Duration = { + encode(message: Duration, writer: Writer = Writer.create()): Writer { + if (message.seconds !== 0) { + writer.uint32(8).int64(message.seconds); + } + if (message.nanos !== 0) { + writer.uint32(16).int32(message.nanos); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Duration { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseDuration } as Duration; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.seconds = longToNumber(reader.int64() as Long); + break; + case 2: + message.nanos = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Duration { + const message = { ...baseDuration } as Duration; + if (object.seconds !== undefined && object.seconds !== null) { + message.seconds = Number(object.seconds); + } else { + message.seconds = 0; + } + if (object.nanos !== undefined && object.nanos !== null) { + message.nanos = Number(object.nanos); + } else { + message.nanos = 0; + } + return message; + }, + + toJSON(message: Duration): unknown { + const obj: any = {}; + message.seconds !== undefined && (obj.seconds = message.seconds); + message.nanos !== undefined && (obj.nanos = message.nanos); + return obj; + }, + + fromPartial(object: DeepPartial): Duration { + const message = { ...baseDuration } as Duration; + if (object.seconds !== undefined && object.seconds !== null) { + message.seconds = object.seconds; + } else { + message.seconds = 0; + } + if (object.nanos !== undefined && object.nanos !== null) { + message.nanos = object.nanos; + } else { + message.nanos = 0; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/cosmos.authz.v1beta1/types/google/protobuf/timestamp.ts b/ts-client/cosmos.authz.v1beta1/types/google/protobuf/timestamp.ts new file mode 100644 index 00000000..11864afc --- /dev/null +++ b/ts-client/cosmos.authz.v1beta1/types/google/protobuf/timestamp.ts @@ -0,0 +1,219 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "google.protobuf"; + +/** + * A Timestamp represents a point in time independent of any time zone or local + * calendar, encoded as a count of seconds and fractions of seconds at + * nanosecond resolution. The count is relative to an epoch at UTC midnight on + * January 1, 1970, in the proleptic Gregorian calendar which extends the + * Gregorian calendar backwards to year one. + * + * All minutes are 60 seconds long. Leap seconds are "smeared" so that no leap + * second table is needed for interpretation, using a [24-hour linear + * smear](https://developers.google.com/time/smear). + * + * The range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. By + * restricting to that range, we ensure that we can convert to and from [RFC + * 3339](https://www.ietf.org/rfc/rfc3339.txt) date strings. + * + * # Examples + * + * Example 1: Compute Timestamp from POSIX `time()`. + * + * Timestamp timestamp; + * timestamp.set_seconds(time(NULL)); + * timestamp.set_nanos(0); + * + * Example 2: Compute Timestamp from POSIX `gettimeofday()`. + * + * struct timeval tv; + * gettimeofday(&tv, NULL); + * + * Timestamp timestamp; + * timestamp.set_seconds(tv.tv_sec); + * timestamp.set_nanos(tv.tv_usec * 1000); + * + * Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`. + * + * FILETIME ft; + * GetSystemTimeAsFileTime(&ft); + * UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime; + * + * // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z + * // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z. + * Timestamp timestamp; + * timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL)); + * timestamp.set_nanos((INT32) ((ticks % 10000000) * 100)); + * + * Example 4: Compute Timestamp from Java `System.currentTimeMillis()`. + * + * long millis = System.currentTimeMillis(); + * + * Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000) + * .setNanos((int) ((millis % 1000) * 1000000)).build(); + * + * + * Example 5: Compute Timestamp from Java `Instant.now()`. + * + * Instant now = Instant.now(); + * + * Timestamp timestamp = + * Timestamp.newBuilder().setSeconds(now.getEpochSecond()) + * .setNanos(now.getNano()).build(); + * + * + * Example 6: Compute Timestamp from current time in Python. + * + * timestamp = Timestamp() + * timestamp.GetCurrentTime() + * + * # JSON Mapping + * + * In JSON format, the Timestamp type is encoded as a string in the + * [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the + * format is "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z" + * where {year} is always expressed using four digits while {month}, {day}, + * {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional + * seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution), + * are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone + * is required. A proto3 JSON serializer should always use UTC (as indicated by + * "Z") when printing the Timestamp type and a proto3 JSON parser should be + * able to accept both UTC and other timezones (as indicated by an offset). + * + * For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past + * 01:30 UTC on January 15, 2017. + * + * In JavaScript, one can convert a Date object to this format using the + * standard + * [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString) + * method. In Python, a standard `datetime.datetime` object can be converted + * to this format using + * [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) with + * the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one can use + * the Joda Time's [`ISODateTimeFormat.dateTime()`]( + * http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime%2D%2D + * ) to obtain a formatter capable of generating timestamps in this format. + */ +export interface Timestamp { + /** + * Represents seconds of UTC time since Unix epoch + * 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to + * 9999-12-31T23:59:59Z inclusive. + */ + seconds: number; + /** + * Non-negative fractions of a second at nanosecond resolution. Negative + * second values with fractions must still have non-negative nanos values + * that count forward in time. Must be from 0 to 999,999,999 + * inclusive. + */ + nanos: number; +} + +const baseTimestamp: object = { seconds: 0, nanos: 0 }; + +export const Timestamp = { + encode(message: Timestamp, writer: Writer = Writer.create()): Writer { + if (message.seconds !== 0) { + writer.uint32(8).int64(message.seconds); + } + if (message.nanos !== 0) { + writer.uint32(16).int32(message.nanos); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Timestamp { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseTimestamp } as Timestamp; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.seconds = longToNumber(reader.int64() as Long); + break; + case 2: + message.nanos = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Timestamp { + const message = { ...baseTimestamp } as Timestamp; + if (object.seconds !== undefined && object.seconds !== null) { + message.seconds = Number(object.seconds); + } else { + message.seconds = 0; + } + if (object.nanos !== undefined && object.nanos !== null) { + message.nanos = Number(object.nanos); + } else { + message.nanos = 0; + } + return message; + }, + + toJSON(message: Timestamp): unknown { + const obj: any = {}; + message.seconds !== undefined && (obj.seconds = message.seconds); + message.nanos !== undefined && (obj.nanos = message.nanos); + return obj; + }, + + fromPartial(object: DeepPartial): Timestamp { + const message = { ...baseTimestamp } as Timestamp; + if (object.seconds !== undefined && object.seconds !== null) { + message.seconds = object.seconds; + } else { + message.seconds = 0; + } + if (object.nanos !== undefined && object.nanos !== null) { + message.nanos = object.nanos; + } else { + message.nanos = 0; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/cosmos.authz.v1beta1/types/tendermint/abci/types.ts b/ts-client/cosmos.authz.v1beta1/types/tendermint/abci/types.ts new file mode 100644 index 00000000..8d4e7ed7 --- /dev/null +++ b/ts-client/cosmos.authz.v1beta1/types/tendermint/abci/types.ts @@ -0,0 +1,5687 @@ +/* eslint-disable */ +import { Reader, util, configure, Writer } from "protobufjs/minimal"; +import { Timestamp } from "../../google/protobuf/timestamp"; +import * as Long from "long"; +import { Header } from "../../tendermint/types/types"; +import { ProofOps } from "../../tendermint/crypto/proof"; +import { + EvidenceParams, + ValidatorParams, + VersionParams, +} from "../../tendermint/types/params"; +import { PublicKey } from "../../tendermint/crypto/keys"; + +export const protobufPackage = "tendermint.abci"; + +export enum CheckTxType { + NEW = 0, + RECHECK = 1, + UNRECOGNIZED = -1, +} + +export function checkTxTypeFromJSON(object: any): CheckTxType { + switch (object) { + case 0: + case "NEW": + return CheckTxType.NEW; + case 1: + case "RECHECK": + return CheckTxType.RECHECK; + case -1: + case "UNRECOGNIZED": + default: + return CheckTxType.UNRECOGNIZED; + } +} + +export function checkTxTypeToJSON(object: CheckTxType): string { + switch (object) { + case CheckTxType.NEW: + return "NEW"; + case CheckTxType.RECHECK: + return "RECHECK"; + default: + return "UNKNOWN"; + } +} + +export enum EvidenceType { + UNKNOWN = 0, + DUPLICATE_VOTE = 1, + LIGHT_CLIENT_ATTACK = 2, + UNRECOGNIZED = -1, +} + +export function evidenceTypeFromJSON(object: any): EvidenceType { + switch (object) { + case 0: + case "UNKNOWN": + return EvidenceType.UNKNOWN; + case 1: + case "DUPLICATE_VOTE": + return EvidenceType.DUPLICATE_VOTE; + case 2: + case "LIGHT_CLIENT_ATTACK": + return EvidenceType.LIGHT_CLIENT_ATTACK; + case -1: + case "UNRECOGNIZED": + default: + return EvidenceType.UNRECOGNIZED; + } +} + +export function evidenceTypeToJSON(object: EvidenceType): string { + switch (object) { + case EvidenceType.UNKNOWN: + return "UNKNOWN"; + case EvidenceType.DUPLICATE_VOTE: + return "DUPLICATE_VOTE"; + case EvidenceType.LIGHT_CLIENT_ATTACK: + return "LIGHT_CLIENT_ATTACK"; + default: + return "UNKNOWN"; + } +} + +export interface Request { + echo: RequestEcho | undefined; + flush: RequestFlush | undefined; + info: RequestInfo | undefined; + setOption: RequestSetOption | undefined; + initChain: RequestInitChain | undefined; + query: RequestQuery | undefined; + beginBlock: RequestBeginBlock | undefined; + checkTx: RequestCheckTx | undefined; + deliverTx: RequestDeliverTx | undefined; + endBlock: RequestEndBlock | undefined; + commit: RequestCommit | undefined; + listSnapshots: RequestListSnapshots | undefined; + offerSnapshot: RequestOfferSnapshot | undefined; + loadSnapshotChunk: RequestLoadSnapshotChunk | undefined; + applySnapshotChunk: RequestApplySnapshotChunk | undefined; +} + +export interface RequestEcho { + message: string; +} + +export interface RequestFlush {} + +export interface RequestInfo { + version: string; + blockVersion: number; + p2pVersion: number; +} + +/** nondeterministic */ +export interface RequestSetOption { + key: string; + value: string; +} + +export interface RequestInitChain { + time: Date | undefined; + chainId: string; + consensusParams: ConsensusParams | undefined; + validators: ValidatorUpdate[]; + appStateBytes: Uint8Array; + initialHeight: number; +} + +export interface RequestQuery { + data: Uint8Array; + path: string; + height: number; + prove: boolean; +} + +export interface RequestBeginBlock { + hash: Uint8Array; + header: Header | undefined; + lastCommitInfo: LastCommitInfo | undefined; + byzantineValidators: Evidence[]; +} + +export interface RequestCheckTx { + tx: Uint8Array; + type: CheckTxType; +} + +export interface RequestDeliverTx { + tx: Uint8Array; +} + +export interface RequestEndBlock { + height: number; +} + +export interface RequestCommit {} + +/** lists available snapshots */ +export interface RequestListSnapshots {} + +/** offers a snapshot to the application */ +export interface RequestOfferSnapshot { + /** snapshot offered by peers */ + snapshot: Snapshot | undefined; + /** light client-verified app hash for snapshot height */ + appHash: Uint8Array; +} + +/** loads a snapshot chunk */ +export interface RequestLoadSnapshotChunk { + height: number; + format: number; + chunk: number; +} + +/** Applies a snapshot chunk */ +export interface RequestApplySnapshotChunk { + index: number; + chunk: Uint8Array; + sender: string; +} + +export interface Response { + exception: ResponseException | undefined; + echo: ResponseEcho | undefined; + flush: ResponseFlush | undefined; + info: ResponseInfo | undefined; + setOption: ResponseSetOption | undefined; + initChain: ResponseInitChain | undefined; + query: ResponseQuery | undefined; + beginBlock: ResponseBeginBlock | undefined; + checkTx: ResponseCheckTx | undefined; + deliverTx: ResponseDeliverTx | undefined; + endBlock: ResponseEndBlock | undefined; + commit: ResponseCommit | undefined; + listSnapshots: ResponseListSnapshots | undefined; + offerSnapshot: ResponseOfferSnapshot | undefined; + loadSnapshotChunk: ResponseLoadSnapshotChunk | undefined; + applySnapshotChunk: ResponseApplySnapshotChunk | undefined; +} + +/** nondeterministic */ +export interface ResponseException { + error: string; +} + +export interface ResponseEcho { + message: string; +} + +export interface ResponseFlush {} + +export interface ResponseInfo { + data: string; + version: string; + appVersion: number; + lastBlockHeight: number; + lastBlockAppHash: Uint8Array; +} + +/** nondeterministic */ +export interface ResponseSetOption { + code: number; + /** bytes data = 2; */ + log: string; + info: string; +} + +export interface ResponseInitChain { + consensusParams: ConsensusParams | undefined; + validators: ValidatorUpdate[]; + appHash: Uint8Array; +} + +export interface ResponseQuery { + code: number; + /** bytes data = 2; // use "value" instead. */ + log: string; + /** nondeterministic */ + info: string; + index: number; + key: Uint8Array; + value: Uint8Array; + proofOps: ProofOps | undefined; + height: number; + codespace: string; +} + +export interface ResponseBeginBlock { + events: Event[]; +} + +export interface ResponseCheckTx { + code: number; + data: Uint8Array; + /** nondeterministic */ + log: string; + /** nondeterministic */ + info: string; + gasWanted: number; + gasUsed: number; + events: Event[]; + codespace: string; + sender: string; + priority: number; + /** + * mempool_error is set by CometBFT. + * ABCI applictions creating a ResponseCheckTX should not set mempool_error. + */ + mempoolError: string; +} + +export interface ResponseDeliverTx { + code: number; + data: Uint8Array; + /** nondeterministic */ + log: string; + /** nondeterministic */ + info: string; + gasWanted: number; + gasUsed: number; + /** nondeterministic */ + events: Event[]; + codespace: string; +} + +export interface ResponseEndBlock { + validatorUpdates: ValidatorUpdate[]; + consensusParamUpdates: ConsensusParams | undefined; + events: Event[]; +} + +export interface ResponseCommit { + /** reserve 1 */ + data: Uint8Array; + retainHeight: number; +} + +export interface ResponseListSnapshots { + snapshots: Snapshot[]; +} + +export interface ResponseOfferSnapshot { + result: ResponseOfferSnapshot_Result; +} + +export enum ResponseOfferSnapshot_Result { + /** UNKNOWN - Unknown result, abort all snapshot restoration */ + UNKNOWN = 0, + /** ACCEPT - Snapshot accepted, apply chunks */ + ACCEPT = 1, + /** ABORT - Abort all snapshot restoration */ + ABORT = 2, + /** REJECT - Reject this specific snapshot, try others */ + REJECT = 3, + /** REJECT_FORMAT - Reject all snapshots of this format, try others */ + REJECT_FORMAT = 4, + /** REJECT_SENDER - Reject all snapshots from the sender(s), try others */ + REJECT_SENDER = 5, + UNRECOGNIZED = -1, +} + +export function responseOfferSnapshot_ResultFromJSON( + object: any +): ResponseOfferSnapshot_Result { + switch (object) { + case 0: + case "UNKNOWN": + return ResponseOfferSnapshot_Result.UNKNOWN; + case 1: + case "ACCEPT": + return ResponseOfferSnapshot_Result.ACCEPT; + case 2: + case "ABORT": + return ResponseOfferSnapshot_Result.ABORT; + case 3: + case "REJECT": + return ResponseOfferSnapshot_Result.REJECT; + case 4: + case "REJECT_FORMAT": + return ResponseOfferSnapshot_Result.REJECT_FORMAT; + case 5: + case "REJECT_SENDER": + return ResponseOfferSnapshot_Result.REJECT_SENDER; + case -1: + case "UNRECOGNIZED": + default: + return ResponseOfferSnapshot_Result.UNRECOGNIZED; + } +} + +export function responseOfferSnapshot_ResultToJSON( + object: ResponseOfferSnapshot_Result +): string { + switch (object) { + case ResponseOfferSnapshot_Result.UNKNOWN: + return "UNKNOWN"; + case ResponseOfferSnapshot_Result.ACCEPT: + return "ACCEPT"; + case ResponseOfferSnapshot_Result.ABORT: + return "ABORT"; + case ResponseOfferSnapshot_Result.REJECT: + return "REJECT"; + case ResponseOfferSnapshot_Result.REJECT_FORMAT: + return "REJECT_FORMAT"; + case ResponseOfferSnapshot_Result.REJECT_SENDER: + return "REJECT_SENDER"; + default: + return "UNKNOWN"; + } +} + +export interface ResponseLoadSnapshotChunk { + chunk: Uint8Array; +} + +export interface ResponseApplySnapshotChunk { + result: ResponseApplySnapshotChunk_Result; + /** Chunks to refetch and reapply */ + refetchChunks: number[]; + /** Chunk senders to reject and ban */ + rejectSenders: string[]; +} + +export enum ResponseApplySnapshotChunk_Result { + /** UNKNOWN - Unknown result, abort all snapshot restoration */ + UNKNOWN = 0, + /** ACCEPT - Chunk successfully accepted */ + ACCEPT = 1, + /** ABORT - Abort all snapshot restoration */ + ABORT = 2, + /** RETRY - Retry chunk (combine with refetch and reject) */ + RETRY = 3, + /** RETRY_SNAPSHOT - Retry snapshot (combine with refetch and reject) */ + RETRY_SNAPSHOT = 4, + /** REJECT_SNAPSHOT - Reject this snapshot, try others */ + REJECT_SNAPSHOT = 5, + UNRECOGNIZED = -1, +} + +export function responseApplySnapshotChunk_ResultFromJSON( + object: any +): ResponseApplySnapshotChunk_Result { + switch (object) { + case 0: + case "UNKNOWN": + return ResponseApplySnapshotChunk_Result.UNKNOWN; + case 1: + case "ACCEPT": + return ResponseApplySnapshotChunk_Result.ACCEPT; + case 2: + case "ABORT": + return ResponseApplySnapshotChunk_Result.ABORT; + case 3: + case "RETRY": + return ResponseApplySnapshotChunk_Result.RETRY; + case 4: + case "RETRY_SNAPSHOT": + return ResponseApplySnapshotChunk_Result.RETRY_SNAPSHOT; + case 5: + case "REJECT_SNAPSHOT": + return ResponseApplySnapshotChunk_Result.REJECT_SNAPSHOT; + case -1: + case "UNRECOGNIZED": + default: + return ResponseApplySnapshotChunk_Result.UNRECOGNIZED; + } +} + +export function responseApplySnapshotChunk_ResultToJSON( + object: ResponseApplySnapshotChunk_Result +): string { + switch (object) { + case ResponseApplySnapshotChunk_Result.UNKNOWN: + return "UNKNOWN"; + case ResponseApplySnapshotChunk_Result.ACCEPT: + return "ACCEPT"; + case ResponseApplySnapshotChunk_Result.ABORT: + return "ABORT"; + case ResponseApplySnapshotChunk_Result.RETRY: + return "RETRY"; + case ResponseApplySnapshotChunk_Result.RETRY_SNAPSHOT: + return "RETRY_SNAPSHOT"; + case ResponseApplySnapshotChunk_Result.REJECT_SNAPSHOT: + return "REJECT_SNAPSHOT"; + default: + return "UNKNOWN"; + } +} + +/** + * ConsensusParams contains all consensus-relevant parameters + * that can be adjusted by the abci app + */ +export interface ConsensusParams { + block: BlockParams | undefined; + evidence: EvidenceParams | undefined; + validator: ValidatorParams | undefined; + version: VersionParams | undefined; +} + +/** BlockParams contains limits on the block size. */ +export interface BlockParams { + /** Note: must be greater than 0 */ + maxBytes: number; + /** Note: must be greater or equal to -1 */ + maxGas: number; +} + +export interface LastCommitInfo { + round: number; + votes: VoteInfo[]; +} + +/** + * Event allows application developers to attach additional information to + * ResponseBeginBlock, ResponseEndBlock, ResponseCheckTx and ResponseDeliverTx. + * Later, transactions may be queried using these events. + */ +export interface Event { + type: string; + attributes: EventAttribute[]; +} + +/** EventAttribute is a single key-value pair, associated with an event. */ +export interface EventAttribute { + key: Uint8Array; + value: Uint8Array; + /** nondeterministic */ + index: boolean; +} + +/** + * TxResult contains results of executing the transaction. + * + * One usage is indexing transaction results. + */ +export interface TxResult { + height: number; + index: number; + tx: Uint8Array; + result: ResponseDeliverTx | undefined; +} + +/** Validator */ +export interface Validator { + /** The first 20 bytes of SHA256(public key) */ + address: Uint8Array; + /** PubKey pub_key = 2 [(gogoproto.nullable)=false]; */ + power: number; +} + +/** ValidatorUpdate */ +export interface ValidatorUpdate { + pubKey: PublicKey | undefined; + power: number; +} + +/** VoteInfo */ +export interface VoteInfo { + validator: Validator | undefined; + signedLastBlock: boolean; +} + +export interface Evidence { + type: EvidenceType; + /** The offending validator */ + validator: Validator | undefined; + /** The height when the offense occurred */ + height: number; + /** The corresponding time where the offense occurred */ + time: Date | undefined; + /** + * Total voting power of the validator set in case the ABCI application does + * not store historical validators. + * https://github.com/tendermint/tendermint/issues/4581 + */ + totalVotingPower: number; +} + +export interface Snapshot { + /** The height at which the snapshot was taken */ + height: number; + /** The application-specific snapshot format */ + format: number; + /** Number of chunks in the snapshot */ + chunks: number; + /** Arbitrary snapshot hash, equal only if identical */ + hash: Uint8Array; + /** Arbitrary application metadata */ + metadata: Uint8Array; +} + +const baseRequest: object = {}; + +export const Request = { + encode(message: Request, writer: Writer = Writer.create()): Writer { + if (message.echo !== undefined) { + RequestEcho.encode(message.echo, writer.uint32(10).fork()).ldelim(); + } + if (message.flush !== undefined) { + RequestFlush.encode(message.flush, writer.uint32(18).fork()).ldelim(); + } + if (message.info !== undefined) { + RequestInfo.encode(message.info, writer.uint32(26).fork()).ldelim(); + } + if (message.setOption !== undefined) { + RequestSetOption.encode( + message.setOption, + writer.uint32(34).fork() + ).ldelim(); + } + if (message.initChain !== undefined) { + RequestInitChain.encode( + message.initChain, + writer.uint32(42).fork() + ).ldelim(); + } + if (message.query !== undefined) { + RequestQuery.encode(message.query, writer.uint32(50).fork()).ldelim(); + } + if (message.beginBlock !== undefined) { + RequestBeginBlock.encode( + message.beginBlock, + writer.uint32(58).fork() + ).ldelim(); + } + if (message.checkTx !== undefined) { + RequestCheckTx.encode(message.checkTx, writer.uint32(66).fork()).ldelim(); + } + if (message.deliverTx !== undefined) { + RequestDeliverTx.encode( + message.deliverTx, + writer.uint32(74).fork() + ).ldelim(); + } + if (message.endBlock !== undefined) { + RequestEndBlock.encode( + message.endBlock, + writer.uint32(82).fork() + ).ldelim(); + } + if (message.commit !== undefined) { + RequestCommit.encode(message.commit, writer.uint32(90).fork()).ldelim(); + } + if (message.listSnapshots !== undefined) { + RequestListSnapshots.encode( + message.listSnapshots, + writer.uint32(98).fork() + ).ldelim(); + } + if (message.offerSnapshot !== undefined) { + RequestOfferSnapshot.encode( + message.offerSnapshot, + writer.uint32(106).fork() + ).ldelim(); + } + if (message.loadSnapshotChunk !== undefined) { + RequestLoadSnapshotChunk.encode( + message.loadSnapshotChunk, + writer.uint32(114).fork() + ).ldelim(); + } + if (message.applySnapshotChunk !== undefined) { + RequestApplySnapshotChunk.encode( + message.applySnapshotChunk, + writer.uint32(122).fork() + ).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Request { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseRequest } as Request; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.echo = RequestEcho.decode(reader, reader.uint32()); + break; + case 2: + message.flush = RequestFlush.decode(reader, reader.uint32()); + break; + case 3: + message.info = RequestInfo.decode(reader, reader.uint32()); + break; + case 4: + message.setOption = RequestSetOption.decode(reader, reader.uint32()); + break; + case 5: + message.initChain = RequestInitChain.decode(reader, reader.uint32()); + break; + case 6: + message.query = RequestQuery.decode(reader, reader.uint32()); + break; + case 7: + message.beginBlock = RequestBeginBlock.decode( + reader, + reader.uint32() + ); + break; + case 8: + message.checkTx = RequestCheckTx.decode(reader, reader.uint32()); + break; + case 9: + message.deliverTx = RequestDeliverTx.decode(reader, reader.uint32()); + break; + case 10: + message.endBlock = RequestEndBlock.decode(reader, reader.uint32()); + break; + case 11: + message.commit = RequestCommit.decode(reader, reader.uint32()); + break; + case 12: + message.listSnapshots = RequestListSnapshots.decode( + reader, + reader.uint32() + ); + break; + case 13: + message.offerSnapshot = RequestOfferSnapshot.decode( + reader, + reader.uint32() + ); + break; + case 14: + message.loadSnapshotChunk = RequestLoadSnapshotChunk.decode( + reader, + reader.uint32() + ); + break; + case 15: + message.applySnapshotChunk = RequestApplySnapshotChunk.decode( + reader, + reader.uint32() + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Request { + const message = { ...baseRequest } as Request; + if (object.echo !== undefined && object.echo !== null) { + message.echo = RequestEcho.fromJSON(object.echo); + } else { + message.echo = undefined; + } + if (object.flush !== undefined && object.flush !== null) { + message.flush = RequestFlush.fromJSON(object.flush); + } else { + message.flush = undefined; + } + if (object.info !== undefined && object.info !== null) { + message.info = RequestInfo.fromJSON(object.info); + } else { + message.info = undefined; + } + if (object.setOption !== undefined && object.setOption !== null) { + message.setOption = RequestSetOption.fromJSON(object.setOption); + } else { + message.setOption = undefined; + } + if (object.initChain !== undefined && object.initChain !== null) { + message.initChain = RequestInitChain.fromJSON(object.initChain); + } else { + message.initChain = undefined; + } + if (object.query !== undefined && object.query !== null) { + message.query = RequestQuery.fromJSON(object.query); + } else { + message.query = undefined; + } + if (object.beginBlock !== undefined && object.beginBlock !== null) { + message.beginBlock = RequestBeginBlock.fromJSON(object.beginBlock); + } else { + message.beginBlock = undefined; + } + if (object.checkTx !== undefined && object.checkTx !== null) { + message.checkTx = RequestCheckTx.fromJSON(object.checkTx); + } else { + message.checkTx = undefined; + } + if (object.deliverTx !== undefined && object.deliverTx !== null) { + message.deliverTx = RequestDeliverTx.fromJSON(object.deliverTx); + } else { + message.deliverTx = undefined; + } + if (object.endBlock !== undefined && object.endBlock !== null) { + message.endBlock = RequestEndBlock.fromJSON(object.endBlock); + } else { + message.endBlock = undefined; + } + if (object.commit !== undefined && object.commit !== null) { + message.commit = RequestCommit.fromJSON(object.commit); + } else { + message.commit = undefined; + } + if (object.listSnapshots !== undefined && object.listSnapshots !== null) { + message.listSnapshots = RequestListSnapshots.fromJSON( + object.listSnapshots + ); + } else { + message.listSnapshots = undefined; + } + if (object.offerSnapshot !== undefined && object.offerSnapshot !== null) { + message.offerSnapshot = RequestOfferSnapshot.fromJSON( + object.offerSnapshot + ); + } else { + message.offerSnapshot = undefined; + } + if ( + object.loadSnapshotChunk !== undefined && + object.loadSnapshotChunk !== null + ) { + message.loadSnapshotChunk = RequestLoadSnapshotChunk.fromJSON( + object.loadSnapshotChunk + ); + } else { + message.loadSnapshotChunk = undefined; + } + if ( + object.applySnapshotChunk !== undefined && + object.applySnapshotChunk !== null + ) { + message.applySnapshotChunk = RequestApplySnapshotChunk.fromJSON( + object.applySnapshotChunk + ); + } else { + message.applySnapshotChunk = undefined; + } + return message; + }, + + toJSON(message: Request): unknown { + const obj: any = {}; + message.echo !== undefined && + (obj.echo = message.echo ? RequestEcho.toJSON(message.echo) : undefined); + message.flush !== undefined && + (obj.flush = message.flush + ? RequestFlush.toJSON(message.flush) + : undefined); + message.info !== undefined && + (obj.info = message.info ? RequestInfo.toJSON(message.info) : undefined); + message.setOption !== undefined && + (obj.setOption = message.setOption + ? RequestSetOption.toJSON(message.setOption) + : undefined); + message.initChain !== undefined && + (obj.initChain = message.initChain + ? RequestInitChain.toJSON(message.initChain) + : undefined); + message.query !== undefined && + (obj.query = message.query + ? RequestQuery.toJSON(message.query) + : undefined); + message.beginBlock !== undefined && + (obj.beginBlock = message.beginBlock + ? RequestBeginBlock.toJSON(message.beginBlock) + : undefined); + message.checkTx !== undefined && + (obj.checkTx = message.checkTx + ? RequestCheckTx.toJSON(message.checkTx) + : undefined); + message.deliverTx !== undefined && + (obj.deliverTx = message.deliverTx + ? RequestDeliverTx.toJSON(message.deliverTx) + : undefined); + message.endBlock !== undefined && + (obj.endBlock = message.endBlock + ? RequestEndBlock.toJSON(message.endBlock) + : undefined); + message.commit !== undefined && + (obj.commit = message.commit + ? RequestCommit.toJSON(message.commit) + : undefined); + message.listSnapshots !== undefined && + (obj.listSnapshots = message.listSnapshots + ? RequestListSnapshots.toJSON(message.listSnapshots) + : undefined); + message.offerSnapshot !== undefined && + (obj.offerSnapshot = message.offerSnapshot + ? RequestOfferSnapshot.toJSON(message.offerSnapshot) + : undefined); + message.loadSnapshotChunk !== undefined && + (obj.loadSnapshotChunk = message.loadSnapshotChunk + ? RequestLoadSnapshotChunk.toJSON(message.loadSnapshotChunk) + : undefined); + message.applySnapshotChunk !== undefined && + (obj.applySnapshotChunk = message.applySnapshotChunk + ? RequestApplySnapshotChunk.toJSON(message.applySnapshotChunk) + : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): Request { + const message = { ...baseRequest } as Request; + if (object.echo !== undefined && object.echo !== null) { + message.echo = RequestEcho.fromPartial(object.echo); + } else { + message.echo = undefined; + } + if (object.flush !== undefined && object.flush !== null) { + message.flush = RequestFlush.fromPartial(object.flush); + } else { + message.flush = undefined; + } + if (object.info !== undefined && object.info !== null) { + message.info = RequestInfo.fromPartial(object.info); + } else { + message.info = undefined; + } + if (object.setOption !== undefined && object.setOption !== null) { + message.setOption = RequestSetOption.fromPartial(object.setOption); + } else { + message.setOption = undefined; + } + if (object.initChain !== undefined && object.initChain !== null) { + message.initChain = RequestInitChain.fromPartial(object.initChain); + } else { + message.initChain = undefined; + } + if (object.query !== undefined && object.query !== null) { + message.query = RequestQuery.fromPartial(object.query); + } else { + message.query = undefined; + } + if (object.beginBlock !== undefined && object.beginBlock !== null) { + message.beginBlock = RequestBeginBlock.fromPartial(object.beginBlock); + } else { + message.beginBlock = undefined; + } + if (object.checkTx !== undefined && object.checkTx !== null) { + message.checkTx = RequestCheckTx.fromPartial(object.checkTx); + } else { + message.checkTx = undefined; + } + if (object.deliverTx !== undefined && object.deliverTx !== null) { + message.deliverTx = RequestDeliverTx.fromPartial(object.deliverTx); + } else { + message.deliverTx = undefined; + } + if (object.endBlock !== undefined && object.endBlock !== null) { + message.endBlock = RequestEndBlock.fromPartial(object.endBlock); + } else { + message.endBlock = undefined; + } + if (object.commit !== undefined && object.commit !== null) { + message.commit = RequestCommit.fromPartial(object.commit); + } else { + message.commit = undefined; + } + if (object.listSnapshots !== undefined && object.listSnapshots !== null) { + message.listSnapshots = RequestListSnapshots.fromPartial( + object.listSnapshots + ); + } else { + message.listSnapshots = undefined; + } + if (object.offerSnapshot !== undefined && object.offerSnapshot !== null) { + message.offerSnapshot = RequestOfferSnapshot.fromPartial( + object.offerSnapshot + ); + } else { + message.offerSnapshot = undefined; + } + if ( + object.loadSnapshotChunk !== undefined && + object.loadSnapshotChunk !== null + ) { + message.loadSnapshotChunk = RequestLoadSnapshotChunk.fromPartial( + object.loadSnapshotChunk + ); + } else { + message.loadSnapshotChunk = undefined; + } + if ( + object.applySnapshotChunk !== undefined && + object.applySnapshotChunk !== null + ) { + message.applySnapshotChunk = RequestApplySnapshotChunk.fromPartial( + object.applySnapshotChunk + ); + } else { + message.applySnapshotChunk = undefined; + } + return message; + }, +}; + +const baseRequestEcho: object = { message: "" }; + +export const RequestEcho = { + encode(message: RequestEcho, writer: Writer = Writer.create()): Writer { + if (message.message !== "") { + writer.uint32(10).string(message.message); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): RequestEcho { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseRequestEcho } as RequestEcho; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.message = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): RequestEcho { + const message = { ...baseRequestEcho } as RequestEcho; + if (object.message !== undefined && object.message !== null) { + message.message = String(object.message); + } else { + message.message = ""; + } + return message; + }, + + toJSON(message: RequestEcho): unknown { + const obj: any = {}; + message.message !== undefined && (obj.message = message.message); + return obj; + }, + + fromPartial(object: DeepPartial): RequestEcho { + const message = { ...baseRequestEcho } as RequestEcho; + if (object.message !== undefined && object.message !== null) { + message.message = object.message; + } else { + message.message = ""; + } + return message; + }, +}; + +const baseRequestFlush: object = {}; + +export const RequestFlush = { + encode(_: RequestFlush, writer: Writer = Writer.create()): Writer { + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): RequestFlush { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseRequestFlush } as RequestFlush; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): RequestFlush { + const message = { ...baseRequestFlush } as RequestFlush; + return message; + }, + + toJSON(_: RequestFlush): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial(_: DeepPartial): RequestFlush { + const message = { ...baseRequestFlush } as RequestFlush; + return message; + }, +}; + +const baseRequestInfo: object = { version: "", blockVersion: 0, p2pVersion: 0 }; + +export const RequestInfo = { + encode(message: RequestInfo, writer: Writer = Writer.create()): Writer { + if (message.version !== "") { + writer.uint32(10).string(message.version); + } + if (message.blockVersion !== 0) { + writer.uint32(16).uint64(message.blockVersion); + } + if (message.p2pVersion !== 0) { + writer.uint32(24).uint64(message.p2pVersion); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): RequestInfo { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseRequestInfo } as RequestInfo; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.version = reader.string(); + break; + case 2: + message.blockVersion = longToNumber(reader.uint64() as Long); + break; + case 3: + message.p2pVersion = longToNumber(reader.uint64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): RequestInfo { + const message = { ...baseRequestInfo } as RequestInfo; + if (object.version !== undefined && object.version !== null) { + message.version = String(object.version); + } else { + message.version = ""; + } + if (object.blockVersion !== undefined && object.blockVersion !== null) { + message.blockVersion = Number(object.blockVersion); + } else { + message.blockVersion = 0; + } + if (object.p2pVersion !== undefined && object.p2pVersion !== null) { + message.p2pVersion = Number(object.p2pVersion); + } else { + message.p2pVersion = 0; + } + return message; + }, + + toJSON(message: RequestInfo): unknown { + const obj: any = {}; + message.version !== undefined && (obj.version = message.version); + message.blockVersion !== undefined && + (obj.blockVersion = message.blockVersion); + message.p2pVersion !== undefined && (obj.p2pVersion = message.p2pVersion); + return obj; + }, + + fromPartial(object: DeepPartial): RequestInfo { + const message = { ...baseRequestInfo } as RequestInfo; + if (object.version !== undefined && object.version !== null) { + message.version = object.version; + } else { + message.version = ""; + } + if (object.blockVersion !== undefined && object.blockVersion !== null) { + message.blockVersion = object.blockVersion; + } else { + message.blockVersion = 0; + } + if (object.p2pVersion !== undefined && object.p2pVersion !== null) { + message.p2pVersion = object.p2pVersion; + } else { + message.p2pVersion = 0; + } + return message; + }, +}; + +const baseRequestSetOption: object = { key: "", value: "" }; + +export const RequestSetOption = { + encode(message: RequestSetOption, writer: Writer = Writer.create()): Writer { + if (message.key !== "") { + writer.uint32(10).string(message.key); + } + if (message.value !== "") { + writer.uint32(18).string(message.value); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): RequestSetOption { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseRequestSetOption } as RequestSetOption; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.key = reader.string(); + break; + case 2: + message.value = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): RequestSetOption { + const message = { ...baseRequestSetOption } as RequestSetOption; + if (object.key !== undefined && object.key !== null) { + message.key = String(object.key); + } else { + message.key = ""; + } + if (object.value !== undefined && object.value !== null) { + message.value = String(object.value); + } else { + message.value = ""; + } + return message; + }, + + toJSON(message: RequestSetOption): unknown { + const obj: any = {}; + message.key !== undefined && (obj.key = message.key); + message.value !== undefined && (obj.value = message.value); + return obj; + }, + + fromPartial(object: DeepPartial): RequestSetOption { + const message = { ...baseRequestSetOption } as RequestSetOption; + if (object.key !== undefined && object.key !== null) { + message.key = object.key; + } else { + message.key = ""; + } + if (object.value !== undefined && object.value !== null) { + message.value = object.value; + } else { + message.value = ""; + } + return message; + }, +}; + +const baseRequestInitChain: object = { chainId: "", initialHeight: 0 }; + +export const RequestInitChain = { + encode(message: RequestInitChain, writer: Writer = Writer.create()): Writer { + if (message.time !== undefined) { + Timestamp.encode( + toTimestamp(message.time), + writer.uint32(10).fork() + ).ldelim(); + } + if (message.chainId !== "") { + writer.uint32(18).string(message.chainId); + } + if (message.consensusParams !== undefined) { + ConsensusParams.encode( + message.consensusParams, + writer.uint32(26).fork() + ).ldelim(); + } + for (const v of message.validators) { + ValidatorUpdate.encode(v!, writer.uint32(34).fork()).ldelim(); + } + if (message.appStateBytes.length !== 0) { + writer.uint32(42).bytes(message.appStateBytes); + } + if (message.initialHeight !== 0) { + writer.uint32(48).int64(message.initialHeight); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): RequestInitChain { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseRequestInitChain } as RequestInitChain; + message.validators = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.time = fromTimestamp( + Timestamp.decode(reader, reader.uint32()) + ); + break; + case 2: + message.chainId = reader.string(); + break; + case 3: + message.consensusParams = ConsensusParams.decode( + reader, + reader.uint32() + ); + break; + case 4: + message.validators.push( + ValidatorUpdate.decode(reader, reader.uint32()) + ); + break; + case 5: + message.appStateBytes = reader.bytes(); + break; + case 6: + message.initialHeight = longToNumber(reader.int64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): RequestInitChain { + const message = { ...baseRequestInitChain } as RequestInitChain; + message.validators = []; + if (object.time !== undefined && object.time !== null) { + message.time = fromJsonTimestamp(object.time); + } else { + message.time = undefined; + } + if (object.chainId !== undefined && object.chainId !== null) { + message.chainId = String(object.chainId); + } else { + message.chainId = ""; + } + if ( + object.consensusParams !== undefined && + object.consensusParams !== null + ) { + message.consensusParams = ConsensusParams.fromJSON( + object.consensusParams + ); + } else { + message.consensusParams = undefined; + } + if (object.validators !== undefined && object.validators !== null) { + for (const e of object.validators) { + message.validators.push(ValidatorUpdate.fromJSON(e)); + } + } + if (object.appStateBytes !== undefined && object.appStateBytes !== null) { + message.appStateBytes = bytesFromBase64(object.appStateBytes); + } + if (object.initialHeight !== undefined && object.initialHeight !== null) { + message.initialHeight = Number(object.initialHeight); + } else { + message.initialHeight = 0; + } + return message; + }, + + toJSON(message: RequestInitChain): unknown { + const obj: any = {}; + message.time !== undefined && + (obj.time = + message.time !== undefined ? message.time.toISOString() : null); + message.chainId !== undefined && (obj.chainId = message.chainId); + message.consensusParams !== undefined && + (obj.consensusParams = message.consensusParams + ? ConsensusParams.toJSON(message.consensusParams) + : undefined); + if (message.validators) { + obj.validators = message.validators.map((e) => + e ? ValidatorUpdate.toJSON(e) : undefined + ); + } else { + obj.validators = []; + } + message.appStateBytes !== undefined && + (obj.appStateBytes = base64FromBytes( + message.appStateBytes !== undefined + ? message.appStateBytes + : new Uint8Array() + )); + message.initialHeight !== undefined && + (obj.initialHeight = message.initialHeight); + return obj; + }, + + fromPartial(object: DeepPartial): RequestInitChain { + const message = { ...baseRequestInitChain } as RequestInitChain; + message.validators = []; + if (object.time !== undefined && object.time !== null) { + message.time = object.time; + } else { + message.time = undefined; + } + if (object.chainId !== undefined && object.chainId !== null) { + message.chainId = object.chainId; + } else { + message.chainId = ""; + } + if ( + object.consensusParams !== undefined && + object.consensusParams !== null + ) { + message.consensusParams = ConsensusParams.fromPartial( + object.consensusParams + ); + } else { + message.consensusParams = undefined; + } + if (object.validators !== undefined && object.validators !== null) { + for (const e of object.validators) { + message.validators.push(ValidatorUpdate.fromPartial(e)); + } + } + if (object.appStateBytes !== undefined && object.appStateBytes !== null) { + message.appStateBytes = object.appStateBytes; + } else { + message.appStateBytes = new Uint8Array(); + } + if (object.initialHeight !== undefined && object.initialHeight !== null) { + message.initialHeight = object.initialHeight; + } else { + message.initialHeight = 0; + } + return message; + }, +}; + +const baseRequestQuery: object = { path: "", height: 0, prove: false }; + +export const RequestQuery = { + encode(message: RequestQuery, writer: Writer = Writer.create()): Writer { + if (message.data.length !== 0) { + writer.uint32(10).bytes(message.data); + } + if (message.path !== "") { + writer.uint32(18).string(message.path); + } + if (message.height !== 0) { + writer.uint32(24).int64(message.height); + } + if (message.prove === true) { + writer.uint32(32).bool(message.prove); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): RequestQuery { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseRequestQuery } as RequestQuery; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.data = reader.bytes(); + break; + case 2: + message.path = reader.string(); + break; + case 3: + message.height = longToNumber(reader.int64() as Long); + break; + case 4: + message.prove = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): RequestQuery { + const message = { ...baseRequestQuery } as RequestQuery; + if (object.data !== undefined && object.data !== null) { + message.data = bytesFromBase64(object.data); + } + if (object.path !== undefined && object.path !== null) { + message.path = String(object.path); + } else { + message.path = ""; + } + if (object.height !== undefined && object.height !== null) { + message.height = Number(object.height); + } else { + message.height = 0; + } + if (object.prove !== undefined && object.prove !== null) { + message.prove = Boolean(object.prove); + } else { + message.prove = false; + } + return message; + }, + + toJSON(message: RequestQuery): unknown { + const obj: any = {}; + message.data !== undefined && + (obj.data = base64FromBytes( + message.data !== undefined ? message.data : new Uint8Array() + )); + message.path !== undefined && (obj.path = message.path); + message.height !== undefined && (obj.height = message.height); + message.prove !== undefined && (obj.prove = message.prove); + return obj; + }, + + fromPartial(object: DeepPartial): RequestQuery { + const message = { ...baseRequestQuery } as RequestQuery; + if (object.data !== undefined && object.data !== null) { + message.data = object.data; + } else { + message.data = new Uint8Array(); + } + if (object.path !== undefined && object.path !== null) { + message.path = object.path; + } else { + message.path = ""; + } + if (object.height !== undefined && object.height !== null) { + message.height = object.height; + } else { + message.height = 0; + } + if (object.prove !== undefined && object.prove !== null) { + message.prove = object.prove; + } else { + message.prove = false; + } + return message; + }, +}; + +const baseRequestBeginBlock: object = {}; + +export const RequestBeginBlock = { + encode(message: RequestBeginBlock, writer: Writer = Writer.create()): Writer { + if (message.hash.length !== 0) { + writer.uint32(10).bytes(message.hash); + } + if (message.header !== undefined) { + Header.encode(message.header, writer.uint32(18).fork()).ldelim(); + } + if (message.lastCommitInfo !== undefined) { + LastCommitInfo.encode( + message.lastCommitInfo, + writer.uint32(26).fork() + ).ldelim(); + } + for (const v of message.byzantineValidators) { + Evidence.encode(v!, writer.uint32(34).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): RequestBeginBlock { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseRequestBeginBlock } as RequestBeginBlock; + message.byzantineValidators = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.hash = reader.bytes(); + break; + case 2: + message.header = Header.decode(reader, reader.uint32()); + break; + case 3: + message.lastCommitInfo = LastCommitInfo.decode( + reader, + reader.uint32() + ); + break; + case 4: + message.byzantineValidators.push( + Evidence.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): RequestBeginBlock { + const message = { ...baseRequestBeginBlock } as RequestBeginBlock; + message.byzantineValidators = []; + if (object.hash !== undefined && object.hash !== null) { + message.hash = bytesFromBase64(object.hash); + } + if (object.header !== undefined && object.header !== null) { + message.header = Header.fromJSON(object.header); + } else { + message.header = undefined; + } + if (object.lastCommitInfo !== undefined && object.lastCommitInfo !== null) { + message.lastCommitInfo = LastCommitInfo.fromJSON(object.lastCommitInfo); + } else { + message.lastCommitInfo = undefined; + } + if ( + object.byzantineValidators !== undefined && + object.byzantineValidators !== null + ) { + for (const e of object.byzantineValidators) { + message.byzantineValidators.push(Evidence.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: RequestBeginBlock): unknown { + const obj: any = {}; + message.hash !== undefined && + (obj.hash = base64FromBytes( + message.hash !== undefined ? message.hash : new Uint8Array() + )); + message.header !== undefined && + (obj.header = message.header ? Header.toJSON(message.header) : undefined); + message.lastCommitInfo !== undefined && + (obj.lastCommitInfo = message.lastCommitInfo + ? LastCommitInfo.toJSON(message.lastCommitInfo) + : undefined); + if (message.byzantineValidators) { + obj.byzantineValidators = message.byzantineValidators.map((e) => + e ? Evidence.toJSON(e) : undefined + ); + } else { + obj.byzantineValidators = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): RequestBeginBlock { + const message = { ...baseRequestBeginBlock } as RequestBeginBlock; + message.byzantineValidators = []; + if (object.hash !== undefined && object.hash !== null) { + message.hash = object.hash; + } else { + message.hash = new Uint8Array(); + } + if (object.header !== undefined && object.header !== null) { + message.header = Header.fromPartial(object.header); + } else { + message.header = undefined; + } + if (object.lastCommitInfo !== undefined && object.lastCommitInfo !== null) { + message.lastCommitInfo = LastCommitInfo.fromPartial( + object.lastCommitInfo + ); + } else { + message.lastCommitInfo = undefined; + } + if ( + object.byzantineValidators !== undefined && + object.byzantineValidators !== null + ) { + for (const e of object.byzantineValidators) { + message.byzantineValidators.push(Evidence.fromPartial(e)); + } + } + return message; + }, +}; + +const baseRequestCheckTx: object = { type: 0 }; + +export const RequestCheckTx = { + encode(message: RequestCheckTx, writer: Writer = Writer.create()): Writer { + if (message.tx.length !== 0) { + writer.uint32(10).bytes(message.tx); + } + if (message.type !== 0) { + writer.uint32(16).int32(message.type); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): RequestCheckTx { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseRequestCheckTx } as RequestCheckTx; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.tx = reader.bytes(); + break; + case 2: + message.type = reader.int32() as any; + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): RequestCheckTx { + const message = { ...baseRequestCheckTx } as RequestCheckTx; + if (object.tx !== undefined && object.tx !== null) { + message.tx = bytesFromBase64(object.tx); + } + if (object.type !== undefined && object.type !== null) { + message.type = checkTxTypeFromJSON(object.type); + } else { + message.type = 0; + } + return message; + }, + + toJSON(message: RequestCheckTx): unknown { + const obj: any = {}; + message.tx !== undefined && + (obj.tx = base64FromBytes( + message.tx !== undefined ? message.tx : new Uint8Array() + )); + message.type !== undefined && (obj.type = checkTxTypeToJSON(message.type)); + return obj; + }, + + fromPartial(object: DeepPartial): RequestCheckTx { + const message = { ...baseRequestCheckTx } as RequestCheckTx; + if (object.tx !== undefined && object.tx !== null) { + message.tx = object.tx; + } else { + message.tx = new Uint8Array(); + } + if (object.type !== undefined && object.type !== null) { + message.type = object.type; + } else { + message.type = 0; + } + return message; + }, +}; + +const baseRequestDeliverTx: object = {}; + +export const RequestDeliverTx = { + encode(message: RequestDeliverTx, writer: Writer = Writer.create()): Writer { + if (message.tx.length !== 0) { + writer.uint32(10).bytes(message.tx); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): RequestDeliverTx { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseRequestDeliverTx } as RequestDeliverTx; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.tx = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): RequestDeliverTx { + const message = { ...baseRequestDeliverTx } as RequestDeliverTx; + if (object.tx !== undefined && object.tx !== null) { + message.tx = bytesFromBase64(object.tx); + } + return message; + }, + + toJSON(message: RequestDeliverTx): unknown { + const obj: any = {}; + message.tx !== undefined && + (obj.tx = base64FromBytes( + message.tx !== undefined ? message.tx : new Uint8Array() + )); + return obj; + }, + + fromPartial(object: DeepPartial): RequestDeliverTx { + const message = { ...baseRequestDeliverTx } as RequestDeliverTx; + if (object.tx !== undefined && object.tx !== null) { + message.tx = object.tx; + } else { + message.tx = new Uint8Array(); + } + return message; + }, +}; + +const baseRequestEndBlock: object = { height: 0 }; + +export const RequestEndBlock = { + encode(message: RequestEndBlock, writer: Writer = Writer.create()): Writer { + if (message.height !== 0) { + writer.uint32(8).int64(message.height); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): RequestEndBlock { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseRequestEndBlock } as RequestEndBlock; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.height = longToNumber(reader.int64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): RequestEndBlock { + const message = { ...baseRequestEndBlock } as RequestEndBlock; + if (object.height !== undefined && object.height !== null) { + message.height = Number(object.height); + } else { + message.height = 0; + } + return message; + }, + + toJSON(message: RequestEndBlock): unknown { + const obj: any = {}; + message.height !== undefined && (obj.height = message.height); + return obj; + }, + + fromPartial(object: DeepPartial): RequestEndBlock { + const message = { ...baseRequestEndBlock } as RequestEndBlock; + if (object.height !== undefined && object.height !== null) { + message.height = object.height; + } else { + message.height = 0; + } + return message; + }, +}; + +const baseRequestCommit: object = {}; + +export const RequestCommit = { + encode(_: RequestCommit, writer: Writer = Writer.create()): Writer { + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): RequestCommit { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseRequestCommit } as RequestCommit; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): RequestCommit { + const message = { ...baseRequestCommit } as RequestCommit; + return message; + }, + + toJSON(_: RequestCommit): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial(_: DeepPartial): RequestCommit { + const message = { ...baseRequestCommit } as RequestCommit; + return message; + }, +}; + +const baseRequestListSnapshots: object = {}; + +export const RequestListSnapshots = { + encode(_: RequestListSnapshots, writer: Writer = Writer.create()): Writer { + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): RequestListSnapshots { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseRequestListSnapshots } as RequestListSnapshots; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): RequestListSnapshots { + const message = { ...baseRequestListSnapshots } as RequestListSnapshots; + return message; + }, + + toJSON(_: RequestListSnapshots): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial(_: DeepPartial): RequestListSnapshots { + const message = { ...baseRequestListSnapshots } as RequestListSnapshots; + return message; + }, +}; + +const baseRequestOfferSnapshot: object = {}; + +export const RequestOfferSnapshot = { + encode( + message: RequestOfferSnapshot, + writer: Writer = Writer.create() + ): Writer { + if (message.snapshot !== undefined) { + Snapshot.encode(message.snapshot, writer.uint32(10).fork()).ldelim(); + } + if (message.appHash.length !== 0) { + writer.uint32(18).bytes(message.appHash); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): RequestOfferSnapshot { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseRequestOfferSnapshot } as RequestOfferSnapshot; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.snapshot = Snapshot.decode(reader, reader.uint32()); + break; + case 2: + message.appHash = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): RequestOfferSnapshot { + const message = { ...baseRequestOfferSnapshot } as RequestOfferSnapshot; + if (object.snapshot !== undefined && object.snapshot !== null) { + message.snapshot = Snapshot.fromJSON(object.snapshot); + } else { + message.snapshot = undefined; + } + if (object.appHash !== undefined && object.appHash !== null) { + message.appHash = bytesFromBase64(object.appHash); + } + return message; + }, + + toJSON(message: RequestOfferSnapshot): unknown { + const obj: any = {}; + message.snapshot !== undefined && + (obj.snapshot = message.snapshot + ? Snapshot.toJSON(message.snapshot) + : undefined); + message.appHash !== undefined && + (obj.appHash = base64FromBytes( + message.appHash !== undefined ? message.appHash : new Uint8Array() + )); + return obj; + }, + + fromPartial(object: DeepPartial): RequestOfferSnapshot { + const message = { ...baseRequestOfferSnapshot } as RequestOfferSnapshot; + if (object.snapshot !== undefined && object.snapshot !== null) { + message.snapshot = Snapshot.fromPartial(object.snapshot); + } else { + message.snapshot = undefined; + } + if (object.appHash !== undefined && object.appHash !== null) { + message.appHash = object.appHash; + } else { + message.appHash = new Uint8Array(); + } + return message; + }, +}; + +const baseRequestLoadSnapshotChunk: object = { height: 0, format: 0, chunk: 0 }; + +export const RequestLoadSnapshotChunk = { + encode( + message: RequestLoadSnapshotChunk, + writer: Writer = Writer.create() + ): Writer { + if (message.height !== 0) { + writer.uint32(8).uint64(message.height); + } + if (message.format !== 0) { + writer.uint32(16).uint32(message.format); + } + if (message.chunk !== 0) { + writer.uint32(24).uint32(message.chunk); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): RequestLoadSnapshotChunk { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseRequestLoadSnapshotChunk, + } as RequestLoadSnapshotChunk; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.height = longToNumber(reader.uint64() as Long); + break; + case 2: + message.format = reader.uint32(); + break; + case 3: + message.chunk = reader.uint32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): RequestLoadSnapshotChunk { + const message = { + ...baseRequestLoadSnapshotChunk, + } as RequestLoadSnapshotChunk; + if (object.height !== undefined && object.height !== null) { + message.height = Number(object.height); + } else { + message.height = 0; + } + if (object.format !== undefined && object.format !== null) { + message.format = Number(object.format); + } else { + message.format = 0; + } + if (object.chunk !== undefined && object.chunk !== null) { + message.chunk = Number(object.chunk); + } else { + message.chunk = 0; + } + return message; + }, + + toJSON(message: RequestLoadSnapshotChunk): unknown { + const obj: any = {}; + message.height !== undefined && (obj.height = message.height); + message.format !== undefined && (obj.format = message.format); + message.chunk !== undefined && (obj.chunk = message.chunk); + return obj; + }, + + fromPartial( + object: DeepPartial + ): RequestLoadSnapshotChunk { + const message = { + ...baseRequestLoadSnapshotChunk, + } as RequestLoadSnapshotChunk; + if (object.height !== undefined && object.height !== null) { + message.height = object.height; + } else { + message.height = 0; + } + if (object.format !== undefined && object.format !== null) { + message.format = object.format; + } else { + message.format = 0; + } + if (object.chunk !== undefined && object.chunk !== null) { + message.chunk = object.chunk; + } else { + message.chunk = 0; + } + return message; + }, +}; + +const baseRequestApplySnapshotChunk: object = { index: 0, sender: "" }; + +export const RequestApplySnapshotChunk = { + encode( + message: RequestApplySnapshotChunk, + writer: Writer = Writer.create() + ): Writer { + if (message.index !== 0) { + writer.uint32(8).uint32(message.index); + } + if (message.chunk.length !== 0) { + writer.uint32(18).bytes(message.chunk); + } + if (message.sender !== "") { + writer.uint32(26).string(message.sender); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): RequestApplySnapshotChunk { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseRequestApplySnapshotChunk, + } as RequestApplySnapshotChunk; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.index = reader.uint32(); + break; + case 2: + message.chunk = reader.bytes(); + break; + case 3: + message.sender = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): RequestApplySnapshotChunk { + const message = { + ...baseRequestApplySnapshotChunk, + } as RequestApplySnapshotChunk; + if (object.index !== undefined && object.index !== null) { + message.index = Number(object.index); + } else { + message.index = 0; + } + if (object.chunk !== undefined && object.chunk !== null) { + message.chunk = bytesFromBase64(object.chunk); + } + if (object.sender !== undefined && object.sender !== null) { + message.sender = String(object.sender); + } else { + message.sender = ""; + } + return message; + }, + + toJSON(message: RequestApplySnapshotChunk): unknown { + const obj: any = {}; + message.index !== undefined && (obj.index = message.index); + message.chunk !== undefined && + (obj.chunk = base64FromBytes( + message.chunk !== undefined ? message.chunk : new Uint8Array() + )); + message.sender !== undefined && (obj.sender = message.sender); + return obj; + }, + + fromPartial( + object: DeepPartial + ): RequestApplySnapshotChunk { + const message = { + ...baseRequestApplySnapshotChunk, + } as RequestApplySnapshotChunk; + if (object.index !== undefined && object.index !== null) { + message.index = object.index; + } else { + message.index = 0; + } + if (object.chunk !== undefined && object.chunk !== null) { + message.chunk = object.chunk; + } else { + message.chunk = new Uint8Array(); + } + if (object.sender !== undefined && object.sender !== null) { + message.sender = object.sender; + } else { + message.sender = ""; + } + return message; + }, +}; + +const baseResponse: object = {}; + +export const Response = { + encode(message: Response, writer: Writer = Writer.create()): Writer { + if (message.exception !== undefined) { + ResponseException.encode( + message.exception, + writer.uint32(10).fork() + ).ldelim(); + } + if (message.echo !== undefined) { + ResponseEcho.encode(message.echo, writer.uint32(18).fork()).ldelim(); + } + if (message.flush !== undefined) { + ResponseFlush.encode(message.flush, writer.uint32(26).fork()).ldelim(); + } + if (message.info !== undefined) { + ResponseInfo.encode(message.info, writer.uint32(34).fork()).ldelim(); + } + if (message.setOption !== undefined) { + ResponseSetOption.encode( + message.setOption, + writer.uint32(42).fork() + ).ldelim(); + } + if (message.initChain !== undefined) { + ResponseInitChain.encode( + message.initChain, + writer.uint32(50).fork() + ).ldelim(); + } + if (message.query !== undefined) { + ResponseQuery.encode(message.query, writer.uint32(58).fork()).ldelim(); + } + if (message.beginBlock !== undefined) { + ResponseBeginBlock.encode( + message.beginBlock, + writer.uint32(66).fork() + ).ldelim(); + } + if (message.checkTx !== undefined) { + ResponseCheckTx.encode( + message.checkTx, + writer.uint32(74).fork() + ).ldelim(); + } + if (message.deliverTx !== undefined) { + ResponseDeliverTx.encode( + message.deliverTx, + writer.uint32(82).fork() + ).ldelim(); + } + if (message.endBlock !== undefined) { + ResponseEndBlock.encode( + message.endBlock, + writer.uint32(90).fork() + ).ldelim(); + } + if (message.commit !== undefined) { + ResponseCommit.encode(message.commit, writer.uint32(98).fork()).ldelim(); + } + if (message.listSnapshots !== undefined) { + ResponseListSnapshots.encode( + message.listSnapshots, + writer.uint32(106).fork() + ).ldelim(); + } + if (message.offerSnapshot !== undefined) { + ResponseOfferSnapshot.encode( + message.offerSnapshot, + writer.uint32(114).fork() + ).ldelim(); + } + if (message.loadSnapshotChunk !== undefined) { + ResponseLoadSnapshotChunk.encode( + message.loadSnapshotChunk, + writer.uint32(122).fork() + ).ldelim(); + } + if (message.applySnapshotChunk !== undefined) { + ResponseApplySnapshotChunk.encode( + message.applySnapshotChunk, + writer.uint32(130).fork() + ).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Response { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseResponse } as Response; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.exception = ResponseException.decode(reader, reader.uint32()); + break; + case 2: + message.echo = ResponseEcho.decode(reader, reader.uint32()); + break; + case 3: + message.flush = ResponseFlush.decode(reader, reader.uint32()); + break; + case 4: + message.info = ResponseInfo.decode(reader, reader.uint32()); + break; + case 5: + message.setOption = ResponseSetOption.decode(reader, reader.uint32()); + break; + case 6: + message.initChain = ResponseInitChain.decode(reader, reader.uint32()); + break; + case 7: + message.query = ResponseQuery.decode(reader, reader.uint32()); + break; + case 8: + message.beginBlock = ResponseBeginBlock.decode( + reader, + reader.uint32() + ); + break; + case 9: + message.checkTx = ResponseCheckTx.decode(reader, reader.uint32()); + break; + case 10: + message.deliverTx = ResponseDeliverTx.decode(reader, reader.uint32()); + break; + case 11: + message.endBlock = ResponseEndBlock.decode(reader, reader.uint32()); + break; + case 12: + message.commit = ResponseCommit.decode(reader, reader.uint32()); + break; + case 13: + message.listSnapshots = ResponseListSnapshots.decode( + reader, + reader.uint32() + ); + break; + case 14: + message.offerSnapshot = ResponseOfferSnapshot.decode( + reader, + reader.uint32() + ); + break; + case 15: + message.loadSnapshotChunk = ResponseLoadSnapshotChunk.decode( + reader, + reader.uint32() + ); + break; + case 16: + message.applySnapshotChunk = ResponseApplySnapshotChunk.decode( + reader, + reader.uint32() + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Response { + const message = { ...baseResponse } as Response; + if (object.exception !== undefined && object.exception !== null) { + message.exception = ResponseException.fromJSON(object.exception); + } else { + message.exception = undefined; + } + if (object.echo !== undefined && object.echo !== null) { + message.echo = ResponseEcho.fromJSON(object.echo); + } else { + message.echo = undefined; + } + if (object.flush !== undefined && object.flush !== null) { + message.flush = ResponseFlush.fromJSON(object.flush); + } else { + message.flush = undefined; + } + if (object.info !== undefined && object.info !== null) { + message.info = ResponseInfo.fromJSON(object.info); + } else { + message.info = undefined; + } + if (object.setOption !== undefined && object.setOption !== null) { + message.setOption = ResponseSetOption.fromJSON(object.setOption); + } else { + message.setOption = undefined; + } + if (object.initChain !== undefined && object.initChain !== null) { + message.initChain = ResponseInitChain.fromJSON(object.initChain); + } else { + message.initChain = undefined; + } + if (object.query !== undefined && object.query !== null) { + message.query = ResponseQuery.fromJSON(object.query); + } else { + message.query = undefined; + } + if (object.beginBlock !== undefined && object.beginBlock !== null) { + message.beginBlock = ResponseBeginBlock.fromJSON(object.beginBlock); + } else { + message.beginBlock = undefined; + } + if (object.checkTx !== undefined && object.checkTx !== null) { + message.checkTx = ResponseCheckTx.fromJSON(object.checkTx); + } else { + message.checkTx = undefined; + } + if (object.deliverTx !== undefined && object.deliverTx !== null) { + message.deliverTx = ResponseDeliverTx.fromJSON(object.deliverTx); + } else { + message.deliverTx = undefined; + } + if (object.endBlock !== undefined && object.endBlock !== null) { + message.endBlock = ResponseEndBlock.fromJSON(object.endBlock); + } else { + message.endBlock = undefined; + } + if (object.commit !== undefined && object.commit !== null) { + message.commit = ResponseCommit.fromJSON(object.commit); + } else { + message.commit = undefined; + } + if (object.listSnapshots !== undefined && object.listSnapshots !== null) { + message.listSnapshots = ResponseListSnapshots.fromJSON( + object.listSnapshots + ); + } else { + message.listSnapshots = undefined; + } + if (object.offerSnapshot !== undefined && object.offerSnapshot !== null) { + message.offerSnapshot = ResponseOfferSnapshot.fromJSON( + object.offerSnapshot + ); + } else { + message.offerSnapshot = undefined; + } + if ( + object.loadSnapshotChunk !== undefined && + object.loadSnapshotChunk !== null + ) { + message.loadSnapshotChunk = ResponseLoadSnapshotChunk.fromJSON( + object.loadSnapshotChunk + ); + } else { + message.loadSnapshotChunk = undefined; + } + if ( + object.applySnapshotChunk !== undefined && + object.applySnapshotChunk !== null + ) { + message.applySnapshotChunk = ResponseApplySnapshotChunk.fromJSON( + object.applySnapshotChunk + ); + } else { + message.applySnapshotChunk = undefined; + } + return message; + }, + + toJSON(message: Response): unknown { + const obj: any = {}; + message.exception !== undefined && + (obj.exception = message.exception + ? ResponseException.toJSON(message.exception) + : undefined); + message.echo !== undefined && + (obj.echo = message.echo ? ResponseEcho.toJSON(message.echo) : undefined); + message.flush !== undefined && + (obj.flush = message.flush + ? ResponseFlush.toJSON(message.flush) + : undefined); + message.info !== undefined && + (obj.info = message.info ? ResponseInfo.toJSON(message.info) : undefined); + message.setOption !== undefined && + (obj.setOption = message.setOption + ? ResponseSetOption.toJSON(message.setOption) + : undefined); + message.initChain !== undefined && + (obj.initChain = message.initChain + ? ResponseInitChain.toJSON(message.initChain) + : undefined); + message.query !== undefined && + (obj.query = message.query + ? ResponseQuery.toJSON(message.query) + : undefined); + message.beginBlock !== undefined && + (obj.beginBlock = message.beginBlock + ? ResponseBeginBlock.toJSON(message.beginBlock) + : undefined); + message.checkTx !== undefined && + (obj.checkTx = message.checkTx + ? ResponseCheckTx.toJSON(message.checkTx) + : undefined); + message.deliverTx !== undefined && + (obj.deliverTx = message.deliverTx + ? ResponseDeliverTx.toJSON(message.deliverTx) + : undefined); + message.endBlock !== undefined && + (obj.endBlock = message.endBlock + ? ResponseEndBlock.toJSON(message.endBlock) + : undefined); + message.commit !== undefined && + (obj.commit = message.commit + ? ResponseCommit.toJSON(message.commit) + : undefined); + message.listSnapshots !== undefined && + (obj.listSnapshots = message.listSnapshots + ? ResponseListSnapshots.toJSON(message.listSnapshots) + : undefined); + message.offerSnapshot !== undefined && + (obj.offerSnapshot = message.offerSnapshot + ? ResponseOfferSnapshot.toJSON(message.offerSnapshot) + : undefined); + message.loadSnapshotChunk !== undefined && + (obj.loadSnapshotChunk = message.loadSnapshotChunk + ? ResponseLoadSnapshotChunk.toJSON(message.loadSnapshotChunk) + : undefined); + message.applySnapshotChunk !== undefined && + (obj.applySnapshotChunk = message.applySnapshotChunk + ? ResponseApplySnapshotChunk.toJSON(message.applySnapshotChunk) + : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): Response { + const message = { ...baseResponse } as Response; + if (object.exception !== undefined && object.exception !== null) { + message.exception = ResponseException.fromPartial(object.exception); + } else { + message.exception = undefined; + } + if (object.echo !== undefined && object.echo !== null) { + message.echo = ResponseEcho.fromPartial(object.echo); + } else { + message.echo = undefined; + } + if (object.flush !== undefined && object.flush !== null) { + message.flush = ResponseFlush.fromPartial(object.flush); + } else { + message.flush = undefined; + } + if (object.info !== undefined && object.info !== null) { + message.info = ResponseInfo.fromPartial(object.info); + } else { + message.info = undefined; + } + if (object.setOption !== undefined && object.setOption !== null) { + message.setOption = ResponseSetOption.fromPartial(object.setOption); + } else { + message.setOption = undefined; + } + if (object.initChain !== undefined && object.initChain !== null) { + message.initChain = ResponseInitChain.fromPartial(object.initChain); + } else { + message.initChain = undefined; + } + if (object.query !== undefined && object.query !== null) { + message.query = ResponseQuery.fromPartial(object.query); + } else { + message.query = undefined; + } + if (object.beginBlock !== undefined && object.beginBlock !== null) { + message.beginBlock = ResponseBeginBlock.fromPartial(object.beginBlock); + } else { + message.beginBlock = undefined; + } + if (object.checkTx !== undefined && object.checkTx !== null) { + message.checkTx = ResponseCheckTx.fromPartial(object.checkTx); + } else { + message.checkTx = undefined; + } + if (object.deliverTx !== undefined && object.deliverTx !== null) { + message.deliverTx = ResponseDeliverTx.fromPartial(object.deliverTx); + } else { + message.deliverTx = undefined; + } + if (object.endBlock !== undefined && object.endBlock !== null) { + message.endBlock = ResponseEndBlock.fromPartial(object.endBlock); + } else { + message.endBlock = undefined; + } + if (object.commit !== undefined && object.commit !== null) { + message.commit = ResponseCommit.fromPartial(object.commit); + } else { + message.commit = undefined; + } + if (object.listSnapshots !== undefined && object.listSnapshots !== null) { + message.listSnapshots = ResponseListSnapshots.fromPartial( + object.listSnapshots + ); + } else { + message.listSnapshots = undefined; + } + if (object.offerSnapshot !== undefined && object.offerSnapshot !== null) { + message.offerSnapshot = ResponseOfferSnapshot.fromPartial( + object.offerSnapshot + ); + } else { + message.offerSnapshot = undefined; + } + if ( + object.loadSnapshotChunk !== undefined && + object.loadSnapshotChunk !== null + ) { + message.loadSnapshotChunk = ResponseLoadSnapshotChunk.fromPartial( + object.loadSnapshotChunk + ); + } else { + message.loadSnapshotChunk = undefined; + } + if ( + object.applySnapshotChunk !== undefined && + object.applySnapshotChunk !== null + ) { + message.applySnapshotChunk = ResponseApplySnapshotChunk.fromPartial( + object.applySnapshotChunk + ); + } else { + message.applySnapshotChunk = undefined; + } + return message; + }, +}; + +const baseResponseException: object = { error: "" }; + +export const ResponseException = { + encode(message: ResponseException, writer: Writer = Writer.create()): Writer { + if (message.error !== "") { + writer.uint32(10).string(message.error); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ResponseException { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseResponseException } as ResponseException; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.error = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ResponseException { + const message = { ...baseResponseException } as ResponseException; + if (object.error !== undefined && object.error !== null) { + message.error = String(object.error); + } else { + message.error = ""; + } + return message; + }, + + toJSON(message: ResponseException): unknown { + const obj: any = {}; + message.error !== undefined && (obj.error = message.error); + return obj; + }, + + fromPartial(object: DeepPartial): ResponseException { + const message = { ...baseResponseException } as ResponseException; + if (object.error !== undefined && object.error !== null) { + message.error = object.error; + } else { + message.error = ""; + } + return message; + }, +}; + +const baseResponseEcho: object = { message: "" }; + +export const ResponseEcho = { + encode(message: ResponseEcho, writer: Writer = Writer.create()): Writer { + if (message.message !== "") { + writer.uint32(10).string(message.message); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ResponseEcho { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseResponseEcho } as ResponseEcho; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.message = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ResponseEcho { + const message = { ...baseResponseEcho } as ResponseEcho; + if (object.message !== undefined && object.message !== null) { + message.message = String(object.message); + } else { + message.message = ""; + } + return message; + }, + + toJSON(message: ResponseEcho): unknown { + const obj: any = {}; + message.message !== undefined && (obj.message = message.message); + return obj; + }, + + fromPartial(object: DeepPartial): ResponseEcho { + const message = { ...baseResponseEcho } as ResponseEcho; + if (object.message !== undefined && object.message !== null) { + message.message = object.message; + } else { + message.message = ""; + } + return message; + }, +}; + +const baseResponseFlush: object = {}; + +export const ResponseFlush = { + encode(_: ResponseFlush, writer: Writer = Writer.create()): Writer { + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ResponseFlush { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseResponseFlush } as ResponseFlush; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): ResponseFlush { + const message = { ...baseResponseFlush } as ResponseFlush; + return message; + }, + + toJSON(_: ResponseFlush): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial(_: DeepPartial): ResponseFlush { + const message = { ...baseResponseFlush } as ResponseFlush; + return message; + }, +}; + +const baseResponseInfo: object = { + data: "", + version: "", + appVersion: 0, + lastBlockHeight: 0, +}; + +export const ResponseInfo = { + encode(message: ResponseInfo, writer: Writer = Writer.create()): Writer { + if (message.data !== "") { + writer.uint32(10).string(message.data); + } + if (message.version !== "") { + writer.uint32(18).string(message.version); + } + if (message.appVersion !== 0) { + writer.uint32(24).uint64(message.appVersion); + } + if (message.lastBlockHeight !== 0) { + writer.uint32(32).int64(message.lastBlockHeight); + } + if (message.lastBlockAppHash.length !== 0) { + writer.uint32(42).bytes(message.lastBlockAppHash); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ResponseInfo { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseResponseInfo } as ResponseInfo; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.data = reader.string(); + break; + case 2: + message.version = reader.string(); + break; + case 3: + message.appVersion = longToNumber(reader.uint64() as Long); + break; + case 4: + message.lastBlockHeight = longToNumber(reader.int64() as Long); + break; + case 5: + message.lastBlockAppHash = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ResponseInfo { + const message = { ...baseResponseInfo } as ResponseInfo; + if (object.data !== undefined && object.data !== null) { + message.data = String(object.data); + } else { + message.data = ""; + } + if (object.version !== undefined && object.version !== null) { + message.version = String(object.version); + } else { + message.version = ""; + } + if (object.appVersion !== undefined && object.appVersion !== null) { + message.appVersion = Number(object.appVersion); + } else { + message.appVersion = 0; + } + if ( + object.lastBlockHeight !== undefined && + object.lastBlockHeight !== null + ) { + message.lastBlockHeight = Number(object.lastBlockHeight); + } else { + message.lastBlockHeight = 0; + } + if ( + object.lastBlockAppHash !== undefined && + object.lastBlockAppHash !== null + ) { + message.lastBlockAppHash = bytesFromBase64(object.lastBlockAppHash); + } + return message; + }, + + toJSON(message: ResponseInfo): unknown { + const obj: any = {}; + message.data !== undefined && (obj.data = message.data); + message.version !== undefined && (obj.version = message.version); + message.appVersion !== undefined && (obj.appVersion = message.appVersion); + message.lastBlockHeight !== undefined && + (obj.lastBlockHeight = message.lastBlockHeight); + message.lastBlockAppHash !== undefined && + (obj.lastBlockAppHash = base64FromBytes( + message.lastBlockAppHash !== undefined + ? message.lastBlockAppHash + : new Uint8Array() + )); + return obj; + }, + + fromPartial(object: DeepPartial): ResponseInfo { + const message = { ...baseResponseInfo } as ResponseInfo; + if (object.data !== undefined && object.data !== null) { + message.data = object.data; + } else { + message.data = ""; + } + if (object.version !== undefined && object.version !== null) { + message.version = object.version; + } else { + message.version = ""; + } + if (object.appVersion !== undefined && object.appVersion !== null) { + message.appVersion = object.appVersion; + } else { + message.appVersion = 0; + } + if ( + object.lastBlockHeight !== undefined && + object.lastBlockHeight !== null + ) { + message.lastBlockHeight = object.lastBlockHeight; + } else { + message.lastBlockHeight = 0; + } + if ( + object.lastBlockAppHash !== undefined && + object.lastBlockAppHash !== null + ) { + message.lastBlockAppHash = object.lastBlockAppHash; + } else { + message.lastBlockAppHash = new Uint8Array(); + } + return message; + }, +}; + +const baseResponseSetOption: object = { code: 0, log: "", info: "" }; + +export const ResponseSetOption = { + encode(message: ResponseSetOption, writer: Writer = Writer.create()): Writer { + if (message.code !== 0) { + writer.uint32(8).uint32(message.code); + } + if (message.log !== "") { + writer.uint32(26).string(message.log); + } + if (message.info !== "") { + writer.uint32(34).string(message.info); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ResponseSetOption { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseResponseSetOption } as ResponseSetOption; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.code = reader.uint32(); + break; + case 3: + message.log = reader.string(); + break; + case 4: + message.info = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ResponseSetOption { + const message = { ...baseResponseSetOption } as ResponseSetOption; + if (object.code !== undefined && object.code !== null) { + message.code = Number(object.code); + } else { + message.code = 0; + } + if (object.log !== undefined && object.log !== null) { + message.log = String(object.log); + } else { + message.log = ""; + } + if (object.info !== undefined && object.info !== null) { + message.info = String(object.info); + } else { + message.info = ""; + } + return message; + }, + + toJSON(message: ResponseSetOption): unknown { + const obj: any = {}; + message.code !== undefined && (obj.code = message.code); + message.log !== undefined && (obj.log = message.log); + message.info !== undefined && (obj.info = message.info); + return obj; + }, + + fromPartial(object: DeepPartial): ResponseSetOption { + const message = { ...baseResponseSetOption } as ResponseSetOption; + if (object.code !== undefined && object.code !== null) { + message.code = object.code; + } else { + message.code = 0; + } + if (object.log !== undefined && object.log !== null) { + message.log = object.log; + } else { + message.log = ""; + } + if (object.info !== undefined && object.info !== null) { + message.info = object.info; + } else { + message.info = ""; + } + return message; + }, +}; + +const baseResponseInitChain: object = {}; + +export const ResponseInitChain = { + encode(message: ResponseInitChain, writer: Writer = Writer.create()): Writer { + if (message.consensusParams !== undefined) { + ConsensusParams.encode( + message.consensusParams, + writer.uint32(10).fork() + ).ldelim(); + } + for (const v of message.validators) { + ValidatorUpdate.encode(v!, writer.uint32(18).fork()).ldelim(); + } + if (message.appHash.length !== 0) { + writer.uint32(26).bytes(message.appHash); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ResponseInitChain { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseResponseInitChain } as ResponseInitChain; + message.validators = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.consensusParams = ConsensusParams.decode( + reader, + reader.uint32() + ); + break; + case 2: + message.validators.push( + ValidatorUpdate.decode(reader, reader.uint32()) + ); + break; + case 3: + message.appHash = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ResponseInitChain { + const message = { ...baseResponseInitChain } as ResponseInitChain; + message.validators = []; + if ( + object.consensusParams !== undefined && + object.consensusParams !== null + ) { + message.consensusParams = ConsensusParams.fromJSON( + object.consensusParams + ); + } else { + message.consensusParams = undefined; + } + if (object.validators !== undefined && object.validators !== null) { + for (const e of object.validators) { + message.validators.push(ValidatorUpdate.fromJSON(e)); + } + } + if (object.appHash !== undefined && object.appHash !== null) { + message.appHash = bytesFromBase64(object.appHash); + } + return message; + }, + + toJSON(message: ResponseInitChain): unknown { + const obj: any = {}; + message.consensusParams !== undefined && + (obj.consensusParams = message.consensusParams + ? ConsensusParams.toJSON(message.consensusParams) + : undefined); + if (message.validators) { + obj.validators = message.validators.map((e) => + e ? ValidatorUpdate.toJSON(e) : undefined + ); + } else { + obj.validators = []; + } + message.appHash !== undefined && + (obj.appHash = base64FromBytes( + message.appHash !== undefined ? message.appHash : new Uint8Array() + )); + return obj; + }, + + fromPartial(object: DeepPartial): ResponseInitChain { + const message = { ...baseResponseInitChain } as ResponseInitChain; + message.validators = []; + if ( + object.consensusParams !== undefined && + object.consensusParams !== null + ) { + message.consensusParams = ConsensusParams.fromPartial( + object.consensusParams + ); + } else { + message.consensusParams = undefined; + } + if (object.validators !== undefined && object.validators !== null) { + for (const e of object.validators) { + message.validators.push(ValidatorUpdate.fromPartial(e)); + } + } + if (object.appHash !== undefined && object.appHash !== null) { + message.appHash = object.appHash; + } else { + message.appHash = new Uint8Array(); + } + return message; + }, +}; + +const baseResponseQuery: object = { + code: 0, + log: "", + info: "", + index: 0, + height: 0, + codespace: "", +}; + +export const ResponseQuery = { + encode(message: ResponseQuery, writer: Writer = Writer.create()): Writer { + if (message.code !== 0) { + writer.uint32(8).uint32(message.code); + } + if (message.log !== "") { + writer.uint32(26).string(message.log); + } + if (message.info !== "") { + writer.uint32(34).string(message.info); + } + if (message.index !== 0) { + writer.uint32(40).int64(message.index); + } + if (message.key.length !== 0) { + writer.uint32(50).bytes(message.key); + } + if (message.value.length !== 0) { + writer.uint32(58).bytes(message.value); + } + if (message.proofOps !== undefined) { + ProofOps.encode(message.proofOps, writer.uint32(66).fork()).ldelim(); + } + if (message.height !== 0) { + writer.uint32(72).int64(message.height); + } + if (message.codespace !== "") { + writer.uint32(82).string(message.codespace); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ResponseQuery { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseResponseQuery } as ResponseQuery; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.code = reader.uint32(); + break; + case 3: + message.log = reader.string(); + break; + case 4: + message.info = reader.string(); + break; + case 5: + message.index = longToNumber(reader.int64() as Long); + break; + case 6: + message.key = reader.bytes(); + break; + case 7: + message.value = reader.bytes(); + break; + case 8: + message.proofOps = ProofOps.decode(reader, reader.uint32()); + break; + case 9: + message.height = longToNumber(reader.int64() as Long); + break; + case 10: + message.codespace = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ResponseQuery { + const message = { ...baseResponseQuery } as ResponseQuery; + if (object.code !== undefined && object.code !== null) { + message.code = Number(object.code); + } else { + message.code = 0; + } + if (object.log !== undefined && object.log !== null) { + message.log = String(object.log); + } else { + message.log = ""; + } + if (object.info !== undefined && object.info !== null) { + message.info = String(object.info); + } else { + message.info = ""; + } + if (object.index !== undefined && object.index !== null) { + message.index = Number(object.index); + } else { + message.index = 0; + } + if (object.key !== undefined && object.key !== null) { + message.key = bytesFromBase64(object.key); + } + if (object.value !== undefined && object.value !== null) { + message.value = bytesFromBase64(object.value); + } + if (object.proofOps !== undefined && object.proofOps !== null) { + message.proofOps = ProofOps.fromJSON(object.proofOps); + } else { + message.proofOps = undefined; + } + if (object.height !== undefined && object.height !== null) { + message.height = Number(object.height); + } else { + message.height = 0; + } + if (object.codespace !== undefined && object.codespace !== null) { + message.codespace = String(object.codespace); + } else { + message.codespace = ""; + } + return message; + }, + + toJSON(message: ResponseQuery): unknown { + const obj: any = {}; + message.code !== undefined && (obj.code = message.code); + message.log !== undefined && (obj.log = message.log); + message.info !== undefined && (obj.info = message.info); + message.index !== undefined && (obj.index = message.index); + message.key !== undefined && + (obj.key = base64FromBytes( + message.key !== undefined ? message.key : new Uint8Array() + )); + message.value !== undefined && + (obj.value = base64FromBytes( + message.value !== undefined ? message.value : new Uint8Array() + )); + message.proofOps !== undefined && + (obj.proofOps = message.proofOps + ? ProofOps.toJSON(message.proofOps) + : undefined); + message.height !== undefined && (obj.height = message.height); + message.codespace !== undefined && (obj.codespace = message.codespace); + return obj; + }, + + fromPartial(object: DeepPartial): ResponseQuery { + const message = { ...baseResponseQuery } as ResponseQuery; + if (object.code !== undefined && object.code !== null) { + message.code = object.code; + } else { + message.code = 0; + } + if (object.log !== undefined && object.log !== null) { + message.log = object.log; + } else { + message.log = ""; + } + if (object.info !== undefined && object.info !== null) { + message.info = object.info; + } else { + message.info = ""; + } + if (object.index !== undefined && object.index !== null) { + message.index = object.index; + } else { + message.index = 0; + } + if (object.key !== undefined && object.key !== null) { + message.key = object.key; + } else { + message.key = new Uint8Array(); + } + if (object.value !== undefined && object.value !== null) { + message.value = object.value; + } else { + message.value = new Uint8Array(); + } + if (object.proofOps !== undefined && object.proofOps !== null) { + message.proofOps = ProofOps.fromPartial(object.proofOps); + } else { + message.proofOps = undefined; + } + if (object.height !== undefined && object.height !== null) { + message.height = object.height; + } else { + message.height = 0; + } + if (object.codespace !== undefined && object.codespace !== null) { + message.codespace = object.codespace; + } else { + message.codespace = ""; + } + return message; + }, +}; + +const baseResponseBeginBlock: object = {}; + +export const ResponseBeginBlock = { + encode( + message: ResponseBeginBlock, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.events) { + Event.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ResponseBeginBlock { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseResponseBeginBlock } as ResponseBeginBlock; + message.events = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.events.push(Event.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ResponseBeginBlock { + const message = { ...baseResponseBeginBlock } as ResponseBeginBlock; + message.events = []; + if (object.events !== undefined && object.events !== null) { + for (const e of object.events) { + message.events.push(Event.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: ResponseBeginBlock): unknown { + const obj: any = {}; + if (message.events) { + obj.events = message.events.map((e) => (e ? Event.toJSON(e) : undefined)); + } else { + obj.events = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): ResponseBeginBlock { + const message = { ...baseResponseBeginBlock } as ResponseBeginBlock; + message.events = []; + if (object.events !== undefined && object.events !== null) { + for (const e of object.events) { + message.events.push(Event.fromPartial(e)); + } + } + return message; + }, +}; + +const baseResponseCheckTx: object = { + code: 0, + log: "", + info: "", + gasWanted: 0, + gasUsed: 0, + codespace: "", + sender: "", + priority: 0, + mempoolError: "", +}; + +export const ResponseCheckTx = { + encode(message: ResponseCheckTx, writer: Writer = Writer.create()): Writer { + if (message.code !== 0) { + writer.uint32(8).uint32(message.code); + } + if (message.data.length !== 0) { + writer.uint32(18).bytes(message.data); + } + if (message.log !== "") { + writer.uint32(26).string(message.log); + } + if (message.info !== "") { + writer.uint32(34).string(message.info); + } + if (message.gasWanted !== 0) { + writer.uint32(40).int64(message.gasWanted); + } + if (message.gasUsed !== 0) { + writer.uint32(48).int64(message.gasUsed); + } + for (const v of message.events) { + Event.encode(v!, writer.uint32(58).fork()).ldelim(); + } + if (message.codespace !== "") { + writer.uint32(66).string(message.codespace); + } + if (message.sender !== "") { + writer.uint32(74).string(message.sender); + } + if (message.priority !== 0) { + writer.uint32(80).int64(message.priority); + } + if (message.mempoolError !== "") { + writer.uint32(90).string(message.mempoolError); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ResponseCheckTx { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseResponseCheckTx } as ResponseCheckTx; + message.events = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.code = reader.uint32(); + break; + case 2: + message.data = reader.bytes(); + break; + case 3: + message.log = reader.string(); + break; + case 4: + message.info = reader.string(); + break; + case 5: + message.gasWanted = longToNumber(reader.int64() as Long); + break; + case 6: + message.gasUsed = longToNumber(reader.int64() as Long); + break; + case 7: + message.events.push(Event.decode(reader, reader.uint32())); + break; + case 8: + message.codespace = reader.string(); + break; + case 9: + message.sender = reader.string(); + break; + case 10: + message.priority = longToNumber(reader.int64() as Long); + break; + case 11: + message.mempoolError = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ResponseCheckTx { + const message = { ...baseResponseCheckTx } as ResponseCheckTx; + message.events = []; + if (object.code !== undefined && object.code !== null) { + message.code = Number(object.code); + } else { + message.code = 0; + } + if (object.data !== undefined && object.data !== null) { + message.data = bytesFromBase64(object.data); + } + if (object.log !== undefined && object.log !== null) { + message.log = String(object.log); + } else { + message.log = ""; + } + if (object.info !== undefined && object.info !== null) { + message.info = String(object.info); + } else { + message.info = ""; + } + if (object.gasWanted !== undefined && object.gasWanted !== null) { + message.gasWanted = Number(object.gasWanted); + } else { + message.gasWanted = 0; + } + if (object.gasUsed !== undefined && object.gasUsed !== null) { + message.gasUsed = Number(object.gasUsed); + } else { + message.gasUsed = 0; + } + if (object.events !== undefined && object.events !== null) { + for (const e of object.events) { + message.events.push(Event.fromJSON(e)); + } + } + if (object.codespace !== undefined && object.codespace !== null) { + message.codespace = String(object.codespace); + } else { + message.codespace = ""; + } + if (object.sender !== undefined && object.sender !== null) { + message.sender = String(object.sender); + } else { + message.sender = ""; + } + if (object.priority !== undefined && object.priority !== null) { + message.priority = Number(object.priority); + } else { + message.priority = 0; + } + if (object.mempoolError !== undefined && object.mempoolError !== null) { + message.mempoolError = String(object.mempoolError); + } else { + message.mempoolError = ""; + } + return message; + }, + + toJSON(message: ResponseCheckTx): unknown { + const obj: any = {}; + message.code !== undefined && (obj.code = message.code); + message.data !== undefined && + (obj.data = base64FromBytes( + message.data !== undefined ? message.data : new Uint8Array() + )); + message.log !== undefined && (obj.log = message.log); + message.info !== undefined && (obj.info = message.info); + message.gasWanted !== undefined && (obj.gasWanted = message.gasWanted); + message.gasUsed !== undefined && (obj.gasUsed = message.gasUsed); + if (message.events) { + obj.events = message.events.map((e) => (e ? Event.toJSON(e) : undefined)); + } else { + obj.events = []; + } + message.codespace !== undefined && (obj.codespace = message.codespace); + message.sender !== undefined && (obj.sender = message.sender); + message.priority !== undefined && (obj.priority = message.priority); + message.mempoolError !== undefined && + (obj.mempoolError = message.mempoolError); + return obj; + }, + + fromPartial(object: DeepPartial): ResponseCheckTx { + const message = { ...baseResponseCheckTx } as ResponseCheckTx; + message.events = []; + if (object.code !== undefined && object.code !== null) { + message.code = object.code; + } else { + message.code = 0; + } + if (object.data !== undefined && object.data !== null) { + message.data = object.data; + } else { + message.data = new Uint8Array(); + } + if (object.log !== undefined && object.log !== null) { + message.log = object.log; + } else { + message.log = ""; + } + if (object.info !== undefined && object.info !== null) { + message.info = object.info; + } else { + message.info = ""; + } + if (object.gasWanted !== undefined && object.gasWanted !== null) { + message.gasWanted = object.gasWanted; + } else { + message.gasWanted = 0; + } + if (object.gasUsed !== undefined && object.gasUsed !== null) { + message.gasUsed = object.gasUsed; + } else { + message.gasUsed = 0; + } + if (object.events !== undefined && object.events !== null) { + for (const e of object.events) { + message.events.push(Event.fromPartial(e)); + } + } + if (object.codespace !== undefined && object.codespace !== null) { + message.codespace = object.codespace; + } else { + message.codespace = ""; + } + if (object.sender !== undefined && object.sender !== null) { + message.sender = object.sender; + } else { + message.sender = ""; + } + if (object.priority !== undefined && object.priority !== null) { + message.priority = object.priority; + } else { + message.priority = 0; + } + if (object.mempoolError !== undefined && object.mempoolError !== null) { + message.mempoolError = object.mempoolError; + } else { + message.mempoolError = ""; + } + return message; + }, +}; + +const baseResponseDeliverTx: object = { + code: 0, + log: "", + info: "", + gasWanted: 0, + gasUsed: 0, + codespace: "", +}; + +export const ResponseDeliverTx = { + encode(message: ResponseDeliverTx, writer: Writer = Writer.create()): Writer { + if (message.code !== 0) { + writer.uint32(8).uint32(message.code); + } + if (message.data.length !== 0) { + writer.uint32(18).bytes(message.data); + } + if (message.log !== "") { + writer.uint32(26).string(message.log); + } + if (message.info !== "") { + writer.uint32(34).string(message.info); + } + if (message.gasWanted !== 0) { + writer.uint32(40).int64(message.gasWanted); + } + if (message.gasUsed !== 0) { + writer.uint32(48).int64(message.gasUsed); + } + for (const v of message.events) { + Event.encode(v!, writer.uint32(58).fork()).ldelim(); + } + if (message.codespace !== "") { + writer.uint32(66).string(message.codespace); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ResponseDeliverTx { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseResponseDeliverTx } as ResponseDeliverTx; + message.events = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.code = reader.uint32(); + break; + case 2: + message.data = reader.bytes(); + break; + case 3: + message.log = reader.string(); + break; + case 4: + message.info = reader.string(); + break; + case 5: + message.gasWanted = longToNumber(reader.int64() as Long); + break; + case 6: + message.gasUsed = longToNumber(reader.int64() as Long); + break; + case 7: + message.events.push(Event.decode(reader, reader.uint32())); + break; + case 8: + message.codespace = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ResponseDeliverTx { + const message = { ...baseResponseDeliverTx } as ResponseDeliverTx; + message.events = []; + if (object.code !== undefined && object.code !== null) { + message.code = Number(object.code); + } else { + message.code = 0; + } + if (object.data !== undefined && object.data !== null) { + message.data = bytesFromBase64(object.data); + } + if (object.log !== undefined && object.log !== null) { + message.log = String(object.log); + } else { + message.log = ""; + } + if (object.info !== undefined && object.info !== null) { + message.info = String(object.info); + } else { + message.info = ""; + } + if (object.gasWanted !== undefined && object.gasWanted !== null) { + message.gasWanted = Number(object.gasWanted); + } else { + message.gasWanted = 0; + } + if (object.gasUsed !== undefined && object.gasUsed !== null) { + message.gasUsed = Number(object.gasUsed); + } else { + message.gasUsed = 0; + } + if (object.events !== undefined && object.events !== null) { + for (const e of object.events) { + message.events.push(Event.fromJSON(e)); + } + } + if (object.codespace !== undefined && object.codespace !== null) { + message.codespace = String(object.codespace); + } else { + message.codespace = ""; + } + return message; + }, + + toJSON(message: ResponseDeliverTx): unknown { + const obj: any = {}; + message.code !== undefined && (obj.code = message.code); + message.data !== undefined && + (obj.data = base64FromBytes( + message.data !== undefined ? message.data : new Uint8Array() + )); + message.log !== undefined && (obj.log = message.log); + message.info !== undefined && (obj.info = message.info); + message.gasWanted !== undefined && (obj.gasWanted = message.gasWanted); + message.gasUsed !== undefined && (obj.gasUsed = message.gasUsed); + if (message.events) { + obj.events = message.events.map((e) => (e ? Event.toJSON(e) : undefined)); + } else { + obj.events = []; + } + message.codespace !== undefined && (obj.codespace = message.codespace); + return obj; + }, + + fromPartial(object: DeepPartial): ResponseDeliverTx { + const message = { ...baseResponseDeliverTx } as ResponseDeliverTx; + message.events = []; + if (object.code !== undefined && object.code !== null) { + message.code = object.code; + } else { + message.code = 0; + } + if (object.data !== undefined && object.data !== null) { + message.data = object.data; + } else { + message.data = new Uint8Array(); + } + if (object.log !== undefined && object.log !== null) { + message.log = object.log; + } else { + message.log = ""; + } + if (object.info !== undefined && object.info !== null) { + message.info = object.info; + } else { + message.info = ""; + } + if (object.gasWanted !== undefined && object.gasWanted !== null) { + message.gasWanted = object.gasWanted; + } else { + message.gasWanted = 0; + } + if (object.gasUsed !== undefined && object.gasUsed !== null) { + message.gasUsed = object.gasUsed; + } else { + message.gasUsed = 0; + } + if (object.events !== undefined && object.events !== null) { + for (const e of object.events) { + message.events.push(Event.fromPartial(e)); + } + } + if (object.codespace !== undefined && object.codespace !== null) { + message.codespace = object.codespace; + } else { + message.codespace = ""; + } + return message; + }, +}; + +const baseResponseEndBlock: object = {}; + +export const ResponseEndBlock = { + encode(message: ResponseEndBlock, writer: Writer = Writer.create()): Writer { + for (const v of message.validatorUpdates) { + ValidatorUpdate.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.consensusParamUpdates !== undefined) { + ConsensusParams.encode( + message.consensusParamUpdates, + writer.uint32(18).fork() + ).ldelim(); + } + for (const v of message.events) { + Event.encode(v!, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ResponseEndBlock { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseResponseEndBlock } as ResponseEndBlock; + message.validatorUpdates = []; + message.events = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.validatorUpdates.push( + ValidatorUpdate.decode(reader, reader.uint32()) + ); + break; + case 2: + message.consensusParamUpdates = ConsensusParams.decode( + reader, + reader.uint32() + ); + break; + case 3: + message.events.push(Event.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ResponseEndBlock { + const message = { ...baseResponseEndBlock } as ResponseEndBlock; + message.validatorUpdates = []; + message.events = []; + if ( + object.validatorUpdates !== undefined && + object.validatorUpdates !== null + ) { + for (const e of object.validatorUpdates) { + message.validatorUpdates.push(ValidatorUpdate.fromJSON(e)); + } + } + if ( + object.consensusParamUpdates !== undefined && + object.consensusParamUpdates !== null + ) { + message.consensusParamUpdates = ConsensusParams.fromJSON( + object.consensusParamUpdates + ); + } else { + message.consensusParamUpdates = undefined; + } + if (object.events !== undefined && object.events !== null) { + for (const e of object.events) { + message.events.push(Event.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: ResponseEndBlock): unknown { + const obj: any = {}; + if (message.validatorUpdates) { + obj.validatorUpdates = message.validatorUpdates.map((e) => + e ? ValidatorUpdate.toJSON(e) : undefined + ); + } else { + obj.validatorUpdates = []; + } + message.consensusParamUpdates !== undefined && + (obj.consensusParamUpdates = message.consensusParamUpdates + ? ConsensusParams.toJSON(message.consensusParamUpdates) + : undefined); + if (message.events) { + obj.events = message.events.map((e) => (e ? Event.toJSON(e) : undefined)); + } else { + obj.events = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): ResponseEndBlock { + const message = { ...baseResponseEndBlock } as ResponseEndBlock; + message.validatorUpdates = []; + message.events = []; + if ( + object.validatorUpdates !== undefined && + object.validatorUpdates !== null + ) { + for (const e of object.validatorUpdates) { + message.validatorUpdates.push(ValidatorUpdate.fromPartial(e)); + } + } + if ( + object.consensusParamUpdates !== undefined && + object.consensusParamUpdates !== null + ) { + message.consensusParamUpdates = ConsensusParams.fromPartial( + object.consensusParamUpdates + ); + } else { + message.consensusParamUpdates = undefined; + } + if (object.events !== undefined && object.events !== null) { + for (const e of object.events) { + message.events.push(Event.fromPartial(e)); + } + } + return message; + }, +}; + +const baseResponseCommit: object = { retainHeight: 0 }; + +export const ResponseCommit = { + encode(message: ResponseCommit, writer: Writer = Writer.create()): Writer { + if (message.data.length !== 0) { + writer.uint32(18).bytes(message.data); + } + if (message.retainHeight !== 0) { + writer.uint32(24).int64(message.retainHeight); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ResponseCommit { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseResponseCommit } as ResponseCommit; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + message.data = reader.bytes(); + break; + case 3: + message.retainHeight = longToNumber(reader.int64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ResponseCommit { + const message = { ...baseResponseCommit } as ResponseCommit; + if (object.data !== undefined && object.data !== null) { + message.data = bytesFromBase64(object.data); + } + if (object.retainHeight !== undefined && object.retainHeight !== null) { + message.retainHeight = Number(object.retainHeight); + } else { + message.retainHeight = 0; + } + return message; + }, + + toJSON(message: ResponseCommit): unknown { + const obj: any = {}; + message.data !== undefined && + (obj.data = base64FromBytes( + message.data !== undefined ? message.data : new Uint8Array() + )); + message.retainHeight !== undefined && + (obj.retainHeight = message.retainHeight); + return obj; + }, + + fromPartial(object: DeepPartial): ResponseCommit { + const message = { ...baseResponseCommit } as ResponseCommit; + if (object.data !== undefined && object.data !== null) { + message.data = object.data; + } else { + message.data = new Uint8Array(); + } + if (object.retainHeight !== undefined && object.retainHeight !== null) { + message.retainHeight = object.retainHeight; + } else { + message.retainHeight = 0; + } + return message; + }, +}; + +const baseResponseListSnapshots: object = {}; + +export const ResponseListSnapshots = { + encode( + message: ResponseListSnapshots, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.snapshots) { + Snapshot.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ResponseListSnapshots { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseResponseListSnapshots } as ResponseListSnapshots; + message.snapshots = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.snapshots.push(Snapshot.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ResponseListSnapshots { + const message = { ...baseResponseListSnapshots } as ResponseListSnapshots; + message.snapshots = []; + if (object.snapshots !== undefined && object.snapshots !== null) { + for (const e of object.snapshots) { + message.snapshots.push(Snapshot.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: ResponseListSnapshots): unknown { + const obj: any = {}; + if (message.snapshots) { + obj.snapshots = message.snapshots.map((e) => + e ? Snapshot.toJSON(e) : undefined + ); + } else { + obj.snapshots = []; + } + return obj; + }, + + fromPartial( + object: DeepPartial + ): ResponseListSnapshots { + const message = { ...baseResponseListSnapshots } as ResponseListSnapshots; + message.snapshots = []; + if (object.snapshots !== undefined && object.snapshots !== null) { + for (const e of object.snapshots) { + message.snapshots.push(Snapshot.fromPartial(e)); + } + } + return message; + }, +}; + +const baseResponseOfferSnapshot: object = { result: 0 }; + +export const ResponseOfferSnapshot = { + encode( + message: ResponseOfferSnapshot, + writer: Writer = Writer.create() + ): Writer { + if (message.result !== 0) { + writer.uint32(8).int32(message.result); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ResponseOfferSnapshot { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseResponseOfferSnapshot } as ResponseOfferSnapshot; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.result = reader.int32() as any; + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ResponseOfferSnapshot { + const message = { ...baseResponseOfferSnapshot } as ResponseOfferSnapshot; + if (object.result !== undefined && object.result !== null) { + message.result = responseOfferSnapshot_ResultFromJSON(object.result); + } else { + message.result = 0; + } + return message; + }, + + toJSON(message: ResponseOfferSnapshot): unknown { + const obj: any = {}; + message.result !== undefined && + (obj.result = responseOfferSnapshot_ResultToJSON(message.result)); + return obj; + }, + + fromPartial( + object: DeepPartial + ): ResponseOfferSnapshot { + const message = { ...baseResponseOfferSnapshot } as ResponseOfferSnapshot; + if (object.result !== undefined && object.result !== null) { + message.result = object.result; + } else { + message.result = 0; + } + return message; + }, +}; + +const baseResponseLoadSnapshotChunk: object = {}; + +export const ResponseLoadSnapshotChunk = { + encode( + message: ResponseLoadSnapshotChunk, + writer: Writer = Writer.create() + ): Writer { + if (message.chunk.length !== 0) { + writer.uint32(10).bytes(message.chunk); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): ResponseLoadSnapshotChunk { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseResponseLoadSnapshotChunk, + } as ResponseLoadSnapshotChunk; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.chunk = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ResponseLoadSnapshotChunk { + const message = { + ...baseResponseLoadSnapshotChunk, + } as ResponseLoadSnapshotChunk; + if (object.chunk !== undefined && object.chunk !== null) { + message.chunk = bytesFromBase64(object.chunk); + } + return message; + }, + + toJSON(message: ResponseLoadSnapshotChunk): unknown { + const obj: any = {}; + message.chunk !== undefined && + (obj.chunk = base64FromBytes( + message.chunk !== undefined ? message.chunk : new Uint8Array() + )); + return obj; + }, + + fromPartial( + object: DeepPartial + ): ResponseLoadSnapshotChunk { + const message = { + ...baseResponseLoadSnapshotChunk, + } as ResponseLoadSnapshotChunk; + if (object.chunk !== undefined && object.chunk !== null) { + message.chunk = object.chunk; + } else { + message.chunk = new Uint8Array(); + } + return message; + }, +}; + +const baseResponseApplySnapshotChunk: object = { + result: 0, + refetchChunks: 0, + rejectSenders: "", +}; + +export const ResponseApplySnapshotChunk = { + encode( + message: ResponseApplySnapshotChunk, + writer: Writer = Writer.create() + ): Writer { + if (message.result !== 0) { + writer.uint32(8).int32(message.result); + } + writer.uint32(18).fork(); + for (const v of message.refetchChunks) { + writer.uint32(v); + } + writer.ldelim(); + for (const v of message.rejectSenders) { + writer.uint32(26).string(v!); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): ResponseApplySnapshotChunk { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseResponseApplySnapshotChunk, + } as ResponseApplySnapshotChunk; + message.refetchChunks = []; + message.rejectSenders = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.result = reader.int32() as any; + break; + case 2: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.refetchChunks.push(reader.uint32()); + } + } else { + message.refetchChunks.push(reader.uint32()); + } + break; + case 3: + message.rejectSenders.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ResponseApplySnapshotChunk { + const message = { + ...baseResponseApplySnapshotChunk, + } as ResponseApplySnapshotChunk; + message.refetchChunks = []; + message.rejectSenders = []; + if (object.result !== undefined && object.result !== null) { + message.result = responseApplySnapshotChunk_ResultFromJSON(object.result); + } else { + message.result = 0; + } + if (object.refetchChunks !== undefined && object.refetchChunks !== null) { + for (const e of object.refetchChunks) { + message.refetchChunks.push(Number(e)); + } + } + if (object.rejectSenders !== undefined && object.rejectSenders !== null) { + for (const e of object.rejectSenders) { + message.rejectSenders.push(String(e)); + } + } + return message; + }, + + toJSON(message: ResponseApplySnapshotChunk): unknown { + const obj: any = {}; + message.result !== undefined && + (obj.result = responseApplySnapshotChunk_ResultToJSON(message.result)); + if (message.refetchChunks) { + obj.refetchChunks = message.refetchChunks.map((e) => e); + } else { + obj.refetchChunks = []; + } + if (message.rejectSenders) { + obj.rejectSenders = message.rejectSenders.map((e) => e); + } else { + obj.rejectSenders = []; + } + return obj; + }, + + fromPartial( + object: DeepPartial + ): ResponseApplySnapshotChunk { + const message = { + ...baseResponseApplySnapshotChunk, + } as ResponseApplySnapshotChunk; + message.refetchChunks = []; + message.rejectSenders = []; + if (object.result !== undefined && object.result !== null) { + message.result = object.result; + } else { + message.result = 0; + } + if (object.refetchChunks !== undefined && object.refetchChunks !== null) { + for (const e of object.refetchChunks) { + message.refetchChunks.push(e); + } + } + if (object.rejectSenders !== undefined && object.rejectSenders !== null) { + for (const e of object.rejectSenders) { + message.rejectSenders.push(e); + } + } + return message; + }, +}; + +const baseConsensusParams: object = {}; + +export const ConsensusParams = { + encode(message: ConsensusParams, writer: Writer = Writer.create()): Writer { + if (message.block !== undefined) { + BlockParams.encode(message.block, writer.uint32(10).fork()).ldelim(); + } + if (message.evidence !== undefined) { + EvidenceParams.encode( + message.evidence, + writer.uint32(18).fork() + ).ldelim(); + } + if (message.validator !== undefined) { + ValidatorParams.encode( + message.validator, + writer.uint32(26).fork() + ).ldelim(); + } + if (message.version !== undefined) { + VersionParams.encode(message.version, writer.uint32(34).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ConsensusParams { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseConsensusParams } as ConsensusParams; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.block = BlockParams.decode(reader, reader.uint32()); + break; + case 2: + message.evidence = EvidenceParams.decode(reader, reader.uint32()); + break; + case 3: + message.validator = ValidatorParams.decode(reader, reader.uint32()); + break; + case 4: + message.version = VersionParams.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ConsensusParams { + const message = { ...baseConsensusParams } as ConsensusParams; + if (object.block !== undefined && object.block !== null) { + message.block = BlockParams.fromJSON(object.block); + } else { + message.block = undefined; + } + if (object.evidence !== undefined && object.evidence !== null) { + message.evidence = EvidenceParams.fromJSON(object.evidence); + } else { + message.evidence = undefined; + } + if (object.validator !== undefined && object.validator !== null) { + message.validator = ValidatorParams.fromJSON(object.validator); + } else { + message.validator = undefined; + } + if (object.version !== undefined && object.version !== null) { + message.version = VersionParams.fromJSON(object.version); + } else { + message.version = undefined; + } + return message; + }, + + toJSON(message: ConsensusParams): unknown { + const obj: any = {}; + message.block !== undefined && + (obj.block = message.block + ? BlockParams.toJSON(message.block) + : undefined); + message.evidence !== undefined && + (obj.evidence = message.evidence + ? EvidenceParams.toJSON(message.evidence) + : undefined); + message.validator !== undefined && + (obj.validator = message.validator + ? ValidatorParams.toJSON(message.validator) + : undefined); + message.version !== undefined && + (obj.version = message.version + ? VersionParams.toJSON(message.version) + : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): ConsensusParams { + const message = { ...baseConsensusParams } as ConsensusParams; + if (object.block !== undefined && object.block !== null) { + message.block = BlockParams.fromPartial(object.block); + } else { + message.block = undefined; + } + if (object.evidence !== undefined && object.evidence !== null) { + message.evidence = EvidenceParams.fromPartial(object.evidence); + } else { + message.evidence = undefined; + } + if (object.validator !== undefined && object.validator !== null) { + message.validator = ValidatorParams.fromPartial(object.validator); + } else { + message.validator = undefined; + } + if (object.version !== undefined && object.version !== null) { + message.version = VersionParams.fromPartial(object.version); + } else { + message.version = undefined; + } + return message; + }, +}; + +const baseBlockParams: object = { maxBytes: 0, maxGas: 0 }; + +export const BlockParams = { + encode(message: BlockParams, writer: Writer = Writer.create()): Writer { + if (message.maxBytes !== 0) { + writer.uint32(8).int64(message.maxBytes); + } + if (message.maxGas !== 0) { + writer.uint32(16).int64(message.maxGas); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): BlockParams { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseBlockParams } as BlockParams; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.maxBytes = longToNumber(reader.int64() as Long); + break; + case 2: + message.maxGas = longToNumber(reader.int64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): BlockParams { + const message = { ...baseBlockParams } as BlockParams; + if (object.maxBytes !== undefined && object.maxBytes !== null) { + message.maxBytes = Number(object.maxBytes); + } else { + message.maxBytes = 0; + } + if (object.maxGas !== undefined && object.maxGas !== null) { + message.maxGas = Number(object.maxGas); + } else { + message.maxGas = 0; + } + return message; + }, + + toJSON(message: BlockParams): unknown { + const obj: any = {}; + message.maxBytes !== undefined && (obj.maxBytes = message.maxBytes); + message.maxGas !== undefined && (obj.maxGas = message.maxGas); + return obj; + }, + + fromPartial(object: DeepPartial): BlockParams { + const message = { ...baseBlockParams } as BlockParams; + if (object.maxBytes !== undefined && object.maxBytes !== null) { + message.maxBytes = object.maxBytes; + } else { + message.maxBytes = 0; + } + if (object.maxGas !== undefined && object.maxGas !== null) { + message.maxGas = object.maxGas; + } else { + message.maxGas = 0; + } + return message; + }, +}; + +const baseLastCommitInfo: object = { round: 0 }; + +export const LastCommitInfo = { + encode(message: LastCommitInfo, writer: Writer = Writer.create()): Writer { + if (message.round !== 0) { + writer.uint32(8).int32(message.round); + } + for (const v of message.votes) { + VoteInfo.encode(v!, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): LastCommitInfo { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseLastCommitInfo } as LastCommitInfo; + message.votes = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.round = reader.int32(); + break; + case 2: + message.votes.push(VoteInfo.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): LastCommitInfo { + const message = { ...baseLastCommitInfo } as LastCommitInfo; + message.votes = []; + if (object.round !== undefined && object.round !== null) { + message.round = Number(object.round); + } else { + message.round = 0; + } + if (object.votes !== undefined && object.votes !== null) { + for (const e of object.votes) { + message.votes.push(VoteInfo.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: LastCommitInfo): unknown { + const obj: any = {}; + message.round !== undefined && (obj.round = message.round); + if (message.votes) { + obj.votes = message.votes.map((e) => + e ? VoteInfo.toJSON(e) : undefined + ); + } else { + obj.votes = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): LastCommitInfo { + const message = { ...baseLastCommitInfo } as LastCommitInfo; + message.votes = []; + if (object.round !== undefined && object.round !== null) { + message.round = object.round; + } else { + message.round = 0; + } + if (object.votes !== undefined && object.votes !== null) { + for (const e of object.votes) { + message.votes.push(VoteInfo.fromPartial(e)); + } + } + return message; + }, +}; + +const baseEvent: object = { type: "" }; + +export const Event = { + encode(message: Event, writer: Writer = Writer.create()): Writer { + if (message.type !== "") { + writer.uint32(10).string(message.type); + } + for (const v of message.attributes) { + EventAttribute.encode(v!, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Event { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseEvent } as Event; + message.attributes = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.type = reader.string(); + break; + case 2: + message.attributes.push( + EventAttribute.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Event { + const message = { ...baseEvent } as Event; + message.attributes = []; + if (object.type !== undefined && object.type !== null) { + message.type = String(object.type); + } else { + message.type = ""; + } + if (object.attributes !== undefined && object.attributes !== null) { + for (const e of object.attributes) { + message.attributes.push(EventAttribute.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: Event): unknown { + const obj: any = {}; + message.type !== undefined && (obj.type = message.type); + if (message.attributes) { + obj.attributes = message.attributes.map((e) => + e ? EventAttribute.toJSON(e) : undefined + ); + } else { + obj.attributes = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): Event { + const message = { ...baseEvent } as Event; + message.attributes = []; + if (object.type !== undefined && object.type !== null) { + message.type = object.type; + } else { + message.type = ""; + } + if (object.attributes !== undefined && object.attributes !== null) { + for (const e of object.attributes) { + message.attributes.push(EventAttribute.fromPartial(e)); + } + } + return message; + }, +}; + +const baseEventAttribute: object = { index: false }; + +export const EventAttribute = { + encode(message: EventAttribute, writer: Writer = Writer.create()): Writer { + if (message.key.length !== 0) { + writer.uint32(10).bytes(message.key); + } + if (message.value.length !== 0) { + writer.uint32(18).bytes(message.value); + } + if (message.index === true) { + writer.uint32(24).bool(message.index); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): EventAttribute { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseEventAttribute } as EventAttribute; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.key = reader.bytes(); + break; + case 2: + message.value = reader.bytes(); + break; + case 3: + message.index = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EventAttribute { + const message = { ...baseEventAttribute } as EventAttribute; + if (object.key !== undefined && object.key !== null) { + message.key = bytesFromBase64(object.key); + } + if (object.value !== undefined && object.value !== null) { + message.value = bytesFromBase64(object.value); + } + if (object.index !== undefined && object.index !== null) { + message.index = Boolean(object.index); + } else { + message.index = false; + } + return message; + }, + + toJSON(message: EventAttribute): unknown { + const obj: any = {}; + message.key !== undefined && + (obj.key = base64FromBytes( + message.key !== undefined ? message.key : new Uint8Array() + )); + message.value !== undefined && + (obj.value = base64FromBytes( + message.value !== undefined ? message.value : new Uint8Array() + )); + message.index !== undefined && (obj.index = message.index); + return obj; + }, + + fromPartial(object: DeepPartial): EventAttribute { + const message = { ...baseEventAttribute } as EventAttribute; + if (object.key !== undefined && object.key !== null) { + message.key = object.key; + } else { + message.key = new Uint8Array(); + } + if (object.value !== undefined && object.value !== null) { + message.value = object.value; + } else { + message.value = new Uint8Array(); + } + if (object.index !== undefined && object.index !== null) { + message.index = object.index; + } else { + message.index = false; + } + return message; + }, +}; + +const baseTxResult: object = { height: 0, index: 0 }; + +export const TxResult = { + encode(message: TxResult, writer: Writer = Writer.create()): Writer { + if (message.height !== 0) { + writer.uint32(8).int64(message.height); + } + if (message.index !== 0) { + writer.uint32(16).uint32(message.index); + } + if (message.tx.length !== 0) { + writer.uint32(26).bytes(message.tx); + } + if (message.result !== undefined) { + ResponseDeliverTx.encode( + message.result, + writer.uint32(34).fork() + ).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): TxResult { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseTxResult } as TxResult; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.height = longToNumber(reader.int64() as Long); + break; + case 2: + message.index = reader.uint32(); + break; + case 3: + message.tx = reader.bytes(); + break; + case 4: + message.result = ResponseDeliverTx.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): TxResult { + const message = { ...baseTxResult } as TxResult; + if (object.height !== undefined && object.height !== null) { + message.height = Number(object.height); + } else { + message.height = 0; + } + if (object.index !== undefined && object.index !== null) { + message.index = Number(object.index); + } else { + message.index = 0; + } + if (object.tx !== undefined && object.tx !== null) { + message.tx = bytesFromBase64(object.tx); + } + if (object.result !== undefined && object.result !== null) { + message.result = ResponseDeliverTx.fromJSON(object.result); + } else { + message.result = undefined; + } + return message; + }, + + toJSON(message: TxResult): unknown { + const obj: any = {}; + message.height !== undefined && (obj.height = message.height); + message.index !== undefined && (obj.index = message.index); + message.tx !== undefined && + (obj.tx = base64FromBytes( + message.tx !== undefined ? message.tx : new Uint8Array() + )); + message.result !== undefined && + (obj.result = message.result + ? ResponseDeliverTx.toJSON(message.result) + : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): TxResult { + const message = { ...baseTxResult } as TxResult; + if (object.height !== undefined && object.height !== null) { + message.height = object.height; + } else { + message.height = 0; + } + if (object.index !== undefined && object.index !== null) { + message.index = object.index; + } else { + message.index = 0; + } + if (object.tx !== undefined && object.tx !== null) { + message.tx = object.tx; + } else { + message.tx = new Uint8Array(); + } + if (object.result !== undefined && object.result !== null) { + message.result = ResponseDeliverTx.fromPartial(object.result); + } else { + message.result = undefined; + } + return message; + }, +}; + +const baseValidator: object = { power: 0 }; + +export const Validator = { + encode(message: Validator, writer: Writer = Writer.create()): Writer { + if (message.address.length !== 0) { + writer.uint32(10).bytes(message.address); + } + if (message.power !== 0) { + writer.uint32(24).int64(message.power); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Validator { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseValidator } as Validator; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.address = reader.bytes(); + break; + case 3: + message.power = longToNumber(reader.int64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Validator { + const message = { ...baseValidator } as Validator; + if (object.address !== undefined && object.address !== null) { + message.address = bytesFromBase64(object.address); + } + if (object.power !== undefined && object.power !== null) { + message.power = Number(object.power); + } else { + message.power = 0; + } + return message; + }, + + toJSON(message: Validator): unknown { + const obj: any = {}; + message.address !== undefined && + (obj.address = base64FromBytes( + message.address !== undefined ? message.address : new Uint8Array() + )); + message.power !== undefined && (obj.power = message.power); + return obj; + }, + + fromPartial(object: DeepPartial): Validator { + const message = { ...baseValidator } as Validator; + if (object.address !== undefined && object.address !== null) { + message.address = object.address; + } else { + message.address = new Uint8Array(); + } + if (object.power !== undefined && object.power !== null) { + message.power = object.power; + } else { + message.power = 0; + } + return message; + }, +}; + +const baseValidatorUpdate: object = { power: 0 }; + +export const ValidatorUpdate = { + encode(message: ValidatorUpdate, writer: Writer = Writer.create()): Writer { + if (message.pubKey !== undefined) { + PublicKey.encode(message.pubKey, writer.uint32(10).fork()).ldelim(); + } + if (message.power !== 0) { + writer.uint32(16).int64(message.power); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ValidatorUpdate { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseValidatorUpdate } as ValidatorUpdate; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.pubKey = PublicKey.decode(reader, reader.uint32()); + break; + case 2: + message.power = longToNumber(reader.int64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ValidatorUpdate { + const message = { ...baseValidatorUpdate } as ValidatorUpdate; + if (object.pubKey !== undefined && object.pubKey !== null) { + message.pubKey = PublicKey.fromJSON(object.pubKey); + } else { + message.pubKey = undefined; + } + if (object.power !== undefined && object.power !== null) { + message.power = Number(object.power); + } else { + message.power = 0; + } + return message; + }, + + toJSON(message: ValidatorUpdate): unknown { + const obj: any = {}; + message.pubKey !== undefined && + (obj.pubKey = message.pubKey + ? PublicKey.toJSON(message.pubKey) + : undefined); + message.power !== undefined && (obj.power = message.power); + return obj; + }, + + fromPartial(object: DeepPartial): ValidatorUpdate { + const message = { ...baseValidatorUpdate } as ValidatorUpdate; + if (object.pubKey !== undefined && object.pubKey !== null) { + message.pubKey = PublicKey.fromPartial(object.pubKey); + } else { + message.pubKey = undefined; + } + if (object.power !== undefined && object.power !== null) { + message.power = object.power; + } else { + message.power = 0; + } + return message; + }, +}; + +const baseVoteInfo: object = { signedLastBlock: false }; + +export const VoteInfo = { + encode(message: VoteInfo, writer: Writer = Writer.create()): Writer { + if (message.validator !== undefined) { + Validator.encode(message.validator, writer.uint32(10).fork()).ldelim(); + } + if (message.signedLastBlock === true) { + writer.uint32(16).bool(message.signedLastBlock); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): VoteInfo { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseVoteInfo } as VoteInfo; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.validator = Validator.decode(reader, reader.uint32()); + break; + case 2: + message.signedLastBlock = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): VoteInfo { + const message = { ...baseVoteInfo } as VoteInfo; + if (object.validator !== undefined && object.validator !== null) { + message.validator = Validator.fromJSON(object.validator); + } else { + message.validator = undefined; + } + if ( + object.signedLastBlock !== undefined && + object.signedLastBlock !== null + ) { + message.signedLastBlock = Boolean(object.signedLastBlock); + } else { + message.signedLastBlock = false; + } + return message; + }, + + toJSON(message: VoteInfo): unknown { + const obj: any = {}; + message.validator !== undefined && + (obj.validator = message.validator + ? Validator.toJSON(message.validator) + : undefined); + message.signedLastBlock !== undefined && + (obj.signedLastBlock = message.signedLastBlock); + return obj; + }, + + fromPartial(object: DeepPartial): VoteInfo { + const message = { ...baseVoteInfo } as VoteInfo; + if (object.validator !== undefined && object.validator !== null) { + message.validator = Validator.fromPartial(object.validator); + } else { + message.validator = undefined; + } + if ( + object.signedLastBlock !== undefined && + object.signedLastBlock !== null + ) { + message.signedLastBlock = object.signedLastBlock; + } else { + message.signedLastBlock = false; + } + return message; + }, +}; + +const baseEvidence: object = { type: 0, height: 0, totalVotingPower: 0 }; + +export const Evidence = { + encode(message: Evidence, writer: Writer = Writer.create()): Writer { + if (message.type !== 0) { + writer.uint32(8).int32(message.type); + } + if (message.validator !== undefined) { + Validator.encode(message.validator, writer.uint32(18).fork()).ldelim(); + } + if (message.height !== 0) { + writer.uint32(24).int64(message.height); + } + if (message.time !== undefined) { + Timestamp.encode( + toTimestamp(message.time), + writer.uint32(34).fork() + ).ldelim(); + } + if (message.totalVotingPower !== 0) { + writer.uint32(40).int64(message.totalVotingPower); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Evidence { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseEvidence } as Evidence; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.type = reader.int32() as any; + break; + case 2: + message.validator = Validator.decode(reader, reader.uint32()); + break; + case 3: + message.height = longToNumber(reader.int64() as Long); + break; + case 4: + message.time = fromTimestamp( + Timestamp.decode(reader, reader.uint32()) + ); + break; + case 5: + message.totalVotingPower = longToNumber(reader.int64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Evidence { + const message = { ...baseEvidence } as Evidence; + if (object.type !== undefined && object.type !== null) { + message.type = evidenceTypeFromJSON(object.type); + } else { + message.type = 0; + } + if (object.validator !== undefined && object.validator !== null) { + message.validator = Validator.fromJSON(object.validator); + } else { + message.validator = undefined; + } + if (object.height !== undefined && object.height !== null) { + message.height = Number(object.height); + } else { + message.height = 0; + } + if (object.time !== undefined && object.time !== null) { + message.time = fromJsonTimestamp(object.time); + } else { + message.time = undefined; + } + if ( + object.totalVotingPower !== undefined && + object.totalVotingPower !== null + ) { + message.totalVotingPower = Number(object.totalVotingPower); + } else { + message.totalVotingPower = 0; + } + return message; + }, + + toJSON(message: Evidence): unknown { + const obj: any = {}; + message.type !== undefined && (obj.type = evidenceTypeToJSON(message.type)); + message.validator !== undefined && + (obj.validator = message.validator + ? Validator.toJSON(message.validator) + : undefined); + message.height !== undefined && (obj.height = message.height); + message.time !== undefined && + (obj.time = + message.time !== undefined ? message.time.toISOString() : null); + message.totalVotingPower !== undefined && + (obj.totalVotingPower = message.totalVotingPower); + return obj; + }, + + fromPartial(object: DeepPartial): Evidence { + const message = { ...baseEvidence } as Evidence; + if (object.type !== undefined && object.type !== null) { + message.type = object.type; + } else { + message.type = 0; + } + if (object.validator !== undefined && object.validator !== null) { + message.validator = Validator.fromPartial(object.validator); + } else { + message.validator = undefined; + } + if (object.height !== undefined && object.height !== null) { + message.height = object.height; + } else { + message.height = 0; + } + if (object.time !== undefined && object.time !== null) { + message.time = object.time; + } else { + message.time = undefined; + } + if ( + object.totalVotingPower !== undefined && + object.totalVotingPower !== null + ) { + message.totalVotingPower = object.totalVotingPower; + } else { + message.totalVotingPower = 0; + } + return message; + }, +}; + +const baseSnapshot: object = { height: 0, format: 0, chunks: 0 }; + +export const Snapshot = { + encode(message: Snapshot, writer: Writer = Writer.create()): Writer { + if (message.height !== 0) { + writer.uint32(8).uint64(message.height); + } + if (message.format !== 0) { + writer.uint32(16).uint32(message.format); + } + if (message.chunks !== 0) { + writer.uint32(24).uint32(message.chunks); + } + if (message.hash.length !== 0) { + writer.uint32(34).bytes(message.hash); + } + if (message.metadata.length !== 0) { + writer.uint32(42).bytes(message.metadata); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Snapshot { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseSnapshot } as Snapshot; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.height = longToNumber(reader.uint64() as Long); + break; + case 2: + message.format = reader.uint32(); + break; + case 3: + message.chunks = reader.uint32(); + break; + case 4: + message.hash = reader.bytes(); + break; + case 5: + message.metadata = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Snapshot { + const message = { ...baseSnapshot } as Snapshot; + if (object.height !== undefined && object.height !== null) { + message.height = Number(object.height); + } else { + message.height = 0; + } + if (object.format !== undefined && object.format !== null) { + message.format = Number(object.format); + } else { + message.format = 0; + } + if (object.chunks !== undefined && object.chunks !== null) { + message.chunks = Number(object.chunks); + } else { + message.chunks = 0; + } + if (object.hash !== undefined && object.hash !== null) { + message.hash = bytesFromBase64(object.hash); + } + if (object.metadata !== undefined && object.metadata !== null) { + message.metadata = bytesFromBase64(object.metadata); + } + return message; + }, + + toJSON(message: Snapshot): unknown { + const obj: any = {}; + message.height !== undefined && (obj.height = message.height); + message.format !== undefined && (obj.format = message.format); + message.chunks !== undefined && (obj.chunks = message.chunks); + message.hash !== undefined && + (obj.hash = base64FromBytes( + message.hash !== undefined ? message.hash : new Uint8Array() + )); + message.metadata !== undefined && + (obj.metadata = base64FromBytes( + message.metadata !== undefined ? message.metadata : new Uint8Array() + )); + return obj; + }, + + fromPartial(object: DeepPartial): Snapshot { + const message = { ...baseSnapshot } as Snapshot; + if (object.height !== undefined && object.height !== null) { + message.height = object.height; + } else { + message.height = 0; + } + if (object.format !== undefined && object.format !== null) { + message.format = object.format; + } else { + message.format = 0; + } + if (object.chunks !== undefined && object.chunks !== null) { + message.chunks = object.chunks; + } else { + message.chunks = 0; + } + if (object.hash !== undefined && object.hash !== null) { + message.hash = object.hash; + } else { + message.hash = new Uint8Array(); + } + if (object.metadata !== undefined && object.metadata !== null) { + message.metadata = object.metadata; + } else { + message.metadata = new Uint8Array(); + } + return message; + }, +}; + +export interface ABCIApplication { + Echo(request: RequestEcho): Promise; + Flush(request: RequestFlush): Promise; + Info(request: RequestInfo): Promise; + SetOption(request: RequestSetOption): Promise; + DeliverTx(request: RequestDeliverTx): Promise; + CheckTx(request: RequestCheckTx): Promise; + Query(request: RequestQuery): Promise; + Commit(request: RequestCommit): Promise; + InitChain(request: RequestInitChain): Promise; + BeginBlock(request: RequestBeginBlock): Promise; + EndBlock(request: RequestEndBlock): Promise; + ListSnapshots(request: RequestListSnapshots): Promise; + OfferSnapshot(request: RequestOfferSnapshot): Promise; + LoadSnapshotChunk( + request: RequestLoadSnapshotChunk + ): Promise; + ApplySnapshotChunk( + request: RequestApplySnapshotChunk + ): Promise; +} + +export class ABCIApplicationClientImpl implements ABCIApplication { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + } + Echo(request: RequestEcho): Promise { + const data = RequestEcho.encode(request).finish(); + const promise = this.rpc.request( + "tendermint.abci.ABCIApplication", + "Echo", + data + ); + return promise.then((data) => ResponseEcho.decode(new Reader(data))); + } + + Flush(request: RequestFlush): Promise { + const data = RequestFlush.encode(request).finish(); + const promise = this.rpc.request( + "tendermint.abci.ABCIApplication", + "Flush", + data + ); + return promise.then((data) => ResponseFlush.decode(new Reader(data))); + } + + Info(request: RequestInfo): Promise { + const data = RequestInfo.encode(request).finish(); + const promise = this.rpc.request( + "tendermint.abci.ABCIApplication", + "Info", + data + ); + return promise.then((data) => ResponseInfo.decode(new Reader(data))); + } + + SetOption(request: RequestSetOption): Promise { + const data = RequestSetOption.encode(request).finish(); + const promise = this.rpc.request( + "tendermint.abci.ABCIApplication", + "SetOption", + data + ); + return promise.then((data) => ResponseSetOption.decode(new Reader(data))); + } + + DeliverTx(request: RequestDeliverTx): Promise { + const data = RequestDeliverTx.encode(request).finish(); + const promise = this.rpc.request( + "tendermint.abci.ABCIApplication", + "DeliverTx", + data + ); + return promise.then((data) => ResponseDeliverTx.decode(new Reader(data))); + } + + CheckTx(request: RequestCheckTx): Promise { + const data = RequestCheckTx.encode(request).finish(); + const promise = this.rpc.request( + "tendermint.abci.ABCIApplication", + "CheckTx", + data + ); + return promise.then((data) => ResponseCheckTx.decode(new Reader(data))); + } + + Query(request: RequestQuery): Promise { + const data = RequestQuery.encode(request).finish(); + const promise = this.rpc.request( + "tendermint.abci.ABCIApplication", + "Query", + data + ); + return promise.then((data) => ResponseQuery.decode(new Reader(data))); + } + + Commit(request: RequestCommit): Promise { + const data = RequestCommit.encode(request).finish(); + const promise = this.rpc.request( + "tendermint.abci.ABCIApplication", + "Commit", + data + ); + return promise.then((data) => ResponseCommit.decode(new Reader(data))); + } + + InitChain(request: RequestInitChain): Promise { + const data = RequestInitChain.encode(request).finish(); + const promise = this.rpc.request( + "tendermint.abci.ABCIApplication", + "InitChain", + data + ); + return promise.then((data) => ResponseInitChain.decode(new Reader(data))); + } + + BeginBlock(request: RequestBeginBlock): Promise { + const data = RequestBeginBlock.encode(request).finish(); + const promise = this.rpc.request( + "tendermint.abci.ABCIApplication", + "BeginBlock", + data + ); + return promise.then((data) => ResponseBeginBlock.decode(new Reader(data))); + } + + EndBlock(request: RequestEndBlock): Promise { + const data = RequestEndBlock.encode(request).finish(); + const promise = this.rpc.request( + "tendermint.abci.ABCIApplication", + "EndBlock", + data + ); + return promise.then((data) => ResponseEndBlock.decode(new Reader(data))); + } + + ListSnapshots(request: RequestListSnapshots): Promise { + const data = RequestListSnapshots.encode(request).finish(); + const promise = this.rpc.request( + "tendermint.abci.ABCIApplication", + "ListSnapshots", + data + ); + return promise.then((data) => + ResponseListSnapshots.decode(new Reader(data)) + ); + } + + OfferSnapshot(request: RequestOfferSnapshot): Promise { + const data = RequestOfferSnapshot.encode(request).finish(); + const promise = this.rpc.request( + "tendermint.abci.ABCIApplication", + "OfferSnapshot", + data + ); + return promise.then((data) => + ResponseOfferSnapshot.decode(new Reader(data)) + ); + } + + LoadSnapshotChunk( + request: RequestLoadSnapshotChunk + ): Promise { + const data = RequestLoadSnapshotChunk.encode(request).finish(); + const promise = this.rpc.request( + "tendermint.abci.ABCIApplication", + "LoadSnapshotChunk", + data + ); + return promise.then((data) => + ResponseLoadSnapshotChunk.decode(new Reader(data)) + ); + } + + ApplySnapshotChunk( + request: RequestApplySnapshotChunk + ): Promise { + const data = RequestApplySnapshotChunk.encode(request).finish(); + const promise = this.rpc.request( + "tendermint.abci.ABCIApplication", + "ApplySnapshotChunk", + data + ); + return promise.then((data) => + ResponseApplySnapshotChunk.decode(new Reader(data)) + ); + } +} + +interface Rpc { + request( + service: string, + method: string, + data: Uint8Array + ): Promise; +} + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function toTimestamp(date: Date): Timestamp { + const seconds = date.getTime() / 1_000; + const nanos = (date.getTime() % 1_000) * 1_000_000; + return { seconds, nanos }; +} + +function fromTimestamp(t: Timestamp): Date { + let millis = t.seconds * 1_000; + millis += t.nanos / 1_000_000; + return new Date(millis); +} + +function fromJsonTimestamp(o: any): Date { + if (o instanceof Date) { + return o; + } else if (typeof o === "string") { + return new Date(o); + } else { + return fromTimestamp(Timestamp.fromJSON(o)); + } +} + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/cosmos.authz.v1beta1/types/tendermint/crypto/keys.ts b/ts-client/cosmos.authz.v1beta1/types/tendermint/crypto/keys.ts new file mode 100644 index 00000000..d530b047 --- /dev/null +++ b/ts-client/cosmos.authz.v1beta1/types/tendermint/crypto/keys.ts @@ -0,0 +1,130 @@ +/* eslint-disable */ +import { Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "tendermint.crypto"; + +/** PublicKey defines the keys available for use with Validators */ +export interface PublicKey { + ed25519: Uint8Array | undefined; + secp256k1: Uint8Array | undefined; +} + +const basePublicKey: object = {}; + +export const PublicKey = { + encode(message: PublicKey, writer: Writer = Writer.create()): Writer { + if (message.ed25519 !== undefined) { + writer.uint32(10).bytes(message.ed25519); + } + if (message.secp256k1 !== undefined) { + writer.uint32(18).bytes(message.secp256k1); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): PublicKey { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...basePublicKey } as PublicKey; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.ed25519 = reader.bytes(); + break; + case 2: + message.secp256k1 = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): PublicKey { + const message = { ...basePublicKey } as PublicKey; + if (object.ed25519 !== undefined && object.ed25519 !== null) { + message.ed25519 = bytesFromBase64(object.ed25519); + } + if (object.secp256k1 !== undefined && object.secp256k1 !== null) { + message.secp256k1 = bytesFromBase64(object.secp256k1); + } + return message; + }, + + toJSON(message: PublicKey): unknown { + const obj: any = {}; + message.ed25519 !== undefined && + (obj.ed25519 = + message.ed25519 !== undefined + ? base64FromBytes(message.ed25519) + : undefined); + message.secp256k1 !== undefined && + (obj.secp256k1 = + message.secp256k1 !== undefined + ? base64FromBytes(message.secp256k1) + : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): PublicKey { + const message = { ...basePublicKey } as PublicKey; + if (object.ed25519 !== undefined && object.ed25519 !== null) { + message.ed25519 = object.ed25519; + } else { + message.ed25519 = undefined; + } + if (object.secp256k1 !== undefined && object.secp256k1 !== null) { + message.secp256k1 = object.secp256k1; + } else { + message.secp256k1 = undefined; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/cosmos.authz.v1beta1/types/tendermint/crypto/proof.ts b/ts-client/cosmos.authz.v1beta1/types/tendermint/crypto/proof.ts new file mode 100644 index 00000000..dae51600 --- /dev/null +++ b/ts-client/cosmos.authz.v1beta1/types/tendermint/crypto/proof.ts @@ -0,0 +1,529 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "tendermint.crypto"; + +export interface Proof { + total: number; + index: number; + leafHash: Uint8Array; + aunts: Uint8Array[]; +} + +export interface ValueOp { + /** Encoded in ProofOp.Key. */ + key: Uint8Array; + /** To encode in ProofOp.Data */ + proof: Proof | undefined; +} + +export interface DominoOp { + key: string; + input: string; + output: string; +} + +/** + * ProofOp defines an operation used for calculating Merkle root + * The data could be arbitrary format, providing nessecary data + * for example neighbouring node hash + */ +export interface ProofOp { + type: string; + key: Uint8Array; + data: Uint8Array; +} + +/** ProofOps is Merkle proof defined by the list of ProofOps */ +export interface ProofOps { + ops: ProofOp[]; +} + +const baseProof: object = { total: 0, index: 0 }; + +export const Proof = { + encode(message: Proof, writer: Writer = Writer.create()): Writer { + if (message.total !== 0) { + writer.uint32(8).int64(message.total); + } + if (message.index !== 0) { + writer.uint32(16).int64(message.index); + } + if (message.leafHash.length !== 0) { + writer.uint32(26).bytes(message.leafHash); + } + for (const v of message.aunts) { + writer.uint32(34).bytes(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Proof { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseProof } as Proof; + message.aunts = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.total = longToNumber(reader.int64() as Long); + break; + case 2: + message.index = longToNumber(reader.int64() as Long); + break; + case 3: + message.leafHash = reader.bytes(); + break; + case 4: + message.aunts.push(reader.bytes()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Proof { + const message = { ...baseProof } as Proof; + message.aunts = []; + if (object.total !== undefined && object.total !== null) { + message.total = Number(object.total); + } else { + message.total = 0; + } + if (object.index !== undefined && object.index !== null) { + message.index = Number(object.index); + } else { + message.index = 0; + } + if (object.leafHash !== undefined && object.leafHash !== null) { + message.leafHash = bytesFromBase64(object.leafHash); + } + if (object.aunts !== undefined && object.aunts !== null) { + for (const e of object.aunts) { + message.aunts.push(bytesFromBase64(e)); + } + } + return message; + }, + + toJSON(message: Proof): unknown { + const obj: any = {}; + message.total !== undefined && (obj.total = message.total); + message.index !== undefined && (obj.index = message.index); + message.leafHash !== undefined && + (obj.leafHash = base64FromBytes( + message.leafHash !== undefined ? message.leafHash : new Uint8Array() + )); + if (message.aunts) { + obj.aunts = message.aunts.map((e) => + base64FromBytes(e !== undefined ? e : new Uint8Array()) + ); + } else { + obj.aunts = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): Proof { + const message = { ...baseProof } as Proof; + message.aunts = []; + if (object.total !== undefined && object.total !== null) { + message.total = object.total; + } else { + message.total = 0; + } + if (object.index !== undefined && object.index !== null) { + message.index = object.index; + } else { + message.index = 0; + } + if (object.leafHash !== undefined && object.leafHash !== null) { + message.leafHash = object.leafHash; + } else { + message.leafHash = new Uint8Array(); + } + if (object.aunts !== undefined && object.aunts !== null) { + for (const e of object.aunts) { + message.aunts.push(e); + } + } + return message; + }, +}; + +const baseValueOp: object = {}; + +export const ValueOp = { + encode(message: ValueOp, writer: Writer = Writer.create()): Writer { + if (message.key.length !== 0) { + writer.uint32(10).bytes(message.key); + } + if (message.proof !== undefined) { + Proof.encode(message.proof, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ValueOp { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseValueOp } as ValueOp; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.key = reader.bytes(); + break; + case 2: + message.proof = Proof.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ValueOp { + const message = { ...baseValueOp } as ValueOp; + if (object.key !== undefined && object.key !== null) { + message.key = bytesFromBase64(object.key); + } + if (object.proof !== undefined && object.proof !== null) { + message.proof = Proof.fromJSON(object.proof); + } else { + message.proof = undefined; + } + return message; + }, + + toJSON(message: ValueOp): unknown { + const obj: any = {}; + message.key !== undefined && + (obj.key = base64FromBytes( + message.key !== undefined ? message.key : new Uint8Array() + )); + message.proof !== undefined && + (obj.proof = message.proof ? Proof.toJSON(message.proof) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): ValueOp { + const message = { ...baseValueOp } as ValueOp; + if (object.key !== undefined && object.key !== null) { + message.key = object.key; + } else { + message.key = new Uint8Array(); + } + if (object.proof !== undefined && object.proof !== null) { + message.proof = Proof.fromPartial(object.proof); + } else { + message.proof = undefined; + } + return message; + }, +}; + +const baseDominoOp: object = { key: "", input: "", output: "" }; + +export const DominoOp = { + encode(message: DominoOp, writer: Writer = Writer.create()): Writer { + if (message.key !== "") { + writer.uint32(10).string(message.key); + } + if (message.input !== "") { + writer.uint32(18).string(message.input); + } + if (message.output !== "") { + writer.uint32(26).string(message.output); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): DominoOp { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseDominoOp } as DominoOp; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.key = reader.string(); + break; + case 2: + message.input = reader.string(); + break; + case 3: + message.output = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DominoOp { + const message = { ...baseDominoOp } as DominoOp; + if (object.key !== undefined && object.key !== null) { + message.key = String(object.key); + } else { + message.key = ""; + } + if (object.input !== undefined && object.input !== null) { + message.input = String(object.input); + } else { + message.input = ""; + } + if (object.output !== undefined && object.output !== null) { + message.output = String(object.output); + } else { + message.output = ""; + } + return message; + }, + + toJSON(message: DominoOp): unknown { + const obj: any = {}; + message.key !== undefined && (obj.key = message.key); + message.input !== undefined && (obj.input = message.input); + message.output !== undefined && (obj.output = message.output); + return obj; + }, + + fromPartial(object: DeepPartial): DominoOp { + const message = { ...baseDominoOp } as DominoOp; + if (object.key !== undefined && object.key !== null) { + message.key = object.key; + } else { + message.key = ""; + } + if (object.input !== undefined && object.input !== null) { + message.input = object.input; + } else { + message.input = ""; + } + if (object.output !== undefined && object.output !== null) { + message.output = object.output; + } else { + message.output = ""; + } + return message; + }, +}; + +const baseProofOp: object = { type: "" }; + +export const ProofOp = { + encode(message: ProofOp, writer: Writer = Writer.create()): Writer { + if (message.type !== "") { + writer.uint32(10).string(message.type); + } + if (message.key.length !== 0) { + writer.uint32(18).bytes(message.key); + } + if (message.data.length !== 0) { + writer.uint32(26).bytes(message.data); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ProofOp { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseProofOp } as ProofOp; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.type = reader.string(); + break; + case 2: + message.key = reader.bytes(); + break; + case 3: + message.data = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ProofOp { + const message = { ...baseProofOp } as ProofOp; + if (object.type !== undefined && object.type !== null) { + message.type = String(object.type); + } else { + message.type = ""; + } + if (object.key !== undefined && object.key !== null) { + message.key = bytesFromBase64(object.key); + } + if (object.data !== undefined && object.data !== null) { + message.data = bytesFromBase64(object.data); + } + return message; + }, + + toJSON(message: ProofOp): unknown { + const obj: any = {}; + message.type !== undefined && (obj.type = message.type); + message.key !== undefined && + (obj.key = base64FromBytes( + message.key !== undefined ? message.key : new Uint8Array() + )); + message.data !== undefined && + (obj.data = base64FromBytes( + message.data !== undefined ? message.data : new Uint8Array() + )); + return obj; + }, + + fromPartial(object: DeepPartial): ProofOp { + const message = { ...baseProofOp } as ProofOp; + if (object.type !== undefined && object.type !== null) { + message.type = object.type; + } else { + message.type = ""; + } + if (object.key !== undefined && object.key !== null) { + message.key = object.key; + } else { + message.key = new Uint8Array(); + } + if (object.data !== undefined && object.data !== null) { + message.data = object.data; + } else { + message.data = new Uint8Array(); + } + return message; + }, +}; + +const baseProofOps: object = {}; + +export const ProofOps = { + encode(message: ProofOps, writer: Writer = Writer.create()): Writer { + for (const v of message.ops) { + ProofOp.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ProofOps { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseProofOps } as ProofOps; + message.ops = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.ops.push(ProofOp.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ProofOps { + const message = { ...baseProofOps } as ProofOps; + message.ops = []; + if (object.ops !== undefined && object.ops !== null) { + for (const e of object.ops) { + message.ops.push(ProofOp.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: ProofOps): unknown { + const obj: any = {}; + if (message.ops) { + obj.ops = message.ops.map((e) => (e ? ProofOp.toJSON(e) : undefined)); + } else { + obj.ops = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): ProofOps { + const message = { ...baseProofOps } as ProofOps; + message.ops = []; + if (object.ops !== undefined && object.ops !== null) { + for (const e of object.ops) { + message.ops.push(ProofOp.fromPartial(e)); + } + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/cosmos.authz.v1beta1/types/tendermint/types/params.ts b/ts-client/cosmos.authz.v1beta1/types/tendermint/types/params.ts new file mode 100644 index 00000000..eaa18463 --- /dev/null +++ b/ts-client/cosmos.authz.v1beta1/types/tendermint/types/params.ts @@ -0,0 +1,625 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; +import { Duration } from "../../google/protobuf/duration"; + +export const protobufPackage = "tendermint.types"; + +/** + * ConsensusParams contains consensus critical parameters that determine the + * validity of blocks. + */ +export interface ConsensusParams { + block: BlockParams | undefined; + evidence: EvidenceParams | undefined; + validator: ValidatorParams | undefined; + version: VersionParams | undefined; +} + +/** BlockParams contains limits on the block size. */ +export interface BlockParams { + /** + * Max block size, in bytes. + * Note: must be greater than 0 + */ + maxBytes: number; + /** + * Max gas per block. + * Note: must be greater or equal to -1 + */ + maxGas: number; + /** + * Minimum time increment between consecutive blocks (in milliseconds) If the + * block header timestamp is ahead of the system clock, decrease this value. + * + * Not exposed to the application. + */ + timeIotaMs: number; +} + +/** EvidenceParams determine how we handle evidence of malfeasance. */ +export interface EvidenceParams { + /** + * Max age of evidence, in blocks. + * + * The basic formula for calculating this is: MaxAgeDuration / {average block + * time}. + */ + maxAgeNumBlocks: number; + /** + * Max age of evidence, in time. + * + * It should correspond with an app's "unbonding period" or other similar + * mechanism for handling [Nothing-At-Stake + * attacks](https://github.com/ethereum/wiki/wiki/Proof-of-Stake-FAQ#what-is-the-nothing-at-stake-problem-and-how-can-it-be-fixed). + */ + maxAgeDuration: Duration | undefined; + /** + * This sets the maximum size of total evidence in bytes that can be committed in a single block. + * and should fall comfortably under the max block bytes. + * Default is 1048576 or 1MB + */ + maxBytes: number; +} + +/** + * ValidatorParams restrict the public key types validators can use. + * NOTE: uses ABCI pubkey naming, not Amino names. + */ +export interface ValidatorParams { + pubKeyTypes: string[]; +} + +/** VersionParams contains the ABCI application version. */ +export interface VersionParams { + appVersion: number; +} + +/** + * HashedParams is a subset of ConsensusParams. + * + * It is hashed into the Header.ConsensusHash. + */ +export interface HashedParams { + blockMaxBytes: number; + blockMaxGas: number; +} + +const baseConsensusParams: object = {}; + +export const ConsensusParams = { + encode(message: ConsensusParams, writer: Writer = Writer.create()): Writer { + if (message.block !== undefined) { + BlockParams.encode(message.block, writer.uint32(10).fork()).ldelim(); + } + if (message.evidence !== undefined) { + EvidenceParams.encode( + message.evidence, + writer.uint32(18).fork() + ).ldelim(); + } + if (message.validator !== undefined) { + ValidatorParams.encode( + message.validator, + writer.uint32(26).fork() + ).ldelim(); + } + if (message.version !== undefined) { + VersionParams.encode(message.version, writer.uint32(34).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ConsensusParams { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseConsensusParams } as ConsensusParams; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.block = BlockParams.decode(reader, reader.uint32()); + break; + case 2: + message.evidence = EvidenceParams.decode(reader, reader.uint32()); + break; + case 3: + message.validator = ValidatorParams.decode(reader, reader.uint32()); + break; + case 4: + message.version = VersionParams.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ConsensusParams { + const message = { ...baseConsensusParams } as ConsensusParams; + if (object.block !== undefined && object.block !== null) { + message.block = BlockParams.fromJSON(object.block); + } else { + message.block = undefined; + } + if (object.evidence !== undefined && object.evidence !== null) { + message.evidence = EvidenceParams.fromJSON(object.evidence); + } else { + message.evidence = undefined; + } + if (object.validator !== undefined && object.validator !== null) { + message.validator = ValidatorParams.fromJSON(object.validator); + } else { + message.validator = undefined; + } + if (object.version !== undefined && object.version !== null) { + message.version = VersionParams.fromJSON(object.version); + } else { + message.version = undefined; + } + return message; + }, + + toJSON(message: ConsensusParams): unknown { + const obj: any = {}; + message.block !== undefined && + (obj.block = message.block + ? BlockParams.toJSON(message.block) + : undefined); + message.evidence !== undefined && + (obj.evidence = message.evidence + ? EvidenceParams.toJSON(message.evidence) + : undefined); + message.validator !== undefined && + (obj.validator = message.validator + ? ValidatorParams.toJSON(message.validator) + : undefined); + message.version !== undefined && + (obj.version = message.version + ? VersionParams.toJSON(message.version) + : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): ConsensusParams { + const message = { ...baseConsensusParams } as ConsensusParams; + if (object.block !== undefined && object.block !== null) { + message.block = BlockParams.fromPartial(object.block); + } else { + message.block = undefined; + } + if (object.evidence !== undefined && object.evidence !== null) { + message.evidence = EvidenceParams.fromPartial(object.evidence); + } else { + message.evidence = undefined; + } + if (object.validator !== undefined && object.validator !== null) { + message.validator = ValidatorParams.fromPartial(object.validator); + } else { + message.validator = undefined; + } + if (object.version !== undefined && object.version !== null) { + message.version = VersionParams.fromPartial(object.version); + } else { + message.version = undefined; + } + return message; + }, +}; + +const baseBlockParams: object = { maxBytes: 0, maxGas: 0, timeIotaMs: 0 }; + +export const BlockParams = { + encode(message: BlockParams, writer: Writer = Writer.create()): Writer { + if (message.maxBytes !== 0) { + writer.uint32(8).int64(message.maxBytes); + } + if (message.maxGas !== 0) { + writer.uint32(16).int64(message.maxGas); + } + if (message.timeIotaMs !== 0) { + writer.uint32(24).int64(message.timeIotaMs); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): BlockParams { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseBlockParams } as BlockParams; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.maxBytes = longToNumber(reader.int64() as Long); + break; + case 2: + message.maxGas = longToNumber(reader.int64() as Long); + break; + case 3: + message.timeIotaMs = longToNumber(reader.int64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): BlockParams { + const message = { ...baseBlockParams } as BlockParams; + if (object.maxBytes !== undefined && object.maxBytes !== null) { + message.maxBytes = Number(object.maxBytes); + } else { + message.maxBytes = 0; + } + if (object.maxGas !== undefined && object.maxGas !== null) { + message.maxGas = Number(object.maxGas); + } else { + message.maxGas = 0; + } + if (object.timeIotaMs !== undefined && object.timeIotaMs !== null) { + message.timeIotaMs = Number(object.timeIotaMs); + } else { + message.timeIotaMs = 0; + } + return message; + }, + + toJSON(message: BlockParams): unknown { + const obj: any = {}; + message.maxBytes !== undefined && (obj.maxBytes = message.maxBytes); + message.maxGas !== undefined && (obj.maxGas = message.maxGas); + message.timeIotaMs !== undefined && (obj.timeIotaMs = message.timeIotaMs); + return obj; + }, + + fromPartial(object: DeepPartial): BlockParams { + const message = { ...baseBlockParams } as BlockParams; + if (object.maxBytes !== undefined && object.maxBytes !== null) { + message.maxBytes = object.maxBytes; + } else { + message.maxBytes = 0; + } + if (object.maxGas !== undefined && object.maxGas !== null) { + message.maxGas = object.maxGas; + } else { + message.maxGas = 0; + } + if (object.timeIotaMs !== undefined && object.timeIotaMs !== null) { + message.timeIotaMs = object.timeIotaMs; + } else { + message.timeIotaMs = 0; + } + return message; + }, +}; + +const baseEvidenceParams: object = { maxAgeNumBlocks: 0, maxBytes: 0 }; + +export const EvidenceParams = { + encode(message: EvidenceParams, writer: Writer = Writer.create()): Writer { + if (message.maxAgeNumBlocks !== 0) { + writer.uint32(8).int64(message.maxAgeNumBlocks); + } + if (message.maxAgeDuration !== undefined) { + Duration.encode( + message.maxAgeDuration, + writer.uint32(18).fork() + ).ldelim(); + } + if (message.maxBytes !== 0) { + writer.uint32(24).int64(message.maxBytes); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): EvidenceParams { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseEvidenceParams } as EvidenceParams; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.maxAgeNumBlocks = longToNumber(reader.int64() as Long); + break; + case 2: + message.maxAgeDuration = Duration.decode(reader, reader.uint32()); + break; + case 3: + message.maxBytes = longToNumber(reader.int64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EvidenceParams { + const message = { ...baseEvidenceParams } as EvidenceParams; + if ( + object.maxAgeNumBlocks !== undefined && + object.maxAgeNumBlocks !== null + ) { + message.maxAgeNumBlocks = Number(object.maxAgeNumBlocks); + } else { + message.maxAgeNumBlocks = 0; + } + if (object.maxAgeDuration !== undefined && object.maxAgeDuration !== null) { + message.maxAgeDuration = Duration.fromJSON(object.maxAgeDuration); + } else { + message.maxAgeDuration = undefined; + } + if (object.maxBytes !== undefined && object.maxBytes !== null) { + message.maxBytes = Number(object.maxBytes); + } else { + message.maxBytes = 0; + } + return message; + }, + + toJSON(message: EvidenceParams): unknown { + const obj: any = {}; + message.maxAgeNumBlocks !== undefined && + (obj.maxAgeNumBlocks = message.maxAgeNumBlocks); + message.maxAgeDuration !== undefined && + (obj.maxAgeDuration = message.maxAgeDuration + ? Duration.toJSON(message.maxAgeDuration) + : undefined); + message.maxBytes !== undefined && (obj.maxBytes = message.maxBytes); + return obj; + }, + + fromPartial(object: DeepPartial): EvidenceParams { + const message = { ...baseEvidenceParams } as EvidenceParams; + if ( + object.maxAgeNumBlocks !== undefined && + object.maxAgeNumBlocks !== null + ) { + message.maxAgeNumBlocks = object.maxAgeNumBlocks; + } else { + message.maxAgeNumBlocks = 0; + } + if (object.maxAgeDuration !== undefined && object.maxAgeDuration !== null) { + message.maxAgeDuration = Duration.fromPartial(object.maxAgeDuration); + } else { + message.maxAgeDuration = undefined; + } + if (object.maxBytes !== undefined && object.maxBytes !== null) { + message.maxBytes = object.maxBytes; + } else { + message.maxBytes = 0; + } + return message; + }, +}; + +const baseValidatorParams: object = { pubKeyTypes: "" }; + +export const ValidatorParams = { + encode(message: ValidatorParams, writer: Writer = Writer.create()): Writer { + for (const v of message.pubKeyTypes) { + writer.uint32(10).string(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ValidatorParams { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseValidatorParams } as ValidatorParams; + message.pubKeyTypes = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.pubKeyTypes.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ValidatorParams { + const message = { ...baseValidatorParams } as ValidatorParams; + message.pubKeyTypes = []; + if (object.pubKeyTypes !== undefined && object.pubKeyTypes !== null) { + for (const e of object.pubKeyTypes) { + message.pubKeyTypes.push(String(e)); + } + } + return message; + }, + + toJSON(message: ValidatorParams): unknown { + const obj: any = {}; + if (message.pubKeyTypes) { + obj.pubKeyTypes = message.pubKeyTypes.map((e) => e); + } else { + obj.pubKeyTypes = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): ValidatorParams { + const message = { ...baseValidatorParams } as ValidatorParams; + message.pubKeyTypes = []; + if (object.pubKeyTypes !== undefined && object.pubKeyTypes !== null) { + for (const e of object.pubKeyTypes) { + message.pubKeyTypes.push(e); + } + } + return message; + }, +}; + +const baseVersionParams: object = { appVersion: 0 }; + +export const VersionParams = { + encode(message: VersionParams, writer: Writer = Writer.create()): Writer { + if (message.appVersion !== 0) { + writer.uint32(8).uint64(message.appVersion); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): VersionParams { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseVersionParams } as VersionParams; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.appVersion = longToNumber(reader.uint64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): VersionParams { + const message = { ...baseVersionParams } as VersionParams; + if (object.appVersion !== undefined && object.appVersion !== null) { + message.appVersion = Number(object.appVersion); + } else { + message.appVersion = 0; + } + return message; + }, + + toJSON(message: VersionParams): unknown { + const obj: any = {}; + message.appVersion !== undefined && (obj.appVersion = message.appVersion); + return obj; + }, + + fromPartial(object: DeepPartial): VersionParams { + const message = { ...baseVersionParams } as VersionParams; + if (object.appVersion !== undefined && object.appVersion !== null) { + message.appVersion = object.appVersion; + } else { + message.appVersion = 0; + } + return message; + }, +}; + +const baseHashedParams: object = { blockMaxBytes: 0, blockMaxGas: 0 }; + +export const HashedParams = { + encode(message: HashedParams, writer: Writer = Writer.create()): Writer { + if (message.blockMaxBytes !== 0) { + writer.uint32(8).int64(message.blockMaxBytes); + } + if (message.blockMaxGas !== 0) { + writer.uint32(16).int64(message.blockMaxGas); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): HashedParams { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseHashedParams } as HashedParams; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.blockMaxBytes = longToNumber(reader.int64() as Long); + break; + case 2: + message.blockMaxGas = longToNumber(reader.int64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): HashedParams { + const message = { ...baseHashedParams } as HashedParams; + if (object.blockMaxBytes !== undefined && object.blockMaxBytes !== null) { + message.blockMaxBytes = Number(object.blockMaxBytes); + } else { + message.blockMaxBytes = 0; + } + if (object.blockMaxGas !== undefined && object.blockMaxGas !== null) { + message.blockMaxGas = Number(object.blockMaxGas); + } else { + message.blockMaxGas = 0; + } + return message; + }, + + toJSON(message: HashedParams): unknown { + const obj: any = {}; + message.blockMaxBytes !== undefined && + (obj.blockMaxBytes = message.blockMaxBytes); + message.blockMaxGas !== undefined && + (obj.blockMaxGas = message.blockMaxGas); + return obj; + }, + + fromPartial(object: DeepPartial): HashedParams { + const message = { ...baseHashedParams } as HashedParams; + if (object.blockMaxBytes !== undefined && object.blockMaxBytes !== null) { + message.blockMaxBytes = object.blockMaxBytes; + } else { + message.blockMaxBytes = 0; + } + if (object.blockMaxGas !== undefined && object.blockMaxGas !== null) { + message.blockMaxGas = object.blockMaxGas; + } else { + message.blockMaxGas = 0; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/cosmos.authz.v1beta1/types/tendermint/types/types.ts b/ts-client/cosmos.authz.v1beta1/types/tendermint/types/types.ts new file mode 100644 index 00000000..429c14a4 --- /dev/null +++ b/ts-client/cosmos.authz.v1beta1/types/tendermint/types/types.ts @@ -0,0 +1,1912 @@ +/* eslint-disable */ +import { Timestamp } from "../../google/protobuf/timestamp"; +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; +import { Proof } from "../../tendermint/crypto/proof"; +import { Consensus } from "../../tendermint/version/types"; +import { ValidatorSet } from "../../tendermint/types/validator"; + +export const protobufPackage = "tendermint.types"; + +/** BlockIdFlag indicates which BlcokID the signature is for */ +export enum BlockIDFlag { + BLOCK_ID_FLAG_UNKNOWN = 0, + BLOCK_ID_FLAG_ABSENT = 1, + BLOCK_ID_FLAG_COMMIT = 2, + BLOCK_ID_FLAG_NIL = 3, + UNRECOGNIZED = -1, +} + +export function blockIDFlagFromJSON(object: any): BlockIDFlag { + switch (object) { + case 0: + case "BLOCK_ID_FLAG_UNKNOWN": + return BlockIDFlag.BLOCK_ID_FLAG_UNKNOWN; + case 1: + case "BLOCK_ID_FLAG_ABSENT": + return BlockIDFlag.BLOCK_ID_FLAG_ABSENT; + case 2: + case "BLOCK_ID_FLAG_COMMIT": + return BlockIDFlag.BLOCK_ID_FLAG_COMMIT; + case 3: + case "BLOCK_ID_FLAG_NIL": + return BlockIDFlag.BLOCK_ID_FLAG_NIL; + case -1: + case "UNRECOGNIZED": + default: + return BlockIDFlag.UNRECOGNIZED; + } +} + +export function blockIDFlagToJSON(object: BlockIDFlag): string { + switch (object) { + case BlockIDFlag.BLOCK_ID_FLAG_UNKNOWN: + return "BLOCK_ID_FLAG_UNKNOWN"; + case BlockIDFlag.BLOCK_ID_FLAG_ABSENT: + return "BLOCK_ID_FLAG_ABSENT"; + case BlockIDFlag.BLOCK_ID_FLAG_COMMIT: + return "BLOCK_ID_FLAG_COMMIT"; + case BlockIDFlag.BLOCK_ID_FLAG_NIL: + return "BLOCK_ID_FLAG_NIL"; + default: + return "UNKNOWN"; + } +} + +/** SignedMsgType is a type of signed message in the consensus. */ +export enum SignedMsgType { + SIGNED_MSG_TYPE_UNKNOWN = 0, + /** SIGNED_MSG_TYPE_PREVOTE - Votes */ + SIGNED_MSG_TYPE_PREVOTE = 1, + SIGNED_MSG_TYPE_PRECOMMIT = 2, + /** SIGNED_MSG_TYPE_PROPOSAL - Proposals */ + SIGNED_MSG_TYPE_PROPOSAL = 32, + UNRECOGNIZED = -1, +} + +export function signedMsgTypeFromJSON(object: any): SignedMsgType { + switch (object) { + case 0: + case "SIGNED_MSG_TYPE_UNKNOWN": + return SignedMsgType.SIGNED_MSG_TYPE_UNKNOWN; + case 1: + case "SIGNED_MSG_TYPE_PREVOTE": + return SignedMsgType.SIGNED_MSG_TYPE_PREVOTE; + case 2: + case "SIGNED_MSG_TYPE_PRECOMMIT": + return SignedMsgType.SIGNED_MSG_TYPE_PRECOMMIT; + case 32: + case "SIGNED_MSG_TYPE_PROPOSAL": + return SignedMsgType.SIGNED_MSG_TYPE_PROPOSAL; + case -1: + case "UNRECOGNIZED": + default: + return SignedMsgType.UNRECOGNIZED; + } +} + +export function signedMsgTypeToJSON(object: SignedMsgType): string { + switch (object) { + case SignedMsgType.SIGNED_MSG_TYPE_UNKNOWN: + return "SIGNED_MSG_TYPE_UNKNOWN"; + case SignedMsgType.SIGNED_MSG_TYPE_PREVOTE: + return "SIGNED_MSG_TYPE_PREVOTE"; + case SignedMsgType.SIGNED_MSG_TYPE_PRECOMMIT: + return "SIGNED_MSG_TYPE_PRECOMMIT"; + case SignedMsgType.SIGNED_MSG_TYPE_PROPOSAL: + return "SIGNED_MSG_TYPE_PROPOSAL"; + default: + return "UNKNOWN"; + } +} + +/** PartsetHeader */ +export interface PartSetHeader { + total: number; + hash: Uint8Array; +} + +export interface Part { + index: number; + bytes: Uint8Array; + proof: Proof | undefined; +} + +/** BlockID */ +export interface BlockID { + hash: Uint8Array; + partSetHeader: PartSetHeader | undefined; +} + +/** Header defines the structure of a block header. */ +export interface Header { + /** basic block info */ + version: Consensus | undefined; + chainId: string; + height: number; + time: Date | undefined; + /** prev block info */ + lastBlockId: BlockID | undefined; + /** hashes of block data */ + lastCommitHash: Uint8Array; + /** transactions */ + dataHash: Uint8Array; + /** hashes from the app output from the prev block */ + validatorsHash: Uint8Array; + /** validators for the next block */ + nextValidatorsHash: Uint8Array; + /** consensus params for current block */ + consensusHash: Uint8Array; + /** state after txs from the previous block */ + appHash: Uint8Array; + /** root hash of all results from the txs from the previous block */ + lastResultsHash: Uint8Array; + /** consensus info */ + evidenceHash: Uint8Array; + /** original proposer of the block */ + proposerAddress: Uint8Array; +} + +/** Data contains the set of transactions included in the block */ +export interface Data { + /** + * Txs that will be applied by state @ block.Height+1. + * NOTE: not all txs here are valid. We're just agreeing on the order first. + * This means that block.AppHash does not include these txs. + */ + txs: Uint8Array[]; +} + +/** + * Vote represents a prevote, precommit, or commit vote from validators for + * consensus. + */ +export interface Vote { + type: SignedMsgType; + height: number; + round: number; + /** zero if vote is nil. */ + blockId: BlockID | undefined; + timestamp: Date | undefined; + validatorAddress: Uint8Array; + validatorIndex: number; + signature: Uint8Array; +} + +/** Commit contains the evidence that a block was committed by a set of validators. */ +export interface Commit { + height: number; + round: number; + blockId: BlockID | undefined; + signatures: CommitSig[]; +} + +/** CommitSig is a part of the Vote included in a Commit. */ +export interface CommitSig { + blockIdFlag: BlockIDFlag; + validatorAddress: Uint8Array; + timestamp: Date | undefined; + signature: Uint8Array; +} + +export interface Proposal { + type: SignedMsgType; + height: number; + round: number; + polRound: number; + blockId: BlockID | undefined; + timestamp: Date | undefined; + signature: Uint8Array; +} + +export interface SignedHeader { + header: Header | undefined; + commit: Commit | undefined; +} + +export interface LightBlock { + signedHeader: SignedHeader | undefined; + validatorSet: ValidatorSet | undefined; +} + +export interface BlockMeta { + blockId: BlockID | undefined; + blockSize: number; + header: Header | undefined; + numTxs: number; +} + +/** TxProof represents a Merkle proof of the presence of a transaction in the Merkle tree. */ +export interface TxProof { + rootHash: Uint8Array; + data: Uint8Array; + proof: Proof | undefined; +} + +const basePartSetHeader: object = { total: 0 }; + +export const PartSetHeader = { + encode(message: PartSetHeader, writer: Writer = Writer.create()): Writer { + if (message.total !== 0) { + writer.uint32(8).uint32(message.total); + } + if (message.hash.length !== 0) { + writer.uint32(18).bytes(message.hash); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): PartSetHeader { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...basePartSetHeader } as PartSetHeader; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.total = reader.uint32(); + break; + case 2: + message.hash = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): PartSetHeader { + const message = { ...basePartSetHeader } as PartSetHeader; + if (object.total !== undefined && object.total !== null) { + message.total = Number(object.total); + } else { + message.total = 0; + } + if (object.hash !== undefined && object.hash !== null) { + message.hash = bytesFromBase64(object.hash); + } + return message; + }, + + toJSON(message: PartSetHeader): unknown { + const obj: any = {}; + message.total !== undefined && (obj.total = message.total); + message.hash !== undefined && + (obj.hash = base64FromBytes( + message.hash !== undefined ? message.hash : new Uint8Array() + )); + return obj; + }, + + fromPartial(object: DeepPartial): PartSetHeader { + const message = { ...basePartSetHeader } as PartSetHeader; + if (object.total !== undefined && object.total !== null) { + message.total = object.total; + } else { + message.total = 0; + } + if (object.hash !== undefined && object.hash !== null) { + message.hash = object.hash; + } else { + message.hash = new Uint8Array(); + } + return message; + }, +}; + +const basePart: object = { index: 0 }; + +export const Part = { + encode(message: Part, writer: Writer = Writer.create()): Writer { + if (message.index !== 0) { + writer.uint32(8).uint32(message.index); + } + if (message.bytes.length !== 0) { + writer.uint32(18).bytes(message.bytes); + } + if (message.proof !== undefined) { + Proof.encode(message.proof, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Part { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...basePart } as Part; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.index = reader.uint32(); + break; + case 2: + message.bytes = reader.bytes(); + break; + case 3: + message.proof = Proof.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Part { + const message = { ...basePart } as Part; + if (object.index !== undefined && object.index !== null) { + message.index = Number(object.index); + } else { + message.index = 0; + } + if (object.bytes !== undefined && object.bytes !== null) { + message.bytes = bytesFromBase64(object.bytes); + } + if (object.proof !== undefined && object.proof !== null) { + message.proof = Proof.fromJSON(object.proof); + } else { + message.proof = undefined; + } + return message; + }, + + toJSON(message: Part): unknown { + const obj: any = {}; + message.index !== undefined && (obj.index = message.index); + message.bytes !== undefined && + (obj.bytes = base64FromBytes( + message.bytes !== undefined ? message.bytes : new Uint8Array() + )); + message.proof !== undefined && + (obj.proof = message.proof ? Proof.toJSON(message.proof) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): Part { + const message = { ...basePart } as Part; + if (object.index !== undefined && object.index !== null) { + message.index = object.index; + } else { + message.index = 0; + } + if (object.bytes !== undefined && object.bytes !== null) { + message.bytes = object.bytes; + } else { + message.bytes = new Uint8Array(); + } + if (object.proof !== undefined && object.proof !== null) { + message.proof = Proof.fromPartial(object.proof); + } else { + message.proof = undefined; + } + return message; + }, +}; + +const baseBlockID: object = {}; + +export const BlockID = { + encode(message: BlockID, writer: Writer = Writer.create()): Writer { + if (message.hash.length !== 0) { + writer.uint32(10).bytes(message.hash); + } + if (message.partSetHeader !== undefined) { + PartSetHeader.encode( + message.partSetHeader, + writer.uint32(18).fork() + ).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): BlockID { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseBlockID } as BlockID; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.hash = reader.bytes(); + break; + case 2: + message.partSetHeader = PartSetHeader.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): BlockID { + const message = { ...baseBlockID } as BlockID; + if (object.hash !== undefined && object.hash !== null) { + message.hash = bytesFromBase64(object.hash); + } + if (object.partSetHeader !== undefined && object.partSetHeader !== null) { + message.partSetHeader = PartSetHeader.fromJSON(object.partSetHeader); + } else { + message.partSetHeader = undefined; + } + return message; + }, + + toJSON(message: BlockID): unknown { + const obj: any = {}; + message.hash !== undefined && + (obj.hash = base64FromBytes( + message.hash !== undefined ? message.hash : new Uint8Array() + )); + message.partSetHeader !== undefined && + (obj.partSetHeader = message.partSetHeader + ? PartSetHeader.toJSON(message.partSetHeader) + : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): BlockID { + const message = { ...baseBlockID } as BlockID; + if (object.hash !== undefined && object.hash !== null) { + message.hash = object.hash; + } else { + message.hash = new Uint8Array(); + } + if (object.partSetHeader !== undefined && object.partSetHeader !== null) { + message.partSetHeader = PartSetHeader.fromPartial(object.partSetHeader); + } else { + message.partSetHeader = undefined; + } + return message; + }, +}; + +const baseHeader: object = { chainId: "", height: 0 }; + +export const Header = { + encode(message: Header, writer: Writer = Writer.create()): Writer { + if (message.version !== undefined) { + Consensus.encode(message.version, writer.uint32(10).fork()).ldelim(); + } + if (message.chainId !== "") { + writer.uint32(18).string(message.chainId); + } + if (message.height !== 0) { + writer.uint32(24).int64(message.height); + } + if (message.time !== undefined) { + Timestamp.encode( + toTimestamp(message.time), + writer.uint32(34).fork() + ).ldelim(); + } + if (message.lastBlockId !== undefined) { + BlockID.encode(message.lastBlockId, writer.uint32(42).fork()).ldelim(); + } + if (message.lastCommitHash.length !== 0) { + writer.uint32(50).bytes(message.lastCommitHash); + } + if (message.dataHash.length !== 0) { + writer.uint32(58).bytes(message.dataHash); + } + if (message.validatorsHash.length !== 0) { + writer.uint32(66).bytes(message.validatorsHash); + } + if (message.nextValidatorsHash.length !== 0) { + writer.uint32(74).bytes(message.nextValidatorsHash); + } + if (message.consensusHash.length !== 0) { + writer.uint32(82).bytes(message.consensusHash); + } + if (message.appHash.length !== 0) { + writer.uint32(90).bytes(message.appHash); + } + if (message.lastResultsHash.length !== 0) { + writer.uint32(98).bytes(message.lastResultsHash); + } + if (message.evidenceHash.length !== 0) { + writer.uint32(106).bytes(message.evidenceHash); + } + if (message.proposerAddress.length !== 0) { + writer.uint32(114).bytes(message.proposerAddress); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Header { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseHeader } as Header; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.version = Consensus.decode(reader, reader.uint32()); + break; + case 2: + message.chainId = reader.string(); + break; + case 3: + message.height = longToNumber(reader.int64() as Long); + break; + case 4: + message.time = fromTimestamp( + Timestamp.decode(reader, reader.uint32()) + ); + break; + case 5: + message.lastBlockId = BlockID.decode(reader, reader.uint32()); + break; + case 6: + message.lastCommitHash = reader.bytes(); + break; + case 7: + message.dataHash = reader.bytes(); + break; + case 8: + message.validatorsHash = reader.bytes(); + break; + case 9: + message.nextValidatorsHash = reader.bytes(); + break; + case 10: + message.consensusHash = reader.bytes(); + break; + case 11: + message.appHash = reader.bytes(); + break; + case 12: + message.lastResultsHash = reader.bytes(); + break; + case 13: + message.evidenceHash = reader.bytes(); + break; + case 14: + message.proposerAddress = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Header { + const message = { ...baseHeader } as Header; + if (object.version !== undefined && object.version !== null) { + message.version = Consensus.fromJSON(object.version); + } else { + message.version = undefined; + } + if (object.chainId !== undefined && object.chainId !== null) { + message.chainId = String(object.chainId); + } else { + message.chainId = ""; + } + if (object.height !== undefined && object.height !== null) { + message.height = Number(object.height); + } else { + message.height = 0; + } + if (object.time !== undefined && object.time !== null) { + message.time = fromJsonTimestamp(object.time); + } else { + message.time = undefined; + } + if (object.lastBlockId !== undefined && object.lastBlockId !== null) { + message.lastBlockId = BlockID.fromJSON(object.lastBlockId); + } else { + message.lastBlockId = undefined; + } + if (object.lastCommitHash !== undefined && object.lastCommitHash !== null) { + message.lastCommitHash = bytesFromBase64(object.lastCommitHash); + } + if (object.dataHash !== undefined && object.dataHash !== null) { + message.dataHash = bytesFromBase64(object.dataHash); + } + if (object.validatorsHash !== undefined && object.validatorsHash !== null) { + message.validatorsHash = bytesFromBase64(object.validatorsHash); + } + if ( + object.nextValidatorsHash !== undefined && + object.nextValidatorsHash !== null + ) { + message.nextValidatorsHash = bytesFromBase64(object.nextValidatorsHash); + } + if (object.consensusHash !== undefined && object.consensusHash !== null) { + message.consensusHash = bytesFromBase64(object.consensusHash); + } + if (object.appHash !== undefined && object.appHash !== null) { + message.appHash = bytesFromBase64(object.appHash); + } + if ( + object.lastResultsHash !== undefined && + object.lastResultsHash !== null + ) { + message.lastResultsHash = bytesFromBase64(object.lastResultsHash); + } + if (object.evidenceHash !== undefined && object.evidenceHash !== null) { + message.evidenceHash = bytesFromBase64(object.evidenceHash); + } + if ( + object.proposerAddress !== undefined && + object.proposerAddress !== null + ) { + message.proposerAddress = bytesFromBase64(object.proposerAddress); + } + return message; + }, + + toJSON(message: Header): unknown { + const obj: any = {}; + message.version !== undefined && + (obj.version = message.version + ? Consensus.toJSON(message.version) + : undefined); + message.chainId !== undefined && (obj.chainId = message.chainId); + message.height !== undefined && (obj.height = message.height); + message.time !== undefined && + (obj.time = + message.time !== undefined ? message.time.toISOString() : null); + message.lastBlockId !== undefined && + (obj.lastBlockId = message.lastBlockId + ? BlockID.toJSON(message.lastBlockId) + : undefined); + message.lastCommitHash !== undefined && + (obj.lastCommitHash = base64FromBytes( + message.lastCommitHash !== undefined + ? message.lastCommitHash + : new Uint8Array() + )); + message.dataHash !== undefined && + (obj.dataHash = base64FromBytes( + message.dataHash !== undefined ? message.dataHash : new Uint8Array() + )); + message.validatorsHash !== undefined && + (obj.validatorsHash = base64FromBytes( + message.validatorsHash !== undefined + ? message.validatorsHash + : new Uint8Array() + )); + message.nextValidatorsHash !== undefined && + (obj.nextValidatorsHash = base64FromBytes( + message.nextValidatorsHash !== undefined + ? message.nextValidatorsHash + : new Uint8Array() + )); + message.consensusHash !== undefined && + (obj.consensusHash = base64FromBytes( + message.consensusHash !== undefined + ? message.consensusHash + : new Uint8Array() + )); + message.appHash !== undefined && + (obj.appHash = base64FromBytes( + message.appHash !== undefined ? message.appHash : new Uint8Array() + )); + message.lastResultsHash !== undefined && + (obj.lastResultsHash = base64FromBytes( + message.lastResultsHash !== undefined + ? message.lastResultsHash + : new Uint8Array() + )); + message.evidenceHash !== undefined && + (obj.evidenceHash = base64FromBytes( + message.evidenceHash !== undefined + ? message.evidenceHash + : new Uint8Array() + )); + message.proposerAddress !== undefined && + (obj.proposerAddress = base64FromBytes( + message.proposerAddress !== undefined + ? message.proposerAddress + : new Uint8Array() + )); + return obj; + }, + + fromPartial(object: DeepPartial
): Header { + const message = { ...baseHeader } as Header; + if (object.version !== undefined && object.version !== null) { + message.version = Consensus.fromPartial(object.version); + } else { + message.version = undefined; + } + if (object.chainId !== undefined && object.chainId !== null) { + message.chainId = object.chainId; + } else { + message.chainId = ""; + } + if (object.height !== undefined && object.height !== null) { + message.height = object.height; + } else { + message.height = 0; + } + if (object.time !== undefined && object.time !== null) { + message.time = object.time; + } else { + message.time = undefined; + } + if (object.lastBlockId !== undefined && object.lastBlockId !== null) { + message.lastBlockId = BlockID.fromPartial(object.lastBlockId); + } else { + message.lastBlockId = undefined; + } + if (object.lastCommitHash !== undefined && object.lastCommitHash !== null) { + message.lastCommitHash = object.lastCommitHash; + } else { + message.lastCommitHash = new Uint8Array(); + } + if (object.dataHash !== undefined && object.dataHash !== null) { + message.dataHash = object.dataHash; + } else { + message.dataHash = new Uint8Array(); + } + if (object.validatorsHash !== undefined && object.validatorsHash !== null) { + message.validatorsHash = object.validatorsHash; + } else { + message.validatorsHash = new Uint8Array(); + } + if ( + object.nextValidatorsHash !== undefined && + object.nextValidatorsHash !== null + ) { + message.nextValidatorsHash = object.nextValidatorsHash; + } else { + message.nextValidatorsHash = new Uint8Array(); + } + if (object.consensusHash !== undefined && object.consensusHash !== null) { + message.consensusHash = object.consensusHash; + } else { + message.consensusHash = new Uint8Array(); + } + if (object.appHash !== undefined && object.appHash !== null) { + message.appHash = object.appHash; + } else { + message.appHash = new Uint8Array(); + } + if ( + object.lastResultsHash !== undefined && + object.lastResultsHash !== null + ) { + message.lastResultsHash = object.lastResultsHash; + } else { + message.lastResultsHash = new Uint8Array(); + } + if (object.evidenceHash !== undefined && object.evidenceHash !== null) { + message.evidenceHash = object.evidenceHash; + } else { + message.evidenceHash = new Uint8Array(); + } + if ( + object.proposerAddress !== undefined && + object.proposerAddress !== null + ) { + message.proposerAddress = object.proposerAddress; + } else { + message.proposerAddress = new Uint8Array(); + } + return message; + }, +}; + +const baseData: object = {}; + +export const Data = { + encode(message: Data, writer: Writer = Writer.create()): Writer { + for (const v of message.txs) { + writer.uint32(10).bytes(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Data { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseData } as Data; + message.txs = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.txs.push(reader.bytes()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Data { + const message = { ...baseData } as Data; + message.txs = []; + if (object.txs !== undefined && object.txs !== null) { + for (const e of object.txs) { + message.txs.push(bytesFromBase64(e)); + } + } + return message; + }, + + toJSON(message: Data): unknown { + const obj: any = {}; + if (message.txs) { + obj.txs = message.txs.map((e) => + base64FromBytes(e !== undefined ? e : new Uint8Array()) + ); + } else { + obj.txs = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): Data { + const message = { ...baseData } as Data; + message.txs = []; + if (object.txs !== undefined && object.txs !== null) { + for (const e of object.txs) { + message.txs.push(e); + } + } + return message; + }, +}; + +const baseVote: object = { type: 0, height: 0, round: 0, validatorIndex: 0 }; + +export const Vote = { + encode(message: Vote, writer: Writer = Writer.create()): Writer { + if (message.type !== 0) { + writer.uint32(8).int32(message.type); + } + if (message.height !== 0) { + writer.uint32(16).int64(message.height); + } + if (message.round !== 0) { + writer.uint32(24).int32(message.round); + } + if (message.blockId !== undefined) { + BlockID.encode(message.blockId, writer.uint32(34).fork()).ldelim(); + } + if (message.timestamp !== undefined) { + Timestamp.encode( + toTimestamp(message.timestamp), + writer.uint32(42).fork() + ).ldelim(); + } + if (message.validatorAddress.length !== 0) { + writer.uint32(50).bytes(message.validatorAddress); + } + if (message.validatorIndex !== 0) { + writer.uint32(56).int32(message.validatorIndex); + } + if (message.signature.length !== 0) { + writer.uint32(66).bytes(message.signature); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Vote { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseVote } as Vote; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.type = reader.int32() as any; + break; + case 2: + message.height = longToNumber(reader.int64() as Long); + break; + case 3: + message.round = reader.int32(); + break; + case 4: + message.blockId = BlockID.decode(reader, reader.uint32()); + break; + case 5: + message.timestamp = fromTimestamp( + Timestamp.decode(reader, reader.uint32()) + ); + break; + case 6: + message.validatorAddress = reader.bytes(); + break; + case 7: + message.validatorIndex = reader.int32(); + break; + case 8: + message.signature = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Vote { + const message = { ...baseVote } as Vote; + if (object.type !== undefined && object.type !== null) { + message.type = signedMsgTypeFromJSON(object.type); + } else { + message.type = 0; + } + if (object.height !== undefined && object.height !== null) { + message.height = Number(object.height); + } else { + message.height = 0; + } + if (object.round !== undefined && object.round !== null) { + message.round = Number(object.round); + } else { + message.round = 0; + } + if (object.blockId !== undefined && object.blockId !== null) { + message.blockId = BlockID.fromJSON(object.blockId); + } else { + message.blockId = undefined; + } + if (object.timestamp !== undefined && object.timestamp !== null) { + message.timestamp = fromJsonTimestamp(object.timestamp); + } else { + message.timestamp = undefined; + } + if ( + object.validatorAddress !== undefined && + object.validatorAddress !== null + ) { + message.validatorAddress = bytesFromBase64(object.validatorAddress); + } + if (object.validatorIndex !== undefined && object.validatorIndex !== null) { + message.validatorIndex = Number(object.validatorIndex); + } else { + message.validatorIndex = 0; + } + if (object.signature !== undefined && object.signature !== null) { + message.signature = bytesFromBase64(object.signature); + } + return message; + }, + + toJSON(message: Vote): unknown { + const obj: any = {}; + message.type !== undefined && + (obj.type = signedMsgTypeToJSON(message.type)); + message.height !== undefined && (obj.height = message.height); + message.round !== undefined && (obj.round = message.round); + message.blockId !== undefined && + (obj.blockId = message.blockId + ? BlockID.toJSON(message.blockId) + : undefined); + message.timestamp !== undefined && + (obj.timestamp = + message.timestamp !== undefined + ? message.timestamp.toISOString() + : null); + message.validatorAddress !== undefined && + (obj.validatorAddress = base64FromBytes( + message.validatorAddress !== undefined + ? message.validatorAddress + : new Uint8Array() + )); + message.validatorIndex !== undefined && + (obj.validatorIndex = message.validatorIndex); + message.signature !== undefined && + (obj.signature = base64FromBytes( + message.signature !== undefined ? message.signature : new Uint8Array() + )); + return obj; + }, + + fromPartial(object: DeepPartial): Vote { + const message = { ...baseVote } as Vote; + if (object.type !== undefined && object.type !== null) { + message.type = object.type; + } else { + message.type = 0; + } + if (object.height !== undefined && object.height !== null) { + message.height = object.height; + } else { + message.height = 0; + } + if (object.round !== undefined && object.round !== null) { + message.round = object.round; + } else { + message.round = 0; + } + if (object.blockId !== undefined && object.blockId !== null) { + message.blockId = BlockID.fromPartial(object.blockId); + } else { + message.blockId = undefined; + } + if (object.timestamp !== undefined && object.timestamp !== null) { + message.timestamp = object.timestamp; + } else { + message.timestamp = undefined; + } + if ( + object.validatorAddress !== undefined && + object.validatorAddress !== null + ) { + message.validatorAddress = object.validatorAddress; + } else { + message.validatorAddress = new Uint8Array(); + } + if (object.validatorIndex !== undefined && object.validatorIndex !== null) { + message.validatorIndex = object.validatorIndex; + } else { + message.validatorIndex = 0; + } + if (object.signature !== undefined && object.signature !== null) { + message.signature = object.signature; + } else { + message.signature = new Uint8Array(); + } + return message; + }, +}; + +const baseCommit: object = { height: 0, round: 0 }; + +export const Commit = { + encode(message: Commit, writer: Writer = Writer.create()): Writer { + if (message.height !== 0) { + writer.uint32(8).int64(message.height); + } + if (message.round !== 0) { + writer.uint32(16).int32(message.round); + } + if (message.blockId !== undefined) { + BlockID.encode(message.blockId, writer.uint32(26).fork()).ldelim(); + } + for (const v of message.signatures) { + CommitSig.encode(v!, writer.uint32(34).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Commit { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseCommit } as Commit; + message.signatures = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.height = longToNumber(reader.int64() as Long); + break; + case 2: + message.round = reader.int32(); + break; + case 3: + message.blockId = BlockID.decode(reader, reader.uint32()); + break; + case 4: + message.signatures.push(CommitSig.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Commit { + const message = { ...baseCommit } as Commit; + message.signatures = []; + if (object.height !== undefined && object.height !== null) { + message.height = Number(object.height); + } else { + message.height = 0; + } + if (object.round !== undefined && object.round !== null) { + message.round = Number(object.round); + } else { + message.round = 0; + } + if (object.blockId !== undefined && object.blockId !== null) { + message.blockId = BlockID.fromJSON(object.blockId); + } else { + message.blockId = undefined; + } + if (object.signatures !== undefined && object.signatures !== null) { + for (const e of object.signatures) { + message.signatures.push(CommitSig.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: Commit): unknown { + const obj: any = {}; + message.height !== undefined && (obj.height = message.height); + message.round !== undefined && (obj.round = message.round); + message.blockId !== undefined && + (obj.blockId = message.blockId + ? BlockID.toJSON(message.blockId) + : undefined); + if (message.signatures) { + obj.signatures = message.signatures.map((e) => + e ? CommitSig.toJSON(e) : undefined + ); + } else { + obj.signatures = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): Commit { + const message = { ...baseCommit } as Commit; + message.signatures = []; + if (object.height !== undefined && object.height !== null) { + message.height = object.height; + } else { + message.height = 0; + } + if (object.round !== undefined && object.round !== null) { + message.round = object.round; + } else { + message.round = 0; + } + if (object.blockId !== undefined && object.blockId !== null) { + message.blockId = BlockID.fromPartial(object.blockId); + } else { + message.blockId = undefined; + } + if (object.signatures !== undefined && object.signatures !== null) { + for (const e of object.signatures) { + message.signatures.push(CommitSig.fromPartial(e)); + } + } + return message; + }, +}; + +const baseCommitSig: object = { blockIdFlag: 0 }; + +export const CommitSig = { + encode(message: CommitSig, writer: Writer = Writer.create()): Writer { + if (message.blockIdFlag !== 0) { + writer.uint32(8).int32(message.blockIdFlag); + } + if (message.validatorAddress.length !== 0) { + writer.uint32(18).bytes(message.validatorAddress); + } + if (message.timestamp !== undefined) { + Timestamp.encode( + toTimestamp(message.timestamp), + writer.uint32(26).fork() + ).ldelim(); + } + if (message.signature.length !== 0) { + writer.uint32(34).bytes(message.signature); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): CommitSig { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseCommitSig } as CommitSig; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.blockIdFlag = reader.int32() as any; + break; + case 2: + message.validatorAddress = reader.bytes(); + break; + case 3: + message.timestamp = fromTimestamp( + Timestamp.decode(reader, reader.uint32()) + ); + break; + case 4: + message.signature = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): CommitSig { + const message = { ...baseCommitSig } as CommitSig; + if (object.blockIdFlag !== undefined && object.blockIdFlag !== null) { + message.blockIdFlag = blockIDFlagFromJSON(object.blockIdFlag); + } else { + message.blockIdFlag = 0; + } + if ( + object.validatorAddress !== undefined && + object.validatorAddress !== null + ) { + message.validatorAddress = bytesFromBase64(object.validatorAddress); + } + if (object.timestamp !== undefined && object.timestamp !== null) { + message.timestamp = fromJsonTimestamp(object.timestamp); + } else { + message.timestamp = undefined; + } + if (object.signature !== undefined && object.signature !== null) { + message.signature = bytesFromBase64(object.signature); + } + return message; + }, + + toJSON(message: CommitSig): unknown { + const obj: any = {}; + message.blockIdFlag !== undefined && + (obj.blockIdFlag = blockIDFlagToJSON(message.blockIdFlag)); + message.validatorAddress !== undefined && + (obj.validatorAddress = base64FromBytes( + message.validatorAddress !== undefined + ? message.validatorAddress + : new Uint8Array() + )); + message.timestamp !== undefined && + (obj.timestamp = + message.timestamp !== undefined + ? message.timestamp.toISOString() + : null); + message.signature !== undefined && + (obj.signature = base64FromBytes( + message.signature !== undefined ? message.signature : new Uint8Array() + )); + return obj; + }, + + fromPartial(object: DeepPartial): CommitSig { + const message = { ...baseCommitSig } as CommitSig; + if (object.blockIdFlag !== undefined && object.blockIdFlag !== null) { + message.blockIdFlag = object.blockIdFlag; + } else { + message.blockIdFlag = 0; + } + if ( + object.validatorAddress !== undefined && + object.validatorAddress !== null + ) { + message.validatorAddress = object.validatorAddress; + } else { + message.validatorAddress = new Uint8Array(); + } + if (object.timestamp !== undefined && object.timestamp !== null) { + message.timestamp = object.timestamp; + } else { + message.timestamp = undefined; + } + if (object.signature !== undefined && object.signature !== null) { + message.signature = object.signature; + } else { + message.signature = new Uint8Array(); + } + return message; + }, +}; + +const baseProposal: object = { type: 0, height: 0, round: 0, polRound: 0 }; + +export const Proposal = { + encode(message: Proposal, writer: Writer = Writer.create()): Writer { + if (message.type !== 0) { + writer.uint32(8).int32(message.type); + } + if (message.height !== 0) { + writer.uint32(16).int64(message.height); + } + if (message.round !== 0) { + writer.uint32(24).int32(message.round); + } + if (message.polRound !== 0) { + writer.uint32(32).int32(message.polRound); + } + if (message.blockId !== undefined) { + BlockID.encode(message.blockId, writer.uint32(42).fork()).ldelim(); + } + if (message.timestamp !== undefined) { + Timestamp.encode( + toTimestamp(message.timestamp), + writer.uint32(50).fork() + ).ldelim(); + } + if (message.signature.length !== 0) { + writer.uint32(58).bytes(message.signature); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Proposal { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseProposal } as Proposal; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.type = reader.int32() as any; + break; + case 2: + message.height = longToNumber(reader.int64() as Long); + break; + case 3: + message.round = reader.int32(); + break; + case 4: + message.polRound = reader.int32(); + break; + case 5: + message.blockId = BlockID.decode(reader, reader.uint32()); + break; + case 6: + message.timestamp = fromTimestamp( + Timestamp.decode(reader, reader.uint32()) + ); + break; + case 7: + message.signature = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Proposal { + const message = { ...baseProposal } as Proposal; + if (object.type !== undefined && object.type !== null) { + message.type = signedMsgTypeFromJSON(object.type); + } else { + message.type = 0; + } + if (object.height !== undefined && object.height !== null) { + message.height = Number(object.height); + } else { + message.height = 0; + } + if (object.round !== undefined && object.round !== null) { + message.round = Number(object.round); + } else { + message.round = 0; + } + if (object.polRound !== undefined && object.polRound !== null) { + message.polRound = Number(object.polRound); + } else { + message.polRound = 0; + } + if (object.blockId !== undefined && object.blockId !== null) { + message.blockId = BlockID.fromJSON(object.blockId); + } else { + message.blockId = undefined; + } + if (object.timestamp !== undefined && object.timestamp !== null) { + message.timestamp = fromJsonTimestamp(object.timestamp); + } else { + message.timestamp = undefined; + } + if (object.signature !== undefined && object.signature !== null) { + message.signature = bytesFromBase64(object.signature); + } + return message; + }, + + toJSON(message: Proposal): unknown { + const obj: any = {}; + message.type !== undefined && + (obj.type = signedMsgTypeToJSON(message.type)); + message.height !== undefined && (obj.height = message.height); + message.round !== undefined && (obj.round = message.round); + message.polRound !== undefined && (obj.polRound = message.polRound); + message.blockId !== undefined && + (obj.blockId = message.blockId + ? BlockID.toJSON(message.blockId) + : undefined); + message.timestamp !== undefined && + (obj.timestamp = + message.timestamp !== undefined + ? message.timestamp.toISOString() + : null); + message.signature !== undefined && + (obj.signature = base64FromBytes( + message.signature !== undefined ? message.signature : new Uint8Array() + )); + return obj; + }, + + fromPartial(object: DeepPartial): Proposal { + const message = { ...baseProposal } as Proposal; + if (object.type !== undefined && object.type !== null) { + message.type = object.type; + } else { + message.type = 0; + } + if (object.height !== undefined && object.height !== null) { + message.height = object.height; + } else { + message.height = 0; + } + if (object.round !== undefined && object.round !== null) { + message.round = object.round; + } else { + message.round = 0; + } + if (object.polRound !== undefined && object.polRound !== null) { + message.polRound = object.polRound; + } else { + message.polRound = 0; + } + if (object.blockId !== undefined && object.blockId !== null) { + message.blockId = BlockID.fromPartial(object.blockId); + } else { + message.blockId = undefined; + } + if (object.timestamp !== undefined && object.timestamp !== null) { + message.timestamp = object.timestamp; + } else { + message.timestamp = undefined; + } + if (object.signature !== undefined && object.signature !== null) { + message.signature = object.signature; + } else { + message.signature = new Uint8Array(); + } + return message; + }, +}; + +const baseSignedHeader: object = {}; + +export const SignedHeader = { + encode(message: SignedHeader, writer: Writer = Writer.create()): Writer { + if (message.header !== undefined) { + Header.encode(message.header, writer.uint32(10).fork()).ldelim(); + } + if (message.commit !== undefined) { + Commit.encode(message.commit, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): SignedHeader { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseSignedHeader } as SignedHeader; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.header = Header.decode(reader, reader.uint32()); + break; + case 2: + message.commit = Commit.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): SignedHeader { + const message = { ...baseSignedHeader } as SignedHeader; + if (object.header !== undefined && object.header !== null) { + message.header = Header.fromJSON(object.header); + } else { + message.header = undefined; + } + if (object.commit !== undefined && object.commit !== null) { + message.commit = Commit.fromJSON(object.commit); + } else { + message.commit = undefined; + } + return message; + }, + + toJSON(message: SignedHeader): unknown { + const obj: any = {}; + message.header !== undefined && + (obj.header = message.header ? Header.toJSON(message.header) : undefined); + message.commit !== undefined && + (obj.commit = message.commit ? Commit.toJSON(message.commit) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): SignedHeader { + const message = { ...baseSignedHeader } as SignedHeader; + if (object.header !== undefined && object.header !== null) { + message.header = Header.fromPartial(object.header); + } else { + message.header = undefined; + } + if (object.commit !== undefined && object.commit !== null) { + message.commit = Commit.fromPartial(object.commit); + } else { + message.commit = undefined; + } + return message; + }, +}; + +const baseLightBlock: object = {}; + +export const LightBlock = { + encode(message: LightBlock, writer: Writer = Writer.create()): Writer { + if (message.signedHeader !== undefined) { + SignedHeader.encode( + message.signedHeader, + writer.uint32(10).fork() + ).ldelim(); + } + if (message.validatorSet !== undefined) { + ValidatorSet.encode( + message.validatorSet, + writer.uint32(18).fork() + ).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): LightBlock { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseLightBlock } as LightBlock; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.signedHeader = SignedHeader.decode(reader, reader.uint32()); + break; + case 2: + message.validatorSet = ValidatorSet.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): LightBlock { + const message = { ...baseLightBlock } as LightBlock; + if (object.signedHeader !== undefined && object.signedHeader !== null) { + message.signedHeader = SignedHeader.fromJSON(object.signedHeader); + } else { + message.signedHeader = undefined; + } + if (object.validatorSet !== undefined && object.validatorSet !== null) { + message.validatorSet = ValidatorSet.fromJSON(object.validatorSet); + } else { + message.validatorSet = undefined; + } + return message; + }, + + toJSON(message: LightBlock): unknown { + const obj: any = {}; + message.signedHeader !== undefined && + (obj.signedHeader = message.signedHeader + ? SignedHeader.toJSON(message.signedHeader) + : undefined); + message.validatorSet !== undefined && + (obj.validatorSet = message.validatorSet + ? ValidatorSet.toJSON(message.validatorSet) + : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): LightBlock { + const message = { ...baseLightBlock } as LightBlock; + if (object.signedHeader !== undefined && object.signedHeader !== null) { + message.signedHeader = SignedHeader.fromPartial(object.signedHeader); + } else { + message.signedHeader = undefined; + } + if (object.validatorSet !== undefined && object.validatorSet !== null) { + message.validatorSet = ValidatorSet.fromPartial(object.validatorSet); + } else { + message.validatorSet = undefined; + } + return message; + }, +}; + +const baseBlockMeta: object = { blockSize: 0, numTxs: 0 }; + +export const BlockMeta = { + encode(message: BlockMeta, writer: Writer = Writer.create()): Writer { + if (message.blockId !== undefined) { + BlockID.encode(message.blockId, writer.uint32(10).fork()).ldelim(); + } + if (message.blockSize !== 0) { + writer.uint32(16).int64(message.blockSize); + } + if (message.header !== undefined) { + Header.encode(message.header, writer.uint32(26).fork()).ldelim(); + } + if (message.numTxs !== 0) { + writer.uint32(32).int64(message.numTxs); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): BlockMeta { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseBlockMeta } as BlockMeta; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.blockId = BlockID.decode(reader, reader.uint32()); + break; + case 2: + message.blockSize = longToNumber(reader.int64() as Long); + break; + case 3: + message.header = Header.decode(reader, reader.uint32()); + break; + case 4: + message.numTxs = longToNumber(reader.int64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): BlockMeta { + const message = { ...baseBlockMeta } as BlockMeta; + if (object.blockId !== undefined && object.blockId !== null) { + message.blockId = BlockID.fromJSON(object.blockId); + } else { + message.blockId = undefined; + } + if (object.blockSize !== undefined && object.blockSize !== null) { + message.blockSize = Number(object.blockSize); + } else { + message.blockSize = 0; + } + if (object.header !== undefined && object.header !== null) { + message.header = Header.fromJSON(object.header); + } else { + message.header = undefined; + } + if (object.numTxs !== undefined && object.numTxs !== null) { + message.numTxs = Number(object.numTxs); + } else { + message.numTxs = 0; + } + return message; + }, + + toJSON(message: BlockMeta): unknown { + const obj: any = {}; + message.blockId !== undefined && + (obj.blockId = message.blockId + ? BlockID.toJSON(message.blockId) + : undefined); + message.blockSize !== undefined && (obj.blockSize = message.blockSize); + message.header !== undefined && + (obj.header = message.header ? Header.toJSON(message.header) : undefined); + message.numTxs !== undefined && (obj.numTxs = message.numTxs); + return obj; + }, + + fromPartial(object: DeepPartial): BlockMeta { + const message = { ...baseBlockMeta } as BlockMeta; + if (object.blockId !== undefined && object.blockId !== null) { + message.blockId = BlockID.fromPartial(object.blockId); + } else { + message.blockId = undefined; + } + if (object.blockSize !== undefined && object.blockSize !== null) { + message.blockSize = object.blockSize; + } else { + message.blockSize = 0; + } + if (object.header !== undefined && object.header !== null) { + message.header = Header.fromPartial(object.header); + } else { + message.header = undefined; + } + if (object.numTxs !== undefined && object.numTxs !== null) { + message.numTxs = object.numTxs; + } else { + message.numTxs = 0; + } + return message; + }, +}; + +const baseTxProof: object = {}; + +export const TxProof = { + encode(message: TxProof, writer: Writer = Writer.create()): Writer { + if (message.rootHash.length !== 0) { + writer.uint32(10).bytes(message.rootHash); + } + if (message.data.length !== 0) { + writer.uint32(18).bytes(message.data); + } + if (message.proof !== undefined) { + Proof.encode(message.proof, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): TxProof { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseTxProof } as TxProof; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.rootHash = reader.bytes(); + break; + case 2: + message.data = reader.bytes(); + break; + case 3: + message.proof = Proof.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): TxProof { + const message = { ...baseTxProof } as TxProof; + if (object.rootHash !== undefined && object.rootHash !== null) { + message.rootHash = bytesFromBase64(object.rootHash); + } + if (object.data !== undefined && object.data !== null) { + message.data = bytesFromBase64(object.data); + } + if (object.proof !== undefined && object.proof !== null) { + message.proof = Proof.fromJSON(object.proof); + } else { + message.proof = undefined; + } + return message; + }, + + toJSON(message: TxProof): unknown { + const obj: any = {}; + message.rootHash !== undefined && + (obj.rootHash = base64FromBytes( + message.rootHash !== undefined ? message.rootHash : new Uint8Array() + )); + message.data !== undefined && + (obj.data = base64FromBytes( + message.data !== undefined ? message.data : new Uint8Array() + )); + message.proof !== undefined && + (obj.proof = message.proof ? Proof.toJSON(message.proof) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): TxProof { + const message = { ...baseTxProof } as TxProof; + if (object.rootHash !== undefined && object.rootHash !== null) { + message.rootHash = object.rootHash; + } else { + message.rootHash = new Uint8Array(); + } + if (object.data !== undefined && object.data !== null) { + message.data = object.data; + } else { + message.data = new Uint8Array(); + } + if (object.proof !== undefined && object.proof !== null) { + message.proof = Proof.fromPartial(object.proof); + } else { + message.proof = undefined; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function toTimestamp(date: Date): Timestamp { + const seconds = date.getTime() / 1_000; + const nanos = (date.getTime() % 1_000) * 1_000_000; + return { seconds, nanos }; +} + +function fromTimestamp(t: Timestamp): Date { + let millis = t.seconds * 1_000; + millis += t.nanos / 1_000_000; + return new Date(millis); +} + +function fromJsonTimestamp(o: any): Date { + if (o instanceof Date) { + return o; + } else if (typeof o === "string") { + return new Date(o); + } else { + return fromTimestamp(Timestamp.fromJSON(o)); + } +} + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/cosmos.authz.v1beta1/types/tendermint/types/validator.ts b/ts-client/cosmos.authz.v1beta1/types/tendermint/types/validator.ts new file mode 100644 index 00000000..c5044032 --- /dev/null +++ b/ts-client/cosmos.authz.v1beta1/types/tendermint/types/validator.ts @@ -0,0 +1,382 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; +import { PublicKey } from "../../tendermint/crypto/keys"; + +export const protobufPackage = "tendermint.types"; + +export interface ValidatorSet { + validators: Validator[]; + proposer: Validator | undefined; + totalVotingPower: number; +} + +export interface Validator { + address: Uint8Array; + pubKey: PublicKey | undefined; + votingPower: number; + proposerPriority: number; +} + +export interface SimpleValidator { + pubKey: PublicKey | undefined; + votingPower: number; +} + +const baseValidatorSet: object = { totalVotingPower: 0 }; + +export const ValidatorSet = { + encode(message: ValidatorSet, writer: Writer = Writer.create()): Writer { + for (const v of message.validators) { + Validator.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.proposer !== undefined) { + Validator.encode(message.proposer, writer.uint32(18).fork()).ldelim(); + } + if (message.totalVotingPower !== 0) { + writer.uint32(24).int64(message.totalVotingPower); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ValidatorSet { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseValidatorSet } as ValidatorSet; + message.validators = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.validators.push(Validator.decode(reader, reader.uint32())); + break; + case 2: + message.proposer = Validator.decode(reader, reader.uint32()); + break; + case 3: + message.totalVotingPower = longToNumber(reader.int64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ValidatorSet { + const message = { ...baseValidatorSet } as ValidatorSet; + message.validators = []; + if (object.validators !== undefined && object.validators !== null) { + for (const e of object.validators) { + message.validators.push(Validator.fromJSON(e)); + } + } + if (object.proposer !== undefined && object.proposer !== null) { + message.proposer = Validator.fromJSON(object.proposer); + } else { + message.proposer = undefined; + } + if ( + object.totalVotingPower !== undefined && + object.totalVotingPower !== null + ) { + message.totalVotingPower = Number(object.totalVotingPower); + } else { + message.totalVotingPower = 0; + } + return message; + }, + + toJSON(message: ValidatorSet): unknown { + const obj: any = {}; + if (message.validators) { + obj.validators = message.validators.map((e) => + e ? Validator.toJSON(e) : undefined + ); + } else { + obj.validators = []; + } + message.proposer !== undefined && + (obj.proposer = message.proposer + ? Validator.toJSON(message.proposer) + : undefined); + message.totalVotingPower !== undefined && + (obj.totalVotingPower = message.totalVotingPower); + return obj; + }, + + fromPartial(object: DeepPartial): ValidatorSet { + const message = { ...baseValidatorSet } as ValidatorSet; + message.validators = []; + if (object.validators !== undefined && object.validators !== null) { + for (const e of object.validators) { + message.validators.push(Validator.fromPartial(e)); + } + } + if (object.proposer !== undefined && object.proposer !== null) { + message.proposer = Validator.fromPartial(object.proposer); + } else { + message.proposer = undefined; + } + if ( + object.totalVotingPower !== undefined && + object.totalVotingPower !== null + ) { + message.totalVotingPower = object.totalVotingPower; + } else { + message.totalVotingPower = 0; + } + return message; + }, +}; + +const baseValidator: object = { votingPower: 0, proposerPriority: 0 }; + +export const Validator = { + encode(message: Validator, writer: Writer = Writer.create()): Writer { + if (message.address.length !== 0) { + writer.uint32(10).bytes(message.address); + } + if (message.pubKey !== undefined) { + PublicKey.encode(message.pubKey, writer.uint32(18).fork()).ldelim(); + } + if (message.votingPower !== 0) { + writer.uint32(24).int64(message.votingPower); + } + if (message.proposerPriority !== 0) { + writer.uint32(32).int64(message.proposerPriority); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Validator { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseValidator } as Validator; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.address = reader.bytes(); + break; + case 2: + message.pubKey = PublicKey.decode(reader, reader.uint32()); + break; + case 3: + message.votingPower = longToNumber(reader.int64() as Long); + break; + case 4: + message.proposerPriority = longToNumber(reader.int64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Validator { + const message = { ...baseValidator } as Validator; + if (object.address !== undefined && object.address !== null) { + message.address = bytesFromBase64(object.address); + } + if (object.pubKey !== undefined && object.pubKey !== null) { + message.pubKey = PublicKey.fromJSON(object.pubKey); + } else { + message.pubKey = undefined; + } + if (object.votingPower !== undefined && object.votingPower !== null) { + message.votingPower = Number(object.votingPower); + } else { + message.votingPower = 0; + } + if ( + object.proposerPriority !== undefined && + object.proposerPriority !== null + ) { + message.proposerPriority = Number(object.proposerPriority); + } else { + message.proposerPriority = 0; + } + return message; + }, + + toJSON(message: Validator): unknown { + const obj: any = {}; + message.address !== undefined && + (obj.address = base64FromBytes( + message.address !== undefined ? message.address : new Uint8Array() + )); + message.pubKey !== undefined && + (obj.pubKey = message.pubKey + ? PublicKey.toJSON(message.pubKey) + : undefined); + message.votingPower !== undefined && + (obj.votingPower = message.votingPower); + message.proposerPriority !== undefined && + (obj.proposerPriority = message.proposerPriority); + return obj; + }, + + fromPartial(object: DeepPartial): Validator { + const message = { ...baseValidator } as Validator; + if (object.address !== undefined && object.address !== null) { + message.address = object.address; + } else { + message.address = new Uint8Array(); + } + if (object.pubKey !== undefined && object.pubKey !== null) { + message.pubKey = PublicKey.fromPartial(object.pubKey); + } else { + message.pubKey = undefined; + } + if (object.votingPower !== undefined && object.votingPower !== null) { + message.votingPower = object.votingPower; + } else { + message.votingPower = 0; + } + if ( + object.proposerPriority !== undefined && + object.proposerPriority !== null + ) { + message.proposerPriority = object.proposerPriority; + } else { + message.proposerPriority = 0; + } + return message; + }, +}; + +const baseSimpleValidator: object = { votingPower: 0 }; + +export const SimpleValidator = { + encode(message: SimpleValidator, writer: Writer = Writer.create()): Writer { + if (message.pubKey !== undefined) { + PublicKey.encode(message.pubKey, writer.uint32(10).fork()).ldelim(); + } + if (message.votingPower !== 0) { + writer.uint32(16).int64(message.votingPower); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): SimpleValidator { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseSimpleValidator } as SimpleValidator; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.pubKey = PublicKey.decode(reader, reader.uint32()); + break; + case 2: + message.votingPower = longToNumber(reader.int64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): SimpleValidator { + const message = { ...baseSimpleValidator } as SimpleValidator; + if (object.pubKey !== undefined && object.pubKey !== null) { + message.pubKey = PublicKey.fromJSON(object.pubKey); + } else { + message.pubKey = undefined; + } + if (object.votingPower !== undefined && object.votingPower !== null) { + message.votingPower = Number(object.votingPower); + } else { + message.votingPower = 0; + } + return message; + }, + + toJSON(message: SimpleValidator): unknown { + const obj: any = {}; + message.pubKey !== undefined && + (obj.pubKey = message.pubKey + ? PublicKey.toJSON(message.pubKey) + : undefined); + message.votingPower !== undefined && + (obj.votingPower = message.votingPower); + return obj; + }, + + fromPartial(object: DeepPartial): SimpleValidator { + const message = { ...baseSimpleValidator } as SimpleValidator; + if (object.pubKey !== undefined && object.pubKey !== null) { + message.pubKey = PublicKey.fromPartial(object.pubKey); + } else { + message.pubKey = undefined; + } + if (object.votingPower !== undefined && object.votingPower !== null) { + message.votingPower = object.votingPower; + } else { + message.votingPower = 0; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/cosmos.authz.v1beta1/types/tendermint/version/types.ts b/ts-client/cosmos.authz.v1beta1/types/tendermint/version/types.ts new file mode 100644 index 00000000..4bc6ad82 --- /dev/null +++ b/ts-client/cosmos.authz.v1beta1/types/tendermint/version/types.ts @@ -0,0 +1,202 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "tendermint.version"; + +/** + * App includes the protocol and software version for the application. + * This information is included in ResponseInfo. The App.Protocol can be + * updated in ResponseEndBlock. + */ +export interface App { + protocol: number; + software: string; +} + +/** + * Consensus captures the consensus rules for processing a block in the blockchain, + * including all blockchain data structures and the rules of the application's + * state transition machine. + */ +export interface Consensus { + block: number; + app: number; +} + +const baseApp: object = { protocol: 0, software: "" }; + +export const App = { + encode(message: App, writer: Writer = Writer.create()): Writer { + if (message.protocol !== 0) { + writer.uint32(8).uint64(message.protocol); + } + if (message.software !== "") { + writer.uint32(18).string(message.software); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): App { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseApp } as App; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.protocol = longToNumber(reader.uint64() as Long); + break; + case 2: + message.software = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): App { + const message = { ...baseApp } as App; + if (object.protocol !== undefined && object.protocol !== null) { + message.protocol = Number(object.protocol); + } else { + message.protocol = 0; + } + if (object.software !== undefined && object.software !== null) { + message.software = String(object.software); + } else { + message.software = ""; + } + return message; + }, + + toJSON(message: App): unknown { + const obj: any = {}; + message.protocol !== undefined && (obj.protocol = message.protocol); + message.software !== undefined && (obj.software = message.software); + return obj; + }, + + fromPartial(object: DeepPartial): App { + const message = { ...baseApp } as App; + if (object.protocol !== undefined && object.protocol !== null) { + message.protocol = object.protocol; + } else { + message.protocol = 0; + } + if (object.software !== undefined && object.software !== null) { + message.software = object.software; + } else { + message.software = ""; + } + return message; + }, +}; + +const baseConsensus: object = { block: 0, app: 0 }; + +export const Consensus = { + encode(message: Consensus, writer: Writer = Writer.create()): Writer { + if (message.block !== 0) { + writer.uint32(8).uint64(message.block); + } + if (message.app !== 0) { + writer.uint32(16).uint64(message.app); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Consensus { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseConsensus } as Consensus; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.block = longToNumber(reader.uint64() as Long); + break; + case 2: + message.app = longToNumber(reader.uint64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Consensus { + const message = { ...baseConsensus } as Consensus; + if (object.block !== undefined && object.block !== null) { + message.block = Number(object.block); + } else { + message.block = 0; + } + if (object.app !== undefined && object.app !== null) { + message.app = Number(object.app); + } else { + message.app = 0; + } + return message; + }, + + toJSON(message: Consensus): unknown { + const obj: any = {}; + message.block !== undefined && (obj.block = message.block); + message.app !== undefined && (obj.app = message.app); + return obj; + }, + + fromPartial(object: DeepPartial): Consensus { + const message = { ...baseConsensus } as Consensus; + if (object.block !== undefined && object.block !== null) { + message.block = object.block; + } else { + message.block = 0; + } + if (object.app !== undefined && object.app !== null) { + message.app = object.app; + } else { + message.app = 0; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/cosmos.bank.v1beta1/index.ts b/ts-client/cosmos.bank.v1beta1/index.ts new file mode 100755 index 00000000..c9dfa159 --- /dev/null +++ b/ts-client/cosmos.bank.v1beta1/index.ts @@ -0,0 +1,6 @@ +import Module from './module'; +import { txClient, queryClient, registry } from './module'; +import { msgTypes } from './registry'; + +export * from "./types"; +export { Module, msgTypes, txClient, queryClient, registry }; diff --git a/ts-client/cosmos.bank.v1beta1/module.ts b/ts-client/cosmos.bank.v1beta1/module.ts new file mode 100755 index 00000000..fa6cd580 --- /dev/null +++ b/ts-client/cosmos.bank.v1beta1/module.ts @@ -0,0 +1,132 @@ +// Generated by Ignite ignite.com/cli + +import { StdFee } from "@cosmjs/launchpad"; +import { SigningStargateClient, DeliverTxResponse } from "@cosmjs/stargate"; +import { EncodeObject, GeneratedType, OfflineSigner, Registry } from "@cosmjs/proto-signing"; +import { msgTypes } from './registry'; +import { IgniteClient } from "../client" +import { MissingWalletError } from "../helpers" +import { Api } from "./rest"; +import { MsgMultiSend } from "./types/cosmos/bank/v1beta1/tx"; +import { MsgSend } from "./types/cosmos/bank/v1beta1/tx"; + + +export { MsgMultiSend, MsgSend }; + +type sendMsgMultiSendParams = { + value: MsgMultiSend, + fee?: StdFee, + memo?: string +}; + +type sendMsgSendParams = { + value: MsgSend, + fee?: StdFee, + memo?: string +}; + + +type msgMultiSendParams = { + value: MsgMultiSend, +}; + +type msgSendParams = { + value: MsgSend, +}; + + +export const registry = new Registry(msgTypes); + +const defaultFee = { + amount: [], + gas: "200000", +}; + +interface TxClientOptions { + addr: string + prefix: string + signer?: OfflineSigner +} + +export const txClient = ({ signer, prefix, addr }: TxClientOptions = { addr: "http://localhost:26657", prefix: "cosmos" }) => { + + return { + + async sendMsgMultiSend({ value, fee, memo }: sendMsgMultiSendParams): Promise { + if (!signer) { + throw new Error('TxClient:sendMsgMultiSend: Unable to sign Tx. Signer is not present.') + } + try { + const { address } = (await signer.getAccounts())[0]; + const signingClient = await SigningStargateClient.connectWithSigner(addr,signer,{registry, prefix}); + let msg = this.msgMultiSend({ value: MsgMultiSend.fromPartial(value) }) + return await signingClient.signAndBroadcast(address, [msg], fee ? fee : defaultFee, memo) + } catch (e: any) { + throw new Error('TxClient:sendMsgMultiSend: Could not broadcast Tx: '+ e.message) + } + }, + + async sendMsgSend({ value, fee, memo }: sendMsgSendParams): Promise { + if (!signer) { + throw new Error('TxClient:sendMsgSend: Unable to sign Tx. Signer is not present.') + } + try { + const { address } = (await signer.getAccounts())[0]; + const signingClient = await SigningStargateClient.connectWithSigner(addr,signer,{registry, prefix}); + let msg = this.msgSend({ value: MsgSend.fromPartial(value) }) + return await signingClient.signAndBroadcast(address, [msg], fee ? fee : defaultFee, memo) + } catch (e: any) { + throw new Error('TxClient:sendMsgSend: Could not broadcast Tx: '+ e.message) + } + }, + + + msgMultiSend({ value }: msgMultiSendParams): EncodeObject { + try { + return { typeUrl: "/cosmos.bank.v1beta1.MsgMultiSend", value: MsgMultiSend.fromPartial( value ) } + } catch (e: any) { + throw new Error('TxClient:MsgMultiSend: Could not create message: ' + e.message) + } + }, + + msgSend({ value }: msgSendParams): EncodeObject { + try { + return { typeUrl: "/cosmos.bank.v1beta1.MsgSend", value: MsgSend.fromPartial( value ) } + } catch (e: any) { + throw new Error('TxClient:MsgSend: Could not create message: ' + e.message) + } + }, + + } +}; + +interface QueryClientOptions { + addr: string +} + +export const queryClient = ({ addr: addr }: QueryClientOptions = { addr: "http://localhost:1317" }) => { + return new Api({ baseUrl: addr }); +}; + +class SDKModule { + public query: ReturnType; + public tx: ReturnType; + + public registry: Array<[string, GeneratedType]>; + + constructor(client: IgniteClient) { + + this.query = queryClient({ addr: client.env.apiURL }); + this.tx = txClient({ signer: client.signer, addr: client.env.rpcURL, prefix: client.env.prefix ?? "cosmos" }); + } +}; + +const Module = (test: IgniteClient) => { + return { + module: { + CosmosBankV1Beta1: new SDKModule(test) + }, + registry: msgTypes + } +} +export default Module; \ No newline at end of file diff --git a/ts-client/cosmos.bank.v1beta1/registry.ts b/ts-client/cosmos.bank.v1beta1/registry.ts new file mode 100755 index 00000000..3a77952c --- /dev/null +++ b/ts-client/cosmos.bank.v1beta1/registry.ts @@ -0,0 +1,11 @@ +import { GeneratedType } from "@cosmjs/proto-signing"; +import { MsgMultiSend } from "./types/cosmos/bank/v1beta1/tx"; +import { MsgSend } from "./types/cosmos/bank/v1beta1/tx"; + +const msgTypes: Array<[string, GeneratedType]> = [ + ["/cosmos.bank.v1beta1.MsgMultiSend", MsgMultiSend], + ["/cosmos.bank.v1beta1.MsgSend", MsgSend], + +]; + +export { msgTypes } \ No newline at end of file diff --git a/ts-client/cosmos.bank.v1beta1/rest.ts b/ts-client/cosmos.bank.v1beta1/rest.ts new file mode 100644 index 00000000..d3300c8e --- /dev/null +++ b/ts-client/cosmos.bank.v1beta1/rest.ts @@ -0,0 +1,636 @@ +/* eslint-disable */ +/* tslint:disable */ +/* + * --------------------------------------------------------------- + * ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ## + * ## ## + * ## AUTHOR: acacode ## + * ## SOURCE: https://github.com/acacode/swagger-typescript-api ## + * --------------------------------------------------------------- + */ + +/** + * Params defines the parameters for the bank module. + */ +export interface Bankv1Beta1Params { + send_enabled?: V1Beta1SendEnabled[]; + default_send_enabled?: boolean; +} + +export interface ProtobufAny { + "@type"?: string; +} + +export interface RpcStatus { + /** @format int32 */ + code?: number; + message?: string; + details?: ProtobufAny[]; +} + +/** +* Coin defines a token with a denomination and an amount. + +NOTE: The amount field is an Int which implements the custom method +signatures required by gogoproto. +*/ +export interface V1Beta1Coin { + denom?: string; + amount?: string; +} + +/** +* DenomUnit represents a struct that describes a given +denomination unit of the basic token. +*/ +export interface V1Beta1DenomUnit { + /** denom represents the string name of the given denom unit (e.g uatom). */ + denom?: string; + + /** + * exponent represents power of 10 exponent that one must + * raise the base_denom to in order to equal the given DenomUnit's denom + * 1 denom = 1^exponent base_denom + * (e.g. with a base_denom of uatom, one can create a DenomUnit of 'atom' with + * exponent = 6, thus: 1 atom = 10^6 uatom). + * @format int64 + */ + exponent?: number; + aliases?: string[]; +} + +/** + * Input models transaction input. + */ +export interface V1Beta1Input { + address?: string; + coins?: V1Beta1Coin[]; +} + +/** +* Metadata represents a struct that describes +a basic token. +*/ +export interface V1Beta1Metadata { + description?: string; + denom_units?: V1Beta1DenomUnit[]; + + /** base represents the base denom (should be the DenomUnit with exponent = 0). */ + base?: string; + + /** + * display indicates the suggested denom that should be + * displayed in clients. + */ + display?: string; + + /** Since: cosmos-sdk 0.43 */ + name?: string; + + /** + * symbol is the token symbol usually shown on exchanges (eg: ATOM). This can + * be the same as the display. + * + * Since: cosmos-sdk 0.43 + */ + symbol?: string; +} + +/** + * MsgMultiSendResponse defines the Msg/MultiSend response type. + */ +export type V1Beta1MsgMultiSendResponse = object; + +/** + * MsgSendResponse defines the Msg/Send response type. + */ +export type V1Beta1MsgSendResponse = object; + +/** + * Output models transaction outputs. + */ +export interface V1Beta1Output { + address?: string; + coins?: V1Beta1Coin[]; +} + +/** +* message SomeRequest { + Foo some_parameter = 1; + PageRequest pagination = 2; + } +*/ +export interface V1Beta1PageRequest { + /** + * key is a value returned in PageResponse.next_key to begin + * querying the next page most efficiently. Only one of offset or key + * should be set. + * @format byte + */ + key?: string; + + /** + * offset is a numeric offset that can be used when key is unavailable. + * It is less efficient than using key. Only one of offset or key should + * be set. + * @format uint64 + */ + offset?: string; + + /** + * limit is the total number of results to be returned in the result page. + * If left empty it will default to a value to be set by each app. + * @format uint64 + */ + limit?: string; + + /** + * count_total is set to true to indicate that the result set should include + * a count of the total number of items available for pagination in UIs. + * count_total is only respected when offset is used. It is ignored when key + * is set. + */ + count_total?: boolean; + + /** + * reverse is set to true if results are to be returned in the descending order. + * + * Since: cosmos-sdk 0.43 + */ + reverse?: boolean; +} + +/** +* PageResponse is to be embedded in gRPC response messages where the +corresponding request message has used PageRequest. + + message SomeResponse { + repeated Bar results = 1; + PageResponse page = 2; + } +*/ +export interface V1Beta1PageResponse { + /** @format byte */ + next_key?: string; + + /** @format uint64 */ + total?: string; +} + +/** +* QueryAllBalancesResponse is the response type for the Query/AllBalances RPC +method. +*/ +export interface V1Beta1QueryAllBalancesResponse { + /** balances is the balances of all the coins. */ + balances?: V1Beta1Coin[]; + + /** pagination defines the pagination in the response. */ + pagination?: V1Beta1PageResponse; +} + +/** + * QueryBalanceResponse is the response type for the Query/Balance RPC method. + */ +export interface V1Beta1QueryBalanceResponse { + /** balance is the balance of the coin. */ + balance?: V1Beta1Coin; +} + +/** +* QueryDenomMetadataResponse is the response type for the Query/DenomMetadata RPC +method. +*/ +export interface V1Beta1QueryDenomMetadataResponse { + /** metadata describes and provides all the client information for the requested token. */ + metadata?: V1Beta1Metadata; +} + +/** +* QueryDenomsMetadataResponse is the response type for the Query/DenomsMetadata RPC +method. +*/ +export interface V1Beta1QueryDenomsMetadataResponse { + /** metadata provides the client information for all the registered tokens. */ + metadatas?: V1Beta1Metadata[]; + + /** pagination defines the pagination in the response. */ + pagination?: V1Beta1PageResponse; +} + +/** + * QueryParamsResponse defines the response type for querying x/bank parameters. + */ +export interface V1Beta1QueryParamsResponse { + /** Params defines the parameters for the bank module. */ + params?: Bankv1Beta1Params; +} + +/** +* QuerySpendableBalancesResponse defines the gRPC response structure for querying +an account's spendable balances. +*/ +export interface V1Beta1QuerySpendableBalancesResponse { + /** balances is the spendable balances of all the coins. */ + balances?: V1Beta1Coin[]; + + /** pagination defines the pagination in the response. */ + pagination?: V1Beta1PageResponse; +} + +/** + * QuerySupplyOfResponse is the response type for the Query/SupplyOf RPC method. + */ +export interface V1Beta1QuerySupplyOfResponse { + /** amount is the supply of the coin. */ + amount?: V1Beta1Coin; +} + +export interface V1Beta1QueryTotalSupplyResponse { + supply?: V1Beta1Coin[]; + + /** + * pagination defines the pagination in the response. + * + * Since: cosmos-sdk 0.43 + */ + pagination?: V1Beta1PageResponse; +} + +/** +* SendEnabled maps coin denom to a send_enabled status (whether a denom is +sendable). +*/ +export interface V1Beta1SendEnabled { + denom?: string; + enabled?: boolean; +} + +export type QueryParamsType = Record; +export type ResponseFormat = keyof Omit; + +export interface FullRequestParams extends Omit { + /** set parameter to `true` for call `securityWorker` for this request */ + secure?: boolean; + /** request path */ + path: string; + /** content type of request body */ + type?: ContentType; + /** query params */ + query?: QueryParamsType; + /** format of response (i.e. response.json() -> format: "json") */ + format?: keyof Omit; + /** request body */ + body?: unknown; + /** base url */ + baseUrl?: string; + /** request cancellation token */ + cancelToken?: CancelToken; +} + +export type RequestParams = Omit; + +export interface ApiConfig { + baseUrl?: string; + baseApiParams?: Omit; + securityWorker?: (securityData: SecurityDataType) => RequestParams | void; +} + +export interface HttpResponse extends Response { + data: D; + error: E; +} + +type CancelToken = Symbol | string | number; + +export enum ContentType { + Json = "application/json", + FormData = "multipart/form-data", + UrlEncoded = "application/x-www-form-urlencoded", +} + +export class HttpClient { + public baseUrl: string = ""; + private securityData: SecurityDataType = null as any; + private securityWorker: null | ApiConfig["securityWorker"] = null; + private abortControllers = new Map(); + + private baseApiParams: RequestParams = { + credentials: "same-origin", + headers: {}, + redirect: "follow", + referrerPolicy: "no-referrer", + }; + + constructor(apiConfig: ApiConfig = {}) { + Object.assign(this, apiConfig); + } + + public setSecurityData = (data: SecurityDataType) => { + this.securityData = data; + }; + + private addQueryParam(query: QueryParamsType, key: string) { + const value = query[key]; + + return ( + encodeURIComponent(key) + + "=" + + encodeURIComponent(Array.isArray(value) ? value.join(",") : typeof value === "number" ? value : `${value}`) + ); + } + + protected toQueryString(rawQuery?: QueryParamsType): string { + const query = rawQuery || {}; + const keys = Object.keys(query).filter((key) => "undefined" !== typeof query[key]); + return keys + .map((key) => + typeof query[key] === "object" && !Array.isArray(query[key]) + ? this.toQueryString(query[key] as QueryParamsType) + : this.addQueryParam(query, key), + ) + .join("&"); + } + + protected addQueryParams(rawQuery?: QueryParamsType): string { + const queryString = this.toQueryString(rawQuery); + return queryString ? `?${queryString}` : ""; + } + + private contentFormatters: Record any> = { + [ContentType.Json]: (input: any) => + input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input, + [ContentType.FormData]: (input: any) => + Object.keys(input || {}).reduce((data, key) => { + data.append(key, input[key]); + return data; + }, new FormData()), + [ContentType.UrlEncoded]: (input: any) => this.toQueryString(input), + }; + + private mergeRequestParams(params1: RequestParams, params2?: RequestParams): RequestParams { + return { + ...this.baseApiParams, + ...params1, + ...(params2 || {}), + headers: { + ...(this.baseApiParams.headers || {}), + ...(params1.headers || {}), + ...((params2 && params2.headers) || {}), + }, + }; + } + + private createAbortSignal = (cancelToken: CancelToken): AbortSignal | undefined => { + if (this.abortControllers.has(cancelToken)) { + const abortController = this.abortControllers.get(cancelToken); + if (abortController) { + return abortController.signal; + } + return void 0; + } + + const abortController = new AbortController(); + this.abortControllers.set(cancelToken, abortController); + return abortController.signal; + }; + + public abortRequest = (cancelToken: CancelToken) => { + const abortController = this.abortControllers.get(cancelToken); + + if (abortController) { + abortController.abort(); + this.abortControllers.delete(cancelToken); + } + }; + + public request = ({ + body, + secure, + path, + type, + query, + format = "json", + baseUrl, + cancelToken, + ...params + }: FullRequestParams): Promise> => { + const secureParams = (secure && this.securityWorker && this.securityWorker(this.securityData)) || {}; + const requestParams = this.mergeRequestParams(params, secureParams); + const queryString = query && this.toQueryString(query); + const payloadFormatter = this.contentFormatters[type || ContentType.Json]; + + return fetch(`${baseUrl || this.baseUrl || ""}${path}${queryString ? `?${queryString}` : ""}`, { + ...requestParams, + headers: { + ...(type && type !== ContentType.FormData ? { "Content-Type": type } : {}), + ...(requestParams.headers || {}), + }, + signal: cancelToken ? this.createAbortSignal(cancelToken) : void 0, + body: typeof body === "undefined" || body === null ? null : payloadFormatter(body), + }).then(async (response) => { + const r = response as HttpResponse; + r.data = (null as unknown) as T; + r.error = (null as unknown) as E; + + const data = await response[format]() + .then((data) => { + if (r.ok) { + r.data = data; + } else { + r.error = data; + } + return r; + }) + .catch((e) => { + r.error = e; + return r; + }); + + if (cancelToken) { + this.abortControllers.delete(cancelToken); + } + + if (!response.ok) throw data; + return data; + }); + }; +} + +/** + * @title cosmos/bank/v1beta1/authz.proto + * @version version not set + */ +export class Api extends HttpClient { + /** + * No description + * + * @tags Query + * @name QueryAllBalances + * @summary AllBalances queries the balance of all coins for a single account. + * @request GET:/cosmos/bank/v1beta1/balances/{address} + */ + queryAllBalances = ( + address: string, + query?: { + "pagination.key"?: string; + "pagination.offset"?: string; + "pagination.limit"?: string; + "pagination.count_total"?: boolean; + "pagination.reverse"?: boolean; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/cosmos/bank/v1beta1/balances/${address}`, + method: "GET", + query: query, + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Query + * @name QueryBalance + * @summary Balance queries the balance of a single coin for a single account. + * @request GET:/cosmos/bank/v1beta1/balances/{address}/by_denom + */ + queryBalance = (address: string, query?: { denom?: string }, params: RequestParams = {}) => + this.request({ + path: `/cosmos/bank/v1beta1/balances/${address}/by_denom`, + method: "GET", + query: query, + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Query + * @name QueryDenomsMetadata + * @summary DenomsMetadata queries the client metadata for all registered coin denominations. + * @request GET:/cosmos/bank/v1beta1/denoms_metadata + */ + queryDenomsMetadata = ( + query?: { + "pagination.key"?: string; + "pagination.offset"?: string; + "pagination.limit"?: string; + "pagination.count_total"?: boolean; + "pagination.reverse"?: boolean; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/cosmos/bank/v1beta1/denoms_metadata`, + method: "GET", + query: query, + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Query + * @name QueryDenomMetadata + * @summary DenomsMetadata queries the client metadata of a given coin denomination. + * @request GET:/cosmos/bank/v1beta1/denoms_metadata/{denom} + */ + queryDenomMetadata = (denom: string, params: RequestParams = {}) => + this.request({ + path: `/cosmos/bank/v1beta1/denoms_metadata/${denom}`, + method: "GET", + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Query + * @name QueryParams + * @summary Params queries the parameters of x/bank module. + * @request GET:/cosmos/bank/v1beta1/params + */ + queryParams = (params: RequestParams = {}) => + this.request({ + path: `/cosmos/bank/v1beta1/params`, + method: "GET", + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Query + * @name QuerySpendableBalances + * @summary SpendableBalances queries the spenable balance of all coins for a single +account. + * @request GET:/cosmos/bank/v1beta1/spendable_balances/{address} + */ + querySpendableBalances = ( + address: string, + query?: { + "pagination.key"?: string; + "pagination.offset"?: string; + "pagination.limit"?: string; + "pagination.count_total"?: boolean; + "pagination.reverse"?: boolean; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/cosmos/bank/v1beta1/spendable_balances/${address}`, + method: "GET", + query: query, + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Query + * @name QueryTotalSupply + * @summary TotalSupply queries the total supply of all coins. + * @request GET:/cosmos/bank/v1beta1/supply + */ + queryTotalSupply = ( + query?: { + "pagination.key"?: string; + "pagination.offset"?: string; + "pagination.limit"?: string; + "pagination.count_total"?: boolean; + "pagination.reverse"?: boolean; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/cosmos/bank/v1beta1/supply`, + method: "GET", + query: query, + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Query + * @name QuerySupplyOf + * @summary SupplyOf queries the supply of a single coin. + * @request GET:/cosmos/bank/v1beta1/supply/{denom} + */ + querySupplyOf = (denom: string, params: RequestParams = {}) => + this.request({ + path: `/cosmos/bank/v1beta1/supply/${denom}`, + method: "GET", + format: "json", + ...params, + }); +} diff --git a/ts-client/cosmos.bank.v1beta1/types.ts b/ts-client/cosmos.bank.v1beta1/types.ts new file mode 100755 index 00000000..85656717 --- /dev/null +++ b/ts-client/cosmos.bank.v1beta1/types.ts @@ -0,0 +1,23 @@ +import { SendAuthorization } from "./types/cosmos/bank/v1beta1/authz" +import { Params } from "./types/cosmos/bank/v1beta1/bank" +import { SendEnabled } from "./types/cosmos/bank/v1beta1/bank" +import { Input } from "./types/cosmos/bank/v1beta1/bank" +import { Output } from "./types/cosmos/bank/v1beta1/bank" +import { Supply } from "./types/cosmos/bank/v1beta1/bank" +import { DenomUnit } from "./types/cosmos/bank/v1beta1/bank" +import { Metadata } from "./types/cosmos/bank/v1beta1/bank" +import { Balance } from "./types/cosmos/bank/v1beta1/genesis" + + +export { + SendAuthorization, + Params, + SendEnabled, + Input, + Output, + Supply, + DenomUnit, + Metadata, + Balance, + + } \ No newline at end of file diff --git a/ts-client/cosmos.bank.v1beta1/types/cosmos/bank/v1beta1/authz.ts b/ts-client/cosmos.bank.v1beta1/types/cosmos/bank/v1beta1/authz.ts new file mode 100644 index 00000000..e8b43878 --- /dev/null +++ b/ts-client/cosmos.bank.v1beta1/types/cosmos/bank/v1beta1/authz.ts @@ -0,0 +1,90 @@ +/* eslint-disable */ +import { Coin } from "../../../cosmos/base/v1beta1/coin"; +import { Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "cosmos.bank.v1beta1"; + +/** + * SendAuthorization allows the grantee to spend up to spend_limit coins from + * the granter's account. + * + * Since: cosmos-sdk 0.43 + */ +export interface SendAuthorization { + spendLimit: Coin[]; +} + +const baseSendAuthorization: object = {}; + +export const SendAuthorization = { + encode(message: SendAuthorization, writer: Writer = Writer.create()): Writer { + for (const v of message.spendLimit) { + Coin.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): SendAuthorization { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseSendAuthorization } as SendAuthorization; + message.spendLimit = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.spendLimit.push(Coin.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): SendAuthorization { + const message = { ...baseSendAuthorization } as SendAuthorization; + message.spendLimit = []; + if (object.spendLimit !== undefined && object.spendLimit !== null) { + for (const e of object.spendLimit) { + message.spendLimit.push(Coin.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: SendAuthorization): unknown { + const obj: any = {}; + if (message.spendLimit) { + obj.spendLimit = message.spendLimit.map((e) => + e ? Coin.toJSON(e) : undefined + ); + } else { + obj.spendLimit = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): SendAuthorization { + const message = { ...baseSendAuthorization } as SendAuthorization; + message.spendLimit = []; + if (object.spendLimit !== undefined && object.spendLimit !== null) { + for (const e of object.spendLimit) { + message.spendLimit.push(Coin.fromPartial(e)); + } + } + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/cosmos.bank.v1beta1/types/cosmos/bank/v1beta1/bank.ts b/ts-client/cosmos.bank.v1beta1/types/cosmos/bank/v1beta1/bank.ts new file mode 100644 index 00000000..7651c102 --- /dev/null +++ b/ts-client/cosmos.bank.v1beta1/types/cosmos/bank/v1beta1/bank.ts @@ -0,0 +1,735 @@ +/* eslint-disable */ +import { Coin } from "../../../cosmos/base/v1beta1/coin"; +import { Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "cosmos.bank.v1beta1"; + +/** Params defines the parameters for the bank module. */ +export interface Params { + sendEnabled: SendEnabled[]; + defaultSendEnabled: boolean; +} + +/** + * SendEnabled maps coin denom to a send_enabled status (whether a denom is + * sendable). + */ +export interface SendEnabled { + denom: string; + enabled: boolean; +} + +/** Input models transaction input. */ +export interface Input { + address: string; + coins: Coin[]; +} + +/** Output models transaction outputs. */ +export interface Output { + address: string; + coins: Coin[]; +} + +/** + * Supply represents a struct that passively keeps track of the total supply + * amounts in the network. + * This message is deprecated now that supply is indexed by denom. + * + * @deprecated + */ +export interface Supply { + total: Coin[]; +} + +/** + * DenomUnit represents a struct that describes a given + * denomination unit of the basic token. + */ +export interface DenomUnit { + /** denom represents the string name of the given denom unit (e.g uatom). */ + denom: string; + /** + * exponent represents power of 10 exponent that one must + * raise the base_denom to in order to equal the given DenomUnit's denom + * 1 denom = 1^exponent base_denom + * (e.g. with a base_denom of uatom, one can create a DenomUnit of 'atom' with + * exponent = 6, thus: 1 atom = 10^6 uatom). + */ + exponent: number; + /** aliases is a list of string aliases for the given denom */ + aliases: string[]; +} + +/** + * Metadata represents a struct that describes + * a basic token. + */ +export interface Metadata { + description: string; + /** denom_units represents the list of DenomUnit's for a given coin */ + denomUnits: DenomUnit[]; + /** base represents the base denom (should be the DenomUnit with exponent = 0). */ + base: string; + /** + * display indicates the suggested denom that should be + * displayed in clients. + */ + display: string; + /** + * name defines the name of the token (eg: Cosmos Atom) + * + * Since: cosmos-sdk 0.43 + */ + name: string; + /** + * symbol is the token symbol usually shown on exchanges (eg: ATOM). This can + * be the same as the display. + * + * Since: cosmos-sdk 0.43 + */ + symbol: string; +} + +const baseParams: object = { defaultSendEnabled: false }; + +export const Params = { + encode(message: Params, writer: Writer = Writer.create()): Writer { + for (const v of message.sendEnabled) { + SendEnabled.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.defaultSendEnabled === true) { + writer.uint32(16).bool(message.defaultSendEnabled); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Params { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseParams } as Params; + message.sendEnabled = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.sendEnabled.push(SendEnabled.decode(reader, reader.uint32())); + break; + case 2: + message.defaultSendEnabled = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Params { + const message = { ...baseParams } as Params; + message.sendEnabled = []; + if (object.sendEnabled !== undefined && object.sendEnabled !== null) { + for (const e of object.sendEnabled) { + message.sendEnabled.push(SendEnabled.fromJSON(e)); + } + } + if ( + object.defaultSendEnabled !== undefined && + object.defaultSendEnabled !== null + ) { + message.defaultSendEnabled = Boolean(object.defaultSendEnabled); + } else { + message.defaultSendEnabled = false; + } + return message; + }, + + toJSON(message: Params): unknown { + const obj: any = {}; + if (message.sendEnabled) { + obj.sendEnabled = message.sendEnabled.map((e) => + e ? SendEnabled.toJSON(e) : undefined + ); + } else { + obj.sendEnabled = []; + } + message.defaultSendEnabled !== undefined && + (obj.defaultSendEnabled = message.defaultSendEnabled); + return obj; + }, + + fromPartial(object: DeepPartial): Params { + const message = { ...baseParams } as Params; + message.sendEnabled = []; + if (object.sendEnabled !== undefined && object.sendEnabled !== null) { + for (const e of object.sendEnabled) { + message.sendEnabled.push(SendEnabled.fromPartial(e)); + } + } + if ( + object.defaultSendEnabled !== undefined && + object.defaultSendEnabled !== null + ) { + message.defaultSendEnabled = object.defaultSendEnabled; + } else { + message.defaultSendEnabled = false; + } + return message; + }, +}; + +const baseSendEnabled: object = { denom: "", enabled: false }; + +export const SendEnabled = { + encode(message: SendEnabled, writer: Writer = Writer.create()): Writer { + if (message.denom !== "") { + writer.uint32(10).string(message.denom); + } + if (message.enabled === true) { + writer.uint32(16).bool(message.enabled); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): SendEnabled { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseSendEnabled } as SendEnabled; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.denom = reader.string(); + break; + case 2: + message.enabled = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): SendEnabled { + const message = { ...baseSendEnabled } as SendEnabled; + if (object.denom !== undefined && object.denom !== null) { + message.denom = String(object.denom); + } else { + message.denom = ""; + } + if (object.enabled !== undefined && object.enabled !== null) { + message.enabled = Boolean(object.enabled); + } else { + message.enabled = false; + } + return message; + }, + + toJSON(message: SendEnabled): unknown { + const obj: any = {}; + message.denom !== undefined && (obj.denom = message.denom); + message.enabled !== undefined && (obj.enabled = message.enabled); + return obj; + }, + + fromPartial(object: DeepPartial): SendEnabled { + const message = { ...baseSendEnabled } as SendEnabled; + if (object.denom !== undefined && object.denom !== null) { + message.denom = object.denom; + } else { + message.denom = ""; + } + if (object.enabled !== undefined && object.enabled !== null) { + message.enabled = object.enabled; + } else { + message.enabled = false; + } + return message; + }, +}; + +const baseInput: object = { address: "" }; + +export const Input = { + encode(message: Input, writer: Writer = Writer.create()): Writer { + if (message.address !== "") { + writer.uint32(10).string(message.address); + } + for (const v of message.coins) { + Coin.encode(v!, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Input { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseInput } as Input; + message.coins = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.address = reader.string(); + break; + case 2: + message.coins.push(Coin.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Input { + const message = { ...baseInput } as Input; + message.coins = []; + if (object.address !== undefined && object.address !== null) { + message.address = String(object.address); + } else { + message.address = ""; + } + if (object.coins !== undefined && object.coins !== null) { + for (const e of object.coins) { + message.coins.push(Coin.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: Input): unknown { + const obj: any = {}; + message.address !== undefined && (obj.address = message.address); + if (message.coins) { + obj.coins = message.coins.map((e) => (e ? Coin.toJSON(e) : undefined)); + } else { + obj.coins = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): Input { + const message = { ...baseInput } as Input; + message.coins = []; + if (object.address !== undefined && object.address !== null) { + message.address = object.address; + } else { + message.address = ""; + } + if (object.coins !== undefined && object.coins !== null) { + for (const e of object.coins) { + message.coins.push(Coin.fromPartial(e)); + } + } + return message; + }, +}; + +const baseOutput: object = { address: "" }; + +export const Output = { + encode(message: Output, writer: Writer = Writer.create()): Writer { + if (message.address !== "") { + writer.uint32(10).string(message.address); + } + for (const v of message.coins) { + Coin.encode(v!, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Output { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseOutput } as Output; + message.coins = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.address = reader.string(); + break; + case 2: + message.coins.push(Coin.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Output { + const message = { ...baseOutput } as Output; + message.coins = []; + if (object.address !== undefined && object.address !== null) { + message.address = String(object.address); + } else { + message.address = ""; + } + if (object.coins !== undefined && object.coins !== null) { + for (const e of object.coins) { + message.coins.push(Coin.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: Output): unknown { + const obj: any = {}; + message.address !== undefined && (obj.address = message.address); + if (message.coins) { + obj.coins = message.coins.map((e) => (e ? Coin.toJSON(e) : undefined)); + } else { + obj.coins = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): Output { + const message = { ...baseOutput } as Output; + message.coins = []; + if (object.address !== undefined && object.address !== null) { + message.address = object.address; + } else { + message.address = ""; + } + if (object.coins !== undefined && object.coins !== null) { + for (const e of object.coins) { + message.coins.push(Coin.fromPartial(e)); + } + } + return message; + }, +}; + +const baseSupply: object = {}; + +export const Supply = { + encode(message: Supply, writer: Writer = Writer.create()): Writer { + for (const v of message.total) { + Coin.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Supply { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseSupply } as Supply; + message.total = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.total.push(Coin.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Supply { + const message = { ...baseSupply } as Supply; + message.total = []; + if (object.total !== undefined && object.total !== null) { + for (const e of object.total) { + message.total.push(Coin.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: Supply): unknown { + const obj: any = {}; + if (message.total) { + obj.total = message.total.map((e) => (e ? Coin.toJSON(e) : undefined)); + } else { + obj.total = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): Supply { + const message = { ...baseSupply } as Supply; + message.total = []; + if (object.total !== undefined && object.total !== null) { + for (const e of object.total) { + message.total.push(Coin.fromPartial(e)); + } + } + return message; + }, +}; + +const baseDenomUnit: object = { denom: "", exponent: 0, aliases: "" }; + +export const DenomUnit = { + encode(message: DenomUnit, writer: Writer = Writer.create()): Writer { + if (message.denom !== "") { + writer.uint32(10).string(message.denom); + } + if (message.exponent !== 0) { + writer.uint32(16).uint32(message.exponent); + } + for (const v of message.aliases) { + writer.uint32(26).string(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): DenomUnit { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseDenomUnit } as DenomUnit; + message.aliases = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.denom = reader.string(); + break; + case 2: + message.exponent = reader.uint32(); + break; + case 3: + message.aliases.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DenomUnit { + const message = { ...baseDenomUnit } as DenomUnit; + message.aliases = []; + if (object.denom !== undefined && object.denom !== null) { + message.denom = String(object.denom); + } else { + message.denom = ""; + } + if (object.exponent !== undefined && object.exponent !== null) { + message.exponent = Number(object.exponent); + } else { + message.exponent = 0; + } + if (object.aliases !== undefined && object.aliases !== null) { + for (const e of object.aliases) { + message.aliases.push(String(e)); + } + } + return message; + }, + + toJSON(message: DenomUnit): unknown { + const obj: any = {}; + message.denom !== undefined && (obj.denom = message.denom); + message.exponent !== undefined && (obj.exponent = message.exponent); + if (message.aliases) { + obj.aliases = message.aliases.map((e) => e); + } else { + obj.aliases = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): DenomUnit { + const message = { ...baseDenomUnit } as DenomUnit; + message.aliases = []; + if (object.denom !== undefined && object.denom !== null) { + message.denom = object.denom; + } else { + message.denom = ""; + } + if (object.exponent !== undefined && object.exponent !== null) { + message.exponent = object.exponent; + } else { + message.exponent = 0; + } + if (object.aliases !== undefined && object.aliases !== null) { + for (const e of object.aliases) { + message.aliases.push(e); + } + } + return message; + }, +}; + +const baseMetadata: object = { + description: "", + base: "", + display: "", + name: "", + symbol: "", +}; + +export const Metadata = { + encode(message: Metadata, writer: Writer = Writer.create()): Writer { + if (message.description !== "") { + writer.uint32(10).string(message.description); + } + for (const v of message.denomUnits) { + DenomUnit.encode(v!, writer.uint32(18).fork()).ldelim(); + } + if (message.base !== "") { + writer.uint32(26).string(message.base); + } + if (message.display !== "") { + writer.uint32(34).string(message.display); + } + if (message.name !== "") { + writer.uint32(42).string(message.name); + } + if (message.symbol !== "") { + writer.uint32(50).string(message.symbol); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Metadata { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMetadata } as Metadata; + message.denomUnits = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.description = reader.string(); + break; + case 2: + message.denomUnits.push(DenomUnit.decode(reader, reader.uint32())); + break; + case 3: + message.base = reader.string(); + break; + case 4: + message.display = reader.string(); + break; + case 5: + message.name = reader.string(); + break; + case 6: + message.symbol = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Metadata { + const message = { ...baseMetadata } as Metadata; + message.denomUnits = []; + if (object.description !== undefined && object.description !== null) { + message.description = String(object.description); + } else { + message.description = ""; + } + if (object.denomUnits !== undefined && object.denomUnits !== null) { + for (const e of object.denomUnits) { + message.denomUnits.push(DenomUnit.fromJSON(e)); + } + } + if (object.base !== undefined && object.base !== null) { + message.base = String(object.base); + } else { + message.base = ""; + } + if (object.display !== undefined && object.display !== null) { + message.display = String(object.display); + } else { + message.display = ""; + } + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.symbol !== undefined && object.symbol !== null) { + message.symbol = String(object.symbol); + } else { + message.symbol = ""; + } + return message; + }, + + toJSON(message: Metadata): unknown { + const obj: any = {}; + message.description !== undefined && + (obj.description = message.description); + if (message.denomUnits) { + obj.denomUnits = message.denomUnits.map((e) => + e ? DenomUnit.toJSON(e) : undefined + ); + } else { + obj.denomUnits = []; + } + message.base !== undefined && (obj.base = message.base); + message.display !== undefined && (obj.display = message.display); + message.name !== undefined && (obj.name = message.name); + message.symbol !== undefined && (obj.symbol = message.symbol); + return obj; + }, + + fromPartial(object: DeepPartial): Metadata { + const message = { ...baseMetadata } as Metadata; + message.denomUnits = []; + if (object.description !== undefined && object.description !== null) { + message.description = object.description; + } else { + message.description = ""; + } + if (object.denomUnits !== undefined && object.denomUnits !== null) { + for (const e of object.denomUnits) { + message.denomUnits.push(DenomUnit.fromPartial(e)); + } + } + if (object.base !== undefined && object.base !== null) { + message.base = object.base; + } else { + message.base = ""; + } + if (object.display !== undefined && object.display !== null) { + message.display = object.display; + } else { + message.display = ""; + } + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.symbol !== undefined && object.symbol !== null) { + message.symbol = object.symbol; + } else { + message.symbol = ""; + } + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/cosmos.bank.v1beta1/types/cosmos/bank/v1beta1/genesis.ts b/ts-client/cosmos.bank.v1beta1/types/cosmos/bank/v1beta1/genesis.ts new file mode 100644 index 00000000..b40fbcd9 --- /dev/null +++ b/ts-client/cosmos.bank.v1beta1/types/cosmos/bank/v1beta1/genesis.ts @@ -0,0 +1,254 @@ +/* eslint-disable */ +import { Params, Metadata } from "../../../cosmos/bank/v1beta1/bank"; +import { Coin } from "../../../cosmos/base/v1beta1/coin"; +import { Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "cosmos.bank.v1beta1"; + +/** GenesisState defines the bank module's genesis state. */ +export interface GenesisState { + /** params defines all the paramaters of the module. */ + params: Params | undefined; + /** balances is an array containing the balances of all the accounts. */ + balances: Balance[]; + /** + * supply represents the total supply. If it is left empty, then supply will be calculated based on the provided + * balances. Otherwise, it will be used to validate that the sum of the balances equals this amount. + */ + supply: Coin[]; + /** denom_metadata defines the metadata of the differents coins. */ + denomMetadata: Metadata[]; +} + +/** + * Balance defines an account address and balance pair used in the bank module's + * genesis state. + */ +export interface Balance { + /** address is the address of the balance holder. */ + address: string; + /** coins defines the different coins this balance holds. */ + coins: Coin[]; +} + +const baseGenesisState: object = {}; + +export const GenesisState = { + encode(message: GenesisState, writer: Writer = Writer.create()): Writer { + if (message.params !== undefined) { + Params.encode(message.params, writer.uint32(10).fork()).ldelim(); + } + for (const v of message.balances) { + Balance.encode(v!, writer.uint32(18).fork()).ldelim(); + } + for (const v of message.supply) { + Coin.encode(v!, writer.uint32(26).fork()).ldelim(); + } + for (const v of message.denomMetadata) { + Metadata.encode(v!, writer.uint32(34).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): GenesisState { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseGenesisState } as GenesisState; + message.balances = []; + message.supply = []; + message.denomMetadata = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.params = Params.decode(reader, reader.uint32()); + break; + case 2: + message.balances.push(Balance.decode(reader, reader.uint32())); + break; + case 3: + message.supply.push(Coin.decode(reader, reader.uint32())); + break; + case 4: + message.denomMetadata.push(Metadata.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GenesisState { + const message = { ...baseGenesisState } as GenesisState; + message.balances = []; + message.supply = []; + message.denomMetadata = []; + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromJSON(object.params); + } else { + message.params = undefined; + } + if (object.balances !== undefined && object.balances !== null) { + for (const e of object.balances) { + message.balances.push(Balance.fromJSON(e)); + } + } + if (object.supply !== undefined && object.supply !== null) { + for (const e of object.supply) { + message.supply.push(Coin.fromJSON(e)); + } + } + if (object.denomMetadata !== undefined && object.denomMetadata !== null) { + for (const e of object.denomMetadata) { + message.denomMetadata.push(Metadata.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: GenesisState): unknown { + const obj: any = {}; + message.params !== undefined && + (obj.params = message.params ? Params.toJSON(message.params) : undefined); + if (message.balances) { + obj.balances = message.balances.map((e) => + e ? Balance.toJSON(e) : undefined + ); + } else { + obj.balances = []; + } + if (message.supply) { + obj.supply = message.supply.map((e) => (e ? Coin.toJSON(e) : undefined)); + } else { + obj.supply = []; + } + if (message.denomMetadata) { + obj.denomMetadata = message.denomMetadata.map((e) => + e ? Metadata.toJSON(e) : undefined + ); + } else { + obj.denomMetadata = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): GenesisState { + const message = { ...baseGenesisState } as GenesisState; + message.balances = []; + message.supply = []; + message.denomMetadata = []; + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromPartial(object.params); + } else { + message.params = undefined; + } + if (object.balances !== undefined && object.balances !== null) { + for (const e of object.balances) { + message.balances.push(Balance.fromPartial(e)); + } + } + if (object.supply !== undefined && object.supply !== null) { + for (const e of object.supply) { + message.supply.push(Coin.fromPartial(e)); + } + } + if (object.denomMetadata !== undefined && object.denomMetadata !== null) { + for (const e of object.denomMetadata) { + message.denomMetadata.push(Metadata.fromPartial(e)); + } + } + return message; + }, +}; + +const baseBalance: object = { address: "" }; + +export const Balance = { + encode(message: Balance, writer: Writer = Writer.create()): Writer { + if (message.address !== "") { + writer.uint32(10).string(message.address); + } + for (const v of message.coins) { + Coin.encode(v!, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Balance { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseBalance } as Balance; + message.coins = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.address = reader.string(); + break; + case 2: + message.coins.push(Coin.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Balance { + const message = { ...baseBalance } as Balance; + message.coins = []; + if (object.address !== undefined && object.address !== null) { + message.address = String(object.address); + } else { + message.address = ""; + } + if (object.coins !== undefined && object.coins !== null) { + for (const e of object.coins) { + message.coins.push(Coin.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: Balance): unknown { + const obj: any = {}; + message.address !== undefined && (obj.address = message.address); + if (message.coins) { + obj.coins = message.coins.map((e) => (e ? Coin.toJSON(e) : undefined)); + } else { + obj.coins = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): Balance { + const message = { ...baseBalance } as Balance; + message.coins = []; + if (object.address !== undefined && object.address !== null) { + message.address = object.address; + } else { + message.address = ""; + } + if (object.coins !== undefined && object.coins !== null) { + for (const e of object.coins) { + message.coins.push(Coin.fromPartial(e)); + } + } + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/cosmos.bank.v1beta1/types/cosmos/bank/v1beta1/query.ts b/ts-client/cosmos.bank.v1beta1/types/cosmos/bank/v1beta1/query.ts new file mode 100644 index 00000000..611dbe7a --- /dev/null +++ b/ts-client/cosmos.bank.v1beta1/types/cosmos/bank/v1beta1/query.ts @@ -0,0 +1,1518 @@ +/* eslint-disable */ +import { Reader, Writer } from "protobufjs/minimal"; +import { Coin } from "../../../cosmos/base/v1beta1/coin"; +import { + PageRequest, + PageResponse, +} from "../../../cosmos/base/query/v1beta1/pagination"; +import { Params, Metadata } from "../../../cosmos/bank/v1beta1/bank"; + +export const protobufPackage = "cosmos.bank.v1beta1"; + +/** QueryBalanceRequest is the request type for the Query/Balance RPC method. */ +export interface QueryBalanceRequest { + /** address is the address to query balances for. */ + address: string; + /** denom is the coin denom to query balances for. */ + denom: string; +} + +/** QueryBalanceResponse is the response type for the Query/Balance RPC method. */ +export interface QueryBalanceResponse { + /** balance is the balance of the coin. */ + balance: Coin | undefined; +} + +/** QueryBalanceRequest is the request type for the Query/AllBalances RPC method. */ +export interface QueryAllBalancesRequest { + /** address is the address to query balances for. */ + address: string; + /** pagination defines an optional pagination for the request. */ + pagination: PageRequest | undefined; +} + +/** + * QueryAllBalancesResponse is the response type for the Query/AllBalances RPC + * method. + */ +export interface QueryAllBalancesResponse { + /** balances is the balances of all the coins. */ + balances: Coin[]; + /** pagination defines the pagination in the response. */ + pagination: PageResponse | undefined; +} + +/** + * QuerySpendableBalancesRequest defines the gRPC request structure for querying + * an account's spendable balances. + */ +export interface QuerySpendableBalancesRequest { + /** address is the address to query spendable balances for. */ + address: string; + /** pagination defines an optional pagination for the request. */ + pagination: PageRequest | undefined; +} + +/** + * QuerySpendableBalancesResponse defines the gRPC response structure for querying + * an account's spendable balances. + */ +export interface QuerySpendableBalancesResponse { + /** balances is the spendable balances of all the coins. */ + balances: Coin[]; + /** pagination defines the pagination in the response. */ + pagination: PageResponse | undefined; +} + +/** + * QueryTotalSupplyRequest is the request type for the Query/TotalSupply RPC + * method. + */ +export interface QueryTotalSupplyRequest { + /** + * pagination defines an optional pagination for the request. + * + * Since: cosmos-sdk 0.43 + */ + pagination: PageRequest | undefined; +} + +/** + * QueryTotalSupplyResponse is the response type for the Query/TotalSupply RPC + * method + */ +export interface QueryTotalSupplyResponse { + /** supply is the supply of the coins */ + supply: Coin[]; + /** + * pagination defines the pagination in the response. + * + * Since: cosmos-sdk 0.43 + */ + pagination: PageResponse | undefined; +} + +/** QuerySupplyOfRequest is the request type for the Query/SupplyOf RPC method. */ +export interface QuerySupplyOfRequest { + /** denom is the coin denom to query balances for. */ + denom: string; +} + +/** QuerySupplyOfResponse is the response type for the Query/SupplyOf RPC method. */ +export interface QuerySupplyOfResponse { + /** amount is the supply of the coin. */ + amount: Coin | undefined; +} + +/** QueryParamsRequest defines the request type for querying x/bank parameters. */ +export interface QueryParamsRequest {} + +/** QueryParamsResponse defines the response type for querying x/bank parameters. */ +export interface QueryParamsResponse { + params: Params | undefined; +} + +/** QueryDenomsMetadataRequest is the request type for the Query/DenomsMetadata RPC method. */ +export interface QueryDenomsMetadataRequest { + /** pagination defines an optional pagination for the request. */ + pagination: PageRequest | undefined; +} + +/** + * QueryDenomsMetadataResponse is the response type for the Query/DenomsMetadata RPC + * method. + */ +export interface QueryDenomsMetadataResponse { + /** metadata provides the client information for all the registered tokens. */ + metadatas: Metadata[]; + /** pagination defines the pagination in the response. */ + pagination: PageResponse | undefined; +} + +/** QueryDenomMetadataRequest is the request type for the Query/DenomMetadata RPC method. */ +export interface QueryDenomMetadataRequest { + /** denom is the coin denom to query the metadata for. */ + denom: string; +} + +/** + * QueryDenomMetadataResponse is the response type for the Query/DenomMetadata RPC + * method. + */ +export interface QueryDenomMetadataResponse { + /** metadata describes and provides all the client information for the requested token. */ + metadata: Metadata | undefined; +} + +const baseQueryBalanceRequest: object = { address: "", denom: "" }; + +export const QueryBalanceRequest = { + encode( + message: QueryBalanceRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.address !== "") { + writer.uint32(10).string(message.address); + } + if (message.denom !== "") { + writer.uint32(18).string(message.denom); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QueryBalanceRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryBalanceRequest } as QueryBalanceRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.address = reader.string(); + break; + case 2: + message.denom = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryBalanceRequest { + const message = { ...baseQueryBalanceRequest } as QueryBalanceRequest; + if (object.address !== undefined && object.address !== null) { + message.address = String(object.address); + } else { + message.address = ""; + } + if (object.denom !== undefined && object.denom !== null) { + message.denom = String(object.denom); + } else { + message.denom = ""; + } + return message; + }, + + toJSON(message: QueryBalanceRequest): unknown { + const obj: any = {}; + message.address !== undefined && (obj.address = message.address); + message.denom !== undefined && (obj.denom = message.denom); + return obj; + }, + + fromPartial(object: DeepPartial): QueryBalanceRequest { + const message = { ...baseQueryBalanceRequest } as QueryBalanceRequest; + if (object.address !== undefined && object.address !== null) { + message.address = object.address; + } else { + message.address = ""; + } + if (object.denom !== undefined && object.denom !== null) { + message.denom = object.denom; + } else { + message.denom = ""; + } + return message; + }, +}; + +const baseQueryBalanceResponse: object = {}; + +export const QueryBalanceResponse = { + encode( + message: QueryBalanceResponse, + writer: Writer = Writer.create() + ): Writer { + if (message.balance !== undefined) { + Coin.encode(message.balance, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QueryBalanceResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryBalanceResponse } as QueryBalanceResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.balance = Coin.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryBalanceResponse { + const message = { ...baseQueryBalanceResponse } as QueryBalanceResponse; + if (object.balance !== undefined && object.balance !== null) { + message.balance = Coin.fromJSON(object.balance); + } else { + message.balance = undefined; + } + return message; + }, + + toJSON(message: QueryBalanceResponse): unknown { + const obj: any = {}; + message.balance !== undefined && + (obj.balance = message.balance + ? Coin.toJSON(message.balance) + : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): QueryBalanceResponse { + const message = { ...baseQueryBalanceResponse } as QueryBalanceResponse; + if (object.balance !== undefined && object.balance !== null) { + message.balance = Coin.fromPartial(object.balance); + } else { + message.balance = undefined; + } + return message; + }, +}; + +const baseQueryAllBalancesRequest: object = { address: "" }; + +export const QueryAllBalancesRequest = { + encode( + message: QueryAllBalancesRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.address !== "") { + writer.uint32(10).string(message.address); + } + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QueryAllBalancesRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryAllBalancesRequest, + } as QueryAllBalancesRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.address = reader.string(); + break; + case 2: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryAllBalancesRequest { + const message = { + ...baseQueryAllBalancesRequest, + } as QueryAllBalancesRequest; + if (object.address !== undefined && object.address !== null) { + message.address = String(object.address); + } else { + message.address = ""; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryAllBalancesRequest): unknown { + const obj: any = {}; + message.address !== undefined && (obj.address = message.address); + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageRequest.toJSON(message.pagination) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryAllBalancesRequest { + const message = { + ...baseQueryAllBalancesRequest, + } as QueryAllBalancesRequest; + if (object.address !== undefined && object.address !== null) { + message.address = object.address; + } else { + message.address = ""; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseQueryAllBalancesResponse: object = {}; + +export const QueryAllBalancesResponse = { + encode( + message: QueryAllBalancesResponse, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.balances) { + Coin.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode( + message.pagination, + writer.uint32(18).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryAllBalancesResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryAllBalancesResponse, + } as QueryAllBalancesResponse; + message.balances = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.balances.push(Coin.decode(reader, reader.uint32())); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryAllBalancesResponse { + const message = { + ...baseQueryAllBalancesResponse, + } as QueryAllBalancesResponse; + message.balances = []; + if (object.balances !== undefined && object.balances !== null) { + for (const e of object.balances) { + message.balances.push(Coin.fromJSON(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryAllBalancesResponse): unknown { + const obj: any = {}; + if (message.balances) { + obj.balances = message.balances.map((e) => + e ? Coin.toJSON(e) : undefined + ); + } else { + obj.balances = []; + } + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageResponse.toJSON(message.pagination) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryAllBalancesResponse { + const message = { + ...baseQueryAllBalancesResponse, + } as QueryAllBalancesResponse; + message.balances = []; + if (object.balances !== undefined && object.balances !== null) { + for (const e of object.balances) { + message.balances.push(Coin.fromPartial(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseQuerySpendableBalancesRequest: object = { address: "" }; + +export const QuerySpendableBalancesRequest = { + encode( + message: QuerySpendableBalancesRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.address !== "") { + writer.uint32(10).string(message.address); + } + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QuerySpendableBalancesRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQuerySpendableBalancesRequest, + } as QuerySpendableBalancesRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.address = reader.string(); + break; + case 2: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QuerySpendableBalancesRequest { + const message = { + ...baseQuerySpendableBalancesRequest, + } as QuerySpendableBalancesRequest; + if (object.address !== undefined && object.address !== null) { + message.address = String(object.address); + } else { + message.address = ""; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QuerySpendableBalancesRequest): unknown { + const obj: any = {}; + message.address !== undefined && (obj.address = message.address); + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageRequest.toJSON(message.pagination) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QuerySpendableBalancesRequest { + const message = { + ...baseQuerySpendableBalancesRequest, + } as QuerySpendableBalancesRequest; + if (object.address !== undefined && object.address !== null) { + message.address = object.address; + } else { + message.address = ""; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseQuerySpendableBalancesResponse: object = {}; + +export const QuerySpendableBalancesResponse = { + encode( + message: QuerySpendableBalancesResponse, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.balances) { + Coin.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode( + message.pagination, + writer.uint32(18).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QuerySpendableBalancesResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQuerySpendableBalancesResponse, + } as QuerySpendableBalancesResponse; + message.balances = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.balances.push(Coin.decode(reader, reader.uint32())); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QuerySpendableBalancesResponse { + const message = { + ...baseQuerySpendableBalancesResponse, + } as QuerySpendableBalancesResponse; + message.balances = []; + if (object.balances !== undefined && object.balances !== null) { + for (const e of object.balances) { + message.balances.push(Coin.fromJSON(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QuerySpendableBalancesResponse): unknown { + const obj: any = {}; + if (message.balances) { + obj.balances = message.balances.map((e) => + e ? Coin.toJSON(e) : undefined + ); + } else { + obj.balances = []; + } + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageResponse.toJSON(message.pagination) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QuerySpendableBalancesResponse { + const message = { + ...baseQuerySpendableBalancesResponse, + } as QuerySpendableBalancesResponse; + message.balances = []; + if (object.balances !== undefined && object.balances !== null) { + for (const e of object.balances) { + message.balances.push(Coin.fromPartial(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseQueryTotalSupplyRequest: object = {}; + +export const QueryTotalSupplyRequest = { + encode( + message: QueryTotalSupplyRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QueryTotalSupplyRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryTotalSupplyRequest, + } as QueryTotalSupplyRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryTotalSupplyRequest { + const message = { + ...baseQueryTotalSupplyRequest, + } as QueryTotalSupplyRequest; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryTotalSupplyRequest): unknown { + const obj: any = {}; + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageRequest.toJSON(message.pagination) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryTotalSupplyRequest { + const message = { + ...baseQueryTotalSupplyRequest, + } as QueryTotalSupplyRequest; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseQueryTotalSupplyResponse: object = {}; + +export const QueryTotalSupplyResponse = { + encode( + message: QueryTotalSupplyResponse, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.supply) { + Coin.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode( + message.pagination, + writer.uint32(18).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryTotalSupplyResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryTotalSupplyResponse, + } as QueryTotalSupplyResponse; + message.supply = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.supply.push(Coin.decode(reader, reader.uint32())); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryTotalSupplyResponse { + const message = { + ...baseQueryTotalSupplyResponse, + } as QueryTotalSupplyResponse; + message.supply = []; + if (object.supply !== undefined && object.supply !== null) { + for (const e of object.supply) { + message.supply.push(Coin.fromJSON(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryTotalSupplyResponse): unknown { + const obj: any = {}; + if (message.supply) { + obj.supply = message.supply.map((e) => (e ? Coin.toJSON(e) : undefined)); + } else { + obj.supply = []; + } + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageResponse.toJSON(message.pagination) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryTotalSupplyResponse { + const message = { + ...baseQueryTotalSupplyResponse, + } as QueryTotalSupplyResponse; + message.supply = []; + if (object.supply !== undefined && object.supply !== null) { + for (const e of object.supply) { + message.supply.push(Coin.fromPartial(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseQuerySupplyOfRequest: object = { denom: "" }; + +export const QuerySupplyOfRequest = { + encode( + message: QuerySupplyOfRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.denom !== "") { + writer.uint32(10).string(message.denom); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QuerySupplyOfRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQuerySupplyOfRequest } as QuerySupplyOfRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.denom = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QuerySupplyOfRequest { + const message = { ...baseQuerySupplyOfRequest } as QuerySupplyOfRequest; + if (object.denom !== undefined && object.denom !== null) { + message.denom = String(object.denom); + } else { + message.denom = ""; + } + return message; + }, + + toJSON(message: QuerySupplyOfRequest): unknown { + const obj: any = {}; + message.denom !== undefined && (obj.denom = message.denom); + return obj; + }, + + fromPartial(object: DeepPartial): QuerySupplyOfRequest { + const message = { ...baseQuerySupplyOfRequest } as QuerySupplyOfRequest; + if (object.denom !== undefined && object.denom !== null) { + message.denom = object.denom; + } else { + message.denom = ""; + } + return message; + }, +}; + +const baseQuerySupplyOfResponse: object = {}; + +export const QuerySupplyOfResponse = { + encode( + message: QuerySupplyOfResponse, + writer: Writer = Writer.create() + ): Writer { + if (message.amount !== undefined) { + Coin.encode(message.amount, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QuerySupplyOfResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQuerySupplyOfResponse } as QuerySupplyOfResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.amount = Coin.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QuerySupplyOfResponse { + const message = { ...baseQuerySupplyOfResponse } as QuerySupplyOfResponse; + if (object.amount !== undefined && object.amount !== null) { + message.amount = Coin.fromJSON(object.amount); + } else { + message.amount = undefined; + } + return message; + }, + + toJSON(message: QuerySupplyOfResponse): unknown { + const obj: any = {}; + message.amount !== undefined && + (obj.amount = message.amount ? Coin.toJSON(message.amount) : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QuerySupplyOfResponse { + const message = { ...baseQuerySupplyOfResponse } as QuerySupplyOfResponse; + if (object.amount !== undefined && object.amount !== null) { + message.amount = Coin.fromPartial(object.amount); + } else { + message.amount = undefined; + } + return message; + }, +}; + +const baseQueryParamsRequest: object = {}; + +export const QueryParamsRequest = { + encode(_: QueryParamsRequest, writer: Writer = Writer.create()): Writer { + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QueryParamsRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryParamsRequest } as QueryParamsRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): QueryParamsRequest { + const message = { ...baseQueryParamsRequest } as QueryParamsRequest; + return message; + }, + + toJSON(_: QueryParamsRequest): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial(_: DeepPartial): QueryParamsRequest { + const message = { ...baseQueryParamsRequest } as QueryParamsRequest; + return message; + }, +}; + +const baseQueryParamsResponse: object = {}; + +export const QueryParamsResponse = { + encode( + message: QueryParamsResponse, + writer: Writer = Writer.create() + ): Writer { + if (message.params !== undefined) { + Params.encode(message.params, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QueryParamsResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryParamsResponse } as QueryParamsResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.params = Params.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryParamsResponse { + const message = { ...baseQueryParamsResponse } as QueryParamsResponse; + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromJSON(object.params); + } else { + message.params = undefined; + } + return message; + }, + + toJSON(message: QueryParamsResponse): unknown { + const obj: any = {}; + message.params !== undefined && + (obj.params = message.params ? Params.toJSON(message.params) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): QueryParamsResponse { + const message = { ...baseQueryParamsResponse } as QueryParamsResponse; + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromPartial(object.params); + } else { + message.params = undefined; + } + return message; + }, +}; + +const baseQueryDenomsMetadataRequest: object = {}; + +export const QueryDenomsMetadataRequest = { + encode( + message: QueryDenomsMetadataRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryDenomsMetadataRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryDenomsMetadataRequest, + } as QueryDenomsMetadataRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryDenomsMetadataRequest { + const message = { + ...baseQueryDenomsMetadataRequest, + } as QueryDenomsMetadataRequest; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryDenomsMetadataRequest): unknown { + const obj: any = {}; + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageRequest.toJSON(message.pagination) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryDenomsMetadataRequest { + const message = { + ...baseQueryDenomsMetadataRequest, + } as QueryDenomsMetadataRequest; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseQueryDenomsMetadataResponse: object = {}; + +export const QueryDenomsMetadataResponse = { + encode( + message: QueryDenomsMetadataResponse, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.metadatas) { + Metadata.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode( + message.pagination, + writer.uint32(18).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryDenomsMetadataResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryDenomsMetadataResponse, + } as QueryDenomsMetadataResponse; + message.metadatas = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.metadatas.push(Metadata.decode(reader, reader.uint32())); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryDenomsMetadataResponse { + const message = { + ...baseQueryDenomsMetadataResponse, + } as QueryDenomsMetadataResponse; + message.metadatas = []; + if (object.metadatas !== undefined && object.metadatas !== null) { + for (const e of object.metadatas) { + message.metadatas.push(Metadata.fromJSON(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryDenomsMetadataResponse): unknown { + const obj: any = {}; + if (message.metadatas) { + obj.metadatas = message.metadatas.map((e) => + e ? Metadata.toJSON(e) : undefined + ); + } else { + obj.metadatas = []; + } + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageResponse.toJSON(message.pagination) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryDenomsMetadataResponse { + const message = { + ...baseQueryDenomsMetadataResponse, + } as QueryDenomsMetadataResponse; + message.metadatas = []; + if (object.metadatas !== undefined && object.metadatas !== null) { + for (const e of object.metadatas) { + message.metadatas.push(Metadata.fromPartial(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseQueryDenomMetadataRequest: object = { denom: "" }; + +export const QueryDenomMetadataRequest = { + encode( + message: QueryDenomMetadataRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.denom !== "") { + writer.uint32(10).string(message.denom); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryDenomMetadataRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryDenomMetadataRequest, + } as QueryDenomMetadataRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.denom = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryDenomMetadataRequest { + const message = { + ...baseQueryDenomMetadataRequest, + } as QueryDenomMetadataRequest; + if (object.denom !== undefined && object.denom !== null) { + message.denom = String(object.denom); + } else { + message.denom = ""; + } + return message; + }, + + toJSON(message: QueryDenomMetadataRequest): unknown { + const obj: any = {}; + message.denom !== undefined && (obj.denom = message.denom); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryDenomMetadataRequest { + const message = { + ...baseQueryDenomMetadataRequest, + } as QueryDenomMetadataRequest; + if (object.denom !== undefined && object.denom !== null) { + message.denom = object.denom; + } else { + message.denom = ""; + } + return message; + }, +}; + +const baseQueryDenomMetadataResponse: object = {}; + +export const QueryDenomMetadataResponse = { + encode( + message: QueryDenomMetadataResponse, + writer: Writer = Writer.create() + ): Writer { + if (message.metadata !== undefined) { + Metadata.encode(message.metadata, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryDenomMetadataResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryDenomMetadataResponse, + } as QueryDenomMetadataResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.metadata = Metadata.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryDenomMetadataResponse { + const message = { + ...baseQueryDenomMetadataResponse, + } as QueryDenomMetadataResponse; + if (object.metadata !== undefined && object.metadata !== null) { + message.metadata = Metadata.fromJSON(object.metadata); + } else { + message.metadata = undefined; + } + return message; + }, + + toJSON(message: QueryDenomMetadataResponse): unknown { + const obj: any = {}; + message.metadata !== undefined && + (obj.metadata = message.metadata + ? Metadata.toJSON(message.metadata) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryDenomMetadataResponse { + const message = { + ...baseQueryDenomMetadataResponse, + } as QueryDenomMetadataResponse; + if (object.metadata !== undefined && object.metadata !== null) { + message.metadata = Metadata.fromPartial(object.metadata); + } else { + message.metadata = undefined; + } + return message; + }, +}; + +/** Query defines the gRPC querier service. */ +export interface Query { + /** Balance queries the balance of a single coin for a single account. */ + Balance(request: QueryBalanceRequest): Promise; + /** AllBalances queries the balance of all coins for a single account. */ + AllBalances( + request: QueryAllBalancesRequest + ): Promise; + /** + * SpendableBalances queries the spenable balance of all coins for a single + * account. + */ + SpendableBalances( + request: QuerySpendableBalancesRequest + ): Promise; + /** TotalSupply queries the total supply of all coins. */ + TotalSupply( + request: QueryTotalSupplyRequest + ): Promise; + /** SupplyOf queries the supply of a single coin. */ + SupplyOf(request: QuerySupplyOfRequest): Promise; + /** Params queries the parameters of x/bank module. */ + Params(request: QueryParamsRequest): Promise; + /** DenomsMetadata queries the client metadata of a given coin denomination. */ + DenomMetadata( + request: QueryDenomMetadataRequest + ): Promise; + /** DenomsMetadata queries the client metadata for all registered coin denominations. */ + DenomsMetadata( + request: QueryDenomsMetadataRequest + ): Promise; +} + +export class QueryClientImpl implements Query { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + } + Balance(request: QueryBalanceRequest): Promise { + const data = QueryBalanceRequest.encode(request).finish(); + const promise = this.rpc.request( + "cosmos.bank.v1beta1.Query", + "Balance", + data + ); + return promise.then((data) => + QueryBalanceResponse.decode(new Reader(data)) + ); + } + + AllBalances( + request: QueryAllBalancesRequest + ): Promise { + const data = QueryAllBalancesRequest.encode(request).finish(); + const promise = this.rpc.request( + "cosmos.bank.v1beta1.Query", + "AllBalances", + data + ); + return promise.then((data) => + QueryAllBalancesResponse.decode(new Reader(data)) + ); + } + + SpendableBalances( + request: QuerySpendableBalancesRequest + ): Promise { + const data = QuerySpendableBalancesRequest.encode(request).finish(); + const promise = this.rpc.request( + "cosmos.bank.v1beta1.Query", + "SpendableBalances", + data + ); + return promise.then((data) => + QuerySpendableBalancesResponse.decode(new Reader(data)) + ); + } + + TotalSupply( + request: QueryTotalSupplyRequest + ): Promise { + const data = QueryTotalSupplyRequest.encode(request).finish(); + const promise = this.rpc.request( + "cosmos.bank.v1beta1.Query", + "TotalSupply", + data + ); + return promise.then((data) => + QueryTotalSupplyResponse.decode(new Reader(data)) + ); + } + + SupplyOf(request: QuerySupplyOfRequest): Promise { + const data = QuerySupplyOfRequest.encode(request).finish(); + const promise = this.rpc.request( + "cosmos.bank.v1beta1.Query", + "SupplyOf", + data + ); + return promise.then((data) => + QuerySupplyOfResponse.decode(new Reader(data)) + ); + } + + Params(request: QueryParamsRequest): Promise { + const data = QueryParamsRequest.encode(request).finish(); + const promise = this.rpc.request( + "cosmos.bank.v1beta1.Query", + "Params", + data + ); + return promise.then((data) => QueryParamsResponse.decode(new Reader(data))); + } + + DenomMetadata( + request: QueryDenomMetadataRequest + ): Promise { + const data = QueryDenomMetadataRequest.encode(request).finish(); + const promise = this.rpc.request( + "cosmos.bank.v1beta1.Query", + "DenomMetadata", + data + ); + return promise.then((data) => + QueryDenomMetadataResponse.decode(new Reader(data)) + ); + } + + DenomsMetadata( + request: QueryDenomsMetadataRequest + ): Promise { + const data = QueryDenomsMetadataRequest.encode(request).finish(); + const promise = this.rpc.request( + "cosmos.bank.v1beta1.Query", + "DenomsMetadata", + data + ); + return promise.then((data) => + QueryDenomsMetadataResponse.decode(new Reader(data)) + ); + } +} + +interface Rpc { + request( + service: string, + method: string, + data: Uint8Array + ): Promise; +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/cosmos.bank.v1beta1/types/cosmos/bank/v1beta1/tx.ts b/ts-client/cosmos.bank.v1beta1/types/cosmos/bank/v1beta1/tx.ts new file mode 100644 index 00000000..7b3c53d1 --- /dev/null +++ b/ts-client/cosmos.bank.v1beta1/types/cosmos/bank/v1beta1/tx.ts @@ -0,0 +1,337 @@ +/* eslint-disable */ +import { Reader, Writer } from "protobufjs/minimal"; +import { Coin } from "../../../cosmos/base/v1beta1/coin"; +import { Input, Output } from "../../../cosmos/bank/v1beta1/bank"; + +export const protobufPackage = "cosmos.bank.v1beta1"; + +/** MsgSend represents a message to send coins from one account to another. */ +export interface MsgSend { + fromAddress: string; + toAddress: string; + amount: Coin[]; +} + +/** MsgSendResponse defines the Msg/Send response type. */ +export interface MsgSendResponse {} + +/** MsgMultiSend represents an arbitrary multi-in, multi-out send message. */ +export interface MsgMultiSend { + inputs: Input[]; + outputs: Output[]; +} + +/** MsgMultiSendResponse defines the Msg/MultiSend response type. */ +export interface MsgMultiSendResponse {} + +const baseMsgSend: object = { fromAddress: "", toAddress: "" }; + +export const MsgSend = { + encode(message: MsgSend, writer: Writer = Writer.create()): Writer { + if (message.fromAddress !== "") { + writer.uint32(10).string(message.fromAddress); + } + if (message.toAddress !== "") { + writer.uint32(18).string(message.toAddress); + } + for (const v of message.amount) { + Coin.encode(v!, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MsgSend { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgSend } as MsgSend; + message.amount = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.fromAddress = reader.string(); + break; + case 2: + message.toAddress = reader.string(); + break; + case 3: + message.amount.push(Coin.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgSend { + const message = { ...baseMsgSend } as MsgSend; + message.amount = []; + if (object.fromAddress !== undefined && object.fromAddress !== null) { + message.fromAddress = String(object.fromAddress); + } else { + message.fromAddress = ""; + } + if (object.toAddress !== undefined && object.toAddress !== null) { + message.toAddress = String(object.toAddress); + } else { + message.toAddress = ""; + } + if (object.amount !== undefined && object.amount !== null) { + for (const e of object.amount) { + message.amount.push(Coin.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: MsgSend): unknown { + const obj: any = {}; + message.fromAddress !== undefined && + (obj.fromAddress = message.fromAddress); + message.toAddress !== undefined && (obj.toAddress = message.toAddress); + if (message.amount) { + obj.amount = message.amount.map((e) => (e ? Coin.toJSON(e) : undefined)); + } else { + obj.amount = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): MsgSend { + const message = { ...baseMsgSend } as MsgSend; + message.amount = []; + if (object.fromAddress !== undefined && object.fromAddress !== null) { + message.fromAddress = object.fromAddress; + } else { + message.fromAddress = ""; + } + if (object.toAddress !== undefined && object.toAddress !== null) { + message.toAddress = object.toAddress; + } else { + message.toAddress = ""; + } + if (object.amount !== undefined && object.amount !== null) { + for (const e of object.amount) { + message.amount.push(Coin.fromPartial(e)); + } + } + return message; + }, +}; + +const baseMsgSendResponse: object = {}; + +export const MsgSendResponse = { + encode(_: MsgSendResponse, writer: Writer = Writer.create()): Writer { + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MsgSendResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgSendResponse } as MsgSendResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): MsgSendResponse { + const message = { ...baseMsgSendResponse } as MsgSendResponse; + return message; + }, + + toJSON(_: MsgSendResponse): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial(_: DeepPartial): MsgSendResponse { + const message = { ...baseMsgSendResponse } as MsgSendResponse; + return message; + }, +}; + +const baseMsgMultiSend: object = {}; + +export const MsgMultiSend = { + encode(message: MsgMultiSend, writer: Writer = Writer.create()): Writer { + for (const v of message.inputs) { + Input.encode(v!, writer.uint32(10).fork()).ldelim(); + } + for (const v of message.outputs) { + Output.encode(v!, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MsgMultiSend { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgMultiSend } as MsgMultiSend; + message.inputs = []; + message.outputs = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.inputs.push(Input.decode(reader, reader.uint32())); + break; + case 2: + message.outputs.push(Output.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgMultiSend { + const message = { ...baseMsgMultiSend } as MsgMultiSend; + message.inputs = []; + message.outputs = []; + if (object.inputs !== undefined && object.inputs !== null) { + for (const e of object.inputs) { + message.inputs.push(Input.fromJSON(e)); + } + } + if (object.outputs !== undefined && object.outputs !== null) { + for (const e of object.outputs) { + message.outputs.push(Output.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: MsgMultiSend): unknown { + const obj: any = {}; + if (message.inputs) { + obj.inputs = message.inputs.map((e) => (e ? Input.toJSON(e) : undefined)); + } else { + obj.inputs = []; + } + if (message.outputs) { + obj.outputs = message.outputs.map((e) => + e ? Output.toJSON(e) : undefined + ); + } else { + obj.outputs = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): MsgMultiSend { + const message = { ...baseMsgMultiSend } as MsgMultiSend; + message.inputs = []; + message.outputs = []; + if (object.inputs !== undefined && object.inputs !== null) { + for (const e of object.inputs) { + message.inputs.push(Input.fromPartial(e)); + } + } + if (object.outputs !== undefined && object.outputs !== null) { + for (const e of object.outputs) { + message.outputs.push(Output.fromPartial(e)); + } + } + return message; + }, +}; + +const baseMsgMultiSendResponse: object = {}; + +export const MsgMultiSendResponse = { + encode(_: MsgMultiSendResponse, writer: Writer = Writer.create()): Writer { + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MsgMultiSendResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgMultiSendResponse } as MsgMultiSendResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): MsgMultiSendResponse { + const message = { ...baseMsgMultiSendResponse } as MsgMultiSendResponse; + return message; + }, + + toJSON(_: MsgMultiSendResponse): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial(_: DeepPartial): MsgMultiSendResponse { + const message = { ...baseMsgMultiSendResponse } as MsgMultiSendResponse; + return message; + }, +}; + +/** Msg defines the bank Msg service. */ +export interface Msg { + /** Send defines a method for sending coins from one account to another account. */ + Send(request: MsgSend): Promise; + /** MultiSend defines a method for sending coins from some accounts to other accounts. */ + MultiSend(request: MsgMultiSend): Promise; +} + +export class MsgClientImpl implements Msg { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + } + Send(request: MsgSend): Promise { + const data = MsgSend.encode(request).finish(); + const promise = this.rpc.request("cosmos.bank.v1beta1.Msg", "Send", data); + return promise.then((data) => MsgSendResponse.decode(new Reader(data))); + } + + MultiSend(request: MsgMultiSend): Promise { + const data = MsgMultiSend.encode(request).finish(); + const promise = this.rpc.request( + "cosmos.bank.v1beta1.Msg", + "MultiSend", + data + ); + return promise.then((data) => + MsgMultiSendResponse.decode(new Reader(data)) + ); + } +} + +interface Rpc { + request( + service: string, + method: string, + data: Uint8Array + ): Promise; +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/cosmos.bank.v1beta1/types/cosmos/base/query/v1beta1/pagination.ts b/ts-client/cosmos.bank.v1beta1/types/cosmos/base/query/v1beta1/pagination.ts new file mode 100644 index 00000000..cd4b2d78 --- /dev/null +++ b/ts-client/cosmos.bank.v1beta1/types/cosmos/base/query/v1beta1/pagination.ts @@ -0,0 +1,327 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "cosmos.base.query.v1beta1"; + +/** + * PageRequest is to be embedded in gRPC request messages for efficient + * pagination. Ex: + * + * message SomeRequest { + * Foo some_parameter = 1; + * PageRequest pagination = 2; + * } + */ +export interface PageRequest { + /** + * key is a value returned in PageResponse.next_key to begin + * querying the next page most efficiently. Only one of offset or key + * should be set. + */ + key: Uint8Array; + /** + * offset is a numeric offset that can be used when key is unavailable. + * It is less efficient than using key. Only one of offset or key should + * be set. + */ + offset: number; + /** + * limit is the total number of results to be returned in the result page. + * If left empty it will default to a value to be set by each app. + */ + limit: number; + /** + * count_total is set to true to indicate that the result set should include + * a count of the total number of items available for pagination in UIs. + * count_total is only respected when offset is used. It is ignored when key + * is set. + */ + countTotal: boolean; + /** + * reverse is set to true if results are to be returned in the descending order. + * + * Since: cosmos-sdk 0.43 + */ + reverse: boolean; +} + +/** + * PageResponse is to be embedded in gRPC response messages where the + * corresponding request message has used PageRequest. + * + * message SomeResponse { + * repeated Bar results = 1; + * PageResponse page = 2; + * } + */ +export interface PageResponse { + /** + * next_key is the key to be passed to PageRequest.key to + * query the next page most efficiently + */ + nextKey: Uint8Array; + /** + * total is total number of results available if PageRequest.count_total + * was set, its value is undefined otherwise + */ + total: number; +} + +const basePageRequest: object = { + offset: 0, + limit: 0, + countTotal: false, + reverse: false, +}; + +export const PageRequest = { + encode(message: PageRequest, writer: Writer = Writer.create()): Writer { + if (message.key.length !== 0) { + writer.uint32(10).bytes(message.key); + } + if (message.offset !== 0) { + writer.uint32(16).uint64(message.offset); + } + if (message.limit !== 0) { + writer.uint32(24).uint64(message.limit); + } + if (message.countTotal === true) { + writer.uint32(32).bool(message.countTotal); + } + if (message.reverse === true) { + writer.uint32(40).bool(message.reverse); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): PageRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...basePageRequest } as PageRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.key = reader.bytes(); + break; + case 2: + message.offset = longToNumber(reader.uint64() as Long); + break; + case 3: + message.limit = longToNumber(reader.uint64() as Long); + break; + case 4: + message.countTotal = reader.bool(); + break; + case 5: + message.reverse = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): PageRequest { + const message = { ...basePageRequest } as PageRequest; + if (object.key !== undefined && object.key !== null) { + message.key = bytesFromBase64(object.key); + } + if (object.offset !== undefined && object.offset !== null) { + message.offset = Number(object.offset); + } else { + message.offset = 0; + } + if (object.limit !== undefined && object.limit !== null) { + message.limit = Number(object.limit); + } else { + message.limit = 0; + } + if (object.countTotal !== undefined && object.countTotal !== null) { + message.countTotal = Boolean(object.countTotal); + } else { + message.countTotal = false; + } + if (object.reverse !== undefined && object.reverse !== null) { + message.reverse = Boolean(object.reverse); + } else { + message.reverse = false; + } + return message; + }, + + toJSON(message: PageRequest): unknown { + const obj: any = {}; + message.key !== undefined && + (obj.key = base64FromBytes( + message.key !== undefined ? message.key : new Uint8Array() + )); + message.offset !== undefined && (obj.offset = message.offset); + message.limit !== undefined && (obj.limit = message.limit); + message.countTotal !== undefined && (obj.countTotal = message.countTotal); + message.reverse !== undefined && (obj.reverse = message.reverse); + return obj; + }, + + fromPartial(object: DeepPartial): PageRequest { + const message = { ...basePageRequest } as PageRequest; + if (object.key !== undefined && object.key !== null) { + message.key = object.key; + } else { + message.key = new Uint8Array(); + } + if (object.offset !== undefined && object.offset !== null) { + message.offset = object.offset; + } else { + message.offset = 0; + } + if (object.limit !== undefined && object.limit !== null) { + message.limit = object.limit; + } else { + message.limit = 0; + } + if (object.countTotal !== undefined && object.countTotal !== null) { + message.countTotal = object.countTotal; + } else { + message.countTotal = false; + } + if (object.reverse !== undefined && object.reverse !== null) { + message.reverse = object.reverse; + } else { + message.reverse = false; + } + return message; + }, +}; + +const basePageResponse: object = { total: 0 }; + +export const PageResponse = { + encode(message: PageResponse, writer: Writer = Writer.create()): Writer { + if (message.nextKey.length !== 0) { + writer.uint32(10).bytes(message.nextKey); + } + if (message.total !== 0) { + writer.uint32(16).uint64(message.total); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): PageResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...basePageResponse } as PageResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.nextKey = reader.bytes(); + break; + case 2: + message.total = longToNumber(reader.uint64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): PageResponse { + const message = { ...basePageResponse } as PageResponse; + if (object.nextKey !== undefined && object.nextKey !== null) { + message.nextKey = bytesFromBase64(object.nextKey); + } + if (object.total !== undefined && object.total !== null) { + message.total = Number(object.total); + } else { + message.total = 0; + } + return message; + }, + + toJSON(message: PageResponse): unknown { + const obj: any = {}; + message.nextKey !== undefined && + (obj.nextKey = base64FromBytes( + message.nextKey !== undefined ? message.nextKey : new Uint8Array() + )); + message.total !== undefined && (obj.total = message.total); + return obj; + }, + + fromPartial(object: DeepPartial): PageResponse { + const message = { ...basePageResponse } as PageResponse; + if (object.nextKey !== undefined && object.nextKey !== null) { + message.nextKey = object.nextKey; + } else { + message.nextKey = new Uint8Array(); + } + if (object.total !== undefined && object.total !== null) { + message.total = object.total; + } else { + message.total = 0; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/cosmos.bank.v1beta1/types/cosmos/base/v1beta1/coin.ts b/ts-client/cosmos.bank.v1beta1/types/cosmos/base/v1beta1/coin.ts new file mode 100644 index 00000000..ce2ac984 --- /dev/null +++ b/ts-client/cosmos.bank.v1beta1/types/cosmos/base/v1beta1/coin.ts @@ -0,0 +1,301 @@ +/* eslint-disable */ +import { Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "cosmos.base.v1beta1"; + +/** + * Coin defines a token with a denomination and an amount. + * + * NOTE: The amount field is an Int which implements the custom method + * signatures required by gogoproto. + */ +export interface Coin { + denom: string; + amount: string; +} + +/** + * DecCoin defines a token with a denomination and a decimal amount. + * + * NOTE: The amount field is an Dec which implements the custom method + * signatures required by gogoproto. + */ +export interface DecCoin { + denom: string; + amount: string; +} + +/** IntProto defines a Protobuf wrapper around an Int object. */ +export interface IntProto { + int: string; +} + +/** DecProto defines a Protobuf wrapper around a Dec object. */ +export interface DecProto { + dec: string; +} + +const baseCoin: object = { denom: "", amount: "" }; + +export const Coin = { + encode(message: Coin, writer: Writer = Writer.create()): Writer { + if (message.denom !== "") { + writer.uint32(10).string(message.denom); + } + if (message.amount !== "") { + writer.uint32(18).string(message.amount); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Coin { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseCoin } as Coin; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.denom = reader.string(); + break; + case 2: + message.amount = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Coin { + const message = { ...baseCoin } as Coin; + if (object.denom !== undefined && object.denom !== null) { + message.denom = String(object.denom); + } else { + message.denom = ""; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = String(object.amount); + } else { + message.amount = ""; + } + return message; + }, + + toJSON(message: Coin): unknown { + const obj: any = {}; + message.denom !== undefined && (obj.denom = message.denom); + message.amount !== undefined && (obj.amount = message.amount); + return obj; + }, + + fromPartial(object: DeepPartial): Coin { + const message = { ...baseCoin } as Coin; + if (object.denom !== undefined && object.denom !== null) { + message.denom = object.denom; + } else { + message.denom = ""; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = object.amount; + } else { + message.amount = ""; + } + return message; + }, +}; + +const baseDecCoin: object = { denom: "", amount: "" }; + +export const DecCoin = { + encode(message: DecCoin, writer: Writer = Writer.create()): Writer { + if (message.denom !== "") { + writer.uint32(10).string(message.denom); + } + if (message.amount !== "") { + writer.uint32(18).string(message.amount); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): DecCoin { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseDecCoin } as DecCoin; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.denom = reader.string(); + break; + case 2: + message.amount = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DecCoin { + const message = { ...baseDecCoin } as DecCoin; + if (object.denom !== undefined && object.denom !== null) { + message.denom = String(object.denom); + } else { + message.denom = ""; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = String(object.amount); + } else { + message.amount = ""; + } + return message; + }, + + toJSON(message: DecCoin): unknown { + const obj: any = {}; + message.denom !== undefined && (obj.denom = message.denom); + message.amount !== undefined && (obj.amount = message.amount); + return obj; + }, + + fromPartial(object: DeepPartial): DecCoin { + const message = { ...baseDecCoin } as DecCoin; + if (object.denom !== undefined && object.denom !== null) { + message.denom = object.denom; + } else { + message.denom = ""; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = object.amount; + } else { + message.amount = ""; + } + return message; + }, +}; + +const baseIntProto: object = { int: "" }; + +export const IntProto = { + encode(message: IntProto, writer: Writer = Writer.create()): Writer { + if (message.int !== "") { + writer.uint32(10).string(message.int); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): IntProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseIntProto } as IntProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.int = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): IntProto { + const message = { ...baseIntProto } as IntProto; + if (object.int !== undefined && object.int !== null) { + message.int = String(object.int); + } else { + message.int = ""; + } + return message; + }, + + toJSON(message: IntProto): unknown { + const obj: any = {}; + message.int !== undefined && (obj.int = message.int); + return obj; + }, + + fromPartial(object: DeepPartial): IntProto { + const message = { ...baseIntProto } as IntProto; + if (object.int !== undefined && object.int !== null) { + message.int = object.int; + } else { + message.int = ""; + } + return message; + }, +}; + +const baseDecProto: object = { dec: "" }; + +export const DecProto = { + encode(message: DecProto, writer: Writer = Writer.create()): Writer { + if (message.dec !== "") { + writer.uint32(10).string(message.dec); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): DecProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseDecProto } as DecProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.dec = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DecProto { + const message = { ...baseDecProto } as DecProto; + if (object.dec !== undefined && object.dec !== null) { + message.dec = String(object.dec); + } else { + message.dec = ""; + } + return message; + }, + + toJSON(message: DecProto): unknown { + const obj: any = {}; + message.dec !== undefined && (obj.dec = message.dec); + return obj; + }, + + fromPartial(object: DeepPartial): DecProto { + const message = { ...baseDecProto } as DecProto; + if (object.dec !== undefined && object.dec !== null) { + message.dec = object.dec; + } else { + message.dec = ""; + } + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/cosmos.bank.v1beta1/types/cosmos_proto/cosmos.ts b/ts-client/cosmos.bank.v1beta1/types/cosmos_proto/cosmos.ts new file mode 100644 index 00000000..9ec67a12 --- /dev/null +++ b/ts-client/cosmos.bank.v1beta1/types/cosmos_proto/cosmos.ts @@ -0,0 +1,2 @@ +/* eslint-disable */ +export const protobufPackage = "cosmos_proto"; diff --git a/ts-client/cosmos.bank.v1beta1/types/gogoproto/gogo.ts b/ts-client/cosmos.bank.v1beta1/types/gogoproto/gogo.ts new file mode 100644 index 00000000..3f41a047 --- /dev/null +++ b/ts-client/cosmos.bank.v1beta1/types/gogoproto/gogo.ts @@ -0,0 +1,2 @@ +/* eslint-disable */ +export const protobufPackage = "gogoproto"; diff --git a/ts-client/cosmos.bank.v1beta1/types/google/api/annotations.ts b/ts-client/cosmos.bank.v1beta1/types/google/api/annotations.ts new file mode 100644 index 00000000..aace4787 --- /dev/null +++ b/ts-client/cosmos.bank.v1beta1/types/google/api/annotations.ts @@ -0,0 +1,2 @@ +/* eslint-disable */ +export const protobufPackage = "google.api"; diff --git a/ts-client/cosmos.bank.v1beta1/types/google/api/http.ts b/ts-client/cosmos.bank.v1beta1/types/google/api/http.ts new file mode 100644 index 00000000..ddc00f8b --- /dev/null +++ b/ts-client/cosmos.bank.v1beta1/types/google/api/http.ts @@ -0,0 +1,705 @@ +/* eslint-disable */ +import { Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "google.api"; + +/** + * Defines the HTTP configuration for an API service. It contains a list of + * [HttpRule][google.api.HttpRule], each specifying the mapping of an RPC method + * to one or more HTTP REST API methods. + */ +export interface Http { + /** + * A list of HTTP configuration rules that apply to individual API methods. + * + * **NOTE:** All service configuration rules follow "last one wins" order. + */ + rules: HttpRule[]; + /** + * When set to true, URL path parmeters will be fully URI-decoded except in + * cases of single segment matches in reserved expansion, where "%2F" will be + * left encoded. + * + * The default behavior is to not decode RFC 6570 reserved characters in multi + * segment matches. + */ + fullyDecodeReservedExpansion: boolean; +} + +/** + * `HttpRule` defines the mapping of an RPC method to one or more HTTP + * REST API methods. The mapping specifies how different portions of the RPC + * request message are mapped to URL path, URL query parameters, and + * HTTP request body. The mapping is typically specified as an + * `google.api.http` annotation on the RPC method, + * see "google/api/annotations.proto" for details. + * + * The mapping consists of a field specifying the path template and + * method kind. The path template can refer to fields in the request + * message, as in the example below which describes a REST GET + * operation on a resource collection of messages: + * + * + * service Messaging { + * rpc GetMessage(GetMessageRequest) returns (Message) { + * option (google.api.http).get = "/v1/messages/{message_id}/{sub.subfield}"; + * } + * } + * message GetMessageRequest { + * message SubMessage { + * string subfield = 1; + * } + * string message_id = 1; // mapped to the URL + * SubMessage sub = 2; // `sub.subfield` is url-mapped + * } + * message Message { + * string text = 1; // content of the resource + * } + * + * The same http annotation can alternatively be expressed inside the + * `GRPC API Configuration` YAML file. + * + * http: + * rules: + * - selector: .Messaging.GetMessage + * get: /v1/messages/{message_id}/{sub.subfield} + * + * This definition enables an automatic, bidrectional mapping of HTTP + * JSON to RPC. Example: + * + * HTTP | RPC + * -----|----- + * `GET /v1/messages/123456/foo` | `GetMessage(message_id: "123456" sub: SubMessage(subfield: "foo"))` + * + * In general, not only fields but also field paths can be referenced + * from a path pattern. Fields mapped to the path pattern cannot be + * repeated and must have a primitive (non-message) type. + * + * Any fields in the request message which are not bound by the path + * pattern automatically become (optional) HTTP query + * parameters. Assume the following definition of the request message: + * + * + * service Messaging { + * rpc GetMessage(GetMessageRequest) returns (Message) { + * option (google.api.http).get = "/v1/messages/{message_id}"; + * } + * } + * message GetMessageRequest { + * message SubMessage { + * string subfield = 1; + * } + * string message_id = 1; // mapped to the URL + * int64 revision = 2; // becomes a parameter + * SubMessage sub = 3; // `sub.subfield` becomes a parameter + * } + * + * + * This enables a HTTP JSON to RPC mapping as below: + * + * HTTP | RPC + * -----|----- + * `GET /v1/messages/123456?revision=2&sub.subfield=foo` | `GetMessage(message_id: "123456" revision: 2 sub: SubMessage(subfield: "foo"))` + * + * Note that fields which are mapped to HTTP parameters must have a + * primitive type or a repeated primitive type. Message types are not + * allowed. In the case of a repeated type, the parameter can be + * repeated in the URL, as in `...?param=A¶m=B`. + * + * For HTTP method kinds which allow a request body, the `body` field + * specifies the mapping. Consider a REST update method on the + * message resource collection: + * + * + * service Messaging { + * rpc UpdateMessage(UpdateMessageRequest) returns (Message) { + * option (google.api.http) = { + * put: "/v1/messages/{message_id}" + * body: "message" + * }; + * } + * } + * message UpdateMessageRequest { + * string message_id = 1; // mapped to the URL + * Message message = 2; // mapped to the body + * } + * + * + * The following HTTP JSON to RPC mapping is enabled, where the + * representation of the JSON in the request body is determined by + * protos JSON encoding: + * + * HTTP | RPC + * -----|----- + * `PUT /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: "123456" message { text: "Hi!" })` + * + * The special name `*` can be used in the body mapping to define that + * every field not bound by the path template should be mapped to the + * request body. This enables the following alternative definition of + * the update method: + * + * service Messaging { + * rpc UpdateMessage(Message) returns (Message) { + * option (google.api.http) = { + * put: "/v1/messages/{message_id}" + * body: "*" + * }; + * } + * } + * message Message { + * string message_id = 1; + * string text = 2; + * } + * + * + * The following HTTP JSON to RPC mapping is enabled: + * + * HTTP | RPC + * -----|----- + * `PUT /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: "123456" text: "Hi!")` + * + * Note that when using `*` in the body mapping, it is not possible to + * have HTTP parameters, as all fields not bound by the path end in + * the body. This makes this option more rarely used in practice of + * defining REST APIs. The common usage of `*` is in custom methods + * which don't use the URL at all for transferring data. + * + * It is possible to define multiple HTTP methods for one RPC by using + * the `additional_bindings` option. Example: + * + * service Messaging { + * rpc GetMessage(GetMessageRequest) returns (Message) { + * option (google.api.http) = { + * get: "/v1/messages/{message_id}" + * additional_bindings { + * get: "/v1/users/{user_id}/messages/{message_id}" + * } + * }; + * } + * } + * message GetMessageRequest { + * string message_id = 1; + * string user_id = 2; + * } + * + * + * This enables the following two alternative HTTP JSON to RPC + * mappings: + * + * HTTP | RPC + * -----|----- + * `GET /v1/messages/123456` | `GetMessage(message_id: "123456")` + * `GET /v1/users/me/messages/123456` | `GetMessage(user_id: "me" message_id: "123456")` + * + * # Rules for HTTP mapping + * + * The rules for mapping HTTP path, query parameters, and body fields + * to the request message are as follows: + * + * 1. The `body` field specifies either `*` or a field path, or is + * omitted. If omitted, it indicates there is no HTTP request body. + * 2. Leaf fields (recursive expansion of nested messages in the + * request) can be classified into three types: + * (a) Matched in the URL template. + * (b) Covered by body (if body is `*`, everything except (a) fields; + * else everything under the body field) + * (c) All other fields. + * 3. URL query parameters found in the HTTP request are mapped to (c) fields. + * 4. Any body sent with an HTTP request can contain only (b) fields. + * + * The syntax of the path template is as follows: + * + * Template = "/" Segments [ Verb ] ; + * Segments = Segment { "/" Segment } ; + * Segment = "*" | "**" | LITERAL | Variable ; + * Variable = "{" FieldPath [ "=" Segments ] "}" ; + * FieldPath = IDENT { "." IDENT } ; + * Verb = ":" LITERAL ; + * + * The syntax `*` matches a single path segment. The syntax `**` matches zero + * or more path segments, which must be the last part of the path except the + * `Verb`. The syntax `LITERAL` matches literal text in the path. + * + * The syntax `Variable` matches part of the URL path as specified by its + * template. A variable template must not contain other variables. If a variable + * matches a single path segment, its template may be omitted, e.g. `{var}` + * is equivalent to `{var=*}`. + * + * If a variable contains exactly one path segment, such as `"{var}"` or + * `"{var=*}"`, when such a variable is expanded into a URL path, all characters + * except `[-_.~0-9a-zA-Z]` are percent-encoded. Such variables show up in the + * Discovery Document as `{var}`. + * + * If a variable contains one or more path segments, such as `"{var=foo/*}"` + * or `"{var=**}"`, when such a variable is expanded into a URL path, all + * characters except `[-_.~/0-9a-zA-Z]` are percent-encoded. Such variables + * show up in the Discovery Document as `{+var}`. + * + * NOTE: While the single segment variable matches the semantics of + * [RFC 6570](https://tools.ietf.org/html/rfc6570) Section 3.2.2 + * Simple String Expansion, the multi segment variable **does not** match + * RFC 6570 Reserved Expansion. The reason is that the Reserved Expansion + * does not expand special characters like `?` and `#`, which would lead + * to invalid URLs. + * + * NOTE: the field paths in variables and in the `body` must not refer to + * repeated fields or map fields. + */ +export interface HttpRule { + /** + * Selects methods to which this rule applies. + * + * Refer to [selector][google.api.DocumentationRule.selector] for syntax details. + */ + selector: string; + /** Used for listing and getting information about resources. */ + get: string | undefined; + /** Used for updating a resource. */ + put: string | undefined; + /** Used for creating a resource. */ + post: string | undefined; + /** Used for deleting a resource. */ + delete: string | undefined; + /** Used for updating a resource. */ + patch: string | undefined; + /** + * The custom pattern is used for specifying an HTTP method that is not + * included in the `pattern` field, such as HEAD, or "*" to leave the + * HTTP method unspecified for this rule. The wild-card rule is useful + * for services that provide content to Web (HTML) clients. + */ + custom: CustomHttpPattern | undefined; + /** + * The name of the request field whose value is mapped to the HTTP body, or + * `*` for mapping all fields not captured by the path pattern to the HTTP + * body. NOTE: the referred field must not be a repeated field and must be + * present at the top-level of request message type. + */ + body: string; + /** + * Optional. The name of the response field whose value is mapped to the HTTP + * body of response. Other response fields are ignored. When + * not set, the response message will be used as HTTP body of response. + */ + responseBody: string; + /** + * Additional HTTP bindings for the selector. Nested bindings must + * not contain an `additional_bindings` field themselves (that is, + * the nesting may only be one level deep). + */ + additionalBindings: HttpRule[]; +} + +/** A custom pattern is used for defining custom HTTP verb. */ +export interface CustomHttpPattern { + /** The name of this custom HTTP verb. */ + kind: string; + /** The path matched by this custom verb. */ + path: string; +} + +const baseHttp: object = { fullyDecodeReservedExpansion: false }; + +export const Http = { + encode(message: Http, writer: Writer = Writer.create()): Writer { + for (const v of message.rules) { + HttpRule.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.fullyDecodeReservedExpansion === true) { + writer.uint32(16).bool(message.fullyDecodeReservedExpansion); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Http { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseHttp } as Http; + message.rules = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.rules.push(HttpRule.decode(reader, reader.uint32())); + break; + case 2: + message.fullyDecodeReservedExpansion = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Http { + const message = { ...baseHttp } as Http; + message.rules = []; + if (object.rules !== undefined && object.rules !== null) { + for (const e of object.rules) { + message.rules.push(HttpRule.fromJSON(e)); + } + } + if ( + object.fullyDecodeReservedExpansion !== undefined && + object.fullyDecodeReservedExpansion !== null + ) { + message.fullyDecodeReservedExpansion = Boolean( + object.fullyDecodeReservedExpansion + ); + } else { + message.fullyDecodeReservedExpansion = false; + } + return message; + }, + + toJSON(message: Http): unknown { + const obj: any = {}; + if (message.rules) { + obj.rules = message.rules.map((e) => + e ? HttpRule.toJSON(e) : undefined + ); + } else { + obj.rules = []; + } + message.fullyDecodeReservedExpansion !== undefined && + (obj.fullyDecodeReservedExpansion = message.fullyDecodeReservedExpansion); + return obj; + }, + + fromPartial(object: DeepPartial): Http { + const message = { ...baseHttp } as Http; + message.rules = []; + if (object.rules !== undefined && object.rules !== null) { + for (const e of object.rules) { + message.rules.push(HttpRule.fromPartial(e)); + } + } + if ( + object.fullyDecodeReservedExpansion !== undefined && + object.fullyDecodeReservedExpansion !== null + ) { + message.fullyDecodeReservedExpansion = + object.fullyDecodeReservedExpansion; + } else { + message.fullyDecodeReservedExpansion = false; + } + return message; + }, +}; + +const baseHttpRule: object = { selector: "", body: "", responseBody: "" }; + +export const HttpRule = { + encode(message: HttpRule, writer: Writer = Writer.create()): Writer { + if (message.selector !== "") { + writer.uint32(10).string(message.selector); + } + if (message.get !== undefined) { + writer.uint32(18).string(message.get); + } + if (message.put !== undefined) { + writer.uint32(26).string(message.put); + } + if (message.post !== undefined) { + writer.uint32(34).string(message.post); + } + if (message.delete !== undefined) { + writer.uint32(42).string(message.delete); + } + if (message.patch !== undefined) { + writer.uint32(50).string(message.patch); + } + if (message.custom !== undefined) { + CustomHttpPattern.encode( + message.custom, + writer.uint32(66).fork() + ).ldelim(); + } + if (message.body !== "") { + writer.uint32(58).string(message.body); + } + if (message.responseBody !== "") { + writer.uint32(98).string(message.responseBody); + } + for (const v of message.additionalBindings) { + HttpRule.encode(v!, writer.uint32(90).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): HttpRule { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseHttpRule } as HttpRule; + message.additionalBindings = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.selector = reader.string(); + break; + case 2: + message.get = reader.string(); + break; + case 3: + message.put = reader.string(); + break; + case 4: + message.post = reader.string(); + break; + case 5: + message.delete = reader.string(); + break; + case 6: + message.patch = reader.string(); + break; + case 8: + message.custom = CustomHttpPattern.decode(reader, reader.uint32()); + break; + case 7: + message.body = reader.string(); + break; + case 12: + message.responseBody = reader.string(); + break; + case 11: + message.additionalBindings.push( + HttpRule.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): HttpRule { + const message = { ...baseHttpRule } as HttpRule; + message.additionalBindings = []; + if (object.selector !== undefined && object.selector !== null) { + message.selector = String(object.selector); + } else { + message.selector = ""; + } + if (object.get !== undefined && object.get !== null) { + message.get = String(object.get); + } else { + message.get = undefined; + } + if (object.put !== undefined && object.put !== null) { + message.put = String(object.put); + } else { + message.put = undefined; + } + if (object.post !== undefined && object.post !== null) { + message.post = String(object.post); + } else { + message.post = undefined; + } + if (object.delete !== undefined && object.delete !== null) { + message.delete = String(object.delete); + } else { + message.delete = undefined; + } + if (object.patch !== undefined && object.patch !== null) { + message.patch = String(object.patch); + } else { + message.patch = undefined; + } + if (object.custom !== undefined && object.custom !== null) { + message.custom = CustomHttpPattern.fromJSON(object.custom); + } else { + message.custom = undefined; + } + if (object.body !== undefined && object.body !== null) { + message.body = String(object.body); + } else { + message.body = ""; + } + if (object.responseBody !== undefined && object.responseBody !== null) { + message.responseBody = String(object.responseBody); + } else { + message.responseBody = ""; + } + if ( + object.additionalBindings !== undefined && + object.additionalBindings !== null + ) { + for (const e of object.additionalBindings) { + message.additionalBindings.push(HttpRule.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: HttpRule): unknown { + const obj: any = {}; + message.selector !== undefined && (obj.selector = message.selector); + message.get !== undefined && (obj.get = message.get); + message.put !== undefined && (obj.put = message.put); + message.post !== undefined && (obj.post = message.post); + message.delete !== undefined && (obj.delete = message.delete); + message.patch !== undefined && (obj.patch = message.patch); + message.custom !== undefined && + (obj.custom = message.custom + ? CustomHttpPattern.toJSON(message.custom) + : undefined); + message.body !== undefined && (obj.body = message.body); + message.responseBody !== undefined && + (obj.responseBody = message.responseBody); + if (message.additionalBindings) { + obj.additionalBindings = message.additionalBindings.map((e) => + e ? HttpRule.toJSON(e) : undefined + ); + } else { + obj.additionalBindings = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): HttpRule { + const message = { ...baseHttpRule } as HttpRule; + message.additionalBindings = []; + if (object.selector !== undefined && object.selector !== null) { + message.selector = object.selector; + } else { + message.selector = ""; + } + if (object.get !== undefined && object.get !== null) { + message.get = object.get; + } else { + message.get = undefined; + } + if (object.put !== undefined && object.put !== null) { + message.put = object.put; + } else { + message.put = undefined; + } + if (object.post !== undefined && object.post !== null) { + message.post = object.post; + } else { + message.post = undefined; + } + if (object.delete !== undefined && object.delete !== null) { + message.delete = object.delete; + } else { + message.delete = undefined; + } + if (object.patch !== undefined && object.patch !== null) { + message.patch = object.patch; + } else { + message.patch = undefined; + } + if (object.custom !== undefined && object.custom !== null) { + message.custom = CustomHttpPattern.fromPartial(object.custom); + } else { + message.custom = undefined; + } + if (object.body !== undefined && object.body !== null) { + message.body = object.body; + } else { + message.body = ""; + } + if (object.responseBody !== undefined && object.responseBody !== null) { + message.responseBody = object.responseBody; + } else { + message.responseBody = ""; + } + if ( + object.additionalBindings !== undefined && + object.additionalBindings !== null + ) { + for (const e of object.additionalBindings) { + message.additionalBindings.push(HttpRule.fromPartial(e)); + } + } + return message; + }, +}; + +const baseCustomHttpPattern: object = { kind: "", path: "" }; + +export const CustomHttpPattern = { + encode(message: CustomHttpPattern, writer: Writer = Writer.create()): Writer { + if (message.kind !== "") { + writer.uint32(10).string(message.kind); + } + if (message.path !== "") { + writer.uint32(18).string(message.path); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): CustomHttpPattern { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseCustomHttpPattern } as CustomHttpPattern; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.kind = reader.string(); + break; + case 2: + message.path = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): CustomHttpPattern { + const message = { ...baseCustomHttpPattern } as CustomHttpPattern; + if (object.kind !== undefined && object.kind !== null) { + message.kind = String(object.kind); + } else { + message.kind = ""; + } + if (object.path !== undefined && object.path !== null) { + message.path = String(object.path); + } else { + message.path = ""; + } + return message; + }, + + toJSON(message: CustomHttpPattern): unknown { + const obj: any = {}; + message.kind !== undefined && (obj.kind = message.kind); + message.path !== undefined && (obj.path = message.path); + return obj; + }, + + fromPartial(object: DeepPartial): CustomHttpPattern { + const message = { ...baseCustomHttpPattern } as CustomHttpPattern; + if (object.kind !== undefined && object.kind !== null) { + message.kind = object.kind; + } else { + message.kind = ""; + } + if (object.path !== undefined && object.path !== null) { + message.path = object.path; + } else { + message.path = ""; + } + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/cosmos.bank.v1beta1/types/google/protobuf/descriptor.ts b/ts-client/cosmos.bank.v1beta1/types/google/protobuf/descriptor.ts new file mode 100644 index 00000000..9e508660 --- /dev/null +++ b/ts-client/cosmos.bank.v1beta1/types/google/protobuf/descriptor.ts @@ -0,0 +1,5261 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "google.protobuf"; + +/** + * The protocol compiler can output a FileDescriptorSet containing the .proto + * files it parses. + */ +export interface FileDescriptorSet { + file: FileDescriptorProto[]; +} + +/** Describes a complete .proto file. */ +export interface FileDescriptorProto { + /** file name, relative to root of source tree */ + name: string; + /** e.g. "foo", "foo.bar", etc. */ + package: string; + /** Names of files imported by this file. */ + dependency: string[]; + /** Indexes of the public imported files in the dependency list above. */ + publicDependency: number[]; + /** + * Indexes of the weak imported files in the dependency list. + * For Google-internal migration only. Do not use. + */ + weakDependency: number[]; + /** All top-level definitions in this file. */ + messageType: DescriptorProto[]; + enumType: EnumDescriptorProto[]; + service: ServiceDescriptorProto[]; + extension: FieldDescriptorProto[]; + options: FileOptions | undefined; + /** + * This field contains optional information about the original source code. + * You may safely remove this entire field without harming runtime + * functionality of the descriptors -- the information is needed only by + * development tools. + */ + sourceCodeInfo: SourceCodeInfo | undefined; + /** + * The syntax of the proto file. + * The supported values are "proto2" and "proto3". + */ + syntax: string; +} + +/** Describes a message type. */ +export interface DescriptorProto { + name: string; + field: FieldDescriptorProto[]; + extension: FieldDescriptorProto[]; + nestedType: DescriptorProto[]; + enumType: EnumDescriptorProto[]; + extensionRange: DescriptorProto_ExtensionRange[]; + oneofDecl: OneofDescriptorProto[]; + options: MessageOptions | undefined; + reservedRange: DescriptorProto_ReservedRange[]; + /** + * Reserved field names, which may not be used by fields in the same message. + * A given name may only be reserved once. + */ + reservedName: string[]; +} + +export interface DescriptorProto_ExtensionRange { + /** Inclusive. */ + start: number; + /** Exclusive. */ + end: number; + options: ExtensionRangeOptions | undefined; +} + +/** + * Range of reserved tag numbers. Reserved tag numbers may not be used by + * fields or extension ranges in the same message. Reserved ranges may + * not overlap. + */ +export interface DescriptorProto_ReservedRange { + /** Inclusive. */ + start: number; + /** Exclusive. */ + end: number; +} + +export interface ExtensionRangeOptions { + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +/** Describes a field within a message. */ +export interface FieldDescriptorProto { + name: string; + number: number; + label: FieldDescriptorProto_Label; + /** + * If type_name is set, this need not be set. If both this and type_name + * are set, this must be one of TYPE_ENUM, TYPE_MESSAGE or TYPE_GROUP. + */ + type: FieldDescriptorProto_Type; + /** + * For message and enum types, this is the name of the type. If the name + * starts with a '.', it is fully-qualified. Otherwise, C++-like scoping + * rules are used to find the type (i.e. first the nested types within this + * message are searched, then within the parent, on up to the root + * namespace). + */ + typeName: string; + /** + * For extensions, this is the name of the type being extended. It is + * resolved in the same manner as type_name. + */ + extendee: string; + /** + * For numeric types, contains the original text representation of the value. + * For booleans, "true" or "false". + * For strings, contains the default text contents (not escaped in any way). + * For bytes, contains the C escaped value. All bytes >= 128 are escaped. + * TODO(kenton): Base-64 encode? + */ + defaultValue: string; + /** + * If set, gives the index of a oneof in the containing type's oneof_decl + * list. This field is a member of that oneof. + */ + oneofIndex: number; + /** + * JSON name of this field. The value is set by protocol compiler. If the + * user has set a "json_name" option on this field, that option's value + * will be used. Otherwise, it's deduced from the field's name by converting + * it to camelCase. + */ + jsonName: string; + options: FieldOptions | undefined; + /** + * If true, this is a proto3 "optional". When a proto3 field is optional, it + * tracks presence regardless of field type. + * + * When proto3_optional is true, this field must be belong to a oneof to + * signal to old proto3 clients that presence is tracked for this field. This + * oneof is known as a "synthetic" oneof, and this field must be its sole + * member (each proto3 optional field gets its own synthetic oneof). Synthetic + * oneofs exist in the descriptor only, and do not generate any API. Synthetic + * oneofs must be ordered after all "real" oneofs. + * + * For message fields, proto3_optional doesn't create any semantic change, + * since non-repeated message fields always track presence. However it still + * indicates the semantic detail of whether the user wrote "optional" or not. + * This can be useful for round-tripping the .proto file. For consistency we + * give message fields a synthetic oneof also, even though it is not required + * to track presence. This is especially important because the parser can't + * tell if a field is a message or an enum, so it must always create a + * synthetic oneof. + * + * Proto2 optional fields do not set this flag, because they already indicate + * optional with `LABEL_OPTIONAL`. + */ + proto3Optional: boolean; +} + +export enum FieldDescriptorProto_Type { + /** + * TYPE_DOUBLE - 0 is reserved for errors. + * Order is weird for historical reasons. + */ + TYPE_DOUBLE = 1, + TYPE_FLOAT = 2, + /** + * TYPE_INT64 - Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT64 if + * negative values are likely. + */ + TYPE_INT64 = 3, + TYPE_UINT64 = 4, + /** + * TYPE_INT32 - Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT32 if + * negative values are likely. + */ + TYPE_INT32 = 5, + TYPE_FIXED64 = 6, + TYPE_FIXED32 = 7, + TYPE_BOOL = 8, + TYPE_STRING = 9, + /** + * TYPE_GROUP - Tag-delimited aggregate. + * Group type is deprecated and not supported in proto3. However, Proto3 + * implementations should still be able to parse the group wire format and + * treat group fields as unknown fields. + */ + TYPE_GROUP = 10, + /** TYPE_MESSAGE - Length-delimited aggregate. */ + TYPE_MESSAGE = 11, + /** TYPE_BYTES - New in version 2. */ + TYPE_BYTES = 12, + TYPE_UINT32 = 13, + TYPE_ENUM = 14, + TYPE_SFIXED32 = 15, + TYPE_SFIXED64 = 16, + /** TYPE_SINT32 - Uses ZigZag encoding. */ + TYPE_SINT32 = 17, + /** TYPE_SINT64 - Uses ZigZag encoding. */ + TYPE_SINT64 = 18, + UNRECOGNIZED = -1, +} + +export function fieldDescriptorProto_TypeFromJSON( + object: any +): FieldDescriptorProto_Type { + switch (object) { + case 1: + case "TYPE_DOUBLE": + return FieldDescriptorProto_Type.TYPE_DOUBLE; + case 2: + case "TYPE_FLOAT": + return FieldDescriptorProto_Type.TYPE_FLOAT; + case 3: + case "TYPE_INT64": + return FieldDescriptorProto_Type.TYPE_INT64; + case 4: + case "TYPE_UINT64": + return FieldDescriptorProto_Type.TYPE_UINT64; + case 5: + case "TYPE_INT32": + return FieldDescriptorProto_Type.TYPE_INT32; + case 6: + case "TYPE_FIXED64": + return FieldDescriptorProto_Type.TYPE_FIXED64; + case 7: + case "TYPE_FIXED32": + return FieldDescriptorProto_Type.TYPE_FIXED32; + case 8: + case "TYPE_BOOL": + return FieldDescriptorProto_Type.TYPE_BOOL; + case 9: + case "TYPE_STRING": + return FieldDescriptorProto_Type.TYPE_STRING; + case 10: + case "TYPE_GROUP": + return FieldDescriptorProto_Type.TYPE_GROUP; + case 11: + case "TYPE_MESSAGE": + return FieldDescriptorProto_Type.TYPE_MESSAGE; + case 12: + case "TYPE_BYTES": + return FieldDescriptorProto_Type.TYPE_BYTES; + case 13: + case "TYPE_UINT32": + return FieldDescriptorProto_Type.TYPE_UINT32; + case 14: + case "TYPE_ENUM": + return FieldDescriptorProto_Type.TYPE_ENUM; + case 15: + case "TYPE_SFIXED32": + return FieldDescriptorProto_Type.TYPE_SFIXED32; + case 16: + case "TYPE_SFIXED64": + return FieldDescriptorProto_Type.TYPE_SFIXED64; + case 17: + case "TYPE_SINT32": + return FieldDescriptorProto_Type.TYPE_SINT32; + case 18: + case "TYPE_SINT64": + return FieldDescriptorProto_Type.TYPE_SINT64; + case -1: + case "UNRECOGNIZED": + default: + return FieldDescriptorProto_Type.UNRECOGNIZED; + } +} + +export function fieldDescriptorProto_TypeToJSON( + object: FieldDescriptorProto_Type +): string { + switch (object) { + case FieldDescriptorProto_Type.TYPE_DOUBLE: + return "TYPE_DOUBLE"; + case FieldDescriptorProto_Type.TYPE_FLOAT: + return "TYPE_FLOAT"; + case FieldDescriptorProto_Type.TYPE_INT64: + return "TYPE_INT64"; + case FieldDescriptorProto_Type.TYPE_UINT64: + return "TYPE_UINT64"; + case FieldDescriptorProto_Type.TYPE_INT32: + return "TYPE_INT32"; + case FieldDescriptorProto_Type.TYPE_FIXED64: + return "TYPE_FIXED64"; + case FieldDescriptorProto_Type.TYPE_FIXED32: + return "TYPE_FIXED32"; + case FieldDescriptorProto_Type.TYPE_BOOL: + return "TYPE_BOOL"; + case FieldDescriptorProto_Type.TYPE_STRING: + return "TYPE_STRING"; + case FieldDescriptorProto_Type.TYPE_GROUP: + return "TYPE_GROUP"; + case FieldDescriptorProto_Type.TYPE_MESSAGE: + return "TYPE_MESSAGE"; + case FieldDescriptorProto_Type.TYPE_BYTES: + return "TYPE_BYTES"; + case FieldDescriptorProto_Type.TYPE_UINT32: + return "TYPE_UINT32"; + case FieldDescriptorProto_Type.TYPE_ENUM: + return "TYPE_ENUM"; + case FieldDescriptorProto_Type.TYPE_SFIXED32: + return "TYPE_SFIXED32"; + case FieldDescriptorProto_Type.TYPE_SFIXED64: + return "TYPE_SFIXED64"; + case FieldDescriptorProto_Type.TYPE_SINT32: + return "TYPE_SINT32"; + case FieldDescriptorProto_Type.TYPE_SINT64: + return "TYPE_SINT64"; + default: + return "UNKNOWN"; + } +} + +export enum FieldDescriptorProto_Label { + /** LABEL_OPTIONAL - 0 is reserved for errors */ + LABEL_OPTIONAL = 1, + LABEL_REQUIRED = 2, + LABEL_REPEATED = 3, + UNRECOGNIZED = -1, +} + +export function fieldDescriptorProto_LabelFromJSON( + object: any +): FieldDescriptorProto_Label { + switch (object) { + case 1: + case "LABEL_OPTIONAL": + return FieldDescriptorProto_Label.LABEL_OPTIONAL; + case 2: + case "LABEL_REQUIRED": + return FieldDescriptorProto_Label.LABEL_REQUIRED; + case 3: + case "LABEL_REPEATED": + return FieldDescriptorProto_Label.LABEL_REPEATED; + case -1: + case "UNRECOGNIZED": + default: + return FieldDescriptorProto_Label.UNRECOGNIZED; + } +} + +export function fieldDescriptorProto_LabelToJSON( + object: FieldDescriptorProto_Label +): string { + switch (object) { + case FieldDescriptorProto_Label.LABEL_OPTIONAL: + return "LABEL_OPTIONAL"; + case FieldDescriptorProto_Label.LABEL_REQUIRED: + return "LABEL_REQUIRED"; + case FieldDescriptorProto_Label.LABEL_REPEATED: + return "LABEL_REPEATED"; + default: + return "UNKNOWN"; + } +} + +/** Describes a oneof. */ +export interface OneofDescriptorProto { + name: string; + options: OneofOptions | undefined; +} + +/** Describes an enum type. */ +export interface EnumDescriptorProto { + name: string; + value: EnumValueDescriptorProto[]; + options: EnumOptions | undefined; + /** + * Range of reserved numeric values. Reserved numeric values may not be used + * by enum values in the same enum declaration. Reserved ranges may not + * overlap. + */ + reservedRange: EnumDescriptorProto_EnumReservedRange[]; + /** + * Reserved enum value names, which may not be reused. A given name may only + * be reserved once. + */ + reservedName: string[]; +} + +/** + * Range of reserved numeric values. Reserved values may not be used by + * entries in the same enum. Reserved ranges may not overlap. + * + * Note that this is distinct from DescriptorProto.ReservedRange in that it + * is inclusive such that it can appropriately represent the entire int32 + * domain. + */ +export interface EnumDescriptorProto_EnumReservedRange { + /** Inclusive. */ + start: number; + /** Inclusive. */ + end: number; +} + +/** Describes a value within an enum. */ +export interface EnumValueDescriptorProto { + name: string; + number: number; + options: EnumValueOptions | undefined; +} + +/** Describes a service. */ +export interface ServiceDescriptorProto { + name: string; + method: MethodDescriptorProto[]; + options: ServiceOptions | undefined; +} + +/** Describes a method of a service. */ +export interface MethodDescriptorProto { + name: string; + /** + * Input and output type names. These are resolved in the same way as + * FieldDescriptorProto.type_name, but must refer to a message type. + */ + inputType: string; + outputType: string; + options: MethodOptions | undefined; + /** Identifies if client streams multiple client messages */ + clientStreaming: boolean; + /** Identifies if server streams multiple server messages */ + serverStreaming: boolean; +} + +export interface FileOptions { + /** + * Sets the Java package where classes generated from this .proto will be + * placed. By default, the proto package is used, but this is often + * inappropriate because proto packages do not normally start with backwards + * domain names. + */ + javaPackage: string; + /** + * Controls the name of the wrapper Java class generated for the .proto file. + * That class will always contain the .proto file's getDescriptor() method as + * well as any top-level extensions defined in the .proto file. + * If java_multiple_files is disabled, then all the other classes from the + * .proto file will be nested inside the single wrapper outer class. + */ + javaOuterClassname: string; + /** + * If enabled, then the Java code generator will generate a separate .java + * file for each top-level message, enum, and service defined in the .proto + * file. Thus, these types will *not* be nested inside the wrapper class + * named by java_outer_classname. However, the wrapper class will still be + * generated to contain the file's getDescriptor() method as well as any + * top-level extensions defined in the file. + */ + javaMultipleFiles: boolean; + /** + * This option does nothing. + * + * @deprecated + */ + javaGenerateEqualsAndHash: boolean; + /** + * If set true, then the Java2 code generator will generate code that + * throws an exception whenever an attempt is made to assign a non-UTF-8 + * byte sequence to a string field. + * Message reflection will do the same. + * However, an extension field still accepts non-UTF-8 byte sequences. + * This option has no effect on when used with the lite runtime. + */ + javaStringCheckUtf8: boolean; + optimizeFor: FileOptions_OptimizeMode; + /** + * Sets the Go package where structs generated from this .proto will be + * placed. If omitted, the Go package will be derived from the following: + * - The basename of the package import path, if provided. + * - Otherwise, the package statement in the .proto file, if present. + * - Otherwise, the basename of the .proto file, without extension. + */ + goPackage: string; + /** + * Should generic services be generated in each language? "Generic" services + * are not specific to any particular RPC system. They are generated by the + * main code generators in each language (without additional plugins). + * Generic services were the only kind of service generation supported by + * early versions of google.protobuf. + * + * Generic services are now considered deprecated in favor of using plugins + * that generate code specific to your particular RPC system. Therefore, + * these default to false. Old code which depends on generic services should + * explicitly set them to true. + */ + ccGenericServices: boolean; + javaGenericServices: boolean; + pyGenericServices: boolean; + phpGenericServices: boolean; + /** + * Is this file deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for everything in the file, or it will be completely ignored; in the very + * least, this is a formalization for deprecating files. + */ + deprecated: boolean; + /** + * Enables the use of arenas for the proto messages in this file. This applies + * only to generated classes for C++. + */ + ccEnableArenas: boolean; + /** + * Sets the objective c class prefix which is prepended to all objective c + * generated classes from this .proto. There is no default. + */ + objcClassPrefix: string; + /** Namespace for generated classes; defaults to the package. */ + csharpNamespace: string; + /** + * By default Swift generators will take the proto package and CamelCase it + * replacing '.' with underscore and use that to prefix the types/symbols + * defined. When this options is provided, they will use this value instead + * to prefix the types/symbols defined. + */ + swiftPrefix: string; + /** + * Sets the php class prefix which is prepended to all php generated classes + * from this .proto. Default is empty. + */ + phpClassPrefix: string; + /** + * Use this option to change the namespace of php generated classes. Default + * is empty. When this option is empty, the package name will be used for + * determining the namespace. + */ + phpNamespace: string; + /** + * Use this option to change the namespace of php generated metadata classes. + * Default is empty. When this option is empty, the proto file name will be + * used for determining the namespace. + */ + phpMetadataNamespace: string; + /** + * Use this option to change the package of ruby generated classes. Default + * is empty. When this option is not set, the package name will be used for + * determining the ruby package. + */ + rubyPackage: string; + /** + * The parser stores options it doesn't recognize here. + * See the documentation for the "Options" section above. + */ + uninterpretedOption: UninterpretedOption[]; +} + +/** Generated classes can be optimized for speed or code size. */ +export enum FileOptions_OptimizeMode { + /** SPEED - Generate complete code for parsing, serialization, */ + SPEED = 1, + /** CODE_SIZE - etc. */ + CODE_SIZE = 2, + /** LITE_RUNTIME - Generate code using MessageLite and the lite runtime. */ + LITE_RUNTIME = 3, + UNRECOGNIZED = -1, +} + +export function fileOptions_OptimizeModeFromJSON( + object: any +): FileOptions_OptimizeMode { + switch (object) { + case 1: + case "SPEED": + return FileOptions_OptimizeMode.SPEED; + case 2: + case "CODE_SIZE": + return FileOptions_OptimizeMode.CODE_SIZE; + case 3: + case "LITE_RUNTIME": + return FileOptions_OptimizeMode.LITE_RUNTIME; + case -1: + case "UNRECOGNIZED": + default: + return FileOptions_OptimizeMode.UNRECOGNIZED; + } +} + +export function fileOptions_OptimizeModeToJSON( + object: FileOptions_OptimizeMode +): string { + switch (object) { + case FileOptions_OptimizeMode.SPEED: + return "SPEED"; + case FileOptions_OptimizeMode.CODE_SIZE: + return "CODE_SIZE"; + case FileOptions_OptimizeMode.LITE_RUNTIME: + return "LITE_RUNTIME"; + default: + return "UNKNOWN"; + } +} + +export interface MessageOptions { + /** + * Set true to use the old proto1 MessageSet wire format for extensions. + * This is provided for backwards-compatibility with the MessageSet wire + * format. You should not use this for any other reason: It's less + * efficient, has fewer features, and is more complicated. + * + * The message must be defined exactly as follows: + * message Foo { + * option message_set_wire_format = true; + * extensions 4 to max; + * } + * Note that the message cannot have any defined fields; MessageSets only + * have extensions. + * + * All extensions of your type must be singular messages; e.g. they cannot + * be int32s, enums, or repeated messages. + * + * Because this is an option, the above two restrictions are not enforced by + * the protocol compiler. + */ + messageSetWireFormat: boolean; + /** + * Disables the generation of the standard "descriptor()" accessor, which can + * conflict with a field of the same name. This is meant to make migration + * from proto1 easier; new code should avoid fields named "descriptor". + */ + noStandardDescriptorAccessor: boolean; + /** + * Is this message deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the message, or it will be completely ignored; in the very least, + * this is a formalization for deprecating messages. + */ + deprecated: boolean; + /** + * Whether the message is an automatically generated map entry type for the + * maps field. + * + * For maps fields: + * map map_field = 1; + * The parsed descriptor looks like: + * message MapFieldEntry { + * option map_entry = true; + * optional KeyType key = 1; + * optional ValueType value = 2; + * } + * repeated MapFieldEntry map_field = 1; + * + * Implementations may choose not to generate the map_entry=true message, but + * use a native map in the target language to hold the keys and values. + * The reflection APIs in such implementations still need to work as + * if the field is a repeated message field. + * + * NOTE: Do not set the option in .proto files. Always use the maps syntax + * instead. The option should only be implicitly set by the proto compiler + * parser. + */ + mapEntry: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface FieldOptions { + /** + * The ctype option instructs the C++ code generator to use a different + * representation of the field than it normally would. See the specific + * options below. This option is not yet implemented in the open source + * release -- sorry, we'll try to include it in a future version! + */ + ctype: FieldOptions_CType; + /** + * The packed option can be enabled for repeated primitive fields to enable + * a more efficient representation on the wire. Rather than repeatedly + * writing the tag and type for each element, the entire array is encoded as + * a single length-delimited blob. In proto3, only explicit setting it to + * false will avoid using packed encoding. + */ + packed: boolean; + /** + * The jstype option determines the JavaScript type used for values of the + * field. The option is permitted only for 64 bit integral and fixed types + * (int64, uint64, sint64, fixed64, sfixed64). A field with jstype JS_STRING + * is represented as JavaScript string, which avoids loss of precision that + * can happen when a large value is converted to a floating point JavaScript. + * Specifying JS_NUMBER for the jstype causes the generated JavaScript code to + * use the JavaScript "number" type. The behavior of the default option + * JS_NORMAL is implementation dependent. + * + * This option is an enum to permit additional types to be added, e.g. + * goog.math.Integer. + */ + jstype: FieldOptions_JSType; + /** + * Should this field be parsed lazily? Lazy applies only to message-type + * fields. It means that when the outer message is initially parsed, the + * inner message's contents will not be parsed but instead stored in encoded + * form. The inner message will actually be parsed when it is first accessed. + * + * This is only a hint. Implementations are free to choose whether to use + * eager or lazy parsing regardless of the value of this option. However, + * setting this option true suggests that the protocol author believes that + * using lazy parsing on this field is worth the additional bookkeeping + * overhead typically needed to implement it. + * + * This option does not affect the public interface of any generated code; + * all method signatures remain the same. Furthermore, thread-safety of the + * interface is not affected by this option; const methods remain safe to + * call from multiple threads concurrently, while non-const methods continue + * to require exclusive access. + * + * + * Note that implementations may choose not to check required fields within + * a lazy sub-message. That is, calling IsInitialized() on the outer message + * may return true even if the inner message has missing required fields. + * This is necessary because otherwise the inner message would have to be + * parsed in order to perform the check, defeating the purpose of lazy + * parsing. An implementation which chooses not to check required fields + * must be consistent about it. That is, for any particular sub-message, the + * implementation must either *always* check its required fields, or *never* + * check its required fields, regardless of whether or not the message has + * been parsed. + */ + lazy: boolean; + /** + * Is this field deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for accessors, or it will be completely ignored; in the very least, this + * is a formalization for deprecating fields. + */ + deprecated: boolean; + /** For Google-internal migration only. Do not use. */ + weak: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export enum FieldOptions_CType { + /** STRING - Default mode. */ + STRING = 0, + CORD = 1, + STRING_PIECE = 2, + UNRECOGNIZED = -1, +} + +export function fieldOptions_CTypeFromJSON(object: any): FieldOptions_CType { + switch (object) { + case 0: + case "STRING": + return FieldOptions_CType.STRING; + case 1: + case "CORD": + return FieldOptions_CType.CORD; + case 2: + case "STRING_PIECE": + return FieldOptions_CType.STRING_PIECE; + case -1: + case "UNRECOGNIZED": + default: + return FieldOptions_CType.UNRECOGNIZED; + } +} + +export function fieldOptions_CTypeToJSON(object: FieldOptions_CType): string { + switch (object) { + case FieldOptions_CType.STRING: + return "STRING"; + case FieldOptions_CType.CORD: + return "CORD"; + case FieldOptions_CType.STRING_PIECE: + return "STRING_PIECE"; + default: + return "UNKNOWN"; + } +} + +export enum FieldOptions_JSType { + /** JS_NORMAL - Use the default type. */ + JS_NORMAL = 0, + /** JS_STRING - Use JavaScript strings. */ + JS_STRING = 1, + /** JS_NUMBER - Use JavaScript numbers. */ + JS_NUMBER = 2, + UNRECOGNIZED = -1, +} + +export function fieldOptions_JSTypeFromJSON(object: any): FieldOptions_JSType { + switch (object) { + case 0: + case "JS_NORMAL": + return FieldOptions_JSType.JS_NORMAL; + case 1: + case "JS_STRING": + return FieldOptions_JSType.JS_STRING; + case 2: + case "JS_NUMBER": + return FieldOptions_JSType.JS_NUMBER; + case -1: + case "UNRECOGNIZED": + default: + return FieldOptions_JSType.UNRECOGNIZED; + } +} + +export function fieldOptions_JSTypeToJSON(object: FieldOptions_JSType): string { + switch (object) { + case FieldOptions_JSType.JS_NORMAL: + return "JS_NORMAL"; + case FieldOptions_JSType.JS_STRING: + return "JS_STRING"; + case FieldOptions_JSType.JS_NUMBER: + return "JS_NUMBER"; + default: + return "UNKNOWN"; + } +} + +export interface OneofOptions { + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface EnumOptions { + /** + * Set this option to true to allow mapping different tag names to the same + * value. + */ + allowAlias: boolean; + /** + * Is this enum deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the enum, or it will be completely ignored; in the very least, this + * is a formalization for deprecating enums. + */ + deprecated: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface EnumValueOptions { + /** + * Is this enum value deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the enum value, or it will be completely ignored; in the very least, + * this is a formalization for deprecating enum values. + */ + deprecated: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface ServiceOptions { + /** + * Is this service deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the service, or it will be completely ignored; in the very least, + * this is a formalization for deprecating services. + */ + deprecated: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface MethodOptions { + /** + * Is this method deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the method, or it will be completely ignored; in the very least, + * this is a formalization for deprecating methods. + */ + deprecated: boolean; + idempotencyLevel: MethodOptions_IdempotencyLevel; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +/** + * Is this method side-effect-free (or safe in HTTP parlance), or idempotent, + * or neither? HTTP based RPC implementation may choose GET verb for safe + * methods, and PUT verb for idempotent methods instead of the default POST. + */ +export enum MethodOptions_IdempotencyLevel { + IDEMPOTENCY_UNKNOWN = 0, + /** NO_SIDE_EFFECTS - implies idempotent */ + NO_SIDE_EFFECTS = 1, + /** IDEMPOTENT - idempotent, but may have side effects */ + IDEMPOTENT = 2, + UNRECOGNIZED = -1, +} + +export function methodOptions_IdempotencyLevelFromJSON( + object: any +): MethodOptions_IdempotencyLevel { + switch (object) { + case 0: + case "IDEMPOTENCY_UNKNOWN": + return MethodOptions_IdempotencyLevel.IDEMPOTENCY_UNKNOWN; + case 1: + case "NO_SIDE_EFFECTS": + return MethodOptions_IdempotencyLevel.NO_SIDE_EFFECTS; + case 2: + case "IDEMPOTENT": + return MethodOptions_IdempotencyLevel.IDEMPOTENT; + case -1: + case "UNRECOGNIZED": + default: + return MethodOptions_IdempotencyLevel.UNRECOGNIZED; + } +} + +export function methodOptions_IdempotencyLevelToJSON( + object: MethodOptions_IdempotencyLevel +): string { + switch (object) { + case MethodOptions_IdempotencyLevel.IDEMPOTENCY_UNKNOWN: + return "IDEMPOTENCY_UNKNOWN"; + case MethodOptions_IdempotencyLevel.NO_SIDE_EFFECTS: + return "NO_SIDE_EFFECTS"; + case MethodOptions_IdempotencyLevel.IDEMPOTENT: + return "IDEMPOTENT"; + default: + return "UNKNOWN"; + } +} + +/** + * A message representing a option the parser does not recognize. This only + * appears in options protos created by the compiler::Parser class. + * DescriptorPool resolves these when building Descriptor objects. Therefore, + * options protos in descriptor objects (e.g. returned by Descriptor::options(), + * or produced by Descriptor::CopyTo()) will never have UninterpretedOptions + * in them. + */ +export interface UninterpretedOption { + name: UninterpretedOption_NamePart[]; + /** + * The value of the uninterpreted option, in whatever type the tokenizer + * identified it as during parsing. Exactly one of these should be set. + */ + identifierValue: string; + positiveIntValue: number; + negativeIntValue: number; + doubleValue: number; + stringValue: Uint8Array; + aggregateValue: string; +} + +/** + * The name of the uninterpreted option. Each string represents a segment in + * a dot-separated name. is_extension is true iff a segment represents an + * extension (denoted with parentheses in options specs in .proto files). + * E.g.,{ ["foo", false], ["bar.baz", true], ["qux", false] } represents + * "foo.(bar.baz).qux". + */ +export interface UninterpretedOption_NamePart { + namePart: string; + isExtension: boolean; +} + +/** + * Encapsulates information about the original source file from which a + * FileDescriptorProto was generated. + */ +export interface SourceCodeInfo { + /** + * A Location identifies a piece of source code in a .proto file which + * corresponds to a particular definition. This information is intended + * to be useful to IDEs, code indexers, documentation generators, and similar + * tools. + * + * For example, say we have a file like: + * message Foo { + * optional string foo = 1; + * } + * Let's look at just the field definition: + * optional string foo = 1; + * ^ ^^ ^^ ^ ^^^ + * a bc de f ghi + * We have the following locations: + * span path represents + * [a,i) [ 4, 0, 2, 0 ] The whole field definition. + * [a,b) [ 4, 0, 2, 0, 4 ] The label (optional). + * [c,d) [ 4, 0, 2, 0, 5 ] The type (string). + * [e,f) [ 4, 0, 2, 0, 1 ] The name (foo). + * [g,h) [ 4, 0, 2, 0, 3 ] The number (1). + * + * Notes: + * - A location may refer to a repeated field itself (i.e. not to any + * particular index within it). This is used whenever a set of elements are + * logically enclosed in a single code segment. For example, an entire + * extend block (possibly containing multiple extension definitions) will + * have an outer location whose path refers to the "extensions" repeated + * field without an index. + * - Multiple locations may have the same path. This happens when a single + * logical declaration is spread out across multiple places. The most + * obvious example is the "extend" block again -- there may be multiple + * extend blocks in the same scope, each of which will have the same path. + * - A location's span is not always a subset of its parent's span. For + * example, the "extendee" of an extension declaration appears at the + * beginning of the "extend" block and is shared by all extensions within + * the block. + * - Just because a location's span is a subset of some other location's span + * does not mean that it is a descendant. For example, a "group" defines + * both a type and a field in a single declaration. Thus, the locations + * corresponding to the type and field and their components will overlap. + * - Code which tries to interpret locations should probably be designed to + * ignore those that it doesn't understand, as more types of locations could + * be recorded in the future. + */ + location: SourceCodeInfo_Location[]; +} + +export interface SourceCodeInfo_Location { + /** + * Identifies which part of the FileDescriptorProto was defined at this + * location. + * + * Each element is a field number or an index. They form a path from + * the root FileDescriptorProto to the place where the definition. For + * example, this path: + * [ 4, 3, 2, 7, 1 ] + * refers to: + * file.message_type(3) // 4, 3 + * .field(7) // 2, 7 + * .name() // 1 + * This is because FileDescriptorProto.message_type has field number 4: + * repeated DescriptorProto message_type = 4; + * and DescriptorProto.field has field number 2: + * repeated FieldDescriptorProto field = 2; + * and FieldDescriptorProto.name has field number 1: + * optional string name = 1; + * + * Thus, the above path gives the location of a field name. If we removed + * the last element: + * [ 4, 3, 2, 7 ] + * this path refers to the whole field declaration (from the beginning + * of the label to the terminating semicolon). + */ + path: number[]; + /** + * Always has exactly three or four elements: start line, start column, + * end line (optional, otherwise assumed same as start line), end column. + * These are packed into a single field for efficiency. Note that line + * and column numbers are zero-based -- typically you will want to add + * 1 to each before displaying to a user. + */ + span: number[]; + /** + * If this SourceCodeInfo represents a complete declaration, these are any + * comments appearing before and after the declaration which appear to be + * attached to the declaration. + * + * A series of line comments appearing on consecutive lines, with no other + * tokens appearing on those lines, will be treated as a single comment. + * + * leading_detached_comments will keep paragraphs of comments that appear + * before (but not connected to) the current element. Each paragraph, + * separated by empty lines, will be one comment element in the repeated + * field. + * + * Only the comment content is provided; comment markers (e.g. //) are + * stripped out. For block comments, leading whitespace and an asterisk + * will be stripped from the beginning of each line other than the first. + * Newlines are included in the output. + * + * Examples: + * + * optional int32 foo = 1; // Comment attached to foo. + * // Comment attached to bar. + * optional int32 bar = 2; + * + * optional string baz = 3; + * // Comment attached to baz. + * // Another line attached to baz. + * + * // Comment attached to qux. + * // + * // Another line attached to qux. + * optional double qux = 4; + * + * // Detached comment for corge. This is not leading or trailing comments + * // to qux or corge because there are blank lines separating it from + * // both. + * + * // Detached comment for corge paragraph 2. + * + * optional string corge = 5; + * /* Block comment attached + * * to corge. Leading asterisks + * * will be removed. * / + * /* Block comment attached to + * * grault. * / + * optional int32 grault = 6; + * + * // ignored detached comments. + */ + leadingComments: string; + trailingComments: string; + leadingDetachedComments: string[]; +} + +/** + * Describes the relationship between generated code and its original source + * file. A GeneratedCodeInfo message is associated with only one generated + * source file, but may contain references to different source .proto files. + */ +export interface GeneratedCodeInfo { + /** + * An Annotation connects some span of text in generated code to an element + * of its generating .proto file. + */ + annotation: GeneratedCodeInfo_Annotation[]; +} + +export interface GeneratedCodeInfo_Annotation { + /** + * Identifies the element in the original source .proto file. This field + * is formatted the same as SourceCodeInfo.Location.path. + */ + path: number[]; + /** Identifies the filesystem path to the original source .proto. */ + sourceFile: string; + /** + * Identifies the starting offset in bytes in the generated code + * that relates to the identified object. + */ + begin: number; + /** + * Identifies the ending offset in bytes in the generated code that + * relates to the identified offset. The end offset should be one past + * the last relevant byte (so the length of the text = end - begin). + */ + end: number; +} + +const baseFileDescriptorSet: object = {}; + +export const FileDescriptorSet = { + encode(message: FileDescriptorSet, writer: Writer = Writer.create()): Writer { + for (const v of message.file) { + FileDescriptorProto.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FileDescriptorSet { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFileDescriptorSet } as FileDescriptorSet; + message.file = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.file.push( + FileDescriptorProto.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FileDescriptorSet { + const message = { ...baseFileDescriptorSet } as FileDescriptorSet; + message.file = []; + if (object.file !== undefined && object.file !== null) { + for (const e of object.file) { + message.file.push(FileDescriptorProto.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: FileDescriptorSet): unknown { + const obj: any = {}; + if (message.file) { + obj.file = message.file.map((e) => + e ? FileDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.file = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): FileDescriptorSet { + const message = { ...baseFileDescriptorSet } as FileDescriptorSet; + message.file = []; + if (object.file !== undefined && object.file !== null) { + for (const e of object.file) { + message.file.push(FileDescriptorProto.fromPartial(e)); + } + } + return message; + }, +}; + +const baseFileDescriptorProto: object = { + name: "", + package: "", + dependency: "", + publicDependency: 0, + weakDependency: 0, + syntax: "", +}; + +export const FileDescriptorProto = { + encode( + message: FileDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.package !== "") { + writer.uint32(18).string(message.package); + } + for (const v of message.dependency) { + writer.uint32(26).string(v!); + } + writer.uint32(82).fork(); + for (const v of message.publicDependency) { + writer.int32(v); + } + writer.ldelim(); + writer.uint32(90).fork(); + for (const v of message.weakDependency) { + writer.int32(v); + } + writer.ldelim(); + for (const v of message.messageType) { + DescriptorProto.encode(v!, writer.uint32(34).fork()).ldelim(); + } + for (const v of message.enumType) { + EnumDescriptorProto.encode(v!, writer.uint32(42).fork()).ldelim(); + } + for (const v of message.service) { + ServiceDescriptorProto.encode(v!, writer.uint32(50).fork()).ldelim(); + } + for (const v of message.extension) { + FieldDescriptorProto.encode(v!, writer.uint32(58).fork()).ldelim(); + } + if (message.options !== undefined) { + FileOptions.encode(message.options, writer.uint32(66).fork()).ldelim(); + } + if (message.sourceCodeInfo !== undefined) { + SourceCodeInfo.encode( + message.sourceCodeInfo, + writer.uint32(74).fork() + ).ldelim(); + } + if (message.syntax !== "") { + writer.uint32(98).string(message.syntax); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FileDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFileDescriptorProto } as FileDescriptorProto; + message.dependency = []; + message.publicDependency = []; + message.weakDependency = []; + message.messageType = []; + message.enumType = []; + message.service = []; + message.extension = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.package = reader.string(); + break; + case 3: + message.dependency.push(reader.string()); + break; + case 10: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.publicDependency.push(reader.int32()); + } + } else { + message.publicDependency.push(reader.int32()); + } + break; + case 11: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.weakDependency.push(reader.int32()); + } + } else { + message.weakDependency.push(reader.int32()); + } + break; + case 4: + message.messageType.push( + DescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 5: + message.enumType.push( + EnumDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 6: + message.service.push( + ServiceDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 7: + message.extension.push( + FieldDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 8: + message.options = FileOptions.decode(reader, reader.uint32()); + break; + case 9: + message.sourceCodeInfo = SourceCodeInfo.decode( + reader, + reader.uint32() + ); + break; + case 12: + message.syntax = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FileDescriptorProto { + const message = { ...baseFileDescriptorProto } as FileDescriptorProto; + message.dependency = []; + message.publicDependency = []; + message.weakDependency = []; + message.messageType = []; + message.enumType = []; + message.service = []; + message.extension = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.package !== undefined && object.package !== null) { + message.package = String(object.package); + } else { + message.package = ""; + } + if (object.dependency !== undefined && object.dependency !== null) { + for (const e of object.dependency) { + message.dependency.push(String(e)); + } + } + if ( + object.publicDependency !== undefined && + object.publicDependency !== null + ) { + for (const e of object.publicDependency) { + message.publicDependency.push(Number(e)); + } + } + if (object.weakDependency !== undefined && object.weakDependency !== null) { + for (const e of object.weakDependency) { + message.weakDependency.push(Number(e)); + } + } + if (object.messageType !== undefined && object.messageType !== null) { + for (const e of object.messageType) { + message.messageType.push(DescriptorProto.fromJSON(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromJSON(e)); + } + } + if (object.service !== undefined && object.service !== null) { + for (const e of object.service) { + message.service.push(ServiceDescriptorProto.fromJSON(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = FileOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.sourceCodeInfo !== undefined && object.sourceCodeInfo !== null) { + message.sourceCodeInfo = SourceCodeInfo.fromJSON(object.sourceCodeInfo); + } else { + message.sourceCodeInfo = undefined; + } + if (object.syntax !== undefined && object.syntax !== null) { + message.syntax = String(object.syntax); + } else { + message.syntax = ""; + } + return message; + }, + + toJSON(message: FileDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.package !== undefined && (obj.package = message.package); + if (message.dependency) { + obj.dependency = message.dependency.map((e) => e); + } else { + obj.dependency = []; + } + if (message.publicDependency) { + obj.publicDependency = message.publicDependency.map((e) => e); + } else { + obj.publicDependency = []; + } + if (message.weakDependency) { + obj.weakDependency = message.weakDependency.map((e) => e); + } else { + obj.weakDependency = []; + } + if (message.messageType) { + obj.messageType = message.messageType.map((e) => + e ? DescriptorProto.toJSON(e) : undefined + ); + } else { + obj.messageType = []; + } + if (message.enumType) { + obj.enumType = message.enumType.map((e) => + e ? EnumDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.enumType = []; + } + if (message.service) { + obj.service = message.service.map((e) => + e ? ServiceDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.service = []; + } + if (message.extension) { + obj.extension = message.extension.map((e) => + e ? FieldDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.extension = []; + } + message.options !== undefined && + (obj.options = message.options + ? FileOptions.toJSON(message.options) + : undefined); + message.sourceCodeInfo !== undefined && + (obj.sourceCodeInfo = message.sourceCodeInfo + ? SourceCodeInfo.toJSON(message.sourceCodeInfo) + : undefined); + message.syntax !== undefined && (obj.syntax = message.syntax); + return obj; + }, + + fromPartial(object: DeepPartial): FileDescriptorProto { + const message = { ...baseFileDescriptorProto } as FileDescriptorProto; + message.dependency = []; + message.publicDependency = []; + message.weakDependency = []; + message.messageType = []; + message.enumType = []; + message.service = []; + message.extension = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.package !== undefined && object.package !== null) { + message.package = object.package; + } else { + message.package = ""; + } + if (object.dependency !== undefined && object.dependency !== null) { + for (const e of object.dependency) { + message.dependency.push(e); + } + } + if ( + object.publicDependency !== undefined && + object.publicDependency !== null + ) { + for (const e of object.publicDependency) { + message.publicDependency.push(e); + } + } + if (object.weakDependency !== undefined && object.weakDependency !== null) { + for (const e of object.weakDependency) { + message.weakDependency.push(e); + } + } + if (object.messageType !== undefined && object.messageType !== null) { + for (const e of object.messageType) { + message.messageType.push(DescriptorProto.fromPartial(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromPartial(e)); + } + } + if (object.service !== undefined && object.service !== null) { + for (const e of object.service) { + message.service.push(ServiceDescriptorProto.fromPartial(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = FileOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.sourceCodeInfo !== undefined && object.sourceCodeInfo !== null) { + message.sourceCodeInfo = SourceCodeInfo.fromPartial( + object.sourceCodeInfo + ); + } else { + message.sourceCodeInfo = undefined; + } + if (object.syntax !== undefined && object.syntax !== null) { + message.syntax = object.syntax; + } else { + message.syntax = ""; + } + return message; + }, +}; + +const baseDescriptorProto: object = { name: "", reservedName: "" }; + +export const DescriptorProto = { + encode(message: DescriptorProto, writer: Writer = Writer.create()): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + for (const v of message.field) { + FieldDescriptorProto.encode(v!, writer.uint32(18).fork()).ldelim(); + } + for (const v of message.extension) { + FieldDescriptorProto.encode(v!, writer.uint32(50).fork()).ldelim(); + } + for (const v of message.nestedType) { + DescriptorProto.encode(v!, writer.uint32(26).fork()).ldelim(); + } + for (const v of message.enumType) { + EnumDescriptorProto.encode(v!, writer.uint32(34).fork()).ldelim(); + } + for (const v of message.extensionRange) { + DescriptorProto_ExtensionRange.encode( + v!, + writer.uint32(42).fork() + ).ldelim(); + } + for (const v of message.oneofDecl) { + OneofDescriptorProto.encode(v!, writer.uint32(66).fork()).ldelim(); + } + if (message.options !== undefined) { + MessageOptions.encode(message.options, writer.uint32(58).fork()).ldelim(); + } + for (const v of message.reservedRange) { + DescriptorProto_ReservedRange.encode( + v!, + writer.uint32(74).fork() + ).ldelim(); + } + for (const v of message.reservedName) { + writer.uint32(82).string(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): DescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseDescriptorProto } as DescriptorProto; + message.field = []; + message.extension = []; + message.nestedType = []; + message.enumType = []; + message.extensionRange = []; + message.oneofDecl = []; + message.reservedRange = []; + message.reservedName = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.field.push( + FieldDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 6: + message.extension.push( + FieldDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 3: + message.nestedType.push( + DescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 4: + message.enumType.push( + EnumDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 5: + message.extensionRange.push( + DescriptorProto_ExtensionRange.decode(reader, reader.uint32()) + ); + break; + case 8: + message.oneofDecl.push( + OneofDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 7: + message.options = MessageOptions.decode(reader, reader.uint32()); + break; + case 9: + message.reservedRange.push( + DescriptorProto_ReservedRange.decode(reader, reader.uint32()) + ); + break; + case 10: + message.reservedName.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DescriptorProto { + const message = { ...baseDescriptorProto } as DescriptorProto; + message.field = []; + message.extension = []; + message.nestedType = []; + message.enumType = []; + message.extensionRange = []; + message.oneofDecl = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.field !== undefined && object.field !== null) { + for (const e of object.field) { + message.field.push(FieldDescriptorProto.fromJSON(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromJSON(e)); + } + } + if (object.nestedType !== undefined && object.nestedType !== null) { + for (const e of object.nestedType) { + message.nestedType.push(DescriptorProto.fromJSON(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromJSON(e)); + } + } + if (object.extensionRange !== undefined && object.extensionRange !== null) { + for (const e of object.extensionRange) { + message.extensionRange.push(DescriptorProto_ExtensionRange.fromJSON(e)); + } + } + if (object.oneofDecl !== undefined && object.oneofDecl !== null) { + for (const e of object.oneofDecl) { + message.oneofDecl.push(OneofDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = MessageOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push(DescriptorProto_ReservedRange.fromJSON(e)); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(String(e)); + } + } + return message; + }, + + toJSON(message: DescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + if (message.field) { + obj.field = message.field.map((e) => + e ? FieldDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.field = []; + } + if (message.extension) { + obj.extension = message.extension.map((e) => + e ? FieldDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.extension = []; + } + if (message.nestedType) { + obj.nestedType = message.nestedType.map((e) => + e ? DescriptorProto.toJSON(e) : undefined + ); + } else { + obj.nestedType = []; + } + if (message.enumType) { + obj.enumType = message.enumType.map((e) => + e ? EnumDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.enumType = []; + } + if (message.extensionRange) { + obj.extensionRange = message.extensionRange.map((e) => + e ? DescriptorProto_ExtensionRange.toJSON(e) : undefined + ); + } else { + obj.extensionRange = []; + } + if (message.oneofDecl) { + obj.oneofDecl = message.oneofDecl.map((e) => + e ? OneofDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.oneofDecl = []; + } + message.options !== undefined && + (obj.options = message.options + ? MessageOptions.toJSON(message.options) + : undefined); + if (message.reservedRange) { + obj.reservedRange = message.reservedRange.map((e) => + e ? DescriptorProto_ReservedRange.toJSON(e) : undefined + ); + } else { + obj.reservedRange = []; + } + if (message.reservedName) { + obj.reservedName = message.reservedName.map((e) => e); + } else { + obj.reservedName = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): DescriptorProto { + const message = { ...baseDescriptorProto } as DescriptorProto; + message.field = []; + message.extension = []; + message.nestedType = []; + message.enumType = []; + message.extensionRange = []; + message.oneofDecl = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.field !== undefined && object.field !== null) { + for (const e of object.field) { + message.field.push(FieldDescriptorProto.fromPartial(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromPartial(e)); + } + } + if (object.nestedType !== undefined && object.nestedType !== null) { + for (const e of object.nestedType) { + message.nestedType.push(DescriptorProto.fromPartial(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromPartial(e)); + } + } + if (object.extensionRange !== undefined && object.extensionRange !== null) { + for (const e of object.extensionRange) { + message.extensionRange.push( + DescriptorProto_ExtensionRange.fromPartial(e) + ); + } + } + if (object.oneofDecl !== undefined && object.oneofDecl !== null) { + for (const e of object.oneofDecl) { + message.oneofDecl.push(OneofDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = MessageOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push( + DescriptorProto_ReservedRange.fromPartial(e) + ); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(e); + } + } + return message; + }, +}; + +const baseDescriptorProto_ExtensionRange: object = { start: 0, end: 0 }; + +export const DescriptorProto_ExtensionRange = { + encode( + message: DescriptorProto_ExtensionRange, + writer: Writer = Writer.create() + ): Writer { + if (message.start !== 0) { + writer.uint32(8).int32(message.start); + } + if (message.end !== 0) { + writer.uint32(16).int32(message.end); + } + if (message.options !== undefined) { + ExtensionRangeOptions.encode( + message.options, + writer.uint32(26).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): DescriptorProto_ExtensionRange { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseDescriptorProto_ExtensionRange, + } as DescriptorProto_ExtensionRange; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.start = reader.int32(); + break; + case 2: + message.end = reader.int32(); + break; + case 3: + message.options = ExtensionRangeOptions.decode( + reader, + reader.uint32() + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DescriptorProto_ExtensionRange { + const message = { + ...baseDescriptorProto_ExtensionRange, + } as DescriptorProto_ExtensionRange; + if (object.start !== undefined && object.start !== null) { + message.start = Number(object.start); + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = ExtensionRangeOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: DescriptorProto_ExtensionRange): unknown { + const obj: any = {}; + message.start !== undefined && (obj.start = message.start); + message.end !== undefined && (obj.end = message.end); + message.options !== undefined && + (obj.options = message.options + ? ExtensionRangeOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): DescriptorProto_ExtensionRange { + const message = { + ...baseDescriptorProto_ExtensionRange, + } as DescriptorProto_ExtensionRange; + if (object.start !== undefined && object.start !== null) { + message.start = object.start; + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = ExtensionRangeOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseDescriptorProto_ReservedRange: object = { start: 0, end: 0 }; + +export const DescriptorProto_ReservedRange = { + encode( + message: DescriptorProto_ReservedRange, + writer: Writer = Writer.create() + ): Writer { + if (message.start !== 0) { + writer.uint32(8).int32(message.start); + } + if (message.end !== 0) { + writer.uint32(16).int32(message.end); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): DescriptorProto_ReservedRange { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseDescriptorProto_ReservedRange, + } as DescriptorProto_ReservedRange; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.start = reader.int32(); + break; + case 2: + message.end = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DescriptorProto_ReservedRange { + const message = { + ...baseDescriptorProto_ReservedRange, + } as DescriptorProto_ReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = Number(object.start); + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + return message; + }, + + toJSON(message: DescriptorProto_ReservedRange): unknown { + const obj: any = {}; + message.start !== undefined && (obj.start = message.start); + message.end !== undefined && (obj.end = message.end); + return obj; + }, + + fromPartial( + object: DeepPartial + ): DescriptorProto_ReservedRange { + const message = { + ...baseDescriptorProto_ReservedRange, + } as DescriptorProto_ReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = object.start; + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + return message; + }, +}; + +const baseExtensionRangeOptions: object = {}; + +export const ExtensionRangeOptions = { + encode( + message: ExtensionRangeOptions, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ExtensionRangeOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseExtensionRangeOptions } as ExtensionRangeOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ExtensionRangeOptions { + const message = { ...baseExtensionRangeOptions } as ExtensionRangeOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: ExtensionRangeOptions): unknown { + const obj: any = {}; + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial( + object: DeepPartial + ): ExtensionRangeOptions { + const message = { ...baseExtensionRangeOptions } as ExtensionRangeOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseFieldDescriptorProto: object = { + name: "", + number: 0, + label: 1, + type: 1, + typeName: "", + extendee: "", + defaultValue: "", + oneofIndex: 0, + jsonName: "", + proto3Optional: false, +}; + +export const FieldDescriptorProto = { + encode( + message: FieldDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.number !== 0) { + writer.uint32(24).int32(message.number); + } + if (message.label !== 1) { + writer.uint32(32).int32(message.label); + } + if (message.type !== 1) { + writer.uint32(40).int32(message.type); + } + if (message.typeName !== "") { + writer.uint32(50).string(message.typeName); + } + if (message.extendee !== "") { + writer.uint32(18).string(message.extendee); + } + if (message.defaultValue !== "") { + writer.uint32(58).string(message.defaultValue); + } + if (message.oneofIndex !== 0) { + writer.uint32(72).int32(message.oneofIndex); + } + if (message.jsonName !== "") { + writer.uint32(82).string(message.jsonName); + } + if (message.options !== undefined) { + FieldOptions.encode(message.options, writer.uint32(66).fork()).ldelim(); + } + if (message.proto3Optional === true) { + writer.uint32(136).bool(message.proto3Optional); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FieldDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFieldDescriptorProto } as FieldDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 3: + message.number = reader.int32(); + break; + case 4: + message.label = reader.int32() as any; + break; + case 5: + message.type = reader.int32() as any; + break; + case 6: + message.typeName = reader.string(); + break; + case 2: + message.extendee = reader.string(); + break; + case 7: + message.defaultValue = reader.string(); + break; + case 9: + message.oneofIndex = reader.int32(); + break; + case 10: + message.jsonName = reader.string(); + break; + case 8: + message.options = FieldOptions.decode(reader, reader.uint32()); + break; + case 17: + message.proto3Optional = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FieldDescriptorProto { + const message = { ...baseFieldDescriptorProto } as FieldDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = Number(object.number); + } else { + message.number = 0; + } + if (object.label !== undefined && object.label !== null) { + message.label = fieldDescriptorProto_LabelFromJSON(object.label); + } else { + message.label = 1; + } + if (object.type !== undefined && object.type !== null) { + message.type = fieldDescriptorProto_TypeFromJSON(object.type); + } else { + message.type = 1; + } + if (object.typeName !== undefined && object.typeName !== null) { + message.typeName = String(object.typeName); + } else { + message.typeName = ""; + } + if (object.extendee !== undefined && object.extendee !== null) { + message.extendee = String(object.extendee); + } else { + message.extendee = ""; + } + if (object.defaultValue !== undefined && object.defaultValue !== null) { + message.defaultValue = String(object.defaultValue); + } else { + message.defaultValue = ""; + } + if (object.oneofIndex !== undefined && object.oneofIndex !== null) { + message.oneofIndex = Number(object.oneofIndex); + } else { + message.oneofIndex = 0; + } + if (object.jsonName !== undefined && object.jsonName !== null) { + message.jsonName = String(object.jsonName); + } else { + message.jsonName = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = FieldOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.proto3Optional !== undefined && object.proto3Optional !== null) { + message.proto3Optional = Boolean(object.proto3Optional); + } else { + message.proto3Optional = false; + } + return message; + }, + + toJSON(message: FieldDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.number !== undefined && (obj.number = message.number); + message.label !== undefined && + (obj.label = fieldDescriptorProto_LabelToJSON(message.label)); + message.type !== undefined && + (obj.type = fieldDescriptorProto_TypeToJSON(message.type)); + message.typeName !== undefined && (obj.typeName = message.typeName); + message.extendee !== undefined && (obj.extendee = message.extendee); + message.defaultValue !== undefined && + (obj.defaultValue = message.defaultValue); + message.oneofIndex !== undefined && (obj.oneofIndex = message.oneofIndex); + message.jsonName !== undefined && (obj.jsonName = message.jsonName); + message.options !== undefined && + (obj.options = message.options + ? FieldOptions.toJSON(message.options) + : undefined); + message.proto3Optional !== undefined && + (obj.proto3Optional = message.proto3Optional); + return obj; + }, + + fromPartial(object: DeepPartial): FieldDescriptorProto { + const message = { ...baseFieldDescriptorProto } as FieldDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = object.number; + } else { + message.number = 0; + } + if (object.label !== undefined && object.label !== null) { + message.label = object.label; + } else { + message.label = 1; + } + if (object.type !== undefined && object.type !== null) { + message.type = object.type; + } else { + message.type = 1; + } + if (object.typeName !== undefined && object.typeName !== null) { + message.typeName = object.typeName; + } else { + message.typeName = ""; + } + if (object.extendee !== undefined && object.extendee !== null) { + message.extendee = object.extendee; + } else { + message.extendee = ""; + } + if (object.defaultValue !== undefined && object.defaultValue !== null) { + message.defaultValue = object.defaultValue; + } else { + message.defaultValue = ""; + } + if (object.oneofIndex !== undefined && object.oneofIndex !== null) { + message.oneofIndex = object.oneofIndex; + } else { + message.oneofIndex = 0; + } + if (object.jsonName !== undefined && object.jsonName !== null) { + message.jsonName = object.jsonName; + } else { + message.jsonName = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = FieldOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.proto3Optional !== undefined && object.proto3Optional !== null) { + message.proto3Optional = object.proto3Optional; + } else { + message.proto3Optional = false; + } + return message; + }, +}; + +const baseOneofDescriptorProto: object = { name: "" }; + +export const OneofDescriptorProto = { + encode( + message: OneofDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.options !== undefined) { + OneofOptions.encode(message.options, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): OneofDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseOneofDescriptorProto } as OneofDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.options = OneofOptions.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): OneofDescriptorProto { + const message = { ...baseOneofDescriptorProto } as OneofDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = OneofOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: OneofDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.options !== undefined && + (obj.options = message.options + ? OneofOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): OneofDescriptorProto { + const message = { ...baseOneofDescriptorProto } as OneofDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = OneofOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseEnumDescriptorProto: object = { name: "", reservedName: "" }; + +export const EnumDescriptorProto = { + encode( + message: EnumDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + for (const v of message.value) { + EnumValueDescriptorProto.encode(v!, writer.uint32(18).fork()).ldelim(); + } + if (message.options !== undefined) { + EnumOptions.encode(message.options, writer.uint32(26).fork()).ldelim(); + } + for (const v of message.reservedRange) { + EnumDescriptorProto_EnumReservedRange.encode( + v!, + writer.uint32(34).fork() + ).ldelim(); + } + for (const v of message.reservedName) { + writer.uint32(42).string(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): EnumDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseEnumDescriptorProto } as EnumDescriptorProto; + message.value = []; + message.reservedRange = []; + message.reservedName = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.value.push( + EnumValueDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 3: + message.options = EnumOptions.decode(reader, reader.uint32()); + break; + case 4: + message.reservedRange.push( + EnumDescriptorProto_EnumReservedRange.decode( + reader, + reader.uint32() + ) + ); + break; + case 5: + message.reservedName.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumDescriptorProto { + const message = { ...baseEnumDescriptorProto } as EnumDescriptorProto; + message.value = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.value !== undefined && object.value !== null) { + for (const e of object.value) { + message.value.push(EnumValueDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push( + EnumDescriptorProto_EnumReservedRange.fromJSON(e) + ); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(String(e)); + } + } + return message; + }, + + toJSON(message: EnumDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + if (message.value) { + obj.value = message.value.map((e) => + e ? EnumValueDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.value = []; + } + message.options !== undefined && + (obj.options = message.options + ? EnumOptions.toJSON(message.options) + : undefined); + if (message.reservedRange) { + obj.reservedRange = message.reservedRange.map((e) => + e ? EnumDescriptorProto_EnumReservedRange.toJSON(e) : undefined + ); + } else { + obj.reservedRange = []; + } + if (message.reservedName) { + obj.reservedName = message.reservedName.map((e) => e); + } else { + obj.reservedName = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): EnumDescriptorProto { + const message = { ...baseEnumDescriptorProto } as EnumDescriptorProto; + message.value = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.value !== undefined && object.value !== null) { + for (const e of object.value) { + message.value.push(EnumValueDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push( + EnumDescriptorProto_EnumReservedRange.fromPartial(e) + ); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(e); + } + } + return message; + }, +}; + +const baseEnumDescriptorProto_EnumReservedRange: object = { start: 0, end: 0 }; + +export const EnumDescriptorProto_EnumReservedRange = { + encode( + message: EnumDescriptorProto_EnumReservedRange, + writer: Writer = Writer.create() + ): Writer { + if (message.start !== 0) { + writer.uint32(8).int32(message.start); + } + if (message.end !== 0) { + writer.uint32(16).int32(message.end); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): EnumDescriptorProto_EnumReservedRange { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseEnumDescriptorProto_EnumReservedRange, + } as EnumDescriptorProto_EnumReservedRange; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.start = reader.int32(); + break; + case 2: + message.end = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumDescriptorProto_EnumReservedRange { + const message = { + ...baseEnumDescriptorProto_EnumReservedRange, + } as EnumDescriptorProto_EnumReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = Number(object.start); + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + return message; + }, + + toJSON(message: EnumDescriptorProto_EnumReservedRange): unknown { + const obj: any = {}; + message.start !== undefined && (obj.start = message.start); + message.end !== undefined && (obj.end = message.end); + return obj; + }, + + fromPartial( + object: DeepPartial + ): EnumDescriptorProto_EnumReservedRange { + const message = { + ...baseEnumDescriptorProto_EnumReservedRange, + } as EnumDescriptorProto_EnumReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = object.start; + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + return message; + }, +}; + +const baseEnumValueDescriptorProto: object = { name: "", number: 0 }; + +export const EnumValueDescriptorProto = { + encode( + message: EnumValueDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.number !== 0) { + writer.uint32(16).int32(message.number); + } + if (message.options !== undefined) { + EnumValueOptions.encode( + message.options, + writer.uint32(26).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): EnumValueDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseEnumValueDescriptorProto, + } as EnumValueDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.number = reader.int32(); + break; + case 3: + message.options = EnumValueOptions.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumValueDescriptorProto { + const message = { + ...baseEnumValueDescriptorProto, + } as EnumValueDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = Number(object.number); + } else { + message.number = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumValueOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: EnumValueDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.number !== undefined && (obj.number = message.number); + message.options !== undefined && + (obj.options = message.options + ? EnumValueOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): EnumValueDescriptorProto { + const message = { + ...baseEnumValueDescriptorProto, + } as EnumValueDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = object.number; + } else { + message.number = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumValueOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseServiceDescriptorProto: object = { name: "" }; + +export const ServiceDescriptorProto = { + encode( + message: ServiceDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + for (const v of message.method) { + MethodDescriptorProto.encode(v!, writer.uint32(18).fork()).ldelim(); + } + if (message.options !== undefined) { + ServiceOptions.encode(message.options, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ServiceDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseServiceDescriptorProto } as ServiceDescriptorProto; + message.method = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.method.push( + MethodDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 3: + message.options = ServiceOptions.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ServiceDescriptorProto { + const message = { ...baseServiceDescriptorProto } as ServiceDescriptorProto; + message.method = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.method !== undefined && object.method !== null) { + for (const e of object.method) { + message.method.push(MethodDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = ServiceOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: ServiceDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + if (message.method) { + obj.method = message.method.map((e) => + e ? MethodDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.method = []; + } + message.options !== undefined && + (obj.options = message.options + ? ServiceOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): ServiceDescriptorProto { + const message = { ...baseServiceDescriptorProto } as ServiceDescriptorProto; + message.method = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.method !== undefined && object.method !== null) { + for (const e of object.method) { + message.method.push(MethodDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = ServiceOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseMethodDescriptorProto: object = { + name: "", + inputType: "", + outputType: "", + clientStreaming: false, + serverStreaming: false, +}; + +export const MethodDescriptorProto = { + encode( + message: MethodDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.inputType !== "") { + writer.uint32(18).string(message.inputType); + } + if (message.outputType !== "") { + writer.uint32(26).string(message.outputType); + } + if (message.options !== undefined) { + MethodOptions.encode(message.options, writer.uint32(34).fork()).ldelim(); + } + if (message.clientStreaming === true) { + writer.uint32(40).bool(message.clientStreaming); + } + if (message.serverStreaming === true) { + writer.uint32(48).bool(message.serverStreaming); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MethodDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMethodDescriptorProto } as MethodDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.inputType = reader.string(); + break; + case 3: + message.outputType = reader.string(); + break; + case 4: + message.options = MethodOptions.decode(reader, reader.uint32()); + break; + case 5: + message.clientStreaming = reader.bool(); + break; + case 6: + message.serverStreaming = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MethodDescriptorProto { + const message = { ...baseMethodDescriptorProto } as MethodDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.inputType !== undefined && object.inputType !== null) { + message.inputType = String(object.inputType); + } else { + message.inputType = ""; + } + if (object.outputType !== undefined && object.outputType !== null) { + message.outputType = String(object.outputType); + } else { + message.outputType = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = MethodOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if ( + object.clientStreaming !== undefined && + object.clientStreaming !== null + ) { + message.clientStreaming = Boolean(object.clientStreaming); + } else { + message.clientStreaming = false; + } + if ( + object.serverStreaming !== undefined && + object.serverStreaming !== null + ) { + message.serverStreaming = Boolean(object.serverStreaming); + } else { + message.serverStreaming = false; + } + return message; + }, + + toJSON(message: MethodDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.inputType !== undefined && (obj.inputType = message.inputType); + message.outputType !== undefined && (obj.outputType = message.outputType); + message.options !== undefined && + (obj.options = message.options + ? MethodOptions.toJSON(message.options) + : undefined); + message.clientStreaming !== undefined && + (obj.clientStreaming = message.clientStreaming); + message.serverStreaming !== undefined && + (obj.serverStreaming = message.serverStreaming); + return obj; + }, + + fromPartial( + object: DeepPartial + ): MethodDescriptorProto { + const message = { ...baseMethodDescriptorProto } as MethodDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.inputType !== undefined && object.inputType !== null) { + message.inputType = object.inputType; + } else { + message.inputType = ""; + } + if (object.outputType !== undefined && object.outputType !== null) { + message.outputType = object.outputType; + } else { + message.outputType = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = MethodOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if ( + object.clientStreaming !== undefined && + object.clientStreaming !== null + ) { + message.clientStreaming = object.clientStreaming; + } else { + message.clientStreaming = false; + } + if ( + object.serverStreaming !== undefined && + object.serverStreaming !== null + ) { + message.serverStreaming = object.serverStreaming; + } else { + message.serverStreaming = false; + } + return message; + }, +}; + +const baseFileOptions: object = { + javaPackage: "", + javaOuterClassname: "", + javaMultipleFiles: false, + javaGenerateEqualsAndHash: false, + javaStringCheckUtf8: false, + optimizeFor: 1, + goPackage: "", + ccGenericServices: false, + javaGenericServices: false, + pyGenericServices: false, + phpGenericServices: false, + deprecated: false, + ccEnableArenas: false, + objcClassPrefix: "", + csharpNamespace: "", + swiftPrefix: "", + phpClassPrefix: "", + phpNamespace: "", + phpMetadataNamespace: "", + rubyPackage: "", +}; + +export const FileOptions = { + encode(message: FileOptions, writer: Writer = Writer.create()): Writer { + if (message.javaPackage !== "") { + writer.uint32(10).string(message.javaPackage); + } + if (message.javaOuterClassname !== "") { + writer.uint32(66).string(message.javaOuterClassname); + } + if (message.javaMultipleFiles === true) { + writer.uint32(80).bool(message.javaMultipleFiles); + } + if (message.javaGenerateEqualsAndHash === true) { + writer.uint32(160).bool(message.javaGenerateEqualsAndHash); + } + if (message.javaStringCheckUtf8 === true) { + writer.uint32(216).bool(message.javaStringCheckUtf8); + } + if (message.optimizeFor !== 1) { + writer.uint32(72).int32(message.optimizeFor); + } + if (message.goPackage !== "") { + writer.uint32(90).string(message.goPackage); + } + if (message.ccGenericServices === true) { + writer.uint32(128).bool(message.ccGenericServices); + } + if (message.javaGenericServices === true) { + writer.uint32(136).bool(message.javaGenericServices); + } + if (message.pyGenericServices === true) { + writer.uint32(144).bool(message.pyGenericServices); + } + if (message.phpGenericServices === true) { + writer.uint32(336).bool(message.phpGenericServices); + } + if (message.deprecated === true) { + writer.uint32(184).bool(message.deprecated); + } + if (message.ccEnableArenas === true) { + writer.uint32(248).bool(message.ccEnableArenas); + } + if (message.objcClassPrefix !== "") { + writer.uint32(290).string(message.objcClassPrefix); + } + if (message.csharpNamespace !== "") { + writer.uint32(298).string(message.csharpNamespace); + } + if (message.swiftPrefix !== "") { + writer.uint32(314).string(message.swiftPrefix); + } + if (message.phpClassPrefix !== "") { + writer.uint32(322).string(message.phpClassPrefix); + } + if (message.phpNamespace !== "") { + writer.uint32(330).string(message.phpNamespace); + } + if (message.phpMetadataNamespace !== "") { + writer.uint32(354).string(message.phpMetadataNamespace); + } + if (message.rubyPackage !== "") { + writer.uint32(362).string(message.rubyPackage); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FileOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFileOptions } as FileOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.javaPackage = reader.string(); + break; + case 8: + message.javaOuterClassname = reader.string(); + break; + case 10: + message.javaMultipleFiles = reader.bool(); + break; + case 20: + message.javaGenerateEqualsAndHash = reader.bool(); + break; + case 27: + message.javaStringCheckUtf8 = reader.bool(); + break; + case 9: + message.optimizeFor = reader.int32() as any; + break; + case 11: + message.goPackage = reader.string(); + break; + case 16: + message.ccGenericServices = reader.bool(); + break; + case 17: + message.javaGenericServices = reader.bool(); + break; + case 18: + message.pyGenericServices = reader.bool(); + break; + case 42: + message.phpGenericServices = reader.bool(); + break; + case 23: + message.deprecated = reader.bool(); + break; + case 31: + message.ccEnableArenas = reader.bool(); + break; + case 36: + message.objcClassPrefix = reader.string(); + break; + case 37: + message.csharpNamespace = reader.string(); + break; + case 39: + message.swiftPrefix = reader.string(); + break; + case 40: + message.phpClassPrefix = reader.string(); + break; + case 41: + message.phpNamespace = reader.string(); + break; + case 44: + message.phpMetadataNamespace = reader.string(); + break; + case 45: + message.rubyPackage = reader.string(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FileOptions { + const message = { ...baseFileOptions } as FileOptions; + message.uninterpretedOption = []; + if (object.javaPackage !== undefined && object.javaPackage !== null) { + message.javaPackage = String(object.javaPackage); + } else { + message.javaPackage = ""; + } + if ( + object.javaOuterClassname !== undefined && + object.javaOuterClassname !== null + ) { + message.javaOuterClassname = String(object.javaOuterClassname); + } else { + message.javaOuterClassname = ""; + } + if ( + object.javaMultipleFiles !== undefined && + object.javaMultipleFiles !== null + ) { + message.javaMultipleFiles = Boolean(object.javaMultipleFiles); + } else { + message.javaMultipleFiles = false; + } + if ( + object.javaGenerateEqualsAndHash !== undefined && + object.javaGenerateEqualsAndHash !== null + ) { + message.javaGenerateEqualsAndHash = Boolean( + object.javaGenerateEqualsAndHash + ); + } else { + message.javaGenerateEqualsAndHash = false; + } + if ( + object.javaStringCheckUtf8 !== undefined && + object.javaStringCheckUtf8 !== null + ) { + message.javaStringCheckUtf8 = Boolean(object.javaStringCheckUtf8); + } else { + message.javaStringCheckUtf8 = false; + } + if (object.optimizeFor !== undefined && object.optimizeFor !== null) { + message.optimizeFor = fileOptions_OptimizeModeFromJSON( + object.optimizeFor + ); + } else { + message.optimizeFor = 1; + } + if (object.goPackage !== undefined && object.goPackage !== null) { + message.goPackage = String(object.goPackage); + } else { + message.goPackage = ""; + } + if ( + object.ccGenericServices !== undefined && + object.ccGenericServices !== null + ) { + message.ccGenericServices = Boolean(object.ccGenericServices); + } else { + message.ccGenericServices = false; + } + if ( + object.javaGenericServices !== undefined && + object.javaGenericServices !== null + ) { + message.javaGenericServices = Boolean(object.javaGenericServices); + } else { + message.javaGenericServices = false; + } + if ( + object.pyGenericServices !== undefined && + object.pyGenericServices !== null + ) { + message.pyGenericServices = Boolean(object.pyGenericServices); + } else { + message.pyGenericServices = false; + } + if ( + object.phpGenericServices !== undefined && + object.phpGenericServices !== null + ) { + message.phpGenericServices = Boolean(object.phpGenericServices); + } else { + message.phpGenericServices = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if (object.ccEnableArenas !== undefined && object.ccEnableArenas !== null) { + message.ccEnableArenas = Boolean(object.ccEnableArenas); + } else { + message.ccEnableArenas = false; + } + if ( + object.objcClassPrefix !== undefined && + object.objcClassPrefix !== null + ) { + message.objcClassPrefix = String(object.objcClassPrefix); + } else { + message.objcClassPrefix = ""; + } + if ( + object.csharpNamespace !== undefined && + object.csharpNamespace !== null + ) { + message.csharpNamespace = String(object.csharpNamespace); + } else { + message.csharpNamespace = ""; + } + if (object.swiftPrefix !== undefined && object.swiftPrefix !== null) { + message.swiftPrefix = String(object.swiftPrefix); + } else { + message.swiftPrefix = ""; + } + if (object.phpClassPrefix !== undefined && object.phpClassPrefix !== null) { + message.phpClassPrefix = String(object.phpClassPrefix); + } else { + message.phpClassPrefix = ""; + } + if (object.phpNamespace !== undefined && object.phpNamespace !== null) { + message.phpNamespace = String(object.phpNamespace); + } else { + message.phpNamespace = ""; + } + if ( + object.phpMetadataNamespace !== undefined && + object.phpMetadataNamespace !== null + ) { + message.phpMetadataNamespace = String(object.phpMetadataNamespace); + } else { + message.phpMetadataNamespace = ""; + } + if (object.rubyPackage !== undefined && object.rubyPackage !== null) { + message.rubyPackage = String(object.rubyPackage); + } else { + message.rubyPackage = ""; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: FileOptions): unknown { + const obj: any = {}; + message.javaPackage !== undefined && + (obj.javaPackage = message.javaPackage); + message.javaOuterClassname !== undefined && + (obj.javaOuterClassname = message.javaOuterClassname); + message.javaMultipleFiles !== undefined && + (obj.javaMultipleFiles = message.javaMultipleFiles); + message.javaGenerateEqualsAndHash !== undefined && + (obj.javaGenerateEqualsAndHash = message.javaGenerateEqualsAndHash); + message.javaStringCheckUtf8 !== undefined && + (obj.javaStringCheckUtf8 = message.javaStringCheckUtf8); + message.optimizeFor !== undefined && + (obj.optimizeFor = fileOptions_OptimizeModeToJSON(message.optimizeFor)); + message.goPackage !== undefined && (obj.goPackage = message.goPackage); + message.ccGenericServices !== undefined && + (obj.ccGenericServices = message.ccGenericServices); + message.javaGenericServices !== undefined && + (obj.javaGenericServices = message.javaGenericServices); + message.pyGenericServices !== undefined && + (obj.pyGenericServices = message.pyGenericServices); + message.phpGenericServices !== undefined && + (obj.phpGenericServices = message.phpGenericServices); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.ccEnableArenas !== undefined && + (obj.ccEnableArenas = message.ccEnableArenas); + message.objcClassPrefix !== undefined && + (obj.objcClassPrefix = message.objcClassPrefix); + message.csharpNamespace !== undefined && + (obj.csharpNamespace = message.csharpNamespace); + message.swiftPrefix !== undefined && + (obj.swiftPrefix = message.swiftPrefix); + message.phpClassPrefix !== undefined && + (obj.phpClassPrefix = message.phpClassPrefix); + message.phpNamespace !== undefined && + (obj.phpNamespace = message.phpNamespace); + message.phpMetadataNamespace !== undefined && + (obj.phpMetadataNamespace = message.phpMetadataNamespace); + message.rubyPackage !== undefined && + (obj.rubyPackage = message.rubyPackage); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): FileOptions { + const message = { ...baseFileOptions } as FileOptions; + message.uninterpretedOption = []; + if (object.javaPackage !== undefined && object.javaPackage !== null) { + message.javaPackage = object.javaPackage; + } else { + message.javaPackage = ""; + } + if ( + object.javaOuterClassname !== undefined && + object.javaOuterClassname !== null + ) { + message.javaOuterClassname = object.javaOuterClassname; + } else { + message.javaOuterClassname = ""; + } + if ( + object.javaMultipleFiles !== undefined && + object.javaMultipleFiles !== null + ) { + message.javaMultipleFiles = object.javaMultipleFiles; + } else { + message.javaMultipleFiles = false; + } + if ( + object.javaGenerateEqualsAndHash !== undefined && + object.javaGenerateEqualsAndHash !== null + ) { + message.javaGenerateEqualsAndHash = object.javaGenerateEqualsAndHash; + } else { + message.javaGenerateEqualsAndHash = false; + } + if ( + object.javaStringCheckUtf8 !== undefined && + object.javaStringCheckUtf8 !== null + ) { + message.javaStringCheckUtf8 = object.javaStringCheckUtf8; + } else { + message.javaStringCheckUtf8 = false; + } + if (object.optimizeFor !== undefined && object.optimizeFor !== null) { + message.optimizeFor = object.optimizeFor; + } else { + message.optimizeFor = 1; + } + if (object.goPackage !== undefined && object.goPackage !== null) { + message.goPackage = object.goPackage; + } else { + message.goPackage = ""; + } + if ( + object.ccGenericServices !== undefined && + object.ccGenericServices !== null + ) { + message.ccGenericServices = object.ccGenericServices; + } else { + message.ccGenericServices = false; + } + if ( + object.javaGenericServices !== undefined && + object.javaGenericServices !== null + ) { + message.javaGenericServices = object.javaGenericServices; + } else { + message.javaGenericServices = false; + } + if ( + object.pyGenericServices !== undefined && + object.pyGenericServices !== null + ) { + message.pyGenericServices = object.pyGenericServices; + } else { + message.pyGenericServices = false; + } + if ( + object.phpGenericServices !== undefined && + object.phpGenericServices !== null + ) { + message.phpGenericServices = object.phpGenericServices; + } else { + message.phpGenericServices = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if (object.ccEnableArenas !== undefined && object.ccEnableArenas !== null) { + message.ccEnableArenas = object.ccEnableArenas; + } else { + message.ccEnableArenas = false; + } + if ( + object.objcClassPrefix !== undefined && + object.objcClassPrefix !== null + ) { + message.objcClassPrefix = object.objcClassPrefix; + } else { + message.objcClassPrefix = ""; + } + if ( + object.csharpNamespace !== undefined && + object.csharpNamespace !== null + ) { + message.csharpNamespace = object.csharpNamespace; + } else { + message.csharpNamespace = ""; + } + if (object.swiftPrefix !== undefined && object.swiftPrefix !== null) { + message.swiftPrefix = object.swiftPrefix; + } else { + message.swiftPrefix = ""; + } + if (object.phpClassPrefix !== undefined && object.phpClassPrefix !== null) { + message.phpClassPrefix = object.phpClassPrefix; + } else { + message.phpClassPrefix = ""; + } + if (object.phpNamespace !== undefined && object.phpNamespace !== null) { + message.phpNamespace = object.phpNamespace; + } else { + message.phpNamespace = ""; + } + if ( + object.phpMetadataNamespace !== undefined && + object.phpMetadataNamespace !== null + ) { + message.phpMetadataNamespace = object.phpMetadataNamespace; + } else { + message.phpMetadataNamespace = ""; + } + if (object.rubyPackage !== undefined && object.rubyPackage !== null) { + message.rubyPackage = object.rubyPackage; + } else { + message.rubyPackage = ""; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseMessageOptions: object = { + messageSetWireFormat: false, + noStandardDescriptorAccessor: false, + deprecated: false, + mapEntry: false, +}; + +export const MessageOptions = { + encode(message: MessageOptions, writer: Writer = Writer.create()): Writer { + if (message.messageSetWireFormat === true) { + writer.uint32(8).bool(message.messageSetWireFormat); + } + if (message.noStandardDescriptorAccessor === true) { + writer.uint32(16).bool(message.noStandardDescriptorAccessor); + } + if (message.deprecated === true) { + writer.uint32(24).bool(message.deprecated); + } + if (message.mapEntry === true) { + writer.uint32(56).bool(message.mapEntry); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MessageOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMessageOptions } as MessageOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.messageSetWireFormat = reader.bool(); + break; + case 2: + message.noStandardDescriptorAccessor = reader.bool(); + break; + case 3: + message.deprecated = reader.bool(); + break; + case 7: + message.mapEntry = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MessageOptions { + const message = { ...baseMessageOptions } as MessageOptions; + message.uninterpretedOption = []; + if ( + object.messageSetWireFormat !== undefined && + object.messageSetWireFormat !== null + ) { + message.messageSetWireFormat = Boolean(object.messageSetWireFormat); + } else { + message.messageSetWireFormat = false; + } + if ( + object.noStandardDescriptorAccessor !== undefined && + object.noStandardDescriptorAccessor !== null + ) { + message.noStandardDescriptorAccessor = Boolean( + object.noStandardDescriptorAccessor + ); + } else { + message.noStandardDescriptorAccessor = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if (object.mapEntry !== undefined && object.mapEntry !== null) { + message.mapEntry = Boolean(object.mapEntry); + } else { + message.mapEntry = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: MessageOptions): unknown { + const obj: any = {}; + message.messageSetWireFormat !== undefined && + (obj.messageSetWireFormat = message.messageSetWireFormat); + message.noStandardDescriptorAccessor !== undefined && + (obj.noStandardDescriptorAccessor = message.noStandardDescriptorAccessor); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.mapEntry !== undefined && (obj.mapEntry = message.mapEntry); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): MessageOptions { + const message = { ...baseMessageOptions } as MessageOptions; + message.uninterpretedOption = []; + if ( + object.messageSetWireFormat !== undefined && + object.messageSetWireFormat !== null + ) { + message.messageSetWireFormat = object.messageSetWireFormat; + } else { + message.messageSetWireFormat = false; + } + if ( + object.noStandardDescriptorAccessor !== undefined && + object.noStandardDescriptorAccessor !== null + ) { + message.noStandardDescriptorAccessor = + object.noStandardDescriptorAccessor; + } else { + message.noStandardDescriptorAccessor = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if (object.mapEntry !== undefined && object.mapEntry !== null) { + message.mapEntry = object.mapEntry; + } else { + message.mapEntry = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseFieldOptions: object = { + ctype: 0, + packed: false, + jstype: 0, + lazy: false, + deprecated: false, + weak: false, +}; + +export const FieldOptions = { + encode(message: FieldOptions, writer: Writer = Writer.create()): Writer { + if (message.ctype !== 0) { + writer.uint32(8).int32(message.ctype); + } + if (message.packed === true) { + writer.uint32(16).bool(message.packed); + } + if (message.jstype !== 0) { + writer.uint32(48).int32(message.jstype); + } + if (message.lazy === true) { + writer.uint32(40).bool(message.lazy); + } + if (message.deprecated === true) { + writer.uint32(24).bool(message.deprecated); + } + if (message.weak === true) { + writer.uint32(80).bool(message.weak); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FieldOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFieldOptions } as FieldOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.ctype = reader.int32() as any; + break; + case 2: + message.packed = reader.bool(); + break; + case 6: + message.jstype = reader.int32() as any; + break; + case 5: + message.lazy = reader.bool(); + break; + case 3: + message.deprecated = reader.bool(); + break; + case 10: + message.weak = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FieldOptions { + const message = { ...baseFieldOptions } as FieldOptions; + message.uninterpretedOption = []; + if (object.ctype !== undefined && object.ctype !== null) { + message.ctype = fieldOptions_CTypeFromJSON(object.ctype); + } else { + message.ctype = 0; + } + if (object.packed !== undefined && object.packed !== null) { + message.packed = Boolean(object.packed); + } else { + message.packed = false; + } + if (object.jstype !== undefined && object.jstype !== null) { + message.jstype = fieldOptions_JSTypeFromJSON(object.jstype); + } else { + message.jstype = 0; + } + if (object.lazy !== undefined && object.lazy !== null) { + message.lazy = Boolean(object.lazy); + } else { + message.lazy = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if (object.weak !== undefined && object.weak !== null) { + message.weak = Boolean(object.weak); + } else { + message.weak = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: FieldOptions): unknown { + const obj: any = {}; + message.ctype !== undefined && + (obj.ctype = fieldOptions_CTypeToJSON(message.ctype)); + message.packed !== undefined && (obj.packed = message.packed); + message.jstype !== undefined && + (obj.jstype = fieldOptions_JSTypeToJSON(message.jstype)); + message.lazy !== undefined && (obj.lazy = message.lazy); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.weak !== undefined && (obj.weak = message.weak); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): FieldOptions { + const message = { ...baseFieldOptions } as FieldOptions; + message.uninterpretedOption = []; + if (object.ctype !== undefined && object.ctype !== null) { + message.ctype = object.ctype; + } else { + message.ctype = 0; + } + if (object.packed !== undefined && object.packed !== null) { + message.packed = object.packed; + } else { + message.packed = false; + } + if (object.jstype !== undefined && object.jstype !== null) { + message.jstype = object.jstype; + } else { + message.jstype = 0; + } + if (object.lazy !== undefined && object.lazy !== null) { + message.lazy = object.lazy; + } else { + message.lazy = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if (object.weak !== undefined && object.weak !== null) { + message.weak = object.weak; + } else { + message.weak = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseOneofOptions: object = {}; + +export const OneofOptions = { + encode(message: OneofOptions, writer: Writer = Writer.create()): Writer { + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): OneofOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseOneofOptions } as OneofOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): OneofOptions { + const message = { ...baseOneofOptions } as OneofOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: OneofOptions): unknown { + const obj: any = {}; + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): OneofOptions { + const message = { ...baseOneofOptions } as OneofOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseEnumOptions: object = { allowAlias: false, deprecated: false }; + +export const EnumOptions = { + encode(message: EnumOptions, writer: Writer = Writer.create()): Writer { + if (message.allowAlias === true) { + writer.uint32(16).bool(message.allowAlias); + } + if (message.deprecated === true) { + writer.uint32(24).bool(message.deprecated); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): EnumOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseEnumOptions } as EnumOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + message.allowAlias = reader.bool(); + break; + case 3: + message.deprecated = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumOptions { + const message = { ...baseEnumOptions } as EnumOptions; + message.uninterpretedOption = []; + if (object.allowAlias !== undefined && object.allowAlias !== null) { + message.allowAlias = Boolean(object.allowAlias); + } else { + message.allowAlias = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: EnumOptions): unknown { + const obj: any = {}; + message.allowAlias !== undefined && (obj.allowAlias = message.allowAlias); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): EnumOptions { + const message = { ...baseEnumOptions } as EnumOptions; + message.uninterpretedOption = []; + if (object.allowAlias !== undefined && object.allowAlias !== null) { + message.allowAlias = object.allowAlias; + } else { + message.allowAlias = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseEnumValueOptions: object = { deprecated: false }; + +export const EnumValueOptions = { + encode(message: EnumValueOptions, writer: Writer = Writer.create()): Writer { + if (message.deprecated === true) { + writer.uint32(8).bool(message.deprecated); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): EnumValueOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseEnumValueOptions } as EnumValueOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.deprecated = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumValueOptions { + const message = { ...baseEnumValueOptions } as EnumValueOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: EnumValueOptions): unknown { + const obj: any = {}; + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): EnumValueOptions { + const message = { ...baseEnumValueOptions } as EnumValueOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseServiceOptions: object = { deprecated: false }; + +export const ServiceOptions = { + encode(message: ServiceOptions, writer: Writer = Writer.create()): Writer { + if (message.deprecated === true) { + writer.uint32(264).bool(message.deprecated); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ServiceOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseServiceOptions } as ServiceOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 33: + message.deprecated = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ServiceOptions { + const message = { ...baseServiceOptions } as ServiceOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: ServiceOptions): unknown { + const obj: any = {}; + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): ServiceOptions { + const message = { ...baseServiceOptions } as ServiceOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseMethodOptions: object = { deprecated: false, idempotencyLevel: 0 }; + +export const MethodOptions = { + encode(message: MethodOptions, writer: Writer = Writer.create()): Writer { + if (message.deprecated === true) { + writer.uint32(264).bool(message.deprecated); + } + if (message.idempotencyLevel !== 0) { + writer.uint32(272).int32(message.idempotencyLevel); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MethodOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMethodOptions } as MethodOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 33: + message.deprecated = reader.bool(); + break; + case 34: + message.idempotencyLevel = reader.int32() as any; + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MethodOptions { + const message = { ...baseMethodOptions } as MethodOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.idempotencyLevel !== undefined && + object.idempotencyLevel !== null + ) { + message.idempotencyLevel = methodOptions_IdempotencyLevelFromJSON( + object.idempotencyLevel + ); + } else { + message.idempotencyLevel = 0; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: MethodOptions): unknown { + const obj: any = {}; + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.idempotencyLevel !== undefined && + (obj.idempotencyLevel = methodOptions_IdempotencyLevelToJSON( + message.idempotencyLevel + )); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): MethodOptions { + const message = { ...baseMethodOptions } as MethodOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.idempotencyLevel !== undefined && + object.idempotencyLevel !== null + ) { + message.idempotencyLevel = object.idempotencyLevel; + } else { + message.idempotencyLevel = 0; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseUninterpretedOption: object = { + identifierValue: "", + positiveIntValue: 0, + negativeIntValue: 0, + doubleValue: 0, + aggregateValue: "", +}; + +export const UninterpretedOption = { + encode( + message: UninterpretedOption, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.name) { + UninterpretedOption_NamePart.encode( + v!, + writer.uint32(18).fork() + ).ldelim(); + } + if (message.identifierValue !== "") { + writer.uint32(26).string(message.identifierValue); + } + if (message.positiveIntValue !== 0) { + writer.uint32(32).uint64(message.positiveIntValue); + } + if (message.negativeIntValue !== 0) { + writer.uint32(40).int64(message.negativeIntValue); + } + if (message.doubleValue !== 0) { + writer.uint32(49).double(message.doubleValue); + } + if (message.stringValue.length !== 0) { + writer.uint32(58).bytes(message.stringValue); + } + if (message.aggregateValue !== "") { + writer.uint32(66).string(message.aggregateValue); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): UninterpretedOption { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseUninterpretedOption } as UninterpretedOption; + message.name = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + message.name.push( + UninterpretedOption_NamePart.decode(reader, reader.uint32()) + ); + break; + case 3: + message.identifierValue = reader.string(); + break; + case 4: + message.positiveIntValue = longToNumber(reader.uint64() as Long); + break; + case 5: + message.negativeIntValue = longToNumber(reader.int64() as Long); + break; + case 6: + message.doubleValue = reader.double(); + break; + case 7: + message.stringValue = reader.bytes(); + break; + case 8: + message.aggregateValue = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): UninterpretedOption { + const message = { ...baseUninterpretedOption } as UninterpretedOption; + message.name = []; + if (object.name !== undefined && object.name !== null) { + for (const e of object.name) { + message.name.push(UninterpretedOption_NamePart.fromJSON(e)); + } + } + if ( + object.identifierValue !== undefined && + object.identifierValue !== null + ) { + message.identifierValue = String(object.identifierValue); + } else { + message.identifierValue = ""; + } + if ( + object.positiveIntValue !== undefined && + object.positiveIntValue !== null + ) { + message.positiveIntValue = Number(object.positiveIntValue); + } else { + message.positiveIntValue = 0; + } + if ( + object.negativeIntValue !== undefined && + object.negativeIntValue !== null + ) { + message.negativeIntValue = Number(object.negativeIntValue); + } else { + message.negativeIntValue = 0; + } + if (object.doubleValue !== undefined && object.doubleValue !== null) { + message.doubleValue = Number(object.doubleValue); + } else { + message.doubleValue = 0; + } + if (object.stringValue !== undefined && object.stringValue !== null) { + message.stringValue = bytesFromBase64(object.stringValue); + } + if (object.aggregateValue !== undefined && object.aggregateValue !== null) { + message.aggregateValue = String(object.aggregateValue); + } else { + message.aggregateValue = ""; + } + return message; + }, + + toJSON(message: UninterpretedOption): unknown { + const obj: any = {}; + if (message.name) { + obj.name = message.name.map((e) => + e ? UninterpretedOption_NamePart.toJSON(e) : undefined + ); + } else { + obj.name = []; + } + message.identifierValue !== undefined && + (obj.identifierValue = message.identifierValue); + message.positiveIntValue !== undefined && + (obj.positiveIntValue = message.positiveIntValue); + message.negativeIntValue !== undefined && + (obj.negativeIntValue = message.negativeIntValue); + message.doubleValue !== undefined && + (obj.doubleValue = message.doubleValue); + message.stringValue !== undefined && + (obj.stringValue = base64FromBytes( + message.stringValue !== undefined + ? message.stringValue + : new Uint8Array() + )); + message.aggregateValue !== undefined && + (obj.aggregateValue = message.aggregateValue); + return obj; + }, + + fromPartial(object: DeepPartial): UninterpretedOption { + const message = { ...baseUninterpretedOption } as UninterpretedOption; + message.name = []; + if (object.name !== undefined && object.name !== null) { + for (const e of object.name) { + message.name.push(UninterpretedOption_NamePart.fromPartial(e)); + } + } + if ( + object.identifierValue !== undefined && + object.identifierValue !== null + ) { + message.identifierValue = object.identifierValue; + } else { + message.identifierValue = ""; + } + if ( + object.positiveIntValue !== undefined && + object.positiveIntValue !== null + ) { + message.positiveIntValue = object.positiveIntValue; + } else { + message.positiveIntValue = 0; + } + if ( + object.negativeIntValue !== undefined && + object.negativeIntValue !== null + ) { + message.negativeIntValue = object.negativeIntValue; + } else { + message.negativeIntValue = 0; + } + if (object.doubleValue !== undefined && object.doubleValue !== null) { + message.doubleValue = object.doubleValue; + } else { + message.doubleValue = 0; + } + if (object.stringValue !== undefined && object.stringValue !== null) { + message.stringValue = object.stringValue; + } else { + message.stringValue = new Uint8Array(); + } + if (object.aggregateValue !== undefined && object.aggregateValue !== null) { + message.aggregateValue = object.aggregateValue; + } else { + message.aggregateValue = ""; + } + return message; + }, +}; + +const baseUninterpretedOption_NamePart: object = { + namePart: "", + isExtension: false, +}; + +export const UninterpretedOption_NamePart = { + encode( + message: UninterpretedOption_NamePart, + writer: Writer = Writer.create() + ): Writer { + if (message.namePart !== "") { + writer.uint32(10).string(message.namePart); + } + if (message.isExtension === true) { + writer.uint32(16).bool(message.isExtension); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): UninterpretedOption_NamePart { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseUninterpretedOption_NamePart, + } as UninterpretedOption_NamePart; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.namePart = reader.string(); + break; + case 2: + message.isExtension = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): UninterpretedOption_NamePart { + const message = { + ...baseUninterpretedOption_NamePart, + } as UninterpretedOption_NamePart; + if (object.namePart !== undefined && object.namePart !== null) { + message.namePart = String(object.namePart); + } else { + message.namePart = ""; + } + if (object.isExtension !== undefined && object.isExtension !== null) { + message.isExtension = Boolean(object.isExtension); + } else { + message.isExtension = false; + } + return message; + }, + + toJSON(message: UninterpretedOption_NamePart): unknown { + const obj: any = {}; + message.namePart !== undefined && (obj.namePart = message.namePart); + message.isExtension !== undefined && + (obj.isExtension = message.isExtension); + return obj; + }, + + fromPartial( + object: DeepPartial + ): UninterpretedOption_NamePart { + const message = { + ...baseUninterpretedOption_NamePart, + } as UninterpretedOption_NamePart; + if (object.namePart !== undefined && object.namePart !== null) { + message.namePart = object.namePart; + } else { + message.namePart = ""; + } + if (object.isExtension !== undefined && object.isExtension !== null) { + message.isExtension = object.isExtension; + } else { + message.isExtension = false; + } + return message; + }, +}; + +const baseSourceCodeInfo: object = {}; + +export const SourceCodeInfo = { + encode(message: SourceCodeInfo, writer: Writer = Writer.create()): Writer { + for (const v of message.location) { + SourceCodeInfo_Location.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): SourceCodeInfo { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseSourceCodeInfo } as SourceCodeInfo; + message.location = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.location.push( + SourceCodeInfo_Location.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): SourceCodeInfo { + const message = { ...baseSourceCodeInfo } as SourceCodeInfo; + message.location = []; + if (object.location !== undefined && object.location !== null) { + for (const e of object.location) { + message.location.push(SourceCodeInfo_Location.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: SourceCodeInfo): unknown { + const obj: any = {}; + if (message.location) { + obj.location = message.location.map((e) => + e ? SourceCodeInfo_Location.toJSON(e) : undefined + ); + } else { + obj.location = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): SourceCodeInfo { + const message = { ...baseSourceCodeInfo } as SourceCodeInfo; + message.location = []; + if (object.location !== undefined && object.location !== null) { + for (const e of object.location) { + message.location.push(SourceCodeInfo_Location.fromPartial(e)); + } + } + return message; + }, +}; + +const baseSourceCodeInfo_Location: object = { + path: 0, + span: 0, + leadingComments: "", + trailingComments: "", + leadingDetachedComments: "", +}; + +export const SourceCodeInfo_Location = { + encode( + message: SourceCodeInfo_Location, + writer: Writer = Writer.create() + ): Writer { + writer.uint32(10).fork(); + for (const v of message.path) { + writer.int32(v); + } + writer.ldelim(); + writer.uint32(18).fork(); + for (const v of message.span) { + writer.int32(v); + } + writer.ldelim(); + if (message.leadingComments !== "") { + writer.uint32(26).string(message.leadingComments); + } + if (message.trailingComments !== "") { + writer.uint32(34).string(message.trailingComments); + } + for (const v of message.leadingDetachedComments) { + writer.uint32(50).string(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): SourceCodeInfo_Location { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseSourceCodeInfo_Location, + } as SourceCodeInfo_Location; + message.path = []; + message.span = []; + message.leadingDetachedComments = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.path.push(reader.int32()); + } + } else { + message.path.push(reader.int32()); + } + break; + case 2: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.span.push(reader.int32()); + } + } else { + message.span.push(reader.int32()); + } + break; + case 3: + message.leadingComments = reader.string(); + break; + case 4: + message.trailingComments = reader.string(); + break; + case 6: + message.leadingDetachedComments.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): SourceCodeInfo_Location { + const message = { + ...baseSourceCodeInfo_Location, + } as SourceCodeInfo_Location; + message.path = []; + message.span = []; + message.leadingDetachedComments = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(Number(e)); + } + } + if (object.span !== undefined && object.span !== null) { + for (const e of object.span) { + message.span.push(Number(e)); + } + } + if ( + object.leadingComments !== undefined && + object.leadingComments !== null + ) { + message.leadingComments = String(object.leadingComments); + } else { + message.leadingComments = ""; + } + if ( + object.trailingComments !== undefined && + object.trailingComments !== null + ) { + message.trailingComments = String(object.trailingComments); + } else { + message.trailingComments = ""; + } + if ( + object.leadingDetachedComments !== undefined && + object.leadingDetachedComments !== null + ) { + for (const e of object.leadingDetachedComments) { + message.leadingDetachedComments.push(String(e)); + } + } + return message; + }, + + toJSON(message: SourceCodeInfo_Location): unknown { + const obj: any = {}; + if (message.path) { + obj.path = message.path.map((e) => e); + } else { + obj.path = []; + } + if (message.span) { + obj.span = message.span.map((e) => e); + } else { + obj.span = []; + } + message.leadingComments !== undefined && + (obj.leadingComments = message.leadingComments); + message.trailingComments !== undefined && + (obj.trailingComments = message.trailingComments); + if (message.leadingDetachedComments) { + obj.leadingDetachedComments = message.leadingDetachedComments.map( + (e) => e + ); + } else { + obj.leadingDetachedComments = []; + } + return obj; + }, + + fromPartial( + object: DeepPartial + ): SourceCodeInfo_Location { + const message = { + ...baseSourceCodeInfo_Location, + } as SourceCodeInfo_Location; + message.path = []; + message.span = []; + message.leadingDetachedComments = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(e); + } + } + if (object.span !== undefined && object.span !== null) { + for (const e of object.span) { + message.span.push(e); + } + } + if ( + object.leadingComments !== undefined && + object.leadingComments !== null + ) { + message.leadingComments = object.leadingComments; + } else { + message.leadingComments = ""; + } + if ( + object.trailingComments !== undefined && + object.trailingComments !== null + ) { + message.trailingComments = object.trailingComments; + } else { + message.trailingComments = ""; + } + if ( + object.leadingDetachedComments !== undefined && + object.leadingDetachedComments !== null + ) { + for (const e of object.leadingDetachedComments) { + message.leadingDetachedComments.push(e); + } + } + return message; + }, +}; + +const baseGeneratedCodeInfo: object = {}; + +export const GeneratedCodeInfo = { + encode(message: GeneratedCodeInfo, writer: Writer = Writer.create()): Writer { + for (const v of message.annotation) { + GeneratedCodeInfo_Annotation.encode( + v!, + writer.uint32(10).fork() + ).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): GeneratedCodeInfo { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseGeneratedCodeInfo } as GeneratedCodeInfo; + message.annotation = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.annotation.push( + GeneratedCodeInfo_Annotation.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GeneratedCodeInfo { + const message = { ...baseGeneratedCodeInfo } as GeneratedCodeInfo; + message.annotation = []; + if (object.annotation !== undefined && object.annotation !== null) { + for (const e of object.annotation) { + message.annotation.push(GeneratedCodeInfo_Annotation.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: GeneratedCodeInfo): unknown { + const obj: any = {}; + if (message.annotation) { + obj.annotation = message.annotation.map((e) => + e ? GeneratedCodeInfo_Annotation.toJSON(e) : undefined + ); + } else { + obj.annotation = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): GeneratedCodeInfo { + const message = { ...baseGeneratedCodeInfo } as GeneratedCodeInfo; + message.annotation = []; + if (object.annotation !== undefined && object.annotation !== null) { + for (const e of object.annotation) { + message.annotation.push(GeneratedCodeInfo_Annotation.fromPartial(e)); + } + } + return message; + }, +}; + +const baseGeneratedCodeInfo_Annotation: object = { + path: 0, + sourceFile: "", + begin: 0, + end: 0, +}; + +export const GeneratedCodeInfo_Annotation = { + encode( + message: GeneratedCodeInfo_Annotation, + writer: Writer = Writer.create() + ): Writer { + writer.uint32(10).fork(); + for (const v of message.path) { + writer.int32(v); + } + writer.ldelim(); + if (message.sourceFile !== "") { + writer.uint32(18).string(message.sourceFile); + } + if (message.begin !== 0) { + writer.uint32(24).int32(message.begin); + } + if (message.end !== 0) { + writer.uint32(32).int32(message.end); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): GeneratedCodeInfo_Annotation { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseGeneratedCodeInfo_Annotation, + } as GeneratedCodeInfo_Annotation; + message.path = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.path.push(reader.int32()); + } + } else { + message.path.push(reader.int32()); + } + break; + case 2: + message.sourceFile = reader.string(); + break; + case 3: + message.begin = reader.int32(); + break; + case 4: + message.end = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GeneratedCodeInfo_Annotation { + const message = { + ...baseGeneratedCodeInfo_Annotation, + } as GeneratedCodeInfo_Annotation; + message.path = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(Number(e)); + } + } + if (object.sourceFile !== undefined && object.sourceFile !== null) { + message.sourceFile = String(object.sourceFile); + } else { + message.sourceFile = ""; + } + if (object.begin !== undefined && object.begin !== null) { + message.begin = Number(object.begin); + } else { + message.begin = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + return message; + }, + + toJSON(message: GeneratedCodeInfo_Annotation): unknown { + const obj: any = {}; + if (message.path) { + obj.path = message.path.map((e) => e); + } else { + obj.path = []; + } + message.sourceFile !== undefined && (obj.sourceFile = message.sourceFile); + message.begin !== undefined && (obj.begin = message.begin); + message.end !== undefined && (obj.end = message.end); + return obj; + }, + + fromPartial( + object: DeepPartial + ): GeneratedCodeInfo_Annotation { + const message = { + ...baseGeneratedCodeInfo_Annotation, + } as GeneratedCodeInfo_Annotation; + message.path = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(e); + } + } + if (object.sourceFile !== undefined && object.sourceFile !== null) { + message.sourceFile = object.sourceFile; + } else { + message.sourceFile = ""; + } + if (object.begin !== undefined && object.begin !== null) { + message.begin = object.begin; + } else { + message.begin = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/cosmos.base.tendermint.v1beta1/index.ts b/ts-client/cosmos.base.tendermint.v1beta1/index.ts new file mode 100755 index 00000000..c9dfa159 --- /dev/null +++ b/ts-client/cosmos.base.tendermint.v1beta1/index.ts @@ -0,0 +1,6 @@ +import Module from './module'; +import { txClient, queryClient, registry } from './module'; +import { msgTypes } from './registry'; + +export * from "./types"; +export { Module, msgTypes, txClient, queryClient, registry }; diff --git a/ts-client/cosmos.base.tendermint.v1beta1/module.ts b/ts-client/cosmos.base.tendermint.v1beta1/module.ts new file mode 100755 index 00000000..57a1c501 --- /dev/null +++ b/ts-client/cosmos.base.tendermint.v1beta1/module.ts @@ -0,0 +1,66 @@ +// Generated by Ignite ignite.com/cli + +import { StdFee } from "@cosmjs/launchpad"; +import { SigningStargateClient, DeliverTxResponse } from "@cosmjs/stargate"; +import { EncodeObject, GeneratedType, OfflineSigner, Registry } from "@cosmjs/proto-signing"; +import { msgTypes } from './registry'; +import { IgniteClient } from "../client" +import { MissingWalletError } from "../helpers" +import { Api } from "./rest"; + + +export { }; + + + +export const registry = new Registry(msgTypes); + +const defaultFee = { + amount: [], + gas: "200000", +}; + +interface TxClientOptions { + addr: string + prefix: string + signer?: OfflineSigner +} + +export const txClient = ({ signer, prefix, addr }: TxClientOptions = { addr: "http://localhost:26657", prefix: "cosmos" }) => { + + return { + + + } +}; + +interface QueryClientOptions { + addr: string +} + +export const queryClient = ({ addr: addr }: QueryClientOptions = { addr: "http://localhost:1317" }) => { + return new Api({ baseUrl: addr }); +}; + +class SDKModule { + public query: ReturnType; + public tx: ReturnType; + + public registry: Array<[string, GeneratedType]>; + + constructor(client: IgniteClient) { + + this.query = queryClient({ addr: client.env.apiURL }); + this.tx = txClient({ signer: client.signer, addr: client.env.rpcURL, prefix: client.env.prefix ?? "cosmos" }); + } +}; + +const Module = (test: IgniteClient) => { + return { + module: { + CosmosBaseTendermintV1Beta1: new SDKModule(test) + }, + registry: msgTypes + } +} +export default Module; \ No newline at end of file diff --git a/ts-client/cosmos.base.tendermint.v1beta1/registry.ts b/ts-client/cosmos.base.tendermint.v1beta1/registry.ts new file mode 100755 index 00000000..26157e4f --- /dev/null +++ b/ts-client/cosmos.base.tendermint.v1beta1/registry.ts @@ -0,0 +1,7 @@ +import { GeneratedType } from "@cosmjs/proto-signing"; + +const msgTypes: Array<[string, GeneratedType]> = [ + +]; + +export { msgTypes } \ No newline at end of file diff --git a/ts-client/cosmos.base.tendermint.v1beta1/rest.ts b/ts-client/cosmos.base.tendermint.v1beta1/rest.ts new file mode 100644 index 00000000..ae801368 --- /dev/null +++ b/ts-client/cosmos.base.tendermint.v1beta1/rest.ts @@ -0,0 +1,998 @@ +/* eslint-disable */ +/* tslint:disable */ +/* + * --------------------------------------------------------------- + * ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ## + * ## ## + * ## AUTHOR: acacode ## + * ## SOURCE: https://github.com/acacode/swagger-typescript-api ## + * --------------------------------------------------------------- + */ + +export interface CryptoPublicKey { + /** @format byte */ + ed25519?: string; + + /** @format byte */ + secp256k1?: string; +} + +export interface P2PDefaultNodeInfo { + protocol_version?: P2PProtocolVersion; + default_node_id?: string; + listen_addr?: string; + network?: string; + version?: string; + + /** @format byte */ + channels?: string; + moniker?: string; + other?: P2PDefaultNodeInfoOther; +} + +export interface P2PDefaultNodeInfoOther { + tx_index?: string; + rpc_address?: string; +} + +export interface P2PProtocolVersion { + /** @format uint64 */ + p2p?: string; + + /** @format uint64 */ + block?: string; + + /** @format uint64 */ + app?: string; +} + +/** +* `Any` contains an arbitrary serialized protocol buffer message along with a +URL that describes the type of the serialized message. + +Protobuf library provides support to pack/unpack Any values in the form +of utility functions or additional generated methods of the Any type. + +Example 1: Pack and unpack a message in C++. + + Foo foo = ...; + Any any; + any.PackFrom(foo); + ... + if (any.UnpackTo(&foo)) { + ... + } + +Example 2: Pack and unpack a message in Java. + + Foo foo = ...; + Any any = Any.pack(foo); + ... + if (any.is(Foo.class)) { + foo = any.unpack(Foo.class); + } + + Example 3: Pack and unpack a message in Python. + + foo = Foo(...) + any = Any() + any.Pack(foo) + ... + if any.Is(Foo.DESCRIPTOR): + any.Unpack(foo) + ... + + Example 4: Pack and unpack a message in Go + + foo := &pb.Foo{...} + any, err := anypb.New(foo) + if err != nil { + ... + } + ... + foo := &pb.Foo{} + if err := any.UnmarshalTo(foo); err != nil { + ... + } + +The pack methods provided by protobuf library will by default use +'type.googleapis.com/full.type.name' as the type URL and the unpack +methods only use the fully qualified type name after the last '/' +in the type URL, for example "foo.bar.com/x/y.z" will yield type +name "y.z". + + +JSON +==== +The JSON representation of an `Any` value uses the regular +representation of the deserialized, embedded message, with an +additional field `@type` which contains the type URL. Example: + + package google.profile; + message Person { + string first_name = 1; + string last_name = 2; + } + + { + "@type": "type.googleapis.com/google.profile.Person", + "firstName": , + "lastName": + } + +If the embedded message type is well-known and has a custom JSON +representation, that representation will be embedded adding a field +`value` which holds the custom JSON in addition to the `@type` +field. Example (for message [google.protobuf.Duration][]): + + { + "@type": "type.googleapis.com/google.protobuf.Duration", + "value": "1.212s" + } +*/ +export interface ProtobufAny { + /** + * A URL/resource name that uniquely identifies the type of the serialized + * protocol buffer message. This string must contain at least + * one "/" character. The last segment of the URL's path must represent + * the fully qualified name of the type (as in + * `path/google.protobuf.Duration`). The name should be in a canonical form + * (e.g., leading "." is not accepted). + * + * In practice, teams usually precompile into the binary all types that they + * expect it to use in the context of Any. However, for URLs which use the + * scheme `http`, `https`, or no scheme, one can optionally set up a type + * server that maps type URLs to message definitions as follows: + * + * * If no scheme is provided, `https` is assumed. + * * An HTTP GET on the URL must yield a [google.protobuf.Type][] + * value in binary format, or produce an error. + * * Applications are allowed to cache lookup results based on the + * URL, or have them precompiled into a binary to avoid any + * lookup. Therefore, binary compatibility needs to be preserved + * on changes to types. (Use versioned type names to manage + * breaking changes.) + * + * Note: this functionality is not currently available in the official + * protobuf release, and it is not used for type URLs beginning with + * type.googleapis.com. + * + * Schemes other than `http`, `https` (or the empty scheme) might be + * used with implementation specific semantics. + */ + "@type"?: string; +} + +export interface RpcStatus { + /** @format int32 */ + code?: number; + message?: string; + details?: ProtobufAny[]; +} + +export interface TenderminttypesValidator { + /** @format byte */ + address?: string; + pub_key?: CryptoPublicKey; + + /** @format int64 */ + voting_power?: string; + + /** @format int64 */ + proposer_priority?: string; +} + +/** + * Validator is the type for the validator-set. + */ +export interface Tendermintv1Beta1Validator { + address?: string; + + /** + * `Any` contains an arbitrary serialized protocol buffer message along with a + * URL that describes the type of the serialized message. + * + * Protobuf library provides support to pack/unpack Any values in the form + * of utility functions or additional generated methods of the Any type. + * + * Example 1: Pack and unpack a message in C++. + * + * Foo foo = ...; + * Any any; + * any.PackFrom(foo); + * ... + * if (any.UnpackTo(&foo)) { + * ... + * } + * + * Example 2: Pack and unpack a message in Java. + * + * Foo foo = ...; + * Any any = Any.pack(foo); + * ... + * if (any.is(Foo.class)) { + * foo = any.unpack(Foo.class); + * } + * + * Example 3: Pack and unpack a message in Python. + * + * foo = Foo(...) + * any = Any() + * any.Pack(foo) + * ... + * if any.Is(Foo.DESCRIPTOR): + * any.Unpack(foo) + * ... + * + * Example 4: Pack and unpack a message in Go + * + * foo := &pb.Foo{...} + * any, err := anypb.New(foo) + * if err != nil { + * ... + * } + * ... + * foo := &pb.Foo{} + * if err := any.UnmarshalTo(foo); err != nil { + * ... + * } + * + * The pack methods provided by protobuf library will by default use + * 'type.googleapis.com/full.type.name' as the type URL and the unpack + * methods only use the fully qualified type name after the last '/' + * in the type URL, for example "foo.bar.com/x/y.z" will yield type + * name "y.z". + * + * + * JSON + * ==== + * The JSON representation of an `Any` value uses the regular + * representation of the deserialized, embedded message, with an + * additional field `@type` which contains the type URL. Example: + * + * package google.profile; + * message Person { + * string first_name = 1; + * string last_name = 2; + * } + * + * { + * "@type": "type.googleapis.com/google.profile.Person", + * "firstName": , + * "lastName": + * } + * + * If the embedded message type is well-known and has a custom JSON + * representation, that representation will be embedded adding a field + * `value` which holds the custom JSON in addition to the `@type` + * field. Example (for message [google.protobuf.Duration][]): + * + * { + * "@type": "type.googleapis.com/google.protobuf.Duration", + * "value": "1.212s" + * } + */ + pub_key?: ProtobufAny; + + /** @format int64 */ + voting_power?: string; + + /** @format int64 */ + proposer_priority?: string; +} + +export interface TypesBlock { + /** Header defines the structure of a block header. */ + header?: TypesHeader; + data?: TypesData; + evidence?: TypesEvidenceList; + + /** Commit contains the evidence that a block was committed by a set of validators. */ + last_commit?: TypesCommit; +} + +export interface TypesBlockID { + /** @format byte */ + hash?: string; + part_set_header?: TypesPartSetHeader; +} + +export enum TypesBlockIDFlag { + BLOCK_ID_FLAG_UNKNOWN = "BLOCK_ID_FLAG_UNKNOWN", + BLOCK_ID_FLAG_ABSENT = "BLOCK_ID_FLAG_ABSENT", + BLOCK_ID_FLAG_COMMIT = "BLOCK_ID_FLAG_COMMIT", + BLOCK_ID_FLAG_NIL = "BLOCK_ID_FLAG_NIL", +} + +/** + * Commit contains the evidence that a block was committed by a set of validators. + */ +export interface TypesCommit { + /** @format int64 */ + height?: string; + + /** @format int32 */ + round?: number; + block_id?: TypesBlockID; + signatures?: TypesCommitSig[]; +} + +/** + * CommitSig is a part of the Vote included in a Commit. + */ +export interface TypesCommitSig { + block_id_flag?: TypesBlockIDFlag; + + /** @format byte */ + validator_address?: string; + + /** @format date-time */ + timestamp?: string; + + /** @format byte */ + signature?: string; +} + +export interface TypesData { + /** + * Txs that will be applied by state @ block.Height+1. + * NOTE: not all txs here are valid. We're just agreeing on the order first. + * This means that block.AppHash does not include these txs. + */ + txs?: string[]; +} + +/** + * DuplicateVoteEvidence contains evidence of a validator signed two conflicting votes. + */ +export interface TypesDuplicateVoteEvidence { + /** + * Vote represents a prevote, precommit, or commit vote from validators for + * consensus. + */ + vote_a?: TypesVote; + + /** + * Vote represents a prevote, precommit, or commit vote from validators for + * consensus. + */ + vote_b?: TypesVote; + + /** @format int64 */ + total_voting_power?: string; + + /** @format int64 */ + validator_power?: string; + + /** @format date-time */ + timestamp?: string; +} + +export interface TypesEvidence { + /** DuplicateVoteEvidence contains evidence of a validator signed two conflicting votes. */ + duplicate_vote_evidence?: TypesDuplicateVoteEvidence; + + /** LightClientAttackEvidence contains evidence of a set of validators attempting to mislead a light client. */ + light_client_attack_evidence?: TypesLightClientAttackEvidence; +} + +export interface TypesEvidenceList { + evidence?: TypesEvidence[]; +} + +/** + * Header defines the structure of a block header. + */ +export interface TypesHeader { + /** + * Consensus captures the consensus rules for processing a block in the blockchain, + * including all blockchain data structures and the rules of the application's + * state transition machine. + */ + version?: VersionConsensus; + chain_id?: string; + + /** @format int64 */ + height?: string; + + /** @format date-time */ + time?: string; + last_block_id?: TypesBlockID; + + /** + * commit from validators from the last block + * @format byte + */ + last_commit_hash?: string; + + /** @format byte */ + data_hash?: string; + + /** + * validators for the current block + * @format byte + */ + validators_hash?: string; + + /** @format byte */ + next_validators_hash?: string; + + /** @format byte */ + consensus_hash?: string; + + /** @format byte */ + app_hash?: string; + + /** @format byte */ + last_results_hash?: string; + + /** + * evidence included in the block + * @format byte + */ + evidence_hash?: string; + + /** @format byte */ + proposer_address?: string; +} + +export interface TypesLightBlock { + signed_header?: TypesSignedHeader; + validator_set?: TypesValidatorSet; +} + +/** + * LightClientAttackEvidence contains evidence of a set of validators attempting to mislead a light client. + */ +export interface TypesLightClientAttackEvidence { + conflicting_block?: TypesLightBlock; + + /** @format int64 */ + common_height?: string; + byzantine_validators?: TenderminttypesValidator[]; + + /** @format int64 */ + total_voting_power?: string; + + /** @format date-time */ + timestamp?: string; +} + +export interface TypesPartSetHeader { + /** @format int64 */ + total?: number; + + /** @format byte */ + hash?: string; +} + +export interface TypesSignedHeader { + /** Header defines the structure of a block header. */ + header?: TypesHeader; + + /** Commit contains the evidence that a block was committed by a set of validators. */ + commit?: TypesCommit; +} + +/** +* SignedMsgType is a type of signed message in the consensus. + + - SIGNED_MSG_TYPE_PREVOTE: Votes + - SIGNED_MSG_TYPE_PROPOSAL: Proposals +*/ +export enum TypesSignedMsgType { + SIGNED_MSG_TYPE_UNKNOWN = "SIGNED_MSG_TYPE_UNKNOWN", + SIGNED_MSG_TYPE_PREVOTE = "SIGNED_MSG_TYPE_PREVOTE", + SIGNED_MSG_TYPE_PRECOMMIT = "SIGNED_MSG_TYPE_PRECOMMIT", + SIGNED_MSG_TYPE_PROPOSAL = "SIGNED_MSG_TYPE_PROPOSAL", +} + +export interface TypesValidatorSet { + validators?: TenderminttypesValidator[]; + proposer?: TenderminttypesValidator; + + /** @format int64 */ + total_voting_power?: string; +} + +/** +* Vote represents a prevote, precommit, or commit vote from validators for +consensus. +*/ +export interface TypesVote { + /** + * SignedMsgType is a type of signed message in the consensus. + * + * - SIGNED_MSG_TYPE_PREVOTE: Votes + * - SIGNED_MSG_TYPE_PROPOSAL: Proposals + */ + type?: TypesSignedMsgType; + + /** @format int64 */ + height?: string; + + /** @format int32 */ + round?: number; + + /** zero if vote is nil. */ + block_id?: TypesBlockID; + + /** @format date-time */ + timestamp?: string; + + /** @format byte */ + validator_address?: string; + + /** @format int32 */ + validator_index?: number; + + /** @format byte */ + signature?: string; +} + +/** + * GetBlockByHeightResponse is the response type for the Query/GetBlockByHeight RPC method. + */ +export interface V1Beta1GetBlockByHeightResponse { + block_id?: TypesBlockID; + block?: TypesBlock; +} + +/** + * GetLatestBlockResponse is the response type for the Query/GetLatestBlock RPC method. + */ +export interface V1Beta1GetLatestBlockResponse { + block_id?: TypesBlockID; + block?: TypesBlock; +} + +/** + * GetLatestValidatorSetResponse is the response type for the Query/GetValidatorSetByHeight RPC method. + */ +export interface V1Beta1GetLatestValidatorSetResponse { + /** @format int64 */ + block_height?: string; + validators?: Tendermintv1Beta1Validator[]; + + /** pagination defines an pagination for the response. */ + pagination?: V1Beta1PageResponse; +} + +/** + * GetNodeInfoResponse is the request type for the Query/GetNodeInfo RPC method. + */ +export interface V1Beta1GetNodeInfoResponse { + default_node_info?: P2PDefaultNodeInfo; + + /** VersionInfo is the type for the GetNodeInfoResponse message. */ + application_version?: V1Beta1VersionInfo; +} + +/** + * GetSyncingResponse is the response type for the Query/GetSyncing RPC method. + */ +export interface V1Beta1GetSyncingResponse { + syncing?: boolean; +} + +/** + * GetValidatorSetByHeightResponse is the response type for the Query/GetValidatorSetByHeight RPC method. + */ +export interface V1Beta1GetValidatorSetByHeightResponse { + /** @format int64 */ + block_height?: string; + validators?: Tendermintv1Beta1Validator[]; + + /** pagination defines an pagination for the response. */ + pagination?: V1Beta1PageResponse; +} + +export interface V1Beta1Module { + path?: string; + version?: string; + sum?: string; +} + +/** +* message SomeRequest { + Foo some_parameter = 1; + PageRequest pagination = 2; + } +*/ +export interface V1Beta1PageRequest { + /** + * key is a value returned in PageResponse.next_key to begin + * querying the next page most efficiently. Only one of offset or key + * should be set. + * @format byte + */ + key?: string; + + /** + * offset is a numeric offset that can be used when key is unavailable. + * It is less efficient than using key. Only one of offset or key should + * be set. + * @format uint64 + */ + offset?: string; + + /** + * limit is the total number of results to be returned in the result page. + * If left empty it will default to a value to be set by each app. + * @format uint64 + */ + limit?: string; + + /** + * count_total is set to true to indicate that the result set should include + * a count of the total number of items available for pagination in UIs. + * count_total is only respected when offset is used. It is ignored when key + * is set. + */ + count_total?: boolean; + + /** + * reverse is set to true if results are to be returned in the descending order. + * + * Since: cosmos-sdk 0.43 + */ + reverse?: boolean; +} + +/** +* PageResponse is to be embedded in gRPC response messages where the +corresponding request message has used PageRequest. + + message SomeResponse { + repeated Bar results = 1; + PageResponse page = 2; + } +*/ +export interface V1Beta1PageResponse { + /** @format byte */ + next_key?: string; + + /** @format uint64 */ + total?: string; +} + +/** + * VersionInfo is the type for the GetNodeInfoResponse message. + */ +export interface V1Beta1VersionInfo { + name?: string; + app_name?: string; + version?: string; + git_commit?: string; + build_tags?: string; + go_version?: string; + build_deps?: V1Beta1Module[]; + cosmos_sdk_version?: string; +} + +/** +* Consensus captures the consensus rules for processing a block in the blockchain, +including all blockchain data structures and the rules of the application's +state transition machine. +*/ +export interface VersionConsensus { + /** @format uint64 */ + block?: string; + + /** @format uint64 */ + app?: string; +} + +export type QueryParamsType = Record; +export type ResponseFormat = keyof Omit; + +export interface FullRequestParams extends Omit { + /** set parameter to `true` for call `securityWorker` for this request */ + secure?: boolean; + /** request path */ + path: string; + /** content type of request body */ + type?: ContentType; + /** query params */ + query?: QueryParamsType; + /** format of response (i.e. response.json() -> format: "json") */ + format?: keyof Omit; + /** request body */ + body?: unknown; + /** base url */ + baseUrl?: string; + /** request cancellation token */ + cancelToken?: CancelToken; +} + +export type RequestParams = Omit; + +export interface ApiConfig { + baseUrl?: string; + baseApiParams?: Omit; + securityWorker?: (securityData: SecurityDataType) => RequestParams | void; +} + +export interface HttpResponse extends Response { + data: D; + error: E; +} + +type CancelToken = Symbol | string | number; + +export enum ContentType { + Json = "application/json", + FormData = "multipart/form-data", + UrlEncoded = "application/x-www-form-urlencoded", +} + +export class HttpClient { + public baseUrl: string = ""; + private securityData: SecurityDataType = null as any; + private securityWorker: null | ApiConfig["securityWorker"] = null; + private abortControllers = new Map(); + + private baseApiParams: RequestParams = { + credentials: "same-origin", + headers: {}, + redirect: "follow", + referrerPolicy: "no-referrer", + }; + + constructor(apiConfig: ApiConfig = {}) { + Object.assign(this, apiConfig); + } + + public setSecurityData = (data: SecurityDataType) => { + this.securityData = data; + }; + + private addQueryParam(query: QueryParamsType, key: string) { + const value = query[key]; + + return ( + encodeURIComponent(key) + + "=" + + encodeURIComponent(Array.isArray(value) ? value.join(",") : typeof value === "number" ? value : `${value}`) + ); + } + + protected toQueryString(rawQuery?: QueryParamsType): string { + const query = rawQuery || {}; + const keys = Object.keys(query).filter((key) => "undefined" !== typeof query[key]); + return keys + .map((key) => + typeof query[key] === "object" && !Array.isArray(query[key]) + ? this.toQueryString(query[key] as QueryParamsType) + : this.addQueryParam(query, key), + ) + .join("&"); + } + + protected addQueryParams(rawQuery?: QueryParamsType): string { + const queryString = this.toQueryString(rawQuery); + return queryString ? `?${queryString}` : ""; + } + + private contentFormatters: Record any> = { + [ContentType.Json]: (input: any) => + input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input, + [ContentType.FormData]: (input: any) => + Object.keys(input || {}).reduce((data, key) => { + data.append(key, input[key]); + return data; + }, new FormData()), + [ContentType.UrlEncoded]: (input: any) => this.toQueryString(input), + }; + + private mergeRequestParams(params1: RequestParams, params2?: RequestParams): RequestParams { + return { + ...this.baseApiParams, + ...params1, + ...(params2 || {}), + headers: { + ...(this.baseApiParams.headers || {}), + ...(params1.headers || {}), + ...((params2 && params2.headers) || {}), + }, + }; + } + + private createAbortSignal = (cancelToken: CancelToken): AbortSignal | undefined => { + if (this.abortControllers.has(cancelToken)) { + const abortController = this.abortControllers.get(cancelToken); + if (abortController) { + return abortController.signal; + } + return void 0; + } + + const abortController = new AbortController(); + this.abortControllers.set(cancelToken, abortController); + return abortController.signal; + }; + + public abortRequest = (cancelToken: CancelToken) => { + const abortController = this.abortControllers.get(cancelToken); + + if (abortController) { + abortController.abort(); + this.abortControllers.delete(cancelToken); + } + }; + + public request = ({ + body, + secure, + path, + type, + query, + format = "json", + baseUrl, + cancelToken, + ...params + }: FullRequestParams): Promise> => { + const secureParams = (secure && this.securityWorker && this.securityWorker(this.securityData)) || {}; + const requestParams = this.mergeRequestParams(params, secureParams); + const queryString = query && this.toQueryString(query); + const payloadFormatter = this.contentFormatters[type || ContentType.Json]; + + return fetch(`${baseUrl || this.baseUrl || ""}${path}${queryString ? `?${queryString}` : ""}`, { + ...requestParams, + headers: { + ...(type && type !== ContentType.FormData ? { "Content-Type": type } : {}), + ...(requestParams.headers || {}), + }, + signal: cancelToken ? this.createAbortSignal(cancelToken) : void 0, + body: typeof body === "undefined" || body === null ? null : payloadFormatter(body), + }).then(async (response) => { + const r = response as HttpResponse; + r.data = (null as unknown) as T; + r.error = (null as unknown) as E; + + const data = await response[format]() + .then((data) => { + if (r.ok) { + r.data = data; + } else { + r.error = data; + } + return r; + }) + .catch((e) => { + r.error = e; + return r; + }); + + if (cancelToken) { + this.abortControllers.delete(cancelToken); + } + + if (!response.ok) throw data; + return data; + }); + }; +} + +/** + * @title cosmos/base/tendermint/v1beta1/query.proto + * @version version not set + */ +export class Api extends HttpClient { + /** + * No description + * + * @tags Service + * @name ServiceGetLatestBlock + * @summary GetLatestBlock returns the latest block. + * @request GET:/cosmos/base/tendermint/v1beta1/blocks/latest + */ + serviceGetLatestBlock = (params: RequestParams = {}) => + this.request({ + path: `/cosmos/base/tendermint/v1beta1/blocks/latest`, + method: "GET", + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Service + * @name ServiceGetBlockByHeight + * @summary GetBlockByHeight queries block for given height. + * @request GET:/cosmos/base/tendermint/v1beta1/blocks/{height} + */ + serviceGetBlockByHeight = (height: string, params: RequestParams = {}) => + this.request({ + path: `/cosmos/base/tendermint/v1beta1/blocks/${height}`, + method: "GET", + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Service + * @name ServiceGetNodeInfo + * @summary GetNodeInfo queries the current node info. + * @request GET:/cosmos/base/tendermint/v1beta1/node_info + */ + serviceGetNodeInfo = (params: RequestParams = {}) => + this.request({ + path: `/cosmos/base/tendermint/v1beta1/node_info`, + method: "GET", + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Service + * @name ServiceGetSyncing + * @summary GetSyncing queries node syncing. + * @request GET:/cosmos/base/tendermint/v1beta1/syncing + */ + serviceGetSyncing = (params: RequestParams = {}) => + this.request({ + path: `/cosmos/base/tendermint/v1beta1/syncing`, + method: "GET", + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Service + * @name ServiceGetLatestValidatorSet + * @summary GetLatestValidatorSet queries latest validator-set. + * @request GET:/cosmos/base/tendermint/v1beta1/validatorsets/latest + */ + serviceGetLatestValidatorSet = ( + query?: { + "pagination.key"?: string; + "pagination.offset"?: string; + "pagination.limit"?: string; + "pagination.count_total"?: boolean; + "pagination.reverse"?: boolean; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/cosmos/base/tendermint/v1beta1/validatorsets/latest`, + method: "GET", + query: query, + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Service + * @name ServiceGetValidatorSetByHeight + * @summary GetValidatorSetByHeight queries validator-set at a given height. + * @request GET:/cosmos/base/tendermint/v1beta1/validatorsets/{height} + */ + serviceGetValidatorSetByHeight = ( + height: string, + query?: { + "pagination.key"?: string; + "pagination.offset"?: string; + "pagination.limit"?: string; + "pagination.count_total"?: boolean; + "pagination.reverse"?: boolean; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/cosmos/base/tendermint/v1beta1/validatorsets/${height}`, + method: "GET", + query: query, + format: "json", + ...params, + }); +} diff --git a/ts-client/cosmos.base.tendermint.v1beta1/types.ts b/ts-client/cosmos.base.tendermint.v1beta1/types.ts new file mode 100755 index 00000000..1f779b8a --- /dev/null +++ b/ts-client/cosmos.base.tendermint.v1beta1/types.ts @@ -0,0 +1,11 @@ +import { Validator } from "./types/cosmos/base/tendermint/v1beta1/query" +import { VersionInfo } from "./types/cosmos/base/tendermint/v1beta1/query" +import { Module } from "./types/cosmos/base/tendermint/v1beta1/query" + + +export { + Validator, + VersionInfo, + Module, + + } \ No newline at end of file diff --git a/ts-client/cosmos.base.tendermint.v1beta1/types/cosmos/base/query/v1beta1/pagination.ts b/ts-client/cosmos.base.tendermint.v1beta1/types/cosmos/base/query/v1beta1/pagination.ts new file mode 100644 index 00000000..cd4b2d78 --- /dev/null +++ b/ts-client/cosmos.base.tendermint.v1beta1/types/cosmos/base/query/v1beta1/pagination.ts @@ -0,0 +1,327 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "cosmos.base.query.v1beta1"; + +/** + * PageRequest is to be embedded in gRPC request messages for efficient + * pagination. Ex: + * + * message SomeRequest { + * Foo some_parameter = 1; + * PageRequest pagination = 2; + * } + */ +export interface PageRequest { + /** + * key is a value returned in PageResponse.next_key to begin + * querying the next page most efficiently. Only one of offset or key + * should be set. + */ + key: Uint8Array; + /** + * offset is a numeric offset that can be used when key is unavailable. + * It is less efficient than using key. Only one of offset or key should + * be set. + */ + offset: number; + /** + * limit is the total number of results to be returned in the result page. + * If left empty it will default to a value to be set by each app. + */ + limit: number; + /** + * count_total is set to true to indicate that the result set should include + * a count of the total number of items available for pagination in UIs. + * count_total is only respected when offset is used. It is ignored when key + * is set. + */ + countTotal: boolean; + /** + * reverse is set to true if results are to be returned in the descending order. + * + * Since: cosmos-sdk 0.43 + */ + reverse: boolean; +} + +/** + * PageResponse is to be embedded in gRPC response messages where the + * corresponding request message has used PageRequest. + * + * message SomeResponse { + * repeated Bar results = 1; + * PageResponse page = 2; + * } + */ +export interface PageResponse { + /** + * next_key is the key to be passed to PageRequest.key to + * query the next page most efficiently + */ + nextKey: Uint8Array; + /** + * total is total number of results available if PageRequest.count_total + * was set, its value is undefined otherwise + */ + total: number; +} + +const basePageRequest: object = { + offset: 0, + limit: 0, + countTotal: false, + reverse: false, +}; + +export const PageRequest = { + encode(message: PageRequest, writer: Writer = Writer.create()): Writer { + if (message.key.length !== 0) { + writer.uint32(10).bytes(message.key); + } + if (message.offset !== 0) { + writer.uint32(16).uint64(message.offset); + } + if (message.limit !== 0) { + writer.uint32(24).uint64(message.limit); + } + if (message.countTotal === true) { + writer.uint32(32).bool(message.countTotal); + } + if (message.reverse === true) { + writer.uint32(40).bool(message.reverse); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): PageRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...basePageRequest } as PageRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.key = reader.bytes(); + break; + case 2: + message.offset = longToNumber(reader.uint64() as Long); + break; + case 3: + message.limit = longToNumber(reader.uint64() as Long); + break; + case 4: + message.countTotal = reader.bool(); + break; + case 5: + message.reverse = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): PageRequest { + const message = { ...basePageRequest } as PageRequest; + if (object.key !== undefined && object.key !== null) { + message.key = bytesFromBase64(object.key); + } + if (object.offset !== undefined && object.offset !== null) { + message.offset = Number(object.offset); + } else { + message.offset = 0; + } + if (object.limit !== undefined && object.limit !== null) { + message.limit = Number(object.limit); + } else { + message.limit = 0; + } + if (object.countTotal !== undefined && object.countTotal !== null) { + message.countTotal = Boolean(object.countTotal); + } else { + message.countTotal = false; + } + if (object.reverse !== undefined && object.reverse !== null) { + message.reverse = Boolean(object.reverse); + } else { + message.reverse = false; + } + return message; + }, + + toJSON(message: PageRequest): unknown { + const obj: any = {}; + message.key !== undefined && + (obj.key = base64FromBytes( + message.key !== undefined ? message.key : new Uint8Array() + )); + message.offset !== undefined && (obj.offset = message.offset); + message.limit !== undefined && (obj.limit = message.limit); + message.countTotal !== undefined && (obj.countTotal = message.countTotal); + message.reverse !== undefined && (obj.reverse = message.reverse); + return obj; + }, + + fromPartial(object: DeepPartial): PageRequest { + const message = { ...basePageRequest } as PageRequest; + if (object.key !== undefined && object.key !== null) { + message.key = object.key; + } else { + message.key = new Uint8Array(); + } + if (object.offset !== undefined && object.offset !== null) { + message.offset = object.offset; + } else { + message.offset = 0; + } + if (object.limit !== undefined && object.limit !== null) { + message.limit = object.limit; + } else { + message.limit = 0; + } + if (object.countTotal !== undefined && object.countTotal !== null) { + message.countTotal = object.countTotal; + } else { + message.countTotal = false; + } + if (object.reverse !== undefined && object.reverse !== null) { + message.reverse = object.reverse; + } else { + message.reverse = false; + } + return message; + }, +}; + +const basePageResponse: object = { total: 0 }; + +export const PageResponse = { + encode(message: PageResponse, writer: Writer = Writer.create()): Writer { + if (message.nextKey.length !== 0) { + writer.uint32(10).bytes(message.nextKey); + } + if (message.total !== 0) { + writer.uint32(16).uint64(message.total); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): PageResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...basePageResponse } as PageResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.nextKey = reader.bytes(); + break; + case 2: + message.total = longToNumber(reader.uint64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): PageResponse { + const message = { ...basePageResponse } as PageResponse; + if (object.nextKey !== undefined && object.nextKey !== null) { + message.nextKey = bytesFromBase64(object.nextKey); + } + if (object.total !== undefined && object.total !== null) { + message.total = Number(object.total); + } else { + message.total = 0; + } + return message; + }, + + toJSON(message: PageResponse): unknown { + const obj: any = {}; + message.nextKey !== undefined && + (obj.nextKey = base64FromBytes( + message.nextKey !== undefined ? message.nextKey : new Uint8Array() + )); + message.total !== undefined && (obj.total = message.total); + return obj; + }, + + fromPartial(object: DeepPartial): PageResponse { + const message = { ...basePageResponse } as PageResponse; + if (object.nextKey !== undefined && object.nextKey !== null) { + message.nextKey = object.nextKey; + } else { + message.nextKey = new Uint8Array(); + } + if (object.total !== undefined && object.total !== null) { + message.total = object.total; + } else { + message.total = 0; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/cosmos.base.tendermint.v1beta1/types/cosmos/base/tendermint/v1beta1/query.ts b/ts-client/cosmos.base.tendermint.v1beta1/types/cosmos/base/tendermint/v1beta1/query.ts new file mode 100644 index 00000000..7a39f519 --- /dev/null +++ b/ts-client/cosmos.base.tendermint.v1beta1/types/cosmos/base/tendermint/v1beta1/query.ts @@ -0,0 +1,1584 @@ +/* eslint-disable */ +import { Reader, util, configure, Writer } from "protobufjs/minimal"; +import * as Long from "long"; +import { + PageRequest, + PageResponse, +} from "../../../../cosmos/base/query/v1beta1/pagination"; +import { Any } from "../../../../google/protobuf/any"; +import { BlockID } from "../../../../tendermint/types/types"; +import { Block } from "../../../../tendermint/types/block"; +import { DefaultNodeInfo } from "../../../../tendermint/p2p/types"; + +export const protobufPackage = "cosmos.base.tendermint.v1beta1"; + +/** GetValidatorSetByHeightRequest is the request type for the Query/GetValidatorSetByHeight RPC method. */ +export interface GetValidatorSetByHeightRequest { + height: number; + /** pagination defines an pagination for the request. */ + pagination: PageRequest | undefined; +} + +/** GetValidatorSetByHeightResponse is the response type for the Query/GetValidatorSetByHeight RPC method. */ +export interface GetValidatorSetByHeightResponse { + blockHeight: number; + validators: Validator[]; + /** pagination defines an pagination for the response. */ + pagination: PageResponse | undefined; +} + +/** GetLatestValidatorSetRequest is the request type for the Query/GetValidatorSetByHeight RPC method. */ +export interface GetLatestValidatorSetRequest { + /** pagination defines an pagination for the request. */ + pagination: PageRequest | undefined; +} + +/** GetLatestValidatorSetResponse is the response type for the Query/GetValidatorSetByHeight RPC method. */ +export interface GetLatestValidatorSetResponse { + blockHeight: number; + validators: Validator[]; + /** pagination defines an pagination for the response. */ + pagination: PageResponse | undefined; +} + +/** Validator is the type for the validator-set. */ +export interface Validator { + address: string; + pubKey: Any | undefined; + votingPower: number; + proposerPriority: number; +} + +/** GetBlockByHeightRequest is the request type for the Query/GetBlockByHeight RPC method. */ +export interface GetBlockByHeightRequest { + height: number; +} + +/** GetBlockByHeightResponse is the response type for the Query/GetBlockByHeight RPC method. */ +export interface GetBlockByHeightResponse { + blockId: BlockID | undefined; + block: Block | undefined; +} + +/** GetLatestBlockRequest is the request type for the Query/GetLatestBlock RPC method. */ +export interface GetLatestBlockRequest {} + +/** GetLatestBlockResponse is the response type for the Query/GetLatestBlock RPC method. */ +export interface GetLatestBlockResponse { + blockId: BlockID | undefined; + block: Block | undefined; +} + +/** GetSyncingRequest is the request type for the Query/GetSyncing RPC method. */ +export interface GetSyncingRequest {} + +/** GetSyncingResponse is the response type for the Query/GetSyncing RPC method. */ +export interface GetSyncingResponse { + syncing: boolean; +} + +/** GetNodeInfoRequest is the request type for the Query/GetNodeInfo RPC method. */ +export interface GetNodeInfoRequest {} + +/** GetNodeInfoResponse is the request type for the Query/GetNodeInfo RPC method. */ +export interface GetNodeInfoResponse { + defaultNodeInfo: DefaultNodeInfo | undefined; + applicationVersion: VersionInfo | undefined; +} + +/** VersionInfo is the type for the GetNodeInfoResponse message. */ +export interface VersionInfo { + name: string; + appName: string; + version: string; + gitCommit: string; + buildTags: string; + goVersion: string; + buildDeps: Module[]; + /** Since: cosmos-sdk 0.43 */ + cosmosSdkVersion: string; +} + +/** Module is the type for VersionInfo */ +export interface Module { + /** module path */ + path: string; + /** module version */ + version: string; + /** checksum */ + sum: string; +} + +const baseGetValidatorSetByHeightRequest: object = { height: 0 }; + +export const GetValidatorSetByHeightRequest = { + encode( + message: GetValidatorSetByHeightRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.height !== 0) { + writer.uint32(8).int64(message.height); + } + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): GetValidatorSetByHeightRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseGetValidatorSetByHeightRequest, + } as GetValidatorSetByHeightRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.height = longToNumber(reader.int64() as Long); + break; + case 2: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GetValidatorSetByHeightRequest { + const message = { + ...baseGetValidatorSetByHeightRequest, + } as GetValidatorSetByHeightRequest; + if (object.height !== undefined && object.height !== null) { + message.height = Number(object.height); + } else { + message.height = 0; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: GetValidatorSetByHeightRequest): unknown { + const obj: any = {}; + message.height !== undefined && (obj.height = message.height); + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageRequest.toJSON(message.pagination) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): GetValidatorSetByHeightRequest { + const message = { + ...baseGetValidatorSetByHeightRequest, + } as GetValidatorSetByHeightRequest; + if (object.height !== undefined && object.height !== null) { + message.height = object.height; + } else { + message.height = 0; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseGetValidatorSetByHeightResponse: object = { blockHeight: 0 }; + +export const GetValidatorSetByHeightResponse = { + encode( + message: GetValidatorSetByHeightResponse, + writer: Writer = Writer.create() + ): Writer { + if (message.blockHeight !== 0) { + writer.uint32(8).int64(message.blockHeight); + } + for (const v of message.validators) { + Validator.encode(v!, writer.uint32(18).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode( + message.pagination, + writer.uint32(26).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): GetValidatorSetByHeightResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseGetValidatorSetByHeightResponse, + } as GetValidatorSetByHeightResponse; + message.validators = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.blockHeight = longToNumber(reader.int64() as Long); + break; + case 2: + message.validators.push(Validator.decode(reader, reader.uint32())); + break; + case 3: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GetValidatorSetByHeightResponse { + const message = { + ...baseGetValidatorSetByHeightResponse, + } as GetValidatorSetByHeightResponse; + message.validators = []; + if (object.blockHeight !== undefined && object.blockHeight !== null) { + message.blockHeight = Number(object.blockHeight); + } else { + message.blockHeight = 0; + } + if (object.validators !== undefined && object.validators !== null) { + for (const e of object.validators) { + message.validators.push(Validator.fromJSON(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: GetValidatorSetByHeightResponse): unknown { + const obj: any = {}; + message.blockHeight !== undefined && + (obj.blockHeight = message.blockHeight); + if (message.validators) { + obj.validators = message.validators.map((e) => + e ? Validator.toJSON(e) : undefined + ); + } else { + obj.validators = []; + } + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageResponse.toJSON(message.pagination) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): GetValidatorSetByHeightResponse { + const message = { + ...baseGetValidatorSetByHeightResponse, + } as GetValidatorSetByHeightResponse; + message.validators = []; + if (object.blockHeight !== undefined && object.blockHeight !== null) { + message.blockHeight = object.blockHeight; + } else { + message.blockHeight = 0; + } + if (object.validators !== undefined && object.validators !== null) { + for (const e of object.validators) { + message.validators.push(Validator.fromPartial(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseGetLatestValidatorSetRequest: object = {}; + +export const GetLatestValidatorSetRequest = { + encode( + message: GetLatestValidatorSetRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): GetLatestValidatorSetRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseGetLatestValidatorSetRequest, + } as GetLatestValidatorSetRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GetLatestValidatorSetRequest { + const message = { + ...baseGetLatestValidatorSetRequest, + } as GetLatestValidatorSetRequest; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: GetLatestValidatorSetRequest): unknown { + const obj: any = {}; + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageRequest.toJSON(message.pagination) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): GetLatestValidatorSetRequest { + const message = { + ...baseGetLatestValidatorSetRequest, + } as GetLatestValidatorSetRequest; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseGetLatestValidatorSetResponse: object = { blockHeight: 0 }; + +export const GetLatestValidatorSetResponse = { + encode( + message: GetLatestValidatorSetResponse, + writer: Writer = Writer.create() + ): Writer { + if (message.blockHeight !== 0) { + writer.uint32(8).int64(message.blockHeight); + } + for (const v of message.validators) { + Validator.encode(v!, writer.uint32(18).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode( + message.pagination, + writer.uint32(26).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): GetLatestValidatorSetResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseGetLatestValidatorSetResponse, + } as GetLatestValidatorSetResponse; + message.validators = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.blockHeight = longToNumber(reader.int64() as Long); + break; + case 2: + message.validators.push(Validator.decode(reader, reader.uint32())); + break; + case 3: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GetLatestValidatorSetResponse { + const message = { + ...baseGetLatestValidatorSetResponse, + } as GetLatestValidatorSetResponse; + message.validators = []; + if (object.blockHeight !== undefined && object.blockHeight !== null) { + message.blockHeight = Number(object.blockHeight); + } else { + message.blockHeight = 0; + } + if (object.validators !== undefined && object.validators !== null) { + for (const e of object.validators) { + message.validators.push(Validator.fromJSON(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: GetLatestValidatorSetResponse): unknown { + const obj: any = {}; + message.blockHeight !== undefined && + (obj.blockHeight = message.blockHeight); + if (message.validators) { + obj.validators = message.validators.map((e) => + e ? Validator.toJSON(e) : undefined + ); + } else { + obj.validators = []; + } + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageResponse.toJSON(message.pagination) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): GetLatestValidatorSetResponse { + const message = { + ...baseGetLatestValidatorSetResponse, + } as GetLatestValidatorSetResponse; + message.validators = []; + if (object.blockHeight !== undefined && object.blockHeight !== null) { + message.blockHeight = object.blockHeight; + } else { + message.blockHeight = 0; + } + if (object.validators !== undefined && object.validators !== null) { + for (const e of object.validators) { + message.validators.push(Validator.fromPartial(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseValidator: object = { + address: "", + votingPower: 0, + proposerPriority: 0, +}; + +export const Validator = { + encode(message: Validator, writer: Writer = Writer.create()): Writer { + if (message.address !== "") { + writer.uint32(10).string(message.address); + } + if (message.pubKey !== undefined) { + Any.encode(message.pubKey, writer.uint32(18).fork()).ldelim(); + } + if (message.votingPower !== 0) { + writer.uint32(24).int64(message.votingPower); + } + if (message.proposerPriority !== 0) { + writer.uint32(32).int64(message.proposerPriority); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Validator { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseValidator } as Validator; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.address = reader.string(); + break; + case 2: + message.pubKey = Any.decode(reader, reader.uint32()); + break; + case 3: + message.votingPower = longToNumber(reader.int64() as Long); + break; + case 4: + message.proposerPriority = longToNumber(reader.int64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Validator { + const message = { ...baseValidator } as Validator; + if (object.address !== undefined && object.address !== null) { + message.address = String(object.address); + } else { + message.address = ""; + } + if (object.pubKey !== undefined && object.pubKey !== null) { + message.pubKey = Any.fromJSON(object.pubKey); + } else { + message.pubKey = undefined; + } + if (object.votingPower !== undefined && object.votingPower !== null) { + message.votingPower = Number(object.votingPower); + } else { + message.votingPower = 0; + } + if ( + object.proposerPriority !== undefined && + object.proposerPriority !== null + ) { + message.proposerPriority = Number(object.proposerPriority); + } else { + message.proposerPriority = 0; + } + return message; + }, + + toJSON(message: Validator): unknown { + const obj: any = {}; + message.address !== undefined && (obj.address = message.address); + message.pubKey !== undefined && + (obj.pubKey = message.pubKey ? Any.toJSON(message.pubKey) : undefined); + message.votingPower !== undefined && + (obj.votingPower = message.votingPower); + message.proposerPriority !== undefined && + (obj.proposerPriority = message.proposerPriority); + return obj; + }, + + fromPartial(object: DeepPartial): Validator { + const message = { ...baseValidator } as Validator; + if (object.address !== undefined && object.address !== null) { + message.address = object.address; + } else { + message.address = ""; + } + if (object.pubKey !== undefined && object.pubKey !== null) { + message.pubKey = Any.fromPartial(object.pubKey); + } else { + message.pubKey = undefined; + } + if (object.votingPower !== undefined && object.votingPower !== null) { + message.votingPower = object.votingPower; + } else { + message.votingPower = 0; + } + if ( + object.proposerPriority !== undefined && + object.proposerPriority !== null + ) { + message.proposerPriority = object.proposerPriority; + } else { + message.proposerPriority = 0; + } + return message; + }, +}; + +const baseGetBlockByHeightRequest: object = { height: 0 }; + +export const GetBlockByHeightRequest = { + encode( + message: GetBlockByHeightRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.height !== 0) { + writer.uint32(8).int64(message.height); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): GetBlockByHeightRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseGetBlockByHeightRequest, + } as GetBlockByHeightRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.height = longToNumber(reader.int64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GetBlockByHeightRequest { + const message = { + ...baseGetBlockByHeightRequest, + } as GetBlockByHeightRequest; + if (object.height !== undefined && object.height !== null) { + message.height = Number(object.height); + } else { + message.height = 0; + } + return message; + }, + + toJSON(message: GetBlockByHeightRequest): unknown { + const obj: any = {}; + message.height !== undefined && (obj.height = message.height); + return obj; + }, + + fromPartial( + object: DeepPartial + ): GetBlockByHeightRequest { + const message = { + ...baseGetBlockByHeightRequest, + } as GetBlockByHeightRequest; + if (object.height !== undefined && object.height !== null) { + message.height = object.height; + } else { + message.height = 0; + } + return message; + }, +}; + +const baseGetBlockByHeightResponse: object = {}; + +export const GetBlockByHeightResponse = { + encode( + message: GetBlockByHeightResponse, + writer: Writer = Writer.create() + ): Writer { + if (message.blockId !== undefined) { + BlockID.encode(message.blockId, writer.uint32(10).fork()).ldelim(); + } + if (message.block !== undefined) { + Block.encode(message.block, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): GetBlockByHeightResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseGetBlockByHeightResponse, + } as GetBlockByHeightResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.blockId = BlockID.decode(reader, reader.uint32()); + break; + case 2: + message.block = Block.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GetBlockByHeightResponse { + const message = { + ...baseGetBlockByHeightResponse, + } as GetBlockByHeightResponse; + if (object.blockId !== undefined && object.blockId !== null) { + message.blockId = BlockID.fromJSON(object.blockId); + } else { + message.blockId = undefined; + } + if (object.block !== undefined && object.block !== null) { + message.block = Block.fromJSON(object.block); + } else { + message.block = undefined; + } + return message; + }, + + toJSON(message: GetBlockByHeightResponse): unknown { + const obj: any = {}; + message.blockId !== undefined && + (obj.blockId = message.blockId + ? BlockID.toJSON(message.blockId) + : undefined); + message.block !== undefined && + (obj.block = message.block ? Block.toJSON(message.block) : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): GetBlockByHeightResponse { + const message = { + ...baseGetBlockByHeightResponse, + } as GetBlockByHeightResponse; + if (object.blockId !== undefined && object.blockId !== null) { + message.blockId = BlockID.fromPartial(object.blockId); + } else { + message.blockId = undefined; + } + if (object.block !== undefined && object.block !== null) { + message.block = Block.fromPartial(object.block); + } else { + message.block = undefined; + } + return message; + }, +}; + +const baseGetLatestBlockRequest: object = {}; + +export const GetLatestBlockRequest = { + encode(_: GetLatestBlockRequest, writer: Writer = Writer.create()): Writer { + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): GetLatestBlockRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseGetLatestBlockRequest } as GetLatestBlockRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): GetLatestBlockRequest { + const message = { ...baseGetLatestBlockRequest } as GetLatestBlockRequest; + return message; + }, + + toJSON(_: GetLatestBlockRequest): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial(_: DeepPartial): GetLatestBlockRequest { + const message = { ...baseGetLatestBlockRequest } as GetLatestBlockRequest; + return message; + }, +}; + +const baseGetLatestBlockResponse: object = {}; + +export const GetLatestBlockResponse = { + encode( + message: GetLatestBlockResponse, + writer: Writer = Writer.create() + ): Writer { + if (message.blockId !== undefined) { + BlockID.encode(message.blockId, writer.uint32(10).fork()).ldelim(); + } + if (message.block !== undefined) { + Block.encode(message.block, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): GetLatestBlockResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseGetLatestBlockResponse } as GetLatestBlockResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.blockId = BlockID.decode(reader, reader.uint32()); + break; + case 2: + message.block = Block.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GetLatestBlockResponse { + const message = { ...baseGetLatestBlockResponse } as GetLatestBlockResponse; + if (object.blockId !== undefined && object.blockId !== null) { + message.blockId = BlockID.fromJSON(object.blockId); + } else { + message.blockId = undefined; + } + if (object.block !== undefined && object.block !== null) { + message.block = Block.fromJSON(object.block); + } else { + message.block = undefined; + } + return message; + }, + + toJSON(message: GetLatestBlockResponse): unknown { + const obj: any = {}; + message.blockId !== undefined && + (obj.blockId = message.blockId + ? BlockID.toJSON(message.blockId) + : undefined); + message.block !== undefined && + (obj.block = message.block ? Block.toJSON(message.block) : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): GetLatestBlockResponse { + const message = { ...baseGetLatestBlockResponse } as GetLatestBlockResponse; + if (object.blockId !== undefined && object.blockId !== null) { + message.blockId = BlockID.fromPartial(object.blockId); + } else { + message.blockId = undefined; + } + if (object.block !== undefined && object.block !== null) { + message.block = Block.fromPartial(object.block); + } else { + message.block = undefined; + } + return message; + }, +}; + +const baseGetSyncingRequest: object = {}; + +export const GetSyncingRequest = { + encode(_: GetSyncingRequest, writer: Writer = Writer.create()): Writer { + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): GetSyncingRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseGetSyncingRequest } as GetSyncingRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): GetSyncingRequest { + const message = { ...baseGetSyncingRequest } as GetSyncingRequest; + return message; + }, + + toJSON(_: GetSyncingRequest): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial(_: DeepPartial): GetSyncingRequest { + const message = { ...baseGetSyncingRequest } as GetSyncingRequest; + return message; + }, +}; + +const baseGetSyncingResponse: object = { syncing: false }; + +export const GetSyncingResponse = { + encode( + message: GetSyncingResponse, + writer: Writer = Writer.create() + ): Writer { + if (message.syncing === true) { + writer.uint32(8).bool(message.syncing); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): GetSyncingResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseGetSyncingResponse } as GetSyncingResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.syncing = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GetSyncingResponse { + const message = { ...baseGetSyncingResponse } as GetSyncingResponse; + if (object.syncing !== undefined && object.syncing !== null) { + message.syncing = Boolean(object.syncing); + } else { + message.syncing = false; + } + return message; + }, + + toJSON(message: GetSyncingResponse): unknown { + const obj: any = {}; + message.syncing !== undefined && (obj.syncing = message.syncing); + return obj; + }, + + fromPartial(object: DeepPartial): GetSyncingResponse { + const message = { ...baseGetSyncingResponse } as GetSyncingResponse; + if (object.syncing !== undefined && object.syncing !== null) { + message.syncing = object.syncing; + } else { + message.syncing = false; + } + return message; + }, +}; + +const baseGetNodeInfoRequest: object = {}; + +export const GetNodeInfoRequest = { + encode(_: GetNodeInfoRequest, writer: Writer = Writer.create()): Writer { + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): GetNodeInfoRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseGetNodeInfoRequest } as GetNodeInfoRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): GetNodeInfoRequest { + const message = { ...baseGetNodeInfoRequest } as GetNodeInfoRequest; + return message; + }, + + toJSON(_: GetNodeInfoRequest): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial(_: DeepPartial): GetNodeInfoRequest { + const message = { ...baseGetNodeInfoRequest } as GetNodeInfoRequest; + return message; + }, +}; + +const baseGetNodeInfoResponse: object = {}; + +export const GetNodeInfoResponse = { + encode( + message: GetNodeInfoResponse, + writer: Writer = Writer.create() + ): Writer { + if (message.defaultNodeInfo !== undefined) { + DefaultNodeInfo.encode( + message.defaultNodeInfo, + writer.uint32(10).fork() + ).ldelim(); + } + if (message.applicationVersion !== undefined) { + VersionInfo.encode( + message.applicationVersion, + writer.uint32(18).fork() + ).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): GetNodeInfoResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseGetNodeInfoResponse } as GetNodeInfoResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.defaultNodeInfo = DefaultNodeInfo.decode( + reader, + reader.uint32() + ); + break; + case 2: + message.applicationVersion = VersionInfo.decode( + reader, + reader.uint32() + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GetNodeInfoResponse { + const message = { ...baseGetNodeInfoResponse } as GetNodeInfoResponse; + if ( + object.defaultNodeInfo !== undefined && + object.defaultNodeInfo !== null + ) { + message.defaultNodeInfo = DefaultNodeInfo.fromJSON( + object.defaultNodeInfo + ); + } else { + message.defaultNodeInfo = undefined; + } + if ( + object.applicationVersion !== undefined && + object.applicationVersion !== null + ) { + message.applicationVersion = VersionInfo.fromJSON( + object.applicationVersion + ); + } else { + message.applicationVersion = undefined; + } + return message; + }, + + toJSON(message: GetNodeInfoResponse): unknown { + const obj: any = {}; + message.defaultNodeInfo !== undefined && + (obj.defaultNodeInfo = message.defaultNodeInfo + ? DefaultNodeInfo.toJSON(message.defaultNodeInfo) + : undefined); + message.applicationVersion !== undefined && + (obj.applicationVersion = message.applicationVersion + ? VersionInfo.toJSON(message.applicationVersion) + : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): GetNodeInfoResponse { + const message = { ...baseGetNodeInfoResponse } as GetNodeInfoResponse; + if ( + object.defaultNodeInfo !== undefined && + object.defaultNodeInfo !== null + ) { + message.defaultNodeInfo = DefaultNodeInfo.fromPartial( + object.defaultNodeInfo + ); + } else { + message.defaultNodeInfo = undefined; + } + if ( + object.applicationVersion !== undefined && + object.applicationVersion !== null + ) { + message.applicationVersion = VersionInfo.fromPartial( + object.applicationVersion + ); + } else { + message.applicationVersion = undefined; + } + return message; + }, +}; + +const baseVersionInfo: object = { + name: "", + appName: "", + version: "", + gitCommit: "", + buildTags: "", + goVersion: "", + cosmosSdkVersion: "", +}; + +export const VersionInfo = { + encode(message: VersionInfo, writer: Writer = Writer.create()): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.appName !== "") { + writer.uint32(18).string(message.appName); + } + if (message.version !== "") { + writer.uint32(26).string(message.version); + } + if (message.gitCommit !== "") { + writer.uint32(34).string(message.gitCommit); + } + if (message.buildTags !== "") { + writer.uint32(42).string(message.buildTags); + } + if (message.goVersion !== "") { + writer.uint32(50).string(message.goVersion); + } + for (const v of message.buildDeps) { + Module.encode(v!, writer.uint32(58).fork()).ldelim(); + } + if (message.cosmosSdkVersion !== "") { + writer.uint32(66).string(message.cosmosSdkVersion); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): VersionInfo { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseVersionInfo } as VersionInfo; + message.buildDeps = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.appName = reader.string(); + break; + case 3: + message.version = reader.string(); + break; + case 4: + message.gitCommit = reader.string(); + break; + case 5: + message.buildTags = reader.string(); + break; + case 6: + message.goVersion = reader.string(); + break; + case 7: + message.buildDeps.push(Module.decode(reader, reader.uint32())); + break; + case 8: + message.cosmosSdkVersion = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): VersionInfo { + const message = { ...baseVersionInfo } as VersionInfo; + message.buildDeps = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.appName !== undefined && object.appName !== null) { + message.appName = String(object.appName); + } else { + message.appName = ""; + } + if (object.version !== undefined && object.version !== null) { + message.version = String(object.version); + } else { + message.version = ""; + } + if (object.gitCommit !== undefined && object.gitCommit !== null) { + message.gitCommit = String(object.gitCommit); + } else { + message.gitCommit = ""; + } + if (object.buildTags !== undefined && object.buildTags !== null) { + message.buildTags = String(object.buildTags); + } else { + message.buildTags = ""; + } + if (object.goVersion !== undefined && object.goVersion !== null) { + message.goVersion = String(object.goVersion); + } else { + message.goVersion = ""; + } + if (object.buildDeps !== undefined && object.buildDeps !== null) { + for (const e of object.buildDeps) { + message.buildDeps.push(Module.fromJSON(e)); + } + } + if ( + object.cosmosSdkVersion !== undefined && + object.cosmosSdkVersion !== null + ) { + message.cosmosSdkVersion = String(object.cosmosSdkVersion); + } else { + message.cosmosSdkVersion = ""; + } + return message; + }, + + toJSON(message: VersionInfo): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.appName !== undefined && (obj.appName = message.appName); + message.version !== undefined && (obj.version = message.version); + message.gitCommit !== undefined && (obj.gitCommit = message.gitCommit); + message.buildTags !== undefined && (obj.buildTags = message.buildTags); + message.goVersion !== undefined && (obj.goVersion = message.goVersion); + if (message.buildDeps) { + obj.buildDeps = message.buildDeps.map((e) => + e ? Module.toJSON(e) : undefined + ); + } else { + obj.buildDeps = []; + } + message.cosmosSdkVersion !== undefined && + (obj.cosmosSdkVersion = message.cosmosSdkVersion); + return obj; + }, + + fromPartial(object: DeepPartial): VersionInfo { + const message = { ...baseVersionInfo } as VersionInfo; + message.buildDeps = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.appName !== undefined && object.appName !== null) { + message.appName = object.appName; + } else { + message.appName = ""; + } + if (object.version !== undefined && object.version !== null) { + message.version = object.version; + } else { + message.version = ""; + } + if (object.gitCommit !== undefined && object.gitCommit !== null) { + message.gitCommit = object.gitCommit; + } else { + message.gitCommit = ""; + } + if (object.buildTags !== undefined && object.buildTags !== null) { + message.buildTags = object.buildTags; + } else { + message.buildTags = ""; + } + if (object.goVersion !== undefined && object.goVersion !== null) { + message.goVersion = object.goVersion; + } else { + message.goVersion = ""; + } + if (object.buildDeps !== undefined && object.buildDeps !== null) { + for (const e of object.buildDeps) { + message.buildDeps.push(Module.fromPartial(e)); + } + } + if ( + object.cosmosSdkVersion !== undefined && + object.cosmosSdkVersion !== null + ) { + message.cosmosSdkVersion = object.cosmosSdkVersion; + } else { + message.cosmosSdkVersion = ""; + } + return message; + }, +}; + +const baseModule: object = { path: "", version: "", sum: "" }; + +export const Module = { + encode(message: Module, writer: Writer = Writer.create()): Writer { + if (message.path !== "") { + writer.uint32(10).string(message.path); + } + if (message.version !== "") { + writer.uint32(18).string(message.version); + } + if (message.sum !== "") { + writer.uint32(26).string(message.sum); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Module { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseModule } as Module; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.path = reader.string(); + break; + case 2: + message.version = reader.string(); + break; + case 3: + message.sum = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Module { + const message = { ...baseModule } as Module; + if (object.path !== undefined && object.path !== null) { + message.path = String(object.path); + } else { + message.path = ""; + } + if (object.version !== undefined && object.version !== null) { + message.version = String(object.version); + } else { + message.version = ""; + } + if (object.sum !== undefined && object.sum !== null) { + message.sum = String(object.sum); + } else { + message.sum = ""; + } + return message; + }, + + toJSON(message: Module): unknown { + const obj: any = {}; + message.path !== undefined && (obj.path = message.path); + message.version !== undefined && (obj.version = message.version); + message.sum !== undefined && (obj.sum = message.sum); + return obj; + }, + + fromPartial(object: DeepPartial): Module { + const message = { ...baseModule } as Module; + if (object.path !== undefined && object.path !== null) { + message.path = object.path; + } else { + message.path = ""; + } + if (object.version !== undefined && object.version !== null) { + message.version = object.version; + } else { + message.version = ""; + } + if (object.sum !== undefined && object.sum !== null) { + message.sum = object.sum; + } else { + message.sum = ""; + } + return message; + }, +}; + +/** Service defines the gRPC querier service for tendermint queries. */ +export interface Service { + /** GetNodeInfo queries the current node info. */ + GetNodeInfo(request: GetNodeInfoRequest): Promise; + /** GetSyncing queries node syncing. */ + GetSyncing(request: GetSyncingRequest): Promise; + /** GetLatestBlock returns the latest block. */ + GetLatestBlock( + request: GetLatestBlockRequest + ): Promise; + /** GetBlockByHeight queries block for given height. */ + GetBlockByHeight( + request: GetBlockByHeightRequest + ): Promise; + /** GetLatestValidatorSet queries latest validator-set. */ + GetLatestValidatorSet( + request: GetLatestValidatorSetRequest + ): Promise; + /** GetValidatorSetByHeight queries validator-set at a given height. */ + GetValidatorSetByHeight( + request: GetValidatorSetByHeightRequest + ): Promise; +} + +export class ServiceClientImpl implements Service { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + } + GetNodeInfo(request: GetNodeInfoRequest): Promise { + const data = GetNodeInfoRequest.encode(request).finish(); + const promise = this.rpc.request( + "cosmos.base.tendermint.v1beta1.Service", + "GetNodeInfo", + data + ); + return promise.then((data) => GetNodeInfoResponse.decode(new Reader(data))); + } + + GetSyncing(request: GetSyncingRequest): Promise { + const data = GetSyncingRequest.encode(request).finish(); + const promise = this.rpc.request( + "cosmos.base.tendermint.v1beta1.Service", + "GetSyncing", + data + ); + return promise.then((data) => GetSyncingResponse.decode(new Reader(data))); + } + + GetLatestBlock( + request: GetLatestBlockRequest + ): Promise { + const data = GetLatestBlockRequest.encode(request).finish(); + const promise = this.rpc.request( + "cosmos.base.tendermint.v1beta1.Service", + "GetLatestBlock", + data + ); + return promise.then((data) => + GetLatestBlockResponse.decode(new Reader(data)) + ); + } + + GetBlockByHeight( + request: GetBlockByHeightRequest + ): Promise { + const data = GetBlockByHeightRequest.encode(request).finish(); + const promise = this.rpc.request( + "cosmos.base.tendermint.v1beta1.Service", + "GetBlockByHeight", + data + ); + return promise.then((data) => + GetBlockByHeightResponse.decode(new Reader(data)) + ); + } + + GetLatestValidatorSet( + request: GetLatestValidatorSetRequest + ): Promise { + const data = GetLatestValidatorSetRequest.encode(request).finish(); + const promise = this.rpc.request( + "cosmos.base.tendermint.v1beta1.Service", + "GetLatestValidatorSet", + data + ); + return promise.then((data) => + GetLatestValidatorSetResponse.decode(new Reader(data)) + ); + } + + GetValidatorSetByHeight( + request: GetValidatorSetByHeightRequest + ): Promise { + const data = GetValidatorSetByHeightRequest.encode(request).finish(); + const promise = this.rpc.request( + "cosmos.base.tendermint.v1beta1.Service", + "GetValidatorSetByHeight", + data + ); + return promise.then((data) => + GetValidatorSetByHeightResponse.decode(new Reader(data)) + ); + } +} + +interface Rpc { + request( + service: string, + method: string, + data: Uint8Array + ): Promise; +} + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/cosmos.base.tendermint.v1beta1/types/gogoproto/gogo.ts b/ts-client/cosmos.base.tendermint.v1beta1/types/gogoproto/gogo.ts new file mode 100644 index 00000000..3f41a047 --- /dev/null +++ b/ts-client/cosmos.base.tendermint.v1beta1/types/gogoproto/gogo.ts @@ -0,0 +1,2 @@ +/* eslint-disable */ +export const protobufPackage = "gogoproto"; diff --git a/ts-client/cosmos.base.tendermint.v1beta1/types/google/api/annotations.ts b/ts-client/cosmos.base.tendermint.v1beta1/types/google/api/annotations.ts new file mode 100644 index 00000000..aace4787 --- /dev/null +++ b/ts-client/cosmos.base.tendermint.v1beta1/types/google/api/annotations.ts @@ -0,0 +1,2 @@ +/* eslint-disable */ +export const protobufPackage = "google.api"; diff --git a/ts-client/cosmos.base.tendermint.v1beta1/types/google/api/http.ts b/ts-client/cosmos.base.tendermint.v1beta1/types/google/api/http.ts new file mode 100644 index 00000000..ddc00f8b --- /dev/null +++ b/ts-client/cosmos.base.tendermint.v1beta1/types/google/api/http.ts @@ -0,0 +1,705 @@ +/* eslint-disable */ +import { Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "google.api"; + +/** + * Defines the HTTP configuration for an API service. It contains a list of + * [HttpRule][google.api.HttpRule], each specifying the mapping of an RPC method + * to one or more HTTP REST API methods. + */ +export interface Http { + /** + * A list of HTTP configuration rules that apply to individual API methods. + * + * **NOTE:** All service configuration rules follow "last one wins" order. + */ + rules: HttpRule[]; + /** + * When set to true, URL path parmeters will be fully URI-decoded except in + * cases of single segment matches in reserved expansion, where "%2F" will be + * left encoded. + * + * The default behavior is to not decode RFC 6570 reserved characters in multi + * segment matches. + */ + fullyDecodeReservedExpansion: boolean; +} + +/** + * `HttpRule` defines the mapping of an RPC method to one or more HTTP + * REST API methods. The mapping specifies how different portions of the RPC + * request message are mapped to URL path, URL query parameters, and + * HTTP request body. The mapping is typically specified as an + * `google.api.http` annotation on the RPC method, + * see "google/api/annotations.proto" for details. + * + * The mapping consists of a field specifying the path template and + * method kind. The path template can refer to fields in the request + * message, as in the example below which describes a REST GET + * operation on a resource collection of messages: + * + * + * service Messaging { + * rpc GetMessage(GetMessageRequest) returns (Message) { + * option (google.api.http).get = "/v1/messages/{message_id}/{sub.subfield}"; + * } + * } + * message GetMessageRequest { + * message SubMessage { + * string subfield = 1; + * } + * string message_id = 1; // mapped to the URL + * SubMessage sub = 2; // `sub.subfield` is url-mapped + * } + * message Message { + * string text = 1; // content of the resource + * } + * + * The same http annotation can alternatively be expressed inside the + * `GRPC API Configuration` YAML file. + * + * http: + * rules: + * - selector: .Messaging.GetMessage + * get: /v1/messages/{message_id}/{sub.subfield} + * + * This definition enables an automatic, bidrectional mapping of HTTP + * JSON to RPC. Example: + * + * HTTP | RPC + * -----|----- + * `GET /v1/messages/123456/foo` | `GetMessage(message_id: "123456" sub: SubMessage(subfield: "foo"))` + * + * In general, not only fields but also field paths can be referenced + * from a path pattern. Fields mapped to the path pattern cannot be + * repeated and must have a primitive (non-message) type. + * + * Any fields in the request message which are not bound by the path + * pattern automatically become (optional) HTTP query + * parameters. Assume the following definition of the request message: + * + * + * service Messaging { + * rpc GetMessage(GetMessageRequest) returns (Message) { + * option (google.api.http).get = "/v1/messages/{message_id}"; + * } + * } + * message GetMessageRequest { + * message SubMessage { + * string subfield = 1; + * } + * string message_id = 1; // mapped to the URL + * int64 revision = 2; // becomes a parameter + * SubMessage sub = 3; // `sub.subfield` becomes a parameter + * } + * + * + * This enables a HTTP JSON to RPC mapping as below: + * + * HTTP | RPC + * -----|----- + * `GET /v1/messages/123456?revision=2&sub.subfield=foo` | `GetMessage(message_id: "123456" revision: 2 sub: SubMessage(subfield: "foo"))` + * + * Note that fields which are mapped to HTTP parameters must have a + * primitive type or a repeated primitive type. Message types are not + * allowed. In the case of a repeated type, the parameter can be + * repeated in the URL, as in `...?param=A¶m=B`. + * + * For HTTP method kinds which allow a request body, the `body` field + * specifies the mapping. Consider a REST update method on the + * message resource collection: + * + * + * service Messaging { + * rpc UpdateMessage(UpdateMessageRequest) returns (Message) { + * option (google.api.http) = { + * put: "/v1/messages/{message_id}" + * body: "message" + * }; + * } + * } + * message UpdateMessageRequest { + * string message_id = 1; // mapped to the URL + * Message message = 2; // mapped to the body + * } + * + * + * The following HTTP JSON to RPC mapping is enabled, where the + * representation of the JSON in the request body is determined by + * protos JSON encoding: + * + * HTTP | RPC + * -----|----- + * `PUT /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: "123456" message { text: "Hi!" })` + * + * The special name `*` can be used in the body mapping to define that + * every field not bound by the path template should be mapped to the + * request body. This enables the following alternative definition of + * the update method: + * + * service Messaging { + * rpc UpdateMessage(Message) returns (Message) { + * option (google.api.http) = { + * put: "/v1/messages/{message_id}" + * body: "*" + * }; + * } + * } + * message Message { + * string message_id = 1; + * string text = 2; + * } + * + * + * The following HTTP JSON to RPC mapping is enabled: + * + * HTTP | RPC + * -----|----- + * `PUT /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: "123456" text: "Hi!")` + * + * Note that when using `*` in the body mapping, it is not possible to + * have HTTP parameters, as all fields not bound by the path end in + * the body. This makes this option more rarely used in practice of + * defining REST APIs. The common usage of `*` is in custom methods + * which don't use the URL at all for transferring data. + * + * It is possible to define multiple HTTP methods for one RPC by using + * the `additional_bindings` option. Example: + * + * service Messaging { + * rpc GetMessage(GetMessageRequest) returns (Message) { + * option (google.api.http) = { + * get: "/v1/messages/{message_id}" + * additional_bindings { + * get: "/v1/users/{user_id}/messages/{message_id}" + * } + * }; + * } + * } + * message GetMessageRequest { + * string message_id = 1; + * string user_id = 2; + * } + * + * + * This enables the following two alternative HTTP JSON to RPC + * mappings: + * + * HTTP | RPC + * -----|----- + * `GET /v1/messages/123456` | `GetMessage(message_id: "123456")` + * `GET /v1/users/me/messages/123456` | `GetMessage(user_id: "me" message_id: "123456")` + * + * # Rules for HTTP mapping + * + * The rules for mapping HTTP path, query parameters, and body fields + * to the request message are as follows: + * + * 1. The `body` field specifies either `*` or a field path, or is + * omitted. If omitted, it indicates there is no HTTP request body. + * 2. Leaf fields (recursive expansion of nested messages in the + * request) can be classified into three types: + * (a) Matched in the URL template. + * (b) Covered by body (if body is `*`, everything except (a) fields; + * else everything under the body field) + * (c) All other fields. + * 3. URL query parameters found in the HTTP request are mapped to (c) fields. + * 4. Any body sent with an HTTP request can contain only (b) fields. + * + * The syntax of the path template is as follows: + * + * Template = "/" Segments [ Verb ] ; + * Segments = Segment { "/" Segment } ; + * Segment = "*" | "**" | LITERAL | Variable ; + * Variable = "{" FieldPath [ "=" Segments ] "}" ; + * FieldPath = IDENT { "." IDENT } ; + * Verb = ":" LITERAL ; + * + * The syntax `*` matches a single path segment. The syntax `**` matches zero + * or more path segments, which must be the last part of the path except the + * `Verb`. The syntax `LITERAL` matches literal text in the path. + * + * The syntax `Variable` matches part of the URL path as specified by its + * template. A variable template must not contain other variables. If a variable + * matches a single path segment, its template may be omitted, e.g. `{var}` + * is equivalent to `{var=*}`. + * + * If a variable contains exactly one path segment, such as `"{var}"` or + * `"{var=*}"`, when such a variable is expanded into a URL path, all characters + * except `[-_.~0-9a-zA-Z]` are percent-encoded. Such variables show up in the + * Discovery Document as `{var}`. + * + * If a variable contains one or more path segments, such as `"{var=foo/*}"` + * or `"{var=**}"`, when such a variable is expanded into a URL path, all + * characters except `[-_.~/0-9a-zA-Z]` are percent-encoded. Such variables + * show up in the Discovery Document as `{+var}`. + * + * NOTE: While the single segment variable matches the semantics of + * [RFC 6570](https://tools.ietf.org/html/rfc6570) Section 3.2.2 + * Simple String Expansion, the multi segment variable **does not** match + * RFC 6570 Reserved Expansion. The reason is that the Reserved Expansion + * does not expand special characters like `?` and `#`, which would lead + * to invalid URLs. + * + * NOTE: the field paths in variables and in the `body` must not refer to + * repeated fields or map fields. + */ +export interface HttpRule { + /** + * Selects methods to which this rule applies. + * + * Refer to [selector][google.api.DocumentationRule.selector] for syntax details. + */ + selector: string; + /** Used for listing and getting information about resources. */ + get: string | undefined; + /** Used for updating a resource. */ + put: string | undefined; + /** Used for creating a resource. */ + post: string | undefined; + /** Used for deleting a resource. */ + delete: string | undefined; + /** Used for updating a resource. */ + patch: string | undefined; + /** + * The custom pattern is used for specifying an HTTP method that is not + * included in the `pattern` field, such as HEAD, or "*" to leave the + * HTTP method unspecified for this rule. The wild-card rule is useful + * for services that provide content to Web (HTML) clients. + */ + custom: CustomHttpPattern | undefined; + /** + * The name of the request field whose value is mapped to the HTTP body, or + * `*` for mapping all fields not captured by the path pattern to the HTTP + * body. NOTE: the referred field must not be a repeated field and must be + * present at the top-level of request message type. + */ + body: string; + /** + * Optional. The name of the response field whose value is mapped to the HTTP + * body of response. Other response fields are ignored. When + * not set, the response message will be used as HTTP body of response. + */ + responseBody: string; + /** + * Additional HTTP bindings for the selector. Nested bindings must + * not contain an `additional_bindings` field themselves (that is, + * the nesting may only be one level deep). + */ + additionalBindings: HttpRule[]; +} + +/** A custom pattern is used for defining custom HTTP verb. */ +export interface CustomHttpPattern { + /** The name of this custom HTTP verb. */ + kind: string; + /** The path matched by this custom verb. */ + path: string; +} + +const baseHttp: object = { fullyDecodeReservedExpansion: false }; + +export const Http = { + encode(message: Http, writer: Writer = Writer.create()): Writer { + for (const v of message.rules) { + HttpRule.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.fullyDecodeReservedExpansion === true) { + writer.uint32(16).bool(message.fullyDecodeReservedExpansion); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Http { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseHttp } as Http; + message.rules = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.rules.push(HttpRule.decode(reader, reader.uint32())); + break; + case 2: + message.fullyDecodeReservedExpansion = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Http { + const message = { ...baseHttp } as Http; + message.rules = []; + if (object.rules !== undefined && object.rules !== null) { + for (const e of object.rules) { + message.rules.push(HttpRule.fromJSON(e)); + } + } + if ( + object.fullyDecodeReservedExpansion !== undefined && + object.fullyDecodeReservedExpansion !== null + ) { + message.fullyDecodeReservedExpansion = Boolean( + object.fullyDecodeReservedExpansion + ); + } else { + message.fullyDecodeReservedExpansion = false; + } + return message; + }, + + toJSON(message: Http): unknown { + const obj: any = {}; + if (message.rules) { + obj.rules = message.rules.map((e) => + e ? HttpRule.toJSON(e) : undefined + ); + } else { + obj.rules = []; + } + message.fullyDecodeReservedExpansion !== undefined && + (obj.fullyDecodeReservedExpansion = message.fullyDecodeReservedExpansion); + return obj; + }, + + fromPartial(object: DeepPartial): Http { + const message = { ...baseHttp } as Http; + message.rules = []; + if (object.rules !== undefined && object.rules !== null) { + for (const e of object.rules) { + message.rules.push(HttpRule.fromPartial(e)); + } + } + if ( + object.fullyDecodeReservedExpansion !== undefined && + object.fullyDecodeReservedExpansion !== null + ) { + message.fullyDecodeReservedExpansion = + object.fullyDecodeReservedExpansion; + } else { + message.fullyDecodeReservedExpansion = false; + } + return message; + }, +}; + +const baseHttpRule: object = { selector: "", body: "", responseBody: "" }; + +export const HttpRule = { + encode(message: HttpRule, writer: Writer = Writer.create()): Writer { + if (message.selector !== "") { + writer.uint32(10).string(message.selector); + } + if (message.get !== undefined) { + writer.uint32(18).string(message.get); + } + if (message.put !== undefined) { + writer.uint32(26).string(message.put); + } + if (message.post !== undefined) { + writer.uint32(34).string(message.post); + } + if (message.delete !== undefined) { + writer.uint32(42).string(message.delete); + } + if (message.patch !== undefined) { + writer.uint32(50).string(message.patch); + } + if (message.custom !== undefined) { + CustomHttpPattern.encode( + message.custom, + writer.uint32(66).fork() + ).ldelim(); + } + if (message.body !== "") { + writer.uint32(58).string(message.body); + } + if (message.responseBody !== "") { + writer.uint32(98).string(message.responseBody); + } + for (const v of message.additionalBindings) { + HttpRule.encode(v!, writer.uint32(90).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): HttpRule { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseHttpRule } as HttpRule; + message.additionalBindings = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.selector = reader.string(); + break; + case 2: + message.get = reader.string(); + break; + case 3: + message.put = reader.string(); + break; + case 4: + message.post = reader.string(); + break; + case 5: + message.delete = reader.string(); + break; + case 6: + message.patch = reader.string(); + break; + case 8: + message.custom = CustomHttpPattern.decode(reader, reader.uint32()); + break; + case 7: + message.body = reader.string(); + break; + case 12: + message.responseBody = reader.string(); + break; + case 11: + message.additionalBindings.push( + HttpRule.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): HttpRule { + const message = { ...baseHttpRule } as HttpRule; + message.additionalBindings = []; + if (object.selector !== undefined && object.selector !== null) { + message.selector = String(object.selector); + } else { + message.selector = ""; + } + if (object.get !== undefined && object.get !== null) { + message.get = String(object.get); + } else { + message.get = undefined; + } + if (object.put !== undefined && object.put !== null) { + message.put = String(object.put); + } else { + message.put = undefined; + } + if (object.post !== undefined && object.post !== null) { + message.post = String(object.post); + } else { + message.post = undefined; + } + if (object.delete !== undefined && object.delete !== null) { + message.delete = String(object.delete); + } else { + message.delete = undefined; + } + if (object.patch !== undefined && object.patch !== null) { + message.patch = String(object.patch); + } else { + message.patch = undefined; + } + if (object.custom !== undefined && object.custom !== null) { + message.custom = CustomHttpPattern.fromJSON(object.custom); + } else { + message.custom = undefined; + } + if (object.body !== undefined && object.body !== null) { + message.body = String(object.body); + } else { + message.body = ""; + } + if (object.responseBody !== undefined && object.responseBody !== null) { + message.responseBody = String(object.responseBody); + } else { + message.responseBody = ""; + } + if ( + object.additionalBindings !== undefined && + object.additionalBindings !== null + ) { + for (const e of object.additionalBindings) { + message.additionalBindings.push(HttpRule.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: HttpRule): unknown { + const obj: any = {}; + message.selector !== undefined && (obj.selector = message.selector); + message.get !== undefined && (obj.get = message.get); + message.put !== undefined && (obj.put = message.put); + message.post !== undefined && (obj.post = message.post); + message.delete !== undefined && (obj.delete = message.delete); + message.patch !== undefined && (obj.patch = message.patch); + message.custom !== undefined && + (obj.custom = message.custom + ? CustomHttpPattern.toJSON(message.custom) + : undefined); + message.body !== undefined && (obj.body = message.body); + message.responseBody !== undefined && + (obj.responseBody = message.responseBody); + if (message.additionalBindings) { + obj.additionalBindings = message.additionalBindings.map((e) => + e ? HttpRule.toJSON(e) : undefined + ); + } else { + obj.additionalBindings = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): HttpRule { + const message = { ...baseHttpRule } as HttpRule; + message.additionalBindings = []; + if (object.selector !== undefined && object.selector !== null) { + message.selector = object.selector; + } else { + message.selector = ""; + } + if (object.get !== undefined && object.get !== null) { + message.get = object.get; + } else { + message.get = undefined; + } + if (object.put !== undefined && object.put !== null) { + message.put = object.put; + } else { + message.put = undefined; + } + if (object.post !== undefined && object.post !== null) { + message.post = object.post; + } else { + message.post = undefined; + } + if (object.delete !== undefined && object.delete !== null) { + message.delete = object.delete; + } else { + message.delete = undefined; + } + if (object.patch !== undefined && object.patch !== null) { + message.patch = object.patch; + } else { + message.patch = undefined; + } + if (object.custom !== undefined && object.custom !== null) { + message.custom = CustomHttpPattern.fromPartial(object.custom); + } else { + message.custom = undefined; + } + if (object.body !== undefined && object.body !== null) { + message.body = object.body; + } else { + message.body = ""; + } + if (object.responseBody !== undefined && object.responseBody !== null) { + message.responseBody = object.responseBody; + } else { + message.responseBody = ""; + } + if ( + object.additionalBindings !== undefined && + object.additionalBindings !== null + ) { + for (const e of object.additionalBindings) { + message.additionalBindings.push(HttpRule.fromPartial(e)); + } + } + return message; + }, +}; + +const baseCustomHttpPattern: object = { kind: "", path: "" }; + +export const CustomHttpPattern = { + encode(message: CustomHttpPattern, writer: Writer = Writer.create()): Writer { + if (message.kind !== "") { + writer.uint32(10).string(message.kind); + } + if (message.path !== "") { + writer.uint32(18).string(message.path); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): CustomHttpPattern { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseCustomHttpPattern } as CustomHttpPattern; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.kind = reader.string(); + break; + case 2: + message.path = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): CustomHttpPattern { + const message = { ...baseCustomHttpPattern } as CustomHttpPattern; + if (object.kind !== undefined && object.kind !== null) { + message.kind = String(object.kind); + } else { + message.kind = ""; + } + if (object.path !== undefined && object.path !== null) { + message.path = String(object.path); + } else { + message.path = ""; + } + return message; + }, + + toJSON(message: CustomHttpPattern): unknown { + const obj: any = {}; + message.kind !== undefined && (obj.kind = message.kind); + message.path !== undefined && (obj.path = message.path); + return obj; + }, + + fromPartial(object: DeepPartial): CustomHttpPattern { + const message = { ...baseCustomHttpPattern } as CustomHttpPattern; + if (object.kind !== undefined && object.kind !== null) { + message.kind = object.kind; + } else { + message.kind = ""; + } + if (object.path !== undefined && object.path !== null) { + message.path = object.path; + } else { + message.path = ""; + } + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/cosmos.base.tendermint.v1beta1/types/google/protobuf/any.ts b/ts-client/cosmos.base.tendermint.v1beta1/types/google/protobuf/any.ts new file mode 100644 index 00000000..b137a629 --- /dev/null +++ b/ts-client/cosmos.base.tendermint.v1beta1/types/google/protobuf/any.ts @@ -0,0 +1,240 @@ +/* eslint-disable */ +import { Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "google.protobuf"; + +/** + * `Any` contains an arbitrary serialized protocol buffer message along with a + * URL that describes the type of the serialized message. + * + * Protobuf library provides support to pack/unpack Any values in the form + * of utility functions or additional generated methods of the Any type. + * + * Example 1: Pack and unpack a message in C++. + * + * Foo foo = ...; + * Any any; + * any.PackFrom(foo); + * ... + * if (any.UnpackTo(&foo)) { + * ... + * } + * + * Example 2: Pack and unpack a message in Java. + * + * Foo foo = ...; + * Any any = Any.pack(foo); + * ... + * if (any.is(Foo.class)) { + * foo = any.unpack(Foo.class); + * } + * + * Example 3: Pack and unpack a message in Python. + * + * foo = Foo(...) + * any = Any() + * any.Pack(foo) + * ... + * if any.Is(Foo.DESCRIPTOR): + * any.Unpack(foo) + * ... + * + * Example 4: Pack and unpack a message in Go + * + * foo := &pb.Foo{...} + * any, err := anypb.New(foo) + * if err != nil { + * ... + * } + * ... + * foo := &pb.Foo{} + * if err := any.UnmarshalTo(foo); err != nil { + * ... + * } + * + * The pack methods provided by protobuf library will by default use + * 'type.googleapis.com/full.type.name' as the type URL and the unpack + * methods only use the fully qualified type name after the last '/' + * in the type URL, for example "foo.bar.com/x/y.z" will yield type + * name "y.z". + * + * + * JSON + * ==== + * The JSON representation of an `Any` value uses the regular + * representation of the deserialized, embedded message, with an + * additional field `@type` which contains the type URL. Example: + * + * package google.profile; + * message Person { + * string first_name = 1; + * string last_name = 2; + * } + * + * { + * "@type": "type.googleapis.com/google.profile.Person", + * "firstName": , + * "lastName": + * } + * + * If the embedded message type is well-known and has a custom JSON + * representation, that representation will be embedded adding a field + * `value` which holds the custom JSON in addition to the `@type` + * field. Example (for message [google.protobuf.Duration][]): + * + * { + * "@type": "type.googleapis.com/google.protobuf.Duration", + * "value": "1.212s" + * } + */ +export interface Any { + /** + * A URL/resource name that uniquely identifies the type of the serialized + * protocol buffer message. This string must contain at least + * one "/" character. The last segment of the URL's path must represent + * the fully qualified name of the type (as in + * `path/google.protobuf.Duration`). The name should be in a canonical form + * (e.g., leading "." is not accepted). + * + * In practice, teams usually precompile into the binary all types that they + * expect it to use in the context of Any. However, for URLs which use the + * scheme `http`, `https`, or no scheme, one can optionally set up a type + * server that maps type URLs to message definitions as follows: + * + * * If no scheme is provided, `https` is assumed. + * * An HTTP GET on the URL must yield a [google.protobuf.Type][] + * value in binary format, or produce an error. + * * Applications are allowed to cache lookup results based on the + * URL, or have them precompiled into a binary to avoid any + * lookup. Therefore, binary compatibility needs to be preserved + * on changes to types. (Use versioned type names to manage + * breaking changes.) + * + * Note: this functionality is not currently available in the official + * protobuf release, and it is not used for type URLs beginning with + * type.googleapis.com. + * + * Schemes other than `http`, `https` (or the empty scheme) might be + * used with implementation specific semantics. + */ + typeUrl: string; + /** Must be a valid serialized protocol buffer of the above specified type. */ + value: Uint8Array; +} + +const baseAny: object = { typeUrl: "" }; + +export const Any = { + encode(message: Any, writer: Writer = Writer.create()): Writer { + if (message.typeUrl !== "") { + writer.uint32(10).string(message.typeUrl); + } + if (message.value.length !== 0) { + writer.uint32(18).bytes(message.value); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Any { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseAny } as Any; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.typeUrl = reader.string(); + break; + case 2: + message.value = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Any { + const message = { ...baseAny } as Any; + if (object.typeUrl !== undefined && object.typeUrl !== null) { + message.typeUrl = String(object.typeUrl); + } else { + message.typeUrl = ""; + } + if (object.value !== undefined && object.value !== null) { + message.value = bytesFromBase64(object.value); + } + return message; + }, + + toJSON(message: Any): unknown { + const obj: any = {}; + message.typeUrl !== undefined && (obj.typeUrl = message.typeUrl); + message.value !== undefined && + (obj.value = base64FromBytes( + message.value !== undefined ? message.value : new Uint8Array() + )); + return obj; + }, + + fromPartial(object: DeepPartial): Any { + const message = { ...baseAny } as Any; + if (object.typeUrl !== undefined && object.typeUrl !== null) { + message.typeUrl = object.typeUrl; + } else { + message.typeUrl = ""; + } + if (object.value !== undefined && object.value !== null) { + message.value = object.value; + } else { + message.value = new Uint8Array(); + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/cosmos.base.tendermint.v1beta1/types/google/protobuf/descriptor.ts b/ts-client/cosmos.base.tendermint.v1beta1/types/google/protobuf/descriptor.ts new file mode 100644 index 00000000..9e508660 --- /dev/null +++ b/ts-client/cosmos.base.tendermint.v1beta1/types/google/protobuf/descriptor.ts @@ -0,0 +1,5261 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "google.protobuf"; + +/** + * The protocol compiler can output a FileDescriptorSet containing the .proto + * files it parses. + */ +export interface FileDescriptorSet { + file: FileDescriptorProto[]; +} + +/** Describes a complete .proto file. */ +export interface FileDescriptorProto { + /** file name, relative to root of source tree */ + name: string; + /** e.g. "foo", "foo.bar", etc. */ + package: string; + /** Names of files imported by this file. */ + dependency: string[]; + /** Indexes of the public imported files in the dependency list above. */ + publicDependency: number[]; + /** + * Indexes of the weak imported files in the dependency list. + * For Google-internal migration only. Do not use. + */ + weakDependency: number[]; + /** All top-level definitions in this file. */ + messageType: DescriptorProto[]; + enumType: EnumDescriptorProto[]; + service: ServiceDescriptorProto[]; + extension: FieldDescriptorProto[]; + options: FileOptions | undefined; + /** + * This field contains optional information about the original source code. + * You may safely remove this entire field without harming runtime + * functionality of the descriptors -- the information is needed only by + * development tools. + */ + sourceCodeInfo: SourceCodeInfo | undefined; + /** + * The syntax of the proto file. + * The supported values are "proto2" and "proto3". + */ + syntax: string; +} + +/** Describes a message type. */ +export interface DescriptorProto { + name: string; + field: FieldDescriptorProto[]; + extension: FieldDescriptorProto[]; + nestedType: DescriptorProto[]; + enumType: EnumDescriptorProto[]; + extensionRange: DescriptorProto_ExtensionRange[]; + oneofDecl: OneofDescriptorProto[]; + options: MessageOptions | undefined; + reservedRange: DescriptorProto_ReservedRange[]; + /** + * Reserved field names, which may not be used by fields in the same message. + * A given name may only be reserved once. + */ + reservedName: string[]; +} + +export interface DescriptorProto_ExtensionRange { + /** Inclusive. */ + start: number; + /** Exclusive. */ + end: number; + options: ExtensionRangeOptions | undefined; +} + +/** + * Range of reserved tag numbers. Reserved tag numbers may not be used by + * fields or extension ranges in the same message. Reserved ranges may + * not overlap. + */ +export interface DescriptorProto_ReservedRange { + /** Inclusive. */ + start: number; + /** Exclusive. */ + end: number; +} + +export interface ExtensionRangeOptions { + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +/** Describes a field within a message. */ +export interface FieldDescriptorProto { + name: string; + number: number; + label: FieldDescriptorProto_Label; + /** + * If type_name is set, this need not be set. If both this and type_name + * are set, this must be one of TYPE_ENUM, TYPE_MESSAGE or TYPE_GROUP. + */ + type: FieldDescriptorProto_Type; + /** + * For message and enum types, this is the name of the type. If the name + * starts with a '.', it is fully-qualified. Otherwise, C++-like scoping + * rules are used to find the type (i.e. first the nested types within this + * message are searched, then within the parent, on up to the root + * namespace). + */ + typeName: string; + /** + * For extensions, this is the name of the type being extended. It is + * resolved in the same manner as type_name. + */ + extendee: string; + /** + * For numeric types, contains the original text representation of the value. + * For booleans, "true" or "false". + * For strings, contains the default text contents (not escaped in any way). + * For bytes, contains the C escaped value. All bytes >= 128 are escaped. + * TODO(kenton): Base-64 encode? + */ + defaultValue: string; + /** + * If set, gives the index of a oneof in the containing type's oneof_decl + * list. This field is a member of that oneof. + */ + oneofIndex: number; + /** + * JSON name of this field. The value is set by protocol compiler. If the + * user has set a "json_name" option on this field, that option's value + * will be used. Otherwise, it's deduced from the field's name by converting + * it to camelCase. + */ + jsonName: string; + options: FieldOptions | undefined; + /** + * If true, this is a proto3 "optional". When a proto3 field is optional, it + * tracks presence regardless of field type. + * + * When proto3_optional is true, this field must be belong to a oneof to + * signal to old proto3 clients that presence is tracked for this field. This + * oneof is known as a "synthetic" oneof, and this field must be its sole + * member (each proto3 optional field gets its own synthetic oneof). Synthetic + * oneofs exist in the descriptor only, and do not generate any API. Synthetic + * oneofs must be ordered after all "real" oneofs. + * + * For message fields, proto3_optional doesn't create any semantic change, + * since non-repeated message fields always track presence. However it still + * indicates the semantic detail of whether the user wrote "optional" or not. + * This can be useful for round-tripping the .proto file. For consistency we + * give message fields a synthetic oneof also, even though it is not required + * to track presence. This is especially important because the parser can't + * tell if a field is a message or an enum, so it must always create a + * synthetic oneof. + * + * Proto2 optional fields do not set this flag, because they already indicate + * optional with `LABEL_OPTIONAL`. + */ + proto3Optional: boolean; +} + +export enum FieldDescriptorProto_Type { + /** + * TYPE_DOUBLE - 0 is reserved for errors. + * Order is weird for historical reasons. + */ + TYPE_DOUBLE = 1, + TYPE_FLOAT = 2, + /** + * TYPE_INT64 - Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT64 if + * negative values are likely. + */ + TYPE_INT64 = 3, + TYPE_UINT64 = 4, + /** + * TYPE_INT32 - Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT32 if + * negative values are likely. + */ + TYPE_INT32 = 5, + TYPE_FIXED64 = 6, + TYPE_FIXED32 = 7, + TYPE_BOOL = 8, + TYPE_STRING = 9, + /** + * TYPE_GROUP - Tag-delimited aggregate. + * Group type is deprecated and not supported in proto3. However, Proto3 + * implementations should still be able to parse the group wire format and + * treat group fields as unknown fields. + */ + TYPE_GROUP = 10, + /** TYPE_MESSAGE - Length-delimited aggregate. */ + TYPE_MESSAGE = 11, + /** TYPE_BYTES - New in version 2. */ + TYPE_BYTES = 12, + TYPE_UINT32 = 13, + TYPE_ENUM = 14, + TYPE_SFIXED32 = 15, + TYPE_SFIXED64 = 16, + /** TYPE_SINT32 - Uses ZigZag encoding. */ + TYPE_SINT32 = 17, + /** TYPE_SINT64 - Uses ZigZag encoding. */ + TYPE_SINT64 = 18, + UNRECOGNIZED = -1, +} + +export function fieldDescriptorProto_TypeFromJSON( + object: any +): FieldDescriptorProto_Type { + switch (object) { + case 1: + case "TYPE_DOUBLE": + return FieldDescriptorProto_Type.TYPE_DOUBLE; + case 2: + case "TYPE_FLOAT": + return FieldDescriptorProto_Type.TYPE_FLOAT; + case 3: + case "TYPE_INT64": + return FieldDescriptorProto_Type.TYPE_INT64; + case 4: + case "TYPE_UINT64": + return FieldDescriptorProto_Type.TYPE_UINT64; + case 5: + case "TYPE_INT32": + return FieldDescriptorProto_Type.TYPE_INT32; + case 6: + case "TYPE_FIXED64": + return FieldDescriptorProto_Type.TYPE_FIXED64; + case 7: + case "TYPE_FIXED32": + return FieldDescriptorProto_Type.TYPE_FIXED32; + case 8: + case "TYPE_BOOL": + return FieldDescriptorProto_Type.TYPE_BOOL; + case 9: + case "TYPE_STRING": + return FieldDescriptorProto_Type.TYPE_STRING; + case 10: + case "TYPE_GROUP": + return FieldDescriptorProto_Type.TYPE_GROUP; + case 11: + case "TYPE_MESSAGE": + return FieldDescriptorProto_Type.TYPE_MESSAGE; + case 12: + case "TYPE_BYTES": + return FieldDescriptorProto_Type.TYPE_BYTES; + case 13: + case "TYPE_UINT32": + return FieldDescriptorProto_Type.TYPE_UINT32; + case 14: + case "TYPE_ENUM": + return FieldDescriptorProto_Type.TYPE_ENUM; + case 15: + case "TYPE_SFIXED32": + return FieldDescriptorProto_Type.TYPE_SFIXED32; + case 16: + case "TYPE_SFIXED64": + return FieldDescriptorProto_Type.TYPE_SFIXED64; + case 17: + case "TYPE_SINT32": + return FieldDescriptorProto_Type.TYPE_SINT32; + case 18: + case "TYPE_SINT64": + return FieldDescriptorProto_Type.TYPE_SINT64; + case -1: + case "UNRECOGNIZED": + default: + return FieldDescriptorProto_Type.UNRECOGNIZED; + } +} + +export function fieldDescriptorProto_TypeToJSON( + object: FieldDescriptorProto_Type +): string { + switch (object) { + case FieldDescriptorProto_Type.TYPE_DOUBLE: + return "TYPE_DOUBLE"; + case FieldDescriptorProto_Type.TYPE_FLOAT: + return "TYPE_FLOAT"; + case FieldDescriptorProto_Type.TYPE_INT64: + return "TYPE_INT64"; + case FieldDescriptorProto_Type.TYPE_UINT64: + return "TYPE_UINT64"; + case FieldDescriptorProto_Type.TYPE_INT32: + return "TYPE_INT32"; + case FieldDescriptorProto_Type.TYPE_FIXED64: + return "TYPE_FIXED64"; + case FieldDescriptorProto_Type.TYPE_FIXED32: + return "TYPE_FIXED32"; + case FieldDescriptorProto_Type.TYPE_BOOL: + return "TYPE_BOOL"; + case FieldDescriptorProto_Type.TYPE_STRING: + return "TYPE_STRING"; + case FieldDescriptorProto_Type.TYPE_GROUP: + return "TYPE_GROUP"; + case FieldDescriptorProto_Type.TYPE_MESSAGE: + return "TYPE_MESSAGE"; + case FieldDescriptorProto_Type.TYPE_BYTES: + return "TYPE_BYTES"; + case FieldDescriptorProto_Type.TYPE_UINT32: + return "TYPE_UINT32"; + case FieldDescriptorProto_Type.TYPE_ENUM: + return "TYPE_ENUM"; + case FieldDescriptorProto_Type.TYPE_SFIXED32: + return "TYPE_SFIXED32"; + case FieldDescriptorProto_Type.TYPE_SFIXED64: + return "TYPE_SFIXED64"; + case FieldDescriptorProto_Type.TYPE_SINT32: + return "TYPE_SINT32"; + case FieldDescriptorProto_Type.TYPE_SINT64: + return "TYPE_SINT64"; + default: + return "UNKNOWN"; + } +} + +export enum FieldDescriptorProto_Label { + /** LABEL_OPTIONAL - 0 is reserved for errors */ + LABEL_OPTIONAL = 1, + LABEL_REQUIRED = 2, + LABEL_REPEATED = 3, + UNRECOGNIZED = -1, +} + +export function fieldDescriptorProto_LabelFromJSON( + object: any +): FieldDescriptorProto_Label { + switch (object) { + case 1: + case "LABEL_OPTIONAL": + return FieldDescriptorProto_Label.LABEL_OPTIONAL; + case 2: + case "LABEL_REQUIRED": + return FieldDescriptorProto_Label.LABEL_REQUIRED; + case 3: + case "LABEL_REPEATED": + return FieldDescriptorProto_Label.LABEL_REPEATED; + case -1: + case "UNRECOGNIZED": + default: + return FieldDescriptorProto_Label.UNRECOGNIZED; + } +} + +export function fieldDescriptorProto_LabelToJSON( + object: FieldDescriptorProto_Label +): string { + switch (object) { + case FieldDescriptorProto_Label.LABEL_OPTIONAL: + return "LABEL_OPTIONAL"; + case FieldDescriptorProto_Label.LABEL_REQUIRED: + return "LABEL_REQUIRED"; + case FieldDescriptorProto_Label.LABEL_REPEATED: + return "LABEL_REPEATED"; + default: + return "UNKNOWN"; + } +} + +/** Describes a oneof. */ +export interface OneofDescriptorProto { + name: string; + options: OneofOptions | undefined; +} + +/** Describes an enum type. */ +export interface EnumDescriptorProto { + name: string; + value: EnumValueDescriptorProto[]; + options: EnumOptions | undefined; + /** + * Range of reserved numeric values. Reserved numeric values may not be used + * by enum values in the same enum declaration. Reserved ranges may not + * overlap. + */ + reservedRange: EnumDescriptorProto_EnumReservedRange[]; + /** + * Reserved enum value names, which may not be reused. A given name may only + * be reserved once. + */ + reservedName: string[]; +} + +/** + * Range of reserved numeric values. Reserved values may not be used by + * entries in the same enum. Reserved ranges may not overlap. + * + * Note that this is distinct from DescriptorProto.ReservedRange in that it + * is inclusive such that it can appropriately represent the entire int32 + * domain. + */ +export interface EnumDescriptorProto_EnumReservedRange { + /** Inclusive. */ + start: number; + /** Inclusive. */ + end: number; +} + +/** Describes a value within an enum. */ +export interface EnumValueDescriptorProto { + name: string; + number: number; + options: EnumValueOptions | undefined; +} + +/** Describes a service. */ +export interface ServiceDescriptorProto { + name: string; + method: MethodDescriptorProto[]; + options: ServiceOptions | undefined; +} + +/** Describes a method of a service. */ +export interface MethodDescriptorProto { + name: string; + /** + * Input and output type names. These are resolved in the same way as + * FieldDescriptorProto.type_name, but must refer to a message type. + */ + inputType: string; + outputType: string; + options: MethodOptions | undefined; + /** Identifies if client streams multiple client messages */ + clientStreaming: boolean; + /** Identifies if server streams multiple server messages */ + serverStreaming: boolean; +} + +export interface FileOptions { + /** + * Sets the Java package where classes generated from this .proto will be + * placed. By default, the proto package is used, but this is often + * inappropriate because proto packages do not normally start with backwards + * domain names. + */ + javaPackage: string; + /** + * Controls the name of the wrapper Java class generated for the .proto file. + * That class will always contain the .proto file's getDescriptor() method as + * well as any top-level extensions defined in the .proto file. + * If java_multiple_files is disabled, then all the other classes from the + * .proto file will be nested inside the single wrapper outer class. + */ + javaOuterClassname: string; + /** + * If enabled, then the Java code generator will generate a separate .java + * file for each top-level message, enum, and service defined in the .proto + * file. Thus, these types will *not* be nested inside the wrapper class + * named by java_outer_classname. However, the wrapper class will still be + * generated to contain the file's getDescriptor() method as well as any + * top-level extensions defined in the file. + */ + javaMultipleFiles: boolean; + /** + * This option does nothing. + * + * @deprecated + */ + javaGenerateEqualsAndHash: boolean; + /** + * If set true, then the Java2 code generator will generate code that + * throws an exception whenever an attempt is made to assign a non-UTF-8 + * byte sequence to a string field. + * Message reflection will do the same. + * However, an extension field still accepts non-UTF-8 byte sequences. + * This option has no effect on when used with the lite runtime. + */ + javaStringCheckUtf8: boolean; + optimizeFor: FileOptions_OptimizeMode; + /** + * Sets the Go package where structs generated from this .proto will be + * placed. If omitted, the Go package will be derived from the following: + * - The basename of the package import path, if provided. + * - Otherwise, the package statement in the .proto file, if present. + * - Otherwise, the basename of the .proto file, without extension. + */ + goPackage: string; + /** + * Should generic services be generated in each language? "Generic" services + * are not specific to any particular RPC system. They are generated by the + * main code generators in each language (without additional plugins). + * Generic services were the only kind of service generation supported by + * early versions of google.protobuf. + * + * Generic services are now considered deprecated in favor of using plugins + * that generate code specific to your particular RPC system. Therefore, + * these default to false. Old code which depends on generic services should + * explicitly set them to true. + */ + ccGenericServices: boolean; + javaGenericServices: boolean; + pyGenericServices: boolean; + phpGenericServices: boolean; + /** + * Is this file deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for everything in the file, or it will be completely ignored; in the very + * least, this is a formalization for deprecating files. + */ + deprecated: boolean; + /** + * Enables the use of arenas for the proto messages in this file. This applies + * only to generated classes for C++. + */ + ccEnableArenas: boolean; + /** + * Sets the objective c class prefix which is prepended to all objective c + * generated classes from this .proto. There is no default. + */ + objcClassPrefix: string; + /** Namespace for generated classes; defaults to the package. */ + csharpNamespace: string; + /** + * By default Swift generators will take the proto package and CamelCase it + * replacing '.' with underscore and use that to prefix the types/symbols + * defined. When this options is provided, they will use this value instead + * to prefix the types/symbols defined. + */ + swiftPrefix: string; + /** + * Sets the php class prefix which is prepended to all php generated classes + * from this .proto. Default is empty. + */ + phpClassPrefix: string; + /** + * Use this option to change the namespace of php generated classes. Default + * is empty. When this option is empty, the package name will be used for + * determining the namespace. + */ + phpNamespace: string; + /** + * Use this option to change the namespace of php generated metadata classes. + * Default is empty. When this option is empty, the proto file name will be + * used for determining the namespace. + */ + phpMetadataNamespace: string; + /** + * Use this option to change the package of ruby generated classes. Default + * is empty. When this option is not set, the package name will be used for + * determining the ruby package. + */ + rubyPackage: string; + /** + * The parser stores options it doesn't recognize here. + * See the documentation for the "Options" section above. + */ + uninterpretedOption: UninterpretedOption[]; +} + +/** Generated classes can be optimized for speed or code size. */ +export enum FileOptions_OptimizeMode { + /** SPEED - Generate complete code for parsing, serialization, */ + SPEED = 1, + /** CODE_SIZE - etc. */ + CODE_SIZE = 2, + /** LITE_RUNTIME - Generate code using MessageLite and the lite runtime. */ + LITE_RUNTIME = 3, + UNRECOGNIZED = -1, +} + +export function fileOptions_OptimizeModeFromJSON( + object: any +): FileOptions_OptimizeMode { + switch (object) { + case 1: + case "SPEED": + return FileOptions_OptimizeMode.SPEED; + case 2: + case "CODE_SIZE": + return FileOptions_OptimizeMode.CODE_SIZE; + case 3: + case "LITE_RUNTIME": + return FileOptions_OptimizeMode.LITE_RUNTIME; + case -1: + case "UNRECOGNIZED": + default: + return FileOptions_OptimizeMode.UNRECOGNIZED; + } +} + +export function fileOptions_OptimizeModeToJSON( + object: FileOptions_OptimizeMode +): string { + switch (object) { + case FileOptions_OptimizeMode.SPEED: + return "SPEED"; + case FileOptions_OptimizeMode.CODE_SIZE: + return "CODE_SIZE"; + case FileOptions_OptimizeMode.LITE_RUNTIME: + return "LITE_RUNTIME"; + default: + return "UNKNOWN"; + } +} + +export interface MessageOptions { + /** + * Set true to use the old proto1 MessageSet wire format for extensions. + * This is provided for backwards-compatibility with the MessageSet wire + * format. You should not use this for any other reason: It's less + * efficient, has fewer features, and is more complicated. + * + * The message must be defined exactly as follows: + * message Foo { + * option message_set_wire_format = true; + * extensions 4 to max; + * } + * Note that the message cannot have any defined fields; MessageSets only + * have extensions. + * + * All extensions of your type must be singular messages; e.g. they cannot + * be int32s, enums, or repeated messages. + * + * Because this is an option, the above two restrictions are not enforced by + * the protocol compiler. + */ + messageSetWireFormat: boolean; + /** + * Disables the generation of the standard "descriptor()" accessor, which can + * conflict with a field of the same name. This is meant to make migration + * from proto1 easier; new code should avoid fields named "descriptor". + */ + noStandardDescriptorAccessor: boolean; + /** + * Is this message deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the message, or it will be completely ignored; in the very least, + * this is a formalization for deprecating messages. + */ + deprecated: boolean; + /** + * Whether the message is an automatically generated map entry type for the + * maps field. + * + * For maps fields: + * map map_field = 1; + * The parsed descriptor looks like: + * message MapFieldEntry { + * option map_entry = true; + * optional KeyType key = 1; + * optional ValueType value = 2; + * } + * repeated MapFieldEntry map_field = 1; + * + * Implementations may choose not to generate the map_entry=true message, but + * use a native map in the target language to hold the keys and values. + * The reflection APIs in such implementations still need to work as + * if the field is a repeated message field. + * + * NOTE: Do not set the option in .proto files. Always use the maps syntax + * instead. The option should only be implicitly set by the proto compiler + * parser. + */ + mapEntry: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface FieldOptions { + /** + * The ctype option instructs the C++ code generator to use a different + * representation of the field than it normally would. See the specific + * options below. This option is not yet implemented in the open source + * release -- sorry, we'll try to include it in a future version! + */ + ctype: FieldOptions_CType; + /** + * The packed option can be enabled for repeated primitive fields to enable + * a more efficient representation on the wire. Rather than repeatedly + * writing the tag and type for each element, the entire array is encoded as + * a single length-delimited blob. In proto3, only explicit setting it to + * false will avoid using packed encoding. + */ + packed: boolean; + /** + * The jstype option determines the JavaScript type used for values of the + * field. The option is permitted only for 64 bit integral and fixed types + * (int64, uint64, sint64, fixed64, sfixed64). A field with jstype JS_STRING + * is represented as JavaScript string, which avoids loss of precision that + * can happen when a large value is converted to a floating point JavaScript. + * Specifying JS_NUMBER for the jstype causes the generated JavaScript code to + * use the JavaScript "number" type. The behavior of the default option + * JS_NORMAL is implementation dependent. + * + * This option is an enum to permit additional types to be added, e.g. + * goog.math.Integer. + */ + jstype: FieldOptions_JSType; + /** + * Should this field be parsed lazily? Lazy applies only to message-type + * fields. It means that when the outer message is initially parsed, the + * inner message's contents will not be parsed but instead stored in encoded + * form. The inner message will actually be parsed when it is first accessed. + * + * This is only a hint. Implementations are free to choose whether to use + * eager or lazy parsing regardless of the value of this option. However, + * setting this option true suggests that the protocol author believes that + * using lazy parsing on this field is worth the additional bookkeeping + * overhead typically needed to implement it. + * + * This option does not affect the public interface of any generated code; + * all method signatures remain the same. Furthermore, thread-safety of the + * interface is not affected by this option; const methods remain safe to + * call from multiple threads concurrently, while non-const methods continue + * to require exclusive access. + * + * + * Note that implementations may choose not to check required fields within + * a lazy sub-message. That is, calling IsInitialized() on the outer message + * may return true even if the inner message has missing required fields. + * This is necessary because otherwise the inner message would have to be + * parsed in order to perform the check, defeating the purpose of lazy + * parsing. An implementation which chooses not to check required fields + * must be consistent about it. That is, for any particular sub-message, the + * implementation must either *always* check its required fields, or *never* + * check its required fields, regardless of whether or not the message has + * been parsed. + */ + lazy: boolean; + /** + * Is this field deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for accessors, or it will be completely ignored; in the very least, this + * is a formalization for deprecating fields. + */ + deprecated: boolean; + /** For Google-internal migration only. Do not use. */ + weak: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export enum FieldOptions_CType { + /** STRING - Default mode. */ + STRING = 0, + CORD = 1, + STRING_PIECE = 2, + UNRECOGNIZED = -1, +} + +export function fieldOptions_CTypeFromJSON(object: any): FieldOptions_CType { + switch (object) { + case 0: + case "STRING": + return FieldOptions_CType.STRING; + case 1: + case "CORD": + return FieldOptions_CType.CORD; + case 2: + case "STRING_PIECE": + return FieldOptions_CType.STRING_PIECE; + case -1: + case "UNRECOGNIZED": + default: + return FieldOptions_CType.UNRECOGNIZED; + } +} + +export function fieldOptions_CTypeToJSON(object: FieldOptions_CType): string { + switch (object) { + case FieldOptions_CType.STRING: + return "STRING"; + case FieldOptions_CType.CORD: + return "CORD"; + case FieldOptions_CType.STRING_PIECE: + return "STRING_PIECE"; + default: + return "UNKNOWN"; + } +} + +export enum FieldOptions_JSType { + /** JS_NORMAL - Use the default type. */ + JS_NORMAL = 0, + /** JS_STRING - Use JavaScript strings. */ + JS_STRING = 1, + /** JS_NUMBER - Use JavaScript numbers. */ + JS_NUMBER = 2, + UNRECOGNIZED = -1, +} + +export function fieldOptions_JSTypeFromJSON(object: any): FieldOptions_JSType { + switch (object) { + case 0: + case "JS_NORMAL": + return FieldOptions_JSType.JS_NORMAL; + case 1: + case "JS_STRING": + return FieldOptions_JSType.JS_STRING; + case 2: + case "JS_NUMBER": + return FieldOptions_JSType.JS_NUMBER; + case -1: + case "UNRECOGNIZED": + default: + return FieldOptions_JSType.UNRECOGNIZED; + } +} + +export function fieldOptions_JSTypeToJSON(object: FieldOptions_JSType): string { + switch (object) { + case FieldOptions_JSType.JS_NORMAL: + return "JS_NORMAL"; + case FieldOptions_JSType.JS_STRING: + return "JS_STRING"; + case FieldOptions_JSType.JS_NUMBER: + return "JS_NUMBER"; + default: + return "UNKNOWN"; + } +} + +export interface OneofOptions { + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface EnumOptions { + /** + * Set this option to true to allow mapping different tag names to the same + * value. + */ + allowAlias: boolean; + /** + * Is this enum deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the enum, or it will be completely ignored; in the very least, this + * is a formalization for deprecating enums. + */ + deprecated: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface EnumValueOptions { + /** + * Is this enum value deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the enum value, or it will be completely ignored; in the very least, + * this is a formalization for deprecating enum values. + */ + deprecated: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface ServiceOptions { + /** + * Is this service deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the service, or it will be completely ignored; in the very least, + * this is a formalization for deprecating services. + */ + deprecated: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface MethodOptions { + /** + * Is this method deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the method, or it will be completely ignored; in the very least, + * this is a formalization for deprecating methods. + */ + deprecated: boolean; + idempotencyLevel: MethodOptions_IdempotencyLevel; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +/** + * Is this method side-effect-free (or safe in HTTP parlance), or idempotent, + * or neither? HTTP based RPC implementation may choose GET verb for safe + * methods, and PUT verb for idempotent methods instead of the default POST. + */ +export enum MethodOptions_IdempotencyLevel { + IDEMPOTENCY_UNKNOWN = 0, + /** NO_SIDE_EFFECTS - implies idempotent */ + NO_SIDE_EFFECTS = 1, + /** IDEMPOTENT - idempotent, but may have side effects */ + IDEMPOTENT = 2, + UNRECOGNIZED = -1, +} + +export function methodOptions_IdempotencyLevelFromJSON( + object: any +): MethodOptions_IdempotencyLevel { + switch (object) { + case 0: + case "IDEMPOTENCY_UNKNOWN": + return MethodOptions_IdempotencyLevel.IDEMPOTENCY_UNKNOWN; + case 1: + case "NO_SIDE_EFFECTS": + return MethodOptions_IdempotencyLevel.NO_SIDE_EFFECTS; + case 2: + case "IDEMPOTENT": + return MethodOptions_IdempotencyLevel.IDEMPOTENT; + case -1: + case "UNRECOGNIZED": + default: + return MethodOptions_IdempotencyLevel.UNRECOGNIZED; + } +} + +export function methodOptions_IdempotencyLevelToJSON( + object: MethodOptions_IdempotencyLevel +): string { + switch (object) { + case MethodOptions_IdempotencyLevel.IDEMPOTENCY_UNKNOWN: + return "IDEMPOTENCY_UNKNOWN"; + case MethodOptions_IdempotencyLevel.NO_SIDE_EFFECTS: + return "NO_SIDE_EFFECTS"; + case MethodOptions_IdempotencyLevel.IDEMPOTENT: + return "IDEMPOTENT"; + default: + return "UNKNOWN"; + } +} + +/** + * A message representing a option the parser does not recognize. This only + * appears in options protos created by the compiler::Parser class. + * DescriptorPool resolves these when building Descriptor objects. Therefore, + * options protos in descriptor objects (e.g. returned by Descriptor::options(), + * or produced by Descriptor::CopyTo()) will never have UninterpretedOptions + * in them. + */ +export interface UninterpretedOption { + name: UninterpretedOption_NamePart[]; + /** + * The value of the uninterpreted option, in whatever type the tokenizer + * identified it as during parsing. Exactly one of these should be set. + */ + identifierValue: string; + positiveIntValue: number; + negativeIntValue: number; + doubleValue: number; + stringValue: Uint8Array; + aggregateValue: string; +} + +/** + * The name of the uninterpreted option. Each string represents a segment in + * a dot-separated name. is_extension is true iff a segment represents an + * extension (denoted with parentheses in options specs in .proto files). + * E.g.,{ ["foo", false], ["bar.baz", true], ["qux", false] } represents + * "foo.(bar.baz).qux". + */ +export interface UninterpretedOption_NamePart { + namePart: string; + isExtension: boolean; +} + +/** + * Encapsulates information about the original source file from which a + * FileDescriptorProto was generated. + */ +export interface SourceCodeInfo { + /** + * A Location identifies a piece of source code in a .proto file which + * corresponds to a particular definition. This information is intended + * to be useful to IDEs, code indexers, documentation generators, and similar + * tools. + * + * For example, say we have a file like: + * message Foo { + * optional string foo = 1; + * } + * Let's look at just the field definition: + * optional string foo = 1; + * ^ ^^ ^^ ^ ^^^ + * a bc de f ghi + * We have the following locations: + * span path represents + * [a,i) [ 4, 0, 2, 0 ] The whole field definition. + * [a,b) [ 4, 0, 2, 0, 4 ] The label (optional). + * [c,d) [ 4, 0, 2, 0, 5 ] The type (string). + * [e,f) [ 4, 0, 2, 0, 1 ] The name (foo). + * [g,h) [ 4, 0, 2, 0, 3 ] The number (1). + * + * Notes: + * - A location may refer to a repeated field itself (i.e. not to any + * particular index within it). This is used whenever a set of elements are + * logically enclosed in a single code segment. For example, an entire + * extend block (possibly containing multiple extension definitions) will + * have an outer location whose path refers to the "extensions" repeated + * field without an index. + * - Multiple locations may have the same path. This happens when a single + * logical declaration is spread out across multiple places. The most + * obvious example is the "extend" block again -- there may be multiple + * extend blocks in the same scope, each of which will have the same path. + * - A location's span is not always a subset of its parent's span. For + * example, the "extendee" of an extension declaration appears at the + * beginning of the "extend" block and is shared by all extensions within + * the block. + * - Just because a location's span is a subset of some other location's span + * does not mean that it is a descendant. For example, a "group" defines + * both a type and a field in a single declaration. Thus, the locations + * corresponding to the type and field and their components will overlap. + * - Code which tries to interpret locations should probably be designed to + * ignore those that it doesn't understand, as more types of locations could + * be recorded in the future. + */ + location: SourceCodeInfo_Location[]; +} + +export interface SourceCodeInfo_Location { + /** + * Identifies which part of the FileDescriptorProto was defined at this + * location. + * + * Each element is a field number or an index. They form a path from + * the root FileDescriptorProto to the place where the definition. For + * example, this path: + * [ 4, 3, 2, 7, 1 ] + * refers to: + * file.message_type(3) // 4, 3 + * .field(7) // 2, 7 + * .name() // 1 + * This is because FileDescriptorProto.message_type has field number 4: + * repeated DescriptorProto message_type = 4; + * and DescriptorProto.field has field number 2: + * repeated FieldDescriptorProto field = 2; + * and FieldDescriptorProto.name has field number 1: + * optional string name = 1; + * + * Thus, the above path gives the location of a field name. If we removed + * the last element: + * [ 4, 3, 2, 7 ] + * this path refers to the whole field declaration (from the beginning + * of the label to the terminating semicolon). + */ + path: number[]; + /** + * Always has exactly three or four elements: start line, start column, + * end line (optional, otherwise assumed same as start line), end column. + * These are packed into a single field for efficiency. Note that line + * and column numbers are zero-based -- typically you will want to add + * 1 to each before displaying to a user. + */ + span: number[]; + /** + * If this SourceCodeInfo represents a complete declaration, these are any + * comments appearing before and after the declaration which appear to be + * attached to the declaration. + * + * A series of line comments appearing on consecutive lines, with no other + * tokens appearing on those lines, will be treated as a single comment. + * + * leading_detached_comments will keep paragraphs of comments that appear + * before (but not connected to) the current element. Each paragraph, + * separated by empty lines, will be one comment element in the repeated + * field. + * + * Only the comment content is provided; comment markers (e.g. //) are + * stripped out. For block comments, leading whitespace and an asterisk + * will be stripped from the beginning of each line other than the first. + * Newlines are included in the output. + * + * Examples: + * + * optional int32 foo = 1; // Comment attached to foo. + * // Comment attached to bar. + * optional int32 bar = 2; + * + * optional string baz = 3; + * // Comment attached to baz. + * // Another line attached to baz. + * + * // Comment attached to qux. + * // + * // Another line attached to qux. + * optional double qux = 4; + * + * // Detached comment for corge. This is not leading or trailing comments + * // to qux or corge because there are blank lines separating it from + * // both. + * + * // Detached comment for corge paragraph 2. + * + * optional string corge = 5; + * /* Block comment attached + * * to corge. Leading asterisks + * * will be removed. * / + * /* Block comment attached to + * * grault. * / + * optional int32 grault = 6; + * + * // ignored detached comments. + */ + leadingComments: string; + trailingComments: string; + leadingDetachedComments: string[]; +} + +/** + * Describes the relationship between generated code and its original source + * file. A GeneratedCodeInfo message is associated with only one generated + * source file, but may contain references to different source .proto files. + */ +export interface GeneratedCodeInfo { + /** + * An Annotation connects some span of text in generated code to an element + * of its generating .proto file. + */ + annotation: GeneratedCodeInfo_Annotation[]; +} + +export interface GeneratedCodeInfo_Annotation { + /** + * Identifies the element in the original source .proto file. This field + * is formatted the same as SourceCodeInfo.Location.path. + */ + path: number[]; + /** Identifies the filesystem path to the original source .proto. */ + sourceFile: string; + /** + * Identifies the starting offset in bytes in the generated code + * that relates to the identified object. + */ + begin: number; + /** + * Identifies the ending offset in bytes in the generated code that + * relates to the identified offset. The end offset should be one past + * the last relevant byte (so the length of the text = end - begin). + */ + end: number; +} + +const baseFileDescriptorSet: object = {}; + +export const FileDescriptorSet = { + encode(message: FileDescriptorSet, writer: Writer = Writer.create()): Writer { + for (const v of message.file) { + FileDescriptorProto.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FileDescriptorSet { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFileDescriptorSet } as FileDescriptorSet; + message.file = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.file.push( + FileDescriptorProto.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FileDescriptorSet { + const message = { ...baseFileDescriptorSet } as FileDescriptorSet; + message.file = []; + if (object.file !== undefined && object.file !== null) { + for (const e of object.file) { + message.file.push(FileDescriptorProto.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: FileDescriptorSet): unknown { + const obj: any = {}; + if (message.file) { + obj.file = message.file.map((e) => + e ? FileDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.file = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): FileDescriptorSet { + const message = { ...baseFileDescriptorSet } as FileDescriptorSet; + message.file = []; + if (object.file !== undefined && object.file !== null) { + for (const e of object.file) { + message.file.push(FileDescriptorProto.fromPartial(e)); + } + } + return message; + }, +}; + +const baseFileDescriptorProto: object = { + name: "", + package: "", + dependency: "", + publicDependency: 0, + weakDependency: 0, + syntax: "", +}; + +export const FileDescriptorProto = { + encode( + message: FileDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.package !== "") { + writer.uint32(18).string(message.package); + } + for (const v of message.dependency) { + writer.uint32(26).string(v!); + } + writer.uint32(82).fork(); + for (const v of message.publicDependency) { + writer.int32(v); + } + writer.ldelim(); + writer.uint32(90).fork(); + for (const v of message.weakDependency) { + writer.int32(v); + } + writer.ldelim(); + for (const v of message.messageType) { + DescriptorProto.encode(v!, writer.uint32(34).fork()).ldelim(); + } + for (const v of message.enumType) { + EnumDescriptorProto.encode(v!, writer.uint32(42).fork()).ldelim(); + } + for (const v of message.service) { + ServiceDescriptorProto.encode(v!, writer.uint32(50).fork()).ldelim(); + } + for (const v of message.extension) { + FieldDescriptorProto.encode(v!, writer.uint32(58).fork()).ldelim(); + } + if (message.options !== undefined) { + FileOptions.encode(message.options, writer.uint32(66).fork()).ldelim(); + } + if (message.sourceCodeInfo !== undefined) { + SourceCodeInfo.encode( + message.sourceCodeInfo, + writer.uint32(74).fork() + ).ldelim(); + } + if (message.syntax !== "") { + writer.uint32(98).string(message.syntax); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FileDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFileDescriptorProto } as FileDescriptorProto; + message.dependency = []; + message.publicDependency = []; + message.weakDependency = []; + message.messageType = []; + message.enumType = []; + message.service = []; + message.extension = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.package = reader.string(); + break; + case 3: + message.dependency.push(reader.string()); + break; + case 10: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.publicDependency.push(reader.int32()); + } + } else { + message.publicDependency.push(reader.int32()); + } + break; + case 11: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.weakDependency.push(reader.int32()); + } + } else { + message.weakDependency.push(reader.int32()); + } + break; + case 4: + message.messageType.push( + DescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 5: + message.enumType.push( + EnumDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 6: + message.service.push( + ServiceDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 7: + message.extension.push( + FieldDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 8: + message.options = FileOptions.decode(reader, reader.uint32()); + break; + case 9: + message.sourceCodeInfo = SourceCodeInfo.decode( + reader, + reader.uint32() + ); + break; + case 12: + message.syntax = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FileDescriptorProto { + const message = { ...baseFileDescriptorProto } as FileDescriptorProto; + message.dependency = []; + message.publicDependency = []; + message.weakDependency = []; + message.messageType = []; + message.enumType = []; + message.service = []; + message.extension = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.package !== undefined && object.package !== null) { + message.package = String(object.package); + } else { + message.package = ""; + } + if (object.dependency !== undefined && object.dependency !== null) { + for (const e of object.dependency) { + message.dependency.push(String(e)); + } + } + if ( + object.publicDependency !== undefined && + object.publicDependency !== null + ) { + for (const e of object.publicDependency) { + message.publicDependency.push(Number(e)); + } + } + if (object.weakDependency !== undefined && object.weakDependency !== null) { + for (const e of object.weakDependency) { + message.weakDependency.push(Number(e)); + } + } + if (object.messageType !== undefined && object.messageType !== null) { + for (const e of object.messageType) { + message.messageType.push(DescriptorProto.fromJSON(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromJSON(e)); + } + } + if (object.service !== undefined && object.service !== null) { + for (const e of object.service) { + message.service.push(ServiceDescriptorProto.fromJSON(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = FileOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.sourceCodeInfo !== undefined && object.sourceCodeInfo !== null) { + message.sourceCodeInfo = SourceCodeInfo.fromJSON(object.sourceCodeInfo); + } else { + message.sourceCodeInfo = undefined; + } + if (object.syntax !== undefined && object.syntax !== null) { + message.syntax = String(object.syntax); + } else { + message.syntax = ""; + } + return message; + }, + + toJSON(message: FileDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.package !== undefined && (obj.package = message.package); + if (message.dependency) { + obj.dependency = message.dependency.map((e) => e); + } else { + obj.dependency = []; + } + if (message.publicDependency) { + obj.publicDependency = message.publicDependency.map((e) => e); + } else { + obj.publicDependency = []; + } + if (message.weakDependency) { + obj.weakDependency = message.weakDependency.map((e) => e); + } else { + obj.weakDependency = []; + } + if (message.messageType) { + obj.messageType = message.messageType.map((e) => + e ? DescriptorProto.toJSON(e) : undefined + ); + } else { + obj.messageType = []; + } + if (message.enumType) { + obj.enumType = message.enumType.map((e) => + e ? EnumDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.enumType = []; + } + if (message.service) { + obj.service = message.service.map((e) => + e ? ServiceDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.service = []; + } + if (message.extension) { + obj.extension = message.extension.map((e) => + e ? FieldDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.extension = []; + } + message.options !== undefined && + (obj.options = message.options + ? FileOptions.toJSON(message.options) + : undefined); + message.sourceCodeInfo !== undefined && + (obj.sourceCodeInfo = message.sourceCodeInfo + ? SourceCodeInfo.toJSON(message.sourceCodeInfo) + : undefined); + message.syntax !== undefined && (obj.syntax = message.syntax); + return obj; + }, + + fromPartial(object: DeepPartial): FileDescriptorProto { + const message = { ...baseFileDescriptorProto } as FileDescriptorProto; + message.dependency = []; + message.publicDependency = []; + message.weakDependency = []; + message.messageType = []; + message.enumType = []; + message.service = []; + message.extension = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.package !== undefined && object.package !== null) { + message.package = object.package; + } else { + message.package = ""; + } + if (object.dependency !== undefined && object.dependency !== null) { + for (const e of object.dependency) { + message.dependency.push(e); + } + } + if ( + object.publicDependency !== undefined && + object.publicDependency !== null + ) { + for (const e of object.publicDependency) { + message.publicDependency.push(e); + } + } + if (object.weakDependency !== undefined && object.weakDependency !== null) { + for (const e of object.weakDependency) { + message.weakDependency.push(e); + } + } + if (object.messageType !== undefined && object.messageType !== null) { + for (const e of object.messageType) { + message.messageType.push(DescriptorProto.fromPartial(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromPartial(e)); + } + } + if (object.service !== undefined && object.service !== null) { + for (const e of object.service) { + message.service.push(ServiceDescriptorProto.fromPartial(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = FileOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.sourceCodeInfo !== undefined && object.sourceCodeInfo !== null) { + message.sourceCodeInfo = SourceCodeInfo.fromPartial( + object.sourceCodeInfo + ); + } else { + message.sourceCodeInfo = undefined; + } + if (object.syntax !== undefined && object.syntax !== null) { + message.syntax = object.syntax; + } else { + message.syntax = ""; + } + return message; + }, +}; + +const baseDescriptorProto: object = { name: "", reservedName: "" }; + +export const DescriptorProto = { + encode(message: DescriptorProto, writer: Writer = Writer.create()): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + for (const v of message.field) { + FieldDescriptorProto.encode(v!, writer.uint32(18).fork()).ldelim(); + } + for (const v of message.extension) { + FieldDescriptorProto.encode(v!, writer.uint32(50).fork()).ldelim(); + } + for (const v of message.nestedType) { + DescriptorProto.encode(v!, writer.uint32(26).fork()).ldelim(); + } + for (const v of message.enumType) { + EnumDescriptorProto.encode(v!, writer.uint32(34).fork()).ldelim(); + } + for (const v of message.extensionRange) { + DescriptorProto_ExtensionRange.encode( + v!, + writer.uint32(42).fork() + ).ldelim(); + } + for (const v of message.oneofDecl) { + OneofDescriptorProto.encode(v!, writer.uint32(66).fork()).ldelim(); + } + if (message.options !== undefined) { + MessageOptions.encode(message.options, writer.uint32(58).fork()).ldelim(); + } + for (const v of message.reservedRange) { + DescriptorProto_ReservedRange.encode( + v!, + writer.uint32(74).fork() + ).ldelim(); + } + for (const v of message.reservedName) { + writer.uint32(82).string(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): DescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseDescriptorProto } as DescriptorProto; + message.field = []; + message.extension = []; + message.nestedType = []; + message.enumType = []; + message.extensionRange = []; + message.oneofDecl = []; + message.reservedRange = []; + message.reservedName = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.field.push( + FieldDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 6: + message.extension.push( + FieldDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 3: + message.nestedType.push( + DescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 4: + message.enumType.push( + EnumDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 5: + message.extensionRange.push( + DescriptorProto_ExtensionRange.decode(reader, reader.uint32()) + ); + break; + case 8: + message.oneofDecl.push( + OneofDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 7: + message.options = MessageOptions.decode(reader, reader.uint32()); + break; + case 9: + message.reservedRange.push( + DescriptorProto_ReservedRange.decode(reader, reader.uint32()) + ); + break; + case 10: + message.reservedName.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DescriptorProto { + const message = { ...baseDescriptorProto } as DescriptorProto; + message.field = []; + message.extension = []; + message.nestedType = []; + message.enumType = []; + message.extensionRange = []; + message.oneofDecl = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.field !== undefined && object.field !== null) { + for (const e of object.field) { + message.field.push(FieldDescriptorProto.fromJSON(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromJSON(e)); + } + } + if (object.nestedType !== undefined && object.nestedType !== null) { + for (const e of object.nestedType) { + message.nestedType.push(DescriptorProto.fromJSON(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromJSON(e)); + } + } + if (object.extensionRange !== undefined && object.extensionRange !== null) { + for (const e of object.extensionRange) { + message.extensionRange.push(DescriptorProto_ExtensionRange.fromJSON(e)); + } + } + if (object.oneofDecl !== undefined && object.oneofDecl !== null) { + for (const e of object.oneofDecl) { + message.oneofDecl.push(OneofDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = MessageOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push(DescriptorProto_ReservedRange.fromJSON(e)); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(String(e)); + } + } + return message; + }, + + toJSON(message: DescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + if (message.field) { + obj.field = message.field.map((e) => + e ? FieldDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.field = []; + } + if (message.extension) { + obj.extension = message.extension.map((e) => + e ? FieldDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.extension = []; + } + if (message.nestedType) { + obj.nestedType = message.nestedType.map((e) => + e ? DescriptorProto.toJSON(e) : undefined + ); + } else { + obj.nestedType = []; + } + if (message.enumType) { + obj.enumType = message.enumType.map((e) => + e ? EnumDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.enumType = []; + } + if (message.extensionRange) { + obj.extensionRange = message.extensionRange.map((e) => + e ? DescriptorProto_ExtensionRange.toJSON(e) : undefined + ); + } else { + obj.extensionRange = []; + } + if (message.oneofDecl) { + obj.oneofDecl = message.oneofDecl.map((e) => + e ? OneofDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.oneofDecl = []; + } + message.options !== undefined && + (obj.options = message.options + ? MessageOptions.toJSON(message.options) + : undefined); + if (message.reservedRange) { + obj.reservedRange = message.reservedRange.map((e) => + e ? DescriptorProto_ReservedRange.toJSON(e) : undefined + ); + } else { + obj.reservedRange = []; + } + if (message.reservedName) { + obj.reservedName = message.reservedName.map((e) => e); + } else { + obj.reservedName = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): DescriptorProto { + const message = { ...baseDescriptorProto } as DescriptorProto; + message.field = []; + message.extension = []; + message.nestedType = []; + message.enumType = []; + message.extensionRange = []; + message.oneofDecl = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.field !== undefined && object.field !== null) { + for (const e of object.field) { + message.field.push(FieldDescriptorProto.fromPartial(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromPartial(e)); + } + } + if (object.nestedType !== undefined && object.nestedType !== null) { + for (const e of object.nestedType) { + message.nestedType.push(DescriptorProto.fromPartial(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromPartial(e)); + } + } + if (object.extensionRange !== undefined && object.extensionRange !== null) { + for (const e of object.extensionRange) { + message.extensionRange.push( + DescriptorProto_ExtensionRange.fromPartial(e) + ); + } + } + if (object.oneofDecl !== undefined && object.oneofDecl !== null) { + for (const e of object.oneofDecl) { + message.oneofDecl.push(OneofDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = MessageOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push( + DescriptorProto_ReservedRange.fromPartial(e) + ); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(e); + } + } + return message; + }, +}; + +const baseDescriptorProto_ExtensionRange: object = { start: 0, end: 0 }; + +export const DescriptorProto_ExtensionRange = { + encode( + message: DescriptorProto_ExtensionRange, + writer: Writer = Writer.create() + ): Writer { + if (message.start !== 0) { + writer.uint32(8).int32(message.start); + } + if (message.end !== 0) { + writer.uint32(16).int32(message.end); + } + if (message.options !== undefined) { + ExtensionRangeOptions.encode( + message.options, + writer.uint32(26).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): DescriptorProto_ExtensionRange { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseDescriptorProto_ExtensionRange, + } as DescriptorProto_ExtensionRange; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.start = reader.int32(); + break; + case 2: + message.end = reader.int32(); + break; + case 3: + message.options = ExtensionRangeOptions.decode( + reader, + reader.uint32() + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DescriptorProto_ExtensionRange { + const message = { + ...baseDescriptorProto_ExtensionRange, + } as DescriptorProto_ExtensionRange; + if (object.start !== undefined && object.start !== null) { + message.start = Number(object.start); + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = ExtensionRangeOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: DescriptorProto_ExtensionRange): unknown { + const obj: any = {}; + message.start !== undefined && (obj.start = message.start); + message.end !== undefined && (obj.end = message.end); + message.options !== undefined && + (obj.options = message.options + ? ExtensionRangeOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): DescriptorProto_ExtensionRange { + const message = { + ...baseDescriptorProto_ExtensionRange, + } as DescriptorProto_ExtensionRange; + if (object.start !== undefined && object.start !== null) { + message.start = object.start; + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = ExtensionRangeOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseDescriptorProto_ReservedRange: object = { start: 0, end: 0 }; + +export const DescriptorProto_ReservedRange = { + encode( + message: DescriptorProto_ReservedRange, + writer: Writer = Writer.create() + ): Writer { + if (message.start !== 0) { + writer.uint32(8).int32(message.start); + } + if (message.end !== 0) { + writer.uint32(16).int32(message.end); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): DescriptorProto_ReservedRange { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseDescriptorProto_ReservedRange, + } as DescriptorProto_ReservedRange; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.start = reader.int32(); + break; + case 2: + message.end = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DescriptorProto_ReservedRange { + const message = { + ...baseDescriptorProto_ReservedRange, + } as DescriptorProto_ReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = Number(object.start); + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + return message; + }, + + toJSON(message: DescriptorProto_ReservedRange): unknown { + const obj: any = {}; + message.start !== undefined && (obj.start = message.start); + message.end !== undefined && (obj.end = message.end); + return obj; + }, + + fromPartial( + object: DeepPartial + ): DescriptorProto_ReservedRange { + const message = { + ...baseDescriptorProto_ReservedRange, + } as DescriptorProto_ReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = object.start; + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + return message; + }, +}; + +const baseExtensionRangeOptions: object = {}; + +export const ExtensionRangeOptions = { + encode( + message: ExtensionRangeOptions, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ExtensionRangeOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseExtensionRangeOptions } as ExtensionRangeOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ExtensionRangeOptions { + const message = { ...baseExtensionRangeOptions } as ExtensionRangeOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: ExtensionRangeOptions): unknown { + const obj: any = {}; + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial( + object: DeepPartial + ): ExtensionRangeOptions { + const message = { ...baseExtensionRangeOptions } as ExtensionRangeOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseFieldDescriptorProto: object = { + name: "", + number: 0, + label: 1, + type: 1, + typeName: "", + extendee: "", + defaultValue: "", + oneofIndex: 0, + jsonName: "", + proto3Optional: false, +}; + +export const FieldDescriptorProto = { + encode( + message: FieldDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.number !== 0) { + writer.uint32(24).int32(message.number); + } + if (message.label !== 1) { + writer.uint32(32).int32(message.label); + } + if (message.type !== 1) { + writer.uint32(40).int32(message.type); + } + if (message.typeName !== "") { + writer.uint32(50).string(message.typeName); + } + if (message.extendee !== "") { + writer.uint32(18).string(message.extendee); + } + if (message.defaultValue !== "") { + writer.uint32(58).string(message.defaultValue); + } + if (message.oneofIndex !== 0) { + writer.uint32(72).int32(message.oneofIndex); + } + if (message.jsonName !== "") { + writer.uint32(82).string(message.jsonName); + } + if (message.options !== undefined) { + FieldOptions.encode(message.options, writer.uint32(66).fork()).ldelim(); + } + if (message.proto3Optional === true) { + writer.uint32(136).bool(message.proto3Optional); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FieldDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFieldDescriptorProto } as FieldDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 3: + message.number = reader.int32(); + break; + case 4: + message.label = reader.int32() as any; + break; + case 5: + message.type = reader.int32() as any; + break; + case 6: + message.typeName = reader.string(); + break; + case 2: + message.extendee = reader.string(); + break; + case 7: + message.defaultValue = reader.string(); + break; + case 9: + message.oneofIndex = reader.int32(); + break; + case 10: + message.jsonName = reader.string(); + break; + case 8: + message.options = FieldOptions.decode(reader, reader.uint32()); + break; + case 17: + message.proto3Optional = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FieldDescriptorProto { + const message = { ...baseFieldDescriptorProto } as FieldDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = Number(object.number); + } else { + message.number = 0; + } + if (object.label !== undefined && object.label !== null) { + message.label = fieldDescriptorProto_LabelFromJSON(object.label); + } else { + message.label = 1; + } + if (object.type !== undefined && object.type !== null) { + message.type = fieldDescriptorProto_TypeFromJSON(object.type); + } else { + message.type = 1; + } + if (object.typeName !== undefined && object.typeName !== null) { + message.typeName = String(object.typeName); + } else { + message.typeName = ""; + } + if (object.extendee !== undefined && object.extendee !== null) { + message.extendee = String(object.extendee); + } else { + message.extendee = ""; + } + if (object.defaultValue !== undefined && object.defaultValue !== null) { + message.defaultValue = String(object.defaultValue); + } else { + message.defaultValue = ""; + } + if (object.oneofIndex !== undefined && object.oneofIndex !== null) { + message.oneofIndex = Number(object.oneofIndex); + } else { + message.oneofIndex = 0; + } + if (object.jsonName !== undefined && object.jsonName !== null) { + message.jsonName = String(object.jsonName); + } else { + message.jsonName = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = FieldOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.proto3Optional !== undefined && object.proto3Optional !== null) { + message.proto3Optional = Boolean(object.proto3Optional); + } else { + message.proto3Optional = false; + } + return message; + }, + + toJSON(message: FieldDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.number !== undefined && (obj.number = message.number); + message.label !== undefined && + (obj.label = fieldDescriptorProto_LabelToJSON(message.label)); + message.type !== undefined && + (obj.type = fieldDescriptorProto_TypeToJSON(message.type)); + message.typeName !== undefined && (obj.typeName = message.typeName); + message.extendee !== undefined && (obj.extendee = message.extendee); + message.defaultValue !== undefined && + (obj.defaultValue = message.defaultValue); + message.oneofIndex !== undefined && (obj.oneofIndex = message.oneofIndex); + message.jsonName !== undefined && (obj.jsonName = message.jsonName); + message.options !== undefined && + (obj.options = message.options + ? FieldOptions.toJSON(message.options) + : undefined); + message.proto3Optional !== undefined && + (obj.proto3Optional = message.proto3Optional); + return obj; + }, + + fromPartial(object: DeepPartial): FieldDescriptorProto { + const message = { ...baseFieldDescriptorProto } as FieldDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = object.number; + } else { + message.number = 0; + } + if (object.label !== undefined && object.label !== null) { + message.label = object.label; + } else { + message.label = 1; + } + if (object.type !== undefined && object.type !== null) { + message.type = object.type; + } else { + message.type = 1; + } + if (object.typeName !== undefined && object.typeName !== null) { + message.typeName = object.typeName; + } else { + message.typeName = ""; + } + if (object.extendee !== undefined && object.extendee !== null) { + message.extendee = object.extendee; + } else { + message.extendee = ""; + } + if (object.defaultValue !== undefined && object.defaultValue !== null) { + message.defaultValue = object.defaultValue; + } else { + message.defaultValue = ""; + } + if (object.oneofIndex !== undefined && object.oneofIndex !== null) { + message.oneofIndex = object.oneofIndex; + } else { + message.oneofIndex = 0; + } + if (object.jsonName !== undefined && object.jsonName !== null) { + message.jsonName = object.jsonName; + } else { + message.jsonName = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = FieldOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.proto3Optional !== undefined && object.proto3Optional !== null) { + message.proto3Optional = object.proto3Optional; + } else { + message.proto3Optional = false; + } + return message; + }, +}; + +const baseOneofDescriptorProto: object = { name: "" }; + +export const OneofDescriptorProto = { + encode( + message: OneofDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.options !== undefined) { + OneofOptions.encode(message.options, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): OneofDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseOneofDescriptorProto } as OneofDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.options = OneofOptions.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): OneofDescriptorProto { + const message = { ...baseOneofDescriptorProto } as OneofDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = OneofOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: OneofDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.options !== undefined && + (obj.options = message.options + ? OneofOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): OneofDescriptorProto { + const message = { ...baseOneofDescriptorProto } as OneofDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = OneofOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseEnumDescriptorProto: object = { name: "", reservedName: "" }; + +export const EnumDescriptorProto = { + encode( + message: EnumDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + for (const v of message.value) { + EnumValueDescriptorProto.encode(v!, writer.uint32(18).fork()).ldelim(); + } + if (message.options !== undefined) { + EnumOptions.encode(message.options, writer.uint32(26).fork()).ldelim(); + } + for (const v of message.reservedRange) { + EnumDescriptorProto_EnumReservedRange.encode( + v!, + writer.uint32(34).fork() + ).ldelim(); + } + for (const v of message.reservedName) { + writer.uint32(42).string(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): EnumDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseEnumDescriptorProto } as EnumDescriptorProto; + message.value = []; + message.reservedRange = []; + message.reservedName = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.value.push( + EnumValueDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 3: + message.options = EnumOptions.decode(reader, reader.uint32()); + break; + case 4: + message.reservedRange.push( + EnumDescriptorProto_EnumReservedRange.decode( + reader, + reader.uint32() + ) + ); + break; + case 5: + message.reservedName.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumDescriptorProto { + const message = { ...baseEnumDescriptorProto } as EnumDescriptorProto; + message.value = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.value !== undefined && object.value !== null) { + for (const e of object.value) { + message.value.push(EnumValueDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push( + EnumDescriptorProto_EnumReservedRange.fromJSON(e) + ); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(String(e)); + } + } + return message; + }, + + toJSON(message: EnumDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + if (message.value) { + obj.value = message.value.map((e) => + e ? EnumValueDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.value = []; + } + message.options !== undefined && + (obj.options = message.options + ? EnumOptions.toJSON(message.options) + : undefined); + if (message.reservedRange) { + obj.reservedRange = message.reservedRange.map((e) => + e ? EnumDescriptorProto_EnumReservedRange.toJSON(e) : undefined + ); + } else { + obj.reservedRange = []; + } + if (message.reservedName) { + obj.reservedName = message.reservedName.map((e) => e); + } else { + obj.reservedName = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): EnumDescriptorProto { + const message = { ...baseEnumDescriptorProto } as EnumDescriptorProto; + message.value = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.value !== undefined && object.value !== null) { + for (const e of object.value) { + message.value.push(EnumValueDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push( + EnumDescriptorProto_EnumReservedRange.fromPartial(e) + ); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(e); + } + } + return message; + }, +}; + +const baseEnumDescriptorProto_EnumReservedRange: object = { start: 0, end: 0 }; + +export const EnumDescriptorProto_EnumReservedRange = { + encode( + message: EnumDescriptorProto_EnumReservedRange, + writer: Writer = Writer.create() + ): Writer { + if (message.start !== 0) { + writer.uint32(8).int32(message.start); + } + if (message.end !== 0) { + writer.uint32(16).int32(message.end); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): EnumDescriptorProto_EnumReservedRange { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseEnumDescriptorProto_EnumReservedRange, + } as EnumDescriptorProto_EnumReservedRange; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.start = reader.int32(); + break; + case 2: + message.end = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumDescriptorProto_EnumReservedRange { + const message = { + ...baseEnumDescriptorProto_EnumReservedRange, + } as EnumDescriptorProto_EnumReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = Number(object.start); + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + return message; + }, + + toJSON(message: EnumDescriptorProto_EnumReservedRange): unknown { + const obj: any = {}; + message.start !== undefined && (obj.start = message.start); + message.end !== undefined && (obj.end = message.end); + return obj; + }, + + fromPartial( + object: DeepPartial + ): EnumDescriptorProto_EnumReservedRange { + const message = { + ...baseEnumDescriptorProto_EnumReservedRange, + } as EnumDescriptorProto_EnumReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = object.start; + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + return message; + }, +}; + +const baseEnumValueDescriptorProto: object = { name: "", number: 0 }; + +export const EnumValueDescriptorProto = { + encode( + message: EnumValueDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.number !== 0) { + writer.uint32(16).int32(message.number); + } + if (message.options !== undefined) { + EnumValueOptions.encode( + message.options, + writer.uint32(26).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): EnumValueDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseEnumValueDescriptorProto, + } as EnumValueDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.number = reader.int32(); + break; + case 3: + message.options = EnumValueOptions.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumValueDescriptorProto { + const message = { + ...baseEnumValueDescriptorProto, + } as EnumValueDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = Number(object.number); + } else { + message.number = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumValueOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: EnumValueDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.number !== undefined && (obj.number = message.number); + message.options !== undefined && + (obj.options = message.options + ? EnumValueOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): EnumValueDescriptorProto { + const message = { + ...baseEnumValueDescriptorProto, + } as EnumValueDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = object.number; + } else { + message.number = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumValueOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseServiceDescriptorProto: object = { name: "" }; + +export const ServiceDescriptorProto = { + encode( + message: ServiceDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + for (const v of message.method) { + MethodDescriptorProto.encode(v!, writer.uint32(18).fork()).ldelim(); + } + if (message.options !== undefined) { + ServiceOptions.encode(message.options, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ServiceDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseServiceDescriptorProto } as ServiceDescriptorProto; + message.method = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.method.push( + MethodDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 3: + message.options = ServiceOptions.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ServiceDescriptorProto { + const message = { ...baseServiceDescriptorProto } as ServiceDescriptorProto; + message.method = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.method !== undefined && object.method !== null) { + for (const e of object.method) { + message.method.push(MethodDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = ServiceOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: ServiceDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + if (message.method) { + obj.method = message.method.map((e) => + e ? MethodDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.method = []; + } + message.options !== undefined && + (obj.options = message.options + ? ServiceOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): ServiceDescriptorProto { + const message = { ...baseServiceDescriptorProto } as ServiceDescriptorProto; + message.method = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.method !== undefined && object.method !== null) { + for (const e of object.method) { + message.method.push(MethodDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = ServiceOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseMethodDescriptorProto: object = { + name: "", + inputType: "", + outputType: "", + clientStreaming: false, + serverStreaming: false, +}; + +export const MethodDescriptorProto = { + encode( + message: MethodDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.inputType !== "") { + writer.uint32(18).string(message.inputType); + } + if (message.outputType !== "") { + writer.uint32(26).string(message.outputType); + } + if (message.options !== undefined) { + MethodOptions.encode(message.options, writer.uint32(34).fork()).ldelim(); + } + if (message.clientStreaming === true) { + writer.uint32(40).bool(message.clientStreaming); + } + if (message.serverStreaming === true) { + writer.uint32(48).bool(message.serverStreaming); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MethodDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMethodDescriptorProto } as MethodDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.inputType = reader.string(); + break; + case 3: + message.outputType = reader.string(); + break; + case 4: + message.options = MethodOptions.decode(reader, reader.uint32()); + break; + case 5: + message.clientStreaming = reader.bool(); + break; + case 6: + message.serverStreaming = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MethodDescriptorProto { + const message = { ...baseMethodDescriptorProto } as MethodDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.inputType !== undefined && object.inputType !== null) { + message.inputType = String(object.inputType); + } else { + message.inputType = ""; + } + if (object.outputType !== undefined && object.outputType !== null) { + message.outputType = String(object.outputType); + } else { + message.outputType = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = MethodOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if ( + object.clientStreaming !== undefined && + object.clientStreaming !== null + ) { + message.clientStreaming = Boolean(object.clientStreaming); + } else { + message.clientStreaming = false; + } + if ( + object.serverStreaming !== undefined && + object.serverStreaming !== null + ) { + message.serverStreaming = Boolean(object.serverStreaming); + } else { + message.serverStreaming = false; + } + return message; + }, + + toJSON(message: MethodDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.inputType !== undefined && (obj.inputType = message.inputType); + message.outputType !== undefined && (obj.outputType = message.outputType); + message.options !== undefined && + (obj.options = message.options + ? MethodOptions.toJSON(message.options) + : undefined); + message.clientStreaming !== undefined && + (obj.clientStreaming = message.clientStreaming); + message.serverStreaming !== undefined && + (obj.serverStreaming = message.serverStreaming); + return obj; + }, + + fromPartial( + object: DeepPartial + ): MethodDescriptorProto { + const message = { ...baseMethodDescriptorProto } as MethodDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.inputType !== undefined && object.inputType !== null) { + message.inputType = object.inputType; + } else { + message.inputType = ""; + } + if (object.outputType !== undefined && object.outputType !== null) { + message.outputType = object.outputType; + } else { + message.outputType = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = MethodOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if ( + object.clientStreaming !== undefined && + object.clientStreaming !== null + ) { + message.clientStreaming = object.clientStreaming; + } else { + message.clientStreaming = false; + } + if ( + object.serverStreaming !== undefined && + object.serverStreaming !== null + ) { + message.serverStreaming = object.serverStreaming; + } else { + message.serverStreaming = false; + } + return message; + }, +}; + +const baseFileOptions: object = { + javaPackage: "", + javaOuterClassname: "", + javaMultipleFiles: false, + javaGenerateEqualsAndHash: false, + javaStringCheckUtf8: false, + optimizeFor: 1, + goPackage: "", + ccGenericServices: false, + javaGenericServices: false, + pyGenericServices: false, + phpGenericServices: false, + deprecated: false, + ccEnableArenas: false, + objcClassPrefix: "", + csharpNamespace: "", + swiftPrefix: "", + phpClassPrefix: "", + phpNamespace: "", + phpMetadataNamespace: "", + rubyPackage: "", +}; + +export const FileOptions = { + encode(message: FileOptions, writer: Writer = Writer.create()): Writer { + if (message.javaPackage !== "") { + writer.uint32(10).string(message.javaPackage); + } + if (message.javaOuterClassname !== "") { + writer.uint32(66).string(message.javaOuterClassname); + } + if (message.javaMultipleFiles === true) { + writer.uint32(80).bool(message.javaMultipleFiles); + } + if (message.javaGenerateEqualsAndHash === true) { + writer.uint32(160).bool(message.javaGenerateEqualsAndHash); + } + if (message.javaStringCheckUtf8 === true) { + writer.uint32(216).bool(message.javaStringCheckUtf8); + } + if (message.optimizeFor !== 1) { + writer.uint32(72).int32(message.optimizeFor); + } + if (message.goPackage !== "") { + writer.uint32(90).string(message.goPackage); + } + if (message.ccGenericServices === true) { + writer.uint32(128).bool(message.ccGenericServices); + } + if (message.javaGenericServices === true) { + writer.uint32(136).bool(message.javaGenericServices); + } + if (message.pyGenericServices === true) { + writer.uint32(144).bool(message.pyGenericServices); + } + if (message.phpGenericServices === true) { + writer.uint32(336).bool(message.phpGenericServices); + } + if (message.deprecated === true) { + writer.uint32(184).bool(message.deprecated); + } + if (message.ccEnableArenas === true) { + writer.uint32(248).bool(message.ccEnableArenas); + } + if (message.objcClassPrefix !== "") { + writer.uint32(290).string(message.objcClassPrefix); + } + if (message.csharpNamespace !== "") { + writer.uint32(298).string(message.csharpNamespace); + } + if (message.swiftPrefix !== "") { + writer.uint32(314).string(message.swiftPrefix); + } + if (message.phpClassPrefix !== "") { + writer.uint32(322).string(message.phpClassPrefix); + } + if (message.phpNamespace !== "") { + writer.uint32(330).string(message.phpNamespace); + } + if (message.phpMetadataNamespace !== "") { + writer.uint32(354).string(message.phpMetadataNamespace); + } + if (message.rubyPackage !== "") { + writer.uint32(362).string(message.rubyPackage); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FileOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFileOptions } as FileOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.javaPackage = reader.string(); + break; + case 8: + message.javaOuterClassname = reader.string(); + break; + case 10: + message.javaMultipleFiles = reader.bool(); + break; + case 20: + message.javaGenerateEqualsAndHash = reader.bool(); + break; + case 27: + message.javaStringCheckUtf8 = reader.bool(); + break; + case 9: + message.optimizeFor = reader.int32() as any; + break; + case 11: + message.goPackage = reader.string(); + break; + case 16: + message.ccGenericServices = reader.bool(); + break; + case 17: + message.javaGenericServices = reader.bool(); + break; + case 18: + message.pyGenericServices = reader.bool(); + break; + case 42: + message.phpGenericServices = reader.bool(); + break; + case 23: + message.deprecated = reader.bool(); + break; + case 31: + message.ccEnableArenas = reader.bool(); + break; + case 36: + message.objcClassPrefix = reader.string(); + break; + case 37: + message.csharpNamespace = reader.string(); + break; + case 39: + message.swiftPrefix = reader.string(); + break; + case 40: + message.phpClassPrefix = reader.string(); + break; + case 41: + message.phpNamespace = reader.string(); + break; + case 44: + message.phpMetadataNamespace = reader.string(); + break; + case 45: + message.rubyPackage = reader.string(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FileOptions { + const message = { ...baseFileOptions } as FileOptions; + message.uninterpretedOption = []; + if (object.javaPackage !== undefined && object.javaPackage !== null) { + message.javaPackage = String(object.javaPackage); + } else { + message.javaPackage = ""; + } + if ( + object.javaOuterClassname !== undefined && + object.javaOuterClassname !== null + ) { + message.javaOuterClassname = String(object.javaOuterClassname); + } else { + message.javaOuterClassname = ""; + } + if ( + object.javaMultipleFiles !== undefined && + object.javaMultipleFiles !== null + ) { + message.javaMultipleFiles = Boolean(object.javaMultipleFiles); + } else { + message.javaMultipleFiles = false; + } + if ( + object.javaGenerateEqualsAndHash !== undefined && + object.javaGenerateEqualsAndHash !== null + ) { + message.javaGenerateEqualsAndHash = Boolean( + object.javaGenerateEqualsAndHash + ); + } else { + message.javaGenerateEqualsAndHash = false; + } + if ( + object.javaStringCheckUtf8 !== undefined && + object.javaStringCheckUtf8 !== null + ) { + message.javaStringCheckUtf8 = Boolean(object.javaStringCheckUtf8); + } else { + message.javaStringCheckUtf8 = false; + } + if (object.optimizeFor !== undefined && object.optimizeFor !== null) { + message.optimizeFor = fileOptions_OptimizeModeFromJSON( + object.optimizeFor + ); + } else { + message.optimizeFor = 1; + } + if (object.goPackage !== undefined && object.goPackage !== null) { + message.goPackage = String(object.goPackage); + } else { + message.goPackage = ""; + } + if ( + object.ccGenericServices !== undefined && + object.ccGenericServices !== null + ) { + message.ccGenericServices = Boolean(object.ccGenericServices); + } else { + message.ccGenericServices = false; + } + if ( + object.javaGenericServices !== undefined && + object.javaGenericServices !== null + ) { + message.javaGenericServices = Boolean(object.javaGenericServices); + } else { + message.javaGenericServices = false; + } + if ( + object.pyGenericServices !== undefined && + object.pyGenericServices !== null + ) { + message.pyGenericServices = Boolean(object.pyGenericServices); + } else { + message.pyGenericServices = false; + } + if ( + object.phpGenericServices !== undefined && + object.phpGenericServices !== null + ) { + message.phpGenericServices = Boolean(object.phpGenericServices); + } else { + message.phpGenericServices = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if (object.ccEnableArenas !== undefined && object.ccEnableArenas !== null) { + message.ccEnableArenas = Boolean(object.ccEnableArenas); + } else { + message.ccEnableArenas = false; + } + if ( + object.objcClassPrefix !== undefined && + object.objcClassPrefix !== null + ) { + message.objcClassPrefix = String(object.objcClassPrefix); + } else { + message.objcClassPrefix = ""; + } + if ( + object.csharpNamespace !== undefined && + object.csharpNamespace !== null + ) { + message.csharpNamespace = String(object.csharpNamespace); + } else { + message.csharpNamespace = ""; + } + if (object.swiftPrefix !== undefined && object.swiftPrefix !== null) { + message.swiftPrefix = String(object.swiftPrefix); + } else { + message.swiftPrefix = ""; + } + if (object.phpClassPrefix !== undefined && object.phpClassPrefix !== null) { + message.phpClassPrefix = String(object.phpClassPrefix); + } else { + message.phpClassPrefix = ""; + } + if (object.phpNamespace !== undefined && object.phpNamespace !== null) { + message.phpNamespace = String(object.phpNamespace); + } else { + message.phpNamespace = ""; + } + if ( + object.phpMetadataNamespace !== undefined && + object.phpMetadataNamespace !== null + ) { + message.phpMetadataNamespace = String(object.phpMetadataNamespace); + } else { + message.phpMetadataNamespace = ""; + } + if (object.rubyPackage !== undefined && object.rubyPackage !== null) { + message.rubyPackage = String(object.rubyPackage); + } else { + message.rubyPackage = ""; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: FileOptions): unknown { + const obj: any = {}; + message.javaPackage !== undefined && + (obj.javaPackage = message.javaPackage); + message.javaOuterClassname !== undefined && + (obj.javaOuterClassname = message.javaOuterClassname); + message.javaMultipleFiles !== undefined && + (obj.javaMultipleFiles = message.javaMultipleFiles); + message.javaGenerateEqualsAndHash !== undefined && + (obj.javaGenerateEqualsAndHash = message.javaGenerateEqualsAndHash); + message.javaStringCheckUtf8 !== undefined && + (obj.javaStringCheckUtf8 = message.javaStringCheckUtf8); + message.optimizeFor !== undefined && + (obj.optimizeFor = fileOptions_OptimizeModeToJSON(message.optimizeFor)); + message.goPackage !== undefined && (obj.goPackage = message.goPackage); + message.ccGenericServices !== undefined && + (obj.ccGenericServices = message.ccGenericServices); + message.javaGenericServices !== undefined && + (obj.javaGenericServices = message.javaGenericServices); + message.pyGenericServices !== undefined && + (obj.pyGenericServices = message.pyGenericServices); + message.phpGenericServices !== undefined && + (obj.phpGenericServices = message.phpGenericServices); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.ccEnableArenas !== undefined && + (obj.ccEnableArenas = message.ccEnableArenas); + message.objcClassPrefix !== undefined && + (obj.objcClassPrefix = message.objcClassPrefix); + message.csharpNamespace !== undefined && + (obj.csharpNamespace = message.csharpNamespace); + message.swiftPrefix !== undefined && + (obj.swiftPrefix = message.swiftPrefix); + message.phpClassPrefix !== undefined && + (obj.phpClassPrefix = message.phpClassPrefix); + message.phpNamespace !== undefined && + (obj.phpNamespace = message.phpNamespace); + message.phpMetadataNamespace !== undefined && + (obj.phpMetadataNamespace = message.phpMetadataNamespace); + message.rubyPackage !== undefined && + (obj.rubyPackage = message.rubyPackage); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): FileOptions { + const message = { ...baseFileOptions } as FileOptions; + message.uninterpretedOption = []; + if (object.javaPackage !== undefined && object.javaPackage !== null) { + message.javaPackage = object.javaPackage; + } else { + message.javaPackage = ""; + } + if ( + object.javaOuterClassname !== undefined && + object.javaOuterClassname !== null + ) { + message.javaOuterClassname = object.javaOuterClassname; + } else { + message.javaOuterClassname = ""; + } + if ( + object.javaMultipleFiles !== undefined && + object.javaMultipleFiles !== null + ) { + message.javaMultipleFiles = object.javaMultipleFiles; + } else { + message.javaMultipleFiles = false; + } + if ( + object.javaGenerateEqualsAndHash !== undefined && + object.javaGenerateEqualsAndHash !== null + ) { + message.javaGenerateEqualsAndHash = object.javaGenerateEqualsAndHash; + } else { + message.javaGenerateEqualsAndHash = false; + } + if ( + object.javaStringCheckUtf8 !== undefined && + object.javaStringCheckUtf8 !== null + ) { + message.javaStringCheckUtf8 = object.javaStringCheckUtf8; + } else { + message.javaStringCheckUtf8 = false; + } + if (object.optimizeFor !== undefined && object.optimizeFor !== null) { + message.optimizeFor = object.optimizeFor; + } else { + message.optimizeFor = 1; + } + if (object.goPackage !== undefined && object.goPackage !== null) { + message.goPackage = object.goPackage; + } else { + message.goPackage = ""; + } + if ( + object.ccGenericServices !== undefined && + object.ccGenericServices !== null + ) { + message.ccGenericServices = object.ccGenericServices; + } else { + message.ccGenericServices = false; + } + if ( + object.javaGenericServices !== undefined && + object.javaGenericServices !== null + ) { + message.javaGenericServices = object.javaGenericServices; + } else { + message.javaGenericServices = false; + } + if ( + object.pyGenericServices !== undefined && + object.pyGenericServices !== null + ) { + message.pyGenericServices = object.pyGenericServices; + } else { + message.pyGenericServices = false; + } + if ( + object.phpGenericServices !== undefined && + object.phpGenericServices !== null + ) { + message.phpGenericServices = object.phpGenericServices; + } else { + message.phpGenericServices = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if (object.ccEnableArenas !== undefined && object.ccEnableArenas !== null) { + message.ccEnableArenas = object.ccEnableArenas; + } else { + message.ccEnableArenas = false; + } + if ( + object.objcClassPrefix !== undefined && + object.objcClassPrefix !== null + ) { + message.objcClassPrefix = object.objcClassPrefix; + } else { + message.objcClassPrefix = ""; + } + if ( + object.csharpNamespace !== undefined && + object.csharpNamespace !== null + ) { + message.csharpNamespace = object.csharpNamespace; + } else { + message.csharpNamespace = ""; + } + if (object.swiftPrefix !== undefined && object.swiftPrefix !== null) { + message.swiftPrefix = object.swiftPrefix; + } else { + message.swiftPrefix = ""; + } + if (object.phpClassPrefix !== undefined && object.phpClassPrefix !== null) { + message.phpClassPrefix = object.phpClassPrefix; + } else { + message.phpClassPrefix = ""; + } + if (object.phpNamespace !== undefined && object.phpNamespace !== null) { + message.phpNamespace = object.phpNamespace; + } else { + message.phpNamespace = ""; + } + if ( + object.phpMetadataNamespace !== undefined && + object.phpMetadataNamespace !== null + ) { + message.phpMetadataNamespace = object.phpMetadataNamespace; + } else { + message.phpMetadataNamespace = ""; + } + if (object.rubyPackage !== undefined && object.rubyPackage !== null) { + message.rubyPackage = object.rubyPackage; + } else { + message.rubyPackage = ""; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseMessageOptions: object = { + messageSetWireFormat: false, + noStandardDescriptorAccessor: false, + deprecated: false, + mapEntry: false, +}; + +export const MessageOptions = { + encode(message: MessageOptions, writer: Writer = Writer.create()): Writer { + if (message.messageSetWireFormat === true) { + writer.uint32(8).bool(message.messageSetWireFormat); + } + if (message.noStandardDescriptorAccessor === true) { + writer.uint32(16).bool(message.noStandardDescriptorAccessor); + } + if (message.deprecated === true) { + writer.uint32(24).bool(message.deprecated); + } + if (message.mapEntry === true) { + writer.uint32(56).bool(message.mapEntry); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MessageOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMessageOptions } as MessageOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.messageSetWireFormat = reader.bool(); + break; + case 2: + message.noStandardDescriptorAccessor = reader.bool(); + break; + case 3: + message.deprecated = reader.bool(); + break; + case 7: + message.mapEntry = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MessageOptions { + const message = { ...baseMessageOptions } as MessageOptions; + message.uninterpretedOption = []; + if ( + object.messageSetWireFormat !== undefined && + object.messageSetWireFormat !== null + ) { + message.messageSetWireFormat = Boolean(object.messageSetWireFormat); + } else { + message.messageSetWireFormat = false; + } + if ( + object.noStandardDescriptorAccessor !== undefined && + object.noStandardDescriptorAccessor !== null + ) { + message.noStandardDescriptorAccessor = Boolean( + object.noStandardDescriptorAccessor + ); + } else { + message.noStandardDescriptorAccessor = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if (object.mapEntry !== undefined && object.mapEntry !== null) { + message.mapEntry = Boolean(object.mapEntry); + } else { + message.mapEntry = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: MessageOptions): unknown { + const obj: any = {}; + message.messageSetWireFormat !== undefined && + (obj.messageSetWireFormat = message.messageSetWireFormat); + message.noStandardDescriptorAccessor !== undefined && + (obj.noStandardDescriptorAccessor = message.noStandardDescriptorAccessor); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.mapEntry !== undefined && (obj.mapEntry = message.mapEntry); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): MessageOptions { + const message = { ...baseMessageOptions } as MessageOptions; + message.uninterpretedOption = []; + if ( + object.messageSetWireFormat !== undefined && + object.messageSetWireFormat !== null + ) { + message.messageSetWireFormat = object.messageSetWireFormat; + } else { + message.messageSetWireFormat = false; + } + if ( + object.noStandardDescriptorAccessor !== undefined && + object.noStandardDescriptorAccessor !== null + ) { + message.noStandardDescriptorAccessor = + object.noStandardDescriptorAccessor; + } else { + message.noStandardDescriptorAccessor = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if (object.mapEntry !== undefined && object.mapEntry !== null) { + message.mapEntry = object.mapEntry; + } else { + message.mapEntry = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseFieldOptions: object = { + ctype: 0, + packed: false, + jstype: 0, + lazy: false, + deprecated: false, + weak: false, +}; + +export const FieldOptions = { + encode(message: FieldOptions, writer: Writer = Writer.create()): Writer { + if (message.ctype !== 0) { + writer.uint32(8).int32(message.ctype); + } + if (message.packed === true) { + writer.uint32(16).bool(message.packed); + } + if (message.jstype !== 0) { + writer.uint32(48).int32(message.jstype); + } + if (message.lazy === true) { + writer.uint32(40).bool(message.lazy); + } + if (message.deprecated === true) { + writer.uint32(24).bool(message.deprecated); + } + if (message.weak === true) { + writer.uint32(80).bool(message.weak); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FieldOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFieldOptions } as FieldOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.ctype = reader.int32() as any; + break; + case 2: + message.packed = reader.bool(); + break; + case 6: + message.jstype = reader.int32() as any; + break; + case 5: + message.lazy = reader.bool(); + break; + case 3: + message.deprecated = reader.bool(); + break; + case 10: + message.weak = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FieldOptions { + const message = { ...baseFieldOptions } as FieldOptions; + message.uninterpretedOption = []; + if (object.ctype !== undefined && object.ctype !== null) { + message.ctype = fieldOptions_CTypeFromJSON(object.ctype); + } else { + message.ctype = 0; + } + if (object.packed !== undefined && object.packed !== null) { + message.packed = Boolean(object.packed); + } else { + message.packed = false; + } + if (object.jstype !== undefined && object.jstype !== null) { + message.jstype = fieldOptions_JSTypeFromJSON(object.jstype); + } else { + message.jstype = 0; + } + if (object.lazy !== undefined && object.lazy !== null) { + message.lazy = Boolean(object.lazy); + } else { + message.lazy = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if (object.weak !== undefined && object.weak !== null) { + message.weak = Boolean(object.weak); + } else { + message.weak = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: FieldOptions): unknown { + const obj: any = {}; + message.ctype !== undefined && + (obj.ctype = fieldOptions_CTypeToJSON(message.ctype)); + message.packed !== undefined && (obj.packed = message.packed); + message.jstype !== undefined && + (obj.jstype = fieldOptions_JSTypeToJSON(message.jstype)); + message.lazy !== undefined && (obj.lazy = message.lazy); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.weak !== undefined && (obj.weak = message.weak); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): FieldOptions { + const message = { ...baseFieldOptions } as FieldOptions; + message.uninterpretedOption = []; + if (object.ctype !== undefined && object.ctype !== null) { + message.ctype = object.ctype; + } else { + message.ctype = 0; + } + if (object.packed !== undefined && object.packed !== null) { + message.packed = object.packed; + } else { + message.packed = false; + } + if (object.jstype !== undefined && object.jstype !== null) { + message.jstype = object.jstype; + } else { + message.jstype = 0; + } + if (object.lazy !== undefined && object.lazy !== null) { + message.lazy = object.lazy; + } else { + message.lazy = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if (object.weak !== undefined && object.weak !== null) { + message.weak = object.weak; + } else { + message.weak = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseOneofOptions: object = {}; + +export const OneofOptions = { + encode(message: OneofOptions, writer: Writer = Writer.create()): Writer { + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): OneofOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseOneofOptions } as OneofOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): OneofOptions { + const message = { ...baseOneofOptions } as OneofOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: OneofOptions): unknown { + const obj: any = {}; + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): OneofOptions { + const message = { ...baseOneofOptions } as OneofOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseEnumOptions: object = { allowAlias: false, deprecated: false }; + +export const EnumOptions = { + encode(message: EnumOptions, writer: Writer = Writer.create()): Writer { + if (message.allowAlias === true) { + writer.uint32(16).bool(message.allowAlias); + } + if (message.deprecated === true) { + writer.uint32(24).bool(message.deprecated); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): EnumOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseEnumOptions } as EnumOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + message.allowAlias = reader.bool(); + break; + case 3: + message.deprecated = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumOptions { + const message = { ...baseEnumOptions } as EnumOptions; + message.uninterpretedOption = []; + if (object.allowAlias !== undefined && object.allowAlias !== null) { + message.allowAlias = Boolean(object.allowAlias); + } else { + message.allowAlias = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: EnumOptions): unknown { + const obj: any = {}; + message.allowAlias !== undefined && (obj.allowAlias = message.allowAlias); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): EnumOptions { + const message = { ...baseEnumOptions } as EnumOptions; + message.uninterpretedOption = []; + if (object.allowAlias !== undefined && object.allowAlias !== null) { + message.allowAlias = object.allowAlias; + } else { + message.allowAlias = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseEnumValueOptions: object = { deprecated: false }; + +export const EnumValueOptions = { + encode(message: EnumValueOptions, writer: Writer = Writer.create()): Writer { + if (message.deprecated === true) { + writer.uint32(8).bool(message.deprecated); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): EnumValueOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseEnumValueOptions } as EnumValueOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.deprecated = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumValueOptions { + const message = { ...baseEnumValueOptions } as EnumValueOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: EnumValueOptions): unknown { + const obj: any = {}; + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): EnumValueOptions { + const message = { ...baseEnumValueOptions } as EnumValueOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseServiceOptions: object = { deprecated: false }; + +export const ServiceOptions = { + encode(message: ServiceOptions, writer: Writer = Writer.create()): Writer { + if (message.deprecated === true) { + writer.uint32(264).bool(message.deprecated); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ServiceOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseServiceOptions } as ServiceOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 33: + message.deprecated = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ServiceOptions { + const message = { ...baseServiceOptions } as ServiceOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: ServiceOptions): unknown { + const obj: any = {}; + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): ServiceOptions { + const message = { ...baseServiceOptions } as ServiceOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseMethodOptions: object = { deprecated: false, idempotencyLevel: 0 }; + +export const MethodOptions = { + encode(message: MethodOptions, writer: Writer = Writer.create()): Writer { + if (message.deprecated === true) { + writer.uint32(264).bool(message.deprecated); + } + if (message.idempotencyLevel !== 0) { + writer.uint32(272).int32(message.idempotencyLevel); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MethodOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMethodOptions } as MethodOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 33: + message.deprecated = reader.bool(); + break; + case 34: + message.idempotencyLevel = reader.int32() as any; + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MethodOptions { + const message = { ...baseMethodOptions } as MethodOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.idempotencyLevel !== undefined && + object.idempotencyLevel !== null + ) { + message.idempotencyLevel = methodOptions_IdempotencyLevelFromJSON( + object.idempotencyLevel + ); + } else { + message.idempotencyLevel = 0; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: MethodOptions): unknown { + const obj: any = {}; + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.idempotencyLevel !== undefined && + (obj.idempotencyLevel = methodOptions_IdempotencyLevelToJSON( + message.idempotencyLevel + )); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): MethodOptions { + const message = { ...baseMethodOptions } as MethodOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.idempotencyLevel !== undefined && + object.idempotencyLevel !== null + ) { + message.idempotencyLevel = object.idempotencyLevel; + } else { + message.idempotencyLevel = 0; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseUninterpretedOption: object = { + identifierValue: "", + positiveIntValue: 0, + negativeIntValue: 0, + doubleValue: 0, + aggregateValue: "", +}; + +export const UninterpretedOption = { + encode( + message: UninterpretedOption, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.name) { + UninterpretedOption_NamePart.encode( + v!, + writer.uint32(18).fork() + ).ldelim(); + } + if (message.identifierValue !== "") { + writer.uint32(26).string(message.identifierValue); + } + if (message.positiveIntValue !== 0) { + writer.uint32(32).uint64(message.positiveIntValue); + } + if (message.negativeIntValue !== 0) { + writer.uint32(40).int64(message.negativeIntValue); + } + if (message.doubleValue !== 0) { + writer.uint32(49).double(message.doubleValue); + } + if (message.stringValue.length !== 0) { + writer.uint32(58).bytes(message.stringValue); + } + if (message.aggregateValue !== "") { + writer.uint32(66).string(message.aggregateValue); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): UninterpretedOption { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseUninterpretedOption } as UninterpretedOption; + message.name = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + message.name.push( + UninterpretedOption_NamePart.decode(reader, reader.uint32()) + ); + break; + case 3: + message.identifierValue = reader.string(); + break; + case 4: + message.positiveIntValue = longToNumber(reader.uint64() as Long); + break; + case 5: + message.negativeIntValue = longToNumber(reader.int64() as Long); + break; + case 6: + message.doubleValue = reader.double(); + break; + case 7: + message.stringValue = reader.bytes(); + break; + case 8: + message.aggregateValue = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): UninterpretedOption { + const message = { ...baseUninterpretedOption } as UninterpretedOption; + message.name = []; + if (object.name !== undefined && object.name !== null) { + for (const e of object.name) { + message.name.push(UninterpretedOption_NamePart.fromJSON(e)); + } + } + if ( + object.identifierValue !== undefined && + object.identifierValue !== null + ) { + message.identifierValue = String(object.identifierValue); + } else { + message.identifierValue = ""; + } + if ( + object.positiveIntValue !== undefined && + object.positiveIntValue !== null + ) { + message.positiveIntValue = Number(object.positiveIntValue); + } else { + message.positiveIntValue = 0; + } + if ( + object.negativeIntValue !== undefined && + object.negativeIntValue !== null + ) { + message.negativeIntValue = Number(object.negativeIntValue); + } else { + message.negativeIntValue = 0; + } + if (object.doubleValue !== undefined && object.doubleValue !== null) { + message.doubleValue = Number(object.doubleValue); + } else { + message.doubleValue = 0; + } + if (object.stringValue !== undefined && object.stringValue !== null) { + message.stringValue = bytesFromBase64(object.stringValue); + } + if (object.aggregateValue !== undefined && object.aggregateValue !== null) { + message.aggregateValue = String(object.aggregateValue); + } else { + message.aggregateValue = ""; + } + return message; + }, + + toJSON(message: UninterpretedOption): unknown { + const obj: any = {}; + if (message.name) { + obj.name = message.name.map((e) => + e ? UninterpretedOption_NamePart.toJSON(e) : undefined + ); + } else { + obj.name = []; + } + message.identifierValue !== undefined && + (obj.identifierValue = message.identifierValue); + message.positiveIntValue !== undefined && + (obj.positiveIntValue = message.positiveIntValue); + message.negativeIntValue !== undefined && + (obj.negativeIntValue = message.negativeIntValue); + message.doubleValue !== undefined && + (obj.doubleValue = message.doubleValue); + message.stringValue !== undefined && + (obj.stringValue = base64FromBytes( + message.stringValue !== undefined + ? message.stringValue + : new Uint8Array() + )); + message.aggregateValue !== undefined && + (obj.aggregateValue = message.aggregateValue); + return obj; + }, + + fromPartial(object: DeepPartial): UninterpretedOption { + const message = { ...baseUninterpretedOption } as UninterpretedOption; + message.name = []; + if (object.name !== undefined && object.name !== null) { + for (const e of object.name) { + message.name.push(UninterpretedOption_NamePart.fromPartial(e)); + } + } + if ( + object.identifierValue !== undefined && + object.identifierValue !== null + ) { + message.identifierValue = object.identifierValue; + } else { + message.identifierValue = ""; + } + if ( + object.positiveIntValue !== undefined && + object.positiveIntValue !== null + ) { + message.positiveIntValue = object.positiveIntValue; + } else { + message.positiveIntValue = 0; + } + if ( + object.negativeIntValue !== undefined && + object.negativeIntValue !== null + ) { + message.negativeIntValue = object.negativeIntValue; + } else { + message.negativeIntValue = 0; + } + if (object.doubleValue !== undefined && object.doubleValue !== null) { + message.doubleValue = object.doubleValue; + } else { + message.doubleValue = 0; + } + if (object.stringValue !== undefined && object.stringValue !== null) { + message.stringValue = object.stringValue; + } else { + message.stringValue = new Uint8Array(); + } + if (object.aggregateValue !== undefined && object.aggregateValue !== null) { + message.aggregateValue = object.aggregateValue; + } else { + message.aggregateValue = ""; + } + return message; + }, +}; + +const baseUninterpretedOption_NamePart: object = { + namePart: "", + isExtension: false, +}; + +export const UninterpretedOption_NamePart = { + encode( + message: UninterpretedOption_NamePart, + writer: Writer = Writer.create() + ): Writer { + if (message.namePart !== "") { + writer.uint32(10).string(message.namePart); + } + if (message.isExtension === true) { + writer.uint32(16).bool(message.isExtension); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): UninterpretedOption_NamePart { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseUninterpretedOption_NamePart, + } as UninterpretedOption_NamePart; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.namePart = reader.string(); + break; + case 2: + message.isExtension = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): UninterpretedOption_NamePart { + const message = { + ...baseUninterpretedOption_NamePart, + } as UninterpretedOption_NamePart; + if (object.namePart !== undefined && object.namePart !== null) { + message.namePart = String(object.namePart); + } else { + message.namePart = ""; + } + if (object.isExtension !== undefined && object.isExtension !== null) { + message.isExtension = Boolean(object.isExtension); + } else { + message.isExtension = false; + } + return message; + }, + + toJSON(message: UninterpretedOption_NamePart): unknown { + const obj: any = {}; + message.namePart !== undefined && (obj.namePart = message.namePart); + message.isExtension !== undefined && + (obj.isExtension = message.isExtension); + return obj; + }, + + fromPartial( + object: DeepPartial + ): UninterpretedOption_NamePart { + const message = { + ...baseUninterpretedOption_NamePart, + } as UninterpretedOption_NamePart; + if (object.namePart !== undefined && object.namePart !== null) { + message.namePart = object.namePart; + } else { + message.namePart = ""; + } + if (object.isExtension !== undefined && object.isExtension !== null) { + message.isExtension = object.isExtension; + } else { + message.isExtension = false; + } + return message; + }, +}; + +const baseSourceCodeInfo: object = {}; + +export const SourceCodeInfo = { + encode(message: SourceCodeInfo, writer: Writer = Writer.create()): Writer { + for (const v of message.location) { + SourceCodeInfo_Location.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): SourceCodeInfo { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseSourceCodeInfo } as SourceCodeInfo; + message.location = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.location.push( + SourceCodeInfo_Location.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): SourceCodeInfo { + const message = { ...baseSourceCodeInfo } as SourceCodeInfo; + message.location = []; + if (object.location !== undefined && object.location !== null) { + for (const e of object.location) { + message.location.push(SourceCodeInfo_Location.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: SourceCodeInfo): unknown { + const obj: any = {}; + if (message.location) { + obj.location = message.location.map((e) => + e ? SourceCodeInfo_Location.toJSON(e) : undefined + ); + } else { + obj.location = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): SourceCodeInfo { + const message = { ...baseSourceCodeInfo } as SourceCodeInfo; + message.location = []; + if (object.location !== undefined && object.location !== null) { + for (const e of object.location) { + message.location.push(SourceCodeInfo_Location.fromPartial(e)); + } + } + return message; + }, +}; + +const baseSourceCodeInfo_Location: object = { + path: 0, + span: 0, + leadingComments: "", + trailingComments: "", + leadingDetachedComments: "", +}; + +export const SourceCodeInfo_Location = { + encode( + message: SourceCodeInfo_Location, + writer: Writer = Writer.create() + ): Writer { + writer.uint32(10).fork(); + for (const v of message.path) { + writer.int32(v); + } + writer.ldelim(); + writer.uint32(18).fork(); + for (const v of message.span) { + writer.int32(v); + } + writer.ldelim(); + if (message.leadingComments !== "") { + writer.uint32(26).string(message.leadingComments); + } + if (message.trailingComments !== "") { + writer.uint32(34).string(message.trailingComments); + } + for (const v of message.leadingDetachedComments) { + writer.uint32(50).string(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): SourceCodeInfo_Location { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseSourceCodeInfo_Location, + } as SourceCodeInfo_Location; + message.path = []; + message.span = []; + message.leadingDetachedComments = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.path.push(reader.int32()); + } + } else { + message.path.push(reader.int32()); + } + break; + case 2: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.span.push(reader.int32()); + } + } else { + message.span.push(reader.int32()); + } + break; + case 3: + message.leadingComments = reader.string(); + break; + case 4: + message.trailingComments = reader.string(); + break; + case 6: + message.leadingDetachedComments.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): SourceCodeInfo_Location { + const message = { + ...baseSourceCodeInfo_Location, + } as SourceCodeInfo_Location; + message.path = []; + message.span = []; + message.leadingDetachedComments = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(Number(e)); + } + } + if (object.span !== undefined && object.span !== null) { + for (const e of object.span) { + message.span.push(Number(e)); + } + } + if ( + object.leadingComments !== undefined && + object.leadingComments !== null + ) { + message.leadingComments = String(object.leadingComments); + } else { + message.leadingComments = ""; + } + if ( + object.trailingComments !== undefined && + object.trailingComments !== null + ) { + message.trailingComments = String(object.trailingComments); + } else { + message.trailingComments = ""; + } + if ( + object.leadingDetachedComments !== undefined && + object.leadingDetachedComments !== null + ) { + for (const e of object.leadingDetachedComments) { + message.leadingDetachedComments.push(String(e)); + } + } + return message; + }, + + toJSON(message: SourceCodeInfo_Location): unknown { + const obj: any = {}; + if (message.path) { + obj.path = message.path.map((e) => e); + } else { + obj.path = []; + } + if (message.span) { + obj.span = message.span.map((e) => e); + } else { + obj.span = []; + } + message.leadingComments !== undefined && + (obj.leadingComments = message.leadingComments); + message.trailingComments !== undefined && + (obj.trailingComments = message.trailingComments); + if (message.leadingDetachedComments) { + obj.leadingDetachedComments = message.leadingDetachedComments.map( + (e) => e + ); + } else { + obj.leadingDetachedComments = []; + } + return obj; + }, + + fromPartial( + object: DeepPartial + ): SourceCodeInfo_Location { + const message = { + ...baseSourceCodeInfo_Location, + } as SourceCodeInfo_Location; + message.path = []; + message.span = []; + message.leadingDetachedComments = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(e); + } + } + if (object.span !== undefined && object.span !== null) { + for (const e of object.span) { + message.span.push(e); + } + } + if ( + object.leadingComments !== undefined && + object.leadingComments !== null + ) { + message.leadingComments = object.leadingComments; + } else { + message.leadingComments = ""; + } + if ( + object.trailingComments !== undefined && + object.trailingComments !== null + ) { + message.trailingComments = object.trailingComments; + } else { + message.trailingComments = ""; + } + if ( + object.leadingDetachedComments !== undefined && + object.leadingDetachedComments !== null + ) { + for (const e of object.leadingDetachedComments) { + message.leadingDetachedComments.push(e); + } + } + return message; + }, +}; + +const baseGeneratedCodeInfo: object = {}; + +export const GeneratedCodeInfo = { + encode(message: GeneratedCodeInfo, writer: Writer = Writer.create()): Writer { + for (const v of message.annotation) { + GeneratedCodeInfo_Annotation.encode( + v!, + writer.uint32(10).fork() + ).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): GeneratedCodeInfo { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseGeneratedCodeInfo } as GeneratedCodeInfo; + message.annotation = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.annotation.push( + GeneratedCodeInfo_Annotation.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GeneratedCodeInfo { + const message = { ...baseGeneratedCodeInfo } as GeneratedCodeInfo; + message.annotation = []; + if (object.annotation !== undefined && object.annotation !== null) { + for (const e of object.annotation) { + message.annotation.push(GeneratedCodeInfo_Annotation.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: GeneratedCodeInfo): unknown { + const obj: any = {}; + if (message.annotation) { + obj.annotation = message.annotation.map((e) => + e ? GeneratedCodeInfo_Annotation.toJSON(e) : undefined + ); + } else { + obj.annotation = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): GeneratedCodeInfo { + const message = { ...baseGeneratedCodeInfo } as GeneratedCodeInfo; + message.annotation = []; + if (object.annotation !== undefined && object.annotation !== null) { + for (const e of object.annotation) { + message.annotation.push(GeneratedCodeInfo_Annotation.fromPartial(e)); + } + } + return message; + }, +}; + +const baseGeneratedCodeInfo_Annotation: object = { + path: 0, + sourceFile: "", + begin: 0, + end: 0, +}; + +export const GeneratedCodeInfo_Annotation = { + encode( + message: GeneratedCodeInfo_Annotation, + writer: Writer = Writer.create() + ): Writer { + writer.uint32(10).fork(); + for (const v of message.path) { + writer.int32(v); + } + writer.ldelim(); + if (message.sourceFile !== "") { + writer.uint32(18).string(message.sourceFile); + } + if (message.begin !== 0) { + writer.uint32(24).int32(message.begin); + } + if (message.end !== 0) { + writer.uint32(32).int32(message.end); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): GeneratedCodeInfo_Annotation { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseGeneratedCodeInfo_Annotation, + } as GeneratedCodeInfo_Annotation; + message.path = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.path.push(reader.int32()); + } + } else { + message.path.push(reader.int32()); + } + break; + case 2: + message.sourceFile = reader.string(); + break; + case 3: + message.begin = reader.int32(); + break; + case 4: + message.end = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GeneratedCodeInfo_Annotation { + const message = { + ...baseGeneratedCodeInfo_Annotation, + } as GeneratedCodeInfo_Annotation; + message.path = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(Number(e)); + } + } + if (object.sourceFile !== undefined && object.sourceFile !== null) { + message.sourceFile = String(object.sourceFile); + } else { + message.sourceFile = ""; + } + if (object.begin !== undefined && object.begin !== null) { + message.begin = Number(object.begin); + } else { + message.begin = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + return message; + }, + + toJSON(message: GeneratedCodeInfo_Annotation): unknown { + const obj: any = {}; + if (message.path) { + obj.path = message.path.map((e) => e); + } else { + obj.path = []; + } + message.sourceFile !== undefined && (obj.sourceFile = message.sourceFile); + message.begin !== undefined && (obj.begin = message.begin); + message.end !== undefined && (obj.end = message.end); + return obj; + }, + + fromPartial( + object: DeepPartial + ): GeneratedCodeInfo_Annotation { + const message = { + ...baseGeneratedCodeInfo_Annotation, + } as GeneratedCodeInfo_Annotation; + message.path = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(e); + } + } + if (object.sourceFile !== undefined && object.sourceFile !== null) { + message.sourceFile = object.sourceFile; + } else { + message.sourceFile = ""; + } + if (object.begin !== undefined && object.begin !== null) { + message.begin = object.begin; + } else { + message.begin = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/cosmos.base.tendermint.v1beta1/types/google/protobuf/timestamp.ts b/ts-client/cosmos.base.tendermint.v1beta1/types/google/protobuf/timestamp.ts new file mode 100644 index 00000000..11864afc --- /dev/null +++ b/ts-client/cosmos.base.tendermint.v1beta1/types/google/protobuf/timestamp.ts @@ -0,0 +1,219 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "google.protobuf"; + +/** + * A Timestamp represents a point in time independent of any time zone or local + * calendar, encoded as a count of seconds and fractions of seconds at + * nanosecond resolution. The count is relative to an epoch at UTC midnight on + * January 1, 1970, in the proleptic Gregorian calendar which extends the + * Gregorian calendar backwards to year one. + * + * All minutes are 60 seconds long. Leap seconds are "smeared" so that no leap + * second table is needed for interpretation, using a [24-hour linear + * smear](https://developers.google.com/time/smear). + * + * The range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. By + * restricting to that range, we ensure that we can convert to and from [RFC + * 3339](https://www.ietf.org/rfc/rfc3339.txt) date strings. + * + * # Examples + * + * Example 1: Compute Timestamp from POSIX `time()`. + * + * Timestamp timestamp; + * timestamp.set_seconds(time(NULL)); + * timestamp.set_nanos(0); + * + * Example 2: Compute Timestamp from POSIX `gettimeofday()`. + * + * struct timeval tv; + * gettimeofday(&tv, NULL); + * + * Timestamp timestamp; + * timestamp.set_seconds(tv.tv_sec); + * timestamp.set_nanos(tv.tv_usec * 1000); + * + * Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`. + * + * FILETIME ft; + * GetSystemTimeAsFileTime(&ft); + * UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime; + * + * // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z + * // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z. + * Timestamp timestamp; + * timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL)); + * timestamp.set_nanos((INT32) ((ticks % 10000000) * 100)); + * + * Example 4: Compute Timestamp from Java `System.currentTimeMillis()`. + * + * long millis = System.currentTimeMillis(); + * + * Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000) + * .setNanos((int) ((millis % 1000) * 1000000)).build(); + * + * + * Example 5: Compute Timestamp from Java `Instant.now()`. + * + * Instant now = Instant.now(); + * + * Timestamp timestamp = + * Timestamp.newBuilder().setSeconds(now.getEpochSecond()) + * .setNanos(now.getNano()).build(); + * + * + * Example 6: Compute Timestamp from current time in Python. + * + * timestamp = Timestamp() + * timestamp.GetCurrentTime() + * + * # JSON Mapping + * + * In JSON format, the Timestamp type is encoded as a string in the + * [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the + * format is "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z" + * where {year} is always expressed using four digits while {month}, {day}, + * {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional + * seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution), + * are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone + * is required. A proto3 JSON serializer should always use UTC (as indicated by + * "Z") when printing the Timestamp type and a proto3 JSON parser should be + * able to accept both UTC and other timezones (as indicated by an offset). + * + * For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past + * 01:30 UTC on January 15, 2017. + * + * In JavaScript, one can convert a Date object to this format using the + * standard + * [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString) + * method. In Python, a standard `datetime.datetime` object can be converted + * to this format using + * [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) with + * the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one can use + * the Joda Time's [`ISODateTimeFormat.dateTime()`]( + * http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime%2D%2D + * ) to obtain a formatter capable of generating timestamps in this format. + */ +export interface Timestamp { + /** + * Represents seconds of UTC time since Unix epoch + * 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to + * 9999-12-31T23:59:59Z inclusive. + */ + seconds: number; + /** + * Non-negative fractions of a second at nanosecond resolution. Negative + * second values with fractions must still have non-negative nanos values + * that count forward in time. Must be from 0 to 999,999,999 + * inclusive. + */ + nanos: number; +} + +const baseTimestamp: object = { seconds: 0, nanos: 0 }; + +export const Timestamp = { + encode(message: Timestamp, writer: Writer = Writer.create()): Writer { + if (message.seconds !== 0) { + writer.uint32(8).int64(message.seconds); + } + if (message.nanos !== 0) { + writer.uint32(16).int32(message.nanos); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Timestamp { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseTimestamp } as Timestamp; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.seconds = longToNumber(reader.int64() as Long); + break; + case 2: + message.nanos = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Timestamp { + const message = { ...baseTimestamp } as Timestamp; + if (object.seconds !== undefined && object.seconds !== null) { + message.seconds = Number(object.seconds); + } else { + message.seconds = 0; + } + if (object.nanos !== undefined && object.nanos !== null) { + message.nanos = Number(object.nanos); + } else { + message.nanos = 0; + } + return message; + }, + + toJSON(message: Timestamp): unknown { + const obj: any = {}; + message.seconds !== undefined && (obj.seconds = message.seconds); + message.nanos !== undefined && (obj.nanos = message.nanos); + return obj; + }, + + fromPartial(object: DeepPartial): Timestamp { + const message = { ...baseTimestamp } as Timestamp; + if (object.seconds !== undefined && object.seconds !== null) { + message.seconds = object.seconds; + } else { + message.seconds = 0; + } + if (object.nanos !== undefined && object.nanos !== null) { + message.nanos = object.nanos; + } else { + message.nanos = 0; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/cosmos.base.tendermint.v1beta1/types/tendermint/crypto/keys.ts b/ts-client/cosmos.base.tendermint.v1beta1/types/tendermint/crypto/keys.ts new file mode 100644 index 00000000..d530b047 --- /dev/null +++ b/ts-client/cosmos.base.tendermint.v1beta1/types/tendermint/crypto/keys.ts @@ -0,0 +1,130 @@ +/* eslint-disable */ +import { Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "tendermint.crypto"; + +/** PublicKey defines the keys available for use with Validators */ +export interface PublicKey { + ed25519: Uint8Array | undefined; + secp256k1: Uint8Array | undefined; +} + +const basePublicKey: object = {}; + +export const PublicKey = { + encode(message: PublicKey, writer: Writer = Writer.create()): Writer { + if (message.ed25519 !== undefined) { + writer.uint32(10).bytes(message.ed25519); + } + if (message.secp256k1 !== undefined) { + writer.uint32(18).bytes(message.secp256k1); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): PublicKey { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...basePublicKey } as PublicKey; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.ed25519 = reader.bytes(); + break; + case 2: + message.secp256k1 = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): PublicKey { + const message = { ...basePublicKey } as PublicKey; + if (object.ed25519 !== undefined && object.ed25519 !== null) { + message.ed25519 = bytesFromBase64(object.ed25519); + } + if (object.secp256k1 !== undefined && object.secp256k1 !== null) { + message.secp256k1 = bytesFromBase64(object.secp256k1); + } + return message; + }, + + toJSON(message: PublicKey): unknown { + const obj: any = {}; + message.ed25519 !== undefined && + (obj.ed25519 = + message.ed25519 !== undefined + ? base64FromBytes(message.ed25519) + : undefined); + message.secp256k1 !== undefined && + (obj.secp256k1 = + message.secp256k1 !== undefined + ? base64FromBytes(message.secp256k1) + : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): PublicKey { + const message = { ...basePublicKey } as PublicKey; + if (object.ed25519 !== undefined && object.ed25519 !== null) { + message.ed25519 = object.ed25519; + } else { + message.ed25519 = undefined; + } + if (object.secp256k1 !== undefined && object.secp256k1 !== null) { + message.secp256k1 = object.secp256k1; + } else { + message.secp256k1 = undefined; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/cosmos.base.tendermint.v1beta1/types/tendermint/crypto/proof.ts b/ts-client/cosmos.base.tendermint.v1beta1/types/tendermint/crypto/proof.ts new file mode 100644 index 00000000..dae51600 --- /dev/null +++ b/ts-client/cosmos.base.tendermint.v1beta1/types/tendermint/crypto/proof.ts @@ -0,0 +1,529 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "tendermint.crypto"; + +export interface Proof { + total: number; + index: number; + leafHash: Uint8Array; + aunts: Uint8Array[]; +} + +export interface ValueOp { + /** Encoded in ProofOp.Key. */ + key: Uint8Array; + /** To encode in ProofOp.Data */ + proof: Proof | undefined; +} + +export interface DominoOp { + key: string; + input: string; + output: string; +} + +/** + * ProofOp defines an operation used for calculating Merkle root + * The data could be arbitrary format, providing nessecary data + * for example neighbouring node hash + */ +export interface ProofOp { + type: string; + key: Uint8Array; + data: Uint8Array; +} + +/** ProofOps is Merkle proof defined by the list of ProofOps */ +export interface ProofOps { + ops: ProofOp[]; +} + +const baseProof: object = { total: 0, index: 0 }; + +export const Proof = { + encode(message: Proof, writer: Writer = Writer.create()): Writer { + if (message.total !== 0) { + writer.uint32(8).int64(message.total); + } + if (message.index !== 0) { + writer.uint32(16).int64(message.index); + } + if (message.leafHash.length !== 0) { + writer.uint32(26).bytes(message.leafHash); + } + for (const v of message.aunts) { + writer.uint32(34).bytes(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Proof { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseProof } as Proof; + message.aunts = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.total = longToNumber(reader.int64() as Long); + break; + case 2: + message.index = longToNumber(reader.int64() as Long); + break; + case 3: + message.leafHash = reader.bytes(); + break; + case 4: + message.aunts.push(reader.bytes()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Proof { + const message = { ...baseProof } as Proof; + message.aunts = []; + if (object.total !== undefined && object.total !== null) { + message.total = Number(object.total); + } else { + message.total = 0; + } + if (object.index !== undefined && object.index !== null) { + message.index = Number(object.index); + } else { + message.index = 0; + } + if (object.leafHash !== undefined && object.leafHash !== null) { + message.leafHash = bytesFromBase64(object.leafHash); + } + if (object.aunts !== undefined && object.aunts !== null) { + for (const e of object.aunts) { + message.aunts.push(bytesFromBase64(e)); + } + } + return message; + }, + + toJSON(message: Proof): unknown { + const obj: any = {}; + message.total !== undefined && (obj.total = message.total); + message.index !== undefined && (obj.index = message.index); + message.leafHash !== undefined && + (obj.leafHash = base64FromBytes( + message.leafHash !== undefined ? message.leafHash : new Uint8Array() + )); + if (message.aunts) { + obj.aunts = message.aunts.map((e) => + base64FromBytes(e !== undefined ? e : new Uint8Array()) + ); + } else { + obj.aunts = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): Proof { + const message = { ...baseProof } as Proof; + message.aunts = []; + if (object.total !== undefined && object.total !== null) { + message.total = object.total; + } else { + message.total = 0; + } + if (object.index !== undefined && object.index !== null) { + message.index = object.index; + } else { + message.index = 0; + } + if (object.leafHash !== undefined && object.leafHash !== null) { + message.leafHash = object.leafHash; + } else { + message.leafHash = new Uint8Array(); + } + if (object.aunts !== undefined && object.aunts !== null) { + for (const e of object.aunts) { + message.aunts.push(e); + } + } + return message; + }, +}; + +const baseValueOp: object = {}; + +export const ValueOp = { + encode(message: ValueOp, writer: Writer = Writer.create()): Writer { + if (message.key.length !== 0) { + writer.uint32(10).bytes(message.key); + } + if (message.proof !== undefined) { + Proof.encode(message.proof, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ValueOp { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseValueOp } as ValueOp; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.key = reader.bytes(); + break; + case 2: + message.proof = Proof.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ValueOp { + const message = { ...baseValueOp } as ValueOp; + if (object.key !== undefined && object.key !== null) { + message.key = bytesFromBase64(object.key); + } + if (object.proof !== undefined && object.proof !== null) { + message.proof = Proof.fromJSON(object.proof); + } else { + message.proof = undefined; + } + return message; + }, + + toJSON(message: ValueOp): unknown { + const obj: any = {}; + message.key !== undefined && + (obj.key = base64FromBytes( + message.key !== undefined ? message.key : new Uint8Array() + )); + message.proof !== undefined && + (obj.proof = message.proof ? Proof.toJSON(message.proof) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): ValueOp { + const message = { ...baseValueOp } as ValueOp; + if (object.key !== undefined && object.key !== null) { + message.key = object.key; + } else { + message.key = new Uint8Array(); + } + if (object.proof !== undefined && object.proof !== null) { + message.proof = Proof.fromPartial(object.proof); + } else { + message.proof = undefined; + } + return message; + }, +}; + +const baseDominoOp: object = { key: "", input: "", output: "" }; + +export const DominoOp = { + encode(message: DominoOp, writer: Writer = Writer.create()): Writer { + if (message.key !== "") { + writer.uint32(10).string(message.key); + } + if (message.input !== "") { + writer.uint32(18).string(message.input); + } + if (message.output !== "") { + writer.uint32(26).string(message.output); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): DominoOp { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseDominoOp } as DominoOp; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.key = reader.string(); + break; + case 2: + message.input = reader.string(); + break; + case 3: + message.output = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DominoOp { + const message = { ...baseDominoOp } as DominoOp; + if (object.key !== undefined && object.key !== null) { + message.key = String(object.key); + } else { + message.key = ""; + } + if (object.input !== undefined && object.input !== null) { + message.input = String(object.input); + } else { + message.input = ""; + } + if (object.output !== undefined && object.output !== null) { + message.output = String(object.output); + } else { + message.output = ""; + } + return message; + }, + + toJSON(message: DominoOp): unknown { + const obj: any = {}; + message.key !== undefined && (obj.key = message.key); + message.input !== undefined && (obj.input = message.input); + message.output !== undefined && (obj.output = message.output); + return obj; + }, + + fromPartial(object: DeepPartial): DominoOp { + const message = { ...baseDominoOp } as DominoOp; + if (object.key !== undefined && object.key !== null) { + message.key = object.key; + } else { + message.key = ""; + } + if (object.input !== undefined && object.input !== null) { + message.input = object.input; + } else { + message.input = ""; + } + if (object.output !== undefined && object.output !== null) { + message.output = object.output; + } else { + message.output = ""; + } + return message; + }, +}; + +const baseProofOp: object = { type: "" }; + +export const ProofOp = { + encode(message: ProofOp, writer: Writer = Writer.create()): Writer { + if (message.type !== "") { + writer.uint32(10).string(message.type); + } + if (message.key.length !== 0) { + writer.uint32(18).bytes(message.key); + } + if (message.data.length !== 0) { + writer.uint32(26).bytes(message.data); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ProofOp { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseProofOp } as ProofOp; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.type = reader.string(); + break; + case 2: + message.key = reader.bytes(); + break; + case 3: + message.data = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ProofOp { + const message = { ...baseProofOp } as ProofOp; + if (object.type !== undefined && object.type !== null) { + message.type = String(object.type); + } else { + message.type = ""; + } + if (object.key !== undefined && object.key !== null) { + message.key = bytesFromBase64(object.key); + } + if (object.data !== undefined && object.data !== null) { + message.data = bytesFromBase64(object.data); + } + return message; + }, + + toJSON(message: ProofOp): unknown { + const obj: any = {}; + message.type !== undefined && (obj.type = message.type); + message.key !== undefined && + (obj.key = base64FromBytes( + message.key !== undefined ? message.key : new Uint8Array() + )); + message.data !== undefined && + (obj.data = base64FromBytes( + message.data !== undefined ? message.data : new Uint8Array() + )); + return obj; + }, + + fromPartial(object: DeepPartial): ProofOp { + const message = { ...baseProofOp } as ProofOp; + if (object.type !== undefined && object.type !== null) { + message.type = object.type; + } else { + message.type = ""; + } + if (object.key !== undefined && object.key !== null) { + message.key = object.key; + } else { + message.key = new Uint8Array(); + } + if (object.data !== undefined && object.data !== null) { + message.data = object.data; + } else { + message.data = new Uint8Array(); + } + return message; + }, +}; + +const baseProofOps: object = {}; + +export const ProofOps = { + encode(message: ProofOps, writer: Writer = Writer.create()): Writer { + for (const v of message.ops) { + ProofOp.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ProofOps { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseProofOps } as ProofOps; + message.ops = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.ops.push(ProofOp.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ProofOps { + const message = { ...baseProofOps } as ProofOps; + message.ops = []; + if (object.ops !== undefined && object.ops !== null) { + for (const e of object.ops) { + message.ops.push(ProofOp.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: ProofOps): unknown { + const obj: any = {}; + if (message.ops) { + obj.ops = message.ops.map((e) => (e ? ProofOp.toJSON(e) : undefined)); + } else { + obj.ops = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): ProofOps { + const message = { ...baseProofOps } as ProofOps; + message.ops = []; + if (object.ops !== undefined && object.ops !== null) { + for (const e of object.ops) { + message.ops.push(ProofOp.fromPartial(e)); + } + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/cosmos.base.tendermint.v1beta1/types/tendermint/p2p/types.ts b/ts-client/cosmos.base.tendermint.v1beta1/types/tendermint/p2p/types.ts new file mode 100644 index 00000000..1b081e95 --- /dev/null +++ b/ts-client/cosmos.base.tendermint.v1beta1/types/tendermint/p2p/types.ts @@ -0,0 +1,549 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "tendermint.p2p"; + +export interface NetAddress { + id: string; + ip: string; + port: number; +} + +export interface ProtocolVersion { + p2p: number; + block: number; + app: number; +} + +export interface DefaultNodeInfo { + protocolVersion: ProtocolVersion | undefined; + defaultNodeId: string; + listenAddr: string; + network: string; + version: string; + channels: Uint8Array; + moniker: string; + other: DefaultNodeInfoOther | undefined; +} + +export interface DefaultNodeInfoOther { + txIndex: string; + rpcAddress: string; +} + +const baseNetAddress: object = { id: "", ip: "", port: 0 }; + +export const NetAddress = { + encode(message: NetAddress, writer: Writer = Writer.create()): Writer { + if (message.id !== "") { + writer.uint32(10).string(message.id); + } + if (message.ip !== "") { + writer.uint32(18).string(message.ip); + } + if (message.port !== 0) { + writer.uint32(24).uint32(message.port); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): NetAddress { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseNetAddress } as NetAddress; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.id = reader.string(); + break; + case 2: + message.ip = reader.string(); + break; + case 3: + message.port = reader.uint32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): NetAddress { + const message = { ...baseNetAddress } as NetAddress; + if (object.id !== undefined && object.id !== null) { + message.id = String(object.id); + } else { + message.id = ""; + } + if (object.ip !== undefined && object.ip !== null) { + message.ip = String(object.ip); + } else { + message.ip = ""; + } + if (object.port !== undefined && object.port !== null) { + message.port = Number(object.port); + } else { + message.port = 0; + } + return message; + }, + + toJSON(message: NetAddress): unknown { + const obj: any = {}; + message.id !== undefined && (obj.id = message.id); + message.ip !== undefined && (obj.ip = message.ip); + message.port !== undefined && (obj.port = message.port); + return obj; + }, + + fromPartial(object: DeepPartial): NetAddress { + const message = { ...baseNetAddress } as NetAddress; + if (object.id !== undefined && object.id !== null) { + message.id = object.id; + } else { + message.id = ""; + } + if (object.ip !== undefined && object.ip !== null) { + message.ip = object.ip; + } else { + message.ip = ""; + } + if (object.port !== undefined && object.port !== null) { + message.port = object.port; + } else { + message.port = 0; + } + return message; + }, +}; + +const baseProtocolVersion: object = { p2p: 0, block: 0, app: 0 }; + +export const ProtocolVersion = { + encode(message: ProtocolVersion, writer: Writer = Writer.create()): Writer { + if (message.p2p !== 0) { + writer.uint32(8).uint64(message.p2p); + } + if (message.block !== 0) { + writer.uint32(16).uint64(message.block); + } + if (message.app !== 0) { + writer.uint32(24).uint64(message.app); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ProtocolVersion { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseProtocolVersion } as ProtocolVersion; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.p2p = longToNumber(reader.uint64() as Long); + break; + case 2: + message.block = longToNumber(reader.uint64() as Long); + break; + case 3: + message.app = longToNumber(reader.uint64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ProtocolVersion { + const message = { ...baseProtocolVersion } as ProtocolVersion; + if (object.p2p !== undefined && object.p2p !== null) { + message.p2p = Number(object.p2p); + } else { + message.p2p = 0; + } + if (object.block !== undefined && object.block !== null) { + message.block = Number(object.block); + } else { + message.block = 0; + } + if (object.app !== undefined && object.app !== null) { + message.app = Number(object.app); + } else { + message.app = 0; + } + return message; + }, + + toJSON(message: ProtocolVersion): unknown { + const obj: any = {}; + message.p2p !== undefined && (obj.p2p = message.p2p); + message.block !== undefined && (obj.block = message.block); + message.app !== undefined && (obj.app = message.app); + return obj; + }, + + fromPartial(object: DeepPartial): ProtocolVersion { + const message = { ...baseProtocolVersion } as ProtocolVersion; + if (object.p2p !== undefined && object.p2p !== null) { + message.p2p = object.p2p; + } else { + message.p2p = 0; + } + if (object.block !== undefined && object.block !== null) { + message.block = object.block; + } else { + message.block = 0; + } + if (object.app !== undefined && object.app !== null) { + message.app = object.app; + } else { + message.app = 0; + } + return message; + }, +}; + +const baseDefaultNodeInfo: object = { + defaultNodeId: "", + listenAddr: "", + network: "", + version: "", + moniker: "", +}; + +export const DefaultNodeInfo = { + encode(message: DefaultNodeInfo, writer: Writer = Writer.create()): Writer { + if (message.protocolVersion !== undefined) { + ProtocolVersion.encode( + message.protocolVersion, + writer.uint32(10).fork() + ).ldelim(); + } + if (message.defaultNodeId !== "") { + writer.uint32(18).string(message.defaultNodeId); + } + if (message.listenAddr !== "") { + writer.uint32(26).string(message.listenAddr); + } + if (message.network !== "") { + writer.uint32(34).string(message.network); + } + if (message.version !== "") { + writer.uint32(42).string(message.version); + } + if (message.channels.length !== 0) { + writer.uint32(50).bytes(message.channels); + } + if (message.moniker !== "") { + writer.uint32(58).string(message.moniker); + } + if (message.other !== undefined) { + DefaultNodeInfoOther.encode( + message.other, + writer.uint32(66).fork() + ).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): DefaultNodeInfo { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseDefaultNodeInfo } as DefaultNodeInfo; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.protocolVersion = ProtocolVersion.decode( + reader, + reader.uint32() + ); + break; + case 2: + message.defaultNodeId = reader.string(); + break; + case 3: + message.listenAddr = reader.string(); + break; + case 4: + message.network = reader.string(); + break; + case 5: + message.version = reader.string(); + break; + case 6: + message.channels = reader.bytes(); + break; + case 7: + message.moniker = reader.string(); + break; + case 8: + message.other = DefaultNodeInfoOther.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DefaultNodeInfo { + const message = { ...baseDefaultNodeInfo } as DefaultNodeInfo; + if ( + object.protocolVersion !== undefined && + object.protocolVersion !== null + ) { + message.protocolVersion = ProtocolVersion.fromJSON( + object.protocolVersion + ); + } else { + message.protocolVersion = undefined; + } + if (object.defaultNodeId !== undefined && object.defaultNodeId !== null) { + message.defaultNodeId = String(object.defaultNodeId); + } else { + message.defaultNodeId = ""; + } + if (object.listenAddr !== undefined && object.listenAddr !== null) { + message.listenAddr = String(object.listenAddr); + } else { + message.listenAddr = ""; + } + if (object.network !== undefined && object.network !== null) { + message.network = String(object.network); + } else { + message.network = ""; + } + if (object.version !== undefined && object.version !== null) { + message.version = String(object.version); + } else { + message.version = ""; + } + if (object.channels !== undefined && object.channels !== null) { + message.channels = bytesFromBase64(object.channels); + } + if (object.moniker !== undefined && object.moniker !== null) { + message.moniker = String(object.moniker); + } else { + message.moniker = ""; + } + if (object.other !== undefined && object.other !== null) { + message.other = DefaultNodeInfoOther.fromJSON(object.other); + } else { + message.other = undefined; + } + return message; + }, + + toJSON(message: DefaultNodeInfo): unknown { + const obj: any = {}; + message.protocolVersion !== undefined && + (obj.protocolVersion = message.protocolVersion + ? ProtocolVersion.toJSON(message.protocolVersion) + : undefined); + message.defaultNodeId !== undefined && + (obj.defaultNodeId = message.defaultNodeId); + message.listenAddr !== undefined && (obj.listenAddr = message.listenAddr); + message.network !== undefined && (obj.network = message.network); + message.version !== undefined && (obj.version = message.version); + message.channels !== undefined && + (obj.channels = base64FromBytes( + message.channels !== undefined ? message.channels : new Uint8Array() + )); + message.moniker !== undefined && (obj.moniker = message.moniker); + message.other !== undefined && + (obj.other = message.other + ? DefaultNodeInfoOther.toJSON(message.other) + : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): DefaultNodeInfo { + const message = { ...baseDefaultNodeInfo } as DefaultNodeInfo; + if ( + object.protocolVersion !== undefined && + object.protocolVersion !== null + ) { + message.protocolVersion = ProtocolVersion.fromPartial( + object.protocolVersion + ); + } else { + message.protocolVersion = undefined; + } + if (object.defaultNodeId !== undefined && object.defaultNodeId !== null) { + message.defaultNodeId = object.defaultNodeId; + } else { + message.defaultNodeId = ""; + } + if (object.listenAddr !== undefined && object.listenAddr !== null) { + message.listenAddr = object.listenAddr; + } else { + message.listenAddr = ""; + } + if (object.network !== undefined && object.network !== null) { + message.network = object.network; + } else { + message.network = ""; + } + if (object.version !== undefined && object.version !== null) { + message.version = object.version; + } else { + message.version = ""; + } + if (object.channels !== undefined && object.channels !== null) { + message.channels = object.channels; + } else { + message.channels = new Uint8Array(); + } + if (object.moniker !== undefined && object.moniker !== null) { + message.moniker = object.moniker; + } else { + message.moniker = ""; + } + if (object.other !== undefined && object.other !== null) { + message.other = DefaultNodeInfoOther.fromPartial(object.other); + } else { + message.other = undefined; + } + return message; + }, +}; + +const baseDefaultNodeInfoOther: object = { txIndex: "", rpcAddress: "" }; + +export const DefaultNodeInfoOther = { + encode( + message: DefaultNodeInfoOther, + writer: Writer = Writer.create() + ): Writer { + if (message.txIndex !== "") { + writer.uint32(10).string(message.txIndex); + } + if (message.rpcAddress !== "") { + writer.uint32(18).string(message.rpcAddress); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): DefaultNodeInfoOther { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseDefaultNodeInfoOther } as DefaultNodeInfoOther; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.txIndex = reader.string(); + break; + case 2: + message.rpcAddress = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DefaultNodeInfoOther { + const message = { ...baseDefaultNodeInfoOther } as DefaultNodeInfoOther; + if (object.txIndex !== undefined && object.txIndex !== null) { + message.txIndex = String(object.txIndex); + } else { + message.txIndex = ""; + } + if (object.rpcAddress !== undefined && object.rpcAddress !== null) { + message.rpcAddress = String(object.rpcAddress); + } else { + message.rpcAddress = ""; + } + return message; + }, + + toJSON(message: DefaultNodeInfoOther): unknown { + const obj: any = {}; + message.txIndex !== undefined && (obj.txIndex = message.txIndex); + message.rpcAddress !== undefined && (obj.rpcAddress = message.rpcAddress); + return obj; + }, + + fromPartial(object: DeepPartial): DefaultNodeInfoOther { + const message = { ...baseDefaultNodeInfoOther } as DefaultNodeInfoOther; + if (object.txIndex !== undefined && object.txIndex !== null) { + message.txIndex = object.txIndex; + } else { + message.txIndex = ""; + } + if (object.rpcAddress !== undefined && object.rpcAddress !== null) { + message.rpcAddress = object.rpcAddress; + } else { + message.rpcAddress = ""; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/cosmos.base.tendermint.v1beta1/types/tendermint/types/block.ts b/ts-client/cosmos.base.tendermint.v1beta1/types/tendermint/types/block.ts new file mode 100644 index 00000000..64d2bbd3 --- /dev/null +++ b/ts-client/cosmos.base.tendermint.v1beta1/types/tendermint/types/block.ts @@ -0,0 +1,138 @@ +/* eslint-disable */ +import { Header, Data, Commit } from "../../tendermint/types/types"; +import { EvidenceList } from "../../tendermint/types/evidence"; +import { Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "tendermint.types"; + +export interface Block { + header: Header | undefined; + data: Data | undefined; + evidence: EvidenceList | undefined; + lastCommit: Commit | undefined; +} + +const baseBlock: object = {}; + +export const Block = { + encode(message: Block, writer: Writer = Writer.create()): Writer { + if (message.header !== undefined) { + Header.encode(message.header, writer.uint32(10).fork()).ldelim(); + } + if (message.data !== undefined) { + Data.encode(message.data, writer.uint32(18).fork()).ldelim(); + } + if (message.evidence !== undefined) { + EvidenceList.encode(message.evidence, writer.uint32(26).fork()).ldelim(); + } + if (message.lastCommit !== undefined) { + Commit.encode(message.lastCommit, writer.uint32(34).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Block { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseBlock } as Block; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.header = Header.decode(reader, reader.uint32()); + break; + case 2: + message.data = Data.decode(reader, reader.uint32()); + break; + case 3: + message.evidence = EvidenceList.decode(reader, reader.uint32()); + break; + case 4: + message.lastCommit = Commit.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Block { + const message = { ...baseBlock } as Block; + if (object.header !== undefined && object.header !== null) { + message.header = Header.fromJSON(object.header); + } else { + message.header = undefined; + } + if (object.data !== undefined && object.data !== null) { + message.data = Data.fromJSON(object.data); + } else { + message.data = undefined; + } + if (object.evidence !== undefined && object.evidence !== null) { + message.evidence = EvidenceList.fromJSON(object.evidence); + } else { + message.evidence = undefined; + } + if (object.lastCommit !== undefined && object.lastCommit !== null) { + message.lastCommit = Commit.fromJSON(object.lastCommit); + } else { + message.lastCommit = undefined; + } + return message; + }, + + toJSON(message: Block): unknown { + const obj: any = {}; + message.header !== undefined && + (obj.header = message.header ? Header.toJSON(message.header) : undefined); + message.data !== undefined && + (obj.data = message.data ? Data.toJSON(message.data) : undefined); + message.evidence !== undefined && + (obj.evidence = message.evidence + ? EvidenceList.toJSON(message.evidence) + : undefined); + message.lastCommit !== undefined && + (obj.lastCommit = message.lastCommit + ? Commit.toJSON(message.lastCommit) + : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): Block { + const message = { ...baseBlock } as Block; + if (object.header !== undefined && object.header !== null) { + message.header = Header.fromPartial(object.header); + } else { + message.header = undefined; + } + if (object.data !== undefined && object.data !== null) { + message.data = Data.fromPartial(object.data); + } else { + message.data = undefined; + } + if (object.evidence !== undefined && object.evidence !== null) { + message.evidence = EvidenceList.fromPartial(object.evidence); + } else { + message.evidence = undefined; + } + if (object.lastCommit !== undefined && object.lastCommit !== null) { + message.lastCommit = Commit.fromPartial(object.lastCommit); + } else { + message.lastCommit = undefined; + } + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/cosmos.base.tendermint.v1beta1/types/tendermint/types/evidence.ts b/ts-client/cosmos.base.tendermint.v1beta1/types/tendermint/types/evidence.ts new file mode 100644 index 00000000..04ec70a4 --- /dev/null +++ b/ts-client/cosmos.base.tendermint.v1beta1/types/tendermint/types/evidence.ts @@ -0,0 +1,602 @@ +/* eslint-disable */ +import { Timestamp } from "../../google/protobuf/timestamp"; +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; +import { Vote, LightBlock } from "../../tendermint/types/types"; +import { Validator } from "../../tendermint/types/validator"; + +export const protobufPackage = "tendermint.types"; + +export interface Evidence { + duplicateVoteEvidence: DuplicateVoteEvidence | undefined; + lightClientAttackEvidence: LightClientAttackEvidence | undefined; +} + +/** DuplicateVoteEvidence contains evidence of a validator signed two conflicting votes. */ +export interface DuplicateVoteEvidence { + voteA: Vote | undefined; + voteB: Vote | undefined; + totalVotingPower: number; + validatorPower: number; + timestamp: Date | undefined; +} + +/** LightClientAttackEvidence contains evidence of a set of validators attempting to mislead a light client. */ +export interface LightClientAttackEvidence { + conflictingBlock: LightBlock | undefined; + commonHeight: number; + byzantineValidators: Validator[]; + totalVotingPower: number; + timestamp: Date | undefined; +} + +export interface EvidenceList { + evidence: Evidence[]; +} + +const baseEvidence: object = {}; + +export const Evidence = { + encode(message: Evidence, writer: Writer = Writer.create()): Writer { + if (message.duplicateVoteEvidence !== undefined) { + DuplicateVoteEvidence.encode( + message.duplicateVoteEvidence, + writer.uint32(10).fork() + ).ldelim(); + } + if (message.lightClientAttackEvidence !== undefined) { + LightClientAttackEvidence.encode( + message.lightClientAttackEvidence, + writer.uint32(18).fork() + ).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Evidence { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseEvidence } as Evidence; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.duplicateVoteEvidence = DuplicateVoteEvidence.decode( + reader, + reader.uint32() + ); + break; + case 2: + message.lightClientAttackEvidence = LightClientAttackEvidence.decode( + reader, + reader.uint32() + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Evidence { + const message = { ...baseEvidence } as Evidence; + if ( + object.duplicateVoteEvidence !== undefined && + object.duplicateVoteEvidence !== null + ) { + message.duplicateVoteEvidence = DuplicateVoteEvidence.fromJSON( + object.duplicateVoteEvidence + ); + } else { + message.duplicateVoteEvidence = undefined; + } + if ( + object.lightClientAttackEvidence !== undefined && + object.lightClientAttackEvidence !== null + ) { + message.lightClientAttackEvidence = LightClientAttackEvidence.fromJSON( + object.lightClientAttackEvidence + ); + } else { + message.lightClientAttackEvidence = undefined; + } + return message; + }, + + toJSON(message: Evidence): unknown { + const obj: any = {}; + message.duplicateVoteEvidence !== undefined && + (obj.duplicateVoteEvidence = message.duplicateVoteEvidence + ? DuplicateVoteEvidence.toJSON(message.duplicateVoteEvidence) + : undefined); + message.lightClientAttackEvidence !== undefined && + (obj.lightClientAttackEvidence = message.lightClientAttackEvidence + ? LightClientAttackEvidence.toJSON(message.lightClientAttackEvidence) + : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): Evidence { + const message = { ...baseEvidence } as Evidence; + if ( + object.duplicateVoteEvidence !== undefined && + object.duplicateVoteEvidence !== null + ) { + message.duplicateVoteEvidence = DuplicateVoteEvidence.fromPartial( + object.duplicateVoteEvidence + ); + } else { + message.duplicateVoteEvidence = undefined; + } + if ( + object.lightClientAttackEvidence !== undefined && + object.lightClientAttackEvidence !== null + ) { + message.lightClientAttackEvidence = LightClientAttackEvidence.fromPartial( + object.lightClientAttackEvidence + ); + } else { + message.lightClientAttackEvidence = undefined; + } + return message; + }, +}; + +const baseDuplicateVoteEvidence: object = { + totalVotingPower: 0, + validatorPower: 0, +}; + +export const DuplicateVoteEvidence = { + encode( + message: DuplicateVoteEvidence, + writer: Writer = Writer.create() + ): Writer { + if (message.voteA !== undefined) { + Vote.encode(message.voteA, writer.uint32(10).fork()).ldelim(); + } + if (message.voteB !== undefined) { + Vote.encode(message.voteB, writer.uint32(18).fork()).ldelim(); + } + if (message.totalVotingPower !== 0) { + writer.uint32(24).int64(message.totalVotingPower); + } + if (message.validatorPower !== 0) { + writer.uint32(32).int64(message.validatorPower); + } + if (message.timestamp !== undefined) { + Timestamp.encode( + toTimestamp(message.timestamp), + writer.uint32(42).fork() + ).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): DuplicateVoteEvidence { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseDuplicateVoteEvidence } as DuplicateVoteEvidence; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.voteA = Vote.decode(reader, reader.uint32()); + break; + case 2: + message.voteB = Vote.decode(reader, reader.uint32()); + break; + case 3: + message.totalVotingPower = longToNumber(reader.int64() as Long); + break; + case 4: + message.validatorPower = longToNumber(reader.int64() as Long); + break; + case 5: + message.timestamp = fromTimestamp( + Timestamp.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DuplicateVoteEvidence { + const message = { ...baseDuplicateVoteEvidence } as DuplicateVoteEvidence; + if (object.voteA !== undefined && object.voteA !== null) { + message.voteA = Vote.fromJSON(object.voteA); + } else { + message.voteA = undefined; + } + if (object.voteB !== undefined && object.voteB !== null) { + message.voteB = Vote.fromJSON(object.voteB); + } else { + message.voteB = undefined; + } + if ( + object.totalVotingPower !== undefined && + object.totalVotingPower !== null + ) { + message.totalVotingPower = Number(object.totalVotingPower); + } else { + message.totalVotingPower = 0; + } + if (object.validatorPower !== undefined && object.validatorPower !== null) { + message.validatorPower = Number(object.validatorPower); + } else { + message.validatorPower = 0; + } + if (object.timestamp !== undefined && object.timestamp !== null) { + message.timestamp = fromJsonTimestamp(object.timestamp); + } else { + message.timestamp = undefined; + } + return message; + }, + + toJSON(message: DuplicateVoteEvidence): unknown { + const obj: any = {}; + message.voteA !== undefined && + (obj.voteA = message.voteA ? Vote.toJSON(message.voteA) : undefined); + message.voteB !== undefined && + (obj.voteB = message.voteB ? Vote.toJSON(message.voteB) : undefined); + message.totalVotingPower !== undefined && + (obj.totalVotingPower = message.totalVotingPower); + message.validatorPower !== undefined && + (obj.validatorPower = message.validatorPower); + message.timestamp !== undefined && + (obj.timestamp = + message.timestamp !== undefined + ? message.timestamp.toISOString() + : null); + return obj; + }, + + fromPartial( + object: DeepPartial + ): DuplicateVoteEvidence { + const message = { ...baseDuplicateVoteEvidence } as DuplicateVoteEvidence; + if (object.voteA !== undefined && object.voteA !== null) { + message.voteA = Vote.fromPartial(object.voteA); + } else { + message.voteA = undefined; + } + if (object.voteB !== undefined && object.voteB !== null) { + message.voteB = Vote.fromPartial(object.voteB); + } else { + message.voteB = undefined; + } + if ( + object.totalVotingPower !== undefined && + object.totalVotingPower !== null + ) { + message.totalVotingPower = object.totalVotingPower; + } else { + message.totalVotingPower = 0; + } + if (object.validatorPower !== undefined && object.validatorPower !== null) { + message.validatorPower = object.validatorPower; + } else { + message.validatorPower = 0; + } + if (object.timestamp !== undefined && object.timestamp !== null) { + message.timestamp = object.timestamp; + } else { + message.timestamp = undefined; + } + return message; + }, +}; + +const baseLightClientAttackEvidence: object = { + commonHeight: 0, + totalVotingPower: 0, +}; + +export const LightClientAttackEvidence = { + encode( + message: LightClientAttackEvidence, + writer: Writer = Writer.create() + ): Writer { + if (message.conflictingBlock !== undefined) { + LightBlock.encode( + message.conflictingBlock, + writer.uint32(10).fork() + ).ldelim(); + } + if (message.commonHeight !== 0) { + writer.uint32(16).int64(message.commonHeight); + } + for (const v of message.byzantineValidators) { + Validator.encode(v!, writer.uint32(26).fork()).ldelim(); + } + if (message.totalVotingPower !== 0) { + writer.uint32(32).int64(message.totalVotingPower); + } + if (message.timestamp !== undefined) { + Timestamp.encode( + toTimestamp(message.timestamp), + writer.uint32(42).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): LightClientAttackEvidence { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseLightClientAttackEvidence, + } as LightClientAttackEvidence; + message.byzantineValidators = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.conflictingBlock = LightBlock.decode(reader, reader.uint32()); + break; + case 2: + message.commonHeight = longToNumber(reader.int64() as Long); + break; + case 3: + message.byzantineValidators.push( + Validator.decode(reader, reader.uint32()) + ); + break; + case 4: + message.totalVotingPower = longToNumber(reader.int64() as Long); + break; + case 5: + message.timestamp = fromTimestamp( + Timestamp.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): LightClientAttackEvidence { + const message = { + ...baseLightClientAttackEvidence, + } as LightClientAttackEvidence; + message.byzantineValidators = []; + if ( + object.conflictingBlock !== undefined && + object.conflictingBlock !== null + ) { + message.conflictingBlock = LightBlock.fromJSON(object.conflictingBlock); + } else { + message.conflictingBlock = undefined; + } + if (object.commonHeight !== undefined && object.commonHeight !== null) { + message.commonHeight = Number(object.commonHeight); + } else { + message.commonHeight = 0; + } + if ( + object.byzantineValidators !== undefined && + object.byzantineValidators !== null + ) { + for (const e of object.byzantineValidators) { + message.byzantineValidators.push(Validator.fromJSON(e)); + } + } + if ( + object.totalVotingPower !== undefined && + object.totalVotingPower !== null + ) { + message.totalVotingPower = Number(object.totalVotingPower); + } else { + message.totalVotingPower = 0; + } + if (object.timestamp !== undefined && object.timestamp !== null) { + message.timestamp = fromJsonTimestamp(object.timestamp); + } else { + message.timestamp = undefined; + } + return message; + }, + + toJSON(message: LightClientAttackEvidence): unknown { + const obj: any = {}; + message.conflictingBlock !== undefined && + (obj.conflictingBlock = message.conflictingBlock + ? LightBlock.toJSON(message.conflictingBlock) + : undefined); + message.commonHeight !== undefined && + (obj.commonHeight = message.commonHeight); + if (message.byzantineValidators) { + obj.byzantineValidators = message.byzantineValidators.map((e) => + e ? Validator.toJSON(e) : undefined + ); + } else { + obj.byzantineValidators = []; + } + message.totalVotingPower !== undefined && + (obj.totalVotingPower = message.totalVotingPower); + message.timestamp !== undefined && + (obj.timestamp = + message.timestamp !== undefined + ? message.timestamp.toISOString() + : null); + return obj; + }, + + fromPartial( + object: DeepPartial + ): LightClientAttackEvidence { + const message = { + ...baseLightClientAttackEvidence, + } as LightClientAttackEvidence; + message.byzantineValidators = []; + if ( + object.conflictingBlock !== undefined && + object.conflictingBlock !== null + ) { + message.conflictingBlock = LightBlock.fromPartial( + object.conflictingBlock + ); + } else { + message.conflictingBlock = undefined; + } + if (object.commonHeight !== undefined && object.commonHeight !== null) { + message.commonHeight = object.commonHeight; + } else { + message.commonHeight = 0; + } + if ( + object.byzantineValidators !== undefined && + object.byzantineValidators !== null + ) { + for (const e of object.byzantineValidators) { + message.byzantineValidators.push(Validator.fromPartial(e)); + } + } + if ( + object.totalVotingPower !== undefined && + object.totalVotingPower !== null + ) { + message.totalVotingPower = object.totalVotingPower; + } else { + message.totalVotingPower = 0; + } + if (object.timestamp !== undefined && object.timestamp !== null) { + message.timestamp = object.timestamp; + } else { + message.timestamp = undefined; + } + return message; + }, +}; + +const baseEvidenceList: object = {}; + +export const EvidenceList = { + encode(message: EvidenceList, writer: Writer = Writer.create()): Writer { + for (const v of message.evidence) { + Evidence.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): EvidenceList { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseEvidenceList } as EvidenceList; + message.evidence = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.evidence.push(Evidence.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EvidenceList { + const message = { ...baseEvidenceList } as EvidenceList; + message.evidence = []; + if (object.evidence !== undefined && object.evidence !== null) { + for (const e of object.evidence) { + message.evidence.push(Evidence.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: EvidenceList): unknown { + const obj: any = {}; + if (message.evidence) { + obj.evidence = message.evidence.map((e) => + e ? Evidence.toJSON(e) : undefined + ); + } else { + obj.evidence = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): EvidenceList { + const message = { ...baseEvidenceList } as EvidenceList; + message.evidence = []; + if (object.evidence !== undefined && object.evidence !== null) { + for (const e of object.evidence) { + message.evidence.push(Evidence.fromPartial(e)); + } + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function toTimestamp(date: Date): Timestamp { + const seconds = date.getTime() / 1_000; + const nanos = (date.getTime() % 1_000) * 1_000_000; + return { seconds, nanos }; +} + +function fromTimestamp(t: Timestamp): Date { + let millis = t.seconds * 1_000; + millis += t.nanos / 1_000_000; + return new Date(millis); +} + +function fromJsonTimestamp(o: any): Date { + if (o instanceof Date) { + return o; + } else if (typeof o === "string") { + return new Date(o); + } else { + return fromTimestamp(Timestamp.fromJSON(o)); + } +} + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/cosmos.base.tendermint.v1beta1/types/tendermint/types/types.ts b/ts-client/cosmos.base.tendermint.v1beta1/types/tendermint/types/types.ts new file mode 100644 index 00000000..429c14a4 --- /dev/null +++ b/ts-client/cosmos.base.tendermint.v1beta1/types/tendermint/types/types.ts @@ -0,0 +1,1912 @@ +/* eslint-disable */ +import { Timestamp } from "../../google/protobuf/timestamp"; +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; +import { Proof } from "../../tendermint/crypto/proof"; +import { Consensus } from "../../tendermint/version/types"; +import { ValidatorSet } from "../../tendermint/types/validator"; + +export const protobufPackage = "tendermint.types"; + +/** BlockIdFlag indicates which BlcokID the signature is for */ +export enum BlockIDFlag { + BLOCK_ID_FLAG_UNKNOWN = 0, + BLOCK_ID_FLAG_ABSENT = 1, + BLOCK_ID_FLAG_COMMIT = 2, + BLOCK_ID_FLAG_NIL = 3, + UNRECOGNIZED = -1, +} + +export function blockIDFlagFromJSON(object: any): BlockIDFlag { + switch (object) { + case 0: + case "BLOCK_ID_FLAG_UNKNOWN": + return BlockIDFlag.BLOCK_ID_FLAG_UNKNOWN; + case 1: + case "BLOCK_ID_FLAG_ABSENT": + return BlockIDFlag.BLOCK_ID_FLAG_ABSENT; + case 2: + case "BLOCK_ID_FLAG_COMMIT": + return BlockIDFlag.BLOCK_ID_FLAG_COMMIT; + case 3: + case "BLOCK_ID_FLAG_NIL": + return BlockIDFlag.BLOCK_ID_FLAG_NIL; + case -1: + case "UNRECOGNIZED": + default: + return BlockIDFlag.UNRECOGNIZED; + } +} + +export function blockIDFlagToJSON(object: BlockIDFlag): string { + switch (object) { + case BlockIDFlag.BLOCK_ID_FLAG_UNKNOWN: + return "BLOCK_ID_FLAG_UNKNOWN"; + case BlockIDFlag.BLOCK_ID_FLAG_ABSENT: + return "BLOCK_ID_FLAG_ABSENT"; + case BlockIDFlag.BLOCK_ID_FLAG_COMMIT: + return "BLOCK_ID_FLAG_COMMIT"; + case BlockIDFlag.BLOCK_ID_FLAG_NIL: + return "BLOCK_ID_FLAG_NIL"; + default: + return "UNKNOWN"; + } +} + +/** SignedMsgType is a type of signed message in the consensus. */ +export enum SignedMsgType { + SIGNED_MSG_TYPE_UNKNOWN = 0, + /** SIGNED_MSG_TYPE_PREVOTE - Votes */ + SIGNED_MSG_TYPE_PREVOTE = 1, + SIGNED_MSG_TYPE_PRECOMMIT = 2, + /** SIGNED_MSG_TYPE_PROPOSAL - Proposals */ + SIGNED_MSG_TYPE_PROPOSAL = 32, + UNRECOGNIZED = -1, +} + +export function signedMsgTypeFromJSON(object: any): SignedMsgType { + switch (object) { + case 0: + case "SIGNED_MSG_TYPE_UNKNOWN": + return SignedMsgType.SIGNED_MSG_TYPE_UNKNOWN; + case 1: + case "SIGNED_MSG_TYPE_PREVOTE": + return SignedMsgType.SIGNED_MSG_TYPE_PREVOTE; + case 2: + case "SIGNED_MSG_TYPE_PRECOMMIT": + return SignedMsgType.SIGNED_MSG_TYPE_PRECOMMIT; + case 32: + case "SIGNED_MSG_TYPE_PROPOSAL": + return SignedMsgType.SIGNED_MSG_TYPE_PROPOSAL; + case -1: + case "UNRECOGNIZED": + default: + return SignedMsgType.UNRECOGNIZED; + } +} + +export function signedMsgTypeToJSON(object: SignedMsgType): string { + switch (object) { + case SignedMsgType.SIGNED_MSG_TYPE_UNKNOWN: + return "SIGNED_MSG_TYPE_UNKNOWN"; + case SignedMsgType.SIGNED_MSG_TYPE_PREVOTE: + return "SIGNED_MSG_TYPE_PREVOTE"; + case SignedMsgType.SIGNED_MSG_TYPE_PRECOMMIT: + return "SIGNED_MSG_TYPE_PRECOMMIT"; + case SignedMsgType.SIGNED_MSG_TYPE_PROPOSAL: + return "SIGNED_MSG_TYPE_PROPOSAL"; + default: + return "UNKNOWN"; + } +} + +/** PartsetHeader */ +export interface PartSetHeader { + total: number; + hash: Uint8Array; +} + +export interface Part { + index: number; + bytes: Uint8Array; + proof: Proof | undefined; +} + +/** BlockID */ +export interface BlockID { + hash: Uint8Array; + partSetHeader: PartSetHeader | undefined; +} + +/** Header defines the structure of a block header. */ +export interface Header { + /** basic block info */ + version: Consensus | undefined; + chainId: string; + height: number; + time: Date | undefined; + /** prev block info */ + lastBlockId: BlockID | undefined; + /** hashes of block data */ + lastCommitHash: Uint8Array; + /** transactions */ + dataHash: Uint8Array; + /** hashes from the app output from the prev block */ + validatorsHash: Uint8Array; + /** validators for the next block */ + nextValidatorsHash: Uint8Array; + /** consensus params for current block */ + consensusHash: Uint8Array; + /** state after txs from the previous block */ + appHash: Uint8Array; + /** root hash of all results from the txs from the previous block */ + lastResultsHash: Uint8Array; + /** consensus info */ + evidenceHash: Uint8Array; + /** original proposer of the block */ + proposerAddress: Uint8Array; +} + +/** Data contains the set of transactions included in the block */ +export interface Data { + /** + * Txs that will be applied by state @ block.Height+1. + * NOTE: not all txs here are valid. We're just agreeing on the order first. + * This means that block.AppHash does not include these txs. + */ + txs: Uint8Array[]; +} + +/** + * Vote represents a prevote, precommit, or commit vote from validators for + * consensus. + */ +export interface Vote { + type: SignedMsgType; + height: number; + round: number; + /** zero if vote is nil. */ + blockId: BlockID | undefined; + timestamp: Date | undefined; + validatorAddress: Uint8Array; + validatorIndex: number; + signature: Uint8Array; +} + +/** Commit contains the evidence that a block was committed by a set of validators. */ +export interface Commit { + height: number; + round: number; + blockId: BlockID | undefined; + signatures: CommitSig[]; +} + +/** CommitSig is a part of the Vote included in a Commit. */ +export interface CommitSig { + blockIdFlag: BlockIDFlag; + validatorAddress: Uint8Array; + timestamp: Date | undefined; + signature: Uint8Array; +} + +export interface Proposal { + type: SignedMsgType; + height: number; + round: number; + polRound: number; + blockId: BlockID | undefined; + timestamp: Date | undefined; + signature: Uint8Array; +} + +export interface SignedHeader { + header: Header | undefined; + commit: Commit | undefined; +} + +export interface LightBlock { + signedHeader: SignedHeader | undefined; + validatorSet: ValidatorSet | undefined; +} + +export interface BlockMeta { + blockId: BlockID | undefined; + blockSize: number; + header: Header | undefined; + numTxs: number; +} + +/** TxProof represents a Merkle proof of the presence of a transaction in the Merkle tree. */ +export interface TxProof { + rootHash: Uint8Array; + data: Uint8Array; + proof: Proof | undefined; +} + +const basePartSetHeader: object = { total: 0 }; + +export const PartSetHeader = { + encode(message: PartSetHeader, writer: Writer = Writer.create()): Writer { + if (message.total !== 0) { + writer.uint32(8).uint32(message.total); + } + if (message.hash.length !== 0) { + writer.uint32(18).bytes(message.hash); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): PartSetHeader { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...basePartSetHeader } as PartSetHeader; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.total = reader.uint32(); + break; + case 2: + message.hash = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): PartSetHeader { + const message = { ...basePartSetHeader } as PartSetHeader; + if (object.total !== undefined && object.total !== null) { + message.total = Number(object.total); + } else { + message.total = 0; + } + if (object.hash !== undefined && object.hash !== null) { + message.hash = bytesFromBase64(object.hash); + } + return message; + }, + + toJSON(message: PartSetHeader): unknown { + const obj: any = {}; + message.total !== undefined && (obj.total = message.total); + message.hash !== undefined && + (obj.hash = base64FromBytes( + message.hash !== undefined ? message.hash : new Uint8Array() + )); + return obj; + }, + + fromPartial(object: DeepPartial): PartSetHeader { + const message = { ...basePartSetHeader } as PartSetHeader; + if (object.total !== undefined && object.total !== null) { + message.total = object.total; + } else { + message.total = 0; + } + if (object.hash !== undefined && object.hash !== null) { + message.hash = object.hash; + } else { + message.hash = new Uint8Array(); + } + return message; + }, +}; + +const basePart: object = { index: 0 }; + +export const Part = { + encode(message: Part, writer: Writer = Writer.create()): Writer { + if (message.index !== 0) { + writer.uint32(8).uint32(message.index); + } + if (message.bytes.length !== 0) { + writer.uint32(18).bytes(message.bytes); + } + if (message.proof !== undefined) { + Proof.encode(message.proof, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Part { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...basePart } as Part; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.index = reader.uint32(); + break; + case 2: + message.bytes = reader.bytes(); + break; + case 3: + message.proof = Proof.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Part { + const message = { ...basePart } as Part; + if (object.index !== undefined && object.index !== null) { + message.index = Number(object.index); + } else { + message.index = 0; + } + if (object.bytes !== undefined && object.bytes !== null) { + message.bytes = bytesFromBase64(object.bytes); + } + if (object.proof !== undefined && object.proof !== null) { + message.proof = Proof.fromJSON(object.proof); + } else { + message.proof = undefined; + } + return message; + }, + + toJSON(message: Part): unknown { + const obj: any = {}; + message.index !== undefined && (obj.index = message.index); + message.bytes !== undefined && + (obj.bytes = base64FromBytes( + message.bytes !== undefined ? message.bytes : new Uint8Array() + )); + message.proof !== undefined && + (obj.proof = message.proof ? Proof.toJSON(message.proof) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): Part { + const message = { ...basePart } as Part; + if (object.index !== undefined && object.index !== null) { + message.index = object.index; + } else { + message.index = 0; + } + if (object.bytes !== undefined && object.bytes !== null) { + message.bytes = object.bytes; + } else { + message.bytes = new Uint8Array(); + } + if (object.proof !== undefined && object.proof !== null) { + message.proof = Proof.fromPartial(object.proof); + } else { + message.proof = undefined; + } + return message; + }, +}; + +const baseBlockID: object = {}; + +export const BlockID = { + encode(message: BlockID, writer: Writer = Writer.create()): Writer { + if (message.hash.length !== 0) { + writer.uint32(10).bytes(message.hash); + } + if (message.partSetHeader !== undefined) { + PartSetHeader.encode( + message.partSetHeader, + writer.uint32(18).fork() + ).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): BlockID { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseBlockID } as BlockID; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.hash = reader.bytes(); + break; + case 2: + message.partSetHeader = PartSetHeader.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): BlockID { + const message = { ...baseBlockID } as BlockID; + if (object.hash !== undefined && object.hash !== null) { + message.hash = bytesFromBase64(object.hash); + } + if (object.partSetHeader !== undefined && object.partSetHeader !== null) { + message.partSetHeader = PartSetHeader.fromJSON(object.partSetHeader); + } else { + message.partSetHeader = undefined; + } + return message; + }, + + toJSON(message: BlockID): unknown { + const obj: any = {}; + message.hash !== undefined && + (obj.hash = base64FromBytes( + message.hash !== undefined ? message.hash : new Uint8Array() + )); + message.partSetHeader !== undefined && + (obj.partSetHeader = message.partSetHeader + ? PartSetHeader.toJSON(message.partSetHeader) + : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): BlockID { + const message = { ...baseBlockID } as BlockID; + if (object.hash !== undefined && object.hash !== null) { + message.hash = object.hash; + } else { + message.hash = new Uint8Array(); + } + if (object.partSetHeader !== undefined && object.partSetHeader !== null) { + message.partSetHeader = PartSetHeader.fromPartial(object.partSetHeader); + } else { + message.partSetHeader = undefined; + } + return message; + }, +}; + +const baseHeader: object = { chainId: "", height: 0 }; + +export const Header = { + encode(message: Header, writer: Writer = Writer.create()): Writer { + if (message.version !== undefined) { + Consensus.encode(message.version, writer.uint32(10).fork()).ldelim(); + } + if (message.chainId !== "") { + writer.uint32(18).string(message.chainId); + } + if (message.height !== 0) { + writer.uint32(24).int64(message.height); + } + if (message.time !== undefined) { + Timestamp.encode( + toTimestamp(message.time), + writer.uint32(34).fork() + ).ldelim(); + } + if (message.lastBlockId !== undefined) { + BlockID.encode(message.lastBlockId, writer.uint32(42).fork()).ldelim(); + } + if (message.lastCommitHash.length !== 0) { + writer.uint32(50).bytes(message.lastCommitHash); + } + if (message.dataHash.length !== 0) { + writer.uint32(58).bytes(message.dataHash); + } + if (message.validatorsHash.length !== 0) { + writer.uint32(66).bytes(message.validatorsHash); + } + if (message.nextValidatorsHash.length !== 0) { + writer.uint32(74).bytes(message.nextValidatorsHash); + } + if (message.consensusHash.length !== 0) { + writer.uint32(82).bytes(message.consensusHash); + } + if (message.appHash.length !== 0) { + writer.uint32(90).bytes(message.appHash); + } + if (message.lastResultsHash.length !== 0) { + writer.uint32(98).bytes(message.lastResultsHash); + } + if (message.evidenceHash.length !== 0) { + writer.uint32(106).bytes(message.evidenceHash); + } + if (message.proposerAddress.length !== 0) { + writer.uint32(114).bytes(message.proposerAddress); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Header { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseHeader } as Header; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.version = Consensus.decode(reader, reader.uint32()); + break; + case 2: + message.chainId = reader.string(); + break; + case 3: + message.height = longToNumber(reader.int64() as Long); + break; + case 4: + message.time = fromTimestamp( + Timestamp.decode(reader, reader.uint32()) + ); + break; + case 5: + message.lastBlockId = BlockID.decode(reader, reader.uint32()); + break; + case 6: + message.lastCommitHash = reader.bytes(); + break; + case 7: + message.dataHash = reader.bytes(); + break; + case 8: + message.validatorsHash = reader.bytes(); + break; + case 9: + message.nextValidatorsHash = reader.bytes(); + break; + case 10: + message.consensusHash = reader.bytes(); + break; + case 11: + message.appHash = reader.bytes(); + break; + case 12: + message.lastResultsHash = reader.bytes(); + break; + case 13: + message.evidenceHash = reader.bytes(); + break; + case 14: + message.proposerAddress = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Header { + const message = { ...baseHeader } as Header; + if (object.version !== undefined && object.version !== null) { + message.version = Consensus.fromJSON(object.version); + } else { + message.version = undefined; + } + if (object.chainId !== undefined && object.chainId !== null) { + message.chainId = String(object.chainId); + } else { + message.chainId = ""; + } + if (object.height !== undefined && object.height !== null) { + message.height = Number(object.height); + } else { + message.height = 0; + } + if (object.time !== undefined && object.time !== null) { + message.time = fromJsonTimestamp(object.time); + } else { + message.time = undefined; + } + if (object.lastBlockId !== undefined && object.lastBlockId !== null) { + message.lastBlockId = BlockID.fromJSON(object.lastBlockId); + } else { + message.lastBlockId = undefined; + } + if (object.lastCommitHash !== undefined && object.lastCommitHash !== null) { + message.lastCommitHash = bytesFromBase64(object.lastCommitHash); + } + if (object.dataHash !== undefined && object.dataHash !== null) { + message.dataHash = bytesFromBase64(object.dataHash); + } + if (object.validatorsHash !== undefined && object.validatorsHash !== null) { + message.validatorsHash = bytesFromBase64(object.validatorsHash); + } + if ( + object.nextValidatorsHash !== undefined && + object.nextValidatorsHash !== null + ) { + message.nextValidatorsHash = bytesFromBase64(object.nextValidatorsHash); + } + if (object.consensusHash !== undefined && object.consensusHash !== null) { + message.consensusHash = bytesFromBase64(object.consensusHash); + } + if (object.appHash !== undefined && object.appHash !== null) { + message.appHash = bytesFromBase64(object.appHash); + } + if ( + object.lastResultsHash !== undefined && + object.lastResultsHash !== null + ) { + message.lastResultsHash = bytesFromBase64(object.lastResultsHash); + } + if (object.evidenceHash !== undefined && object.evidenceHash !== null) { + message.evidenceHash = bytesFromBase64(object.evidenceHash); + } + if ( + object.proposerAddress !== undefined && + object.proposerAddress !== null + ) { + message.proposerAddress = bytesFromBase64(object.proposerAddress); + } + return message; + }, + + toJSON(message: Header): unknown { + const obj: any = {}; + message.version !== undefined && + (obj.version = message.version + ? Consensus.toJSON(message.version) + : undefined); + message.chainId !== undefined && (obj.chainId = message.chainId); + message.height !== undefined && (obj.height = message.height); + message.time !== undefined && + (obj.time = + message.time !== undefined ? message.time.toISOString() : null); + message.lastBlockId !== undefined && + (obj.lastBlockId = message.lastBlockId + ? BlockID.toJSON(message.lastBlockId) + : undefined); + message.lastCommitHash !== undefined && + (obj.lastCommitHash = base64FromBytes( + message.lastCommitHash !== undefined + ? message.lastCommitHash + : new Uint8Array() + )); + message.dataHash !== undefined && + (obj.dataHash = base64FromBytes( + message.dataHash !== undefined ? message.dataHash : new Uint8Array() + )); + message.validatorsHash !== undefined && + (obj.validatorsHash = base64FromBytes( + message.validatorsHash !== undefined + ? message.validatorsHash + : new Uint8Array() + )); + message.nextValidatorsHash !== undefined && + (obj.nextValidatorsHash = base64FromBytes( + message.nextValidatorsHash !== undefined + ? message.nextValidatorsHash + : new Uint8Array() + )); + message.consensusHash !== undefined && + (obj.consensusHash = base64FromBytes( + message.consensusHash !== undefined + ? message.consensusHash + : new Uint8Array() + )); + message.appHash !== undefined && + (obj.appHash = base64FromBytes( + message.appHash !== undefined ? message.appHash : new Uint8Array() + )); + message.lastResultsHash !== undefined && + (obj.lastResultsHash = base64FromBytes( + message.lastResultsHash !== undefined + ? message.lastResultsHash + : new Uint8Array() + )); + message.evidenceHash !== undefined && + (obj.evidenceHash = base64FromBytes( + message.evidenceHash !== undefined + ? message.evidenceHash + : new Uint8Array() + )); + message.proposerAddress !== undefined && + (obj.proposerAddress = base64FromBytes( + message.proposerAddress !== undefined + ? message.proposerAddress + : new Uint8Array() + )); + return obj; + }, + + fromPartial(object: DeepPartial
): Header { + const message = { ...baseHeader } as Header; + if (object.version !== undefined && object.version !== null) { + message.version = Consensus.fromPartial(object.version); + } else { + message.version = undefined; + } + if (object.chainId !== undefined && object.chainId !== null) { + message.chainId = object.chainId; + } else { + message.chainId = ""; + } + if (object.height !== undefined && object.height !== null) { + message.height = object.height; + } else { + message.height = 0; + } + if (object.time !== undefined && object.time !== null) { + message.time = object.time; + } else { + message.time = undefined; + } + if (object.lastBlockId !== undefined && object.lastBlockId !== null) { + message.lastBlockId = BlockID.fromPartial(object.lastBlockId); + } else { + message.lastBlockId = undefined; + } + if (object.lastCommitHash !== undefined && object.lastCommitHash !== null) { + message.lastCommitHash = object.lastCommitHash; + } else { + message.lastCommitHash = new Uint8Array(); + } + if (object.dataHash !== undefined && object.dataHash !== null) { + message.dataHash = object.dataHash; + } else { + message.dataHash = new Uint8Array(); + } + if (object.validatorsHash !== undefined && object.validatorsHash !== null) { + message.validatorsHash = object.validatorsHash; + } else { + message.validatorsHash = new Uint8Array(); + } + if ( + object.nextValidatorsHash !== undefined && + object.nextValidatorsHash !== null + ) { + message.nextValidatorsHash = object.nextValidatorsHash; + } else { + message.nextValidatorsHash = new Uint8Array(); + } + if (object.consensusHash !== undefined && object.consensusHash !== null) { + message.consensusHash = object.consensusHash; + } else { + message.consensusHash = new Uint8Array(); + } + if (object.appHash !== undefined && object.appHash !== null) { + message.appHash = object.appHash; + } else { + message.appHash = new Uint8Array(); + } + if ( + object.lastResultsHash !== undefined && + object.lastResultsHash !== null + ) { + message.lastResultsHash = object.lastResultsHash; + } else { + message.lastResultsHash = new Uint8Array(); + } + if (object.evidenceHash !== undefined && object.evidenceHash !== null) { + message.evidenceHash = object.evidenceHash; + } else { + message.evidenceHash = new Uint8Array(); + } + if ( + object.proposerAddress !== undefined && + object.proposerAddress !== null + ) { + message.proposerAddress = object.proposerAddress; + } else { + message.proposerAddress = new Uint8Array(); + } + return message; + }, +}; + +const baseData: object = {}; + +export const Data = { + encode(message: Data, writer: Writer = Writer.create()): Writer { + for (const v of message.txs) { + writer.uint32(10).bytes(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Data { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseData } as Data; + message.txs = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.txs.push(reader.bytes()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Data { + const message = { ...baseData } as Data; + message.txs = []; + if (object.txs !== undefined && object.txs !== null) { + for (const e of object.txs) { + message.txs.push(bytesFromBase64(e)); + } + } + return message; + }, + + toJSON(message: Data): unknown { + const obj: any = {}; + if (message.txs) { + obj.txs = message.txs.map((e) => + base64FromBytes(e !== undefined ? e : new Uint8Array()) + ); + } else { + obj.txs = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): Data { + const message = { ...baseData } as Data; + message.txs = []; + if (object.txs !== undefined && object.txs !== null) { + for (const e of object.txs) { + message.txs.push(e); + } + } + return message; + }, +}; + +const baseVote: object = { type: 0, height: 0, round: 0, validatorIndex: 0 }; + +export const Vote = { + encode(message: Vote, writer: Writer = Writer.create()): Writer { + if (message.type !== 0) { + writer.uint32(8).int32(message.type); + } + if (message.height !== 0) { + writer.uint32(16).int64(message.height); + } + if (message.round !== 0) { + writer.uint32(24).int32(message.round); + } + if (message.blockId !== undefined) { + BlockID.encode(message.blockId, writer.uint32(34).fork()).ldelim(); + } + if (message.timestamp !== undefined) { + Timestamp.encode( + toTimestamp(message.timestamp), + writer.uint32(42).fork() + ).ldelim(); + } + if (message.validatorAddress.length !== 0) { + writer.uint32(50).bytes(message.validatorAddress); + } + if (message.validatorIndex !== 0) { + writer.uint32(56).int32(message.validatorIndex); + } + if (message.signature.length !== 0) { + writer.uint32(66).bytes(message.signature); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Vote { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseVote } as Vote; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.type = reader.int32() as any; + break; + case 2: + message.height = longToNumber(reader.int64() as Long); + break; + case 3: + message.round = reader.int32(); + break; + case 4: + message.blockId = BlockID.decode(reader, reader.uint32()); + break; + case 5: + message.timestamp = fromTimestamp( + Timestamp.decode(reader, reader.uint32()) + ); + break; + case 6: + message.validatorAddress = reader.bytes(); + break; + case 7: + message.validatorIndex = reader.int32(); + break; + case 8: + message.signature = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Vote { + const message = { ...baseVote } as Vote; + if (object.type !== undefined && object.type !== null) { + message.type = signedMsgTypeFromJSON(object.type); + } else { + message.type = 0; + } + if (object.height !== undefined && object.height !== null) { + message.height = Number(object.height); + } else { + message.height = 0; + } + if (object.round !== undefined && object.round !== null) { + message.round = Number(object.round); + } else { + message.round = 0; + } + if (object.blockId !== undefined && object.blockId !== null) { + message.blockId = BlockID.fromJSON(object.blockId); + } else { + message.blockId = undefined; + } + if (object.timestamp !== undefined && object.timestamp !== null) { + message.timestamp = fromJsonTimestamp(object.timestamp); + } else { + message.timestamp = undefined; + } + if ( + object.validatorAddress !== undefined && + object.validatorAddress !== null + ) { + message.validatorAddress = bytesFromBase64(object.validatorAddress); + } + if (object.validatorIndex !== undefined && object.validatorIndex !== null) { + message.validatorIndex = Number(object.validatorIndex); + } else { + message.validatorIndex = 0; + } + if (object.signature !== undefined && object.signature !== null) { + message.signature = bytesFromBase64(object.signature); + } + return message; + }, + + toJSON(message: Vote): unknown { + const obj: any = {}; + message.type !== undefined && + (obj.type = signedMsgTypeToJSON(message.type)); + message.height !== undefined && (obj.height = message.height); + message.round !== undefined && (obj.round = message.round); + message.blockId !== undefined && + (obj.blockId = message.blockId + ? BlockID.toJSON(message.blockId) + : undefined); + message.timestamp !== undefined && + (obj.timestamp = + message.timestamp !== undefined + ? message.timestamp.toISOString() + : null); + message.validatorAddress !== undefined && + (obj.validatorAddress = base64FromBytes( + message.validatorAddress !== undefined + ? message.validatorAddress + : new Uint8Array() + )); + message.validatorIndex !== undefined && + (obj.validatorIndex = message.validatorIndex); + message.signature !== undefined && + (obj.signature = base64FromBytes( + message.signature !== undefined ? message.signature : new Uint8Array() + )); + return obj; + }, + + fromPartial(object: DeepPartial): Vote { + const message = { ...baseVote } as Vote; + if (object.type !== undefined && object.type !== null) { + message.type = object.type; + } else { + message.type = 0; + } + if (object.height !== undefined && object.height !== null) { + message.height = object.height; + } else { + message.height = 0; + } + if (object.round !== undefined && object.round !== null) { + message.round = object.round; + } else { + message.round = 0; + } + if (object.blockId !== undefined && object.blockId !== null) { + message.blockId = BlockID.fromPartial(object.blockId); + } else { + message.blockId = undefined; + } + if (object.timestamp !== undefined && object.timestamp !== null) { + message.timestamp = object.timestamp; + } else { + message.timestamp = undefined; + } + if ( + object.validatorAddress !== undefined && + object.validatorAddress !== null + ) { + message.validatorAddress = object.validatorAddress; + } else { + message.validatorAddress = new Uint8Array(); + } + if (object.validatorIndex !== undefined && object.validatorIndex !== null) { + message.validatorIndex = object.validatorIndex; + } else { + message.validatorIndex = 0; + } + if (object.signature !== undefined && object.signature !== null) { + message.signature = object.signature; + } else { + message.signature = new Uint8Array(); + } + return message; + }, +}; + +const baseCommit: object = { height: 0, round: 0 }; + +export const Commit = { + encode(message: Commit, writer: Writer = Writer.create()): Writer { + if (message.height !== 0) { + writer.uint32(8).int64(message.height); + } + if (message.round !== 0) { + writer.uint32(16).int32(message.round); + } + if (message.blockId !== undefined) { + BlockID.encode(message.blockId, writer.uint32(26).fork()).ldelim(); + } + for (const v of message.signatures) { + CommitSig.encode(v!, writer.uint32(34).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Commit { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseCommit } as Commit; + message.signatures = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.height = longToNumber(reader.int64() as Long); + break; + case 2: + message.round = reader.int32(); + break; + case 3: + message.blockId = BlockID.decode(reader, reader.uint32()); + break; + case 4: + message.signatures.push(CommitSig.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Commit { + const message = { ...baseCommit } as Commit; + message.signatures = []; + if (object.height !== undefined && object.height !== null) { + message.height = Number(object.height); + } else { + message.height = 0; + } + if (object.round !== undefined && object.round !== null) { + message.round = Number(object.round); + } else { + message.round = 0; + } + if (object.blockId !== undefined && object.blockId !== null) { + message.blockId = BlockID.fromJSON(object.blockId); + } else { + message.blockId = undefined; + } + if (object.signatures !== undefined && object.signatures !== null) { + for (const e of object.signatures) { + message.signatures.push(CommitSig.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: Commit): unknown { + const obj: any = {}; + message.height !== undefined && (obj.height = message.height); + message.round !== undefined && (obj.round = message.round); + message.blockId !== undefined && + (obj.blockId = message.blockId + ? BlockID.toJSON(message.blockId) + : undefined); + if (message.signatures) { + obj.signatures = message.signatures.map((e) => + e ? CommitSig.toJSON(e) : undefined + ); + } else { + obj.signatures = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): Commit { + const message = { ...baseCommit } as Commit; + message.signatures = []; + if (object.height !== undefined && object.height !== null) { + message.height = object.height; + } else { + message.height = 0; + } + if (object.round !== undefined && object.round !== null) { + message.round = object.round; + } else { + message.round = 0; + } + if (object.blockId !== undefined && object.blockId !== null) { + message.blockId = BlockID.fromPartial(object.blockId); + } else { + message.blockId = undefined; + } + if (object.signatures !== undefined && object.signatures !== null) { + for (const e of object.signatures) { + message.signatures.push(CommitSig.fromPartial(e)); + } + } + return message; + }, +}; + +const baseCommitSig: object = { blockIdFlag: 0 }; + +export const CommitSig = { + encode(message: CommitSig, writer: Writer = Writer.create()): Writer { + if (message.blockIdFlag !== 0) { + writer.uint32(8).int32(message.blockIdFlag); + } + if (message.validatorAddress.length !== 0) { + writer.uint32(18).bytes(message.validatorAddress); + } + if (message.timestamp !== undefined) { + Timestamp.encode( + toTimestamp(message.timestamp), + writer.uint32(26).fork() + ).ldelim(); + } + if (message.signature.length !== 0) { + writer.uint32(34).bytes(message.signature); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): CommitSig { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseCommitSig } as CommitSig; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.blockIdFlag = reader.int32() as any; + break; + case 2: + message.validatorAddress = reader.bytes(); + break; + case 3: + message.timestamp = fromTimestamp( + Timestamp.decode(reader, reader.uint32()) + ); + break; + case 4: + message.signature = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): CommitSig { + const message = { ...baseCommitSig } as CommitSig; + if (object.blockIdFlag !== undefined && object.blockIdFlag !== null) { + message.blockIdFlag = blockIDFlagFromJSON(object.blockIdFlag); + } else { + message.blockIdFlag = 0; + } + if ( + object.validatorAddress !== undefined && + object.validatorAddress !== null + ) { + message.validatorAddress = bytesFromBase64(object.validatorAddress); + } + if (object.timestamp !== undefined && object.timestamp !== null) { + message.timestamp = fromJsonTimestamp(object.timestamp); + } else { + message.timestamp = undefined; + } + if (object.signature !== undefined && object.signature !== null) { + message.signature = bytesFromBase64(object.signature); + } + return message; + }, + + toJSON(message: CommitSig): unknown { + const obj: any = {}; + message.blockIdFlag !== undefined && + (obj.blockIdFlag = blockIDFlagToJSON(message.blockIdFlag)); + message.validatorAddress !== undefined && + (obj.validatorAddress = base64FromBytes( + message.validatorAddress !== undefined + ? message.validatorAddress + : new Uint8Array() + )); + message.timestamp !== undefined && + (obj.timestamp = + message.timestamp !== undefined + ? message.timestamp.toISOString() + : null); + message.signature !== undefined && + (obj.signature = base64FromBytes( + message.signature !== undefined ? message.signature : new Uint8Array() + )); + return obj; + }, + + fromPartial(object: DeepPartial): CommitSig { + const message = { ...baseCommitSig } as CommitSig; + if (object.blockIdFlag !== undefined && object.blockIdFlag !== null) { + message.blockIdFlag = object.blockIdFlag; + } else { + message.blockIdFlag = 0; + } + if ( + object.validatorAddress !== undefined && + object.validatorAddress !== null + ) { + message.validatorAddress = object.validatorAddress; + } else { + message.validatorAddress = new Uint8Array(); + } + if (object.timestamp !== undefined && object.timestamp !== null) { + message.timestamp = object.timestamp; + } else { + message.timestamp = undefined; + } + if (object.signature !== undefined && object.signature !== null) { + message.signature = object.signature; + } else { + message.signature = new Uint8Array(); + } + return message; + }, +}; + +const baseProposal: object = { type: 0, height: 0, round: 0, polRound: 0 }; + +export const Proposal = { + encode(message: Proposal, writer: Writer = Writer.create()): Writer { + if (message.type !== 0) { + writer.uint32(8).int32(message.type); + } + if (message.height !== 0) { + writer.uint32(16).int64(message.height); + } + if (message.round !== 0) { + writer.uint32(24).int32(message.round); + } + if (message.polRound !== 0) { + writer.uint32(32).int32(message.polRound); + } + if (message.blockId !== undefined) { + BlockID.encode(message.blockId, writer.uint32(42).fork()).ldelim(); + } + if (message.timestamp !== undefined) { + Timestamp.encode( + toTimestamp(message.timestamp), + writer.uint32(50).fork() + ).ldelim(); + } + if (message.signature.length !== 0) { + writer.uint32(58).bytes(message.signature); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Proposal { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseProposal } as Proposal; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.type = reader.int32() as any; + break; + case 2: + message.height = longToNumber(reader.int64() as Long); + break; + case 3: + message.round = reader.int32(); + break; + case 4: + message.polRound = reader.int32(); + break; + case 5: + message.blockId = BlockID.decode(reader, reader.uint32()); + break; + case 6: + message.timestamp = fromTimestamp( + Timestamp.decode(reader, reader.uint32()) + ); + break; + case 7: + message.signature = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Proposal { + const message = { ...baseProposal } as Proposal; + if (object.type !== undefined && object.type !== null) { + message.type = signedMsgTypeFromJSON(object.type); + } else { + message.type = 0; + } + if (object.height !== undefined && object.height !== null) { + message.height = Number(object.height); + } else { + message.height = 0; + } + if (object.round !== undefined && object.round !== null) { + message.round = Number(object.round); + } else { + message.round = 0; + } + if (object.polRound !== undefined && object.polRound !== null) { + message.polRound = Number(object.polRound); + } else { + message.polRound = 0; + } + if (object.blockId !== undefined && object.blockId !== null) { + message.blockId = BlockID.fromJSON(object.blockId); + } else { + message.blockId = undefined; + } + if (object.timestamp !== undefined && object.timestamp !== null) { + message.timestamp = fromJsonTimestamp(object.timestamp); + } else { + message.timestamp = undefined; + } + if (object.signature !== undefined && object.signature !== null) { + message.signature = bytesFromBase64(object.signature); + } + return message; + }, + + toJSON(message: Proposal): unknown { + const obj: any = {}; + message.type !== undefined && + (obj.type = signedMsgTypeToJSON(message.type)); + message.height !== undefined && (obj.height = message.height); + message.round !== undefined && (obj.round = message.round); + message.polRound !== undefined && (obj.polRound = message.polRound); + message.blockId !== undefined && + (obj.blockId = message.blockId + ? BlockID.toJSON(message.blockId) + : undefined); + message.timestamp !== undefined && + (obj.timestamp = + message.timestamp !== undefined + ? message.timestamp.toISOString() + : null); + message.signature !== undefined && + (obj.signature = base64FromBytes( + message.signature !== undefined ? message.signature : new Uint8Array() + )); + return obj; + }, + + fromPartial(object: DeepPartial): Proposal { + const message = { ...baseProposal } as Proposal; + if (object.type !== undefined && object.type !== null) { + message.type = object.type; + } else { + message.type = 0; + } + if (object.height !== undefined && object.height !== null) { + message.height = object.height; + } else { + message.height = 0; + } + if (object.round !== undefined && object.round !== null) { + message.round = object.round; + } else { + message.round = 0; + } + if (object.polRound !== undefined && object.polRound !== null) { + message.polRound = object.polRound; + } else { + message.polRound = 0; + } + if (object.blockId !== undefined && object.blockId !== null) { + message.blockId = BlockID.fromPartial(object.blockId); + } else { + message.blockId = undefined; + } + if (object.timestamp !== undefined && object.timestamp !== null) { + message.timestamp = object.timestamp; + } else { + message.timestamp = undefined; + } + if (object.signature !== undefined && object.signature !== null) { + message.signature = object.signature; + } else { + message.signature = new Uint8Array(); + } + return message; + }, +}; + +const baseSignedHeader: object = {}; + +export const SignedHeader = { + encode(message: SignedHeader, writer: Writer = Writer.create()): Writer { + if (message.header !== undefined) { + Header.encode(message.header, writer.uint32(10).fork()).ldelim(); + } + if (message.commit !== undefined) { + Commit.encode(message.commit, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): SignedHeader { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseSignedHeader } as SignedHeader; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.header = Header.decode(reader, reader.uint32()); + break; + case 2: + message.commit = Commit.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): SignedHeader { + const message = { ...baseSignedHeader } as SignedHeader; + if (object.header !== undefined && object.header !== null) { + message.header = Header.fromJSON(object.header); + } else { + message.header = undefined; + } + if (object.commit !== undefined && object.commit !== null) { + message.commit = Commit.fromJSON(object.commit); + } else { + message.commit = undefined; + } + return message; + }, + + toJSON(message: SignedHeader): unknown { + const obj: any = {}; + message.header !== undefined && + (obj.header = message.header ? Header.toJSON(message.header) : undefined); + message.commit !== undefined && + (obj.commit = message.commit ? Commit.toJSON(message.commit) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): SignedHeader { + const message = { ...baseSignedHeader } as SignedHeader; + if (object.header !== undefined && object.header !== null) { + message.header = Header.fromPartial(object.header); + } else { + message.header = undefined; + } + if (object.commit !== undefined && object.commit !== null) { + message.commit = Commit.fromPartial(object.commit); + } else { + message.commit = undefined; + } + return message; + }, +}; + +const baseLightBlock: object = {}; + +export const LightBlock = { + encode(message: LightBlock, writer: Writer = Writer.create()): Writer { + if (message.signedHeader !== undefined) { + SignedHeader.encode( + message.signedHeader, + writer.uint32(10).fork() + ).ldelim(); + } + if (message.validatorSet !== undefined) { + ValidatorSet.encode( + message.validatorSet, + writer.uint32(18).fork() + ).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): LightBlock { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseLightBlock } as LightBlock; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.signedHeader = SignedHeader.decode(reader, reader.uint32()); + break; + case 2: + message.validatorSet = ValidatorSet.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): LightBlock { + const message = { ...baseLightBlock } as LightBlock; + if (object.signedHeader !== undefined && object.signedHeader !== null) { + message.signedHeader = SignedHeader.fromJSON(object.signedHeader); + } else { + message.signedHeader = undefined; + } + if (object.validatorSet !== undefined && object.validatorSet !== null) { + message.validatorSet = ValidatorSet.fromJSON(object.validatorSet); + } else { + message.validatorSet = undefined; + } + return message; + }, + + toJSON(message: LightBlock): unknown { + const obj: any = {}; + message.signedHeader !== undefined && + (obj.signedHeader = message.signedHeader + ? SignedHeader.toJSON(message.signedHeader) + : undefined); + message.validatorSet !== undefined && + (obj.validatorSet = message.validatorSet + ? ValidatorSet.toJSON(message.validatorSet) + : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): LightBlock { + const message = { ...baseLightBlock } as LightBlock; + if (object.signedHeader !== undefined && object.signedHeader !== null) { + message.signedHeader = SignedHeader.fromPartial(object.signedHeader); + } else { + message.signedHeader = undefined; + } + if (object.validatorSet !== undefined && object.validatorSet !== null) { + message.validatorSet = ValidatorSet.fromPartial(object.validatorSet); + } else { + message.validatorSet = undefined; + } + return message; + }, +}; + +const baseBlockMeta: object = { blockSize: 0, numTxs: 0 }; + +export const BlockMeta = { + encode(message: BlockMeta, writer: Writer = Writer.create()): Writer { + if (message.blockId !== undefined) { + BlockID.encode(message.blockId, writer.uint32(10).fork()).ldelim(); + } + if (message.blockSize !== 0) { + writer.uint32(16).int64(message.blockSize); + } + if (message.header !== undefined) { + Header.encode(message.header, writer.uint32(26).fork()).ldelim(); + } + if (message.numTxs !== 0) { + writer.uint32(32).int64(message.numTxs); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): BlockMeta { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseBlockMeta } as BlockMeta; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.blockId = BlockID.decode(reader, reader.uint32()); + break; + case 2: + message.blockSize = longToNumber(reader.int64() as Long); + break; + case 3: + message.header = Header.decode(reader, reader.uint32()); + break; + case 4: + message.numTxs = longToNumber(reader.int64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): BlockMeta { + const message = { ...baseBlockMeta } as BlockMeta; + if (object.blockId !== undefined && object.blockId !== null) { + message.blockId = BlockID.fromJSON(object.blockId); + } else { + message.blockId = undefined; + } + if (object.blockSize !== undefined && object.blockSize !== null) { + message.blockSize = Number(object.blockSize); + } else { + message.blockSize = 0; + } + if (object.header !== undefined && object.header !== null) { + message.header = Header.fromJSON(object.header); + } else { + message.header = undefined; + } + if (object.numTxs !== undefined && object.numTxs !== null) { + message.numTxs = Number(object.numTxs); + } else { + message.numTxs = 0; + } + return message; + }, + + toJSON(message: BlockMeta): unknown { + const obj: any = {}; + message.blockId !== undefined && + (obj.blockId = message.blockId + ? BlockID.toJSON(message.blockId) + : undefined); + message.blockSize !== undefined && (obj.blockSize = message.blockSize); + message.header !== undefined && + (obj.header = message.header ? Header.toJSON(message.header) : undefined); + message.numTxs !== undefined && (obj.numTxs = message.numTxs); + return obj; + }, + + fromPartial(object: DeepPartial): BlockMeta { + const message = { ...baseBlockMeta } as BlockMeta; + if (object.blockId !== undefined && object.blockId !== null) { + message.blockId = BlockID.fromPartial(object.blockId); + } else { + message.blockId = undefined; + } + if (object.blockSize !== undefined && object.blockSize !== null) { + message.blockSize = object.blockSize; + } else { + message.blockSize = 0; + } + if (object.header !== undefined && object.header !== null) { + message.header = Header.fromPartial(object.header); + } else { + message.header = undefined; + } + if (object.numTxs !== undefined && object.numTxs !== null) { + message.numTxs = object.numTxs; + } else { + message.numTxs = 0; + } + return message; + }, +}; + +const baseTxProof: object = {}; + +export const TxProof = { + encode(message: TxProof, writer: Writer = Writer.create()): Writer { + if (message.rootHash.length !== 0) { + writer.uint32(10).bytes(message.rootHash); + } + if (message.data.length !== 0) { + writer.uint32(18).bytes(message.data); + } + if (message.proof !== undefined) { + Proof.encode(message.proof, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): TxProof { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseTxProof } as TxProof; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.rootHash = reader.bytes(); + break; + case 2: + message.data = reader.bytes(); + break; + case 3: + message.proof = Proof.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): TxProof { + const message = { ...baseTxProof } as TxProof; + if (object.rootHash !== undefined && object.rootHash !== null) { + message.rootHash = bytesFromBase64(object.rootHash); + } + if (object.data !== undefined && object.data !== null) { + message.data = bytesFromBase64(object.data); + } + if (object.proof !== undefined && object.proof !== null) { + message.proof = Proof.fromJSON(object.proof); + } else { + message.proof = undefined; + } + return message; + }, + + toJSON(message: TxProof): unknown { + const obj: any = {}; + message.rootHash !== undefined && + (obj.rootHash = base64FromBytes( + message.rootHash !== undefined ? message.rootHash : new Uint8Array() + )); + message.data !== undefined && + (obj.data = base64FromBytes( + message.data !== undefined ? message.data : new Uint8Array() + )); + message.proof !== undefined && + (obj.proof = message.proof ? Proof.toJSON(message.proof) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): TxProof { + const message = { ...baseTxProof } as TxProof; + if (object.rootHash !== undefined && object.rootHash !== null) { + message.rootHash = object.rootHash; + } else { + message.rootHash = new Uint8Array(); + } + if (object.data !== undefined && object.data !== null) { + message.data = object.data; + } else { + message.data = new Uint8Array(); + } + if (object.proof !== undefined && object.proof !== null) { + message.proof = Proof.fromPartial(object.proof); + } else { + message.proof = undefined; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function toTimestamp(date: Date): Timestamp { + const seconds = date.getTime() / 1_000; + const nanos = (date.getTime() % 1_000) * 1_000_000; + return { seconds, nanos }; +} + +function fromTimestamp(t: Timestamp): Date { + let millis = t.seconds * 1_000; + millis += t.nanos / 1_000_000; + return new Date(millis); +} + +function fromJsonTimestamp(o: any): Date { + if (o instanceof Date) { + return o; + } else if (typeof o === "string") { + return new Date(o); + } else { + return fromTimestamp(Timestamp.fromJSON(o)); + } +} + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/cosmos.base.tendermint.v1beta1/types/tendermint/types/validator.ts b/ts-client/cosmos.base.tendermint.v1beta1/types/tendermint/types/validator.ts new file mode 100644 index 00000000..c5044032 --- /dev/null +++ b/ts-client/cosmos.base.tendermint.v1beta1/types/tendermint/types/validator.ts @@ -0,0 +1,382 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; +import { PublicKey } from "../../tendermint/crypto/keys"; + +export const protobufPackage = "tendermint.types"; + +export interface ValidatorSet { + validators: Validator[]; + proposer: Validator | undefined; + totalVotingPower: number; +} + +export interface Validator { + address: Uint8Array; + pubKey: PublicKey | undefined; + votingPower: number; + proposerPriority: number; +} + +export interface SimpleValidator { + pubKey: PublicKey | undefined; + votingPower: number; +} + +const baseValidatorSet: object = { totalVotingPower: 0 }; + +export const ValidatorSet = { + encode(message: ValidatorSet, writer: Writer = Writer.create()): Writer { + for (const v of message.validators) { + Validator.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.proposer !== undefined) { + Validator.encode(message.proposer, writer.uint32(18).fork()).ldelim(); + } + if (message.totalVotingPower !== 0) { + writer.uint32(24).int64(message.totalVotingPower); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ValidatorSet { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseValidatorSet } as ValidatorSet; + message.validators = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.validators.push(Validator.decode(reader, reader.uint32())); + break; + case 2: + message.proposer = Validator.decode(reader, reader.uint32()); + break; + case 3: + message.totalVotingPower = longToNumber(reader.int64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ValidatorSet { + const message = { ...baseValidatorSet } as ValidatorSet; + message.validators = []; + if (object.validators !== undefined && object.validators !== null) { + for (const e of object.validators) { + message.validators.push(Validator.fromJSON(e)); + } + } + if (object.proposer !== undefined && object.proposer !== null) { + message.proposer = Validator.fromJSON(object.proposer); + } else { + message.proposer = undefined; + } + if ( + object.totalVotingPower !== undefined && + object.totalVotingPower !== null + ) { + message.totalVotingPower = Number(object.totalVotingPower); + } else { + message.totalVotingPower = 0; + } + return message; + }, + + toJSON(message: ValidatorSet): unknown { + const obj: any = {}; + if (message.validators) { + obj.validators = message.validators.map((e) => + e ? Validator.toJSON(e) : undefined + ); + } else { + obj.validators = []; + } + message.proposer !== undefined && + (obj.proposer = message.proposer + ? Validator.toJSON(message.proposer) + : undefined); + message.totalVotingPower !== undefined && + (obj.totalVotingPower = message.totalVotingPower); + return obj; + }, + + fromPartial(object: DeepPartial): ValidatorSet { + const message = { ...baseValidatorSet } as ValidatorSet; + message.validators = []; + if (object.validators !== undefined && object.validators !== null) { + for (const e of object.validators) { + message.validators.push(Validator.fromPartial(e)); + } + } + if (object.proposer !== undefined && object.proposer !== null) { + message.proposer = Validator.fromPartial(object.proposer); + } else { + message.proposer = undefined; + } + if ( + object.totalVotingPower !== undefined && + object.totalVotingPower !== null + ) { + message.totalVotingPower = object.totalVotingPower; + } else { + message.totalVotingPower = 0; + } + return message; + }, +}; + +const baseValidator: object = { votingPower: 0, proposerPriority: 0 }; + +export const Validator = { + encode(message: Validator, writer: Writer = Writer.create()): Writer { + if (message.address.length !== 0) { + writer.uint32(10).bytes(message.address); + } + if (message.pubKey !== undefined) { + PublicKey.encode(message.pubKey, writer.uint32(18).fork()).ldelim(); + } + if (message.votingPower !== 0) { + writer.uint32(24).int64(message.votingPower); + } + if (message.proposerPriority !== 0) { + writer.uint32(32).int64(message.proposerPriority); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Validator { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseValidator } as Validator; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.address = reader.bytes(); + break; + case 2: + message.pubKey = PublicKey.decode(reader, reader.uint32()); + break; + case 3: + message.votingPower = longToNumber(reader.int64() as Long); + break; + case 4: + message.proposerPriority = longToNumber(reader.int64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Validator { + const message = { ...baseValidator } as Validator; + if (object.address !== undefined && object.address !== null) { + message.address = bytesFromBase64(object.address); + } + if (object.pubKey !== undefined && object.pubKey !== null) { + message.pubKey = PublicKey.fromJSON(object.pubKey); + } else { + message.pubKey = undefined; + } + if (object.votingPower !== undefined && object.votingPower !== null) { + message.votingPower = Number(object.votingPower); + } else { + message.votingPower = 0; + } + if ( + object.proposerPriority !== undefined && + object.proposerPriority !== null + ) { + message.proposerPriority = Number(object.proposerPriority); + } else { + message.proposerPriority = 0; + } + return message; + }, + + toJSON(message: Validator): unknown { + const obj: any = {}; + message.address !== undefined && + (obj.address = base64FromBytes( + message.address !== undefined ? message.address : new Uint8Array() + )); + message.pubKey !== undefined && + (obj.pubKey = message.pubKey + ? PublicKey.toJSON(message.pubKey) + : undefined); + message.votingPower !== undefined && + (obj.votingPower = message.votingPower); + message.proposerPriority !== undefined && + (obj.proposerPriority = message.proposerPriority); + return obj; + }, + + fromPartial(object: DeepPartial): Validator { + const message = { ...baseValidator } as Validator; + if (object.address !== undefined && object.address !== null) { + message.address = object.address; + } else { + message.address = new Uint8Array(); + } + if (object.pubKey !== undefined && object.pubKey !== null) { + message.pubKey = PublicKey.fromPartial(object.pubKey); + } else { + message.pubKey = undefined; + } + if (object.votingPower !== undefined && object.votingPower !== null) { + message.votingPower = object.votingPower; + } else { + message.votingPower = 0; + } + if ( + object.proposerPriority !== undefined && + object.proposerPriority !== null + ) { + message.proposerPriority = object.proposerPriority; + } else { + message.proposerPriority = 0; + } + return message; + }, +}; + +const baseSimpleValidator: object = { votingPower: 0 }; + +export const SimpleValidator = { + encode(message: SimpleValidator, writer: Writer = Writer.create()): Writer { + if (message.pubKey !== undefined) { + PublicKey.encode(message.pubKey, writer.uint32(10).fork()).ldelim(); + } + if (message.votingPower !== 0) { + writer.uint32(16).int64(message.votingPower); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): SimpleValidator { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseSimpleValidator } as SimpleValidator; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.pubKey = PublicKey.decode(reader, reader.uint32()); + break; + case 2: + message.votingPower = longToNumber(reader.int64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): SimpleValidator { + const message = { ...baseSimpleValidator } as SimpleValidator; + if (object.pubKey !== undefined && object.pubKey !== null) { + message.pubKey = PublicKey.fromJSON(object.pubKey); + } else { + message.pubKey = undefined; + } + if (object.votingPower !== undefined && object.votingPower !== null) { + message.votingPower = Number(object.votingPower); + } else { + message.votingPower = 0; + } + return message; + }, + + toJSON(message: SimpleValidator): unknown { + const obj: any = {}; + message.pubKey !== undefined && + (obj.pubKey = message.pubKey + ? PublicKey.toJSON(message.pubKey) + : undefined); + message.votingPower !== undefined && + (obj.votingPower = message.votingPower); + return obj; + }, + + fromPartial(object: DeepPartial): SimpleValidator { + const message = { ...baseSimpleValidator } as SimpleValidator; + if (object.pubKey !== undefined && object.pubKey !== null) { + message.pubKey = PublicKey.fromPartial(object.pubKey); + } else { + message.pubKey = undefined; + } + if (object.votingPower !== undefined && object.votingPower !== null) { + message.votingPower = object.votingPower; + } else { + message.votingPower = 0; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/cosmos.base.tendermint.v1beta1/types/tendermint/version/types.ts b/ts-client/cosmos.base.tendermint.v1beta1/types/tendermint/version/types.ts new file mode 100644 index 00000000..4bc6ad82 --- /dev/null +++ b/ts-client/cosmos.base.tendermint.v1beta1/types/tendermint/version/types.ts @@ -0,0 +1,202 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "tendermint.version"; + +/** + * App includes the protocol and software version for the application. + * This information is included in ResponseInfo. The App.Protocol can be + * updated in ResponseEndBlock. + */ +export interface App { + protocol: number; + software: string; +} + +/** + * Consensus captures the consensus rules for processing a block in the blockchain, + * including all blockchain data structures and the rules of the application's + * state transition machine. + */ +export interface Consensus { + block: number; + app: number; +} + +const baseApp: object = { protocol: 0, software: "" }; + +export const App = { + encode(message: App, writer: Writer = Writer.create()): Writer { + if (message.protocol !== 0) { + writer.uint32(8).uint64(message.protocol); + } + if (message.software !== "") { + writer.uint32(18).string(message.software); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): App { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseApp } as App; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.protocol = longToNumber(reader.uint64() as Long); + break; + case 2: + message.software = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): App { + const message = { ...baseApp } as App; + if (object.protocol !== undefined && object.protocol !== null) { + message.protocol = Number(object.protocol); + } else { + message.protocol = 0; + } + if (object.software !== undefined && object.software !== null) { + message.software = String(object.software); + } else { + message.software = ""; + } + return message; + }, + + toJSON(message: App): unknown { + const obj: any = {}; + message.protocol !== undefined && (obj.protocol = message.protocol); + message.software !== undefined && (obj.software = message.software); + return obj; + }, + + fromPartial(object: DeepPartial): App { + const message = { ...baseApp } as App; + if (object.protocol !== undefined && object.protocol !== null) { + message.protocol = object.protocol; + } else { + message.protocol = 0; + } + if (object.software !== undefined && object.software !== null) { + message.software = object.software; + } else { + message.software = ""; + } + return message; + }, +}; + +const baseConsensus: object = { block: 0, app: 0 }; + +export const Consensus = { + encode(message: Consensus, writer: Writer = Writer.create()): Writer { + if (message.block !== 0) { + writer.uint32(8).uint64(message.block); + } + if (message.app !== 0) { + writer.uint32(16).uint64(message.app); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Consensus { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseConsensus } as Consensus; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.block = longToNumber(reader.uint64() as Long); + break; + case 2: + message.app = longToNumber(reader.uint64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Consensus { + const message = { ...baseConsensus } as Consensus; + if (object.block !== undefined && object.block !== null) { + message.block = Number(object.block); + } else { + message.block = 0; + } + if (object.app !== undefined && object.app !== null) { + message.app = Number(object.app); + } else { + message.app = 0; + } + return message; + }, + + toJSON(message: Consensus): unknown { + const obj: any = {}; + message.block !== undefined && (obj.block = message.block); + message.app !== undefined && (obj.app = message.app); + return obj; + }, + + fromPartial(object: DeepPartial): Consensus { + const message = { ...baseConsensus } as Consensus; + if (object.block !== undefined && object.block !== null) { + message.block = object.block; + } else { + message.block = 0; + } + if (object.app !== undefined && object.app !== null) { + message.app = object.app; + } else { + message.app = 0; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/cosmos.crisis.v1beta1/index.ts b/ts-client/cosmos.crisis.v1beta1/index.ts new file mode 100755 index 00000000..c9dfa159 --- /dev/null +++ b/ts-client/cosmos.crisis.v1beta1/index.ts @@ -0,0 +1,6 @@ +import Module from './module'; +import { txClient, queryClient, registry } from './module'; +import { msgTypes } from './registry'; + +export * from "./types"; +export { Module, msgTypes, txClient, queryClient, registry }; diff --git a/ts-client/cosmos.crisis.v1beta1/module.ts b/ts-client/cosmos.crisis.v1beta1/module.ts new file mode 100755 index 00000000..aadb75b7 --- /dev/null +++ b/ts-client/cosmos.crisis.v1beta1/module.ts @@ -0,0 +1,99 @@ +// Generated by Ignite ignite.com/cli + +import { StdFee } from "@cosmjs/launchpad"; +import { SigningStargateClient, DeliverTxResponse } from "@cosmjs/stargate"; +import { EncodeObject, GeneratedType, OfflineSigner, Registry } from "@cosmjs/proto-signing"; +import { msgTypes } from './registry'; +import { IgniteClient } from "../client" +import { MissingWalletError } from "../helpers" +import { Api } from "./rest"; +import { MsgVerifyInvariant } from "./types/cosmos/crisis/v1beta1/tx"; + + +export { MsgVerifyInvariant }; + +type sendMsgVerifyInvariantParams = { + value: MsgVerifyInvariant, + fee?: StdFee, + memo?: string +}; + + +type msgVerifyInvariantParams = { + value: MsgVerifyInvariant, +}; + + +export const registry = new Registry(msgTypes); + +const defaultFee = { + amount: [], + gas: "200000", +}; + +interface TxClientOptions { + addr: string + prefix: string + signer?: OfflineSigner +} + +export const txClient = ({ signer, prefix, addr }: TxClientOptions = { addr: "http://localhost:26657", prefix: "cosmos" }) => { + + return { + + async sendMsgVerifyInvariant({ value, fee, memo }: sendMsgVerifyInvariantParams): Promise { + if (!signer) { + throw new Error('TxClient:sendMsgVerifyInvariant: Unable to sign Tx. Signer is not present.') + } + try { + const { address } = (await signer.getAccounts())[0]; + const signingClient = await SigningStargateClient.connectWithSigner(addr,signer,{registry, prefix}); + let msg = this.msgVerifyInvariant({ value: MsgVerifyInvariant.fromPartial(value) }) + return await signingClient.signAndBroadcast(address, [msg], fee ? fee : defaultFee, memo) + } catch (e: any) { + throw new Error('TxClient:sendMsgVerifyInvariant: Could not broadcast Tx: '+ e.message) + } + }, + + + msgVerifyInvariant({ value }: msgVerifyInvariantParams): EncodeObject { + try { + return { typeUrl: "/cosmos.crisis.v1beta1.MsgVerifyInvariant", value: MsgVerifyInvariant.fromPartial( value ) } + } catch (e: any) { + throw new Error('TxClient:MsgVerifyInvariant: Could not create message: ' + e.message) + } + }, + + } +}; + +interface QueryClientOptions { + addr: string +} + +export const queryClient = ({ addr: addr }: QueryClientOptions = { addr: "http://localhost:1317" }) => { + return new Api({ baseUrl: addr }); +}; + +class SDKModule { + public query: ReturnType; + public tx: ReturnType; + + public registry: Array<[string, GeneratedType]>; + + constructor(client: IgniteClient) { + + this.query = queryClient({ addr: client.env.apiURL }); + this.tx = txClient({ signer: client.signer, addr: client.env.rpcURL, prefix: client.env.prefix ?? "cosmos" }); + } +}; + +const Module = (test: IgniteClient) => { + return { + module: { + CosmosCrisisV1Beta1: new SDKModule(test) + }, + registry: msgTypes + } +} +export default Module; \ No newline at end of file diff --git a/ts-client/cosmos.crisis.v1beta1/registry.ts b/ts-client/cosmos.crisis.v1beta1/registry.ts new file mode 100755 index 00000000..66de7b5a --- /dev/null +++ b/ts-client/cosmos.crisis.v1beta1/registry.ts @@ -0,0 +1,9 @@ +import { GeneratedType } from "@cosmjs/proto-signing"; +import { MsgVerifyInvariant } from "./types/cosmos/crisis/v1beta1/tx"; + +const msgTypes: Array<[string, GeneratedType]> = [ + ["/cosmos.crisis.v1beta1.MsgVerifyInvariant", MsgVerifyInvariant], + +]; + +export { msgTypes } \ No newline at end of file diff --git a/ts-client/cosmos.crisis.v1beta1/rest.ts b/ts-client/cosmos.crisis.v1beta1/rest.ts new file mode 100644 index 00000000..6f35bbff --- /dev/null +++ b/ts-client/cosmos.crisis.v1beta1/rest.ts @@ -0,0 +1,223 @@ +/* eslint-disable */ +/* tslint:disable */ +/* + * --------------------------------------------------------------- + * ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ## + * ## ## + * ## AUTHOR: acacode ## + * ## SOURCE: https://github.com/acacode/swagger-typescript-api ## + * --------------------------------------------------------------- + */ + +export interface ProtobufAny { + "@type"?: string; +} + +export interface RpcStatus { + /** @format int32 */ + code?: number; + message?: string; + details?: ProtobufAny[]; +} + +/** + * MsgVerifyInvariantResponse defines the Msg/VerifyInvariant response type. + */ +export type V1Beta1MsgVerifyInvariantResponse = object; + +export type QueryParamsType = Record; +export type ResponseFormat = keyof Omit; + +export interface FullRequestParams extends Omit { + /** set parameter to `true` for call `securityWorker` for this request */ + secure?: boolean; + /** request path */ + path: string; + /** content type of request body */ + type?: ContentType; + /** query params */ + query?: QueryParamsType; + /** format of response (i.e. response.json() -> format: "json") */ + format?: keyof Omit; + /** request body */ + body?: unknown; + /** base url */ + baseUrl?: string; + /** request cancellation token */ + cancelToken?: CancelToken; +} + +export type RequestParams = Omit; + +export interface ApiConfig { + baseUrl?: string; + baseApiParams?: Omit; + securityWorker?: (securityData: SecurityDataType) => RequestParams | void; +} + +export interface HttpResponse extends Response { + data: D; + error: E; +} + +type CancelToken = Symbol | string | number; + +export enum ContentType { + Json = "application/json", + FormData = "multipart/form-data", + UrlEncoded = "application/x-www-form-urlencoded", +} + +export class HttpClient { + public baseUrl: string = ""; + private securityData: SecurityDataType = null as any; + private securityWorker: null | ApiConfig["securityWorker"] = null; + private abortControllers = new Map(); + + private baseApiParams: RequestParams = { + credentials: "same-origin", + headers: {}, + redirect: "follow", + referrerPolicy: "no-referrer", + }; + + constructor(apiConfig: ApiConfig = {}) { + Object.assign(this, apiConfig); + } + + public setSecurityData = (data: SecurityDataType) => { + this.securityData = data; + }; + + private addQueryParam(query: QueryParamsType, key: string) { + const value = query[key]; + + return ( + encodeURIComponent(key) + + "=" + + encodeURIComponent(Array.isArray(value) ? value.join(",") : typeof value === "number" ? value : `${value}`) + ); + } + + protected toQueryString(rawQuery?: QueryParamsType): string { + const query = rawQuery || {}; + const keys = Object.keys(query).filter((key) => "undefined" !== typeof query[key]); + return keys + .map((key) => + typeof query[key] === "object" && !Array.isArray(query[key]) + ? this.toQueryString(query[key] as QueryParamsType) + : this.addQueryParam(query, key), + ) + .join("&"); + } + + protected addQueryParams(rawQuery?: QueryParamsType): string { + const queryString = this.toQueryString(rawQuery); + return queryString ? `?${queryString}` : ""; + } + + private contentFormatters: Record any> = { + [ContentType.Json]: (input: any) => + input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input, + [ContentType.FormData]: (input: any) => + Object.keys(input || {}).reduce((data, key) => { + data.append(key, input[key]); + return data; + }, new FormData()), + [ContentType.UrlEncoded]: (input: any) => this.toQueryString(input), + }; + + private mergeRequestParams(params1: RequestParams, params2?: RequestParams): RequestParams { + return { + ...this.baseApiParams, + ...params1, + ...(params2 || {}), + headers: { + ...(this.baseApiParams.headers || {}), + ...(params1.headers || {}), + ...((params2 && params2.headers) || {}), + }, + }; + } + + private createAbortSignal = (cancelToken: CancelToken): AbortSignal | undefined => { + if (this.abortControllers.has(cancelToken)) { + const abortController = this.abortControllers.get(cancelToken); + if (abortController) { + return abortController.signal; + } + return void 0; + } + + const abortController = new AbortController(); + this.abortControllers.set(cancelToken, abortController); + return abortController.signal; + }; + + public abortRequest = (cancelToken: CancelToken) => { + const abortController = this.abortControllers.get(cancelToken); + + if (abortController) { + abortController.abort(); + this.abortControllers.delete(cancelToken); + } + }; + + public request = ({ + body, + secure, + path, + type, + query, + format = "json", + baseUrl, + cancelToken, + ...params + }: FullRequestParams): Promise> => { + const secureParams = (secure && this.securityWorker && this.securityWorker(this.securityData)) || {}; + const requestParams = this.mergeRequestParams(params, secureParams); + const queryString = query && this.toQueryString(query); + const payloadFormatter = this.contentFormatters[type || ContentType.Json]; + + return fetch(`${baseUrl || this.baseUrl || ""}${path}${queryString ? `?${queryString}` : ""}`, { + ...requestParams, + headers: { + ...(type && type !== ContentType.FormData ? { "Content-Type": type } : {}), + ...(requestParams.headers || {}), + }, + signal: cancelToken ? this.createAbortSignal(cancelToken) : void 0, + body: typeof body === "undefined" || body === null ? null : payloadFormatter(body), + }).then(async (response) => { + const r = response as HttpResponse; + r.data = (null as unknown) as T; + r.error = (null as unknown) as E; + + const data = await response[format]() + .then((data) => { + if (r.ok) { + r.data = data; + } else { + r.error = data; + } + return r; + }) + .catch((e) => { + r.error = e; + return r; + }); + + if (cancelToken) { + this.abortControllers.delete(cancelToken); + } + + if (!response.ok) throw data; + return data; + }); + }; +} + +/** + * @title cosmos/crisis/v1beta1/genesis.proto + * @version version not set + */ +export class Api extends HttpClient {} diff --git a/ts-client/cosmos.crisis.v1beta1/types.ts b/ts-client/cosmos.crisis.v1beta1/types.ts new file mode 100755 index 00000000..fbb084a7 --- /dev/null +++ b/ts-client/cosmos.crisis.v1beta1/types.ts @@ -0,0 +1,5 @@ + + +export { + + } \ No newline at end of file diff --git a/ts-client/cosmos.crisis.v1beta1/types/cosmos/base/v1beta1/coin.ts b/ts-client/cosmos.crisis.v1beta1/types/cosmos/base/v1beta1/coin.ts new file mode 100644 index 00000000..ce2ac984 --- /dev/null +++ b/ts-client/cosmos.crisis.v1beta1/types/cosmos/base/v1beta1/coin.ts @@ -0,0 +1,301 @@ +/* eslint-disable */ +import { Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "cosmos.base.v1beta1"; + +/** + * Coin defines a token with a denomination and an amount. + * + * NOTE: The amount field is an Int which implements the custom method + * signatures required by gogoproto. + */ +export interface Coin { + denom: string; + amount: string; +} + +/** + * DecCoin defines a token with a denomination and a decimal amount. + * + * NOTE: The amount field is an Dec which implements the custom method + * signatures required by gogoproto. + */ +export interface DecCoin { + denom: string; + amount: string; +} + +/** IntProto defines a Protobuf wrapper around an Int object. */ +export interface IntProto { + int: string; +} + +/** DecProto defines a Protobuf wrapper around a Dec object. */ +export interface DecProto { + dec: string; +} + +const baseCoin: object = { denom: "", amount: "" }; + +export const Coin = { + encode(message: Coin, writer: Writer = Writer.create()): Writer { + if (message.denom !== "") { + writer.uint32(10).string(message.denom); + } + if (message.amount !== "") { + writer.uint32(18).string(message.amount); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Coin { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseCoin } as Coin; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.denom = reader.string(); + break; + case 2: + message.amount = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Coin { + const message = { ...baseCoin } as Coin; + if (object.denom !== undefined && object.denom !== null) { + message.denom = String(object.denom); + } else { + message.denom = ""; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = String(object.amount); + } else { + message.amount = ""; + } + return message; + }, + + toJSON(message: Coin): unknown { + const obj: any = {}; + message.denom !== undefined && (obj.denom = message.denom); + message.amount !== undefined && (obj.amount = message.amount); + return obj; + }, + + fromPartial(object: DeepPartial): Coin { + const message = { ...baseCoin } as Coin; + if (object.denom !== undefined && object.denom !== null) { + message.denom = object.denom; + } else { + message.denom = ""; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = object.amount; + } else { + message.amount = ""; + } + return message; + }, +}; + +const baseDecCoin: object = { denom: "", amount: "" }; + +export const DecCoin = { + encode(message: DecCoin, writer: Writer = Writer.create()): Writer { + if (message.denom !== "") { + writer.uint32(10).string(message.denom); + } + if (message.amount !== "") { + writer.uint32(18).string(message.amount); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): DecCoin { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseDecCoin } as DecCoin; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.denom = reader.string(); + break; + case 2: + message.amount = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DecCoin { + const message = { ...baseDecCoin } as DecCoin; + if (object.denom !== undefined && object.denom !== null) { + message.denom = String(object.denom); + } else { + message.denom = ""; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = String(object.amount); + } else { + message.amount = ""; + } + return message; + }, + + toJSON(message: DecCoin): unknown { + const obj: any = {}; + message.denom !== undefined && (obj.denom = message.denom); + message.amount !== undefined && (obj.amount = message.amount); + return obj; + }, + + fromPartial(object: DeepPartial): DecCoin { + const message = { ...baseDecCoin } as DecCoin; + if (object.denom !== undefined && object.denom !== null) { + message.denom = object.denom; + } else { + message.denom = ""; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = object.amount; + } else { + message.amount = ""; + } + return message; + }, +}; + +const baseIntProto: object = { int: "" }; + +export const IntProto = { + encode(message: IntProto, writer: Writer = Writer.create()): Writer { + if (message.int !== "") { + writer.uint32(10).string(message.int); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): IntProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseIntProto } as IntProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.int = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): IntProto { + const message = { ...baseIntProto } as IntProto; + if (object.int !== undefined && object.int !== null) { + message.int = String(object.int); + } else { + message.int = ""; + } + return message; + }, + + toJSON(message: IntProto): unknown { + const obj: any = {}; + message.int !== undefined && (obj.int = message.int); + return obj; + }, + + fromPartial(object: DeepPartial): IntProto { + const message = { ...baseIntProto } as IntProto; + if (object.int !== undefined && object.int !== null) { + message.int = object.int; + } else { + message.int = ""; + } + return message; + }, +}; + +const baseDecProto: object = { dec: "" }; + +export const DecProto = { + encode(message: DecProto, writer: Writer = Writer.create()): Writer { + if (message.dec !== "") { + writer.uint32(10).string(message.dec); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): DecProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseDecProto } as DecProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.dec = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DecProto { + const message = { ...baseDecProto } as DecProto; + if (object.dec !== undefined && object.dec !== null) { + message.dec = String(object.dec); + } else { + message.dec = ""; + } + return message; + }, + + toJSON(message: DecProto): unknown { + const obj: any = {}; + message.dec !== undefined && (obj.dec = message.dec); + return obj; + }, + + fromPartial(object: DeepPartial): DecProto { + const message = { ...baseDecProto } as DecProto; + if (object.dec !== undefined && object.dec !== null) { + message.dec = object.dec; + } else { + message.dec = ""; + } + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/cosmos.crisis.v1beta1/types/cosmos/crisis/v1beta1/genesis.ts b/ts-client/cosmos.crisis.v1beta1/types/cosmos/crisis/v1beta1/genesis.ts new file mode 100644 index 00000000..603198a3 --- /dev/null +++ b/ts-client/cosmos.crisis.v1beta1/types/cosmos/crisis/v1beta1/genesis.ts @@ -0,0 +1,83 @@ +/* eslint-disable */ +import { Coin } from "../../../cosmos/base/v1beta1/coin"; +import { Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "cosmos.crisis.v1beta1"; + +/** GenesisState defines the crisis module's genesis state. */ +export interface GenesisState { + /** + * constant_fee is the fee used to verify the invariant in the crisis + * module. + */ + constantFee: Coin | undefined; +} + +const baseGenesisState: object = {}; + +export const GenesisState = { + encode(message: GenesisState, writer: Writer = Writer.create()): Writer { + if (message.constantFee !== undefined) { + Coin.encode(message.constantFee, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): GenesisState { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseGenesisState } as GenesisState; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 3: + message.constantFee = Coin.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GenesisState { + const message = { ...baseGenesisState } as GenesisState; + if (object.constantFee !== undefined && object.constantFee !== null) { + message.constantFee = Coin.fromJSON(object.constantFee); + } else { + message.constantFee = undefined; + } + return message; + }, + + toJSON(message: GenesisState): unknown { + const obj: any = {}; + message.constantFee !== undefined && + (obj.constantFee = message.constantFee + ? Coin.toJSON(message.constantFee) + : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): GenesisState { + const message = { ...baseGenesisState } as GenesisState; + if (object.constantFee !== undefined && object.constantFee !== null) { + message.constantFee = Coin.fromPartial(object.constantFee); + } else { + message.constantFee = undefined; + } + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/cosmos.crisis.v1beta1/types/cosmos/crisis/v1beta1/tx.ts b/ts-client/cosmos.crisis.v1beta1/types/cosmos/crisis/v1beta1/tx.ts new file mode 100644 index 00000000..6c668817 --- /dev/null +++ b/ts-client/cosmos.crisis.v1beta1/types/cosmos/crisis/v1beta1/tx.ts @@ -0,0 +1,217 @@ +/* eslint-disable */ +import { Reader, Writer } from "protobufjs/minimal"; + +export const protobufPackage = "cosmos.crisis.v1beta1"; + +/** MsgVerifyInvariant represents a message to verify a particular invariance. */ +export interface MsgVerifyInvariant { + sender: string; + invariantModuleName: string; + invariantRoute: string; +} + +/** MsgVerifyInvariantResponse defines the Msg/VerifyInvariant response type. */ +export interface MsgVerifyInvariantResponse {} + +const baseMsgVerifyInvariant: object = { + sender: "", + invariantModuleName: "", + invariantRoute: "", +}; + +export const MsgVerifyInvariant = { + encode( + message: MsgVerifyInvariant, + writer: Writer = Writer.create() + ): Writer { + if (message.sender !== "") { + writer.uint32(10).string(message.sender); + } + if (message.invariantModuleName !== "") { + writer.uint32(18).string(message.invariantModuleName); + } + if (message.invariantRoute !== "") { + writer.uint32(26).string(message.invariantRoute); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MsgVerifyInvariant { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgVerifyInvariant } as MsgVerifyInvariant; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.sender = reader.string(); + break; + case 2: + message.invariantModuleName = reader.string(); + break; + case 3: + message.invariantRoute = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgVerifyInvariant { + const message = { ...baseMsgVerifyInvariant } as MsgVerifyInvariant; + if (object.sender !== undefined && object.sender !== null) { + message.sender = String(object.sender); + } else { + message.sender = ""; + } + if ( + object.invariantModuleName !== undefined && + object.invariantModuleName !== null + ) { + message.invariantModuleName = String(object.invariantModuleName); + } else { + message.invariantModuleName = ""; + } + if (object.invariantRoute !== undefined && object.invariantRoute !== null) { + message.invariantRoute = String(object.invariantRoute); + } else { + message.invariantRoute = ""; + } + return message; + }, + + toJSON(message: MsgVerifyInvariant): unknown { + const obj: any = {}; + message.sender !== undefined && (obj.sender = message.sender); + message.invariantModuleName !== undefined && + (obj.invariantModuleName = message.invariantModuleName); + message.invariantRoute !== undefined && + (obj.invariantRoute = message.invariantRoute); + return obj; + }, + + fromPartial(object: DeepPartial): MsgVerifyInvariant { + const message = { ...baseMsgVerifyInvariant } as MsgVerifyInvariant; + if (object.sender !== undefined && object.sender !== null) { + message.sender = object.sender; + } else { + message.sender = ""; + } + if ( + object.invariantModuleName !== undefined && + object.invariantModuleName !== null + ) { + message.invariantModuleName = object.invariantModuleName; + } else { + message.invariantModuleName = ""; + } + if (object.invariantRoute !== undefined && object.invariantRoute !== null) { + message.invariantRoute = object.invariantRoute; + } else { + message.invariantRoute = ""; + } + return message; + }, +}; + +const baseMsgVerifyInvariantResponse: object = {}; + +export const MsgVerifyInvariantResponse = { + encode( + _: MsgVerifyInvariantResponse, + writer: Writer = Writer.create() + ): Writer { + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): MsgVerifyInvariantResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseMsgVerifyInvariantResponse, + } as MsgVerifyInvariantResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): MsgVerifyInvariantResponse { + const message = { + ...baseMsgVerifyInvariantResponse, + } as MsgVerifyInvariantResponse; + return message; + }, + + toJSON(_: MsgVerifyInvariantResponse): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial( + _: DeepPartial + ): MsgVerifyInvariantResponse { + const message = { + ...baseMsgVerifyInvariantResponse, + } as MsgVerifyInvariantResponse; + return message; + }, +}; + +/** Msg defines the bank Msg service. */ +export interface Msg { + /** VerifyInvariant defines a method to verify a particular invariance. */ + VerifyInvariant( + request: MsgVerifyInvariant + ): Promise; +} + +export class MsgClientImpl implements Msg { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + } + VerifyInvariant( + request: MsgVerifyInvariant + ): Promise { + const data = MsgVerifyInvariant.encode(request).finish(); + const promise = this.rpc.request( + "cosmos.crisis.v1beta1.Msg", + "VerifyInvariant", + data + ); + return promise.then((data) => + MsgVerifyInvariantResponse.decode(new Reader(data)) + ); + } +} + +interface Rpc { + request( + service: string, + method: string, + data: Uint8Array + ): Promise; +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/cosmos.crisis.v1beta1/types/gogoproto/gogo.ts b/ts-client/cosmos.crisis.v1beta1/types/gogoproto/gogo.ts new file mode 100644 index 00000000..3f41a047 --- /dev/null +++ b/ts-client/cosmos.crisis.v1beta1/types/gogoproto/gogo.ts @@ -0,0 +1,2 @@ +/* eslint-disable */ +export const protobufPackage = "gogoproto"; diff --git a/ts-client/cosmos.crisis.v1beta1/types/google/protobuf/descriptor.ts b/ts-client/cosmos.crisis.v1beta1/types/google/protobuf/descriptor.ts new file mode 100644 index 00000000..9e508660 --- /dev/null +++ b/ts-client/cosmos.crisis.v1beta1/types/google/protobuf/descriptor.ts @@ -0,0 +1,5261 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "google.protobuf"; + +/** + * The protocol compiler can output a FileDescriptorSet containing the .proto + * files it parses. + */ +export interface FileDescriptorSet { + file: FileDescriptorProto[]; +} + +/** Describes a complete .proto file. */ +export interface FileDescriptorProto { + /** file name, relative to root of source tree */ + name: string; + /** e.g. "foo", "foo.bar", etc. */ + package: string; + /** Names of files imported by this file. */ + dependency: string[]; + /** Indexes of the public imported files in the dependency list above. */ + publicDependency: number[]; + /** + * Indexes of the weak imported files in the dependency list. + * For Google-internal migration only. Do not use. + */ + weakDependency: number[]; + /** All top-level definitions in this file. */ + messageType: DescriptorProto[]; + enumType: EnumDescriptorProto[]; + service: ServiceDescriptorProto[]; + extension: FieldDescriptorProto[]; + options: FileOptions | undefined; + /** + * This field contains optional information about the original source code. + * You may safely remove this entire field without harming runtime + * functionality of the descriptors -- the information is needed only by + * development tools. + */ + sourceCodeInfo: SourceCodeInfo | undefined; + /** + * The syntax of the proto file. + * The supported values are "proto2" and "proto3". + */ + syntax: string; +} + +/** Describes a message type. */ +export interface DescriptorProto { + name: string; + field: FieldDescriptorProto[]; + extension: FieldDescriptorProto[]; + nestedType: DescriptorProto[]; + enumType: EnumDescriptorProto[]; + extensionRange: DescriptorProto_ExtensionRange[]; + oneofDecl: OneofDescriptorProto[]; + options: MessageOptions | undefined; + reservedRange: DescriptorProto_ReservedRange[]; + /** + * Reserved field names, which may not be used by fields in the same message. + * A given name may only be reserved once. + */ + reservedName: string[]; +} + +export interface DescriptorProto_ExtensionRange { + /** Inclusive. */ + start: number; + /** Exclusive. */ + end: number; + options: ExtensionRangeOptions | undefined; +} + +/** + * Range of reserved tag numbers. Reserved tag numbers may not be used by + * fields or extension ranges in the same message. Reserved ranges may + * not overlap. + */ +export interface DescriptorProto_ReservedRange { + /** Inclusive. */ + start: number; + /** Exclusive. */ + end: number; +} + +export interface ExtensionRangeOptions { + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +/** Describes a field within a message. */ +export interface FieldDescriptorProto { + name: string; + number: number; + label: FieldDescriptorProto_Label; + /** + * If type_name is set, this need not be set. If both this and type_name + * are set, this must be one of TYPE_ENUM, TYPE_MESSAGE or TYPE_GROUP. + */ + type: FieldDescriptorProto_Type; + /** + * For message and enum types, this is the name of the type. If the name + * starts with a '.', it is fully-qualified. Otherwise, C++-like scoping + * rules are used to find the type (i.e. first the nested types within this + * message are searched, then within the parent, on up to the root + * namespace). + */ + typeName: string; + /** + * For extensions, this is the name of the type being extended. It is + * resolved in the same manner as type_name. + */ + extendee: string; + /** + * For numeric types, contains the original text representation of the value. + * For booleans, "true" or "false". + * For strings, contains the default text contents (not escaped in any way). + * For bytes, contains the C escaped value. All bytes >= 128 are escaped. + * TODO(kenton): Base-64 encode? + */ + defaultValue: string; + /** + * If set, gives the index of a oneof in the containing type's oneof_decl + * list. This field is a member of that oneof. + */ + oneofIndex: number; + /** + * JSON name of this field. The value is set by protocol compiler. If the + * user has set a "json_name" option on this field, that option's value + * will be used. Otherwise, it's deduced from the field's name by converting + * it to camelCase. + */ + jsonName: string; + options: FieldOptions | undefined; + /** + * If true, this is a proto3 "optional". When a proto3 field is optional, it + * tracks presence regardless of field type. + * + * When proto3_optional is true, this field must be belong to a oneof to + * signal to old proto3 clients that presence is tracked for this field. This + * oneof is known as a "synthetic" oneof, and this field must be its sole + * member (each proto3 optional field gets its own synthetic oneof). Synthetic + * oneofs exist in the descriptor only, and do not generate any API. Synthetic + * oneofs must be ordered after all "real" oneofs. + * + * For message fields, proto3_optional doesn't create any semantic change, + * since non-repeated message fields always track presence. However it still + * indicates the semantic detail of whether the user wrote "optional" or not. + * This can be useful for round-tripping the .proto file. For consistency we + * give message fields a synthetic oneof also, even though it is not required + * to track presence. This is especially important because the parser can't + * tell if a field is a message or an enum, so it must always create a + * synthetic oneof. + * + * Proto2 optional fields do not set this flag, because they already indicate + * optional with `LABEL_OPTIONAL`. + */ + proto3Optional: boolean; +} + +export enum FieldDescriptorProto_Type { + /** + * TYPE_DOUBLE - 0 is reserved for errors. + * Order is weird for historical reasons. + */ + TYPE_DOUBLE = 1, + TYPE_FLOAT = 2, + /** + * TYPE_INT64 - Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT64 if + * negative values are likely. + */ + TYPE_INT64 = 3, + TYPE_UINT64 = 4, + /** + * TYPE_INT32 - Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT32 if + * negative values are likely. + */ + TYPE_INT32 = 5, + TYPE_FIXED64 = 6, + TYPE_FIXED32 = 7, + TYPE_BOOL = 8, + TYPE_STRING = 9, + /** + * TYPE_GROUP - Tag-delimited aggregate. + * Group type is deprecated and not supported in proto3. However, Proto3 + * implementations should still be able to parse the group wire format and + * treat group fields as unknown fields. + */ + TYPE_GROUP = 10, + /** TYPE_MESSAGE - Length-delimited aggregate. */ + TYPE_MESSAGE = 11, + /** TYPE_BYTES - New in version 2. */ + TYPE_BYTES = 12, + TYPE_UINT32 = 13, + TYPE_ENUM = 14, + TYPE_SFIXED32 = 15, + TYPE_SFIXED64 = 16, + /** TYPE_SINT32 - Uses ZigZag encoding. */ + TYPE_SINT32 = 17, + /** TYPE_SINT64 - Uses ZigZag encoding. */ + TYPE_SINT64 = 18, + UNRECOGNIZED = -1, +} + +export function fieldDescriptorProto_TypeFromJSON( + object: any +): FieldDescriptorProto_Type { + switch (object) { + case 1: + case "TYPE_DOUBLE": + return FieldDescriptorProto_Type.TYPE_DOUBLE; + case 2: + case "TYPE_FLOAT": + return FieldDescriptorProto_Type.TYPE_FLOAT; + case 3: + case "TYPE_INT64": + return FieldDescriptorProto_Type.TYPE_INT64; + case 4: + case "TYPE_UINT64": + return FieldDescriptorProto_Type.TYPE_UINT64; + case 5: + case "TYPE_INT32": + return FieldDescriptorProto_Type.TYPE_INT32; + case 6: + case "TYPE_FIXED64": + return FieldDescriptorProto_Type.TYPE_FIXED64; + case 7: + case "TYPE_FIXED32": + return FieldDescriptorProto_Type.TYPE_FIXED32; + case 8: + case "TYPE_BOOL": + return FieldDescriptorProto_Type.TYPE_BOOL; + case 9: + case "TYPE_STRING": + return FieldDescriptorProto_Type.TYPE_STRING; + case 10: + case "TYPE_GROUP": + return FieldDescriptorProto_Type.TYPE_GROUP; + case 11: + case "TYPE_MESSAGE": + return FieldDescriptorProto_Type.TYPE_MESSAGE; + case 12: + case "TYPE_BYTES": + return FieldDescriptorProto_Type.TYPE_BYTES; + case 13: + case "TYPE_UINT32": + return FieldDescriptorProto_Type.TYPE_UINT32; + case 14: + case "TYPE_ENUM": + return FieldDescriptorProto_Type.TYPE_ENUM; + case 15: + case "TYPE_SFIXED32": + return FieldDescriptorProto_Type.TYPE_SFIXED32; + case 16: + case "TYPE_SFIXED64": + return FieldDescriptorProto_Type.TYPE_SFIXED64; + case 17: + case "TYPE_SINT32": + return FieldDescriptorProto_Type.TYPE_SINT32; + case 18: + case "TYPE_SINT64": + return FieldDescriptorProto_Type.TYPE_SINT64; + case -1: + case "UNRECOGNIZED": + default: + return FieldDescriptorProto_Type.UNRECOGNIZED; + } +} + +export function fieldDescriptorProto_TypeToJSON( + object: FieldDescriptorProto_Type +): string { + switch (object) { + case FieldDescriptorProto_Type.TYPE_DOUBLE: + return "TYPE_DOUBLE"; + case FieldDescriptorProto_Type.TYPE_FLOAT: + return "TYPE_FLOAT"; + case FieldDescriptorProto_Type.TYPE_INT64: + return "TYPE_INT64"; + case FieldDescriptorProto_Type.TYPE_UINT64: + return "TYPE_UINT64"; + case FieldDescriptorProto_Type.TYPE_INT32: + return "TYPE_INT32"; + case FieldDescriptorProto_Type.TYPE_FIXED64: + return "TYPE_FIXED64"; + case FieldDescriptorProto_Type.TYPE_FIXED32: + return "TYPE_FIXED32"; + case FieldDescriptorProto_Type.TYPE_BOOL: + return "TYPE_BOOL"; + case FieldDescriptorProto_Type.TYPE_STRING: + return "TYPE_STRING"; + case FieldDescriptorProto_Type.TYPE_GROUP: + return "TYPE_GROUP"; + case FieldDescriptorProto_Type.TYPE_MESSAGE: + return "TYPE_MESSAGE"; + case FieldDescriptorProto_Type.TYPE_BYTES: + return "TYPE_BYTES"; + case FieldDescriptorProto_Type.TYPE_UINT32: + return "TYPE_UINT32"; + case FieldDescriptorProto_Type.TYPE_ENUM: + return "TYPE_ENUM"; + case FieldDescriptorProto_Type.TYPE_SFIXED32: + return "TYPE_SFIXED32"; + case FieldDescriptorProto_Type.TYPE_SFIXED64: + return "TYPE_SFIXED64"; + case FieldDescriptorProto_Type.TYPE_SINT32: + return "TYPE_SINT32"; + case FieldDescriptorProto_Type.TYPE_SINT64: + return "TYPE_SINT64"; + default: + return "UNKNOWN"; + } +} + +export enum FieldDescriptorProto_Label { + /** LABEL_OPTIONAL - 0 is reserved for errors */ + LABEL_OPTIONAL = 1, + LABEL_REQUIRED = 2, + LABEL_REPEATED = 3, + UNRECOGNIZED = -1, +} + +export function fieldDescriptorProto_LabelFromJSON( + object: any +): FieldDescriptorProto_Label { + switch (object) { + case 1: + case "LABEL_OPTIONAL": + return FieldDescriptorProto_Label.LABEL_OPTIONAL; + case 2: + case "LABEL_REQUIRED": + return FieldDescriptorProto_Label.LABEL_REQUIRED; + case 3: + case "LABEL_REPEATED": + return FieldDescriptorProto_Label.LABEL_REPEATED; + case -1: + case "UNRECOGNIZED": + default: + return FieldDescriptorProto_Label.UNRECOGNIZED; + } +} + +export function fieldDescriptorProto_LabelToJSON( + object: FieldDescriptorProto_Label +): string { + switch (object) { + case FieldDescriptorProto_Label.LABEL_OPTIONAL: + return "LABEL_OPTIONAL"; + case FieldDescriptorProto_Label.LABEL_REQUIRED: + return "LABEL_REQUIRED"; + case FieldDescriptorProto_Label.LABEL_REPEATED: + return "LABEL_REPEATED"; + default: + return "UNKNOWN"; + } +} + +/** Describes a oneof. */ +export interface OneofDescriptorProto { + name: string; + options: OneofOptions | undefined; +} + +/** Describes an enum type. */ +export interface EnumDescriptorProto { + name: string; + value: EnumValueDescriptorProto[]; + options: EnumOptions | undefined; + /** + * Range of reserved numeric values. Reserved numeric values may not be used + * by enum values in the same enum declaration. Reserved ranges may not + * overlap. + */ + reservedRange: EnumDescriptorProto_EnumReservedRange[]; + /** + * Reserved enum value names, which may not be reused. A given name may only + * be reserved once. + */ + reservedName: string[]; +} + +/** + * Range of reserved numeric values. Reserved values may not be used by + * entries in the same enum. Reserved ranges may not overlap. + * + * Note that this is distinct from DescriptorProto.ReservedRange in that it + * is inclusive such that it can appropriately represent the entire int32 + * domain. + */ +export interface EnumDescriptorProto_EnumReservedRange { + /** Inclusive. */ + start: number; + /** Inclusive. */ + end: number; +} + +/** Describes a value within an enum. */ +export interface EnumValueDescriptorProto { + name: string; + number: number; + options: EnumValueOptions | undefined; +} + +/** Describes a service. */ +export interface ServiceDescriptorProto { + name: string; + method: MethodDescriptorProto[]; + options: ServiceOptions | undefined; +} + +/** Describes a method of a service. */ +export interface MethodDescriptorProto { + name: string; + /** + * Input and output type names. These are resolved in the same way as + * FieldDescriptorProto.type_name, but must refer to a message type. + */ + inputType: string; + outputType: string; + options: MethodOptions | undefined; + /** Identifies if client streams multiple client messages */ + clientStreaming: boolean; + /** Identifies if server streams multiple server messages */ + serverStreaming: boolean; +} + +export interface FileOptions { + /** + * Sets the Java package where classes generated from this .proto will be + * placed. By default, the proto package is used, but this is often + * inappropriate because proto packages do not normally start with backwards + * domain names. + */ + javaPackage: string; + /** + * Controls the name of the wrapper Java class generated for the .proto file. + * That class will always contain the .proto file's getDescriptor() method as + * well as any top-level extensions defined in the .proto file. + * If java_multiple_files is disabled, then all the other classes from the + * .proto file will be nested inside the single wrapper outer class. + */ + javaOuterClassname: string; + /** + * If enabled, then the Java code generator will generate a separate .java + * file for each top-level message, enum, and service defined in the .proto + * file. Thus, these types will *not* be nested inside the wrapper class + * named by java_outer_classname. However, the wrapper class will still be + * generated to contain the file's getDescriptor() method as well as any + * top-level extensions defined in the file. + */ + javaMultipleFiles: boolean; + /** + * This option does nothing. + * + * @deprecated + */ + javaGenerateEqualsAndHash: boolean; + /** + * If set true, then the Java2 code generator will generate code that + * throws an exception whenever an attempt is made to assign a non-UTF-8 + * byte sequence to a string field. + * Message reflection will do the same. + * However, an extension field still accepts non-UTF-8 byte sequences. + * This option has no effect on when used with the lite runtime. + */ + javaStringCheckUtf8: boolean; + optimizeFor: FileOptions_OptimizeMode; + /** + * Sets the Go package where structs generated from this .proto will be + * placed. If omitted, the Go package will be derived from the following: + * - The basename of the package import path, if provided. + * - Otherwise, the package statement in the .proto file, if present. + * - Otherwise, the basename of the .proto file, without extension. + */ + goPackage: string; + /** + * Should generic services be generated in each language? "Generic" services + * are not specific to any particular RPC system. They are generated by the + * main code generators in each language (without additional plugins). + * Generic services were the only kind of service generation supported by + * early versions of google.protobuf. + * + * Generic services are now considered deprecated in favor of using plugins + * that generate code specific to your particular RPC system. Therefore, + * these default to false. Old code which depends on generic services should + * explicitly set them to true. + */ + ccGenericServices: boolean; + javaGenericServices: boolean; + pyGenericServices: boolean; + phpGenericServices: boolean; + /** + * Is this file deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for everything in the file, or it will be completely ignored; in the very + * least, this is a formalization for deprecating files. + */ + deprecated: boolean; + /** + * Enables the use of arenas for the proto messages in this file. This applies + * only to generated classes for C++. + */ + ccEnableArenas: boolean; + /** + * Sets the objective c class prefix which is prepended to all objective c + * generated classes from this .proto. There is no default. + */ + objcClassPrefix: string; + /** Namespace for generated classes; defaults to the package. */ + csharpNamespace: string; + /** + * By default Swift generators will take the proto package and CamelCase it + * replacing '.' with underscore and use that to prefix the types/symbols + * defined. When this options is provided, they will use this value instead + * to prefix the types/symbols defined. + */ + swiftPrefix: string; + /** + * Sets the php class prefix which is prepended to all php generated classes + * from this .proto. Default is empty. + */ + phpClassPrefix: string; + /** + * Use this option to change the namespace of php generated classes. Default + * is empty. When this option is empty, the package name will be used for + * determining the namespace. + */ + phpNamespace: string; + /** + * Use this option to change the namespace of php generated metadata classes. + * Default is empty. When this option is empty, the proto file name will be + * used for determining the namespace. + */ + phpMetadataNamespace: string; + /** + * Use this option to change the package of ruby generated classes. Default + * is empty. When this option is not set, the package name will be used for + * determining the ruby package. + */ + rubyPackage: string; + /** + * The parser stores options it doesn't recognize here. + * See the documentation for the "Options" section above. + */ + uninterpretedOption: UninterpretedOption[]; +} + +/** Generated classes can be optimized for speed or code size. */ +export enum FileOptions_OptimizeMode { + /** SPEED - Generate complete code for parsing, serialization, */ + SPEED = 1, + /** CODE_SIZE - etc. */ + CODE_SIZE = 2, + /** LITE_RUNTIME - Generate code using MessageLite and the lite runtime. */ + LITE_RUNTIME = 3, + UNRECOGNIZED = -1, +} + +export function fileOptions_OptimizeModeFromJSON( + object: any +): FileOptions_OptimizeMode { + switch (object) { + case 1: + case "SPEED": + return FileOptions_OptimizeMode.SPEED; + case 2: + case "CODE_SIZE": + return FileOptions_OptimizeMode.CODE_SIZE; + case 3: + case "LITE_RUNTIME": + return FileOptions_OptimizeMode.LITE_RUNTIME; + case -1: + case "UNRECOGNIZED": + default: + return FileOptions_OptimizeMode.UNRECOGNIZED; + } +} + +export function fileOptions_OptimizeModeToJSON( + object: FileOptions_OptimizeMode +): string { + switch (object) { + case FileOptions_OptimizeMode.SPEED: + return "SPEED"; + case FileOptions_OptimizeMode.CODE_SIZE: + return "CODE_SIZE"; + case FileOptions_OptimizeMode.LITE_RUNTIME: + return "LITE_RUNTIME"; + default: + return "UNKNOWN"; + } +} + +export interface MessageOptions { + /** + * Set true to use the old proto1 MessageSet wire format for extensions. + * This is provided for backwards-compatibility with the MessageSet wire + * format. You should not use this for any other reason: It's less + * efficient, has fewer features, and is more complicated. + * + * The message must be defined exactly as follows: + * message Foo { + * option message_set_wire_format = true; + * extensions 4 to max; + * } + * Note that the message cannot have any defined fields; MessageSets only + * have extensions. + * + * All extensions of your type must be singular messages; e.g. they cannot + * be int32s, enums, or repeated messages. + * + * Because this is an option, the above two restrictions are not enforced by + * the protocol compiler. + */ + messageSetWireFormat: boolean; + /** + * Disables the generation of the standard "descriptor()" accessor, which can + * conflict with a field of the same name. This is meant to make migration + * from proto1 easier; new code should avoid fields named "descriptor". + */ + noStandardDescriptorAccessor: boolean; + /** + * Is this message deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the message, or it will be completely ignored; in the very least, + * this is a formalization for deprecating messages. + */ + deprecated: boolean; + /** + * Whether the message is an automatically generated map entry type for the + * maps field. + * + * For maps fields: + * map map_field = 1; + * The parsed descriptor looks like: + * message MapFieldEntry { + * option map_entry = true; + * optional KeyType key = 1; + * optional ValueType value = 2; + * } + * repeated MapFieldEntry map_field = 1; + * + * Implementations may choose not to generate the map_entry=true message, but + * use a native map in the target language to hold the keys and values. + * The reflection APIs in such implementations still need to work as + * if the field is a repeated message field. + * + * NOTE: Do not set the option in .proto files. Always use the maps syntax + * instead. The option should only be implicitly set by the proto compiler + * parser. + */ + mapEntry: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface FieldOptions { + /** + * The ctype option instructs the C++ code generator to use a different + * representation of the field than it normally would. See the specific + * options below. This option is not yet implemented in the open source + * release -- sorry, we'll try to include it in a future version! + */ + ctype: FieldOptions_CType; + /** + * The packed option can be enabled for repeated primitive fields to enable + * a more efficient representation on the wire. Rather than repeatedly + * writing the tag and type for each element, the entire array is encoded as + * a single length-delimited blob. In proto3, only explicit setting it to + * false will avoid using packed encoding. + */ + packed: boolean; + /** + * The jstype option determines the JavaScript type used for values of the + * field. The option is permitted only for 64 bit integral and fixed types + * (int64, uint64, sint64, fixed64, sfixed64). A field with jstype JS_STRING + * is represented as JavaScript string, which avoids loss of precision that + * can happen when a large value is converted to a floating point JavaScript. + * Specifying JS_NUMBER for the jstype causes the generated JavaScript code to + * use the JavaScript "number" type. The behavior of the default option + * JS_NORMAL is implementation dependent. + * + * This option is an enum to permit additional types to be added, e.g. + * goog.math.Integer. + */ + jstype: FieldOptions_JSType; + /** + * Should this field be parsed lazily? Lazy applies only to message-type + * fields. It means that when the outer message is initially parsed, the + * inner message's contents will not be parsed but instead stored in encoded + * form. The inner message will actually be parsed when it is first accessed. + * + * This is only a hint. Implementations are free to choose whether to use + * eager or lazy parsing regardless of the value of this option. However, + * setting this option true suggests that the protocol author believes that + * using lazy parsing on this field is worth the additional bookkeeping + * overhead typically needed to implement it. + * + * This option does not affect the public interface of any generated code; + * all method signatures remain the same. Furthermore, thread-safety of the + * interface is not affected by this option; const methods remain safe to + * call from multiple threads concurrently, while non-const methods continue + * to require exclusive access. + * + * + * Note that implementations may choose not to check required fields within + * a lazy sub-message. That is, calling IsInitialized() on the outer message + * may return true even if the inner message has missing required fields. + * This is necessary because otherwise the inner message would have to be + * parsed in order to perform the check, defeating the purpose of lazy + * parsing. An implementation which chooses not to check required fields + * must be consistent about it. That is, for any particular sub-message, the + * implementation must either *always* check its required fields, or *never* + * check its required fields, regardless of whether or not the message has + * been parsed. + */ + lazy: boolean; + /** + * Is this field deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for accessors, or it will be completely ignored; in the very least, this + * is a formalization for deprecating fields. + */ + deprecated: boolean; + /** For Google-internal migration only. Do not use. */ + weak: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export enum FieldOptions_CType { + /** STRING - Default mode. */ + STRING = 0, + CORD = 1, + STRING_PIECE = 2, + UNRECOGNIZED = -1, +} + +export function fieldOptions_CTypeFromJSON(object: any): FieldOptions_CType { + switch (object) { + case 0: + case "STRING": + return FieldOptions_CType.STRING; + case 1: + case "CORD": + return FieldOptions_CType.CORD; + case 2: + case "STRING_PIECE": + return FieldOptions_CType.STRING_PIECE; + case -1: + case "UNRECOGNIZED": + default: + return FieldOptions_CType.UNRECOGNIZED; + } +} + +export function fieldOptions_CTypeToJSON(object: FieldOptions_CType): string { + switch (object) { + case FieldOptions_CType.STRING: + return "STRING"; + case FieldOptions_CType.CORD: + return "CORD"; + case FieldOptions_CType.STRING_PIECE: + return "STRING_PIECE"; + default: + return "UNKNOWN"; + } +} + +export enum FieldOptions_JSType { + /** JS_NORMAL - Use the default type. */ + JS_NORMAL = 0, + /** JS_STRING - Use JavaScript strings. */ + JS_STRING = 1, + /** JS_NUMBER - Use JavaScript numbers. */ + JS_NUMBER = 2, + UNRECOGNIZED = -1, +} + +export function fieldOptions_JSTypeFromJSON(object: any): FieldOptions_JSType { + switch (object) { + case 0: + case "JS_NORMAL": + return FieldOptions_JSType.JS_NORMAL; + case 1: + case "JS_STRING": + return FieldOptions_JSType.JS_STRING; + case 2: + case "JS_NUMBER": + return FieldOptions_JSType.JS_NUMBER; + case -1: + case "UNRECOGNIZED": + default: + return FieldOptions_JSType.UNRECOGNIZED; + } +} + +export function fieldOptions_JSTypeToJSON(object: FieldOptions_JSType): string { + switch (object) { + case FieldOptions_JSType.JS_NORMAL: + return "JS_NORMAL"; + case FieldOptions_JSType.JS_STRING: + return "JS_STRING"; + case FieldOptions_JSType.JS_NUMBER: + return "JS_NUMBER"; + default: + return "UNKNOWN"; + } +} + +export interface OneofOptions { + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface EnumOptions { + /** + * Set this option to true to allow mapping different tag names to the same + * value. + */ + allowAlias: boolean; + /** + * Is this enum deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the enum, or it will be completely ignored; in the very least, this + * is a formalization for deprecating enums. + */ + deprecated: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface EnumValueOptions { + /** + * Is this enum value deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the enum value, or it will be completely ignored; in the very least, + * this is a formalization for deprecating enum values. + */ + deprecated: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface ServiceOptions { + /** + * Is this service deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the service, or it will be completely ignored; in the very least, + * this is a formalization for deprecating services. + */ + deprecated: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface MethodOptions { + /** + * Is this method deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the method, or it will be completely ignored; in the very least, + * this is a formalization for deprecating methods. + */ + deprecated: boolean; + idempotencyLevel: MethodOptions_IdempotencyLevel; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +/** + * Is this method side-effect-free (or safe in HTTP parlance), or idempotent, + * or neither? HTTP based RPC implementation may choose GET verb for safe + * methods, and PUT verb for idempotent methods instead of the default POST. + */ +export enum MethodOptions_IdempotencyLevel { + IDEMPOTENCY_UNKNOWN = 0, + /** NO_SIDE_EFFECTS - implies idempotent */ + NO_SIDE_EFFECTS = 1, + /** IDEMPOTENT - idempotent, but may have side effects */ + IDEMPOTENT = 2, + UNRECOGNIZED = -1, +} + +export function methodOptions_IdempotencyLevelFromJSON( + object: any +): MethodOptions_IdempotencyLevel { + switch (object) { + case 0: + case "IDEMPOTENCY_UNKNOWN": + return MethodOptions_IdempotencyLevel.IDEMPOTENCY_UNKNOWN; + case 1: + case "NO_SIDE_EFFECTS": + return MethodOptions_IdempotencyLevel.NO_SIDE_EFFECTS; + case 2: + case "IDEMPOTENT": + return MethodOptions_IdempotencyLevel.IDEMPOTENT; + case -1: + case "UNRECOGNIZED": + default: + return MethodOptions_IdempotencyLevel.UNRECOGNIZED; + } +} + +export function methodOptions_IdempotencyLevelToJSON( + object: MethodOptions_IdempotencyLevel +): string { + switch (object) { + case MethodOptions_IdempotencyLevel.IDEMPOTENCY_UNKNOWN: + return "IDEMPOTENCY_UNKNOWN"; + case MethodOptions_IdempotencyLevel.NO_SIDE_EFFECTS: + return "NO_SIDE_EFFECTS"; + case MethodOptions_IdempotencyLevel.IDEMPOTENT: + return "IDEMPOTENT"; + default: + return "UNKNOWN"; + } +} + +/** + * A message representing a option the parser does not recognize. This only + * appears in options protos created by the compiler::Parser class. + * DescriptorPool resolves these when building Descriptor objects. Therefore, + * options protos in descriptor objects (e.g. returned by Descriptor::options(), + * or produced by Descriptor::CopyTo()) will never have UninterpretedOptions + * in them. + */ +export interface UninterpretedOption { + name: UninterpretedOption_NamePart[]; + /** + * The value of the uninterpreted option, in whatever type the tokenizer + * identified it as during parsing. Exactly one of these should be set. + */ + identifierValue: string; + positiveIntValue: number; + negativeIntValue: number; + doubleValue: number; + stringValue: Uint8Array; + aggregateValue: string; +} + +/** + * The name of the uninterpreted option. Each string represents a segment in + * a dot-separated name. is_extension is true iff a segment represents an + * extension (denoted with parentheses in options specs in .proto files). + * E.g.,{ ["foo", false], ["bar.baz", true], ["qux", false] } represents + * "foo.(bar.baz).qux". + */ +export interface UninterpretedOption_NamePart { + namePart: string; + isExtension: boolean; +} + +/** + * Encapsulates information about the original source file from which a + * FileDescriptorProto was generated. + */ +export interface SourceCodeInfo { + /** + * A Location identifies a piece of source code in a .proto file which + * corresponds to a particular definition. This information is intended + * to be useful to IDEs, code indexers, documentation generators, and similar + * tools. + * + * For example, say we have a file like: + * message Foo { + * optional string foo = 1; + * } + * Let's look at just the field definition: + * optional string foo = 1; + * ^ ^^ ^^ ^ ^^^ + * a bc de f ghi + * We have the following locations: + * span path represents + * [a,i) [ 4, 0, 2, 0 ] The whole field definition. + * [a,b) [ 4, 0, 2, 0, 4 ] The label (optional). + * [c,d) [ 4, 0, 2, 0, 5 ] The type (string). + * [e,f) [ 4, 0, 2, 0, 1 ] The name (foo). + * [g,h) [ 4, 0, 2, 0, 3 ] The number (1). + * + * Notes: + * - A location may refer to a repeated field itself (i.e. not to any + * particular index within it). This is used whenever a set of elements are + * logically enclosed in a single code segment. For example, an entire + * extend block (possibly containing multiple extension definitions) will + * have an outer location whose path refers to the "extensions" repeated + * field without an index. + * - Multiple locations may have the same path. This happens when a single + * logical declaration is spread out across multiple places. The most + * obvious example is the "extend" block again -- there may be multiple + * extend blocks in the same scope, each of which will have the same path. + * - A location's span is not always a subset of its parent's span. For + * example, the "extendee" of an extension declaration appears at the + * beginning of the "extend" block and is shared by all extensions within + * the block. + * - Just because a location's span is a subset of some other location's span + * does not mean that it is a descendant. For example, a "group" defines + * both a type and a field in a single declaration. Thus, the locations + * corresponding to the type and field and their components will overlap. + * - Code which tries to interpret locations should probably be designed to + * ignore those that it doesn't understand, as more types of locations could + * be recorded in the future. + */ + location: SourceCodeInfo_Location[]; +} + +export interface SourceCodeInfo_Location { + /** + * Identifies which part of the FileDescriptorProto was defined at this + * location. + * + * Each element is a field number or an index. They form a path from + * the root FileDescriptorProto to the place where the definition. For + * example, this path: + * [ 4, 3, 2, 7, 1 ] + * refers to: + * file.message_type(3) // 4, 3 + * .field(7) // 2, 7 + * .name() // 1 + * This is because FileDescriptorProto.message_type has field number 4: + * repeated DescriptorProto message_type = 4; + * and DescriptorProto.field has field number 2: + * repeated FieldDescriptorProto field = 2; + * and FieldDescriptorProto.name has field number 1: + * optional string name = 1; + * + * Thus, the above path gives the location of a field name. If we removed + * the last element: + * [ 4, 3, 2, 7 ] + * this path refers to the whole field declaration (from the beginning + * of the label to the terminating semicolon). + */ + path: number[]; + /** + * Always has exactly three or four elements: start line, start column, + * end line (optional, otherwise assumed same as start line), end column. + * These are packed into a single field for efficiency. Note that line + * and column numbers are zero-based -- typically you will want to add + * 1 to each before displaying to a user. + */ + span: number[]; + /** + * If this SourceCodeInfo represents a complete declaration, these are any + * comments appearing before and after the declaration which appear to be + * attached to the declaration. + * + * A series of line comments appearing on consecutive lines, with no other + * tokens appearing on those lines, will be treated as a single comment. + * + * leading_detached_comments will keep paragraphs of comments that appear + * before (but not connected to) the current element. Each paragraph, + * separated by empty lines, will be one comment element in the repeated + * field. + * + * Only the comment content is provided; comment markers (e.g. //) are + * stripped out. For block comments, leading whitespace and an asterisk + * will be stripped from the beginning of each line other than the first. + * Newlines are included in the output. + * + * Examples: + * + * optional int32 foo = 1; // Comment attached to foo. + * // Comment attached to bar. + * optional int32 bar = 2; + * + * optional string baz = 3; + * // Comment attached to baz. + * // Another line attached to baz. + * + * // Comment attached to qux. + * // + * // Another line attached to qux. + * optional double qux = 4; + * + * // Detached comment for corge. This is not leading or trailing comments + * // to qux or corge because there are blank lines separating it from + * // both. + * + * // Detached comment for corge paragraph 2. + * + * optional string corge = 5; + * /* Block comment attached + * * to corge. Leading asterisks + * * will be removed. * / + * /* Block comment attached to + * * grault. * / + * optional int32 grault = 6; + * + * // ignored detached comments. + */ + leadingComments: string; + trailingComments: string; + leadingDetachedComments: string[]; +} + +/** + * Describes the relationship between generated code and its original source + * file. A GeneratedCodeInfo message is associated with only one generated + * source file, but may contain references to different source .proto files. + */ +export interface GeneratedCodeInfo { + /** + * An Annotation connects some span of text in generated code to an element + * of its generating .proto file. + */ + annotation: GeneratedCodeInfo_Annotation[]; +} + +export interface GeneratedCodeInfo_Annotation { + /** + * Identifies the element in the original source .proto file. This field + * is formatted the same as SourceCodeInfo.Location.path. + */ + path: number[]; + /** Identifies the filesystem path to the original source .proto. */ + sourceFile: string; + /** + * Identifies the starting offset in bytes in the generated code + * that relates to the identified object. + */ + begin: number; + /** + * Identifies the ending offset in bytes in the generated code that + * relates to the identified offset. The end offset should be one past + * the last relevant byte (so the length of the text = end - begin). + */ + end: number; +} + +const baseFileDescriptorSet: object = {}; + +export const FileDescriptorSet = { + encode(message: FileDescriptorSet, writer: Writer = Writer.create()): Writer { + for (const v of message.file) { + FileDescriptorProto.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FileDescriptorSet { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFileDescriptorSet } as FileDescriptorSet; + message.file = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.file.push( + FileDescriptorProto.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FileDescriptorSet { + const message = { ...baseFileDescriptorSet } as FileDescriptorSet; + message.file = []; + if (object.file !== undefined && object.file !== null) { + for (const e of object.file) { + message.file.push(FileDescriptorProto.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: FileDescriptorSet): unknown { + const obj: any = {}; + if (message.file) { + obj.file = message.file.map((e) => + e ? FileDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.file = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): FileDescriptorSet { + const message = { ...baseFileDescriptorSet } as FileDescriptorSet; + message.file = []; + if (object.file !== undefined && object.file !== null) { + for (const e of object.file) { + message.file.push(FileDescriptorProto.fromPartial(e)); + } + } + return message; + }, +}; + +const baseFileDescriptorProto: object = { + name: "", + package: "", + dependency: "", + publicDependency: 0, + weakDependency: 0, + syntax: "", +}; + +export const FileDescriptorProto = { + encode( + message: FileDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.package !== "") { + writer.uint32(18).string(message.package); + } + for (const v of message.dependency) { + writer.uint32(26).string(v!); + } + writer.uint32(82).fork(); + for (const v of message.publicDependency) { + writer.int32(v); + } + writer.ldelim(); + writer.uint32(90).fork(); + for (const v of message.weakDependency) { + writer.int32(v); + } + writer.ldelim(); + for (const v of message.messageType) { + DescriptorProto.encode(v!, writer.uint32(34).fork()).ldelim(); + } + for (const v of message.enumType) { + EnumDescriptorProto.encode(v!, writer.uint32(42).fork()).ldelim(); + } + for (const v of message.service) { + ServiceDescriptorProto.encode(v!, writer.uint32(50).fork()).ldelim(); + } + for (const v of message.extension) { + FieldDescriptorProto.encode(v!, writer.uint32(58).fork()).ldelim(); + } + if (message.options !== undefined) { + FileOptions.encode(message.options, writer.uint32(66).fork()).ldelim(); + } + if (message.sourceCodeInfo !== undefined) { + SourceCodeInfo.encode( + message.sourceCodeInfo, + writer.uint32(74).fork() + ).ldelim(); + } + if (message.syntax !== "") { + writer.uint32(98).string(message.syntax); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FileDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFileDescriptorProto } as FileDescriptorProto; + message.dependency = []; + message.publicDependency = []; + message.weakDependency = []; + message.messageType = []; + message.enumType = []; + message.service = []; + message.extension = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.package = reader.string(); + break; + case 3: + message.dependency.push(reader.string()); + break; + case 10: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.publicDependency.push(reader.int32()); + } + } else { + message.publicDependency.push(reader.int32()); + } + break; + case 11: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.weakDependency.push(reader.int32()); + } + } else { + message.weakDependency.push(reader.int32()); + } + break; + case 4: + message.messageType.push( + DescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 5: + message.enumType.push( + EnumDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 6: + message.service.push( + ServiceDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 7: + message.extension.push( + FieldDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 8: + message.options = FileOptions.decode(reader, reader.uint32()); + break; + case 9: + message.sourceCodeInfo = SourceCodeInfo.decode( + reader, + reader.uint32() + ); + break; + case 12: + message.syntax = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FileDescriptorProto { + const message = { ...baseFileDescriptorProto } as FileDescriptorProto; + message.dependency = []; + message.publicDependency = []; + message.weakDependency = []; + message.messageType = []; + message.enumType = []; + message.service = []; + message.extension = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.package !== undefined && object.package !== null) { + message.package = String(object.package); + } else { + message.package = ""; + } + if (object.dependency !== undefined && object.dependency !== null) { + for (const e of object.dependency) { + message.dependency.push(String(e)); + } + } + if ( + object.publicDependency !== undefined && + object.publicDependency !== null + ) { + for (const e of object.publicDependency) { + message.publicDependency.push(Number(e)); + } + } + if (object.weakDependency !== undefined && object.weakDependency !== null) { + for (const e of object.weakDependency) { + message.weakDependency.push(Number(e)); + } + } + if (object.messageType !== undefined && object.messageType !== null) { + for (const e of object.messageType) { + message.messageType.push(DescriptorProto.fromJSON(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromJSON(e)); + } + } + if (object.service !== undefined && object.service !== null) { + for (const e of object.service) { + message.service.push(ServiceDescriptorProto.fromJSON(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = FileOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.sourceCodeInfo !== undefined && object.sourceCodeInfo !== null) { + message.sourceCodeInfo = SourceCodeInfo.fromJSON(object.sourceCodeInfo); + } else { + message.sourceCodeInfo = undefined; + } + if (object.syntax !== undefined && object.syntax !== null) { + message.syntax = String(object.syntax); + } else { + message.syntax = ""; + } + return message; + }, + + toJSON(message: FileDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.package !== undefined && (obj.package = message.package); + if (message.dependency) { + obj.dependency = message.dependency.map((e) => e); + } else { + obj.dependency = []; + } + if (message.publicDependency) { + obj.publicDependency = message.publicDependency.map((e) => e); + } else { + obj.publicDependency = []; + } + if (message.weakDependency) { + obj.weakDependency = message.weakDependency.map((e) => e); + } else { + obj.weakDependency = []; + } + if (message.messageType) { + obj.messageType = message.messageType.map((e) => + e ? DescriptorProto.toJSON(e) : undefined + ); + } else { + obj.messageType = []; + } + if (message.enumType) { + obj.enumType = message.enumType.map((e) => + e ? EnumDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.enumType = []; + } + if (message.service) { + obj.service = message.service.map((e) => + e ? ServiceDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.service = []; + } + if (message.extension) { + obj.extension = message.extension.map((e) => + e ? FieldDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.extension = []; + } + message.options !== undefined && + (obj.options = message.options + ? FileOptions.toJSON(message.options) + : undefined); + message.sourceCodeInfo !== undefined && + (obj.sourceCodeInfo = message.sourceCodeInfo + ? SourceCodeInfo.toJSON(message.sourceCodeInfo) + : undefined); + message.syntax !== undefined && (obj.syntax = message.syntax); + return obj; + }, + + fromPartial(object: DeepPartial): FileDescriptorProto { + const message = { ...baseFileDescriptorProto } as FileDescriptorProto; + message.dependency = []; + message.publicDependency = []; + message.weakDependency = []; + message.messageType = []; + message.enumType = []; + message.service = []; + message.extension = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.package !== undefined && object.package !== null) { + message.package = object.package; + } else { + message.package = ""; + } + if (object.dependency !== undefined && object.dependency !== null) { + for (const e of object.dependency) { + message.dependency.push(e); + } + } + if ( + object.publicDependency !== undefined && + object.publicDependency !== null + ) { + for (const e of object.publicDependency) { + message.publicDependency.push(e); + } + } + if (object.weakDependency !== undefined && object.weakDependency !== null) { + for (const e of object.weakDependency) { + message.weakDependency.push(e); + } + } + if (object.messageType !== undefined && object.messageType !== null) { + for (const e of object.messageType) { + message.messageType.push(DescriptorProto.fromPartial(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromPartial(e)); + } + } + if (object.service !== undefined && object.service !== null) { + for (const e of object.service) { + message.service.push(ServiceDescriptorProto.fromPartial(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = FileOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.sourceCodeInfo !== undefined && object.sourceCodeInfo !== null) { + message.sourceCodeInfo = SourceCodeInfo.fromPartial( + object.sourceCodeInfo + ); + } else { + message.sourceCodeInfo = undefined; + } + if (object.syntax !== undefined && object.syntax !== null) { + message.syntax = object.syntax; + } else { + message.syntax = ""; + } + return message; + }, +}; + +const baseDescriptorProto: object = { name: "", reservedName: "" }; + +export const DescriptorProto = { + encode(message: DescriptorProto, writer: Writer = Writer.create()): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + for (const v of message.field) { + FieldDescriptorProto.encode(v!, writer.uint32(18).fork()).ldelim(); + } + for (const v of message.extension) { + FieldDescriptorProto.encode(v!, writer.uint32(50).fork()).ldelim(); + } + for (const v of message.nestedType) { + DescriptorProto.encode(v!, writer.uint32(26).fork()).ldelim(); + } + for (const v of message.enumType) { + EnumDescriptorProto.encode(v!, writer.uint32(34).fork()).ldelim(); + } + for (const v of message.extensionRange) { + DescriptorProto_ExtensionRange.encode( + v!, + writer.uint32(42).fork() + ).ldelim(); + } + for (const v of message.oneofDecl) { + OneofDescriptorProto.encode(v!, writer.uint32(66).fork()).ldelim(); + } + if (message.options !== undefined) { + MessageOptions.encode(message.options, writer.uint32(58).fork()).ldelim(); + } + for (const v of message.reservedRange) { + DescriptorProto_ReservedRange.encode( + v!, + writer.uint32(74).fork() + ).ldelim(); + } + for (const v of message.reservedName) { + writer.uint32(82).string(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): DescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseDescriptorProto } as DescriptorProto; + message.field = []; + message.extension = []; + message.nestedType = []; + message.enumType = []; + message.extensionRange = []; + message.oneofDecl = []; + message.reservedRange = []; + message.reservedName = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.field.push( + FieldDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 6: + message.extension.push( + FieldDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 3: + message.nestedType.push( + DescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 4: + message.enumType.push( + EnumDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 5: + message.extensionRange.push( + DescriptorProto_ExtensionRange.decode(reader, reader.uint32()) + ); + break; + case 8: + message.oneofDecl.push( + OneofDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 7: + message.options = MessageOptions.decode(reader, reader.uint32()); + break; + case 9: + message.reservedRange.push( + DescriptorProto_ReservedRange.decode(reader, reader.uint32()) + ); + break; + case 10: + message.reservedName.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DescriptorProto { + const message = { ...baseDescriptorProto } as DescriptorProto; + message.field = []; + message.extension = []; + message.nestedType = []; + message.enumType = []; + message.extensionRange = []; + message.oneofDecl = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.field !== undefined && object.field !== null) { + for (const e of object.field) { + message.field.push(FieldDescriptorProto.fromJSON(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromJSON(e)); + } + } + if (object.nestedType !== undefined && object.nestedType !== null) { + for (const e of object.nestedType) { + message.nestedType.push(DescriptorProto.fromJSON(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromJSON(e)); + } + } + if (object.extensionRange !== undefined && object.extensionRange !== null) { + for (const e of object.extensionRange) { + message.extensionRange.push(DescriptorProto_ExtensionRange.fromJSON(e)); + } + } + if (object.oneofDecl !== undefined && object.oneofDecl !== null) { + for (const e of object.oneofDecl) { + message.oneofDecl.push(OneofDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = MessageOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push(DescriptorProto_ReservedRange.fromJSON(e)); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(String(e)); + } + } + return message; + }, + + toJSON(message: DescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + if (message.field) { + obj.field = message.field.map((e) => + e ? FieldDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.field = []; + } + if (message.extension) { + obj.extension = message.extension.map((e) => + e ? FieldDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.extension = []; + } + if (message.nestedType) { + obj.nestedType = message.nestedType.map((e) => + e ? DescriptorProto.toJSON(e) : undefined + ); + } else { + obj.nestedType = []; + } + if (message.enumType) { + obj.enumType = message.enumType.map((e) => + e ? EnumDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.enumType = []; + } + if (message.extensionRange) { + obj.extensionRange = message.extensionRange.map((e) => + e ? DescriptorProto_ExtensionRange.toJSON(e) : undefined + ); + } else { + obj.extensionRange = []; + } + if (message.oneofDecl) { + obj.oneofDecl = message.oneofDecl.map((e) => + e ? OneofDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.oneofDecl = []; + } + message.options !== undefined && + (obj.options = message.options + ? MessageOptions.toJSON(message.options) + : undefined); + if (message.reservedRange) { + obj.reservedRange = message.reservedRange.map((e) => + e ? DescriptorProto_ReservedRange.toJSON(e) : undefined + ); + } else { + obj.reservedRange = []; + } + if (message.reservedName) { + obj.reservedName = message.reservedName.map((e) => e); + } else { + obj.reservedName = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): DescriptorProto { + const message = { ...baseDescriptorProto } as DescriptorProto; + message.field = []; + message.extension = []; + message.nestedType = []; + message.enumType = []; + message.extensionRange = []; + message.oneofDecl = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.field !== undefined && object.field !== null) { + for (const e of object.field) { + message.field.push(FieldDescriptorProto.fromPartial(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromPartial(e)); + } + } + if (object.nestedType !== undefined && object.nestedType !== null) { + for (const e of object.nestedType) { + message.nestedType.push(DescriptorProto.fromPartial(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromPartial(e)); + } + } + if (object.extensionRange !== undefined && object.extensionRange !== null) { + for (const e of object.extensionRange) { + message.extensionRange.push( + DescriptorProto_ExtensionRange.fromPartial(e) + ); + } + } + if (object.oneofDecl !== undefined && object.oneofDecl !== null) { + for (const e of object.oneofDecl) { + message.oneofDecl.push(OneofDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = MessageOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push( + DescriptorProto_ReservedRange.fromPartial(e) + ); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(e); + } + } + return message; + }, +}; + +const baseDescriptorProto_ExtensionRange: object = { start: 0, end: 0 }; + +export const DescriptorProto_ExtensionRange = { + encode( + message: DescriptorProto_ExtensionRange, + writer: Writer = Writer.create() + ): Writer { + if (message.start !== 0) { + writer.uint32(8).int32(message.start); + } + if (message.end !== 0) { + writer.uint32(16).int32(message.end); + } + if (message.options !== undefined) { + ExtensionRangeOptions.encode( + message.options, + writer.uint32(26).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): DescriptorProto_ExtensionRange { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseDescriptorProto_ExtensionRange, + } as DescriptorProto_ExtensionRange; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.start = reader.int32(); + break; + case 2: + message.end = reader.int32(); + break; + case 3: + message.options = ExtensionRangeOptions.decode( + reader, + reader.uint32() + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DescriptorProto_ExtensionRange { + const message = { + ...baseDescriptorProto_ExtensionRange, + } as DescriptorProto_ExtensionRange; + if (object.start !== undefined && object.start !== null) { + message.start = Number(object.start); + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = ExtensionRangeOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: DescriptorProto_ExtensionRange): unknown { + const obj: any = {}; + message.start !== undefined && (obj.start = message.start); + message.end !== undefined && (obj.end = message.end); + message.options !== undefined && + (obj.options = message.options + ? ExtensionRangeOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): DescriptorProto_ExtensionRange { + const message = { + ...baseDescriptorProto_ExtensionRange, + } as DescriptorProto_ExtensionRange; + if (object.start !== undefined && object.start !== null) { + message.start = object.start; + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = ExtensionRangeOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseDescriptorProto_ReservedRange: object = { start: 0, end: 0 }; + +export const DescriptorProto_ReservedRange = { + encode( + message: DescriptorProto_ReservedRange, + writer: Writer = Writer.create() + ): Writer { + if (message.start !== 0) { + writer.uint32(8).int32(message.start); + } + if (message.end !== 0) { + writer.uint32(16).int32(message.end); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): DescriptorProto_ReservedRange { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseDescriptorProto_ReservedRange, + } as DescriptorProto_ReservedRange; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.start = reader.int32(); + break; + case 2: + message.end = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DescriptorProto_ReservedRange { + const message = { + ...baseDescriptorProto_ReservedRange, + } as DescriptorProto_ReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = Number(object.start); + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + return message; + }, + + toJSON(message: DescriptorProto_ReservedRange): unknown { + const obj: any = {}; + message.start !== undefined && (obj.start = message.start); + message.end !== undefined && (obj.end = message.end); + return obj; + }, + + fromPartial( + object: DeepPartial + ): DescriptorProto_ReservedRange { + const message = { + ...baseDescriptorProto_ReservedRange, + } as DescriptorProto_ReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = object.start; + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + return message; + }, +}; + +const baseExtensionRangeOptions: object = {}; + +export const ExtensionRangeOptions = { + encode( + message: ExtensionRangeOptions, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ExtensionRangeOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseExtensionRangeOptions } as ExtensionRangeOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ExtensionRangeOptions { + const message = { ...baseExtensionRangeOptions } as ExtensionRangeOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: ExtensionRangeOptions): unknown { + const obj: any = {}; + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial( + object: DeepPartial + ): ExtensionRangeOptions { + const message = { ...baseExtensionRangeOptions } as ExtensionRangeOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseFieldDescriptorProto: object = { + name: "", + number: 0, + label: 1, + type: 1, + typeName: "", + extendee: "", + defaultValue: "", + oneofIndex: 0, + jsonName: "", + proto3Optional: false, +}; + +export const FieldDescriptorProto = { + encode( + message: FieldDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.number !== 0) { + writer.uint32(24).int32(message.number); + } + if (message.label !== 1) { + writer.uint32(32).int32(message.label); + } + if (message.type !== 1) { + writer.uint32(40).int32(message.type); + } + if (message.typeName !== "") { + writer.uint32(50).string(message.typeName); + } + if (message.extendee !== "") { + writer.uint32(18).string(message.extendee); + } + if (message.defaultValue !== "") { + writer.uint32(58).string(message.defaultValue); + } + if (message.oneofIndex !== 0) { + writer.uint32(72).int32(message.oneofIndex); + } + if (message.jsonName !== "") { + writer.uint32(82).string(message.jsonName); + } + if (message.options !== undefined) { + FieldOptions.encode(message.options, writer.uint32(66).fork()).ldelim(); + } + if (message.proto3Optional === true) { + writer.uint32(136).bool(message.proto3Optional); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FieldDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFieldDescriptorProto } as FieldDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 3: + message.number = reader.int32(); + break; + case 4: + message.label = reader.int32() as any; + break; + case 5: + message.type = reader.int32() as any; + break; + case 6: + message.typeName = reader.string(); + break; + case 2: + message.extendee = reader.string(); + break; + case 7: + message.defaultValue = reader.string(); + break; + case 9: + message.oneofIndex = reader.int32(); + break; + case 10: + message.jsonName = reader.string(); + break; + case 8: + message.options = FieldOptions.decode(reader, reader.uint32()); + break; + case 17: + message.proto3Optional = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FieldDescriptorProto { + const message = { ...baseFieldDescriptorProto } as FieldDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = Number(object.number); + } else { + message.number = 0; + } + if (object.label !== undefined && object.label !== null) { + message.label = fieldDescriptorProto_LabelFromJSON(object.label); + } else { + message.label = 1; + } + if (object.type !== undefined && object.type !== null) { + message.type = fieldDescriptorProto_TypeFromJSON(object.type); + } else { + message.type = 1; + } + if (object.typeName !== undefined && object.typeName !== null) { + message.typeName = String(object.typeName); + } else { + message.typeName = ""; + } + if (object.extendee !== undefined && object.extendee !== null) { + message.extendee = String(object.extendee); + } else { + message.extendee = ""; + } + if (object.defaultValue !== undefined && object.defaultValue !== null) { + message.defaultValue = String(object.defaultValue); + } else { + message.defaultValue = ""; + } + if (object.oneofIndex !== undefined && object.oneofIndex !== null) { + message.oneofIndex = Number(object.oneofIndex); + } else { + message.oneofIndex = 0; + } + if (object.jsonName !== undefined && object.jsonName !== null) { + message.jsonName = String(object.jsonName); + } else { + message.jsonName = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = FieldOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.proto3Optional !== undefined && object.proto3Optional !== null) { + message.proto3Optional = Boolean(object.proto3Optional); + } else { + message.proto3Optional = false; + } + return message; + }, + + toJSON(message: FieldDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.number !== undefined && (obj.number = message.number); + message.label !== undefined && + (obj.label = fieldDescriptorProto_LabelToJSON(message.label)); + message.type !== undefined && + (obj.type = fieldDescriptorProto_TypeToJSON(message.type)); + message.typeName !== undefined && (obj.typeName = message.typeName); + message.extendee !== undefined && (obj.extendee = message.extendee); + message.defaultValue !== undefined && + (obj.defaultValue = message.defaultValue); + message.oneofIndex !== undefined && (obj.oneofIndex = message.oneofIndex); + message.jsonName !== undefined && (obj.jsonName = message.jsonName); + message.options !== undefined && + (obj.options = message.options + ? FieldOptions.toJSON(message.options) + : undefined); + message.proto3Optional !== undefined && + (obj.proto3Optional = message.proto3Optional); + return obj; + }, + + fromPartial(object: DeepPartial): FieldDescriptorProto { + const message = { ...baseFieldDescriptorProto } as FieldDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = object.number; + } else { + message.number = 0; + } + if (object.label !== undefined && object.label !== null) { + message.label = object.label; + } else { + message.label = 1; + } + if (object.type !== undefined && object.type !== null) { + message.type = object.type; + } else { + message.type = 1; + } + if (object.typeName !== undefined && object.typeName !== null) { + message.typeName = object.typeName; + } else { + message.typeName = ""; + } + if (object.extendee !== undefined && object.extendee !== null) { + message.extendee = object.extendee; + } else { + message.extendee = ""; + } + if (object.defaultValue !== undefined && object.defaultValue !== null) { + message.defaultValue = object.defaultValue; + } else { + message.defaultValue = ""; + } + if (object.oneofIndex !== undefined && object.oneofIndex !== null) { + message.oneofIndex = object.oneofIndex; + } else { + message.oneofIndex = 0; + } + if (object.jsonName !== undefined && object.jsonName !== null) { + message.jsonName = object.jsonName; + } else { + message.jsonName = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = FieldOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.proto3Optional !== undefined && object.proto3Optional !== null) { + message.proto3Optional = object.proto3Optional; + } else { + message.proto3Optional = false; + } + return message; + }, +}; + +const baseOneofDescriptorProto: object = { name: "" }; + +export const OneofDescriptorProto = { + encode( + message: OneofDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.options !== undefined) { + OneofOptions.encode(message.options, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): OneofDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseOneofDescriptorProto } as OneofDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.options = OneofOptions.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): OneofDescriptorProto { + const message = { ...baseOneofDescriptorProto } as OneofDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = OneofOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: OneofDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.options !== undefined && + (obj.options = message.options + ? OneofOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): OneofDescriptorProto { + const message = { ...baseOneofDescriptorProto } as OneofDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = OneofOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseEnumDescriptorProto: object = { name: "", reservedName: "" }; + +export const EnumDescriptorProto = { + encode( + message: EnumDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + for (const v of message.value) { + EnumValueDescriptorProto.encode(v!, writer.uint32(18).fork()).ldelim(); + } + if (message.options !== undefined) { + EnumOptions.encode(message.options, writer.uint32(26).fork()).ldelim(); + } + for (const v of message.reservedRange) { + EnumDescriptorProto_EnumReservedRange.encode( + v!, + writer.uint32(34).fork() + ).ldelim(); + } + for (const v of message.reservedName) { + writer.uint32(42).string(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): EnumDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseEnumDescriptorProto } as EnumDescriptorProto; + message.value = []; + message.reservedRange = []; + message.reservedName = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.value.push( + EnumValueDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 3: + message.options = EnumOptions.decode(reader, reader.uint32()); + break; + case 4: + message.reservedRange.push( + EnumDescriptorProto_EnumReservedRange.decode( + reader, + reader.uint32() + ) + ); + break; + case 5: + message.reservedName.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumDescriptorProto { + const message = { ...baseEnumDescriptorProto } as EnumDescriptorProto; + message.value = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.value !== undefined && object.value !== null) { + for (const e of object.value) { + message.value.push(EnumValueDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push( + EnumDescriptorProto_EnumReservedRange.fromJSON(e) + ); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(String(e)); + } + } + return message; + }, + + toJSON(message: EnumDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + if (message.value) { + obj.value = message.value.map((e) => + e ? EnumValueDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.value = []; + } + message.options !== undefined && + (obj.options = message.options + ? EnumOptions.toJSON(message.options) + : undefined); + if (message.reservedRange) { + obj.reservedRange = message.reservedRange.map((e) => + e ? EnumDescriptorProto_EnumReservedRange.toJSON(e) : undefined + ); + } else { + obj.reservedRange = []; + } + if (message.reservedName) { + obj.reservedName = message.reservedName.map((e) => e); + } else { + obj.reservedName = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): EnumDescriptorProto { + const message = { ...baseEnumDescriptorProto } as EnumDescriptorProto; + message.value = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.value !== undefined && object.value !== null) { + for (const e of object.value) { + message.value.push(EnumValueDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push( + EnumDescriptorProto_EnumReservedRange.fromPartial(e) + ); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(e); + } + } + return message; + }, +}; + +const baseEnumDescriptorProto_EnumReservedRange: object = { start: 0, end: 0 }; + +export const EnumDescriptorProto_EnumReservedRange = { + encode( + message: EnumDescriptorProto_EnumReservedRange, + writer: Writer = Writer.create() + ): Writer { + if (message.start !== 0) { + writer.uint32(8).int32(message.start); + } + if (message.end !== 0) { + writer.uint32(16).int32(message.end); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): EnumDescriptorProto_EnumReservedRange { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseEnumDescriptorProto_EnumReservedRange, + } as EnumDescriptorProto_EnumReservedRange; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.start = reader.int32(); + break; + case 2: + message.end = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumDescriptorProto_EnumReservedRange { + const message = { + ...baseEnumDescriptorProto_EnumReservedRange, + } as EnumDescriptorProto_EnumReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = Number(object.start); + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + return message; + }, + + toJSON(message: EnumDescriptorProto_EnumReservedRange): unknown { + const obj: any = {}; + message.start !== undefined && (obj.start = message.start); + message.end !== undefined && (obj.end = message.end); + return obj; + }, + + fromPartial( + object: DeepPartial + ): EnumDescriptorProto_EnumReservedRange { + const message = { + ...baseEnumDescriptorProto_EnumReservedRange, + } as EnumDescriptorProto_EnumReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = object.start; + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + return message; + }, +}; + +const baseEnumValueDescriptorProto: object = { name: "", number: 0 }; + +export const EnumValueDescriptorProto = { + encode( + message: EnumValueDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.number !== 0) { + writer.uint32(16).int32(message.number); + } + if (message.options !== undefined) { + EnumValueOptions.encode( + message.options, + writer.uint32(26).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): EnumValueDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseEnumValueDescriptorProto, + } as EnumValueDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.number = reader.int32(); + break; + case 3: + message.options = EnumValueOptions.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumValueDescriptorProto { + const message = { + ...baseEnumValueDescriptorProto, + } as EnumValueDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = Number(object.number); + } else { + message.number = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumValueOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: EnumValueDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.number !== undefined && (obj.number = message.number); + message.options !== undefined && + (obj.options = message.options + ? EnumValueOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): EnumValueDescriptorProto { + const message = { + ...baseEnumValueDescriptorProto, + } as EnumValueDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = object.number; + } else { + message.number = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumValueOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseServiceDescriptorProto: object = { name: "" }; + +export const ServiceDescriptorProto = { + encode( + message: ServiceDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + for (const v of message.method) { + MethodDescriptorProto.encode(v!, writer.uint32(18).fork()).ldelim(); + } + if (message.options !== undefined) { + ServiceOptions.encode(message.options, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ServiceDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseServiceDescriptorProto } as ServiceDescriptorProto; + message.method = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.method.push( + MethodDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 3: + message.options = ServiceOptions.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ServiceDescriptorProto { + const message = { ...baseServiceDescriptorProto } as ServiceDescriptorProto; + message.method = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.method !== undefined && object.method !== null) { + for (const e of object.method) { + message.method.push(MethodDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = ServiceOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: ServiceDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + if (message.method) { + obj.method = message.method.map((e) => + e ? MethodDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.method = []; + } + message.options !== undefined && + (obj.options = message.options + ? ServiceOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): ServiceDescriptorProto { + const message = { ...baseServiceDescriptorProto } as ServiceDescriptorProto; + message.method = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.method !== undefined && object.method !== null) { + for (const e of object.method) { + message.method.push(MethodDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = ServiceOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseMethodDescriptorProto: object = { + name: "", + inputType: "", + outputType: "", + clientStreaming: false, + serverStreaming: false, +}; + +export const MethodDescriptorProto = { + encode( + message: MethodDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.inputType !== "") { + writer.uint32(18).string(message.inputType); + } + if (message.outputType !== "") { + writer.uint32(26).string(message.outputType); + } + if (message.options !== undefined) { + MethodOptions.encode(message.options, writer.uint32(34).fork()).ldelim(); + } + if (message.clientStreaming === true) { + writer.uint32(40).bool(message.clientStreaming); + } + if (message.serverStreaming === true) { + writer.uint32(48).bool(message.serverStreaming); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MethodDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMethodDescriptorProto } as MethodDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.inputType = reader.string(); + break; + case 3: + message.outputType = reader.string(); + break; + case 4: + message.options = MethodOptions.decode(reader, reader.uint32()); + break; + case 5: + message.clientStreaming = reader.bool(); + break; + case 6: + message.serverStreaming = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MethodDescriptorProto { + const message = { ...baseMethodDescriptorProto } as MethodDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.inputType !== undefined && object.inputType !== null) { + message.inputType = String(object.inputType); + } else { + message.inputType = ""; + } + if (object.outputType !== undefined && object.outputType !== null) { + message.outputType = String(object.outputType); + } else { + message.outputType = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = MethodOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if ( + object.clientStreaming !== undefined && + object.clientStreaming !== null + ) { + message.clientStreaming = Boolean(object.clientStreaming); + } else { + message.clientStreaming = false; + } + if ( + object.serverStreaming !== undefined && + object.serverStreaming !== null + ) { + message.serverStreaming = Boolean(object.serverStreaming); + } else { + message.serverStreaming = false; + } + return message; + }, + + toJSON(message: MethodDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.inputType !== undefined && (obj.inputType = message.inputType); + message.outputType !== undefined && (obj.outputType = message.outputType); + message.options !== undefined && + (obj.options = message.options + ? MethodOptions.toJSON(message.options) + : undefined); + message.clientStreaming !== undefined && + (obj.clientStreaming = message.clientStreaming); + message.serverStreaming !== undefined && + (obj.serverStreaming = message.serverStreaming); + return obj; + }, + + fromPartial( + object: DeepPartial + ): MethodDescriptorProto { + const message = { ...baseMethodDescriptorProto } as MethodDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.inputType !== undefined && object.inputType !== null) { + message.inputType = object.inputType; + } else { + message.inputType = ""; + } + if (object.outputType !== undefined && object.outputType !== null) { + message.outputType = object.outputType; + } else { + message.outputType = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = MethodOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if ( + object.clientStreaming !== undefined && + object.clientStreaming !== null + ) { + message.clientStreaming = object.clientStreaming; + } else { + message.clientStreaming = false; + } + if ( + object.serverStreaming !== undefined && + object.serverStreaming !== null + ) { + message.serverStreaming = object.serverStreaming; + } else { + message.serverStreaming = false; + } + return message; + }, +}; + +const baseFileOptions: object = { + javaPackage: "", + javaOuterClassname: "", + javaMultipleFiles: false, + javaGenerateEqualsAndHash: false, + javaStringCheckUtf8: false, + optimizeFor: 1, + goPackage: "", + ccGenericServices: false, + javaGenericServices: false, + pyGenericServices: false, + phpGenericServices: false, + deprecated: false, + ccEnableArenas: false, + objcClassPrefix: "", + csharpNamespace: "", + swiftPrefix: "", + phpClassPrefix: "", + phpNamespace: "", + phpMetadataNamespace: "", + rubyPackage: "", +}; + +export const FileOptions = { + encode(message: FileOptions, writer: Writer = Writer.create()): Writer { + if (message.javaPackage !== "") { + writer.uint32(10).string(message.javaPackage); + } + if (message.javaOuterClassname !== "") { + writer.uint32(66).string(message.javaOuterClassname); + } + if (message.javaMultipleFiles === true) { + writer.uint32(80).bool(message.javaMultipleFiles); + } + if (message.javaGenerateEqualsAndHash === true) { + writer.uint32(160).bool(message.javaGenerateEqualsAndHash); + } + if (message.javaStringCheckUtf8 === true) { + writer.uint32(216).bool(message.javaStringCheckUtf8); + } + if (message.optimizeFor !== 1) { + writer.uint32(72).int32(message.optimizeFor); + } + if (message.goPackage !== "") { + writer.uint32(90).string(message.goPackage); + } + if (message.ccGenericServices === true) { + writer.uint32(128).bool(message.ccGenericServices); + } + if (message.javaGenericServices === true) { + writer.uint32(136).bool(message.javaGenericServices); + } + if (message.pyGenericServices === true) { + writer.uint32(144).bool(message.pyGenericServices); + } + if (message.phpGenericServices === true) { + writer.uint32(336).bool(message.phpGenericServices); + } + if (message.deprecated === true) { + writer.uint32(184).bool(message.deprecated); + } + if (message.ccEnableArenas === true) { + writer.uint32(248).bool(message.ccEnableArenas); + } + if (message.objcClassPrefix !== "") { + writer.uint32(290).string(message.objcClassPrefix); + } + if (message.csharpNamespace !== "") { + writer.uint32(298).string(message.csharpNamespace); + } + if (message.swiftPrefix !== "") { + writer.uint32(314).string(message.swiftPrefix); + } + if (message.phpClassPrefix !== "") { + writer.uint32(322).string(message.phpClassPrefix); + } + if (message.phpNamespace !== "") { + writer.uint32(330).string(message.phpNamespace); + } + if (message.phpMetadataNamespace !== "") { + writer.uint32(354).string(message.phpMetadataNamespace); + } + if (message.rubyPackage !== "") { + writer.uint32(362).string(message.rubyPackage); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FileOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFileOptions } as FileOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.javaPackage = reader.string(); + break; + case 8: + message.javaOuterClassname = reader.string(); + break; + case 10: + message.javaMultipleFiles = reader.bool(); + break; + case 20: + message.javaGenerateEqualsAndHash = reader.bool(); + break; + case 27: + message.javaStringCheckUtf8 = reader.bool(); + break; + case 9: + message.optimizeFor = reader.int32() as any; + break; + case 11: + message.goPackage = reader.string(); + break; + case 16: + message.ccGenericServices = reader.bool(); + break; + case 17: + message.javaGenericServices = reader.bool(); + break; + case 18: + message.pyGenericServices = reader.bool(); + break; + case 42: + message.phpGenericServices = reader.bool(); + break; + case 23: + message.deprecated = reader.bool(); + break; + case 31: + message.ccEnableArenas = reader.bool(); + break; + case 36: + message.objcClassPrefix = reader.string(); + break; + case 37: + message.csharpNamespace = reader.string(); + break; + case 39: + message.swiftPrefix = reader.string(); + break; + case 40: + message.phpClassPrefix = reader.string(); + break; + case 41: + message.phpNamespace = reader.string(); + break; + case 44: + message.phpMetadataNamespace = reader.string(); + break; + case 45: + message.rubyPackage = reader.string(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FileOptions { + const message = { ...baseFileOptions } as FileOptions; + message.uninterpretedOption = []; + if (object.javaPackage !== undefined && object.javaPackage !== null) { + message.javaPackage = String(object.javaPackage); + } else { + message.javaPackage = ""; + } + if ( + object.javaOuterClassname !== undefined && + object.javaOuterClassname !== null + ) { + message.javaOuterClassname = String(object.javaOuterClassname); + } else { + message.javaOuterClassname = ""; + } + if ( + object.javaMultipleFiles !== undefined && + object.javaMultipleFiles !== null + ) { + message.javaMultipleFiles = Boolean(object.javaMultipleFiles); + } else { + message.javaMultipleFiles = false; + } + if ( + object.javaGenerateEqualsAndHash !== undefined && + object.javaGenerateEqualsAndHash !== null + ) { + message.javaGenerateEqualsAndHash = Boolean( + object.javaGenerateEqualsAndHash + ); + } else { + message.javaGenerateEqualsAndHash = false; + } + if ( + object.javaStringCheckUtf8 !== undefined && + object.javaStringCheckUtf8 !== null + ) { + message.javaStringCheckUtf8 = Boolean(object.javaStringCheckUtf8); + } else { + message.javaStringCheckUtf8 = false; + } + if (object.optimizeFor !== undefined && object.optimizeFor !== null) { + message.optimizeFor = fileOptions_OptimizeModeFromJSON( + object.optimizeFor + ); + } else { + message.optimizeFor = 1; + } + if (object.goPackage !== undefined && object.goPackage !== null) { + message.goPackage = String(object.goPackage); + } else { + message.goPackage = ""; + } + if ( + object.ccGenericServices !== undefined && + object.ccGenericServices !== null + ) { + message.ccGenericServices = Boolean(object.ccGenericServices); + } else { + message.ccGenericServices = false; + } + if ( + object.javaGenericServices !== undefined && + object.javaGenericServices !== null + ) { + message.javaGenericServices = Boolean(object.javaGenericServices); + } else { + message.javaGenericServices = false; + } + if ( + object.pyGenericServices !== undefined && + object.pyGenericServices !== null + ) { + message.pyGenericServices = Boolean(object.pyGenericServices); + } else { + message.pyGenericServices = false; + } + if ( + object.phpGenericServices !== undefined && + object.phpGenericServices !== null + ) { + message.phpGenericServices = Boolean(object.phpGenericServices); + } else { + message.phpGenericServices = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if (object.ccEnableArenas !== undefined && object.ccEnableArenas !== null) { + message.ccEnableArenas = Boolean(object.ccEnableArenas); + } else { + message.ccEnableArenas = false; + } + if ( + object.objcClassPrefix !== undefined && + object.objcClassPrefix !== null + ) { + message.objcClassPrefix = String(object.objcClassPrefix); + } else { + message.objcClassPrefix = ""; + } + if ( + object.csharpNamespace !== undefined && + object.csharpNamespace !== null + ) { + message.csharpNamespace = String(object.csharpNamespace); + } else { + message.csharpNamespace = ""; + } + if (object.swiftPrefix !== undefined && object.swiftPrefix !== null) { + message.swiftPrefix = String(object.swiftPrefix); + } else { + message.swiftPrefix = ""; + } + if (object.phpClassPrefix !== undefined && object.phpClassPrefix !== null) { + message.phpClassPrefix = String(object.phpClassPrefix); + } else { + message.phpClassPrefix = ""; + } + if (object.phpNamespace !== undefined && object.phpNamespace !== null) { + message.phpNamespace = String(object.phpNamespace); + } else { + message.phpNamespace = ""; + } + if ( + object.phpMetadataNamespace !== undefined && + object.phpMetadataNamespace !== null + ) { + message.phpMetadataNamespace = String(object.phpMetadataNamespace); + } else { + message.phpMetadataNamespace = ""; + } + if (object.rubyPackage !== undefined && object.rubyPackage !== null) { + message.rubyPackage = String(object.rubyPackage); + } else { + message.rubyPackage = ""; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: FileOptions): unknown { + const obj: any = {}; + message.javaPackage !== undefined && + (obj.javaPackage = message.javaPackage); + message.javaOuterClassname !== undefined && + (obj.javaOuterClassname = message.javaOuterClassname); + message.javaMultipleFiles !== undefined && + (obj.javaMultipleFiles = message.javaMultipleFiles); + message.javaGenerateEqualsAndHash !== undefined && + (obj.javaGenerateEqualsAndHash = message.javaGenerateEqualsAndHash); + message.javaStringCheckUtf8 !== undefined && + (obj.javaStringCheckUtf8 = message.javaStringCheckUtf8); + message.optimizeFor !== undefined && + (obj.optimizeFor = fileOptions_OptimizeModeToJSON(message.optimizeFor)); + message.goPackage !== undefined && (obj.goPackage = message.goPackage); + message.ccGenericServices !== undefined && + (obj.ccGenericServices = message.ccGenericServices); + message.javaGenericServices !== undefined && + (obj.javaGenericServices = message.javaGenericServices); + message.pyGenericServices !== undefined && + (obj.pyGenericServices = message.pyGenericServices); + message.phpGenericServices !== undefined && + (obj.phpGenericServices = message.phpGenericServices); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.ccEnableArenas !== undefined && + (obj.ccEnableArenas = message.ccEnableArenas); + message.objcClassPrefix !== undefined && + (obj.objcClassPrefix = message.objcClassPrefix); + message.csharpNamespace !== undefined && + (obj.csharpNamespace = message.csharpNamespace); + message.swiftPrefix !== undefined && + (obj.swiftPrefix = message.swiftPrefix); + message.phpClassPrefix !== undefined && + (obj.phpClassPrefix = message.phpClassPrefix); + message.phpNamespace !== undefined && + (obj.phpNamespace = message.phpNamespace); + message.phpMetadataNamespace !== undefined && + (obj.phpMetadataNamespace = message.phpMetadataNamespace); + message.rubyPackage !== undefined && + (obj.rubyPackage = message.rubyPackage); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): FileOptions { + const message = { ...baseFileOptions } as FileOptions; + message.uninterpretedOption = []; + if (object.javaPackage !== undefined && object.javaPackage !== null) { + message.javaPackage = object.javaPackage; + } else { + message.javaPackage = ""; + } + if ( + object.javaOuterClassname !== undefined && + object.javaOuterClassname !== null + ) { + message.javaOuterClassname = object.javaOuterClassname; + } else { + message.javaOuterClassname = ""; + } + if ( + object.javaMultipleFiles !== undefined && + object.javaMultipleFiles !== null + ) { + message.javaMultipleFiles = object.javaMultipleFiles; + } else { + message.javaMultipleFiles = false; + } + if ( + object.javaGenerateEqualsAndHash !== undefined && + object.javaGenerateEqualsAndHash !== null + ) { + message.javaGenerateEqualsAndHash = object.javaGenerateEqualsAndHash; + } else { + message.javaGenerateEqualsAndHash = false; + } + if ( + object.javaStringCheckUtf8 !== undefined && + object.javaStringCheckUtf8 !== null + ) { + message.javaStringCheckUtf8 = object.javaStringCheckUtf8; + } else { + message.javaStringCheckUtf8 = false; + } + if (object.optimizeFor !== undefined && object.optimizeFor !== null) { + message.optimizeFor = object.optimizeFor; + } else { + message.optimizeFor = 1; + } + if (object.goPackage !== undefined && object.goPackage !== null) { + message.goPackage = object.goPackage; + } else { + message.goPackage = ""; + } + if ( + object.ccGenericServices !== undefined && + object.ccGenericServices !== null + ) { + message.ccGenericServices = object.ccGenericServices; + } else { + message.ccGenericServices = false; + } + if ( + object.javaGenericServices !== undefined && + object.javaGenericServices !== null + ) { + message.javaGenericServices = object.javaGenericServices; + } else { + message.javaGenericServices = false; + } + if ( + object.pyGenericServices !== undefined && + object.pyGenericServices !== null + ) { + message.pyGenericServices = object.pyGenericServices; + } else { + message.pyGenericServices = false; + } + if ( + object.phpGenericServices !== undefined && + object.phpGenericServices !== null + ) { + message.phpGenericServices = object.phpGenericServices; + } else { + message.phpGenericServices = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if (object.ccEnableArenas !== undefined && object.ccEnableArenas !== null) { + message.ccEnableArenas = object.ccEnableArenas; + } else { + message.ccEnableArenas = false; + } + if ( + object.objcClassPrefix !== undefined && + object.objcClassPrefix !== null + ) { + message.objcClassPrefix = object.objcClassPrefix; + } else { + message.objcClassPrefix = ""; + } + if ( + object.csharpNamespace !== undefined && + object.csharpNamespace !== null + ) { + message.csharpNamespace = object.csharpNamespace; + } else { + message.csharpNamespace = ""; + } + if (object.swiftPrefix !== undefined && object.swiftPrefix !== null) { + message.swiftPrefix = object.swiftPrefix; + } else { + message.swiftPrefix = ""; + } + if (object.phpClassPrefix !== undefined && object.phpClassPrefix !== null) { + message.phpClassPrefix = object.phpClassPrefix; + } else { + message.phpClassPrefix = ""; + } + if (object.phpNamespace !== undefined && object.phpNamespace !== null) { + message.phpNamespace = object.phpNamespace; + } else { + message.phpNamespace = ""; + } + if ( + object.phpMetadataNamespace !== undefined && + object.phpMetadataNamespace !== null + ) { + message.phpMetadataNamespace = object.phpMetadataNamespace; + } else { + message.phpMetadataNamespace = ""; + } + if (object.rubyPackage !== undefined && object.rubyPackage !== null) { + message.rubyPackage = object.rubyPackage; + } else { + message.rubyPackage = ""; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseMessageOptions: object = { + messageSetWireFormat: false, + noStandardDescriptorAccessor: false, + deprecated: false, + mapEntry: false, +}; + +export const MessageOptions = { + encode(message: MessageOptions, writer: Writer = Writer.create()): Writer { + if (message.messageSetWireFormat === true) { + writer.uint32(8).bool(message.messageSetWireFormat); + } + if (message.noStandardDescriptorAccessor === true) { + writer.uint32(16).bool(message.noStandardDescriptorAccessor); + } + if (message.deprecated === true) { + writer.uint32(24).bool(message.deprecated); + } + if (message.mapEntry === true) { + writer.uint32(56).bool(message.mapEntry); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MessageOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMessageOptions } as MessageOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.messageSetWireFormat = reader.bool(); + break; + case 2: + message.noStandardDescriptorAccessor = reader.bool(); + break; + case 3: + message.deprecated = reader.bool(); + break; + case 7: + message.mapEntry = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MessageOptions { + const message = { ...baseMessageOptions } as MessageOptions; + message.uninterpretedOption = []; + if ( + object.messageSetWireFormat !== undefined && + object.messageSetWireFormat !== null + ) { + message.messageSetWireFormat = Boolean(object.messageSetWireFormat); + } else { + message.messageSetWireFormat = false; + } + if ( + object.noStandardDescriptorAccessor !== undefined && + object.noStandardDescriptorAccessor !== null + ) { + message.noStandardDescriptorAccessor = Boolean( + object.noStandardDescriptorAccessor + ); + } else { + message.noStandardDescriptorAccessor = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if (object.mapEntry !== undefined && object.mapEntry !== null) { + message.mapEntry = Boolean(object.mapEntry); + } else { + message.mapEntry = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: MessageOptions): unknown { + const obj: any = {}; + message.messageSetWireFormat !== undefined && + (obj.messageSetWireFormat = message.messageSetWireFormat); + message.noStandardDescriptorAccessor !== undefined && + (obj.noStandardDescriptorAccessor = message.noStandardDescriptorAccessor); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.mapEntry !== undefined && (obj.mapEntry = message.mapEntry); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): MessageOptions { + const message = { ...baseMessageOptions } as MessageOptions; + message.uninterpretedOption = []; + if ( + object.messageSetWireFormat !== undefined && + object.messageSetWireFormat !== null + ) { + message.messageSetWireFormat = object.messageSetWireFormat; + } else { + message.messageSetWireFormat = false; + } + if ( + object.noStandardDescriptorAccessor !== undefined && + object.noStandardDescriptorAccessor !== null + ) { + message.noStandardDescriptorAccessor = + object.noStandardDescriptorAccessor; + } else { + message.noStandardDescriptorAccessor = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if (object.mapEntry !== undefined && object.mapEntry !== null) { + message.mapEntry = object.mapEntry; + } else { + message.mapEntry = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseFieldOptions: object = { + ctype: 0, + packed: false, + jstype: 0, + lazy: false, + deprecated: false, + weak: false, +}; + +export const FieldOptions = { + encode(message: FieldOptions, writer: Writer = Writer.create()): Writer { + if (message.ctype !== 0) { + writer.uint32(8).int32(message.ctype); + } + if (message.packed === true) { + writer.uint32(16).bool(message.packed); + } + if (message.jstype !== 0) { + writer.uint32(48).int32(message.jstype); + } + if (message.lazy === true) { + writer.uint32(40).bool(message.lazy); + } + if (message.deprecated === true) { + writer.uint32(24).bool(message.deprecated); + } + if (message.weak === true) { + writer.uint32(80).bool(message.weak); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FieldOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFieldOptions } as FieldOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.ctype = reader.int32() as any; + break; + case 2: + message.packed = reader.bool(); + break; + case 6: + message.jstype = reader.int32() as any; + break; + case 5: + message.lazy = reader.bool(); + break; + case 3: + message.deprecated = reader.bool(); + break; + case 10: + message.weak = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FieldOptions { + const message = { ...baseFieldOptions } as FieldOptions; + message.uninterpretedOption = []; + if (object.ctype !== undefined && object.ctype !== null) { + message.ctype = fieldOptions_CTypeFromJSON(object.ctype); + } else { + message.ctype = 0; + } + if (object.packed !== undefined && object.packed !== null) { + message.packed = Boolean(object.packed); + } else { + message.packed = false; + } + if (object.jstype !== undefined && object.jstype !== null) { + message.jstype = fieldOptions_JSTypeFromJSON(object.jstype); + } else { + message.jstype = 0; + } + if (object.lazy !== undefined && object.lazy !== null) { + message.lazy = Boolean(object.lazy); + } else { + message.lazy = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if (object.weak !== undefined && object.weak !== null) { + message.weak = Boolean(object.weak); + } else { + message.weak = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: FieldOptions): unknown { + const obj: any = {}; + message.ctype !== undefined && + (obj.ctype = fieldOptions_CTypeToJSON(message.ctype)); + message.packed !== undefined && (obj.packed = message.packed); + message.jstype !== undefined && + (obj.jstype = fieldOptions_JSTypeToJSON(message.jstype)); + message.lazy !== undefined && (obj.lazy = message.lazy); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.weak !== undefined && (obj.weak = message.weak); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): FieldOptions { + const message = { ...baseFieldOptions } as FieldOptions; + message.uninterpretedOption = []; + if (object.ctype !== undefined && object.ctype !== null) { + message.ctype = object.ctype; + } else { + message.ctype = 0; + } + if (object.packed !== undefined && object.packed !== null) { + message.packed = object.packed; + } else { + message.packed = false; + } + if (object.jstype !== undefined && object.jstype !== null) { + message.jstype = object.jstype; + } else { + message.jstype = 0; + } + if (object.lazy !== undefined && object.lazy !== null) { + message.lazy = object.lazy; + } else { + message.lazy = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if (object.weak !== undefined && object.weak !== null) { + message.weak = object.weak; + } else { + message.weak = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseOneofOptions: object = {}; + +export const OneofOptions = { + encode(message: OneofOptions, writer: Writer = Writer.create()): Writer { + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): OneofOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseOneofOptions } as OneofOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): OneofOptions { + const message = { ...baseOneofOptions } as OneofOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: OneofOptions): unknown { + const obj: any = {}; + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): OneofOptions { + const message = { ...baseOneofOptions } as OneofOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseEnumOptions: object = { allowAlias: false, deprecated: false }; + +export const EnumOptions = { + encode(message: EnumOptions, writer: Writer = Writer.create()): Writer { + if (message.allowAlias === true) { + writer.uint32(16).bool(message.allowAlias); + } + if (message.deprecated === true) { + writer.uint32(24).bool(message.deprecated); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): EnumOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseEnumOptions } as EnumOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + message.allowAlias = reader.bool(); + break; + case 3: + message.deprecated = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumOptions { + const message = { ...baseEnumOptions } as EnumOptions; + message.uninterpretedOption = []; + if (object.allowAlias !== undefined && object.allowAlias !== null) { + message.allowAlias = Boolean(object.allowAlias); + } else { + message.allowAlias = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: EnumOptions): unknown { + const obj: any = {}; + message.allowAlias !== undefined && (obj.allowAlias = message.allowAlias); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): EnumOptions { + const message = { ...baseEnumOptions } as EnumOptions; + message.uninterpretedOption = []; + if (object.allowAlias !== undefined && object.allowAlias !== null) { + message.allowAlias = object.allowAlias; + } else { + message.allowAlias = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseEnumValueOptions: object = { deprecated: false }; + +export const EnumValueOptions = { + encode(message: EnumValueOptions, writer: Writer = Writer.create()): Writer { + if (message.deprecated === true) { + writer.uint32(8).bool(message.deprecated); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): EnumValueOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseEnumValueOptions } as EnumValueOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.deprecated = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumValueOptions { + const message = { ...baseEnumValueOptions } as EnumValueOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: EnumValueOptions): unknown { + const obj: any = {}; + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): EnumValueOptions { + const message = { ...baseEnumValueOptions } as EnumValueOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseServiceOptions: object = { deprecated: false }; + +export const ServiceOptions = { + encode(message: ServiceOptions, writer: Writer = Writer.create()): Writer { + if (message.deprecated === true) { + writer.uint32(264).bool(message.deprecated); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ServiceOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseServiceOptions } as ServiceOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 33: + message.deprecated = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ServiceOptions { + const message = { ...baseServiceOptions } as ServiceOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: ServiceOptions): unknown { + const obj: any = {}; + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): ServiceOptions { + const message = { ...baseServiceOptions } as ServiceOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseMethodOptions: object = { deprecated: false, idempotencyLevel: 0 }; + +export const MethodOptions = { + encode(message: MethodOptions, writer: Writer = Writer.create()): Writer { + if (message.deprecated === true) { + writer.uint32(264).bool(message.deprecated); + } + if (message.idempotencyLevel !== 0) { + writer.uint32(272).int32(message.idempotencyLevel); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MethodOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMethodOptions } as MethodOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 33: + message.deprecated = reader.bool(); + break; + case 34: + message.idempotencyLevel = reader.int32() as any; + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MethodOptions { + const message = { ...baseMethodOptions } as MethodOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.idempotencyLevel !== undefined && + object.idempotencyLevel !== null + ) { + message.idempotencyLevel = methodOptions_IdempotencyLevelFromJSON( + object.idempotencyLevel + ); + } else { + message.idempotencyLevel = 0; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: MethodOptions): unknown { + const obj: any = {}; + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.idempotencyLevel !== undefined && + (obj.idempotencyLevel = methodOptions_IdempotencyLevelToJSON( + message.idempotencyLevel + )); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): MethodOptions { + const message = { ...baseMethodOptions } as MethodOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.idempotencyLevel !== undefined && + object.idempotencyLevel !== null + ) { + message.idempotencyLevel = object.idempotencyLevel; + } else { + message.idempotencyLevel = 0; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseUninterpretedOption: object = { + identifierValue: "", + positiveIntValue: 0, + negativeIntValue: 0, + doubleValue: 0, + aggregateValue: "", +}; + +export const UninterpretedOption = { + encode( + message: UninterpretedOption, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.name) { + UninterpretedOption_NamePart.encode( + v!, + writer.uint32(18).fork() + ).ldelim(); + } + if (message.identifierValue !== "") { + writer.uint32(26).string(message.identifierValue); + } + if (message.positiveIntValue !== 0) { + writer.uint32(32).uint64(message.positiveIntValue); + } + if (message.negativeIntValue !== 0) { + writer.uint32(40).int64(message.negativeIntValue); + } + if (message.doubleValue !== 0) { + writer.uint32(49).double(message.doubleValue); + } + if (message.stringValue.length !== 0) { + writer.uint32(58).bytes(message.stringValue); + } + if (message.aggregateValue !== "") { + writer.uint32(66).string(message.aggregateValue); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): UninterpretedOption { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseUninterpretedOption } as UninterpretedOption; + message.name = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + message.name.push( + UninterpretedOption_NamePart.decode(reader, reader.uint32()) + ); + break; + case 3: + message.identifierValue = reader.string(); + break; + case 4: + message.positiveIntValue = longToNumber(reader.uint64() as Long); + break; + case 5: + message.negativeIntValue = longToNumber(reader.int64() as Long); + break; + case 6: + message.doubleValue = reader.double(); + break; + case 7: + message.stringValue = reader.bytes(); + break; + case 8: + message.aggregateValue = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): UninterpretedOption { + const message = { ...baseUninterpretedOption } as UninterpretedOption; + message.name = []; + if (object.name !== undefined && object.name !== null) { + for (const e of object.name) { + message.name.push(UninterpretedOption_NamePart.fromJSON(e)); + } + } + if ( + object.identifierValue !== undefined && + object.identifierValue !== null + ) { + message.identifierValue = String(object.identifierValue); + } else { + message.identifierValue = ""; + } + if ( + object.positiveIntValue !== undefined && + object.positiveIntValue !== null + ) { + message.positiveIntValue = Number(object.positiveIntValue); + } else { + message.positiveIntValue = 0; + } + if ( + object.negativeIntValue !== undefined && + object.negativeIntValue !== null + ) { + message.negativeIntValue = Number(object.negativeIntValue); + } else { + message.negativeIntValue = 0; + } + if (object.doubleValue !== undefined && object.doubleValue !== null) { + message.doubleValue = Number(object.doubleValue); + } else { + message.doubleValue = 0; + } + if (object.stringValue !== undefined && object.stringValue !== null) { + message.stringValue = bytesFromBase64(object.stringValue); + } + if (object.aggregateValue !== undefined && object.aggregateValue !== null) { + message.aggregateValue = String(object.aggregateValue); + } else { + message.aggregateValue = ""; + } + return message; + }, + + toJSON(message: UninterpretedOption): unknown { + const obj: any = {}; + if (message.name) { + obj.name = message.name.map((e) => + e ? UninterpretedOption_NamePart.toJSON(e) : undefined + ); + } else { + obj.name = []; + } + message.identifierValue !== undefined && + (obj.identifierValue = message.identifierValue); + message.positiveIntValue !== undefined && + (obj.positiveIntValue = message.positiveIntValue); + message.negativeIntValue !== undefined && + (obj.negativeIntValue = message.negativeIntValue); + message.doubleValue !== undefined && + (obj.doubleValue = message.doubleValue); + message.stringValue !== undefined && + (obj.stringValue = base64FromBytes( + message.stringValue !== undefined + ? message.stringValue + : new Uint8Array() + )); + message.aggregateValue !== undefined && + (obj.aggregateValue = message.aggregateValue); + return obj; + }, + + fromPartial(object: DeepPartial): UninterpretedOption { + const message = { ...baseUninterpretedOption } as UninterpretedOption; + message.name = []; + if (object.name !== undefined && object.name !== null) { + for (const e of object.name) { + message.name.push(UninterpretedOption_NamePart.fromPartial(e)); + } + } + if ( + object.identifierValue !== undefined && + object.identifierValue !== null + ) { + message.identifierValue = object.identifierValue; + } else { + message.identifierValue = ""; + } + if ( + object.positiveIntValue !== undefined && + object.positiveIntValue !== null + ) { + message.positiveIntValue = object.positiveIntValue; + } else { + message.positiveIntValue = 0; + } + if ( + object.negativeIntValue !== undefined && + object.negativeIntValue !== null + ) { + message.negativeIntValue = object.negativeIntValue; + } else { + message.negativeIntValue = 0; + } + if (object.doubleValue !== undefined && object.doubleValue !== null) { + message.doubleValue = object.doubleValue; + } else { + message.doubleValue = 0; + } + if (object.stringValue !== undefined && object.stringValue !== null) { + message.stringValue = object.stringValue; + } else { + message.stringValue = new Uint8Array(); + } + if (object.aggregateValue !== undefined && object.aggregateValue !== null) { + message.aggregateValue = object.aggregateValue; + } else { + message.aggregateValue = ""; + } + return message; + }, +}; + +const baseUninterpretedOption_NamePart: object = { + namePart: "", + isExtension: false, +}; + +export const UninterpretedOption_NamePart = { + encode( + message: UninterpretedOption_NamePart, + writer: Writer = Writer.create() + ): Writer { + if (message.namePart !== "") { + writer.uint32(10).string(message.namePart); + } + if (message.isExtension === true) { + writer.uint32(16).bool(message.isExtension); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): UninterpretedOption_NamePart { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseUninterpretedOption_NamePart, + } as UninterpretedOption_NamePart; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.namePart = reader.string(); + break; + case 2: + message.isExtension = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): UninterpretedOption_NamePart { + const message = { + ...baseUninterpretedOption_NamePart, + } as UninterpretedOption_NamePart; + if (object.namePart !== undefined && object.namePart !== null) { + message.namePart = String(object.namePart); + } else { + message.namePart = ""; + } + if (object.isExtension !== undefined && object.isExtension !== null) { + message.isExtension = Boolean(object.isExtension); + } else { + message.isExtension = false; + } + return message; + }, + + toJSON(message: UninterpretedOption_NamePart): unknown { + const obj: any = {}; + message.namePart !== undefined && (obj.namePart = message.namePart); + message.isExtension !== undefined && + (obj.isExtension = message.isExtension); + return obj; + }, + + fromPartial( + object: DeepPartial + ): UninterpretedOption_NamePart { + const message = { + ...baseUninterpretedOption_NamePart, + } as UninterpretedOption_NamePart; + if (object.namePart !== undefined && object.namePart !== null) { + message.namePart = object.namePart; + } else { + message.namePart = ""; + } + if (object.isExtension !== undefined && object.isExtension !== null) { + message.isExtension = object.isExtension; + } else { + message.isExtension = false; + } + return message; + }, +}; + +const baseSourceCodeInfo: object = {}; + +export const SourceCodeInfo = { + encode(message: SourceCodeInfo, writer: Writer = Writer.create()): Writer { + for (const v of message.location) { + SourceCodeInfo_Location.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): SourceCodeInfo { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseSourceCodeInfo } as SourceCodeInfo; + message.location = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.location.push( + SourceCodeInfo_Location.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): SourceCodeInfo { + const message = { ...baseSourceCodeInfo } as SourceCodeInfo; + message.location = []; + if (object.location !== undefined && object.location !== null) { + for (const e of object.location) { + message.location.push(SourceCodeInfo_Location.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: SourceCodeInfo): unknown { + const obj: any = {}; + if (message.location) { + obj.location = message.location.map((e) => + e ? SourceCodeInfo_Location.toJSON(e) : undefined + ); + } else { + obj.location = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): SourceCodeInfo { + const message = { ...baseSourceCodeInfo } as SourceCodeInfo; + message.location = []; + if (object.location !== undefined && object.location !== null) { + for (const e of object.location) { + message.location.push(SourceCodeInfo_Location.fromPartial(e)); + } + } + return message; + }, +}; + +const baseSourceCodeInfo_Location: object = { + path: 0, + span: 0, + leadingComments: "", + trailingComments: "", + leadingDetachedComments: "", +}; + +export const SourceCodeInfo_Location = { + encode( + message: SourceCodeInfo_Location, + writer: Writer = Writer.create() + ): Writer { + writer.uint32(10).fork(); + for (const v of message.path) { + writer.int32(v); + } + writer.ldelim(); + writer.uint32(18).fork(); + for (const v of message.span) { + writer.int32(v); + } + writer.ldelim(); + if (message.leadingComments !== "") { + writer.uint32(26).string(message.leadingComments); + } + if (message.trailingComments !== "") { + writer.uint32(34).string(message.trailingComments); + } + for (const v of message.leadingDetachedComments) { + writer.uint32(50).string(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): SourceCodeInfo_Location { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseSourceCodeInfo_Location, + } as SourceCodeInfo_Location; + message.path = []; + message.span = []; + message.leadingDetachedComments = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.path.push(reader.int32()); + } + } else { + message.path.push(reader.int32()); + } + break; + case 2: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.span.push(reader.int32()); + } + } else { + message.span.push(reader.int32()); + } + break; + case 3: + message.leadingComments = reader.string(); + break; + case 4: + message.trailingComments = reader.string(); + break; + case 6: + message.leadingDetachedComments.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): SourceCodeInfo_Location { + const message = { + ...baseSourceCodeInfo_Location, + } as SourceCodeInfo_Location; + message.path = []; + message.span = []; + message.leadingDetachedComments = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(Number(e)); + } + } + if (object.span !== undefined && object.span !== null) { + for (const e of object.span) { + message.span.push(Number(e)); + } + } + if ( + object.leadingComments !== undefined && + object.leadingComments !== null + ) { + message.leadingComments = String(object.leadingComments); + } else { + message.leadingComments = ""; + } + if ( + object.trailingComments !== undefined && + object.trailingComments !== null + ) { + message.trailingComments = String(object.trailingComments); + } else { + message.trailingComments = ""; + } + if ( + object.leadingDetachedComments !== undefined && + object.leadingDetachedComments !== null + ) { + for (const e of object.leadingDetachedComments) { + message.leadingDetachedComments.push(String(e)); + } + } + return message; + }, + + toJSON(message: SourceCodeInfo_Location): unknown { + const obj: any = {}; + if (message.path) { + obj.path = message.path.map((e) => e); + } else { + obj.path = []; + } + if (message.span) { + obj.span = message.span.map((e) => e); + } else { + obj.span = []; + } + message.leadingComments !== undefined && + (obj.leadingComments = message.leadingComments); + message.trailingComments !== undefined && + (obj.trailingComments = message.trailingComments); + if (message.leadingDetachedComments) { + obj.leadingDetachedComments = message.leadingDetachedComments.map( + (e) => e + ); + } else { + obj.leadingDetachedComments = []; + } + return obj; + }, + + fromPartial( + object: DeepPartial + ): SourceCodeInfo_Location { + const message = { + ...baseSourceCodeInfo_Location, + } as SourceCodeInfo_Location; + message.path = []; + message.span = []; + message.leadingDetachedComments = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(e); + } + } + if (object.span !== undefined && object.span !== null) { + for (const e of object.span) { + message.span.push(e); + } + } + if ( + object.leadingComments !== undefined && + object.leadingComments !== null + ) { + message.leadingComments = object.leadingComments; + } else { + message.leadingComments = ""; + } + if ( + object.trailingComments !== undefined && + object.trailingComments !== null + ) { + message.trailingComments = object.trailingComments; + } else { + message.trailingComments = ""; + } + if ( + object.leadingDetachedComments !== undefined && + object.leadingDetachedComments !== null + ) { + for (const e of object.leadingDetachedComments) { + message.leadingDetachedComments.push(e); + } + } + return message; + }, +}; + +const baseGeneratedCodeInfo: object = {}; + +export const GeneratedCodeInfo = { + encode(message: GeneratedCodeInfo, writer: Writer = Writer.create()): Writer { + for (const v of message.annotation) { + GeneratedCodeInfo_Annotation.encode( + v!, + writer.uint32(10).fork() + ).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): GeneratedCodeInfo { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseGeneratedCodeInfo } as GeneratedCodeInfo; + message.annotation = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.annotation.push( + GeneratedCodeInfo_Annotation.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GeneratedCodeInfo { + const message = { ...baseGeneratedCodeInfo } as GeneratedCodeInfo; + message.annotation = []; + if (object.annotation !== undefined && object.annotation !== null) { + for (const e of object.annotation) { + message.annotation.push(GeneratedCodeInfo_Annotation.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: GeneratedCodeInfo): unknown { + const obj: any = {}; + if (message.annotation) { + obj.annotation = message.annotation.map((e) => + e ? GeneratedCodeInfo_Annotation.toJSON(e) : undefined + ); + } else { + obj.annotation = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): GeneratedCodeInfo { + const message = { ...baseGeneratedCodeInfo } as GeneratedCodeInfo; + message.annotation = []; + if (object.annotation !== undefined && object.annotation !== null) { + for (const e of object.annotation) { + message.annotation.push(GeneratedCodeInfo_Annotation.fromPartial(e)); + } + } + return message; + }, +}; + +const baseGeneratedCodeInfo_Annotation: object = { + path: 0, + sourceFile: "", + begin: 0, + end: 0, +}; + +export const GeneratedCodeInfo_Annotation = { + encode( + message: GeneratedCodeInfo_Annotation, + writer: Writer = Writer.create() + ): Writer { + writer.uint32(10).fork(); + for (const v of message.path) { + writer.int32(v); + } + writer.ldelim(); + if (message.sourceFile !== "") { + writer.uint32(18).string(message.sourceFile); + } + if (message.begin !== 0) { + writer.uint32(24).int32(message.begin); + } + if (message.end !== 0) { + writer.uint32(32).int32(message.end); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): GeneratedCodeInfo_Annotation { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseGeneratedCodeInfo_Annotation, + } as GeneratedCodeInfo_Annotation; + message.path = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.path.push(reader.int32()); + } + } else { + message.path.push(reader.int32()); + } + break; + case 2: + message.sourceFile = reader.string(); + break; + case 3: + message.begin = reader.int32(); + break; + case 4: + message.end = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GeneratedCodeInfo_Annotation { + const message = { + ...baseGeneratedCodeInfo_Annotation, + } as GeneratedCodeInfo_Annotation; + message.path = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(Number(e)); + } + } + if (object.sourceFile !== undefined && object.sourceFile !== null) { + message.sourceFile = String(object.sourceFile); + } else { + message.sourceFile = ""; + } + if (object.begin !== undefined && object.begin !== null) { + message.begin = Number(object.begin); + } else { + message.begin = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + return message; + }, + + toJSON(message: GeneratedCodeInfo_Annotation): unknown { + const obj: any = {}; + if (message.path) { + obj.path = message.path.map((e) => e); + } else { + obj.path = []; + } + message.sourceFile !== undefined && (obj.sourceFile = message.sourceFile); + message.begin !== undefined && (obj.begin = message.begin); + message.end !== undefined && (obj.end = message.end); + return obj; + }, + + fromPartial( + object: DeepPartial + ): GeneratedCodeInfo_Annotation { + const message = { + ...baseGeneratedCodeInfo_Annotation, + } as GeneratedCodeInfo_Annotation; + message.path = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(e); + } + } + if (object.sourceFile !== undefined && object.sourceFile !== null) { + message.sourceFile = object.sourceFile; + } else { + message.sourceFile = ""; + } + if (object.begin !== undefined && object.begin !== null) { + message.begin = object.begin; + } else { + message.begin = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/cosmos.distribution.v1beta1/index.ts b/ts-client/cosmos.distribution.v1beta1/index.ts new file mode 100755 index 00000000..c9dfa159 --- /dev/null +++ b/ts-client/cosmos.distribution.v1beta1/index.ts @@ -0,0 +1,6 @@ +import Module from './module'; +import { txClient, queryClient, registry } from './module'; +import { msgTypes } from './registry'; + +export * from "./types"; +export { Module, msgTypes, txClient, queryClient, registry }; diff --git a/ts-client/cosmos.distribution.v1beta1/module.ts b/ts-client/cosmos.distribution.v1beta1/module.ts new file mode 100755 index 00000000..4e33e8f1 --- /dev/null +++ b/ts-client/cosmos.distribution.v1beta1/module.ts @@ -0,0 +1,198 @@ +// Generated by Ignite ignite.com/cli + +import { StdFee } from "@cosmjs/launchpad"; +import { SigningStargateClient, DeliverTxResponse } from "@cosmjs/stargate"; +import { EncodeObject, GeneratedType, OfflineSigner, Registry } from "@cosmjs/proto-signing"; +import { msgTypes } from './registry'; +import { IgniteClient } from "../client" +import { MissingWalletError } from "../helpers" +import { Api } from "./rest"; +import { MsgFundCommunityPool } from "./types/cosmos/distribution/v1beta1/tx"; +import { MsgWithdrawDelegatorReward } from "./types/cosmos/distribution/v1beta1/tx"; +import { MsgSetWithdrawAddress } from "./types/cosmos/distribution/v1beta1/tx"; +import { MsgWithdrawValidatorCommission } from "./types/cosmos/distribution/v1beta1/tx"; + + +export { MsgFundCommunityPool, MsgWithdrawDelegatorReward, MsgSetWithdrawAddress, MsgWithdrawValidatorCommission }; + +type sendMsgFundCommunityPoolParams = { + value: MsgFundCommunityPool, + fee?: StdFee, + memo?: string +}; + +type sendMsgWithdrawDelegatorRewardParams = { + value: MsgWithdrawDelegatorReward, + fee?: StdFee, + memo?: string +}; + +type sendMsgSetWithdrawAddressParams = { + value: MsgSetWithdrawAddress, + fee?: StdFee, + memo?: string +}; + +type sendMsgWithdrawValidatorCommissionParams = { + value: MsgWithdrawValidatorCommission, + fee?: StdFee, + memo?: string +}; + + +type msgFundCommunityPoolParams = { + value: MsgFundCommunityPool, +}; + +type msgWithdrawDelegatorRewardParams = { + value: MsgWithdrawDelegatorReward, +}; + +type msgSetWithdrawAddressParams = { + value: MsgSetWithdrawAddress, +}; + +type msgWithdrawValidatorCommissionParams = { + value: MsgWithdrawValidatorCommission, +}; + + +export const registry = new Registry(msgTypes); + +const defaultFee = { + amount: [], + gas: "200000", +}; + +interface TxClientOptions { + addr: string + prefix: string + signer?: OfflineSigner +} + +export const txClient = ({ signer, prefix, addr }: TxClientOptions = { addr: "http://localhost:26657", prefix: "cosmos" }) => { + + return { + + async sendMsgFundCommunityPool({ value, fee, memo }: sendMsgFundCommunityPoolParams): Promise { + if (!signer) { + throw new Error('TxClient:sendMsgFundCommunityPool: Unable to sign Tx. Signer is not present.') + } + try { + const { address } = (await signer.getAccounts())[0]; + const signingClient = await SigningStargateClient.connectWithSigner(addr,signer,{registry, prefix}); + let msg = this.msgFundCommunityPool({ value: MsgFundCommunityPool.fromPartial(value) }) + return await signingClient.signAndBroadcast(address, [msg], fee ? fee : defaultFee, memo) + } catch (e: any) { + throw new Error('TxClient:sendMsgFundCommunityPool: Could not broadcast Tx: '+ e.message) + } + }, + + async sendMsgWithdrawDelegatorReward({ value, fee, memo }: sendMsgWithdrawDelegatorRewardParams): Promise { + if (!signer) { + throw new Error('TxClient:sendMsgWithdrawDelegatorReward: Unable to sign Tx. Signer is not present.') + } + try { + const { address } = (await signer.getAccounts())[0]; + const signingClient = await SigningStargateClient.connectWithSigner(addr,signer,{registry, prefix}); + let msg = this.msgWithdrawDelegatorReward({ value: MsgWithdrawDelegatorReward.fromPartial(value) }) + return await signingClient.signAndBroadcast(address, [msg], fee ? fee : defaultFee, memo) + } catch (e: any) { + throw new Error('TxClient:sendMsgWithdrawDelegatorReward: Could not broadcast Tx: '+ e.message) + } + }, + + async sendMsgSetWithdrawAddress({ value, fee, memo }: sendMsgSetWithdrawAddressParams): Promise { + if (!signer) { + throw new Error('TxClient:sendMsgSetWithdrawAddress: Unable to sign Tx. Signer is not present.') + } + try { + const { address } = (await signer.getAccounts())[0]; + const signingClient = await SigningStargateClient.connectWithSigner(addr,signer,{registry, prefix}); + let msg = this.msgSetWithdrawAddress({ value: MsgSetWithdrawAddress.fromPartial(value) }) + return await signingClient.signAndBroadcast(address, [msg], fee ? fee : defaultFee, memo) + } catch (e: any) { + throw new Error('TxClient:sendMsgSetWithdrawAddress: Could not broadcast Tx: '+ e.message) + } + }, + + async sendMsgWithdrawValidatorCommission({ value, fee, memo }: sendMsgWithdrawValidatorCommissionParams): Promise { + if (!signer) { + throw new Error('TxClient:sendMsgWithdrawValidatorCommission: Unable to sign Tx. Signer is not present.') + } + try { + const { address } = (await signer.getAccounts())[0]; + const signingClient = await SigningStargateClient.connectWithSigner(addr,signer,{registry, prefix}); + let msg = this.msgWithdrawValidatorCommission({ value: MsgWithdrawValidatorCommission.fromPartial(value) }) + return await signingClient.signAndBroadcast(address, [msg], fee ? fee : defaultFee, memo) + } catch (e: any) { + throw new Error('TxClient:sendMsgWithdrawValidatorCommission: Could not broadcast Tx: '+ e.message) + } + }, + + + msgFundCommunityPool({ value }: msgFundCommunityPoolParams): EncodeObject { + try { + return { typeUrl: "/cosmos.distribution.v1beta1.MsgFundCommunityPool", value: MsgFundCommunityPool.fromPartial( value ) } + } catch (e: any) { + throw new Error('TxClient:MsgFundCommunityPool: Could not create message: ' + e.message) + } + }, + + msgWithdrawDelegatorReward({ value }: msgWithdrawDelegatorRewardParams): EncodeObject { + try { + return { typeUrl: "/cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward", value: MsgWithdrawDelegatorReward.fromPartial( value ) } + } catch (e: any) { + throw new Error('TxClient:MsgWithdrawDelegatorReward: Could not create message: ' + e.message) + } + }, + + msgSetWithdrawAddress({ value }: msgSetWithdrawAddressParams): EncodeObject { + try { + return { typeUrl: "/cosmos.distribution.v1beta1.MsgSetWithdrawAddress", value: MsgSetWithdrawAddress.fromPartial( value ) } + } catch (e: any) { + throw new Error('TxClient:MsgSetWithdrawAddress: Could not create message: ' + e.message) + } + }, + + msgWithdrawValidatorCommission({ value }: msgWithdrawValidatorCommissionParams): EncodeObject { + try { + return { typeUrl: "/cosmos.distribution.v1beta1.MsgWithdrawValidatorCommission", value: MsgWithdrawValidatorCommission.fromPartial( value ) } + } catch (e: any) { + throw new Error('TxClient:MsgWithdrawValidatorCommission: Could not create message: ' + e.message) + } + }, + + } +}; + +interface QueryClientOptions { + addr: string +} + +export const queryClient = ({ addr: addr }: QueryClientOptions = { addr: "http://localhost:1317" }) => { + return new Api({ baseUrl: addr }); +}; + +class SDKModule { + public query: ReturnType; + public tx: ReturnType; + + public registry: Array<[string, GeneratedType]>; + + constructor(client: IgniteClient) { + + this.query = queryClient({ addr: client.env.apiURL }); + this.tx = txClient({ signer: client.signer, addr: client.env.rpcURL, prefix: client.env.prefix ?? "cosmos" }); + } +}; + +const Module = (test: IgniteClient) => { + return { + module: { + CosmosDistributionV1Beta1: new SDKModule(test) + }, + registry: msgTypes + } +} +export default Module; \ No newline at end of file diff --git a/ts-client/cosmos.distribution.v1beta1/registry.ts b/ts-client/cosmos.distribution.v1beta1/registry.ts new file mode 100755 index 00000000..d2b3b85b --- /dev/null +++ b/ts-client/cosmos.distribution.v1beta1/registry.ts @@ -0,0 +1,15 @@ +import { GeneratedType } from "@cosmjs/proto-signing"; +import { MsgFundCommunityPool } from "./types/cosmos/distribution/v1beta1/tx"; +import { MsgWithdrawDelegatorReward } from "./types/cosmos/distribution/v1beta1/tx"; +import { MsgSetWithdrawAddress } from "./types/cosmos/distribution/v1beta1/tx"; +import { MsgWithdrawValidatorCommission } from "./types/cosmos/distribution/v1beta1/tx"; + +const msgTypes: Array<[string, GeneratedType]> = [ + ["/cosmos.distribution.v1beta1.MsgFundCommunityPool", MsgFundCommunityPool], + ["/cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward", MsgWithdrawDelegatorReward], + ["/cosmos.distribution.v1beta1.MsgSetWithdrawAddress", MsgSetWithdrawAddress], + ["/cosmos.distribution.v1beta1.MsgWithdrawValidatorCommission", MsgWithdrawValidatorCommission], + +]; + +export { msgTypes } \ No newline at end of file diff --git a/ts-client/cosmos.distribution.v1beta1/rest.ts b/ts-client/cosmos.distribution.v1beta1/rest.ts new file mode 100644 index 00000000..6e88af52 --- /dev/null +++ b/ts-client/cosmos.distribution.v1beta1/rest.ts @@ -0,0 +1,613 @@ +/* eslint-disable */ +/* tslint:disable */ +/* + * --------------------------------------------------------------- + * ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ## + * ## ## + * ## AUTHOR: acacode ## + * ## SOURCE: https://github.com/acacode/swagger-typescript-api ## + * --------------------------------------------------------------- + */ + +/** + * Params defines the set of params for the distribution module. + */ +export interface Distributionv1Beta1Params { + community_tax?: string; + base_proposer_reward?: string; + bonus_proposer_reward?: string; + withdraw_addr_enabled?: boolean; +} + +/** +* ValidatorOutstandingRewards represents outstanding (un-withdrawn) rewards +for a validator inexpensive to track, allows simple sanity checks. +*/ +export interface Distributionv1Beta1ValidatorOutstandingRewards { + rewards?: V1Beta1DecCoin[]; +} + +export interface ProtobufAny { + "@type"?: string; +} + +export interface RpcStatus { + /** @format int32 */ + code?: number; + message?: string; + details?: ProtobufAny[]; +} + +/** +* Coin defines a token with a denomination and an amount. + +NOTE: The amount field is an Int which implements the custom method +signatures required by gogoproto. +*/ +export interface V1Beta1Coin { + denom?: string; + amount?: string; +} + +/** +* DecCoin defines a token with a denomination and a decimal amount. + +NOTE: The amount field is an Dec which implements the custom method +signatures required by gogoproto. +*/ +export interface V1Beta1DecCoin { + denom?: string; + amount?: string; +} + +/** +* DelegationDelegatorReward represents the properties +of a delegator's delegation reward. +*/ +export interface V1Beta1DelegationDelegatorReward { + validator_address?: string; + reward?: V1Beta1DecCoin[]; +} + +/** + * MsgFundCommunityPoolResponse defines the Msg/FundCommunityPool response type. + */ +export type V1Beta1MsgFundCommunityPoolResponse = object; + +/** + * MsgSetWithdrawAddressResponse defines the Msg/SetWithdrawAddress response type. + */ +export type V1Beta1MsgSetWithdrawAddressResponse = object; + +/** + * MsgWithdrawDelegatorRewardResponse defines the Msg/WithdrawDelegatorReward response type. + */ +export type V1Beta1MsgWithdrawDelegatorRewardResponse = object; + +/** + * MsgWithdrawValidatorCommissionResponse defines the Msg/WithdrawValidatorCommission response type. + */ +export type V1Beta1MsgWithdrawValidatorCommissionResponse = object; + +/** +* message SomeRequest { + Foo some_parameter = 1; + PageRequest pagination = 2; + } +*/ +export interface V1Beta1PageRequest { + /** + * key is a value returned in PageResponse.next_key to begin + * querying the next page most efficiently. Only one of offset or key + * should be set. + * @format byte + */ + key?: string; + + /** + * offset is a numeric offset that can be used when key is unavailable. + * It is less efficient than using key. Only one of offset or key should + * be set. + * @format uint64 + */ + offset?: string; + + /** + * limit is the total number of results to be returned in the result page. + * If left empty it will default to a value to be set by each app. + * @format uint64 + */ + limit?: string; + + /** + * count_total is set to true to indicate that the result set should include + * a count of the total number of items available for pagination in UIs. + * count_total is only respected when offset is used. It is ignored when key + * is set. + */ + count_total?: boolean; + + /** + * reverse is set to true if results are to be returned in the descending order. + * + * Since: cosmos-sdk 0.43 + */ + reverse?: boolean; +} + +/** +* PageResponse is to be embedded in gRPC response messages where the +corresponding request message has used PageRequest. + + message SomeResponse { + repeated Bar results = 1; + PageResponse page = 2; + } +*/ +export interface V1Beta1PageResponse { + /** @format byte */ + next_key?: string; + + /** @format uint64 */ + total?: string; +} + +/** +* QueryCommunityPoolResponse is the response type for the Query/CommunityPool +RPC method. +*/ +export interface V1Beta1QueryCommunityPoolResponse { + /** pool defines community pool's coins. */ + pool?: V1Beta1DecCoin[]; +} + +/** +* QueryDelegationRewardsResponse is the response type for the +Query/DelegationRewards RPC method. +*/ +export interface V1Beta1QueryDelegationRewardsResponse { + /** rewards defines the rewards accrued by a delegation. */ + rewards?: V1Beta1DecCoin[]; +} + +/** +* QueryDelegationTotalRewardsResponse is the response type for the +Query/DelegationTotalRewards RPC method. +*/ +export interface V1Beta1QueryDelegationTotalRewardsResponse { + /** rewards defines all the rewards accrued by a delegator. */ + rewards?: V1Beta1DelegationDelegatorReward[]; + + /** total defines the sum of all the rewards. */ + total?: V1Beta1DecCoin[]; +} + +/** +* QueryDelegatorValidatorsResponse is the response type for the +Query/DelegatorValidators RPC method. +*/ +export interface V1Beta1QueryDelegatorValidatorsResponse { + /** validators defines the validators a delegator is delegating for. */ + validators?: string[]; +} + +/** +* QueryDelegatorWithdrawAddressResponse is the response type for the +Query/DelegatorWithdrawAddress RPC method. +*/ +export interface V1Beta1QueryDelegatorWithdrawAddressResponse { + /** withdraw_address defines the delegator address to query for. */ + withdraw_address?: string; +} + +/** + * QueryParamsResponse is the response type for the Query/Params RPC method. + */ +export interface V1Beta1QueryParamsResponse { + /** params defines the parameters of the module. */ + params?: Distributionv1Beta1Params; +} + +export interface V1Beta1QueryValidatorCommissionResponse { + /** commission defines the commision the validator received. */ + commission?: V1Beta1ValidatorAccumulatedCommission; +} + +/** +* QueryValidatorOutstandingRewardsResponse is the response type for the +Query/ValidatorOutstandingRewards RPC method. +*/ +export interface V1Beta1QueryValidatorOutstandingRewardsResponse { + /** + * ValidatorOutstandingRewards represents outstanding (un-withdrawn) rewards + * for a validator inexpensive to track, allows simple sanity checks. + */ + rewards?: Distributionv1Beta1ValidatorOutstandingRewards; +} + +/** +* QueryValidatorSlashesResponse is the response type for the +Query/ValidatorSlashes RPC method. +*/ +export interface V1Beta1QueryValidatorSlashesResponse { + /** slashes defines the slashes the validator received. */ + slashes?: V1Beta1ValidatorSlashEvent[]; + + /** pagination defines the pagination in the response. */ + pagination?: V1Beta1PageResponse; +} + +/** +* ValidatorAccumulatedCommission represents accumulated commission +for a validator kept as a running counter, can be withdrawn at any time. +*/ +export interface V1Beta1ValidatorAccumulatedCommission { + commission?: V1Beta1DecCoin[]; +} + +/** +* ValidatorSlashEvent represents a validator slash event. +Height is implicit within the store key. +This is needed to calculate appropriate amount of staking tokens +for delegations which are withdrawn after a slash has occurred. +*/ +export interface V1Beta1ValidatorSlashEvent { + /** @format uint64 */ + validator_period?: string; + fraction?: string; +} + +export type QueryParamsType = Record; +export type ResponseFormat = keyof Omit; + +export interface FullRequestParams extends Omit { + /** set parameter to `true` for call `securityWorker` for this request */ + secure?: boolean; + /** request path */ + path: string; + /** content type of request body */ + type?: ContentType; + /** query params */ + query?: QueryParamsType; + /** format of response (i.e. response.json() -> format: "json") */ + format?: keyof Omit; + /** request body */ + body?: unknown; + /** base url */ + baseUrl?: string; + /** request cancellation token */ + cancelToken?: CancelToken; +} + +export type RequestParams = Omit; + +export interface ApiConfig { + baseUrl?: string; + baseApiParams?: Omit; + securityWorker?: (securityData: SecurityDataType) => RequestParams | void; +} + +export interface HttpResponse extends Response { + data: D; + error: E; +} + +type CancelToken = Symbol | string | number; + +export enum ContentType { + Json = "application/json", + FormData = "multipart/form-data", + UrlEncoded = "application/x-www-form-urlencoded", +} + +export class HttpClient { + public baseUrl: string = ""; + private securityData: SecurityDataType = null as any; + private securityWorker: null | ApiConfig["securityWorker"] = null; + private abortControllers = new Map(); + + private baseApiParams: RequestParams = { + credentials: "same-origin", + headers: {}, + redirect: "follow", + referrerPolicy: "no-referrer", + }; + + constructor(apiConfig: ApiConfig = {}) { + Object.assign(this, apiConfig); + } + + public setSecurityData = (data: SecurityDataType) => { + this.securityData = data; + }; + + private addQueryParam(query: QueryParamsType, key: string) { + const value = query[key]; + + return ( + encodeURIComponent(key) + + "=" + + encodeURIComponent(Array.isArray(value) ? value.join(",") : typeof value === "number" ? value : `${value}`) + ); + } + + protected toQueryString(rawQuery?: QueryParamsType): string { + const query = rawQuery || {}; + const keys = Object.keys(query).filter((key) => "undefined" !== typeof query[key]); + return keys + .map((key) => + typeof query[key] === "object" && !Array.isArray(query[key]) + ? this.toQueryString(query[key] as QueryParamsType) + : this.addQueryParam(query, key), + ) + .join("&"); + } + + protected addQueryParams(rawQuery?: QueryParamsType): string { + const queryString = this.toQueryString(rawQuery); + return queryString ? `?${queryString}` : ""; + } + + private contentFormatters: Record any> = { + [ContentType.Json]: (input: any) => + input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input, + [ContentType.FormData]: (input: any) => + Object.keys(input || {}).reduce((data, key) => { + data.append(key, input[key]); + return data; + }, new FormData()), + [ContentType.UrlEncoded]: (input: any) => this.toQueryString(input), + }; + + private mergeRequestParams(params1: RequestParams, params2?: RequestParams): RequestParams { + return { + ...this.baseApiParams, + ...params1, + ...(params2 || {}), + headers: { + ...(this.baseApiParams.headers || {}), + ...(params1.headers || {}), + ...((params2 && params2.headers) || {}), + }, + }; + } + + private createAbortSignal = (cancelToken: CancelToken): AbortSignal | undefined => { + if (this.abortControllers.has(cancelToken)) { + const abortController = this.abortControllers.get(cancelToken); + if (abortController) { + return abortController.signal; + } + return void 0; + } + + const abortController = new AbortController(); + this.abortControllers.set(cancelToken, abortController); + return abortController.signal; + }; + + public abortRequest = (cancelToken: CancelToken) => { + const abortController = this.abortControllers.get(cancelToken); + + if (abortController) { + abortController.abort(); + this.abortControllers.delete(cancelToken); + } + }; + + public request = ({ + body, + secure, + path, + type, + query, + format = "json", + baseUrl, + cancelToken, + ...params + }: FullRequestParams): Promise> => { + const secureParams = (secure && this.securityWorker && this.securityWorker(this.securityData)) || {}; + const requestParams = this.mergeRequestParams(params, secureParams); + const queryString = query && this.toQueryString(query); + const payloadFormatter = this.contentFormatters[type || ContentType.Json]; + + return fetch(`${baseUrl || this.baseUrl || ""}${path}${queryString ? `?${queryString}` : ""}`, { + ...requestParams, + headers: { + ...(type && type !== ContentType.FormData ? { "Content-Type": type } : {}), + ...(requestParams.headers || {}), + }, + signal: cancelToken ? this.createAbortSignal(cancelToken) : void 0, + body: typeof body === "undefined" || body === null ? null : payloadFormatter(body), + }).then(async (response) => { + const r = response as HttpResponse; + r.data = (null as unknown) as T; + r.error = (null as unknown) as E; + + const data = await response[format]() + .then((data) => { + if (r.ok) { + r.data = data; + } else { + r.error = data; + } + return r; + }) + .catch((e) => { + r.error = e; + return r; + }); + + if (cancelToken) { + this.abortControllers.delete(cancelToken); + } + + if (!response.ok) throw data; + return data; + }); + }; +} + +/** + * @title cosmos/distribution/v1beta1/distribution.proto + * @version version not set + */ +export class Api extends HttpClient { + /** + * No description + * + * @tags Query + * @name QueryCommunityPool + * @summary CommunityPool queries the community pool coins. + * @request GET:/cosmos/distribution/v1beta1/community_pool + */ + queryCommunityPool = (params: RequestParams = {}) => + this.request({ + path: `/cosmos/distribution/v1beta1/community_pool`, + method: "GET", + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Query + * @name QueryDelegationTotalRewards + * @summary DelegationTotalRewards queries the total rewards accrued by a each +validator. + * @request GET:/cosmos/distribution/v1beta1/delegators/{delegator_address}/rewards + */ + queryDelegationTotalRewards = (delegator_address: string, params: RequestParams = {}) => + this.request({ + path: `/cosmos/distribution/v1beta1/delegators/${delegator_address}/rewards`, + method: "GET", + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Query + * @name QueryDelegationRewards + * @summary DelegationRewards queries the total rewards accrued by a delegation. + * @request GET:/cosmos/distribution/v1beta1/delegators/{delegator_address}/rewards/{validator_address} + */ + queryDelegationRewards = (delegator_address: string, validator_address: string, params: RequestParams = {}) => + this.request({ + path: `/cosmos/distribution/v1beta1/delegators/${delegator_address}/rewards/${validator_address}`, + method: "GET", + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Query + * @name QueryDelegatorValidators + * @summary DelegatorValidators queries the validators of a delegator. + * @request GET:/cosmos/distribution/v1beta1/delegators/{delegator_address}/validators + */ + queryDelegatorValidators = (delegator_address: string, params: RequestParams = {}) => + this.request({ + path: `/cosmos/distribution/v1beta1/delegators/${delegator_address}/validators`, + method: "GET", + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Query + * @name QueryDelegatorWithdrawAddress + * @summary DelegatorWithdrawAddress queries withdraw address of a delegator. + * @request GET:/cosmos/distribution/v1beta1/delegators/{delegator_address}/withdraw_address + */ + queryDelegatorWithdrawAddress = (delegator_address: string, params: RequestParams = {}) => + this.request({ + path: `/cosmos/distribution/v1beta1/delegators/${delegator_address}/withdraw_address`, + method: "GET", + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Query + * @name QueryParams + * @summary Params queries params of the distribution module. + * @request GET:/cosmos/distribution/v1beta1/params + */ + queryParams = (params: RequestParams = {}) => + this.request({ + path: `/cosmos/distribution/v1beta1/params`, + method: "GET", + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Query + * @name QueryValidatorCommission + * @summary ValidatorCommission queries accumulated commission for a validator. + * @request GET:/cosmos/distribution/v1beta1/validators/{validator_address}/commission + */ + queryValidatorCommission = (validator_address: string, params: RequestParams = {}) => + this.request({ + path: `/cosmos/distribution/v1beta1/validators/${validator_address}/commission`, + method: "GET", + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Query + * @name QueryValidatorOutstandingRewards + * @summary ValidatorOutstandingRewards queries rewards of a validator address. + * @request GET:/cosmos/distribution/v1beta1/validators/{validator_address}/outstanding_rewards + */ + queryValidatorOutstandingRewards = (validator_address: string, params: RequestParams = {}) => + this.request({ + path: `/cosmos/distribution/v1beta1/validators/${validator_address}/outstanding_rewards`, + method: "GET", + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Query + * @name QueryValidatorSlashes + * @summary ValidatorSlashes queries slash events of a validator. + * @request GET:/cosmos/distribution/v1beta1/validators/{validator_address}/slashes + */ + queryValidatorSlashes = ( + validator_address: string, + query?: { + starting_height?: string; + ending_height?: string; + "pagination.key"?: string; + "pagination.offset"?: string; + "pagination.limit"?: string; + "pagination.count_total"?: boolean; + "pagination.reverse"?: boolean; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/cosmos/distribution/v1beta1/validators/${validator_address}/slashes`, + method: "GET", + query: query, + format: "json", + ...params, + }); +} diff --git a/ts-client/cosmos.distribution.v1beta1/types.ts b/ts-client/cosmos.distribution.v1beta1/types.ts new file mode 100755 index 00000000..fe32173e --- /dev/null +++ b/ts-client/cosmos.distribution.v1beta1/types.ts @@ -0,0 +1,43 @@ +import { Params } from "./types/cosmos/distribution/v1beta1/distribution" +import { ValidatorHistoricalRewards } from "./types/cosmos/distribution/v1beta1/distribution" +import { ValidatorCurrentRewards } from "./types/cosmos/distribution/v1beta1/distribution" +import { ValidatorAccumulatedCommission } from "./types/cosmos/distribution/v1beta1/distribution" +import { ValidatorOutstandingRewards } from "./types/cosmos/distribution/v1beta1/distribution" +import { ValidatorSlashEvent } from "./types/cosmos/distribution/v1beta1/distribution" +import { ValidatorSlashEvents } from "./types/cosmos/distribution/v1beta1/distribution" +import { FeePool } from "./types/cosmos/distribution/v1beta1/distribution" +import { CommunityPoolSpendProposal } from "./types/cosmos/distribution/v1beta1/distribution" +import { DelegatorStartingInfo } from "./types/cosmos/distribution/v1beta1/distribution" +import { DelegationDelegatorReward } from "./types/cosmos/distribution/v1beta1/distribution" +import { CommunityPoolSpendProposalWithDeposit } from "./types/cosmos/distribution/v1beta1/distribution" +import { DelegatorWithdrawInfo } from "./types/cosmos/distribution/v1beta1/genesis" +import { ValidatorOutstandingRewardsRecord } from "./types/cosmos/distribution/v1beta1/genesis" +import { ValidatorAccumulatedCommissionRecord } from "./types/cosmos/distribution/v1beta1/genesis" +import { ValidatorHistoricalRewardsRecord } from "./types/cosmos/distribution/v1beta1/genesis" +import { ValidatorCurrentRewardsRecord } from "./types/cosmos/distribution/v1beta1/genesis" +import { DelegatorStartingInfoRecord } from "./types/cosmos/distribution/v1beta1/genesis" +import { ValidatorSlashEventRecord } from "./types/cosmos/distribution/v1beta1/genesis" + + +export { + Params, + ValidatorHistoricalRewards, + ValidatorCurrentRewards, + ValidatorAccumulatedCommission, + ValidatorOutstandingRewards, + ValidatorSlashEvent, + ValidatorSlashEvents, + FeePool, + CommunityPoolSpendProposal, + DelegatorStartingInfo, + DelegationDelegatorReward, + CommunityPoolSpendProposalWithDeposit, + DelegatorWithdrawInfo, + ValidatorOutstandingRewardsRecord, + ValidatorAccumulatedCommissionRecord, + ValidatorHistoricalRewardsRecord, + ValidatorCurrentRewardsRecord, + DelegatorStartingInfoRecord, + ValidatorSlashEventRecord, + + } \ No newline at end of file diff --git a/ts-client/cosmos.distribution.v1beta1/types/cosmos/base/query/v1beta1/pagination.ts b/ts-client/cosmos.distribution.v1beta1/types/cosmos/base/query/v1beta1/pagination.ts new file mode 100644 index 00000000..cd4b2d78 --- /dev/null +++ b/ts-client/cosmos.distribution.v1beta1/types/cosmos/base/query/v1beta1/pagination.ts @@ -0,0 +1,327 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "cosmos.base.query.v1beta1"; + +/** + * PageRequest is to be embedded in gRPC request messages for efficient + * pagination. Ex: + * + * message SomeRequest { + * Foo some_parameter = 1; + * PageRequest pagination = 2; + * } + */ +export interface PageRequest { + /** + * key is a value returned in PageResponse.next_key to begin + * querying the next page most efficiently. Only one of offset or key + * should be set. + */ + key: Uint8Array; + /** + * offset is a numeric offset that can be used when key is unavailable. + * It is less efficient than using key. Only one of offset or key should + * be set. + */ + offset: number; + /** + * limit is the total number of results to be returned in the result page. + * If left empty it will default to a value to be set by each app. + */ + limit: number; + /** + * count_total is set to true to indicate that the result set should include + * a count of the total number of items available for pagination in UIs. + * count_total is only respected when offset is used. It is ignored when key + * is set. + */ + countTotal: boolean; + /** + * reverse is set to true if results are to be returned in the descending order. + * + * Since: cosmos-sdk 0.43 + */ + reverse: boolean; +} + +/** + * PageResponse is to be embedded in gRPC response messages where the + * corresponding request message has used PageRequest. + * + * message SomeResponse { + * repeated Bar results = 1; + * PageResponse page = 2; + * } + */ +export interface PageResponse { + /** + * next_key is the key to be passed to PageRequest.key to + * query the next page most efficiently + */ + nextKey: Uint8Array; + /** + * total is total number of results available if PageRequest.count_total + * was set, its value is undefined otherwise + */ + total: number; +} + +const basePageRequest: object = { + offset: 0, + limit: 0, + countTotal: false, + reverse: false, +}; + +export const PageRequest = { + encode(message: PageRequest, writer: Writer = Writer.create()): Writer { + if (message.key.length !== 0) { + writer.uint32(10).bytes(message.key); + } + if (message.offset !== 0) { + writer.uint32(16).uint64(message.offset); + } + if (message.limit !== 0) { + writer.uint32(24).uint64(message.limit); + } + if (message.countTotal === true) { + writer.uint32(32).bool(message.countTotal); + } + if (message.reverse === true) { + writer.uint32(40).bool(message.reverse); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): PageRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...basePageRequest } as PageRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.key = reader.bytes(); + break; + case 2: + message.offset = longToNumber(reader.uint64() as Long); + break; + case 3: + message.limit = longToNumber(reader.uint64() as Long); + break; + case 4: + message.countTotal = reader.bool(); + break; + case 5: + message.reverse = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): PageRequest { + const message = { ...basePageRequest } as PageRequest; + if (object.key !== undefined && object.key !== null) { + message.key = bytesFromBase64(object.key); + } + if (object.offset !== undefined && object.offset !== null) { + message.offset = Number(object.offset); + } else { + message.offset = 0; + } + if (object.limit !== undefined && object.limit !== null) { + message.limit = Number(object.limit); + } else { + message.limit = 0; + } + if (object.countTotal !== undefined && object.countTotal !== null) { + message.countTotal = Boolean(object.countTotal); + } else { + message.countTotal = false; + } + if (object.reverse !== undefined && object.reverse !== null) { + message.reverse = Boolean(object.reverse); + } else { + message.reverse = false; + } + return message; + }, + + toJSON(message: PageRequest): unknown { + const obj: any = {}; + message.key !== undefined && + (obj.key = base64FromBytes( + message.key !== undefined ? message.key : new Uint8Array() + )); + message.offset !== undefined && (obj.offset = message.offset); + message.limit !== undefined && (obj.limit = message.limit); + message.countTotal !== undefined && (obj.countTotal = message.countTotal); + message.reverse !== undefined && (obj.reverse = message.reverse); + return obj; + }, + + fromPartial(object: DeepPartial): PageRequest { + const message = { ...basePageRequest } as PageRequest; + if (object.key !== undefined && object.key !== null) { + message.key = object.key; + } else { + message.key = new Uint8Array(); + } + if (object.offset !== undefined && object.offset !== null) { + message.offset = object.offset; + } else { + message.offset = 0; + } + if (object.limit !== undefined && object.limit !== null) { + message.limit = object.limit; + } else { + message.limit = 0; + } + if (object.countTotal !== undefined && object.countTotal !== null) { + message.countTotal = object.countTotal; + } else { + message.countTotal = false; + } + if (object.reverse !== undefined && object.reverse !== null) { + message.reverse = object.reverse; + } else { + message.reverse = false; + } + return message; + }, +}; + +const basePageResponse: object = { total: 0 }; + +export const PageResponse = { + encode(message: PageResponse, writer: Writer = Writer.create()): Writer { + if (message.nextKey.length !== 0) { + writer.uint32(10).bytes(message.nextKey); + } + if (message.total !== 0) { + writer.uint32(16).uint64(message.total); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): PageResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...basePageResponse } as PageResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.nextKey = reader.bytes(); + break; + case 2: + message.total = longToNumber(reader.uint64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): PageResponse { + const message = { ...basePageResponse } as PageResponse; + if (object.nextKey !== undefined && object.nextKey !== null) { + message.nextKey = bytesFromBase64(object.nextKey); + } + if (object.total !== undefined && object.total !== null) { + message.total = Number(object.total); + } else { + message.total = 0; + } + return message; + }, + + toJSON(message: PageResponse): unknown { + const obj: any = {}; + message.nextKey !== undefined && + (obj.nextKey = base64FromBytes( + message.nextKey !== undefined ? message.nextKey : new Uint8Array() + )); + message.total !== undefined && (obj.total = message.total); + return obj; + }, + + fromPartial(object: DeepPartial): PageResponse { + const message = { ...basePageResponse } as PageResponse; + if (object.nextKey !== undefined && object.nextKey !== null) { + message.nextKey = object.nextKey; + } else { + message.nextKey = new Uint8Array(); + } + if (object.total !== undefined && object.total !== null) { + message.total = object.total; + } else { + message.total = 0; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/cosmos.distribution.v1beta1/types/cosmos/base/v1beta1/coin.ts b/ts-client/cosmos.distribution.v1beta1/types/cosmos/base/v1beta1/coin.ts new file mode 100644 index 00000000..ce2ac984 --- /dev/null +++ b/ts-client/cosmos.distribution.v1beta1/types/cosmos/base/v1beta1/coin.ts @@ -0,0 +1,301 @@ +/* eslint-disable */ +import { Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "cosmos.base.v1beta1"; + +/** + * Coin defines a token with a denomination and an amount. + * + * NOTE: The amount field is an Int which implements the custom method + * signatures required by gogoproto. + */ +export interface Coin { + denom: string; + amount: string; +} + +/** + * DecCoin defines a token with a denomination and a decimal amount. + * + * NOTE: The amount field is an Dec which implements the custom method + * signatures required by gogoproto. + */ +export interface DecCoin { + denom: string; + amount: string; +} + +/** IntProto defines a Protobuf wrapper around an Int object. */ +export interface IntProto { + int: string; +} + +/** DecProto defines a Protobuf wrapper around a Dec object. */ +export interface DecProto { + dec: string; +} + +const baseCoin: object = { denom: "", amount: "" }; + +export const Coin = { + encode(message: Coin, writer: Writer = Writer.create()): Writer { + if (message.denom !== "") { + writer.uint32(10).string(message.denom); + } + if (message.amount !== "") { + writer.uint32(18).string(message.amount); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Coin { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseCoin } as Coin; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.denom = reader.string(); + break; + case 2: + message.amount = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Coin { + const message = { ...baseCoin } as Coin; + if (object.denom !== undefined && object.denom !== null) { + message.denom = String(object.denom); + } else { + message.denom = ""; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = String(object.amount); + } else { + message.amount = ""; + } + return message; + }, + + toJSON(message: Coin): unknown { + const obj: any = {}; + message.denom !== undefined && (obj.denom = message.denom); + message.amount !== undefined && (obj.amount = message.amount); + return obj; + }, + + fromPartial(object: DeepPartial): Coin { + const message = { ...baseCoin } as Coin; + if (object.denom !== undefined && object.denom !== null) { + message.denom = object.denom; + } else { + message.denom = ""; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = object.amount; + } else { + message.amount = ""; + } + return message; + }, +}; + +const baseDecCoin: object = { denom: "", amount: "" }; + +export const DecCoin = { + encode(message: DecCoin, writer: Writer = Writer.create()): Writer { + if (message.denom !== "") { + writer.uint32(10).string(message.denom); + } + if (message.amount !== "") { + writer.uint32(18).string(message.amount); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): DecCoin { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseDecCoin } as DecCoin; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.denom = reader.string(); + break; + case 2: + message.amount = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DecCoin { + const message = { ...baseDecCoin } as DecCoin; + if (object.denom !== undefined && object.denom !== null) { + message.denom = String(object.denom); + } else { + message.denom = ""; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = String(object.amount); + } else { + message.amount = ""; + } + return message; + }, + + toJSON(message: DecCoin): unknown { + const obj: any = {}; + message.denom !== undefined && (obj.denom = message.denom); + message.amount !== undefined && (obj.amount = message.amount); + return obj; + }, + + fromPartial(object: DeepPartial): DecCoin { + const message = { ...baseDecCoin } as DecCoin; + if (object.denom !== undefined && object.denom !== null) { + message.denom = object.denom; + } else { + message.denom = ""; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = object.amount; + } else { + message.amount = ""; + } + return message; + }, +}; + +const baseIntProto: object = { int: "" }; + +export const IntProto = { + encode(message: IntProto, writer: Writer = Writer.create()): Writer { + if (message.int !== "") { + writer.uint32(10).string(message.int); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): IntProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseIntProto } as IntProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.int = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): IntProto { + const message = { ...baseIntProto } as IntProto; + if (object.int !== undefined && object.int !== null) { + message.int = String(object.int); + } else { + message.int = ""; + } + return message; + }, + + toJSON(message: IntProto): unknown { + const obj: any = {}; + message.int !== undefined && (obj.int = message.int); + return obj; + }, + + fromPartial(object: DeepPartial): IntProto { + const message = { ...baseIntProto } as IntProto; + if (object.int !== undefined && object.int !== null) { + message.int = object.int; + } else { + message.int = ""; + } + return message; + }, +}; + +const baseDecProto: object = { dec: "" }; + +export const DecProto = { + encode(message: DecProto, writer: Writer = Writer.create()): Writer { + if (message.dec !== "") { + writer.uint32(10).string(message.dec); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): DecProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseDecProto } as DecProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.dec = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DecProto { + const message = { ...baseDecProto } as DecProto; + if (object.dec !== undefined && object.dec !== null) { + message.dec = String(object.dec); + } else { + message.dec = ""; + } + return message; + }, + + toJSON(message: DecProto): unknown { + const obj: any = {}; + message.dec !== undefined && (obj.dec = message.dec); + return obj; + }, + + fromPartial(object: DeepPartial): DecProto { + const message = { ...baseDecProto } as DecProto; + if (object.dec !== undefined && object.dec !== null) { + message.dec = object.dec; + } else { + message.dec = ""; + } + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/cosmos.distribution.v1beta1/types/cosmos/distribution/v1beta1/distribution.ts b/ts-client/cosmos.distribution.v1beta1/types/cosmos/distribution/v1beta1/distribution.ts new file mode 100644 index 00000000..c8a6ff84 --- /dev/null +++ b/ts-client/cosmos.distribution.v1beta1/types/cosmos/distribution/v1beta1/distribution.ts @@ -0,0 +1,1343 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; +import { DecCoin, Coin } from "../../../cosmos/base/v1beta1/coin"; + +export const protobufPackage = "cosmos.distribution.v1beta1"; + +/** Params defines the set of params for the distribution module. */ +export interface Params { + communityTax: string; + baseProposerReward: string; + bonusProposerReward: string; + withdrawAddrEnabled: boolean; +} + +/** + * ValidatorHistoricalRewards represents historical rewards for a validator. + * Height is implicit within the store key. + * Cumulative reward ratio is the sum from the zeroeth period + * until this period of rewards / tokens, per the spec. + * The reference count indicates the number of objects + * which might need to reference this historical entry at any point. + * ReferenceCount = + * number of outstanding delegations which ended the associated period (and + * might need to read that record) + * + number of slashes which ended the associated period (and might need to + * read that record) + * + one per validator for the zeroeth period, set on initialization + */ +export interface ValidatorHistoricalRewards { + cumulativeRewardRatio: DecCoin[]; + referenceCount: number; +} + +/** + * ValidatorCurrentRewards represents current rewards and current + * period for a validator kept as a running counter and incremented + * each block as long as the validator's tokens remain constant. + */ +export interface ValidatorCurrentRewards { + rewards: DecCoin[]; + period: number; +} + +/** + * ValidatorAccumulatedCommission represents accumulated commission + * for a validator kept as a running counter, can be withdrawn at any time. + */ +export interface ValidatorAccumulatedCommission { + commission: DecCoin[]; +} + +/** + * ValidatorOutstandingRewards represents outstanding (un-withdrawn) rewards + * for a validator inexpensive to track, allows simple sanity checks. + */ +export interface ValidatorOutstandingRewards { + rewards: DecCoin[]; +} + +/** + * ValidatorSlashEvent represents a validator slash event. + * Height is implicit within the store key. + * This is needed to calculate appropriate amount of staking tokens + * for delegations which are withdrawn after a slash has occurred. + */ +export interface ValidatorSlashEvent { + validatorPeriod: number; + fraction: string; +} + +/** ValidatorSlashEvents is a collection of ValidatorSlashEvent messages. */ +export interface ValidatorSlashEvents { + validatorSlashEvents: ValidatorSlashEvent[]; +} + +/** FeePool is the global fee pool for distribution. */ +export interface FeePool { + communityPool: DecCoin[]; +} + +/** + * CommunityPoolSpendProposal details a proposal for use of community funds, + * together with how many coins are proposed to be spent, and to which + * recipient account. + */ +export interface CommunityPoolSpendProposal { + title: string; + description: string; + recipient: string; + amount: Coin[]; +} + +/** + * DelegatorStartingInfo represents the starting info for a delegator reward + * period. It tracks the previous validator period, the delegation's amount of + * staking token, and the creation height (to check later on if any slashes have + * occurred). NOTE: Even though validators are slashed to whole staking tokens, + * the delegators within the validator may be left with less than a full token, + * thus sdk.Dec is used. + */ +export interface DelegatorStartingInfo { + previousPeriod: number; + stake: string; + height: number; +} + +/** + * DelegationDelegatorReward represents the properties + * of a delegator's delegation reward. + */ +export interface DelegationDelegatorReward { + validatorAddress: string; + reward: DecCoin[]; +} + +/** + * CommunityPoolSpendProposalWithDeposit defines a CommunityPoolSpendProposal + * with a deposit + */ +export interface CommunityPoolSpendProposalWithDeposit { + title: string; + description: string; + recipient: string; + amount: string; + deposit: string; +} + +const baseParams: object = { + communityTax: "", + baseProposerReward: "", + bonusProposerReward: "", + withdrawAddrEnabled: false, +}; + +export const Params = { + encode(message: Params, writer: Writer = Writer.create()): Writer { + if (message.communityTax !== "") { + writer.uint32(10).string(message.communityTax); + } + if (message.baseProposerReward !== "") { + writer.uint32(18).string(message.baseProposerReward); + } + if (message.bonusProposerReward !== "") { + writer.uint32(26).string(message.bonusProposerReward); + } + if (message.withdrawAddrEnabled === true) { + writer.uint32(32).bool(message.withdrawAddrEnabled); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Params { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseParams } as Params; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.communityTax = reader.string(); + break; + case 2: + message.baseProposerReward = reader.string(); + break; + case 3: + message.bonusProposerReward = reader.string(); + break; + case 4: + message.withdrawAddrEnabled = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Params { + const message = { ...baseParams } as Params; + if (object.communityTax !== undefined && object.communityTax !== null) { + message.communityTax = String(object.communityTax); + } else { + message.communityTax = ""; + } + if ( + object.baseProposerReward !== undefined && + object.baseProposerReward !== null + ) { + message.baseProposerReward = String(object.baseProposerReward); + } else { + message.baseProposerReward = ""; + } + if ( + object.bonusProposerReward !== undefined && + object.bonusProposerReward !== null + ) { + message.bonusProposerReward = String(object.bonusProposerReward); + } else { + message.bonusProposerReward = ""; + } + if ( + object.withdrawAddrEnabled !== undefined && + object.withdrawAddrEnabled !== null + ) { + message.withdrawAddrEnabled = Boolean(object.withdrawAddrEnabled); + } else { + message.withdrawAddrEnabled = false; + } + return message; + }, + + toJSON(message: Params): unknown { + const obj: any = {}; + message.communityTax !== undefined && + (obj.communityTax = message.communityTax); + message.baseProposerReward !== undefined && + (obj.baseProposerReward = message.baseProposerReward); + message.bonusProposerReward !== undefined && + (obj.bonusProposerReward = message.bonusProposerReward); + message.withdrawAddrEnabled !== undefined && + (obj.withdrawAddrEnabled = message.withdrawAddrEnabled); + return obj; + }, + + fromPartial(object: DeepPartial): Params { + const message = { ...baseParams } as Params; + if (object.communityTax !== undefined && object.communityTax !== null) { + message.communityTax = object.communityTax; + } else { + message.communityTax = ""; + } + if ( + object.baseProposerReward !== undefined && + object.baseProposerReward !== null + ) { + message.baseProposerReward = object.baseProposerReward; + } else { + message.baseProposerReward = ""; + } + if ( + object.bonusProposerReward !== undefined && + object.bonusProposerReward !== null + ) { + message.bonusProposerReward = object.bonusProposerReward; + } else { + message.bonusProposerReward = ""; + } + if ( + object.withdrawAddrEnabled !== undefined && + object.withdrawAddrEnabled !== null + ) { + message.withdrawAddrEnabled = object.withdrawAddrEnabled; + } else { + message.withdrawAddrEnabled = false; + } + return message; + }, +}; + +const baseValidatorHistoricalRewards: object = { referenceCount: 0 }; + +export const ValidatorHistoricalRewards = { + encode( + message: ValidatorHistoricalRewards, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.cumulativeRewardRatio) { + DecCoin.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.referenceCount !== 0) { + writer.uint32(16).uint32(message.referenceCount); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): ValidatorHistoricalRewards { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseValidatorHistoricalRewards, + } as ValidatorHistoricalRewards; + message.cumulativeRewardRatio = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.cumulativeRewardRatio.push( + DecCoin.decode(reader, reader.uint32()) + ); + break; + case 2: + message.referenceCount = reader.uint32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ValidatorHistoricalRewards { + const message = { + ...baseValidatorHistoricalRewards, + } as ValidatorHistoricalRewards; + message.cumulativeRewardRatio = []; + if ( + object.cumulativeRewardRatio !== undefined && + object.cumulativeRewardRatio !== null + ) { + for (const e of object.cumulativeRewardRatio) { + message.cumulativeRewardRatio.push(DecCoin.fromJSON(e)); + } + } + if (object.referenceCount !== undefined && object.referenceCount !== null) { + message.referenceCount = Number(object.referenceCount); + } else { + message.referenceCount = 0; + } + return message; + }, + + toJSON(message: ValidatorHistoricalRewards): unknown { + const obj: any = {}; + if (message.cumulativeRewardRatio) { + obj.cumulativeRewardRatio = message.cumulativeRewardRatio.map((e) => + e ? DecCoin.toJSON(e) : undefined + ); + } else { + obj.cumulativeRewardRatio = []; + } + message.referenceCount !== undefined && + (obj.referenceCount = message.referenceCount); + return obj; + }, + + fromPartial( + object: DeepPartial + ): ValidatorHistoricalRewards { + const message = { + ...baseValidatorHistoricalRewards, + } as ValidatorHistoricalRewards; + message.cumulativeRewardRatio = []; + if ( + object.cumulativeRewardRatio !== undefined && + object.cumulativeRewardRatio !== null + ) { + for (const e of object.cumulativeRewardRatio) { + message.cumulativeRewardRatio.push(DecCoin.fromPartial(e)); + } + } + if (object.referenceCount !== undefined && object.referenceCount !== null) { + message.referenceCount = object.referenceCount; + } else { + message.referenceCount = 0; + } + return message; + }, +}; + +const baseValidatorCurrentRewards: object = { period: 0 }; + +export const ValidatorCurrentRewards = { + encode( + message: ValidatorCurrentRewards, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.rewards) { + DecCoin.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.period !== 0) { + writer.uint32(16).uint64(message.period); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ValidatorCurrentRewards { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseValidatorCurrentRewards, + } as ValidatorCurrentRewards; + message.rewards = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.rewards.push(DecCoin.decode(reader, reader.uint32())); + break; + case 2: + message.period = longToNumber(reader.uint64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ValidatorCurrentRewards { + const message = { + ...baseValidatorCurrentRewards, + } as ValidatorCurrentRewards; + message.rewards = []; + if (object.rewards !== undefined && object.rewards !== null) { + for (const e of object.rewards) { + message.rewards.push(DecCoin.fromJSON(e)); + } + } + if (object.period !== undefined && object.period !== null) { + message.period = Number(object.period); + } else { + message.period = 0; + } + return message; + }, + + toJSON(message: ValidatorCurrentRewards): unknown { + const obj: any = {}; + if (message.rewards) { + obj.rewards = message.rewards.map((e) => + e ? DecCoin.toJSON(e) : undefined + ); + } else { + obj.rewards = []; + } + message.period !== undefined && (obj.period = message.period); + return obj; + }, + + fromPartial( + object: DeepPartial + ): ValidatorCurrentRewards { + const message = { + ...baseValidatorCurrentRewards, + } as ValidatorCurrentRewards; + message.rewards = []; + if (object.rewards !== undefined && object.rewards !== null) { + for (const e of object.rewards) { + message.rewards.push(DecCoin.fromPartial(e)); + } + } + if (object.period !== undefined && object.period !== null) { + message.period = object.period; + } else { + message.period = 0; + } + return message; + }, +}; + +const baseValidatorAccumulatedCommission: object = {}; + +export const ValidatorAccumulatedCommission = { + encode( + message: ValidatorAccumulatedCommission, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.commission) { + DecCoin.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): ValidatorAccumulatedCommission { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseValidatorAccumulatedCommission, + } as ValidatorAccumulatedCommission; + message.commission = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.commission.push(DecCoin.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ValidatorAccumulatedCommission { + const message = { + ...baseValidatorAccumulatedCommission, + } as ValidatorAccumulatedCommission; + message.commission = []; + if (object.commission !== undefined && object.commission !== null) { + for (const e of object.commission) { + message.commission.push(DecCoin.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: ValidatorAccumulatedCommission): unknown { + const obj: any = {}; + if (message.commission) { + obj.commission = message.commission.map((e) => + e ? DecCoin.toJSON(e) : undefined + ); + } else { + obj.commission = []; + } + return obj; + }, + + fromPartial( + object: DeepPartial + ): ValidatorAccumulatedCommission { + const message = { + ...baseValidatorAccumulatedCommission, + } as ValidatorAccumulatedCommission; + message.commission = []; + if (object.commission !== undefined && object.commission !== null) { + for (const e of object.commission) { + message.commission.push(DecCoin.fromPartial(e)); + } + } + return message; + }, +}; + +const baseValidatorOutstandingRewards: object = {}; + +export const ValidatorOutstandingRewards = { + encode( + message: ValidatorOutstandingRewards, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.rewards) { + DecCoin.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): ValidatorOutstandingRewards { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseValidatorOutstandingRewards, + } as ValidatorOutstandingRewards; + message.rewards = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.rewards.push(DecCoin.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ValidatorOutstandingRewards { + const message = { + ...baseValidatorOutstandingRewards, + } as ValidatorOutstandingRewards; + message.rewards = []; + if (object.rewards !== undefined && object.rewards !== null) { + for (const e of object.rewards) { + message.rewards.push(DecCoin.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: ValidatorOutstandingRewards): unknown { + const obj: any = {}; + if (message.rewards) { + obj.rewards = message.rewards.map((e) => + e ? DecCoin.toJSON(e) : undefined + ); + } else { + obj.rewards = []; + } + return obj; + }, + + fromPartial( + object: DeepPartial + ): ValidatorOutstandingRewards { + const message = { + ...baseValidatorOutstandingRewards, + } as ValidatorOutstandingRewards; + message.rewards = []; + if (object.rewards !== undefined && object.rewards !== null) { + for (const e of object.rewards) { + message.rewards.push(DecCoin.fromPartial(e)); + } + } + return message; + }, +}; + +const baseValidatorSlashEvent: object = { validatorPeriod: 0, fraction: "" }; + +export const ValidatorSlashEvent = { + encode( + message: ValidatorSlashEvent, + writer: Writer = Writer.create() + ): Writer { + if (message.validatorPeriod !== 0) { + writer.uint32(8).uint64(message.validatorPeriod); + } + if (message.fraction !== "") { + writer.uint32(18).string(message.fraction); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ValidatorSlashEvent { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseValidatorSlashEvent } as ValidatorSlashEvent; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.validatorPeriod = longToNumber(reader.uint64() as Long); + break; + case 2: + message.fraction = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ValidatorSlashEvent { + const message = { ...baseValidatorSlashEvent } as ValidatorSlashEvent; + if ( + object.validatorPeriod !== undefined && + object.validatorPeriod !== null + ) { + message.validatorPeriod = Number(object.validatorPeriod); + } else { + message.validatorPeriod = 0; + } + if (object.fraction !== undefined && object.fraction !== null) { + message.fraction = String(object.fraction); + } else { + message.fraction = ""; + } + return message; + }, + + toJSON(message: ValidatorSlashEvent): unknown { + const obj: any = {}; + message.validatorPeriod !== undefined && + (obj.validatorPeriod = message.validatorPeriod); + message.fraction !== undefined && (obj.fraction = message.fraction); + return obj; + }, + + fromPartial(object: DeepPartial): ValidatorSlashEvent { + const message = { ...baseValidatorSlashEvent } as ValidatorSlashEvent; + if ( + object.validatorPeriod !== undefined && + object.validatorPeriod !== null + ) { + message.validatorPeriod = object.validatorPeriod; + } else { + message.validatorPeriod = 0; + } + if (object.fraction !== undefined && object.fraction !== null) { + message.fraction = object.fraction; + } else { + message.fraction = ""; + } + return message; + }, +}; + +const baseValidatorSlashEvents: object = {}; + +export const ValidatorSlashEvents = { + encode( + message: ValidatorSlashEvents, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.validatorSlashEvents) { + ValidatorSlashEvent.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ValidatorSlashEvents { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseValidatorSlashEvents } as ValidatorSlashEvents; + message.validatorSlashEvents = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.validatorSlashEvents.push( + ValidatorSlashEvent.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ValidatorSlashEvents { + const message = { ...baseValidatorSlashEvents } as ValidatorSlashEvents; + message.validatorSlashEvents = []; + if ( + object.validatorSlashEvents !== undefined && + object.validatorSlashEvents !== null + ) { + for (const e of object.validatorSlashEvents) { + message.validatorSlashEvents.push(ValidatorSlashEvent.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: ValidatorSlashEvents): unknown { + const obj: any = {}; + if (message.validatorSlashEvents) { + obj.validatorSlashEvents = message.validatorSlashEvents.map((e) => + e ? ValidatorSlashEvent.toJSON(e) : undefined + ); + } else { + obj.validatorSlashEvents = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): ValidatorSlashEvents { + const message = { ...baseValidatorSlashEvents } as ValidatorSlashEvents; + message.validatorSlashEvents = []; + if ( + object.validatorSlashEvents !== undefined && + object.validatorSlashEvents !== null + ) { + for (const e of object.validatorSlashEvents) { + message.validatorSlashEvents.push(ValidatorSlashEvent.fromPartial(e)); + } + } + return message; + }, +}; + +const baseFeePool: object = {}; + +export const FeePool = { + encode(message: FeePool, writer: Writer = Writer.create()): Writer { + for (const v of message.communityPool) { + DecCoin.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FeePool { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFeePool } as FeePool; + message.communityPool = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.communityPool.push(DecCoin.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FeePool { + const message = { ...baseFeePool } as FeePool; + message.communityPool = []; + if (object.communityPool !== undefined && object.communityPool !== null) { + for (const e of object.communityPool) { + message.communityPool.push(DecCoin.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: FeePool): unknown { + const obj: any = {}; + if (message.communityPool) { + obj.communityPool = message.communityPool.map((e) => + e ? DecCoin.toJSON(e) : undefined + ); + } else { + obj.communityPool = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): FeePool { + const message = { ...baseFeePool } as FeePool; + message.communityPool = []; + if (object.communityPool !== undefined && object.communityPool !== null) { + for (const e of object.communityPool) { + message.communityPool.push(DecCoin.fromPartial(e)); + } + } + return message; + }, +}; + +const baseCommunityPoolSpendProposal: object = { + title: "", + description: "", + recipient: "", +}; + +export const CommunityPoolSpendProposal = { + encode( + message: CommunityPoolSpendProposal, + writer: Writer = Writer.create() + ): Writer { + if (message.title !== "") { + writer.uint32(10).string(message.title); + } + if (message.description !== "") { + writer.uint32(18).string(message.description); + } + if (message.recipient !== "") { + writer.uint32(26).string(message.recipient); + } + for (const v of message.amount) { + Coin.encode(v!, writer.uint32(34).fork()).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): CommunityPoolSpendProposal { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseCommunityPoolSpendProposal, + } as CommunityPoolSpendProposal; + message.amount = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.title = reader.string(); + break; + case 2: + message.description = reader.string(); + break; + case 3: + message.recipient = reader.string(); + break; + case 4: + message.amount.push(Coin.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): CommunityPoolSpendProposal { + const message = { + ...baseCommunityPoolSpendProposal, + } as CommunityPoolSpendProposal; + message.amount = []; + if (object.title !== undefined && object.title !== null) { + message.title = String(object.title); + } else { + message.title = ""; + } + if (object.description !== undefined && object.description !== null) { + message.description = String(object.description); + } else { + message.description = ""; + } + if (object.recipient !== undefined && object.recipient !== null) { + message.recipient = String(object.recipient); + } else { + message.recipient = ""; + } + if (object.amount !== undefined && object.amount !== null) { + for (const e of object.amount) { + message.amount.push(Coin.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: CommunityPoolSpendProposal): unknown { + const obj: any = {}; + message.title !== undefined && (obj.title = message.title); + message.description !== undefined && + (obj.description = message.description); + message.recipient !== undefined && (obj.recipient = message.recipient); + if (message.amount) { + obj.amount = message.amount.map((e) => (e ? Coin.toJSON(e) : undefined)); + } else { + obj.amount = []; + } + return obj; + }, + + fromPartial( + object: DeepPartial + ): CommunityPoolSpendProposal { + const message = { + ...baseCommunityPoolSpendProposal, + } as CommunityPoolSpendProposal; + message.amount = []; + if (object.title !== undefined && object.title !== null) { + message.title = object.title; + } else { + message.title = ""; + } + if (object.description !== undefined && object.description !== null) { + message.description = object.description; + } else { + message.description = ""; + } + if (object.recipient !== undefined && object.recipient !== null) { + message.recipient = object.recipient; + } else { + message.recipient = ""; + } + if (object.amount !== undefined && object.amount !== null) { + for (const e of object.amount) { + message.amount.push(Coin.fromPartial(e)); + } + } + return message; + }, +}; + +const baseDelegatorStartingInfo: object = { + previousPeriod: 0, + stake: "", + height: 0, +}; + +export const DelegatorStartingInfo = { + encode( + message: DelegatorStartingInfo, + writer: Writer = Writer.create() + ): Writer { + if (message.previousPeriod !== 0) { + writer.uint32(8).uint64(message.previousPeriod); + } + if (message.stake !== "") { + writer.uint32(18).string(message.stake); + } + if (message.height !== 0) { + writer.uint32(24).uint64(message.height); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): DelegatorStartingInfo { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseDelegatorStartingInfo } as DelegatorStartingInfo; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.previousPeriod = longToNumber(reader.uint64() as Long); + break; + case 2: + message.stake = reader.string(); + break; + case 3: + message.height = longToNumber(reader.uint64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DelegatorStartingInfo { + const message = { ...baseDelegatorStartingInfo } as DelegatorStartingInfo; + if (object.previousPeriod !== undefined && object.previousPeriod !== null) { + message.previousPeriod = Number(object.previousPeriod); + } else { + message.previousPeriod = 0; + } + if (object.stake !== undefined && object.stake !== null) { + message.stake = String(object.stake); + } else { + message.stake = ""; + } + if (object.height !== undefined && object.height !== null) { + message.height = Number(object.height); + } else { + message.height = 0; + } + return message; + }, + + toJSON(message: DelegatorStartingInfo): unknown { + const obj: any = {}; + message.previousPeriod !== undefined && + (obj.previousPeriod = message.previousPeriod); + message.stake !== undefined && (obj.stake = message.stake); + message.height !== undefined && (obj.height = message.height); + return obj; + }, + + fromPartial( + object: DeepPartial + ): DelegatorStartingInfo { + const message = { ...baseDelegatorStartingInfo } as DelegatorStartingInfo; + if (object.previousPeriod !== undefined && object.previousPeriod !== null) { + message.previousPeriod = object.previousPeriod; + } else { + message.previousPeriod = 0; + } + if (object.stake !== undefined && object.stake !== null) { + message.stake = object.stake; + } else { + message.stake = ""; + } + if (object.height !== undefined && object.height !== null) { + message.height = object.height; + } else { + message.height = 0; + } + return message; + }, +}; + +const baseDelegationDelegatorReward: object = { validatorAddress: "" }; + +export const DelegationDelegatorReward = { + encode( + message: DelegationDelegatorReward, + writer: Writer = Writer.create() + ): Writer { + if (message.validatorAddress !== "") { + writer.uint32(10).string(message.validatorAddress); + } + for (const v of message.reward) { + DecCoin.encode(v!, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): DelegationDelegatorReward { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseDelegationDelegatorReward, + } as DelegationDelegatorReward; + message.reward = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.validatorAddress = reader.string(); + break; + case 2: + message.reward.push(DecCoin.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DelegationDelegatorReward { + const message = { + ...baseDelegationDelegatorReward, + } as DelegationDelegatorReward; + message.reward = []; + if ( + object.validatorAddress !== undefined && + object.validatorAddress !== null + ) { + message.validatorAddress = String(object.validatorAddress); + } else { + message.validatorAddress = ""; + } + if (object.reward !== undefined && object.reward !== null) { + for (const e of object.reward) { + message.reward.push(DecCoin.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: DelegationDelegatorReward): unknown { + const obj: any = {}; + message.validatorAddress !== undefined && + (obj.validatorAddress = message.validatorAddress); + if (message.reward) { + obj.reward = message.reward.map((e) => + e ? DecCoin.toJSON(e) : undefined + ); + } else { + obj.reward = []; + } + return obj; + }, + + fromPartial( + object: DeepPartial + ): DelegationDelegatorReward { + const message = { + ...baseDelegationDelegatorReward, + } as DelegationDelegatorReward; + message.reward = []; + if ( + object.validatorAddress !== undefined && + object.validatorAddress !== null + ) { + message.validatorAddress = object.validatorAddress; + } else { + message.validatorAddress = ""; + } + if (object.reward !== undefined && object.reward !== null) { + for (const e of object.reward) { + message.reward.push(DecCoin.fromPartial(e)); + } + } + return message; + }, +}; + +const baseCommunityPoolSpendProposalWithDeposit: object = { + title: "", + description: "", + recipient: "", + amount: "", + deposit: "", +}; + +export const CommunityPoolSpendProposalWithDeposit = { + encode( + message: CommunityPoolSpendProposalWithDeposit, + writer: Writer = Writer.create() + ): Writer { + if (message.title !== "") { + writer.uint32(10).string(message.title); + } + if (message.description !== "") { + writer.uint32(18).string(message.description); + } + if (message.recipient !== "") { + writer.uint32(26).string(message.recipient); + } + if (message.amount !== "") { + writer.uint32(34).string(message.amount); + } + if (message.deposit !== "") { + writer.uint32(42).string(message.deposit); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): CommunityPoolSpendProposalWithDeposit { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseCommunityPoolSpendProposalWithDeposit, + } as CommunityPoolSpendProposalWithDeposit; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.title = reader.string(); + break; + case 2: + message.description = reader.string(); + break; + case 3: + message.recipient = reader.string(); + break; + case 4: + message.amount = reader.string(); + break; + case 5: + message.deposit = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): CommunityPoolSpendProposalWithDeposit { + const message = { + ...baseCommunityPoolSpendProposalWithDeposit, + } as CommunityPoolSpendProposalWithDeposit; + if (object.title !== undefined && object.title !== null) { + message.title = String(object.title); + } else { + message.title = ""; + } + if (object.description !== undefined && object.description !== null) { + message.description = String(object.description); + } else { + message.description = ""; + } + if (object.recipient !== undefined && object.recipient !== null) { + message.recipient = String(object.recipient); + } else { + message.recipient = ""; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = String(object.amount); + } else { + message.amount = ""; + } + if (object.deposit !== undefined && object.deposit !== null) { + message.deposit = String(object.deposit); + } else { + message.deposit = ""; + } + return message; + }, + + toJSON(message: CommunityPoolSpendProposalWithDeposit): unknown { + const obj: any = {}; + message.title !== undefined && (obj.title = message.title); + message.description !== undefined && + (obj.description = message.description); + message.recipient !== undefined && (obj.recipient = message.recipient); + message.amount !== undefined && (obj.amount = message.amount); + message.deposit !== undefined && (obj.deposit = message.deposit); + return obj; + }, + + fromPartial( + object: DeepPartial + ): CommunityPoolSpendProposalWithDeposit { + const message = { + ...baseCommunityPoolSpendProposalWithDeposit, + } as CommunityPoolSpendProposalWithDeposit; + if (object.title !== undefined && object.title !== null) { + message.title = object.title; + } else { + message.title = ""; + } + if (object.description !== undefined && object.description !== null) { + message.description = object.description; + } else { + message.description = ""; + } + if (object.recipient !== undefined && object.recipient !== null) { + message.recipient = object.recipient; + } else { + message.recipient = ""; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = object.amount; + } else { + message.amount = ""; + } + if (object.deposit !== undefined && object.deposit !== null) { + message.deposit = object.deposit; + } else { + message.deposit = ""; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/cosmos.distribution.v1beta1/types/cosmos/distribution/v1beta1/genesis.ts b/ts-client/cosmos.distribution.v1beta1/types/cosmos/distribution/v1beta1/genesis.ts new file mode 100644 index 00000000..db8c7b43 --- /dev/null +++ b/ts-client/cosmos.distribution.v1beta1/types/cosmos/distribution/v1beta1/genesis.ts @@ -0,0 +1,1341 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; +import { DecCoin } from "../../../cosmos/base/v1beta1/coin"; +import { + ValidatorAccumulatedCommission, + ValidatorHistoricalRewards, + ValidatorCurrentRewards, + DelegatorStartingInfo, + ValidatorSlashEvent, + Params, + FeePool, +} from "../../../cosmos/distribution/v1beta1/distribution"; + +export const protobufPackage = "cosmos.distribution.v1beta1"; + +/** + * DelegatorWithdrawInfo is the address for where distributions rewards are + * withdrawn to by default this struct is only used at genesis to feed in + * default withdraw addresses. + */ +export interface DelegatorWithdrawInfo { + /** delegator_address is the address of the delegator. */ + delegatorAddress: string; + /** withdraw_address is the address to withdraw the delegation rewards to. */ + withdrawAddress: string; +} + +/** ValidatorOutstandingRewardsRecord is used for import/export via genesis json. */ +export interface ValidatorOutstandingRewardsRecord { + /** validator_address is the address of the validator. */ + validatorAddress: string; + /** outstanding_rewards represents the oustanding rewards of a validator. */ + outstandingRewards: DecCoin[]; +} + +/** + * ValidatorAccumulatedCommissionRecord is used for import / export via genesis + * json. + */ +export interface ValidatorAccumulatedCommissionRecord { + /** validator_address is the address of the validator. */ + validatorAddress: string; + /** accumulated is the accumulated commission of a validator. */ + accumulated: ValidatorAccumulatedCommission | undefined; +} + +/** + * ValidatorHistoricalRewardsRecord is used for import / export via genesis + * json. + */ +export interface ValidatorHistoricalRewardsRecord { + /** validator_address is the address of the validator. */ + validatorAddress: string; + /** period defines the period the historical rewards apply to. */ + period: number; + /** rewards defines the historical rewards of a validator. */ + rewards: ValidatorHistoricalRewards | undefined; +} + +/** ValidatorCurrentRewardsRecord is used for import / export via genesis json. */ +export interface ValidatorCurrentRewardsRecord { + /** validator_address is the address of the validator. */ + validatorAddress: string; + /** rewards defines the current rewards of a validator. */ + rewards: ValidatorCurrentRewards | undefined; +} + +/** DelegatorStartingInfoRecord used for import / export via genesis json. */ +export interface DelegatorStartingInfoRecord { + /** delegator_address is the address of the delegator. */ + delegatorAddress: string; + /** validator_address is the address of the validator. */ + validatorAddress: string; + /** starting_info defines the starting info of a delegator. */ + startingInfo: DelegatorStartingInfo | undefined; +} + +/** ValidatorSlashEventRecord is used for import / export via genesis json. */ +export interface ValidatorSlashEventRecord { + /** validator_address is the address of the validator. */ + validatorAddress: string; + /** height defines the block height at which the slash event occured. */ + height: number; + /** period is the period of the slash event. */ + period: number; + /** validator_slash_event describes the slash event. */ + validatorSlashEvent: ValidatorSlashEvent | undefined; +} + +/** GenesisState defines the distribution module's genesis state. */ +export interface GenesisState { + /** params defines all the paramaters of the module. */ + params: Params | undefined; + /** fee_pool defines the fee pool at genesis. */ + feePool: FeePool | undefined; + /** fee_pool defines the delegator withdraw infos at genesis. */ + delegatorWithdrawInfos: DelegatorWithdrawInfo[]; + /** fee_pool defines the previous proposer at genesis. */ + previousProposer: string; + /** fee_pool defines the outstanding rewards of all validators at genesis. */ + outstandingRewards: ValidatorOutstandingRewardsRecord[]; + /** fee_pool defines the accumulated commisions of all validators at genesis. */ + validatorAccumulatedCommissions: ValidatorAccumulatedCommissionRecord[]; + /** fee_pool defines the historical rewards of all validators at genesis. */ + validatorHistoricalRewards: ValidatorHistoricalRewardsRecord[]; + /** fee_pool defines the current rewards of all validators at genesis. */ + validatorCurrentRewards: ValidatorCurrentRewardsRecord[]; + /** fee_pool defines the delegator starting infos at genesis. */ + delegatorStartingInfos: DelegatorStartingInfoRecord[]; + /** fee_pool defines the validator slash events at genesis. */ + validatorSlashEvents: ValidatorSlashEventRecord[]; +} + +const baseDelegatorWithdrawInfo: object = { + delegatorAddress: "", + withdrawAddress: "", +}; + +export const DelegatorWithdrawInfo = { + encode( + message: DelegatorWithdrawInfo, + writer: Writer = Writer.create() + ): Writer { + if (message.delegatorAddress !== "") { + writer.uint32(10).string(message.delegatorAddress); + } + if (message.withdrawAddress !== "") { + writer.uint32(18).string(message.withdrawAddress); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): DelegatorWithdrawInfo { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseDelegatorWithdrawInfo } as DelegatorWithdrawInfo; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.delegatorAddress = reader.string(); + break; + case 2: + message.withdrawAddress = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DelegatorWithdrawInfo { + const message = { ...baseDelegatorWithdrawInfo } as DelegatorWithdrawInfo; + if ( + object.delegatorAddress !== undefined && + object.delegatorAddress !== null + ) { + message.delegatorAddress = String(object.delegatorAddress); + } else { + message.delegatorAddress = ""; + } + if ( + object.withdrawAddress !== undefined && + object.withdrawAddress !== null + ) { + message.withdrawAddress = String(object.withdrawAddress); + } else { + message.withdrawAddress = ""; + } + return message; + }, + + toJSON(message: DelegatorWithdrawInfo): unknown { + const obj: any = {}; + message.delegatorAddress !== undefined && + (obj.delegatorAddress = message.delegatorAddress); + message.withdrawAddress !== undefined && + (obj.withdrawAddress = message.withdrawAddress); + return obj; + }, + + fromPartial( + object: DeepPartial + ): DelegatorWithdrawInfo { + const message = { ...baseDelegatorWithdrawInfo } as DelegatorWithdrawInfo; + if ( + object.delegatorAddress !== undefined && + object.delegatorAddress !== null + ) { + message.delegatorAddress = object.delegatorAddress; + } else { + message.delegatorAddress = ""; + } + if ( + object.withdrawAddress !== undefined && + object.withdrawAddress !== null + ) { + message.withdrawAddress = object.withdrawAddress; + } else { + message.withdrawAddress = ""; + } + return message; + }, +}; + +const baseValidatorOutstandingRewardsRecord: object = { validatorAddress: "" }; + +export const ValidatorOutstandingRewardsRecord = { + encode( + message: ValidatorOutstandingRewardsRecord, + writer: Writer = Writer.create() + ): Writer { + if (message.validatorAddress !== "") { + writer.uint32(10).string(message.validatorAddress); + } + for (const v of message.outstandingRewards) { + DecCoin.encode(v!, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): ValidatorOutstandingRewardsRecord { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseValidatorOutstandingRewardsRecord, + } as ValidatorOutstandingRewardsRecord; + message.outstandingRewards = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.validatorAddress = reader.string(); + break; + case 2: + message.outstandingRewards.push( + DecCoin.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ValidatorOutstandingRewardsRecord { + const message = { + ...baseValidatorOutstandingRewardsRecord, + } as ValidatorOutstandingRewardsRecord; + message.outstandingRewards = []; + if ( + object.validatorAddress !== undefined && + object.validatorAddress !== null + ) { + message.validatorAddress = String(object.validatorAddress); + } else { + message.validatorAddress = ""; + } + if ( + object.outstandingRewards !== undefined && + object.outstandingRewards !== null + ) { + for (const e of object.outstandingRewards) { + message.outstandingRewards.push(DecCoin.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: ValidatorOutstandingRewardsRecord): unknown { + const obj: any = {}; + message.validatorAddress !== undefined && + (obj.validatorAddress = message.validatorAddress); + if (message.outstandingRewards) { + obj.outstandingRewards = message.outstandingRewards.map((e) => + e ? DecCoin.toJSON(e) : undefined + ); + } else { + obj.outstandingRewards = []; + } + return obj; + }, + + fromPartial( + object: DeepPartial + ): ValidatorOutstandingRewardsRecord { + const message = { + ...baseValidatorOutstandingRewardsRecord, + } as ValidatorOutstandingRewardsRecord; + message.outstandingRewards = []; + if ( + object.validatorAddress !== undefined && + object.validatorAddress !== null + ) { + message.validatorAddress = object.validatorAddress; + } else { + message.validatorAddress = ""; + } + if ( + object.outstandingRewards !== undefined && + object.outstandingRewards !== null + ) { + for (const e of object.outstandingRewards) { + message.outstandingRewards.push(DecCoin.fromPartial(e)); + } + } + return message; + }, +}; + +const baseValidatorAccumulatedCommissionRecord: object = { + validatorAddress: "", +}; + +export const ValidatorAccumulatedCommissionRecord = { + encode( + message: ValidatorAccumulatedCommissionRecord, + writer: Writer = Writer.create() + ): Writer { + if (message.validatorAddress !== "") { + writer.uint32(10).string(message.validatorAddress); + } + if (message.accumulated !== undefined) { + ValidatorAccumulatedCommission.encode( + message.accumulated, + writer.uint32(18).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): ValidatorAccumulatedCommissionRecord { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseValidatorAccumulatedCommissionRecord, + } as ValidatorAccumulatedCommissionRecord; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.validatorAddress = reader.string(); + break; + case 2: + message.accumulated = ValidatorAccumulatedCommission.decode( + reader, + reader.uint32() + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ValidatorAccumulatedCommissionRecord { + const message = { + ...baseValidatorAccumulatedCommissionRecord, + } as ValidatorAccumulatedCommissionRecord; + if ( + object.validatorAddress !== undefined && + object.validatorAddress !== null + ) { + message.validatorAddress = String(object.validatorAddress); + } else { + message.validatorAddress = ""; + } + if (object.accumulated !== undefined && object.accumulated !== null) { + message.accumulated = ValidatorAccumulatedCommission.fromJSON( + object.accumulated + ); + } else { + message.accumulated = undefined; + } + return message; + }, + + toJSON(message: ValidatorAccumulatedCommissionRecord): unknown { + const obj: any = {}; + message.validatorAddress !== undefined && + (obj.validatorAddress = message.validatorAddress); + message.accumulated !== undefined && + (obj.accumulated = message.accumulated + ? ValidatorAccumulatedCommission.toJSON(message.accumulated) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): ValidatorAccumulatedCommissionRecord { + const message = { + ...baseValidatorAccumulatedCommissionRecord, + } as ValidatorAccumulatedCommissionRecord; + if ( + object.validatorAddress !== undefined && + object.validatorAddress !== null + ) { + message.validatorAddress = object.validatorAddress; + } else { + message.validatorAddress = ""; + } + if (object.accumulated !== undefined && object.accumulated !== null) { + message.accumulated = ValidatorAccumulatedCommission.fromPartial( + object.accumulated + ); + } else { + message.accumulated = undefined; + } + return message; + }, +}; + +const baseValidatorHistoricalRewardsRecord: object = { + validatorAddress: "", + period: 0, +}; + +export const ValidatorHistoricalRewardsRecord = { + encode( + message: ValidatorHistoricalRewardsRecord, + writer: Writer = Writer.create() + ): Writer { + if (message.validatorAddress !== "") { + writer.uint32(10).string(message.validatorAddress); + } + if (message.period !== 0) { + writer.uint32(16).uint64(message.period); + } + if (message.rewards !== undefined) { + ValidatorHistoricalRewards.encode( + message.rewards, + writer.uint32(26).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): ValidatorHistoricalRewardsRecord { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseValidatorHistoricalRewardsRecord, + } as ValidatorHistoricalRewardsRecord; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.validatorAddress = reader.string(); + break; + case 2: + message.period = longToNumber(reader.uint64() as Long); + break; + case 3: + message.rewards = ValidatorHistoricalRewards.decode( + reader, + reader.uint32() + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ValidatorHistoricalRewardsRecord { + const message = { + ...baseValidatorHistoricalRewardsRecord, + } as ValidatorHistoricalRewardsRecord; + if ( + object.validatorAddress !== undefined && + object.validatorAddress !== null + ) { + message.validatorAddress = String(object.validatorAddress); + } else { + message.validatorAddress = ""; + } + if (object.period !== undefined && object.period !== null) { + message.period = Number(object.period); + } else { + message.period = 0; + } + if (object.rewards !== undefined && object.rewards !== null) { + message.rewards = ValidatorHistoricalRewards.fromJSON(object.rewards); + } else { + message.rewards = undefined; + } + return message; + }, + + toJSON(message: ValidatorHistoricalRewardsRecord): unknown { + const obj: any = {}; + message.validatorAddress !== undefined && + (obj.validatorAddress = message.validatorAddress); + message.period !== undefined && (obj.period = message.period); + message.rewards !== undefined && + (obj.rewards = message.rewards + ? ValidatorHistoricalRewards.toJSON(message.rewards) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): ValidatorHistoricalRewardsRecord { + const message = { + ...baseValidatorHistoricalRewardsRecord, + } as ValidatorHistoricalRewardsRecord; + if ( + object.validatorAddress !== undefined && + object.validatorAddress !== null + ) { + message.validatorAddress = object.validatorAddress; + } else { + message.validatorAddress = ""; + } + if (object.period !== undefined && object.period !== null) { + message.period = object.period; + } else { + message.period = 0; + } + if (object.rewards !== undefined && object.rewards !== null) { + message.rewards = ValidatorHistoricalRewards.fromPartial(object.rewards); + } else { + message.rewards = undefined; + } + return message; + }, +}; + +const baseValidatorCurrentRewardsRecord: object = { validatorAddress: "" }; + +export const ValidatorCurrentRewardsRecord = { + encode( + message: ValidatorCurrentRewardsRecord, + writer: Writer = Writer.create() + ): Writer { + if (message.validatorAddress !== "") { + writer.uint32(10).string(message.validatorAddress); + } + if (message.rewards !== undefined) { + ValidatorCurrentRewards.encode( + message.rewards, + writer.uint32(18).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): ValidatorCurrentRewardsRecord { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseValidatorCurrentRewardsRecord, + } as ValidatorCurrentRewardsRecord; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.validatorAddress = reader.string(); + break; + case 2: + message.rewards = ValidatorCurrentRewards.decode( + reader, + reader.uint32() + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ValidatorCurrentRewardsRecord { + const message = { + ...baseValidatorCurrentRewardsRecord, + } as ValidatorCurrentRewardsRecord; + if ( + object.validatorAddress !== undefined && + object.validatorAddress !== null + ) { + message.validatorAddress = String(object.validatorAddress); + } else { + message.validatorAddress = ""; + } + if (object.rewards !== undefined && object.rewards !== null) { + message.rewards = ValidatorCurrentRewards.fromJSON(object.rewards); + } else { + message.rewards = undefined; + } + return message; + }, + + toJSON(message: ValidatorCurrentRewardsRecord): unknown { + const obj: any = {}; + message.validatorAddress !== undefined && + (obj.validatorAddress = message.validatorAddress); + message.rewards !== undefined && + (obj.rewards = message.rewards + ? ValidatorCurrentRewards.toJSON(message.rewards) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): ValidatorCurrentRewardsRecord { + const message = { + ...baseValidatorCurrentRewardsRecord, + } as ValidatorCurrentRewardsRecord; + if ( + object.validatorAddress !== undefined && + object.validatorAddress !== null + ) { + message.validatorAddress = object.validatorAddress; + } else { + message.validatorAddress = ""; + } + if (object.rewards !== undefined && object.rewards !== null) { + message.rewards = ValidatorCurrentRewards.fromPartial(object.rewards); + } else { + message.rewards = undefined; + } + return message; + }, +}; + +const baseDelegatorStartingInfoRecord: object = { + delegatorAddress: "", + validatorAddress: "", +}; + +export const DelegatorStartingInfoRecord = { + encode( + message: DelegatorStartingInfoRecord, + writer: Writer = Writer.create() + ): Writer { + if (message.delegatorAddress !== "") { + writer.uint32(10).string(message.delegatorAddress); + } + if (message.validatorAddress !== "") { + writer.uint32(18).string(message.validatorAddress); + } + if (message.startingInfo !== undefined) { + DelegatorStartingInfo.encode( + message.startingInfo, + writer.uint32(26).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): DelegatorStartingInfoRecord { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseDelegatorStartingInfoRecord, + } as DelegatorStartingInfoRecord; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.delegatorAddress = reader.string(); + break; + case 2: + message.validatorAddress = reader.string(); + break; + case 3: + message.startingInfo = DelegatorStartingInfo.decode( + reader, + reader.uint32() + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DelegatorStartingInfoRecord { + const message = { + ...baseDelegatorStartingInfoRecord, + } as DelegatorStartingInfoRecord; + if ( + object.delegatorAddress !== undefined && + object.delegatorAddress !== null + ) { + message.delegatorAddress = String(object.delegatorAddress); + } else { + message.delegatorAddress = ""; + } + if ( + object.validatorAddress !== undefined && + object.validatorAddress !== null + ) { + message.validatorAddress = String(object.validatorAddress); + } else { + message.validatorAddress = ""; + } + if (object.startingInfo !== undefined && object.startingInfo !== null) { + message.startingInfo = DelegatorStartingInfo.fromJSON( + object.startingInfo + ); + } else { + message.startingInfo = undefined; + } + return message; + }, + + toJSON(message: DelegatorStartingInfoRecord): unknown { + const obj: any = {}; + message.delegatorAddress !== undefined && + (obj.delegatorAddress = message.delegatorAddress); + message.validatorAddress !== undefined && + (obj.validatorAddress = message.validatorAddress); + message.startingInfo !== undefined && + (obj.startingInfo = message.startingInfo + ? DelegatorStartingInfo.toJSON(message.startingInfo) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): DelegatorStartingInfoRecord { + const message = { + ...baseDelegatorStartingInfoRecord, + } as DelegatorStartingInfoRecord; + if ( + object.delegatorAddress !== undefined && + object.delegatorAddress !== null + ) { + message.delegatorAddress = object.delegatorAddress; + } else { + message.delegatorAddress = ""; + } + if ( + object.validatorAddress !== undefined && + object.validatorAddress !== null + ) { + message.validatorAddress = object.validatorAddress; + } else { + message.validatorAddress = ""; + } + if (object.startingInfo !== undefined && object.startingInfo !== null) { + message.startingInfo = DelegatorStartingInfo.fromPartial( + object.startingInfo + ); + } else { + message.startingInfo = undefined; + } + return message; + }, +}; + +const baseValidatorSlashEventRecord: object = { + validatorAddress: "", + height: 0, + period: 0, +}; + +export const ValidatorSlashEventRecord = { + encode( + message: ValidatorSlashEventRecord, + writer: Writer = Writer.create() + ): Writer { + if (message.validatorAddress !== "") { + writer.uint32(10).string(message.validatorAddress); + } + if (message.height !== 0) { + writer.uint32(16).uint64(message.height); + } + if (message.period !== 0) { + writer.uint32(24).uint64(message.period); + } + if (message.validatorSlashEvent !== undefined) { + ValidatorSlashEvent.encode( + message.validatorSlashEvent, + writer.uint32(34).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): ValidatorSlashEventRecord { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseValidatorSlashEventRecord, + } as ValidatorSlashEventRecord; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.validatorAddress = reader.string(); + break; + case 2: + message.height = longToNumber(reader.uint64() as Long); + break; + case 3: + message.period = longToNumber(reader.uint64() as Long); + break; + case 4: + message.validatorSlashEvent = ValidatorSlashEvent.decode( + reader, + reader.uint32() + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ValidatorSlashEventRecord { + const message = { + ...baseValidatorSlashEventRecord, + } as ValidatorSlashEventRecord; + if ( + object.validatorAddress !== undefined && + object.validatorAddress !== null + ) { + message.validatorAddress = String(object.validatorAddress); + } else { + message.validatorAddress = ""; + } + if (object.height !== undefined && object.height !== null) { + message.height = Number(object.height); + } else { + message.height = 0; + } + if (object.period !== undefined && object.period !== null) { + message.period = Number(object.period); + } else { + message.period = 0; + } + if ( + object.validatorSlashEvent !== undefined && + object.validatorSlashEvent !== null + ) { + message.validatorSlashEvent = ValidatorSlashEvent.fromJSON( + object.validatorSlashEvent + ); + } else { + message.validatorSlashEvent = undefined; + } + return message; + }, + + toJSON(message: ValidatorSlashEventRecord): unknown { + const obj: any = {}; + message.validatorAddress !== undefined && + (obj.validatorAddress = message.validatorAddress); + message.height !== undefined && (obj.height = message.height); + message.period !== undefined && (obj.period = message.period); + message.validatorSlashEvent !== undefined && + (obj.validatorSlashEvent = message.validatorSlashEvent + ? ValidatorSlashEvent.toJSON(message.validatorSlashEvent) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): ValidatorSlashEventRecord { + const message = { + ...baseValidatorSlashEventRecord, + } as ValidatorSlashEventRecord; + if ( + object.validatorAddress !== undefined && + object.validatorAddress !== null + ) { + message.validatorAddress = object.validatorAddress; + } else { + message.validatorAddress = ""; + } + if (object.height !== undefined && object.height !== null) { + message.height = object.height; + } else { + message.height = 0; + } + if (object.period !== undefined && object.period !== null) { + message.period = object.period; + } else { + message.period = 0; + } + if ( + object.validatorSlashEvent !== undefined && + object.validatorSlashEvent !== null + ) { + message.validatorSlashEvent = ValidatorSlashEvent.fromPartial( + object.validatorSlashEvent + ); + } else { + message.validatorSlashEvent = undefined; + } + return message; + }, +}; + +const baseGenesisState: object = { previousProposer: "" }; + +export const GenesisState = { + encode(message: GenesisState, writer: Writer = Writer.create()): Writer { + if (message.params !== undefined) { + Params.encode(message.params, writer.uint32(10).fork()).ldelim(); + } + if (message.feePool !== undefined) { + FeePool.encode(message.feePool, writer.uint32(18).fork()).ldelim(); + } + for (const v of message.delegatorWithdrawInfos) { + DelegatorWithdrawInfo.encode(v!, writer.uint32(26).fork()).ldelim(); + } + if (message.previousProposer !== "") { + writer.uint32(34).string(message.previousProposer); + } + for (const v of message.outstandingRewards) { + ValidatorOutstandingRewardsRecord.encode( + v!, + writer.uint32(42).fork() + ).ldelim(); + } + for (const v of message.validatorAccumulatedCommissions) { + ValidatorAccumulatedCommissionRecord.encode( + v!, + writer.uint32(50).fork() + ).ldelim(); + } + for (const v of message.validatorHistoricalRewards) { + ValidatorHistoricalRewardsRecord.encode( + v!, + writer.uint32(58).fork() + ).ldelim(); + } + for (const v of message.validatorCurrentRewards) { + ValidatorCurrentRewardsRecord.encode( + v!, + writer.uint32(66).fork() + ).ldelim(); + } + for (const v of message.delegatorStartingInfos) { + DelegatorStartingInfoRecord.encode(v!, writer.uint32(74).fork()).ldelim(); + } + for (const v of message.validatorSlashEvents) { + ValidatorSlashEventRecord.encode(v!, writer.uint32(82).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): GenesisState { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseGenesisState } as GenesisState; + message.delegatorWithdrawInfos = []; + message.outstandingRewards = []; + message.validatorAccumulatedCommissions = []; + message.validatorHistoricalRewards = []; + message.validatorCurrentRewards = []; + message.delegatorStartingInfos = []; + message.validatorSlashEvents = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.params = Params.decode(reader, reader.uint32()); + break; + case 2: + message.feePool = FeePool.decode(reader, reader.uint32()); + break; + case 3: + message.delegatorWithdrawInfos.push( + DelegatorWithdrawInfo.decode(reader, reader.uint32()) + ); + break; + case 4: + message.previousProposer = reader.string(); + break; + case 5: + message.outstandingRewards.push( + ValidatorOutstandingRewardsRecord.decode(reader, reader.uint32()) + ); + break; + case 6: + message.validatorAccumulatedCommissions.push( + ValidatorAccumulatedCommissionRecord.decode(reader, reader.uint32()) + ); + break; + case 7: + message.validatorHistoricalRewards.push( + ValidatorHistoricalRewardsRecord.decode(reader, reader.uint32()) + ); + break; + case 8: + message.validatorCurrentRewards.push( + ValidatorCurrentRewardsRecord.decode(reader, reader.uint32()) + ); + break; + case 9: + message.delegatorStartingInfos.push( + DelegatorStartingInfoRecord.decode(reader, reader.uint32()) + ); + break; + case 10: + message.validatorSlashEvents.push( + ValidatorSlashEventRecord.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GenesisState { + const message = { ...baseGenesisState } as GenesisState; + message.delegatorWithdrawInfos = []; + message.outstandingRewards = []; + message.validatorAccumulatedCommissions = []; + message.validatorHistoricalRewards = []; + message.validatorCurrentRewards = []; + message.delegatorStartingInfos = []; + message.validatorSlashEvents = []; + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromJSON(object.params); + } else { + message.params = undefined; + } + if (object.feePool !== undefined && object.feePool !== null) { + message.feePool = FeePool.fromJSON(object.feePool); + } else { + message.feePool = undefined; + } + if ( + object.delegatorWithdrawInfos !== undefined && + object.delegatorWithdrawInfos !== null + ) { + for (const e of object.delegatorWithdrawInfos) { + message.delegatorWithdrawInfos.push(DelegatorWithdrawInfo.fromJSON(e)); + } + } + if ( + object.previousProposer !== undefined && + object.previousProposer !== null + ) { + message.previousProposer = String(object.previousProposer); + } else { + message.previousProposer = ""; + } + if ( + object.outstandingRewards !== undefined && + object.outstandingRewards !== null + ) { + for (const e of object.outstandingRewards) { + message.outstandingRewards.push( + ValidatorOutstandingRewardsRecord.fromJSON(e) + ); + } + } + if ( + object.validatorAccumulatedCommissions !== undefined && + object.validatorAccumulatedCommissions !== null + ) { + for (const e of object.validatorAccumulatedCommissions) { + message.validatorAccumulatedCommissions.push( + ValidatorAccumulatedCommissionRecord.fromJSON(e) + ); + } + } + if ( + object.validatorHistoricalRewards !== undefined && + object.validatorHistoricalRewards !== null + ) { + for (const e of object.validatorHistoricalRewards) { + message.validatorHistoricalRewards.push( + ValidatorHistoricalRewardsRecord.fromJSON(e) + ); + } + } + if ( + object.validatorCurrentRewards !== undefined && + object.validatorCurrentRewards !== null + ) { + for (const e of object.validatorCurrentRewards) { + message.validatorCurrentRewards.push( + ValidatorCurrentRewardsRecord.fromJSON(e) + ); + } + } + if ( + object.delegatorStartingInfos !== undefined && + object.delegatorStartingInfos !== null + ) { + for (const e of object.delegatorStartingInfos) { + message.delegatorStartingInfos.push( + DelegatorStartingInfoRecord.fromJSON(e) + ); + } + } + if ( + object.validatorSlashEvents !== undefined && + object.validatorSlashEvents !== null + ) { + for (const e of object.validatorSlashEvents) { + message.validatorSlashEvents.push( + ValidatorSlashEventRecord.fromJSON(e) + ); + } + } + return message; + }, + + toJSON(message: GenesisState): unknown { + const obj: any = {}; + message.params !== undefined && + (obj.params = message.params ? Params.toJSON(message.params) : undefined); + message.feePool !== undefined && + (obj.feePool = message.feePool + ? FeePool.toJSON(message.feePool) + : undefined); + if (message.delegatorWithdrawInfos) { + obj.delegatorWithdrawInfos = message.delegatorWithdrawInfos.map((e) => + e ? DelegatorWithdrawInfo.toJSON(e) : undefined + ); + } else { + obj.delegatorWithdrawInfos = []; + } + message.previousProposer !== undefined && + (obj.previousProposer = message.previousProposer); + if (message.outstandingRewards) { + obj.outstandingRewards = message.outstandingRewards.map((e) => + e ? ValidatorOutstandingRewardsRecord.toJSON(e) : undefined + ); + } else { + obj.outstandingRewards = []; + } + if (message.validatorAccumulatedCommissions) { + obj.validatorAccumulatedCommissions = message.validatorAccumulatedCommissions.map( + (e) => (e ? ValidatorAccumulatedCommissionRecord.toJSON(e) : undefined) + ); + } else { + obj.validatorAccumulatedCommissions = []; + } + if (message.validatorHistoricalRewards) { + obj.validatorHistoricalRewards = message.validatorHistoricalRewards.map( + (e) => (e ? ValidatorHistoricalRewardsRecord.toJSON(e) : undefined) + ); + } else { + obj.validatorHistoricalRewards = []; + } + if (message.validatorCurrentRewards) { + obj.validatorCurrentRewards = message.validatorCurrentRewards.map((e) => + e ? ValidatorCurrentRewardsRecord.toJSON(e) : undefined + ); + } else { + obj.validatorCurrentRewards = []; + } + if (message.delegatorStartingInfos) { + obj.delegatorStartingInfos = message.delegatorStartingInfos.map((e) => + e ? DelegatorStartingInfoRecord.toJSON(e) : undefined + ); + } else { + obj.delegatorStartingInfos = []; + } + if (message.validatorSlashEvents) { + obj.validatorSlashEvents = message.validatorSlashEvents.map((e) => + e ? ValidatorSlashEventRecord.toJSON(e) : undefined + ); + } else { + obj.validatorSlashEvents = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): GenesisState { + const message = { ...baseGenesisState } as GenesisState; + message.delegatorWithdrawInfos = []; + message.outstandingRewards = []; + message.validatorAccumulatedCommissions = []; + message.validatorHistoricalRewards = []; + message.validatorCurrentRewards = []; + message.delegatorStartingInfos = []; + message.validatorSlashEvents = []; + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromPartial(object.params); + } else { + message.params = undefined; + } + if (object.feePool !== undefined && object.feePool !== null) { + message.feePool = FeePool.fromPartial(object.feePool); + } else { + message.feePool = undefined; + } + if ( + object.delegatorWithdrawInfos !== undefined && + object.delegatorWithdrawInfos !== null + ) { + for (const e of object.delegatorWithdrawInfos) { + message.delegatorWithdrawInfos.push( + DelegatorWithdrawInfo.fromPartial(e) + ); + } + } + if ( + object.previousProposer !== undefined && + object.previousProposer !== null + ) { + message.previousProposer = object.previousProposer; + } else { + message.previousProposer = ""; + } + if ( + object.outstandingRewards !== undefined && + object.outstandingRewards !== null + ) { + for (const e of object.outstandingRewards) { + message.outstandingRewards.push( + ValidatorOutstandingRewardsRecord.fromPartial(e) + ); + } + } + if ( + object.validatorAccumulatedCommissions !== undefined && + object.validatorAccumulatedCommissions !== null + ) { + for (const e of object.validatorAccumulatedCommissions) { + message.validatorAccumulatedCommissions.push( + ValidatorAccumulatedCommissionRecord.fromPartial(e) + ); + } + } + if ( + object.validatorHistoricalRewards !== undefined && + object.validatorHistoricalRewards !== null + ) { + for (const e of object.validatorHistoricalRewards) { + message.validatorHistoricalRewards.push( + ValidatorHistoricalRewardsRecord.fromPartial(e) + ); + } + } + if ( + object.validatorCurrentRewards !== undefined && + object.validatorCurrentRewards !== null + ) { + for (const e of object.validatorCurrentRewards) { + message.validatorCurrentRewards.push( + ValidatorCurrentRewardsRecord.fromPartial(e) + ); + } + } + if ( + object.delegatorStartingInfos !== undefined && + object.delegatorStartingInfos !== null + ) { + for (const e of object.delegatorStartingInfos) { + message.delegatorStartingInfos.push( + DelegatorStartingInfoRecord.fromPartial(e) + ); + } + } + if ( + object.validatorSlashEvents !== undefined && + object.validatorSlashEvents !== null + ) { + for (const e of object.validatorSlashEvents) { + message.validatorSlashEvents.push( + ValidatorSlashEventRecord.fromPartial(e) + ); + } + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/cosmos.distribution.v1beta1/types/cosmos/distribution/v1beta1/query.ts b/ts-client/cosmos.distribution.v1beta1/types/cosmos/distribution/v1beta1/query.ts new file mode 100644 index 00000000..c3052039 --- /dev/null +++ b/ts-client/cosmos.distribution.v1beta1/types/cosmos/distribution/v1beta1/query.ts @@ -0,0 +1,1837 @@ +/* eslint-disable */ +import { Reader, util, configure, Writer } from "protobufjs/minimal"; +import * as Long from "long"; +import { + Params, + ValidatorOutstandingRewards, + ValidatorAccumulatedCommission, + ValidatorSlashEvent, + DelegationDelegatorReward, +} from "../../../cosmos/distribution/v1beta1/distribution"; +import { + PageRequest, + PageResponse, +} from "../../../cosmos/base/query/v1beta1/pagination"; +import { DecCoin } from "../../../cosmos/base/v1beta1/coin"; + +export const protobufPackage = "cosmos.distribution.v1beta1"; + +/** QueryParamsRequest is the request type for the Query/Params RPC method. */ +export interface QueryParamsRequest {} + +/** QueryParamsResponse is the response type for the Query/Params RPC method. */ +export interface QueryParamsResponse { + /** params defines the parameters of the module. */ + params: Params | undefined; +} + +/** + * QueryValidatorOutstandingRewardsRequest is the request type for the + * Query/ValidatorOutstandingRewards RPC method. + */ +export interface QueryValidatorOutstandingRewardsRequest { + /** validator_address defines the validator address to query for. */ + validatorAddress: string; +} + +/** + * QueryValidatorOutstandingRewardsResponse is the response type for the + * Query/ValidatorOutstandingRewards RPC method. + */ +export interface QueryValidatorOutstandingRewardsResponse { + rewards: ValidatorOutstandingRewards | undefined; +} + +/** + * QueryValidatorCommissionRequest is the request type for the + * Query/ValidatorCommission RPC method + */ +export interface QueryValidatorCommissionRequest { + /** validator_address defines the validator address to query for. */ + validatorAddress: string; +} + +/** + * QueryValidatorCommissionResponse is the response type for the + * Query/ValidatorCommission RPC method + */ +export interface QueryValidatorCommissionResponse { + /** commission defines the commision the validator received. */ + commission: ValidatorAccumulatedCommission | undefined; +} + +/** + * QueryValidatorSlashesRequest is the request type for the + * Query/ValidatorSlashes RPC method + */ +export interface QueryValidatorSlashesRequest { + /** validator_address defines the validator address to query for. */ + validatorAddress: string; + /** starting_height defines the optional starting height to query the slashes. */ + startingHeight: number; + /** starting_height defines the optional ending height to query the slashes. */ + endingHeight: number; + /** pagination defines an optional pagination for the request. */ + pagination: PageRequest | undefined; +} + +/** + * QueryValidatorSlashesResponse is the response type for the + * Query/ValidatorSlashes RPC method. + */ +export interface QueryValidatorSlashesResponse { + /** slashes defines the slashes the validator received. */ + slashes: ValidatorSlashEvent[]; + /** pagination defines the pagination in the response. */ + pagination: PageResponse | undefined; +} + +/** + * QueryDelegationRewardsRequest is the request type for the + * Query/DelegationRewards RPC method. + */ +export interface QueryDelegationRewardsRequest { + /** delegator_address defines the delegator address to query for. */ + delegatorAddress: string; + /** validator_address defines the validator address to query for. */ + validatorAddress: string; +} + +/** + * QueryDelegationRewardsResponse is the response type for the + * Query/DelegationRewards RPC method. + */ +export interface QueryDelegationRewardsResponse { + /** rewards defines the rewards accrued by a delegation. */ + rewards: DecCoin[]; +} + +/** + * QueryDelegationTotalRewardsRequest is the request type for the + * Query/DelegationTotalRewards RPC method. + */ +export interface QueryDelegationTotalRewardsRequest { + /** delegator_address defines the delegator address to query for. */ + delegatorAddress: string; +} + +/** + * QueryDelegationTotalRewardsResponse is the response type for the + * Query/DelegationTotalRewards RPC method. + */ +export interface QueryDelegationTotalRewardsResponse { + /** rewards defines all the rewards accrued by a delegator. */ + rewards: DelegationDelegatorReward[]; + /** total defines the sum of all the rewards. */ + total: DecCoin[]; +} + +/** + * QueryDelegatorValidatorsRequest is the request type for the + * Query/DelegatorValidators RPC method. + */ +export interface QueryDelegatorValidatorsRequest { + /** delegator_address defines the delegator address to query for. */ + delegatorAddress: string; +} + +/** + * QueryDelegatorValidatorsResponse is the response type for the + * Query/DelegatorValidators RPC method. + */ +export interface QueryDelegatorValidatorsResponse { + /** validators defines the validators a delegator is delegating for. */ + validators: string[]; +} + +/** + * QueryDelegatorWithdrawAddressRequest is the request type for the + * Query/DelegatorWithdrawAddress RPC method. + */ +export interface QueryDelegatorWithdrawAddressRequest { + /** delegator_address defines the delegator address to query for. */ + delegatorAddress: string; +} + +/** + * QueryDelegatorWithdrawAddressResponse is the response type for the + * Query/DelegatorWithdrawAddress RPC method. + */ +export interface QueryDelegatorWithdrawAddressResponse { + /** withdraw_address defines the delegator address to query for. */ + withdrawAddress: string; +} + +/** + * QueryCommunityPoolRequest is the request type for the Query/CommunityPool RPC + * method. + */ +export interface QueryCommunityPoolRequest {} + +/** + * QueryCommunityPoolResponse is the response type for the Query/CommunityPool + * RPC method. + */ +export interface QueryCommunityPoolResponse { + /** pool defines community pool's coins. */ + pool: DecCoin[]; +} + +const baseQueryParamsRequest: object = {}; + +export const QueryParamsRequest = { + encode(_: QueryParamsRequest, writer: Writer = Writer.create()): Writer { + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QueryParamsRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryParamsRequest } as QueryParamsRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): QueryParamsRequest { + const message = { ...baseQueryParamsRequest } as QueryParamsRequest; + return message; + }, + + toJSON(_: QueryParamsRequest): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial(_: DeepPartial): QueryParamsRequest { + const message = { ...baseQueryParamsRequest } as QueryParamsRequest; + return message; + }, +}; + +const baseQueryParamsResponse: object = {}; + +export const QueryParamsResponse = { + encode( + message: QueryParamsResponse, + writer: Writer = Writer.create() + ): Writer { + if (message.params !== undefined) { + Params.encode(message.params, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QueryParamsResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryParamsResponse } as QueryParamsResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.params = Params.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryParamsResponse { + const message = { ...baseQueryParamsResponse } as QueryParamsResponse; + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromJSON(object.params); + } else { + message.params = undefined; + } + return message; + }, + + toJSON(message: QueryParamsResponse): unknown { + const obj: any = {}; + message.params !== undefined && + (obj.params = message.params ? Params.toJSON(message.params) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): QueryParamsResponse { + const message = { ...baseQueryParamsResponse } as QueryParamsResponse; + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromPartial(object.params); + } else { + message.params = undefined; + } + return message; + }, +}; + +const baseQueryValidatorOutstandingRewardsRequest: object = { + validatorAddress: "", +}; + +export const QueryValidatorOutstandingRewardsRequest = { + encode( + message: QueryValidatorOutstandingRewardsRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.validatorAddress !== "") { + writer.uint32(10).string(message.validatorAddress); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryValidatorOutstandingRewardsRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryValidatorOutstandingRewardsRequest, + } as QueryValidatorOutstandingRewardsRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.validatorAddress = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryValidatorOutstandingRewardsRequest { + const message = { + ...baseQueryValidatorOutstandingRewardsRequest, + } as QueryValidatorOutstandingRewardsRequest; + if ( + object.validatorAddress !== undefined && + object.validatorAddress !== null + ) { + message.validatorAddress = String(object.validatorAddress); + } else { + message.validatorAddress = ""; + } + return message; + }, + + toJSON(message: QueryValidatorOutstandingRewardsRequest): unknown { + const obj: any = {}; + message.validatorAddress !== undefined && + (obj.validatorAddress = message.validatorAddress); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryValidatorOutstandingRewardsRequest { + const message = { + ...baseQueryValidatorOutstandingRewardsRequest, + } as QueryValidatorOutstandingRewardsRequest; + if ( + object.validatorAddress !== undefined && + object.validatorAddress !== null + ) { + message.validatorAddress = object.validatorAddress; + } else { + message.validatorAddress = ""; + } + return message; + }, +}; + +const baseQueryValidatorOutstandingRewardsResponse: object = {}; + +export const QueryValidatorOutstandingRewardsResponse = { + encode( + message: QueryValidatorOutstandingRewardsResponse, + writer: Writer = Writer.create() + ): Writer { + if (message.rewards !== undefined) { + ValidatorOutstandingRewards.encode( + message.rewards, + writer.uint32(10).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryValidatorOutstandingRewardsResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryValidatorOutstandingRewardsResponse, + } as QueryValidatorOutstandingRewardsResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.rewards = ValidatorOutstandingRewards.decode( + reader, + reader.uint32() + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryValidatorOutstandingRewardsResponse { + const message = { + ...baseQueryValidatorOutstandingRewardsResponse, + } as QueryValidatorOutstandingRewardsResponse; + if (object.rewards !== undefined && object.rewards !== null) { + message.rewards = ValidatorOutstandingRewards.fromJSON(object.rewards); + } else { + message.rewards = undefined; + } + return message; + }, + + toJSON(message: QueryValidatorOutstandingRewardsResponse): unknown { + const obj: any = {}; + message.rewards !== undefined && + (obj.rewards = message.rewards + ? ValidatorOutstandingRewards.toJSON(message.rewards) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryValidatorOutstandingRewardsResponse { + const message = { + ...baseQueryValidatorOutstandingRewardsResponse, + } as QueryValidatorOutstandingRewardsResponse; + if (object.rewards !== undefined && object.rewards !== null) { + message.rewards = ValidatorOutstandingRewards.fromPartial(object.rewards); + } else { + message.rewards = undefined; + } + return message; + }, +}; + +const baseQueryValidatorCommissionRequest: object = { validatorAddress: "" }; + +export const QueryValidatorCommissionRequest = { + encode( + message: QueryValidatorCommissionRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.validatorAddress !== "") { + writer.uint32(10).string(message.validatorAddress); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryValidatorCommissionRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryValidatorCommissionRequest, + } as QueryValidatorCommissionRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.validatorAddress = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryValidatorCommissionRequest { + const message = { + ...baseQueryValidatorCommissionRequest, + } as QueryValidatorCommissionRequest; + if ( + object.validatorAddress !== undefined && + object.validatorAddress !== null + ) { + message.validatorAddress = String(object.validatorAddress); + } else { + message.validatorAddress = ""; + } + return message; + }, + + toJSON(message: QueryValidatorCommissionRequest): unknown { + const obj: any = {}; + message.validatorAddress !== undefined && + (obj.validatorAddress = message.validatorAddress); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryValidatorCommissionRequest { + const message = { + ...baseQueryValidatorCommissionRequest, + } as QueryValidatorCommissionRequest; + if ( + object.validatorAddress !== undefined && + object.validatorAddress !== null + ) { + message.validatorAddress = object.validatorAddress; + } else { + message.validatorAddress = ""; + } + return message; + }, +}; + +const baseQueryValidatorCommissionResponse: object = {}; + +export const QueryValidatorCommissionResponse = { + encode( + message: QueryValidatorCommissionResponse, + writer: Writer = Writer.create() + ): Writer { + if (message.commission !== undefined) { + ValidatorAccumulatedCommission.encode( + message.commission, + writer.uint32(10).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryValidatorCommissionResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryValidatorCommissionResponse, + } as QueryValidatorCommissionResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.commission = ValidatorAccumulatedCommission.decode( + reader, + reader.uint32() + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryValidatorCommissionResponse { + const message = { + ...baseQueryValidatorCommissionResponse, + } as QueryValidatorCommissionResponse; + if (object.commission !== undefined && object.commission !== null) { + message.commission = ValidatorAccumulatedCommission.fromJSON( + object.commission + ); + } else { + message.commission = undefined; + } + return message; + }, + + toJSON(message: QueryValidatorCommissionResponse): unknown { + const obj: any = {}; + message.commission !== undefined && + (obj.commission = message.commission + ? ValidatorAccumulatedCommission.toJSON(message.commission) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryValidatorCommissionResponse { + const message = { + ...baseQueryValidatorCommissionResponse, + } as QueryValidatorCommissionResponse; + if (object.commission !== undefined && object.commission !== null) { + message.commission = ValidatorAccumulatedCommission.fromPartial( + object.commission + ); + } else { + message.commission = undefined; + } + return message; + }, +}; + +const baseQueryValidatorSlashesRequest: object = { + validatorAddress: "", + startingHeight: 0, + endingHeight: 0, +}; + +export const QueryValidatorSlashesRequest = { + encode( + message: QueryValidatorSlashesRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.validatorAddress !== "") { + writer.uint32(10).string(message.validatorAddress); + } + if (message.startingHeight !== 0) { + writer.uint32(16).uint64(message.startingHeight); + } + if (message.endingHeight !== 0) { + writer.uint32(24).uint64(message.endingHeight); + } + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(34).fork()).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryValidatorSlashesRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryValidatorSlashesRequest, + } as QueryValidatorSlashesRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.validatorAddress = reader.string(); + break; + case 2: + message.startingHeight = longToNumber(reader.uint64() as Long); + break; + case 3: + message.endingHeight = longToNumber(reader.uint64() as Long); + break; + case 4: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryValidatorSlashesRequest { + const message = { + ...baseQueryValidatorSlashesRequest, + } as QueryValidatorSlashesRequest; + if ( + object.validatorAddress !== undefined && + object.validatorAddress !== null + ) { + message.validatorAddress = String(object.validatorAddress); + } else { + message.validatorAddress = ""; + } + if (object.startingHeight !== undefined && object.startingHeight !== null) { + message.startingHeight = Number(object.startingHeight); + } else { + message.startingHeight = 0; + } + if (object.endingHeight !== undefined && object.endingHeight !== null) { + message.endingHeight = Number(object.endingHeight); + } else { + message.endingHeight = 0; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryValidatorSlashesRequest): unknown { + const obj: any = {}; + message.validatorAddress !== undefined && + (obj.validatorAddress = message.validatorAddress); + message.startingHeight !== undefined && + (obj.startingHeight = message.startingHeight); + message.endingHeight !== undefined && + (obj.endingHeight = message.endingHeight); + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageRequest.toJSON(message.pagination) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryValidatorSlashesRequest { + const message = { + ...baseQueryValidatorSlashesRequest, + } as QueryValidatorSlashesRequest; + if ( + object.validatorAddress !== undefined && + object.validatorAddress !== null + ) { + message.validatorAddress = object.validatorAddress; + } else { + message.validatorAddress = ""; + } + if (object.startingHeight !== undefined && object.startingHeight !== null) { + message.startingHeight = object.startingHeight; + } else { + message.startingHeight = 0; + } + if (object.endingHeight !== undefined && object.endingHeight !== null) { + message.endingHeight = object.endingHeight; + } else { + message.endingHeight = 0; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseQueryValidatorSlashesResponse: object = {}; + +export const QueryValidatorSlashesResponse = { + encode( + message: QueryValidatorSlashesResponse, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.slashes) { + ValidatorSlashEvent.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode( + message.pagination, + writer.uint32(18).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryValidatorSlashesResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryValidatorSlashesResponse, + } as QueryValidatorSlashesResponse; + message.slashes = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.slashes.push( + ValidatorSlashEvent.decode(reader, reader.uint32()) + ); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryValidatorSlashesResponse { + const message = { + ...baseQueryValidatorSlashesResponse, + } as QueryValidatorSlashesResponse; + message.slashes = []; + if (object.slashes !== undefined && object.slashes !== null) { + for (const e of object.slashes) { + message.slashes.push(ValidatorSlashEvent.fromJSON(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryValidatorSlashesResponse): unknown { + const obj: any = {}; + if (message.slashes) { + obj.slashes = message.slashes.map((e) => + e ? ValidatorSlashEvent.toJSON(e) : undefined + ); + } else { + obj.slashes = []; + } + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageResponse.toJSON(message.pagination) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryValidatorSlashesResponse { + const message = { + ...baseQueryValidatorSlashesResponse, + } as QueryValidatorSlashesResponse; + message.slashes = []; + if (object.slashes !== undefined && object.slashes !== null) { + for (const e of object.slashes) { + message.slashes.push(ValidatorSlashEvent.fromPartial(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseQueryDelegationRewardsRequest: object = { + delegatorAddress: "", + validatorAddress: "", +}; + +export const QueryDelegationRewardsRequest = { + encode( + message: QueryDelegationRewardsRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.delegatorAddress !== "") { + writer.uint32(10).string(message.delegatorAddress); + } + if (message.validatorAddress !== "") { + writer.uint32(18).string(message.validatorAddress); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryDelegationRewardsRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryDelegationRewardsRequest, + } as QueryDelegationRewardsRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.delegatorAddress = reader.string(); + break; + case 2: + message.validatorAddress = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryDelegationRewardsRequest { + const message = { + ...baseQueryDelegationRewardsRequest, + } as QueryDelegationRewardsRequest; + if ( + object.delegatorAddress !== undefined && + object.delegatorAddress !== null + ) { + message.delegatorAddress = String(object.delegatorAddress); + } else { + message.delegatorAddress = ""; + } + if ( + object.validatorAddress !== undefined && + object.validatorAddress !== null + ) { + message.validatorAddress = String(object.validatorAddress); + } else { + message.validatorAddress = ""; + } + return message; + }, + + toJSON(message: QueryDelegationRewardsRequest): unknown { + const obj: any = {}; + message.delegatorAddress !== undefined && + (obj.delegatorAddress = message.delegatorAddress); + message.validatorAddress !== undefined && + (obj.validatorAddress = message.validatorAddress); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryDelegationRewardsRequest { + const message = { + ...baseQueryDelegationRewardsRequest, + } as QueryDelegationRewardsRequest; + if ( + object.delegatorAddress !== undefined && + object.delegatorAddress !== null + ) { + message.delegatorAddress = object.delegatorAddress; + } else { + message.delegatorAddress = ""; + } + if ( + object.validatorAddress !== undefined && + object.validatorAddress !== null + ) { + message.validatorAddress = object.validatorAddress; + } else { + message.validatorAddress = ""; + } + return message; + }, +}; + +const baseQueryDelegationRewardsResponse: object = {}; + +export const QueryDelegationRewardsResponse = { + encode( + message: QueryDelegationRewardsResponse, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.rewards) { + DecCoin.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryDelegationRewardsResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryDelegationRewardsResponse, + } as QueryDelegationRewardsResponse; + message.rewards = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.rewards.push(DecCoin.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryDelegationRewardsResponse { + const message = { + ...baseQueryDelegationRewardsResponse, + } as QueryDelegationRewardsResponse; + message.rewards = []; + if (object.rewards !== undefined && object.rewards !== null) { + for (const e of object.rewards) { + message.rewards.push(DecCoin.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: QueryDelegationRewardsResponse): unknown { + const obj: any = {}; + if (message.rewards) { + obj.rewards = message.rewards.map((e) => + e ? DecCoin.toJSON(e) : undefined + ); + } else { + obj.rewards = []; + } + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryDelegationRewardsResponse { + const message = { + ...baseQueryDelegationRewardsResponse, + } as QueryDelegationRewardsResponse; + message.rewards = []; + if (object.rewards !== undefined && object.rewards !== null) { + for (const e of object.rewards) { + message.rewards.push(DecCoin.fromPartial(e)); + } + } + return message; + }, +}; + +const baseQueryDelegationTotalRewardsRequest: object = { delegatorAddress: "" }; + +export const QueryDelegationTotalRewardsRequest = { + encode( + message: QueryDelegationTotalRewardsRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.delegatorAddress !== "") { + writer.uint32(10).string(message.delegatorAddress); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryDelegationTotalRewardsRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryDelegationTotalRewardsRequest, + } as QueryDelegationTotalRewardsRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.delegatorAddress = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryDelegationTotalRewardsRequest { + const message = { + ...baseQueryDelegationTotalRewardsRequest, + } as QueryDelegationTotalRewardsRequest; + if ( + object.delegatorAddress !== undefined && + object.delegatorAddress !== null + ) { + message.delegatorAddress = String(object.delegatorAddress); + } else { + message.delegatorAddress = ""; + } + return message; + }, + + toJSON(message: QueryDelegationTotalRewardsRequest): unknown { + const obj: any = {}; + message.delegatorAddress !== undefined && + (obj.delegatorAddress = message.delegatorAddress); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryDelegationTotalRewardsRequest { + const message = { + ...baseQueryDelegationTotalRewardsRequest, + } as QueryDelegationTotalRewardsRequest; + if ( + object.delegatorAddress !== undefined && + object.delegatorAddress !== null + ) { + message.delegatorAddress = object.delegatorAddress; + } else { + message.delegatorAddress = ""; + } + return message; + }, +}; + +const baseQueryDelegationTotalRewardsResponse: object = {}; + +export const QueryDelegationTotalRewardsResponse = { + encode( + message: QueryDelegationTotalRewardsResponse, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.rewards) { + DelegationDelegatorReward.encode(v!, writer.uint32(10).fork()).ldelim(); + } + for (const v of message.total) { + DecCoin.encode(v!, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryDelegationTotalRewardsResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryDelegationTotalRewardsResponse, + } as QueryDelegationTotalRewardsResponse; + message.rewards = []; + message.total = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.rewards.push( + DelegationDelegatorReward.decode(reader, reader.uint32()) + ); + break; + case 2: + message.total.push(DecCoin.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryDelegationTotalRewardsResponse { + const message = { + ...baseQueryDelegationTotalRewardsResponse, + } as QueryDelegationTotalRewardsResponse; + message.rewards = []; + message.total = []; + if (object.rewards !== undefined && object.rewards !== null) { + for (const e of object.rewards) { + message.rewards.push(DelegationDelegatorReward.fromJSON(e)); + } + } + if (object.total !== undefined && object.total !== null) { + for (const e of object.total) { + message.total.push(DecCoin.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: QueryDelegationTotalRewardsResponse): unknown { + const obj: any = {}; + if (message.rewards) { + obj.rewards = message.rewards.map((e) => + e ? DelegationDelegatorReward.toJSON(e) : undefined + ); + } else { + obj.rewards = []; + } + if (message.total) { + obj.total = message.total.map((e) => (e ? DecCoin.toJSON(e) : undefined)); + } else { + obj.total = []; + } + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryDelegationTotalRewardsResponse { + const message = { + ...baseQueryDelegationTotalRewardsResponse, + } as QueryDelegationTotalRewardsResponse; + message.rewards = []; + message.total = []; + if (object.rewards !== undefined && object.rewards !== null) { + for (const e of object.rewards) { + message.rewards.push(DelegationDelegatorReward.fromPartial(e)); + } + } + if (object.total !== undefined && object.total !== null) { + for (const e of object.total) { + message.total.push(DecCoin.fromPartial(e)); + } + } + return message; + }, +}; + +const baseQueryDelegatorValidatorsRequest: object = { delegatorAddress: "" }; + +export const QueryDelegatorValidatorsRequest = { + encode( + message: QueryDelegatorValidatorsRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.delegatorAddress !== "") { + writer.uint32(10).string(message.delegatorAddress); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryDelegatorValidatorsRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryDelegatorValidatorsRequest, + } as QueryDelegatorValidatorsRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.delegatorAddress = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryDelegatorValidatorsRequest { + const message = { + ...baseQueryDelegatorValidatorsRequest, + } as QueryDelegatorValidatorsRequest; + if ( + object.delegatorAddress !== undefined && + object.delegatorAddress !== null + ) { + message.delegatorAddress = String(object.delegatorAddress); + } else { + message.delegatorAddress = ""; + } + return message; + }, + + toJSON(message: QueryDelegatorValidatorsRequest): unknown { + const obj: any = {}; + message.delegatorAddress !== undefined && + (obj.delegatorAddress = message.delegatorAddress); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryDelegatorValidatorsRequest { + const message = { + ...baseQueryDelegatorValidatorsRequest, + } as QueryDelegatorValidatorsRequest; + if ( + object.delegatorAddress !== undefined && + object.delegatorAddress !== null + ) { + message.delegatorAddress = object.delegatorAddress; + } else { + message.delegatorAddress = ""; + } + return message; + }, +}; + +const baseQueryDelegatorValidatorsResponse: object = { validators: "" }; + +export const QueryDelegatorValidatorsResponse = { + encode( + message: QueryDelegatorValidatorsResponse, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.validators) { + writer.uint32(10).string(v!); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryDelegatorValidatorsResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryDelegatorValidatorsResponse, + } as QueryDelegatorValidatorsResponse; + message.validators = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.validators.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryDelegatorValidatorsResponse { + const message = { + ...baseQueryDelegatorValidatorsResponse, + } as QueryDelegatorValidatorsResponse; + message.validators = []; + if (object.validators !== undefined && object.validators !== null) { + for (const e of object.validators) { + message.validators.push(String(e)); + } + } + return message; + }, + + toJSON(message: QueryDelegatorValidatorsResponse): unknown { + const obj: any = {}; + if (message.validators) { + obj.validators = message.validators.map((e) => e); + } else { + obj.validators = []; + } + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryDelegatorValidatorsResponse { + const message = { + ...baseQueryDelegatorValidatorsResponse, + } as QueryDelegatorValidatorsResponse; + message.validators = []; + if (object.validators !== undefined && object.validators !== null) { + for (const e of object.validators) { + message.validators.push(e); + } + } + return message; + }, +}; + +const baseQueryDelegatorWithdrawAddressRequest: object = { + delegatorAddress: "", +}; + +export const QueryDelegatorWithdrawAddressRequest = { + encode( + message: QueryDelegatorWithdrawAddressRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.delegatorAddress !== "") { + writer.uint32(10).string(message.delegatorAddress); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryDelegatorWithdrawAddressRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryDelegatorWithdrawAddressRequest, + } as QueryDelegatorWithdrawAddressRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.delegatorAddress = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryDelegatorWithdrawAddressRequest { + const message = { + ...baseQueryDelegatorWithdrawAddressRequest, + } as QueryDelegatorWithdrawAddressRequest; + if ( + object.delegatorAddress !== undefined && + object.delegatorAddress !== null + ) { + message.delegatorAddress = String(object.delegatorAddress); + } else { + message.delegatorAddress = ""; + } + return message; + }, + + toJSON(message: QueryDelegatorWithdrawAddressRequest): unknown { + const obj: any = {}; + message.delegatorAddress !== undefined && + (obj.delegatorAddress = message.delegatorAddress); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryDelegatorWithdrawAddressRequest { + const message = { + ...baseQueryDelegatorWithdrawAddressRequest, + } as QueryDelegatorWithdrawAddressRequest; + if ( + object.delegatorAddress !== undefined && + object.delegatorAddress !== null + ) { + message.delegatorAddress = object.delegatorAddress; + } else { + message.delegatorAddress = ""; + } + return message; + }, +}; + +const baseQueryDelegatorWithdrawAddressResponse: object = { + withdrawAddress: "", +}; + +export const QueryDelegatorWithdrawAddressResponse = { + encode( + message: QueryDelegatorWithdrawAddressResponse, + writer: Writer = Writer.create() + ): Writer { + if (message.withdrawAddress !== "") { + writer.uint32(10).string(message.withdrawAddress); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryDelegatorWithdrawAddressResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryDelegatorWithdrawAddressResponse, + } as QueryDelegatorWithdrawAddressResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.withdrawAddress = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryDelegatorWithdrawAddressResponse { + const message = { + ...baseQueryDelegatorWithdrawAddressResponse, + } as QueryDelegatorWithdrawAddressResponse; + if ( + object.withdrawAddress !== undefined && + object.withdrawAddress !== null + ) { + message.withdrawAddress = String(object.withdrawAddress); + } else { + message.withdrawAddress = ""; + } + return message; + }, + + toJSON(message: QueryDelegatorWithdrawAddressResponse): unknown { + const obj: any = {}; + message.withdrawAddress !== undefined && + (obj.withdrawAddress = message.withdrawAddress); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryDelegatorWithdrawAddressResponse { + const message = { + ...baseQueryDelegatorWithdrawAddressResponse, + } as QueryDelegatorWithdrawAddressResponse; + if ( + object.withdrawAddress !== undefined && + object.withdrawAddress !== null + ) { + message.withdrawAddress = object.withdrawAddress; + } else { + message.withdrawAddress = ""; + } + return message; + }, +}; + +const baseQueryCommunityPoolRequest: object = {}; + +export const QueryCommunityPoolRequest = { + encode( + _: QueryCommunityPoolRequest, + writer: Writer = Writer.create() + ): Writer { + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryCommunityPoolRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryCommunityPoolRequest, + } as QueryCommunityPoolRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): QueryCommunityPoolRequest { + const message = { + ...baseQueryCommunityPoolRequest, + } as QueryCommunityPoolRequest; + return message; + }, + + toJSON(_: QueryCommunityPoolRequest): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial( + _: DeepPartial + ): QueryCommunityPoolRequest { + const message = { + ...baseQueryCommunityPoolRequest, + } as QueryCommunityPoolRequest; + return message; + }, +}; + +const baseQueryCommunityPoolResponse: object = {}; + +export const QueryCommunityPoolResponse = { + encode( + message: QueryCommunityPoolResponse, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.pool) { + DecCoin.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryCommunityPoolResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryCommunityPoolResponse, + } as QueryCommunityPoolResponse; + message.pool = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.pool.push(DecCoin.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryCommunityPoolResponse { + const message = { + ...baseQueryCommunityPoolResponse, + } as QueryCommunityPoolResponse; + message.pool = []; + if (object.pool !== undefined && object.pool !== null) { + for (const e of object.pool) { + message.pool.push(DecCoin.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: QueryCommunityPoolResponse): unknown { + const obj: any = {}; + if (message.pool) { + obj.pool = message.pool.map((e) => (e ? DecCoin.toJSON(e) : undefined)); + } else { + obj.pool = []; + } + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryCommunityPoolResponse { + const message = { + ...baseQueryCommunityPoolResponse, + } as QueryCommunityPoolResponse; + message.pool = []; + if (object.pool !== undefined && object.pool !== null) { + for (const e of object.pool) { + message.pool.push(DecCoin.fromPartial(e)); + } + } + return message; + }, +}; + +/** Query defines the gRPC querier service for distribution module. */ +export interface Query { + /** Params queries params of the distribution module. */ + Params(request: QueryParamsRequest): Promise; + /** ValidatorOutstandingRewards queries rewards of a validator address. */ + ValidatorOutstandingRewards( + request: QueryValidatorOutstandingRewardsRequest + ): Promise; + /** ValidatorCommission queries accumulated commission for a validator. */ + ValidatorCommission( + request: QueryValidatorCommissionRequest + ): Promise; + /** ValidatorSlashes queries slash events of a validator. */ + ValidatorSlashes( + request: QueryValidatorSlashesRequest + ): Promise; + /** DelegationRewards queries the total rewards accrued by a delegation. */ + DelegationRewards( + request: QueryDelegationRewardsRequest + ): Promise; + /** + * DelegationTotalRewards queries the total rewards accrued by a each + * validator. + */ + DelegationTotalRewards( + request: QueryDelegationTotalRewardsRequest + ): Promise; + /** DelegatorValidators queries the validators of a delegator. */ + DelegatorValidators( + request: QueryDelegatorValidatorsRequest + ): Promise; + /** DelegatorWithdrawAddress queries withdraw address of a delegator. */ + DelegatorWithdrawAddress( + request: QueryDelegatorWithdrawAddressRequest + ): Promise; + /** CommunityPool queries the community pool coins. */ + CommunityPool( + request: QueryCommunityPoolRequest + ): Promise; +} + +export class QueryClientImpl implements Query { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + } + Params(request: QueryParamsRequest): Promise { + const data = QueryParamsRequest.encode(request).finish(); + const promise = this.rpc.request( + "cosmos.distribution.v1beta1.Query", + "Params", + data + ); + return promise.then((data) => QueryParamsResponse.decode(new Reader(data))); + } + + ValidatorOutstandingRewards( + request: QueryValidatorOutstandingRewardsRequest + ): Promise { + const data = QueryValidatorOutstandingRewardsRequest.encode( + request + ).finish(); + const promise = this.rpc.request( + "cosmos.distribution.v1beta1.Query", + "ValidatorOutstandingRewards", + data + ); + return promise.then((data) => + QueryValidatorOutstandingRewardsResponse.decode(new Reader(data)) + ); + } + + ValidatorCommission( + request: QueryValidatorCommissionRequest + ): Promise { + const data = QueryValidatorCommissionRequest.encode(request).finish(); + const promise = this.rpc.request( + "cosmos.distribution.v1beta1.Query", + "ValidatorCommission", + data + ); + return promise.then((data) => + QueryValidatorCommissionResponse.decode(new Reader(data)) + ); + } + + ValidatorSlashes( + request: QueryValidatorSlashesRequest + ): Promise { + const data = QueryValidatorSlashesRequest.encode(request).finish(); + const promise = this.rpc.request( + "cosmos.distribution.v1beta1.Query", + "ValidatorSlashes", + data + ); + return promise.then((data) => + QueryValidatorSlashesResponse.decode(new Reader(data)) + ); + } + + DelegationRewards( + request: QueryDelegationRewardsRequest + ): Promise { + const data = QueryDelegationRewardsRequest.encode(request).finish(); + const promise = this.rpc.request( + "cosmos.distribution.v1beta1.Query", + "DelegationRewards", + data + ); + return promise.then((data) => + QueryDelegationRewardsResponse.decode(new Reader(data)) + ); + } + + DelegationTotalRewards( + request: QueryDelegationTotalRewardsRequest + ): Promise { + const data = QueryDelegationTotalRewardsRequest.encode(request).finish(); + const promise = this.rpc.request( + "cosmos.distribution.v1beta1.Query", + "DelegationTotalRewards", + data + ); + return promise.then((data) => + QueryDelegationTotalRewardsResponse.decode(new Reader(data)) + ); + } + + DelegatorValidators( + request: QueryDelegatorValidatorsRequest + ): Promise { + const data = QueryDelegatorValidatorsRequest.encode(request).finish(); + const promise = this.rpc.request( + "cosmos.distribution.v1beta1.Query", + "DelegatorValidators", + data + ); + return promise.then((data) => + QueryDelegatorValidatorsResponse.decode(new Reader(data)) + ); + } + + DelegatorWithdrawAddress( + request: QueryDelegatorWithdrawAddressRequest + ): Promise { + const data = QueryDelegatorWithdrawAddressRequest.encode(request).finish(); + const promise = this.rpc.request( + "cosmos.distribution.v1beta1.Query", + "DelegatorWithdrawAddress", + data + ); + return promise.then((data) => + QueryDelegatorWithdrawAddressResponse.decode(new Reader(data)) + ); + } + + CommunityPool( + request: QueryCommunityPoolRequest + ): Promise { + const data = QueryCommunityPoolRequest.encode(request).finish(); + const promise = this.rpc.request( + "cosmos.distribution.v1beta1.Query", + "CommunityPool", + data + ); + return promise.then((data) => + QueryCommunityPoolResponse.decode(new Reader(data)) + ); + } +} + +interface Rpc { + request( + service: string, + method: string, + data: Uint8Array + ): Promise; +} + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/cosmos.distribution.v1beta1/types/cosmos/distribution/v1beta1/tx.ts b/ts-client/cosmos.distribution.v1beta1/types/cosmos/distribution/v1beta1/tx.ts new file mode 100644 index 00000000..ac2ec164 --- /dev/null +++ b/ts-client/cosmos.distribution.v1beta1/types/cosmos/distribution/v1beta1/tx.ts @@ -0,0 +1,728 @@ +/* eslint-disable */ +import { Reader, Writer } from "protobufjs/minimal"; +import { Coin } from "../../../cosmos/base/v1beta1/coin"; + +export const protobufPackage = "cosmos.distribution.v1beta1"; + +/** + * MsgSetWithdrawAddress sets the withdraw address for + * a delegator (or validator self-delegation). + */ +export interface MsgSetWithdrawAddress { + delegatorAddress: string; + withdrawAddress: string; +} + +/** MsgSetWithdrawAddressResponse defines the Msg/SetWithdrawAddress response type. */ +export interface MsgSetWithdrawAddressResponse {} + +/** + * MsgWithdrawDelegatorReward represents delegation withdrawal to a delegator + * from a single validator. + */ +export interface MsgWithdrawDelegatorReward { + delegatorAddress: string; + validatorAddress: string; +} + +/** MsgWithdrawDelegatorRewardResponse defines the Msg/WithdrawDelegatorReward response type. */ +export interface MsgWithdrawDelegatorRewardResponse {} + +/** + * MsgWithdrawValidatorCommission withdraws the full commission to the validator + * address. + */ +export interface MsgWithdrawValidatorCommission { + validatorAddress: string; +} + +/** MsgWithdrawValidatorCommissionResponse defines the Msg/WithdrawValidatorCommission response type. */ +export interface MsgWithdrawValidatorCommissionResponse {} + +/** + * MsgFundCommunityPool allows an account to directly + * fund the community pool. + */ +export interface MsgFundCommunityPool { + amount: Coin[]; + depositor: string; +} + +/** MsgFundCommunityPoolResponse defines the Msg/FundCommunityPool response type. */ +export interface MsgFundCommunityPoolResponse {} + +const baseMsgSetWithdrawAddress: object = { + delegatorAddress: "", + withdrawAddress: "", +}; + +export const MsgSetWithdrawAddress = { + encode( + message: MsgSetWithdrawAddress, + writer: Writer = Writer.create() + ): Writer { + if (message.delegatorAddress !== "") { + writer.uint32(10).string(message.delegatorAddress); + } + if (message.withdrawAddress !== "") { + writer.uint32(18).string(message.withdrawAddress); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MsgSetWithdrawAddress { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgSetWithdrawAddress } as MsgSetWithdrawAddress; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.delegatorAddress = reader.string(); + break; + case 2: + message.withdrawAddress = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgSetWithdrawAddress { + const message = { ...baseMsgSetWithdrawAddress } as MsgSetWithdrawAddress; + if ( + object.delegatorAddress !== undefined && + object.delegatorAddress !== null + ) { + message.delegatorAddress = String(object.delegatorAddress); + } else { + message.delegatorAddress = ""; + } + if ( + object.withdrawAddress !== undefined && + object.withdrawAddress !== null + ) { + message.withdrawAddress = String(object.withdrawAddress); + } else { + message.withdrawAddress = ""; + } + return message; + }, + + toJSON(message: MsgSetWithdrawAddress): unknown { + const obj: any = {}; + message.delegatorAddress !== undefined && + (obj.delegatorAddress = message.delegatorAddress); + message.withdrawAddress !== undefined && + (obj.withdrawAddress = message.withdrawAddress); + return obj; + }, + + fromPartial( + object: DeepPartial + ): MsgSetWithdrawAddress { + const message = { ...baseMsgSetWithdrawAddress } as MsgSetWithdrawAddress; + if ( + object.delegatorAddress !== undefined && + object.delegatorAddress !== null + ) { + message.delegatorAddress = object.delegatorAddress; + } else { + message.delegatorAddress = ""; + } + if ( + object.withdrawAddress !== undefined && + object.withdrawAddress !== null + ) { + message.withdrawAddress = object.withdrawAddress; + } else { + message.withdrawAddress = ""; + } + return message; + }, +}; + +const baseMsgSetWithdrawAddressResponse: object = {}; + +export const MsgSetWithdrawAddressResponse = { + encode( + _: MsgSetWithdrawAddressResponse, + writer: Writer = Writer.create() + ): Writer { + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): MsgSetWithdrawAddressResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseMsgSetWithdrawAddressResponse, + } as MsgSetWithdrawAddressResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): MsgSetWithdrawAddressResponse { + const message = { + ...baseMsgSetWithdrawAddressResponse, + } as MsgSetWithdrawAddressResponse; + return message; + }, + + toJSON(_: MsgSetWithdrawAddressResponse): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial( + _: DeepPartial + ): MsgSetWithdrawAddressResponse { + const message = { + ...baseMsgSetWithdrawAddressResponse, + } as MsgSetWithdrawAddressResponse; + return message; + }, +}; + +const baseMsgWithdrawDelegatorReward: object = { + delegatorAddress: "", + validatorAddress: "", +}; + +export const MsgWithdrawDelegatorReward = { + encode( + message: MsgWithdrawDelegatorReward, + writer: Writer = Writer.create() + ): Writer { + if (message.delegatorAddress !== "") { + writer.uint32(10).string(message.delegatorAddress); + } + if (message.validatorAddress !== "") { + writer.uint32(18).string(message.validatorAddress); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): MsgWithdrawDelegatorReward { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseMsgWithdrawDelegatorReward, + } as MsgWithdrawDelegatorReward; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.delegatorAddress = reader.string(); + break; + case 2: + message.validatorAddress = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgWithdrawDelegatorReward { + const message = { + ...baseMsgWithdrawDelegatorReward, + } as MsgWithdrawDelegatorReward; + if ( + object.delegatorAddress !== undefined && + object.delegatorAddress !== null + ) { + message.delegatorAddress = String(object.delegatorAddress); + } else { + message.delegatorAddress = ""; + } + if ( + object.validatorAddress !== undefined && + object.validatorAddress !== null + ) { + message.validatorAddress = String(object.validatorAddress); + } else { + message.validatorAddress = ""; + } + return message; + }, + + toJSON(message: MsgWithdrawDelegatorReward): unknown { + const obj: any = {}; + message.delegatorAddress !== undefined && + (obj.delegatorAddress = message.delegatorAddress); + message.validatorAddress !== undefined && + (obj.validatorAddress = message.validatorAddress); + return obj; + }, + + fromPartial( + object: DeepPartial + ): MsgWithdrawDelegatorReward { + const message = { + ...baseMsgWithdrawDelegatorReward, + } as MsgWithdrawDelegatorReward; + if ( + object.delegatorAddress !== undefined && + object.delegatorAddress !== null + ) { + message.delegatorAddress = object.delegatorAddress; + } else { + message.delegatorAddress = ""; + } + if ( + object.validatorAddress !== undefined && + object.validatorAddress !== null + ) { + message.validatorAddress = object.validatorAddress; + } else { + message.validatorAddress = ""; + } + return message; + }, +}; + +const baseMsgWithdrawDelegatorRewardResponse: object = {}; + +export const MsgWithdrawDelegatorRewardResponse = { + encode( + _: MsgWithdrawDelegatorRewardResponse, + writer: Writer = Writer.create() + ): Writer { + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): MsgWithdrawDelegatorRewardResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseMsgWithdrawDelegatorRewardResponse, + } as MsgWithdrawDelegatorRewardResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): MsgWithdrawDelegatorRewardResponse { + const message = { + ...baseMsgWithdrawDelegatorRewardResponse, + } as MsgWithdrawDelegatorRewardResponse; + return message; + }, + + toJSON(_: MsgWithdrawDelegatorRewardResponse): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial( + _: DeepPartial + ): MsgWithdrawDelegatorRewardResponse { + const message = { + ...baseMsgWithdrawDelegatorRewardResponse, + } as MsgWithdrawDelegatorRewardResponse; + return message; + }, +}; + +const baseMsgWithdrawValidatorCommission: object = { validatorAddress: "" }; + +export const MsgWithdrawValidatorCommission = { + encode( + message: MsgWithdrawValidatorCommission, + writer: Writer = Writer.create() + ): Writer { + if (message.validatorAddress !== "") { + writer.uint32(10).string(message.validatorAddress); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): MsgWithdrawValidatorCommission { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseMsgWithdrawValidatorCommission, + } as MsgWithdrawValidatorCommission; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.validatorAddress = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgWithdrawValidatorCommission { + const message = { + ...baseMsgWithdrawValidatorCommission, + } as MsgWithdrawValidatorCommission; + if ( + object.validatorAddress !== undefined && + object.validatorAddress !== null + ) { + message.validatorAddress = String(object.validatorAddress); + } else { + message.validatorAddress = ""; + } + return message; + }, + + toJSON(message: MsgWithdrawValidatorCommission): unknown { + const obj: any = {}; + message.validatorAddress !== undefined && + (obj.validatorAddress = message.validatorAddress); + return obj; + }, + + fromPartial( + object: DeepPartial + ): MsgWithdrawValidatorCommission { + const message = { + ...baseMsgWithdrawValidatorCommission, + } as MsgWithdrawValidatorCommission; + if ( + object.validatorAddress !== undefined && + object.validatorAddress !== null + ) { + message.validatorAddress = object.validatorAddress; + } else { + message.validatorAddress = ""; + } + return message; + }, +}; + +const baseMsgWithdrawValidatorCommissionResponse: object = {}; + +export const MsgWithdrawValidatorCommissionResponse = { + encode( + _: MsgWithdrawValidatorCommissionResponse, + writer: Writer = Writer.create() + ): Writer { + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): MsgWithdrawValidatorCommissionResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseMsgWithdrawValidatorCommissionResponse, + } as MsgWithdrawValidatorCommissionResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): MsgWithdrawValidatorCommissionResponse { + const message = { + ...baseMsgWithdrawValidatorCommissionResponse, + } as MsgWithdrawValidatorCommissionResponse; + return message; + }, + + toJSON(_: MsgWithdrawValidatorCommissionResponse): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial( + _: DeepPartial + ): MsgWithdrawValidatorCommissionResponse { + const message = { + ...baseMsgWithdrawValidatorCommissionResponse, + } as MsgWithdrawValidatorCommissionResponse; + return message; + }, +}; + +const baseMsgFundCommunityPool: object = { depositor: "" }; + +export const MsgFundCommunityPool = { + encode( + message: MsgFundCommunityPool, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.amount) { + Coin.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.depositor !== "") { + writer.uint32(18).string(message.depositor); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MsgFundCommunityPool { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgFundCommunityPool } as MsgFundCommunityPool; + message.amount = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.amount.push(Coin.decode(reader, reader.uint32())); + break; + case 2: + message.depositor = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgFundCommunityPool { + const message = { ...baseMsgFundCommunityPool } as MsgFundCommunityPool; + message.amount = []; + if (object.amount !== undefined && object.amount !== null) { + for (const e of object.amount) { + message.amount.push(Coin.fromJSON(e)); + } + } + if (object.depositor !== undefined && object.depositor !== null) { + message.depositor = String(object.depositor); + } else { + message.depositor = ""; + } + return message; + }, + + toJSON(message: MsgFundCommunityPool): unknown { + const obj: any = {}; + if (message.amount) { + obj.amount = message.amount.map((e) => (e ? Coin.toJSON(e) : undefined)); + } else { + obj.amount = []; + } + message.depositor !== undefined && (obj.depositor = message.depositor); + return obj; + }, + + fromPartial(object: DeepPartial): MsgFundCommunityPool { + const message = { ...baseMsgFundCommunityPool } as MsgFundCommunityPool; + message.amount = []; + if (object.amount !== undefined && object.amount !== null) { + for (const e of object.amount) { + message.amount.push(Coin.fromPartial(e)); + } + } + if (object.depositor !== undefined && object.depositor !== null) { + message.depositor = object.depositor; + } else { + message.depositor = ""; + } + return message; + }, +}; + +const baseMsgFundCommunityPoolResponse: object = {}; + +export const MsgFundCommunityPoolResponse = { + encode( + _: MsgFundCommunityPoolResponse, + writer: Writer = Writer.create() + ): Writer { + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): MsgFundCommunityPoolResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseMsgFundCommunityPoolResponse, + } as MsgFundCommunityPoolResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): MsgFundCommunityPoolResponse { + const message = { + ...baseMsgFundCommunityPoolResponse, + } as MsgFundCommunityPoolResponse; + return message; + }, + + toJSON(_: MsgFundCommunityPoolResponse): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial( + _: DeepPartial + ): MsgFundCommunityPoolResponse { + const message = { + ...baseMsgFundCommunityPoolResponse, + } as MsgFundCommunityPoolResponse; + return message; + }, +}; + +/** Msg defines the distribution Msg service. */ +export interface Msg { + /** + * SetWithdrawAddress defines a method to change the withdraw address + * for a delegator (or validator self-delegation). + */ + SetWithdrawAddress( + request: MsgSetWithdrawAddress + ): Promise; + /** + * WithdrawDelegatorReward defines a method to withdraw rewards of delegator + * from a single validator. + */ + WithdrawDelegatorReward( + request: MsgWithdrawDelegatorReward + ): Promise; + /** + * WithdrawValidatorCommission defines a method to withdraw the + * full commission to the validator address. + */ + WithdrawValidatorCommission( + request: MsgWithdrawValidatorCommission + ): Promise; + /** + * FundCommunityPool defines a method to allow an account to directly + * fund the community pool. + */ + FundCommunityPool( + request: MsgFundCommunityPool + ): Promise; +} + +export class MsgClientImpl implements Msg { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + } + SetWithdrawAddress( + request: MsgSetWithdrawAddress + ): Promise { + const data = MsgSetWithdrawAddress.encode(request).finish(); + const promise = this.rpc.request( + "cosmos.distribution.v1beta1.Msg", + "SetWithdrawAddress", + data + ); + return promise.then((data) => + MsgSetWithdrawAddressResponse.decode(new Reader(data)) + ); + } + + WithdrawDelegatorReward( + request: MsgWithdrawDelegatorReward + ): Promise { + const data = MsgWithdrawDelegatorReward.encode(request).finish(); + const promise = this.rpc.request( + "cosmos.distribution.v1beta1.Msg", + "WithdrawDelegatorReward", + data + ); + return promise.then((data) => + MsgWithdrawDelegatorRewardResponse.decode(new Reader(data)) + ); + } + + WithdrawValidatorCommission( + request: MsgWithdrawValidatorCommission + ): Promise { + const data = MsgWithdrawValidatorCommission.encode(request).finish(); + const promise = this.rpc.request( + "cosmos.distribution.v1beta1.Msg", + "WithdrawValidatorCommission", + data + ); + return promise.then((data) => + MsgWithdrawValidatorCommissionResponse.decode(new Reader(data)) + ); + } + + FundCommunityPool( + request: MsgFundCommunityPool + ): Promise { + const data = MsgFundCommunityPool.encode(request).finish(); + const promise = this.rpc.request( + "cosmos.distribution.v1beta1.Msg", + "FundCommunityPool", + data + ); + return promise.then((data) => + MsgFundCommunityPoolResponse.decode(new Reader(data)) + ); + } +} + +interface Rpc { + request( + service: string, + method: string, + data: Uint8Array + ): Promise; +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/cosmos.distribution.v1beta1/types/gogoproto/gogo.ts b/ts-client/cosmos.distribution.v1beta1/types/gogoproto/gogo.ts new file mode 100644 index 00000000..3f41a047 --- /dev/null +++ b/ts-client/cosmos.distribution.v1beta1/types/gogoproto/gogo.ts @@ -0,0 +1,2 @@ +/* eslint-disable */ +export const protobufPackage = "gogoproto"; diff --git a/ts-client/cosmos.distribution.v1beta1/types/google/api/annotations.ts b/ts-client/cosmos.distribution.v1beta1/types/google/api/annotations.ts new file mode 100644 index 00000000..aace4787 --- /dev/null +++ b/ts-client/cosmos.distribution.v1beta1/types/google/api/annotations.ts @@ -0,0 +1,2 @@ +/* eslint-disable */ +export const protobufPackage = "google.api"; diff --git a/ts-client/cosmos.distribution.v1beta1/types/google/api/http.ts b/ts-client/cosmos.distribution.v1beta1/types/google/api/http.ts new file mode 100644 index 00000000..ddc00f8b --- /dev/null +++ b/ts-client/cosmos.distribution.v1beta1/types/google/api/http.ts @@ -0,0 +1,705 @@ +/* eslint-disable */ +import { Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "google.api"; + +/** + * Defines the HTTP configuration for an API service. It contains a list of + * [HttpRule][google.api.HttpRule], each specifying the mapping of an RPC method + * to one or more HTTP REST API methods. + */ +export interface Http { + /** + * A list of HTTP configuration rules that apply to individual API methods. + * + * **NOTE:** All service configuration rules follow "last one wins" order. + */ + rules: HttpRule[]; + /** + * When set to true, URL path parmeters will be fully URI-decoded except in + * cases of single segment matches in reserved expansion, where "%2F" will be + * left encoded. + * + * The default behavior is to not decode RFC 6570 reserved characters in multi + * segment matches. + */ + fullyDecodeReservedExpansion: boolean; +} + +/** + * `HttpRule` defines the mapping of an RPC method to one or more HTTP + * REST API methods. The mapping specifies how different portions of the RPC + * request message are mapped to URL path, URL query parameters, and + * HTTP request body. The mapping is typically specified as an + * `google.api.http` annotation on the RPC method, + * see "google/api/annotations.proto" for details. + * + * The mapping consists of a field specifying the path template and + * method kind. The path template can refer to fields in the request + * message, as in the example below which describes a REST GET + * operation on a resource collection of messages: + * + * + * service Messaging { + * rpc GetMessage(GetMessageRequest) returns (Message) { + * option (google.api.http).get = "/v1/messages/{message_id}/{sub.subfield}"; + * } + * } + * message GetMessageRequest { + * message SubMessage { + * string subfield = 1; + * } + * string message_id = 1; // mapped to the URL + * SubMessage sub = 2; // `sub.subfield` is url-mapped + * } + * message Message { + * string text = 1; // content of the resource + * } + * + * The same http annotation can alternatively be expressed inside the + * `GRPC API Configuration` YAML file. + * + * http: + * rules: + * - selector: .Messaging.GetMessage + * get: /v1/messages/{message_id}/{sub.subfield} + * + * This definition enables an automatic, bidrectional mapping of HTTP + * JSON to RPC. Example: + * + * HTTP | RPC + * -----|----- + * `GET /v1/messages/123456/foo` | `GetMessage(message_id: "123456" sub: SubMessage(subfield: "foo"))` + * + * In general, not only fields but also field paths can be referenced + * from a path pattern. Fields mapped to the path pattern cannot be + * repeated and must have a primitive (non-message) type. + * + * Any fields in the request message which are not bound by the path + * pattern automatically become (optional) HTTP query + * parameters. Assume the following definition of the request message: + * + * + * service Messaging { + * rpc GetMessage(GetMessageRequest) returns (Message) { + * option (google.api.http).get = "/v1/messages/{message_id}"; + * } + * } + * message GetMessageRequest { + * message SubMessage { + * string subfield = 1; + * } + * string message_id = 1; // mapped to the URL + * int64 revision = 2; // becomes a parameter + * SubMessage sub = 3; // `sub.subfield` becomes a parameter + * } + * + * + * This enables a HTTP JSON to RPC mapping as below: + * + * HTTP | RPC + * -----|----- + * `GET /v1/messages/123456?revision=2&sub.subfield=foo` | `GetMessage(message_id: "123456" revision: 2 sub: SubMessage(subfield: "foo"))` + * + * Note that fields which are mapped to HTTP parameters must have a + * primitive type or a repeated primitive type. Message types are not + * allowed. In the case of a repeated type, the parameter can be + * repeated in the URL, as in `...?param=A¶m=B`. + * + * For HTTP method kinds which allow a request body, the `body` field + * specifies the mapping. Consider a REST update method on the + * message resource collection: + * + * + * service Messaging { + * rpc UpdateMessage(UpdateMessageRequest) returns (Message) { + * option (google.api.http) = { + * put: "/v1/messages/{message_id}" + * body: "message" + * }; + * } + * } + * message UpdateMessageRequest { + * string message_id = 1; // mapped to the URL + * Message message = 2; // mapped to the body + * } + * + * + * The following HTTP JSON to RPC mapping is enabled, where the + * representation of the JSON in the request body is determined by + * protos JSON encoding: + * + * HTTP | RPC + * -----|----- + * `PUT /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: "123456" message { text: "Hi!" })` + * + * The special name `*` can be used in the body mapping to define that + * every field not bound by the path template should be mapped to the + * request body. This enables the following alternative definition of + * the update method: + * + * service Messaging { + * rpc UpdateMessage(Message) returns (Message) { + * option (google.api.http) = { + * put: "/v1/messages/{message_id}" + * body: "*" + * }; + * } + * } + * message Message { + * string message_id = 1; + * string text = 2; + * } + * + * + * The following HTTP JSON to RPC mapping is enabled: + * + * HTTP | RPC + * -----|----- + * `PUT /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: "123456" text: "Hi!")` + * + * Note that when using `*` in the body mapping, it is not possible to + * have HTTP parameters, as all fields not bound by the path end in + * the body. This makes this option more rarely used in practice of + * defining REST APIs. The common usage of `*` is in custom methods + * which don't use the URL at all for transferring data. + * + * It is possible to define multiple HTTP methods for one RPC by using + * the `additional_bindings` option. Example: + * + * service Messaging { + * rpc GetMessage(GetMessageRequest) returns (Message) { + * option (google.api.http) = { + * get: "/v1/messages/{message_id}" + * additional_bindings { + * get: "/v1/users/{user_id}/messages/{message_id}" + * } + * }; + * } + * } + * message GetMessageRequest { + * string message_id = 1; + * string user_id = 2; + * } + * + * + * This enables the following two alternative HTTP JSON to RPC + * mappings: + * + * HTTP | RPC + * -----|----- + * `GET /v1/messages/123456` | `GetMessage(message_id: "123456")` + * `GET /v1/users/me/messages/123456` | `GetMessage(user_id: "me" message_id: "123456")` + * + * # Rules for HTTP mapping + * + * The rules for mapping HTTP path, query parameters, and body fields + * to the request message are as follows: + * + * 1. The `body` field specifies either `*` or a field path, or is + * omitted. If omitted, it indicates there is no HTTP request body. + * 2. Leaf fields (recursive expansion of nested messages in the + * request) can be classified into three types: + * (a) Matched in the URL template. + * (b) Covered by body (if body is `*`, everything except (a) fields; + * else everything under the body field) + * (c) All other fields. + * 3. URL query parameters found in the HTTP request are mapped to (c) fields. + * 4. Any body sent with an HTTP request can contain only (b) fields. + * + * The syntax of the path template is as follows: + * + * Template = "/" Segments [ Verb ] ; + * Segments = Segment { "/" Segment } ; + * Segment = "*" | "**" | LITERAL | Variable ; + * Variable = "{" FieldPath [ "=" Segments ] "}" ; + * FieldPath = IDENT { "." IDENT } ; + * Verb = ":" LITERAL ; + * + * The syntax `*` matches a single path segment. The syntax `**` matches zero + * or more path segments, which must be the last part of the path except the + * `Verb`. The syntax `LITERAL` matches literal text in the path. + * + * The syntax `Variable` matches part of the URL path as specified by its + * template. A variable template must not contain other variables. If a variable + * matches a single path segment, its template may be omitted, e.g. `{var}` + * is equivalent to `{var=*}`. + * + * If a variable contains exactly one path segment, such as `"{var}"` or + * `"{var=*}"`, when such a variable is expanded into a URL path, all characters + * except `[-_.~0-9a-zA-Z]` are percent-encoded. Such variables show up in the + * Discovery Document as `{var}`. + * + * If a variable contains one or more path segments, such as `"{var=foo/*}"` + * or `"{var=**}"`, when such a variable is expanded into a URL path, all + * characters except `[-_.~/0-9a-zA-Z]` are percent-encoded. Such variables + * show up in the Discovery Document as `{+var}`. + * + * NOTE: While the single segment variable matches the semantics of + * [RFC 6570](https://tools.ietf.org/html/rfc6570) Section 3.2.2 + * Simple String Expansion, the multi segment variable **does not** match + * RFC 6570 Reserved Expansion. The reason is that the Reserved Expansion + * does not expand special characters like `?` and `#`, which would lead + * to invalid URLs. + * + * NOTE: the field paths in variables and in the `body` must not refer to + * repeated fields or map fields. + */ +export interface HttpRule { + /** + * Selects methods to which this rule applies. + * + * Refer to [selector][google.api.DocumentationRule.selector] for syntax details. + */ + selector: string; + /** Used for listing and getting information about resources. */ + get: string | undefined; + /** Used for updating a resource. */ + put: string | undefined; + /** Used for creating a resource. */ + post: string | undefined; + /** Used for deleting a resource. */ + delete: string | undefined; + /** Used for updating a resource. */ + patch: string | undefined; + /** + * The custom pattern is used for specifying an HTTP method that is not + * included in the `pattern` field, such as HEAD, or "*" to leave the + * HTTP method unspecified for this rule. The wild-card rule is useful + * for services that provide content to Web (HTML) clients. + */ + custom: CustomHttpPattern | undefined; + /** + * The name of the request field whose value is mapped to the HTTP body, or + * `*` for mapping all fields not captured by the path pattern to the HTTP + * body. NOTE: the referred field must not be a repeated field and must be + * present at the top-level of request message type. + */ + body: string; + /** + * Optional. The name of the response field whose value is mapped to the HTTP + * body of response. Other response fields are ignored. When + * not set, the response message will be used as HTTP body of response. + */ + responseBody: string; + /** + * Additional HTTP bindings for the selector. Nested bindings must + * not contain an `additional_bindings` field themselves (that is, + * the nesting may only be one level deep). + */ + additionalBindings: HttpRule[]; +} + +/** A custom pattern is used for defining custom HTTP verb. */ +export interface CustomHttpPattern { + /** The name of this custom HTTP verb. */ + kind: string; + /** The path matched by this custom verb. */ + path: string; +} + +const baseHttp: object = { fullyDecodeReservedExpansion: false }; + +export const Http = { + encode(message: Http, writer: Writer = Writer.create()): Writer { + for (const v of message.rules) { + HttpRule.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.fullyDecodeReservedExpansion === true) { + writer.uint32(16).bool(message.fullyDecodeReservedExpansion); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Http { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseHttp } as Http; + message.rules = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.rules.push(HttpRule.decode(reader, reader.uint32())); + break; + case 2: + message.fullyDecodeReservedExpansion = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Http { + const message = { ...baseHttp } as Http; + message.rules = []; + if (object.rules !== undefined && object.rules !== null) { + for (const e of object.rules) { + message.rules.push(HttpRule.fromJSON(e)); + } + } + if ( + object.fullyDecodeReservedExpansion !== undefined && + object.fullyDecodeReservedExpansion !== null + ) { + message.fullyDecodeReservedExpansion = Boolean( + object.fullyDecodeReservedExpansion + ); + } else { + message.fullyDecodeReservedExpansion = false; + } + return message; + }, + + toJSON(message: Http): unknown { + const obj: any = {}; + if (message.rules) { + obj.rules = message.rules.map((e) => + e ? HttpRule.toJSON(e) : undefined + ); + } else { + obj.rules = []; + } + message.fullyDecodeReservedExpansion !== undefined && + (obj.fullyDecodeReservedExpansion = message.fullyDecodeReservedExpansion); + return obj; + }, + + fromPartial(object: DeepPartial): Http { + const message = { ...baseHttp } as Http; + message.rules = []; + if (object.rules !== undefined && object.rules !== null) { + for (const e of object.rules) { + message.rules.push(HttpRule.fromPartial(e)); + } + } + if ( + object.fullyDecodeReservedExpansion !== undefined && + object.fullyDecodeReservedExpansion !== null + ) { + message.fullyDecodeReservedExpansion = + object.fullyDecodeReservedExpansion; + } else { + message.fullyDecodeReservedExpansion = false; + } + return message; + }, +}; + +const baseHttpRule: object = { selector: "", body: "", responseBody: "" }; + +export const HttpRule = { + encode(message: HttpRule, writer: Writer = Writer.create()): Writer { + if (message.selector !== "") { + writer.uint32(10).string(message.selector); + } + if (message.get !== undefined) { + writer.uint32(18).string(message.get); + } + if (message.put !== undefined) { + writer.uint32(26).string(message.put); + } + if (message.post !== undefined) { + writer.uint32(34).string(message.post); + } + if (message.delete !== undefined) { + writer.uint32(42).string(message.delete); + } + if (message.patch !== undefined) { + writer.uint32(50).string(message.patch); + } + if (message.custom !== undefined) { + CustomHttpPattern.encode( + message.custom, + writer.uint32(66).fork() + ).ldelim(); + } + if (message.body !== "") { + writer.uint32(58).string(message.body); + } + if (message.responseBody !== "") { + writer.uint32(98).string(message.responseBody); + } + for (const v of message.additionalBindings) { + HttpRule.encode(v!, writer.uint32(90).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): HttpRule { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseHttpRule } as HttpRule; + message.additionalBindings = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.selector = reader.string(); + break; + case 2: + message.get = reader.string(); + break; + case 3: + message.put = reader.string(); + break; + case 4: + message.post = reader.string(); + break; + case 5: + message.delete = reader.string(); + break; + case 6: + message.patch = reader.string(); + break; + case 8: + message.custom = CustomHttpPattern.decode(reader, reader.uint32()); + break; + case 7: + message.body = reader.string(); + break; + case 12: + message.responseBody = reader.string(); + break; + case 11: + message.additionalBindings.push( + HttpRule.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): HttpRule { + const message = { ...baseHttpRule } as HttpRule; + message.additionalBindings = []; + if (object.selector !== undefined && object.selector !== null) { + message.selector = String(object.selector); + } else { + message.selector = ""; + } + if (object.get !== undefined && object.get !== null) { + message.get = String(object.get); + } else { + message.get = undefined; + } + if (object.put !== undefined && object.put !== null) { + message.put = String(object.put); + } else { + message.put = undefined; + } + if (object.post !== undefined && object.post !== null) { + message.post = String(object.post); + } else { + message.post = undefined; + } + if (object.delete !== undefined && object.delete !== null) { + message.delete = String(object.delete); + } else { + message.delete = undefined; + } + if (object.patch !== undefined && object.patch !== null) { + message.patch = String(object.patch); + } else { + message.patch = undefined; + } + if (object.custom !== undefined && object.custom !== null) { + message.custom = CustomHttpPattern.fromJSON(object.custom); + } else { + message.custom = undefined; + } + if (object.body !== undefined && object.body !== null) { + message.body = String(object.body); + } else { + message.body = ""; + } + if (object.responseBody !== undefined && object.responseBody !== null) { + message.responseBody = String(object.responseBody); + } else { + message.responseBody = ""; + } + if ( + object.additionalBindings !== undefined && + object.additionalBindings !== null + ) { + for (const e of object.additionalBindings) { + message.additionalBindings.push(HttpRule.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: HttpRule): unknown { + const obj: any = {}; + message.selector !== undefined && (obj.selector = message.selector); + message.get !== undefined && (obj.get = message.get); + message.put !== undefined && (obj.put = message.put); + message.post !== undefined && (obj.post = message.post); + message.delete !== undefined && (obj.delete = message.delete); + message.patch !== undefined && (obj.patch = message.patch); + message.custom !== undefined && + (obj.custom = message.custom + ? CustomHttpPattern.toJSON(message.custom) + : undefined); + message.body !== undefined && (obj.body = message.body); + message.responseBody !== undefined && + (obj.responseBody = message.responseBody); + if (message.additionalBindings) { + obj.additionalBindings = message.additionalBindings.map((e) => + e ? HttpRule.toJSON(e) : undefined + ); + } else { + obj.additionalBindings = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): HttpRule { + const message = { ...baseHttpRule } as HttpRule; + message.additionalBindings = []; + if (object.selector !== undefined && object.selector !== null) { + message.selector = object.selector; + } else { + message.selector = ""; + } + if (object.get !== undefined && object.get !== null) { + message.get = object.get; + } else { + message.get = undefined; + } + if (object.put !== undefined && object.put !== null) { + message.put = object.put; + } else { + message.put = undefined; + } + if (object.post !== undefined && object.post !== null) { + message.post = object.post; + } else { + message.post = undefined; + } + if (object.delete !== undefined && object.delete !== null) { + message.delete = object.delete; + } else { + message.delete = undefined; + } + if (object.patch !== undefined && object.patch !== null) { + message.patch = object.patch; + } else { + message.patch = undefined; + } + if (object.custom !== undefined && object.custom !== null) { + message.custom = CustomHttpPattern.fromPartial(object.custom); + } else { + message.custom = undefined; + } + if (object.body !== undefined && object.body !== null) { + message.body = object.body; + } else { + message.body = ""; + } + if (object.responseBody !== undefined && object.responseBody !== null) { + message.responseBody = object.responseBody; + } else { + message.responseBody = ""; + } + if ( + object.additionalBindings !== undefined && + object.additionalBindings !== null + ) { + for (const e of object.additionalBindings) { + message.additionalBindings.push(HttpRule.fromPartial(e)); + } + } + return message; + }, +}; + +const baseCustomHttpPattern: object = { kind: "", path: "" }; + +export const CustomHttpPattern = { + encode(message: CustomHttpPattern, writer: Writer = Writer.create()): Writer { + if (message.kind !== "") { + writer.uint32(10).string(message.kind); + } + if (message.path !== "") { + writer.uint32(18).string(message.path); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): CustomHttpPattern { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseCustomHttpPattern } as CustomHttpPattern; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.kind = reader.string(); + break; + case 2: + message.path = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): CustomHttpPattern { + const message = { ...baseCustomHttpPattern } as CustomHttpPattern; + if (object.kind !== undefined && object.kind !== null) { + message.kind = String(object.kind); + } else { + message.kind = ""; + } + if (object.path !== undefined && object.path !== null) { + message.path = String(object.path); + } else { + message.path = ""; + } + return message; + }, + + toJSON(message: CustomHttpPattern): unknown { + const obj: any = {}; + message.kind !== undefined && (obj.kind = message.kind); + message.path !== undefined && (obj.path = message.path); + return obj; + }, + + fromPartial(object: DeepPartial): CustomHttpPattern { + const message = { ...baseCustomHttpPattern } as CustomHttpPattern; + if (object.kind !== undefined && object.kind !== null) { + message.kind = object.kind; + } else { + message.kind = ""; + } + if (object.path !== undefined && object.path !== null) { + message.path = object.path; + } else { + message.path = ""; + } + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/cosmos.distribution.v1beta1/types/google/protobuf/descriptor.ts b/ts-client/cosmos.distribution.v1beta1/types/google/protobuf/descriptor.ts new file mode 100644 index 00000000..9e508660 --- /dev/null +++ b/ts-client/cosmos.distribution.v1beta1/types/google/protobuf/descriptor.ts @@ -0,0 +1,5261 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "google.protobuf"; + +/** + * The protocol compiler can output a FileDescriptorSet containing the .proto + * files it parses. + */ +export interface FileDescriptorSet { + file: FileDescriptorProto[]; +} + +/** Describes a complete .proto file. */ +export interface FileDescriptorProto { + /** file name, relative to root of source tree */ + name: string; + /** e.g. "foo", "foo.bar", etc. */ + package: string; + /** Names of files imported by this file. */ + dependency: string[]; + /** Indexes of the public imported files in the dependency list above. */ + publicDependency: number[]; + /** + * Indexes of the weak imported files in the dependency list. + * For Google-internal migration only. Do not use. + */ + weakDependency: number[]; + /** All top-level definitions in this file. */ + messageType: DescriptorProto[]; + enumType: EnumDescriptorProto[]; + service: ServiceDescriptorProto[]; + extension: FieldDescriptorProto[]; + options: FileOptions | undefined; + /** + * This field contains optional information about the original source code. + * You may safely remove this entire field without harming runtime + * functionality of the descriptors -- the information is needed only by + * development tools. + */ + sourceCodeInfo: SourceCodeInfo | undefined; + /** + * The syntax of the proto file. + * The supported values are "proto2" and "proto3". + */ + syntax: string; +} + +/** Describes a message type. */ +export interface DescriptorProto { + name: string; + field: FieldDescriptorProto[]; + extension: FieldDescriptorProto[]; + nestedType: DescriptorProto[]; + enumType: EnumDescriptorProto[]; + extensionRange: DescriptorProto_ExtensionRange[]; + oneofDecl: OneofDescriptorProto[]; + options: MessageOptions | undefined; + reservedRange: DescriptorProto_ReservedRange[]; + /** + * Reserved field names, which may not be used by fields in the same message. + * A given name may only be reserved once. + */ + reservedName: string[]; +} + +export interface DescriptorProto_ExtensionRange { + /** Inclusive. */ + start: number; + /** Exclusive. */ + end: number; + options: ExtensionRangeOptions | undefined; +} + +/** + * Range of reserved tag numbers. Reserved tag numbers may not be used by + * fields or extension ranges in the same message. Reserved ranges may + * not overlap. + */ +export interface DescriptorProto_ReservedRange { + /** Inclusive. */ + start: number; + /** Exclusive. */ + end: number; +} + +export interface ExtensionRangeOptions { + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +/** Describes a field within a message. */ +export interface FieldDescriptorProto { + name: string; + number: number; + label: FieldDescriptorProto_Label; + /** + * If type_name is set, this need not be set. If both this and type_name + * are set, this must be one of TYPE_ENUM, TYPE_MESSAGE or TYPE_GROUP. + */ + type: FieldDescriptorProto_Type; + /** + * For message and enum types, this is the name of the type. If the name + * starts with a '.', it is fully-qualified. Otherwise, C++-like scoping + * rules are used to find the type (i.e. first the nested types within this + * message are searched, then within the parent, on up to the root + * namespace). + */ + typeName: string; + /** + * For extensions, this is the name of the type being extended. It is + * resolved in the same manner as type_name. + */ + extendee: string; + /** + * For numeric types, contains the original text representation of the value. + * For booleans, "true" or "false". + * For strings, contains the default text contents (not escaped in any way). + * For bytes, contains the C escaped value. All bytes >= 128 are escaped. + * TODO(kenton): Base-64 encode? + */ + defaultValue: string; + /** + * If set, gives the index of a oneof in the containing type's oneof_decl + * list. This field is a member of that oneof. + */ + oneofIndex: number; + /** + * JSON name of this field. The value is set by protocol compiler. If the + * user has set a "json_name" option on this field, that option's value + * will be used. Otherwise, it's deduced from the field's name by converting + * it to camelCase. + */ + jsonName: string; + options: FieldOptions | undefined; + /** + * If true, this is a proto3 "optional". When a proto3 field is optional, it + * tracks presence regardless of field type. + * + * When proto3_optional is true, this field must be belong to a oneof to + * signal to old proto3 clients that presence is tracked for this field. This + * oneof is known as a "synthetic" oneof, and this field must be its sole + * member (each proto3 optional field gets its own synthetic oneof). Synthetic + * oneofs exist in the descriptor only, and do not generate any API. Synthetic + * oneofs must be ordered after all "real" oneofs. + * + * For message fields, proto3_optional doesn't create any semantic change, + * since non-repeated message fields always track presence. However it still + * indicates the semantic detail of whether the user wrote "optional" or not. + * This can be useful for round-tripping the .proto file. For consistency we + * give message fields a synthetic oneof also, even though it is not required + * to track presence. This is especially important because the parser can't + * tell if a field is a message or an enum, so it must always create a + * synthetic oneof. + * + * Proto2 optional fields do not set this flag, because they already indicate + * optional with `LABEL_OPTIONAL`. + */ + proto3Optional: boolean; +} + +export enum FieldDescriptorProto_Type { + /** + * TYPE_DOUBLE - 0 is reserved for errors. + * Order is weird for historical reasons. + */ + TYPE_DOUBLE = 1, + TYPE_FLOAT = 2, + /** + * TYPE_INT64 - Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT64 if + * negative values are likely. + */ + TYPE_INT64 = 3, + TYPE_UINT64 = 4, + /** + * TYPE_INT32 - Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT32 if + * negative values are likely. + */ + TYPE_INT32 = 5, + TYPE_FIXED64 = 6, + TYPE_FIXED32 = 7, + TYPE_BOOL = 8, + TYPE_STRING = 9, + /** + * TYPE_GROUP - Tag-delimited aggregate. + * Group type is deprecated and not supported in proto3. However, Proto3 + * implementations should still be able to parse the group wire format and + * treat group fields as unknown fields. + */ + TYPE_GROUP = 10, + /** TYPE_MESSAGE - Length-delimited aggregate. */ + TYPE_MESSAGE = 11, + /** TYPE_BYTES - New in version 2. */ + TYPE_BYTES = 12, + TYPE_UINT32 = 13, + TYPE_ENUM = 14, + TYPE_SFIXED32 = 15, + TYPE_SFIXED64 = 16, + /** TYPE_SINT32 - Uses ZigZag encoding. */ + TYPE_SINT32 = 17, + /** TYPE_SINT64 - Uses ZigZag encoding. */ + TYPE_SINT64 = 18, + UNRECOGNIZED = -1, +} + +export function fieldDescriptorProto_TypeFromJSON( + object: any +): FieldDescriptorProto_Type { + switch (object) { + case 1: + case "TYPE_DOUBLE": + return FieldDescriptorProto_Type.TYPE_DOUBLE; + case 2: + case "TYPE_FLOAT": + return FieldDescriptorProto_Type.TYPE_FLOAT; + case 3: + case "TYPE_INT64": + return FieldDescriptorProto_Type.TYPE_INT64; + case 4: + case "TYPE_UINT64": + return FieldDescriptorProto_Type.TYPE_UINT64; + case 5: + case "TYPE_INT32": + return FieldDescriptorProto_Type.TYPE_INT32; + case 6: + case "TYPE_FIXED64": + return FieldDescriptorProto_Type.TYPE_FIXED64; + case 7: + case "TYPE_FIXED32": + return FieldDescriptorProto_Type.TYPE_FIXED32; + case 8: + case "TYPE_BOOL": + return FieldDescriptorProto_Type.TYPE_BOOL; + case 9: + case "TYPE_STRING": + return FieldDescriptorProto_Type.TYPE_STRING; + case 10: + case "TYPE_GROUP": + return FieldDescriptorProto_Type.TYPE_GROUP; + case 11: + case "TYPE_MESSAGE": + return FieldDescriptorProto_Type.TYPE_MESSAGE; + case 12: + case "TYPE_BYTES": + return FieldDescriptorProto_Type.TYPE_BYTES; + case 13: + case "TYPE_UINT32": + return FieldDescriptorProto_Type.TYPE_UINT32; + case 14: + case "TYPE_ENUM": + return FieldDescriptorProto_Type.TYPE_ENUM; + case 15: + case "TYPE_SFIXED32": + return FieldDescriptorProto_Type.TYPE_SFIXED32; + case 16: + case "TYPE_SFIXED64": + return FieldDescriptorProto_Type.TYPE_SFIXED64; + case 17: + case "TYPE_SINT32": + return FieldDescriptorProto_Type.TYPE_SINT32; + case 18: + case "TYPE_SINT64": + return FieldDescriptorProto_Type.TYPE_SINT64; + case -1: + case "UNRECOGNIZED": + default: + return FieldDescriptorProto_Type.UNRECOGNIZED; + } +} + +export function fieldDescriptorProto_TypeToJSON( + object: FieldDescriptorProto_Type +): string { + switch (object) { + case FieldDescriptorProto_Type.TYPE_DOUBLE: + return "TYPE_DOUBLE"; + case FieldDescriptorProto_Type.TYPE_FLOAT: + return "TYPE_FLOAT"; + case FieldDescriptorProto_Type.TYPE_INT64: + return "TYPE_INT64"; + case FieldDescriptorProto_Type.TYPE_UINT64: + return "TYPE_UINT64"; + case FieldDescriptorProto_Type.TYPE_INT32: + return "TYPE_INT32"; + case FieldDescriptorProto_Type.TYPE_FIXED64: + return "TYPE_FIXED64"; + case FieldDescriptorProto_Type.TYPE_FIXED32: + return "TYPE_FIXED32"; + case FieldDescriptorProto_Type.TYPE_BOOL: + return "TYPE_BOOL"; + case FieldDescriptorProto_Type.TYPE_STRING: + return "TYPE_STRING"; + case FieldDescriptorProto_Type.TYPE_GROUP: + return "TYPE_GROUP"; + case FieldDescriptorProto_Type.TYPE_MESSAGE: + return "TYPE_MESSAGE"; + case FieldDescriptorProto_Type.TYPE_BYTES: + return "TYPE_BYTES"; + case FieldDescriptorProto_Type.TYPE_UINT32: + return "TYPE_UINT32"; + case FieldDescriptorProto_Type.TYPE_ENUM: + return "TYPE_ENUM"; + case FieldDescriptorProto_Type.TYPE_SFIXED32: + return "TYPE_SFIXED32"; + case FieldDescriptorProto_Type.TYPE_SFIXED64: + return "TYPE_SFIXED64"; + case FieldDescriptorProto_Type.TYPE_SINT32: + return "TYPE_SINT32"; + case FieldDescriptorProto_Type.TYPE_SINT64: + return "TYPE_SINT64"; + default: + return "UNKNOWN"; + } +} + +export enum FieldDescriptorProto_Label { + /** LABEL_OPTIONAL - 0 is reserved for errors */ + LABEL_OPTIONAL = 1, + LABEL_REQUIRED = 2, + LABEL_REPEATED = 3, + UNRECOGNIZED = -1, +} + +export function fieldDescriptorProto_LabelFromJSON( + object: any +): FieldDescriptorProto_Label { + switch (object) { + case 1: + case "LABEL_OPTIONAL": + return FieldDescriptorProto_Label.LABEL_OPTIONAL; + case 2: + case "LABEL_REQUIRED": + return FieldDescriptorProto_Label.LABEL_REQUIRED; + case 3: + case "LABEL_REPEATED": + return FieldDescriptorProto_Label.LABEL_REPEATED; + case -1: + case "UNRECOGNIZED": + default: + return FieldDescriptorProto_Label.UNRECOGNIZED; + } +} + +export function fieldDescriptorProto_LabelToJSON( + object: FieldDescriptorProto_Label +): string { + switch (object) { + case FieldDescriptorProto_Label.LABEL_OPTIONAL: + return "LABEL_OPTIONAL"; + case FieldDescriptorProto_Label.LABEL_REQUIRED: + return "LABEL_REQUIRED"; + case FieldDescriptorProto_Label.LABEL_REPEATED: + return "LABEL_REPEATED"; + default: + return "UNKNOWN"; + } +} + +/** Describes a oneof. */ +export interface OneofDescriptorProto { + name: string; + options: OneofOptions | undefined; +} + +/** Describes an enum type. */ +export interface EnumDescriptorProto { + name: string; + value: EnumValueDescriptorProto[]; + options: EnumOptions | undefined; + /** + * Range of reserved numeric values. Reserved numeric values may not be used + * by enum values in the same enum declaration. Reserved ranges may not + * overlap. + */ + reservedRange: EnumDescriptorProto_EnumReservedRange[]; + /** + * Reserved enum value names, which may not be reused. A given name may only + * be reserved once. + */ + reservedName: string[]; +} + +/** + * Range of reserved numeric values. Reserved values may not be used by + * entries in the same enum. Reserved ranges may not overlap. + * + * Note that this is distinct from DescriptorProto.ReservedRange in that it + * is inclusive such that it can appropriately represent the entire int32 + * domain. + */ +export interface EnumDescriptorProto_EnumReservedRange { + /** Inclusive. */ + start: number; + /** Inclusive. */ + end: number; +} + +/** Describes a value within an enum. */ +export interface EnumValueDescriptorProto { + name: string; + number: number; + options: EnumValueOptions | undefined; +} + +/** Describes a service. */ +export interface ServiceDescriptorProto { + name: string; + method: MethodDescriptorProto[]; + options: ServiceOptions | undefined; +} + +/** Describes a method of a service. */ +export interface MethodDescriptorProto { + name: string; + /** + * Input and output type names. These are resolved in the same way as + * FieldDescriptorProto.type_name, but must refer to a message type. + */ + inputType: string; + outputType: string; + options: MethodOptions | undefined; + /** Identifies if client streams multiple client messages */ + clientStreaming: boolean; + /** Identifies if server streams multiple server messages */ + serverStreaming: boolean; +} + +export interface FileOptions { + /** + * Sets the Java package where classes generated from this .proto will be + * placed. By default, the proto package is used, but this is often + * inappropriate because proto packages do not normally start with backwards + * domain names. + */ + javaPackage: string; + /** + * Controls the name of the wrapper Java class generated for the .proto file. + * That class will always contain the .proto file's getDescriptor() method as + * well as any top-level extensions defined in the .proto file. + * If java_multiple_files is disabled, then all the other classes from the + * .proto file will be nested inside the single wrapper outer class. + */ + javaOuterClassname: string; + /** + * If enabled, then the Java code generator will generate a separate .java + * file for each top-level message, enum, and service defined in the .proto + * file. Thus, these types will *not* be nested inside the wrapper class + * named by java_outer_classname. However, the wrapper class will still be + * generated to contain the file's getDescriptor() method as well as any + * top-level extensions defined in the file. + */ + javaMultipleFiles: boolean; + /** + * This option does nothing. + * + * @deprecated + */ + javaGenerateEqualsAndHash: boolean; + /** + * If set true, then the Java2 code generator will generate code that + * throws an exception whenever an attempt is made to assign a non-UTF-8 + * byte sequence to a string field. + * Message reflection will do the same. + * However, an extension field still accepts non-UTF-8 byte sequences. + * This option has no effect on when used with the lite runtime. + */ + javaStringCheckUtf8: boolean; + optimizeFor: FileOptions_OptimizeMode; + /** + * Sets the Go package where structs generated from this .proto will be + * placed. If omitted, the Go package will be derived from the following: + * - The basename of the package import path, if provided. + * - Otherwise, the package statement in the .proto file, if present. + * - Otherwise, the basename of the .proto file, without extension. + */ + goPackage: string; + /** + * Should generic services be generated in each language? "Generic" services + * are not specific to any particular RPC system. They are generated by the + * main code generators in each language (without additional plugins). + * Generic services were the only kind of service generation supported by + * early versions of google.protobuf. + * + * Generic services are now considered deprecated in favor of using plugins + * that generate code specific to your particular RPC system. Therefore, + * these default to false. Old code which depends on generic services should + * explicitly set them to true. + */ + ccGenericServices: boolean; + javaGenericServices: boolean; + pyGenericServices: boolean; + phpGenericServices: boolean; + /** + * Is this file deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for everything in the file, or it will be completely ignored; in the very + * least, this is a formalization for deprecating files. + */ + deprecated: boolean; + /** + * Enables the use of arenas for the proto messages in this file. This applies + * only to generated classes for C++. + */ + ccEnableArenas: boolean; + /** + * Sets the objective c class prefix which is prepended to all objective c + * generated classes from this .proto. There is no default. + */ + objcClassPrefix: string; + /** Namespace for generated classes; defaults to the package. */ + csharpNamespace: string; + /** + * By default Swift generators will take the proto package and CamelCase it + * replacing '.' with underscore and use that to prefix the types/symbols + * defined. When this options is provided, they will use this value instead + * to prefix the types/symbols defined. + */ + swiftPrefix: string; + /** + * Sets the php class prefix which is prepended to all php generated classes + * from this .proto. Default is empty. + */ + phpClassPrefix: string; + /** + * Use this option to change the namespace of php generated classes. Default + * is empty. When this option is empty, the package name will be used for + * determining the namespace. + */ + phpNamespace: string; + /** + * Use this option to change the namespace of php generated metadata classes. + * Default is empty. When this option is empty, the proto file name will be + * used for determining the namespace. + */ + phpMetadataNamespace: string; + /** + * Use this option to change the package of ruby generated classes. Default + * is empty. When this option is not set, the package name will be used for + * determining the ruby package. + */ + rubyPackage: string; + /** + * The parser stores options it doesn't recognize here. + * See the documentation for the "Options" section above. + */ + uninterpretedOption: UninterpretedOption[]; +} + +/** Generated classes can be optimized for speed or code size. */ +export enum FileOptions_OptimizeMode { + /** SPEED - Generate complete code for parsing, serialization, */ + SPEED = 1, + /** CODE_SIZE - etc. */ + CODE_SIZE = 2, + /** LITE_RUNTIME - Generate code using MessageLite and the lite runtime. */ + LITE_RUNTIME = 3, + UNRECOGNIZED = -1, +} + +export function fileOptions_OptimizeModeFromJSON( + object: any +): FileOptions_OptimizeMode { + switch (object) { + case 1: + case "SPEED": + return FileOptions_OptimizeMode.SPEED; + case 2: + case "CODE_SIZE": + return FileOptions_OptimizeMode.CODE_SIZE; + case 3: + case "LITE_RUNTIME": + return FileOptions_OptimizeMode.LITE_RUNTIME; + case -1: + case "UNRECOGNIZED": + default: + return FileOptions_OptimizeMode.UNRECOGNIZED; + } +} + +export function fileOptions_OptimizeModeToJSON( + object: FileOptions_OptimizeMode +): string { + switch (object) { + case FileOptions_OptimizeMode.SPEED: + return "SPEED"; + case FileOptions_OptimizeMode.CODE_SIZE: + return "CODE_SIZE"; + case FileOptions_OptimizeMode.LITE_RUNTIME: + return "LITE_RUNTIME"; + default: + return "UNKNOWN"; + } +} + +export interface MessageOptions { + /** + * Set true to use the old proto1 MessageSet wire format for extensions. + * This is provided for backwards-compatibility with the MessageSet wire + * format. You should not use this for any other reason: It's less + * efficient, has fewer features, and is more complicated. + * + * The message must be defined exactly as follows: + * message Foo { + * option message_set_wire_format = true; + * extensions 4 to max; + * } + * Note that the message cannot have any defined fields; MessageSets only + * have extensions. + * + * All extensions of your type must be singular messages; e.g. they cannot + * be int32s, enums, or repeated messages. + * + * Because this is an option, the above two restrictions are not enforced by + * the protocol compiler. + */ + messageSetWireFormat: boolean; + /** + * Disables the generation of the standard "descriptor()" accessor, which can + * conflict with a field of the same name. This is meant to make migration + * from proto1 easier; new code should avoid fields named "descriptor". + */ + noStandardDescriptorAccessor: boolean; + /** + * Is this message deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the message, or it will be completely ignored; in the very least, + * this is a formalization for deprecating messages. + */ + deprecated: boolean; + /** + * Whether the message is an automatically generated map entry type for the + * maps field. + * + * For maps fields: + * map map_field = 1; + * The parsed descriptor looks like: + * message MapFieldEntry { + * option map_entry = true; + * optional KeyType key = 1; + * optional ValueType value = 2; + * } + * repeated MapFieldEntry map_field = 1; + * + * Implementations may choose not to generate the map_entry=true message, but + * use a native map in the target language to hold the keys and values. + * The reflection APIs in such implementations still need to work as + * if the field is a repeated message field. + * + * NOTE: Do not set the option in .proto files. Always use the maps syntax + * instead. The option should only be implicitly set by the proto compiler + * parser. + */ + mapEntry: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface FieldOptions { + /** + * The ctype option instructs the C++ code generator to use a different + * representation of the field than it normally would. See the specific + * options below. This option is not yet implemented in the open source + * release -- sorry, we'll try to include it in a future version! + */ + ctype: FieldOptions_CType; + /** + * The packed option can be enabled for repeated primitive fields to enable + * a more efficient representation on the wire. Rather than repeatedly + * writing the tag and type for each element, the entire array is encoded as + * a single length-delimited blob. In proto3, only explicit setting it to + * false will avoid using packed encoding. + */ + packed: boolean; + /** + * The jstype option determines the JavaScript type used for values of the + * field. The option is permitted only for 64 bit integral and fixed types + * (int64, uint64, sint64, fixed64, sfixed64). A field with jstype JS_STRING + * is represented as JavaScript string, which avoids loss of precision that + * can happen when a large value is converted to a floating point JavaScript. + * Specifying JS_NUMBER for the jstype causes the generated JavaScript code to + * use the JavaScript "number" type. The behavior of the default option + * JS_NORMAL is implementation dependent. + * + * This option is an enum to permit additional types to be added, e.g. + * goog.math.Integer. + */ + jstype: FieldOptions_JSType; + /** + * Should this field be parsed lazily? Lazy applies only to message-type + * fields. It means that when the outer message is initially parsed, the + * inner message's contents will not be parsed but instead stored in encoded + * form. The inner message will actually be parsed when it is first accessed. + * + * This is only a hint. Implementations are free to choose whether to use + * eager or lazy parsing regardless of the value of this option. However, + * setting this option true suggests that the protocol author believes that + * using lazy parsing on this field is worth the additional bookkeeping + * overhead typically needed to implement it. + * + * This option does not affect the public interface of any generated code; + * all method signatures remain the same. Furthermore, thread-safety of the + * interface is not affected by this option; const methods remain safe to + * call from multiple threads concurrently, while non-const methods continue + * to require exclusive access. + * + * + * Note that implementations may choose not to check required fields within + * a lazy sub-message. That is, calling IsInitialized() on the outer message + * may return true even if the inner message has missing required fields. + * This is necessary because otherwise the inner message would have to be + * parsed in order to perform the check, defeating the purpose of lazy + * parsing. An implementation which chooses not to check required fields + * must be consistent about it. That is, for any particular sub-message, the + * implementation must either *always* check its required fields, or *never* + * check its required fields, regardless of whether or not the message has + * been parsed. + */ + lazy: boolean; + /** + * Is this field deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for accessors, or it will be completely ignored; in the very least, this + * is a formalization for deprecating fields. + */ + deprecated: boolean; + /** For Google-internal migration only. Do not use. */ + weak: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export enum FieldOptions_CType { + /** STRING - Default mode. */ + STRING = 0, + CORD = 1, + STRING_PIECE = 2, + UNRECOGNIZED = -1, +} + +export function fieldOptions_CTypeFromJSON(object: any): FieldOptions_CType { + switch (object) { + case 0: + case "STRING": + return FieldOptions_CType.STRING; + case 1: + case "CORD": + return FieldOptions_CType.CORD; + case 2: + case "STRING_PIECE": + return FieldOptions_CType.STRING_PIECE; + case -1: + case "UNRECOGNIZED": + default: + return FieldOptions_CType.UNRECOGNIZED; + } +} + +export function fieldOptions_CTypeToJSON(object: FieldOptions_CType): string { + switch (object) { + case FieldOptions_CType.STRING: + return "STRING"; + case FieldOptions_CType.CORD: + return "CORD"; + case FieldOptions_CType.STRING_PIECE: + return "STRING_PIECE"; + default: + return "UNKNOWN"; + } +} + +export enum FieldOptions_JSType { + /** JS_NORMAL - Use the default type. */ + JS_NORMAL = 0, + /** JS_STRING - Use JavaScript strings. */ + JS_STRING = 1, + /** JS_NUMBER - Use JavaScript numbers. */ + JS_NUMBER = 2, + UNRECOGNIZED = -1, +} + +export function fieldOptions_JSTypeFromJSON(object: any): FieldOptions_JSType { + switch (object) { + case 0: + case "JS_NORMAL": + return FieldOptions_JSType.JS_NORMAL; + case 1: + case "JS_STRING": + return FieldOptions_JSType.JS_STRING; + case 2: + case "JS_NUMBER": + return FieldOptions_JSType.JS_NUMBER; + case -1: + case "UNRECOGNIZED": + default: + return FieldOptions_JSType.UNRECOGNIZED; + } +} + +export function fieldOptions_JSTypeToJSON(object: FieldOptions_JSType): string { + switch (object) { + case FieldOptions_JSType.JS_NORMAL: + return "JS_NORMAL"; + case FieldOptions_JSType.JS_STRING: + return "JS_STRING"; + case FieldOptions_JSType.JS_NUMBER: + return "JS_NUMBER"; + default: + return "UNKNOWN"; + } +} + +export interface OneofOptions { + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface EnumOptions { + /** + * Set this option to true to allow mapping different tag names to the same + * value. + */ + allowAlias: boolean; + /** + * Is this enum deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the enum, or it will be completely ignored; in the very least, this + * is a formalization for deprecating enums. + */ + deprecated: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface EnumValueOptions { + /** + * Is this enum value deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the enum value, or it will be completely ignored; in the very least, + * this is a formalization for deprecating enum values. + */ + deprecated: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface ServiceOptions { + /** + * Is this service deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the service, or it will be completely ignored; in the very least, + * this is a formalization for deprecating services. + */ + deprecated: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface MethodOptions { + /** + * Is this method deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the method, or it will be completely ignored; in the very least, + * this is a formalization for deprecating methods. + */ + deprecated: boolean; + idempotencyLevel: MethodOptions_IdempotencyLevel; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +/** + * Is this method side-effect-free (or safe in HTTP parlance), or idempotent, + * or neither? HTTP based RPC implementation may choose GET verb for safe + * methods, and PUT verb for idempotent methods instead of the default POST. + */ +export enum MethodOptions_IdempotencyLevel { + IDEMPOTENCY_UNKNOWN = 0, + /** NO_SIDE_EFFECTS - implies idempotent */ + NO_SIDE_EFFECTS = 1, + /** IDEMPOTENT - idempotent, but may have side effects */ + IDEMPOTENT = 2, + UNRECOGNIZED = -1, +} + +export function methodOptions_IdempotencyLevelFromJSON( + object: any +): MethodOptions_IdempotencyLevel { + switch (object) { + case 0: + case "IDEMPOTENCY_UNKNOWN": + return MethodOptions_IdempotencyLevel.IDEMPOTENCY_UNKNOWN; + case 1: + case "NO_SIDE_EFFECTS": + return MethodOptions_IdempotencyLevel.NO_SIDE_EFFECTS; + case 2: + case "IDEMPOTENT": + return MethodOptions_IdempotencyLevel.IDEMPOTENT; + case -1: + case "UNRECOGNIZED": + default: + return MethodOptions_IdempotencyLevel.UNRECOGNIZED; + } +} + +export function methodOptions_IdempotencyLevelToJSON( + object: MethodOptions_IdempotencyLevel +): string { + switch (object) { + case MethodOptions_IdempotencyLevel.IDEMPOTENCY_UNKNOWN: + return "IDEMPOTENCY_UNKNOWN"; + case MethodOptions_IdempotencyLevel.NO_SIDE_EFFECTS: + return "NO_SIDE_EFFECTS"; + case MethodOptions_IdempotencyLevel.IDEMPOTENT: + return "IDEMPOTENT"; + default: + return "UNKNOWN"; + } +} + +/** + * A message representing a option the parser does not recognize. This only + * appears in options protos created by the compiler::Parser class. + * DescriptorPool resolves these when building Descriptor objects. Therefore, + * options protos in descriptor objects (e.g. returned by Descriptor::options(), + * or produced by Descriptor::CopyTo()) will never have UninterpretedOptions + * in them. + */ +export interface UninterpretedOption { + name: UninterpretedOption_NamePart[]; + /** + * The value of the uninterpreted option, in whatever type the tokenizer + * identified it as during parsing. Exactly one of these should be set. + */ + identifierValue: string; + positiveIntValue: number; + negativeIntValue: number; + doubleValue: number; + stringValue: Uint8Array; + aggregateValue: string; +} + +/** + * The name of the uninterpreted option. Each string represents a segment in + * a dot-separated name. is_extension is true iff a segment represents an + * extension (denoted with parentheses in options specs in .proto files). + * E.g.,{ ["foo", false], ["bar.baz", true], ["qux", false] } represents + * "foo.(bar.baz).qux". + */ +export interface UninterpretedOption_NamePart { + namePart: string; + isExtension: boolean; +} + +/** + * Encapsulates information about the original source file from which a + * FileDescriptorProto was generated. + */ +export interface SourceCodeInfo { + /** + * A Location identifies a piece of source code in a .proto file which + * corresponds to a particular definition. This information is intended + * to be useful to IDEs, code indexers, documentation generators, and similar + * tools. + * + * For example, say we have a file like: + * message Foo { + * optional string foo = 1; + * } + * Let's look at just the field definition: + * optional string foo = 1; + * ^ ^^ ^^ ^ ^^^ + * a bc de f ghi + * We have the following locations: + * span path represents + * [a,i) [ 4, 0, 2, 0 ] The whole field definition. + * [a,b) [ 4, 0, 2, 0, 4 ] The label (optional). + * [c,d) [ 4, 0, 2, 0, 5 ] The type (string). + * [e,f) [ 4, 0, 2, 0, 1 ] The name (foo). + * [g,h) [ 4, 0, 2, 0, 3 ] The number (1). + * + * Notes: + * - A location may refer to a repeated field itself (i.e. not to any + * particular index within it). This is used whenever a set of elements are + * logically enclosed in a single code segment. For example, an entire + * extend block (possibly containing multiple extension definitions) will + * have an outer location whose path refers to the "extensions" repeated + * field without an index. + * - Multiple locations may have the same path. This happens when a single + * logical declaration is spread out across multiple places. The most + * obvious example is the "extend" block again -- there may be multiple + * extend blocks in the same scope, each of which will have the same path. + * - A location's span is not always a subset of its parent's span. For + * example, the "extendee" of an extension declaration appears at the + * beginning of the "extend" block and is shared by all extensions within + * the block. + * - Just because a location's span is a subset of some other location's span + * does not mean that it is a descendant. For example, a "group" defines + * both a type and a field in a single declaration. Thus, the locations + * corresponding to the type and field and their components will overlap. + * - Code which tries to interpret locations should probably be designed to + * ignore those that it doesn't understand, as more types of locations could + * be recorded in the future. + */ + location: SourceCodeInfo_Location[]; +} + +export interface SourceCodeInfo_Location { + /** + * Identifies which part of the FileDescriptorProto was defined at this + * location. + * + * Each element is a field number or an index. They form a path from + * the root FileDescriptorProto to the place where the definition. For + * example, this path: + * [ 4, 3, 2, 7, 1 ] + * refers to: + * file.message_type(3) // 4, 3 + * .field(7) // 2, 7 + * .name() // 1 + * This is because FileDescriptorProto.message_type has field number 4: + * repeated DescriptorProto message_type = 4; + * and DescriptorProto.field has field number 2: + * repeated FieldDescriptorProto field = 2; + * and FieldDescriptorProto.name has field number 1: + * optional string name = 1; + * + * Thus, the above path gives the location of a field name. If we removed + * the last element: + * [ 4, 3, 2, 7 ] + * this path refers to the whole field declaration (from the beginning + * of the label to the terminating semicolon). + */ + path: number[]; + /** + * Always has exactly three or four elements: start line, start column, + * end line (optional, otherwise assumed same as start line), end column. + * These are packed into a single field for efficiency. Note that line + * and column numbers are zero-based -- typically you will want to add + * 1 to each before displaying to a user. + */ + span: number[]; + /** + * If this SourceCodeInfo represents a complete declaration, these are any + * comments appearing before and after the declaration which appear to be + * attached to the declaration. + * + * A series of line comments appearing on consecutive lines, with no other + * tokens appearing on those lines, will be treated as a single comment. + * + * leading_detached_comments will keep paragraphs of comments that appear + * before (but not connected to) the current element. Each paragraph, + * separated by empty lines, will be one comment element in the repeated + * field. + * + * Only the comment content is provided; comment markers (e.g. //) are + * stripped out. For block comments, leading whitespace and an asterisk + * will be stripped from the beginning of each line other than the first. + * Newlines are included in the output. + * + * Examples: + * + * optional int32 foo = 1; // Comment attached to foo. + * // Comment attached to bar. + * optional int32 bar = 2; + * + * optional string baz = 3; + * // Comment attached to baz. + * // Another line attached to baz. + * + * // Comment attached to qux. + * // + * // Another line attached to qux. + * optional double qux = 4; + * + * // Detached comment for corge. This is not leading or trailing comments + * // to qux or corge because there are blank lines separating it from + * // both. + * + * // Detached comment for corge paragraph 2. + * + * optional string corge = 5; + * /* Block comment attached + * * to corge. Leading asterisks + * * will be removed. * / + * /* Block comment attached to + * * grault. * / + * optional int32 grault = 6; + * + * // ignored detached comments. + */ + leadingComments: string; + trailingComments: string; + leadingDetachedComments: string[]; +} + +/** + * Describes the relationship between generated code and its original source + * file. A GeneratedCodeInfo message is associated with only one generated + * source file, but may contain references to different source .proto files. + */ +export interface GeneratedCodeInfo { + /** + * An Annotation connects some span of text in generated code to an element + * of its generating .proto file. + */ + annotation: GeneratedCodeInfo_Annotation[]; +} + +export interface GeneratedCodeInfo_Annotation { + /** + * Identifies the element in the original source .proto file. This field + * is formatted the same as SourceCodeInfo.Location.path. + */ + path: number[]; + /** Identifies the filesystem path to the original source .proto. */ + sourceFile: string; + /** + * Identifies the starting offset in bytes in the generated code + * that relates to the identified object. + */ + begin: number; + /** + * Identifies the ending offset in bytes in the generated code that + * relates to the identified offset. The end offset should be one past + * the last relevant byte (so the length of the text = end - begin). + */ + end: number; +} + +const baseFileDescriptorSet: object = {}; + +export const FileDescriptorSet = { + encode(message: FileDescriptorSet, writer: Writer = Writer.create()): Writer { + for (const v of message.file) { + FileDescriptorProto.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FileDescriptorSet { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFileDescriptorSet } as FileDescriptorSet; + message.file = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.file.push( + FileDescriptorProto.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FileDescriptorSet { + const message = { ...baseFileDescriptorSet } as FileDescriptorSet; + message.file = []; + if (object.file !== undefined && object.file !== null) { + for (const e of object.file) { + message.file.push(FileDescriptorProto.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: FileDescriptorSet): unknown { + const obj: any = {}; + if (message.file) { + obj.file = message.file.map((e) => + e ? FileDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.file = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): FileDescriptorSet { + const message = { ...baseFileDescriptorSet } as FileDescriptorSet; + message.file = []; + if (object.file !== undefined && object.file !== null) { + for (const e of object.file) { + message.file.push(FileDescriptorProto.fromPartial(e)); + } + } + return message; + }, +}; + +const baseFileDescriptorProto: object = { + name: "", + package: "", + dependency: "", + publicDependency: 0, + weakDependency: 0, + syntax: "", +}; + +export const FileDescriptorProto = { + encode( + message: FileDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.package !== "") { + writer.uint32(18).string(message.package); + } + for (const v of message.dependency) { + writer.uint32(26).string(v!); + } + writer.uint32(82).fork(); + for (const v of message.publicDependency) { + writer.int32(v); + } + writer.ldelim(); + writer.uint32(90).fork(); + for (const v of message.weakDependency) { + writer.int32(v); + } + writer.ldelim(); + for (const v of message.messageType) { + DescriptorProto.encode(v!, writer.uint32(34).fork()).ldelim(); + } + for (const v of message.enumType) { + EnumDescriptorProto.encode(v!, writer.uint32(42).fork()).ldelim(); + } + for (const v of message.service) { + ServiceDescriptorProto.encode(v!, writer.uint32(50).fork()).ldelim(); + } + for (const v of message.extension) { + FieldDescriptorProto.encode(v!, writer.uint32(58).fork()).ldelim(); + } + if (message.options !== undefined) { + FileOptions.encode(message.options, writer.uint32(66).fork()).ldelim(); + } + if (message.sourceCodeInfo !== undefined) { + SourceCodeInfo.encode( + message.sourceCodeInfo, + writer.uint32(74).fork() + ).ldelim(); + } + if (message.syntax !== "") { + writer.uint32(98).string(message.syntax); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FileDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFileDescriptorProto } as FileDescriptorProto; + message.dependency = []; + message.publicDependency = []; + message.weakDependency = []; + message.messageType = []; + message.enumType = []; + message.service = []; + message.extension = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.package = reader.string(); + break; + case 3: + message.dependency.push(reader.string()); + break; + case 10: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.publicDependency.push(reader.int32()); + } + } else { + message.publicDependency.push(reader.int32()); + } + break; + case 11: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.weakDependency.push(reader.int32()); + } + } else { + message.weakDependency.push(reader.int32()); + } + break; + case 4: + message.messageType.push( + DescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 5: + message.enumType.push( + EnumDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 6: + message.service.push( + ServiceDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 7: + message.extension.push( + FieldDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 8: + message.options = FileOptions.decode(reader, reader.uint32()); + break; + case 9: + message.sourceCodeInfo = SourceCodeInfo.decode( + reader, + reader.uint32() + ); + break; + case 12: + message.syntax = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FileDescriptorProto { + const message = { ...baseFileDescriptorProto } as FileDescriptorProto; + message.dependency = []; + message.publicDependency = []; + message.weakDependency = []; + message.messageType = []; + message.enumType = []; + message.service = []; + message.extension = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.package !== undefined && object.package !== null) { + message.package = String(object.package); + } else { + message.package = ""; + } + if (object.dependency !== undefined && object.dependency !== null) { + for (const e of object.dependency) { + message.dependency.push(String(e)); + } + } + if ( + object.publicDependency !== undefined && + object.publicDependency !== null + ) { + for (const e of object.publicDependency) { + message.publicDependency.push(Number(e)); + } + } + if (object.weakDependency !== undefined && object.weakDependency !== null) { + for (const e of object.weakDependency) { + message.weakDependency.push(Number(e)); + } + } + if (object.messageType !== undefined && object.messageType !== null) { + for (const e of object.messageType) { + message.messageType.push(DescriptorProto.fromJSON(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromJSON(e)); + } + } + if (object.service !== undefined && object.service !== null) { + for (const e of object.service) { + message.service.push(ServiceDescriptorProto.fromJSON(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = FileOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.sourceCodeInfo !== undefined && object.sourceCodeInfo !== null) { + message.sourceCodeInfo = SourceCodeInfo.fromJSON(object.sourceCodeInfo); + } else { + message.sourceCodeInfo = undefined; + } + if (object.syntax !== undefined && object.syntax !== null) { + message.syntax = String(object.syntax); + } else { + message.syntax = ""; + } + return message; + }, + + toJSON(message: FileDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.package !== undefined && (obj.package = message.package); + if (message.dependency) { + obj.dependency = message.dependency.map((e) => e); + } else { + obj.dependency = []; + } + if (message.publicDependency) { + obj.publicDependency = message.publicDependency.map((e) => e); + } else { + obj.publicDependency = []; + } + if (message.weakDependency) { + obj.weakDependency = message.weakDependency.map((e) => e); + } else { + obj.weakDependency = []; + } + if (message.messageType) { + obj.messageType = message.messageType.map((e) => + e ? DescriptorProto.toJSON(e) : undefined + ); + } else { + obj.messageType = []; + } + if (message.enumType) { + obj.enumType = message.enumType.map((e) => + e ? EnumDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.enumType = []; + } + if (message.service) { + obj.service = message.service.map((e) => + e ? ServiceDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.service = []; + } + if (message.extension) { + obj.extension = message.extension.map((e) => + e ? FieldDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.extension = []; + } + message.options !== undefined && + (obj.options = message.options + ? FileOptions.toJSON(message.options) + : undefined); + message.sourceCodeInfo !== undefined && + (obj.sourceCodeInfo = message.sourceCodeInfo + ? SourceCodeInfo.toJSON(message.sourceCodeInfo) + : undefined); + message.syntax !== undefined && (obj.syntax = message.syntax); + return obj; + }, + + fromPartial(object: DeepPartial): FileDescriptorProto { + const message = { ...baseFileDescriptorProto } as FileDescriptorProto; + message.dependency = []; + message.publicDependency = []; + message.weakDependency = []; + message.messageType = []; + message.enumType = []; + message.service = []; + message.extension = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.package !== undefined && object.package !== null) { + message.package = object.package; + } else { + message.package = ""; + } + if (object.dependency !== undefined && object.dependency !== null) { + for (const e of object.dependency) { + message.dependency.push(e); + } + } + if ( + object.publicDependency !== undefined && + object.publicDependency !== null + ) { + for (const e of object.publicDependency) { + message.publicDependency.push(e); + } + } + if (object.weakDependency !== undefined && object.weakDependency !== null) { + for (const e of object.weakDependency) { + message.weakDependency.push(e); + } + } + if (object.messageType !== undefined && object.messageType !== null) { + for (const e of object.messageType) { + message.messageType.push(DescriptorProto.fromPartial(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromPartial(e)); + } + } + if (object.service !== undefined && object.service !== null) { + for (const e of object.service) { + message.service.push(ServiceDescriptorProto.fromPartial(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = FileOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.sourceCodeInfo !== undefined && object.sourceCodeInfo !== null) { + message.sourceCodeInfo = SourceCodeInfo.fromPartial( + object.sourceCodeInfo + ); + } else { + message.sourceCodeInfo = undefined; + } + if (object.syntax !== undefined && object.syntax !== null) { + message.syntax = object.syntax; + } else { + message.syntax = ""; + } + return message; + }, +}; + +const baseDescriptorProto: object = { name: "", reservedName: "" }; + +export const DescriptorProto = { + encode(message: DescriptorProto, writer: Writer = Writer.create()): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + for (const v of message.field) { + FieldDescriptorProto.encode(v!, writer.uint32(18).fork()).ldelim(); + } + for (const v of message.extension) { + FieldDescriptorProto.encode(v!, writer.uint32(50).fork()).ldelim(); + } + for (const v of message.nestedType) { + DescriptorProto.encode(v!, writer.uint32(26).fork()).ldelim(); + } + for (const v of message.enumType) { + EnumDescriptorProto.encode(v!, writer.uint32(34).fork()).ldelim(); + } + for (const v of message.extensionRange) { + DescriptorProto_ExtensionRange.encode( + v!, + writer.uint32(42).fork() + ).ldelim(); + } + for (const v of message.oneofDecl) { + OneofDescriptorProto.encode(v!, writer.uint32(66).fork()).ldelim(); + } + if (message.options !== undefined) { + MessageOptions.encode(message.options, writer.uint32(58).fork()).ldelim(); + } + for (const v of message.reservedRange) { + DescriptorProto_ReservedRange.encode( + v!, + writer.uint32(74).fork() + ).ldelim(); + } + for (const v of message.reservedName) { + writer.uint32(82).string(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): DescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseDescriptorProto } as DescriptorProto; + message.field = []; + message.extension = []; + message.nestedType = []; + message.enumType = []; + message.extensionRange = []; + message.oneofDecl = []; + message.reservedRange = []; + message.reservedName = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.field.push( + FieldDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 6: + message.extension.push( + FieldDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 3: + message.nestedType.push( + DescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 4: + message.enumType.push( + EnumDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 5: + message.extensionRange.push( + DescriptorProto_ExtensionRange.decode(reader, reader.uint32()) + ); + break; + case 8: + message.oneofDecl.push( + OneofDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 7: + message.options = MessageOptions.decode(reader, reader.uint32()); + break; + case 9: + message.reservedRange.push( + DescriptorProto_ReservedRange.decode(reader, reader.uint32()) + ); + break; + case 10: + message.reservedName.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DescriptorProto { + const message = { ...baseDescriptorProto } as DescriptorProto; + message.field = []; + message.extension = []; + message.nestedType = []; + message.enumType = []; + message.extensionRange = []; + message.oneofDecl = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.field !== undefined && object.field !== null) { + for (const e of object.field) { + message.field.push(FieldDescriptorProto.fromJSON(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromJSON(e)); + } + } + if (object.nestedType !== undefined && object.nestedType !== null) { + for (const e of object.nestedType) { + message.nestedType.push(DescriptorProto.fromJSON(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromJSON(e)); + } + } + if (object.extensionRange !== undefined && object.extensionRange !== null) { + for (const e of object.extensionRange) { + message.extensionRange.push(DescriptorProto_ExtensionRange.fromJSON(e)); + } + } + if (object.oneofDecl !== undefined && object.oneofDecl !== null) { + for (const e of object.oneofDecl) { + message.oneofDecl.push(OneofDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = MessageOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push(DescriptorProto_ReservedRange.fromJSON(e)); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(String(e)); + } + } + return message; + }, + + toJSON(message: DescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + if (message.field) { + obj.field = message.field.map((e) => + e ? FieldDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.field = []; + } + if (message.extension) { + obj.extension = message.extension.map((e) => + e ? FieldDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.extension = []; + } + if (message.nestedType) { + obj.nestedType = message.nestedType.map((e) => + e ? DescriptorProto.toJSON(e) : undefined + ); + } else { + obj.nestedType = []; + } + if (message.enumType) { + obj.enumType = message.enumType.map((e) => + e ? EnumDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.enumType = []; + } + if (message.extensionRange) { + obj.extensionRange = message.extensionRange.map((e) => + e ? DescriptorProto_ExtensionRange.toJSON(e) : undefined + ); + } else { + obj.extensionRange = []; + } + if (message.oneofDecl) { + obj.oneofDecl = message.oneofDecl.map((e) => + e ? OneofDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.oneofDecl = []; + } + message.options !== undefined && + (obj.options = message.options + ? MessageOptions.toJSON(message.options) + : undefined); + if (message.reservedRange) { + obj.reservedRange = message.reservedRange.map((e) => + e ? DescriptorProto_ReservedRange.toJSON(e) : undefined + ); + } else { + obj.reservedRange = []; + } + if (message.reservedName) { + obj.reservedName = message.reservedName.map((e) => e); + } else { + obj.reservedName = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): DescriptorProto { + const message = { ...baseDescriptorProto } as DescriptorProto; + message.field = []; + message.extension = []; + message.nestedType = []; + message.enumType = []; + message.extensionRange = []; + message.oneofDecl = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.field !== undefined && object.field !== null) { + for (const e of object.field) { + message.field.push(FieldDescriptorProto.fromPartial(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromPartial(e)); + } + } + if (object.nestedType !== undefined && object.nestedType !== null) { + for (const e of object.nestedType) { + message.nestedType.push(DescriptorProto.fromPartial(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromPartial(e)); + } + } + if (object.extensionRange !== undefined && object.extensionRange !== null) { + for (const e of object.extensionRange) { + message.extensionRange.push( + DescriptorProto_ExtensionRange.fromPartial(e) + ); + } + } + if (object.oneofDecl !== undefined && object.oneofDecl !== null) { + for (const e of object.oneofDecl) { + message.oneofDecl.push(OneofDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = MessageOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push( + DescriptorProto_ReservedRange.fromPartial(e) + ); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(e); + } + } + return message; + }, +}; + +const baseDescriptorProto_ExtensionRange: object = { start: 0, end: 0 }; + +export const DescriptorProto_ExtensionRange = { + encode( + message: DescriptorProto_ExtensionRange, + writer: Writer = Writer.create() + ): Writer { + if (message.start !== 0) { + writer.uint32(8).int32(message.start); + } + if (message.end !== 0) { + writer.uint32(16).int32(message.end); + } + if (message.options !== undefined) { + ExtensionRangeOptions.encode( + message.options, + writer.uint32(26).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): DescriptorProto_ExtensionRange { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseDescriptorProto_ExtensionRange, + } as DescriptorProto_ExtensionRange; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.start = reader.int32(); + break; + case 2: + message.end = reader.int32(); + break; + case 3: + message.options = ExtensionRangeOptions.decode( + reader, + reader.uint32() + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DescriptorProto_ExtensionRange { + const message = { + ...baseDescriptorProto_ExtensionRange, + } as DescriptorProto_ExtensionRange; + if (object.start !== undefined && object.start !== null) { + message.start = Number(object.start); + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = ExtensionRangeOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: DescriptorProto_ExtensionRange): unknown { + const obj: any = {}; + message.start !== undefined && (obj.start = message.start); + message.end !== undefined && (obj.end = message.end); + message.options !== undefined && + (obj.options = message.options + ? ExtensionRangeOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): DescriptorProto_ExtensionRange { + const message = { + ...baseDescriptorProto_ExtensionRange, + } as DescriptorProto_ExtensionRange; + if (object.start !== undefined && object.start !== null) { + message.start = object.start; + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = ExtensionRangeOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseDescriptorProto_ReservedRange: object = { start: 0, end: 0 }; + +export const DescriptorProto_ReservedRange = { + encode( + message: DescriptorProto_ReservedRange, + writer: Writer = Writer.create() + ): Writer { + if (message.start !== 0) { + writer.uint32(8).int32(message.start); + } + if (message.end !== 0) { + writer.uint32(16).int32(message.end); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): DescriptorProto_ReservedRange { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseDescriptorProto_ReservedRange, + } as DescriptorProto_ReservedRange; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.start = reader.int32(); + break; + case 2: + message.end = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DescriptorProto_ReservedRange { + const message = { + ...baseDescriptorProto_ReservedRange, + } as DescriptorProto_ReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = Number(object.start); + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + return message; + }, + + toJSON(message: DescriptorProto_ReservedRange): unknown { + const obj: any = {}; + message.start !== undefined && (obj.start = message.start); + message.end !== undefined && (obj.end = message.end); + return obj; + }, + + fromPartial( + object: DeepPartial + ): DescriptorProto_ReservedRange { + const message = { + ...baseDescriptorProto_ReservedRange, + } as DescriptorProto_ReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = object.start; + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + return message; + }, +}; + +const baseExtensionRangeOptions: object = {}; + +export const ExtensionRangeOptions = { + encode( + message: ExtensionRangeOptions, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ExtensionRangeOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseExtensionRangeOptions } as ExtensionRangeOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ExtensionRangeOptions { + const message = { ...baseExtensionRangeOptions } as ExtensionRangeOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: ExtensionRangeOptions): unknown { + const obj: any = {}; + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial( + object: DeepPartial + ): ExtensionRangeOptions { + const message = { ...baseExtensionRangeOptions } as ExtensionRangeOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseFieldDescriptorProto: object = { + name: "", + number: 0, + label: 1, + type: 1, + typeName: "", + extendee: "", + defaultValue: "", + oneofIndex: 0, + jsonName: "", + proto3Optional: false, +}; + +export const FieldDescriptorProto = { + encode( + message: FieldDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.number !== 0) { + writer.uint32(24).int32(message.number); + } + if (message.label !== 1) { + writer.uint32(32).int32(message.label); + } + if (message.type !== 1) { + writer.uint32(40).int32(message.type); + } + if (message.typeName !== "") { + writer.uint32(50).string(message.typeName); + } + if (message.extendee !== "") { + writer.uint32(18).string(message.extendee); + } + if (message.defaultValue !== "") { + writer.uint32(58).string(message.defaultValue); + } + if (message.oneofIndex !== 0) { + writer.uint32(72).int32(message.oneofIndex); + } + if (message.jsonName !== "") { + writer.uint32(82).string(message.jsonName); + } + if (message.options !== undefined) { + FieldOptions.encode(message.options, writer.uint32(66).fork()).ldelim(); + } + if (message.proto3Optional === true) { + writer.uint32(136).bool(message.proto3Optional); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FieldDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFieldDescriptorProto } as FieldDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 3: + message.number = reader.int32(); + break; + case 4: + message.label = reader.int32() as any; + break; + case 5: + message.type = reader.int32() as any; + break; + case 6: + message.typeName = reader.string(); + break; + case 2: + message.extendee = reader.string(); + break; + case 7: + message.defaultValue = reader.string(); + break; + case 9: + message.oneofIndex = reader.int32(); + break; + case 10: + message.jsonName = reader.string(); + break; + case 8: + message.options = FieldOptions.decode(reader, reader.uint32()); + break; + case 17: + message.proto3Optional = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FieldDescriptorProto { + const message = { ...baseFieldDescriptorProto } as FieldDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = Number(object.number); + } else { + message.number = 0; + } + if (object.label !== undefined && object.label !== null) { + message.label = fieldDescriptorProto_LabelFromJSON(object.label); + } else { + message.label = 1; + } + if (object.type !== undefined && object.type !== null) { + message.type = fieldDescriptorProto_TypeFromJSON(object.type); + } else { + message.type = 1; + } + if (object.typeName !== undefined && object.typeName !== null) { + message.typeName = String(object.typeName); + } else { + message.typeName = ""; + } + if (object.extendee !== undefined && object.extendee !== null) { + message.extendee = String(object.extendee); + } else { + message.extendee = ""; + } + if (object.defaultValue !== undefined && object.defaultValue !== null) { + message.defaultValue = String(object.defaultValue); + } else { + message.defaultValue = ""; + } + if (object.oneofIndex !== undefined && object.oneofIndex !== null) { + message.oneofIndex = Number(object.oneofIndex); + } else { + message.oneofIndex = 0; + } + if (object.jsonName !== undefined && object.jsonName !== null) { + message.jsonName = String(object.jsonName); + } else { + message.jsonName = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = FieldOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.proto3Optional !== undefined && object.proto3Optional !== null) { + message.proto3Optional = Boolean(object.proto3Optional); + } else { + message.proto3Optional = false; + } + return message; + }, + + toJSON(message: FieldDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.number !== undefined && (obj.number = message.number); + message.label !== undefined && + (obj.label = fieldDescriptorProto_LabelToJSON(message.label)); + message.type !== undefined && + (obj.type = fieldDescriptorProto_TypeToJSON(message.type)); + message.typeName !== undefined && (obj.typeName = message.typeName); + message.extendee !== undefined && (obj.extendee = message.extendee); + message.defaultValue !== undefined && + (obj.defaultValue = message.defaultValue); + message.oneofIndex !== undefined && (obj.oneofIndex = message.oneofIndex); + message.jsonName !== undefined && (obj.jsonName = message.jsonName); + message.options !== undefined && + (obj.options = message.options + ? FieldOptions.toJSON(message.options) + : undefined); + message.proto3Optional !== undefined && + (obj.proto3Optional = message.proto3Optional); + return obj; + }, + + fromPartial(object: DeepPartial): FieldDescriptorProto { + const message = { ...baseFieldDescriptorProto } as FieldDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = object.number; + } else { + message.number = 0; + } + if (object.label !== undefined && object.label !== null) { + message.label = object.label; + } else { + message.label = 1; + } + if (object.type !== undefined && object.type !== null) { + message.type = object.type; + } else { + message.type = 1; + } + if (object.typeName !== undefined && object.typeName !== null) { + message.typeName = object.typeName; + } else { + message.typeName = ""; + } + if (object.extendee !== undefined && object.extendee !== null) { + message.extendee = object.extendee; + } else { + message.extendee = ""; + } + if (object.defaultValue !== undefined && object.defaultValue !== null) { + message.defaultValue = object.defaultValue; + } else { + message.defaultValue = ""; + } + if (object.oneofIndex !== undefined && object.oneofIndex !== null) { + message.oneofIndex = object.oneofIndex; + } else { + message.oneofIndex = 0; + } + if (object.jsonName !== undefined && object.jsonName !== null) { + message.jsonName = object.jsonName; + } else { + message.jsonName = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = FieldOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.proto3Optional !== undefined && object.proto3Optional !== null) { + message.proto3Optional = object.proto3Optional; + } else { + message.proto3Optional = false; + } + return message; + }, +}; + +const baseOneofDescriptorProto: object = { name: "" }; + +export const OneofDescriptorProto = { + encode( + message: OneofDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.options !== undefined) { + OneofOptions.encode(message.options, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): OneofDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseOneofDescriptorProto } as OneofDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.options = OneofOptions.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): OneofDescriptorProto { + const message = { ...baseOneofDescriptorProto } as OneofDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = OneofOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: OneofDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.options !== undefined && + (obj.options = message.options + ? OneofOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): OneofDescriptorProto { + const message = { ...baseOneofDescriptorProto } as OneofDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = OneofOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseEnumDescriptorProto: object = { name: "", reservedName: "" }; + +export const EnumDescriptorProto = { + encode( + message: EnumDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + for (const v of message.value) { + EnumValueDescriptorProto.encode(v!, writer.uint32(18).fork()).ldelim(); + } + if (message.options !== undefined) { + EnumOptions.encode(message.options, writer.uint32(26).fork()).ldelim(); + } + for (const v of message.reservedRange) { + EnumDescriptorProto_EnumReservedRange.encode( + v!, + writer.uint32(34).fork() + ).ldelim(); + } + for (const v of message.reservedName) { + writer.uint32(42).string(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): EnumDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseEnumDescriptorProto } as EnumDescriptorProto; + message.value = []; + message.reservedRange = []; + message.reservedName = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.value.push( + EnumValueDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 3: + message.options = EnumOptions.decode(reader, reader.uint32()); + break; + case 4: + message.reservedRange.push( + EnumDescriptorProto_EnumReservedRange.decode( + reader, + reader.uint32() + ) + ); + break; + case 5: + message.reservedName.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumDescriptorProto { + const message = { ...baseEnumDescriptorProto } as EnumDescriptorProto; + message.value = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.value !== undefined && object.value !== null) { + for (const e of object.value) { + message.value.push(EnumValueDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push( + EnumDescriptorProto_EnumReservedRange.fromJSON(e) + ); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(String(e)); + } + } + return message; + }, + + toJSON(message: EnumDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + if (message.value) { + obj.value = message.value.map((e) => + e ? EnumValueDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.value = []; + } + message.options !== undefined && + (obj.options = message.options + ? EnumOptions.toJSON(message.options) + : undefined); + if (message.reservedRange) { + obj.reservedRange = message.reservedRange.map((e) => + e ? EnumDescriptorProto_EnumReservedRange.toJSON(e) : undefined + ); + } else { + obj.reservedRange = []; + } + if (message.reservedName) { + obj.reservedName = message.reservedName.map((e) => e); + } else { + obj.reservedName = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): EnumDescriptorProto { + const message = { ...baseEnumDescriptorProto } as EnumDescriptorProto; + message.value = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.value !== undefined && object.value !== null) { + for (const e of object.value) { + message.value.push(EnumValueDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push( + EnumDescriptorProto_EnumReservedRange.fromPartial(e) + ); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(e); + } + } + return message; + }, +}; + +const baseEnumDescriptorProto_EnumReservedRange: object = { start: 0, end: 0 }; + +export const EnumDescriptorProto_EnumReservedRange = { + encode( + message: EnumDescriptorProto_EnumReservedRange, + writer: Writer = Writer.create() + ): Writer { + if (message.start !== 0) { + writer.uint32(8).int32(message.start); + } + if (message.end !== 0) { + writer.uint32(16).int32(message.end); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): EnumDescriptorProto_EnumReservedRange { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseEnumDescriptorProto_EnumReservedRange, + } as EnumDescriptorProto_EnumReservedRange; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.start = reader.int32(); + break; + case 2: + message.end = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumDescriptorProto_EnumReservedRange { + const message = { + ...baseEnumDescriptorProto_EnumReservedRange, + } as EnumDescriptorProto_EnumReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = Number(object.start); + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + return message; + }, + + toJSON(message: EnumDescriptorProto_EnumReservedRange): unknown { + const obj: any = {}; + message.start !== undefined && (obj.start = message.start); + message.end !== undefined && (obj.end = message.end); + return obj; + }, + + fromPartial( + object: DeepPartial + ): EnumDescriptorProto_EnumReservedRange { + const message = { + ...baseEnumDescriptorProto_EnumReservedRange, + } as EnumDescriptorProto_EnumReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = object.start; + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + return message; + }, +}; + +const baseEnumValueDescriptorProto: object = { name: "", number: 0 }; + +export const EnumValueDescriptorProto = { + encode( + message: EnumValueDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.number !== 0) { + writer.uint32(16).int32(message.number); + } + if (message.options !== undefined) { + EnumValueOptions.encode( + message.options, + writer.uint32(26).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): EnumValueDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseEnumValueDescriptorProto, + } as EnumValueDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.number = reader.int32(); + break; + case 3: + message.options = EnumValueOptions.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumValueDescriptorProto { + const message = { + ...baseEnumValueDescriptorProto, + } as EnumValueDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = Number(object.number); + } else { + message.number = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumValueOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: EnumValueDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.number !== undefined && (obj.number = message.number); + message.options !== undefined && + (obj.options = message.options + ? EnumValueOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): EnumValueDescriptorProto { + const message = { + ...baseEnumValueDescriptorProto, + } as EnumValueDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = object.number; + } else { + message.number = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumValueOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseServiceDescriptorProto: object = { name: "" }; + +export const ServiceDescriptorProto = { + encode( + message: ServiceDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + for (const v of message.method) { + MethodDescriptorProto.encode(v!, writer.uint32(18).fork()).ldelim(); + } + if (message.options !== undefined) { + ServiceOptions.encode(message.options, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ServiceDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseServiceDescriptorProto } as ServiceDescriptorProto; + message.method = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.method.push( + MethodDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 3: + message.options = ServiceOptions.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ServiceDescriptorProto { + const message = { ...baseServiceDescriptorProto } as ServiceDescriptorProto; + message.method = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.method !== undefined && object.method !== null) { + for (const e of object.method) { + message.method.push(MethodDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = ServiceOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: ServiceDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + if (message.method) { + obj.method = message.method.map((e) => + e ? MethodDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.method = []; + } + message.options !== undefined && + (obj.options = message.options + ? ServiceOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): ServiceDescriptorProto { + const message = { ...baseServiceDescriptorProto } as ServiceDescriptorProto; + message.method = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.method !== undefined && object.method !== null) { + for (const e of object.method) { + message.method.push(MethodDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = ServiceOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseMethodDescriptorProto: object = { + name: "", + inputType: "", + outputType: "", + clientStreaming: false, + serverStreaming: false, +}; + +export const MethodDescriptorProto = { + encode( + message: MethodDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.inputType !== "") { + writer.uint32(18).string(message.inputType); + } + if (message.outputType !== "") { + writer.uint32(26).string(message.outputType); + } + if (message.options !== undefined) { + MethodOptions.encode(message.options, writer.uint32(34).fork()).ldelim(); + } + if (message.clientStreaming === true) { + writer.uint32(40).bool(message.clientStreaming); + } + if (message.serverStreaming === true) { + writer.uint32(48).bool(message.serverStreaming); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MethodDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMethodDescriptorProto } as MethodDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.inputType = reader.string(); + break; + case 3: + message.outputType = reader.string(); + break; + case 4: + message.options = MethodOptions.decode(reader, reader.uint32()); + break; + case 5: + message.clientStreaming = reader.bool(); + break; + case 6: + message.serverStreaming = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MethodDescriptorProto { + const message = { ...baseMethodDescriptorProto } as MethodDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.inputType !== undefined && object.inputType !== null) { + message.inputType = String(object.inputType); + } else { + message.inputType = ""; + } + if (object.outputType !== undefined && object.outputType !== null) { + message.outputType = String(object.outputType); + } else { + message.outputType = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = MethodOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if ( + object.clientStreaming !== undefined && + object.clientStreaming !== null + ) { + message.clientStreaming = Boolean(object.clientStreaming); + } else { + message.clientStreaming = false; + } + if ( + object.serverStreaming !== undefined && + object.serverStreaming !== null + ) { + message.serverStreaming = Boolean(object.serverStreaming); + } else { + message.serverStreaming = false; + } + return message; + }, + + toJSON(message: MethodDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.inputType !== undefined && (obj.inputType = message.inputType); + message.outputType !== undefined && (obj.outputType = message.outputType); + message.options !== undefined && + (obj.options = message.options + ? MethodOptions.toJSON(message.options) + : undefined); + message.clientStreaming !== undefined && + (obj.clientStreaming = message.clientStreaming); + message.serverStreaming !== undefined && + (obj.serverStreaming = message.serverStreaming); + return obj; + }, + + fromPartial( + object: DeepPartial + ): MethodDescriptorProto { + const message = { ...baseMethodDescriptorProto } as MethodDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.inputType !== undefined && object.inputType !== null) { + message.inputType = object.inputType; + } else { + message.inputType = ""; + } + if (object.outputType !== undefined && object.outputType !== null) { + message.outputType = object.outputType; + } else { + message.outputType = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = MethodOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if ( + object.clientStreaming !== undefined && + object.clientStreaming !== null + ) { + message.clientStreaming = object.clientStreaming; + } else { + message.clientStreaming = false; + } + if ( + object.serverStreaming !== undefined && + object.serverStreaming !== null + ) { + message.serverStreaming = object.serverStreaming; + } else { + message.serverStreaming = false; + } + return message; + }, +}; + +const baseFileOptions: object = { + javaPackage: "", + javaOuterClassname: "", + javaMultipleFiles: false, + javaGenerateEqualsAndHash: false, + javaStringCheckUtf8: false, + optimizeFor: 1, + goPackage: "", + ccGenericServices: false, + javaGenericServices: false, + pyGenericServices: false, + phpGenericServices: false, + deprecated: false, + ccEnableArenas: false, + objcClassPrefix: "", + csharpNamespace: "", + swiftPrefix: "", + phpClassPrefix: "", + phpNamespace: "", + phpMetadataNamespace: "", + rubyPackage: "", +}; + +export const FileOptions = { + encode(message: FileOptions, writer: Writer = Writer.create()): Writer { + if (message.javaPackage !== "") { + writer.uint32(10).string(message.javaPackage); + } + if (message.javaOuterClassname !== "") { + writer.uint32(66).string(message.javaOuterClassname); + } + if (message.javaMultipleFiles === true) { + writer.uint32(80).bool(message.javaMultipleFiles); + } + if (message.javaGenerateEqualsAndHash === true) { + writer.uint32(160).bool(message.javaGenerateEqualsAndHash); + } + if (message.javaStringCheckUtf8 === true) { + writer.uint32(216).bool(message.javaStringCheckUtf8); + } + if (message.optimizeFor !== 1) { + writer.uint32(72).int32(message.optimizeFor); + } + if (message.goPackage !== "") { + writer.uint32(90).string(message.goPackage); + } + if (message.ccGenericServices === true) { + writer.uint32(128).bool(message.ccGenericServices); + } + if (message.javaGenericServices === true) { + writer.uint32(136).bool(message.javaGenericServices); + } + if (message.pyGenericServices === true) { + writer.uint32(144).bool(message.pyGenericServices); + } + if (message.phpGenericServices === true) { + writer.uint32(336).bool(message.phpGenericServices); + } + if (message.deprecated === true) { + writer.uint32(184).bool(message.deprecated); + } + if (message.ccEnableArenas === true) { + writer.uint32(248).bool(message.ccEnableArenas); + } + if (message.objcClassPrefix !== "") { + writer.uint32(290).string(message.objcClassPrefix); + } + if (message.csharpNamespace !== "") { + writer.uint32(298).string(message.csharpNamespace); + } + if (message.swiftPrefix !== "") { + writer.uint32(314).string(message.swiftPrefix); + } + if (message.phpClassPrefix !== "") { + writer.uint32(322).string(message.phpClassPrefix); + } + if (message.phpNamespace !== "") { + writer.uint32(330).string(message.phpNamespace); + } + if (message.phpMetadataNamespace !== "") { + writer.uint32(354).string(message.phpMetadataNamespace); + } + if (message.rubyPackage !== "") { + writer.uint32(362).string(message.rubyPackage); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FileOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFileOptions } as FileOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.javaPackage = reader.string(); + break; + case 8: + message.javaOuterClassname = reader.string(); + break; + case 10: + message.javaMultipleFiles = reader.bool(); + break; + case 20: + message.javaGenerateEqualsAndHash = reader.bool(); + break; + case 27: + message.javaStringCheckUtf8 = reader.bool(); + break; + case 9: + message.optimizeFor = reader.int32() as any; + break; + case 11: + message.goPackage = reader.string(); + break; + case 16: + message.ccGenericServices = reader.bool(); + break; + case 17: + message.javaGenericServices = reader.bool(); + break; + case 18: + message.pyGenericServices = reader.bool(); + break; + case 42: + message.phpGenericServices = reader.bool(); + break; + case 23: + message.deprecated = reader.bool(); + break; + case 31: + message.ccEnableArenas = reader.bool(); + break; + case 36: + message.objcClassPrefix = reader.string(); + break; + case 37: + message.csharpNamespace = reader.string(); + break; + case 39: + message.swiftPrefix = reader.string(); + break; + case 40: + message.phpClassPrefix = reader.string(); + break; + case 41: + message.phpNamespace = reader.string(); + break; + case 44: + message.phpMetadataNamespace = reader.string(); + break; + case 45: + message.rubyPackage = reader.string(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FileOptions { + const message = { ...baseFileOptions } as FileOptions; + message.uninterpretedOption = []; + if (object.javaPackage !== undefined && object.javaPackage !== null) { + message.javaPackage = String(object.javaPackage); + } else { + message.javaPackage = ""; + } + if ( + object.javaOuterClassname !== undefined && + object.javaOuterClassname !== null + ) { + message.javaOuterClassname = String(object.javaOuterClassname); + } else { + message.javaOuterClassname = ""; + } + if ( + object.javaMultipleFiles !== undefined && + object.javaMultipleFiles !== null + ) { + message.javaMultipleFiles = Boolean(object.javaMultipleFiles); + } else { + message.javaMultipleFiles = false; + } + if ( + object.javaGenerateEqualsAndHash !== undefined && + object.javaGenerateEqualsAndHash !== null + ) { + message.javaGenerateEqualsAndHash = Boolean( + object.javaGenerateEqualsAndHash + ); + } else { + message.javaGenerateEqualsAndHash = false; + } + if ( + object.javaStringCheckUtf8 !== undefined && + object.javaStringCheckUtf8 !== null + ) { + message.javaStringCheckUtf8 = Boolean(object.javaStringCheckUtf8); + } else { + message.javaStringCheckUtf8 = false; + } + if (object.optimizeFor !== undefined && object.optimizeFor !== null) { + message.optimizeFor = fileOptions_OptimizeModeFromJSON( + object.optimizeFor + ); + } else { + message.optimizeFor = 1; + } + if (object.goPackage !== undefined && object.goPackage !== null) { + message.goPackage = String(object.goPackage); + } else { + message.goPackage = ""; + } + if ( + object.ccGenericServices !== undefined && + object.ccGenericServices !== null + ) { + message.ccGenericServices = Boolean(object.ccGenericServices); + } else { + message.ccGenericServices = false; + } + if ( + object.javaGenericServices !== undefined && + object.javaGenericServices !== null + ) { + message.javaGenericServices = Boolean(object.javaGenericServices); + } else { + message.javaGenericServices = false; + } + if ( + object.pyGenericServices !== undefined && + object.pyGenericServices !== null + ) { + message.pyGenericServices = Boolean(object.pyGenericServices); + } else { + message.pyGenericServices = false; + } + if ( + object.phpGenericServices !== undefined && + object.phpGenericServices !== null + ) { + message.phpGenericServices = Boolean(object.phpGenericServices); + } else { + message.phpGenericServices = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if (object.ccEnableArenas !== undefined && object.ccEnableArenas !== null) { + message.ccEnableArenas = Boolean(object.ccEnableArenas); + } else { + message.ccEnableArenas = false; + } + if ( + object.objcClassPrefix !== undefined && + object.objcClassPrefix !== null + ) { + message.objcClassPrefix = String(object.objcClassPrefix); + } else { + message.objcClassPrefix = ""; + } + if ( + object.csharpNamespace !== undefined && + object.csharpNamespace !== null + ) { + message.csharpNamespace = String(object.csharpNamespace); + } else { + message.csharpNamespace = ""; + } + if (object.swiftPrefix !== undefined && object.swiftPrefix !== null) { + message.swiftPrefix = String(object.swiftPrefix); + } else { + message.swiftPrefix = ""; + } + if (object.phpClassPrefix !== undefined && object.phpClassPrefix !== null) { + message.phpClassPrefix = String(object.phpClassPrefix); + } else { + message.phpClassPrefix = ""; + } + if (object.phpNamespace !== undefined && object.phpNamespace !== null) { + message.phpNamespace = String(object.phpNamespace); + } else { + message.phpNamespace = ""; + } + if ( + object.phpMetadataNamespace !== undefined && + object.phpMetadataNamespace !== null + ) { + message.phpMetadataNamespace = String(object.phpMetadataNamespace); + } else { + message.phpMetadataNamespace = ""; + } + if (object.rubyPackage !== undefined && object.rubyPackage !== null) { + message.rubyPackage = String(object.rubyPackage); + } else { + message.rubyPackage = ""; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: FileOptions): unknown { + const obj: any = {}; + message.javaPackage !== undefined && + (obj.javaPackage = message.javaPackage); + message.javaOuterClassname !== undefined && + (obj.javaOuterClassname = message.javaOuterClassname); + message.javaMultipleFiles !== undefined && + (obj.javaMultipleFiles = message.javaMultipleFiles); + message.javaGenerateEqualsAndHash !== undefined && + (obj.javaGenerateEqualsAndHash = message.javaGenerateEqualsAndHash); + message.javaStringCheckUtf8 !== undefined && + (obj.javaStringCheckUtf8 = message.javaStringCheckUtf8); + message.optimizeFor !== undefined && + (obj.optimizeFor = fileOptions_OptimizeModeToJSON(message.optimizeFor)); + message.goPackage !== undefined && (obj.goPackage = message.goPackage); + message.ccGenericServices !== undefined && + (obj.ccGenericServices = message.ccGenericServices); + message.javaGenericServices !== undefined && + (obj.javaGenericServices = message.javaGenericServices); + message.pyGenericServices !== undefined && + (obj.pyGenericServices = message.pyGenericServices); + message.phpGenericServices !== undefined && + (obj.phpGenericServices = message.phpGenericServices); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.ccEnableArenas !== undefined && + (obj.ccEnableArenas = message.ccEnableArenas); + message.objcClassPrefix !== undefined && + (obj.objcClassPrefix = message.objcClassPrefix); + message.csharpNamespace !== undefined && + (obj.csharpNamespace = message.csharpNamespace); + message.swiftPrefix !== undefined && + (obj.swiftPrefix = message.swiftPrefix); + message.phpClassPrefix !== undefined && + (obj.phpClassPrefix = message.phpClassPrefix); + message.phpNamespace !== undefined && + (obj.phpNamespace = message.phpNamespace); + message.phpMetadataNamespace !== undefined && + (obj.phpMetadataNamespace = message.phpMetadataNamespace); + message.rubyPackage !== undefined && + (obj.rubyPackage = message.rubyPackage); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): FileOptions { + const message = { ...baseFileOptions } as FileOptions; + message.uninterpretedOption = []; + if (object.javaPackage !== undefined && object.javaPackage !== null) { + message.javaPackage = object.javaPackage; + } else { + message.javaPackage = ""; + } + if ( + object.javaOuterClassname !== undefined && + object.javaOuterClassname !== null + ) { + message.javaOuterClassname = object.javaOuterClassname; + } else { + message.javaOuterClassname = ""; + } + if ( + object.javaMultipleFiles !== undefined && + object.javaMultipleFiles !== null + ) { + message.javaMultipleFiles = object.javaMultipleFiles; + } else { + message.javaMultipleFiles = false; + } + if ( + object.javaGenerateEqualsAndHash !== undefined && + object.javaGenerateEqualsAndHash !== null + ) { + message.javaGenerateEqualsAndHash = object.javaGenerateEqualsAndHash; + } else { + message.javaGenerateEqualsAndHash = false; + } + if ( + object.javaStringCheckUtf8 !== undefined && + object.javaStringCheckUtf8 !== null + ) { + message.javaStringCheckUtf8 = object.javaStringCheckUtf8; + } else { + message.javaStringCheckUtf8 = false; + } + if (object.optimizeFor !== undefined && object.optimizeFor !== null) { + message.optimizeFor = object.optimizeFor; + } else { + message.optimizeFor = 1; + } + if (object.goPackage !== undefined && object.goPackage !== null) { + message.goPackage = object.goPackage; + } else { + message.goPackage = ""; + } + if ( + object.ccGenericServices !== undefined && + object.ccGenericServices !== null + ) { + message.ccGenericServices = object.ccGenericServices; + } else { + message.ccGenericServices = false; + } + if ( + object.javaGenericServices !== undefined && + object.javaGenericServices !== null + ) { + message.javaGenericServices = object.javaGenericServices; + } else { + message.javaGenericServices = false; + } + if ( + object.pyGenericServices !== undefined && + object.pyGenericServices !== null + ) { + message.pyGenericServices = object.pyGenericServices; + } else { + message.pyGenericServices = false; + } + if ( + object.phpGenericServices !== undefined && + object.phpGenericServices !== null + ) { + message.phpGenericServices = object.phpGenericServices; + } else { + message.phpGenericServices = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if (object.ccEnableArenas !== undefined && object.ccEnableArenas !== null) { + message.ccEnableArenas = object.ccEnableArenas; + } else { + message.ccEnableArenas = false; + } + if ( + object.objcClassPrefix !== undefined && + object.objcClassPrefix !== null + ) { + message.objcClassPrefix = object.objcClassPrefix; + } else { + message.objcClassPrefix = ""; + } + if ( + object.csharpNamespace !== undefined && + object.csharpNamespace !== null + ) { + message.csharpNamespace = object.csharpNamespace; + } else { + message.csharpNamespace = ""; + } + if (object.swiftPrefix !== undefined && object.swiftPrefix !== null) { + message.swiftPrefix = object.swiftPrefix; + } else { + message.swiftPrefix = ""; + } + if (object.phpClassPrefix !== undefined && object.phpClassPrefix !== null) { + message.phpClassPrefix = object.phpClassPrefix; + } else { + message.phpClassPrefix = ""; + } + if (object.phpNamespace !== undefined && object.phpNamespace !== null) { + message.phpNamespace = object.phpNamespace; + } else { + message.phpNamespace = ""; + } + if ( + object.phpMetadataNamespace !== undefined && + object.phpMetadataNamespace !== null + ) { + message.phpMetadataNamespace = object.phpMetadataNamespace; + } else { + message.phpMetadataNamespace = ""; + } + if (object.rubyPackage !== undefined && object.rubyPackage !== null) { + message.rubyPackage = object.rubyPackage; + } else { + message.rubyPackage = ""; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseMessageOptions: object = { + messageSetWireFormat: false, + noStandardDescriptorAccessor: false, + deprecated: false, + mapEntry: false, +}; + +export const MessageOptions = { + encode(message: MessageOptions, writer: Writer = Writer.create()): Writer { + if (message.messageSetWireFormat === true) { + writer.uint32(8).bool(message.messageSetWireFormat); + } + if (message.noStandardDescriptorAccessor === true) { + writer.uint32(16).bool(message.noStandardDescriptorAccessor); + } + if (message.deprecated === true) { + writer.uint32(24).bool(message.deprecated); + } + if (message.mapEntry === true) { + writer.uint32(56).bool(message.mapEntry); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MessageOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMessageOptions } as MessageOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.messageSetWireFormat = reader.bool(); + break; + case 2: + message.noStandardDescriptorAccessor = reader.bool(); + break; + case 3: + message.deprecated = reader.bool(); + break; + case 7: + message.mapEntry = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MessageOptions { + const message = { ...baseMessageOptions } as MessageOptions; + message.uninterpretedOption = []; + if ( + object.messageSetWireFormat !== undefined && + object.messageSetWireFormat !== null + ) { + message.messageSetWireFormat = Boolean(object.messageSetWireFormat); + } else { + message.messageSetWireFormat = false; + } + if ( + object.noStandardDescriptorAccessor !== undefined && + object.noStandardDescriptorAccessor !== null + ) { + message.noStandardDescriptorAccessor = Boolean( + object.noStandardDescriptorAccessor + ); + } else { + message.noStandardDescriptorAccessor = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if (object.mapEntry !== undefined && object.mapEntry !== null) { + message.mapEntry = Boolean(object.mapEntry); + } else { + message.mapEntry = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: MessageOptions): unknown { + const obj: any = {}; + message.messageSetWireFormat !== undefined && + (obj.messageSetWireFormat = message.messageSetWireFormat); + message.noStandardDescriptorAccessor !== undefined && + (obj.noStandardDescriptorAccessor = message.noStandardDescriptorAccessor); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.mapEntry !== undefined && (obj.mapEntry = message.mapEntry); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): MessageOptions { + const message = { ...baseMessageOptions } as MessageOptions; + message.uninterpretedOption = []; + if ( + object.messageSetWireFormat !== undefined && + object.messageSetWireFormat !== null + ) { + message.messageSetWireFormat = object.messageSetWireFormat; + } else { + message.messageSetWireFormat = false; + } + if ( + object.noStandardDescriptorAccessor !== undefined && + object.noStandardDescriptorAccessor !== null + ) { + message.noStandardDescriptorAccessor = + object.noStandardDescriptorAccessor; + } else { + message.noStandardDescriptorAccessor = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if (object.mapEntry !== undefined && object.mapEntry !== null) { + message.mapEntry = object.mapEntry; + } else { + message.mapEntry = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseFieldOptions: object = { + ctype: 0, + packed: false, + jstype: 0, + lazy: false, + deprecated: false, + weak: false, +}; + +export const FieldOptions = { + encode(message: FieldOptions, writer: Writer = Writer.create()): Writer { + if (message.ctype !== 0) { + writer.uint32(8).int32(message.ctype); + } + if (message.packed === true) { + writer.uint32(16).bool(message.packed); + } + if (message.jstype !== 0) { + writer.uint32(48).int32(message.jstype); + } + if (message.lazy === true) { + writer.uint32(40).bool(message.lazy); + } + if (message.deprecated === true) { + writer.uint32(24).bool(message.deprecated); + } + if (message.weak === true) { + writer.uint32(80).bool(message.weak); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FieldOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFieldOptions } as FieldOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.ctype = reader.int32() as any; + break; + case 2: + message.packed = reader.bool(); + break; + case 6: + message.jstype = reader.int32() as any; + break; + case 5: + message.lazy = reader.bool(); + break; + case 3: + message.deprecated = reader.bool(); + break; + case 10: + message.weak = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FieldOptions { + const message = { ...baseFieldOptions } as FieldOptions; + message.uninterpretedOption = []; + if (object.ctype !== undefined && object.ctype !== null) { + message.ctype = fieldOptions_CTypeFromJSON(object.ctype); + } else { + message.ctype = 0; + } + if (object.packed !== undefined && object.packed !== null) { + message.packed = Boolean(object.packed); + } else { + message.packed = false; + } + if (object.jstype !== undefined && object.jstype !== null) { + message.jstype = fieldOptions_JSTypeFromJSON(object.jstype); + } else { + message.jstype = 0; + } + if (object.lazy !== undefined && object.lazy !== null) { + message.lazy = Boolean(object.lazy); + } else { + message.lazy = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if (object.weak !== undefined && object.weak !== null) { + message.weak = Boolean(object.weak); + } else { + message.weak = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: FieldOptions): unknown { + const obj: any = {}; + message.ctype !== undefined && + (obj.ctype = fieldOptions_CTypeToJSON(message.ctype)); + message.packed !== undefined && (obj.packed = message.packed); + message.jstype !== undefined && + (obj.jstype = fieldOptions_JSTypeToJSON(message.jstype)); + message.lazy !== undefined && (obj.lazy = message.lazy); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.weak !== undefined && (obj.weak = message.weak); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): FieldOptions { + const message = { ...baseFieldOptions } as FieldOptions; + message.uninterpretedOption = []; + if (object.ctype !== undefined && object.ctype !== null) { + message.ctype = object.ctype; + } else { + message.ctype = 0; + } + if (object.packed !== undefined && object.packed !== null) { + message.packed = object.packed; + } else { + message.packed = false; + } + if (object.jstype !== undefined && object.jstype !== null) { + message.jstype = object.jstype; + } else { + message.jstype = 0; + } + if (object.lazy !== undefined && object.lazy !== null) { + message.lazy = object.lazy; + } else { + message.lazy = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if (object.weak !== undefined && object.weak !== null) { + message.weak = object.weak; + } else { + message.weak = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseOneofOptions: object = {}; + +export const OneofOptions = { + encode(message: OneofOptions, writer: Writer = Writer.create()): Writer { + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): OneofOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseOneofOptions } as OneofOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): OneofOptions { + const message = { ...baseOneofOptions } as OneofOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: OneofOptions): unknown { + const obj: any = {}; + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): OneofOptions { + const message = { ...baseOneofOptions } as OneofOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseEnumOptions: object = { allowAlias: false, deprecated: false }; + +export const EnumOptions = { + encode(message: EnumOptions, writer: Writer = Writer.create()): Writer { + if (message.allowAlias === true) { + writer.uint32(16).bool(message.allowAlias); + } + if (message.deprecated === true) { + writer.uint32(24).bool(message.deprecated); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): EnumOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseEnumOptions } as EnumOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + message.allowAlias = reader.bool(); + break; + case 3: + message.deprecated = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumOptions { + const message = { ...baseEnumOptions } as EnumOptions; + message.uninterpretedOption = []; + if (object.allowAlias !== undefined && object.allowAlias !== null) { + message.allowAlias = Boolean(object.allowAlias); + } else { + message.allowAlias = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: EnumOptions): unknown { + const obj: any = {}; + message.allowAlias !== undefined && (obj.allowAlias = message.allowAlias); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): EnumOptions { + const message = { ...baseEnumOptions } as EnumOptions; + message.uninterpretedOption = []; + if (object.allowAlias !== undefined && object.allowAlias !== null) { + message.allowAlias = object.allowAlias; + } else { + message.allowAlias = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseEnumValueOptions: object = { deprecated: false }; + +export const EnumValueOptions = { + encode(message: EnumValueOptions, writer: Writer = Writer.create()): Writer { + if (message.deprecated === true) { + writer.uint32(8).bool(message.deprecated); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): EnumValueOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseEnumValueOptions } as EnumValueOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.deprecated = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumValueOptions { + const message = { ...baseEnumValueOptions } as EnumValueOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: EnumValueOptions): unknown { + const obj: any = {}; + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): EnumValueOptions { + const message = { ...baseEnumValueOptions } as EnumValueOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseServiceOptions: object = { deprecated: false }; + +export const ServiceOptions = { + encode(message: ServiceOptions, writer: Writer = Writer.create()): Writer { + if (message.deprecated === true) { + writer.uint32(264).bool(message.deprecated); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ServiceOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseServiceOptions } as ServiceOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 33: + message.deprecated = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ServiceOptions { + const message = { ...baseServiceOptions } as ServiceOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: ServiceOptions): unknown { + const obj: any = {}; + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): ServiceOptions { + const message = { ...baseServiceOptions } as ServiceOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseMethodOptions: object = { deprecated: false, idempotencyLevel: 0 }; + +export const MethodOptions = { + encode(message: MethodOptions, writer: Writer = Writer.create()): Writer { + if (message.deprecated === true) { + writer.uint32(264).bool(message.deprecated); + } + if (message.idempotencyLevel !== 0) { + writer.uint32(272).int32(message.idempotencyLevel); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MethodOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMethodOptions } as MethodOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 33: + message.deprecated = reader.bool(); + break; + case 34: + message.idempotencyLevel = reader.int32() as any; + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MethodOptions { + const message = { ...baseMethodOptions } as MethodOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.idempotencyLevel !== undefined && + object.idempotencyLevel !== null + ) { + message.idempotencyLevel = methodOptions_IdempotencyLevelFromJSON( + object.idempotencyLevel + ); + } else { + message.idempotencyLevel = 0; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: MethodOptions): unknown { + const obj: any = {}; + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.idempotencyLevel !== undefined && + (obj.idempotencyLevel = methodOptions_IdempotencyLevelToJSON( + message.idempotencyLevel + )); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): MethodOptions { + const message = { ...baseMethodOptions } as MethodOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.idempotencyLevel !== undefined && + object.idempotencyLevel !== null + ) { + message.idempotencyLevel = object.idempotencyLevel; + } else { + message.idempotencyLevel = 0; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseUninterpretedOption: object = { + identifierValue: "", + positiveIntValue: 0, + negativeIntValue: 0, + doubleValue: 0, + aggregateValue: "", +}; + +export const UninterpretedOption = { + encode( + message: UninterpretedOption, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.name) { + UninterpretedOption_NamePart.encode( + v!, + writer.uint32(18).fork() + ).ldelim(); + } + if (message.identifierValue !== "") { + writer.uint32(26).string(message.identifierValue); + } + if (message.positiveIntValue !== 0) { + writer.uint32(32).uint64(message.positiveIntValue); + } + if (message.negativeIntValue !== 0) { + writer.uint32(40).int64(message.negativeIntValue); + } + if (message.doubleValue !== 0) { + writer.uint32(49).double(message.doubleValue); + } + if (message.stringValue.length !== 0) { + writer.uint32(58).bytes(message.stringValue); + } + if (message.aggregateValue !== "") { + writer.uint32(66).string(message.aggregateValue); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): UninterpretedOption { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseUninterpretedOption } as UninterpretedOption; + message.name = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + message.name.push( + UninterpretedOption_NamePart.decode(reader, reader.uint32()) + ); + break; + case 3: + message.identifierValue = reader.string(); + break; + case 4: + message.positiveIntValue = longToNumber(reader.uint64() as Long); + break; + case 5: + message.negativeIntValue = longToNumber(reader.int64() as Long); + break; + case 6: + message.doubleValue = reader.double(); + break; + case 7: + message.stringValue = reader.bytes(); + break; + case 8: + message.aggregateValue = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): UninterpretedOption { + const message = { ...baseUninterpretedOption } as UninterpretedOption; + message.name = []; + if (object.name !== undefined && object.name !== null) { + for (const e of object.name) { + message.name.push(UninterpretedOption_NamePart.fromJSON(e)); + } + } + if ( + object.identifierValue !== undefined && + object.identifierValue !== null + ) { + message.identifierValue = String(object.identifierValue); + } else { + message.identifierValue = ""; + } + if ( + object.positiveIntValue !== undefined && + object.positiveIntValue !== null + ) { + message.positiveIntValue = Number(object.positiveIntValue); + } else { + message.positiveIntValue = 0; + } + if ( + object.negativeIntValue !== undefined && + object.negativeIntValue !== null + ) { + message.negativeIntValue = Number(object.negativeIntValue); + } else { + message.negativeIntValue = 0; + } + if (object.doubleValue !== undefined && object.doubleValue !== null) { + message.doubleValue = Number(object.doubleValue); + } else { + message.doubleValue = 0; + } + if (object.stringValue !== undefined && object.stringValue !== null) { + message.stringValue = bytesFromBase64(object.stringValue); + } + if (object.aggregateValue !== undefined && object.aggregateValue !== null) { + message.aggregateValue = String(object.aggregateValue); + } else { + message.aggregateValue = ""; + } + return message; + }, + + toJSON(message: UninterpretedOption): unknown { + const obj: any = {}; + if (message.name) { + obj.name = message.name.map((e) => + e ? UninterpretedOption_NamePart.toJSON(e) : undefined + ); + } else { + obj.name = []; + } + message.identifierValue !== undefined && + (obj.identifierValue = message.identifierValue); + message.positiveIntValue !== undefined && + (obj.positiveIntValue = message.positiveIntValue); + message.negativeIntValue !== undefined && + (obj.negativeIntValue = message.negativeIntValue); + message.doubleValue !== undefined && + (obj.doubleValue = message.doubleValue); + message.stringValue !== undefined && + (obj.stringValue = base64FromBytes( + message.stringValue !== undefined + ? message.stringValue + : new Uint8Array() + )); + message.aggregateValue !== undefined && + (obj.aggregateValue = message.aggregateValue); + return obj; + }, + + fromPartial(object: DeepPartial): UninterpretedOption { + const message = { ...baseUninterpretedOption } as UninterpretedOption; + message.name = []; + if (object.name !== undefined && object.name !== null) { + for (const e of object.name) { + message.name.push(UninterpretedOption_NamePart.fromPartial(e)); + } + } + if ( + object.identifierValue !== undefined && + object.identifierValue !== null + ) { + message.identifierValue = object.identifierValue; + } else { + message.identifierValue = ""; + } + if ( + object.positiveIntValue !== undefined && + object.positiveIntValue !== null + ) { + message.positiveIntValue = object.positiveIntValue; + } else { + message.positiveIntValue = 0; + } + if ( + object.negativeIntValue !== undefined && + object.negativeIntValue !== null + ) { + message.negativeIntValue = object.negativeIntValue; + } else { + message.negativeIntValue = 0; + } + if (object.doubleValue !== undefined && object.doubleValue !== null) { + message.doubleValue = object.doubleValue; + } else { + message.doubleValue = 0; + } + if (object.stringValue !== undefined && object.stringValue !== null) { + message.stringValue = object.stringValue; + } else { + message.stringValue = new Uint8Array(); + } + if (object.aggregateValue !== undefined && object.aggregateValue !== null) { + message.aggregateValue = object.aggregateValue; + } else { + message.aggregateValue = ""; + } + return message; + }, +}; + +const baseUninterpretedOption_NamePart: object = { + namePart: "", + isExtension: false, +}; + +export const UninterpretedOption_NamePart = { + encode( + message: UninterpretedOption_NamePart, + writer: Writer = Writer.create() + ): Writer { + if (message.namePart !== "") { + writer.uint32(10).string(message.namePart); + } + if (message.isExtension === true) { + writer.uint32(16).bool(message.isExtension); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): UninterpretedOption_NamePart { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseUninterpretedOption_NamePart, + } as UninterpretedOption_NamePart; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.namePart = reader.string(); + break; + case 2: + message.isExtension = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): UninterpretedOption_NamePart { + const message = { + ...baseUninterpretedOption_NamePart, + } as UninterpretedOption_NamePart; + if (object.namePart !== undefined && object.namePart !== null) { + message.namePart = String(object.namePart); + } else { + message.namePart = ""; + } + if (object.isExtension !== undefined && object.isExtension !== null) { + message.isExtension = Boolean(object.isExtension); + } else { + message.isExtension = false; + } + return message; + }, + + toJSON(message: UninterpretedOption_NamePart): unknown { + const obj: any = {}; + message.namePart !== undefined && (obj.namePart = message.namePart); + message.isExtension !== undefined && + (obj.isExtension = message.isExtension); + return obj; + }, + + fromPartial( + object: DeepPartial + ): UninterpretedOption_NamePart { + const message = { + ...baseUninterpretedOption_NamePart, + } as UninterpretedOption_NamePart; + if (object.namePart !== undefined && object.namePart !== null) { + message.namePart = object.namePart; + } else { + message.namePart = ""; + } + if (object.isExtension !== undefined && object.isExtension !== null) { + message.isExtension = object.isExtension; + } else { + message.isExtension = false; + } + return message; + }, +}; + +const baseSourceCodeInfo: object = {}; + +export const SourceCodeInfo = { + encode(message: SourceCodeInfo, writer: Writer = Writer.create()): Writer { + for (const v of message.location) { + SourceCodeInfo_Location.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): SourceCodeInfo { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseSourceCodeInfo } as SourceCodeInfo; + message.location = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.location.push( + SourceCodeInfo_Location.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): SourceCodeInfo { + const message = { ...baseSourceCodeInfo } as SourceCodeInfo; + message.location = []; + if (object.location !== undefined && object.location !== null) { + for (const e of object.location) { + message.location.push(SourceCodeInfo_Location.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: SourceCodeInfo): unknown { + const obj: any = {}; + if (message.location) { + obj.location = message.location.map((e) => + e ? SourceCodeInfo_Location.toJSON(e) : undefined + ); + } else { + obj.location = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): SourceCodeInfo { + const message = { ...baseSourceCodeInfo } as SourceCodeInfo; + message.location = []; + if (object.location !== undefined && object.location !== null) { + for (const e of object.location) { + message.location.push(SourceCodeInfo_Location.fromPartial(e)); + } + } + return message; + }, +}; + +const baseSourceCodeInfo_Location: object = { + path: 0, + span: 0, + leadingComments: "", + trailingComments: "", + leadingDetachedComments: "", +}; + +export const SourceCodeInfo_Location = { + encode( + message: SourceCodeInfo_Location, + writer: Writer = Writer.create() + ): Writer { + writer.uint32(10).fork(); + for (const v of message.path) { + writer.int32(v); + } + writer.ldelim(); + writer.uint32(18).fork(); + for (const v of message.span) { + writer.int32(v); + } + writer.ldelim(); + if (message.leadingComments !== "") { + writer.uint32(26).string(message.leadingComments); + } + if (message.trailingComments !== "") { + writer.uint32(34).string(message.trailingComments); + } + for (const v of message.leadingDetachedComments) { + writer.uint32(50).string(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): SourceCodeInfo_Location { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseSourceCodeInfo_Location, + } as SourceCodeInfo_Location; + message.path = []; + message.span = []; + message.leadingDetachedComments = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.path.push(reader.int32()); + } + } else { + message.path.push(reader.int32()); + } + break; + case 2: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.span.push(reader.int32()); + } + } else { + message.span.push(reader.int32()); + } + break; + case 3: + message.leadingComments = reader.string(); + break; + case 4: + message.trailingComments = reader.string(); + break; + case 6: + message.leadingDetachedComments.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): SourceCodeInfo_Location { + const message = { + ...baseSourceCodeInfo_Location, + } as SourceCodeInfo_Location; + message.path = []; + message.span = []; + message.leadingDetachedComments = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(Number(e)); + } + } + if (object.span !== undefined && object.span !== null) { + for (const e of object.span) { + message.span.push(Number(e)); + } + } + if ( + object.leadingComments !== undefined && + object.leadingComments !== null + ) { + message.leadingComments = String(object.leadingComments); + } else { + message.leadingComments = ""; + } + if ( + object.trailingComments !== undefined && + object.trailingComments !== null + ) { + message.trailingComments = String(object.trailingComments); + } else { + message.trailingComments = ""; + } + if ( + object.leadingDetachedComments !== undefined && + object.leadingDetachedComments !== null + ) { + for (const e of object.leadingDetachedComments) { + message.leadingDetachedComments.push(String(e)); + } + } + return message; + }, + + toJSON(message: SourceCodeInfo_Location): unknown { + const obj: any = {}; + if (message.path) { + obj.path = message.path.map((e) => e); + } else { + obj.path = []; + } + if (message.span) { + obj.span = message.span.map((e) => e); + } else { + obj.span = []; + } + message.leadingComments !== undefined && + (obj.leadingComments = message.leadingComments); + message.trailingComments !== undefined && + (obj.trailingComments = message.trailingComments); + if (message.leadingDetachedComments) { + obj.leadingDetachedComments = message.leadingDetachedComments.map( + (e) => e + ); + } else { + obj.leadingDetachedComments = []; + } + return obj; + }, + + fromPartial( + object: DeepPartial + ): SourceCodeInfo_Location { + const message = { + ...baseSourceCodeInfo_Location, + } as SourceCodeInfo_Location; + message.path = []; + message.span = []; + message.leadingDetachedComments = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(e); + } + } + if (object.span !== undefined && object.span !== null) { + for (const e of object.span) { + message.span.push(e); + } + } + if ( + object.leadingComments !== undefined && + object.leadingComments !== null + ) { + message.leadingComments = object.leadingComments; + } else { + message.leadingComments = ""; + } + if ( + object.trailingComments !== undefined && + object.trailingComments !== null + ) { + message.trailingComments = object.trailingComments; + } else { + message.trailingComments = ""; + } + if ( + object.leadingDetachedComments !== undefined && + object.leadingDetachedComments !== null + ) { + for (const e of object.leadingDetachedComments) { + message.leadingDetachedComments.push(e); + } + } + return message; + }, +}; + +const baseGeneratedCodeInfo: object = {}; + +export const GeneratedCodeInfo = { + encode(message: GeneratedCodeInfo, writer: Writer = Writer.create()): Writer { + for (const v of message.annotation) { + GeneratedCodeInfo_Annotation.encode( + v!, + writer.uint32(10).fork() + ).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): GeneratedCodeInfo { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseGeneratedCodeInfo } as GeneratedCodeInfo; + message.annotation = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.annotation.push( + GeneratedCodeInfo_Annotation.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GeneratedCodeInfo { + const message = { ...baseGeneratedCodeInfo } as GeneratedCodeInfo; + message.annotation = []; + if (object.annotation !== undefined && object.annotation !== null) { + for (const e of object.annotation) { + message.annotation.push(GeneratedCodeInfo_Annotation.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: GeneratedCodeInfo): unknown { + const obj: any = {}; + if (message.annotation) { + obj.annotation = message.annotation.map((e) => + e ? GeneratedCodeInfo_Annotation.toJSON(e) : undefined + ); + } else { + obj.annotation = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): GeneratedCodeInfo { + const message = { ...baseGeneratedCodeInfo } as GeneratedCodeInfo; + message.annotation = []; + if (object.annotation !== undefined && object.annotation !== null) { + for (const e of object.annotation) { + message.annotation.push(GeneratedCodeInfo_Annotation.fromPartial(e)); + } + } + return message; + }, +}; + +const baseGeneratedCodeInfo_Annotation: object = { + path: 0, + sourceFile: "", + begin: 0, + end: 0, +}; + +export const GeneratedCodeInfo_Annotation = { + encode( + message: GeneratedCodeInfo_Annotation, + writer: Writer = Writer.create() + ): Writer { + writer.uint32(10).fork(); + for (const v of message.path) { + writer.int32(v); + } + writer.ldelim(); + if (message.sourceFile !== "") { + writer.uint32(18).string(message.sourceFile); + } + if (message.begin !== 0) { + writer.uint32(24).int32(message.begin); + } + if (message.end !== 0) { + writer.uint32(32).int32(message.end); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): GeneratedCodeInfo_Annotation { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseGeneratedCodeInfo_Annotation, + } as GeneratedCodeInfo_Annotation; + message.path = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.path.push(reader.int32()); + } + } else { + message.path.push(reader.int32()); + } + break; + case 2: + message.sourceFile = reader.string(); + break; + case 3: + message.begin = reader.int32(); + break; + case 4: + message.end = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GeneratedCodeInfo_Annotation { + const message = { + ...baseGeneratedCodeInfo_Annotation, + } as GeneratedCodeInfo_Annotation; + message.path = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(Number(e)); + } + } + if (object.sourceFile !== undefined && object.sourceFile !== null) { + message.sourceFile = String(object.sourceFile); + } else { + message.sourceFile = ""; + } + if (object.begin !== undefined && object.begin !== null) { + message.begin = Number(object.begin); + } else { + message.begin = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + return message; + }, + + toJSON(message: GeneratedCodeInfo_Annotation): unknown { + const obj: any = {}; + if (message.path) { + obj.path = message.path.map((e) => e); + } else { + obj.path = []; + } + message.sourceFile !== undefined && (obj.sourceFile = message.sourceFile); + message.begin !== undefined && (obj.begin = message.begin); + message.end !== undefined && (obj.end = message.end); + return obj; + }, + + fromPartial( + object: DeepPartial + ): GeneratedCodeInfo_Annotation { + const message = { + ...baseGeneratedCodeInfo_Annotation, + } as GeneratedCodeInfo_Annotation; + message.path = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(e); + } + } + if (object.sourceFile !== undefined && object.sourceFile !== null) { + message.sourceFile = object.sourceFile; + } else { + message.sourceFile = ""; + } + if (object.begin !== undefined && object.begin !== null) { + message.begin = object.begin; + } else { + message.begin = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/cosmos.evidence.v1beta1/index.ts b/ts-client/cosmos.evidence.v1beta1/index.ts new file mode 100755 index 00000000..c9dfa159 --- /dev/null +++ b/ts-client/cosmos.evidence.v1beta1/index.ts @@ -0,0 +1,6 @@ +import Module from './module'; +import { txClient, queryClient, registry } from './module'; +import { msgTypes } from './registry'; + +export * from "./types"; +export { Module, msgTypes, txClient, queryClient, registry }; diff --git a/ts-client/cosmos.evidence.v1beta1/module.ts b/ts-client/cosmos.evidence.v1beta1/module.ts new file mode 100755 index 00000000..d25de960 --- /dev/null +++ b/ts-client/cosmos.evidence.v1beta1/module.ts @@ -0,0 +1,99 @@ +// Generated by Ignite ignite.com/cli + +import { StdFee } from "@cosmjs/launchpad"; +import { SigningStargateClient, DeliverTxResponse } from "@cosmjs/stargate"; +import { EncodeObject, GeneratedType, OfflineSigner, Registry } from "@cosmjs/proto-signing"; +import { msgTypes } from './registry'; +import { IgniteClient } from "../client" +import { MissingWalletError } from "../helpers" +import { Api } from "./rest"; +import { MsgSubmitEvidence } from "./types/cosmos/evidence/v1beta1/tx"; + + +export { MsgSubmitEvidence }; + +type sendMsgSubmitEvidenceParams = { + value: MsgSubmitEvidence, + fee?: StdFee, + memo?: string +}; + + +type msgSubmitEvidenceParams = { + value: MsgSubmitEvidence, +}; + + +export const registry = new Registry(msgTypes); + +const defaultFee = { + amount: [], + gas: "200000", +}; + +interface TxClientOptions { + addr: string + prefix: string + signer?: OfflineSigner +} + +export const txClient = ({ signer, prefix, addr }: TxClientOptions = { addr: "http://localhost:26657", prefix: "cosmos" }) => { + + return { + + async sendMsgSubmitEvidence({ value, fee, memo }: sendMsgSubmitEvidenceParams): Promise { + if (!signer) { + throw new Error('TxClient:sendMsgSubmitEvidence: Unable to sign Tx. Signer is not present.') + } + try { + const { address } = (await signer.getAccounts())[0]; + const signingClient = await SigningStargateClient.connectWithSigner(addr,signer,{registry, prefix}); + let msg = this.msgSubmitEvidence({ value: MsgSubmitEvidence.fromPartial(value) }) + return await signingClient.signAndBroadcast(address, [msg], fee ? fee : defaultFee, memo) + } catch (e: any) { + throw new Error('TxClient:sendMsgSubmitEvidence: Could not broadcast Tx: '+ e.message) + } + }, + + + msgSubmitEvidence({ value }: msgSubmitEvidenceParams): EncodeObject { + try { + return { typeUrl: "/cosmos.evidence.v1beta1.MsgSubmitEvidence", value: MsgSubmitEvidence.fromPartial( value ) } + } catch (e: any) { + throw new Error('TxClient:MsgSubmitEvidence: Could not create message: ' + e.message) + } + }, + + } +}; + +interface QueryClientOptions { + addr: string +} + +export const queryClient = ({ addr: addr }: QueryClientOptions = { addr: "http://localhost:1317" }) => { + return new Api({ baseUrl: addr }); +}; + +class SDKModule { + public query: ReturnType; + public tx: ReturnType; + + public registry: Array<[string, GeneratedType]>; + + constructor(client: IgniteClient) { + + this.query = queryClient({ addr: client.env.apiURL }); + this.tx = txClient({ signer: client.signer, addr: client.env.rpcURL, prefix: client.env.prefix ?? "cosmos" }); + } +}; + +const Module = (test: IgniteClient) => { + return { + module: { + CosmosEvidenceV1Beta1: new SDKModule(test) + }, + registry: msgTypes + } +} +export default Module; \ No newline at end of file diff --git a/ts-client/cosmos.evidence.v1beta1/registry.ts b/ts-client/cosmos.evidence.v1beta1/registry.ts new file mode 100755 index 00000000..b92dce59 --- /dev/null +++ b/ts-client/cosmos.evidence.v1beta1/registry.ts @@ -0,0 +1,9 @@ +import { GeneratedType } from "@cosmjs/proto-signing"; +import { MsgSubmitEvidence } from "./types/cosmos/evidence/v1beta1/tx"; + +const msgTypes: Array<[string, GeneratedType]> = [ + ["/cosmos.evidence.v1beta1.MsgSubmitEvidence", MsgSubmitEvidence], + +]; + +export { msgTypes } \ No newline at end of file diff --git a/ts-client/cosmos.evidence.v1beta1/rest.ts b/ts-client/cosmos.evidence.v1beta1/rest.ts new file mode 100644 index 00000000..16ee77f3 --- /dev/null +++ b/ts-client/cosmos.evidence.v1beta1/rest.ts @@ -0,0 +1,467 @@ +/* eslint-disable */ +/* tslint:disable */ +/* + * --------------------------------------------------------------- + * ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ## + * ## ## + * ## AUTHOR: acacode ## + * ## SOURCE: https://github.com/acacode/swagger-typescript-api ## + * --------------------------------------------------------------- + */ + +/** +* `Any` contains an arbitrary serialized protocol buffer message along with a +URL that describes the type of the serialized message. + +Protobuf library provides support to pack/unpack Any values in the form +of utility functions or additional generated methods of the Any type. + +Example 1: Pack and unpack a message in C++. + + Foo foo = ...; + Any any; + any.PackFrom(foo); + ... + if (any.UnpackTo(&foo)) { + ... + } + +Example 2: Pack and unpack a message in Java. + + Foo foo = ...; + Any any = Any.pack(foo); + ... + if (any.is(Foo.class)) { + foo = any.unpack(Foo.class); + } + + Example 3: Pack and unpack a message in Python. + + foo = Foo(...) + any = Any() + any.Pack(foo) + ... + if any.Is(Foo.DESCRIPTOR): + any.Unpack(foo) + ... + + Example 4: Pack and unpack a message in Go + + foo := &pb.Foo{...} + any, err := anypb.New(foo) + if err != nil { + ... + } + ... + foo := &pb.Foo{} + if err := any.UnmarshalTo(foo); err != nil { + ... + } + +The pack methods provided by protobuf library will by default use +'type.googleapis.com/full.type.name' as the type URL and the unpack +methods only use the fully qualified type name after the last '/' +in the type URL, for example "foo.bar.com/x/y.z" will yield type +name "y.z". + + +JSON +==== +The JSON representation of an `Any` value uses the regular +representation of the deserialized, embedded message, with an +additional field `@type` which contains the type URL. Example: + + package google.profile; + message Person { + string first_name = 1; + string last_name = 2; + } + + { + "@type": "type.googleapis.com/google.profile.Person", + "firstName": , + "lastName": + } + +If the embedded message type is well-known and has a custom JSON +representation, that representation will be embedded adding a field +`value` which holds the custom JSON in addition to the `@type` +field. Example (for message [google.protobuf.Duration][]): + + { + "@type": "type.googleapis.com/google.protobuf.Duration", + "value": "1.212s" + } +*/ +export interface ProtobufAny { + /** + * A URL/resource name that uniquely identifies the type of the serialized + * protocol buffer message. This string must contain at least + * one "/" character. The last segment of the URL's path must represent + * the fully qualified name of the type (as in + * `path/google.protobuf.Duration`). The name should be in a canonical form + * (e.g., leading "." is not accepted). + * + * In practice, teams usually precompile into the binary all types that they + * expect it to use in the context of Any. However, for URLs which use the + * scheme `http`, `https`, or no scheme, one can optionally set up a type + * server that maps type URLs to message definitions as follows: + * + * * If no scheme is provided, `https` is assumed. + * * An HTTP GET on the URL must yield a [google.protobuf.Type][] + * value in binary format, or produce an error. + * * Applications are allowed to cache lookup results based on the + * URL, or have them precompiled into a binary to avoid any + * lookup. Therefore, binary compatibility needs to be preserved + * on changes to types. (Use versioned type names to manage + * breaking changes.) + * + * Note: this functionality is not currently available in the official + * protobuf release, and it is not used for type URLs beginning with + * type.googleapis.com. + * + * Schemes other than `http`, `https` (or the empty scheme) might be + * used with implementation specific semantics. + */ + "@type"?: string; +} + +export interface RpcStatus { + /** @format int32 */ + code?: number; + message?: string; + details?: ProtobufAny[]; +} + +/** + * MsgSubmitEvidenceResponse defines the Msg/SubmitEvidence response type. + */ +export interface V1Beta1MsgSubmitEvidenceResponse { + /** + * hash defines the hash of the evidence. + * @format byte + */ + hash?: string; +} + +/** +* message SomeRequest { + Foo some_parameter = 1; + PageRequest pagination = 2; + } +*/ +export interface V1Beta1PageRequest { + /** + * key is a value returned in PageResponse.next_key to begin + * querying the next page most efficiently. Only one of offset or key + * should be set. + * @format byte + */ + key?: string; + + /** + * offset is a numeric offset that can be used when key is unavailable. + * It is less efficient than using key. Only one of offset or key should + * be set. + * @format uint64 + */ + offset?: string; + + /** + * limit is the total number of results to be returned in the result page. + * If left empty it will default to a value to be set by each app. + * @format uint64 + */ + limit?: string; + + /** + * count_total is set to true to indicate that the result set should include + * a count of the total number of items available for pagination in UIs. + * count_total is only respected when offset is used. It is ignored when key + * is set. + */ + count_total?: boolean; + + /** + * reverse is set to true if results are to be returned in the descending order. + * + * Since: cosmos-sdk 0.43 + */ + reverse?: boolean; +} + +/** +* PageResponse is to be embedded in gRPC response messages where the +corresponding request message has used PageRequest. + + message SomeResponse { + repeated Bar results = 1; + PageResponse page = 2; + } +*/ +export interface V1Beta1PageResponse { + /** @format byte */ + next_key?: string; + + /** @format uint64 */ + total?: string; +} + +/** +* QueryAllEvidenceResponse is the response type for the Query/AllEvidence RPC +method. +*/ +export interface V1Beta1QueryAllEvidenceResponse { + /** evidence returns all evidences. */ + evidence?: ProtobufAny[]; + + /** pagination defines the pagination in the response. */ + pagination?: V1Beta1PageResponse; +} + +/** + * QueryEvidenceResponse is the response type for the Query/Evidence RPC method. + */ +export interface V1Beta1QueryEvidenceResponse { + /** evidence returns the requested evidence. */ + evidence?: ProtobufAny; +} + +export type QueryParamsType = Record; +export type ResponseFormat = keyof Omit; + +export interface FullRequestParams extends Omit { + /** set parameter to `true` for call `securityWorker` for this request */ + secure?: boolean; + /** request path */ + path: string; + /** content type of request body */ + type?: ContentType; + /** query params */ + query?: QueryParamsType; + /** format of response (i.e. response.json() -> format: "json") */ + format?: keyof Omit; + /** request body */ + body?: unknown; + /** base url */ + baseUrl?: string; + /** request cancellation token */ + cancelToken?: CancelToken; +} + +export type RequestParams = Omit; + +export interface ApiConfig { + baseUrl?: string; + baseApiParams?: Omit; + securityWorker?: (securityData: SecurityDataType) => RequestParams | void; +} + +export interface HttpResponse extends Response { + data: D; + error: E; +} + +type CancelToken = Symbol | string | number; + +export enum ContentType { + Json = "application/json", + FormData = "multipart/form-data", + UrlEncoded = "application/x-www-form-urlencoded", +} + +export class HttpClient { + public baseUrl: string = ""; + private securityData: SecurityDataType = null as any; + private securityWorker: null | ApiConfig["securityWorker"] = null; + private abortControllers = new Map(); + + private baseApiParams: RequestParams = { + credentials: "same-origin", + headers: {}, + redirect: "follow", + referrerPolicy: "no-referrer", + }; + + constructor(apiConfig: ApiConfig = {}) { + Object.assign(this, apiConfig); + } + + public setSecurityData = (data: SecurityDataType) => { + this.securityData = data; + }; + + private addQueryParam(query: QueryParamsType, key: string) { + const value = query[key]; + + return ( + encodeURIComponent(key) + + "=" + + encodeURIComponent(Array.isArray(value) ? value.join(",") : typeof value === "number" ? value : `${value}`) + ); + } + + protected toQueryString(rawQuery?: QueryParamsType): string { + const query = rawQuery || {}; + const keys = Object.keys(query).filter((key) => "undefined" !== typeof query[key]); + return keys + .map((key) => + typeof query[key] === "object" && !Array.isArray(query[key]) + ? this.toQueryString(query[key] as QueryParamsType) + : this.addQueryParam(query, key), + ) + .join("&"); + } + + protected addQueryParams(rawQuery?: QueryParamsType): string { + const queryString = this.toQueryString(rawQuery); + return queryString ? `?${queryString}` : ""; + } + + private contentFormatters: Record any> = { + [ContentType.Json]: (input: any) => + input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input, + [ContentType.FormData]: (input: any) => + Object.keys(input || {}).reduce((data, key) => { + data.append(key, input[key]); + return data; + }, new FormData()), + [ContentType.UrlEncoded]: (input: any) => this.toQueryString(input), + }; + + private mergeRequestParams(params1: RequestParams, params2?: RequestParams): RequestParams { + return { + ...this.baseApiParams, + ...params1, + ...(params2 || {}), + headers: { + ...(this.baseApiParams.headers || {}), + ...(params1.headers || {}), + ...((params2 && params2.headers) || {}), + }, + }; + } + + private createAbortSignal = (cancelToken: CancelToken): AbortSignal | undefined => { + if (this.abortControllers.has(cancelToken)) { + const abortController = this.abortControllers.get(cancelToken); + if (abortController) { + return abortController.signal; + } + return void 0; + } + + const abortController = new AbortController(); + this.abortControllers.set(cancelToken, abortController); + return abortController.signal; + }; + + public abortRequest = (cancelToken: CancelToken) => { + const abortController = this.abortControllers.get(cancelToken); + + if (abortController) { + abortController.abort(); + this.abortControllers.delete(cancelToken); + } + }; + + public request = ({ + body, + secure, + path, + type, + query, + format = "json", + baseUrl, + cancelToken, + ...params + }: FullRequestParams): Promise> => { + const secureParams = (secure && this.securityWorker && this.securityWorker(this.securityData)) || {}; + const requestParams = this.mergeRequestParams(params, secureParams); + const queryString = query && this.toQueryString(query); + const payloadFormatter = this.contentFormatters[type || ContentType.Json]; + + return fetch(`${baseUrl || this.baseUrl || ""}${path}${queryString ? `?${queryString}` : ""}`, { + ...requestParams, + headers: { + ...(type && type !== ContentType.FormData ? { "Content-Type": type } : {}), + ...(requestParams.headers || {}), + }, + signal: cancelToken ? this.createAbortSignal(cancelToken) : void 0, + body: typeof body === "undefined" || body === null ? null : payloadFormatter(body), + }).then(async (response) => { + const r = response as HttpResponse; + r.data = (null as unknown) as T; + r.error = (null as unknown) as E; + + const data = await response[format]() + .then((data) => { + if (r.ok) { + r.data = data; + } else { + r.error = data; + } + return r; + }) + .catch((e) => { + r.error = e; + return r; + }); + + if (cancelToken) { + this.abortControllers.delete(cancelToken); + } + + if (!response.ok) throw data; + return data; + }); + }; +} + +/** + * @title cosmos/evidence/v1beta1/evidence.proto + * @version version not set + */ +export class Api extends HttpClient { + /** + * No description + * + * @tags Query + * @name QueryAllEvidence + * @summary AllEvidence queries all evidence. + * @request GET:/cosmos/evidence/v1beta1/evidence + */ + queryAllEvidence = ( + query?: { + "pagination.key"?: string; + "pagination.offset"?: string; + "pagination.limit"?: string; + "pagination.count_total"?: boolean; + "pagination.reverse"?: boolean; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/cosmos/evidence/v1beta1/evidence`, + method: "GET", + query: query, + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Query + * @name QueryEvidence + * @summary Evidence queries evidence based on evidence hash. + * @request GET:/cosmos/evidence/v1beta1/evidence/{evidence_hash} + */ + queryEvidence = (evidence_hash: string, params: RequestParams = {}) => + this.request({ + path: `/cosmos/evidence/v1beta1/evidence/${evidence_hash}`, + method: "GET", + format: "json", + ...params, + }); +} diff --git a/ts-client/cosmos.evidence.v1beta1/types.ts b/ts-client/cosmos.evidence.v1beta1/types.ts new file mode 100755 index 00000000..0114dd34 --- /dev/null +++ b/ts-client/cosmos.evidence.v1beta1/types.ts @@ -0,0 +1,7 @@ +import { Equivocation } from "./types/cosmos/evidence/v1beta1/evidence" + + +export { + Equivocation, + + } \ No newline at end of file diff --git a/ts-client/cosmos.evidence.v1beta1/types/cosmos/base/query/v1beta1/pagination.ts b/ts-client/cosmos.evidence.v1beta1/types/cosmos/base/query/v1beta1/pagination.ts new file mode 100644 index 00000000..cd4b2d78 --- /dev/null +++ b/ts-client/cosmos.evidence.v1beta1/types/cosmos/base/query/v1beta1/pagination.ts @@ -0,0 +1,327 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "cosmos.base.query.v1beta1"; + +/** + * PageRequest is to be embedded in gRPC request messages for efficient + * pagination. Ex: + * + * message SomeRequest { + * Foo some_parameter = 1; + * PageRequest pagination = 2; + * } + */ +export interface PageRequest { + /** + * key is a value returned in PageResponse.next_key to begin + * querying the next page most efficiently. Only one of offset or key + * should be set. + */ + key: Uint8Array; + /** + * offset is a numeric offset that can be used when key is unavailable. + * It is less efficient than using key. Only one of offset or key should + * be set. + */ + offset: number; + /** + * limit is the total number of results to be returned in the result page. + * If left empty it will default to a value to be set by each app. + */ + limit: number; + /** + * count_total is set to true to indicate that the result set should include + * a count of the total number of items available for pagination in UIs. + * count_total is only respected when offset is used. It is ignored when key + * is set. + */ + countTotal: boolean; + /** + * reverse is set to true if results are to be returned in the descending order. + * + * Since: cosmos-sdk 0.43 + */ + reverse: boolean; +} + +/** + * PageResponse is to be embedded in gRPC response messages where the + * corresponding request message has used PageRequest. + * + * message SomeResponse { + * repeated Bar results = 1; + * PageResponse page = 2; + * } + */ +export interface PageResponse { + /** + * next_key is the key to be passed to PageRequest.key to + * query the next page most efficiently + */ + nextKey: Uint8Array; + /** + * total is total number of results available if PageRequest.count_total + * was set, its value is undefined otherwise + */ + total: number; +} + +const basePageRequest: object = { + offset: 0, + limit: 0, + countTotal: false, + reverse: false, +}; + +export const PageRequest = { + encode(message: PageRequest, writer: Writer = Writer.create()): Writer { + if (message.key.length !== 0) { + writer.uint32(10).bytes(message.key); + } + if (message.offset !== 0) { + writer.uint32(16).uint64(message.offset); + } + if (message.limit !== 0) { + writer.uint32(24).uint64(message.limit); + } + if (message.countTotal === true) { + writer.uint32(32).bool(message.countTotal); + } + if (message.reverse === true) { + writer.uint32(40).bool(message.reverse); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): PageRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...basePageRequest } as PageRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.key = reader.bytes(); + break; + case 2: + message.offset = longToNumber(reader.uint64() as Long); + break; + case 3: + message.limit = longToNumber(reader.uint64() as Long); + break; + case 4: + message.countTotal = reader.bool(); + break; + case 5: + message.reverse = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): PageRequest { + const message = { ...basePageRequest } as PageRequest; + if (object.key !== undefined && object.key !== null) { + message.key = bytesFromBase64(object.key); + } + if (object.offset !== undefined && object.offset !== null) { + message.offset = Number(object.offset); + } else { + message.offset = 0; + } + if (object.limit !== undefined && object.limit !== null) { + message.limit = Number(object.limit); + } else { + message.limit = 0; + } + if (object.countTotal !== undefined && object.countTotal !== null) { + message.countTotal = Boolean(object.countTotal); + } else { + message.countTotal = false; + } + if (object.reverse !== undefined && object.reverse !== null) { + message.reverse = Boolean(object.reverse); + } else { + message.reverse = false; + } + return message; + }, + + toJSON(message: PageRequest): unknown { + const obj: any = {}; + message.key !== undefined && + (obj.key = base64FromBytes( + message.key !== undefined ? message.key : new Uint8Array() + )); + message.offset !== undefined && (obj.offset = message.offset); + message.limit !== undefined && (obj.limit = message.limit); + message.countTotal !== undefined && (obj.countTotal = message.countTotal); + message.reverse !== undefined && (obj.reverse = message.reverse); + return obj; + }, + + fromPartial(object: DeepPartial): PageRequest { + const message = { ...basePageRequest } as PageRequest; + if (object.key !== undefined && object.key !== null) { + message.key = object.key; + } else { + message.key = new Uint8Array(); + } + if (object.offset !== undefined && object.offset !== null) { + message.offset = object.offset; + } else { + message.offset = 0; + } + if (object.limit !== undefined && object.limit !== null) { + message.limit = object.limit; + } else { + message.limit = 0; + } + if (object.countTotal !== undefined && object.countTotal !== null) { + message.countTotal = object.countTotal; + } else { + message.countTotal = false; + } + if (object.reverse !== undefined && object.reverse !== null) { + message.reverse = object.reverse; + } else { + message.reverse = false; + } + return message; + }, +}; + +const basePageResponse: object = { total: 0 }; + +export const PageResponse = { + encode(message: PageResponse, writer: Writer = Writer.create()): Writer { + if (message.nextKey.length !== 0) { + writer.uint32(10).bytes(message.nextKey); + } + if (message.total !== 0) { + writer.uint32(16).uint64(message.total); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): PageResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...basePageResponse } as PageResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.nextKey = reader.bytes(); + break; + case 2: + message.total = longToNumber(reader.uint64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): PageResponse { + const message = { ...basePageResponse } as PageResponse; + if (object.nextKey !== undefined && object.nextKey !== null) { + message.nextKey = bytesFromBase64(object.nextKey); + } + if (object.total !== undefined && object.total !== null) { + message.total = Number(object.total); + } else { + message.total = 0; + } + return message; + }, + + toJSON(message: PageResponse): unknown { + const obj: any = {}; + message.nextKey !== undefined && + (obj.nextKey = base64FromBytes( + message.nextKey !== undefined ? message.nextKey : new Uint8Array() + )); + message.total !== undefined && (obj.total = message.total); + return obj; + }, + + fromPartial(object: DeepPartial): PageResponse { + const message = { ...basePageResponse } as PageResponse; + if (object.nextKey !== undefined && object.nextKey !== null) { + message.nextKey = object.nextKey; + } else { + message.nextKey = new Uint8Array(); + } + if (object.total !== undefined && object.total !== null) { + message.total = object.total; + } else { + message.total = 0; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/cosmos.evidence.v1beta1/types/cosmos/evidence/v1beta1/evidence.ts b/ts-client/cosmos.evidence.v1beta1/types/cosmos/evidence/v1beta1/evidence.ts new file mode 100644 index 00000000..30cb0316 --- /dev/null +++ b/ts-client/cosmos.evidence.v1beta1/types/cosmos/evidence/v1beta1/evidence.ts @@ -0,0 +1,192 @@ +/* eslint-disable */ +import { Timestamp } from "../../../google/protobuf/timestamp"; +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "cosmos.evidence.v1beta1"; + +/** + * Equivocation implements the Evidence interface and defines evidence of double + * signing misbehavior. + */ +export interface Equivocation { + height: number; + time: Date | undefined; + power: number; + consensusAddress: string; +} + +const baseEquivocation: object = { height: 0, power: 0, consensusAddress: "" }; + +export const Equivocation = { + encode(message: Equivocation, writer: Writer = Writer.create()): Writer { + if (message.height !== 0) { + writer.uint32(8).int64(message.height); + } + if (message.time !== undefined) { + Timestamp.encode( + toTimestamp(message.time), + writer.uint32(18).fork() + ).ldelim(); + } + if (message.power !== 0) { + writer.uint32(24).int64(message.power); + } + if (message.consensusAddress !== "") { + writer.uint32(34).string(message.consensusAddress); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Equivocation { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseEquivocation } as Equivocation; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.height = longToNumber(reader.int64() as Long); + break; + case 2: + message.time = fromTimestamp( + Timestamp.decode(reader, reader.uint32()) + ); + break; + case 3: + message.power = longToNumber(reader.int64() as Long); + break; + case 4: + message.consensusAddress = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Equivocation { + const message = { ...baseEquivocation } as Equivocation; + if (object.height !== undefined && object.height !== null) { + message.height = Number(object.height); + } else { + message.height = 0; + } + if (object.time !== undefined && object.time !== null) { + message.time = fromJsonTimestamp(object.time); + } else { + message.time = undefined; + } + if (object.power !== undefined && object.power !== null) { + message.power = Number(object.power); + } else { + message.power = 0; + } + if ( + object.consensusAddress !== undefined && + object.consensusAddress !== null + ) { + message.consensusAddress = String(object.consensusAddress); + } else { + message.consensusAddress = ""; + } + return message; + }, + + toJSON(message: Equivocation): unknown { + const obj: any = {}; + message.height !== undefined && (obj.height = message.height); + message.time !== undefined && + (obj.time = + message.time !== undefined ? message.time.toISOString() : null); + message.power !== undefined && (obj.power = message.power); + message.consensusAddress !== undefined && + (obj.consensusAddress = message.consensusAddress); + return obj; + }, + + fromPartial(object: DeepPartial): Equivocation { + const message = { ...baseEquivocation } as Equivocation; + if (object.height !== undefined && object.height !== null) { + message.height = object.height; + } else { + message.height = 0; + } + if (object.time !== undefined && object.time !== null) { + message.time = object.time; + } else { + message.time = undefined; + } + if (object.power !== undefined && object.power !== null) { + message.power = object.power; + } else { + message.power = 0; + } + if ( + object.consensusAddress !== undefined && + object.consensusAddress !== null + ) { + message.consensusAddress = object.consensusAddress; + } else { + message.consensusAddress = ""; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function toTimestamp(date: Date): Timestamp { + const seconds = date.getTime() / 1_000; + const nanos = (date.getTime() % 1_000) * 1_000_000; + return { seconds, nanos }; +} + +function fromTimestamp(t: Timestamp): Date { + let millis = t.seconds * 1_000; + millis += t.nanos / 1_000_000; + return new Date(millis); +} + +function fromJsonTimestamp(o: any): Date { + if (o instanceof Date) { + return o; + } else if (typeof o === "string") { + return new Date(o); + } else { + return fromTimestamp(Timestamp.fromJSON(o)); + } +} + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/cosmos.evidence.v1beta1/types/cosmos/evidence/v1beta1/genesis.ts b/ts-client/cosmos.evidence.v1beta1/types/cosmos/evidence/v1beta1/genesis.ts new file mode 100644 index 00000000..2b659101 --- /dev/null +++ b/ts-client/cosmos.evidence.v1beta1/types/cosmos/evidence/v1beta1/genesis.ts @@ -0,0 +1,86 @@ +/* eslint-disable */ +import { Any } from "../../../google/protobuf/any"; +import { Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "cosmos.evidence.v1beta1"; + +/** GenesisState defines the evidence module's genesis state. */ +export interface GenesisState { + /** evidence defines all the evidence at genesis. */ + evidence: Any[]; +} + +const baseGenesisState: object = {}; + +export const GenesisState = { + encode(message: GenesisState, writer: Writer = Writer.create()): Writer { + for (const v of message.evidence) { + Any.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): GenesisState { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseGenesisState } as GenesisState; + message.evidence = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.evidence.push(Any.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GenesisState { + const message = { ...baseGenesisState } as GenesisState; + message.evidence = []; + if (object.evidence !== undefined && object.evidence !== null) { + for (const e of object.evidence) { + message.evidence.push(Any.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: GenesisState): unknown { + const obj: any = {}; + if (message.evidence) { + obj.evidence = message.evidence.map((e) => + e ? Any.toJSON(e) : undefined + ); + } else { + obj.evidence = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): GenesisState { + const message = { ...baseGenesisState } as GenesisState; + message.evidence = []; + if (object.evidence !== undefined && object.evidence !== null) { + for (const e of object.evidence) { + message.evidence.push(Any.fromPartial(e)); + } + } + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/cosmos.evidence.v1beta1/types/cosmos/evidence/v1beta1/query.ts b/ts-client/cosmos.evidence.v1beta1/types/cosmos/evidence/v1beta1/query.ts new file mode 100644 index 00000000..3c756624 --- /dev/null +++ b/ts-client/cosmos.evidence.v1beta1/types/cosmos/evidence/v1beta1/query.ts @@ -0,0 +1,429 @@ +/* eslint-disable */ +import { Reader, Writer } from "protobufjs/minimal"; +import { Any } from "../../../google/protobuf/any"; +import { + PageRequest, + PageResponse, +} from "../../../cosmos/base/query/v1beta1/pagination"; + +export const protobufPackage = "cosmos.evidence.v1beta1"; + +/** QueryEvidenceRequest is the request type for the Query/Evidence RPC method. */ +export interface QueryEvidenceRequest { + /** evidence_hash defines the hash of the requested evidence. */ + evidenceHash: Uint8Array; +} + +/** QueryEvidenceResponse is the response type for the Query/Evidence RPC method. */ +export interface QueryEvidenceResponse { + /** evidence returns the requested evidence. */ + evidence: Any | undefined; +} + +/** + * QueryEvidenceRequest is the request type for the Query/AllEvidence RPC + * method. + */ +export interface QueryAllEvidenceRequest { + /** pagination defines an optional pagination for the request. */ + pagination: PageRequest | undefined; +} + +/** + * QueryAllEvidenceResponse is the response type for the Query/AllEvidence RPC + * method. + */ +export interface QueryAllEvidenceResponse { + /** evidence returns all evidences. */ + evidence: Any[]; + /** pagination defines the pagination in the response. */ + pagination: PageResponse | undefined; +} + +const baseQueryEvidenceRequest: object = {}; + +export const QueryEvidenceRequest = { + encode( + message: QueryEvidenceRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.evidenceHash.length !== 0) { + writer.uint32(10).bytes(message.evidenceHash); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QueryEvidenceRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryEvidenceRequest } as QueryEvidenceRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.evidenceHash = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryEvidenceRequest { + const message = { ...baseQueryEvidenceRequest } as QueryEvidenceRequest; + if (object.evidenceHash !== undefined && object.evidenceHash !== null) { + message.evidenceHash = bytesFromBase64(object.evidenceHash); + } + return message; + }, + + toJSON(message: QueryEvidenceRequest): unknown { + const obj: any = {}; + message.evidenceHash !== undefined && + (obj.evidenceHash = base64FromBytes( + message.evidenceHash !== undefined + ? message.evidenceHash + : new Uint8Array() + )); + return obj; + }, + + fromPartial(object: DeepPartial): QueryEvidenceRequest { + const message = { ...baseQueryEvidenceRequest } as QueryEvidenceRequest; + if (object.evidenceHash !== undefined && object.evidenceHash !== null) { + message.evidenceHash = object.evidenceHash; + } else { + message.evidenceHash = new Uint8Array(); + } + return message; + }, +}; + +const baseQueryEvidenceResponse: object = {}; + +export const QueryEvidenceResponse = { + encode( + message: QueryEvidenceResponse, + writer: Writer = Writer.create() + ): Writer { + if (message.evidence !== undefined) { + Any.encode(message.evidence, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QueryEvidenceResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryEvidenceResponse } as QueryEvidenceResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.evidence = Any.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryEvidenceResponse { + const message = { ...baseQueryEvidenceResponse } as QueryEvidenceResponse; + if (object.evidence !== undefined && object.evidence !== null) { + message.evidence = Any.fromJSON(object.evidence); + } else { + message.evidence = undefined; + } + return message; + }, + + toJSON(message: QueryEvidenceResponse): unknown { + const obj: any = {}; + message.evidence !== undefined && + (obj.evidence = message.evidence + ? Any.toJSON(message.evidence) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryEvidenceResponse { + const message = { ...baseQueryEvidenceResponse } as QueryEvidenceResponse; + if (object.evidence !== undefined && object.evidence !== null) { + message.evidence = Any.fromPartial(object.evidence); + } else { + message.evidence = undefined; + } + return message; + }, +}; + +const baseQueryAllEvidenceRequest: object = {}; + +export const QueryAllEvidenceRequest = { + encode( + message: QueryAllEvidenceRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QueryAllEvidenceRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryAllEvidenceRequest, + } as QueryAllEvidenceRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryAllEvidenceRequest { + const message = { + ...baseQueryAllEvidenceRequest, + } as QueryAllEvidenceRequest; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryAllEvidenceRequest): unknown { + const obj: any = {}; + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageRequest.toJSON(message.pagination) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryAllEvidenceRequest { + const message = { + ...baseQueryAllEvidenceRequest, + } as QueryAllEvidenceRequest; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseQueryAllEvidenceResponse: object = {}; + +export const QueryAllEvidenceResponse = { + encode( + message: QueryAllEvidenceResponse, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.evidence) { + Any.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode( + message.pagination, + writer.uint32(18).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryAllEvidenceResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryAllEvidenceResponse, + } as QueryAllEvidenceResponse; + message.evidence = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.evidence.push(Any.decode(reader, reader.uint32())); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryAllEvidenceResponse { + const message = { + ...baseQueryAllEvidenceResponse, + } as QueryAllEvidenceResponse; + message.evidence = []; + if (object.evidence !== undefined && object.evidence !== null) { + for (const e of object.evidence) { + message.evidence.push(Any.fromJSON(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryAllEvidenceResponse): unknown { + const obj: any = {}; + if (message.evidence) { + obj.evidence = message.evidence.map((e) => + e ? Any.toJSON(e) : undefined + ); + } else { + obj.evidence = []; + } + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageResponse.toJSON(message.pagination) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryAllEvidenceResponse { + const message = { + ...baseQueryAllEvidenceResponse, + } as QueryAllEvidenceResponse; + message.evidence = []; + if (object.evidence !== undefined && object.evidence !== null) { + for (const e of object.evidence) { + message.evidence.push(Any.fromPartial(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +/** Query defines the gRPC querier service. */ +export interface Query { + /** Evidence queries evidence based on evidence hash. */ + Evidence(request: QueryEvidenceRequest): Promise; + /** AllEvidence queries all evidence. */ + AllEvidence( + request: QueryAllEvidenceRequest + ): Promise; +} + +export class QueryClientImpl implements Query { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + } + Evidence(request: QueryEvidenceRequest): Promise { + const data = QueryEvidenceRequest.encode(request).finish(); + const promise = this.rpc.request( + "cosmos.evidence.v1beta1.Query", + "Evidence", + data + ); + return promise.then((data) => + QueryEvidenceResponse.decode(new Reader(data)) + ); + } + + AllEvidence( + request: QueryAllEvidenceRequest + ): Promise { + const data = QueryAllEvidenceRequest.encode(request).finish(); + const promise = this.rpc.request( + "cosmos.evidence.v1beta1.Query", + "AllEvidence", + data + ); + return promise.then((data) => + QueryAllEvidenceResponse.decode(new Reader(data)) + ); + } +} + +interface Rpc { + request( + service: string, + method: string, + data: Uint8Array + ): Promise; +} + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/cosmos.evidence.v1beta1/types/cosmos/evidence/v1beta1/tx.ts b/ts-client/cosmos.evidence.v1beta1/types/cosmos/evidence/v1beta1/tx.ts new file mode 100644 index 00000000..51a891b9 --- /dev/null +++ b/ts-client/cosmos.evidence.v1beta1/types/cosmos/evidence/v1beta1/tx.ts @@ -0,0 +1,248 @@ +/* eslint-disable */ +import { Reader, Writer } from "protobufjs/minimal"; +import { Any } from "../../../google/protobuf/any"; + +export const protobufPackage = "cosmos.evidence.v1beta1"; + +/** + * MsgSubmitEvidence represents a message that supports submitting arbitrary + * Evidence of misbehavior such as equivocation or counterfactual signing. + */ +export interface MsgSubmitEvidence { + submitter: string; + evidence: Any | undefined; +} + +/** MsgSubmitEvidenceResponse defines the Msg/SubmitEvidence response type. */ +export interface MsgSubmitEvidenceResponse { + /** hash defines the hash of the evidence. */ + hash: Uint8Array; +} + +const baseMsgSubmitEvidence: object = { submitter: "" }; + +export const MsgSubmitEvidence = { + encode(message: MsgSubmitEvidence, writer: Writer = Writer.create()): Writer { + if (message.submitter !== "") { + writer.uint32(10).string(message.submitter); + } + if (message.evidence !== undefined) { + Any.encode(message.evidence, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MsgSubmitEvidence { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgSubmitEvidence } as MsgSubmitEvidence; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.submitter = reader.string(); + break; + case 2: + message.evidence = Any.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgSubmitEvidence { + const message = { ...baseMsgSubmitEvidence } as MsgSubmitEvidence; + if (object.submitter !== undefined && object.submitter !== null) { + message.submitter = String(object.submitter); + } else { + message.submitter = ""; + } + if (object.evidence !== undefined && object.evidence !== null) { + message.evidence = Any.fromJSON(object.evidence); + } else { + message.evidence = undefined; + } + return message; + }, + + toJSON(message: MsgSubmitEvidence): unknown { + const obj: any = {}; + message.submitter !== undefined && (obj.submitter = message.submitter); + message.evidence !== undefined && + (obj.evidence = message.evidence + ? Any.toJSON(message.evidence) + : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): MsgSubmitEvidence { + const message = { ...baseMsgSubmitEvidence } as MsgSubmitEvidence; + if (object.submitter !== undefined && object.submitter !== null) { + message.submitter = object.submitter; + } else { + message.submitter = ""; + } + if (object.evidence !== undefined && object.evidence !== null) { + message.evidence = Any.fromPartial(object.evidence); + } else { + message.evidence = undefined; + } + return message; + }, +}; + +const baseMsgSubmitEvidenceResponse: object = {}; + +export const MsgSubmitEvidenceResponse = { + encode( + message: MsgSubmitEvidenceResponse, + writer: Writer = Writer.create() + ): Writer { + if (message.hash.length !== 0) { + writer.uint32(34).bytes(message.hash); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): MsgSubmitEvidenceResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseMsgSubmitEvidenceResponse, + } as MsgSubmitEvidenceResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 4: + message.hash = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgSubmitEvidenceResponse { + const message = { + ...baseMsgSubmitEvidenceResponse, + } as MsgSubmitEvidenceResponse; + if (object.hash !== undefined && object.hash !== null) { + message.hash = bytesFromBase64(object.hash); + } + return message; + }, + + toJSON(message: MsgSubmitEvidenceResponse): unknown { + const obj: any = {}; + message.hash !== undefined && + (obj.hash = base64FromBytes( + message.hash !== undefined ? message.hash : new Uint8Array() + )); + return obj; + }, + + fromPartial( + object: DeepPartial + ): MsgSubmitEvidenceResponse { + const message = { + ...baseMsgSubmitEvidenceResponse, + } as MsgSubmitEvidenceResponse; + if (object.hash !== undefined && object.hash !== null) { + message.hash = object.hash; + } else { + message.hash = new Uint8Array(); + } + return message; + }, +}; + +/** Msg defines the evidence Msg service. */ +export interface Msg { + /** + * SubmitEvidence submits an arbitrary Evidence of misbehavior such as equivocation or + * counterfactual signing. + */ + SubmitEvidence( + request: MsgSubmitEvidence + ): Promise; +} + +export class MsgClientImpl implements Msg { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + } + SubmitEvidence( + request: MsgSubmitEvidence + ): Promise { + const data = MsgSubmitEvidence.encode(request).finish(); + const promise = this.rpc.request( + "cosmos.evidence.v1beta1.Msg", + "SubmitEvidence", + data + ); + return promise.then((data) => + MsgSubmitEvidenceResponse.decode(new Reader(data)) + ); + } +} + +interface Rpc { + request( + service: string, + method: string, + data: Uint8Array + ): Promise; +} + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/cosmos.evidence.v1beta1/types/cosmos_proto/cosmos.ts b/ts-client/cosmos.evidence.v1beta1/types/cosmos_proto/cosmos.ts new file mode 100644 index 00000000..9ec67a12 --- /dev/null +++ b/ts-client/cosmos.evidence.v1beta1/types/cosmos_proto/cosmos.ts @@ -0,0 +1,2 @@ +/* eslint-disable */ +export const protobufPackage = "cosmos_proto"; diff --git a/ts-client/cosmos.evidence.v1beta1/types/gogoproto/gogo.ts b/ts-client/cosmos.evidence.v1beta1/types/gogoproto/gogo.ts new file mode 100644 index 00000000..3f41a047 --- /dev/null +++ b/ts-client/cosmos.evidence.v1beta1/types/gogoproto/gogo.ts @@ -0,0 +1,2 @@ +/* eslint-disable */ +export const protobufPackage = "gogoproto"; diff --git a/ts-client/cosmos.evidence.v1beta1/types/google/api/annotations.ts b/ts-client/cosmos.evidence.v1beta1/types/google/api/annotations.ts new file mode 100644 index 00000000..aace4787 --- /dev/null +++ b/ts-client/cosmos.evidence.v1beta1/types/google/api/annotations.ts @@ -0,0 +1,2 @@ +/* eslint-disable */ +export const protobufPackage = "google.api"; diff --git a/ts-client/cosmos.evidence.v1beta1/types/google/api/http.ts b/ts-client/cosmos.evidence.v1beta1/types/google/api/http.ts new file mode 100644 index 00000000..ddc00f8b --- /dev/null +++ b/ts-client/cosmos.evidence.v1beta1/types/google/api/http.ts @@ -0,0 +1,705 @@ +/* eslint-disable */ +import { Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "google.api"; + +/** + * Defines the HTTP configuration for an API service. It contains a list of + * [HttpRule][google.api.HttpRule], each specifying the mapping of an RPC method + * to one or more HTTP REST API methods. + */ +export interface Http { + /** + * A list of HTTP configuration rules that apply to individual API methods. + * + * **NOTE:** All service configuration rules follow "last one wins" order. + */ + rules: HttpRule[]; + /** + * When set to true, URL path parmeters will be fully URI-decoded except in + * cases of single segment matches in reserved expansion, where "%2F" will be + * left encoded. + * + * The default behavior is to not decode RFC 6570 reserved characters in multi + * segment matches. + */ + fullyDecodeReservedExpansion: boolean; +} + +/** + * `HttpRule` defines the mapping of an RPC method to one or more HTTP + * REST API methods. The mapping specifies how different portions of the RPC + * request message are mapped to URL path, URL query parameters, and + * HTTP request body. The mapping is typically specified as an + * `google.api.http` annotation on the RPC method, + * see "google/api/annotations.proto" for details. + * + * The mapping consists of a field specifying the path template and + * method kind. The path template can refer to fields in the request + * message, as in the example below which describes a REST GET + * operation on a resource collection of messages: + * + * + * service Messaging { + * rpc GetMessage(GetMessageRequest) returns (Message) { + * option (google.api.http).get = "/v1/messages/{message_id}/{sub.subfield}"; + * } + * } + * message GetMessageRequest { + * message SubMessage { + * string subfield = 1; + * } + * string message_id = 1; // mapped to the URL + * SubMessage sub = 2; // `sub.subfield` is url-mapped + * } + * message Message { + * string text = 1; // content of the resource + * } + * + * The same http annotation can alternatively be expressed inside the + * `GRPC API Configuration` YAML file. + * + * http: + * rules: + * - selector: .Messaging.GetMessage + * get: /v1/messages/{message_id}/{sub.subfield} + * + * This definition enables an automatic, bidrectional mapping of HTTP + * JSON to RPC. Example: + * + * HTTP | RPC + * -----|----- + * `GET /v1/messages/123456/foo` | `GetMessage(message_id: "123456" sub: SubMessage(subfield: "foo"))` + * + * In general, not only fields but also field paths can be referenced + * from a path pattern. Fields mapped to the path pattern cannot be + * repeated and must have a primitive (non-message) type. + * + * Any fields in the request message which are not bound by the path + * pattern automatically become (optional) HTTP query + * parameters. Assume the following definition of the request message: + * + * + * service Messaging { + * rpc GetMessage(GetMessageRequest) returns (Message) { + * option (google.api.http).get = "/v1/messages/{message_id}"; + * } + * } + * message GetMessageRequest { + * message SubMessage { + * string subfield = 1; + * } + * string message_id = 1; // mapped to the URL + * int64 revision = 2; // becomes a parameter + * SubMessage sub = 3; // `sub.subfield` becomes a parameter + * } + * + * + * This enables a HTTP JSON to RPC mapping as below: + * + * HTTP | RPC + * -----|----- + * `GET /v1/messages/123456?revision=2&sub.subfield=foo` | `GetMessage(message_id: "123456" revision: 2 sub: SubMessage(subfield: "foo"))` + * + * Note that fields which are mapped to HTTP parameters must have a + * primitive type or a repeated primitive type. Message types are not + * allowed. In the case of a repeated type, the parameter can be + * repeated in the URL, as in `...?param=A¶m=B`. + * + * For HTTP method kinds which allow a request body, the `body` field + * specifies the mapping. Consider a REST update method on the + * message resource collection: + * + * + * service Messaging { + * rpc UpdateMessage(UpdateMessageRequest) returns (Message) { + * option (google.api.http) = { + * put: "/v1/messages/{message_id}" + * body: "message" + * }; + * } + * } + * message UpdateMessageRequest { + * string message_id = 1; // mapped to the URL + * Message message = 2; // mapped to the body + * } + * + * + * The following HTTP JSON to RPC mapping is enabled, where the + * representation of the JSON in the request body is determined by + * protos JSON encoding: + * + * HTTP | RPC + * -----|----- + * `PUT /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: "123456" message { text: "Hi!" })` + * + * The special name `*` can be used in the body mapping to define that + * every field not bound by the path template should be mapped to the + * request body. This enables the following alternative definition of + * the update method: + * + * service Messaging { + * rpc UpdateMessage(Message) returns (Message) { + * option (google.api.http) = { + * put: "/v1/messages/{message_id}" + * body: "*" + * }; + * } + * } + * message Message { + * string message_id = 1; + * string text = 2; + * } + * + * + * The following HTTP JSON to RPC mapping is enabled: + * + * HTTP | RPC + * -----|----- + * `PUT /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: "123456" text: "Hi!")` + * + * Note that when using `*` in the body mapping, it is not possible to + * have HTTP parameters, as all fields not bound by the path end in + * the body. This makes this option more rarely used in practice of + * defining REST APIs. The common usage of `*` is in custom methods + * which don't use the URL at all for transferring data. + * + * It is possible to define multiple HTTP methods for one RPC by using + * the `additional_bindings` option. Example: + * + * service Messaging { + * rpc GetMessage(GetMessageRequest) returns (Message) { + * option (google.api.http) = { + * get: "/v1/messages/{message_id}" + * additional_bindings { + * get: "/v1/users/{user_id}/messages/{message_id}" + * } + * }; + * } + * } + * message GetMessageRequest { + * string message_id = 1; + * string user_id = 2; + * } + * + * + * This enables the following two alternative HTTP JSON to RPC + * mappings: + * + * HTTP | RPC + * -----|----- + * `GET /v1/messages/123456` | `GetMessage(message_id: "123456")` + * `GET /v1/users/me/messages/123456` | `GetMessage(user_id: "me" message_id: "123456")` + * + * # Rules for HTTP mapping + * + * The rules for mapping HTTP path, query parameters, and body fields + * to the request message are as follows: + * + * 1. The `body` field specifies either `*` or a field path, or is + * omitted. If omitted, it indicates there is no HTTP request body. + * 2. Leaf fields (recursive expansion of nested messages in the + * request) can be classified into three types: + * (a) Matched in the URL template. + * (b) Covered by body (if body is `*`, everything except (a) fields; + * else everything under the body field) + * (c) All other fields. + * 3. URL query parameters found in the HTTP request are mapped to (c) fields. + * 4. Any body sent with an HTTP request can contain only (b) fields. + * + * The syntax of the path template is as follows: + * + * Template = "/" Segments [ Verb ] ; + * Segments = Segment { "/" Segment } ; + * Segment = "*" | "**" | LITERAL | Variable ; + * Variable = "{" FieldPath [ "=" Segments ] "}" ; + * FieldPath = IDENT { "." IDENT } ; + * Verb = ":" LITERAL ; + * + * The syntax `*` matches a single path segment. The syntax `**` matches zero + * or more path segments, which must be the last part of the path except the + * `Verb`. The syntax `LITERAL` matches literal text in the path. + * + * The syntax `Variable` matches part of the URL path as specified by its + * template. A variable template must not contain other variables. If a variable + * matches a single path segment, its template may be omitted, e.g. `{var}` + * is equivalent to `{var=*}`. + * + * If a variable contains exactly one path segment, such as `"{var}"` or + * `"{var=*}"`, when such a variable is expanded into a URL path, all characters + * except `[-_.~0-9a-zA-Z]` are percent-encoded. Such variables show up in the + * Discovery Document as `{var}`. + * + * If a variable contains one or more path segments, such as `"{var=foo/*}"` + * or `"{var=**}"`, when such a variable is expanded into a URL path, all + * characters except `[-_.~/0-9a-zA-Z]` are percent-encoded. Such variables + * show up in the Discovery Document as `{+var}`. + * + * NOTE: While the single segment variable matches the semantics of + * [RFC 6570](https://tools.ietf.org/html/rfc6570) Section 3.2.2 + * Simple String Expansion, the multi segment variable **does not** match + * RFC 6570 Reserved Expansion. The reason is that the Reserved Expansion + * does not expand special characters like `?` and `#`, which would lead + * to invalid URLs. + * + * NOTE: the field paths in variables and in the `body` must not refer to + * repeated fields or map fields. + */ +export interface HttpRule { + /** + * Selects methods to which this rule applies. + * + * Refer to [selector][google.api.DocumentationRule.selector] for syntax details. + */ + selector: string; + /** Used for listing and getting information about resources. */ + get: string | undefined; + /** Used for updating a resource. */ + put: string | undefined; + /** Used for creating a resource. */ + post: string | undefined; + /** Used for deleting a resource. */ + delete: string | undefined; + /** Used for updating a resource. */ + patch: string | undefined; + /** + * The custom pattern is used for specifying an HTTP method that is not + * included in the `pattern` field, such as HEAD, or "*" to leave the + * HTTP method unspecified for this rule. The wild-card rule is useful + * for services that provide content to Web (HTML) clients. + */ + custom: CustomHttpPattern | undefined; + /** + * The name of the request field whose value is mapped to the HTTP body, or + * `*` for mapping all fields not captured by the path pattern to the HTTP + * body. NOTE: the referred field must not be a repeated field and must be + * present at the top-level of request message type. + */ + body: string; + /** + * Optional. The name of the response field whose value is mapped to the HTTP + * body of response. Other response fields are ignored. When + * not set, the response message will be used as HTTP body of response. + */ + responseBody: string; + /** + * Additional HTTP bindings for the selector. Nested bindings must + * not contain an `additional_bindings` field themselves (that is, + * the nesting may only be one level deep). + */ + additionalBindings: HttpRule[]; +} + +/** A custom pattern is used for defining custom HTTP verb. */ +export interface CustomHttpPattern { + /** The name of this custom HTTP verb. */ + kind: string; + /** The path matched by this custom verb. */ + path: string; +} + +const baseHttp: object = { fullyDecodeReservedExpansion: false }; + +export const Http = { + encode(message: Http, writer: Writer = Writer.create()): Writer { + for (const v of message.rules) { + HttpRule.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.fullyDecodeReservedExpansion === true) { + writer.uint32(16).bool(message.fullyDecodeReservedExpansion); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Http { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseHttp } as Http; + message.rules = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.rules.push(HttpRule.decode(reader, reader.uint32())); + break; + case 2: + message.fullyDecodeReservedExpansion = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Http { + const message = { ...baseHttp } as Http; + message.rules = []; + if (object.rules !== undefined && object.rules !== null) { + for (const e of object.rules) { + message.rules.push(HttpRule.fromJSON(e)); + } + } + if ( + object.fullyDecodeReservedExpansion !== undefined && + object.fullyDecodeReservedExpansion !== null + ) { + message.fullyDecodeReservedExpansion = Boolean( + object.fullyDecodeReservedExpansion + ); + } else { + message.fullyDecodeReservedExpansion = false; + } + return message; + }, + + toJSON(message: Http): unknown { + const obj: any = {}; + if (message.rules) { + obj.rules = message.rules.map((e) => + e ? HttpRule.toJSON(e) : undefined + ); + } else { + obj.rules = []; + } + message.fullyDecodeReservedExpansion !== undefined && + (obj.fullyDecodeReservedExpansion = message.fullyDecodeReservedExpansion); + return obj; + }, + + fromPartial(object: DeepPartial): Http { + const message = { ...baseHttp } as Http; + message.rules = []; + if (object.rules !== undefined && object.rules !== null) { + for (const e of object.rules) { + message.rules.push(HttpRule.fromPartial(e)); + } + } + if ( + object.fullyDecodeReservedExpansion !== undefined && + object.fullyDecodeReservedExpansion !== null + ) { + message.fullyDecodeReservedExpansion = + object.fullyDecodeReservedExpansion; + } else { + message.fullyDecodeReservedExpansion = false; + } + return message; + }, +}; + +const baseHttpRule: object = { selector: "", body: "", responseBody: "" }; + +export const HttpRule = { + encode(message: HttpRule, writer: Writer = Writer.create()): Writer { + if (message.selector !== "") { + writer.uint32(10).string(message.selector); + } + if (message.get !== undefined) { + writer.uint32(18).string(message.get); + } + if (message.put !== undefined) { + writer.uint32(26).string(message.put); + } + if (message.post !== undefined) { + writer.uint32(34).string(message.post); + } + if (message.delete !== undefined) { + writer.uint32(42).string(message.delete); + } + if (message.patch !== undefined) { + writer.uint32(50).string(message.patch); + } + if (message.custom !== undefined) { + CustomHttpPattern.encode( + message.custom, + writer.uint32(66).fork() + ).ldelim(); + } + if (message.body !== "") { + writer.uint32(58).string(message.body); + } + if (message.responseBody !== "") { + writer.uint32(98).string(message.responseBody); + } + for (const v of message.additionalBindings) { + HttpRule.encode(v!, writer.uint32(90).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): HttpRule { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseHttpRule } as HttpRule; + message.additionalBindings = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.selector = reader.string(); + break; + case 2: + message.get = reader.string(); + break; + case 3: + message.put = reader.string(); + break; + case 4: + message.post = reader.string(); + break; + case 5: + message.delete = reader.string(); + break; + case 6: + message.patch = reader.string(); + break; + case 8: + message.custom = CustomHttpPattern.decode(reader, reader.uint32()); + break; + case 7: + message.body = reader.string(); + break; + case 12: + message.responseBody = reader.string(); + break; + case 11: + message.additionalBindings.push( + HttpRule.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): HttpRule { + const message = { ...baseHttpRule } as HttpRule; + message.additionalBindings = []; + if (object.selector !== undefined && object.selector !== null) { + message.selector = String(object.selector); + } else { + message.selector = ""; + } + if (object.get !== undefined && object.get !== null) { + message.get = String(object.get); + } else { + message.get = undefined; + } + if (object.put !== undefined && object.put !== null) { + message.put = String(object.put); + } else { + message.put = undefined; + } + if (object.post !== undefined && object.post !== null) { + message.post = String(object.post); + } else { + message.post = undefined; + } + if (object.delete !== undefined && object.delete !== null) { + message.delete = String(object.delete); + } else { + message.delete = undefined; + } + if (object.patch !== undefined && object.patch !== null) { + message.patch = String(object.patch); + } else { + message.patch = undefined; + } + if (object.custom !== undefined && object.custom !== null) { + message.custom = CustomHttpPattern.fromJSON(object.custom); + } else { + message.custom = undefined; + } + if (object.body !== undefined && object.body !== null) { + message.body = String(object.body); + } else { + message.body = ""; + } + if (object.responseBody !== undefined && object.responseBody !== null) { + message.responseBody = String(object.responseBody); + } else { + message.responseBody = ""; + } + if ( + object.additionalBindings !== undefined && + object.additionalBindings !== null + ) { + for (const e of object.additionalBindings) { + message.additionalBindings.push(HttpRule.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: HttpRule): unknown { + const obj: any = {}; + message.selector !== undefined && (obj.selector = message.selector); + message.get !== undefined && (obj.get = message.get); + message.put !== undefined && (obj.put = message.put); + message.post !== undefined && (obj.post = message.post); + message.delete !== undefined && (obj.delete = message.delete); + message.patch !== undefined && (obj.patch = message.patch); + message.custom !== undefined && + (obj.custom = message.custom + ? CustomHttpPattern.toJSON(message.custom) + : undefined); + message.body !== undefined && (obj.body = message.body); + message.responseBody !== undefined && + (obj.responseBody = message.responseBody); + if (message.additionalBindings) { + obj.additionalBindings = message.additionalBindings.map((e) => + e ? HttpRule.toJSON(e) : undefined + ); + } else { + obj.additionalBindings = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): HttpRule { + const message = { ...baseHttpRule } as HttpRule; + message.additionalBindings = []; + if (object.selector !== undefined && object.selector !== null) { + message.selector = object.selector; + } else { + message.selector = ""; + } + if (object.get !== undefined && object.get !== null) { + message.get = object.get; + } else { + message.get = undefined; + } + if (object.put !== undefined && object.put !== null) { + message.put = object.put; + } else { + message.put = undefined; + } + if (object.post !== undefined && object.post !== null) { + message.post = object.post; + } else { + message.post = undefined; + } + if (object.delete !== undefined && object.delete !== null) { + message.delete = object.delete; + } else { + message.delete = undefined; + } + if (object.patch !== undefined && object.patch !== null) { + message.patch = object.patch; + } else { + message.patch = undefined; + } + if (object.custom !== undefined && object.custom !== null) { + message.custom = CustomHttpPattern.fromPartial(object.custom); + } else { + message.custom = undefined; + } + if (object.body !== undefined && object.body !== null) { + message.body = object.body; + } else { + message.body = ""; + } + if (object.responseBody !== undefined && object.responseBody !== null) { + message.responseBody = object.responseBody; + } else { + message.responseBody = ""; + } + if ( + object.additionalBindings !== undefined && + object.additionalBindings !== null + ) { + for (const e of object.additionalBindings) { + message.additionalBindings.push(HttpRule.fromPartial(e)); + } + } + return message; + }, +}; + +const baseCustomHttpPattern: object = { kind: "", path: "" }; + +export const CustomHttpPattern = { + encode(message: CustomHttpPattern, writer: Writer = Writer.create()): Writer { + if (message.kind !== "") { + writer.uint32(10).string(message.kind); + } + if (message.path !== "") { + writer.uint32(18).string(message.path); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): CustomHttpPattern { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseCustomHttpPattern } as CustomHttpPattern; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.kind = reader.string(); + break; + case 2: + message.path = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): CustomHttpPattern { + const message = { ...baseCustomHttpPattern } as CustomHttpPattern; + if (object.kind !== undefined && object.kind !== null) { + message.kind = String(object.kind); + } else { + message.kind = ""; + } + if (object.path !== undefined && object.path !== null) { + message.path = String(object.path); + } else { + message.path = ""; + } + return message; + }, + + toJSON(message: CustomHttpPattern): unknown { + const obj: any = {}; + message.kind !== undefined && (obj.kind = message.kind); + message.path !== undefined && (obj.path = message.path); + return obj; + }, + + fromPartial(object: DeepPartial): CustomHttpPattern { + const message = { ...baseCustomHttpPattern } as CustomHttpPattern; + if (object.kind !== undefined && object.kind !== null) { + message.kind = object.kind; + } else { + message.kind = ""; + } + if (object.path !== undefined && object.path !== null) { + message.path = object.path; + } else { + message.path = ""; + } + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/cosmos.evidence.v1beta1/types/google/protobuf/any.ts b/ts-client/cosmos.evidence.v1beta1/types/google/protobuf/any.ts new file mode 100644 index 00000000..b137a629 --- /dev/null +++ b/ts-client/cosmos.evidence.v1beta1/types/google/protobuf/any.ts @@ -0,0 +1,240 @@ +/* eslint-disable */ +import { Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "google.protobuf"; + +/** + * `Any` contains an arbitrary serialized protocol buffer message along with a + * URL that describes the type of the serialized message. + * + * Protobuf library provides support to pack/unpack Any values in the form + * of utility functions or additional generated methods of the Any type. + * + * Example 1: Pack and unpack a message in C++. + * + * Foo foo = ...; + * Any any; + * any.PackFrom(foo); + * ... + * if (any.UnpackTo(&foo)) { + * ... + * } + * + * Example 2: Pack and unpack a message in Java. + * + * Foo foo = ...; + * Any any = Any.pack(foo); + * ... + * if (any.is(Foo.class)) { + * foo = any.unpack(Foo.class); + * } + * + * Example 3: Pack and unpack a message in Python. + * + * foo = Foo(...) + * any = Any() + * any.Pack(foo) + * ... + * if any.Is(Foo.DESCRIPTOR): + * any.Unpack(foo) + * ... + * + * Example 4: Pack and unpack a message in Go + * + * foo := &pb.Foo{...} + * any, err := anypb.New(foo) + * if err != nil { + * ... + * } + * ... + * foo := &pb.Foo{} + * if err := any.UnmarshalTo(foo); err != nil { + * ... + * } + * + * The pack methods provided by protobuf library will by default use + * 'type.googleapis.com/full.type.name' as the type URL and the unpack + * methods only use the fully qualified type name after the last '/' + * in the type URL, for example "foo.bar.com/x/y.z" will yield type + * name "y.z". + * + * + * JSON + * ==== + * The JSON representation of an `Any` value uses the regular + * representation of the deserialized, embedded message, with an + * additional field `@type` which contains the type URL. Example: + * + * package google.profile; + * message Person { + * string first_name = 1; + * string last_name = 2; + * } + * + * { + * "@type": "type.googleapis.com/google.profile.Person", + * "firstName": , + * "lastName": + * } + * + * If the embedded message type is well-known and has a custom JSON + * representation, that representation will be embedded adding a field + * `value` which holds the custom JSON in addition to the `@type` + * field. Example (for message [google.protobuf.Duration][]): + * + * { + * "@type": "type.googleapis.com/google.protobuf.Duration", + * "value": "1.212s" + * } + */ +export interface Any { + /** + * A URL/resource name that uniquely identifies the type of the serialized + * protocol buffer message. This string must contain at least + * one "/" character. The last segment of the URL's path must represent + * the fully qualified name of the type (as in + * `path/google.protobuf.Duration`). The name should be in a canonical form + * (e.g., leading "." is not accepted). + * + * In practice, teams usually precompile into the binary all types that they + * expect it to use in the context of Any. However, for URLs which use the + * scheme `http`, `https`, or no scheme, one can optionally set up a type + * server that maps type URLs to message definitions as follows: + * + * * If no scheme is provided, `https` is assumed. + * * An HTTP GET on the URL must yield a [google.protobuf.Type][] + * value in binary format, or produce an error. + * * Applications are allowed to cache lookup results based on the + * URL, or have them precompiled into a binary to avoid any + * lookup. Therefore, binary compatibility needs to be preserved + * on changes to types. (Use versioned type names to manage + * breaking changes.) + * + * Note: this functionality is not currently available in the official + * protobuf release, and it is not used for type URLs beginning with + * type.googleapis.com. + * + * Schemes other than `http`, `https` (or the empty scheme) might be + * used with implementation specific semantics. + */ + typeUrl: string; + /** Must be a valid serialized protocol buffer of the above specified type. */ + value: Uint8Array; +} + +const baseAny: object = { typeUrl: "" }; + +export const Any = { + encode(message: Any, writer: Writer = Writer.create()): Writer { + if (message.typeUrl !== "") { + writer.uint32(10).string(message.typeUrl); + } + if (message.value.length !== 0) { + writer.uint32(18).bytes(message.value); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Any { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseAny } as Any; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.typeUrl = reader.string(); + break; + case 2: + message.value = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Any { + const message = { ...baseAny } as Any; + if (object.typeUrl !== undefined && object.typeUrl !== null) { + message.typeUrl = String(object.typeUrl); + } else { + message.typeUrl = ""; + } + if (object.value !== undefined && object.value !== null) { + message.value = bytesFromBase64(object.value); + } + return message; + }, + + toJSON(message: Any): unknown { + const obj: any = {}; + message.typeUrl !== undefined && (obj.typeUrl = message.typeUrl); + message.value !== undefined && + (obj.value = base64FromBytes( + message.value !== undefined ? message.value : new Uint8Array() + )); + return obj; + }, + + fromPartial(object: DeepPartial): Any { + const message = { ...baseAny } as Any; + if (object.typeUrl !== undefined && object.typeUrl !== null) { + message.typeUrl = object.typeUrl; + } else { + message.typeUrl = ""; + } + if (object.value !== undefined && object.value !== null) { + message.value = object.value; + } else { + message.value = new Uint8Array(); + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/cosmos.evidence.v1beta1/types/google/protobuf/descriptor.ts b/ts-client/cosmos.evidence.v1beta1/types/google/protobuf/descriptor.ts new file mode 100644 index 00000000..9e508660 --- /dev/null +++ b/ts-client/cosmos.evidence.v1beta1/types/google/protobuf/descriptor.ts @@ -0,0 +1,5261 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "google.protobuf"; + +/** + * The protocol compiler can output a FileDescriptorSet containing the .proto + * files it parses. + */ +export interface FileDescriptorSet { + file: FileDescriptorProto[]; +} + +/** Describes a complete .proto file. */ +export interface FileDescriptorProto { + /** file name, relative to root of source tree */ + name: string; + /** e.g. "foo", "foo.bar", etc. */ + package: string; + /** Names of files imported by this file. */ + dependency: string[]; + /** Indexes of the public imported files in the dependency list above. */ + publicDependency: number[]; + /** + * Indexes of the weak imported files in the dependency list. + * For Google-internal migration only. Do not use. + */ + weakDependency: number[]; + /** All top-level definitions in this file. */ + messageType: DescriptorProto[]; + enumType: EnumDescriptorProto[]; + service: ServiceDescriptorProto[]; + extension: FieldDescriptorProto[]; + options: FileOptions | undefined; + /** + * This field contains optional information about the original source code. + * You may safely remove this entire field without harming runtime + * functionality of the descriptors -- the information is needed only by + * development tools. + */ + sourceCodeInfo: SourceCodeInfo | undefined; + /** + * The syntax of the proto file. + * The supported values are "proto2" and "proto3". + */ + syntax: string; +} + +/** Describes a message type. */ +export interface DescriptorProto { + name: string; + field: FieldDescriptorProto[]; + extension: FieldDescriptorProto[]; + nestedType: DescriptorProto[]; + enumType: EnumDescriptorProto[]; + extensionRange: DescriptorProto_ExtensionRange[]; + oneofDecl: OneofDescriptorProto[]; + options: MessageOptions | undefined; + reservedRange: DescriptorProto_ReservedRange[]; + /** + * Reserved field names, which may not be used by fields in the same message. + * A given name may only be reserved once. + */ + reservedName: string[]; +} + +export interface DescriptorProto_ExtensionRange { + /** Inclusive. */ + start: number; + /** Exclusive. */ + end: number; + options: ExtensionRangeOptions | undefined; +} + +/** + * Range of reserved tag numbers. Reserved tag numbers may not be used by + * fields or extension ranges in the same message. Reserved ranges may + * not overlap. + */ +export interface DescriptorProto_ReservedRange { + /** Inclusive. */ + start: number; + /** Exclusive. */ + end: number; +} + +export interface ExtensionRangeOptions { + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +/** Describes a field within a message. */ +export interface FieldDescriptorProto { + name: string; + number: number; + label: FieldDescriptorProto_Label; + /** + * If type_name is set, this need not be set. If both this and type_name + * are set, this must be one of TYPE_ENUM, TYPE_MESSAGE or TYPE_GROUP. + */ + type: FieldDescriptorProto_Type; + /** + * For message and enum types, this is the name of the type. If the name + * starts with a '.', it is fully-qualified. Otherwise, C++-like scoping + * rules are used to find the type (i.e. first the nested types within this + * message are searched, then within the parent, on up to the root + * namespace). + */ + typeName: string; + /** + * For extensions, this is the name of the type being extended. It is + * resolved in the same manner as type_name. + */ + extendee: string; + /** + * For numeric types, contains the original text representation of the value. + * For booleans, "true" or "false". + * For strings, contains the default text contents (not escaped in any way). + * For bytes, contains the C escaped value. All bytes >= 128 are escaped. + * TODO(kenton): Base-64 encode? + */ + defaultValue: string; + /** + * If set, gives the index of a oneof in the containing type's oneof_decl + * list. This field is a member of that oneof. + */ + oneofIndex: number; + /** + * JSON name of this field. The value is set by protocol compiler. If the + * user has set a "json_name" option on this field, that option's value + * will be used. Otherwise, it's deduced from the field's name by converting + * it to camelCase. + */ + jsonName: string; + options: FieldOptions | undefined; + /** + * If true, this is a proto3 "optional". When a proto3 field is optional, it + * tracks presence regardless of field type. + * + * When proto3_optional is true, this field must be belong to a oneof to + * signal to old proto3 clients that presence is tracked for this field. This + * oneof is known as a "synthetic" oneof, and this field must be its sole + * member (each proto3 optional field gets its own synthetic oneof). Synthetic + * oneofs exist in the descriptor only, and do not generate any API. Synthetic + * oneofs must be ordered after all "real" oneofs. + * + * For message fields, proto3_optional doesn't create any semantic change, + * since non-repeated message fields always track presence. However it still + * indicates the semantic detail of whether the user wrote "optional" or not. + * This can be useful for round-tripping the .proto file. For consistency we + * give message fields a synthetic oneof also, even though it is not required + * to track presence. This is especially important because the parser can't + * tell if a field is a message or an enum, so it must always create a + * synthetic oneof. + * + * Proto2 optional fields do not set this flag, because they already indicate + * optional with `LABEL_OPTIONAL`. + */ + proto3Optional: boolean; +} + +export enum FieldDescriptorProto_Type { + /** + * TYPE_DOUBLE - 0 is reserved for errors. + * Order is weird for historical reasons. + */ + TYPE_DOUBLE = 1, + TYPE_FLOAT = 2, + /** + * TYPE_INT64 - Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT64 if + * negative values are likely. + */ + TYPE_INT64 = 3, + TYPE_UINT64 = 4, + /** + * TYPE_INT32 - Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT32 if + * negative values are likely. + */ + TYPE_INT32 = 5, + TYPE_FIXED64 = 6, + TYPE_FIXED32 = 7, + TYPE_BOOL = 8, + TYPE_STRING = 9, + /** + * TYPE_GROUP - Tag-delimited aggregate. + * Group type is deprecated and not supported in proto3. However, Proto3 + * implementations should still be able to parse the group wire format and + * treat group fields as unknown fields. + */ + TYPE_GROUP = 10, + /** TYPE_MESSAGE - Length-delimited aggregate. */ + TYPE_MESSAGE = 11, + /** TYPE_BYTES - New in version 2. */ + TYPE_BYTES = 12, + TYPE_UINT32 = 13, + TYPE_ENUM = 14, + TYPE_SFIXED32 = 15, + TYPE_SFIXED64 = 16, + /** TYPE_SINT32 - Uses ZigZag encoding. */ + TYPE_SINT32 = 17, + /** TYPE_SINT64 - Uses ZigZag encoding. */ + TYPE_SINT64 = 18, + UNRECOGNIZED = -1, +} + +export function fieldDescriptorProto_TypeFromJSON( + object: any +): FieldDescriptorProto_Type { + switch (object) { + case 1: + case "TYPE_DOUBLE": + return FieldDescriptorProto_Type.TYPE_DOUBLE; + case 2: + case "TYPE_FLOAT": + return FieldDescriptorProto_Type.TYPE_FLOAT; + case 3: + case "TYPE_INT64": + return FieldDescriptorProto_Type.TYPE_INT64; + case 4: + case "TYPE_UINT64": + return FieldDescriptorProto_Type.TYPE_UINT64; + case 5: + case "TYPE_INT32": + return FieldDescriptorProto_Type.TYPE_INT32; + case 6: + case "TYPE_FIXED64": + return FieldDescriptorProto_Type.TYPE_FIXED64; + case 7: + case "TYPE_FIXED32": + return FieldDescriptorProto_Type.TYPE_FIXED32; + case 8: + case "TYPE_BOOL": + return FieldDescriptorProto_Type.TYPE_BOOL; + case 9: + case "TYPE_STRING": + return FieldDescriptorProto_Type.TYPE_STRING; + case 10: + case "TYPE_GROUP": + return FieldDescriptorProto_Type.TYPE_GROUP; + case 11: + case "TYPE_MESSAGE": + return FieldDescriptorProto_Type.TYPE_MESSAGE; + case 12: + case "TYPE_BYTES": + return FieldDescriptorProto_Type.TYPE_BYTES; + case 13: + case "TYPE_UINT32": + return FieldDescriptorProto_Type.TYPE_UINT32; + case 14: + case "TYPE_ENUM": + return FieldDescriptorProto_Type.TYPE_ENUM; + case 15: + case "TYPE_SFIXED32": + return FieldDescriptorProto_Type.TYPE_SFIXED32; + case 16: + case "TYPE_SFIXED64": + return FieldDescriptorProto_Type.TYPE_SFIXED64; + case 17: + case "TYPE_SINT32": + return FieldDescriptorProto_Type.TYPE_SINT32; + case 18: + case "TYPE_SINT64": + return FieldDescriptorProto_Type.TYPE_SINT64; + case -1: + case "UNRECOGNIZED": + default: + return FieldDescriptorProto_Type.UNRECOGNIZED; + } +} + +export function fieldDescriptorProto_TypeToJSON( + object: FieldDescriptorProto_Type +): string { + switch (object) { + case FieldDescriptorProto_Type.TYPE_DOUBLE: + return "TYPE_DOUBLE"; + case FieldDescriptorProto_Type.TYPE_FLOAT: + return "TYPE_FLOAT"; + case FieldDescriptorProto_Type.TYPE_INT64: + return "TYPE_INT64"; + case FieldDescriptorProto_Type.TYPE_UINT64: + return "TYPE_UINT64"; + case FieldDescriptorProto_Type.TYPE_INT32: + return "TYPE_INT32"; + case FieldDescriptorProto_Type.TYPE_FIXED64: + return "TYPE_FIXED64"; + case FieldDescriptorProto_Type.TYPE_FIXED32: + return "TYPE_FIXED32"; + case FieldDescriptorProto_Type.TYPE_BOOL: + return "TYPE_BOOL"; + case FieldDescriptorProto_Type.TYPE_STRING: + return "TYPE_STRING"; + case FieldDescriptorProto_Type.TYPE_GROUP: + return "TYPE_GROUP"; + case FieldDescriptorProto_Type.TYPE_MESSAGE: + return "TYPE_MESSAGE"; + case FieldDescriptorProto_Type.TYPE_BYTES: + return "TYPE_BYTES"; + case FieldDescriptorProto_Type.TYPE_UINT32: + return "TYPE_UINT32"; + case FieldDescriptorProto_Type.TYPE_ENUM: + return "TYPE_ENUM"; + case FieldDescriptorProto_Type.TYPE_SFIXED32: + return "TYPE_SFIXED32"; + case FieldDescriptorProto_Type.TYPE_SFIXED64: + return "TYPE_SFIXED64"; + case FieldDescriptorProto_Type.TYPE_SINT32: + return "TYPE_SINT32"; + case FieldDescriptorProto_Type.TYPE_SINT64: + return "TYPE_SINT64"; + default: + return "UNKNOWN"; + } +} + +export enum FieldDescriptorProto_Label { + /** LABEL_OPTIONAL - 0 is reserved for errors */ + LABEL_OPTIONAL = 1, + LABEL_REQUIRED = 2, + LABEL_REPEATED = 3, + UNRECOGNIZED = -1, +} + +export function fieldDescriptorProto_LabelFromJSON( + object: any +): FieldDescriptorProto_Label { + switch (object) { + case 1: + case "LABEL_OPTIONAL": + return FieldDescriptorProto_Label.LABEL_OPTIONAL; + case 2: + case "LABEL_REQUIRED": + return FieldDescriptorProto_Label.LABEL_REQUIRED; + case 3: + case "LABEL_REPEATED": + return FieldDescriptorProto_Label.LABEL_REPEATED; + case -1: + case "UNRECOGNIZED": + default: + return FieldDescriptorProto_Label.UNRECOGNIZED; + } +} + +export function fieldDescriptorProto_LabelToJSON( + object: FieldDescriptorProto_Label +): string { + switch (object) { + case FieldDescriptorProto_Label.LABEL_OPTIONAL: + return "LABEL_OPTIONAL"; + case FieldDescriptorProto_Label.LABEL_REQUIRED: + return "LABEL_REQUIRED"; + case FieldDescriptorProto_Label.LABEL_REPEATED: + return "LABEL_REPEATED"; + default: + return "UNKNOWN"; + } +} + +/** Describes a oneof. */ +export interface OneofDescriptorProto { + name: string; + options: OneofOptions | undefined; +} + +/** Describes an enum type. */ +export interface EnumDescriptorProto { + name: string; + value: EnumValueDescriptorProto[]; + options: EnumOptions | undefined; + /** + * Range of reserved numeric values. Reserved numeric values may not be used + * by enum values in the same enum declaration. Reserved ranges may not + * overlap. + */ + reservedRange: EnumDescriptorProto_EnumReservedRange[]; + /** + * Reserved enum value names, which may not be reused. A given name may only + * be reserved once. + */ + reservedName: string[]; +} + +/** + * Range of reserved numeric values. Reserved values may not be used by + * entries in the same enum. Reserved ranges may not overlap. + * + * Note that this is distinct from DescriptorProto.ReservedRange in that it + * is inclusive such that it can appropriately represent the entire int32 + * domain. + */ +export interface EnumDescriptorProto_EnumReservedRange { + /** Inclusive. */ + start: number; + /** Inclusive. */ + end: number; +} + +/** Describes a value within an enum. */ +export interface EnumValueDescriptorProto { + name: string; + number: number; + options: EnumValueOptions | undefined; +} + +/** Describes a service. */ +export interface ServiceDescriptorProto { + name: string; + method: MethodDescriptorProto[]; + options: ServiceOptions | undefined; +} + +/** Describes a method of a service. */ +export interface MethodDescriptorProto { + name: string; + /** + * Input and output type names. These are resolved in the same way as + * FieldDescriptorProto.type_name, but must refer to a message type. + */ + inputType: string; + outputType: string; + options: MethodOptions | undefined; + /** Identifies if client streams multiple client messages */ + clientStreaming: boolean; + /** Identifies if server streams multiple server messages */ + serverStreaming: boolean; +} + +export interface FileOptions { + /** + * Sets the Java package where classes generated from this .proto will be + * placed. By default, the proto package is used, but this is often + * inappropriate because proto packages do not normally start with backwards + * domain names. + */ + javaPackage: string; + /** + * Controls the name of the wrapper Java class generated for the .proto file. + * That class will always contain the .proto file's getDescriptor() method as + * well as any top-level extensions defined in the .proto file. + * If java_multiple_files is disabled, then all the other classes from the + * .proto file will be nested inside the single wrapper outer class. + */ + javaOuterClassname: string; + /** + * If enabled, then the Java code generator will generate a separate .java + * file for each top-level message, enum, and service defined in the .proto + * file. Thus, these types will *not* be nested inside the wrapper class + * named by java_outer_classname. However, the wrapper class will still be + * generated to contain the file's getDescriptor() method as well as any + * top-level extensions defined in the file. + */ + javaMultipleFiles: boolean; + /** + * This option does nothing. + * + * @deprecated + */ + javaGenerateEqualsAndHash: boolean; + /** + * If set true, then the Java2 code generator will generate code that + * throws an exception whenever an attempt is made to assign a non-UTF-8 + * byte sequence to a string field. + * Message reflection will do the same. + * However, an extension field still accepts non-UTF-8 byte sequences. + * This option has no effect on when used with the lite runtime. + */ + javaStringCheckUtf8: boolean; + optimizeFor: FileOptions_OptimizeMode; + /** + * Sets the Go package where structs generated from this .proto will be + * placed. If omitted, the Go package will be derived from the following: + * - The basename of the package import path, if provided. + * - Otherwise, the package statement in the .proto file, if present. + * - Otherwise, the basename of the .proto file, without extension. + */ + goPackage: string; + /** + * Should generic services be generated in each language? "Generic" services + * are not specific to any particular RPC system. They are generated by the + * main code generators in each language (without additional plugins). + * Generic services were the only kind of service generation supported by + * early versions of google.protobuf. + * + * Generic services are now considered deprecated in favor of using plugins + * that generate code specific to your particular RPC system. Therefore, + * these default to false. Old code which depends on generic services should + * explicitly set them to true. + */ + ccGenericServices: boolean; + javaGenericServices: boolean; + pyGenericServices: boolean; + phpGenericServices: boolean; + /** + * Is this file deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for everything in the file, or it will be completely ignored; in the very + * least, this is a formalization for deprecating files. + */ + deprecated: boolean; + /** + * Enables the use of arenas for the proto messages in this file. This applies + * only to generated classes for C++. + */ + ccEnableArenas: boolean; + /** + * Sets the objective c class prefix which is prepended to all objective c + * generated classes from this .proto. There is no default. + */ + objcClassPrefix: string; + /** Namespace for generated classes; defaults to the package. */ + csharpNamespace: string; + /** + * By default Swift generators will take the proto package and CamelCase it + * replacing '.' with underscore and use that to prefix the types/symbols + * defined. When this options is provided, they will use this value instead + * to prefix the types/symbols defined. + */ + swiftPrefix: string; + /** + * Sets the php class prefix which is prepended to all php generated classes + * from this .proto. Default is empty. + */ + phpClassPrefix: string; + /** + * Use this option to change the namespace of php generated classes. Default + * is empty. When this option is empty, the package name will be used for + * determining the namespace. + */ + phpNamespace: string; + /** + * Use this option to change the namespace of php generated metadata classes. + * Default is empty. When this option is empty, the proto file name will be + * used for determining the namespace. + */ + phpMetadataNamespace: string; + /** + * Use this option to change the package of ruby generated classes. Default + * is empty. When this option is not set, the package name will be used for + * determining the ruby package. + */ + rubyPackage: string; + /** + * The parser stores options it doesn't recognize here. + * See the documentation for the "Options" section above. + */ + uninterpretedOption: UninterpretedOption[]; +} + +/** Generated classes can be optimized for speed or code size. */ +export enum FileOptions_OptimizeMode { + /** SPEED - Generate complete code for parsing, serialization, */ + SPEED = 1, + /** CODE_SIZE - etc. */ + CODE_SIZE = 2, + /** LITE_RUNTIME - Generate code using MessageLite and the lite runtime. */ + LITE_RUNTIME = 3, + UNRECOGNIZED = -1, +} + +export function fileOptions_OptimizeModeFromJSON( + object: any +): FileOptions_OptimizeMode { + switch (object) { + case 1: + case "SPEED": + return FileOptions_OptimizeMode.SPEED; + case 2: + case "CODE_SIZE": + return FileOptions_OptimizeMode.CODE_SIZE; + case 3: + case "LITE_RUNTIME": + return FileOptions_OptimizeMode.LITE_RUNTIME; + case -1: + case "UNRECOGNIZED": + default: + return FileOptions_OptimizeMode.UNRECOGNIZED; + } +} + +export function fileOptions_OptimizeModeToJSON( + object: FileOptions_OptimizeMode +): string { + switch (object) { + case FileOptions_OptimizeMode.SPEED: + return "SPEED"; + case FileOptions_OptimizeMode.CODE_SIZE: + return "CODE_SIZE"; + case FileOptions_OptimizeMode.LITE_RUNTIME: + return "LITE_RUNTIME"; + default: + return "UNKNOWN"; + } +} + +export interface MessageOptions { + /** + * Set true to use the old proto1 MessageSet wire format for extensions. + * This is provided for backwards-compatibility with the MessageSet wire + * format. You should not use this for any other reason: It's less + * efficient, has fewer features, and is more complicated. + * + * The message must be defined exactly as follows: + * message Foo { + * option message_set_wire_format = true; + * extensions 4 to max; + * } + * Note that the message cannot have any defined fields; MessageSets only + * have extensions. + * + * All extensions of your type must be singular messages; e.g. they cannot + * be int32s, enums, or repeated messages. + * + * Because this is an option, the above two restrictions are not enforced by + * the protocol compiler. + */ + messageSetWireFormat: boolean; + /** + * Disables the generation of the standard "descriptor()" accessor, which can + * conflict with a field of the same name. This is meant to make migration + * from proto1 easier; new code should avoid fields named "descriptor". + */ + noStandardDescriptorAccessor: boolean; + /** + * Is this message deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the message, or it will be completely ignored; in the very least, + * this is a formalization for deprecating messages. + */ + deprecated: boolean; + /** + * Whether the message is an automatically generated map entry type for the + * maps field. + * + * For maps fields: + * map map_field = 1; + * The parsed descriptor looks like: + * message MapFieldEntry { + * option map_entry = true; + * optional KeyType key = 1; + * optional ValueType value = 2; + * } + * repeated MapFieldEntry map_field = 1; + * + * Implementations may choose not to generate the map_entry=true message, but + * use a native map in the target language to hold the keys and values. + * The reflection APIs in such implementations still need to work as + * if the field is a repeated message field. + * + * NOTE: Do not set the option in .proto files. Always use the maps syntax + * instead. The option should only be implicitly set by the proto compiler + * parser. + */ + mapEntry: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface FieldOptions { + /** + * The ctype option instructs the C++ code generator to use a different + * representation of the field than it normally would. See the specific + * options below. This option is not yet implemented in the open source + * release -- sorry, we'll try to include it in a future version! + */ + ctype: FieldOptions_CType; + /** + * The packed option can be enabled for repeated primitive fields to enable + * a more efficient representation on the wire. Rather than repeatedly + * writing the tag and type for each element, the entire array is encoded as + * a single length-delimited blob. In proto3, only explicit setting it to + * false will avoid using packed encoding. + */ + packed: boolean; + /** + * The jstype option determines the JavaScript type used for values of the + * field. The option is permitted only for 64 bit integral and fixed types + * (int64, uint64, sint64, fixed64, sfixed64). A field with jstype JS_STRING + * is represented as JavaScript string, which avoids loss of precision that + * can happen when a large value is converted to a floating point JavaScript. + * Specifying JS_NUMBER for the jstype causes the generated JavaScript code to + * use the JavaScript "number" type. The behavior of the default option + * JS_NORMAL is implementation dependent. + * + * This option is an enum to permit additional types to be added, e.g. + * goog.math.Integer. + */ + jstype: FieldOptions_JSType; + /** + * Should this field be parsed lazily? Lazy applies only to message-type + * fields. It means that when the outer message is initially parsed, the + * inner message's contents will not be parsed but instead stored in encoded + * form. The inner message will actually be parsed when it is first accessed. + * + * This is only a hint. Implementations are free to choose whether to use + * eager or lazy parsing regardless of the value of this option. However, + * setting this option true suggests that the protocol author believes that + * using lazy parsing on this field is worth the additional bookkeeping + * overhead typically needed to implement it. + * + * This option does not affect the public interface of any generated code; + * all method signatures remain the same. Furthermore, thread-safety of the + * interface is not affected by this option; const methods remain safe to + * call from multiple threads concurrently, while non-const methods continue + * to require exclusive access. + * + * + * Note that implementations may choose not to check required fields within + * a lazy sub-message. That is, calling IsInitialized() on the outer message + * may return true even if the inner message has missing required fields. + * This is necessary because otherwise the inner message would have to be + * parsed in order to perform the check, defeating the purpose of lazy + * parsing. An implementation which chooses not to check required fields + * must be consistent about it. That is, for any particular sub-message, the + * implementation must either *always* check its required fields, or *never* + * check its required fields, regardless of whether or not the message has + * been parsed. + */ + lazy: boolean; + /** + * Is this field deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for accessors, or it will be completely ignored; in the very least, this + * is a formalization for deprecating fields. + */ + deprecated: boolean; + /** For Google-internal migration only. Do not use. */ + weak: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export enum FieldOptions_CType { + /** STRING - Default mode. */ + STRING = 0, + CORD = 1, + STRING_PIECE = 2, + UNRECOGNIZED = -1, +} + +export function fieldOptions_CTypeFromJSON(object: any): FieldOptions_CType { + switch (object) { + case 0: + case "STRING": + return FieldOptions_CType.STRING; + case 1: + case "CORD": + return FieldOptions_CType.CORD; + case 2: + case "STRING_PIECE": + return FieldOptions_CType.STRING_PIECE; + case -1: + case "UNRECOGNIZED": + default: + return FieldOptions_CType.UNRECOGNIZED; + } +} + +export function fieldOptions_CTypeToJSON(object: FieldOptions_CType): string { + switch (object) { + case FieldOptions_CType.STRING: + return "STRING"; + case FieldOptions_CType.CORD: + return "CORD"; + case FieldOptions_CType.STRING_PIECE: + return "STRING_PIECE"; + default: + return "UNKNOWN"; + } +} + +export enum FieldOptions_JSType { + /** JS_NORMAL - Use the default type. */ + JS_NORMAL = 0, + /** JS_STRING - Use JavaScript strings. */ + JS_STRING = 1, + /** JS_NUMBER - Use JavaScript numbers. */ + JS_NUMBER = 2, + UNRECOGNIZED = -1, +} + +export function fieldOptions_JSTypeFromJSON(object: any): FieldOptions_JSType { + switch (object) { + case 0: + case "JS_NORMAL": + return FieldOptions_JSType.JS_NORMAL; + case 1: + case "JS_STRING": + return FieldOptions_JSType.JS_STRING; + case 2: + case "JS_NUMBER": + return FieldOptions_JSType.JS_NUMBER; + case -1: + case "UNRECOGNIZED": + default: + return FieldOptions_JSType.UNRECOGNIZED; + } +} + +export function fieldOptions_JSTypeToJSON(object: FieldOptions_JSType): string { + switch (object) { + case FieldOptions_JSType.JS_NORMAL: + return "JS_NORMAL"; + case FieldOptions_JSType.JS_STRING: + return "JS_STRING"; + case FieldOptions_JSType.JS_NUMBER: + return "JS_NUMBER"; + default: + return "UNKNOWN"; + } +} + +export interface OneofOptions { + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface EnumOptions { + /** + * Set this option to true to allow mapping different tag names to the same + * value. + */ + allowAlias: boolean; + /** + * Is this enum deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the enum, or it will be completely ignored; in the very least, this + * is a formalization for deprecating enums. + */ + deprecated: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface EnumValueOptions { + /** + * Is this enum value deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the enum value, or it will be completely ignored; in the very least, + * this is a formalization for deprecating enum values. + */ + deprecated: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface ServiceOptions { + /** + * Is this service deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the service, or it will be completely ignored; in the very least, + * this is a formalization for deprecating services. + */ + deprecated: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface MethodOptions { + /** + * Is this method deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the method, or it will be completely ignored; in the very least, + * this is a formalization for deprecating methods. + */ + deprecated: boolean; + idempotencyLevel: MethodOptions_IdempotencyLevel; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +/** + * Is this method side-effect-free (or safe in HTTP parlance), or idempotent, + * or neither? HTTP based RPC implementation may choose GET verb for safe + * methods, and PUT verb for idempotent methods instead of the default POST. + */ +export enum MethodOptions_IdempotencyLevel { + IDEMPOTENCY_UNKNOWN = 0, + /** NO_SIDE_EFFECTS - implies idempotent */ + NO_SIDE_EFFECTS = 1, + /** IDEMPOTENT - idempotent, but may have side effects */ + IDEMPOTENT = 2, + UNRECOGNIZED = -1, +} + +export function methodOptions_IdempotencyLevelFromJSON( + object: any +): MethodOptions_IdempotencyLevel { + switch (object) { + case 0: + case "IDEMPOTENCY_UNKNOWN": + return MethodOptions_IdempotencyLevel.IDEMPOTENCY_UNKNOWN; + case 1: + case "NO_SIDE_EFFECTS": + return MethodOptions_IdempotencyLevel.NO_SIDE_EFFECTS; + case 2: + case "IDEMPOTENT": + return MethodOptions_IdempotencyLevel.IDEMPOTENT; + case -1: + case "UNRECOGNIZED": + default: + return MethodOptions_IdempotencyLevel.UNRECOGNIZED; + } +} + +export function methodOptions_IdempotencyLevelToJSON( + object: MethodOptions_IdempotencyLevel +): string { + switch (object) { + case MethodOptions_IdempotencyLevel.IDEMPOTENCY_UNKNOWN: + return "IDEMPOTENCY_UNKNOWN"; + case MethodOptions_IdempotencyLevel.NO_SIDE_EFFECTS: + return "NO_SIDE_EFFECTS"; + case MethodOptions_IdempotencyLevel.IDEMPOTENT: + return "IDEMPOTENT"; + default: + return "UNKNOWN"; + } +} + +/** + * A message representing a option the parser does not recognize. This only + * appears in options protos created by the compiler::Parser class. + * DescriptorPool resolves these when building Descriptor objects. Therefore, + * options protos in descriptor objects (e.g. returned by Descriptor::options(), + * or produced by Descriptor::CopyTo()) will never have UninterpretedOptions + * in them. + */ +export interface UninterpretedOption { + name: UninterpretedOption_NamePart[]; + /** + * The value of the uninterpreted option, in whatever type the tokenizer + * identified it as during parsing. Exactly one of these should be set. + */ + identifierValue: string; + positiveIntValue: number; + negativeIntValue: number; + doubleValue: number; + stringValue: Uint8Array; + aggregateValue: string; +} + +/** + * The name of the uninterpreted option. Each string represents a segment in + * a dot-separated name. is_extension is true iff a segment represents an + * extension (denoted with parentheses in options specs in .proto files). + * E.g.,{ ["foo", false], ["bar.baz", true], ["qux", false] } represents + * "foo.(bar.baz).qux". + */ +export interface UninterpretedOption_NamePart { + namePart: string; + isExtension: boolean; +} + +/** + * Encapsulates information about the original source file from which a + * FileDescriptorProto was generated. + */ +export interface SourceCodeInfo { + /** + * A Location identifies a piece of source code in a .proto file which + * corresponds to a particular definition. This information is intended + * to be useful to IDEs, code indexers, documentation generators, and similar + * tools. + * + * For example, say we have a file like: + * message Foo { + * optional string foo = 1; + * } + * Let's look at just the field definition: + * optional string foo = 1; + * ^ ^^ ^^ ^ ^^^ + * a bc de f ghi + * We have the following locations: + * span path represents + * [a,i) [ 4, 0, 2, 0 ] The whole field definition. + * [a,b) [ 4, 0, 2, 0, 4 ] The label (optional). + * [c,d) [ 4, 0, 2, 0, 5 ] The type (string). + * [e,f) [ 4, 0, 2, 0, 1 ] The name (foo). + * [g,h) [ 4, 0, 2, 0, 3 ] The number (1). + * + * Notes: + * - A location may refer to a repeated field itself (i.e. not to any + * particular index within it). This is used whenever a set of elements are + * logically enclosed in a single code segment. For example, an entire + * extend block (possibly containing multiple extension definitions) will + * have an outer location whose path refers to the "extensions" repeated + * field without an index. + * - Multiple locations may have the same path. This happens when a single + * logical declaration is spread out across multiple places. The most + * obvious example is the "extend" block again -- there may be multiple + * extend blocks in the same scope, each of which will have the same path. + * - A location's span is not always a subset of its parent's span. For + * example, the "extendee" of an extension declaration appears at the + * beginning of the "extend" block and is shared by all extensions within + * the block. + * - Just because a location's span is a subset of some other location's span + * does not mean that it is a descendant. For example, a "group" defines + * both a type and a field in a single declaration. Thus, the locations + * corresponding to the type and field and their components will overlap. + * - Code which tries to interpret locations should probably be designed to + * ignore those that it doesn't understand, as more types of locations could + * be recorded in the future. + */ + location: SourceCodeInfo_Location[]; +} + +export interface SourceCodeInfo_Location { + /** + * Identifies which part of the FileDescriptorProto was defined at this + * location. + * + * Each element is a field number or an index. They form a path from + * the root FileDescriptorProto to the place where the definition. For + * example, this path: + * [ 4, 3, 2, 7, 1 ] + * refers to: + * file.message_type(3) // 4, 3 + * .field(7) // 2, 7 + * .name() // 1 + * This is because FileDescriptorProto.message_type has field number 4: + * repeated DescriptorProto message_type = 4; + * and DescriptorProto.field has field number 2: + * repeated FieldDescriptorProto field = 2; + * and FieldDescriptorProto.name has field number 1: + * optional string name = 1; + * + * Thus, the above path gives the location of a field name. If we removed + * the last element: + * [ 4, 3, 2, 7 ] + * this path refers to the whole field declaration (from the beginning + * of the label to the terminating semicolon). + */ + path: number[]; + /** + * Always has exactly three or four elements: start line, start column, + * end line (optional, otherwise assumed same as start line), end column. + * These are packed into a single field for efficiency. Note that line + * and column numbers are zero-based -- typically you will want to add + * 1 to each before displaying to a user. + */ + span: number[]; + /** + * If this SourceCodeInfo represents a complete declaration, these are any + * comments appearing before and after the declaration which appear to be + * attached to the declaration. + * + * A series of line comments appearing on consecutive lines, with no other + * tokens appearing on those lines, will be treated as a single comment. + * + * leading_detached_comments will keep paragraphs of comments that appear + * before (but not connected to) the current element. Each paragraph, + * separated by empty lines, will be one comment element in the repeated + * field. + * + * Only the comment content is provided; comment markers (e.g. //) are + * stripped out. For block comments, leading whitespace and an asterisk + * will be stripped from the beginning of each line other than the first. + * Newlines are included in the output. + * + * Examples: + * + * optional int32 foo = 1; // Comment attached to foo. + * // Comment attached to bar. + * optional int32 bar = 2; + * + * optional string baz = 3; + * // Comment attached to baz. + * // Another line attached to baz. + * + * // Comment attached to qux. + * // + * // Another line attached to qux. + * optional double qux = 4; + * + * // Detached comment for corge. This is not leading or trailing comments + * // to qux or corge because there are blank lines separating it from + * // both. + * + * // Detached comment for corge paragraph 2. + * + * optional string corge = 5; + * /* Block comment attached + * * to corge. Leading asterisks + * * will be removed. * / + * /* Block comment attached to + * * grault. * / + * optional int32 grault = 6; + * + * // ignored detached comments. + */ + leadingComments: string; + trailingComments: string; + leadingDetachedComments: string[]; +} + +/** + * Describes the relationship between generated code and its original source + * file. A GeneratedCodeInfo message is associated with only one generated + * source file, but may contain references to different source .proto files. + */ +export interface GeneratedCodeInfo { + /** + * An Annotation connects some span of text in generated code to an element + * of its generating .proto file. + */ + annotation: GeneratedCodeInfo_Annotation[]; +} + +export interface GeneratedCodeInfo_Annotation { + /** + * Identifies the element in the original source .proto file. This field + * is formatted the same as SourceCodeInfo.Location.path. + */ + path: number[]; + /** Identifies the filesystem path to the original source .proto. */ + sourceFile: string; + /** + * Identifies the starting offset in bytes in the generated code + * that relates to the identified object. + */ + begin: number; + /** + * Identifies the ending offset in bytes in the generated code that + * relates to the identified offset. The end offset should be one past + * the last relevant byte (so the length of the text = end - begin). + */ + end: number; +} + +const baseFileDescriptorSet: object = {}; + +export const FileDescriptorSet = { + encode(message: FileDescriptorSet, writer: Writer = Writer.create()): Writer { + for (const v of message.file) { + FileDescriptorProto.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FileDescriptorSet { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFileDescriptorSet } as FileDescriptorSet; + message.file = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.file.push( + FileDescriptorProto.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FileDescriptorSet { + const message = { ...baseFileDescriptorSet } as FileDescriptorSet; + message.file = []; + if (object.file !== undefined && object.file !== null) { + for (const e of object.file) { + message.file.push(FileDescriptorProto.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: FileDescriptorSet): unknown { + const obj: any = {}; + if (message.file) { + obj.file = message.file.map((e) => + e ? FileDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.file = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): FileDescriptorSet { + const message = { ...baseFileDescriptorSet } as FileDescriptorSet; + message.file = []; + if (object.file !== undefined && object.file !== null) { + for (const e of object.file) { + message.file.push(FileDescriptorProto.fromPartial(e)); + } + } + return message; + }, +}; + +const baseFileDescriptorProto: object = { + name: "", + package: "", + dependency: "", + publicDependency: 0, + weakDependency: 0, + syntax: "", +}; + +export const FileDescriptorProto = { + encode( + message: FileDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.package !== "") { + writer.uint32(18).string(message.package); + } + for (const v of message.dependency) { + writer.uint32(26).string(v!); + } + writer.uint32(82).fork(); + for (const v of message.publicDependency) { + writer.int32(v); + } + writer.ldelim(); + writer.uint32(90).fork(); + for (const v of message.weakDependency) { + writer.int32(v); + } + writer.ldelim(); + for (const v of message.messageType) { + DescriptorProto.encode(v!, writer.uint32(34).fork()).ldelim(); + } + for (const v of message.enumType) { + EnumDescriptorProto.encode(v!, writer.uint32(42).fork()).ldelim(); + } + for (const v of message.service) { + ServiceDescriptorProto.encode(v!, writer.uint32(50).fork()).ldelim(); + } + for (const v of message.extension) { + FieldDescriptorProto.encode(v!, writer.uint32(58).fork()).ldelim(); + } + if (message.options !== undefined) { + FileOptions.encode(message.options, writer.uint32(66).fork()).ldelim(); + } + if (message.sourceCodeInfo !== undefined) { + SourceCodeInfo.encode( + message.sourceCodeInfo, + writer.uint32(74).fork() + ).ldelim(); + } + if (message.syntax !== "") { + writer.uint32(98).string(message.syntax); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FileDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFileDescriptorProto } as FileDescriptorProto; + message.dependency = []; + message.publicDependency = []; + message.weakDependency = []; + message.messageType = []; + message.enumType = []; + message.service = []; + message.extension = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.package = reader.string(); + break; + case 3: + message.dependency.push(reader.string()); + break; + case 10: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.publicDependency.push(reader.int32()); + } + } else { + message.publicDependency.push(reader.int32()); + } + break; + case 11: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.weakDependency.push(reader.int32()); + } + } else { + message.weakDependency.push(reader.int32()); + } + break; + case 4: + message.messageType.push( + DescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 5: + message.enumType.push( + EnumDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 6: + message.service.push( + ServiceDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 7: + message.extension.push( + FieldDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 8: + message.options = FileOptions.decode(reader, reader.uint32()); + break; + case 9: + message.sourceCodeInfo = SourceCodeInfo.decode( + reader, + reader.uint32() + ); + break; + case 12: + message.syntax = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FileDescriptorProto { + const message = { ...baseFileDescriptorProto } as FileDescriptorProto; + message.dependency = []; + message.publicDependency = []; + message.weakDependency = []; + message.messageType = []; + message.enumType = []; + message.service = []; + message.extension = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.package !== undefined && object.package !== null) { + message.package = String(object.package); + } else { + message.package = ""; + } + if (object.dependency !== undefined && object.dependency !== null) { + for (const e of object.dependency) { + message.dependency.push(String(e)); + } + } + if ( + object.publicDependency !== undefined && + object.publicDependency !== null + ) { + for (const e of object.publicDependency) { + message.publicDependency.push(Number(e)); + } + } + if (object.weakDependency !== undefined && object.weakDependency !== null) { + for (const e of object.weakDependency) { + message.weakDependency.push(Number(e)); + } + } + if (object.messageType !== undefined && object.messageType !== null) { + for (const e of object.messageType) { + message.messageType.push(DescriptorProto.fromJSON(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromJSON(e)); + } + } + if (object.service !== undefined && object.service !== null) { + for (const e of object.service) { + message.service.push(ServiceDescriptorProto.fromJSON(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = FileOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.sourceCodeInfo !== undefined && object.sourceCodeInfo !== null) { + message.sourceCodeInfo = SourceCodeInfo.fromJSON(object.sourceCodeInfo); + } else { + message.sourceCodeInfo = undefined; + } + if (object.syntax !== undefined && object.syntax !== null) { + message.syntax = String(object.syntax); + } else { + message.syntax = ""; + } + return message; + }, + + toJSON(message: FileDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.package !== undefined && (obj.package = message.package); + if (message.dependency) { + obj.dependency = message.dependency.map((e) => e); + } else { + obj.dependency = []; + } + if (message.publicDependency) { + obj.publicDependency = message.publicDependency.map((e) => e); + } else { + obj.publicDependency = []; + } + if (message.weakDependency) { + obj.weakDependency = message.weakDependency.map((e) => e); + } else { + obj.weakDependency = []; + } + if (message.messageType) { + obj.messageType = message.messageType.map((e) => + e ? DescriptorProto.toJSON(e) : undefined + ); + } else { + obj.messageType = []; + } + if (message.enumType) { + obj.enumType = message.enumType.map((e) => + e ? EnumDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.enumType = []; + } + if (message.service) { + obj.service = message.service.map((e) => + e ? ServiceDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.service = []; + } + if (message.extension) { + obj.extension = message.extension.map((e) => + e ? FieldDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.extension = []; + } + message.options !== undefined && + (obj.options = message.options + ? FileOptions.toJSON(message.options) + : undefined); + message.sourceCodeInfo !== undefined && + (obj.sourceCodeInfo = message.sourceCodeInfo + ? SourceCodeInfo.toJSON(message.sourceCodeInfo) + : undefined); + message.syntax !== undefined && (obj.syntax = message.syntax); + return obj; + }, + + fromPartial(object: DeepPartial): FileDescriptorProto { + const message = { ...baseFileDescriptorProto } as FileDescriptorProto; + message.dependency = []; + message.publicDependency = []; + message.weakDependency = []; + message.messageType = []; + message.enumType = []; + message.service = []; + message.extension = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.package !== undefined && object.package !== null) { + message.package = object.package; + } else { + message.package = ""; + } + if (object.dependency !== undefined && object.dependency !== null) { + for (const e of object.dependency) { + message.dependency.push(e); + } + } + if ( + object.publicDependency !== undefined && + object.publicDependency !== null + ) { + for (const e of object.publicDependency) { + message.publicDependency.push(e); + } + } + if (object.weakDependency !== undefined && object.weakDependency !== null) { + for (const e of object.weakDependency) { + message.weakDependency.push(e); + } + } + if (object.messageType !== undefined && object.messageType !== null) { + for (const e of object.messageType) { + message.messageType.push(DescriptorProto.fromPartial(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromPartial(e)); + } + } + if (object.service !== undefined && object.service !== null) { + for (const e of object.service) { + message.service.push(ServiceDescriptorProto.fromPartial(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = FileOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.sourceCodeInfo !== undefined && object.sourceCodeInfo !== null) { + message.sourceCodeInfo = SourceCodeInfo.fromPartial( + object.sourceCodeInfo + ); + } else { + message.sourceCodeInfo = undefined; + } + if (object.syntax !== undefined && object.syntax !== null) { + message.syntax = object.syntax; + } else { + message.syntax = ""; + } + return message; + }, +}; + +const baseDescriptorProto: object = { name: "", reservedName: "" }; + +export const DescriptorProto = { + encode(message: DescriptorProto, writer: Writer = Writer.create()): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + for (const v of message.field) { + FieldDescriptorProto.encode(v!, writer.uint32(18).fork()).ldelim(); + } + for (const v of message.extension) { + FieldDescriptorProto.encode(v!, writer.uint32(50).fork()).ldelim(); + } + for (const v of message.nestedType) { + DescriptorProto.encode(v!, writer.uint32(26).fork()).ldelim(); + } + for (const v of message.enumType) { + EnumDescriptorProto.encode(v!, writer.uint32(34).fork()).ldelim(); + } + for (const v of message.extensionRange) { + DescriptorProto_ExtensionRange.encode( + v!, + writer.uint32(42).fork() + ).ldelim(); + } + for (const v of message.oneofDecl) { + OneofDescriptorProto.encode(v!, writer.uint32(66).fork()).ldelim(); + } + if (message.options !== undefined) { + MessageOptions.encode(message.options, writer.uint32(58).fork()).ldelim(); + } + for (const v of message.reservedRange) { + DescriptorProto_ReservedRange.encode( + v!, + writer.uint32(74).fork() + ).ldelim(); + } + for (const v of message.reservedName) { + writer.uint32(82).string(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): DescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseDescriptorProto } as DescriptorProto; + message.field = []; + message.extension = []; + message.nestedType = []; + message.enumType = []; + message.extensionRange = []; + message.oneofDecl = []; + message.reservedRange = []; + message.reservedName = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.field.push( + FieldDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 6: + message.extension.push( + FieldDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 3: + message.nestedType.push( + DescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 4: + message.enumType.push( + EnumDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 5: + message.extensionRange.push( + DescriptorProto_ExtensionRange.decode(reader, reader.uint32()) + ); + break; + case 8: + message.oneofDecl.push( + OneofDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 7: + message.options = MessageOptions.decode(reader, reader.uint32()); + break; + case 9: + message.reservedRange.push( + DescriptorProto_ReservedRange.decode(reader, reader.uint32()) + ); + break; + case 10: + message.reservedName.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DescriptorProto { + const message = { ...baseDescriptorProto } as DescriptorProto; + message.field = []; + message.extension = []; + message.nestedType = []; + message.enumType = []; + message.extensionRange = []; + message.oneofDecl = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.field !== undefined && object.field !== null) { + for (const e of object.field) { + message.field.push(FieldDescriptorProto.fromJSON(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromJSON(e)); + } + } + if (object.nestedType !== undefined && object.nestedType !== null) { + for (const e of object.nestedType) { + message.nestedType.push(DescriptorProto.fromJSON(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromJSON(e)); + } + } + if (object.extensionRange !== undefined && object.extensionRange !== null) { + for (const e of object.extensionRange) { + message.extensionRange.push(DescriptorProto_ExtensionRange.fromJSON(e)); + } + } + if (object.oneofDecl !== undefined && object.oneofDecl !== null) { + for (const e of object.oneofDecl) { + message.oneofDecl.push(OneofDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = MessageOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push(DescriptorProto_ReservedRange.fromJSON(e)); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(String(e)); + } + } + return message; + }, + + toJSON(message: DescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + if (message.field) { + obj.field = message.field.map((e) => + e ? FieldDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.field = []; + } + if (message.extension) { + obj.extension = message.extension.map((e) => + e ? FieldDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.extension = []; + } + if (message.nestedType) { + obj.nestedType = message.nestedType.map((e) => + e ? DescriptorProto.toJSON(e) : undefined + ); + } else { + obj.nestedType = []; + } + if (message.enumType) { + obj.enumType = message.enumType.map((e) => + e ? EnumDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.enumType = []; + } + if (message.extensionRange) { + obj.extensionRange = message.extensionRange.map((e) => + e ? DescriptorProto_ExtensionRange.toJSON(e) : undefined + ); + } else { + obj.extensionRange = []; + } + if (message.oneofDecl) { + obj.oneofDecl = message.oneofDecl.map((e) => + e ? OneofDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.oneofDecl = []; + } + message.options !== undefined && + (obj.options = message.options + ? MessageOptions.toJSON(message.options) + : undefined); + if (message.reservedRange) { + obj.reservedRange = message.reservedRange.map((e) => + e ? DescriptorProto_ReservedRange.toJSON(e) : undefined + ); + } else { + obj.reservedRange = []; + } + if (message.reservedName) { + obj.reservedName = message.reservedName.map((e) => e); + } else { + obj.reservedName = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): DescriptorProto { + const message = { ...baseDescriptorProto } as DescriptorProto; + message.field = []; + message.extension = []; + message.nestedType = []; + message.enumType = []; + message.extensionRange = []; + message.oneofDecl = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.field !== undefined && object.field !== null) { + for (const e of object.field) { + message.field.push(FieldDescriptorProto.fromPartial(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromPartial(e)); + } + } + if (object.nestedType !== undefined && object.nestedType !== null) { + for (const e of object.nestedType) { + message.nestedType.push(DescriptorProto.fromPartial(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromPartial(e)); + } + } + if (object.extensionRange !== undefined && object.extensionRange !== null) { + for (const e of object.extensionRange) { + message.extensionRange.push( + DescriptorProto_ExtensionRange.fromPartial(e) + ); + } + } + if (object.oneofDecl !== undefined && object.oneofDecl !== null) { + for (const e of object.oneofDecl) { + message.oneofDecl.push(OneofDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = MessageOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push( + DescriptorProto_ReservedRange.fromPartial(e) + ); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(e); + } + } + return message; + }, +}; + +const baseDescriptorProto_ExtensionRange: object = { start: 0, end: 0 }; + +export const DescriptorProto_ExtensionRange = { + encode( + message: DescriptorProto_ExtensionRange, + writer: Writer = Writer.create() + ): Writer { + if (message.start !== 0) { + writer.uint32(8).int32(message.start); + } + if (message.end !== 0) { + writer.uint32(16).int32(message.end); + } + if (message.options !== undefined) { + ExtensionRangeOptions.encode( + message.options, + writer.uint32(26).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): DescriptorProto_ExtensionRange { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseDescriptorProto_ExtensionRange, + } as DescriptorProto_ExtensionRange; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.start = reader.int32(); + break; + case 2: + message.end = reader.int32(); + break; + case 3: + message.options = ExtensionRangeOptions.decode( + reader, + reader.uint32() + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DescriptorProto_ExtensionRange { + const message = { + ...baseDescriptorProto_ExtensionRange, + } as DescriptorProto_ExtensionRange; + if (object.start !== undefined && object.start !== null) { + message.start = Number(object.start); + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = ExtensionRangeOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: DescriptorProto_ExtensionRange): unknown { + const obj: any = {}; + message.start !== undefined && (obj.start = message.start); + message.end !== undefined && (obj.end = message.end); + message.options !== undefined && + (obj.options = message.options + ? ExtensionRangeOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): DescriptorProto_ExtensionRange { + const message = { + ...baseDescriptorProto_ExtensionRange, + } as DescriptorProto_ExtensionRange; + if (object.start !== undefined && object.start !== null) { + message.start = object.start; + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = ExtensionRangeOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseDescriptorProto_ReservedRange: object = { start: 0, end: 0 }; + +export const DescriptorProto_ReservedRange = { + encode( + message: DescriptorProto_ReservedRange, + writer: Writer = Writer.create() + ): Writer { + if (message.start !== 0) { + writer.uint32(8).int32(message.start); + } + if (message.end !== 0) { + writer.uint32(16).int32(message.end); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): DescriptorProto_ReservedRange { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseDescriptorProto_ReservedRange, + } as DescriptorProto_ReservedRange; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.start = reader.int32(); + break; + case 2: + message.end = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DescriptorProto_ReservedRange { + const message = { + ...baseDescriptorProto_ReservedRange, + } as DescriptorProto_ReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = Number(object.start); + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + return message; + }, + + toJSON(message: DescriptorProto_ReservedRange): unknown { + const obj: any = {}; + message.start !== undefined && (obj.start = message.start); + message.end !== undefined && (obj.end = message.end); + return obj; + }, + + fromPartial( + object: DeepPartial + ): DescriptorProto_ReservedRange { + const message = { + ...baseDescriptorProto_ReservedRange, + } as DescriptorProto_ReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = object.start; + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + return message; + }, +}; + +const baseExtensionRangeOptions: object = {}; + +export const ExtensionRangeOptions = { + encode( + message: ExtensionRangeOptions, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ExtensionRangeOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseExtensionRangeOptions } as ExtensionRangeOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ExtensionRangeOptions { + const message = { ...baseExtensionRangeOptions } as ExtensionRangeOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: ExtensionRangeOptions): unknown { + const obj: any = {}; + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial( + object: DeepPartial + ): ExtensionRangeOptions { + const message = { ...baseExtensionRangeOptions } as ExtensionRangeOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseFieldDescriptorProto: object = { + name: "", + number: 0, + label: 1, + type: 1, + typeName: "", + extendee: "", + defaultValue: "", + oneofIndex: 0, + jsonName: "", + proto3Optional: false, +}; + +export const FieldDescriptorProto = { + encode( + message: FieldDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.number !== 0) { + writer.uint32(24).int32(message.number); + } + if (message.label !== 1) { + writer.uint32(32).int32(message.label); + } + if (message.type !== 1) { + writer.uint32(40).int32(message.type); + } + if (message.typeName !== "") { + writer.uint32(50).string(message.typeName); + } + if (message.extendee !== "") { + writer.uint32(18).string(message.extendee); + } + if (message.defaultValue !== "") { + writer.uint32(58).string(message.defaultValue); + } + if (message.oneofIndex !== 0) { + writer.uint32(72).int32(message.oneofIndex); + } + if (message.jsonName !== "") { + writer.uint32(82).string(message.jsonName); + } + if (message.options !== undefined) { + FieldOptions.encode(message.options, writer.uint32(66).fork()).ldelim(); + } + if (message.proto3Optional === true) { + writer.uint32(136).bool(message.proto3Optional); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FieldDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFieldDescriptorProto } as FieldDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 3: + message.number = reader.int32(); + break; + case 4: + message.label = reader.int32() as any; + break; + case 5: + message.type = reader.int32() as any; + break; + case 6: + message.typeName = reader.string(); + break; + case 2: + message.extendee = reader.string(); + break; + case 7: + message.defaultValue = reader.string(); + break; + case 9: + message.oneofIndex = reader.int32(); + break; + case 10: + message.jsonName = reader.string(); + break; + case 8: + message.options = FieldOptions.decode(reader, reader.uint32()); + break; + case 17: + message.proto3Optional = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FieldDescriptorProto { + const message = { ...baseFieldDescriptorProto } as FieldDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = Number(object.number); + } else { + message.number = 0; + } + if (object.label !== undefined && object.label !== null) { + message.label = fieldDescriptorProto_LabelFromJSON(object.label); + } else { + message.label = 1; + } + if (object.type !== undefined && object.type !== null) { + message.type = fieldDescriptorProto_TypeFromJSON(object.type); + } else { + message.type = 1; + } + if (object.typeName !== undefined && object.typeName !== null) { + message.typeName = String(object.typeName); + } else { + message.typeName = ""; + } + if (object.extendee !== undefined && object.extendee !== null) { + message.extendee = String(object.extendee); + } else { + message.extendee = ""; + } + if (object.defaultValue !== undefined && object.defaultValue !== null) { + message.defaultValue = String(object.defaultValue); + } else { + message.defaultValue = ""; + } + if (object.oneofIndex !== undefined && object.oneofIndex !== null) { + message.oneofIndex = Number(object.oneofIndex); + } else { + message.oneofIndex = 0; + } + if (object.jsonName !== undefined && object.jsonName !== null) { + message.jsonName = String(object.jsonName); + } else { + message.jsonName = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = FieldOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.proto3Optional !== undefined && object.proto3Optional !== null) { + message.proto3Optional = Boolean(object.proto3Optional); + } else { + message.proto3Optional = false; + } + return message; + }, + + toJSON(message: FieldDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.number !== undefined && (obj.number = message.number); + message.label !== undefined && + (obj.label = fieldDescriptorProto_LabelToJSON(message.label)); + message.type !== undefined && + (obj.type = fieldDescriptorProto_TypeToJSON(message.type)); + message.typeName !== undefined && (obj.typeName = message.typeName); + message.extendee !== undefined && (obj.extendee = message.extendee); + message.defaultValue !== undefined && + (obj.defaultValue = message.defaultValue); + message.oneofIndex !== undefined && (obj.oneofIndex = message.oneofIndex); + message.jsonName !== undefined && (obj.jsonName = message.jsonName); + message.options !== undefined && + (obj.options = message.options + ? FieldOptions.toJSON(message.options) + : undefined); + message.proto3Optional !== undefined && + (obj.proto3Optional = message.proto3Optional); + return obj; + }, + + fromPartial(object: DeepPartial): FieldDescriptorProto { + const message = { ...baseFieldDescriptorProto } as FieldDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = object.number; + } else { + message.number = 0; + } + if (object.label !== undefined && object.label !== null) { + message.label = object.label; + } else { + message.label = 1; + } + if (object.type !== undefined && object.type !== null) { + message.type = object.type; + } else { + message.type = 1; + } + if (object.typeName !== undefined && object.typeName !== null) { + message.typeName = object.typeName; + } else { + message.typeName = ""; + } + if (object.extendee !== undefined && object.extendee !== null) { + message.extendee = object.extendee; + } else { + message.extendee = ""; + } + if (object.defaultValue !== undefined && object.defaultValue !== null) { + message.defaultValue = object.defaultValue; + } else { + message.defaultValue = ""; + } + if (object.oneofIndex !== undefined && object.oneofIndex !== null) { + message.oneofIndex = object.oneofIndex; + } else { + message.oneofIndex = 0; + } + if (object.jsonName !== undefined && object.jsonName !== null) { + message.jsonName = object.jsonName; + } else { + message.jsonName = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = FieldOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.proto3Optional !== undefined && object.proto3Optional !== null) { + message.proto3Optional = object.proto3Optional; + } else { + message.proto3Optional = false; + } + return message; + }, +}; + +const baseOneofDescriptorProto: object = { name: "" }; + +export const OneofDescriptorProto = { + encode( + message: OneofDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.options !== undefined) { + OneofOptions.encode(message.options, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): OneofDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseOneofDescriptorProto } as OneofDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.options = OneofOptions.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): OneofDescriptorProto { + const message = { ...baseOneofDescriptorProto } as OneofDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = OneofOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: OneofDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.options !== undefined && + (obj.options = message.options + ? OneofOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): OneofDescriptorProto { + const message = { ...baseOneofDescriptorProto } as OneofDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = OneofOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseEnumDescriptorProto: object = { name: "", reservedName: "" }; + +export const EnumDescriptorProto = { + encode( + message: EnumDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + for (const v of message.value) { + EnumValueDescriptorProto.encode(v!, writer.uint32(18).fork()).ldelim(); + } + if (message.options !== undefined) { + EnumOptions.encode(message.options, writer.uint32(26).fork()).ldelim(); + } + for (const v of message.reservedRange) { + EnumDescriptorProto_EnumReservedRange.encode( + v!, + writer.uint32(34).fork() + ).ldelim(); + } + for (const v of message.reservedName) { + writer.uint32(42).string(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): EnumDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseEnumDescriptorProto } as EnumDescriptorProto; + message.value = []; + message.reservedRange = []; + message.reservedName = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.value.push( + EnumValueDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 3: + message.options = EnumOptions.decode(reader, reader.uint32()); + break; + case 4: + message.reservedRange.push( + EnumDescriptorProto_EnumReservedRange.decode( + reader, + reader.uint32() + ) + ); + break; + case 5: + message.reservedName.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumDescriptorProto { + const message = { ...baseEnumDescriptorProto } as EnumDescriptorProto; + message.value = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.value !== undefined && object.value !== null) { + for (const e of object.value) { + message.value.push(EnumValueDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push( + EnumDescriptorProto_EnumReservedRange.fromJSON(e) + ); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(String(e)); + } + } + return message; + }, + + toJSON(message: EnumDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + if (message.value) { + obj.value = message.value.map((e) => + e ? EnumValueDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.value = []; + } + message.options !== undefined && + (obj.options = message.options + ? EnumOptions.toJSON(message.options) + : undefined); + if (message.reservedRange) { + obj.reservedRange = message.reservedRange.map((e) => + e ? EnumDescriptorProto_EnumReservedRange.toJSON(e) : undefined + ); + } else { + obj.reservedRange = []; + } + if (message.reservedName) { + obj.reservedName = message.reservedName.map((e) => e); + } else { + obj.reservedName = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): EnumDescriptorProto { + const message = { ...baseEnumDescriptorProto } as EnumDescriptorProto; + message.value = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.value !== undefined && object.value !== null) { + for (const e of object.value) { + message.value.push(EnumValueDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push( + EnumDescriptorProto_EnumReservedRange.fromPartial(e) + ); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(e); + } + } + return message; + }, +}; + +const baseEnumDescriptorProto_EnumReservedRange: object = { start: 0, end: 0 }; + +export const EnumDescriptorProto_EnumReservedRange = { + encode( + message: EnumDescriptorProto_EnumReservedRange, + writer: Writer = Writer.create() + ): Writer { + if (message.start !== 0) { + writer.uint32(8).int32(message.start); + } + if (message.end !== 0) { + writer.uint32(16).int32(message.end); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): EnumDescriptorProto_EnumReservedRange { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseEnumDescriptorProto_EnumReservedRange, + } as EnumDescriptorProto_EnumReservedRange; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.start = reader.int32(); + break; + case 2: + message.end = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumDescriptorProto_EnumReservedRange { + const message = { + ...baseEnumDescriptorProto_EnumReservedRange, + } as EnumDescriptorProto_EnumReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = Number(object.start); + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + return message; + }, + + toJSON(message: EnumDescriptorProto_EnumReservedRange): unknown { + const obj: any = {}; + message.start !== undefined && (obj.start = message.start); + message.end !== undefined && (obj.end = message.end); + return obj; + }, + + fromPartial( + object: DeepPartial + ): EnumDescriptorProto_EnumReservedRange { + const message = { + ...baseEnumDescriptorProto_EnumReservedRange, + } as EnumDescriptorProto_EnumReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = object.start; + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + return message; + }, +}; + +const baseEnumValueDescriptorProto: object = { name: "", number: 0 }; + +export const EnumValueDescriptorProto = { + encode( + message: EnumValueDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.number !== 0) { + writer.uint32(16).int32(message.number); + } + if (message.options !== undefined) { + EnumValueOptions.encode( + message.options, + writer.uint32(26).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): EnumValueDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseEnumValueDescriptorProto, + } as EnumValueDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.number = reader.int32(); + break; + case 3: + message.options = EnumValueOptions.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumValueDescriptorProto { + const message = { + ...baseEnumValueDescriptorProto, + } as EnumValueDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = Number(object.number); + } else { + message.number = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumValueOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: EnumValueDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.number !== undefined && (obj.number = message.number); + message.options !== undefined && + (obj.options = message.options + ? EnumValueOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): EnumValueDescriptorProto { + const message = { + ...baseEnumValueDescriptorProto, + } as EnumValueDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = object.number; + } else { + message.number = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumValueOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseServiceDescriptorProto: object = { name: "" }; + +export const ServiceDescriptorProto = { + encode( + message: ServiceDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + for (const v of message.method) { + MethodDescriptorProto.encode(v!, writer.uint32(18).fork()).ldelim(); + } + if (message.options !== undefined) { + ServiceOptions.encode(message.options, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ServiceDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseServiceDescriptorProto } as ServiceDescriptorProto; + message.method = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.method.push( + MethodDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 3: + message.options = ServiceOptions.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ServiceDescriptorProto { + const message = { ...baseServiceDescriptorProto } as ServiceDescriptorProto; + message.method = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.method !== undefined && object.method !== null) { + for (const e of object.method) { + message.method.push(MethodDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = ServiceOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: ServiceDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + if (message.method) { + obj.method = message.method.map((e) => + e ? MethodDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.method = []; + } + message.options !== undefined && + (obj.options = message.options + ? ServiceOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): ServiceDescriptorProto { + const message = { ...baseServiceDescriptorProto } as ServiceDescriptorProto; + message.method = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.method !== undefined && object.method !== null) { + for (const e of object.method) { + message.method.push(MethodDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = ServiceOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseMethodDescriptorProto: object = { + name: "", + inputType: "", + outputType: "", + clientStreaming: false, + serverStreaming: false, +}; + +export const MethodDescriptorProto = { + encode( + message: MethodDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.inputType !== "") { + writer.uint32(18).string(message.inputType); + } + if (message.outputType !== "") { + writer.uint32(26).string(message.outputType); + } + if (message.options !== undefined) { + MethodOptions.encode(message.options, writer.uint32(34).fork()).ldelim(); + } + if (message.clientStreaming === true) { + writer.uint32(40).bool(message.clientStreaming); + } + if (message.serverStreaming === true) { + writer.uint32(48).bool(message.serverStreaming); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MethodDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMethodDescriptorProto } as MethodDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.inputType = reader.string(); + break; + case 3: + message.outputType = reader.string(); + break; + case 4: + message.options = MethodOptions.decode(reader, reader.uint32()); + break; + case 5: + message.clientStreaming = reader.bool(); + break; + case 6: + message.serverStreaming = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MethodDescriptorProto { + const message = { ...baseMethodDescriptorProto } as MethodDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.inputType !== undefined && object.inputType !== null) { + message.inputType = String(object.inputType); + } else { + message.inputType = ""; + } + if (object.outputType !== undefined && object.outputType !== null) { + message.outputType = String(object.outputType); + } else { + message.outputType = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = MethodOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if ( + object.clientStreaming !== undefined && + object.clientStreaming !== null + ) { + message.clientStreaming = Boolean(object.clientStreaming); + } else { + message.clientStreaming = false; + } + if ( + object.serverStreaming !== undefined && + object.serverStreaming !== null + ) { + message.serverStreaming = Boolean(object.serverStreaming); + } else { + message.serverStreaming = false; + } + return message; + }, + + toJSON(message: MethodDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.inputType !== undefined && (obj.inputType = message.inputType); + message.outputType !== undefined && (obj.outputType = message.outputType); + message.options !== undefined && + (obj.options = message.options + ? MethodOptions.toJSON(message.options) + : undefined); + message.clientStreaming !== undefined && + (obj.clientStreaming = message.clientStreaming); + message.serverStreaming !== undefined && + (obj.serverStreaming = message.serverStreaming); + return obj; + }, + + fromPartial( + object: DeepPartial + ): MethodDescriptorProto { + const message = { ...baseMethodDescriptorProto } as MethodDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.inputType !== undefined && object.inputType !== null) { + message.inputType = object.inputType; + } else { + message.inputType = ""; + } + if (object.outputType !== undefined && object.outputType !== null) { + message.outputType = object.outputType; + } else { + message.outputType = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = MethodOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if ( + object.clientStreaming !== undefined && + object.clientStreaming !== null + ) { + message.clientStreaming = object.clientStreaming; + } else { + message.clientStreaming = false; + } + if ( + object.serverStreaming !== undefined && + object.serverStreaming !== null + ) { + message.serverStreaming = object.serverStreaming; + } else { + message.serverStreaming = false; + } + return message; + }, +}; + +const baseFileOptions: object = { + javaPackage: "", + javaOuterClassname: "", + javaMultipleFiles: false, + javaGenerateEqualsAndHash: false, + javaStringCheckUtf8: false, + optimizeFor: 1, + goPackage: "", + ccGenericServices: false, + javaGenericServices: false, + pyGenericServices: false, + phpGenericServices: false, + deprecated: false, + ccEnableArenas: false, + objcClassPrefix: "", + csharpNamespace: "", + swiftPrefix: "", + phpClassPrefix: "", + phpNamespace: "", + phpMetadataNamespace: "", + rubyPackage: "", +}; + +export const FileOptions = { + encode(message: FileOptions, writer: Writer = Writer.create()): Writer { + if (message.javaPackage !== "") { + writer.uint32(10).string(message.javaPackage); + } + if (message.javaOuterClassname !== "") { + writer.uint32(66).string(message.javaOuterClassname); + } + if (message.javaMultipleFiles === true) { + writer.uint32(80).bool(message.javaMultipleFiles); + } + if (message.javaGenerateEqualsAndHash === true) { + writer.uint32(160).bool(message.javaGenerateEqualsAndHash); + } + if (message.javaStringCheckUtf8 === true) { + writer.uint32(216).bool(message.javaStringCheckUtf8); + } + if (message.optimizeFor !== 1) { + writer.uint32(72).int32(message.optimizeFor); + } + if (message.goPackage !== "") { + writer.uint32(90).string(message.goPackage); + } + if (message.ccGenericServices === true) { + writer.uint32(128).bool(message.ccGenericServices); + } + if (message.javaGenericServices === true) { + writer.uint32(136).bool(message.javaGenericServices); + } + if (message.pyGenericServices === true) { + writer.uint32(144).bool(message.pyGenericServices); + } + if (message.phpGenericServices === true) { + writer.uint32(336).bool(message.phpGenericServices); + } + if (message.deprecated === true) { + writer.uint32(184).bool(message.deprecated); + } + if (message.ccEnableArenas === true) { + writer.uint32(248).bool(message.ccEnableArenas); + } + if (message.objcClassPrefix !== "") { + writer.uint32(290).string(message.objcClassPrefix); + } + if (message.csharpNamespace !== "") { + writer.uint32(298).string(message.csharpNamespace); + } + if (message.swiftPrefix !== "") { + writer.uint32(314).string(message.swiftPrefix); + } + if (message.phpClassPrefix !== "") { + writer.uint32(322).string(message.phpClassPrefix); + } + if (message.phpNamespace !== "") { + writer.uint32(330).string(message.phpNamespace); + } + if (message.phpMetadataNamespace !== "") { + writer.uint32(354).string(message.phpMetadataNamespace); + } + if (message.rubyPackage !== "") { + writer.uint32(362).string(message.rubyPackage); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FileOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFileOptions } as FileOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.javaPackage = reader.string(); + break; + case 8: + message.javaOuterClassname = reader.string(); + break; + case 10: + message.javaMultipleFiles = reader.bool(); + break; + case 20: + message.javaGenerateEqualsAndHash = reader.bool(); + break; + case 27: + message.javaStringCheckUtf8 = reader.bool(); + break; + case 9: + message.optimizeFor = reader.int32() as any; + break; + case 11: + message.goPackage = reader.string(); + break; + case 16: + message.ccGenericServices = reader.bool(); + break; + case 17: + message.javaGenericServices = reader.bool(); + break; + case 18: + message.pyGenericServices = reader.bool(); + break; + case 42: + message.phpGenericServices = reader.bool(); + break; + case 23: + message.deprecated = reader.bool(); + break; + case 31: + message.ccEnableArenas = reader.bool(); + break; + case 36: + message.objcClassPrefix = reader.string(); + break; + case 37: + message.csharpNamespace = reader.string(); + break; + case 39: + message.swiftPrefix = reader.string(); + break; + case 40: + message.phpClassPrefix = reader.string(); + break; + case 41: + message.phpNamespace = reader.string(); + break; + case 44: + message.phpMetadataNamespace = reader.string(); + break; + case 45: + message.rubyPackage = reader.string(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FileOptions { + const message = { ...baseFileOptions } as FileOptions; + message.uninterpretedOption = []; + if (object.javaPackage !== undefined && object.javaPackage !== null) { + message.javaPackage = String(object.javaPackage); + } else { + message.javaPackage = ""; + } + if ( + object.javaOuterClassname !== undefined && + object.javaOuterClassname !== null + ) { + message.javaOuterClassname = String(object.javaOuterClassname); + } else { + message.javaOuterClassname = ""; + } + if ( + object.javaMultipleFiles !== undefined && + object.javaMultipleFiles !== null + ) { + message.javaMultipleFiles = Boolean(object.javaMultipleFiles); + } else { + message.javaMultipleFiles = false; + } + if ( + object.javaGenerateEqualsAndHash !== undefined && + object.javaGenerateEqualsAndHash !== null + ) { + message.javaGenerateEqualsAndHash = Boolean( + object.javaGenerateEqualsAndHash + ); + } else { + message.javaGenerateEqualsAndHash = false; + } + if ( + object.javaStringCheckUtf8 !== undefined && + object.javaStringCheckUtf8 !== null + ) { + message.javaStringCheckUtf8 = Boolean(object.javaStringCheckUtf8); + } else { + message.javaStringCheckUtf8 = false; + } + if (object.optimizeFor !== undefined && object.optimizeFor !== null) { + message.optimizeFor = fileOptions_OptimizeModeFromJSON( + object.optimizeFor + ); + } else { + message.optimizeFor = 1; + } + if (object.goPackage !== undefined && object.goPackage !== null) { + message.goPackage = String(object.goPackage); + } else { + message.goPackage = ""; + } + if ( + object.ccGenericServices !== undefined && + object.ccGenericServices !== null + ) { + message.ccGenericServices = Boolean(object.ccGenericServices); + } else { + message.ccGenericServices = false; + } + if ( + object.javaGenericServices !== undefined && + object.javaGenericServices !== null + ) { + message.javaGenericServices = Boolean(object.javaGenericServices); + } else { + message.javaGenericServices = false; + } + if ( + object.pyGenericServices !== undefined && + object.pyGenericServices !== null + ) { + message.pyGenericServices = Boolean(object.pyGenericServices); + } else { + message.pyGenericServices = false; + } + if ( + object.phpGenericServices !== undefined && + object.phpGenericServices !== null + ) { + message.phpGenericServices = Boolean(object.phpGenericServices); + } else { + message.phpGenericServices = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if (object.ccEnableArenas !== undefined && object.ccEnableArenas !== null) { + message.ccEnableArenas = Boolean(object.ccEnableArenas); + } else { + message.ccEnableArenas = false; + } + if ( + object.objcClassPrefix !== undefined && + object.objcClassPrefix !== null + ) { + message.objcClassPrefix = String(object.objcClassPrefix); + } else { + message.objcClassPrefix = ""; + } + if ( + object.csharpNamespace !== undefined && + object.csharpNamespace !== null + ) { + message.csharpNamespace = String(object.csharpNamespace); + } else { + message.csharpNamespace = ""; + } + if (object.swiftPrefix !== undefined && object.swiftPrefix !== null) { + message.swiftPrefix = String(object.swiftPrefix); + } else { + message.swiftPrefix = ""; + } + if (object.phpClassPrefix !== undefined && object.phpClassPrefix !== null) { + message.phpClassPrefix = String(object.phpClassPrefix); + } else { + message.phpClassPrefix = ""; + } + if (object.phpNamespace !== undefined && object.phpNamespace !== null) { + message.phpNamespace = String(object.phpNamespace); + } else { + message.phpNamespace = ""; + } + if ( + object.phpMetadataNamespace !== undefined && + object.phpMetadataNamespace !== null + ) { + message.phpMetadataNamespace = String(object.phpMetadataNamespace); + } else { + message.phpMetadataNamespace = ""; + } + if (object.rubyPackage !== undefined && object.rubyPackage !== null) { + message.rubyPackage = String(object.rubyPackage); + } else { + message.rubyPackage = ""; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: FileOptions): unknown { + const obj: any = {}; + message.javaPackage !== undefined && + (obj.javaPackage = message.javaPackage); + message.javaOuterClassname !== undefined && + (obj.javaOuterClassname = message.javaOuterClassname); + message.javaMultipleFiles !== undefined && + (obj.javaMultipleFiles = message.javaMultipleFiles); + message.javaGenerateEqualsAndHash !== undefined && + (obj.javaGenerateEqualsAndHash = message.javaGenerateEqualsAndHash); + message.javaStringCheckUtf8 !== undefined && + (obj.javaStringCheckUtf8 = message.javaStringCheckUtf8); + message.optimizeFor !== undefined && + (obj.optimizeFor = fileOptions_OptimizeModeToJSON(message.optimizeFor)); + message.goPackage !== undefined && (obj.goPackage = message.goPackage); + message.ccGenericServices !== undefined && + (obj.ccGenericServices = message.ccGenericServices); + message.javaGenericServices !== undefined && + (obj.javaGenericServices = message.javaGenericServices); + message.pyGenericServices !== undefined && + (obj.pyGenericServices = message.pyGenericServices); + message.phpGenericServices !== undefined && + (obj.phpGenericServices = message.phpGenericServices); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.ccEnableArenas !== undefined && + (obj.ccEnableArenas = message.ccEnableArenas); + message.objcClassPrefix !== undefined && + (obj.objcClassPrefix = message.objcClassPrefix); + message.csharpNamespace !== undefined && + (obj.csharpNamespace = message.csharpNamespace); + message.swiftPrefix !== undefined && + (obj.swiftPrefix = message.swiftPrefix); + message.phpClassPrefix !== undefined && + (obj.phpClassPrefix = message.phpClassPrefix); + message.phpNamespace !== undefined && + (obj.phpNamespace = message.phpNamespace); + message.phpMetadataNamespace !== undefined && + (obj.phpMetadataNamespace = message.phpMetadataNamespace); + message.rubyPackage !== undefined && + (obj.rubyPackage = message.rubyPackage); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): FileOptions { + const message = { ...baseFileOptions } as FileOptions; + message.uninterpretedOption = []; + if (object.javaPackage !== undefined && object.javaPackage !== null) { + message.javaPackage = object.javaPackage; + } else { + message.javaPackage = ""; + } + if ( + object.javaOuterClassname !== undefined && + object.javaOuterClassname !== null + ) { + message.javaOuterClassname = object.javaOuterClassname; + } else { + message.javaOuterClassname = ""; + } + if ( + object.javaMultipleFiles !== undefined && + object.javaMultipleFiles !== null + ) { + message.javaMultipleFiles = object.javaMultipleFiles; + } else { + message.javaMultipleFiles = false; + } + if ( + object.javaGenerateEqualsAndHash !== undefined && + object.javaGenerateEqualsAndHash !== null + ) { + message.javaGenerateEqualsAndHash = object.javaGenerateEqualsAndHash; + } else { + message.javaGenerateEqualsAndHash = false; + } + if ( + object.javaStringCheckUtf8 !== undefined && + object.javaStringCheckUtf8 !== null + ) { + message.javaStringCheckUtf8 = object.javaStringCheckUtf8; + } else { + message.javaStringCheckUtf8 = false; + } + if (object.optimizeFor !== undefined && object.optimizeFor !== null) { + message.optimizeFor = object.optimizeFor; + } else { + message.optimizeFor = 1; + } + if (object.goPackage !== undefined && object.goPackage !== null) { + message.goPackage = object.goPackage; + } else { + message.goPackage = ""; + } + if ( + object.ccGenericServices !== undefined && + object.ccGenericServices !== null + ) { + message.ccGenericServices = object.ccGenericServices; + } else { + message.ccGenericServices = false; + } + if ( + object.javaGenericServices !== undefined && + object.javaGenericServices !== null + ) { + message.javaGenericServices = object.javaGenericServices; + } else { + message.javaGenericServices = false; + } + if ( + object.pyGenericServices !== undefined && + object.pyGenericServices !== null + ) { + message.pyGenericServices = object.pyGenericServices; + } else { + message.pyGenericServices = false; + } + if ( + object.phpGenericServices !== undefined && + object.phpGenericServices !== null + ) { + message.phpGenericServices = object.phpGenericServices; + } else { + message.phpGenericServices = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if (object.ccEnableArenas !== undefined && object.ccEnableArenas !== null) { + message.ccEnableArenas = object.ccEnableArenas; + } else { + message.ccEnableArenas = false; + } + if ( + object.objcClassPrefix !== undefined && + object.objcClassPrefix !== null + ) { + message.objcClassPrefix = object.objcClassPrefix; + } else { + message.objcClassPrefix = ""; + } + if ( + object.csharpNamespace !== undefined && + object.csharpNamespace !== null + ) { + message.csharpNamespace = object.csharpNamespace; + } else { + message.csharpNamespace = ""; + } + if (object.swiftPrefix !== undefined && object.swiftPrefix !== null) { + message.swiftPrefix = object.swiftPrefix; + } else { + message.swiftPrefix = ""; + } + if (object.phpClassPrefix !== undefined && object.phpClassPrefix !== null) { + message.phpClassPrefix = object.phpClassPrefix; + } else { + message.phpClassPrefix = ""; + } + if (object.phpNamespace !== undefined && object.phpNamespace !== null) { + message.phpNamespace = object.phpNamespace; + } else { + message.phpNamespace = ""; + } + if ( + object.phpMetadataNamespace !== undefined && + object.phpMetadataNamespace !== null + ) { + message.phpMetadataNamespace = object.phpMetadataNamespace; + } else { + message.phpMetadataNamespace = ""; + } + if (object.rubyPackage !== undefined && object.rubyPackage !== null) { + message.rubyPackage = object.rubyPackage; + } else { + message.rubyPackage = ""; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseMessageOptions: object = { + messageSetWireFormat: false, + noStandardDescriptorAccessor: false, + deprecated: false, + mapEntry: false, +}; + +export const MessageOptions = { + encode(message: MessageOptions, writer: Writer = Writer.create()): Writer { + if (message.messageSetWireFormat === true) { + writer.uint32(8).bool(message.messageSetWireFormat); + } + if (message.noStandardDescriptorAccessor === true) { + writer.uint32(16).bool(message.noStandardDescriptorAccessor); + } + if (message.deprecated === true) { + writer.uint32(24).bool(message.deprecated); + } + if (message.mapEntry === true) { + writer.uint32(56).bool(message.mapEntry); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MessageOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMessageOptions } as MessageOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.messageSetWireFormat = reader.bool(); + break; + case 2: + message.noStandardDescriptorAccessor = reader.bool(); + break; + case 3: + message.deprecated = reader.bool(); + break; + case 7: + message.mapEntry = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MessageOptions { + const message = { ...baseMessageOptions } as MessageOptions; + message.uninterpretedOption = []; + if ( + object.messageSetWireFormat !== undefined && + object.messageSetWireFormat !== null + ) { + message.messageSetWireFormat = Boolean(object.messageSetWireFormat); + } else { + message.messageSetWireFormat = false; + } + if ( + object.noStandardDescriptorAccessor !== undefined && + object.noStandardDescriptorAccessor !== null + ) { + message.noStandardDescriptorAccessor = Boolean( + object.noStandardDescriptorAccessor + ); + } else { + message.noStandardDescriptorAccessor = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if (object.mapEntry !== undefined && object.mapEntry !== null) { + message.mapEntry = Boolean(object.mapEntry); + } else { + message.mapEntry = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: MessageOptions): unknown { + const obj: any = {}; + message.messageSetWireFormat !== undefined && + (obj.messageSetWireFormat = message.messageSetWireFormat); + message.noStandardDescriptorAccessor !== undefined && + (obj.noStandardDescriptorAccessor = message.noStandardDescriptorAccessor); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.mapEntry !== undefined && (obj.mapEntry = message.mapEntry); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): MessageOptions { + const message = { ...baseMessageOptions } as MessageOptions; + message.uninterpretedOption = []; + if ( + object.messageSetWireFormat !== undefined && + object.messageSetWireFormat !== null + ) { + message.messageSetWireFormat = object.messageSetWireFormat; + } else { + message.messageSetWireFormat = false; + } + if ( + object.noStandardDescriptorAccessor !== undefined && + object.noStandardDescriptorAccessor !== null + ) { + message.noStandardDescriptorAccessor = + object.noStandardDescriptorAccessor; + } else { + message.noStandardDescriptorAccessor = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if (object.mapEntry !== undefined && object.mapEntry !== null) { + message.mapEntry = object.mapEntry; + } else { + message.mapEntry = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseFieldOptions: object = { + ctype: 0, + packed: false, + jstype: 0, + lazy: false, + deprecated: false, + weak: false, +}; + +export const FieldOptions = { + encode(message: FieldOptions, writer: Writer = Writer.create()): Writer { + if (message.ctype !== 0) { + writer.uint32(8).int32(message.ctype); + } + if (message.packed === true) { + writer.uint32(16).bool(message.packed); + } + if (message.jstype !== 0) { + writer.uint32(48).int32(message.jstype); + } + if (message.lazy === true) { + writer.uint32(40).bool(message.lazy); + } + if (message.deprecated === true) { + writer.uint32(24).bool(message.deprecated); + } + if (message.weak === true) { + writer.uint32(80).bool(message.weak); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FieldOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFieldOptions } as FieldOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.ctype = reader.int32() as any; + break; + case 2: + message.packed = reader.bool(); + break; + case 6: + message.jstype = reader.int32() as any; + break; + case 5: + message.lazy = reader.bool(); + break; + case 3: + message.deprecated = reader.bool(); + break; + case 10: + message.weak = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FieldOptions { + const message = { ...baseFieldOptions } as FieldOptions; + message.uninterpretedOption = []; + if (object.ctype !== undefined && object.ctype !== null) { + message.ctype = fieldOptions_CTypeFromJSON(object.ctype); + } else { + message.ctype = 0; + } + if (object.packed !== undefined && object.packed !== null) { + message.packed = Boolean(object.packed); + } else { + message.packed = false; + } + if (object.jstype !== undefined && object.jstype !== null) { + message.jstype = fieldOptions_JSTypeFromJSON(object.jstype); + } else { + message.jstype = 0; + } + if (object.lazy !== undefined && object.lazy !== null) { + message.lazy = Boolean(object.lazy); + } else { + message.lazy = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if (object.weak !== undefined && object.weak !== null) { + message.weak = Boolean(object.weak); + } else { + message.weak = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: FieldOptions): unknown { + const obj: any = {}; + message.ctype !== undefined && + (obj.ctype = fieldOptions_CTypeToJSON(message.ctype)); + message.packed !== undefined && (obj.packed = message.packed); + message.jstype !== undefined && + (obj.jstype = fieldOptions_JSTypeToJSON(message.jstype)); + message.lazy !== undefined && (obj.lazy = message.lazy); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.weak !== undefined && (obj.weak = message.weak); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): FieldOptions { + const message = { ...baseFieldOptions } as FieldOptions; + message.uninterpretedOption = []; + if (object.ctype !== undefined && object.ctype !== null) { + message.ctype = object.ctype; + } else { + message.ctype = 0; + } + if (object.packed !== undefined && object.packed !== null) { + message.packed = object.packed; + } else { + message.packed = false; + } + if (object.jstype !== undefined && object.jstype !== null) { + message.jstype = object.jstype; + } else { + message.jstype = 0; + } + if (object.lazy !== undefined && object.lazy !== null) { + message.lazy = object.lazy; + } else { + message.lazy = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if (object.weak !== undefined && object.weak !== null) { + message.weak = object.weak; + } else { + message.weak = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseOneofOptions: object = {}; + +export const OneofOptions = { + encode(message: OneofOptions, writer: Writer = Writer.create()): Writer { + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): OneofOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseOneofOptions } as OneofOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): OneofOptions { + const message = { ...baseOneofOptions } as OneofOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: OneofOptions): unknown { + const obj: any = {}; + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): OneofOptions { + const message = { ...baseOneofOptions } as OneofOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseEnumOptions: object = { allowAlias: false, deprecated: false }; + +export const EnumOptions = { + encode(message: EnumOptions, writer: Writer = Writer.create()): Writer { + if (message.allowAlias === true) { + writer.uint32(16).bool(message.allowAlias); + } + if (message.deprecated === true) { + writer.uint32(24).bool(message.deprecated); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): EnumOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseEnumOptions } as EnumOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + message.allowAlias = reader.bool(); + break; + case 3: + message.deprecated = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumOptions { + const message = { ...baseEnumOptions } as EnumOptions; + message.uninterpretedOption = []; + if (object.allowAlias !== undefined && object.allowAlias !== null) { + message.allowAlias = Boolean(object.allowAlias); + } else { + message.allowAlias = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: EnumOptions): unknown { + const obj: any = {}; + message.allowAlias !== undefined && (obj.allowAlias = message.allowAlias); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): EnumOptions { + const message = { ...baseEnumOptions } as EnumOptions; + message.uninterpretedOption = []; + if (object.allowAlias !== undefined && object.allowAlias !== null) { + message.allowAlias = object.allowAlias; + } else { + message.allowAlias = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseEnumValueOptions: object = { deprecated: false }; + +export const EnumValueOptions = { + encode(message: EnumValueOptions, writer: Writer = Writer.create()): Writer { + if (message.deprecated === true) { + writer.uint32(8).bool(message.deprecated); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): EnumValueOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseEnumValueOptions } as EnumValueOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.deprecated = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumValueOptions { + const message = { ...baseEnumValueOptions } as EnumValueOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: EnumValueOptions): unknown { + const obj: any = {}; + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): EnumValueOptions { + const message = { ...baseEnumValueOptions } as EnumValueOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseServiceOptions: object = { deprecated: false }; + +export const ServiceOptions = { + encode(message: ServiceOptions, writer: Writer = Writer.create()): Writer { + if (message.deprecated === true) { + writer.uint32(264).bool(message.deprecated); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ServiceOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseServiceOptions } as ServiceOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 33: + message.deprecated = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ServiceOptions { + const message = { ...baseServiceOptions } as ServiceOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: ServiceOptions): unknown { + const obj: any = {}; + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): ServiceOptions { + const message = { ...baseServiceOptions } as ServiceOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseMethodOptions: object = { deprecated: false, idempotencyLevel: 0 }; + +export const MethodOptions = { + encode(message: MethodOptions, writer: Writer = Writer.create()): Writer { + if (message.deprecated === true) { + writer.uint32(264).bool(message.deprecated); + } + if (message.idempotencyLevel !== 0) { + writer.uint32(272).int32(message.idempotencyLevel); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MethodOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMethodOptions } as MethodOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 33: + message.deprecated = reader.bool(); + break; + case 34: + message.idempotencyLevel = reader.int32() as any; + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MethodOptions { + const message = { ...baseMethodOptions } as MethodOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.idempotencyLevel !== undefined && + object.idempotencyLevel !== null + ) { + message.idempotencyLevel = methodOptions_IdempotencyLevelFromJSON( + object.idempotencyLevel + ); + } else { + message.idempotencyLevel = 0; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: MethodOptions): unknown { + const obj: any = {}; + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.idempotencyLevel !== undefined && + (obj.idempotencyLevel = methodOptions_IdempotencyLevelToJSON( + message.idempotencyLevel + )); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): MethodOptions { + const message = { ...baseMethodOptions } as MethodOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.idempotencyLevel !== undefined && + object.idempotencyLevel !== null + ) { + message.idempotencyLevel = object.idempotencyLevel; + } else { + message.idempotencyLevel = 0; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseUninterpretedOption: object = { + identifierValue: "", + positiveIntValue: 0, + negativeIntValue: 0, + doubleValue: 0, + aggregateValue: "", +}; + +export const UninterpretedOption = { + encode( + message: UninterpretedOption, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.name) { + UninterpretedOption_NamePart.encode( + v!, + writer.uint32(18).fork() + ).ldelim(); + } + if (message.identifierValue !== "") { + writer.uint32(26).string(message.identifierValue); + } + if (message.positiveIntValue !== 0) { + writer.uint32(32).uint64(message.positiveIntValue); + } + if (message.negativeIntValue !== 0) { + writer.uint32(40).int64(message.negativeIntValue); + } + if (message.doubleValue !== 0) { + writer.uint32(49).double(message.doubleValue); + } + if (message.stringValue.length !== 0) { + writer.uint32(58).bytes(message.stringValue); + } + if (message.aggregateValue !== "") { + writer.uint32(66).string(message.aggregateValue); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): UninterpretedOption { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseUninterpretedOption } as UninterpretedOption; + message.name = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + message.name.push( + UninterpretedOption_NamePart.decode(reader, reader.uint32()) + ); + break; + case 3: + message.identifierValue = reader.string(); + break; + case 4: + message.positiveIntValue = longToNumber(reader.uint64() as Long); + break; + case 5: + message.negativeIntValue = longToNumber(reader.int64() as Long); + break; + case 6: + message.doubleValue = reader.double(); + break; + case 7: + message.stringValue = reader.bytes(); + break; + case 8: + message.aggregateValue = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): UninterpretedOption { + const message = { ...baseUninterpretedOption } as UninterpretedOption; + message.name = []; + if (object.name !== undefined && object.name !== null) { + for (const e of object.name) { + message.name.push(UninterpretedOption_NamePart.fromJSON(e)); + } + } + if ( + object.identifierValue !== undefined && + object.identifierValue !== null + ) { + message.identifierValue = String(object.identifierValue); + } else { + message.identifierValue = ""; + } + if ( + object.positiveIntValue !== undefined && + object.positiveIntValue !== null + ) { + message.positiveIntValue = Number(object.positiveIntValue); + } else { + message.positiveIntValue = 0; + } + if ( + object.negativeIntValue !== undefined && + object.negativeIntValue !== null + ) { + message.negativeIntValue = Number(object.negativeIntValue); + } else { + message.negativeIntValue = 0; + } + if (object.doubleValue !== undefined && object.doubleValue !== null) { + message.doubleValue = Number(object.doubleValue); + } else { + message.doubleValue = 0; + } + if (object.stringValue !== undefined && object.stringValue !== null) { + message.stringValue = bytesFromBase64(object.stringValue); + } + if (object.aggregateValue !== undefined && object.aggregateValue !== null) { + message.aggregateValue = String(object.aggregateValue); + } else { + message.aggregateValue = ""; + } + return message; + }, + + toJSON(message: UninterpretedOption): unknown { + const obj: any = {}; + if (message.name) { + obj.name = message.name.map((e) => + e ? UninterpretedOption_NamePart.toJSON(e) : undefined + ); + } else { + obj.name = []; + } + message.identifierValue !== undefined && + (obj.identifierValue = message.identifierValue); + message.positiveIntValue !== undefined && + (obj.positiveIntValue = message.positiveIntValue); + message.negativeIntValue !== undefined && + (obj.negativeIntValue = message.negativeIntValue); + message.doubleValue !== undefined && + (obj.doubleValue = message.doubleValue); + message.stringValue !== undefined && + (obj.stringValue = base64FromBytes( + message.stringValue !== undefined + ? message.stringValue + : new Uint8Array() + )); + message.aggregateValue !== undefined && + (obj.aggregateValue = message.aggregateValue); + return obj; + }, + + fromPartial(object: DeepPartial): UninterpretedOption { + const message = { ...baseUninterpretedOption } as UninterpretedOption; + message.name = []; + if (object.name !== undefined && object.name !== null) { + for (const e of object.name) { + message.name.push(UninterpretedOption_NamePart.fromPartial(e)); + } + } + if ( + object.identifierValue !== undefined && + object.identifierValue !== null + ) { + message.identifierValue = object.identifierValue; + } else { + message.identifierValue = ""; + } + if ( + object.positiveIntValue !== undefined && + object.positiveIntValue !== null + ) { + message.positiveIntValue = object.positiveIntValue; + } else { + message.positiveIntValue = 0; + } + if ( + object.negativeIntValue !== undefined && + object.negativeIntValue !== null + ) { + message.negativeIntValue = object.negativeIntValue; + } else { + message.negativeIntValue = 0; + } + if (object.doubleValue !== undefined && object.doubleValue !== null) { + message.doubleValue = object.doubleValue; + } else { + message.doubleValue = 0; + } + if (object.stringValue !== undefined && object.stringValue !== null) { + message.stringValue = object.stringValue; + } else { + message.stringValue = new Uint8Array(); + } + if (object.aggregateValue !== undefined && object.aggregateValue !== null) { + message.aggregateValue = object.aggregateValue; + } else { + message.aggregateValue = ""; + } + return message; + }, +}; + +const baseUninterpretedOption_NamePart: object = { + namePart: "", + isExtension: false, +}; + +export const UninterpretedOption_NamePart = { + encode( + message: UninterpretedOption_NamePart, + writer: Writer = Writer.create() + ): Writer { + if (message.namePart !== "") { + writer.uint32(10).string(message.namePart); + } + if (message.isExtension === true) { + writer.uint32(16).bool(message.isExtension); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): UninterpretedOption_NamePart { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseUninterpretedOption_NamePart, + } as UninterpretedOption_NamePart; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.namePart = reader.string(); + break; + case 2: + message.isExtension = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): UninterpretedOption_NamePart { + const message = { + ...baseUninterpretedOption_NamePart, + } as UninterpretedOption_NamePart; + if (object.namePart !== undefined && object.namePart !== null) { + message.namePart = String(object.namePart); + } else { + message.namePart = ""; + } + if (object.isExtension !== undefined && object.isExtension !== null) { + message.isExtension = Boolean(object.isExtension); + } else { + message.isExtension = false; + } + return message; + }, + + toJSON(message: UninterpretedOption_NamePart): unknown { + const obj: any = {}; + message.namePart !== undefined && (obj.namePart = message.namePart); + message.isExtension !== undefined && + (obj.isExtension = message.isExtension); + return obj; + }, + + fromPartial( + object: DeepPartial + ): UninterpretedOption_NamePart { + const message = { + ...baseUninterpretedOption_NamePart, + } as UninterpretedOption_NamePart; + if (object.namePart !== undefined && object.namePart !== null) { + message.namePart = object.namePart; + } else { + message.namePart = ""; + } + if (object.isExtension !== undefined && object.isExtension !== null) { + message.isExtension = object.isExtension; + } else { + message.isExtension = false; + } + return message; + }, +}; + +const baseSourceCodeInfo: object = {}; + +export const SourceCodeInfo = { + encode(message: SourceCodeInfo, writer: Writer = Writer.create()): Writer { + for (const v of message.location) { + SourceCodeInfo_Location.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): SourceCodeInfo { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseSourceCodeInfo } as SourceCodeInfo; + message.location = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.location.push( + SourceCodeInfo_Location.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): SourceCodeInfo { + const message = { ...baseSourceCodeInfo } as SourceCodeInfo; + message.location = []; + if (object.location !== undefined && object.location !== null) { + for (const e of object.location) { + message.location.push(SourceCodeInfo_Location.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: SourceCodeInfo): unknown { + const obj: any = {}; + if (message.location) { + obj.location = message.location.map((e) => + e ? SourceCodeInfo_Location.toJSON(e) : undefined + ); + } else { + obj.location = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): SourceCodeInfo { + const message = { ...baseSourceCodeInfo } as SourceCodeInfo; + message.location = []; + if (object.location !== undefined && object.location !== null) { + for (const e of object.location) { + message.location.push(SourceCodeInfo_Location.fromPartial(e)); + } + } + return message; + }, +}; + +const baseSourceCodeInfo_Location: object = { + path: 0, + span: 0, + leadingComments: "", + trailingComments: "", + leadingDetachedComments: "", +}; + +export const SourceCodeInfo_Location = { + encode( + message: SourceCodeInfo_Location, + writer: Writer = Writer.create() + ): Writer { + writer.uint32(10).fork(); + for (const v of message.path) { + writer.int32(v); + } + writer.ldelim(); + writer.uint32(18).fork(); + for (const v of message.span) { + writer.int32(v); + } + writer.ldelim(); + if (message.leadingComments !== "") { + writer.uint32(26).string(message.leadingComments); + } + if (message.trailingComments !== "") { + writer.uint32(34).string(message.trailingComments); + } + for (const v of message.leadingDetachedComments) { + writer.uint32(50).string(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): SourceCodeInfo_Location { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseSourceCodeInfo_Location, + } as SourceCodeInfo_Location; + message.path = []; + message.span = []; + message.leadingDetachedComments = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.path.push(reader.int32()); + } + } else { + message.path.push(reader.int32()); + } + break; + case 2: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.span.push(reader.int32()); + } + } else { + message.span.push(reader.int32()); + } + break; + case 3: + message.leadingComments = reader.string(); + break; + case 4: + message.trailingComments = reader.string(); + break; + case 6: + message.leadingDetachedComments.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): SourceCodeInfo_Location { + const message = { + ...baseSourceCodeInfo_Location, + } as SourceCodeInfo_Location; + message.path = []; + message.span = []; + message.leadingDetachedComments = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(Number(e)); + } + } + if (object.span !== undefined && object.span !== null) { + for (const e of object.span) { + message.span.push(Number(e)); + } + } + if ( + object.leadingComments !== undefined && + object.leadingComments !== null + ) { + message.leadingComments = String(object.leadingComments); + } else { + message.leadingComments = ""; + } + if ( + object.trailingComments !== undefined && + object.trailingComments !== null + ) { + message.trailingComments = String(object.trailingComments); + } else { + message.trailingComments = ""; + } + if ( + object.leadingDetachedComments !== undefined && + object.leadingDetachedComments !== null + ) { + for (const e of object.leadingDetachedComments) { + message.leadingDetachedComments.push(String(e)); + } + } + return message; + }, + + toJSON(message: SourceCodeInfo_Location): unknown { + const obj: any = {}; + if (message.path) { + obj.path = message.path.map((e) => e); + } else { + obj.path = []; + } + if (message.span) { + obj.span = message.span.map((e) => e); + } else { + obj.span = []; + } + message.leadingComments !== undefined && + (obj.leadingComments = message.leadingComments); + message.trailingComments !== undefined && + (obj.trailingComments = message.trailingComments); + if (message.leadingDetachedComments) { + obj.leadingDetachedComments = message.leadingDetachedComments.map( + (e) => e + ); + } else { + obj.leadingDetachedComments = []; + } + return obj; + }, + + fromPartial( + object: DeepPartial + ): SourceCodeInfo_Location { + const message = { + ...baseSourceCodeInfo_Location, + } as SourceCodeInfo_Location; + message.path = []; + message.span = []; + message.leadingDetachedComments = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(e); + } + } + if (object.span !== undefined && object.span !== null) { + for (const e of object.span) { + message.span.push(e); + } + } + if ( + object.leadingComments !== undefined && + object.leadingComments !== null + ) { + message.leadingComments = object.leadingComments; + } else { + message.leadingComments = ""; + } + if ( + object.trailingComments !== undefined && + object.trailingComments !== null + ) { + message.trailingComments = object.trailingComments; + } else { + message.trailingComments = ""; + } + if ( + object.leadingDetachedComments !== undefined && + object.leadingDetachedComments !== null + ) { + for (const e of object.leadingDetachedComments) { + message.leadingDetachedComments.push(e); + } + } + return message; + }, +}; + +const baseGeneratedCodeInfo: object = {}; + +export const GeneratedCodeInfo = { + encode(message: GeneratedCodeInfo, writer: Writer = Writer.create()): Writer { + for (const v of message.annotation) { + GeneratedCodeInfo_Annotation.encode( + v!, + writer.uint32(10).fork() + ).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): GeneratedCodeInfo { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseGeneratedCodeInfo } as GeneratedCodeInfo; + message.annotation = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.annotation.push( + GeneratedCodeInfo_Annotation.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GeneratedCodeInfo { + const message = { ...baseGeneratedCodeInfo } as GeneratedCodeInfo; + message.annotation = []; + if (object.annotation !== undefined && object.annotation !== null) { + for (const e of object.annotation) { + message.annotation.push(GeneratedCodeInfo_Annotation.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: GeneratedCodeInfo): unknown { + const obj: any = {}; + if (message.annotation) { + obj.annotation = message.annotation.map((e) => + e ? GeneratedCodeInfo_Annotation.toJSON(e) : undefined + ); + } else { + obj.annotation = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): GeneratedCodeInfo { + const message = { ...baseGeneratedCodeInfo } as GeneratedCodeInfo; + message.annotation = []; + if (object.annotation !== undefined && object.annotation !== null) { + for (const e of object.annotation) { + message.annotation.push(GeneratedCodeInfo_Annotation.fromPartial(e)); + } + } + return message; + }, +}; + +const baseGeneratedCodeInfo_Annotation: object = { + path: 0, + sourceFile: "", + begin: 0, + end: 0, +}; + +export const GeneratedCodeInfo_Annotation = { + encode( + message: GeneratedCodeInfo_Annotation, + writer: Writer = Writer.create() + ): Writer { + writer.uint32(10).fork(); + for (const v of message.path) { + writer.int32(v); + } + writer.ldelim(); + if (message.sourceFile !== "") { + writer.uint32(18).string(message.sourceFile); + } + if (message.begin !== 0) { + writer.uint32(24).int32(message.begin); + } + if (message.end !== 0) { + writer.uint32(32).int32(message.end); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): GeneratedCodeInfo_Annotation { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseGeneratedCodeInfo_Annotation, + } as GeneratedCodeInfo_Annotation; + message.path = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.path.push(reader.int32()); + } + } else { + message.path.push(reader.int32()); + } + break; + case 2: + message.sourceFile = reader.string(); + break; + case 3: + message.begin = reader.int32(); + break; + case 4: + message.end = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GeneratedCodeInfo_Annotation { + const message = { + ...baseGeneratedCodeInfo_Annotation, + } as GeneratedCodeInfo_Annotation; + message.path = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(Number(e)); + } + } + if (object.sourceFile !== undefined && object.sourceFile !== null) { + message.sourceFile = String(object.sourceFile); + } else { + message.sourceFile = ""; + } + if (object.begin !== undefined && object.begin !== null) { + message.begin = Number(object.begin); + } else { + message.begin = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + return message; + }, + + toJSON(message: GeneratedCodeInfo_Annotation): unknown { + const obj: any = {}; + if (message.path) { + obj.path = message.path.map((e) => e); + } else { + obj.path = []; + } + message.sourceFile !== undefined && (obj.sourceFile = message.sourceFile); + message.begin !== undefined && (obj.begin = message.begin); + message.end !== undefined && (obj.end = message.end); + return obj; + }, + + fromPartial( + object: DeepPartial + ): GeneratedCodeInfo_Annotation { + const message = { + ...baseGeneratedCodeInfo_Annotation, + } as GeneratedCodeInfo_Annotation; + message.path = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(e); + } + } + if (object.sourceFile !== undefined && object.sourceFile !== null) { + message.sourceFile = object.sourceFile; + } else { + message.sourceFile = ""; + } + if (object.begin !== undefined && object.begin !== null) { + message.begin = object.begin; + } else { + message.begin = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/cosmos.evidence.v1beta1/types/google/protobuf/timestamp.ts b/ts-client/cosmos.evidence.v1beta1/types/google/protobuf/timestamp.ts new file mode 100644 index 00000000..11864afc --- /dev/null +++ b/ts-client/cosmos.evidence.v1beta1/types/google/protobuf/timestamp.ts @@ -0,0 +1,219 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "google.protobuf"; + +/** + * A Timestamp represents a point in time independent of any time zone or local + * calendar, encoded as a count of seconds and fractions of seconds at + * nanosecond resolution. The count is relative to an epoch at UTC midnight on + * January 1, 1970, in the proleptic Gregorian calendar which extends the + * Gregorian calendar backwards to year one. + * + * All minutes are 60 seconds long. Leap seconds are "smeared" so that no leap + * second table is needed for interpretation, using a [24-hour linear + * smear](https://developers.google.com/time/smear). + * + * The range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. By + * restricting to that range, we ensure that we can convert to and from [RFC + * 3339](https://www.ietf.org/rfc/rfc3339.txt) date strings. + * + * # Examples + * + * Example 1: Compute Timestamp from POSIX `time()`. + * + * Timestamp timestamp; + * timestamp.set_seconds(time(NULL)); + * timestamp.set_nanos(0); + * + * Example 2: Compute Timestamp from POSIX `gettimeofday()`. + * + * struct timeval tv; + * gettimeofday(&tv, NULL); + * + * Timestamp timestamp; + * timestamp.set_seconds(tv.tv_sec); + * timestamp.set_nanos(tv.tv_usec * 1000); + * + * Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`. + * + * FILETIME ft; + * GetSystemTimeAsFileTime(&ft); + * UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime; + * + * // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z + * // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z. + * Timestamp timestamp; + * timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL)); + * timestamp.set_nanos((INT32) ((ticks % 10000000) * 100)); + * + * Example 4: Compute Timestamp from Java `System.currentTimeMillis()`. + * + * long millis = System.currentTimeMillis(); + * + * Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000) + * .setNanos((int) ((millis % 1000) * 1000000)).build(); + * + * + * Example 5: Compute Timestamp from Java `Instant.now()`. + * + * Instant now = Instant.now(); + * + * Timestamp timestamp = + * Timestamp.newBuilder().setSeconds(now.getEpochSecond()) + * .setNanos(now.getNano()).build(); + * + * + * Example 6: Compute Timestamp from current time in Python. + * + * timestamp = Timestamp() + * timestamp.GetCurrentTime() + * + * # JSON Mapping + * + * In JSON format, the Timestamp type is encoded as a string in the + * [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the + * format is "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z" + * where {year} is always expressed using four digits while {month}, {day}, + * {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional + * seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution), + * are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone + * is required. A proto3 JSON serializer should always use UTC (as indicated by + * "Z") when printing the Timestamp type and a proto3 JSON parser should be + * able to accept both UTC and other timezones (as indicated by an offset). + * + * For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past + * 01:30 UTC on January 15, 2017. + * + * In JavaScript, one can convert a Date object to this format using the + * standard + * [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString) + * method. In Python, a standard `datetime.datetime` object can be converted + * to this format using + * [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) with + * the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one can use + * the Joda Time's [`ISODateTimeFormat.dateTime()`]( + * http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime%2D%2D + * ) to obtain a formatter capable of generating timestamps in this format. + */ +export interface Timestamp { + /** + * Represents seconds of UTC time since Unix epoch + * 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to + * 9999-12-31T23:59:59Z inclusive. + */ + seconds: number; + /** + * Non-negative fractions of a second at nanosecond resolution. Negative + * second values with fractions must still have non-negative nanos values + * that count forward in time. Must be from 0 to 999,999,999 + * inclusive. + */ + nanos: number; +} + +const baseTimestamp: object = { seconds: 0, nanos: 0 }; + +export const Timestamp = { + encode(message: Timestamp, writer: Writer = Writer.create()): Writer { + if (message.seconds !== 0) { + writer.uint32(8).int64(message.seconds); + } + if (message.nanos !== 0) { + writer.uint32(16).int32(message.nanos); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Timestamp { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseTimestamp } as Timestamp; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.seconds = longToNumber(reader.int64() as Long); + break; + case 2: + message.nanos = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Timestamp { + const message = { ...baseTimestamp } as Timestamp; + if (object.seconds !== undefined && object.seconds !== null) { + message.seconds = Number(object.seconds); + } else { + message.seconds = 0; + } + if (object.nanos !== undefined && object.nanos !== null) { + message.nanos = Number(object.nanos); + } else { + message.nanos = 0; + } + return message; + }, + + toJSON(message: Timestamp): unknown { + const obj: any = {}; + message.seconds !== undefined && (obj.seconds = message.seconds); + message.nanos !== undefined && (obj.nanos = message.nanos); + return obj; + }, + + fromPartial(object: DeepPartial): Timestamp { + const message = { ...baseTimestamp } as Timestamp; + if (object.seconds !== undefined && object.seconds !== null) { + message.seconds = object.seconds; + } else { + message.seconds = 0; + } + if (object.nanos !== undefined && object.nanos !== null) { + message.nanos = object.nanos; + } else { + message.nanos = 0; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/cosmos.feegrant.v1beta1/index.ts b/ts-client/cosmos.feegrant.v1beta1/index.ts new file mode 100755 index 00000000..c9dfa159 --- /dev/null +++ b/ts-client/cosmos.feegrant.v1beta1/index.ts @@ -0,0 +1,6 @@ +import Module from './module'; +import { txClient, queryClient, registry } from './module'; +import { msgTypes } from './registry'; + +export * from "./types"; +export { Module, msgTypes, txClient, queryClient, registry }; diff --git a/ts-client/cosmos.feegrant.v1beta1/module.ts b/ts-client/cosmos.feegrant.v1beta1/module.ts new file mode 100755 index 00000000..bf5caa6d --- /dev/null +++ b/ts-client/cosmos.feegrant.v1beta1/module.ts @@ -0,0 +1,132 @@ +// Generated by Ignite ignite.com/cli + +import { StdFee } from "@cosmjs/launchpad"; +import { SigningStargateClient, DeliverTxResponse } from "@cosmjs/stargate"; +import { EncodeObject, GeneratedType, OfflineSigner, Registry } from "@cosmjs/proto-signing"; +import { msgTypes } from './registry'; +import { IgniteClient } from "../client" +import { MissingWalletError } from "../helpers" +import { Api } from "./rest"; +import { MsgGrantAllowance } from "./types/cosmos/feegrant/v1beta1/tx"; +import { MsgRevokeAllowance } from "./types/cosmos/feegrant/v1beta1/tx"; + + +export { MsgGrantAllowance, MsgRevokeAllowance }; + +type sendMsgGrantAllowanceParams = { + value: MsgGrantAllowance, + fee?: StdFee, + memo?: string +}; + +type sendMsgRevokeAllowanceParams = { + value: MsgRevokeAllowance, + fee?: StdFee, + memo?: string +}; + + +type msgGrantAllowanceParams = { + value: MsgGrantAllowance, +}; + +type msgRevokeAllowanceParams = { + value: MsgRevokeAllowance, +}; + + +export const registry = new Registry(msgTypes); + +const defaultFee = { + amount: [], + gas: "200000", +}; + +interface TxClientOptions { + addr: string + prefix: string + signer?: OfflineSigner +} + +export const txClient = ({ signer, prefix, addr }: TxClientOptions = { addr: "http://localhost:26657", prefix: "cosmos" }) => { + + return { + + async sendMsgGrantAllowance({ value, fee, memo }: sendMsgGrantAllowanceParams): Promise { + if (!signer) { + throw new Error('TxClient:sendMsgGrantAllowance: Unable to sign Tx. Signer is not present.') + } + try { + const { address } = (await signer.getAccounts())[0]; + const signingClient = await SigningStargateClient.connectWithSigner(addr,signer,{registry, prefix}); + let msg = this.msgGrantAllowance({ value: MsgGrantAllowance.fromPartial(value) }) + return await signingClient.signAndBroadcast(address, [msg], fee ? fee : defaultFee, memo) + } catch (e: any) { + throw new Error('TxClient:sendMsgGrantAllowance: Could not broadcast Tx: '+ e.message) + } + }, + + async sendMsgRevokeAllowance({ value, fee, memo }: sendMsgRevokeAllowanceParams): Promise { + if (!signer) { + throw new Error('TxClient:sendMsgRevokeAllowance: Unable to sign Tx. Signer is not present.') + } + try { + const { address } = (await signer.getAccounts())[0]; + const signingClient = await SigningStargateClient.connectWithSigner(addr,signer,{registry, prefix}); + let msg = this.msgRevokeAllowance({ value: MsgRevokeAllowance.fromPartial(value) }) + return await signingClient.signAndBroadcast(address, [msg], fee ? fee : defaultFee, memo) + } catch (e: any) { + throw new Error('TxClient:sendMsgRevokeAllowance: Could not broadcast Tx: '+ e.message) + } + }, + + + msgGrantAllowance({ value }: msgGrantAllowanceParams): EncodeObject { + try { + return { typeUrl: "/cosmos.feegrant.v1beta1.MsgGrantAllowance", value: MsgGrantAllowance.fromPartial( value ) } + } catch (e: any) { + throw new Error('TxClient:MsgGrantAllowance: Could not create message: ' + e.message) + } + }, + + msgRevokeAllowance({ value }: msgRevokeAllowanceParams): EncodeObject { + try { + return { typeUrl: "/cosmos.feegrant.v1beta1.MsgRevokeAllowance", value: MsgRevokeAllowance.fromPartial( value ) } + } catch (e: any) { + throw new Error('TxClient:MsgRevokeAllowance: Could not create message: ' + e.message) + } + }, + + } +}; + +interface QueryClientOptions { + addr: string +} + +export const queryClient = ({ addr: addr }: QueryClientOptions = { addr: "http://localhost:1317" }) => { + return new Api({ baseUrl: addr }); +}; + +class SDKModule { + public query: ReturnType; + public tx: ReturnType; + + public registry: Array<[string, GeneratedType]>; + + constructor(client: IgniteClient) { + + this.query = queryClient({ addr: client.env.apiURL }); + this.tx = txClient({ signer: client.signer, addr: client.env.rpcURL, prefix: client.env.prefix ?? "cosmos" }); + } +}; + +const Module = (test: IgniteClient) => { + return { + module: { + CosmosFeegrantV1Beta1: new SDKModule(test) + }, + registry: msgTypes + } +} +export default Module; \ No newline at end of file diff --git a/ts-client/cosmos.feegrant.v1beta1/registry.ts b/ts-client/cosmos.feegrant.v1beta1/registry.ts new file mode 100755 index 00000000..433cf300 --- /dev/null +++ b/ts-client/cosmos.feegrant.v1beta1/registry.ts @@ -0,0 +1,11 @@ +import { GeneratedType } from "@cosmjs/proto-signing"; +import { MsgGrantAllowance } from "./types/cosmos/feegrant/v1beta1/tx"; +import { MsgRevokeAllowance } from "./types/cosmos/feegrant/v1beta1/tx"; + +const msgTypes: Array<[string, GeneratedType]> = [ + ["/cosmos.feegrant.v1beta1.MsgGrantAllowance", MsgGrantAllowance], + ["/cosmos.feegrant.v1beta1.MsgRevokeAllowance", MsgRevokeAllowance], + +]; + +export { msgTypes } \ No newline at end of file diff --git a/ts-client/cosmos.feegrant.v1beta1/rest.ts b/ts-client/cosmos.feegrant.v1beta1/rest.ts new file mode 100644 index 00000000..c5b377b8 --- /dev/null +++ b/ts-client/cosmos.feegrant.v1beta1/rest.ts @@ -0,0 +1,516 @@ +/* eslint-disable */ +/* tslint:disable */ +/* + * --------------------------------------------------------------- + * ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ## + * ## ## + * ## AUTHOR: acacode ## + * ## SOURCE: https://github.com/acacode/swagger-typescript-api ## + * --------------------------------------------------------------- + */ + +/** +* `Any` contains an arbitrary serialized protocol buffer message along with a +URL that describes the type of the serialized message. + +Protobuf library provides support to pack/unpack Any values in the form +of utility functions or additional generated methods of the Any type. + +Example 1: Pack and unpack a message in C++. + + Foo foo = ...; + Any any; + any.PackFrom(foo); + ... + if (any.UnpackTo(&foo)) { + ... + } + +Example 2: Pack and unpack a message in Java. + + Foo foo = ...; + Any any = Any.pack(foo); + ... + if (any.is(Foo.class)) { + foo = any.unpack(Foo.class); + } + + Example 3: Pack and unpack a message in Python. + + foo = Foo(...) + any = Any() + any.Pack(foo) + ... + if any.Is(Foo.DESCRIPTOR): + any.Unpack(foo) + ... + + Example 4: Pack and unpack a message in Go + + foo := &pb.Foo{...} + any, err := anypb.New(foo) + if err != nil { + ... + } + ... + foo := &pb.Foo{} + if err := any.UnmarshalTo(foo); err != nil { + ... + } + +The pack methods provided by protobuf library will by default use +'type.googleapis.com/full.type.name' as the type URL and the unpack +methods only use the fully qualified type name after the last '/' +in the type URL, for example "foo.bar.com/x/y.z" will yield type +name "y.z". + + +JSON +==== +The JSON representation of an `Any` value uses the regular +representation of the deserialized, embedded message, with an +additional field `@type` which contains the type URL. Example: + + package google.profile; + message Person { + string first_name = 1; + string last_name = 2; + } + + { + "@type": "type.googleapis.com/google.profile.Person", + "firstName": , + "lastName": + } + +If the embedded message type is well-known and has a custom JSON +representation, that representation will be embedded adding a field +`value` which holds the custom JSON in addition to the `@type` +field. Example (for message [google.protobuf.Duration][]): + + { + "@type": "type.googleapis.com/google.protobuf.Duration", + "value": "1.212s" + } +*/ +export interface ProtobufAny { + /** + * A URL/resource name that uniquely identifies the type of the serialized + * protocol buffer message. This string must contain at least + * one "/" character. The last segment of the URL's path must represent + * the fully qualified name of the type (as in + * `path/google.protobuf.Duration`). The name should be in a canonical form + * (e.g., leading "." is not accepted). + * + * In practice, teams usually precompile into the binary all types that they + * expect it to use in the context of Any. However, for URLs which use the + * scheme `http`, `https`, or no scheme, one can optionally set up a type + * server that maps type URLs to message definitions as follows: + * + * * If no scheme is provided, `https` is assumed. + * * An HTTP GET on the URL must yield a [google.protobuf.Type][] + * value in binary format, or produce an error. + * * Applications are allowed to cache lookup results based on the + * URL, or have them precompiled into a binary to avoid any + * lookup. Therefore, binary compatibility needs to be preserved + * on changes to types. (Use versioned type names to manage + * breaking changes.) + * + * Note: this functionality is not currently available in the official + * protobuf release, and it is not used for type URLs beginning with + * type.googleapis.com. + * + * Schemes other than `http`, `https` (or the empty scheme) might be + * used with implementation specific semantics. + */ + "@type"?: string; +} + +export interface RpcStatus { + /** @format int32 */ + code?: number; + message?: string; + details?: ProtobufAny[]; +} + +export interface V1Beta1Grant { + /** granter is the address of the user granting an allowance of their funds. */ + granter?: string; + + /** grantee is the address of the user being granted an allowance of another user's funds. */ + grantee?: string; + + /** allowance can be any of basic and filtered fee allowance. */ + allowance?: ProtobufAny; +} + +/** + * MsgGrantAllowanceResponse defines the Msg/GrantAllowanceResponse response type. + */ +export type V1Beta1MsgGrantAllowanceResponse = object; + +/** + * MsgRevokeAllowanceResponse defines the Msg/RevokeAllowanceResponse response type. + */ +export type V1Beta1MsgRevokeAllowanceResponse = object; + +/** +* message SomeRequest { + Foo some_parameter = 1; + PageRequest pagination = 2; + } +*/ +export interface V1Beta1PageRequest { + /** + * key is a value returned in PageResponse.next_key to begin + * querying the next page most efficiently. Only one of offset or key + * should be set. + * @format byte + */ + key?: string; + + /** + * offset is a numeric offset that can be used when key is unavailable. + * It is less efficient than using key. Only one of offset or key should + * be set. + * @format uint64 + */ + offset?: string; + + /** + * limit is the total number of results to be returned in the result page. + * If left empty it will default to a value to be set by each app. + * @format uint64 + */ + limit?: string; + + /** + * count_total is set to true to indicate that the result set should include + * a count of the total number of items available for pagination in UIs. + * count_total is only respected when offset is used. It is ignored when key + * is set. + */ + count_total?: boolean; + + /** + * reverse is set to true if results are to be returned in the descending order. + * + * Since: cosmos-sdk 0.43 + */ + reverse?: boolean; +} + +/** +* PageResponse is to be embedded in gRPC response messages where the +corresponding request message has used PageRequest. + + message SomeResponse { + repeated Bar results = 1; + PageResponse page = 2; + } +*/ +export interface V1Beta1PageResponse { + /** @format byte */ + next_key?: string; + + /** @format uint64 */ + total?: string; +} + +/** + * QueryAllowanceResponse is the response type for the Query/Allowance RPC method. + */ +export interface V1Beta1QueryAllowanceResponse { + /** allowance is a allowance granted for grantee by granter. */ + allowance?: V1Beta1Grant; +} + +/** + * QueryAllowancesByGranterResponse is the response type for the Query/AllowancesByGranter RPC method. + */ +export interface V1Beta1QueryAllowancesByGranterResponse { + /** allowances that have been issued by the granter. */ + allowances?: V1Beta1Grant[]; + + /** pagination defines an pagination for the response. */ + pagination?: V1Beta1PageResponse; +} + +/** + * QueryAllowancesResponse is the response type for the Query/Allowances RPC method. + */ +export interface V1Beta1QueryAllowancesResponse { + /** allowances are allowance's granted for grantee by granter. */ + allowances?: V1Beta1Grant[]; + + /** pagination defines an pagination for the response. */ + pagination?: V1Beta1PageResponse; +} + +export type QueryParamsType = Record; +export type ResponseFormat = keyof Omit; + +export interface FullRequestParams extends Omit { + /** set parameter to `true` for call `securityWorker` for this request */ + secure?: boolean; + /** request path */ + path: string; + /** content type of request body */ + type?: ContentType; + /** query params */ + query?: QueryParamsType; + /** format of response (i.e. response.json() -> format: "json") */ + format?: keyof Omit; + /** request body */ + body?: unknown; + /** base url */ + baseUrl?: string; + /** request cancellation token */ + cancelToken?: CancelToken; +} + +export type RequestParams = Omit; + +export interface ApiConfig { + baseUrl?: string; + baseApiParams?: Omit; + securityWorker?: (securityData: SecurityDataType) => RequestParams | void; +} + +export interface HttpResponse extends Response { + data: D; + error: E; +} + +type CancelToken = Symbol | string | number; + +export enum ContentType { + Json = "application/json", + FormData = "multipart/form-data", + UrlEncoded = "application/x-www-form-urlencoded", +} + +export class HttpClient { + public baseUrl: string = ""; + private securityData: SecurityDataType = null as any; + private securityWorker: null | ApiConfig["securityWorker"] = null; + private abortControllers = new Map(); + + private baseApiParams: RequestParams = { + credentials: "same-origin", + headers: {}, + redirect: "follow", + referrerPolicy: "no-referrer", + }; + + constructor(apiConfig: ApiConfig = {}) { + Object.assign(this, apiConfig); + } + + public setSecurityData = (data: SecurityDataType) => { + this.securityData = data; + }; + + private addQueryParam(query: QueryParamsType, key: string) { + const value = query[key]; + + return ( + encodeURIComponent(key) + + "=" + + encodeURIComponent(Array.isArray(value) ? value.join(",") : typeof value === "number" ? value : `${value}`) + ); + } + + protected toQueryString(rawQuery?: QueryParamsType): string { + const query = rawQuery || {}; + const keys = Object.keys(query).filter((key) => "undefined" !== typeof query[key]); + return keys + .map((key) => + typeof query[key] === "object" && !Array.isArray(query[key]) + ? this.toQueryString(query[key] as QueryParamsType) + : this.addQueryParam(query, key), + ) + .join("&"); + } + + protected addQueryParams(rawQuery?: QueryParamsType): string { + const queryString = this.toQueryString(rawQuery); + return queryString ? `?${queryString}` : ""; + } + + private contentFormatters: Record any> = { + [ContentType.Json]: (input: any) => + input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input, + [ContentType.FormData]: (input: any) => + Object.keys(input || {}).reduce((data, key) => { + data.append(key, input[key]); + return data; + }, new FormData()), + [ContentType.UrlEncoded]: (input: any) => this.toQueryString(input), + }; + + private mergeRequestParams(params1: RequestParams, params2?: RequestParams): RequestParams { + return { + ...this.baseApiParams, + ...params1, + ...(params2 || {}), + headers: { + ...(this.baseApiParams.headers || {}), + ...(params1.headers || {}), + ...((params2 && params2.headers) || {}), + }, + }; + } + + private createAbortSignal = (cancelToken: CancelToken): AbortSignal | undefined => { + if (this.abortControllers.has(cancelToken)) { + const abortController = this.abortControllers.get(cancelToken); + if (abortController) { + return abortController.signal; + } + return void 0; + } + + const abortController = new AbortController(); + this.abortControllers.set(cancelToken, abortController); + return abortController.signal; + }; + + public abortRequest = (cancelToken: CancelToken) => { + const abortController = this.abortControllers.get(cancelToken); + + if (abortController) { + abortController.abort(); + this.abortControllers.delete(cancelToken); + } + }; + + public request = ({ + body, + secure, + path, + type, + query, + format = "json", + baseUrl, + cancelToken, + ...params + }: FullRequestParams): Promise> => { + const secureParams = (secure && this.securityWorker && this.securityWorker(this.securityData)) || {}; + const requestParams = this.mergeRequestParams(params, secureParams); + const queryString = query && this.toQueryString(query); + const payloadFormatter = this.contentFormatters[type || ContentType.Json]; + + return fetch(`${baseUrl || this.baseUrl || ""}${path}${queryString ? `?${queryString}` : ""}`, { + ...requestParams, + headers: { + ...(type && type !== ContentType.FormData ? { "Content-Type": type } : {}), + ...(requestParams.headers || {}), + }, + signal: cancelToken ? this.createAbortSignal(cancelToken) : void 0, + body: typeof body === "undefined" || body === null ? null : payloadFormatter(body), + }).then(async (response) => { + const r = response as HttpResponse; + r.data = (null as unknown) as T; + r.error = (null as unknown) as E; + + const data = await response[format]() + .then((data) => { + if (r.ok) { + r.data = data; + } else { + r.error = data; + } + return r; + }) + .catch((e) => { + r.error = e; + return r; + }); + + if (cancelToken) { + this.abortControllers.delete(cancelToken); + } + + if (!response.ok) throw data; + return data; + }); + }; +} + +/** + * @title cosmos/feegrant/v1beta1/feegrant.proto + * @version version not set + */ +export class Api extends HttpClient { + /** + * No description + * + * @tags Query + * @name QueryAllowance + * @summary Allowance returns fee granted to the grantee by the granter. + * @request GET:/cosmos/feegrant/v1beta1/allowance/{granter}/{grantee} + */ + queryAllowance = (granter: string, grantee: string, params: RequestParams = {}) => + this.request({ + path: `/cosmos/feegrant/v1beta1/allowance/${granter}/${grantee}`, + method: "GET", + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Query + * @name QueryAllowances + * @summary Allowances returns all the grants for address. + * @request GET:/cosmos/feegrant/v1beta1/allowances/{grantee} + */ + queryAllowances = ( + grantee: string, + query?: { + "pagination.key"?: string; + "pagination.offset"?: string; + "pagination.limit"?: string; + "pagination.count_total"?: boolean; + "pagination.reverse"?: boolean; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/cosmos/feegrant/v1beta1/allowances/${grantee}`, + method: "GET", + query: query, + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Query + * @name QueryAllowancesByGranter + * @summary AllowancesByGranter returns all the grants given by an address +Since v0.46 + * @request GET:/cosmos/feegrant/v1beta1/issued/{granter} + */ + queryAllowancesByGranter = ( + granter: string, + query?: { + "pagination.key"?: string; + "pagination.offset"?: string; + "pagination.limit"?: string; + "pagination.count_total"?: boolean; + "pagination.reverse"?: boolean; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/cosmos/feegrant/v1beta1/issued/${granter}`, + method: "GET", + query: query, + format: "json", + ...params, + }); +} diff --git a/ts-client/cosmos.feegrant.v1beta1/types.ts b/ts-client/cosmos.feegrant.v1beta1/types.ts new file mode 100755 index 00000000..56cd3612 --- /dev/null +++ b/ts-client/cosmos.feegrant.v1beta1/types.ts @@ -0,0 +1,13 @@ +import { BasicAllowance } from "./types/cosmos/feegrant/v1beta1/feegrant" +import { PeriodicAllowance } from "./types/cosmos/feegrant/v1beta1/feegrant" +import { AllowedMsgAllowance } from "./types/cosmos/feegrant/v1beta1/feegrant" +import { Grant } from "./types/cosmos/feegrant/v1beta1/feegrant" + + +export { + BasicAllowance, + PeriodicAllowance, + AllowedMsgAllowance, + Grant, + + } \ No newline at end of file diff --git a/ts-client/cosmos.feegrant.v1beta1/types/cosmos/base/query/v1beta1/pagination.ts b/ts-client/cosmos.feegrant.v1beta1/types/cosmos/base/query/v1beta1/pagination.ts new file mode 100644 index 00000000..cd4b2d78 --- /dev/null +++ b/ts-client/cosmos.feegrant.v1beta1/types/cosmos/base/query/v1beta1/pagination.ts @@ -0,0 +1,327 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "cosmos.base.query.v1beta1"; + +/** + * PageRequest is to be embedded in gRPC request messages for efficient + * pagination. Ex: + * + * message SomeRequest { + * Foo some_parameter = 1; + * PageRequest pagination = 2; + * } + */ +export interface PageRequest { + /** + * key is a value returned in PageResponse.next_key to begin + * querying the next page most efficiently. Only one of offset or key + * should be set. + */ + key: Uint8Array; + /** + * offset is a numeric offset that can be used when key is unavailable. + * It is less efficient than using key. Only one of offset or key should + * be set. + */ + offset: number; + /** + * limit is the total number of results to be returned in the result page. + * If left empty it will default to a value to be set by each app. + */ + limit: number; + /** + * count_total is set to true to indicate that the result set should include + * a count of the total number of items available for pagination in UIs. + * count_total is only respected when offset is used. It is ignored when key + * is set. + */ + countTotal: boolean; + /** + * reverse is set to true if results are to be returned in the descending order. + * + * Since: cosmos-sdk 0.43 + */ + reverse: boolean; +} + +/** + * PageResponse is to be embedded in gRPC response messages where the + * corresponding request message has used PageRequest. + * + * message SomeResponse { + * repeated Bar results = 1; + * PageResponse page = 2; + * } + */ +export interface PageResponse { + /** + * next_key is the key to be passed to PageRequest.key to + * query the next page most efficiently + */ + nextKey: Uint8Array; + /** + * total is total number of results available if PageRequest.count_total + * was set, its value is undefined otherwise + */ + total: number; +} + +const basePageRequest: object = { + offset: 0, + limit: 0, + countTotal: false, + reverse: false, +}; + +export const PageRequest = { + encode(message: PageRequest, writer: Writer = Writer.create()): Writer { + if (message.key.length !== 0) { + writer.uint32(10).bytes(message.key); + } + if (message.offset !== 0) { + writer.uint32(16).uint64(message.offset); + } + if (message.limit !== 0) { + writer.uint32(24).uint64(message.limit); + } + if (message.countTotal === true) { + writer.uint32(32).bool(message.countTotal); + } + if (message.reverse === true) { + writer.uint32(40).bool(message.reverse); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): PageRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...basePageRequest } as PageRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.key = reader.bytes(); + break; + case 2: + message.offset = longToNumber(reader.uint64() as Long); + break; + case 3: + message.limit = longToNumber(reader.uint64() as Long); + break; + case 4: + message.countTotal = reader.bool(); + break; + case 5: + message.reverse = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): PageRequest { + const message = { ...basePageRequest } as PageRequest; + if (object.key !== undefined && object.key !== null) { + message.key = bytesFromBase64(object.key); + } + if (object.offset !== undefined && object.offset !== null) { + message.offset = Number(object.offset); + } else { + message.offset = 0; + } + if (object.limit !== undefined && object.limit !== null) { + message.limit = Number(object.limit); + } else { + message.limit = 0; + } + if (object.countTotal !== undefined && object.countTotal !== null) { + message.countTotal = Boolean(object.countTotal); + } else { + message.countTotal = false; + } + if (object.reverse !== undefined && object.reverse !== null) { + message.reverse = Boolean(object.reverse); + } else { + message.reverse = false; + } + return message; + }, + + toJSON(message: PageRequest): unknown { + const obj: any = {}; + message.key !== undefined && + (obj.key = base64FromBytes( + message.key !== undefined ? message.key : new Uint8Array() + )); + message.offset !== undefined && (obj.offset = message.offset); + message.limit !== undefined && (obj.limit = message.limit); + message.countTotal !== undefined && (obj.countTotal = message.countTotal); + message.reverse !== undefined && (obj.reverse = message.reverse); + return obj; + }, + + fromPartial(object: DeepPartial): PageRequest { + const message = { ...basePageRequest } as PageRequest; + if (object.key !== undefined && object.key !== null) { + message.key = object.key; + } else { + message.key = new Uint8Array(); + } + if (object.offset !== undefined && object.offset !== null) { + message.offset = object.offset; + } else { + message.offset = 0; + } + if (object.limit !== undefined && object.limit !== null) { + message.limit = object.limit; + } else { + message.limit = 0; + } + if (object.countTotal !== undefined && object.countTotal !== null) { + message.countTotal = object.countTotal; + } else { + message.countTotal = false; + } + if (object.reverse !== undefined && object.reverse !== null) { + message.reverse = object.reverse; + } else { + message.reverse = false; + } + return message; + }, +}; + +const basePageResponse: object = { total: 0 }; + +export const PageResponse = { + encode(message: PageResponse, writer: Writer = Writer.create()): Writer { + if (message.nextKey.length !== 0) { + writer.uint32(10).bytes(message.nextKey); + } + if (message.total !== 0) { + writer.uint32(16).uint64(message.total); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): PageResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...basePageResponse } as PageResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.nextKey = reader.bytes(); + break; + case 2: + message.total = longToNumber(reader.uint64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): PageResponse { + const message = { ...basePageResponse } as PageResponse; + if (object.nextKey !== undefined && object.nextKey !== null) { + message.nextKey = bytesFromBase64(object.nextKey); + } + if (object.total !== undefined && object.total !== null) { + message.total = Number(object.total); + } else { + message.total = 0; + } + return message; + }, + + toJSON(message: PageResponse): unknown { + const obj: any = {}; + message.nextKey !== undefined && + (obj.nextKey = base64FromBytes( + message.nextKey !== undefined ? message.nextKey : new Uint8Array() + )); + message.total !== undefined && (obj.total = message.total); + return obj; + }, + + fromPartial(object: DeepPartial): PageResponse { + const message = { ...basePageResponse } as PageResponse; + if (object.nextKey !== undefined && object.nextKey !== null) { + message.nextKey = object.nextKey; + } else { + message.nextKey = new Uint8Array(); + } + if (object.total !== undefined && object.total !== null) { + message.total = object.total; + } else { + message.total = 0; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/cosmos.feegrant.v1beta1/types/cosmos/base/v1beta1/coin.ts b/ts-client/cosmos.feegrant.v1beta1/types/cosmos/base/v1beta1/coin.ts new file mode 100644 index 00000000..ce2ac984 --- /dev/null +++ b/ts-client/cosmos.feegrant.v1beta1/types/cosmos/base/v1beta1/coin.ts @@ -0,0 +1,301 @@ +/* eslint-disable */ +import { Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "cosmos.base.v1beta1"; + +/** + * Coin defines a token with a denomination and an amount. + * + * NOTE: The amount field is an Int which implements the custom method + * signatures required by gogoproto. + */ +export interface Coin { + denom: string; + amount: string; +} + +/** + * DecCoin defines a token with a denomination and a decimal amount. + * + * NOTE: The amount field is an Dec which implements the custom method + * signatures required by gogoproto. + */ +export interface DecCoin { + denom: string; + amount: string; +} + +/** IntProto defines a Protobuf wrapper around an Int object. */ +export interface IntProto { + int: string; +} + +/** DecProto defines a Protobuf wrapper around a Dec object. */ +export interface DecProto { + dec: string; +} + +const baseCoin: object = { denom: "", amount: "" }; + +export const Coin = { + encode(message: Coin, writer: Writer = Writer.create()): Writer { + if (message.denom !== "") { + writer.uint32(10).string(message.denom); + } + if (message.amount !== "") { + writer.uint32(18).string(message.amount); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Coin { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseCoin } as Coin; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.denom = reader.string(); + break; + case 2: + message.amount = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Coin { + const message = { ...baseCoin } as Coin; + if (object.denom !== undefined && object.denom !== null) { + message.denom = String(object.denom); + } else { + message.denom = ""; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = String(object.amount); + } else { + message.amount = ""; + } + return message; + }, + + toJSON(message: Coin): unknown { + const obj: any = {}; + message.denom !== undefined && (obj.denom = message.denom); + message.amount !== undefined && (obj.amount = message.amount); + return obj; + }, + + fromPartial(object: DeepPartial): Coin { + const message = { ...baseCoin } as Coin; + if (object.denom !== undefined && object.denom !== null) { + message.denom = object.denom; + } else { + message.denom = ""; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = object.amount; + } else { + message.amount = ""; + } + return message; + }, +}; + +const baseDecCoin: object = { denom: "", amount: "" }; + +export const DecCoin = { + encode(message: DecCoin, writer: Writer = Writer.create()): Writer { + if (message.denom !== "") { + writer.uint32(10).string(message.denom); + } + if (message.amount !== "") { + writer.uint32(18).string(message.amount); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): DecCoin { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseDecCoin } as DecCoin; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.denom = reader.string(); + break; + case 2: + message.amount = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DecCoin { + const message = { ...baseDecCoin } as DecCoin; + if (object.denom !== undefined && object.denom !== null) { + message.denom = String(object.denom); + } else { + message.denom = ""; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = String(object.amount); + } else { + message.amount = ""; + } + return message; + }, + + toJSON(message: DecCoin): unknown { + const obj: any = {}; + message.denom !== undefined && (obj.denom = message.denom); + message.amount !== undefined && (obj.amount = message.amount); + return obj; + }, + + fromPartial(object: DeepPartial): DecCoin { + const message = { ...baseDecCoin } as DecCoin; + if (object.denom !== undefined && object.denom !== null) { + message.denom = object.denom; + } else { + message.denom = ""; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = object.amount; + } else { + message.amount = ""; + } + return message; + }, +}; + +const baseIntProto: object = { int: "" }; + +export const IntProto = { + encode(message: IntProto, writer: Writer = Writer.create()): Writer { + if (message.int !== "") { + writer.uint32(10).string(message.int); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): IntProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseIntProto } as IntProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.int = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): IntProto { + const message = { ...baseIntProto } as IntProto; + if (object.int !== undefined && object.int !== null) { + message.int = String(object.int); + } else { + message.int = ""; + } + return message; + }, + + toJSON(message: IntProto): unknown { + const obj: any = {}; + message.int !== undefined && (obj.int = message.int); + return obj; + }, + + fromPartial(object: DeepPartial): IntProto { + const message = { ...baseIntProto } as IntProto; + if (object.int !== undefined && object.int !== null) { + message.int = object.int; + } else { + message.int = ""; + } + return message; + }, +}; + +const baseDecProto: object = { dec: "" }; + +export const DecProto = { + encode(message: DecProto, writer: Writer = Writer.create()): Writer { + if (message.dec !== "") { + writer.uint32(10).string(message.dec); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): DecProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseDecProto } as DecProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.dec = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DecProto { + const message = { ...baseDecProto } as DecProto; + if (object.dec !== undefined && object.dec !== null) { + message.dec = String(object.dec); + } else { + message.dec = ""; + } + return message; + }, + + toJSON(message: DecProto): unknown { + const obj: any = {}; + message.dec !== undefined && (obj.dec = message.dec); + return obj; + }, + + fromPartial(object: DeepPartial): DecProto { + const message = { ...baseDecProto } as DecProto; + if (object.dec !== undefined && object.dec !== null) { + message.dec = object.dec; + } else { + message.dec = ""; + } + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/cosmos.feegrant.v1beta1/types/cosmos/feegrant/v1beta1/feegrant.ts b/ts-client/cosmos.feegrant.v1beta1/types/cosmos/feegrant/v1beta1/feegrant.ts new file mode 100644 index 00000000..adeeeb6b --- /dev/null +++ b/ts-client/cosmos.feegrant.v1beta1/types/cosmos/feegrant/v1beta1/feegrant.ts @@ -0,0 +1,538 @@ +/* eslint-disable */ +import { Timestamp } from "../../../google/protobuf/timestamp"; +import { Coin } from "../../../cosmos/base/v1beta1/coin"; +import { Duration } from "../../../google/protobuf/duration"; +import { Any } from "../../../google/protobuf/any"; +import { Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "cosmos.feegrant.v1beta1"; + +/** Since: cosmos-sdk 0.43 */ + +/** + * BasicAllowance implements Allowance with a one-time grant of tokens + * that optionally expires. The grantee can use up to SpendLimit to cover fees. + */ +export interface BasicAllowance { + /** + * spend_limit specifies the maximum amount of tokens that can be spent + * by this allowance and will be updated as tokens are spent. If it is + * empty, there is no spend limit and any amount of coins can be spent. + */ + spendLimit: Coin[]; + /** expiration specifies an optional time when this allowance expires */ + expiration: Date | undefined; +} + +/** + * PeriodicAllowance extends Allowance to allow for both a maximum cap, + * as well as a limit per time period. + */ +export interface PeriodicAllowance { + /** basic specifies a struct of `BasicAllowance` */ + basic: BasicAllowance | undefined; + /** + * period specifies the time duration in which period_spend_limit coins can + * be spent before that allowance is reset + */ + period: Duration | undefined; + /** + * period_spend_limit specifies the maximum number of coins that can be spent + * in the period + */ + periodSpendLimit: Coin[]; + /** period_can_spend is the number of coins left to be spent before the period_reset time */ + periodCanSpend: Coin[]; + /** + * period_reset is the time at which this period resets and a new one begins, + * it is calculated from the start time of the first transaction after the + * last period ended + */ + periodReset: Date | undefined; +} + +/** AllowedMsgAllowance creates allowance only for specified message types. */ +export interface AllowedMsgAllowance { + /** allowance can be any of basic and filtered fee allowance. */ + allowance: Any | undefined; + /** allowed_messages are the messages for which the grantee has the access. */ + allowedMessages: string[]; +} + +/** Grant is stored in the KVStore to record a grant with full context */ +export interface Grant { + /** granter is the address of the user granting an allowance of their funds. */ + granter: string; + /** grantee is the address of the user being granted an allowance of another user's funds. */ + grantee: string; + /** allowance can be any of basic and filtered fee allowance. */ + allowance: Any | undefined; +} + +const baseBasicAllowance: object = {}; + +export const BasicAllowance = { + encode(message: BasicAllowance, writer: Writer = Writer.create()): Writer { + for (const v of message.spendLimit) { + Coin.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.expiration !== undefined) { + Timestamp.encode( + toTimestamp(message.expiration), + writer.uint32(18).fork() + ).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): BasicAllowance { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseBasicAllowance } as BasicAllowance; + message.spendLimit = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.spendLimit.push(Coin.decode(reader, reader.uint32())); + break; + case 2: + message.expiration = fromTimestamp( + Timestamp.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): BasicAllowance { + const message = { ...baseBasicAllowance } as BasicAllowance; + message.spendLimit = []; + if (object.spendLimit !== undefined && object.spendLimit !== null) { + for (const e of object.spendLimit) { + message.spendLimit.push(Coin.fromJSON(e)); + } + } + if (object.expiration !== undefined && object.expiration !== null) { + message.expiration = fromJsonTimestamp(object.expiration); + } else { + message.expiration = undefined; + } + return message; + }, + + toJSON(message: BasicAllowance): unknown { + const obj: any = {}; + if (message.spendLimit) { + obj.spendLimit = message.spendLimit.map((e) => + e ? Coin.toJSON(e) : undefined + ); + } else { + obj.spendLimit = []; + } + message.expiration !== undefined && + (obj.expiration = + message.expiration !== undefined + ? message.expiration.toISOString() + : null); + return obj; + }, + + fromPartial(object: DeepPartial): BasicAllowance { + const message = { ...baseBasicAllowance } as BasicAllowance; + message.spendLimit = []; + if (object.spendLimit !== undefined && object.spendLimit !== null) { + for (const e of object.spendLimit) { + message.spendLimit.push(Coin.fromPartial(e)); + } + } + if (object.expiration !== undefined && object.expiration !== null) { + message.expiration = object.expiration; + } else { + message.expiration = undefined; + } + return message; + }, +}; + +const basePeriodicAllowance: object = {}; + +export const PeriodicAllowance = { + encode(message: PeriodicAllowance, writer: Writer = Writer.create()): Writer { + if (message.basic !== undefined) { + BasicAllowance.encode(message.basic, writer.uint32(10).fork()).ldelim(); + } + if (message.period !== undefined) { + Duration.encode(message.period, writer.uint32(18).fork()).ldelim(); + } + for (const v of message.periodSpendLimit) { + Coin.encode(v!, writer.uint32(26).fork()).ldelim(); + } + for (const v of message.periodCanSpend) { + Coin.encode(v!, writer.uint32(34).fork()).ldelim(); + } + if (message.periodReset !== undefined) { + Timestamp.encode( + toTimestamp(message.periodReset), + writer.uint32(42).fork() + ).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): PeriodicAllowance { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...basePeriodicAllowance } as PeriodicAllowance; + message.periodSpendLimit = []; + message.periodCanSpend = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.basic = BasicAllowance.decode(reader, reader.uint32()); + break; + case 2: + message.period = Duration.decode(reader, reader.uint32()); + break; + case 3: + message.periodSpendLimit.push(Coin.decode(reader, reader.uint32())); + break; + case 4: + message.periodCanSpend.push(Coin.decode(reader, reader.uint32())); + break; + case 5: + message.periodReset = fromTimestamp( + Timestamp.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): PeriodicAllowance { + const message = { ...basePeriodicAllowance } as PeriodicAllowance; + message.periodSpendLimit = []; + message.periodCanSpend = []; + if (object.basic !== undefined && object.basic !== null) { + message.basic = BasicAllowance.fromJSON(object.basic); + } else { + message.basic = undefined; + } + if (object.period !== undefined && object.period !== null) { + message.period = Duration.fromJSON(object.period); + } else { + message.period = undefined; + } + if ( + object.periodSpendLimit !== undefined && + object.periodSpendLimit !== null + ) { + for (const e of object.periodSpendLimit) { + message.periodSpendLimit.push(Coin.fromJSON(e)); + } + } + if (object.periodCanSpend !== undefined && object.periodCanSpend !== null) { + for (const e of object.periodCanSpend) { + message.periodCanSpend.push(Coin.fromJSON(e)); + } + } + if (object.periodReset !== undefined && object.periodReset !== null) { + message.periodReset = fromJsonTimestamp(object.periodReset); + } else { + message.periodReset = undefined; + } + return message; + }, + + toJSON(message: PeriodicAllowance): unknown { + const obj: any = {}; + message.basic !== undefined && + (obj.basic = message.basic + ? BasicAllowance.toJSON(message.basic) + : undefined); + message.period !== undefined && + (obj.period = message.period + ? Duration.toJSON(message.period) + : undefined); + if (message.periodSpendLimit) { + obj.periodSpendLimit = message.periodSpendLimit.map((e) => + e ? Coin.toJSON(e) : undefined + ); + } else { + obj.periodSpendLimit = []; + } + if (message.periodCanSpend) { + obj.periodCanSpend = message.periodCanSpend.map((e) => + e ? Coin.toJSON(e) : undefined + ); + } else { + obj.periodCanSpend = []; + } + message.periodReset !== undefined && + (obj.periodReset = + message.periodReset !== undefined + ? message.periodReset.toISOString() + : null); + return obj; + }, + + fromPartial(object: DeepPartial): PeriodicAllowance { + const message = { ...basePeriodicAllowance } as PeriodicAllowance; + message.periodSpendLimit = []; + message.periodCanSpend = []; + if (object.basic !== undefined && object.basic !== null) { + message.basic = BasicAllowance.fromPartial(object.basic); + } else { + message.basic = undefined; + } + if (object.period !== undefined && object.period !== null) { + message.period = Duration.fromPartial(object.period); + } else { + message.period = undefined; + } + if ( + object.periodSpendLimit !== undefined && + object.periodSpendLimit !== null + ) { + for (const e of object.periodSpendLimit) { + message.periodSpendLimit.push(Coin.fromPartial(e)); + } + } + if (object.periodCanSpend !== undefined && object.periodCanSpend !== null) { + for (const e of object.periodCanSpend) { + message.periodCanSpend.push(Coin.fromPartial(e)); + } + } + if (object.periodReset !== undefined && object.periodReset !== null) { + message.periodReset = object.periodReset; + } else { + message.periodReset = undefined; + } + return message; + }, +}; + +const baseAllowedMsgAllowance: object = { allowedMessages: "" }; + +export const AllowedMsgAllowance = { + encode( + message: AllowedMsgAllowance, + writer: Writer = Writer.create() + ): Writer { + if (message.allowance !== undefined) { + Any.encode(message.allowance, writer.uint32(10).fork()).ldelim(); + } + for (const v of message.allowedMessages) { + writer.uint32(18).string(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): AllowedMsgAllowance { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseAllowedMsgAllowance } as AllowedMsgAllowance; + message.allowedMessages = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.allowance = Any.decode(reader, reader.uint32()); + break; + case 2: + message.allowedMessages.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): AllowedMsgAllowance { + const message = { ...baseAllowedMsgAllowance } as AllowedMsgAllowance; + message.allowedMessages = []; + if (object.allowance !== undefined && object.allowance !== null) { + message.allowance = Any.fromJSON(object.allowance); + } else { + message.allowance = undefined; + } + if ( + object.allowedMessages !== undefined && + object.allowedMessages !== null + ) { + for (const e of object.allowedMessages) { + message.allowedMessages.push(String(e)); + } + } + return message; + }, + + toJSON(message: AllowedMsgAllowance): unknown { + const obj: any = {}; + message.allowance !== undefined && + (obj.allowance = message.allowance + ? Any.toJSON(message.allowance) + : undefined); + if (message.allowedMessages) { + obj.allowedMessages = message.allowedMessages.map((e) => e); + } else { + obj.allowedMessages = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): AllowedMsgAllowance { + const message = { ...baseAllowedMsgAllowance } as AllowedMsgAllowance; + message.allowedMessages = []; + if (object.allowance !== undefined && object.allowance !== null) { + message.allowance = Any.fromPartial(object.allowance); + } else { + message.allowance = undefined; + } + if ( + object.allowedMessages !== undefined && + object.allowedMessages !== null + ) { + for (const e of object.allowedMessages) { + message.allowedMessages.push(e); + } + } + return message; + }, +}; + +const baseGrant: object = { granter: "", grantee: "" }; + +export const Grant = { + encode(message: Grant, writer: Writer = Writer.create()): Writer { + if (message.granter !== "") { + writer.uint32(10).string(message.granter); + } + if (message.grantee !== "") { + writer.uint32(18).string(message.grantee); + } + if (message.allowance !== undefined) { + Any.encode(message.allowance, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Grant { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseGrant } as Grant; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.granter = reader.string(); + break; + case 2: + message.grantee = reader.string(); + break; + case 3: + message.allowance = Any.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Grant { + const message = { ...baseGrant } as Grant; + if (object.granter !== undefined && object.granter !== null) { + message.granter = String(object.granter); + } else { + message.granter = ""; + } + if (object.grantee !== undefined && object.grantee !== null) { + message.grantee = String(object.grantee); + } else { + message.grantee = ""; + } + if (object.allowance !== undefined && object.allowance !== null) { + message.allowance = Any.fromJSON(object.allowance); + } else { + message.allowance = undefined; + } + return message; + }, + + toJSON(message: Grant): unknown { + const obj: any = {}; + message.granter !== undefined && (obj.granter = message.granter); + message.grantee !== undefined && (obj.grantee = message.grantee); + message.allowance !== undefined && + (obj.allowance = message.allowance + ? Any.toJSON(message.allowance) + : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): Grant { + const message = { ...baseGrant } as Grant; + if (object.granter !== undefined && object.granter !== null) { + message.granter = object.granter; + } else { + message.granter = ""; + } + if (object.grantee !== undefined && object.grantee !== null) { + message.grantee = object.grantee; + } else { + message.grantee = ""; + } + if (object.allowance !== undefined && object.allowance !== null) { + message.allowance = Any.fromPartial(object.allowance); + } else { + message.allowance = undefined; + } + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function toTimestamp(date: Date): Timestamp { + const seconds = date.getTime() / 1_000; + const nanos = (date.getTime() % 1_000) * 1_000_000; + return { seconds, nanos }; +} + +function fromTimestamp(t: Timestamp): Date { + let millis = t.seconds * 1_000; + millis += t.nanos / 1_000_000; + return new Date(millis); +} + +function fromJsonTimestamp(o: any): Date { + if (o instanceof Date) { + return o; + } else if (typeof o === "string") { + return new Date(o); + } else { + return fromTimestamp(Timestamp.fromJSON(o)); + } +} diff --git a/ts-client/cosmos.feegrant.v1beta1/types/cosmos/feegrant/v1beta1/genesis.ts b/ts-client/cosmos.feegrant.v1beta1/types/cosmos/feegrant/v1beta1/genesis.ts new file mode 100644 index 00000000..3b9371b8 --- /dev/null +++ b/ts-client/cosmos.feegrant.v1beta1/types/cosmos/feegrant/v1beta1/genesis.ts @@ -0,0 +1,87 @@ +/* eslint-disable */ +import { Grant } from "../../../cosmos/feegrant/v1beta1/feegrant"; +import { Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "cosmos.feegrant.v1beta1"; + +/** Since: cosmos-sdk 0.43 */ + +/** GenesisState contains a set of fee allowances, persisted from the store */ +export interface GenesisState { + allowances: Grant[]; +} + +const baseGenesisState: object = {}; + +export const GenesisState = { + encode(message: GenesisState, writer: Writer = Writer.create()): Writer { + for (const v of message.allowances) { + Grant.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): GenesisState { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseGenesisState } as GenesisState; + message.allowances = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.allowances.push(Grant.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GenesisState { + const message = { ...baseGenesisState } as GenesisState; + message.allowances = []; + if (object.allowances !== undefined && object.allowances !== null) { + for (const e of object.allowances) { + message.allowances.push(Grant.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: GenesisState): unknown { + const obj: any = {}; + if (message.allowances) { + obj.allowances = message.allowances.map((e) => + e ? Grant.toJSON(e) : undefined + ); + } else { + obj.allowances = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): GenesisState { + const message = { ...baseGenesisState } as GenesisState; + message.allowances = []; + if (object.allowances !== undefined && object.allowances !== null) { + for (const e of object.allowances) { + message.allowances.push(Grant.fromPartial(e)); + } + } + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/cosmos.feegrant.v1beta1/types/cosmos/feegrant/v1beta1/query.ts b/ts-client/cosmos.feegrant.v1beta1/types/cosmos/feegrant/v1beta1/query.ts new file mode 100644 index 00000000..376d5ab5 --- /dev/null +++ b/ts-client/cosmos.feegrant.v1beta1/types/cosmos/feegrant/v1beta1/query.ts @@ -0,0 +1,643 @@ +/* eslint-disable */ +import { Reader, Writer } from "protobufjs/minimal"; +import { Grant } from "../../../cosmos/feegrant/v1beta1/feegrant"; +import { + PageRequest, + PageResponse, +} from "../../../cosmos/base/query/v1beta1/pagination"; + +export const protobufPackage = "cosmos.feegrant.v1beta1"; + +/** Since: cosmos-sdk 0.43 */ + +/** QueryAllowanceRequest is the request type for the Query/Allowance RPC method. */ +export interface QueryAllowanceRequest { + /** granter is the address of the user granting an allowance of their funds. */ + granter: string; + /** grantee is the address of the user being granted an allowance of another user's funds. */ + grantee: string; +} + +/** QueryAllowanceResponse is the response type for the Query/Allowance RPC method. */ +export interface QueryAllowanceResponse { + /** allowance is a allowance granted for grantee by granter. */ + allowance: Grant | undefined; +} + +/** QueryAllowancesRequest is the request type for the Query/Allowances RPC method. */ +export interface QueryAllowancesRequest { + grantee: string; + /** pagination defines an pagination for the request. */ + pagination: PageRequest | undefined; +} + +/** QueryAllowancesResponse is the response type for the Query/Allowances RPC method. */ +export interface QueryAllowancesResponse { + /** allowances are allowance's granted for grantee by granter. */ + allowances: Grant[]; + /** pagination defines an pagination for the response. */ + pagination: PageResponse | undefined; +} + +/** QueryAllowancesByGranterRequest is the request type for the Query/AllowancesByGranter RPC method. */ +export interface QueryAllowancesByGranterRequest { + granter: string; + /** pagination defines an pagination for the request. */ + pagination: PageRequest | undefined; +} + +/** QueryAllowancesByGranterResponse is the response type for the Query/AllowancesByGranter RPC method. */ +export interface QueryAllowancesByGranterResponse { + /** allowances that have been issued by the granter. */ + allowances: Grant[]; + /** pagination defines an pagination for the response. */ + pagination: PageResponse | undefined; +} + +const baseQueryAllowanceRequest: object = { granter: "", grantee: "" }; + +export const QueryAllowanceRequest = { + encode( + message: QueryAllowanceRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.granter !== "") { + writer.uint32(10).string(message.granter); + } + if (message.grantee !== "") { + writer.uint32(18).string(message.grantee); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QueryAllowanceRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryAllowanceRequest } as QueryAllowanceRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.granter = reader.string(); + break; + case 2: + message.grantee = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryAllowanceRequest { + const message = { ...baseQueryAllowanceRequest } as QueryAllowanceRequest; + if (object.granter !== undefined && object.granter !== null) { + message.granter = String(object.granter); + } else { + message.granter = ""; + } + if (object.grantee !== undefined && object.grantee !== null) { + message.grantee = String(object.grantee); + } else { + message.grantee = ""; + } + return message; + }, + + toJSON(message: QueryAllowanceRequest): unknown { + const obj: any = {}; + message.granter !== undefined && (obj.granter = message.granter); + message.grantee !== undefined && (obj.grantee = message.grantee); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryAllowanceRequest { + const message = { ...baseQueryAllowanceRequest } as QueryAllowanceRequest; + if (object.granter !== undefined && object.granter !== null) { + message.granter = object.granter; + } else { + message.granter = ""; + } + if (object.grantee !== undefined && object.grantee !== null) { + message.grantee = object.grantee; + } else { + message.grantee = ""; + } + return message; + }, +}; + +const baseQueryAllowanceResponse: object = {}; + +export const QueryAllowanceResponse = { + encode( + message: QueryAllowanceResponse, + writer: Writer = Writer.create() + ): Writer { + if (message.allowance !== undefined) { + Grant.encode(message.allowance, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QueryAllowanceResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryAllowanceResponse } as QueryAllowanceResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.allowance = Grant.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryAllowanceResponse { + const message = { ...baseQueryAllowanceResponse } as QueryAllowanceResponse; + if (object.allowance !== undefined && object.allowance !== null) { + message.allowance = Grant.fromJSON(object.allowance); + } else { + message.allowance = undefined; + } + return message; + }, + + toJSON(message: QueryAllowanceResponse): unknown { + const obj: any = {}; + message.allowance !== undefined && + (obj.allowance = message.allowance + ? Grant.toJSON(message.allowance) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryAllowanceResponse { + const message = { ...baseQueryAllowanceResponse } as QueryAllowanceResponse; + if (object.allowance !== undefined && object.allowance !== null) { + message.allowance = Grant.fromPartial(object.allowance); + } else { + message.allowance = undefined; + } + return message; + }, +}; + +const baseQueryAllowancesRequest: object = { grantee: "" }; + +export const QueryAllowancesRequest = { + encode( + message: QueryAllowancesRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.grantee !== "") { + writer.uint32(10).string(message.grantee); + } + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QueryAllowancesRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryAllowancesRequest } as QueryAllowancesRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.grantee = reader.string(); + break; + case 2: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryAllowancesRequest { + const message = { ...baseQueryAllowancesRequest } as QueryAllowancesRequest; + if (object.grantee !== undefined && object.grantee !== null) { + message.grantee = String(object.grantee); + } else { + message.grantee = ""; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryAllowancesRequest): unknown { + const obj: any = {}; + message.grantee !== undefined && (obj.grantee = message.grantee); + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageRequest.toJSON(message.pagination) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryAllowancesRequest { + const message = { ...baseQueryAllowancesRequest } as QueryAllowancesRequest; + if (object.grantee !== undefined && object.grantee !== null) { + message.grantee = object.grantee; + } else { + message.grantee = ""; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseQueryAllowancesResponse: object = {}; + +export const QueryAllowancesResponse = { + encode( + message: QueryAllowancesResponse, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.allowances) { + Grant.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode( + message.pagination, + writer.uint32(18).fork() + ).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QueryAllowancesResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryAllowancesResponse, + } as QueryAllowancesResponse; + message.allowances = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.allowances.push(Grant.decode(reader, reader.uint32())); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryAllowancesResponse { + const message = { + ...baseQueryAllowancesResponse, + } as QueryAllowancesResponse; + message.allowances = []; + if (object.allowances !== undefined && object.allowances !== null) { + for (const e of object.allowances) { + message.allowances.push(Grant.fromJSON(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryAllowancesResponse): unknown { + const obj: any = {}; + if (message.allowances) { + obj.allowances = message.allowances.map((e) => + e ? Grant.toJSON(e) : undefined + ); + } else { + obj.allowances = []; + } + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageResponse.toJSON(message.pagination) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryAllowancesResponse { + const message = { + ...baseQueryAllowancesResponse, + } as QueryAllowancesResponse; + message.allowances = []; + if (object.allowances !== undefined && object.allowances !== null) { + for (const e of object.allowances) { + message.allowances.push(Grant.fromPartial(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseQueryAllowancesByGranterRequest: object = { granter: "" }; + +export const QueryAllowancesByGranterRequest = { + encode( + message: QueryAllowancesByGranterRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.granter !== "") { + writer.uint32(10).string(message.granter); + } + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryAllowancesByGranterRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryAllowancesByGranterRequest, + } as QueryAllowancesByGranterRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.granter = reader.string(); + break; + case 2: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryAllowancesByGranterRequest { + const message = { + ...baseQueryAllowancesByGranterRequest, + } as QueryAllowancesByGranterRequest; + if (object.granter !== undefined && object.granter !== null) { + message.granter = String(object.granter); + } else { + message.granter = ""; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryAllowancesByGranterRequest): unknown { + const obj: any = {}; + message.granter !== undefined && (obj.granter = message.granter); + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageRequest.toJSON(message.pagination) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryAllowancesByGranterRequest { + const message = { + ...baseQueryAllowancesByGranterRequest, + } as QueryAllowancesByGranterRequest; + if (object.granter !== undefined && object.granter !== null) { + message.granter = object.granter; + } else { + message.granter = ""; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseQueryAllowancesByGranterResponse: object = {}; + +export const QueryAllowancesByGranterResponse = { + encode( + message: QueryAllowancesByGranterResponse, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.allowances) { + Grant.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode( + message.pagination, + writer.uint32(18).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryAllowancesByGranterResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryAllowancesByGranterResponse, + } as QueryAllowancesByGranterResponse; + message.allowances = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.allowances.push(Grant.decode(reader, reader.uint32())); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryAllowancesByGranterResponse { + const message = { + ...baseQueryAllowancesByGranterResponse, + } as QueryAllowancesByGranterResponse; + message.allowances = []; + if (object.allowances !== undefined && object.allowances !== null) { + for (const e of object.allowances) { + message.allowances.push(Grant.fromJSON(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryAllowancesByGranterResponse): unknown { + const obj: any = {}; + if (message.allowances) { + obj.allowances = message.allowances.map((e) => + e ? Grant.toJSON(e) : undefined + ); + } else { + obj.allowances = []; + } + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageResponse.toJSON(message.pagination) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryAllowancesByGranterResponse { + const message = { + ...baseQueryAllowancesByGranterResponse, + } as QueryAllowancesByGranterResponse; + message.allowances = []; + if (object.allowances !== undefined && object.allowances !== null) { + for (const e of object.allowances) { + message.allowances.push(Grant.fromPartial(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +/** Query defines the gRPC querier service. */ +export interface Query { + /** Allowance returns fee granted to the grantee by the granter. */ + Allowance(request: QueryAllowanceRequest): Promise; + /** Allowances returns all the grants for address. */ + Allowances(request: QueryAllowancesRequest): Promise; + /** + * AllowancesByGranter returns all the grants given by an address + * Since v0.46 + */ + AllowancesByGranter( + request: QueryAllowancesByGranterRequest + ): Promise; +} + +export class QueryClientImpl implements Query { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + } + Allowance(request: QueryAllowanceRequest): Promise { + const data = QueryAllowanceRequest.encode(request).finish(); + const promise = this.rpc.request( + "cosmos.feegrant.v1beta1.Query", + "Allowance", + data + ); + return promise.then((data) => + QueryAllowanceResponse.decode(new Reader(data)) + ); + } + + Allowances( + request: QueryAllowancesRequest + ): Promise { + const data = QueryAllowancesRequest.encode(request).finish(); + const promise = this.rpc.request( + "cosmos.feegrant.v1beta1.Query", + "Allowances", + data + ); + return promise.then((data) => + QueryAllowancesResponse.decode(new Reader(data)) + ); + } + + AllowancesByGranter( + request: QueryAllowancesByGranterRequest + ): Promise { + const data = QueryAllowancesByGranterRequest.encode(request).finish(); + const promise = this.rpc.request( + "cosmos.feegrant.v1beta1.Query", + "AllowancesByGranter", + data + ); + return promise.then((data) => + QueryAllowancesByGranterResponse.decode(new Reader(data)) + ); + } +} + +interface Rpc { + request( + service: string, + method: string, + data: Uint8Array + ): Promise; +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/cosmos.feegrant.v1beta1/types/cosmos/feegrant/v1beta1/tx.ts b/ts-client/cosmos.feegrant.v1beta1/types/cosmos/feegrant/v1beta1/tx.ts new file mode 100644 index 00000000..1206a2bf --- /dev/null +++ b/ts-client/cosmos.feegrant.v1beta1/types/cosmos/feegrant/v1beta1/tx.ts @@ -0,0 +1,376 @@ +/* eslint-disable */ +import { Reader, Writer } from "protobufjs/minimal"; +import { Any } from "../../../google/protobuf/any"; + +export const protobufPackage = "cosmos.feegrant.v1beta1"; + +/** Since: cosmos-sdk 0.43 */ + +/** + * MsgGrantAllowance adds permission for Grantee to spend up to Allowance + * of fees from the account of Granter. + */ +export interface MsgGrantAllowance { + /** granter is the address of the user granting an allowance of their funds. */ + granter: string; + /** grantee is the address of the user being granted an allowance of another user's funds. */ + grantee: string; + /** allowance can be any of basic and filtered fee allowance. */ + allowance: Any | undefined; +} + +/** MsgGrantAllowanceResponse defines the Msg/GrantAllowanceResponse response type. */ +export interface MsgGrantAllowanceResponse {} + +/** MsgRevokeAllowance removes any existing Allowance from Granter to Grantee. */ +export interface MsgRevokeAllowance { + /** granter is the address of the user granting an allowance of their funds. */ + granter: string; + /** grantee is the address of the user being granted an allowance of another user's funds. */ + grantee: string; +} + +/** MsgRevokeAllowanceResponse defines the Msg/RevokeAllowanceResponse response type. */ +export interface MsgRevokeAllowanceResponse {} + +const baseMsgGrantAllowance: object = { granter: "", grantee: "" }; + +export const MsgGrantAllowance = { + encode(message: MsgGrantAllowance, writer: Writer = Writer.create()): Writer { + if (message.granter !== "") { + writer.uint32(10).string(message.granter); + } + if (message.grantee !== "") { + writer.uint32(18).string(message.grantee); + } + if (message.allowance !== undefined) { + Any.encode(message.allowance, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MsgGrantAllowance { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgGrantAllowance } as MsgGrantAllowance; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.granter = reader.string(); + break; + case 2: + message.grantee = reader.string(); + break; + case 3: + message.allowance = Any.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgGrantAllowance { + const message = { ...baseMsgGrantAllowance } as MsgGrantAllowance; + if (object.granter !== undefined && object.granter !== null) { + message.granter = String(object.granter); + } else { + message.granter = ""; + } + if (object.grantee !== undefined && object.grantee !== null) { + message.grantee = String(object.grantee); + } else { + message.grantee = ""; + } + if (object.allowance !== undefined && object.allowance !== null) { + message.allowance = Any.fromJSON(object.allowance); + } else { + message.allowance = undefined; + } + return message; + }, + + toJSON(message: MsgGrantAllowance): unknown { + const obj: any = {}; + message.granter !== undefined && (obj.granter = message.granter); + message.grantee !== undefined && (obj.grantee = message.grantee); + message.allowance !== undefined && + (obj.allowance = message.allowance + ? Any.toJSON(message.allowance) + : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): MsgGrantAllowance { + const message = { ...baseMsgGrantAllowance } as MsgGrantAllowance; + if (object.granter !== undefined && object.granter !== null) { + message.granter = object.granter; + } else { + message.granter = ""; + } + if (object.grantee !== undefined && object.grantee !== null) { + message.grantee = object.grantee; + } else { + message.grantee = ""; + } + if (object.allowance !== undefined && object.allowance !== null) { + message.allowance = Any.fromPartial(object.allowance); + } else { + message.allowance = undefined; + } + return message; + }, +}; + +const baseMsgGrantAllowanceResponse: object = {}; + +export const MsgGrantAllowanceResponse = { + encode( + _: MsgGrantAllowanceResponse, + writer: Writer = Writer.create() + ): Writer { + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): MsgGrantAllowanceResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseMsgGrantAllowanceResponse, + } as MsgGrantAllowanceResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): MsgGrantAllowanceResponse { + const message = { + ...baseMsgGrantAllowanceResponse, + } as MsgGrantAllowanceResponse; + return message; + }, + + toJSON(_: MsgGrantAllowanceResponse): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial( + _: DeepPartial + ): MsgGrantAllowanceResponse { + const message = { + ...baseMsgGrantAllowanceResponse, + } as MsgGrantAllowanceResponse; + return message; + }, +}; + +const baseMsgRevokeAllowance: object = { granter: "", grantee: "" }; + +export const MsgRevokeAllowance = { + encode( + message: MsgRevokeAllowance, + writer: Writer = Writer.create() + ): Writer { + if (message.granter !== "") { + writer.uint32(10).string(message.granter); + } + if (message.grantee !== "") { + writer.uint32(18).string(message.grantee); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MsgRevokeAllowance { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgRevokeAllowance } as MsgRevokeAllowance; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.granter = reader.string(); + break; + case 2: + message.grantee = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgRevokeAllowance { + const message = { ...baseMsgRevokeAllowance } as MsgRevokeAllowance; + if (object.granter !== undefined && object.granter !== null) { + message.granter = String(object.granter); + } else { + message.granter = ""; + } + if (object.grantee !== undefined && object.grantee !== null) { + message.grantee = String(object.grantee); + } else { + message.grantee = ""; + } + return message; + }, + + toJSON(message: MsgRevokeAllowance): unknown { + const obj: any = {}; + message.granter !== undefined && (obj.granter = message.granter); + message.grantee !== undefined && (obj.grantee = message.grantee); + return obj; + }, + + fromPartial(object: DeepPartial): MsgRevokeAllowance { + const message = { ...baseMsgRevokeAllowance } as MsgRevokeAllowance; + if (object.granter !== undefined && object.granter !== null) { + message.granter = object.granter; + } else { + message.granter = ""; + } + if (object.grantee !== undefined && object.grantee !== null) { + message.grantee = object.grantee; + } else { + message.grantee = ""; + } + return message; + }, +}; + +const baseMsgRevokeAllowanceResponse: object = {}; + +export const MsgRevokeAllowanceResponse = { + encode( + _: MsgRevokeAllowanceResponse, + writer: Writer = Writer.create() + ): Writer { + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): MsgRevokeAllowanceResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseMsgRevokeAllowanceResponse, + } as MsgRevokeAllowanceResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): MsgRevokeAllowanceResponse { + const message = { + ...baseMsgRevokeAllowanceResponse, + } as MsgRevokeAllowanceResponse; + return message; + }, + + toJSON(_: MsgRevokeAllowanceResponse): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial( + _: DeepPartial + ): MsgRevokeAllowanceResponse { + const message = { + ...baseMsgRevokeAllowanceResponse, + } as MsgRevokeAllowanceResponse; + return message; + }, +}; + +/** Msg defines the feegrant msg service. */ +export interface Msg { + /** + * GrantAllowance grants fee allowance to the grantee on the granter's + * account with the provided expiration time. + */ + GrantAllowance( + request: MsgGrantAllowance + ): Promise; + /** + * RevokeAllowance revokes any fee allowance of granter's account that + * has been granted to the grantee. + */ + RevokeAllowance( + request: MsgRevokeAllowance + ): Promise; +} + +export class MsgClientImpl implements Msg { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + } + GrantAllowance( + request: MsgGrantAllowance + ): Promise { + const data = MsgGrantAllowance.encode(request).finish(); + const promise = this.rpc.request( + "cosmos.feegrant.v1beta1.Msg", + "GrantAllowance", + data + ); + return promise.then((data) => + MsgGrantAllowanceResponse.decode(new Reader(data)) + ); + } + + RevokeAllowance( + request: MsgRevokeAllowance + ): Promise { + const data = MsgRevokeAllowance.encode(request).finish(); + const promise = this.rpc.request( + "cosmos.feegrant.v1beta1.Msg", + "RevokeAllowance", + data + ); + return promise.then((data) => + MsgRevokeAllowanceResponse.decode(new Reader(data)) + ); + } +} + +interface Rpc { + request( + service: string, + method: string, + data: Uint8Array + ): Promise; +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/cosmos.feegrant.v1beta1/types/cosmos_proto/cosmos.ts b/ts-client/cosmos.feegrant.v1beta1/types/cosmos_proto/cosmos.ts new file mode 100644 index 00000000..9ec67a12 --- /dev/null +++ b/ts-client/cosmos.feegrant.v1beta1/types/cosmos_proto/cosmos.ts @@ -0,0 +1,2 @@ +/* eslint-disable */ +export const protobufPackage = "cosmos_proto"; diff --git a/ts-client/cosmos.feegrant.v1beta1/types/gogoproto/gogo.ts b/ts-client/cosmos.feegrant.v1beta1/types/gogoproto/gogo.ts new file mode 100644 index 00000000..3f41a047 --- /dev/null +++ b/ts-client/cosmos.feegrant.v1beta1/types/gogoproto/gogo.ts @@ -0,0 +1,2 @@ +/* eslint-disable */ +export const protobufPackage = "gogoproto"; diff --git a/ts-client/cosmos.feegrant.v1beta1/types/google/api/annotations.ts b/ts-client/cosmos.feegrant.v1beta1/types/google/api/annotations.ts new file mode 100644 index 00000000..aace4787 --- /dev/null +++ b/ts-client/cosmos.feegrant.v1beta1/types/google/api/annotations.ts @@ -0,0 +1,2 @@ +/* eslint-disable */ +export const protobufPackage = "google.api"; diff --git a/ts-client/cosmos.feegrant.v1beta1/types/google/api/http.ts b/ts-client/cosmos.feegrant.v1beta1/types/google/api/http.ts new file mode 100644 index 00000000..ddc00f8b --- /dev/null +++ b/ts-client/cosmos.feegrant.v1beta1/types/google/api/http.ts @@ -0,0 +1,705 @@ +/* eslint-disable */ +import { Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "google.api"; + +/** + * Defines the HTTP configuration for an API service. It contains a list of + * [HttpRule][google.api.HttpRule], each specifying the mapping of an RPC method + * to one or more HTTP REST API methods. + */ +export interface Http { + /** + * A list of HTTP configuration rules that apply to individual API methods. + * + * **NOTE:** All service configuration rules follow "last one wins" order. + */ + rules: HttpRule[]; + /** + * When set to true, URL path parmeters will be fully URI-decoded except in + * cases of single segment matches in reserved expansion, where "%2F" will be + * left encoded. + * + * The default behavior is to not decode RFC 6570 reserved characters in multi + * segment matches. + */ + fullyDecodeReservedExpansion: boolean; +} + +/** + * `HttpRule` defines the mapping of an RPC method to one or more HTTP + * REST API methods. The mapping specifies how different portions of the RPC + * request message are mapped to URL path, URL query parameters, and + * HTTP request body. The mapping is typically specified as an + * `google.api.http` annotation on the RPC method, + * see "google/api/annotations.proto" for details. + * + * The mapping consists of a field specifying the path template and + * method kind. The path template can refer to fields in the request + * message, as in the example below which describes a REST GET + * operation on a resource collection of messages: + * + * + * service Messaging { + * rpc GetMessage(GetMessageRequest) returns (Message) { + * option (google.api.http).get = "/v1/messages/{message_id}/{sub.subfield}"; + * } + * } + * message GetMessageRequest { + * message SubMessage { + * string subfield = 1; + * } + * string message_id = 1; // mapped to the URL + * SubMessage sub = 2; // `sub.subfield` is url-mapped + * } + * message Message { + * string text = 1; // content of the resource + * } + * + * The same http annotation can alternatively be expressed inside the + * `GRPC API Configuration` YAML file. + * + * http: + * rules: + * - selector: .Messaging.GetMessage + * get: /v1/messages/{message_id}/{sub.subfield} + * + * This definition enables an automatic, bidrectional mapping of HTTP + * JSON to RPC. Example: + * + * HTTP | RPC + * -----|----- + * `GET /v1/messages/123456/foo` | `GetMessage(message_id: "123456" sub: SubMessage(subfield: "foo"))` + * + * In general, not only fields but also field paths can be referenced + * from a path pattern. Fields mapped to the path pattern cannot be + * repeated and must have a primitive (non-message) type. + * + * Any fields in the request message which are not bound by the path + * pattern automatically become (optional) HTTP query + * parameters. Assume the following definition of the request message: + * + * + * service Messaging { + * rpc GetMessage(GetMessageRequest) returns (Message) { + * option (google.api.http).get = "/v1/messages/{message_id}"; + * } + * } + * message GetMessageRequest { + * message SubMessage { + * string subfield = 1; + * } + * string message_id = 1; // mapped to the URL + * int64 revision = 2; // becomes a parameter + * SubMessage sub = 3; // `sub.subfield` becomes a parameter + * } + * + * + * This enables a HTTP JSON to RPC mapping as below: + * + * HTTP | RPC + * -----|----- + * `GET /v1/messages/123456?revision=2&sub.subfield=foo` | `GetMessage(message_id: "123456" revision: 2 sub: SubMessage(subfield: "foo"))` + * + * Note that fields which are mapped to HTTP parameters must have a + * primitive type or a repeated primitive type. Message types are not + * allowed. In the case of a repeated type, the parameter can be + * repeated in the URL, as in `...?param=A¶m=B`. + * + * For HTTP method kinds which allow a request body, the `body` field + * specifies the mapping. Consider a REST update method on the + * message resource collection: + * + * + * service Messaging { + * rpc UpdateMessage(UpdateMessageRequest) returns (Message) { + * option (google.api.http) = { + * put: "/v1/messages/{message_id}" + * body: "message" + * }; + * } + * } + * message UpdateMessageRequest { + * string message_id = 1; // mapped to the URL + * Message message = 2; // mapped to the body + * } + * + * + * The following HTTP JSON to RPC mapping is enabled, where the + * representation of the JSON in the request body is determined by + * protos JSON encoding: + * + * HTTP | RPC + * -----|----- + * `PUT /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: "123456" message { text: "Hi!" })` + * + * The special name `*` can be used in the body mapping to define that + * every field not bound by the path template should be mapped to the + * request body. This enables the following alternative definition of + * the update method: + * + * service Messaging { + * rpc UpdateMessage(Message) returns (Message) { + * option (google.api.http) = { + * put: "/v1/messages/{message_id}" + * body: "*" + * }; + * } + * } + * message Message { + * string message_id = 1; + * string text = 2; + * } + * + * + * The following HTTP JSON to RPC mapping is enabled: + * + * HTTP | RPC + * -----|----- + * `PUT /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: "123456" text: "Hi!")` + * + * Note that when using `*` in the body mapping, it is not possible to + * have HTTP parameters, as all fields not bound by the path end in + * the body. This makes this option more rarely used in practice of + * defining REST APIs. The common usage of `*` is in custom methods + * which don't use the URL at all for transferring data. + * + * It is possible to define multiple HTTP methods for one RPC by using + * the `additional_bindings` option. Example: + * + * service Messaging { + * rpc GetMessage(GetMessageRequest) returns (Message) { + * option (google.api.http) = { + * get: "/v1/messages/{message_id}" + * additional_bindings { + * get: "/v1/users/{user_id}/messages/{message_id}" + * } + * }; + * } + * } + * message GetMessageRequest { + * string message_id = 1; + * string user_id = 2; + * } + * + * + * This enables the following two alternative HTTP JSON to RPC + * mappings: + * + * HTTP | RPC + * -----|----- + * `GET /v1/messages/123456` | `GetMessage(message_id: "123456")` + * `GET /v1/users/me/messages/123456` | `GetMessage(user_id: "me" message_id: "123456")` + * + * # Rules for HTTP mapping + * + * The rules for mapping HTTP path, query parameters, and body fields + * to the request message are as follows: + * + * 1. The `body` field specifies either `*` or a field path, or is + * omitted. If omitted, it indicates there is no HTTP request body. + * 2. Leaf fields (recursive expansion of nested messages in the + * request) can be classified into three types: + * (a) Matched in the URL template. + * (b) Covered by body (if body is `*`, everything except (a) fields; + * else everything under the body field) + * (c) All other fields. + * 3. URL query parameters found in the HTTP request are mapped to (c) fields. + * 4. Any body sent with an HTTP request can contain only (b) fields. + * + * The syntax of the path template is as follows: + * + * Template = "/" Segments [ Verb ] ; + * Segments = Segment { "/" Segment } ; + * Segment = "*" | "**" | LITERAL | Variable ; + * Variable = "{" FieldPath [ "=" Segments ] "}" ; + * FieldPath = IDENT { "." IDENT } ; + * Verb = ":" LITERAL ; + * + * The syntax `*` matches a single path segment. The syntax `**` matches zero + * or more path segments, which must be the last part of the path except the + * `Verb`. The syntax `LITERAL` matches literal text in the path. + * + * The syntax `Variable` matches part of the URL path as specified by its + * template. A variable template must not contain other variables. If a variable + * matches a single path segment, its template may be omitted, e.g. `{var}` + * is equivalent to `{var=*}`. + * + * If a variable contains exactly one path segment, such as `"{var}"` or + * `"{var=*}"`, when such a variable is expanded into a URL path, all characters + * except `[-_.~0-9a-zA-Z]` are percent-encoded. Such variables show up in the + * Discovery Document as `{var}`. + * + * If a variable contains one or more path segments, such as `"{var=foo/*}"` + * or `"{var=**}"`, when such a variable is expanded into a URL path, all + * characters except `[-_.~/0-9a-zA-Z]` are percent-encoded. Such variables + * show up in the Discovery Document as `{+var}`. + * + * NOTE: While the single segment variable matches the semantics of + * [RFC 6570](https://tools.ietf.org/html/rfc6570) Section 3.2.2 + * Simple String Expansion, the multi segment variable **does not** match + * RFC 6570 Reserved Expansion. The reason is that the Reserved Expansion + * does not expand special characters like `?` and `#`, which would lead + * to invalid URLs. + * + * NOTE: the field paths in variables and in the `body` must not refer to + * repeated fields or map fields. + */ +export interface HttpRule { + /** + * Selects methods to which this rule applies. + * + * Refer to [selector][google.api.DocumentationRule.selector] for syntax details. + */ + selector: string; + /** Used for listing and getting information about resources. */ + get: string | undefined; + /** Used for updating a resource. */ + put: string | undefined; + /** Used for creating a resource. */ + post: string | undefined; + /** Used for deleting a resource. */ + delete: string | undefined; + /** Used for updating a resource. */ + patch: string | undefined; + /** + * The custom pattern is used for specifying an HTTP method that is not + * included in the `pattern` field, such as HEAD, or "*" to leave the + * HTTP method unspecified for this rule. The wild-card rule is useful + * for services that provide content to Web (HTML) clients. + */ + custom: CustomHttpPattern | undefined; + /** + * The name of the request field whose value is mapped to the HTTP body, or + * `*` for mapping all fields not captured by the path pattern to the HTTP + * body. NOTE: the referred field must not be a repeated field and must be + * present at the top-level of request message type. + */ + body: string; + /** + * Optional. The name of the response field whose value is mapped to the HTTP + * body of response. Other response fields are ignored. When + * not set, the response message will be used as HTTP body of response. + */ + responseBody: string; + /** + * Additional HTTP bindings for the selector. Nested bindings must + * not contain an `additional_bindings` field themselves (that is, + * the nesting may only be one level deep). + */ + additionalBindings: HttpRule[]; +} + +/** A custom pattern is used for defining custom HTTP verb. */ +export interface CustomHttpPattern { + /** The name of this custom HTTP verb. */ + kind: string; + /** The path matched by this custom verb. */ + path: string; +} + +const baseHttp: object = { fullyDecodeReservedExpansion: false }; + +export const Http = { + encode(message: Http, writer: Writer = Writer.create()): Writer { + for (const v of message.rules) { + HttpRule.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.fullyDecodeReservedExpansion === true) { + writer.uint32(16).bool(message.fullyDecodeReservedExpansion); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Http { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseHttp } as Http; + message.rules = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.rules.push(HttpRule.decode(reader, reader.uint32())); + break; + case 2: + message.fullyDecodeReservedExpansion = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Http { + const message = { ...baseHttp } as Http; + message.rules = []; + if (object.rules !== undefined && object.rules !== null) { + for (const e of object.rules) { + message.rules.push(HttpRule.fromJSON(e)); + } + } + if ( + object.fullyDecodeReservedExpansion !== undefined && + object.fullyDecodeReservedExpansion !== null + ) { + message.fullyDecodeReservedExpansion = Boolean( + object.fullyDecodeReservedExpansion + ); + } else { + message.fullyDecodeReservedExpansion = false; + } + return message; + }, + + toJSON(message: Http): unknown { + const obj: any = {}; + if (message.rules) { + obj.rules = message.rules.map((e) => + e ? HttpRule.toJSON(e) : undefined + ); + } else { + obj.rules = []; + } + message.fullyDecodeReservedExpansion !== undefined && + (obj.fullyDecodeReservedExpansion = message.fullyDecodeReservedExpansion); + return obj; + }, + + fromPartial(object: DeepPartial): Http { + const message = { ...baseHttp } as Http; + message.rules = []; + if (object.rules !== undefined && object.rules !== null) { + for (const e of object.rules) { + message.rules.push(HttpRule.fromPartial(e)); + } + } + if ( + object.fullyDecodeReservedExpansion !== undefined && + object.fullyDecodeReservedExpansion !== null + ) { + message.fullyDecodeReservedExpansion = + object.fullyDecodeReservedExpansion; + } else { + message.fullyDecodeReservedExpansion = false; + } + return message; + }, +}; + +const baseHttpRule: object = { selector: "", body: "", responseBody: "" }; + +export const HttpRule = { + encode(message: HttpRule, writer: Writer = Writer.create()): Writer { + if (message.selector !== "") { + writer.uint32(10).string(message.selector); + } + if (message.get !== undefined) { + writer.uint32(18).string(message.get); + } + if (message.put !== undefined) { + writer.uint32(26).string(message.put); + } + if (message.post !== undefined) { + writer.uint32(34).string(message.post); + } + if (message.delete !== undefined) { + writer.uint32(42).string(message.delete); + } + if (message.patch !== undefined) { + writer.uint32(50).string(message.patch); + } + if (message.custom !== undefined) { + CustomHttpPattern.encode( + message.custom, + writer.uint32(66).fork() + ).ldelim(); + } + if (message.body !== "") { + writer.uint32(58).string(message.body); + } + if (message.responseBody !== "") { + writer.uint32(98).string(message.responseBody); + } + for (const v of message.additionalBindings) { + HttpRule.encode(v!, writer.uint32(90).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): HttpRule { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseHttpRule } as HttpRule; + message.additionalBindings = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.selector = reader.string(); + break; + case 2: + message.get = reader.string(); + break; + case 3: + message.put = reader.string(); + break; + case 4: + message.post = reader.string(); + break; + case 5: + message.delete = reader.string(); + break; + case 6: + message.patch = reader.string(); + break; + case 8: + message.custom = CustomHttpPattern.decode(reader, reader.uint32()); + break; + case 7: + message.body = reader.string(); + break; + case 12: + message.responseBody = reader.string(); + break; + case 11: + message.additionalBindings.push( + HttpRule.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): HttpRule { + const message = { ...baseHttpRule } as HttpRule; + message.additionalBindings = []; + if (object.selector !== undefined && object.selector !== null) { + message.selector = String(object.selector); + } else { + message.selector = ""; + } + if (object.get !== undefined && object.get !== null) { + message.get = String(object.get); + } else { + message.get = undefined; + } + if (object.put !== undefined && object.put !== null) { + message.put = String(object.put); + } else { + message.put = undefined; + } + if (object.post !== undefined && object.post !== null) { + message.post = String(object.post); + } else { + message.post = undefined; + } + if (object.delete !== undefined && object.delete !== null) { + message.delete = String(object.delete); + } else { + message.delete = undefined; + } + if (object.patch !== undefined && object.patch !== null) { + message.patch = String(object.patch); + } else { + message.patch = undefined; + } + if (object.custom !== undefined && object.custom !== null) { + message.custom = CustomHttpPattern.fromJSON(object.custom); + } else { + message.custom = undefined; + } + if (object.body !== undefined && object.body !== null) { + message.body = String(object.body); + } else { + message.body = ""; + } + if (object.responseBody !== undefined && object.responseBody !== null) { + message.responseBody = String(object.responseBody); + } else { + message.responseBody = ""; + } + if ( + object.additionalBindings !== undefined && + object.additionalBindings !== null + ) { + for (const e of object.additionalBindings) { + message.additionalBindings.push(HttpRule.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: HttpRule): unknown { + const obj: any = {}; + message.selector !== undefined && (obj.selector = message.selector); + message.get !== undefined && (obj.get = message.get); + message.put !== undefined && (obj.put = message.put); + message.post !== undefined && (obj.post = message.post); + message.delete !== undefined && (obj.delete = message.delete); + message.patch !== undefined && (obj.patch = message.patch); + message.custom !== undefined && + (obj.custom = message.custom + ? CustomHttpPattern.toJSON(message.custom) + : undefined); + message.body !== undefined && (obj.body = message.body); + message.responseBody !== undefined && + (obj.responseBody = message.responseBody); + if (message.additionalBindings) { + obj.additionalBindings = message.additionalBindings.map((e) => + e ? HttpRule.toJSON(e) : undefined + ); + } else { + obj.additionalBindings = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): HttpRule { + const message = { ...baseHttpRule } as HttpRule; + message.additionalBindings = []; + if (object.selector !== undefined && object.selector !== null) { + message.selector = object.selector; + } else { + message.selector = ""; + } + if (object.get !== undefined && object.get !== null) { + message.get = object.get; + } else { + message.get = undefined; + } + if (object.put !== undefined && object.put !== null) { + message.put = object.put; + } else { + message.put = undefined; + } + if (object.post !== undefined && object.post !== null) { + message.post = object.post; + } else { + message.post = undefined; + } + if (object.delete !== undefined && object.delete !== null) { + message.delete = object.delete; + } else { + message.delete = undefined; + } + if (object.patch !== undefined && object.patch !== null) { + message.patch = object.patch; + } else { + message.patch = undefined; + } + if (object.custom !== undefined && object.custom !== null) { + message.custom = CustomHttpPattern.fromPartial(object.custom); + } else { + message.custom = undefined; + } + if (object.body !== undefined && object.body !== null) { + message.body = object.body; + } else { + message.body = ""; + } + if (object.responseBody !== undefined && object.responseBody !== null) { + message.responseBody = object.responseBody; + } else { + message.responseBody = ""; + } + if ( + object.additionalBindings !== undefined && + object.additionalBindings !== null + ) { + for (const e of object.additionalBindings) { + message.additionalBindings.push(HttpRule.fromPartial(e)); + } + } + return message; + }, +}; + +const baseCustomHttpPattern: object = { kind: "", path: "" }; + +export const CustomHttpPattern = { + encode(message: CustomHttpPattern, writer: Writer = Writer.create()): Writer { + if (message.kind !== "") { + writer.uint32(10).string(message.kind); + } + if (message.path !== "") { + writer.uint32(18).string(message.path); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): CustomHttpPattern { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseCustomHttpPattern } as CustomHttpPattern; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.kind = reader.string(); + break; + case 2: + message.path = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): CustomHttpPattern { + const message = { ...baseCustomHttpPattern } as CustomHttpPattern; + if (object.kind !== undefined && object.kind !== null) { + message.kind = String(object.kind); + } else { + message.kind = ""; + } + if (object.path !== undefined && object.path !== null) { + message.path = String(object.path); + } else { + message.path = ""; + } + return message; + }, + + toJSON(message: CustomHttpPattern): unknown { + const obj: any = {}; + message.kind !== undefined && (obj.kind = message.kind); + message.path !== undefined && (obj.path = message.path); + return obj; + }, + + fromPartial(object: DeepPartial): CustomHttpPattern { + const message = { ...baseCustomHttpPattern } as CustomHttpPattern; + if (object.kind !== undefined && object.kind !== null) { + message.kind = object.kind; + } else { + message.kind = ""; + } + if (object.path !== undefined && object.path !== null) { + message.path = object.path; + } else { + message.path = ""; + } + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/cosmos.feegrant.v1beta1/types/google/protobuf/any.ts b/ts-client/cosmos.feegrant.v1beta1/types/google/protobuf/any.ts new file mode 100644 index 00000000..b137a629 --- /dev/null +++ b/ts-client/cosmos.feegrant.v1beta1/types/google/protobuf/any.ts @@ -0,0 +1,240 @@ +/* eslint-disable */ +import { Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "google.protobuf"; + +/** + * `Any` contains an arbitrary serialized protocol buffer message along with a + * URL that describes the type of the serialized message. + * + * Protobuf library provides support to pack/unpack Any values in the form + * of utility functions or additional generated methods of the Any type. + * + * Example 1: Pack and unpack a message in C++. + * + * Foo foo = ...; + * Any any; + * any.PackFrom(foo); + * ... + * if (any.UnpackTo(&foo)) { + * ... + * } + * + * Example 2: Pack and unpack a message in Java. + * + * Foo foo = ...; + * Any any = Any.pack(foo); + * ... + * if (any.is(Foo.class)) { + * foo = any.unpack(Foo.class); + * } + * + * Example 3: Pack and unpack a message in Python. + * + * foo = Foo(...) + * any = Any() + * any.Pack(foo) + * ... + * if any.Is(Foo.DESCRIPTOR): + * any.Unpack(foo) + * ... + * + * Example 4: Pack and unpack a message in Go + * + * foo := &pb.Foo{...} + * any, err := anypb.New(foo) + * if err != nil { + * ... + * } + * ... + * foo := &pb.Foo{} + * if err := any.UnmarshalTo(foo); err != nil { + * ... + * } + * + * The pack methods provided by protobuf library will by default use + * 'type.googleapis.com/full.type.name' as the type URL and the unpack + * methods only use the fully qualified type name after the last '/' + * in the type URL, for example "foo.bar.com/x/y.z" will yield type + * name "y.z". + * + * + * JSON + * ==== + * The JSON representation of an `Any` value uses the regular + * representation of the deserialized, embedded message, with an + * additional field `@type` which contains the type URL. Example: + * + * package google.profile; + * message Person { + * string first_name = 1; + * string last_name = 2; + * } + * + * { + * "@type": "type.googleapis.com/google.profile.Person", + * "firstName": , + * "lastName": + * } + * + * If the embedded message type is well-known and has a custom JSON + * representation, that representation will be embedded adding a field + * `value` which holds the custom JSON in addition to the `@type` + * field. Example (for message [google.protobuf.Duration][]): + * + * { + * "@type": "type.googleapis.com/google.protobuf.Duration", + * "value": "1.212s" + * } + */ +export interface Any { + /** + * A URL/resource name that uniquely identifies the type of the serialized + * protocol buffer message. This string must contain at least + * one "/" character. The last segment of the URL's path must represent + * the fully qualified name of the type (as in + * `path/google.protobuf.Duration`). The name should be in a canonical form + * (e.g., leading "." is not accepted). + * + * In practice, teams usually precompile into the binary all types that they + * expect it to use in the context of Any. However, for URLs which use the + * scheme `http`, `https`, or no scheme, one can optionally set up a type + * server that maps type URLs to message definitions as follows: + * + * * If no scheme is provided, `https` is assumed. + * * An HTTP GET on the URL must yield a [google.protobuf.Type][] + * value in binary format, or produce an error. + * * Applications are allowed to cache lookup results based on the + * URL, or have them precompiled into a binary to avoid any + * lookup. Therefore, binary compatibility needs to be preserved + * on changes to types. (Use versioned type names to manage + * breaking changes.) + * + * Note: this functionality is not currently available in the official + * protobuf release, and it is not used for type URLs beginning with + * type.googleapis.com. + * + * Schemes other than `http`, `https` (or the empty scheme) might be + * used with implementation specific semantics. + */ + typeUrl: string; + /** Must be a valid serialized protocol buffer of the above specified type. */ + value: Uint8Array; +} + +const baseAny: object = { typeUrl: "" }; + +export const Any = { + encode(message: Any, writer: Writer = Writer.create()): Writer { + if (message.typeUrl !== "") { + writer.uint32(10).string(message.typeUrl); + } + if (message.value.length !== 0) { + writer.uint32(18).bytes(message.value); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Any { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseAny } as Any; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.typeUrl = reader.string(); + break; + case 2: + message.value = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Any { + const message = { ...baseAny } as Any; + if (object.typeUrl !== undefined && object.typeUrl !== null) { + message.typeUrl = String(object.typeUrl); + } else { + message.typeUrl = ""; + } + if (object.value !== undefined && object.value !== null) { + message.value = bytesFromBase64(object.value); + } + return message; + }, + + toJSON(message: Any): unknown { + const obj: any = {}; + message.typeUrl !== undefined && (obj.typeUrl = message.typeUrl); + message.value !== undefined && + (obj.value = base64FromBytes( + message.value !== undefined ? message.value : new Uint8Array() + )); + return obj; + }, + + fromPartial(object: DeepPartial): Any { + const message = { ...baseAny } as Any; + if (object.typeUrl !== undefined && object.typeUrl !== null) { + message.typeUrl = object.typeUrl; + } else { + message.typeUrl = ""; + } + if (object.value !== undefined && object.value !== null) { + message.value = object.value; + } else { + message.value = new Uint8Array(); + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/cosmos.feegrant.v1beta1/types/google/protobuf/descriptor.ts b/ts-client/cosmos.feegrant.v1beta1/types/google/protobuf/descriptor.ts new file mode 100644 index 00000000..9e508660 --- /dev/null +++ b/ts-client/cosmos.feegrant.v1beta1/types/google/protobuf/descriptor.ts @@ -0,0 +1,5261 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "google.protobuf"; + +/** + * The protocol compiler can output a FileDescriptorSet containing the .proto + * files it parses. + */ +export interface FileDescriptorSet { + file: FileDescriptorProto[]; +} + +/** Describes a complete .proto file. */ +export interface FileDescriptorProto { + /** file name, relative to root of source tree */ + name: string; + /** e.g. "foo", "foo.bar", etc. */ + package: string; + /** Names of files imported by this file. */ + dependency: string[]; + /** Indexes of the public imported files in the dependency list above. */ + publicDependency: number[]; + /** + * Indexes of the weak imported files in the dependency list. + * For Google-internal migration only. Do not use. + */ + weakDependency: number[]; + /** All top-level definitions in this file. */ + messageType: DescriptorProto[]; + enumType: EnumDescriptorProto[]; + service: ServiceDescriptorProto[]; + extension: FieldDescriptorProto[]; + options: FileOptions | undefined; + /** + * This field contains optional information about the original source code. + * You may safely remove this entire field without harming runtime + * functionality of the descriptors -- the information is needed only by + * development tools. + */ + sourceCodeInfo: SourceCodeInfo | undefined; + /** + * The syntax of the proto file. + * The supported values are "proto2" and "proto3". + */ + syntax: string; +} + +/** Describes a message type. */ +export interface DescriptorProto { + name: string; + field: FieldDescriptorProto[]; + extension: FieldDescriptorProto[]; + nestedType: DescriptorProto[]; + enumType: EnumDescriptorProto[]; + extensionRange: DescriptorProto_ExtensionRange[]; + oneofDecl: OneofDescriptorProto[]; + options: MessageOptions | undefined; + reservedRange: DescriptorProto_ReservedRange[]; + /** + * Reserved field names, which may not be used by fields in the same message. + * A given name may only be reserved once. + */ + reservedName: string[]; +} + +export interface DescriptorProto_ExtensionRange { + /** Inclusive. */ + start: number; + /** Exclusive. */ + end: number; + options: ExtensionRangeOptions | undefined; +} + +/** + * Range of reserved tag numbers. Reserved tag numbers may not be used by + * fields or extension ranges in the same message. Reserved ranges may + * not overlap. + */ +export interface DescriptorProto_ReservedRange { + /** Inclusive. */ + start: number; + /** Exclusive. */ + end: number; +} + +export interface ExtensionRangeOptions { + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +/** Describes a field within a message. */ +export interface FieldDescriptorProto { + name: string; + number: number; + label: FieldDescriptorProto_Label; + /** + * If type_name is set, this need not be set. If both this and type_name + * are set, this must be one of TYPE_ENUM, TYPE_MESSAGE or TYPE_GROUP. + */ + type: FieldDescriptorProto_Type; + /** + * For message and enum types, this is the name of the type. If the name + * starts with a '.', it is fully-qualified. Otherwise, C++-like scoping + * rules are used to find the type (i.e. first the nested types within this + * message are searched, then within the parent, on up to the root + * namespace). + */ + typeName: string; + /** + * For extensions, this is the name of the type being extended. It is + * resolved in the same manner as type_name. + */ + extendee: string; + /** + * For numeric types, contains the original text representation of the value. + * For booleans, "true" or "false". + * For strings, contains the default text contents (not escaped in any way). + * For bytes, contains the C escaped value. All bytes >= 128 are escaped. + * TODO(kenton): Base-64 encode? + */ + defaultValue: string; + /** + * If set, gives the index of a oneof in the containing type's oneof_decl + * list. This field is a member of that oneof. + */ + oneofIndex: number; + /** + * JSON name of this field. The value is set by protocol compiler. If the + * user has set a "json_name" option on this field, that option's value + * will be used. Otherwise, it's deduced from the field's name by converting + * it to camelCase. + */ + jsonName: string; + options: FieldOptions | undefined; + /** + * If true, this is a proto3 "optional". When a proto3 field is optional, it + * tracks presence regardless of field type. + * + * When proto3_optional is true, this field must be belong to a oneof to + * signal to old proto3 clients that presence is tracked for this field. This + * oneof is known as a "synthetic" oneof, and this field must be its sole + * member (each proto3 optional field gets its own synthetic oneof). Synthetic + * oneofs exist in the descriptor only, and do not generate any API. Synthetic + * oneofs must be ordered after all "real" oneofs. + * + * For message fields, proto3_optional doesn't create any semantic change, + * since non-repeated message fields always track presence. However it still + * indicates the semantic detail of whether the user wrote "optional" or not. + * This can be useful for round-tripping the .proto file. For consistency we + * give message fields a synthetic oneof also, even though it is not required + * to track presence. This is especially important because the parser can't + * tell if a field is a message or an enum, so it must always create a + * synthetic oneof. + * + * Proto2 optional fields do not set this flag, because they already indicate + * optional with `LABEL_OPTIONAL`. + */ + proto3Optional: boolean; +} + +export enum FieldDescriptorProto_Type { + /** + * TYPE_DOUBLE - 0 is reserved for errors. + * Order is weird for historical reasons. + */ + TYPE_DOUBLE = 1, + TYPE_FLOAT = 2, + /** + * TYPE_INT64 - Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT64 if + * negative values are likely. + */ + TYPE_INT64 = 3, + TYPE_UINT64 = 4, + /** + * TYPE_INT32 - Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT32 if + * negative values are likely. + */ + TYPE_INT32 = 5, + TYPE_FIXED64 = 6, + TYPE_FIXED32 = 7, + TYPE_BOOL = 8, + TYPE_STRING = 9, + /** + * TYPE_GROUP - Tag-delimited aggregate. + * Group type is deprecated and not supported in proto3. However, Proto3 + * implementations should still be able to parse the group wire format and + * treat group fields as unknown fields. + */ + TYPE_GROUP = 10, + /** TYPE_MESSAGE - Length-delimited aggregate. */ + TYPE_MESSAGE = 11, + /** TYPE_BYTES - New in version 2. */ + TYPE_BYTES = 12, + TYPE_UINT32 = 13, + TYPE_ENUM = 14, + TYPE_SFIXED32 = 15, + TYPE_SFIXED64 = 16, + /** TYPE_SINT32 - Uses ZigZag encoding. */ + TYPE_SINT32 = 17, + /** TYPE_SINT64 - Uses ZigZag encoding. */ + TYPE_SINT64 = 18, + UNRECOGNIZED = -1, +} + +export function fieldDescriptorProto_TypeFromJSON( + object: any +): FieldDescriptorProto_Type { + switch (object) { + case 1: + case "TYPE_DOUBLE": + return FieldDescriptorProto_Type.TYPE_DOUBLE; + case 2: + case "TYPE_FLOAT": + return FieldDescriptorProto_Type.TYPE_FLOAT; + case 3: + case "TYPE_INT64": + return FieldDescriptorProto_Type.TYPE_INT64; + case 4: + case "TYPE_UINT64": + return FieldDescriptorProto_Type.TYPE_UINT64; + case 5: + case "TYPE_INT32": + return FieldDescriptorProto_Type.TYPE_INT32; + case 6: + case "TYPE_FIXED64": + return FieldDescriptorProto_Type.TYPE_FIXED64; + case 7: + case "TYPE_FIXED32": + return FieldDescriptorProto_Type.TYPE_FIXED32; + case 8: + case "TYPE_BOOL": + return FieldDescriptorProto_Type.TYPE_BOOL; + case 9: + case "TYPE_STRING": + return FieldDescriptorProto_Type.TYPE_STRING; + case 10: + case "TYPE_GROUP": + return FieldDescriptorProto_Type.TYPE_GROUP; + case 11: + case "TYPE_MESSAGE": + return FieldDescriptorProto_Type.TYPE_MESSAGE; + case 12: + case "TYPE_BYTES": + return FieldDescriptorProto_Type.TYPE_BYTES; + case 13: + case "TYPE_UINT32": + return FieldDescriptorProto_Type.TYPE_UINT32; + case 14: + case "TYPE_ENUM": + return FieldDescriptorProto_Type.TYPE_ENUM; + case 15: + case "TYPE_SFIXED32": + return FieldDescriptorProto_Type.TYPE_SFIXED32; + case 16: + case "TYPE_SFIXED64": + return FieldDescriptorProto_Type.TYPE_SFIXED64; + case 17: + case "TYPE_SINT32": + return FieldDescriptorProto_Type.TYPE_SINT32; + case 18: + case "TYPE_SINT64": + return FieldDescriptorProto_Type.TYPE_SINT64; + case -1: + case "UNRECOGNIZED": + default: + return FieldDescriptorProto_Type.UNRECOGNIZED; + } +} + +export function fieldDescriptorProto_TypeToJSON( + object: FieldDescriptorProto_Type +): string { + switch (object) { + case FieldDescriptorProto_Type.TYPE_DOUBLE: + return "TYPE_DOUBLE"; + case FieldDescriptorProto_Type.TYPE_FLOAT: + return "TYPE_FLOAT"; + case FieldDescriptorProto_Type.TYPE_INT64: + return "TYPE_INT64"; + case FieldDescriptorProto_Type.TYPE_UINT64: + return "TYPE_UINT64"; + case FieldDescriptorProto_Type.TYPE_INT32: + return "TYPE_INT32"; + case FieldDescriptorProto_Type.TYPE_FIXED64: + return "TYPE_FIXED64"; + case FieldDescriptorProto_Type.TYPE_FIXED32: + return "TYPE_FIXED32"; + case FieldDescriptorProto_Type.TYPE_BOOL: + return "TYPE_BOOL"; + case FieldDescriptorProto_Type.TYPE_STRING: + return "TYPE_STRING"; + case FieldDescriptorProto_Type.TYPE_GROUP: + return "TYPE_GROUP"; + case FieldDescriptorProto_Type.TYPE_MESSAGE: + return "TYPE_MESSAGE"; + case FieldDescriptorProto_Type.TYPE_BYTES: + return "TYPE_BYTES"; + case FieldDescriptorProto_Type.TYPE_UINT32: + return "TYPE_UINT32"; + case FieldDescriptorProto_Type.TYPE_ENUM: + return "TYPE_ENUM"; + case FieldDescriptorProto_Type.TYPE_SFIXED32: + return "TYPE_SFIXED32"; + case FieldDescriptorProto_Type.TYPE_SFIXED64: + return "TYPE_SFIXED64"; + case FieldDescriptorProto_Type.TYPE_SINT32: + return "TYPE_SINT32"; + case FieldDescriptorProto_Type.TYPE_SINT64: + return "TYPE_SINT64"; + default: + return "UNKNOWN"; + } +} + +export enum FieldDescriptorProto_Label { + /** LABEL_OPTIONAL - 0 is reserved for errors */ + LABEL_OPTIONAL = 1, + LABEL_REQUIRED = 2, + LABEL_REPEATED = 3, + UNRECOGNIZED = -1, +} + +export function fieldDescriptorProto_LabelFromJSON( + object: any +): FieldDescriptorProto_Label { + switch (object) { + case 1: + case "LABEL_OPTIONAL": + return FieldDescriptorProto_Label.LABEL_OPTIONAL; + case 2: + case "LABEL_REQUIRED": + return FieldDescriptorProto_Label.LABEL_REQUIRED; + case 3: + case "LABEL_REPEATED": + return FieldDescriptorProto_Label.LABEL_REPEATED; + case -1: + case "UNRECOGNIZED": + default: + return FieldDescriptorProto_Label.UNRECOGNIZED; + } +} + +export function fieldDescriptorProto_LabelToJSON( + object: FieldDescriptorProto_Label +): string { + switch (object) { + case FieldDescriptorProto_Label.LABEL_OPTIONAL: + return "LABEL_OPTIONAL"; + case FieldDescriptorProto_Label.LABEL_REQUIRED: + return "LABEL_REQUIRED"; + case FieldDescriptorProto_Label.LABEL_REPEATED: + return "LABEL_REPEATED"; + default: + return "UNKNOWN"; + } +} + +/** Describes a oneof. */ +export interface OneofDescriptorProto { + name: string; + options: OneofOptions | undefined; +} + +/** Describes an enum type. */ +export interface EnumDescriptorProto { + name: string; + value: EnumValueDescriptorProto[]; + options: EnumOptions | undefined; + /** + * Range of reserved numeric values. Reserved numeric values may not be used + * by enum values in the same enum declaration. Reserved ranges may not + * overlap. + */ + reservedRange: EnumDescriptorProto_EnumReservedRange[]; + /** + * Reserved enum value names, which may not be reused. A given name may only + * be reserved once. + */ + reservedName: string[]; +} + +/** + * Range of reserved numeric values. Reserved values may not be used by + * entries in the same enum. Reserved ranges may not overlap. + * + * Note that this is distinct from DescriptorProto.ReservedRange in that it + * is inclusive such that it can appropriately represent the entire int32 + * domain. + */ +export interface EnumDescriptorProto_EnumReservedRange { + /** Inclusive. */ + start: number; + /** Inclusive. */ + end: number; +} + +/** Describes a value within an enum. */ +export interface EnumValueDescriptorProto { + name: string; + number: number; + options: EnumValueOptions | undefined; +} + +/** Describes a service. */ +export interface ServiceDescriptorProto { + name: string; + method: MethodDescriptorProto[]; + options: ServiceOptions | undefined; +} + +/** Describes a method of a service. */ +export interface MethodDescriptorProto { + name: string; + /** + * Input and output type names. These are resolved in the same way as + * FieldDescriptorProto.type_name, but must refer to a message type. + */ + inputType: string; + outputType: string; + options: MethodOptions | undefined; + /** Identifies if client streams multiple client messages */ + clientStreaming: boolean; + /** Identifies if server streams multiple server messages */ + serverStreaming: boolean; +} + +export interface FileOptions { + /** + * Sets the Java package where classes generated from this .proto will be + * placed. By default, the proto package is used, but this is often + * inappropriate because proto packages do not normally start with backwards + * domain names. + */ + javaPackage: string; + /** + * Controls the name of the wrapper Java class generated for the .proto file. + * That class will always contain the .proto file's getDescriptor() method as + * well as any top-level extensions defined in the .proto file. + * If java_multiple_files is disabled, then all the other classes from the + * .proto file will be nested inside the single wrapper outer class. + */ + javaOuterClassname: string; + /** + * If enabled, then the Java code generator will generate a separate .java + * file for each top-level message, enum, and service defined in the .proto + * file. Thus, these types will *not* be nested inside the wrapper class + * named by java_outer_classname. However, the wrapper class will still be + * generated to contain the file's getDescriptor() method as well as any + * top-level extensions defined in the file. + */ + javaMultipleFiles: boolean; + /** + * This option does nothing. + * + * @deprecated + */ + javaGenerateEqualsAndHash: boolean; + /** + * If set true, then the Java2 code generator will generate code that + * throws an exception whenever an attempt is made to assign a non-UTF-8 + * byte sequence to a string field. + * Message reflection will do the same. + * However, an extension field still accepts non-UTF-8 byte sequences. + * This option has no effect on when used with the lite runtime. + */ + javaStringCheckUtf8: boolean; + optimizeFor: FileOptions_OptimizeMode; + /** + * Sets the Go package where structs generated from this .proto will be + * placed. If omitted, the Go package will be derived from the following: + * - The basename of the package import path, if provided. + * - Otherwise, the package statement in the .proto file, if present. + * - Otherwise, the basename of the .proto file, without extension. + */ + goPackage: string; + /** + * Should generic services be generated in each language? "Generic" services + * are not specific to any particular RPC system. They are generated by the + * main code generators in each language (without additional plugins). + * Generic services were the only kind of service generation supported by + * early versions of google.protobuf. + * + * Generic services are now considered deprecated in favor of using plugins + * that generate code specific to your particular RPC system. Therefore, + * these default to false. Old code which depends on generic services should + * explicitly set them to true. + */ + ccGenericServices: boolean; + javaGenericServices: boolean; + pyGenericServices: boolean; + phpGenericServices: boolean; + /** + * Is this file deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for everything in the file, or it will be completely ignored; in the very + * least, this is a formalization for deprecating files. + */ + deprecated: boolean; + /** + * Enables the use of arenas for the proto messages in this file. This applies + * only to generated classes for C++. + */ + ccEnableArenas: boolean; + /** + * Sets the objective c class prefix which is prepended to all objective c + * generated classes from this .proto. There is no default. + */ + objcClassPrefix: string; + /** Namespace for generated classes; defaults to the package. */ + csharpNamespace: string; + /** + * By default Swift generators will take the proto package and CamelCase it + * replacing '.' with underscore and use that to prefix the types/symbols + * defined. When this options is provided, they will use this value instead + * to prefix the types/symbols defined. + */ + swiftPrefix: string; + /** + * Sets the php class prefix which is prepended to all php generated classes + * from this .proto. Default is empty. + */ + phpClassPrefix: string; + /** + * Use this option to change the namespace of php generated classes. Default + * is empty. When this option is empty, the package name will be used for + * determining the namespace. + */ + phpNamespace: string; + /** + * Use this option to change the namespace of php generated metadata classes. + * Default is empty. When this option is empty, the proto file name will be + * used for determining the namespace. + */ + phpMetadataNamespace: string; + /** + * Use this option to change the package of ruby generated classes. Default + * is empty. When this option is not set, the package name will be used for + * determining the ruby package. + */ + rubyPackage: string; + /** + * The parser stores options it doesn't recognize here. + * See the documentation for the "Options" section above. + */ + uninterpretedOption: UninterpretedOption[]; +} + +/** Generated classes can be optimized for speed or code size. */ +export enum FileOptions_OptimizeMode { + /** SPEED - Generate complete code for parsing, serialization, */ + SPEED = 1, + /** CODE_SIZE - etc. */ + CODE_SIZE = 2, + /** LITE_RUNTIME - Generate code using MessageLite and the lite runtime. */ + LITE_RUNTIME = 3, + UNRECOGNIZED = -1, +} + +export function fileOptions_OptimizeModeFromJSON( + object: any +): FileOptions_OptimizeMode { + switch (object) { + case 1: + case "SPEED": + return FileOptions_OptimizeMode.SPEED; + case 2: + case "CODE_SIZE": + return FileOptions_OptimizeMode.CODE_SIZE; + case 3: + case "LITE_RUNTIME": + return FileOptions_OptimizeMode.LITE_RUNTIME; + case -1: + case "UNRECOGNIZED": + default: + return FileOptions_OptimizeMode.UNRECOGNIZED; + } +} + +export function fileOptions_OptimizeModeToJSON( + object: FileOptions_OptimizeMode +): string { + switch (object) { + case FileOptions_OptimizeMode.SPEED: + return "SPEED"; + case FileOptions_OptimizeMode.CODE_SIZE: + return "CODE_SIZE"; + case FileOptions_OptimizeMode.LITE_RUNTIME: + return "LITE_RUNTIME"; + default: + return "UNKNOWN"; + } +} + +export interface MessageOptions { + /** + * Set true to use the old proto1 MessageSet wire format for extensions. + * This is provided for backwards-compatibility with the MessageSet wire + * format. You should not use this for any other reason: It's less + * efficient, has fewer features, and is more complicated. + * + * The message must be defined exactly as follows: + * message Foo { + * option message_set_wire_format = true; + * extensions 4 to max; + * } + * Note that the message cannot have any defined fields; MessageSets only + * have extensions. + * + * All extensions of your type must be singular messages; e.g. they cannot + * be int32s, enums, or repeated messages. + * + * Because this is an option, the above two restrictions are not enforced by + * the protocol compiler. + */ + messageSetWireFormat: boolean; + /** + * Disables the generation of the standard "descriptor()" accessor, which can + * conflict with a field of the same name. This is meant to make migration + * from proto1 easier; new code should avoid fields named "descriptor". + */ + noStandardDescriptorAccessor: boolean; + /** + * Is this message deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the message, or it will be completely ignored; in the very least, + * this is a formalization for deprecating messages. + */ + deprecated: boolean; + /** + * Whether the message is an automatically generated map entry type for the + * maps field. + * + * For maps fields: + * map map_field = 1; + * The parsed descriptor looks like: + * message MapFieldEntry { + * option map_entry = true; + * optional KeyType key = 1; + * optional ValueType value = 2; + * } + * repeated MapFieldEntry map_field = 1; + * + * Implementations may choose not to generate the map_entry=true message, but + * use a native map in the target language to hold the keys and values. + * The reflection APIs in such implementations still need to work as + * if the field is a repeated message field. + * + * NOTE: Do not set the option in .proto files. Always use the maps syntax + * instead. The option should only be implicitly set by the proto compiler + * parser. + */ + mapEntry: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface FieldOptions { + /** + * The ctype option instructs the C++ code generator to use a different + * representation of the field than it normally would. See the specific + * options below. This option is not yet implemented in the open source + * release -- sorry, we'll try to include it in a future version! + */ + ctype: FieldOptions_CType; + /** + * The packed option can be enabled for repeated primitive fields to enable + * a more efficient representation on the wire. Rather than repeatedly + * writing the tag and type for each element, the entire array is encoded as + * a single length-delimited blob. In proto3, only explicit setting it to + * false will avoid using packed encoding. + */ + packed: boolean; + /** + * The jstype option determines the JavaScript type used for values of the + * field. The option is permitted only for 64 bit integral and fixed types + * (int64, uint64, sint64, fixed64, sfixed64). A field with jstype JS_STRING + * is represented as JavaScript string, which avoids loss of precision that + * can happen when a large value is converted to a floating point JavaScript. + * Specifying JS_NUMBER for the jstype causes the generated JavaScript code to + * use the JavaScript "number" type. The behavior of the default option + * JS_NORMAL is implementation dependent. + * + * This option is an enum to permit additional types to be added, e.g. + * goog.math.Integer. + */ + jstype: FieldOptions_JSType; + /** + * Should this field be parsed lazily? Lazy applies only to message-type + * fields. It means that when the outer message is initially parsed, the + * inner message's contents will not be parsed but instead stored in encoded + * form. The inner message will actually be parsed when it is first accessed. + * + * This is only a hint. Implementations are free to choose whether to use + * eager or lazy parsing regardless of the value of this option. However, + * setting this option true suggests that the protocol author believes that + * using lazy parsing on this field is worth the additional bookkeeping + * overhead typically needed to implement it. + * + * This option does not affect the public interface of any generated code; + * all method signatures remain the same. Furthermore, thread-safety of the + * interface is not affected by this option; const methods remain safe to + * call from multiple threads concurrently, while non-const methods continue + * to require exclusive access. + * + * + * Note that implementations may choose not to check required fields within + * a lazy sub-message. That is, calling IsInitialized() on the outer message + * may return true even if the inner message has missing required fields. + * This is necessary because otherwise the inner message would have to be + * parsed in order to perform the check, defeating the purpose of lazy + * parsing. An implementation which chooses not to check required fields + * must be consistent about it. That is, for any particular sub-message, the + * implementation must either *always* check its required fields, or *never* + * check its required fields, regardless of whether or not the message has + * been parsed. + */ + lazy: boolean; + /** + * Is this field deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for accessors, or it will be completely ignored; in the very least, this + * is a formalization for deprecating fields. + */ + deprecated: boolean; + /** For Google-internal migration only. Do not use. */ + weak: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export enum FieldOptions_CType { + /** STRING - Default mode. */ + STRING = 0, + CORD = 1, + STRING_PIECE = 2, + UNRECOGNIZED = -1, +} + +export function fieldOptions_CTypeFromJSON(object: any): FieldOptions_CType { + switch (object) { + case 0: + case "STRING": + return FieldOptions_CType.STRING; + case 1: + case "CORD": + return FieldOptions_CType.CORD; + case 2: + case "STRING_PIECE": + return FieldOptions_CType.STRING_PIECE; + case -1: + case "UNRECOGNIZED": + default: + return FieldOptions_CType.UNRECOGNIZED; + } +} + +export function fieldOptions_CTypeToJSON(object: FieldOptions_CType): string { + switch (object) { + case FieldOptions_CType.STRING: + return "STRING"; + case FieldOptions_CType.CORD: + return "CORD"; + case FieldOptions_CType.STRING_PIECE: + return "STRING_PIECE"; + default: + return "UNKNOWN"; + } +} + +export enum FieldOptions_JSType { + /** JS_NORMAL - Use the default type. */ + JS_NORMAL = 0, + /** JS_STRING - Use JavaScript strings. */ + JS_STRING = 1, + /** JS_NUMBER - Use JavaScript numbers. */ + JS_NUMBER = 2, + UNRECOGNIZED = -1, +} + +export function fieldOptions_JSTypeFromJSON(object: any): FieldOptions_JSType { + switch (object) { + case 0: + case "JS_NORMAL": + return FieldOptions_JSType.JS_NORMAL; + case 1: + case "JS_STRING": + return FieldOptions_JSType.JS_STRING; + case 2: + case "JS_NUMBER": + return FieldOptions_JSType.JS_NUMBER; + case -1: + case "UNRECOGNIZED": + default: + return FieldOptions_JSType.UNRECOGNIZED; + } +} + +export function fieldOptions_JSTypeToJSON(object: FieldOptions_JSType): string { + switch (object) { + case FieldOptions_JSType.JS_NORMAL: + return "JS_NORMAL"; + case FieldOptions_JSType.JS_STRING: + return "JS_STRING"; + case FieldOptions_JSType.JS_NUMBER: + return "JS_NUMBER"; + default: + return "UNKNOWN"; + } +} + +export interface OneofOptions { + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface EnumOptions { + /** + * Set this option to true to allow mapping different tag names to the same + * value. + */ + allowAlias: boolean; + /** + * Is this enum deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the enum, or it will be completely ignored; in the very least, this + * is a formalization for deprecating enums. + */ + deprecated: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface EnumValueOptions { + /** + * Is this enum value deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the enum value, or it will be completely ignored; in the very least, + * this is a formalization for deprecating enum values. + */ + deprecated: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface ServiceOptions { + /** + * Is this service deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the service, or it will be completely ignored; in the very least, + * this is a formalization for deprecating services. + */ + deprecated: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface MethodOptions { + /** + * Is this method deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the method, or it will be completely ignored; in the very least, + * this is a formalization for deprecating methods. + */ + deprecated: boolean; + idempotencyLevel: MethodOptions_IdempotencyLevel; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +/** + * Is this method side-effect-free (or safe in HTTP parlance), or idempotent, + * or neither? HTTP based RPC implementation may choose GET verb for safe + * methods, and PUT verb for idempotent methods instead of the default POST. + */ +export enum MethodOptions_IdempotencyLevel { + IDEMPOTENCY_UNKNOWN = 0, + /** NO_SIDE_EFFECTS - implies idempotent */ + NO_SIDE_EFFECTS = 1, + /** IDEMPOTENT - idempotent, but may have side effects */ + IDEMPOTENT = 2, + UNRECOGNIZED = -1, +} + +export function methodOptions_IdempotencyLevelFromJSON( + object: any +): MethodOptions_IdempotencyLevel { + switch (object) { + case 0: + case "IDEMPOTENCY_UNKNOWN": + return MethodOptions_IdempotencyLevel.IDEMPOTENCY_UNKNOWN; + case 1: + case "NO_SIDE_EFFECTS": + return MethodOptions_IdempotencyLevel.NO_SIDE_EFFECTS; + case 2: + case "IDEMPOTENT": + return MethodOptions_IdempotencyLevel.IDEMPOTENT; + case -1: + case "UNRECOGNIZED": + default: + return MethodOptions_IdempotencyLevel.UNRECOGNIZED; + } +} + +export function methodOptions_IdempotencyLevelToJSON( + object: MethodOptions_IdempotencyLevel +): string { + switch (object) { + case MethodOptions_IdempotencyLevel.IDEMPOTENCY_UNKNOWN: + return "IDEMPOTENCY_UNKNOWN"; + case MethodOptions_IdempotencyLevel.NO_SIDE_EFFECTS: + return "NO_SIDE_EFFECTS"; + case MethodOptions_IdempotencyLevel.IDEMPOTENT: + return "IDEMPOTENT"; + default: + return "UNKNOWN"; + } +} + +/** + * A message representing a option the parser does not recognize. This only + * appears in options protos created by the compiler::Parser class. + * DescriptorPool resolves these when building Descriptor objects. Therefore, + * options protos in descriptor objects (e.g. returned by Descriptor::options(), + * or produced by Descriptor::CopyTo()) will never have UninterpretedOptions + * in them. + */ +export interface UninterpretedOption { + name: UninterpretedOption_NamePart[]; + /** + * The value of the uninterpreted option, in whatever type the tokenizer + * identified it as during parsing. Exactly one of these should be set. + */ + identifierValue: string; + positiveIntValue: number; + negativeIntValue: number; + doubleValue: number; + stringValue: Uint8Array; + aggregateValue: string; +} + +/** + * The name of the uninterpreted option. Each string represents a segment in + * a dot-separated name. is_extension is true iff a segment represents an + * extension (denoted with parentheses in options specs in .proto files). + * E.g.,{ ["foo", false], ["bar.baz", true], ["qux", false] } represents + * "foo.(bar.baz).qux". + */ +export interface UninterpretedOption_NamePart { + namePart: string; + isExtension: boolean; +} + +/** + * Encapsulates information about the original source file from which a + * FileDescriptorProto was generated. + */ +export interface SourceCodeInfo { + /** + * A Location identifies a piece of source code in a .proto file which + * corresponds to a particular definition. This information is intended + * to be useful to IDEs, code indexers, documentation generators, and similar + * tools. + * + * For example, say we have a file like: + * message Foo { + * optional string foo = 1; + * } + * Let's look at just the field definition: + * optional string foo = 1; + * ^ ^^ ^^ ^ ^^^ + * a bc de f ghi + * We have the following locations: + * span path represents + * [a,i) [ 4, 0, 2, 0 ] The whole field definition. + * [a,b) [ 4, 0, 2, 0, 4 ] The label (optional). + * [c,d) [ 4, 0, 2, 0, 5 ] The type (string). + * [e,f) [ 4, 0, 2, 0, 1 ] The name (foo). + * [g,h) [ 4, 0, 2, 0, 3 ] The number (1). + * + * Notes: + * - A location may refer to a repeated field itself (i.e. not to any + * particular index within it). This is used whenever a set of elements are + * logically enclosed in a single code segment. For example, an entire + * extend block (possibly containing multiple extension definitions) will + * have an outer location whose path refers to the "extensions" repeated + * field without an index. + * - Multiple locations may have the same path. This happens when a single + * logical declaration is spread out across multiple places. The most + * obvious example is the "extend" block again -- there may be multiple + * extend blocks in the same scope, each of which will have the same path. + * - A location's span is not always a subset of its parent's span. For + * example, the "extendee" of an extension declaration appears at the + * beginning of the "extend" block and is shared by all extensions within + * the block. + * - Just because a location's span is a subset of some other location's span + * does not mean that it is a descendant. For example, a "group" defines + * both a type and a field in a single declaration. Thus, the locations + * corresponding to the type and field and their components will overlap. + * - Code which tries to interpret locations should probably be designed to + * ignore those that it doesn't understand, as more types of locations could + * be recorded in the future. + */ + location: SourceCodeInfo_Location[]; +} + +export interface SourceCodeInfo_Location { + /** + * Identifies which part of the FileDescriptorProto was defined at this + * location. + * + * Each element is a field number or an index. They form a path from + * the root FileDescriptorProto to the place where the definition. For + * example, this path: + * [ 4, 3, 2, 7, 1 ] + * refers to: + * file.message_type(3) // 4, 3 + * .field(7) // 2, 7 + * .name() // 1 + * This is because FileDescriptorProto.message_type has field number 4: + * repeated DescriptorProto message_type = 4; + * and DescriptorProto.field has field number 2: + * repeated FieldDescriptorProto field = 2; + * and FieldDescriptorProto.name has field number 1: + * optional string name = 1; + * + * Thus, the above path gives the location of a field name. If we removed + * the last element: + * [ 4, 3, 2, 7 ] + * this path refers to the whole field declaration (from the beginning + * of the label to the terminating semicolon). + */ + path: number[]; + /** + * Always has exactly three or four elements: start line, start column, + * end line (optional, otherwise assumed same as start line), end column. + * These are packed into a single field for efficiency. Note that line + * and column numbers are zero-based -- typically you will want to add + * 1 to each before displaying to a user. + */ + span: number[]; + /** + * If this SourceCodeInfo represents a complete declaration, these are any + * comments appearing before and after the declaration which appear to be + * attached to the declaration. + * + * A series of line comments appearing on consecutive lines, with no other + * tokens appearing on those lines, will be treated as a single comment. + * + * leading_detached_comments will keep paragraphs of comments that appear + * before (but not connected to) the current element. Each paragraph, + * separated by empty lines, will be one comment element in the repeated + * field. + * + * Only the comment content is provided; comment markers (e.g. //) are + * stripped out. For block comments, leading whitespace and an asterisk + * will be stripped from the beginning of each line other than the first. + * Newlines are included in the output. + * + * Examples: + * + * optional int32 foo = 1; // Comment attached to foo. + * // Comment attached to bar. + * optional int32 bar = 2; + * + * optional string baz = 3; + * // Comment attached to baz. + * // Another line attached to baz. + * + * // Comment attached to qux. + * // + * // Another line attached to qux. + * optional double qux = 4; + * + * // Detached comment for corge. This is not leading or trailing comments + * // to qux or corge because there are blank lines separating it from + * // both. + * + * // Detached comment for corge paragraph 2. + * + * optional string corge = 5; + * /* Block comment attached + * * to corge. Leading asterisks + * * will be removed. * / + * /* Block comment attached to + * * grault. * / + * optional int32 grault = 6; + * + * // ignored detached comments. + */ + leadingComments: string; + trailingComments: string; + leadingDetachedComments: string[]; +} + +/** + * Describes the relationship between generated code and its original source + * file. A GeneratedCodeInfo message is associated with only one generated + * source file, but may contain references to different source .proto files. + */ +export interface GeneratedCodeInfo { + /** + * An Annotation connects some span of text in generated code to an element + * of its generating .proto file. + */ + annotation: GeneratedCodeInfo_Annotation[]; +} + +export interface GeneratedCodeInfo_Annotation { + /** + * Identifies the element in the original source .proto file. This field + * is formatted the same as SourceCodeInfo.Location.path. + */ + path: number[]; + /** Identifies the filesystem path to the original source .proto. */ + sourceFile: string; + /** + * Identifies the starting offset in bytes in the generated code + * that relates to the identified object. + */ + begin: number; + /** + * Identifies the ending offset in bytes in the generated code that + * relates to the identified offset. The end offset should be one past + * the last relevant byte (so the length of the text = end - begin). + */ + end: number; +} + +const baseFileDescriptorSet: object = {}; + +export const FileDescriptorSet = { + encode(message: FileDescriptorSet, writer: Writer = Writer.create()): Writer { + for (const v of message.file) { + FileDescriptorProto.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FileDescriptorSet { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFileDescriptorSet } as FileDescriptorSet; + message.file = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.file.push( + FileDescriptorProto.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FileDescriptorSet { + const message = { ...baseFileDescriptorSet } as FileDescriptorSet; + message.file = []; + if (object.file !== undefined && object.file !== null) { + for (const e of object.file) { + message.file.push(FileDescriptorProto.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: FileDescriptorSet): unknown { + const obj: any = {}; + if (message.file) { + obj.file = message.file.map((e) => + e ? FileDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.file = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): FileDescriptorSet { + const message = { ...baseFileDescriptorSet } as FileDescriptorSet; + message.file = []; + if (object.file !== undefined && object.file !== null) { + for (const e of object.file) { + message.file.push(FileDescriptorProto.fromPartial(e)); + } + } + return message; + }, +}; + +const baseFileDescriptorProto: object = { + name: "", + package: "", + dependency: "", + publicDependency: 0, + weakDependency: 0, + syntax: "", +}; + +export const FileDescriptorProto = { + encode( + message: FileDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.package !== "") { + writer.uint32(18).string(message.package); + } + for (const v of message.dependency) { + writer.uint32(26).string(v!); + } + writer.uint32(82).fork(); + for (const v of message.publicDependency) { + writer.int32(v); + } + writer.ldelim(); + writer.uint32(90).fork(); + for (const v of message.weakDependency) { + writer.int32(v); + } + writer.ldelim(); + for (const v of message.messageType) { + DescriptorProto.encode(v!, writer.uint32(34).fork()).ldelim(); + } + for (const v of message.enumType) { + EnumDescriptorProto.encode(v!, writer.uint32(42).fork()).ldelim(); + } + for (const v of message.service) { + ServiceDescriptorProto.encode(v!, writer.uint32(50).fork()).ldelim(); + } + for (const v of message.extension) { + FieldDescriptorProto.encode(v!, writer.uint32(58).fork()).ldelim(); + } + if (message.options !== undefined) { + FileOptions.encode(message.options, writer.uint32(66).fork()).ldelim(); + } + if (message.sourceCodeInfo !== undefined) { + SourceCodeInfo.encode( + message.sourceCodeInfo, + writer.uint32(74).fork() + ).ldelim(); + } + if (message.syntax !== "") { + writer.uint32(98).string(message.syntax); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FileDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFileDescriptorProto } as FileDescriptorProto; + message.dependency = []; + message.publicDependency = []; + message.weakDependency = []; + message.messageType = []; + message.enumType = []; + message.service = []; + message.extension = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.package = reader.string(); + break; + case 3: + message.dependency.push(reader.string()); + break; + case 10: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.publicDependency.push(reader.int32()); + } + } else { + message.publicDependency.push(reader.int32()); + } + break; + case 11: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.weakDependency.push(reader.int32()); + } + } else { + message.weakDependency.push(reader.int32()); + } + break; + case 4: + message.messageType.push( + DescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 5: + message.enumType.push( + EnumDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 6: + message.service.push( + ServiceDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 7: + message.extension.push( + FieldDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 8: + message.options = FileOptions.decode(reader, reader.uint32()); + break; + case 9: + message.sourceCodeInfo = SourceCodeInfo.decode( + reader, + reader.uint32() + ); + break; + case 12: + message.syntax = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FileDescriptorProto { + const message = { ...baseFileDescriptorProto } as FileDescriptorProto; + message.dependency = []; + message.publicDependency = []; + message.weakDependency = []; + message.messageType = []; + message.enumType = []; + message.service = []; + message.extension = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.package !== undefined && object.package !== null) { + message.package = String(object.package); + } else { + message.package = ""; + } + if (object.dependency !== undefined && object.dependency !== null) { + for (const e of object.dependency) { + message.dependency.push(String(e)); + } + } + if ( + object.publicDependency !== undefined && + object.publicDependency !== null + ) { + for (const e of object.publicDependency) { + message.publicDependency.push(Number(e)); + } + } + if (object.weakDependency !== undefined && object.weakDependency !== null) { + for (const e of object.weakDependency) { + message.weakDependency.push(Number(e)); + } + } + if (object.messageType !== undefined && object.messageType !== null) { + for (const e of object.messageType) { + message.messageType.push(DescriptorProto.fromJSON(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromJSON(e)); + } + } + if (object.service !== undefined && object.service !== null) { + for (const e of object.service) { + message.service.push(ServiceDescriptorProto.fromJSON(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = FileOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.sourceCodeInfo !== undefined && object.sourceCodeInfo !== null) { + message.sourceCodeInfo = SourceCodeInfo.fromJSON(object.sourceCodeInfo); + } else { + message.sourceCodeInfo = undefined; + } + if (object.syntax !== undefined && object.syntax !== null) { + message.syntax = String(object.syntax); + } else { + message.syntax = ""; + } + return message; + }, + + toJSON(message: FileDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.package !== undefined && (obj.package = message.package); + if (message.dependency) { + obj.dependency = message.dependency.map((e) => e); + } else { + obj.dependency = []; + } + if (message.publicDependency) { + obj.publicDependency = message.publicDependency.map((e) => e); + } else { + obj.publicDependency = []; + } + if (message.weakDependency) { + obj.weakDependency = message.weakDependency.map((e) => e); + } else { + obj.weakDependency = []; + } + if (message.messageType) { + obj.messageType = message.messageType.map((e) => + e ? DescriptorProto.toJSON(e) : undefined + ); + } else { + obj.messageType = []; + } + if (message.enumType) { + obj.enumType = message.enumType.map((e) => + e ? EnumDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.enumType = []; + } + if (message.service) { + obj.service = message.service.map((e) => + e ? ServiceDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.service = []; + } + if (message.extension) { + obj.extension = message.extension.map((e) => + e ? FieldDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.extension = []; + } + message.options !== undefined && + (obj.options = message.options + ? FileOptions.toJSON(message.options) + : undefined); + message.sourceCodeInfo !== undefined && + (obj.sourceCodeInfo = message.sourceCodeInfo + ? SourceCodeInfo.toJSON(message.sourceCodeInfo) + : undefined); + message.syntax !== undefined && (obj.syntax = message.syntax); + return obj; + }, + + fromPartial(object: DeepPartial): FileDescriptorProto { + const message = { ...baseFileDescriptorProto } as FileDescriptorProto; + message.dependency = []; + message.publicDependency = []; + message.weakDependency = []; + message.messageType = []; + message.enumType = []; + message.service = []; + message.extension = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.package !== undefined && object.package !== null) { + message.package = object.package; + } else { + message.package = ""; + } + if (object.dependency !== undefined && object.dependency !== null) { + for (const e of object.dependency) { + message.dependency.push(e); + } + } + if ( + object.publicDependency !== undefined && + object.publicDependency !== null + ) { + for (const e of object.publicDependency) { + message.publicDependency.push(e); + } + } + if (object.weakDependency !== undefined && object.weakDependency !== null) { + for (const e of object.weakDependency) { + message.weakDependency.push(e); + } + } + if (object.messageType !== undefined && object.messageType !== null) { + for (const e of object.messageType) { + message.messageType.push(DescriptorProto.fromPartial(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromPartial(e)); + } + } + if (object.service !== undefined && object.service !== null) { + for (const e of object.service) { + message.service.push(ServiceDescriptorProto.fromPartial(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = FileOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.sourceCodeInfo !== undefined && object.sourceCodeInfo !== null) { + message.sourceCodeInfo = SourceCodeInfo.fromPartial( + object.sourceCodeInfo + ); + } else { + message.sourceCodeInfo = undefined; + } + if (object.syntax !== undefined && object.syntax !== null) { + message.syntax = object.syntax; + } else { + message.syntax = ""; + } + return message; + }, +}; + +const baseDescriptorProto: object = { name: "", reservedName: "" }; + +export const DescriptorProto = { + encode(message: DescriptorProto, writer: Writer = Writer.create()): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + for (const v of message.field) { + FieldDescriptorProto.encode(v!, writer.uint32(18).fork()).ldelim(); + } + for (const v of message.extension) { + FieldDescriptorProto.encode(v!, writer.uint32(50).fork()).ldelim(); + } + for (const v of message.nestedType) { + DescriptorProto.encode(v!, writer.uint32(26).fork()).ldelim(); + } + for (const v of message.enumType) { + EnumDescriptorProto.encode(v!, writer.uint32(34).fork()).ldelim(); + } + for (const v of message.extensionRange) { + DescriptorProto_ExtensionRange.encode( + v!, + writer.uint32(42).fork() + ).ldelim(); + } + for (const v of message.oneofDecl) { + OneofDescriptorProto.encode(v!, writer.uint32(66).fork()).ldelim(); + } + if (message.options !== undefined) { + MessageOptions.encode(message.options, writer.uint32(58).fork()).ldelim(); + } + for (const v of message.reservedRange) { + DescriptorProto_ReservedRange.encode( + v!, + writer.uint32(74).fork() + ).ldelim(); + } + for (const v of message.reservedName) { + writer.uint32(82).string(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): DescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseDescriptorProto } as DescriptorProto; + message.field = []; + message.extension = []; + message.nestedType = []; + message.enumType = []; + message.extensionRange = []; + message.oneofDecl = []; + message.reservedRange = []; + message.reservedName = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.field.push( + FieldDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 6: + message.extension.push( + FieldDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 3: + message.nestedType.push( + DescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 4: + message.enumType.push( + EnumDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 5: + message.extensionRange.push( + DescriptorProto_ExtensionRange.decode(reader, reader.uint32()) + ); + break; + case 8: + message.oneofDecl.push( + OneofDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 7: + message.options = MessageOptions.decode(reader, reader.uint32()); + break; + case 9: + message.reservedRange.push( + DescriptorProto_ReservedRange.decode(reader, reader.uint32()) + ); + break; + case 10: + message.reservedName.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DescriptorProto { + const message = { ...baseDescriptorProto } as DescriptorProto; + message.field = []; + message.extension = []; + message.nestedType = []; + message.enumType = []; + message.extensionRange = []; + message.oneofDecl = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.field !== undefined && object.field !== null) { + for (const e of object.field) { + message.field.push(FieldDescriptorProto.fromJSON(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromJSON(e)); + } + } + if (object.nestedType !== undefined && object.nestedType !== null) { + for (const e of object.nestedType) { + message.nestedType.push(DescriptorProto.fromJSON(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromJSON(e)); + } + } + if (object.extensionRange !== undefined && object.extensionRange !== null) { + for (const e of object.extensionRange) { + message.extensionRange.push(DescriptorProto_ExtensionRange.fromJSON(e)); + } + } + if (object.oneofDecl !== undefined && object.oneofDecl !== null) { + for (const e of object.oneofDecl) { + message.oneofDecl.push(OneofDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = MessageOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push(DescriptorProto_ReservedRange.fromJSON(e)); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(String(e)); + } + } + return message; + }, + + toJSON(message: DescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + if (message.field) { + obj.field = message.field.map((e) => + e ? FieldDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.field = []; + } + if (message.extension) { + obj.extension = message.extension.map((e) => + e ? FieldDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.extension = []; + } + if (message.nestedType) { + obj.nestedType = message.nestedType.map((e) => + e ? DescriptorProto.toJSON(e) : undefined + ); + } else { + obj.nestedType = []; + } + if (message.enumType) { + obj.enumType = message.enumType.map((e) => + e ? EnumDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.enumType = []; + } + if (message.extensionRange) { + obj.extensionRange = message.extensionRange.map((e) => + e ? DescriptorProto_ExtensionRange.toJSON(e) : undefined + ); + } else { + obj.extensionRange = []; + } + if (message.oneofDecl) { + obj.oneofDecl = message.oneofDecl.map((e) => + e ? OneofDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.oneofDecl = []; + } + message.options !== undefined && + (obj.options = message.options + ? MessageOptions.toJSON(message.options) + : undefined); + if (message.reservedRange) { + obj.reservedRange = message.reservedRange.map((e) => + e ? DescriptorProto_ReservedRange.toJSON(e) : undefined + ); + } else { + obj.reservedRange = []; + } + if (message.reservedName) { + obj.reservedName = message.reservedName.map((e) => e); + } else { + obj.reservedName = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): DescriptorProto { + const message = { ...baseDescriptorProto } as DescriptorProto; + message.field = []; + message.extension = []; + message.nestedType = []; + message.enumType = []; + message.extensionRange = []; + message.oneofDecl = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.field !== undefined && object.field !== null) { + for (const e of object.field) { + message.field.push(FieldDescriptorProto.fromPartial(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromPartial(e)); + } + } + if (object.nestedType !== undefined && object.nestedType !== null) { + for (const e of object.nestedType) { + message.nestedType.push(DescriptorProto.fromPartial(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromPartial(e)); + } + } + if (object.extensionRange !== undefined && object.extensionRange !== null) { + for (const e of object.extensionRange) { + message.extensionRange.push( + DescriptorProto_ExtensionRange.fromPartial(e) + ); + } + } + if (object.oneofDecl !== undefined && object.oneofDecl !== null) { + for (const e of object.oneofDecl) { + message.oneofDecl.push(OneofDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = MessageOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push( + DescriptorProto_ReservedRange.fromPartial(e) + ); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(e); + } + } + return message; + }, +}; + +const baseDescriptorProto_ExtensionRange: object = { start: 0, end: 0 }; + +export const DescriptorProto_ExtensionRange = { + encode( + message: DescriptorProto_ExtensionRange, + writer: Writer = Writer.create() + ): Writer { + if (message.start !== 0) { + writer.uint32(8).int32(message.start); + } + if (message.end !== 0) { + writer.uint32(16).int32(message.end); + } + if (message.options !== undefined) { + ExtensionRangeOptions.encode( + message.options, + writer.uint32(26).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): DescriptorProto_ExtensionRange { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseDescriptorProto_ExtensionRange, + } as DescriptorProto_ExtensionRange; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.start = reader.int32(); + break; + case 2: + message.end = reader.int32(); + break; + case 3: + message.options = ExtensionRangeOptions.decode( + reader, + reader.uint32() + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DescriptorProto_ExtensionRange { + const message = { + ...baseDescriptorProto_ExtensionRange, + } as DescriptorProto_ExtensionRange; + if (object.start !== undefined && object.start !== null) { + message.start = Number(object.start); + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = ExtensionRangeOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: DescriptorProto_ExtensionRange): unknown { + const obj: any = {}; + message.start !== undefined && (obj.start = message.start); + message.end !== undefined && (obj.end = message.end); + message.options !== undefined && + (obj.options = message.options + ? ExtensionRangeOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): DescriptorProto_ExtensionRange { + const message = { + ...baseDescriptorProto_ExtensionRange, + } as DescriptorProto_ExtensionRange; + if (object.start !== undefined && object.start !== null) { + message.start = object.start; + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = ExtensionRangeOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseDescriptorProto_ReservedRange: object = { start: 0, end: 0 }; + +export const DescriptorProto_ReservedRange = { + encode( + message: DescriptorProto_ReservedRange, + writer: Writer = Writer.create() + ): Writer { + if (message.start !== 0) { + writer.uint32(8).int32(message.start); + } + if (message.end !== 0) { + writer.uint32(16).int32(message.end); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): DescriptorProto_ReservedRange { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseDescriptorProto_ReservedRange, + } as DescriptorProto_ReservedRange; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.start = reader.int32(); + break; + case 2: + message.end = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DescriptorProto_ReservedRange { + const message = { + ...baseDescriptorProto_ReservedRange, + } as DescriptorProto_ReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = Number(object.start); + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + return message; + }, + + toJSON(message: DescriptorProto_ReservedRange): unknown { + const obj: any = {}; + message.start !== undefined && (obj.start = message.start); + message.end !== undefined && (obj.end = message.end); + return obj; + }, + + fromPartial( + object: DeepPartial + ): DescriptorProto_ReservedRange { + const message = { + ...baseDescriptorProto_ReservedRange, + } as DescriptorProto_ReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = object.start; + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + return message; + }, +}; + +const baseExtensionRangeOptions: object = {}; + +export const ExtensionRangeOptions = { + encode( + message: ExtensionRangeOptions, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ExtensionRangeOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseExtensionRangeOptions } as ExtensionRangeOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ExtensionRangeOptions { + const message = { ...baseExtensionRangeOptions } as ExtensionRangeOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: ExtensionRangeOptions): unknown { + const obj: any = {}; + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial( + object: DeepPartial + ): ExtensionRangeOptions { + const message = { ...baseExtensionRangeOptions } as ExtensionRangeOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseFieldDescriptorProto: object = { + name: "", + number: 0, + label: 1, + type: 1, + typeName: "", + extendee: "", + defaultValue: "", + oneofIndex: 0, + jsonName: "", + proto3Optional: false, +}; + +export const FieldDescriptorProto = { + encode( + message: FieldDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.number !== 0) { + writer.uint32(24).int32(message.number); + } + if (message.label !== 1) { + writer.uint32(32).int32(message.label); + } + if (message.type !== 1) { + writer.uint32(40).int32(message.type); + } + if (message.typeName !== "") { + writer.uint32(50).string(message.typeName); + } + if (message.extendee !== "") { + writer.uint32(18).string(message.extendee); + } + if (message.defaultValue !== "") { + writer.uint32(58).string(message.defaultValue); + } + if (message.oneofIndex !== 0) { + writer.uint32(72).int32(message.oneofIndex); + } + if (message.jsonName !== "") { + writer.uint32(82).string(message.jsonName); + } + if (message.options !== undefined) { + FieldOptions.encode(message.options, writer.uint32(66).fork()).ldelim(); + } + if (message.proto3Optional === true) { + writer.uint32(136).bool(message.proto3Optional); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FieldDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFieldDescriptorProto } as FieldDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 3: + message.number = reader.int32(); + break; + case 4: + message.label = reader.int32() as any; + break; + case 5: + message.type = reader.int32() as any; + break; + case 6: + message.typeName = reader.string(); + break; + case 2: + message.extendee = reader.string(); + break; + case 7: + message.defaultValue = reader.string(); + break; + case 9: + message.oneofIndex = reader.int32(); + break; + case 10: + message.jsonName = reader.string(); + break; + case 8: + message.options = FieldOptions.decode(reader, reader.uint32()); + break; + case 17: + message.proto3Optional = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FieldDescriptorProto { + const message = { ...baseFieldDescriptorProto } as FieldDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = Number(object.number); + } else { + message.number = 0; + } + if (object.label !== undefined && object.label !== null) { + message.label = fieldDescriptorProto_LabelFromJSON(object.label); + } else { + message.label = 1; + } + if (object.type !== undefined && object.type !== null) { + message.type = fieldDescriptorProto_TypeFromJSON(object.type); + } else { + message.type = 1; + } + if (object.typeName !== undefined && object.typeName !== null) { + message.typeName = String(object.typeName); + } else { + message.typeName = ""; + } + if (object.extendee !== undefined && object.extendee !== null) { + message.extendee = String(object.extendee); + } else { + message.extendee = ""; + } + if (object.defaultValue !== undefined && object.defaultValue !== null) { + message.defaultValue = String(object.defaultValue); + } else { + message.defaultValue = ""; + } + if (object.oneofIndex !== undefined && object.oneofIndex !== null) { + message.oneofIndex = Number(object.oneofIndex); + } else { + message.oneofIndex = 0; + } + if (object.jsonName !== undefined && object.jsonName !== null) { + message.jsonName = String(object.jsonName); + } else { + message.jsonName = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = FieldOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.proto3Optional !== undefined && object.proto3Optional !== null) { + message.proto3Optional = Boolean(object.proto3Optional); + } else { + message.proto3Optional = false; + } + return message; + }, + + toJSON(message: FieldDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.number !== undefined && (obj.number = message.number); + message.label !== undefined && + (obj.label = fieldDescriptorProto_LabelToJSON(message.label)); + message.type !== undefined && + (obj.type = fieldDescriptorProto_TypeToJSON(message.type)); + message.typeName !== undefined && (obj.typeName = message.typeName); + message.extendee !== undefined && (obj.extendee = message.extendee); + message.defaultValue !== undefined && + (obj.defaultValue = message.defaultValue); + message.oneofIndex !== undefined && (obj.oneofIndex = message.oneofIndex); + message.jsonName !== undefined && (obj.jsonName = message.jsonName); + message.options !== undefined && + (obj.options = message.options + ? FieldOptions.toJSON(message.options) + : undefined); + message.proto3Optional !== undefined && + (obj.proto3Optional = message.proto3Optional); + return obj; + }, + + fromPartial(object: DeepPartial): FieldDescriptorProto { + const message = { ...baseFieldDescriptorProto } as FieldDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = object.number; + } else { + message.number = 0; + } + if (object.label !== undefined && object.label !== null) { + message.label = object.label; + } else { + message.label = 1; + } + if (object.type !== undefined && object.type !== null) { + message.type = object.type; + } else { + message.type = 1; + } + if (object.typeName !== undefined && object.typeName !== null) { + message.typeName = object.typeName; + } else { + message.typeName = ""; + } + if (object.extendee !== undefined && object.extendee !== null) { + message.extendee = object.extendee; + } else { + message.extendee = ""; + } + if (object.defaultValue !== undefined && object.defaultValue !== null) { + message.defaultValue = object.defaultValue; + } else { + message.defaultValue = ""; + } + if (object.oneofIndex !== undefined && object.oneofIndex !== null) { + message.oneofIndex = object.oneofIndex; + } else { + message.oneofIndex = 0; + } + if (object.jsonName !== undefined && object.jsonName !== null) { + message.jsonName = object.jsonName; + } else { + message.jsonName = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = FieldOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.proto3Optional !== undefined && object.proto3Optional !== null) { + message.proto3Optional = object.proto3Optional; + } else { + message.proto3Optional = false; + } + return message; + }, +}; + +const baseOneofDescriptorProto: object = { name: "" }; + +export const OneofDescriptorProto = { + encode( + message: OneofDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.options !== undefined) { + OneofOptions.encode(message.options, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): OneofDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseOneofDescriptorProto } as OneofDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.options = OneofOptions.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): OneofDescriptorProto { + const message = { ...baseOneofDescriptorProto } as OneofDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = OneofOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: OneofDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.options !== undefined && + (obj.options = message.options + ? OneofOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): OneofDescriptorProto { + const message = { ...baseOneofDescriptorProto } as OneofDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = OneofOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseEnumDescriptorProto: object = { name: "", reservedName: "" }; + +export const EnumDescriptorProto = { + encode( + message: EnumDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + for (const v of message.value) { + EnumValueDescriptorProto.encode(v!, writer.uint32(18).fork()).ldelim(); + } + if (message.options !== undefined) { + EnumOptions.encode(message.options, writer.uint32(26).fork()).ldelim(); + } + for (const v of message.reservedRange) { + EnumDescriptorProto_EnumReservedRange.encode( + v!, + writer.uint32(34).fork() + ).ldelim(); + } + for (const v of message.reservedName) { + writer.uint32(42).string(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): EnumDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseEnumDescriptorProto } as EnumDescriptorProto; + message.value = []; + message.reservedRange = []; + message.reservedName = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.value.push( + EnumValueDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 3: + message.options = EnumOptions.decode(reader, reader.uint32()); + break; + case 4: + message.reservedRange.push( + EnumDescriptorProto_EnumReservedRange.decode( + reader, + reader.uint32() + ) + ); + break; + case 5: + message.reservedName.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumDescriptorProto { + const message = { ...baseEnumDescriptorProto } as EnumDescriptorProto; + message.value = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.value !== undefined && object.value !== null) { + for (const e of object.value) { + message.value.push(EnumValueDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push( + EnumDescriptorProto_EnumReservedRange.fromJSON(e) + ); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(String(e)); + } + } + return message; + }, + + toJSON(message: EnumDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + if (message.value) { + obj.value = message.value.map((e) => + e ? EnumValueDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.value = []; + } + message.options !== undefined && + (obj.options = message.options + ? EnumOptions.toJSON(message.options) + : undefined); + if (message.reservedRange) { + obj.reservedRange = message.reservedRange.map((e) => + e ? EnumDescriptorProto_EnumReservedRange.toJSON(e) : undefined + ); + } else { + obj.reservedRange = []; + } + if (message.reservedName) { + obj.reservedName = message.reservedName.map((e) => e); + } else { + obj.reservedName = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): EnumDescriptorProto { + const message = { ...baseEnumDescriptorProto } as EnumDescriptorProto; + message.value = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.value !== undefined && object.value !== null) { + for (const e of object.value) { + message.value.push(EnumValueDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push( + EnumDescriptorProto_EnumReservedRange.fromPartial(e) + ); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(e); + } + } + return message; + }, +}; + +const baseEnumDescriptorProto_EnumReservedRange: object = { start: 0, end: 0 }; + +export const EnumDescriptorProto_EnumReservedRange = { + encode( + message: EnumDescriptorProto_EnumReservedRange, + writer: Writer = Writer.create() + ): Writer { + if (message.start !== 0) { + writer.uint32(8).int32(message.start); + } + if (message.end !== 0) { + writer.uint32(16).int32(message.end); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): EnumDescriptorProto_EnumReservedRange { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseEnumDescriptorProto_EnumReservedRange, + } as EnumDescriptorProto_EnumReservedRange; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.start = reader.int32(); + break; + case 2: + message.end = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumDescriptorProto_EnumReservedRange { + const message = { + ...baseEnumDescriptorProto_EnumReservedRange, + } as EnumDescriptorProto_EnumReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = Number(object.start); + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + return message; + }, + + toJSON(message: EnumDescriptorProto_EnumReservedRange): unknown { + const obj: any = {}; + message.start !== undefined && (obj.start = message.start); + message.end !== undefined && (obj.end = message.end); + return obj; + }, + + fromPartial( + object: DeepPartial + ): EnumDescriptorProto_EnumReservedRange { + const message = { + ...baseEnumDescriptorProto_EnumReservedRange, + } as EnumDescriptorProto_EnumReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = object.start; + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + return message; + }, +}; + +const baseEnumValueDescriptorProto: object = { name: "", number: 0 }; + +export const EnumValueDescriptorProto = { + encode( + message: EnumValueDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.number !== 0) { + writer.uint32(16).int32(message.number); + } + if (message.options !== undefined) { + EnumValueOptions.encode( + message.options, + writer.uint32(26).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): EnumValueDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseEnumValueDescriptorProto, + } as EnumValueDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.number = reader.int32(); + break; + case 3: + message.options = EnumValueOptions.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumValueDescriptorProto { + const message = { + ...baseEnumValueDescriptorProto, + } as EnumValueDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = Number(object.number); + } else { + message.number = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumValueOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: EnumValueDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.number !== undefined && (obj.number = message.number); + message.options !== undefined && + (obj.options = message.options + ? EnumValueOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): EnumValueDescriptorProto { + const message = { + ...baseEnumValueDescriptorProto, + } as EnumValueDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = object.number; + } else { + message.number = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumValueOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseServiceDescriptorProto: object = { name: "" }; + +export const ServiceDescriptorProto = { + encode( + message: ServiceDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + for (const v of message.method) { + MethodDescriptorProto.encode(v!, writer.uint32(18).fork()).ldelim(); + } + if (message.options !== undefined) { + ServiceOptions.encode(message.options, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ServiceDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseServiceDescriptorProto } as ServiceDescriptorProto; + message.method = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.method.push( + MethodDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 3: + message.options = ServiceOptions.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ServiceDescriptorProto { + const message = { ...baseServiceDescriptorProto } as ServiceDescriptorProto; + message.method = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.method !== undefined && object.method !== null) { + for (const e of object.method) { + message.method.push(MethodDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = ServiceOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: ServiceDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + if (message.method) { + obj.method = message.method.map((e) => + e ? MethodDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.method = []; + } + message.options !== undefined && + (obj.options = message.options + ? ServiceOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): ServiceDescriptorProto { + const message = { ...baseServiceDescriptorProto } as ServiceDescriptorProto; + message.method = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.method !== undefined && object.method !== null) { + for (const e of object.method) { + message.method.push(MethodDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = ServiceOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseMethodDescriptorProto: object = { + name: "", + inputType: "", + outputType: "", + clientStreaming: false, + serverStreaming: false, +}; + +export const MethodDescriptorProto = { + encode( + message: MethodDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.inputType !== "") { + writer.uint32(18).string(message.inputType); + } + if (message.outputType !== "") { + writer.uint32(26).string(message.outputType); + } + if (message.options !== undefined) { + MethodOptions.encode(message.options, writer.uint32(34).fork()).ldelim(); + } + if (message.clientStreaming === true) { + writer.uint32(40).bool(message.clientStreaming); + } + if (message.serverStreaming === true) { + writer.uint32(48).bool(message.serverStreaming); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MethodDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMethodDescriptorProto } as MethodDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.inputType = reader.string(); + break; + case 3: + message.outputType = reader.string(); + break; + case 4: + message.options = MethodOptions.decode(reader, reader.uint32()); + break; + case 5: + message.clientStreaming = reader.bool(); + break; + case 6: + message.serverStreaming = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MethodDescriptorProto { + const message = { ...baseMethodDescriptorProto } as MethodDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.inputType !== undefined && object.inputType !== null) { + message.inputType = String(object.inputType); + } else { + message.inputType = ""; + } + if (object.outputType !== undefined && object.outputType !== null) { + message.outputType = String(object.outputType); + } else { + message.outputType = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = MethodOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if ( + object.clientStreaming !== undefined && + object.clientStreaming !== null + ) { + message.clientStreaming = Boolean(object.clientStreaming); + } else { + message.clientStreaming = false; + } + if ( + object.serverStreaming !== undefined && + object.serverStreaming !== null + ) { + message.serverStreaming = Boolean(object.serverStreaming); + } else { + message.serverStreaming = false; + } + return message; + }, + + toJSON(message: MethodDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.inputType !== undefined && (obj.inputType = message.inputType); + message.outputType !== undefined && (obj.outputType = message.outputType); + message.options !== undefined && + (obj.options = message.options + ? MethodOptions.toJSON(message.options) + : undefined); + message.clientStreaming !== undefined && + (obj.clientStreaming = message.clientStreaming); + message.serverStreaming !== undefined && + (obj.serverStreaming = message.serverStreaming); + return obj; + }, + + fromPartial( + object: DeepPartial + ): MethodDescriptorProto { + const message = { ...baseMethodDescriptorProto } as MethodDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.inputType !== undefined && object.inputType !== null) { + message.inputType = object.inputType; + } else { + message.inputType = ""; + } + if (object.outputType !== undefined && object.outputType !== null) { + message.outputType = object.outputType; + } else { + message.outputType = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = MethodOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if ( + object.clientStreaming !== undefined && + object.clientStreaming !== null + ) { + message.clientStreaming = object.clientStreaming; + } else { + message.clientStreaming = false; + } + if ( + object.serverStreaming !== undefined && + object.serverStreaming !== null + ) { + message.serverStreaming = object.serverStreaming; + } else { + message.serverStreaming = false; + } + return message; + }, +}; + +const baseFileOptions: object = { + javaPackage: "", + javaOuterClassname: "", + javaMultipleFiles: false, + javaGenerateEqualsAndHash: false, + javaStringCheckUtf8: false, + optimizeFor: 1, + goPackage: "", + ccGenericServices: false, + javaGenericServices: false, + pyGenericServices: false, + phpGenericServices: false, + deprecated: false, + ccEnableArenas: false, + objcClassPrefix: "", + csharpNamespace: "", + swiftPrefix: "", + phpClassPrefix: "", + phpNamespace: "", + phpMetadataNamespace: "", + rubyPackage: "", +}; + +export const FileOptions = { + encode(message: FileOptions, writer: Writer = Writer.create()): Writer { + if (message.javaPackage !== "") { + writer.uint32(10).string(message.javaPackage); + } + if (message.javaOuterClassname !== "") { + writer.uint32(66).string(message.javaOuterClassname); + } + if (message.javaMultipleFiles === true) { + writer.uint32(80).bool(message.javaMultipleFiles); + } + if (message.javaGenerateEqualsAndHash === true) { + writer.uint32(160).bool(message.javaGenerateEqualsAndHash); + } + if (message.javaStringCheckUtf8 === true) { + writer.uint32(216).bool(message.javaStringCheckUtf8); + } + if (message.optimizeFor !== 1) { + writer.uint32(72).int32(message.optimizeFor); + } + if (message.goPackage !== "") { + writer.uint32(90).string(message.goPackage); + } + if (message.ccGenericServices === true) { + writer.uint32(128).bool(message.ccGenericServices); + } + if (message.javaGenericServices === true) { + writer.uint32(136).bool(message.javaGenericServices); + } + if (message.pyGenericServices === true) { + writer.uint32(144).bool(message.pyGenericServices); + } + if (message.phpGenericServices === true) { + writer.uint32(336).bool(message.phpGenericServices); + } + if (message.deprecated === true) { + writer.uint32(184).bool(message.deprecated); + } + if (message.ccEnableArenas === true) { + writer.uint32(248).bool(message.ccEnableArenas); + } + if (message.objcClassPrefix !== "") { + writer.uint32(290).string(message.objcClassPrefix); + } + if (message.csharpNamespace !== "") { + writer.uint32(298).string(message.csharpNamespace); + } + if (message.swiftPrefix !== "") { + writer.uint32(314).string(message.swiftPrefix); + } + if (message.phpClassPrefix !== "") { + writer.uint32(322).string(message.phpClassPrefix); + } + if (message.phpNamespace !== "") { + writer.uint32(330).string(message.phpNamespace); + } + if (message.phpMetadataNamespace !== "") { + writer.uint32(354).string(message.phpMetadataNamespace); + } + if (message.rubyPackage !== "") { + writer.uint32(362).string(message.rubyPackage); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FileOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFileOptions } as FileOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.javaPackage = reader.string(); + break; + case 8: + message.javaOuterClassname = reader.string(); + break; + case 10: + message.javaMultipleFiles = reader.bool(); + break; + case 20: + message.javaGenerateEqualsAndHash = reader.bool(); + break; + case 27: + message.javaStringCheckUtf8 = reader.bool(); + break; + case 9: + message.optimizeFor = reader.int32() as any; + break; + case 11: + message.goPackage = reader.string(); + break; + case 16: + message.ccGenericServices = reader.bool(); + break; + case 17: + message.javaGenericServices = reader.bool(); + break; + case 18: + message.pyGenericServices = reader.bool(); + break; + case 42: + message.phpGenericServices = reader.bool(); + break; + case 23: + message.deprecated = reader.bool(); + break; + case 31: + message.ccEnableArenas = reader.bool(); + break; + case 36: + message.objcClassPrefix = reader.string(); + break; + case 37: + message.csharpNamespace = reader.string(); + break; + case 39: + message.swiftPrefix = reader.string(); + break; + case 40: + message.phpClassPrefix = reader.string(); + break; + case 41: + message.phpNamespace = reader.string(); + break; + case 44: + message.phpMetadataNamespace = reader.string(); + break; + case 45: + message.rubyPackage = reader.string(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FileOptions { + const message = { ...baseFileOptions } as FileOptions; + message.uninterpretedOption = []; + if (object.javaPackage !== undefined && object.javaPackage !== null) { + message.javaPackage = String(object.javaPackage); + } else { + message.javaPackage = ""; + } + if ( + object.javaOuterClassname !== undefined && + object.javaOuterClassname !== null + ) { + message.javaOuterClassname = String(object.javaOuterClassname); + } else { + message.javaOuterClassname = ""; + } + if ( + object.javaMultipleFiles !== undefined && + object.javaMultipleFiles !== null + ) { + message.javaMultipleFiles = Boolean(object.javaMultipleFiles); + } else { + message.javaMultipleFiles = false; + } + if ( + object.javaGenerateEqualsAndHash !== undefined && + object.javaGenerateEqualsAndHash !== null + ) { + message.javaGenerateEqualsAndHash = Boolean( + object.javaGenerateEqualsAndHash + ); + } else { + message.javaGenerateEqualsAndHash = false; + } + if ( + object.javaStringCheckUtf8 !== undefined && + object.javaStringCheckUtf8 !== null + ) { + message.javaStringCheckUtf8 = Boolean(object.javaStringCheckUtf8); + } else { + message.javaStringCheckUtf8 = false; + } + if (object.optimizeFor !== undefined && object.optimizeFor !== null) { + message.optimizeFor = fileOptions_OptimizeModeFromJSON( + object.optimizeFor + ); + } else { + message.optimizeFor = 1; + } + if (object.goPackage !== undefined && object.goPackage !== null) { + message.goPackage = String(object.goPackage); + } else { + message.goPackage = ""; + } + if ( + object.ccGenericServices !== undefined && + object.ccGenericServices !== null + ) { + message.ccGenericServices = Boolean(object.ccGenericServices); + } else { + message.ccGenericServices = false; + } + if ( + object.javaGenericServices !== undefined && + object.javaGenericServices !== null + ) { + message.javaGenericServices = Boolean(object.javaGenericServices); + } else { + message.javaGenericServices = false; + } + if ( + object.pyGenericServices !== undefined && + object.pyGenericServices !== null + ) { + message.pyGenericServices = Boolean(object.pyGenericServices); + } else { + message.pyGenericServices = false; + } + if ( + object.phpGenericServices !== undefined && + object.phpGenericServices !== null + ) { + message.phpGenericServices = Boolean(object.phpGenericServices); + } else { + message.phpGenericServices = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if (object.ccEnableArenas !== undefined && object.ccEnableArenas !== null) { + message.ccEnableArenas = Boolean(object.ccEnableArenas); + } else { + message.ccEnableArenas = false; + } + if ( + object.objcClassPrefix !== undefined && + object.objcClassPrefix !== null + ) { + message.objcClassPrefix = String(object.objcClassPrefix); + } else { + message.objcClassPrefix = ""; + } + if ( + object.csharpNamespace !== undefined && + object.csharpNamespace !== null + ) { + message.csharpNamespace = String(object.csharpNamespace); + } else { + message.csharpNamespace = ""; + } + if (object.swiftPrefix !== undefined && object.swiftPrefix !== null) { + message.swiftPrefix = String(object.swiftPrefix); + } else { + message.swiftPrefix = ""; + } + if (object.phpClassPrefix !== undefined && object.phpClassPrefix !== null) { + message.phpClassPrefix = String(object.phpClassPrefix); + } else { + message.phpClassPrefix = ""; + } + if (object.phpNamespace !== undefined && object.phpNamespace !== null) { + message.phpNamespace = String(object.phpNamespace); + } else { + message.phpNamespace = ""; + } + if ( + object.phpMetadataNamespace !== undefined && + object.phpMetadataNamespace !== null + ) { + message.phpMetadataNamespace = String(object.phpMetadataNamespace); + } else { + message.phpMetadataNamespace = ""; + } + if (object.rubyPackage !== undefined && object.rubyPackage !== null) { + message.rubyPackage = String(object.rubyPackage); + } else { + message.rubyPackage = ""; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: FileOptions): unknown { + const obj: any = {}; + message.javaPackage !== undefined && + (obj.javaPackage = message.javaPackage); + message.javaOuterClassname !== undefined && + (obj.javaOuterClassname = message.javaOuterClassname); + message.javaMultipleFiles !== undefined && + (obj.javaMultipleFiles = message.javaMultipleFiles); + message.javaGenerateEqualsAndHash !== undefined && + (obj.javaGenerateEqualsAndHash = message.javaGenerateEqualsAndHash); + message.javaStringCheckUtf8 !== undefined && + (obj.javaStringCheckUtf8 = message.javaStringCheckUtf8); + message.optimizeFor !== undefined && + (obj.optimizeFor = fileOptions_OptimizeModeToJSON(message.optimizeFor)); + message.goPackage !== undefined && (obj.goPackage = message.goPackage); + message.ccGenericServices !== undefined && + (obj.ccGenericServices = message.ccGenericServices); + message.javaGenericServices !== undefined && + (obj.javaGenericServices = message.javaGenericServices); + message.pyGenericServices !== undefined && + (obj.pyGenericServices = message.pyGenericServices); + message.phpGenericServices !== undefined && + (obj.phpGenericServices = message.phpGenericServices); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.ccEnableArenas !== undefined && + (obj.ccEnableArenas = message.ccEnableArenas); + message.objcClassPrefix !== undefined && + (obj.objcClassPrefix = message.objcClassPrefix); + message.csharpNamespace !== undefined && + (obj.csharpNamespace = message.csharpNamespace); + message.swiftPrefix !== undefined && + (obj.swiftPrefix = message.swiftPrefix); + message.phpClassPrefix !== undefined && + (obj.phpClassPrefix = message.phpClassPrefix); + message.phpNamespace !== undefined && + (obj.phpNamespace = message.phpNamespace); + message.phpMetadataNamespace !== undefined && + (obj.phpMetadataNamespace = message.phpMetadataNamespace); + message.rubyPackage !== undefined && + (obj.rubyPackage = message.rubyPackage); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): FileOptions { + const message = { ...baseFileOptions } as FileOptions; + message.uninterpretedOption = []; + if (object.javaPackage !== undefined && object.javaPackage !== null) { + message.javaPackage = object.javaPackage; + } else { + message.javaPackage = ""; + } + if ( + object.javaOuterClassname !== undefined && + object.javaOuterClassname !== null + ) { + message.javaOuterClassname = object.javaOuterClassname; + } else { + message.javaOuterClassname = ""; + } + if ( + object.javaMultipleFiles !== undefined && + object.javaMultipleFiles !== null + ) { + message.javaMultipleFiles = object.javaMultipleFiles; + } else { + message.javaMultipleFiles = false; + } + if ( + object.javaGenerateEqualsAndHash !== undefined && + object.javaGenerateEqualsAndHash !== null + ) { + message.javaGenerateEqualsAndHash = object.javaGenerateEqualsAndHash; + } else { + message.javaGenerateEqualsAndHash = false; + } + if ( + object.javaStringCheckUtf8 !== undefined && + object.javaStringCheckUtf8 !== null + ) { + message.javaStringCheckUtf8 = object.javaStringCheckUtf8; + } else { + message.javaStringCheckUtf8 = false; + } + if (object.optimizeFor !== undefined && object.optimizeFor !== null) { + message.optimizeFor = object.optimizeFor; + } else { + message.optimizeFor = 1; + } + if (object.goPackage !== undefined && object.goPackage !== null) { + message.goPackage = object.goPackage; + } else { + message.goPackage = ""; + } + if ( + object.ccGenericServices !== undefined && + object.ccGenericServices !== null + ) { + message.ccGenericServices = object.ccGenericServices; + } else { + message.ccGenericServices = false; + } + if ( + object.javaGenericServices !== undefined && + object.javaGenericServices !== null + ) { + message.javaGenericServices = object.javaGenericServices; + } else { + message.javaGenericServices = false; + } + if ( + object.pyGenericServices !== undefined && + object.pyGenericServices !== null + ) { + message.pyGenericServices = object.pyGenericServices; + } else { + message.pyGenericServices = false; + } + if ( + object.phpGenericServices !== undefined && + object.phpGenericServices !== null + ) { + message.phpGenericServices = object.phpGenericServices; + } else { + message.phpGenericServices = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if (object.ccEnableArenas !== undefined && object.ccEnableArenas !== null) { + message.ccEnableArenas = object.ccEnableArenas; + } else { + message.ccEnableArenas = false; + } + if ( + object.objcClassPrefix !== undefined && + object.objcClassPrefix !== null + ) { + message.objcClassPrefix = object.objcClassPrefix; + } else { + message.objcClassPrefix = ""; + } + if ( + object.csharpNamespace !== undefined && + object.csharpNamespace !== null + ) { + message.csharpNamespace = object.csharpNamespace; + } else { + message.csharpNamespace = ""; + } + if (object.swiftPrefix !== undefined && object.swiftPrefix !== null) { + message.swiftPrefix = object.swiftPrefix; + } else { + message.swiftPrefix = ""; + } + if (object.phpClassPrefix !== undefined && object.phpClassPrefix !== null) { + message.phpClassPrefix = object.phpClassPrefix; + } else { + message.phpClassPrefix = ""; + } + if (object.phpNamespace !== undefined && object.phpNamespace !== null) { + message.phpNamespace = object.phpNamespace; + } else { + message.phpNamespace = ""; + } + if ( + object.phpMetadataNamespace !== undefined && + object.phpMetadataNamespace !== null + ) { + message.phpMetadataNamespace = object.phpMetadataNamespace; + } else { + message.phpMetadataNamespace = ""; + } + if (object.rubyPackage !== undefined && object.rubyPackage !== null) { + message.rubyPackage = object.rubyPackage; + } else { + message.rubyPackage = ""; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseMessageOptions: object = { + messageSetWireFormat: false, + noStandardDescriptorAccessor: false, + deprecated: false, + mapEntry: false, +}; + +export const MessageOptions = { + encode(message: MessageOptions, writer: Writer = Writer.create()): Writer { + if (message.messageSetWireFormat === true) { + writer.uint32(8).bool(message.messageSetWireFormat); + } + if (message.noStandardDescriptorAccessor === true) { + writer.uint32(16).bool(message.noStandardDescriptorAccessor); + } + if (message.deprecated === true) { + writer.uint32(24).bool(message.deprecated); + } + if (message.mapEntry === true) { + writer.uint32(56).bool(message.mapEntry); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MessageOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMessageOptions } as MessageOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.messageSetWireFormat = reader.bool(); + break; + case 2: + message.noStandardDescriptorAccessor = reader.bool(); + break; + case 3: + message.deprecated = reader.bool(); + break; + case 7: + message.mapEntry = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MessageOptions { + const message = { ...baseMessageOptions } as MessageOptions; + message.uninterpretedOption = []; + if ( + object.messageSetWireFormat !== undefined && + object.messageSetWireFormat !== null + ) { + message.messageSetWireFormat = Boolean(object.messageSetWireFormat); + } else { + message.messageSetWireFormat = false; + } + if ( + object.noStandardDescriptorAccessor !== undefined && + object.noStandardDescriptorAccessor !== null + ) { + message.noStandardDescriptorAccessor = Boolean( + object.noStandardDescriptorAccessor + ); + } else { + message.noStandardDescriptorAccessor = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if (object.mapEntry !== undefined && object.mapEntry !== null) { + message.mapEntry = Boolean(object.mapEntry); + } else { + message.mapEntry = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: MessageOptions): unknown { + const obj: any = {}; + message.messageSetWireFormat !== undefined && + (obj.messageSetWireFormat = message.messageSetWireFormat); + message.noStandardDescriptorAccessor !== undefined && + (obj.noStandardDescriptorAccessor = message.noStandardDescriptorAccessor); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.mapEntry !== undefined && (obj.mapEntry = message.mapEntry); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): MessageOptions { + const message = { ...baseMessageOptions } as MessageOptions; + message.uninterpretedOption = []; + if ( + object.messageSetWireFormat !== undefined && + object.messageSetWireFormat !== null + ) { + message.messageSetWireFormat = object.messageSetWireFormat; + } else { + message.messageSetWireFormat = false; + } + if ( + object.noStandardDescriptorAccessor !== undefined && + object.noStandardDescriptorAccessor !== null + ) { + message.noStandardDescriptorAccessor = + object.noStandardDescriptorAccessor; + } else { + message.noStandardDescriptorAccessor = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if (object.mapEntry !== undefined && object.mapEntry !== null) { + message.mapEntry = object.mapEntry; + } else { + message.mapEntry = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseFieldOptions: object = { + ctype: 0, + packed: false, + jstype: 0, + lazy: false, + deprecated: false, + weak: false, +}; + +export const FieldOptions = { + encode(message: FieldOptions, writer: Writer = Writer.create()): Writer { + if (message.ctype !== 0) { + writer.uint32(8).int32(message.ctype); + } + if (message.packed === true) { + writer.uint32(16).bool(message.packed); + } + if (message.jstype !== 0) { + writer.uint32(48).int32(message.jstype); + } + if (message.lazy === true) { + writer.uint32(40).bool(message.lazy); + } + if (message.deprecated === true) { + writer.uint32(24).bool(message.deprecated); + } + if (message.weak === true) { + writer.uint32(80).bool(message.weak); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FieldOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFieldOptions } as FieldOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.ctype = reader.int32() as any; + break; + case 2: + message.packed = reader.bool(); + break; + case 6: + message.jstype = reader.int32() as any; + break; + case 5: + message.lazy = reader.bool(); + break; + case 3: + message.deprecated = reader.bool(); + break; + case 10: + message.weak = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FieldOptions { + const message = { ...baseFieldOptions } as FieldOptions; + message.uninterpretedOption = []; + if (object.ctype !== undefined && object.ctype !== null) { + message.ctype = fieldOptions_CTypeFromJSON(object.ctype); + } else { + message.ctype = 0; + } + if (object.packed !== undefined && object.packed !== null) { + message.packed = Boolean(object.packed); + } else { + message.packed = false; + } + if (object.jstype !== undefined && object.jstype !== null) { + message.jstype = fieldOptions_JSTypeFromJSON(object.jstype); + } else { + message.jstype = 0; + } + if (object.lazy !== undefined && object.lazy !== null) { + message.lazy = Boolean(object.lazy); + } else { + message.lazy = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if (object.weak !== undefined && object.weak !== null) { + message.weak = Boolean(object.weak); + } else { + message.weak = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: FieldOptions): unknown { + const obj: any = {}; + message.ctype !== undefined && + (obj.ctype = fieldOptions_CTypeToJSON(message.ctype)); + message.packed !== undefined && (obj.packed = message.packed); + message.jstype !== undefined && + (obj.jstype = fieldOptions_JSTypeToJSON(message.jstype)); + message.lazy !== undefined && (obj.lazy = message.lazy); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.weak !== undefined && (obj.weak = message.weak); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): FieldOptions { + const message = { ...baseFieldOptions } as FieldOptions; + message.uninterpretedOption = []; + if (object.ctype !== undefined && object.ctype !== null) { + message.ctype = object.ctype; + } else { + message.ctype = 0; + } + if (object.packed !== undefined && object.packed !== null) { + message.packed = object.packed; + } else { + message.packed = false; + } + if (object.jstype !== undefined && object.jstype !== null) { + message.jstype = object.jstype; + } else { + message.jstype = 0; + } + if (object.lazy !== undefined && object.lazy !== null) { + message.lazy = object.lazy; + } else { + message.lazy = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if (object.weak !== undefined && object.weak !== null) { + message.weak = object.weak; + } else { + message.weak = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseOneofOptions: object = {}; + +export const OneofOptions = { + encode(message: OneofOptions, writer: Writer = Writer.create()): Writer { + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): OneofOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseOneofOptions } as OneofOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): OneofOptions { + const message = { ...baseOneofOptions } as OneofOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: OneofOptions): unknown { + const obj: any = {}; + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): OneofOptions { + const message = { ...baseOneofOptions } as OneofOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseEnumOptions: object = { allowAlias: false, deprecated: false }; + +export const EnumOptions = { + encode(message: EnumOptions, writer: Writer = Writer.create()): Writer { + if (message.allowAlias === true) { + writer.uint32(16).bool(message.allowAlias); + } + if (message.deprecated === true) { + writer.uint32(24).bool(message.deprecated); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): EnumOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseEnumOptions } as EnumOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + message.allowAlias = reader.bool(); + break; + case 3: + message.deprecated = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumOptions { + const message = { ...baseEnumOptions } as EnumOptions; + message.uninterpretedOption = []; + if (object.allowAlias !== undefined && object.allowAlias !== null) { + message.allowAlias = Boolean(object.allowAlias); + } else { + message.allowAlias = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: EnumOptions): unknown { + const obj: any = {}; + message.allowAlias !== undefined && (obj.allowAlias = message.allowAlias); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): EnumOptions { + const message = { ...baseEnumOptions } as EnumOptions; + message.uninterpretedOption = []; + if (object.allowAlias !== undefined && object.allowAlias !== null) { + message.allowAlias = object.allowAlias; + } else { + message.allowAlias = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseEnumValueOptions: object = { deprecated: false }; + +export const EnumValueOptions = { + encode(message: EnumValueOptions, writer: Writer = Writer.create()): Writer { + if (message.deprecated === true) { + writer.uint32(8).bool(message.deprecated); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): EnumValueOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseEnumValueOptions } as EnumValueOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.deprecated = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumValueOptions { + const message = { ...baseEnumValueOptions } as EnumValueOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: EnumValueOptions): unknown { + const obj: any = {}; + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): EnumValueOptions { + const message = { ...baseEnumValueOptions } as EnumValueOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseServiceOptions: object = { deprecated: false }; + +export const ServiceOptions = { + encode(message: ServiceOptions, writer: Writer = Writer.create()): Writer { + if (message.deprecated === true) { + writer.uint32(264).bool(message.deprecated); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ServiceOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseServiceOptions } as ServiceOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 33: + message.deprecated = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ServiceOptions { + const message = { ...baseServiceOptions } as ServiceOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: ServiceOptions): unknown { + const obj: any = {}; + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): ServiceOptions { + const message = { ...baseServiceOptions } as ServiceOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseMethodOptions: object = { deprecated: false, idempotencyLevel: 0 }; + +export const MethodOptions = { + encode(message: MethodOptions, writer: Writer = Writer.create()): Writer { + if (message.deprecated === true) { + writer.uint32(264).bool(message.deprecated); + } + if (message.idempotencyLevel !== 0) { + writer.uint32(272).int32(message.idempotencyLevel); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MethodOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMethodOptions } as MethodOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 33: + message.deprecated = reader.bool(); + break; + case 34: + message.idempotencyLevel = reader.int32() as any; + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MethodOptions { + const message = { ...baseMethodOptions } as MethodOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.idempotencyLevel !== undefined && + object.idempotencyLevel !== null + ) { + message.idempotencyLevel = methodOptions_IdempotencyLevelFromJSON( + object.idempotencyLevel + ); + } else { + message.idempotencyLevel = 0; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: MethodOptions): unknown { + const obj: any = {}; + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.idempotencyLevel !== undefined && + (obj.idempotencyLevel = methodOptions_IdempotencyLevelToJSON( + message.idempotencyLevel + )); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): MethodOptions { + const message = { ...baseMethodOptions } as MethodOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.idempotencyLevel !== undefined && + object.idempotencyLevel !== null + ) { + message.idempotencyLevel = object.idempotencyLevel; + } else { + message.idempotencyLevel = 0; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseUninterpretedOption: object = { + identifierValue: "", + positiveIntValue: 0, + negativeIntValue: 0, + doubleValue: 0, + aggregateValue: "", +}; + +export const UninterpretedOption = { + encode( + message: UninterpretedOption, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.name) { + UninterpretedOption_NamePart.encode( + v!, + writer.uint32(18).fork() + ).ldelim(); + } + if (message.identifierValue !== "") { + writer.uint32(26).string(message.identifierValue); + } + if (message.positiveIntValue !== 0) { + writer.uint32(32).uint64(message.positiveIntValue); + } + if (message.negativeIntValue !== 0) { + writer.uint32(40).int64(message.negativeIntValue); + } + if (message.doubleValue !== 0) { + writer.uint32(49).double(message.doubleValue); + } + if (message.stringValue.length !== 0) { + writer.uint32(58).bytes(message.stringValue); + } + if (message.aggregateValue !== "") { + writer.uint32(66).string(message.aggregateValue); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): UninterpretedOption { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseUninterpretedOption } as UninterpretedOption; + message.name = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + message.name.push( + UninterpretedOption_NamePart.decode(reader, reader.uint32()) + ); + break; + case 3: + message.identifierValue = reader.string(); + break; + case 4: + message.positiveIntValue = longToNumber(reader.uint64() as Long); + break; + case 5: + message.negativeIntValue = longToNumber(reader.int64() as Long); + break; + case 6: + message.doubleValue = reader.double(); + break; + case 7: + message.stringValue = reader.bytes(); + break; + case 8: + message.aggregateValue = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): UninterpretedOption { + const message = { ...baseUninterpretedOption } as UninterpretedOption; + message.name = []; + if (object.name !== undefined && object.name !== null) { + for (const e of object.name) { + message.name.push(UninterpretedOption_NamePart.fromJSON(e)); + } + } + if ( + object.identifierValue !== undefined && + object.identifierValue !== null + ) { + message.identifierValue = String(object.identifierValue); + } else { + message.identifierValue = ""; + } + if ( + object.positiveIntValue !== undefined && + object.positiveIntValue !== null + ) { + message.positiveIntValue = Number(object.positiveIntValue); + } else { + message.positiveIntValue = 0; + } + if ( + object.negativeIntValue !== undefined && + object.negativeIntValue !== null + ) { + message.negativeIntValue = Number(object.negativeIntValue); + } else { + message.negativeIntValue = 0; + } + if (object.doubleValue !== undefined && object.doubleValue !== null) { + message.doubleValue = Number(object.doubleValue); + } else { + message.doubleValue = 0; + } + if (object.stringValue !== undefined && object.stringValue !== null) { + message.stringValue = bytesFromBase64(object.stringValue); + } + if (object.aggregateValue !== undefined && object.aggregateValue !== null) { + message.aggregateValue = String(object.aggregateValue); + } else { + message.aggregateValue = ""; + } + return message; + }, + + toJSON(message: UninterpretedOption): unknown { + const obj: any = {}; + if (message.name) { + obj.name = message.name.map((e) => + e ? UninterpretedOption_NamePart.toJSON(e) : undefined + ); + } else { + obj.name = []; + } + message.identifierValue !== undefined && + (obj.identifierValue = message.identifierValue); + message.positiveIntValue !== undefined && + (obj.positiveIntValue = message.positiveIntValue); + message.negativeIntValue !== undefined && + (obj.negativeIntValue = message.negativeIntValue); + message.doubleValue !== undefined && + (obj.doubleValue = message.doubleValue); + message.stringValue !== undefined && + (obj.stringValue = base64FromBytes( + message.stringValue !== undefined + ? message.stringValue + : new Uint8Array() + )); + message.aggregateValue !== undefined && + (obj.aggregateValue = message.aggregateValue); + return obj; + }, + + fromPartial(object: DeepPartial): UninterpretedOption { + const message = { ...baseUninterpretedOption } as UninterpretedOption; + message.name = []; + if (object.name !== undefined && object.name !== null) { + for (const e of object.name) { + message.name.push(UninterpretedOption_NamePart.fromPartial(e)); + } + } + if ( + object.identifierValue !== undefined && + object.identifierValue !== null + ) { + message.identifierValue = object.identifierValue; + } else { + message.identifierValue = ""; + } + if ( + object.positiveIntValue !== undefined && + object.positiveIntValue !== null + ) { + message.positiveIntValue = object.positiveIntValue; + } else { + message.positiveIntValue = 0; + } + if ( + object.negativeIntValue !== undefined && + object.negativeIntValue !== null + ) { + message.negativeIntValue = object.negativeIntValue; + } else { + message.negativeIntValue = 0; + } + if (object.doubleValue !== undefined && object.doubleValue !== null) { + message.doubleValue = object.doubleValue; + } else { + message.doubleValue = 0; + } + if (object.stringValue !== undefined && object.stringValue !== null) { + message.stringValue = object.stringValue; + } else { + message.stringValue = new Uint8Array(); + } + if (object.aggregateValue !== undefined && object.aggregateValue !== null) { + message.aggregateValue = object.aggregateValue; + } else { + message.aggregateValue = ""; + } + return message; + }, +}; + +const baseUninterpretedOption_NamePart: object = { + namePart: "", + isExtension: false, +}; + +export const UninterpretedOption_NamePart = { + encode( + message: UninterpretedOption_NamePart, + writer: Writer = Writer.create() + ): Writer { + if (message.namePart !== "") { + writer.uint32(10).string(message.namePart); + } + if (message.isExtension === true) { + writer.uint32(16).bool(message.isExtension); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): UninterpretedOption_NamePart { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseUninterpretedOption_NamePart, + } as UninterpretedOption_NamePart; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.namePart = reader.string(); + break; + case 2: + message.isExtension = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): UninterpretedOption_NamePart { + const message = { + ...baseUninterpretedOption_NamePart, + } as UninterpretedOption_NamePart; + if (object.namePart !== undefined && object.namePart !== null) { + message.namePart = String(object.namePart); + } else { + message.namePart = ""; + } + if (object.isExtension !== undefined && object.isExtension !== null) { + message.isExtension = Boolean(object.isExtension); + } else { + message.isExtension = false; + } + return message; + }, + + toJSON(message: UninterpretedOption_NamePart): unknown { + const obj: any = {}; + message.namePart !== undefined && (obj.namePart = message.namePart); + message.isExtension !== undefined && + (obj.isExtension = message.isExtension); + return obj; + }, + + fromPartial( + object: DeepPartial + ): UninterpretedOption_NamePart { + const message = { + ...baseUninterpretedOption_NamePart, + } as UninterpretedOption_NamePart; + if (object.namePart !== undefined && object.namePart !== null) { + message.namePart = object.namePart; + } else { + message.namePart = ""; + } + if (object.isExtension !== undefined && object.isExtension !== null) { + message.isExtension = object.isExtension; + } else { + message.isExtension = false; + } + return message; + }, +}; + +const baseSourceCodeInfo: object = {}; + +export const SourceCodeInfo = { + encode(message: SourceCodeInfo, writer: Writer = Writer.create()): Writer { + for (const v of message.location) { + SourceCodeInfo_Location.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): SourceCodeInfo { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseSourceCodeInfo } as SourceCodeInfo; + message.location = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.location.push( + SourceCodeInfo_Location.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): SourceCodeInfo { + const message = { ...baseSourceCodeInfo } as SourceCodeInfo; + message.location = []; + if (object.location !== undefined && object.location !== null) { + for (const e of object.location) { + message.location.push(SourceCodeInfo_Location.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: SourceCodeInfo): unknown { + const obj: any = {}; + if (message.location) { + obj.location = message.location.map((e) => + e ? SourceCodeInfo_Location.toJSON(e) : undefined + ); + } else { + obj.location = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): SourceCodeInfo { + const message = { ...baseSourceCodeInfo } as SourceCodeInfo; + message.location = []; + if (object.location !== undefined && object.location !== null) { + for (const e of object.location) { + message.location.push(SourceCodeInfo_Location.fromPartial(e)); + } + } + return message; + }, +}; + +const baseSourceCodeInfo_Location: object = { + path: 0, + span: 0, + leadingComments: "", + trailingComments: "", + leadingDetachedComments: "", +}; + +export const SourceCodeInfo_Location = { + encode( + message: SourceCodeInfo_Location, + writer: Writer = Writer.create() + ): Writer { + writer.uint32(10).fork(); + for (const v of message.path) { + writer.int32(v); + } + writer.ldelim(); + writer.uint32(18).fork(); + for (const v of message.span) { + writer.int32(v); + } + writer.ldelim(); + if (message.leadingComments !== "") { + writer.uint32(26).string(message.leadingComments); + } + if (message.trailingComments !== "") { + writer.uint32(34).string(message.trailingComments); + } + for (const v of message.leadingDetachedComments) { + writer.uint32(50).string(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): SourceCodeInfo_Location { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseSourceCodeInfo_Location, + } as SourceCodeInfo_Location; + message.path = []; + message.span = []; + message.leadingDetachedComments = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.path.push(reader.int32()); + } + } else { + message.path.push(reader.int32()); + } + break; + case 2: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.span.push(reader.int32()); + } + } else { + message.span.push(reader.int32()); + } + break; + case 3: + message.leadingComments = reader.string(); + break; + case 4: + message.trailingComments = reader.string(); + break; + case 6: + message.leadingDetachedComments.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): SourceCodeInfo_Location { + const message = { + ...baseSourceCodeInfo_Location, + } as SourceCodeInfo_Location; + message.path = []; + message.span = []; + message.leadingDetachedComments = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(Number(e)); + } + } + if (object.span !== undefined && object.span !== null) { + for (const e of object.span) { + message.span.push(Number(e)); + } + } + if ( + object.leadingComments !== undefined && + object.leadingComments !== null + ) { + message.leadingComments = String(object.leadingComments); + } else { + message.leadingComments = ""; + } + if ( + object.trailingComments !== undefined && + object.trailingComments !== null + ) { + message.trailingComments = String(object.trailingComments); + } else { + message.trailingComments = ""; + } + if ( + object.leadingDetachedComments !== undefined && + object.leadingDetachedComments !== null + ) { + for (const e of object.leadingDetachedComments) { + message.leadingDetachedComments.push(String(e)); + } + } + return message; + }, + + toJSON(message: SourceCodeInfo_Location): unknown { + const obj: any = {}; + if (message.path) { + obj.path = message.path.map((e) => e); + } else { + obj.path = []; + } + if (message.span) { + obj.span = message.span.map((e) => e); + } else { + obj.span = []; + } + message.leadingComments !== undefined && + (obj.leadingComments = message.leadingComments); + message.trailingComments !== undefined && + (obj.trailingComments = message.trailingComments); + if (message.leadingDetachedComments) { + obj.leadingDetachedComments = message.leadingDetachedComments.map( + (e) => e + ); + } else { + obj.leadingDetachedComments = []; + } + return obj; + }, + + fromPartial( + object: DeepPartial + ): SourceCodeInfo_Location { + const message = { + ...baseSourceCodeInfo_Location, + } as SourceCodeInfo_Location; + message.path = []; + message.span = []; + message.leadingDetachedComments = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(e); + } + } + if (object.span !== undefined && object.span !== null) { + for (const e of object.span) { + message.span.push(e); + } + } + if ( + object.leadingComments !== undefined && + object.leadingComments !== null + ) { + message.leadingComments = object.leadingComments; + } else { + message.leadingComments = ""; + } + if ( + object.trailingComments !== undefined && + object.trailingComments !== null + ) { + message.trailingComments = object.trailingComments; + } else { + message.trailingComments = ""; + } + if ( + object.leadingDetachedComments !== undefined && + object.leadingDetachedComments !== null + ) { + for (const e of object.leadingDetachedComments) { + message.leadingDetachedComments.push(e); + } + } + return message; + }, +}; + +const baseGeneratedCodeInfo: object = {}; + +export const GeneratedCodeInfo = { + encode(message: GeneratedCodeInfo, writer: Writer = Writer.create()): Writer { + for (const v of message.annotation) { + GeneratedCodeInfo_Annotation.encode( + v!, + writer.uint32(10).fork() + ).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): GeneratedCodeInfo { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseGeneratedCodeInfo } as GeneratedCodeInfo; + message.annotation = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.annotation.push( + GeneratedCodeInfo_Annotation.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GeneratedCodeInfo { + const message = { ...baseGeneratedCodeInfo } as GeneratedCodeInfo; + message.annotation = []; + if (object.annotation !== undefined && object.annotation !== null) { + for (const e of object.annotation) { + message.annotation.push(GeneratedCodeInfo_Annotation.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: GeneratedCodeInfo): unknown { + const obj: any = {}; + if (message.annotation) { + obj.annotation = message.annotation.map((e) => + e ? GeneratedCodeInfo_Annotation.toJSON(e) : undefined + ); + } else { + obj.annotation = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): GeneratedCodeInfo { + const message = { ...baseGeneratedCodeInfo } as GeneratedCodeInfo; + message.annotation = []; + if (object.annotation !== undefined && object.annotation !== null) { + for (const e of object.annotation) { + message.annotation.push(GeneratedCodeInfo_Annotation.fromPartial(e)); + } + } + return message; + }, +}; + +const baseGeneratedCodeInfo_Annotation: object = { + path: 0, + sourceFile: "", + begin: 0, + end: 0, +}; + +export const GeneratedCodeInfo_Annotation = { + encode( + message: GeneratedCodeInfo_Annotation, + writer: Writer = Writer.create() + ): Writer { + writer.uint32(10).fork(); + for (const v of message.path) { + writer.int32(v); + } + writer.ldelim(); + if (message.sourceFile !== "") { + writer.uint32(18).string(message.sourceFile); + } + if (message.begin !== 0) { + writer.uint32(24).int32(message.begin); + } + if (message.end !== 0) { + writer.uint32(32).int32(message.end); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): GeneratedCodeInfo_Annotation { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseGeneratedCodeInfo_Annotation, + } as GeneratedCodeInfo_Annotation; + message.path = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.path.push(reader.int32()); + } + } else { + message.path.push(reader.int32()); + } + break; + case 2: + message.sourceFile = reader.string(); + break; + case 3: + message.begin = reader.int32(); + break; + case 4: + message.end = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GeneratedCodeInfo_Annotation { + const message = { + ...baseGeneratedCodeInfo_Annotation, + } as GeneratedCodeInfo_Annotation; + message.path = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(Number(e)); + } + } + if (object.sourceFile !== undefined && object.sourceFile !== null) { + message.sourceFile = String(object.sourceFile); + } else { + message.sourceFile = ""; + } + if (object.begin !== undefined && object.begin !== null) { + message.begin = Number(object.begin); + } else { + message.begin = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + return message; + }, + + toJSON(message: GeneratedCodeInfo_Annotation): unknown { + const obj: any = {}; + if (message.path) { + obj.path = message.path.map((e) => e); + } else { + obj.path = []; + } + message.sourceFile !== undefined && (obj.sourceFile = message.sourceFile); + message.begin !== undefined && (obj.begin = message.begin); + message.end !== undefined && (obj.end = message.end); + return obj; + }, + + fromPartial( + object: DeepPartial + ): GeneratedCodeInfo_Annotation { + const message = { + ...baseGeneratedCodeInfo_Annotation, + } as GeneratedCodeInfo_Annotation; + message.path = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(e); + } + } + if (object.sourceFile !== undefined && object.sourceFile !== null) { + message.sourceFile = object.sourceFile; + } else { + message.sourceFile = ""; + } + if (object.begin !== undefined && object.begin !== null) { + message.begin = object.begin; + } else { + message.begin = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/cosmos.feegrant.v1beta1/types/google/protobuf/duration.ts b/ts-client/cosmos.feegrant.v1beta1/types/google/protobuf/duration.ts new file mode 100644 index 00000000..fffd5b14 --- /dev/null +++ b/ts-client/cosmos.feegrant.v1beta1/types/google/protobuf/duration.ts @@ -0,0 +1,188 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "google.protobuf"; + +/** + * A Duration represents a signed, fixed-length span of time represented + * as a count of seconds and fractions of seconds at nanosecond + * resolution. It is independent of any calendar and concepts like "day" + * or "month". It is related to Timestamp in that the difference between + * two Timestamp values is a Duration and it can be added or subtracted + * from a Timestamp. Range is approximately +-10,000 years. + * + * # Examples + * + * Example 1: Compute Duration from two Timestamps in pseudo code. + * + * Timestamp start = ...; + * Timestamp end = ...; + * Duration duration = ...; + * + * duration.seconds = end.seconds - start.seconds; + * duration.nanos = end.nanos - start.nanos; + * + * if (duration.seconds < 0 && duration.nanos > 0) { + * duration.seconds += 1; + * duration.nanos -= 1000000000; + * } else if (duration.seconds > 0 && duration.nanos < 0) { + * duration.seconds -= 1; + * duration.nanos += 1000000000; + * } + * + * Example 2: Compute Timestamp from Timestamp + Duration in pseudo code. + * + * Timestamp start = ...; + * Duration duration = ...; + * Timestamp end = ...; + * + * end.seconds = start.seconds + duration.seconds; + * end.nanos = start.nanos + duration.nanos; + * + * if (end.nanos < 0) { + * end.seconds -= 1; + * end.nanos += 1000000000; + * } else if (end.nanos >= 1000000000) { + * end.seconds += 1; + * end.nanos -= 1000000000; + * } + * + * Example 3: Compute Duration from datetime.timedelta in Python. + * + * td = datetime.timedelta(days=3, minutes=10) + * duration = Duration() + * duration.FromTimedelta(td) + * + * # JSON Mapping + * + * In JSON format, the Duration type is encoded as a string rather than an + * object, where the string ends in the suffix "s" (indicating seconds) and + * is preceded by the number of seconds, with nanoseconds expressed as + * fractional seconds. For example, 3 seconds with 0 nanoseconds should be + * encoded in JSON format as "3s", while 3 seconds and 1 nanosecond should + * be expressed in JSON format as "3.000000001s", and 3 seconds and 1 + * microsecond should be expressed in JSON format as "3.000001s". + */ +export interface Duration { + /** + * Signed seconds of the span of time. Must be from -315,576,000,000 + * to +315,576,000,000 inclusive. Note: these bounds are computed from: + * 60 sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years + */ + seconds: number; + /** + * Signed fractions of a second at nanosecond resolution of the span + * of time. Durations less than one second are represented with a 0 + * `seconds` field and a positive or negative `nanos` field. For durations + * of one second or more, a non-zero value for the `nanos` field must be + * of the same sign as the `seconds` field. Must be from -999,999,999 + * to +999,999,999 inclusive. + */ + nanos: number; +} + +const baseDuration: object = { seconds: 0, nanos: 0 }; + +export const Duration = { + encode(message: Duration, writer: Writer = Writer.create()): Writer { + if (message.seconds !== 0) { + writer.uint32(8).int64(message.seconds); + } + if (message.nanos !== 0) { + writer.uint32(16).int32(message.nanos); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Duration { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseDuration } as Duration; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.seconds = longToNumber(reader.int64() as Long); + break; + case 2: + message.nanos = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Duration { + const message = { ...baseDuration } as Duration; + if (object.seconds !== undefined && object.seconds !== null) { + message.seconds = Number(object.seconds); + } else { + message.seconds = 0; + } + if (object.nanos !== undefined && object.nanos !== null) { + message.nanos = Number(object.nanos); + } else { + message.nanos = 0; + } + return message; + }, + + toJSON(message: Duration): unknown { + const obj: any = {}; + message.seconds !== undefined && (obj.seconds = message.seconds); + message.nanos !== undefined && (obj.nanos = message.nanos); + return obj; + }, + + fromPartial(object: DeepPartial): Duration { + const message = { ...baseDuration } as Duration; + if (object.seconds !== undefined && object.seconds !== null) { + message.seconds = object.seconds; + } else { + message.seconds = 0; + } + if (object.nanos !== undefined && object.nanos !== null) { + message.nanos = object.nanos; + } else { + message.nanos = 0; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/cosmos.feegrant.v1beta1/types/google/protobuf/timestamp.ts b/ts-client/cosmos.feegrant.v1beta1/types/google/protobuf/timestamp.ts new file mode 100644 index 00000000..11864afc --- /dev/null +++ b/ts-client/cosmos.feegrant.v1beta1/types/google/protobuf/timestamp.ts @@ -0,0 +1,219 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "google.protobuf"; + +/** + * A Timestamp represents a point in time independent of any time zone or local + * calendar, encoded as a count of seconds and fractions of seconds at + * nanosecond resolution. The count is relative to an epoch at UTC midnight on + * January 1, 1970, in the proleptic Gregorian calendar which extends the + * Gregorian calendar backwards to year one. + * + * All minutes are 60 seconds long. Leap seconds are "smeared" so that no leap + * second table is needed for interpretation, using a [24-hour linear + * smear](https://developers.google.com/time/smear). + * + * The range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. By + * restricting to that range, we ensure that we can convert to and from [RFC + * 3339](https://www.ietf.org/rfc/rfc3339.txt) date strings. + * + * # Examples + * + * Example 1: Compute Timestamp from POSIX `time()`. + * + * Timestamp timestamp; + * timestamp.set_seconds(time(NULL)); + * timestamp.set_nanos(0); + * + * Example 2: Compute Timestamp from POSIX `gettimeofday()`. + * + * struct timeval tv; + * gettimeofday(&tv, NULL); + * + * Timestamp timestamp; + * timestamp.set_seconds(tv.tv_sec); + * timestamp.set_nanos(tv.tv_usec * 1000); + * + * Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`. + * + * FILETIME ft; + * GetSystemTimeAsFileTime(&ft); + * UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime; + * + * // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z + * // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z. + * Timestamp timestamp; + * timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL)); + * timestamp.set_nanos((INT32) ((ticks % 10000000) * 100)); + * + * Example 4: Compute Timestamp from Java `System.currentTimeMillis()`. + * + * long millis = System.currentTimeMillis(); + * + * Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000) + * .setNanos((int) ((millis % 1000) * 1000000)).build(); + * + * + * Example 5: Compute Timestamp from Java `Instant.now()`. + * + * Instant now = Instant.now(); + * + * Timestamp timestamp = + * Timestamp.newBuilder().setSeconds(now.getEpochSecond()) + * .setNanos(now.getNano()).build(); + * + * + * Example 6: Compute Timestamp from current time in Python. + * + * timestamp = Timestamp() + * timestamp.GetCurrentTime() + * + * # JSON Mapping + * + * In JSON format, the Timestamp type is encoded as a string in the + * [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the + * format is "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z" + * where {year} is always expressed using four digits while {month}, {day}, + * {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional + * seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution), + * are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone + * is required. A proto3 JSON serializer should always use UTC (as indicated by + * "Z") when printing the Timestamp type and a proto3 JSON parser should be + * able to accept both UTC and other timezones (as indicated by an offset). + * + * For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past + * 01:30 UTC on January 15, 2017. + * + * In JavaScript, one can convert a Date object to this format using the + * standard + * [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString) + * method. In Python, a standard `datetime.datetime` object can be converted + * to this format using + * [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) with + * the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one can use + * the Joda Time's [`ISODateTimeFormat.dateTime()`]( + * http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime%2D%2D + * ) to obtain a formatter capable of generating timestamps in this format. + */ +export interface Timestamp { + /** + * Represents seconds of UTC time since Unix epoch + * 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to + * 9999-12-31T23:59:59Z inclusive. + */ + seconds: number; + /** + * Non-negative fractions of a second at nanosecond resolution. Negative + * second values with fractions must still have non-negative nanos values + * that count forward in time. Must be from 0 to 999,999,999 + * inclusive. + */ + nanos: number; +} + +const baseTimestamp: object = { seconds: 0, nanos: 0 }; + +export const Timestamp = { + encode(message: Timestamp, writer: Writer = Writer.create()): Writer { + if (message.seconds !== 0) { + writer.uint32(8).int64(message.seconds); + } + if (message.nanos !== 0) { + writer.uint32(16).int32(message.nanos); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Timestamp { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseTimestamp } as Timestamp; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.seconds = longToNumber(reader.int64() as Long); + break; + case 2: + message.nanos = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Timestamp { + const message = { ...baseTimestamp } as Timestamp; + if (object.seconds !== undefined && object.seconds !== null) { + message.seconds = Number(object.seconds); + } else { + message.seconds = 0; + } + if (object.nanos !== undefined && object.nanos !== null) { + message.nanos = Number(object.nanos); + } else { + message.nanos = 0; + } + return message; + }, + + toJSON(message: Timestamp): unknown { + const obj: any = {}; + message.seconds !== undefined && (obj.seconds = message.seconds); + message.nanos !== undefined && (obj.nanos = message.nanos); + return obj; + }, + + fromPartial(object: DeepPartial): Timestamp { + const message = { ...baseTimestamp } as Timestamp; + if (object.seconds !== undefined && object.seconds !== null) { + message.seconds = object.seconds; + } else { + message.seconds = 0; + } + if (object.nanos !== undefined && object.nanos !== null) { + message.nanos = object.nanos; + } else { + message.nanos = 0; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/cosmos.gov.v1beta1/index.ts b/ts-client/cosmos.gov.v1beta1/index.ts new file mode 100755 index 00000000..c9dfa159 --- /dev/null +++ b/ts-client/cosmos.gov.v1beta1/index.ts @@ -0,0 +1,6 @@ +import Module from './module'; +import { txClient, queryClient, registry } from './module'; +import { msgTypes } from './registry'; + +export * from "./types"; +export { Module, msgTypes, txClient, queryClient, registry }; diff --git a/ts-client/cosmos.gov.v1beta1/module.ts b/ts-client/cosmos.gov.v1beta1/module.ts new file mode 100755 index 00000000..6c2ae0b5 --- /dev/null +++ b/ts-client/cosmos.gov.v1beta1/module.ts @@ -0,0 +1,198 @@ +// Generated by Ignite ignite.com/cli + +import { StdFee } from "@cosmjs/launchpad"; +import { SigningStargateClient, DeliverTxResponse } from "@cosmjs/stargate"; +import { EncodeObject, GeneratedType, OfflineSigner, Registry } from "@cosmjs/proto-signing"; +import { msgTypes } from './registry'; +import { IgniteClient } from "../client" +import { MissingWalletError } from "../helpers" +import { Api } from "./rest"; +import { MsgVoteWeighted } from "./types/cosmos/gov/v1beta1/tx"; +import { MsgVote } from "./types/cosmos/gov/v1beta1/tx"; +import { MsgSubmitProposal } from "./types/cosmos/gov/v1beta1/tx"; +import { MsgDeposit } from "./types/cosmos/gov/v1beta1/tx"; + + +export { MsgVoteWeighted, MsgVote, MsgSubmitProposal, MsgDeposit }; + +type sendMsgVoteWeightedParams = { + value: MsgVoteWeighted, + fee?: StdFee, + memo?: string +}; + +type sendMsgVoteParams = { + value: MsgVote, + fee?: StdFee, + memo?: string +}; + +type sendMsgSubmitProposalParams = { + value: MsgSubmitProposal, + fee?: StdFee, + memo?: string +}; + +type sendMsgDepositParams = { + value: MsgDeposit, + fee?: StdFee, + memo?: string +}; + + +type msgVoteWeightedParams = { + value: MsgVoteWeighted, +}; + +type msgVoteParams = { + value: MsgVote, +}; + +type msgSubmitProposalParams = { + value: MsgSubmitProposal, +}; + +type msgDepositParams = { + value: MsgDeposit, +}; + + +export const registry = new Registry(msgTypes); + +const defaultFee = { + amount: [], + gas: "200000", +}; + +interface TxClientOptions { + addr: string + prefix: string + signer?: OfflineSigner +} + +export const txClient = ({ signer, prefix, addr }: TxClientOptions = { addr: "http://localhost:26657", prefix: "cosmos" }) => { + + return { + + async sendMsgVoteWeighted({ value, fee, memo }: sendMsgVoteWeightedParams): Promise { + if (!signer) { + throw new Error('TxClient:sendMsgVoteWeighted: Unable to sign Tx. Signer is not present.') + } + try { + const { address } = (await signer.getAccounts())[0]; + const signingClient = await SigningStargateClient.connectWithSigner(addr,signer,{registry, prefix}); + let msg = this.msgVoteWeighted({ value: MsgVoteWeighted.fromPartial(value) }) + return await signingClient.signAndBroadcast(address, [msg], fee ? fee : defaultFee, memo) + } catch (e: any) { + throw new Error('TxClient:sendMsgVoteWeighted: Could not broadcast Tx: '+ e.message) + } + }, + + async sendMsgVote({ value, fee, memo }: sendMsgVoteParams): Promise { + if (!signer) { + throw new Error('TxClient:sendMsgVote: Unable to sign Tx. Signer is not present.') + } + try { + const { address } = (await signer.getAccounts())[0]; + const signingClient = await SigningStargateClient.connectWithSigner(addr,signer,{registry, prefix}); + let msg = this.msgVote({ value: MsgVote.fromPartial(value) }) + return await signingClient.signAndBroadcast(address, [msg], fee ? fee : defaultFee, memo) + } catch (e: any) { + throw new Error('TxClient:sendMsgVote: Could not broadcast Tx: '+ e.message) + } + }, + + async sendMsgSubmitProposal({ value, fee, memo }: sendMsgSubmitProposalParams): Promise { + if (!signer) { + throw new Error('TxClient:sendMsgSubmitProposal: Unable to sign Tx. Signer is not present.') + } + try { + const { address } = (await signer.getAccounts())[0]; + const signingClient = await SigningStargateClient.connectWithSigner(addr,signer,{registry, prefix}); + let msg = this.msgSubmitProposal({ value: MsgSubmitProposal.fromPartial(value) }) + return await signingClient.signAndBroadcast(address, [msg], fee ? fee : defaultFee, memo) + } catch (e: any) { + throw new Error('TxClient:sendMsgSubmitProposal: Could not broadcast Tx: '+ e.message) + } + }, + + async sendMsgDeposit({ value, fee, memo }: sendMsgDepositParams): Promise { + if (!signer) { + throw new Error('TxClient:sendMsgDeposit: Unable to sign Tx. Signer is not present.') + } + try { + const { address } = (await signer.getAccounts())[0]; + const signingClient = await SigningStargateClient.connectWithSigner(addr,signer,{registry, prefix}); + let msg = this.msgDeposit({ value: MsgDeposit.fromPartial(value) }) + return await signingClient.signAndBroadcast(address, [msg], fee ? fee : defaultFee, memo) + } catch (e: any) { + throw new Error('TxClient:sendMsgDeposit: Could not broadcast Tx: '+ e.message) + } + }, + + + msgVoteWeighted({ value }: msgVoteWeightedParams): EncodeObject { + try { + return { typeUrl: "/cosmos.gov.v1beta1.MsgVoteWeighted", value: MsgVoteWeighted.fromPartial( value ) } + } catch (e: any) { + throw new Error('TxClient:MsgVoteWeighted: Could not create message: ' + e.message) + } + }, + + msgVote({ value }: msgVoteParams): EncodeObject { + try { + return { typeUrl: "/cosmos.gov.v1beta1.MsgVote", value: MsgVote.fromPartial( value ) } + } catch (e: any) { + throw new Error('TxClient:MsgVote: Could not create message: ' + e.message) + } + }, + + msgSubmitProposal({ value }: msgSubmitProposalParams): EncodeObject { + try { + return { typeUrl: "/cosmos.gov.v1beta1.MsgSubmitProposal", value: MsgSubmitProposal.fromPartial( value ) } + } catch (e: any) { + throw new Error('TxClient:MsgSubmitProposal: Could not create message: ' + e.message) + } + }, + + msgDeposit({ value }: msgDepositParams): EncodeObject { + try { + return { typeUrl: "/cosmos.gov.v1beta1.MsgDeposit", value: MsgDeposit.fromPartial( value ) } + } catch (e: any) { + throw new Error('TxClient:MsgDeposit: Could not create message: ' + e.message) + } + }, + + } +}; + +interface QueryClientOptions { + addr: string +} + +export const queryClient = ({ addr: addr }: QueryClientOptions = { addr: "http://localhost:1317" }) => { + return new Api({ baseUrl: addr }); +}; + +class SDKModule { + public query: ReturnType; + public tx: ReturnType; + + public registry: Array<[string, GeneratedType]>; + + constructor(client: IgniteClient) { + + this.query = queryClient({ addr: client.env.apiURL }); + this.tx = txClient({ signer: client.signer, addr: client.env.rpcURL, prefix: client.env.prefix ?? "cosmos" }); + } +}; + +const Module = (test: IgniteClient) => { + return { + module: { + CosmosGovV1Beta1: new SDKModule(test) + }, + registry: msgTypes + } +} +export default Module; \ No newline at end of file diff --git a/ts-client/cosmos.gov.v1beta1/registry.ts b/ts-client/cosmos.gov.v1beta1/registry.ts new file mode 100755 index 00000000..9974fdd6 --- /dev/null +++ b/ts-client/cosmos.gov.v1beta1/registry.ts @@ -0,0 +1,15 @@ +import { GeneratedType } from "@cosmjs/proto-signing"; +import { MsgVoteWeighted } from "./types/cosmos/gov/v1beta1/tx"; +import { MsgVote } from "./types/cosmos/gov/v1beta1/tx"; +import { MsgSubmitProposal } from "./types/cosmos/gov/v1beta1/tx"; +import { MsgDeposit } from "./types/cosmos/gov/v1beta1/tx"; + +const msgTypes: Array<[string, GeneratedType]> = [ + ["/cosmos.gov.v1beta1.MsgVoteWeighted", MsgVoteWeighted], + ["/cosmos.gov.v1beta1.MsgVote", MsgVote], + ["/cosmos.gov.v1beta1.MsgSubmitProposal", MsgSubmitProposal], + ["/cosmos.gov.v1beta1.MsgDeposit", MsgDeposit], + +]; + +export { msgTypes } \ No newline at end of file diff --git a/ts-client/cosmos.gov.v1beta1/rest.ts b/ts-client/cosmos.gov.v1beta1/rest.ts new file mode 100644 index 00000000..dd5f6fc9 --- /dev/null +++ b/ts-client/cosmos.gov.v1beta1/rest.ts @@ -0,0 +1,950 @@ +/* eslint-disable */ +/* tslint:disable */ +/* + * --------------------------------------------------------------- + * ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ## + * ## ## + * ## AUTHOR: acacode ## + * ## SOURCE: https://github.com/acacode/swagger-typescript-api ## + * --------------------------------------------------------------- + */ + +/** +* Deposit defines an amount deposited by an account address to an active +proposal. +*/ +export interface Govv1Beta1Deposit { + /** @format uint64 */ + proposal_id?: string; + depositor?: string; + amount?: V1Beta1Coin[]; +} + +/** + * Proposal defines the core field members of a governance proposal. + */ +export interface Govv1Beta1Proposal { + /** @format uint64 */ + proposal_id?: string; + + /** + * `Any` contains an arbitrary serialized protocol buffer message along with a + * URL that describes the type of the serialized message. + * + * Protobuf library provides support to pack/unpack Any values in the form + * of utility functions or additional generated methods of the Any type. + * + * Example 1: Pack and unpack a message in C++. + * + * Foo foo = ...; + * Any any; + * any.PackFrom(foo); + * ... + * if (any.UnpackTo(&foo)) { + * ... + * } + * + * Example 2: Pack and unpack a message in Java. + * + * Foo foo = ...; + * Any any = Any.pack(foo); + * ... + * if (any.is(Foo.class)) { + * foo = any.unpack(Foo.class); + * } + * + * Example 3: Pack and unpack a message in Python. + * + * foo = Foo(...) + * any = Any() + * any.Pack(foo) + * ... + * if any.Is(Foo.DESCRIPTOR): + * any.Unpack(foo) + * ... + * + * Example 4: Pack and unpack a message in Go + * + * foo := &pb.Foo{...} + * any, err := anypb.New(foo) + * if err != nil { + * ... + * } + * ... + * foo := &pb.Foo{} + * if err := any.UnmarshalTo(foo); err != nil { + * ... + * } + * + * The pack methods provided by protobuf library will by default use + * 'type.googleapis.com/full.type.name' as the type URL and the unpack + * methods only use the fully qualified type name after the last '/' + * in the type URL, for example "foo.bar.com/x/y.z" will yield type + * name "y.z". + * + * + * JSON + * ==== + * The JSON representation of an `Any` value uses the regular + * representation of the deserialized, embedded message, with an + * additional field `@type` which contains the type URL. Example: + * + * package google.profile; + * message Person { + * string first_name = 1; + * string last_name = 2; + * } + * + * { + * "@type": "type.googleapis.com/google.profile.Person", + * "firstName": , + * "lastName": + * } + * + * If the embedded message type is well-known and has a custom JSON + * representation, that representation will be embedded adding a field + * `value` which holds the custom JSON in addition to the `@type` + * field. Example (for message [google.protobuf.Duration][]): + * + * { + * "@type": "type.googleapis.com/google.protobuf.Duration", + * "value": "1.212s" + * } + */ + content?: ProtobufAny; + + /** + * ProposalStatus enumerates the valid statuses of a proposal. + * + * - PROPOSAL_STATUS_UNSPECIFIED: PROPOSAL_STATUS_UNSPECIFIED defines the default propopsal status. + * - PROPOSAL_STATUS_DEPOSIT_PERIOD: PROPOSAL_STATUS_DEPOSIT_PERIOD defines a proposal status during the deposit + * period. + * - PROPOSAL_STATUS_VOTING_PERIOD: PROPOSAL_STATUS_VOTING_PERIOD defines a proposal status during the voting + * period. + * - PROPOSAL_STATUS_PASSED: PROPOSAL_STATUS_PASSED defines a proposal status of a proposal that has + * passed. + * - PROPOSAL_STATUS_REJECTED: PROPOSAL_STATUS_REJECTED defines a proposal status of a proposal that has + * been rejected. + * - PROPOSAL_STATUS_FAILED: PROPOSAL_STATUS_FAILED defines a proposal status of a proposal that has + * failed. + */ + status?: V1Beta1ProposalStatus; + + /** TallyResult defines a standard tally for a governance proposal. */ + final_tally_result?: Govv1Beta1TallyResult; + + /** @format date-time */ + submit_time?: string; + + /** @format date-time */ + deposit_end_time?: string; + total_deposit?: V1Beta1Coin[]; + + /** @format date-time */ + voting_start_time?: string; + + /** @format date-time */ + voting_end_time?: string; +} + +/** + * TallyResult defines a standard tally for a governance proposal. + */ +export interface Govv1Beta1TallyResult { + yes?: string; + abstain?: string; + no?: string; + no_with_veto?: string; +} + +/** +* Vote defines a vote on a governance proposal. +A Vote consists of a proposal ID, the voter, and the vote option. +*/ +export interface Govv1Beta1Vote { + /** @format uint64 */ + proposal_id?: string; + voter?: string; + + /** + * Deprecated: Prefer to use `options` instead. This field is set in queries + * if and only if `len(options) == 1` and that option has weight 1. In all + * other cases, this field will default to VOTE_OPTION_UNSPECIFIED. + */ + option?: V1Beta1VoteOption; + options?: V1Beta1WeightedVoteOption[]; +} + +/** +* `Any` contains an arbitrary serialized protocol buffer message along with a +URL that describes the type of the serialized message. + +Protobuf library provides support to pack/unpack Any values in the form +of utility functions or additional generated methods of the Any type. + +Example 1: Pack and unpack a message in C++. + + Foo foo = ...; + Any any; + any.PackFrom(foo); + ... + if (any.UnpackTo(&foo)) { + ... + } + +Example 2: Pack and unpack a message in Java. + + Foo foo = ...; + Any any = Any.pack(foo); + ... + if (any.is(Foo.class)) { + foo = any.unpack(Foo.class); + } + + Example 3: Pack and unpack a message in Python. + + foo = Foo(...) + any = Any() + any.Pack(foo) + ... + if any.Is(Foo.DESCRIPTOR): + any.Unpack(foo) + ... + + Example 4: Pack and unpack a message in Go + + foo := &pb.Foo{...} + any, err := anypb.New(foo) + if err != nil { + ... + } + ... + foo := &pb.Foo{} + if err := any.UnmarshalTo(foo); err != nil { + ... + } + +The pack methods provided by protobuf library will by default use +'type.googleapis.com/full.type.name' as the type URL and the unpack +methods only use the fully qualified type name after the last '/' +in the type URL, for example "foo.bar.com/x/y.z" will yield type +name "y.z". + + +JSON +==== +The JSON representation of an `Any` value uses the regular +representation of the deserialized, embedded message, with an +additional field `@type` which contains the type URL. Example: + + package google.profile; + message Person { + string first_name = 1; + string last_name = 2; + } + + { + "@type": "type.googleapis.com/google.profile.Person", + "firstName": , + "lastName": + } + +If the embedded message type is well-known and has a custom JSON +representation, that representation will be embedded adding a field +`value` which holds the custom JSON in addition to the `@type` +field. Example (for message [google.protobuf.Duration][]): + + { + "@type": "type.googleapis.com/google.protobuf.Duration", + "value": "1.212s" + } +*/ +export interface ProtobufAny { + /** + * A URL/resource name that uniquely identifies the type of the serialized + * protocol buffer message. This string must contain at least + * one "/" character. The last segment of the URL's path must represent + * the fully qualified name of the type (as in + * `path/google.protobuf.Duration`). The name should be in a canonical form + * (e.g., leading "." is not accepted). + * + * In practice, teams usually precompile into the binary all types that they + * expect it to use in the context of Any. However, for URLs which use the + * scheme `http`, `https`, or no scheme, one can optionally set up a type + * server that maps type URLs to message definitions as follows: + * + * * If no scheme is provided, `https` is assumed. + * * An HTTP GET on the URL must yield a [google.protobuf.Type][] + * value in binary format, or produce an error. + * * Applications are allowed to cache lookup results based on the + * URL, or have them precompiled into a binary to avoid any + * lookup. Therefore, binary compatibility needs to be preserved + * on changes to types. (Use versioned type names to manage + * breaking changes.) + * + * Note: this functionality is not currently available in the official + * protobuf release, and it is not used for type URLs beginning with + * type.googleapis.com. + * + * Schemes other than `http`, `https` (or the empty scheme) might be + * used with implementation specific semantics. + */ + "@type"?: string; +} + +export interface RpcStatus { + /** @format int32 */ + code?: number; + message?: string; + details?: ProtobufAny[]; +} + +/** +* Coin defines a token with a denomination and an amount. + +NOTE: The amount field is an Int which implements the custom method +signatures required by gogoproto. +*/ +export interface V1Beta1Coin { + denom?: string; + amount?: string; +} + +/** + * DepositParams defines the params for deposits on governance proposals. + */ +export interface V1Beta1DepositParams { + /** Minimum deposit for a proposal to enter voting period. */ + min_deposit?: V1Beta1Coin[]; + + /** + * Maximum period for Atom holders to deposit on a proposal. Initial value: 2 + * months. + */ + max_deposit_period?: string; +} + +/** + * MsgDepositResponse defines the Msg/Deposit response type. + */ +export type V1Beta1MsgDepositResponse = object; + +/** + * MsgSubmitProposalResponse defines the Msg/SubmitProposal response type. + */ +export interface V1Beta1MsgSubmitProposalResponse { + /** @format uint64 */ + proposal_id?: string; +} + +/** + * MsgVoteResponse defines the Msg/Vote response type. + */ +export type V1Beta1MsgVoteResponse = object; + +/** +* MsgVoteWeightedResponse defines the Msg/VoteWeighted response type. + +Since: cosmos-sdk 0.43 +*/ +export type V1Beta1MsgVoteWeightedResponse = object; + +/** +* message SomeRequest { + Foo some_parameter = 1; + PageRequest pagination = 2; + } +*/ +export interface V1Beta1PageRequest { + /** + * key is a value returned in PageResponse.next_key to begin + * querying the next page most efficiently. Only one of offset or key + * should be set. + * @format byte + */ + key?: string; + + /** + * offset is a numeric offset that can be used when key is unavailable. + * It is less efficient than using key. Only one of offset or key should + * be set. + * @format uint64 + */ + offset?: string; + + /** + * limit is the total number of results to be returned in the result page. + * If left empty it will default to a value to be set by each app. + * @format uint64 + */ + limit?: string; + + /** + * count_total is set to true to indicate that the result set should include + * a count of the total number of items available for pagination in UIs. + * count_total is only respected when offset is used. It is ignored when key + * is set. + */ + count_total?: boolean; + + /** + * reverse is set to true if results are to be returned in the descending order. + * + * Since: cosmos-sdk 0.43 + */ + reverse?: boolean; +} + +/** +* PageResponse is to be embedded in gRPC response messages where the +corresponding request message has used PageRequest. + + message SomeResponse { + repeated Bar results = 1; + PageResponse page = 2; + } +*/ +export interface V1Beta1PageResponse { + /** @format byte */ + next_key?: string; + + /** @format uint64 */ + total?: string; +} + +/** +* ProposalStatus enumerates the valid statuses of a proposal. + + - PROPOSAL_STATUS_UNSPECIFIED: PROPOSAL_STATUS_UNSPECIFIED defines the default propopsal status. + - PROPOSAL_STATUS_DEPOSIT_PERIOD: PROPOSAL_STATUS_DEPOSIT_PERIOD defines a proposal status during the deposit +period. + - PROPOSAL_STATUS_VOTING_PERIOD: PROPOSAL_STATUS_VOTING_PERIOD defines a proposal status during the voting +period. + - PROPOSAL_STATUS_PASSED: PROPOSAL_STATUS_PASSED defines a proposal status of a proposal that has +passed. + - PROPOSAL_STATUS_REJECTED: PROPOSAL_STATUS_REJECTED defines a proposal status of a proposal that has +been rejected. + - PROPOSAL_STATUS_FAILED: PROPOSAL_STATUS_FAILED defines a proposal status of a proposal that has +failed. +*/ +export enum V1Beta1ProposalStatus { + PROPOSAL_STATUS_UNSPECIFIED = "PROPOSAL_STATUS_UNSPECIFIED", + PROPOSAL_STATUS_DEPOSIT_PERIOD = "PROPOSAL_STATUS_DEPOSIT_PERIOD", + PROPOSAL_STATUS_VOTING_PERIOD = "PROPOSAL_STATUS_VOTING_PERIOD", + PROPOSAL_STATUS_PASSED = "PROPOSAL_STATUS_PASSED", + PROPOSAL_STATUS_REJECTED = "PROPOSAL_STATUS_REJECTED", + PROPOSAL_STATUS_FAILED = "PROPOSAL_STATUS_FAILED", +} + +/** + * QueryDepositResponse is the response type for the Query/Deposit RPC method. + */ +export interface V1Beta1QueryDepositResponse { + /** deposit defines the requested deposit. */ + deposit?: Govv1Beta1Deposit; +} + +/** + * QueryDepositsResponse is the response type for the Query/Deposits RPC method. + */ +export interface V1Beta1QueryDepositsResponse { + deposits?: Govv1Beta1Deposit[]; + + /** pagination defines the pagination in the response. */ + pagination?: V1Beta1PageResponse; +} + +/** + * QueryParamsResponse is the response type for the Query/Params RPC method. + */ +export interface V1Beta1QueryParamsResponse { + /** voting_params defines the parameters related to voting. */ + voting_params?: V1Beta1VotingParams; + + /** deposit_params defines the parameters related to deposit. */ + deposit_params?: V1Beta1DepositParams; + + /** tally_params defines the parameters related to tally. */ + tally_params?: V1Beta1TallyParams; +} + +/** + * QueryProposalResponse is the response type for the Query/Proposal RPC method. + */ +export interface V1Beta1QueryProposalResponse { + /** Proposal defines the core field members of a governance proposal. */ + proposal?: Govv1Beta1Proposal; +} + +/** +* QueryProposalsResponse is the response type for the Query/Proposals RPC +method. +*/ +export interface V1Beta1QueryProposalsResponse { + proposals?: Govv1Beta1Proposal[]; + + /** pagination defines the pagination in the response. */ + pagination?: V1Beta1PageResponse; +} + +/** + * QueryTallyResultResponse is the response type for the Query/Tally RPC method. + */ +export interface V1Beta1QueryTallyResultResponse { + /** tally defines the requested tally. */ + tally?: Govv1Beta1TallyResult; +} + +/** + * QueryVoteResponse is the response type for the Query/Vote RPC method. + */ +export interface V1Beta1QueryVoteResponse { + /** vote defined the queried vote. */ + vote?: Govv1Beta1Vote; +} + +/** + * QueryVotesResponse is the response type for the Query/Votes RPC method. + */ +export interface V1Beta1QueryVotesResponse { + /** votes defined the queried votes. */ + votes?: Govv1Beta1Vote[]; + + /** pagination defines the pagination in the response. */ + pagination?: V1Beta1PageResponse; +} + +/** + * TallyParams defines the params for tallying votes on governance proposals. + */ +export interface V1Beta1TallyParams { + /** + * Minimum percentage of total stake needed to vote for a result to be + * considered valid. + * @format byte + */ + quorum?: string; + + /** + * Minimum proportion of Yes votes for proposal to pass. Default value: 0.5. + * @format byte + */ + threshold?: string; + + /** + * Minimum value of Veto votes to Total votes ratio for proposal to be + * vetoed. Default value: 1/3. + * @format byte + */ + veto_threshold?: string; +} + +/** +* VoteOption enumerates the valid vote options for a given governance proposal. + + - VOTE_OPTION_UNSPECIFIED: VOTE_OPTION_UNSPECIFIED defines a no-op vote option. + - VOTE_OPTION_YES: VOTE_OPTION_YES defines a yes vote option. + - VOTE_OPTION_ABSTAIN: VOTE_OPTION_ABSTAIN defines an abstain vote option. + - VOTE_OPTION_NO: VOTE_OPTION_NO defines a no vote option. + - VOTE_OPTION_NO_WITH_VETO: VOTE_OPTION_NO_WITH_VETO defines a no with veto vote option. +*/ +export enum V1Beta1VoteOption { + VOTE_OPTION_UNSPECIFIED = "VOTE_OPTION_UNSPECIFIED", + VOTE_OPTION_YES = "VOTE_OPTION_YES", + VOTE_OPTION_ABSTAIN = "VOTE_OPTION_ABSTAIN", + VOTE_OPTION_NO = "VOTE_OPTION_NO", + VOTE_OPTION_NO_WITH_VETO = "VOTE_OPTION_NO_WITH_VETO", +} + +/** + * VotingParams defines the params for voting on governance proposals. + */ +export interface V1Beta1VotingParams { + /** Length of the voting period. */ + voting_period?: string; +} + +/** +* WeightedVoteOption defines a unit of vote for vote split. + +Since: cosmos-sdk 0.43 +*/ +export interface V1Beta1WeightedVoteOption { + /** + * VoteOption enumerates the valid vote options for a given governance proposal. + * + * - VOTE_OPTION_UNSPECIFIED: VOTE_OPTION_UNSPECIFIED defines a no-op vote option. + * - VOTE_OPTION_YES: VOTE_OPTION_YES defines a yes vote option. + * - VOTE_OPTION_ABSTAIN: VOTE_OPTION_ABSTAIN defines an abstain vote option. + * - VOTE_OPTION_NO: VOTE_OPTION_NO defines a no vote option. + * - VOTE_OPTION_NO_WITH_VETO: VOTE_OPTION_NO_WITH_VETO defines a no with veto vote option. + */ + option?: V1Beta1VoteOption; + weight?: string; +} + +export type QueryParamsType = Record; +export type ResponseFormat = keyof Omit; + +export interface FullRequestParams extends Omit { + /** set parameter to `true` for call `securityWorker` for this request */ + secure?: boolean; + /** request path */ + path: string; + /** content type of request body */ + type?: ContentType; + /** query params */ + query?: QueryParamsType; + /** format of response (i.e. response.json() -> format: "json") */ + format?: keyof Omit; + /** request body */ + body?: unknown; + /** base url */ + baseUrl?: string; + /** request cancellation token */ + cancelToken?: CancelToken; +} + +export type RequestParams = Omit; + +export interface ApiConfig { + baseUrl?: string; + baseApiParams?: Omit; + securityWorker?: (securityData: SecurityDataType) => RequestParams | void; +} + +export interface HttpResponse extends Response { + data: D; + error: E; +} + +type CancelToken = Symbol | string | number; + +export enum ContentType { + Json = "application/json", + FormData = "multipart/form-data", + UrlEncoded = "application/x-www-form-urlencoded", +} + +export class HttpClient { + public baseUrl: string = ""; + private securityData: SecurityDataType = null as any; + private securityWorker: null | ApiConfig["securityWorker"] = null; + private abortControllers = new Map(); + + private baseApiParams: RequestParams = { + credentials: "same-origin", + headers: {}, + redirect: "follow", + referrerPolicy: "no-referrer", + }; + + constructor(apiConfig: ApiConfig = {}) { + Object.assign(this, apiConfig); + } + + public setSecurityData = (data: SecurityDataType) => { + this.securityData = data; + }; + + private addQueryParam(query: QueryParamsType, key: string) { + const value = query[key]; + + return ( + encodeURIComponent(key) + + "=" + + encodeURIComponent(Array.isArray(value) ? value.join(",") : typeof value === "number" ? value : `${value}`) + ); + } + + protected toQueryString(rawQuery?: QueryParamsType): string { + const query = rawQuery || {}; + const keys = Object.keys(query).filter((key) => "undefined" !== typeof query[key]); + return keys + .map((key) => + typeof query[key] === "object" && !Array.isArray(query[key]) + ? this.toQueryString(query[key] as QueryParamsType) + : this.addQueryParam(query, key), + ) + .join("&"); + } + + protected addQueryParams(rawQuery?: QueryParamsType): string { + const queryString = this.toQueryString(rawQuery); + return queryString ? `?${queryString}` : ""; + } + + private contentFormatters: Record any> = { + [ContentType.Json]: (input: any) => + input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input, + [ContentType.FormData]: (input: any) => + Object.keys(input || {}).reduce((data, key) => { + data.append(key, input[key]); + return data; + }, new FormData()), + [ContentType.UrlEncoded]: (input: any) => this.toQueryString(input), + }; + + private mergeRequestParams(params1: RequestParams, params2?: RequestParams): RequestParams { + return { + ...this.baseApiParams, + ...params1, + ...(params2 || {}), + headers: { + ...(this.baseApiParams.headers || {}), + ...(params1.headers || {}), + ...((params2 && params2.headers) || {}), + }, + }; + } + + private createAbortSignal = (cancelToken: CancelToken): AbortSignal | undefined => { + if (this.abortControllers.has(cancelToken)) { + const abortController = this.abortControllers.get(cancelToken); + if (abortController) { + return abortController.signal; + } + return void 0; + } + + const abortController = new AbortController(); + this.abortControllers.set(cancelToken, abortController); + return abortController.signal; + }; + + public abortRequest = (cancelToken: CancelToken) => { + const abortController = this.abortControllers.get(cancelToken); + + if (abortController) { + abortController.abort(); + this.abortControllers.delete(cancelToken); + } + }; + + public request = ({ + body, + secure, + path, + type, + query, + format = "json", + baseUrl, + cancelToken, + ...params + }: FullRequestParams): Promise> => { + const secureParams = (secure && this.securityWorker && this.securityWorker(this.securityData)) || {}; + const requestParams = this.mergeRequestParams(params, secureParams); + const queryString = query && this.toQueryString(query); + const payloadFormatter = this.contentFormatters[type || ContentType.Json]; + + return fetch(`${baseUrl || this.baseUrl || ""}${path}${queryString ? `?${queryString}` : ""}`, { + ...requestParams, + headers: { + ...(type && type !== ContentType.FormData ? { "Content-Type": type } : {}), + ...(requestParams.headers || {}), + }, + signal: cancelToken ? this.createAbortSignal(cancelToken) : void 0, + body: typeof body === "undefined" || body === null ? null : payloadFormatter(body), + }).then(async (response) => { + const r = response as HttpResponse; + r.data = (null as unknown) as T; + r.error = (null as unknown) as E; + + const data = await response[format]() + .then((data) => { + if (r.ok) { + r.data = data; + } else { + r.error = data; + } + return r; + }) + .catch((e) => { + r.error = e; + return r; + }); + + if (cancelToken) { + this.abortControllers.delete(cancelToken); + } + + if (!response.ok) throw data; + return data; + }); + }; +} + +/** + * @title cosmos/gov/v1beta1/genesis.proto + * @version version not set + */ +export class Api extends HttpClient { + /** + * No description + * + * @tags Query + * @name QueryParams + * @summary Params queries all parameters of the gov module. + * @request GET:/cosmos/gov/v1beta1/params/{params_type} + */ + queryParams = (params_type: string, params: RequestParams = {}) => + this.request({ + path: `/cosmos/gov/v1beta1/params/${params_type}`, + method: "GET", + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Query + * @name QueryProposals + * @summary Proposals queries all proposals based on given status. + * @request GET:/cosmos/gov/v1beta1/proposals + */ + queryProposals = ( + query?: { + proposal_status?: + | "PROPOSAL_STATUS_UNSPECIFIED" + | "PROPOSAL_STATUS_DEPOSIT_PERIOD" + | "PROPOSAL_STATUS_VOTING_PERIOD" + | "PROPOSAL_STATUS_PASSED" + | "PROPOSAL_STATUS_REJECTED" + | "PROPOSAL_STATUS_FAILED"; + voter?: string; + depositor?: string; + "pagination.key"?: string; + "pagination.offset"?: string; + "pagination.limit"?: string; + "pagination.count_total"?: boolean; + "pagination.reverse"?: boolean; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/cosmos/gov/v1beta1/proposals`, + method: "GET", + query: query, + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Query + * @name QueryProposal + * @summary Proposal queries proposal details based on ProposalID. + * @request GET:/cosmos/gov/v1beta1/proposals/{proposal_id} + */ + queryProposal = (proposal_id: string, params: RequestParams = {}) => + this.request({ + path: `/cosmos/gov/v1beta1/proposals/${proposal_id}`, + method: "GET", + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Query + * @name QueryDeposits + * @summary Deposits queries all deposits of a single proposal. + * @request GET:/cosmos/gov/v1beta1/proposals/{proposal_id}/deposits + */ + queryDeposits = ( + proposal_id: string, + query?: { + "pagination.key"?: string; + "pagination.offset"?: string; + "pagination.limit"?: string; + "pagination.count_total"?: boolean; + "pagination.reverse"?: boolean; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/cosmos/gov/v1beta1/proposals/${proposal_id}/deposits`, + method: "GET", + query: query, + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Query + * @name QueryDeposit + * @summary Deposit queries single deposit information based proposalID, depositAddr. + * @request GET:/cosmos/gov/v1beta1/proposals/{proposal_id}/deposits/{depositor} + */ + queryDeposit = (proposal_id: string, depositor: string, params: RequestParams = {}) => + this.request({ + path: `/cosmos/gov/v1beta1/proposals/${proposal_id}/deposits/${depositor}`, + method: "GET", + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Query + * @name QueryTallyResult + * @summary TallyResult queries the tally of a proposal vote. + * @request GET:/cosmos/gov/v1beta1/proposals/{proposal_id}/tally + */ + queryTallyResult = (proposal_id: string, params: RequestParams = {}) => + this.request({ + path: `/cosmos/gov/v1beta1/proposals/${proposal_id}/tally`, + method: "GET", + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Query + * @name QueryVotes + * @summary Votes queries votes of a given proposal. + * @request GET:/cosmos/gov/v1beta1/proposals/{proposal_id}/votes + */ + queryVotes = ( + proposal_id: string, + query?: { + "pagination.key"?: string; + "pagination.offset"?: string; + "pagination.limit"?: string; + "pagination.count_total"?: boolean; + "pagination.reverse"?: boolean; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/cosmos/gov/v1beta1/proposals/${proposal_id}/votes`, + method: "GET", + query: query, + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Query + * @name QueryVote + * @summary Vote queries voted information based on proposalID, voterAddr. + * @request GET:/cosmos/gov/v1beta1/proposals/{proposal_id}/votes/{voter} + */ + queryVote = (proposal_id: string, voter: string, params: RequestParams = {}) => + this.request({ + path: `/cosmos/gov/v1beta1/proposals/${proposal_id}/votes/${voter}`, + method: "GET", + format: "json", + ...params, + }); +} diff --git a/ts-client/cosmos.gov.v1beta1/types.ts b/ts-client/cosmos.gov.v1beta1/types.ts new file mode 100755 index 00000000..eb5d993d --- /dev/null +++ b/ts-client/cosmos.gov.v1beta1/types.ts @@ -0,0 +1,23 @@ +import { WeightedVoteOption } from "./types/cosmos/gov/v1beta1/gov" +import { TextProposal } from "./types/cosmos/gov/v1beta1/gov" +import { Deposit } from "./types/cosmos/gov/v1beta1/gov" +import { Proposal } from "./types/cosmos/gov/v1beta1/gov" +import { TallyResult } from "./types/cosmos/gov/v1beta1/gov" +import { Vote } from "./types/cosmos/gov/v1beta1/gov" +import { DepositParams } from "./types/cosmos/gov/v1beta1/gov" +import { VotingParams } from "./types/cosmos/gov/v1beta1/gov" +import { TallyParams } from "./types/cosmos/gov/v1beta1/gov" + + +export { + WeightedVoteOption, + TextProposal, + Deposit, + Proposal, + TallyResult, + Vote, + DepositParams, + VotingParams, + TallyParams, + + } \ No newline at end of file diff --git a/ts-client/cosmos.gov.v1beta1/types/cosmos/base/query/v1beta1/pagination.ts b/ts-client/cosmos.gov.v1beta1/types/cosmos/base/query/v1beta1/pagination.ts new file mode 100644 index 00000000..cd4b2d78 --- /dev/null +++ b/ts-client/cosmos.gov.v1beta1/types/cosmos/base/query/v1beta1/pagination.ts @@ -0,0 +1,327 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "cosmos.base.query.v1beta1"; + +/** + * PageRequest is to be embedded in gRPC request messages for efficient + * pagination. Ex: + * + * message SomeRequest { + * Foo some_parameter = 1; + * PageRequest pagination = 2; + * } + */ +export interface PageRequest { + /** + * key is a value returned in PageResponse.next_key to begin + * querying the next page most efficiently. Only one of offset or key + * should be set. + */ + key: Uint8Array; + /** + * offset is a numeric offset that can be used when key is unavailable. + * It is less efficient than using key. Only one of offset or key should + * be set. + */ + offset: number; + /** + * limit is the total number of results to be returned in the result page. + * If left empty it will default to a value to be set by each app. + */ + limit: number; + /** + * count_total is set to true to indicate that the result set should include + * a count of the total number of items available for pagination in UIs. + * count_total is only respected when offset is used. It is ignored when key + * is set. + */ + countTotal: boolean; + /** + * reverse is set to true if results are to be returned in the descending order. + * + * Since: cosmos-sdk 0.43 + */ + reverse: boolean; +} + +/** + * PageResponse is to be embedded in gRPC response messages where the + * corresponding request message has used PageRequest. + * + * message SomeResponse { + * repeated Bar results = 1; + * PageResponse page = 2; + * } + */ +export interface PageResponse { + /** + * next_key is the key to be passed to PageRequest.key to + * query the next page most efficiently + */ + nextKey: Uint8Array; + /** + * total is total number of results available if PageRequest.count_total + * was set, its value is undefined otherwise + */ + total: number; +} + +const basePageRequest: object = { + offset: 0, + limit: 0, + countTotal: false, + reverse: false, +}; + +export const PageRequest = { + encode(message: PageRequest, writer: Writer = Writer.create()): Writer { + if (message.key.length !== 0) { + writer.uint32(10).bytes(message.key); + } + if (message.offset !== 0) { + writer.uint32(16).uint64(message.offset); + } + if (message.limit !== 0) { + writer.uint32(24).uint64(message.limit); + } + if (message.countTotal === true) { + writer.uint32(32).bool(message.countTotal); + } + if (message.reverse === true) { + writer.uint32(40).bool(message.reverse); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): PageRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...basePageRequest } as PageRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.key = reader.bytes(); + break; + case 2: + message.offset = longToNumber(reader.uint64() as Long); + break; + case 3: + message.limit = longToNumber(reader.uint64() as Long); + break; + case 4: + message.countTotal = reader.bool(); + break; + case 5: + message.reverse = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): PageRequest { + const message = { ...basePageRequest } as PageRequest; + if (object.key !== undefined && object.key !== null) { + message.key = bytesFromBase64(object.key); + } + if (object.offset !== undefined && object.offset !== null) { + message.offset = Number(object.offset); + } else { + message.offset = 0; + } + if (object.limit !== undefined && object.limit !== null) { + message.limit = Number(object.limit); + } else { + message.limit = 0; + } + if (object.countTotal !== undefined && object.countTotal !== null) { + message.countTotal = Boolean(object.countTotal); + } else { + message.countTotal = false; + } + if (object.reverse !== undefined && object.reverse !== null) { + message.reverse = Boolean(object.reverse); + } else { + message.reverse = false; + } + return message; + }, + + toJSON(message: PageRequest): unknown { + const obj: any = {}; + message.key !== undefined && + (obj.key = base64FromBytes( + message.key !== undefined ? message.key : new Uint8Array() + )); + message.offset !== undefined && (obj.offset = message.offset); + message.limit !== undefined && (obj.limit = message.limit); + message.countTotal !== undefined && (obj.countTotal = message.countTotal); + message.reverse !== undefined && (obj.reverse = message.reverse); + return obj; + }, + + fromPartial(object: DeepPartial): PageRequest { + const message = { ...basePageRequest } as PageRequest; + if (object.key !== undefined && object.key !== null) { + message.key = object.key; + } else { + message.key = new Uint8Array(); + } + if (object.offset !== undefined && object.offset !== null) { + message.offset = object.offset; + } else { + message.offset = 0; + } + if (object.limit !== undefined && object.limit !== null) { + message.limit = object.limit; + } else { + message.limit = 0; + } + if (object.countTotal !== undefined && object.countTotal !== null) { + message.countTotal = object.countTotal; + } else { + message.countTotal = false; + } + if (object.reverse !== undefined && object.reverse !== null) { + message.reverse = object.reverse; + } else { + message.reverse = false; + } + return message; + }, +}; + +const basePageResponse: object = { total: 0 }; + +export const PageResponse = { + encode(message: PageResponse, writer: Writer = Writer.create()): Writer { + if (message.nextKey.length !== 0) { + writer.uint32(10).bytes(message.nextKey); + } + if (message.total !== 0) { + writer.uint32(16).uint64(message.total); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): PageResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...basePageResponse } as PageResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.nextKey = reader.bytes(); + break; + case 2: + message.total = longToNumber(reader.uint64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): PageResponse { + const message = { ...basePageResponse } as PageResponse; + if (object.nextKey !== undefined && object.nextKey !== null) { + message.nextKey = bytesFromBase64(object.nextKey); + } + if (object.total !== undefined && object.total !== null) { + message.total = Number(object.total); + } else { + message.total = 0; + } + return message; + }, + + toJSON(message: PageResponse): unknown { + const obj: any = {}; + message.nextKey !== undefined && + (obj.nextKey = base64FromBytes( + message.nextKey !== undefined ? message.nextKey : new Uint8Array() + )); + message.total !== undefined && (obj.total = message.total); + return obj; + }, + + fromPartial(object: DeepPartial): PageResponse { + const message = { ...basePageResponse } as PageResponse; + if (object.nextKey !== undefined && object.nextKey !== null) { + message.nextKey = object.nextKey; + } else { + message.nextKey = new Uint8Array(); + } + if (object.total !== undefined && object.total !== null) { + message.total = object.total; + } else { + message.total = 0; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/cosmos.gov.v1beta1/types/cosmos/base/v1beta1/coin.ts b/ts-client/cosmos.gov.v1beta1/types/cosmos/base/v1beta1/coin.ts new file mode 100644 index 00000000..ce2ac984 --- /dev/null +++ b/ts-client/cosmos.gov.v1beta1/types/cosmos/base/v1beta1/coin.ts @@ -0,0 +1,301 @@ +/* eslint-disable */ +import { Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "cosmos.base.v1beta1"; + +/** + * Coin defines a token with a denomination and an amount. + * + * NOTE: The amount field is an Int which implements the custom method + * signatures required by gogoproto. + */ +export interface Coin { + denom: string; + amount: string; +} + +/** + * DecCoin defines a token with a denomination and a decimal amount. + * + * NOTE: The amount field is an Dec which implements the custom method + * signatures required by gogoproto. + */ +export interface DecCoin { + denom: string; + amount: string; +} + +/** IntProto defines a Protobuf wrapper around an Int object. */ +export interface IntProto { + int: string; +} + +/** DecProto defines a Protobuf wrapper around a Dec object. */ +export interface DecProto { + dec: string; +} + +const baseCoin: object = { denom: "", amount: "" }; + +export const Coin = { + encode(message: Coin, writer: Writer = Writer.create()): Writer { + if (message.denom !== "") { + writer.uint32(10).string(message.denom); + } + if (message.amount !== "") { + writer.uint32(18).string(message.amount); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Coin { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseCoin } as Coin; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.denom = reader.string(); + break; + case 2: + message.amount = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Coin { + const message = { ...baseCoin } as Coin; + if (object.denom !== undefined && object.denom !== null) { + message.denom = String(object.denom); + } else { + message.denom = ""; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = String(object.amount); + } else { + message.amount = ""; + } + return message; + }, + + toJSON(message: Coin): unknown { + const obj: any = {}; + message.denom !== undefined && (obj.denom = message.denom); + message.amount !== undefined && (obj.amount = message.amount); + return obj; + }, + + fromPartial(object: DeepPartial): Coin { + const message = { ...baseCoin } as Coin; + if (object.denom !== undefined && object.denom !== null) { + message.denom = object.denom; + } else { + message.denom = ""; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = object.amount; + } else { + message.amount = ""; + } + return message; + }, +}; + +const baseDecCoin: object = { denom: "", amount: "" }; + +export const DecCoin = { + encode(message: DecCoin, writer: Writer = Writer.create()): Writer { + if (message.denom !== "") { + writer.uint32(10).string(message.denom); + } + if (message.amount !== "") { + writer.uint32(18).string(message.amount); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): DecCoin { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseDecCoin } as DecCoin; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.denom = reader.string(); + break; + case 2: + message.amount = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DecCoin { + const message = { ...baseDecCoin } as DecCoin; + if (object.denom !== undefined && object.denom !== null) { + message.denom = String(object.denom); + } else { + message.denom = ""; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = String(object.amount); + } else { + message.amount = ""; + } + return message; + }, + + toJSON(message: DecCoin): unknown { + const obj: any = {}; + message.denom !== undefined && (obj.denom = message.denom); + message.amount !== undefined && (obj.amount = message.amount); + return obj; + }, + + fromPartial(object: DeepPartial): DecCoin { + const message = { ...baseDecCoin } as DecCoin; + if (object.denom !== undefined && object.denom !== null) { + message.denom = object.denom; + } else { + message.denom = ""; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = object.amount; + } else { + message.amount = ""; + } + return message; + }, +}; + +const baseIntProto: object = { int: "" }; + +export const IntProto = { + encode(message: IntProto, writer: Writer = Writer.create()): Writer { + if (message.int !== "") { + writer.uint32(10).string(message.int); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): IntProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseIntProto } as IntProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.int = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): IntProto { + const message = { ...baseIntProto } as IntProto; + if (object.int !== undefined && object.int !== null) { + message.int = String(object.int); + } else { + message.int = ""; + } + return message; + }, + + toJSON(message: IntProto): unknown { + const obj: any = {}; + message.int !== undefined && (obj.int = message.int); + return obj; + }, + + fromPartial(object: DeepPartial): IntProto { + const message = { ...baseIntProto } as IntProto; + if (object.int !== undefined && object.int !== null) { + message.int = object.int; + } else { + message.int = ""; + } + return message; + }, +}; + +const baseDecProto: object = { dec: "" }; + +export const DecProto = { + encode(message: DecProto, writer: Writer = Writer.create()): Writer { + if (message.dec !== "") { + writer.uint32(10).string(message.dec); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): DecProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseDecProto } as DecProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.dec = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DecProto { + const message = { ...baseDecProto } as DecProto; + if (object.dec !== undefined && object.dec !== null) { + message.dec = String(object.dec); + } else { + message.dec = ""; + } + return message; + }, + + toJSON(message: DecProto): unknown { + const obj: any = {}; + message.dec !== undefined && (obj.dec = message.dec); + return obj; + }, + + fromPartial(object: DeepPartial): DecProto { + const message = { ...baseDecProto } as DecProto; + if (object.dec !== undefined && object.dec !== null) { + message.dec = object.dec; + } else { + message.dec = ""; + } + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/cosmos.gov.v1beta1/types/cosmos/gov/v1beta1/genesis.ts b/ts-client/cosmos.gov.v1beta1/types/cosmos/gov/v1beta1/genesis.ts new file mode 100644 index 00000000..9d0bdd90 --- /dev/null +++ b/ts-client/cosmos.gov.v1beta1/types/cosmos/gov/v1beta1/genesis.ts @@ -0,0 +1,271 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; +import { + Deposit, + Vote, + Proposal, + DepositParams, + VotingParams, + TallyParams, +} from "../../../cosmos/gov/v1beta1/gov"; + +export const protobufPackage = "cosmos.gov.v1beta1"; + +/** GenesisState defines the gov module's genesis state. */ +export interface GenesisState { + /** starting_proposal_id is the ID of the starting proposal. */ + startingProposalId: number; + /** deposits defines all the deposits present at genesis. */ + deposits: Deposit[]; + /** votes defines all the votes present at genesis. */ + votes: Vote[]; + /** proposals defines all the proposals present at genesis. */ + proposals: Proposal[]; + /** params defines all the paramaters of related to deposit. */ + depositParams: DepositParams | undefined; + /** params defines all the paramaters of related to voting. */ + votingParams: VotingParams | undefined; + /** params defines all the paramaters of related to tally. */ + tallyParams: TallyParams | undefined; +} + +const baseGenesisState: object = { startingProposalId: 0 }; + +export const GenesisState = { + encode(message: GenesisState, writer: Writer = Writer.create()): Writer { + if (message.startingProposalId !== 0) { + writer.uint32(8).uint64(message.startingProposalId); + } + for (const v of message.deposits) { + Deposit.encode(v!, writer.uint32(18).fork()).ldelim(); + } + for (const v of message.votes) { + Vote.encode(v!, writer.uint32(26).fork()).ldelim(); + } + for (const v of message.proposals) { + Proposal.encode(v!, writer.uint32(34).fork()).ldelim(); + } + if (message.depositParams !== undefined) { + DepositParams.encode( + message.depositParams, + writer.uint32(42).fork() + ).ldelim(); + } + if (message.votingParams !== undefined) { + VotingParams.encode( + message.votingParams, + writer.uint32(50).fork() + ).ldelim(); + } + if (message.tallyParams !== undefined) { + TallyParams.encode( + message.tallyParams, + writer.uint32(58).fork() + ).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): GenesisState { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseGenesisState } as GenesisState; + message.deposits = []; + message.votes = []; + message.proposals = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.startingProposalId = longToNumber(reader.uint64() as Long); + break; + case 2: + message.deposits.push(Deposit.decode(reader, reader.uint32())); + break; + case 3: + message.votes.push(Vote.decode(reader, reader.uint32())); + break; + case 4: + message.proposals.push(Proposal.decode(reader, reader.uint32())); + break; + case 5: + message.depositParams = DepositParams.decode(reader, reader.uint32()); + break; + case 6: + message.votingParams = VotingParams.decode(reader, reader.uint32()); + break; + case 7: + message.tallyParams = TallyParams.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GenesisState { + const message = { ...baseGenesisState } as GenesisState; + message.deposits = []; + message.votes = []; + message.proposals = []; + if ( + object.startingProposalId !== undefined && + object.startingProposalId !== null + ) { + message.startingProposalId = Number(object.startingProposalId); + } else { + message.startingProposalId = 0; + } + if (object.deposits !== undefined && object.deposits !== null) { + for (const e of object.deposits) { + message.deposits.push(Deposit.fromJSON(e)); + } + } + if (object.votes !== undefined && object.votes !== null) { + for (const e of object.votes) { + message.votes.push(Vote.fromJSON(e)); + } + } + if (object.proposals !== undefined && object.proposals !== null) { + for (const e of object.proposals) { + message.proposals.push(Proposal.fromJSON(e)); + } + } + if (object.depositParams !== undefined && object.depositParams !== null) { + message.depositParams = DepositParams.fromJSON(object.depositParams); + } else { + message.depositParams = undefined; + } + if (object.votingParams !== undefined && object.votingParams !== null) { + message.votingParams = VotingParams.fromJSON(object.votingParams); + } else { + message.votingParams = undefined; + } + if (object.tallyParams !== undefined && object.tallyParams !== null) { + message.tallyParams = TallyParams.fromJSON(object.tallyParams); + } else { + message.tallyParams = undefined; + } + return message; + }, + + toJSON(message: GenesisState): unknown { + const obj: any = {}; + message.startingProposalId !== undefined && + (obj.startingProposalId = message.startingProposalId); + if (message.deposits) { + obj.deposits = message.deposits.map((e) => + e ? Deposit.toJSON(e) : undefined + ); + } else { + obj.deposits = []; + } + if (message.votes) { + obj.votes = message.votes.map((e) => (e ? Vote.toJSON(e) : undefined)); + } else { + obj.votes = []; + } + if (message.proposals) { + obj.proposals = message.proposals.map((e) => + e ? Proposal.toJSON(e) : undefined + ); + } else { + obj.proposals = []; + } + message.depositParams !== undefined && + (obj.depositParams = message.depositParams + ? DepositParams.toJSON(message.depositParams) + : undefined); + message.votingParams !== undefined && + (obj.votingParams = message.votingParams + ? VotingParams.toJSON(message.votingParams) + : undefined); + message.tallyParams !== undefined && + (obj.tallyParams = message.tallyParams + ? TallyParams.toJSON(message.tallyParams) + : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): GenesisState { + const message = { ...baseGenesisState } as GenesisState; + message.deposits = []; + message.votes = []; + message.proposals = []; + if ( + object.startingProposalId !== undefined && + object.startingProposalId !== null + ) { + message.startingProposalId = object.startingProposalId; + } else { + message.startingProposalId = 0; + } + if (object.deposits !== undefined && object.deposits !== null) { + for (const e of object.deposits) { + message.deposits.push(Deposit.fromPartial(e)); + } + } + if (object.votes !== undefined && object.votes !== null) { + for (const e of object.votes) { + message.votes.push(Vote.fromPartial(e)); + } + } + if (object.proposals !== undefined && object.proposals !== null) { + for (const e of object.proposals) { + message.proposals.push(Proposal.fromPartial(e)); + } + } + if (object.depositParams !== undefined && object.depositParams !== null) { + message.depositParams = DepositParams.fromPartial(object.depositParams); + } else { + message.depositParams = undefined; + } + if (object.votingParams !== undefined && object.votingParams !== null) { + message.votingParams = VotingParams.fromPartial(object.votingParams); + } else { + message.votingParams = undefined; + } + if (object.tallyParams !== undefined && object.tallyParams !== null) { + message.tallyParams = TallyParams.fromPartial(object.tallyParams); + } else { + message.tallyParams = undefined; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/cosmos.gov.v1beta1/types/cosmos/gov/v1beta1/gov.ts b/ts-client/cosmos.gov.v1beta1/types/cosmos/gov/v1beta1/gov.ts new file mode 100644 index 00000000..769bab70 --- /dev/null +++ b/ts-client/cosmos.gov.v1beta1/types/cosmos/gov/v1beta1/gov.ts @@ -0,0 +1,1303 @@ +/* eslint-disable */ +import { Timestamp } from "../../../google/protobuf/timestamp"; +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; +import { Coin } from "../../../cosmos/base/v1beta1/coin"; +import { Any } from "../../../google/protobuf/any"; +import { Duration } from "../../../google/protobuf/duration"; + +export const protobufPackage = "cosmos.gov.v1beta1"; + +/** VoteOption enumerates the valid vote options for a given governance proposal. */ +export enum VoteOption { + /** VOTE_OPTION_UNSPECIFIED - VOTE_OPTION_UNSPECIFIED defines a no-op vote option. */ + VOTE_OPTION_UNSPECIFIED = 0, + /** VOTE_OPTION_YES - VOTE_OPTION_YES defines a yes vote option. */ + VOTE_OPTION_YES = 1, + /** VOTE_OPTION_ABSTAIN - VOTE_OPTION_ABSTAIN defines an abstain vote option. */ + VOTE_OPTION_ABSTAIN = 2, + /** VOTE_OPTION_NO - VOTE_OPTION_NO defines a no vote option. */ + VOTE_OPTION_NO = 3, + /** VOTE_OPTION_NO_WITH_VETO - VOTE_OPTION_NO_WITH_VETO defines a no with veto vote option. */ + VOTE_OPTION_NO_WITH_VETO = 4, + UNRECOGNIZED = -1, +} + +export function voteOptionFromJSON(object: any): VoteOption { + switch (object) { + case 0: + case "VOTE_OPTION_UNSPECIFIED": + return VoteOption.VOTE_OPTION_UNSPECIFIED; + case 1: + case "VOTE_OPTION_YES": + return VoteOption.VOTE_OPTION_YES; + case 2: + case "VOTE_OPTION_ABSTAIN": + return VoteOption.VOTE_OPTION_ABSTAIN; + case 3: + case "VOTE_OPTION_NO": + return VoteOption.VOTE_OPTION_NO; + case 4: + case "VOTE_OPTION_NO_WITH_VETO": + return VoteOption.VOTE_OPTION_NO_WITH_VETO; + case -1: + case "UNRECOGNIZED": + default: + return VoteOption.UNRECOGNIZED; + } +} + +export function voteOptionToJSON(object: VoteOption): string { + switch (object) { + case VoteOption.VOTE_OPTION_UNSPECIFIED: + return "VOTE_OPTION_UNSPECIFIED"; + case VoteOption.VOTE_OPTION_YES: + return "VOTE_OPTION_YES"; + case VoteOption.VOTE_OPTION_ABSTAIN: + return "VOTE_OPTION_ABSTAIN"; + case VoteOption.VOTE_OPTION_NO: + return "VOTE_OPTION_NO"; + case VoteOption.VOTE_OPTION_NO_WITH_VETO: + return "VOTE_OPTION_NO_WITH_VETO"; + default: + return "UNKNOWN"; + } +} + +/** ProposalStatus enumerates the valid statuses of a proposal. */ +export enum ProposalStatus { + /** PROPOSAL_STATUS_UNSPECIFIED - PROPOSAL_STATUS_UNSPECIFIED defines the default propopsal status. */ + PROPOSAL_STATUS_UNSPECIFIED = 0, + /** + * PROPOSAL_STATUS_DEPOSIT_PERIOD - PROPOSAL_STATUS_DEPOSIT_PERIOD defines a proposal status during the deposit + * period. + */ + PROPOSAL_STATUS_DEPOSIT_PERIOD = 1, + /** + * PROPOSAL_STATUS_VOTING_PERIOD - PROPOSAL_STATUS_VOTING_PERIOD defines a proposal status during the voting + * period. + */ + PROPOSAL_STATUS_VOTING_PERIOD = 2, + /** + * PROPOSAL_STATUS_PASSED - PROPOSAL_STATUS_PASSED defines a proposal status of a proposal that has + * passed. + */ + PROPOSAL_STATUS_PASSED = 3, + /** + * PROPOSAL_STATUS_REJECTED - PROPOSAL_STATUS_REJECTED defines a proposal status of a proposal that has + * been rejected. + */ + PROPOSAL_STATUS_REJECTED = 4, + /** + * PROPOSAL_STATUS_FAILED - PROPOSAL_STATUS_FAILED defines a proposal status of a proposal that has + * failed. + */ + PROPOSAL_STATUS_FAILED = 5, + UNRECOGNIZED = -1, +} + +export function proposalStatusFromJSON(object: any): ProposalStatus { + switch (object) { + case 0: + case "PROPOSAL_STATUS_UNSPECIFIED": + return ProposalStatus.PROPOSAL_STATUS_UNSPECIFIED; + case 1: + case "PROPOSAL_STATUS_DEPOSIT_PERIOD": + return ProposalStatus.PROPOSAL_STATUS_DEPOSIT_PERIOD; + case 2: + case "PROPOSAL_STATUS_VOTING_PERIOD": + return ProposalStatus.PROPOSAL_STATUS_VOTING_PERIOD; + case 3: + case "PROPOSAL_STATUS_PASSED": + return ProposalStatus.PROPOSAL_STATUS_PASSED; + case 4: + case "PROPOSAL_STATUS_REJECTED": + return ProposalStatus.PROPOSAL_STATUS_REJECTED; + case 5: + case "PROPOSAL_STATUS_FAILED": + return ProposalStatus.PROPOSAL_STATUS_FAILED; + case -1: + case "UNRECOGNIZED": + default: + return ProposalStatus.UNRECOGNIZED; + } +} + +export function proposalStatusToJSON(object: ProposalStatus): string { + switch (object) { + case ProposalStatus.PROPOSAL_STATUS_UNSPECIFIED: + return "PROPOSAL_STATUS_UNSPECIFIED"; + case ProposalStatus.PROPOSAL_STATUS_DEPOSIT_PERIOD: + return "PROPOSAL_STATUS_DEPOSIT_PERIOD"; + case ProposalStatus.PROPOSAL_STATUS_VOTING_PERIOD: + return "PROPOSAL_STATUS_VOTING_PERIOD"; + case ProposalStatus.PROPOSAL_STATUS_PASSED: + return "PROPOSAL_STATUS_PASSED"; + case ProposalStatus.PROPOSAL_STATUS_REJECTED: + return "PROPOSAL_STATUS_REJECTED"; + case ProposalStatus.PROPOSAL_STATUS_FAILED: + return "PROPOSAL_STATUS_FAILED"; + default: + return "UNKNOWN"; + } +} + +/** + * WeightedVoteOption defines a unit of vote for vote split. + * + * Since: cosmos-sdk 0.43 + */ +export interface WeightedVoteOption { + option: VoteOption; + weight: string; +} + +/** + * TextProposal defines a standard text proposal whose changes need to be + * manually updated in case of approval. + */ +export interface TextProposal { + title: string; + description: string; +} + +/** + * Deposit defines an amount deposited by an account address to an active + * proposal. + */ +export interface Deposit { + proposalId: number; + depositor: string; + amount: Coin[]; +} + +/** Proposal defines the core field members of a governance proposal. */ +export interface Proposal { + proposalId: number; + content: Any | undefined; + status: ProposalStatus; + finalTallyResult: TallyResult | undefined; + submitTime: Date | undefined; + depositEndTime: Date | undefined; + totalDeposit: Coin[]; + votingStartTime: Date | undefined; + votingEndTime: Date | undefined; +} + +/** TallyResult defines a standard tally for a governance proposal. */ +export interface TallyResult { + yes: string; + abstain: string; + no: string; + noWithVeto: string; +} + +/** + * Vote defines a vote on a governance proposal. + * A Vote consists of a proposal ID, the voter, and the vote option. + */ +export interface Vote { + proposalId: number; + voter: string; + /** + * Deprecated: Prefer to use `options` instead. This field is set in queries + * if and only if `len(options) == 1` and that option has weight 1. In all + * other cases, this field will default to VOTE_OPTION_UNSPECIFIED. + * + * @deprecated + */ + option: VoteOption; + /** Since: cosmos-sdk 0.43 */ + options: WeightedVoteOption[]; +} + +/** DepositParams defines the params for deposits on governance proposals. */ +export interface DepositParams { + /** Minimum deposit for a proposal to enter voting period. */ + minDeposit: Coin[]; + /** + * Maximum period for Atom holders to deposit on a proposal. Initial value: 2 + * months. + */ + maxDepositPeriod: Duration | undefined; +} + +/** VotingParams defines the params for voting on governance proposals. */ +export interface VotingParams { + /** Length of the voting period. */ + votingPeriod: Duration | undefined; +} + +/** TallyParams defines the params for tallying votes on governance proposals. */ +export interface TallyParams { + /** + * Minimum percentage of total stake needed to vote for a result to be + * considered valid. + */ + quorum: Uint8Array; + /** Minimum proportion of Yes votes for proposal to pass. Default value: 0.5. */ + threshold: Uint8Array; + /** + * Minimum value of Veto votes to Total votes ratio for proposal to be + * vetoed. Default value: 1/3. + */ + vetoThreshold: Uint8Array; +} + +const baseWeightedVoteOption: object = { option: 0, weight: "" }; + +export const WeightedVoteOption = { + encode( + message: WeightedVoteOption, + writer: Writer = Writer.create() + ): Writer { + if (message.option !== 0) { + writer.uint32(8).int32(message.option); + } + if (message.weight !== "") { + writer.uint32(18).string(message.weight); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): WeightedVoteOption { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseWeightedVoteOption } as WeightedVoteOption; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.option = reader.int32() as any; + break; + case 2: + message.weight = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): WeightedVoteOption { + const message = { ...baseWeightedVoteOption } as WeightedVoteOption; + if (object.option !== undefined && object.option !== null) { + message.option = voteOptionFromJSON(object.option); + } else { + message.option = 0; + } + if (object.weight !== undefined && object.weight !== null) { + message.weight = String(object.weight); + } else { + message.weight = ""; + } + return message; + }, + + toJSON(message: WeightedVoteOption): unknown { + const obj: any = {}; + message.option !== undefined && + (obj.option = voteOptionToJSON(message.option)); + message.weight !== undefined && (obj.weight = message.weight); + return obj; + }, + + fromPartial(object: DeepPartial): WeightedVoteOption { + const message = { ...baseWeightedVoteOption } as WeightedVoteOption; + if (object.option !== undefined && object.option !== null) { + message.option = object.option; + } else { + message.option = 0; + } + if (object.weight !== undefined && object.weight !== null) { + message.weight = object.weight; + } else { + message.weight = ""; + } + return message; + }, +}; + +const baseTextProposal: object = { title: "", description: "" }; + +export const TextProposal = { + encode(message: TextProposal, writer: Writer = Writer.create()): Writer { + if (message.title !== "") { + writer.uint32(10).string(message.title); + } + if (message.description !== "") { + writer.uint32(18).string(message.description); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): TextProposal { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseTextProposal } as TextProposal; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.title = reader.string(); + break; + case 2: + message.description = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): TextProposal { + const message = { ...baseTextProposal } as TextProposal; + if (object.title !== undefined && object.title !== null) { + message.title = String(object.title); + } else { + message.title = ""; + } + if (object.description !== undefined && object.description !== null) { + message.description = String(object.description); + } else { + message.description = ""; + } + return message; + }, + + toJSON(message: TextProposal): unknown { + const obj: any = {}; + message.title !== undefined && (obj.title = message.title); + message.description !== undefined && + (obj.description = message.description); + return obj; + }, + + fromPartial(object: DeepPartial): TextProposal { + const message = { ...baseTextProposal } as TextProposal; + if (object.title !== undefined && object.title !== null) { + message.title = object.title; + } else { + message.title = ""; + } + if (object.description !== undefined && object.description !== null) { + message.description = object.description; + } else { + message.description = ""; + } + return message; + }, +}; + +const baseDeposit: object = { proposalId: 0, depositor: "" }; + +export const Deposit = { + encode(message: Deposit, writer: Writer = Writer.create()): Writer { + if (message.proposalId !== 0) { + writer.uint32(8).uint64(message.proposalId); + } + if (message.depositor !== "") { + writer.uint32(18).string(message.depositor); + } + for (const v of message.amount) { + Coin.encode(v!, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Deposit { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseDeposit } as Deposit; + message.amount = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.proposalId = longToNumber(reader.uint64() as Long); + break; + case 2: + message.depositor = reader.string(); + break; + case 3: + message.amount.push(Coin.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Deposit { + const message = { ...baseDeposit } as Deposit; + message.amount = []; + if (object.proposalId !== undefined && object.proposalId !== null) { + message.proposalId = Number(object.proposalId); + } else { + message.proposalId = 0; + } + if (object.depositor !== undefined && object.depositor !== null) { + message.depositor = String(object.depositor); + } else { + message.depositor = ""; + } + if (object.amount !== undefined && object.amount !== null) { + for (const e of object.amount) { + message.amount.push(Coin.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: Deposit): unknown { + const obj: any = {}; + message.proposalId !== undefined && (obj.proposalId = message.proposalId); + message.depositor !== undefined && (obj.depositor = message.depositor); + if (message.amount) { + obj.amount = message.amount.map((e) => (e ? Coin.toJSON(e) : undefined)); + } else { + obj.amount = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): Deposit { + const message = { ...baseDeposit } as Deposit; + message.amount = []; + if (object.proposalId !== undefined && object.proposalId !== null) { + message.proposalId = object.proposalId; + } else { + message.proposalId = 0; + } + if (object.depositor !== undefined && object.depositor !== null) { + message.depositor = object.depositor; + } else { + message.depositor = ""; + } + if (object.amount !== undefined && object.amount !== null) { + for (const e of object.amount) { + message.amount.push(Coin.fromPartial(e)); + } + } + return message; + }, +}; + +const baseProposal: object = { proposalId: 0, status: 0 }; + +export const Proposal = { + encode(message: Proposal, writer: Writer = Writer.create()): Writer { + if (message.proposalId !== 0) { + writer.uint32(8).uint64(message.proposalId); + } + if (message.content !== undefined) { + Any.encode(message.content, writer.uint32(18).fork()).ldelim(); + } + if (message.status !== 0) { + writer.uint32(24).int32(message.status); + } + if (message.finalTallyResult !== undefined) { + TallyResult.encode( + message.finalTallyResult, + writer.uint32(34).fork() + ).ldelim(); + } + if (message.submitTime !== undefined) { + Timestamp.encode( + toTimestamp(message.submitTime), + writer.uint32(42).fork() + ).ldelim(); + } + if (message.depositEndTime !== undefined) { + Timestamp.encode( + toTimestamp(message.depositEndTime), + writer.uint32(50).fork() + ).ldelim(); + } + for (const v of message.totalDeposit) { + Coin.encode(v!, writer.uint32(58).fork()).ldelim(); + } + if (message.votingStartTime !== undefined) { + Timestamp.encode( + toTimestamp(message.votingStartTime), + writer.uint32(66).fork() + ).ldelim(); + } + if (message.votingEndTime !== undefined) { + Timestamp.encode( + toTimestamp(message.votingEndTime), + writer.uint32(74).fork() + ).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Proposal { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseProposal } as Proposal; + message.totalDeposit = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.proposalId = longToNumber(reader.uint64() as Long); + break; + case 2: + message.content = Any.decode(reader, reader.uint32()); + break; + case 3: + message.status = reader.int32() as any; + break; + case 4: + message.finalTallyResult = TallyResult.decode( + reader, + reader.uint32() + ); + break; + case 5: + message.submitTime = fromTimestamp( + Timestamp.decode(reader, reader.uint32()) + ); + break; + case 6: + message.depositEndTime = fromTimestamp( + Timestamp.decode(reader, reader.uint32()) + ); + break; + case 7: + message.totalDeposit.push(Coin.decode(reader, reader.uint32())); + break; + case 8: + message.votingStartTime = fromTimestamp( + Timestamp.decode(reader, reader.uint32()) + ); + break; + case 9: + message.votingEndTime = fromTimestamp( + Timestamp.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Proposal { + const message = { ...baseProposal } as Proposal; + message.totalDeposit = []; + if (object.proposalId !== undefined && object.proposalId !== null) { + message.proposalId = Number(object.proposalId); + } else { + message.proposalId = 0; + } + if (object.content !== undefined && object.content !== null) { + message.content = Any.fromJSON(object.content); + } else { + message.content = undefined; + } + if (object.status !== undefined && object.status !== null) { + message.status = proposalStatusFromJSON(object.status); + } else { + message.status = 0; + } + if ( + object.finalTallyResult !== undefined && + object.finalTallyResult !== null + ) { + message.finalTallyResult = TallyResult.fromJSON(object.finalTallyResult); + } else { + message.finalTallyResult = undefined; + } + if (object.submitTime !== undefined && object.submitTime !== null) { + message.submitTime = fromJsonTimestamp(object.submitTime); + } else { + message.submitTime = undefined; + } + if (object.depositEndTime !== undefined && object.depositEndTime !== null) { + message.depositEndTime = fromJsonTimestamp(object.depositEndTime); + } else { + message.depositEndTime = undefined; + } + if (object.totalDeposit !== undefined && object.totalDeposit !== null) { + for (const e of object.totalDeposit) { + message.totalDeposit.push(Coin.fromJSON(e)); + } + } + if ( + object.votingStartTime !== undefined && + object.votingStartTime !== null + ) { + message.votingStartTime = fromJsonTimestamp(object.votingStartTime); + } else { + message.votingStartTime = undefined; + } + if (object.votingEndTime !== undefined && object.votingEndTime !== null) { + message.votingEndTime = fromJsonTimestamp(object.votingEndTime); + } else { + message.votingEndTime = undefined; + } + return message; + }, + + toJSON(message: Proposal): unknown { + const obj: any = {}; + message.proposalId !== undefined && (obj.proposalId = message.proposalId); + message.content !== undefined && + (obj.content = message.content ? Any.toJSON(message.content) : undefined); + message.status !== undefined && + (obj.status = proposalStatusToJSON(message.status)); + message.finalTallyResult !== undefined && + (obj.finalTallyResult = message.finalTallyResult + ? TallyResult.toJSON(message.finalTallyResult) + : undefined); + message.submitTime !== undefined && + (obj.submitTime = + message.submitTime !== undefined + ? message.submitTime.toISOString() + : null); + message.depositEndTime !== undefined && + (obj.depositEndTime = + message.depositEndTime !== undefined + ? message.depositEndTime.toISOString() + : null); + if (message.totalDeposit) { + obj.totalDeposit = message.totalDeposit.map((e) => + e ? Coin.toJSON(e) : undefined + ); + } else { + obj.totalDeposit = []; + } + message.votingStartTime !== undefined && + (obj.votingStartTime = + message.votingStartTime !== undefined + ? message.votingStartTime.toISOString() + : null); + message.votingEndTime !== undefined && + (obj.votingEndTime = + message.votingEndTime !== undefined + ? message.votingEndTime.toISOString() + : null); + return obj; + }, + + fromPartial(object: DeepPartial): Proposal { + const message = { ...baseProposal } as Proposal; + message.totalDeposit = []; + if (object.proposalId !== undefined && object.proposalId !== null) { + message.proposalId = object.proposalId; + } else { + message.proposalId = 0; + } + if (object.content !== undefined && object.content !== null) { + message.content = Any.fromPartial(object.content); + } else { + message.content = undefined; + } + if (object.status !== undefined && object.status !== null) { + message.status = object.status; + } else { + message.status = 0; + } + if ( + object.finalTallyResult !== undefined && + object.finalTallyResult !== null + ) { + message.finalTallyResult = TallyResult.fromPartial( + object.finalTallyResult + ); + } else { + message.finalTallyResult = undefined; + } + if (object.submitTime !== undefined && object.submitTime !== null) { + message.submitTime = object.submitTime; + } else { + message.submitTime = undefined; + } + if (object.depositEndTime !== undefined && object.depositEndTime !== null) { + message.depositEndTime = object.depositEndTime; + } else { + message.depositEndTime = undefined; + } + if (object.totalDeposit !== undefined && object.totalDeposit !== null) { + for (const e of object.totalDeposit) { + message.totalDeposit.push(Coin.fromPartial(e)); + } + } + if ( + object.votingStartTime !== undefined && + object.votingStartTime !== null + ) { + message.votingStartTime = object.votingStartTime; + } else { + message.votingStartTime = undefined; + } + if (object.votingEndTime !== undefined && object.votingEndTime !== null) { + message.votingEndTime = object.votingEndTime; + } else { + message.votingEndTime = undefined; + } + return message; + }, +}; + +const baseTallyResult: object = { + yes: "", + abstain: "", + no: "", + noWithVeto: "", +}; + +export const TallyResult = { + encode(message: TallyResult, writer: Writer = Writer.create()): Writer { + if (message.yes !== "") { + writer.uint32(10).string(message.yes); + } + if (message.abstain !== "") { + writer.uint32(18).string(message.abstain); + } + if (message.no !== "") { + writer.uint32(26).string(message.no); + } + if (message.noWithVeto !== "") { + writer.uint32(34).string(message.noWithVeto); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): TallyResult { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseTallyResult } as TallyResult; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.yes = reader.string(); + break; + case 2: + message.abstain = reader.string(); + break; + case 3: + message.no = reader.string(); + break; + case 4: + message.noWithVeto = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): TallyResult { + const message = { ...baseTallyResult } as TallyResult; + if (object.yes !== undefined && object.yes !== null) { + message.yes = String(object.yes); + } else { + message.yes = ""; + } + if (object.abstain !== undefined && object.abstain !== null) { + message.abstain = String(object.abstain); + } else { + message.abstain = ""; + } + if (object.no !== undefined && object.no !== null) { + message.no = String(object.no); + } else { + message.no = ""; + } + if (object.noWithVeto !== undefined && object.noWithVeto !== null) { + message.noWithVeto = String(object.noWithVeto); + } else { + message.noWithVeto = ""; + } + return message; + }, + + toJSON(message: TallyResult): unknown { + const obj: any = {}; + message.yes !== undefined && (obj.yes = message.yes); + message.abstain !== undefined && (obj.abstain = message.abstain); + message.no !== undefined && (obj.no = message.no); + message.noWithVeto !== undefined && (obj.noWithVeto = message.noWithVeto); + return obj; + }, + + fromPartial(object: DeepPartial): TallyResult { + const message = { ...baseTallyResult } as TallyResult; + if (object.yes !== undefined && object.yes !== null) { + message.yes = object.yes; + } else { + message.yes = ""; + } + if (object.abstain !== undefined && object.abstain !== null) { + message.abstain = object.abstain; + } else { + message.abstain = ""; + } + if (object.no !== undefined && object.no !== null) { + message.no = object.no; + } else { + message.no = ""; + } + if (object.noWithVeto !== undefined && object.noWithVeto !== null) { + message.noWithVeto = object.noWithVeto; + } else { + message.noWithVeto = ""; + } + return message; + }, +}; + +const baseVote: object = { proposalId: 0, voter: "", option: 0 }; + +export const Vote = { + encode(message: Vote, writer: Writer = Writer.create()): Writer { + if (message.proposalId !== 0) { + writer.uint32(8).uint64(message.proposalId); + } + if (message.voter !== "") { + writer.uint32(18).string(message.voter); + } + if (message.option !== 0) { + writer.uint32(24).int32(message.option); + } + for (const v of message.options) { + WeightedVoteOption.encode(v!, writer.uint32(34).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Vote { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseVote } as Vote; + message.options = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.proposalId = longToNumber(reader.uint64() as Long); + break; + case 2: + message.voter = reader.string(); + break; + case 3: + message.option = reader.int32() as any; + break; + case 4: + message.options.push( + WeightedVoteOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Vote { + const message = { ...baseVote } as Vote; + message.options = []; + if (object.proposalId !== undefined && object.proposalId !== null) { + message.proposalId = Number(object.proposalId); + } else { + message.proposalId = 0; + } + if (object.voter !== undefined && object.voter !== null) { + message.voter = String(object.voter); + } else { + message.voter = ""; + } + if (object.option !== undefined && object.option !== null) { + message.option = voteOptionFromJSON(object.option); + } else { + message.option = 0; + } + if (object.options !== undefined && object.options !== null) { + for (const e of object.options) { + message.options.push(WeightedVoteOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: Vote): unknown { + const obj: any = {}; + message.proposalId !== undefined && (obj.proposalId = message.proposalId); + message.voter !== undefined && (obj.voter = message.voter); + message.option !== undefined && + (obj.option = voteOptionToJSON(message.option)); + if (message.options) { + obj.options = message.options.map((e) => + e ? WeightedVoteOption.toJSON(e) : undefined + ); + } else { + obj.options = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): Vote { + const message = { ...baseVote } as Vote; + message.options = []; + if (object.proposalId !== undefined && object.proposalId !== null) { + message.proposalId = object.proposalId; + } else { + message.proposalId = 0; + } + if (object.voter !== undefined && object.voter !== null) { + message.voter = object.voter; + } else { + message.voter = ""; + } + if (object.option !== undefined && object.option !== null) { + message.option = object.option; + } else { + message.option = 0; + } + if (object.options !== undefined && object.options !== null) { + for (const e of object.options) { + message.options.push(WeightedVoteOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseDepositParams: object = {}; + +export const DepositParams = { + encode(message: DepositParams, writer: Writer = Writer.create()): Writer { + for (const v of message.minDeposit) { + Coin.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.maxDepositPeriod !== undefined) { + Duration.encode( + message.maxDepositPeriod, + writer.uint32(18).fork() + ).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): DepositParams { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseDepositParams } as DepositParams; + message.minDeposit = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.minDeposit.push(Coin.decode(reader, reader.uint32())); + break; + case 2: + message.maxDepositPeriod = Duration.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DepositParams { + const message = { ...baseDepositParams } as DepositParams; + message.minDeposit = []; + if (object.minDeposit !== undefined && object.minDeposit !== null) { + for (const e of object.minDeposit) { + message.minDeposit.push(Coin.fromJSON(e)); + } + } + if ( + object.maxDepositPeriod !== undefined && + object.maxDepositPeriod !== null + ) { + message.maxDepositPeriod = Duration.fromJSON(object.maxDepositPeriod); + } else { + message.maxDepositPeriod = undefined; + } + return message; + }, + + toJSON(message: DepositParams): unknown { + const obj: any = {}; + if (message.minDeposit) { + obj.minDeposit = message.minDeposit.map((e) => + e ? Coin.toJSON(e) : undefined + ); + } else { + obj.minDeposit = []; + } + message.maxDepositPeriod !== undefined && + (obj.maxDepositPeriod = message.maxDepositPeriod + ? Duration.toJSON(message.maxDepositPeriod) + : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): DepositParams { + const message = { ...baseDepositParams } as DepositParams; + message.minDeposit = []; + if (object.minDeposit !== undefined && object.minDeposit !== null) { + for (const e of object.minDeposit) { + message.minDeposit.push(Coin.fromPartial(e)); + } + } + if ( + object.maxDepositPeriod !== undefined && + object.maxDepositPeriod !== null + ) { + message.maxDepositPeriod = Duration.fromPartial(object.maxDepositPeriod); + } else { + message.maxDepositPeriod = undefined; + } + return message; + }, +}; + +const baseVotingParams: object = {}; + +export const VotingParams = { + encode(message: VotingParams, writer: Writer = Writer.create()): Writer { + if (message.votingPeriod !== undefined) { + Duration.encode(message.votingPeriod, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): VotingParams { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseVotingParams } as VotingParams; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.votingPeriod = Duration.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): VotingParams { + const message = { ...baseVotingParams } as VotingParams; + if (object.votingPeriod !== undefined && object.votingPeriod !== null) { + message.votingPeriod = Duration.fromJSON(object.votingPeriod); + } else { + message.votingPeriod = undefined; + } + return message; + }, + + toJSON(message: VotingParams): unknown { + const obj: any = {}; + message.votingPeriod !== undefined && + (obj.votingPeriod = message.votingPeriod + ? Duration.toJSON(message.votingPeriod) + : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): VotingParams { + const message = { ...baseVotingParams } as VotingParams; + if (object.votingPeriod !== undefined && object.votingPeriod !== null) { + message.votingPeriod = Duration.fromPartial(object.votingPeriod); + } else { + message.votingPeriod = undefined; + } + return message; + }, +}; + +const baseTallyParams: object = {}; + +export const TallyParams = { + encode(message: TallyParams, writer: Writer = Writer.create()): Writer { + if (message.quorum.length !== 0) { + writer.uint32(10).bytes(message.quorum); + } + if (message.threshold.length !== 0) { + writer.uint32(18).bytes(message.threshold); + } + if (message.vetoThreshold.length !== 0) { + writer.uint32(26).bytes(message.vetoThreshold); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): TallyParams { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseTallyParams } as TallyParams; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.quorum = reader.bytes(); + break; + case 2: + message.threshold = reader.bytes(); + break; + case 3: + message.vetoThreshold = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): TallyParams { + const message = { ...baseTallyParams } as TallyParams; + if (object.quorum !== undefined && object.quorum !== null) { + message.quorum = bytesFromBase64(object.quorum); + } + if (object.threshold !== undefined && object.threshold !== null) { + message.threshold = bytesFromBase64(object.threshold); + } + if (object.vetoThreshold !== undefined && object.vetoThreshold !== null) { + message.vetoThreshold = bytesFromBase64(object.vetoThreshold); + } + return message; + }, + + toJSON(message: TallyParams): unknown { + const obj: any = {}; + message.quorum !== undefined && + (obj.quorum = base64FromBytes( + message.quorum !== undefined ? message.quorum : new Uint8Array() + )); + message.threshold !== undefined && + (obj.threshold = base64FromBytes( + message.threshold !== undefined ? message.threshold : new Uint8Array() + )); + message.vetoThreshold !== undefined && + (obj.vetoThreshold = base64FromBytes( + message.vetoThreshold !== undefined + ? message.vetoThreshold + : new Uint8Array() + )); + return obj; + }, + + fromPartial(object: DeepPartial): TallyParams { + const message = { ...baseTallyParams } as TallyParams; + if (object.quorum !== undefined && object.quorum !== null) { + message.quorum = object.quorum; + } else { + message.quorum = new Uint8Array(); + } + if (object.threshold !== undefined && object.threshold !== null) { + message.threshold = object.threshold; + } else { + message.threshold = new Uint8Array(); + } + if (object.vetoThreshold !== undefined && object.vetoThreshold !== null) { + message.vetoThreshold = object.vetoThreshold; + } else { + message.vetoThreshold = new Uint8Array(); + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function toTimestamp(date: Date): Timestamp { + const seconds = date.getTime() / 1_000; + const nanos = (date.getTime() % 1_000) * 1_000_000; + return { seconds, nanos }; +} + +function fromTimestamp(t: Timestamp): Date { + let millis = t.seconds * 1_000; + millis += t.nanos / 1_000_000; + return new Date(millis); +} + +function fromJsonTimestamp(o: any): Date { + if (o instanceof Date) { + return o; + } else if (typeof o === "string") { + return new Date(o); + } else { + return fromTimestamp(Timestamp.fromJSON(o)); + } +} + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/cosmos.gov.v1beta1/types/cosmos/gov/v1beta1/query.ts b/ts-client/cosmos.gov.v1beta1/types/cosmos/gov/v1beta1/query.ts new file mode 100644 index 00000000..cde4f296 --- /dev/null +++ b/ts-client/cosmos.gov.v1beta1/types/cosmos/gov/v1beta1/query.ts @@ -0,0 +1,1532 @@ +/* eslint-disable */ +import { + ProposalStatus, + Proposal, + Vote, + VotingParams, + DepositParams, + TallyParams, + Deposit, + TallyResult, + proposalStatusFromJSON, + proposalStatusToJSON, +} from "../../../cosmos/gov/v1beta1/gov"; +import { Reader, util, configure, Writer } from "protobufjs/minimal"; +import * as Long from "long"; +import { + PageRequest, + PageResponse, +} from "../../../cosmos/base/query/v1beta1/pagination"; + +export const protobufPackage = "cosmos.gov.v1beta1"; + +/** QueryProposalRequest is the request type for the Query/Proposal RPC method. */ +export interface QueryProposalRequest { + /** proposal_id defines the unique id of the proposal. */ + proposalId: number; +} + +/** QueryProposalResponse is the response type for the Query/Proposal RPC method. */ +export interface QueryProposalResponse { + proposal: Proposal | undefined; +} + +/** QueryProposalsRequest is the request type for the Query/Proposals RPC method. */ +export interface QueryProposalsRequest { + /** proposal_status defines the status of the proposals. */ + proposalStatus: ProposalStatus; + /** voter defines the voter address for the proposals. */ + voter: string; + /** depositor defines the deposit addresses from the proposals. */ + depositor: string; + /** pagination defines an optional pagination for the request. */ + pagination: PageRequest | undefined; +} + +/** + * QueryProposalsResponse is the response type for the Query/Proposals RPC + * method. + */ +export interface QueryProposalsResponse { + proposals: Proposal[]; + /** pagination defines the pagination in the response. */ + pagination: PageResponse | undefined; +} + +/** QueryVoteRequest is the request type for the Query/Vote RPC method. */ +export interface QueryVoteRequest { + /** proposal_id defines the unique id of the proposal. */ + proposalId: number; + /** voter defines the oter address for the proposals. */ + voter: string; +} + +/** QueryVoteResponse is the response type for the Query/Vote RPC method. */ +export interface QueryVoteResponse { + /** vote defined the queried vote. */ + vote: Vote | undefined; +} + +/** QueryVotesRequest is the request type for the Query/Votes RPC method. */ +export interface QueryVotesRequest { + /** proposal_id defines the unique id of the proposal. */ + proposalId: number; + /** pagination defines an optional pagination for the request. */ + pagination: PageRequest | undefined; +} + +/** QueryVotesResponse is the response type for the Query/Votes RPC method. */ +export interface QueryVotesResponse { + /** votes defined the queried votes. */ + votes: Vote[]; + /** pagination defines the pagination in the response. */ + pagination: PageResponse | undefined; +} + +/** QueryParamsRequest is the request type for the Query/Params RPC method. */ +export interface QueryParamsRequest { + /** + * params_type defines which parameters to query for, can be one of "voting", + * "tallying" or "deposit". + */ + paramsType: string; +} + +/** QueryParamsResponse is the response type for the Query/Params RPC method. */ +export interface QueryParamsResponse { + /** voting_params defines the parameters related to voting. */ + votingParams: VotingParams | undefined; + /** deposit_params defines the parameters related to deposit. */ + depositParams: DepositParams | undefined; + /** tally_params defines the parameters related to tally. */ + tallyParams: TallyParams | undefined; +} + +/** QueryDepositRequest is the request type for the Query/Deposit RPC method. */ +export interface QueryDepositRequest { + /** proposal_id defines the unique id of the proposal. */ + proposalId: number; + /** depositor defines the deposit addresses from the proposals. */ + depositor: string; +} + +/** QueryDepositResponse is the response type for the Query/Deposit RPC method. */ +export interface QueryDepositResponse { + /** deposit defines the requested deposit. */ + deposit: Deposit | undefined; +} + +/** QueryDepositsRequest is the request type for the Query/Deposits RPC method. */ +export interface QueryDepositsRequest { + /** proposal_id defines the unique id of the proposal. */ + proposalId: number; + /** pagination defines an optional pagination for the request. */ + pagination: PageRequest | undefined; +} + +/** QueryDepositsResponse is the response type for the Query/Deposits RPC method. */ +export interface QueryDepositsResponse { + deposits: Deposit[]; + /** pagination defines the pagination in the response. */ + pagination: PageResponse | undefined; +} + +/** QueryTallyResultRequest is the request type for the Query/Tally RPC method. */ +export interface QueryTallyResultRequest { + /** proposal_id defines the unique id of the proposal. */ + proposalId: number; +} + +/** QueryTallyResultResponse is the response type for the Query/Tally RPC method. */ +export interface QueryTallyResultResponse { + /** tally defines the requested tally. */ + tally: TallyResult | undefined; +} + +const baseQueryProposalRequest: object = { proposalId: 0 }; + +export const QueryProposalRequest = { + encode( + message: QueryProposalRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.proposalId !== 0) { + writer.uint32(8).uint64(message.proposalId); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QueryProposalRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryProposalRequest } as QueryProposalRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.proposalId = longToNumber(reader.uint64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryProposalRequest { + const message = { ...baseQueryProposalRequest } as QueryProposalRequest; + if (object.proposalId !== undefined && object.proposalId !== null) { + message.proposalId = Number(object.proposalId); + } else { + message.proposalId = 0; + } + return message; + }, + + toJSON(message: QueryProposalRequest): unknown { + const obj: any = {}; + message.proposalId !== undefined && (obj.proposalId = message.proposalId); + return obj; + }, + + fromPartial(object: DeepPartial): QueryProposalRequest { + const message = { ...baseQueryProposalRequest } as QueryProposalRequest; + if (object.proposalId !== undefined && object.proposalId !== null) { + message.proposalId = object.proposalId; + } else { + message.proposalId = 0; + } + return message; + }, +}; + +const baseQueryProposalResponse: object = {}; + +export const QueryProposalResponse = { + encode( + message: QueryProposalResponse, + writer: Writer = Writer.create() + ): Writer { + if (message.proposal !== undefined) { + Proposal.encode(message.proposal, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QueryProposalResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryProposalResponse } as QueryProposalResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.proposal = Proposal.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryProposalResponse { + const message = { ...baseQueryProposalResponse } as QueryProposalResponse; + if (object.proposal !== undefined && object.proposal !== null) { + message.proposal = Proposal.fromJSON(object.proposal); + } else { + message.proposal = undefined; + } + return message; + }, + + toJSON(message: QueryProposalResponse): unknown { + const obj: any = {}; + message.proposal !== undefined && + (obj.proposal = message.proposal + ? Proposal.toJSON(message.proposal) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryProposalResponse { + const message = { ...baseQueryProposalResponse } as QueryProposalResponse; + if (object.proposal !== undefined && object.proposal !== null) { + message.proposal = Proposal.fromPartial(object.proposal); + } else { + message.proposal = undefined; + } + return message; + }, +}; + +const baseQueryProposalsRequest: object = { + proposalStatus: 0, + voter: "", + depositor: "", +}; + +export const QueryProposalsRequest = { + encode( + message: QueryProposalsRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.proposalStatus !== 0) { + writer.uint32(8).int32(message.proposalStatus); + } + if (message.voter !== "") { + writer.uint32(18).string(message.voter); + } + if (message.depositor !== "") { + writer.uint32(26).string(message.depositor); + } + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(34).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QueryProposalsRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryProposalsRequest } as QueryProposalsRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.proposalStatus = reader.int32() as any; + break; + case 2: + message.voter = reader.string(); + break; + case 3: + message.depositor = reader.string(); + break; + case 4: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryProposalsRequest { + const message = { ...baseQueryProposalsRequest } as QueryProposalsRequest; + if (object.proposalStatus !== undefined && object.proposalStatus !== null) { + message.proposalStatus = proposalStatusFromJSON(object.proposalStatus); + } else { + message.proposalStatus = 0; + } + if (object.voter !== undefined && object.voter !== null) { + message.voter = String(object.voter); + } else { + message.voter = ""; + } + if (object.depositor !== undefined && object.depositor !== null) { + message.depositor = String(object.depositor); + } else { + message.depositor = ""; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryProposalsRequest): unknown { + const obj: any = {}; + message.proposalStatus !== undefined && + (obj.proposalStatus = proposalStatusToJSON(message.proposalStatus)); + message.voter !== undefined && (obj.voter = message.voter); + message.depositor !== undefined && (obj.depositor = message.depositor); + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageRequest.toJSON(message.pagination) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryProposalsRequest { + const message = { ...baseQueryProposalsRequest } as QueryProposalsRequest; + if (object.proposalStatus !== undefined && object.proposalStatus !== null) { + message.proposalStatus = object.proposalStatus; + } else { + message.proposalStatus = 0; + } + if (object.voter !== undefined && object.voter !== null) { + message.voter = object.voter; + } else { + message.voter = ""; + } + if (object.depositor !== undefined && object.depositor !== null) { + message.depositor = object.depositor; + } else { + message.depositor = ""; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseQueryProposalsResponse: object = {}; + +export const QueryProposalsResponse = { + encode( + message: QueryProposalsResponse, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.proposals) { + Proposal.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode( + message.pagination, + writer.uint32(18).fork() + ).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QueryProposalsResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryProposalsResponse } as QueryProposalsResponse; + message.proposals = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.proposals.push(Proposal.decode(reader, reader.uint32())); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryProposalsResponse { + const message = { ...baseQueryProposalsResponse } as QueryProposalsResponse; + message.proposals = []; + if (object.proposals !== undefined && object.proposals !== null) { + for (const e of object.proposals) { + message.proposals.push(Proposal.fromJSON(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryProposalsResponse): unknown { + const obj: any = {}; + if (message.proposals) { + obj.proposals = message.proposals.map((e) => + e ? Proposal.toJSON(e) : undefined + ); + } else { + obj.proposals = []; + } + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageResponse.toJSON(message.pagination) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryProposalsResponse { + const message = { ...baseQueryProposalsResponse } as QueryProposalsResponse; + message.proposals = []; + if (object.proposals !== undefined && object.proposals !== null) { + for (const e of object.proposals) { + message.proposals.push(Proposal.fromPartial(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseQueryVoteRequest: object = { proposalId: 0, voter: "" }; + +export const QueryVoteRequest = { + encode(message: QueryVoteRequest, writer: Writer = Writer.create()): Writer { + if (message.proposalId !== 0) { + writer.uint32(8).uint64(message.proposalId); + } + if (message.voter !== "") { + writer.uint32(18).string(message.voter); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QueryVoteRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryVoteRequest } as QueryVoteRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.proposalId = longToNumber(reader.uint64() as Long); + break; + case 2: + message.voter = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryVoteRequest { + const message = { ...baseQueryVoteRequest } as QueryVoteRequest; + if (object.proposalId !== undefined && object.proposalId !== null) { + message.proposalId = Number(object.proposalId); + } else { + message.proposalId = 0; + } + if (object.voter !== undefined && object.voter !== null) { + message.voter = String(object.voter); + } else { + message.voter = ""; + } + return message; + }, + + toJSON(message: QueryVoteRequest): unknown { + const obj: any = {}; + message.proposalId !== undefined && (obj.proposalId = message.proposalId); + message.voter !== undefined && (obj.voter = message.voter); + return obj; + }, + + fromPartial(object: DeepPartial): QueryVoteRequest { + const message = { ...baseQueryVoteRequest } as QueryVoteRequest; + if (object.proposalId !== undefined && object.proposalId !== null) { + message.proposalId = object.proposalId; + } else { + message.proposalId = 0; + } + if (object.voter !== undefined && object.voter !== null) { + message.voter = object.voter; + } else { + message.voter = ""; + } + return message; + }, +}; + +const baseQueryVoteResponse: object = {}; + +export const QueryVoteResponse = { + encode(message: QueryVoteResponse, writer: Writer = Writer.create()): Writer { + if (message.vote !== undefined) { + Vote.encode(message.vote, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QueryVoteResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryVoteResponse } as QueryVoteResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.vote = Vote.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryVoteResponse { + const message = { ...baseQueryVoteResponse } as QueryVoteResponse; + if (object.vote !== undefined && object.vote !== null) { + message.vote = Vote.fromJSON(object.vote); + } else { + message.vote = undefined; + } + return message; + }, + + toJSON(message: QueryVoteResponse): unknown { + const obj: any = {}; + message.vote !== undefined && + (obj.vote = message.vote ? Vote.toJSON(message.vote) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): QueryVoteResponse { + const message = { ...baseQueryVoteResponse } as QueryVoteResponse; + if (object.vote !== undefined && object.vote !== null) { + message.vote = Vote.fromPartial(object.vote); + } else { + message.vote = undefined; + } + return message; + }, +}; + +const baseQueryVotesRequest: object = { proposalId: 0 }; + +export const QueryVotesRequest = { + encode(message: QueryVotesRequest, writer: Writer = Writer.create()): Writer { + if (message.proposalId !== 0) { + writer.uint32(8).uint64(message.proposalId); + } + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QueryVotesRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryVotesRequest } as QueryVotesRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.proposalId = longToNumber(reader.uint64() as Long); + break; + case 2: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryVotesRequest { + const message = { ...baseQueryVotesRequest } as QueryVotesRequest; + if (object.proposalId !== undefined && object.proposalId !== null) { + message.proposalId = Number(object.proposalId); + } else { + message.proposalId = 0; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryVotesRequest): unknown { + const obj: any = {}; + message.proposalId !== undefined && (obj.proposalId = message.proposalId); + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageRequest.toJSON(message.pagination) + : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): QueryVotesRequest { + const message = { ...baseQueryVotesRequest } as QueryVotesRequest; + if (object.proposalId !== undefined && object.proposalId !== null) { + message.proposalId = object.proposalId; + } else { + message.proposalId = 0; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseQueryVotesResponse: object = {}; + +export const QueryVotesResponse = { + encode( + message: QueryVotesResponse, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.votes) { + Vote.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode( + message.pagination, + writer.uint32(18).fork() + ).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QueryVotesResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryVotesResponse } as QueryVotesResponse; + message.votes = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.votes.push(Vote.decode(reader, reader.uint32())); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryVotesResponse { + const message = { ...baseQueryVotesResponse } as QueryVotesResponse; + message.votes = []; + if (object.votes !== undefined && object.votes !== null) { + for (const e of object.votes) { + message.votes.push(Vote.fromJSON(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryVotesResponse): unknown { + const obj: any = {}; + if (message.votes) { + obj.votes = message.votes.map((e) => (e ? Vote.toJSON(e) : undefined)); + } else { + obj.votes = []; + } + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageResponse.toJSON(message.pagination) + : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): QueryVotesResponse { + const message = { ...baseQueryVotesResponse } as QueryVotesResponse; + message.votes = []; + if (object.votes !== undefined && object.votes !== null) { + for (const e of object.votes) { + message.votes.push(Vote.fromPartial(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseQueryParamsRequest: object = { paramsType: "" }; + +export const QueryParamsRequest = { + encode( + message: QueryParamsRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.paramsType !== "") { + writer.uint32(10).string(message.paramsType); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QueryParamsRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryParamsRequest } as QueryParamsRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.paramsType = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryParamsRequest { + const message = { ...baseQueryParamsRequest } as QueryParamsRequest; + if (object.paramsType !== undefined && object.paramsType !== null) { + message.paramsType = String(object.paramsType); + } else { + message.paramsType = ""; + } + return message; + }, + + toJSON(message: QueryParamsRequest): unknown { + const obj: any = {}; + message.paramsType !== undefined && (obj.paramsType = message.paramsType); + return obj; + }, + + fromPartial(object: DeepPartial): QueryParamsRequest { + const message = { ...baseQueryParamsRequest } as QueryParamsRequest; + if (object.paramsType !== undefined && object.paramsType !== null) { + message.paramsType = object.paramsType; + } else { + message.paramsType = ""; + } + return message; + }, +}; + +const baseQueryParamsResponse: object = {}; + +export const QueryParamsResponse = { + encode( + message: QueryParamsResponse, + writer: Writer = Writer.create() + ): Writer { + if (message.votingParams !== undefined) { + VotingParams.encode( + message.votingParams, + writer.uint32(10).fork() + ).ldelim(); + } + if (message.depositParams !== undefined) { + DepositParams.encode( + message.depositParams, + writer.uint32(18).fork() + ).ldelim(); + } + if (message.tallyParams !== undefined) { + TallyParams.encode( + message.tallyParams, + writer.uint32(26).fork() + ).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QueryParamsResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryParamsResponse } as QueryParamsResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.votingParams = VotingParams.decode(reader, reader.uint32()); + break; + case 2: + message.depositParams = DepositParams.decode(reader, reader.uint32()); + break; + case 3: + message.tallyParams = TallyParams.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryParamsResponse { + const message = { ...baseQueryParamsResponse } as QueryParamsResponse; + if (object.votingParams !== undefined && object.votingParams !== null) { + message.votingParams = VotingParams.fromJSON(object.votingParams); + } else { + message.votingParams = undefined; + } + if (object.depositParams !== undefined && object.depositParams !== null) { + message.depositParams = DepositParams.fromJSON(object.depositParams); + } else { + message.depositParams = undefined; + } + if (object.tallyParams !== undefined && object.tallyParams !== null) { + message.tallyParams = TallyParams.fromJSON(object.tallyParams); + } else { + message.tallyParams = undefined; + } + return message; + }, + + toJSON(message: QueryParamsResponse): unknown { + const obj: any = {}; + message.votingParams !== undefined && + (obj.votingParams = message.votingParams + ? VotingParams.toJSON(message.votingParams) + : undefined); + message.depositParams !== undefined && + (obj.depositParams = message.depositParams + ? DepositParams.toJSON(message.depositParams) + : undefined); + message.tallyParams !== undefined && + (obj.tallyParams = message.tallyParams + ? TallyParams.toJSON(message.tallyParams) + : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): QueryParamsResponse { + const message = { ...baseQueryParamsResponse } as QueryParamsResponse; + if (object.votingParams !== undefined && object.votingParams !== null) { + message.votingParams = VotingParams.fromPartial(object.votingParams); + } else { + message.votingParams = undefined; + } + if (object.depositParams !== undefined && object.depositParams !== null) { + message.depositParams = DepositParams.fromPartial(object.depositParams); + } else { + message.depositParams = undefined; + } + if (object.tallyParams !== undefined && object.tallyParams !== null) { + message.tallyParams = TallyParams.fromPartial(object.tallyParams); + } else { + message.tallyParams = undefined; + } + return message; + }, +}; + +const baseQueryDepositRequest: object = { proposalId: 0, depositor: "" }; + +export const QueryDepositRequest = { + encode( + message: QueryDepositRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.proposalId !== 0) { + writer.uint32(8).uint64(message.proposalId); + } + if (message.depositor !== "") { + writer.uint32(18).string(message.depositor); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QueryDepositRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryDepositRequest } as QueryDepositRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.proposalId = longToNumber(reader.uint64() as Long); + break; + case 2: + message.depositor = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryDepositRequest { + const message = { ...baseQueryDepositRequest } as QueryDepositRequest; + if (object.proposalId !== undefined && object.proposalId !== null) { + message.proposalId = Number(object.proposalId); + } else { + message.proposalId = 0; + } + if (object.depositor !== undefined && object.depositor !== null) { + message.depositor = String(object.depositor); + } else { + message.depositor = ""; + } + return message; + }, + + toJSON(message: QueryDepositRequest): unknown { + const obj: any = {}; + message.proposalId !== undefined && (obj.proposalId = message.proposalId); + message.depositor !== undefined && (obj.depositor = message.depositor); + return obj; + }, + + fromPartial(object: DeepPartial): QueryDepositRequest { + const message = { ...baseQueryDepositRequest } as QueryDepositRequest; + if (object.proposalId !== undefined && object.proposalId !== null) { + message.proposalId = object.proposalId; + } else { + message.proposalId = 0; + } + if (object.depositor !== undefined && object.depositor !== null) { + message.depositor = object.depositor; + } else { + message.depositor = ""; + } + return message; + }, +}; + +const baseQueryDepositResponse: object = {}; + +export const QueryDepositResponse = { + encode( + message: QueryDepositResponse, + writer: Writer = Writer.create() + ): Writer { + if (message.deposit !== undefined) { + Deposit.encode(message.deposit, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QueryDepositResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryDepositResponse } as QueryDepositResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.deposit = Deposit.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryDepositResponse { + const message = { ...baseQueryDepositResponse } as QueryDepositResponse; + if (object.deposit !== undefined && object.deposit !== null) { + message.deposit = Deposit.fromJSON(object.deposit); + } else { + message.deposit = undefined; + } + return message; + }, + + toJSON(message: QueryDepositResponse): unknown { + const obj: any = {}; + message.deposit !== undefined && + (obj.deposit = message.deposit + ? Deposit.toJSON(message.deposit) + : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): QueryDepositResponse { + const message = { ...baseQueryDepositResponse } as QueryDepositResponse; + if (object.deposit !== undefined && object.deposit !== null) { + message.deposit = Deposit.fromPartial(object.deposit); + } else { + message.deposit = undefined; + } + return message; + }, +}; + +const baseQueryDepositsRequest: object = { proposalId: 0 }; + +export const QueryDepositsRequest = { + encode( + message: QueryDepositsRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.proposalId !== 0) { + writer.uint32(8).uint64(message.proposalId); + } + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QueryDepositsRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryDepositsRequest } as QueryDepositsRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.proposalId = longToNumber(reader.uint64() as Long); + break; + case 2: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryDepositsRequest { + const message = { ...baseQueryDepositsRequest } as QueryDepositsRequest; + if (object.proposalId !== undefined && object.proposalId !== null) { + message.proposalId = Number(object.proposalId); + } else { + message.proposalId = 0; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryDepositsRequest): unknown { + const obj: any = {}; + message.proposalId !== undefined && (obj.proposalId = message.proposalId); + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageRequest.toJSON(message.pagination) + : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): QueryDepositsRequest { + const message = { ...baseQueryDepositsRequest } as QueryDepositsRequest; + if (object.proposalId !== undefined && object.proposalId !== null) { + message.proposalId = object.proposalId; + } else { + message.proposalId = 0; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseQueryDepositsResponse: object = {}; + +export const QueryDepositsResponse = { + encode( + message: QueryDepositsResponse, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.deposits) { + Deposit.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode( + message.pagination, + writer.uint32(18).fork() + ).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QueryDepositsResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryDepositsResponse } as QueryDepositsResponse; + message.deposits = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.deposits.push(Deposit.decode(reader, reader.uint32())); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryDepositsResponse { + const message = { ...baseQueryDepositsResponse } as QueryDepositsResponse; + message.deposits = []; + if (object.deposits !== undefined && object.deposits !== null) { + for (const e of object.deposits) { + message.deposits.push(Deposit.fromJSON(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryDepositsResponse): unknown { + const obj: any = {}; + if (message.deposits) { + obj.deposits = message.deposits.map((e) => + e ? Deposit.toJSON(e) : undefined + ); + } else { + obj.deposits = []; + } + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageResponse.toJSON(message.pagination) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryDepositsResponse { + const message = { ...baseQueryDepositsResponse } as QueryDepositsResponse; + message.deposits = []; + if (object.deposits !== undefined && object.deposits !== null) { + for (const e of object.deposits) { + message.deposits.push(Deposit.fromPartial(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseQueryTallyResultRequest: object = { proposalId: 0 }; + +export const QueryTallyResultRequest = { + encode( + message: QueryTallyResultRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.proposalId !== 0) { + writer.uint32(8).uint64(message.proposalId); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QueryTallyResultRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryTallyResultRequest, + } as QueryTallyResultRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.proposalId = longToNumber(reader.uint64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryTallyResultRequest { + const message = { + ...baseQueryTallyResultRequest, + } as QueryTallyResultRequest; + if (object.proposalId !== undefined && object.proposalId !== null) { + message.proposalId = Number(object.proposalId); + } else { + message.proposalId = 0; + } + return message; + }, + + toJSON(message: QueryTallyResultRequest): unknown { + const obj: any = {}; + message.proposalId !== undefined && (obj.proposalId = message.proposalId); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryTallyResultRequest { + const message = { + ...baseQueryTallyResultRequest, + } as QueryTallyResultRequest; + if (object.proposalId !== undefined && object.proposalId !== null) { + message.proposalId = object.proposalId; + } else { + message.proposalId = 0; + } + return message; + }, +}; + +const baseQueryTallyResultResponse: object = {}; + +export const QueryTallyResultResponse = { + encode( + message: QueryTallyResultResponse, + writer: Writer = Writer.create() + ): Writer { + if (message.tally !== undefined) { + TallyResult.encode(message.tally, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryTallyResultResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryTallyResultResponse, + } as QueryTallyResultResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.tally = TallyResult.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryTallyResultResponse { + const message = { + ...baseQueryTallyResultResponse, + } as QueryTallyResultResponse; + if (object.tally !== undefined && object.tally !== null) { + message.tally = TallyResult.fromJSON(object.tally); + } else { + message.tally = undefined; + } + return message; + }, + + toJSON(message: QueryTallyResultResponse): unknown { + const obj: any = {}; + message.tally !== undefined && + (obj.tally = message.tally + ? TallyResult.toJSON(message.tally) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryTallyResultResponse { + const message = { + ...baseQueryTallyResultResponse, + } as QueryTallyResultResponse; + if (object.tally !== undefined && object.tally !== null) { + message.tally = TallyResult.fromPartial(object.tally); + } else { + message.tally = undefined; + } + return message; + }, +}; + +/** Query defines the gRPC querier service for gov module */ +export interface Query { + /** Proposal queries proposal details based on ProposalID. */ + Proposal(request: QueryProposalRequest): Promise; + /** Proposals queries all proposals based on given status. */ + Proposals(request: QueryProposalsRequest): Promise; + /** Vote queries voted information based on proposalID, voterAddr. */ + Vote(request: QueryVoteRequest): Promise; + /** Votes queries votes of a given proposal. */ + Votes(request: QueryVotesRequest): Promise; + /** Params queries all parameters of the gov module. */ + Params(request: QueryParamsRequest): Promise; + /** Deposit queries single deposit information based proposalID, depositAddr. */ + Deposit(request: QueryDepositRequest): Promise; + /** Deposits queries all deposits of a single proposal. */ + Deposits(request: QueryDepositsRequest): Promise; + /** TallyResult queries the tally of a proposal vote. */ + TallyResult( + request: QueryTallyResultRequest + ): Promise; +} + +export class QueryClientImpl implements Query { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + } + Proposal(request: QueryProposalRequest): Promise { + const data = QueryProposalRequest.encode(request).finish(); + const promise = this.rpc.request( + "cosmos.gov.v1beta1.Query", + "Proposal", + data + ); + return promise.then((data) => + QueryProposalResponse.decode(new Reader(data)) + ); + } + + Proposals(request: QueryProposalsRequest): Promise { + const data = QueryProposalsRequest.encode(request).finish(); + const promise = this.rpc.request( + "cosmos.gov.v1beta1.Query", + "Proposals", + data + ); + return promise.then((data) => + QueryProposalsResponse.decode(new Reader(data)) + ); + } + + Vote(request: QueryVoteRequest): Promise { + const data = QueryVoteRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.gov.v1beta1.Query", "Vote", data); + return promise.then((data) => QueryVoteResponse.decode(new Reader(data))); + } + + Votes(request: QueryVotesRequest): Promise { + const data = QueryVotesRequest.encode(request).finish(); + const promise = this.rpc.request("cosmos.gov.v1beta1.Query", "Votes", data); + return promise.then((data) => QueryVotesResponse.decode(new Reader(data))); + } + + Params(request: QueryParamsRequest): Promise { + const data = QueryParamsRequest.encode(request).finish(); + const promise = this.rpc.request( + "cosmos.gov.v1beta1.Query", + "Params", + data + ); + return promise.then((data) => QueryParamsResponse.decode(new Reader(data))); + } + + Deposit(request: QueryDepositRequest): Promise { + const data = QueryDepositRequest.encode(request).finish(); + const promise = this.rpc.request( + "cosmos.gov.v1beta1.Query", + "Deposit", + data + ); + return promise.then((data) => + QueryDepositResponse.decode(new Reader(data)) + ); + } + + Deposits(request: QueryDepositsRequest): Promise { + const data = QueryDepositsRequest.encode(request).finish(); + const promise = this.rpc.request( + "cosmos.gov.v1beta1.Query", + "Deposits", + data + ); + return promise.then((data) => + QueryDepositsResponse.decode(new Reader(data)) + ); + } + + TallyResult( + request: QueryTallyResultRequest + ): Promise { + const data = QueryTallyResultRequest.encode(request).finish(); + const promise = this.rpc.request( + "cosmos.gov.v1beta1.Query", + "TallyResult", + data + ); + return promise.then((data) => + QueryTallyResultResponse.decode(new Reader(data)) + ); + } +} + +interface Rpc { + request( + service: string, + method: string, + data: Uint8Array + ): Promise; +} + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/cosmos.gov.v1beta1/types/cosmos/gov/v1beta1/tx.ts b/ts-client/cosmos.gov.v1beta1/types/cosmos/gov/v1beta1/tx.ts new file mode 100644 index 00000000..eda5d8f9 --- /dev/null +++ b/ts-client/cosmos.gov.v1beta1/types/cosmos/gov/v1beta1/tx.ts @@ -0,0 +1,745 @@ +/* eslint-disable */ +import { + VoteOption, + WeightedVoteOption, + voteOptionFromJSON, + voteOptionToJSON, +} from "../../../cosmos/gov/v1beta1/gov"; +import { Reader, util, configure, Writer } from "protobufjs/minimal"; +import * as Long from "long"; +import { Any } from "../../../google/protobuf/any"; +import { Coin } from "../../../cosmos/base/v1beta1/coin"; + +export const protobufPackage = "cosmos.gov.v1beta1"; + +/** + * MsgSubmitProposal defines an sdk.Msg type that supports submitting arbitrary + * proposal Content. + */ +export interface MsgSubmitProposal { + content: Any | undefined; + initialDeposit: Coin[]; + proposer: string; +} + +/** MsgSubmitProposalResponse defines the Msg/SubmitProposal response type. */ +export interface MsgSubmitProposalResponse { + proposalId: number; +} + +/** MsgVote defines a message to cast a vote. */ +export interface MsgVote { + proposalId: number; + voter: string; + option: VoteOption; +} + +/** MsgVoteResponse defines the Msg/Vote response type. */ +export interface MsgVoteResponse {} + +/** + * MsgVoteWeighted defines a message to cast a vote. + * + * Since: cosmos-sdk 0.43 + */ +export interface MsgVoteWeighted { + proposalId: number; + voter: string; + options: WeightedVoteOption[]; +} + +/** + * MsgVoteWeightedResponse defines the Msg/VoteWeighted response type. + * + * Since: cosmos-sdk 0.43 + */ +export interface MsgVoteWeightedResponse {} + +/** MsgDeposit defines a message to submit a deposit to an existing proposal. */ +export interface MsgDeposit { + proposalId: number; + depositor: string; + amount: Coin[]; +} + +/** MsgDepositResponse defines the Msg/Deposit response type. */ +export interface MsgDepositResponse {} + +const baseMsgSubmitProposal: object = { proposer: "" }; + +export const MsgSubmitProposal = { + encode(message: MsgSubmitProposal, writer: Writer = Writer.create()): Writer { + if (message.content !== undefined) { + Any.encode(message.content, writer.uint32(10).fork()).ldelim(); + } + for (const v of message.initialDeposit) { + Coin.encode(v!, writer.uint32(18).fork()).ldelim(); + } + if (message.proposer !== "") { + writer.uint32(26).string(message.proposer); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MsgSubmitProposal { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgSubmitProposal } as MsgSubmitProposal; + message.initialDeposit = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.content = Any.decode(reader, reader.uint32()); + break; + case 2: + message.initialDeposit.push(Coin.decode(reader, reader.uint32())); + break; + case 3: + message.proposer = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgSubmitProposal { + const message = { ...baseMsgSubmitProposal } as MsgSubmitProposal; + message.initialDeposit = []; + if (object.content !== undefined && object.content !== null) { + message.content = Any.fromJSON(object.content); + } else { + message.content = undefined; + } + if (object.initialDeposit !== undefined && object.initialDeposit !== null) { + for (const e of object.initialDeposit) { + message.initialDeposit.push(Coin.fromJSON(e)); + } + } + if (object.proposer !== undefined && object.proposer !== null) { + message.proposer = String(object.proposer); + } else { + message.proposer = ""; + } + return message; + }, + + toJSON(message: MsgSubmitProposal): unknown { + const obj: any = {}; + message.content !== undefined && + (obj.content = message.content ? Any.toJSON(message.content) : undefined); + if (message.initialDeposit) { + obj.initialDeposit = message.initialDeposit.map((e) => + e ? Coin.toJSON(e) : undefined + ); + } else { + obj.initialDeposit = []; + } + message.proposer !== undefined && (obj.proposer = message.proposer); + return obj; + }, + + fromPartial(object: DeepPartial): MsgSubmitProposal { + const message = { ...baseMsgSubmitProposal } as MsgSubmitProposal; + message.initialDeposit = []; + if (object.content !== undefined && object.content !== null) { + message.content = Any.fromPartial(object.content); + } else { + message.content = undefined; + } + if (object.initialDeposit !== undefined && object.initialDeposit !== null) { + for (const e of object.initialDeposit) { + message.initialDeposit.push(Coin.fromPartial(e)); + } + } + if (object.proposer !== undefined && object.proposer !== null) { + message.proposer = object.proposer; + } else { + message.proposer = ""; + } + return message; + }, +}; + +const baseMsgSubmitProposalResponse: object = { proposalId: 0 }; + +export const MsgSubmitProposalResponse = { + encode( + message: MsgSubmitProposalResponse, + writer: Writer = Writer.create() + ): Writer { + if (message.proposalId !== 0) { + writer.uint32(8).uint64(message.proposalId); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): MsgSubmitProposalResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseMsgSubmitProposalResponse, + } as MsgSubmitProposalResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.proposalId = longToNumber(reader.uint64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgSubmitProposalResponse { + const message = { + ...baseMsgSubmitProposalResponse, + } as MsgSubmitProposalResponse; + if (object.proposalId !== undefined && object.proposalId !== null) { + message.proposalId = Number(object.proposalId); + } else { + message.proposalId = 0; + } + return message; + }, + + toJSON(message: MsgSubmitProposalResponse): unknown { + const obj: any = {}; + message.proposalId !== undefined && (obj.proposalId = message.proposalId); + return obj; + }, + + fromPartial( + object: DeepPartial + ): MsgSubmitProposalResponse { + const message = { + ...baseMsgSubmitProposalResponse, + } as MsgSubmitProposalResponse; + if (object.proposalId !== undefined && object.proposalId !== null) { + message.proposalId = object.proposalId; + } else { + message.proposalId = 0; + } + return message; + }, +}; + +const baseMsgVote: object = { proposalId: 0, voter: "", option: 0 }; + +export const MsgVote = { + encode(message: MsgVote, writer: Writer = Writer.create()): Writer { + if (message.proposalId !== 0) { + writer.uint32(8).uint64(message.proposalId); + } + if (message.voter !== "") { + writer.uint32(18).string(message.voter); + } + if (message.option !== 0) { + writer.uint32(24).int32(message.option); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MsgVote { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgVote } as MsgVote; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.proposalId = longToNumber(reader.uint64() as Long); + break; + case 2: + message.voter = reader.string(); + break; + case 3: + message.option = reader.int32() as any; + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgVote { + const message = { ...baseMsgVote } as MsgVote; + if (object.proposalId !== undefined && object.proposalId !== null) { + message.proposalId = Number(object.proposalId); + } else { + message.proposalId = 0; + } + if (object.voter !== undefined && object.voter !== null) { + message.voter = String(object.voter); + } else { + message.voter = ""; + } + if (object.option !== undefined && object.option !== null) { + message.option = voteOptionFromJSON(object.option); + } else { + message.option = 0; + } + return message; + }, + + toJSON(message: MsgVote): unknown { + const obj: any = {}; + message.proposalId !== undefined && (obj.proposalId = message.proposalId); + message.voter !== undefined && (obj.voter = message.voter); + message.option !== undefined && + (obj.option = voteOptionToJSON(message.option)); + return obj; + }, + + fromPartial(object: DeepPartial): MsgVote { + const message = { ...baseMsgVote } as MsgVote; + if (object.proposalId !== undefined && object.proposalId !== null) { + message.proposalId = object.proposalId; + } else { + message.proposalId = 0; + } + if (object.voter !== undefined && object.voter !== null) { + message.voter = object.voter; + } else { + message.voter = ""; + } + if (object.option !== undefined && object.option !== null) { + message.option = object.option; + } else { + message.option = 0; + } + return message; + }, +}; + +const baseMsgVoteResponse: object = {}; + +export const MsgVoteResponse = { + encode(_: MsgVoteResponse, writer: Writer = Writer.create()): Writer { + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MsgVoteResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgVoteResponse } as MsgVoteResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): MsgVoteResponse { + const message = { ...baseMsgVoteResponse } as MsgVoteResponse; + return message; + }, + + toJSON(_: MsgVoteResponse): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial(_: DeepPartial): MsgVoteResponse { + const message = { ...baseMsgVoteResponse } as MsgVoteResponse; + return message; + }, +}; + +const baseMsgVoteWeighted: object = { proposalId: 0, voter: "" }; + +export const MsgVoteWeighted = { + encode(message: MsgVoteWeighted, writer: Writer = Writer.create()): Writer { + if (message.proposalId !== 0) { + writer.uint32(8).uint64(message.proposalId); + } + if (message.voter !== "") { + writer.uint32(18).string(message.voter); + } + for (const v of message.options) { + WeightedVoteOption.encode(v!, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MsgVoteWeighted { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgVoteWeighted } as MsgVoteWeighted; + message.options = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.proposalId = longToNumber(reader.uint64() as Long); + break; + case 2: + message.voter = reader.string(); + break; + case 3: + message.options.push( + WeightedVoteOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgVoteWeighted { + const message = { ...baseMsgVoteWeighted } as MsgVoteWeighted; + message.options = []; + if (object.proposalId !== undefined && object.proposalId !== null) { + message.proposalId = Number(object.proposalId); + } else { + message.proposalId = 0; + } + if (object.voter !== undefined && object.voter !== null) { + message.voter = String(object.voter); + } else { + message.voter = ""; + } + if (object.options !== undefined && object.options !== null) { + for (const e of object.options) { + message.options.push(WeightedVoteOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: MsgVoteWeighted): unknown { + const obj: any = {}; + message.proposalId !== undefined && (obj.proposalId = message.proposalId); + message.voter !== undefined && (obj.voter = message.voter); + if (message.options) { + obj.options = message.options.map((e) => + e ? WeightedVoteOption.toJSON(e) : undefined + ); + } else { + obj.options = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): MsgVoteWeighted { + const message = { ...baseMsgVoteWeighted } as MsgVoteWeighted; + message.options = []; + if (object.proposalId !== undefined && object.proposalId !== null) { + message.proposalId = object.proposalId; + } else { + message.proposalId = 0; + } + if (object.voter !== undefined && object.voter !== null) { + message.voter = object.voter; + } else { + message.voter = ""; + } + if (object.options !== undefined && object.options !== null) { + for (const e of object.options) { + message.options.push(WeightedVoteOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseMsgVoteWeightedResponse: object = {}; + +export const MsgVoteWeightedResponse = { + encode(_: MsgVoteWeightedResponse, writer: Writer = Writer.create()): Writer { + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MsgVoteWeightedResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseMsgVoteWeightedResponse, + } as MsgVoteWeightedResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): MsgVoteWeightedResponse { + const message = { + ...baseMsgVoteWeightedResponse, + } as MsgVoteWeightedResponse; + return message; + }, + + toJSON(_: MsgVoteWeightedResponse): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial( + _: DeepPartial + ): MsgVoteWeightedResponse { + const message = { + ...baseMsgVoteWeightedResponse, + } as MsgVoteWeightedResponse; + return message; + }, +}; + +const baseMsgDeposit: object = { proposalId: 0, depositor: "" }; + +export const MsgDeposit = { + encode(message: MsgDeposit, writer: Writer = Writer.create()): Writer { + if (message.proposalId !== 0) { + writer.uint32(8).uint64(message.proposalId); + } + if (message.depositor !== "") { + writer.uint32(18).string(message.depositor); + } + for (const v of message.amount) { + Coin.encode(v!, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MsgDeposit { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgDeposit } as MsgDeposit; + message.amount = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.proposalId = longToNumber(reader.uint64() as Long); + break; + case 2: + message.depositor = reader.string(); + break; + case 3: + message.amount.push(Coin.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgDeposit { + const message = { ...baseMsgDeposit } as MsgDeposit; + message.amount = []; + if (object.proposalId !== undefined && object.proposalId !== null) { + message.proposalId = Number(object.proposalId); + } else { + message.proposalId = 0; + } + if (object.depositor !== undefined && object.depositor !== null) { + message.depositor = String(object.depositor); + } else { + message.depositor = ""; + } + if (object.amount !== undefined && object.amount !== null) { + for (const e of object.amount) { + message.amount.push(Coin.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: MsgDeposit): unknown { + const obj: any = {}; + message.proposalId !== undefined && (obj.proposalId = message.proposalId); + message.depositor !== undefined && (obj.depositor = message.depositor); + if (message.amount) { + obj.amount = message.amount.map((e) => (e ? Coin.toJSON(e) : undefined)); + } else { + obj.amount = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): MsgDeposit { + const message = { ...baseMsgDeposit } as MsgDeposit; + message.amount = []; + if (object.proposalId !== undefined && object.proposalId !== null) { + message.proposalId = object.proposalId; + } else { + message.proposalId = 0; + } + if (object.depositor !== undefined && object.depositor !== null) { + message.depositor = object.depositor; + } else { + message.depositor = ""; + } + if (object.amount !== undefined && object.amount !== null) { + for (const e of object.amount) { + message.amount.push(Coin.fromPartial(e)); + } + } + return message; + }, +}; + +const baseMsgDepositResponse: object = {}; + +export const MsgDepositResponse = { + encode(_: MsgDepositResponse, writer: Writer = Writer.create()): Writer { + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MsgDepositResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgDepositResponse } as MsgDepositResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): MsgDepositResponse { + const message = { ...baseMsgDepositResponse } as MsgDepositResponse; + return message; + }, + + toJSON(_: MsgDepositResponse): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial(_: DeepPartial): MsgDepositResponse { + const message = { ...baseMsgDepositResponse } as MsgDepositResponse; + return message; + }, +}; + +/** Msg defines the bank Msg service. */ +export interface Msg { + /** SubmitProposal defines a method to create new proposal given a content. */ + SubmitProposal( + request: MsgSubmitProposal + ): Promise; + /** Vote defines a method to add a vote on a specific proposal. */ + Vote(request: MsgVote): Promise; + /** + * VoteWeighted defines a method to add a weighted vote on a specific proposal. + * + * Since: cosmos-sdk 0.43 + */ + VoteWeighted(request: MsgVoteWeighted): Promise; + /** Deposit defines a method to add deposit on a specific proposal. */ + Deposit(request: MsgDeposit): Promise; +} + +export class MsgClientImpl implements Msg { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + } + SubmitProposal( + request: MsgSubmitProposal + ): Promise { + const data = MsgSubmitProposal.encode(request).finish(); + const promise = this.rpc.request( + "cosmos.gov.v1beta1.Msg", + "SubmitProposal", + data + ); + return promise.then((data) => + MsgSubmitProposalResponse.decode(new Reader(data)) + ); + } + + Vote(request: MsgVote): Promise { + const data = MsgVote.encode(request).finish(); + const promise = this.rpc.request("cosmos.gov.v1beta1.Msg", "Vote", data); + return promise.then((data) => MsgVoteResponse.decode(new Reader(data))); + } + + VoteWeighted(request: MsgVoteWeighted): Promise { + const data = MsgVoteWeighted.encode(request).finish(); + const promise = this.rpc.request( + "cosmos.gov.v1beta1.Msg", + "VoteWeighted", + data + ); + return promise.then((data) => + MsgVoteWeightedResponse.decode(new Reader(data)) + ); + } + + Deposit(request: MsgDeposit): Promise { + const data = MsgDeposit.encode(request).finish(); + const promise = this.rpc.request("cosmos.gov.v1beta1.Msg", "Deposit", data); + return promise.then((data) => MsgDepositResponse.decode(new Reader(data))); + } +} + +interface Rpc { + request( + service: string, + method: string, + data: Uint8Array + ): Promise; +} + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/cosmos.gov.v1beta1/types/cosmos_proto/cosmos.ts b/ts-client/cosmos.gov.v1beta1/types/cosmos_proto/cosmos.ts new file mode 100644 index 00000000..9ec67a12 --- /dev/null +++ b/ts-client/cosmos.gov.v1beta1/types/cosmos_proto/cosmos.ts @@ -0,0 +1,2 @@ +/* eslint-disable */ +export const protobufPackage = "cosmos_proto"; diff --git a/ts-client/cosmos.gov.v1beta1/types/gogoproto/gogo.ts b/ts-client/cosmos.gov.v1beta1/types/gogoproto/gogo.ts new file mode 100644 index 00000000..3f41a047 --- /dev/null +++ b/ts-client/cosmos.gov.v1beta1/types/gogoproto/gogo.ts @@ -0,0 +1,2 @@ +/* eslint-disable */ +export const protobufPackage = "gogoproto"; diff --git a/ts-client/cosmos.gov.v1beta1/types/google/api/annotations.ts b/ts-client/cosmos.gov.v1beta1/types/google/api/annotations.ts new file mode 100644 index 00000000..aace4787 --- /dev/null +++ b/ts-client/cosmos.gov.v1beta1/types/google/api/annotations.ts @@ -0,0 +1,2 @@ +/* eslint-disable */ +export const protobufPackage = "google.api"; diff --git a/ts-client/cosmos.gov.v1beta1/types/google/api/http.ts b/ts-client/cosmos.gov.v1beta1/types/google/api/http.ts new file mode 100644 index 00000000..ddc00f8b --- /dev/null +++ b/ts-client/cosmos.gov.v1beta1/types/google/api/http.ts @@ -0,0 +1,705 @@ +/* eslint-disable */ +import { Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "google.api"; + +/** + * Defines the HTTP configuration for an API service. It contains a list of + * [HttpRule][google.api.HttpRule], each specifying the mapping of an RPC method + * to one or more HTTP REST API methods. + */ +export interface Http { + /** + * A list of HTTP configuration rules that apply to individual API methods. + * + * **NOTE:** All service configuration rules follow "last one wins" order. + */ + rules: HttpRule[]; + /** + * When set to true, URL path parmeters will be fully URI-decoded except in + * cases of single segment matches in reserved expansion, where "%2F" will be + * left encoded. + * + * The default behavior is to not decode RFC 6570 reserved characters in multi + * segment matches. + */ + fullyDecodeReservedExpansion: boolean; +} + +/** + * `HttpRule` defines the mapping of an RPC method to one or more HTTP + * REST API methods. The mapping specifies how different portions of the RPC + * request message are mapped to URL path, URL query parameters, and + * HTTP request body. The mapping is typically specified as an + * `google.api.http` annotation on the RPC method, + * see "google/api/annotations.proto" for details. + * + * The mapping consists of a field specifying the path template and + * method kind. The path template can refer to fields in the request + * message, as in the example below which describes a REST GET + * operation on a resource collection of messages: + * + * + * service Messaging { + * rpc GetMessage(GetMessageRequest) returns (Message) { + * option (google.api.http).get = "/v1/messages/{message_id}/{sub.subfield}"; + * } + * } + * message GetMessageRequest { + * message SubMessage { + * string subfield = 1; + * } + * string message_id = 1; // mapped to the URL + * SubMessage sub = 2; // `sub.subfield` is url-mapped + * } + * message Message { + * string text = 1; // content of the resource + * } + * + * The same http annotation can alternatively be expressed inside the + * `GRPC API Configuration` YAML file. + * + * http: + * rules: + * - selector: .Messaging.GetMessage + * get: /v1/messages/{message_id}/{sub.subfield} + * + * This definition enables an automatic, bidrectional mapping of HTTP + * JSON to RPC. Example: + * + * HTTP | RPC + * -----|----- + * `GET /v1/messages/123456/foo` | `GetMessage(message_id: "123456" sub: SubMessage(subfield: "foo"))` + * + * In general, not only fields but also field paths can be referenced + * from a path pattern. Fields mapped to the path pattern cannot be + * repeated and must have a primitive (non-message) type. + * + * Any fields in the request message which are not bound by the path + * pattern automatically become (optional) HTTP query + * parameters. Assume the following definition of the request message: + * + * + * service Messaging { + * rpc GetMessage(GetMessageRequest) returns (Message) { + * option (google.api.http).get = "/v1/messages/{message_id}"; + * } + * } + * message GetMessageRequest { + * message SubMessage { + * string subfield = 1; + * } + * string message_id = 1; // mapped to the URL + * int64 revision = 2; // becomes a parameter + * SubMessage sub = 3; // `sub.subfield` becomes a parameter + * } + * + * + * This enables a HTTP JSON to RPC mapping as below: + * + * HTTP | RPC + * -----|----- + * `GET /v1/messages/123456?revision=2&sub.subfield=foo` | `GetMessage(message_id: "123456" revision: 2 sub: SubMessage(subfield: "foo"))` + * + * Note that fields which are mapped to HTTP parameters must have a + * primitive type or a repeated primitive type. Message types are not + * allowed. In the case of a repeated type, the parameter can be + * repeated in the URL, as in `...?param=A¶m=B`. + * + * For HTTP method kinds which allow a request body, the `body` field + * specifies the mapping. Consider a REST update method on the + * message resource collection: + * + * + * service Messaging { + * rpc UpdateMessage(UpdateMessageRequest) returns (Message) { + * option (google.api.http) = { + * put: "/v1/messages/{message_id}" + * body: "message" + * }; + * } + * } + * message UpdateMessageRequest { + * string message_id = 1; // mapped to the URL + * Message message = 2; // mapped to the body + * } + * + * + * The following HTTP JSON to RPC mapping is enabled, where the + * representation of the JSON in the request body is determined by + * protos JSON encoding: + * + * HTTP | RPC + * -----|----- + * `PUT /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: "123456" message { text: "Hi!" })` + * + * The special name `*` can be used in the body mapping to define that + * every field not bound by the path template should be mapped to the + * request body. This enables the following alternative definition of + * the update method: + * + * service Messaging { + * rpc UpdateMessage(Message) returns (Message) { + * option (google.api.http) = { + * put: "/v1/messages/{message_id}" + * body: "*" + * }; + * } + * } + * message Message { + * string message_id = 1; + * string text = 2; + * } + * + * + * The following HTTP JSON to RPC mapping is enabled: + * + * HTTP | RPC + * -----|----- + * `PUT /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: "123456" text: "Hi!")` + * + * Note that when using `*` in the body mapping, it is not possible to + * have HTTP parameters, as all fields not bound by the path end in + * the body. This makes this option more rarely used in practice of + * defining REST APIs. The common usage of `*` is in custom methods + * which don't use the URL at all for transferring data. + * + * It is possible to define multiple HTTP methods for one RPC by using + * the `additional_bindings` option. Example: + * + * service Messaging { + * rpc GetMessage(GetMessageRequest) returns (Message) { + * option (google.api.http) = { + * get: "/v1/messages/{message_id}" + * additional_bindings { + * get: "/v1/users/{user_id}/messages/{message_id}" + * } + * }; + * } + * } + * message GetMessageRequest { + * string message_id = 1; + * string user_id = 2; + * } + * + * + * This enables the following two alternative HTTP JSON to RPC + * mappings: + * + * HTTP | RPC + * -----|----- + * `GET /v1/messages/123456` | `GetMessage(message_id: "123456")` + * `GET /v1/users/me/messages/123456` | `GetMessage(user_id: "me" message_id: "123456")` + * + * # Rules for HTTP mapping + * + * The rules for mapping HTTP path, query parameters, and body fields + * to the request message are as follows: + * + * 1. The `body` field specifies either `*` or a field path, or is + * omitted. If omitted, it indicates there is no HTTP request body. + * 2. Leaf fields (recursive expansion of nested messages in the + * request) can be classified into three types: + * (a) Matched in the URL template. + * (b) Covered by body (if body is `*`, everything except (a) fields; + * else everything under the body field) + * (c) All other fields. + * 3. URL query parameters found in the HTTP request are mapped to (c) fields. + * 4. Any body sent with an HTTP request can contain only (b) fields. + * + * The syntax of the path template is as follows: + * + * Template = "/" Segments [ Verb ] ; + * Segments = Segment { "/" Segment } ; + * Segment = "*" | "**" | LITERAL | Variable ; + * Variable = "{" FieldPath [ "=" Segments ] "}" ; + * FieldPath = IDENT { "." IDENT } ; + * Verb = ":" LITERAL ; + * + * The syntax `*` matches a single path segment. The syntax `**` matches zero + * or more path segments, which must be the last part of the path except the + * `Verb`. The syntax `LITERAL` matches literal text in the path. + * + * The syntax `Variable` matches part of the URL path as specified by its + * template. A variable template must not contain other variables. If a variable + * matches a single path segment, its template may be omitted, e.g. `{var}` + * is equivalent to `{var=*}`. + * + * If a variable contains exactly one path segment, such as `"{var}"` or + * `"{var=*}"`, when such a variable is expanded into a URL path, all characters + * except `[-_.~0-9a-zA-Z]` are percent-encoded. Such variables show up in the + * Discovery Document as `{var}`. + * + * If a variable contains one or more path segments, such as `"{var=foo/*}"` + * or `"{var=**}"`, when such a variable is expanded into a URL path, all + * characters except `[-_.~/0-9a-zA-Z]` are percent-encoded. Such variables + * show up in the Discovery Document as `{+var}`. + * + * NOTE: While the single segment variable matches the semantics of + * [RFC 6570](https://tools.ietf.org/html/rfc6570) Section 3.2.2 + * Simple String Expansion, the multi segment variable **does not** match + * RFC 6570 Reserved Expansion. The reason is that the Reserved Expansion + * does not expand special characters like `?` and `#`, which would lead + * to invalid URLs. + * + * NOTE: the field paths in variables and in the `body` must not refer to + * repeated fields or map fields. + */ +export interface HttpRule { + /** + * Selects methods to which this rule applies. + * + * Refer to [selector][google.api.DocumentationRule.selector] for syntax details. + */ + selector: string; + /** Used for listing and getting information about resources. */ + get: string | undefined; + /** Used for updating a resource. */ + put: string | undefined; + /** Used for creating a resource. */ + post: string | undefined; + /** Used for deleting a resource. */ + delete: string | undefined; + /** Used for updating a resource. */ + patch: string | undefined; + /** + * The custom pattern is used for specifying an HTTP method that is not + * included in the `pattern` field, such as HEAD, or "*" to leave the + * HTTP method unspecified for this rule. The wild-card rule is useful + * for services that provide content to Web (HTML) clients. + */ + custom: CustomHttpPattern | undefined; + /** + * The name of the request field whose value is mapped to the HTTP body, or + * `*` for mapping all fields not captured by the path pattern to the HTTP + * body. NOTE: the referred field must not be a repeated field and must be + * present at the top-level of request message type. + */ + body: string; + /** + * Optional. The name of the response field whose value is mapped to the HTTP + * body of response. Other response fields are ignored. When + * not set, the response message will be used as HTTP body of response. + */ + responseBody: string; + /** + * Additional HTTP bindings for the selector. Nested bindings must + * not contain an `additional_bindings` field themselves (that is, + * the nesting may only be one level deep). + */ + additionalBindings: HttpRule[]; +} + +/** A custom pattern is used for defining custom HTTP verb. */ +export interface CustomHttpPattern { + /** The name of this custom HTTP verb. */ + kind: string; + /** The path matched by this custom verb. */ + path: string; +} + +const baseHttp: object = { fullyDecodeReservedExpansion: false }; + +export const Http = { + encode(message: Http, writer: Writer = Writer.create()): Writer { + for (const v of message.rules) { + HttpRule.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.fullyDecodeReservedExpansion === true) { + writer.uint32(16).bool(message.fullyDecodeReservedExpansion); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Http { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseHttp } as Http; + message.rules = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.rules.push(HttpRule.decode(reader, reader.uint32())); + break; + case 2: + message.fullyDecodeReservedExpansion = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Http { + const message = { ...baseHttp } as Http; + message.rules = []; + if (object.rules !== undefined && object.rules !== null) { + for (const e of object.rules) { + message.rules.push(HttpRule.fromJSON(e)); + } + } + if ( + object.fullyDecodeReservedExpansion !== undefined && + object.fullyDecodeReservedExpansion !== null + ) { + message.fullyDecodeReservedExpansion = Boolean( + object.fullyDecodeReservedExpansion + ); + } else { + message.fullyDecodeReservedExpansion = false; + } + return message; + }, + + toJSON(message: Http): unknown { + const obj: any = {}; + if (message.rules) { + obj.rules = message.rules.map((e) => + e ? HttpRule.toJSON(e) : undefined + ); + } else { + obj.rules = []; + } + message.fullyDecodeReservedExpansion !== undefined && + (obj.fullyDecodeReservedExpansion = message.fullyDecodeReservedExpansion); + return obj; + }, + + fromPartial(object: DeepPartial): Http { + const message = { ...baseHttp } as Http; + message.rules = []; + if (object.rules !== undefined && object.rules !== null) { + for (const e of object.rules) { + message.rules.push(HttpRule.fromPartial(e)); + } + } + if ( + object.fullyDecodeReservedExpansion !== undefined && + object.fullyDecodeReservedExpansion !== null + ) { + message.fullyDecodeReservedExpansion = + object.fullyDecodeReservedExpansion; + } else { + message.fullyDecodeReservedExpansion = false; + } + return message; + }, +}; + +const baseHttpRule: object = { selector: "", body: "", responseBody: "" }; + +export const HttpRule = { + encode(message: HttpRule, writer: Writer = Writer.create()): Writer { + if (message.selector !== "") { + writer.uint32(10).string(message.selector); + } + if (message.get !== undefined) { + writer.uint32(18).string(message.get); + } + if (message.put !== undefined) { + writer.uint32(26).string(message.put); + } + if (message.post !== undefined) { + writer.uint32(34).string(message.post); + } + if (message.delete !== undefined) { + writer.uint32(42).string(message.delete); + } + if (message.patch !== undefined) { + writer.uint32(50).string(message.patch); + } + if (message.custom !== undefined) { + CustomHttpPattern.encode( + message.custom, + writer.uint32(66).fork() + ).ldelim(); + } + if (message.body !== "") { + writer.uint32(58).string(message.body); + } + if (message.responseBody !== "") { + writer.uint32(98).string(message.responseBody); + } + for (const v of message.additionalBindings) { + HttpRule.encode(v!, writer.uint32(90).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): HttpRule { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseHttpRule } as HttpRule; + message.additionalBindings = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.selector = reader.string(); + break; + case 2: + message.get = reader.string(); + break; + case 3: + message.put = reader.string(); + break; + case 4: + message.post = reader.string(); + break; + case 5: + message.delete = reader.string(); + break; + case 6: + message.patch = reader.string(); + break; + case 8: + message.custom = CustomHttpPattern.decode(reader, reader.uint32()); + break; + case 7: + message.body = reader.string(); + break; + case 12: + message.responseBody = reader.string(); + break; + case 11: + message.additionalBindings.push( + HttpRule.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): HttpRule { + const message = { ...baseHttpRule } as HttpRule; + message.additionalBindings = []; + if (object.selector !== undefined && object.selector !== null) { + message.selector = String(object.selector); + } else { + message.selector = ""; + } + if (object.get !== undefined && object.get !== null) { + message.get = String(object.get); + } else { + message.get = undefined; + } + if (object.put !== undefined && object.put !== null) { + message.put = String(object.put); + } else { + message.put = undefined; + } + if (object.post !== undefined && object.post !== null) { + message.post = String(object.post); + } else { + message.post = undefined; + } + if (object.delete !== undefined && object.delete !== null) { + message.delete = String(object.delete); + } else { + message.delete = undefined; + } + if (object.patch !== undefined && object.patch !== null) { + message.patch = String(object.patch); + } else { + message.patch = undefined; + } + if (object.custom !== undefined && object.custom !== null) { + message.custom = CustomHttpPattern.fromJSON(object.custom); + } else { + message.custom = undefined; + } + if (object.body !== undefined && object.body !== null) { + message.body = String(object.body); + } else { + message.body = ""; + } + if (object.responseBody !== undefined && object.responseBody !== null) { + message.responseBody = String(object.responseBody); + } else { + message.responseBody = ""; + } + if ( + object.additionalBindings !== undefined && + object.additionalBindings !== null + ) { + for (const e of object.additionalBindings) { + message.additionalBindings.push(HttpRule.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: HttpRule): unknown { + const obj: any = {}; + message.selector !== undefined && (obj.selector = message.selector); + message.get !== undefined && (obj.get = message.get); + message.put !== undefined && (obj.put = message.put); + message.post !== undefined && (obj.post = message.post); + message.delete !== undefined && (obj.delete = message.delete); + message.patch !== undefined && (obj.patch = message.patch); + message.custom !== undefined && + (obj.custom = message.custom + ? CustomHttpPattern.toJSON(message.custom) + : undefined); + message.body !== undefined && (obj.body = message.body); + message.responseBody !== undefined && + (obj.responseBody = message.responseBody); + if (message.additionalBindings) { + obj.additionalBindings = message.additionalBindings.map((e) => + e ? HttpRule.toJSON(e) : undefined + ); + } else { + obj.additionalBindings = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): HttpRule { + const message = { ...baseHttpRule } as HttpRule; + message.additionalBindings = []; + if (object.selector !== undefined && object.selector !== null) { + message.selector = object.selector; + } else { + message.selector = ""; + } + if (object.get !== undefined && object.get !== null) { + message.get = object.get; + } else { + message.get = undefined; + } + if (object.put !== undefined && object.put !== null) { + message.put = object.put; + } else { + message.put = undefined; + } + if (object.post !== undefined && object.post !== null) { + message.post = object.post; + } else { + message.post = undefined; + } + if (object.delete !== undefined && object.delete !== null) { + message.delete = object.delete; + } else { + message.delete = undefined; + } + if (object.patch !== undefined && object.patch !== null) { + message.patch = object.patch; + } else { + message.patch = undefined; + } + if (object.custom !== undefined && object.custom !== null) { + message.custom = CustomHttpPattern.fromPartial(object.custom); + } else { + message.custom = undefined; + } + if (object.body !== undefined && object.body !== null) { + message.body = object.body; + } else { + message.body = ""; + } + if (object.responseBody !== undefined && object.responseBody !== null) { + message.responseBody = object.responseBody; + } else { + message.responseBody = ""; + } + if ( + object.additionalBindings !== undefined && + object.additionalBindings !== null + ) { + for (const e of object.additionalBindings) { + message.additionalBindings.push(HttpRule.fromPartial(e)); + } + } + return message; + }, +}; + +const baseCustomHttpPattern: object = { kind: "", path: "" }; + +export const CustomHttpPattern = { + encode(message: CustomHttpPattern, writer: Writer = Writer.create()): Writer { + if (message.kind !== "") { + writer.uint32(10).string(message.kind); + } + if (message.path !== "") { + writer.uint32(18).string(message.path); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): CustomHttpPattern { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseCustomHttpPattern } as CustomHttpPattern; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.kind = reader.string(); + break; + case 2: + message.path = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): CustomHttpPattern { + const message = { ...baseCustomHttpPattern } as CustomHttpPattern; + if (object.kind !== undefined && object.kind !== null) { + message.kind = String(object.kind); + } else { + message.kind = ""; + } + if (object.path !== undefined && object.path !== null) { + message.path = String(object.path); + } else { + message.path = ""; + } + return message; + }, + + toJSON(message: CustomHttpPattern): unknown { + const obj: any = {}; + message.kind !== undefined && (obj.kind = message.kind); + message.path !== undefined && (obj.path = message.path); + return obj; + }, + + fromPartial(object: DeepPartial): CustomHttpPattern { + const message = { ...baseCustomHttpPattern } as CustomHttpPattern; + if (object.kind !== undefined && object.kind !== null) { + message.kind = object.kind; + } else { + message.kind = ""; + } + if (object.path !== undefined && object.path !== null) { + message.path = object.path; + } else { + message.path = ""; + } + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/cosmos.gov.v1beta1/types/google/protobuf/any.ts b/ts-client/cosmos.gov.v1beta1/types/google/protobuf/any.ts new file mode 100644 index 00000000..b137a629 --- /dev/null +++ b/ts-client/cosmos.gov.v1beta1/types/google/protobuf/any.ts @@ -0,0 +1,240 @@ +/* eslint-disable */ +import { Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "google.protobuf"; + +/** + * `Any` contains an arbitrary serialized protocol buffer message along with a + * URL that describes the type of the serialized message. + * + * Protobuf library provides support to pack/unpack Any values in the form + * of utility functions or additional generated methods of the Any type. + * + * Example 1: Pack and unpack a message in C++. + * + * Foo foo = ...; + * Any any; + * any.PackFrom(foo); + * ... + * if (any.UnpackTo(&foo)) { + * ... + * } + * + * Example 2: Pack and unpack a message in Java. + * + * Foo foo = ...; + * Any any = Any.pack(foo); + * ... + * if (any.is(Foo.class)) { + * foo = any.unpack(Foo.class); + * } + * + * Example 3: Pack and unpack a message in Python. + * + * foo = Foo(...) + * any = Any() + * any.Pack(foo) + * ... + * if any.Is(Foo.DESCRIPTOR): + * any.Unpack(foo) + * ... + * + * Example 4: Pack and unpack a message in Go + * + * foo := &pb.Foo{...} + * any, err := anypb.New(foo) + * if err != nil { + * ... + * } + * ... + * foo := &pb.Foo{} + * if err := any.UnmarshalTo(foo); err != nil { + * ... + * } + * + * The pack methods provided by protobuf library will by default use + * 'type.googleapis.com/full.type.name' as the type URL and the unpack + * methods only use the fully qualified type name after the last '/' + * in the type URL, for example "foo.bar.com/x/y.z" will yield type + * name "y.z". + * + * + * JSON + * ==== + * The JSON representation of an `Any` value uses the regular + * representation of the deserialized, embedded message, with an + * additional field `@type` which contains the type URL. Example: + * + * package google.profile; + * message Person { + * string first_name = 1; + * string last_name = 2; + * } + * + * { + * "@type": "type.googleapis.com/google.profile.Person", + * "firstName": , + * "lastName": + * } + * + * If the embedded message type is well-known and has a custom JSON + * representation, that representation will be embedded adding a field + * `value` which holds the custom JSON in addition to the `@type` + * field. Example (for message [google.protobuf.Duration][]): + * + * { + * "@type": "type.googleapis.com/google.protobuf.Duration", + * "value": "1.212s" + * } + */ +export interface Any { + /** + * A URL/resource name that uniquely identifies the type of the serialized + * protocol buffer message. This string must contain at least + * one "/" character. The last segment of the URL's path must represent + * the fully qualified name of the type (as in + * `path/google.protobuf.Duration`). The name should be in a canonical form + * (e.g., leading "." is not accepted). + * + * In practice, teams usually precompile into the binary all types that they + * expect it to use in the context of Any. However, for URLs which use the + * scheme `http`, `https`, or no scheme, one can optionally set up a type + * server that maps type URLs to message definitions as follows: + * + * * If no scheme is provided, `https` is assumed. + * * An HTTP GET on the URL must yield a [google.protobuf.Type][] + * value in binary format, or produce an error. + * * Applications are allowed to cache lookup results based on the + * URL, or have them precompiled into a binary to avoid any + * lookup. Therefore, binary compatibility needs to be preserved + * on changes to types. (Use versioned type names to manage + * breaking changes.) + * + * Note: this functionality is not currently available in the official + * protobuf release, and it is not used for type URLs beginning with + * type.googleapis.com. + * + * Schemes other than `http`, `https` (or the empty scheme) might be + * used with implementation specific semantics. + */ + typeUrl: string; + /** Must be a valid serialized protocol buffer of the above specified type. */ + value: Uint8Array; +} + +const baseAny: object = { typeUrl: "" }; + +export const Any = { + encode(message: Any, writer: Writer = Writer.create()): Writer { + if (message.typeUrl !== "") { + writer.uint32(10).string(message.typeUrl); + } + if (message.value.length !== 0) { + writer.uint32(18).bytes(message.value); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Any { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseAny } as Any; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.typeUrl = reader.string(); + break; + case 2: + message.value = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Any { + const message = { ...baseAny } as Any; + if (object.typeUrl !== undefined && object.typeUrl !== null) { + message.typeUrl = String(object.typeUrl); + } else { + message.typeUrl = ""; + } + if (object.value !== undefined && object.value !== null) { + message.value = bytesFromBase64(object.value); + } + return message; + }, + + toJSON(message: Any): unknown { + const obj: any = {}; + message.typeUrl !== undefined && (obj.typeUrl = message.typeUrl); + message.value !== undefined && + (obj.value = base64FromBytes( + message.value !== undefined ? message.value : new Uint8Array() + )); + return obj; + }, + + fromPartial(object: DeepPartial): Any { + const message = { ...baseAny } as Any; + if (object.typeUrl !== undefined && object.typeUrl !== null) { + message.typeUrl = object.typeUrl; + } else { + message.typeUrl = ""; + } + if (object.value !== undefined && object.value !== null) { + message.value = object.value; + } else { + message.value = new Uint8Array(); + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/cosmos.gov.v1beta1/types/google/protobuf/descriptor.ts b/ts-client/cosmos.gov.v1beta1/types/google/protobuf/descriptor.ts new file mode 100644 index 00000000..9e508660 --- /dev/null +++ b/ts-client/cosmos.gov.v1beta1/types/google/protobuf/descriptor.ts @@ -0,0 +1,5261 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "google.protobuf"; + +/** + * The protocol compiler can output a FileDescriptorSet containing the .proto + * files it parses. + */ +export interface FileDescriptorSet { + file: FileDescriptorProto[]; +} + +/** Describes a complete .proto file. */ +export interface FileDescriptorProto { + /** file name, relative to root of source tree */ + name: string; + /** e.g. "foo", "foo.bar", etc. */ + package: string; + /** Names of files imported by this file. */ + dependency: string[]; + /** Indexes of the public imported files in the dependency list above. */ + publicDependency: number[]; + /** + * Indexes of the weak imported files in the dependency list. + * For Google-internal migration only. Do not use. + */ + weakDependency: number[]; + /** All top-level definitions in this file. */ + messageType: DescriptorProto[]; + enumType: EnumDescriptorProto[]; + service: ServiceDescriptorProto[]; + extension: FieldDescriptorProto[]; + options: FileOptions | undefined; + /** + * This field contains optional information about the original source code. + * You may safely remove this entire field without harming runtime + * functionality of the descriptors -- the information is needed only by + * development tools. + */ + sourceCodeInfo: SourceCodeInfo | undefined; + /** + * The syntax of the proto file. + * The supported values are "proto2" and "proto3". + */ + syntax: string; +} + +/** Describes a message type. */ +export interface DescriptorProto { + name: string; + field: FieldDescriptorProto[]; + extension: FieldDescriptorProto[]; + nestedType: DescriptorProto[]; + enumType: EnumDescriptorProto[]; + extensionRange: DescriptorProto_ExtensionRange[]; + oneofDecl: OneofDescriptorProto[]; + options: MessageOptions | undefined; + reservedRange: DescriptorProto_ReservedRange[]; + /** + * Reserved field names, which may not be used by fields in the same message. + * A given name may only be reserved once. + */ + reservedName: string[]; +} + +export interface DescriptorProto_ExtensionRange { + /** Inclusive. */ + start: number; + /** Exclusive. */ + end: number; + options: ExtensionRangeOptions | undefined; +} + +/** + * Range of reserved tag numbers. Reserved tag numbers may not be used by + * fields or extension ranges in the same message. Reserved ranges may + * not overlap. + */ +export interface DescriptorProto_ReservedRange { + /** Inclusive. */ + start: number; + /** Exclusive. */ + end: number; +} + +export interface ExtensionRangeOptions { + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +/** Describes a field within a message. */ +export interface FieldDescriptorProto { + name: string; + number: number; + label: FieldDescriptorProto_Label; + /** + * If type_name is set, this need not be set. If both this and type_name + * are set, this must be one of TYPE_ENUM, TYPE_MESSAGE or TYPE_GROUP. + */ + type: FieldDescriptorProto_Type; + /** + * For message and enum types, this is the name of the type. If the name + * starts with a '.', it is fully-qualified. Otherwise, C++-like scoping + * rules are used to find the type (i.e. first the nested types within this + * message are searched, then within the parent, on up to the root + * namespace). + */ + typeName: string; + /** + * For extensions, this is the name of the type being extended. It is + * resolved in the same manner as type_name. + */ + extendee: string; + /** + * For numeric types, contains the original text representation of the value. + * For booleans, "true" or "false". + * For strings, contains the default text contents (not escaped in any way). + * For bytes, contains the C escaped value. All bytes >= 128 are escaped. + * TODO(kenton): Base-64 encode? + */ + defaultValue: string; + /** + * If set, gives the index of a oneof in the containing type's oneof_decl + * list. This field is a member of that oneof. + */ + oneofIndex: number; + /** + * JSON name of this field. The value is set by protocol compiler. If the + * user has set a "json_name" option on this field, that option's value + * will be used. Otherwise, it's deduced from the field's name by converting + * it to camelCase. + */ + jsonName: string; + options: FieldOptions | undefined; + /** + * If true, this is a proto3 "optional". When a proto3 field is optional, it + * tracks presence regardless of field type. + * + * When proto3_optional is true, this field must be belong to a oneof to + * signal to old proto3 clients that presence is tracked for this field. This + * oneof is known as a "synthetic" oneof, and this field must be its sole + * member (each proto3 optional field gets its own synthetic oneof). Synthetic + * oneofs exist in the descriptor only, and do not generate any API. Synthetic + * oneofs must be ordered after all "real" oneofs. + * + * For message fields, proto3_optional doesn't create any semantic change, + * since non-repeated message fields always track presence. However it still + * indicates the semantic detail of whether the user wrote "optional" or not. + * This can be useful for round-tripping the .proto file. For consistency we + * give message fields a synthetic oneof also, even though it is not required + * to track presence. This is especially important because the parser can't + * tell if a field is a message or an enum, so it must always create a + * synthetic oneof. + * + * Proto2 optional fields do not set this flag, because they already indicate + * optional with `LABEL_OPTIONAL`. + */ + proto3Optional: boolean; +} + +export enum FieldDescriptorProto_Type { + /** + * TYPE_DOUBLE - 0 is reserved for errors. + * Order is weird for historical reasons. + */ + TYPE_DOUBLE = 1, + TYPE_FLOAT = 2, + /** + * TYPE_INT64 - Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT64 if + * negative values are likely. + */ + TYPE_INT64 = 3, + TYPE_UINT64 = 4, + /** + * TYPE_INT32 - Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT32 if + * negative values are likely. + */ + TYPE_INT32 = 5, + TYPE_FIXED64 = 6, + TYPE_FIXED32 = 7, + TYPE_BOOL = 8, + TYPE_STRING = 9, + /** + * TYPE_GROUP - Tag-delimited aggregate. + * Group type is deprecated and not supported in proto3. However, Proto3 + * implementations should still be able to parse the group wire format and + * treat group fields as unknown fields. + */ + TYPE_GROUP = 10, + /** TYPE_MESSAGE - Length-delimited aggregate. */ + TYPE_MESSAGE = 11, + /** TYPE_BYTES - New in version 2. */ + TYPE_BYTES = 12, + TYPE_UINT32 = 13, + TYPE_ENUM = 14, + TYPE_SFIXED32 = 15, + TYPE_SFIXED64 = 16, + /** TYPE_SINT32 - Uses ZigZag encoding. */ + TYPE_SINT32 = 17, + /** TYPE_SINT64 - Uses ZigZag encoding. */ + TYPE_SINT64 = 18, + UNRECOGNIZED = -1, +} + +export function fieldDescriptorProto_TypeFromJSON( + object: any +): FieldDescriptorProto_Type { + switch (object) { + case 1: + case "TYPE_DOUBLE": + return FieldDescriptorProto_Type.TYPE_DOUBLE; + case 2: + case "TYPE_FLOAT": + return FieldDescriptorProto_Type.TYPE_FLOAT; + case 3: + case "TYPE_INT64": + return FieldDescriptorProto_Type.TYPE_INT64; + case 4: + case "TYPE_UINT64": + return FieldDescriptorProto_Type.TYPE_UINT64; + case 5: + case "TYPE_INT32": + return FieldDescriptorProto_Type.TYPE_INT32; + case 6: + case "TYPE_FIXED64": + return FieldDescriptorProto_Type.TYPE_FIXED64; + case 7: + case "TYPE_FIXED32": + return FieldDescriptorProto_Type.TYPE_FIXED32; + case 8: + case "TYPE_BOOL": + return FieldDescriptorProto_Type.TYPE_BOOL; + case 9: + case "TYPE_STRING": + return FieldDescriptorProto_Type.TYPE_STRING; + case 10: + case "TYPE_GROUP": + return FieldDescriptorProto_Type.TYPE_GROUP; + case 11: + case "TYPE_MESSAGE": + return FieldDescriptorProto_Type.TYPE_MESSAGE; + case 12: + case "TYPE_BYTES": + return FieldDescriptorProto_Type.TYPE_BYTES; + case 13: + case "TYPE_UINT32": + return FieldDescriptorProto_Type.TYPE_UINT32; + case 14: + case "TYPE_ENUM": + return FieldDescriptorProto_Type.TYPE_ENUM; + case 15: + case "TYPE_SFIXED32": + return FieldDescriptorProto_Type.TYPE_SFIXED32; + case 16: + case "TYPE_SFIXED64": + return FieldDescriptorProto_Type.TYPE_SFIXED64; + case 17: + case "TYPE_SINT32": + return FieldDescriptorProto_Type.TYPE_SINT32; + case 18: + case "TYPE_SINT64": + return FieldDescriptorProto_Type.TYPE_SINT64; + case -1: + case "UNRECOGNIZED": + default: + return FieldDescriptorProto_Type.UNRECOGNIZED; + } +} + +export function fieldDescriptorProto_TypeToJSON( + object: FieldDescriptorProto_Type +): string { + switch (object) { + case FieldDescriptorProto_Type.TYPE_DOUBLE: + return "TYPE_DOUBLE"; + case FieldDescriptorProto_Type.TYPE_FLOAT: + return "TYPE_FLOAT"; + case FieldDescriptorProto_Type.TYPE_INT64: + return "TYPE_INT64"; + case FieldDescriptorProto_Type.TYPE_UINT64: + return "TYPE_UINT64"; + case FieldDescriptorProto_Type.TYPE_INT32: + return "TYPE_INT32"; + case FieldDescriptorProto_Type.TYPE_FIXED64: + return "TYPE_FIXED64"; + case FieldDescriptorProto_Type.TYPE_FIXED32: + return "TYPE_FIXED32"; + case FieldDescriptorProto_Type.TYPE_BOOL: + return "TYPE_BOOL"; + case FieldDescriptorProto_Type.TYPE_STRING: + return "TYPE_STRING"; + case FieldDescriptorProto_Type.TYPE_GROUP: + return "TYPE_GROUP"; + case FieldDescriptorProto_Type.TYPE_MESSAGE: + return "TYPE_MESSAGE"; + case FieldDescriptorProto_Type.TYPE_BYTES: + return "TYPE_BYTES"; + case FieldDescriptorProto_Type.TYPE_UINT32: + return "TYPE_UINT32"; + case FieldDescriptorProto_Type.TYPE_ENUM: + return "TYPE_ENUM"; + case FieldDescriptorProto_Type.TYPE_SFIXED32: + return "TYPE_SFIXED32"; + case FieldDescriptorProto_Type.TYPE_SFIXED64: + return "TYPE_SFIXED64"; + case FieldDescriptorProto_Type.TYPE_SINT32: + return "TYPE_SINT32"; + case FieldDescriptorProto_Type.TYPE_SINT64: + return "TYPE_SINT64"; + default: + return "UNKNOWN"; + } +} + +export enum FieldDescriptorProto_Label { + /** LABEL_OPTIONAL - 0 is reserved for errors */ + LABEL_OPTIONAL = 1, + LABEL_REQUIRED = 2, + LABEL_REPEATED = 3, + UNRECOGNIZED = -1, +} + +export function fieldDescriptorProto_LabelFromJSON( + object: any +): FieldDescriptorProto_Label { + switch (object) { + case 1: + case "LABEL_OPTIONAL": + return FieldDescriptorProto_Label.LABEL_OPTIONAL; + case 2: + case "LABEL_REQUIRED": + return FieldDescriptorProto_Label.LABEL_REQUIRED; + case 3: + case "LABEL_REPEATED": + return FieldDescriptorProto_Label.LABEL_REPEATED; + case -1: + case "UNRECOGNIZED": + default: + return FieldDescriptorProto_Label.UNRECOGNIZED; + } +} + +export function fieldDescriptorProto_LabelToJSON( + object: FieldDescriptorProto_Label +): string { + switch (object) { + case FieldDescriptorProto_Label.LABEL_OPTIONAL: + return "LABEL_OPTIONAL"; + case FieldDescriptorProto_Label.LABEL_REQUIRED: + return "LABEL_REQUIRED"; + case FieldDescriptorProto_Label.LABEL_REPEATED: + return "LABEL_REPEATED"; + default: + return "UNKNOWN"; + } +} + +/** Describes a oneof. */ +export interface OneofDescriptorProto { + name: string; + options: OneofOptions | undefined; +} + +/** Describes an enum type. */ +export interface EnumDescriptorProto { + name: string; + value: EnumValueDescriptorProto[]; + options: EnumOptions | undefined; + /** + * Range of reserved numeric values. Reserved numeric values may not be used + * by enum values in the same enum declaration. Reserved ranges may not + * overlap. + */ + reservedRange: EnumDescriptorProto_EnumReservedRange[]; + /** + * Reserved enum value names, which may not be reused. A given name may only + * be reserved once. + */ + reservedName: string[]; +} + +/** + * Range of reserved numeric values. Reserved values may not be used by + * entries in the same enum. Reserved ranges may not overlap. + * + * Note that this is distinct from DescriptorProto.ReservedRange in that it + * is inclusive such that it can appropriately represent the entire int32 + * domain. + */ +export interface EnumDescriptorProto_EnumReservedRange { + /** Inclusive. */ + start: number; + /** Inclusive. */ + end: number; +} + +/** Describes a value within an enum. */ +export interface EnumValueDescriptorProto { + name: string; + number: number; + options: EnumValueOptions | undefined; +} + +/** Describes a service. */ +export interface ServiceDescriptorProto { + name: string; + method: MethodDescriptorProto[]; + options: ServiceOptions | undefined; +} + +/** Describes a method of a service. */ +export interface MethodDescriptorProto { + name: string; + /** + * Input and output type names. These are resolved in the same way as + * FieldDescriptorProto.type_name, but must refer to a message type. + */ + inputType: string; + outputType: string; + options: MethodOptions | undefined; + /** Identifies if client streams multiple client messages */ + clientStreaming: boolean; + /** Identifies if server streams multiple server messages */ + serverStreaming: boolean; +} + +export interface FileOptions { + /** + * Sets the Java package where classes generated from this .proto will be + * placed. By default, the proto package is used, but this is often + * inappropriate because proto packages do not normally start with backwards + * domain names. + */ + javaPackage: string; + /** + * Controls the name of the wrapper Java class generated for the .proto file. + * That class will always contain the .proto file's getDescriptor() method as + * well as any top-level extensions defined in the .proto file. + * If java_multiple_files is disabled, then all the other classes from the + * .proto file will be nested inside the single wrapper outer class. + */ + javaOuterClassname: string; + /** + * If enabled, then the Java code generator will generate a separate .java + * file for each top-level message, enum, and service defined in the .proto + * file. Thus, these types will *not* be nested inside the wrapper class + * named by java_outer_classname. However, the wrapper class will still be + * generated to contain the file's getDescriptor() method as well as any + * top-level extensions defined in the file. + */ + javaMultipleFiles: boolean; + /** + * This option does nothing. + * + * @deprecated + */ + javaGenerateEqualsAndHash: boolean; + /** + * If set true, then the Java2 code generator will generate code that + * throws an exception whenever an attempt is made to assign a non-UTF-8 + * byte sequence to a string field. + * Message reflection will do the same. + * However, an extension field still accepts non-UTF-8 byte sequences. + * This option has no effect on when used with the lite runtime. + */ + javaStringCheckUtf8: boolean; + optimizeFor: FileOptions_OptimizeMode; + /** + * Sets the Go package where structs generated from this .proto will be + * placed. If omitted, the Go package will be derived from the following: + * - The basename of the package import path, if provided. + * - Otherwise, the package statement in the .proto file, if present. + * - Otherwise, the basename of the .proto file, without extension. + */ + goPackage: string; + /** + * Should generic services be generated in each language? "Generic" services + * are not specific to any particular RPC system. They are generated by the + * main code generators in each language (without additional plugins). + * Generic services were the only kind of service generation supported by + * early versions of google.protobuf. + * + * Generic services are now considered deprecated in favor of using plugins + * that generate code specific to your particular RPC system. Therefore, + * these default to false. Old code which depends on generic services should + * explicitly set them to true. + */ + ccGenericServices: boolean; + javaGenericServices: boolean; + pyGenericServices: boolean; + phpGenericServices: boolean; + /** + * Is this file deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for everything in the file, or it will be completely ignored; in the very + * least, this is a formalization for deprecating files. + */ + deprecated: boolean; + /** + * Enables the use of arenas for the proto messages in this file. This applies + * only to generated classes for C++. + */ + ccEnableArenas: boolean; + /** + * Sets the objective c class prefix which is prepended to all objective c + * generated classes from this .proto. There is no default. + */ + objcClassPrefix: string; + /** Namespace for generated classes; defaults to the package. */ + csharpNamespace: string; + /** + * By default Swift generators will take the proto package and CamelCase it + * replacing '.' with underscore and use that to prefix the types/symbols + * defined. When this options is provided, they will use this value instead + * to prefix the types/symbols defined. + */ + swiftPrefix: string; + /** + * Sets the php class prefix which is prepended to all php generated classes + * from this .proto. Default is empty. + */ + phpClassPrefix: string; + /** + * Use this option to change the namespace of php generated classes. Default + * is empty. When this option is empty, the package name will be used for + * determining the namespace. + */ + phpNamespace: string; + /** + * Use this option to change the namespace of php generated metadata classes. + * Default is empty. When this option is empty, the proto file name will be + * used for determining the namespace. + */ + phpMetadataNamespace: string; + /** + * Use this option to change the package of ruby generated classes. Default + * is empty. When this option is not set, the package name will be used for + * determining the ruby package. + */ + rubyPackage: string; + /** + * The parser stores options it doesn't recognize here. + * See the documentation for the "Options" section above. + */ + uninterpretedOption: UninterpretedOption[]; +} + +/** Generated classes can be optimized for speed or code size. */ +export enum FileOptions_OptimizeMode { + /** SPEED - Generate complete code for parsing, serialization, */ + SPEED = 1, + /** CODE_SIZE - etc. */ + CODE_SIZE = 2, + /** LITE_RUNTIME - Generate code using MessageLite and the lite runtime. */ + LITE_RUNTIME = 3, + UNRECOGNIZED = -1, +} + +export function fileOptions_OptimizeModeFromJSON( + object: any +): FileOptions_OptimizeMode { + switch (object) { + case 1: + case "SPEED": + return FileOptions_OptimizeMode.SPEED; + case 2: + case "CODE_SIZE": + return FileOptions_OptimizeMode.CODE_SIZE; + case 3: + case "LITE_RUNTIME": + return FileOptions_OptimizeMode.LITE_RUNTIME; + case -1: + case "UNRECOGNIZED": + default: + return FileOptions_OptimizeMode.UNRECOGNIZED; + } +} + +export function fileOptions_OptimizeModeToJSON( + object: FileOptions_OptimizeMode +): string { + switch (object) { + case FileOptions_OptimizeMode.SPEED: + return "SPEED"; + case FileOptions_OptimizeMode.CODE_SIZE: + return "CODE_SIZE"; + case FileOptions_OptimizeMode.LITE_RUNTIME: + return "LITE_RUNTIME"; + default: + return "UNKNOWN"; + } +} + +export interface MessageOptions { + /** + * Set true to use the old proto1 MessageSet wire format for extensions. + * This is provided for backwards-compatibility with the MessageSet wire + * format. You should not use this for any other reason: It's less + * efficient, has fewer features, and is more complicated. + * + * The message must be defined exactly as follows: + * message Foo { + * option message_set_wire_format = true; + * extensions 4 to max; + * } + * Note that the message cannot have any defined fields; MessageSets only + * have extensions. + * + * All extensions of your type must be singular messages; e.g. they cannot + * be int32s, enums, or repeated messages. + * + * Because this is an option, the above two restrictions are not enforced by + * the protocol compiler. + */ + messageSetWireFormat: boolean; + /** + * Disables the generation of the standard "descriptor()" accessor, which can + * conflict with a field of the same name. This is meant to make migration + * from proto1 easier; new code should avoid fields named "descriptor". + */ + noStandardDescriptorAccessor: boolean; + /** + * Is this message deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the message, or it will be completely ignored; in the very least, + * this is a formalization for deprecating messages. + */ + deprecated: boolean; + /** + * Whether the message is an automatically generated map entry type for the + * maps field. + * + * For maps fields: + * map map_field = 1; + * The parsed descriptor looks like: + * message MapFieldEntry { + * option map_entry = true; + * optional KeyType key = 1; + * optional ValueType value = 2; + * } + * repeated MapFieldEntry map_field = 1; + * + * Implementations may choose not to generate the map_entry=true message, but + * use a native map in the target language to hold the keys and values. + * The reflection APIs in such implementations still need to work as + * if the field is a repeated message field. + * + * NOTE: Do not set the option in .proto files. Always use the maps syntax + * instead. The option should only be implicitly set by the proto compiler + * parser. + */ + mapEntry: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface FieldOptions { + /** + * The ctype option instructs the C++ code generator to use a different + * representation of the field than it normally would. See the specific + * options below. This option is not yet implemented in the open source + * release -- sorry, we'll try to include it in a future version! + */ + ctype: FieldOptions_CType; + /** + * The packed option can be enabled for repeated primitive fields to enable + * a more efficient representation on the wire. Rather than repeatedly + * writing the tag and type for each element, the entire array is encoded as + * a single length-delimited blob. In proto3, only explicit setting it to + * false will avoid using packed encoding. + */ + packed: boolean; + /** + * The jstype option determines the JavaScript type used for values of the + * field. The option is permitted only for 64 bit integral and fixed types + * (int64, uint64, sint64, fixed64, sfixed64). A field with jstype JS_STRING + * is represented as JavaScript string, which avoids loss of precision that + * can happen when a large value is converted to a floating point JavaScript. + * Specifying JS_NUMBER for the jstype causes the generated JavaScript code to + * use the JavaScript "number" type. The behavior of the default option + * JS_NORMAL is implementation dependent. + * + * This option is an enum to permit additional types to be added, e.g. + * goog.math.Integer. + */ + jstype: FieldOptions_JSType; + /** + * Should this field be parsed lazily? Lazy applies only to message-type + * fields. It means that when the outer message is initially parsed, the + * inner message's contents will not be parsed but instead stored in encoded + * form. The inner message will actually be parsed when it is first accessed. + * + * This is only a hint. Implementations are free to choose whether to use + * eager or lazy parsing regardless of the value of this option. However, + * setting this option true suggests that the protocol author believes that + * using lazy parsing on this field is worth the additional bookkeeping + * overhead typically needed to implement it. + * + * This option does not affect the public interface of any generated code; + * all method signatures remain the same. Furthermore, thread-safety of the + * interface is not affected by this option; const methods remain safe to + * call from multiple threads concurrently, while non-const methods continue + * to require exclusive access. + * + * + * Note that implementations may choose not to check required fields within + * a lazy sub-message. That is, calling IsInitialized() on the outer message + * may return true even if the inner message has missing required fields. + * This is necessary because otherwise the inner message would have to be + * parsed in order to perform the check, defeating the purpose of lazy + * parsing. An implementation which chooses not to check required fields + * must be consistent about it. That is, for any particular sub-message, the + * implementation must either *always* check its required fields, or *never* + * check its required fields, regardless of whether or not the message has + * been parsed. + */ + lazy: boolean; + /** + * Is this field deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for accessors, or it will be completely ignored; in the very least, this + * is a formalization for deprecating fields. + */ + deprecated: boolean; + /** For Google-internal migration only. Do not use. */ + weak: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export enum FieldOptions_CType { + /** STRING - Default mode. */ + STRING = 0, + CORD = 1, + STRING_PIECE = 2, + UNRECOGNIZED = -1, +} + +export function fieldOptions_CTypeFromJSON(object: any): FieldOptions_CType { + switch (object) { + case 0: + case "STRING": + return FieldOptions_CType.STRING; + case 1: + case "CORD": + return FieldOptions_CType.CORD; + case 2: + case "STRING_PIECE": + return FieldOptions_CType.STRING_PIECE; + case -1: + case "UNRECOGNIZED": + default: + return FieldOptions_CType.UNRECOGNIZED; + } +} + +export function fieldOptions_CTypeToJSON(object: FieldOptions_CType): string { + switch (object) { + case FieldOptions_CType.STRING: + return "STRING"; + case FieldOptions_CType.CORD: + return "CORD"; + case FieldOptions_CType.STRING_PIECE: + return "STRING_PIECE"; + default: + return "UNKNOWN"; + } +} + +export enum FieldOptions_JSType { + /** JS_NORMAL - Use the default type. */ + JS_NORMAL = 0, + /** JS_STRING - Use JavaScript strings. */ + JS_STRING = 1, + /** JS_NUMBER - Use JavaScript numbers. */ + JS_NUMBER = 2, + UNRECOGNIZED = -1, +} + +export function fieldOptions_JSTypeFromJSON(object: any): FieldOptions_JSType { + switch (object) { + case 0: + case "JS_NORMAL": + return FieldOptions_JSType.JS_NORMAL; + case 1: + case "JS_STRING": + return FieldOptions_JSType.JS_STRING; + case 2: + case "JS_NUMBER": + return FieldOptions_JSType.JS_NUMBER; + case -1: + case "UNRECOGNIZED": + default: + return FieldOptions_JSType.UNRECOGNIZED; + } +} + +export function fieldOptions_JSTypeToJSON(object: FieldOptions_JSType): string { + switch (object) { + case FieldOptions_JSType.JS_NORMAL: + return "JS_NORMAL"; + case FieldOptions_JSType.JS_STRING: + return "JS_STRING"; + case FieldOptions_JSType.JS_NUMBER: + return "JS_NUMBER"; + default: + return "UNKNOWN"; + } +} + +export interface OneofOptions { + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface EnumOptions { + /** + * Set this option to true to allow mapping different tag names to the same + * value. + */ + allowAlias: boolean; + /** + * Is this enum deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the enum, or it will be completely ignored; in the very least, this + * is a formalization for deprecating enums. + */ + deprecated: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface EnumValueOptions { + /** + * Is this enum value deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the enum value, or it will be completely ignored; in the very least, + * this is a formalization for deprecating enum values. + */ + deprecated: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface ServiceOptions { + /** + * Is this service deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the service, or it will be completely ignored; in the very least, + * this is a formalization for deprecating services. + */ + deprecated: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface MethodOptions { + /** + * Is this method deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the method, or it will be completely ignored; in the very least, + * this is a formalization for deprecating methods. + */ + deprecated: boolean; + idempotencyLevel: MethodOptions_IdempotencyLevel; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +/** + * Is this method side-effect-free (or safe in HTTP parlance), or idempotent, + * or neither? HTTP based RPC implementation may choose GET verb for safe + * methods, and PUT verb for idempotent methods instead of the default POST. + */ +export enum MethodOptions_IdempotencyLevel { + IDEMPOTENCY_UNKNOWN = 0, + /** NO_SIDE_EFFECTS - implies idempotent */ + NO_SIDE_EFFECTS = 1, + /** IDEMPOTENT - idempotent, but may have side effects */ + IDEMPOTENT = 2, + UNRECOGNIZED = -1, +} + +export function methodOptions_IdempotencyLevelFromJSON( + object: any +): MethodOptions_IdempotencyLevel { + switch (object) { + case 0: + case "IDEMPOTENCY_UNKNOWN": + return MethodOptions_IdempotencyLevel.IDEMPOTENCY_UNKNOWN; + case 1: + case "NO_SIDE_EFFECTS": + return MethodOptions_IdempotencyLevel.NO_SIDE_EFFECTS; + case 2: + case "IDEMPOTENT": + return MethodOptions_IdempotencyLevel.IDEMPOTENT; + case -1: + case "UNRECOGNIZED": + default: + return MethodOptions_IdempotencyLevel.UNRECOGNIZED; + } +} + +export function methodOptions_IdempotencyLevelToJSON( + object: MethodOptions_IdempotencyLevel +): string { + switch (object) { + case MethodOptions_IdempotencyLevel.IDEMPOTENCY_UNKNOWN: + return "IDEMPOTENCY_UNKNOWN"; + case MethodOptions_IdempotencyLevel.NO_SIDE_EFFECTS: + return "NO_SIDE_EFFECTS"; + case MethodOptions_IdempotencyLevel.IDEMPOTENT: + return "IDEMPOTENT"; + default: + return "UNKNOWN"; + } +} + +/** + * A message representing a option the parser does not recognize. This only + * appears in options protos created by the compiler::Parser class. + * DescriptorPool resolves these when building Descriptor objects. Therefore, + * options protos in descriptor objects (e.g. returned by Descriptor::options(), + * or produced by Descriptor::CopyTo()) will never have UninterpretedOptions + * in them. + */ +export interface UninterpretedOption { + name: UninterpretedOption_NamePart[]; + /** + * The value of the uninterpreted option, in whatever type the tokenizer + * identified it as during parsing. Exactly one of these should be set. + */ + identifierValue: string; + positiveIntValue: number; + negativeIntValue: number; + doubleValue: number; + stringValue: Uint8Array; + aggregateValue: string; +} + +/** + * The name of the uninterpreted option. Each string represents a segment in + * a dot-separated name. is_extension is true iff a segment represents an + * extension (denoted with parentheses in options specs in .proto files). + * E.g.,{ ["foo", false], ["bar.baz", true], ["qux", false] } represents + * "foo.(bar.baz).qux". + */ +export interface UninterpretedOption_NamePart { + namePart: string; + isExtension: boolean; +} + +/** + * Encapsulates information about the original source file from which a + * FileDescriptorProto was generated. + */ +export interface SourceCodeInfo { + /** + * A Location identifies a piece of source code in a .proto file which + * corresponds to a particular definition. This information is intended + * to be useful to IDEs, code indexers, documentation generators, and similar + * tools. + * + * For example, say we have a file like: + * message Foo { + * optional string foo = 1; + * } + * Let's look at just the field definition: + * optional string foo = 1; + * ^ ^^ ^^ ^ ^^^ + * a bc de f ghi + * We have the following locations: + * span path represents + * [a,i) [ 4, 0, 2, 0 ] The whole field definition. + * [a,b) [ 4, 0, 2, 0, 4 ] The label (optional). + * [c,d) [ 4, 0, 2, 0, 5 ] The type (string). + * [e,f) [ 4, 0, 2, 0, 1 ] The name (foo). + * [g,h) [ 4, 0, 2, 0, 3 ] The number (1). + * + * Notes: + * - A location may refer to a repeated field itself (i.e. not to any + * particular index within it). This is used whenever a set of elements are + * logically enclosed in a single code segment. For example, an entire + * extend block (possibly containing multiple extension definitions) will + * have an outer location whose path refers to the "extensions" repeated + * field without an index. + * - Multiple locations may have the same path. This happens when a single + * logical declaration is spread out across multiple places. The most + * obvious example is the "extend" block again -- there may be multiple + * extend blocks in the same scope, each of which will have the same path. + * - A location's span is not always a subset of its parent's span. For + * example, the "extendee" of an extension declaration appears at the + * beginning of the "extend" block and is shared by all extensions within + * the block. + * - Just because a location's span is a subset of some other location's span + * does not mean that it is a descendant. For example, a "group" defines + * both a type and a field in a single declaration. Thus, the locations + * corresponding to the type and field and their components will overlap. + * - Code which tries to interpret locations should probably be designed to + * ignore those that it doesn't understand, as more types of locations could + * be recorded in the future. + */ + location: SourceCodeInfo_Location[]; +} + +export interface SourceCodeInfo_Location { + /** + * Identifies which part of the FileDescriptorProto was defined at this + * location. + * + * Each element is a field number or an index. They form a path from + * the root FileDescriptorProto to the place where the definition. For + * example, this path: + * [ 4, 3, 2, 7, 1 ] + * refers to: + * file.message_type(3) // 4, 3 + * .field(7) // 2, 7 + * .name() // 1 + * This is because FileDescriptorProto.message_type has field number 4: + * repeated DescriptorProto message_type = 4; + * and DescriptorProto.field has field number 2: + * repeated FieldDescriptorProto field = 2; + * and FieldDescriptorProto.name has field number 1: + * optional string name = 1; + * + * Thus, the above path gives the location of a field name. If we removed + * the last element: + * [ 4, 3, 2, 7 ] + * this path refers to the whole field declaration (from the beginning + * of the label to the terminating semicolon). + */ + path: number[]; + /** + * Always has exactly three or four elements: start line, start column, + * end line (optional, otherwise assumed same as start line), end column. + * These are packed into a single field for efficiency. Note that line + * and column numbers are zero-based -- typically you will want to add + * 1 to each before displaying to a user. + */ + span: number[]; + /** + * If this SourceCodeInfo represents a complete declaration, these are any + * comments appearing before and after the declaration which appear to be + * attached to the declaration. + * + * A series of line comments appearing on consecutive lines, with no other + * tokens appearing on those lines, will be treated as a single comment. + * + * leading_detached_comments will keep paragraphs of comments that appear + * before (but not connected to) the current element. Each paragraph, + * separated by empty lines, will be one comment element in the repeated + * field. + * + * Only the comment content is provided; comment markers (e.g. //) are + * stripped out. For block comments, leading whitespace and an asterisk + * will be stripped from the beginning of each line other than the first. + * Newlines are included in the output. + * + * Examples: + * + * optional int32 foo = 1; // Comment attached to foo. + * // Comment attached to bar. + * optional int32 bar = 2; + * + * optional string baz = 3; + * // Comment attached to baz. + * // Another line attached to baz. + * + * // Comment attached to qux. + * // + * // Another line attached to qux. + * optional double qux = 4; + * + * // Detached comment for corge. This is not leading or trailing comments + * // to qux or corge because there are blank lines separating it from + * // both. + * + * // Detached comment for corge paragraph 2. + * + * optional string corge = 5; + * /* Block comment attached + * * to corge. Leading asterisks + * * will be removed. * / + * /* Block comment attached to + * * grault. * / + * optional int32 grault = 6; + * + * // ignored detached comments. + */ + leadingComments: string; + trailingComments: string; + leadingDetachedComments: string[]; +} + +/** + * Describes the relationship between generated code and its original source + * file. A GeneratedCodeInfo message is associated with only one generated + * source file, but may contain references to different source .proto files. + */ +export interface GeneratedCodeInfo { + /** + * An Annotation connects some span of text in generated code to an element + * of its generating .proto file. + */ + annotation: GeneratedCodeInfo_Annotation[]; +} + +export interface GeneratedCodeInfo_Annotation { + /** + * Identifies the element in the original source .proto file. This field + * is formatted the same as SourceCodeInfo.Location.path. + */ + path: number[]; + /** Identifies the filesystem path to the original source .proto. */ + sourceFile: string; + /** + * Identifies the starting offset in bytes in the generated code + * that relates to the identified object. + */ + begin: number; + /** + * Identifies the ending offset in bytes in the generated code that + * relates to the identified offset. The end offset should be one past + * the last relevant byte (so the length of the text = end - begin). + */ + end: number; +} + +const baseFileDescriptorSet: object = {}; + +export const FileDescriptorSet = { + encode(message: FileDescriptorSet, writer: Writer = Writer.create()): Writer { + for (const v of message.file) { + FileDescriptorProto.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FileDescriptorSet { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFileDescriptorSet } as FileDescriptorSet; + message.file = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.file.push( + FileDescriptorProto.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FileDescriptorSet { + const message = { ...baseFileDescriptorSet } as FileDescriptorSet; + message.file = []; + if (object.file !== undefined && object.file !== null) { + for (const e of object.file) { + message.file.push(FileDescriptorProto.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: FileDescriptorSet): unknown { + const obj: any = {}; + if (message.file) { + obj.file = message.file.map((e) => + e ? FileDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.file = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): FileDescriptorSet { + const message = { ...baseFileDescriptorSet } as FileDescriptorSet; + message.file = []; + if (object.file !== undefined && object.file !== null) { + for (const e of object.file) { + message.file.push(FileDescriptorProto.fromPartial(e)); + } + } + return message; + }, +}; + +const baseFileDescriptorProto: object = { + name: "", + package: "", + dependency: "", + publicDependency: 0, + weakDependency: 0, + syntax: "", +}; + +export const FileDescriptorProto = { + encode( + message: FileDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.package !== "") { + writer.uint32(18).string(message.package); + } + for (const v of message.dependency) { + writer.uint32(26).string(v!); + } + writer.uint32(82).fork(); + for (const v of message.publicDependency) { + writer.int32(v); + } + writer.ldelim(); + writer.uint32(90).fork(); + for (const v of message.weakDependency) { + writer.int32(v); + } + writer.ldelim(); + for (const v of message.messageType) { + DescriptorProto.encode(v!, writer.uint32(34).fork()).ldelim(); + } + for (const v of message.enumType) { + EnumDescriptorProto.encode(v!, writer.uint32(42).fork()).ldelim(); + } + for (const v of message.service) { + ServiceDescriptorProto.encode(v!, writer.uint32(50).fork()).ldelim(); + } + for (const v of message.extension) { + FieldDescriptorProto.encode(v!, writer.uint32(58).fork()).ldelim(); + } + if (message.options !== undefined) { + FileOptions.encode(message.options, writer.uint32(66).fork()).ldelim(); + } + if (message.sourceCodeInfo !== undefined) { + SourceCodeInfo.encode( + message.sourceCodeInfo, + writer.uint32(74).fork() + ).ldelim(); + } + if (message.syntax !== "") { + writer.uint32(98).string(message.syntax); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FileDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFileDescriptorProto } as FileDescriptorProto; + message.dependency = []; + message.publicDependency = []; + message.weakDependency = []; + message.messageType = []; + message.enumType = []; + message.service = []; + message.extension = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.package = reader.string(); + break; + case 3: + message.dependency.push(reader.string()); + break; + case 10: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.publicDependency.push(reader.int32()); + } + } else { + message.publicDependency.push(reader.int32()); + } + break; + case 11: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.weakDependency.push(reader.int32()); + } + } else { + message.weakDependency.push(reader.int32()); + } + break; + case 4: + message.messageType.push( + DescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 5: + message.enumType.push( + EnumDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 6: + message.service.push( + ServiceDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 7: + message.extension.push( + FieldDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 8: + message.options = FileOptions.decode(reader, reader.uint32()); + break; + case 9: + message.sourceCodeInfo = SourceCodeInfo.decode( + reader, + reader.uint32() + ); + break; + case 12: + message.syntax = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FileDescriptorProto { + const message = { ...baseFileDescriptorProto } as FileDescriptorProto; + message.dependency = []; + message.publicDependency = []; + message.weakDependency = []; + message.messageType = []; + message.enumType = []; + message.service = []; + message.extension = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.package !== undefined && object.package !== null) { + message.package = String(object.package); + } else { + message.package = ""; + } + if (object.dependency !== undefined && object.dependency !== null) { + for (const e of object.dependency) { + message.dependency.push(String(e)); + } + } + if ( + object.publicDependency !== undefined && + object.publicDependency !== null + ) { + for (const e of object.publicDependency) { + message.publicDependency.push(Number(e)); + } + } + if (object.weakDependency !== undefined && object.weakDependency !== null) { + for (const e of object.weakDependency) { + message.weakDependency.push(Number(e)); + } + } + if (object.messageType !== undefined && object.messageType !== null) { + for (const e of object.messageType) { + message.messageType.push(DescriptorProto.fromJSON(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromJSON(e)); + } + } + if (object.service !== undefined && object.service !== null) { + for (const e of object.service) { + message.service.push(ServiceDescriptorProto.fromJSON(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = FileOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.sourceCodeInfo !== undefined && object.sourceCodeInfo !== null) { + message.sourceCodeInfo = SourceCodeInfo.fromJSON(object.sourceCodeInfo); + } else { + message.sourceCodeInfo = undefined; + } + if (object.syntax !== undefined && object.syntax !== null) { + message.syntax = String(object.syntax); + } else { + message.syntax = ""; + } + return message; + }, + + toJSON(message: FileDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.package !== undefined && (obj.package = message.package); + if (message.dependency) { + obj.dependency = message.dependency.map((e) => e); + } else { + obj.dependency = []; + } + if (message.publicDependency) { + obj.publicDependency = message.publicDependency.map((e) => e); + } else { + obj.publicDependency = []; + } + if (message.weakDependency) { + obj.weakDependency = message.weakDependency.map((e) => e); + } else { + obj.weakDependency = []; + } + if (message.messageType) { + obj.messageType = message.messageType.map((e) => + e ? DescriptorProto.toJSON(e) : undefined + ); + } else { + obj.messageType = []; + } + if (message.enumType) { + obj.enumType = message.enumType.map((e) => + e ? EnumDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.enumType = []; + } + if (message.service) { + obj.service = message.service.map((e) => + e ? ServiceDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.service = []; + } + if (message.extension) { + obj.extension = message.extension.map((e) => + e ? FieldDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.extension = []; + } + message.options !== undefined && + (obj.options = message.options + ? FileOptions.toJSON(message.options) + : undefined); + message.sourceCodeInfo !== undefined && + (obj.sourceCodeInfo = message.sourceCodeInfo + ? SourceCodeInfo.toJSON(message.sourceCodeInfo) + : undefined); + message.syntax !== undefined && (obj.syntax = message.syntax); + return obj; + }, + + fromPartial(object: DeepPartial): FileDescriptorProto { + const message = { ...baseFileDescriptorProto } as FileDescriptorProto; + message.dependency = []; + message.publicDependency = []; + message.weakDependency = []; + message.messageType = []; + message.enumType = []; + message.service = []; + message.extension = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.package !== undefined && object.package !== null) { + message.package = object.package; + } else { + message.package = ""; + } + if (object.dependency !== undefined && object.dependency !== null) { + for (const e of object.dependency) { + message.dependency.push(e); + } + } + if ( + object.publicDependency !== undefined && + object.publicDependency !== null + ) { + for (const e of object.publicDependency) { + message.publicDependency.push(e); + } + } + if (object.weakDependency !== undefined && object.weakDependency !== null) { + for (const e of object.weakDependency) { + message.weakDependency.push(e); + } + } + if (object.messageType !== undefined && object.messageType !== null) { + for (const e of object.messageType) { + message.messageType.push(DescriptorProto.fromPartial(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromPartial(e)); + } + } + if (object.service !== undefined && object.service !== null) { + for (const e of object.service) { + message.service.push(ServiceDescriptorProto.fromPartial(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = FileOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.sourceCodeInfo !== undefined && object.sourceCodeInfo !== null) { + message.sourceCodeInfo = SourceCodeInfo.fromPartial( + object.sourceCodeInfo + ); + } else { + message.sourceCodeInfo = undefined; + } + if (object.syntax !== undefined && object.syntax !== null) { + message.syntax = object.syntax; + } else { + message.syntax = ""; + } + return message; + }, +}; + +const baseDescriptorProto: object = { name: "", reservedName: "" }; + +export const DescriptorProto = { + encode(message: DescriptorProto, writer: Writer = Writer.create()): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + for (const v of message.field) { + FieldDescriptorProto.encode(v!, writer.uint32(18).fork()).ldelim(); + } + for (const v of message.extension) { + FieldDescriptorProto.encode(v!, writer.uint32(50).fork()).ldelim(); + } + for (const v of message.nestedType) { + DescriptorProto.encode(v!, writer.uint32(26).fork()).ldelim(); + } + for (const v of message.enumType) { + EnumDescriptorProto.encode(v!, writer.uint32(34).fork()).ldelim(); + } + for (const v of message.extensionRange) { + DescriptorProto_ExtensionRange.encode( + v!, + writer.uint32(42).fork() + ).ldelim(); + } + for (const v of message.oneofDecl) { + OneofDescriptorProto.encode(v!, writer.uint32(66).fork()).ldelim(); + } + if (message.options !== undefined) { + MessageOptions.encode(message.options, writer.uint32(58).fork()).ldelim(); + } + for (const v of message.reservedRange) { + DescriptorProto_ReservedRange.encode( + v!, + writer.uint32(74).fork() + ).ldelim(); + } + for (const v of message.reservedName) { + writer.uint32(82).string(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): DescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseDescriptorProto } as DescriptorProto; + message.field = []; + message.extension = []; + message.nestedType = []; + message.enumType = []; + message.extensionRange = []; + message.oneofDecl = []; + message.reservedRange = []; + message.reservedName = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.field.push( + FieldDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 6: + message.extension.push( + FieldDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 3: + message.nestedType.push( + DescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 4: + message.enumType.push( + EnumDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 5: + message.extensionRange.push( + DescriptorProto_ExtensionRange.decode(reader, reader.uint32()) + ); + break; + case 8: + message.oneofDecl.push( + OneofDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 7: + message.options = MessageOptions.decode(reader, reader.uint32()); + break; + case 9: + message.reservedRange.push( + DescriptorProto_ReservedRange.decode(reader, reader.uint32()) + ); + break; + case 10: + message.reservedName.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DescriptorProto { + const message = { ...baseDescriptorProto } as DescriptorProto; + message.field = []; + message.extension = []; + message.nestedType = []; + message.enumType = []; + message.extensionRange = []; + message.oneofDecl = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.field !== undefined && object.field !== null) { + for (const e of object.field) { + message.field.push(FieldDescriptorProto.fromJSON(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromJSON(e)); + } + } + if (object.nestedType !== undefined && object.nestedType !== null) { + for (const e of object.nestedType) { + message.nestedType.push(DescriptorProto.fromJSON(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromJSON(e)); + } + } + if (object.extensionRange !== undefined && object.extensionRange !== null) { + for (const e of object.extensionRange) { + message.extensionRange.push(DescriptorProto_ExtensionRange.fromJSON(e)); + } + } + if (object.oneofDecl !== undefined && object.oneofDecl !== null) { + for (const e of object.oneofDecl) { + message.oneofDecl.push(OneofDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = MessageOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push(DescriptorProto_ReservedRange.fromJSON(e)); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(String(e)); + } + } + return message; + }, + + toJSON(message: DescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + if (message.field) { + obj.field = message.field.map((e) => + e ? FieldDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.field = []; + } + if (message.extension) { + obj.extension = message.extension.map((e) => + e ? FieldDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.extension = []; + } + if (message.nestedType) { + obj.nestedType = message.nestedType.map((e) => + e ? DescriptorProto.toJSON(e) : undefined + ); + } else { + obj.nestedType = []; + } + if (message.enumType) { + obj.enumType = message.enumType.map((e) => + e ? EnumDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.enumType = []; + } + if (message.extensionRange) { + obj.extensionRange = message.extensionRange.map((e) => + e ? DescriptorProto_ExtensionRange.toJSON(e) : undefined + ); + } else { + obj.extensionRange = []; + } + if (message.oneofDecl) { + obj.oneofDecl = message.oneofDecl.map((e) => + e ? OneofDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.oneofDecl = []; + } + message.options !== undefined && + (obj.options = message.options + ? MessageOptions.toJSON(message.options) + : undefined); + if (message.reservedRange) { + obj.reservedRange = message.reservedRange.map((e) => + e ? DescriptorProto_ReservedRange.toJSON(e) : undefined + ); + } else { + obj.reservedRange = []; + } + if (message.reservedName) { + obj.reservedName = message.reservedName.map((e) => e); + } else { + obj.reservedName = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): DescriptorProto { + const message = { ...baseDescriptorProto } as DescriptorProto; + message.field = []; + message.extension = []; + message.nestedType = []; + message.enumType = []; + message.extensionRange = []; + message.oneofDecl = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.field !== undefined && object.field !== null) { + for (const e of object.field) { + message.field.push(FieldDescriptorProto.fromPartial(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromPartial(e)); + } + } + if (object.nestedType !== undefined && object.nestedType !== null) { + for (const e of object.nestedType) { + message.nestedType.push(DescriptorProto.fromPartial(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromPartial(e)); + } + } + if (object.extensionRange !== undefined && object.extensionRange !== null) { + for (const e of object.extensionRange) { + message.extensionRange.push( + DescriptorProto_ExtensionRange.fromPartial(e) + ); + } + } + if (object.oneofDecl !== undefined && object.oneofDecl !== null) { + for (const e of object.oneofDecl) { + message.oneofDecl.push(OneofDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = MessageOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push( + DescriptorProto_ReservedRange.fromPartial(e) + ); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(e); + } + } + return message; + }, +}; + +const baseDescriptorProto_ExtensionRange: object = { start: 0, end: 0 }; + +export const DescriptorProto_ExtensionRange = { + encode( + message: DescriptorProto_ExtensionRange, + writer: Writer = Writer.create() + ): Writer { + if (message.start !== 0) { + writer.uint32(8).int32(message.start); + } + if (message.end !== 0) { + writer.uint32(16).int32(message.end); + } + if (message.options !== undefined) { + ExtensionRangeOptions.encode( + message.options, + writer.uint32(26).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): DescriptorProto_ExtensionRange { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseDescriptorProto_ExtensionRange, + } as DescriptorProto_ExtensionRange; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.start = reader.int32(); + break; + case 2: + message.end = reader.int32(); + break; + case 3: + message.options = ExtensionRangeOptions.decode( + reader, + reader.uint32() + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DescriptorProto_ExtensionRange { + const message = { + ...baseDescriptorProto_ExtensionRange, + } as DescriptorProto_ExtensionRange; + if (object.start !== undefined && object.start !== null) { + message.start = Number(object.start); + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = ExtensionRangeOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: DescriptorProto_ExtensionRange): unknown { + const obj: any = {}; + message.start !== undefined && (obj.start = message.start); + message.end !== undefined && (obj.end = message.end); + message.options !== undefined && + (obj.options = message.options + ? ExtensionRangeOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): DescriptorProto_ExtensionRange { + const message = { + ...baseDescriptorProto_ExtensionRange, + } as DescriptorProto_ExtensionRange; + if (object.start !== undefined && object.start !== null) { + message.start = object.start; + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = ExtensionRangeOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseDescriptorProto_ReservedRange: object = { start: 0, end: 0 }; + +export const DescriptorProto_ReservedRange = { + encode( + message: DescriptorProto_ReservedRange, + writer: Writer = Writer.create() + ): Writer { + if (message.start !== 0) { + writer.uint32(8).int32(message.start); + } + if (message.end !== 0) { + writer.uint32(16).int32(message.end); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): DescriptorProto_ReservedRange { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseDescriptorProto_ReservedRange, + } as DescriptorProto_ReservedRange; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.start = reader.int32(); + break; + case 2: + message.end = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DescriptorProto_ReservedRange { + const message = { + ...baseDescriptorProto_ReservedRange, + } as DescriptorProto_ReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = Number(object.start); + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + return message; + }, + + toJSON(message: DescriptorProto_ReservedRange): unknown { + const obj: any = {}; + message.start !== undefined && (obj.start = message.start); + message.end !== undefined && (obj.end = message.end); + return obj; + }, + + fromPartial( + object: DeepPartial + ): DescriptorProto_ReservedRange { + const message = { + ...baseDescriptorProto_ReservedRange, + } as DescriptorProto_ReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = object.start; + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + return message; + }, +}; + +const baseExtensionRangeOptions: object = {}; + +export const ExtensionRangeOptions = { + encode( + message: ExtensionRangeOptions, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ExtensionRangeOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseExtensionRangeOptions } as ExtensionRangeOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ExtensionRangeOptions { + const message = { ...baseExtensionRangeOptions } as ExtensionRangeOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: ExtensionRangeOptions): unknown { + const obj: any = {}; + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial( + object: DeepPartial + ): ExtensionRangeOptions { + const message = { ...baseExtensionRangeOptions } as ExtensionRangeOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseFieldDescriptorProto: object = { + name: "", + number: 0, + label: 1, + type: 1, + typeName: "", + extendee: "", + defaultValue: "", + oneofIndex: 0, + jsonName: "", + proto3Optional: false, +}; + +export const FieldDescriptorProto = { + encode( + message: FieldDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.number !== 0) { + writer.uint32(24).int32(message.number); + } + if (message.label !== 1) { + writer.uint32(32).int32(message.label); + } + if (message.type !== 1) { + writer.uint32(40).int32(message.type); + } + if (message.typeName !== "") { + writer.uint32(50).string(message.typeName); + } + if (message.extendee !== "") { + writer.uint32(18).string(message.extendee); + } + if (message.defaultValue !== "") { + writer.uint32(58).string(message.defaultValue); + } + if (message.oneofIndex !== 0) { + writer.uint32(72).int32(message.oneofIndex); + } + if (message.jsonName !== "") { + writer.uint32(82).string(message.jsonName); + } + if (message.options !== undefined) { + FieldOptions.encode(message.options, writer.uint32(66).fork()).ldelim(); + } + if (message.proto3Optional === true) { + writer.uint32(136).bool(message.proto3Optional); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FieldDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFieldDescriptorProto } as FieldDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 3: + message.number = reader.int32(); + break; + case 4: + message.label = reader.int32() as any; + break; + case 5: + message.type = reader.int32() as any; + break; + case 6: + message.typeName = reader.string(); + break; + case 2: + message.extendee = reader.string(); + break; + case 7: + message.defaultValue = reader.string(); + break; + case 9: + message.oneofIndex = reader.int32(); + break; + case 10: + message.jsonName = reader.string(); + break; + case 8: + message.options = FieldOptions.decode(reader, reader.uint32()); + break; + case 17: + message.proto3Optional = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FieldDescriptorProto { + const message = { ...baseFieldDescriptorProto } as FieldDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = Number(object.number); + } else { + message.number = 0; + } + if (object.label !== undefined && object.label !== null) { + message.label = fieldDescriptorProto_LabelFromJSON(object.label); + } else { + message.label = 1; + } + if (object.type !== undefined && object.type !== null) { + message.type = fieldDescriptorProto_TypeFromJSON(object.type); + } else { + message.type = 1; + } + if (object.typeName !== undefined && object.typeName !== null) { + message.typeName = String(object.typeName); + } else { + message.typeName = ""; + } + if (object.extendee !== undefined && object.extendee !== null) { + message.extendee = String(object.extendee); + } else { + message.extendee = ""; + } + if (object.defaultValue !== undefined && object.defaultValue !== null) { + message.defaultValue = String(object.defaultValue); + } else { + message.defaultValue = ""; + } + if (object.oneofIndex !== undefined && object.oneofIndex !== null) { + message.oneofIndex = Number(object.oneofIndex); + } else { + message.oneofIndex = 0; + } + if (object.jsonName !== undefined && object.jsonName !== null) { + message.jsonName = String(object.jsonName); + } else { + message.jsonName = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = FieldOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.proto3Optional !== undefined && object.proto3Optional !== null) { + message.proto3Optional = Boolean(object.proto3Optional); + } else { + message.proto3Optional = false; + } + return message; + }, + + toJSON(message: FieldDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.number !== undefined && (obj.number = message.number); + message.label !== undefined && + (obj.label = fieldDescriptorProto_LabelToJSON(message.label)); + message.type !== undefined && + (obj.type = fieldDescriptorProto_TypeToJSON(message.type)); + message.typeName !== undefined && (obj.typeName = message.typeName); + message.extendee !== undefined && (obj.extendee = message.extendee); + message.defaultValue !== undefined && + (obj.defaultValue = message.defaultValue); + message.oneofIndex !== undefined && (obj.oneofIndex = message.oneofIndex); + message.jsonName !== undefined && (obj.jsonName = message.jsonName); + message.options !== undefined && + (obj.options = message.options + ? FieldOptions.toJSON(message.options) + : undefined); + message.proto3Optional !== undefined && + (obj.proto3Optional = message.proto3Optional); + return obj; + }, + + fromPartial(object: DeepPartial): FieldDescriptorProto { + const message = { ...baseFieldDescriptorProto } as FieldDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = object.number; + } else { + message.number = 0; + } + if (object.label !== undefined && object.label !== null) { + message.label = object.label; + } else { + message.label = 1; + } + if (object.type !== undefined && object.type !== null) { + message.type = object.type; + } else { + message.type = 1; + } + if (object.typeName !== undefined && object.typeName !== null) { + message.typeName = object.typeName; + } else { + message.typeName = ""; + } + if (object.extendee !== undefined && object.extendee !== null) { + message.extendee = object.extendee; + } else { + message.extendee = ""; + } + if (object.defaultValue !== undefined && object.defaultValue !== null) { + message.defaultValue = object.defaultValue; + } else { + message.defaultValue = ""; + } + if (object.oneofIndex !== undefined && object.oneofIndex !== null) { + message.oneofIndex = object.oneofIndex; + } else { + message.oneofIndex = 0; + } + if (object.jsonName !== undefined && object.jsonName !== null) { + message.jsonName = object.jsonName; + } else { + message.jsonName = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = FieldOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.proto3Optional !== undefined && object.proto3Optional !== null) { + message.proto3Optional = object.proto3Optional; + } else { + message.proto3Optional = false; + } + return message; + }, +}; + +const baseOneofDescriptorProto: object = { name: "" }; + +export const OneofDescriptorProto = { + encode( + message: OneofDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.options !== undefined) { + OneofOptions.encode(message.options, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): OneofDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseOneofDescriptorProto } as OneofDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.options = OneofOptions.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): OneofDescriptorProto { + const message = { ...baseOneofDescriptorProto } as OneofDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = OneofOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: OneofDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.options !== undefined && + (obj.options = message.options + ? OneofOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): OneofDescriptorProto { + const message = { ...baseOneofDescriptorProto } as OneofDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = OneofOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseEnumDescriptorProto: object = { name: "", reservedName: "" }; + +export const EnumDescriptorProto = { + encode( + message: EnumDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + for (const v of message.value) { + EnumValueDescriptorProto.encode(v!, writer.uint32(18).fork()).ldelim(); + } + if (message.options !== undefined) { + EnumOptions.encode(message.options, writer.uint32(26).fork()).ldelim(); + } + for (const v of message.reservedRange) { + EnumDescriptorProto_EnumReservedRange.encode( + v!, + writer.uint32(34).fork() + ).ldelim(); + } + for (const v of message.reservedName) { + writer.uint32(42).string(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): EnumDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseEnumDescriptorProto } as EnumDescriptorProto; + message.value = []; + message.reservedRange = []; + message.reservedName = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.value.push( + EnumValueDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 3: + message.options = EnumOptions.decode(reader, reader.uint32()); + break; + case 4: + message.reservedRange.push( + EnumDescriptorProto_EnumReservedRange.decode( + reader, + reader.uint32() + ) + ); + break; + case 5: + message.reservedName.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumDescriptorProto { + const message = { ...baseEnumDescriptorProto } as EnumDescriptorProto; + message.value = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.value !== undefined && object.value !== null) { + for (const e of object.value) { + message.value.push(EnumValueDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push( + EnumDescriptorProto_EnumReservedRange.fromJSON(e) + ); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(String(e)); + } + } + return message; + }, + + toJSON(message: EnumDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + if (message.value) { + obj.value = message.value.map((e) => + e ? EnumValueDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.value = []; + } + message.options !== undefined && + (obj.options = message.options + ? EnumOptions.toJSON(message.options) + : undefined); + if (message.reservedRange) { + obj.reservedRange = message.reservedRange.map((e) => + e ? EnumDescriptorProto_EnumReservedRange.toJSON(e) : undefined + ); + } else { + obj.reservedRange = []; + } + if (message.reservedName) { + obj.reservedName = message.reservedName.map((e) => e); + } else { + obj.reservedName = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): EnumDescriptorProto { + const message = { ...baseEnumDescriptorProto } as EnumDescriptorProto; + message.value = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.value !== undefined && object.value !== null) { + for (const e of object.value) { + message.value.push(EnumValueDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push( + EnumDescriptorProto_EnumReservedRange.fromPartial(e) + ); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(e); + } + } + return message; + }, +}; + +const baseEnumDescriptorProto_EnumReservedRange: object = { start: 0, end: 0 }; + +export const EnumDescriptorProto_EnumReservedRange = { + encode( + message: EnumDescriptorProto_EnumReservedRange, + writer: Writer = Writer.create() + ): Writer { + if (message.start !== 0) { + writer.uint32(8).int32(message.start); + } + if (message.end !== 0) { + writer.uint32(16).int32(message.end); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): EnumDescriptorProto_EnumReservedRange { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseEnumDescriptorProto_EnumReservedRange, + } as EnumDescriptorProto_EnumReservedRange; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.start = reader.int32(); + break; + case 2: + message.end = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumDescriptorProto_EnumReservedRange { + const message = { + ...baseEnumDescriptorProto_EnumReservedRange, + } as EnumDescriptorProto_EnumReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = Number(object.start); + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + return message; + }, + + toJSON(message: EnumDescriptorProto_EnumReservedRange): unknown { + const obj: any = {}; + message.start !== undefined && (obj.start = message.start); + message.end !== undefined && (obj.end = message.end); + return obj; + }, + + fromPartial( + object: DeepPartial + ): EnumDescriptorProto_EnumReservedRange { + const message = { + ...baseEnumDescriptorProto_EnumReservedRange, + } as EnumDescriptorProto_EnumReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = object.start; + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + return message; + }, +}; + +const baseEnumValueDescriptorProto: object = { name: "", number: 0 }; + +export const EnumValueDescriptorProto = { + encode( + message: EnumValueDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.number !== 0) { + writer.uint32(16).int32(message.number); + } + if (message.options !== undefined) { + EnumValueOptions.encode( + message.options, + writer.uint32(26).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): EnumValueDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseEnumValueDescriptorProto, + } as EnumValueDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.number = reader.int32(); + break; + case 3: + message.options = EnumValueOptions.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumValueDescriptorProto { + const message = { + ...baseEnumValueDescriptorProto, + } as EnumValueDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = Number(object.number); + } else { + message.number = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumValueOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: EnumValueDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.number !== undefined && (obj.number = message.number); + message.options !== undefined && + (obj.options = message.options + ? EnumValueOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): EnumValueDescriptorProto { + const message = { + ...baseEnumValueDescriptorProto, + } as EnumValueDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = object.number; + } else { + message.number = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumValueOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseServiceDescriptorProto: object = { name: "" }; + +export const ServiceDescriptorProto = { + encode( + message: ServiceDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + for (const v of message.method) { + MethodDescriptorProto.encode(v!, writer.uint32(18).fork()).ldelim(); + } + if (message.options !== undefined) { + ServiceOptions.encode(message.options, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ServiceDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseServiceDescriptorProto } as ServiceDescriptorProto; + message.method = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.method.push( + MethodDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 3: + message.options = ServiceOptions.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ServiceDescriptorProto { + const message = { ...baseServiceDescriptorProto } as ServiceDescriptorProto; + message.method = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.method !== undefined && object.method !== null) { + for (const e of object.method) { + message.method.push(MethodDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = ServiceOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: ServiceDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + if (message.method) { + obj.method = message.method.map((e) => + e ? MethodDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.method = []; + } + message.options !== undefined && + (obj.options = message.options + ? ServiceOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): ServiceDescriptorProto { + const message = { ...baseServiceDescriptorProto } as ServiceDescriptorProto; + message.method = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.method !== undefined && object.method !== null) { + for (const e of object.method) { + message.method.push(MethodDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = ServiceOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseMethodDescriptorProto: object = { + name: "", + inputType: "", + outputType: "", + clientStreaming: false, + serverStreaming: false, +}; + +export const MethodDescriptorProto = { + encode( + message: MethodDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.inputType !== "") { + writer.uint32(18).string(message.inputType); + } + if (message.outputType !== "") { + writer.uint32(26).string(message.outputType); + } + if (message.options !== undefined) { + MethodOptions.encode(message.options, writer.uint32(34).fork()).ldelim(); + } + if (message.clientStreaming === true) { + writer.uint32(40).bool(message.clientStreaming); + } + if (message.serverStreaming === true) { + writer.uint32(48).bool(message.serverStreaming); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MethodDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMethodDescriptorProto } as MethodDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.inputType = reader.string(); + break; + case 3: + message.outputType = reader.string(); + break; + case 4: + message.options = MethodOptions.decode(reader, reader.uint32()); + break; + case 5: + message.clientStreaming = reader.bool(); + break; + case 6: + message.serverStreaming = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MethodDescriptorProto { + const message = { ...baseMethodDescriptorProto } as MethodDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.inputType !== undefined && object.inputType !== null) { + message.inputType = String(object.inputType); + } else { + message.inputType = ""; + } + if (object.outputType !== undefined && object.outputType !== null) { + message.outputType = String(object.outputType); + } else { + message.outputType = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = MethodOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if ( + object.clientStreaming !== undefined && + object.clientStreaming !== null + ) { + message.clientStreaming = Boolean(object.clientStreaming); + } else { + message.clientStreaming = false; + } + if ( + object.serverStreaming !== undefined && + object.serverStreaming !== null + ) { + message.serverStreaming = Boolean(object.serverStreaming); + } else { + message.serverStreaming = false; + } + return message; + }, + + toJSON(message: MethodDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.inputType !== undefined && (obj.inputType = message.inputType); + message.outputType !== undefined && (obj.outputType = message.outputType); + message.options !== undefined && + (obj.options = message.options + ? MethodOptions.toJSON(message.options) + : undefined); + message.clientStreaming !== undefined && + (obj.clientStreaming = message.clientStreaming); + message.serverStreaming !== undefined && + (obj.serverStreaming = message.serverStreaming); + return obj; + }, + + fromPartial( + object: DeepPartial + ): MethodDescriptorProto { + const message = { ...baseMethodDescriptorProto } as MethodDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.inputType !== undefined && object.inputType !== null) { + message.inputType = object.inputType; + } else { + message.inputType = ""; + } + if (object.outputType !== undefined && object.outputType !== null) { + message.outputType = object.outputType; + } else { + message.outputType = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = MethodOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if ( + object.clientStreaming !== undefined && + object.clientStreaming !== null + ) { + message.clientStreaming = object.clientStreaming; + } else { + message.clientStreaming = false; + } + if ( + object.serverStreaming !== undefined && + object.serverStreaming !== null + ) { + message.serverStreaming = object.serverStreaming; + } else { + message.serverStreaming = false; + } + return message; + }, +}; + +const baseFileOptions: object = { + javaPackage: "", + javaOuterClassname: "", + javaMultipleFiles: false, + javaGenerateEqualsAndHash: false, + javaStringCheckUtf8: false, + optimizeFor: 1, + goPackage: "", + ccGenericServices: false, + javaGenericServices: false, + pyGenericServices: false, + phpGenericServices: false, + deprecated: false, + ccEnableArenas: false, + objcClassPrefix: "", + csharpNamespace: "", + swiftPrefix: "", + phpClassPrefix: "", + phpNamespace: "", + phpMetadataNamespace: "", + rubyPackage: "", +}; + +export const FileOptions = { + encode(message: FileOptions, writer: Writer = Writer.create()): Writer { + if (message.javaPackage !== "") { + writer.uint32(10).string(message.javaPackage); + } + if (message.javaOuterClassname !== "") { + writer.uint32(66).string(message.javaOuterClassname); + } + if (message.javaMultipleFiles === true) { + writer.uint32(80).bool(message.javaMultipleFiles); + } + if (message.javaGenerateEqualsAndHash === true) { + writer.uint32(160).bool(message.javaGenerateEqualsAndHash); + } + if (message.javaStringCheckUtf8 === true) { + writer.uint32(216).bool(message.javaStringCheckUtf8); + } + if (message.optimizeFor !== 1) { + writer.uint32(72).int32(message.optimizeFor); + } + if (message.goPackage !== "") { + writer.uint32(90).string(message.goPackage); + } + if (message.ccGenericServices === true) { + writer.uint32(128).bool(message.ccGenericServices); + } + if (message.javaGenericServices === true) { + writer.uint32(136).bool(message.javaGenericServices); + } + if (message.pyGenericServices === true) { + writer.uint32(144).bool(message.pyGenericServices); + } + if (message.phpGenericServices === true) { + writer.uint32(336).bool(message.phpGenericServices); + } + if (message.deprecated === true) { + writer.uint32(184).bool(message.deprecated); + } + if (message.ccEnableArenas === true) { + writer.uint32(248).bool(message.ccEnableArenas); + } + if (message.objcClassPrefix !== "") { + writer.uint32(290).string(message.objcClassPrefix); + } + if (message.csharpNamespace !== "") { + writer.uint32(298).string(message.csharpNamespace); + } + if (message.swiftPrefix !== "") { + writer.uint32(314).string(message.swiftPrefix); + } + if (message.phpClassPrefix !== "") { + writer.uint32(322).string(message.phpClassPrefix); + } + if (message.phpNamespace !== "") { + writer.uint32(330).string(message.phpNamespace); + } + if (message.phpMetadataNamespace !== "") { + writer.uint32(354).string(message.phpMetadataNamespace); + } + if (message.rubyPackage !== "") { + writer.uint32(362).string(message.rubyPackage); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FileOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFileOptions } as FileOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.javaPackage = reader.string(); + break; + case 8: + message.javaOuterClassname = reader.string(); + break; + case 10: + message.javaMultipleFiles = reader.bool(); + break; + case 20: + message.javaGenerateEqualsAndHash = reader.bool(); + break; + case 27: + message.javaStringCheckUtf8 = reader.bool(); + break; + case 9: + message.optimizeFor = reader.int32() as any; + break; + case 11: + message.goPackage = reader.string(); + break; + case 16: + message.ccGenericServices = reader.bool(); + break; + case 17: + message.javaGenericServices = reader.bool(); + break; + case 18: + message.pyGenericServices = reader.bool(); + break; + case 42: + message.phpGenericServices = reader.bool(); + break; + case 23: + message.deprecated = reader.bool(); + break; + case 31: + message.ccEnableArenas = reader.bool(); + break; + case 36: + message.objcClassPrefix = reader.string(); + break; + case 37: + message.csharpNamespace = reader.string(); + break; + case 39: + message.swiftPrefix = reader.string(); + break; + case 40: + message.phpClassPrefix = reader.string(); + break; + case 41: + message.phpNamespace = reader.string(); + break; + case 44: + message.phpMetadataNamespace = reader.string(); + break; + case 45: + message.rubyPackage = reader.string(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FileOptions { + const message = { ...baseFileOptions } as FileOptions; + message.uninterpretedOption = []; + if (object.javaPackage !== undefined && object.javaPackage !== null) { + message.javaPackage = String(object.javaPackage); + } else { + message.javaPackage = ""; + } + if ( + object.javaOuterClassname !== undefined && + object.javaOuterClassname !== null + ) { + message.javaOuterClassname = String(object.javaOuterClassname); + } else { + message.javaOuterClassname = ""; + } + if ( + object.javaMultipleFiles !== undefined && + object.javaMultipleFiles !== null + ) { + message.javaMultipleFiles = Boolean(object.javaMultipleFiles); + } else { + message.javaMultipleFiles = false; + } + if ( + object.javaGenerateEqualsAndHash !== undefined && + object.javaGenerateEqualsAndHash !== null + ) { + message.javaGenerateEqualsAndHash = Boolean( + object.javaGenerateEqualsAndHash + ); + } else { + message.javaGenerateEqualsAndHash = false; + } + if ( + object.javaStringCheckUtf8 !== undefined && + object.javaStringCheckUtf8 !== null + ) { + message.javaStringCheckUtf8 = Boolean(object.javaStringCheckUtf8); + } else { + message.javaStringCheckUtf8 = false; + } + if (object.optimizeFor !== undefined && object.optimizeFor !== null) { + message.optimizeFor = fileOptions_OptimizeModeFromJSON( + object.optimizeFor + ); + } else { + message.optimizeFor = 1; + } + if (object.goPackage !== undefined && object.goPackage !== null) { + message.goPackage = String(object.goPackage); + } else { + message.goPackage = ""; + } + if ( + object.ccGenericServices !== undefined && + object.ccGenericServices !== null + ) { + message.ccGenericServices = Boolean(object.ccGenericServices); + } else { + message.ccGenericServices = false; + } + if ( + object.javaGenericServices !== undefined && + object.javaGenericServices !== null + ) { + message.javaGenericServices = Boolean(object.javaGenericServices); + } else { + message.javaGenericServices = false; + } + if ( + object.pyGenericServices !== undefined && + object.pyGenericServices !== null + ) { + message.pyGenericServices = Boolean(object.pyGenericServices); + } else { + message.pyGenericServices = false; + } + if ( + object.phpGenericServices !== undefined && + object.phpGenericServices !== null + ) { + message.phpGenericServices = Boolean(object.phpGenericServices); + } else { + message.phpGenericServices = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if (object.ccEnableArenas !== undefined && object.ccEnableArenas !== null) { + message.ccEnableArenas = Boolean(object.ccEnableArenas); + } else { + message.ccEnableArenas = false; + } + if ( + object.objcClassPrefix !== undefined && + object.objcClassPrefix !== null + ) { + message.objcClassPrefix = String(object.objcClassPrefix); + } else { + message.objcClassPrefix = ""; + } + if ( + object.csharpNamespace !== undefined && + object.csharpNamespace !== null + ) { + message.csharpNamespace = String(object.csharpNamespace); + } else { + message.csharpNamespace = ""; + } + if (object.swiftPrefix !== undefined && object.swiftPrefix !== null) { + message.swiftPrefix = String(object.swiftPrefix); + } else { + message.swiftPrefix = ""; + } + if (object.phpClassPrefix !== undefined && object.phpClassPrefix !== null) { + message.phpClassPrefix = String(object.phpClassPrefix); + } else { + message.phpClassPrefix = ""; + } + if (object.phpNamespace !== undefined && object.phpNamespace !== null) { + message.phpNamespace = String(object.phpNamespace); + } else { + message.phpNamespace = ""; + } + if ( + object.phpMetadataNamespace !== undefined && + object.phpMetadataNamespace !== null + ) { + message.phpMetadataNamespace = String(object.phpMetadataNamespace); + } else { + message.phpMetadataNamespace = ""; + } + if (object.rubyPackage !== undefined && object.rubyPackage !== null) { + message.rubyPackage = String(object.rubyPackage); + } else { + message.rubyPackage = ""; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: FileOptions): unknown { + const obj: any = {}; + message.javaPackage !== undefined && + (obj.javaPackage = message.javaPackage); + message.javaOuterClassname !== undefined && + (obj.javaOuterClassname = message.javaOuterClassname); + message.javaMultipleFiles !== undefined && + (obj.javaMultipleFiles = message.javaMultipleFiles); + message.javaGenerateEqualsAndHash !== undefined && + (obj.javaGenerateEqualsAndHash = message.javaGenerateEqualsAndHash); + message.javaStringCheckUtf8 !== undefined && + (obj.javaStringCheckUtf8 = message.javaStringCheckUtf8); + message.optimizeFor !== undefined && + (obj.optimizeFor = fileOptions_OptimizeModeToJSON(message.optimizeFor)); + message.goPackage !== undefined && (obj.goPackage = message.goPackage); + message.ccGenericServices !== undefined && + (obj.ccGenericServices = message.ccGenericServices); + message.javaGenericServices !== undefined && + (obj.javaGenericServices = message.javaGenericServices); + message.pyGenericServices !== undefined && + (obj.pyGenericServices = message.pyGenericServices); + message.phpGenericServices !== undefined && + (obj.phpGenericServices = message.phpGenericServices); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.ccEnableArenas !== undefined && + (obj.ccEnableArenas = message.ccEnableArenas); + message.objcClassPrefix !== undefined && + (obj.objcClassPrefix = message.objcClassPrefix); + message.csharpNamespace !== undefined && + (obj.csharpNamespace = message.csharpNamespace); + message.swiftPrefix !== undefined && + (obj.swiftPrefix = message.swiftPrefix); + message.phpClassPrefix !== undefined && + (obj.phpClassPrefix = message.phpClassPrefix); + message.phpNamespace !== undefined && + (obj.phpNamespace = message.phpNamespace); + message.phpMetadataNamespace !== undefined && + (obj.phpMetadataNamespace = message.phpMetadataNamespace); + message.rubyPackage !== undefined && + (obj.rubyPackage = message.rubyPackage); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): FileOptions { + const message = { ...baseFileOptions } as FileOptions; + message.uninterpretedOption = []; + if (object.javaPackage !== undefined && object.javaPackage !== null) { + message.javaPackage = object.javaPackage; + } else { + message.javaPackage = ""; + } + if ( + object.javaOuterClassname !== undefined && + object.javaOuterClassname !== null + ) { + message.javaOuterClassname = object.javaOuterClassname; + } else { + message.javaOuterClassname = ""; + } + if ( + object.javaMultipleFiles !== undefined && + object.javaMultipleFiles !== null + ) { + message.javaMultipleFiles = object.javaMultipleFiles; + } else { + message.javaMultipleFiles = false; + } + if ( + object.javaGenerateEqualsAndHash !== undefined && + object.javaGenerateEqualsAndHash !== null + ) { + message.javaGenerateEqualsAndHash = object.javaGenerateEqualsAndHash; + } else { + message.javaGenerateEqualsAndHash = false; + } + if ( + object.javaStringCheckUtf8 !== undefined && + object.javaStringCheckUtf8 !== null + ) { + message.javaStringCheckUtf8 = object.javaStringCheckUtf8; + } else { + message.javaStringCheckUtf8 = false; + } + if (object.optimizeFor !== undefined && object.optimizeFor !== null) { + message.optimizeFor = object.optimizeFor; + } else { + message.optimizeFor = 1; + } + if (object.goPackage !== undefined && object.goPackage !== null) { + message.goPackage = object.goPackage; + } else { + message.goPackage = ""; + } + if ( + object.ccGenericServices !== undefined && + object.ccGenericServices !== null + ) { + message.ccGenericServices = object.ccGenericServices; + } else { + message.ccGenericServices = false; + } + if ( + object.javaGenericServices !== undefined && + object.javaGenericServices !== null + ) { + message.javaGenericServices = object.javaGenericServices; + } else { + message.javaGenericServices = false; + } + if ( + object.pyGenericServices !== undefined && + object.pyGenericServices !== null + ) { + message.pyGenericServices = object.pyGenericServices; + } else { + message.pyGenericServices = false; + } + if ( + object.phpGenericServices !== undefined && + object.phpGenericServices !== null + ) { + message.phpGenericServices = object.phpGenericServices; + } else { + message.phpGenericServices = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if (object.ccEnableArenas !== undefined && object.ccEnableArenas !== null) { + message.ccEnableArenas = object.ccEnableArenas; + } else { + message.ccEnableArenas = false; + } + if ( + object.objcClassPrefix !== undefined && + object.objcClassPrefix !== null + ) { + message.objcClassPrefix = object.objcClassPrefix; + } else { + message.objcClassPrefix = ""; + } + if ( + object.csharpNamespace !== undefined && + object.csharpNamespace !== null + ) { + message.csharpNamespace = object.csharpNamespace; + } else { + message.csharpNamespace = ""; + } + if (object.swiftPrefix !== undefined && object.swiftPrefix !== null) { + message.swiftPrefix = object.swiftPrefix; + } else { + message.swiftPrefix = ""; + } + if (object.phpClassPrefix !== undefined && object.phpClassPrefix !== null) { + message.phpClassPrefix = object.phpClassPrefix; + } else { + message.phpClassPrefix = ""; + } + if (object.phpNamespace !== undefined && object.phpNamespace !== null) { + message.phpNamespace = object.phpNamespace; + } else { + message.phpNamespace = ""; + } + if ( + object.phpMetadataNamespace !== undefined && + object.phpMetadataNamespace !== null + ) { + message.phpMetadataNamespace = object.phpMetadataNamespace; + } else { + message.phpMetadataNamespace = ""; + } + if (object.rubyPackage !== undefined && object.rubyPackage !== null) { + message.rubyPackage = object.rubyPackage; + } else { + message.rubyPackage = ""; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseMessageOptions: object = { + messageSetWireFormat: false, + noStandardDescriptorAccessor: false, + deprecated: false, + mapEntry: false, +}; + +export const MessageOptions = { + encode(message: MessageOptions, writer: Writer = Writer.create()): Writer { + if (message.messageSetWireFormat === true) { + writer.uint32(8).bool(message.messageSetWireFormat); + } + if (message.noStandardDescriptorAccessor === true) { + writer.uint32(16).bool(message.noStandardDescriptorAccessor); + } + if (message.deprecated === true) { + writer.uint32(24).bool(message.deprecated); + } + if (message.mapEntry === true) { + writer.uint32(56).bool(message.mapEntry); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MessageOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMessageOptions } as MessageOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.messageSetWireFormat = reader.bool(); + break; + case 2: + message.noStandardDescriptorAccessor = reader.bool(); + break; + case 3: + message.deprecated = reader.bool(); + break; + case 7: + message.mapEntry = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MessageOptions { + const message = { ...baseMessageOptions } as MessageOptions; + message.uninterpretedOption = []; + if ( + object.messageSetWireFormat !== undefined && + object.messageSetWireFormat !== null + ) { + message.messageSetWireFormat = Boolean(object.messageSetWireFormat); + } else { + message.messageSetWireFormat = false; + } + if ( + object.noStandardDescriptorAccessor !== undefined && + object.noStandardDescriptorAccessor !== null + ) { + message.noStandardDescriptorAccessor = Boolean( + object.noStandardDescriptorAccessor + ); + } else { + message.noStandardDescriptorAccessor = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if (object.mapEntry !== undefined && object.mapEntry !== null) { + message.mapEntry = Boolean(object.mapEntry); + } else { + message.mapEntry = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: MessageOptions): unknown { + const obj: any = {}; + message.messageSetWireFormat !== undefined && + (obj.messageSetWireFormat = message.messageSetWireFormat); + message.noStandardDescriptorAccessor !== undefined && + (obj.noStandardDescriptorAccessor = message.noStandardDescriptorAccessor); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.mapEntry !== undefined && (obj.mapEntry = message.mapEntry); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): MessageOptions { + const message = { ...baseMessageOptions } as MessageOptions; + message.uninterpretedOption = []; + if ( + object.messageSetWireFormat !== undefined && + object.messageSetWireFormat !== null + ) { + message.messageSetWireFormat = object.messageSetWireFormat; + } else { + message.messageSetWireFormat = false; + } + if ( + object.noStandardDescriptorAccessor !== undefined && + object.noStandardDescriptorAccessor !== null + ) { + message.noStandardDescriptorAccessor = + object.noStandardDescriptorAccessor; + } else { + message.noStandardDescriptorAccessor = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if (object.mapEntry !== undefined && object.mapEntry !== null) { + message.mapEntry = object.mapEntry; + } else { + message.mapEntry = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseFieldOptions: object = { + ctype: 0, + packed: false, + jstype: 0, + lazy: false, + deprecated: false, + weak: false, +}; + +export const FieldOptions = { + encode(message: FieldOptions, writer: Writer = Writer.create()): Writer { + if (message.ctype !== 0) { + writer.uint32(8).int32(message.ctype); + } + if (message.packed === true) { + writer.uint32(16).bool(message.packed); + } + if (message.jstype !== 0) { + writer.uint32(48).int32(message.jstype); + } + if (message.lazy === true) { + writer.uint32(40).bool(message.lazy); + } + if (message.deprecated === true) { + writer.uint32(24).bool(message.deprecated); + } + if (message.weak === true) { + writer.uint32(80).bool(message.weak); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FieldOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFieldOptions } as FieldOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.ctype = reader.int32() as any; + break; + case 2: + message.packed = reader.bool(); + break; + case 6: + message.jstype = reader.int32() as any; + break; + case 5: + message.lazy = reader.bool(); + break; + case 3: + message.deprecated = reader.bool(); + break; + case 10: + message.weak = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FieldOptions { + const message = { ...baseFieldOptions } as FieldOptions; + message.uninterpretedOption = []; + if (object.ctype !== undefined && object.ctype !== null) { + message.ctype = fieldOptions_CTypeFromJSON(object.ctype); + } else { + message.ctype = 0; + } + if (object.packed !== undefined && object.packed !== null) { + message.packed = Boolean(object.packed); + } else { + message.packed = false; + } + if (object.jstype !== undefined && object.jstype !== null) { + message.jstype = fieldOptions_JSTypeFromJSON(object.jstype); + } else { + message.jstype = 0; + } + if (object.lazy !== undefined && object.lazy !== null) { + message.lazy = Boolean(object.lazy); + } else { + message.lazy = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if (object.weak !== undefined && object.weak !== null) { + message.weak = Boolean(object.weak); + } else { + message.weak = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: FieldOptions): unknown { + const obj: any = {}; + message.ctype !== undefined && + (obj.ctype = fieldOptions_CTypeToJSON(message.ctype)); + message.packed !== undefined && (obj.packed = message.packed); + message.jstype !== undefined && + (obj.jstype = fieldOptions_JSTypeToJSON(message.jstype)); + message.lazy !== undefined && (obj.lazy = message.lazy); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.weak !== undefined && (obj.weak = message.weak); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): FieldOptions { + const message = { ...baseFieldOptions } as FieldOptions; + message.uninterpretedOption = []; + if (object.ctype !== undefined && object.ctype !== null) { + message.ctype = object.ctype; + } else { + message.ctype = 0; + } + if (object.packed !== undefined && object.packed !== null) { + message.packed = object.packed; + } else { + message.packed = false; + } + if (object.jstype !== undefined && object.jstype !== null) { + message.jstype = object.jstype; + } else { + message.jstype = 0; + } + if (object.lazy !== undefined && object.lazy !== null) { + message.lazy = object.lazy; + } else { + message.lazy = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if (object.weak !== undefined && object.weak !== null) { + message.weak = object.weak; + } else { + message.weak = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseOneofOptions: object = {}; + +export const OneofOptions = { + encode(message: OneofOptions, writer: Writer = Writer.create()): Writer { + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): OneofOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseOneofOptions } as OneofOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): OneofOptions { + const message = { ...baseOneofOptions } as OneofOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: OneofOptions): unknown { + const obj: any = {}; + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): OneofOptions { + const message = { ...baseOneofOptions } as OneofOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseEnumOptions: object = { allowAlias: false, deprecated: false }; + +export const EnumOptions = { + encode(message: EnumOptions, writer: Writer = Writer.create()): Writer { + if (message.allowAlias === true) { + writer.uint32(16).bool(message.allowAlias); + } + if (message.deprecated === true) { + writer.uint32(24).bool(message.deprecated); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): EnumOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseEnumOptions } as EnumOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + message.allowAlias = reader.bool(); + break; + case 3: + message.deprecated = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumOptions { + const message = { ...baseEnumOptions } as EnumOptions; + message.uninterpretedOption = []; + if (object.allowAlias !== undefined && object.allowAlias !== null) { + message.allowAlias = Boolean(object.allowAlias); + } else { + message.allowAlias = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: EnumOptions): unknown { + const obj: any = {}; + message.allowAlias !== undefined && (obj.allowAlias = message.allowAlias); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): EnumOptions { + const message = { ...baseEnumOptions } as EnumOptions; + message.uninterpretedOption = []; + if (object.allowAlias !== undefined && object.allowAlias !== null) { + message.allowAlias = object.allowAlias; + } else { + message.allowAlias = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseEnumValueOptions: object = { deprecated: false }; + +export const EnumValueOptions = { + encode(message: EnumValueOptions, writer: Writer = Writer.create()): Writer { + if (message.deprecated === true) { + writer.uint32(8).bool(message.deprecated); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): EnumValueOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseEnumValueOptions } as EnumValueOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.deprecated = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumValueOptions { + const message = { ...baseEnumValueOptions } as EnumValueOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: EnumValueOptions): unknown { + const obj: any = {}; + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): EnumValueOptions { + const message = { ...baseEnumValueOptions } as EnumValueOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseServiceOptions: object = { deprecated: false }; + +export const ServiceOptions = { + encode(message: ServiceOptions, writer: Writer = Writer.create()): Writer { + if (message.deprecated === true) { + writer.uint32(264).bool(message.deprecated); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ServiceOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseServiceOptions } as ServiceOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 33: + message.deprecated = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ServiceOptions { + const message = { ...baseServiceOptions } as ServiceOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: ServiceOptions): unknown { + const obj: any = {}; + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): ServiceOptions { + const message = { ...baseServiceOptions } as ServiceOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseMethodOptions: object = { deprecated: false, idempotencyLevel: 0 }; + +export const MethodOptions = { + encode(message: MethodOptions, writer: Writer = Writer.create()): Writer { + if (message.deprecated === true) { + writer.uint32(264).bool(message.deprecated); + } + if (message.idempotencyLevel !== 0) { + writer.uint32(272).int32(message.idempotencyLevel); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MethodOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMethodOptions } as MethodOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 33: + message.deprecated = reader.bool(); + break; + case 34: + message.idempotencyLevel = reader.int32() as any; + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MethodOptions { + const message = { ...baseMethodOptions } as MethodOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.idempotencyLevel !== undefined && + object.idempotencyLevel !== null + ) { + message.idempotencyLevel = methodOptions_IdempotencyLevelFromJSON( + object.idempotencyLevel + ); + } else { + message.idempotencyLevel = 0; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: MethodOptions): unknown { + const obj: any = {}; + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.idempotencyLevel !== undefined && + (obj.idempotencyLevel = methodOptions_IdempotencyLevelToJSON( + message.idempotencyLevel + )); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): MethodOptions { + const message = { ...baseMethodOptions } as MethodOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.idempotencyLevel !== undefined && + object.idempotencyLevel !== null + ) { + message.idempotencyLevel = object.idempotencyLevel; + } else { + message.idempotencyLevel = 0; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseUninterpretedOption: object = { + identifierValue: "", + positiveIntValue: 0, + negativeIntValue: 0, + doubleValue: 0, + aggregateValue: "", +}; + +export const UninterpretedOption = { + encode( + message: UninterpretedOption, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.name) { + UninterpretedOption_NamePart.encode( + v!, + writer.uint32(18).fork() + ).ldelim(); + } + if (message.identifierValue !== "") { + writer.uint32(26).string(message.identifierValue); + } + if (message.positiveIntValue !== 0) { + writer.uint32(32).uint64(message.positiveIntValue); + } + if (message.negativeIntValue !== 0) { + writer.uint32(40).int64(message.negativeIntValue); + } + if (message.doubleValue !== 0) { + writer.uint32(49).double(message.doubleValue); + } + if (message.stringValue.length !== 0) { + writer.uint32(58).bytes(message.stringValue); + } + if (message.aggregateValue !== "") { + writer.uint32(66).string(message.aggregateValue); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): UninterpretedOption { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseUninterpretedOption } as UninterpretedOption; + message.name = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + message.name.push( + UninterpretedOption_NamePart.decode(reader, reader.uint32()) + ); + break; + case 3: + message.identifierValue = reader.string(); + break; + case 4: + message.positiveIntValue = longToNumber(reader.uint64() as Long); + break; + case 5: + message.negativeIntValue = longToNumber(reader.int64() as Long); + break; + case 6: + message.doubleValue = reader.double(); + break; + case 7: + message.stringValue = reader.bytes(); + break; + case 8: + message.aggregateValue = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): UninterpretedOption { + const message = { ...baseUninterpretedOption } as UninterpretedOption; + message.name = []; + if (object.name !== undefined && object.name !== null) { + for (const e of object.name) { + message.name.push(UninterpretedOption_NamePart.fromJSON(e)); + } + } + if ( + object.identifierValue !== undefined && + object.identifierValue !== null + ) { + message.identifierValue = String(object.identifierValue); + } else { + message.identifierValue = ""; + } + if ( + object.positiveIntValue !== undefined && + object.positiveIntValue !== null + ) { + message.positiveIntValue = Number(object.positiveIntValue); + } else { + message.positiveIntValue = 0; + } + if ( + object.negativeIntValue !== undefined && + object.negativeIntValue !== null + ) { + message.negativeIntValue = Number(object.negativeIntValue); + } else { + message.negativeIntValue = 0; + } + if (object.doubleValue !== undefined && object.doubleValue !== null) { + message.doubleValue = Number(object.doubleValue); + } else { + message.doubleValue = 0; + } + if (object.stringValue !== undefined && object.stringValue !== null) { + message.stringValue = bytesFromBase64(object.stringValue); + } + if (object.aggregateValue !== undefined && object.aggregateValue !== null) { + message.aggregateValue = String(object.aggregateValue); + } else { + message.aggregateValue = ""; + } + return message; + }, + + toJSON(message: UninterpretedOption): unknown { + const obj: any = {}; + if (message.name) { + obj.name = message.name.map((e) => + e ? UninterpretedOption_NamePart.toJSON(e) : undefined + ); + } else { + obj.name = []; + } + message.identifierValue !== undefined && + (obj.identifierValue = message.identifierValue); + message.positiveIntValue !== undefined && + (obj.positiveIntValue = message.positiveIntValue); + message.negativeIntValue !== undefined && + (obj.negativeIntValue = message.negativeIntValue); + message.doubleValue !== undefined && + (obj.doubleValue = message.doubleValue); + message.stringValue !== undefined && + (obj.stringValue = base64FromBytes( + message.stringValue !== undefined + ? message.stringValue + : new Uint8Array() + )); + message.aggregateValue !== undefined && + (obj.aggregateValue = message.aggregateValue); + return obj; + }, + + fromPartial(object: DeepPartial): UninterpretedOption { + const message = { ...baseUninterpretedOption } as UninterpretedOption; + message.name = []; + if (object.name !== undefined && object.name !== null) { + for (const e of object.name) { + message.name.push(UninterpretedOption_NamePart.fromPartial(e)); + } + } + if ( + object.identifierValue !== undefined && + object.identifierValue !== null + ) { + message.identifierValue = object.identifierValue; + } else { + message.identifierValue = ""; + } + if ( + object.positiveIntValue !== undefined && + object.positiveIntValue !== null + ) { + message.positiveIntValue = object.positiveIntValue; + } else { + message.positiveIntValue = 0; + } + if ( + object.negativeIntValue !== undefined && + object.negativeIntValue !== null + ) { + message.negativeIntValue = object.negativeIntValue; + } else { + message.negativeIntValue = 0; + } + if (object.doubleValue !== undefined && object.doubleValue !== null) { + message.doubleValue = object.doubleValue; + } else { + message.doubleValue = 0; + } + if (object.stringValue !== undefined && object.stringValue !== null) { + message.stringValue = object.stringValue; + } else { + message.stringValue = new Uint8Array(); + } + if (object.aggregateValue !== undefined && object.aggregateValue !== null) { + message.aggregateValue = object.aggregateValue; + } else { + message.aggregateValue = ""; + } + return message; + }, +}; + +const baseUninterpretedOption_NamePart: object = { + namePart: "", + isExtension: false, +}; + +export const UninterpretedOption_NamePart = { + encode( + message: UninterpretedOption_NamePart, + writer: Writer = Writer.create() + ): Writer { + if (message.namePart !== "") { + writer.uint32(10).string(message.namePart); + } + if (message.isExtension === true) { + writer.uint32(16).bool(message.isExtension); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): UninterpretedOption_NamePart { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseUninterpretedOption_NamePart, + } as UninterpretedOption_NamePart; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.namePart = reader.string(); + break; + case 2: + message.isExtension = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): UninterpretedOption_NamePart { + const message = { + ...baseUninterpretedOption_NamePart, + } as UninterpretedOption_NamePart; + if (object.namePart !== undefined && object.namePart !== null) { + message.namePart = String(object.namePart); + } else { + message.namePart = ""; + } + if (object.isExtension !== undefined && object.isExtension !== null) { + message.isExtension = Boolean(object.isExtension); + } else { + message.isExtension = false; + } + return message; + }, + + toJSON(message: UninterpretedOption_NamePart): unknown { + const obj: any = {}; + message.namePart !== undefined && (obj.namePart = message.namePart); + message.isExtension !== undefined && + (obj.isExtension = message.isExtension); + return obj; + }, + + fromPartial( + object: DeepPartial + ): UninterpretedOption_NamePart { + const message = { + ...baseUninterpretedOption_NamePart, + } as UninterpretedOption_NamePart; + if (object.namePart !== undefined && object.namePart !== null) { + message.namePart = object.namePart; + } else { + message.namePart = ""; + } + if (object.isExtension !== undefined && object.isExtension !== null) { + message.isExtension = object.isExtension; + } else { + message.isExtension = false; + } + return message; + }, +}; + +const baseSourceCodeInfo: object = {}; + +export const SourceCodeInfo = { + encode(message: SourceCodeInfo, writer: Writer = Writer.create()): Writer { + for (const v of message.location) { + SourceCodeInfo_Location.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): SourceCodeInfo { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseSourceCodeInfo } as SourceCodeInfo; + message.location = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.location.push( + SourceCodeInfo_Location.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): SourceCodeInfo { + const message = { ...baseSourceCodeInfo } as SourceCodeInfo; + message.location = []; + if (object.location !== undefined && object.location !== null) { + for (const e of object.location) { + message.location.push(SourceCodeInfo_Location.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: SourceCodeInfo): unknown { + const obj: any = {}; + if (message.location) { + obj.location = message.location.map((e) => + e ? SourceCodeInfo_Location.toJSON(e) : undefined + ); + } else { + obj.location = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): SourceCodeInfo { + const message = { ...baseSourceCodeInfo } as SourceCodeInfo; + message.location = []; + if (object.location !== undefined && object.location !== null) { + for (const e of object.location) { + message.location.push(SourceCodeInfo_Location.fromPartial(e)); + } + } + return message; + }, +}; + +const baseSourceCodeInfo_Location: object = { + path: 0, + span: 0, + leadingComments: "", + trailingComments: "", + leadingDetachedComments: "", +}; + +export const SourceCodeInfo_Location = { + encode( + message: SourceCodeInfo_Location, + writer: Writer = Writer.create() + ): Writer { + writer.uint32(10).fork(); + for (const v of message.path) { + writer.int32(v); + } + writer.ldelim(); + writer.uint32(18).fork(); + for (const v of message.span) { + writer.int32(v); + } + writer.ldelim(); + if (message.leadingComments !== "") { + writer.uint32(26).string(message.leadingComments); + } + if (message.trailingComments !== "") { + writer.uint32(34).string(message.trailingComments); + } + for (const v of message.leadingDetachedComments) { + writer.uint32(50).string(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): SourceCodeInfo_Location { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseSourceCodeInfo_Location, + } as SourceCodeInfo_Location; + message.path = []; + message.span = []; + message.leadingDetachedComments = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.path.push(reader.int32()); + } + } else { + message.path.push(reader.int32()); + } + break; + case 2: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.span.push(reader.int32()); + } + } else { + message.span.push(reader.int32()); + } + break; + case 3: + message.leadingComments = reader.string(); + break; + case 4: + message.trailingComments = reader.string(); + break; + case 6: + message.leadingDetachedComments.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): SourceCodeInfo_Location { + const message = { + ...baseSourceCodeInfo_Location, + } as SourceCodeInfo_Location; + message.path = []; + message.span = []; + message.leadingDetachedComments = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(Number(e)); + } + } + if (object.span !== undefined && object.span !== null) { + for (const e of object.span) { + message.span.push(Number(e)); + } + } + if ( + object.leadingComments !== undefined && + object.leadingComments !== null + ) { + message.leadingComments = String(object.leadingComments); + } else { + message.leadingComments = ""; + } + if ( + object.trailingComments !== undefined && + object.trailingComments !== null + ) { + message.trailingComments = String(object.trailingComments); + } else { + message.trailingComments = ""; + } + if ( + object.leadingDetachedComments !== undefined && + object.leadingDetachedComments !== null + ) { + for (const e of object.leadingDetachedComments) { + message.leadingDetachedComments.push(String(e)); + } + } + return message; + }, + + toJSON(message: SourceCodeInfo_Location): unknown { + const obj: any = {}; + if (message.path) { + obj.path = message.path.map((e) => e); + } else { + obj.path = []; + } + if (message.span) { + obj.span = message.span.map((e) => e); + } else { + obj.span = []; + } + message.leadingComments !== undefined && + (obj.leadingComments = message.leadingComments); + message.trailingComments !== undefined && + (obj.trailingComments = message.trailingComments); + if (message.leadingDetachedComments) { + obj.leadingDetachedComments = message.leadingDetachedComments.map( + (e) => e + ); + } else { + obj.leadingDetachedComments = []; + } + return obj; + }, + + fromPartial( + object: DeepPartial + ): SourceCodeInfo_Location { + const message = { + ...baseSourceCodeInfo_Location, + } as SourceCodeInfo_Location; + message.path = []; + message.span = []; + message.leadingDetachedComments = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(e); + } + } + if (object.span !== undefined && object.span !== null) { + for (const e of object.span) { + message.span.push(e); + } + } + if ( + object.leadingComments !== undefined && + object.leadingComments !== null + ) { + message.leadingComments = object.leadingComments; + } else { + message.leadingComments = ""; + } + if ( + object.trailingComments !== undefined && + object.trailingComments !== null + ) { + message.trailingComments = object.trailingComments; + } else { + message.trailingComments = ""; + } + if ( + object.leadingDetachedComments !== undefined && + object.leadingDetachedComments !== null + ) { + for (const e of object.leadingDetachedComments) { + message.leadingDetachedComments.push(e); + } + } + return message; + }, +}; + +const baseGeneratedCodeInfo: object = {}; + +export const GeneratedCodeInfo = { + encode(message: GeneratedCodeInfo, writer: Writer = Writer.create()): Writer { + for (const v of message.annotation) { + GeneratedCodeInfo_Annotation.encode( + v!, + writer.uint32(10).fork() + ).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): GeneratedCodeInfo { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseGeneratedCodeInfo } as GeneratedCodeInfo; + message.annotation = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.annotation.push( + GeneratedCodeInfo_Annotation.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GeneratedCodeInfo { + const message = { ...baseGeneratedCodeInfo } as GeneratedCodeInfo; + message.annotation = []; + if (object.annotation !== undefined && object.annotation !== null) { + for (const e of object.annotation) { + message.annotation.push(GeneratedCodeInfo_Annotation.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: GeneratedCodeInfo): unknown { + const obj: any = {}; + if (message.annotation) { + obj.annotation = message.annotation.map((e) => + e ? GeneratedCodeInfo_Annotation.toJSON(e) : undefined + ); + } else { + obj.annotation = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): GeneratedCodeInfo { + const message = { ...baseGeneratedCodeInfo } as GeneratedCodeInfo; + message.annotation = []; + if (object.annotation !== undefined && object.annotation !== null) { + for (const e of object.annotation) { + message.annotation.push(GeneratedCodeInfo_Annotation.fromPartial(e)); + } + } + return message; + }, +}; + +const baseGeneratedCodeInfo_Annotation: object = { + path: 0, + sourceFile: "", + begin: 0, + end: 0, +}; + +export const GeneratedCodeInfo_Annotation = { + encode( + message: GeneratedCodeInfo_Annotation, + writer: Writer = Writer.create() + ): Writer { + writer.uint32(10).fork(); + for (const v of message.path) { + writer.int32(v); + } + writer.ldelim(); + if (message.sourceFile !== "") { + writer.uint32(18).string(message.sourceFile); + } + if (message.begin !== 0) { + writer.uint32(24).int32(message.begin); + } + if (message.end !== 0) { + writer.uint32(32).int32(message.end); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): GeneratedCodeInfo_Annotation { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseGeneratedCodeInfo_Annotation, + } as GeneratedCodeInfo_Annotation; + message.path = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.path.push(reader.int32()); + } + } else { + message.path.push(reader.int32()); + } + break; + case 2: + message.sourceFile = reader.string(); + break; + case 3: + message.begin = reader.int32(); + break; + case 4: + message.end = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GeneratedCodeInfo_Annotation { + const message = { + ...baseGeneratedCodeInfo_Annotation, + } as GeneratedCodeInfo_Annotation; + message.path = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(Number(e)); + } + } + if (object.sourceFile !== undefined && object.sourceFile !== null) { + message.sourceFile = String(object.sourceFile); + } else { + message.sourceFile = ""; + } + if (object.begin !== undefined && object.begin !== null) { + message.begin = Number(object.begin); + } else { + message.begin = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + return message; + }, + + toJSON(message: GeneratedCodeInfo_Annotation): unknown { + const obj: any = {}; + if (message.path) { + obj.path = message.path.map((e) => e); + } else { + obj.path = []; + } + message.sourceFile !== undefined && (obj.sourceFile = message.sourceFile); + message.begin !== undefined && (obj.begin = message.begin); + message.end !== undefined && (obj.end = message.end); + return obj; + }, + + fromPartial( + object: DeepPartial + ): GeneratedCodeInfo_Annotation { + const message = { + ...baseGeneratedCodeInfo_Annotation, + } as GeneratedCodeInfo_Annotation; + message.path = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(e); + } + } + if (object.sourceFile !== undefined && object.sourceFile !== null) { + message.sourceFile = object.sourceFile; + } else { + message.sourceFile = ""; + } + if (object.begin !== undefined && object.begin !== null) { + message.begin = object.begin; + } else { + message.begin = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/cosmos.gov.v1beta1/types/google/protobuf/duration.ts b/ts-client/cosmos.gov.v1beta1/types/google/protobuf/duration.ts new file mode 100644 index 00000000..fffd5b14 --- /dev/null +++ b/ts-client/cosmos.gov.v1beta1/types/google/protobuf/duration.ts @@ -0,0 +1,188 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "google.protobuf"; + +/** + * A Duration represents a signed, fixed-length span of time represented + * as a count of seconds and fractions of seconds at nanosecond + * resolution. It is independent of any calendar and concepts like "day" + * or "month". It is related to Timestamp in that the difference between + * two Timestamp values is a Duration and it can be added or subtracted + * from a Timestamp. Range is approximately +-10,000 years. + * + * # Examples + * + * Example 1: Compute Duration from two Timestamps in pseudo code. + * + * Timestamp start = ...; + * Timestamp end = ...; + * Duration duration = ...; + * + * duration.seconds = end.seconds - start.seconds; + * duration.nanos = end.nanos - start.nanos; + * + * if (duration.seconds < 0 && duration.nanos > 0) { + * duration.seconds += 1; + * duration.nanos -= 1000000000; + * } else if (duration.seconds > 0 && duration.nanos < 0) { + * duration.seconds -= 1; + * duration.nanos += 1000000000; + * } + * + * Example 2: Compute Timestamp from Timestamp + Duration in pseudo code. + * + * Timestamp start = ...; + * Duration duration = ...; + * Timestamp end = ...; + * + * end.seconds = start.seconds + duration.seconds; + * end.nanos = start.nanos + duration.nanos; + * + * if (end.nanos < 0) { + * end.seconds -= 1; + * end.nanos += 1000000000; + * } else if (end.nanos >= 1000000000) { + * end.seconds += 1; + * end.nanos -= 1000000000; + * } + * + * Example 3: Compute Duration from datetime.timedelta in Python. + * + * td = datetime.timedelta(days=3, minutes=10) + * duration = Duration() + * duration.FromTimedelta(td) + * + * # JSON Mapping + * + * In JSON format, the Duration type is encoded as a string rather than an + * object, where the string ends in the suffix "s" (indicating seconds) and + * is preceded by the number of seconds, with nanoseconds expressed as + * fractional seconds. For example, 3 seconds with 0 nanoseconds should be + * encoded in JSON format as "3s", while 3 seconds and 1 nanosecond should + * be expressed in JSON format as "3.000000001s", and 3 seconds and 1 + * microsecond should be expressed in JSON format as "3.000001s". + */ +export interface Duration { + /** + * Signed seconds of the span of time. Must be from -315,576,000,000 + * to +315,576,000,000 inclusive. Note: these bounds are computed from: + * 60 sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years + */ + seconds: number; + /** + * Signed fractions of a second at nanosecond resolution of the span + * of time. Durations less than one second are represented with a 0 + * `seconds` field and a positive or negative `nanos` field. For durations + * of one second or more, a non-zero value for the `nanos` field must be + * of the same sign as the `seconds` field. Must be from -999,999,999 + * to +999,999,999 inclusive. + */ + nanos: number; +} + +const baseDuration: object = { seconds: 0, nanos: 0 }; + +export const Duration = { + encode(message: Duration, writer: Writer = Writer.create()): Writer { + if (message.seconds !== 0) { + writer.uint32(8).int64(message.seconds); + } + if (message.nanos !== 0) { + writer.uint32(16).int32(message.nanos); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Duration { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseDuration } as Duration; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.seconds = longToNumber(reader.int64() as Long); + break; + case 2: + message.nanos = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Duration { + const message = { ...baseDuration } as Duration; + if (object.seconds !== undefined && object.seconds !== null) { + message.seconds = Number(object.seconds); + } else { + message.seconds = 0; + } + if (object.nanos !== undefined && object.nanos !== null) { + message.nanos = Number(object.nanos); + } else { + message.nanos = 0; + } + return message; + }, + + toJSON(message: Duration): unknown { + const obj: any = {}; + message.seconds !== undefined && (obj.seconds = message.seconds); + message.nanos !== undefined && (obj.nanos = message.nanos); + return obj; + }, + + fromPartial(object: DeepPartial): Duration { + const message = { ...baseDuration } as Duration; + if (object.seconds !== undefined && object.seconds !== null) { + message.seconds = object.seconds; + } else { + message.seconds = 0; + } + if (object.nanos !== undefined && object.nanos !== null) { + message.nanos = object.nanos; + } else { + message.nanos = 0; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/cosmos.gov.v1beta1/types/google/protobuf/timestamp.ts b/ts-client/cosmos.gov.v1beta1/types/google/protobuf/timestamp.ts new file mode 100644 index 00000000..11864afc --- /dev/null +++ b/ts-client/cosmos.gov.v1beta1/types/google/protobuf/timestamp.ts @@ -0,0 +1,219 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "google.protobuf"; + +/** + * A Timestamp represents a point in time independent of any time zone or local + * calendar, encoded as a count of seconds and fractions of seconds at + * nanosecond resolution. The count is relative to an epoch at UTC midnight on + * January 1, 1970, in the proleptic Gregorian calendar which extends the + * Gregorian calendar backwards to year one. + * + * All minutes are 60 seconds long. Leap seconds are "smeared" so that no leap + * second table is needed for interpretation, using a [24-hour linear + * smear](https://developers.google.com/time/smear). + * + * The range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. By + * restricting to that range, we ensure that we can convert to and from [RFC + * 3339](https://www.ietf.org/rfc/rfc3339.txt) date strings. + * + * # Examples + * + * Example 1: Compute Timestamp from POSIX `time()`. + * + * Timestamp timestamp; + * timestamp.set_seconds(time(NULL)); + * timestamp.set_nanos(0); + * + * Example 2: Compute Timestamp from POSIX `gettimeofday()`. + * + * struct timeval tv; + * gettimeofday(&tv, NULL); + * + * Timestamp timestamp; + * timestamp.set_seconds(tv.tv_sec); + * timestamp.set_nanos(tv.tv_usec * 1000); + * + * Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`. + * + * FILETIME ft; + * GetSystemTimeAsFileTime(&ft); + * UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime; + * + * // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z + * // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z. + * Timestamp timestamp; + * timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL)); + * timestamp.set_nanos((INT32) ((ticks % 10000000) * 100)); + * + * Example 4: Compute Timestamp from Java `System.currentTimeMillis()`. + * + * long millis = System.currentTimeMillis(); + * + * Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000) + * .setNanos((int) ((millis % 1000) * 1000000)).build(); + * + * + * Example 5: Compute Timestamp from Java `Instant.now()`. + * + * Instant now = Instant.now(); + * + * Timestamp timestamp = + * Timestamp.newBuilder().setSeconds(now.getEpochSecond()) + * .setNanos(now.getNano()).build(); + * + * + * Example 6: Compute Timestamp from current time in Python. + * + * timestamp = Timestamp() + * timestamp.GetCurrentTime() + * + * # JSON Mapping + * + * In JSON format, the Timestamp type is encoded as a string in the + * [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the + * format is "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z" + * where {year} is always expressed using four digits while {month}, {day}, + * {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional + * seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution), + * are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone + * is required. A proto3 JSON serializer should always use UTC (as indicated by + * "Z") when printing the Timestamp type and a proto3 JSON parser should be + * able to accept both UTC and other timezones (as indicated by an offset). + * + * For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past + * 01:30 UTC on January 15, 2017. + * + * In JavaScript, one can convert a Date object to this format using the + * standard + * [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString) + * method. In Python, a standard `datetime.datetime` object can be converted + * to this format using + * [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) with + * the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one can use + * the Joda Time's [`ISODateTimeFormat.dateTime()`]( + * http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime%2D%2D + * ) to obtain a formatter capable of generating timestamps in this format. + */ +export interface Timestamp { + /** + * Represents seconds of UTC time since Unix epoch + * 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to + * 9999-12-31T23:59:59Z inclusive. + */ + seconds: number; + /** + * Non-negative fractions of a second at nanosecond resolution. Negative + * second values with fractions must still have non-negative nanos values + * that count forward in time. Must be from 0 to 999,999,999 + * inclusive. + */ + nanos: number; +} + +const baseTimestamp: object = { seconds: 0, nanos: 0 }; + +export const Timestamp = { + encode(message: Timestamp, writer: Writer = Writer.create()): Writer { + if (message.seconds !== 0) { + writer.uint32(8).int64(message.seconds); + } + if (message.nanos !== 0) { + writer.uint32(16).int32(message.nanos); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Timestamp { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseTimestamp } as Timestamp; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.seconds = longToNumber(reader.int64() as Long); + break; + case 2: + message.nanos = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Timestamp { + const message = { ...baseTimestamp } as Timestamp; + if (object.seconds !== undefined && object.seconds !== null) { + message.seconds = Number(object.seconds); + } else { + message.seconds = 0; + } + if (object.nanos !== undefined && object.nanos !== null) { + message.nanos = Number(object.nanos); + } else { + message.nanos = 0; + } + return message; + }, + + toJSON(message: Timestamp): unknown { + const obj: any = {}; + message.seconds !== undefined && (obj.seconds = message.seconds); + message.nanos !== undefined && (obj.nanos = message.nanos); + return obj; + }, + + fromPartial(object: DeepPartial): Timestamp { + const message = { ...baseTimestamp } as Timestamp; + if (object.seconds !== undefined && object.seconds !== null) { + message.seconds = object.seconds; + } else { + message.seconds = 0; + } + if (object.nanos !== undefined && object.nanos !== null) { + message.nanos = object.nanos; + } else { + message.nanos = 0; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/cosmos.mint.v1beta1/index.ts b/ts-client/cosmos.mint.v1beta1/index.ts new file mode 100755 index 00000000..c9dfa159 --- /dev/null +++ b/ts-client/cosmos.mint.v1beta1/index.ts @@ -0,0 +1,6 @@ +import Module from './module'; +import { txClient, queryClient, registry } from './module'; +import { msgTypes } from './registry'; + +export * from "./types"; +export { Module, msgTypes, txClient, queryClient, registry }; diff --git a/ts-client/cosmos.mint.v1beta1/module.ts b/ts-client/cosmos.mint.v1beta1/module.ts new file mode 100755 index 00000000..b3917731 --- /dev/null +++ b/ts-client/cosmos.mint.v1beta1/module.ts @@ -0,0 +1,66 @@ +// Generated by Ignite ignite.com/cli + +import { StdFee } from "@cosmjs/launchpad"; +import { SigningStargateClient, DeliverTxResponse } from "@cosmjs/stargate"; +import { EncodeObject, GeneratedType, OfflineSigner, Registry } from "@cosmjs/proto-signing"; +import { msgTypes } from './registry'; +import { IgniteClient } from "../client" +import { MissingWalletError } from "../helpers" +import { Api } from "./rest"; + + +export { }; + + + +export const registry = new Registry(msgTypes); + +const defaultFee = { + amount: [], + gas: "200000", +}; + +interface TxClientOptions { + addr: string + prefix: string + signer?: OfflineSigner +} + +export const txClient = ({ signer, prefix, addr }: TxClientOptions = { addr: "http://localhost:26657", prefix: "cosmos" }) => { + + return { + + + } +}; + +interface QueryClientOptions { + addr: string +} + +export const queryClient = ({ addr: addr }: QueryClientOptions = { addr: "http://localhost:1317" }) => { + return new Api({ baseUrl: addr }); +}; + +class SDKModule { + public query: ReturnType; + public tx: ReturnType; + + public registry: Array<[string, GeneratedType]>; + + constructor(client: IgniteClient) { + + this.query = queryClient({ addr: client.env.apiURL }); + this.tx = txClient({ signer: client.signer, addr: client.env.rpcURL, prefix: client.env.prefix ?? "cosmos" }); + } +}; + +const Module = (test: IgniteClient) => { + return { + module: { + CosmosMintV1Beta1: new SDKModule(test) + }, + registry: msgTypes + } +} +export default Module; \ No newline at end of file diff --git a/ts-client/cosmos.mint.v1beta1/registry.ts b/ts-client/cosmos.mint.v1beta1/registry.ts new file mode 100755 index 00000000..26157e4f --- /dev/null +++ b/ts-client/cosmos.mint.v1beta1/registry.ts @@ -0,0 +1,7 @@ +import { GeneratedType } from "@cosmjs/proto-signing"; + +const msgTypes: Array<[string, GeneratedType]> = [ + +]; + +export { msgTypes } \ No newline at end of file diff --git a/ts-client/cosmos.mint.v1beta1/rest.ts b/ts-client/cosmos.mint.v1beta1/rest.ts new file mode 100644 index 00000000..57a65fdd --- /dev/null +++ b/ts-client/cosmos.mint.v1beta1/rest.ts @@ -0,0 +1,312 @@ +/* eslint-disable */ +/* tslint:disable */ +/* + * --------------------------------------------------------------- + * ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ## + * ## ## + * ## AUTHOR: acacode ## + * ## SOURCE: https://github.com/acacode/swagger-typescript-api ## + * --------------------------------------------------------------- + */ + +/** + * Params holds parameters for the mint module. + */ +export interface Mintv1Beta1Params { + mint_denom?: string; + inflation_rate_change?: string; + inflation_max?: string; + inflation_min?: string; + goal_bonded?: string; + + /** @format uint64 */ + blocks_per_year?: string; +} + +export interface ProtobufAny { + "@type"?: string; +} + +export interface RpcStatus { + /** @format int32 */ + code?: number; + message?: string; + details?: ProtobufAny[]; +} + +/** +* QueryAnnualProvisionsResponse is the response type for the +Query/AnnualProvisions RPC method. +*/ +export interface V1Beta1QueryAnnualProvisionsResponse { + /** + * annual_provisions is the current minting annual provisions value. + * @format byte + */ + annual_provisions?: string; +} + +/** +* QueryInflationResponse is the response type for the Query/Inflation RPC +method. +*/ +export interface V1Beta1QueryInflationResponse { + /** + * inflation is the current minting inflation value. + * @format byte + */ + inflation?: string; +} + +/** + * QueryParamsResponse is the response type for the Query/Params RPC method. + */ +export interface V1Beta1QueryParamsResponse { + /** params defines the parameters of the module. */ + params?: Mintv1Beta1Params; +} + +export type QueryParamsType = Record; +export type ResponseFormat = keyof Omit; + +export interface FullRequestParams extends Omit { + /** set parameter to `true` for call `securityWorker` for this request */ + secure?: boolean; + /** request path */ + path: string; + /** content type of request body */ + type?: ContentType; + /** query params */ + query?: QueryParamsType; + /** format of response (i.e. response.json() -> format: "json") */ + format?: keyof Omit; + /** request body */ + body?: unknown; + /** base url */ + baseUrl?: string; + /** request cancellation token */ + cancelToken?: CancelToken; +} + +export type RequestParams = Omit; + +export interface ApiConfig { + baseUrl?: string; + baseApiParams?: Omit; + securityWorker?: (securityData: SecurityDataType) => RequestParams | void; +} + +export interface HttpResponse extends Response { + data: D; + error: E; +} + +type CancelToken = Symbol | string | number; + +export enum ContentType { + Json = "application/json", + FormData = "multipart/form-data", + UrlEncoded = "application/x-www-form-urlencoded", +} + +export class HttpClient { + public baseUrl: string = ""; + private securityData: SecurityDataType = null as any; + private securityWorker: null | ApiConfig["securityWorker"] = null; + private abortControllers = new Map(); + + private baseApiParams: RequestParams = { + credentials: "same-origin", + headers: {}, + redirect: "follow", + referrerPolicy: "no-referrer", + }; + + constructor(apiConfig: ApiConfig = {}) { + Object.assign(this, apiConfig); + } + + public setSecurityData = (data: SecurityDataType) => { + this.securityData = data; + }; + + private addQueryParam(query: QueryParamsType, key: string) { + const value = query[key]; + + return ( + encodeURIComponent(key) + + "=" + + encodeURIComponent(Array.isArray(value) ? value.join(",") : typeof value === "number" ? value : `${value}`) + ); + } + + protected toQueryString(rawQuery?: QueryParamsType): string { + const query = rawQuery || {}; + const keys = Object.keys(query).filter((key) => "undefined" !== typeof query[key]); + return keys + .map((key) => + typeof query[key] === "object" && !Array.isArray(query[key]) + ? this.toQueryString(query[key] as QueryParamsType) + : this.addQueryParam(query, key), + ) + .join("&"); + } + + protected addQueryParams(rawQuery?: QueryParamsType): string { + const queryString = this.toQueryString(rawQuery); + return queryString ? `?${queryString}` : ""; + } + + private contentFormatters: Record any> = { + [ContentType.Json]: (input: any) => + input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input, + [ContentType.FormData]: (input: any) => + Object.keys(input || {}).reduce((data, key) => { + data.append(key, input[key]); + return data; + }, new FormData()), + [ContentType.UrlEncoded]: (input: any) => this.toQueryString(input), + }; + + private mergeRequestParams(params1: RequestParams, params2?: RequestParams): RequestParams { + return { + ...this.baseApiParams, + ...params1, + ...(params2 || {}), + headers: { + ...(this.baseApiParams.headers || {}), + ...(params1.headers || {}), + ...((params2 && params2.headers) || {}), + }, + }; + } + + private createAbortSignal = (cancelToken: CancelToken): AbortSignal | undefined => { + if (this.abortControllers.has(cancelToken)) { + const abortController = this.abortControllers.get(cancelToken); + if (abortController) { + return abortController.signal; + } + return void 0; + } + + const abortController = new AbortController(); + this.abortControllers.set(cancelToken, abortController); + return abortController.signal; + }; + + public abortRequest = (cancelToken: CancelToken) => { + const abortController = this.abortControllers.get(cancelToken); + + if (abortController) { + abortController.abort(); + this.abortControllers.delete(cancelToken); + } + }; + + public request = ({ + body, + secure, + path, + type, + query, + format = "json", + baseUrl, + cancelToken, + ...params + }: FullRequestParams): Promise> => { + const secureParams = (secure && this.securityWorker && this.securityWorker(this.securityData)) || {}; + const requestParams = this.mergeRequestParams(params, secureParams); + const queryString = query && this.toQueryString(query); + const payloadFormatter = this.contentFormatters[type || ContentType.Json]; + + return fetch(`${baseUrl || this.baseUrl || ""}${path}${queryString ? `?${queryString}` : ""}`, { + ...requestParams, + headers: { + ...(type && type !== ContentType.FormData ? { "Content-Type": type } : {}), + ...(requestParams.headers || {}), + }, + signal: cancelToken ? this.createAbortSignal(cancelToken) : void 0, + body: typeof body === "undefined" || body === null ? null : payloadFormatter(body), + }).then(async (response) => { + const r = response as HttpResponse; + r.data = (null as unknown) as T; + r.error = (null as unknown) as E; + + const data = await response[format]() + .then((data) => { + if (r.ok) { + r.data = data; + } else { + r.error = data; + } + return r; + }) + .catch((e) => { + r.error = e; + return r; + }); + + if (cancelToken) { + this.abortControllers.delete(cancelToken); + } + + if (!response.ok) throw data; + return data; + }); + }; +} + +/** + * @title cosmos/mint/v1beta1/genesis.proto + * @version version not set + */ +export class Api extends HttpClient { + /** + * No description + * + * @tags Query + * @name QueryAnnualProvisions + * @summary AnnualProvisions current minting annual provisions value. + * @request GET:/cosmos/mint/v1beta1/annual_provisions + */ + queryAnnualProvisions = (params: RequestParams = {}) => + this.request({ + path: `/cosmos/mint/v1beta1/annual_provisions`, + method: "GET", + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Query + * @name QueryInflation + * @summary Inflation returns the current minting inflation value. + * @request GET:/cosmos/mint/v1beta1/inflation + */ + queryInflation = (params: RequestParams = {}) => + this.request({ + path: `/cosmos/mint/v1beta1/inflation`, + method: "GET", + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Query + * @name QueryParams + * @summary Params returns the total set of minting parameters. + * @request GET:/cosmos/mint/v1beta1/params + */ + queryParams = (params: RequestParams = {}) => + this.request({ + path: `/cosmos/mint/v1beta1/params`, + method: "GET", + format: "json", + ...params, + }); +} diff --git a/ts-client/cosmos.mint.v1beta1/types.ts b/ts-client/cosmos.mint.v1beta1/types.ts new file mode 100755 index 00000000..7e832e9e --- /dev/null +++ b/ts-client/cosmos.mint.v1beta1/types.ts @@ -0,0 +1,9 @@ +import { Minter } from "./types/cosmos/mint/v1beta1/mint" +import { Params } from "./types/cosmos/mint/v1beta1/mint" + + +export { + Minter, + Params, + + } \ No newline at end of file diff --git a/ts-client/cosmos.mint.v1beta1/types/cosmos/mint/v1beta1/genesis.ts b/ts-client/cosmos.mint.v1beta1/types/cosmos/mint/v1beta1/genesis.ts new file mode 100644 index 00000000..779cb180 --- /dev/null +++ b/ts-client/cosmos.mint.v1beta1/types/cosmos/mint/v1beta1/genesis.ts @@ -0,0 +1,98 @@ +/* eslint-disable */ +import { Minter, Params } from "../../../cosmos/mint/v1beta1/mint"; +import { Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "cosmos.mint.v1beta1"; + +/** GenesisState defines the mint module's genesis state. */ +export interface GenesisState { + /** minter is a space for holding current inflation information. */ + minter: Minter | undefined; + /** params defines all the paramaters of the module. */ + params: Params | undefined; +} + +const baseGenesisState: object = {}; + +export const GenesisState = { + encode(message: GenesisState, writer: Writer = Writer.create()): Writer { + if (message.minter !== undefined) { + Minter.encode(message.minter, writer.uint32(10).fork()).ldelim(); + } + if (message.params !== undefined) { + Params.encode(message.params, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): GenesisState { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseGenesisState } as GenesisState; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.minter = Minter.decode(reader, reader.uint32()); + break; + case 2: + message.params = Params.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GenesisState { + const message = { ...baseGenesisState } as GenesisState; + if (object.minter !== undefined && object.minter !== null) { + message.minter = Minter.fromJSON(object.minter); + } else { + message.minter = undefined; + } + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromJSON(object.params); + } else { + message.params = undefined; + } + return message; + }, + + toJSON(message: GenesisState): unknown { + const obj: any = {}; + message.minter !== undefined && + (obj.minter = message.minter ? Minter.toJSON(message.minter) : undefined); + message.params !== undefined && + (obj.params = message.params ? Params.toJSON(message.params) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): GenesisState { + const message = { ...baseGenesisState } as GenesisState; + if (object.minter !== undefined && object.minter !== null) { + message.minter = Minter.fromPartial(object.minter); + } else { + message.minter = undefined; + } + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromPartial(object.params); + } else { + message.params = undefined; + } + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/cosmos.mint.v1beta1/types/cosmos/mint/v1beta1/mint.ts b/ts-client/cosmos.mint.v1beta1/types/cosmos/mint/v1beta1/mint.ts new file mode 100644 index 00000000..3a9959df --- /dev/null +++ b/ts-client/cosmos.mint.v1beta1/types/cosmos/mint/v1beta1/mint.ts @@ -0,0 +1,298 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "cosmos.mint.v1beta1"; + +/** Minter represents the minting state. */ +export interface Minter { + /** current annual inflation rate */ + inflation: string; + /** current annual expected provisions */ + annualProvisions: string; +} + +/** Params holds parameters for the mint module. */ +export interface Params { + /** type of coin to mint */ + mintDenom: string; + /** maximum annual change in inflation rate */ + inflationRateChange: string; + /** maximum inflation rate */ + inflationMax: string; + /** minimum inflation rate */ + inflationMin: string; + /** goal of percent bonded atoms */ + goalBonded: string; + /** expected blocks per year */ + blocksPerYear: number; +} + +const baseMinter: object = { inflation: "", annualProvisions: "" }; + +export const Minter = { + encode(message: Minter, writer: Writer = Writer.create()): Writer { + if (message.inflation !== "") { + writer.uint32(10).string(message.inflation); + } + if (message.annualProvisions !== "") { + writer.uint32(18).string(message.annualProvisions); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Minter { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMinter } as Minter; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.inflation = reader.string(); + break; + case 2: + message.annualProvisions = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Minter { + const message = { ...baseMinter } as Minter; + if (object.inflation !== undefined && object.inflation !== null) { + message.inflation = String(object.inflation); + } else { + message.inflation = ""; + } + if ( + object.annualProvisions !== undefined && + object.annualProvisions !== null + ) { + message.annualProvisions = String(object.annualProvisions); + } else { + message.annualProvisions = ""; + } + return message; + }, + + toJSON(message: Minter): unknown { + const obj: any = {}; + message.inflation !== undefined && (obj.inflation = message.inflation); + message.annualProvisions !== undefined && + (obj.annualProvisions = message.annualProvisions); + return obj; + }, + + fromPartial(object: DeepPartial): Minter { + const message = { ...baseMinter } as Minter; + if (object.inflation !== undefined && object.inflation !== null) { + message.inflation = object.inflation; + } else { + message.inflation = ""; + } + if ( + object.annualProvisions !== undefined && + object.annualProvisions !== null + ) { + message.annualProvisions = object.annualProvisions; + } else { + message.annualProvisions = ""; + } + return message; + }, +}; + +const baseParams: object = { + mintDenom: "", + inflationRateChange: "", + inflationMax: "", + inflationMin: "", + goalBonded: "", + blocksPerYear: 0, +}; + +export const Params = { + encode(message: Params, writer: Writer = Writer.create()): Writer { + if (message.mintDenom !== "") { + writer.uint32(10).string(message.mintDenom); + } + if (message.inflationRateChange !== "") { + writer.uint32(18).string(message.inflationRateChange); + } + if (message.inflationMax !== "") { + writer.uint32(26).string(message.inflationMax); + } + if (message.inflationMin !== "") { + writer.uint32(34).string(message.inflationMin); + } + if (message.goalBonded !== "") { + writer.uint32(42).string(message.goalBonded); + } + if (message.blocksPerYear !== 0) { + writer.uint32(48).uint64(message.blocksPerYear); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Params { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseParams } as Params; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.mintDenom = reader.string(); + break; + case 2: + message.inflationRateChange = reader.string(); + break; + case 3: + message.inflationMax = reader.string(); + break; + case 4: + message.inflationMin = reader.string(); + break; + case 5: + message.goalBonded = reader.string(); + break; + case 6: + message.blocksPerYear = longToNumber(reader.uint64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Params { + const message = { ...baseParams } as Params; + if (object.mintDenom !== undefined && object.mintDenom !== null) { + message.mintDenom = String(object.mintDenom); + } else { + message.mintDenom = ""; + } + if ( + object.inflationRateChange !== undefined && + object.inflationRateChange !== null + ) { + message.inflationRateChange = String(object.inflationRateChange); + } else { + message.inflationRateChange = ""; + } + if (object.inflationMax !== undefined && object.inflationMax !== null) { + message.inflationMax = String(object.inflationMax); + } else { + message.inflationMax = ""; + } + if (object.inflationMin !== undefined && object.inflationMin !== null) { + message.inflationMin = String(object.inflationMin); + } else { + message.inflationMin = ""; + } + if (object.goalBonded !== undefined && object.goalBonded !== null) { + message.goalBonded = String(object.goalBonded); + } else { + message.goalBonded = ""; + } + if (object.blocksPerYear !== undefined && object.blocksPerYear !== null) { + message.blocksPerYear = Number(object.blocksPerYear); + } else { + message.blocksPerYear = 0; + } + return message; + }, + + toJSON(message: Params): unknown { + const obj: any = {}; + message.mintDenom !== undefined && (obj.mintDenom = message.mintDenom); + message.inflationRateChange !== undefined && + (obj.inflationRateChange = message.inflationRateChange); + message.inflationMax !== undefined && + (obj.inflationMax = message.inflationMax); + message.inflationMin !== undefined && + (obj.inflationMin = message.inflationMin); + message.goalBonded !== undefined && (obj.goalBonded = message.goalBonded); + message.blocksPerYear !== undefined && + (obj.blocksPerYear = message.blocksPerYear); + return obj; + }, + + fromPartial(object: DeepPartial): Params { + const message = { ...baseParams } as Params; + if (object.mintDenom !== undefined && object.mintDenom !== null) { + message.mintDenom = object.mintDenom; + } else { + message.mintDenom = ""; + } + if ( + object.inflationRateChange !== undefined && + object.inflationRateChange !== null + ) { + message.inflationRateChange = object.inflationRateChange; + } else { + message.inflationRateChange = ""; + } + if (object.inflationMax !== undefined && object.inflationMax !== null) { + message.inflationMax = object.inflationMax; + } else { + message.inflationMax = ""; + } + if (object.inflationMin !== undefined && object.inflationMin !== null) { + message.inflationMin = object.inflationMin; + } else { + message.inflationMin = ""; + } + if (object.goalBonded !== undefined && object.goalBonded !== null) { + message.goalBonded = object.goalBonded; + } else { + message.goalBonded = ""; + } + if (object.blocksPerYear !== undefined && object.blocksPerYear !== null) { + message.blocksPerYear = object.blocksPerYear; + } else { + message.blocksPerYear = 0; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/cosmos.mint.v1beta1/types/cosmos/mint/v1beta1/query.ts b/ts-client/cosmos.mint.v1beta1/types/cosmos/mint/v1beta1/query.ts new file mode 100644 index 00000000..879c4991 --- /dev/null +++ b/ts-client/cosmos.mint.v1beta1/types/cosmos/mint/v1beta1/query.ts @@ -0,0 +1,473 @@ +/* eslint-disable */ +import { Reader, Writer } from "protobufjs/minimal"; +import { Params } from "../../../cosmos/mint/v1beta1/mint"; + +export const protobufPackage = "cosmos.mint.v1beta1"; + +/** QueryParamsRequest is the request type for the Query/Params RPC method. */ +export interface QueryParamsRequest {} + +/** QueryParamsResponse is the response type for the Query/Params RPC method. */ +export interface QueryParamsResponse { + /** params defines the parameters of the module. */ + params: Params | undefined; +} + +/** QueryInflationRequest is the request type for the Query/Inflation RPC method. */ +export interface QueryInflationRequest {} + +/** + * QueryInflationResponse is the response type for the Query/Inflation RPC + * method. + */ +export interface QueryInflationResponse { + /** inflation is the current minting inflation value. */ + inflation: Uint8Array; +} + +/** + * QueryAnnualProvisionsRequest is the request type for the + * Query/AnnualProvisions RPC method. + */ +export interface QueryAnnualProvisionsRequest {} + +/** + * QueryAnnualProvisionsResponse is the response type for the + * Query/AnnualProvisions RPC method. + */ +export interface QueryAnnualProvisionsResponse { + /** annual_provisions is the current minting annual provisions value. */ + annualProvisions: Uint8Array; +} + +const baseQueryParamsRequest: object = {}; + +export const QueryParamsRequest = { + encode(_: QueryParamsRequest, writer: Writer = Writer.create()): Writer { + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QueryParamsRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryParamsRequest } as QueryParamsRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): QueryParamsRequest { + const message = { ...baseQueryParamsRequest } as QueryParamsRequest; + return message; + }, + + toJSON(_: QueryParamsRequest): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial(_: DeepPartial): QueryParamsRequest { + const message = { ...baseQueryParamsRequest } as QueryParamsRequest; + return message; + }, +}; + +const baseQueryParamsResponse: object = {}; + +export const QueryParamsResponse = { + encode( + message: QueryParamsResponse, + writer: Writer = Writer.create() + ): Writer { + if (message.params !== undefined) { + Params.encode(message.params, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QueryParamsResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryParamsResponse } as QueryParamsResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.params = Params.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryParamsResponse { + const message = { ...baseQueryParamsResponse } as QueryParamsResponse; + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromJSON(object.params); + } else { + message.params = undefined; + } + return message; + }, + + toJSON(message: QueryParamsResponse): unknown { + const obj: any = {}; + message.params !== undefined && + (obj.params = message.params ? Params.toJSON(message.params) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): QueryParamsResponse { + const message = { ...baseQueryParamsResponse } as QueryParamsResponse; + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromPartial(object.params); + } else { + message.params = undefined; + } + return message; + }, +}; + +const baseQueryInflationRequest: object = {}; + +export const QueryInflationRequest = { + encode(_: QueryInflationRequest, writer: Writer = Writer.create()): Writer { + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QueryInflationRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryInflationRequest } as QueryInflationRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): QueryInflationRequest { + const message = { ...baseQueryInflationRequest } as QueryInflationRequest; + return message; + }, + + toJSON(_: QueryInflationRequest): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial(_: DeepPartial): QueryInflationRequest { + const message = { ...baseQueryInflationRequest } as QueryInflationRequest; + return message; + }, +}; + +const baseQueryInflationResponse: object = {}; + +export const QueryInflationResponse = { + encode( + message: QueryInflationResponse, + writer: Writer = Writer.create() + ): Writer { + if (message.inflation.length !== 0) { + writer.uint32(10).bytes(message.inflation); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QueryInflationResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryInflationResponse } as QueryInflationResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.inflation = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryInflationResponse { + const message = { ...baseQueryInflationResponse } as QueryInflationResponse; + if (object.inflation !== undefined && object.inflation !== null) { + message.inflation = bytesFromBase64(object.inflation); + } + return message; + }, + + toJSON(message: QueryInflationResponse): unknown { + const obj: any = {}; + message.inflation !== undefined && + (obj.inflation = base64FromBytes( + message.inflation !== undefined ? message.inflation : new Uint8Array() + )); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryInflationResponse { + const message = { ...baseQueryInflationResponse } as QueryInflationResponse; + if (object.inflation !== undefined && object.inflation !== null) { + message.inflation = object.inflation; + } else { + message.inflation = new Uint8Array(); + } + return message; + }, +}; + +const baseQueryAnnualProvisionsRequest: object = {}; + +export const QueryAnnualProvisionsRequest = { + encode( + _: QueryAnnualProvisionsRequest, + writer: Writer = Writer.create() + ): Writer { + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryAnnualProvisionsRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryAnnualProvisionsRequest, + } as QueryAnnualProvisionsRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): QueryAnnualProvisionsRequest { + const message = { + ...baseQueryAnnualProvisionsRequest, + } as QueryAnnualProvisionsRequest; + return message; + }, + + toJSON(_: QueryAnnualProvisionsRequest): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial( + _: DeepPartial + ): QueryAnnualProvisionsRequest { + const message = { + ...baseQueryAnnualProvisionsRequest, + } as QueryAnnualProvisionsRequest; + return message; + }, +}; + +const baseQueryAnnualProvisionsResponse: object = {}; + +export const QueryAnnualProvisionsResponse = { + encode( + message: QueryAnnualProvisionsResponse, + writer: Writer = Writer.create() + ): Writer { + if (message.annualProvisions.length !== 0) { + writer.uint32(10).bytes(message.annualProvisions); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryAnnualProvisionsResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryAnnualProvisionsResponse, + } as QueryAnnualProvisionsResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.annualProvisions = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryAnnualProvisionsResponse { + const message = { + ...baseQueryAnnualProvisionsResponse, + } as QueryAnnualProvisionsResponse; + if ( + object.annualProvisions !== undefined && + object.annualProvisions !== null + ) { + message.annualProvisions = bytesFromBase64(object.annualProvisions); + } + return message; + }, + + toJSON(message: QueryAnnualProvisionsResponse): unknown { + const obj: any = {}; + message.annualProvisions !== undefined && + (obj.annualProvisions = base64FromBytes( + message.annualProvisions !== undefined + ? message.annualProvisions + : new Uint8Array() + )); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryAnnualProvisionsResponse { + const message = { + ...baseQueryAnnualProvisionsResponse, + } as QueryAnnualProvisionsResponse; + if ( + object.annualProvisions !== undefined && + object.annualProvisions !== null + ) { + message.annualProvisions = object.annualProvisions; + } else { + message.annualProvisions = new Uint8Array(); + } + return message; + }, +}; + +/** Query provides defines the gRPC querier service. */ +export interface Query { + /** Params returns the total set of minting parameters. */ + Params(request: QueryParamsRequest): Promise; + /** Inflation returns the current minting inflation value. */ + Inflation(request: QueryInflationRequest): Promise; + /** AnnualProvisions current minting annual provisions value. */ + AnnualProvisions( + request: QueryAnnualProvisionsRequest + ): Promise; +} + +export class QueryClientImpl implements Query { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + } + Params(request: QueryParamsRequest): Promise { + const data = QueryParamsRequest.encode(request).finish(); + const promise = this.rpc.request( + "cosmos.mint.v1beta1.Query", + "Params", + data + ); + return promise.then((data) => QueryParamsResponse.decode(new Reader(data))); + } + + Inflation(request: QueryInflationRequest): Promise { + const data = QueryInflationRequest.encode(request).finish(); + const promise = this.rpc.request( + "cosmos.mint.v1beta1.Query", + "Inflation", + data + ); + return promise.then((data) => + QueryInflationResponse.decode(new Reader(data)) + ); + } + + AnnualProvisions( + request: QueryAnnualProvisionsRequest + ): Promise { + const data = QueryAnnualProvisionsRequest.encode(request).finish(); + const promise = this.rpc.request( + "cosmos.mint.v1beta1.Query", + "AnnualProvisions", + data + ); + return promise.then((data) => + QueryAnnualProvisionsResponse.decode(new Reader(data)) + ); + } +} + +interface Rpc { + request( + service: string, + method: string, + data: Uint8Array + ): Promise; +} + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/cosmos.mint.v1beta1/types/gogoproto/gogo.ts b/ts-client/cosmos.mint.v1beta1/types/gogoproto/gogo.ts new file mode 100644 index 00000000..3f41a047 --- /dev/null +++ b/ts-client/cosmos.mint.v1beta1/types/gogoproto/gogo.ts @@ -0,0 +1,2 @@ +/* eslint-disable */ +export const protobufPackage = "gogoproto"; diff --git a/ts-client/cosmos.mint.v1beta1/types/google/api/annotations.ts b/ts-client/cosmos.mint.v1beta1/types/google/api/annotations.ts new file mode 100644 index 00000000..aace4787 --- /dev/null +++ b/ts-client/cosmos.mint.v1beta1/types/google/api/annotations.ts @@ -0,0 +1,2 @@ +/* eslint-disable */ +export const protobufPackage = "google.api"; diff --git a/ts-client/cosmos.mint.v1beta1/types/google/api/http.ts b/ts-client/cosmos.mint.v1beta1/types/google/api/http.ts new file mode 100644 index 00000000..ddc00f8b --- /dev/null +++ b/ts-client/cosmos.mint.v1beta1/types/google/api/http.ts @@ -0,0 +1,705 @@ +/* eslint-disable */ +import { Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "google.api"; + +/** + * Defines the HTTP configuration for an API service. It contains a list of + * [HttpRule][google.api.HttpRule], each specifying the mapping of an RPC method + * to one or more HTTP REST API methods. + */ +export interface Http { + /** + * A list of HTTP configuration rules that apply to individual API methods. + * + * **NOTE:** All service configuration rules follow "last one wins" order. + */ + rules: HttpRule[]; + /** + * When set to true, URL path parmeters will be fully URI-decoded except in + * cases of single segment matches in reserved expansion, where "%2F" will be + * left encoded. + * + * The default behavior is to not decode RFC 6570 reserved characters in multi + * segment matches. + */ + fullyDecodeReservedExpansion: boolean; +} + +/** + * `HttpRule` defines the mapping of an RPC method to one or more HTTP + * REST API methods. The mapping specifies how different portions of the RPC + * request message are mapped to URL path, URL query parameters, and + * HTTP request body. The mapping is typically specified as an + * `google.api.http` annotation on the RPC method, + * see "google/api/annotations.proto" for details. + * + * The mapping consists of a field specifying the path template and + * method kind. The path template can refer to fields in the request + * message, as in the example below which describes a REST GET + * operation on a resource collection of messages: + * + * + * service Messaging { + * rpc GetMessage(GetMessageRequest) returns (Message) { + * option (google.api.http).get = "/v1/messages/{message_id}/{sub.subfield}"; + * } + * } + * message GetMessageRequest { + * message SubMessage { + * string subfield = 1; + * } + * string message_id = 1; // mapped to the URL + * SubMessage sub = 2; // `sub.subfield` is url-mapped + * } + * message Message { + * string text = 1; // content of the resource + * } + * + * The same http annotation can alternatively be expressed inside the + * `GRPC API Configuration` YAML file. + * + * http: + * rules: + * - selector: .Messaging.GetMessage + * get: /v1/messages/{message_id}/{sub.subfield} + * + * This definition enables an automatic, bidrectional mapping of HTTP + * JSON to RPC. Example: + * + * HTTP | RPC + * -----|----- + * `GET /v1/messages/123456/foo` | `GetMessage(message_id: "123456" sub: SubMessage(subfield: "foo"))` + * + * In general, not only fields but also field paths can be referenced + * from a path pattern. Fields mapped to the path pattern cannot be + * repeated and must have a primitive (non-message) type. + * + * Any fields in the request message which are not bound by the path + * pattern automatically become (optional) HTTP query + * parameters. Assume the following definition of the request message: + * + * + * service Messaging { + * rpc GetMessage(GetMessageRequest) returns (Message) { + * option (google.api.http).get = "/v1/messages/{message_id}"; + * } + * } + * message GetMessageRequest { + * message SubMessage { + * string subfield = 1; + * } + * string message_id = 1; // mapped to the URL + * int64 revision = 2; // becomes a parameter + * SubMessage sub = 3; // `sub.subfield` becomes a parameter + * } + * + * + * This enables a HTTP JSON to RPC mapping as below: + * + * HTTP | RPC + * -----|----- + * `GET /v1/messages/123456?revision=2&sub.subfield=foo` | `GetMessage(message_id: "123456" revision: 2 sub: SubMessage(subfield: "foo"))` + * + * Note that fields which are mapped to HTTP parameters must have a + * primitive type or a repeated primitive type. Message types are not + * allowed. In the case of a repeated type, the parameter can be + * repeated in the URL, as in `...?param=A¶m=B`. + * + * For HTTP method kinds which allow a request body, the `body` field + * specifies the mapping. Consider a REST update method on the + * message resource collection: + * + * + * service Messaging { + * rpc UpdateMessage(UpdateMessageRequest) returns (Message) { + * option (google.api.http) = { + * put: "/v1/messages/{message_id}" + * body: "message" + * }; + * } + * } + * message UpdateMessageRequest { + * string message_id = 1; // mapped to the URL + * Message message = 2; // mapped to the body + * } + * + * + * The following HTTP JSON to RPC mapping is enabled, where the + * representation of the JSON in the request body is determined by + * protos JSON encoding: + * + * HTTP | RPC + * -----|----- + * `PUT /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: "123456" message { text: "Hi!" })` + * + * The special name `*` can be used in the body mapping to define that + * every field not bound by the path template should be mapped to the + * request body. This enables the following alternative definition of + * the update method: + * + * service Messaging { + * rpc UpdateMessage(Message) returns (Message) { + * option (google.api.http) = { + * put: "/v1/messages/{message_id}" + * body: "*" + * }; + * } + * } + * message Message { + * string message_id = 1; + * string text = 2; + * } + * + * + * The following HTTP JSON to RPC mapping is enabled: + * + * HTTP | RPC + * -----|----- + * `PUT /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: "123456" text: "Hi!")` + * + * Note that when using `*` in the body mapping, it is not possible to + * have HTTP parameters, as all fields not bound by the path end in + * the body. This makes this option more rarely used in practice of + * defining REST APIs. The common usage of `*` is in custom methods + * which don't use the URL at all for transferring data. + * + * It is possible to define multiple HTTP methods for one RPC by using + * the `additional_bindings` option. Example: + * + * service Messaging { + * rpc GetMessage(GetMessageRequest) returns (Message) { + * option (google.api.http) = { + * get: "/v1/messages/{message_id}" + * additional_bindings { + * get: "/v1/users/{user_id}/messages/{message_id}" + * } + * }; + * } + * } + * message GetMessageRequest { + * string message_id = 1; + * string user_id = 2; + * } + * + * + * This enables the following two alternative HTTP JSON to RPC + * mappings: + * + * HTTP | RPC + * -----|----- + * `GET /v1/messages/123456` | `GetMessage(message_id: "123456")` + * `GET /v1/users/me/messages/123456` | `GetMessage(user_id: "me" message_id: "123456")` + * + * # Rules for HTTP mapping + * + * The rules for mapping HTTP path, query parameters, and body fields + * to the request message are as follows: + * + * 1. The `body` field specifies either `*` or a field path, or is + * omitted. If omitted, it indicates there is no HTTP request body. + * 2. Leaf fields (recursive expansion of nested messages in the + * request) can be classified into three types: + * (a) Matched in the URL template. + * (b) Covered by body (if body is `*`, everything except (a) fields; + * else everything under the body field) + * (c) All other fields. + * 3. URL query parameters found in the HTTP request are mapped to (c) fields. + * 4. Any body sent with an HTTP request can contain only (b) fields. + * + * The syntax of the path template is as follows: + * + * Template = "/" Segments [ Verb ] ; + * Segments = Segment { "/" Segment } ; + * Segment = "*" | "**" | LITERAL | Variable ; + * Variable = "{" FieldPath [ "=" Segments ] "}" ; + * FieldPath = IDENT { "." IDENT } ; + * Verb = ":" LITERAL ; + * + * The syntax `*` matches a single path segment. The syntax `**` matches zero + * or more path segments, which must be the last part of the path except the + * `Verb`. The syntax `LITERAL` matches literal text in the path. + * + * The syntax `Variable` matches part of the URL path as specified by its + * template. A variable template must not contain other variables. If a variable + * matches a single path segment, its template may be omitted, e.g. `{var}` + * is equivalent to `{var=*}`. + * + * If a variable contains exactly one path segment, such as `"{var}"` or + * `"{var=*}"`, when such a variable is expanded into a URL path, all characters + * except `[-_.~0-9a-zA-Z]` are percent-encoded. Such variables show up in the + * Discovery Document as `{var}`. + * + * If a variable contains one or more path segments, such as `"{var=foo/*}"` + * or `"{var=**}"`, when such a variable is expanded into a URL path, all + * characters except `[-_.~/0-9a-zA-Z]` are percent-encoded. Such variables + * show up in the Discovery Document as `{+var}`. + * + * NOTE: While the single segment variable matches the semantics of + * [RFC 6570](https://tools.ietf.org/html/rfc6570) Section 3.2.2 + * Simple String Expansion, the multi segment variable **does not** match + * RFC 6570 Reserved Expansion. The reason is that the Reserved Expansion + * does not expand special characters like `?` and `#`, which would lead + * to invalid URLs. + * + * NOTE: the field paths in variables and in the `body` must not refer to + * repeated fields or map fields. + */ +export interface HttpRule { + /** + * Selects methods to which this rule applies. + * + * Refer to [selector][google.api.DocumentationRule.selector] for syntax details. + */ + selector: string; + /** Used for listing and getting information about resources. */ + get: string | undefined; + /** Used for updating a resource. */ + put: string | undefined; + /** Used for creating a resource. */ + post: string | undefined; + /** Used for deleting a resource. */ + delete: string | undefined; + /** Used for updating a resource. */ + patch: string | undefined; + /** + * The custom pattern is used for specifying an HTTP method that is not + * included in the `pattern` field, such as HEAD, or "*" to leave the + * HTTP method unspecified for this rule. The wild-card rule is useful + * for services that provide content to Web (HTML) clients. + */ + custom: CustomHttpPattern | undefined; + /** + * The name of the request field whose value is mapped to the HTTP body, or + * `*` for mapping all fields not captured by the path pattern to the HTTP + * body. NOTE: the referred field must not be a repeated field and must be + * present at the top-level of request message type. + */ + body: string; + /** + * Optional. The name of the response field whose value is mapped to the HTTP + * body of response. Other response fields are ignored. When + * not set, the response message will be used as HTTP body of response. + */ + responseBody: string; + /** + * Additional HTTP bindings for the selector. Nested bindings must + * not contain an `additional_bindings` field themselves (that is, + * the nesting may only be one level deep). + */ + additionalBindings: HttpRule[]; +} + +/** A custom pattern is used for defining custom HTTP verb. */ +export interface CustomHttpPattern { + /** The name of this custom HTTP verb. */ + kind: string; + /** The path matched by this custom verb. */ + path: string; +} + +const baseHttp: object = { fullyDecodeReservedExpansion: false }; + +export const Http = { + encode(message: Http, writer: Writer = Writer.create()): Writer { + for (const v of message.rules) { + HttpRule.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.fullyDecodeReservedExpansion === true) { + writer.uint32(16).bool(message.fullyDecodeReservedExpansion); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Http { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseHttp } as Http; + message.rules = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.rules.push(HttpRule.decode(reader, reader.uint32())); + break; + case 2: + message.fullyDecodeReservedExpansion = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Http { + const message = { ...baseHttp } as Http; + message.rules = []; + if (object.rules !== undefined && object.rules !== null) { + for (const e of object.rules) { + message.rules.push(HttpRule.fromJSON(e)); + } + } + if ( + object.fullyDecodeReservedExpansion !== undefined && + object.fullyDecodeReservedExpansion !== null + ) { + message.fullyDecodeReservedExpansion = Boolean( + object.fullyDecodeReservedExpansion + ); + } else { + message.fullyDecodeReservedExpansion = false; + } + return message; + }, + + toJSON(message: Http): unknown { + const obj: any = {}; + if (message.rules) { + obj.rules = message.rules.map((e) => + e ? HttpRule.toJSON(e) : undefined + ); + } else { + obj.rules = []; + } + message.fullyDecodeReservedExpansion !== undefined && + (obj.fullyDecodeReservedExpansion = message.fullyDecodeReservedExpansion); + return obj; + }, + + fromPartial(object: DeepPartial): Http { + const message = { ...baseHttp } as Http; + message.rules = []; + if (object.rules !== undefined && object.rules !== null) { + for (const e of object.rules) { + message.rules.push(HttpRule.fromPartial(e)); + } + } + if ( + object.fullyDecodeReservedExpansion !== undefined && + object.fullyDecodeReservedExpansion !== null + ) { + message.fullyDecodeReservedExpansion = + object.fullyDecodeReservedExpansion; + } else { + message.fullyDecodeReservedExpansion = false; + } + return message; + }, +}; + +const baseHttpRule: object = { selector: "", body: "", responseBody: "" }; + +export const HttpRule = { + encode(message: HttpRule, writer: Writer = Writer.create()): Writer { + if (message.selector !== "") { + writer.uint32(10).string(message.selector); + } + if (message.get !== undefined) { + writer.uint32(18).string(message.get); + } + if (message.put !== undefined) { + writer.uint32(26).string(message.put); + } + if (message.post !== undefined) { + writer.uint32(34).string(message.post); + } + if (message.delete !== undefined) { + writer.uint32(42).string(message.delete); + } + if (message.patch !== undefined) { + writer.uint32(50).string(message.patch); + } + if (message.custom !== undefined) { + CustomHttpPattern.encode( + message.custom, + writer.uint32(66).fork() + ).ldelim(); + } + if (message.body !== "") { + writer.uint32(58).string(message.body); + } + if (message.responseBody !== "") { + writer.uint32(98).string(message.responseBody); + } + for (const v of message.additionalBindings) { + HttpRule.encode(v!, writer.uint32(90).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): HttpRule { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseHttpRule } as HttpRule; + message.additionalBindings = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.selector = reader.string(); + break; + case 2: + message.get = reader.string(); + break; + case 3: + message.put = reader.string(); + break; + case 4: + message.post = reader.string(); + break; + case 5: + message.delete = reader.string(); + break; + case 6: + message.patch = reader.string(); + break; + case 8: + message.custom = CustomHttpPattern.decode(reader, reader.uint32()); + break; + case 7: + message.body = reader.string(); + break; + case 12: + message.responseBody = reader.string(); + break; + case 11: + message.additionalBindings.push( + HttpRule.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): HttpRule { + const message = { ...baseHttpRule } as HttpRule; + message.additionalBindings = []; + if (object.selector !== undefined && object.selector !== null) { + message.selector = String(object.selector); + } else { + message.selector = ""; + } + if (object.get !== undefined && object.get !== null) { + message.get = String(object.get); + } else { + message.get = undefined; + } + if (object.put !== undefined && object.put !== null) { + message.put = String(object.put); + } else { + message.put = undefined; + } + if (object.post !== undefined && object.post !== null) { + message.post = String(object.post); + } else { + message.post = undefined; + } + if (object.delete !== undefined && object.delete !== null) { + message.delete = String(object.delete); + } else { + message.delete = undefined; + } + if (object.patch !== undefined && object.patch !== null) { + message.patch = String(object.patch); + } else { + message.patch = undefined; + } + if (object.custom !== undefined && object.custom !== null) { + message.custom = CustomHttpPattern.fromJSON(object.custom); + } else { + message.custom = undefined; + } + if (object.body !== undefined && object.body !== null) { + message.body = String(object.body); + } else { + message.body = ""; + } + if (object.responseBody !== undefined && object.responseBody !== null) { + message.responseBody = String(object.responseBody); + } else { + message.responseBody = ""; + } + if ( + object.additionalBindings !== undefined && + object.additionalBindings !== null + ) { + for (const e of object.additionalBindings) { + message.additionalBindings.push(HttpRule.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: HttpRule): unknown { + const obj: any = {}; + message.selector !== undefined && (obj.selector = message.selector); + message.get !== undefined && (obj.get = message.get); + message.put !== undefined && (obj.put = message.put); + message.post !== undefined && (obj.post = message.post); + message.delete !== undefined && (obj.delete = message.delete); + message.patch !== undefined && (obj.patch = message.patch); + message.custom !== undefined && + (obj.custom = message.custom + ? CustomHttpPattern.toJSON(message.custom) + : undefined); + message.body !== undefined && (obj.body = message.body); + message.responseBody !== undefined && + (obj.responseBody = message.responseBody); + if (message.additionalBindings) { + obj.additionalBindings = message.additionalBindings.map((e) => + e ? HttpRule.toJSON(e) : undefined + ); + } else { + obj.additionalBindings = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): HttpRule { + const message = { ...baseHttpRule } as HttpRule; + message.additionalBindings = []; + if (object.selector !== undefined && object.selector !== null) { + message.selector = object.selector; + } else { + message.selector = ""; + } + if (object.get !== undefined && object.get !== null) { + message.get = object.get; + } else { + message.get = undefined; + } + if (object.put !== undefined && object.put !== null) { + message.put = object.put; + } else { + message.put = undefined; + } + if (object.post !== undefined && object.post !== null) { + message.post = object.post; + } else { + message.post = undefined; + } + if (object.delete !== undefined && object.delete !== null) { + message.delete = object.delete; + } else { + message.delete = undefined; + } + if (object.patch !== undefined && object.patch !== null) { + message.patch = object.patch; + } else { + message.patch = undefined; + } + if (object.custom !== undefined && object.custom !== null) { + message.custom = CustomHttpPattern.fromPartial(object.custom); + } else { + message.custom = undefined; + } + if (object.body !== undefined && object.body !== null) { + message.body = object.body; + } else { + message.body = ""; + } + if (object.responseBody !== undefined && object.responseBody !== null) { + message.responseBody = object.responseBody; + } else { + message.responseBody = ""; + } + if ( + object.additionalBindings !== undefined && + object.additionalBindings !== null + ) { + for (const e of object.additionalBindings) { + message.additionalBindings.push(HttpRule.fromPartial(e)); + } + } + return message; + }, +}; + +const baseCustomHttpPattern: object = { kind: "", path: "" }; + +export const CustomHttpPattern = { + encode(message: CustomHttpPattern, writer: Writer = Writer.create()): Writer { + if (message.kind !== "") { + writer.uint32(10).string(message.kind); + } + if (message.path !== "") { + writer.uint32(18).string(message.path); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): CustomHttpPattern { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseCustomHttpPattern } as CustomHttpPattern; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.kind = reader.string(); + break; + case 2: + message.path = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): CustomHttpPattern { + const message = { ...baseCustomHttpPattern } as CustomHttpPattern; + if (object.kind !== undefined && object.kind !== null) { + message.kind = String(object.kind); + } else { + message.kind = ""; + } + if (object.path !== undefined && object.path !== null) { + message.path = String(object.path); + } else { + message.path = ""; + } + return message; + }, + + toJSON(message: CustomHttpPattern): unknown { + const obj: any = {}; + message.kind !== undefined && (obj.kind = message.kind); + message.path !== undefined && (obj.path = message.path); + return obj; + }, + + fromPartial(object: DeepPartial): CustomHttpPattern { + const message = { ...baseCustomHttpPattern } as CustomHttpPattern; + if (object.kind !== undefined && object.kind !== null) { + message.kind = object.kind; + } else { + message.kind = ""; + } + if (object.path !== undefined && object.path !== null) { + message.path = object.path; + } else { + message.path = ""; + } + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/cosmos.mint.v1beta1/types/google/protobuf/descriptor.ts b/ts-client/cosmos.mint.v1beta1/types/google/protobuf/descriptor.ts new file mode 100644 index 00000000..9e508660 --- /dev/null +++ b/ts-client/cosmos.mint.v1beta1/types/google/protobuf/descriptor.ts @@ -0,0 +1,5261 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "google.protobuf"; + +/** + * The protocol compiler can output a FileDescriptorSet containing the .proto + * files it parses. + */ +export interface FileDescriptorSet { + file: FileDescriptorProto[]; +} + +/** Describes a complete .proto file. */ +export interface FileDescriptorProto { + /** file name, relative to root of source tree */ + name: string; + /** e.g. "foo", "foo.bar", etc. */ + package: string; + /** Names of files imported by this file. */ + dependency: string[]; + /** Indexes of the public imported files in the dependency list above. */ + publicDependency: number[]; + /** + * Indexes of the weak imported files in the dependency list. + * For Google-internal migration only. Do not use. + */ + weakDependency: number[]; + /** All top-level definitions in this file. */ + messageType: DescriptorProto[]; + enumType: EnumDescriptorProto[]; + service: ServiceDescriptorProto[]; + extension: FieldDescriptorProto[]; + options: FileOptions | undefined; + /** + * This field contains optional information about the original source code. + * You may safely remove this entire field without harming runtime + * functionality of the descriptors -- the information is needed only by + * development tools. + */ + sourceCodeInfo: SourceCodeInfo | undefined; + /** + * The syntax of the proto file. + * The supported values are "proto2" and "proto3". + */ + syntax: string; +} + +/** Describes a message type. */ +export interface DescriptorProto { + name: string; + field: FieldDescriptorProto[]; + extension: FieldDescriptorProto[]; + nestedType: DescriptorProto[]; + enumType: EnumDescriptorProto[]; + extensionRange: DescriptorProto_ExtensionRange[]; + oneofDecl: OneofDescriptorProto[]; + options: MessageOptions | undefined; + reservedRange: DescriptorProto_ReservedRange[]; + /** + * Reserved field names, which may not be used by fields in the same message. + * A given name may only be reserved once. + */ + reservedName: string[]; +} + +export interface DescriptorProto_ExtensionRange { + /** Inclusive. */ + start: number; + /** Exclusive. */ + end: number; + options: ExtensionRangeOptions | undefined; +} + +/** + * Range of reserved tag numbers. Reserved tag numbers may not be used by + * fields or extension ranges in the same message. Reserved ranges may + * not overlap. + */ +export interface DescriptorProto_ReservedRange { + /** Inclusive. */ + start: number; + /** Exclusive. */ + end: number; +} + +export interface ExtensionRangeOptions { + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +/** Describes a field within a message. */ +export interface FieldDescriptorProto { + name: string; + number: number; + label: FieldDescriptorProto_Label; + /** + * If type_name is set, this need not be set. If both this and type_name + * are set, this must be one of TYPE_ENUM, TYPE_MESSAGE or TYPE_GROUP. + */ + type: FieldDescriptorProto_Type; + /** + * For message and enum types, this is the name of the type. If the name + * starts with a '.', it is fully-qualified. Otherwise, C++-like scoping + * rules are used to find the type (i.e. first the nested types within this + * message are searched, then within the parent, on up to the root + * namespace). + */ + typeName: string; + /** + * For extensions, this is the name of the type being extended. It is + * resolved in the same manner as type_name. + */ + extendee: string; + /** + * For numeric types, contains the original text representation of the value. + * For booleans, "true" or "false". + * For strings, contains the default text contents (not escaped in any way). + * For bytes, contains the C escaped value. All bytes >= 128 are escaped. + * TODO(kenton): Base-64 encode? + */ + defaultValue: string; + /** + * If set, gives the index of a oneof in the containing type's oneof_decl + * list. This field is a member of that oneof. + */ + oneofIndex: number; + /** + * JSON name of this field. The value is set by protocol compiler. If the + * user has set a "json_name" option on this field, that option's value + * will be used. Otherwise, it's deduced from the field's name by converting + * it to camelCase. + */ + jsonName: string; + options: FieldOptions | undefined; + /** + * If true, this is a proto3 "optional". When a proto3 field is optional, it + * tracks presence regardless of field type. + * + * When proto3_optional is true, this field must be belong to a oneof to + * signal to old proto3 clients that presence is tracked for this field. This + * oneof is known as a "synthetic" oneof, and this field must be its sole + * member (each proto3 optional field gets its own synthetic oneof). Synthetic + * oneofs exist in the descriptor only, and do not generate any API. Synthetic + * oneofs must be ordered after all "real" oneofs. + * + * For message fields, proto3_optional doesn't create any semantic change, + * since non-repeated message fields always track presence. However it still + * indicates the semantic detail of whether the user wrote "optional" or not. + * This can be useful for round-tripping the .proto file. For consistency we + * give message fields a synthetic oneof also, even though it is not required + * to track presence. This is especially important because the parser can't + * tell if a field is a message or an enum, so it must always create a + * synthetic oneof. + * + * Proto2 optional fields do not set this flag, because they already indicate + * optional with `LABEL_OPTIONAL`. + */ + proto3Optional: boolean; +} + +export enum FieldDescriptorProto_Type { + /** + * TYPE_DOUBLE - 0 is reserved for errors. + * Order is weird for historical reasons. + */ + TYPE_DOUBLE = 1, + TYPE_FLOAT = 2, + /** + * TYPE_INT64 - Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT64 if + * negative values are likely. + */ + TYPE_INT64 = 3, + TYPE_UINT64 = 4, + /** + * TYPE_INT32 - Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT32 if + * negative values are likely. + */ + TYPE_INT32 = 5, + TYPE_FIXED64 = 6, + TYPE_FIXED32 = 7, + TYPE_BOOL = 8, + TYPE_STRING = 9, + /** + * TYPE_GROUP - Tag-delimited aggregate. + * Group type is deprecated and not supported in proto3. However, Proto3 + * implementations should still be able to parse the group wire format and + * treat group fields as unknown fields. + */ + TYPE_GROUP = 10, + /** TYPE_MESSAGE - Length-delimited aggregate. */ + TYPE_MESSAGE = 11, + /** TYPE_BYTES - New in version 2. */ + TYPE_BYTES = 12, + TYPE_UINT32 = 13, + TYPE_ENUM = 14, + TYPE_SFIXED32 = 15, + TYPE_SFIXED64 = 16, + /** TYPE_SINT32 - Uses ZigZag encoding. */ + TYPE_SINT32 = 17, + /** TYPE_SINT64 - Uses ZigZag encoding. */ + TYPE_SINT64 = 18, + UNRECOGNIZED = -1, +} + +export function fieldDescriptorProto_TypeFromJSON( + object: any +): FieldDescriptorProto_Type { + switch (object) { + case 1: + case "TYPE_DOUBLE": + return FieldDescriptorProto_Type.TYPE_DOUBLE; + case 2: + case "TYPE_FLOAT": + return FieldDescriptorProto_Type.TYPE_FLOAT; + case 3: + case "TYPE_INT64": + return FieldDescriptorProto_Type.TYPE_INT64; + case 4: + case "TYPE_UINT64": + return FieldDescriptorProto_Type.TYPE_UINT64; + case 5: + case "TYPE_INT32": + return FieldDescriptorProto_Type.TYPE_INT32; + case 6: + case "TYPE_FIXED64": + return FieldDescriptorProto_Type.TYPE_FIXED64; + case 7: + case "TYPE_FIXED32": + return FieldDescriptorProto_Type.TYPE_FIXED32; + case 8: + case "TYPE_BOOL": + return FieldDescriptorProto_Type.TYPE_BOOL; + case 9: + case "TYPE_STRING": + return FieldDescriptorProto_Type.TYPE_STRING; + case 10: + case "TYPE_GROUP": + return FieldDescriptorProto_Type.TYPE_GROUP; + case 11: + case "TYPE_MESSAGE": + return FieldDescriptorProto_Type.TYPE_MESSAGE; + case 12: + case "TYPE_BYTES": + return FieldDescriptorProto_Type.TYPE_BYTES; + case 13: + case "TYPE_UINT32": + return FieldDescriptorProto_Type.TYPE_UINT32; + case 14: + case "TYPE_ENUM": + return FieldDescriptorProto_Type.TYPE_ENUM; + case 15: + case "TYPE_SFIXED32": + return FieldDescriptorProto_Type.TYPE_SFIXED32; + case 16: + case "TYPE_SFIXED64": + return FieldDescriptorProto_Type.TYPE_SFIXED64; + case 17: + case "TYPE_SINT32": + return FieldDescriptorProto_Type.TYPE_SINT32; + case 18: + case "TYPE_SINT64": + return FieldDescriptorProto_Type.TYPE_SINT64; + case -1: + case "UNRECOGNIZED": + default: + return FieldDescriptorProto_Type.UNRECOGNIZED; + } +} + +export function fieldDescriptorProto_TypeToJSON( + object: FieldDescriptorProto_Type +): string { + switch (object) { + case FieldDescriptorProto_Type.TYPE_DOUBLE: + return "TYPE_DOUBLE"; + case FieldDescriptorProto_Type.TYPE_FLOAT: + return "TYPE_FLOAT"; + case FieldDescriptorProto_Type.TYPE_INT64: + return "TYPE_INT64"; + case FieldDescriptorProto_Type.TYPE_UINT64: + return "TYPE_UINT64"; + case FieldDescriptorProto_Type.TYPE_INT32: + return "TYPE_INT32"; + case FieldDescriptorProto_Type.TYPE_FIXED64: + return "TYPE_FIXED64"; + case FieldDescriptorProto_Type.TYPE_FIXED32: + return "TYPE_FIXED32"; + case FieldDescriptorProto_Type.TYPE_BOOL: + return "TYPE_BOOL"; + case FieldDescriptorProto_Type.TYPE_STRING: + return "TYPE_STRING"; + case FieldDescriptorProto_Type.TYPE_GROUP: + return "TYPE_GROUP"; + case FieldDescriptorProto_Type.TYPE_MESSAGE: + return "TYPE_MESSAGE"; + case FieldDescriptorProto_Type.TYPE_BYTES: + return "TYPE_BYTES"; + case FieldDescriptorProto_Type.TYPE_UINT32: + return "TYPE_UINT32"; + case FieldDescriptorProto_Type.TYPE_ENUM: + return "TYPE_ENUM"; + case FieldDescriptorProto_Type.TYPE_SFIXED32: + return "TYPE_SFIXED32"; + case FieldDescriptorProto_Type.TYPE_SFIXED64: + return "TYPE_SFIXED64"; + case FieldDescriptorProto_Type.TYPE_SINT32: + return "TYPE_SINT32"; + case FieldDescriptorProto_Type.TYPE_SINT64: + return "TYPE_SINT64"; + default: + return "UNKNOWN"; + } +} + +export enum FieldDescriptorProto_Label { + /** LABEL_OPTIONAL - 0 is reserved for errors */ + LABEL_OPTIONAL = 1, + LABEL_REQUIRED = 2, + LABEL_REPEATED = 3, + UNRECOGNIZED = -1, +} + +export function fieldDescriptorProto_LabelFromJSON( + object: any +): FieldDescriptorProto_Label { + switch (object) { + case 1: + case "LABEL_OPTIONAL": + return FieldDescriptorProto_Label.LABEL_OPTIONAL; + case 2: + case "LABEL_REQUIRED": + return FieldDescriptorProto_Label.LABEL_REQUIRED; + case 3: + case "LABEL_REPEATED": + return FieldDescriptorProto_Label.LABEL_REPEATED; + case -1: + case "UNRECOGNIZED": + default: + return FieldDescriptorProto_Label.UNRECOGNIZED; + } +} + +export function fieldDescriptorProto_LabelToJSON( + object: FieldDescriptorProto_Label +): string { + switch (object) { + case FieldDescriptorProto_Label.LABEL_OPTIONAL: + return "LABEL_OPTIONAL"; + case FieldDescriptorProto_Label.LABEL_REQUIRED: + return "LABEL_REQUIRED"; + case FieldDescriptorProto_Label.LABEL_REPEATED: + return "LABEL_REPEATED"; + default: + return "UNKNOWN"; + } +} + +/** Describes a oneof. */ +export interface OneofDescriptorProto { + name: string; + options: OneofOptions | undefined; +} + +/** Describes an enum type. */ +export interface EnumDescriptorProto { + name: string; + value: EnumValueDescriptorProto[]; + options: EnumOptions | undefined; + /** + * Range of reserved numeric values. Reserved numeric values may not be used + * by enum values in the same enum declaration. Reserved ranges may not + * overlap. + */ + reservedRange: EnumDescriptorProto_EnumReservedRange[]; + /** + * Reserved enum value names, which may not be reused. A given name may only + * be reserved once. + */ + reservedName: string[]; +} + +/** + * Range of reserved numeric values. Reserved values may not be used by + * entries in the same enum. Reserved ranges may not overlap. + * + * Note that this is distinct from DescriptorProto.ReservedRange in that it + * is inclusive such that it can appropriately represent the entire int32 + * domain. + */ +export interface EnumDescriptorProto_EnumReservedRange { + /** Inclusive. */ + start: number; + /** Inclusive. */ + end: number; +} + +/** Describes a value within an enum. */ +export interface EnumValueDescriptorProto { + name: string; + number: number; + options: EnumValueOptions | undefined; +} + +/** Describes a service. */ +export interface ServiceDescriptorProto { + name: string; + method: MethodDescriptorProto[]; + options: ServiceOptions | undefined; +} + +/** Describes a method of a service. */ +export interface MethodDescriptorProto { + name: string; + /** + * Input and output type names. These are resolved in the same way as + * FieldDescriptorProto.type_name, but must refer to a message type. + */ + inputType: string; + outputType: string; + options: MethodOptions | undefined; + /** Identifies if client streams multiple client messages */ + clientStreaming: boolean; + /** Identifies if server streams multiple server messages */ + serverStreaming: boolean; +} + +export interface FileOptions { + /** + * Sets the Java package where classes generated from this .proto will be + * placed. By default, the proto package is used, but this is often + * inappropriate because proto packages do not normally start with backwards + * domain names. + */ + javaPackage: string; + /** + * Controls the name of the wrapper Java class generated for the .proto file. + * That class will always contain the .proto file's getDescriptor() method as + * well as any top-level extensions defined in the .proto file. + * If java_multiple_files is disabled, then all the other classes from the + * .proto file will be nested inside the single wrapper outer class. + */ + javaOuterClassname: string; + /** + * If enabled, then the Java code generator will generate a separate .java + * file for each top-level message, enum, and service defined in the .proto + * file. Thus, these types will *not* be nested inside the wrapper class + * named by java_outer_classname. However, the wrapper class will still be + * generated to contain the file's getDescriptor() method as well as any + * top-level extensions defined in the file. + */ + javaMultipleFiles: boolean; + /** + * This option does nothing. + * + * @deprecated + */ + javaGenerateEqualsAndHash: boolean; + /** + * If set true, then the Java2 code generator will generate code that + * throws an exception whenever an attempt is made to assign a non-UTF-8 + * byte sequence to a string field. + * Message reflection will do the same. + * However, an extension field still accepts non-UTF-8 byte sequences. + * This option has no effect on when used with the lite runtime. + */ + javaStringCheckUtf8: boolean; + optimizeFor: FileOptions_OptimizeMode; + /** + * Sets the Go package where structs generated from this .proto will be + * placed. If omitted, the Go package will be derived from the following: + * - The basename of the package import path, if provided. + * - Otherwise, the package statement in the .proto file, if present. + * - Otherwise, the basename of the .proto file, without extension. + */ + goPackage: string; + /** + * Should generic services be generated in each language? "Generic" services + * are not specific to any particular RPC system. They are generated by the + * main code generators in each language (without additional plugins). + * Generic services were the only kind of service generation supported by + * early versions of google.protobuf. + * + * Generic services are now considered deprecated in favor of using plugins + * that generate code specific to your particular RPC system. Therefore, + * these default to false. Old code which depends on generic services should + * explicitly set them to true. + */ + ccGenericServices: boolean; + javaGenericServices: boolean; + pyGenericServices: boolean; + phpGenericServices: boolean; + /** + * Is this file deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for everything in the file, or it will be completely ignored; in the very + * least, this is a formalization for deprecating files. + */ + deprecated: boolean; + /** + * Enables the use of arenas for the proto messages in this file. This applies + * only to generated classes for C++. + */ + ccEnableArenas: boolean; + /** + * Sets the objective c class prefix which is prepended to all objective c + * generated classes from this .proto. There is no default. + */ + objcClassPrefix: string; + /** Namespace for generated classes; defaults to the package. */ + csharpNamespace: string; + /** + * By default Swift generators will take the proto package and CamelCase it + * replacing '.' with underscore and use that to prefix the types/symbols + * defined. When this options is provided, they will use this value instead + * to prefix the types/symbols defined. + */ + swiftPrefix: string; + /** + * Sets the php class prefix which is prepended to all php generated classes + * from this .proto. Default is empty. + */ + phpClassPrefix: string; + /** + * Use this option to change the namespace of php generated classes. Default + * is empty. When this option is empty, the package name will be used for + * determining the namespace. + */ + phpNamespace: string; + /** + * Use this option to change the namespace of php generated metadata classes. + * Default is empty. When this option is empty, the proto file name will be + * used for determining the namespace. + */ + phpMetadataNamespace: string; + /** + * Use this option to change the package of ruby generated classes. Default + * is empty. When this option is not set, the package name will be used for + * determining the ruby package. + */ + rubyPackage: string; + /** + * The parser stores options it doesn't recognize here. + * See the documentation for the "Options" section above. + */ + uninterpretedOption: UninterpretedOption[]; +} + +/** Generated classes can be optimized for speed or code size. */ +export enum FileOptions_OptimizeMode { + /** SPEED - Generate complete code for parsing, serialization, */ + SPEED = 1, + /** CODE_SIZE - etc. */ + CODE_SIZE = 2, + /** LITE_RUNTIME - Generate code using MessageLite and the lite runtime. */ + LITE_RUNTIME = 3, + UNRECOGNIZED = -1, +} + +export function fileOptions_OptimizeModeFromJSON( + object: any +): FileOptions_OptimizeMode { + switch (object) { + case 1: + case "SPEED": + return FileOptions_OptimizeMode.SPEED; + case 2: + case "CODE_SIZE": + return FileOptions_OptimizeMode.CODE_SIZE; + case 3: + case "LITE_RUNTIME": + return FileOptions_OptimizeMode.LITE_RUNTIME; + case -1: + case "UNRECOGNIZED": + default: + return FileOptions_OptimizeMode.UNRECOGNIZED; + } +} + +export function fileOptions_OptimizeModeToJSON( + object: FileOptions_OptimizeMode +): string { + switch (object) { + case FileOptions_OptimizeMode.SPEED: + return "SPEED"; + case FileOptions_OptimizeMode.CODE_SIZE: + return "CODE_SIZE"; + case FileOptions_OptimizeMode.LITE_RUNTIME: + return "LITE_RUNTIME"; + default: + return "UNKNOWN"; + } +} + +export interface MessageOptions { + /** + * Set true to use the old proto1 MessageSet wire format for extensions. + * This is provided for backwards-compatibility with the MessageSet wire + * format. You should not use this for any other reason: It's less + * efficient, has fewer features, and is more complicated. + * + * The message must be defined exactly as follows: + * message Foo { + * option message_set_wire_format = true; + * extensions 4 to max; + * } + * Note that the message cannot have any defined fields; MessageSets only + * have extensions. + * + * All extensions of your type must be singular messages; e.g. they cannot + * be int32s, enums, or repeated messages. + * + * Because this is an option, the above two restrictions are not enforced by + * the protocol compiler. + */ + messageSetWireFormat: boolean; + /** + * Disables the generation of the standard "descriptor()" accessor, which can + * conflict with a field of the same name. This is meant to make migration + * from proto1 easier; new code should avoid fields named "descriptor". + */ + noStandardDescriptorAccessor: boolean; + /** + * Is this message deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the message, or it will be completely ignored; in the very least, + * this is a formalization for deprecating messages. + */ + deprecated: boolean; + /** + * Whether the message is an automatically generated map entry type for the + * maps field. + * + * For maps fields: + * map map_field = 1; + * The parsed descriptor looks like: + * message MapFieldEntry { + * option map_entry = true; + * optional KeyType key = 1; + * optional ValueType value = 2; + * } + * repeated MapFieldEntry map_field = 1; + * + * Implementations may choose not to generate the map_entry=true message, but + * use a native map in the target language to hold the keys and values. + * The reflection APIs in such implementations still need to work as + * if the field is a repeated message field. + * + * NOTE: Do not set the option in .proto files. Always use the maps syntax + * instead. The option should only be implicitly set by the proto compiler + * parser. + */ + mapEntry: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface FieldOptions { + /** + * The ctype option instructs the C++ code generator to use a different + * representation of the field than it normally would. See the specific + * options below. This option is not yet implemented in the open source + * release -- sorry, we'll try to include it in a future version! + */ + ctype: FieldOptions_CType; + /** + * The packed option can be enabled for repeated primitive fields to enable + * a more efficient representation on the wire. Rather than repeatedly + * writing the tag and type for each element, the entire array is encoded as + * a single length-delimited blob. In proto3, only explicit setting it to + * false will avoid using packed encoding. + */ + packed: boolean; + /** + * The jstype option determines the JavaScript type used for values of the + * field. The option is permitted only for 64 bit integral and fixed types + * (int64, uint64, sint64, fixed64, sfixed64). A field with jstype JS_STRING + * is represented as JavaScript string, which avoids loss of precision that + * can happen when a large value is converted to a floating point JavaScript. + * Specifying JS_NUMBER for the jstype causes the generated JavaScript code to + * use the JavaScript "number" type. The behavior of the default option + * JS_NORMAL is implementation dependent. + * + * This option is an enum to permit additional types to be added, e.g. + * goog.math.Integer. + */ + jstype: FieldOptions_JSType; + /** + * Should this field be parsed lazily? Lazy applies only to message-type + * fields. It means that when the outer message is initially parsed, the + * inner message's contents will not be parsed but instead stored in encoded + * form. The inner message will actually be parsed when it is first accessed. + * + * This is only a hint. Implementations are free to choose whether to use + * eager or lazy parsing regardless of the value of this option. However, + * setting this option true suggests that the protocol author believes that + * using lazy parsing on this field is worth the additional bookkeeping + * overhead typically needed to implement it. + * + * This option does not affect the public interface of any generated code; + * all method signatures remain the same. Furthermore, thread-safety of the + * interface is not affected by this option; const methods remain safe to + * call from multiple threads concurrently, while non-const methods continue + * to require exclusive access. + * + * + * Note that implementations may choose not to check required fields within + * a lazy sub-message. That is, calling IsInitialized() on the outer message + * may return true even if the inner message has missing required fields. + * This is necessary because otherwise the inner message would have to be + * parsed in order to perform the check, defeating the purpose of lazy + * parsing. An implementation which chooses not to check required fields + * must be consistent about it. That is, for any particular sub-message, the + * implementation must either *always* check its required fields, or *never* + * check its required fields, regardless of whether or not the message has + * been parsed. + */ + lazy: boolean; + /** + * Is this field deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for accessors, or it will be completely ignored; in the very least, this + * is a formalization for deprecating fields. + */ + deprecated: boolean; + /** For Google-internal migration only. Do not use. */ + weak: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export enum FieldOptions_CType { + /** STRING - Default mode. */ + STRING = 0, + CORD = 1, + STRING_PIECE = 2, + UNRECOGNIZED = -1, +} + +export function fieldOptions_CTypeFromJSON(object: any): FieldOptions_CType { + switch (object) { + case 0: + case "STRING": + return FieldOptions_CType.STRING; + case 1: + case "CORD": + return FieldOptions_CType.CORD; + case 2: + case "STRING_PIECE": + return FieldOptions_CType.STRING_PIECE; + case -1: + case "UNRECOGNIZED": + default: + return FieldOptions_CType.UNRECOGNIZED; + } +} + +export function fieldOptions_CTypeToJSON(object: FieldOptions_CType): string { + switch (object) { + case FieldOptions_CType.STRING: + return "STRING"; + case FieldOptions_CType.CORD: + return "CORD"; + case FieldOptions_CType.STRING_PIECE: + return "STRING_PIECE"; + default: + return "UNKNOWN"; + } +} + +export enum FieldOptions_JSType { + /** JS_NORMAL - Use the default type. */ + JS_NORMAL = 0, + /** JS_STRING - Use JavaScript strings. */ + JS_STRING = 1, + /** JS_NUMBER - Use JavaScript numbers. */ + JS_NUMBER = 2, + UNRECOGNIZED = -1, +} + +export function fieldOptions_JSTypeFromJSON(object: any): FieldOptions_JSType { + switch (object) { + case 0: + case "JS_NORMAL": + return FieldOptions_JSType.JS_NORMAL; + case 1: + case "JS_STRING": + return FieldOptions_JSType.JS_STRING; + case 2: + case "JS_NUMBER": + return FieldOptions_JSType.JS_NUMBER; + case -1: + case "UNRECOGNIZED": + default: + return FieldOptions_JSType.UNRECOGNIZED; + } +} + +export function fieldOptions_JSTypeToJSON(object: FieldOptions_JSType): string { + switch (object) { + case FieldOptions_JSType.JS_NORMAL: + return "JS_NORMAL"; + case FieldOptions_JSType.JS_STRING: + return "JS_STRING"; + case FieldOptions_JSType.JS_NUMBER: + return "JS_NUMBER"; + default: + return "UNKNOWN"; + } +} + +export interface OneofOptions { + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface EnumOptions { + /** + * Set this option to true to allow mapping different tag names to the same + * value. + */ + allowAlias: boolean; + /** + * Is this enum deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the enum, or it will be completely ignored; in the very least, this + * is a formalization for deprecating enums. + */ + deprecated: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface EnumValueOptions { + /** + * Is this enum value deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the enum value, or it will be completely ignored; in the very least, + * this is a formalization for deprecating enum values. + */ + deprecated: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface ServiceOptions { + /** + * Is this service deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the service, or it will be completely ignored; in the very least, + * this is a formalization for deprecating services. + */ + deprecated: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface MethodOptions { + /** + * Is this method deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the method, or it will be completely ignored; in the very least, + * this is a formalization for deprecating methods. + */ + deprecated: boolean; + idempotencyLevel: MethodOptions_IdempotencyLevel; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +/** + * Is this method side-effect-free (or safe in HTTP parlance), or idempotent, + * or neither? HTTP based RPC implementation may choose GET verb for safe + * methods, and PUT verb for idempotent methods instead of the default POST. + */ +export enum MethodOptions_IdempotencyLevel { + IDEMPOTENCY_UNKNOWN = 0, + /** NO_SIDE_EFFECTS - implies idempotent */ + NO_SIDE_EFFECTS = 1, + /** IDEMPOTENT - idempotent, but may have side effects */ + IDEMPOTENT = 2, + UNRECOGNIZED = -1, +} + +export function methodOptions_IdempotencyLevelFromJSON( + object: any +): MethodOptions_IdempotencyLevel { + switch (object) { + case 0: + case "IDEMPOTENCY_UNKNOWN": + return MethodOptions_IdempotencyLevel.IDEMPOTENCY_UNKNOWN; + case 1: + case "NO_SIDE_EFFECTS": + return MethodOptions_IdempotencyLevel.NO_SIDE_EFFECTS; + case 2: + case "IDEMPOTENT": + return MethodOptions_IdempotencyLevel.IDEMPOTENT; + case -1: + case "UNRECOGNIZED": + default: + return MethodOptions_IdempotencyLevel.UNRECOGNIZED; + } +} + +export function methodOptions_IdempotencyLevelToJSON( + object: MethodOptions_IdempotencyLevel +): string { + switch (object) { + case MethodOptions_IdempotencyLevel.IDEMPOTENCY_UNKNOWN: + return "IDEMPOTENCY_UNKNOWN"; + case MethodOptions_IdempotencyLevel.NO_SIDE_EFFECTS: + return "NO_SIDE_EFFECTS"; + case MethodOptions_IdempotencyLevel.IDEMPOTENT: + return "IDEMPOTENT"; + default: + return "UNKNOWN"; + } +} + +/** + * A message representing a option the parser does not recognize. This only + * appears in options protos created by the compiler::Parser class. + * DescriptorPool resolves these when building Descriptor objects. Therefore, + * options protos in descriptor objects (e.g. returned by Descriptor::options(), + * or produced by Descriptor::CopyTo()) will never have UninterpretedOptions + * in them. + */ +export interface UninterpretedOption { + name: UninterpretedOption_NamePart[]; + /** + * The value of the uninterpreted option, in whatever type the tokenizer + * identified it as during parsing. Exactly one of these should be set. + */ + identifierValue: string; + positiveIntValue: number; + negativeIntValue: number; + doubleValue: number; + stringValue: Uint8Array; + aggregateValue: string; +} + +/** + * The name of the uninterpreted option. Each string represents a segment in + * a dot-separated name. is_extension is true iff a segment represents an + * extension (denoted with parentheses in options specs in .proto files). + * E.g.,{ ["foo", false], ["bar.baz", true], ["qux", false] } represents + * "foo.(bar.baz).qux". + */ +export interface UninterpretedOption_NamePart { + namePart: string; + isExtension: boolean; +} + +/** + * Encapsulates information about the original source file from which a + * FileDescriptorProto was generated. + */ +export interface SourceCodeInfo { + /** + * A Location identifies a piece of source code in a .proto file which + * corresponds to a particular definition. This information is intended + * to be useful to IDEs, code indexers, documentation generators, and similar + * tools. + * + * For example, say we have a file like: + * message Foo { + * optional string foo = 1; + * } + * Let's look at just the field definition: + * optional string foo = 1; + * ^ ^^ ^^ ^ ^^^ + * a bc de f ghi + * We have the following locations: + * span path represents + * [a,i) [ 4, 0, 2, 0 ] The whole field definition. + * [a,b) [ 4, 0, 2, 0, 4 ] The label (optional). + * [c,d) [ 4, 0, 2, 0, 5 ] The type (string). + * [e,f) [ 4, 0, 2, 0, 1 ] The name (foo). + * [g,h) [ 4, 0, 2, 0, 3 ] The number (1). + * + * Notes: + * - A location may refer to a repeated field itself (i.e. not to any + * particular index within it). This is used whenever a set of elements are + * logically enclosed in a single code segment. For example, an entire + * extend block (possibly containing multiple extension definitions) will + * have an outer location whose path refers to the "extensions" repeated + * field without an index. + * - Multiple locations may have the same path. This happens when a single + * logical declaration is spread out across multiple places. The most + * obvious example is the "extend" block again -- there may be multiple + * extend blocks in the same scope, each of which will have the same path. + * - A location's span is not always a subset of its parent's span. For + * example, the "extendee" of an extension declaration appears at the + * beginning of the "extend" block and is shared by all extensions within + * the block. + * - Just because a location's span is a subset of some other location's span + * does not mean that it is a descendant. For example, a "group" defines + * both a type and a field in a single declaration. Thus, the locations + * corresponding to the type and field and their components will overlap. + * - Code which tries to interpret locations should probably be designed to + * ignore those that it doesn't understand, as more types of locations could + * be recorded in the future. + */ + location: SourceCodeInfo_Location[]; +} + +export interface SourceCodeInfo_Location { + /** + * Identifies which part of the FileDescriptorProto was defined at this + * location. + * + * Each element is a field number or an index. They form a path from + * the root FileDescriptorProto to the place where the definition. For + * example, this path: + * [ 4, 3, 2, 7, 1 ] + * refers to: + * file.message_type(3) // 4, 3 + * .field(7) // 2, 7 + * .name() // 1 + * This is because FileDescriptorProto.message_type has field number 4: + * repeated DescriptorProto message_type = 4; + * and DescriptorProto.field has field number 2: + * repeated FieldDescriptorProto field = 2; + * and FieldDescriptorProto.name has field number 1: + * optional string name = 1; + * + * Thus, the above path gives the location of a field name. If we removed + * the last element: + * [ 4, 3, 2, 7 ] + * this path refers to the whole field declaration (from the beginning + * of the label to the terminating semicolon). + */ + path: number[]; + /** + * Always has exactly three or four elements: start line, start column, + * end line (optional, otherwise assumed same as start line), end column. + * These are packed into a single field for efficiency. Note that line + * and column numbers are zero-based -- typically you will want to add + * 1 to each before displaying to a user. + */ + span: number[]; + /** + * If this SourceCodeInfo represents a complete declaration, these are any + * comments appearing before and after the declaration which appear to be + * attached to the declaration. + * + * A series of line comments appearing on consecutive lines, with no other + * tokens appearing on those lines, will be treated as a single comment. + * + * leading_detached_comments will keep paragraphs of comments that appear + * before (but not connected to) the current element. Each paragraph, + * separated by empty lines, will be one comment element in the repeated + * field. + * + * Only the comment content is provided; comment markers (e.g. //) are + * stripped out. For block comments, leading whitespace and an asterisk + * will be stripped from the beginning of each line other than the first. + * Newlines are included in the output. + * + * Examples: + * + * optional int32 foo = 1; // Comment attached to foo. + * // Comment attached to bar. + * optional int32 bar = 2; + * + * optional string baz = 3; + * // Comment attached to baz. + * // Another line attached to baz. + * + * // Comment attached to qux. + * // + * // Another line attached to qux. + * optional double qux = 4; + * + * // Detached comment for corge. This is not leading or trailing comments + * // to qux or corge because there are blank lines separating it from + * // both. + * + * // Detached comment for corge paragraph 2. + * + * optional string corge = 5; + * /* Block comment attached + * * to corge. Leading asterisks + * * will be removed. * / + * /* Block comment attached to + * * grault. * / + * optional int32 grault = 6; + * + * // ignored detached comments. + */ + leadingComments: string; + trailingComments: string; + leadingDetachedComments: string[]; +} + +/** + * Describes the relationship between generated code and its original source + * file. A GeneratedCodeInfo message is associated with only one generated + * source file, but may contain references to different source .proto files. + */ +export interface GeneratedCodeInfo { + /** + * An Annotation connects some span of text in generated code to an element + * of its generating .proto file. + */ + annotation: GeneratedCodeInfo_Annotation[]; +} + +export interface GeneratedCodeInfo_Annotation { + /** + * Identifies the element in the original source .proto file. This field + * is formatted the same as SourceCodeInfo.Location.path. + */ + path: number[]; + /** Identifies the filesystem path to the original source .proto. */ + sourceFile: string; + /** + * Identifies the starting offset in bytes in the generated code + * that relates to the identified object. + */ + begin: number; + /** + * Identifies the ending offset in bytes in the generated code that + * relates to the identified offset. The end offset should be one past + * the last relevant byte (so the length of the text = end - begin). + */ + end: number; +} + +const baseFileDescriptorSet: object = {}; + +export const FileDescriptorSet = { + encode(message: FileDescriptorSet, writer: Writer = Writer.create()): Writer { + for (const v of message.file) { + FileDescriptorProto.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FileDescriptorSet { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFileDescriptorSet } as FileDescriptorSet; + message.file = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.file.push( + FileDescriptorProto.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FileDescriptorSet { + const message = { ...baseFileDescriptorSet } as FileDescriptorSet; + message.file = []; + if (object.file !== undefined && object.file !== null) { + for (const e of object.file) { + message.file.push(FileDescriptorProto.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: FileDescriptorSet): unknown { + const obj: any = {}; + if (message.file) { + obj.file = message.file.map((e) => + e ? FileDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.file = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): FileDescriptorSet { + const message = { ...baseFileDescriptorSet } as FileDescriptorSet; + message.file = []; + if (object.file !== undefined && object.file !== null) { + for (const e of object.file) { + message.file.push(FileDescriptorProto.fromPartial(e)); + } + } + return message; + }, +}; + +const baseFileDescriptorProto: object = { + name: "", + package: "", + dependency: "", + publicDependency: 0, + weakDependency: 0, + syntax: "", +}; + +export const FileDescriptorProto = { + encode( + message: FileDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.package !== "") { + writer.uint32(18).string(message.package); + } + for (const v of message.dependency) { + writer.uint32(26).string(v!); + } + writer.uint32(82).fork(); + for (const v of message.publicDependency) { + writer.int32(v); + } + writer.ldelim(); + writer.uint32(90).fork(); + for (const v of message.weakDependency) { + writer.int32(v); + } + writer.ldelim(); + for (const v of message.messageType) { + DescriptorProto.encode(v!, writer.uint32(34).fork()).ldelim(); + } + for (const v of message.enumType) { + EnumDescriptorProto.encode(v!, writer.uint32(42).fork()).ldelim(); + } + for (const v of message.service) { + ServiceDescriptorProto.encode(v!, writer.uint32(50).fork()).ldelim(); + } + for (const v of message.extension) { + FieldDescriptorProto.encode(v!, writer.uint32(58).fork()).ldelim(); + } + if (message.options !== undefined) { + FileOptions.encode(message.options, writer.uint32(66).fork()).ldelim(); + } + if (message.sourceCodeInfo !== undefined) { + SourceCodeInfo.encode( + message.sourceCodeInfo, + writer.uint32(74).fork() + ).ldelim(); + } + if (message.syntax !== "") { + writer.uint32(98).string(message.syntax); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FileDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFileDescriptorProto } as FileDescriptorProto; + message.dependency = []; + message.publicDependency = []; + message.weakDependency = []; + message.messageType = []; + message.enumType = []; + message.service = []; + message.extension = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.package = reader.string(); + break; + case 3: + message.dependency.push(reader.string()); + break; + case 10: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.publicDependency.push(reader.int32()); + } + } else { + message.publicDependency.push(reader.int32()); + } + break; + case 11: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.weakDependency.push(reader.int32()); + } + } else { + message.weakDependency.push(reader.int32()); + } + break; + case 4: + message.messageType.push( + DescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 5: + message.enumType.push( + EnumDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 6: + message.service.push( + ServiceDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 7: + message.extension.push( + FieldDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 8: + message.options = FileOptions.decode(reader, reader.uint32()); + break; + case 9: + message.sourceCodeInfo = SourceCodeInfo.decode( + reader, + reader.uint32() + ); + break; + case 12: + message.syntax = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FileDescriptorProto { + const message = { ...baseFileDescriptorProto } as FileDescriptorProto; + message.dependency = []; + message.publicDependency = []; + message.weakDependency = []; + message.messageType = []; + message.enumType = []; + message.service = []; + message.extension = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.package !== undefined && object.package !== null) { + message.package = String(object.package); + } else { + message.package = ""; + } + if (object.dependency !== undefined && object.dependency !== null) { + for (const e of object.dependency) { + message.dependency.push(String(e)); + } + } + if ( + object.publicDependency !== undefined && + object.publicDependency !== null + ) { + for (const e of object.publicDependency) { + message.publicDependency.push(Number(e)); + } + } + if (object.weakDependency !== undefined && object.weakDependency !== null) { + for (const e of object.weakDependency) { + message.weakDependency.push(Number(e)); + } + } + if (object.messageType !== undefined && object.messageType !== null) { + for (const e of object.messageType) { + message.messageType.push(DescriptorProto.fromJSON(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromJSON(e)); + } + } + if (object.service !== undefined && object.service !== null) { + for (const e of object.service) { + message.service.push(ServiceDescriptorProto.fromJSON(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = FileOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.sourceCodeInfo !== undefined && object.sourceCodeInfo !== null) { + message.sourceCodeInfo = SourceCodeInfo.fromJSON(object.sourceCodeInfo); + } else { + message.sourceCodeInfo = undefined; + } + if (object.syntax !== undefined && object.syntax !== null) { + message.syntax = String(object.syntax); + } else { + message.syntax = ""; + } + return message; + }, + + toJSON(message: FileDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.package !== undefined && (obj.package = message.package); + if (message.dependency) { + obj.dependency = message.dependency.map((e) => e); + } else { + obj.dependency = []; + } + if (message.publicDependency) { + obj.publicDependency = message.publicDependency.map((e) => e); + } else { + obj.publicDependency = []; + } + if (message.weakDependency) { + obj.weakDependency = message.weakDependency.map((e) => e); + } else { + obj.weakDependency = []; + } + if (message.messageType) { + obj.messageType = message.messageType.map((e) => + e ? DescriptorProto.toJSON(e) : undefined + ); + } else { + obj.messageType = []; + } + if (message.enumType) { + obj.enumType = message.enumType.map((e) => + e ? EnumDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.enumType = []; + } + if (message.service) { + obj.service = message.service.map((e) => + e ? ServiceDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.service = []; + } + if (message.extension) { + obj.extension = message.extension.map((e) => + e ? FieldDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.extension = []; + } + message.options !== undefined && + (obj.options = message.options + ? FileOptions.toJSON(message.options) + : undefined); + message.sourceCodeInfo !== undefined && + (obj.sourceCodeInfo = message.sourceCodeInfo + ? SourceCodeInfo.toJSON(message.sourceCodeInfo) + : undefined); + message.syntax !== undefined && (obj.syntax = message.syntax); + return obj; + }, + + fromPartial(object: DeepPartial): FileDescriptorProto { + const message = { ...baseFileDescriptorProto } as FileDescriptorProto; + message.dependency = []; + message.publicDependency = []; + message.weakDependency = []; + message.messageType = []; + message.enumType = []; + message.service = []; + message.extension = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.package !== undefined && object.package !== null) { + message.package = object.package; + } else { + message.package = ""; + } + if (object.dependency !== undefined && object.dependency !== null) { + for (const e of object.dependency) { + message.dependency.push(e); + } + } + if ( + object.publicDependency !== undefined && + object.publicDependency !== null + ) { + for (const e of object.publicDependency) { + message.publicDependency.push(e); + } + } + if (object.weakDependency !== undefined && object.weakDependency !== null) { + for (const e of object.weakDependency) { + message.weakDependency.push(e); + } + } + if (object.messageType !== undefined && object.messageType !== null) { + for (const e of object.messageType) { + message.messageType.push(DescriptorProto.fromPartial(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromPartial(e)); + } + } + if (object.service !== undefined && object.service !== null) { + for (const e of object.service) { + message.service.push(ServiceDescriptorProto.fromPartial(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = FileOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.sourceCodeInfo !== undefined && object.sourceCodeInfo !== null) { + message.sourceCodeInfo = SourceCodeInfo.fromPartial( + object.sourceCodeInfo + ); + } else { + message.sourceCodeInfo = undefined; + } + if (object.syntax !== undefined && object.syntax !== null) { + message.syntax = object.syntax; + } else { + message.syntax = ""; + } + return message; + }, +}; + +const baseDescriptorProto: object = { name: "", reservedName: "" }; + +export const DescriptorProto = { + encode(message: DescriptorProto, writer: Writer = Writer.create()): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + for (const v of message.field) { + FieldDescriptorProto.encode(v!, writer.uint32(18).fork()).ldelim(); + } + for (const v of message.extension) { + FieldDescriptorProto.encode(v!, writer.uint32(50).fork()).ldelim(); + } + for (const v of message.nestedType) { + DescriptorProto.encode(v!, writer.uint32(26).fork()).ldelim(); + } + for (const v of message.enumType) { + EnumDescriptorProto.encode(v!, writer.uint32(34).fork()).ldelim(); + } + for (const v of message.extensionRange) { + DescriptorProto_ExtensionRange.encode( + v!, + writer.uint32(42).fork() + ).ldelim(); + } + for (const v of message.oneofDecl) { + OneofDescriptorProto.encode(v!, writer.uint32(66).fork()).ldelim(); + } + if (message.options !== undefined) { + MessageOptions.encode(message.options, writer.uint32(58).fork()).ldelim(); + } + for (const v of message.reservedRange) { + DescriptorProto_ReservedRange.encode( + v!, + writer.uint32(74).fork() + ).ldelim(); + } + for (const v of message.reservedName) { + writer.uint32(82).string(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): DescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseDescriptorProto } as DescriptorProto; + message.field = []; + message.extension = []; + message.nestedType = []; + message.enumType = []; + message.extensionRange = []; + message.oneofDecl = []; + message.reservedRange = []; + message.reservedName = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.field.push( + FieldDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 6: + message.extension.push( + FieldDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 3: + message.nestedType.push( + DescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 4: + message.enumType.push( + EnumDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 5: + message.extensionRange.push( + DescriptorProto_ExtensionRange.decode(reader, reader.uint32()) + ); + break; + case 8: + message.oneofDecl.push( + OneofDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 7: + message.options = MessageOptions.decode(reader, reader.uint32()); + break; + case 9: + message.reservedRange.push( + DescriptorProto_ReservedRange.decode(reader, reader.uint32()) + ); + break; + case 10: + message.reservedName.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DescriptorProto { + const message = { ...baseDescriptorProto } as DescriptorProto; + message.field = []; + message.extension = []; + message.nestedType = []; + message.enumType = []; + message.extensionRange = []; + message.oneofDecl = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.field !== undefined && object.field !== null) { + for (const e of object.field) { + message.field.push(FieldDescriptorProto.fromJSON(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromJSON(e)); + } + } + if (object.nestedType !== undefined && object.nestedType !== null) { + for (const e of object.nestedType) { + message.nestedType.push(DescriptorProto.fromJSON(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromJSON(e)); + } + } + if (object.extensionRange !== undefined && object.extensionRange !== null) { + for (const e of object.extensionRange) { + message.extensionRange.push(DescriptorProto_ExtensionRange.fromJSON(e)); + } + } + if (object.oneofDecl !== undefined && object.oneofDecl !== null) { + for (const e of object.oneofDecl) { + message.oneofDecl.push(OneofDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = MessageOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push(DescriptorProto_ReservedRange.fromJSON(e)); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(String(e)); + } + } + return message; + }, + + toJSON(message: DescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + if (message.field) { + obj.field = message.field.map((e) => + e ? FieldDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.field = []; + } + if (message.extension) { + obj.extension = message.extension.map((e) => + e ? FieldDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.extension = []; + } + if (message.nestedType) { + obj.nestedType = message.nestedType.map((e) => + e ? DescriptorProto.toJSON(e) : undefined + ); + } else { + obj.nestedType = []; + } + if (message.enumType) { + obj.enumType = message.enumType.map((e) => + e ? EnumDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.enumType = []; + } + if (message.extensionRange) { + obj.extensionRange = message.extensionRange.map((e) => + e ? DescriptorProto_ExtensionRange.toJSON(e) : undefined + ); + } else { + obj.extensionRange = []; + } + if (message.oneofDecl) { + obj.oneofDecl = message.oneofDecl.map((e) => + e ? OneofDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.oneofDecl = []; + } + message.options !== undefined && + (obj.options = message.options + ? MessageOptions.toJSON(message.options) + : undefined); + if (message.reservedRange) { + obj.reservedRange = message.reservedRange.map((e) => + e ? DescriptorProto_ReservedRange.toJSON(e) : undefined + ); + } else { + obj.reservedRange = []; + } + if (message.reservedName) { + obj.reservedName = message.reservedName.map((e) => e); + } else { + obj.reservedName = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): DescriptorProto { + const message = { ...baseDescriptorProto } as DescriptorProto; + message.field = []; + message.extension = []; + message.nestedType = []; + message.enumType = []; + message.extensionRange = []; + message.oneofDecl = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.field !== undefined && object.field !== null) { + for (const e of object.field) { + message.field.push(FieldDescriptorProto.fromPartial(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromPartial(e)); + } + } + if (object.nestedType !== undefined && object.nestedType !== null) { + for (const e of object.nestedType) { + message.nestedType.push(DescriptorProto.fromPartial(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromPartial(e)); + } + } + if (object.extensionRange !== undefined && object.extensionRange !== null) { + for (const e of object.extensionRange) { + message.extensionRange.push( + DescriptorProto_ExtensionRange.fromPartial(e) + ); + } + } + if (object.oneofDecl !== undefined && object.oneofDecl !== null) { + for (const e of object.oneofDecl) { + message.oneofDecl.push(OneofDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = MessageOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push( + DescriptorProto_ReservedRange.fromPartial(e) + ); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(e); + } + } + return message; + }, +}; + +const baseDescriptorProto_ExtensionRange: object = { start: 0, end: 0 }; + +export const DescriptorProto_ExtensionRange = { + encode( + message: DescriptorProto_ExtensionRange, + writer: Writer = Writer.create() + ): Writer { + if (message.start !== 0) { + writer.uint32(8).int32(message.start); + } + if (message.end !== 0) { + writer.uint32(16).int32(message.end); + } + if (message.options !== undefined) { + ExtensionRangeOptions.encode( + message.options, + writer.uint32(26).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): DescriptorProto_ExtensionRange { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseDescriptorProto_ExtensionRange, + } as DescriptorProto_ExtensionRange; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.start = reader.int32(); + break; + case 2: + message.end = reader.int32(); + break; + case 3: + message.options = ExtensionRangeOptions.decode( + reader, + reader.uint32() + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DescriptorProto_ExtensionRange { + const message = { + ...baseDescriptorProto_ExtensionRange, + } as DescriptorProto_ExtensionRange; + if (object.start !== undefined && object.start !== null) { + message.start = Number(object.start); + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = ExtensionRangeOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: DescriptorProto_ExtensionRange): unknown { + const obj: any = {}; + message.start !== undefined && (obj.start = message.start); + message.end !== undefined && (obj.end = message.end); + message.options !== undefined && + (obj.options = message.options + ? ExtensionRangeOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): DescriptorProto_ExtensionRange { + const message = { + ...baseDescriptorProto_ExtensionRange, + } as DescriptorProto_ExtensionRange; + if (object.start !== undefined && object.start !== null) { + message.start = object.start; + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = ExtensionRangeOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseDescriptorProto_ReservedRange: object = { start: 0, end: 0 }; + +export const DescriptorProto_ReservedRange = { + encode( + message: DescriptorProto_ReservedRange, + writer: Writer = Writer.create() + ): Writer { + if (message.start !== 0) { + writer.uint32(8).int32(message.start); + } + if (message.end !== 0) { + writer.uint32(16).int32(message.end); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): DescriptorProto_ReservedRange { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseDescriptorProto_ReservedRange, + } as DescriptorProto_ReservedRange; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.start = reader.int32(); + break; + case 2: + message.end = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DescriptorProto_ReservedRange { + const message = { + ...baseDescriptorProto_ReservedRange, + } as DescriptorProto_ReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = Number(object.start); + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + return message; + }, + + toJSON(message: DescriptorProto_ReservedRange): unknown { + const obj: any = {}; + message.start !== undefined && (obj.start = message.start); + message.end !== undefined && (obj.end = message.end); + return obj; + }, + + fromPartial( + object: DeepPartial + ): DescriptorProto_ReservedRange { + const message = { + ...baseDescriptorProto_ReservedRange, + } as DescriptorProto_ReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = object.start; + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + return message; + }, +}; + +const baseExtensionRangeOptions: object = {}; + +export const ExtensionRangeOptions = { + encode( + message: ExtensionRangeOptions, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ExtensionRangeOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseExtensionRangeOptions } as ExtensionRangeOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ExtensionRangeOptions { + const message = { ...baseExtensionRangeOptions } as ExtensionRangeOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: ExtensionRangeOptions): unknown { + const obj: any = {}; + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial( + object: DeepPartial + ): ExtensionRangeOptions { + const message = { ...baseExtensionRangeOptions } as ExtensionRangeOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseFieldDescriptorProto: object = { + name: "", + number: 0, + label: 1, + type: 1, + typeName: "", + extendee: "", + defaultValue: "", + oneofIndex: 0, + jsonName: "", + proto3Optional: false, +}; + +export const FieldDescriptorProto = { + encode( + message: FieldDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.number !== 0) { + writer.uint32(24).int32(message.number); + } + if (message.label !== 1) { + writer.uint32(32).int32(message.label); + } + if (message.type !== 1) { + writer.uint32(40).int32(message.type); + } + if (message.typeName !== "") { + writer.uint32(50).string(message.typeName); + } + if (message.extendee !== "") { + writer.uint32(18).string(message.extendee); + } + if (message.defaultValue !== "") { + writer.uint32(58).string(message.defaultValue); + } + if (message.oneofIndex !== 0) { + writer.uint32(72).int32(message.oneofIndex); + } + if (message.jsonName !== "") { + writer.uint32(82).string(message.jsonName); + } + if (message.options !== undefined) { + FieldOptions.encode(message.options, writer.uint32(66).fork()).ldelim(); + } + if (message.proto3Optional === true) { + writer.uint32(136).bool(message.proto3Optional); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FieldDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFieldDescriptorProto } as FieldDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 3: + message.number = reader.int32(); + break; + case 4: + message.label = reader.int32() as any; + break; + case 5: + message.type = reader.int32() as any; + break; + case 6: + message.typeName = reader.string(); + break; + case 2: + message.extendee = reader.string(); + break; + case 7: + message.defaultValue = reader.string(); + break; + case 9: + message.oneofIndex = reader.int32(); + break; + case 10: + message.jsonName = reader.string(); + break; + case 8: + message.options = FieldOptions.decode(reader, reader.uint32()); + break; + case 17: + message.proto3Optional = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FieldDescriptorProto { + const message = { ...baseFieldDescriptorProto } as FieldDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = Number(object.number); + } else { + message.number = 0; + } + if (object.label !== undefined && object.label !== null) { + message.label = fieldDescriptorProto_LabelFromJSON(object.label); + } else { + message.label = 1; + } + if (object.type !== undefined && object.type !== null) { + message.type = fieldDescriptorProto_TypeFromJSON(object.type); + } else { + message.type = 1; + } + if (object.typeName !== undefined && object.typeName !== null) { + message.typeName = String(object.typeName); + } else { + message.typeName = ""; + } + if (object.extendee !== undefined && object.extendee !== null) { + message.extendee = String(object.extendee); + } else { + message.extendee = ""; + } + if (object.defaultValue !== undefined && object.defaultValue !== null) { + message.defaultValue = String(object.defaultValue); + } else { + message.defaultValue = ""; + } + if (object.oneofIndex !== undefined && object.oneofIndex !== null) { + message.oneofIndex = Number(object.oneofIndex); + } else { + message.oneofIndex = 0; + } + if (object.jsonName !== undefined && object.jsonName !== null) { + message.jsonName = String(object.jsonName); + } else { + message.jsonName = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = FieldOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.proto3Optional !== undefined && object.proto3Optional !== null) { + message.proto3Optional = Boolean(object.proto3Optional); + } else { + message.proto3Optional = false; + } + return message; + }, + + toJSON(message: FieldDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.number !== undefined && (obj.number = message.number); + message.label !== undefined && + (obj.label = fieldDescriptorProto_LabelToJSON(message.label)); + message.type !== undefined && + (obj.type = fieldDescriptorProto_TypeToJSON(message.type)); + message.typeName !== undefined && (obj.typeName = message.typeName); + message.extendee !== undefined && (obj.extendee = message.extendee); + message.defaultValue !== undefined && + (obj.defaultValue = message.defaultValue); + message.oneofIndex !== undefined && (obj.oneofIndex = message.oneofIndex); + message.jsonName !== undefined && (obj.jsonName = message.jsonName); + message.options !== undefined && + (obj.options = message.options + ? FieldOptions.toJSON(message.options) + : undefined); + message.proto3Optional !== undefined && + (obj.proto3Optional = message.proto3Optional); + return obj; + }, + + fromPartial(object: DeepPartial): FieldDescriptorProto { + const message = { ...baseFieldDescriptorProto } as FieldDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = object.number; + } else { + message.number = 0; + } + if (object.label !== undefined && object.label !== null) { + message.label = object.label; + } else { + message.label = 1; + } + if (object.type !== undefined && object.type !== null) { + message.type = object.type; + } else { + message.type = 1; + } + if (object.typeName !== undefined && object.typeName !== null) { + message.typeName = object.typeName; + } else { + message.typeName = ""; + } + if (object.extendee !== undefined && object.extendee !== null) { + message.extendee = object.extendee; + } else { + message.extendee = ""; + } + if (object.defaultValue !== undefined && object.defaultValue !== null) { + message.defaultValue = object.defaultValue; + } else { + message.defaultValue = ""; + } + if (object.oneofIndex !== undefined && object.oneofIndex !== null) { + message.oneofIndex = object.oneofIndex; + } else { + message.oneofIndex = 0; + } + if (object.jsonName !== undefined && object.jsonName !== null) { + message.jsonName = object.jsonName; + } else { + message.jsonName = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = FieldOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.proto3Optional !== undefined && object.proto3Optional !== null) { + message.proto3Optional = object.proto3Optional; + } else { + message.proto3Optional = false; + } + return message; + }, +}; + +const baseOneofDescriptorProto: object = { name: "" }; + +export const OneofDescriptorProto = { + encode( + message: OneofDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.options !== undefined) { + OneofOptions.encode(message.options, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): OneofDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseOneofDescriptorProto } as OneofDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.options = OneofOptions.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): OneofDescriptorProto { + const message = { ...baseOneofDescriptorProto } as OneofDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = OneofOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: OneofDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.options !== undefined && + (obj.options = message.options + ? OneofOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): OneofDescriptorProto { + const message = { ...baseOneofDescriptorProto } as OneofDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = OneofOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseEnumDescriptorProto: object = { name: "", reservedName: "" }; + +export const EnumDescriptorProto = { + encode( + message: EnumDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + for (const v of message.value) { + EnumValueDescriptorProto.encode(v!, writer.uint32(18).fork()).ldelim(); + } + if (message.options !== undefined) { + EnumOptions.encode(message.options, writer.uint32(26).fork()).ldelim(); + } + for (const v of message.reservedRange) { + EnumDescriptorProto_EnumReservedRange.encode( + v!, + writer.uint32(34).fork() + ).ldelim(); + } + for (const v of message.reservedName) { + writer.uint32(42).string(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): EnumDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseEnumDescriptorProto } as EnumDescriptorProto; + message.value = []; + message.reservedRange = []; + message.reservedName = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.value.push( + EnumValueDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 3: + message.options = EnumOptions.decode(reader, reader.uint32()); + break; + case 4: + message.reservedRange.push( + EnumDescriptorProto_EnumReservedRange.decode( + reader, + reader.uint32() + ) + ); + break; + case 5: + message.reservedName.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumDescriptorProto { + const message = { ...baseEnumDescriptorProto } as EnumDescriptorProto; + message.value = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.value !== undefined && object.value !== null) { + for (const e of object.value) { + message.value.push(EnumValueDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push( + EnumDescriptorProto_EnumReservedRange.fromJSON(e) + ); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(String(e)); + } + } + return message; + }, + + toJSON(message: EnumDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + if (message.value) { + obj.value = message.value.map((e) => + e ? EnumValueDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.value = []; + } + message.options !== undefined && + (obj.options = message.options + ? EnumOptions.toJSON(message.options) + : undefined); + if (message.reservedRange) { + obj.reservedRange = message.reservedRange.map((e) => + e ? EnumDescriptorProto_EnumReservedRange.toJSON(e) : undefined + ); + } else { + obj.reservedRange = []; + } + if (message.reservedName) { + obj.reservedName = message.reservedName.map((e) => e); + } else { + obj.reservedName = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): EnumDescriptorProto { + const message = { ...baseEnumDescriptorProto } as EnumDescriptorProto; + message.value = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.value !== undefined && object.value !== null) { + for (const e of object.value) { + message.value.push(EnumValueDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push( + EnumDescriptorProto_EnumReservedRange.fromPartial(e) + ); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(e); + } + } + return message; + }, +}; + +const baseEnumDescriptorProto_EnumReservedRange: object = { start: 0, end: 0 }; + +export const EnumDescriptorProto_EnumReservedRange = { + encode( + message: EnumDescriptorProto_EnumReservedRange, + writer: Writer = Writer.create() + ): Writer { + if (message.start !== 0) { + writer.uint32(8).int32(message.start); + } + if (message.end !== 0) { + writer.uint32(16).int32(message.end); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): EnumDescriptorProto_EnumReservedRange { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseEnumDescriptorProto_EnumReservedRange, + } as EnumDescriptorProto_EnumReservedRange; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.start = reader.int32(); + break; + case 2: + message.end = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumDescriptorProto_EnumReservedRange { + const message = { + ...baseEnumDescriptorProto_EnumReservedRange, + } as EnumDescriptorProto_EnumReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = Number(object.start); + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + return message; + }, + + toJSON(message: EnumDescriptorProto_EnumReservedRange): unknown { + const obj: any = {}; + message.start !== undefined && (obj.start = message.start); + message.end !== undefined && (obj.end = message.end); + return obj; + }, + + fromPartial( + object: DeepPartial + ): EnumDescriptorProto_EnumReservedRange { + const message = { + ...baseEnumDescriptorProto_EnumReservedRange, + } as EnumDescriptorProto_EnumReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = object.start; + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + return message; + }, +}; + +const baseEnumValueDescriptorProto: object = { name: "", number: 0 }; + +export const EnumValueDescriptorProto = { + encode( + message: EnumValueDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.number !== 0) { + writer.uint32(16).int32(message.number); + } + if (message.options !== undefined) { + EnumValueOptions.encode( + message.options, + writer.uint32(26).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): EnumValueDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseEnumValueDescriptorProto, + } as EnumValueDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.number = reader.int32(); + break; + case 3: + message.options = EnumValueOptions.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumValueDescriptorProto { + const message = { + ...baseEnumValueDescriptorProto, + } as EnumValueDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = Number(object.number); + } else { + message.number = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumValueOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: EnumValueDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.number !== undefined && (obj.number = message.number); + message.options !== undefined && + (obj.options = message.options + ? EnumValueOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): EnumValueDescriptorProto { + const message = { + ...baseEnumValueDescriptorProto, + } as EnumValueDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = object.number; + } else { + message.number = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumValueOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseServiceDescriptorProto: object = { name: "" }; + +export const ServiceDescriptorProto = { + encode( + message: ServiceDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + for (const v of message.method) { + MethodDescriptorProto.encode(v!, writer.uint32(18).fork()).ldelim(); + } + if (message.options !== undefined) { + ServiceOptions.encode(message.options, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ServiceDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseServiceDescriptorProto } as ServiceDescriptorProto; + message.method = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.method.push( + MethodDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 3: + message.options = ServiceOptions.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ServiceDescriptorProto { + const message = { ...baseServiceDescriptorProto } as ServiceDescriptorProto; + message.method = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.method !== undefined && object.method !== null) { + for (const e of object.method) { + message.method.push(MethodDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = ServiceOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: ServiceDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + if (message.method) { + obj.method = message.method.map((e) => + e ? MethodDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.method = []; + } + message.options !== undefined && + (obj.options = message.options + ? ServiceOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): ServiceDescriptorProto { + const message = { ...baseServiceDescriptorProto } as ServiceDescriptorProto; + message.method = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.method !== undefined && object.method !== null) { + for (const e of object.method) { + message.method.push(MethodDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = ServiceOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseMethodDescriptorProto: object = { + name: "", + inputType: "", + outputType: "", + clientStreaming: false, + serverStreaming: false, +}; + +export const MethodDescriptorProto = { + encode( + message: MethodDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.inputType !== "") { + writer.uint32(18).string(message.inputType); + } + if (message.outputType !== "") { + writer.uint32(26).string(message.outputType); + } + if (message.options !== undefined) { + MethodOptions.encode(message.options, writer.uint32(34).fork()).ldelim(); + } + if (message.clientStreaming === true) { + writer.uint32(40).bool(message.clientStreaming); + } + if (message.serverStreaming === true) { + writer.uint32(48).bool(message.serverStreaming); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MethodDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMethodDescriptorProto } as MethodDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.inputType = reader.string(); + break; + case 3: + message.outputType = reader.string(); + break; + case 4: + message.options = MethodOptions.decode(reader, reader.uint32()); + break; + case 5: + message.clientStreaming = reader.bool(); + break; + case 6: + message.serverStreaming = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MethodDescriptorProto { + const message = { ...baseMethodDescriptorProto } as MethodDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.inputType !== undefined && object.inputType !== null) { + message.inputType = String(object.inputType); + } else { + message.inputType = ""; + } + if (object.outputType !== undefined && object.outputType !== null) { + message.outputType = String(object.outputType); + } else { + message.outputType = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = MethodOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if ( + object.clientStreaming !== undefined && + object.clientStreaming !== null + ) { + message.clientStreaming = Boolean(object.clientStreaming); + } else { + message.clientStreaming = false; + } + if ( + object.serverStreaming !== undefined && + object.serverStreaming !== null + ) { + message.serverStreaming = Boolean(object.serverStreaming); + } else { + message.serverStreaming = false; + } + return message; + }, + + toJSON(message: MethodDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.inputType !== undefined && (obj.inputType = message.inputType); + message.outputType !== undefined && (obj.outputType = message.outputType); + message.options !== undefined && + (obj.options = message.options + ? MethodOptions.toJSON(message.options) + : undefined); + message.clientStreaming !== undefined && + (obj.clientStreaming = message.clientStreaming); + message.serverStreaming !== undefined && + (obj.serverStreaming = message.serverStreaming); + return obj; + }, + + fromPartial( + object: DeepPartial + ): MethodDescriptorProto { + const message = { ...baseMethodDescriptorProto } as MethodDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.inputType !== undefined && object.inputType !== null) { + message.inputType = object.inputType; + } else { + message.inputType = ""; + } + if (object.outputType !== undefined && object.outputType !== null) { + message.outputType = object.outputType; + } else { + message.outputType = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = MethodOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if ( + object.clientStreaming !== undefined && + object.clientStreaming !== null + ) { + message.clientStreaming = object.clientStreaming; + } else { + message.clientStreaming = false; + } + if ( + object.serverStreaming !== undefined && + object.serverStreaming !== null + ) { + message.serverStreaming = object.serverStreaming; + } else { + message.serverStreaming = false; + } + return message; + }, +}; + +const baseFileOptions: object = { + javaPackage: "", + javaOuterClassname: "", + javaMultipleFiles: false, + javaGenerateEqualsAndHash: false, + javaStringCheckUtf8: false, + optimizeFor: 1, + goPackage: "", + ccGenericServices: false, + javaGenericServices: false, + pyGenericServices: false, + phpGenericServices: false, + deprecated: false, + ccEnableArenas: false, + objcClassPrefix: "", + csharpNamespace: "", + swiftPrefix: "", + phpClassPrefix: "", + phpNamespace: "", + phpMetadataNamespace: "", + rubyPackage: "", +}; + +export const FileOptions = { + encode(message: FileOptions, writer: Writer = Writer.create()): Writer { + if (message.javaPackage !== "") { + writer.uint32(10).string(message.javaPackage); + } + if (message.javaOuterClassname !== "") { + writer.uint32(66).string(message.javaOuterClassname); + } + if (message.javaMultipleFiles === true) { + writer.uint32(80).bool(message.javaMultipleFiles); + } + if (message.javaGenerateEqualsAndHash === true) { + writer.uint32(160).bool(message.javaGenerateEqualsAndHash); + } + if (message.javaStringCheckUtf8 === true) { + writer.uint32(216).bool(message.javaStringCheckUtf8); + } + if (message.optimizeFor !== 1) { + writer.uint32(72).int32(message.optimizeFor); + } + if (message.goPackage !== "") { + writer.uint32(90).string(message.goPackage); + } + if (message.ccGenericServices === true) { + writer.uint32(128).bool(message.ccGenericServices); + } + if (message.javaGenericServices === true) { + writer.uint32(136).bool(message.javaGenericServices); + } + if (message.pyGenericServices === true) { + writer.uint32(144).bool(message.pyGenericServices); + } + if (message.phpGenericServices === true) { + writer.uint32(336).bool(message.phpGenericServices); + } + if (message.deprecated === true) { + writer.uint32(184).bool(message.deprecated); + } + if (message.ccEnableArenas === true) { + writer.uint32(248).bool(message.ccEnableArenas); + } + if (message.objcClassPrefix !== "") { + writer.uint32(290).string(message.objcClassPrefix); + } + if (message.csharpNamespace !== "") { + writer.uint32(298).string(message.csharpNamespace); + } + if (message.swiftPrefix !== "") { + writer.uint32(314).string(message.swiftPrefix); + } + if (message.phpClassPrefix !== "") { + writer.uint32(322).string(message.phpClassPrefix); + } + if (message.phpNamespace !== "") { + writer.uint32(330).string(message.phpNamespace); + } + if (message.phpMetadataNamespace !== "") { + writer.uint32(354).string(message.phpMetadataNamespace); + } + if (message.rubyPackage !== "") { + writer.uint32(362).string(message.rubyPackage); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FileOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFileOptions } as FileOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.javaPackage = reader.string(); + break; + case 8: + message.javaOuterClassname = reader.string(); + break; + case 10: + message.javaMultipleFiles = reader.bool(); + break; + case 20: + message.javaGenerateEqualsAndHash = reader.bool(); + break; + case 27: + message.javaStringCheckUtf8 = reader.bool(); + break; + case 9: + message.optimizeFor = reader.int32() as any; + break; + case 11: + message.goPackage = reader.string(); + break; + case 16: + message.ccGenericServices = reader.bool(); + break; + case 17: + message.javaGenericServices = reader.bool(); + break; + case 18: + message.pyGenericServices = reader.bool(); + break; + case 42: + message.phpGenericServices = reader.bool(); + break; + case 23: + message.deprecated = reader.bool(); + break; + case 31: + message.ccEnableArenas = reader.bool(); + break; + case 36: + message.objcClassPrefix = reader.string(); + break; + case 37: + message.csharpNamespace = reader.string(); + break; + case 39: + message.swiftPrefix = reader.string(); + break; + case 40: + message.phpClassPrefix = reader.string(); + break; + case 41: + message.phpNamespace = reader.string(); + break; + case 44: + message.phpMetadataNamespace = reader.string(); + break; + case 45: + message.rubyPackage = reader.string(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FileOptions { + const message = { ...baseFileOptions } as FileOptions; + message.uninterpretedOption = []; + if (object.javaPackage !== undefined && object.javaPackage !== null) { + message.javaPackage = String(object.javaPackage); + } else { + message.javaPackage = ""; + } + if ( + object.javaOuterClassname !== undefined && + object.javaOuterClassname !== null + ) { + message.javaOuterClassname = String(object.javaOuterClassname); + } else { + message.javaOuterClassname = ""; + } + if ( + object.javaMultipleFiles !== undefined && + object.javaMultipleFiles !== null + ) { + message.javaMultipleFiles = Boolean(object.javaMultipleFiles); + } else { + message.javaMultipleFiles = false; + } + if ( + object.javaGenerateEqualsAndHash !== undefined && + object.javaGenerateEqualsAndHash !== null + ) { + message.javaGenerateEqualsAndHash = Boolean( + object.javaGenerateEqualsAndHash + ); + } else { + message.javaGenerateEqualsAndHash = false; + } + if ( + object.javaStringCheckUtf8 !== undefined && + object.javaStringCheckUtf8 !== null + ) { + message.javaStringCheckUtf8 = Boolean(object.javaStringCheckUtf8); + } else { + message.javaStringCheckUtf8 = false; + } + if (object.optimizeFor !== undefined && object.optimizeFor !== null) { + message.optimizeFor = fileOptions_OptimizeModeFromJSON( + object.optimizeFor + ); + } else { + message.optimizeFor = 1; + } + if (object.goPackage !== undefined && object.goPackage !== null) { + message.goPackage = String(object.goPackage); + } else { + message.goPackage = ""; + } + if ( + object.ccGenericServices !== undefined && + object.ccGenericServices !== null + ) { + message.ccGenericServices = Boolean(object.ccGenericServices); + } else { + message.ccGenericServices = false; + } + if ( + object.javaGenericServices !== undefined && + object.javaGenericServices !== null + ) { + message.javaGenericServices = Boolean(object.javaGenericServices); + } else { + message.javaGenericServices = false; + } + if ( + object.pyGenericServices !== undefined && + object.pyGenericServices !== null + ) { + message.pyGenericServices = Boolean(object.pyGenericServices); + } else { + message.pyGenericServices = false; + } + if ( + object.phpGenericServices !== undefined && + object.phpGenericServices !== null + ) { + message.phpGenericServices = Boolean(object.phpGenericServices); + } else { + message.phpGenericServices = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if (object.ccEnableArenas !== undefined && object.ccEnableArenas !== null) { + message.ccEnableArenas = Boolean(object.ccEnableArenas); + } else { + message.ccEnableArenas = false; + } + if ( + object.objcClassPrefix !== undefined && + object.objcClassPrefix !== null + ) { + message.objcClassPrefix = String(object.objcClassPrefix); + } else { + message.objcClassPrefix = ""; + } + if ( + object.csharpNamespace !== undefined && + object.csharpNamespace !== null + ) { + message.csharpNamespace = String(object.csharpNamespace); + } else { + message.csharpNamespace = ""; + } + if (object.swiftPrefix !== undefined && object.swiftPrefix !== null) { + message.swiftPrefix = String(object.swiftPrefix); + } else { + message.swiftPrefix = ""; + } + if (object.phpClassPrefix !== undefined && object.phpClassPrefix !== null) { + message.phpClassPrefix = String(object.phpClassPrefix); + } else { + message.phpClassPrefix = ""; + } + if (object.phpNamespace !== undefined && object.phpNamespace !== null) { + message.phpNamespace = String(object.phpNamespace); + } else { + message.phpNamespace = ""; + } + if ( + object.phpMetadataNamespace !== undefined && + object.phpMetadataNamespace !== null + ) { + message.phpMetadataNamespace = String(object.phpMetadataNamespace); + } else { + message.phpMetadataNamespace = ""; + } + if (object.rubyPackage !== undefined && object.rubyPackage !== null) { + message.rubyPackage = String(object.rubyPackage); + } else { + message.rubyPackage = ""; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: FileOptions): unknown { + const obj: any = {}; + message.javaPackage !== undefined && + (obj.javaPackage = message.javaPackage); + message.javaOuterClassname !== undefined && + (obj.javaOuterClassname = message.javaOuterClassname); + message.javaMultipleFiles !== undefined && + (obj.javaMultipleFiles = message.javaMultipleFiles); + message.javaGenerateEqualsAndHash !== undefined && + (obj.javaGenerateEqualsAndHash = message.javaGenerateEqualsAndHash); + message.javaStringCheckUtf8 !== undefined && + (obj.javaStringCheckUtf8 = message.javaStringCheckUtf8); + message.optimizeFor !== undefined && + (obj.optimizeFor = fileOptions_OptimizeModeToJSON(message.optimizeFor)); + message.goPackage !== undefined && (obj.goPackage = message.goPackage); + message.ccGenericServices !== undefined && + (obj.ccGenericServices = message.ccGenericServices); + message.javaGenericServices !== undefined && + (obj.javaGenericServices = message.javaGenericServices); + message.pyGenericServices !== undefined && + (obj.pyGenericServices = message.pyGenericServices); + message.phpGenericServices !== undefined && + (obj.phpGenericServices = message.phpGenericServices); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.ccEnableArenas !== undefined && + (obj.ccEnableArenas = message.ccEnableArenas); + message.objcClassPrefix !== undefined && + (obj.objcClassPrefix = message.objcClassPrefix); + message.csharpNamespace !== undefined && + (obj.csharpNamespace = message.csharpNamespace); + message.swiftPrefix !== undefined && + (obj.swiftPrefix = message.swiftPrefix); + message.phpClassPrefix !== undefined && + (obj.phpClassPrefix = message.phpClassPrefix); + message.phpNamespace !== undefined && + (obj.phpNamespace = message.phpNamespace); + message.phpMetadataNamespace !== undefined && + (obj.phpMetadataNamespace = message.phpMetadataNamespace); + message.rubyPackage !== undefined && + (obj.rubyPackage = message.rubyPackage); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): FileOptions { + const message = { ...baseFileOptions } as FileOptions; + message.uninterpretedOption = []; + if (object.javaPackage !== undefined && object.javaPackage !== null) { + message.javaPackage = object.javaPackage; + } else { + message.javaPackage = ""; + } + if ( + object.javaOuterClassname !== undefined && + object.javaOuterClassname !== null + ) { + message.javaOuterClassname = object.javaOuterClassname; + } else { + message.javaOuterClassname = ""; + } + if ( + object.javaMultipleFiles !== undefined && + object.javaMultipleFiles !== null + ) { + message.javaMultipleFiles = object.javaMultipleFiles; + } else { + message.javaMultipleFiles = false; + } + if ( + object.javaGenerateEqualsAndHash !== undefined && + object.javaGenerateEqualsAndHash !== null + ) { + message.javaGenerateEqualsAndHash = object.javaGenerateEqualsAndHash; + } else { + message.javaGenerateEqualsAndHash = false; + } + if ( + object.javaStringCheckUtf8 !== undefined && + object.javaStringCheckUtf8 !== null + ) { + message.javaStringCheckUtf8 = object.javaStringCheckUtf8; + } else { + message.javaStringCheckUtf8 = false; + } + if (object.optimizeFor !== undefined && object.optimizeFor !== null) { + message.optimizeFor = object.optimizeFor; + } else { + message.optimizeFor = 1; + } + if (object.goPackage !== undefined && object.goPackage !== null) { + message.goPackage = object.goPackage; + } else { + message.goPackage = ""; + } + if ( + object.ccGenericServices !== undefined && + object.ccGenericServices !== null + ) { + message.ccGenericServices = object.ccGenericServices; + } else { + message.ccGenericServices = false; + } + if ( + object.javaGenericServices !== undefined && + object.javaGenericServices !== null + ) { + message.javaGenericServices = object.javaGenericServices; + } else { + message.javaGenericServices = false; + } + if ( + object.pyGenericServices !== undefined && + object.pyGenericServices !== null + ) { + message.pyGenericServices = object.pyGenericServices; + } else { + message.pyGenericServices = false; + } + if ( + object.phpGenericServices !== undefined && + object.phpGenericServices !== null + ) { + message.phpGenericServices = object.phpGenericServices; + } else { + message.phpGenericServices = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if (object.ccEnableArenas !== undefined && object.ccEnableArenas !== null) { + message.ccEnableArenas = object.ccEnableArenas; + } else { + message.ccEnableArenas = false; + } + if ( + object.objcClassPrefix !== undefined && + object.objcClassPrefix !== null + ) { + message.objcClassPrefix = object.objcClassPrefix; + } else { + message.objcClassPrefix = ""; + } + if ( + object.csharpNamespace !== undefined && + object.csharpNamespace !== null + ) { + message.csharpNamespace = object.csharpNamespace; + } else { + message.csharpNamespace = ""; + } + if (object.swiftPrefix !== undefined && object.swiftPrefix !== null) { + message.swiftPrefix = object.swiftPrefix; + } else { + message.swiftPrefix = ""; + } + if (object.phpClassPrefix !== undefined && object.phpClassPrefix !== null) { + message.phpClassPrefix = object.phpClassPrefix; + } else { + message.phpClassPrefix = ""; + } + if (object.phpNamespace !== undefined && object.phpNamespace !== null) { + message.phpNamespace = object.phpNamespace; + } else { + message.phpNamespace = ""; + } + if ( + object.phpMetadataNamespace !== undefined && + object.phpMetadataNamespace !== null + ) { + message.phpMetadataNamespace = object.phpMetadataNamespace; + } else { + message.phpMetadataNamespace = ""; + } + if (object.rubyPackage !== undefined && object.rubyPackage !== null) { + message.rubyPackage = object.rubyPackage; + } else { + message.rubyPackage = ""; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseMessageOptions: object = { + messageSetWireFormat: false, + noStandardDescriptorAccessor: false, + deprecated: false, + mapEntry: false, +}; + +export const MessageOptions = { + encode(message: MessageOptions, writer: Writer = Writer.create()): Writer { + if (message.messageSetWireFormat === true) { + writer.uint32(8).bool(message.messageSetWireFormat); + } + if (message.noStandardDescriptorAccessor === true) { + writer.uint32(16).bool(message.noStandardDescriptorAccessor); + } + if (message.deprecated === true) { + writer.uint32(24).bool(message.deprecated); + } + if (message.mapEntry === true) { + writer.uint32(56).bool(message.mapEntry); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MessageOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMessageOptions } as MessageOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.messageSetWireFormat = reader.bool(); + break; + case 2: + message.noStandardDescriptorAccessor = reader.bool(); + break; + case 3: + message.deprecated = reader.bool(); + break; + case 7: + message.mapEntry = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MessageOptions { + const message = { ...baseMessageOptions } as MessageOptions; + message.uninterpretedOption = []; + if ( + object.messageSetWireFormat !== undefined && + object.messageSetWireFormat !== null + ) { + message.messageSetWireFormat = Boolean(object.messageSetWireFormat); + } else { + message.messageSetWireFormat = false; + } + if ( + object.noStandardDescriptorAccessor !== undefined && + object.noStandardDescriptorAccessor !== null + ) { + message.noStandardDescriptorAccessor = Boolean( + object.noStandardDescriptorAccessor + ); + } else { + message.noStandardDescriptorAccessor = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if (object.mapEntry !== undefined && object.mapEntry !== null) { + message.mapEntry = Boolean(object.mapEntry); + } else { + message.mapEntry = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: MessageOptions): unknown { + const obj: any = {}; + message.messageSetWireFormat !== undefined && + (obj.messageSetWireFormat = message.messageSetWireFormat); + message.noStandardDescriptorAccessor !== undefined && + (obj.noStandardDescriptorAccessor = message.noStandardDescriptorAccessor); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.mapEntry !== undefined && (obj.mapEntry = message.mapEntry); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): MessageOptions { + const message = { ...baseMessageOptions } as MessageOptions; + message.uninterpretedOption = []; + if ( + object.messageSetWireFormat !== undefined && + object.messageSetWireFormat !== null + ) { + message.messageSetWireFormat = object.messageSetWireFormat; + } else { + message.messageSetWireFormat = false; + } + if ( + object.noStandardDescriptorAccessor !== undefined && + object.noStandardDescriptorAccessor !== null + ) { + message.noStandardDescriptorAccessor = + object.noStandardDescriptorAccessor; + } else { + message.noStandardDescriptorAccessor = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if (object.mapEntry !== undefined && object.mapEntry !== null) { + message.mapEntry = object.mapEntry; + } else { + message.mapEntry = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseFieldOptions: object = { + ctype: 0, + packed: false, + jstype: 0, + lazy: false, + deprecated: false, + weak: false, +}; + +export const FieldOptions = { + encode(message: FieldOptions, writer: Writer = Writer.create()): Writer { + if (message.ctype !== 0) { + writer.uint32(8).int32(message.ctype); + } + if (message.packed === true) { + writer.uint32(16).bool(message.packed); + } + if (message.jstype !== 0) { + writer.uint32(48).int32(message.jstype); + } + if (message.lazy === true) { + writer.uint32(40).bool(message.lazy); + } + if (message.deprecated === true) { + writer.uint32(24).bool(message.deprecated); + } + if (message.weak === true) { + writer.uint32(80).bool(message.weak); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FieldOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFieldOptions } as FieldOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.ctype = reader.int32() as any; + break; + case 2: + message.packed = reader.bool(); + break; + case 6: + message.jstype = reader.int32() as any; + break; + case 5: + message.lazy = reader.bool(); + break; + case 3: + message.deprecated = reader.bool(); + break; + case 10: + message.weak = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FieldOptions { + const message = { ...baseFieldOptions } as FieldOptions; + message.uninterpretedOption = []; + if (object.ctype !== undefined && object.ctype !== null) { + message.ctype = fieldOptions_CTypeFromJSON(object.ctype); + } else { + message.ctype = 0; + } + if (object.packed !== undefined && object.packed !== null) { + message.packed = Boolean(object.packed); + } else { + message.packed = false; + } + if (object.jstype !== undefined && object.jstype !== null) { + message.jstype = fieldOptions_JSTypeFromJSON(object.jstype); + } else { + message.jstype = 0; + } + if (object.lazy !== undefined && object.lazy !== null) { + message.lazy = Boolean(object.lazy); + } else { + message.lazy = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if (object.weak !== undefined && object.weak !== null) { + message.weak = Boolean(object.weak); + } else { + message.weak = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: FieldOptions): unknown { + const obj: any = {}; + message.ctype !== undefined && + (obj.ctype = fieldOptions_CTypeToJSON(message.ctype)); + message.packed !== undefined && (obj.packed = message.packed); + message.jstype !== undefined && + (obj.jstype = fieldOptions_JSTypeToJSON(message.jstype)); + message.lazy !== undefined && (obj.lazy = message.lazy); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.weak !== undefined && (obj.weak = message.weak); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): FieldOptions { + const message = { ...baseFieldOptions } as FieldOptions; + message.uninterpretedOption = []; + if (object.ctype !== undefined && object.ctype !== null) { + message.ctype = object.ctype; + } else { + message.ctype = 0; + } + if (object.packed !== undefined && object.packed !== null) { + message.packed = object.packed; + } else { + message.packed = false; + } + if (object.jstype !== undefined && object.jstype !== null) { + message.jstype = object.jstype; + } else { + message.jstype = 0; + } + if (object.lazy !== undefined && object.lazy !== null) { + message.lazy = object.lazy; + } else { + message.lazy = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if (object.weak !== undefined && object.weak !== null) { + message.weak = object.weak; + } else { + message.weak = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseOneofOptions: object = {}; + +export const OneofOptions = { + encode(message: OneofOptions, writer: Writer = Writer.create()): Writer { + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): OneofOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseOneofOptions } as OneofOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): OneofOptions { + const message = { ...baseOneofOptions } as OneofOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: OneofOptions): unknown { + const obj: any = {}; + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): OneofOptions { + const message = { ...baseOneofOptions } as OneofOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseEnumOptions: object = { allowAlias: false, deprecated: false }; + +export const EnumOptions = { + encode(message: EnumOptions, writer: Writer = Writer.create()): Writer { + if (message.allowAlias === true) { + writer.uint32(16).bool(message.allowAlias); + } + if (message.deprecated === true) { + writer.uint32(24).bool(message.deprecated); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): EnumOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseEnumOptions } as EnumOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + message.allowAlias = reader.bool(); + break; + case 3: + message.deprecated = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumOptions { + const message = { ...baseEnumOptions } as EnumOptions; + message.uninterpretedOption = []; + if (object.allowAlias !== undefined && object.allowAlias !== null) { + message.allowAlias = Boolean(object.allowAlias); + } else { + message.allowAlias = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: EnumOptions): unknown { + const obj: any = {}; + message.allowAlias !== undefined && (obj.allowAlias = message.allowAlias); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): EnumOptions { + const message = { ...baseEnumOptions } as EnumOptions; + message.uninterpretedOption = []; + if (object.allowAlias !== undefined && object.allowAlias !== null) { + message.allowAlias = object.allowAlias; + } else { + message.allowAlias = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseEnumValueOptions: object = { deprecated: false }; + +export const EnumValueOptions = { + encode(message: EnumValueOptions, writer: Writer = Writer.create()): Writer { + if (message.deprecated === true) { + writer.uint32(8).bool(message.deprecated); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): EnumValueOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseEnumValueOptions } as EnumValueOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.deprecated = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumValueOptions { + const message = { ...baseEnumValueOptions } as EnumValueOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: EnumValueOptions): unknown { + const obj: any = {}; + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): EnumValueOptions { + const message = { ...baseEnumValueOptions } as EnumValueOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseServiceOptions: object = { deprecated: false }; + +export const ServiceOptions = { + encode(message: ServiceOptions, writer: Writer = Writer.create()): Writer { + if (message.deprecated === true) { + writer.uint32(264).bool(message.deprecated); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ServiceOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseServiceOptions } as ServiceOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 33: + message.deprecated = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ServiceOptions { + const message = { ...baseServiceOptions } as ServiceOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: ServiceOptions): unknown { + const obj: any = {}; + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): ServiceOptions { + const message = { ...baseServiceOptions } as ServiceOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseMethodOptions: object = { deprecated: false, idempotencyLevel: 0 }; + +export const MethodOptions = { + encode(message: MethodOptions, writer: Writer = Writer.create()): Writer { + if (message.deprecated === true) { + writer.uint32(264).bool(message.deprecated); + } + if (message.idempotencyLevel !== 0) { + writer.uint32(272).int32(message.idempotencyLevel); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MethodOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMethodOptions } as MethodOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 33: + message.deprecated = reader.bool(); + break; + case 34: + message.idempotencyLevel = reader.int32() as any; + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MethodOptions { + const message = { ...baseMethodOptions } as MethodOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.idempotencyLevel !== undefined && + object.idempotencyLevel !== null + ) { + message.idempotencyLevel = methodOptions_IdempotencyLevelFromJSON( + object.idempotencyLevel + ); + } else { + message.idempotencyLevel = 0; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: MethodOptions): unknown { + const obj: any = {}; + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.idempotencyLevel !== undefined && + (obj.idempotencyLevel = methodOptions_IdempotencyLevelToJSON( + message.idempotencyLevel + )); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): MethodOptions { + const message = { ...baseMethodOptions } as MethodOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.idempotencyLevel !== undefined && + object.idempotencyLevel !== null + ) { + message.idempotencyLevel = object.idempotencyLevel; + } else { + message.idempotencyLevel = 0; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseUninterpretedOption: object = { + identifierValue: "", + positiveIntValue: 0, + negativeIntValue: 0, + doubleValue: 0, + aggregateValue: "", +}; + +export const UninterpretedOption = { + encode( + message: UninterpretedOption, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.name) { + UninterpretedOption_NamePart.encode( + v!, + writer.uint32(18).fork() + ).ldelim(); + } + if (message.identifierValue !== "") { + writer.uint32(26).string(message.identifierValue); + } + if (message.positiveIntValue !== 0) { + writer.uint32(32).uint64(message.positiveIntValue); + } + if (message.negativeIntValue !== 0) { + writer.uint32(40).int64(message.negativeIntValue); + } + if (message.doubleValue !== 0) { + writer.uint32(49).double(message.doubleValue); + } + if (message.stringValue.length !== 0) { + writer.uint32(58).bytes(message.stringValue); + } + if (message.aggregateValue !== "") { + writer.uint32(66).string(message.aggregateValue); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): UninterpretedOption { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseUninterpretedOption } as UninterpretedOption; + message.name = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + message.name.push( + UninterpretedOption_NamePart.decode(reader, reader.uint32()) + ); + break; + case 3: + message.identifierValue = reader.string(); + break; + case 4: + message.positiveIntValue = longToNumber(reader.uint64() as Long); + break; + case 5: + message.negativeIntValue = longToNumber(reader.int64() as Long); + break; + case 6: + message.doubleValue = reader.double(); + break; + case 7: + message.stringValue = reader.bytes(); + break; + case 8: + message.aggregateValue = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): UninterpretedOption { + const message = { ...baseUninterpretedOption } as UninterpretedOption; + message.name = []; + if (object.name !== undefined && object.name !== null) { + for (const e of object.name) { + message.name.push(UninterpretedOption_NamePart.fromJSON(e)); + } + } + if ( + object.identifierValue !== undefined && + object.identifierValue !== null + ) { + message.identifierValue = String(object.identifierValue); + } else { + message.identifierValue = ""; + } + if ( + object.positiveIntValue !== undefined && + object.positiveIntValue !== null + ) { + message.positiveIntValue = Number(object.positiveIntValue); + } else { + message.positiveIntValue = 0; + } + if ( + object.negativeIntValue !== undefined && + object.negativeIntValue !== null + ) { + message.negativeIntValue = Number(object.negativeIntValue); + } else { + message.negativeIntValue = 0; + } + if (object.doubleValue !== undefined && object.doubleValue !== null) { + message.doubleValue = Number(object.doubleValue); + } else { + message.doubleValue = 0; + } + if (object.stringValue !== undefined && object.stringValue !== null) { + message.stringValue = bytesFromBase64(object.stringValue); + } + if (object.aggregateValue !== undefined && object.aggregateValue !== null) { + message.aggregateValue = String(object.aggregateValue); + } else { + message.aggregateValue = ""; + } + return message; + }, + + toJSON(message: UninterpretedOption): unknown { + const obj: any = {}; + if (message.name) { + obj.name = message.name.map((e) => + e ? UninterpretedOption_NamePart.toJSON(e) : undefined + ); + } else { + obj.name = []; + } + message.identifierValue !== undefined && + (obj.identifierValue = message.identifierValue); + message.positiveIntValue !== undefined && + (obj.positiveIntValue = message.positiveIntValue); + message.negativeIntValue !== undefined && + (obj.negativeIntValue = message.negativeIntValue); + message.doubleValue !== undefined && + (obj.doubleValue = message.doubleValue); + message.stringValue !== undefined && + (obj.stringValue = base64FromBytes( + message.stringValue !== undefined + ? message.stringValue + : new Uint8Array() + )); + message.aggregateValue !== undefined && + (obj.aggregateValue = message.aggregateValue); + return obj; + }, + + fromPartial(object: DeepPartial): UninterpretedOption { + const message = { ...baseUninterpretedOption } as UninterpretedOption; + message.name = []; + if (object.name !== undefined && object.name !== null) { + for (const e of object.name) { + message.name.push(UninterpretedOption_NamePart.fromPartial(e)); + } + } + if ( + object.identifierValue !== undefined && + object.identifierValue !== null + ) { + message.identifierValue = object.identifierValue; + } else { + message.identifierValue = ""; + } + if ( + object.positiveIntValue !== undefined && + object.positiveIntValue !== null + ) { + message.positiveIntValue = object.positiveIntValue; + } else { + message.positiveIntValue = 0; + } + if ( + object.negativeIntValue !== undefined && + object.negativeIntValue !== null + ) { + message.negativeIntValue = object.negativeIntValue; + } else { + message.negativeIntValue = 0; + } + if (object.doubleValue !== undefined && object.doubleValue !== null) { + message.doubleValue = object.doubleValue; + } else { + message.doubleValue = 0; + } + if (object.stringValue !== undefined && object.stringValue !== null) { + message.stringValue = object.stringValue; + } else { + message.stringValue = new Uint8Array(); + } + if (object.aggregateValue !== undefined && object.aggregateValue !== null) { + message.aggregateValue = object.aggregateValue; + } else { + message.aggregateValue = ""; + } + return message; + }, +}; + +const baseUninterpretedOption_NamePart: object = { + namePart: "", + isExtension: false, +}; + +export const UninterpretedOption_NamePart = { + encode( + message: UninterpretedOption_NamePart, + writer: Writer = Writer.create() + ): Writer { + if (message.namePart !== "") { + writer.uint32(10).string(message.namePart); + } + if (message.isExtension === true) { + writer.uint32(16).bool(message.isExtension); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): UninterpretedOption_NamePart { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseUninterpretedOption_NamePart, + } as UninterpretedOption_NamePart; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.namePart = reader.string(); + break; + case 2: + message.isExtension = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): UninterpretedOption_NamePart { + const message = { + ...baseUninterpretedOption_NamePart, + } as UninterpretedOption_NamePart; + if (object.namePart !== undefined && object.namePart !== null) { + message.namePart = String(object.namePart); + } else { + message.namePart = ""; + } + if (object.isExtension !== undefined && object.isExtension !== null) { + message.isExtension = Boolean(object.isExtension); + } else { + message.isExtension = false; + } + return message; + }, + + toJSON(message: UninterpretedOption_NamePart): unknown { + const obj: any = {}; + message.namePart !== undefined && (obj.namePart = message.namePart); + message.isExtension !== undefined && + (obj.isExtension = message.isExtension); + return obj; + }, + + fromPartial( + object: DeepPartial + ): UninterpretedOption_NamePart { + const message = { + ...baseUninterpretedOption_NamePart, + } as UninterpretedOption_NamePart; + if (object.namePart !== undefined && object.namePart !== null) { + message.namePart = object.namePart; + } else { + message.namePart = ""; + } + if (object.isExtension !== undefined && object.isExtension !== null) { + message.isExtension = object.isExtension; + } else { + message.isExtension = false; + } + return message; + }, +}; + +const baseSourceCodeInfo: object = {}; + +export const SourceCodeInfo = { + encode(message: SourceCodeInfo, writer: Writer = Writer.create()): Writer { + for (const v of message.location) { + SourceCodeInfo_Location.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): SourceCodeInfo { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseSourceCodeInfo } as SourceCodeInfo; + message.location = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.location.push( + SourceCodeInfo_Location.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): SourceCodeInfo { + const message = { ...baseSourceCodeInfo } as SourceCodeInfo; + message.location = []; + if (object.location !== undefined && object.location !== null) { + for (const e of object.location) { + message.location.push(SourceCodeInfo_Location.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: SourceCodeInfo): unknown { + const obj: any = {}; + if (message.location) { + obj.location = message.location.map((e) => + e ? SourceCodeInfo_Location.toJSON(e) : undefined + ); + } else { + obj.location = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): SourceCodeInfo { + const message = { ...baseSourceCodeInfo } as SourceCodeInfo; + message.location = []; + if (object.location !== undefined && object.location !== null) { + for (const e of object.location) { + message.location.push(SourceCodeInfo_Location.fromPartial(e)); + } + } + return message; + }, +}; + +const baseSourceCodeInfo_Location: object = { + path: 0, + span: 0, + leadingComments: "", + trailingComments: "", + leadingDetachedComments: "", +}; + +export const SourceCodeInfo_Location = { + encode( + message: SourceCodeInfo_Location, + writer: Writer = Writer.create() + ): Writer { + writer.uint32(10).fork(); + for (const v of message.path) { + writer.int32(v); + } + writer.ldelim(); + writer.uint32(18).fork(); + for (const v of message.span) { + writer.int32(v); + } + writer.ldelim(); + if (message.leadingComments !== "") { + writer.uint32(26).string(message.leadingComments); + } + if (message.trailingComments !== "") { + writer.uint32(34).string(message.trailingComments); + } + for (const v of message.leadingDetachedComments) { + writer.uint32(50).string(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): SourceCodeInfo_Location { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseSourceCodeInfo_Location, + } as SourceCodeInfo_Location; + message.path = []; + message.span = []; + message.leadingDetachedComments = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.path.push(reader.int32()); + } + } else { + message.path.push(reader.int32()); + } + break; + case 2: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.span.push(reader.int32()); + } + } else { + message.span.push(reader.int32()); + } + break; + case 3: + message.leadingComments = reader.string(); + break; + case 4: + message.trailingComments = reader.string(); + break; + case 6: + message.leadingDetachedComments.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): SourceCodeInfo_Location { + const message = { + ...baseSourceCodeInfo_Location, + } as SourceCodeInfo_Location; + message.path = []; + message.span = []; + message.leadingDetachedComments = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(Number(e)); + } + } + if (object.span !== undefined && object.span !== null) { + for (const e of object.span) { + message.span.push(Number(e)); + } + } + if ( + object.leadingComments !== undefined && + object.leadingComments !== null + ) { + message.leadingComments = String(object.leadingComments); + } else { + message.leadingComments = ""; + } + if ( + object.trailingComments !== undefined && + object.trailingComments !== null + ) { + message.trailingComments = String(object.trailingComments); + } else { + message.trailingComments = ""; + } + if ( + object.leadingDetachedComments !== undefined && + object.leadingDetachedComments !== null + ) { + for (const e of object.leadingDetachedComments) { + message.leadingDetachedComments.push(String(e)); + } + } + return message; + }, + + toJSON(message: SourceCodeInfo_Location): unknown { + const obj: any = {}; + if (message.path) { + obj.path = message.path.map((e) => e); + } else { + obj.path = []; + } + if (message.span) { + obj.span = message.span.map((e) => e); + } else { + obj.span = []; + } + message.leadingComments !== undefined && + (obj.leadingComments = message.leadingComments); + message.trailingComments !== undefined && + (obj.trailingComments = message.trailingComments); + if (message.leadingDetachedComments) { + obj.leadingDetachedComments = message.leadingDetachedComments.map( + (e) => e + ); + } else { + obj.leadingDetachedComments = []; + } + return obj; + }, + + fromPartial( + object: DeepPartial + ): SourceCodeInfo_Location { + const message = { + ...baseSourceCodeInfo_Location, + } as SourceCodeInfo_Location; + message.path = []; + message.span = []; + message.leadingDetachedComments = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(e); + } + } + if (object.span !== undefined && object.span !== null) { + for (const e of object.span) { + message.span.push(e); + } + } + if ( + object.leadingComments !== undefined && + object.leadingComments !== null + ) { + message.leadingComments = object.leadingComments; + } else { + message.leadingComments = ""; + } + if ( + object.trailingComments !== undefined && + object.trailingComments !== null + ) { + message.trailingComments = object.trailingComments; + } else { + message.trailingComments = ""; + } + if ( + object.leadingDetachedComments !== undefined && + object.leadingDetachedComments !== null + ) { + for (const e of object.leadingDetachedComments) { + message.leadingDetachedComments.push(e); + } + } + return message; + }, +}; + +const baseGeneratedCodeInfo: object = {}; + +export const GeneratedCodeInfo = { + encode(message: GeneratedCodeInfo, writer: Writer = Writer.create()): Writer { + for (const v of message.annotation) { + GeneratedCodeInfo_Annotation.encode( + v!, + writer.uint32(10).fork() + ).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): GeneratedCodeInfo { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseGeneratedCodeInfo } as GeneratedCodeInfo; + message.annotation = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.annotation.push( + GeneratedCodeInfo_Annotation.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GeneratedCodeInfo { + const message = { ...baseGeneratedCodeInfo } as GeneratedCodeInfo; + message.annotation = []; + if (object.annotation !== undefined && object.annotation !== null) { + for (const e of object.annotation) { + message.annotation.push(GeneratedCodeInfo_Annotation.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: GeneratedCodeInfo): unknown { + const obj: any = {}; + if (message.annotation) { + obj.annotation = message.annotation.map((e) => + e ? GeneratedCodeInfo_Annotation.toJSON(e) : undefined + ); + } else { + obj.annotation = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): GeneratedCodeInfo { + const message = { ...baseGeneratedCodeInfo } as GeneratedCodeInfo; + message.annotation = []; + if (object.annotation !== undefined && object.annotation !== null) { + for (const e of object.annotation) { + message.annotation.push(GeneratedCodeInfo_Annotation.fromPartial(e)); + } + } + return message; + }, +}; + +const baseGeneratedCodeInfo_Annotation: object = { + path: 0, + sourceFile: "", + begin: 0, + end: 0, +}; + +export const GeneratedCodeInfo_Annotation = { + encode( + message: GeneratedCodeInfo_Annotation, + writer: Writer = Writer.create() + ): Writer { + writer.uint32(10).fork(); + for (const v of message.path) { + writer.int32(v); + } + writer.ldelim(); + if (message.sourceFile !== "") { + writer.uint32(18).string(message.sourceFile); + } + if (message.begin !== 0) { + writer.uint32(24).int32(message.begin); + } + if (message.end !== 0) { + writer.uint32(32).int32(message.end); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): GeneratedCodeInfo_Annotation { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseGeneratedCodeInfo_Annotation, + } as GeneratedCodeInfo_Annotation; + message.path = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.path.push(reader.int32()); + } + } else { + message.path.push(reader.int32()); + } + break; + case 2: + message.sourceFile = reader.string(); + break; + case 3: + message.begin = reader.int32(); + break; + case 4: + message.end = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GeneratedCodeInfo_Annotation { + const message = { + ...baseGeneratedCodeInfo_Annotation, + } as GeneratedCodeInfo_Annotation; + message.path = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(Number(e)); + } + } + if (object.sourceFile !== undefined && object.sourceFile !== null) { + message.sourceFile = String(object.sourceFile); + } else { + message.sourceFile = ""; + } + if (object.begin !== undefined && object.begin !== null) { + message.begin = Number(object.begin); + } else { + message.begin = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + return message; + }, + + toJSON(message: GeneratedCodeInfo_Annotation): unknown { + const obj: any = {}; + if (message.path) { + obj.path = message.path.map((e) => e); + } else { + obj.path = []; + } + message.sourceFile !== undefined && (obj.sourceFile = message.sourceFile); + message.begin !== undefined && (obj.begin = message.begin); + message.end !== undefined && (obj.end = message.end); + return obj; + }, + + fromPartial( + object: DeepPartial + ): GeneratedCodeInfo_Annotation { + const message = { + ...baseGeneratedCodeInfo_Annotation, + } as GeneratedCodeInfo_Annotation; + message.path = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(e); + } + } + if (object.sourceFile !== undefined && object.sourceFile !== null) { + message.sourceFile = object.sourceFile; + } else { + message.sourceFile = ""; + } + if (object.begin !== undefined && object.begin !== null) { + message.begin = object.begin; + } else { + message.begin = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/cosmos.params.v1beta1/index.ts b/ts-client/cosmos.params.v1beta1/index.ts new file mode 100755 index 00000000..c9dfa159 --- /dev/null +++ b/ts-client/cosmos.params.v1beta1/index.ts @@ -0,0 +1,6 @@ +import Module from './module'; +import { txClient, queryClient, registry } from './module'; +import { msgTypes } from './registry'; + +export * from "./types"; +export { Module, msgTypes, txClient, queryClient, registry }; diff --git a/ts-client/cosmos.params.v1beta1/module.ts b/ts-client/cosmos.params.v1beta1/module.ts new file mode 100755 index 00000000..b30bfe3e --- /dev/null +++ b/ts-client/cosmos.params.v1beta1/module.ts @@ -0,0 +1,66 @@ +// Generated by Ignite ignite.com/cli + +import { StdFee } from "@cosmjs/launchpad"; +import { SigningStargateClient, DeliverTxResponse } from "@cosmjs/stargate"; +import { EncodeObject, GeneratedType, OfflineSigner, Registry } from "@cosmjs/proto-signing"; +import { msgTypes } from './registry'; +import { IgniteClient } from "../client" +import { MissingWalletError } from "../helpers" +import { Api } from "./rest"; + + +export { }; + + + +export const registry = new Registry(msgTypes); + +const defaultFee = { + amount: [], + gas: "200000", +}; + +interface TxClientOptions { + addr: string + prefix: string + signer?: OfflineSigner +} + +export const txClient = ({ signer, prefix, addr }: TxClientOptions = { addr: "http://localhost:26657", prefix: "cosmos" }) => { + + return { + + + } +}; + +interface QueryClientOptions { + addr: string +} + +export const queryClient = ({ addr: addr }: QueryClientOptions = { addr: "http://localhost:1317" }) => { + return new Api({ baseUrl: addr }); +}; + +class SDKModule { + public query: ReturnType; + public tx: ReturnType; + + public registry: Array<[string, GeneratedType]>; + + constructor(client: IgniteClient) { + + this.query = queryClient({ addr: client.env.apiURL }); + this.tx = txClient({ signer: client.signer, addr: client.env.rpcURL, prefix: client.env.prefix ?? "cosmos" }); + } +}; + +const Module = (test: IgniteClient) => { + return { + module: { + CosmosParamsV1Beta1: new SDKModule(test) + }, + registry: msgTypes + } +} +export default Module; \ No newline at end of file diff --git a/ts-client/cosmos.params.v1beta1/registry.ts b/ts-client/cosmos.params.v1beta1/registry.ts new file mode 100755 index 00000000..26157e4f --- /dev/null +++ b/ts-client/cosmos.params.v1beta1/registry.ts @@ -0,0 +1,7 @@ +import { GeneratedType } from "@cosmjs/proto-signing"; + +const msgTypes: Array<[string, GeneratedType]> = [ + +]; + +export { msgTypes } \ No newline at end of file diff --git a/ts-client/cosmos.params.v1beta1/rest.ts b/ts-client/cosmos.params.v1beta1/rest.ts new file mode 100644 index 00000000..88d657f7 --- /dev/null +++ b/ts-client/cosmos.params.v1beta1/rest.ts @@ -0,0 +1,254 @@ +/* eslint-disable */ +/* tslint:disable */ +/* + * --------------------------------------------------------------- + * ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ## + * ## ## + * ## AUTHOR: acacode ## + * ## SOURCE: https://github.com/acacode/swagger-typescript-api ## + * --------------------------------------------------------------- + */ + +export interface ProtobufAny { + "@type"?: string; +} + +export interface RpcStatus { + /** @format int32 */ + code?: number; + message?: string; + details?: ProtobufAny[]; +} + +/** +* ParamChange defines an individual parameter change, for use in +ParameterChangeProposal. +*/ +export interface V1Beta1ParamChange { + subspace?: string; + key?: string; + value?: string; +} + +/** + * QueryParamsResponse is response type for the Query/Params RPC method. + */ +export interface V1Beta1QueryParamsResponse { + /** param defines the queried parameter. */ + param?: V1Beta1ParamChange; +} + +export type QueryParamsType = Record; +export type ResponseFormat = keyof Omit; + +export interface FullRequestParams extends Omit { + /** set parameter to `true` for call `securityWorker` for this request */ + secure?: boolean; + /** request path */ + path: string; + /** content type of request body */ + type?: ContentType; + /** query params */ + query?: QueryParamsType; + /** format of response (i.e. response.json() -> format: "json") */ + format?: keyof Omit; + /** request body */ + body?: unknown; + /** base url */ + baseUrl?: string; + /** request cancellation token */ + cancelToken?: CancelToken; +} + +export type RequestParams = Omit; + +export interface ApiConfig { + baseUrl?: string; + baseApiParams?: Omit; + securityWorker?: (securityData: SecurityDataType) => RequestParams | void; +} + +export interface HttpResponse extends Response { + data: D; + error: E; +} + +type CancelToken = Symbol | string | number; + +export enum ContentType { + Json = "application/json", + FormData = "multipart/form-data", + UrlEncoded = "application/x-www-form-urlencoded", +} + +export class HttpClient { + public baseUrl: string = ""; + private securityData: SecurityDataType = null as any; + private securityWorker: null | ApiConfig["securityWorker"] = null; + private abortControllers = new Map(); + + private baseApiParams: RequestParams = { + credentials: "same-origin", + headers: {}, + redirect: "follow", + referrerPolicy: "no-referrer", + }; + + constructor(apiConfig: ApiConfig = {}) { + Object.assign(this, apiConfig); + } + + public setSecurityData = (data: SecurityDataType) => { + this.securityData = data; + }; + + private addQueryParam(query: QueryParamsType, key: string) { + const value = query[key]; + + return ( + encodeURIComponent(key) + + "=" + + encodeURIComponent(Array.isArray(value) ? value.join(",") : typeof value === "number" ? value : `${value}`) + ); + } + + protected toQueryString(rawQuery?: QueryParamsType): string { + const query = rawQuery || {}; + const keys = Object.keys(query).filter((key) => "undefined" !== typeof query[key]); + return keys + .map((key) => + typeof query[key] === "object" && !Array.isArray(query[key]) + ? this.toQueryString(query[key] as QueryParamsType) + : this.addQueryParam(query, key), + ) + .join("&"); + } + + protected addQueryParams(rawQuery?: QueryParamsType): string { + const queryString = this.toQueryString(rawQuery); + return queryString ? `?${queryString}` : ""; + } + + private contentFormatters: Record any> = { + [ContentType.Json]: (input: any) => + input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input, + [ContentType.FormData]: (input: any) => + Object.keys(input || {}).reduce((data, key) => { + data.append(key, input[key]); + return data; + }, new FormData()), + [ContentType.UrlEncoded]: (input: any) => this.toQueryString(input), + }; + + private mergeRequestParams(params1: RequestParams, params2?: RequestParams): RequestParams { + return { + ...this.baseApiParams, + ...params1, + ...(params2 || {}), + headers: { + ...(this.baseApiParams.headers || {}), + ...(params1.headers || {}), + ...((params2 && params2.headers) || {}), + }, + }; + } + + private createAbortSignal = (cancelToken: CancelToken): AbortSignal | undefined => { + if (this.abortControllers.has(cancelToken)) { + const abortController = this.abortControllers.get(cancelToken); + if (abortController) { + return abortController.signal; + } + return void 0; + } + + const abortController = new AbortController(); + this.abortControllers.set(cancelToken, abortController); + return abortController.signal; + }; + + public abortRequest = (cancelToken: CancelToken) => { + const abortController = this.abortControllers.get(cancelToken); + + if (abortController) { + abortController.abort(); + this.abortControllers.delete(cancelToken); + } + }; + + public request = ({ + body, + secure, + path, + type, + query, + format = "json", + baseUrl, + cancelToken, + ...params + }: FullRequestParams): Promise> => { + const secureParams = (secure && this.securityWorker && this.securityWorker(this.securityData)) || {}; + const requestParams = this.mergeRequestParams(params, secureParams); + const queryString = query && this.toQueryString(query); + const payloadFormatter = this.contentFormatters[type || ContentType.Json]; + + return fetch(`${baseUrl || this.baseUrl || ""}${path}${queryString ? `?${queryString}` : ""}`, { + ...requestParams, + headers: { + ...(type && type !== ContentType.FormData ? { "Content-Type": type } : {}), + ...(requestParams.headers || {}), + }, + signal: cancelToken ? this.createAbortSignal(cancelToken) : void 0, + body: typeof body === "undefined" || body === null ? null : payloadFormatter(body), + }).then(async (response) => { + const r = response as HttpResponse; + r.data = (null as unknown) as T; + r.error = (null as unknown) as E; + + const data = await response[format]() + .then((data) => { + if (r.ok) { + r.data = data; + } else { + r.error = data; + } + return r; + }) + .catch((e) => { + r.error = e; + return r; + }); + + if (cancelToken) { + this.abortControllers.delete(cancelToken); + } + + if (!response.ok) throw data; + return data; + }); + }; +} + +/** + * @title cosmos/params/v1beta1/params.proto + * @version version not set + */ +export class Api extends HttpClient { + /** + * No description + * + * @tags Query + * @name QueryParams + * @summary Params queries a specific parameter of a module, given its subspace and +key. + * @request GET:/cosmos/params/v1beta1/params + */ + queryParams = (query?: { subspace?: string; key?: string }, params: RequestParams = {}) => + this.request({ + path: `/cosmos/params/v1beta1/params`, + method: "GET", + query: query, + format: "json", + ...params, + }); +} diff --git a/ts-client/cosmos.params.v1beta1/types.ts b/ts-client/cosmos.params.v1beta1/types.ts new file mode 100755 index 00000000..1ce75e6d --- /dev/null +++ b/ts-client/cosmos.params.v1beta1/types.ts @@ -0,0 +1,9 @@ +import { ParameterChangeProposal } from "./types/cosmos/params/v1beta1/params" +import { ParamChange } from "./types/cosmos/params/v1beta1/params" + + +export { + ParameterChangeProposal, + ParamChange, + + } \ No newline at end of file diff --git a/ts-client/cosmos.params.v1beta1/types/cosmos/params/v1beta1/params.ts b/ts-client/cosmos.params.v1beta1/types/cosmos/params/v1beta1/params.ts new file mode 100644 index 00000000..1aae5a59 --- /dev/null +++ b/ts-client/cosmos.params.v1beta1/types/cosmos/params/v1beta1/params.ts @@ -0,0 +1,231 @@ +/* eslint-disable */ +import { Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "cosmos.params.v1beta1"; + +/** ParameterChangeProposal defines a proposal to change one or more parameters. */ +export interface ParameterChangeProposal { + title: string; + description: string; + changes: ParamChange[]; +} + +/** + * ParamChange defines an individual parameter change, for use in + * ParameterChangeProposal. + */ +export interface ParamChange { + subspace: string; + key: string; + value: string; +} + +const baseParameterChangeProposal: object = { title: "", description: "" }; + +export const ParameterChangeProposal = { + encode( + message: ParameterChangeProposal, + writer: Writer = Writer.create() + ): Writer { + if (message.title !== "") { + writer.uint32(10).string(message.title); + } + if (message.description !== "") { + writer.uint32(18).string(message.description); + } + for (const v of message.changes) { + ParamChange.encode(v!, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ParameterChangeProposal { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseParameterChangeProposal, + } as ParameterChangeProposal; + message.changes = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.title = reader.string(); + break; + case 2: + message.description = reader.string(); + break; + case 3: + message.changes.push(ParamChange.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ParameterChangeProposal { + const message = { + ...baseParameterChangeProposal, + } as ParameterChangeProposal; + message.changes = []; + if (object.title !== undefined && object.title !== null) { + message.title = String(object.title); + } else { + message.title = ""; + } + if (object.description !== undefined && object.description !== null) { + message.description = String(object.description); + } else { + message.description = ""; + } + if (object.changes !== undefined && object.changes !== null) { + for (const e of object.changes) { + message.changes.push(ParamChange.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: ParameterChangeProposal): unknown { + const obj: any = {}; + message.title !== undefined && (obj.title = message.title); + message.description !== undefined && + (obj.description = message.description); + if (message.changes) { + obj.changes = message.changes.map((e) => + e ? ParamChange.toJSON(e) : undefined + ); + } else { + obj.changes = []; + } + return obj; + }, + + fromPartial( + object: DeepPartial + ): ParameterChangeProposal { + const message = { + ...baseParameterChangeProposal, + } as ParameterChangeProposal; + message.changes = []; + if (object.title !== undefined && object.title !== null) { + message.title = object.title; + } else { + message.title = ""; + } + if (object.description !== undefined && object.description !== null) { + message.description = object.description; + } else { + message.description = ""; + } + if (object.changes !== undefined && object.changes !== null) { + for (const e of object.changes) { + message.changes.push(ParamChange.fromPartial(e)); + } + } + return message; + }, +}; + +const baseParamChange: object = { subspace: "", key: "", value: "" }; + +export const ParamChange = { + encode(message: ParamChange, writer: Writer = Writer.create()): Writer { + if (message.subspace !== "") { + writer.uint32(10).string(message.subspace); + } + if (message.key !== "") { + writer.uint32(18).string(message.key); + } + if (message.value !== "") { + writer.uint32(26).string(message.value); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ParamChange { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseParamChange } as ParamChange; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.subspace = reader.string(); + break; + case 2: + message.key = reader.string(); + break; + case 3: + message.value = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ParamChange { + const message = { ...baseParamChange } as ParamChange; + if (object.subspace !== undefined && object.subspace !== null) { + message.subspace = String(object.subspace); + } else { + message.subspace = ""; + } + if (object.key !== undefined && object.key !== null) { + message.key = String(object.key); + } else { + message.key = ""; + } + if (object.value !== undefined && object.value !== null) { + message.value = String(object.value); + } else { + message.value = ""; + } + return message; + }, + + toJSON(message: ParamChange): unknown { + const obj: any = {}; + message.subspace !== undefined && (obj.subspace = message.subspace); + message.key !== undefined && (obj.key = message.key); + message.value !== undefined && (obj.value = message.value); + return obj; + }, + + fromPartial(object: DeepPartial): ParamChange { + const message = { ...baseParamChange } as ParamChange; + if (object.subspace !== undefined && object.subspace !== null) { + message.subspace = object.subspace; + } else { + message.subspace = ""; + } + if (object.key !== undefined && object.key !== null) { + message.key = object.key; + } else { + message.key = ""; + } + if (object.value !== undefined && object.value !== null) { + message.value = object.value; + } else { + message.value = ""; + } + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/cosmos.params.v1beta1/types/cosmos/params/v1beta1/query.ts b/ts-client/cosmos.params.v1beta1/types/cosmos/params/v1beta1/query.ts new file mode 100644 index 00000000..30572593 --- /dev/null +++ b/ts-client/cosmos.params.v1beta1/types/cosmos/params/v1beta1/query.ts @@ -0,0 +1,199 @@ +/* eslint-disable */ +import { Reader, Writer } from "protobufjs/minimal"; +import { ParamChange } from "../../../cosmos/params/v1beta1/params"; + +export const protobufPackage = "cosmos.params.v1beta1"; + +/** QueryParamsRequest is request type for the Query/Params RPC method. */ +export interface QueryParamsRequest { + /** subspace defines the module to query the parameter for. */ + subspace: string; + /** key defines the key of the parameter in the subspace. */ + key: string; +} + +/** QueryParamsResponse is response type for the Query/Params RPC method. */ +export interface QueryParamsResponse { + /** param defines the queried parameter. */ + param: ParamChange | undefined; +} + +const baseQueryParamsRequest: object = { subspace: "", key: "" }; + +export const QueryParamsRequest = { + encode( + message: QueryParamsRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.subspace !== "") { + writer.uint32(10).string(message.subspace); + } + if (message.key !== "") { + writer.uint32(18).string(message.key); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QueryParamsRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryParamsRequest } as QueryParamsRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.subspace = reader.string(); + break; + case 2: + message.key = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryParamsRequest { + const message = { ...baseQueryParamsRequest } as QueryParamsRequest; + if (object.subspace !== undefined && object.subspace !== null) { + message.subspace = String(object.subspace); + } else { + message.subspace = ""; + } + if (object.key !== undefined && object.key !== null) { + message.key = String(object.key); + } else { + message.key = ""; + } + return message; + }, + + toJSON(message: QueryParamsRequest): unknown { + const obj: any = {}; + message.subspace !== undefined && (obj.subspace = message.subspace); + message.key !== undefined && (obj.key = message.key); + return obj; + }, + + fromPartial(object: DeepPartial): QueryParamsRequest { + const message = { ...baseQueryParamsRequest } as QueryParamsRequest; + if (object.subspace !== undefined && object.subspace !== null) { + message.subspace = object.subspace; + } else { + message.subspace = ""; + } + if (object.key !== undefined && object.key !== null) { + message.key = object.key; + } else { + message.key = ""; + } + return message; + }, +}; + +const baseQueryParamsResponse: object = {}; + +export const QueryParamsResponse = { + encode( + message: QueryParamsResponse, + writer: Writer = Writer.create() + ): Writer { + if (message.param !== undefined) { + ParamChange.encode(message.param, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QueryParamsResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryParamsResponse } as QueryParamsResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.param = ParamChange.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryParamsResponse { + const message = { ...baseQueryParamsResponse } as QueryParamsResponse; + if (object.param !== undefined && object.param !== null) { + message.param = ParamChange.fromJSON(object.param); + } else { + message.param = undefined; + } + return message; + }, + + toJSON(message: QueryParamsResponse): unknown { + const obj: any = {}; + message.param !== undefined && + (obj.param = message.param + ? ParamChange.toJSON(message.param) + : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): QueryParamsResponse { + const message = { ...baseQueryParamsResponse } as QueryParamsResponse; + if (object.param !== undefined && object.param !== null) { + message.param = ParamChange.fromPartial(object.param); + } else { + message.param = undefined; + } + return message; + }, +}; + +/** Query defines the gRPC querier service. */ +export interface Query { + /** + * Params queries a specific parameter of a module, given its subspace and + * key. + */ + Params(request: QueryParamsRequest): Promise; +} + +export class QueryClientImpl implements Query { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + } + Params(request: QueryParamsRequest): Promise { + const data = QueryParamsRequest.encode(request).finish(); + const promise = this.rpc.request( + "cosmos.params.v1beta1.Query", + "Params", + data + ); + return promise.then((data) => QueryParamsResponse.decode(new Reader(data))); + } +} + +interface Rpc { + request( + service: string, + method: string, + data: Uint8Array + ): Promise; +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/cosmos.params.v1beta1/types/gogoproto/gogo.ts b/ts-client/cosmos.params.v1beta1/types/gogoproto/gogo.ts new file mode 100644 index 00000000..3f41a047 --- /dev/null +++ b/ts-client/cosmos.params.v1beta1/types/gogoproto/gogo.ts @@ -0,0 +1,2 @@ +/* eslint-disable */ +export const protobufPackage = "gogoproto"; diff --git a/ts-client/cosmos.params.v1beta1/types/google/api/annotations.ts b/ts-client/cosmos.params.v1beta1/types/google/api/annotations.ts new file mode 100644 index 00000000..aace4787 --- /dev/null +++ b/ts-client/cosmos.params.v1beta1/types/google/api/annotations.ts @@ -0,0 +1,2 @@ +/* eslint-disable */ +export const protobufPackage = "google.api"; diff --git a/ts-client/cosmos.params.v1beta1/types/google/api/http.ts b/ts-client/cosmos.params.v1beta1/types/google/api/http.ts new file mode 100644 index 00000000..ddc00f8b --- /dev/null +++ b/ts-client/cosmos.params.v1beta1/types/google/api/http.ts @@ -0,0 +1,705 @@ +/* eslint-disable */ +import { Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "google.api"; + +/** + * Defines the HTTP configuration for an API service. It contains a list of + * [HttpRule][google.api.HttpRule], each specifying the mapping of an RPC method + * to one or more HTTP REST API methods. + */ +export interface Http { + /** + * A list of HTTP configuration rules that apply to individual API methods. + * + * **NOTE:** All service configuration rules follow "last one wins" order. + */ + rules: HttpRule[]; + /** + * When set to true, URL path parmeters will be fully URI-decoded except in + * cases of single segment matches in reserved expansion, where "%2F" will be + * left encoded. + * + * The default behavior is to not decode RFC 6570 reserved characters in multi + * segment matches. + */ + fullyDecodeReservedExpansion: boolean; +} + +/** + * `HttpRule` defines the mapping of an RPC method to one or more HTTP + * REST API methods. The mapping specifies how different portions of the RPC + * request message are mapped to URL path, URL query parameters, and + * HTTP request body. The mapping is typically specified as an + * `google.api.http` annotation on the RPC method, + * see "google/api/annotations.proto" for details. + * + * The mapping consists of a field specifying the path template and + * method kind. The path template can refer to fields in the request + * message, as in the example below which describes a REST GET + * operation on a resource collection of messages: + * + * + * service Messaging { + * rpc GetMessage(GetMessageRequest) returns (Message) { + * option (google.api.http).get = "/v1/messages/{message_id}/{sub.subfield}"; + * } + * } + * message GetMessageRequest { + * message SubMessage { + * string subfield = 1; + * } + * string message_id = 1; // mapped to the URL + * SubMessage sub = 2; // `sub.subfield` is url-mapped + * } + * message Message { + * string text = 1; // content of the resource + * } + * + * The same http annotation can alternatively be expressed inside the + * `GRPC API Configuration` YAML file. + * + * http: + * rules: + * - selector: .Messaging.GetMessage + * get: /v1/messages/{message_id}/{sub.subfield} + * + * This definition enables an automatic, bidrectional mapping of HTTP + * JSON to RPC. Example: + * + * HTTP | RPC + * -----|----- + * `GET /v1/messages/123456/foo` | `GetMessage(message_id: "123456" sub: SubMessage(subfield: "foo"))` + * + * In general, not only fields but also field paths can be referenced + * from a path pattern. Fields mapped to the path pattern cannot be + * repeated and must have a primitive (non-message) type. + * + * Any fields in the request message which are not bound by the path + * pattern automatically become (optional) HTTP query + * parameters. Assume the following definition of the request message: + * + * + * service Messaging { + * rpc GetMessage(GetMessageRequest) returns (Message) { + * option (google.api.http).get = "/v1/messages/{message_id}"; + * } + * } + * message GetMessageRequest { + * message SubMessage { + * string subfield = 1; + * } + * string message_id = 1; // mapped to the URL + * int64 revision = 2; // becomes a parameter + * SubMessage sub = 3; // `sub.subfield` becomes a parameter + * } + * + * + * This enables a HTTP JSON to RPC mapping as below: + * + * HTTP | RPC + * -----|----- + * `GET /v1/messages/123456?revision=2&sub.subfield=foo` | `GetMessage(message_id: "123456" revision: 2 sub: SubMessage(subfield: "foo"))` + * + * Note that fields which are mapped to HTTP parameters must have a + * primitive type or a repeated primitive type. Message types are not + * allowed. In the case of a repeated type, the parameter can be + * repeated in the URL, as in `...?param=A¶m=B`. + * + * For HTTP method kinds which allow a request body, the `body` field + * specifies the mapping. Consider a REST update method on the + * message resource collection: + * + * + * service Messaging { + * rpc UpdateMessage(UpdateMessageRequest) returns (Message) { + * option (google.api.http) = { + * put: "/v1/messages/{message_id}" + * body: "message" + * }; + * } + * } + * message UpdateMessageRequest { + * string message_id = 1; // mapped to the URL + * Message message = 2; // mapped to the body + * } + * + * + * The following HTTP JSON to RPC mapping is enabled, where the + * representation of the JSON in the request body is determined by + * protos JSON encoding: + * + * HTTP | RPC + * -----|----- + * `PUT /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: "123456" message { text: "Hi!" })` + * + * The special name `*` can be used in the body mapping to define that + * every field not bound by the path template should be mapped to the + * request body. This enables the following alternative definition of + * the update method: + * + * service Messaging { + * rpc UpdateMessage(Message) returns (Message) { + * option (google.api.http) = { + * put: "/v1/messages/{message_id}" + * body: "*" + * }; + * } + * } + * message Message { + * string message_id = 1; + * string text = 2; + * } + * + * + * The following HTTP JSON to RPC mapping is enabled: + * + * HTTP | RPC + * -----|----- + * `PUT /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: "123456" text: "Hi!")` + * + * Note that when using `*` in the body mapping, it is not possible to + * have HTTP parameters, as all fields not bound by the path end in + * the body. This makes this option more rarely used in practice of + * defining REST APIs. The common usage of `*` is in custom methods + * which don't use the URL at all for transferring data. + * + * It is possible to define multiple HTTP methods for one RPC by using + * the `additional_bindings` option. Example: + * + * service Messaging { + * rpc GetMessage(GetMessageRequest) returns (Message) { + * option (google.api.http) = { + * get: "/v1/messages/{message_id}" + * additional_bindings { + * get: "/v1/users/{user_id}/messages/{message_id}" + * } + * }; + * } + * } + * message GetMessageRequest { + * string message_id = 1; + * string user_id = 2; + * } + * + * + * This enables the following two alternative HTTP JSON to RPC + * mappings: + * + * HTTP | RPC + * -----|----- + * `GET /v1/messages/123456` | `GetMessage(message_id: "123456")` + * `GET /v1/users/me/messages/123456` | `GetMessage(user_id: "me" message_id: "123456")` + * + * # Rules for HTTP mapping + * + * The rules for mapping HTTP path, query parameters, and body fields + * to the request message are as follows: + * + * 1. The `body` field specifies either `*` or a field path, or is + * omitted. If omitted, it indicates there is no HTTP request body. + * 2. Leaf fields (recursive expansion of nested messages in the + * request) can be classified into three types: + * (a) Matched in the URL template. + * (b) Covered by body (if body is `*`, everything except (a) fields; + * else everything under the body field) + * (c) All other fields. + * 3. URL query parameters found in the HTTP request are mapped to (c) fields. + * 4. Any body sent with an HTTP request can contain only (b) fields. + * + * The syntax of the path template is as follows: + * + * Template = "/" Segments [ Verb ] ; + * Segments = Segment { "/" Segment } ; + * Segment = "*" | "**" | LITERAL | Variable ; + * Variable = "{" FieldPath [ "=" Segments ] "}" ; + * FieldPath = IDENT { "." IDENT } ; + * Verb = ":" LITERAL ; + * + * The syntax `*` matches a single path segment. The syntax `**` matches zero + * or more path segments, which must be the last part of the path except the + * `Verb`. The syntax `LITERAL` matches literal text in the path. + * + * The syntax `Variable` matches part of the URL path as specified by its + * template. A variable template must not contain other variables. If a variable + * matches a single path segment, its template may be omitted, e.g. `{var}` + * is equivalent to `{var=*}`. + * + * If a variable contains exactly one path segment, such as `"{var}"` or + * `"{var=*}"`, when such a variable is expanded into a URL path, all characters + * except `[-_.~0-9a-zA-Z]` are percent-encoded. Such variables show up in the + * Discovery Document as `{var}`. + * + * If a variable contains one or more path segments, such as `"{var=foo/*}"` + * or `"{var=**}"`, when such a variable is expanded into a URL path, all + * characters except `[-_.~/0-9a-zA-Z]` are percent-encoded. Such variables + * show up in the Discovery Document as `{+var}`. + * + * NOTE: While the single segment variable matches the semantics of + * [RFC 6570](https://tools.ietf.org/html/rfc6570) Section 3.2.2 + * Simple String Expansion, the multi segment variable **does not** match + * RFC 6570 Reserved Expansion. The reason is that the Reserved Expansion + * does not expand special characters like `?` and `#`, which would lead + * to invalid URLs. + * + * NOTE: the field paths in variables and in the `body` must not refer to + * repeated fields or map fields. + */ +export interface HttpRule { + /** + * Selects methods to which this rule applies. + * + * Refer to [selector][google.api.DocumentationRule.selector] for syntax details. + */ + selector: string; + /** Used for listing and getting information about resources. */ + get: string | undefined; + /** Used for updating a resource. */ + put: string | undefined; + /** Used for creating a resource. */ + post: string | undefined; + /** Used for deleting a resource. */ + delete: string | undefined; + /** Used for updating a resource. */ + patch: string | undefined; + /** + * The custom pattern is used for specifying an HTTP method that is not + * included in the `pattern` field, such as HEAD, or "*" to leave the + * HTTP method unspecified for this rule. The wild-card rule is useful + * for services that provide content to Web (HTML) clients. + */ + custom: CustomHttpPattern | undefined; + /** + * The name of the request field whose value is mapped to the HTTP body, or + * `*` for mapping all fields not captured by the path pattern to the HTTP + * body. NOTE: the referred field must not be a repeated field and must be + * present at the top-level of request message type. + */ + body: string; + /** + * Optional. The name of the response field whose value is mapped to the HTTP + * body of response. Other response fields are ignored. When + * not set, the response message will be used as HTTP body of response. + */ + responseBody: string; + /** + * Additional HTTP bindings for the selector. Nested bindings must + * not contain an `additional_bindings` field themselves (that is, + * the nesting may only be one level deep). + */ + additionalBindings: HttpRule[]; +} + +/** A custom pattern is used for defining custom HTTP verb. */ +export interface CustomHttpPattern { + /** The name of this custom HTTP verb. */ + kind: string; + /** The path matched by this custom verb. */ + path: string; +} + +const baseHttp: object = { fullyDecodeReservedExpansion: false }; + +export const Http = { + encode(message: Http, writer: Writer = Writer.create()): Writer { + for (const v of message.rules) { + HttpRule.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.fullyDecodeReservedExpansion === true) { + writer.uint32(16).bool(message.fullyDecodeReservedExpansion); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Http { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseHttp } as Http; + message.rules = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.rules.push(HttpRule.decode(reader, reader.uint32())); + break; + case 2: + message.fullyDecodeReservedExpansion = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Http { + const message = { ...baseHttp } as Http; + message.rules = []; + if (object.rules !== undefined && object.rules !== null) { + for (const e of object.rules) { + message.rules.push(HttpRule.fromJSON(e)); + } + } + if ( + object.fullyDecodeReservedExpansion !== undefined && + object.fullyDecodeReservedExpansion !== null + ) { + message.fullyDecodeReservedExpansion = Boolean( + object.fullyDecodeReservedExpansion + ); + } else { + message.fullyDecodeReservedExpansion = false; + } + return message; + }, + + toJSON(message: Http): unknown { + const obj: any = {}; + if (message.rules) { + obj.rules = message.rules.map((e) => + e ? HttpRule.toJSON(e) : undefined + ); + } else { + obj.rules = []; + } + message.fullyDecodeReservedExpansion !== undefined && + (obj.fullyDecodeReservedExpansion = message.fullyDecodeReservedExpansion); + return obj; + }, + + fromPartial(object: DeepPartial): Http { + const message = { ...baseHttp } as Http; + message.rules = []; + if (object.rules !== undefined && object.rules !== null) { + for (const e of object.rules) { + message.rules.push(HttpRule.fromPartial(e)); + } + } + if ( + object.fullyDecodeReservedExpansion !== undefined && + object.fullyDecodeReservedExpansion !== null + ) { + message.fullyDecodeReservedExpansion = + object.fullyDecodeReservedExpansion; + } else { + message.fullyDecodeReservedExpansion = false; + } + return message; + }, +}; + +const baseHttpRule: object = { selector: "", body: "", responseBody: "" }; + +export const HttpRule = { + encode(message: HttpRule, writer: Writer = Writer.create()): Writer { + if (message.selector !== "") { + writer.uint32(10).string(message.selector); + } + if (message.get !== undefined) { + writer.uint32(18).string(message.get); + } + if (message.put !== undefined) { + writer.uint32(26).string(message.put); + } + if (message.post !== undefined) { + writer.uint32(34).string(message.post); + } + if (message.delete !== undefined) { + writer.uint32(42).string(message.delete); + } + if (message.patch !== undefined) { + writer.uint32(50).string(message.patch); + } + if (message.custom !== undefined) { + CustomHttpPattern.encode( + message.custom, + writer.uint32(66).fork() + ).ldelim(); + } + if (message.body !== "") { + writer.uint32(58).string(message.body); + } + if (message.responseBody !== "") { + writer.uint32(98).string(message.responseBody); + } + for (const v of message.additionalBindings) { + HttpRule.encode(v!, writer.uint32(90).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): HttpRule { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseHttpRule } as HttpRule; + message.additionalBindings = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.selector = reader.string(); + break; + case 2: + message.get = reader.string(); + break; + case 3: + message.put = reader.string(); + break; + case 4: + message.post = reader.string(); + break; + case 5: + message.delete = reader.string(); + break; + case 6: + message.patch = reader.string(); + break; + case 8: + message.custom = CustomHttpPattern.decode(reader, reader.uint32()); + break; + case 7: + message.body = reader.string(); + break; + case 12: + message.responseBody = reader.string(); + break; + case 11: + message.additionalBindings.push( + HttpRule.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): HttpRule { + const message = { ...baseHttpRule } as HttpRule; + message.additionalBindings = []; + if (object.selector !== undefined && object.selector !== null) { + message.selector = String(object.selector); + } else { + message.selector = ""; + } + if (object.get !== undefined && object.get !== null) { + message.get = String(object.get); + } else { + message.get = undefined; + } + if (object.put !== undefined && object.put !== null) { + message.put = String(object.put); + } else { + message.put = undefined; + } + if (object.post !== undefined && object.post !== null) { + message.post = String(object.post); + } else { + message.post = undefined; + } + if (object.delete !== undefined && object.delete !== null) { + message.delete = String(object.delete); + } else { + message.delete = undefined; + } + if (object.patch !== undefined && object.patch !== null) { + message.patch = String(object.patch); + } else { + message.patch = undefined; + } + if (object.custom !== undefined && object.custom !== null) { + message.custom = CustomHttpPattern.fromJSON(object.custom); + } else { + message.custom = undefined; + } + if (object.body !== undefined && object.body !== null) { + message.body = String(object.body); + } else { + message.body = ""; + } + if (object.responseBody !== undefined && object.responseBody !== null) { + message.responseBody = String(object.responseBody); + } else { + message.responseBody = ""; + } + if ( + object.additionalBindings !== undefined && + object.additionalBindings !== null + ) { + for (const e of object.additionalBindings) { + message.additionalBindings.push(HttpRule.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: HttpRule): unknown { + const obj: any = {}; + message.selector !== undefined && (obj.selector = message.selector); + message.get !== undefined && (obj.get = message.get); + message.put !== undefined && (obj.put = message.put); + message.post !== undefined && (obj.post = message.post); + message.delete !== undefined && (obj.delete = message.delete); + message.patch !== undefined && (obj.patch = message.patch); + message.custom !== undefined && + (obj.custom = message.custom + ? CustomHttpPattern.toJSON(message.custom) + : undefined); + message.body !== undefined && (obj.body = message.body); + message.responseBody !== undefined && + (obj.responseBody = message.responseBody); + if (message.additionalBindings) { + obj.additionalBindings = message.additionalBindings.map((e) => + e ? HttpRule.toJSON(e) : undefined + ); + } else { + obj.additionalBindings = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): HttpRule { + const message = { ...baseHttpRule } as HttpRule; + message.additionalBindings = []; + if (object.selector !== undefined && object.selector !== null) { + message.selector = object.selector; + } else { + message.selector = ""; + } + if (object.get !== undefined && object.get !== null) { + message.get = object.get; + } else { + message.get = undefined; + } + if (object.put !== undefined && object.put !== null) { + message.put = object.put; + } else { + message.put = undefined; + } + if (object.post !== undefined && object.post !== null) { + message.post = object.post; + } else { + message.post = undefined; + } + if (object.delete !== undefined && object.delete !== null) { + message.delete = object.delete; + } else { + message.delete = undefined; + } + if (object.patch !== undefined && object.patch !== null) { + message.patch = object.patch; + } else { + message.patch = undefined; + } + if (object.custom !== undefined && object.custom !== null) { + message.custom = CustomHttpPattern.fromPartial(object.custom); + } else { + message.custom = undefined; + } + if (object.body !== undefined && object.body !== null) { + message.body = object.body; + } else { + message.body = ""; + } + if (object.responseBody !== undefined && object.responseBody !== null) { + message.responseBody = object.responseBody; + } else { + message.responseBody = ""; + } + if ( + object.additionalBindings !== undefined && + object.additionalBindings !== null + ) { + for (const e of object.additionalBindings) { + message.additionalBindings.push(HttpRule.fromPartial(e)); + } + } + return message; + }, +}; + +const baseCustomHttpPattern: object = { kind: "", path: "" }; + +export const CustomHttpPattern = { + encode(message: CustomHttpPattern, writer: Writer = Writer.create()): Writer { + if (message.kind !== "") { + writer.uint32(10).string(message.kind); + } + if (message.path !== "") { + writer.uint32(18).string(message.path); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): CustomHttpPattern { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseCustomHttpPattern } as CustomHttpPattern; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.kind = reader.string(); + break; + case 2: + message.path = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): CustomHttpPattern { + const message = { ...baseCustomHttpPattern } as CustomHttpPattern; + if (object.kind !== undefined && object.kind !== null) { + message.kind = String(object.kind); + } else { + message.kind = ""; + } + if (object.path !== undefined && object.path !== null) { + message.path = String(object.path); + } else { + message.path = ""; + } + return message; + }, + + toJSON(message: CustomHttpPattern): unknown { + const obj: any = {}; + message.kind !== undefined && (obj.kind = message.kind); + message.path !== undefined && (obj.path = message.path); + return obj; + }, + + fromPartial(object: DeepPartial): CustomHttpPattern { + const message = { ...baseCustomHttpPattern } as CustomHttpPattern; + if (object.kind !== undefined && object.kind !== null) { + message.kind = object.kind; + } else { + message.kind = ""; + } + if (object.path !== undefined && object.path !== null) { + message.path = object.path; + } else { + message.path = ""; + } + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/cosmos.params.v1beta1/types/google/protobuf/descriptor.ts b/ts-client/cosmos.params.v1beta1/types/google/protobuf/descriptor.ts new file mode 100644 index 00000000..9e508660 --- /dev/null +++ b/ts-client/cosmos.params.v1beta1/types/google/protobuf/descriptor.ts @@ -0,0 +1,5261 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "google.protobuf"; + +/** + * The protocol compiler can output a FileDescriptorSet containing the .proto + * files it parses. + */ +export interface FileDescriptorSet { + file: FileDescriptorProto[]; +} + +/** Describes a complete .proto file. */ +export interface FileDescriptorProto { + /** file name, relative to root of source tree */ + name: string; + /** e.g. "foo", "foo.bar", etc. */ + package: string; + /** Names of files imported by this file. */ + dependency: string[]; + /** Indexes of the public imported files in the dependency list above. */ + publicDependency: number[]; + /** + * Indexes of the weak imported files in the dependency list. + * For Google-internal migration only. Do not use. + */ + weakDependency: number[]; + /** All top-level definitions in this file. */ + messageType: DescriptorProto[]; + enumType: EnumDescriptorProto[]; + service: ServiceDescriptorProto[]; + extension: FieldDescriptorProto[]; + options: FileOptions | undefined; + /** + * This field contains optional information about the original source code. + * You may safely remove this entire field without harming runtime + * functionality of the descriptors -- the information is needed only by + * development tools. + */ + sourceCodeInfo: SourceCodeInfo | undefined; + /** + * The syntax of the proto file. + * The supported values are "proto2" and "proto3". + */ + syntax: string; +} + +/** Describes a message type. */ +export interface DescriptorProto { + name: string; + field: FieldDescriptorProto[]; + extension: FieldDescriptorProto[]; + nestedType: DescriptorProto[]; + enumType: EnumDescriptorProto[]; + extensionRange: DescriptorProto_ExtensionRange[]; + oneofDecl: OneofDescriptorProto[]; + options: MessageOptions | undefined; + reservedRange: DescriptorProto_ReservedRange[]; + /** + * Reserved field names, which may not be used by fields in the same message. + * A given name may only be reserved once. + */ + reservedName: string[]; +} + +export interface DescriptorProto_ExtensionRange { + /** Inclusive. */ + start: number; + /** Exclusive. */ + end: number; + options: ExtensionRangeOptions | undefined; +} + +/** + * Range of reserved tag numbers. Reserved tag numbers may not be used by + * fields or extension ranges in the same message. Reserved ranges may + * not overlap. + */ +export interface DescriptorProto_ReservedRange { + /** Inclusive. */ + start: number; + /** Exclusive. */ + end: number; +} + +export interface ExtensionRangeOptions { + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +/** Describes a field within a message. */ +export interface FieldDescriptorProto { + name: string; + number: number; + label: FieldDescriptorProto_Label; + /** + * If type_name is set, this need not be set. If both this and type_name + * are set, this must be one of TYPE_ENUM, TYPE_MESSAGE or TYPE_GROUP. + */ + type: FieldDescriptorProto_Type; + /** + * For message and enum types, this is the name of the type. If the name + * starts with a '.', it is fully-qualified. Otherwise, C++-like scoping + * rules are used to find the type (i.e. first the nested types within this + * message are searched, then within the parent, on up to the root + * namespace). + */ + typeName: string; + /** + * For extensions, this is the name of the type being extended. It is + * resolved in the same manner as type_name. + */ + extendee: string; + /** + * For numeric types, contains the original text representation of the value. + * For booleans, "true" or "false". + * For strings, contains the default text contents (not escaped in any way). + * For bytes, contains the C escaped value. All bytes >= 128 are escaped. + * TODO(kenton): Base-64 encode? + */ + defaultValue: string; + /** + * If set, gives the index of a oneof in the containing type's oneof_decl + * list. This field is a member of that oneof. + */ + oneofIndex: number; + /** + * JSON name of this field. The value is set by protocol compiler. If the + * user has set a "json_name" option on this field, that option's value + * will be used. Otherwise, it's deduced from the field's name by converting + * it to camelCase. + */ + jsonName: string; + options: FieldOptions | undefined; + /** + * If true, this is a proto3 "optional". When a proto3 field is optional, it + * tracks presence regardless of field type. + * + * When proto3_optional is true, this field must be belong to a oneof to + * signal to old proto3 clients that presence is tracked for this field. This + * oneof is known as a "synthetic" oneof, and this field must be its sole + * member (each proto3 optional field gets its own synthetic oneof). Synthetic + * oneofs exist in the descriptor only, and do not generate any API. Synthetic + * oneofs must be ordered after all "real" oneofs. + * + * For message fields, proto3_optional doesn't create any semantic change, + * since non-repeated message fields always track presence. However it still + * indicates the semantic detail of whether the user wrote "optional" or not. + * This can be useful for round-tripping the .proto file. For consistency we + * give message fields a synthetic oneof also, even though it is not required + * to track presence. This is especially important because the parser can't + * tell if a field is a message or an enum, so it must always create a + * synthetic oneof. + * + * Proto2 optional fields do not set this flag, because they already indicate + * optional with `LABEL_OPTIONAL`. + */ + proto3Optional: boolean; +} + +export enum FieldDescriptorProto_Type { + /** + * TYPE_DOUBLE - 0 is reserved for errors. + * Order is weird for historical reasons. + */ + TYPE_DOUBLE = 1, + TYPE_FLOAT = 2, + /** + * TYPE_INT64 - Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT64 if + * negative values are likely. + */ + TYPE_INT64 = 3, + TYPE_UINT64 = 4, + /** + * TYPE_INT32 - Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT32 if + * negative values are likely. + */ + TYPE_INT32 = 5, + TYPE_FIXED64 = 6, + TYPE_FIXED32 = 7, + TYPE_BOOL = 8, + TYPE_STRING = 9, + /** + * TYPE_GROUP - Tag-delimited aggregate. + * Group type is deprecated and not supported in proto3. However, Proto3 + * implementations should still be able to parse the group wire format and + * treat group fields as unknown fields. + */ + TYPE_GROUP = 10, + /** TYPE_MESSAGE - Length-delimited aggregate. */ + TYPE_MESSAGE = 11, + /** TYPE_BYTES - New in version 2. */ + TYPE_BYTES = 12, + TYPE_UINT32 = 13, + TYPE_ENUM = 14, + TYPE_SFIXED32 = 15, + TYPE_SFIXED64 = 16, + /** TYPE_SINT32 - Uses ZigZag encoding. */ + TYPE_SINT32 = 17, + /** TYPE_SINT64 - Uses ZigZag encoding. */ + TYPE_SINT64 = 18, + UNRECOGNIZED = -1, +} + +export function fieldDescriptorProto_TypeFromJSON( + object: any +): FieldDescriptorProto_Type { + switch (object) { + case 1: + case "TYPE_DOUBLE": + return FieldDescriptorProto_Type.TYPE_DOUBLE; + case 2: + case "TYPE_FLOAT": + return FieldDescriptorProto_Type.TYPE_FLOAT; + case 3: + case "TYPE_INT64": + return FieldDescriptorProto_Type.TYPE_INT64; + case 4: + case "TYPE_UINT64": + return FieldDescriptorProto_Type.TYPE_UINT64; + case 5: + case "TYPE_INT32": + return FieldDescriptorProto_Type.TYPE_INT32; + case 6: + case "TYPE_FIXED64": + return FieldDescriptorProto_Type.TYPE_FIXED64; + case 7: + case "TYPE_FIXED32": + return FieldDescriptorProto_Type.TYPE_FIXED32; + case 8: + case "TYPE_BOOL": + return FieldDescriptorProto_Type.TYPE_BOOL; + case 9: + case "TYPE_STRING": + return FieldDescriptorProto_Type.TYPE_STRING; + case 10: + case "TYPE_GROUP": + return FieldDescriptorProto_Type.TYPE_GROUP; + case 11: + case "TYPE_MESSAGE": + return FieldDescriptorProto_Type.TYPE_MESSAGE; + case 12: + case "TYPE_BYTES": + return FieldDescriptorProto_Type.TYPE_BYTES; + case 13: + case "TYPE_UINT32": + return FieldDescriptorProto_Type.TYPE_UINT32; + case 14: + case "TYPE_ENUM": + return FieldDescriptorProto_Type.TYPE_ENUM; + case 15: + case "TYPE_SFIXED32": + return FieldDescriptorProto_Type.TYPE_SFIXED32; + case 16: + case "TYPE_SFIXED64": + return FieldDescriptorProto_Type.TYPE_SFIXED64; + case 17: + case "TYPE_SINT32": + return FieldDescriptorProto_Type.TYPE_SINT32; + case 18: + case "TYPE_SINT64": + return FieldDescriptorProto_Type.TYPE_SINT64; + case -1: + case "UNRECOGNIZED": + default: + return FieldDescriptorProto_Type.UNRECOGNIZED; + } +} + +export function fieldDescriptorProto_TypeToJSON( + object: FieldDescriptorProto_Type +): string { + switch (object) { + case FieldDescriptorProto_Type.TYPE_DOUBLE: + return "TYPE_DOUBLE"; + case FieldDescriptorProto_Type.TYPE_FLOAT: + return "TYPE_FLOAT"; + case FieldDescriptorProto_Type.TYPE_INT64: + return "TYPE_INT64"; + case FieldDescriptorProto_Type.TYPE_UINT64: + return "TYPE_UINT64"; + case FieldDescriptorProto_Type.TYPE_INT32: + return "TYPE_INT32"; + case FieldDescriptorProto_Type.TYPE_FIXED64: + return "TYPE_FIXED64"; + case FieldDescriptorProto_Type.TYPE_FIXED32: + return "TYPE_FIXED32"; + case FieldDescriptorProto_Type.TYPE_BOOL: + return "TYPE_BOOL"; + case FieldDescriptorProto_Type.TYPE_STRING: + return "TYPE_STRING"; + case FieldDescriptorProto_Type.TYPE_GROUP: + return "TYPE_GROUP"; + case FieldDescriptorProto_Type.TYPE_MESSAGE: + return "TYPE_MESSAGE"; + case FieldDescriptorProto_Type.TYPE_BYTES: + return "TYPE_BYTES"; + case FieldDescriptorProto_Type.TYPE_UINT32: + return "TYPE_UINT32"; + case FieldDescriptorProto_Type.TYPE_ENUM: + return "TYPE_ENUM"; + case FieldDescriptorProto_Type.TYPE_SFIXED32: + return "TYPE_SFIXED32"; + case FieldDescriptorProto_Type.TYPE_SFIXED64: + return "TYPE_SFIXED64"; + case FieldDescriptorProto_Type.TYPE_SINT32: + return "TYPE_SINT32"; + case FieldDescriptorProto_Type.TYPE_SINT64: + return "TYPE_SINT64"; + default: + return "UNKNOWN"; + } +} + +export enum FieldDescriptorProto_Label { + /** LABEL_OPTIONAL - 0 is reserved for errors */ + LABEL_OPTIONAL = 1, + LABEL_REQUIRED = 2, + LABEL_REPEATED = 3, + UNRECOGNIZED = -1, +} + +export function fieldDescriptorProto_LabelFromJSON( + object: any +): FieldDescriptorProto_Label { + switch (object) { + case 1: + case "LABEL_OPTIONAL": + return FieldDescriptorProto_Label.LABEL_OPTIONAL; + case 2: + case "LABEL_REQUIRED": + return FieldDescriptorProto_Label.LABEL_REQUIRED; + case 3: + case "LABEL_REPEATED": + return FieldDescriptorProto_Label.LABEL_REPEATED; + case -1: + case "UNRECOGNIZED": + default: + return FieldDescriptorProto_Label.UNRECOGNIZED; + } +} + +export function fieldDescriptorProto_LabelToJSON( + object: FieldDescriptorProto_Label +): string { + switch (object) { + case FieldDescriptorProto_Label.LABEL_OPTIONAL: + return "LABEL_OPTIONAL"; + case FieldDescriptorProto_Label.LABEL_REQUIRED: + return "LABEL_REQUIRED"; + case FieldDescriptorProto_Label.LABEL_REPEATED: + return "LABEL_REPEATED"; + default: + return "UNKNOWN"; + } +} + +/** Describes a oneof. */ +export interface OneofDescriptorProto { + name: string; + options: OneofOptions | undefined; +} + +/** Describes an enum type. */ +export interface EnumDescriptorProto { + name: string; + value: EnumValueDescriptorProto[]; + options: EnumOptions | undefined; + /** + * Range of reserved numeric values. Reserved numeric values may not be used + * by enum values in the same enum declaration. Reserved ranges may not + * overlap. + */ + reservedRange: EnumDescriptorProto_EnumReservedRange[]; + /** + * Reserved enum value names, which may not be reused. A given name may only + * be reserved once. + */ + reservedName: string[]; +} + +/** + * Range of reserved numeric values. Reserved values may not be used by + * entries in the same enum. Reserved ranges may not overlap. + * + * Note that this is distinct from DescriptorProto.ReservedRange in that it + * is inclusive such that it can appropriately represent the entire int32 + * domain. + */ +export interface EnumDescriptorProto_EnumReservedRange { + /** Inclusive. */ + start: number; + /** Inclusive. */ + end: number; +} + +/** Describes a value within an enum. */ +export interface EnumValueDescriptorProto { + name: string; + number: number; + options: EnumValueOptions | undefined; +} + +/** Describes a service. */ +export interface ServiceDescriptorProto { + name: string; + method: MethodDescriptorProto[]; + options: ServiceOptions | undefined; +} + +/** Describes a method of a service. */ +export interface MethodDescriptorProto { + name: string; + /** + * Input and output type names. These are resolved in the same way as + * FieldDescriptorProto.type_name, but must refer to a message type. + */ + inputType: string; + outputType: string; + options: MethodOptions | undefined; + /** Identifies if client streams multiple client messages */ + clientStreaming: boolean; + /** Identifies if server streams multiple server messages */ + serverStreaming: boolean; +} + +export interface FileOptions { + /** + * Sets the Java package where classes generated from this .proto will be + * placed. By default, the proto package is used, but this is often + * inappropriate because proto packages do not normally start with backwards + * domain names. + */ + javaPackage: string; + /** + * Controls the name of the wrapper Java class generated for the .proto file. + * That class will always contain the .proto file's getDescriptor() method as + * well as any top-level extensions defined in the .proto file. + * If java_multiple_files is disabled, then all the other classes from the + * .proto file will be nested inside the single wrapper outer class. + */ + javaOuterClassname: string; + /** + * If enabled, then the Java code generator will generate a separate .java + * file for each top-level message, enum, and service defined in the .proto + * file. Thus, these types will *not* be nested inside the wrapper class + * named by java_outer_classname. However, the wrapper class will still be + * generated to contain the file's getDescriptor() method as well as any + * top-level extensions defined in the file. + */ + javaMultipleFiles: boolean; + /** + * This option does nothing. + * + * @deprecated + */ + javaGenerateEqualsAndHash: boolean; + /** + * If set true, then the Java2 code generator will generate code that + * throws an exception whenever an attempt is made to assign a non-UTF-8 + * byte sequence to a string field. + * Message reflection will do the same. + * However, an extension field still accepts non-UTF-8 byte sequences. + * This option has no effect on when used with the lite runtime. + */ + javaStringCheckUtf8: boolean; + optimizeFor: FileOptions_OptimizeMode; + /** + * Sets the Go package where structs generated from this .proto will be + * placed. If omitted, the Go package will be derived from the following: + * - The basename of the package import path, if provided. + * - Otherwise, the package statement in the .proto file, if present. + * - Otherwise, the basename of the .proto file, without extension. + */ + goPackage: string; + /** + * Should generic services be generated in each language? "Generic" services + * are not specific to any particular RPC system. They are generated by the + * main code generators in each language (without additional plugins). + * Generic services were the only kind of service generation supported by + * early versions of google.protobuf. + * + * Generic services are now considered deprecated in favor of using plugins + * that generate code specific to your particular RPC system. Therefore, + * these default to false. Old code which depends on generic services should + * explicitly set them to true. + */ + ccGenericServices: boolean; + javaGenericServices: boolean; + pyGenericServices: boolean; + phpGenericServices: boolean; + /** + * Is this file deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for everything in the file, or it will be completely ignored; in the very + * least, this is a formalization for deprecating files. + */ + deprecated: boolean; + /** + * Enables the use of arenas for the proto messages in this file. This applies + * only to generated classes for C++. + */ + ccEnableArenas: boolean; + /** + * Sets the objective c class prefix which is prepended to all objective c + * generated classes from this .proto. There is no default. + */ + objcClassPrefix: string; + /** Namespace for generated classes; defaults to the package. */ + csharpNamespace: string; + /** + * By default Swift generators will take the proto package and CamelCase it + * replacing '.' with underscore and use that to prefix the types/symbols + * defined. When this options is provided, they will use this value instead + * to prefix the types/symbols defined. + */ + swiftPrefix: string; + /** + * Sets the php class prefix which is prepended to all php generated classes + * from this .proto. Default is empty. + */ + phpClassPrefix: string; + /** + * Use this option to change the namespace of php generated classes. Default + * is empty. When this option is empty, the package name will be used for + * determining the namespace. + */ + phpNamespace: string; + /** + * Use this option to change the namespace of php generated metadata classes. + * Default is empty. When this option is empty, the proto file name will be + * used for determining the namespace. + */ + phpMetadataNamespace: string; + /** + * Use this option to change the package of ruby generated classes. Default + * is empty. When this option is not set, the package name will be used for + * determining the ruby package. + */ + rubyPackage: string; + /** + * The parser stores options it doesn't recognize here. + * See the documentation for the "Options" section above. + */ + uninterpretedOption: UninterpretedOption[]; +} + +/** Generated classes can be optimized for speed or code size. */ +export enum FileOptions_OptimizeMode { + /** SPEED - Generate complete code for parsing, serialization, */ + SPEED = 1, + /** CODE_SIZE - etc. */ + CODE_SIZE = 2, + /** LITE_RUNTIME - Generate code using MessageLite and the lite runtime. */ + LITE_RUNTIME = 3, + UNRECOGNIZED = -1, +} + +export function fileOptions_OptimizeModeFromJSON( + object: any +): FileOptions_OptimizeMode { + switch (object) { + case 1: + case "SPEED": + return FileOptions_OptimizeMode.SPEED; + case 2: + case "CODE_SIZE": + return FileOptions_OptimizeMode.CODE_SIZE; + case 3: + case "LITE_RUNTIME": + return FileOptions_OptimizeMode.LITE_RUNTIME; + case -1: + case "UNRECOGNIZED": + default: + return FileOptions_OptimizeMode.UNRECOGNIZED; + } +} + +export function fileOptions_OptimizeModeToJSON( + object: FileOptions_OptimizeMode +): string { + switch (object) { + case FileOptions_OptimizeMode.SPEED: + return "SPEED"; + case FileOptions_OptimizeMode.CODE_SIZE: + return "CODE_SIZE"; + case FileOptions_OptimizeMode.LITE_RUNTIME: + return "LITE_RUNTIME"; + default: + return "UNKNOWN"; + } +} + +export interface MessageOptions { + /** + * Set true to use the old proto1 MessageSet wire format for extensions. + * This is provided for backwards-compatibility with the MessageSet wire + * format. You should not use this for any other reason: It's less + * efficient, has fewer features, and is more complicated. + * + * The message must be defined exactly as follows: + * message Foo { + * option message_set_wire_format = true; + * extensions 4 to max; + * } + * Note that the message cannot have any defined fields; MessageSets only + * have extensions. + * + * All extensions of your type must be singular messages; e.g. they cannot + * be int32s, enums, or repeated messages. + * + * Because this is an option, the above two restrictions are not enforced by + * the protocol compiler. + */ + messageSetWireFormat: boolean; + /** + * Disables the generation of the standard "descriptor()" accessor, which can + * conflict with a field of the same name. This is meant to make migration + * from proto1 easier; new code should avoid fields named "descriptor". + */ + noStandardDescriptorAccessor: boolean; + /** + * Is this message deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the message, or it will be completely ignored; in the very least, + * this is a formalization for deprecating messages. + */ + deprecated: boolean; + /** + * Whether the message is an automatically generated map entry type for the + * maps field. + * + * For maps fields: + * map map_field = 1; + * The parsed descriptor looks like: + * message MapFieldEntry { + * option map_entry = true; + * optional KeyType key = 1; + * optional ValueType value = 2; + * } + * repeated MapFieldEntry map_field = 1; + * + * Implementations may choose not to generate the map_entry=true message, but + * use a native map in the target language to hold the keys and values. + * The reflection APIs in such implementations still need to work as + * if the field is a repeated message field. + * + * NOTE: Do not set the option in .proto files. Always use the maps syntax + * instead. The option should only be implicitly set by the proto compiler + * parser. + */ + mapEntry: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface FieldOptions { + /** + * The ctype option instructs the C++ code generator to use a different + * representation of the field than it normally would. See the specific + * options below. This option is not yet implemented in the open source + * release -- sorry, we'll try to include it in a future version! + */ + ctype: FieldOptions_CType; + /** + * The packed option can be enabled for repeated primitive fields to enable + * a more efficient representation on the wire. Rather than repeatedly + * writing the tag and type for each element, the entire array is encoded as + * a single length-delimited blob. In proto3, only explicit setting it to + * false will avoid using packed encoding. + */ + packed: boolean; + /** + * The jstype option determines the JavaScript type used for values of the + * field. The option is permitted only for 64 bit integral and fixed types + * (int64, uint64, sint64, fixed64, sfixed64). A field with jstype JS_STRING + * is represented as JavaScript string, which avoids loss of precision that + * can happen when a large value is converted to a floating point JavaScript. + * Specifying JS_NUMBER for the jstype causes the generated JavaScript code to + * use the JavaScript "number" type. The behavior of the default option + * JS_NORMAL is implementation dependent. + * + * This option is an enum to permit additional types to be added, e.g. + * goog.math.Integer. + */ + jstype: FieldOptions_JSType; + /** + * Should this field be parsed lazily? Lazy applies only to message-type + * fields. It means that when the outer message is initially parsed, the + * inner message's contents will not be parsed but instead stored in encoded + * form. The inner message will actually be parsed when it is first accessed. + * + * This is only a hint. Implementations are free to choose whether to use + * eager or lazy parsing regardless of the value of this option. However, + * setting this option true suggests that the protocol author believes that + * using lazy parsing on this field is worth the additional bookkeeping + * overhead typically needed to implement it. + * + * This option does not affect the public interface of any generated code; + * all method signatures remain the same. Furthermore, thread-safety of the + * interface is not affected by this option; const methods remain safe to + * call from multiple threads concurrently, while non-const methods continue + * to require exclusive access. + * + * + * Note that implementations may choose not to check required fields within + * a lazy sub-message. That is, calling IsInitialized() on the outer message + * may return true even if the inner message has missing required fields. + * This is necessary because otherwise the inner message would have to be + * parsed in order to perform the check, defeating the purpose of lazy + * parsing. An implementation which chooses not to check required fields + * must be consistent about it. That is, for any particular sub-message, the + * implementation must either *always* check its required fields, or *never* + * check its required fields, regardless of whether or not the message has + * been parsed. + */ + lazy: boolean; + /** + * Is this field deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for accessors, or it will be completely ignored; in the very least, this + * is a formalization for deprecating fields. + */ + deprecated: boolean; + /** For Google-internal migration only. Do not use. */ + weak: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export enum FieldOptions_CType { + /** STRING - Default mode. */ + STRING = 0, + CORD = 1, + STRING_PIECE = 2, + UNRECOGNIZED = -1, +} + +export function fieldOptions_CTypeFromJSON(object: any): FieldOptions_CType { + switch (object) { + case 0: + case "STRING": + return FieldOptions_CType.STRING; + case 1: + case "CORD": + return FieldOptions_CType.CORD; + case 2: + case "STRING_PIECE": + return FieldOptions_CType.STRING_PIECE; + case -1: + case "UNRECOGNIZED": + default: + return FieldOptions_CType.UNRECOGNIZED; + } +} + +export function fieldOptions_CTypeToJSON(object: FieldOptions_CType): string { + switch (object) { + case FieldOptions_CType.STRING: + return "STRING"; + case FieldOptions_CType.CORD: + return "CORD"; + case FieldOptions_CType.STRING_PIECE: + return "STRING_PIECE"; + default: + return "UNKNOWN"; + } +} + +export enum FieldOptions_JSType { + /** JS_NORMAL - Use the default type. */ + JS_NORMAL = 0, + /** JS_STRING - Use JavaScript strings. */ + JS_STRING = 1, + /** JS_NUMBER - Use JavaScript numbers. */ + JS_NUMBER = 2, + UNRECOGNIZED = -1, +} + +export function fieldOptions_JSTypeFromJSON(object: any): FieldOptions_JSType { + switch (object) { + case 0: + case "JS_NORMAL": + return FieldOptions_JSType.JS_NORMAL; + case 1: + case "JS_STRING": + return FieldOptions_JSType.JS_STRING; + case 2: + case "JS_NUMBER": + return FieldOptions_JSType.JS_NUMBER; + case -1: + case "UNRECOGNIZED": + default: + return FieldOptions_JSType.UNRECOGNIZED; + } +} + +export function fieldOptions_JSTypeToJSON(object: FieldOptions_JSType): string { + switch (object) { + case FieldOptions_JSType.JS_NORMAL: + return "JS_NORMAL"; + case FieldOptions_JSType.JS_STRING: + return "JS_STRING"; + case FieldOptions_JSType.JS_NUMBER: + return "JS_NUMBER"; + default: + return "UNKNOWN"; + } +} + +export interface OneofOptions { + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface EnumOptions { + /** + * Set this option to true to allow mapping different tag names to the same + * value. + */ + allowAlias: boolean; + /** + * Is this enum deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the enum, or it will be completely ignored; in the very least, this + * is a formalization for deprecating enums. + */ + deprecated: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface EnumValueOptions { + /** + * Is this enum value deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the enum value, or it will be completely ignored; in the very least, + * this is a formalization for deprecating enum values. + */ + deprecated: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface ServiceOptions { + /** + * Is this service deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the service, or it will be completely ignored; in the very least, + * this is a formalization for deprecating services. + */ + deprecated: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface MethodOptions { + /** + * Is this method deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the method, or it will be completely ignored; in the very least, + * this is a formalization for deprecating methods. + */ + deprecated: boolean; + idempotencyLevel: MethodOptions_IdempotencyLevel; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +/** + * Is this method side-effect-free (or safe in HTTP parlance), or idempotent, + * or neither? HTTP based RPC implementation may choose GET verb for safe + * methods, and PUT verb for idempotent methods instead of the default POST. + */ +export enum MethodOptions_IdempotencyLevel { + IDEMPOTENCY_UNKNOWN = 0, + /** NO_SIDE_EFFECTS - implies idempotent */ + NO_SIDE_EFFECTS = 1, + /** IDEMPOTENT - idempotent, but may have side effects */ + IDEMPOTENT = 2, + UNRECOGNIZED = -1, +} + +export function methodOptions_IdempotencyLevelFromJSON( + object: any +): MethodOptions_IdempotencyLevel { + switch (object) { + case 0: + case "IDEMPOTENCY_UNKNOWN": + return MethodOptions_IdempotencyLevel.IDEMPOTENCY_UNKNOWN; + case 1: + case "NO_SIDE_EFFECTS": + return MethodOptions_IdempotencyLevel.NO_SIDE_EFFECTS; + case 2: + case "IDEMPOTENT": + return MethodOptions_IdempotencyLevel.IDEMPOTENT; + case -1: + case "UNRECOGNIZED": + default: + return MethodOptions_IdempotencyLevel.UNRECOGNIZED; + } +} + +export function methodOptions_IdempotencyLevelToJSON( + object: MethodOptions_IdempotencyLevel +): string { + switch (object) { + case MethodOptions_IdempotencyLevel.IDEMPOTENCY_UNKNOWN: + return "IDEMPOTENCY_UNKNOWN"; + case MethodOptions_IdempotencyLevel.NO_SIDE_EFFECTS: + return "NO_SIDE_EFFECTS"; + case MethodOptions_IdempotencyLevel.IDEMPOTENT: + return "IDEMPOTENT"; + default: + return "UNKNOWN"; + } +} + +/** + * A message representing a option the parser does not recognize. This only + * appears in options protos created by the compiler::Parser class. + * DescriptorPool resolves these when building Descriptor objects. Therefore, + * options protos in descriptor objects (e.g. returned by Descriptor::options(), + * or produced by Descriptor::CopyTo()) will never have UninterpretedOptions + * in them. + */ +export interface UninterpretedOption { + name: UninterpretedOption_NamePart[]; + /** + * The value of the uninterpreted option, in whatever type the tokenizer + * identified it as during parsing. Exactly one of these should be set. + */ + identifierValue: string; + positiveIntValue: number; + negativeIntValue: number; + doubleValue: number; + stringValue: Uint8Array; + aggregateValue: string; +} + +/** + * The name of the uninterpreted option. Each string represents a segment in + * a dot-separated name. is_extension is true iff a segment represents an + * extension (denoted with parentheses in options specs in .proto files). + * E.g.,{ ["foo", false], ["bar.baz", true], ["qux", false] } represents + * "foo.(bar.baz).qux". + */ +export interface UninterpretedOption_NamePart { + namePart: string; + isExtension: boolean; +} + +/** + * Encapsulates information about the original source file from which a + * FileDescriptorProto was generated. + */ +export interface SourceCodeInfo { + /** + * A Location identifies a piece of source code in a .proto file which + * corresponds to a particular definition. This information is intended + * to be useful to IDEs, code indexers, documentation generators, and similar + * tools. + * + * For example, say we have a file like: + * message Foo { + * optional string foo = 1; + * } + * Let's look at just the field definition: + * optional string foo = 1; + * ^ ^^ ^^ ^ ^^^ + * a bc de f ghi + * We have the following locations: + * span path represents + * [a,i) [ 4, 0, 2, 0 ] The whole field definition. + * [a,b) [ 4, 0, 2, 0, 4 ] The label (optional). + * [c,d) [ 4, 0, 2, 0, 5 ] The type (string). + * [e,f) [ 4, 0, 2, 0, 1 ] The name (foo). + * [g,h) [ 4, 0, 2, 0, 3 ] The number (1). + * + * Notes: + * - A location may refer to a repeated field itself (i.e. not to any + * particular index within it). This is used whenever a set of elements are + * logically enclosed in a single code segment. For example, an entire + * extend block (possibly containing multiple extension definitions) will + * have an outer location whose path refers to the "extensions" repeated + * field without an index. + * - Multiple locations may have the same path. This happens when a single + * logical declaration is spread out across multiple places. The most + * obvious example is the "extend" block again -- there may be multiple + * extend blocks in the same scope, each of which will have the same path. + * - A location's span is not always a subset of its parent's span. For + * example, the "extendee" of an extension declaration appears at the + * beginning of the "extend" block and is shared by all extensions within + * the block. + * - Just because a location's span is a subset of some other location's span + * does not mean that it is a descendant. For example, a "group" defines + * both a type and a field in a single declaration. Thus, the locations + * corresponding to the type and field and their components will overlap. + * - Code which tries to interpret locations should probably be designed to + * ignore those that it doesn't understand, as more types of locations could + * be recorded in the future. + */ + location: SourceCodeInfo_Location[]; +} + +export interface SourceCodeInfo_Location { + /** + * Identifies which part of the FileDescriptorProto was defined at this + * location. + * + * Each element is a field number or an index. They form a path from + * the root FileDescriptorProto to the place where the definition. For + * example, this path: + * [ 4, 3, 2, 7, 1 ] + * refers to: + * file.message_type(3) // 4, 3 + * .field(7) // 2, 7 + * .name() // 1 + * This is because FileDescriptorProto.message_type has field number 4: + * repeated DescriptorProto message_type = 4; + * and DescriptorProto.field has field number 2: + * repeated FieldDescriptorProto field = 2; + * and FieldDescriptorProto.name has field number 1: + * optional string name = 1; + * + * Thus, the above path gives the location of a field name. If we removed + * the last element: + * [ 4, 3, 2, 7 ] + * this path refers to the whole field declaration (from the beginning + * of the label to the terminating semicolon). + */ + path: number[]; + /** + * Always has exactly three or four elements: start line, start column, + * end line (optional, otherwise assumed same as start line), end column. + * These are packed into a single field for efficiency. Note that line + * and column numbers are zero-based -- typically you will want to add + * 1 to each before displaying to a user. + */ + span: number[]; + /** + * If this SourceCodeInfo represents a complete declaration, these are any + * comments appearing before and after the declaration which appear to be + * attached to the declaration. + * + * A series of line comments appearing on consecutive lines, with no other + * tokens appearing on those lines, will be treated as a single comment. + * + * leading_detached_comments will keep paragraphs of comments that appear + * before (but not connected to) the current element. Each paragraph, + * separated by empty lines, will be one comment element in the repeated + * field. + * + * Only the comment content is provided; comment markers (e.g. //) are + * stripped out. For block comments, leading whitespace and an asterisk + * will be stripped from the beginning of each line other than the first. + * Newlines are included in the output. + * + * Examples: + * + * optional int32 foo = 1; // Comment attached to foo. + * // Comment attached to bar. + * optional int32 bar = 2; + * + * optional string baz = 3; + * // Comment attached to baz. + * // Another line attached to baz. + * + * // Comment attached to qux. + * // + * // Another line attached to qux. + * optional double qux = 4; + * + * // Detached comment for corge. This is not leading or trailing comments + * // to qux or corge because there are blank lines separating it from + * // both. + * + * // Detached comment for corge paragraph 2. + * + * optional string corge = 5; + * /* Block comment attached + * * to corge. Leading asterisks + * * will be removed. * / + * /* Block comment attached to + * * grault. * / + * optional int32 grault = 6; + * + * // ignored detached comments. + */ + leadingComments: string; + trailingComments: string; + leadingDetachedComments: string[]; +} + +/** + * Describes the relationship between generated code and its original source + * file. A GeneratedCodeInfo message is associated with only one generated + * source file, but may contain references to different source .proto files. + */ +export interface GeneratedCodeInfo { + /** + * An Annotation connects some span of text in generated code to an element + * of its generating .proto file. + */ + annotation: GeneratedCodeInfo_Annotation[]; +} + +export interface GeneratedCodeInfo_Annotation { + /** + * Identifies the element in the original source .proto file. This field + * is formatted the same as SourceCodeInfo.Location.path. + */ + path: number[]; + /** Identifies the filesystem path to the original source .proto. */ + sourceFile: string; + /** + * Identifies the starting offset in bytes in the generated code + * that relates to the identified object. + */ + begin: number; + /** + * Identifies the ending offset in bytes in the generated code that + * relates to the identified offset. The end offset should be one past + * the last relevant byte (so the length of the text = end - begin). + */ + end: number; +} + +const baseFileDescriptorSet: object = {}; + +export const FileDescriptorSet = { + encode(message: FileDescriptorSet, writer: Writer = Writer.create()): Writer { + for (const v of message.file) { + FileDescriptorProto.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FileDescriptorSet { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFileDescriptorSet } as FileDescriptorSet; + message.file = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.file.push( + FileDescriptorProto.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FileDescriptorSet { + const message = { ...baseFileDescriptorSet } as FileDescriptorSet; + message.file = []; + if (object.file !== undefined && object.file !== null) { + for (const e of object.file) { + message.file.push(FileDescriptorProto.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: FileDescriptorSet): unknown { + const obj: any = {}; + if (message.file) { + obj.file = message.file.map((e) => + e ? FileDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.file = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): FileDescriptorSet { + const message = { ...baseFileDescriptorSet } as FileDescriptorSet; + message.file = []; + if (object.file !== undefined && object.file !== null) { + for (const e of object.file) { + message.file.push(FileDescriptorProto.fromPartial(e)); + } + } + return message; + }, +}; + +const baseFileDescriptorProto: object = { + name: "", + package: "", + dependency: "", + publicDependency: 0, + weakDependency: 0, + syntax: "", +}; + +export const FileDescriptorProto = { + encode( + message: FileDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.package !== "") { + writer.uint32(18).string(message.package); + } + for (const v of message.dependency) { + writer.uint32(26).string(v!); + } + writer.uint32(82).fork(); + for (const v of message.publicDependency) { + writer.int32(v); + } + writer.ldelim(); + writer.uint32(90).fork(); + for (const v of message.weakDependency) { + writer.int32(v); + } + writer.ldelim(); + for (const v of message.messageType) { + DescriptorProto.encode(v!, writer.uint32(34).fork()).ldelim(); + } + for (const v of message.enumType) { + EnumDescriptorProto.encode(v!, writer.uint32(42).fork()).ldelim(); + } + for (const v of message.service) { + ServiceDescriptorProto.encode(v!, writer.uint32(50).fork()).ldelim(); + } + for (const v of message.extension) { + FieldDescriptorProto.encode(v!, writer.uint32(58).fork()).ldelim(); + } + if (message.options !== undefined) { + FileOptions.encode(message.options, writer.uint32(66).fork()).ldelim(); + } + if (message.sourceCodeInfo !== undefined) { + SourceCodeInfo.encode( + message.sourceCodeInfo, + writer.uint32(74).fork() + ).ldelim(); + } + if (message.syntax !== "") { + writer.uint32(98).string(message.syntax); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FileDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFileDescriptorProto } as FileDescriptorProto; + message.dependency = []; + message.publicDependency = []; + message.weakDependency = []; + message.messageType = []; + message.enumType = []; + message.service = []; + message.extension = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.package = reader.string(); + break; + case 3: + message.dependency.push(reader.string()); + break; + case 10: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.publicDependency.push(reader.int32()); + } + } else { + message.publicDependency.push(reader.int32()); + } + break; + case 11: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.weakDependency.push(reader.int32()); + } + } else { + message.weakDependency.push(reader.int32()); + } + break; + case 4: + message.messageType.push( + DescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 5: + message.enumType.push( + EnumDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 6: + message.service.push( + ServiceDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 7: + message.extension.push( + FieldDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 8: + message.options = FileOptions.decode(reader, reader.uint32()); + break; + case 9: + message.sourceCodeInfo = SourceCodeInfo.decode( + reader, + reader.uint32() + ); + break; + case 12: + message.syntax = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FileDescriptorProto { + const message = { ...baseFileDescriptorProto } as FileDescriptorProto; + message.dependency = []; + message.publicDependency = []; + message.weakDependency = []; + message.messageType = []; + message.enumType = []; + message.service = []; + message.extension = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.package !== undefined && object.package !== null) { + message.package = String(object.package); + } else { + message.package = ""; + } + if (object.dependency !== undefined && object.dependency !== null) { + for (const e of object.dependency) { + message.dependency.push(String(e)); + } + } + if ( + object.publicDependency !== undefined && + object.publicDependency !== null + ) { + for (const e of object.publicDependency) { + message.publicDependency.push(Number(e)); + } + } + if (object.weakDependency !== undefined && object.weakDependency !== null) { + for (const e of object.weakDependency) { + message.weakDependency.push(Number(e)); + } + } + if (object.messageType !== undefined && object.messageType !== null) { + for (const e of object.messageType) { + message.messageType.push(DescriptorProto.fromJSON(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromJSON(e)); + } + } + if (object.service !== undefined && object.service !== null) { + for (const e of object.service) { + message.service.push(ServiceDescriptorProto.fromJSON(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = FileOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.sourceCodeInfo !== undefined && object.sourceCodeInfo !== null) { + message.sourceCodeInfo = SourceCodeInfo.fromJSON(object.sourceCodeInfo); + } else { + message.sourceCodeInfo = undefined; + } + if (object.syntax !== undefined && object.syntax !== null) { + message.syntax = String(object.syntax); + } else { + message.syntax = ""; + } + return message; + }, + + toJSON(message: FileDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.package !== undefined && (obj.package = message.package); + if (message.dependency) { + obj.dependency = message.dependency.map((e) => e); + } else { + obj.dependency = []; + } + if (message.publicDependency) { + obj.publicDependency = message.publicDependency.map((e) => e); + } else { + obj.publicDependency = []; + } + if (message.weakDependency) { + obj.weakDependency = message.weakDependency.map((e) => e); + } else { + obj.weakDependency = []; + } + if (message.messageType) { + obj.messageType = message.messageType.map((e) => + e ? DescriptorProto.toJSON(e) : undefined + ); + } else { + obj.messageType = []; + } + if (message.enumType) { + obj.enumType = message.enumType.map((e) => + e ? EnumDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.enumType = []; + } + if (message.service) { + obj.service = message.service.map((e) => + e ? ServiceDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.service = []; + } + if (message.extension) { + obj.extension = message.extension.map((e) => + e ? FieldDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.extension = []; + } + message.options !== undefined && + (obj.options = message.options + ? FileOptions.toJSON(message.options) + : undefined); + message.sourceCodeInfo !== undefined && + (obj.sourceCodeInfo = message.sourceCodeInfo + ? SourceCodeInfo.toJSON(message.sourceCodeInfo) + : undefined); + message.syntax !== undefined && (obj.syntax = message.syntax); + return obj; + }, + + fromPartial(object: DeepPartial): FileDescriptorProto { + const message = { ...baseFileDescriptorProto } as FileDescriptorProto; + message.dependency = []; + message.publicDependency = []; + message.weakDependency = []; + message.messageType = []; + message.enumType = []; + message.service = []; + message.extension = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.package !== undefined && object.package !== null) { + message.package = object.package; + } else { + message.package = ""; + } + if (object.dependency !== undefined && object.dependency !== null) { + for (const e of object.dependency) { + message.dependency.push(e); + } + } + if ( + object.publicDependency !== undefined && + object.publicDependency !== null + ) { + for (const e of object.publicDependency) { + message.publicDependency.push(e); + } + } + if (object.weakDependency !== undefined && object.weakDependency !== null) { + for (const e of object.weakDependency) { + message.weakDependency.push(e); + } + } + if (object.messageType !== undefined && object.messageType !== null) { + for (const e of object.messageType) { + message.messageType.push(DescriptorProto.fromPartial(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromPartial(e)); + } + } + if (object.service !== undefined && object.service !== null) { + for (const e of object.service) { + message.service.push(ServiceDescriptorProto.fromPartial(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = FileOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.sourceCodeInfo !== undefined && object.sourceCodeInfo !== null) { + message.sourceCodeInfo = SourceCodeInfo.fromPartial( + object.sourceCodeInfo + ); + } else { + message.sourceCodeInfo = undefined; + } + if (object.syntax !== undefined && object.syntax !== null) { + message.syntax = object.syntax; + } else { + message.syntax = ""; + } + return message; + }, +}; + +const baseDescriptorProto: object = { name: "", reservedName: "" }; + +export const DescriptorProto = { + encode(message: DescriptorProto, writer: Writer = Writer.create()): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + for (const v of message.field) { + FieldDescriptorProto.encode(v!, writer.uint32(18).fork()).ldelim(); + } + for (const v of message.extension) { + FieldDescriptorProto.encode(v!, writer.uint32(50).fork()).ldelim(); + } + for (const v of message.nestedType) { + DescriptorProto.encode(v!, writer.uint32(26).fork()).ldelim(); + } + for (const v of message.enumType) { + EnumDescriptorProto.encode(v!, writer.uint32(34).fork()).ldelim(); + } + for (const v of message.extensionRange) { + DescriptorProto_ExtensionRange.encode( + v!, + writer.uint32(42).fork() + ).ldelim(); + } + for (const v of message.oneofDecl) { + OneofDescriptorProto.encode(v!, writer.uint32(66).fork()).ldelim(); + } + if (message.options !== undefined) { + MessageOptions.encode(message.options, writer.uint32(58).fork()).ldelim(); + } + for (const v of message.reservedRange) { + DescriptorProto_ReservedRange.encode( + v!, + writer.uint32(74).fork() + ).ldelim(); + } + for (const v of message.reservedName) { + writer.uint32(82).string(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): DescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseDescriptorProto } as DescriptorProto; + message.field = []; + message.extension = []; + message.nestedType = []; + message.enumType = []; + message.extensionRange = []; + message.oneofDecl = []; + message.reservedRange = []; + message.reservedName = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.field.push( + FieldDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 6: + message.extension.push( + FieldDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 3: + message.nestedType.push( + DescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 4: + message.enumType.push( + EnumDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 5: + message.extensionRange.push( + DescriptorProto_ExtensionRange.decode(reader, reader.uint32()) + ); + break; + case 8: + message.oneofDecl.push( + OneofDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 7: + message.options = MessageOptions.decode(reader, reader.uint32()); + break; + case 9: + message.reservedRange.push( + DescriptorProto_ReservedRange.decode(reader, reader.uint32()) + ); + break; + case 10: + message.reservedName.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DescriptorProto { + const message = { ...baseDescriptorProto } as DescriptorProto; + message.field = []; + message.extension = []; + message.nestedType = []; + message.enumType = []; + message.extensionRange = []; + message.oneofDecl = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.field !== undefined && object.field !== null) { + for (const e of object.field) { + message.field.push(FieldDescriptorProto.fromJSON(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromJSON(e)); + } + } + if (object.nestedType !== undefined && object.nestedType !== null) { + for (const e of object.nestedType) { + message.nestedType.push(DescriptorProto.fromJSON(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromJSON(e)); + } + } + if (object.extensionRange !== undefined && object.extensionRange !== null) { + for (const e of object.extensionRange) { + message.extensionRange.push(DescriptorProto_ExtensionRange.fromJSON(e)); + } + } + if (object.oneofDecl !== undefined && object.oneofDecl !== null) { + for (const e of object.oneofDecl) { + message.oneofDecl.push(OneofDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = MessageOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push(DescriptorProto_ReservedRange.fromJSON(e)); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(String(e)); + } + } + return message; + }, + + toJSON(message: DescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + if (message.field) { + obj.field = message.field.map((e) => + e ? FieldDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.field = []; + } + if (message.extension) { + obj.extension = message.extension.map((e) => + e ? FieldDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.extension = []; + } + if (message.nestedType) { + obj.nestedType = message.nestedType.map((e) => + e ? DescriptorProto.toJSON(e) : undefined + ); + } else { + obj.nestedType = []; + } + if (message.enumType) { + obj.enumType = message.enumType.map((e) => + e ? EnumDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.enumType = []; + } + if (message.extensionRange) { + obj.extensionRange = message.extensionRange.map((e) => + e ? DescriptorProto_ExtensionRange.toJSON(e) : undefined + ); + } else { + obj.extensionRange = []; + } + if (message.oneofDecl) { + obj.oneofDecl = message.oneofDecl.map((e) => + e ? OneofDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.oneofDecl = []; + } + message.options !== undefined && + (obj.options = message.options + ? MessageOptions.toJSON(message.options) + : undefined); + if (message.reservedRange) { + obj.reservedRange = message.reservedRange.map((e) => + e ? DescriptorProto_ReservedRange.toJSON(e) : undefined + ); + } else { + obj.reservedRange = []; + } + if (message.reservedName) { + obj.reservedName = message.reservedName.map((e) => e); + } else { + obj.reservedName = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): DescriptorProto { + const message = { ...baseDescriptorProto } as DescriptorProto; + message.field = []; + message.extension = []; + message.nestedType = []; + message.enumType = []; + message.extensionRange = []; + message.oneofDecl = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.field !== undefined && object.field !== null) { + for (const e of object.field) { + message.field.push(FieldDescriptorProto.fromPartial(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromPartial(e)); + } + } + if (object.nestedType !== undefined && object.nestedType !== null) { + for (const e of object.nestedType) { + message.nestedType.push(DescriptorProto.fromPartial(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromPartial(e)); + } + } + if (object.extensionRange !== undefined && object.extensionRange !== null) { + for (const e of object.extensionRange) { + message.extensionRange.push( + DescriptorProto_ExtensionRange.fromPartial(e) + ); + } + } + if (object.oneofDecl !== undefined && object.oneofDecl !== null) { + for (const e of object.oneofDecl) { + message.oneofDecl.push(OneofDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = MessageOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push( + DescriptorProto_ReservedRange.fromPartial(e) + ); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(e); + } + } + return message; + }, +}; + +const baseDescriptorProto_ExtensionRange: object = { start: 0, end: 0 }; + +export const DescriptorProto_ExtensionRange = { + encode( + message: DescriptorProto_ExtensionRange, + writer: Writer = Writer.create() + ): Writer { + if (message.start !== 0) { + writer.uint32(8).int32(message.start); + } + if (message.end !== 0) { + writer.uint32(16).int32(message.end); + } + if (message.options !== undefined) { + ExtensionRangeOptions.encode( + message.options, + writer.uint32(26).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): DescriptorProto_ExtensionRange { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseDescriptorProto_ExtensionRange, + } as DescriptorProto_ExtensionRange; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.start = reader.int32(); + break; + case 2: + message.end = reader.int32(); + break; + case 3: + message.options = ExtensionRangeOptions.decode( + reader, + reader.uint32() + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DescriptorProto_ExtensionRange { + const message = { + ...baseDescriptorProto_ExtensionRange, + } as DescriptorProto_ExtensionRange; + if (object.start !== undefined && object.start !== null) { + message.start = Number(object.start); + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = ExtensionRangeOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: DescriptorProto_ExtensionRange): unknown { + const obj: any = {}; + message.start !== undefined && (obj.start = message.start); + message.end !== undefined && (obj.end = message.end); + message.options !== undefined && + (obj.options = message.options + ? ExtensionRangeOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): DescriptorProto_ExtensionRange { + const message = { + ...baseDescriptorProto_ExtensionRange, + } as DescriptorProto_ExtensionRange; + if (object.start !== undefined && object.start !== null) { + message.start = object.start; + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = ExtensionRangeOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseDescriptorProto_ReservedRange: object = { start: 0, end: 0 }; + +export const DescriptorProto_ReservedRange = { + encode( + message: DescriptorProto_ReservedRange, + writer: Writer = Writer.create() + ): Writer { + if (message.start !== 0) { + writer.uint32(8).int32(message.start); + } + if (message.end !== 0) { + writer.uint32(16).int32(message.end); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): DescriptorProto_ReservedRange { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseDescriptorProto_ReservedRange, + } as DescriptorProto_ReservedRange; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.start = reader.int32(); + break; + case 2: + message.end = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DescriptorProto_ReservedRange { + const message = { + ...baseDescriptorProto_ReservedRange, + } as DescriptorProto_ReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = Number(object.start); + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + return message; + }, + + toJSON(message: DescriptorProto_ReservedRange): unknown { + const obj: any = {}; + message.start !== undefined && (obj.start = message.start); + message.end !== undefined && (obj.end = message.end); + return obj; + }, + + fromPartial( + object: DeepPartial + ): DescriptorProto_ReservedRange { + const message = { + ...baseDescriptorProto_ReservedRange, + } as DescriptorProto_ReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = object.start; + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + return message; + }, +}; + +const baseExtensionRangeOptions: object = {}; + +export const ExtensionRangeOptions = { + encode( + message: ExtensionRangeOptions, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ExtensionRangeOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseExtensionRangeOptions } as ExtensionRangeOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ExtensionRangeOptions { + const message = { ...baseExtensionRangeOptions } as ExtensionRangeOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: ExtensionRangeOptions): unknown { + const obj: any = {}; + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial( + object: DeepPartial + ): ExtensionRangeOptions { + const message = { ...baseExtensionRangeOptions } as ExtensionRangeOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseFieldDescriptorProto: object = { + name: "", + number: 0, + label: 1, + type: 1, + typeName: "", + extendee: "", + defaultValue: "", + oneofIndex: 0, + jsonName: "", + proto3Optional: false, +}; + +export const FieldDescriptorProto = { + encode( + message: FieldDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.number !== 0) { + writer.uint32(24).int32(message.number); + } + if (message.label !== 1) { + writer.uint32(32).int32(message.label); + } + if (message.type !== 1) { + writer.uint32(40).int32(message.type); + } + if (message.typeName !== "") { + writer.uint32(50).string(message.typeName); + } + if (message.extendee !== "") { + writer.uint32(18).string(message.extendee); + } + if (message.defaultValue !== "") { + writer.uint32(58).string(message.defaultValue); + } + if (message.oneofIndex !== 0) { + writer.uint32(72).int32(message.oneofIndex); + } + if (message.jsonName !== "") { + writer.uint32(82).string(message.jsonName); + } + if (message.options !== undefined) { + FieldOptions.encode(message.options, writer.uint32(66).fork()).ldelim(); + } + if (message.proto3Optional === true) { + writer.uint32(136).bool(message.proto3Optional); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FieldDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFieldDescriptorProto } as FieldDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 3: + message.number = reader.int32(); + break; + case 4: + message.label = reader.int32() as any; + break; + case 5: + message.type = reader.int32() as any; + break; + case 6: + message.typeName = reader.string(); + break; + case 2: + message.extendee = reader.string(); + break; + case 7: + message.defaultValue = reader.string(); + break; + case 9: + message.oneofIndex = reader.int32(); + break; + case 10: + message.jsonName = reader.string(); + break; + case 8: + message.options = FieldOptions.decode(reader, reader.uint32()); + break; + case 17: + message.proto3Optional = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FieldDescriptorProto { + const message = { ...baseFieldDescriptorProto } as FieldDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = Number(object.number); + } else { + message.number = 0; + } + if (object.label !== undefined && object.label !== null) { + message.label = fieldDescriptorProto_LabelFromJSON(object.label); + } else { + message.label = 1; + } + if (object.type !== undefined && object.type !== null) { + message.type = fieldDescriptorProto_TypeFromJSON(object.type); + } else { + message.type = 1; + } + if (object.typeName !== undefined && object.typeName !== null) { + message.typeName = String(object.typeName); + } else { + message.typeName = ""; + } + if (object.extendee !== undefined && object.extendee !== null) { + message.extendee = String(object.extendee); + } else { + message.extendee = ""; + } + if (object.defaultValue !== undefined && object.defaultValue !== null) { + message.defaultValue = String(object.defaultValue); + } else { + message.defaultValue = ""; + } + if (object.oneofIndex !== undefined && object.oneofIndex !== null) { + message.oneofIndex = Number(object.oneofIndex); + } else { + message.oneofIndex = 0; + } + if (object.jsonName !== undefined && object.jsonName !== null) { + message.jsonName = String(object.jsonName); + } else { + message.jsonName = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = FieldOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.proto3Optional !== undefined && object.proto3Optional !== null) { + message.proto3Optional = Boolean(object.proto3Optional); + } else { + message.proto3Optional = false; + } + return message; + }, + + toJSON(message: FieldDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.number !== undefined && (obj.number = message.number); + message.label !== undefined && + (obj.label = fieldDescriptorProto_LabelToJSON(message.label)); + message.type !== undefined && + (obj.type = fieldDescriptorProto_TypeToJSON(message.type)); + message.typeName !== undefined && (obj.typeName = message.typeName); + message.extendee !== undefined && (obj.extendee = message.extendee); + message.defaultValue !== undefined && + (obj.defaultValue = message.defaultValue); + message.oneofIndex !== undefined && (obj.oneofIndex = message.oneofIndex); + message.jsonName !== undefined && (obj.jsonName = message.jsonName); + message.options !== undefined && + (obj.options = message.options + ? FieldOptions.toJSON(message.options) + : undefined); + message.proto3Optional !== undefined && + (obj.proto3Optional = message.proto3Optional); + return obj; + }, + + fromPartial(object: DeepPartial): FieldDescriptorProto { + const message = { ...baseFieldDescriptorProto } as FieldDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = object.number; + } else { + message.number = 0; + } + if (object.label !== undefined && object.label !== null) { + message.label = object.label; + } else { + message.label = 1; + } + if (object.type !== undefined && object.type !== null) { + message.type = object.type; + } else { + message.type = 1; + } + if (object.typeName !== undefined && object.typeName !== null) { + message.typeName = object.typeName; + } else { + message.typeName = ""; + } + if (object.extendee !== undefined && object.extendee !== null) { + message.extendee = object.extendee; + } else { + message.extendee = ""; + } + if (object.defaultValue !== undefined && object.defaultValue !== null) { + message.defaultValue = object.defaultValue; + } else { + message.defaultValue = ""; + } + if (object.oneofIndex !== undefined && object.oneofIndex !== null) { + message.oneofIndex = object.oneofIndex; + } else { + message.oneofIndex = 0; + } + if (object.jsonName !== undefined && object.jsonName !== null) { + message.jsonName = object.jsonName; + } else { + message.jsonName = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = FieldOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.proto3Optional !== undefined && object.proto3Optional !== null) { + message.proto3Optional = object.proto3Optional; + } else { + message.proto3Optional = false; + } + return message; + }, +}; + +const baseOneofDescriptorProto: object = { name: "" }; + +export const OneofDescriptorProto = { + encode( + message: OneofDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.options !== undefined) { + OneofOptions.encode(message.options, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): OneofDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseOneofDescriptorProto } as OneofDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.options = OneofOptions.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): OneofDescriptorProto { + const message = { ...baseOneofDescriptorProto } as OneofDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = OneofOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: OneofDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.options !== undefined && + (obj.options = message.options + ? OneofOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): OneofDescriptorProto { + const message = { ...baseOneofDescriptorProto } as OneofDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = OneofOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseEnumDescriptorProto: object = { name: "", reservedName: "" }; + +export const EnumDescriptorProto = { + encode( + message: EnumDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + for (const v of message.value) { + EnumValueDescriptorProto.encode(v!, writer.uint32(18).fork()).ldelim(); + } + if (message.options !== undefined) { + EnumOptions.encode(message.options, writer.uint32(26).fork()).ldelim(); + } + for (const v of message.reservedRange) { + EnumDescriptorProto_EnumReservedRange.encode( + v!, + writer.uint32(34).fork() + ).ldelim(); + } + for (const v of message.reservedName) { + writer.uint32(42).string(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): EnumDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseEnumDescriptorProto } as EnumDescriptorProto; + message.value = []; + message.reservedRange = []; + message.reservedName = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.value.push( + EnumValueDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 3: + message.options = EnumOptions.decode(reader, reader.uint32()); + break; + case 4: + message.reservedRange.push( + EnumDescriptorProto_EnumReservedRange.decode( + reader, + reader.uint32() + ) + ); + break; + case 5: + message.reservedName.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumDescriptorProto { + const message = { ...baseEnumDescriptorProto } as EnumDescriptorProto; + message.value = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.value !== undefined && object.value !== null) { + for (const e of object.value) { + message.value.push(EnumValueDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push( + EnumDescriptorProto_EnumReservedRange.fromJSON(e) + ); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(String(e)); + } + } + return message; + }, + + toJSON(message: EnumDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + if (message.value) { + obj.value = message.value.map((e) => + e ? EnumValueDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.value = []; + } + message.options !== undefined && + (obj.options = message.options + ? EnumOptions.toJSON(message.options) + : undefined); + if (message.reservedRange) { + obj.reservedRange = message.reservedRange.map((e) => + e ? EnumDescriptorProto_EnumReservedRange.toJSON(e) : undefined + ); + } else { + obj.reservedRange = []; + } + if (message.reservedName) { + obj.reservedName = message.reservedName.map((e) => e); + } else { + obj.reservedName = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): EnumDescriptorProto { + const message = { ...baseEnumDescriptorProto } as EnumDescriptorProto; + message.value = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.value !== undefined && object.value !== null) { + for (const e of object.value) { + message.value.push(EnumValueDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push( + EnumDescriptorProto_EnumReservedRange.fromPartial(e) + ); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(e); + } + } + return message; + }, +}; + +const baseEnumDescriptorProto_EnumReservedRange: object = { start: 0, end: 0 }; + +export const EnumDescriptorProto_EnumReservedRange = { + encode( + message: EnumDescriptorProto_EnumReservedRange, + writer: Writer = Writer.create() + ): Writer { + if (message.start !== 0) { + writer.uint32(8).int32(message.start); + } + if (message.end !== 0) { + writer.uint32(16).int32(message.end); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): EnumDescriptorProto_EnumReservedRange { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseEnumDescriptorProto_EnumReservedRange, + } as EnumDescriptorProto_EnumReservedRange; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.start = reader.int32(); + break; + case 2: + message.end = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumDescriptorProto_EnumReservedRange { + const message = { + ...baseEnumDescriptorProto_EnumReservedRange, + } as EnumDescriptorProto_EnumReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = Number(object.start); + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + return message; + }, + + toJSON(message: EnumDescriptorProto_EnumReservedRange): unknown { + const obj: any = {}; + message.start !== undefined && (obj.start = message.start); + message.end !== undefined && (obj.end = message.end); + return obj; + }, + + fromPartial( + object: DeepPartial + ): EnumDescriptorProto_EnumReservedRange { + const message = { + ...baseEnumDescriptorProto_EnumReservedRange, + } as EnumDescriptorProto_EnumReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = object.start; + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + return message; + }, +}; + +const baseEnumValueDescriptorProto: object = { name: "", number: 0 }; + +export const EnumValueDescriptorProto = { + encode( + message: EnumValueDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.number !== 0) { + writer.uint32(16).int32(message.number); + } + if (message.options !== undefined) { + EnumValueOptions.encode( + message.options, + writer.uint32(26).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): EnumValueDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseEnumValueDescriptorProto, + } as EnumValueDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.number = reader.int32(); + break; + case 3: + message.options = EnumValueOptions.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumValueDescriptorProto { + const message = { + ...baseEnumValueDescriptorProto, + } as EnumValueDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = Number(object.number); + } else { + message.number = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumValueOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: EnumValueDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.number !== undefined && (obj.number = message.number); + message.options !== undefined && + (obj.options = message.options + ? EnumValueOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): EnumValueDescriptorProto { + const message = { + ...baseEnumValueDescriptorProto, + } as EnumValueDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = object.number; + } else { + message.number = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumValueOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseServiceDescriptorProto: object = { name: "" }; + +export const ServiceDescriptorProto = { + encode( + message: ServiceDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + for (const v of message.method) { + MethodDescriptorProto.encode(v!, writer.uint32(18).fork()).ldelim(); + } + if (message.options !== undefined) { + ServiceOptions.encode(message.options, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ServiceDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseServiceDescriptorProto } as ServiceDescriptorProto; + message.method = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.method.push( + MethodDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 3: + message.options = ServiceOptions.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ServiceDescriptorProto { + const message = { ...baseServiceDescriptorProto } as ServiceDescriptorProto; + message.method = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.method !== undefined && object.method !== null) { + for (const e of object.method) { + message.method.push(MethodDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = ServiceOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: ServiceDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + if (message.method) { + obj.method = message.method.map((e) => + e ? MethodDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.method = []; + } + message.options !== undefined && + (obj.options = message.options + ? ServiceOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): ServiceDescriptorProto { + const message = { ...baseServiceDescriptorProto } as ServiceDescriptorProto; + message.method = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.method !== undefined && object.method !== null) { + for (const e of object.method) { + message.method.push(MethodDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = ServiceOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseMethodDescriptorProto: object = { + name: "", + inputType: "", + outputType: "", + clientStreaming: false, + serverStreaming: false, +}; + +export const MethodDescriptorProto = { + encode( + message: MethodDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.inputType !== "") { + writer.uint32(18).string(message.inputType); + } + if (message.outputType !== "") { + writer.uint32(26).string(message.outputType); + } + if (message.options !== undefined) { + MethodOptions.encode(message.options, writer.uint32(34).fork()).ldelim(); + } + if (message.clientStreaming === true) { + writer.uint32(40).bool(message.clientStreaming); + } + if (message.serverStreaming === true) { + writer.uint32(48).bool(message.serverStreaming); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MethodDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMethodDescriptorProto } as MethodDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.inputType = reader.string(); + break; + case 3: + message.outputType = reader.string(); + break; + case 4: + message.options = MethodOptions.decode(reader, reader.uint32()); + break; + case 5: + message.clientStreaming = reader.bool(); + break; + case 6: + message.serverStreaming = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MethodDescriptorProto { + const message = { ...baseMethodDescriptorProto } as MethodDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.inputType !== undefined && object.inputType !== null) { + message.inputType = String(object.inputType); + } else { + message.inputType = ""; + } + if (object.outputType !== undefined && object.outputType !== null) { + message.outputType = String(object.outputType); + } else { + message.outputType = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = MethodOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if ( + object.clientStreaming !== undefined && + object.clientStreaming !== null + ) { + message.clientStreaming = Boolean(object.clientStreaming); + } else { + message.clientStreaming = false; + } + if ( + object.serverStreaming !== undefined && + object.serverStreaming !== null + ) { + message.serverStreaming = Boolean(object.serverStreaming); + } else { + message.serverStreaming = false; + } + return message; + }, + + toJSON(message: MethodDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.inputType !== undefined && (obj.inputType = message.inputType); + message.outputType !== undefined && (obj.outputType = message.outputType); + message.options !== undefined && + (obj.options = message.options + ? MethodOptions.toJSON(message.options) + : undefined); + message.clientStreaming !== undefined && + (obj.clientStreaming = message.clientStreaming); + message.serverStreaming !== undefined && + (obj.serverStreaming = message.serverStreaming); + return obj; + }, + + fromPartial( + object: DeepPartial + ): MethodDescriptorProto { + const message = { ...baseMethodDescriptorProto } as MethodDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.inputType !== undefined && object.inputType !== null) { + message.inputType = object.inputType; + } else { + message.inputType = ""; + } + if (object.outputType !== undefined && object.outputType !== null) { + message.outputType = object.outputType; + } else { + message.outputType = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = MethodOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if ( + object.clientStreaming !== undefined && + object.clientStreaming !== null + ) { + message.clientStreaming = object.clientStreaming; + } else { + message.clientStreaming = false; + } + if ( + object.serverStreaming !== undefined && + object.serverStreaming !== null + ) { + message.serverStreaming = object.serverStreaming; + } else { + message.serverStreaming = false; + } + return message; + }, +}; + +const baseFileOptions: object = { + javaPackage: "", + javaOuterClassname: "", + javaMultipleFiles: false, + javaGenerateEqualsAndHash: false, + javaStringCheckUtf8: false, + optimizeFor: 1, + goPackage: "", + ccGenericServices: false, + javaGenericServices: false, + pyGenericServices: false, + phpGenericServices: false, + deprecated: false, + ccEnableArenas: false, + objcClassPrefix: "", + csharpNamespace: "", + swiftPrefix: "", + phpClassPrefix: "", + phpNamespace: "", + phpMetadataNamespace: "", + rubyPackage: "", +}; + +export const FileOptions = { + encode(message: FileOptions, writer: Writer = Writer.create()): Writer { + if (message.javaPackage !== "") { + writer.uint32(10).string(message.javaPackage); + } + if (message.javaOuterClassname !== "") { + writer.uint32(66).string(message.javaOuterClassname); + } + if (message.javaMultipleFiles === true) { + writer.uint32(80).bool(message.javaMultipleFiles); + } + if (message.javaGenerateEqualsAndHash === true) { + writer.uint32(160).bool(message.javaGenerateEqualsAndHash); + } + if (message.javaStringCheckUtf8 === true) { + writer.uint32(216).bool(message.javaStringCheckUtf8); + } + if (message.optimizeFor !== 1) { + writer.uint32(72).int32(message.optimizeFor); + } + if (message.goPackage !== "") { + writer.uint32(90).string(message.goPackage); + } + if (message.ccGenericServices === true) { + writer.uint32(128).bool(message.ccGenericServices); + } + if (message.javaGenericServices === true) { + writer.uint32(136).bool(message.javaGenericServices); + } + if (message.pyGenericServices === true) { + writer.uint32(144).bool(message.pyGenericServices); + } + if (message.phpGenericServices === true) { + writer.uint32(336).bool(message.phpGenericServices); + } + if (message.deprecated === true) { + writer.uint32(184).bool(message.deprecated); + } + if (message.ccEnableArenas === true) { + writer.uint32(248).bool(message.ccEnableArenas); + } + if (message.objcClassPrefix !== "") { + writer.uint32(290).string(message.objcClassPrefix); + } + if (message.csharpNamespace !== "") { + writer.uint32(298).string(message.csharpNamespace); + } + if (message.swiftPrefix !== "") { + writer.uint32(314).string(message.swiftPrefix); + } + if (message.phpClassPrefix !== "") { + writer.uint32(322).string(message.phpClassPrefix); + } + if (message.phpNamespace !== "") { + writer.uint32(330).string(message.phpNamespace); + } + if (message.phpMetadataNamespace !== "") { + writer.uint32(354).string(message.phpMetadataNamespace); + } + if (message.rubyPackage !== "") { + writer.uint32(362).string(message.rubyPackage); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FileOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFileOptions } as FileOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.javaPackage = reader.string(); + break; + case 8: + message.javaOuterClassname = reader.string(); + break; + case 10: + message.javaMultipleFiles = reader.bool(); + break; + case 20: + message.javaGenerateEqualsAndHash = reader.bool(); + break; + case 27: + message.javaStringCheckUtf8 = reader.bool(); + break; + case 9: + message.optimizeFor = reader.int32() as any; + break; + case 11: + message.goPackage = reader.string(); + break; + case 16: + message.ccGenericServices = reader.bool(); + break; + case 17: + message.javaGenericServices = reader.bool(); + break; + case 18: + message.pyGenericServices = reader.bool(); + break; + case 42: + message.phpGenericServices = reader.bool(); + break; + case 23: + message.deprecated = reader.bool(); + break; + case 31: + message.ccEnableArenas = reader.bool(); + break; + case 36: + message.objcClassPrefix = reader.string(); + break; + case 37: + message.csharpNamespace = reader.string(); + break; + case 39: + message.swiftPrefix = reader.string(); + break; + case 40: + message.phpClassPrefix = reader.string(); + break; + case 41: + message.phpNamespace = reader.string(); + break; + case 44: + message.phpMetadataNamespace = reader.string(); + break; + case 45: + message.rubyPackage = reader.string(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FileOptions { + const message = { ...baseFileOptions } as FileOptions; + message.uninterpretedOption = []; + if (object.javaPackage !== undefined && object.javaPackage !== null) { + message.javaPackage = String(object.javaPackage); + } else { + message.javaPackage = ""; + } + if ( + object.javaOuterClassname !== undefined && + object.javaOuterClassname !== null + ) { + message.javaOuterClassname = String(object.javaOuterClassname); + } else { + message.javaOuterClassname = ""; + } + if ( + object.javaMultipleFiles !== undefined && + object.javaMultipleFiles !== null + ) { + message.javaMultipleFiles = Boolean(object.javaMultipleFiles); + } else { + message.javaMultipleFiles = false; + } + if ( + object.javaGenerateEqualsAndHash !== undefined && + object.javaGenerateEqualsAndHash !== null + ) { + message.javaGenerateEqualsAndHash = Boolean( + object.javaGenerateEqualsAndHash + ); + } else { + message.javaGenerateEqualsAndHash = false; + } + if ( + object.javaStringCheckUtf8 !== undefined && + object.javaStringCheckUtf8 !== null + ) { + message.javaStringCheckUtf8 = Boolean(object.javaStringCheckUtf8); + } else { + message.javaStringCheckUtf8 = false; + } + if (object.optimizeFor !== undefined && object.optimizeFor !== null) { + message.optimizeFor = fileOptions_OptimizeModeFromJSON( + object.optimizeFor + ); + } else { + message.optimizeFor = 1; + } + if (object.goPackage !== undefined && object.goPackage !== null) { + message.goPackage = String(object.goPackage); + } else { + message.goPackage = ""; + } + if ( + object.ccGenericServices !== undefined && + object.ccGenericServices !== null + ) { + message.ccGenericServices = Boolean(object.ccGenericServices); + } else { + message.ccGenericServices = false; + } + if ( + object.javaGenericServices !== undefined && + object.javaGenericServices !== null + ) { + message.javaGenericServices = Boolean(object.javaGenericServices); + } else { + message.javaGenericServices = false; + } + if ( + object.pyGenericServices !== undefined && + object.pyGenericServices !== null + ) { + message.pyGenericServices = Boolean(object.pyGenericServices); + } else { + message.pyGenericServices = false; + } + if ( + object.phpGenericServices !== undefined && + object.phpGenericServices !== null + ) { + message.phpGenericServices = Boolean(object.phpGenericServices); + } else { + message.phpGenericServices = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if (object.ccEnableArenas !== undefined && object.ccEnableArenas !== null) { + message.ccEnableArenas = Boolean(object.ccEnableArenas); + } else { + message.ccEnableArenas = false; + } + if ( + object.objcClassPrefix !== undefined && + object.objcClassPrefix !== null + ) { + message.objcClassPrefix = String(object.objcClassPrefix); + } else { + message.objcClassPrefix = ""; + } + if ( + object.csharpNamespace !== undefined && + object.csharpNamespace !== null + ) { + message.csharpNamespace = String(object.csharpNamespace); + } else { + message.csharpNamespace = ""; + } + if (object.swiftPrefix !== undefined && object.swiftPrefix !== null) { + message.swiftPrefix = String(object.swiftPrefix); + } else { + message.swiftPrefix = ""; + } + if (object.phpClassPrefix !== undefined && object.phpClassPrefix !== null) { + message.phpClassPrefix = String(object.phpClassPrefix); + } else { + message.phpClassPrefix = ""; + } + if (object.phpNamespace !== undefined && object.phpNamespace !== null) { + message.phpNamespace = String(object.phpNamespace); + } else { + message.phpNamespace = ""; + } + if ( + object.phpMetadataNamespace !== undefined && + object.phpMetadataNamespace !== null + ) { + message.phpMetadataNamespace = String(object.phpMetadataNamespace); + } else { + message.phpMetadataNamespace = ""; + } + if (object.rubyPackage !== undefined && object.rubyPackage !== null) { + message.rubyPackage = String(object.rubyPackage); + } else { + message.rubyPackage = ""; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: FileOptions): unknown { + const obj: any = {}; + message.javaPackage !== undefined && + (obj.javaPackage = message.javaPackage); + message.javaOuterClassname !== undefined && + (obj.javaOuterClassname = message.javaOuterClassname); + message.javaMultipleFiles !== undefined && + (obj.javaMultipleFiles = message.javaMultipleFiles); + message.javaGenerateEqualsAndHash !== undefined && + (obj.javaGenerateEqualsAndHash = message.javaGenerateEqualsAndHash); + message.javaStringCheckUtf8 !== undefined && + (obj.javaStringCheckUtf8 = message.javaStringCheckUtf8); + message.optimizeFor !== undefined && + (obj.optimizeFor = fileOptions_OptimizeModeToJSON(message.optimizeFor)); + message.goPackage !== undefined && (obj.goPackage = message.goPackage); + message.ccGenericServices !== undefined && + (obj.ccGenericServices = message.ccGenericServices); + message.javaGenericServices !== undefined && + (obj.javaGenericServices = message.javaGenericServices); + message.pyGenericServices !== undefined && + (obj.pyGenericServices = message.pyGenericServices); + message.phpGenericServices !== undefined && + (obj.phpGenericServices = message.phpGenericServices); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.ccEnableArenas !== undefined && + (obj.ccEnableArenas = message.ccEnableArenas); + message.objcClassPrefix !== undefined && + (obj.objcClassPrefix = message.objcClassPrefix); + message.csharpNamespace !== undefined && + (obj.csharpNamespace = message.csharpNamespace); + message.swiftPrefix !== undefined && + (obj.swiftPrefix = message.swiftPrefix); + message.phpClassPrefix !== undefined && + (obj.phpClassPrefix = message.phpClassPrefix); + message.phpNamespace !== undefined && + (obj.phpNamespace = message.phpNamespace); + message.phpMetadataNamespace !== undefined && + (obj.phpMetadataNamespace = message.phpMetadataNamespace); + message.rubyPackage !== undefined && + (obj.rubyPackage = message.rubyPackage); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): FileOptions { + const message = { ...baseFileOptions } as FileOptions; + message.uninterpretedOption = []; + if (object.javaPackage !== undefined && object.javaPackage !== null) { + message.javaPackage = object.javaPackage; + } else { + message.javaPackage = ""; + } + if ( + object.javaOuterClassname !== undefined && + object.javaOuterClassname !== null + ) { + message.javaOuterClassname = object.javaOuterClassname; + } else { + message.javaOuterClassname = ""; + } + if ( + object.javaMultipleFiles !== undefined && + object.javaMultipleFiles !== null + ) { + message.javaMultipleFiles = object.javaMultipleFiles; + } else { + message.javaMultipleFiles = false; + } + if ( + object.javaGenerateEqualsAndHash !== undefined && + object.javaGenerateEqualsAndHash !== null + ) { + message.javaGenerateEqualsAndHash = object.javaGenerateEqualsAndHash; + } else { + message.javaGenerateEqualsAndHash = false; + } + if ( + object.javaStringCheckUtf8 !== undefined && + object.javaStringCheckUtf8 !== null + ) { + message.javaStringCheckUtf8 = object.javaStringCheckUtf8; + } else { + message.javaStringCheckUtf8 = false; + } + if (object.optimizeFor !== undefined && object.optimizeFor !== null) { + message.optimizeFor = object.optimizeFor; + } else { + message.optimizeFor = 1; + } + if (object.goPackage !== undefined && object.goPackage !== null) { + message.goPackage = object.goPackage; + } else { + message.goPackage = ""; + } + if ( + object.ccGenericServices !== undefined && + object.ccGenericServices !== null + ) { + message.ccGenericServices = object.ccGenericServices; + } else { + message.ccGenericServices = false; + } + if ( + object.javaGenericServices !== undefined && + object.javaGenericServices !== null + ) { + message.javaGenericServices = object.javaGenericServices; + } else { + message.javaGenericServices = false; + } + if ( + object.pyGenericServices !== undefined && + object.pyGenericServices !== null + ) { + message.pyGenericServices = object.pyGenericServices; + } else { + message.pyGenericServices = false; + } + if ( + object.phpGenericServices !== undefined && + object.phpGenericServices !== null + ) { + message.phpGenericServices = object.phpGenericServices; + } else { + message.phpGenericServices = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if (object.ccEnableArenas !== undefined && object.ccEnableArenas !== null) { + message.ccEnableArenas = object.ccEnableArenas; + } else { + message.ccEnableArenas = false; + } + if ( + object.objcClassPrefix !== undefined && + object.objcClassPrefix !== null + ) { + message.objcClassPrefix = object.objcClassPrefix; + } else { + message.objcClassPrefix = ""; + } + if ( + object.csharpNamespace !== undefined && + object.csharpNamespace !== null + ) { + message.csharpNamespace = object.csharpNamespace; + } else { + message.csharpNamespace = ""; + } + if (object.swiftPrefix !== undefined && object.swiftPrefix !== null) { + message.swiftPrefix = object.swiftPrefix; + } else { + message.swiftPrefix = ""; + } + if (object.phpClassPrefix !== undefined && object.phpClassPrefix !== null) { + message.phpClassPrefix = object.phpClassPrefix; + } else { + message.phpClassPrefix = ""; + } + if (object.phpNamespace !== undefined && object.phpNamespace !== null) { + message.phpNamespace = object.phpNamespace; + } else { + message.phpNamespace = ""; + } + if ( + object.phpMetadataNamespace !== undefined && + object.phpMetadataNamespace !== null + ) { + message.phpMetadataNamespace = object.phpMetadataNamespace; + } else { + message.phpMetadataNamespace = ""; + } + if (object.rubyPackage !== undefined && object.rubyPackage !== null) { + message.rubyPackage = object.rubyPackage; + } else { + message.rubyPackage = ""; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseMessageOptions: object = { + messageSetWireFormat: false, + noStandardDescriptorAccessor: false, + deprecated: false, + mapEntry: false, +}; + +export const MessageOptions = { + encode(message: MessageOptions, writer: Writer = Writer.create()): Writer { + if (message.messageSetWireFormat === true) { + writer.uint32(8).bool(message.messageSetWireFormat); + } + if (message.noStandardDescriptorAccessor === true) { + writer.uint32(16).bool(message.noStandardDescriptorAccessor); + } + if (message.deprecated === true) { + writer.uint32(24).bool(message.deprecated); + } + if (message.mapEntry === true) { + writer.uint32(56).bool(message.mapEntry); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MessageOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMessageOptions } as MessageOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.messageSetWireFormat = reader.bool(); + break; + case 2: + message.noStandardDescriptorAccessor = reader.bool(); + break; + case 3: + message.deprecated = reader.bool(); + break; + case 7: + message.mapEntry = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MessageOptions { + const message = { ...baseMessageOptions } as MessageOptions; + message.uninterpretedOption = []; + if ( + object.messageSetWireFormat !== undefined && + object.messageSetWireFormat !== null + ) { + message.messageSetWireFormat = Boolean(object.messageSetWireFormat); + } else { + message.messageSetWireFormat = false; + } + if ( + object.noStandardDescriptorAccessor !== undefined && + object.noStandardDescriptorAccessor !== null + ) { + message.noStandardDescriptorAccessor = Boolean( + object.noStandardDescriptorAccessor + ); + } else { + message.noStandardDescriptorAccessor = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if (object.mapEntry !== undefined && object.mapEntry !== null) { + message.mapEntry = Boolean(object.mapEntry); + } else { + message.mapEntry = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: MessageOptions): unknown { + const obj: any = {}; + message.messageSetWireFormat !== undefined && + (obj.messageSetWireFormat = message.messageSetWireFormat); + message.noStandardDescriptorAccessor !== undefined && + (obj.noStandardDescriptorAccessor = message.noStandardDescriptorAccessor); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.mapEntry !== undefined && (obj.mapEntry = message.mapEntry); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): MessageOptions { + const message = { ...baseMessageOptions } as MessageOptions; + message.uninterpretedOption = []; + if ( + object.messageSetWireFormat !== undefined && + object.messageSetWireFormat !== null + ) { + message.messageSetWireFormat = object.messageSetWireFormat; + } else { + message.messageSetWireFormat = false; + } + if ( + object.noStandardDescriptorAccessor !== undefined && + object.noStandardDescriptorAccessor !== null + ) { + message.noStandardDescriptorAccessor = + object.noStandardDescriptorAccessor; + } else { + message.noStandardDescriptorAccessor = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if (object.mapEntry !== undefined && object.mapEntry !== null) { + message.mapEntry = object.mapEntry; + } else { + message.mapEntry = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseFieldOptions: object = { + ctype: 0, + packed: false, + jstype: 0, + lazy: false, + deprecated: false, + weak: false, +}; + +export const FieldOptions = { + encode(message: FieldOptions, writer: Writer = Writer.create()): Writer { + if (message.ctype !== 0) { + writer.uint32(8).int32(message.ctype); + } + if (message.packed === true) { + writer.uint32(16).bool(message.packed); + } + if (message.jstype !== 0) { + writer.uint32(48).int32(message.jstype); + } + if (message.lazy === true) { + writer.uint32(40).bool(message.lazy); + } + if (message.deprecated === true) { + writer.uint32(24).bool(message.deprecated); + } + if (message.weak === true) { + writer.uint32(80).bool(message.weak); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FieldOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFieldOptions } as FieldOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.ctype = reader.int32() as any; + break; + case 2: + message.packed = reader.bool(); + break; + case 6: + message.jstype = reader.int32() as any; + break; + case 5: + message.lazy = reader.bool(); + break; + case 3: + message.deprecated = reader.bool(); + break; + case 10: + message.weak = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FieldOptions { + const message = { ...baseFieldOptions } as FieldOptions; + message.uninterpretedOption = []; + if (object.ctype !== undefined && object.ctype !== null) { + message.ctype = fieldOptions_CTypeFromJSON(object.ctype); + } else { + message.ctype = 0; + } + if (object.packed !== undefined && object.packed !== null) { + message.packed = Boolean(object.packed); + } else { + message.packed = false; + } + if (object.jstype !== undefined && object.jstype !== null) { + message.jstype = fieldOptions_JSTypeFromJSON(object.jstype); + } else { + message.jstype = 0; + } + if (object.lazy !== undefined && object.lazy !== null) { + message.lazy = Boolean(object.lazy); + } else { + message.lazy = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if (object.weak !== undefined && object.weak !== null) { + message.weak = Boolean(object.weak); + } else { + message.weak = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: FieldOptions): unknown { + const obj: any = {}; + message.ctype !== undefined && + (obj.ctype = fieldOptions_CTypeToJSON(message.ctype)); + message.packed !== undefined && (obj.packed = message.packed); + message.jstype !== undefined && + (obj.jstype = fieldOptions_JSTypeToJSON(message.jstype)); + message.lazy !== undefined && (obj.lazy = message.lazy); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.weak !== undefined && (obj.weak = message.weak); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): FieldOptions { + const message = { ...baseFieldOptions } as FieldOptions; + message.uninterpretedOption = []; + if (object.ctype !== undefined && object.ctype !== null) { + message.ctype = object.ctype; + } else { + message.ctype = 0; + } + if (object.packed !== undefined && object.packed !== null) { + message.packed = object.packed; + } else { + message.packed = false; + } + if (object.jstype !== undefined && object.jstype !== null) { + message.jstype = object.jstype; + } else { + message.jstype = 0; + } + if (object.lazy !== undefined && object.lazy !== null) { + message.lazy = object.lazy; + } else { + message.lazy = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if (object.weak !== undefined && object.weak !== null) { + message.weak = object.weak; + } else { + message.weak = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseOneofOptions: object = {}; + +export const OneofOptions = { + encode(message: OneofOptions, writer: Writer = Writer.create()): Writer { + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): OneofOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseOneofOptions } as OneofOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): OneofOptions { + const message = { ...baseOneofOptions } as OneofOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: OneofOptions): unknown { + const obj: any = {}; + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): OneofOptions { + const message = { ...baseOneofOptions } as OneofOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseEnumOptions: object = { allowAlias: false, deprecated: false }; + +export const EnumOptions = { + encode(message: EnumOptions, writer: Writer = Writer.create()): Writer { + if (message.allowAlias === true) { + writer.uint32(16).bool(message.allowAlias); + } + if (message.deprecated === true) { + writer.uint32(24).bool(message.deprecated); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): EnumOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseEnumOptions } as EnumOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + message.allowAlias = reader.bool(); + break; + case 3: + message.deprecated = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumOptions { + const message = { ...baseEnumOptions } as EnumOptions; + message.uninterpretedOption = []; + if (object.allowAlias !== undefined && object.allowAlias !== null) { + message.allowAlias = Boolean(object.allowAlias); + } else { + message.allowAlias = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: EnumOptions): unknown { + const obj: any = {}; + message.allowAlias !== undefined && (obj.allowAlias = message.allowAlias); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): EnumOptions { + const message = { ...baseEnumOptions } as EnumOptions; + message.uninterpretedOption = []; + if (object.allowAlias !== undefined && object.allowAlias !== null) { + message.allowAlias = object.allowAlias; + } else { + message.allowAlias = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseEnumValueOptions: object = { deprecated: false }; + +export const EnumValueOptions = { + encode(message: EnumValueOptions, writer: Writer = Writer.create()): Writer { + if (message.deprecated === true) { + writer.uint32(8).bool(message.deprecated); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): EnumValueOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseEnumValueOptions } as EnumValueOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.deprecated = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumValueOptions { + const message = { ...baseEnumValueOptions } as EnumValueOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: EnumValueOptions): unknown { + const obj: any = {}; + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): EnumValueOptions { + const message = { ...baseEnumValueOptions } as EnumValueOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseServiceOptions: object = { deprecated: false }; + +export const ServiceOptions = { + encode(message: ServiceOptions, writer: Writer = Writer.create()): Writer { + if (message.deprecated === true) { + writer.uint32(264).bool(message.deprecated); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ServiceOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseServiceOptions } as ServiceOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 33: + message.deprecated = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ServiceOptions { + const message = { ...baseServiceOptions } as ServiceOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: ServiceOptions): unknown { + const obj: any = {}; + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): ServiceOptions { + const message = { ...baseServiceOptions } as ServiceOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseMethodOptions: object = { deprecated: false, idempotencyLevel: 0 }; + +export const MethodOptions = { + encode(message: MethodOptions, writer: Writer = Writer.create()): Writer { + if (message.deprecated === true) { + writer.uint32(264).bool(message.deprecated); + } + if (message.idempotencyLevel !== 0) { + writer.uint32(272).int32(message.idempotencyLevel); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MethodOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMethodOptions } as MethodOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 33: + message.deprecated = reader.bool(); + break; + case 34: + message.idempotencyLevel = reader.int32() as any; + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MethodOptions { + const message = { ...baseMethodOptions } as MethodOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.idempotencyLevel !== undefined && + object.idempotencyLevel !== null + ) { + message.idempotencyLevel = methodOptions_IdempotencyLevelFromJSON( + object.idempotencyLevel + ); + } else { + message.idempotencyLevel = 0; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: MethodOptions): unknown { + const obj: any = {}; + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.idempotencyLevel !== undefined && + (obj.idempotencyLevel = methodOptions_IdempotencyLevelToJSON( + message.idempotencyLevel + )); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): MethodOptions { + const message = { ...baseMethodOptions } as MethodOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.idempotencyLevel !== undefined && + object.idempotencyLevel !== null + ) { + message.idempotencyLevel = object.idempotencyLevel; + } else { + message.idempotencyLevel = 0; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseUninterpretedOption: object = { + identifierValue: "", + positiveIntValue: 0, + negativeIntValue: 0, + doubleValue: 0, + aggregateValue: "", +}; + +export const UninterpretedOption = { + encode( + message: UninterpretedOption, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.name) { + UninterpretedOption_NamePart.encode( + v!, + writer.uint32(18).fork() + ).ldelim(); + } + if (message.identifierValue !== "") { + writer.uint32(26).string(message.identifierValue); + } + if (message.positiveIntValue !== 0) { + writer.uint32(32).uint64(message.positiveIntValue); + } + if (message.negativeIntValue !== 0) { + writer.uint32(40).int64(message.negativeIntValue); + } + if (message.doubleValue !== 0) { + writer.uint32(49).double(message.doubleValue); + } + if (message.stringValue.length !== 0) { + writer.uint32(58).bytes(message.stringValue); + } + if (message.aggregateValue !== "") { + writer.uint32(66).string(message.aggregateValue); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): UninterpretedOption { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseUninterpretedOption } as UninterpretedOption; + message.name = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + message.name.push( + UninterpretedOption_NamePart.decode(reader, reader.uint32()) + ); + break; + case 3: + message.identifierValue = reader.string(); + break; + case 4: + message.positiveIntValue = longToNumber(reader.uint64() as Long); + break; + case 5: + message.negativeIntValue = longToNumber(reader.int64() as Long); + break; + case 6: + message.doubleValue = reader.double(); + break; + case 7: + message.stringValue = reader.bytes(); + break; + case 8: + message.aggregateValue = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): UninterpretedOption { + const message = { ...baseUninterpretedOption } as UninterpretedOption; + message.name = []; + if (object.name !== undefined && object.name !== null) { + for (const e of object.name) { + message.name.push(UninterpretedOption_NamePart.fromJSON(e)); + } + } + if ( + object.identifierValue !== undefined && + object.identifierValue !== null + ) { + message.identifierValue = String(object.identifierValue); + } else { + message.identifierValue = ""; + } + if ( + object.positiveIntValue !== undefined && + object.positiveIntValue !== null + ) { + message.positiveIntValue = Number(object.positiveIntValue); + } else { + message.positiveIntValue = 0; + } + if ( + object.negativeIntValue !== undefined && + object.negativeIntValue !== null + ) { + message.negativeIntValue = Number(object.negativeIntValue); + } else { + message.negativeIntValue = 0; + } + if (object.doubleValue !== undefined && object.doubleValue !== null) { + message.doubleValue = Number(object.doubleValue); + } else { + message.doubleValue = 0; + } + if (object.stringValue !== undefined && object.stringValue !== null) { + message.stringValue = bytesFromBase64(object.stringValue); + } + if (object.aggregateValue !== undefined && object.aggregateValue !== null) { + message.aggregateValue = String(object.aggregateValue); + } else { + message.aggregateValue = ""; + } + return message; + }, + + toJSON(message: UninterpretedOption): unknown { + const obj: any = {}; + if (message.name) { + obj.name = message.name.map((e) => + e ? UninterpretedOption_NamePart.toJSON(e) : undefined + ); + } else { + obj.name = []; + } + message.identifierValue !== undefined && + (obj.identifierValue = message.identifierValue); + message.positiveIntValue !== undefined && + (obj.positiveIntValue = message.positiveIntValue); + message.negativeIntValue !== undefined && + (obj.negativeIntValue = message.negativeIntValue); + message.doubleValue !== undefined && + (obj.doubleValue = message.doubleValue); + message.stringValue !== undefined && + (obj.stringValue = base64FromBytes( + message.stringValue !== undefined + ? message.stringValue + : new Uint8Array() + )); + message.aggregateValue !== undefined && + (obj.aggregateValue = message.aggregateValue); + return obj; + }, + + fromPartial(object: DeepPartial): UninterpretedOption { + const message = { ...baseUninterpretedOption } as UninterpretedOption; + message.name = []; + if (object.name !== undefined && object.name !== null) { + for (const e of object.name) { + message.name.push(UninterpretedOption_NamePart.fromPartial(e)); + } + } + if ( + object.identifierValue !== undefined && + object.identifierValue !== null + ) { + message.identifierValue = object.identifierValue; + } else { + message.identifierValue = ""; + } + if ( + object.positiveIntValue !== undefined && + object.positiveIntValue !== null + ) { + message.positiveIntValue = object.positiveIntValue; + } else { + message.positiveIntValue = 0; + } + if ( + object.negativeIntValue !== undefined && + object.negativeIntValue !== null + ) { + message.negativeIntValue = object.negativeIntValue; + } else { + message.negativeIntValue = 0; + } + if (object.doubleValue !== undefined && object.doubleValue !== null) { + message.doubleValue = object.doubleValue; + } else { + message.doubleValue = 0; + } + if (object.stringValue !== undefined && object.stringValue !== null) { + message.stringValue = object.stringValue; + } else { + message.stringValue = new Uint8Array(); + } + if (object.aggregateValue !== undefined && object.aggregateValue !== null) { + message.aggregateValue = object.aggregateValue; + } else { + message.aggregateValue = ""; + } + return message; + }, +}; + +const baseUninterpretedOption_NamePart: object = { + namePart: "", + isExtension: false, +}; + +export const UninterpretedOption_NamePart = { + encode( + message: UninterpretedOption_NamePart, + writer: Writer = Writer.create() + ): Writer { + if (message.namePart !== "") { + writer.uint32(10).string(message.namePart); + } + if (message.isExtension === true) { + writer.uint32(16).bool(message.isExtension); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): UninterpretedOption_NamePart { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseUninterpretedOption_NamePart, + } as UninterpretedOption_NamePart; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.namePart = reader.string(); + break; + case 2: + message.isExtension = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): UninterpretedOption_NamePart { + const message = { + ...baseUninterpretedOption_NamePart, + } as UninterpretedOption_NamePart; + if (object.namePart !== undefined && object.namePart !== null) { + message.namePart = String(object.namePart); + } else { + message.namePart = ""; + } + if (object.isExtension !== undefined && object.isExtension !== null) { + message.isExtension = Boolean(object.isExtension); + } else { + message.isExtension = false; + } + return message; + }, + + toJSON(message: UninterpretedOption_NamePart): unknown { + const obj: any = {}; + message.namePart !== undefined && (obj.namePart = message.namePart); + message.isExtension !== undefined && + (obj.isExtension = message.isExtension); + return obj; + }, + + fromPartial( + object: DeepPartial + ): UninterpretedOption_NamePart { + const message = { + ...baseUninterpretedOption_NamePart, + } as UninterpretedOption_NamePart; + if (object.namePart !== undefined && object.namePart !== null) { + message.namePart = object.namePart; + } else { + message.namePart = ""; + } + if (object.isExtension !== undefined && object.isExtension !== null) { + message.isExtension = object.isExtension; + } else { + message.isExtension = false; + } + return message; + }, +}; + +const baseSourceCodeInfo: object = {}; + +export const SourceCodeInfo = { + encode(message: SourceCodeInfo, writer: Writer = Writer.create()): Writer { + for (const v of message.location) { + SourceCodeInfo_Location.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): SourceCodeInfo { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseSourceCodeInfo } as SourceCodeInfo; + message.location = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.location.push( + SourceCodeInfo_Location.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): SourceCodeInfo { + const message = { ...baseSourceCodeInfo } as SourceCodeInfo; + message.location = []; + if (object.location !== undefined && object.location !== null) { + for (const e of object.location) { + message.location.push(SourceCodeInfo_Location.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: SourceCodeInfo): unknown { + const obj: any = {}; + if (message.location) { + obj.location = message.location.map((e) => + e ? SourceCodeInfo_Location.toJSON(e) : undefined + ); + } else { + obj.location = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): SourceCodeInfo { + const message = { ...baseSourceCodeInfo } as SourceCodeInfo; + message.location = []; + if (object.location !== undefined && object.location !== null) { + for (const e of object.location) { + message.location.push(SourceCodeInfo_Location.fromPartial(e)); + } + } + return message; + }, +}; + +const baseSourceCodeInfo_Location: object = { + path: 0, + span: 0, + leadingComments: "", + trailingComments: "", + leadingDetachedComments: "", +}; + +export const SourceCodeInfo_Location = { + encode( + message: SourceCodeInfo_Location, + writer: Writer = Writer.create() + ): Writer { + writer.uint32(10).fork(); + for (const v of message.path) { + writer.int32(v); + } + writer.ldelim(); + writer.uint32(18).fork(); + for (const v of message.span) { + writer.int32(v); + } + writer.ldelim(); + if (message.leadingComments !== "") { + writer.uint32(26).string(message.leadingComments); + } + if (message.trailingComments !== "") { + writer.uint32(34).string(message.trailingComments); + } + for (const v of message.leadingDetachedComments) { + writer.uint32(50).string(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): SourceCodeInfo_Location { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseSourceCodeInfo_Location, + } as SourceCodeInfo_Location; + message.path = []; + message.span = []; + message.leadingDetachedComments = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.path.push(reader.int32()); + } + } else { + message.path.push(reader.int32()); + } + break; + case 2: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.span.push(reader.int32()); + } + } else { + message.span.push(reader.int32()); + } + break; + case 3: + message.leadingComments = reader.string(); + break; + case 4: + message.trailingComments = reader.string(); + break; + case 6: + message.leadingDetachedComments.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): SourceCodeInfo_Location { + const message = { + ...baseSourceCodeInfo_Location, + } as SourceCodeInfo_Location; + message.path = []; + message.span = []; + message.leadingDetachedComments = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(Number(e)); + } + } + if (object.span !== undefined && object.span !== null) { + for (const e of object.span) { + message.span.push(Number(e)); + } + } + if ( + object.leadingComments !== undefined && + object.leadingComments !== null + ) { + message.leadingComments = String(object.leadingComments); + } else { + message.leadingComments = ""; + } + if ( + object.trailingComments !== undefined && + object.trailingComments !== null + ) { + message.trailingComments = String(object.trailingComments); + } else { + message.trailingComments = ""; + } + if ( + object.leadingDetachedComments !== undefined && + object.leadingDetachedComments !== null + ) { + for (const e of object.leadingDetachedComments) { + message.leadingDetachedComments.push(String(e)); + } + } + return message; + }, + + toJSON(message: SourceCodeInfo_Location): unknown { + const obj: any = {}; + if (message.path) { + obj.path = message.path.map((e) => e); + } else { + obj.path = []; + } + if (message.span) { + obj.span = message.span.map((e) => e); + } else { + obj.span = []; + } + message.leadingComments !== undefined && + (obj.leadingComments = message.leadingComments); + message.trailingComments !== undefined && + (obj.trailingComments = message.trailingComments); + if (message.leadingDetachedComments) { + obj.leadingDetachedComments = message.leadingDetachedComments.map( + (e) => e + ); + } else { + obj.leadingDetachedComments = []; + } + return obj; + }, + + fromPartial( + object: DeepPartial + ): SourceCodeInfo_Location { + const message = { + ...baseSourceCodeInfo_Location, + } as SourceCodeInfo_Location; + message.path = []; + message.span = []; + message.leadingDetachedComments = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(e); + } + } + if (object.span !== undefined && object.span !== null) { + for (const e of object.span) { + message.span.push(e); + } + } + if ( + object.leadingComments !== undefined && + object.leadingComments !== null + ) { + message.leadingComments = object.leadingComments; + } else { + message.leadingComments = ""; + } + if ( + object.trailingComments !== undefined && + object.trailingComments !== null + ) { + message.trailingComments = object.trailingComments; + } else { + message.trailingComments = ""; + } + if ( + object.leadingDetachedComments !== undefined && + object.leadingDetachedComments !== null + ) { + for (const e of object.leadingDetachedComments) { + message.leadingDetachedComments.push(e); + } + } + return message; + }, +}; + +const baseGeneratedCodeInfo: object = {}; + +export const GeneratedCodeInfo = { + encode(message: GeneratedCodeInfo, writer: Writer = Writer.create()): Writer { + for (const v of message.annotation) { + GeneratedCodeInfo_Annotation.encode( + v!, + writer.uint32(10).fork() + ).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): GeneratedCodeInfo { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseGeneratedCodeInfo } as GeneratedCodeInfo; + message.annotation = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.annotation.push( + GeneratedCodeInfo_Annotation.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GeneratedCodeInfo { + const message = { ...baseGeneratedCodeInfo } as GeneratedCodeInfo; + message.annotation = []; + if (object.annotation !== undefined && object.annotation !== null) { + for (const e of object.annotation) { + message.annotation.push(GeneratedCodeInfo_Annotation.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: GeneratedCodeInfo): unknown { + const obj: any = {}; + if (message.annotation) { + obj.annotation = message.annotation.map((e) => + e ? GeneratedCodeInfo_Annotation.toJSON(e) : undefined + ); + } else { + obj.annotation = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): GeneratedCodeInfo { + const message = { ...baseGeneratedCodeInfo } as GeneratedCodeInfo; + message.annotation = []; + if (object.annotation !== undefined && object.annotation !== null) { + for (const e of object.annotation) { + message.annotation.push(GeneratedCodeInfo_Annotation.fromPartial(e)); + } + } + return message; + }, +}; + +const baseGeneratedCodeInfo_Annotation: object = { + path: 0, + sourceFile: "", + begin: 0, + end: 0, +}; + +export const GeneratedCodeInfo_Annotation = { + encode( + message: GeneratedCodeInfo_Annotation, + writer: Writer = Writer.create() + ): Writer { + writer.uint32(10).fork(); + for (const v of message.path) { + writer.int32(v); + } + writer.ldelim(); + if (message.sourceFile !== "") { + writer.uint32(18).string(message.sourceFile); + } + if (message.begin !== 0) { + writer.uint32(24).int32(message.begin); + } + if (message.end !== 0) { + writer.uint32(32).int32(message.end); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): GeneratedCodeInfo_Annotation { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseGeneratedCodeInfo_Annotation, + } as GeneratedCodeInfo_Annotation; + message.path = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.path.push(reader.int32()); + } + } else { + message.path.push(reader.int32()); + } + break; + case 2: + message.sourceFile = reader.string(); + break; + case 3: + message.begin = reader.int32(); + break; + case 4: + message.end = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GeneratedCodeInfo_Annotation { + const message = { + ...baseGeneratedCodeInfo_Annotation, + } as GeneratedCodeInfo_Annotation; + message.path = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(Number(e)); + } + } + if (object.sourceFile !== undefined && object.sourceFile !== null) { + message.sourceFile = String(object.sourceFile); + } else { + message.sourceFile = ""; + } + if (object.begin !== undefined && object.begin !== null) { + message.begin = Number(object.begin); + } else { + message.begin = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + return message; + }, + + toJSON(message: GeneratedCodeInfo_Annotation): unknown { + const obj: any = {}; + if (message.path) { + obj.path = message.path.map((e) => e); + } else { + obj.path = []; + } + message.sourceFile !== undefined && (obj.sourceFile = message.sourceFile); + message.begin !== undefined && (obj.begin = message.begin); + message.end !== undefined && (obj.end = message.end); + return obj; + }, + + fromPartial( + object: DeepPartial + ): GeneratedCodeInfo_Annotation { + const message = { + ...baseGeneratedCodeInfo_Annotation, + } as GeneratedCodeInfo_Annotation; + message.path = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(e); + } + } + if (object.sourceFile !== undefined && object.sourceFile !== null) { + message.sourceFile = object.sourceFile; + } else { + message.sourceFile = ""; + } + if (object.begin !== undefined && object.begin !== null) { + message.begin = object.begin; + } else { + message.begin = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/cosmos.slashing.v1beta1/index.ts b/ts-client/cosmos.slashing.v1beta1/index.ts new file mode 100755 index 00000000..c9dfa159 --- /dev/null +++ b/ts-client/cosmos.slashing.v1beta1/index.ts @@ -0,0 +1,6 @@ +import Module from './module'; +import { txClient, queryClient, registry } from './module'; +import { msgTypes } from './registry'; + +export * from "./types"; +export { Module, msgTypes, txClient, queryClient, registry }; diff --git a/ts-client/cosmos.slashing.v1beta1/module.ts b/ts-client/cosmos.slashing.v1beta1/module.ts new file mode 100755 index 00000000..98db9055 --- /dev/null +++ b/ts-client/cosmos.slashing.v1beta1/module.ts @@ -0,0 +1,99 @@ +// Generated by Ignite ignite.com/cli + +import { StdFee } from "@cosmjs/launchpad"; +import { SigningStargateClient, DeliverTxResponse } from "@cosmjs/stargate"; +import { EncodeObject, GeneratedType, OfflineSigner, Registry } from "@cosmjs/proto-signing"; +import { msgTypes } from './registry'; +import { IgniteClient } from "../client" +import { MissingWalletError } from "../helpers" +import { Api } from "./rest"; +import { MsgUnjail } from "./types/cosmos/slashing/v1beta1/tx"; + + +export { MsgUnjail }; + +type sendMsgUnjailParams = { + value: MsgUnjail, + fee?: StdFee, + memo?: string +}; + + +type msgUnjailParams = { + value: MsgUnjail, +}; + + +export const registry = new Registry(msgTypes); + +const defaultFee = { + amount: [], + gas: "200000", +}; + +interface TxClientOptions { + addr: string + prefix: string + signer?: OfflineSigner +} + +export const txClient = ({ signer, prefix, addr }: TxClientOptions = { addr: "http://localhost:26657", prefix: "cosmos" }) => { + + return { + + async sendMsgUnjail({ value, fee, memo }: sendMsgUnjailParams): Promise { + if (!signer) { + throw new Error('TxClient:sendMsgUnjail: Unable to sign Tx. Signer is not present.') + } + try { + const { address } = (await signer.getAccounts())[0]; + const signingClient = await SigningStargateClient.connectWithSigner(addr,signer,{registry, prefix}); + let msg = this.msgUnjail({ value: MsgUnjail.fromPartial(value) }) + return await signingClient.signAndBroadcast(address, [msg], fee ? fee : defaultFee, memo) + } catch (e: any) { + throw new Error('TxClient:sendMsgUnjail: Could not broadcast Tx: '+ e.message) + } + }, + + + msgUnjail({ value }: msgUnjailParams): EncodeObject { + try { + return { typeUrl: "/cosmos.slashing.v1beta1.MsgUnjail", value: MsgUnjail.fromPartial( value ) } + } catch (e: any) { + throw new Error('TxClient:MsgUnjail: Could not create message: ' + e.message) + } + }, + + } +}; + +interface QueryClientOptions { + addr: string +} + +export const queryClient = ({ addr: addr }: QueryClientOptions = { addr: "http://localhost:1317" }) => { + return new Api({ baseUrl: addr }); +}; + +class SDKModule { + public query: ReturnType; + public tx: ReturnType; + + public registry: Array<[string, GeneratedType]>; + + constructor(client: IgniteClient) { + + this.query = queryClient({ addr: client.env.apiURL }); + this.tx = txClient({ signer: client.signer, addr: client.env.rpcURL, prefix: client.env.prefix ?? "cosmos" }); + } +}; + +const Module = (test: IgniteClient) => { + return { + module: { + CosmosSlashingV1Beta1: new SDKModule(test) + }, + registry: msgTypes + } +} +export default Module; \ No newline at end of file diff --git a/ts-client/cosmos.slashing.v1beta1/registry.ts b/ts-client/cosmos.slashing.v1beta1/registry.ts new file mode 100755 index 00000000..3dd69069 --- /dev/null +++ b/ts-client/cosmos.slashing.v1beta1/registry.ts @@ -0,0 +1,9 @@ +import { GeneratedType } from "@cosmjs/proto-signing"; +import { MsgUnjail } from "./types/cosmos/slashing/v1beta1/tx"; + +const msgTypes: Array<[string, GeneratedType]> = [ + ["/cosmos.slashing.v1beta1.MsgUnjail", MsgUnjail], + +]; + +export { msgTypes } \ No newline at end of file diff --git a/ts-client/cosmos.slashing.v1beta1/rest.ts b/ts-client/cosmos.slashing.v1beta1/rest.ts new file mode 100644 index 00000000..61d6b6cb --- /dev/null +++ b/ts-client/cosmos.slashing.v1beta1/rest.ts @@ -0,0 +1,425 @@ +/* eslint-disable */ +/* tslint:disable */ +/* + * --------------------------------------------------------------- + * ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ## + * ## ## + * ## AUTHOR: acacode ## + * ## SOURCE: https://github.com/acacode/swagger-typescript-api ## + * --------------------------------------------------------------- + */ + +export interface ProtobufAny { + "@type"?: string; +} + +export interface RpcStatus { + /** @format int32 */ + code?: number; + message?: string; + details?: ProtobufAny[]; +} + +/** + * Params represents the parameters used for by the slashing module. + */ +export interface Slashingv1Beta1Params { + /** @format int64 */ + signed_blocks_window?: string; + + /** @format byte */ + min_signed_per_window?: string; + downtime_jail_duration?: string; + + /** @format byte */ + slash_fraction_double_sign?: string; + + /** @format byte */ + slash_fraction_downtime?: string; +} + +export type V1Beta1MsgUnjailResponse = object; + +/** +* message SomeRequest { + Foo some_parameter = 1; + PageRequest pagination = 2; + } +*/ +export interface V1Beta1PageRequest { + /** + * key is a value returned in PageResponse.next_key to begin + * querying the next page most efficiently. Only one of offset or key + * should be set. + * @format byte + */ + key?: string; + + /** + * offset is a numeric offset that can be used when key is unavailable. + * It is less efficient than using key. Only one of offset or key should + * be set. + * @format uint64 + */ + offset?: string; + + /** + * limit is the total number of results to be returned in the result page. + * If left empty it will default to a value to be set by each app. + * @format uint64 + */ + limit?: string; + + /** + * count_total is set to true to indicate that the result set should include + * a count of the total number of items available for pagination in UIs. + * count_total is only respected when offset is used. It is ignored when key + * is set. + */ + count_total?: boolean; + + /** + * reverse is set to true if results are to be returned in the descending order. + * + * Since: cosmos-sdk 0.43 + */ + reverse?: boolean; +} + +/** +* PageResponse is to be embedded in gRPC response messages where the +corresponding request message has used PageRequest. + + message SomeResponse { + repeated Bar results = 1; + PageResponse page = 2; + } +*/ +export interface V1Beta1PageResponse { + /** @format byte */ + next_key?: string; + + /** @format uint64 */ + total?: string; +} + +export interface V1Beta1QueryParamsResponse { + /** Params represents the parameters used for by the slashing module. */ + params?: Slashingv1Beta1Params; +} + +export interface V1Beta1QuerySigningInfoResponse { + /** + * ValidatorSigningInfo defines a validator's signing info for monitoring their + * liveness activity. + */ + val_signing_info?: V1Beta1ValidatorSigningInfo; +} + +export interface V1Beta1QuerySigningInfosResponse { + info?: V1Beta1ValidatorSigningInfo[]; + + /** + * PageResponse is to be embedded in gRPC response messages where the + * corresponding request message has used PageRequest. + * + * message SomeResponse { + * repeated Bar results = 1; + * PageResponse page = 2; + * } + */ + pagination?: V1Beta1PageResponse; +} + +/** +* ValidatorSigningInfo defines a validator's signing info for monitoring their +liveness activity. +*/ +export interface V1Beta1ValidatorSigningInfo { + address?: string; + + /** @format int64 */ + start_height?: string; + + /** + * Index which is incremented each time the validator was a bonded + * in a block and may have signed a precommit or not. This in conjunction with the + * `SignedBlocksWindow` param determines the index in the `MissedBlocksBitArray`. + * @format int64 + */ + index_offset?: string; + + /** + * Timestamp until which the validator is jailed due to liveness downtime. + * @format date-time + */ + jailed_until?: string; + + /** + * Whether or not a validator has been tombstoned (killed out of validator set). It is set + * once the validator commits an equivocation or for any other configured misbehiavor. + */ + tombstoned?: boolean; + + /** + * A counter kept to avoid unnecessary array reads. + * Note that `Sum(MissedBlocksBitArray)` always equals `MissedBlocksCounter`. + * @format int64 + */ + missed_blocks_counter?: string; +} + +export type QueryParamsType = Record; +export type ResponseFormat = keyof Omit; + +export interface FullRequestParams extends Omit { + /** set parameter to `true` for call `securityWorker` for this request */ + secure?: boolean; + /** request path */ + path: string; + /** content type of request body */ + type?: ContentType; + /** query params */ + query?: QueryParamsType; + /** format of response (i.e. response.json() -> format: "json") */ + format?: keyof Omit; + /** request body */ + body?: unknown; + /** base url */ + baseUrl?: string; + /** request cancellation token */ + cancelToken?: CancelToken; +} + +export type RequestParams = Omit; + +export interface ApiConfig { + baseUrl?: string; + baseApiParams?: Omit; + securityWorker?: (securityData: SecurityDataType) => RequestParams | void; +} + +export interface HttpResponse extends Response { + data: D; + error: E; +} + +type CancelToken = Symbol | string | number; + +export enum ContentType { + Json = "application/json", + FormData = "multipart/form-data", + UrlEncoded = "application/x-www-form-urlencoded", +} + +export class HttpClient { + public baseUrl: string = ""; + private securityData: SecurityDataType = null as any; + private securityWorker: null | ApiConfig["securityWorker"] = null; + private abortControllers = new Map(); + + private baseApiParams: RequestParams = { + credentials: "same-origin", + headers: {}, + redirect: "follow", + referrerPolicy: "no-referrer", + }; + + constructor(apiConfig: ApiConfig = {}) { + Object.assign(this, apiConfig); + } + + public setSecurityData = (data: SecurityDataType) => { + this.securityData = data; + }; + + private addQueryParam(query: QueryParamsType, key: string) { + const value = query[key]; + + return ( + encodeURIComponent(key) + + "=" + + encodeURIComponent(Array.isArray(value) ? value.join(",") : typeof value === "number" ? value : `${value}`) + ); + } + + protected toQueryString(rawQuery?: QueryParamsType): string { + const query = rawQuery || {}; + const keys = Object.keys(query).filter((key) => "undefined" !== typeof query[key]); + return keys + .map((key) => + typeof query[key] === "object" && !Array.isArray(query[key]) + ? this.toQueryString(query[key] as QueryParamsType) + : this.addQueryParam(query, key), + ) + .join("&"); + } + + protected addQueryParams(rawQuery?: QueryParamsType): string { + const queryString = this.toQueryString(rawQuery); + return queryString ? `?${queryString}` : ""; + } + + private contentFormatters: Record any> = { + [ContentType.Json]: (input: any) => + input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input, + [ContentType.FormData]: (input: any) => + Object.keys(input || {}).reduce((data, key) => { + data.append(key, input[key]); + return data; + }, new FormData()), + [ContentType.UrlEncoded]: (input: any) => this.toQueryString(input), + }; + + private mergeRequestParams(params1: RequestParams, params2?: RequestParams): RequestParams { + return { + ...this.baseApiParams, + ...params1, + ...(params2 || {}), + headers: { + ...(this.baseApiParams.headers || {}), + ...(params1.headers || {}), + ...((params2 && params2.headers) || {}), + }, + }; + } + + private createAbortSignal = (cancelToken: CancelToken): AbortSignal | undefined => { + if (this.abortControllers.has(cancelToken)) { + const abortController = this.abortControllers.get(cancelToken); + if (abortController) { + return abortController.signal; + } + return void 0; + } + + const abortController = new AbortController(); + this.abortControllers.set(cancelToken, abortController); + return abortController.signal; + }; + + public abortRequest = (cancelToken: CancelToken) => { + const abortController = this.abortControllers.get(cancelToken); + + if (abortController) { + abortController.abort(); + this.abortControllers.delete(cancelToken); + } + }; + + public request = ({ + body, + secure, + path, + type, + query, + format = "json", + baseUrl, + cancelToken, + ...params + }: FullRequestParams): Promise> => { + const secureParams = (secure && this.securityWorker && this.securityWorker(this.securityData)) || {}; + const requestParams = this.mergeRequestParams(params, secureParams); + const queryString = query && this.toQueryString(query); + const payloadFormatter = this.contentFormatters[type || ContentType.Json]; + + return fetch(`${baseUrl || this.baseUrl || ""}${path}${queryString ? `?${queryString}` : ""}`, { + ...requestParams, + headers: { + ...(type && type !== ContentType.FormData ? { "Content-Type": type } : {}), + ...(requestParams.headers || {}), + }, + signal: cancelToken ? this.createAbortSignal(cancelToken) : void 0, + body: typeof body === "undefined" || body === null ? null : payloadFormatter(body), + }).then(async (response) => { + const r = response as HttpResponse; + r.data = (null as unknown) as T; + r.error = (null as unknown) as E; + + const data = await response[format]() + .then((data) => { + if (r.ok) { + r.data = data; + } else { + r.error = data; + } + return r; + }) + .catch((e) => { + r.error = e; + return r; + }); + + if (cancelToken) { + this.abortControllers.delete(cancelToken); + } + + if (!response.ok) throw data; + return data; + }); + }; +} + +/** + * @title cosmos/slashing/v1beta1/genesis.proto + * @version version not set + */ +export class Api extends HttpClient { + /** + * No description + * + * @tags Query + * @name QueryParams + * @summary Params queries the parameters of slashing module + * @request GET:/cosmos/slashing/v1beta1/params + */ + queryParams = (params: RequestParams = {}) => + this.request({ + path: `/cosmos/slashing/v1beta1/params`, + method: "GET", + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Query + * @name QuerySigningInfos + * @summary SigningInfos queries signing info of all validators + * @request GET:/cosmos/slashing/v1beta1/signing_infos + */ + querySigningInfos = ( + query?: { + "pagination.key"?: string; + "pagination.offset"?: string; + "pagination.limit"?: string; + "pagination.count_total"?: boolean; + "pagination.reverse"?: boolean; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/cosmos/slashing/v1beta1/signing_infos`, + method: "GET", + query: query, + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Query + * @name QuerySigningInfo + * @summary SigningInfo queries the signing info of given cons address + * @request GET:/cosmos/slashing/v1beta1/signing_infos/{cons_address} + */ + querySigningInfo = (cons_address: string, params: RequestParams = {}) => + this.request({ + path: `/cosmos/slashing/v1beta1/signing_infos/${cons_address}`, + method: "GET", + format: "json", + ...params, + }); +} diff --git a/ts-client/cosmos.slashing.v1beta1/types.ts b/ts-client/cosmos.slashing.v1beta1/types.ts new file mode 100755 index 00000000..6102fb8a --- /dev/null +++ b/ts-client/cosmos.slashing.v1beta1/types.ts @@ -0,0 +1,15 @@ +import { SigningInfo } from "./types/cosmos/slashing/v1beta1/genesis" +import { ValidatorMissedBlocks } from "./types/cosmos/slashing/v1beta1/genesis" +import { MissedBlock } from "./types/cosmos/slashing/v1beta1/genesis" +import { ValidatorSigningInfo } from "./types/cosmos/slashing/v1beta1/slashing" +import { Params } from "./types/cosmos/slashing/v1beta1/slashing" + + +export { + SigningInfo, + ValidatorMissedBlocks, + MissedBlock, + ValidatorSigningInfo, + Params, + + } \ No newline at end of file diff --git a/ts-client/cosmos.slashing.v1beta1/types/cosmos/base/query/v1beta1/pagination.ts b/ts-client/cosmos.slashing.v1beta1/types/cosmos/base/query/v1beta1/pagination.ts new file mode 100644 index 00000000..cd4b2d78 --- /dev/null +++ b/ts-client/cosmos.slashing.v1beta1/types/cosmos/base/query/v1beta1/pagination.ts @@ -0,0 +1,327 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "cosmos.base.query.v1beta1"; + +/** + * PageRequest is to be embedded in gRPC request messages for efficient + * pagination. Ex: + * + * message SomeRequest { + * Foo some_parameter = 1; + * PageRequest pagination = 2; + * } + */ +export interface PageRequest { + /** + * key is a value returned in PageResponse.next_key to begin + * querying the next page most efficiently. Only one of offset or key + * should be set. + */ + key: Uint8Array; + /** + * offset is a numeric offset that can be used when key is unavailable. + * It is less efficient than using key. Only one of offset or key should + * be set. + */ + offset: number; + /** + * limit is the total number of results to be returned in the result page. + * If left empty it will default to a value to be set by each app. + */ + limit: number; + /** + * count_total is set to true to indicate that the result set should include + * a count of the total number of items available for pagination in UIs. + * count_total is only respected when offset is used. It is ignored when key + * is set. + */ + countTotal: boolean; + /** + * reverse is set to true if results are to be returned in the descending order. + * + * Since: cosmos-sdk 0.43 + */ + reverse: boolean; +} + +/** + * PageResponse is to be embedded in gRPC response messages where the + * corresponding request message has used PageRequest. + * + * message SomeResponse { + * repeated Bar results = 1; + * PageResponse page = 2; + * } + */ +export interface PageResponse { + /** + * next_key is the key to be passed to PageRequest.key to + * query the next page most efficiently + */ + nextKey: Uint8Array; + /** + * total is total number of results available if PageRequest.count_total + * was set, its value is undefined otherwise + */ + total: number; +} + +const basePageRequest: object = { + offset: 0, + limit: 0, + countTotal: false, + reverse: false, +}; + +export const PageRequest = { + encode(message: PageRequest, writer: Writer = Writer.create()): Writer { + if (message.key.length !== 0) { + writer.uint32(10).bytes(message.key); + } + if (message.offset !== 0) { + writer.uint32(16).uint64(message.offset); + } + if (message.limit !== 0) { + writer.uint32(24).uint64(message.limit); + } + if (message.countTotal === true) { + writer.uint32(32).bool(message.countTotal); + } + if (message.reverse === true) { + writer.uint32(40).bool(message.reverse); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): PageRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...basePageRequest } as PageRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.key = reader.bytes(); + break; + case 2: + message.offset = longToNumber(reader.uint64() as Long); + break; + case 3: + message.limit = longToNumber(reader.uint64() as Long); + break; + case 4: + message.countTotal = reader.bool(); + break; + case 5: + message.reverse = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): PageRequest { + const message = { ...basePageRequest } as PageRequest; + if (object.key !== undefined && object.key !== null) { + message.key = bytesFromBase64(object.key); + } + if (object.offset !== undefined && object.offset !== null) { + message.offset = Number(object.offset); + } else { + message.offset = 0; + } + if (object.limit !== undefined && object.limit !== null) { + message.limit = Number(object.limit); + } else { + message.limit = 0; + } + if (object.countTotal !== undefined && object.countTotal !== null) { + message.countTotal = Boolean(object.countTotal); + } else { + message.countTotal = false; + } + if (object.reverse !== undefined && object.reverse !== null) { + message.reverse = Boolean(object.reverse); + } else { + message.reverse = false; + } + return message; + }, + + toJSON(message: PageRequest): unknown { + const obj: any = {}; + message.key !== undefined && + (obj.key = base64FromBytes( + message.key !== undefined ? message.key : new Uint8Array() + )); + message.offset !== undefined && (obj.offset = message.offset); + message.limit !== undefined && (obj.limit = message.limit); + message.countTotal !== undefined && (obj.countTotal = message.countTotal); + message.reverse !== undefined && (obj.reverse = message.reverse); + return obj; + }, + + fromPartial(object: DeepPartial): PageRequest { + const message = { ...basePageRequest } as PageRequest; + if (object.key !== undefined && object.key !== null) { + message.key = object.key; + } else { + message.key = new Uint8Array(); + } + if (object.offset !== undefined && object.offset !== null) { + message.offset = object.offset; + } else { + message.offset = 0; + } + if (object.limit !== undefined && object.limit !== null) { + message.limit = object.limit; + } else { + message.limit = 0; + } + if (object.countTotal !== undefined && object.countTotal !== null) { + message.countTotal = object.countTotal; + } else { + message.countTotal = false; + } + if (object.reverse !== undefined && object.reverse !== null) { + message.reverse = object.reverse; + } else { + message.reverse = false; + } + return message; + }, +}; + +const basePageResponse: object = { total: 0 }; + +export const PageResponse = { + encode(message: PageResponse, writer: Writer = Writer.create()): Writer { + if (message.nextKey.length !== 0) { + writer.uint32(10).bytes(message.nextKey); + } + if (message.total !== 0) { + writer.uint32(16).uint64(message.total); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): PageResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...basePageResponse } as PageResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.nextKey = reader.bytes(); + break; + case 2: + message.total = longToNumber(reader.uint64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): PageResponse { + const message = { ...basePageResponse } as PageResponse; + if (object.nextKey !== undefined && object.nextKey !== null) { + message.nextKey = bytesFromBase64(object.nextKey); + } + if (object.total !== undefined && object.total !== null) { + message.total = Number(object.total); + } else { + message.total = 0; + } + return message; + }, + + toJSON(message: PageResponse): unknown { + const obj: any = {}; + message.nextKey !== undefined && + (obj.nextKey = base64FromBytes( + message.nextKey !== undefined ? message.nextKey : new Uint8Array() + )); + message.total !== undefined && (obj.total = message.total); + return obj; + }, + + fromPartial(object: DeepPartial): PageResponse { + const message = { ...basePageResponse } as PageResponse; + if (object.nextKey !== undefined && object.nextKey !== null) { + message.nextKey = object.nextKey; + } else { + message.nextKey = new Uint8Array(); + } + if (object.total !== undefined && object.total !== null) { + message.total = object.total; + } else { + message.total = 0; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/cosmos.slashing.v1beta1/types/cosmos/slashing/v1beta1/genesis.ts b/ts-client/cosmos.slashing.v1beta1/types/cosmos/slashing/v1beta1/genesis.ts new file mode 100644 index 00000000..c4f331b7 --- /dev/null +++ b/ts-client/cosmos.slashing.v1beta1/types/cosmos/slashing/v1beta1/genesis.ts @@ -0,0 +1,448 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; +import { + Params, + ValidatorSigningInfo, +} from "../../../cosmos/slashing/v1beta1/slashing"; + +export const protobufPackage = "cosmos.slashing.v1beta1"; + +/** GenesisState defines the slashing module's genesis state. */ +export interface GenesisState { + /** params defines all the paramaters of related to deposit. */ + params: Params | undefined; + /** + * signing_infos represents a map between validator addresses and their + * signing infos. + */ + signingInfos: SigningInfo[]; + /** + * missed_blocks represents a map between validator addresses and their + * missed blocks. + */ + missedBlocks: ValidatorMissedBlocks[]; +} + +/** SigningInfo stores validator signing info of corresponding address. */ +export interface SigningInfo { + /** address is the validator address. */ + address: string; + /** validator_signing_info represents the signing info of this validator. */ + validatorSigningInfo: ValidatorSigningInfo | undefined; +} + +/** + * ValidatorMissedBlocks contains array of missed blocks of corresponding + * address. + */ +export interface ValidatorMissedBlocks { + /** address is the validator address. */ + address: string; + /** missed_blocks is an array of missed blocks by the validator. */ + missedBlocks: MissedBlock[]; +} + +/** MissedBlock contains height and missed status as boolean. */ +export interface MissedBlock { + /** index is the height at which the block was missed. */ + index: number; + /** missed is the missed status. */ + missed: boolean; +} + +const baseGenesisState: object = {}; + +export const GenesisState = { + encode(message: GenesisState, writer: Writer = Writer.create()): Writer { + if (message.params !== undefined) { + Params.encode(message.params, writer.uint32(10).fork()).ldelim(); + } + for (const v of message.signingInfos) { + SigningInfo.encode(v!, writer.uint32(18).fork()).ldelim(); + } + for (const v of message.missedBlocks) { + ValidatorMissedBlocks.encode(v!, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): GenesisState { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseGenesisState } as GenesisState; + message.signingInfos = []; + message.missedBlocks = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.params = Params.decode(reader, reader.uint32()); + break; + case 2: + message.signingInfos.push( + SigningInfo.decode(reader, reader.uint32()) + ); + break; + case 3: + message.missedBlocks.push( + ValidatorMissedBlocks.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GenesisState { + const message = { ...baseGenesisState } as GenesisState; + message.signingInfos = []; + message.missedBlocks = []; + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromJSON(object.params); + } else { + message.params = undefined; + } + if (object.signingInfos !== undefined && object.signingInfos !== null) { + for (const e of object.signingInfos) { + message.signingInfos.push(SigningInfo.fromJSON(e)); + } + } + if (object.missedBlocks !== undefined && object.missedBlocks !== null) { + for (const e of object.missedBlocks) { + message.missedBlocks.push(ValidatorMissedBlocks.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: GenesisState): unknown { + const obj: any = {}; + message.params !== undefined && + (obj.params = message.params ? Params.toJSON(message.params) : undefined); + if (message.signingInfos) { + obj.signingInfos = message.signingInfos.map((e) => + e ? SigningInfo.toJSON(e) : undefined + ); + } else { + obj.signingInfos = []; + } + if (message.missedBlocks) { + obj.missedBlocks = message.missedBlocks.map((e) => + e ? ValidatorMissedBlocks.toJSON(e) : undefined + ); + } else { + obj.missedBlocks = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): GenesisState { + const message = { ...baseGenesisState } as GenesisState; + message.signingInfos = []; + message.missedBlocks = []; + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromPartial(object.params); + } else { + message.params = undefined; + } + if (object.signingInfos !== undefined && object.signingInfos !== null) { + for (const e of object.signingInfos) { + message.signingInfos.push(SigningInfo.fromPartial(e)); + } + } + if (object.missedBlocks !== undefined && object.missedBlocks !== null) { + for (const e of object.missedBlocks) { + message.missedBlocks.push(ValidatorMissedBlocks.fromPartial(e)); + } + } + return message; + }, +}; + +const baseSigningInfo: object = { address: "" }; + +export const SigningInfo = { + encode(message: SigningInfo, writer: Writer = Writer.create()): Writer { + if (message.address !== "") { + writer.uint32(10).string(message.address); + } + if (message.validatorSigningInfo !== undefined) { + ValidatorSigningInfo.encode( + message.validatorSigningInfo, + writer.uint32(18).fork() + ).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): SigningInfo { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseSigningInfo } as SigningInfo; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.address = reader.string(); + break; + case 2: + message.validatorSigningInfo = ValidatorSigningInfo.decode( + reader, + reader.uint32() + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): SigningInfo { + const message = { ...baseSigningInfo } as SigningInfo; + if (object.address !== undefined && object.address !== null) { + message.address = String(object.address); + } else { + message.address = ""; + } + if ( + object.validatorSigningInfo !== undefined && + object.validatorSigningInfo !== null + ) { + message.validatorSigningInfo = ValidatorSigningInfo.fromJSON( + object.validatorSigningInfo + ); + } else { + message.validatorSigningInfo = undefined; + } + return message; + }, + + toJSON(message: SigningInfo): unknown { + const obj: any = {}; + message.address !== undefined && (obj.address = message.address); + message.validatorSigningInfo !== undefined && + (obj.validatorSigningInfo = message.validatorSigningInfo + ? ValidatorSigningInfo.toJSON(message.validatorSigningInfo) + : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): SigningInfo { + const message = { ...baseSigningInfo } as SigningInfo; + if (object.address !== undefined && object.address !== null) { + message.address = object.address; + } else { + message.address = ""; + } + if ( + object.validatorSigningInfo !== undefined && + object.validatorSigningInfo !== null + ) { + message.validatorSigningInfo = ValidatorSigningInfo.fromPartial( + object.validatorSigningInfo + ); + } else { + message.validatorSigningInfo = undefined; + } + return message; + }, +}; + +const baseValidatorMissedBlocks: object = { address: "" }; + +export const ValidatorMissedBlocks = { + encode( + message: ValidatorMissedBlocks, + writer: Writer = Writer.create() + ): Writer { + if (message.address !== "") { + writer.uint32(10).string(message.address); + } + for (const v of message.missedBlocks) { + MissedBlock.encode(v!, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ValidatorMissedBlocks { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseValidatorMissedBlocks } as ValidatorMissedBlocks; + message.missedBlocks = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.address = reader.string(); + break; + case 2: + message.missedBlocks.push( + MissedBlock.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ValidatorMissedBlocks { + const message = { ...baseValidatorMissedBlocks } as ValidatorMissedBlocks; + message.missedBlocks = []; + if (object.address !== undefined && object.address !== null) { + message.address = String(object.address); + } else { + message.address = ""; + } + if (object.missedBlocks !== undefined && object.missedBlocks !== null) { + for (const e of object.missedBlocks) { + message.missedBlocks.push(MissedBlock.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: ValidatorMissedBlocks): unknown { + const obj: any = {}; + message.address !== undefined && (obj.address = message.address); + if (message.missedBlocks) { + obj.missedBlocks = message.missedBlocks.map((e) => + e ? MissedBlock.toJSON(e) : undefined + ); + } else { + obj.missedBlocks = []; + } + return obj; + }, + + fromPartial( + object: DeepPartial + ): ValidatorMissedBlocks { + const message = { ...baseValidatorMissedBlocks } as ValidatorMissedBlocks; + message.missedBlocks = []; + if (object.address !== undefined && object.address !== null) { + message.address = object.address; + } else { + message.address = ""; + } + if (object.missedBlocks !== undefined && object.missedBlocks !== null) { + for (const e of object.missedBlocks) { + message.missedBlocks.push(MissedBlock.fromPartial(e)); + } + } + return message; + }, +}; + +const baseMissedBlock: object = { index: 0, missed: false }; + +export const MissedBlock = { + encode(message: MissedBlock, writer: Writer = Writer.create()): Writer { + if (message.index !== 0) { + writer.uint32(8).int64(message.index); + } + if (message.missed === true) { + writer.uint32(16).bool(message.missed); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MissedBlock { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMissedBlock } as MissedBlock; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.index = longToNumber(reader.int64() as Long); + break; + case 2: + message.missed = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MissedBlock { + const message = { ...baseMissedBlock } as MissedBlock; + if (object.index !== undefined && object.index !== null) { + message.index = Number(object.index); + } else { + message.index = 0; + } + if (object.missed !== undefined && object.missed !== null) { + message.missed = Boolean(object.missed); + } else { + message.missed = false; + } + return message; + }, + + toJSON(message: MissedBlock): unknown { + const obj: any = {}; + message.index !== undefined && (obj.index = message.index); + message.missed !== undefined && (obj.missed = message.missed); + return obj; + }, + + fromPartial(object: DeepPartial): MissedBlock { + const message = { ...baseMissedBlock } as MissedBlock; + if (object.index !== undefined && object.index !== null) { + message.index = object.index; + } else { + message.index = 0; + } + if (object.missed !== undefined && object.missed !== null) { + message.missed = object.missed; + } else { + message.missed = false; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/cosmos.slashing.v1beta1/types/cosmos/slashing/v1beta1/query.ts b/ts-client/cosmos.slashing.v1beta1/types/cosmos/slashing/v1beta1/query.ts new file mode 100644 index 00000000..10501cbf --- /dev/null +++ b/ts-client/cosmos.slashing.v1beta1/types/cosmos/slashing/v1beta1/query.ts @@ -0,0 +1,554 @@ +/* eslint-disable */ +import { Reader, Writer } from "protobufjs/minimal"; +import { + Params, + ValidatorSigningInfo, +} from "../../../cosmos/slashing/v1beta1/slashing"; +import { + PageRequest, + PageResponse, +} from "../../../cosmos/base/query/v1beta1/pagination"; + +export const protobufPackage = "cosmos.slashing.v1beta1"; + +/** QueryParamsRequest is the request type for the Query/Params RPC method */ +export interface QueryParamsRequest {} + +/** QueryParamsResponse is the response type for the Query/Params RPC method */ +export interface QueryParamsResponse { + params: Params | undefined; +} + +/** + * QuerySigningInfoRequest is the request type for the Query/SigningInfo RPC + * method + */ +export interface QuerySigningInfoRequest { + /** cons_address is the address to query signing info of */ + consAddress: string; +} + +/** + * QuerySigningInfoResponse is the response type for the Query/SigningInfo RPC + * method + */ +export interface QuerySigningInfoResponse { + /** val_signing_info is the signing info of requested val cons address */ + valSigningInfo: ValidatorSigningInfo | undefined; +} + +/** + * QuerySigningInfosRequest is the request type for the Query/SigningInfos RPC + * method + */ +export interface QuerySigningInfosRequest { + pagination: PageRequest | undefined; +} + +/** + * QuerySigningInfosResponse is the response type for the Query/SigningInfos RPC + * method + */ +export interface QuerySigningInfosResponse { + /** info is the signing info of all validators */ + info: ValidatorSigningInfo[]; + pagination: PageResponse | undefined; +} + +const baseQueryParamsRequest: object = {}; + +export const QueryParamsRequest = { + encode(_: QueryParamsRequest, writer: Writer = Writer.create()): Writer { + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QueryParamsRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryParamsRequest } as QueryParamsRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): QueryParamsRequest { + const message = { ...baseQueryParamsRequest } as QueryParamsRequest; + return message; + }, + + toJSON(_: QueryParamsRequest): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial(_: DeepPartial): QueryParamsRequest { + const message = { ...baseQueryParamsRequest } as QueryParamsRequest; + return message; + }, +}; + +const baseQueryParamsResponse: object = {}; + +export const QueryParamsResponse = { + encode( + message: QueryParamsResponse, + writer: Writer = Writer.create() + ): Writer { + if (message.params !== undefined) { + Params.encode(message.params, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QueryParamsResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryParamsResponse } as QueryParamsResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.params = Params.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryParamsResponse { + const message = { ...baseQueryParamsResponse } as QueryParamsResponse; + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromJSON(object.params); + } else { + message.params = undefined; + } + return message; + }, + + toJSON(message: QueryParamsResponse): unknown { + const obj: any = {}; + message.params !== undefined && + (obj.params = message.params ? Params.toJSON(message.params) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): QueryParamsResponse { + const message = { ...baseQueryParamsResponse } as QueryParamsResponse; + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromPartial(object.params); + } else { + message.params = undefined; + } + return message; + }, +}; + +const baseQuerySigningInfoRequest: object = { consAddress: "" }; + +export const QuerySigningInfoRequest = { + encode( + message: QuerySigningInfoRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.consAddress !== "") { + writer.uint32(10).string(message.consAddress); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QuerySigningInfoRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQuerySigningInfoRequest, + } as QuerySigningInfoRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.consAddress = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QuerySigningInfoRequest { + const message = { + ...baseQuerySigningInfoRequest, + } as QuerySigningInfoRequest; + if (object.consAddress !== undefined && object.consAddress !== null) { + message.consAddress = String(object.consAddress); + } else { + message.consAddress = ""; + } + return message; + }, + + toJSON(message: QuerySigningInfoRequest): unknown { + const obj: any = {}; + message.consAddress !== undefined && + (obj.consAddress = message.consAddress); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QuerySigningInfoRequest { + const message = { + ...baseQuerySigningInfoRequest, + } as QuerySigningInfoRequest; + if (object.consAddress !== undefined && object.consAddress !== null) { + message.consAddress = object.consAddress; + } else { + message.consAddress = ""; + } + return message; + }, +}; + +const baseQuerySigningInfoResponse: object = {}; + +export const QuerySigningInfoResponse = { + encode( + message: QuerySigningInfoResponse, + writer: Writer = Writer.create() + ): Writer { + if (message.valSigningInfo !== undefined) { + ValidatorSigningInfo.encode( + message.valSigningInfo, + writer.uint32(10).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QuerySigningInfoResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQuerySigningInfoResponse, + } as QuerySigningInfoResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.valSigningInfo = ValidatorSigningInfo.decode( + reader, + reader.uint32() + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QuerySigningInfoResponse { + const message = { + ...baseQuerySigningInfoResponse, + } as QuerySigningInfoResponse; + if (object.valSigningInfo !== undefined && object.valSigningInfo !== null) { + message.valSigningInfo = ValidatorSigningInfo.fromJSON( + object.valSigningInfo + ); + } else { + message.valSigningInfo = undefined; + } + return message; + }, + + toJSON(message: QuerySigningInfoResponse): unknown { + const obj: any = {}; + message.valSigningInfo !== undefined && + (obj.valSigningInfo = message.valSigningInfo + ? ValidatorSigningInfo.toJSON(message.valSigningInfo) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QuerySigningInfoResponse { + const message = { + ...baseQuerySigningInfoResponse, + } as QuerySigningInfoResponse; + if (object.valSigningInfo !== undefined && object.valSigningInfo !== null) { + message.valSigningInfo = ValidatorSigningInfo.fromPartial( + object.valSigningInfo + ); + } else { + message.valSigningInfo = undefined; + } + return message; + }, +}; + +const baseQuerySigningInfosRequest: object = {}; + +export const QuerySigningInfosRequest = { + encode( + message: QuerySigningInfosRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QuerySigningInfosRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQuerySigningInfosRequest, + } as QuerySigningInfosRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QuerySigningInfosRequest { + const message = { + ...baseQuerySigningInfosRequest, + } as QuerySigningInfosRequest; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QuerySigningInfosRequest): unknown { + const obj: any = {}; + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageRequest.toJSON(message.pagination) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QuerySigningInfosRequest { + const message = { + ...baseQuerySigningInfosRequest, + } as QuerySigningInfosRequest; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseQuerySigningInfosResponse: object = {}; + +export const QuerySigningInfosResponse = { + encode( + message: QuerySigningInfosResponse, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.info) { + ValidatorSigningInfo.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode( + message.pagination, + writer.uint32(18).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QuerySigningInfosResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQuerySigningInfosResponse, + } as QuerySigningInfosResponse; + message.info = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.info.push( + ValidatorSigningInfo.decode(reader, reader.uint32()) + ); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QuerySigningInfosResponse { + const message = { + ...baseQuerySigningInfosResponse, + } as QuerySigningInfosResponse; + message.info = []; + if (object.info !== undefined && object.info !== null) { + for (const e of object.info) { + message.info.push(ValidatorSigningInfo.fromJSON(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QuerySigningInfosResponse): unknown { + const obj: any = {}; + if (message.info) { + obj.info = message.info.map((e) => + e ? ValidatorSigningInfo.toJSON(e) : undefined + ); + } else { + obj.info = []; + } + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageResponse.toJSON(message.pagination) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QuerySigningInfosResponse { + const message = { + ...baseQuerySigningInfosResponse, + } as QuerySigningInfosResponse; + message.info = []; + if (object.info !== undefined && object.info !== null) { + for (const e of object.info) { + message.info.push(ValidatorSigningInfo.fromPartial(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +/** Query provides defines the gRPC querier service */ +export interface Query { + /** Params queries the parameters of slashing module */ + Params(request: QueryParamsRequest): Promise; + /** SigningInfo queries the signing info of given cons address */ + SigningInfo( + request: QuerySigningInfoRequest + ): Promise; + /** SigningInfos queries signing info of all validators */ + SigningInfos( + request: QuerySigningInfosRequest + ): Promise; +} + +export class QueryClientImpl implements Query { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + } + Params(request: QueryParamsRequest): Promise { + const data = QueryParamsRequest.encode(request).finish(); + const promise = this.rpc.request( + "cosmos.slashing.v1beta1.Query", + "Params", + data + ); + return promise.then((data) => QueryParamsResponse.decode(new Reader(data))); + } + + SigningInfo( + request: QuerySigningInfoRequest + ): Promise { + const data = QuerySigningInfoRequest.encode(request).finish(); + const promise = this.rpc.request( + "cosmos.slashing.v1beta1.Query", + "SigningInfo", + data + ); + return promise.then((data) => + QuerySigningInfoResponse.decode(new Reader(data)) + ); + } + + SigningInfos( + request: QuerySigningInfosRequest + ): Promise { + const data = QuerySigningInfosRequest.encode(request).finish(); + const promise = this.rpc.request( + "cosmos.slashing.v1beta1.Query", + "SigningInfos", + data + ); + return promise.then((data) => + QuerySigningInfosResponse.decode(new Reader(data)) + ); + } +} + +interface Rpc { + request( + service: string, + method: string, + data: Uint8Array + ): Promise; +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/cosmos.slashing.v1beta1/types/cosmos/slashing/v1beta1/slashing.ts b/ts-client/cosmos.slashing.v1beta1/types/cosmos/slashing/v1beta1/slashing.ts new file mode 100644 index 00000000..143787b2 --- /dev/null +++ b/ts-client/cosmos.slashing.v1beta1/types/cosmos/slashing/v1beta1/slashing.ts @@ -0,0 +1,469 @@ +/* eslint-disable */ +import { Timestamp } from "../../../google/protobuf/timestamp"; +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; +import { Duration } from "../../../google/protobuf/duration"; + +export const protobufPackage = "cosmos.slashing.v1beta1"; + +/** + * ValidatorSigningInfo defines a validator's signing info for monitoring their + * liveness activity. + */ +export interface ValidatorSigningInfo { + address: string; + /** Height at which validator was first a candidate OR was unjailed */ + startHeight: number; + /** + * Index which is incremented each time the validator was a bonded + * in a block and may have signed a precommit or not. This in conjunction with the + * `SignedBlocksWindow` param determines the index in the `MissedBlocksBitArray`. + */ + indexOffset: number; + /** Timestamp until which the validator is jailed due to liveness downtime. */ + jailedUntil: Date | undefined; + /** + * Whether or not a validator has been tombstoned (killed out of validator set). It is set + * once the validator commits an equivocation or for any other configured misbehiavor. + */ + tombstoned: boolean; + /** + * A counter kept to avoid unnecessary array reads. + * Note that `Sum(MissedBlocksBitArray)` always equals `MissedBlocksCounter`. + */ + missedBlocksCounter: number; +} + +/** Params represents the parameters used for by the slashing module. */ +export interface Params { + signedBlocksWindow: number; + minSignedPerWindow: Uint8Array; + downtimeJailDuration: Duration | undefined; + slashFractionDoubleSign: Uint8Array; + slashFractionDowntime: Uint8Array; +} + +const baseValidatorSigningInfo: object = { + address: "", + startHeight: 0, + indexOffset: 0, + tombstoned: false, + missedBlocksCounter: 0, +}; + +export const ValidatorSigningInfo = { + encode( + message: ValidatorSigningInfo, + writer: Writer = Writer.create() + ): Writer { + if (message.address !== "") { + writer.uint32(10).string(message.address); + } + if (message.startHeight !== 0) { + writer.uint32(16).int64(message.startHeight); + } + if (message.indexOffset !== 0) { + writer.uint32(24).int64(message.indexOffset); + } + if (message.jailedUntil !== undefined) { + Timestamp.encode( + toTimestamp(message.jailedUntil), + writer.uint32(34).fork() + ).ldelim(); + } + if (message.tombstoned === true) { + writer.uint32(40).bool(message.tombstoned); + } + if (message.missedBlocksCounter !== 0) { + writer.uint32(48).int64(message.missedBlocksCounter); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ValidatorSigningInfo { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseValidatorSigningInfo } as ValidatorSigningInfo; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.address = reader.string(); + break; + case 2: + message.startHeight = longToNumber(reader.int64() as Long); + break; + case 3: + message.indexOffset = longToNumber(reader.int64() as Long); + break; + case 4: + message.jailedUntil = fromTimestamp( + Timestamp.decode(reader, reader.uint32()) + ); + break; + case 5: + message.tombstoned = reader.bool(); + break; + case 6: + message.missedBlocksCounter = longToNumber(reader.int64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ValidatorSigningInfo { + const message = { ...baseValidatorSigningInfo } as ValidatorSigningInfo; + if (object.address !== undefined && object.address !== null) { + message.address = String(object.address); + } else { + message.address = ""; + } + if (object.startHeight !== undefined && object.startHeight !== null) { + message.startHeight = Number(object.startHeight); + } else { + message.startHeight = 0; + } + if (object.indexOffset !== undefined && object.indexOffset !== null) { + message.indexOffset = Number(object.indexOffset); + } else { + message.indexOffset = 0; + } + if (object.jailedUntil !== undefined && object.jailedUntil !== null) { + message.jailedUntil = fromJsonTimestamp(object.jailedUntil); + } else { + message.jailedUntil = undefined; + } + if (object.tombstoned !== undefined && object.tombstoned !== null) { + message.tombstoned = Boolean(object.tombstoned); + } else { + message.tombstoned = false; + } + if ( + object.missedBlocksCounter !== undefined && + object.missedBlocksCounter !== null + ) { + message.missedBlocksCounter = Number(object.missedBlocksCounter); + } else { + message.missedBlocksCounter = 0; + } + return message; + }, + + toJSON(message: ValidatorSigningInfo): unknown { + const obj: any = {}; + message.address !== undefined && (obj.address = message.address); + message.startHeight !== undefined && + (obj.startHeight = message.startHeight); + message.indexOffset !== undefined && + (obj.indexOffset = message.indexOffset); + message.jailedUntil !== undefined && + (obj.jailedUntil = + message.jailedUntil !== undefined + ? message.jailedUntil.toISOString() + : null); + message.tombstoned !== undefined && (obj.tombstoned = message.tombstoned); + message.missedBlocksCounter !== undefined && + (obj.missedBlocksCounter = message.missedBlocksCounter); + return obj; + }, + + fromPartial(object: DeepPartial): ValidatorSigningInfo { + const message = { ...baseValidatorSigningInfo } as ValidatorSigningInfo; + if (object.address !== undefined && object.address !== null) { + message.address = object.address; + } else { + message.address = ""; + } + if (object.startHeight !== undefined && object.startHeight !== null) { + message.startHeight = object.startHeight; + } else { + message.startHeight = 0; + } + if (object.indexOffset !== undefined && object.indexOffset !== null) { + message.indexOffset = object.indexOffset; + } else { + message.indexOffset = 0; + } + if (object.jailedUntil !== undefined && object.jailedUntil !== null) { + message.jailedUntil = object.jailedUntil; + } else { + message.jailedUntil = undefined; + } + if (object.tombstoned !== undefined && object.tombstoned !== null) { + message.tombstoned = object.tombstoned; + } else { + message.tombstoned = false; + } + if ( + object.missedBlocksCounter !== undefined && + object.missedBlocksCounter !== null + ) { + message.missedBlocksCounter = object.missedBlocksCounter; + } else { + message.missedBlocksCounter = 0; + } + return message; + }, +}; + +const baseParams: object = { signedBlocksWindow: 0 }; + +export const Params = { + encode(message: Params, writer: Writer = Writer.create()): Writer { + if (message.signedBlocksWindow !== 0) { + writer.uint32(8).int64(message.signedBlocksWindow); + } + if (message.minSignedPerWindow.length !== 0) { + writer.uint32(18).bytes(message.minSignedPerWindow); + } + if (message.downtimeJailDuration !== undefined) { + Duration.encode( + message.downtimeJailDuration, + writer.uint32(26).fork() + ).ldelim(); + } + if (message.slashFractionDoubleSign.length !== 0) { + writer.uint32(34).bytes(message.slashFractionDoubleSign); + } + if (message.slashFractionDowntime.length !== 0) { + writer.uint32(42).bytes(message.slashFractionDowntime); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Params { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseParams } as Params; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.signedBlocksWindow = longToNumber(reader.int64() as Long); + break; + case 2: + message.minSignedPerWindow = reader.bytes(); + break; + case 3: + message.downtimeJailDuration = Duration.decode( + reader, + reader.uint32() + ); + break; + case 4: + message.slashFractionDoubleSign = reader.bytes(); + break; + case 5: + message.slashFractionDowntime = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Params { + const message = { ...baseParams } as Params; + if ( + object.signedBlocksWindow !== undefined && + object.signedBlocksWindow !== null + ) { + message.signedBlocksWindow = Number(object.signedBlocksWindow); + } else { + message.signedBlocksWindow = 0; + } + if ( + object.minSignedPerWindow !== undefined && + object.minSignedPerWindow !== null + ) { + message.minSignedPerWindow = bytesFromBase64(object.minSignedPerWindow); + } + if ( + object.downtimeJailDuration !== undefined && + object.downtimeJailDuration !== null + ) { + message.downtimeJailDuration = Duration.fromJSON( + object.downtimeJailDuration + ); + } else { + message.downtimeJailDuration = undefined; + } + if ( + object.slashFractionDoubleSign !== undefined && + object.slashFractionDoubleSign !== null + ) { + message.slashFractionDoubleSign = bytesFromBase64( + object.slashFractionDoubleSign + ); + } + if ( + object.slashFractionDowntime !== undefined && + object.slashFractionDowntime !== null + ) { + message.slashFractionDowntime = bytesFromBase64( + object.slashFractionDowntime + ); + } + return message; + }, + + toJSON(message: Params): unknown { + const obj: any = {}; + message.signedBlocksWindow !== undefined && + (obj.signedBlocksWindow = message.signedBlocksWindow); + message.minSignedPerWindow !== undefined && + (obj.minSignedPerWindow = base64FromBytes( + message.minSignedPerWindow !== undefined + ? message.minSignedPerWindow + : new Uint8Array() + )); + message.downtimeJailDuration !== undefined && + (obj.downtimeJailDuration = message.downtimeJailDuration + ? Duration.toJSON(message.downtimeJailDuration) + : undefined); + message.slashFractionDoubleSign !== undefined && + (obj.slashFractionDoubleSign = base64FromBytes( + message.slashFractionDoubleSign !== undefined + ? message.slashFractionDoubleSign + : new Uint8Array() + )); + message.slashFractionDowntime !== undefined && + (obj.slashFractionDowntime = base64FromBytes( + message.slashFractionDowntime !== undefined + ? message.slashFractionDowntime + : new Uint8Array() + )); + return obj; + }, + + fromPartial(object: DeepPartial): Params { + const message = { ...baseParams } as Params; + if ( + object.signedBlocksWindow !== undefined && + object.signedBlocksWindow !== null + ) { + message.signedBlocksWindow = object.signedBlocksWindow; + } else { + message.signedBlocksWindow = 0; + } + if ( + object.minSignedPerWindow !== undefined && + object.minSignedPerWindow !== null + ) { + message.minSignedPerWindow = object.minSignedPerWindow; + } else { + message.minSignedPerWindow = new Uint8Array(); + } + if ( + object.downtimeJailDuration !== undefined && + object.downtimeJailDuration !== null + ) { + message.downtimeJailDuration = Duration.fromPartial( + object.downtimeJailDuration + ); + } else { + message.downtimeJailDuration = undefined; + } + if ( + object.slashFractionDoubleSign !== undefined && + object.slashFractionDoubleSign !== null + ) { + message.slashFractionDoubleSign = object.slashFractionDoubleSign; + } else { + message.slashFractionDoubleSign = new Uint8Array(); + } + if ( + object.slashFractionDowntime !== undefined && + object.slashFractionDowntime !== null + ) { + message.slashFractionDowntime = object.slashFractionDowntime; + } else { + message.slashFractionDowntime = new Uint8Array(); + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function toTimestamp(date: Date): Timestamp { + const seconds = date.getTime() / 1_000; + const nanos = (date.getTime() % 1_000) * 1_000_000; + return { seconds, nanos }; +} + +function fromTimestamp(t: Timestamp): Date { + let millis = t.seconds * 1_000; + millis += t.nanos / 1_000_000; + return new Date(millis); +} + +function fromJsonTimestamp(o: any): Date { + if (o instanceof Date) { + return o; + } else if (typeof o === "string") { + return new Date(o); + } else { + return fromTimestamp(Timestamp.fromJSON(o)); + } +} + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/cosmos.slashing.v1beta1/types/cosmos/slashing/v1beta1/tx.ts b/ts-client/cosmos.slashing.v1beta1/types/cosmos/slashing/v1beta1/tx.ts new file mode 100644 index 00000000..3906fba7 --- /dev/null +++ b/ts-client/cosmos.slashing.v1beta1/types/cosmos/slashing/v1beta1/tx.ts @@ -0,0 +1,151 @@ +/* eslint-disable */ +import { Reader, Writer } from "protobufjs/minimal"; + +export const protobufPackage = "cosmos.slashing.v1beta1"; + +/** MsgUnjail defines the Msg/Unjail request type */ +export interface MsgUnjail { + validatorAddr: string; +} + +/** MsgUnjailResponse defines the Msg/Unjail response type */ +export interface MsgUnjailResponse {} + +const baseMsgUnjail: object = { validatorAddr: "" }; + +export const MsgUnjail = { + encode(message: MsgUnjail, writer: Writer = Writer.create()): Writer { + if (message.validatorAddr !== "") { + writer.uint32(10).string(message.validatorAddr); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MsgUnjail { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgUnjail } as MsgUnjail; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.validatorAddr = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgUnjail { + const message = { ...baseMsgUnjail } as MsgUnjail; + if (object.validatorAddr !== undefined && object.validatorAddr !== null) { + message.validatorAddr = String(object.validatorAddr); + } else { + message.validatorAddr = ""; + } + return message; + }, + + toJSON(message: MsgUnjail): unknown { + const obj: any = {}; + message.validatorAddr !== undefined && + (obj.validatorAddr = message.validatorAddr); + return obj; + }, + + fromPartial(object: DeepPartial): MsgUnjail { + const message = { ...baseMsgUnjail } as MsgUnjail; + if (object.validatorAddr !== undefined && object.validatorAddr !== null) { + message.validatorAddr = object.validatorAddr; + } else { + message.validatorAddr = ""; + } + return message; + }, +}; + +const baseMsgUnjailResponse: object = {}; + +export const MsgUnjailResponse = { + encode(_: MsgUnjailResponse, writer: Writer = Writer.create()): Writer { + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MsgUnjailResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgUnjailResponse } as MsgUnjailResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): MsgUnjailResponse { + const message = { ...baseMsgUnjailResponse } as MsgUnjailResponse; + return message; + }, + + toJSON(_: MsgUnjailResponse): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial(_: DeepPartial): MsgUnjailResponse { + const message = { ...baseMsgUnjailResponse } as MsgUnjailResponse; + return message; + }, +}; + +/** Msg defines the slashing Msg service. */ +export interface Msg { + /** + * Unjail defines a method for unjailing a jailed validator, thus returning + * them into the bonded validator set, so they can begin receiving provisions + * and rewards again. + */ + Unjail(request: MsgUnjail): Promise; +} + +export class MsgClientImpl implements Msg { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + } + Unjail(request: MsgUnjail): Promise { + const data = MsgUnjail.encode(request).finish(); + const promise = this.rpc.request( + "cosmos.slashing.v1beta1.Msg", + "Unjail", + data + ); + return promise.then((data) => MsgUnjailResponse.decode(new Reader(data))); + } +} + +interface Rpc { + request( + service: string, + method: string, + data: Uint8Array + ): Promise; +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/cosmos.slashing.v1beta1/types/gogoproto/gogo.ts b/ts-client/cosmos.slashing.v1beta1/types/gogoproto/gogo.ts new file mode 100644 index 00000000..3f41a047 --- /dev/null +++ b/ts-client/cosmos.slashing.v1beta1/types/gogoproto/gogo.ts @@ -0,0 +1,2 @@ +/* eslint-disable */ +export const protobufPackage = "gogoproto"; diff --git a/ts-client/cosmos.slashing.v1beta1/types/google/api/annotations.ts b/ts-client/cosmos.slashing.v1beta1/types/google/api/annotations.ts new file mode 100644 index 00000000..aace4787 --- /dev/null +++ b/ts-client/cosmos.slashing.v1beta1/types/google/api/annotations.ts @@ -0,0 +1,2 @@ +/* eslint-disable */ +export const protobufPackage = "google.api"; diff --git a/ts-client/cosmos.slashing.v1beta1/types/google/api/http.ts b/ts-client/cosmos.slashing.v1beta1/types/google/api/http.ts new file mode 100644 index 00000000..ddc00f8b --- /dev/null +++ b/ts-client/cosmos.slashing.v1beta1/types/google/api/http.ts @@ -0,0 +1,705 @@ +/* eslint-disable */ +import { Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "google.api"; + +/** + * Defines the HTTP configuration for an API service. It contains a list of + * [HttpRule][google.api.HttpRule], each specifying the mapping of an RPC method + * to one or more HTTP REST API methods. + */ +export interface Http { + /** + * A list of HTTP configuration rules that apply to individual API methods. + * + * **NOTE:** All service configuration rules follow "last one wins" order. + */ + rules: HttpRule[]; + /** + * When set to true, URL path parmeters will be fully URI-decoded except in + * cases of single segment matches in reserved expansion, where "%2F" will be + * left encoded. + * + * The default behavior is to not decode RFC 6570 reserved characters in multi + * segment matches. + */ + fullyDecodeReservedExpansion: boolean; +} + +/** + * `HttpRule` defines the mapping of an RPC method to one or more HTTP + * REST API methods. The mapping specifies how different portions of the RPC + * request message are mapped to URL path, URL query parameters, and + * HTTP request body. The mapping is typically specified as an + * `google.api.http` annotation on the RPC method, + * see "google/api/annotations.proto" for details. + * + * The mapping consists of a field specifying the path template and + * method kind. The path template can refer to fields in the request + * message, as in the example below which describes a REST GET + * operation on a resource collection of messages: + * + * + * service Messaging { + * rpc GetMessage(GetMessageRequest) returns (Message) { + * option (google.api.http).get = "/v1/messages/{message_id}/{sub.subfield}"; + * } + * } + * message GetMessageRequest { + * message SubMessage { + * string subfield = 1; + * } + * string message_id = 1; // mapped to the URL + * SubMessage sub = 2; // `sub.subfield` is url-mapped + * } + * message Message { + * string text = 1; // content of the resource + * } + * + * The same http annotation can alternatively be expressed inside the + * `GRPC API Configuration` YAML file. + * + * http: + * rules: + * - selector: .Messaging.GetMessage + * get: /v1/messages/{message_id}/{sub.subfield} + * + * This definition enables an automatic, bidrectional mapping of HTTP + * JSON to RPC. Example: + * + * HTTP | RPC + * -----|----- + * `GET /v1/messages/123456/foo` | `GetMessage(message_id: "123456" sub: SubMessage(subfield: "foo"))` + * + * In general, not only fields but also field paths can be referenced + * from a path pattern. Fields mapped to the path pattern cannot be + * repeated and must have a primitive (non-message) type. + * + * Any fields in the request message which are not bound by the path + * pattern automatically become (optional) HTTP query + * parameters. Assume the following definition of the request message: + * + * + * service Messaging { + * rpc GetMessage(GetMessageRequest) returns (Message) { + * option (google.api.http).get = "/v1/messages/{message_id}"; + * } + * } + * message GetMessageRequest { + * message SubMessage { + * string subfield = 1; + * } + * string message_id = 1; // mapped to the URL + * int64 revision = 2; // becomes a parameter + * SubMessage sub = 3; // `sub.subfield` becomes a parameter + * } + * + * + * This enables a HTTP JSON to RPC mapping as below: + * + * HTTP | RPC + * -----|----- + * `GET /v1/messages/123456?revision=2&sub.subfield=foo` | `GetMessage(message_id: "123456" revision: 2 sub: SubMessage(subfield: "foo"))` + * + * Note that fields which are mapped to HTTP parameters must have a + * primitive type or a repeated primitive type. Message types are not + * allowed. In the case of a repeated type, the parameter can be + * repeated in the URL, as in `...?param=A¶m=B`. + * + * For HTTP method kinds which allow a request body, the `body` field + * specifies the mapping. Consider a REST update method on the + * message resource collection: + * + * + * service Messaging { + * rpc UpdateMessage(UpdateMessageRequest) returns (Message) { + * option (google.api.http) = { + * put: "/v1/messages/{message_id}" + * body: "message" + * }; + * } + * } + * message UpdateMessageRequest { + * string message_id = 1; // mapped to the URL + * Message message = 2; // mapped to the body + * } + * + * + * The following HTTP JSON to RPC mapping is enabled, where the + * representation of the JSON in the request body is determined by + * protos JSON encoding: + * + * HTTP | RPC + * -----|----- + * `PUT /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: "123456" message { text: "Hi!" })` + * + * The special name `*` can be used in the body mapping to define that + * every field not bound by the path template should be mapped to the + * request body. This enables the following alternative definition of + * the update method: + * + * service Messaging { + * rpc UpdateMessage(Message) returns (Message) { + * option (google.api.http) = { + * put: "/v1/messages/{message_id}" + * body: "*" + * }; + * } + * } + * message Message { + * string message_id = 1; + * string text = 2; + * } + * + * + * The following HTTP JSON to RPC mapping is enabled: + * + * HTTP | RPC + * -----|----- + * `PUT /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: "123456" text: "Hi!")` + * + * Note that when using `*` in the body mapping, it is not possible to + * have HTTP parameters, as all fields not bound by the path end in + * the body. This makes this option more rarely used in practice of + * defining REST APIs. The common usage of `*` is in custom methods + * which don't use the URL at all for transferring data. + * + * It is possible to define multiple HTTP methods for one RPC by using + * the `additional_bindings` option. Example: + * + * service Messaging { + * rpc GetMessage(GetMessageRequest) returns (Message) { + * option (google.api.http) = { + * get: "/v1/messages/{message_id}" + * additional_bindings { + * get: "/v1/users/{user_id}/messages/{message_id}" + * } + * }; + * } + * } + * message GetMessageRequest { + * string message_id = 1; + * string user_id = 2; + * } + * + * + * This enables the following two alternative HTTP JSON to RPC + * mappings: + * + * HTTP | RPC + * -----|----- + * `GET /v1/messages/123456` | `GetMessage(message_id: "123456")` + * `GET /v1/users/me/messages/123456` | `GetMessage(user_id: "me" message_id: "123456")` + * + * # Rules for HTTP mapping + * + * The rules for mapping HTTP path, query parameters, and body fields + * to the request message are as follows: + * + * 1. The `body` field specifies either `*` or a field path, or is + * omitted. If omitted, it indicates there is no HTTP request body. + * 2. Leaf fields (recursive expansion of nested messages in the + * request) can be classified into three types: + * (a) Matched in the URL template. + * (b) Covered by body (if body is `*`, everything except (a) fields; + * else everything under the body field) + * (c) All other fields. + * 3. URL query parameters found in the HTTP request are mapped to (c) fields. + * 4. Any body sent with an HTTP request can contain only (b) fields. + * + * The syntax of the path template is as follows: + * + * Template = "/" Segments [ Verb ] ; + * Segments = Segment { "/" Segment } ; + * Segment = "*" | "**" | LITERAL | Variable ; + * Variable = "{" FieldPath [ "=" Segments ] "}" ; + * FieldPath = IDENT { "." IDENT } ; + * Verb = ":" LITERAL ; + * + * The syntax `*` matches a single path segment. The syntax `**` matches zero + * or more path segments, which must be the last part of the path except the + * `Verb`. The syntax `LITERAL` matches literal text in the path. + * + * The syntax `Variable` matches part of the URL path as specified by its + * template. A variable template must not contain other variables. If a variable + * matches a single path segment, its template may be omitted, e.g. `{var}` + * is equivalent to `{var=*}`. + * + * If a variable contains exactly one path segment, such as `"{var}"` or + * `"{var=*}"`, when such a variable is expanded into a URL path, all characters + * except `[-_.~0-9a-zA-Z]` are percent-encoded. Such variables show up in the + * Discovery Document as `{var}`. + * + * If a variable contains one or more path segments, such as `"{var=foo/*}"` + * or `"{var=**}"`, when such a variable is expanded into a URL path, all + * characters except `[-_.~/0-9a-zA-Z]` are percent-encoded. Such variables + * show up in the Discovery Document as `{+var}`. + * + * NOTE: While the single segment variable matches the semantics of + * [RFC 6570](https://tools.ietf.org/html/rfc6570) Section 3.2.2 + * Simple String Expansion, the multi segment variable **does not** match + * RFC 6570 Reserved Expansion. The reason is that the Reserved Expansion + * does not expand special characters like `?` and `#`, which would lead + * to invalid URLs. + * + * NOTE: the field paths in variables and in the `body` must not refer to + * repeated fields or map fields. + */ +export interface HttpRule { + /** + * Selects methods to which this rule applies. + * + * Refer to [selector][google.api.DocumentationRule.selector] for syntax details. + */ + selector: string; + /** Used for listing and getting information about resources. */ + get: string | undefined; + /** Used for updating a resource. */ + put: string | undefined; + /** Used for creating a resource. */ + post: string | undefined; + /** Used for deleting a resource. */ + delete: string | undefined; + /** Used for updating a resource. */ + patch: string | undefined; + /** + * The custom pattern is used for specifying an HTTP method that is not + * included in the `pattern` field, such as HEAD, or "*" to leave the + * HTTP method unspecified for this rule. The wild-card rule is useful + * for services that provide content to Web (HTML) clients. + */ + custom: CustomHttpPattern | undefined; + /** + * The name of the request field whose value is mapped to the HTTP body, or + * `*` for mapping all fields not captured by the path pattern to the HTTP + * body. NOTE: the referred field must not be a repeated field and must be + * present at the top-level of request message type. + */ + body: string; + /** + * Optional. The name of the response field whose value is mapped to the HTTP + * body of response. Other response fields are ignored. When + * not set, the response message will be used as HTTP body of response. + */ + responseBody: string; + /** + * Additional HTTP bindings for the selector. Nested bindings must + * not contain an `additional_bindings` field themselves (that is, + * the nesting may only be one level deep). + */ + additionalBindings: HttpRule[]; +} + +/** A custom pattern is used for defining custom HTTP verb. */ +export interface CustomHttpPattern { + /** The name of this custom HTTP verb. */ + kind: string; + /** The path matched by this custom verb. */ + path: string; +} + +const baseHttp: object = { fullyDecodeReservedExpansion: false }; + +export const Http = { + encode(message: Http, writer: Writer = Writer.create()): Writer { + for (const v of message.rules) { + HttpRule.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.fullyDecodeReservedExpansion === true) { + writer.uint32(16).bool(message.fullyDecodeReservedExpansion); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Http { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseHttp } as Http; + message.rules = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.rules.push(HttpRule.decode(reader, reader.uint32())); + break; + case 2: + message.fullyDecodeReservedExpansion = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Http { + const message = { ...baseHttp } as Http; + message.rules = []; + if (object.rules !== undefined && object.rules !== null) { + for (const e of object.rules) { + message.rules.push(HttpRule.fromJSON(e)); + } + } + if ( + object.fullyDecodeReservedExpansion !== undefined && + object.fullyDecodeReservedExpansion !== null + ) { + message.fullyDecodeReservedExpansion = Boolean( + object.fullyDecodeReservedExpansion + ); + } else { + message.fullyDecodeReservedExpansion = false; + } + return message; + }, + + toJSON(message: Http): unknown { + const obj: any = {}; + if (message.rules) { + obj.rules = message.rules.map((e) => + e ? HttpRule.toJSON(e) : undefined + ); + } else { + obj.rules = []; + } + message.fullyDecodeReservedExpansion !== undefined && + (obj.fullyDecodeReservedExpansion = message.fullyDecodeReservedExpansion); + return obj; + }, + + fromPartial(object: DeepPartial): Http { + const message = { ...baseHttp } as Http; + message.rules = []; + if (object.rules !== undefined && object.rules !== null) { + for (const e of object.rules) { + message.rules.push(HttpRule.fromPartial(e)); + } + } + if ( + object.fullyDecodeReservedExpansion !== undefined && + object.fullyDecodeReservedExpansion !== null + ) { + message.fullyDecodeReservedExpansion = + object.fullyDecodeReservedExpansion; + } else { + message.fullyDecodeReservedExpansion = false; + } + return message; + }, +}; + +const baseHttpRule: object = { selector: "", body: "", responseBody: "" }; + +export const HttpRule = { + encode(message: HttpRule, writer: Writer = Writer.create()): Writer { + if (message.selector !== "") { + writer.uint32(10).string(message.selector); + } + if (message.get !== undefined) { + writer.uint32(18).string(message.get); + } + if (message.put !== undefined) { + writer.uint32(26).string(message.put); + } + if (message.post !== undefined) { + writer.uint32(34).string(message.post); + } + if (message.delete !== undefined) { + writer.uint32(42).string(message.delete); + } + if (message.patch !== undefined) { + writer.uint32(50).string(message.patch); + } + if (message.custom !== undefined) { + CustomHttpPattern.encode( + message.custom, + writer.uint32(66).fork() + ).ldelim(); + } + if (message.body !== "") { + writer.uint32(58).string(message.body); + } + if (message.responseBody !== "") { + writer.uint32(98).string(message.responseBody); + } + for (const v of message.additionalBindings) { + HttpRule.encode(v!, writer.uint32(90).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): HttpRule { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseHttpRule } as HttpRule; + message.additionalBindings = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.selector = reader.string(); + break; + case 2: + message.get = reader.string(); + break; + case 3: + message.put = reader.string(); + break; + case 4: + message.post = reader.string(); + break; + case 5: + message.delete = reader.string(); + break; + case 6: + message.patch = reader.string(); + break; + case 8: + message.custom = CustomHttpPattern.decode(reader, reader.uint32()); + break; + case 7: + message.body = reader.string(); + break; + case 12: + message.responseBody = reader.string(); + break; + case 11: + message.additionalBindings.push( + HttpRule.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): HttpRule { + const message = { ...baseHttpRule } as HttpRule; + message.additionalBindings = []; + if (object.selector !== undefined && object.selector !== null) { + message.selector = String(object.selector); + } else { + message.selector = ""; + } + if (object.get !== undefined && object.get !== null) { + message.get = String(object.get); + } else { + message.get = undefined; + } + if (object.put !== undefined && object.put !== null) { + message.put = String(object.put); + } else { + message.put = undefined; + } + if (object.post !== undefined && object.post !== null) { + message.post = String(object.post); + } else { + message.post = undefined; + } + if (object.delete !== undefined && object.delete !== null) { + message.delete = String(object.delete); + } else { + message.delete = undefined; + } + if (object.patch !== undefined && object.patch !== null) { + message.patch = String(object.patch); + } else { + message.patch = undefined; + } + if (object.custom !== undefined && object.custom !== null) { + message.custom = CustomHttpPattern.fromJSON(object.custom); + } else { + message.custom = undefined; + } + if (object.body !== undefined && object.body !== null) { + message.body = String(object.body); + } else { + message.body = ""; + } + if (object.responseBody !== undefined && object.responseBody !== null) { + message.responseBody = String(object.responseBody); + } else { + message.responseBody = ""; + } + if ( + object.additionalBindings !== undefined && + object.additionalBindings !== null + ) { + for (const e of object.additionalBindings) { + message.additionalBindings.push(HttpRule.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: HttpRule): unknown { + const obj: any = {}; + message.selector !== undefined && (obj.selector = message.selector); + message.get !== undefined && (obj.get = message.get); + message.put !== undefined && (obj.put = message.put); + message.post !== undefined && (obj.post = message.post); + message.delete !== undefined && (obj.delete = message.delete); + message.patch !== undefined && (obj.patch = message.patch); + message.custom !== undefined && + (obj.custom = message.custom + ? CustomHttpPattern.toJSON(message.custom) + : undefined); + message.body !== undefined && (obj.body = message.body); + message.responseBody !== undefined && + (obj.responseBody = message.responseBody); + if (message.additionalBindings) { + obj.additionalBindings = message.additionalBindings.map((e) => + e ? HttpRule.toJSON(e) : undefined + ); + } else { + obj.additionalBindings = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): HttpRule { + const message = { ...baseHttpRule } as HttpRule; + message.additionalBindings = []; + if (object.selector !== undefined && object.selector !== null) { + message.selector = object.selector; + } else { + message.selector = ""; + } + if (object.get !== undefined && object.get !== null) { + message.get = object.get; + } else { + message.get = undefined; + } + if (object.put !== undefined && object.put !== null) { + message.put = object.put; + } else { + message.put = undefined; + } + if (object.post !== undefined && object.post !== null) { + message.post = object.post; + } else { + message.post = undefined; + } + if (object.delete !== undefined && object.delete !== null) { + message.delete = object.delete; + } else { + message.delete = undefined; + } + if (object.patch !== undefined && object.patch !== null) { + message.patch = object.patch; + } else { + message.patch = undefined; + } + if (object.custom !== undefined && object.custom !== null) { + message.custom = CustomHttpPattern.fromPartial(object.custom); + } else { + message.custom = undefined; + } + if (object.body !== undefined && object.body !== null) { + message.body = object.body; + } else { + message.body = ""; + } + if (object.responseBody !== undefined && object.responseBody !== null) { + message.responseBody = object.responseBody; + } else { + message.responseBody = ""; + } + if ( + object.additionalBindings !== undefined && + object.additionalBindings !== null + ) { + for (const e of object.additionalBindings) { + message.additionalBindings.push(HttpRule.fromPartial(e)); + } + } + return message; + }, +}; + +const baseCustomHttpPattern: object = { kind: "", path: "" }; + +export const CustomHttpPattern = { + encode(message: CustomHttpPattern, writer: Writer = Writer.create()): Writer { + if (message.kind !== "") { + writer.uint32(10).string(message.kind); + } + if (message.path !== "") { + writer.uint32(18).string(message.path); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): CustomHttpPattern { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseCustomHttpPattern } as CustomHttpPattern; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.kind = reader.string(); + break; + case 2: + message.path = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): CustomHttpPattern { + const message = { ...baseCustomHttpPattern } as CustomHttpPattern; + if (object.kind !== undefined && object.kind !== null) { + message.kind = String(object.kind); + } else { + message.kind = ""; + } + if (object.path !== undefined && object.path !== null) { + message.path = String(object.path); + } else { + message.path = ""; + } + return message; + }, + + toJSON(message: CustomHttpPattern): unknown { + const obj: any = {}; + message.kind !== undefined && (obj.kind = message.kind); + message.path !== undefined && (obj.path = message.path); + return obj; + }, + + fromPartial(object: DeepPartial): CustomHttpPattern { + const message = { ...baseCustomHttpPattern } as CustomHttpPattern; + if (object.kind !== undefined && object.kind !== null) { + message.kind = object.kind; + } else { + message.kind = ""; + } + if (object.path !== undefined && object.path !== null) { + message.path = object.path; + } else { + message.path = ""; + } + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/cosmos.slashing.v1beta1/types/google/protobuf/descriptor.ts b/ts-client/cosmos.slashing.v1beta1/types/google/protobuf/descriptor.ts new file mode 100644 index 00000000..9e508660 --- /dev/null +++ b/ts-client/cosmos.slashing.v1beta1/types/google/protobuf/descriptor.ts @@ -0,0 +1,5261 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "google.protobuf"; + +/** + * The protocol compiler can output a FileDescriptorSet containing the .proto + * files it parses. + */ +export interface FileDescriptorSet { + file: FileDescriptorProto[]; +} + +/** Describes a complete .proto file. */ +export interface FileDescriptorProto { + /** file name, relative to root of source tree */ + name: string; + /** e.g. "foo", "foo.bar", etc. */ + package: string; + /** Names of files imported by this file. */ + dependency: string[]; + /** Indexes of the public imported files in the dependency list above. */ + publicDependency: number[]; + /** + * Indexes of the weak imported files in the dependency list. + * For Google-internal migration only. Do not use. + */ + weakDependency: number[]; + /** All top-level definitions in this file. */ + messageType: DescriptorProto[]; + enumType: EnumDescriptorProto[]; + service: ServiceDescriptorProto[]; + extension: FieldDescriptorProto[]; + options: FileOptions | undefined; + /** + * This field contains optional information about the original source code. + * You may safely remove this entire field without harming runtime + * functionality of the descriptors -- the information is needed only by + * development tools. + */ + sourceCodeInfo: SourceCodeInfo | undefined; + /** + * The syntax of the proto file. + * The supported values are "proto2" and "proto3". + */ + syntax: string; +} + +/** Describes a message type. */ +export interface DescriptorProto { + name: string; + field: FieldDescriptorProto[]; + extension: FieldDescriptorProto[]; + nestedType: DescriptorProto[]; + enumType: EnumDescriptorProto[]; + extensionRange: DescriptorProto_ExtensionRange[]; + oneofDecl: OneofDescriptorProto[]; + options: MessageOptions | undefined; + reservedRange: DescriptorProto_ReservedRange[]; + /** + * Reserved field names, which may not be used by fields in the same message. + * A given name may only be reserved once. + */ + reservedName: string[]; +} + +export interface DescriptorProto_ExtensionRange { + /** Inclusive. */ + start: number; + /** Exclusive. */ + end: number; + options: ExtensionRangeOptions | undefined; +} + +/** + * Range of reserved tag numbers. Reserved tag numbers may not be used by + * fields or extension ranges in the same message. Reserved ranges may + * not overlap. + */ +export interface DescriptorProto_ReservedRange { + /** Inclusive. */ + start: number; + /** Exclusive. */ + end: number; +} + +export interface ExtensionRangeOptions { + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +/** Describes a field within a message. */ +export interface FieldDescriptorProto { + name: string; + number: number; + label: FieldDescriptorProto_Label; + /** + * If type_name is set, this need not be set. If both this and type_name + * are set, this must be one of TYPE_ENUM, TYPE_MESSAGE or TYPE_GROUP. + */ + type: FieldDescriptorProto_Type; + /** + * For message and enum types, this is the name of the type. If the name + * starts with a '.', it is fully-qualified. Otherwise, C++-like scoping + * rules are used to find the type (i.e. first the nested types within this + * message are searched, then within the parent, on up to the root + * namespace). + */ + typeName: string; + /** + * For extensions, this is the name of the type being extended. It is + * resolved in the same manner as type_name. + */ + extendee: string; + /** + * For numeric types, contains the original text representation of the value. + * For booleans, "true" or "false". + * For strings, contains the default text contents (not escaped in any way). + * For bytes, contains the C escaped value. All bytes >= 128 are escaped. + * TODO(kenton): Base-64 encode? + */ + defaultValue: string; + /** + * If set, gives the index of a oneof in the containing type's oneof_decl + * list. This field is a member of that oneof. + */ + oneofIndex: number; + /** + * JSON name of this field. The value is set by protocol compiler. If the + * user has set a "json_name" option on this field, that option's value + * will be used. Otherwise, it's deduced from the field's name by converting + * it to camelCase. + */ + jsonName: string; + options: FieldOptions | undefined; + /** + * If true, this is a proto3 "optional". When a proto3 field is optional, it + * tracks presence regardless of field type. + * + * When proto3_optional is true, this field must be belong to a oneof to + * signal to old proto3 clients that presence is tracked for this field. This + * oneof is known as a "synthetic" oneof, and this field must be its sole + * member (each proto3 optional field gets its own synthetic oneof). Synthetic + * oneofs exist in the descriptor only, and do not generate any API. Synthetic + * oneofs must be ordered after all "real" oneofs. + * + * For message fields, proto3_optional doesn't create any semantic change, + * since non-repeated message fields always track presence. However it still + * indicates the semantic detail of whether the user wrote "optional" or not. + * This can be useful for round-tripping the .proto file. For consistency we + * give message fields a synthetic oneof also, even though it is not required + * to track presence. This is especially important because the parser can't + * tell if a field is a message or an enum, so it must always create a + * synthetic oneof. + * + * Proto2 optional fields do not set this flag, because they already indicate + * optional with `LABEL_OPTIONAL`. + */ + proto3Optional: boolean; +} + +export enum FieldDescriptorProto_Type { + /** + * TYPE_DOUBLE - 0 is reserved for errors. + * Order is weird for historical reasons. + */ + TYPE_DOUBLE = 1, + TYPE_FLOAT = 2, + /** + * TYPE_INT64 - Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT64 if + * negative values are likely. + */ + TYPE_INT64 = 3, + TYPE_UINT64 = 4, + /** + * TYPE_INT32 - Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT32 if + * negative values are likely. + */ + TYPE_INT32 = 5, + TYPE_FIXED64 = 6, + TYPE_FIXED32 = 7, + TYPE_BOOL = 8, + TYPE_STRING = 9, + /** + * TYPE_GROUP - Tag-delimited aggregate. + * Group type is deprecated and not supported in proto3. However, Proto3 + * implementations should still be able to parse the group wire format and + * treat group fields as unknown fields. + */ + TYPE_GROUP = 10, + /** TYPE_MESSAGE - Length-delimited aggregate. */ + TYPE_MESSAGE = 11, + /** TYPE_BYTES - New in version 2. */ + TYPE_BYTES = 12, + TYPE_UINT32 = 13, + TYPE_ENUM = 14, + TYPE_SFIXED32 = 15, + TYPE_SFIXED64 = 16, + /** TYPE_SINT32 - Uses ZigZag encoding. */ + TYPE_SINT32 = 17, + /** TYPE_SINT64 - Uses ZigZag encoding. */ + TYPE_SINT64 = 18, + UNRECOGNIZED = -1, +} + +export function fieldDescriptorProto_TypeFromJSON( + object: any +): FieldDescriptorProto_Type { + switch (object) { + case 1: + case "TYPE_DOUBLE": + return FieldDescriptorProto_Type.TYPE_DOUBLE; + case 2: + case "TYPE_FLOAT": + return FieldDescriptorProto_Type.TYPE_FLOAT; + case 3: + case "TYPE_INT64": + return FieldDescriptorProto_Type.TYPE_INT64; + case 4: + case "TYPE_UINT64": + return FieldDescriptorProto_Type.TYPE_UINT64; + case 5: + case "TYPE_INT32": + return FieldDescriptorProto_Type.TYPE_INT32; + case 6: + case "TYPE_FIXED64": + return FieldDescriptorProto_Type.TYPE_FIXED64; + case 7: + case "TYPE_FIXED32": + return FieldDescriptorProto_Type.TYPE_FIXED32; + case 8: + case "TYPE_BOOL": + return FieldDescriptorProto_Type.TYPE_BOOL; + case 9: + case "TYPE_STRING": + return FieldDescriptorProto_Type.TYPE_STRING; + case 10: + case "TYPE_GROUP": + return FieldDescriptorProto_Type.TYPE_GROUP; + case 11: + case "TYPE_MESSAGE": + return FieldDescriptorProto_Type.TYPE_MESSAGE; + case 12: + case "TYPE_BYTES": + return FieldDescriptorProto_Type.TYPE_BYTES; + case 13: + case "TYPE_UINT32": + return FieldDescriptorProto_Type.TYPE_UINT32; + case 14: + case "TYPE_ENUM": + return FieldDescriptorProto_Type.TYPE_ENUM; + case 15: + case "TYPE_SFIXED32": + return FieldDescriptorProto_Type.TYPE_SFIXED32; + case 16: + case "TYPE_SFIXED64": + return FieldDescriptorProto_Type.TYPE_SFIXED64; + case 17: + case "TYPE_SINT32": + return FieldDescriptorProto_Type.TYPE_SINT32; + case 18: + case "TYPE_SINT64": + return FieldDescriptorProto_Type.TYPE_SINT64; + case -1: + case "UNRECOGNIZED": + default: + return FieldDescriptorProto_Type.UNRECOGNIZED; + } +} + +export function fieldDescriptorProto_TypeToJSON( + object: FieldDescriptorProto_Type +): string { + switch (object) { + case FieldDescriptorProto_Type.TYPE_DOUBLE: + return "TYPE_DOUBLE"; + case FieldDescriptorProto_Type.TYPE_FLOAT: + return "TYPE_FLOAT"; + case FieldDescriptorProto_Type.TYPE_INT64: + return "TYPE_INT64"; + case FieldDescriptorProto_Type.TYPE_UINT64: + return "TYPE_UINT64"; + case FieldDescriptorProto_Type.TYPE_INT32: + return "TYPE_INT32"; + case FieldDescriptorProto_Type.TYPE_FIXED64: + return "TYPE_FIXED64"; + case FieldDescriptorProto_Type.TYPE_FIXED32: + return "TYPE_FIXED32"; + case FieldDescriptorProto_Type.TYPE_BOOL: + return "TYPE_BOOL"; + case FieldDescriptorProto_Type.TYPE_STRING: + return "TYPE_STRING"; + case FieldDescriptorProto_Type.TYPE_GROUP: + return "TYPE_GROUP"; + case FieldDescriptorProto_Type.TYPE_MESSAGE: + return "TYPE_MESSAGE"; + case FieldDescriptorProto_Type.TYPE_BYTES: + return "TYPE_BYTES"; + case FieldDescriptorProto_Type.TYPE_UINT32: + return "TYPE_UINT32"; + case FieldDescriptorProto_Type.TYPE_ENUM: + return "TYPE_ENUM"; + case FieldDescriptorProto_Type.TYPE_SFIXED32: + return "TYPE_SFIXED32"; + case FieldDescriptorProto_Type.TYPE_SFIXED64: + return "TYPE_SFIXED64"; + case FieldDescriptorProto_Type.TYPE_SINT32: + return "TYPE_SINT32"; + case FieldDescriptorProto_Type.TYPE_SINT64: + return "TYPE_SINT64"; + default: + return "UNKNOWN"; + } +} + +export enum FieldDescriptorProto_Label { + /** LABEL_OPTIONAL - 0 is reserved for errors */ + LABEL_OPTIONAL = 1, + LABEL_REQUIRED = 2, + LABEL_REPEATED = 3, + UNRECOGNIZED = -1, +} + +export function fieldDescriptorProto_LabelFromJSON( + object: any +): FieldDescriptorProto_Label { + switch (object) { + case 1: + case "LABEL_OPTIONAL": + return FieldDescriptorProto_Label.LABEL_OPTIONAL; + case 2: + case "LABEL_REQUIRED": + return FieldDescriptorProto_Label.LABEL_REQUIRED; + case 3: + case "LABEL_REPEATED": + return FieldDescriptorProto_Label.LABEL_REPEATED; + case -1: + case "UNRECOGNIZED": + default: + return FieldDescriptorProto_Label.UNRECOGNIZED; + } +} + +export function fieldDescriptorProto_LabelToJSON( + object: FieldDescriptorProto_Label +): string { + switch (object) { + case FieldDescriptorProto_Label.LABEL_OPTIONAL: + return "LABEL_OPTIONAL"; + case FieldDescriptorProto_Label.LABEL_REQUIRED: + return "LABEL_REQUIRED"; + case FieldDescriptorProto_Label.LABEL_REPEATED: + return "LABEL_REPEATED"; + default: + return "UNKNOWN"; + } +} + +/** Describes a oneof. */ +export interface OneofDescriptorProto { + name: string; + options: OneofOptions | undefined; +} + +/** Describes an enum type. */ +export interface EnumDescriptorProto { + name: string; + value: EnumValueDescriptorProto[]; + options: EnumOptions | undefined; + /** + * Range of reserved numeric values. Reserved numeric values may not be used + * by enum values in the same enum declaration. Reserved ranges may not + * overlap. + */ + reservedRange: EnumDescriptorProto_EnumReservedRange[]; + /** + * Reserved enum value names, which may not be reused. A given name may only + * be reserved once. + */ + reservedName: string[]; +} + +/** + * Range of reserved numeric values. Reserved values may not be used by + * entries in the same enum. Reserved ranges may not overlap. + * + * Note that this is distinct from DescriptorProto.ReservedRange in that it + * is inclusive such that it can appropriately represent the entire int32 + * domain. + */ +export interface EnumDescriptorProto_EnumReservedRange { + /** Inclusive. */ + start: number; + /** Inclusive. */ + end: number; +} + +/** Describes a value within an enum. */ +export interface EnumValueDescriptorProto { + name: string; + number: number; + options: EnumValueOptions | undefined; +} + +/** Describes a service. */ +export interface ServiceDescriptorProto { + name: string; + method: MethodDescriptorProto[]; + options: ServiceOptions | undefined; +} + +/** Describes a method of a service. */ +export interface MethodDescriptorProto { + name: string; + /** + * Input and output type names. These are resolved in the same way as + * FieldDescriptorProto.type_name, but must refer to a message type. + */ + inputType: string; + outputType: string; + options: MethodOptions | undefined; + /** Identifies if client streams multiple client messages */ + clientStreaming: boolean; + /** Identifies if server streams multiple server messages */ + serverStreaming: boolean; +} + +export interface FileOptions { + /** + * Sets the Java package where classes generated from this .proto will be + * placed. By default, the proto package is used, but this is often + * inappropriate because proto packages do not normally start with backwards + * domain names. + */ + javaPackage: string; + /** + * Controls the name of the wrapper Java class generated for the .proto file. + * That class will always contain the .proto file's getDescriptor() method as + * well as any top-level extensions defined in the .proto file. + * If java_multiple_files is disabled, then all the other classes from the + * .proto file will be nested inside the single wrapper outer class. + */ + javaOuterClassname: string; + /** + * If enabled, then the Java code generator will generate a separate .java + * file for each top-level message, enum, and service defined in the .proto + * file. Thus, these types will *not* be nested inside the wrapper class + * named by java_outer_classname. However, the wrapper class will still be + * generated to contain the file's getDescriptor() method as well as any + * top-level extensions defined in the file. + */ + javaMultipleFiles: boolean; + /** + * This option does nothing. + * + * @deprecated + */ + javaGenerateEqualsAndHash: boolean; + /** + * If set true, then the Java2 code generator will generate code that + * throws an exception whenever an attempt is made to assign a non-UTF-8 + * byte sequence to a string field. + * Message reflection will do the same. + * However, an extension field still accepts non-UTF-8 byte sequences. + * This option has no effect on when used with the lite runtime. + */ + javaStringCheckUtf8: boolean; + optimizeFor: FileOptions_OptimizeMode; + /** + * Sets the Go package where structs generated from this .proto will be + * placed. If omitted, the Go package will be derived from the following: + * - The basename of the package import path, if provided. + * - Otherwise, the package statement in the .proto file, if present. + * - Otherwise, the basename of the .proto file, without extension. + */ + goPackage: string; + /** + * Should generic services be generated in each language? "Generic" services + * are not specific to any particular RPC system. They are generated by the + * main code generators in each language (without additional plugins). + * Generic services were the only kind of service generation supported by + * early versions of google.protobuf. + * + * Generic services are now considered deprecated in favor of using plugins + * that generate code specific to your particular RPC system. Therefore, + * these default to false. Old code which depends on generic services should + * explicitly set them to true. + */ + ccGenericServices: boolean; + javaGenericServices: boolean; + pyGenericServices: boolean; + phpGenericServices: boolean; + /** + * Is this file deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for everything in the file, or it will be completely ignored; in the very + * least, this is a formalization for deprecating files. + */ + deprecated: boolean; + /** + * Enables the use of arenas for the proto messages in this file. This applies + * only to generated classes for C++. + */ + ccEnableArenas: boolean; + /** + * Sets the objective c class prefix which is prepended to all objective c + * generated classes from this .proto. There is no default. + */ + objcClassPrefix: string; + /** Namespace for generated classes; defaults to the package. */ + csharpNamespace: string; + /** + * By default Swift generators will take the proto package and CamelCase it + * replacing '.' with underscore and use that to prefix the types/symbols + * defined. When this options is provided, they will use this value instead + * to prefix the types/symbols defined. + */ + swiftPrefix: string; + /** + * Sets the php class prefix which is prepended to all php generated classes + * from this .proto. Default is empty. + */ + phpClassPrefix: string; + /** + * Use this option to change the namespace of php generated classes. Default + * is empty. When this option is empty, the package name will be used for + * determining the namespace. + */ + phpNamespace: string; + /** + * Use this option to change the namespace of php generated metadata classes. + * Default is empty. When this option is empty, the proto file name will be + * used for determining the namespace. + */ + phpMetadataNamespace: string; + /** + * Use this option to change the package of ruby generated classes. Default + * is empty. When this option is not set, the package name will be used for + * determining the ruby package. + */ + rubyPackage: string; + /** + * The parser stores options it doesn't recognize here. + * See the documentation for the "Options" section above. + */ + uninterpretedOption: UninterpretedOption[]; +} + +/** Generated classes can be optimized for speed or code size. */ +export enum FileOptions_OptimizeMode { + /** SPEED - Generate complete code for parsing, serialization, */ + SPEED = 1, + /** CODE_SIZE - etc. */ + CODE_SIZE = 2, + /** LITE_RUNTIME - Generate code using MessageLite and the lite runtime. */ + LITE_RUNTIME = 3, + UNRECOGNIZED = -1, +} + +export function fileOptions_OptimizeModeFromJSON( + object: any +): FileOptions_OptimizeMode { + switch (object) { + case 1: + case "SPEED": + return FileOptions_OptimizeMode.SPEED; + case 2: + case "CODE_SIZE": + return FileOptions_OptimizeMode.CODE_SIZE; + case 3: + case "LITE_RUNTIME": + return FileOptions_OptimizeMode.LITE_RUNTIME; + case -1: + case "UNRECOGNIZED": + default: + return FileOptions_OptimizeMode.UNRECOGNIZED; + } +} + +export function fileOptions_OptimizeModeToJSON( + object: FileOptions_OptimizeMode +): string { + switch (object) { + case FileOptions_OptimizeMode.SPEED: + return "SPEED"; + case FileOptions_OptimizeMode.CODE_SIZE: + return "CODE_SIZE"; + case FileOptions_OptimizeMode.LITE_RUNTIME: + return "LITE_RUNTIME"; + default: + return "UNKNOWN"; + } +} + +export interface MessageOptions { + /** + * Set true to use the old proto1 MessageSet wire format for extensions. + * This is provided for backwards-compatibility with the MessageSet wire + * format. You should not use this for any other reason: It's less + * efficient, has fewer features, and is more complicated. + * + * The message must be defined exactly as follows: + * message Foo { + * option message_set_wire_format = true; + * extensions 4 to max; + * } + * Note that the message cannot have any defined fields; MessageSets only + * have extensions. + * + * All extensions of your type must be singular messages; e.g. they cannot + * be int32s, enums, or repeated messages. + * + * Because this is an option, the above two restrictions are not enforced by + * the protocol compiler. + */ + messageSetWireFormat: boolean; + /** + * Disables the generation of the standard "descriptor()" accessor, which can + * conflict with a field of the same name. This is meant to make migration + * from proto1 easier; new code should avoid fields named "descriptor". + */ + noStandardDescriptorAccessor: boolean; + /** + * Is this message deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the message, or it will be completely ignored; in the very least, + * this is a formalization for deprecating messages. + */ + deprecated: boolean; + /** + * Whether the message is an automatically generated map entry type for the + * maps field. + * + * For maps fields: + * map map_field = 1; + * The parsed descriptor looks like: + * message MapFieldEntry { + * option map_entry = true; + * optional KeyType key = 1; + * optional ValueType value = 2; + * } + * repeated MapFieldEntry map_field = 1; + * + * Implementations may choose not to generate the map_entry=true message, but + * use a native map in the target language to hold the keys and values. + * The reflection APIs in such implementations still need to work as + * if the field is a repeated message field. + * + * NOTE: Do not set the option in .proto files. Always use the maps syntax + * instead. The option should only be implicitly set by the proto compiler + * parser. + */ + mapEntry: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface FieldOptions { + /** + * The ctype option instructs the C++ code generator to use a different + * representation of the field than it normally would. See the specific + * options below. This option is not yet implemented in the open source + * release -- sorry, we'll try to include it in a future version! + */ + ctype: FieldOptions_CType; + /** + * The packed option can be enabled for repeated primitive fields to enable + * a more efficient representation on the wire. Rather than repeatedly + * writing the tag and type for each element, the entire array is encoded as + * a single length-delimited blob. In proto3, only explicit setting it to + * false will avoid using packed encoding. + */ + packed: boolean; + /** + * The jstype option determines the JavaScript type used for values of the + * field. The option is permitted only for 64 bit integral and fixed types + * (int64, uint64, sint64, fixed64, sfixed64). A field with jstype JS_STRING + * is represented as JavaScript string, which avoids loss of precision that + * can happen when a large value is converted to a floating point JavaScript. + * Specifying JS_NUMBER for the jstype causes the generated JavaScript code to + * use the JavaScript "number" type. The behavior of the default option + * JS_NORMAL is implementation dependent. + * + * This option is an enum to permit additional types to be added, e.g. + * goog.math.Integer. + */ + jstype: FieldOptions_JSType; + /** + * Should this field be parsed lazily? Lazy applies only to message-type + * fields. It means that when the outer message is initially parsed, the + * inner message's contents will not be parsed but instead stored in encoded + * form. The inner message will actually be parsed when it is first accessed. + * + * This is only a hint. Implementations are free to choose whether to use + * eager or lazy parsing regardless of the value of this option. However, + * setting this option true suggests that the protocol author believes that + * using lazy parsing on this field is worth the additional bookkeeping + * overhead typically needed to implement it. + * + * This option does not affect the public interface of any generated code; + * all method signatures remain the same. Furthermore, thread-safety of the + * interface is not affected by this option; const methods remain safe to + * call from multiple threads concurrently, while non-const methods continue + * to require exclusive access. + * + * + * Note that implementations may choose not to check required fields within + * a lazy sub-message. That is, calling IsInitialized() on the outer message + * may return true even if the inner message has missing required fields. + * This is necessary because otherwise the inner message would have to be + * parsed in order to perform the check, defeating the purpose of lazy + * parsing. An implementation which chooses not to check required fields + * must be consistent about it. That is, for any particular sub-message, the + * implementation must either *always* check its required fields, or *never* + * check its required fields, regardless of whether or not the message has + * been parsed. + */ + lazy: boolean; + /** + * Is this field deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for accessors, or it will be completely ignored; in the very least, this + * is a formalization for deprecating fields. + */ + deprecated: boolean; + /** For Google-internal migration only. Do not use. */ + weak: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export enum FieldOptions_CType { + /** STRING - Default mode. */ + STRING = 0, + CORD = 1, + STRING_PIECE = 2, + UNRECOGNIZED = -1, +} + +export function fieldOptions_CTypeFromJSON(object: any): FieldOptions_CType { + switch (object) { + case 0: + case "STRING": + return FieldOptions_CType.STRING; + case 1: + case "CORD": + return FieldOptions_CType.CORD; + case 2: + case "STRING_PIECE": + return FieldOptions_CType.STRING_PIECE; + case -1: + case "UNRECOGNIZED": + default: + return FieldOptions_CType.UNRECOGNIZED; + } +} + +export function fieldOptions_CTypeToJSON(object: FieldOptions_CType): string { + switch (object) { + case FieldOptions_CType.STRING: + return "STRING"; + case FieldOptions_CType.CORD: + return "CORD"; + case FieldOptions_CType.STRING_PIECE: + return "STRING_PIECE"; + default: + return "UNKNOWN"; + } +} + +export enum FieldOptions_JSType { + /** JS_NORMAL - Use the default type. */ + JS_NORMAL = 0, + /** JS_STRING - Use JavaScript strings. */ + JS_STRING = 1, + /** JS_NUMBER - Use JavaScript numbers. */ + JS_NUMBER = 2, + UNRECOGNIZED = -1, +} + +export function fieldOptions_JSTypeFromJSON(object: any): FieldOptions_JSType { + switch (object) { + case 0: + case "JS_NORMAL": + return FieldOptions_JSType.JS_NORMAL; + case 1: + case "JS_STRING": + return FieldOptions_JSType.JS_STRING; + case 2: + case "JS_NUMBER": + return FieldOptions_JSType.JS_NUMBER; + case -1: + case "UNRECOGNIZED": + default: + return FieldOptions_JSType.UNRECOGNIZED; + } +} + +export function fieldOptions_JSTypeToJSON(object: FieldOptions_JSType): string { + switch (object) { + case FieldOptions_JSType.JS_NORMAL: + return "JS_NORMAL"; + case FieldOptions_JSType.JS_STRING: + return "JS_STRING"; + case FieldOptions_JSType.JS_NUMBER: + return "JS_NUMBER"; + default: + return "UNKNOWN"; + } +} + +export interface OneofOptions { + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface EnumOptions { + /** + * Set this option to true to allow mapping different tag names to the same + * value. + */ + allowAlias: boolean; + /** + * Is this enum deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the enum, or it will be completely ignored; in the very least, this + * is a formalization for deprecating enums. + */ + deprecated: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface EnumValueOptions { + /** + * Is this enum value deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the enum value, or it will be completely ignored; in the very least, + * this is a formalization for deprecating enum values. + */ + deprecated: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface ServiceOptions { + /** + * Is this service deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the service, or it will be completely ignored; in the very least, + * this is a formalization for deprecating services. + */ + deprecated: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface MethodOptions { + /** + * Is this method deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the method, or it will be completely ignored; in the very least, + * this is a formalization for deprecating methods. + */ + deprecated: boolean; + idempotencyLevel: MethodOptions_IdempotencyLevel; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +/** + * Is this method side-effect-free (or safe in HTTP parlance), or idempotent, + * or neither? HTTP based RPC implementation may choose GET verb for safe + * methods, and PUT verb for idempotent methods instead of the default POST. + */ +export enum MethodOptions_IdempotencyLevel { + IDEMPOTENCY_UNKNOWN = 0, + /** NO_SIDE_EFFECTS - implies idempotent */ + NO_SIDE_EFFECTS = 1, + /** IDEMPOTENT - idempotent, but may have side effects */ + IDEMPOTENT = 2, + UNRECOGNIZED = -1, +} + +export function methodOptions_IdempotencyLevelFromJSON( + object: any +): MethodOptions_IdempotencyLevel { + switch (object) { + case 0: + case "IDEMPOTENCY_UNKNOWN": + return MethodOptions_IdempotencyLevel.IDEMPOTENCY_UNKNOWN; + case 1: + case "NO_SIDE_EFFECTS": + return MethodOptions_IdempotencyLevel.NO_SIDE_EFFECTS; + case 2: + case "IDEMPOTENT": + return MethodOptions_IdempotencyLevel.IDEMPOTENT; + case -1: + case "UNRECOGNIZED": + default: + return MethodOptions_IdempotencyLevel.UNRECOGNIZED; + } +} + +export function methodOptions_IdempotencyLevelToJSON( + object: MethodOptions_IdempotencyLevel +): string { + switch (object) { + case MethodOptions_IdempotencyLevel.IDEMPOTENCY_UNKNOWN: + return "IDEMPOTENCY_UNKNOWN"; + case MethodOptions_IdempotencyLevel.NO_SIDE_EFFECTS: + return "NO_SIDE_EFFECTS"; + case MethodOptions_IdempotencyLevel.IDEMPOTENT: + return "IDEMPOTENT"; + default: + return "UNKNOWN"; + } +} + +/** + * A message representing a option the parser does not recognize. This only + * appears in options protos created by the compiler::Parser class. + * DescriptorPool resolves these when building Descriptor objects. Therefore, + * options protos in descriptor objects (e.g. returned by Descriptor::options(), + * or produced by Descriptor::CopyTo()) will never have UninterpretedOptions + * in them. + */ +export interface UninterpretedOption { + name: UninterpretedOption_NamePart[]; + /** + * The value of the uninterpreted option, in whatever type the tokenizer + * identified it as during parsing. Exactly one of these should be set. + */ + identifierValue: string; + positiveIntValue: number; + negativeIntValue: number; + doubleValue: number; + stringValue: Uint8Array; + aggregateValue: string; +} + +/** + * The name of the uninterpreted option. Each string represents a segment in + * a dot-separated name. is_extension is true iff a segment represents an + * extension (denoted with parentheses in options specs in .proto files). + * E.g.,{ ["foo", false], ["bar.baz", true], ["qux", false] } represents + * "foo.(bar.baz).qux". + */ +export interface UninterpretedOption_NamePart { + namePart: string; + isExtension: boolean; +} + +/** + * Encapsulates information about the original source file from which a + * FileDescriptorProto was generated. + */ +export interface SourceCodeInfo { + /** + * A Location identifies a piece of source code in a .proto file which + * corresponds to a particular definition. This information is intended + * to be useful to IDEs, code indexers, documentation generators, and similar + * tools. + * + * For example, say we have a file like: + * message Foo { + * optional string foo = 1; + * } + * Let's look at just the field definition: + * optional string foo = 1; + * ^ ^^ ^^ ^ ^^^ + * a bc de f ghi + * We have the following locations: + * span path represents + * [a,i) [ 4, 0, 2, 0 ] The whole field definition. + * [a,b) [ 4, 0, 2, 0, 4 ] The label (optional). + * [c,d) [ 4, 0, 2, 0, 5 ] The type (string). + * [e,f) [ 4, 0, 2, 0, 1 ] The name (foo). + * [g,h) [ 4, 0, 2, 0, 3 ] The number (1). + * + * Notes: + * - A location may refer to a repeated field itself (i.e. not to any + * particular index within it). This is used whenever a set of elements are + * logically enclosed in a single code segment. For example, an entire + * extend block (possibly containing multiple extension definitions) will + * have an outer location whose path refers to the "extensions" repeated + * field without an index. + * - Multiple locations may have the same path. This happens when a single + * logical declaration is spread out across multiple places. The most + * obvious example is the "extend" block again -- there may be multiple + * extend blocks in the same scope, each of which will have the same path. + * - A location's span is not always a subset of its parent's span. For + * example, the "extendee" of an extension declaration appears at the + * beginning of the "extend" block and is shared by all extensions within + * the block. + * - Just because a location's span is a subset of some other location's span + * does not mean that it is a descendant. For example, a "group" defines + * both a type and a field in a single declaration. Thus, the locations + * corresponding to the type and field and their components will overlap. + * - Code which tries to interpret locations should probably be designed to + * ignore those that it doesn't understand, as more types of locations could + * be recorded in the future. + */ + location: SourceCodeInfo_Location[]; +} + +export interface SourceCodeInfo_Location { + /** + * Identifies which part of the FileDescriptorProto was defined at this + * location. + * + * Each element is a field number or an index. They form a path from + * the root FileDescriptorProto to the place where the definition. For + * example, this path: + * [ 4, 3, 2, 7, 1 ] + * refers to: + * file.message_type(3) // 4, 3 + * .field(7) // 2, 7 + * .name() // 1 + * This is because FileDescriptorProto.message_type has field number 4: + * repeated DescriptorProto message_type = 4; + * and DescriptorProto.field has field number 2: + * repeated FieldDescriptorProto field = 2; + * and FieldDescriptorProto.name has field number 1: + * optional string name = 1; + * + * Thus, the above path gives the location of a field name. If we removed + * the last element: + * [ 4, 3, 2, 7 ] + * this path refers to the whole field declaration (from the beginning + * of the label to the terminating semicolon). + */ + path: number[]; + /** + * Always has exactly three or four elements: start line, start column, + * end line (optional, otherwise assumed same as start line), end column. + * These are packed into a single field for efficiency. Note that line + * and column numbers are zero-based -- typically you will want to add + * 1 to each before displaying to a user. + */ + span: number[]; + /** + * If this SourceCodeInfo represents a complete declaration, these are any + * comments appearing before and after the declaration which appear to be + * attached to the declaration. + * + * A series of line comments appearing on consecutive lines, with no other + * tokens appearing on those lines, will be treated as a single comment. + * + * leading_detached_comments will keep paragraphs of comments that appear + * before (but not connected to) the current element. Each paragraph, + * separated by empty lines, will be one comment element in the repeated + * field. + * + * Only the comment content is provided; comment markers (e.g. //) are + * stripped out. For block comments, leading whitespace and an asterisk + * will be stripped from the beginning of each line other than the first. + * Newlines are included in the output. + * + * Examples: + * + * optional int32 foo = 1; // Comment attached to foo. + * // Comment attached to bar. + * optional int32 bar = 2; + * + * optional string baz = 3; + * // Comment attached to baz. + * // Another line attached to baz. + * + * // Comment attached to qux. + * // + * // Another line attached to qux. + * optional double qux = 4; + * + * // Detached comment for corge. This is not leading or trailing comments + * // to qux or corge because there are blank lines separating it from + * // both. + * + * // Detached comment for corge paragraph 2. + * + * optional string corge = 5; + * /* Block comment attached + * * to corge. Leading asterisks + * * will be removed. * / + * /* Block comment attached to + * * grault. * / + * optional int32 grault = 6; + * + * // ignored detached comments. + */ + leadingComments: string; + trailingComments: string; + leadingDetachedComments: string[]; +} + +/** + * Describes the relationship between generated code and its original source + * file. A GeneratedCodeInfo message is associated with only one generated + * source file, but may contain references to different source .proto files. + */ +export interface GeneratedCodeInfo { + /** + * An Annotation connects some span of text in generated code to an element + * of its generating .proto file. + */ + annotation: GeneratedCodeInfo_Annotation[]; +} + +export interface GeneratedCodeInfo_Annotation { + /** + * Identifies the element in the original source .proto file. This field + * is formatted the same as SourceCodeInfo.Location.path. + */ + path: number[]; + /** Identifies the filesystem path to the original source .proto. */ + sourceFile: string; + /** + * Identifies the starting offset in bytes in the generated code + * that relates to the identified object. + */ + begin: number; + /** + * Identifies the ending offset in bytes in the generated code that + * relates to the identified offset. The end offset should be one past + * the last relevant byte (so the length of the text = end - begin). + */ + end: number; +} + +const baseFileDescriptorSet: object = {}; + +export const FileDescriptorSet = { + encode(message: FileDescriptorSet, writer: Writer = Writer.create()): Writer { + for (const v of message.file) { + FileDescriptorProto.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FileDescriptorSet { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFileDescriptorSet } as FileDescriptorSet; + message.file = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.file.push( + FileDescriptorProto.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FileDescriptorSet { + const message = { ...baseFileDescriptorSet } as FileDescriptorSet; + message.file = []; + if (object.file !== undefined && object.file !== null) { + for (const e of object.file) { + message.file.push(FileDescriptorProto.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: FileDescriptorSet): unknown { + const obj: any = {}; + if (message.file) { + obj.file = message.file.map((e) => + e ? FileDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.file = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): FileDescriptorSet { + const message = { ...baseFileDescriptorSet } as FileDescriptorSet; + message.file = []; + if (object.file !== undefined && object.file !== null) { + for (const e of object.file) { + message.file.push(FileDescriptorProto.fromPartial(e)); + } + } + return message; + }, +}; + +const baseFileDescriptorProto: object = { + name: "", + package: "", + dependency: "", + publicDependency: 0, + weakDependency: 0, + syntax: "", +}; + +export const FileDescriptorProto = { + encode( + message: FileDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.package !== "") { + writer.uint32(18).string(message.package); + } + for (const v of message.dependency) { + writer.uint32(26).string(v!); + } + writer.uint32(82).fork(); + for (const v of message.publicDependency) { + writer.int32(v); + } + writer.ldelim(); + writer.uint32(90).fork(); + for (const v of message.weakDependency) { + writer.int32(v); + } + writer.ldelim(); + for (const v of message.messageType) { + DescriptorProto.encode(v!, writer.uint32(34).fork()).ldelim(); + } + for (const v of message.enumType) { + EnumDescriptorProto.encode(v!, writer.uint32(42).fork()).ldelim(); + } + for (const v of message.service) { + ServiceDescriptorProto.encode(v!, writer.uint32(50).fork()).ldelim(); + } + for (const v of message.extension) { + FieldDescriptorProto.encode(v!, writer.uint32(58).fork()).ldelim(); + } + if (message.options !== undefined) { + FileOptions.encode(message.options, writer.uint32(66).fork()).ldelim(); + } + if (message.sourceCodeInfo !== undefined) { + SourceCodeInfo.encode( + message.sourceCodeInfo, + writer.uint32(74).fork() + ).ldelim(); + } + if (message.syntax !== "") { + writer.uint32(98).string(message.syntax); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FileDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFileDescriptorProto } as FileDescriptorProto; + message.dependency = []; + message.publicDependency = []; + message.weakDependency = []; + message.messageType = []; + message.enumType = []; + message.service = []; + message.extension = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.package = reader.string(); + break; + case 3: + message.dependency.push(reader.string()); + break; + case 10: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.publicDependency.push(reader.int32()); + } + } else { + message.publicDependency.push(reader.int32()); + } + break; + case 11: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.weakDependency.push(reader.int32()); + } + } else { + message.weakDependency.push(reader.int32()); + } + break; + case 4: + message.messageType.push( + DescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 5: + message.enumType.push( + EnumDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 6: + message.service.push( + ServiceDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 7: + message.extension.push( + FieldDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 8: + message.options = FileOptions.decode(reader, reader.uint32()); + break; + case 9: + message.sourceCodeInfo = SourceCodeInfo.decode( + reader, + reader.uint32() + ); + break; + case 12: + message.syntax = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FileDescriptorProto { + const message = { ...baseFileDescriptorProto } as FileDescriptorProto; + message.dependency = []; + message.publicDependency = []; + message.weakDependency = []; + message.messageType = []; + message.enumType = []; + message.service = []; + message.extension = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.package !== undefined && object.package !== null) { + message.package = String(object.package); + } else { + message.package = ""; + } + if (object.dependency !== undefined && object.dependency !== null) { + for (const e of object.dependency) { + message.dependency.push(String(e)); + } + } + if ( + object.publicDependency !== undefined && + object.publicDependency !== null + ) { + for (const e of object.publicDependency) { + message.publicDependency.push(Number(e)); + } + } + if (object.weakDependency !== undefined && object.weakDependency !== null) { + for (const e of object.weakDependency) { + message.weakDependency.push(Number(e)); + } + } + if (object.messageType !== undefined && object.messageType !== null) { + for (const e of object.messageType) { + message.messageType.push(DescriptorProto.fromJSON(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromJSON(e)); + } + } + if (object.service !== undefined && object.service !== null) { + for (const e of object.service) { + message.service.push(ServiceDescriptorProto.fromJSON(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = FileOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.sourceCodeInfo !== undefined && object.sourceCodeInfo !== null) { + message.sourceCodeInfo = SourceCodeInfo.fromJSON(object.sourceCodeInfo); + } else { + message.sourceCodeInfo = undefined; + } + if (object.syntax !== undefined && object.syntax !== null) { + message.syntax = String(object.syntax); + } else { + message.syntax = ""; + } + return message; + }, + + toJSON(message: FileDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.package !== undefined && (obj.package = message.package); + if (message.dependency) { + obj.dependency = message.dependency.map((e) => e); + } else { + obj.dependency = []; + } + if (message.publicDependency) { + obj.publicDependency = message.publicDependency.map((e) => e); + } else { + obj.publicDependency = []; + } + if (message.weakDependency) { + obj.weakDependency = message.weakDependency.map((e) => e); + } else { + obj.weakDependency = []; + } + if (message.messageType) { + obj.messageType = message.messageType.map((e) => + e ? DescriptorProto.toJSON(e) : undefined + ); + } else { + obj.messageType = []; + } + if (message.enumType) { + obj.enumType = message.enumType.map((e) => + e ? EnumDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.enumType = []; + } + if (message.service) { + obj.service = message.service.map((e) => + e ? ServiceDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.service = []; + } + if (message.extension) { + obj.extension = message.extension.map((e) => + e ? FieldDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.extension = []; + } + message.options !== undefined && + (obj.options = message.options + ? FileOptions.toJSON(message.options) + : undefined); + message.sourceCodeInfo !== undefined && + (obj.sourceCodeInfo = message.sourceCodeInfo + ? SourceCodeInfo.toJSON(message.sourceCodeInfo) + : undefined); + message.syntax !== undefined && (obj.syntax = message.syntax); + return obj; + }, + + fromPartial(object: DeepPartial): FileDescriptorProto { + const message = { ...baseFileDescriptorProto } as FileDescriptorProto; + message.dependency = []; + message.publicDependency = []; + message.weakDependency = []; + message.messageType = []; + message.enumType = []; + message.service = []; + message.extension = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.package !== undefined && object.package !== null) { + message.package = object.package; + } else { + message.package = ""; + } + if (object.dependency !== undefined && object.dependency !== null) { + for (const e of object.dependency) { + message.dependency.push(e); + } + } + if ( + object.publicDependency !== undefined && + object.publicDependency !== null + ) { + for (const e of object.publicDependency) { + message.publicDependency.push(e); + } + } + if (object.weakDependency !== undefined && object.weakDependency !== null) { + for (const e of object.weakDependency) { + message.weakDependency.push(e); + } + } + if (object.messageType !== undefined && object.messageType !== null) { + for (const e of object.messageType) { + message.messageType.push(DescriptorProto.fromPartial(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromPartial(e)); + } + } + if (object.service !== undefined && object.service !== null) { + for (const e of object.service) { + message.service.push(ServiceDescriptorProto.fromPartial(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = FileOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.sourceCodeInfo !== undefined && object.sourceCodeInfo !== null) { + message.sourceCodeInfo = SourceCodeInfo.fromPartial( + object.sourceCodeInfo + ); + } else { + message.sourceCodeInfo = undefined; + } + if (object.syntax !== undefined && object.syntax !== null) { + message.syntax = object.syntax; + } else { + message.syntax = ""; + } + return message; + }, +}; + +const baseDescriptorProto: object = { name: "", reservedName: "" }; + +export const DescriptorProto = { + encode(message: DescriptorProto, writer: Writer = Writer.create()): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + for (const v of message.field) { + FieldDescriptorProto.encode(v!, writer.uint32(18).fork()).ldelim(); + } + for (const v of message.extension) { + FieldDescriptorProto.encode(v!, writer.uint32(50).fork()).ldelim(); + } + for (const v of message.nestedType) { + DescriptorProto.encode(v!, writer.uint32(26).fork()).ldelim(); + } + for (const v of message.enumType) { + EnumDescriptorProto.encode(v!, writer.uint32(34).fork()).ldelim(); + } + for (const v of message.extensionRange) { + DescriptorProto_ExtensionRange.encode( + v!, + writer.uint32(42).fork() + ).ldelim(); + } + for (const v of message.oneofDecl) { + OneofDescriptorProto.encode(v!, writer.uint32(66).fork()).ldelim(); + } + if (message.options !== undefined) { + MessageOptions.encode(message.options, writer.uint32(58).fork()).ldelim(); + } + for (const v of message.reservedRange) { + DescriptorProto_ReservedRange.encode( + v!, + writer.uint32(74).fork() + ).ldelim(); + } + for (const v of message.reservedName) { + writer.uint32(82).string(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): DescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseDescriptorProto } as DescriptorProto; + message.field = []; + message.extension = []; + message.nestedType = []; + message.enumType = []; + message.extensionRange = []; + message.oneofDecl = []; + message.reservedRange = []; + message.reservedName = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.field.push( + FieldDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 6: + message.extension.push( + FieldDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 3: + message.nestedType.push( + DescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 4: + message.enumType.push( + EnumDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 5: + message.extensionRange.push( + DescriptorProto_ExtensionRange.decode(reader, reader.uint32()) + ); + break; + case 8: + message.oneofDecl.push( + OneofDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 7: + message.options = MessageOptions.decode(reader, reader.uint32()); + break; + case 9: + message.reservedRange.push( + DescriptorProto_ReservedRange.decode(reader, reader.uint32()) + ); + break; + case 10: + message.reservedName.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DescriptorProto { + const message = { ...baseDescriptorProto } as DescriptorProto; + message.field = []; + message.extension = []; + message.nestedType = []; + message.enumType = []; + message.extensionRange = []; + message.oneofDecl = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.field !== undefined && object.field !== null) { + for (const e of object.field) { + message.field.push(FieldDescriptorProto.fromJSON(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromJSON(e)); + } + } + if (object.nestedType !== undefined && object.nestedType !== null) { + for (const e of object.nestedType) { + message.nestedType.push(DescriptorProto.fromJSON(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromJSON(e)); + } + } + if (object.extensionRange !== undefined && object.extensionRange !== null) { + for (const e of object.extensionRange) { + message.extensionRange.push(DescriptorProto_ExtensionRange.fromJSON(e)); + } + } + if (object.oneofDecl !== undefined && object.oneofDecl !== null) { + for (const e of object.oneofDecl) { + message.oneofDecl.push(OneofDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = MessageOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push(DescriptorProto_ReservedRange.fromJSON(e)); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(String(e)); + } + } + return message; + }, + + toJSON(message: DescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + if (message.field) { + obj.field = message.field.map((e) => + e ? FieldDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.field = []; + } + if (message.extension) { + obj.extension = message.extension.map((e) => + e ? FieldDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.extension = []; + } + if (message.nestedType) { + obj.nestedType = message.nestedType.map((e) => + e ? DescriptorProto.toJSON(e) : undefined + ); + } else { + obj.nestedType = []; + } + if (message.enumType) { + obj.enumType = message.enumType.map((e) => + e ? EnumDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.enumType = []; + } + if (message.extensionRange) { + obj.extensionRange = message.extensionRange.map((e) => + e ? DescriptorProto_ExtensionRange.toJSON(e) : undefined + ); + } else { + obj.extensionRange = []; + } + if (message.oneofDecl) { + obj.oneofDecl = message.oneofDecl.map((e) => + e ? OneofDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.oneofDecl = []; + } + message.options !== undefined && + (obj.options = message.options + ? MessageOptions.toJSON(message.options) + : undefined); + if (message.reservedRange) { + obj.reservedRange = message.reservedRange.map((e) => + e ? DescriptorProto_ReservedRange.toJSON(e) : undefined + ); + } else { + obj.reservedRange = []; + } + if (message.reservedName) { + obj.reservedName = message.reservedName.map((e) => e); + } else { + obj.reservedName = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): DescriptorProto { + const message = { ...baseDescriptorProto } as DescriptorProto; + message.field = []; + message.extension = []; + message.nestedType = []; + message.enumType = []; + message.extensionRange = []; + message.oneofDecl = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.field !== undefined && object.field !== null) { + for (const e of object.field) { + message.field.push(FieldDescriptorProto.fromPartial(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromPartial(e)); + } + } + if (object.nestedType !== undefined && object.nestedType !== null) { + for (const e of object.nestedType) { + message.nestedType.push(DescriptorProto.fromPartial(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromPartial(e)); + } + } + if (object.extensionRange !== undefined && object.extensionRange !== null) { + for (const e of object.extensionRange) { + message.extensionRange.push( + DescriptorProto_ExtensionRange.fromPartial(e) + ); + } + } + if (object.oneofDecl !== undefined && object.oneofDecl !== null) { + for (const e of object.oneofDecl) { + message.oneofDecl.push(OneofDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = MessageOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push( + DescriptorProto_ReservedRange.fromPartial(e) + ); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(e); + } + } + return message; + }, +}; + +const baseDescriptorProto_ExtensionRange: object = { start: 0, end: 0 }; + +export const DescriptorProto_ExtensionRange = { + encode( + message: DescriptorProto_ExtensionRange, + writer: Writer = Writer.create() + ): Writer { + if (message.start !== 0) { + writer.uint32(8).int32(message.start); + } + if (message.end !== 0) { + writer.uint32(16).int32(message.end); + } + if (message.options !== undefined) { + ExtensionRangeOptions.encode( + message.options, + writer.uint32(26).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): DescriptorProto_ExtensionRange { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseDescriptorProto_ExtensionRange, + } as DescriptorProto_ExtensionRange; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.start = reader.int32(); + break; + case 2: + message.end = reader.int32(); + break; + case 3: + message.options = ExtensionRangeOptions.decode( + reader, + reader.uint32() + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DescriptorProto_ExtensionRange { + const message = { + ...baseDescriptorProto_ExtensionRange, + } as DescriptorProto_ExtensionRange; + if (object.start !== undefined && object.start !== null) { + message.start = Number(object.start); + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = ExtensionRangeOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: DescriptorProto_ExtensionRange): unknown { + const obj: any = {}; + message.start !== undefined && (obj.start = message.start); + message.end !== undefined && (obj.end = message.end); + message.options !== undefined && + (obj.options = message.options + ? ExtensionRangeOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): DescriptorProto_ExtensionRange { + const message = { + ...baseDescriptorProto_ExtensionRange, + } as DescriptorProto_ExtensionRange; + if (object.start !== undefined && object.start !== null) { + message.start = object.start; + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = ExtensionRangeOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseDescriptorProto_ReservedRange: object = { start: 0, end: 0 }; + +export const DescriptorProto_ReservedRange = { + encode( + message: DescriptorProto_ReservedRange, + writer: Writer = Writer.create() + ): Writer { + if (message.start !== 0) { + writer.uint32(8).int32(message.start); + } + if (message.end !== 0) { + writer.uint32(16).int32(message.end); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): DescriptorProto_ReservedRange { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseDescriptorProto_ReservedRange, + } as DescriptorProto_ReservedRange; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.start = reader.int32(); + break; + case 2: + message.end = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DescriptorProto_ReservedRange { + const message = { + ...baseDescriptorProto_ReservedRange, + } as DescriptorProto_ReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = Number(object.start); + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + return message; + }, + + toJSON(message: DescriptorProto_ReservedRange): unknown { + const obj: any = {}; + message.start !== undefined && (obj.start = message.start); + message.end !== undefined && (obj.end = message.end); + return obj; + }, + + fromPartial( + object: DeepPartial + ): DescriptorProto_ReservedRange { + const message = { + ...baseDescriptorProto_ReservedRange, + } as DescriptorProto_ReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = object.start; + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + return message; + }, +}; + +const baseExtensionRangeOptions: object = {}; + +export const ExtensionRangeOptions = { + encode( + message: ExtensionRangeOptions, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ExtensionRangeOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseExtensionRangeOptions } as ExtensionRangeOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ExtensionRangeOptions { + const message = { ...baseExtensionRangeOptions } as ExtensionRangeOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: ExtensionRangeOptions): unknown { + const obj: any = {}; + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial( + object: DeepPartial + ): ExtensionRangeOptions { + const message = { ...baseExtensionRangeOptions } as ExtensionRangeOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseFieldDescriptorProto: object = { + name: "", + number: 0, + label: 1, + type: 1, + typeName: "", + extendee: "", + defaultValue: "", + oneofIndex: 0, + jsonName: "", + proto3Optional: false, +}; + +export const FieldDescriptorProto = { + encode( + message: FieldDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.number !== 0) { + writer.uint32(24).int32(message.number); + } + if (message.label !== 1) { + writer.uint32(32).int32(message.label); + } + if (message.type !== 1) { + writer.uint32(40).int32(message.type); + } + if (message.typeName !== "") { + writer.uint32(50).string(message.typeName); + } + if (message.extendee !== "") { + writer.uint32(18).string(message.extendee); + } + if (message.defaultValue !== "") { + writer.uint32(58).string(message.defaultValue); + } + if (message.oneofIndex !== 0) { + writer.uint32(72).int32(message.oneofIndex); + } + if (message.jsonName !== "") { + writer.uint32(82).string(message.jsonName); + } + if (message.options !== undefined) { + FieldOptions.encode(message.options, writer.uint32(66).fork()).ldelim(); + } + if (message.proto3Optional === true) { + writer.uint32(136).bool(message.proto3Optional); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FieldDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFieldDescriptorProto } as FieldDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 3: + message.number = reader.int32(); + break; + case 4: + message.label = reader.int32() as any; + break; + case 5: + message.type = reader.int32() as any; + break; + case 6: + message.typeName = reader.string(); + break; + case 2: + message.extendee = reader.string(); + break; + case 7: + message.defaultValue = reader.string(); + break; + case 9: + message.oneofIndex = reader.int32(); + break; + case 10: + message.jsonName = reader.string(); + break; + case 8: + message.options = FieldOptions.decode(reader, reader.uint32()); + break; + case 17: + message.proto3Optional = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FieldDescriptorProto { + const message = { ...baseFieldDescriptorProto } as FieldDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = Number(object.number); + } else { + message.number = 0; + } + if (object.label !== undefined && object.label !== null) { + message.label = fieldDescriptorProto_LabelFromJSON(object.label); + } else { + message.label = 1; + } + if (object.type !== undefined && object.type !== null) { + message.type = fieldDescriptorProto_TypeFromJSON(object.type); + } else { + message.type = 1; + } + if (object.typeName !== undefined && object.typeName !== null) { + message.typeName = String(object.typeName); + } else { + message.typeName = ""; + } + if (object.extendee !== undefined && object.extendee !== null) { + message.extendee = String(object.extendee); + } else { + message.extendee = ""; + } + if (object.defaultValue !== undefined && object.defaultValue !== null) { + message.defaultValue = String(object.defaultValue); + } else { + message.defaultValue = ""; + } + if (object.oneofIndex !== undefined && object.oneofIndex !== null) { + message.oneofIndex = Number(object.oneofIndex); + } else { + message.oneofIndex = 0; + } + if (object.jsonName !== undefined && object.jsonName !== null) { + message.jsonName = String(object.jsonName); + } else { + message.jsonName = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = FieldOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.proto3Optional !== undefined && object.proto3Optional !== null) { + message.proto3Optional = Boolean(object.proto3Optional); + } else { + message.proto3Optional = false; + } + return message; + }, + + toJSON(message: FieldDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.number !== undefined && (obj.number = message.number); + message.label !== undefined && + (obj.label = fieldDescriptorProto_LabelToJSON(message.label)); + message.type !== undefined && + (obj.type = fieldDescriptorProto_TypeToJSON(message.type)); + message.typeName !== undefined && (obj.typeName = message.typeName); + message.extendee !== undefined && (obj.extendee = message.extendee); + message.defaultValue !== undefined && + (obj.defaultValue = message.defaultValue); + message.oneofIndex !== undefined && (obj.oneofIndex = message.oneofIndex); + message.jsonName !== undefined && (obj.jsonName = message.jsonName); + message.options !== undefined && + (obj.options = message.options + ? FieldOptions.toJSON(message.options) + : undefined); + message.proto3Optional !== undefined && + (obj.proto3Optional = message.proto3Optional); + return obj; + }, + + fromPartial(object: DeepPartial): FieldDescriptorProto { + const message = { ...baseFieldDescriptorProto } as FieldDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = object.number; + } else { + message.number = 0; + } + if (object.label !== undefined && object.label !== null) { + message.label = object.label; + } else { + message.label = 1; + } + if (object.type !== undefined && object.type !== null) { + message.type = object.type; + } else { + message.type = 1; + } + if (object.typeName !== undefined && object.typeName !== null) { + message.typeName = object.typeName; + } else { + message.typeName = ""; + } + if (object.extendee !== undefined && object.extendee !== null) { + message.extendee = object.extendee; + } else { + message.extendee = ""; + } + if (object.defaultValue !== undefined && object.defaultValue !== null) { + message.defaultValue = object.defaultValue; + } else { + message.defaultValue = ""; + } + if (object.oneofIndex !== undefined && object.oneofIndex !== null) { + message.oneofIndex = object.oneofIndex; + } else { + message.oneofIndex = 0; + } + if (object.jsonName !== undefined && object.jsonName !== null) { + message.jsonName = object.jsonName; + } else { + message.jsonName = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = FieldOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.proto3Optional !== undefined && object.proto3Optional !== null) { + message.proto3Optional = object.proto3Optional; + } else { + message.proto3Optional = false; + } + return message; + }, +}; + +const baseOneofDescriptorProto: object = { name: "" }; + +export const OneofDescriptorProto = { + encode( + message: OneofDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.options !== undefined) { + OneofOptions.encode(message.options, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): OneofDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseOneofDescriptorProto } as OneofDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.options = OneofOptions.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): OneofDescriptorProto { + const message = { ...baseOneofDescriptorProto } as OneofDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = OneofOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: OneofDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.options !== undefined && + (obj.options = message.options + ? OneofOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): OneofDescriptorProto { + const message = { ...baseOneofDescriptorProto } as OneofDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = OneofOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseEnumDescriptorProto: object = { name: "", reservedName: "" }; + +export const EnumDescriptorProto = { + encode( + message: EnumDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + for (const v of message.value) { + EnumValueDescriptorProto.encode(v!, writer.uint32(18).fork()).ldelim(); + } + if (message.options !== undefined) { + EnumOptions.encode(message.options, writer.uint32(26).fork()).ldelim(); + } + for (const v of message.reservedRange) { + EnumDescriptorProto_EnumReservedRange.encode( + v!, + writer.uint32(34).fork() + ).ldelim(); + } + for (const v of message.reservedName) { + writer.uint32(42).string(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): EnumDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseEnumDescriptorProto } as EnumDescriptorProto; + message.value = []; + message.reservedRange = []; + message.reservedName = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.value.push( + EnumValueDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 3: + message.options = EnumOptions.decode(reader, reader.uint32()); + break; + case 4: + message.reservedRange.push( + EnumDescriptorProto_EnumReservedRange.decode( + reader, + reader.uint32() + ) + ); + break; + case 5: + message.reservedName.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumDescriptorProto { + const message = { ...baseEnumDescriptorProto } as EnumDescriptorProto; + message.value = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.value !== undefined && object.value !== null) { + for (const e of object.value) { + message.value.push(EnumValueDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push( + EnumDescriptorProto_EnumReservedRange.fromJSON(e) + ); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(String(e)); + } + } + return message; + }, + + toJSON(message: EnumDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + if (message.value) { + obj.value = message.value.map((e) => + e ? EnumValueDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.value = []; + } + message.options !== undefined && + (obj.options = message.options + ? EnumOptions.toJSON(message.options) + : undefined); + if (message.reservedRange) { + obj.reservedRange = message.reservedRange.map((e) => + e ? EnumDescriptorProto_EnumReservedRange.toJSON(e) : undefined + ); + } else { + obj.reservedRange = []; + } + if (message.reservedName) { + obj.reservedName = message.reservedName.map((e) => e); + } else { + obj.reservedName = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): EnumDescriptorProto { + const message = { ...baseEnumDescriptorProto } as EnumDescriptorProto; + message.value = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.value !== undefined && object.value !== null) { + for (const e of object.value) { + message.value.push(EnumValueDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push( + EnumDescriptorProto_EnumReservedRange.fromPartial(e) + ); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(e); + } + } + return message; + }, +}; + +const baseEnumDescriptorProto_EnumReservedRange: object = { start: 0, end: 0 }; + +export const EnumDescriptorProto_EnumReservedRange = { + encode( + message: EnumDescriptorProto_EnumReservedRange, + writer: Writer = Writer.create() + ): Writer { + if (message.start !== 0) { + writer.uint32(8).int32(message.start); + } + if (message.end !== 0) { + writer.uint32(16).int32(message.end); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): EnumDescriptorProto_EnumReservedRange { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseEnumDescriptorProto_EnumReservedRange, + } as EnumDescriptorProto_EnumReservedRange; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.start = reader.int32(); + break; + case 2: + message.end = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumDescriptorProto_EnumReservedRange { + const message = { + ...baseEnumDescriptorProto_EnumReservedRange, + } as EnumDescriptorProto_EnumReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = Number(object.start); + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + return message; + }, + + toJSON(message: EnumDescriptorProto_EnumReservedRange): unknown { + const obj: any = {}; + message.start !== undefined && (obj.start = message.start); + message.end !== undefined && (obj.end = message.end); + return obj; + }, + + fromPartial( + object: DeepPartial + ): EnumDescriptorProto_EnumReservedRange { + const message = { + ...baseEnumDescriptorProto_EnumReservedRange, + } as EnumDescriptorProto_EnumReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = object.start; + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + return message; + }, +}; + +const baseEnumValueDescriptorProto: object = { name: "", number: 0 }; + +export const EnumValueDescriptorProto = { + encode( + message: EnumValueDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.number !== 0) { + writer.uint32(16).int32(message.number); + } + if (message.options !== undefined) { + EnumValueOptions.encode( + message.options, + writer.uint32(26).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): EnumValueDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseEnumValueDescriptorProto, + } as EnumValueDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.number = reader.int32(); + break; + case 3: + message.options = EnumValueOptions.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumValueDescriptorProto { + const message = { + ...baseEnumValueDescriptorProto, + } as EnumValueDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = Number(object.number); + } else { + message.number = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumValueOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: EnumValueDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.number !== undefined && (obj.number = message.number); + message.options !== undefined && + (obj.options = message.options + ? EnumValueOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): EnumValueDescriptorProto { + const message = { + ...baseEnumValueDescriptorProto, + } as EnumValueDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = object.number; + } else { + message.number = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumValueOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseServiceDescriptorProto: object = { name: "" }; + +export const ServiceDescriptorProto = { + encode( + message: ServiceDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + for (const v of message.method) { + MethodDescriptorProto.encode(v!, writer.uint32(18).fork()).ldelim(); + } + if (message.options !== undefined) { + ServiceOptions.encode(message.options, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ServiceDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseServiceDescriptorProto } as ServiceDescriptorProto; + message.method = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.method.push( + MethodDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 3: + message.options = ServiceOptions.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ServiceDescriptorProto { + const message = { ...baseServiceDescriptorProto } as ServiceDescriptorProto; + message.method = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.method !== undefined && object.method !== null) { + for (const e of object.method) { + message.method.push(MethodDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = ServiceOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: ServiceDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + if (message.method) { + obj.method = message.method.map((e) => + e ? MethodDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.method = []; + } + message.options !== undefined && + (obj.options = message.options + ? ServiceOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): ServiceDescriptorProto { + const message = { ...baseServiceDescriptorProto } as ServiceDescriptorProto; + message.method = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.method !== undefined && object.method !== null) { + for (const e of object.method) { + message.method.push(MethodDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = ServiceOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseMethodDescriptorProto: object = { + name: "", + inputType: "", + outputType: "", + clientStreaming: false, + serverStreaming: false, +}; + +export const MethodDescriptorProto = { + encode( + message: MethodDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.inputType !== "") { + writer.uint32(18).string(message.inputType); + } + if (message.outputType !== "") { + writer.uint32(26).string(message.outputType); + } + if (message.options !== undefined) { + MethodOptions.encode(message.options, writer.uint32(34).fork()).ldelim(); + } + if (message.clientStreaming === true) { + writer.uint32(40).bool(message.clientStreaming); + } + if (message.serverStreaming === true) { + writer.uint32(48).bool(message.serverStreaming); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MethodDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMethodDescriptorProto } as MethodDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.inputType = reader.string(); + break; + case 3: + message.outputType = reader.string(); + break; + case 4: + message.options = MethodOptions.decode(reader, reader.uint32()); + break; + case 5: + message.clientStreaming = reader.bool(); + break; + case 6: + message.serverStreaming = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MethodDescriptorProto { + const message = { ...baseMethodDescriptorProto } as MethodDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.inputType !== undefined && object.inputType !== null) { + message.inputType = String(object.inputType); + } else { + message.inputType = ""; + } + if (object.outputType !== undefined && object.outputType !== null) { + message.outputType = String(object.outputType); + } else { + message.outputType = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = MethodOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if ( + object.clientStreaming !== undefined && + object.clientStreaming !== null + ) { + message.clientStreaming = Boolean(object.clientStreaming); + } else { + message.clientStreaming = false; + } + if ( + object.serverStreaming !== undefined && + object.serverStreaming !== null + ) { + message.serverStreaming = Boolean(object.serverStreaming); + } else { + message.serverStreaming = false; + } + return message; + }, + + toJSON(message: MethodDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.inputType !== undefined && (obj.inputType = message.inputType); + message.outputType !== undefined && (obj.outputType = message.outputType); + message.options !== undefined && + (obj.options = message.options + ? MethodOptions.toJSON(message.options) + : undefined); + message.clientStreaming !== undefined && + (obj.clientStreaming = message.clientStreaming); + message.serverStreaming !== undefined && + (obj.serverStreaming = message.serverStreaming); + return obj; + }, + + fromPartial( + object: DeepPartial + ): MethodDescriptorProto { + const message = { ...baseMethodDescriptorProto } as MethodDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.inputType !== undefined && object.inputType !== null) { + message.inputType = object.inputType; + } else { + message.inputType = ""; + } + if (object.outputType !== undefined && object.outputType !== null) { + message.outputType = object.outputType; + } else { + message.outputType = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = MethodOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if ( + object.clientStreaming !== undefined && + object.clientStreaming !== null + ) { + message.clientStreaming = object.clientStreaming; + } else { + message.clientStreaming = false; + } + if ( + object.serverStreaming !== undefined && + object.serverStreaming !== null + ) { + message.serverStreaming = object.serverStreaming; + } else { + message.serverStreaming = false; + } + return message; + }, +}; + +const baseFileOptions: object = { + javaPackage: "", + javaOuterClassname: "", + javaMultipleFiles: false, + javaGenerateEqualsAndHash: false, + javaStringCheckUtf8: false, + optimizeFor: 1, + goPackage: "", + ccGenericServices: false, + javaGenericServices: false, + pyGenericServices: false, + phpGenericServices: false, + deprecated: false, + ccEnableArenas: false, + objcClassPrefix: "", + csharpNamespace: "", + swiftPrefix: "", + phpClassPrefix: "", + phpNamespace: "", + phpMetadataNamespace: "", + rubyPackage: "", +}; + +export const FileOptions = { + encode(message: FileOptions, writer: Writer = Writer.create()): Writer { + if (message.javaPackage !== "") { + writer.uint32(10).string(message.javaPackage); + } + if (message.javaOuterClassname !== "") { + writer.uint32(66).string(message.javaOuterClassname); + } + if (message.javaMultipleFiles === true) { + writer.uint32(80).bool(message.javaMultipleFiles); + } + if (message.javaGenerateEqualsAndHash === true) { + writer.uint32(160).bool(message.javaGenerateEqualsAndHash); + } + if (message.javaStringCheckUtf8 === true) { + writer.uint32(216).bool(message.javaStringCheckUtf8); + } + if (message.optimizeFor !== 1) { + writer.uint32(72).int32(message.optimizeFor); + } + if (message.goPackage !== "") { + writer.uint32(90).string(message.goPackage); + } + if (message.ccGenericServices === true) { + writer.uint32(128).bool(message.ccGenericServices); + } + if (message.javaGenericServices === true) { + writer.uint32(136).bool(message.javaGenericServices); + } + if (message.pyGenericServices === true) { + writer.uint32(144).bool(message.pyGenericServices); + } + if (message.phpGenericServices === true) { + writer.uint32(336).bool(message.phpGenericServices); + } + if (message.deprecated === true) { + writer.uint32(184).bool(message.deprecated); + } + if (message.ccEnableArenas === true) { + writer.uint32(248).bool(message.ccEnableArenas); + } + if (message.objcClassPrefix !== "") { + writer.uint32(290).string(message.objcClassPrefix); + } + if (message.csharpNamespace !== "") { + writer.uint32(298).string(message.csharpNamespace); + } + if (message.swiftPrefix !== "") { + writer.uint32(314).string(message.swiftPrefix); + } + if (message.phpClassPrefix !== "") { + writer.uint32(322).string(message.phpClassPrefix); + } + if (message.phpNamespace !== "") { + writer.uint32(330).string(message.phpNamespace); + } + if (message.phpMetadataNamespace !== "") { + writer.uint32(354).string(message.phpMetadataNamespace); + } + if (message.rubyPackage !== "") { + writer.uint32(362).string(message.rubyPackage); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FileOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFileOptions } as FileOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.javaPackage = reader.string(); + break; + case 8: + message.javaOuterClassname = reader.string(); + break; + case 10: + message.javaMultipleFiles = reader.bool(); + break; + case 20: + message.javaGenerateEqualsAndHash = reader.bool(); + break; + case 27: + message.javaStringCheckUtf8 = reader.bool(); + break; + case 9: + message.optimizeFor = reader.int32() as any; + break; + case 11: + message.goPackage = reader.string(); + break; + case 16: + message.ccGenericServices = reader.bool(); + break; + case 17: + message.javaGenericServices = reader.bool(); + break; + case 18: + message.pyGenericServices = reader.bool(); + break; + case 42: + message.phpGenericServices = reader.bool(); + break; + case 23: + message.deprecated = reader.bool(); + break; + case 31: + message.ccEnableArenas = reader.bool(); + break; + case 36: + message.objcClassPrefix = reader.string(); + break; + case 37: + message.csharpNamespace = reader.string(); + break; + case 39: + message.swiftPrefix = reader.string(); + break; + case 40: + message.phpClassPrefix = reader.string(); + break; + case 41: + message.phpNamespace = reader.string(); + break; + case 44: + message.phpMetadataNamespace = reader.string(); + break; + case 45: + message.rubyPackage = reader.string(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FileOptions { + const message = { ...baseFileOptions } as FileOptions; + message.uninterpretedOption = []; + if (object.javaPackage !== undefined && object.javaPackage !== null) { + message.javaPackage = String(object.javaPackage); + } else { + message.javaPackage = ""; + } + if ( + object.javaOuterClassname !== undefined && + object.javaOuterClassname !== null + ) { + message.javaOuterClassname = String(object.javaOuterClassname); + } else { + message.javaOuterClassname = ""; + } + if ( + object.javaMultipleFiles !== undefined && + object.javaMultipleFiles !== null + ) { + message.javaMultipleFiles = Boolean(object.javaMultipleFiles); + } else { + message.javaMultipleFiles = false; + } + if ( + object.javaGenerateEqualsAndHash !== undefined && + object.javaGenerateEqualsAndHash !== null + ) { + message.javaGenerateEqualsAndHash = Boolean( + object.javaGenerateEqualsAndHash + ); + } else { + message.javaGenerateEqualsAndHash = false; + } + if ( + object.javaStringCheckUtf8 !== undefined && + object.javaStringCheckUtf8 !== null + ) { + message.javaStringCheckUtf8 = Boolean(object.javaStringCheckUtf8); + } else { + message.javaStringCheckUtf8 = false; + } + if (object.optimizeFor !== undefined && object.optimizeFor !== null) { + message.optimizeFor = fileOptions_OptimizeModeFromJSON( + object.optimizeFor + ); + } else { + message.optimizeFor = 1; + } + if (object.goPackage !== undefined && object.goPackage !== null) { + message.goPackage = String(object.goPackage); + } else { + message.goPackage = ""; + } + if ( + object.ccGenericServices !== undefined && + object.ccGenericServices !== null + ) { + message.ccGenericServices = Boolean(object.ccGenericServices); + } else { + message.ccGenericServices = false; + } + if ( + object.javaGenericServices !== undefined && + object.javaGenericServices !== null + ) { + message.javaGenericServices = Boolean(object.javaGenericServices); + } else { + message.javaGenericServices = false; + } + if ( + object.pyGenericServices !== undefined && + object.pyGenericServices !== null + ) { + message.pyGenericServices = Boolean(object.pyGenericServices); + } else { + message.pyGenericServices = false; + } + if ( + object.phpGenericServices !== undefined && + object.phpGenericServices !== null + ) { + message.phpGenericServices = Boolean(object.phpGenericServices); + } else { + message.phpGenericServices = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if (object.ccEnableArenas !== undefined && object.ccEnableArenas !== null) { + message.ccEnableArenas = Boolean(object.ccEnableArenas); + } else { + message.ccEnableArenas = false; + } + if ( + object.objcClassPrefix !== undefined && + object.objcClassPrefix !== null + ) { + message.objcClassPrefix = String(object.objcClassPrefix); + } else { + message.objcClassPrefix = ""; + } + if ( + object.csharpNamespace !== undefined && + object.csharpNamespace !== null + ) { + message.csharpNamespace = String(object.csharpNamespace); + } else { + message.csharpNamespace = ""; + } + if (object.swiftPrefix !== undefined && object.swiftPrefix !== null) { + message.swiftPrefix = String(object.swiftPrefix); + } else { + message.swiftPrefix = ""; + } + if (object.phpClassPrefix !== undefined && object.phpClassPrefix !== null) { + message.phpClassPrefix = String(object.phpClassPrefix); + } else { + message.phpClassPrefix = ""; + } + if (object.phpNamespace !== undefined && object.phpNamespace !== null) { + message.phpNamespace = String(object.phpNamespace); + } else { + message.phpNamespace = ""; + } + if ( + object.phpMetadataNamespace !== undefined && + object.phpMetadataNamespace !== null + ) { + message.phpMetadataNamespace = String(object.phpMetadataNamespace); + } else { + message.phpMetadataNamespace = ""; + } + if (object.rubyPackage !== undefined && object.rubyPackage !== null) { + message.rubyPackage = String(object.rubyPackage); + } else { + message.rubyPackage = ""; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: FileOptions): unknown { + const obj: any = {}; + message.javaPackage !== undefined && + (obj.javaPackage = message.javaPackage); + message.javaOuterClassname !== undefined && + (obj.javaOuterClassname = message.javaOuterClassname); + message.javaMultipleFiles !== undefined && + (obj.javaMultipleFiles = message.javaMultipleFiles); + message.javaGenerateEqualsAndHash !== undefined && + (obj.javaGenerateEqualsAndHash = message.javaGenerateEqualsAndHash); + message.javaStringCheckUtf8 !== undefined && + (obj.javaStringCheckUtf8 = message.javaStringCheckUtf8); + message.optimizeFor !== undefined && + (obj.optimizeFor = fileOptions_OptimizeModeToJSON(message.optimizeFor)); + message.goPackage !== undefined && (obj.goPackage = message.goPackage); + message.ccGenericServices !== undefined && + (obj.ccGenericServices = message.ccGenericServices); + message.javaGenericServices !== undefined && + (obj.javaGenericServices = message.javaGenericServices); + message.pyGenericServices !== undefined && + (obj.pyGenericServices = message.pyGenericServices); + message.phpGenericServices !== undefined && + (obj.phpGenericServices = message.phpGenericServices); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.ccEnableArenas !== undefined && + (obj.ccEnableArenas = message.ccEnableArenas); + message.objcClassPrefix !== undefined && + (obj.objcClassPrefix = message.objcClassPrefix); + message.csharpNamespace !== undefined && + (obj.csharpNamespace = message.csharpNamespace); + message.swiftPrefix !== undefined && + (obj.swiftPrefix = message.swiftPrefix); + message.phpClassPrefix !== undefined && + (obj.phpClassPrefix = message.phpClassPrefix); + message.phpNamespace !== undefined && + (obj.phpNamespace = message.phpNamespace); + message.phpMetadataNamespace !== undefined && + (obj.phpMetadataNamespace = message.phpMetadataNamespace); + message.rubyPackage !== undefined && + (obj.rubyPackage = message.rubyPackage); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): FileOptions { + const message = { ...baseFileOptions } as FileOptions; + message.uninterpretedOption = []; + if (object.javaPackage !== undefined && object.javaPackage !== null) { + message.javaPackage = object.javaPackage; + } else { + message.javaPackage = ""; + } + if ( + object.javaOuterClassname !== undefined && + object.javaOuterClassname !== null + ) { + message.javaOuterClassname = object.javaOuterClassname; + } else { + message.javaOuterClassname = ""; + } + if ( + object.javaMultipleFiles !== undefined && + object.javaMultipleFiles !== null + ) { + message.javaMultipleFiles = object.javaMultipleFiles; + } else { + message.javaMultipleFiles = false; + } + if ( + object.javaGenerateEqualsAndHash !== undefined && + object.javaGenerateEqualsAndHash !== null + ) { + message.javaGenerateEqualsAndHash = object.javaGenerateEqualsAndHash; + } else { + message.javaGenerateEqualsAndHash = false; + } + if ( + object.javaStringCheckUtf8 !== undefined && + object.javaStringCheckUtf8 !== null + ) { + message.javaStringCheckUtf8 = object.javaStringCheckUtf8; + } else { + message.javaStringCheckUtf8 = false; + } + if (object.optimizeFor !== undefined && object.optimizeFor !== null) { + message.optimizeFor = object.optimizeFor; + } else { + message.optimizeFor = 1; + } + if (object.goPackage !== undefined && object.goPackage !== null) { + message.goPackage = object.goPackage; + } else { + message.goPackage = ""; + } + if ( + object.ccGenericServices !== undefined && + object.ccGenericServices !== null + ) { + message.ccGenericServices = object.ccGenericServices; + } else { + message.ccGenericServices = false; + } + if ( + object.javaGenericServices !== undefined && + object.javaGenericServices !== null + ) { + message.javaGenericServices = object.javaGenericServices; + } else { + message.javaGenericServices = false; + } + if ( + object.pyGenericServices !== undefined && + object.pyGenericServices !== null + ) { + message.pyGenericServices = object.pyGenericServices; + } else { + message.pyGenericServices = false; + } + if ( + object.phpGenericServices !== undefined && + object.phpGenericServices !== null + ) { + message.phpGenericServices = object.phpGenericServices; + } else { + message.phpGenericServices = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if (object.ccEnableArenas !== undefined && object.ccEnableArenas !== null) { + message.ccEnableArenas = object.ccEnableArenas; + } else { + message.ccEnableArenas = false; + } + if ( + object.objcClassPrefix !== undefined && + object.objcClassPrefix !== null + ) { + message.objcClassPrefix = object.objcClassPrefix; + } else { + message.objcClassPrefix = ""; + } + if ( + object.csharpNamespace !== undefined && + object.csharpNamespace !== null + ) { + message.csharpNamespace = object.csharpNamespace; + } else { + message.csharpNamespace = ""; + } + if (object.swiftPrefix !== undefined && object.swiftPrefix !== null) { + message.swiftPrefix = object.swiftPrefix; + } else { + message.swiftPrefix = ""; + } + if (object.phpClassPrefix !== undefined && object.phpClassPrefix !== null) { + message.phpClassPrefix = object.phpClassPrefix; + } else { + message.phpClassPrefix = ""; + } + if (object.phpNamespace !== undefined && object.phpNamespace !== null) { + message.phpNamespace = object.phpNamespace; + } else { + message.phpNamespace = ""; + } + if ( + object.phpMetadataNamespace !== undefined && + object.phpMetadataNamespace !== null + ) { + message.phpMetadataNamespace = object.phpMetadataNamespace; + } else { + message.phpMetadataNamespace = ""; + } + if (object.rubyPackage !== undefined && object.rubyPackage !== null) { + message.rubyPackage = object.rubyPackage; + } else { + message.rubyPackage = ""; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseMessageOptions: object = { + messageSetWireFormat: false, + noStandardDescriptorAccessor: false, + deprecated: false, + mapEntry: false, +}; + +export const MessageOptions = { + encode(message: MessageOptions, writer: Writer = Writer.create()): Writer { + if (message.messageSetWireFormat === true) { + writer.uint32(8).bool(message.messageSetWireFormat); + } + if (message.noStandardDescriptorAccessor === true) { + writer.uint32(16).bool(message.noStandardDescriptorAccessor); + } + if (message.deprecated === true) { + writer.uint32(24).bool(message.deprecated); + } + if (message.mapEntry === true) { + writer.uint32(56).bool(message.mapEntry); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MessageOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMessageOptions } as MessageOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.messageSetWireFormat = reader.bool(); + break; + case 2: + message.noStandardDescriptorAccessor = reader.bool(); + break; + case 3: + message.deprecated = reader.bool(); + break; + case 7: + message.mapEntry = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MessageOptions { + const message = { ...baseMessageOptions } as MessageOptions; + message.uninterpretedOption = []; + if ( + object.messageSetWireFormat !== undefined && + object.messageSetWireFormat !== null + ) { + message.messageSetWireFormat = Boolean(object.messageSetWireFormat); + } else { + message.messageSetWireFormat = false; + } + if ( + object.noStandardDescriptorAccessor !== undefined && + object.noStandardDescriptorAccessor !== null + ) { + message.noStandardDescriptorAccessor = Boolean( + object.noStandardDescriptorAccessor + ); + } else { + message.noStandardDescriptorAccessor = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if (object.mapEntry !== undefined && object.mapEntry !== null) { + message.mapEntry = Boolean(object.mapEntry); + } else { + message.mapEntry = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: MessageOptions): unknown { + const obj: any = {}; + message.messageSetWireFormat !== undefined && + (obj.messageSetWireFormat = message.messageSetWireFormat); + message.noStandardDescriptorAccessor !== undefined && + (obj.noStandardDescriptorAccessor = message.noStandardDescriptorAccessor); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.mapEntry !== undefined && (obj.mapEntry = message.mapEntry); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): MessageOptions { + const message = { ...baseMessageOptions } as MessageOptions; + message.uninterpretedOption = []; + if ( + object.messageSetWireFormat !== undefined && + object.messageSetWireFormat !== null + ) { + message.messageSetWireFormat = object.messageSetWireFormat; + } else { + message.messageSetWireFormat = false; + } + if ( + object.noStandardDescriptorAccessor !== undefined && + object.noStandardDescriptorAccessor !== null + ) { + message.noStandardDescriptorAccessor = + object.noStandardDescriptorAccessor; + } else { + message.noStandardDescriptorAccessor = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if (object.mapEntry !== undefined && object.mapEntry !== null) { + message.mapEntry = object.mapEntry; + } else { + message.mapEntry = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseFieldOptions: object = { + ctype: 0, + packed: false, + jstype: 0, + lazy: false, + deprecated: false, + weak: false, +}; + +export const FieldOptions = { + encode(message: FieldOptions, writer: Writer = Writer.create()): Writer { + if (message.ctype !== 0) { + writer.uint32(8).int32(message.ctype); + } + if (message.packed === true) { + writer.uint32(16).bool(message.packed); + } + if (message.jstype !== 0) { + writer.uint32(48).int32(message.jstype); + } + if (message.lazy === true) { + writer.uint32(40).bool(message.lazy); + } + if (message.deprecated === true) { + writer.uint32(24).bool(message.deprecated); + } + if (message.weak === true) { + writer.uint32(80).bool(message.weak); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FieldOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFieldOptions } as FieldOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.ctype = reader.int32() as any; + break; + case 2: + message.packed = reader.bool(); + break; + case 6: + message.jstype = reader.int32() as any; + break; + case 5: + message.lazy = reader.bool(); + break; + case 3: + message.deprecated = reader.bool(); + break; + case 10: + message.weak = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FieldOptions { + const message = { ...baseFieldOptions } as FieldOptions; + message.uninterpretedOption = []; + if (object.ctype !== undefined && object.ctype !== null) { + message.ctype = fieldOptions_CTypeFromJSON(object.ctype); + } else { + message.ctype = 0; + } + if (object.packed !== undefined && object.packed !== null) { + message.packed = Boolean(object.packed); + } else { + message.packed = false; + } + if (object.jstype !== undefined && object.jstype !== null) { + message.jstype = fieldOptions_JSTypeFromJSON(object.jstype); + } else { + message.jstype = 0; + } + if (object.lazy !== undefined && object.lazy !== null) { + message.lazy = Boolean(object.lazy); + } else { + message.lazy = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if (object.weak !== undefined && object.weak !== null) { + message.weak = Boolean(object.weak); + } else { + message.weak = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: FieldOptions): unknown { + const obj: any = {}; + message.ctype !== undefined && + (obj.ctype = fieldOptions_CTypeToJSON(message.ctype)); + message.packed !== undefined && (obj.packed = message.packed); + message.jstype !== undefined && + (obj.jstype = fieldOptions_JSTypeToJSON(message.jstype)); + message.lazy !== undefined && (obj.lazy = message.lazy); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.weak !== undefined && (obj.weak = message.weak); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): FieldOptions { + const message = { ...baseFieldOptions } as FieldOptions; + message.uninterpretedOption = []; + if (object.ctype !== undefined && object.ctype !== null) { + message.ctype = object.ctype; + } else { + message.ctype = 0; + } + if (object.packed !== undefined && object.packed !== null) { + message.packed = object.packed; + } else { + message.packed = false; + } + if (object.jstype !== undefined && object.jstype !== null) { + message.jstype = object.jstype; + } else { + message.jstype = 0; + } + if (object.lazy !== undefined && object.lazy !== null) { + message.lazy = object.lazy; + } else { + message.lazy = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if (object.weak !== undefined && object.weak !== null) { + message.weak = object.weak; + } else { + message.weak = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseOneofOptions: object = {}; + +export const OneofOptions = { + encode(message: OneofOptions, writer: Writer = Writer.create()): Writer { + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): OneofOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseOneofOptions } as OneofOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): OneofOptions { + const message = { ...baseOneofOptions } as OneofOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: OneofOptions): unknown { + const obj: any = {}; + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): OneofOptions { + const message = { ...baseOneofOptions } as OneofOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseEnumOptions: object = { allowAlias: false, deprecated: false }; + +export const EnumOptions = { + encode(message: EnumOptions, writer: Writer = Writer.create()): Writer { + if (message.allowAlias === true) { + writer.uint32(16).bool(message.allowAlias); + } + if (message.deprecated === true) { + writer.uint32(24).bool(message.deprecated); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): EnumOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseEnumOptions } as EnumOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + message.allowAlias = reader.bool(); + break; + case 3: + message.deprecated = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumOptions { + const message = { ...baseEnumOptions } as EnumOptions; + message.uninterpretedOption = []; + if (object.allowAlias !== undefined && object.allowAlias !== null) { + message.allowAlias = Boolean(object.allowAlias); + } else { + message.allowAlias = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: EnumOptions): unknown { + const obj: any = {}; + message.allowAlias !== undefined && (obj.allowAlias = message.allowAlias); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): EnumOptions { + const message = { ...baseEnumOptions } as EnumOptions; + message.uninterpretedOption = []; + if (object.allowAlias !== undefined && object.allowAlias !== null) { + message.allowAlias = object.allowAlias; + } else { + message.allowAlias = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseEnumValueOptions: object = { deprecated: false }; + +export const EnumValueOptions = { + encode(message: EnumValueOptions, writer: Writer = Writer.create()): Writer { + if (message.deprecated === true) { + writer.uint32(8).bool(message.deprecated); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): EnumValueOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseEnumValueOptions } as EnumValueOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.deprecated = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumValueOptions { + const message = { ...baseEnumValueOptions } as EnumValueOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: EnumValueOptions): unknown { + const obj: any = {}; + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): EnumValueOptions { + const message = { ...baseEnumValueOptions } as EnumValueOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseServiceOptions: object = { deprecated: false }; + +export const ServiceOptions = { + encode(message: ServiceOptions, writer: Writer = Writer.create()): Writer { + if (message.deprecated === true) { + writer.uint32(264).bool(message.deprecated); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ServiceOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseServiceOptions } as ServiceOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 33: + message.deprecated = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ServiceOptions { + const message = { ...baseServiceOptions } as ServiceOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: ServiceOptions): unknown { + const obj: any = {}; + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): ServiceOptions { + const message = { ...baseServiceOptions } as ServiceOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseMethodOptions: object = { deprecated: false, idempotencyLevel: 0 }; + +export const MethodOptions = { + encode(message: MethodOptions, writer: Writer = Writer.create()): Writer { + if (message.deprecated === true) { + writer.uint32(264).bool(message.deprecated); + } + if (message.idempotencyLevel !== 0) { + writer.uint32(272).int32(message.idempotencyLevel); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MethodOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMethodOptions } as MethodOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 33: + message.deprecated = reader.bool(); + break; + case 34: + message.idempotencyLevel = reader.int32() as any; + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MethodOptions { + const message = { ...baseMethodOptions } as MethodOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.idempotencyLevel !== undefined && + object.idempotencyLevel !== null + ) { + message.idempotencyLevel = methodOptions_IdempotencyLevelFromJSON( + object.idempotencyLevel + ); + } else { + message.idempotencyLevel = 0; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: MethodOptions): unknown { + const obj: any = {}; + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.idempotencyLevel !== undefined && + (obj.idempotencyLevel = methodOptions_IdempotencyLevelToJSON( + message.idempotencyLevel + )); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): MethodOptions { + const message = { ...baseMethodOptions } as MethodOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.idempotencyLevel !== undefined && + object.idempotencyLevel !== null + ) { + message.idempotencyLevel = object.idempotencyLevel; + } else { + message.idempotencyLevel = 0; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseUninterpretedOption: object = { + identifierValue: "", + positiveIntValue: 0, + negativeIntValue: 0, + doubleValue: 0, + aggregateValue: "", +}; + +export const UninterpretedOption = { + encode( + message: UninterpretedOption, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.name) { + UninterpretedOption_NamePart.encode( + v!, + writer.uint32(18).fork() + ).ldelim(); + } + if (message.identifierValue !== "") { + writer.uint32(26).string(message.identifierValue); + } + if (message.positiveIntValue !== 0) { + writer.uint32(32).uint64(message.positiveIntValue); + } + if (message.negativeIntValue !== 0) { + writer.uint32(40).int64(message.negativeIntValue); + } + if (message.doubleValue !== 0) { + writer.uint32(49).double(message.doubleValue); + } + if (message.stringValue.length !== 0) { + writer.uint32(58).bytes(message.stringValue); + } + if (message.aggregateValue !== "") { + writer.uint32(66).string(message.aggregateValue); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): UninterpretedOption { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseUninterpretedOption } as UninterpretedOption; + message.name = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + message.name.push( + UninterpretedOption_NamePart.decode(reader, reader.uint32()) + ); + break; + case 3: + message.identifierValue = reader.string(); + break; + case 4: + message.positiveIntValue = longToNumber(reader.uint64() as Long); + break; + case 5: + message.negativeIntValue = longToNumber(reader.int64() as Long); + break; + case 6: + message.doubleValue = reader.double(); + break; + case 7: + message.stringValue = reader.bytes(); + break; + case 8: + message.aggregateValue = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): UninterpretedOption { + const message = { ...baseUninterpretedOption } as UninterpretedOption; + message.name = []; + if (object.name !== undefined && object.name !== null) { + for (const e of object.name) { + message.name.push(UninterpretedOption_NamePart.fromJSON(e)); + } + } + if ( + object.identifierValue !== undefined && + object.identifierValue !== null + ) { + message.identifierValue = String(object.identifierValue); + } else { + message.identifierValue = ""; + } + if ( + object.positiveIntValue !== undefined && + object.positiveIntValue !== null + ) { + message.positiveIntValue = Number(object.positiveIntValue); + } else { + message.positiveIntValue = 0; + } + if ( + object.negativeIntValue !== undefined && + object.negativeIntValue !== null + ) { + message.negativeIntValue = Number(object.negativeIntValue); + } else { + message.negativeIntValue = 0; + } + if (object.doubleValue !== undefined && object.doubleValue !== null) { + message.doubleValue = Number(object.doubleValue); + } else { + message.doubleValue = 0; + } + if (object.stringValue !== undefined && object.stringValue !== null) { + message.stringValue = bytesFromBase64(object.stringValue); + } + if (object.aggregateValue !== undefined && object.aggregateValue !== null) { + message.aggregateValue = String(object.aggregateValue); + } else { + message.aggregateValue = ""; + } + return message; + }, + + toJSON(message: UninterpretedOption): unknown { + const obj: any = {}; + if (message.name) { + obj.name = message.name.map((e) => + e ? UninterpretedOption_NamePart.toJSON(e) : undefined + ); + } else { + obj.name = []; + } + message.identifierValue !== undefined && + (obj.identifierValue = message.identifierValue); + message.positiveIntValue !== undefined && + (obj.positiveIntValue = message.positiveIntValue); + message.negativeIntValue !== undefined && + (obj.negativeIntValue = message.negativeIntValue); + message.doubleValue !== undefined && + (obj.doubleValue = message.doubleValue); + message.stringValue !== undefined && + (obj.stringValue = base64FromBytes( + message.stringValue !== undefined + ? message.stringValue + : new Uint8Array() + )); + message.aggregateValue !== undefined && + (obj.aggregateValue = message.aggregateValue); + return obj; + }, + + fromPartial(object: DeepPartial): UninterpretedOption { + const message = { ...baseUninterpretedOption } as UninterpretedOption; + message.name = []; + if (object.name !== undefined && object.name !== null) { + for (const e of object.name) { + message.name.push(UninterpretedOption_NamePart.fromPartial(e)); + } + } + if ( + object.identifierValue !== undefined && + object.identifierValue !== null + ) { + message.identifierValue = object.identifierValue; + } else { + message.identifierValue = ""; + } + if ( + object.positiveIntValue !== undefined && + object.positiveIntValue !== null + ) { + message.positiveIntValue = object.positiveIntValue; + } else { + message.positiveIntValue = 0; + } + if ( + object.negativeIntValue !== undefined && + object.negativeIntValue !== null + ) { + message.negativeIntValue = object.negativeIntValue; + } else { + message.negativeIntValue = 0; + } + if (object.doubleValue !== undefined && object.doubleValue !== null) { + message.doubleValue = object.doubleValue; + } else { + message.doubleValue = 0; + } + if (object.stringValue !== undefined && object.stringValue !== null) { + message.stringValue = object.stringValue; + } else { + message.stringValue = new Uint8Array(); + } + if (object.aggregateValue !== undefined && object.aggregateValue !== null) { + message.aggregateValue = object.aggregateValue; + } else { + message.aggregateValue = ""; + } + return message; + }, +}; + +const baseUninterpretedOption_NamePart: object = { + namePart: "", + isExtension: false, +}; + +export const UninterpretedOption_NamePart = { + encode( + message: UninterpretedOption_NamePart, + writer: Writer = Writer.create() + ): Writer { + if (message.namePart !== "") { + writer.uint32(10).string(message.namePart); + } + if (message.isExtension === true) { + writer.uint32(16).bool(message.isExtension); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): UninterpretedOption_NamePart { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseUninterpretedOption_NamePart, + } as UninterpretedOption_NamePart; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.namePart = reader.string(); + break; + case 2: + message.isExtension = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): UninterpretedOption_NamePart { + const message = { + ...baseUninterpretedOption_NamePart, + } as UninterpretedOption_NamePart; + if (object.namePart !== undefined && object.namePart !== null) { + message.namePart = String(object.namePart); + } else { + message.namePart = ""; + } + if (object.isExtension !== undefined && object.isExtension !== null) { + message.isExtension = Boolean(object.isExtension); + } else { + message.isExtension = false; + } + return message; + }, + + toJSON(message: UninterpretedOption_NamePart): unknown { + const obj: any = {}; + message.namePart !== undefined && (obj.namePart = message.namePart); + message.isExtension !== undefined && + (obj.isExtension = message.isExtension); + return obj; + }, + + fromPartial( + object: DeepPartial + ): UninterpretedOption_NamePart { + const message = { + ...baseUninterpretedOption_NamePart, + } as UninterpretedOption_NamePart; + if (object.namePart !== undefined && object.namePart !== null) { + message.namePart = object.namePart; + } else { + message.namePart = ""; + } + if (object.isExtension !== undefined && object.isExtension !== null) { + message.isExtension = object.isExtension; + } else { + message.isExtension = false; + } + return message; + }, +}; + +const baseSourceCodeInfo: object = {}; + +export const SourceCodeInfo = { + encode(message: SourceCodeInfo, writer: Writer = Writer.create()): Writer { + for (const v of message.location) { + SourceCodeInfo_Location.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): SourceCodeInfo { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseSourceCodeInfo } as SourceCodeInfo; + message.location = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.location.push( + SourceCodeInfo_Location.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): SourceCodeInfo { + const message = { ...baseSourceCodeInfo } as SourceCodeInfo; + message.location = []; + if (object.location !== undefined && object.location !== null) { + for (const e of object.location) { + message.location.push(SourceCodeInfo_Location.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: SourceCodeInfo): unknown { + const obj: any = {}; + if (message.location) { + obj.location = message.location.map((e) => + e ? SourceCodeInfo_Location.toJSON(e) : undefined + ); + } else { + obj.location = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): SourceCodeInfo { + const message = { ...baseSourceCodeInfo } as SourceCodeInfo; + message.location = []; + if (object.location !== undefined && object.location !== null) { + for (const e of object.location) { + message.location.push(SourceCodeInfo_Location.fromPartial(e)); + } + } + return message; + }, +}; + +const baseSourceCodeInfo_Location: object = { + path: 0, + span: 0, + leadingComments: "", + trailingComments: "", + leadingDetachedComments: "", +}; + +export const SourceCodeInfo_Location = { + encode( + message: SourceCodeInfo_Location, + writer: Writer = Writer.create() + ): Writer { + writer.uint32(10).fork(); + for (const v of message.path) { + writer.int32(v); + } + writer.ldelim(); + writer.uint32(18).fork(); + for (const v of message.span) { + writer.int32(v); + } + writer.ldelim(); + if (message.leadingComments !== "") { + writer.uint32(26).string(message.leadingComments); + } + if (message.trailingComments !== "") { + writer.uint32(34).string(message.trailingComments); + } + for (const v of message.leadingDetachedComments) { + writer.uint32(50).string(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): SourceCodeInfo_Location { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseSourceCodeInfo_Location, + } as SourceCodeInfo_Location; + message.path = []; + message.span = []; + message.leadingDetachedComments = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.path.push(reader.int32()); + } + } else { + message.path.push(reader.int32()); + } + break; + case 2: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.span.push(reader.int32()); + } + } else { + message.span.push(reader.int32()); + } + break; + case 3: + message.leadingComments = reader.string(); + break; + case 4: + message.trailingComments = reader.string(); + break; + case 6: + message.leadingDetachedComments.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): SourceCodeInfo_Location { + const message = { + ...baseSourceCodeInfo_Location, + } as SourceCodeInfo_Location; + message.path = []; + message.span = []; + message.leadingDetachedComments = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(Number(e)); + } + } + if (object.span !== undefined && object.span !== null) { + for (const e of object.span) { + message.span.push(Number(e)); + } + } + if ( + object.leadingComments !== undefined && + object.leadingComments !== null + ) { + message.leadingComments = String(object.leadingComments); + } else { + message.leadingComments = ""; + } + if ( + object.trailingComments !== undefined && + object.trailingComments !== null + ) { + message.trailingComments = String(object.trailingComments); + } else { + message.trailingComments = ""; + } + if ( + object.leadingDetachedComments !== undefined && + object.leadingDetachedComments !== null + ) { + for (const e of object.leadingDetachedComments) { + message.leadingDetachedComments.push(String(e)); + } + } + return message; + }, + + toJSON(message: SourceCodeInfo_Location): unknown { + const obj: any = {}; + if (message.path) { + obj.path = message.path.map((e) => e); + } else { + obj.path = []; + } + if (message.span) { + obj.span = message.span.map((e) => e); + } else { + obj.span = []; + } + message.leadingComments !== undefined && + (obj.leadingComments = message.leadingComments); + message.trailingComments !== undefined && + (obj.trailingComments = message.trailingComments); + if (message.leadingDetachedComments) { + obj.leadingDetachedComments = message.leadingDetachedComments.map( + (e) => e + ); + } else { + obj.leadingDetachedComments = []; + } + return obj; + }, + + fromPartial( + object: DeepPartial + ): SourceCodeInfo_Location { + const message = { + ...baseSourceCodeInfo_Location, + } as SourceCodeInfo_Location; + message.path = []; + message.span = []; + message.leadingDetachedComments = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(e); + } + } + if (object.span !== undefined && object.span !== null) { + for (const e of object.span) { + message.span.push(e); + } + } + if ( + object.leadingComments !== undefined && + object.leadingComments !== null + ) { + message.leadingComments = object.leadingComments; + } else { + message.leadingComments = ""; + } + if ( + object.trailingComments !== undefined && + object.trailingComments !== null + ) { + message.trailingComments = object.trailingComments; + } else { + message.trailingComments = ""; + } + if ( + object.leadingDetachedComments !== undefined && + object.leadingDetachedComments !== null + ) { + for (const e of object.leadingDetachedComments) { + message.leadingDetachedComments.push(e); + } + } + return message; + }, +}; + +const baseGeneratedCodeInfo: object = {}; + +export const GeneratedCodeInfo = { + encode(message: GeneratedCodeInfo, writer: Writer = Writer.create()): Writer { + for (const v of message.annotation) { + GeneratedCodeInfo_Annotation.encode( + v!, + writer.uint32(10).fork() + ).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): GeneratedCodeInfo { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseGeneratedCodeInfo } as GeneratedCodeInfo; + message.annotation = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.annotation.push( + GeneratedCodeInfo_Annotation.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GeneratedCodeInfo { + const message = { ...baseGeneratedCodeInfo } as GeneratedCodeInfo; + message.annotation = []; + if (object.annotation !== undefined && object.annotation !== null) { + for (const e of object.annotation) { + message.annotation.push(GeneratedCodeInfo_Annotation.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: GeneratedCodeInfo): unknown { + const obj: any = {}; + if (message.annotation) { + obj.annotation = message.annotation.map((e) => + e ? GeneratedCodeInfo_Annotation.toJSON(e) : undefined + ); + } else { + obj.annotation = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): GeneratedCodeInfo { + const message = { ...baseGeneratedCodeInfo } as GeneratedCodeInfo; + message.annotation = []; + if (object.annotation !== undefined && object.annotation !== null) { + for (const e of object.annotation) { + message.annotation.push(GeneratedCodeInfo_Annotation.fromPartial(e)); + } + } + return message; + }, +}; + +const baseGeneratedCodeInfo_Annotation: object = { + path: 0, + sourceFile: "", + begin: 0, + end: 0, +}; + +export const GeneratedCodeInfo_Annotation = { + encode( + message: GeneratedCodeInfo_Annotation, + writer: Writer = Writer.create() + ): Writer { + writer.uint32(10).fork(); + for (const v of message.path) { + writer.int32(v); + } + writer.ldelim(); + if (message.sourceFile !== "") { + writer.uint32(18).string(message.sourceFile); + } + if (message.begin !== 0) { + writer.uint32(24).int32(message.begin); + } + if (message.end !== 0) { + writer.uint32(32).int32(message.end); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): GeneratedCodeInfo_Annotation { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseGeneratedCodeInfo_Annotation, + } as GeneratedCodeInfo_Annotation; + message.path = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.path.push(reader.int32()); + } + } else { + message.path.push(reader.int32()); + } + break; + case 2: + message.sourceFile = reader.string(); + break; + case 3: + message.begin = reader.int32(); + break; + case 4: + message.end = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GeneratedCodeInfo_Annotation { + const message = { + ...baseGeneratedCodeInfo_Annotation, + } as GeneratedCodeInfo_Annotation; + message.path = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(Number(e)); + } + } + if (object.sourceFile !== undefined && object.sourceFile !== null) { + message.sourceFile = String(object.sourceFile); + } else { + message.sourceFile = ""; + } + if (object.begin !== undefined && object.begin !== null) { + message.begin = Number(object.begin); + } else { + message.begin = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + return message; + }, + + toJSON(message: GeneratedCodeInfo_Annotation): unknown { + const obj: any = {}; + if (message.path) { + obj.path = message.path.map((e) => e); + } else { + obj.path = []; + } + message.sourceFile !== undefined && (obj.sourceFile = message.sourceFile); + message.begin !== undefined && (obj.begin = message.begin); + message.end !== undefined && (obj.end = message.end); + return obj; + }, + + fromPartial( + object: DeepPartial + ): GeneratedCodeInfo_Annotation { + const message = { + ...baseGeneratedCodeInfo_Annotation, + } as GeneratedCodeInfo_Annotation; + message.path = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(e); + } + } + if (object.sourceFile !== undefined && object.sourceFile !== null) { + message.sourceFile = object.sourceFile; + } else { + message.sourceFile = ""; + } + if (object.begin !== undefined && object.begin !== null) { + message.begin = object.begin; + } else { + message.begin = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/cosmos.slashing.v1beta1/types/google/protobuf/duration.ts b/ts-client/cosmos.slashing.v1beta1/types/google/protobuf/duration.ts new file mode 100644 index 00000000..fffd5b14 --- /dev/null +++ b/ts-client/cosmos.slashing.v1beta1/types/google/protobuf/duration.ts @@ -0,0 +1,188 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "google.protobuf"; + +/** + * A Duration represents a signed, fixed-length span of time represented + * as a count of seconds and fractions of seconds at nanosecond + * resolution. It is independent of any calendar and concepts like "day" + * or "month". It is related to Timestamp in that the difference between + * two Timestamp values is a Duration and it can be added or subtracted + * from a Timestamp. Range is approximately +-10,000 years. + * + * # Examples + * + * Example 1: Compute Duration from two Timestamps in pseudo code. + * + * Timestamp start = ...; + * Timestamp end = ...; + * Duration duration = ...; + * + * duration.seconds = end.seconds - start.seconds; + * duration.nanos = end.nanos - start.nanos; + * + * if (duration.seconds < 0 && duration.nanos > 0) { + * duration.seconds += 1; + * duration.nanos -= 1000000000; + * } else if (duration.seconds > 0 && duration.nanos < 0) { + * duration.seconds -= 1; + * duration.nanos += 1000000000; + * } + * + * Example 2: Compute Timestamp from Timestamp + Duration in pseudo code. + * + * Timestamp start = ...; + * Duration duration = ...; + * Timestamp end = ...; + * + * end.seconds = start.seconds + duration.seconds; + * end.nanos = start.nanos + duration.nanos; + * + * if (end.nanos < 0) { + * end.seconds -= 1; + * end.nanos += 1000000000; + * } else if (end.nanos >= 1000000000) { + * end.seconds += 1; + * end.nanos -= 1000000000; + * } + * + * Example 3: Compute Duration from datetime.timedelta in Python. + * + * td = datetime.timedelta(days=3, minutes=10) + * duration = Duration() + * duration.FromTimedelta(td) + * + * # JSON Mapping + * + * In JSON format, the Duration type is encoded as a string rather than an + * object, where the string ends in the suffix "s" (indicating seconds) and + * is preceded by the number of seconds, with nanoseconds expressed as + * fractional seconds. For example, 3 seconds with 0 nanoseconds should be + * encoded in JSON format as "3s", while 3 seconds and 1 nanosecond should + * be expressed in JSON format as "3.000000001s", and 3 seconds and 1 + * microsecond should be expressed in JSON format as "3.000001s". + */ +export interface Duration { + /** + * Signed seconds of the span of time. Must be from -315,576,000,000 + * to +315,576,000,000 inclusive. Note: these bounds are computed from: + * 60 sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years + */ + seconds: number; + /** + * Signed fractions of a second at nanosecond resolution of the span + * of time. Durations less than one second are represented with a 0 + * `seconds` field and a positive or negative `nanos` field. For durations + * of one second or more, a non-zero value for the `nanos` field must be + * of the same sign as the `seconds` field. Must be from -999,999,999 + * to +999,999,999 inclusive. + */ + nanos: number; +} + +const baseDuration: object = { seconds: 0, nanos: 0 }; + +export const Duration = { + encode(message: Duration, writer: Writer = Writer.create()): Writer { + if (message.seconds !== 0) { + writer.uint32(8).int64(message.seconds); + } + if (message.nanos !== 0) { + writer.uint32(16).int32(message.nanos); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Duration { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseDuration } as Duration; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.seconds = longToNumber(reader.int64() as Long); + break; + case 2: + message.nanos = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Duration { + const message = { ...baseDuration } as Duration; + if (object.seconds !== undefined && object.seconds !== null) { + message.seconds = Number(object.seconds); + } else { + message.seconds = 0; + } + if (object.nanos !== undefined && object.nanos !== null) { + message.nanos = Number(object.nanos); + } else { + message.nanos = 0; + } + return message; + }, + + toJSON(message: Duration): unknown { + const obj: any = {}; + message.seconds !== undefined && (obj.seconds = message.seconds); + message.nanos !== undefined && (obj.nanos = message.nanos); + return obj; + }, + + fromPartial(object: DeepPartial): Duration { + const message = { ...baseDuration } as Duration; + if (object.seconds !== undefined && object.seconds !== null) { + message.seconds = object.seconds; + } else { + message.seconds = 0; + } + if (object.nanos !== undefined && object.nanos !== null) { + message.nanos = object.nanos; + } else { + message.nanos = 0; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/cosmos.slashing.v1beta1/types/google/protobuf/timestamp.ts b/ts-client/cosmos.slashing.v1beta1/types/google/protobuf/timestamp.ts new file mode 100644 index 00000000..11864afc --- /dev/null +++ b/ts-client/cosmos.slashing.v1beta1/types/google/protobuf/timestamp.ts @@ -0,0 +1,219 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "google.protobuf"; + +/** + * A Timestamp represents a point in time independent of any time zone or local + * calendar, encoded as a count of seconds and fractions of seconds at + * nanosecond resolution. The count is relative to an epoch at UTC midnight on + * January 1, 1970, in the proleptic Gregorian calendar which extends the + * Gregorian calendar backwards to year one. + * + * All minutes are 60 seconds long. Leap seconds are "smeared" so that no leap + * second table is needed for interpretation, using a [24-hour linear + * smear](https://developers.google.com/time/smear). + * + * The range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. By + * restricting to that range, we ensure that we can convert to and from [RFC + * 3339](https://www.ietf.org/rfc/rfc3339.txt) date strings. + * + * # Examples + * + * Example 1: Compute Timestamp from POSIX `time()`. + * + * Timestamp timestamp; + * timestamp.set_seconds(time(NULL)); + * timestamp.set_nanos(0); + * + * Example 2: Compute Timestamp from POSIX `gettimeofday()`. + * + * struct timeval tv; + * gettimeofday(&tv, NULL); + * + * Timestamp timestamp; + * timestamp.set_seconds(tv.tv_sec); + * timestamp.set_nanos(tv.tv_usec * 1000); + * + * Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`. + * + * FILETIME ft; + * GetSystemTimeAsFileTime(&ft); + * UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime; + * + * // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z + * // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z. + * Timestamp timestamp; + * timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL)); + * timestamp.set_nanos((INT32) ((ticks % 10000000) * 100)); + * + * Example 4: Compute Timestamp from Java `System.currentTimeMillis()`. + * + * long millis = System.currentTimeMillis(); + * + * Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000) + * .setNanos((int) ((millis % 1000) * 1000000)).build(); + * + * + * Example 5: Compute Timestamp from Java `Instant.now()`. + * + * Instant now = Instant.now(); + * + * Timestamp timestamp = + * Timestamp.newBuilder().setSeconds(now.getEpochSecond()) + * .setNanos(now.getNano()).build(); + * + * + * Example 6: Compute Timestamp from current time in Python. + * + * timestamp = Timestamp() + * timestamp.GetCurrentTime() + * + * # JSON Mapping + * + * In JSON format, the Timestamp type is encoded as a string in the + * [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the + * format is "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z" + * where {year} is always expressed using four digits while {month}, {day}, + * {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional + * seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution), + * are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone + * is required. A proto3 JSON serializer should always use UTC (as indicated by + * "Z") when printing the Timestamp type and a proto3 JSON parser should be + * able to accept both UTC and other timezones (as indicated by an offset). + * + * For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past + * 01:30 UTC on January 15, 2017. + * + * In JavaScript, one can convert a Date object to this format using the + * standard + * [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString) + * method. In Python, a standard `datetime.datetime` object can be converted + * to this format using + * [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) with + * the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one can use + * the Joda Time's [`ISODateTimeFormat.dateTime()`]( + * http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime%2D%2D + * ) to obtain a formatter capable of generating timestamps in this format. + */ +export interface Timestamp { + /** + * Represents seconds of UTC time since Unix epoch + * 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to + * 9999-12-31T23:59:59Z inclusive. + */ + seconds: number; + /** + * Non-negative fractions of a second at nanosecond resolution. Negative + * second values with fractions must still have non-negative nanos values + * that count forward in time. Must be from 0 to 999,999,999 + * inclusive. + */ + nanos: number; +} + +const baseTimestamp: object = { seconds: 0, nanos: 0 }; + +export const Timestamp = { + encode(message: Timestamp, writer: Writer = Writer.create()): Writer { + if (message.seconds !== 0) { + writer.uint32(8).int64(message.seconds); + } + if (message.nanos !== 0) { + writer.uint32(16).int32(message.nanos); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Timestamp { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseTimestamp } as Timestamp; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.seconds = longToNumber(reader.int64() as Long); + break; + case 2: + message.nanos = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Timestamp { + const message = { ...baseTimestamp } as Timestamp; + if (object.seconds !== undefined && object.seconds !== null) { + message.seconds = Number(object.seconds); + } else { + message.seconds = 0; + } + if (object.nanos !== undefined && object.nanos !== null) { + message.nanos = Number(object.nanos); + } else { + message.nanos = 0; + } + return message; + }, + + toJSON(message: Timestamp): unknown { + const obj: any = {}; + message.seconds !== undefined && (obj.seconds = message.seconds); + message.nanos !== undefined && (obj.nanos = message.nanos); + return obj; + }, + + fromPartial(object: DeepPartial): Timestamp { + const message = { ...baseTimestamp } as Timestamp; + if (object.seconds !== undefined && object.seconds !== null) { + message.seconds = object.seconds; + } else { + message.seconds = 0; + } + if (object.nanos !== undefined && object.nanos !== null) { + message.nanos = object.nanos; + } else { + message.nanos = 0; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/cosmos.staking.v1beta1/index.ts b/ts-client/cosmos.staking.v1beta1/index.ts new file mode 100755 index 00000000..c9dfa159 --- /dev/null +++ b/ts-client/cosmos.staking.v1beta1/index.ts @@ -0,0 +1,6 @@ +import Module from './module'; +import { txClient, queryClient, registry } from './module'; +import { msgTypes } from './registry'; + +export * from "./types"; +export { Module, msgTypes, txClient, queryClient, registry }; diff --git a/ts-client/cosmos.staking.v1beta1/module.ts b/ts-client/cosmos.staking.v1beta1/module.ts new file mode 100755 index 00000000..2be5315e --- /dev/null +++ b/ts-client/cosmos.staking.v1beta1/module.ts @@ -0,0 +1,231 @@ +// Generated by Ignite ignite.com/cli + +import { StdFee } from "@cosmjs/launchpad"; +import { SigningStargateClient, DeliverTxResponse } from "@cosmjs/stargate"; +import { EncodeObject, GeneratedType, OfflineSigner, Registry } from "@cosmjs/proto-signing"; +import { msgTypes } from './registry'; +import { IgniteClient } from "../client" +import { MissingWalletError } from "../helpers" +import { Api } from "./rest"; +import { MsgEditValidator } from "./types/cosmos/staking/v1beta1/tx"; +import { MsgUndelegate } from "./types/cosmos/staking/v1beta1/tx"; +import { MsgDelegate } from "./types/cosmos/staking/v1beta1/tx"; +import { MsgCreateValidator } from "./types/cosmos/staking/v1beta1/tx"; +import { MsgBeginRedelegate } from "./types/cosmos/staking/v1beta1/tx"; + + +export { MsgEditValidator, MsgUndelegate, MsgDelegate, MsgCreateValidator, MsgBeginRedelegate }; + +type sendMsgEditValidatorParams = { + value: MsgEditValidator, + fee?: StdFee, + memo?: string +}; + +type sendMsgUndelegateParams = { + value: MsgUndelegate, + fee?: StdFee, + memo?: string +}; + +type sendMsgDelegateParams = { + value: MsgDelegate, + fee?: StdFee, + memo?: string +}; + +type sendMsgCreateValidatorParams = { + value: MsgCreateValidator, + fee?: StdFee, + memo?: string +}; + +type sendMsgBeginRedelegateParams = { + value: MsgBeginRedelegate, + fee?: StdFee, + memo?: string +}; + + +type msgEditValidatorParams = { + value: MsgEditValidator, +}; + +type msgUndelegateParams = { + value: MsgUndelegate, +}; + +type msgDelegateParams = { + value: MsgDelegate, +}; + +type msgCreateValidatorParams = { + value: MsgCreateValidator, +}; + +type msgBeginRedelegateParams = { + value: MsgBeginRedelegate, +}; + + +export const registry = new Registry(msgTypes); + +const defaultFee = { + amount: [], + gas: "200000", +}; + +interface TxClientOptions { + addr: string + prefix: string + signer?: OfflineSigner +} + +export const txClient = ({ signer, prefix, addr }: TxClientOptions = { addr: "http://localhost:26657", prefix: "cosmos" }) => { + + return { + + async sendMsgEditValidator({ value, fee, memo }: sendMsgEditValidatorParams): Promise { + if (!signer) { + throw new Error('TxClient:sendMsgEditValidator: Unable to sign Tx. Signer is not present.') + } + try { + const { address } = (await signer.getAccounts())[0]; + const signingClient = await SigningStargateClient.connectWithSigner(addr,signer,{registry, prefix}); + let msg = this.msgEditValidator({ value: MsgEditValidator.fromPartial(value) }) + return await signingClient.signAndBroadcast(address, [msg], fee ? fee : defaultFee, memo) + } catch (e: any) { + throw new Error('TxClient:sendMsgEditValidator: Could not broadcast Tx: '+ e.message) + } + }, + + async sendMsgUndelegate({ value, fee, memo }: sendMsgUndelegateParams): Promise { + if (!signer) { + throw new Error('TxClient:sendMsgUndelegate: Unable to sign Tx. Signer is not present.') + } + try { + const { address } = (await signer.getAccounts())[0]; + const signingClient = await SigningStargateClient.connectWithSigner(addr,signer,{registry, prefix}); + let msg = this.msgUndelegate({ value: MsgUndelegate.fromPartial(value) }) + return await signingClient.signAndBroadcast(address, [msg], fee ? fee : defaultFee, memo) + } catch (e: any) { + throw new Error('TxClient:sendMsgUndelegate: Could not broadcast Tx: '+ e.message) + } + }, + + async sendMsgDelegate({ value, fee, memo }: sendMsgDelegateParams): Promise { + if (!signer) { + throw new Error('TxClient:sendMsgDelegate: Unable to sign Tx. Signer is not present.') + } + try { + const { address } = (await signer.getAccounts())[0]; + const signingClient = await SigningStargateClient.connectWithSigner(addr,signer,{registry, prefix}); + let msg = this.msgDelegate({ value: MsgDelegate.fromPartial(value) }) + return await signingClient.signAndBroadcast(address, [msg], fee ? fee : defaultFee, memo) + } catch (e: any) { + throw new Error('TxClient:sendMsgDelegate: Could not broadcast Tx: '+ e.message) + } + }, + + async sendMsgCreateValidator({ value, fee, memo }: sendMsgCreateValidatorParams): Promise { + if (!signer) { + throw new Error('TxClient:sendMsgCreateValidator: Unable to sign Tx. Signer is not present.') + } + try { + const { address } = (await signer.getAccounts())[0]; + const signingClient = await SigningStargateClient.connectWithSigner(addr,signer,{registry, prefix}); + let msg = this.msgCreateValidator({ value: MsgCreateValidator.fromPartial(value) }) + return await signingClient.signAndBroadcast(address, [msg], fee ? fee : defaultFee, memo) + } catch (e: any) { + throw new Error('TxClient:sendMsgCreateValidator: Could not broadcast Tx: '+ e.message) + } + }, + + async sendMsgBeginRedelegate({ value, fee, memo }: sendMsgBeginRedelegateParams): Promise { + if (!signer) { + throw new Error('TxClient:sendMsgBeginRedelegate: Unable to sign Tx. Signer is not present.') + } + try { + const { address } = (await signer.getAccounts())[0]; + const signingClient = await SigningStargateClient.connectWithSigner(addr,signer,{registry, prefix}); + let msg = this.msgBeginRedelegate({ value: MsgBeginRedelegate.fromPartial(value) }) + return await signingClient.signAndBroadcast(address, [msg], fee ? fee : defaultFee, memo) + } catch (e: any) { + throw new Error('TxClient:sendMsgBeginRedelegate: Could not broadcast Tx: '+ e.message) + } + }, + + + msgEditValidator({ value }: msgEditValidatorParams): EncodeObject { + try { + return { typeUrl: "/cosmos.staking.v1beta1.MsgEditValidator", value: MsgEditValidator.fromPartial( value ) } + } catch (e: any) { + throw new Error('TxClient:MsgEditValidator: Could not create message: ' + e.message) + } + }, + + msgUndelegate({ value }: msgUndelegateParams): EncodeObject { + try { + return { typeUrl: "/cosmos.staking.v1beta1.MsgUndelegate", value: MsgUndelegate.fromPartial( value ) } + } catch (e: any) { + throw new Error('TxClient:MsgUndelegate: Could not create message: ' + e.message) + } + }, + + msgDelegate({ value }: msgDelegateParams): EncodeObject { + try { + return { typeUrl: "/cosmos.staking.v1beta1.MsgDelegate", value: MsgDelegate.fromPartial( value ) } + } catch (e: any) { + throw new Error('TxClient:MsgDelegate: Could not create message: ' + e.message) + } + }, + + msgCreateValidator({ value }: msgCreateValidatorParams): EncodeObject { + try { + return { typeUrl: "/cosmos.staking.v1beta1.MsgCreateValidator", value: MsgCreateValidator.fromPartial( value ) } + } catch (e: any) { + throw new Error('TxClient:MsgCreateValidator: Could not create message: ' + e.message) + } + }, + + msgBeginRedelegate({ value }: msgBeginRedelegateParams): EncodeObject { + try { + return { typeUrl: "/cosmos.staking.v1beta1.MsgBeginRedelegate", value: MsgBeginRedelegate.fromPartial( value ) } + } catch (e: any) { + throw new Error('TxClient:MsgBeginRedelegate: Could not create message: ' + e.message) + } + }, + + } +}; + +interface QueryClientOptions { + addr: string +} + +export const queryClient = ({ addr: addr }: QueryClientOptions = { addr: "http://localhost:1317" }) => { + return new Api({ baseUrl: addr }); +}; + +class SDKModule { + public query: ReturnType; + public tx: ReturnType; + + public registry: Array<[string, GeneratedType]>; + + constructor(client: IgniteClient) { + + this.query = queryClient({ addr: client.env.apiURL }); + this.tx = txClient({ signer: client.signer, addr: client.env.rpcURL, prefix: client.env.prefix ?? "cosmos" }); + } +}; + +const Module = (test: IgniteClient) => { + return { + module: { + CosmosStakingV1Beta1: new SDKModule(test) + }, + registry: msgTypes + } +} +export default Module; \ No newline at end of file diff --git a/ts-client/cosmos.staking.v1beta1/registry.ts b/ts-client/cosmos.staking.v1beta1/registry.ts new file mode 100755 index 00000000..6af7f690 --- /dev/null +++ b/ts-client/cosmos.staking.v1beta1/registry.ts @@ -0,0 +1,17 @@ +import { GeneratedType } from "@cosmjs/proto-signing"; +import { MsgEditValidator } from "./types/cosmos/staking/v1beta1/tx"; +import { MsgUndelegate } from "./types/cosmos/staking/v1beta1/tx"; +import { MsgDelegate } from "./types/cosmos/staking/v1beta1/tx"; +import { MsgCreateValidator } from "./types/cosmos/staking/v1beta1/tx"; +import { MsgBeginRedelegate } from "./types/cosmos/staking/v1beta1/tx"; + +const msgTypes: Array<[string, GeneratedType]> = [ + ["/cosmos.staking.v1beta1.MsgEditValidator", MsgEditValidator], + ["/cosmos.staking.v1beta1.MsgUndelegate", MsgUndelegate], + ["/cosmos.staking.v1beta1.MsgDelegate", MsgDelegate], + ["/cosmos.staking.v1beta1.MsgCreateValidator", MsgCreateValidator], + ["/cosmos.staking.v1beta1.MsgBeginRedelegate", MsgBeginRedelegate], + +]; + +export { msgTypes } \ No newline at end of file diff --git a/ts-client/cosmos.staking.v1beta1/rest.ts b/ts-client/cosmos.staking.v1beta1/rest.ts new file mode 100644 index 00000000..9cf97f4d --- /dev/null +++ b/ts-client/cosmos.staking.v1beta1/rest.ts @@ -0,0 +1,1268 @@ +/* eslint-disable */ +/* tslint:disable */ +/* + * --------------------------------------------------------------- + * ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ## + * ## ## + * ## AUTHOR: acacode ## + * ## SOURCE: https://github.com/acacode/swagger-typescript-api ## + * --------------------------------------------------------------- + */ + +/** +* `Any` contains an arbitrary serialized protocol buffer message along with a +URL that describes the type of the serialized message. + +Protobuf library provides support to pack/unpack Any values in the form +of utility functions or additional generated methods of the Any type. + +Example 1: Pack and unpack a message in C++. + + Foo foo = ...; + Any any; + any.PackFrom(foo); + ... + if (any.UnpackTo(&foo)) { + ... + } + +Example 2: Pack and unpack a message in Java. + + Foo foo = ...; + Any any = Any.pack(foo); + ... + if (any.is(Foo.class)) { + foo = any.unpack(Foo.class); + } + + Example 3: Pack and unpack a message in Python. + + foo = Foo(...) + any = Any() + any.Pack(foo) + ... + if any.Is(Foo.DESCRIPTOR): + any.Unpack(foo) + ... + + Example 4: Pack and unpack a message in Go + + foo := &pb.Foo{...} + any, err := anypb.New(foo) + if err != nil { + ... + } + ... + foo := &pb.Foo{} + if err := any.UnmarshalTo(foo); err != nil { + ... + } + +The pack methods provided by protobuf library will by default use +'type.googleapis.com/full.type.name' as the type URL and the unpack +methods only use the fully qualified type name after the last '/' +in the type URL, for example "foo.bar.com/x/y.z" will yield type +name "y.z". + + +JSON +==== +The JSON representation of an `Any` value uses the regular +representation of the deserialized, embedded message, with an +additional field `@type` which contains the type URL. Example: + + package google.profile; + message Person { + string first_name = 1; + string last_name = 2; + } + + { + "@type": "type.googleapis.com/google.profile.Person", + "firstName": , + "lastName": + } + +If the embedded message type is well-known and has a custom JSON +representation, that representation will be embedded adding a field +`value` which holds the custom JSON in addition to the `@type` +field. Example (for message [google.protobuf.Duration][]): + + { + "@type": "type.googleapis.com/google.protobuf.Duration", + "value": "1.212s" + } +*/ +export interface ProtobufAny { + /** + * A URL/resource name that uniquely identifies the type of the serialized + * protocol buffer message. This string must contain at least + * one "/" character. The last segment of the URL's path must represent + * the fully qualified name of the type (as in + * `path/google.protobuf.Duration`). The name should be in a canonical form + * (e.g., leading "." is not accepted). + * + * In practice, teams usually precompile into the binary all types that they + * expect it to use in the context of Any. However, for URLs which use the + * scheme `http`, `https`, or no scheme, one can optionally set up a type + * server that maps type URLs to message definitions as follows: + * + * * If no scheme is provided, `https` is assumed. + * * An HTTP GET on the URL must yield a [google.protobuf.Type][] + * value in binary format, or produce an error. + * * Applications are allowed to cache lookup results based on the + * URL, or have them precompiled into a binary to avoid any + * lookup. Therefore, binary compatibility needs to be preserved + * on changes to types. (Use versioned type names to manage + * breaking changes.) + * + * Note: this functionality is not currently available in the official + * protobuf release, and it is not used for type URLs beginning with + * type.googleapis.com. + * + * Schemes other than `http`, `https` (or the empty scheme) might be + * used with implementation specific semantics. + */ + "@type"?: string; +} + +export interface RpcStatus { + /** @format int32 */ + code?: number; + message?: string; + details?: ProtobufAny[]; +} + +/** +* Delegation represents the bond with tokens held by an account. It is +owned by one delegator, and is associated with the voting power of one +validator. +*/ +export interface Stakingv1Beta1Delegation { + /** delegator_address is the bech32-encoded address of the delegator. */ + delegator_address?: string; + + /** validator_address is the bech32-encoded address of the validator. */ + validator_address?: string; + + /** shares define the delegation shares received. */ + shares?: string; +} + +/** +* HistoricalInfo contains header and validator information for a given block. +It is stored as part of staking module's state, which persists the `n` most +recent HistoricalInfo +(`n` is set by the staking module's `historical_entries` parameter). +*/ +export interface Stakingv1Beta1HistoricalInfo { + /** Header defines the structure of a block header. */ + header?: TypesHeader; + valset?: Stakingv1Beta1Validator[]; +} + +/** + * Params defines the parameters for the staking module. + */ +export interface Stakingv1Beta1Params { + /** unbonding_time is the time duration of unbonding. */ + unbonding_time?: string; + + /** + * max_validators is the maximum number of validators. + * @format int64 + */ + max_validators?: number; + + /** + * max_entries is the max entries for either unbonding delegation or redelegation (per pair/trio). + * @format int64 + */ + max_entries?: number; + + /** + * historical_entries is the number of historical entries to persist. + * @format int64 + */ + historical_entries?: number; + + /** bond_denom defines the bondable coin denomination. */ + bond_denom?: string; +} + +/** +* Pool is used for tracking bonded and not-bonded token supply of the bond +denomination. +*/ +export interface Stakingv1Beta1Pool { + not_bonded_tokens?: string; + bonded_tokens?: string; +} + +/** +* UnbondingDelegation stores all of a single delegator's unbonding bonds +for a single validator in an time-ordered list. +*/ +export interface Stakingv1Beta1UnbondingDelegation { + /** delegator_address is the bech32-encoded address of the delegator. */ + delegator_address?: string; + + /** validator_address is the bech32-encoded address of the validator. */ + validator_address?: string; + + /** + * entries are the unbonding delegation entries. + * + * unbonding delegation entries + */ + entries?: V1Beta1UnbondingDelegationEntry[]; +} + +/** +* Validator defines a validator, together with the total amount of the +Validator's bond shares and their exchange rate to coins. Slashing results in +a decrease in the exchange rate, allowing correct calculation of future +undelegations without iterating over delegators. When coins are delegated to +this validator, the validator is credited with a delegation whose number of +bond shares is based on the amount of coins delegated divided by the current +exchange rate. Voting power can be calculated as total bonded shares +multiplied by exchange rate. +*/ +export interface Stakingv1Beta1Validator { + /** operator_address defines the address of the validator's operator; bech encoded in JSON. */ + operator_address?: string; + + /** consensus_pubkey is the consensus public key of the validator, as a Protobuf Any. */ + consensus_pubkey?: ProtobufAny; + + /** jailed defined whether the validator has been jailed from bonded status or not. */ + jailed?: boolean; + + /** status is the validator status (bonded/unbonding/unbonded). */ + status?: V1Beta1BondStatus; + + /** tokens define the delegated tokens (incl. self-delegation). */ + tokens?: string; + + /** delegator_shares defines total shares issued to a validator's delegators. */ + delegator_shares?: string; + + /** description defines the description terms for the validator. */ + description?: V1Beta1Description; + + /** + * unbonding_height defines, if unbonding, the height at which this validator has begun unbonding. + * @format int64 + */ + unbonding_height?: string; + + /** + * unbonding_time defines, if unbonding, the min time for the validator to complete unbonding. + * @format date-time + */ + unbonding_time?: string; + + /** commission defines the commission parameters. */ + commission?: V1Beta1Commission; + + /** min_self_delegation is the validator's self declared minimum self delegation. */ + min_self_delegation?: string; +} + +export interface TypesBlockID { + /** @format byte */ + hash?: string; + part_set_header?: TypesPartSetHeader; +} + +/** + * Header defines the structure of a block header. + */ +export interface TypesHeader { + /** + * Consensus captures the consensus rules for processing a block in the blockchain, + * including all blockchain data structures and the rules of the application's + * state transition machine. + */ + version?: VersionConsensus; + chain_id?: string; + + /** @format int64 */ + height?: string; + + /** @format date-time */ + time?: string; + last_block_id?: TypesBlockID; + + /** + * commit from validators from the last block + * @format byte + */ + last_commit_hash?: string; + + /** @format byte */ + data_hash?: string; + + /** + * validators for the current block + * @format byte + */ + validators_hash?: string; + + /** @format byte */ + next_validators_hash?: string; + + /** @format byte */ + consensus_hash?: string; + + /** @format byte */ + app_hash?: string; + + /** @format byte */ + last_results_hash?: string; + + /** + * evidence included in the block + * @format byte + */ + evidence_hash?: string; + + /** @format byte */ + proposer_address?: string; +} + +export interface TypesPartSetHeader { + /** @format int64 */ + total?: number; + + /** @format byte */ + hash?: string; +} + +/** +* BondStatus is the status of a validator. + + - BOND_STATUS_UNSPECIFIED: UNSPECIFIED defines an invalid validator status. + - BOND_STATUS_UNBONDED: UNBONDED defines a validator that is not bonded. + - BOND_STATUS_UNBONDING: UNBONDING defines a validator that is unbonding. + - BOND_STATUS_BONDED: BONDED defines a validator that is bonded. +*/ +export enum V1Beta1BondStatus { + BOND_STATUS_UNSPECIFIED = "BOND_STATUS_UNSPECIFIED", + BOND_STATUS_UNBONDED = "BOND_STATUS_UNBONDED", + BOND_STATUS_UNBONDING = "BOND_STATUS_UNBONDING", + BOND_STATUS_BONDED = "BOND_STATUS_BONDED", +} + +/** +* Coin defines a token with a denomination and an amount. + +NOTE: The amount field is an Int which implements the custom method +signatures required by gogoproto. +*/ +export interface V1Beta1Coin { + denom?: string; + amount?: string; +} + +/** + * Commission defines commission parameters for a given validator. + */ +export interface V1Beta1Commission { + /** commission_rates defines the initial commission rates to be used for creating a validator. */ + commission_rates?: V1Beta1CommissionRates; + + /** + * update_time is the last time the commission rate was changed. + * @format date-time + */ + update_time?: string; +} + +/** +* CommissionRates defines the initial commission rates to be used for creating +a validator. +*/ +export interface V1Beta1CommissionRates { + /** rate is the commission rate charged to delegators, as a fraction. */ + rate?: string; + + /** max_rate defines the maximum commission rate which validator can ever charge, as a fraction. */ + max_rate?: string; + + /** max_change_rate defines the maximum daily increase of the validator commission, as a fraction. */ + max_change_rate?: string; +} + +/** +* DelegationResponse is equivalent to Delegation except that it contains a +balance in addition to shares which is more suitable for client responses. +*/ +export interface V1Beta1DelegationResponse { + /** + * Delegation represents the bond with tokens held by an account. It is + * owned by one delegator, and is associated with the voting power of one + * validator. + */ + delegation?: Stakingv1Beta1Delegation; + + /** + * Coin defines a token with a denomination and an amount. + * + * NOTE: The amount field is an Int which implements the custom method + * signatures required by gogoproto. + */ + balance?: V1Beta1Coin; +} + +/** + * Description defines a validator description. + */ +export interface V1Beta1Description { + /** moniker defines a human-readable name for the validator. */ + moniker?: string; + + /** identity defines an optional identity signature (ex. UPort or Keybase). */ + identity?: string; + + /** website defines an optional website link. */ + website?: string; + + /** security_contact defines an optional email for security contact. */ + security_contact?: string; + + /** details define other optional details. */ + details?: string; +} + +/** + * MsgBeginRedelegateResponse defines the Msg/BeginRedelegate response type. + */ +export interface V1Beta1MsgBeginRedelegateResponse { + /** @format date-time */ + completion_time?: string; +} + +/** + * MsgCreateValidatorResponse defines the Msg/CreateValidator response type. + */ +export type V1Beta1MsgCreateValidatorResponse = object; + +/** + * MsgDelegateResponse defines the Msg/Delegate response type. + */ +export type V1Beta1MsgDelegateResponse = object; + +/** + * MsgEditValidatorResponse defines the Msg/EditValidator response type. + */ +export type V1Beta1MsgEditValidatorResponse = object; + +/** + * MsgUndelegateResponse defines the Msg/Undelegate response type. + */ +export interface V1Beta1MsgUndelegateResponse { + /** @format date-time */ + completion_time?: string; +} + +/** +* message SomeRequest { + Foo some_parameter = 1; + PageRequest pagination = 2; + } +*/ +export interface V1Beta1PageRequest { + /** + * key is a value returned in PageResponse.next_key to begin + * querying the next page most efficiently. Only one of offset or key + * should be set. + * @format byte + */ + key?: string; + + /** + * offset is a numeric offset that can be used when key is unavailable. + * It is less efficient than using key. Only one of offset or key should + * be set. + * @format uint64 + */ + offset?: string; + + /** + * limit is the total number of results to be returned in the result page. + * If left empty it will default to a value to be set by each app. + * @format uint64 + */ + limit?: string; + + /** + * count_total is set to true to indicate that the result set should include + * a count of the total number of items available for pagination in UIs. + * count_total is only respected when offset is used. It is ignored when key + * is set. + */ + count_total?: boolean; + + /** + * reverse is set to true if results are to be returned in the descending order. + * + * Since: cosmos-sdk 0.43 + */ + reverse?: boolean; +} + +/** +* PageResponse is to be embedded in gRPC response messages where the +corresponding request message has used PageRequest. + + message SomeResponse { + repeated Bar results = 1; + PageResponse page = 2; + } +*/ +export interface V1Beta1PageResponse { + /** @format byte */ + next_key?: string; + + /** @format uint64 */ + total?: string; +} + +/** + * QueryDelegationResponse is response type for the Query/Delegation RPC method. + */ +export interface V1Beta1QueryDelegationResponse { + /** delegation_responses defines the delegation info of a delegation. */ + delegation_response?: V1Beta1DelegationResponse; +} + +/** +* QueryDelegatorDelegationsResponse is response type for the +Query/DelegatorDelegations RPC method. +*/ +export interface V1Beta1QueryDelegatorDelegationsResponse { + /** delegation_responses defines all the delegations' info of a delegator. */ + delegation_responses?: V1Beta1DelegationResponse[]; + + /** pagination defines the pagination in the response. */ + pagination?: V1Beta1PageResponse; +} + +/** +* QueryUnbondingDelegatorDelegationsResponse is response type for the +Query/UnbondingDelegatorDelegations RPC method. +*/ +export interface V1Beta1QueryDelegatorUnbondingDelegationsResponse { + unbonding_responses?: Stakingv1Beta1UnbondingDelegation[]; + + /** pagination defines the pagination in the response. */ + pagination?: V1Beta1PageResponse; +} + +/** +* QueryDelegatorValidatorResponse response type for the +Query/DelegatorValidator RPC method. +*/ +export interface V1Beta1QueryDelegatorValidatorResponse { + /** validator defines the the validator info. */ + validator?: Stakingv1Beta1Validator; +} + +/** +* QueryDelegatorValidatorsResponse is response type for the +Query/DelegatorValidators RPC method. +*/ +export interface V1Beta1QueryDelegatorValidatorsResponse { + /** validators defines the the validators' info of a delegator. */ + validators?: Stakingv1Beta1Validator[]; + + /** pagination defines the pagination in the response. */ + pagination?: V1Beta1PageResponse; +} + +/** +* QueryHistoricalInfoResponse is response type for the Query/HistoricalInfo RPC +method. +*/ +export interface V1Beta1QueryHistoricalInfoResponse { + /** hist defines the historical info at the given height. */ + hist?: Stakingv1Beta1HistoricalInfo; +} + +/** + * QueryParamsResponse is response type for the Query/Params RPC method. + */ +export interface V1Beta1QueryParamsResponse { + /** params holds all the parameters of this module. */ + params?: Stakingv1Beta1Params; +} + +/** + * QueryPoolResponse is response type for the Query/Pool RPC method. + */ +export interface V1Beta1QueryPoolResponse { + /** pool defines the pool info. */ + pool?: Stakingv1Beta1Pool; +} + +/** +* QueryRedelegationsResponse is response type for the Query/Redelegations RPC +method. +*/ +export interface V1Beta1QueryRedelegationsResponse { + redelegation_responses?: V1Beta1RedelegationResponse[]; + + /** pagination defines the pagination in the response. */ + pagination?: V1Beta1PageResponse; +} + +/** +* QueryDelegationResponse is response type for the Query/UnbondingDelegation +RPC method. +*/ +export interface V1Beta1QueryUnbondingDelegationResponse { + /** unbond defines the unbonding information of a delegation. */ + unbond?: Stakingv1Beta1UnbondingDelegation; +} + +export interface V1Beta1QueryValidatorDelegationsResponse { + delegation_responses?: V1Beta1DelegationResponse[]; + + /** pagination defines the pagination in the response. */ + pagination?: V1Beta1PageResponse; +} + +export interface V1Beta1QueryValidatorResponse { + /** validator defines the the validator info. */ + validator?: Stakingv1Beta1Validator; +} + +/** +* QueryValidatorUnbondingDelegationsResponse is response type for the +Query/ValidatorUnbondingDelegations RPC method. +*/ +export interface V1Beta1QueryValidatorUnbondingDelegationsResponse { + unbonding_responses?: Stakingv1Beta1UnbondingDelegation[]; + + /** pagination defines the pagination in the response. */ + pagination?: V1Beta1PageResponse; +} + +export interface V1Beta1QueryValidatorsResponse { + /** validators contains all the queried validators. */ + validators?: Stakingv1Beta1Validator[]; + + /** pagination defines the pagination in the response. */ + pagination?: V1Beta1PageResponse; +} + +/** +* Redelegation contains the list of a particular delegator's redelegating bonds +from a particular source validator to a particular destination validator. +*/ +export interface V1Beta1Redelegation { + /** delegator_address is the bech32-encoded address of the delegator. */ + delegator_address?: string; + + /** validator_src_address is the validator redelegation source operator address. */ + validator_src_address?: string; + + /** validator_dst_address is the validator redelegation destination operator address. */ + validator_dst_address?: string; + + /** + * entries are the redelegation entries. + * + * redelegation entries + */ + entries?: V1Beta1RedelegationEntry[]; +} + +/** + * RedelegationEntry defines a redelegation object with relevant metadata. + */ +export interface V1Beta1RedelegationEntry { + /** + * creation_height defines the height which the redelegation took place. + * @format int64 + */ + creation_height?: string; + + /** + * completion_time defines the unix time for redelegation completion. + * @format date-time + */ + completion_time?: string; + + /** initial_balance defines the initial balance when redelegation started. */ + initial_balance?: string; + + /** shares_dst is the amount of destination-validator shares created by redelegation. */ + shares_dst?: string; +} + +/** +* RedelegationEntryResponse is equivalent to a RedelegationEntry except that it +contains a balance in addition to shares which is more suitable for client +responses. +*/ +export interface V1Beta1RedelegationEntryResponse { + /** RedelegationEntry defines a redelegation object with relevant metadata. */ + redelegation_entry?: V1Beta1RedelegationEntry; + balance?: string; +} + +/** +* RedelegationResponse is equivalent to a Redelegation except that its entries +contain a balance in addition to shares which is more suitable for client +responses. +*/ +export interface V1Beta1RedelegationResponse { + /** + * Redelegation contains the list of a particular delegator's redelegating bonds + * from a particular source validator to a particular destination validator. + */ + redelegation?: V1Beta1Redelegation; + entries?: V1Beta1RedelegationEntryResponse[]; +} + +/** + * UnbondingDelegationEntry defines an unbonding object with relevant metadata. + */ +export interface V1Beta1UnbondingDelegationEntry { + /** + * creation_height is the height which the unbonding took place. + * @format int64 + */ + creation_height?: string; + + /** + * completion_time is the unix time for unbonding completion. + * @format date-time + */ + completion_time?: string; + + /** initial_balance defines the tokens initially scheduled to receive at completion. */ + initial_balance?: string; + + /** balance defines the tokens to receive at completion. */ + balance?: string; +} + +/** +* Consensus captures the consensus rules for processing a block in the blockchain, +including all blockchain data structures and the rules of the application's +state transition machine. +*/ +export interface VersionConsensus { + /** @format uint64 */ + block?: string; + + /** @format uint64 */ + app?: string; +} + +export type QueryParamsType = Record; +export type ResponseFormat = keyof Omit; + +export interface FullRequestParams extends Omit { + /** set parameter to `true` for call `securityWorker` for this request */ + secure?: boolean; + /** request path */ + path: string; + /** content type of request body */ + type?: ContentType; + /** query params */ + query?: QueryParamsType; + /** format of response (i.e. response.json() -> format: "json") */ + format?: keyof Omit; + /** request body */ + body?: unknown; + /** base url */ + baseUrl?: string; + /** request cancellation token */ + cancelToken?: CancelToken; +} + +export type RequestParams = Omit; + +export interface ApiConfig { + baseUrl?: string; + baseApiParams?: Omit; + securityWorker?: (securityData: SecurityDataType) => RequestParams | void; +} + +export interface HttpResponse extends Response { + data: D; + error: E; +} + +type CancelToken = Symbol | string | number; + +export enum ContentType { + Json = "application/json", + FormData = "multipart/form-data", + UrlEncoded = "application/x-www-form-urlencoded", +} + +export class HttpClient { + public baseUrl: string = ""; + private securityData: SecurityDataType = null as any; + private securityWorker: null | ApiConfig["securityWorker"] = null; + private abortControllers = new Map(); + + private baseApiParams: RequestParams = { + credentials: "same-origin", + headers: {}, + redirect: "follow", + referrerPolicy: "no-referrer", + }; + + constructor(apiConfig: ApiConfig = {}) { + Object.assign(this, apiConfig); + } + + public setSecurityData = (data: SecurityDataType) => { + this.securityData = data; + }; + + private addQueryParam(query: QueryParamsType, key: string) { + const value = query[key]; + + return ( + encodeURIComponent(key) + + "=" + + encodeURIComponent(Array.isArray(value) ? value.join(",") : typeof value === "number" ? value : `${value}`) + ); + } + + protected toQueryString(rawQuery?: QueryParamsType): string { + const query = rawQuery || {}; + const keys = Object.keys(query).filter((key) => "undefined" !== typeof query[key]); + return keys + .map((key) => + typeof query[key] === "object" && !Array.isArray(query[key]) + ? this.toQueryString(query[key] as QueryParamsType) + : this.addQueryParam(query, key), + ) + .join("&"); + } + + protected addQueryParams(rawQuery?: QueryParamsType): string { + const queryString = this.toQueryString(rawQuery); + return queryString ? `?${queryString}` : ""; + } + + private contentFormatters: Record any> = { + [ContentType.Json]: (input: any) => + input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input, + [ContentType.FormData]: (input: any) => + Object.keys(input || {}).reduce((data, key) => { + data.append(key, input[key]); + return data; + }, new FormData()), + [ContentType.UrlEncoded]: (input: any) => this.toQueryString(input), + }; + + private mergeRequestParams(params1: RequestParams, params2?: RequestParams): RequestParams { + return { + ...this.baseApiParams, + ...params1, + ...(params2 || {}), + headers: { + ...(this.baseApiParams.headers || {}), + ...(params1.headers || {}), + ...((params2 && params2.headers) || {}), + }, + }; + } + + private createAbortSignal = (cancelToken: CancelToken): AbortSignal | undefined => { + if (this.abortControllers.has(cancelToken)) { + const abortController = this.abortControllers.get(cancelToken); + if (abortController) { + return abortController.signal; + } + return void 0; + } + + const abortController = new AbortController(); + this.abortControllers.set(cancelToken, abortController); + return abortController.signal; + }; + + public abortRequest = (cancelToken: CancelToken) => { + const abortController = this.abortControllers.get(cancelToken); + + if (abortController) { + abortController.abort(); + this.abortControllers.delete(cancelToken); + } + }; + + public request = ({ + body, + secure, + path, + type, + query, + format = "json", + baseUrl, + cancelToken, + ...params + }: FullRequestParams): Promise> => { + const secureParams = (secure && this.securityWorker && this.securityWorker(this.securityData)) || {}; + const requestParams = this.mergeRequestParams(params, secureParams); + const queryString = query && this.toQueryString(query); + const payloadFormatter = this.contentFormatters[type || ContentType.Json]; + + return fetch(`${baseUrl || this.baseUrl || ""}${path}${queryString ? `?${queryString}` : ""}`, { + ...requestParams, + headers: { + ...(type && type !== ContentType.FormData ? { "Content-Type": type } : {}), + ...(requestParams.headers || {}), + }, + signal: cancelToken ? this.createAbortSignal(cancelToken) : void 0, + body: typeof body === "undefined" || body === null ? null : payloadFormatter(body), + }).then(async (response) => { + const r = response as HttpResponse; + r.data = (null as unknown) as T; + r.error = (null as unknown) as E; + + const data = await response[format]() + .then((data) => { + if (r.ok) { + r.data = data; + } else { + r.error = data; + } + return r; + }) + .catch((e) => { + r.error = e; + return r; + }); + + if (cancelToken) { + this.abortControllers.delete(cancelToken); + } + + if (!response.ok) throw data; + return data; + }); + }; +} + +/** + * @title cosmos/staking/v1beta1/authz.proto + * @version version not set + */ +export class Api extends HttpClient { + /** + * No description + * + * @tags Query + * @name QueryDelegatorDelegations + * @summary DelegatorDelegations queries all delegations of a given delegator address. + * @request GET:/cosmos/staking/v1beta1/delegations/{delegator_addr} + */ + queryDelegatorDelegations = ( + delegator_addr: string, + query?: { + "pagination.key"?: string; + "pagination.offset"?: string; + "pagination.limit"?: string; + "pagination.count_total"?: boolean; + "pagination.reverse"?: boolean; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/cosmos/staking/v1beta1/delegations/${delegator_addr}`, + method: "GET", + query: query, + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Query + * @name QueryRedelegations + * @summary Redelegations queries redelegations of given address. + * @request GET:/cosmos/staking/v1beta1/delegators/{delegator_addr}/redelegations + */ + queryRedelegations = ( + delegator_addr: string, + query?: { + src_validator_addr?: string; + dst_validator_addr?: string; + "pagination.key"?: string; + "pagination.offset"?: string; + "pagination.limit"?: string; + "pagination.count_total"?: boolean; + "pagination.reverse"?: boolean; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/cosmos/staking/v1beta1/delegators/${delegator_addr}/redelegations`, + method: "GET", + query: query, + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Query + * @name QueryDelegatorUnbondingDelegations + * @summary DelegatorUnbondingDelegations queries all unbonding delegations of a given +delegator address. + * @request GET:/cosmos/staking/v1beta1/delegators/{delegator_addr}/unbonding_delegations + */ + queryDelegatorUnbondingDelegations = ( + delegator_addr: string, + query?: { + "pagination.key"?: string; + "pagination.offset"?: string; + "pagination.limit"?: string; + "pagination.count_total"?: boolean; + "pagination.reverse"?: boolean; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/cosmos/staking/v1beta1/delegators/${delegator_addr}/unbonding_delegations`, + method: "GET", + query: query, + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Query + * @name QueryDelegatorValidators + * @summary DelegatorValidators queries all validators info for given delegator +address. + * @request GET:/cosmos/staking/v1beta1/delegators/{delegator_addr}/validators + */ + queryDelegatorValidators = ( + delegator_addr: string, + query?: { + "pagination.key"?: string; + "pagination.offset"?: string; + "pagination.limit"?: string; + "pagination.count_total"?: boolean; + "pagination.reverse"?: boolean; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/cosmos/staking/v1beta1/delegators/${delegator_addr}/validators`, + method: "GET", + query: query, + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Query + * @name QueryDelegatorValidator + * @summary DelegatorValidator queries validator info for given delegator validator +pair. + * @request GET:/cosmos/staking/v1beta1/delegators/{delegator_addr}/validators/{validator_addr} + */ + queryDelegatorValidator = (delegator_addr: string, validator_addr: string, params: RequestParams = {}) => + this.request({ + path: `/cosmos/staking/v1beta1/delegators/${delegator_addr}/validators/${validator_addr}`, + method: "GET", + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Query + * @name QueryHistoricalInfo + * @summary HistoricalInfo queries the historical info for given height. + * @request GET:/cosmos/staking/v1beta1/historical_info/{height} + */ + queryHistoricalInfo = (height: string, params: RequestParams = {}) => + this.request({ + path: `/cosmos/staking/v1beta1/historical_info/${height}`, + method: "GET", + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Query + * @name QueryParams + * @summary Parameters queries the staking parameters. + * @request GET:/cosmos/staking/v1beta1/params + */ + queryParams = (params: RequestParams = {}) => + this.request({ + path: `/cosmos/staking/v1beta1/params`, + method: "GET", + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Query + * @name QueryPool + * @summary Pool queries the pool info. + * @request GET:/cosmos/staking/v1beta1/pool + */ + queryPool = (params: RequestParams = {}) => + this.request({ + path: `/cosmos/staking/v1beta1/pool`, + method: "GET", + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Query + * @name QueryValidators + * @summary Validators queries all validators that match the given status. + * @request GET:/cosmos/staking/v1beta1/validators + */ + queryValidators = ( + query?: { + status?: string; + "pagination.key"?: string; + "pagination.offset"?: string; + "pagination.limit"?: string; + "pagination.count_total"?: boolean; + "pagination.reverse"?: boolean; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/cosmos/staking/v1beta1/validators`, + method: "GET", + query: query, + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Query + * @name QueryValidator + * @summary Validator queries validator info for given validator address. + * @request GET:/cosmos/staking/v1beta1/validators/{validator_addr} + */ + queryValidator = (validator_addr: string, params: RequestParams = {}) => + this.request({ + path: `/cosmos/staking/v1beta1/validators/${validator_addr}`, + method: "GET", + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Query + * @name QueryValidatorDelegations + * @summary ValidatorDelegations queries delegate info for given validator. + * @request GET:/cosmos/staking/v1beta1/validators/{validator_addr}/delegations + */ + queryValidatorDelegations = ( + validator_addr: string, + query?: { + "pagination.key"?: string; + "pagination.offset"?: string; + "pagination.limit"?: string; + "pagination.count_total"?: boolean; + "pagination.reverse"?: boolean; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/cosmos/staking/v1beta1/validators/${validator_addr}/delegations`, + method: "GET", + query: query, + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Query + * @name QueryDelegation + * @summary Delegation queries delegate info for given validator delegator pair. + * @request GET:/cosmos/staking/v1beta1/validators/{validator_addr}/delegations/{delegator_addr} + */ + queryDelegation = (validator_addr: string, delegator_addr: string, params: RequestParams = {}) => + this.request({ + path: `/cosmos/staking/v1beta1/validators/${validator_addr}/delegations/${delegator_addr}`, + method: "GET", + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Query + * @name QueryUnbondingDelegation + * @summary UnbondingDelegation queries unbonding info for given validator delegator +pair. + * @request GET:/cosmos/staking/v1beta1/validators/{validator_addr}/delegations/{delegator_addr}/unbonding_delegation + */ + queryUnbondingDelegation = (validator_addr: string, delegator_addr: string, params: RequestParams = {}) => + this.request({ + path: `/cosmos/staking/v1beta1/validators/${validator_addr}/delegations/${delegator_addr}/unbonding_delegation`, + method: "GET", + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Query + * @name QueryValidatorUnbondingDelegations + * @summary ValidatorUnbondingDelegations queries unbonding delegations of a validator. + * @request GET:/cosmos/staking/v1beta1/validators/{validator_addr}/unbonding_delegations + */ + queryValidatorUnbondingDelegations = ( + validator_addr: string, + query?: { + "pagination.key"?: string; + "pagination.offset"?: string; + "pagination.limit"?: string; + "pagination.count_total"?: boolean; + "pagination.reverse"?: boolean; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/cosmos/staking/v1beta1/validators/${validator_addr}/unbonding_delegations`, + method: "GET", + query: query, + format: "json", + ...params, + }); +} diff --git a/ts-client/cosmos.staking.v1beta1/types.ts b/ts-client/cosmos.staking.v1beta1/types.ts new file mode 100755 index 00000000..716ffae8 --- /dev/null +++ b/ts-client/cosmos.staking.v1beta1/types.ts @@ -0,0 +1,51 @@ +import { StakeAuthorization } from "./types/cosmos/staking/v1beta1/authz" +import { StakeAuthorization_Validators } from "./types/cosmos/staking/v1beta1/authz" +import { LastValidatorPower } from "./types/cosmos/staking/v1beta1/genesis" +import { HistoricalInfo } from "./types/cosmos/staking/v1beta1/staking" +import { CommissionRates } from "./types/cosmos/staking/v1beta1/staking" +import { Commission } from "./types/cosmos/staking/v1beta1/staking" +import { Description } from "./types/cosmos/staking/v1beta1/staking" +import { Validator } from "./types/cosmos/staking/v1beta1/staking" +import { ValAddresses } from "./types/cosmos/staking/v1beta1/staking" +import { DVPair } from "./types/cosmos/staking/v1beta1/staking" +import { DVPairs } from "./types/cosmos/staking/v1beta1/staking" +import { DVVTriplet } from "./types/cosmos/staking/v1beta1/staking" +import { DVVTriplets } from "./types/cosmos/staking/v1beta1/staking" +import { Delegation } from "./types/cosmos/staking/v1beta1/staking" +import { UnbondingDelegation } from "./types/cosmos/staking/v1beta1/staking" +import { UnbondingDelegationEntry } from "./types/cosmos/staking/v1beta1/staking" +import { RedelegationEntry } from "./types/cosmos/staking/v1beta1/staking" +import { Redelegation } from "./types/cosmos/staking/v1beta1/staking" +import { Params } from "./types/cosmos/staking/v1beta1/staking" +import { DelegationResponse } from "./types/cosmos/staking/v1beta1/staking" +import { RedelegationEntryResponse } from "./types/cosmos/staking/v1beta1/staking" +import { RedelegationResponse } from "./types/cosmos/staking/v1beta1/staking" +import { Pool } from "./types/cosmos/staking/v1beta1/staking" + + +export { + StakeAuthorization, + StakeAuthorization_Validators, + LastValidatorPower, + HistoricalInfo, + CommissionRates, + Commission, + Description, + Validator, + ValAddresses, + DVPair, + DVPairs, + DVVTriplet, + DVVTriplets, + Delegation, + UnbondingDelegation, + UnbondingDelegationEntry, + RedelegationEntry, + Redelegation, + Params, + DelegationResponse, + RedelegationEntryResponse, + RedelegationResponse, + Pool, + + } \ No newline at end of file diff --git a/ts-client/cosmos.staking.v1beta1/types/cosmos/base/query/v1beta1/pagination.ts b/ts-client/cosmos.staking.v1beta1/types/cosmos/base/query/v1beta1/pagination.ts new file mode 100644 index 00000000..cd4b2d78 --- /dev/null +++ b/ts-client/cosmos.staking.v1beta1/types/cosmos/base/query/v1beta1/pagination.ts @@ -0,0 +1,327 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "cosmos.base.query.v1beta1"; + +/** + * PageRequest is to be embedded in gRPC request messages for efficient + * pagination. Ex: + * + * message SomeRequest { + * Foo some_parameter = 1; + * PageRequest pagination = 2; + * } + */ +export interface PageRequest { + /** + * key is a value returned in PageResponse.next_key to begin + * querying the next page most efficiently. Only one of offset or key + * should be set. + */ + key: Uint8Array; + /** + * offset is a numeric offset that can be used when key is unavailable. + * It is less efficient than using key. Only one of offset or key should + * be set. + */ + offset: number; + /** + * limit is the total number of results to be returned in the result page. + * If left empty it will default to a value to be set by each app. + */ + limit: number; + /** + * count_total is set to true to indicate that the result set should include + * a count of the total number of items available for pagination in UIs. + * count_total is only respected when offset is used. It is ignored when key + * is set. + */ + countTotal: boolean; + /** + * reverse is set to true if results are to be returned in the descending order. + * + * Since: cosmos-sdk 0.43 + */ + reverse: boolean; +} + +/** + * PageResponse is to be embedded in gRPC response messages where the + * corresponding request message has used PageRequest. + * + * message SomeResponse { + * repeated Bar results = 1; + * PageResponse page = 2; + * } + */ +export interface PageResponse { + /** + * next_key is the key to be passed to PageRequest.key to + * query the next page most efficiently + */ + nextKey: Uint8Array; + /** + * total is total number of results available if PageRequest.count_total + * was set, its value is undefined otherwise + */ + total: number; +} + +const basePageRequest: object = { + offset: 0, + limit: 0, + countTotal: false, + reverse: false, +}; + +export const PageRequest = { + encode(message: PageRequest, writer: Writer = Writer.create()): Writer { + if (message.key.length !== 0) { + writer.uint32(10).bytes(message.key); + } + if (message.offset !== 0) { + writer.uint32(16).uint64(message.offset); + } + if (message.limit !== 0) { + writer.uint32(24).uint64(message.limit); + } + if (message.countTotal === true) { + writer.uint32(32).bool(message.countTotal); + } + if (message.reverse === true) { + writer.uint32(40).bool(message.reverse); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): PageRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...basePageRequest } as PageRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.key = reader.bytes(); + break; + case 2: + message.offset = longToNumber(reader.uint64() as Long); + break; + case 3: + message.limit = longToNumber(reader.uint64() as Long); + break; + case 4: + message.countTotal = reader.bool(); + break; + case 5: + message.reverse = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): PageRequest { + const message = { ...basePageRequest } as PageRequest; + if (object.key !== undefined && object.key !== null) { + message.key = bytesFromBase64(object.key); + } + if (object.offset !== undefined && object.offset !== null) { + message.offset = Number(object.offset); + } else { + message.offset = 0; + } + if (object.limit !== undefined && object.limit !== null) { + message.limit = Number(object.limit); + } else { + message.limit = 0; + } + if (object.countTotal !== undefined && object.countTotal !== null) { + message.countTotal = Boolean(object.countTotal); + } else { + message.countTotal = false; + } + if (object.reverse !== undefined && object.reverse !== null) { + message.reverse = Boolean(object.reverse); + } else { + message.reverse = false; + } + return message; + }, + + toJSON(message: PageRequest): unknown { + const obj: any = {}; + message.key !== undefined && + (obj.key = base64FromBytes( + message.key !== undefined ? message.key : new Uint8Array() + )); + message.offset !== undefined && (obj.offset = message.offset); + message.limit !== undefined && (obj.limit = message.limit); + message.countTotal !== undefined && (obj.countTotal = message.countTotal); + message.reverse !== undefined && (obj.reverse = message.reverse); + return obj; + }, + + fromPartial(object: DeepPartial): PageRequest { + const message = { ...basePageRequest } as PageRequest; + if (object.key !== undefined && object.key !== null) { + message.key = object.key; + } else { + message.key = new Uint8Array(); + } + if (object.offset !== undefined && object.offset !== null) { + message.offset = object.offset; + } else { + message.offset = 0; + } + if (object.limit !== undefined && object.limit !== null) { + message.limit = object.limit; + } else { + message.limit = 0; + } + if (object.countTotal !== undefined && object.countTotal !== null) { + message.countTotal = object.countTotal; + } else { + message.countTotal = false; + } + if (object.reverse !== undefined && object.reverse !== null) { + message.reverse = object.reverse; + } else { + message.reverse = false; + } + return message; + }, +}; + +const basePageResponse: object = { total: 0 }; + +export const PageResponse = { + encode(message: PageResponse, writer: Writer = Writer.create()): Writer { + if (message.nextKey.length !== 0) { + writer.uint32(10).bytes(message.nextKey); + } + if (message.total !== 0) { + writer.uint32(16).uint64(message.total); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): PageResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...basePageResponse } as PageResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.nextKey = reader.bytes(); + break; + case 2: + message.total = longToNumber(reader.uint64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): PageResponse { + const message = { ...basePageResponse } as PageResponse; + if (object.nextKey !== undefined && object.nextKey !== null) { + message.nextKey = bytesFromBase64(object.nextKey); + } + if (object.total !== undefined && object.total !== null) { + message.total = Number(object.total); + } else { + message.total = 0; + } + return message; + }, + + toJSON(message: PageResponse): unknown { + const obj: any = {}; + message.nextKey !== undefined && + (obj.nextKey = base64FromBytes( + message.nextKey !== undefined ? message.nextKey : new Uint8Array() + )); + message.total !== undefined && (obj.total = message.total); + return obj; + }, + + fromPartial(object: DeepPartial): PageResponse { + const message = { ...basePageResponse } as PageResponse; + if (object.nextKey !== undefined && object.nextKey !== null) { + message.nextKey = object.nextKey; + } else { + message.nextKey = new Uint8Array(); + } + if (object.total !== undefined && object.total !== null) { + message.total = object.total; + } else { + message.total = 0; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/cosmos.staking.v1beta1/types/cosmos/base/v1beta1/coin.ts b/ts-client/cosmos.staking.v1beta1/types/cosmos/base/v1beta1/coin.ts new file mode 100644 index 00000000..ce2ac984 --- /dev/null +++ b/ts-client/cosmos.staking.v1beta1/types/cosmos/base/v1beta1/coin.ts @@ -0,0 +1,301 @@ +/* eslint-disable */ +import { Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "cosmos.base.v1beta1"; + +/** + * Coin defines a token with a denomination and an amount. + * + * NOTE: The amount field is an Int which implements the custom method + * signatures required by gogoproto. + */ +export interface Coin { + denom: string; + amount: string; +} + +/** + * DecCoin defines a token with a denomination and a decimal amount. + * + * NOTE: The amount field is an Dec which implements the custom method + * signatures required by gogoproto. + */ +export interface DecCoin { + denom: string; + amount: string; +} + +/** IntProto defines a Protobuf wrapper around an Int object. */ +export interface IntProto { + int: string; +} + +/** DecProto defines a Protobuf wrapper around a Dec object. */ +export interface DecProto { + dec: string; +} + +const baseCoin: object = { denom: "", amount: "" }; + +export const Coin = { + encode(message: Coin, writer: Writer = Writer.create()): Writer { + if (message.denom !== "") { + writer.uint32(10).string(message.denom); + } + if (message.amount !== "") { + writer.uint32(18).string(message.amount); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Coin { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseCoin } as Coin; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.denom = reader.string(); + break; + case 2: + message.amount = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Coin { + const message = { ...baseCoin } as Coin; + if (object.denom !== undefined && object.denom !== null) { + message.denom = String(object.denom); + } else { + message.denom = ""; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = String(object.amount); + } else { + message.amount = ""; + } + return message; + }, + + toJSON(message: Coin): unknown { + const obj: any = {}; + message.denom !== undefined && (obj.denom = message.denom); + message.amount !== undefined && (obj.amount = message.amount); + return obj; + }, + + fromPartial(object: DeepPartial): Coin { + const message = { ...baseCoin } as Coin; + if (object.denom !== undefined && object.denom !== null) { + message.denom = object.denom; + } else { + message.denom = ""; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = object.amount; + } else { + message.amount = ""; + } + return message; + }, +}; + +const baseDecCoin: object = { denom: "", amount: "" }; + +export const DecCoin = { + encode(message: DecCoin, writer: Writer = Writer.create()): Writer { + if (message.denom !== "") { + writer.uint32(10).string(message.denom); + } + if (message.amount !== "") { + writer.uint32(18).string(message.amount); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): DecCoin { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseDecCoin } as DecCoin; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.denom = reader.string(); + break; + case 2: + message.amount = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DecCoin { + const message = { ...baseDecCoin } as DecCoin; + if (object.denom !== undefined && object.denom !== null) { + message.denom = String(object.denom); + } else { + message.denom = ""; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = String(object.amount); + } else { + message.amount = ""; + } + return message; + }, + + toJSON(message: DecCoin): unknown { + const obj: any = {}; + message.denom !== undefined && (obj.denom = message.denom); + message.amount !== undefined && (obj.amount = message.amount); + return obj; + }, + + fromPartial(object: DeepPartial): DecCoin { + const message = { ...baseDecCoin } as DecCoin; + if (object.denom !== undefined && object.denom !== null) { + message.denom = object.denom; + } else { + message.denom = ""; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = object.amount; + } else { + message.amount = ""; + } + return message; + }, +}; + +const baseIntProto: object = { int: "" }; + +export const IntProto = { + encode(message: IntProto, writer: Writer = Writer.create()): Writer { + if (message.int !== "") { + writer.uint32(10).string(message.int); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): IntProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseIntProto } as IntProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.int = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): IntProto { + const message = { ...baseIntProto } as IntProto; + if (object.int !== undefined && object.int !== null) { + message.int = String(object.int); + } else { + message.int = ""; + } + return message; + }, + + toJSON(message: IntProto): unknown { + const obj: any = {}; + message.int !== undefined && (obj.int = message.int); + return obj; + }, + + fromPartial(object: DeepPartial): IntProto { + const message = { ...baseIntProto } as IntProto; + if (object.int !== undefined && object.int !== null) { + message.int = object.int; + } else { + message.int = ""; + } + return message; + }, +}; + +const baseDecProto: object = { dec: "" }; + +export const DecProto = { + encode(message: DecProto, writer: Writer = Writer.create()): Writer { + if (message.dec !== "") { + writer.uint32(10).string(message.dec); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): DecProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseDecProto } as DecProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.dec = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DecProto { + const message = { ...baseDecProto } as DecProto; + if (object.dec !== undefined && object.dec !== null) { + message.dec = String(object.dec); + } else { + message.dec = ""; + } + return message; + }, + + toJSON(message: DecProto): unknown { + const obj: any = {}; + message.dec !== undefined && (obj.dec = message.dec); + return obj; + }, + + fromPartial(object: DeepPartial): DecProto { + const message = { ...baseDecProto } as DecProto; + if (object.dec !== undefined && object.dec !== null) { + message.dec = object.dec; + } else { + message.dec = ""; + } + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/cosmos.staking.v1beta1/types/cosmos/staking/v1beta1/authz.ts b/ts-client/cosmos.staking.v1beta1/types/cosmos/staking/v1beta1/authz.ts new file mode 100644 index 00000000..9d9110b6 --- /dev/null +++ b/ts-client/cosmos.staking.v1beta1/types/cosmos/staking/v1beta1/authz.ts @@ -0,0 +1,321 @@ +/* eslint-disable */ +import { Coin } from "../../../cosmos/base/v1beta1/coin"; +import { Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "cosmos.staking.v1beta1"; + +/** + * AuthorizationType defines the type of staking module authorization type + * + * Since: cosmos-sdk 0.43 + */ +export enum AuthorizationType { + /** AUTHORIZATION_TYPE_UNSPECIFIED - AUTHORIZATION_TYPE_UNSPECIFIED specifies an unknown authorization type */ + AUTHORIZATION_TYPE_UNSPECIFIED = 0, + /** AUTHORIZATION_TYPE_DELEGATE - AUTHORIZATION_TYPE_DELEGATE defines an authorization type for Msg/Delegate */ + AUTHORIZATION_TYPE_DELEGATE = 1, + /** AUTHORIZATION_TYPE_UNDELEGATE - AUTHORIZATION_TYPE_UNDELEGATE defines an authorization type for Msg/Undelegate */ + AUTHORIZATION_TYPE_UNDELEGATE = 2, + /** AUTHORIZATION_TYPE_REDELEGATE - AUTHORIZATION_TYPE_REDELEGATE defines an authorization type for Msg/BeginRedelegate */ + AUTHORIZATION_TYPE_REDELEGATE = 3, + UNRECOGNIZED = -1, +} + +export function authorizationTypeFromJSON(object: any): AuthorizationType { + switch (object) { + case 0: + case "AUTHORIZATION_TYPE_UNSPECIFIED": + return AuthorizationType.AUTHORIZATION_TYPE_UNSPECIFIED; + case 1: + case "AUTHORIZATION_TYPE_DELEGATE": + return AuthorizationType.AUTHORIZATION_TYPE_DELEGATE; + case 2: + case "AUTHORIZATION_TYPE_UNDELEGATE": + return AuthorizationType.AUTHORIZATION_TYPE_UNDELEGATE; + case 3: + case "AUTHORIZATION_TYPE_REDELEGATE": + return AuthorizationType.AUTHORIZATION_TYPE_REDELEGATE; + case -1: + case "UNRECOGNIZED": + default: + return AuthorizationType.UNRECOGNIZED; + } +} + +export function authorizationTypeToJSON(object: AuthorizationType): string { + switch (object) { + case AuthorizationType.AUTHORIZATION_TYPE_UNSPECIFIED: + return "AUTHORIZATION_TYPE_UNSPECIFIED"; + case AuthorizationType.AUTHORIZATION_TYPE_DELEGATE: + return "AUTHORIZATION_TYPE_DELEGATE"; + case AuthorizationType.AUTHORIZATION_TYPE_UNDELEGATE: + return "AUTHORIZATION_TYPE_UNDELEGATE"; + case AuthorizationType.AUTHORIZATION_TYPE_REDELEGATE: + return "AUTHORIZATION_TYPE_REDELEGATE"; + default: + return "UNKNOWN"; + } +} + +/** + * StakeAuthorization defines authorization for delegate/undelegate/redelegate. + * + * Since: cosmos-sdk 0.43 + */ +export interface StakeAuthorization { + /** + * max_tokens specifies the maximum amount of tokens can be delegate to a validator. If it is + * empty, there is no spend limit and any amount of coins can be delegated. + */ + maxTokens: Coin | undefined; + /** + * allow_list specifies list of validator addresses to whom grantee can delegate tokens on behalf of granter's + * account. + */ + allowList: StakeAuthorization_Validators | undefined; + /** deny_list specifies list of validator addresses to whom grantee can not delegate tokens. */ + denyList: StakeAuthorization_Validators | undefined; + /** authorization_type defines one of AuthorizationType. */ + authorizationType: AuthorizationType; +} + +/** Validators defines list of validator addresses. */ +export interface StakeAuthorization_Validators { + address: string[]; +} + +const baseStakeAuthorization: object = { authorizationType: 0 }; + +export const StakeAuthorization = { + encode( + message: StakeAuthorization, + writer: Writer = Writer.create() + ): Writer { + if (message.maxTokens !== undefined) { + Coin.encode(message.maxTokens, writer.uint32(10).fork()).ldelim(); + } + if (message.allowList !== undefined) { + StakeAuthorization_Validators.encode( + message.allowList, + writer.uint32(18).fork() + ).ldelim(); + } + if (message.denyList !== undefined) { + StakeAuthorization_Validators.encode( + message.denyList, + writer.uint32(26).fork() + ).ldelim(); + } + if (message.authorizationType !== 0) { + writer.uint32(32).int32(message.authorizationType); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): StakeAuthorization { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseStakeAuthorization } as StakeAuthorization; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.maxTokens = Coin.decode(reader, reader.uint32()); + break; + case 2: + message.allowList = StakeAuthorization_Validators.decode( + reader, + reader.uint32() + ); + break; + case 3: + message.denyList = StakeAuthorization_Validators.decode( + reader, + reader.uint32() + ); + break; + case 4: + message.authorizationType = reader.int32() as any; + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): StakeAuthorization { + const message = { ...baseStakeAuthorization } as StakeAuthorization; + if (object.maxTokens !== undefined && object.maxTokens !== null) { + message.maxTokens = Coin.fromJSON(object.maxTokens); + } else { + message.maxTokens = undefined; + } + if (object.allowList !== undefined && object.allowList !== null) { + message.allowList = StakeAuthorization_Validators.fromJSON( + object.allowList + ); + } else { + message.allowList = undefined; + } + if (object.denyList !== undefined && object.denyList !== null) { + message.denyList = StakeAuthorization_Validators.fromJSON( + object.denyList + ); + } else { + message.denyList = undefined; + } + if ( + object.authorizationType !== undefined && + object.authorizationType !== null + ) { + message.authorizationType = authorizationTypeFromJSON( + object.authorizationType + ); + } else { + message.authorizationType = 0; + } + return message; + }, + + toJSON(message: StakeAuthorization): unknown { + const obj: any = {}; + message.maxTokens !== undefined && + (obj.maxTokens = message.maxTokens + ? Coin.toJSON(message.maxTokens) + : undefined); + message.allowList !== undefined && + (obj.allowList = message.allowList + ? StakeAuthorization_Validators.toJSON(message.allowList) + : undefined); + message.denyList !== undefined && + (obj.denyList = message.denyList + ? StakeAuthorization_Validators.toJSON(message.denyList) + : undefined); + message.authorizationType !== undefined && + (obj.authorizationType = authorizationTypeToJSON( + message.authorizationType + )); + return obj; + }, + + fromPartial(object: DeepPartial): StakeAuthorization { + const message = { ...baseStakeAuthorization } as StakeAuthorization; + if (object.maxTokens !== undefined && object.maxTokens !== null) { + message.maxTokens = Coin.fromPartial(object.maxTokens); + } else { + message.maxTokens = undefined; + } + if (object.allowList !== undefined && object.allowList !== null) { + message.allowList = StakeAuthorization_Validators.fromPartial( + object.allowList + ); + } else { + message.allowList = undefined; + } + if (object.denyList !== undefined && object.denyList !== null) { + message.denyList = StakeAuthorization_Validators.fromPartial( + object.denyList + ); + } else { + message.denyList = undefined; + } + if ( + object.authorizationType !== undefined && + object.authorizationType !== null + ) { + message.authorizationType = object.authorizationType; + } else { + message.authorizationType = 0; + } + return message; + }, +}; + +const baseStakeAuthorization_Validators: object = { address: "" }; + +export const StakeAuthorization_Validators = { + encode( + message: StakeAuthorization_Validators, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.address) { + writer.uint32(10).string(v!); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): StakeAuthorization_Validators { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseStakeAuthorization_Validators, + } as StakeAuthorization_Validators; + message.address = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.address.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): StakeAuthorization_Validators { + const message = { + ...baseStakeAuthorization_Validators, + } as StakeAuthorization_Validators; + message.address = []; + if (object.address !== undefined && object.address !== null) { + for (const e of object.address) { + message.address.push(String(e)); + } + } + return message; + }, + + toJSON(message: StakeAuthorization_Validators): unknown { + const obj: any = {}; + if (message.address) { + obj.address = message.address.map((e) => e); + } else { + obj.address = []; + } + return obj; + }, + + fromPartial( + object: DeepPartial + ): StakeAuthorization_Validators { + const message = { + ...baseStakeAuthorization_Validators, + } as StakeAuthorization_Validators; + message.address = []; + if (object.address !== undefined && object.address !== null) { + for (const e of object.address) { + message.address.push(e); + } + } + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/cosmos.staking.v1beta1/types/cosmos/staking/v1beta1/genesis.ts b/ts-client/cosmos.staking.v1beta1/types/cosmos/staking/v1beta1/genesis.ts new file mode 100644 index 00000000..04cb5319 --- /dev/null +++ b/ts-client/cosmos.staking.v1beta1/types/cosmos/staking/v1beta1/genesis.ts @@ -0,0 +1,417 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; +import { + Params, + Validator, + Delegation, + UnbondingDelegation, + Redelegation, +} from "../../../cosmos/staking/v1beta1/staking"; + +export const protobufPackage = "cosmos.staking.v1beta1"; + +/** GenesisState defines the staking module's genesis state. */ +export interface GenesisState { + /** params defines all the paramaters of related to deposit. */ + params: Params | undefined; + /** + * last_total_power tracks the total amounts of bonded tokens recorded during + * the previous end block. + */ + lastTotalPower: Uint8Array; + /** + * last_validator_powers is a special index that provides a historical list + * of the last-block's bonded validators. + */ + lastValidatorPowers: LastValidatorPower[]; + /** delegations defines the validator set at genesis. */ + validators: Validator[]; + /** delegations defines the delegations active at genesis. */ + delegations: Delegation[]; + /** unbonding_delegations defines the unbonding delegations active at genesis. */ + unbondingDelegations: UnbondingDelegation[]; + /** redelegations defines the redelegations active at genesis. */ + redelegations: Redelegation[]; + exported: boolean; +} + +/** LastValidatorPower required for validator set update logic. */ +export interface LastValidatorPower { + /** address is the address of the validator. */ + address: string; + /** power defines the power of the validator. */ + power: number; +} + +const baseGenesisState: object = { exported: false }; + +export const GenesisState = { + encode(message: GenesisState, writer: Writer = Writer.create()): Writer { + if (message.params !== undefined) { + Params.encode(message.params, writer.uint32(10).fork()).ldelim(); + } + if (message.lastTotalPower.length !== 0) { + writer.uint32(18).bytes(message.lastTotalPower); + } + for (const v of message.lastValidatorPowers) { + LastValidatorPower.encode(v!, writer.uint32(26).fork()).ldelim(); + } + for (const v of message.validators) { + Validator.encode(v!, writer.uint32(34).fork()).ldelim(); + } + for (const v of message.delegations) { + Delegation.encode(v!, writer.uint32(42).fork()).ldelim(); + } + for (const v of message.unbondingDelegations) { + UnbondingDelegation.encode(v!, writer.uint32(50).fork()).ldelim(); + } + for (const v of message.redelegations) { + Redelegation.encode(v!, writer.uint32(58).fork()).ldelim(); + } + if (message.exported === true) { + writer.uint32(64).bool(message.exported); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): GenesisState { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseGenesisState } as GenesisState; + message.lastValidatorPowers = []; + message.validators = []; + message.delegations = []; + message.unbondingDelegations = []; + message.redelegations = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.params = Params.decode(reader, reader.uint32()); + break; + case 2: + message.lastTotalPower = reader.bytes(); + break; + case 3: + message.lastValidatorPowers.push( + LastValidatorPower.decode(reader, reader.uint32()) + ); + break; + case 4: + message.validators.push(Validator.decode(reader, reader.uint32())); + break; + case 5: + message.delegations.push(Delegation.decode(reader, reader.uint32())); + break; + case 6: + message.unbondingDelegations.push( + UnbondingDelegation.decode(reader, reader.uint32()) + ); + break; + case 7: + message.redelegations.push( + Redelegation.decode(reader, reader.uint32()) + ); + break; + case 8: + message.exported = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GenesisState { + const message = { ...baseGenesisState } as GenesisState; + message.lastValidatorPowers = []; + message.validators = []; + message.delegations = []; + message.unbondingDelegations = []; + message.redelegations = []; + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromJSON(object.params); + } else { + message.params = undefined; + } + if (object.lastTotalPower !== undefined && object.lastTotalPower !== null) { + message.lastTotalPower = bytesFromBase64(object.lastTotalPower); + } + if ( + object.lastValidatorPowers !== undefined && + object.lastValidatorPowers !== null + ) { + for (const e of object.lastValidatorPowers) { + message.lastValidatorPowers.push(LastValidatorPower.fromJSON(e)); + } + } + if (object.validators !== undefined && object.validators !== null) { + for (const e of object.validators) { + message.validators.push(Validator.fromJSON(e)); + } + } + if (object.delegations !== undefined && object.delegations !== null) { + for (const e of object.delegations) { + message.delegations.push(Delegation.fromJSON(e)); + } + } + if ( + object.unbondingDelegations !== undefined && + object.unbondingDelegations !== null + ) { + for (const e of object.unbondingDelegations) { + message.unbondingDelegations.push(UnbondingDelegation.fromJSON(e)); + } + } + if (object.redelegations !== undefined && object.redelegations !== null) { + for (const e of object.redelegations) { + message.redelegations.push(Redelegation.fromJSON(e)); + } + } + if (object.exported !== undefined && object.exported !== null) { + message.exported = Boolean(object.exported); + } else { + message.exported = false; + } + return message; + }, + + toJSON(message: GenesisState): unknown { + const obj: any = {}; + message.params !== undefined && + (obj.params = message.params ? Params.toJSON(message.params) : undefined); + message.lastTotalPower !== undefined && + (obj.lastTotalPower = base64FromBytes( + message.lastTotalPower !== undefined + ? message.lastTotalPower + : new Uint8Array() + )); + if (message.lastValidatorPowers) { + obj.lastValidatorPowers = message.lastValidatorPowers.map((e) => + e ? LastValidatorPower.toJSON(e) : undefined + ); + } else { + obj.lastValidatorPowers = []; + } + if (message.validators) { + obj.validators = message.validators.map((e) => + e ? Validator.toJSON(e) : undefined + ); + } else { + obj.validators = []; + } + if (message.delegations) { + obj.delegations = message.delegations.map((e) => + e ? Delegation.toJSON(e) : undefined + ); + } else { + obj.delegations = []; + } + if (message.unbondingDelegations) { + obj.unbondingDelegations = message.unbondingDelegations.map((e) => + e ? UnbondingDelegation.toJSON(e) : undefined + ); + } else { + obj.unbondingDelegations = []; + } + if (message.redelegations) { + obj.redelegations = message.redelegations.map((e) => + e ? Redelegation.toJSON(e) : undefined + ); + } else { + obj.redelegations = []; + } + message.exported !== undefined && (obj.exported = message.exported); + return obj; + }, + + fromPartial(object: DeepPartial): GenesisState { + const message = { ...baseGenesisState } as GenesisState; + message.lastValidatorPowers = []; + message.validators = []; + message.delegations = []; + message.unbondingDelegations = []; + message.redelegations = []; + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromPartial(object.params); + } else { + message.params = undefined; + } + if (object.lastTotalPower !== undefined && object.lastTotalPower !== null) { + message.lastTotalPower = object.lastTotalPower; + } else { + message.lastTotalPower = new Uint8Array(); + } + if ( + object.lastValidatorPowers !== undefined && + object.lastValidatorPowers !== null + ) { + for (const e of object.lastValidatorPowers) { + message.lastValidatorPowers.push(LastValidatorPower.fromPartial(e)); + } + } + if (object.validators !== undefined && object.validators !== null) { + for (const e of object.validators) { + message.validators.push(Validator.fromPartial(e)); + } + } + if (object.delegations !== undefined && object.delegations !== null) { + for (const e of object.delegations) { + message.delegations.push(Delegation.fromPartial(e)); + } + } + if ( + object.unbondingDelegations !== undefined && + object.unbondingDelegations !== null + ) { + for (const e of object.unbondingDelegations) { + message.unbondingDelegations.push(UnbondingDelegation.fromPartial(e)); + } + } + if (object.redelegations !== undefined && object.redelegations !== null) { + for (const e of object.redelegations) { + message.redelegations.push(Redelegation.fromPartial(e)); + } + } + if (object.exported !== undefined && object.exported !== null) { + message.exported = object.exported; + } else { + message.exported = false; + } + return message; + }, +}; + +const baseLastValidatorPower: object = { address: "", power: 0 }; + +export const LastValidatorPower = { + encode( + message: LastValidatorPower, + writer: Writer = Writer.create() + ): Writer { + if (message.address !== "") { + writer.uint32(10).string(message.address); + } + if (message.power !== 0) { + writer.uint32(16).int64(message.power); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): LastValidatorPower { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseLastValidatorPower } as LastValidatorPower; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.address = reader.string(); + break; + case 2: + message.power = longToNumber(reader.int64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): LastValidatorPower { + const message = { ...baseLastValidatorPower } as LastValidatorPower; + if (object.address !== undefined && object.address !== null) { + message.address = String(object.address); + } else { + message.address = ""; + } + if (object.power !== undefined && object.power !== null) { + message.power = Number(object.power); + } else { + message.power = 0; + } + return message; + }, + + toJSON(message: LastValidatorPower): unknown { + const obj: any = {}; + message.address !== undefined && (obj.address = message.address); + message.power !== undefined && (obj.power = message.power); + return obj; + }, + + fromPartial(object: DeepPartial): LastValidatorPower { + const message = { ...baseLastValidatorPower } as LastValidatorPower; + if (object.address !== undefined && object.address !== null) { + message.address = object.address; + } else { + message.address = ""; + } + if (object.power !== undefined && object.power !== null) { + message.power = object.power; + } else { + message.power = 0; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/cosmos.staking.v1beta1/types/cosmos/staking/v1beta1/query.ts b/ts-client/cosmos.staking.v1beta1/types/cosmos/staking/v1beta1/query.ts new file mode 100644 index 00000000..95e3adcf --- /dev/null +++ b/ts-client/cosmos.staking.v1beta1/types/cosmos/staking/v1beta1/query.ts @@ -0,0 +1,2939 @@ +/* eslint-disable */ +import { Reader, util, configure, Writer } from "protobufjs/minimal"; +import * as Long from "long"; +import { + PageRequest, + PageResponse, +} from "../../../cosmos/base/query/v1beta1/pagination"; +import { + Validator, + DelegationResponse, + UnbondingDelegation, + RedelegationResponse, + HistoricalInfo, + Pool, + Params, +} from "../../../cosmos/staking/v1beta1/staking"; + +export const protobufPackage = "cosmos.staking.v1beta1"; + +/** QueryValidatorsRequest is request type for Query/Validators RPC method. */ +export interface QueryValidatorsRequest { + /** status enables to query for validators matching a given status. */ + status: string; + /** pagination defines an optional pagination for the request. */ + pagination: PageRequest | undefined; +} + +/** QueryValidatorsResponse is response type for the Query/Validators RPC method */ +export interface QueryValidatorsResponse { + /** validators contains all the queried validators. */ + validators: Validator[]; + /** pagination defines the pagination in the response. */ + pagination: PageResponse | undefined; +} + +/** QueryValidatorRequest is response type for the Query/Validator RPC method */ +export interface QueryValidatorRequest { + /** validator_addr defines the validator address to query for. */ + validatorAddr: string; +} + +/** QueryValidatorResponse is response type for the Query/Validator RPC method */ +export interface QueryValidatorResponse { + /** validator defines the the validator info. */ + validator: Validator | undefined; +} + +/** + * QueryValidatorDelegationsRequest is request type for the + * Query/ValidatorDelegations RPC method + */ +export interface QueryValidatorDelegationsRequest { + /** validator_addr defines the validator address to query for. */ + validatorAddr: string; + /** pagination defines an optional pagination for the request. */ + pagination: PageRequest | undefined; +} + +/** + * QueryValidatorDelegationsResponse is response type for the + * Query/ValidatorDelegations RPC method + */ +export interface QueryValidatorDelegationsResponse { + delegationResponses: DelegationResponse[]; + /** pagination defines the pagination in the response. */ + pagination: PageResponse | undefined; +} + +/** + * QueryValidatorUnbondingDelegationsRequest is required type for the + * Query/ValidatorUnbondingDelegations RPC method + */ +export interface QueryValidatorUnbondingDelegationsRequest { + /** validator_addr defines the validator address to query for. */ + validatorAddr: string; + /** pagination defines an optional pagination for the request. */ + pagination: PageRequest | undefined; +} + +/** + * QueryValidatorUnbondingDelegationsResponse is response type for the + * Query/ValidatorUnbondingDelegations RPC method. + */ +export interface QueryValidatorUnbondingDelegationsResponse { + unbondingResponses: UnbondingDelegation[]; + /** pagination defines the pagination in the response. */ + pagination: PageResponse | undefined; +} + +/** QueryDelegationRequest is request type for the Query/Delegation RPC method. */ +export interface QueryDelegationRequest { + /** delegator_addr defines the delegator address to query for. */ + delegatorAddr: string; + /** validator_addr defines the validator address to query for. */ + validatorAddr: string; +} + +/** QueryDelegationResponse is response type for the Query/Delegation RPC method. */ +export interface QueryDelegationResponse { + /** delegation_responses defines the delegation info of a delegation. */ + delegationResponse: DelegationResponse | undefined; +} + +/** + * QueryUnbondingDelegationRequest is request type for the + * Query/UnbondingDelegation RPC method. + */ +export interface QueryUnbondingDelegationRequest { + /** delegator_addr defines the delegator address to query for. */ + delegatorAddr: string; + /** validator_addr defines the validator address to query for. */ + validatorAddr: string; +} + +/** + * QueryDelegationResponse is response type for the Query/UnbondingDelegation + * RPC method. + */ +export interface QueryUnbondingDelegationResponse { + /** unbond defines the unbonding information of a delegation. */ + unbond: UnbondingDelegation | undefined; +} + +/** + * QueryDelegatorDelegationsRequest is request type for the + * Query/DelegatorDelegations RPC method. + */ +export interface QueryDelegatorDelegationsRequest { + /** delegator_addr defines the delegator address to query for. */ + delegatorAddr: string; + /** pagination defines an optional pagination for the request. */ + pagination: PageRequest | undefined; +} + +/** + * QueryDelegatorDelegationsResponse is response type for the + * Query/DelegatorDelegations RPC method. + */ +export interface QueryDelegatorDelegationsResponse { + /** delegation_responses defines all the delegations' info of a delegator. */ + delegationResponses: DelegationResponse[]; + /** pagination defines the pagination in the response. */ + pagination: PageResponse | undefined; +} + +/** + * QueryDelegatorUnbondingDelegationsRequest is request type for the + * Query/DelegatorUnbondingDelegations RPC method. + */ +export interface QueryDelegatorUnbondingDelegationsRequest { + /** delegator_addr defines the delegator address to query for. */ + delegatorAddr: string; + /** pagination defines an optional pagination for the request. */ + pagination: PageRequest | undefined; +} + +/** + * QueryUnbondingDelegatorDelegationsResponse is response type for the + * Query/UnbondingDelegatorDelegations RPC method. + */ +export interface QueryDelegatorUnbondingDelegationsResponse { + unbondingResponses: UnbondingDelegation[]; + /** pagination defines the pagination in the response. */ + pagination: PageResponse | undefined; +} + +/** + * QueryRedelegationsRequest is request type for the Query/Redelegations RPC + * method. + */ +export interface QueryRedelegationsRequest { + /** delegator_addr defines the delegator address to query for. */ + delegatorAddr: string; + /** src_validator_addr defines the validator address to redelegate from. */ + srcValidatorAddr: string; + /** dst_validator_addr defines the validator address to redelegate to. */ + dstValidatorAddr: string; + /** pagination defines an optional pagination for the request. */ + pagination: PageRequest | undefined; +} + +/** + * QueryRedelegationsResponse is response type for the Query/Redelegations RPC + * method. + */ +export interface QueryRedelegationsResponse { + redelegationResponses: RedelegationResponse[]; + /** pagination defines the pagination in the response. */ + pagination: PageResponse | undefined; +} + +/** + * QueryDelegatorValidatorsRequest is request type for the + * Query/DelegatorValidators RPC method. + */ +export interface QueryDelegatorValidatorsRequest { + /** delegator_addr defines the delegator address to query for. */ + delegatorAddr: string; + /** pagination defines an optional pagination for the request. */ + pagination: PageRequest | undefined; +} + +/** + * QueryDelegatorValidatorsResponse is response type for the + * Query/DelegatorValidators RPC method. + */ +export interface QueryDelegatorValidatorsResponse { + /** validators defines the the validators' info of a delegator. */ + validators: Validator[]; + /** pagination defines the pagination in the response. */ + pagination: PageResponse | undefined; +} + +/** + * QueryDelegatorValidatorRequest is request type for the + * Query/DelegatorValidator RPC method. + */ +export interface QueryDelegatorValidatorRequest { + /** delegator_addr defines the delegator address to query for. */ + delegatorAddr: string; + /** validator_addr defines the validator address to query for. */ + validatorAddr: string; +} + +/** + * QueryDelegatorValidatorResponse response type for the + * Query/DelegatorValidator RPC method. + */ +export interface QueryDelegatorValidatorResponse { + /** validator defines the the validator info. */ + validator: Validator | undefined; +} + +/** + * QueryHistoricalInfoRequest is request type for the Query/HistoricalInfo RPC + * method. + */ +export interface QueryHistoricalInfoRequest { + /** height defines at which height to query the historical info. */ + height: number; +} + +/** + * QueryHistoricalInfoResponse is response type for the Query/HistoricalInfo RPC + * method. + */ +export interface QueryHistoricalInfoResponse { + /** hist defines the historical info at the given height. */ + hist: HistoricalInfo | undefined; +} + +/** QueryPoolRequest is request type for the Query/Pool RPC method. */ +export interface QueryPoolRequest {} + +/** QueryPoolResponse is response type for the Query/Pool RPC method. */ +export interface QueryPoolResponse { + /** pool defines the pool info. */ + pool: Pool | undefined; +} + +/** QueryParamsRequest is request type for the Query/Params RPC method. */ +export interface QueryParamsRequest {} + +/** QueryParamsResponse is response type for the Query/Params RPC method. */ +export interface QueryParamsResponse { + /** params holds all the parameters of this module. */ + params: Params | undefined; +} + +const baseQueryValidatorsRequest: object = { status: "" }; + +export const QueryValidatorsRequest = { + encode( + message: QueryValidatorsRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.status !== "") { + writer.uint32(10).string(message.status); + } + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QueryValidatorsRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryValidatorsRequest } as QueryValidatorsRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.status = reader.string(); + break; + case 2: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryValidatorsRequest { + const message = { ...baseQueryValidatorsRequest } as QueryValidatorsRequest; + if (object.status !== undefined && object.status !== null) { + message.status = String(object.status); + } else { + message.status = ""; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryValidatorsRequest): unknown { + const obj: any = {}; + message.status !== undefined && (obj.status = message.status); + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageRequest.toJSON(message.pagination) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryValidatorsRequest { + const message = { ...baseQueryValidatorsRequest } as QueryValidatorsRequest; + if (object.status !== undefined && object.status !== null) { + message.status = object.status; + } else { + message.status = ""; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseQueryValidatorsResponse: object = {}; + +export const QueryValidatorsResponse = { + encode( + message: QueryValidatorsResponse, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.validators) { + Validator.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode( + message.pagination, + writer.uint32(18).fork() + ).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QueryValidatorsResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryValidatorsResponse, + } as QueryValidatorsResponse; + message.validators = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.validators.push(Validator.decode(reader, reader.uint32())); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryValidatorsResponse { + const message = { + ...baseQueryValidatorsResponse, + } as QueryValidatorsResponse; + message.validators = []; + if (object.validators !== undefined && object.validators !== null) { + for (const e of object.validators) { + message.validators.push(Validator.fromJSON(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryValidatorsResponse): unknown { + const obj: any = {}; + if (message.validators) { + obj.validators = message.validators.map((e) => + e ? Validator.toJSON(e) : undefined + ); + } else { + obj.validators = []; + } + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageResponse.toJSON(message.pagination) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryValidatorsResponse { + const message = { + ...baseQueryValidatorsResponse, + } as QueryValidatorsResponse; + message.validators = []; + if (object.validators !== undefined && object.validators !== null) { + for (const e of object.validators) { + message.validators.push(Validator.fromPartial(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseQueryValidatorRequest: object = { validatorAddr: "" }; + +export const QueryValidatorRequest = { + encode( + message: QueryValidatorRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.validatorAddr !== "") { + writer.uint32(10).string(message.validatorAddr); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QueryValidatorRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryValidatorRequest } as QueryValidatorRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.validatorAddr = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryValidatorRequest { + const message = { ...baseQueryValidatorRequest } as QueryValidatorRequest; + if (object.validatorAddr !== undefined && object.validatorAddr !== null) { + message.validatorAddr = String(object.validatorAddr); + } else { + message.validatorAddr = ""; + } + return message; + }, + + toJSON(message: QueryValidatorRequest): unknown { + const obj: any = {}; + message.validatorAddr !== undefined && + (obj.validatorAddr = message.validatorAddr); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryValidatorRequest { + const message = { ...baseQueryValidatorRequest } as QueryValidatorRequest; + if (object.validatorAddr !== undefined && object.validatorAddr !== null) { + message.validatorAddr = object.validatorAddr; + } else { + message.validatorAddr = ""; + } + return message; + }, +}; + +const baseQueryValidatorResponse: object = {}; + +export const QueryValidatorResponse = { + encode( + message: QueryValidatorResponse, + writer: Writer = Writer.create() + ): Writer { + if (message.validator !== undefined) { + Validator.encode(message.validator, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QueryValidatorResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryValidatorResponse } as QueryValidatorResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.validator = Validator.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryValidatorResponse { + const message = { ...baseQueryValidatorResponse } as QueryValidatorResponse; + if (object.validator !== undefined && object.validator !== null) { + message.validator = Validator.fromJSON(object.validator); + } else { + message.validator = undefined; + } + return message; + }, + + toJSON(message: QueryValidatorResponse): unknown { + const obj: any = {}; + message.validator !== undefined && + (obj.validator = message.validator + ? Validator.toJSON(message.validator) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryValidatorResponse { + const message = { ...baseQueryValidatorResponse } as QueryValidatorResponse; + if (object.validator !== undefined && object.validator !== null) { + message.validator = Validator.fromPartial(object.validator); + } else { + message.validator = undefined; + } + return message; + }, +}; + +const baseQueryValidatorDelegationsRequest: object = { validatorAddr: "" }; + +export const QueryValidatorDelegationsRequest = { + encode( + message: QueryValidatorDelegationsRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.validatorAddr !== "") { + writer.uint32(10).string(message.validatorAddr); + } + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryValidatorDelegationsRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryValidatorDelegationsRequest, + } as QueryValidatorDelegationsRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.validatorAddr = reader.string(); + break; + case 2: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryValidatorDelegationsRequest { + const message = { + ...baseQueryValidatorDelegationsRequest, + } as QueryValidatorDelegationsRequest; + if (object.validatorAddr !== undefined && object.validatorAddr !== null) { + message.validatorAddr = String(object.validatorAddr); + } else { + message.validatorAddr = ""; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryValidatorDelegationsRequest): unknown { + const obj: any = {}; + message.validatorAddr !== undefined && + (obj.validatorAddr = message.validatorAddr); + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageRequest.toJSON(message.pagination) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryValidatorDelegationsRequest { + const message = { + ...baseQueryValidatorDelegationsRequest, + } as QueryValidatorDelegationsRequest; + if (object.validatorAddr !== undefined && object.validatorAddr !== null) { + message.validatorAddr = object.validatorAddr; + } else { + message.validatorAddr = ""; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseQueryValidatorDelegationsResponse: object = {}; + +export const QueryValidatorDelegationsResponse = { + encode( + message: QueryValidatorDelegationsResponse, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.delegationResponses) { + DelegationResponse.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode( + message.pagination, + writer.uint32(18).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryValidatorDelegationsResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryValidatorDelegationsResponse, + } as QueryValidatorDelegationsResponse; + message.delegationResponses = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.delegationResponses.push( + DelegationResponse.decode(reader, reader.uint32()) + ); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryValidatorDelegationsResponse { + const message = { + ...baseQueryValidatorDelegationsResponse, + } as QueryValidatorDelegationsResponse; + message.delegationResponses = []; + if ( + object.delegationResponses !== undefined && + object.delegationResponses !== null + ) { + for (const e of object.delegationResponses) { + message.delegationResponses.push(DelegationResponse.fromJSON(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryValidatorDelegationsResponse): unknown { + const obj: any = {}; + if (message.delegationResponses) { + obj.delegationResponses = message.delegationResponses.map((e) => + e ? DelegationResponse.toJSON(e) : undefined + ); + } else { + obj.delegationResponses = []; + } + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageResponse.toJSON(message.pagination) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryValidatorDelegationsResponse { + const message = { + ...baseQueryValidatorDelegationsResponse, + } as QueryValidatorDelegationsResponse; + message.delegationResponses = []; + if ( + object.delegationResponses !== undefined && + object.delegationResponses !== null + ) { + for (const e of object.delegationResponses) { + message.delegationResponses.push(DelegationResponse.fromPartial(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseQueryValidatorUnbondingDelegationsRequest: object = { + validatorAddr: "", +}; + +export const QueryValidatorUnbondingDelegationsRequest = { + encode( + message: QueryValidatorUnbondingDelegationsRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.validatorAddr !== "") { + writer.uint32(10).string(message.validatorAddr); + } + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryValidatorUnbondingDelegationsRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryValidatorUnbondingDelegationsRequest, + } as QueryValidatorUnbondingDelegationsRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.validatorAddr = reader.string(); + break; + case 2: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryValidatorUnbondingDelegationsRequest { + const message = { + ...baseQueryValidatorUnbondingDelegationsRequest, + } as QueryValidatorUnbondingDelegationsRequest; + if (object.validatorAddr !== undefined && object.validatorAddr !== null) { + message.validatorAddr = String(object.validatorAddr); + } else { + message.validatorAddr = ""; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryValidatorUnbondingDelegationsRequest): unknown { + const obj: any = {}; + message.validatorAddr !== undefined && + (obj.validatorAddr = message.validatorAddr); + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageRequest.toJSON(message.pagination) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryValidatorUnbondingDelegationsRequest { + const message = { + ...baseQueryValidatorUnbondingDelegationsRequest, + } as QueryValidatorUnbondingDelegationsRequest; + if (object.validatorAddr !== undefined && object.validatorAddr !== null) { + message.validatorAddr = object.validatorAddr; + } else { + message.validatorAddr = ""; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseQueryValidatorUnbondingDelegationsResponse: object = {}; + +export const QueryValidatorUnbondingDelegationsResponse = { + encode( + message: QueryValidatorUnbondingDelegationsResponse, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.unbondingResponses) { + UnbondingDelegation.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode( + message.pagination, + writer.uint32(18).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryValidatorUnbondingDelegationsResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryValidatorUnbondingDelegationsResponse, + } as QueryValidatorUnbondingDelegationsResponse; + message.unbondingResponses = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.unbondingResponses.push( + UnbondingDelegation.decode(reader, reader.uint32()) + ); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryValidatorUnbondingDelegationsResponse { + const message = { + ...baseQueryValidatorUnbondingDelegationsResponse, + } as QueryValidatorUnbondingDelegationsResponse; + message.unbondingResponses = []; + if ( + object.unbondingResponses !== undefined && + object.unbondingResponses !== null + ) { + for (const e of object.unbondingResponses) { + message.unbondingResponses.push(UnbondingDelegation.fromJSON(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryValidatorUnbondingDelegationsResponse): unknown { + const obj: any = {}; + if (message.unbondingResponses) { + obj.unbondingResponses = message.unbondingResponses.map((e) => + e ? UnbondingDelegation.toJSON(e) : undefined + ); + } else { + obj.unbondingResponses = []; + } + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageResponse.toJSON(message.pagination) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryValidatorUnbondingDelegationsResponse { + const message = { + ...baseQueryValidatorUnbondingDelegationsResponse, + } as QueryValidatorUnbondingDelegationsResponse; + message.unbondingResponses = []; + if ( + object.unbondingResponses !== undefined && + object.unbondingResponses !== null + ) { + for (const e of object.unbondingResponses) { + message.unbondingResponses.push(UnbondingDelegation.fromPartial(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseQueryDelegationRequest: object = { + delegatorAddr: "", + validatorAddr: "", +}; + +export const QueryDelegationRequest = { + encode( + message: QueryDelegationRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.delegatorAddr !== "") { + writer.uint32(10).string(message.delegatorAddr); + } + if (message.validatorAddr !== "") { + writer.uint32(18).string(message.validatorAddr); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QueryDelegationRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryDelegationRequest } as QueryDelegationRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.delegatorAddr = reader.string(); + break; + case 2: + message.validatorAddr = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryDelegationRequest { + const message = { ...baseQueryDelegationRequest } as QueryDelegationRequest; + if (object.delegatorAddr !== undefined && object.delegatorAddr !== null) { + message.delegatorAddr = String(object.delegatorAddr); + } else { + message.delegatorAddr = ""; + } + if (object.validatorAddr !== undefined && object.validatorAddr !== null) { + message.validatorAddr = String(object.validatorAddr); + } else { + message.validatorAddr = ""; + } + return message; + }, + + toJSON(message: QueryDelegationRequest): unknown { + const obj: any = {}; + message.delegatorAddr !== undefined && + (obj.delegatorAddr = message.delegatorAddr); + message.validatorAddr !== undefined && + (obj.validatorAddr = message.validatorAddr); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryDelegationRequest { + const message = { ...baseQueryDelegationRequest } as QueryDelegationRequest; + if (object.delegatorAddr !== undefined && object.delegatorAddr !== null) { + message.delegatorAddr = object.delegatorAddr; + } else { + message.delegatorAddr = ""; + } + if (object.validatorAddr !== undefined && object.validatorAddr !== null) { + message.validatorAddr = object.validatorAddr; + } else { + message.validatorAddr = ""; + } + return message; + }, +}; + +const baseQueryDelegationResponse: object = {}; + +export const QueryDelegationResponse = { + encode( + message: QueryDelegationResponse, + writer: Writer = Writer.create() + ): Writer { + if (message.delegationResponse !== undefined) { + DelegationResponse.encode( + message.delegationResponse, + writer.uint32(10).fork() + ).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QueryDelegationResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryDelegationResponse, + } as QueryDelegationResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.delegationResponse = DelegationResponse.decode( + reader, + reader.uint32() + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryDelegationResponse { + const message = { + ...baseQueryDelegationResponse, + } as QueryDelegationResponse; + if ( + object.delegationResponse !== undefined && + object.delegationResponse !== null + ) { + message.delegationResponse = DelegationResponse.fromJSON( + object.delegationResponse + ); + } else { + message.delegationResponse = undefined; + } + return message; + }, + + toJSON(message: QueryDelegationResponse): unknown { + const obj: any = {}; + message.delegationResponse !== undefined && + (obj.delegationResponse = message.delegationResponse + ? DelegationResponse.toJSON(message.delegationResponse) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryDelegationResponse { + const message = { + ...baseQueryDelegationResponse, + } as QueryDelegationResponse; + if ( + object.delegationResponse !== undefined && + object.delegationResponse !== null + ) { + message.delegationResponse = DelegationResponse.fromPartial( + object.delegationResponse + ); + } else { + message.delegationResponse = undefined; + } + return message; + }, +}; + +const baseQueryUnbondingDelegationRequest: object = { + delegatorAddr: "", + validatorAddr: "", +}; + +export const QueryUnbondingDelegationRequest = { + encode( + message: QueryUnbondingDelegationRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.delegatorAddr !== "") { + writer.uint32(10).string(message.delegatorAddr); + } + if (message.validatorAddr !== "") { + writer.uint32(18).string(message.validatorAddr); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryUnbondingDelegationRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryUnbondingDelegationRequest, + } as QueryUnbondingDelegationRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.delegatorAddr = reader.string(); + break; + case 2: + message.validatorAddr = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryUnbondingDelegationRequest { + const message = { + ...baseQueryUnbondingDelegationRequest, + } as QueryUnbondingDelegationRequest; + if (object.delegatorAddr !== undefined && object.delegatorAddr !== null) { + message.delegatorAddr = String(object.delegatorAddr); + } else { + message.delegatorAddr = ""; + } + if (object.validatorAddr !== undefined && object.validatorAddr !== null) { + message.validatorAddr = String(object.validatorAddr); + } else { + message.validatorAddr = ""; + } + return message; + }, + + toJSON(message: QueryUnbondingDelegationRequest): unknown { + const obj: any = {}; + message.delegatorAddr !== undefined && + (obj.delegatorAddr = message.delegatorAddr); + message.validatorAddr !== undefined && + (obj.validatorAddr = message.validatorAddr); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryUnbondingDelegationRequest { + const message = { + ...baseQueryUnbondingDelegationRequest, + } as QueryUnbondingDelegationRequest; + if (object.delegatorAddr !== undefined && object.delegatorAddr !== null) { + message.delegatorAddr = object.delegatorAddr; + } else { + message.delegatorAddr = ""; + } + if (object.validatorAddr !== undefined && object.validatorAddr !== null) { + message.validatorAddr = object.validatorAddr; + } else { + message.validatorAddr = ""; + } + return message; + }, +}; + +const baseQueryUnbondingDelegationResponse: object = {}; + +export const QueryUnbondingDelegationResponse = { + encode( + message: QueryUnbondingDelegationResponse, + writer: Writer = Writer.create() + ): Writer { + if (message.unbond !== undefined) { + UnbondingDelegation.encode( + message.unbond, + writer.uint32(10).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryUnbondingDelegationResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryUnbondingDelegationResponse, + } as QueryUnbondingDelegationResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.unbond = UnbondingDelegation.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryUnbondingDelegationResponse { + const message = { + ...baseQueryUnbondingDelegationResponse, + } as QueryUnbondingDelegationResponse; + if (object.unbond !== undefined && object.unbond !== null) { + message.unbond = UnbondingDelegation.fromJSON(object.unbond); + } else { + message.unbond = undefined; + } + return message; + }, + + toJSON(message: QueryUnbondingDelegationResponse): unknown { + const obj: any = {}; + message.unbond !== undefined && + (obj.unbond = message.unbond + ? UnbondingDelegation.toJSON(message.unbond) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryUnbondingDelegationResponse { + const message = { + ...baseQueryUnbondingDelegationResponse, + } as QueryUnbondingDelegationResponse; + if (object.unbond !== undefined && object.unbond !== null) { + message.unbond = UnbondingDelegation.fromPartial(object.unbond); + } else { + message.unbond = undefined; + } + return message; + }, +}; + +const baseQueryDelegatorDelegationsRequest: object = { delegatorAddr: "" }; + +export const QueryDelegatorDelegationsRequest = { + encode( + message: QueryDelegatorDelegationsRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.delegatorAddr !== "") { + writer.uint32(10).string(message.delegatorAddr); + } + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryDelegatorDelegationsRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryDelegatorDelegationsRequest, + } as QueryDelegatorDelegationsRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.delegatorAddr = reader.string(); + break; + case 2: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryDelegatorDelegationsRequest { + const message = { + ...baseQueryDelegatorDelegationsRequest, + } as QueryDelegatorDelegationsRequest; + if (object.delegatorAddr !== undefined && object.delegatorAddr !== null) { + message.delegatorAddr = String(object.delegatorAddr); + } else { + message.delegatorAddr = ""; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryDelegatorDelegationsRequest): unknown { + const obj: any = {}; + message.delegatorAddr !== undefined && + (obj.delegatorAddr = message.delegatorAddr); + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageRequest.toJSON(message.pagination) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryDelegatorDelegationsRequest { + const message = { + ...baseQueryDelegatorDelegationsRequest, + } as QueryDelegatorDelegationsRequest; + if (object.delegatorAddr !== undefined && object.delegatorAddr !== null) { + message.delegatorAddr = object.delegatorAddr; + } else { + message.delegatorAddr = ""; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseQueryDelegatorDelegationsResponse: object = {}; + +export const QueryDelegatorDelegationsResponse = { + encode( + message: QueryDelegatorDelegationsResponse, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.delegationResponses) { + DelegationResponse.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode( + message.pagination, + writer.uint32(18).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryDelegatorDelegationsResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryDelegatorDelegationsResponse, + } as QueryDelegatorDelegationsResponse; + message.delegationResponses = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.delegationResponses.push( + DelegationResponse.decode(reader, reader.uint32()) + ); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryDelegatorDelegationsResponse { + const message = { + ...baseQueryDelegatorDelegationsResponse, + } as QueryDelegatorDelegationsResponse; + message.delegationResponses = []; + if ( + object.delegationResponses !== undefined && + object.delegationResponses !== null + ) { + for (const e of object.delegationResponses) { + message.delegationResponses.push(DelegationResponse.fromJSON(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryDelegatorDelegationsResponse): unknown { + const obj: any = {}; + if (message.delegationResponses) { + obj.delegationResponses = message.delegationResponses.map((e) => + e ? DelegationResponse.toJSON(e) : undefined + ); + } else { + obj.delegationResponses = []; + } + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageResponse.toJSON(message.pagination) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryDelegatorDelegationsResponse { + const message = { + ...baseQueryDelegatorDelegationsResponse, + } as QueryDelegatorDelegationsResponse; + message.delegationResponses = []; + if ( + object.delegationResponses !== undefined && + object.delegationResponses !== null + ) { + for (const e of object.delegationResponses) { + message.delegationResponses.push(DelegationResponse.fromPartial(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseQueryDelegatorUnbondingDelegationsRequest: object = { + delegatorAddr: "", +}; + +export const QueryDelegatorUnbondingDelegationsRequest = { + encode( + message: QueryDelegatorUnbondingDelegationsRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.delegatorAddr !== "") { + writer.uint32(10).string(message.delegatorAddr); + } + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryDelegatorUnbondingDelegationsRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryDelegatorUnbondingDelegationsRequest, + } as QueryDelegatorUnbondingDelegationsRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.delegatorAddr = reader.string(); + break; + case 2: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryDelegatorUnbondingDelegationsRequest { + const message = { + ...baseQueryDelegatorUnbondingDelegationsRequest, + } as QueryDelegatorUnbondingDelegationsRequest; + if (object.delegatorAddr !== undefined && object.delegatorAddr !== null) { + message.delegatorAddr = String(object.delegatorAddr); + } else { + message.delegatorAddr = ""; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryDelegatorUnbondingDelegationsRequest): unknown { + const obj: any = {}; + message.delegatorAddr !== undefined && + (obj.delegatorAddr = message.delegatorAddr); + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageRequest.toJSON(message.pagination) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryDelegatorUnbondingDelegationsRequest { + const message = { + ...baseQueryDelegatorUnbondingDelegationsRequest, + } as QueryDelegatorUnbondingDelegationsRequest; + if (object.delegatorAddr !== undefined && object.delegatorAddr !== null) { + message.delegatorAddr = object.delegatorAddr; + } else { + message.delegatorAddr = ""; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseQueryDelegatorUnbondingDelegationsResponse: object = {}; + +export const QueryDelegatorUnbondingDelegationsResponse = { + encode( + message: QueryDelegatorUnbondingDelegationsResponse, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.unbondingResponses) { + UnbondingDelegation.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode( + message.pagination, + writer.uint32(18).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryDelegatorUnbondingDelegationsResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryDelegatorUnbondingDelegationsResponse, + } as QueryDelegatorUnbondingDelegationsResponse; + message.unbondingResponses = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.unbondingResponses.push( + UnbondingDelegation.decode(reader, reader.uint32()) + ); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryDelegatorUnbondingDelegationsResponse { + const message = { + ...baseQueryDelegatorUnbondingDelegationsResponse, + } as QueryDelegatorUnbondingDelegationsResponse; + message.unbondingResponses = []; + if ( + object.unbondingResponses !== undefined && + object.unbondingResponses !== null + ) { + for (const e of object.unbondingResponses) { + message.unbondingResponses.push(UnbondingDelegation.fromJSON(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryDelegatorUnbondingDelegationsResponse): unknown { + const obj: any = {}; + if (message.unbondingResponses) { + obj.unbondingResponses = message.unbondingResponses.map((e) => + e ? UnbondingDelegation.toJSON(e) : undefined + ); + } else { + obj.unbondingResponses = []; + } + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageResponse.toJSON(message.pagination) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryDelegatorUnbondingDelegationsResponse { + const message = { + ...baseQueryDelegatorUnbondingDelegationsResponse, + } as QueryDelegatorUnbondingDelegationsResponse; + message.unbondingResponses = []; + if ( + object.unbondingResponses !== undefined && + object.unbondingResponses !== null + ) { + for (const e of object.unbondingResponses) { + message.unbondingResponses.push(UnbondingDelegation.fromPartial(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseQueryRedelegationsRequest: object = { + delegatorAddr: "", + srcValidatorAddr: "", + dstValidatorAddr: "", +}; + +export const QueryRedelegationsRequest = { + encode( + message: QueryRedelegationsRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.delegatorAddr !== "") { + writer.uint32(10).string(message.delegatorAddr); + } + if (message.srcValidatorAddr !== "") { + writer.uint32(18).string(message.srcValidatorAddr); + } + if (message.dstValidatorAddr !== "") { + writer.uint32(26).string(message.dstValidatorAddr); + } + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(34).fork()).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryRedelegationsRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryRedelegationsRequest, + } as QueryRedelegationsRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.delegatorAddr = reader.string(); + break; + case 2: + message.srcValidatorAddr = reader.string(); + break; + case 3: + message.dstValidatorAddr = reader.string(); + break; + case 4: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryRedelegationsRequest { + const message = { + ...baseQueryRedelegationsRequest, + } as QueryRedelegationsRequest; + if (object.delegatorAddr !== undefined && object.delegatorAddr !== null) { + message.delegatorAddr = String(object.delegatorAddr); + } else { + message.delegatorAddr = ""; + } + if ( + object.srcValidatorAddr !== undefined && + object.srcValidatorAddr !== null + ) { + message.srcValidatorAddr = String(object.srcValidatorAddr); + } else { + message.srcValidatorAddr = ""; + } + if ( + object.dstValidatorAddr !== undefined && + object.dstValidatorAddr !== null + ) { + message.dstValidatorAddr = String(object.dstValidatorAddr); + } else { + message.dstValidatorAddr = ""; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryRedelegationsRequest): unknown { + const obj: any = {}; + message.delegatorAddr !== undefined && + (obj.delegatorAddr = message.delegatorAddr); + message.srcValidatorAddr !== undefined && + (obj.srcValidatorAddr = message.srcValidatorAddr); + message.dstValidatorAddr !== undefined && + (obj.dstValidatorAddr = message.dstValidatorAddr); + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageRequest.toJSON(message.pagination) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryRedelegationsRequest { + const message = { + ...baseQueryRedelegationsRequest, + } as QueryRedelegationsRequest; + if (object.delegatorAddr !== undefined && object.delegatorAddr !== null) { + message.delegatorAddr = object.delegatorAddr; + } else { + message.delegatorAddr = ""; + } + if ( + object.srcValidatorAddr !== undefined && + object.srcValidatorAddr !== null + ) { + message.srcValidatorAddr = object.srcValidatorAddr; + } else { + message.srcValidatorAddr = ""; + } + if ( + object.dstValidatorAddr !== undefined && + object.dstValidatorAddr !== null + ) { + message.dstValidatorAddr = object.dstValidatorAddr; + } else { + message.dstValidatorAddr = ""; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseQueryRedelegationsResponse: object = {}; + +export const QueryRedelegationsResponse = { + encode( + message: QueryRedelegationsResponse, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.redelegationResponses) { + RedelegationResponse.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode( + message.pagination, + writer.uint32(18).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryRedelegationsResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryRedelegationsResponse, + } as QueryRedelegationsResponse; + message.redelegationResponses = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.redelegationResponses.push( + RedelegationResponse.decode(reader, reader.uint32()) + ); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryRedelegationsResponse { + const message = { + ...baseQueryRedelegationsResponse, + } as QueryRedelegationsResponse; + message.redelegationResponses = []; + if ( + object.redelegationResponses !== undefined && + object.redelegationResponses !== null + ) { + for (const e of object.redelegationResponses) { + message.redelegationResponses.push(RedelegationResponse.fromJSON(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryRedelegationsResponse): unknown { + const obj: any = {}; + if (message.redelegationResponses) { + obj.redelegationResponses = message.redelegationResponses.map((e) => + e ? RedelegationResponse.toJSON(e) : undefined + ); + } else { + obj.redelegationResponses = []; + } + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageResponse.toJSON(message.pagination) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryRedelegationsResponse { + const message = { + ...baseQueryRedelegationsResponse, + } as QueryRedelegationsResponse; + message.redelegationResponses = []; + if ( + object.redelegationResponses !== undefined && + object.redelegationResponses !== null + ) { + for (const e of object.redelegationResponses) { + message.redelegationResponses.push(RedelegationResponse.fromPartial(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseQueryDelegatorValidatorsRequest: object = { delegatorAddr: "" }; + +export const QueryDelegatorValidatorsRequest = { + encode( + message: QueryDelegatorValidatorsRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.delegatorAddr !== "") { + writer.uint32(10).string(message.delegatorAddr); + } + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryDelegatorValidatorsRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryDelegatorValidatorsRequest, + } as QueryDelegatorValidatorsRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.delegatorAddr = reader.string(); + break; + case 2: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryDelegatorValidatorsRequest { + const message = { + ...baseQueryDelegatorValidatorsRequest, + } as QueryDelegatorValidatorsRequest; + if (object.delegatorAddr !== undefined && object.delegatorAddr !== null) { + message.delegatorAddr = String(object.delegatorAddr); + } else { + message.delegatorAddr = ""; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryDelegatorValidatorsRequest): unknown { + const obj: any = {}; + message.delegatorAddr !== undefined && + (obj.delegatorAddr = message.delegatorAddr); + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageRequest.toJSON(message.pagination) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryDelegatorValidatorsRequest { + const message = { + ...baseQueryDelegatorValidatorsRequest, + } as QueryDelegatorValidatorsRequest; + if (object.delegatorAddr !== undefined && object.delegatorAddr !== null) { + message.delegatorAddr = object.delegatorAddr; + } else { + message.delegatorAddr = ""; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseQueryDelegatorValidatorsResponse: object = {}; + +export const QueryDelegatorValidatorsResponse = { + encode( + message: QueryDelegatorValidatorsResponse, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.validators) { + Validator.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode( + message.pagination, + writer.uint32(18).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryDelegatorValidatorsResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryDelegatorValidatorsResponse, + } as QueryDelegatorValidatorsResponse; + message.validators = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.validators.push(Validator.decode(reader, reader.uint32())); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryDelegatorValidatorsResponse { + const message = { + ...baseQueryDelegatorValidatorsResponse, + } as QueryDelegatorValidatorsResponse; + message.validators = []; + if (object.validators !== undefined && object.validators !== null) { + for (const e of object.validators) { + message.validators.push(Validator.fromJSON(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryDelegatorValidatorsResponse): unknown { + const obj: any = {}; + if (message.validators) { + obj.validators = message.validators.map((e) => + e ? Validator.toJSON(e) : undefined + ); + } else { + obj.validators = []; + } + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageResponse.toJSON(message.pagination) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryDelegatorValidatorsResponse { + const message = { + ...baseQueryDelegatorValidatorsResponse, + } as QueryDelegatorValidatorsResponse; + message.validators = []; + if (object.validators !== undefined && object.validators !== null) { + for (const e of object.validators) { + message.validators.push(Validator.fromPartial(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseQueryDelegatorValidatorRequest: object = { + delegatorAddr: "", + validatorAddr: "", +}; + +export const QueryDelegatorValidatorRequest = { + encode( + message: QueryDelegatorValidatorRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.delegatorAddr !== "") { + writer.uint32(10).string(message.delegatorAddr); + } + if (message.validatorAddr !== "") { + writer.uint32(18).string(message.validatorAddr); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryDelegatorValidatorRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryDelegatorValidatorRequest, + } as QueryDelegatorValidatorRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.delegatorAddr = reader.string(); + break; + case 2: + message.validatorAddr = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryDelegatorValidatorRequest { + const message = { + ...baseQueryDelegatorValidatorRequest, + } as QueryDelegatorValidatorRequest; + if (object.delegatorAddr !== undefined && object.delegatorAddr !== null) { + message.delegatorAddr = String(object.delegatorAddr); + } else { + message.delegatorAddr = ""; + } + if (object.validatorAddr !== undefined && object.validatorAddr !== null) { + message.validatorAddr = String(object.validatorAddr); + } else { + message.validatorAddr = ""; + } + return message; + }, + + toJSON(message: QueryDelegatorValidatorRequest): unknown { + const obj: any = {}; + message.delegatorAddr !== undefined && + (obj.delegatorAddr = message.delegatorAddr); + message.validatorAddr !== undefined && + (obj.validatorAddr = message.validatorAddr); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryDelegatorValidatorRequest { + const message = { + ...baseQueryDelegatorValidatorRequest, + } as QueryDelegatorValidatorRequest; + if (object.delegatorAddr !== undefined && object.delegatorAddr !== null) { + message.delegatorAddr = object.delegatorAddr; + } else { + message.delegatorAddr = ""; + } + if (object.validatorAddr !== undefined && object.validatorAddr !== null) { + message.validatorAddr = object.validatorAddr; + } else { + message.validatorAddr = ""; + } + return message; + }, +}; + +const baseQueryDelegatorValidatorResponse: object = {}; + +export const QueryDelegatorValidatorResponse = { + encode( + message: QueryDelegatorValidatorResponse, + writer: Writer = Writer.create() + ): Writer { + if (message.validator !== undefined) { + Validator.encode(message.validator, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryDelegatorValidatorResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryDelegatorValidatorResponse, + } as QueryDelegatorValidatorResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.validator = Validator.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryDelegatorValidatorResponse { + const message = { + ...baseQueryDelegatorValidatorResponse, + } as QueryDelegatorValidatorResponse; + if (object.validator !== undefined && object.validator !== null) { + message.validator = Validator.fromJSON(object.validator); + } else { + message.validator = undefined; + } + return message; + }, + + toJSON(message: QueryDelegatorValidatorResponse): unknown { + const obj: any = {}; + message.validator !== undefined && + (obj.validator = message.validator + ? Validator.toJSON(message.validator) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryDelegatorValidatorResponse { + const message = { + ...baseQueryDelegatorValidatorResponse, + } as QueryDelegatorValidatorResponse; + if (object.validator !== undefined && object.validator !== null) { + message.validator = Validator.fromPartial(object.validator); + } else { + message.validator = undefined; + } + return message; + }, +}; + +const baseQueryHistoricalInfoRequest: object = { height: 0 }; + +export const QueryHistoricalInfoRequest = { + encode( + message: QueryHistoricalInfoRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.height !== 0) { + writer.uint32(8).int64(message.height); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryHistoricalInfoRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryHistoricalInfoRequest, + } as QueryHistoricalInfoRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.height = longToNumber(reader.int64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryHistoricalInfoRequest { + const message = { + ...baseQueryHistoricalInfoRequest, + } as QueryHistoricalInfoRequest; + if (object.height !== undefined && object.height !== null) { + message.height = Number(object.height); + } else { + message.height = 0; + } + return message; + }, + + toJSON(message: QueryHistoricalInfoRequest): unknown { + const obj: any = {}; + message.height !== undefined && (obj.height = message.height); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryHistoricalInfoRequest { + const message = { + ...baseQueryHistoricalInfoRequest, + } as QueryHistoricalInfoRequest; + if (object.height !== undefined && object.height !== null) { + message.height = object.height; + } else { + message.height = 0; + } + return message; + }, +}; + +const baseQueryHistoricalInfoResponse: object = {}; + +export const QueryHistoricalInfoResponse = { + encode( + message: QueryHistoricalInfoResponse, + writer: Writer = Writer.create() + ): Writer { + if (message.hist !== undefined) { + HistoricalInfo.encode(message.hist, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryHistoricalInfoResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryHistoricalInfoResponse, + } as QueryHistoricalInfoResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.hist = HistoricalInfo.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryHistoricalInfoResponse { + const message = { + ...baseQueryHistoricalInfoResponse, + } as QueryHistoricalInfoResponse; + if (object.hist !== undefined && object.hist !== null) { + message.hist = HistoricalInfo.fromJSON(object.hist); + } else { + message.hist = undefined; + } + return message; + }, + + toJSON(message: QueryHistoricalInfoResponse): unknown { + const obj: any = {}; + message.hist !== undefined && + (obj.hist = message.hist + ? HistoricalInfo.toJSON(message.hist) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryHistoricalInfoResponse { + const message = { + ...baseQueryHistoricalInfoResponse, + } as QueryHistoricalInfoResponse; + if (object.hist !== undefined && object.hist !== null) { + message.hist = HistoricalInfo.fromPartial(object.hist); + } else { + message.hist = undefined; + } + return message; + }, +}; + +const baseQueryPoolRequest: object = {}; + +export const QueryPoolRequest = { + encode(_: QueryPoolRequest, writer: Writer = Writer.create()): Writer { + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QueryPoolRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryPoolRequest } as QueryPoolRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): QueryPoolRequest { + const message = { ...baseQueryPoolRequest } as QueryPoolRequest; + return message; + }, + + toJSON(_: QueryPoolRequest): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial(_: DeepPartial): QueryPoolRequest { + const message = { ...baseQueryPoolRequest } as QueryPoolRequest; + return message; + }, +}; + +const baseQueryPoolResponse: object = {}; + +export const QueryPoolResponse = { + encode(message: QueryPoolResponse, writer: Writer = Writer.create()): Writer { + if (message.pool !== undefined) { + Pool.encode(message.pool, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QueryPoolResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryPoolResponse } as QueryPoolResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.pool = Pool.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryPoolResponse { + const message = { ...baseQueryPoolResponse } as QueryPoolResponse; + if (object.pool !== undefined && object.pool !== null) { + message.pool = Pool.fromJSON(object.pool); + } else { + message.pool = undefined; + } + return message; + }, + + toJSON(message: QueryPoolResponse): unknown { + const obj: any = {}; + message.pool !== undefined && + (obj.pool = message.pool ? Pool.toJSON(message.pool) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): QueryPoolResponse { + const message = { ...baseQueryPoolResponse } as QueryPoolResponse; + if (object.pool !== undefined && object.pool !== null) { + message.pool = Pool.fromPartial(object.pool); + } else { + message.pool = undefined; + } + return message; + }, +}; + +const baseQueryParamsRequest: object = {}; + +export const QueryParamsRequest = { + encode(_: QueryParamsRequest, writer: Writer = Writer.create()): Writer { + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QueryParamsRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryParamsRequest } as QueryParamsRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): QueryParamsRequest { + const message = { ...baseQueryParamsRequest } as QueryParamsRequest; + return message; + }, + + toJSON(_: QueryParamsRequest): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial(_: DeepPartial): QueryParamsRequest { + const message = { ...baseQueryParamsRequest } as QueryParamsRequest; + return message; + }, +}; + +const baseQueryParamsResponse: object = {}; + +export const QueryParamsResponse = { + encode( + message: QueryParamsResponse, + writer: Writer = Writer.create() + ): Writer { + if (message.params !== undefined) { + Params.encode(message.params, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QueryParamsResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryParamsResponse } as QueryParamsResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.params = Params.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryParamsResponse { + const message = { ...baseQueryParamsResponse } as QueryParamsResponse; + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromJSON(object.params); + } else { + message.params = undefined; + } + return message; + }, + + toJSON(message: QueryParamsResponse): unknown { + const obj: any = {}; + message.params !== undefined && + (obj.params = message.params ? Params.toJSON(message.params) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): QueryParamsResponse { + const message = { ...baseQueryParamsResponse } as QueryParamsResponse; + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromPartial(object.params); + } else { + message.params = undefined; + } + return message; + }, +}; + +/** Query defines the gRPC querier service. */ +export interface Query { + /** Validators queries all validators that match the given status. */ + Validators(request: QueryValidatorsRequest): Promise; + /** Validator queries validator info for given validator address. */ + Validator(request: QueryValidatorRequest): Promise; + /** ValidatorDelegations queries delegate info for given validator. */ + ValidatorDelegations( + request: QueryValidatorDelegationsRequest + ): Promise; + /** ValidatorUnbondingDelegations queries unbonding delegations of a validator. */ + ValidatorUnbondingDelegations( + request: QueryValidatorUnbondingDelegationsRequest + ): Promise; + /** Delegation queries delegate info for given validator delegator pair. */ + Delegation(request: QueryDelegationRequest): Promise; + /** + * UnbondingDelegation queries unbonding info for given validator delegator + * pair. + */ + UnbondingDelegation( + request: QueryUnbondingDelegationRequest + ): Promise; + /** DelegatorDelegations queries all delegations of a given delegator address. */ + DelegatorDelegations( + request: QueryDelegatorDelegationsRequest + ): Promise; + /** + * DelegatorUnbondingDelegations queries all unbonding delegations of a given + * delegator address. + */ + DelegatorUnbondingDelegations( + request: QueryDelegatorUnbondingDelegationsRequest + ): Promise; + /** Redelegations queries redelegations of given address. */ + Redelegations( + request: QueryRedelegationsRequest + ): Promise; + /** + * DelegatorValidators queries all validators info for given delegator + * address. + */ + DelegatorValidators( + request: QueryDelegatorValidatorsRequest + ): Promise; + /** + * DelegatorValidator queries validator info for given delegator validator + * pair. + */ + DelegatorValidator( + request: QueryDelegatorValidatorRequest + ): Promise; + /** HistoricalInfo queries the historical info for given height. */ + HistoricalInfo( + request: QueryHistoricalInfoRequest + ): Promise; + /** Pool queries the pool info. */ + Pool(request: QueryPoolRequest): Promise; + /** Parameters queries the staking parameters. */ + Params(request: QueryParamsRequest): Promise; +} + +export class QueryClientImpl implements Query { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + } + Validators( + request: QueryValidatorsRequest + ): Promise { + const data = QueryValidatorsRequest.encode(request).finish(); + const promise = this.rpc.request( + "cosmos.staking.v1beta1.Query", + "Validators", + data + ); + return promise.then((data) => + QueryValidatorsResponse.decode(new Reader(data)) + ); + } + + Validator(request: QueryValidatorRequest): Promise { + const data = QueryValidatorRequest.encode(request).finish(); + const promise = this.rpc.request( + "cosmos.staking.v1beta1.Query", + "Validator", + data + ); + return promise.then((data) => + QueryValidatorResponse.decode(new Reader(data)) + ); + } + + ValidatorDelegations( + request: QueryValidatorDelegationsRequest + ): Promise { + const data = QueryValidatorDelegationsRequest.encode(request).finish(); + const promise = this.rpc.request( + "cosmos.staking.v1beta1.Query", + "ValidatorDelegations", + data + ); + return promise.then((data) => + QueryValidatorDelegationsResponse.decode(new Reader(data)) + ); + } + + ValidatorUnbondingDelegations( + request: QueryValidatorUnbondingDelegationsRequest + ): Promise { + const data = QueryValidatorUnbondingDelegationsRequest.encode( + request + ).finish(); + const promise = this.rpc.request( + "cosmos.staking.v1beta1.Query", + "ValidatorUnbondingDelegations", + data + ); + return promise.then((data) => + QueryValidatorUnbondingDelegationsResponse.decode(new Reader(data)) + ); + } + + Delegation( + request: QueryDelegationRequest + ): Promise { + const data = QueryDelegationRequest.encode(request).finish(); + const promise = this.rpc.request( + "cosmos.staking.v1beta1.Query", + "Delegation", + data + ); + return promise.then((data) => + QueryDelegationResponse.decode(new Reader(data)) + ); + } + + UnbondingDelegation( + request: QueryUnbondingDelegationRequest + ): Promise { + const data = QueryUnbondingDelegationRequest.encode(request).finish(); + const promise = this.rpc.request( + "cosmos.staking.v1beta1.Query", + "UnbondingDelegation", + data + ); + return promise.then((data) => + QueryUnbondingDelegationResponse.decode(new Reader(data)) + ); + } + + DelegatorDelegations( + request: QueryDelegatorDelegationsRequest + ): Promise { + const data = QueryDelegatorDelegationsRequest.encode(request).finish(); + const promise = this.rpc.request( + "cosmos.staking.v1beta1.Query", + "DelegatorDelegations", + data + ); + return promise.then((data) => + QueryDelegatorDelegationsResponse.decode(new Reader(data)) + ); + } + + DelegatorUnbondingDelegations( + request: QueryDelegatorUnbondingDelegationsRequest + ): Promise { + const data = QueryDelegatorUnbondingDelegationsRequest.encode( + request + ).finish(); + const promise = this.rpc.request( + "cosmos.staking.v1beta1.Query", + "DelegatorUnbondingDelegations", + data + ); + return promise.then((data) => + QueryDelegatorUnbondingDelegationsResponse.decode(new Reader(data)) + ); + } + + Redelegations( + request: QueryRedelegationsRequest + ): Promise { + const data = QueryRedelegationsRequest.encode(request).finish(); + const promise = this.rpc.request( + "cosmos.staking.v1beta1.Query", + "Redelegations", + data + ); + return promise.then((data) => + QueryRedelegationsResponse.decode(new Reader(data)) + ); + } + + DelegatorValidators( + request: QueryDelegatorValidatorsRequest + ): Promise { + const data = QueryDelegatorValidatorsRequest.encode(request).finish(); + const promise = this.rpc.request( + "cosmos.staking.v1beta1.Query", + "DelegatorValidators", + data + ); + return promise.then((data) => + QueryDelegatorValidatorsResponse.decode(new Reader(data)) + ); + } + + DelegatorValidator( + request: QueryDelegatorValidatorRequest + ): Promise { + const data = QueryDelegatorValidatorRequest.encode(request).finish(); + const promise = this.rpc.request( + "cosmos.staking.v1beta1.Query", + "DelegatorValidator", + data + ); + return promise.then((data) => + QueryDelegatorValidatorResponse.decode(new Reader(data)) + ); + } + + HistoricalInfo( + request: QueryHistoricalInfoRequest + ): Promise { + const data = QueryHistoricalInfoRequest.encode(request).finish(); + const promise = this.rpc.request( + "cosmos.staking.v1beta1.Query", + "HistoricalInfo", + data + ); + return promise.then((data) => + QueryHistoricalInfoResponse.decode(new Reader(data)) + ); + } + + Pool(request: QueryPoolRequest): Promise { + const data = QueryPoolRequest.encode(request).finish(); + const promise = this.rpc.request( + "cosmos.staking.v1beta1.Query", + "Pool", + data + ); + return promise.then((data) => QueryPoolResponse.decode(new Reader(data))); + } + + Params(request: QueryParamsRequest): Promise { + const data = QueryParamsRequest.encode(request).finish(); + const promise = this.rpc.request( + "cosmos.staking.v1beta1.Query", + "Params", + data + ); + return promise.then((data) => QueryParamsResponse.decode(new Reader(data))); + } +} + +interface Rpc { + request( + service: string, + method: string, + data: Uint8Array + ): Promise; +} + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/cosmos.staking.v1beta1/types/cosmos/staking/v1beta1/staking.ts b/ts-client/cosmos.staking.v1beta1/types/cosmos/staking/v1beta1/staking.ts new file mode 100644 index 00000000..609cc763 --- /dev/null +++ b/ts-client/cosmos.staking.v1beta1/types/cosmos/staking/v1beta1/staking.ts @@ -0,0 +1,2561 @@ +/* eslint-disable */ +import { Timestamp } from "../../../google/protobuf/timestamp"; +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; +import { Header } from "../../../tendermint/types/types"; +import { Any } from "../../../google/protobuf/any"; +import { Duration } from "../../../google/protobuf/duration"; +import { Coin } from "../../../cosmos/base/v1beta1/coin"; + +export const protobufPackage = "cosmos.staking.v1beta1"; + +/** BondStatus is the status of a validator. */ +export enum BondStatus { + /** BOND_STATUS_UNSPECIFIED - UNSPECIFIED defines an invalid validator status. */ + BOND_STATUS_UNSPECIFIED = 0, + /** BOND_STATUS_UNBONDED - UNBONDED defines a validator that is not bonded. */ + BOND_STATUS_UNBONDED = 1, + /** BOND_STATUS_UNBONDING - UNBONDING defines a validator that is unbonding. */ + BOND_STATUS_UNBONDING = 2, + /** BOND_STATUS_BONDED - BONDED defines a validator that is bonded. */ + BOND_STATUS_BONDED = 3, + UNRECOGNIZED = -1, +} + +export function bondStatusFromJSON(object: any): BondStatus { + switch (object) { + case 0: + case "BOND_STATUS_UNSPECIFIED": + return BondStatus.BOND_STATUS_UNSPECIFIED; + case 1: + case "BOND_STATUS_UNBONDED": + return BondStatus.BOND_STATUS_UNBONDED; + case 2: + case "BOND_STATUS_UNBONDING": + return BondStatus.BOND_STATUS_UNBONDING; + case 3: + case "BOND_STATUS_BONDED": + return BondStatus.BOND_STATUS_BONDED; + case -1: + case "UNRECOGNIZED": + default: + return BondStatus.UNRECOGNIZED; + } +} + +export function bondStatusToJSON(object: BondStatus): string { + switch (object) { + case BondStatus.BOND_STATUS_UNSPECIFIED: + return "BOND_STATUS_UNSPECIFIED"; + case BondStatus.BOND_STATUS_UNBONDED: + return "BOND_STATUS_UNBONDED"; + case BondStatus.BOND_STATUS_UNBONDING: + return "BOND_STATUS_UNBONDING"; + case BondStatus.BOND_STATUS_BONDED: + return "BOND_STATUS_BONDED"; + default: + return "UNKNOWN"; + } +} + +/** + * HistoricalInfo contains header and validator information for a given block. + * It is stored as part of staking module's state, which persists the `n` most + * recent HistoricalInfo + * (`n` is set by the staking module's `historical_entries` parameter). + */ +export interface HistoricalInfo { + header: Header | undefined; + valset: Validator[]; +} + +/** + * CommissionRates defines the initial commission rates to be used for creating + * a validator. + */ +export interface CommissionRates { + /** rate is the commission rate charged to delegators, as a fraction. */ + rate: string; + /** max_rate defines the maximum commission rate which validator can ever charge, as a fraction. */ + maxRate: string; + /** max_change_rate defines the maximum daily increase of the validator commission, as a fraction. */ + maxChangeRate: string; +} + +/** Commission defines commission parameters for a given validator. */ +export interface Commission { + /** commission_rates defines the initial commission rates to be used for creating a validator. */ + commissionRates: CommissionRates | undefined; + /** update_time is the last time the commission rate was changed. */ + updateTime: Date | undefined; +} + +/** Description defines a validator description. */ +export interface Description { + /** moniker defines a human-readable name for the validator. */ + moniker: string; + /** identity defines an optional identity signature (ex. UPort or Keybase). */ + identity: string; + /** website defines an optional website link. */ + website: string; + /** security_contact defines an optional email for security contact. */ + securityContact: string; + /** details define other optional details. */ + details: string; +} + +/** + * Validator defines a validator, together with the total amount of the + * Validator's bond shares and their exchange rate to coins. Slashing results in + * a decrease in the exchange rate, allowing correct calculation of future + * undelegations without iterating over delegators. When coins are delegated to + * this validator, the validator is credited with a delegation whose number of + * bond shares is based on the amount of coins delegated divided by the current + * exchange rate. Voting power can be calculated as total bonded shares + * multiplied by exchange rate. + */ +export interface Validator { + /** operator_address defines the address of the validator's operator; bech encoded in JSON. */ + operatorAddress: string; + /** consensus_pubkey is the consensus public key of the validator, as a Protobuf Any. */ + consensusPubkey: Any | undefined; + /** jailed defined whether the validator has been jailed from bonded status or not. */ + jailed: boolean; + /** status is the validator status (bonded/unbonding/unbonded). */ + status: BondStatus; + /** tokens define the delegated tokens (incl. self-delegation). */ + tokens: string; + /** delegator_shares defines total shares issued to a validator's delegators. */ + delegatorShares: string; + /** description defines the description terms for the validator. */ + description: Description | undefined; + /** unbonding_height defines, if unbonding, the height at which this validator has begun unbonding. */ + unbondingHeight: number; + /** unbonding_time defines, if unbonding, the min time for the validator to complete unbonding. */ + unbondingTime: Date | undefined; + /** commission defines the commission parameters. */ + commission: Commission | undefined; + /** min_self_delegation is the validator's self declared minimum self delegation. */ + minSelfDelegation: string; +} + +/** ValAddresses defines a repeated set of validator addresses. */ +export interface ValAddresses { + addresses: string[]; +} + +/** + * DVPair is struct that just has a delegator-validator pair with no other data. + * It is intended to be used as a marshalable pointer. For example, a DVPair can + * be used to construct the key to getting an UnbondingDelegation from state. + */ +export interface DVPair { + delegatorAddress: string; + validatorAddress: string; +} + +/** DVPairs defines an array of DVPair objects. */ +export interface DVPairs { + pairs: DVPair[]; +} + +/** + * DVVTriplet is struct that just has a delegator-validator-validator triplet + * with no other data. It is intended to be used as a marshalable pointer. For + * example, a DVVTriplet can be used to construct the key to getting a + * Redelegation from state. + */ +export interface DVVTriplet { + delegatorAddress: string; + validatorSrcAddress: string; + validatorDstAddress: string; +} + +/** DVVTriplets defines an array of DVVTriplet objects. */ +export interface DVVTriplets { + triplets: DVVTriplet[]; +} + +/** + * Delegation represents the bond with tokens held by an account. It is + * owned by one delegator, and is associated with the voting power of one + * validator. + */ +export interface Delegation { + /** delegator_address is the bech32-encoded address of the delegator. */ + delegatorAddress: string; + /** validator_address is the bech32-encoded address of the validator. */ + validatorAddress: string; + /** shares define the delegation shares received. */ + shares: string; +} + +/** + * UnbondingDelegation stores all of a single delegator's unbonding bonds + * for a single validator in an time-ordered list. + */ +export interface UnbondingDelegation { + /** delegator_address is the bech32-encoded address of the delegator. */ + delegatorAddress: string; + /** validator_address is the bech32-encoded address of the validator. */ + validatorAddress: string; + /** entries are the unbonding delegation entries. */ + entries: UnbondingDelegationEntry[]; +} + +/** UnbondingDelegationEntry defines an unbonding object with relevant metadata. */ +export interface UnbondingDelegationEntry { + /** creation_height is the height which the unbonding took place. */ + creationHeight: number; + /** completion_time is the unix time for unbonding completion. */ + completionTime: Date | undefined; + /** initial_balance defines the tokens initially scheduled to receive at completion. */ + initialBalance: string; + /** balance defines the tokens to receive at completion. */ + balance: string; +} + +/** RedelegationEntry defines a redelegation object with relevant metadata. */ +export interface RedelegationEntry { + /** creation_height defines the height which the redelegation took place. */ + creationHeight: number; + /** completion_time defines the unix time for redelegation completion. */ + completionTime: Date | undefined; + /** initial_balance defines the initial balance when redelegation started. */ + initialBalance: string; + /** shares_dst is the amount of destination-validator shares created by redelegation. */ + sharesDst: string; +} + +/** + * Redelegation contains the list of a particular delegator's redelegating bonds + * from a particular source validator to a particular destination validator. + */ +export interface Redelegation { + /** delegator_address is the bech32-encoded address of the delegator. */ + delegatorAddress: string; + /** validator_src_address is the validator redelegation source operator address. */ + validatorSrcAddress: string; + /** validator_dst_address is the validator redelegation destination operator address. */ + validatorDstAddress: string; + /** entries are the redelegation entries. */ + entries: RedelegationEntry[]; +} + +/** Params defines the parameters for the staking module. */ +export interface Params { + /** unbonding_time is the time duration of unbonding. */ + unbondingTime: Duration | undefined; + /** max_validators is the maximum number of validators. */ + maxValidators: number; + /** max_entries is the max entries for either unbonding delegation or redelegation (per pair/trio). */ + maxEntries: number; + /** historical_entries is the number of historical entries to persist. */ + historicalEntries: number; + /** bond_denom defines the bondable coin denomination. */ + bondDenom: string; +} + +/** + * DelegationResponse is equivalent to Delegation except that it contains a + * balance in addition to shares which is more suitable for client responses. + */ +export interface DelegationResponse { + delegation: Delegation | undefined; + balance: Coin | undefined; +} + +/** + * RedelegationEntryResponse is equivalent to a RedelegationEntry except that it + * contains a balance in addition to shares which is more suitable for client + * responses. + */ +export interface RedelegationEntryResponse { + redelegationEntry: RedelegationEntry | undefined; + balance: string; +} + +/** + * RedelegationResponse is equivalent to a Redelegation except that its entries + * contain a balance in addition to shares which is more suitable for client + * responses. + */ +export interface RedelegationResponse { + redelegation: Redelegation | undefined; + entries: RedelegationEntryResponse[]; +} + +/** + * Pool is used for tracking bonded and not-bonded token supply of the bond + * denomination. + */ +export interface Pool { + notBondedTokens: string; + bondedTokens: string; +} + +const baseHistoricalInfo: object = {}; + +export const HistoricalInfo = { + encode(message: HistoricalInfo, writer: Writer = Writer.create()): Writer { + if (message.header !== undefined) { + Header.encode(message.header, writer.uint32(10).fork()).ldelim(); + } + for (const v of message.valset) { + Validator.encode(v!, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): HistoricalInfo { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseHistoricalInfo } as HistoricalInfo; + message.valset = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.header = Header.decode(reader, reader.uint32()); + break; + case 2: + message.valset.push(Validator.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): HistoricalInfo { + const message = { ...baseHistoricalInfo } as HistoricalInfo; + message.valset = []; + if (object.header !== undefined && object.header !== null) { + message.header = Header.fromJSON(object.header); + } else { + message.header = undefined; + } + if (object.valset !== undefined && object.valset !== null) { + for (const e of object.valset) { + message.valset.push(Validator.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: HistoricalInfo): unknown { + const obj: any = {}; + message.header !== undefined && + (obj.header = message.header ? Header.toJSON(message.header) : undefined); + if (message.valset) { + obj.valset = message.valset.map((e) => + e ? Validator.toJSON(e) : undefined + ); + } else { + obj.valset = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): HistoricalInfo { + const message = { ...baseHistoricalInfo } as HistoricalInfo; + message.valset = []; + if (object.header !== undefined && object.header !== null) { + message.header = Header.fromPartial(object.header); + } else { + message.header = undefined; + } + if (object.valset !== undefined && object.valset !== null) { + for (const e of object.valset) { + message.valset.push(Validator.fromPartial(e)); + } + } + return message; + }, +}; + +const baseCommissionRates: object = { + rate: "", + maxRate: "", + maxChangeRate: "", +}; + +export const CommissionRates = { + encode(message: CommissionRates, writer: Writer = Writer.create()): Writer { + if (message.rate !== "") { + writer.uint32(10).string(message.rate); + } + if (message.maxRate !== "") { + writer.uint32(18).string(message.maxRate); + } + if (message.maxChangeRate !== "") { + writer.uint32(26).string(message.maxChangeRate); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): CommissionRates { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseCommissionRates } as CommissionRates; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.rate = reader.string(); + break; + case 2: + message.maxRate = reader.string(); + break; + case 3: + message.maxChangeRate = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): CommissionRates { + const message = { ...baseCommissionRates } as CommissionRates; + if (object.rate !== undefined && object.rate !== null) { + message.rate = String(object.rate); + } else { + message.rate = ""; + } + if (object.maxRate !== undefined && object.maxRate !== null) { + message.maxRate = String(object.maxRate); + } else { + message.maxRate = ""; + } + if (object.maxChangeRate !== undefined && object.maxChangeRate !== null) { + message.maxChangeRate = String(object.maxChangeRate); + } else { + message.maxChangeRate = ""; + } + return message; + }, + + toJSON(message: CommissionRates): unknown { + const obj: any = {}; + message.rate !== undefined && (obj.rate = message.rate); + message.maxRate !== undefined && (obj.maxRate = message.maxRate); + message.maxChangeRate !== undefined && + (obj.maxChangeRate = message.maxChangeRate); + return obj; + }, + + fromPartial(object: DeepPartial): CommissionRates { + const message = { ...baseCommissionRates } as CommissionRates; + if (object.rate !== undefined && object.rate !== null) { + message.rate = object.rate; + } else { + message.rate = ""; + } + if (object.maxRate !== undefined && object.maxRate !== null) { + message.maxRate = object.maxRate; + } else { + message.maxRate = ""; + } + if (object.maxChangeRate !== undefined && object.maxChangeRate !== null) { + message.maxChangeRate = object.maxChangeRate; + } else { + message.maxChangeRate = ""; + } + return message; + }, +}; + +const baseCommission: object = {}; + +export const Commission = { + encode(message: Commission, writer: Writer = Writer.create()): Writer { + if (message.commissionRates !== undefined) { + CommissionRates.encode( + message.commissionRates, + writer.uint32(10).fork() + ).ldelim(); + } + if (message.updateTime !== undefined) { + Timestamp.encode( + toTimestamp(message.updateTime), + writer.uint32(18).fork() + ).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Commission { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseCommission } as Commission; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.commissionRates = CommissionRates.decode( + reader, + reader.uint32() + ); + break; + case 2: + message.updateTime = fromTimestamp( + Timestamp.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Commission { + const message = { ...baseCommission } as Commission; + if ( + object.commissionRates !== undefined && + object.commissionRates !== null + ) { + message.commissionRates = CommissionRates.fromJSON( + object.commissionRates + ); + } else { + message.commissionRates = undefined; + } + if (object.updateTime !== undefined && object.updateTime !== null) { + message.updateTime = fromJsonTimestamp(object.updateTime); + } else { + message.updateTime = undefined; + } + return message; + }, + + toJSON(message: Commission): unknown { + const obj: any = {}; + message.commissionRates !== undefined && + (obj.commissionRates = message.commissionRates + ? CommissionRates.toJSON(message.commissionRates) + : undefined); + message.updateTime !== undefined && + (obj.updateTime = + message.updateTime !== undefined + ? message.updateTime.toISOString() + : null); + return obj; + }, + + fromPartial(object: DeepPartial): Commission { + const message = { ...baseCommission } as Commission; + if ( + object.commissionRates !== undefined && + object.commissionRates !== null + ) { + message.commissionRates = CommissionRates.fromPartial( + object.commissionRates + ); + } else { + message.commissionRates = undefined; + } + if (object.updateTime !== undefined && object.updateTime !== null) { + message.updateTime = object.updateTime; + } else { + message.updateTime = undefined; + } + return message; + }, +}; + +const baseDescription: object = { + moniker: "", + identity: "", + website: "", + securityContact: "", + details: "", +}; + +export const Description = { + encode(message: Description, writer: Writer = Writer.create()): Writer { + if (message.moniker !== "") { + writer.uint32(10).string(message.moniker); + } + if (message.identity !== "") { + writer.uint32(18).string(message.identity); + } + if (message.website !== "") { + writer.uint32(26).string(message.website); + } + if (message.securityContact !== "") { + writer.uint32(34).string(message.securityContact); + } + if (message.details !== "") { + writer.uint32(42).string(message.details); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Description { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseDescription } as Description; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.moniker = reader.string(); + break; + case 2: + message.identity = reader.string(); + break; + case 3: + message.website = reader.string(); + break; + case 4: + message.securityContact = reader.string(); + break; + case 5: + message.details = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Description { + const message = { ...baseDescription } as Description; + if (object.moniker !== undefined && object.moniker !== null) { + message.moniker = String(object.moniker); + } else { + message.moniker = ""; + } + if (object.identity !== undefined && object.identity !== null) { + message.identity = String(object.identity); + } else { + message.identity = ""; + } + if (object.website !== undefined && object.website !== null) { + message.website = String(object.website); + } else { + message.website = ""; + } + if ( + object.securityContact !== undefined && + object.securityContact !== null + ) { + message.securityContact = String(object.securityContact); + } else { + message.securityContact = ""; + } + if (object.details !== undefined && object.details !== null) { + message.details = String(object.details); + } else { + message.details = ""; + } + return message; + }, + + toJSON(message: Description): unknown { + const obj: any = {}; + message.moniker !== undefined && (obj.moniker = message.moniker); + message.identity !== undefined && (obj.identity = message.identity); + message.website !== undefined && (obj.website = message.website); + message.securityContact !== undefined && + (obj.securityContact = message.securityContact); + message.details !== undefined && (obj.details = message.details); + return obj; + }, + + fromPartial(object: DeepPartial): Description { + const message = { ...baseDescription } as Description; + if (object.moniker !== undefined && object.moniker !== null) { + message.moniker = object.moniker; + } else { + message.moniker = ""; + } + if (object.identity !== undefined && object.identity !== null) { + message.identity = object.identity; + } else { + message.identity = ""; + } + if (object.website !== undefined && object.website !== null) { + message.website = object.website; + } else { + message.website = ""; + } + if ( + object.securityContact !== undefined && + object.securityContact !== null + ) { + message.securityContact = object.securityContact; + } else { + message.securityContact = ""; + } + if (object.details !== undefined && object.details !== null) { + message.details = object.details; + } else { + message.details = ""; + } + return message; + }, +}; + +const baseValidator: object = { + operatorAddress: "", + jailed: false, + status: 0, + tokens: "", + delegatorShares: "", + unbondingHeight: 0, + minSelfDelegation: "", +}; + +export const Validator = { + encode(message: Validator, writer: Writer = Writer.create()): Writer { + if (message.operatorAddress !== "") { + writer.uint32(10).string(message.operatorAddress); + } + if (message.consensusPubkey !== undefined) { + Any.encode(message.consensusPubkey, writer.uint32(18).fork()).ldelim(); + } + if (message.jailed === true) { + writer.uint32(24).bool(message.jailed); + } + if (message.status !== 0) { + writer.uint32(32).int32(message.status); + } + if (message.tokens !== "") { + writer.uint32(42).string(message.tokens); + } + if (message.delegatorShares !== "") { + writer.uint32(50).string(message.delegatorShares); + } + if (message.description !== undefined) { + Description.encode( + message.description, + writer.uint32(58).fork() + ).ldelim(); + } + if (message.unbondingHeight !== 0) { + writer.uint32(64).int64(message.unbondingHeight); + } + if (message.unbondingTime !== undefined) { + Timestamp.encode( + toTimestamp(message.unbondingTime), + writer.uint32(74).fork() + ).ldelim(); + } + if (message.commission !== undefined) { + Commission.encode(message.commission, writer.uint32(82).fork()).ldelim(); + } + if (message.minSelfDelegation !== "") { + writer.uint32(90).string(message.minSelfDelegation); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Validator { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseValidator } as Validator; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.operatorAddress = reader.string(); + break; + case 2: + message.consensusPubkey = Any.decode(reader, reader.uint32()); + break; + case 3: + message.jailed = reader.bool(); + break; + case 4: + message.status = reader.int32() as any; + break; + case 5: + message.tokens = reader.string(); + break; + case 6: + message.delegatorShares = reader.string(); + break; + case 7: + message.description = Description.decode(reader, reader.uint32()); + break; + case 8: + message.unbondingHeight = longToNumber(reader.int64() as Long); + break; + case 9: + message.unbondingTime = fromTimestamp( + Timestamp.decode(reader, reader.uint32()) + ); + break; + case 10: + message.commission = Commission.decode(reader, reader.uint32()); + break; + case 11: + message.minSelfDelegation = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Validator { + const message = { ...baseValidator } as Validator; + if ( + object.operatorAddress !== undefined && + object.operatorAddress !== null + ) { + message.operatorAddress = String(object.operatorAddress); + } else { + message.operatorAddress = ""; + } + if ( + object.consensusPubkey !== undefined && + object.consensusPubkey !== null + ) { + message.consensusPubkey = Any.fromJSON(object.consensusPubkey); + } else { + message.consensusPubkey = undefined; + } + if (object.jailed !== undefined && object.jailed !== null) { + message.jailed = Boolean(object.jailed); + } else { + message.jailed = false; + } + if (object.status !== undefined && object.status !== null) { + message.status = bondStatusFromJSON(object.status); + } else { + message.status = 0; + } + if (object.tokens !== undefined && object.tokens !== null) { + message.tokens = String(object.tokens); + } else { + message.tokens = ""; + } + if ( + object.delegatorShares !== undefined && + object.delegatorShares !== null + ) { + message.delegatorShares = String(object.delegatorShares); + } else { + message.delegatorShares = ""; + } + if (object.description !== undefined && object.description !== null) { + message.description = Description.fromJSON(object.description); + } else { + message.description = undefined; + } + if ( + object.unbondingHeight !== undefined && + object.unbondingHeight !== null + ) { + message.unbondingHeight = Number(object.unbondingHeight); + } else { + message.unbondingHeight = 0; + } + if (object.unbondingTime !== undefined && object.unbondingTime !== null) { + message.unbondingTime = fromJsonTimestamp(object.unbondingTime); + } else { + message.unbondingTime = undefined; + } + if (object.commission !== undefined && object.commission !== null) { + message.commission = Commission.fromJSON(object.commission); + } else { + message.commission = undefined; + } + if ( + object.minSelfDelegation !== undefined && + object.minSelfDelegation !== null + ) { + message.minSelfDelegation = String(object.minSelfDelegation); + } else { + message.minSelfDelegation = ""; + } + return message; + }, + + toJSON(message: Validator): unknown { + const obj: any = {}; + message.operatorAddress !== undefined && + (obj.operatorAddress = message.operatorAddress); + message.consensusPubkey !== undefined && + (obj.consensusPubkey = message.consensusPubkey + ? Any.toJSON(message.consensusPubkey) + : undefined); + message.jailed !== undefined && (obj.jailed = message.jailed); + message.status !== undefined && + (obj.status = bondStatusToJSON(message.status)); + message.tokens !== undefined && (obj.tokens = message.tokens); + message.delegatorShares !== undefined && + (obj.delegatorShares = message.delegatorShares); + message.description !== undefined && + (obj.description = message.description + ? Description.toJSON(message.description) + : undefined); + message.unbondingHeight !== undefined && + (obj.unbondingHeight = message.unbondingHeight); + message.unbondingTime !== undefined && + (obj.unbondingTime = + message.unbondingTime !== undefined + ? message.unbondingTime.toISOString() + : null); + message.commission !== undefined && + (obj.commission = message.commission + ? Commission.toJSON(message.commission) + : undefined); + message.minSelfDelegation !== undefined && + (obj.minSelfDelegation = message.minSelfDelegation); + return obj; + }, + + fromPartial(object: DeepPartial): Validator { + const message = { ...baseValidator } as Validator; + if ( + object.operatorAddress !== undefined && + object.operatorAddress !== null + ) { + message.operatorAddress = object.operatorAddress; + } else { + message.operatorAddress = ""; + } + if ( + object.consensusPubkey !== undefined && + object.consensusPubkey !== null + ) { + message.consensusPubkey = Any.fromPartial(object.consensusPubkey); + } else { + message.consensusPubkey = undefined; + } + if (object.jailed !== undefined && object.jailed !== null) { + message.jailed = object.jailed; + } else { + message.jailed = false; + } + if (object.status !== undefined && object.status !== null) { + message.status = object.status; + } else { + message.status = 0; + } + if (object.tokens !== undefined && object.tokens !== null) { + message.tokens = object.tokens; + } else { + message.tokens = ""; + } + if ( + object.delegatorShares !== undefined && + object.delegatorShares !== null + ) { + message.delegatorShares = object.delegatorShares; + } else { + message.delegatorShares = ""; + } + if (object.description !== undefined && object.description !== null) { + message.description = Description.fromPartial(object.description); + } else { + message.description = undefined; + } + if ( + object.unbondingHeight !== undefined && + object.unbondingHeight !== null + ) { + message.unbondingHeight = object.unbondingHeight; + } else { + message.unbondingHeight = 0; + } + if (object.unbondingTime !== undefined && object.unbondingTime !== null) { + message.unbondingTime = object.unbondingTime; + } else { + message.unbondingTime = undefined; + } + if (object.commission !== undefined && object.commission !== null) { + message.commission = Commission.fromPartial(object.commission); + } else { + message.commission = undefined; + } + if ( + object.minSelfDelegation !== undefined && + object.minSelfDelegation !== null + ) { + message.minSelfDelegation = object.minSelfDelegation; + } else { + message.minSelfDelegation = ""; + } + return message; + }, +}; + +const baseValAddresses: object = { addresses: "" }; + +export const ValAddresses = { + encode(message: ValAddresses, writer: Writer = Writer.create()): Writer { + for (const v of message.addresses) { + writer.uint32(10).string(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ValAddresses { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseValAddresses } as ValAddresses; + message.addresses = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.addresses.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ValAddresses { + const message = { ...baseValAddresses } as ValAddresses; + message.addresses = []; + if (object.addresses !== undefined && object.addresses !== null) { + for (const e of object.addresses) { + message.addresses.push(String(e)); + } + } + return message; + }, + + toJSON(message: ValAddresses): unknown { + const obj: any = {}; + if (message.addresses) { + obj.addresses = message.addresses.map((e) => e); + } else { + obj.addresses = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): ValAddresses { + const message = { ...baseValAddresses } as ValAddresses; + message.addresses = []; + if (object.addresses !== undefined && object.addresses !== null) { + for (const e of object.addresses) { + message.addresses.push(e); + } + } + return message; + }, +}; + +const baseDVPair: object = { delegatorAddress: "", validatorAddress: "" }; + +export const DVPair = { + encode(message: DVPair, writer: Writer = Writer.create()): Writer { + if (message.delegatorAddress !== "") { + writer.uint32(10).string(message.delegatorAddress); + } + if (message.validatorAddress !== "") { + writer.uint32(18).string(message.validatorAddress); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): DVPair { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseDVPair } as DVPair; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.delegatorAddress = reader.string(); + break; + case 2: + message.validatorAddress = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DVPair { + const message = { ...baseDVPair } as DVPair; + if ( + object.delegatorAddress !== undefined && + object.delegatorAddress !== null + ) { + message.delegatorAddress = String(object.delegatorAddress); + } else { + message.delegatorAddress = ""; + } + if ( + object.validatorAddress !== undefined && + object.validatorAddress !== null + ) { + message.validatorAddress = String(object.validatorAddress); + } else { + message.validatorAddress = ""; + } + return message; + }, + + toJSON(message: DVPair): unknown { + const obj: any = {}; + message.delegatorAddress !== undefined && + (obj.delegatorAddress = message.delegatorAddress); + message.validatorAddress !== undefined && + (obj.validatorAddress = message.validatorAddress); + return obj; + }, + + fromPartial(object: DeepPartial): DVPair { + const message = { ...baseDVPair } as DVPair; + if ( + object.delegatorAddress !== undefined && + object.delegatorAddress !== null + ) { + message.delegatorAddress = object.delegatorAddress; + } else { + message.delegatorAddress = ""; + } + if ( + object.validatorAddress !== undefined && + object.validatorAddress !== null + ) { + message.validatorAddress = object.validatorAddress; + } else { + message.validatorAddress = ""; + } + return message; + }, +}; + +const baseDVPairs: object = {}; + +export const DVPairs = { + encode(message: DVPairs, writer: Writer = Writer.create()): Writer { + for (const v of message.pairs) { + DVPair.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): DVPairs { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseDVPairs } as DVPairs; + message.pairs = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.pairs.push(DVPair.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DVPairs { + const message = { ...baseDVPairs } as DVPairs; + message.pairs = []; + if (object.pairs !== undefined && object.pairs !== null) { + for (const e of object.pairs) { + message.pairs.push(DVPair.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: DVPairs): unknown { + const obj: any = {}; + if (message.pairs) { + obj.pairs = message.pairs.map((e) => (e ? DVPair.toJSON(e) : undefined)); + } else { + obj.pairs = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): DVPairs { + const message = { ...baseDVPairs } as DVPairs; + message.pairs = []; + if (object.pairs !== undefined && object.pairs !== null) { + for (const e of object.pairs) { + message.pairs.push(DVPair.fromPartial(e)); + } + } + return message; + }, +}; + +const baseDVVTriplet: object = { + delegatorAddress: "", + validatorSrcAddress: "", + validatorDstAddress: "", +}; + +export const DVVTriplet = { + encode(message: DVVTriplet, writer: Writer = Writer.create()): Writer { + if (message.delegatorAddress !== "") { + writer.uint32(10).string(message.delegatorAddress); + } + if (message.validatorSrcAddress !== "") { + writer.uint32(18).string(message.validatorSrcAddress); + } + if (message.validatorDstAddress !== "") { + writer.uint32(26).string(message.validatorDstAddress); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): DVVTriplet { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseDVVTriplet } as DVVTriplet; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.delegatorAddress = reader.string(); + break; + case 2: + message.validatorSrcAddress = reader.string(); + break; + case 3: + message.validatorDstAddress = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DVVTriplet { + const message = { ...baseDVVTriplet } as DVVTriplet; + if ( + object.delegatorAddress !== undefined && + object.delegatorAddress !== null + ) { + message.delegatorAddress = String(object.delegatorAddress); + } else { + message.delegatorAddress = ""; + } + if ( + object.validatorSrcAddress !== undefined && + object.validatorSrcAddress !== null + ) { + message.validatorSrcAddress = String(object.validatorSrcAddress); + } else { + message.validatorSrcAddress = ""; + } + if ( + object.validatorDstAddress !== undefined && + object.validatorDstAddress !== null + ) { + message.validatorDstAddress = String(object.validatorDstAddress); + } else { + message.validatorDstAddress = ""; + } + return message; + }, + + toJSON(message: DVVTriplet): unknown { + const obj: any = {}; + message.delegatorAddress !== undefined && + (obj.delegatorAddress = message.delegatorAddress); + message.validatorSrcAddress !== undefined && + (obj.validatorSrcAddress = message.validatorSrcAddress); + message.validatorDstAddress !== undefined && + (obj.validatorDstAddress = message.validatorDstAddress); + return obj; + }, + + fromPartial(object: DeepPartial): DVVTriplet { + const message = { ...baseDVVTriplet } as DVVTriplet; + if ( + object.delegatorAddress !== undefined && + object.delegatorAddress !== null + ) { + message.delegatorAddress = object.delegatorAddress; + } else { + message.delegatorAddress = ""; + } + if ( + object.validatorSrcAddress !== undefined && + object.validatorSrcAddress !== null + ) { + message.validatorSrcAddress = object.validatorSrcAddress; + } else { + message.validatorSrcAddress = ""; + } + if ( + object.validatorDstAddress !== undefined && + object.validatorDstAddress !== null + ) { + message.validatorDstAddress = object.validatorDstAddress; + } else { + message.validatorDstAddress = ""; + } + return message; + }, +}; + +const baseDVVTriplets: object = {}; + +export const DVVTriplets = { + encode(message: DVVTriplets, writer: Writer = Writer.create()): Writer { + for (const v of message.triplets) { + DVVTriplet.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): DVVTriplets { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseDVVTriplets } as DVVTriplets; + message.triplets = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.triplets.push(DVVTriplet.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DVVTriplets { + const message = { ...baseDVVTriplets } as DVVTriplets; + message.triplets = []; + if (object.triplets !== undefined && object.triplets !== null) { + for (const e of object.triplets) { + message.triplets.push(DVVTriplet.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: DVVTriplets): unknown { + const obj: any = {}; + if (message.triplets) { + obj.triplets = message.triplets.map((e) => + e ? DVVTriplet.toJSON(e) : undefined + ); + } else { + obj.triplets = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): DVVTriplets { + const message = { ...baseDVVTriplets } as DVVTriplets; + message.triplets = []; + if (object.triplets !== undefined && object.triplets !== null) { + for (const e of object.triplets) { + message.triplets.push(DVVTriplet.fromPartial(e)); + } + } + return message; + }, +}; + +const baseDelegation: object = { + delegatorAddress: "", + validatorAddress: "", + shares: "", +}; + +export const Delegation = { + encode(message: Delegation, writer: Writer = Writer.create()): Writer { + if (message.delegatorAddress !== "") { + writer.uint32(10).string(message.delegatorAddress); + } + if (message.validatorAddress !== "") { + writer.uint32(18).string(message.validatorAddress); + } + if (message.shares !== "") { + writer.uint32(26).string(message.shares); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Delegation { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseDelegation } as Delegation; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.delegatorAddress = reader.string(); + break; + case 2: + message.validatorAddress = reader.string(); + break; + case 3: + message.shares = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Delegation { + const message = { ...baseDelegation } as Delegation; + if ( + object.delegatorAddress !== undefined && + object.delegatorAddress !== null + ) { + message.delegatorAddress = String(object.delegatorAddress); + } else { + message.delegatorAddress = ""; + } + if ( + object.validatorAddress !== undefined && + object.validatorAddress !== null + ) { + message.validatorAddress = String(object.validatorAddress); + } else { + message.validatorAddress = ""; + } + if (object.shares !== undefined && object.shares !== null) { + message.shares = String(object.shares); + } else { + message.shares = ""; + } + return message; + }, + + toJSON(message: Delegation): unknown { + const obj: any = {}; + message.delegatorAddress !== undefined && + (obj.delegatorAddress = message.delegatorAddress); + message.validatorAddress !== undefined && + (obj.validatorAddress = message.validatorAddress); + message.shares !== undefined && (obj.shares = message.shares); + return obj; + }, + + fromPartial(object: DeepPartial): Delegation { + const message = { ...baseDelegation } as Delegation; + if ( + object.delegatorAddress !== undefined && + object.delegatorAddress !== null + ) { + message.delegatorAddress = object.delegatorAddress; + } else { + message.delegatorAddress = ""; + } + if ( + object.validatorAddress !== undefined && + object.validatorAddress !== null + ) { + message.validatorAddress = object.validatorAddress; + } else { + message.validatorAddress = ""; + } + if (object.shares !== undefined && object.shares !== null) { + message.shares = object.shares; + } else { + message.shares = ""; + } + return message; + }, +}; + +const baseUnbondingDelegation: object = { + delegatorAddress: "", + validatorAddress: "", +}; + +export const UnbondingDelegation = { + encode( + message: UnbondingDelegation, + writer: Writer = Writer.create() + ): Writer { + if (message.delegatorAddress !== "") { + writer.uint32(10).string(message.delegatorAddress); + } + if (message.validatorAddress !== "") { + writer.uint32(18).string(message.validatorAddress); + } + for (const v of message.entries) { + UnbondingDelegationEntry.encode(v!, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): UnbondingDelegation { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseUnbondingDelegation } as UnbondingDelegation; + message.entries = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.delegatorAddress = reader.string(); + break; + case 2: + message.validatorAddress = reader.string(); + break; + case 3: + message.entries.push( + UnbondingDelegationEntry.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): UnbondingDelegation { + const message = { ...baseUnbondingDelegation } as UnbondingDelegation; + message.entries = []; + if ( + object.delegatorAddress !== undefined && + object.delegatorAddress !== null + ) { + message.delegatorAddress = String(object.delegatorAddress); + } else { + message.delegatorAddress = ""; + } + if ( + object.validatorAddress !== undefined && + object.validatorAddress !== null + ) { + message.validatorAddress = String(object.validatorAddress); + } else { + message.validatorAddress = ""; + } + if (object.entries !== undefined && object.entries !== null) { + for (const e of object.entries) { + message.entries.push(UnbondingDelegationEntry.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: UnbondingDelegation): unknown { + const obj: any = {}; + message.delegatorAddress !== undefined && + (obj.delegatorAddress = message.delegatorAddress); + message.validatorAddress !== undefined && + (obj.validatorAddress = message.validatorAddress); + if (message.entries) { + obj.entries = message.entries.map((e) => + e ? UnbondingDelegationEntry.toJSON(e) : undefined + ); + } else { + obj.entries = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): UnbondingDelegation { + const message = { ...baseUnbondingDelegation } as UnbondingDelegation; + message.entries = []; + if ( + object.delegatorAddress !== undefined && + object.delegatorAddress !== null + ) { + message.delegatorAddress = object.delegatorAddress; + } else { + message.delegatorAddress = ""; + } + if ( + object.validatorAddress !== undefined && + object.validatorAddress !== null + ) { + message.validatorAddress = object.validatorAddress; + } else { + message.validatorAddress = ""; + } + if (object.entries !== undefined && object.entries !== null) { + for (const e of object.entries) { + message.entries.push(UnbondingDelegationEntry.fromPartial(e)); + } + } + return message; + }, +}; + +const baseUnbondingDelegationEntry: object = { + creationHeight: 0, + initialBalance: "", + balance: "", +}; + +export const UnbondingDelegationEntry = { + encode( + message: UnbondingDelegationEntry, + writer: Writer = Writer.create() + ): Writer { + if (message.creationHeight !== 0) { + writer.uint32(8).int64(message.creationHeight); + } + if (message.completionTime !== undefined) { + Timestamp.encode( + toTimestamp(message.completionTime), + writer.uint32(18).fork() + ).ldelim(); + } + if (message.initialBalance !== "") { + writer.uint32(26).string(message.initialBalance); + } + if (message.balance !== "") { + writer.uint32(34).string(message.balance); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): UnbondingDelegationEntry { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseUnbondingDelegationEntry, + } as UnbondingDelegationEntry; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.creationHeight = longToNumber(reader.int64() as Long); + break; + case 2: + message.completionTime = fromTimestamp( + Timestamp.decode(reader, reader.uint32()) + ); + break; + case 3: + message.initialBalance = reader.string(); + break; + case 4: + message.balance = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): UnbondingDelegationEntry { + const message = { + ...baseUnbondingDelegationEntry, + } as UnbondingDelegationEntry; + if (object.creationHeight !== undefined && object.creationHeight !== null) { + message.creationHeight = Number(object.creationHeight); + } else { + message.creationHeight = 0; + } + if (object.completionTime !== undefined && object.completionTime !== null) { + message.completionTime = fromJsonTimestamp(object.completionTime); + } else { + message.completionTime = undefined; + } + if (object.initialBalance !== undefined && object.initialBalance !== null) { + message.initialBalance = String(object.initialBalance); + } else { + message.initialBalance = ""; + } + if (object.balance !== undefined && object.balance !== null) { + message.balance = String(object.balance); + } else { + message.balance = ""; + } + return message; + }, + + toJSON(message: UnbondingDelegationEntry): unknown { + const obj: any = {}; + message.creationHeight !== undefined && + (obj.creationHeight = message.creationHeight); + message.completionTime !== undefined && + (obj.completionTime = + message.completionTime !== undefined + ? message.completionTime.toISOString() + : null); + message.initialBalance !== undefined && + (obj.initialBalance = message.initialBalance); + message.balance !== undefined && (obj.balance = message.balance); + return obj; + }, + + fromPartial( + object: DeepPartial + ): UnbondingDelegationEntry { + const message = { + ...baseUnbondingDelegationEntry, + } as UnbondingDelegationEntry; + if (object.creationHeight !== undefined && object.creationHeight !== null) { + message.creationHeight = object.creationHeight; + } else { + message.creationHeight = 0; + } + if (object.completionTime !== undefined && object.completionTime !== null) { + message.completionTime = object.completionTime; + } else { + message.completionTime = undefined; + } + if (object.initialBalance !== undefined && object.initialBalance !== null) { + message.initialBalance = object.initialBalance; + } else { + message.initialBalance = ""; + } + if (object.balance !== undefined && object.balance !== null) { + message.balance = object.balance; + } else { + message.balance = ""; + } + return message; + }, +}; + +const baseRedelegationEntry: object = { + creationHeight: 0, + initialBalance: "", + sharesDst: "", +}; + +export const RedelegationEntry = { + encode(message: RedelegationEntry, writer: Writer = Writer.create()): Writer { + if (message.creationHeight !== 0) { + writer.uint32(8).int64(message.creationHeight); + } + if (message.completionTime !== undefined) { + Timestamp.encode( + toTimestamp(message.completionTime), + writer.uint32(18).fork() + ).ldelim(); + } + if (message.initialBalance !== "") { + writer.uint32(26).string(message.initialBalance); + } + if (message.sharesDst !== "") { + writer.uint32(34).string(message.sharesDst); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): RedelegationEntry { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseRedelegationEntry } as RedelegationEntry; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.creationHeight = longToNumber(reader.int64() as Long); + break; + case 2: + message.completionTime = fromTimestamp( + Timestamp.decode(reader, reader.uint32()) + ); + break; + case 3: + message.initialBalance = reader.string(); + break; + case 4: + message.sharesDst = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): RedelegationEntry { + const message = { ...baseRedelegationEntry } as RedelegationEntry; + if (object.creationHeight !== undefined && object.creationHeight !== null) { + message.creationHeight = Number(object.creationHeight); + } else { + message.creationHeight = 0; + } + if (object.completionTime !== undefined && object.completionTime !== null) { + message.completionTime = fromJsonTimestamp(object.completionTime); + } else { + message.completionTime = undefined; + } + if (object.initialBalance !== undefined && object.initialBalance !== null) { + message.initialBalance = String(object.initialBalance); + } else { + message.initialBalance = ""; + } + if (object.sharesDst !== undefined && object.sharesDst !== null) { + message.sharesDst = String(object.sharesDst); + } else { + message.sharesDst = ""; + } + return message; + }, + + toJSON(message: RedelegationEntry): unknown { + const obj: any = {}; + message.creationHeight !== undefined && + (obj.creationHeight = message.creationHeight); + message.completionTime !== undefined && + (obj.completionTime = + message.completionTime !== undefined + ? message.completionTime.toISOString() + : null); + message.initialBalance !== undefined && + (obj.initialBalance = message.initialBalance); + message.sharesDst !== undefined && (obj.sharesDst = message.sharesDst); + return obj; + }, + + fromPartial(object: DeepPartial): RedelegationEntry { + const message = { ...baseRedelegationEntry } as RedelegationEntry; + if (object.creationHeight !== undefined && object.creationHeight !== null) { + message.creationHeight = object.creationHeight; + } else { + message.creationHeight = 0; + } + if (object.completionTime !== undefined && object.completionTime !== null) { + message.completionTime = object.completionTime; + } else { + message.completionTime = undefined; + } + if (object.initialBalance !== undefined && object.initialBalance !== null) { + message.initialBalance = object.initialBalance; + } else { + message.initialBalance = ""; + } + if (object.sharesDst !== undefined && object.sharesDst !== null) { + message.sharesDst = object.sharesDst; + } else { + message.sharesDst = ""; + } + return message; + }, +}; + +const baseRedelegation: object = { + delegatorAddress: "", + validatorSrcAddress: "", + validatorDstAddress: "", +}; + +export const Redelegation = { + encode(message: Redelegation, writer: Writer = Writer.create()): Writer { + if (message.delegatorAddress !== "") { + writer.uint32(10).string(message.delegatorAddress); + } + if (message.validatorSrcAddress !== "") { + writer.uint32(18).string(message.validatorSrcAddress); + } + if (message.validatorDstAddress !== "") { + writer.uint32(26).string(message.validatorDstAddress); + } + for (const v of message.entries) { + RedelegationEntry.encode(v!, writer.uint32(34).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Redelegation { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseRedelegation } as Redelegation; + message.entries = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.delegatorAddress = reader.string(); + break; + case 2: + message.validatorSrcAddress = reader.string(); + break; + case 3: + message.validatorDstAddress = reader.string(); + break; + case 4: + message.entries.push( + RedelegationEntry.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Redelegation { + const message = { ...baseRedelegation } as Redelegation; + message.entries = []; + if ( + object.delegatorAddress !== undefined && + object.delegatorAddress !== null + ) { + message.delegatorAddress = String(object.delegatorAddress); + } else { + message.delegatorAddress = ""; + } + if ( + object.validatorSrcAddress !== undefined && + object.validatorSrcAddress !== null + ) { + message.validatorSrcAddress = String(object.validatorSrcAddress); + } else { + message.validatorSrcAddress = ""; + } + if ( + object.validatorDstAddress !== undefined && + object.validatorDstAddress !== null + ) { + message.validatorDstAddress = String(object.validatorDstAddress); + } else { + message.validatorDstAddress = ""; + } + if (object.entries !== undefined && object.entries !== null) { + for (const e of object.entries) { + message.entries.push(RedelegationEntry.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: Redelegation): unknown { + const obj: any = {}; + message.delegatorAddress !== undefined && + (obj.delegatorAddress = message.delegatorAddress); + message.validatorSrcAddress !== undefined && + (obj.validatorSrcAddress = message.validatorSrcAddress); + message.validatorDstAddress !== undefined && + (obj.validatorDstAddress = message.validatorDstAddress); + if (message.entries) { + obj.entries = message.entries.map((e) => + e ? RedelegationEntry.toJSON(e) : undefined + ); + } else { + obj.entries = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): Redelegation { + const message = { ...baseRedelegation } as Redelegation; + message.entries = []; + if ( + object.delegatorAddress !== undefined && + object.delegatorAddress !== null + ) { + message.delegatorAddress = object.delegatorAddress; + } else { + message.delegatorAddress = ""; + } + if ( + object.validatorSrcAddress !== undefined && + object.validatorSrcAddress !== null + ) { + message.validatorSrcAddress = object.validatorSrcAddress; + } else { + message.validatorSrcAddress = ""; + } + if ( + object.validatorDstAddress !== undefined && + object.validatorDstAddress !== null + ) { + message.validatorDstAddress = object.validatorDstAddress; + } else { + message.validatorDstAddress = ""; + } + if (object.entries !== undefined && object.entries !== null) { + for (const e of object.entries) { + message.entries.push(RedelegationEntry.fromPartial(e)); + } + } + return message; + }, +}; + +const baseParams: object = { + maxValidators: 0, + maxEntries: 0, + historicalEntries: 0, + bondDenom: "", +}; + +export const Params = { + encode(message: Params, writer: Writer = Writer.create()): Writer { + if (message.unbondingTime !== undefined) { + Duration.encode(message.unbondingTime, writer.uint32(10).fork()).ldelim(); + } + if (message.maxValidators !== 0) { + writer.uint32(16).uint32(message.maxValidators); + } + if (message.maxEntries !== 0) { + writer.uint32(24).uint32(message.maxEntries); + } + if (message.historicalEntries !== 0) { + writer.uint32(32).uint32(message.historicalEntries); + } + if (message.bondDenom !== "") { + writer.uint32(42).string(message.bondDenom); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Params { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseParams } as Params; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.unbondingTime = Duration.decode(reader, reader.uint32()); + break; + case 2: + message.maxValidators = reader.uint32(); + break; + case 3: + message.maxEntries = reader.uint32(); + break; + case 4: + message.historicalEntries = reader.uint32(); + break; + case 5: + message.bondDenom = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Params { + const message = { ...baseParams } as Params; + if (object.unbondingTime !== undefined && object.unbondingTime !== null) { + message.unbondingTime = Duration.fromJSON(object.unbondingTime); + } else { + message.unbondingTime = undefined; + } + if (object.maxValidators !== undefined && object.maxValidators !== null) { + message.maxValidators = Number(object.maxValidators); + } else { + message.maxValidators = 0; + } + if (object.maxEntries !== undefined && object.maxEntries !== null) { + message.maxEntries = Number(object.maxEntries); + } else { + message.maxEntries = 0; + } + if ( + object.historicalEntries !== undefined && + object.historicalEntries !== null + ) { + message.historicalEntries = Number(object.historicalEntries); + } else { + message.historicalEntries = 0; + } + if (object.bondDenom !== undefined && object.bondDenom !== null) { + message.bondDenom = String(object.bondDenom); + } else { + message.bondDenom = ""; + } + return message; + }, + + toJSON(message: Params): unknown { + const obj: any = {}; + message.unbondingTime !== undefined && + (obj.unbondingTime = message.unbondingTime + ? Duration.toJSON(message.unbondingTime) + : undefined); + message.maxValidators !== undefined && + (obj.maxValidators = message.maxValidators); + message.maxEntries !== undefined && (obj.maxEntries = message.maxEntries); + message.historicalEntries !== undefined && + (obj.historicalEntries = message.historicalEntries); + message.bondDenom !== undefined && (obj.bondDenom = message.bondDenom); + return obj; + }, + + fromPartial(object: DeepPartial): Params { + const message = { ...baseParams } as Params; + if (object.unbondingTime !== undefined && object.unbondingTime !== null) { + message.unbondingTime = Duration.fromPartial(object.unbondingTime); + } else { + message.unbondingTime = undefined; + } + if (object.maxValidators !== undefined && object.maxValidators !== null) { + message.maxValidators = object.maxValidators; + } else { + message.maxValidators = 0; + } + if (object.maxEntries !== undefined && object.maxEntries !== null) { + message.maxEntries = object.maxEntries; + } else { + message.maxEntries = 0; + } + if ( + object.historicalEntries !== undefined && + object.historicalEntries !== null + ) { + message.historicalEntries = object.historicalEntries; + } else { + message.historicalEntries = 0; + } + if (object.bondDenom !== undefined && object.bondDenom !== null) { + message.bondDenom = object.bondDenom; + } else { + message.bondDenom = ""; + } + return message; + }, +}; + +const baseDelegationResponse: object = {}; + +export const DelegationResponse = { + encode( + message: DelegationResponse, + writer: Writer = Writer.create() + ): Writer { + if (message.delegation !== undefined) { + Delegation.encode(message.delegation, writer.uint32(10).fork()).ldelim(); + } + if (message.balance !== undefined) { + Coin.encode(message.balance, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): DelegationResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseDelegationResponse } as DelegationResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.delegation = Delegation.decode(reader, reader.uint32()); + break; + case 2: + message.balance = Coin.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DelegationResponse { + const message = { ...baseDelegationResponse } as DelegationResponse; + if (object.delegation !== undefined && object.delegation !== null) { + message.delegation = Delegation.fromJSON(object.delegation); + } else { + message.delegation = undefined; + } + if (object.balance !== undefined && object.balance !== null) { + message.balance = Coin.fromJSON(object.balance); + } else { + message.balance = undefined; + } + return message; + }, + + toJSON(message: DelegationResponse): unknown { + const obj: any = {}; + message.delegation !== undefined && + (obj.delegation = message.delegation + ? Delegation.toJSON(message.delegation) + : undefined); + message.balance !== undefined && + (obj.balance = message.balance + ? Coin.toJSON(message.balance) + : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): DelegationResponse { + const message = { ...baseDelegationResponse } as DelegationResponse; + if (object.delegation !== undefined && object.delegation !== null) { + message.delegation = Delegation.fromPartial(object.delegation); + } else { + message.delegation = undefined; + } + if (object.balance !== undefined && object.balance !== null) { + message.balance = Coin.fromPartial(object.balance); + } else { + message.balance = undefined; + } + return message; + }, +}; + +const baseRedelegationEntryResponse: object = { balance: "" }; + +export const RedelegationEntryResponse = { + encode( + message: RedelegationEntryResponse, + writer: Writer = Writer.create() + ): Writer { + if (message.redelegationEntry !== undefined) { + RedelegationEntry.encode( + message.redelegationEntry, + writer.uint32(10).fork() + ).ldelim(); + } + if (message.balance !== "") { + writer.uint32(34).string(message.balance); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): RedelegationEntryResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseRedelegationEntryResponse, + } as RedelegationEntryResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.redelegationEntry = RedelegationEntry.decode( + reader, + reader.uint32() + ); + break; + case 4: + message.balance = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): RedelegationEntryResponse { + const message = { + ...baseRedelegationEntryResponse, + } as RedelegationEntryResponse; + if ( + object.redelegationEntry !== undefined && + object.redelegationEntry !== null + ) { + message.redelegationEntry = RedelegationEntry.fromJSON( + object.redelegationEntry + ); + } else { + message.redelegationEntry = undefined; + } + if (object.balance !== undefined && object.balance !== null) { + message.balance = String(object.balance); + } else { + message.balance = ""; + } + return message; + }, + + toJSON(message: RedelegationEntryResponse): unknown { + const obj: any = {}; + message.redelegationEntry !== undefined && + (obj.redelegationEntry = message.redelegationEntry + ? RedelegationEntry.toJSON(message.redelegationEntry) + : undefined); + message.balance !== undefined && (obj.balance = message.balance); + return obj; + }, + + fromPartial( + object: DeepPartial + ): RedelegationEntryResponse { + const message = { + ...baseRedelegationEntryResponse, + } as RedelegationEntryResponse; + if ( + object.redelegationEntry !== undefined && + object.redelegationEntry !== null + ) { + message.redelegationEntry = RedelegationEntry.fromPartial( + object.redelegationEntry + ); + } else { + message.redelegationEntry = undefined; + } + if (object.balance !== undefined && object.balance !== null) { + message.balance = object.balance; + } else { + message.balance = ""; + } + return message; + }, +}; + +const baseRedelegationResponse: object = {}; + +export const RedelegationResponse = { + encode( + message: RedelegationResponse, + writer: Writer = Writer.create() + ): Writer { + if (message.redelegation !== undefined) { + Redelegation.encode( + message.redelegation, + writer.uint32(10).fork() + ).ldelim(); + } + for (const v of message.entries) { + RedelegationEntryResponse.encode(v!, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): RedelegationResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseRedelegationResponse } as RedelegationResponse; + message.entries = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.redelegation = Redelegation.decode(reader, reader.uint32()); + break; + case 2: + message.entries.push( + RedelegationEntryResponse.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): RedelegationResponse { + const message = { ...baseRedelegationResponse } as RedelegationResponse; + message.entries = []; + if (object.redelegation !== undefined && object.redelegation !== null) { + message.redelegation = Redelegation.fromJSON(object.redelegation); + } else { + message.redelegation = undefined; + } + if (object.entries !== undefined && object.entries !== null) { + for (const e of object.entries) { + message.entries.push(RedelegationEntryResponse.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: RedelegationResponse): unknown { + const obj: any = {}; + message.redelegation !== undefined && + (obj.redelegation = message.redelegation + ? Redelegation.toJSON(message.redelegation) + : undefined); + if (message.entries) { + obj.entries = message.entries.map((e) => + e ? RedelegationEntryResponse.toJSON(e) : undefined + ); + } else { + obj.entries = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): RedelegationResponse { + const message = { ...baseRedelegationResponse } as RedelegationResponse; + message.entries = []; + if (object.redelegation !== undefined && object.redelegation !== null) { + message.redelegation = Redelegation.fromPartial(object.redelegation); + } else { + message.redelegation = undefined; + } + if (object.entries !== undefined && object.entries !== null) { + for (const e of object.entries) { + message.entries.push(RedelegationEntryResponse.fromPartial(e)); + } + } + return message; + }, +}; + +const basePool: object = { notBondedTokens: "", bondedTokens: "" }; + +export const Pool = { + encode(message: Pool, writer: Writer = Writer.create()): Writer { + if (message.notBondedTokens !== "") { + writer.uint32(10).string(message.notBondedTokens); + } + if (message.bondedTokens !== "") { + writer.uint32(18).string(message.bondedTokens); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Pool { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...basePool } as Pool; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.notBondedTokens = reader.string(); + break; + case 2: + message.bondedTokens = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Pool { + const message = { ...basePool } as Pool; + if ( + object.notBondedTokens !== undefined && + object.notBondedTokens !== null + ) { + message.notBondedTokens = String(object.notBondedTokens); + } else { + message.notBondedTokens = ""; + } + if (object.bondedTokens !== undefined && object.bondedTokens !== null) { + message.bondedTokens = String(object.bondedTokens); + } else { + message.bondedTokens = ""; + } + return message; + }, + + toJSON(message: Pool): unknown { + const obj: any = {}; + message.notBondedTokens !== undefined && + (obj.notBondedTokens = message.notBondedTokens); + message.bondedTokens !== undefined && + (obj.bondedTokens = message.bondedTokens); + return obj; + }, + + fromPartial(object: DeepPartial): Pool { + const message = { ...basePool } as Pool; + if ( + object.notBondedTokens !== undefined && + object.notBondedTokens !== null + ) { + message.notBondedTokens = object.notBondedTokens; + } else { + message.notBondedTokens = ""; + } + if (object.bondedTokens !== undefined && object.bondedTokens !== null) { + message.bondedTokens = object.bondedTokens; + } else { + message.bondedTokens = ""; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function toTimestamp(date: Date): Timestamp { + const seconds = date.getTime() / 1_000; + const nanos = (date.getTime() % 1_000) * 1_000_000; + return { seconds, nanos }; +} + +function fromTimestamp(t: Timestamp): Date { + let millis = t.seconds * 1_000; + millis += t.nanos / 1_000_000; + return new Date(millis); +} + +function fromJsonTimestamp(o: any): Date { + if (o instanceof Date) { + return o; + } else if (typeof o === "string") { + return new Date(o); + } else { + return fromTimestamp(Timestamp.fromJSON(o)); + } +} + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/cosmos.staking.v1beta1/types/cosmos/staking/v1beta1/tx.ts b/ts-client/cosmos.staking.v1beta1/types/cosmos/staking/v1beta1/tx.ts new file mode 100644 index 00000000..a165d55f --- /dev/null +++ b/ts-client/cosmos.staking.v1beta1/types/cosmos/staking/v1beta1/tx.ts @@ -0,0 +1,1187 @@ +/* eslint-disable */ +import { Reader, Writer } from "protobufjs/minimal"; +import { Timestamp } from "../../../google/protobuf/timestamp"; +import { + Description, + CommissionRates, +} from "../../../cosmos/staking/v1beta1/staking"; +import { Any } from "../../../google/protobuf/any"; +import { Coin } from "../../../cosmos/base/v1beta1/coin"; + +export const protobufPackage = "cosmos.staking.v1beta1"; + +/** MsgCreateValidator defines a SDK message for creating a new validator. */ +export interface MsgCreateValidator { + description: Description | undefined; + commission: CommissionRates | undefined; + minSelfDelegation: string; + delegatorAddress: string; + validatorAddress: string; + pubkey: Any | undefined; + value: Coin | undefined; +} + +/** MsgCreateValidatorResponse defines the Msg/CreateValidator response type. */ +export interface MsgCreateValidatorResponse {} + +/** MsgEditValidator defines a SDK message for editing an existing validator. */ +export interface MsgEditValidator { + description: Description | undefined; + validatorAddress: string; + /** + * We pass a reference to the new commission rate and min self delegation as + * it's not mandatory to update. If not updated, the deserialized rate will be + * zero with no way to distinguish if an update was intended. + * REF: #2373 + */ + commissionRate: string; + minSelfDelegation: string; +} + +/** MsgEditValidatorResponse defines the Msg/EditValidator response type. */ +export interface MsgEditValidatorResponse {} + +/** + * MsgDelegate defines a SDK message for performing a delegation of coins + * from a delegator to a validator. + */ +export interface MsgDelegate { + delegatorAddress: string; + validatorAddress: string; + amount: Coin | undefined; +} + +/** MsgDelegateResponse defines the Msg/Delegate response type. */ +export interface MsgDelegateResponse {} + +/** + * MsgBeginRedelegate defines a SDK message for performing a redelegation + * of coins from a delegator and source validator to a destination validator. + */ +export interface MsgBeginRedelegate { + delegatorAddress: string; + validatorSrcAddress: string; + validatorDstAddress: string; + amount: Coin | undefined; +} + +/** MsgBeginRedelegateResponse defines the Msg/BeginRedelegate response type. */ +export interface MsgBeginRedelegateResponse { + completionTime: Date | undefined; +} + +/** + * MsgUndelegate defines a SDK message for performing an undelegation from a + * delegate and a validator. + */ +export interface MsgUndelegate { + delegatorAddress: string; + validatorAddress: string; + amount: Coin | undefined; +} + +/** MsgUndelegateResponse defines the Msg/Undelegate response type. */ +export interface MsgUndelegateResponse { + completionTime: Date | undefined; +} + +const baseMsgCreateValidator: object = { + minSelfDelegation: "", + delegatorAddress: "", + validatorAddress: "", +}; + +export const MsgCreateValidator = { + encode( + message: MsgCreateValidator, + writer: Writer = Writer.create() + ): Writer { + if (message.description !== undefined) { + Description.encode( + message.description, + writer.uint32(10).fork() + ).ldelim(); + } + if (message.commission !== undefined) { + CommissionRates.encode( + message.commission, + writer.uint32(18).fork() + ).ldelim(); + } + if (message.minSelfDelegation !== "") { + writer.uint32(26).string(message.minSelfDelegation); + } + if (message.delegatorAddress !== "") { + writer.uint32(34).string(message.delegatorAddress); + } + if (message.validatorAddress !== "") { + writer.uint32(42).string(message.validatorAddress); + } + if (message.pubkey !== undefined) { + Any.encode(message.pubkey, writer.uint32(50).fork()).ldelim(); + } + if (message.value !== undefined) { + Coin.encode(message.value, writer.uint32(58).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MsgCreateValidator { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgCreateValidator } as MsgCreateValidator; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.description = Description.decode(reader, reader.uint32()); + break; + case 2: + message.commission = CommissionRates.decode(reader, reader.uint32()); + break; + case 3: + message.minSelfDelegation = reader.string(); + break; + case 4: + message.delegatorAddress = reader.string(); + break; + case 5: + message.validatorAddress = reader.string(); + break; + case 6: + message.pubkey = Any.decode(reader, reader.uint32()); + break; + case 7: + message.value = Coin.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgCreateValidator { + const message = { ...baseMsgCreateValidator } as MsgCreateValidator; + if (object.description !== undefined && object.description !== null) { + message.description = Description.fromJSON(object.description); + } else { + message.description = undefined; + } + if (object.commission !== undefined && object.commission !== null) { + message.commission = CommissionRates.fromJSON(object.commission); + } else { + message.commission = undefined; + } + if ( + object.minSelfDelegation !== undefined && + object.minSelfDelegation !== null + ) { + message.minSelfDelegation = String(object.minSelfDelegation); + } else { + message.minSelfDelegation = ""; + } + if ( + object.delegatorAddress !== undefined && + object.delegatorAddress !== null + ) { + message.delegatorAddress = String(object.delegatorAddress); + } else { + message.delegatorAddress = ""; + } + if ( + object.validatorAddress !== undefined && + object.validatorAddress !== null + ) { + message.validatorAddress = String(object.validatorAddress); + } else { + message.validatorAddress = ""; + } + if (object.pubkey !== undefined && object.pubkey !== null) { + message.pubkey = Any.fromJSON(object.pubkey); + } else { + message.pubkey = undefined; + } + if (object.value !== undefined && object.value !== null) { + message.value = Coin.fromJSON(object.value); + } else { + message.value = undefined; + } + return message; + }, + + toJSON(message: MsgCreateValidator): unknown { + const obj: any = {}; + message.description !== undefined && + (obj.description = message.description + ? Description.toJSON(message.description) + : undefined); + message.commission !== undefined && + (obj.commission = message.commission + ? CommissionRates.toJSON(message.commission) + : undefined); + message.minSelfDelegation !== undefined && + (obj.minSelfDelegation = message.minSelfDelegation); + message.delegatorAddress !== undefined && + (obj.delegatorAddress = message.delegatorAddress); + message.validatorAddress !== undefined && + (obj.validatorAddress = message.validatorAddress); + message.pubkey !== undefined && + (obj.pubkey = message.pubkey ? Any.toJSON(message.pubkey) : undefined); + message.value !== undefined && + (obj.value = message.value ? Coin.toJSON(message.value) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): MsgCreateValidator { + const message = { ...baseMsgCreateValidator } as MsgCreateValidator; + if (object.description !== undefined && object.description !== null) { + message.description = Description.fromPartial(object.description); + } else { + message.description = undefined; + } + if (object.commission !== undefined && object.commission !== null) { + message.commission = CommissionRates.fromPartial(object.commission); + } else { + message.commission = undefined; + } + if ( + object.minSelfDelegation !== undefined && + object.minSelfDelegation !== null + ) { + message.minSelfDelegation = object.minSelfDelegation; + } else { + message.minSelfDelegation = ""; + } + if ( + object.delegatorAddress !== undefined && + object.delegatorAddress !== null + ) { + message.delegatorAddress = object.delegatorAddress; + } else { + message.delegatorAddress = ""; + } + if ( + object.validatorAddress !== undefined && + object.validatorAddress !== null + ) { + message.validatorAddress = object.validatorAddress; + } else { + message.validatorAddress = ""; + } + if (object.pubkey !== undefined && object.pubkey !== null) { + message.pubkey = Any.fromPartial(object.pubkey); + } else { + message.pubkey = undefined; + } + if (object.value !== undefined && object.value !== null) { + message.value = Coin.fromPartial(object.value); + } else { + message.value = undefined; + } + return message; + }, +}; + +const baseMsgCreateValidatorResponse: object = {}; + +export const MsgCreateValidatorResponse = { + encode( + _: MsgCreateValidatorResponse, + writer: Writer = Writer.create() + ): Writer { + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): MsgCreateValidatorResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseMsgCreateValidatorResponse, + } as MsgCreateValidatorResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): MsgCreateValidatorResponse { + const message = { + ...baseMsgCreateValidatorResponse, + } as MsgCreateValidatorResponse; + return message; + }, + + toJSON(_: MsgCreateValidatorResponse): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial( + _: DeepPartial + ): MsgCreateValidatorResponse { + const message = { + ...baseMsgCreateValidatorResponse, + } as MsgCreateValidatorResponse; + return message; + }, +}; + +const baseMsgEditValidator: object = { + validatorAddress: "", + commissionRate: "", + minSelfDelegation: "", +}; + +export const MsgEditValidator = { + encode(message: MsgEditValidator, writer: Writer = Writer.create()): Writer { + if (message.description !== undefined) { + Description.encode( + message.description, + writer.uint32(10).fork() + ).ldelim(); + } + if (message.validatorAddress !== "") { + writer.uint32(18).string(message.validatorAddress); + } + if (message.commissionRate !== "") { + writer.uint32(26).string(message.commissionRate); + } + if (message.minSelfDelegation !== "") { + writer.uint32(34).string(message.minSelfDelegation); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MsgEditValidator { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgEditValidator } as MsgEditValidator; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.description = Description.decode(reader, reader.uint32()); + break; + case 2: + message.validatorAddress = reader.string(); + break; + case 3: + message.commissionRate = reader.string(); + break; + case 4: + message.minSelfDelegation = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgEditValidator { + const message = { ...baseMsgEditValidator } as MsgEditValidator; + if (object.description !== undefined && object.description !== null) { + message.description = Description.fromJSON(object.description); + } else { + message.description = undefined; + } + if ( + object.validatorAddress !== undefined && + object.validatorAddress !== null + ) { + message.validatorAddress = String(object.validatorAddress); + } else { + message.validatorAddress = ""; + } + if (object.commissionRate !== undefined && object.commissionRate !== null) { + message.commissionRate = String(object.commissionRate); + } else { + message.commissionRate = ""; + } + if ( + object.minSelfDelegation !== undefined && + object.minSelfDelegation !== null + ) { + message.minSelfDelegation = String(object.minSelfDelegation); + } else { + message.minSelfDelegation = ""; + } + return message; + }, + + toJSON(message: MsgEditValidator): unknown { + const obj: any = {}; + message.description !== undefined && + (obj.description = message.description + ? Description.toJSON(message.description) + : undefined); + message.validatorAddress !== undefined && + (obj.validatorAddress = message.validatorAddress); + message.commissionRate !== undefined && + (obj.commissionRate = message.commissionRate); + message.minSelfDelegation !== undefined && + (obj.minSelfDelegation = message.minSelfDelegation); + return obj; + }, + + fromPartial(object: DeepPartial): MsgEditValidator { + const message = { ...baseMsgEditValidator } as MsgEditValidator; + if (object.description !== undefined && object.description !== null) { + message.description = Description.fromPartial(object.description); + } else { + message.description = undefined; + } + if ( + object.validatorAddress !== undefined && + object.validatorAddress !== null + ) { + message.validatorAddress = object.validatorAddress; + } else { + message.validatorAddress = ""; + } + if (object.commissionRate !== undefined && object.commissionRate !== null) { + message.commissionRate = object.commissionRate; + } else { + message.commissionRate = ""; + } + if ( + object.minSelfDelegation !== undefined && + object.minSelfDelegation !== null + ) { + message.minSelfDelegation = object.minSelfDelegation; + } else { + message.minSelfDelegation = ""; + } + return message; + }, +}; + +const baseMsgEditValidatorResponse: object = {}; + +export const MsgEditValidatorResponse = { + encode( + _: MsgEditValidatorResponse, + writer: Writer = Writer.create() + ): Writer { + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): MsgEditValidatorResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseMsgEditValidatorResponse, + } as MsgEditValidatorResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): MsgEditValidatorResponse { + const message = { + ...baseMsgEditValidatorResponse, + } as MsgEditValidatorResponse; + return message; + }, + + toJSON(_: MsgEditValidatorResponse): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial( + _: DeepPartial + ): MsgEditValidatorResponse { + const message = { + ...baseMsgEditValidatorResponse, + } as MsgEditValidatorResponse; + return message; + }, +}; + +const baseMsgDelegate: object = { delegatorAddress: "", validatorAddress: "" }; + +export const MsgDelegate = { + encode(message: MsgDelegate, writer: Writer = Writer.create()): Writer { + if (message.delegatorAddress !== "") { + writer.uint32(10).string(message.delegatorAddress); + } + if (message.validatorAddress !== "") { + writer.uint32(18).string(message.validatorAddress); + } + if (message.amount !== undefined) { + Coin.encode(message.amount, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MsgDelegate { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgDelegate } as MsgDelegate; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.delegatorAddress = reader.string(); + break; + case 2: + message.validatorAddress = reader.string(); + break; + case 3: + message.amount = Coin.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgDelegate { + const message = { ...baseMsgDelegate } as MsgDelegate; + if ( + object.delegatorAddress !== undefined && + object.delegatorAddress !== null + ) { + message.delegatorAddress = String(object.delegatorAddress); + } else { + message.delegatorAddress = ""; + } + if ( + object.validatorAddress !== undefined && + object.validatorAddress !== null + ) { + message.validatorAddress = String(object.validatorAddress); + } else { + message.validatorAddress = ""; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = Coin.fromJSON(object.amount); + } else { + message.amount = undefined; + } + return message; + }, + + toJSON(message: MsgDelegate): unknown { + const obj: any = {}; + message.delegatorAddress !== undefined && + (obj.delegatorAddress = message.delegatorAddress); + message.validatorAddress !== undefined && + (obj.validatorAddress = message.validatorAddress); + message.amount !== undefined && + (obj.amount = message.amount ? Coin.toJSON(message.amount) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): MsgDelegate { + const message = { ...baseMsgDelegate } as MsgDelegate; + if ( + object.delegatorAddress !== undefined && + object.delegatorAddress !== null + ) { + message.delegatorAddress = object.delegatorAddress; + } else { + message.delegatorAddress = ""; + } + if ( + object.validatorAddress !== undefined && + object.validatorAddress !== null + ) { + message.validatorAddress = object.validatorAddress; + } else { + message.validatorAddress = ""; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = Coin.fromPartial(object.amount); + } else { + message.amount = undefined; + } + return message; + }, +}; + +const baseMsgDelegateResponse: object = {}; + +export const MsgDelegateResponse = { + encode(_: MsgDelegateResponse, writer: Writer = Writer.create()): Writer { + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MsgDelegateResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgDelegateResponse } as MsgDelegateResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): MsgDelegateResponse { + const message = { ...baseMsgDelegateResponse } as MsgDelegateResponse; + return message; + }, + + toJSON(_: MsgDelegateResponse): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial(_: DeepPartial): MsgDelegateResponse { + const message = { ...baseMsgDelegateResponse } as MsgDelegateResponse; + return message; + }, +}; + +const baseMsgBeginRedelegate: object = { + delegatorAddress: "", + validatorSrcAddress: "", + validatorDstAddress: "", +}; + +export const MsgBeginRedelegate = { + encode( + message: MsgBeginRedelegate, + writer: Writer = Writer.create() + ): Writer { + if (message.delegatorAddress !== "") { + writer.uint32(10).string(message.delegatorAddress); + } + if (message.validatorSrcAddress !== "") { + writer.uint32(18).string(message.validatorSrcAddress); + } + if (message.validatorDstAddress !== "") { + writer.uint32(26).string(message.validatorDstAddress); + } + if (message.amount !== undefined) { + Coin.encode(message.amount, writer.uint32(34).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MsgBeginRedelegate { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgBeginRedelegate } as MsgBeginRedelegate; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.delegatorAddress = reader.string(); + break; + case 2: + message.validatorSrcAddress = reader.string(); + break; + case 3: + message.validatorDstAddress = reader.string(); + break; + case 4: + message.amount = Coin.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgBeginRedelegate { + const message = { ...baseMsgBeginRedelegate } as MsgBeginRedelegate; + if ( + object.delegatorAddress !== undefined && + object.delegatorAddress !== null + ) { + message.delegatorAddress = String(object.delegatorAddress); + } else { + message.delegatorAddress = ""; + } + if ( + object.validatorSrcAddress !== undefined && + object.validatorSrcAddress !== null + ) { + message.validatorSrcAddress = String(object.validatorSrcAddress); + } else { + message.validatorSrcAddress = ""; + } + if ( + object.validatorDstAddress !== undefined && + object.validatorDstAddress !== null + ) { + message.validatorDstAddress = String(object.validatorDstAddress); + } else { + message.validatorDstAddress = ""; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = Coin.fromJSON(object.amount); + } else { + message.amount = undefined; + } + return message; + }, + + toJSON(message: MsgBeginRedelegate): unknown { + const obj: any = {}; + message.delegatorAddress !== undefined && + (obj.delegatorAddress = message.delegatorAddress); + message.validatorSrcAddress !== undefined && + (obj.validatorSrcAddress = message.validatorSrcAddress); + message.validatorDstAddress !== undefined && + (obj.validatorDstAddress = message.validatorDstAddress); + message.amount !== undefined && + (obj.amount = message.amount ? Coin.toJSON(message.amount) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): MsgBeginRedelegate { + const message = { ...baseMsgBeginRedelegate } as MsgBeginRedelegate; + if ( + object.delegatorAddress !== undefined && + object.delegatorAddress !== null + ) { + message.delegatorAddress = object.delegatorAddress; + } else { + message.delegatorAddress = ""; + } + if ( + object.validatorSrcAddress !== undefined && + object.validatorSrcAddress !== null + ) { + message.validatorSrcAddress = object.validatorSrcAddress; + } else { + message.validatorSrcAddress = ""; + } + if ( + object.validatorDstAddress !== undefined && + object.validatorDstAddress !== null + ) { + message.validatorDstAddress = object.validatorDstAddress; + } else { + message.validatorDstAddress = ""; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = Coin.fromPartial(object.amount); + } else { + message.amount = undefined; + } + return message; + }, +}; + +const baseMsgBeginRedelegateResponse: object = {}; + +export const MsgBeginRedelegateResponse = { + encode( + message: MsgBeginRedelegateResponse, + writer: Writer = Writer.create() + ): Writer { + if (message.completionTime !== undefined) { + Timestamp.encode( + toTimestamp(message.completionTime), + writer.uint32(10).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): MsgBeginRedelegateResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseMsgBeginRedelegateResponse, + } as MsgBeginRedelegateResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.completionTime = fromTimestamp( + Timestamp.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgBeginRedelegateResponse { + const message = { + ...baseMsgBeginRedelegateResponse, + } as MsgBeginRedelegateResponse; + if (object.completionTime !== undefined && object.completionTime !== null) { + message.completionTime = fromJsonTimestamp(object.completionTime); + } else { + message.completionTime = undefined; + } + return message; + }, + + toJSON(message: MsgBeginRedelegateResponse): unknown { + const obj: any = {}; + message.completionTime !== undefined && + (obj.completionTime = + message.completionTime !== undefined + ? message.completionTime.toISOString() + : null); + return obj; + }, + + fromPartial( + object: DeepPartial + ): MsgBeginRedelegateResponse { + const message = { + ...baseMsgBeginRedelegateResponse, + } as MsgBeginRedelegateResponse; + if (object.completionTime !== undefined && object.completionTime !== null) { + message.completionTime = object.completionTime; + } else { + message.completionTime = undefined; + } + return message; + }, +}; + +const baseMsgUndelegate: object = { + delegatorAddress: "", + validatorAddress: "", +}; + +export const MsgUndelegate = { + encode(message: MsgUndelegate, writer: Writer = Writer.create()): Writer { + if (message.delegatorAddress !== "") { + writer.uint32(10).string(message.delegatorAddress); + } + if (message.validatorAddress !== "") { + writer.uint32(18).string(message.validatorAddress); + } + if (message.amount !== undefined) { + Coin.encode(message.amount, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MsgUndelegate { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgUndelegate } as MsgUndelegate; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.delegatorAddress = reader.string(); + break; + case 2: + message.validatorAddress = reader.string(); + break; + case 3: + message.amount = Coin.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgUndelegate { + const message = { ...baseMsgUndelegate } as MsgUndelegate; + if ( + object.delegatorAddress !== undefined && + object.delegatorAddress !== null + ) { + message.delegatorAddress = String(object.delegatorAddress); + } else { + message.delegatorAddress = ""; + } + if ( + object.validatorAddress !== undefined && + object.validatorAddress !== null + ) { + message.validatorAddress = String(object.validatorAddress); + } else { + message.validatorAddress = ""; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = Coin.fromJSON(object.amount); + } else { + message.amount = undefined; + } + return message; + }, + + toJSON(message: MsgUndelegate): unknown { + const obj: any = {}; + message.delegatorAddress !== undefined && + (obj.delegatorAddress = message.delegatorAddress); + message.validatorAddress !== undefined && + (obj.validatorAddress = message.validatorAddress); + message.amount !== undefined && + (obj.amount = message.amount ? Coin.toJSON(message.amount) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): MsgUndelegate { + const message = { ...baseMsgUndelegate } as MsgUndelegate; + if ( + object.delegatorAddress !== undefined && + object.delegatorAddress !== null + ) { + message.delegatorAddress = object.delegatorAddress; + } else { + message.delegatorAddress = ""; + } + if ( + object.validatorAddress !== undefined && + object.validatorAddress !== null + ) { + message.validatorAddress = object.validatorAddress; + } else { + message.validatorAddress = ""; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = Coin.fromPartial(object.amount); + } else { + message.amount = undefined; + } + return message; + }, +}; + +const baseMsgUndelegateResponse: object = {}; + +export const MsgUndelegateResponse = { + encode( + message: MsgUndelegateResponse, + writer: Writer = Writer.create() + ): Writer { + if (message.completionTime !== undefined) { + Timestamp.encode( + toTimestamp(message.completionTime), + writer.uint32(10).fork() + ).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MsgUndelegateResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgUndelegateResponse } as MsgUndelegateResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.completionTime = fromTimestamp( + Timestamp.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgUndelegateResponse { + const message = { ...baseMsgUndelegateResponse } as MsgUndelegateResponse; + if (object.completionTime !== undefined && object.completionTime !== null) { + message.completionTime = fromJsonTimestamp(object.completionTime); + } else { + message.completionTime = undefined; + } + return message; + }, + + toJSON(message: MsgUndelegateResponse): unknown { + const obj: any = {}; + message.completionTime !== undefined && + (obj.completionTime = + message.completionTime !== undefined + ? message.completionTime.toISOString() + : null); + return obj; + }, + + fromPartial( + object: DeepPartial + ): MsgUndelegateResponse { + const message = { ...baseMsgUndelegateResponse } as MsgUndelegateResponse; + if (object.completionTime !== undefined && object.completionTime !== null) { + message.completionTime = object.completionTime; + } else { + message.completionTime = undefined; + } + return message; + }, +}; + +/** Msg defines the staking Msg service. */ +export interface Msg { + /** CreateValidator defines a method for creating a new validator. */ + CreateValidator( + request: MsgCreateValidator + ): Promise; + /** EditValidator defines a method for editing an existing validator. */ + EditValidator(request: MsgEditValidator): Promise; + /** + * Delegate defines a method for performing a delegation of coins + * from a delegator to a validator. + */ + Delegate(request: MsgDelegate): Promise; + /** + * BeginRedelegate defines a method for performing a redelegation + * of coins from a delegator and source validator to a destination validator. + */ + BeginRedelegate( + request: MsgBeginRedelegate + ): Promise; + /** + * Undelegate defines a method for performing an undelegation from a + * delegate and a validator. + */ + Undelegate(request: MsgUndelegate): Promise; +} + +export class MsgClientImpl implements Msg { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + } + CreateValidator( + request: MsgCreateValidator + ): Promise { + const data = MsgCreateValidator.encode(request).finish(); + const promise = this.rpc.request( + "cosmos.staking.v1beta1.Msg", + "CreateValidator", + data + ); + return promise.then((data) => + MsgCreateValidatorResponse.decode(new Reader(data)) + ); + } + + EditValidator(request: MsgEditValidator): Promise { + const data = MsgEditValidator.encode(request).finish(); + const promise = this.rpc.request( + "cosmos.staking.v1beta1.Msg", + "EditValidator", + data + ); + return promise.then((data) => + MsgEditValidatorResponse.decode(new Reader(data)) + ); + } + + Delegate(request: MsgDelegate): Promise { + const data = MsgDelegate.encode(request).finish(); + const promise = this.rpc.request( + "cosmos.staking.v1beta1.Msg", + "Delegate", + data + ); + return promise.then((data) => MsgDelegateResponse.decode(new Reader(data))); + } + + BeginRedelegate( + request: MsgBeginRedelegate + ): Promise { + const data = MsgBeginRedelegate.encode(request).finish(); + const promise = this.rpc.request( + "cosmos.staking.v1beta1.Msg", + "BeginRedelegate", + data + ); + return promise.then((data) => + MsgBeginRedelegateResponse.decode(new Reader(data)) + ); + } + + Undelegate(request: MsgUndelegate): Promise { + const data = MsgUndelegate.encode(request).finish(); + const promise = this.rpc.request( + "cosmos.staking.v1beta1.Msg", + "Undelegate", + data + ); + return promise.then((data) => + MsgUndelegateResponse.decode(new Reader(data)) + ); + } +} + +interface Rpc { + request( + service: string, + method: string, + data: Uint8Array + ): Promise; +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function toTimestamp(date: Date): Timestamp { + const seconds = date.getTime() / 1_000; + const nanos = (date.getTime() % 1_000) * 1_000_000; + return { seconds, nanos }; +} + +function fromTimestamp(t: Timestamp): Date { + let millis = t.seconds * 1_000; + millis += t.nanos / 1_000_000; + return new Date(millis); +} + +function fromJsonTimestamp(o: any): Date { + if (o instanceof Date) { + return o; + } else if (typeof o === "string") { + return new Date(o); + } else { + return fromTimestamp(Timestamp.fromJSON(o)); + } +} diff --git a/ts-client/cosmos.staking.v1beta1/types/cosmos_proto/cosmos.ts b/ts-client/cosmos.staking.v1beta1/types/cosmos_proto/cosmos.ts new file mode 100644 index 00000000..9ec67a12 --- /dev/null +++ b/ts-client/cosmos.staking.v1beta1/types/cosmos_proto/cosmos.ts @@ -0,0 +1,2 @@ +/* eslint-disable */ +export const protobufPackage = "cosmos_proto"; diff --git a/ts-client/cosmos.staking.v1beta1/types/gogoproto/gogo.ts b/ts-client/cosmos.staking.v1beta1/types/gogoproto/gogo.ts new file mode 100644 index 00000000..3f41a047 --- /dev/null +++ b/ts-client/cosmos.staking.v1beta1/types/gogoproto/gogo.ts @@ -0,0 +1,2 @@ +/* eslint-disable */ +export const protobufPackage = "gogoproto"; diff --git a/ts-client/cosmos.staking.v1beta1/types/google/api/annotations.ts b/ts-client/cosmos.staking.v1beta1/types/google/api/annotations.ts new file mode 100644 index 00000000..aace4787 --- /dev/null +++ b/ts-client/cosmos.staking.v1beta1/types/google/api/annotations.ts @@ -0,0 +1,2 @@ +/* eslint-disable */ +export const protobufPackage = "google.api"; diff --git a/ts-client/cosmos.staking.v1beta1/types/google/api/http.ts b/ts-client/cosmos.staking.v1beta1/types/google/api/http.ts new file mode 100644 index 00000000..ddc00f8b --- /dev/null +++ b/ts-client/cosmos.staking.v1beta1/types/google/api/http.ts @@ -0,0 +1,705 @@ +/* eslint-disable */ +import { Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "google.api"; + +/** + * Defines the HTTP configuration for an API service. It contains a list of + * [HttpRule][google.api.HttpRule], each specifying the mapping of an RPC method + * to one or more HTTP REST API methods. + */ +export interface Http { + /** + * A list of HTTP configuration rules that apply to individual API methods. + * + * **NOTE:** All service configuration rules follow "last one wins" order. + */ + rules: HttpRule[]; + /** + * When set to true, URL path parmeters will be fully URI-decoded except in + * cases of single segment matches in reserved expansion, where "%2F" will be + * left encoded. + * + * The default behavior is to not decode RFC 6570 reserved characters in multi + * segment matches. + */ + fullyDecodeReservedExpansion: boolean; +} + +/** + * `HttpRule` defines the mapping of an RPC method to one or more HTTP + * REST API methods. The mapping specifies how different portions of the RPC + * request message are mapped to URL path, URL query parameters, and + * HTTP request body. The mapping is typically specified as an + * `google.api.http` annotation on the RPC method, + * see "google/api/annotations.proto" for details. + * + * The mapping consists of a field specifying the path template and + * method kind. The path template can refer to fields in the request + * message, as in the example below which describes a REST GET + * operation on a resource collection of messages: + * + * + * service Messaging { + * rpc GetMessage(GetMessageRequest) returns (Message) { + * option (google.api.http).get = "/v1/messages/{message_id}/{sub.subfield}"; + * } + * } + * message GetMessageRequest { + * message SubMessage { + * string subfield = 1; + * } + * string message_id = 1; // mapped to the URL + * SubMessage sub = 2; // `sub.subfield` is url-mapped + * } + * message Message { + * string text = 1; // content of the resource + * } + * + * The same http annotation can alternatively be expressed inside the + * `GRPC API Configuration` YAML file. + * + * http: + * rules: + * - selector: .Messaging.GetMessage + * get: /v1/messages/{message_id}/{sub.subfield} + * + * This definition enables an automatic, bidrectional mapping of HTTP + * JSON to RPC. Example: + * + * HTTP | RPC + * -----|----- + * `GET /v1/messages/123456/foo` | `GetMessage(message_id: "123456" sub: SubMessage(subfield: "foo"))` + * + * In general, not only fields but also field paths can be referenced + * from a path pattern. Fields mapped to the path pattern cannot be + * repeated and must have a primitive (non-message) type. + * + * Any fields in the request message which are not bound by the path + * pattern automatically become (optional) HTTP query + * parameters. Assume the following definition of the request message: + * + * + * service Messaging { + * rpc GetMessage(GetMessageRequest) returns (Message) { + * option (google.api.http).get = "/v1/messages/{message_id}"; + * } + * } + * message GetMessageRequest { + * message SubMessage { + * string subfield = 1; + * } + * string message_id = 1; // mapped to the URL + * int64 revision = 2; // becomes a parameter + * SubMessage sub = 3; // `sub.subfield` becomes a parameter + * } + * + * + * This enables a HTTP JSON to RPC mapping as below: + * + * HTTP | RPC + * -----|----- + * `GET /v1/messages/123456?revision=2&sub.subfield=foo` | `GetMessage(message_id: "123456" revision: 2 sub: SubMessage(subfield: "foo"))` + * + * Note that fields which are mapped to HTTP parameters must have a + * primitive type or a repeated primitive type. Message types are not + * allowed. In the case of a repeated type, the parameter can be + * repeated in the URL, as in `...?param=A¶m=B`. + * + * For HTTP method kinds which allow a request body, the `body` field + * specifies the mapping. Consider a REST update method on the + * message resource collection: + * + * + * service Messaging { + * rpc UpdateMessage(UpdateMessageRequest) returns (Message) { + * option (google.api.http) = { + * put: "/v1/messages/{message_id}" + * body: "message" + * }; + * } + * } + * message UpdateMessageRequest { + * string message_id = 1; // mapped to the URL + * Message message = 2; // mapped to the body + * } + * + * + * The following HTTP JSON to RPC mapping is enabled, where the + * representation of the JSON in the request body is determined by + * protos JSON encoding: + * + * HTTP | RPC + * -----|----- + * `PUT /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: "123456" message { text: "Hi!" })` + * + * The special name `*` can be used in the body mapping to define that + * every field not bound by the path template should be mapped to the + * request body. This enables the following alternative definition of + * the update method: + * + * service Messaging { + * rpc UpdateMessage(Message) returns (Message) { + * option (google.api.http) = { + * put: "/v1/messages/{message_id}" + * body: "*" + * }; + * } + * } + * message Message { + * string message_id = 1; + * string text = 2; + * } + * + * + * The following HTTP JSON to RPC mapping is enabled: + * + * HTTP | RPC + * -----|----- + * `PUT /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: "123456" text: "Hi!")` + * + * Note that when using `*` in the body mapping, it is not possible to + * have HTTP parameters, as all fields not bound by the path end in + * the body. This makes this option more rarely used in practice of + * defining REST APIs. The common usage of `*` is in custom methods + * which don't use the URL at all for transferring data. + * + * It is possible to define multiple HTTP methods for one RPC by using + * the `additional_bindings` option. Example: + * + * service Messaging { + * rpc GetMessage(GetMessageRequest) returns (Message) { + * option (google.api.http) = { + * get: "/v1/messages/{message_id}" + * additional_bindings { + * get: "/v1/users/{user_id}/messages/{message_id}" + * } + * }; + * } + * } + * message GetMessageRequest { + * string message_id = 1; + * string user_id = 2; + * } + * + * + * This enables the following two alternative HTTP JSON to RPC + * mappings: + * + * HTTP | RPC + * -----|----- + * `GET /v1/messages/123456` | `GetMessage(message_id: "123456")` + * `GET /v1/users/me/messages/123456` | `GetMessage(user_id: "me" message_id: "123456")` + * + * # Rules for HTTP mapping + * + * The rules for mapping HTTP path, query parameters, and body fields + * to the request message are as follows: + * + * 1. The `body` field specifies either `*` or a field path, or is + * omitted. If omitted, it indicates there is no HTTP request body. + * 2. Leaf fields (recursive expansion of nested messages in the + * request) can be classified into three types: + * (a) Matched in the URL template. + * (b) Covered by body (if body is `*`, everything except (a) fields; + * else everything under the body field) + * (c) All other fields. + * 3. URL query parameters found in the HTTP request are mapped to (c) fields. + * 4. Any body sent with an HTTP request can contain only (b) fields. + * + * The syntax of the path template is as follows: + * + * Template = "/" Segments [ Verb ] ; + * Segments = Segment { "/" Segment } ; + * Segment = "*" | "**" | LITERAL | Variable ; + * Variable = "{" FieldPath [ "=" Segments ] "}" ; + * FieldPath = IDENT { "." IDENT } ; + * Verb = ":" LITERAL ; + * + * The syntax `*` matches a single path segment. The syntax `**` matches zero + * or more path segments, which must be the last part of the path except the + * `Verb`. The syntax `LITERAL` matches literal text in the path. + * + * The syntax `Variable` matches part of the URL path as specified by its + * template. A variable template must not contain other variables. If a variable + * matches a single path segment, its template may be omitted, e.g. `{var}` + * is equivalent to `{var=*}`. + * + * If a variable contains exactly one path segment, such as `"{var}"` or + * `"{var=*}"`, when such a variable is expanded into a URL path, all characters + * except `[-_.~0-9a-zA-Z]` are percent-encoded. Such variables show up in the + * Discovery Document as `{var}`. + * + * If a variable contains one or more path segments, such as `"{var=foo/*}"` + * or `"{var=**}"`, when such a variable is expanded into a URL path, all + * characters except `[-_.~/0-9a-zA-Z]` are percent-encoded. Such variables + * show up in the Discovery Document as `{+var}`. + * + * NOTE: While the single segment variable matches the semantics of + * [RFC 6570](https://tools.ietf.org/html/rfc6570) Section 3.2.2 + * Simple String Expansion, the multi segment variable **does not** match + * RFC 6570 Reserved Expansion. The reason is that the Reserved Expansion + * does not expand special characters like `?` and `#`, which would lead + * to invalid URLs. + * + * NOTE: the field paths in variables and in the `body` must not refer to + * repeated fields or map fields. + */ +export interface HttpRule { + /** + * Selects methods to which this rule applies. + * + * Refer to [selector][google.api.DocumentationRule.selector] for syntax details. + */ + selector: string; + /** Used for listing and getting information about resources. */ + get: string | undefined; + /** Used for updating a resource. */ + put: string | undefined; + /** Used for creating a resource. */ + post: string | undefined; + /** Used for deleting a resource. */ + delete: string | undefined; + /** Used for updating a resource. */ + patch: string | undefined; + /** + * The custom pattern is used for specifying an HTTP method that is not + * included in the `pattern` field, such as HEAD, or "*" to leave the + * HTTP method unspecified for this rule. The wild-card rule is useful + * for services that provide content to Web (HTML) clients. + */ + custom: CustomHttpPattern | undefined; + /** + * The name of the request field whose value is mapped to the HTTP body, or + * `*` for mapping all fields not captured by the path pattern to the HTTP + * body. NOTE: the referred field must not be a repeated field and must be + * present at the top-level of request message type. + */ + body: string; + /** + * Optional. The name of the response field whose value is mapped to the HTTP + * body of response. Other response fields are ignored. When + * not set, the response message will be used as HTTP body of response. + */ + responseBody: string; + /** + * Additional HTTP bindings for the selector. Nested bindings must + * not contain an `additional_bindings` field themselves (that is, + * the nesting may only be one level deep). + */ + additionalBindings: HttpRule[]; +} + +/** A custom pattern is used for defining custom HTTP verb. */ +export interface CustomHttpPattern { + /** The name of this custom HTTP verb. */ + kind: string; + /** The path matched by this custom verb. */ + path: string; +} + +const baseHttp: object = { fullyDecodeReservedExpansion: false }; + +export const Http = { + encode(message: Http, writer: Writer = Writer.create()): Writer { + for (const v of message.rules) { + HttpRule.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.fullyDecodeReservedExpansion === true) { + writer.uint32(16).bool(message.fullyDecodeReservedExpansion); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Http { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseHttp } as Http; + message.rules = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.rules.push(HttpRule.decode(reader, reader.uint32())); + break; + case 2: + message.fullyDecodeReservedExpansion = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Http { + const message = { ...baseHttp } as Http; + message.rules = []; + if (object.rules !== undefined && object.rules !== null) { + for (const e of object.rules) { + message.rules.push(HttpRule.fromJSON(e)); + } + } + if ( + object.fullyDecodeReservedExpansion !== undefined && + object.fullyDecodeReservedExpansion !== null + ) { + message.fullyDecodeReservedExpansion = Boolean( + object.fullyDecodeReservedExpansion + ); + } else { + message.fullyDecodeReservedExpansion = false; + } + return message; + }, + + toJSON(message: Http): unknown { + const obj: any = {}; + if (message.rules) { + obj.rules = message.rules.map((e) => + e ? HttpRule.toJSON(e) : undefined + ); + } else { + obj.rules = []; + } + message.fullyDecodeReservedExpansion !== undefined && + (obj.fullyDecodeReservedExpansion = message.fullyDecodeReservedExpansion); + return obj; + }, + + fromPartial(object: DeepPartial): Http { + const message = { ...baseHttp } as Http; + message.rules = []; + if (object.rules !== undefined && object.rules !== null) { + for (const e of object.rules) { + message.rules.push(HttpRule.fromPartial(e)); + } + } + if ( + object.fullyDecodeReservedExpansion !== undefined && + object.fullyDecodeReservedExpansion !== null + ) { + message.fullyDecodeReservedExpansion = + object.fullyDecodeReservedExpansion; + } else { + message.fullyDecodeReservedExpansion = false; + } + return message; + }, +}; + +const baseHttpRule: object = { selector: "", body: "", responseBody: "" }; + +export const HttpRule = { + encode(message: HttpRule, writer: Writer = Writer.create()): Writer { + if (message.selector !== "") { + writer.uint32(10).string(message.selector); + } + if (message.get !== undefined) { + writer.uint32(18).string(message.get); + } + if (message.put !== undefined) { + writer.uint32(26).string(message.put); + } + if (message.post !== undefined) { + writer.uint32(34).string(message.post); + } + if (message.delete !== undefined) { + writer.uint32(42).string(message.delete); + } + if (message.patch !== undefined) { + writer.uint32(50).string(message.patch); + } + if (message.custom !== undefined) { + CustomHttpPattern.encode( + message.custom, + writer.uint32(66).fork() + ).ldelim(); + } + if (message.body !== "") { + writer.uint32(58).string(message.body); + } + if (message.responseBody !== "") { + writer.uint32(98).string(message.responseBody); + } + for (const v of message.additionalBindings) { + HttpRule.encode(v!, writer.uint32(90).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): HttpRule { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseHttpRule } as HttpRule; + message.additionalBindings = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.selector = reader.string(); + break; + case 2: + message.get = reader.string(); + break; + case 3: + message.put = reader.string(); + break; + case 4: + message.post = reader.string(); + break; + case 5: + message.delete = reader.string(); + break; + case 6: + message.patch = reader.string(); + break; + case 8: + message.custom = CustomHttpPattern.decode(reader, reader.uint32()); + break; + case 7: + message.body = reader.string(); + break; + case 12: + message.responseBody = reader.string(); + break; + case 11: + message.additionalBindings.push( + HttpRule.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): HttpRule { + const message = { ...baseHttpRule } as HttpRule; + message.additionalBindings = []; + if (object.selector !== undefined && object.selector !== null) { + message.selector = String(object.selector); + } else { + message.selector = ""; + } + if (object.get !== undefined && object.get !== null) { + message.get = String(object.get); + } else { + message.get = undefined; + } + if (object.put !== undefined && object.put !== null) { + message.put = String(object.put); + } else { + message.put = undefined; + } + if (object.post !== undefined && object.post !== null) { + message.post = String(object.post); + } else { + message.post = undefined; + } + if (object.delete !== undefined && object.delete !== null) { + message.delete = String(object.delete); + } else { + message.delete = undefined; + } + if (object.patch !== undefined && object.patch !== null) { + message.patch = String(object.patch); + } else { + message.patch = undefined; + } + if (object.custom !== undefined && object.custom !== null) { + message.custom = CustomHttpPattern.fromJSON(object.custom); + } else { + message.custom = undefined; + } + if (object.body !== undefined && object.body !== null) { + message.body = String(object.body); + } else { + message.body = ""; + } + if (object.responseBody !== undefined && object.responseBody !== null) { + message.responseBody = String(object.responseBody); + } else { + message.responseBody = ""; + } + if ( + object.additionalBindings !== undefined && + object.additionalBindings !== null + ) { + for (const e of object.additionalBindings) { + message.additionalBindings.push(HttpRule.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: HttpRule): unknown { + const obj: any = {}; + message.selector !== undefined && (obj.selector = message.selector); + message.get !== undefined && (obj.get = message.get); + message.put !== undefined && (obj.put = message.put); + message.post !== undefined && (obj.post = message.post); + message.delete !== undefined && (obj.delete = message.delete); + message.patch !== undefined && (obj.patch = message.patch); + message.custom !== undefined && + (obj.custom = message.custom + ? CustomHttpPattern.toJSON(message.custom) + : undefined); + message.body !== undefined && (obj.body = message.body); + message.responseBody !== undefined && + (obj.responseBody = message.responseBody); + if (message.additionalBindings) { + obj.additionalBindings = message.additionalBindings.map((e) => + e ? HttpRule.toJSON(e) : undefined + ); + } else { + obj.additionalBindings = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): HttpRule { + const message = { ...baseHttpRule } as HttpRule; + message.additionalBindings = []; + if (object.selector !== undefined && object.selector !== null) { + message.selector = object.selector; + } else { + message.selector = ""; + } + if (object.get !== undefined && object.get !== null) { + message.get = object.get; + } else { + message.get = undefined; + } + if (object.put !== undefined && object.put !== null) { + message.put = object.put; + } else { + message.put = undefined; + } + if (object.post !== undefined && object.post !== null) { + message.post = object.post; + } else { + message.post = undefined; + } + if (object.delete !== undefined && object.delete !== null) { + message.delete = object.delete; + } else { + message.delete = undefined; + } + if (object.patch !== undefined && object.patch !== null) { + message.patch = object.patch; + } else { + message.patch = undefined; + } + if (object.custom !== undefined && object.custom !== null) { + message.custom = CustomHttpPattern.fromPartial(object.custom); + } else { + message.custom = undefined; + } + if (object.body !== undefined && object.body !== null) { + message.body = object.body; + } else { + message.body = ""; + } + if (object.responseBody !== undefined && object.responseBody !== null) { + message.responseBody = object.responseBody; + } else { + message.responseBody = ""; + } + if ( + object.additionalBindings !== undefined && + object.additionalBindings !== null + ) { + for (const e of object.additionalBindings) { + message.additionalBindings.push(HttpRule.fromPartial(e)); + } + } + return message; + }, +}; + +const baseCustomHttpPattern: object = { kind: "", path: "" }; + +export const CustomHttpPattern = { + encode(message: CustomHttpPattern, writer: Writer = Writer.create()): Writer { + if (message.kind !== "") { + writer.uint32(10).string(message.kind); + } + if (message.path !== "") { + writer.uint32(18).string(message.path); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): CustomHttpPattern { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseCustomHttpPattern } as CustomHttpPattern; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.kind = reader.string(); + break; + case 2: + message.path = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): CustomHttpPattern { + const message = { ...baseCustomHttpPattern } as CustomHttpPattern; + if (object.kind !== undefined && object.kind !== null) { + message.kind = String(object.kind); + } else { + message.kind = ""; + } + if (object.path !== undefined && object.path !== null) { + message.path = String(object.path); + } else { + message.path = ""; + } + return message; + }, + + toJSON(message: CustomHttpPattern): unknown { + const obj: any = {}; + message.kind !== undefined && (obj.kind = message.kind); + message.path !== undefined && (obj.path = message.path); + return obj; + }, + + fromPartial(object: DeepPartial): CustomHttpPattern { + const message = { ...baseCustomHttpPattern } as CustomHttpPattern; + if (object.kind !== undefined && object.kind !== null) { + message.kind = object.kind; + } else { + message.kind = ""; + } + if (object.path !== undefined && object.path !== null) { + message.path = object.path; + } else { + message.path = ""; + } + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/cosmos.staking.v1beta1/types/google/protobuf/any.ts b/ts-client/cosmos.staking.v1beta1/types/google/protobuf/any.ts new file mode 100644 index 00000000..b137a629 --- /dev/null +++ b/ts-client/cosmos.staking.v1beta1/types/google/protobuf/any.ts @@ -0,0 +1,240 @@ +/* eslint-disable */ +import { Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "google.protobuf"; + +/** + * `Any` contains an arbitrary serialized protocol buffer message along with a + * URL that describes the type of the serialized message. + * + * Protobuf library provides support to pack/unpack Any values in the form + * of utility functions or additional generated methods of the Any type. + * + * Example 1: Pack and unpack a message in C++. + * + * Foo foo = ...; + * Any any; + * any.PackFrom(foo); + * ... + * if (any.UnpackTo(&foo)) { + * ... + * } + * + * Example 2: Pack and unpack a message in Java. + * + * Foo foo = ...; + * Any any = Any.pack(foo); + * ... + * if (any.is(Foo.class)) { + * foo = any.unpack(Foo.class); + * } + * + * Example 3: Pack and unpack a message in Python. + * + * foo = Foo(...) + * any = Any() + * any.Pack(foo) + * ... + * if any.Is(Foo.DESCRIPTOR): + * any.Unpack(foo) + * ... + * + * Example 4: Pack and unpack a message in Go + * + * foo := &pb.Foo{...} + * any, err := anypb.New(foo) + * if err != nil { + * ... + * } + * ... + * foo := &pb.Foo{} + * if err := any.UnmarshalTo(foo); err != nil { + * ... + * } + * + * The pack methods provided by protobuf library will by default use + * 'type.googleapis.com/full.type.name' as the type URL and the unpack + * methods only use the fully qualified type name after the last '/' + * in the type URL, for example "foo.bar.com/x/y.z" will yield type + * name "y.z". + * + * + * JSON + * ==== + * The JSON representation of an `Any` value uses the regular + * representation of the deserialized, embedded message, with an + * additional field `@type` which contains the type URL. Example: + * + * package google.profile; + * message Person { + * string first_name = 1; + * string last_name = 2; + * } + * + * { + * "@type": "type.googleapis.com/google.profile.Person", + * "firstName": , + * "lastName": + * } + * + * If the embedded message type is well-known and has a custom JSON + * representation, that representation will be embedded adding a field + * `value` which holds the custom JSON in addition to the `@type` + * field. Example (for message [google.protobuf.Duration][]): + * + * { + * "@type": "type.googleapis.com/google.protobuf.Duration", + * "value": "1.212s" + * } + */ +export interface Any { + /** + * A URL/resource name that uniquely identifies the type of the serialized + * protocol buffer message. This string must contain at least + * one "/" character. The last segment of the URL's path must represent + * the fully qualified name of the type (as in + * `path/google.protobuf.Duration`). The name should be in a canonical form + * (e.g., leading "." is not accepted). + * + * In practice, teams usually precompile into the binary all types that they + * expect it to use in the context of Any. However, for URLs which use the + * scheme `http`, `https`, or no scheme, one can optionally set up a type + * server that maps type URLs to message definitions as follows: + * + * * If no scheme is provided, `https` is assumed. + * * An HTTP GET on the URL must yield a [google.protobuf.Type][] + * value in binary format, or produce an error. + * * Applications are allowed to cache lookup results based on the + * URL, or have them precompiled into a binary to avoid any + * lookup. Therefore, binary compatibility needs to be preserved + * on changes to types. (Use versioned type names to manage + * breaking changes.) + * + * Note: this functionality is not currently available in the official + * protobuf release, and it is not used for type URLs beginning with + * type.googleapis.com. + * + * Schemes other than `http`, `https` (or the empty scheme) might be + * used with implementation specific semantics. + */ + typeUrl: string; + /** Must be a valid serialized protocol buffer of the above specified type. */ + value: Uint8Array; +} + +const baseAny: object = { typeUrl: "" }; + +export const Any = { + encode(message: Any, writer: Writer = Writer.create()): Writer { + if (message.typeUrl !== "") { + writer.uint32(10).string(message.typeUrl); + } + if (message.value.length !== 0) { + writer.uint32(18).bytes(message.value); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Any { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseAny } as Any; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.typeUrl = reader.string(); + break; + case 2: + message.value = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Any { + const message = { ...baseAny } as Any; + if (object.typeUrl !== undefined && object.typeUrl !== null) { + message.typeUrl = String(object.typeUrl); + } else { + message.typeUrl = ""; + } + if (object.value !== undefined && object.value !== null) { + message.value = bytesFromBase64(object.value); + } + return message; + }, + + toJSON(message: Any): unknown { + const obj: any = {}; + message.typeUrl !== undefined && (obj.typeUrl = message.typeUrl); + message.value !== undefined && + (obj.value = base64FromBytes( + message.value !== undefined ? message.value : new Uint8Array() + )); + return obj; + }, + + fromPartial(object: DeepPartial): Any { + const message = { ...baseAny } as Any; + if (object.typeUrl !== undefined && object.typeUrl !== null) { + message.typeUrl = object.typeUrl; + } else { + message.typeUrl = ""; + } + if (object.value !== undefined && object.value !== null) { + message.value = object.value; + } else { + message.value = new Uint8Array(); + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/cosmos.staking.v1beta1/types/google/protobuf/descriptor.ts b/ts-client/cosmos.staking.v1beta1/types/google/protobuf/descriptor.ts new file mode 100644 index 00000000..9e508660 --- /dev/null +++ b/ts-client/cosmos.staking.v1beta1/types/google/protobuf/descriptor.ts @@ -0,0 +1,5261 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "google.protobuf"; + +/** + * The protocol compiler can output a FileDescriptorSet containing the .proto + * files it parses. + */ +export interface FileDescriptorSet { + file: FileDescriptorProto[]; +} + +/** Describes a complete .proto file. */ +export interface FileDescriptorProto { + /** file name, relative to root of source tree */ + name: string; + /** e.g. "foo", "foo.bar", etc. */ + package: string; + /** Names of files imported by this file. */ + dependency: string[]; + /** Indexes of the public imported files in the dependency list above. */ + publicDependency: number[]; + /** + * Indexes of the weak imported files in the dependency list. + * For Google-internal migration only. Do not use. + */ + weakDependency: number[]; + /** All top-level definitions in this file. */ + messageType: DescriptorProto[]; + enumType: EnumDescriptorProto[]; + service: ServiceDescriptorProto[]; + extension: FieldDescriptorProto[]; + options: FileOptions | undefined; + /** + * This field contains optional information about the original source code. + * You may safely remove this entire field without harming runtime + * functionality of the descriptors -- the information is needed only by + * development tools. + */ + sourceCodeInfo: SourceCodeInfo | undefined; + /** + * The syntax of the proto file. + * The supported values are "proto2" and "proto3". + */ + syntax: string; +} + +/** Describes a message type. */ +export interface DescriptorProto { + name: string; + field: FieldDescriptorProto[]; + extension: FieldDescriptorProto[]; + nestedType: DescriptorProto[]; + enumType: EnumDescriptorProto[]; + extensionRange: DescriptorProto_ExtensionRange[]; + oneofDecl: OneofDescriptorProto[]; + options: MessageOptions | undefined; + reservedRange: DescriptorProto_ReservedRange[]; + /** + * Reserved field names, which may not be used by fields in the same message. + * A given name may only be reserved once. + */ + reservedName: string[]; +} + +export interface DescriptorProto_ExtensionRange { + /** Inclusive. */ + start: number; + /** Exclusive. */ + end: number; + options: ExtensionRangeOptions | undefined; +} + +/** + * Range of reserved tag numbers. Reserved tag numbers may not be used by + * fields or extension ranges in the same message. Reserved ranges may + * not overlap. + */ +export interface DescriptorProto_ReservedRange { + /** Inclusive. */ + start: number; + /** Exclusive. */ + end: number; +} + +export interface ExtensionRangeOptions { + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +/** Describes a field within a message. */ +export interface FieldDescriptorProto { + name: string; + number: number; + label: FieldDescriptorProto_Label; + /** + * If type_name is set, this need not be set. If both this and type_name + * are set, this must be one of TYPE_ENUM, TYPE_MESSAGE or TYPE_GROUP. + */ + type: FieldDescriptorProto_Type; + /** + * For message and enum types, this is the name of the type. If the name + * starts with a '.', it is fully-qualified. Otherwise, C++-like scoping + * rules are used to find the type (i.e. first the nested types within this + * message are searched, then within the parent, on up to the root + * namespace). + */ + typeName: string; + /** + * For extensions, this is the name of the type being extended. It is + * resolved in the same manner as type_name. + */ + extendee: string; + /** + * For numeric types, contains the original text representation of the value. + * For booleans, "true" or "false". + * For strings, contains the default text contents (not escaped in any way). + * For bytes, contains the C escaped value. All bytes >= 128 are escaped. + * TODO(kenton): Base-64 encode? + */ + defaultValue: string; + /** + * If set, gives the index of a oneof in the containing type's oneof_decl + * list. This field is a member of that oneof. + */ + oneofIndex: number; + /** + * JSON name of this field. The value is set by protocol compiler. If the + * user has set a "json_name" option on this field, that option's value + * will be used. Otherwise, it's deduced from the field's name by converting + * it to camelCase. + */ + jsonName: string; + options: FieldOptions | undefined; + /** + * If true, this is a proto3 "optional". When a proto3 field is optional, it + * tracks presence regardless of field type. + * + * When proto3_optional is true, this field must be belong to a oneof to + * signal to old proto3 clients that presence is tracked for this field. This + * oneof is known as a "synthetic" oneof, and this field must be its sole + * member (each proto3 optional field gets its own synthetic oneof). Synthetic + * oneofs exist in the descriptor only, and do not generate any API. Synthetic + * oneofs must be ordered after all "real" oneofs. + * + * For message fields, proto3_optional doesn't create any semantic change, + * since non-repeated message fields always track presence. However it still + * indicates the semantic detail of whether the user wrote "optional" or not. + * This can be useful for round-tripping the .proto file. For consistency we + * give message fields a synthetic oneof also, even though it is not required + * to track presence. This is especially important because the parser can't + * tell if a field is a message or an enum, so it must always create a + * synthetic oneof. + * + * Proto2 optional fields do not set this flag, because they already indicate + * optional with `LABEL_OPTIONAL`. + */ + proto3Optional: boolean; +} + +export enum FieldDescriptorProto_Type { + /** + * TYPE_DOUBLE - 0 is reserved for errors. + * Order is weird for historical reasons. + */ + TYPE_DOUBLE = 1, + TYPE_FLOAT = 2, + /** + * TYPE_INT64 - Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT64 if + * negative values are likely. + */ + TYPE_INT64 = 3, + TYPE_UINT64 = 4, + /** + * TYPE_INT32 - Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT32 if + * negative values are likely. + */ + TYPE_INT32 = 5, + TYPE_FIXED64 = 6, + TYPE_FIXED32 = 7, + TYPE_BOOL = 8, + TYPE_STRING = 9, + /** + * TYPE_GROUP - Tag-delimited aggregate. + * Group type is deprecated and not supported in proto3. However, Proto3 + * implementations should still be able to parse the group wire format and + * treat group fields as unknown fields. + */ + TYPE_GROUP = 10, + /** TYPE_MESSAGE - Length-delimited aggregate. */ + TYPE_MESSAGE = 11, + /** TYPE_BYTES - New in version 2. */ + TYPE_BYTES = 12, + TYPE_UINT32 = 13, + TYPE_ENUM = 14, + TYPE_SFIXED32 = 15, + TYPE_SFIXED64 = 16, + /** TYPE_SINT32 - Uses ZigZag encoding. */ + TYPE_SINT32 = 17, + /** TYPE_SINT64 - Uses ZigZag encoding. */ + TYPE_SINT64 = 18, + UNRECOGNIZED = -1, +} + +export function fieldDescriptorProto_TypeFromJSON( + object: any +): FieldDescriptorProto_Type { + switch (object) { + case 1: + case "TYPE_DOUBLE": + return FieldDescriptorProto_Type.TYPE_DOUBLE; + case 2: + case "TYPE_FLOAT": + return FieldDescriptorProto_Type.TYPE_FLOAT; + case 3: + case "TYPE_INT64": + return FieldDescriptorProto_Type.TYPE_INT64; + case 4: + case "TYPE_UINT64": + return FieldDescriptorProto_Type.TYPE_UINT64; + case 5: + case "TYPE_INT32": + return FieldDescriptorProto_Type.TYPE_INT32; + case 6: + case "TYPE_FIXED64": + return FieldDescriptorProto_Type.TYPE_FIXED64; + case 7: + case "TYPE_FIXED32": + return FieldDescriptorProto_Type.TYPE_FIXED32; + case 8: + case "TYPE_BOOL": + return FieldDescriptorProto_Type.TYPE_BOOL; + case 9: + case "TYPE_STRING": + return FieldDescriptorProto_Type.TYPE_STRING; + case 10: + case "TYPE_GROUP": + return FieldDescriptorProto_Type.TYPE_GROUP; + case 11: + case "TYPE_MESSAGE": + return FieldDescriptorProto_Type.TYPE_MESSAGE; + case 12: + case "TYPE_BYTES": + return FieldDescriptorProto_Type.TYPE_BYTES; + case 13: + case "TYPE_UINT32": + return FieldDescriptorProto_Type.TYPE_UINT32; + case 14: + case "TYPE_ENUM": + return FieldDescriptorProto_Type.TYPE_ENUM; + case 15: + case "TYPE_SFIXED32": + return FieldDescriptorProto_Type.TYPE_SFIXED32; + case 16: + case "TYPE_SFIXED64": + return FieldDescriptorProto_Type.TYPE_SFIXED64; + case 17: + case "TYPE_SINT32": + return FieldDescriptorProto_Type.TYPE_SINT32; + case 18: + case "TYPE_SINT64": + return FieldDescriptorProto_Type.TYPE_SINT64; + case -1: + case "UNRECOGNIZED": + default: + return FieldDescriptorProto_Type.UNRECOGNIZED; + } +} + +export function fieldDescriptorProto_TypeToJSON( + object: FieldDescriptorProto_Type +): string { + switch (object) { + case FieldDescriptorProto_Type.TYPE_DOUBLE: + return "TYPE_DOUBLE"; + case FieldDescriptorProto_Type.TYPE_FLOAT: + return "TYPE_FLOAT"; + case FieldDescriptorProto_Type.TYPE_INT64: + return "TYPE_INT64"; + case FieldDescriptorProto_Type.TYPE_UINT64: + return "TYPE_UINT64"; + case FieldDescriptorProto_Type.TYPE_INT32: + return "TYPE_INT32"; + case FieldDescriptorProto_Type.TYPE_FIXED64: + return "TYPE_FIXED64"; + case FieldDescriptorProto_Type.TYPE_FIXED32: + return "TYPE_FIXED32"; + case FieldDescriptorProto_Type.TYPE_BOOL: + return "TYPE_BOOL"; + case FieldDescriptorProto_Type.TYPE_STRING: + return "TYPE_STRING"; + case FieldDescriptorProto_Type.TYPE_GROUP: + return "TYPE_GROUP"; + case FieldDescriptorProto_Type.TYPE_MESSAGE: + return "TYPE_MESSAGE"; + case FieldDescriptorProto_Type.TYPE_BYTES: + return "TYPE_BYTES"; + case FieldDescriptorProto_Type.TYPE_UINT32: + return "TYPE_UINT32"; + case FieldDescriptorProto_Type.TYPE_ENUM: + return "TYPE_ENUM"; + case FieldDescriptorProto_Type.TYPE_SFIXED32: + return "TYPE_SFIXED32"; + case FieldDescriptorProto_Type.TYPE_SFIXED64: + return "TYPE_SFIXED64"; + case FieldDescriptorProto_Type.TYPE_SINT32: + return "TYPE_SINT32"; + case FieldDescriptorProto_Type.TYPE_SINT64: + return "TYPE_SINT64"; + default: + return "UNKNOWN"; + } +} + +export enum FieldDescriptorProto_Label { + /** LABEL_OPTIONAL - 0 is reserved for errors */ + LABEL_OPTIONAL = 1, + LABEL_REQUIRED = 2, + LABEL_REPEATED = 3, + UNRECOGNIZED = -1, +} + +export function fieldDescriptorProto_LabelFromJSON( + object: any +): FieldDescriptorProto_Label { + switch (object) { + case 1: + case "LABEL_OPTIONAL": + return FieldDescriptorProto_Label.LABEL_OPTIONAL; + case 2: + case "LABEL_REQUIRED": + return FieldDescriptorProto_Label.LABEL_REQUIRED; + case 3: + case "LABEL_REPEATED": + return FieldDescriptorProto_Label.LABEL_REPEATED; + case -1: + case "UNRECOGNIZED": + default: + return FieldDescriptorProto_Label.UNRECOGNIZED; + } +} + +export function fieldDescriptorProto_LabelToJSON( + object: FieldDescriptorProto_Label +): string { + switch (object) { + case FieldDescriptorProto_Label.LABEL_OPTIONAL: + return "LABEL_OPTIONAL"; + case FieldDescriptorProto_Label.LABEL_REQUIRED: + return "LABEL_REQUIRED"; + case FieldDescriptorProto_Label.LABEL_REPEATED: + return "LABEL_REPEATED"; + default: + return "UNKNOWN"; + } +} + +/** Describes a oneof. */ +export interface OneofDescriptorProto { + name: string; + options: OneofOptions | undefined; +} + +/** Describes an enum type. */ +export interface EnumDescriptorProto { + name: string; + value: EnumValueDescriptorProto[]; + options: EnumOptions | undefined; + /** + * Range of reserved numeric values. Reserved numeric values may not be used + * by enum values in the same enum declaration. Reserved ranges may not + * overlap. + */ + reservedRange: EnumDescriptorProto_EnumReservedRange[]; + /** + * Reserved enum value names, which may not be reused. A given name may only + * be reserved once. + */ + reservedName: string[]; +} + +/** + * Range of reserved numeric values. Reserved values may not be used by + * entries in the same enum. Reserved ranges may not overlap. + * + * Note that this is distinct from DescriptorProto.ReservedRange in that it + * is inclusive such that it can appropriately represent the entire int32 + * domain. + */ +export interface EnumDescriptorProto_EnumReservedRange { + /** Inclusive. */ + start: number; + /** Inclusive. */ + end: number; +} + +/** Describes a value within an enum. */ +export interface EnumValueDescriptorProto { + name: string; + number: number; + options: EnumValueOptions | undefined; +} + +/** Describes a service. */ +export interface ServiceDescriptorProto { + name: string; + method: MethodDescriptorProto[]; + options: ServiceOptions | undefined; +} + +/** Describes a method of a service. */ +export interface MethodDescriptorProto { + name: string; + /** + * Input and output type names. These are resolved in the same way as + * FieldDescriptorProto.type_name, but must refer to a message type. + */ + inputType: string; + outputType: string; + options: MethodOptions | undefined; + /** Identifies if client streams multiple client messages */ + clientStreaming: boolean; + /** Identifies if server streams multiple server messages */ + serverStreaming: boolean; +} + +export interface FileOptions { + /** + * Sets the Java package where classes generated from this .proto will be + * placed. By default, the proto package is used, but this is often + * inappropriate because proto packages do not normally start with backwards + * domain names. + */ + javaPackage: string; + /** + * Controls the name of the wrapper Java class generated for the .proto file. + * That class will always contain the .proto file's getDescriptor() method as + * well as any top-level extensions defined in the .proto file. + * If java_multiple_files is disabled, then all the other classes from the + * .proto file will be nested inside the single wrapper outer class. + */ + javaOuterClassname: string; + /** + * If enabled, then the Java code generator will generate a separate .java + * file for each top-level message, enum, and service defined in the .proto + * file. Thus, these types will *not* be nested inside the wrapper class + * named by java_outer_classname. However, the wrapper class will still be + * generated to contain the file's getDescriptor() method as well as any + * top-level extensions defined in the file. + */ + javaMultipleFiles: boolean; + /** + * This option does nothing. + * + * @deprecated + */ + javaGenerateEqualsAndHash: boolean; + /** + * If set true, then the Java2 code generator will generate code that + * throws an exception whenever an attempt is made to assign a non-UTF-8 + * byte sequence to a string field. + * Message reflection will do the same. + * However, an extension field still accepts non-UTF-8 byte sequences. + * This option has no effect on when used with the lite runtime. + */ + javaStringCheckUtf8: boolean; + optimizeFor: FileOptions_OptimizeMode; + /** + * Sets the Go package where structs generated from this .proto will be + * placed. If omitted, the Go package will be derived from the following: + * - The basename of the package import path, if provided. + * - Otherwise, the package statement in the .proto file, if present. + * - Otherwise, the basename of the .proto file, without extension. + */ + goPackage: string; + /** + * Should generic services be generated in each language? "Generic" services + * are not specific to any particular RPC system. They are generated by the + * main code generators in each language (without additional plugins). + * Generic services were the only kind of service generation supported by + * early versions of google.protobuf. + * + * Generic services are now considered deprecated in favor of using plugins + * that generate code specific to your particular RPC system. Therefore, + * these default to false. Old code which depends on generic services should + * explicitly set them to true. + */ + ccGenericServices: boolean; + javaGenericServices: boolean; + pyGenericServices: boolean; + phpGenericServices: boolean; + /** + * Is this file deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for everything in the file, or it will be completely ignored; in the very + * least, this is a formalization for deprecating files. + */ + deprecated: boolean; + /** + * Enables the use of arenas for the proto messages in this file. This applies + * only to generated classes for C++. + */ + ccEnableArenas: boolean; + /** + * Sets the objective c class prefix which is prepended to all objective c + * generated classes from this .proto. There is no default. + */ + objcClassPrefix: string; + /** Namespace for generated classes; defaults to the package. */ + csharpNamespace: string; + /** + * By default Swift generators will take the proto package and CamelCase it + * replacing '.' with underscore and use that to prefix the types/symbols + * defined. When this options is provided, they will use this value instead + * to prefix the types/symbols defined. + */ + swiftPrefix: string; + /** + * Sets the php class prefix which is prepended to all php generated classes + * from this .proto. Default is empty. + */ + phpClassPrefix: string; + /** + * Use this option to change the namespace of php generated classes. Default + * is empty. When this option is empty, the package name will be used for + * determining the namespace. + */ + phpNamespace: string; + /** + * Use this option to change the namespace of php generated metadata classes. + * Default is empty. When this option is empty, the proto file name will be + * used for determining the namespace. + */ + phpMetadataNamespace: string; + /** + * Use this option to change the package of ruby generated classes. Default + * is empty. When this option is not set, the package name will be used for + * determining the ruby package. + */ + rubyPackage: string; + /** + * The parser stores options it doesn't recognize here. + * See the documentation for the "Options" section above. + */ + uninterpretedOption: UninterpretedOption[]; +} + +/** Generated classes can be optimized for speed or code size. */ +export enum FileOptions_OptimizeMode { + /** SPEED - Generate complete code for parsing, serialization, */ + SPEED = 1, + /** CODE_SIZE - etc. */ + CODE_SIZE = 2, + /** LITE_RUNTIME - Generate code using MessageLite and the lite runtime. */ + LITE_RUNTIME = 3, + UNRECOGNIZED = -1, +} + +export function fileOptions_OptimizeModeFromJSON( + object: any +): FileOptions_OptimizeMode { + switch (object) { + case 1: + case "SPEED": + return FileOptions_OptimizeMode.SPEED; + case 2: + case "CODE_SIZE": + return FileOptions_OptimizeMode.CODE_SIZE; + case 3: + case "LITE_RUNTIME": + return FileOptions_OptimizeMode.LITE_RUNTIME; + case -1: + case "UNRECOGNIZED": + default: + return FileOptions_OptimizeMode.UNRECOGNIZED; + } +} + +export function fileOptions_OptimizeModeToJSON( + object: FileOptions_OptimizeMode +): string { + switch (object) { + case FileOptions_OptimizeMode.SPEED: + return "SPEED"; + case FileOptions_OptimizeMode.CODE_SIZE: + return "CODE_SIZE"; + case FileOptions_OptimizeMode.LITE_RUNTIME: + return "LITE_RUNTIME"; + default: + return "UNKNOWN"; + } +} + +export interface MessageOptions { + /** + * Set true to use the old proto1 MessageSet wire format for extensions. + * This is provided for backwards-compatibility with the MessageSet wire + * format. You should not use this for any other reason: It's less + * efficient, has fewer features, and is more complicated. + * + * The message must be defined exactly as follows: + * message Foo { + * option message_set_wire_format = true; + * extensions 4 to max; + * } + * Note that the message cannot have any defined fields; MessageSets only + * have extensions. + * + * All extensions of your type must be singular messages; e.g. they cannot + * be int32s, enums, or repeated messages. + * + * Because this is an option, the above two restrictions are not enforced by + * the protocol compiler. + */ + messageSetWireFormat: boolean; + /** + * Disables the generation of the standard "descriptor()" accessor, which can + * conflict with a field of the same name. This is meant to make migration + * from proto1 easier; new code should avoid fields named "descriptor". + */ + noStandardDescriptorAccessor: boolean; + /** + * Is this message deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the message, or it will be completely ignored; in the very least, + * this is a formalization for deprecating messages. + */ + deprecated: boolean; + /** + * Whether the message is an automatically generated map entry type for the + * maps field. + * + * For maps fields: + * map map_field = 1; + * The parsed descriptor looks like: + * message MapFieldEntry { + * option map_entry = true; + * optional KeyType key = 1; + * optional ValueType value = 2; + * } + * repeated MapFieldEntry map_field = 1; + * + * Implementations may choose not to generate the map_entry=true message, but + * use a native map in the target language to hold the keys and values. + * The reflection APIs in such implementations still need to work as + * if the field is a repeated message field. + * + * NOTE: Do not set the option in .proto files. Always use the maps syntax + * instead. The option should only be implicitly set by the proto compiler + * parser. + */ + mapEntry: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface FieldOptions { + /** + * The ctype option instructs the C++ code generator to use a different + * representation of the field than it normally would. See the specific + * options below. This option is not yet implemented in the open source + * release -- sorry, we'll try to include it in a future version! + */ + ctype: FieldOptions_CType; + /** + * The packed option can be enabled for repeated primitive fields to enable + * a more efficient representation on the wire. Rather than repeatedly + * writing the tag and type for each element, the entire array is encoded as + * a single length-delimited blob. In proto3, only explicit setting it to + * false will avoid using packed encoding. + */ + packed: boolean; + /** + * The jstype option determines the JavaScript type used for values of the + * field. The option is permitted only for 64 bit integral and fixed types + * (int64, uint64, sint64, fixed64, sfixed64). A field with jstype JS_STRING + * is represented as JavaScript string, which avoids loss of precision that + * can happen when a large value is converted to a floating point JavaScript. + * Specifying JS_NUMBER for the jstype causes the generated JavaScript code to + * use the JavaScript "number" type. The behavior of the default option + * JS_NORMAL is implementation dependent. + * + * This option is an enum to permit additional types to be added, e.g. + * goog.math.Integer. + */ + jstype: FieldOptions_JSType; + /** + * Should this field be parsed lazily? Lazy applies only to message-type + * fields. It means that when the outer message is initially parsed, the + * inner message's contents will not be parsed but instead stored in encoded + * form. The inner message will actually be parsed when it is first accessed. + * + * This is only a hint. Implementations are free to choose whether to use + * eager or lazy parsing regardless of the value of this option. However, + * setting this option true suggests that the protocol author believes that + * using lazy parsing on this field is worth the additional bookkeeping + * overhead typically needed to implement it. + * + * This option does not affect the public interface of any generated code; + * all method signatures remain the same. Furthermore, thread-safety of the + * interface is not affected by this option; const methods remain safe to + * call from multiple threads concurrently, while non-const methods continue + * to require exclusive access. + * + * + * Note that implementations may choose not to check required fields within + * a lazy sub-message. That is, calling IsInitialized() on the outer message + * may return true even if the inner message has missing required fields. + * This is necessary because otherwise the inner message would have to be + * parsed in order to perform the check, defeating the purpose of lazy + * parsing. An implementation which chooses not to check required fields + * must be consistent about it. That is, for any particular sub-message, the + * implementation must either *always* check its required fields, or *never* + * check its required fields, regardless of whether or not the message has + * been parsed. + */ + lazy: boolean; + /** + * Is this field deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for accessors, or it will be completely ignored; in the very least, this + * is a formalization for deprecating fields. + */ + deprecated: boolean; + /** For Google-internal migration only. Do not use. */ + weak: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export enum FieldOptions_CType { + /** STRING - Default mode. */ + STRING = 0, + CORD = 1, + STRING_PIECE = 2, + UNRECOGNIZED = -1, +} + +export function fieldOptions_CTypeFromJSON(object: any): FieldOptions_CType { + switch (object) { + case 0: + case "STRING": + return FieldOptions_CType.STRING; + case 1: + case "CORD": + return FieldOptions_CType.CORD; + case 2: + case "STRING_PIECE": + return FieldOptions_CType.STRING_PIECE; + case -1: + case "UNRECOGNIZED": + default: + return FieldOptions_CType.UNRECOGNIZED; + } +} + +export function fieldOptions_CTypeToJSON(object: FieldOptions_CType): string { + switch (object) { + case FieldOptions_CType.STRING: + return "STRING"; + case FieldOptions_CType.CORD: + return "CORD"; + case FieldOptions_CType.STRING_PIECE: + return "STRING_PIECE"; + default: + return "UNKNOWN"; + } +} + +export enum FieldOptions_JSType { + /** JS_NORMAL - Use the default type. */ + JS_NORMAL = 0, + /** JS_STRING - Use JavaScript strings. */ + JS_STRING = 1, + /** JS_NUMBER - Use JavaScript numbers. */ + JS_NUMBER = 2, + UNRECOGNIZED = -1, +} + +export function fieldOptions_JSTypeFromJSON(object: any): FieldOptions_JSType { + switch (object) { + case 0: + case "JS_NORMAL": + return FieldOptions_JSType.JS_NORMAL; + case 1: + case "JS_STRING": + return FieldOptions_JSType.JS_STRING; + case 2: + case "JS_NUMBER": + return FieldOptions_JSType.JS_NUMBER; + case -1: + case "UNRECOGNIZED": + default: + return FieldOptions_JSType.UNRECOGNIZED; + } +} + +export function fieldOptions_JSTypeToJSON(object: FieldOptions_JSType): string { + switch (object) { + case FieldOptions_JSType.JS_NORMAL: + return "JS_NORMAL"; + case FieldOptions_JSType.JS_STRING: + return "JS_STRING"; + case FieldOptions_JSType.JS_NUMBER: + return "JS_NUMBER"; + default: + return "UNKNOWN"; + } +} + +export interface OneofOptions { + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface EnumOptions { + /** + * Set this option to true to allow mapping different tag names to the same + * value. + */ + allowAlias: boolean; + /** + * Is this enum deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the enum, or it will be completely ignored; in the very least, this + * is a formalization for deprecating enums. + */ + deprecated: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface EnumValueOptions { + /** + * Is this enum value deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the enum value, or it will be completely ignored; in the very least, + * this is a formalization for deprecating enum values. + */ + deprecated: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface ServiceOptions { + /** + * Is this service deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the service, or it will be completely ignored; in the very least, + * this is a formalization for deprecating services. + */ + deprecated: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface MethodOptions { + /** + * Is this method deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the method, or it will be completely ignored; in the very least, + * this is a formalization for deprecating methods. + */ + deprecated: boolean; + idempotencyLevel: MethodOptions_IdempotencyLevel; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +/** + * Is this method side-effect-free (or safe in HTTP parlance), or idempotent, + * or neither? HTTP based RPC implementation may choose GET verb for safe + * methods, and PUT verb for idempotent methods instead of the default POST. + */ +export enum MethodOptions_IdempotencyLevel { + IDEMPOTENCY_UNKNOWN = 0, + /** NO_SIDE_EFFECTS - implies idempotent */ + NO_SIDE_EFFECTS = 1, + /** IDEMPOTENT - idempotent, but may have side effects */ + IDEMPOTENT = 2, + UNRECOGNIZED = -1, +} + +export function methodOptions_IdempotencyLevelFromJSON( + object: any +): MethodOptions_IdempotencyLevel { + switch (object) { + case 0: + case "IDEMPOTENCY_UNKNOWN": + return MethodOptions_IdempotencyLevel.IDEMPOTENCY_UNKNOWN; + case 1: + case "NO_SIDE_EFFECTS": + return MethodOptions_IdempotencyLevel.NO_SIDE_EFFECTS; + case 2: + case "IDEMPOTENT": + return MethodOptions_IdempotencyLevel.IDEMPOTENT; + case -1: + case "UNRECOGNIZED": + default: + return MethodOptions_IdempotencyLevel.UNRECOGNIZED; + } +} + +export function methodOptions_IdempotencyLevelToJSON( + object: MethodOptions_IdempotencyLevel +): string { + switch (object) { + case MethodOptions_IdempotencyLevel.IDEMPOTENCY_UNKNOWN: + return "IDEMPOTENCY_UNKNOWN"; + case MethodOptions_IdempotencyLevel.NO_SIDE_EFFECTS: + return "NO_SIDE_EFFECTS"; + case MethodOptions_IdempotencyLevel.IDEMPOTENT: + return "IDEMPOTENT"; + default: + return "UNKNOWN"; + } +} + +/** + * A message representing a option the parser does not recognize. This only + * appears in options protos created by the compiler::Parser class. + * DescriptorPool resolves these when building Descriptor objects. Therefore, + * options protos in descriptor objects (e.g. returned by Descriptor::options(), + * or produced by Descriptor::CopyTo()) will never have UninterpretedOptions + * in them. + */ +export interface UninterpretedOption { + name: UninterpretedOption_NamePart[]; + /** + * The value of the uninterpreted option, in whatever type the tokenizer + * identified it as during parsing. Exactly one of these should be set. + */ + identifierValue: string; + positiveIntValue: number; + negativeIntValue: number; + doubleValue: number; + stringValue: Uint8Array; + aggregateValue: string; +} + +/** + * The name of the uninterpreted option. Each string represents a segment in + * a dot-separated name. is_extension is true iff a segment represents an + * extension (denoted with parentheses in options specs in .proto files). + * E.g.,{ ["foo", false], ["bar.baz", true], ["qux", false] } represents + * "foo.(bar.baz).qux". + */ +export interface UninterpretedOption_NamePart { + namePart: string; + isExtension: boolean; +} + +/** + * Encapsulates information about the original source file from which a + * FileDescriptorProto was generated. + */ +export interface SourceCodeInfo { + /** + * A Location identifies a piece of source code in a .proto file which + * corresponds to a particular definition. This information is intended + * to be useful to IDEs, code indexers, documentation generators, and similar + * tools. + * + * For example, say we have a file like: + * message Foo { + * optional string foo = 1; + * } + * Let's look at just the field definition: + * optional string foo = 1; + * ^ ^^ ^^ ^ ^^^ + * a bc de f ghi + * We have the following locations: + * span path represents + * [a,i) [ 4, 0, 2, 0 ] The whole field definition. + * [a,b) [ 4, 0, 2, 0, 4 ] The label (optional). + * [c,d) [ 4, 0, 2, 0, 5 ] The type (string). + * [e,f) [ 4, 0, 2, 0, 1 ] The name (foo). + * [g,h) [ 4, 0, 2, 0, 3 ] The number (1). + * + * Notes: + * - A location may refer to a repeated field itself (i.e. not to any + * particular index within it). This is used whenever a set of elements are + * logically enclosed in a single code segment. For example, an entire + * extend block (possibly containing multiple extension definitions) will + * have an outer location whose path refers to the "extensions" repeated + * field without an index. + * - Multiple locations may have the same path. This happens when a single + * logical declaration is spread out across multiple places. The most + * obvious example is the "extend" block again -- there may be multiple + * extend blocks in the same scope, each of which will have the same path. + * - A location's span is not always a subset of its parent's span. For + * example, the "extendee" of an extension declaration appears at the + * beginning of the "extend" block and is shared by all extensions within + * the block. + * - Just because a location's span is a subset of some other location's span + * does not mean that it is a descendant. For example, a "group" defines + * both a type and a field in a single declaration. Thus, the locations + * corresponding to the type and field and their components will overlap. + * - Code which tries to interpret locations should probably be designed to + * ignore those that it doesn't understand, as more types of locations could + * be recorded in the future. + */ + location: SourceCodeInfo_Location[]; +} + +export interface SourceCodeInfo_Location { + /** + * Identifies which part of the FileDescriptorProto was defined at this + * location. + * + * Each element is a field number or an index. They form a path from + * the root FileDescriptorProto to the place where the definition. For + * example, this path: + * [ 4, 3, 2, 7, 1 ] + * refers to: + * file.message_type(3) // 4, 3 + * .field(7) // 2, 7 + * .name() // 1 + * This is because FileDescriptorProto.message_type has field number 4: + * repeated DescriptorProto message_type = 4; + * and DescriptorProto.field has field number 2: + * repeated FieldDescriptorProto field = 2; + * and FieldDescriptorProto.name has field number 1: + * optional string name = 1; + * + * Thus, the above path gives the location of a field name. If we removed + * the last element: + * [ 4, 3, 2, 7 ] + * this path refers to the whole field declaration (from the beginning + * of the label to the terminating semicolon). + */ + path: number[]; + /** + * Always has exactly three or four elements: start line, start column, + * end line (optional, otherwise assumed same as start line), end column. + * These are packed into a single field for efficiency. Note that line + * and column numbers are zero-based -- typically you will want to add + * 1 to each before displaying to a user. + */ + span: number[]; + /** + * If this SourceCodeInfo represents a complete declaration, these are any + * comments appearing before and after the declaration which appear to be + * attached to the declaration. + * + * A series of line comments appearing on consecutive lines, with no other + * tokens appearing on those lines, will be treated as a single comment. + * + * leading_detached_comments will keep paragraphs of comments that appear + * before (but not connected to) the current element. Each paragraph, + * separated by empty lines, will be one comment element in the repeated + * field. + * + * Only the comment content is provided; comment markers (e.g. //) are + * stripped out. For block comments, leading whitespace and an asterisk + * will be stripped from the beginning of each line other than the first. + * Newlines are included in the output. + * + * Examples: + * + * optional int32 foo = 1; // Comment attached to foo. + * // Comment attached to bar. + * optional int32 bar = 2; + * + * optional string baz = 3; + * // Comment attached to baz. + * // Another line attached to baz. + * + * // Comment attached to qux. + * // + * // Another line attached to qux. + * optional double qux = 4; + * + * // Detached comment for corge. This is not leading or trailing comments + * // to qux or corge because there are blank lines separating it from + * // both. + * + * // Detached comment for corge paragraph 2. + * + * optional string corge = 5; + * /* Block comment attached + * * to corge. Leading asterisks + * * will be removed. * / + * /* Block comment attached to + * * grault. * / + * optional int32 grault = 6; + * + * // ignored detached comments. + */ + leadingComments: string; + trailingComments: string; + leadingDetachedComments: string[]; +} + +/** + * Describes the relationship between generated code and its original source + * file. A GeneratedCodeInfo message is associated with only one generated + * source file, but may contain references to different source .proto files. + */ +export interface GeneratedCodeInfo { + /** + * An Annotation connects some span of text in generated code to an element + * of its generating .proto file. + */ + annotation: GeneratedCodeInfo_Annotation[]; +} + +export interface GeneratedCodeInfo_Annotation { + /** + * Identifies the element in the original source .proto file. This field + * is formatted the same as SourceCodeInfo.Location.path. + */ + path: number[]; + /** Identifies the filesystem path to the original source .proto. */ + sourceFile: string; + /** + * Identifies the starting offset in bytes in the generated code + * that relates to the identified object. + */ + begin: number; + /** + * Identifies the ending offset in bytes in the generated code that + * relates to the identified offset. The end offset should be one past + * the last relevant byte (so the length of the text = end - begin). + */ + end: number; +} + +const baseFileDescriptorSet: object = {}; + +export const FileDescriptorSet = { + encode(message: FileDescriptorSet, writer: Writer = Writer.create()): Writer { + for (const v of message.file) { + FileDescriptorProto.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FileDescriptorSet { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFileDescriptorSet } as FileDescriptorSet; + message.file = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.file.push( + FileDescriptorProto.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FileDescriptorSet { + const message = { ...baseFileDescriptorSet } as FileDescriptorSet; + message.file = []; + if (object.file !== undefined && object.file !== null) { + for (const e of object.file) { + message.file.push(FileDescriptorProto.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: FileDescriptorSet): unknown { + const obj: any = {}; + if (message.file) { + obj.file = message.file.map((e) => + e ? FileDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.file = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): FileDescriptorSet { + const message = { ...baseFileDescriptorSet } as FileDescriptorSet; + message.file = []; + if (object.file !== undefined && object.file !== null) { + for (const e of object.file) { + message.file.push(FileDescriptorProto.fromPartial(e)); + } + } + return message; + }, +}; + +const baseFileDescriptorProto: object = { + name: "", + package: "", + dependency: "", + publicDependency: 0, + weakDependency: 0, + syntax: "", +}; + +export const FileDescriptorProto = { + encode( + message: FileDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.package !== "") { + writer.uint32(18).string(message.package); + } + for (const v of message.dependency) { + writer.uint32(26).string(v!); + } + writer.uint32(82).fork(); + for (const v of message.publicDependency) { + writer.int32(v); + } + writer.ldelim(); + writer.uint32(90).fork(); + for (const v of message.weakDependency) { + writer.int32(v); + } + writer.ldelim(); + for (const v of message.messageType) { + DescriptorProto.encode(v!, writer.uint32(34).fork()).ldelim(); + } + for (const v of message.enumType) { + EnumDescriptorProto.encode(v!, writer.uint32(42).fork()).ldelim(); + } + for (const v of message.service) { + ServiceDescriptorProto.encode(v!, writer.uint32(50).fork()).ldelim(); + } + for (const v of message.extension) { + FieldDescriptorProto.encode(v!, writer.uint32(58).fork()).ldelim(); + } + if (message.options !== undefined) { + FileOptions.encode(message.options, writer.uint32(66).fork()).ldelim(); + } + if (message.sourceCodeInfo !== undefined) { + SourceCodeInfo.encode( + message.sourceCodeInfo, + writer.uint32(74).fork() + ).ldelim(); + } + if (message.syntax !== "") { + writer.uint32(98).string(message.syntax); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FileDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFileDescriptorProto } as FileDescriptorProto; + message.dependency = []; + message.publicDependency = []; + message.weakDependency = []; + message.messageType = []; + message.enumType = []; + message.service = []; + message.extension = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.package = reader.string(); + break; + case 3: + message.dependency.push(reader.string()); + break; + case 10: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.publicDependency.push(reader.int32()); + } + } else { + message.publicDependency.push(reader.int32()); + } + break; + case 11: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.weakDependency.push(reader.int32()); + } + } else { + message.weakDependency.push(reader.int32()); + } + break; + case 4: + message.messageType.push( + DescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 5: + message.enumType.push( + EnumDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 6: + message.service.push( + ServiceDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 7: + message.extension.push( + FieldDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 8: + message.options = FileOptions.decode(reader, reader.uint32()); + break; + case 9: + message.sourceCodeInfo = SourceCodeInfo.decode( + reader, + reader.uint32() + ); + break; + case 12: + message.syntax = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FileDescriptorProto { + const message = { ...baseFileDescriptorProto } as FileDescriptorProto; + message.dependency = []; + message.publicDependency = []; + message.weakDependency = []; + message.messageType = []; + message.enumType = []; + message.service = []; + message.extension = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.package !== undefined && object.package !== null) { + message.package = String(object.package); + } else { + message.package = ""; + } + if (object.dependency !== undefined && object.dependency !== null) { + for (const e of object.dependency) { + message.dependency.push(String(e)); + } + } + if ( + object.publicDependency !== undefined && + object.publicDependency !== null + ) { + for (const e of object.publicDependency) { + message.publicDependency.push(Number(e)); + } + } + if (object.weakDependency !== undefined && object.weakDependency !== null) { + for (const e of object.weakDependency) { + message.weakDependency.push(Number(e)); + } + } + if (object.messageType !== undefined && object.messageType !== null) { + for (const e of object.messageType) { + message.messageType.push(DescriptorProto.fromJSON(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromJSON(e)); + } + } + if (object.service !== undefined && object.service !== null) { + for (const e of object.service) { + message.service.push(ServiceDescriptorProto.fromJSON(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = FileOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.sourceCodeInfo !== undefined && object.sourceCodeInfo !== null) { + message.sourceCodeInfo = SourceCodeInfo.fromJSON(object.sourceCodeInfo); + } else { + message.sourceCodeInfo = undefined; + } + if (object.syntax !== undefined && object.syntax !== null) { + message.syntax = String(object.syntax); + } else { + message.syntax = ""; + } + return message; + }, + + toJSON(message: FileDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.package !== undefined && (obj.package = message.package); + if (message.dependency) { + obj.dependency = message.dependency.map((e) => e); + } else { + obj.dependency = []; + } + if (message.publicDependency) { + obj.publicDependency = message.publicDependency.map((e) => e); + } else { + obj.publicDependency = []; + } + if (message.weakDependency) { + obj.weakDependency = message.weakDependency.map((e) => e); + } else { + obj.weakDependency = []; + } + if (message.messageType) { + obj.messageType = message.messageType.map((e) => + e ? DescriptorProto.toJSON(e) : undefined + ); + } else { + obj.messageType = []; + } + if (message.enumType) { + obj.enumType = message.enumType.map((e) => + e ? EnumDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.enumType = []; + } + if (message.service) { + obj.service = message.service.map((e) => + e ? ServiceDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.service = []; + } + if (message.extension) { + obj.extension = message.extension.map((e) => + e ? FieldDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.extension = []; + } + message.options !== undefined && + (obj.options = message.options + ? FileOptions.toJSON(message.options) + : undefined); + message.sourceCodeInfo !== undefined && + (obj.sourceCodeInfo = message.sourceCodeInfo + ? SourceCodeInfo.toJSON(message.sourceCodeInfo) + : undefined); + message.syntax !== undefined && (obj.syntax = message.syntax); + return obj; + }, + + fromPartial(object: DeepPartial): FileDescriptorProto { + const message = { ...baseFileDescriptorProto } as FileDescriptorProto; + message.dependency = []; + message.publicDependency = []; + message.weakDependency = []; + message.messageType = []; + message.enumType = []; + message.service = []; + message.extension = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.package !== undefined && object.package !== null) { + message.package = object.package; + } else { + message.package = ""; + } + if (object.dependency !== undefined && object.dependency !== null) { + for (const e of object.dependency) { + message.dependency.push(e); + } + } + if ( + object.publicDependency !== undefined && + object.publicDependency !== null + ) { + for (const e of object.publicDependency) { + message.publicDependency.push(e); + } + } + if (object.weakDependency !== undefined && object.weakDependency !== null) { + for (const e of object.weakDependency) { + message.weakDependency.push(e); + } + } + if (object.messageType !== undefined && object.messageType !== null) { + for (const e of object.messageType) { + message.messageType.push(DescriptorProto.fromPartial(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromPartial(e)); + } + } + if (object.service !== undefined && object.service !== null) { + for (const e of object.service) { + message.service.push(ServiceDescriptorProto.fromPartial(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = FileOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.sourceCodeInfo !== undefined && object.sourceCodeInfo !== null) { + message.sourceCodeInfo = SourceCodeInfo.fromPartial( + object.sourceCodeInfo + ); + } else { + message.sourceCodeInfo = undefined; + } + if (object.syntax !== undefined && object.syntax !== null) { + message.syntax = object.syntax; + } else { + message.syntax = ""; + } + return message; + }, +}; + +const baseDescriptorProto: object = { name: "", reservedName: "" }; + +export const DescriptorProto = { + encode(message: DescriptorProto, writer: Writer = Writer.create()): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + for (const v of message.field) { + FieldDescriptorProto.encode(v!, writer.uint32(18).fork()).ldelim(); + } + for (const v of message.extension) { + FieldDescriptorProto.encode(v!, writer.uint32(50).fork()).ldelim(); + } + for (const v of message.nestedType) { + DescriptorProto.encode(v!, writer.uint32(26).fork()).ldelim(); + } + for (const v of message.enumType) { + EnumDescriptorProto.encode(v!, writer.uint32(34).fork()).ldelim(); + } + for (const v of message.extensionRange) { + DescriptorProto_ExtensionRange.encode( + v!, + writer.uint32(42).fork() + ).ldelim(); + } + for (const v of message.oneofDecl) { + OneofDescriptorProto.encode(v!, writer.uint32(66).fork()).ldelim(); + } + if (message.options !== undefined) { + MessageOptions.encode(message.options, writer.uint32(58).fork()).ldelim(); + } + for (const v of message.reservedRange) { + DescriptorProto_ReservedRange.encode( + v!, + writer.uint32(74).fork() + ).ldelim(); + } + for (const v of message.reservedName) { + writer.uint32(82).string(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): DescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseDescriptorProto } as DescriptorProto; + message.field = []; + message.extension = []; + message.nestedType = []; + message.enumType = []; + message.extensionRange = []; + message.oneofDecl = []; + message.reservedRange = []; + message.reservedName = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.field.push( + FieldDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 6: + message.extension.push( + FieldDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 3: + message.nestedType.push( + DescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 4: + message.enumType.push( + EnumDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 5: + message.extensionRange.push( + DescriptorProto_ExtensionRange.decode(reader, reader.uint32()) + ); + break; + case 8: + message.oneofDecl.push( + OneofDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 7: + message.options = MessageOptions.decode(reader, reader.uint32()); + break; + case 9: + message.reservedRange.push( + DescriptorProto_ReservedRange.decode(reader, reader.uint32()) + ); + break; + case 10: + message.reservedName.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DescriptorProto { + const message = { ...baseDescriptorProto } as DescriptorProto; + message.field = []; + message.extension = []; + message.nestedType = []; + message.enumType = []; + message.extensionRange = []; + message.oneofDecl = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.field !== undefined && object.field !== null) { + for (const e of object.field) { + message.field.push(FieldDescriptorProto.fromJSON(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromJSON(e)); + } + } + if (object.nestedType !== undefined && object.nestedType !== null) { + for (const e of object.nestedType) { + message.nestedType.push(DescriptorProto.fromJSON(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromJSON(e)); + } + } + if (object.extensionRange !== undefined && object.extensionRange !== null) { + for (const e of object.extensionRange) { + message.extensionRange.push(DescriptorProto_ExtensionRange.fromJSON(e)); + } + } + if (object.oneofDecl !== undefined && object.oneofDecl !== null) { + for (const e of object.oneofDecl) { + message.oneofDecl.push(OneofDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = MessageOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push(DescriptorProto_ReservedRange.fromJSON(e)); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(String(e)); + } + } + return message; + }, + + toJSON(message: DescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + if (message.field) { + obj.field = message.field.map((e) => + e ? FieldDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.field = []; + } + if (message.extension) { + obj.extension = message.extension.map((e) => + e ? FieldDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.extension = []; + } + if (message.nestedType) { + obj.nestedType = message.nestedType.map((e) => + e ? DescriptorProto.toJSON(e) : undefined + ); + } else { + obj.nestedType = []; + } + if (message.enumType) { + obj.enumType = message.enumType.map((e) => + e ? EnumDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.enumType = []; + } + if (message.extensionRange) { + obj.extensionRange = message.extensionRange.map((e) => + e ? DescriptorProto_ExtensionRange.toJSON(e) : undefined + ); + } else { + obj.extensionRange = []; + } + if (message.oneofDecl) { + obj.oneofDecl = message.oneofDecl.map((e) => + e ? OneofDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.oneofDecl = []; + } + message.options !== undefined && + (obj.options = message.options + ? MessageOptions.toJSON(message.options) + : undefined); + if (message.reservedRange) { + obj.reservedRange = message.reservedRange.map((e) => + e ? DescriptorProto_ReservedRange.toJSON(e) : undefined + ); + } else { + obj.reservedRange = []; + } + if (message.reservedName) { + obj.reservedName = message.reservedName.map((e) => e); + } else { + obj.reservedName = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): DescriptorProto { + const message = { ...baseDescriptorProto } as DescriptorProto; + message.field = []; + message.extension = []; + message.nestedType = []; + message.enumType = []; + message.extensionRange = []; + message.oneofDecl = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.field !== undefined && object.field !== null) { + for (const e of object.field) { + message.field.push(FieldDescriptorProto.fromPartial(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromPartial(e)); + } + } + if (object.nestedType !== undefined && object.nestedType !== null) { + for (const e of object.nestedType) { + message.nestedType.push(DescriptorProto.fromPartial(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromPartial(e)); + } + } + if (object.extensionRange !== undefined && object.extensionRange !== null) { + for (const e of object.extensionRange) { + message.extensionRange.push( + DescriptorProto_ExtensionRange.fromPartial(e) + ); + } + } + if (object.oneofDecl !== undefined && object.oneofDecl !== null) { + for (const e of object.oneofDecl) { + message.oneofDecl.push(OneofDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = MessageOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push( + DescriptorProto_ReservedRange.fromPartial(e) + ); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(e); + } + } + return message; + }, +}; + +const baseDescriptorProto_ExtensionRange: object = { start: 0, end: 0 }; + +export const DescriptorProto_ExtensionRange = { + encode( + message: DescriptorProto_ExtensionRange, + writer: Writer = Writer.create() + ): Writer { + if (message.start !== 0) { + writer.uint32(8).int32(message.start); + } + if (message.end !== 0) { + writer.uint32(16).int32(message.end); + } + if (message.options !== undefined) { + ExtensionRangeOptions.encode( + message.options, + writer.uint32(26).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): DescriptorProto_ExtensionRange { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseDescriptorProto_ExtensionRange, + } as DescriptorProto_ExtensionRange; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.start = reader.int32(); + break; + case 2: + message.end = reader.int32(); + break; + case 3: + message.options = ExtensionRangeOptions.decode( + reader, + reader.uint32() + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DescriptorProto_ExtensionRange { + const message = { + ...baseDescriptorProto_ExtensionRange, + } as DescriptorProto_ExtensionRange; + if (object.start !== undefined && object.start !== null) { + message.start = Number(object.start); + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = ExtensionRangeOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: DescriptorProto_ExtensionRange): unknown { + const obj: any = {}; + message.start !== undefined && (obj.start = message.start); + message.end !== undefined && (obj.end = message.end); + message.options !== undefined && + (obj.options = message.options + ? ExtensionRangeOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): DescriptorProto_ExtensionRange { + const message = { + ...baseDescriptorProto_ExtensionRange, + } as DescriptorProto_ExtensionRange; + if (object.start !== undefined && object.start !== null) { + message.start = object.start; + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = ExtensionRangeOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseDescriptorProto_ReservedRange: object = { start: 0, end: 0 }; + +export const DescriptorProto_ReservedRange = { + encode( + message: DescriptorProto_ReservedRange, + writer: Writer = Writer.create() + ): Writer { + if (message.start !== 0) { + writer.uint32(8).int32(message.start); + } + if (message.end !== 0) { + writer.uint32(16).int32(message.end); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): DescriptorProto_ReservedRange { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseDescriptorProto_ReservedRange, + } as DescriptorProto_ReservedRange; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.start = reader.int32(); + break; + case 2: + message.end = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DescriptorProto_ReservedRange { + const message = { + ...baseDescriptorProto_ReservedRange, + } as DescriptorProto_ReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = Number(object.start); + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + return message; + }, + + toJSON(message: DescriptorProto_ReservedRange): unknown { + const obj: any = {}; + message.start !== undefined && (obj.start = message.start); + message.end !== undefined && (obj.end = message.end); + return obj; + }, + + fromPartial( + object: DeepPartial + ): DescriptorProto_ReservedRange { + const message = { + ...baseDescriptorProto_ReservedRange, + } as DescriptorProto_ReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = object.start; + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + return message; + }, +}; + +const baseExtensionRangeOptions: object = {}; + +export const ExtensionRangeOptions = { + encode( + message: ExtensionRangeOptions, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ExtensionRangeOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseExtensionRangeOptions } as ExtensionRangeOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ExtensionRangeOptions { + const message = { ...baseExtensionRangeOptions } as ExtensionRangeOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: ExtensionRangeOptions): unknown { + const obj: any = {}; + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial( + object: DeepPartial + ): ExtensionRangeOptions { + const message = { ...baseExtensionRangeOptions } as ExtensionRangeOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseFieldDescriptorProto: object = { + name: "", + number: 0, + label: 1, + type: 1, + typeName: "", + extendee: "", + defaultValue: "", + oneofIndex: 0, + jsonName: "", + proto3Optional: false, +}; + +export const FieldDescriptorProto = { + encode( + message: FieldDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.number !== 0) { + writer.uint32(24).int32(message.number); + } + if (message.label !== 1) { + writer.uint32(32).int32(message.label); + } + if (message.type !== 1) { + writer.uint32(40).int32(message.type); + } + if (message.typeName !== "") { + writer.uint32(50).string(message.typeName); + } + if (message.extendee !== "") { + writer.uint32(18).string(message.extendee); + } + if (message.defaultValue !== "") { + writer.uint32(58).string(message.defaultValue); + } + if (message.oneofIndex !== 0) { + writer.uint32(72).int32(message.oneofIndex); + } + if (message.jsonName !== "") { + writer.uint32(82).string(message.jsonName); + } + if (message.options !== undefined) { + FieldOptions.encode(message.options, writer.uint32(66).fork()).ldelim(); + } + if (message.proto3Optional === true) { + writer.uint32(136).bool(message.proto3Optional); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FieldDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFieldDescriptorProto } as FieldDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 3: + message.number = reader.int32(); + break; + case 4: + message.label = reader.int32() as any; + break; + case 5: + message.type = reader.int32() as any; + break; + case 6: + message.typeName = reader.string(); + break; + case 2: + message.extendee = reader.string(); + break; + case 7: + message.defaultValue = reader.string(); + break; + case 9: + message.oneofIndex = reader.int32(); + break; + case 10: + message.jsonName = reader.string(); + break; + case 8: + message.options = FieldOptions.decode(reader, reader.uint32()); + break; + case 17: + message.proto3Optional = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FieldDescriptorProto { + const message = { ...baseFieldDescriptorProto } as FieldDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = Number(object.number); + } else { + message.number = 0; + } + if (object.label !== undefined && object.label !== null) { + message.label = fieldDescriptorProto_LabelFromJSON(object.label); + } else { + message.label = 1; + } + if (object.type !== undefined && object.type !== null) { + message.type = fieldDescriptorProto_TypeFromJSON(object.type); + } else { + message.type = 1; + } + if (object.typeName !== undefined && object.typeName !== null) { + message.typeName = String(object.typeName); + } else { + message.typeName = ""; + } + if (object.extendee !== undefined && object.extendee !== null) { + message.extendee = String(object.extendee); + } else { + message.extendee = ""; + } + if (object.defaultValue !== undefined && object.defaultValue !== null) { + message.defaultValue = String(object.defaultValue); + } else { + message.defaultValue = ""; + } + if (object.oneofIndex !== undefined && object.oneofIndex !== null) { + message.oneofIndex = Number(object.oneofIndex); + } else { + message.oneofIndex = 0; + } + if (object.jsonName !== undefined && object.jsonName !== null) { + message.jsonName = String(object.jsonName); + } else { + message.jsonName = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = FieldOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.proto3Optional !== undefined && object.proto3Optional !== null) { + message.proto3Optional = Boolean(object.proto3Optional); + } else { + message.proto3Optional = false; + } + return message; + }, + + toJSON(message: FieldDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.number !== undefined && (obj.number = message.number); + message.label !== undefined && + (obj.label = fieldDescriptorProto_LabelToJSON(message.label)); + message.type !== undefined && + (obj.type = fieldDescriptorProto_TypeToJSON(message.type)); + message.typeName !== undefined && (obj.typeName = message.typeName); + message.extendee !== undefined && (obj.extendee = message.extendee); + message.defaultValue !== undefined && + (obj.defaultValue = message.defaultValue); + message.oneofIndex !== undefined && (obj.oneofIndex = message.oneofIndex); + message.jsonName !== undefined && (obj.jsonName = message.jsonName); + message.options !== undefined && + (obj.options = message.options + ? FieldOptions.toJSON(message.options) + : undefined); + message.proto3Optional !== undefined && + (obj.proto3Optional = message.proto3Optional); + return obj; + }, + + fromPartial(object: DeepPartial): FieldDescriptorProto { + const message = { ...baseFieldDescriptorProto } as FieldDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = object.number; + } else { + message.number = 0; + } + if (object.label !== undefined && object.label !== null) { + message.label = object.label; + } else { + message.label = 1; + } + if (object.type !== undefined && object.type !== null) { + message.type = object.type; + } else { + message.type = 1; + } + if (object.typeName !== undefined && object.typeName !== null) { + message.typeName = object.typeName; + } else { + message.typeName = ""; + } + if (object.extendee !== undefined && object.extendee !== null) { + message.extendee = object.extendee; + } else { + message.extendee = ""; + } + if (object.defaultValue !== undefined && object.defaultValue !== null) { + message.defaultValue = object.defaultValue; + } else { + message.defaultValue = ""; + } + if (object.oneofIndex !== undefined && object.oneofIndex !== null) { + message.oneofIndex = object.oneofIndex; + } else { + message.oneofIndex = 0; + } + if (object.jsonName !== undefined && object.jsonName !== null) { + message.jsonName = object.jsonName; + } else { + message.jsonName = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = FieldOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.proto3Optional !== undefined && object.proto3Optional !== null) { + message.proto3Optional = object.proto3Optional; + } else { + message.proto3Optional = false; + } + return message; + }, +}; + +const baseOneofDescriptorProto: object = { name: "" }; + +export const OneofDescriptorProto = { + encode( + message: OneofDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.options !== undefined) { + OneofOptions.encode(message.options, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): OneofDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseOneofDescriptorProto } as OneofDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.options = OneofOptions.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): OneofDescriptorProto { + const message = { ...baseOneofDescriptorProto } as OneofDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = OneofOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: OneofDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.options !== undefined && + (obj.options = message.options + ? OneofOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): OneofDescriptorProto { + const message = { ...baseOneofDescriptorProto } as OneofDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = OneofOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseEnumDescriptorProto: object = { name: "", reservedName: "" }; + +export const EnumDescriptorProto = { + encode( + message: EnumDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + for (const v of message.value) { + EnumValueDescriptorProto.encode(v!, writer.uint32(18).fork()).ldelim(); + } + if (message.options !== undefined) { + EnumOptions.encode(message.options, writer.uint32(26).fork()).ldelim(); + } + for (const v of message.reservedRange) { + EnumDescriptorProto_EnumReservedRange.encode( + v!, + writer.uint32(34).fork() + ).ldelim(); + } + for (const v of message.reservedName) { + writer.uint32(42).string(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): EnumDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseEnumDescriptorProto } as EnumDescriptorProto; + message.value = []; + message.reservedRange = []; + message.reservedName = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.value.push( + EnumValueDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 3: + message.options = EnumOptions.decode(reader, reader.uint32()); + break; + case 4: + message.reservedRange.push( + EnumDescriptorProto_EnumReservedRange.decode( + reader, + reader.uint32() + ) + ); + break; + case 5: + message.reservedName.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumDescriptorProto { + const message = { ...baseEnumDescriptorProto } as EnumDescriptorProto; + message.value = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.value !== undefined && object.value !== null) { + for (const e of object.value) { + message.value.push(EnumValueDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push( + EnumDescriptorProto_EnumReservedRange.fromJSON(e) + ); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(String(e)); + } + } + return message; + }, + + toJSON(message: EnumDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + if (message.value) { + obj.value = message.value.map((e) => + e ? EnumValueDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.value = []; + } + message.options !== undefined && + (obj.options = message.options + ? EnumOptions.toJSON(message.options) + : undefined); + if (message.reservedRange) { + obj.reservedRange = message.reservedRange.map((e) => + e ? EnumDescriptorProto_EnumReservedRange.toJSON(e) : undefined + ); + } else { + obj.reservedRange = []; + } + if (message.reservedName) { + obj.reservedName = message.reservedName.map((e) => e); + } else { + obj.reservedName = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): EnumDescriptorProto { + const message = { ...baseEnumDescriptorProto } as EnumDescriptorProto; + message.value = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.value !== undefined && object.value !== null) { + for (const e of object.value) { + message.value.push(EnumValueDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push( + EnumDescriptorProto_EnumReservedRange.fromPartial(e) + ); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(e); + } + } + return message; + }, +}; + +const baseEnumDescriptorProto_EnumReservedRange: object = { start: 0, end: 0 }; + +export const EnumDescriptorProto_EnumReservedRange = { + encode( + message: EnumDescriptorProto_EnumReservedRange, + writer: Writer = Writer.create() + ): Writer { + if (message.start !== 0) { + writer.uint32(8).int32(message.start); + } + if (message.end !== 0) { + writer.uint32(16).int32(message.end); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): EnumDescriptorProto_EnumReservedRange { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseEnumDescriptorProto_EnumReservedRange, + } as EnumDescriptorProto_EnumReservedRange; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.start = reader.int32(); + break; + case 2: + message.end = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumDescriptorProto_EnumReservedRange { + const message = { + ...baseEnumDescriptorProto_EnumReservedRange, + } as EnumDescriptorProto_EnumReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = Number(object.start); + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + return message; + }, + + toJSON(message: EnumDescriptorProto_EnumReservedRange): unknown { + const obj: any = {}; + message.start !== undefined && (obj.start = message.start); + message.end !== undefined && (obj.end = message.end); + return obj; + }, + + fromPartial( + object: DeepPartial + ): EnumDescriptorProto_EnumReservedRange { + const message = { + ...baseEnumDescriptorProto_EnumReservedRange, + } as EnumDescriptorProto_EnumReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = object.start; + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + return message; + }, +}; + +const baseEnumValueDescriptorProto: object = { name: "", number: 0 }; + +export const EnumValueDescriptorProto = { + encode( + message: EnumValueDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.number !== 0) { + writer.uint32(16).int32(message.number); + } + if (message.options !== undefined) { + EnumValueOptions.encode( + message.options, + writer.uint32(26).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): EnumValueDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseEnumValueDescriptorProto, + } as EnumValueDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.number = reader.int32(); + break; + case 3: + message.options = EnumValueOptions.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumValueDescriptorProto { + const message = { + ...baseEnumValueDescriptorProto, + } as EnumValueDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = Number(object.number); + } else { + message.number = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumValueOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: EnumValueDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.number !== undefined && (obj.number = message.number); + message.options !== undefined && + (obj.options = message.options + ? EnumValueOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): EnumValueDescriptorProto { + const message = { + ...baseEnumValueDescriptorProto, + } as EnumValueDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = object.number; + } else { + message.number = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumValueOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseServiceDescriptorProto: object = { name: "" }; + +export const ServiceDescriptorProto = { + encode( + message: ServiceDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + for (const v of message.method) { + MethodDescriptorProto.encode(v!, writer.uint32(18).fork()).ldelim(); + } + if (message.options !== undefined) { + ServiceOptions.encode(message.options, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ServiceDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseServiceDescriptorProto } as ServiceDescriptorProto; + message.method = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.method.push( + MethodDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 3: + message.options = ServiceOptions.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ServiceDescriptorProto { + const message = { ...baseServiceDescriptorProto } as ServiceDescriptorProto; + message.method = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.method !== undefined && object.method !== null) { + for (const e of object.method) { + message.method.push(MethodDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = ServiceOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: ServiceDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + if (message.method) { + obj.method = message.method.map((e) => + e ? MethodDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.method = []; + } + message.options !== undefined && + (obj.options = message.options + ? ServiceOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): ServiceDescriptorProto { + const message = { ...baseServiceDescriptorProto } as ServiceDescriptorProto; + message.method = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.method !== undefined && object.method !== null) { + for (const e of object.method) { + message.method.push(MethodDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = ServiceOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseMethodDescriptorProto: object = { + name: "", + inputType: "", + outputType: "", + clientStreaming: false, + serverStreaming: false, +}; + +export const MethodDescriptorProto = { + encode( + message: MethodDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.inputType !== "") { + writer.uint32(18).string(message.inputType); + } + if (message.outputType !== "") { + writer.uint32(26).string(message.outputType); + } + if (message.options !== undefined) { + MethodOptions.encode(message.options, writer.uint32(34).fork()).ldelim(); + } + if (message.clientStreaming === true) { + writer.uint32(40).bool(message.clientStreaming); + } + if (message.serverStreaming === true) { + writer.uint32(48).bool(message.serverStreaming); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MethodDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMethodDescriptorProto } as MethodDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.inputType = reader.string(); + break; + case 3: + message.outputType = reader.string(); + break; + case 4: + message.options = MethodOptions.decode(reader, reader.uint32()); + break; + case 5: + message.clientStreaming = reader.bool(); + break; + case 6: + message.serverStreaming = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MethodDescriptorProto { + const message = { ...baseMethodDescriptorProto } as MethodDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.inputType !== undefined && object.inputType !== null) { + message.inputType = String(object.inputType); + } else { + message.inputType = ""; + } + if (object.outputType !== undefined && object.outputType !== null) { + message.outputType = String(object.outputType); + } else { + message.outputType = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = MethodOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if ( + object.clientStreaming !== undefined && + object.clientStreaming !== null + ) { + message.clientStreaming = Boolean(object.clientStreaming); + } else { + message.clientStreaming = false; + } + if ( + object.serverStreaming !== undefined && + object.serverStreaming !== null + ) { + message.serverStreaming = Boolean(object.serverStreaming); + } else { + message.serverStreaming = false; + } + return message; + }, + + toJSON(message: MethodDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.inputType !== undefined && (obj.inputType = message.inputType); + message.outputType !== undefined && (obj.outputType = message.outputType); + message.options !== undefined && + (obj.options = message.options + ? MethodOptions.toJSON(message.options) + : undefined); + message.clientStreaming !== undefined && + (obj.clientStreaming = message.clientStreaming); + message.serverStreaming !== undefined && + (obj.serverStreaming = message.serverStreaming); + return obj; + }, + + fromPartial( + object: DeepPartial + ): MethodDescriptorProto { + const message = { ...baseMethodDescriptorProto } as MethodDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.inputType !== undefined && object.inputType !== null) { + message.inputType = object.inputType; + } else { + message.inputType = ""; + } + if (object.outputType !== undefined && object.outputType !== null) { + message.outputType = object.outputType; + } else { + message.outputType = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = MethodOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if ( + object.clientStreaming !== undefined && + object.clientStreaming !== null + ) { + message.clientStreaming = object.clientStreaming; + } else { + message.clientStreaming = false; + } + if ( + object.serverStreaming !== undefined && + object.serverStreaming !== null + ) { + message.serverStreaming = object.serverStreaming; + } else { + message.serverStreaming = false; + } + return message; + }, +}; + +const baseFileOptions: object = { + javaPackage: "", + javaOuterClassname: "", + javaMultipleFiles: false, + javaGenerateEqualsAndHash: false, + javaStringCheckUtf8: false, + optimizeFor: 1, + goPackage: "", + ccGenericServices: false, + javaGenericServices: false, + pyGenericServices: false, + phpGenericServices: false, + deprecated: false, + ccEnableArenas: false, + objcClassPrefix: "", + csharpNamespace: "", + swiftPrefix: "", + phpClassPrefix: "", + phpNamespace: "", + phpMetadataNamespace: "", + rubyPackage: "", +}; + +export const FileOptions = { + encode(message: FileOptions, writer: Writer = Writer.create()): Writer { + if (message.javaPackage !== "") { + writer.uint32(10).string(message.javaPackage); + } + if (message.javaOuterClassname !== "") { + writer.uint32(66).string(message.javaOuterClassname); + } + if (message.javaMultipleFiles === true) { + writer.uint32(80).bool(message.javaMultipleFiles); + } + if (message.javaGenerateEqualsAndHash === true) { + writer.uint32(160).bool(message.javaGenerateEqualsAndHash); + } + if (message.javaStringCheckUtf8 === true) { + writer.uint32(216).bool(message.javaStringCheckUtf8); + } + if (message.optimizeFor !== 1) { + writer.uint32(72).int32(message.optimizeFor); + } + if (message.goPackage !== "") { + writer.uint32(90).string(message.goPackage); + } + if (message.ccGenericServices === true) { + writer.uint32(128).bool(message.ccGenericServices); + } + if (message.javaGenericServices === true) { + writer.uint32(136).bool(message.javaGenericServices); + } + if (message.pyGenericServices === true) { + writer.uint32(144).bool(message.pyGenericServices); + } + if (message.phpGenericServices === true) { + writer.uint32(336).bool(message.phpGenericServices); + } + if (message.deprecated === true) { + writer.uint32(184).bool(message.deprecated); + } + if (message.ccEnableArenas === true) { + writer.uint32(248).bool(message.ccEnableArenas); + } + if (message.objcClassPrefix !== "") { + writer.uint32(290).string(message.objcClassPrefix); + } + if (message.csharpNamespace !== "") { + writer.uint32(298).string(message.csharpNamespace); + } + if (message.swiftPrefix !== "") { + writer.uint32(314).string(message.swiftPrefix); + } + if (message.phpClassPrefix !== "") { + writer.uint32(322).string(message.phpClassPrefix); + } + if (message.phpNamespace !== "") { + writer.uint32(330).string(message.phpNamespace); + } + if (message.phpMetadataNamespace !== "") { + writer.uint32(354).string(message.phpMetadataNamespace); + } + if (message.rubyPackage !== "") { + writer.uint32(362).string(message.rubyPackage); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FileOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFileOptions } as FileOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.javaPackage = reader.string(); + break; + case 8: + message.javaOuterClassname = reader.string(); + break; + case 10: + message.javaMultipleFiles = reader.bool(); + break; + case 20: + message.javaGenerateEqualsAndHash = reader.bool(); + break; + case 27: + message.javaStringCheckUtf8 = reader.bool(); + break; + case 9: + message.optimizeFor = reader.int32() as any; + break; + case 11: + message.goPackage = reader.string(); + break; + case 16: + message.ccGenericServices = reader.bool(); + break; + case 17: + message.javaGenericServices = reader.bool(); + break; + case 18: + message.pyGenericServices = reader.bool(); + break; + case 42: + message.phpGenericServices = reader.bool(); + break; + case 23: + message.deprecated = reader.bool(); + break; + case 31: + message.ccEnableArenas = reader.bool(); + break; + case 36: + message.objcClassPrefix = reader.string(); + break; + case 37: + message.csharpNamespace = reader.string(); + break; + case 39: + message.swiftPrefix = reader.string(); + break; + case 40: + message.phpClassPrefix = reader.string(); + break; + case 41: + message.phpNamespace = reader.string(); + break; + case 44: + message.phpMetadataNamespace = reader.string(); + break; + case 45: + message.rubyPackage = reader.string(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FileOptions { + const message = { ...baseFileOptions } as FileOptions; + message.uninterpretedOption = []; + if (object.javaPackage !== undefined && object.javaPackage !== null) { + message.javaPackage = String(object.javaPackage); + } else { + message.javaPackage = ""; + } + if ( + object.javaOuterClassname !== undefined && + object.javaOuterClassname !== null + ) { + message.javaOuterClassname = String(object.javaOuterClassname); + } else { + message.javaOuterClassname = ""; + } + if ( + object.javaMultipleFiles !== undefined && + object.javaMultipleFiles !== null + ) { + message.javaMultipleFiles = Boolean(object.javaMultipleFiles); + } else { + message.javaMultipleFiles = false; + } + if ( + object.javaGenerateEqualsAndHash !== undefined && + object.javaGenerateEqualsAndHash !== null + ) { + message.javaGenerateEqualsAndHash = Boolean( + object.javaGenerateEqualsAndHash + ); + } else { + message.javaGenerateEqualsAndHash = false; + } + if ( + object.javaStringCheckUtf8 !== undefined && + object.javaStringCheckUtf8 !== null + ) { + message.javaStringCheckUtf8 = Boolean(object.javaStringCheckUtf8); + } else { + message.javaStringCheckUtf8 = false; + } + if (object.optimizeFor !== undefined && object.optimizeFor !== null) { + message.optimizeFor = fileOptions_OptimizeModeFromJSON( + object.optimizeFor + ); + } else { + message.optimizeFor = 1; + } + if (object.goPackage !== undefined && object.goPackage !== null) { + message.goPackage = String(object.goPackage); + } else { + message.goPackage = ""; + } + if ( + object.ccGenericServices !== undefined && + object.ccGenericServices !== null + ) { + message.ccGenericServices = Boolean(object.ccGenericServices); + } else { + message.ccGenericServices = false; + } + if ( + object.javaGenericServices !== undefined && + object.javaGenericServices !== null + ) { + message.javaGenericServices = Boolean(object.javaGenericServices); + } else { + message.javaGenericServices = false; + } + if ( + object.pyGenericServices !== undefined && + object.pyGenericServices !== null + ) { + message.pyGenericServices = Boolean(object.pyGenericServices); + } else { + message.pyGenericServices = false; + } + if ( + object.phpGenericServices !== undefined && + object.phpGenericServices !== null + ) { + message.phpGenericServices = Boolean(object.phpGenericServices); + } else { + message.phpGenericServices = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if (object.ccEnableArenas !== undefined && object.ccEnableArenas !== null) { + message.ccEnableArenas = Boolean(object.ccEnableArenas); + } else { + message.ccEnableArenas = false; + } + if ( + object.objcClassPrefix !== undefined && + object.objcClassPrefix !== null + ) { + message.objcClassPrefix = String(object.objcClassPrefix); + } else { + message.objcClassPrefix = ""; + } + if ( + object.csharpNamespace !== undefined && + object.csharpNamespace !== null + ) { + message.csharpNamespace = String(object.csharpNamespace); + } else { + message.csharpNamespace = ""; + } + if (object.swiftPrefix !== undefined && object.swiftPrefix !== null) { + message.swiftPrefix = String(object.swiftPrefix); + } else { + message.swiftPrefix = ""; + } + if (object.phpClassPrefix !== undefined && object.phpClassPrefix !== null) { + message.phpClassPrefix = String(object.phpClassPrefix); + } else { + message.phpClassPrefix = ""; + } + if (object.phpNamespace !== undefined && object.phpNamespace !== null) { + message.phpNamespace = String(object.phpNamespace); + } else { + message.phpNamespace = ""; + } + if ( + object.phpMetadataNamespace !== undefined && + object.phpMetadataNamespace !== null + ) { + message.phpMetadataNamespace = String(object.phpMetadataNamespace); + } else { + message.phpMetadataNamespace = ""; + } + if (object.rubyPackage !== undefined && object.rubyPackage !== null) { + message.rubyPackage = String(object.rubyPackage); + } else { + message.rubyPackage = ""; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: FileOptions): unknown { + const obj: any = {}; + message.javaPackage !== undefined && + (obj.javaPackage = message.javaPackage); + message.javaOuterClassname !== undefined && + (obj.javaOuterClassname = message.javaOuterClassname); + message.javaMultipleFiles !== undefined && + (obj.javaMultipleFiles = message.javaMultipleFiles); + message.javaGenerateEqualsAndHash !== undefined && + (obj.javaGenerateEqualsAndHash = message.javaGenerateEqualsAndHash); + message.javaStringCheckUtf8 !== undefined && + (obj.javaStringCheckUtf8 = message.javaStringCheckUtf8); + message.optimizeFor !== undefined && + (obj.optimizeFor = fileOptions_OptimizeModeToJSON(message.optimizeFor)); + message.goPackage !== undefined && (obj.goPackage = message.goPackage); + message.ccGenericServices !== undefined && + (obj.ccGenericServices = message.ccGenericServices); + message.javaGenericServices !== undefined && + (obj.javaGenericServices = message.javaGenericServices); + message.pyGenericServices !== undefined && + (obj.pyGenericServices = message.pyGenericServices); + message.phpGenericServices !== undefined && + (obj.phpGenericServices = message.phpGenericServices); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.ccEnableArenas !== undefined && + (obj.ccEnableArenas = message.ccEnableArenas); + message.objcClassPrefix !== undefined && + (obj.objcClassPrefix = message.objcClassPrefix); + message.csharpNamespace !== undefined && + (obj.csharpNamespace = message.csharpNamespace); + message.swiftPrefix !== undefined && + (obj.swiftPrefix = message.swiftPrefix); + message.phpClassPrefix !== undefined && + (obj.phpClassPrefix = message.phpClassPrefix); + message.phpNamespace !== undefined && + (obj.phpNamespace = message.phpNamespace); + message.phpMetadataNamespace !== undefined && + (obj.phpMetadataNamespace = message.phpMetadataNamespace); + message.rubyPackage !== undefined && + (obj.rubyPackage = message.rubyPackage); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): FileOptions { + const message = { ...baseFileOptions } as FileOptions; + message.uninterpretedOption = []; + if (object.javaPackage !== undefined && object.javaPackage !== null) { + message.javaPackage = object.javaPackage; + } else { + message.javaPackage = ""; + } + if ( + object.javaOuterClassname !== undefined && + object.javaOuterClassname !== null + ) { + message.javaOuterClassname = object.javaOuterClassname; + } else { + message.javaOuterClassname = ""; + } + if ( + object.javaMultipleFiles !== undefined && + object.javaMultipleFiles !== null + ) { + message.javaMultipleFiles = object.javaMultipleFiles; + } else { + message.javaMultipleFiles = false; + } + if ( + object.javaGenerateEqualsAndHash !== undefined && + object.javaGenerateEqualsAndHash !== null + ) { + message.javaGenerateEqualsAndHash = object.javaGenerateEqualsAndHash; + } else { + message.javaGenerateEqualsAndHash = false; + } + if ( + object.javaStringCheckUtf8 !== undefined && + object.javaStringCheckUtf8 !== null + ) { + message.javaStringCheckUtf8 = object.javaStringCheckUtf8; + } else { + message.javaStringCheckUtf8 = false; + } + if (object.optimizeFor !== undefined && object.optimizeFor !== null) { + message.optimizeFor = object.optimizeFor; + } else { + message.optimizeFor = 1; + } + if (object.goPackage !== undefined && object.goPackage !== null) { + message.goPackage = object.goPackage; + } else { + message.goPackage = ""; + } + if ( + object.ccGenericServices !== undefined && + object.ccGenericServices !== null + ) { + message.ccGenericServices = object.ccGenericServices; + } else { + message.ccGenericServices = false; + } + if ( + object.javaGenericServices !== undefined && + object.javaGenericServices !== null + ) { + message.javaGenericServices = object.javaGenericServices; + } else { + message.javaGenericServices = false; + } + if ( + object.pyGenericServices !== undefined && + object.pyGenericServices !== null + ) { + message.pyGenericServices = object.pyGenericServices; + } else { + message.pyGenericServices = false; + } + if ( + object.phpGenericServices !== undefined && + object.phpGenericServices !== null + ) { + message.phpGenericServices = object.phpGenericServices; + } else { + message.phpGenericServices = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if (object.ccEnableArenas !== undefined && object.ccEnableArenas !== null) { + message.ccEnableArenas = object.ccEnableArenas; + } else { + message.ccEnableArenas = false; + } + if ( + object.objcClassPrefix !== undefined && + object.objcClassPrefix !== null + ) { + message.objcClassPrefix = object.objcClassPrefix; + } else { + message.objcClassPrefix = ""; + } + if ( + object.csharpNamespace !== undefined && + object.csharpNamespace !== null + ) { + message.csharpNamespace = object.csharpNamespace; + } else { + message.csharpNamespace = ""; + } + if (object.swiftPrefix !== undefined && object.swiftPrefix !== null) { + message.swiftPrefix = object.swiftPrefix; + } else { + message.swiftPrefix = ""; + } + if (object.phpClassPrefix !== undefined && object.phpClassPrefix !== null) { + message.phpClassPrefix = object.phpClassPrefix; + } else { + message.phpClassPrefix = ""; + } + if (object.phpNamespace !== undefined && object.phpNamespace !== null) { + message.phpNamespace = object.phpNamespace; + } else { + message.phpNamespace = ""; + } + if ( + object.phpMetadataNamespace !== undefined && + object.phpMetadataNamespace !== null + ) { + message.phpMetadataNamespace = object.phpMetadataNamespace; + } else { + message.phpMetadataNamespace = ""; + } + if (object.rubyPackage !== undefined && object.rubyPackage !== null) { + message.rubyPackage = object.rubyPackage; + } else { + message.rubyPackage = ""; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseMessageOptions: object = { + messageSetWireFormat: false, + noStandardDescriptorAccessor: false, + deprecated: false, + mapEntry: false, +}; + +export const MessageOptions = { + encode(message: MessageOptions, writer: Writer = Writer.create()): Writer { + if (message.messageSetWireFormat === true) { + writer.uint32(8).bool(message.messageSetWireFormat); + } + if (message.noStandardDescriptorAccessor === true) { + writer.uint32(16).bool(message.noStandardDescriptorAccessor); + } + if (message.deprecated === true) { + writer.uint32(24).bool(message.deprecated); + } + if (message.mapEntry === true) { + writer.uint32(56).bool(message.mapEntry); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MessageOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMessageOptions } as MessageOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.messageSetWireFormat = reader.bool(); + break; + case 2: + message.noStandardDescriptorAccessor = reader.bool(); + break; + case 3: + message.deprecated = reader.bool(); + break; + case 7: + message.mapEntry = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MessageOptions { + const message = { ...baseMessageOptions } as MessageOptions; + message.uninterpretedOption = []; + if ( + object.messageSetWireFormat !== undefined && + object.messageSetWireFormat !== null + ) { + message.messageSetWireFormat = Boolean(object.messageSetWireFormat); + } else { + message.messageSetWireFormat = false; + } + if ( + object.noStandardDescriptorAccessor !== undefined && + object.noStandardDescriptorAccessor !== null + ) { + message.noStandardDescriptorAccessor = Boolean( + object.noStandardDescriptorAccessor + ); + } else { + message.noStandardDescriptorAccessor = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if (object.mapEntry !== undefined && object.mapEntry !== null) { + message.mapEntry = Boolean(object.mapEntry); + } else { + message.mapEntry = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: MessageOptions): unknown { + const obj: any = {}; + message.messageSetWireFormat !== undefined && + (obj.messageSetWireFormat = message.messageSetWireFormat); + message.noStandardDescriptorAccessor !== undefined && + (obj.noStandardDescriptorAccessor = message.noStandardDescriptorAccessor); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.mapEntry !== undefined && (obj.mapEntry = message.mapEntry); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): MessageOptions { + const message = { ...baseMessageOptions } as MessageOptions; + message.uninterpretedOption = []; + if ( + object.messageSetWireFormat !== undefined && + object.messageSetWireFormat !== null + ) { + message.messageSetWireFormat = object.messageSetWireFormat; + } else { + message.messageSetWireFormat = false; + } + if ( + object.noStandardDescriptorAccessor !== undefined && + object.noStandardDescriptorAccessor !== null + ) { + message.noStandardDescriptorAccessor = + object.noStandardDescriptorAccessor; + } else { + message.noStandardDescriptorAccessor = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if (object.mapEntry !== undefined && object.mapEntry !== null) { + message.mapEntry = object.mapEntry; + } else { + message.mapEntry = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseFieldOptions: object = { + ctype: 0, + packed: false, + jstype: 0, + lazy: false, + deprecated: false, + weak: false, +}; + +export const FieldOptions = { + encode(message: FieldOptions, writer: Writer = Writer.create()): Writer { + if (message.ctype !== 0) { + writer.uint32(8).int32(message.ctype); + } + if (message.packed === true) { + writer.uint32(16).bool(message.packed); + } + if (message.jstype !== 0) { + writer.uint32(48).int32(message.jstype); + } + if (message.lazy === true) { + writer.uint32(40).bool(message.lazy); + } + if (message.deprecated === true) { + writer.uint32(24).bool(message.deprecated); + } + if (message.weak === true) { + writer.uint32(80).bool(message.weak); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FieldOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFieldOptions } as FieldOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.ctype = reader.int32() as any; + break; + case 2: + message.packed = reader.bool(); + break; + case 6: + message.jstype = reader.int32() as any; + break; + case 5: + message.lazy = reader.bool(); + break; + case 3: + message.deprecated = reader.bool(); + break; + case 10: + message.weak = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FieldOptions { + const message = { ...baseFieldOptions } as FieldOptions; + message.uninterpretedOption = []; + if (object.ctype !== undefined && object.ctype !== null) { + message.ctype = fieldOptions_CTypeFromJSON(object.ctype); + } else { + message.ctype = 0; + } + if (object.packed !== undefined && object.packed !== null) { + message.packed = Boolean(object.packed); + } else { + message.packed = false; + } + if (object.jstype !== undefined && object.jstype !== null) { + message.jstype = fieldOptions_JSTypeFromJSON(object.jstype); + } else { + message.jstype = 0; + } + if (object.lazy !== undefined && object.lazy !== null) { + message.lazy = Boolean(object.lazy); + } else { + message.lazy = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if (object.weak !== undefined && object.weak !== null) { + message.weak = Boolean(object.weak); + } else { + message.weak = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: FieldOptions): unknown { + const obj: any = {}; + message.ctype !== undefined && + (obj.ctype = fieldOptions_CTypeToJSON(message.ctype)); + message.packed !== undefined && (obj.packed = message.packed); + message.jstype !== undefined && + (obj.jstype = fieldOptions_JSTypeToJSON(message.jstype)); + message.lazy !== undefined && (obj.lazy = message.lazy); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.weak !== undefined && (obj.weak = message.weak); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): FieldOptions { + const message = { ...baseFieldOptions } as FieldOptions; + message.uninterpretedOption = []; + if (object.ctype !== undefined && object.ctype !== null) { + message.ctype = object.ctype; + } else { + message.ctype = 0; + } + if (object.packed !== undefined && object.packed !== null) { + message.packed = object.packed; + } else { + message.packed = false; + } + if (object.jstype !== undefined && object.jstype !== null) { + message.jstype = object.jstype; + } else { + message.jstype = 0; + } + if (object.lazy !== undefined && object.lazy !== null) { + message.lazy = object.lazy; + } else { + message.lazy = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if (object.weak !== undefined && object.weak !== null) { + message.weak = object.weak; + } else { + message.weak = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseOneofOptions: object = {}; + +export const OneofOptions = { + encode(message: OneofOptions, writer: Writer = Writer.create()): Writer { + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): OneofOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseOneofOptions } as OneofOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): OneofOptions { + const message = { ...baseOneofOptions } as OneofOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: OneofOptions): unknown { + const obj: any = {}; + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): OneofOptions { + const message = { ...baseOneofOptions } as OneofOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseEnumOptions: object = { allowAlias: false, deprecated: false }; + +export const EnumOptions = { + encode(message: EnumOptions, writer: Writer = Writer.create()): Writer { + if (message.allowAlias === true) { + writer.uint32(16).bool(message.allowAlias); + } + if (message.deprecated === true) { + writer.uint32(24).bool(message.deprecated); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): EnumOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseEnumOptions } as EnumOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + message.allowAlias = reader.bool(); + break; + case 3: + message.deprecated = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumOptions { + const message = { ...baseEnumOptions } as EnumOptions; + message.uninterpretedOption = []; + if (object.allowAlias !== undefined && object.allowAlias !== null) { + message.allowAlias = Boolean(object.allowAlias); + } else { + message.allowAlias = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: EnumOptions): unknown { + const obj: any = {}; + message.allowAlias !== undefined && (obj.allowAlias = message.allowAlias); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): EnumOptions { + const message = { ...baseEnumOptions } as EnumOptions; + message.uninterpretedOption = []; + if (object.allowAlias !== undefined && object.allowAlias !== null) { + message.allowAlias = object.allowAlias; + } else { + message.allowAlias = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseEnumValueOptions: object = { deprecated: false }; + +export const EnumValueOptions = { + encode(message: EnumValueOptions, writer: Writer = Writer.create()): Writer { + if (message.deprecated === true) { + writer.uint32(8).bool(message.deprecated); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): EnumValueOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseEnumValueOptions } as EnumValueOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.deprecated = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumValueOptions { + const message = { ...baseEnumValueOptions } as EnumValueOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: EnumValueOptions): unknown { + const obj: any = {}; + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): EnumValueOptions { + const message = { ...baseEnumValueOptions } as EnumValueOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseServiceOptions: object = { deprecated: false }; + +export const ServiceOptions = { + encode(message: ServiceOptions, writer: Writer = Writer.create()): Writer { + if (message.deprecated === true) { + writer.uint32(264).bool(message.deprecated); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ServiceOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseServiceOptions } as ServiceOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 33: + message.deprecated = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ServiceOptions { + const message = { ...baseServiceOptions } as ServiceOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: ServiceOptions): unknown { + const obj: any = {}; + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): ServiceOptions { + const message = { ...baseServiceOptions } as ServiceOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseMethodOptions: object = { deprecated: false, idempotencyLevel: 0 }; + +export const MethodOptions = { + encode(message: MethodOptions, writer: Writer = Writer.create()): Writer { + if (message.deprecated === true) { + writer.uint32(264).bool(message.deprecated); + } + if (message.idempotencyLevel !== 0) { + writer.uint32(272).int32(message.idempotencyLevel); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MethodOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMethodOptions } as MethodOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 33: + message.deprecated = reader.bool(); + break; + case 34: + message.idempotencyLevel = reader.int32() as any; + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MethodOptions { + const message = { ...baseMethodOptions } as MethodOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.idempotencyLevel !== undefined && + object.idempotencyLevel !== null + ) { + message.idempotencyLevel = methodOptions_IdempotencyLevelFromJSON( + object.idempotencyLevel + ); + } else { + message.idempotencyLevel = 0; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: MethodOptions): unknown { + const obj: any = {}; + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.idempotencyLevel !== undefined && + (obj.idempotencyLevel = methodOptions_IdempotencyLevelToJSON( + message.idempotencyLevel + )); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): MethodOptions { + const message = { ...baseMethodOptions } as MethodOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.idempotencyLevel !== undefined && + object.idempotencyLevel !== null + ) { + message.idempotencyLevel = object.idempotencyLevel; + } else { + message.idempotencyLevel = 0; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseUninterpretedOption: object = { + identifierValue: "", + positiveIntValue: 0, + negativeIntValue: 0, + doubleValue: 0, + aggregateValue: "", +}; + +export const UninterpretedOption = { + encode( + message: UninterpretedOption, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.name) { + UninterpretedOption_NamePart.encode( + v!, + writer.uint32(18).fork() + ).ldelim(); + } + if (message.identifierValue !== "") { + writer.uint32(26).string(message.identifierValue); + } + if (message.positiveIntValue !== 0) { + writer.uint32(32).uint64(message.positiveIntValue); + } + if (message.negativeIntValue !== 0) { + writer.uint32(40).int64(message.negativeIntValue); + } + if (message.doubleValue !== 0) { + writer.uint32(49).double(message.doubleValue); + } + if (message.stringValue.length !== 0) { + writer.uint32(58).bytes(message.stringValue); + } + if (message.aggregateValue !== "") { + writer.uint32(66).string(message.aggregateValue); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): UninterpretedOption { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseUninterpretedOption } as UninterpretedOption; + message.name = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + message.name.push( + UninterpretedOption_NamePart.decode(reader, reader.uint32()) + ); + break; + case 3: + message.identifierValue = reader.string(); + break; + case 4: + message.positiveIntValue = longToNumber(reader.uint64() as Long); + break; + case 5: + message.negativeIntValue = longToNumber(reader.int64() as Long); + break; + case 6: + message.doubleValue = reader.double(); + break; + case 7: + message.stringValue = reader.bytes(); + break; + case 8: + message.aggregateValue = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): UninterpretedOption { + const message = { ...baseUninterpretedOption } as UninterpretedOption; + message.name = []; + if (object.name !== undefined && object.name !== null) { + for (const e of object.name) { + message.name.push(UninterpretedOption_NamePart.fromJSON(e)); + } + } + if ( + object.identifierValue !== undefined && + object.identifierValue !== null + ) { + message.identifierValue = String(object.identifierValue); + } else { + message.identifierValue = ""; + } + if ( + object.positiveIntValue !== undefined && + object.positiveIntValue !== null + ) { + message.positiveIntValue = Number(object.positiveIntValue); + } else { + message.positiveIntValue = 0; + } + if ( + object.negativeIntValue !== undefined && + object.negativeIntValue !== null + ) { + message.negativeIntValue = Number(object.negativeIntValue); + } else { + message.negativeIntValue = 0; + } + if (object.doubleValue !== undefined && object.doubleValue !== null) { + message.doubleValue = Number(object.doubleValue); + } else { + message.doubleValue = 0; + } + if (object.stringValue !== undefined && object.stringValue !== null) { + message.stringValue = bytesFromBase64(object.stringValue); + } + if (object.aggregateValue !== undefined && object.aggregateValue !== null) { + message.aggregateValue = String(object.aggregateValue); + } else { + message.aggregateValue = ""; + } + return message; + }, + + toJSON(message: UninterpretedOption): unknown { + const obj: any = {}; + if (message.name) { + obj.name = message.name.map((e) => + e ? UninterpretedOption_NamePart.toJSON(e) : undefined + ); + } else { + obj.name = []; + } + message.identifierValue !== undefined && + (obj.identifierValue = message.identifierValue); + message.positiveIntValue !== undefined && + (obj.positiveIntValue = message.positiveIntValue); + message.negativeIntValue !== undefined && + (obj.negativeIntValue = message.negativeIntValue); + message.doubleValue !== undefined && + (obj.doubleValue = message.doubleValue); + message.stringValue !== undefined && + (obj.stringValue = base64FromBytes( + message.stringValue !== undefined + ? message.stringValue + : new Uint8Array() + )); + message.aggregateValue !== undefined && + (obj.aggregateValue = message.aggregateValue); + return obj; + }, + + fromPartial(object: DeepPartial): UninterpretedOption { + const message = { ...baseUninterpretedOption } as UninterpretedOption; + message.name = []; + if (object.name !== undefined && object.name !== null) { + for (const e of object.name) { + message.name.push(UninterpretedOption_NamePart.fromPartial(e)); + } + } + if ( + object.identifierValue !== undefined && + object.identifierValue !== null + ) { + message.identifierValue = object.identifierValue; + } else { + message.identifierValue = ""; + } + if ( + object.positiveIntValue !== undefined && + object.positiveIntValue !== null + ) { + message.positiveIntValue = object.positiveIntValue; + } else { + message.positiveIntValue = 0; + } + if ( + object.negativeIntValue !== undefined && + object.negativeIntValue !== null + ) { + message.negativeIntValue = object.negativeIntValue; + } else { + message.negativeIntValue = 0; + } + if (object.doubleValue !== undefined && object.doubleValue !== null) { + message.doubleValue = object.doubleValue; + } else { + message.doubleValue = 0; + } + if (object.stringValue !== undefined && object.stringValue !== null) { + message.stringValue = object.stringValue; + } else { + message.stringValue = new Uint8Array(); + } + if (object.aggregateValue !== undefined && object.aggregateValue !== null) { + message.aggregateValue = object.aggregateValue; + } else { + message.aggregateValue = ""; + } + return message; + }, +}; + +const baseUninterpretedOption_NamePart: object = { + namePart: "", + isExtension: false, +}; + +export const UninterpretedOption_NamePart = { + encode( + message: UninterpretedOption_NamePart, + writer: Writer = Writer.create() + ): Writer { + if (message.namePart !== "") { + writer.uint32(10).string(message.namePart); + } + if (message.isExtension === true) { + writer.uint32(16).bool(message.isExtension); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): UninterpretedOption_NamePart { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseUninterpretedOption_NamePart, + } as UninterpretedOption_NamePart; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.namePart = reader.string(); + break; + case 2: + message.isExtension = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): UninterpretedOption_NamePart { + const message = { + ...baseUninterpretedOption_NamePart, + } as UninterpretedOption_NamePart; + if (object.namePart !== undefined && object.namePart !== null) { + message.namePart = String(object.namePart); + } else { + message.namePart = ""; + } + if (object.isExtension !== undefined && object.isExtension !== null) { + message.isExtension = Boolean(object.isExtension); + } else { + message.isExtension = false; + } + return message; + }, + + toJSON(message: UninterpretedOption_NamePart): unknown { + const obj: any = {}; + message.namePart !== undefined && (obj.namePart = message.namePart); + message.isExtension !== undefined && + (obj.isExtension = message.isExtension); + return obj; + }, + + fromPartial( + object: DeepPartial + ): UninterpretedOption_NamePart { + const message = { + ...baseUninterpretedOption_NamePart, + } as UninterpretedOption_NamePart; + if (object.namePart !== undefined && object.namePart !== null) { + message.namePart = object.namePart; + } else { + message.namePart = ""; + } + if (object.isExtension !== undefined && object.isExtension !== null) { + message.isExtension = object.isExtension; + } else { + message.isExtension = false; + } + return message; + }, +}; + +const baseSourceCodeInfo: object = {}; + +export const SourceCodeInfo = { + encode(message: SourceCodeInfo, writer: Writer = Writer.create()): Writer { + for (const v of message.location) { + SourceCodeInfo_Location.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): SourceCodeInfo { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseSourceCodeInfo } as SourceCodeInfo; + message.location = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.location.push( + SourceCodeInfo_Location.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): SourceCodeInfo { + const message = { ...baseSourceCodeInfo } as SourceCodeInfo; + message.location = []; + if (object.location !== undefined && object.location !== null) { + for (const e of object.location) { + message.location.push(SourceCodeInfo_Location.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: SourceCodeInfo): unknown { + const obj: any = {}; + if (message.location) { + obj.location = message.location.map((e) => + e ? SourceCodeInfo_Location.toJSON(e) : undefined + ); + } else { + obj.location = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): SourceCodeInfo { + const message = { ...baseSourceCodeInfo } as SourceCodeInfo; + message.location = []; + if (object.location !== undefined && object.location !== null) { + for (const e of object.location) { + message.location.push(SourceCodeInfo_Location.fromPartial(e)); + } + } + return message; + }, +}; + +const baseSourceCodeInfo_Location: object = { + path: 0, + span: 0, + leadingComments: "", + trailingComments: "", + leadingDetachedComments: "", +}; + +export const SourceCodeInfo_Location = { + encode( + message: SourceCodeInfo_Location, + writer: Writer = Writer.create() + ): Writer { + writer.uint32(10).fork(); + for (const v of message.path) { + writer.int32(v); + } + writer.ldelim(); + writer.uint32(18).fork(); + for (const v of message.span) { + writer.int32(v); + } + writer.ldelim(); + if (message.leadingComments !== "") { + writer.uint32(26).string(message.leadingComments); + } + if (message.trailingComments !== "") { + writer.uint32(34).string(message.trailingComments); + } + for (const v of message.leadingDetachedComments) { + writer.uint32(50).string(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): SourceCodeInfo_Location { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseSourceCodeInfo_Location, + } as SourceCodeInfo_Location; + message.path = []; + message.span = []; + message.leadingDetachedComments = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.path.push(reader.int32()); + } + } else { + message.path.push(reader.int32()); + } + break; + case 2: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.span.push(reader.int32()); + } + } else { + message.span.push(reader.int32()); + } + break; + case 3: + message.leadingComments = reader.string(); + break; + case 4: + message.trailingComments = reader.string(); + break; + case 6: + message.leadingDetachedComments.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): SourceCodeInfo_Location { + const message = { + ...baseSourceCodeInfo_Location, + } as SourceCodeInfo_Location; + message.path = []; + message.span = []; + message.leadingDetachedComments = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(Number(e)); + } + } + if (object.span !== undefined && object.span !== null) { + for (const e of object.span) { + message.span.push(Number(e)); + } + } + if ( + object.leadingComments !== undefined && + object.leadingComments !== null + ) { + message.leadingComments = String(object.leadingComments); + } else { + message.leadingComments = ""; + } + if ( + object.trailingComments !== undefined && + object.trailingComments !== null + ) { + message.trailingComments = String(object.trailingComments); + } else { + message.trailingComments = ""; + } + if ( + object.leadingDetachedComments !== undefined && + object.leadingDetachedComments !== null + ) { + for (const e of object.leadingDetachedComments) { + message.leadingDetachedComments.push(String(e)); + } + } + return message; + }, + + toJSON(message: SourceCodeInfo_Location): unknown { + const obj: any = {}; + if (message.path) { + obj.path = message.path.map((e) => e); + } else { + obj.path = []; + } + if (message.span) { + obj.span = message.span.map((e) => e); + } else { + obj.span = []; + } + message.leadingComments !== undefined && + (obj.leadingComments = message.leadingComments); + message.trailingComments !== undefined && + (obj.trailingComments = message.trailingComments); + if (message.leadingDetachedComments) { + obj.leadingDetachedComments = message.leadingDetachedComments.map( + (e) => e + ); + } else { + obj.leadingDetachedComments = []; + } + return obj; + }, + + fromPartial( + object: DeepPartial + ): SourceCodeInfo_Location { + const message = { + ...baseSourceCodeInfo_Location, + } as SourceCodeInfo_Location; + message.path = []; + message.span = []; + message.leadingDetachedComments = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(e); + } + } + if (object.span !== undefined && object.span !== null) { + for (const e of object.span) { + message.span.push(e); + } + } + if ( + object.leadingComments !== undefined && + object.leadingComments !== null + ) { + message.leadingComments = object.leadingComments; + } else { + message.leadingComments = ""; + } + if ( + object.trailingComments !== undefined && + object.trailingComments !== null + ) { + message.trailingComments = object.trailingComments; + } else { + message.trailingComments = ""; + } + if ( + object.leadingDetachedComments !== undefined && + object.leadingDetachedComments !== null + ) { + for (const e of object.leadingDetachedComments) { + message.leadingDetachedComments.push(e); + } + } + return message; + }, +}; + +const baseGeneratedCodeInfo: object = {}; + +export const GeneratedCodeInfo = { + encode(message: GeneratedCodeInfo, writer: Writer = Writer.create()): Writer { + for (const v of message.annotation) { + GeneratedCodeInfo_Annotation.encode( + v!, + writer.uint32(10).fork() + ).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): GeneratedCodeInfo { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseGeneratedCodeInfo } as GeneratedCodeInfo; + message.annotation = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.annotation.push( + GeneratedCodeInfo_Annotation.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GeneratedCodeInfo { + const message = { ...baseGeneratedCodeInfo } as GeneratedCodeInfo; + message.annotation = []; + if (object.annotation !== undefined && object.annotation !== null) { + for (const e of object.annotation) { + message.annotation.push(GeneratedCodeInfo_Annotation.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: GeneratedCodeInfo): unknown { + const obj: any = {}; + if (message.annotation) { + obj.annotation = message.annotation.map((e) => + e ? GeneratedCodeInfo_Annotation.toJSON(e) : undefined + ); + } else { + obj.annotation = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): GeneratedCodeInfo { + const message = { ...baseGeneratedCodeInfo } as GeneratedCodeInfo; + message.annotation = []; + if (object.annotation !== undefined && object.annotation !== null) { + for (const e of object.annotation) { + message.annotation.push(GeneratedCodeInfo_Annotation.fromPartial(e)); + } + } + return message; + }, +}; + +const baseGeneratedCodeInfo_Annotation: object = { + path: 0, + sourceFile: "", + begin: 0, + end: 0, +}; + +export const GeneratedCodeInfo_Annotation = { + encode( + message: GeneratedCodeInfo_Annotation, + writer: Writer = Writer.create() + ): Writer { + writer.uint32(10).fork(); + for (const v of message.path) { + writer.int32(v); + } + writer.ldelim(); + if (message.sourceFile !== "") { + writer.uint32(18).string(message.sourceFile); + } + if (message.begin !== 0) { + writer.uint32(24).int32(message.begin); + } + if (message.end !== 0) { + writer.uint32(32).int32(message.end); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): GeneratedCodeInfo_Annotation { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseGeneratedCodeInfo_Annotation, + } as GeneratedCodeInfo_Annotation; + message.path = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.path.push(reader.int32()); + } + } else { + message.path.push(reader.int32()); + } + break; + case 2: + message.sourceFile = reader.string(); + break; + case 3: + message.begin = reader.int32(); + break; + case 4: + message.end = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GeneratedCodeInfo_Annotation { + const message = { + ...baseGeneratedCodeInfo_Annotation, + } as GeneratedCodeInfo_Annotation; + message.path = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(Number(e)); + } + } + if (object.sourceFile !== undefined && object.sourceFile !== null) { + message.sourceFile = String(object.sourceFile); + } else { + message.sourceFile = ""; + } + if (object.begin !== undefined && object.begin !== null) { + message.begin = Number(object.begin); + } else { + message.begin = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + return message; + }, + + toJSON(message: GeneratedCodeInfo_Annotation): unknown { + const obj: any = {}; + if (message.path) { + obj.path = message.path.map((e) => e); + } else { + obj.path = []; + } + message.sourceFile !== undefined && (obj.sourceFile = message.sourceFile); + message.begin !== undefined && (obj.begin = message.begin); + message.end !== undefined && (obj.end = message.end); + return obj; + }, + + fromPartial( + object: DeepPartial + ): GeneratedCodeInfo_Annotation { + const message = { + ...baseGeneratedCodeInfo_Annotation, + } as GeneratedCodeInfo_Annotation; + message.path = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(e); + } + } + if (object.sourceFile !== undefined && object.sourceFile !== null) { + message.sourceFile = object.sourceFile; + } else { + message.sourceFile = ""; + } + if (object.begin !== undefined && object.begin !== null) { + message.begin = object.begin; + } else { + message.begin = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/cosmos.staking.v1beta1/types/google/protobuf/duration.ts b/ts-client/cosmos.staking.v1beta1/types/google/protobuf/duration.ts new file mode 100644 index 00000000..fffd5b14 --- /dev/null +++ b/ts-client/cosmos.staking.v1beta1/types/google/protobuf/duration.ts @@ -0,0 +1,188 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "google.protobuf"; + +/** + * A Duration represents a signed, fixed-length span of time represented + * as a count of seconds and fractions of seconds at nanosecond + * resolution. It is independent of any calendar and concepts like "day" + * or "month". It is related to Timestamp in that the difference between + * two Timestamp values is a Duration and it can be added or subtracted + * from a Timestamp. Range is approximately +-10,000 years. + * + * # Examples + * + * Example 1: Compute Duration from two Timestamps in pseudo code. + * + * Timestamp start = ...; + * Timestamp end = ...; + * Duration duration = ...; + * + * duration.seconds = end.seconds - start.seconds; + * duration.nanos = end.nanos - start.nanos; + * + * if (duration.seconds < 0 && duration.nanos > 0) { + * duration.seconds += 1; + * duration.nanos -= 1000000000; + * } else if (duration.seconds > 0 && duration.nanos < 0) { + * duration.seconds -= 1; + * duration.nanos += 1000000000; + * } + * + * Example 2: Compute Timestamp from Timestamp + Duration in pseudo code. + * + * Timestamp start = ...; + * Duration duration = ...; + * Timestamp end = ...; + * + * end.seconds = start.seconds + duration.seconds; + * end.nanos = start.nanos + duration.nanos; + * + * if (end.nanos < 0) { + * end.seconds -= 1; + * end.nanos += 1000000000; + * } else if (end.nanos >= 1000000000) { + * end.seconds += 1; + * end.nanos -= 1000000000; + * } + * + * Example 3: Compute Duration from datetime.timedelta in Python. + * + * td = datetime.timedelta(days=3, minutes=10) + * duration = Duration() + * duration.FromTimedelta(td) + * + * # JSON Mapping + * + * In JSON format, the Duration type is encoded as a string rather than an + * object, where the string ends in the suffix "s" (indicating seconds) and + * is preceded by the number of seconds, with nanoseconds expressed as + * fractional seconds. For example, 3 seconds with 0 nanoseconds should be + * encoded in JSON format as "3s", while 3 seconds and 1 nanosecond should + * be expressed in JSON format as "3.000000001s", and 3 seconds and 1 + * microsecond should be expressed in JSON format as "3.000001s". + */ +export interface Duration { + /** + * Signed seconds of the span of time. Must be from -315,576,000,000 + * to +315,576,000,000 inclusive. Note: these bounds are computed from: + * 60 sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years + */ + seconds: number; + /** + * Signed fractions of a second at nanosecond resolution of the span + * of time. Durations less than one second are represented with a 0 + * `seconds` field and a positive or negative `nanos` field. For durations + * of one second or more, a non-zero value for the `nanos` field must be + * of the same sign as the `seconds` field. Must be from -999,999,999 + * to +999,999,999 inclusive. + */ + nanos: number; +} + +const baseDuration: object = { seconds: 0, nanos: 0 }; + +export const Duration = { + encode(message: Duration, writer: Writer = Writer.create()): Writer { + if (message.seconds !== 0) { + writer.uint32(8).int64(message.seconds); + } + if (message.nanos !== 0) { + writer.uint32(16).int32(message.nanos); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Duration { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseDuration } as Duration; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.seconds = longToNumber(reader.int64() as Long); + break; + case 2: + message.nanos = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Duration { + const message = { ...baseDuration } as Duration; + if (object.seconds !== undefined && object.seconds !== null) { + message.seconds = Number(object.seconds); + } else { + message.seconds = 0; + } + if (object.nanos !== undefined && object.nanos !== null) { + message.nanos = Number(object.nanos); + } else { + message.nanos = 0; + } + return message; + }, + + toJSON(message: Duration): unknown { + const obj: any = {}; + message.seconds !== undefined && (obj.seconds = message.seconds); + message.nanos !== undefined && (obj.nanos = message.nanos); + return obj; + }, + + fromPartial(object: DeepPartial): Duration { + const message = { ...baseDuration } as Duration; + if (object.seconds !== undefined && object.seconds !== null) { + message.seconds = object.seconds; + } else { + message.seconds = 0; + } + if (object.nanos !== undefined && object.nanos !== null) { + message.nanos = object.nanos; + } else { + message.nanos = 0; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/cosmos.staking.v1beta1/types/google/protobuf/timestamp.ts b/ts-client/cosmos.staking.v1beta1/types/google/protobuf/timestamp.ts new file mode 100644 index 00000000..11864afc --- /dev/null +++ b/ts-client/cosmos.staking.v1beta1/types/google/protobuf/timestamp.ts @@ -0,0 +1,219 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "google.protobuf"; + +/** + * A Timestamp represents a point in time independent of any time zone or local + * calendar, encoded as a count of seconds and fractions of seconds at + * nanosecond resolution. The count is relative to an epoch at UTC midnight on + * January 1, 1970, in the proleptic Gregorian calendar which extends the + * Gregorian calendar backwards to year one. + * + * All minutes are 60 seconds long. Leap seconds are "smeared" so that no leap + * second table is needed for interpretation, using a [24-hour linear + * smear](https://developers.google.com/time/smear). + * + * The range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. By + * restricting to that range, we ensure that we can convert to and from [RFC + * 3339](https://www.ietf.org/rfc/rfc3339.txt) date strings. + * + * # Examples + * + * Example 1: Compute Timestamp from POSIX `time()`. + * + * Timestamp timestamp; + * timestamp.set_seconds(time(NULL)); + * timestamp.set_nanos(0); + * + * Example 2: Compute Timestamp from POSIX `gettimeofday()`. + * + * struct timeval tv; + * gettimeofday(&tv, NULL); + * + * Timestamp timestamp; + * timestamp.set_seconds(tv.tv_sec); + * timestamp.set_nanos(tv.tv_usec * 1000); + * + * Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`. + * + * FILETIME ft; + * GetSystemTimeAsFileTime(&ft); + * UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime; + * + * // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z + * // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z. + * Timestamp timestamp; + * timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL)); + * timestamp.set_nanos((INT32) ((ticks % 10000000) * 100)); + * + * Example 4: Compute Timestamp from Java `System.currentTimeMillis()`. + * + * long millis = System.currentTimeMillis(); + * + * Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000) + * .setNanos((int) ((millis % 1000) * 1000000)).build(); + * + * + * Example 5: Compute Timestamp from Java `Instant.now()`. + * + * Instant now = Instant.now(); + * + * Timestamp timestamp = + * Timestamp.newBuilder().setSeconds(now.getEpochSecond()) + * .setNanos(now.getNano()).build(); + * + * + * Example 6: Compute Timestamp from current time in Python. + * + * timestamp = Timestamp() + * timestamp.GetCurrentTime() + * + * # JSON Mapping + * + * In JSON format, the Timestamp type is encoded as a string in the + * [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the + * format is "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z" + * where {year} is always expressed using four digits while {month}, {day}, + * {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional + * seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution), + * are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone + * is required. A proto3 JSON serializer should always use UTC (as indicated by + * "Z") when printing the Timestamp type and a proto3 JSON parser should be + * able to accept both UTC and other timezones (as indicated by an offset). + * + * For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past + * 01:30 UTC on January 15, 2017. + * + * In JavaScript, one can convert a Date object to this format using the + * standard + * [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString) + * method. In Python, a standard `datetime.datetime` object can be converted + * to this format using + * [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) with + * the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one can use + * the Joda Time's [`ISODateTimeFormat.dateTime()`]( + * http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime%2D%2D + * ) to obtain a formatter capable of generating timestamps in this format. + */ +export interface Timestamp { + /** + * Represents seconds of UTC time since Unix epoch + * 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to + * 9999-12-31T23:59:59Z inclusive. + */ + seconds: number; + /** + * Non-negative fractions of a second at nanosecond resolution. Negative + * second values with fractions must still have non-negative nanos values + * that count forward in time. Must be from 0 to 999,999,999 + * inclusive. + */ + nanos: number; +} + +const baseTimestamp: object = { seconds: 0, nanos: 0 }; + +export const Timestamp = { + encode(message: Timestamp, writer: Writer = Writer.create()): Writer { + if (message.seconds !== 0) { + writer.uint32(8).int64(message.seconds); + } + if (message.nanos !== 0) { + writer.uint32(16).int32(message.nanos); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Timestamp { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseTimestamp } as Timestamp; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.seconds = longToNumber(reader.int64() as Long); + break; + case 2: + message.nanos = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Timestamp { + const message = { ...baseTimestamp } as Timestamp; + if (object.seconds !== undefined && object.seconds !== null) { + message.seconds = Number(object.seconds); + } else { + message.seconds = 0; + } + if (object.nanos !== undefined && object.nanos !== null) { + message.nanos = Number(object.nanos); + } else { + message.nanos = 0; + } + return message; + }, + + toJSON(message: Timestamp): unknown { + const obj: any = {}; + message.seconds !== undefined && (obj.seconds = message.seconds); + message.nanos !== undefined && (obj.nanos = message.nanos); + return obj; + }, + + fromPartial(object: DeepPartial): Timestamp { + const message = { ...baseTimestamp } as Timestamp; + if (object.seconds !== undefined && object.seconds !== null) { + message.seconds = object.seconds; + } else { + message.seconds = 0; + } + if (object.nanos !== undefined && object.nanos !== null) { + message.nanos = object.nanos; + } else { + message.nanos = 0; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/cosmos.staking.v1beta1/types/tendermint/crypto/keys.ts b/ts-client/cosmos.staking.v1beta1/types/tendermint/crypto/keys.ts new file mode 100644 index 00000000..d530b047 --- /dev/null +++ b/ts-client/cosmos.staking.v1beta1/types/tendermint/crypto/keys.ts @@ -0,0 +1,130 @@ +/* eslint-disable */ +import { Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "tendermint.crypto"; + +/** PublicKey defines the keys available for use with Validators */ +export interface PublicKey { + ed25519: Uint8Array | undefined; + secp256k1: Uint8Array | undefined; +} + +const basePublicKey: object = {}; + +export const PublicKey = { + encode(message: PublicKey, writer: Writer = Writer.create()): Writer { + if (message.ed25519 !== undefined) { + writer.uint32(10).bytes(message.ed25519); + } + if (message.secp256k1 !== undefined) { + writer.uint32(18).bytes(message.secp256k1); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): PublicKey { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...basePublicKey } as PublicKey; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.ed25519 = reader.bytes(); + break; + case 2: + message.secp256k1 = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): PublicKey { + const message = { ...basePublicKey } as PublicKey; + if (object.ed25519 !== undefined && object.ed25519 !== null) { + message.ed25519 = bytesFromBase64(object.ed25519); + } + if (object.secp256k1 !== undefined && object.secp256k1 !== null) { + message.secp256k1 = bytesFromBase64(object.secp256k1); + } + return message; + }, + + toJSON(message: PublicKey): unknown { + const obj: any = {}; + message.ed25519 !== undefined && + (obj.ed25519 = + message.ed25519 !== undefined + ? base64FromBytes(message.ed25519) + : undefined); + message.secp256k1 !== undefined && + (obj.secp256k1 = + message.secp256k1 !== undefined + ? base64FromBytes(message.secp256k1) + : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): PublicKey { + const message = { ...basePublicKey } as PublicKey; + if (object.ed25519 !== undefined && object.ed25519 !== null) { + message.ed25519 = object.ed25519; + } else { + message.ed25519 = undefined; + } + if (object.secp256k1 !== undefined && object.secp256k1 !== null) { + message.secp256k1 = object.secp256k1; + } else { + message.secp256k1 = undefined; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/cosmos.staking.v1beta1/types/tendermint/crypto/proof.ts b/ts-client/cosmos.staking.v1beta1/types/tendermint/crypto/proof.ts new file mode 100644 index 00000000..dae51600 --- /dev/null +++ b/ts-client/cosmos.staking.v1beta1/types/tendermint/crypto/proof.ts @@ -0,0 +1,529 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "tendermint.crypto"; + +export interface Proof { + total: number; + index: number; + leafHash: Uint8Array; + aunts: Uint8Array[]; +} + +export interface ValueOp { + /** Encoded in ProofOp.Key. */ + key: Uint8Array; + /** To encode in ProofOp.Data */ + proof: Proof | undefined; +} + +export interface DominoOp { + key: string; + input: string; + output: string; +} + +/** + * ProofOp defines an operation used for calculating Merkle root + * The data could be arbitrary format, providing nessecary data + * for example neighbouring node hash + */ +export interface ProofOp { + type: string; + key: Uint8Array; + data: Uint8Array; +} + +/** ProofOps is Merkle proof defined by the list of ProofOps */ +export interface ProofOps { + ops: ProofOp[]; +} + +const baseProof: object = { total: 0, index: 0 }; + +export const Proof = { + encode(message: Proof, writer: Writer = Writer.create()): Writer { + if (message.total !== 0) { + writer.uint32(8).int64(message.total); + } + if (message.index !== 0) { + writer.uint32(16).int64(message.index); + } + if (message.leafHash.length !== 0) { + writer.uint32(26).bytes(message.leafHash); + } + for (const v of message.aunts) { + writer.uint32(34).bytes(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Proof { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseProof } as Proof; + message.aunts = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.total = longToNumber(reader.int64() as Long); + break; + case 2: + message.index = longToNumber(reader.int64() as Long); + break; + case 3: + message.leafHash = reader.bytes(); + break; + case 4: + message.aunts.push(reader.bytes()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Proof { + const message = { ...baseProof } as Proof; + message.aunts = []; + if (object.total !== undefined && object.total !== null) { + message.total = Number(object.total); + } else { + message.total = 0; + } + if (object.index !== undefined && object.index !== null) { + message.index = Number(object.index); + } else { + message.index = 0; + } + if (object.leafHash !== undefined && object.leafHash !== null) { + message.leafHash = bytesFromBase64(object.leafHash); + } + if (object.aunts !== undefined && object.aunts !== null) { + for (const e of object.aunts) { + message.aunts.push(bytesFromBase64(e)); + } + } + return message; + }, + + toJSON(message: Proof): unknown { + const obj: any = {}; + message.total !== undefined && (obj.total = message.total); + message.index !== undefined && (obj.index = message.index); + message.leafHash !== undefined && + (obj.leafHash = base64FromBytes( + message.leafHash !== undefined ? message.leafHash : new Uint8Array() + )); + if (message.aunts) { + obj.aunts = message.aunts.map((e) => + base64FromBytes(e !== undefined ? e : new Uint8Array()) + ); + } else { + obj.aunts = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): Proof { + const message = { ...baseProof } as Proof; + message.aunts = []; + if (object.total !== undefined && object.total !== null) { + message.total = object.total; + } else { + message.total = 0; + } + if (object.index !== undefined && object.index !== null) { + message.index = object.index; + } else { + message.index = 0; + } + if (object.leafHash !== undefined && object.leafHash !== null) { + message.leafHash = object.leafHash; + } else { + message.leafHash = new Uint8Array(); + } + if (object.aunts !== undefined && object.aunts !== null) { + for (const e of object.aunts) { + message.aunts.push(e); + } + } + return message; + }, +}; + +const baseValueOp: object = {}; + +export const ValueOp = { + encode(message: ValueOp, writer: Writer = Writer.create()): Writer { + if (message.key.length !== 0) { + writer.uint32(10).bytes(message.key); + } + if (message.proof !== undefined) { + Proof.encode(message.proof, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ValueOp { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseValueOp } as ValueOp; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.key = reader.bytes(); + break; + case 2: + message.proof = Proof.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ValueOp { + const message = { ...baseValueOp } as ValueOp; + if (object.key !== undefined && object.key !== null) { + message.key = bytesFromBase64(object.key); + } + if (object.proof !== undefined && object.proof !== null) { + message.proof = Proof.fromJSON(object.proof); + } else { + message.proof = undefined; + } + return message; + }, + + toJSON(message: ValueOp): unknown { + const obj: any = {}; + message.key !== undefined && + (obj.key = base64FromBytes( + message.key !== undefined ? message.key : new Uint8Array() + )); + message.proof !== undefined && + (obj.proof = message.proof ? Proof.toJSON(message.proof) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): ValueOp { + const message = { ...baseValueOp } as ValueOp; + if (object.key !== undefined && object.key !== null) { + message.key = object.key; + } else { + message.key = new Uint8Array(); + } + if (object.proof !== undefined && object.proof !== null) { + message.proof = Proof.fromPartial(object.proof); + } else { + message.proof = undefined; + } + return message; + }, +}; + +const baseDominoOp: object = { key: "", input: "", output: "" }; + +export const DominoOp = { + encode(message: DominoOp, writer: Writer = Writer.create()): Writer { + if (message.key !== "") { + writer.uint32(10).string(message.key); + } + if (message.input !== "") { + writer.uint32(18).string(message.input); + } + if (message.output !== "") { + writer.uint32(26).string(message.output); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): DominoOp { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseDominoOp } as DominoOp; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.key = reader.string(); + break; + case 2: + message.input = reader.string(); + break; + case 3: + message.output = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DominoOp { + const message = { ...baseDominoOp } as DominoOp; + if (object.key !== undefined && object.key !== null) { + message.key = String(object.key); + } else { + message.key = ""; + } + if (object.input !== undefined && object.input !== null) { + message.input = String(object.input); + } else { + message.input = ""; + } + if (object.output !== undefined && object.output !== null) { + message.output = String(object.output); + } else { + message.output = ""; + } + return message; + }, + + toJSON(message: DominoOp): unknown { + const obj: any = {}; + message.key !== undefined && (obj.key = message.key); + message.input !== undefined && (obj.input = message.input); + message.output !== undefined && (obj.output = message.output); + return obj; + }, + + fromPartial(object: DeepPartial): DominoOp { + const message = { ...baseDominoOp } as DominoOp; + if (object.key !== undefined && object.key !== null) { + message.key = object.key; + } else { + message.key = ""; + } + if (object.input !== undefined && object.input !== null) { + message.input = object.input; + } else { + message.input = ""; + } + if (object.output !== undefined && object.output !== null) { + message.output = object.output; + } else { + message.output = ""; + } + return message; + }, +}; + +const baseProofOp: object = { type: "" }; + +export const ProofOp = { + encode(message: ProofOp, writer: Writer = Writer.create()): Writer { + if (message.type !== "") { + writer.uint32(10).string(message.type); + } + if (message.key.length !== 0) { + writer.uint32(18).bytes(message.key); + } + if (message.data.length !== 0) { + writer.uint32(26).bytes(message.data); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ProofOp { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseProofOp } as ProofOp; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.type = reader.string(); + break; + case 2: + message.key = reader.bytes(); + break; + case 3: + message.data = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ProofOp { + const message = { ...baseProofOp } as ProofOp; + if (object.type !== undefined && object.type !== null) { + message.type = String(object.type); + } else { + message.type = ""; + } + if (object.key !== undefined && object.key !== null) { + message.key = bytesFromBase64(object.key); + } + if (object.data !== undefined && object.data !== null) { + message.data = bytesFromBase64(object.data); + } + return message; + }, + + toJSON(message: ProofOp): unknown { + const obj: any = {}; + message.type !== undefined && (obj.type = message.type); + message.key !== undefined && + (obj.key = base64FromBytes( + message.key !== undefined ? message.key : new Uint8Array() + )); + message.data !== undefined && + (obj.data = base64FromBytes( + message.data !== undefined ? message.data : new Uint8Array() + )); + return obj; + }, + + fromPartial(object: DeepPartial): ProofOp { + const message = { ...baseProofOp } as ProofOp; + if (object.type !== undefined && object.type !== null) { + message.type = object.type; + } else { + message.type = ""; + } + if (object.key !== undefined && object.key !== null) { + message.key = object.key; + } else { + message.key = new Uint8Array(); + } + if (object.data !== undefined && object.data !== null) { + message.data = object.data; + } else { + message.data = new Uint8Array(); + } + return message; + }, +}; + +const baseProofOps: object = {}; + +export const ProofOps = { + encode(message: ProofOps, writer: Writer = Writer.create()): Writer { + for (const v of message.ops) { + ProofOp.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ProofOps { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseProofOps } as ProofOps; + message.ops = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.ops.push(ProofOp.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ProofOps { + const message = { ...baseProofOps } as ProofOps; + message.ops = []; + if (object.ops !== undefined && object.ops !== null) { + for (const e of object.ops) { + message.ops.push(ProofOp.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: ProofOps): unknown { + const obj: any = {}; + if (message.ops) { + obj.ops = message.ops.map((e) => (e ? ProofOp.toJSON(e) : undefined)); + } else { + obj.ops = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): ProofOps { + const message = { ...baseProofOps } as ProofOps; + message.ops = []; + if (object.ops !== undefined && object.ops !== null) { + for (const e of object.ops) { + message.ops.push(ProofOp.fromPartial(e)); + } + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/cosmos.staking.v1beta1/types/tendermint/types/types.ts b/ts-client/cosmos.staking.v1beta1/types/tendermint/types/types.ts new file mode 100644 index 00000000..429c14a4 --- /dev/null +++ b/ts-client/cosmos.staking.v1beta1/types/tendermint/types/types.ts @@ -0,0 +1,1912 @@ +/* eslint-disable */ +import { Timestamp } from "../../google/protobuf/timestamp"; +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; +import { Proof } from "../../tendermint/crypto/proof"; +import { Consensus } from "../../tendermint/version/types"; +import { ValidatorSet } from "../../tendermint/types/validator"; + +export const protobufPackage = "tendermint.types"; + +/** BlockIdFlag indicates which BlcokID the signature is for */ +export enum BlockIDFlag { + BLOCK_ID_FLAG_UNKNOWN = 0, + BLOCK_ID_FLAG_ABSENT = 1, + BLOCK_ID_FLAG_COMMIT = 2, + BLOCK_ID_FLAG_NIL = 3, + UNRECOGNIZED = -1, +} + +export function blockIDFlagFromJSON(object: any): BlockIDFlag { + switch (object) { + case 0: + case "BLOCK_ID_FLAG_UNKNOWN": + return BlockIDFlag.BLOCK_ID_FLAG_UNKNOWN; + case 1: + case "BLOCK_ID_FLAG_ABSENT": + return BlockIDFlag.BLOCK_ID_FLAG_ABSENT; + case 2: + case "BLOCK_ID_FLAG_COMMIT": + return BlockIDFlag.BLOCK_ID_FLAG_COMMIT; + case 3: + case "BLOCK_ID_FLAG_NIL": + return BlockIDFlag.BLOCK_ID_FLAG_NIL; + case -1: + case "UNRECOGNIZED": + default: + return BlockIDFlag.UNRECOGNIZED; + } +} + +export function blockIDFlagToJSON(object: BlockIDFlag): string { + switch (object) { + case BlockIDFlag.BLOCK_ID_FLAG_UNKNOWN: + return "BLOCK_ID_FLAG_UNKNOWN"; + case BlockIDFlag.BLOCK_ID_FLAG_ABSENT: + return "BLOCK_ID_FLAG_ABSENT"; + case BlockIDFlag.BLOCK_ID_FLAG_COMMIT: + return "BLOCK_ID_FLAG_COMMIT"; + case BlockIDFlag.BLOCK_ID_FLAG_NIL: + return "BLOCK_ID_FLAG_NIL"; + default: + return "UNKNOWN"; + } +} + +/** SignedMsgType is a type of signed message in the consensus. */ +export enum SignedMsgType { + SIGNED_MSG_TYPE_UNKNOWN = 0, + /** SIGNED_MSG_TYPE_PREVOTE - Votes */ + SIGNED_MSG_TYPE_PREVOTE = 1, + SIGNED_MSG_TYPE_PRECOMMIT = 2, + /** SIGNED_MSG_TYPE_PROPOSAL - Proposals */ + SIGNED_MSG_TYPE_PROPOSAL = 32, + UNRECOGNIZED = -1, +} + +export function signedMsgTypeFromJSON(object: any): SignedMsgType { + switch (object) { + case 0: + case "SIGNED_MSG_TYPE_UNKNOWN": + return SignedMsgType.SIGNED_MSG_TYPE_UNKNOWN; + case 1: + case "SIGNED_MSG_TYPE_PREVOTE": + return SignedMsgType.SIGNED_MSG_TYPE_PREVOTE; + case 2: + case "SIGNED_MSG_TYPE_PRECOMMIT": + return SignedMsgType.SIGNED_MSG_TYPE_PRECOMMIT; + case 32: + case "SIGNED_MSG_TYPE_PROPOSAL": + return SignedMsgType.SIGNED_MSG_TYPE_PROPOSAL; + case -1: + case "UNRECOGNIZED": + default: + return SignedMsgType.UNRECOGNIZED; + } +} + +export function signedMsgTypeToJSON(object: SignedMsgType): string { + switch (object) { + case SignedMsgType.SIGNED_MSG_TYPE_UNKNOWN: + return "SIGNED_MSG_TYPE_UNKNOWN"; + case SignedMsgType.SIGNED_MSG_TYPE_PREVOTE: + return "SIGNED_MSG_TYPE_PREVOTE"; + case SignedMsgType.SIGNED_MSG_TYPE_PRECOMMIT: + return "SIGNED_MSG_TYPE_PRECOMMIT"; + case SignedMsgType.SIGNED_MSG_TYPE_PROPOSAL: + return "SIGNED_MSG_TYPE_PROPOSAL"; + default: + return "UNKNOWN"; + } +} + +/** PartsetHeader */ +export interface PartSetHeader { + total: number; + hash: Uint8Array; +} + +export interface Part { + index: number; + bytes: Uint8Array; + proof: Proof | undefined; +} + +/** BlockID */ +export interface BlockID { + hash: Uint8Array; + partSetHeader: PartSetHeader | undefined; +} + +/** Header defines the structure of a block header. */ +export interface Header { + /** basic block info */ + version: Consensus | undefined; + chainId: string; + height: number; + time: Date | undefined; + /** prev block info */ + lastBlockId: BlockID | undefined; + /** hashes of block data */ + lastCommitHash: Uint8Array; + /** transactions */ + dataHash: Uint8Array; + /** hashes from the app output from the prev block */ + validatorsHash: Uint8Array; + /** validators for the next block */ + nextValidatorsHash: Uint8Array; + /** consensus params for current block */ + consensusHash: Uint8Array; + /** state after txs from the previous block */ + appHash: Uint8Array; + /** root hash of all results from the txs from the previous block */ + lastResultsHash: Uint8Array; + /** consensus info */ + evidenceHash: Uint8Array; + /** original proposer of the block */ + proposerAddress: Uint8Array; +} + +/** Data contains the set of transactions included in the block */ +export interface Data { + /** + * Txs that will be applied by state @ block.Height+1. + * NOTE: not all txs here are valid. We're just agreeing on the order first. + * This means that block.AppHash does not include these txs. + */ + txs: Uint8Array[]; +} + +/** + * Vote represents a prevote, precommit, or commit vote from validators for + * consensus. + */ +export interface Vote { + type: SignedMsgType; + height: number; + round: number; + /** zero if vote is nil. */ + blockId: BlockID | undefined; + timestamp: Date | undefined; + validatorAddress: Uint8Array; + validatorIndex: number; + signature: Uint8Array; +} + +/** Commit contains the evidence that a block was committed by a set of validators. */ +export interface Commit { + height: number; + round: number; + blockId: BlockID | undefined; + signatures: CommitSig[]; +} + +/** CommitSig is a part of the Vote included in a Commit. */ +export interface CommitSig { + blockIdFlag: BlockIDFlag; + validatorAddress: Uint8Array; + timestamp: Date | undefined; + signature: Uint8Array; +} + +export interface Proposal { + type: SignedMsgType; + height: number; + round: number; + polRound: number; + blockId: BlockID | undefined; + timestamp: Date | undefined; + signature: Uint8Array; +} + +export interface SignedHeader { + header: Header | undefined; + commit: Commit | undefined; +} + +export interface LightBlock { + signedHeader: SignedHeader | undefined; + validatorSet: ValidatorSet | undefined; +} + +export interface BlockMeta { + blockId: BlockID | undefined; + blockSize: number; + header: Header | undefined; + numTxs: number; +} + +/** TxProof represents a Merkle proof of the presence of a transaction in the Merkle tree. */ +export interface TxProof { + rootHash: Uint8Array; + data: Uint8Array; + proof: Proof | undefined; +} + +const basePartSetHeader: object = { total: 0 }; + +export const PartSetHeader = { + encode(message: PartSetHeader, writer: Writer = Writer.create()): Writer { + if (message.total !== 0) { + writer.uint32(8).uint32(message.total); + } + if (message.hash.length !== 0) { + writer.uint32(18).bytes(message.hash); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): PartSetHeader { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...basePartSetHeader } as PartSetHeader; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.total = reader.uint32(); + break; + case 2: + message.hash = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): PartSetHeader { + const message = { ...basePartSetHeader } as PartSetHeader; + if (object.total !== undefined && object.total !== null) { + message.total = Number(object.total); + } else { + message.total = 0; + } + if (object.hash !== undefined && object.hash !== null) { + message.hash = bytesFromBase64(object.hash); + } + return message; + }, + + toJSON(message: PartSetHeader): unknown { + const obj: any = {}; + message.total !== undefined && (obj.total = message.total); + message.hash !== undefined && + (obj.hash = base64FromBytes( + message.hash !== undefined ? message.hash : new Uint8Array() + )); + return obj; + }, + + fromPartial(object: DeepPartial): PartSetHeader { + const message = { ...basePartSetHeader } as PartSetHeader; + if (object.total !== undefined && object.total !== null) { + message.total = object.total; + } else { + message.total = 0; + } + if (object.hash !== undefined && object.hash !== null) { + message.hash = object.hash; + } else { + message.hash = new Uint8Array(); + } + return message; + }, +}; + +const basePart: object = { index: 0 }; + +export const Part = { + encode(message: Part, writer: Writer = Writer.create()): Writer { + if (message.index !== 0) { + writer.uint32(8).uint32(message.index); + } + if (message.bytes.length !== 0) { + writer.uint32(18).bytes(message.bytes); + } + if (message.proof !== undefined) { + Proof.encode(message.proof, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Part { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...basePart } as Part; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.index = reader.uint32(); + break; + case 2: + message.bytes = reader.bytes(); + break; + case 3: + message.proof = Proof.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Part { + const message = { ...basePart } as Part; + if (object.index !== undefined && object.index !== null) { + message.index = Number(object.index); + } else { + message.index = 0; + } + if (object.bytes !== undefined && object.bytes !== null) { + message.bytes = bytesFromBase64(object.bytes); + } + if (object.proof !== undefined && object.proof !== null) { + message.proof = Proof.fromJSON(object.proof); + } else { + message.proof = undefined; + } + return message; + }, + + toJSON(message: Part): unknown { + const obj: any = {}; + message.index !== undefined && (obj.index = message.index); + message.bytes !== undefined && + (obj.bytes = base64FromBytes( + message.bytes !== undefined ? message.bytes : new Uint8Array() + )); + message.proof !== undefined && + (obj.proof = message.proof ? Proof.toJSON(message.proof) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): Part { + const message = { ...basePart } as Part; + if (object.index !== undefined && object.index !== null) { + message.index = object.index; + } else { + message.index = 0; + } + if (object.bytes !== undefined && object.bytes !== null) { + message.bytes = object.bytes; + } else { + message.bytes = new Uint8Array(); + } + if (object.proof !== undefined && object.proof !== null) { + message.proof = Proof.fromPartial(object.proof); + } else { + message.proof = undefined; + } + return message; + }, +}; + +const baseBlockID: object = {}; + +export const BlockID = { + encode(message: BlockID, writer: Writer = Writer.create()): Writer { + if (message.hash.length !== 0) { + writer.uint32(10).bytes(message.hash); + } + if (message.partSetHeader !== undefined) { + PartSetHeader.encode( + message.partSetHeader, + writer.uint32(18).fork() + ).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): BlockID { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseBlockID } as BlockID; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.hash = reader.bytes(); + break; + case 2: + message.partSetHeader = PartSetHeader.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): BlockID { + const message = { ...baseBlockID } as BlockID; + if (object.hash !== undefined && object.hash !== null) { + message.hash = bytesFromBase64(object.hash); + } + if (object.partSetHeader !== undefined && object.partSetHeader !== null) { + message.partSetHeader = PartSetHeader.fromJSON(object.partSetHeader); + } else { + message.partSetHeader = undefined; + } + return message; + }, + + toJSON(message: BlockID): unknown { + const obj: any = {}; + message.hash !== undefined && + (obj.hash = base64FromBytes( + message.hash !== undefined ? message.hash : new Uint8Array() + )); + message.partSetHeader !== undefined && + (obj.partSetHeader = message.partSetHeader + ? PartSetHeader.toJSON(message.partSetHeader) + : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): BlockID { + const message = { ...baseBlockID } as BlockID; + if (object.hash !== undefined && object.hash !== null) { + message.hash = object.hash; + } else { + message.hash = new Uint8Array(); + } + if (object.partSetHeader !== undefined && object.partSetHeader !== null) { + message.partSetHeader = PartSetHeader.fromPartial(object.partSetHeader); + } else { + message.partSetHeader = undefined; + } + return message; + }, +}; + +const baseHeader: object = { chainId: "", height: 0 }; + +export const Header = { + encode(message: Header, writer: Writer = Writer.create()): Writer { + if (message.version !== undefined) { + Consensus.encode(message.version, writer.uint32(10).fork()).ldelim(); + } + if (message.chainId !== "") { + writer.uint32(18).string(message.chainId); + } + if (message.height !== 0) { + writer.uint32(24).int64(message.height); + } + if (message.time !== undefined) { + Timestamp.encode( + toTimestamp(message.time), + writer.uint32(34).fork() + ).ldelim(); + } + if (message.lastBlockId !== undefined) { + BlockID.encode(message.lastBlockId, writer.uint32(42).fork()).ldelim(); + } + if (message.lastCommitHash.length !== 0) { + writer.uint32(50).bytes(message.lastCommitHash); + } + if (message.dataHash.length !== 0) { + writer.uint32(58).bytes(message.dataHash); + } + if (message.validatorsHash.length !== 0) { + writer.uint32(66).bytes(message.validatorsHash); + } + if (message.nextValidatorsHash.length !== 0) { + writer.uint32(74).bytes(message.nextValidatorsHash); + } + if (message.consensusHash.length !== 0) { + writer.uint32(82).bytes(message.consensusHash); + } + if (message.appHash.length !== 0) { + writer.uint32(90).bytes(message.appHash); + } + if (message.lastResultsHash.length !== 0) { + writer.uint32(98).bytes(message.lastResultsHash); + } + if (message.evidenceHash.length !== 0) { + writer.uint32(106).bytes(message.evidenceHash); + } + if (message.proposerAddress.length !== 0) { + writer.uint32(114).bytes(message.proposerAddress); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Header { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseHeader } as Header; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.version = Consensus.decode(reader, reader.uint32()); + break; + case 2: + message.chainId = reader.string(); + break; + case 3: + message.height = longToNumber(reader.int64() as Long); + break; + case 4: + message.time = fromTimestamp( + Timestamp.decode(reader, reader.uint32()) + ); + break; + case 5: + message.lastBlockId = BlockID.decode(reader, reader.uint32()); + break; + case 6: + message.lastCommitHash = reader.bytes(); + break; + case 7: + message.dataHash = reader.bytes(); + break; + case 8: + message.validatorsHash = reader.bytes(); + break; + case 9: + message.nextValidatorsHash = reader.bytes(); + break; + case 10: + message.consensusHash = reader.bytes(); + break; + case 11: + message.appHash = reader.bytes(); + break; + case 12: + message.lastResultsHash = reader.bytes(); + break; + case 13: + message.evidenceHash = reader.bytes(); + break; + case 14: + message.proposerAddress = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Header { + const message = { ...baseHeader } as Header; + if (object.version !== undefined && object.version !== null) { + message.version = Consensus.fromJSON(object.version); + } else { + message.version = undefined; + } + if (object.chainId !== undefined && object.chainId !== null) { + message.chainId = String(object.chainId); + } else { + message.chainId = ""; + } + if (object.height !== undefined && object.height !== null) { + message.height = Number(object.height); + } else { + message.height = 0; + } + if (object.time !== undefined && object.time !== null) { + message.time = fromJsonTimestamp(object.time); + } else { + message.time = undefined; + } + if (object.lastBlockId !== undefined && object.lastBlockId !== null) { + message.lastBlockId = BlockID.fromJSON(object.lastBlockId); + } else { + message.lastBlockId = undefined; + } + if (object.lastCommitHash !== undefined && object.lastCommitHash !== null) { + message.lastCommitHash = bytesFromBase64(object.lastCommitHash); + } + if (object.dataHash !== undefined && object.dataHash !== null) { + message.dataHash = bytesFromBase64(object.dataHash); + } + if (object.validatorsHash !== undefined && object.validatorsHash !== null) { + message.validatorsHash = bytesFromBase64(object.validatorsHash); + } + if ( + object.nextValidatorsHash !== undefined && + object.nextValidatorsHash !== null + ) { + message.nextValidatorsHash = bytesFromBase64(object.nextValidatorsHash); + } + if (object.consensusHash !== undefined && object.consensusHash !== null) { + message.consensusHash = bytesFromBase64(object.consensusHash); + } + if (object.appHash !== undefined && object.appHash !== null) { + message.appHash = bytesFromBase64(object.appHash); + } + if ( + object.lastResultsHash !== undefined && + object.lastResultsHash !== null + ) { + message.lastResultsHash = bytesFromBase64(object.lastResultsHash); + } + if (object.evidenceHash !== undefined && object.evidenceHash !== null) { + message.evidenceHash = bytesFromBase64(object.evidenceHash); + } + if ( + object.proposerAddress !== undefined && + object.proposerAddress !== null + ) { + message.proposerAddress = bytesFromBase64(object.proposerAddress); + } + return message; + }, + + toJSON(message: Header): unknown { + const obj: any = {}; + message.version !== undefined && + (obj.version = message.version + ? Consensus.toJSON(message.version) + : undefined); + message.chainId !== undefined && (obj.chainId = message.chainId); + message.height !== undefined && (obj.height = message.height); + message.time !== undefined && + (obj.time = + message.time !== undefined ? message.time.toISOString() : null); + message.lastBlockId !== undefined && + (obj.lastBlockId = message.lastBlockId + ? BlockID.toJSON(message.lastBlockId) + : undefined); + message.lastCommitHash !== undefined && + (obj.lastCommitHash = base64FromBytes( + message.lastCommitHash !== undefined + ? message.lastCommitHash + : new Uint8Array() + )); + message.dataHash !== undefined && + (obj.dataHash = base64FromBytes( + message.dataHash !== undefined ? message.dataHash : new Uint8Array() + )); + message.validatorsHash !== undefined && + (obj.validatorsHash = base64FromBytes( + message.validatorsHash !== undefined + ? message.validatorsHash + : new Uint8Array() + )); + message.nextValidatorsHash !== undefined && + (obj.nextValidatorsHash = base64FromBytes( + message.nextValidatorsHash !== undefined + ? message.nextValidatorsHash + : new Uint8Array() + )); + message.consensusHash !== undefined && + (obj.consensusHash = base64FromBytes( + message.consensusHash !== undefined + ? message.consensusHash + : new Uint8Array() + )); + message.appHash !== undefined && + (obj.appHash = base64FromBytes( + message.appHash !== undefined ? message.appHash : new Uint8Array() + )); + message.lastResultsHash !== undefined && + (obj.lastResultsHash = base64FromBytes( + message.lastResultsHash !== undefined + ? message.lastResultsHash + : new Uint8Array() + )); + message.evidenceHash !== undefined && + (obj.evidenceHash = base64FromBytes( + message.evidenceHash !== undefined + ? message.evidenceHash + : new Uint8Array() + )); + message.proposerAddress !== undefined && + (obj.proposerAddress = base64FromBytes( + message.proposerAddress !== undefined + ? message.proposerAddress + : new Uint8Array() + )); + return obj; + }, + + fromPartial(object: DeepPartial
): Header { + const message = { ...baseHeader } as Header; + if (object.version !== undefined && object.version !== null) { + message.version = Consensus.fromPartial(object.version); + } else { + message.version = undefined; + } + if (object.chainId !== undefined && object.chainId !== null) { + message.chainId = object.chainId; + } else { + message.chainId = ""; + } + if (object.height !== undefined && object.height !== null) { + message.height = object.height; + } else { + message.height = 0; + } + if (object.time !== undefined && object.time !== null) { + message.time = object.time; + } else { + message.time = undefined; + } + if (object.lastBlockId !== undefined && object.lastBlockId !== null) { + message.lastBlockId = BlockID.fromPartial(object.lastBlockId); + } else { + message.lastBlockId = undefined; + } + if (object.lastCommitHash !== undefined && object.lastCommitHash !== null) { + message.lastCommitHash = object.lastCommitHash; + } else { + message.lastCommitHash = new Uint8Array(); + } + if (object.dataHash !== undefined && object.dataHash !== null) { + message.dataHash = object.dataHash; + } else { + message.dataHash = new Uint8Array(); + } + if (object.validatorsHash !== undefined && object.validatorsHash !== null) { + message.validatorsHash = object.validatorsHash; + } else { + message.validatorsHash = new Uint8Array(); + } + if ( + object.nextValidatorsHash !== undefined && + object.nextValidatorsHash !== null + ) { + message.nextValidatorsHash = object.nextValidatorsHash; + } else { + message.nextValidatorsHash = new Uint8Array(); + } + if (object.consensusHash !== undefined && object.consensusHash !== null) { + message.consensusHash = object.consensusHash; + } else { + message.consensusHash = new Uint8Array(); + } + if (object.appHash !== undefined && object.appHash !== null) { + message.appHash = object.appHash; + } else { + message.appHash = new Uint8Array(); + } + if ( + object.lastResultsHash !== undefined && + object.lastResultsHash !== null + ) { + message.lastResultsHash = object.lastResultsHash; + } else { + message.lastResultsHash = new Uint8Array(); + } + if (object.evidenceHash !== undefined && object.evidenceHash !== null) { + message.evidenceHash = object.evidenceHash; + } else { + message.evidenceHash = new Uint8Array(); + } + if ( + object.proposerAddress !== undefined && + object.proposerAddress !== null + ) { + message.proposerAddress = object.proposerAddress; + } else { + message.proposerAddress = new Uint8Array(); + } + return message; + }, +}; + +const baseData: object = {}; + +export const Data = { + encode(message: Data, writer: Writer = Writer.create()): Writer { + for (const v of message.txs) { + writer.uint32(10).bytes(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Data { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseData } as Data; + message.txs = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.txs.push(reader.bytes()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Data { + const message = { ...baseData } as Data; + message.txs = []; + if (object.txs !== undefined && object.txs !== null) { + for (const e of object.txs) { + message.txs.push(bytesFromBase64(e)); + } + } + return message; + }, + + toJSON(message: Data): unknown { + const obj: any = {}; + if (message.txs) { + obj.txs = message.txs.map((e) => + base64FromBytes(e !== undefined ? e : new Uint8Array()) + ); + } else { + obj.txs = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): Data { + const message = { ...baseData } as Data; + message.txs = []; + if (object.txs !== undefined && object.txs !== null) { + for (const e of object.txs) { + message.txs.push(e); + } + } + return message; + }, +}; + +const baseVote: object = { type: 0, height: 0, round: 0, validatorIndex: 0 }; + +export const Vote = { + encode(message: Vote, writer: Writer = Writer.create()): Writer { + if (message.type !== 0) { + writer.uint32(8).int32(message.type); + } + if (message.height !== 0) { + writer.uint32(16).int64(message.height); + } + if (message.round !== 0) { + writer.uint32(24).int32(message.round); + } + if (message.blockId !== undefined) { + BlockID.encode(message.blockId, writer.uint32(34).fork()).ldelim(); + } + if (message.timestamp !== undefined) { + Timestamp.encode( + toTimestamp(message.timestamp), + writer.uint32(42).fork() + ).ldelim(); + } + if (message.validatorAddress.length !== 0) { + writer.uint32(50).bytes(message.validatorAddress); + } + if (message.validatorIndex !== 0) { + writer.uint32(56).int32(message.validatorIndex); + } + if (message.signature.length !== 0) { + writer.uint32(66).bytes(message.signature); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Vote { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseVote } as Vote; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.type = reader.int32() as any; + break; + case 2: + message.height = longToNumber(reader.int64() as Long); + break; + case 3: + message.round = reader.int32(); + break; + case 4: + message.blockId = BlockID.decode(reader, reader.uint32()); + break; + case 5: + message.timestamp = fromTimestamp( + Timestamp.decode(reader, reader.uint32()) + ); + break; + case 6: + message.validatorAddress = reader.bytes(); + break; + case 7: + message.validatorIndex = reader.int32(); + break; + case 8: + message.signature = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Vote { + const message = { ...baseVote } as Vote; + if (object.type !== undefined && object.type !== null) { + message.type = signedMsgTypeFromJSON(object.type); + } else { + message.type = 0; + } + if (object.height !== undefined && object.height !== null) { + message.height = Number(object.height); + } else { + message.height = 0; + } + if (object.round !== undefined && object.round !== null) { + message.round = Number(object.round); + } else { + message.round = 0; + } + if (object.blockId !== undefined && object.blockId !== null) { + message.blockId = BlockID.fromJSON(object.blockId); + } else { + message.blockId = undefined; + } + if (object.timestamp !== undefined && object.timestamp !== null) { + message.timestamp = fromJsonTimestamp(object.timestamp); + } else { + message.timestamp = undefined; + } + if ( + object.validatorAddress !== undefined && + object.validatorAddress !== null + ) { + message.validatorAddress = bytesFromBase64(object.validatorAddress); + } + if (object.validatorIndex !== undefined && object.validatorIndex !== null) { + message.validatorIndex = Number(object.validatorIndex); + } else { + message.validatorIndex = 0; + } + if (object.signature !== undefined && object.signature !== null) { + message.signature = bytesFromBase64(object.signature); + } + return message; + }, + + toJSON(message: Vote): unknown { + const obj: any = {}; + message.type !== undefined && + (obj.type = signedMsgTypeToJSON(message.type)); + message.height !== undefined && (obj.height = message.height); + message.round !== undefined && (obj.round = message.round); + message.blockId !== undefined && + (obj.blockId = message.blockId + ? BlockID.toJSON(message.blockId) + : undefined); + message.timestamp !== undefined && + (obj.timestamp = + message.timestamp !== undefined + ? message.timestamp.toISOString() + : null); + message.validatorAddress !== undefined && + (obj.validatorAddress = base64FromBytes( + message.validatorAddress !== undefined + ? message.validatorAddress + : new Uint8Array() + )); + message.validatorIndex !== undefined && + (obj.validatorIndex = message.validatorIndex); + message.signature !== undefined && + (obj.signature = base64FromBytes( + message.signature !== undefined ? message.signature : new Uint8Array() + )); + return obj; + }, + + fromPartial(object: DeepPartial): Vote { + const message = { ...baseVote } as Vote; + if (object.type !== undefined && object.type !== null) { + message.type = object.type; + } else { + message.type = 0; + } + if (object.height !== undefined && object.height !== null) { + message.height = object.height; + } else { + message.height = 0; + } + if (object.round !== undefined && object.round !== null) { + message.round = object.round; + } else { + message.round = 0; + } + if (object.blockId !== undefined && object.blockId !== null) { + message.blockId = BlockID.fromPartial(object.blockId); + } else { + message.blockId = undefined; + } + if (object.timestamp !== undefined && object.timestamp !== null) { + message.timestamp = object.timestamp; + } else { + message.timestamp = undefined; + } + if ( + object.validatorAddress !== undefined && + object.validatorAddress !== null + ) { + message.validatorAddress = object.validatorAddress; + } else { + message.validatorAddress = new Uint8Array(); + } + if (object.validatorIndex !== undefined && object.validatorIndex !== null) { + message.validatorIndex = object.validatorIndex; + } else { + message.validatorIndex = 0; + } + if (object.signature !== undefined && object.signature !== null) { + message.signature = object.signature; + } else { + message.signature = new Uint8Array(); + } + return message; + }, +}; + +const baseCommit: object = { height: 0, round: 0 }; + +export const Commit = { + encode(message: Commit, writer: Writer = Writer.create()): Writer { + if (message.height !== 0) { + writer.uint32(8).int64(message.height); + } + if (message.round !== 0) { + writer.uint32(16).int32(message.round); + } + if (message.blockId !== undefined) { + BlockID.encode(message.blockId, writer.uint32(26).fork()).ldelim(); + } + for (const v of message.signatures) { + CommitSig.encode(v!, writer.uint32(34).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Commit { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseCommit } as Commit; + message.signatures = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.height = longToNumber(reader.int64() as Long); + break; + case 2: + message.round = reader.int32(); + break; + case 3: + message.blockId = BlockID.decode(reader, reader.uint32()); + break; + case 4: + message.signatures.push(CommitSig.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Commit { + const message = { ...baseCommit } as Commit; + message.signatures = []; + if (object.height !== undefined && object.height !== null) { + message.height = Number(object.height); + } else { + message.height = 0; + } + if (object.round !== undefined && object.round !== null) { + message.round = Number(object.round); + } else { + message.round = 0; + } + if (object.blockId !== undefined && object.blockId !== null) { + message.blockId = BlockID.fromJSON(object.blockId); + } else { + message.blockId = undefined; + } + if (object.signatures !== undefined && object.signatures !== null) { + for (const e of object.signatures) { + message.signatures.push(CommitSig.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: Commit): unknown { + const obj: any = {}; + message.height !== undefined && (obj.height = message.height); + message.round !== undefined && (obj.round = message.round); + message.blockId !== undefined && + (obj.blockId = message.blockId + ? BlockID.toJSON(message.blockId) + : undefined); + if (message.signatures) { + obj.signatures = message.signatures.map((e) => + e ? CommitSig.toJSON(e) : undefined + ); + } else { + obj.signatures = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): Commit { + const message = { ...baseCommit } as Commit; + message.signatures = []; + if (object.height !== undefined && object.height !== null) { + message.height = object.height; + } else { + message.height = 0; + } + if (object.round !== undefined && object.round !== null) { + message.round = object.round; + } else { + message.round = 0; + } + if (object.blockId !== undefined && object.blockId !== null) { + message.blockId = BlockID.fromPartial(object.blockId); + } else { + message.blockId = undefined; + } + if (object.signatures !== undefined && object.signatures !== null) { + for (const e of object.signatures) { + message.signatures.push(CommitSig.fromPartial(e)); + } + } + return message; + }, +}; + +const baseCommitSig: object = { blockIdFlag: 0 }; + +export const CommitSig = { + encode(message: CommitSig, writer: Writer = Writer.create()): Writer { + if (message.blockIdFlag !== 0) { + writer.uint32(8).int32(message.blockIdFlag); + } + if (message.validatorAddress.length !== 0) { + writer.uint32(18).bytes(message.validatorAddress); + } + if (message.timestamp !== undefined) { + Timestamp.encode( + toTimestamp(message.timestamp), + writer.uint32(26).fork() + ).ldelim(); + } + if (message.signature.length !== 0) { + writer.uint32(34).bytes(message.signature); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): CommitSig { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseCommitSig } as CommitSig; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.blockIdFlag = reader.int32() as any; + break; + case 2: + message.validatorAddress = reader.bytes(); + break; + case 3: + message.timestamp = fromTimestamp( + Timestamp.decode(reader, reader.uint32()) + ); + break; + case 4: + message.signature = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): CommitSig { + const message = { ...baseCommitSig } as CommitSig; + if (object.blockIdFlag !== undefined && object.blockIdFlag !== null) { + message.blockIdFlag = blockIDFlagFromJSON(object.blockIdFlag); + } else { + message.blockIdFlag = 0; + } + if ( + object.validatorAddress !== undefined && + object.validatorAddress !== null + ) { + message.validatorAddress = bytesFromBase64(object.validatorAddress); + } + if (object.timestamp !== undefined && object.timestamp !== null) { + message.timestamp = fromJsonTimestamp(object.timestamp); + } else { + message.timestamp = undefined; + } + if (object.signature !== undefined && object.signature !== null) { + message.signature = bytesFromBase64(object.signature); + } + return message; + }, + + toJSON(message: CommitSig): unknown { + const obj: any = {}; + message.blockIdFlag !== undefined && + (obj.blockIdFlag = blockIDFlagToJSON(message.blockIdFlag)); + message.validatorAddress !== undefined && + (obj.validatorAddress = base64FromBytes( + message.validatorAddress !== undefined + ? message.validatorAddress + : new Uint8Array() + )); + message.timestamp !== undefined && + (obj.timestamp = + message.timestamp !== undefined + ? message.timestamp.toISOString() + : null); + message.signature !== undefined && + (obj.signature = base64FromBytes( + message.signature !== undefined ? message.signature : new Uint8Array() + )); + return obj; + }, + + fromPartial(object: DeepPartial): CommitSig { + const message = { ...baseCommitSig } as CommitSig; + if (object.blockIdFlag !== undefined && object.blockIdFlag !== null) { + message.blockIdFlag = object.blockIdFlag; + } else { + message.blockIdFlag = 0; + } + if ( + object.validatorAddress !== undefined && + object.validatorAddress !== null + ) { + message.validatorAddress = object.validatorAddress; + } else { + message.validatorAddress = new Uint8Array(); + } + if (object.timestamp !== undefined && object.timestamp !== null) { + message.timestamp = object.timestamp; + } else { + message.timestamp = undefined; + } + if (object.signature !== undefined && object.signature !== null) { + message.signature = object.signature; + } else { + message.signature = new Uint8Array(); + } + return message; + }, +}; + +const baseProposal: object = { type: 0, height: 0, round: 0, polRound: 0 }; + +export const Proposal = { + encode(message: Proposal, writer: Writer = Writer.create()): Writer { + if (message.type !== 0) { + writer.uint32(8).int32(message.type); + } + if (message.height !== 0) { + writer.uint32(16).int64(message.height); + } + if (message.round !== 0) { + writer.uint32(24).int32(message.round); + } + if (message.polRound !== 0) { + writer.uint32(32).int32(message.polRound); + } + if (message.blockId !== undefined) { + BlockID.encode(message.blockId, writer.uint32(42).fork()).ldelim(); + } + if (message.timestamp !== undefined) { + Timestamp.encode( + toTimestamp(message.timestamp), + writer.uint32(50).fork() + ).ldelim(); + } + if (message.signature.length !== 0) { + writer.uint32(58).bytes(message.signature); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Proposal { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseProposal } as Proposal; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.type = reader.int32() as any; + break; + case 2: + message.height = longToNumber(reader.int64() as Long); + break; + case 3: + message.round = reader.int32(); + break; + case 4: + message.polRound = reader.int32(); + break; + case 5: + message.blockId = BlockID.decode(reader, reader.uint32()); + break; + case 6: + message.timestamp = fromTimestamp( + Timestamp.decode(reader, reader.uint32()) + ); + break; + case 7: + message.signature = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Proposal { + const message = { ...baseProposal } as Proposal; + if (object.type !== undefined && object.type !== null) { + message.type = signedMsgTypeFromJSON(object.type); + } else { + message.type = 0; + } + if (object.height !== undefined && object.height !== null) { + message.height = Number(object.height); + } else { + message.height = 0; + } + if (object.round !== undefined && object.round !== null) { + message.round = Number(object.round); + } else { + message.round = 0; + } + if (object.polRound !== undefined && object.polRound !== null) { + message.polRound = Number(object.polRound); + } else { + message.polRound = 0; + } + if (object.blockId !== undefined && object.blockId !== null) { + message.blockId = BlockID.fromJSON(object.blockId); + } else { + message.blockId = undefined; + } + if (object.timestamp !== undefined && object.timestamp !== null) { + message.timestamp = fromJsonTimestamp(object.timestamp); + } else { + message.timestamp = undefined; + } + if (object.signature !== undefined && object.signature !== null) { + message.signature = bytesFromBase64(object.signature); + } + return message; + }, + + toJSON(message: Proposal): unknown { + const obj: any = {}; + message.type !== undefined && + (obj.type = signedMsgTypeToJSON(message.type)); + message.height !== undefined && (obj.height = message.height); + message.round !== undefined && (obj.round = message.round); + message.polRound !== undefined && (obj.polRound = message.polRound); + message.blockId !== undefined && + (obj.blockId = message.blockId + ? BlockID.toJSON(message.blockId) + : undefined); + message.timestamp !== undefined && + (obj.timestamp = + message.timestamp !== undefined + ? message.timestamp.toISOString() + : null); + message.signature !== undefined && + (obj.signature = base64FromBytes( + message.signature !== undefined ? message.signature : new Uint8Array() + )); + return obj; + }, + + fromPartial(object: DeepPartial): Proposal { + const message = { ...baseProposal } as Proposal; + if (object.type !== undefined && object.type !== null) { + message.type = object.type; + } else { + message.type = 0; + } + if (object.height !== undefined && object.height !== null) { + message.height = object.height; + } else { + message.height = 0; + } + if (object.round !== undefined && object.round !== null) { + message.round = object.round; + } else { + message.round = 0; + } + if (object.polRound !== undefined && object.polRound !== null) { + message.polRound = object.polRound; + } else { + message.polRound = 0; + } + if (object.blockId !== undefined && object.blockId !== null) { + message.blockId = BlockID.fromPartial(object.blockId); + } else { + message.blockId = undefined; + } + if (object.timestamp !== undefined && object.timestamp !== null) { + message.timestamp = object.timestamp; + } else { + message.timestamp = undefined; + } + if (object.signature !== undefined && object.signature !== null) { + message.signature = object.signature; + } else { + message.signature = new Uint8Array(); + } + return message; + }, +}; + +const baseSignedHeader: object = {}; + +export const SignedHeader = { + encode(message: SignedHeader, writer: Writer = Writer.create()): Writer { + if (message.header !== undefined) { + Header.encode(message.header, writer.uint32(10).fork()).ldelim(); + } + if (message.commit !== undefined) { + Commit.encode(message.commit, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): SignedHeader { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseSignedHeader } as SignedHeader; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.header = Header.decode(reader, reader.uint32()); + break; + case 2: + message.commit = Commit.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): SignedHeader { + const message = { ...baseSignedHeader } as SignedHeader; + if (object.header !== undefined && object.header !== null) { + message.header = Header.fromJSON(object.header); + } else { + message.header = undefined; + } + if (object.commit !== undefined && object.commit !== null) { + message.commit = Commit.fromJSON(object.commit); + } else { + message.commit = undefined; + } + return message; + }, + + toJSON(message: SignedHeader): unknown { + const obj: any = {}; + message.header !== undefined && + (obj.header = message.header ? Header.toJSON(message.header) : undefined); + message.commit !== undefined && + (obj.commit = message.commit ? Commit.toJSON(message.commit) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): SignedHeader { + const message = { ...baseSignedHeader } as SignedHeader; + if (object.header !== undefined && object.header !== null) { + message.header = Header.fromPartial(object.header); + } else { + message.header = undefined; + } + if (object.commit !== undefined && object.commit !== null) { + message.commit = Commit.fromPartial(object.commit); + } else { + message.commit = undefined; + } + return message; + }, +}; + +const baseLightBlock: object = {}; + +export const LightBlock = { + encode(message: LightBlock, writer: Writer = Writer.create()): Writer { + if (message.signedHeader !== undefined) { + SignedHeader.encode( + message.signedHeader, + writer.uint32(10).fork() + ).ldelim(); + } + if (message.validatorSet !== undefined) { + ValidatorSet.encode( + message.validatorSet, + writer.uint32(18).fork() + ).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): LightBlock { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseLightBlock } as LightBlock; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.signedHeader = SignedHeader.decode(reader, reader.uint32()); + break; + case 2: + message.validatorSet = ValidatorSet.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): LightBlock { + const message = { ...baseLightBlock } as LightBlock; + if (object.signedHeader !== undefined && object.signedHeader !== null) { + message.signedHeader = SignedHeader.fromJSON(object.signedHeader); + } else { + message.signedHeader = undefined; + } + if (object.validatorSet !== undefined && object.validatorSet !== null) { + message.validatorSet = ValidatorSet.fromJSON(object.validatorSet); + } else { + message.validatorSet = undefined; + } + return message; + }, + + toJSON(message: LightBlock): unknown { + const obj: any = {}; + message.signedHeader !== undefined && + (obj.signedHeader = message.signedHeader + ? SignedHeader.toJSON(message.signedHeader) + : undefined); + message.validatorSet !== undefined && + (obj.validatorSet = message.validatorSet + ? ValidatorSet.toJSON(message.validatorSet) + : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): LightBlock { + const message = { ...baseLightBlock } as LightBlock; + if (object.signedHeader !== undefined && object.signedHeader !== null) { + message.signedHeader = SignedHeader.fromPartial(object.signedHeader); + } else { + message.signedHeader = undefined; + } + if (object.validatorSet !== undefined && object.validatorSet !== null) { + message.validatorSet = ValidatorSet.fromPartial(object.validatorSet); + } else { + message.validatorSet = undefined; + } + return message; + }, +}; + +const baseBlockMeta: object = { blockSize: 0, numTxs: 0 }; + +export const BlockMeta = { + encode(message: BlockMeta, writer: Writer = Writer.create()): Writer { + if (message.blockId !== undefined) { + BlockID.encode(message.blockId, writer.uint32(10).fork()).ldelim(); + } + if (message.blockSize !== 0) { + writer.uint32(16).int64(message.blockSize); + } + if (message.header !== undefined) { + Header.encode(message.header, writer.uint32(26).fork()).ldelim(); + } + if (message.numTxs !== 0) { + writer.uint32(32).int64(message.numTxs); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): BlockMeta { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseBlockMeta } as BlockMeta; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.blockId = BlockID.decode(reader, reader.uint32()); + break; + case 2: + message.blockSize = longToNumber(reader.int64() as Long); + break; + case 3: + message.header = Header.decode(reader, reader.uint32()); + break; + case 4: + message.numTxs = longToNumber(reader.int64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): BlockMeta { + const message = { ...baseBlockMeta } as BlockMeta; + if (object.blockId !== undefined && object.blockId !== null) { + message.blockId = BlockID.fromJSON(object.blockId); + } else { + message.blockId = undefined; + } + if (object.blockSize !== undefined && object.blockSize !== null) { + message.blockSize = Number(object.blockSize); + } else { + message.blockSize = 0; + } + if (object.header !== undefined && object.header !== null) { + message.header = Header.fromJSON(object.header); + } else { + message.header = undefined; + } + if (object.numTxs !== undefined && object.numTxs !== null) { + message.numTxs = Number(object.numTxs); + } else { + message.numTxs = 0; + } + return message; + }, + + toJSON(message: BlockMeta): unknown { + const obj: any = {}; + message.blockId !== undefined && + (obj.blockId = message.blockId + ? BlockID.toJSON(message.blockId) + : undefined); + message.blockSize !== undefined && (obj.blockSize = message.blockSize); + message.header !== undefined && + (obj.header = message.header ? Header.toJSON(message.header) : undefined); + message.numTxs !== undefined && (obj.numTxs = message.numTxs); + return obj; + }, + + fromPartial(object: DeepPartial): BlockMeta { + const message = { ...baseBlockMeta } as BlockMeta; + if (object.blockId !== undefined && object.blockId !== null) { + message.blockId = BlockID.fromPartial(object.blockId); + } else { + message.blockId = undefined; + } + if (object.blockSize !== undefined && object.blockSize !== null) { + message.blockSize = object.blockSize; + } else { + message.blockSize = 0; + } + if (object.header !== undefined && object.header !== null) { + message.header = Header.fromPartial(object.header); + } else { + message.header = undefined; + } + if (object.numTxs !== undefined && object.numTxs !== null) { + message.numTxs = object.numTxs; + } else { + message.numTxs = 0; + } + return message; + }, +}; + +const baseTxProof: object = {}; + +export const TxProof = { + encode(message: TxProof, writer: Writer = Writer.create()): Writer { + if (message.rootHash.length !== 0) { + writer.uint32(10).bytes(message.rootHash); + } + if (message.data.length !== 0) { + writer.uint32(18).bytes(message.data); + } + if (message.proof !== undefined) { + Proof.encode(message.proof, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): TxProof { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseTxProof } as TxProof; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.rootHash = reader.bytes(); + break; + case 2: + message.data = reader.bytes(); + break; + case 3: + message.proof = Proof.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): TxProof { + const message = { ...baseTxProof } as TxProof; + if (object.rootHash !== undefined && object.rootHash !== null) { + message.rootHash = bytesFromBase64(object.rootHash); + } + if (object.data !== undefined && object.data !== null) { + message.data = bytesFromBase64(object.data); + } + if (object.proof !== undefined && object.proof !== null) { + message.proof = Proof.fromJSON(object.proof); + } else { + message.proof = undefined; + } + return message; + }, + + toJSON(message: TxProof): unknown { + const obj: any = {}; + message.rootHash !== undefined && + (obj.rootHash = base64FromBytes( + message.rootHash !== undefined ? message.rootHash : new Uint8Array() + )); + message.data !== undefined && + (obj.data = base64FromBytes( + message.data !== undefined ? message.data : new Uint8Array() + )); + message.proof !== undefined && + (obj.proof = message.proof ? Proof.toJSON(message.proof) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): TxProof { + const message = { ...baseTxProof } as TxProof; + if (object.rootHash !== undefined && object.rootHash !== null) { + message.rootHash = object.rootHash; + } else { + message.rootHash = new Uint8Array(); + } + if (object.data !== undefined && object.data !== null) { + message.data = object.data; + } else { + message.data = new Uint8Array(); + } + if (object.proof !== undefined && object.proof !== null) { + message.proof = Proof.fromPartial(object.proof); + } else { + message.proof = undefined; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function toTimestamp(date: Date): Timestamp { + const seconds = date.getTime() / 1_000; + const nanos = (date.getTime() % 1_000) * 1_000_000; + return { seconds, nanos }; +} + +function fromTimestamp(t: Timestamp): Date { + let millis = t.seconds * 1_000; + millis += t.nanos / 1_000_000; + return new Date(millis); +} + +function fromJsonTimestamp(o: any): Date { + if (o instanceof Date) { + return o; + } else if (typeof o === "string") { + return new Date(o); + } else { + return fromTimestamp(Timestamp.fromJSON(o)); + } +} + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/cosmos.staking.v1beta1/types/tendermint/types/validator.ts b/ts-client/cosmos.staking.v1beta1/types/tendermint/types/validator.ts new file mode 100644 index 00000000..c5044032 --- /dev/null +++ b/ts-client/cosmos.staking.v1beta1/types/tendermint/types/validator.ts @@ -0,0 +1,382 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; +import { PublicKey } from "../../tendermint/crypto/keys"; + +export const protobufPackage = "tendermint.types"; + +export interface ValidatorSet { + validators: Validator[]; + proposer: Validator | undefined; + totalVotingPower: number; +} + +export interface Validator { + address: Uint8Array; + pubKey: PublicKey | undefined; + votingPower: number; + proposerPriority: number; +} + +export interface SimpleValidator { + pubKey: PublicKey | undefined; + votingPower: number; +} + +const baseValidatorSet: object = { totalVotingPower: 0 }; + +export const ValidatorSet = { + encode(message: ValidatorSet, writer: Writer = Writer.create()): Writer { + for (const v of message.validators) { + Validator.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.proposer !== undefined) { + Validator.encode(message.proposer, writer.uint32(18).fork()).ldelim(); + } + if (message.totalVotingPower !== 0) { + writer.uint32(24).int64(message.totalVotingPower); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ValidatorSet { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseValidatorSet } as ValidatorSet; + message.validators = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.validators.push(Validator.decode(reader, reader.uint32())); + break; + case 2: + message.proposer = Validator.decode(reader, reader.uint32()); + break; + case 3: + message.totalVotingPower = longToNumber(reader.int64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ValidatorSet { + const message = { ...baseValidatorSet } as ValidatorSet; + message.validators = []; + if (object.validators !== undefined && object.validators !== null) { + for (const e of object.validators) { + message.validators.push(Validator.fromJSON(e)); + } + } + if (object.proposer !== undefined && object.proposer !== null) { + message.proposer = Validator.fromJSON(object.proposer); + } else { + message.proposer = undefined; + } + if ( + object.totalVotingPower !== undefined && + object.totalVotingPower !== null + ) { + message.totalVotingPower = Number(object.totalVotingPower); + } else { + message.totalVotingPower = 0; + } + return message; + }, + + toJSON(message: ValidatorSet): unknown { + const obj: any = {}; + if (message.validators) { + obj.validators = message.validators.map((e) => + e ? Validator.toJSON(e) : undefined + ); + } else { + obj.validators = []; + } + message.proposer !== undefined && + (obj.proposer = message.proposer + ? Validator.toJSON(message.proposer) + : undefined); + message.totalVotingPower !== undefined && + (obj.totalVotingPower = message.totalVotingPower); + return obj; + }, + + fromPartial(object: DeepPartial): ValidatorSet { + const message = { ...baseValidatorSet } as ValidatorSet; + message.validators = []; + if (object.validators !== undefined && object.validators !== null) { + for (const e of object.validators) { + message.validators.push(Validator.fromPartial(e)); + } + } + if (object.proposer !== undefined && object.proposer !== null) { + message.proposer = Validator.fromPartial(object.proposer); + } else { + message.proposer = undefined; + } + if ( + object.totalVotingPower !== undefined && + object.totalVotingPower !== null + ) { + message.totalVotingPower = object.totalVotingPower; + } else { + message.totalVotingPower = 0; + } + return message; + }, +}; + +const baseValidator: object = { votingPower: 0, proposerPriority: 0 }; + +export const Validator = { + encode(message: Validator, writer: Writer = Writer.create()): Writer { + if (message.address.length !== 0) { + writer.uint32(10).bytes(message.address); + } + if (message.pubKey !== undefined) { + PublicKey.encode(message.pubKey, writer.uint32(18).fork()).ldelim(); + } + if (message.votingPower !== 0) { + writer.uint32(24).int64(message.votingPower); + } + if (message.proposerPriority !== 0) { + writer.uint32(32).int64(message.proposerPriority); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Validator { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseValidator } as Validator; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.address = reader.bytes(); + break; + case 2: + message.pubKey = PublicKey.decode(reader, reader.uint32()); + break; + case 3: + message.votingPower = longToNumber(reader.int64() as Long); + break; + case 4: + message.proposerPriority = longToNumber(reader.int64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Validator { + const message = { ...baseValidator } as Validator; + if (object.address !== undefined && object.address !== null) { + message.address = bytesFromBase64(object.address); + } + if (object.pubKey !== undefined && object.pubKey !== null) { + message.pubKey = PublicKey.fromJSON(object.pubKey); + } else { + message.pubKey = undefined; + } + if (object.votingPower !== undefined && object.votingPower !== null) { + message.votingPower = Number(object.votingPower); + } else { + message.votingPower = 0; + } + if ( + object.proposerPriority !== undefined && + object.proposerPriority !== null + ) { + message.proposerPriority = Number(object.proposerPriority); + } else { + message.proposerPriority = 0; + } + return message; + }, + + toJSON(message: Validator): unknown { + const obj: any = {}; + message.address !== undefined && + (obj.address = base64FromBytes( + message.address !== undefined ? message.address : new Uint8Array() + )); + message.pubKey !== undefined && + (obj.pubKey = message.pubKey + ? PublicKey.toJSON(message.pubKey) + : undefined); + message.votingPower !== undefined && + (obj.votingPower = message.votingPower); + message.proposerPriority !== undefined && + (obj.proposerPriority = message.proposerPriority); + return obj; + }, + + fromPartial(object: DeepPartial): Validator { + const message = { ...baseValidator } as Validator; + if (object.address !== undefined && object.address !== null) { + message.address = object.address; + } else { + message.address = new Uint8Array(); + } + if (object.pubKey !== undefined && object.pubKey !== null) { + message.pubKey = PublicKey.fromPartial(object.pubKey); + } else { + message.pubKey = undefined; + } + if (object.votingPower !== undefined && object.votingPower !== null) { + message.votingPower = object.votingPower; + } else { + message.votingPower = 0; + } + if ( + object.proposerPriority !== undefined && + object.proposerPriority !== null + ) { + message.proposerPriority = object.proposerPriority; + } else { + message.proposerPriority = 0; + } + return message; + }, +}; + +const baseSimpleValidator: object = { votingPower: 0 }; + +export const SimpleValidator = { + encode(message: SimpleValidator, writer: Writer = Writer.create()): Writer { + if (message.pubKey !== undefined) { + PublicKey.encode(message.pubKey, writer.uint32(10).fork()).ldelim(); + } + if (message.votingPower !== 0) { + writer.uint32(16).int64(message.votingPower); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): SimpleValidator { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseSimpleValidator } as SimpleValidator; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.pubKey = PublicKey.decode(reader, reader.uint32()); + break; + case 2: + message.votingPower = longToNumber(reader.int64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): SimpleValidator { + const message = { ...baseSimpleValidator } as SimpleValidator; + if (object.pubKey !== undefined && object.pubKey !== null) { + message.pubKey = PublicKey.fromJSON(object.pubKey); + } else { + message.pubKey = undefined; + } + if (object.votingPower !== undefined && object.votingPower !== null) { + message.votingPower = Number(object.votingPower); + } else { + message.votingPower = 0; + } + return message; + }, + + toJSON(message: SimpleValidator): unknown { + const obj: any = {}; + message.pubKey !== undefined && + (obj.pubKey = message.pubKey + ? PublicKey.toJSON(message.pubKey) + : undefined); + message.votingPower !== undefined && + (obj.votingPower = message.votingPower); + return obj; + }, + + fromPartial(object: DeepPartial): SimpleValidator { + const message = { ...baseSimpleValidator } as SimpleValidator; + if (object.pubKey !== undefined && object.pubKey !== null) { + message.pubKey = PublicKey.fromPartial(object.pubKey); + } else { + message.pubKey = undefined; + } + if (object.votingPower !== undefined && object.votingPower !== null) { + message.votingPower = object.votingPower; + } else { + message.votingPower = 0; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/cosmos.staking.v1beta1/types/tendermint/version/types.ts b/ts-client/cosmos.staking.v1beta1/types/tendermint/version/types.ts new file mode 100644 index 00000000..4bc6ad82 --- /dev/null +++ b/ts-client/cosmos.staking.v1beta1/types/tendermint/version/types.ts @@ -0,0 +1,202 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "tendermint.version"; + +/** + * App includes the protocol and software version for the application. + * This information is included in ResponseInfo. The App.Protocol can be + * updated in ResponseEndBlock. + */ +export interface App { + protocol: number; + software: string; +} + +/** + * Consensus captures the consensus rules for processing a block in the blockchain, + * including all blockchain data structures and the rules of the application's + * state transition machine. + */ +export interface Consensus { + block: number; + app: number; +} + +const baseApp: object = { protocol: 0, software: "" }; + +export const App = { + encode(message: App, writer: Writer = Writer.create()): Writer { + if (message.protocol !== 0) { + writer.uint32(8).uint64(message.protocol); + } + if (message.software !== "") { + writer.uint32(18).string(message.software); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): App { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseApp } as App; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.protocol = longToNumber(reader.uint64() as Long); + break; + case 2: + message.software = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): App { + const message = { ...baseApp } as App; + if (object.protocol !== undefined && object.protocol !== null) { + message.protocol = Number(object.protocol); + } else { + message.protocol = 0; + } + if (object.software !== undefined && object.software !== null) { + message.software = String(object.software); + } else { + message.software = ""; + } + return message; + }, + + toJSON(message: App): unknown { + const obj: any = {}; + message.protocol !== undefined && (obj.protocol = message.protocol); + message.software !== undefined && (obj.software = message.software); + return obj; + }, + + fromPartial(object: DeepPartial): App { + const message = { ...baseApp } as App; + if (object.protocol !== undefined && object.protocol !== null) { + message.protocol = object.protocol; + } else { + message.protocol = 0; + } + if (object.software !== undefined && object.software !== null) { + message.software = object.software; + } else { + message.software = ""; + } + return message; + }, +}; + +const baseConsensus: object = { block: 0, app: 0 }; + +export const Consensus = { + encode(message: Consensus, writer: Writer = Writer.create()): Writer { + if (message.block !== 0) { + writer.uint32(8).uint64(message.block); + } + if (message.app !== 0) { + writer.uint32(16).uint64(message.app); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Consensus { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseConsensus } as Consensus; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.block = longToNumber(reader.uint64() as Long); + break; + case 2: + message.app = longToNumber(reader.uint64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Consensus { + const message = { ...baseConsensus } as Consensus; + if (object.block !== undefined && object.block !== null) { + message.block = Number(object.block); + } else { + message.block = 0; + } + if (object.app !== undefined && object.app !== null) { + message.app = Number(object.app); + } else { + message.app = 0; + } + return message; + }, + + toJSON(message: Consensus): unknown { + const obj: any = {}; + message.block !== undefined && (obj.block = message.block); + message.app !== undefined && (obj.app = message.app); + return obj; + }, + + fromPartial(object: DeepPartial): Consensus { + const message = { ...baseConsensus } as Consensus; + if (object.block !== undefined && object.block !== null) { + message.block = object.block; + } else { + message.block = 0; + } + if (object.app !== undefined && object.app !== null) { + message.app = object.app; + } else { + message.app = 0; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/cosmos.tx.v1beta1/index.ts b/ts-client/cosmos.tx.v1beta1/index.ts new file mode 100755 index 00000000..c9dfa159 --- /dev/null +++ b/ts-client/cosmos.tx.v1beta1/index.ts @@ -0,0 +1,6 @@ +import Module from './module'; +import { txClient, queryClient, registry } from './module'; +import { msgTypes } from './registry'; + +export * from "./types"; +export { Module, msgTypes, txClient, queryClient, registry }; diff --git a/ts-client/cosmos.tx.v1beta1/module.ts b/ts-client/cosmos.tx.v1beta1/module.ts new file mode 100755 index 00000000..7caa1d8c --- /dev/null +++ b/ts-client/cosmos.tx.v1beta1/module.ts @@ -0,0 +1,66 @@ +// Generated by Ignite ignite.com/cli + +import { StdFee } from "@cosmjs/launchpad"; +import { SigningStargateClient, DeliverTxResponse } from "@cosmjs/stargate"; +import { EncodeObject, GeneratedType, OfflineSigner, Registry } from "@cosmjs/proto-signing"; +import { msgTypes } from './registry'; +import { IgniteClient } from "../client" +import { MissingWalletError } from "../helpers" +import { Api } from "./rest"; + + +export { }; + + + +export const registry = new Registry(msgTypes); + +const defaultFee = { + amount: [], + gas: "200000", +}; + +interface TxClientOptions { + addr: string + prefix: string + signer?: OfflineSigner +} + +export const txClient = ({ signer, prefix, addr }: TxClientOptions = { addr: "http://localhost:26657", prefix: "cosmos" }) => { + + return { + + + } +}; + +interface QueryClientOptions { + addr: string +} + +export const queryClient = ({ addr: addr }: QueryClientOptions = { addr: "http://localhost:1317" }) => { + return new Api({ baseUrl: addr }); +}; + +class SDKModule { + public query: ReturnType; + public tx: ReturnType; + + public registry: Array<[string, GeneratedType]>; + + constructor(client: IgniteClient) { + + this.query = queryClient({ addr: client.env.apiURL }); + this.tx = txClient({ signer: client.signer, addr: client.env.rpcURL, prefix: client.env.prefix ?? "cosmos" }); + } +}; + +const Module = (test: IgniteClient) => { + return { + module: { + CosmosTxV1Beta1: new SDKModule(test) + }, + registry: msgTypes + } +} +export default Module; \ No newline at end of file diff --git a/ts-client/cosmos.tx.v1beta1/registry.ts b/ts-client/cosmos.tx.v1beta1/registry.ts new file mode 100755 index 00000000..26157e4f --- /dev/null +++ b/ts-client/cosmos.tx.v1beta1/registry.ts @@ -0,0 +1,7 @@ +import { GeneratedType } from "@cosmjs/proto-signing"; + +const msgTypes: Array<[string, GeneratedType]> = [ + +]; + +export { msgTypes } \ No newline at end of file diff --git a/ts-client/cosmos.tx.v1beta1/rest.ts b/ts-client/cosmos.tx.v1beta1/rest.ts new file mode 100644 index 00000000..7a328347 --- /dev/null +++ b/ts-client/cosmos.tx.v1beta1/rest.ts @@ -0,0 +1,1295 @@ +/* eslint-disable */ +/* tslint:disable */ +/* + * --------------------------------------------------------------- + * ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ## + * ## ## + * ## AUTHOR: acacode ## + * ## SOURCE: https://github.com/acacode/swagger-typescript-api ## + * --------------------------------------------------------------- + */ + +/** +* Event allows application developers to attach additional information to +ResponseBeginBlock, ResponseEndBlock, ResponseCheckTx and ResponseDeliverTx. +Later, transactions may be queried using these events. +*/ +export interface AbciEvent { + type?: string; + attributes?: AbciEventAttribute[]; +} + +/** + * EventAttribute is a single key-value pair, associated with an event. + */ +export interface AbciEventAttribute { + /** @format byte */ + key?: string; + + /** @format byte */ + value?: string; + index?: boolean; +} + +/** + * Result is the union of ResponseFormat and ResponseCheckTx. + */ +export interface Abciv1Beta1Result { + /** + * Data is any data returned from message or handler execution. It MUST be + * length prefixed in order to separate data from multiple message executions. + * @format byte + */ + data?: string; + + /** Log contains the log information from message or handler execution. */ + log?: string; + + /** + * Events contains a slice of Event objects that were emitted during message + * or handler execution. + */ + events?: AbciEvent[]; +} + +export interface CryptoPublicKey { + /** @format byte */ + ed25519?: string; + + /** @format byte */ + secp256k1?: string; +} + +/** +* `Any` contains an arbitrary serialized protocol buffer message along with a +URL that describes the type of the serialized message. + +Protobuf library provides support to pack/unpack Any values in the form +of utility functions or additional generated methods of the Any type. + +Example 1: Pack and unpack a message in C++. + + Foo foo = ...; + Any any; + any.PackFrom(foo); + ... + if (any.UnpackTo(&foo)) { + ... + } + +Example 2: Pack and unpack a message in Java. + + Foo foo = ...; + Any any = Any.pack(foo); + ... + if (any.is(Foo.class)) { + foo = any.unpack(Foo.class); + } + + Example 3: Pack and unpack a message in Python. + + foo = Foo(...) + any = Any() + any.Pack(foo) + ... + if any.Is(Foo.DESCRIPTOR): + any.Unpack(foo) + ... + + Example 4: Pack and unpack a message in Go + + foo := &pb.Foo{...} + any, err := anypb.New(foo) + if err != nil { + ... + } + ... + foo := &pb.Foo{} + if err := any.UnmarshalTo(foo); err != nil { + ... + } + +The pack methods provided by protobuf library will by default use +'type.googleapis.com/full.type.name' as the type URL and the unpack +methods only use the fully qualified type name after the last '/' +in the type URL, for example "foo.bar.com/x/y.z" will yield type +name "y.z". + + +JSON +==== +The JSON representation of an `Any` value uses the regular +representation of the deserialized, embedded message, with an +additional field `@type` which contains the type URL. Example: + + package google.profile; + message Person { + string first_name = 1; + string last_name = 2; + } + + { + "@type": "type.googleapis.com/google.profile.Person", + "firstName": , + "lastName": + } + +If the embedded message type is well-known and has a custom JSON +representation, that representation will be embedded adding a field +`value` which holds the custom JSON in addition to the `@type` +field. Example (for message [google.protobuf.Duration][]): + + { + "@type": "type.googleapis.com/google.protobuf.Duration", + "value": "1.212s" + } +*/ +export interface ProtobufAny { + /** + * A URL/resource name that uniquely identifies the type of the serialized + * protocol buffer message. This string must contain at least + * one "/" character. The last segment of the URL's path must represent + * the fully qualified name of the type (as in + * `path/google.protobuf.Duration`). The name should be in a canonical form + * (e.g., leading "." is not accepted). + * + * In practice, teams usually precompile into the binary all types that they + * expect it to use in the context of Any. However, for URLs which use the + * scheme `http`, `https`, or no scheme, one can optionally set up a type + * server that maps type URLs to message definitions as follows: + * + * * If no scheme is provided, `https` is assumed. + * * An HTTP GET on the URL must yield a [google.protobuf.Type][] + * value in binary format, or produce an error. + * * Applications are allowed to cache lookup results based on the + * URL, or have them precompiled into a binary to avoid any + * lookup. Therefore, binary compatibility needs to be preserved + * on changes to types. (Use versioned type names to manage + * breaking changes.) + * + * Note: this functionality is not currently available in the official + * protobuf release, and it is not used for type URLs beginning with + * type.googleapis.com. + * + * Schemes other than `http`, `https` (or the empty scheme) might be + * used with implementation specific semantics. + */ + "@type"?: string; +} + +export interface RpcStatus { + /** @format int32 */ + code?: number; + message?: string; + details?: ProtobufAny[]; +} + +export interface TenderminttypesData { + /** + * Txs that will be applied by state @ block.Height+1. + * NOTE: not all txs here are valid. We're just agreeing on the order first. + * This means that block.AppHash does not include these txs. + */ + txs?: string[]; +} + +export interface TenderminttypesEvidence { + /** DuplicateVoteEvidence contains evidence of a validator signed two conflicting votes. */ + duplicate_vote_evidence?: TypesDuplicateVoteEvidence; + + /** LightClientAttackEvidence contains evidence of a set of validators attempting to mislead a light client. */ + light_client_attack_evidence?: TypesLightClientAttackEvidence; +} + +export interface TenderminttypesValidator { + /** @format byte */ + address?: string; + pub_key?: CryptoPublicKey; + + /** @format int64 */ + voting_power?: string; + + /** @format int64 */ + proposer_priority?: string; +} + +export interface TypesBlock { + /** Header defines the structure of a block header. */ + header?: TypesHeader; + data?: TenderminttypesData; + evidence?: TypesEvidenceList; + + /** Commit contains the evidence that a block was committed by a set of validators. */ + last_commit?: TypesCommit; +} + +export interface TypesBlockID { + /** @format byte */ + hash?: string; + part_set_header?: TypesPartSetHeader; +} + +export enum TypesBlockIDFlag { + BLOCK_ID_FLAG_UNKNOWN = "BLOCK_ID_FLAG_UNKNOWN", + BLOCK_ID_FLAG_ABSENT = "BLOCK_ID_FLAG_ABSENT", + BLOCK_ID_FLAG_COMMIT = "BLOCK_ID_FLAG_COMMIT", + BLOCK_ID_FLAG_NIL = "BLOCK_ID_FLAG_NIL", +} + +/** + * Commit contains the evidence that a block was committed by a set of validators. + */ +export interface TypesCommit { + /** @format int64 */ + height?: string; + + /** @format int32 */ + round?: number; + block_id?: TypesBlockID; + signatures?: TypesCommitSig[]; +} + +/** + * CommitSig is a part of the Vote included in a Commit. + */ +export interface TypesCommitSig { + block_id_flag?: TypesBlockIDFlag; + + /** @format byte */ + validator_address?: string; + + /** @format date-time */ + timestamp?: string; + + /** @format byte */ + signature?: string; +} + +/** + * DuplicateVoteEvidence contains evidence of a validator signed two conflicting votes. + */ +export interface TypesDuplicateVoteEvidence { + /** + * Vote represents a prevote, precommit, or commit vote from validators for + * consensus. + */ + vote_a?: TypesVote; + + /** + * Vote represents a prevote, precommit, or commit vote from validators for + * consensus. + */ + vote_b?: TypesVote; + + /** @format int64 */ + total_voting_power?: string; + + /** @format int64 */ + validator_power?: string; + + /** @format date-time */ + timestamp?: string; +} + +export interface TypesEvidenceList { + evidence?: TenderminttypesEvidence[]; +} + +/** + * Header defines the structure of a block header. + */ +export interface TypesHeader { + /** + * Consensus captures the consensus rules for processing a block in the blockchain, + * including all blockchain data structures and the rules of the application's + * state transition machine. + */ + version?: VersionConsensus; + chain_id?: string; + + /** @format int64 */ + height?: string; + + /** @format date-time */ + time?: string; + last_block_id?: TypesBlockID; + + /** + * commit from validators from the last block + * @format byte + */ + last_commit_hash?: string; + + /** @format byte */ + data_hash?: string; + + /** + * validators for the current block + * @format byte + */ + validators_hash?: string; + + /** @format byte */ + next_validators_hash?: string; + + /** @format byte */ + consensus_hash?: string; + + /** @format byte */ + app_hash?: string; + + /** @format byte */ + last_results_hash?: string; + + /** + * evidence included in the block + * @format byte + */ + evidence_hash?: string; + + /** @format byte */ + proposer_address?: string; +} + +export interface TypesLightBlock { + signed_header?: TypesSignedHeader; + validator_set?: TypesValidatorSet; +} + +/** + * LightClientAttackEvidence contains evidence of a set of validators attempting to mislead a light client. + */ +export interface TypesLightClientAttackEvidence { + conflicting_block?: TypesLightBlock; + + /** @format int64 */ + common_height?: string; + byzantine_validators?: TenderminttypesValidator[]; + + /** @format int64 */ + total_voting_power?: string; + + /** @format date-time */ + timestamp?: string; +} + +export interface TypesPartSetHeader { + /** @format int64 */ + total?: number; + + /** @format byte */ + hash?: string; +} + +export interface TypesSignedHeader { + /** Header defines the structure of a block header. */ + header?: TypesHeader; + + /** Commit contains the evidence that a block was committed by a set of validators. */ + commit?: TypesCommit; +} + +/** +* SignedMsgType is a type of signed message in the consensus. + + - SIGNED_MSG_TYPE_PREVOTE: Votes + - SIGNED_MSG_TYPE_PROPOSAL: Proposals +*/ +export enum TypesSignedMsgType { + SIGNED_MSG_TYPE_UNKNOWN = "SIGNED_MSG_TYPE_UNKNOWN", + SIGNED_MSG_TYPE_PREVOTE = "SIGNED_MSG_TYPE_PREVOTE", + SIGNED_MSG_TYPE_PRECOMMIT = "SIGNED_MSG_TYPE_PRECOMMIT", + SIGNED_MSG_TYPE_PROPOSAL = "SIGNED_MSG_TYPE_PROPOSAL", +} + +export interface TypesValidatorSet { + validators?: TenderminttypesValidator[]; + proposer?: TenderminttypesValidator; + + /** @format int64 */ + total_voting_power?: string; +} + +/** +* Vote represents a prevote, precommit, or commit vote from validators for +consensus. +*/ +export interface TypesVote { + /** + * SignedMsgType is a type of signed message in the consensus. + * + * - SIGNED_MSG_TYPE_PREVOTE: Votes + * - SIGNED_MSG_TYPE_PROPOSAL: Proposals + */ + type?: TypesSignedMsgType; + + /** @format int64 */ + height?: string; + + /** @format int32 */ + round?: number; + + /** zero if vote is nil. */ + block_id?: TypesBlockID; + + /** @format date-time */ + timestamp?: string; + + /** @format byte */ + validator_address?: string; + + /** @format int32 */ + validator_index?: number; + + /** @format byte */ + signature?: string; +} + +/** + * ABCIMessageLog defines a structure containing an indexed tx ABCI message log. + */ +export interface V1Beta1ABCIMessageLog { + /** @format int64 */ + msg_index?: number; + log?: string; + + /** + * Events contains a slice of Event objects that were emitted during some + * execution. + */ + events?: V1Beta1StringEvent[]; +} + +/** +* Attribute defines an attribute wrapper where the key and value are +strings instead of raw bytes. +*/ +export interface V1Beta1Attribute { + key?: string; + value?: string; +} + +/** +* AuthInfo describes the fee and signer modes that are used to sign a +transaction. +*/ +export interface V1Beta1AuthInfo { + /** + * signer_infos defines the signing modes for the required signers. The number + * and order of elements must match the required signers from TxBody's + * messages. The first element is the primary signer and the one which pays + * the fee. + */ + signer_infos?: V1Beta1SignerInfo[]; + + /** + * Fee is the fee and gas limit for the transaction. The first signer is the + * primary signer and the one which pays the fee. The fee can be calculated + * based on the cost of evaluating the body and doing signature verification + * of the signers. This can be estimated via simulation. + */ + fee?: V1Beta1Fee; +} + +/** +* BroadcastMode specifies the broadcast mode for the TxService.Broadcast RPC method. + + - BROADCAST_MODE_UNSPECIFIED: zero-value for mode ordering + - BROADCAST_MODE_BLOCK: BROADCAST_MODE_BLOCK defines a tx broadcasting mode where the client waits for +the tx to be committed in a block. + - BROADCAST_MODE_SYNC: BROADCAST_MODE_SYNC defines a tx broadcasting mode where the client waits for +a CheckTx execution response only. + - BROADCAST_MODE_ASYNC: BROADCAST_MODE_ASYNC defines a tx broadcasting mode where the client returns +immediately. +*/ +export enum V1Beta1BroadcastMode { + BROADCAST_MODE_UNSPECIFIED = "BROADCAST_MODE_UNSPECIFIED", + BROADCAST_MODE_BLOCK = "BROADCAST_MODE_BLOCK", + BROADCAST_MODE_SYNC = "BROADCAST_MODE_SYNC", + BROADCAST_MODE_ASYNC = "BROADCAST_MODE_ASYNC", +} + +/** +* BroadcastTxRequest is the request type for the Service.BroadcastTxRequest +RPC method. +*/ +export interface V1Beta1BroadcastTxRequest { + /** + * tx_bytes is the raw transaction. + * @format byte + */ + tx_bytes?: string; + + /** + * BroadcastMode specifies the broadcast mode for the TxService.Broadcast RPC method. + * + * - BROADCAST_MODE_UNSPECIFIED: zero-value for mode ordering + * - BROADCAST_MODE_BLOCK: BROADCAST_MODE_BLOCK defines a tx broadcasting mode where the client waits for + * the tx to be committed in a block. + * - BROADCAST_MODE_SYNC: BROADCAST_MODE_SYNC defines a tx broadcasting mode where the client waits for + * a CheckTx execution response only. + * - BROADCAST_MODE_ASYNC: BROADCAST_MODE_ASYNC defines a tx broadcasting mode where the client returns + * immediately. + */ + mode?: V1Beta1BroadcastMode; +} + +/** +* BroadcastTxResponse is the response type for the +Service.BroadcastTx method. +*/ +export interface V1Beta1BroadcastTxResponse { + /** tx_response is the queried TxResponses. */ + tx_response?: V1Beta1TxResponse; +} + +/** +* Coin defines a token with a denomination and an amount. + +NOTE: The amount field is an Int which implements the custom method +signatures required by gogoproto. +*/ +export interface V1Beta1Coin { + denom?: string; + amount?: string; +} + +/** +* CompactBitArray is an implementation of a space efficient bit array. +This is used to ensure that the encoded data takes up a minimal amount of +space after proto encoding. +This is not thread safe, and is not intended for concurrent usage. +*/ +export interface V1Beta1CompactBitArray { + /** @format int64 */ + extra_bits_stored?: number; + + /** @format byte */ + elems?: string; +} + +/** +* Fee includes the amount of coins paid in fees and the maximum +gas to be used by the transaction. The ratio yields an effective "gasprice", +which must be above some miminum to be accepted into the mempool. +*/ +export interface V1Beta1Fee { + amount?: V1Beta1Coin[]; + + /** @format uint64 */ + gas_limit?: string; + + /** + * if unset, the first signer is responsible for paying the fees. If set, the specified account must pay the fees. + * the payer must be a tx signer (and thus have signed this field in AuthInfo). + * setting this field does *not* change the ordering of required signers for the transaction. + */ + payer?: string; + granter?: string; +} + +/** + * GasInfo defines tx execution gas context. + */ +export interface V1Beta1GasInfo { + /** + * GasWanted is the maximum units of work we allow this tx to perform. + * @format uint64 + */ + gas_wanted?: string; + + /** + * GasUsed is the amount of gas actually consumed. + * @format uint64 + */ + gas_used?: string; +} + +/** +* GetBlockWithTxsResponse is the response type for the Service.GetBlockWithTxs method. + +Since: cosmos-sdk 0.45.2 +*/ +export interface V1Beta1GetBlockWithTxsResponse { + /** txs are the transactions in the block. */ + txs?: V1Beta1Tx[]; + block_id?: TypesBlockID; + block?: TypesBlock; + + /** pagination defines a pagination for the response. */ + pagination?: V1Beta1PageResponse; +} + +/** + * GetTxResponse is the response type for the Service.GetTx method. + */ +export interface V1Beta1GetTxResponse { + /** tx is the queried transaction. */ + tx?: V1Beta1Tx; + + /** tx_response is the queried TxResponses. */ + tx_response?: V1Beta1TxResponse; +} + +/** +* GetTxsEventResponse is the response type for the Service.TxsByEvents +RPC method. +*/ +export interface V1Beta1GetTxsEventResponse { + /** txs is the list of queried transactions. */ + txs?: V1Beta1Tx[]; + + /** tx_responses is the list of queried TxResponses. */ + tx_responses?: V1Beta1TxResponse[]; + + /** pagination defines a pagination for the response. */ + pagination?: V1Beta1PageResponse; +} + +/** + * ModeInfo describes the signing mode of a single or nested multisig signer. + */ +export interface V1Beta1ModeInfo { + single?: V1Beta1ModeInfoSingle; + multi?: V1Beta1ModeInfoMulti; +} + +export interface V1Beta1ModeInfoMulti { + /** + * CompactBitArray is an implementation of a space efficient bit array. + * This is used to ensure that the encoded data takes up a minimal amount of + * space after proto encoding. + * This is not thread safe, and is not intended for concurrent usage. + */ + bitarray?: V1Beta1CompactBitArray; + mode_infos?: V1Beta1ModeInfo[]; +} + +export interface V1Beta1ModeInfoSingle { + /** + * SignMode represents a signing mode with its own security guarantees. + * + * - SIGN_MODE_UNSPECIFIED: SIGN_MODE_UNSPECIFIED specifies an unknown signing mode and will be + * rejected + * - SIGN_MODE_DIRECT: SIGN_MODE_DIRECT specifies a signing mode which uses SignDoc and is + * verified with raw bytes from Tx + * - SIGN_MODE_TEXTUAL: SIGN_MODE_TEXTUAL is a future signing mode that will verify some + * human-readable textual representation on top of the binary representation + * from SIGN_MODE_DIRECT + * - SIGN_MODE_LEGACY_AMINO_JSON: SIGN_MODE_LEGACY_AMINO_JSON is a backwards compatibility mode which uses + * Amino JSON and will be removed in the future + * - SIGN_MODE_EIP_191: SIGN_MODE_EIP_191 specifies the sign mode for EIP 191 signing on the Cosmos + * SDK. Ref: https://eips.ethereum.org/EIPS/eip-191 + * + * Currently, SIGN_MODE_EIP_191 is registered as a SignMode enum variant, + * but is not implemented on the SDK by default. To enable EIP-191, you need + * to pass a custom `TxConfig` that has an implementation of + * `SignModeHandler` for EIP-191. The SDK may decide to fully support + * EIP-191 in the future. + * + * Since: cosmos-sdk 0.45.2 + */ + mode?: V1Beta1SignMode; +} + +/** +* - ORDER_BY_UNSPECIFIED: ORDER_BY_UNSPECIFIED specifies an unknown sorting order. OrderBy defaults to ASC in this case. + - ORDER_BY_ASC: ORDER_BY_ASC defines ascending order + - ORDER_BY_DESC: ORDER_BY_DESC defines descending order +*/ +export enum V1Beta1OrderBy { + ORDER_BY_UNSPECIFIED = "ORDER_BY_UNSPECIFIED", + ORDER_BY_ASC = "ORDER_BY_ASC", + ORDER_BY_DESC = "ORDER_BY_DESC", +} + +/** +* message SomeRequest { + Foo some_parameter = 1; + PageRequest pagination = 2; + } +*/ +export interface V1Beta1PageRequest { + /** + * key is a value returned in PageResponse.next_key to begin + * querying the next page most efficiently. Only one of offset or key + * should be set. + * @format byte + */ + key?: string; + + /** + * offset is a numeric offset that can be used when key is unavailable. + * It is less efficient than using key. Only one of offset or key should + * be set. + * @format uint64 + */ + offset?: string; + + /** + * limit is the total number of results to be returned in the result page. + * If left empty it will default to a value to be set by each app. + * @format uint64 + */ + limit?: string; + + /** + * count_total is set to true to indicate that the result set should include + * a count of the total number of items available for pagination in UIs. + * count_total is only respected when offset is used. It is ignored when key + * is set. + */ + count_total?: boolean; + + /** + * reverse is set to true if results are to be returned in the descending order. + * + * Since: cosmos-sdk 0.43 + */ + reverse?: boolean; +} + +/** +* PageResponse is to be embedded in gRPC response messages where the +corresponding request message has used PageRequest. + + message SomeResponse { + repeated Bar results = 1; + PageResponse page = 2; + } +*/ +export interface V1Beta1PageResponse { + /** @format byte */ + next_key?: string; + + /** @format uint64 */ + total?: string; +} + +/** +* SignMode represents a signing mode with its own security guarantees. + + - SIGN_MODE_UNSPECIFIED: SIGN_MODE_UNSPECIFIED specifies an unknown signing mode and will be +rejected + - SIGN_MODE_DIRECT: SIGN_MODE_DIRECT specifies a signing mode which uses SignDoc and is +verified with raw bytes from Tx + - SIGN_MODE_TEXTUAL: SIGN_MODE_TEXTUAL is a future signing mode that will verify some +human-readable textual representation on top of the binary representation +from SIGN_MODE_DIRECT + - SIGN_MODE_LEGACY_AMINO_JSON: SIGN_MODE_LEGACY_AMINO_JSON is a backwards compatibility mode which uses +Amino JSON and will be removed in the future + - SIGN_MODE_EIP_191: SIGN_MODE_EIP_191 specifies the sign mode for EIP 191 signing on the Cosmos +SDK. Ref: https://eips.ethereum.org/EIPS/eip-191 + +Currently, SIGN_MODE_EIP_191 is registered as a SignMode enum variant, +but is not implemented on the SDK by default. To enable EIP-191, you need +to pass a custom `TxConfig` that has an implementation of +`SignModeHandler` for EIP-191. The SDK may decide to fully support +EIP-191 in the future. + +Since: cosmos-sdk 0.45.2 +*/ +export enum V1Beta1SignMode { + SIGN_MODE_UNSPECIFIED = "SIGN_MODE_UNSPECIFIED", + SIGN_MODE_DIRECT = "SIGN_MODE_DIRECT", + SIGN_MODE_TEXTUAL = "SIGN_MODE_TEXTUAL", + SIGN_MODE_LEGACY_AMINO_JSON = "SIGN_MODE_LEGACY_AMINO_JSON", + SIGNMODEEIP191 = "SIGN_MODE_EIP_191", +} + +/** +* SignerInfo describes the public key and signing mode of a single top-level +signer. +*/ +export interface V1Beta1SignerInfo { + /** + * public_key is the public key of the signer. It is optional for accounts + * that already exist in state. If unset, the verifier can use the required \ + * signer address for this position and lookup the public key. + */ + public_key?: ProtobufAny; + + /** ModeInfo describes the signing mode of a single or nested multisig signer. */ + mode_info?: V1Beta1ModeInfo; + + /** + * sequence is the sequence of the account, which describes the + * number of committed transactions signed by a given address. It is used to + * prevent replay attacks. + * @format uint64 + */ + sequence?: string; +} + +/** +* SimulateRequest is the request type for the Service.Simulate +RPC method. +*/ +export interface V1Beta1SimulateRequest { + /** + * tx is the transaction to simulate. + * Deprecated. Send raw tx bytes instead. + */ + tx?: V1Beta1Tx; + + /** + * tx_bytes is the raw transaction. + * + * Since: cosmos-sdk 0.43 + * @format byte + */ + tx_bytes?: string; +} + +/** +* SimulateResponse is the response type for the +Service.SimulateRPC method. +*/ +export interface V1Beta1SimulateResponse { + /** gas_info is the information about gas used in the simulation. */ + gas_info?: V1Beta1GasInfo; + + /** result is the result of the simulation. */ + result?: Abciv1Beta1Result; +} + +/** +* StringEvent defines en Event object wrapper where all the attributes +contain key/value pairs that are strings instead of raw bytes. +*/ +export interface V1Beta1StringEvent { + type?: string; + attributes?: V1Beta1Attribute[]; +} + +/** + * Tx is the standard type used for broadcasting transactions. + */ +export interface V1Beta1Tx { + /** TxBody is the body of a transaction that all signers sign over. */ + body?: V1Beta1TxBody; + + /** + * AuthInfo describes the fee and signer modes that are used to sign a + * transaction. + */ + auth_info?: V1Beta1AuthInfo; + + /** + * signatures is a list of signatures that matches the length and order of + * AuthInfo's signer_infos to allow connecting signature meta information like + * public key and signing mode by position. + */ + signatures?: string[]; +} + +/** + * TxBody is the body of a transaction that all signers sign over. + */ +export interface V1Beta1TxBody { + /** + * messages is a list of messages to be executed. The required signers of + * those messages define the number and order of elements in AuthInfo's + * signer_infos and Tx's signatures. Each required signer address is added to + * the list only the first time it occurs. + * By convention, the first required signer (usually from the first message) + * is referred to as the primary signer and pays the fee for the whole + * transaction. + */ + messages?: ProtobufAny[]; + + /** + * memo is any arbitrary note/comment to be added to the transaction. + * WARNING: in clients, any publicly exposed text should not be called memo, + * but should be called `note` instead (see https://github.com/cosmos/cosmos-sdk/issues/9122). + */ + memo?: string; + + /** @format uint64 */ + timeout_height?: string; + extension_options?: ProtobufAny[]; + non_critical_extension_options?: ProtobufAny[]; +} + +/** +* TxResponse defines a structure containing relevant tx data and metadata. The +tags are stringified and the log is JSON decoded. +*/ +export interface V1Beta1TxResponse { + /** @format int64 */ + height?: string; + + /** The transaction hash. */ + txhash?: string; + codespace?: string; + + /** + * Response code. + * @format int64 + */ + code?: number; + + /** Result bytes, if any. */ + data?: string; + + /** + * The output of the application's logger (raw string). May be + * non-deterministic. + */ + raw_log?: string; + + /** The output of the application's logger (typed). May be non-deterministic. */ + logs?: V1Beta1ABCIMessageLog[]; + + /** Additional information. May be non-deterministic. */ + info?: string; + + /** + * Amount of gas requested for transaction. + * @format int64 + */ + gas_wanted?: string; + + /** + * Amount of gas consumed by transaction. + * @format int64 + */ + gas_used?: string; + + /** The request transaction bytes. */ + tx?: ProtobufAny; + + /** + * Time of the previous block. For heights > 1, it's the weighted median of + * the timestamps of the valid votes in the block.LastCommit. For height == 1, + * it's genesis time. + */ + timestamp?: string; + + /** + * Events defines all the events emitted by processing a transaction. Note, + * these events include those emitted by processing all the messages and those + * emitted from the ante handler. Whereas Logs contains the events, with + * additional metadata, emitted only by processing the messages. + * + * Since: cosmos-sdk 0.42.11, 0.44.5, 0.45 + */ + events?: AbciEvent[]; +} + +/** +* Consensus captures the consensus rules for processing a block in the blockchain, +including all blockchain data structures and the rules of the application's +state transition machine. +*/ +export interface VersionConsensus { + /** @format uint64 */ + block?: string; + + /** @format uint64 */ + app?: string; +} + +export type QueryParamsType = Record; +export type ResponseFormat = keyof Omit; + +export interface FullRequestParams extends Omit { + /** set parameter to `true` for call `securityWorker` for this request */ + secure?: boolean; + /** request path */ + path: string; + /** content type of request body */ + type?: ContentType; + /** query params */ + query?: QueryParamsType; + /** format of response (i.e. response.json() -> format: "json") */ + format?: keyof Omit; + /** request body */ + body?: unknown; + /** base url */ + baseUrl?: string; + /** request cancellation token */ + cancelToken?: CancelToken; +} + +export type RequestParams = Omit; + +export interface ApiConfig { + baseUrl?: string; + baseApiParams?: Omit; + securityWorker?: (securityData: SecurityDataType) => RequestParams | void; +} + +export interface HttpResponse extends Response { + data: D; + error: E; +} + +type CancelToken = Symbol | string | number; + +export enum ContentType { + Json = "application/json", + FormData = "multipart/form-data", + UrlEncoded = "application/x-www-form-urlencoded", +} + +export class HttpClient { + public baseUrl: string = ""; + private securityData: SecurityDataType = null as any; + private securityWorker: null | ApiConfig["securityWorker"] = null; + private abortControllers = new Map(); + + private baseApiParams: RequestParams = { + credentials: "same-origin", + headers: {}, + redirect: "follow", + referrerPolicy: "no-referrer", + }; + + constructor(apiConfig: ApiConfig = {}) { + Object.assign(this, apiConfig); + } + + public setSecurityData = (data: SecurityDataType) => { + this.securityData = data; + }; + + private addQueryParam(query: QueryParamsType, key: string) { + const value = query[key]; + + return ( + encodeURIComponent(key) + + "=" + + encodeURIComponent(Array.isArray(value) ? value.join(",") : typeof value === "number" ? value : `${value}`) + ); + } + + protected toQueryString(rawQuery?: QueryParamsType): string { + const query = rawQuery || {}; + const keys = Object.keys(query).filter((key) => "undefined" !== typeof query[key]); + return keys + .map((key) => + typeof query[key] === "object" && !Array.isArray(query[key]) + ? this.toQueryString(query[key] as QueryParamsType) + : this.addQueryParam(query, key), + ) + .join("&"); + } + + protected addQueryParams(rawQuery?: QueryParamsType): string { + const queryString = this.toQueryString(rawQuery); + return queryString ? `?${queryString}` : ""; + } + + private contentFormatters: Record any> = { + [ContentType.Json]: (input: any) => + input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input, + [ContentType.FormData]: (input: any) => + Object.keys(input || {}).reduce((data, key) => { + data.append(key, input[key]); + return data; + }, new FormData()), + [ContentType.UrlEncoded]: (input: any) => this.toQueryString(input), + }; + + private mergeRequestParams(params1: RequestParams, params2?: RequestParams): RequestParams { + return { + ...this.baseApiParams, + ...params1, + ...(params2 || {}), + headers: { + ...(this.baseApiParams.headers || {}), + ...(params1.headers || {}), + ...((params2 && params2.headers) || {}), + }, + }; + } + + private createAbortSignal = (cancelToken: CancelToken): AbortSignal | undefined => { + if (this.abortControllers.has(cancelToken)) { + const abortController = this.abortControllers.get(cancelToken); + if (abortController) { + return abortController.signal; + } + return void 0; + } + + const abortController = new AbortController(); + this.abortControllers.set(cancelToken, abortController); + return abortController.signal; + }; + + public abortRequest = (cancelToken: CancelToken) => { + const abortController = this.abortControllers.get(cancelToken); + + if (abortController) { + abortController.abort(); + this.abortControllers.delete(cancelToken); + } + }; + + public request = ({ + body, + secure, + path, + type, + query, + format = "json", + baseUrl, + cancelToken, + ...params + }: FullRequestParams): Promise> => { + const secureParams = (secure && this.securityWorker && this.securityWorker(this.securityData)) || {}; + const requestParams = this.mergeRequestParams(params, secureParams); + const queryString = query && this.toQueryString(query); + const payloadFormatter = this.contentFormatters[type || ContentType.Json]; + + return fetch(`${baseUrl || this.baseUrl || ""}${path}${queryString ? `?${queryString}` : ""}`, { + ...requestParams, + headers: { + ...(type && type !== ContentType.FormData ? { "Content-Type": type } : {}), + ...(requestParams.headers || {}), + }, + signal: cancelToken ? this.createAbortSignal(cancelToken) : void 0, + body: typeof body === "undefined" || body === null ? null : payloadFormatter(body), + }).then(async (response) => { + const r = response as HttpResponse; + r.data = (null as unknown) as T; + r.error = (null as unknown) as E; + + const data = await response[format]() + .then((data) => { + if (r.ok) { + r.data = data; + } else { + r.error = data; + } + return r; + }) + .catch((e) => { + r.error = e; + return r; + }); + + if (cancelToken) { + this.abortControllers.delete(cancelToken); + } + + if (!response.ok) throw data; + return data; + }); + }; +} + +/** + * @title cosmos/tx/v1beta1/service.proto + * @version version not set + */ +export class Api extends HttpClient { + /** + * No description + * + * @tags Service + * @name ServiceSimulate + * @summary Simulate simulates executing a transaction for estimating gas usage. + * @request POST:/cosmos/tx/v1beta1/simulate + */ + serviceSimulate = (body: V1Beta1SimulateRequest, params: RequestParams = {}) => + this.request({ + path: `/cosmos/tx/v1beta1/simulate`, + method: "POST", + body: body, + type: ContentType.Json, + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Service + * @name ServiceGetTxsEvent + * @summary GetTxsEvent fetches txs by event. + * @request GET:/cosmos/tx/v1beta1/txs + */ + serviceGetTxsEvent = ( + query?: { + events?: string[]; + "pagination.key"?: string; + "pagination.offset"?: string; + "pagination.limit"?: string; + "pagination.count_total"?: boolean; + "pagination.reverse"?: boolean; + order_by?: "ORDER_BY_UNSPECIFIED" | "ORDER_BY_ASC" | "ORDER_BY_DESC"; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/cosmos/tx/v1beta1/txs`, + method: "GET", + query: query, + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Service + * @name ServiceBroadcastTx + * @summary BroadcastTx broadcast transaction. + * @request POST:/cosmos/tx/v1beta1/txs + */ + serviceBroadcastTx = (body: V1Beta1BroadcastTxRequest, params: RequestParams = {}) => + this.request({ + path: `/cosmos/tx/v1beta1/txs`, + method: "POST", + body: body, + type: ContentType.Json, + format: "json", + ...params, + }); + + /** + * @description Since: cosmos-sdk 0.45.2 + * + * @tags Service + * @name ServiceGetBlockWithTxs + * @summary GetBlockWithTxs fetches a block with decoded txs. + * @request GET:/cosmos/tx/v1beta1/txs/block/{height} + */ + serviceGetBlockWithTxs = ( + height: string, + query?: { + "pagination.key"?: string; + "pagination.offset"?: string; + "pagination.limit"?: string; + "pagination.count_total"?: boolean; + "pagination.reverse"?: boolean; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/cosmos/tx/v1beta1/txs/block/${height}`, + method: "GET", + query: query, + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Service + * @name ServiceGetTx + * @summary GetTx fetches a tx by hash. + * @request GET:/cosmos/tx/v1beta1/txs/{hash} + */ + serviceGetTx = (hash: string, params: RequestParams = {}) => + this.request({ + path: `/cosmos/tx/v1beta1/txs/${hash}`, + method: "GET", + format: "json", + ...params, + }); +} diff --git a/ts-client/cosmos.tx.v1beta1/types.ts b/ts-client/cosmos.tx.v1beta1/types.ts new file mode 100755 index 00000000..2a4f4957 --- /dev/null +++ b/ts-client/cosmos.tx.v1beta1/types.ts @@ -0,0 +1,25 @@ +import { Tx } from "./types/cosmos/tx/v1beta1/tx" +import { TxRaw } from "./types/cosmos/tx/v1beta1/tx" +import { SignDoc } from "./types/cosmos/tx/v1beta1/tx" +import { TxBody } from "./types/cosmos/tx/v1beta1/tx" +import { AuthInfo } from "./types/cosmos/tx/v1beta1/tx" +import { SignerInfo } from "./types/cosmos/tx/v1beta1/tx" +import { ModeInfo } from "./types/cosmos/tx/v1beta1/tx" +import { ModeInfo_Single } from "./types/cosmos/tx/v1beta1/tx" +import { ModeInfo_Multi } from "./types/cosmos/tx/v1beta1/tx" +import { Fee } from "./types/cosmos/tx/v1beta1/tx" + + +export { + Tx, + TxRaw, + SignDoc, + TxBody, + AuthInfo, + SignerInfo, + ModeInfo, + ModeInfo_Single, + ModeInfo_Multi, + Fee, + + } \ No newline at end of file diff --git a/ts-client/cosmos.tx.v1beta1/types/cosmos/base/abci/v1beta1/abci.ts b/ts-client/cosmos.tx.v1beta1/types/cosmos/base/abci/v1beta1/abci.ts new file mode 100644 index 00000000..5f1e5e7e --- /dev/null +++ b/ts-client/cosmos.tx.v1beta1/types/cosmos/base/abci/v1beta1/abci.ts @@ -0,0 +1,1279 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; +import { Any } from "../../../../google/protobuf/any"; +import { Event } from "../../../../tendermint/abci/types"; + +export const protobufPackage = "cosmos.base.abci.v1beta1"; + +/** + * TxResponse defines a structure containing relevant tx data and metadata. The + * tags are stringified and the log is JSON decoded. + */ +export interface TxResponse { + /** The block height */ + height: number; + /** The transaction hash. */ + txhash: string; + /** Namespace for the Code */ + codespace: string; + /** Response code. */ + code: number; + /** Result bytes, if any. */ + data: string; + /** + * The output of the application's logger (raw string). May be + * non-deterministic. + */ + rawLog: string; + /** The output of the application's logger (typed). May be non-deterministic. */ + logs: ABCIMessageLog[]; + /** Additional information. May be non-deterministic. */ + info: string; + /** Amount of gas requested for transaction. */ + gasWanted: number; + /** Amount of gas consumed by transaction. */ + gasUsed: number; + /** The request transaction bytes. */ + tx: Any | undefined; + /** + * Time of the previous block. For heights > 1, it's the weighted median of + * the timestamps of the valid votes in the block.LastCommit. For height == 1, + * it's genesis time. + */ + timestamp: string; + /** + * Events defines all the events emitted by processing a transaction. Note, + * these events include those emitted by processing all the messages and those + * emitted from the ante handler. Whereas Logs contains the events, with + * additional metadata, emitted only by processing the messages. + * + * Since: cosmos-sdk 0.42.11, 0.44.5, 0.45 + */ + events: Event[]; +} + +/** ABCIMessageLog defines a structure containing an indexed tx ABCI message log. */ +export interface ABCIMessageLog { + msgIndex: number; + log: string; + /** + * Events contains a slice of Event objects that were emitted during some + * execution. + */ + events: StringEvent[]; +} + +/** + * StringEvent defines en Event object wrapper where all the attributes + * contain key/value pairs that are strings instead of raw bytes. + */ +export interface StringEvent { + type: string; + attributes: Attribute[]; +} + +/** + * Attribute defines an attribute wrapper where the key and value are + * strings instead of raw bytes. + */ +export interface Attribute { + key: string; + value: string; +} + +/** GasInfo defines tx execution gas context. */ +export interface GasInfo { + /** GasWanted is the maximum units of work we allow this tx to perform. */ + gasWanted: number; + /** GasUsed is the amount of gas actually consumed. */ + gasUsed: number; +} + +/** Result is the union of ResponseFormat and ResponseCheckTx. */ +export interface Result { + /** + * Data is any data returned from message or handler execution. It MUST be + * length prefixed in order to separate data from multiple message executions. + */ + data: Uint8Array; + /** Log contains the log information from message or handler execution. */ + log: string; + /** + * Events contains a slice of Event objects that were emitted during message + * or handler execution. + */ + events: Event[]; +} + +/** + * SimulationResponse defines the response generated when a transaction is + * successfully simulated. + */ +export interface SimulationResponse { + gasInfo: GasInfo | undefined; + result: Result | undefined; +} + +/** + * MsgData defines the data returned in a Result object during message + * execution. + */ +export interface MsgData { + msgType: string; + data: Uint8Array; +} + +/** + * TxMsgData defines a list of MsgData. A transaction will have a MsgData object + * for each message. + */ +export interface TxMsgData { + data: MsgData[]; +} + +/** SearchTxsResult defines a structure for querying txs pageable */ +export interface SearchTxsResult { + /** Count of all txs */ + totalCount: number; + /** Count of txs in current page */ + count: number; + /** Index of current page, start from 1 */ + pageNumber: number; + /** Count of total pages */ + pageTotal: number; + /** Max count txs per page */ + limit: number; + /** List of txs in current page */ + txs: TxResponse[]; +} + +const baseTxResponse: object = { + height: 0, + txhash: "", + codespace: "", + code: 0, + data: "", + rawLog: "", + info: "", + gasWanted: 0, + gasUsed: 0, + timestamp: "", +}; + +export const TxResponse = { + encode(message: TxResponse, writer: Writer = Writer.create()): Writer { + if (message.height !== 0) { + writer.uint32(8).int64(message.height); + } + if (message.txhash !== "") { + writer.uint32(18).string(message.txhash); + } + if (message.codespace !== "") { + writer.uint32(26).string(message.codespace); + } + if (message.code !== 0) { + writer.uint32(32).uint32(message.code); + } + if (message.data !== "") { + writer.uint32(42).string(message.data); + } + if (message.rawLog !== "") { + writer.uint32(50).string(message.rawLog); + } + for (const v of message.logs) { + ABCIMessageLog.encode(v!, writer.uint32(58).fork()).ldelim(); + } + if (message.info !== "") { + writer.uint32(66).string(message.info); + } + if (message.gasWanted !== 0) { + writer.uint32(72).int64(message.gasWanted); + } + if (message.gasUsed !== 0) { + writer.uint32(80).int64(message.gasUsed); + } + if (message.tx !== undefined) { + Any.encode(message.tx, writer.uint32(90).fork()).ldelim(); + } + if (message.timestamp !== "") { + writer.uint32(98).string(message.timestamp); + } + for (const v of message.events) { + Event.encode(v!, writer.uint32(106).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): TxResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseTxResponse } as TxResponse; + message.logs = []; + message.events = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.height = longToNumber(reader.int64() as Long); + break; + case 2: + message.txhash = reader.string(); + break; + case 3: + message.codespace = reader.string(); + break; + case 4: + message.code = reader.uint32(); + break; + case 5: + message.data = reader.string(); + break; + case 6: + message.rawLog = reader.string(); + break; + case 7: + message.logs.push(ABCIMessageLog.decode(reader, reader.uint32())); + break; + case 8: + message.info = reader.string(); + break; + case 9: + message.gasWanted = longToNumber(reader.int64() as Long); + break; + case 10: + message.gasUsed = longToNumber(reader.int64() as Long); + break; + case 11: + message.tx = Any.decode(reader, reader.uint32()); + break; + case 12: + message.timestamp = reader.string(); + break; + case 13: + message.events.push(Event.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): TxResponse { + const message = { ...baseTxResponse } as TxResponse; + message.logs = []; + message.events = []; + if (object.height !== undefined && object.height !== null) { + message.height = Number(object.height); + } else { + message.height = 0; + } + if (object.txhash !== undefined && object.txhash !== null) { + message.txhash = String(object.txhash); + } else { + message.txhash = ""; + } + if (object.codespace !== undefined && object.codespace !== null) { + message.codespace = String(object.codespace); + } else { + message.codespace = ""; + } + if (object.code !== undefined && object.code !== null) { + message.code = Number(object.code); + } else { + message.code = 0; + } + if (object.data !== undefined && object.data !== null) { + message.data = String(object.data); + } else { + message.data = ""; + } + if (object.rawLog !== undefined && object.rawLog !== null) { + message.rawLog = String(object.rawLog); + } else { + message.rawLog = ""; + } + if (object.logs !== undefined && object.logs !== null) { + for (const e of object.logs) { + message.logs.push(ABCIMessageLog.fromJSON(e)); + } + } + if (object.info !== undefined && object.info !== null) { + message.info = String(object.info); + } else { + message.info = ""; + } + if (object.gasWanted !== undefined && object.gasWanted !== null) { + message.gasWanted = Number(object.gasWanted); + } else { + message.gasWanted = 0; + } + if (object.gasUsed !== undefined && object.gasUsed !== null) { + message.gasUsed = Number(object.gasUsed); + } else { + message.gasUsed = 0; + } + if (object.tx !== undefined && object.tx !== null) { + message.tx = Any.fromJSON(object.tx); + } else { + message.tx = undefined; + } + if (object.timestamp !== undefined && object.timestamp !== null) { + message.timestamp = String(object.timestamp); + } else { + message.timestamp = ""; + } + if (object.events !== undefined && object.events !== null) { + for (const e of object.events) { + message.events.push(Event.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: TxResponse): unknown { + const obj: any = {}; + message.height !== undefined && (obj.height = message.height); + message.txhash !== undefined && (obj.txhash = message.txhash); + message.codespace !== undefined && (obj.codespace = message.codespace); + message.code !== undefined && (obj.code = message.code); + message.data !== undefined && (obj.data = message.data); + message.rawLog !== undefined && (obj.rawLog = message.rawLog); + if (message.logs) { + obj.logs = message.logs.map((e) => + e ? ABCIMessageLog.toJSON(e) : undefined + ); + } else { + obj.logs = []; + } + message.info !== undefined && (obj.info = message.info); + message.gasWanted !== undefined && (obj.gasWanted = message.gasWanted); + message.gasUsed !== undefined && (obj.gasUsed = message.gasUsed); + message.tx !== undefined && + (obj.tx = message.tx ? Any.toJSON(message.tx) : undefined); + message.timestamp !== undefined && (obj.timestamp = message.timestamp); + if (message.events) { + obj.events = message.events.map((e) => (e ? Event.toJSON(e) : undefined)); + } else { + obj.events = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): TxResponse { + const message = { ...baseTxResponse } as TxResponse; + message.logs = []; + message.events = []; + if (object.height !== undefined && object.height !== null) { + message.height = object.height; + } else { + message.height = 0; + } + if (object.txhash !== undefined && object.txhash !== null) { + message.txhash = object.txhash; + } else { + message.txhash = ""; + } + if (object.codespace !== undefined && object.codespace !== null) { + message.codespace = object.codespace; + } else { + message.codespace = ""; + } + if (object.code !== undefined && object.code !== null) { + message.code = object.code; + } else { + message.code = 0; + } + if (object.data !== undefined && object.data !== null) { + message.data = object.data; + } else { + message.data = ""; + } + if (object.rawLog !== undefined && object.rawLog !== null) { + message.rawLog = object.rawLog; + } else { + message.rawLog = ""; + } + if (object.logs !== undefined && object.logs !== null) { + for (const e of object.logs) { + message.logs.push(ABCIMessageLog.fromPartial(e)); + } + } + if (object.info !== undefined && object.info !== null) { + message.info = object.info; + } else { + message.info = ""; + } + if (object.gasWanted !== undefined && object.gasWanted !== null) { + message.gasWanted = object.gasWanted; + } else { + message.gasWanted = 0; + } + if (object.gasUsed !== undefined && object.gasUsed !== null) { + message.gasUsed = object.gasUsed; + } else { + message.gasUsed = 0; + } + if (object.tx !== undefined && object.tx !== null) { + message.tx = Any.fromPartial(object.tx); + } else { + message.tx = undefined; + } + if (object.timestamp !== undefined && object.timestamp !== null) { + message.timestamp = object.timestamp; + } else { + message.timestamp = ""; + } + if (object.events !== undefined && object.events !== null) { + for (const e of object.events) { + message.events.push(Event.fromPartial(e)); + } + } + return message; + }, +}; + +const baseABCIMessageLog: object = { msgIndex: 0, log: "" }; + +export const ABCIMessageLog = { + encode(message: ABCIMessageLog, writer: Writer = Writer.create()): Writer { + if (message.msgIndex !== 0) { + writer.uint32(8).uint32(message.msgIndex); + } + if (message.log !== "") { + writer.uint32(18).string(message.log); + } + for (const v of message.events) { + StringEvent.encode(v!, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ABCIMessageLog { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseABCIMessageLog } as ABCIMessageLog; + message.events = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.msgIndex = reader.uint32(); + break; + case 2: + message.log = reader.string(); + break; + case 3: + message.events.push(StringEvent.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ABCIMessageLog { + const message = { ...baseABCIMessageLog } as ABCIMessageLog; + message.events = []; + if (object.msgIndex !== undefined && object.msgIndex !== null) { + message.msgIndex = Number(object.msgIndex); + } else { + message.msgIndex = 0; + } + if (object.log !== undefined && object.log !== null) { + message.log = String(object.log); + } else { + message.log = ""; + } + if (object.events !== undefined && object.events !== null) { + for (const e of object.events) { + message.events.push(StringEvent.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: ABCIMessageLog): unknown { + const obj: any = {}; + message.msgIndex !== undefined && (obj.msgIndex = message.msgIndex); + message.log !== undefined && (obj.log = message.log); + if (message.events) { + obj.events = message.events.map((e) => + e ? StringEvent.toJSON(e) : undefined + ); + } else { + obj.events = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): ABCIMessageLog { + const message = { ...baseABCIMessageLog } as ABCIMessageLog; + message.events = []; + if (object.msgIndex !== undefined && object.msgIndex !== null) { + message.msgIndex = object.msgIndex; + } else { + message.msgIndex = 0; + } + if (object.log !== undefined && object.log !== null) { + message.log = object.log; + } else { + message.log = ""; + } + if (object.events !== undefined && object.events !== null) { + for (const e of object.events) { + message.events.push(StringEvent.fromPartial(e)); + } + } + return message; + }, +}; + +const baseStringEvent: object = { type: "" }; + +export const StringEvent = { + encode(message: StringEvent, writer: Writer = Writer.create()): Writer { + if (message.type !== "") { + writer.uint32(10).string(message.type); + } + for (const v of message.attributes) { + Attribute.encode(v!, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): StringEvent { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseStringEvent } as StringEvent; + message.attributes = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.type = reader.string(); + break; + case 2: + message.attributes.push(Attribute.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): StringEvent { + const message = { ...baseStringEvent } as StringEvent; + message.attributes = []; + if (object.type !== undefined && object.type !== null) { + message.type = String(object.type); + } else { + message.type = ""; + } + if (object.attributes !== undefined && object.attributes !== null) { + for (const e of object.attributes) { + message.attributes.push(Attribute.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: StringEvent): unknown { + const obj: any = {}; + message.type !== undefined && (obj.type = message.type); + if (message.attributes) { + obj.attributes = message.attributes.map((e) => + e ? Attribute.toJSON(e) : undefined + ); + } else { + obj.attributes = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): StringEvent { + const message = { ...baseStringEvent } as StringEvent; + message.attributes = []; + if (object.type !== undefined && object.type !== null) { + message.type = object.type; + } else { + message.type = ""; + } + if (object.attributes !== undefined && object.attributes !== null) { + for (const e of object.attributes) { + message.attributes.push(Attribute.fromPartial(e)); + } + } + return message; + }, +}; + +const baseAttribute: object = { key: "", value: "" }; + +export const Attribute = { + encode(message: Attribute, writer: Writer = Writer.create()): Writer { + if (message.key !== "") { + writer.uint32(10).string(message.key); + } + if (message.value !== "") { + writer.uint32(18).string(message.value); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Attribute { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseAttribute } as Attribute; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.key = reader.string(); + break; + case 2: + message.value = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Attribute { + const message = { ...baseAttribute } as Attribute; + if (object.key !== undefined && object.key !== null) { + message.key = String(object.key); + } else { + message.key = ""; + } + if (object.value !== undefined && object.value !== null) { + message.value = String(object.value); + } else { + message.value = ""; + } + return message; + }, + + toJSON(message: Attribute): unknown { + const obj: any = {}; + message.key !== undefined && (obj.key = message.key); + message.value !== undefined && (obj.value = message.value); + return obj; + }, + + fromPartial(object: DeepPartial): Attribute { + const message = { ...baseAttribute } as Attribute; + if (object.key !== undefined && object.key !== null) { + message.key = object.key; + } else { + message.key = ""; + } + if (object.value !== undefined && object.value !== null) { + message.value = object.value; + } else { + message.value = ""; + } + return message; + }, +}; + +const baseGasInfo: object = { gasWanted: 0, gasUsed: 0 }; + +export const GasInfo = { + encode(message: GasInfo, writer: Writer = Writer.create()): Writer { + if (message.gasWanted !== 0) { + writer.uint32(8).uint64(message.gasWanted); + } + if (message.gasUsed !== 0) { + writer.uint32(16).uint64(message.gasUsed); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): GasInfo { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseGasInfo } as GasInfo; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.gasWanted = longToNumber(reader.uint64() as Long); + break; + case 2: + message.gasUsed = longToNumber(reader.uint64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GasInfo { + const message = { ...baseGasInfo } as GasInfo; + if (object.gasWanted !== undefined && object.gasWanted !== null) { + message.gasWanted = Number(object.gasWanted); + } else { + message.gasWanted = 0; + } + if (object.gasUsed !== undefined && object.gasUsed !== null) { + message.gasUsed = Number(object.gasUsed); + } else { + message.gasUsed = 0; + } + return message; + }, + + toJSON(message: GasInfo): unknown { + const obj: any = {}; + message.gasWanted !== undefined && (obj.gasWanted = message.gasWanted); + message.gasUsed !== undefined && (obj.gasUsed = message.gasUsed); + return obj; + }, + + fromPartial(object: DeepPartial): GasInfo { + const message = { ...baseGasInfo } as GasInfo; + if (object.gasWanted !== undefined && object.gasWanted !== null) { + message.gasWanted = object.gasWanted; + } else { + message.gasWanted = 0; + } + if (object.gasUsed !== undefined && object.gasUsed !== null) { + message.gasUsed = object.gasUsed; + } else { + message.gasUsed = 0; + } + return message; + }, +}; + +const baseResult: object = { log: "" }; + +export const Result = { + encode(message: Result, writer: Writer = Writer.create()): Writer { + if (message.data.length !== 0) { + writer.uint32(10).bytes(message.data); + } + if (message.log !== "") { + writer.uint32(18).string(message.log); + } + for (const v of message.events) { + Event.encode(v!, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Result { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseResult } as Result; + message.events = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.data = reader.bytes(); + break; + case 2: + message.log = reader.string(); + break; + case 3: + message.events.push(Event.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Result { + const message = { ...baseResult } as Result; + message.events = []; + if (object.data !== undefined && object.data !== null) { + message.data = bytesFromBase64(object.data); + } + if (object.log !== undefined && object.log !== null) { + message.log = String(object.log); + } else { + message.log = ""; + } + if (object.events !== undefined && object.events !== null) { + for (const e of object.events) { + message.events.push(Event.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: Result): unknown { + const obj: any = {}; + message.data !== undefined && + (obj.data = base64FromBytes( + message.data !== undefined ? message.data : new Uint8Array() + )); + message.log !== undefined && (obj.log = message.log); + if (message.events) { + obj.events = message.events.map((e) => (e ? Event.toJSON(e) : undefined)); + } else { + obj.events = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): Result { + const message = { ...baseResult } as Result; + message.events = []; + if (object.data !== undefined && object.data !== null) { + message.data = object.data; + } else { + message.data = new Uint8Array(); + } + if (object.log !== undefined && object.log !== null) { + message.log = object.log; + } else { + message.log = ""; + } + if (object.events !== undefined && object.events !== null) { + for (const e of object.events) { + message.events.push(Event.fromPartial(e)); + } + } + return message; + }, +}; + +const baseSimulationResponse: object = {}; + +export const SimulationResponse = { + encode( + message: SimulationResponse, + writer: Writer = Writer.create() + ): Writer { + if (message.gasInfo !== undefined) { + GasInfo.encode(message.gasInfo, writer.uint32(10).fork()).ldelim(); + } + if (message.result !== undefined) { + Result.encode(message.result, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): SimulationResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseSimulationResponse } as SimulationResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.gasInfo = GasInfo.decode(reader, reader.uint32()); + break; + case 2: + message.result = Result.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): SimulationResponse { + const message = { ...baseSimulationResponse } as SimulationResponse; + if (object.gasInfo !== undefined && object.gasInfo !== null) { + message.gasInfo = GasInfo.fromJSON(object.gasInfo); + } else { + message.gasInfo = undefined; + } + if (object.result !== undefined && object.result !== null) { + message.result = Result.fromJSON(object.result); + } else { + message.result = undefined; + } + return message; + }, + + toJSON(message: SimulationResponse): unknown { + const obj: any = {}; + message.gasInfo !== undefined && + (obj.gasInfo = message.gasInfo + ? GasInfo.toJSON(message.gasInfo) + : undefined); + message.result !== undefined && + (obj.result = message.result ? Result.toJSON(message.result) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): SimulationResponse { + const message = { ...baseSimulationResponse } as SimulationResponse; + if (object.gasInfo !== undefined && object.gasInfo !== null) { + message.gasInfo = GasInfo.fromPartial(object.gasInfo); + } else { + message.gasInfo = undefined; + } + if (object.result !== undefined && object.result !== null) { + message.result = Result.fromPartial(object.result); + } else { + message.result = undefined; + } + return message; + }, +}; + +const baseMsgData: object = { msgType: "" }; + +export const MsgData = { + encode(message: MsgData, writer: Writer = Writer.create()): Writer { + if (message.msgType !== "") { + writer.uint32(10).string(message.msgType); + } + if (message.data.length !== 0) { + writer.uint32(18).bytes(message.data); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MsgData { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgData } as MsgData; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.msgType = reader.string(); + break; + case 2: + message.data = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgData { + const message = { ...baseMsgData } as MsgData; + if (object.msgType !== undefined && object.msgType !== null) { + message.msgType = String(object.msgType); + } else { + message.msgType = ""; + } + if (object.data !== undefined && object.data !== null) { + message.data = bytesFromBase64(object.data); + } + return message; + }, + + toJSON(message: MsgData): unknown { + const obj: any = {}; + message.msgType !== undefined && (obj.msgType = message.msgType); + message.data !== undefined && + (obj.data = base64FromBytes( + message.data !== undefined ? message.data : new Uint8Array() + )); + return obj; + }, + + fromPartial(object: DeepPartial): MsgData { + const message = { ...baseMsgData } as MsgData; + if (object.msgType !== undefined && object.msgType !== null) { + message.msgType = object.msgType; + } else { + message.msgType = ""; + } + if (object.data !== undefined && object.data !== null) { + message.data = object.data; + } else { + message.data = new Uint8Array(); + } + return message; + }, +}; + +const baseTxMsgData: object = {}; + +export const TxMsgData = { + encode(message: TxMsgData, writer: Writer = Writer.create()): Writer { + for (const v of message.data) { + MsgData.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): TxMsgData { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseTxMsgData } as TxMsgData; + message.data = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.data.push(MsgData.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): TxMsgData { + const message = { ...baseTxMsgData } as TxMsgData; + message.data = []; + if (object.data !== undefined && object.data !== null) { + for (const e of object.data) { + message.data.push(MsgData.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: TxMsgData): unknown { + const obj: any = {}; + if (message.data) { + obj.data = message.data.map((e) => (e ? MsgData.toJSON(e) : undefined)); + } else { + obj.data = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): TxMsgData { + const message = { ...baseTxMsgData } as TxMsgData; + message.data = []; + if (object.data !== undefined && object.data !== null) { + for (const e of object.data) { + message.data.push(MsgData.fromPartial(e)); + } + } + return message; + }, +}; + +const baseSearchTxsResult: object = { + totalCount: 0, + count: 0, + pageNumber: 0, + pageTotal: 0, + limit: 0, +}; + +export const SearchTxsResult = { + encode(message: SearchTxsResult, writer: Writer = Writer.create()): Writer { + if (message.totalCount !== 0) { + writer.uint32(8).uint64(message.totalCount); + } + if (message.count !== 0) { + writer.uint32(16).uint64(message.count); + } + if (message.pageNumber !== 0) { + writer.uint32(24).uint64(message.pageNumber); + } + if (message.pageTotal !== 0) { + writer.uint32(32).uint64(message.pageTotal); + } + if (message.limit !== 0) { + writer.uint32(40).uint64(message.limit); + } + for (const v of message.txs) { + TxResponse.encode(v!, writer.uint32(50).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): SearchTxsResult { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseSearchTxsResult } as SearchTxsResult; + message.txs = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.totalCount = longToNumber(reader.uint64() as Long); + break; + case 2: + message.count = longToNumber(reader.uint64() as Long); + break; + case 3: + message.pageNumber = longToNumber(reader.uint64() as Long); + break; + case 4: + message.pageTotal = longToNumber(reader.uint64() as Long); + break; + case 5: + message.limit = longToNumber(reader.uint64() as Long); + break; + case 6: + message.txs.push(TxResponse.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): SearchTxsResult { + const message = { ...baseSearchTxsResult } as SearchTxsResult; + message.txs = []; + if (object.totalCount !== undefined && object.totalCount !== null) { + message.totalCount = Number(object.totalCount); + } else { + message.totalCount = 0; + } + if (object.count !== undefined && object.count !== null) { + message.count = Number(object.count); + } else { + message.count = 0; + } + if (object.pageNumber !== undefined && object.pageNumber !== null) { + message.pageNumber = Number(object.pageNumber); + } else { + message.pageNumber = 0; + } + if (object.pageTotal !== undefined && object.pageTotal !== null) { + message.pageTotal = Number(object.pageTotal); + } else { + message.pageTotal = 0; + } + if (object.limit !== undefined && object.limit !== null) { + message.limit = Number(object.limit); + } else { + message.limit = 0; + } + if (object.txs !== undefined && object.txs !== null) { + for (const e of object.txs) { + message.txs.push(TxResponse.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: SearchTxsResult): unknown { + const obj: any = {}; + message.totalCount !== undefined && (obj.totalCount = message.totalCount); + message.count !== undefined && (obj.count = message.count); + message.pageNumber !== undefined && (obj.pageNumber = message.pageNumber); + message.pageTotal !== undefined && (obj.pageTotal = message.pageTotal); + message.limit !== undefined && (obj.limit = message.limit); + if (message.txs) { + obj.txs = message.txs.map((e) => (e ? TxResponse.toJSON(e) : undefined)); + } else { + obj.txs = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): SearchTxsResult { + const message = { ...baseSearchTxsResult } as SearchTxsResult; + message.txs = []; + if (object.totalCount !== undefined && object.totalCount !== null) { + message.totalCount = object.totalCount; + } else { + message.totalCount = 0; + } + if (object.count !== undefined && object.count !== null) { + message.count = object.count; + } else { + message.count = 0; + } + if (object.pageNumber !== undefined && object.pageNumber !== null) { + message.pageNumber = object.pageNumber; + } else { + message.pageNumber = 0; + } + if (object.pageTotal !== undefined && object.pageTotal !== null) { + message.pageTotal = object.pageTotal; + } else { + message.pageTotal = 0; + } + if (object.limit !== undefined && object.limit !== null) { + message.limit = object.limit; + } else { + message.limit = 0; + } + if (object.txs !== undefined && object.txs !== null) { + for (const e of object.txs) { + message.txs.push(TxResponse.fromPartial(e)); + } + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/cosmos.tx.v1beta1/types/cosmos/base/query/v1beta1/pagination.ts b/ts-client/cosmos.tx.v1beta1/types/cosmos/base/query/v1beta1/pagination.ts new file mode 100644 index 00000000..cd4b2d78 --- /dev/null +++ b/ts-client/cosmos.tx.v1beta1/types/cosmos/base/query/v1beta1/pagination.ts @@ -0,0 +1,327 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "cosmos.base.query.v1beta1"; + +/** + * PageRequest is to be embedded in gRPC request messages for efficient + * pagination. Ex: + * + * message SomeRequest { + * Foo some_parameter = 1; + * PageRequest pagination = 2; + * } + */ +export interface PageRequest { + /** + * key is a value returned in PageResponse.next_key to begin + * querying the next page most efficiently. Only one of offset or key + * should be set. + */ + key: Uint8Array; + /** + * offset is a numeric offset that can be used when key is unavailable. + * It is less efficient than using key. Only one of offset or key should + * be set. + */ + offset: number; + /** + * limit is the total number of results to be returned in the result page. + * If left empty it will default to a value to be set by each app. + */ + limit: number; + /** + * count_total is set to true to indicate that the result set should include + * a count of the total number of items available for pagination in UIs. + * count_total is only respected when offset is used. It is ignored when key + * is set. + */ + countTotal: boolean; + /** + * reverse is set to true if results are to be returned in the descending order. + * + * Since: cosmos-sdk 0.43 + */ + reverse: boolean; +} + +/** + * PageResponse is to be embedded in gRPC response messages where the + * corresponding request message has used PageRequest. + * + * message SomeResponse { + * repeated Bar results = 1; + * PageResponse page = 2; + * } + */ +export interface PageResponse { + /** + * next_key is the key to be passed to PageRequest.key to + * query the next page most efficiently + */ + nextKey: Uint8Array; + /** + * total is total number of results available if PageRequest.count_total + * was set, its value is undefined otherwise + */ + total: number; +} + +const basePageRequest: object = { + offset: 0, + limit: 0, + countTotal: false, + reverse: false, +}; + +export const PageRequest = { + encode(message: PageRequest, writer: Writer = Writer.create()): Writer { + if (message.key.length !== 0) { + writer.uint32(10).bytes(message.key); + } + if (message.offset !== 0) { + writer.uint32(16).uint64(message.offset); + } + if (message.limit !== 0) { + writer.uint32(24).uint64(message.limit); + } + if (message.countTotal === true) { + writer.uint32(32).bool(message.countTotal); + } + if (message.reverse === true) { + writer.uint32(40).bool(message.reverse); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): PageRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...basePageRequest } as PageRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.key = reader.bytes(); + break; + case 2: + message.offset = longToNumber(reader.uint64() as Long); + break; + case 3: + message.limit = longToNumber(reader.uint64() as Long); + break; + case 4: + message.countTotal = reader.bool(); + break; + case 5: + message.reverse = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): PageRequest { + const message = { ...basePageRequest } as PageRequest; + if (object.key !== undefined && object.key !== null) { + message.key = bytesFromBase64(object.key); + } + if (object.offset !== undefined && object.offset !== null) { + message.offset = Number(object.offset); + } else { + message.offset = 0; + } + if (object.limit !== undefined && object.limit !== null) { + message.limit = Number(object.limit); + } else { + message.limit = 0; + } + if (object.countTotal !== undefined && object.countTotal !== null) { + message.countTotal = Boolean(object.countTotal); + } else { + message.countTotal = false; + } + if (object.reverse !== undefined && object.reverse !== null) { + message.reverse = Boolean(object.reverse); + } else { + message.reverse = false; + } + return message; + }, + + toJSON(message: PageRequest): unknown { + const obj: any = {}; + message.key !== undefined && + (obj.key = base64FromBytes( + message.key !== undefined ? message.key : new Uint8Array() + )); + message.offset !== undefined && (obj.offset = message.offset); + message.limit !== undefined && (obj.limit = message.limit); + message.countTotal !== undefined && (obj.countTotal = message.countTotal); + message.reverse !== undefined && (obj.reverse = message.reverse); + return obj; + }, + + fromPartial(object: DeepPartial): PageRequest { + const message = { ...basePageRequest } as PageRequest; + if (object.key !== undefined && object.key !== null) { + message.key = object.key; + } else { + message.key = new Uint8Array(); + } + if (object.offset !== undefined && object.offset !== null) { + message.offset = object.offset; + } else { + message.offset = 0; + } + if (object.limit !== undefined && object.limit !== null) { + message.limit = object.limit; + } else { + message.limit = 0; + } + if (object.countTotal !== undefined && object.countTotal !== null) { + message.countTotal = object.countTotal; + } else { + message.countTotal = false; + } + if (object.reverse !== undefined && object.reverse !== null) { + message.reverse = object.reverse; + } else { + message.reverse = false; + } + return message; + }, +}; + +const basePageResponse: object = { total: 0 }; + +export const PageResponse = { + encode(message: PageResponse, writer: Writer = Writer.create()): Writer { + if (message.nextKey.length !== 0) { + writer.uint32(10).bytes(message.nextKey); + } + if (message.total !== 0) { + writer.uint32(16).uint64(message.total); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): PageResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...basePageResponse } as PageResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.nextKey = reader.bytes(); + break; + case 2: + message.total = longToNumber(reader.uint64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): PageResponse { + const message = { ...basePageResponse } as PageResponse; + if (object.nextKey !== undefined && object.nextKey !== null) { + message.nextKey = bytesFromBase64(object.nextKey); + } + if (object.total !== undefined && object.total !== null) { + message.total = Number(object.total); + } else { + message.total = 0; + } + return message; + }, + + toJSON(message: PageResponse): unknown { + const obj: any = {}; + message.nextKey !== undefined && + (obj.nextKey = base64FromBytes( + message.nextKey !== undefined ? message.nextKey : new Uint8Array() + )); + message.total !== undefined && (obj.total = message.total); + return obj; + }, + + fromPartial(object: DeepPartial): PageResponse { + const message = { ...basePageResponse } as PageResponse; + if (object.nextKey !== undefined && object.nextKey !== null) { + message.nextKey = object.nextKey; + } else { + message.nextKey = new Uint8Array(); + } + if (object.total !== undefined && object.total !== null) { + message.total = object.total; + } else { + message.total = 0; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/cosmos.tx.v1beta1/types/cosmos/base/v1beta1/coin.ts b/ts-client/cosmos.tx.v1beta1/types/cosmos/base/v1beta1/coin.ts new file mode 100644 index 00000000..ce2ac984 --- /dev/null +++ b/ts-client/cosmos.tx.v1beta1/types/cosmos/base/v1beta1/coin.ts @@ -0,0 +1,301 @@ +/* eslint-disable */ +import { Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "cosmos.base.v1beta1"; + +/** + * Coin defines a token with a denomination and an amount. + * + * NOTE: The amount field is an Int which implements the custom method + * signatures required by gogoproto. + */ +export interface Coin { + denom: string; + amount: string; +} + +/** + * DecCoin defines a token with a denomination and a decimal amount. + * + * NOTE: The amount field is an Dec which implements the custom method + * signatures required by gogoproto. + */ +export interface DecCoin { + denom: string; + amount: string; +} + +/** IntProto defines a Protobuf wrapper around an Int object. */ +export interface IntProto { + int: string; +} + +/** DecProto defines a Protobuf wrapper around a Dec object. */ +export interface DecProto { + dec: string; +} + +const baseCoin: object = { denom: "", amount: "" }; + +export const Coin = { + encode(message: Coin, writer: Writer = Writer.create()): Writer { + if (message.denom !== "") { + writer.uint32(10).string(message.denom); + } + if (message.amount !== "") { + writer.uint32(18).string(message.amount); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Coin { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseCoin } as Coin; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.denom = reader.string(); + break; + case 2: + message.amount = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Coin { + const message = { ...baseCoin } as Coin; + if (object.denom !== undefined && object.denom !== null) { + message.denom = String(object.denom); + } else { + message.denom = ""; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = String(object.amount); + } else { + message.amount = ""; + } + return message; + }, + + toJSON(message: Coin): unknown { + const obj: any = {}; + message.denom !== undefined && (obj.denom = message.denom); + message.amount !== undefined && (obj.amount = message.amount); + return obj; + }, + + fromPartial(object: DeepPartial): Coin { + const message = { ...baseCoin } as Coin; + if (object.denom !== undefined && object.denom !== null) { + message.denom = object.denom; + } else { + message.denom = ""; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = object.amount; + } else { + message.amount = ""; + } + return message; + }, +}; + +const baseDecCoin: object = { denom: "", amount: "" }; + +export const DecCoin = { + encode(message: DecCoin, writer: Writer = Writer.create()): Writer { + if (message.denom !== "") { + writer.uint32(10).string(message.denom); + } + if (message.amount !== "") { + writer.uint32(18).string(message.amount); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): DecCoin { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseDecCoin } as DecCoin; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.denom = reader.string(); + break; + case 2: + message.amount = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DecCoin { + const message = { ...baseDecCoin } as DecCoin; + if (object.denom !== undefined && object.denom !== null) { + message.denom = String(object.denom); + } else { + message.denom = ""; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = String(object.amount); + } else { + message.amount = ""; + } + return message; + }, + + toJSON(message: DecCoin): unknown { + const obj: any = {}; + message.denom !== undefined && (obj.denom = message.denom); + message.amount !== undefined && (obj.amount = message.amount); + return obj; + }, + + fromPartial(object: DeepPartial): DecCoin { + const message = { ...baseDecCoin } as DecCoin; + if (object.denom !== undefined && object.denom !== null) { + message.denom = object.denom; + } else { + message.denom = ""; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = object.amount; + } else { + message.amount = ""; + } + return message; + }, +}; + +const baseIntProto: object = { int: "" }; + +export const IntProto = { + encode(message: IntProto, writer: Writer = Writer.create()): Writer { + if (message.int !== "") { + writer.uint32(10).string(message.int); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): IntProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseIntProto } as IntProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.int = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): IntProto { + const message = { ...baseIntProto } as IntProto; + if (object.int !== undefined && object.int !== null) { + message.int = String(object.int); + } else { + message.int = ""; + } + return message; + }, + + toJSON(message: IntProto): unknown { + const obj: any = {}; + message.int !== undefined && (obj.int = message.int); + return obj; + }, + + fromPartial(object: DeepPartial): IntProto { + const message = { ...baseIntProto } as IntProto; + if (object.int !== undefined && object.int !== null) { + message.int = object.int; + } else { + message.int = ""; + } + return message; + }, +}; + +const baseDecProto: object = { dec: "" }; + +export const DecProto = { + encode(message: DecProto, writer: Writer = Writer.create()): Writer { + if (message.dec !== "") { + writer.uint32(10).string(message.dec); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): DecProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseDecProto } as DecProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.dec = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DecProto { + const message = { ...baseDecProto } as DecProto; + if (object.dec !== undefined && object.dec !== null) { + message.dec = String(object.dec); + } else { + message.dec = ""; + } + return message; + }, + + toJSON(message: DecProto): unknown { + const obj: any = {}; + message.dec !== undefined && (obj.dec = message.dec); + return obj; + }, + + fromPartial(object: DeepPartial): DecProto { + const message = { ...baseDecProto } as DecProto; + if (object.dec !== undefined && object.dec !== null) { + message.dec = object.dec; + } else { + message.dec = ""; + } + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/cosmos.tx.v1beta1/types/cosmos/crypto/multisig/v1beta1/multisig.ts b/ts-client/cosmos.tx.v1beta1/types/cosmos/crypto/multisig/v1beta1/multisig.ts new file mode 100644 index 00000000..fb338cb8 --- /dev/null +++ b/ts-client/cosmos.tx.v1beta1/types/cosmos/crypto/multisig/v1beta1/multisig.ts @@ -0,0 +1,212 @@ +/* eslint-disable */ +import { Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "cosmos.crypto.multisig.v1beta1"; + +/** + * MultiSignature wraps the signatures from a multisig.LegacyAminoPubKey. + * See cosmos.tx.v1betata1.ModeInfo.Multi for how to specify which signers + * signed and with which modes. + */ +export interface MultiSignature { + signatures: Uint8Array[]; +} + +/** + * CompactBitArray is an implementation of a space efficient bit array. + * This is used to ensure that the encoded data takes up a minimal amount of + * space after proto encoding. + * This is not thread safe, and is not intended for concurrent usage. + */ +export interface CompactBitArray { + extraBitsStored: number; + elems: Uint8Array; +} + +const baseMultiSignature: object = {}; + +export const MultiSignature = { + encode(message: MultiSignature, writer: Writer = Writer.create()): Writer { + for (const v of message.signatures) { + writer.uint32(10).bytes(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MultiSignature { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMultiSignature } as MultiSignature; + message.signatures = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.signatures.push(reader.bytes()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MultiSignature { + const message = { ...baseMultiSignature } as MultiSignature; + message.signatures = []; + if (object.signatures !== undefined && object.signatures !== null) { + for (const e of object.signatures) { + message.signatures.push(bytesFromBase64(e)); + } + } + return message; + }, + + toJSON(message: MultiSignature): unknown { + const obj: any = {}; + if (message.signatures) { + obj.signatures = message.signatures.map((e) => + base64FromBytes(e !== undefined ? e : new Uint8Array()) + ); + } else { + obj.signatures = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): MultiSignature { + const message = { ...baseMultiSignature } as MultiSignature; + message.signatures = []; + if (object.signatures !== undefined && object.signatures !== null) { + for (const e of object.signatures) { + message.signatures.push(e); + } + } + return message; + }, +}; + +const baseCompactBitArray: object = { extraBitsStored: 0 }; + +export const CompactBitArray = { + encode(message: CompactBitArray, writer: Writer = Writer.create()): Writer { + if (message.extraBitsStored !== 0) { + writer.uint32(8).uint32(message.extraBitsStored); + } + if (message.elems.length !== 0) { + writer.uint32(18).bytes(message.elems); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): CompactBitArray { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseCompactBitArray } as CompactBitArray; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.extraBitsStored = reader.uint32(); + break; + case 2: + message.elems = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): CompactBitArray { + const message = { ...baseCompactBitArray } as CompactBitArray; + if ( + object.extraBitsStored !== undefined && + object.extraBitsStored !== null + ) { + message.extraBitsStored = Number(object.extraBitsStored); + } else { + message.extraBitsStored = 0; + } + if (object.elems !== undefined && object.elems !== null) { + message.elems = bytesFromBase64(object.elems); + } + return message; + }, + + toJSON(message: CompactBitArray): unknown { + const obj: any = {}; + message.extraBitsStored !== undefined && + (obj.extraBitsStored = message.extraBitsStored); + message.elems !== undefined && + (obj.elems = base64FromBytes( + message.elems !== undefined ? message.elems : new Uint8Array() + )); + return obj; + }, + + fromPartial(object: DeepPartial): CompactBitArray { + const message = { ...baseCompactBitArray } as CompactBitArray; + if ( + object.extraBitsStored !== undefined && + object.extraBitsStored !== null + ) { + message.extraBitsStored = object.extraBitsStored; + } else { + message.extraBitsStored = 0; + } + if (object.elems !== undefined && object.elems !== null) { + message.elems = object.elems; + } else { + message.elems = new Uint8Array(); + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/cosmos.tx.v1beta1/types/cosmos/tx/signing/v1beta1/signing.ts b/ts-client/cosmos.tx.v1beta1/types/cosmos/tx/signing/v1beta1/signing.ts new file mode 100644 index 00000000..9c92cab1 --- /dev/null +++ b/ts-client/cosmos.tx.v1beta1/types/cosmos/tx/signing/v1beta1/signing.ts @@ -0,0 +1,660 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; +import { Any } from "../../../../google/protobuf/any"; +import { CompactBitArray } from "../../../../cosmos/crypto/multisig/v1beta1/multisig"; + +export const protobufPackage = "cosmos.tx.signing.v1beta1"; + +/** SignMode represents a signing mode with its own security guarantees. */ +export enum SignMode { + /** + * SIGN_MODE_UNSPECIFIED - SIGN_MODE_UNSPECIFIED specifies an unknown signing mode and will be + * rejected + */ + SIGN_MODE_UNSPECIFIED = 0, + /** + * SIGN_MODE_DIRECT - SIGN_MODE_DIRECT specifies a signing mode which uses SignDoc and is + * verified with raw bytes from Tx + */ + SIGN_MODE_DIRECT = 1, + /** + * SIGN_MODE_TEXTUAL - SIGN_MODE_TEXTUAL is a future signing mode that will verify some + * human-readable textual representation on top of the binary representation + * from SIGN_MODE_DIRECT + */ + SIGN_MODE_TEXTUAL = 2, + /** + * SIGN_MODE_LEGACY_AMINO_JSON - SIGN_MODE_LEGACY_AMINO_JSON is a backwards compatibility mode which uses + * Amino JSON and will be removed in the future + */ + SIGN_MODE_LEGACY_AMINO_JSON = 127, + /** + * SIGN_MODE_EIP_191 - SIGN_MODE_EIP_191 specifies the sign mode for EIP 191 signing on the Cosmos + * SDK. Ref: https://eips.ethereum.org/EIPS/eip-191 + * + * Currently, SIGN_MODE_EIP_191 is registered as a SignMode enum variant, + * but is not implemented on the SDK by default. To enable EIP-191, you need + * to pass a custom `TxConfig` that has an implementation of + * `SignModeHandler` for EIP-191. The SDK may decide to fully support + * EIP-191 in the future. + * + * Since: cosmos-sdk 0.45.2 + */ + SIGN_MODE_EIP_191 = 191, + UNRECOGNIZED = -1, +} + +export function signModeFromJSON(object: any): SignMode { + switch (object) { + case 0: + case "SIGN_MODE_UNSPECIFIED": + return SignMode.SIGN_MODE_UNSPECIFIED; + case 1: + case "SIGN_MODE_DIRECT": + return SignMode.SIGN_MODE_DIRECT; + case 2: + case "SIGN_MODE_TEXTUAL": + return SignMode.SIGN_MODE_TEXTUAL; + case 127: + case "SIGN_MODE_LEGACY_AMINO_JSON": + return SignMode.SIGN_MODE_LEGACY_AMINO_JSON; + case 191: + case "SIGN_MODE_EIP_191": + return SignMode.SIGN_MODE_EIP_191; + case -1: + case "UNRECOGNIZED": + default: + return SignMode.UNRECOGNIZED; + } +} + +export function signModeToJSON(object: SignMode): string { + switch (object) { + case SignMode.SIGN_MODE_UNSPECIFIED: + return "SIGN_MODE_UNSPECIFIED"; + case SignMode.SIGN_MODE_DIRECT: + return "SIGN_MODE_DIRECT"; + case SignMode.SIGN_MODE_TEXTUAL: + return "SIGN_MODE_TEXTUAL"; + case SignMode.SIGN_MODE_LEGACY_AMINO_JSON: + return "SIGN_MODE_LEGACY_AMINO_JSON"; + case SignMode.SIGN_MODE_EIP_191: + return "SIGN_MODE_EIP_191"; + default: + return "UNKNOWN"; + } +} + +/** SignatureDescriptors wraps multiple SignatureDescriptor's. */ +export interface SignatureDescriptors { + /** signatures are the signature descriptors */ + signatures: SignatureDescriptor[]; +} + +/** + * SignatureDescriptor is a convenience type which represents the full data for + * a signature including the public key of the signer, signing modes and the + * signature itself. It is primarily used for coordinating signatures between + * clients. + */ +export interface SignatureDescriptor { + /** public_key is the public key of the signer */ + publicKey: Any | undefined; + data: SignatureDescriptor_Data | undefined; + /** + * sequence is the sequence of the account, which describes the + * number of committed transactions signed by a given address. It is used to prevent + * replay attacks. + */ + sequence: number; +} + +/** Data represents signature data */ +export interface SignatureDescriptor_Data { + /** single represents a single signer */ + single: SignatureDescriptor_Data_Single | undefined; + /** multi represents a multisig signer */ + multi: SignatureDescriptor_Data_Multi | undefined; +} + +/** Single is the signature data for a single signer */ +export interface SignatureDescriptor_Data_Single { + /** mode is the signing mode of the single signer */ + mode: SignMode; + /** signature is the raw signature bytes */ + signature: Uint8Array; +} + +/** Multi is the signature data for a multisig public key */ +export interface SignatureDescriptor_Data_Multi { + /** bitarray specifies which keys within the multisig are signing */ + bitarray: CompactBitArray | undefined; + /** signatures is the signatures of the multi-signature */ + signatures: SignatureDescriptor_Data[]; +} + +const baseSignatureDescriptors: object = {}; + +export const SignatureDescriptors = { + encode( + message: SignatureDescriptors, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.signatures) { + SignatureDescriptor.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): SignatureDescriptors { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseSignatureDescriptors } as SignatureDescriptors; + message.signatures = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.signatures.push( + SignatureDescriptor.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): SignatureDescriptors { + const message = { ...baseSignatureDescriptors } as SignatureDescriptors; + message.signatures = []; + if (object.signatures !== undefined && object.signatures !== null) { + for (const e of object.signatures) { + message.signatures.push(SignatureDescriptor.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: SignatureDescriptors): unknown { + const obj: any = {}; + if (message.signatures) { + obj.signatures = message.signatures.map((e) => + e ? SignatureDescriptor.toJSON(e) : undefined + ); + } else { + obj.signatures = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): SignatureDescriptors { + const message = { ...baseSignatureDescriptors } as SignatureDescriptors; + message.signatures = []; + if (object.signatures !== undefined && object.signatures !== null) { + for (const e of object.signatures) { + message.signatures.push(SignatureDescriptor.fromPartial(e)); + } + } + return message; + }, +}; + +const baseSignatureDescriptor: object = { sequence: 0 }; + +export const SignatureDescriptor = { + encode( + message: SignatureDescriptor, + writer: Writer = Writer.create() + ): Writer { + if (message.publicKey !== undefined) { + Any.encode(message.publicKey, writer.uint32(10).fork()).ldelim(); + } + if (message.data !== undefined) { + SignatureDescriptor_Data.encode( + message.data, + writer.uint32(18).fork() + ).ldelim(); + } + if (message.sequence !== 0) { + writer.uint32(24).uint64(message.sequence); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): SignatureDescriptor { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseSignatureDescriptor } as SignatureDescriptor; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.publicKey = Any.decode(reader, reader.uint32()); + break; + case 2: + message.data = SignatureDescriptor_Data.decode( + reader, + reader.uint32() + ); + break; + case 3: + message.sequence = longToNumber(reader.uint64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): SignatureDescriptor { + const message = { ...baseSignatureDescriptor } as SignatureDescriptor; + if (object.publicKey !== undefined && object.publicKey !== null) { + message.publicKey = Any.fromJSON(object.publicKey); + } else { + message.publicKey = undefined; + } + if (object.data !== undefined && object.data !== null) { + message.data = SignatureDescriptor_Data.fromJSON(object.data); + } else { + message.data = undefined; + } + if (object.sequence !== undefined && object.sequence !== null) { + message.sequence = Number(object.sequence); + } else { + message.sequence = 0; + } + return message; + }, + + toJSON(message: SignatureDescriptor): unknown { + const obj: any = {}; + message.publicKey !== undefined && + (obj.publicKey = message.publicKey + ? Any.toJSON(message.publicKey) + : undefined); + message.data !== undefined && + (obj.data = message.data + ? SignatureDescriptor_Data.toJSON(message.data) + : undefined); + message.sequence !== undefined && (obj.sequence = message.sequence); + return obj; + }, + + fromPartial(object: DeepPartial): SignatureDescriptor { + const message = { ...baseSignatureDescriptor } as SignatureDescriptor; + if (object.publicKey !== undefined && object.publicKey !== null) { + message.publicKey = Any.fromPartial(object.publicKey); + } else { + message.publicKey = undefined; + } + if (object.data !== undefined && object.data !== null) { + message.data = SignatureDescriptor_Data.fromPartial(object.data); + } else { + message.data = undefined; + } + if (object.sequence !== undefined && object.sequence !== null) { + message.sequence = object.sequence; + } else { + message.sequence = 0; + } + return message; + }, +}; + +const baseSignatureDescriptor_Data: object = {}; + +export const SignatureDescriptor_Data = { + encode( + message: SignatureDescriptor_Data, + writer: Writer = Writer.create() + ): Writer { + if (message.single !== undefined) { + SignatureDescriptor_Data_Single.encode( + message.single, + writer.uint32(10).fork() + ).ldelim(); + } + if (message.multi !== undefined) { + SignatureDescriptor_Data_Multi.encode( + message.multi, + writer.uint32(18).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): SignatureDescriptor_Data { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseSignatureDescriptor_Data, + } as SignatureDescriptor_Data; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.single = SignatureDescriptor_Data_Single.decode( + reader, + reader.uint32() + ); + break; + case 2: + message.multi = SignatureDescriptor_Data_Multi.decode( + reader, + reader.uint32() + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): SignatureDescriptor_Data { + const message = { + ...baseSignatureDescriptor_Data, + } as SignatureDescriptor_Data; + if (object.single !== undefined && object.single !== null) { + message.single = SignatureDescriptor_Data_Single.fromJSON(object.single); + } else { + message.single = undefined; + } + if (object.multi !== undefined && object.multi !== null) { + message.multi = SignatureDescriptor_Data_Multi.fromJSON(object.multi); + } else { + message.multi = undefined; + } + return message; + }, + + toJSON(message: SignatureDescriptor_Data): unknown { + const obj: any = {}; + message.single !== undefined && + (obj.single = message.single + ? SignatureDescriptor_Data_Single.toJSON(message.single) + : undefined); + message.multi !== undefined && + (obj.multi = message.multi + ? SignatureDescriptor_Data_Multi.toJSON(message.multi) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): SignatureDescriptor_Data { + const message = { + ...baseSignatureDescriptor_Data, + } as SignatureDescriptor_Data; + if (object.single !== undefined && object.single !== null) { + message.single = SignatureDescriptor_Data_Single.fromPartial( + object.single + ); + } else { + message.single = undefined; + } + if (object.multi !== undefined && object.multi !== null) { + message.multi = SignatureDescriptor_Data_Multi.fromPartial(object.multi); + } else { + message.multi = undefined; + } + return message; + }, +}; + +const baseSignatureDescriptor_Data_Single: object = { mode: 0 }; + +export const SignatureDescriptor_Data_Single = { + encode( + message: SignatureDescriptor_Data_Single, + writer: Writer = Writer.create() + ): Writer { + if (message.mode !== 0) { + writer.uint32(8).int32(message.mode); + } + if (message.signature.length !== 0) { + writer.uint32(18).bytes(message.signature); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): SignatureDescriptor_Data_Single { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseSignatureDescriptor_Data_Single, + } as SignatureDescriptor_Data_Single; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.mode = reader.int32() as any; + break; + case 2: + message.signature = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): SignatureDescriptor_Data_Single { + const message = { + ...baseSignatureDescriptor_Data_Single, + } as SignatureDescriptor_Data_Single; + if (object.mode !== undefined && object.mode !== null) { + message.mode = signModeFromJSON(object.mode); + } else { + message.mode = 0; + } + if (object.signature !== undefined && object.signature !== null) { + message.signature = bytesFromBase64(object.signature); + } + return message; + }, + + toJSON(message: SignatureDescriptor_Data_Single): unknown { + const obj: any = {}; + message.mode !== undefined && (obj.mode = signModeToJSON(message.mode)); + message.signature !== undefined && + (obj.signature = base64FromBytes( + message.signature !== undefined ? message.signature : new Uint8Array() + )); + return obj; + }, + + fromPartial( + object: DeepPartial + ): SignatureDescriptor_Data_Single { + const message = { + ...baseSignatureDescriptor_Data_Single, + } as SignatureDescriptor_Data_Single; + if (object.mode !== undefined && object.mode !== null) { + message.mode = object.mode; + } else { + message.mode = 0; + } + if (object.signature !== undefined && object.signature !== null) { + message.signature = object.signature; + } else { + message.signature = new Uint8Array(); + } + return message; + }, +}; + +const baseSignatureDescriptor_Data_Multi: object = {}; + +export const SignatureDescriptor_Data_Multi = { + encode( + message: SignatureDescriptor_Data_Multi, + writer: Writer = Writer.create() + ): Writer { + if (message.bitarray !== undefined) { + CompactBitArray.encode( + message.bitarray, + writer.uint32(10).fork() + ).ldelim(); + } + for (const v of message.signatures) { + SignatureDescriptor_Data.encode(v!, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): SignatureDescriptor_Data_Multi { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseSignatureDescriptor_Data_Multi, + } as SignatureDescriptor_Data_Multi; + message.signatures = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.bitarray = CompactBitArray.decode(reader, reader.uint32()); + break; + case 2: + message.signatures.push( + SignatureDescriptor_Data.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): SignatureDescriptor_Data_Multi { + const message = { + ...baseSignatureDescriptor_Data_Multi, + } as SignatureDescriptor_Data_Multi; + message.signatures = []; + if (object.bitarray !== undefined && object.bitarray !== null) { + message.bitarray = CompactBitArray.fromJSON(object.bitarray); + } else { + message.bitarray = undefined; + } + if (object.signatures !== undefined && object.signatures !== null) { + for (const e of object.signatures) { + message.signatures.push(SignatureDescriptor_Data.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: SignatureDescriptor_Data_Multi): unknown { + const obj: any = {}; + message.bitarray !== undefined && + (obj.bitarray = message.bitarray + ? CompactBitArray.toJSON(message.bitarray) + : undefined); + if (message.signatures) { + obj.signatures = message.signatures.map((e) => + e ? SignatureDescriptor_Data.toJSON(e) : undefined + ); + } else { + obj.signatures = []; + } + return obj; + }, + + fromPartial( + object: DeepPartial + ): SignatureDescriptor_Data_Multi { + const message = { + ...baseSignatureDescriptor_Data_Multi, + } as SignatureDescriptor_Data_Multi; + message.signatures = []; + if (object.bitarray !== undefined && object.bitarray !== null) { + message.bitarray = CompactBitArray.fromPartial(object.bitarray); + } else { + message.bitarray = undefined; + } + if (object.signatures !== undefined && object.signatures !== null) { + for (const e of object.signatures) { + message.signatures.push(SignatureDescriptor_Data.fromPartial(e)); + } + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/cosmos.tx.v1beta1/types/cosmos/tx/v1beta1/service.ts b/ts-client/cosmos.tx.v1beta1/types/cosmos/tx/v1beta1/service.ts new file mode 100644 index 00000000..3edd2a88 --- /dev/null +++ b/ts-client/cosmos.tx.v1beta1/types/cosmos/tx/v1beta1/service.ts @@ -0,0 +1,1230 @@ +/* eslint-disable */ +import { Reader, util, configure, Writer } from "protobufjs/minimal"; +import * as Long from "long"; +import { + PageRequest, + PageResponse, +} from "../../../cosmos/base/query/v1beta1/pagination"; +import { Tx } from "../../../cosmos/tx/v1beta1/tx"; +import { + TxResponse, + GasInfo, + Result, +} from "../../../cosmos/base/abci/v1beta1/abci"; +import { BlockID } from "../../../tendermint/types/types"; +import { Block } from "../../../tendermint/types/block"; + +export const protobufPackage = "cosmos.tx.v1beta1"; + +/** OrderBy defines the sorting order */ +export enum OrderBy { + /** ORDER_BY_UNSPECIFIED - ORDER_BY_UNSPECIFIED specifies an unknown sorting order. OrderBy defaults to ASC in this case. */ + ORDER_BY_UNSPECIFIED = 0, + /** ORDER_BY_ASC - ORDER_BY_ASC defines ascending order */ + ORDER_BY_ASC = 1, + /** ORDER_BY_DESC - ORDER_BY_DESC defines descending order */ + ORDER_BY_DESC = 2, + UNRECOGNIZED = -1, +} + +export function orderByFromJSON(object: any): OrderBy { + switch (object) { + case 0: + case "ORDER_BY_UNSPECIFIED": + return OrderBy.ORDER_BY_UNSPECIFIED; + case 1: + case "ORDER_BY_ASC": + return OrderBy.ORDER_BY_ASC; + case 2: + case "ORDER_BY_DESC": + return OrderBy.ORDER_BY_DESC; + case -1: + case "UNRECOGNIZED": + default: + return OrderBy.UNRECOGNIZED; + } +} + +export function orderByToJSON(object: OrderBy): string { + switch (object) { + case OrderBy.ORDER_BY_UNSPECIFIED: + return "ORDER_BY_UNSPECIFIED"; + case OrderBy.ORDER_BY_ASC: + return "ORDER_BY_ASC"; + case OrderBy.ORDER_BY_DESC: + return "ORDER_BY_DESC"; + default: + return "UNKNOWN"; + } +} + +/** BroadcastMode specifies the broadcast mode for the TxService.Broadcast RPC method. */ +export enum BroadcastMode { + /** BROADCAST_MODE_UNSPECIFIED - zero-value for mode ordering */ + BROADCAST_MODE_UNSPECIFIED = 0, + /** + * BROADCAST_MODE_BLOCK - BROADCAST_MODE_BLOCK defines a tx broadcasting mode where the client waits for + * the tx to be committed in a block. + */ + BROADCAST_MODE_BLOCK = 1, + /** + * BROADCAST_MODE_SYNC - BROADCAST_MODE_SYNC defines a tx broadcasting mode where the client waits for + * a CheckTx execution response only. + */ + BROADCAST_MODE_SYNC = 2, + /** + * BROADCAST_MODE_ASYNC - BROADCAST_MODE_ASYNC defines a tx broadcasting mode where the client returns + * immediately. + */ + BROADCAST_MODE_ASYNC = 3, + UNRECOGNIZED = -1, +} + +export function broadcastModeFromJSON(object: any): BroadcastMode { + switch (object) { + case 0: + case "BROADCAST_MODE_UNSPECIFIED": + return BroadcastMode.BROADCAST_MODE_UNSPECIFIED; + case 1: + case "BROADCAST_MODE_BLOCK": + return BroadcastMode.BROADCAST_MODE_BLOCK; + case 2: + case "BROADCAST_MODE_SYNC": + return BroadcastMode.BROADCAST_MODE_SYNC; + case 3: + case "BROADCAST_MODE_ASYNC": + return BroadcastMode.BROADCAST_MODE_ASYNC; + case -1: + case "UNRECOGNIZED": + default: + return BroadcastMode.UNRECOGNIZED; + } +} + +export function broadcastModeToJSON(object: BroadcastMode): string { + switch (object) { + case BroadcastMode.BROADCAST_MODE_UNSPECIFIED: + return "BROADCAST_MODE_UNSPECIFIED"; + case BroadcastMode.BROADCAST_MODE_BLOCK: + return "BROADCAST_MODE_BLOCK"; + case BroadcastMode.BROADCAST_MODE_SYNC: + return "BROADCAST_MODE_SYNC"; + case BroadcastMode.BROADCAST_MODE_ASYNC: + return "BROADCAST_MODE_ASYNC"; + default: + return "UNKNOWN"; + } +} + +/** + * GetTxsEventRequest is the request type for the Service.TxsByEvents + * RPC method. + */ +export interface GetTxsEventRequest { + /** events is the list of transaction event type. */ + events: string[]; + /** pagination defines a pagination for the request. */ + pagination: PageRequest | undefined; + orderBy: OrderBy; +} + +/** + * GetTxsEventResponse is the response type for the Service.TxsByEvents + * RPC method. + */ +export interface GetTxsEventResponse { + /** txs is the list of queried transactions. */ + txs: Tx[]; + /** tx_responses is the list of queried TxResponses. */ + txResponses: TxResponse[]; + /** pagination defines a pagination for the response. */ + pagination: PageResponse | undefined; +} + +/** + * BroadcastTxRequest is the request type for the Service.BroadcastTxRequest + * RPC method. + */ +export interface BroadcastTxRequest { + /** tx_bytes is the raw transaction. */ + txBytes: Uint8Array; + mode: BroadcastMode; +} + +/** + * BroadcastTxResponse is the response type for the + * Service.BroadcastTx method. + */ +export interface BroadcastTxResponse { + /** tx_response is the queried TxResponses. */ + txResponse: TxResponse | undefined; +} + +/** + * SimulateRequest is the request type for the Service.Simulate + * RPC method. + */ +export interface SimulateRequest { + /** + * tx is the transaction to simulate. + * Deprecated. Send raw tx bytes instead. + * + * @deprecated + */ + tx: Tx | undefined; + /** + * tx_bytes is the raw transaction. + * + * Since: cosmos-sdk 0.43 + */ + txBytes: Uint8Array; +} + +/** + * SimulateResponse is the response type for the + * Service.SimulateRPC method. + */ +export interface SimulateResponse { + /** gas_info is the information about gas used in the simulation. */ + gasInfo: GasInfo | undefined; + /** result is the result of the simulation. */ + result: Result | undefined; +} + +/** + * GetTxRequest is the request type for the Service.GetTx + * RPC method. + */ +export interface GetTxRequest { + /** hash is the tx hash to query, encoded as a hex string. */ + hash: string; +} + +/** GetTxResponse is the response type for the Service.GetTx method. */ +export interface GetTxResponse { + /** tx is the queried transaction. */ + tx: Tx | undefined; + /** tx_response is the queried TxResponses. */ + txResponse: TxResponse | undefined; +} + +/** + * GetBlockWithTxsRequest is the request type for the Service.GetBlockWithTxs + * RPC method. + * + * Since: cosmos-sdk 0.45.2 + */ +export interface GetBlockWithTxsRequest { + /** height is the height of the block to query. */ + height: number; + /** pagination defines a pagination for the request. */ + pagination: PageRequest | undefined; +} + +/** + * GetBlockWithTxsResponse is the response type for the Service.GetBlockWithTxs method. + * + * Since: cosmos-sdk 0.45.2 + */ +export interface GetBlockWithTxsResponse { + /** txs are the transactions in the block. */ + txs: Tx[]; + blockId: BlockID | undefined; + block: Block | undefined; + /** pagination defines a pagination for the response. */ + pagination: PageResponse | undefined; +} + +const baseGetTxsEventRequest: object = { events: "", orderBy: 0 }; + +export const GetTxsEventRequest = { + encode( + message: GetTxsEventRequest, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.events) { + writer.uint32(10).string(v!); + } + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + if (message.orderBy !== 0) { + writer.uint32(24).int32(message.orderBy); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): GetTxsEventRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseGetTxsEventRequest } as GetTxsEventRequest; + message.events = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.events.push(reader.string()); + break; + case 2: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + case 3: + message.orderBy = reader.int32() as any; + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GetTxsEventRequest { + const message = { ...baseGetTxsEventRequest } as GetTxsEventRequest; + message.events = []; + if (object.events !== undefined && object.events !== null) { + for (const e of object.events) { + message.events.push(String(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + if (object.orderBy !== undefined && object.orderBy !== null) { + message.orderBy = orderByFromJSON(object.orderBy); + } else { + message.orderBy = 0; + } + return message; + }, + + toJSON(message: GetTxsEventRequest): unknown { + const obj: any = {}; + if (message.events) { + obj.events = message.events.map((e) => e); + } else { + obj.events = []; + } + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageRequest.toJSON(message.pagination) + : undefined); + message.orderBy !== undefined && + (obj.orderBy = orderByToJSON(message.orderBy)); + return obj; + }, + + fromPartial(object: DeepPartial): GetTxsEventRequest { + const message = { ...baseGetTxsEventRequest } as GetTxsEventRequest; + message.events = []; + if (object.events !== undefined && object.events !== null) { + for (const e of object.events) { + message.events.push(e); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + if (object.orderBy !== undefined && object.orderBy !== null) { + message.orderBy = object.orderBy; + } else { + message.orderBy = 0; + } + return message; + }, +}; + +const baseGetTxsEventResponse: object = {}; + +export const GetTxsEventResponse = { + encode( + message: GetTxsEventResponse, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.txs) { + Tx.encode(v!, writer.uint32(10).fork()).ldelim(); + } + for (const v of message.txResponses) { + TxResponse.encode(v!, writer.uint32(18).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode( + message.pagination, + writer.uint32(26).fork() + ).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): GetTxsEventResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseGetTxsEventResponse } as GetTxsEventResponse; + message.txs = []; + message.txResponses = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.txs.push(Tx.decode(reader, reader.uint32())); + break; + case 2: + message.txResponses.push(TxResponse.decode(reader, reader.uint32())); + break; + case 3: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GetTxsEventResponse { + const message = { ...baseGetTxsEventResponse } as GetTxsEventResponse; + message.txs = []; + message.txResponses = []; + if (object.txs !== undefined && object.txs !== null) { + for (const e of object.txs) { + message.txs.push(Tx.fromJSON(e)); + } + } + if (object.txResponses !== undefined && object.txResponses !== null) { + for (const e of object.txResponses) { + message.txResponses.push(TxResponse.fromJSON(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: GetTxsEventResponse): unknown { + const obj: any = {}; + if (message.txs) { + obj.txs = message.txs.map((e) => (e ? Tx.toJSON(e) : undefined)); + } else { + obj.txs = []; + } + if (message.txResponses) { + obj.txResponses = message.txResponses.map((e) => + e ? TxResponse.toJSON(e) : undefined + ); + } else { + obj.txResponses = []; + } + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageResponse.toJSON(message.pagination) + : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): GetTxsEventResponse { + const message = { ...baseGetTxsEventResponse } as GetTxsEventResponse; + message.txs = []; + message.txResponses = []; + if (object.txs !== undefined && object.txs !== null) { + for (const e of object.txs) { + message.txs.push(Tx.fromPartial(e)); + } + } + if (object.txResponses !== undefined && object.txResponses !== null) { + for (const e of object.txResponses) { + message.txResponses.push(TxResponse.fromPartial(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseBroadcastTxRequest: object = { mode: 0 }; + +export const BroadcastTxRequest = { + encode( + message: BroadcastTxRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.txBytes.length !== 0) { + writer.uint32(10).bytes(message.txBytes); + } + if (message.mode !== 0) { + writer.uint32(16).int32(message.mode); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): BroadcastTxRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseBroadcastTxRequest } as BroadcastTxRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.txBytes = reader.bytes(); + break; + case 2: + message.mode = reader.int32() as any; + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): BroadcastTxRequest { + const message = { ...baseBroadcastTxRequest } as BroadcastTxRequest; + if (object.txBytes !== undefined && object.txBytes !== null) { + message.txBytes = bytesFromBase64(object.txBytes); + } + if (object.mode !== undefined && object.mode !== null) { + message.mode = broadcastModeFromJSON(object.mode); + } else { + message.mode = 0; + } + return message; + }, + + toJSON(message: BroadcastTxRequest): unknown { + const obj: any = {}; + message.txBytes !== undefined && + (obj.txBytes = base64FromBytes( + message.txBytes !== undefined ? message.txBytes : new Uint8Array() + )); + message.mode !== undefined && + (obj.mode = broadcastModeToJSON(message.mode)); + return obj; + }, + + fromPartial(object: DeepPartial): BroadcastTxRequest { + const message = { ...baseBroadcastTxRequest } as BroadcastTxRequest; + if (object.txBytes !== undefined && object.txBytes !== null) { + message.txBytes = object.txBytes; + } else { + message.txBytes = new Uint8Array(); + } + if (object.mode !== undefined && object.mode !== null) { + message.mode = object.mode; + } else { + message.mode = 0; + } + return message; + }, +}; + +const baseBroadcastTxResponse: object = {}; + +export const BroadcastTxResponse = { + encode( + message: BroadcastTxResponse, + writer: Writer = Writer.create() + ): Writer { + if (message.txResponse !== undefined) { + TxResponse.encode(message.txResponse, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): BroadcastTxResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseBroadcastTxResponse } as BroadcastTxResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.txResponse = TxResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): BroadcastTxResponse { + const message = { ...baseBroadcastTxResponse } as BroadcastTxResponse; + if (object.txResponse !== undefined && object.txResponse !== null) { + message.txResponse = TxResponse.fromJSON(object.txResponse); + } else { + message.txResponse = undefined; + } + return message; + }, + + toJSON(message: BroadcastTxResponse): unknown { + const obj: any = {}; + message.txResponse !== undefined && + (obj.txResponse = message.txResponse + ? TxResponse.toJSON(message.txResponse) + : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): BroadcastTxResponse { + const message = { ...baseBroadcastTxResponse } as BroadcastTxResponse; + if (object.txResponse !== undefined && object.txResponse !== null) { + message.txResponse = TxResponse.fromPartial(object.txResponse); + } else { + message.txResponse = undefined; + } + return message; + }, +}; + +const baseSimulateRequest: object = {}; + +export const SimulateRequest = { + encode(message: SimulateRequest, writer: Writer = Writer.create()): Writer { + if (message.tx !== undefined) { + Tx.encode(message.tx, writer.uint32(10).fork()).ldelim(); + } + if (message.txBytes.length !== 0) { + writer.uint32(18).bytes(message.txBytes); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): SimulateRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseSimulateRequest } as SimulateRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.tx = Tx.decode(reader, reader.uint32()); + break; + case 2: + message.txBytes = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): SimulateRequest { + const message = { ...baseSimulateRequest } as SimulateRequest; + if (object.tx !== undefined && object.tx !== null) { + message.tx = Tx.fromJSON(object.tx); + } else { + message.tx = undefined; + } + if (object.txBytes !== undefined && object.txBytes !== null) { + message.txBytes = bytesFromBase64(object.txBytes); + } + return message; + }, + + toJSON(message: SimulateRequest): unknown { + const obj: any = {}; + message.tx !== undefined && + (obj.tx = message.tx ? Tx.toJSON(message.tx) : undefined); + message.txBytes !== undefined && + (obj.txBytes = base64FromBytes( + message.txBytes !== undefined ? message.txBytes : new Uint8Array() + )); + return obj; + }, + + fromPartial(object: DeepPartial): SimulateRequest { + const message = { ...baseSimulateRequest } as SimulateRequest; + if (object.tx !== undefined && object.tx !== null) { + message.tx = Tx.fromPartial(object.tx); + } else { + message.tx = undefined; + } + if (object.txBytes !== undefined && object.txBytes !== null) { + message.txBytes = object.txBytes; + } else { + message.txBytes = new Uint8Array(); + } + return message; + }, +}; + +const baseSimulateResponse: object = {}; + +export const SimulateResponse = { + encode(message: SimulateResponse, writer: Writer = Writer.create()): Writer { + if (message.gasInfo !== undefined) { + GasInfo.encode(message.gasInfo, writer.uint32(10).fork()).ldelim(); + } + if (message.result !== undefined) { + Result.encode(message.result, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): SimulateResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseSimulateResponse } as SimulateResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.gasInfo = GasInfo.decode(reader, reader.uint32()); + break; + case 2: + message.result = Result.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): SimulateResponse { + const message = { ...baseSimulateResponse } as SimulateResponse; + if (object.gasInfo !== undefined && object.gasInfo !== null) { + message.gasInfo = GasInfo.fromJSON(object.gasInfo); + } else { + message.gasInfo = undefined; + } + if (object.result !== undefined && object.result !== null) { + message.result = Result.fromJSON(object.result); + } else { + message.result = undefined; + } + return message; + }, + + toJSON(message: SimulateResponse): unknown { + const obj: any = {}; + message.gasInfo !== undefined && + (obj.gasInfo = message.gasInfo + ? GasInfo.toJSON(message.gasInfo) + : undefined); + message.result !== undefined && + (obj.result = message.result ? Result.toJSON(message.result) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): SimulateResponse { + const message = { ...baseSimulateResponse } as SimulateResponse; + if (object.gasInfo !== undefined && object.gasInfo !== null) { + message.gasInfo = GasInfo.fromPartial(object.gasInfo); + } else { + message.gasInfo = undefined; + } + if (object.result !== undefined && object.result !== null) { + message.result = Result.fromPartial(object.result); + } else { + message.result = undefined; + } + return message; + }, +}; + +const baseGetTxRequest: object = { hash: "" }; + +export const GetTxRequest = { + encode(message: GetTxRequest, writer: Writer = Writer.create()): Writer { + if (message.hash !== "") { + writer.uint32(10).string(message.hash); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): GetTxRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseGetTxRequest } as GetTxRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.hash = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GetTxRequest { + const message = { ...baseGetTxRequest } as GetTxRequest; + if (object.hash !== undefined && object.hash !== null) { + message.hash = String(object.hash); + } else { + message.hash = ""; + } + return message; + }, + + toJSON(message: GetTxRequest): unknown { + const obj: any = {}; + message.hash !== undefined && (obj.hash = message.hash); + return obj; + }, + + fromPartial(object: DeepPartial): GetTxRequest { + const message = { ...baseGetTxRequest } as GetTxRequest; + if (object.hash !== undefined && object.hash !== null) { + message.hash = object.hash; + } else { + message.hash = ""; + } + return message; + }, +}; + +const baseGetTxResponse: object = {}; + +export const GetTxResponse = { + encode(message: GetTxResponse, writer: Writer = Writer.create()): Writer { + if (message.tx !== undefined) { + Tx.encode(message.tx, writer.uint32(10).fork()).ldelim(); + } + if (message.txResponse !== undefined) { + TxResponse.encode(message.txResponse, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): GetTxResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseGetTxResponse } as GetTxResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.tx = Tx.decode(reader, reader.uint32()); + break; + case 2: + message.txResponse = TxResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GetTxResponse { + const message = { ...baseGetTxResponse } as GetTxResponse; + if (object.tx !== undefined && object.tx !== null) { + message.tx = Tx.fromJSON(object.tx); + } else { + message.tx = undefined; + } + if (object.txResponse !== undefined && object.txResponse !== null) { + message.txResponse = TxResponse.fromJSON(object.txResponse); + } else { + message.txResponse = undefined; + } + return message; + }, + + toJSON(message: GetTxResponse): unknown { + const obj: any = {}; + message.tx !== undefined && + (obj.tx = message.tx ? Tx.toJSON(message.tx) : undefined); + message.txResponse !== undefined && + (obj.txResponse = message.txResponse + ? TxResponse.toJSON(message.txResponse) + : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): GetTxResponse { + const message = { ...baseGetTxResponse } as GetTxResponse; + if (object.tx !== undefined && object.tx !== null) { + message.tx = Tx.fromPartial(object.tx); + } else { + message.tx = undefined; + } + if (object.txResponse !== undefined && object.txResponse !== null) { + message.txResponse = TxResponse.fromPartial(object.txResponse); + } else { + message.txResponse = undefined; + } + return message; + }, +}; + +const baseGetBlockWithTxsRequest: object = { height: 0 }; + +export const GetBlockWithTxsRequest = { + encode( + message: GetBlockWithTxsRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.height !== 0) { + writer.uint32(8).int64(message.height); + } + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): GetBlockWithTxsRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseGetBlockWithTxsRequest } as GetBlockWithTxsRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.height = longToNumber(reader.int64() as Long); + break; + case 2: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GetBlockWithTxsRequest { + const message = { ...baseGetBlockWithTxsRequest } as GetBlockWithTxsRequest; + if (object.height !== undefined && object.height !== null) { + message.height = Number(object.height); + } else { + message.height = 0; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: GetBlockWithTxsRequest): unknown { + const obj: any = {}; + message.height !== undefined && (obj.height = message.height); + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageRequest.toJSON(message.pagination) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): GetBlockWithTxsRequest { + const message = { ...baseGetBlockWithTxsRequest } as GetBlockWithTxsRequest; + if (object.height !== undefined && object.height !== null) { + message.height = object.height; + } else { + message.height = 0; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseGetBlockWithTxsResponse: object = {}; + +export const GetBlockWithTxsResponse = { + encode( + message: GetBlockWithTxsResponse, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.txs) { + Tx.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.blockId !== undefined) { + BlockID.encode(message.blockId, writer.uint32(18).fork()).ldelim(); + } + if (message.block !== undefined) { + Block.encode(message.block, writer.uint32(26).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode( + message.pagination, + writer.uint32(34).fork() + ).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): GetBlockWithTxsResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseGetBlockWithTxsResponse, + } as GetBlockWithTxsResponse; + message.txs = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.txs.push(Tx.decode(reader, reader.uint32())); + break; + case 2: + message.blockId = BlockID.decode(reader, reader.uint32()); + break; + case 3: + message.block = Block.decode(reader, reader.uint32()); + break; + case 4: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GetBlockWithTxsResponse { + const message = { + ...baseGetBlockWithTxsResponse, + } as GetBlockWithTxsResponse; + message.txs = []; + if (object.txs !== undefined && object.txs !== null) { + for (const e of object.txs) { + message.txs.push(Tx.fromJSON(e)); + } + } + if (object.blockId !== undefined && object.blockId !== null) { + message.blockId = BlockID.fromJSON(object.blockId); + } else { + message.blockId = undefined; + } + if (object.block !== undefined && object.block !== null) { + message.block = Block.fromJSON(object.block); + } else { + message.block = undefined; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: GetBlockWithTxsResponse): unknown { + const obj: any = {}; + if (message.txs) { + obj.txs = message.txs.map((e) => (e ? Tx.toJSON(e) : undefined)); + } else { + obj.txs = []; + } + message.blockId !== undefined && + (obj.blockId = message.blockId + ? BlockID.toJSON(message.blockId) + : undefined); + message.block !== undefined && + (obj.block = message.block ? Block.toJSON(message.block) : undefined); + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageResponse.toJSON(message.pagination) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): GetBlockWithTxsResponse { + const message = { + ...baseGetBlockWithTxsResponse, + } as GetBlockWithTxsResponse; + message.txs = []; + if (object.txs !== undefined && object.txs !== null) { + for (const e of object.txs) { + message.txs.push(Tx.fromPartial(e)); + } + } + if (object.blockId !== undefined && object.blockId !== null) { + message.blockId = BlockID.fromPartial(object.blockId); + } else { + message.blockId = undefined; + } + if (object.block !== undefined && object.block !== null) { + message.block = Block.fromPartial(object.block); + } else { + message.block = undefined; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +/** Service defines a gRPC service for interacting with transactions. */ +export interface Service { + /** Simulate simulates executing a transaction for estimating gas usage. */ + Simulate(request: SimulateRequest): Promise; + /** GetTx fetches a tx by hash. */ + GetTx(request: GetTxRequest): Promise; + /** BroadcastTx broadcast transaction. */ + BroadcastTx(request: BroadcastTxRequest): Promise; + /** GetTxsEvent fetches txs by event. */ + GetTxsEvent(request: GetTxsEventRequest): Promise; + /** + * GetBlockWithTxs fetches a block with decoded txs. + * + * Since: cosmos-sdk 0.45.2 + */ + GetBlockWithTxs( + request: GetBlockWithTxsRequest + ): Promise; +} + +export class ServiceClientImpl implements Service { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + } + Simulate(request: SimulateRequest): Promise { + const data = SimulateRequest.encode(request).finish(); + const promise = this.rpc.request( + "cosmos.tx.v1beta1.Service", + "Simulate", + data + ); + return promise.then((data) => SimulateResponse.decode(new Reader(data))); + } + + GetTx(request: GetTxRequest): Promise { + const data = GetTxRequest.encode(request).finish(); + const promise = this.rpc.request( + "cosmos.tx.v1beta1.Service", + "GetTx", + data + ); + return promise.then((data) => GetTxResponse.decode(new Reader(data))); + } + + BroadcastTx(request: BroadcastTxRequest): Promise { + const data = BroadcastTxRequest.encode(request).finish(); + const promise = this.rpc.request( + "cosmos.tx.v1beta1.Service", + "BroadcastTx", + data + ); + return promise.then((data) => BroadcastTxResponse.decode(new Reader(data))); + } + + GetTxsEvent(request: GetTxsEventRequest): Promise { + const data = GetTxsEventRequest.encode(request).finish(); + const promise = this.rpc.request( + "cosmos.tx.v1beta1.Service", + "GetTxsEvent", + data + ); + return promise.then((data) => GetTxsEventResponse.decode(new Reader(data))); + } + + GetBlockWithTxs( + request: GetBlockWithTxsRequest + ): Promise { + const data = GetBlockWithTxsRequest.encode(request).finish(); + const promise = this.rpc.request( + "cosmos.tx.v1beta1.Service", + "GetBlockWithTxs", + data + ); + return promise.then((data) => + GetBlockWithTxsResponse.decode(new Reader(data)) + ); + } +} + +interface Rpc { + request( + service: string, + method: string, + data: Uint8Array + ): Promise; +} + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/cosmos.tx.v1beta1/types/cosmos/tx/v1beta1/tx.ts b/ts-client/cosmos.tx.v1beta1/types/cosmos/tx/v1beta1/tx.ts new file mode 100644 index 00000000..f833e5fd --- /dev/null +++ b/ts-client/cosmos.tx.v1beta1/types/cosmos/tx/v1beta1/tx.ts @@ -0,0 +1,1262 @@ +/* eslint-disable */ +import { + SignMode, + signModeFromJSON, + signModeToJSON, +} from "../../../cosmos/tx/signing/v1beta1/signing"; +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; +import { Any } from "../../../google/protobuf/any"; +import { CompactBitArray } from "../../../cosmos/crypto/multisig/v1beta1/multisig"; +import { Coin } from "../../../cosmos/base/v1beta1/coin"; + +export const protobufPackage = "cosmos.tx.v1beta1"; + +/** Tx is the standard type used for broadcasting transactions. */ +export interface Tx { + /** body is the processable content of the transaction */ + body: TxBody | undefined; + /** + * auth_info is the authorization related content of the transaction, + * specifically signers, signer modes and fee + */ + authInfo: AuthInfo | undefined; + /** + * signatures is a list of signatures that matches the length and order of + * AuthInfo's signer_infos to allow connecting signature meta information like + * public key and signing mode by position. + */ + signatures: Uint8Array[]; +} + +/** + * TxRaw is a variant of Tx that pins the signer's exact binary representation + * of body and auth_info. This is used for signing, broadcasting and + * verification. The binary `serialize(tx: TxRaw)` is stored in Tendermint and + * the hash `sha256(serialize(tx: TxRaw))` becomes the "txhash", commonly used + * as the transaction ID. + */ +export interface TxRaw { + /** + * body_bytes is a protobuf serialization of a TxBody that matches the + * representation in SignDoc. + */ + bodyBytes: Uint8Array; + /** + * auth_info_bytes is a protobuf serialization of an AuthInfo that matches the + * representation in SignDoc. + */ + authInfoBytes: Uint8Array; + /** + * signatures is a list of signatures that matches the length and order of + * AuthInfo's signer_infos to allow connecting signature meta information like + * public key and signing mode by position. + */ + signatures: Uint8Array[]; +} + +/** SignDoc is the type used for generating sign bytes for SIGN_MODE_DIRECT. */ +export interface SignDoc { + /** + * body_bytes is protobuf serialization of a TxBody that matches the + * representation in TxRaw. + */ + bodyBytes: Uint8Array; + /** + * auth_info_bytes is a protobuf serialization of an AuthInfo that matches the + * representation in TxRaw. + */ + authInfoBytes: Uint8Array; + /** + * chain_id is the unique identifier of the chain this transaction targets. + * It prevents signed transactions from being used on another chain by an + * attacker + */ + chainId: string; + /** account_number is the account number of the account in state */ + accountNumber: number; +} + +/** TxBody is the body of a transaction that all signers sign over. */ +export interface TxBody { + /** + * messages is a list of messages to be executed. The required signers of + * those messages define the number and order of elements in AuthInfo's + * signer_infos and Tx's signatures. Each required signer address is added to + * the list only the first time it occurs. + * By convention, the first required signer (usually from the first message) + * is referred to as the primary signer and pays the fee for the whole + * transaction. + */ + messages: Any[]; + /** + * memo is any arbitrary note/comment to be added to the transaction. + * WARNING: in clients, any publicly exposed text should not be called memo, + * but should be called `note` instead (see https://github.com/cosmos/cosmos-sdk/issues/9122). + */ + memo: string; + /** + * timeout is the block height after which this transaction will not + * be processed by the chain + */ + timeoutHeight: number; + /** + * extension_options are arbitrary options that can be added by chains + * when the default options are not sufficient. If any of these are present + * and can't be handled, the transaction will be rejected + */ + extensionOptions: Any[]; + /** + * extension_options are arbitrary options that can be added by chains + * when the default options are not sufficient. If any of these are present + * and can't be handled, they will be ignored + */ + nonCriticalExtensionOptions: Any[]; +} + +/** + * AuthInfo describes the fee and signer modes that are used to sign a + * transaction. + */ +export interface AuthInfo { + /** + * signer_infos defines the signing modes for the required signers. The number + * and order of elements must match the required signers from TxBody's + * messages. The first element is the primary signer and the one which pays + * the fee. + */ + signerInfos: SignerInfo[]; + /** + * Fee is the fee and gas limit for the transaction. The first signer is the + * primary signer and the one which pays the fee. The fee can be calculated + * based on the cost of evaluating the body and doing signature verification + * of the signers. This can be estimated via simulation. + */ + fee: Fee | undefined; +} + +/** + * SignerInfo describes the public key and signing mode of a single top-level + * signer. + */ +export interface SignerInfo { + /** + * public_key is the public key of the signer. It is optional for accounts + * that already exist in state. If unset, the verifier can use the required \ + * signer address for this position and lookup the public key. + */ + publicKey: Any | undefined; + /** + * mode_info describes the signing mode of the signer and is a nested + * structure to support nested multisig pubkey's + */ + modeInfo: ModeInfo | undefined; + /** + * sequence is the sequence of the account, which describes the + * number of committed transactions signed by a given address. It is used to + * prevent replay attacks. + */ + sequence: number; +} + +/** ModeInfo describes the signing mode of a single or nested multisig signer. */ +export interface ModeInfo { + /** single represents a single signer */ + single: ModeInfo_Single | undefined; + /** multi represents a nested multisig signer */ + multi: ModeInfo_Multi | undefined; +} + +/** + * Single is the mode info for a single signer. It is structured as a message + * to allow for additional fields such as locale for SIGN_MODE_TEXTUAL in the + * future + */ +export interface ModeInfo_Single { + /** mode is the signing mode of the single signer */ + mode: SignMode; +} + +/** Multi is the mode info for a multisig public key */ +export interface ModeInfo_Multi { + /** bitarray specifies which keys within the multisig are signing */ + bitarray: CompactBitArray | undefined; + /** + * mode_infos is the corresponding modes of the signers of the multisig + * which could include nested multisig public keys + */ + modeInfos: ModeInfo[]; +} + +/** + * Fee includes the amount of coins paid in fees and the maximum + * gas to be used by the transaction. The ratio yields an effective "gasprice", + * which must be above some miminum to be accepted into the mempool. + */ +export interface Fee { + /** amount is the amount of coins to be paid as a fee */ + amount: Coin[]; + /** + * gas_limit is the maximum gas that can be used in transaction processing + * before an out of gas error occurs + */ + gasLimit: number; + /** + * if unset, the first signer is responsible for paying the fees. If set, the specified account must pay the fees. + * the payer must be a tx signer (and thus have signed this field in AuthInfo). + * setting this field does *not* change the ordering of required signers for the transaction. + */ + payer: string; + /** + * if set, the fee payer (either the first signer or the value of the payer field) requests that a fee grant be used + * to pay fees instead of the fee payer's own balance. If an appropriate fee grant does not exist or the chain does + * not support fee grants, this will fail + */ + granter: string; +} + +const baseTx: object = {}; + +export const Tx = { + encode(message: Tx, writer: Writer = Writer.create()): Writer { + if (message.body !== undefined) { + TxBody.encode(message.body, writer.uint32(10).fork()).ldelim(); + } + if (message.authInfo !== undefined) { + AuthInfo.encode(message.authInfo, writer.uint32(18).fork()).ldelim(); + } + for (const v of message.signatures) { + writer.uint32(26).bytes(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Tx { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseTx } as Tx; + message.signatures = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.body = TxBody.decode(reader, reader.uint32()); + break; + case 2: + message.authInfo = AuthInfo.decode(reader, reader.uint32()); + break; + case 3: + message.signatures.push(reader.bytes()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Tx { + const message = { ...baseTx } as Tx; + message.signatures = []; + if (object.body !== undefined && object.body !== null) { + message.body = TxBody.fromJSON(object.body); + } else { + message.body = undefined; + } + if (object.authInfo !== undefined && object.authInfo !== null) { + message.authInfo = AuthInfo.fromJSON(object.authInfo); + } else { + message.authInfo = undefined; + } + if (object.signatures !== undefined && object.signatures !== null) { + for (const e of object.signatures) { + message.signatures.push(bytesFromBase64(e)); + } + } + return message; + }, + + toJSON(message: Tx): unknown { + const obj: any = {}; + message.body !== undefined && + (obj.body = message.body ? TxBody.toJSON(message.body) : undefined); + message.authInfo !== undefined && + (obj.authInfo = message.authInfo + ? AuthInfo.toJSON(message.authInfo) + : undefined); + if (message.signatures) { + obj.signatures = message.signatures.map((e) => + base64FromBytes(e !== undefined ? e : new Uint8Array()) + ); + } else { + obj.signatures = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): Tx { + const message = { ...baseTx } as Tx; + message.signatures = []; + if (object.body !== undefined && object.body !== null) { + message.body = TxBody.fromPartial(object.body); + } else { + message.body = undefined; + } + if (object.authInfo !== undefined && object.authInfo !== null) { + message.authInfo = AuthInfo.fromPartial(object.authInfo); + } else { + message.authInfo = undefined; + } + if (object.signatures !== undefined && object.signatures !== null) { + for (const e of object.signatures) { + message.signatures.push(e); + } + } + return message; + }, +}; + +const baseTxRaw: object = {}; + +export const TxRaw = { + encode(message: TxRaw, writer: Writer = Writer.create()): Writer { + if (message.bodyBytes.length !== 0) { + writer.uint32(10).bytes(message.bodyBytes); + } + if (message.authInfoBytes.length !== 0) { + writer.uint32(18).bytes(message.authInfoBytes); + } + for (const v of message.signatures) { + writer.uint32(26).bytes(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): TxRaw { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseTxRaw } as TxRaw; + message.signatures = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.bodyBytes = reader.bytes(); + break; + case 2: + message.authInfoBytes = reader.bytes(); + break; + case 3: + message.signatures.push(reader.bytes()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): TxRaw { + const message = { ...baseTxRaw } as TxRaw; + message.signatures = []; + if (object.bodyBytes !== undefined && object.bodyBytes !== null) { + message.bodyBytes = bytesFromBase64(object.bodyBytes); + } + if (object.authInfoBytes !== undefined && object.authInfoBytes !== null) { + message.authInfoBytes = bytesFromBase64(object.authInfoBytes); + } + if (object.signatures !== undefined && object.signatures !== null) { + for (const e of object.signatures) { + message.signatures.push(bytesFromBase64(e)); + } + } + return message; + }, + + toJSON(message: TxRaw): unknown { + const obj: any = {}; + message.bodyBytes !== undefined && + (obj.bodyBytes = base64FromBytes( + message.bodyBytes !== undefined ? message.bodyBytes : new Uint8Array() + )); + message.authInfoBytes !== undefined && + (obj.authInfoBytes = base64FromBytes( + message.authInfoBytes !== undefined + ? message.authInfoBytes + : new Uint8Array() + )); + if (message.signatures) { + obj.signatures = message.signatures.map((e) => + base64FromBytes(e !== undefined ? e : new Uint8Array()) + ); + } else { + obj.signatures = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): TxRaw { + const message = { ...baseTxRaw } as TxRaw; + message.signatures = []; + if (object.bodyBytes !== undefined && object.bodyBytes !== null) { + message.bodyBytes = object.bodyBytes; + } else { + message.bodyBytes = new Uint8Array(); + } + if (object.authInfoBytes !== undefined && object.authInfoBytes !== null) { + message.authInfoBytes = object.authInfoBytes; + } else { + message.authInfoBytes = new Uint8Array(); + } + if (object.signatures !== undefined && object.signatures !== null) { + for (const e of object.signatures) { + message.signatures.push(e); + } + } + return message; + }, +}; + +const baseSignDoc: object = { chainId: "", accountNumber: 0 }; + +export const SignDoc = { + encode(message: SignDoc, writer: Writer = Writer.create()): Writer { + if (message.bodyBytes.length !== 0) { + writer.uint32(10).bytes(message.bodyBytes); + } + if (message.authInfoBytes.length !== 0) { + writer.uint32(18).bytes(message.authInfoBytes); + } + if (message.chainId !== "") { + writer.uint32(26).string(message.chainId); + } + if (message.accountNumber !== 0) { + writer.uint32(32).uint64(message.accountNumber); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): SignDoc { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseSignDoc } as SignDoc; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.bodyBytes = reader.bytes(); + break; + case 2: + message.authInfoBytes = reader.bytes(); + break; + case 3: + message.chainId = reader.string(); + break; + case 4: + message.accountNumber = longToNumber(reader.uint64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): SignDoc { + const message = { ...baseSignDoc } as SignDoc; + if (object.bodyBytes !== undefined && object.bodyBytes !== null) { + message.bodyBytes = bytesFromBase64(object.bodyBytes); + } + if (object.authInfoBytes !== undefined && object.authInfoBytes !== null) { + message.authInfoBytes = bytesFromBase64(object.authInfoBytes); + } + if (object.chainId !== undefined && object.chainId !== null) { + message.chainId = String(object.chainId); + } else { + message.chainId = ""; + } + if (object.accountNumber !== undefined && object.accountNumber !== null) { + message.accountNumber = Number(object.accountNumber); + } else { + message.accountNumber = 0; + } + return message; + }, + + toJSON(message: SignDoc): unknown { + const obj: any = {}; + message.bodyBytes !== undefined && + (obj.bodyBytes = base64FromBytes( + message.bodyBytes !== undefined ? message.bodyBytes : new Uint8Array() + )); + message.authInfoBytes !== undefined && + (obj.authInfoBytes = base64FromBytes( + message.authInfoBytes !== undefined + ? message.authInfoBytes + : new Uint8Array() + )); + message.chainId !== undefined && (obj.chainId = message.chainId); + message.accountNumber !== undefined && + (obj.accountNumber = message.accountNumber); + return obj; + }, + + fromPartial(object: DeepPartial): SignDoc { + const message = { ...baseSignDoc } as SignDoc; + if (object.bodyBytes !== undefined && object.bodyBytes !== null) { + message.bodyBytes = object.bodyBytes; + } else { + message.bodyBytes = new Uint8Array(); + } + if (object.authInfoBytes !== undefined && object.authInfoBytes !== null) { + message.authInfoBytes = object.authInfoBytes; + } else { + message.authInfoBytes = new Uint8Array(); + } + if (object.chainId !== undefined && object.chainId !== null) { + message.chainId = object.chainId; + } else { + message.chainId = ""; + } + if (object.accountNumber !== undefined && object.accountNumber !== null) { + message.accountNumber = object.accountNumber; + } else { + message.accountNumber = 0; + } + return message; + }, +}; + +const baseTxBody: object = { memo: "", timeoutHeight: 0 }; + +export const TxBody = { + encode(message: TxBody, writer: Writer = Writer.create()): Writer { + for (const v of message.messages) { + Any.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.memo !== "") { + writer.uint32(18).string(message.memo); + } + if (message.timeoutHeight !== 0) { + writer.uint32(24).uint64(message.timeoutHeight); + } + for (const v of message.extensionOptions) { + Any.encode(v!, writer.uint32(8186).fork()).ldelim(); + } + for (const v of message.nonCriticalExtensionOptions) { + Any.encode(v!, writer.uint32(16378).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): TxBody { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseTxBody } as TxBody; + message.messages = []; + message.extensionOptions = []; + message.nonCriticalExtensionOptions = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.messages.push(Any.decode(reader, reader.uint32())); + break; + case 2: + message.memo = reader.string(); + break; + case 3: + message.timeoutHeight = longToNumber(reader.uint64() as Long); + break; + case 1023: + message.extensionOptions.push(Any.decode(reader, reader.uint32())); + break; + case 2047: + message.nonCriticalExtensionOptions.push( + Any.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): TxBody { + const message = { ...baseTxBody } as TxBody; + message.messages = []; + message.extensionOptions = []; + message.nonCriticalExtensionOptions = []; + if (object.messages !== undefined && object.messages !== null) { + for (const e of object.messages) { + message.messages.push(Any.fromJSON(e)); + } + } + if (object.memo !== undefined && object.memo !== null) { + message.memo = String(object.memo); + } else { + message.memo = ""; + } + if (object.timeoutHeight !== undefined && object.timeoutHeight !== null) { + message.timeoutHeight = Number(object.timeoutHeight); + } else { + message.timeoutHeight = 0; + } + if ( + object.extensionOptions !== undefined && + object.extensionOptions !== null + ) { + for (const e of object.extensionOptions) { + message.extensionOptions.push(Any.fromJSON(e)); + } + } + if ( + object.nonCriticalExtensionOptions !== undefined && + object.nonCriticalExtensionOptions !== null + ) { + for (const e of object.nonCriticalExtensionOptions) { + message.nonCriticalExtensionOptions.push(Any.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: TxBody): unknown { + const obj: any = {}; + if (message.messages) { + obj.messages = message.messages.map((e) => + e ? Any.toJSON(e) : undefined + ); + } else { + obj.messages = []; + } + message.memo !== undefined && (obj.memo = message.memo); + message.timeoutHeight !== undefined && + (obj.timeoutHeight = message.timeoutHeight); + if (message.extensionOptions) { + obj.extensionOptions = message.extensionOptions.map((e) => + e ? Any.toJSON(e) : undefined + ); + } else { + obj.extensionOptions = []; + } + if (message.nonCriticalExtensionOptions) { + obj.nonCriticalExtensionOptions = message.nonCriticalExtensionOptions.map( + (e) => (e ? Any.toJSON(e) : undefined) + ); + } else { + obj.nonCriticalExtensionOptions = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): TxBody { + const message = { ...baseTxBody } as TxBody; + message.messages = []; + message.extensionOptions = []; + message.nonCriticalExtensionOptions = []; + if (object.messages !== undefined && object.messages !== null) { + for (const e of object.messages) { + message.messages.push(Any.fromPartial(e)); + } + } + if (object.memo !== undefined && object.memo !== null) { + message.memo = object.memo; + } else { + message.memo = ""; + } + if (object.timeoutHeight !== undefined && object.timeoutHeight !== null) { + message.timeoutHeight = object.timeoutHeight; + } else { + message.timeoutHeight = 0; + } + if ( + object.extensionOptions !== undefined && + object.extensionOptions !== null + ) { + for (const e of object.extensionOptions) { + message.extensionOptions.push(Any.fromPartial(e)); + } + } + if ( + object.nonCriticalExtensionOptions !== undefined && + object.nonCriticalExtensionOptions !== null + ) { + for (const e of object.nonCriticalExtensionOptions) { + message.nonCriticalExtensionOptions.push(Any.fromPartial(e)); + } + } + return message; + }, +}; + +const baseAuthInfo: object = {}; + +export const AuthInfo = { + encode(message: AuthInfo, writer: Writer = Writer.create()): Writer { + for (const v of message.signerInfos) { + SignerInfo.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.fee !== undefined) { + Fee.encode(message.fee, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): AuthInfo { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseAuthInfo } as AuthInfo; + message.signerInfos = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.signerInfos.push(SignerInfo.decode(reader, reader.uint32())); + break; + case 2: + message.fee = Fee.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): AuthInfo { + const message = { ...baseAuthInfo } as AuthInfo; + message.signerInfos = []; + if (object.signerInfos !== undefined && object.signerInfos !== null) { + for (const e of object.signerInfos) { + message.signerInfos.push(SignerInfo.fromJSON(e)); + } + } + if (object.fee !== undefined && object.fee !== null) { + message.fee = Fee.fromJSON(object.fee); + } else { + message.fee = undefined; + } + return message; + }, + + toJSON(message: AuthInfo): unknown { + const obj: any = {}; + if (message.signerInfos) { + obj.signerInfos = message.signerInfos.map((e) => + e ? SignerInfo.toJSON(e) : undefined + ); + } else { + obj.signerInfos = []; + } + message.fee !== undefined && + (obj.fee = message.fee ? Fee.toJSON(message.fee) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): AuthInfo { + const message = { ...baseAuthInfo } as AuthInfo; + message.signerInfos = []; + if (object.signerInfos !== undefined && object.signerInfos !== null) { + for (const e of object.signerInfos) { + message.signerInfos.push(SignerInfo.fromPartial(e)); + } + } + if (object.fee !== undefined && object.fee !== null) { + message.fee = Fee.fromPartial(object.fee); + } else { + message.fee = undefined; + } + return message; + }, +}; + +const baseSignerInfo: object = { sequence: 0 }; + +export const SignerInfo = { + encode(message: SignerInfo, writer: Writer = Writer.create()): Writer { + if (message.publicKey !== undefined) { + Any.encode(message.publicKey, writer.uint32(10).fork()).ldelim(); + } + if (message.modeInfo !== undefined) { + ModeInfo.encode(message.modeInfo, writer.uint32(18).fork()).ldelim(); + } + if (message.sequence !== 0) { + writer.uint32(24).uint64(message.sequence); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): SignerInfo { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseSignerInfo } as SignerInfo; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.publicKey = Any.decode(reader, reader.uint32()); + break; + case 2: + message.modeInfo = ModeInfo.decode(reader, reader.uint32()); + break; + case 3: + message.sequence = longToNumber(reader.uint64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): SignerInfo { + const message = { ...baseSignerInfo } as SignerInfo; + if (object.publicKey !== undefined && object.publicKey !== null) { + message.publicKey = Any.fromJSON(object.publicKey); + } else { + message.publicKey = undefined; + } + if (object.modeInfo !== undefined && object.modeInfo !== null) { + message.modeInfo = ModeInfo.fromJSON(object.modeInfo); + } else { + message.modeInfo = undefined; + } + if (object.sequence !== undefined && object.sequence !== null) { + message.sequence = Number(object.sequence); + } else { + message.sequence = 0; + } + return message; + }, + + toJSON(message: SignerInfo): unknown { + const obj: any = {}; + message.publicKey !== undefined && + (obj.publicKey = message.publicKey + ? Any.toJSON(message.publicKey) + : undefined); + message.modeInfo !== undefined && + (obj.modeInfo = message.modeInfo + ? ModeInfo.toJSON(message.modeInfo) + : undefined); + message.sequence !== undefined && (obj.sequence = message.sequence); + return obj; + }, + + fromPartial(object: DeepPartial): SignerInfo { + const message = { ...baseSignerInfo } as SignerInfo; + if (object.publicKey !== undefined && object.publicKey !== null) { + message.publicKey = Any.fromPartial(object.publicKey); + } else { + message.publicKey = undefined; + } + if (object.modeInfo !== undefined && object.modeInfo !== null) { + message.modeInfo = ModeInfo.fromPartial(object.modeInfo); + } else { + message.modeInfo = undefined; + } + if (object.sequence !== undefined && object.sequence !== null) { + message.sequence = object.sequence; + } else { + message.sequence = 0; + } + return message; + }, +}; + +const baseModeInfo: object = {}; + +export const ModeInfo = { + encode(message: ModeInfo, writer: Writer = Writer.create()): Writer { + if (message.single !== undefined) { + ModeInfo_Single.encode(message.single, writer.uint32(10).fork()).ldelim(); + } + if (message.multi !== undefined) { + ModeInfo_Multi.encode(message.multi, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ModeInfo { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseModeInfo } as ModeInfo; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.single = ModeInfo_Single.decode(reader, reader.uint32()); + break; + case 2: + message.multi = ModeInfo_Multi.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ModeInfo { + const message = { ...baseModeInfo } as ModeInfo; + if (object.single !== undefined && object.single !== null) { + message.single = ModeInfo_Single.fromJSON(object.single); + } else { + message.single = undefined; + } + if (object.multi !== undefined && object.multi !== null) { + message.multi = ModeInfo_Multi.fromJSON(object.multi); + } else { + message.multi = undefined; + } + return message; + }, + + toJSON(message: ModeInfo): unknown { + const obj: any = {}; + message.single !== undefined && + (obj.single = message.single + ? ModeInfo_Single.toJSON(message.single) + : undefined); + message.multi !== undefined && + (obj.multi = message.multi + ? ModeInfo_Multi.toJSON(message.multi) + : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): ModeInfo { + const message = { ...baseModeInfo } as ModeInfo; + if (object.single !== undefined && object.single !== null) { + message.single = ModeInfo_Single.fromPartial(object.single); + } else { + message.single = undefined; + } + if (object.multi !== undefined && object.multi !== null) { + message.multi = ModeInfo_Multi.fromPartial(object.multi); + } else { + message.multi = undefined; + } + return message; + }, +}; + +const baseModeInfo_Single: object = { mode: 0 }; + +export const ModeInfo_Single = { + encode(message: ModeInfo_Single, writer: Writer = Writer.create()): Writer { + if (message.mode !== 0) { + writer.uint32(8).int32(message.mode); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ModeInfo_Single { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseModeInfo_Single } as ModeInfo_Single; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.mode = reader.int32() as any; + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ModeInfo_Single { + const message = { ...baseModeInfo_Single } as ModeInfo_Single; + if (object.mode !== undefined && object.mode !== null) { + message.mode = signModeFromJSON(object.mode); + } else { + message.mode = 0; + } + return message; + }, + + toJSON(message: ModeInfo_Single): unknown { + const obj: any = {}; + message.mode !== undefined && (obj.mode = signModeToJSON(message.mode)); + return obj; + }, + + fromPartial(object: DeepPartial): ModeInfo_Single { + const message = { ...baseModeInfo_Single } as ModeInfo_Single; + if (object.mode !== undefined && object.mode !== null) { + message.mode = object.mode; + } else { + message.mode = 0; + } + return message; + }, +}; + +const baseModeInfo_Multi: object = {}; + +export const ModeInfo_Multi = { + encode(message: ModeInfo_Multi, writer: Writer = Writer.create()): Writer { + if (message.bitarray !== undefined) { + CompactBitArray.encode( + message.bitarray, + writer.uint32(10).fork() + ).ldelim(); + } + for (const v of message.modeInfos) { + ModeInfo.encode(v!, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ModeInfo_Multi { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseModeInfo_Multi } as ModeInfo_Multi; + message.modeInfos = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.bitarray = CompactBitArray.decode(reader, reader.uint32()); + break; + case 2: + message.modeInfos.push(ModeInfo.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ModeInfo_Multi { + const message = { ...baseModeInfo_Multi } as ModeInfo_Multi; + message.modeInfos = []; + if (object.bitarray !== undefined && object.bitarray !== null) { + message.bitarray = CompactBitArray.fromJSON(object.bitarray); + } else { + message.bitarray = undefined; + } + if (object.modeInfos !== undefined && object.modeInfos !== null) { + for (const e of object.modeInfos) { + message.modeInfos.push(ModeInfo.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: ModeInfo_Multi): unknown { + const obj: any = {}; + message.bitarray !== undefined && + (obj.bitarray = message.bitarray + ? CompactBitArray.toJSON(message.bitarray) + : undefined); + if (message.modeInfos) { + obj.modeInfos = message.modeInfos.map((e) => + e ? ModeInfo.toJSON(e) : undefined + ); + } else { + obj.modeInfos = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): ModeInfo_Multi { + const message = { ...baseModeInfo_Multi } as ModeInfo_Multi; + message.modeInfos = []; + if (object.bitarray !== undefined && object.bitarray !== null) { + message.bitarray = CompactBitArray.fromPartial(object.bitarray); + } else { + message.bitarray = undefined; + } + if (object.modeInfos !== undefined && object.modeInfos !== null) { + for (const e of object.modeInfos) { + message.modeInfos.push(ModeInfo.fromPartial(e)); + } + } + return message; + }, +}; + +const baseFee: object = { gasLimit: 0, payer: "", granter: "" }; + +export const Fee = { + encode(message: Fee, writer: Writer = Writer.create()): Writer { + for (const v of message.amount) { + Coin.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.gasLimit !== 0) { + writer.uint32(16).uint64(message.gasLimit); + } + if (message.payer !== "") { + writer.uint32(26).string(message.payer); + } + if (message.granter !== "") { + writer.uint32(34).string(message.granter); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Fee { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFee } as Fee; + message.amount = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.amount.push(Coin.decode(reader, reader.uint32())); + break; + case 2: + message.gasLimit = longToNumber(reader.uint64() as Long); + break; + case 3: + message.payer = reader.string(); + break; + case 4: + message.granter = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Fee { + const message = { ...baseFee } as Fee; + message.amount = []; + if (object.amount !== undefined && object.amount !== null) { + for (const e of object.amount) { + message.amount.push(Coin.fromJSON(e)); + } + } + if (object.gasLimit !== undefined && object.gasLimit !== null) { + message.gasLimit = Number(object.gasLimit); + } else { + message.gasLimit = 0; + } + if (object.payer !== undefined && object.payer !== null) { + message.payer = String(object.payer); + } else { + message.payer = ""; + } + if (object.granter !== undefined && object.granter !== null) { + message.granter = String(object.granter); + } else { + message.granter = ""; + } + return message; + }, + + toJSON(message: Fee): unknown { + const obj: any = {}; + if (message.amount) { + obj.amount = message.amount.map((e) => (e ? Coin.toJSON(e) : undefined)); + } else { + obj.amount = []; + } + message.gasLimit !== undefined && (obj.gasLimit = message.gasLimit); + message.payer !== undefined && (obj.payer = message.payer); + message.granter !== undefined && (obj.granter = message.granter); + return obj; + }, + + fromPartial(object: DeepPartial): Fee { + const message = { ...baseFee } as Fee; + message.amount = []; + if (object.amount !== undefined && object.amount !== null) { + for (const e of object.amount) { + message.amount.push(Coin.fromPartial(e)); + } + } + if (object.gasLimit !== undefined && object.gasLimit !== null) { + message.gasLimit = object.gasLimit; + } else { + message.gasLimit = 0; + } + if (object.payer !== undefined && object.payer !== null) { + message.payer = object.payer; + } else { + message.payer = ""; + } + if (object.granter !== undefined && object.granter !== null) { + message.granter = object.granter; + } else { + message.granter = ""; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/cosmos.tx.v1beta1/types/gogoproto/gogo.ts b/ts-client/cosmos.tx.v1beta1/types/gogoproto/gogo.ts new file mode 100644 index 00000000..3f41a047 --- /dev/null +++ b/ts-client/cosmos.tx.v1beta1/types/gogoproto/gogo.ts @@ -0,0 +1,2 @@ +/* eslint-disable */ +export const protobufPackage = "gogoproto"; diff --git a/ts-client/cosmos.tx.v1beta1/types/google/api/annotations.ts b/ts-client/cosmos.tx.v1beta1/types/google/api/annotations.ts new file mode 100644 index 00000000..aace4787 --- /dev/null +++ b/ts-client/cosmos.tx.v1beta1/types/google/api/annotations.ts @@ -0,0 +1,2 @@ +/* eslint-disable */ +export const protobufPackage = "google.api"; diff --git a/ts-client/cosmos.tx.v1beta1/types/google/api/http.ts b/ts-client/cosmos.tx.v1beta1/types/google/api/http.ts new file mode 100644 index 00000000..ddc00f8b --- /dev/null +++ b/ts-client/cosmos.tx.v1beta1/types/google/api/http.ts @@ -0,0 +1,705 @@ +/* eslint-disable */ +import { Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "google.api"; + +/** + * Defines the HTTP configuration for an API service. It contains a list of + * [HttpRule][google.api.HttpRule], each specifying the mapping of an RPC method + * to one or more HTTP REST API methods. + */ +export interface Http { + /** + * A list of HTTP configuration rules that apply to individual API methods. + * + * **NOTE:** All service configuration rules follow "last one wins" order. + */ + rules: HttpRule[]; + /** + * When set to true, URL path parmeters will be fully URI-decoded except in + * cases of single segment matches in reserved expansion, where "%2F" will be + * left encoded. + * + * The default behavior is to not decode RFC 6570 reserved characters in multi + * segment matches. + */ + fullyDecodeReservedExpansion: boolean; +} + +/** + * `HttpRule` defines the mapping of an RPC method to one or more HTTP + * REST API methods. The mapping specifies how different portions of the RPC + * request message are mapped to URL path, URL query parameters, and + * HTTP request body. The mapping is typically specified as an + * `google.api.http` annotation on the RPC method, + * see "google/api/annotations.proto" for details. + * + * The mapping consists of a field specifying the path template and + * method kind. The path template can refer to fields in the request + * message, as in the example below which describes a REST GET + * operation on a resource collection of messages: + * + * + * service Messaging { + * rpc GetMessage(GetMessageRequest) returns (Message) { + * option (google.api.http).get = "/v1/messages/{message_id}/{sub.subfield}"; + * } + * } + * message GetMessageRequest { + * message SubMessage { + * string subfield = 1; + * } + * string message_id = 1; // mapped to the URL + * SubMessage sub = 2; // `sub.subfield` is url-mapped + * } + * message Message { + * string text = 1; // content of the resource + * } + * + * The same http annotation can alternatively be expressed inside the + * `GRPC API Configuration` YAML file. + * + * http: + * rules: + * - selector: .Messaging.GetMessage + * get: /v1/messages/{message_id}/{sub.subfield} + * + * This definition enables an automatic, bidrectional mapping of HTTP + * JSON to RPC. Example: + * + * HTTP | RPC + * -----|----- + * `GET /v1/messages/123456/foo` | `GetMessage(message_id: "123456" sub: SubMessage(subfield: "foo"))` + * + * In general, not only fields but also field paths can be referenced + * from a path pattern. Fields mapped to the path pattern cannot be + * repeated and must have a primitive (non-message) type. + * + * Any fields in the request message which are not bound by the path + * pattern automatically become (optional) HTTP query + * parameters. Assume the following definition of the request message: + * + * + * service Messaging { + * rpc GetMessage(GetMessageRequest) returns (Message) { + * option (google.api.http).get = "/v1/messages/{message_id}"; + * } + * } + * message GetMessageRequest { + * message SubMessage { + * string subfield = 1; + * } + * string message_id = 1; // mapped to the URL + * int64 revision = 2; // becomes a parameter + * SubMessage sub = 3; // `sub.subfield` becomes a parameter + * } + * + * + * This enables a HTTP JSON to RPC mapping as below: + * + * HTTP | RPC + * -----|----- + * `GET /v1/messages/123456?revision=2&sub.subfield=foo` | `GetMessage(message_id: "123456" revision: 2 sub: SubMessage(subfield: "foo"))` + * + * Note that fields which are mapped to HTTP parameters must have a + * primitive type or a repeated primitive type. Message types are not + * allowed. In the case of a repeated type, the parameter can be + * repeated in the URL, as in `...?param=A¶m=B`. + * + * For HTTP method kinds which allow a request body, the `body` field + * specifies the mapping. Consider a REST update method on the + * message resource collection: + * + * + * service Messaging { + * rpc UpdateMessage(UpdateMessageRequest) returns (Message) { + * option (google.api.http) = { + * put: "/v1/messages/{message_id}" + * body: "message" + * }; + * } + * } + * message UpdateMessageRequest { + * string message_id = 1; // mapped to the URL + * Message message = 2; // mapped to the body + * } + * + * + * The following HTTP JSON to RPC mapping is enabled, where the + * representation of the JSON in the request body is determined by + * protos JSON encoding: + * + * HTTP | RPC + * -----|----- + * `PUT /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: "123456" message { text: "Hi!" })` + * + * The special name `*` can be used in the body mapping to define that + * every field not bound by the path template should be mapped to the + * request body. This enables the following alternative definition of + * the update method: + * + * service Messaging { + * rpc UpdateMessage(Message) returns (Message) { + * option (google.api.http) = { + * put: "/v1/messages/{message_id}" + * body: "*" + * }; + * } + * } + * message Message { + * string message_id = 1; + * string text = 2; + * } + * + * + * The following HTTP JSON to RPC mapping is enabled: + * + * HTTP | RPC + * -----|----- + * `PUT /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: "123456" text: "Hi!")` + * + * Note that when using `*` in the body mapping, it is not possible to + * have HTTP parameters, as all fields not bound by the path end in + * the body. This makes this option more rarely used in practice of + * defining REST APIs. The common usage of `*` is in custom methods + * which don't use the URL at all for transferring data. + * + * It is possible to define multiple HTTP methods for one RPC by using + * the `additional_bindings` option. Example: + * + * service Messaging { + * rpc GetMessage(GetMessageRequest) returns (Message) { + * option (google.api.http) = { + * get: "/v1/messages/{message_id}" + * additional_bindings { + * get: "/v1/users/{user_id}/messages/{message_id}" + * } + * }; + * } + * } + * message GetMessageRequest { + * string message_id = 1; + * string user_id = 2; + * } + * + * + * This enables the following two alternative HTTP JSON to RPC + * mappings: + * + * HTTP | RPC + * -----|----- + * `GET /v1/messages/123456` | `GetMessage(message_id: "123456")` + * `GET /v1/users/me/messages/123456` | `GetMessage(user_id: "me" message_id: "123456")` + * + * # Rules for HTTP mapping + * + * The rules for mapping HTTP path, query parameters, and body fields + * to the request message are as follows: + * + * 1. The `body` field specifies either `*` or a field path, or is + * omitted. If omitted, it indicates there is no HTTP request body. + * 2. Leaf fields (recursive expansion of nested messages in the + * request) can be classified into three types: + * (a) Matched in the URL template. + * (b) Covered by body (if body is `*`, everything except (a) fields; + * else everything under the body field) + * (c) All other fields. + * 3. URL query parameters found in the HTTP request are mapped to (c) fields. + * 4. Any body sent with an HTTP request can contain only (b) fields. + * + * The syntax of the path template is as follows: + * + * Template = "/" Segments [ Verb ] ; + * Segments = Segment { "/" Segment } ; + * Segment = "*" | "**" | LITERAL | Variable ; + * Variable = "{" FieldPath [ "=" Segments ] "}" ; + * FieldPath = IDENT { "." IDENT } ; + * Verb = ":" LITERAL ; + * + * The syntax `*` matches a single path segment. The syntax `**` matches zero + * or more path segments, which must be the last part of the path except the + * `Verb`. The syntax `LITERAL` matches literal text in the path. + * + * The syntax `Variable` matches part of the URL path as specified by its + * template. A variable template must not contain other variables. If a variable + * matches a single path segment, its template may be omitted, e.g. `{var}` + * is equivalent to `{var=*}`. + * + * If a variable contains exactly one path segment, such as `"{var}"` or + * `"{var=*}"`, when such a variable is expanded into a URL path, all characters + * except `[-_.~0-9a-zA-Z]` are percent-encoded. Such variables show up in the + * Discovery Document as `{var}`. + * + * If a variable contains one or more path segments, such as `"{var=foo/*}"` + * or `"{var=**}"`, when such a variable is expanded into a URL path, all + * characters except `[-_.~/0-9a-zA-Z]` are percent-encoded. Such variables + * show up in the Discovery Document as `{+var}`. + * + * NOTE: While the single segment variable matches the semantics of + * [RFC 6570](https://tools.ietf.org/html/rfc6570) Section 3.2.2 + * Simple String Expansion, the multi segment variable **does not** match + * RFC 6570 Reserved Expansion. The reason is that the Reserved Expansion + * does not expand special characters like `?` and `#`, which would lead + * to invalid URLs. + * + * NOTE: the field paths in variables and in the `body` must not refer to + * repeated fields or map fields. + */ +export interface HttpRule { + /** + * Selects methods to which this rule applies. + * + * Refer to [selector][google.api.DocumentationRule.selector] for syntax details. + */ + selector: string; + /** Used for listing and getting information about resources. */ + get: string | undefined; + /** Used for updating a resource. */ + put: string | undefined; + /** Used for creating a resource. */ + post: string | undefined; + /** Used for deleting a resource. */ + delete: string | undefined; + /** Used for updating a resource. */ + patch: string | undefined; + /** + * The custom pattern is used for specifying an HTTP method that is not + * included in the `pattern` field, such as HEAD, or "*" to leave the + * HTTP method unspecified for this rule. The wild-card rule is useful + * for services that provide content to Web (HTML) clients. + */ + custom: CustomHttpPattern | undefined; + /** + * The name of the request field whose value is mapped to the HTTP body, or + * `*` for mapping all fields not captured by the path pattern to the HTTP + * body. NOTE: the referred field must not be a repeated field and must be + * present at the top-level of request message type. + */ + body: string; + /** + * Optional. The name of the response field whose value is mapped to the HTTP + * body of response. Other response fields are ignored. When + * not set, the response message will be used as HTTP body of response. + */ + responseBody: string; + /** + * Additional HTTP bindings for the selector. Nested bindings must + * not contain an `additional_bindings` field themselves (that is, + * the nesting may only be one level deep). + */ + additionalBindings: HttpRule[]; +} + +/** A custom pattern is used for defining custom HTTP verb. */ +export interface CustomHttpPattern { + /** The name of this custom HTTP verb. */ + kind: string; + /** The path matched by this custom verb. */ + path: string; +} + +const baseHttp: object = { fullyDecodeReservedExpansion: false }; + +export const Http = { + encode(message: Http, writer: Writer = Writer.create()): Writer { + for (const v of message.rules) { + HttpRule.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.fullyDecodeReservedExpansion === true) { + writer.uint32(16).bool(message.fullyDecodeReservedExpansion); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Http { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseHttp } as Http; + message.rules = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.rules.push(HttpRule.decode(reader, reader.uint32())); + break; + case 2: + message.fullyDecodeReservedExpansion = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Http { + const message = { ...baseHttp } as Http; + message.rules = []; + if (object.rules !== undefined && object.rules !== null) { + for (const e of object.rules) { + message.rules.push(HttpRule.fromJSON(e)); + } + } + if ( + object.fullyDecodeReservedExpansion !== undefined && + object.fullyDecodeReservedExpansion !== null + ) { + message.fullyDecodeReservedExpansion = Boolean( + object.fullyDecodeReservedExpansion + ); + } else { + message.fullyDecodeReservedExpansion = false; + } + return message; + }, + + toJSON(message: Http): unknown { + const obj: any = {}; + if (message.rules) { + obj.rules = message.rules.map((e) => + e ? HttpRule.toJSON(e) : undefined + ); + } else { + obj.rules = []; + } + message.fullyDecodeReservedExpansion !== undefined && + (obj.fullyDecodeReservedExpansion = message.fullyDecodeReservedExpansion); + return obj; + }, + + fromPartial(object: DeepPartial): Http { + const message = { ...baseHttp } as Http; + message.rules = []; + if (object.rules !== undefined && object.rules !== null) { + for (const e of object.rules) { + message.rules.push(HttpRule.fromPartial(e)); + } + } + if ( + object.fullyDecodeReservedExpansion !== undefined && + object.fullyDecodeReservedExpansion !== null + ) { + message.fullyDecodeReservedExpansion = + object.fullyDecodeReservedExpansion; + } else { + message.fullyDecodeReservedExpansion = false; + } + return message; + }, +}; + +const baseHttpRule: object = { selector: "", body: "", responseBody: "" }; + +export const HttpRule = { + encode(message: HttpRule, writer: Writer = Writer.create()): Writer { + if (message.selector !== "") { + writer.uint32(10).string(message.selector); + } + if (message.get !== undefined) { + writer.uint32(18).string(message.get); + } + if (message.put !== undefined) { + writer.uint32(26).string(message.put); + } + if (message.post !== undefined) { + writer.uint32(34).string(message.post); + } + if (message.delete !== undefined) { + writer.uint32(42).string(message.delete); + } + if (message.patch !== undefined) { + writer.uint32(50).string(message.patch); + } + if (message.custom !== undefined) { + CustomHttpPattern.encode( + message.custom, + writer.uint32(66).fork() + ).ldelim(); + } + if (message.body !== "") { + writer.uint32(58).string(message.body); + } + if (message.responseBody !== "") { + writer.uint32(98).string(message.responseBody); + } + for (const v of message.additionalBindings) { + HttpRule.encode(v!, writer.uint32(90).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): HttpRule { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseHttpRule } as HttpRule; + message.additionalBindings = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.selector = reader.string(); + break; + case 2: + message.get = reader.string(); + break; + case 3: + message.put = reader.string(); + break; + case 4: + message.post = reader.string(); + break; + case 5: + message.delete = reader.string(); + break; + case 6: + message.patch = reader.string(); + break; + case 8: + message.custom = CustomHttpPattern.decode(reader, reader.uint32()); + break; + case 7: + message.body = reader.string(); + break; + case 12: + message.responseBody = reader.string(); + break; + case 11: + message.additionalBindings.push( + HttpRule.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): HttpRule { + const message = { ...baseHttpRule } as HttpRule; + message.additionalBindings = []; + if (object.selector !== undefined && object.selector !== null) { + message.selector = String(object.selector); + } else { + message.selector = ""; + } + if (object.get !== undefined && object.get !== null) { + message.get = String(object.get); + } else { + message.get = undefined; + } + if (object.put !== undefined && object.put !== null) { + message.put = String(object.put); + } else { + message.put = undefined; + } + if (object.post !== undefined && object.post !== null) { + message.post = String(object.post); + } else { + message.post = undefined; + } + if (object.delete !== undefined && object.delete !== null) { + message.delete = String(object.delete); + } else { + message.delete = undefined; + } + if (object.patch !== undefined && object.patch !== null) { + message.patch = String(object.patch); + } else { + message.patch = undefined; + } + if (object.custom !== undefined && object.custom !== null) { + message.custom = CustomHttpPattern.fromJSON(object.custom); + } else { + message.custom = undefined; + } + if (object.body !== undefined && object.body !== null) { + message.body = String(object.body); + } else { + message.body = ""; + } + if (object.responseBody !== undefined && object.responseBody !== null) { + message.responseBody = String(object.responseBody); + } else { + message.responseBody = ""; + } + if ( + object.additionalBindings !== undefined && + object.additionalBindings !== null + ) { + for (const e of object.additionalBindings) { + message.additionalBindings.push(HttpRule.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: HttpRule): unknown { + const obj: any = {}; + message.selector !== undefined && (obj.selector = message.selector); + message.get !== undefined && (obj.get = message.get); + message.put !== undefined && (obj.put = message.put); + message.post !== undefined && (obj.post = message.post); + message.delete !== undefined && (obj.delete = message.delete); + message.patch !== undefined && (obj.patch = message.patch); + message.custom !== undefined && + (obj.custom = message.custom + ? CustomHttpPattern.toJSON(message.custom) + : undefined); + message.body !== undefined && (obj.body = message.body); + message.responseBody !== undefined && + (obj.responseBody = message.responseBody); + if (message.additionalBindings) { + obj.additionalBindings = message.additionalBindings.map((e) => + e ? HttpRule.toJSON(e) : undefined + ); + } else { + obj.additionalBindings = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): HttpRule { + const message = { ...baseHttpRule } as HttpRule; + message.additionalBindings = []; + if (object.selector !== undefined && object.selector !== null) { + message.selector = object.selector; + } else { + message.selector = ""; + } + if (object.get !== undefined && object.get !== null) { + message.get = object.get; + } else { + message.get = undefined; + } + if (object.put !== undefined && object.put !== null) { + message.put = object.put; + } else { + message.put = undefined; + } + if (object.post !== undefined && object.post !== null) { + message.post = object.post; + } else { + message.post = undefined; + } + if (object.delete !== undefined && object.delete !== null) { + message.delete = object.delete; + } else { + message.delete = undefined; + } + if (object.patch !== undefined && object.patch !== null) { + message.patch = object.patch; + } else { + message.patch = undefined; + } + if (object.custom !== undefined && object.custom !== null) { + message.custom = CustomHttpPattern.fromPartial(object.custom); + } else { + message.custom = undefined; + } + if (object.body !== undefined && object.body !== null) { + message.body = object.body; + } else { + message.body = ""; + } + if (object.responseBody !== undefined && object.responseBody !== null) { + message.responseBody = object.responseBody; + } else { + message.responseBody = ""; + } + if ( + object.additionalBindings !== undefined && + object.additionalBindings !== null + ) { + for (const e of object.additionalBindings) { + message.additionalBindings.push(HttpRule.fromPartial(e)); + } + } + return message; + }, +}; + +const baseCustomHttpPattern: object = { kind: "", path: "" }; + +export const CustomHttpPattern = { + encode(message: CustomHttpPattern, writer: Writer = Writer.create()): Writer { + if (message.kind !== "") { + writer.uint32(10).string(message.kind); + } + if (message.path !== "") { + writer.uint32(18).string(message.path); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): CustomHttpPattern { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseCustomHttpPattern } as CustomHttpPattern; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.kind = reader.string(); + break; + case 2: + message.path = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): CustomHttpPattern { + const message = { ...baseCustomHttpPattern } as CustomHttpPattern; + if (object.kind !== undefined && object.kind !== null) { + message.kind = String(object.kind); + } else { + message.kind = ""; + } + if (object.path !== undefined && object.path !== null) { + message.path = String(object.path); + } else { + message.path = ""; + } + return message; + }, + + toJSON(message: CustomHttpPattern): unknown { + const obj: any = {}; + message.kind !== undefined && (obj.kind = message.kind); + message.path !== undefined && (obj.path = message.path); + return obj; + }, + + fromPartial(object: DeepPartial): CustomHttpPattern { + const message = { ...baseCustomHttpPattern } as CustomHttpPattern; + if (object.kind !== undefined && object.kind !== null) { + message.kind = object.kind; + } else { + message.kind = ""; + } + if (object.path !== undefined && object.path !== null) { + message.path = object.path; + } else { + message.path = ""; + } + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/cosmos.tx.v1beta1/types/google/protobuf/any.ts b/ts-client/cosmos.tx.v1beta1/types/google/protobuf/any.ts new file mode 100644 index 00000000..b137a629 --- /dev/null +++ b/ts-client/cosmos.tx.v1beta1/types/google/protobuf/any.ts @@ -0,0 +1,240 @@ +/* eslint-disable */ +import { Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "google.protobuf"; + +/** + * `Any` contains an arbitrary serialized protocol buffer message along with a + * URL that describes the type of the serialized message. + * + * Protobuf library provides support to pack/unpack Any values in the form + * of utility functions or additional generated methods of the Any type. + * + * Example 1: Pack and unpack a message in C++. + * + * Foo foo = ...; + * Any any; + * any.PackFrom(foo); + * ... + * if (any.UnpackTo(&foo)) { + * ... + * } + * + * Example 2: Pack and unpack a message in Java. + * + * Foo foo = ...; + * Any any = Any.pack(foo); + * ... + * if (any.is(Foo.class)) { + * foo = any.unpack(Foo.class); + * } + * + * Example 3: Pack and unpack a message in Python. + * + * foo = Foo(...) + * any = Any() + * any.Pack(foo) + * ... + * if any.Is(Foo.DESCRIPTOR): + * any.Unpack(foo) + * ... + * + * Example 4: Pack and unpack a message in Go + * + * foo := &pb.Foo{...} + * any, err := anypb.New(foo) + * if err != nil { + * ... + * } + * ... + * foo := &pb.Foo{} + * if err := any.UnmarshalTo(foo); err != nil { + * ... + * } + * + * The pack methods provided by protobuf library will by default use + * 'type.googleapis.com/full.type.name' as the type URL and the unpack + * methods only use the fully qualified type name after the last '/' + * in the type URL, for example "foo.bar.com/x/y.z" will yield type + * name "y.z". + * + * + * JSON + * ==== + * The JSON representation of an `Any` value uses the regular + * representation of the deserialized, embedded message, with an + * additional field `@type` which contains the type URL. Example: + * + * package google.profile; + * message Person { + * string first_name = 1; + * string last_name = 2; + * } + * + * { + * "@type": "type.googleapis.com/google.profile.Person", + * "firstName": , + * "lastName": + * } + * + * If the embedded message type is well-known and has a custom JSON + * representation, that representation will be embedded adding a field + * `value` which holds the custom JSON in addition to the `@type` + * field. Example (for message [google.protobuf.Duration][]): + * + * { + * "@type": "type.googleapis.com/google.protobuf.Duration", + * "value": "1.212s" + * } + */ +export interface Any { + /** + * A URL/resource name that uniquely identifies the type of the serialized + * protocol buffer message. This string must contain at least + * one "/" character. The last segment of the URL's path must represent + * the fully qualified name of the type (as in + * `path/google.protobuf.Duration`). The name should be in a canonical form + * (e.g., leading "." is not accepted). + * + * In practice, teams usually precompile into the binary all types that they + * expect it to use in the context of Any. However, for URLs which use the + * scheme `http`, `https`, or no scheme, one can optionally set up a type + * server that maps type URLs to message definitions as follows: + * + * * If no scheme is provided, `https` is assumed. + * * An HTTP GET on the URL must yield a [google.protobuf.Type][] + * value in binary format, or produce an error. + * * Applications are allowed to cache lookup results based on the + * URL, or have them precompiled into a binary to avoid any + * lookup. Therefore, binary compatibility needs to be preserved + * on changes to types. (Use versioned type names to manage + * breaking changes.) + * + * Note: this functionality is not currently available in the official + * protobuf release, and it is not used for type URLs beginning with + * type.googleapis.com. + * + * Schemes other than `http`, `https` (or the empty scheme) might be + * used with implementation specific semantics. + */ + typeUrl: string; + /** Must be a valid serialized protocol buffer of the above specified type. */ + value: Uint8Array; +} + +const baseAny: object = { typeUrl: "" }; + +export const Any = { + encode(message: Any, writer: Writer = Writer.create()): Writer { + if (message.typeUrl !== "") { + writer.uint32(10).string(message.typeUrl); + } + if (message.value.length !== 0) { + writer.uint32(18).bytes(message.value); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Any { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseAny } as Any; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.typeUrl = reader.string(); + break; + case 2: + message.value = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Any { + const message = { ...baseAny } as Any; + if (object.typeUrl !== undefined && object.typeUrl !== null) { + message.typeUrl = String(object.typeUrl); + } else { + message.typeUrl = ""; + } + if (object.value !== undefined && object.value !== null) { + message.value = bytesFromBase64(object.value); + } + return message; + }, + + toJSON(message: Any): unknown { + const obj: any = {}; + message.typeUrl !== undefined && (obj.typeUrl = message.typeUrl); + message.value !== undefined && + (obj.value = base64FromBytes( + message.value !== undefined ? message.value : new Uint8Array() + )); + return obj; + }, + + fromPartial(object: DeepPartial): Any { + const message = { ...baseAny } as Any; + if (object.typeUrl !== undefined && object.typeUrl !== null) { + message.typeUrl = object.typeUrl; + } else { + message.typeUrl = ""; + } + if (object.value !== undefined && object.value !== null) { + message.value = object.value; + } else { + message.value = new Uint8Array(); + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/cosmos.tx.v1beta1/types/google/protobuf/descriptor.ts b/ts-client/cosmos.tx.v1beta1/types/google/protobuf/descriptor.ts new file mode 100644 index 00000000..9e508660 --- /dev/null +++ b/ts-client/cosmos.tx.v1beta1/types/google/protobuf/descriptor.ts @@ -0,0 +1,5261 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "google.protobuf"; + +/** + * The protocol compiler can output a FileDescriptorSet containing the .proto + * files it parses. + */ +export interface FileDescriptorSet { + file: FileDescriptorProto[]; +} + +/** Describes a complete .proto file. */ +export interface FileDescriptorProto { + /** file name, relative to root of source tree */ + name: string; + /** e.g. "foo", "foo.bar", etc. */ + package: string; + /** Names of files imported by this file. */ + dependency: string[]; + /** Indexes of the public imported files in the dependency list above. */ + publicDependency: number[]; + /** + * Indexes of the weak imported files in the dependency list. + * For Google-internal migration only. Do not use. + */ + weakDependency: number[]; + /** All top-level definitions in this file. */ + messageType: DescriptorProto[]; + enumType: EnumDescriptorProto[]; + service: ServiceDescriptorProto[]; + extension: FieldDescriptorProto[]; + options: FileOptions | undefined; + /** + * This field contains optional information about the original source code. + * You may safely remove this entire field without harming runtime + * functionality of the descriptors -- the information is needed only by + * development tools. + */ + sourceCodeInfo: SourceCodeInfo | undefined; + /** + * The syntax of the proto file. + * The supported values are "proto2" and "proto3". + */ + syntax: string; +} + +/** Describes a message type. */ +export interface DescriptorProto { + name: string; + field: FieldDescriptorProto[]; + extension: FieldDescriptorProto[]; + nestedType: DescriptorProto[]; + enumType: EnumDescriptorProto[]; + extensionRange: DescriptorProto_ExtensionRange[]; + oneofDecl: OneofDescriptorProto[]; + options: MessageOptions | undefined; + reservedRange: DescriptorProto_ReservedRange[]; + /** + * Reserved field names, which may not be used by fields in the same message. + * A given name may only be reserved once. + */ + reservedName: string[]; +} + +export interface DescriptorProto_ExtensionRange { + /** Inclusive. */ + start: number; + /** Exclusive. */ + end: number; + options: ExtensionRangeOptions | undefined; +} + +/** + * Range of reserved tag numbers. Reserved tag numbers may not be used by + * fields or extension ranges in the same message. Reserved ranges may + * not overlap. + */ +export interface DescriptorProto_ReservedRange { + /** Inclusive. */ + start: number; + /** Exclusive. */ + end: number; +} + +export interface ExtensionRangeOptions { + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +/** Describes a field within a message. */ +export interface FieldDescriptorProto { + name: string; + number: number; + label: FieldDescriptorProto_Label; + /** + * If type_name is set, this need not be set. If both this and type_name + * are set, this must be one of TYPE_ENUM, TYPE_MESSAGE or TYPE_GROUP. + */ + type: FieldDescriptorProto_Type; + /** + * For message and enum types, this is the name of the type. If the name + * starts with a '.', it is fully-qualified. Otherwise, C++-like scoping + * rules are used to find the type (i.e. first the nested types within this + * message are searched, then within the parent, on up to the root + * namespace). + */ + typeName: string; + /** + * For extensions, this is the name of the type being extended. It is + * resolved in the same manner as type_name. + */ + extendee: string; + /** + * For numeric types, contains the original text representation of the value. + * For booleans, "true" or "false". + * For strings, contains the default text contents (not escaped in any way). + * For bytes, contains the C escaped value. All bytes >= 128 are escaped. + * TODO(kenton): Base-64 encode? + */ + defaultValue: string; + /** + * If set, gives the index of a oneof in the containing type's oneof_decl + * list. This field is a member of that oneof. + */ + oneofIndex: number; + /** + * JSON name of this field. The value is set by protocol compiler. If the + * user has set a "json_name" option on this field, that option's value + * will be used. Otherwise, it's deduced from the field's name by converting + * it to camelCase. + */ + jsonName: string; + options: FieldOptions | undefined; + /** + * If true, this is a proto3 "optional". When a proto3 field is optional, it + * tracks presence regardless of field type. + * + * When proto3_optional is true, this field must be belong to a oneof to + * signal to old proto3 clients that presence is tracked for this field. This + * oneof is known as a "synthetic" oneof, and this field must be its sole + * member (each proto3 optional field gets its own synthetic oneof). Synthetic + * oneofs exist in the descriptor only, and do not generate any API. Synthetic + * oneofs must be ordered after all "real" oneofs. + * + * For message fields, proto3_optional doesn't create any semantic change, + * since non-repeated message fields always track presence. However it still + * indicates the semantic detail of whether the user wrote "optional" or not. + * This can be useful for round-tripping the .proto file. For consistency we + * give message fields a synthetic oneof also, even though it is not required + * to track presence. This is especially important because the parser can't + * tell if a field is a message or an enum, so it must always create a + * synthetic oneof. + * + * Proto2 optional fields do not set this flag, because they already indicate + * optional with `LABEL_OPTIONAL`. + */ + proto3Optional: boolean; +} + +export enum FieldDescriptorProto_Type { + /** + * TYPE_DOUBLE - 0 is reserved for errors. + * Order is weird for historical reasons. + */ + TYPE_DOUBLE = 1, + TYPE_FLOAT = 2, + /** + * TYPE_INT64 - Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT64 if + * negative values are likely. + */ + TYPE_INT64 = 3, + TYPE_UINT64 = 4, + /** + * TYPE_INT32 - Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT32 if + * negative values are likely. + */ + TYPE_INT32 = 5, + TYPE_FIXED64 = 6, + TYPE_FIXED32 = 7, + TYPE_BOOL = 8, + TYPE_STRING = 9, + /** + * TYPE_GROUP - Tag-delimited aggregate. + * Group type is deprecated and not supported in proto3. However, Proto3 + * implementations should still be able to parse the group wire format and + * treat group fields as unknown fields. + */ + TYPE_GROUP = 10, + /** TYPE_MESSAGE - Length-delimited aggregate. */ + TYPE_MESSAGE = 11, + /** TYPE_BYTES - New in version 2. */ + TYPE_BYTES = 12, + TYPE_UINT32 = 13, + TYPE_ENUM = 14, + TYPE_SFIXED32 = 15, + TYPE_SFIXED64 = 16, + /** TYPE_SINT32 - Uses ZigZag encoding. */ + TYPE_SINT32 = 17, + /** TYPE_SINT64 - Uses ZigZag encoding. */ + TYPE_SINT64 = 18, + UNRECOGNIZED = -1, +} + +export function fieldDescriptorProto_TypeFromJSON( + object: any +): FieldDescriptorProto_Type { + switch (object) { + case 1: + case "TYPE_DOUBLE": + return FieldDescriptorProto_Type.TYPE_DOUBLE; + case 2: + case "TYPE_FLOAT": + return FieldDescriptorProto_Type.TYPE_FLOAT; + case 3: + case "TYPE_INT64": + return FieldDescriptorProto_Type.TYPE_INT64; + case 4: + case "TYPE_UINT64": + return FieldDescriptorProto_Type.TYPE_UINT64; + case 5: + case "TYPE_INT32": + return FieldDescriptorProto_Type.TYPE_INT32; + case 6: + case "TYPE_FIXED64": + return FieldDescriptorProto_Type.TYPE_FIXED64; + case 7: + case "TYPE_FIXED32": + return FieldDescriptorProto_Type.TYPE_FIXED32; + case 8: + case "TYPE_BOOL": + return FieldDescriptorProto_Type.TYPE_BOOL; + case 9: + case "TYPE_STRING": + return FieldDescriptorProto_Type.TYPE_STRING; + case 10: + case "TYPE_GROUP": + return FieldDescriptorProto_Type.TYPE_GROUP; + case 11: + case "TYPE_MESSAGE": + return FieldDescriptorProto_Type.TYPE_MESSAGE; + case 12: + case "TYPE_BYTES": + return FieldDescriptorProto_Type.TYPE_BYTES; + case 13: + case "TYPE_UINT32": + return FieldDescriptorProto_Type.TYPE_UINT32; + case 14: + case "TYPE_ENUM": + return FieldDescriptorProto_Type.TYPE_ENUM; + case 15: + case "TYPE_SFIXED32": + return FieldDescriptorProto_Type.TYPE_SFIXED32; + case 16: + case "TYPE_SFIXED64": + return FieldDescriptorProto_Type.TYPE_SFIXED64; + case 17: + case "TYPE_SINT32": + return FieldDescriptorProto_Type.TYPE_SINT32; + case 18: + case "TYPE_SINT64": + return FieldDescriptorProto_Type.TYPE_SINT64; + case -1: + case "UNRECOGNIZED": + default: + return FieldDescriptorProto_Type.UNRECOGNIZED; + } +} + +export function fieldDescriptorProto_TypeToJSON( + object: FieldDescriptorProto_Type +): string { + switch (object) { + case FieldDescriptorProto_Type.TYPE_DOUBLE: + return "TYPE_DOUBLE"; + case FieldDescriptorProto_Type.TYPE_FLOAT: + return "TYPE_FLOAT"; + case FieldDescriptorProto_Type.TYPE_INT64: + return "TYPE_INT64"; + case FieldDescriptorProto_Type.TYPE_UINT64: + return "TYPE_UINT64"; + case FieldDescriptorProto_Type.TYPE_INT32: + return "TYPE_INT32"; + case FieldDescriptorProto_Type.TYPE_FIXED64: + return "TYPE_FIXED64"; + case FieldDescriptorProto_Type.TYPE_FIXED32: + return "TYPE_FIXED32"; + case FieldDescriptorProto_Type.TYPE_BOOL: + return "TYPE_BOOL"; + case FieldDescriptorProto_Type.TYPE_STRING: + return "TYPE_STRING"; + case FieldDescriptorProto_Type.TYPE_GROUP: + return "TYPE_GROUP"; + case FieldDescriptorProto_Type.TYPE_MESSAGE: + return "TYPE_MESSAGE"; + case FieldDescriptorProto_Type.TYPE_BYTES: + return "TYPE_BYTES"; + case FieldDescriptorProto_Type.TYPE_UINT32: + return "TYPE_UINT32"; + case FieldDescriptorProto_Type.TYPE_ENUM: + return "TYPE_ENUM"; + case FieldDescriptorProto_Type.TYPE_SFIXED32: + return "TYPE_SFIXED32"; + case FieldDescriptorProto_Type.TYPE_SFIXED64: + return "TYPE_SFIXED64"; + case FieldDescriptorProto_Type.TYPE_SINT32: + return "TYPE_SINT32"; + case FieldDescriptorProto_Type.TYPE_SINT64: + return "TYPE_SINT64"; + default: + return "UNKNOWN"; + } +} + +export enum FieldDescriptorProto_Label { + /** LABEL_OPTIONAL - 0 is reserved for errors */ + LABEL_OPTIONAL = 1, + LABEL_REQUIRED = 2, + LABEL_REPEATED = 3, + UNRECOGNIZED = -1, +} + +export function fieldDescriptorProto_LabelFromJSON( + object: any +): FieldDescriptorProto_Label { + switch (object) { + case 1: + case "LABEL_OPTIONAL": + return FieldDescriptorProto_Label.LABEL_OPTIONAL; + case 2: + case "LABEL_REQUIRED": + return FieldDescriptorProto_Label.LABEL_REQUIRED; + case 3: + case "LABEL_REPEATED": + return FieldDescriptorProto_Label.LABEL_REPEATED; + case -1: + case "UNRECOGNIZED": + default: + return FieldDescriptorProto_Label.UNRECOGNIZED; + } +} + +export function fieldDescriptorProto_LabelToJSON( + object: FieldDescriptorProto_Label +): string { + switch (object) { + case FieldDescriptorProto_Label.LABEL_OPTIONAL: + return "LABEL_OPTIONAL"; + case FieldDescriptorProto_Label.LABEL_REQUIRED: + return "LABEL_REQUIRED"; + case FieldDescriptorProto_Label.LABEL_REPEATED: + return "LABEL_REPEATED"; + default: + return "UNKNOWN"; + } +} + +/** Describes a oneof. */ +export interface OneofDescriptorProto { + name: string; + options: OneofOptions | undefined; +} + +/** Describes an enum type. */ +export interface EnumDescriptorProto { + name: string; + value: EnumValueDescriptorProto[]; + options: EnumOptions | undefined; + /** + * Range of reserved numeric values. Reserved numeric values may not be used + * by enum values in the same enum declaration. Reserved ranges may not + * overlap. + */ + reservedRange: EnumDescriptorProto_EnumReservedRange[]; + /** + * Reserved enum value names, which may not be reused. A given name may only + * be reserved once. + */ + reservedName: string[]; +} + +/** + * Range of reserved numeric values. Reserved values may not be used by + * entries in the same enum. Reserved ranges may not overlap. + * + * Note that this is distinct from DescriptorProto.ReservedRange in that it + * is inclusive such that it can appropriately represent the entire int32 + * domain. + */ +export interface EnumDescriptorProto_EnumReservedRange { + /** Inclusive. */ + start: number; + /** Inclusive. */ + end: number; +} + +/** Describes a value within an enum. */ +export interface EnumValueDescriptorProto { + name: string; + number: number; + options: EnumValueOptions | undefined; +} + +/** Describes a service. */ +export interface ServiceDescriptorProto { + name: string; + method: MethodDescriptorProto[]; + options: ServiceOptions | undefined; +} + +/** Describes a method of a service. */ +export interface MethodDescriptorProto { + name: string; + /** + * Input and output type names. These are resolved in the same way as + * FieldDescriptorProto.type_name, but must refer to a message type. + */ + inputType: string; + outputType: string; + options: MethodOptions | undefined; + /** Identifies if client streams multiple client messages */ + clientStreaming: boolean; + /** Identifies if server streams multiple server messages */ + serverStreaming: boolean; +} + +export interface FileOptions { + /** + * Sets the Java package where classes generated from this .proto will be + * placed. By default, the proto package is used, but this is often + * inappropriate because proto packages do not normally start with backwards + * domain names. + */ + javaPackage: string; + /** + * Controls the name of the wrapper Java class generated for the .proto file. + * That class will always contain the .proto file's getDescriptor() method as + * well as any top-level extensions defined in the .proto file. + * If java_multiple_files is disabled, then all the other classes from the + * .proto file will be nested inside the single wrapper outer class. + */ + javaOuterClassname: string; + /** + * If enabled, then the Java code generator will generate a separate .java + * file for each top-level message, enum, and service defined in the .proto + * file. Thus, these types will *not* be nested inside the wrapper class + * named by java_outer_classname. However, the wrapper class will still be + * generated to contain the file's getDescriptor() method as well as any + * top-level extensions defined in the file. + */ + javaMultipleFiles: boolean; + /** + * This option does nothing. + * + * @deprecated + */ + javaGenerateEqualsAndHash: boolean; + /** + * If set true, then the Java2 code generator will generate code that + * throws an exception whenever an attempt is made to assign a non-UTF-8 + * byte sequence to a string field. + * Message reflection will do the same. + * However, an extension field still accepts non-UTF-8 byte sequences. + * This option has no effect on when used with the lite runtime. + */ + javaStringCheckUtf8: boolean; + optimizeFor: FileOptions_OptimizeMode; + /** + * Sets the Go package where structs generated from this .proto will be + * placed. If omitted, the Go package will be derived from the following: + * - The basename of the package import path, if provided. + * - Otherwise, the package statement in the .proto file, if present. + * - Otherwise, the basename of the .proto file, without extension. + */ + goPackage: string; + /** + * Should generic services be generated in each language? "Generic" services + * are not specific to any particular RPC system. They are generated by the + * main code generators in each language (without additional plugins). + * Generic services were the only kind of service generation supported by + * early versions of google.protobuf. + * + * Generic services are now considered deprecated in favor of using plugins + * that generate code specific to your particular RPC system. Therefore, + * these default to false. Old code which depends on generic services should + * explicitly set them to true. + */ + ccGenericServices: boolean; + javaGenericServices: boolean; + pyGenericServices: boolean; + phpGenericServices: boolean; + /** + * Is this file deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for everything in the file, or it will be completely ignored; in the very + * least, this is a formalization for deprecating files. + */ + deprecated: boolean; + /** + * Enables the use of arenas for the proto messages in this file. This applies + * only to generated classes for C++. + */ + ccEnableArenas: boolean; + /** + * Sets the objective c class prefix which is prepended to all objective c + * generated classes from this .proto. There is no default. + */ + objcClassPrefix: string; + /** Namespace for generated classes; defaults to the package. */ + csharpNamespace: string; + /** + * By default Swift generators will take the proto package and CamelCase it + * replacing '.' with underscore and use that to prefix the types/symbols + * defined. When this options is provided, they will use this value instead + * to prefix the types/symbols defined. + */ + swiftPrefix: string; + /** + * Sets the php class prefix which is prepended to all php generated classes + * from this .proto. Default is empty. + */ + phpClassPrefix: string; + /** + * Use this option to change the namespace of php generated classes. Default + * is empty. When this option is empty, the package name will be used for + * determining the namespace. + */ + phpNamespace: string; + /** + * Use this option to change the namespace of php generated metadata classes. + * Default is empty. When this option is empty, the proto file name will be + * used for determining the namespace. + */ + phpMetadataNamespace: string; + /** + * Use this option to change the package of ruby generated classes. Default + * is empty. When this option is not set, the package name will be used for + * determining the ruby package. + */ + rubyPackage: string; + /** + * The parser stores options it doesn't recognize here. + * See the documentation for the "Options" section above. + */ + uninterpretedOption: UninterpretedOption[]; +} + +/** Generated classes can be optimized for speed or code size. */ +export enum FileOptions_OptimizeMode { + /** SPEED - Generate complete code for parsing, serialization, */ + SPEED = 1, + /** CODE_SIZE - etc. */ + CODE_SIZE = 2, + /** LITE_RUNTIME - Generate code using MessageLite and the lite runtime. */ + LITE_RUNTIME = 3, + UNRECOGNIZED = -1, +} + +export function fileOptions_OptimizeModeFromJSON( + object: any +): FileOptions_OptimizeMode { + switch (object) { + case 1: + case "SPEED": + return FileOptions_OptimizeMode.SPEED; + case 2: + case "CODE_SIZE": + return FileOptions_OptimizeMode.CODE_SIZE; + case 3: + case "LITE_RUNTIME": + return FileOptions_OptimizeMode.LITE_RUNTIME; + case -1: + case "UNRECOGNIZED": + default: + return FileOptions_OptimizeMode.UNRECOGNIZED; + } +} + +export function fileOptions_OptimizeModeToJSON( + object: FileOptions_OptimizeMode +): string { + switch (object) { + case FileOptions_OptimizeMode.SPEED: + return "SPEED"; + case FileOptions_OptimizeMode.CODE_SIZE: + return "CODE_SIZE"; + case FileOptions_OptimizeMode.LITE_RUNTIME: + return "LITE_RUNTIME"; + default: + return "UNKNOWN"; + } +} + +export interface MessageOptions { + /** + * Set true to use the old proto1 MessageSet wire format for extensions. + * This is provided for backwards-compatibility with the MessageSet wire + * format. You should not use this for any other reason: It's less + * efficient, has fewer features, and is more complicated. + * + * The message must be defined exactly as follows: + * message Foo { + * option message_set_wire_format = true; + * extensions 4 to max; + * } + * Note that the message cannot have any defined fields; MessageSets only + * have extensions. + * + * All extensions of your type must be singular messages; e.g. they cannot + * be int32s, enums, or repeated messages. + * + * Because this is an option, the above two restrictions are not enforced by + * the protocol compiler. + */ + messageSetWireFormat: boolean; + /** + * Disables the generation of the standard "descriptor()" accessor, which can + * conflict with a field of the same name. This is meant to make migration + * from proto1 easier; new code should avoid fields named "descriptor". + */ + noStandardDescriptorAccessor: boolean; + /** + * Is this message deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the message, or it will be completely ignored; in the very least, + * this is a formalization for deprecating messages. + */ + deprecated: boolean; + /** + * Whether the message is an automatically generated map entry type for the + * maps field. + * + * For maps fields: + * map map_field = 1; + * The parsed descriptor looks like: + * message MapFieldEntry { + * option map_entry = true; + * optional KeyType key = 1; + * optional ValueType value = 2; + * } + * repeated MapFieldEntry map_field = 1; + * + * Implementations may choose not to generate the map_entry=true message, but + * use a native map in the target language to hold the keys and values. + * The reflection APIs in such implementations still need to work as + * if the field is a repeated message field. + * + * NOTE: Do not set the option in .proto files. Always use the maps syntax + * instead. The option should only be implicitly set by the proto compiler + * parser. + */ + mapEntry: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface FieldOptions { + /** + * The ctype option instructs the C++ code generator to use a different + * representation of the field than it normally would. See the specific + * options below. This option is not yet implemented in the open source + * release -- sorry, we'll try to include it in a future version! + */ + ctype: FieldOptions_CType; + /** + * The packed option can be enabled for repeated primitive fields to enable + * a more efficient representation on the wire. Rather than repeatedly + * writing the tag and type for each element, the entire array is encoded as + * a single length-delimited blob. In proto3, only explicit setting it to + * false will avoid using packed encoding. + */ + packed: boolean; + /** + * The jstype option determines the JavaScript type used for values of the + * field. The option is permitted only for 64 bit integral and fixed types + * (int64, uint64, sint64, fixed64, sfixed64). A field with jstype JS_STRING + * is represented as JavaScript string, which avoids loss of precision that + * can happen when a large value is converted to a floating point JavaScript. + * Specifying JS_NUMBER for the jstype causes the generated JavaScript code to + * use the JavaScript "number" type. The behavior of the default option + * JS_NORMAL is implementation dependent. + * + * This option is an enum to permit additional types to be added, e.g. + * goog.math.Integer. + */ + jstype: FieldOptions_JSType; + /** + * Should this field be parsed lazily? Lazy applies only to message-type + * fields. It means that when the outer message is initially parsed, the + * inner message's contents will not be parsed but instead stored in encoded + * form. The inner message will actually be parsed when it is first accessed. + * + * This is only a hint. Implementations are free to choose whether to use + * eager or lazy parsing regardless of the value of this option. However, + * setting this option true suggests that the protocol author believes that + * using lazy parsing on this field is worth the additional bookkeeping + * overhead typically needed to implement it. + * + * This option does not affect the public interface of any generated code; + * all method signatures remain the same. Furthermore, thread-safety of the + * interface is not affected by this option; const methods remain safe to + * call from multiple threads concurrently, while non-const methods continue + * to require exclusive access. + * + * + * Note that implementations may choose not to check required fields within + * a lazy sub-message. That is, calling IsInitialized() on the outer message + * may return true even if the inner message has missing required fields. + * This is necessary because otherwise the inner message would have to be + * parsed in order to perform the check, defeating the purpose of lazy + * parsing. An implementation which chooses not to check required fields + * must be consistent about it. That is, for any particular sub-message, the + * implementation must either *always* check its required fields, or *never* + * check its required fields, regardless of whether or not the message has + * been parsed. + */ + lazy: boolean; + /** + * Is this field deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for accessors, or it will be completely ignored; in the very least, this + * is a formalization for deprecating fields. + */ + deprecated: boolean; + /** For Google-internal migration only. Do not use. */ + weak: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export enum FieldOptions_CType { + /** STRING - Default mode. */ + STRING = 0, + CORD = 1, + STRING_PIECE = 2, + UNRECOGNIZED = -1, +} + +export function fieldOptions_CTypeFromJSON(object: any): FieldOptions_CType { + switch (object) { + case 0: + case "STRING": + return FieldOptions_CType.STRING; + case 1: + case "CORD": + return FieldOptions_CType.CORD; + case 2: + case "STRING_PIECE": + return FieldOptions_CType.STRING_PIECE; + case -1: + case "UNRECOGNIZED": + default: + return FieldOptions_CType.UNRECOGNIZED; + } +} + +export function fieldOptions_CTypeToJSON(object: FieldOptions_CType): string { + switch (object) { + case FieldOptions_CType.STRING: + return "STRING"; + case FieldOptions_CType.CORD: + return "CORD"; + case FieldOptions_CType.STRING_PIECE: + return "STRING_PIECE"; + default: + return "UNKNOWN"; + } +} + +export enum FieldOptions_JSType { + /** JS_NORMAL - Use the default type. */ + JS_NORMAL = 0, + /** JS_STRING - Use JavaScript strings. */ + JS_STRING = 1, + /** JS_NUMBER - Use JavaScript numbers. */ + JS_NUMBER = 2, + UNRECOGNIZED = -1, +} + +export function fieldOptions_JSTypeFromJSON(object: any): FieldOptions_JSType { + switch (object) { + case 0: + case "JS_NORMAL": + return FieldOptions_JSType.JS_NORMAL; + case 1: + case "JS_STRING": + return FieldOptions_JSType.JS_STRING; + case 2: + case "JS_NUMBER": + return FieldOptions_JSType.JS_NUMBER; + case -1: + case "UNRECOGNIZED": + default: + return FieldOptions_JSType.UNRECOGNIZED; + } +} + +export function fieldOptions_JSTypeToJSON(object: FieldOptions_JSType): string { + switch (object) { + case FieldOptions_JSType.JS_NORMAL: + return "JS_NORMAL"; + case FieldOptions_JSType.JS_STRING: + return "JS_STRING"; + case FieldOptions_JSType.JS_NUMBER: + return "JS_NUMBER"; + default: + return "UNKNOWN"; + } +} + +export interface OneofOptions { + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface EnumOptions { + /** + * Set this option to true to allow mapping different tag names to the same + * value. + */ + allowAlias: boolean; + /** + * Is this enum deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the enum, or it will be completely ignored; in the very least, this + * is a formalization for deprecating enums. + */ + deprecated: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface EnumValueOptions { + /** + * Is this enum value deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the enum value, or it will be completely ignored; in the very least, + * this is a formalization for deprecating enum values. + */ + deprecated: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface ServiceOptions { + /** + * Is this service deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the service, or it will be completely ignored; in the very least, + * this is a formalization for deprecating services. + */ + deprecated: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface MethodOptions { + /** + * Is this method deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the method, or it will be completely ignored; in the very least, + * this is a formalization for deprecating methods. + */ + deprecated: boolean; + idempotencyLevel: MethodOptions_IdempotencyLevel; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +/** + * Is this method side-effect-free (or safe in HTTP parlance), or idempotent, + * or neither? HTTP based RPC implementation may choose GET verb for safe + * methods, and PUT verb for idempotent methods instead of the default POST. + */ +export enum MethodOptions_IdempotencyLevel { + IDEMPOTENCY_UNKNOWN = 0, + /** NO_SIDE_EFFECTS - implies idempotent */ + NO_SIDE_EFFECTS = 1, + /** IDEMPOTENT - idempotent, but may have side effects */ + IDEMPOTENT = 2, + UNRECOGNIZED = -1, +} + +export function methodOptions_IdempotencyLevelFromJSON( + object: any +): MethodOptions_IdempotencyLevel { + switch (object) { + case 0: + case "IDEMPOTENCY_UNKNOWN": + return MethodOptions_IdempotencyLevel.IDEMPOTENCY_UNKNOWN; + case 1: + case "NO_SIDE_EFFECTS": + return MethodOptions_IdempotencyLevel.NO_SIDE_EFFECTS; + case 2: + case "IDEMPOTENT": + return MethodOptions_IdempotencyLevel.IDEMPOTENT; + case -1: + case "UNRECOGNIZED": + default: + return MethodOptions_IdempotencyLevel.UNRECOGNIZED; + } +} + +export function methodOptions_IdempotencyLevelToJSON( + object: MethodOptions_IdempotencyLevel +): string { + switch (object) { + case MethodOptions_IdempotencyLevel.IDEMPOTENCY_UNKNOWN: + return "IDEMPOTENCY_UNKNOWN"; + case MethodOptions_IdempotencyLevel.NO_SIDE_EFFECTS: + return "NO_SIDE_EFFECTS"; + case MethodOptions_IdempotencyLevel.IDEMPOTENT: + return "IDEMPOTENT"; + default: + return "UNKNOWN"; + } +} + +/** + * A message representing a option the parser does not recognize. This only + * appears in options protos created by the compiler::Parser class. + * DescriptorPool resolves these when building Descriptor objects. Therefore, + * options protos in descriptor objects (e.g. returned by Descriptor::options(), + * or produced by Descriptor::CopyTo()) will never have UninterpretedOptions + * in them. + */ +export interface UninterpretedOption { + name: UninterpretedOption_NamePart[]; + /** + * The value of the uninterpreted option, in whatever type the tokenizer + * identified it as during parsing. Exactly one of these should be set. + */ + identifierValue: string; + positiveIntValue: number; + negativeIntValue: number; + doubleValue: number; + stringValue: Uint8Array; + aggregateValue: string; +} + +/** + * The name of the uninterpreted option. Each string represents a segment in + * a dot-separated name. is_extension is true iff a segment represents an + * extension (denoted with parentheses in options specs in .proto files). + * E.g.,{ ["foo", false], ["bar.baz", true], ["qux", false] } represents + * "foo.(bar.baz).qux". + */ +export interface UninterpretedOption_NamePart { + namePart: string; + isExtension: boolean; +} + +/** + * Encapsulates information about the original source file from which a + * FileDescriptorProto was generated. + */ +export interface SourceCodeInfo { + /** + * A Location identifies a piece of source code in a .proto file which + * corresponds to a particular definition. This information is intended + * to be useful to IDEs, code indexers, documentation generators, and similar + * tools. + * + * For example, say we have a file like: + * message Foo { + * optional string foo = 1; + * } + * Let's look at just the field definition: + * optional string foo = 1; + * ^ ^^ ^^ ^ ^^^ + * a bc de f ghi + * We have the following locations: + * span path represents + * [a,i) [ 4, 0, 2, 0 ] The whole field definition. + * [a,b) [ 4, 0, 2, 0, 4 ] The label (optional). + * [c,d) [ 4, 0, 2, 0, 5 ] The type (string). + * [e,f) [ 4, 0, 2, 0, 1 ] The name (foo). + * [g,h) [ 4, 0, 2, 0, 3 ] The number (1). + * + * Notes: + * - A location may refer to a repeated field itself (i.e. not to any + * particular index within it). This is used whenever a set of elements are + * logically enclosed in a single code segment. For example, an entire + * extend block (possibly containing multiple extension definitions) will + * have an outer location whose path refers to the "extensions" repeated + * field without an index. + * - Multiple locations may have the same path. This happens when a single + * logical declaration is spread out across multiple places. The most + * obvious example is the "extend" block again -- there may be multiple + * extend blocks in the same scope, each of which will have the same path. + * - A location's span is not always a subset of its parent's span. For + * example, the "extendee" of an extension declaration appears at the + * beginning of the "extend" block and is shared by all extensions within + * the block. + * - Just because a location's span is a subset of some other location's span + * does not mean that it is a descendant. For example, a "group" defines + * both a type and a field in a single declaration. Thus, the locations + * corresponding to the type and field and their components will overlap. + * - Code which tries to interpret locations should probably be designed to + * ignore those that it doesn't understand, as more types of locations could + * be recorded in the future. + */ + location: SourceCodeInfo_Location[]; +} + +export interface SourceCodeInfo_Location { + /** + * Identifies which part of the FileDescriptorProto was defined at this + * location. + * + * Each element is a field number or an index. They form a path from + * the root FileDescriptorProto to the place where the definition. For + * example, this path: + * [ 4, 3, 2, 7, 1 ] + * refers to: + * file.message_type(3) // 4, 3 + * .field(7) // 2, 7 + * .name() // 1 + * This is because FileDescriptorProto.message_type has field number 4: + * repeated DescriptorProto message_type = 4; + * and DescriptorProto.field has field number 2: + * repeated FieldDescriptorProto field = 2; + * and FieldDescriptorProto.name has field number 1: + * optional string name = 1; + * + * Thus, the above path gives the location of a field name. If we removed + * the last element: + * [ 4, 3, 2, 7 ] + * this path refers to the whole field declaration (from the beginning + * of the label to the terminating semicolon). + */ + path: number[]; + /** + * Always has exactly three or four elements: start line, start column, + * end line (optional, otherwise assumed same as start line), end column. + * These are packed into a single field for efficiency. Note that line + * and column numbers are zero-based -- typically you will want to add + * 1 to each before displaying to a user. + */ + span: number[]; + /** + * If this SourceCodeInfo represents a complete declaration, these are any + * comments appearing before and after the declaration which appear to be + * attached to the declaration. + * + * A series of line comments appearing on consecutive lines, with no other + * tokens appearing on those lines, will be treated as a single comment. + * + * leading_detached_comments will keep paragraphs of comments that appear + * before (but not connected to) the current element. Each paragraph, + * separated by empty lines, will be one comment element in the repeated + * field. + * + * Only the comment content is provided; comment markers (e.g. //) are + * stripped out. For block comments, leading whitespace and an asterisk + * will be stripped from the beginning of each line other than the first. + * Newlines are included in the output. + * + * Examples: + * + * optional int32 foo = 1; // Comment attached to foo. + * // Comment attached to bar. + * optional int32 bar = 2; + * + * optional string baz = 3; + * // Comment attached to baz. + * // Another line attached to baz. + * + * // Comment attached to qux. + * // + * // Another line attached to qux. + * optional double qux = 4; + * + * // Detached comment for corge. This is not leading or trailing comments + * // to qux or corge because there are blank lines separating it from + * // both. + * + * // Detached comment for corge paragraph 2. + * + * optional string corge = 5; + * /* Block comment attached + * * to corge. Leading asterisks + * * will be removed. * / + * /* Block comment attached to + * * grault. * / + * optional int32 grault = 6; + * + * // ignored detached comments. + */ + leadingComments: string; + trailingComments: string; + leadingDetachedComments: string[]; +} + +/** + * Describes the relationship between generated code and its original source + * file. A GeneratedCodeInfo message is associated with only one generated + * source file, but may contain references to different source .proto files. + */ +export interface GeneratedCodeInfo { + /** + * An Annotation connects some span of text in generated code to an element + * of its generating .proto file. + */ + annotation: GeneratedCodeInfo_Annotation[]; +} + +export interface GeneratedCodeInfo_Annotation { + /** + * Identifies the element in the original source .proto file. This field + * is formatted the same as SourceCodeInfo.Location.path. + */ + path: number[]; + /** Identifies the filesystem path to the original source .proto. */ + sourceFile: string; + /** + * Identifies the starting offset in bytes in the generated code + * that relates to the identified object. + */ + begin: number; + /** + * Identifies the ending offset in bytes in the generated code that + * relates to the identified offset. The end offset should be one past + * the last relevant byte (so the length of the text = end - begin). + */ + end: number; +} + +const baseFileDescriptorSet: object = {}; + +export const FileDescriptorSet = { + encode(message: FileDescriptorSet, writer: Writer = Writer.create()): Writer { + for (const v of message.file) { + FileDescriptorProto.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FileDescriptorSet { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFileDescriptorSet } as FileDescriptorSet; + message.file = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.file.push( + FileDescriptorProto.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FileDescriptorSet { + const message = { ...baseFileDescriptorSet } as FileDescriptorSet; + message.file = []; + if (object.file !== undefined && object.file !== null) { + for (const e of object.file) { + message.file.push(FileDescriptorProto.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: FileDescriptorSet): unknown { + const obj: any = {}; + if (message.file) { + obj.file = message.file.map((e) => + e ? FileDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.file = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): FileDescriptorSet { + const message = { ...baseFileDescriptorSet } as FileDescriptorSet; + message.file = []; + if (object.file !== undefined && object.file !== null) { + for (const e of object.file) { + message.file.push(FileDescriptorProto.fromPartial(e)); + } + } + return message; + }, +}; + +const baseFileDescriptorProto: object = { + name: "", + package: "", + dependency: "", + publicDependency: 0, + weakDependency: 0, + syntax: "", +}; + +export const FileDescriptorProto = { + encode( + message: FileDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.package !== "") { + writer.uint32(18).string(message.package); + } + for (const v of message.dependency) { + writer.uint32(26).string(v!); + } + writer.uint32(82).fork(); + for (const v of message.publicDependency) { + writer.int32(v); + } + writer.ldelim(); + writer.uint32(90).fork(); + for (const v of message.weakDependency) { + writer.int32(v); + } + writer.ldelim(); + for (const v of message.messageType) { + DescriptorProto.encode(v!, writer.uint32(34).fork()).ldelim(); + } + for (const v of message.enumType) { + EnumDescriptorProto.encode(v!, writer.uint32(42).fork()).ldelim(); + } + for (const v of message.service) { + ServiceDescriptorProto.encode(v!, writer.uint32(50).fork()).ldelim(); + } + for (const v of message.extension) { + FieldDescriptorProto.encode(v!, writer.uint32(58).fork()).ldelim(); + } + if (message.options !== undefined) { + FileOptions.encode(message.options, writer.uint32(66).fork()).ldelim(); + } + if (message.sourceCodeInfo !== undefined) { + SourceCodeInfo.encode( + message.sourceCodeInfo, + writer.uint32(74).fork() + ).ldelim(); + } + if (message.syntax !== "") { + writer.uint32(98).string(message.syntax); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FileDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFileDescriptorProto } as FileDescriptorProto; + message.dependency = []; + message.publicDependency = []; + message.weakDependency = []; + message.messageType = []; + message.enumType = []; + message.service = []; + message.extension = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.package = reader.string(); + break; + case 3: + message.dependency.push(reader.string()); + break; + case 10: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.publicDependency.push(reader.int32()); + } + } else { + message.publicDependency.push(reader.int32()); + } + break; + case 11: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.weakDependency.push(reader.int32()); + } + } else { + message.weakDependency.push(reader.int32()); + } + break; + case 4: + message.messageType.push( + DescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 5: + message.enumType.push( + EnumDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 6: + message.service.push( + ServiceDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 7: + message.extension.push( + FieldDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 8: + message.options = FileOptions.decode(reader, reader.uint32()); + break; + case 9: + message.sourceCodeInfo = SourceCodeInfo.decode( + reader, + reader.uint32() + ); + break; + case 12: + message.syntax = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FileDescriptorProto { + const message = { ...baseFileDescriptorProto } as FileDescriptorProto; + message.dependency = []; + message.publicDependency = []; + message.weakDependency = []; + message.messageType = []; + message.enumType = []; + message.service = []; + message.extension = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.package !== undefined && object.package !== null) { + message.package = String(object.package); + } else { + message.package = ""; + } + if (object.dependency !== undefined && object.dependency !== null) { + for (const e of object.dependency) { + message.dependency.push(String(e)); + } + } + if ( + object.publicDependency !== undefined && + object.publicDependency !== null + ) { + for (const e of object.publicDependency) { + message.publicDependency.push(Number(e)); + } + } + if (object.weakDependency !== undefined && object.weakDependency !== null) { + for (const e of object.weakDependency) { + message.weakDependency.push(Number(e)); + } + } + if (object.messageType !== undefined && object.messageType !== null) { + for (const e of object.messageType) { + message.messageType.push(DescriptorProto.fromJSON(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromJSON(e)); + } + } + if (object.service !== undefined && object.service !== null) { + for (const e of object.service) { + message.service.push(ServiceDescriptorProto.fromJSON(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = FileOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.sourceCodeInfo !== undefined && object.sourceCodeInfo !== null) { + message.sourceCodeInfo = SourceCodeInfo.fromJSON(object.sourceCodeInfo); + } else { + message.sourceCodeInfo = undefined; + } + if (object.syntax !== undefined && object.syntax !== null) { + message.syntax = String(object.syntax); + } else { + message.syntax = ""; + } + return message; + }, + + toJSON(message: FileDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.package !== undefined && (obj.package = message.package); + if (message.dependency) { + obj.dependency = message.dependency.map((e) => e); + } else { + obj.dependency = []; + } + if (message.publicDependency) { + obj.publicDependency = message.publicDependency.map((e) => e); + } else { + obj.publicDependency = []; + } + if (message.weakDependency) { + obj.weakDependency = message.weakDependency.map((e) => e); + } else { + obj.weakDependency = []; + } + if (message.messageType) { + obj.messageType = message.messageType.map((e) => + e ? DescriptorProto.toJSON(e) : undefined + ); + } else { + obj.messageType = []; + } + if (message.enumType) { + obj.enumType = message.enumType.map((e) => + e ? EnumDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.enumType = []; + } + if (message.service) { + obj.service = message.service.map((e) => + e ? ServiceDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.service = []; + } + if (message.extension) { + obj.extension = message.extension.map((e) => + e ? FieldDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.extension = []; + } + message.options !== undefined && + (obj.options = message.options + ? FileOptions.toJSON(message.options) + : undefined); + message.sourceCodeInfo !== undefined && + (obj.sourceCodeInfo = message.sourceCodeInfo + ? SourceCodeInfo.toJSON(message.sourceCodeInfo) + : undefined); + message.syntax !== undefined && (obj.syntax = message.syntax); + return obj; + }, + + fromPartial(object: DeepPartial): FileDescriptorProto { + const message = { ...baseFileDescriptorProto } as FileDescriptorProto; + message.dependency = []; + message.publicDependency = []; + message.weakDependency = []; + message.messageType = []; + message.enumType = []; + message.service = []; + message.extension = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.package !== undefined && object.package !== null) { + message.package = object.package; + } else { + message.package = ""; + } + if (object.dependency !== undefined && object.dependency !== null) { + for (const e of object.dependency) { + message.dependency.push(e); + } + } + if ( + object.publicDependency !== undefined && + object.publicDependency !== null + ) { + for (const e of object.publicDependency) { + message.publicDependency.push(e); + } + } + if (object.weakDependency !== undefined && object.weakDependency !== null) { + for (const e of object.weakDependency) { + message.weakDependency.push(e); + } + } + if (object.messageType !== undefined && object.messageType !== null) { + for (const e of object.messageType) { + message.messageType.push(DescriptorProto.fromPartial(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromPartial(e)); + } + } + if (object.service !== undefined && object.service !== null) { + for (const e of object.service) { + message.service.push(ServiceDescriptorProto.fromPartial(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = FileOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.sourceCodeInfo !== undefined && object.sourceCodeInfo !== null) { + message.sourceCodeInfo = SourceCodeInfo.fromPartial( + object.sourceCodeInfo + ); + } else { + message.sourceCodeInfo = undefined; + } + if (object.syntax !== undefined && object.syntax !== null) { + message.syntax = object.syntax; + } else { + message.syntax = ""; + } + return message; + }, +}; + +const baseDescriptorProto: object = { name: "", reservedName: "" }; + +export const DescriptorProto = { + encode(message: DescriptorProto, writer: Writer = Writer.create()): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + for (const v of message.field) { + FieldDescriptorProto.encode(v!, writer.uint32(18).fork()).ldelim(); + } + for (const v of message.extension) { + FieldDescriptorProto.encode(v!, writer.uint32(50).fork()).ldelim(); + } + for (const v of message.nestedType) { + DescriptorProto.encode(v!, writer.uint32(26).fork()).ldelim(); + } + for (const v of message.enumType) { + EnumDescriptorProto.encode(v!, writer.uint32(34).fork()).ldelim(); + } + for (const v of message.extensionRange) { + DescriptorProto_ExtensionRange.encode( + v!, + writer.uint32(42).fork() + ).ldelim(); + } + for (const v of message.oneofDecl) { + OneofDescriptorProto.encode(v!, writer.uint32(66).fork()).ldelim(); + } + if (message.options !== undefined) { + MessageOptions.encode(message.options, writer.uint32(58).fork()).ldelim(); + } + for (const v of message.reservedRange) { + DescriptorProto_ReservedRange.encode( + v!, + writer.uint32(74).fork() + ).ldelim(); + } + for (const v of message.reservedName) { + writer.uint32(82).string(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): DescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseDescriptorProto } as DescriptorProto; + message.field = []; + message.extension = []; + message.nestedType = []; + message.enumType = []; + message.extensionRange = []; + message.oneofDecl = []; + message.reservedRange = []; + message.reservedName = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.field.push( + FieldDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 6: + message.extension.push( + FieldDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 3: + message.nestedType.push( + DescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 4: + message.enumType.push( + EnumDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 5: + message.extensionRange.push( + DescriptorProto_ExtensionRange.decode(reader, reader.uint32()) + ); + break; + case 8: + message.oneofDecl.push( + OneofDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 7: + message.options = MessageOptions.decode(reader, reader.uint32()); + break; + case 9: + message.reservedRange.push( + DescriptorProto_ReservedRange.decode(reader, reader.uint32()) + ); + break; + case 10: + message.reservedName.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DescriptorProto { + const message = { ...baseDescriptorProto } as DescriptorProto; + message.field = []; + message.extension = []; + message.nestedType = []; + message.enumType = []; + message.extensionRange = []; + message.oneofDecl = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.field !== undefined && object.field !== null) { + for (const e of object.field) { + message.field.push(FieldDescriptorProto.fromJSON(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromJSON(e)); + } + } + if (object.nestedType !== undefined && object.nestedType !== null) { + for (const e of object.nestedType) { + message.nestedType.push(DescriptorProto.fromJSON(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromJSON(e)); + } + } + if (object.extensionRange !== undefined && object.extensionRange !== null) { + for (const e of object.extensionRange) { + message.extensionRange.push(DescriptorProto_ExtensionRange.fromJSON(e)); + } + } + if (object.oneofDecl !== undefined && object.oneofDecl !== null) { + for (const e of object.oneofDecl) { + message.oneofDecl.push(OneofDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = MessageOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push(DescriptorProto_ReservedRange.fromJSON(e)); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(String(e)); + } + } + return message; + }, + + toJSON(message: DescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + if (message.field) { + obj.field = message.field.map((e) => + e ? FieldDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.field = []; + } + if (message.extension) { + obj.extension = message.extension.map((e) => + e ? FieldDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.extension = []; + } + if (message.nestedType) { + obj.nestedType = message.nestedType.map((e) => + e ? DescriptorProto.toJSON(e) : undefined + ); + } else { + obj.nestedType = []; + } + if (message.enumType) { + obj.enumType = message.enumType.map((e) => + e ? EnumDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.enumType = []; + } + if (message.extensionRange) { + obj.extensionRange = message.extensionRange.map((e) => + e ? DescriptorProto_ExtensionRange.toJSON(e) : undefined + ); + } else { + obj.extensionRange = []; + } + if (message.oneofDecl) { + obj.oneofDecl = message.oneofDecl.map((e) => + e ? OneofDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.oneofDecl = []; + } + message.options !== undefined && + (obj.options = message.options + ? MessageOptions.toJSON(message.options) + : undefined); + if (message.reservedRange) { + obj.reservedRange = message.reservedRange.map((e) => + e ? DescriptorProto_ReservedRange.toJSON(e) : undefined + ); + } else { + obj.reservedRange = []; + } + if (message.reservedName) { + obj.reservedName = message.reservedName.map((e) => e); + } else { + obj.reservedName = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): DescriptorProto { + const message = { ...baseDescriptorProto } as DescriptorProto; + message.field = []; + message.extension = []; + message.nestedType = []; + message.enumType = []; + message.extensionRange = []; + message.oneofDecl = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.field !== undefined && object.field !== null) { + for (const e of object.field) { + message.field.push(FieldDescriptorProto.fromPartial(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromPartial(e)); + } + } + if (object.nestedType !== undefined && object.nestedType !== null) { + for (const e of object.nestedType) { + message.nestedType.push(DescriptorProto.fromPartial(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromPartial(e)); + } + } + if (object.extensionRange !== undefined && object.extensionRange !== null) { + for (const e of object.extensionRange) { + message.extensionRange.push( + DescriptorProto_ExtensionRange.fromPartial(e) + ); + } + } + if (object.oneofDecl !== undefined && object.oneofDecl !== null) { + for (const e of object.oneofDecl) { + message.oneofDecl.push(OneofDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = MessageOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push( + DescriptorProto_ReservedRange.fromPartial(e) + ); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(e); + } + } + return message; + }, +}; + +const baseDescriptorProto_ExtensionRange: object = { start: 0, end: 0 }; + +export const DescriptorProto_ExtensionRange = { + encode( + message: DescriptorProto_ExtensionRange, + writer: Writer = Writer.create() + ): Writer { + if (message.start !== 0) { + writer.uint32(8).int32(message.start); + } + if (message.end !== 0) { + writer.uint32(16).int32(message.end); + } + if (message.options !== undefined) { + ExtensionRangeOptions.encode( + message.options, + writer.uint32(26).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): DescriptorProto_ExtensionRange { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseDescriptorProto_ExtensionRange, + } as DescriptorProto_ExtensionRange; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.start = reader.int32(); + break; + case 2: + message.end = reader.int32(); + break; + case 3: + message.options = ExtensionRangeOptions.decode( + reader, + reader.uint32() + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DescriptorProto_ExtensionRange { + const message = { + ...baseDescriptorProto_ExtensionRange, + } as DescriptorProto_ExtensionRange; + if (object.start !== undefined && object.start !== null) { + message.start = Number(object.start); + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = ExtensionRangeOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: DescriptorProto_ExtensionRange): unknown { + const obj: any = {}; + message.start !== undefined && (obj.start = message.start); + message.end !== undefined && (obj.end = message.end); + message.options !== undefined && + (obj.options = message.options + ? ExtensionRangeOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): DescriptorProto_ExtensionRange { + const message = { + ...baseDescriptorProto_ExtensionRange, + } as DescriptorProto_ExtensionRange; + if (object.start !== undefined && object.start !== null) { + message.start = object.start; + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = ExtensionRangeOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseDescriptorProto_ReservedRange: object = { start: 0, end: 0 }; + +export const DescriptorProto_ReservedRange = { + encode( + message: DescriptorProto_ReservedRange, + writer: Writer = Writer.create() + ): Writer { + if (message.start !== 0) { + writer.uint32(8).int32(message.start); + } + if (message.end !== 0) { + writer.uint32(16).int32(message.end); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): DescriptorProto_ReservedRange { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseDescriptorProto_ReservedRange, + } as DescriptorProto_ReservedRange; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.start = reader.int32(); + break; + case 2: + message.end = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DescriptorProto_ReservedRange { + const message = { + ...baseDescriptorProto_ReservedRange, + } as DescriptorProto_ReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = Number(object.start); + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + return message; + }, + + toJSON(message: DescriptorProto_ReservedRange): unknown { + const obj: any = {}; + message.start !== undefined && (obj.start = message.start); + message.end !== undefined && (obj.end = message.end); + return obj; + }, + + fromPartial( + object: DeepPartial + ): DescriptorProto_ReservedRange { + const message = { + ...baseDescriptorProto_ReservedRange, + } as DescriptorProto_ReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = object.start; + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + return message; + }, +}; + +const baseExtensionRangeOptions: object = {}; + +export const ExtensionRangeOptions = { + encode( + message: ExtensionRangeOptions, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ExtensionRangeOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseExtensionRangeOptions } as ExtensionRangeOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ExtensionRangeOptions { + const message = { ...baseExtensionRangeOptions } as ExtensionRangeOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: ExtensionRangeOptions): unknown { + const obj: any = {}; + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial( + object: DeepPartial + ): ExtensionRangeOptions { + const message = { ...baseExtensionRangeOptions } as ExtensionRangeOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseFieldDescriptorProto: object = { + name: "", + number: 0, + label: 1, + type: 1, + typeName: "", + extendee: "", + defaultValue: "", + oneofIndex: 0, + jsonName: "", + proto3Optional: false, +}; + +export const FieldDescriptorProto = { + encode( + message: FieldDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.number !== 0) { + writer.uint32(24).int32(message.number); + } + if (message.label !== 1) { + writer.uint32(32).int32(message.label); + } + if (message.type !== 1) { + writer.uint32(40).int32(message.type); + } + if (message.typeName !== "") { + writer.uint32(50).string(message.typeName); + } + if (message.extendee !== "") { + writer.uint32(18).string(message.extendee); + } + if (message.defaultValue !== "") { + writer.uint32(58).string(message.defaultValue); + } + if (message.oneofIndex !== 0) { + writer.uint32(72).int32(message.oneofIndex); + } + if (message.jsonName !== "") { + writer.uint32(82).string(message.jsonName); + } + if (message.options !== undefined) { + FieldOptions.encode(message.options, writer.uint32(66).fork()).ldelim(); + } + if (message.proto3Optional === true) { + writer.uint32(136).bool(message.proto3Optional); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FieldDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFieldDescriptorProto } as FieldDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 3: + message.number = reader.int32(); + break; + case 4: + message.label = reader.int32() as any; + break; + case 5: + message.type = reader.int32() as any; + break; + case 6: + message.typeName = reader.string(); + break; + case 2: + message.extendee = reader.string(); + break; + case 7: + message.defaultValue = reader.string(); + break; + case 9: + message.oneofIndex = reader.int32(); + break; + case 10: + message.jsonName = reader.string(); + break; + case 8: + message.options = FieldOptions.decode(reader, reader.uint32()); + break; + case 17: + message.proto3Optional = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FieldDescriptorProto { + const message = { ...baseFieldDescriptorProto } as FieldDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = Number(object.number); + } else { + message.number = 0; + } + if (object.label !== undefined && object.label !== null) { + message.label = fieldDescriptorProto_LabelFromJSON(object.label); + } else { + message.label = 1; + } + if (object.type !== undefined && object.type !== null) { + message.type = fieldDescriptorProto_TypeFromJSON(object.type); + } else { + message.type = 1; + } + if (object.typeName !== undefined && object.typeName !== null) { + message.typeName = String(object.typeName); + } else { + message.typeName = ""; + } + if (object.extendee !== undefined && object.extendee !== null) { + message.extendee = String(object.extendee); + } else { + message.extendee = ""; + } + if (object.defaultValue !== undefined && object.defaultValue !== null) { + message.defaultValue = String(object.defaultValue); + } else { + message.defaultValue = ""; + } + if (object.oneofIndex !== undefined && object.oneofIndex !== null) { + message.oneofIndex = Number(object.oneofIndex); + } else { + message.oneofIndex = 0; + } + if (object.jsonName !== undefined && object.jsonName !== null) { + message.jsonName = String(object.jsonName); + } else { + message.jsonName = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = FieldOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.proto3Optional !== undefined && object.proto3Optional !== null) { + message.proto3Optional = Boolean(object.proto3Optional); + } else { + message.proto3Optional = false; + } + return message; + }, + + toJSON(message: FieldDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.number !== undefined && (obj.number = message.number); + message.label !== undefined && + (obj.label = fieldDescriptorProto_LabelToJSON(message.label)); + message.type !== undefined && + (obj.type = fieldDescriptorProto_TypeToJSON(message.type)); + message.typeName !== undefined && (obj.typeName = message.typeName); + message.extendee !== undefined && (obj.extendee = message.extendee); + message.defaultValue !== undefined && + (obj.defaultValue = message.defaultValue); + message.oneofIndex !== undefined && (obj.oneofIndex = message.oneofIndex); + message.jsonName !== undefined && (obj.jsonName = message.jsonName); + message.options !== undefined && + (obj.options = message.options + ? FieldOptions.toJSON(message.options) + : undefined); + message.proto3Optional !== undefined && + (obj.proto3Optional = message.proto3Optional); + return obj; + }, + + fromPartial(object: DeepPartial): FieldDescriptorProto { + const message = { ...baseFieldDescriptorProto } as FieldDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = object.number; + } else { + message.number = 0; + } + if (object.label !== undefined && object.label !== null) { + message.label = object.label; + } else { + message.label = 1; + } + if (object.type !== undefined && object.type !== null) { + message.type = object.type; + } else { + message.type = 1; + } + if (object.typeName !== undefined && object.typeName !== null) { + message.typeName = object.typeName; + } else { + message.typeName = ""; + } + if (object.extendee !== undefined && object.extendee !== null) { + message.extendee = object.extendee; + } else { + message.extendee = ""; + } + if (object.defaultValue !== undefined && object.defaultValue !== null) { + message.defaultValue = object.defaultValue; + } else { + message.defaultValue = ""; + } + if (object.oneofIndex !== undefined && object.oneofIndex !== null) { + message.oneofIndex = object.oneofIndex; + } else { + message.oneofIndex = 0; + } + if (object.jsonName !== undefined && object.jsonName !== null) { + message.jsonName = object.jsonName; + } else { + message.jsonName = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = FieldOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.proto3Optional !== undefined && object.proto3Optional !== null) { + message.proto3Optional = object.proto3Optional; + } else { + message.proto3Optional = false; + } + return message; + }, +}; + +const baseOneofDescriptorProto: object = { name: "" }; + +export const OneofDescriptorProto = { + encode( + message: OneofDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.options !== undefined) { + OneofOptions.encode(message.options, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): OneofDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseOneofDescriptorProto } as OneofDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.options = OneofOptions.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): OneofDescriptorProto { + const message = { ...baseOneofDescriptorProto } as OneofDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = OneofOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: OneofDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.options !== undefined && + (obj.options = message.options + ? OneofOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): OneofDescriptorProto { + const message = { ...baseOneofDescriptorProto } as OneofDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = OneofOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseEnumDescriptorProto: object = { name: "", reservedName: "" }; + +export const EnumDescriptorProto = { + encode( + message: EnumDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + for (const v of message.value) { + EnumValueDescriptorProto.encode(v!, writer.uint32(18).fork()).ldelim(); + } + if (message.options !== undefined) { + EnumOptions.encode(message.options, writer.uint32(26).fork()).ldelim(); + } + for (const v of message.reservedRange) { + EnumDescriptorProto_EnumReservedRange.encode( + v!, + writer.uint32(34).fork() + ).ldelim(); + } + for (const v of message.reservedName) { + writer.uint32(42).string(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): EnumDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseEnumDescriptorProto } as EnumDescriptorProto; + message.value = []; + message.reservedRange = []; + message.reservedName = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.value.push( + EnumValueDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 3: + message.options = EnumOptions.decode(reader, reader.uint32()); + break; + case 4: + message.reservedRange.push( + EnumDescriptorProto_EnumReservedRange.decode( + reader, + reader.uint32() + ) + ); + break; + case 5: + message.reservedName.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumDescriptorProto { + const message = { ...baseEnumDescriptorProto } as EnumDescriptorProto; + message.value = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.value !== undefined && object.value !== null) { + for (const e of object.value) { + message.value.push(EnumValueDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push( + EnumDescriptorProto_EnumReservedRange.fromJSON(e) + ); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(String(e)); + } + } + return message; + }, + + toJSON(message: EnumDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + if (message.value) { + obj.value = message.value.map((e) => + e ? EnumValueDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.value = []; + } + message.options !== undefined && + (obj.options = message.options + ? EnumOptions.toJSON(message.options) + : undefined); + if (message.reservedRange) { + obj.reservedRange = message.reservedRange.map((e) => + e ? EnumDescriptorProto_EnumReservedRange.toJSON(e) : undefined + ); + } else { + obj.reservedRange = []; + } + if (message.reservedName) { + obj.reservedName = message.reservedName.map((e) => e); + } else { + obj.reservedName = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): EnumDescriptorProto { + const message = { ...baseEnumDescriptorProto } as EnumDescriptorProto; + message.value = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.value !== undefined && object.value !== null) { + for (const e of object.value) { + message.value.push(EnumValueDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push( + EnumDescriptorProto_EnumReservedRange.fromPartial(e) + ); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(e); + } + } + return message; + }, +}; + +const baseEnumDescriptorProto_EnumReservedRange: object = { start: 0, end: 0 }; + +export const EnumDescriptorProto_EnumReservedRange = { + encode( + message: EnumDescriptorProto_EnumReservedRange, + writer: Writer = Writer.create() + ): Writer { + if (message.start !== 0) { + writer.uint32(8).int32(message.start); + } + if (message.end !== 0) { + writer.uint32(16).int32(message.end); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): EnumDescriptorProto_EnumReservedRange { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseEnumDescriptorProto_EnumReservedRange, + } as EnumDescriptorProto_EnumReservedRange; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.start = reader.int32(); + break; + case 2: + message.end = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumDescriptorProto_EnumReservedRange { + const message = { + ...baseEnumDescriptorProto_EnumReservedRange, + } as EnumDescriptorProto_EnumReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = Number(object.start); + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + return message; + }, + + toJSON(message: EnumDescriptorProto_EnumReservedRange): unknown { + const obj: any = {}; + message.start !== undefined && (obj.start = message.start); + message.end !== undefined && (obj.end = message.end); + return obj; + }, + + fromPartial( + object: DeepPartial + ): EnumDescriptorProto_EnumReservedRange { + const message = { + ...baseEnumDescriptorProto_EnumReservedRange, + } as EnumDescriptorProto_EnumReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = object.start; + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + return message; + }, +}; + +const baseEnumValueDescriptorProto: object = { name: "", number: 0 }; + +export const EnumValueDescriptorProto = { + encode( + message: EnumValueDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.number !== 0) { + writer.uint32(16).int32(message.number); + } + if (message.options !== undefined) { + EnumValueOptions.encode( + message.options, + writer.uint32(26).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): EnumValueDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseEnumValueDescriptorProto, + } as EnumValueDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.number = reader.int32(); + break; + case 3: + message.options = EnumValueOptions.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumValueDescriptorProto { + const message = { + ...baseEnumValueDescriptorProto, + } as EnumValueDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = Number(object.number); + } else { + message.number = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumValueOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: EnumValueDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.number !== undefined && (obj.number = message.number); + message.options !== undefined && + (obj.options = message.options + ? EnumValueOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): EnumValueDescriptorProto { + const message = { + ...baseEnumValueDescriptorProto, + } as EnumValueDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = object.number; + } else { + message.number = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumValueOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseServiceDescriptorProto: object = { name: "" }; + +export const ServiceDescriptorProto = { + encode( + message: ServiceDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + for (const v of message.method) { + MethodDescriptorProto.encode(v!, writer.uint32(18).fork()).ldelim(); + } + if (message.options !== undefined) { + ServiceOptions.encode(message.options, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ServiceDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseServiceDescriptorProto } as ServiceDescriptorProto; + message.method = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.method.push( + MethodDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 3: + message.options = ServiceOptions.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ServiceDescriptorProto { + const message = { ...baseServiceDescriptorProto } as ServiceDescriptorProto; + message.method = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.method !== undefined && object.method !== null) { + for (const e of object.method) { + message.method.push(MethodDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = ServiceOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: ServiceDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + if (message.method) { + obj.method = message.method.map((e) => + e ? MethodDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.method = []; + } + message.options !== undefined && + (obj.options = message.options + ? ServiceOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): ServiceDescriptorProto { + const message = { ...baseServiceDescriptorProto } as ServiceDescriptorProto; + message.method = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.method !== undefined && object.method !== null) { + for (const e of object.method) { + message.method.push(MethodDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = ServiceOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseMethodDescriptorProto: object = { + name: "", + inputType: "", + outputType: "", + clientStreaming: false, + serverStreaming: false, +}; + +export const MethodDescriptorProto = { + encode( + message: MethodDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.inputType !== "") { + writer.uint32(18).string(message.inputType); + } + if (message.outputType !== "") { + writer.uint32(26).string(message.outputType); + } + if (message.options !== undefined) { + MethodOptions.encode(message.options, writer.uint32(34).fork()).ldelim(); + } + if (message.clientStreaming === true) { + writer.uint32(40).bool(message.clientStreaming); + } + if (message.serverStreaming === true) { + writer.uint32(48).bool(message.serverStreaming); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MethodDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMethodDescriptorProto } as MethodDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.inputType = reader.string(); + break; + case 3: + message.outputType = reader.string(); + break; + case 4: + message.options = MethodOptions.decode(reader, reader.uint32()); + break; + case 5: + message.clientStreaming = reader.bool(); + break; + case 6: + message.serverStreaming = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MethodDescriptorProto { + const message = { ...baseMethodDescriptorProto } as MethodDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.inputType !== undefined && object.inputType !== null) { + message.inputType = String(object.inputType); + } else { + message.inputType = ""; + } + if (object.outputType !== undefined && object.outputType !== null) { + message.outputType = String(object.outputType); + } else { + message.outputType = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = MethodOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if ( + object.clientStreaming !== undefined && + object.clientStreaming !== null + ) { + message.clientStreaming = Boolean(object.clientStreaming); + } else { + message.clientStreaming = false; + } + if ( + object.serverStreaming !== undefined && + object.serverStreaming !== null + ) { + message.serverStreaming = Boolean(object.serverStreaming); + } else { + message.serverStreaming = false; + } + return message; + }, + + toJSON(message: MethodDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.inputType !== undefined && (obj.inputType = message.inputType); + message.outputType !== undefined && (obj.outputType = message.outputType); + message.options !== undefined && + (obj.options = message.options + ? MethodOptions.toJSON(message.options) + : undefined); + message.clientStreaming !== undefined && + (obj.clientStreaming = message.clientStreaming); + message.serverStreaming !== undefined && + (obj.serverStreaming = message.serverStreaming); + return obj; + }, + + fromPartial( + object: DeepPartial + ): MethodDescriptorProto { + const message = { ...baseMethodDescriptorProto } as MethodDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.inputType !== undefined && object.inputType !== null) { + message.inputType = object.inputType; + } else { + message.inputType = ""; + } + if (object.outputType !== undefined && object.outputType !== null) { + message.outputType = object.outputType; + } else { + message.outputType = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = MethodOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if ( + object.clientStreaming !== undefined && + object.clientStreaming !== null + ) { + message.clientStreaming = object.clientStreaming; + } else { + message.clientStreaming = false; + } + if ( + object.serverStreaming !== undefined && + object.serverStreaming !== null + ) { + message.serverStreaming = object.serverStreaming; + } else { + message.serverStreaming = false; + } + return message; + }, +}; + +const baseFileOptions: object = { + javaPackage: "", + javaOuterClassname: "", + javaMultipleFiles: false, + javaGenerateEqualsAndHash: false, + javaStringCheckUtf8: false, + optimizeFor: 1, + goPackage: "", + ccGenericServices: false, + javaGenericServices: false, + pyGenericServices: false, + phpGenericServices: false, + deprecated: false, + ccEnableArenas: false, + objcClassPrefix: "", + csharpNamespace: "", + swiftPrefix: "", + phpClassPrefix: "", + phpNamespace: "", + phpMetadataNamespace: "", + rubyPackage: "", +}; + +export const FileOptions = { + encode(message: FileOptions, writer: Writer = Writer.create()): Writer { + if (message.javaPackage !== "") { + writer.uint32(10).string(message.javaPackage); + } + if (message.javaOuterClassname !== "") { + writer.uint32(66).string(message.javaOuterClassname); + } + if (message.javaMultipleFiles === true) { + writer.uint32(80).bool(message.javaMultipleFiles); + } + if (message.javaGenerateEqualsAndHash === true) { + writer.uint32(160).bool(message.javaGenerateEqualsAndHash); + } + if (message.javaStringCheckUtf8 === true) { + writer.uint32(216).bool(message.javaStringCheckUtf8); + } + if (message.optimizeFor !== 1) { + writer.uint32(72).int32(message.optimizeFor); + } + if (message.goPackage !== "") { + writer.uint32(90).string(message.goPackage); + } + if (message.ccGenericServices === true) { + writer.uint32(128).bool(message.ccGenericServices); + } + if (message.javaGenericServices === true) { + writer.uint32(136).bool(message.javaGenericServices); + } + if (message.pyGenericServices === true) { + writer.uint32(144).bool(message.pyGenericServices); + } + if (message.phpGenericServices === true) { + writer.uint32(336).bool(message.phpGenericServices); + } + if (message.deprecated === true) { + writer.uint32(184).bool(message.deprecated); + } + if (message.ccEnableArenas === true) { + writer.uint32(248).bool(message.ccEnableArenas); + } + if (message.objcClassPrefix !== "") { + writer.uint32(290).string(message.objcClassPrefix); + } + if (message.csharpNamespace !== "") { + writer.uint32(298).string(message.csharpNamespace); + } + if (message.swiftPrefix !== "") { + writer.uint32(314).string(message.swiftPrefix); + } + if (message.phpClassPrefix !== "") { + writer.uint32(322).string(message.phpClassPrefix); + } + if (message.phpNamespace !== "") { + writer.uint32(330).string(message.phpNamespace); + } + if (message.phpMetadataNamespace !== "") { + writer.uint32(354).string(message.phpMetadataNamespace); + } + if (message.rubyPackage !== "") { + writer.uint32(362).string(message.rubyPackage); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FileOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFileOptions } as FileOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.javaPackage = reader.string(); + break; + case 8: + message.javaOuterClassname = reader.string(); + break; + case 10: + message.javaMultipleFiles = reader.bool(); + break; + case 20: + message.javaGenerateEqualsAndHash = reader.bool(); + break; + case 27: + message.javaStringCheckUtf8 = reader.bool(); + break; + case 9: + message.optimizeFor = reader.int32() as any; + break; + case 11: + message.goPackage = reader.string(); + break; + case 16: + message.ccGenericServices = reader.bool(); + break; + case 17: + message.javaGenericServices = reader.bool(); + break; + case 18: + message.pyGenericServices = reader.bool(); + break; + case 42: + message.phpGenericServices = reader.bool(); + break; + case 23: + message.deprecated = reader.bool(); + break; + case 31: + message.ccEnableArenas = reader.bool(); + break; + case 36: + message.objcClassPrefix = reader.string(); + break; + case 37: + message.csharpNamespace = reader.string(); + break; + case 39: + message.swiftPrefix = reader.string(); + break; + case 40: + message.phpClassPrefix = reader.string(); + break; + case 41: + message.phpNamespace = reader.string(); + break; + case 44: + message.phpMetadataNamespace = reader.string(); + break; + case 45: + message.rubyPackage = reader.string(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FileOptions { + const message = { ...baseFileOptions } as FileOptions; + message.uninterpretedOption = []; + if (object.javaPackage !== undefined && object.javaPackage !== null) { + message.javaPackage = String(object.javaPackage); + } else { + message.javaPackage = ""; + } + if ( + object.javaOuterClassname !== undefined && + object.javaOuterClassname !== null + ) { + message.javaOuterClassname = String(object.javaOuterClassname); + } else { + message.javaOuterClassname = ""; + } + if ( + object.javaMultipleFiles !== undefined && + object.javaMultipleFiles !== null + ) { + message.javaMultipleFiles = Boolean(object.javaMultipleFiles); + } else { + message.javaMultipleFiles = false; + } + if ( + object.javaGenerateEqualsAndHash !== undefined && + object.javaGenerateEqualsAndHash !== null + ) { + message.javaGenerateEqualsAndHash = Boolean( + object.javaGenerateEqualsAndHash + ); + } else { + message.javaGenerateEqualsAndHash = false; + } + if ( + object.javaStringCheckUtf8 !== undefined && + object.javaStringCheckUtf8 !== null + ) { + message.javaStringCheckUtf8 = Boolean(object.javaStringCheckUtf8); + } else { + message.javaStringCheckUtf8 = false; + } + if (object.optimizeFor !== undefined && object.optimizeFor !== null) { + message.optimizeFor = fileOptions_OptimizeModeFromJSON( + object.optimizeFor + ); + } else { + message.optimizeFor = 1; + } + if (object.goPackage !== undefined && object.goPackage !== null) { + message.goPackage = String(object.goPackage); + } else { + message.goPackage = ""; + } + if ( + object.ccGenericServices !== undefined && + object.ccGenericServices !== null + ) { + message.ccGenericServices = Boolean(object.ccGenericServices); + } else { + message.ccGenericServices = false; + } + if ( + object.javaGenericServices !== undefined && + object.javaGenericServices !== null + ) { + message.javaGenericServices = Boolean(object.javaGenericServices); + } else { + message.javaGenericServices = false; + } + if ( + object.pyGenericServices !== undefined && + object.pyGenericServices !== null + ) { + message.pyGenericServices = Boolean(object.pyGenericServices); + } else { + message.pyGenericServices = false; + } + if ( + object.phpGenericServices !== undefined && + object.phpGenericServices !== null + ) { + message.phpGenericServices = Boolean(object.phpGenericServices); + } else { + message.phpGenericServices = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if (object.ccEnableArenas !== undefined && object.ccEnableArenas !== null) { + message.ccEnableArenas = Boolean(object.ccEnableArenas); + } else { + message.ccEnableArenas = false; + } + if ( + object.objcClassPrefix !== undefined && + object.objcClassPrefix !== null + ) { + message.objcClassPrefix = String(object.objcClassPrefix); + } else { + message.objcClassPrefix = ""; + } + if ( + object.csharpNamespace !== undefined && + object.csharpNamespace !== null + ) { + message.csharpNamespace = String(object.csharpNamespace); + } else { + message.csharpNamespace = ""; + } + if (object.swiftPrefix !== undefined && object.swiftPrefix !== null) { + message.swiftPrefix = String(object.swiftPrefix); + } else { + message.swiftPrefix = ""; + } + if (object.phpClassPrefix !== undefined && object.phpClassPrefix !== null) { + message.phpClassPrefix = String(object.phpClassPrefix); + } else { + message.phpClassPrefix = ""; + } + if (object.phpNamespace !== undefined && object.phpNamespace !== null) { + message.phpNamespace = String(object.phpNamespace); + } else { + message.phpNamespace = ""; + } + if ( + object.phpMetadataNamespace !== undefined && + object.phpMetadataNamespace !== null + ) { + message.phpMetadataNamespace = String(object.phpMetadataNamespace); + } else { + message.phpMetadataNamespace = ""; + } + if (object.rubyPackage !== undefined && object.rubyPackage !== null) { + message.rubyPackage = String(object.rubyPackage); + } else { + message.rubyPackage = ""; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: FileOptions): unknown { + const obj: any = {}; + message.javaPackage !== undefined && + (obj.javaPackage = message.javaPackage); + message.javaOuterClassname !== undefined && + (obj.javaOuterClassname = message.javaOuterClassname); + message.javaMultipleFiles !== undefined && + (obj.javaMultipleFiles = message.javaMultipleFiles); + message.javaGenerateEqualsAndHash !== undefined && + (obj.javaGenerateEqualsAndHash = message.javaGenerateEqualsAndHash); + message.javaStringCheckUtf8 !== undefined && + (obj.javaStringCheckUtf8 = message.javaStringCheckUtf8); + message.optimizeFor !== undefined && + (obj.optimizeFor = fileOptions_OptimizeModeToJSON(message.optimizeFor)); + message.goPackage !== undefined && (obj.goPackage = message.goPackage); + message.ccGenericServices !== undefined && + (obj.ccGenericServices = message.ccGenericServices); + message.javaGenericServices !== undefined && + (obj.javaGenericServices = message.javaGenericServices); + message.pyGenericServices !== undefined && + (obj.pyGenericServices = message.pyGenericServices); + message.phpGenericServices !== undefined && + (obj.phpGenericServices = message.phpGenericServices); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.ccEnableArenas !== undefined && + (obj.ccEnableArenas = message.ccEnableArenas); + message.objcClassPrefix !== undefined && + (obj.objcClassPrefix = message.objcClassPrefix); + message.csharpNamespace !== undefined && + (obj.csharpNamespace = message.csharpNamespace); + message.swiftPrefix !== undefined && + (obj.swiftPrefix = message.swiftPrefix); + message.phpClassPrefix !== undefined && + (obj.phpClassPrefix = message.phpClassPrefix); + message.phpNamespace !== undefined && + (obj.phpNamespace = message.phpNamespace); + message.phpMetadataNamespace !== undefined && + (obj.phpMetadataNamespace = message.phpMetadataNamespace); + message.rubyPackage !== undefined && + (obj.rubyPackage = message.rubyPackage); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): FileOptions { + const message = { ...baseFileOptions } as FileOptions; + message.uninterpretedOption = []; + if (object.javaPackage !== undefined && object.javaPackage !== null) { + message.javaPackage = object.javaPackage; + } else { + message.javaPackage = ""; + } + if ( + object.javaOuterClassname !== undefined && + object.javaOuterClassname !== null + ) { + message.javaOuterClassname = object.javaOuterClassname; + } else { + message.javaOuterClassname = ""; + } + if ( + object.javaMultipleFiles !== undefined && + object.javaMultipleFiles !== null + ) { + message.javaMultipleFiles = object.javaMultipleFiles; + } else { + message.javaMultipleFiles = false; + } + if ( + object.javaGenerateEqualsAndHash !== undefined && + object.javaGenerateEqualsAndHash !== null + ) { + message.javaGenerateEqualsAndHash = object.javaGenerateEqualsAndHash; + } else { + message.javaGenerateEqualsAndHash = false; + } + if ( + object.javaStringCheckUtf8 !== undefined && + object.javaStringCheckUtf8 !== null + ) { + message.javaStringCheckUtf8 = object.javaStringCheckUtf8; + } else { + message.javaStringCheckUtf8 = false; + } + if (object.optimizeFor !== undefined && object.optimizeFor !== null) { + message.optimizeFor = object.optimizeFor; + } else { + message.optimizeFor = 1; + } + if (object.goPackage !== undefined && object.goPackage !== null) { + message.goPackage = object.goPackage; + } else { + message.goPackage = ""; + } + if ( + object.ccGenericServices !== undefined && + object.ccGenericServices !== null + ) { + message.ccGenericServices = object.ccGenericServices; + } else { + message.ccGenericServices = false; + } + if ( + object.javaGenericServices !== undefined && + object.javaGenericServices !== null + ) { + message.javaGenericServices = object.javaGenericServices; + } else { + message.javaGenericServices = false; + } + if ( + object.pyGenericServices !== undefined && + object.pyGenericServices !== null + ) { + message.pyGenericServices = object.pyGenericServices; + } else { + message.pyGenericServices = false; + } + if ( + object.phpGenericServices !== undefined && + object.phpGenericServices !== null + ) { + message.phpGenericServices = object.phpGenericServices; + } else { + message.phpGenericServices = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if (object.ccEnableArenas !== undefined && object.ccEnableArenas !== null) { + message.ccEnableArenas = object.ccEnableArenas; + } else { + message.ccEnableArenas = false; + } + if ( + object.objcClassPrefix !== undefined && + object.objcClassPrefix !== null + ) { + message.objcClassPrefix = object.objcClassPrefix; + } else { + message.objcClassPrefix = ""; + } + if ( + object.csharpNamespace !== undefined && + object.csharpNamespace !== null + ) { + message.csharpNamespace = object.csharpNamespace; + } else { + message.csharpNamespace = ""; + } + if (object.swiftPrefix !== undefined && object.swiftPrefix !== null) { + message.swiftPrefix = object.swiftPrefix; + } else { + message.swiftPrefix = ""; + } + if (object.phpClassPrefix !== undefined && object.phpClassPrefix !== null) { + message.phpClassPrefix = object.phpClassPrefix; + } else { + message.phpClassPrefix = ""; + } + if (object.phpNamespace !== undefined && object.phpNamespace !== null) { + message.phpNamespace = object.phpNamespace; + } else { + message.phpNamespace = ""; + } + if ( + object.phpMetadataNamespace !== undefined && + object.phpMetadataNamespace !== null + ) { + message.phpMetadataNamespace = object.phpMetadataNamespace; + } else { + message.phpMetadataNamespace = ""; + } + if (object.rubyPackage !== undefined && object.rubyPackage !== null) { + message.rubyPackage = object.rubyPackage; + } else { + message.rubyPackage = ""; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseMessageOptions: object = { + messageSetWireFormat: false, + noStandardDescriptorAccessor: false, + deprecated: false, + mapEntry: false, +}; + +export const MessageOptions = { + encode(message: MessageOptions, writer: Writer = Writer.create()): Writer { + if (message.messageSetWireFormat === true) { + writer.uint32(8).bool(message.messageSetWireFormat); + } + if (message.noStandardDescriptorAccessor === true) { + writer.uint32(16).bool(message.noStandardDescriptorAccessor); + } + if (message.deprecated === true) { + writer.uint32(24).bool(message.deprecated); + } + if (message.mapEntry === true) { + writer.uint32(56).bool(message.mapEntry); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MessageOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMessageOptions } as MessageOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.messageSetWireFormat = reader.bool(); + break; + case 2: + message.noStandardDescriptorAccessor = reader.bool(); + break; + case 3: + message.deprecated = reader.bool(); + break; + case 7: + message.mapEntry = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MessageOptions { + const message = { ...baseMessageOptions } as MessageOptions; + message.uninterpretedOption = []; + if ( + object.messageSetWireFormat !== undefined && + object.messageSetWireFormat !== null + ) { + message.messageSetWireFormat = Boolean(object.messageSetWireFormat); + } else { + message.messageSetWireFormat = false; + } + if ( + object.noStandardDescriptorAccessor !== undefined && + object.noStandardDescriptorAccessor !== null + ) { + message.noStandardDescriptorAccessor = Boolean( + object.noStandardDescriptorAccessor + ); + } else { + message.noStandardDescriptorAccessor = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if (object.mapEntry !== undefined && object.mapEntry !== null) { + message.mapEntry = Boolean(object.mapEntry); + } else { + message.mapEntry = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: MessageOptions): unknown { + const obj: any = {}; + message.messageSetWireFormat !== undefined && + (obj.messageSetWireFormat = message.messageSetWireFormat); + message.noStandardDescriptorAccessor !== undefined && + (obj.noStandardDescriptorAccessor = message.noStandardDescriptorAccessor); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.mapEntry !== undefined && (obj.mapEntry = message.mapEntry); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): MessageOptions { + const message = { ...baseMessageOptions } as MessageOptions; + message.uninterpretedOption = []; + if ( + object.messageSetWireFormat !== undefined && + object.messageSetWireFormat !== null + ) { + message.messageSetWireFormat = object.messageSetWireFormat; + } else { + message.messageSetWireFormat = false; + } + if ( + object.noStandardDescriptorAccessor !== undefined && + object.noStandardDescriptorAccessor !== null + ) { + message.noStandardDescriptorAccessor = + object.noStandardDescriptorAccessor; + } else { + message.noStandardDescriptorAccessor = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if (object.mapEntry !== undefined && object.mapEntry !== null) { + message.mapEntry = object.mapEntry; + } else { + message.mapEntry = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseFieldOptions: object = { + ctype: 0, + packed: false, + jstype: 0, + lazy: false, + deprecated: false, + weak: false, +}; + +export const FieldOptions = { + encode(message: FieldOptions, writer: Writer = Writer.create()): Writer { + if (message.ctype !== 0) { + writer.uint32(8).int32(message.ctype); + } + if (message.packed === true) { + writer.uint32(16).bool(message.packed); + } + if (message.jstype !== 0) { + writer.uint32(48).int32(message.jstype); + } + if (message.lazy === true) { + writer.uint32(40).bool(message.lazy); + } + if (message.deprecated === true) { + writer.uint32(24).bool(message.deprecated); + } + if (message.weak === true) { + writer.uint32(80).bool(message.weak); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FieldOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFieldOptions } as FieldOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.ctype = reader.int32() as any; + break; + case 2: + message.packed = reader.bool(); + break; + case 6: + message.jstype = reader.int32() as any; + break; + case 5: + message.lazy = reader.bool(); + break; + case 3: + message.deprecated = reader.bool(); + break; + case 10: + message.weak = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FieldOptions { + const message = { ...baseFieldOptions } as FieldOptions; + message.uninterpretedOption = []; + if (object.ctype !== undefined && object.ctype !== null) { + message.ctype = fieldOptions_CTypeFromJSON(object.ctype); + } else { + message.ctype = 0; + } + if (object.packed !== undefined && object.packed !== null) { + message.packed = Boolean(object.packed); + } else { + message.packed = false; + } + if (object.jstype !== undefined && object.jstype !== null) { + message.jstype = fieldOptions_JSTypeFromJSON(object.jstype); + } else { + message.jstype = 0; + } + if (object.lazy !== undefined && object.lazy !== null) { + message.lazy = Boolean(object.lazy); + } else { + message.lazy = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if (object.weak !== undefined && object.weak !== null) { + message.weak = Boolean(object.weak); + } else { + message.weak = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: FieldOptions): unknown { + const obj: any = {}; + message.ctype !== undefined && + (obj.ctype = fieldOptions_CTypeToJSON(message.ctype)); + message.packed !== undefined && (obj.packed = message.packed); + message.jstype !== undefined && + (obj.jstype = fieldOptions_JSTypeToJSON(message.jstype)); + message.lazy !== undefined && (obj.lazy = message.lazy); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.weak !== undefined && (obj.weak = message.weak); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): FieldOptions { + const message = { ...baseFieldOptions } as FieldOptions; + message.uninterpretedOption = []; + if (object.ctype !== undefined && object.ctype !== null) { + message.ctype = object.ctype; + } else { + message.ctype = 0; + } + if (object.packed !== undefined && object.packed !== null) { + message.packed = object.packed; + } else { + message.packed = false; + } + if (object.jstype !== undefined && object.jstype !== null) { + message.jstype = object.jstype; + } else { + message.jstype = 0; + } + if (object.lazy !== undefined && object.lazy !== null) { + message.lazy = object.lazy; + } else { + message.lazy = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if (object.weak !== undefined && object.weak !== null) { + message.weak = object.weak; + } else { + message.weak = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseOneofOptions: object = {}; + +export const OneofOptions = { + encode(message: OneofOptions, writer: Writer = Writer.create()): Writer { + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): OneofOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseOneofOptions } as OneofOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): OneofOptions { + const message = { ...baseOneofOptions } as OneofOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: OneofOptions): unknown { + const obj: any = {}; + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): OneofOptions { + const message = { ...baseOneofOptions } as OneofOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseEnumOptions: object = { allowAlias: false, deprecated: false }; + +export const EnumOptions = { + encode(message: EnumOptions, writer: Writer = Writer.create()): Writer { + if (message.allowAlias === true) { + writer.uint32(16).bool(message.allowAlias); + } + if (message.deprecated === true) { + writer.uint32(24).bool(message.deprecated); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): EnumOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseEnumOptions } as EnumOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + message.allowAlias = reader.bool(); + break; + case 3: + message.deprecated = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumOptions { + const message = { ...baseEnumOptions } as EnumOptions; + message.uninterpretedOption = []; + if (object.allowAlias !== undefined && object.allowAlias !== null) { + message.allowAlias = Boolean(object.allowAlias); + } else { + message.allowAlias = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: EnumOptions): unknown { + const obj: any = {}; + message.allowAlias !== undefined && (obj.allowAlias = message.allowAlias); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): EnumOptions { + const message = { ...baseEnumOptions } as EnumOptions; + message.uninterpretedOption = []; + if (object.allowAlias !== undefined && object.allowAlias !== null) { + message.allowAlias = object.allowAlias; + } else { + message.allowAlias = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseEnumValueOptions: object = { deprecated: false }; + +export const EnumValueOptions = { + encode(message: EnumValueOptions, writer: Writer = Writer.create()): Writer { + if (message.deprecated === true) { + writer.uint32(8).bool(message.deprecated); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): EnumValueOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseEnumValueOptions } as EnumValueOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.deprecated = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumValueOptions { + const message = { ...baseEnumValueOptions } as EnumValueOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: EnumValueOptions): unknown { + const obj: any = {}; + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): EnumValueOptions { + const message = { ...baseEnumValueOptions } as EnumValueOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseServiceOptions: object = { deprecated: false }; + +export const ServiceOptions = { + encode(message: ServiceOptions, writer: Writer = Writer.create()): Writer { + if (message.deprecated === true) { + writer.uint32(264).bool(message.deprecated); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ServiceOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseServiceOptions } as ServiceOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 33: + message.deprecated = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ServiceOptions { + const message = { ...baseServiceOptions } as ServiceOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: ServiceOptions): unknown { + const obj: any = {}; + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): ServiceOptions { + const message = { ...baseServiceOptions } as ServiceOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseMethodOptions: object = { deprecated: false, idempotencyLevel: 0 }; + +export const MethodOptions = { + encode(message: MethodOptions, writer: Writer = Writer.create()): Writer { + if (message.deprecated === true) { + writer.uint32(264).bool(message.deprecated); + } + if (message.idempotencyLevel !== 0) { + writer.uint32(272).int32(message.idempotencyLevel); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MethodOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMethodOptions } as MethodOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 33: + message.deprecated = reader.bool(); + break; + case 34: + message.idempotencyLevel = reader.int32() as any; + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MethodOptions { + const message = { ...baseMethodOptions } as MethodOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.idempotencyLevel !== undefined && + object.idempotencyLevel !== null + ) { + message.idempotencyLevel = methodOptions_IdempotencyLevelFromJSON( + object.idempotencyLevel + ); + } else { + message.idempotencyLevel = 0; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: MethodOptions): unknown { + const obj: any = {}; + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.idempotencyLevel !== undefined && + (obj.idempotencyLevel = methodOptions_IdempotencyLevelToJSON( + message.idempotencyLevel + )); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): MethodOptions { + const message = { ...baseMethodOptions } as MethodOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.idempotencyLevel !== undefined && + object.idempotencyLevel !== null + ) { + message.idempotencyLevel = object.idempotencyLevel; + } else { + message.idempotencyLevel = 0; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseUninterpretedOption: object = { + identifierValue: "", + positiveIntValue: 0, + negativeIntValue: 0, + doubleValue: 0, + aggregateValue: "", +}; + +export const UninterpretedOption = { + encode( + message: UninterpretedOption, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.name) { + UninterpretedOption_NamePart.encode( + v!, + writer.uint32(18).fork() + ).ldelim(); + } + if (message.identifierValue !== "") { + writer.uint32(26).string(message.identifierValue); + } + if (message.positiveIntValue !== 0) { + writer.uint32(32).uint64(message.positiveIntValue); + } + if (message.negativeIntValue !== 0) { + writer.uint32(40).int64(message.negativeIntValue); + } + if (message.doubleValue !== 0) { + writer.uint32(49).double(message.doubleValue); + } + if (message.stringValue.length !== 0) { + writer.uint32(58).bytes(message.stringValue); + } + if (message.aggregateValue !== "") { + writer.uint32(66).string(message.aggregateValue); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): UninterpretedOption { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseUninterpretedOption } as UninterpretedOption; + message.name = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + message.name.push( + UninterpretedOption_NamePart.decode(reader, reader.uint32()) + ); + break; + case 3: + message.identifierValue = reader.string(); + break; + case 4: + message.positiveIntValue = longToNumber(reader.uint64() as Long); + break; + case 5: + message.negativeIntValue = longToNumber(reader.int64() as Long); + break; + case 6: + message.doubleValue = reader.double(); + break; + case 7: + message.stringValue = reader.bytes(); + break; + case 8: + message.aggregateValue = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): UninterpretedOption { + const message = { ...baseUninterpretedOption } as UninterpretedOption; + message.name = []; + if (object.name !== undefined && object.name !== null) { + for (const e of object.name) { + message.name.push(UninterpretedOption_NamePart.fromJSON(e)); + } + } + if ( + object.identifierValue !== undefined && + object.identifierValue !== null + ) { + message.identifierValue = String(object.identifierValue); + } else { + message.identifierValue = ""; + } + if ( + object.positiveIntValue !== undefined && + object.positiveIntValue !== null + ) { + message.positiveIntValue = Number(object.positiveIntValue); + } else { + message.positiveIntValue = 0; + } + if ( + object.negativeIntValue !== undefined && + object.negativeIntValue !== null + ) { + message.negativeIntValue = Number(object.negativeIntValue); + } else { + message.negativeIntValue = 0; + } + if (object.doubleValue !== undefined && object.doubleValue !== null) { + message.doubleValue = Number(object.doubleValue); + } else { + message.doubleValue = 0; + } + if (object.stringValue !== undefined && object.stringValue !== null) { + message.stringValue = bytesFromBase64(object.stringValue); + } + if (object.aggregateValue !== undefined && object.aggregateValue !== null) { + message.aggregateValue = String(object.aggregateValue); + } else { + message.aggregateValue = ""; + } + return message; + }, + + toJSON(message: UninterpretedOption): unknown { + const obj: any = {}; + if (message.name) { + obj.name = message.name.map((e) => + e ? UninterpretedOption_NamePart.toJSON(e) : undefined + ); + } else { + obj.name = []; + } + message.identifierValue !== undefined && + (obj.identifierValue = message.identifierValue); + message.positiveIntValue !== undefined && + (obj.positiveIntValue = message.positiveIntValue); + message.negativeIntValue !== undefined && + (obj.negativeIntValue = message.negativeIntValue); + message.doubleValue !== undefined && + (obj.doubleValue = message.doubleValue); + message.stringValue !== undefined && + (obj.stringValue = base64FromBytes( + message.stringValue !== undefined + ? message.stringValue + : new Uint8Array() + )); + message.aggregateValue !== undefined && + (obj.aggregateValue = message.aggregateValue); + return obj; + }, + + fromPartial(object: DeepPartial): UninterpretedOption { + const message = { ...baseUninterpretedOption } as UninterpretedOption; + message.name = []; + if (object.name !== undefined && object.name !== null) { + for (const e of object.name) { + message.name.push(UninterpretedOption_NamePart.fromPartial(e)); + } + } + if ( + object.identifierValue !== undefined && + object.identifierValue !== null + ) { + message.identifierValue = object.identifierValue; + } else { + message.identifierValue = ""; + } + if ( + object.positiveIntValue !== undefined && + object.positiveIntValue !== null + ) { + message.positiveIntValue = object.positiveIntValue; + } else { + message.positiveIntValue = 0; + } + if ( + object.negativeIntValue !== undefined && + object.negativeIntValue !== null + ) { + message.negativeIntValue = object.negativeIntValue; + } else { + message.negativeIntValue = 0; + } + if (object.doubleValue !== undefined && object.doubleValue !== null) { + message.doubleValue = object.doubleValue; + } else { + message.doubleValue = 0; + } + if (object.stringValue !== undefined && object.stringValue !== null) { + message.stringValue = object.stringValue; + } else { + message.stringValue = new Uint8Array(); + } + if (object.aggregateValue !== undefined && object.aggregateValue !== null) { + message.aggregateValue = object.aggregateValue; + } else { + message.aggregateValue = ""; + } + return message; + }, +}; + +const baseUninterpretedOption_NamePart: object = { + namePart: "", + isExtension: false, +}; + +export const UninterpretedOption_NamePart = { + encode( + message: UninterpretedOption_NamePart, + writer: Writer = Writer.create() + ): Writer { + if (message.namePart !== "") { + writer.uint32(10).string(message.namePart); + } + if (message.isExtension === true) { + writer.uint32(16).bool(message.isExtension); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): UninterpretedOption_NamePart { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseUninterpretedOption_NamePart, + } as UninterpretedOption_NamePart; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.namePart = reader.string(); + break; + case 2: + message.isExtension = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): UninterpretedOption_NamePart { + const message = { + ...baseUninterpretedOption_NamePart, + } as UninterpretedOption_NamePart; + if (object.namePart !== undefined && object.namePart !== null) { + message.namePart = String(object.namePart); + } else { + message.namePart = ""; + } + if (object.isExtension !== undefined && object.isExtension !== null) { + message.isExtension = Boolean(object.isExtension); + } else { + message.isExtension = false; + } + return message; + }, + + toJSON(message: UninterpretedOption_NamePart): unknown { + const obj: any = {}; + message.namePart !== undefined && (obj.namePart = message.namePart); + message.isExtension !== undefined && + (obj.isExtension = message.isExtension); + return obj; + }, + + fromPartial( + object: DeepPartial + ): UninterpretedOption_NamePart { + const message = { + ...baseUninterpretedOption_NamePart, + } as UninterpretedOption_NamePart; + if (object.namePart !== undefined && object.namePart !== null) { + message.namePart = object.namePart; + } else { + message.namePart = ""; + } + if (object.isExtension !== undefined && object.isExtension !== null) { + message.isExtension = object.isExtension; + } else { + message.isExtension = false; + } + return message; + }, +}; + +const baseSourceCodeInfo: object = {}; + +export const SourceCodeInfo = { + encode(message: SourceCodeInfo, writer: Writer = Writer.create()): Writer { + for (const v of message.location) { + SourceCodeInfo_Location.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): SourceCodeInfo { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseSourceCodeInfo } as SourceCodeInfo; + message.location = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.location.push( + SourceCodeInfo_Location.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): SourceCodeInfo { + const message = { ...baseSourceCodeInfo } as SourceCodeInfo; + message.location = []; + if (object.location !== undefined && object.location !== null) { + for (const e of object.location) { + message.location.push(SourceCodeInfo_Location.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: SourceCodeInfo): unknown { + const obj: any = {}; + if (message.location) { + obj.location = message.location.map((e) => + e ? SourceCodeInfo_Location.toJSON(e) : undefined + ); + } else { + obj.location = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): SourceCodeInfo { + const message = { ...baseSourceCodeInfo } as SourceCodeInfo; + message.location = []; + if (object.location !== undefined && object.location !== null) { + for (const e of object.location) { + message.location.push(SourceCodeInfo_Location.fromPartial(e)); + } + } + return message; + }, +}; + +const baseSourceCodeInfo_Location: object = { + path: 0, + span: 0, + leadingComments: "", + trailingComments: "", + leadingDetachedComments: "", +}; + +export const SourceCodeInfo_Location = { + encode( + message: SourceCodeInfo_Location, + writer: Writer = Writer.create() + ): Writer { + writer.uint32(10).fork(); + for (const v of message.path) { + writer.int32(v); + } + writer.ldelim(); + writer.uint32(18).fork(); + for (const v of message.span) { + writer.int32(v); + } + writer.ldelim(); + if (message.leadingComments !== "") { + writer.uint32(26).string(message.leadingComments); + } + if (message.trailingComments !== "") { + writer.uint32(34).string(message.trailingComments); + } + for (const v of message.leadingDetachedComments) { + writer.uint32(50).string(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): SourceCodeInfo_Location { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseSourceCodeInfo_Location, + } as SourceCodeInfo_Location; + message.path = []; + message.span = []; + message.leadingDetachedComments = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.path.push(reader.int32()); + } + } else { + message.path.push(reader.int32()); + } + break; + case 2: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.span.push(reader.int32()); + } + } else { + message.span.push(reader.int32()); + } + break; + case 3: + message.leadingComments = reader.string(); + break; + case 4: + message.trailingComments = reader.string(); + break; + case 6: + message.leadingDetachedComments.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): SourceCodeInfo_Location { + const message = { + ...baseSourceCodeInfo_Location, + } as SourceCodeInfo_Location; + message.path = []; + message.span = []; + message.leadingDetachedComments = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(Number(e)); + } + } + if (object.span !== undefined && object.span !== null) { + for (const e of object.span) { + message.span.push(Number(e)); + } + } + if ( + object.leadingComments !== undefined && + object.leadingComments !== null + ) { + message.leadingComments = String(object.leadingComments); + } else { + message.leadingComments = ""; + } + if ( + object.trailingComments !== undefined && + object.trailingComments !== null + ) { + message.trailingComments = String(object.trailingComments); + } else { + message.trailingComments = ""; + } + if ( + object.leadingDetachedComments !== undefined && + object.leadingDetachedComments !== null + ) { + for (const e of object.leadingDetachedComments) { + message.leadingDetachedComments.push(String(e)); + } + } + return message; + }, + + toJSON(message: SourceCodeInfo_Location): unknown { + const obj: any = {}; + if (message.path) { + obj.path = message.path.map((e) => e); + } else { + obj.path = []; + } + if (message.span) { + obj.span = message.span.map((e) => e); + } else { + obj.span = []; + } + message.leadingComments !== undefined && + (obj.leadingComments = message.leadingComments); + message.trailingComments !== undefined && + (obj.trailingComments = message.trailingComments); + if (message.leadingDetachedComments) { + obj.leadingDetachedComments = message.leadingDetachedComments.map( + (e) => e + ); + } else { + obj.leadingDetachedComments = []; + } + return obj; + }, + + fromPartial( + object: DeepPartial + ): SourceCodeInfo_Location { + const message = { + ...baseSourceCodeInfo_Location, + } as SourceCodeInfo_Location; + message.path = []; + message.span = []; + message.leadingDetachedComments = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(e); + } + } + if (object.span !== undefined && object.span !== null) { + for (const e of object.span) { + message.span.push(e); + } + } + if ( + object.leadingComments !== undefined && + object.leadingComments !== null + ) { + message.leadingComments = object.leadingComments; + } else { + message.leadingComments = ""; + } + if ( + object.trailingComments !== undefined && + object.trailingComments !== null + ) { + message.trailingComments = object.trailingComments; + } else { + message.trailingComments = ""; + } + if ( + object.leadingDetachedComments !== undefined && + object.leadingDetachedComments !== null + ) { + for (const e of object.leadingDetachedComments) { + message.leadingDetachedComments.push(e); + } + } + return message; + }, +}; + +const baseGeneratedCodeInfo: object = {}; + +export const GeneratedCodeInfo = { + encode(message: GeneratedCodeInfo, writer: Writer = Writer.create()): Writer { + for (const v of message.annotation) { + GeneratedCodeInfo_Annotation.encode( + v!, + writer.uint32(10).fork() + ).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): GeneratedCodeInfo { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseGeneratedCodeInfo } as GeneratedCodeInfo; + message.annotation = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.annotation.push( + GeneratedCodeInfo_Annotation.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GeneratedCodeInfo { + const message = { ...baseGeneratedCodeInfo } as GeneratedCodeInfo; + message.annotation = []; + if (object.annotation !== undefined && object.annotation !== null) { + for (const e of object.annotation) { + message.annotation.push(GeneratedCodeInfo_Annotation.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: GeneratedCodeInfo): unknown { + const obj: any = {}; + if (message.annotation) { + obj.annotation = message.annotation.map((e) => + e ? GeneratedCodeInfo_Annotation.toJSON(e) : undefined + ); + } else { + obj.annotation = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): GeneratedCodeInfo { + const message = { ...baseGeneratedCodeInfo } as GeneratedCodeInfo; + message.annotation = []; + if (object.annotation !== undefined && object.annotation !== null) { + for (const e of object.annotation) { + message.annotation.push(GeneratedCodeInfo_Annotation.fromPartial(e)); + } + } + return message; + }, +}; + +const baseGeneratedCodeInfo_Annotation: object = { + path: 0, + sourceFile: "", + begin: 0, + end: 0, +}; + +export const GeneratedCodeInfo_Annotation = { + encode( + message: GeneratedCodeInfo_Annotation, + writer: Writer = Writer.create() + ): Writer { + writer.uint32(10).fork(); + for (const v of message.path) { + writer.int32(v); + } + writer.ldelim(); + if (message.sourceFile !== "") { + writer.uint32(18).string(message.sourceFile); + } + if (message.begin !== 0) { + writer.uint32(24).int32(message.begin); + } + if (message.end !== 0) { + writer.uint32(32).int32(message.end); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): GeneratedCodeInfo_Annotation { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseGeneratedCodeInfo_Annotation, + } as GeneratedCodeInfo_Annotation; + message.path = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.path.push(reader.int32()); + } + } else { + message.path.push(reader.int32()); + } + break; + case 2: + message.sourceFile = reader.string(); + break; + case 3: + message.begin = reader.int32(); + break; + case 4: + message.end = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GeneratedCodeInfo_Annotation { + const message = { + ...baseGeneratedCodeInfo_Annotation, + } as GeneratedCodeInfo_Annotation; + message.path = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(Number(e)); + } + } + if (object.sourceFile !== undefined && object.sourceFile !== null) { + message.sourceFile = String(object.sourceFile); + } else { + message.sourceFile = ""; + } + if (object.begin !== undefined && object.begin !== null) { + message.begin = Number(object.begin); + } else { + message.begin = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + return message; + }, + + toJSON(message: GeneratedCodeInfo_Annotation): unknown { + const obj: any = {}; + if (message.path) { + obj.path = message.path.map((e) => e); + } else { + obj.path = []; + } + message.sourceFile !== undefined && (obj.sourceFile = message.sourceFile); + message.begin !== undefined && (obj.begin = message.begin); + message.end !== undefined && (obj.end = message.end); + return obj; + }, + + fromPartial( + object: DeepPartial + ): GeneratedCodeInfo_Annotation { + const message = { + ...baseGeneratedCodeInfo_Annotation, + } as GeneratedCodeInfo_Annotation; + message.path = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(e); + } + } + if (object.sourceFile !== undefined && object.sourceFile !== null) { + message.sourceFile = object.sourceFile; + } else { + message.sourceFile = ""; + } + if (object.begin !== undefined && object.begin !== null) { + message.begin = object.begin; + } else { + message.begin = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/cosmos.tx.v1beta1/types/google/protobuf/duration.ts b/ts-client/cosmos.tx.v1beta1/types/google/protobuf/duration.ts new file mode 100644 index 00000000..fffd5b14 --- /dev/null +++ b/ts-client/cosmos.tx.v1beta1/types/google/protobuf/duration.ts @@ -0,0 +1,188 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "google.protobuf"; + +/** + * A Duration represents a signed, fixed-length span of time represented + * as a count of seconds and fractions of seconds at nanosecond + * resolution. It is independent of any calendar and concepts like "day" + * or "month". It is related to Timestamp in that the difference between + * two Timestamp values is a Duration and it can be added or subtracted + * from a Timestamp. Range is approximately +-10,000 years. + * + * # Examples + * + * Example 1: Compute Duration from two Timestamps in pseudo code. + * + * Timestamp start = ...; + * Timestamp end = ...; + * Duration duration = ...; + * + * duration.seconds = end.seconds - start.seconds; + * duration.nanos = end.nanos - start.nanos; + * + * if (duration.seconds < 0 && duration.nanos > 0) { + * duration.seconds += 1; + * duration.nanos -= 1000000000; + * } else if (duration.seconds > 0 && duration.nanos < 0) { + * duration.seconds -= 1; + * duration.nanos += 1000000000; + * } + * + * Example 2: Compute Timestamp from Timestamp + Duration in pseudo code. + * + * Timestamp start = ...; + * Duration duration = ...; + * Timestamp end = ...; + * + * end.seconds = start.seconds + duration.seconds; + * end.nanos = start.nanos + duration.nanos; + * + * if (end.nanos < 0) { + * end.seconds -= 1; + * end.nanos += 1000000000; + * } else if (end.nanos >= 1000000000) { + * end.seconds += 1; + * end.nanos -= 1000000000; + * } + * + * Example 3: Compute Duration from datetime.timedelta in Python. + * + * td = datetime.timedelta(days=3, minutes=10) + * duration = Duration() + * duration.FromTimedelta(td) + * + * # JSON Mapping + * + * In JSON format, the Duration type is encoded as a string rather than an + * object, where the string ends in the suffix "s" (indicating seconds) and + * is preceded by the number of seconds, with nanoseconds expressed as + * fractional seconds. For example, 3 seconds with 0 nanoseconds should be + * encoded in JSON format as "3s", while 3 seconds and 1 nanosecond should + * be expressed in JSON format as "3.000000001s", and 3 seconds and 1 + * microsecond should be expressed in JSON format as "3.000001s". + */ +export interface Duration { + /** + * Signed seconds of the span of time. Must be from -315,576,000,000 + * to +315,576,000,000 inclusive. Note: these bounds are computed from: + * 60 sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years + */ + seconds: number; + /** + * Signed fractions of a second at nanosecond resolution of the span + * of time. Durations less than one second are represented with a 0 + * `seconds` field and a positive or negative `nanos` field. For durations + * of one second or more, a non-zero value for the `nanos` field must be + * of the same sign as the `seconds` field. Must be from -999,999,999 + * to +999,999,999 inclusive. + */ + nanos: number; +} + +const baseDuration: object = { seconds: 0, nanos: 0 }; + +export const Duration = { + encode(message: Duration, writer: Writer = Writer.create()): Writer { + if (message.seconds !== 0) { + writer.uint32(8).int64(message.seconds); + } + if (message.nanos !== 0) { + writer.uint32(16).int32(message.nanos); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Duration { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseDuration } as Duration; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.seconds = longToNumber(reader.int64() as Long); + break; + case 2: + message.nanos = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Duration { + const message = { ...baseDuration } as Duration; + if (object.seconds !== undefined && object.seconds !== null) { + message.seconds = Number(object.seconds); + } else { + message.seconds = 0; + } + if (object.nanos !== undefined && object.nanos !== null) { + message.nanos = Number(object.nanos); + } else { + message.nanos = 0; + } + return message; + }, + + toJSON(message: Duration): unknown { + const obj: any = {}; + message.seconds !== undefined && (obj.seconds = message.seconds); + message.nanos !== undefined && (obj.nanos = message.nanos); + return obj; + }, + + fromPartial(object: DeepPartial): Duration { + const message = { ...baseDuration } as Duration; + if (object.seconds !== undefined && object.seconds !== null) { + message.seconds = object.seconds; + } else { + message.seconds = 0; + } + if (object.nanos !== undefined && object.nanos !== null) { + message.nanos = object.nanos; + } else { + message.nanos = 0; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/cosmos.tx.v1beta1/types/google/protobuf/timestamp.ts b/ts-client/cosmos.tx.v1beta1/types/google/protobuf/timestamp.ts new file mode 100644 index 00000000..11864afc --- /dev/null +++ b/ts-client/cosmos.tx.v1beta1/types/google/protobuf/timestamp.ts @@ -0,0 +1,219 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "google.protobuf"; + +/** + * A Timestamp represents a point in time independent of any time zone or local + * calendar, encoded as a count of seconds and fractions of seconds at + * nanosecond resolution. The count is relative to an epoch at UTC midnight on + * January 1, 1970, in the proleptic Gregorian calendar which extends the + * Gregorian calendar backwards to year one. + * + * All minutes are 60 seconds long. Leap seconds are "smeared" so that no leap + * second table is needed for interpretation, using a [24-hour linear + * smear](https://developers.google.com/time/smear). + * + * The range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. By + * restricting to that range, we ensure that we can convert to and from [RFC + * 3339](https://www.ietf.org/rfc/rfc3339.txt) date strings. + * + * # Examples + * + * Example 1: Compute Timestamp from POSIX `time()`. + * + * Timestamp timestamp; + * timestamp.set_seconds(time(NULL)); + * timestamp.set_nanos(0); + * + * Example 2: Compute Timestamp from POSIX `gettimeofday()`. + * + * struct timeval tv; + * gettimeofday(&tv, NULL); + * + * Timestamp timestamp; + * timestamp.set_seconds(tv.tv_sec); + * timestamp.set_nanos(tv.tv_usec * 1000); + * + * Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`. + * + * FILETIME ft; + * GetSystemTimeAsFileTime(&ft); + * UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime; + * + * // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z + * // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z. + * Timestamp timestamp; + * timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL)); + * timestamp.set_nanos((INT32) ((ticks % 10000000) * 100)); + * + * Example 4: Compute Timestamp from Java `System.currentTimeMillis()`. + * + * long millis = System.currentTimeMillis(); + * + * Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000) + * .setNanos((int) ((millis % 1000) * 1000000)).build(); + * + * + * Example 5: Compute Timestamp from Java `Instant.now()`. + * + * Instant now = Instant.now(); + * + * Timestamp timestamp = + * Timestamp.newBuilder().setSeconds(now.getEpochSecond()) + * .setNanos(now.getNano()).build(); + * + * + * Example 6: Compute Timestamp from current time in Python. + * + * timestamp = Timestamp() + * timestamp.GetCurrentTime() + * + * # JSON Mapping + * + * In JSON format, the Timestamp type is encoded as a string in the + * [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the + * format is "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z" + * where {year} is always expressed using four digits while {month}, {day}, + * {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional + * seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution), + * are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone + * is required. A proto3 JSON serializer should always use UTC (as indicated by + * "Z") when printing the Timestamp type and a proto3 JSON parser should be + * able to accept both UTC and other timezones (as indicated by an offset). + * + * For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past + * 01:30 UTC on January 15, 2017. + * + * In JavaScript, one can convert a Date object to this format using the + * standard + * [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString) + * method. In Python, a standard `datetime.datetime` object can be converted + * to this format using + * [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) with + * the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one can use + * the Joda Time's [`ISODateTimeFormat.dateTime()`]( + * http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime%2D%2D + * ) to obtain a formatter capable of generating timestamps in this format. + */ +export interface Timestamp { + /** + * Represents seconds of UTC time since Unix epoch + * 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to + * 9999-12-31T23:59:59Z inclusive. + */ + seconds: number; + /** + * Non-negative fractions of a second at nanosecond resolution. Negative + * second values with fractions must still have non-negative nanos values + * that count forward in time. Must be from 0 to 999,999,999 + * inclusive. + */ + nanos: number; +} + +const baseTimestamp: object = { seconds: 0, nanos: 0 }; + +export const Timestamp = { + encode(message: Timestamp, writer: Writer = Writer.create()): Writer { + if (message.seconds !== 0) { + writer.uint32(8).int64(message.seconds); + } + if (message.nanos !== 0) { + writer.uint32(16).int32(message.nanos); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Timestamp { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseTimestamp } as Timestamp; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.seconds = longToNumber(reader.int64() as Long); + break; + case 2: + message.nanos = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Timestamp { + const message = { ...baseTimestamp } as Timestamp; + if (object.seconds !== undefined && object.seconds !== null) { + message.seconds = Number(object.seconds); + } else { + message.seconds = 0; + } + if (object.nanos !== undefined && object.nanos !== null) { + message.nanos = Number(object.nanos); + } else { + message.nanos = 0; + } + return message; + }, + + toJSON(message: Timestamp): unknown { + const obj: any = {}; + message.seconds !== undefined && (obj.seconds = message.seconds); + message.nanos !== undefined && (obj.nanos = message.nanos); + return obj; + }, + + fromPartial(object: DeepPartial): Timestamp { + const message = { ...baseTimestamp } as Timestamp; + if (object.seconds !== undefined && object.seconds !== null) { + message.seconds = object.seconds; + } else { + message.seconds = 0; + } + if (object.nanos !== undefined && object.nanos !== null) { + message.nanos = object.nanos; + } else { + message.nanos = 0; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/cosmos.tx.v1beta1/types/tendermint/abci/types.ts b/ts-client/cosmos.tx.v1beta1/types/tendermint/abci/types.ts new file mode 100644 index 00000000..8d4e7ed7 --- /dev/null +++ b/ts-client/cosmos.tx.v1beta1/types/tendermint/abci/types.ts @@ -0,0 +1,5687 @@ +/* eslint-disable */ +import { Reader, util, configure, Writer } from "protobufjs/minimal"; +import { Timestamp } from "../../google/protobuf/timestamp"; +import * as Long from "long"; +import { Header } from "../../tendermint/types/types"; +import { ProofOps } from "../../tendermint/crypto/proof"; +import { + EvidenceParams, + ValidatorParams, + VersionParams, +} from "../../tendermint/types/params"; +import { PublicKey } from "../../tendermint/crypto/keys"; + +export const protobufPackage = "tendermint.abci"; + +export enum CheckTxType { + NEW = 0, + RECHECK = 1, + UNRECOGNIZED = -1, +} + +export function checkTxTypeFromJSON(object: any): CheckTxType { + switch (object) { + case 0: + case "NEW": + return CheckTxType.NEW; + case 1: + case "RECHECK": + return CheckTxType.RECHECK; + case -1: + case "UNRECOGNIZED": + default: + return CheckTxType.UNRECOGNIZED; + } +} + +export function checkTxTypeToJSON(object: CheckTxType): string { + switch (object) { + case CheckTxType.NEW: + return "NEW"; + case CheckTxType.RECHECK: + return "RECHECK"; + default: + return "UNKNOWN"; + } +} + +export enum EvidenceType { + UNKNOWN = 0, + DUPLICATE_VOTE = 1, + LIGHT_CLIENT_ATTACK = 2, + UNRECOGNIZED = -1, +} + +export function evidenceTypeFromJSON(object: any): EvidenceType { + switch (object) { + case 0: + case "UNKNOWN": + return EvidenceType.UNKNOWN; + case 1: + case "DUPLICATE_VOTE": + return EvidenceType.DUPLICATE_VOTE; + case 2: + case "LIGHT_CLIENT_ATTACK": + return EvidenceType.LIGHT_CLIENT_ATTACK; + case -1: + case "UNRECOGNIZED": + default: + return EvidenceType.UNRECOGNIZED; + } +} + +export function evidenceTypeToJSON(object: EvidenceType): string { + switch (object) { + case EvidenceType.UNKNOWN: + return "UNKNOWN"; + case EvidenceType.DUPLICATE_VOTE: + return "DUPLICATE_VOTE"; + case EvidenceType.LIGHT_CLIENT_ATTACK: + return "LIGHT_CLIENT_ATTACK"; + default: + return "UNKNOWN"; + } +} + +export interface Request { + echo: RequestEcho | undefined; + flush: RequestFlush | undefined; + info: RequestInfo | undefined; + setOption: RequestSetOption | undefined; + initChain: RequestInitChain | undefined; + query: RequestQuery | undefined; + beginBlock: RequestBeginBlock | undefined; + checkTx: RequestCheckTx | undefined; + deliverTx: RequestDeliverTx | undefined; + endBlock: RequestEndBlock | undefined; + commit: RequestCommit | undefined; + listSnapshots: RequestListSnapshots | undefined; + offerSnapshot: RequestOfferSnapshot | undefined; + loadSnapshotChunk: RequestLoadSnapshotChunk | undefined; + applySnapshotChunk: RequestApplySnapshotChunk | undefined; +} + +export interface RequestEcho { + message: string; +} + +export interface RequestFlush {} + +export interface RequestInfo { + version: string; + blockVersion: number; + p2pVersion: number; +} + +/** nondeterministic */ +export interface RequestSetOption { + key: string; + value: string; +} + +export interface RequestInitChain { + time: Date | undefined; + chainId: string; + consensusParams: ConsensusParams | undefined; + validators: ValidatorUpdate[]; + appStateBytes: Uint8Array; + initialHeight: number; +} + +export interface RequestQuery { + data: Uint8Array; + path: string; + height: number; + prove: boolean; +} + +export interface RequestBeginBlock { + hash: Uint8Array; + header: Header | undefined; + lastCommitInfo: LastCommitInfo | undefined; + byzantineValidators: Evidence[]; +} + +export interface RequestCheckTx { + tx: Uint8Array; + type: CheckTxType; +} + +export interface RequestDeliverTx { + tx: Uint8Array; +} + +export interface RequestEndBlock { + height: number; +} + +export interface RequestCommit {} + +/** lists available snapshots */ +export interface RequestListSnapshots {} + +/** offers a snapshot to the application */ +export interface RequestOfferSnapshot { + /** snapshot offered by peers */ + snapshot: Snapshot | undefined; + /** light client-verified app hash for snapshot height */ + appHash: Uint8Array; +} + +/** loads a snapshot chunk */ +export interface RequestLoadSnapshotChunk { + height: number; + format: number; + chunk: number; +} + +/** Applies a snapshot chunk */ +export interface RequestApplySnapshotChunk { + index: number; + chunk: Uint8Array; + sender: string; +} + +export interface Response { + exception: ResponseException | undefined; + echo: ResponseEcho | undefined; + flush: ResponseFlush | undefined; + info: ResponseInfo | undefined; + setOption: ResponseSetOption | undefined; + initChain: ResponseInitChain | undefined; + query: ResponseQuery | undefined; + beginBlock: ResponseBeginBlock | undefined; + checkTx: ResponseCheckTx | undefined; + deliverTx: ResponseDeliverTx | undefined; + endBlock: ResponseEndBlock | undefined; + commit: ResponseCommit | undefined; + listSnapshots: ResponseListSnapshots | undefined; + offerSnapshot: ResponseOfferSnapshot | undefined; + loadSnapshotChunk: ResponseLoadSnapshotChunk | undefined; + applySnapshotChunk: ResponseApplySnapshotChunk | undefined; +} + +/** nondeterministic */ +export interface ResponseException { + error: string; +} + +export interface ResponseEcho { + message: string; +} + +export interface ResponseFlush {} + +export interface ResponseInfo { + data: string; + version: string; + appVersion: number; + lastBlockHeight: number; + lastBlockAppHash: Uint8Array; +} + +/** nondeterministic */ +export interface ResponseSetOption { + code: number; + /** bytes data = 2; */ + log: string; + info: string; +} + +export interface ResponseInitChain { + consensusParams: ConsensusParams | undefined; + validators: ValidatorUpdate[]; + appHash: Uint8Array; +} + +export interface ResponseQuery { + code: number; + /** bytes data = 2; // use "value" instead. */ + log: string; + /** nondeterministic */ + info: string; + index: number; + key: Uint8Array; + value: Uint8Array; + proofOps: ProofOps | undefined; + height: number; + codespace: string; +} + +export interface ResponseBeginBlock { + events: Event[]; +} + +export interface ResponseCheckTx { + code: number; + data: Uint8Array; + /** nondeterministic */ + log: string; + /** nondeterministic */ + info: string; + gasWanted: number; + gasUsed: number; + events: Event[]; + codespace: string; + sender: string; + priority: number; + /** + * mempool_error is set by CometBFT. + * ABCI applictions creating a ResponseCheckTX should not set mempool_error. + */ + mempoolError: string; +} + +export interface ResponseDeliverTx { + code: number; + data: Uint8Array; + /** nondeterministic */ + log: string; + /** nondeterministic */ + info: string; + gasWanted: number; + gasUsed: number; + /** nondeterministic */ + events: Event[]; + codespace: string; +} + +export interface ResponseEndBlock { + validatorUpdates: ValidatorUpdate[]; + consensusParamUpdates: ConsensusParams | undefined; + events: Event[]; +} + +export interface ResponseCommit { + /** reserve 1 */ + data: Uint8Array; + retainHeight: number; +} + +export interface ResponseListSnapshots { + snapshots: Snapshot[]; +} + +export interface ResponseOfferSnapshot { + result: ResponseOfferSnapshot_Result; +} + +export enum ResponseOfferSnapshot_Result { + /** UNKNOWN - Unknown result, abort all snapshot restoration */ + UNKNOWN = 0, + /** ACCEPT - Snapshot accepted, apply chunks */ + ACCEPT = 1, + /** ABORT - Abort all snapshot restoration */ + ABORT = 2, + /** REJECT - Reject this specific snapshot, try others */ + REJECT = 3, + /** REJECT_FORMAT - Reject all snapshots of this format, try others */ + REJECT_FORMAT = 4, + /** REJECT_SENDER - Reject all snapshots from the sender(s), try others */ + REJECT_SENDER = 5, + UNRECOGNIZED = -1, +} + +export function responseOfferSnapshot_ResultFromJSON( + object: any +): ResponseOfferSnapshot_Result { + switch (object) { + case 0: + case "UNKNOWN": + return ResponseOfferSnapshot_Result.UNKNOWN; + case 1: + case "ACCEPT": + return ResponseOfferSnapshot_Result.ACCEPT; + case 2: + case "ABORT": + return ResponseOfferSnapshot_Result.ABORT; + case 3: + case "REJECT": + return ResponseOfferSnapshot_Result.REJECT; + case 4: + case "REJECT_FORMAT": + return ResponseOfferSnapshot_Result.REJECT_FORMAT; + case 5: + case "REJECT_SENDER": + return ResponseOfferSnapshot_Result.REJECT_SENDER; + case -1: + case "UNRECOGNIZED": + default: + return ResponseOfferSnapshot_Result.UNRECOGNIZED; + } +} + +export function responseOfferSnapshot_ResultToJSON( + object: ResponseOfferSnapshot_Result +): string { + switch (object) { + case ResponseOfferSnapshot_Result.UNKNOWN: + return "UNKNOWN"; + case ResponseOfferSnapshot_Result.ACCEPT: + return "ACCEPT"; + case ResponseOfferSnapshot_Result.ABORT: + return "ABORT"; + case ResponseOfferSnapshot_Result.REJECT: + return "REJECT"; + case ResponseOfferSnapshot_Result.REJECT_FORMAT: + return "REJECT_FORMAT"; + case ResponseOfferSnapshot_Result.REJECT_SENDER: + return "REJECT_SENDER"; + default: + return "UNKNOWN"; + } +} + +export interface ResponseLoadSnapshotChunk { + chunk: Uint8Array; +} + +export interface ResponseApplySnapshotChunk { + result: ResponseApplySnapshotChunk_Result; + /** Chunks to refetch and reapply */ + refetchChunks: number[]; + /** Chunk senders to reject and ban */ + rejectSenders: string[]; +} + +export enum ResponseApplySnapshotChunk_Result { + /** UNKNOWN - Unknown result, abort all snapshot restoration */ + UNKNOWN = 0, + /** ACCEPT - Chunk successfully accepted */ + ACCEPT = 1, + /** ABORT - Abort all snapshot restoration */ + ABORT = 2, + /** RETRY - Retry chunk (combine with refetch and reject) */ + RETRY = 3, + /** RETRY_SNAPSHOT - Retry snapshot (combine with refetch and reject) */ + RETRY_SNAPSHOT = 4, + /** REJECT_SNAPSHOT - Reject this snapshot, try others */ + REJECT_SNAPSHOT = 5, + UNRECOGNIZED = -1, +} + +export function responseApplySnapshotChunk_ResultFromJSON( + object: any +): ResponseApplySnapshotChunk_Result { + switch (object) { + case 0: + case "UNKNOWN": + return ResponseApplySnapshotChunk_Result.UNKNOWN; + case 1: + case "ACCEPT": + return ResponseApplySnapshotChunk_Result.ACCEPT; + case 2: + case "ABORT": + return ResponseApplySnapshotChunk_Result.ABORT; + case 3: + case "RETRY": + return ResponseApplySnapshotChunk_Result.RETRY; + case 4: + case "RETRY_SNAPSHOT": + return ResponseApplySnapshotChunk_Result.RETRY_SNAPSHOT; + case 5: + case "REJECT_SNAPSHOT": + return ResponseApplySnapshotChunk_Result.REJECT_SNAPSHOT; + case -1: + case "UNRECOGNIZED": + default: + return ResponseApplySnapshotChunk_Result.UNRECOGNIZED; + } +} + +export function responseApplySnapshotChunk_ResultToJSON( + object: ResponseApplySnapshotChunk_Result +): string { + switch (object) { + case ResponseApplySnapshotChunk_Result.UNKNOWN: + return "UNKNOWN"; + case ResponseApplySnapshotChunk_Result.ACCEPT: + return "ACCEPT"; + case ResponseApplySnapshotChunk_Result.ABORT: + return "ABORT"; + case ResponseApplySnapshotChunk_Result.RETRY: + return "RETRY"; + case ResponseApplySnapshotChunk_Result.RETRY_SNAPSHOT: + return "RETRY_SNAPSHOT"; + case ResponseApplySnapshotChunk_Result.REJECT_SNAPSHOT: + return "REJECT_SNAPSHOT"; + default: + return "UNKNOWN"; + } +} + +/** + * ConsensusParams contains all consensus-relevant parameters + * that can be adjusted by the abci app + */ +export interface ConsensusParams { + block: BlockParams | undefined; + evidence: EvidenceParams | undefined; + validator: ValidatorParams | undefined; + version: VersionParams | undefined; +} + +/** BlockParams contains limits on the block size. */ +export interface BlockParams { + /** Note: must be greater than 0 */ + maxBytes: number; + /** Note: must be greater or equal to -1 */ + maxGas: number; +} + +export interface LastCommitInfo { + round: number; + votes: VoteInfo[]; +} + +/** + * Event allows application developers to attach additional information to + * ResponseBeginBlock, ResponseEndBlock, ResponseCheckTx and ResponseDeliverTx. + * Later, transactions may be queried using these events. + */ +export interface Event { + type: string; + attributes: EventAttribute[]; +} + +/** EventAttribute is a single key-value pair, associated with an event. */ +export interface EventAttribute { + key: Uint8Array; + value: Uint8Array; + /** nondeterministic */ + index: boolean; +} + +/** + * TxResult contains results of executing the transaction. + * + * One usage is indexing transaction results. + */ +export interface TxResult { + height: number; + index: number; + tx: Uint8Array; + result: ResponseDeliverTx | undefined; +} + +/** Validator */ +export interface Validator { + /** The first 20 bytes of SHA256(public key) */ + address: Uint8Array; + /** PubKey pub_key = 2 [(gogoproto.nullable)=false]; */ + power: number; +} + +/** ValidatorUpdate */ +export interface ValidatorUpdate { + pubKey: PublicKey | undefined; + power: number; +} + +/** VoteInfo */ +export interface VoteInfo { + validator: Validator | undefined; + signedLastBlock: boolean; +} + +export interface Evidence { + type: EvidenceType; + /** The offending validator */ + validator: Validator | undefined; + /** The height when the offense occurred */ + height: number; + /** The corresponding time where the offense occurred */ + time: Date | undefined; + /** + * Total voting power of the validator set in case the ABCI application does + * not store historical validators. + * https://github.com/tendermint/tendermint/issues/4581 + */ + totalVotingPower: number; +} + +export interface Snapshot { + /** The height at which the snapshot was taken */ + height: number; + /** The application-specific snapshot format */ + format: number; + /** Number of chunks in the snapshot */ + chunks: number; + /** Arbitrary snapshot hash, equal only if identical */ + hash: Uint8Array; + /** Arbitrary application metadata */ + metadata: Uint8Array; +} + +const baseRequest: object = {}; + +export const Request = { + encode(message: Request, writer: Writer = Writer.create()): Writer { + if (message.echo !== undefined) { + RequestEcho.encode(message.echo, writer.uint32(10).fork()).ldelim(); + } + if (message.flush !== undefined) { + RequestFlush.encode(message.flush, writer.uint32(18).fork()).ldelim(); + } + if (message.info !== undefined) { + RequestInfo.encode(message.info, writer.uint32(26).fork()).ldelim(); + } + if (message.setOption !== undefined) { + RequestSetOption.encode( + message.setOption, + writer.uint32(34).fork() + ).ldelim(); + } + if (message.initChain !== undefined) { + RequestInitChain.encode( + message.initChain, + writer.uint32(42).fork() + ).ldelim(); + } + if (message.query !== undefined) { + RequestQuery.encode(message.query, writer.uint32(50).fork()).ldelim(); + } + if (message.beginBlock !== undefined) { + RequestBeginBlock.encode( + message.beginBlock, + writer.uint32(58).fork() + ).ldelim(); + } + if (message.checkTx !== undefined) { + RequestCheckTx.encode(message.checkTx, writer.uint32(66).fork()).ldelim(); + } + if (message.deliverTx !== undefined) { + RequestDeliverTx.encode( + message.deliverTx, + writer.uint32(74).fork() + ).ldelim(); + } + if (message.endBlock !== undefined) { + RequestEndBlock.encode( + message.endBlock, + writer.uint32(82).fork() + ).ldelim(); + } + if (message.commit !== undefined) { + RequestCommit.encode(message.commit, writer.uint32(90).fork()).ldelim(); + } + if (message.listSnapshots !== undefined) { + RequestListSnapshots.encode( + message.listSnapshots, + writer.uint32(98).fork() + ).ldelim(); + } + if (message.offerSnapshot !== undefined) { + RequestOfferSnapshot.encode( + message.offerSnapshot, + writer.uint32(106).fork() + ).ldelim(); + } + if (message.loadSnapshotChunk !== undefined) { + RequestLoadSnapshotChunk.encode( + message.loadSnapshotChunk, + writer.uint32(114).fork() + ).ldelim(); + } + if (message.applySnapshotChunk !== undefined) { + RequestApplySnapshotChunk.encode( + message.applySnapshotChunk, + writer.uint32(122).fork() + ).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Request { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseRequest } as Request; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.echo = RequestEcho.decode(reader, reader.uint32()); + break; + case 2: + message.flush = RequestFlush.decode(reader, reader.uint32()); + break; + case 3: + message.info = RequestInfo.decode(reader, reader.uint32()); + break; + case 4: + message.setOption = RequestSetOption.decode(reader, reader.uint32()); + break; + case 5: + message.initChain = RequestInitChain.decode(reader, reader.uint32()); + break; + case 6: + message.query = RequestQuery.decode(reader, reader.uint32()); + break; + case 7: + message.beginBlock = RequestBeginBlock.decode( + reader, + reader.uint32() + ); + break; + case 8: + message.checkTx = RequestCheckTx.decode(reader, reader.uint32()); + break; + case 9: + message.deliverTx = RequestDeliverTx.decode(reader, reader.uint32()); + break; + case 10: + message.endBlock = RequestEndBlock.decode(reader, reader.uint32()); + break; + case 11: + message.commit = RequestCommit.decode(reader, reader.uint32()); + break; + case 12: + message.listSnapshots = RequestListSnapshots.decode( + reader, + reader.uint32() + ); + break; + case 13: + message.offerSnapshot = RequestOfferSnapshot.decode( + reader, + reader.uint32() + ); + break; + case 14: + message.loadSnapshotChunk = RequestLoadSnapshotChunk.decode( + reader, + reader.uint32() + ); + break; + case 15: + message.applySnapshotChunk = RequestApplySnapshotChunk.decode( + reader, + reader.uint32() + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Request { + const message = { ...baseRequest } as Request; + if (object.echo !== undefined && object.echo !== null) { + message.echo = RequestEcho.fromJSON(object.echo); + } else { + message.echo = undefined; + } + if (object.flush !== undefined && object.flush !== null) { + message.flush = RequestFlush.fromJSON(object.flush); + } else { + message.flush = undefined; + } + if (object.info !== undefined && object.info !== null) { + message.info = RequestInfo.fromJSON(object.info); + } else { + message.info = undefined; + } + if (object.setOption !== undefined && object.setOption !== null) { + message.setOption = RequestSetOption.fromJSON(object.setOption); + } else { + message.setOption = undefined; + } + if (object.initChain !== undefined && object.initChain !== null) { + message.initChain = RequestInitChain.fromJSON(object.initChain); + } else { + message.initChain = undefined; + } + if (object.query !== undefined && object.query !== null) { + message.query = RequestQuery.fromJSON(object.query); + } else { + message.query = undefined; + } + if (object.beginBlock !== undefined && object.beginBlock !== null) { + message.beginBlock = RequestBeginBlock.fromJSON(object.beginBlock); + } else { + message.beginBlock = undefined; + } + if (object.checkTx !== undefined && object.checkTx !== null) { + message.checkTx = RequestCheckTx.fromJSON(object.checkTx); + } else { + message.checkTx = undefined; + } + if (object.deliverTx !== undefined && object.deliverTx !== null) { + message.deliverTx = RequestDeliverTx.fromJSON(object.deliverTx); + } else { + message.deliverTx = undefined; + } + if (object.endBlock !== undefined && object.endBlock !== null) { + message.endBlock = RequestEndBlock.fromJSON(object.endBlock); + } else { + message.endBlock = undefined; + } + if (object.commit !== undefined && object.commit !== null) { + message.commit = RequestCommit.fromJSON(object.commit); + } else { + message.commit = undefined; + } + if (object.listSnapshots !== undefined && object.listSnapshots !== null) { + message.listSnapshots = RequestListSnapshots.fromJSON( + object.listSnapshots + ); + } else { + message.listSnapshots = undefined; + } + if (object.offerSnapshot !== undefined && object.offerSnapshot !== null) { + message.offerSnapshot = RequestOfferSnapshot.fromJSON( + object.offerSnapshot + ); + } else { + message.offerSnapshot = undefined; + } + if ( + object.loadSnapshotChunk !== undefined && + object.loadSnapshotChunk !== null + ) { + message.loadSnapshotChunk = RequestLoadSnapshotChunk.fromJSON( + object.loadSnapshotChunk + ); + } else { + message.loadSnapshotChunk = undefined; + } + if ( + object.applySnapshotChunk !== undefined && + object.applySnapshotChunk !== null + ) { + message.applySnapshotChunk = RequestApplySnapshotChunk.fromJSON( + object.applySnapshotChunk + ); + } else { + message.applySnapshotChunk = undefined; + } + return message; + }, + + toJSON(message: Request): unknown { + const obj: any = {}; + message.echo !== undefined && + (obj.echo = message.echo ? RequestEcho.toJSON(message.echo) : undefined); + message.flush !== undefined && + (obj.flush = message.flush + ? RequestFlush.toJSON(message.flush) + : undefined); + message.info !== undefined && + (obj.info = message.info ? RequestInfo.toJSON(message.info) : undefined); + message.setOption !== undefined && + (obj.setOption = message.setOption + ? RequestSetOption.toJSON(message.setOption) + : undefined); + message.initChain !== undefined && + (obj.initChain = message.initChain + ? RequestInitChain.toJSON(message.initChain) + : undefined); + message.query !== undefined && + (obj.query = message.query + ? RequestQuery.toJSON(message.query) + : undefined); + message.beginBlock !== undefined && + (obj.beginBlock = message.beginBlock + ? RequestBeginBlock.toJSON(message.beginBlock) + : undefined); + message.checkTx !== undefined && + (obj.checkTx = message.checkTx + ? RequestCheckTx.toJSON(message.checkTx) + : undefined); + message.deliverTx !== undefined && + (obj.deliverTx = message.deliverTx + ? RequestDeliverTx.toJSON(message.deliverTx) + : undefined); + message.endBlock !== undefined && + (obj.endBlock = message.endBlock + ? RequestEndBlock.toJSON(message.endBlock) + : undefined); + message.commit !== undefined && + (obj.commit = message.commit + ? RequestCommit.toJSON(message.commit) + : undefined); + message.listSnapshots !== undefined && + (obj.listSnapshots = message.listSnapshots + ? RequestListSnapshots.toJSON(message.listSnapshots) + : undefined); + message.offerSnapshot !== undefined && + (obj.offerSnapshot = message.offerSnapshot + ? RequestOfferSnapshot.toJSON(message.offerSnapshot) + : undefined); + message.loadSnapshotChunk !== undefined && + (obj.loadSnapshotChunk = message.loadSnapshotChunk + ? RequestLoadSnapshotChunk.toJSON(message.loadSnapshotChunk) + : undefined); + message.applySnapshotChunk !== undefined && + (obj.applySnapshotChunk = message.applySnapshotChunk + ? RequestApplySnapshotChunk.toJSON(message.applySnapshotChunk) + : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): Request { + const message = { ...baseRequest } as Request; + if (object.echo !== undefined && object.echo !== null) { + message.echo = RequestEcho.fromPartial(object.echo); + } else { + message.echo = undefined; + } + if (object.flush !== undefined && object.flush !== null) { + message.flush = RequestFlush.fromPartial(object.flush); + } else { + message.flush = undefined; + } + if (object.info !== undefined && object.info !== null) { + message.info = RequestInfo.fromPartial(object.info); + } else { + message.info = undefined; + } + if (object.setOption !== undefined && object.setOption !== null) { + message.setOption = RequestSetOption.fromPartial(object.setOption); + } else { + message.setOption = undefined; + } + if (object.initChain !== undefined && object.initChain !== null) { + message.initChain = RequestInitChain.fromPartial(object.initChain); + } else { + message.initChain = undefined; + } + if (object.query !== undefined && object.query !== null) { + message.query = RequestQuery.fromPartial(object.query); + } else { + message.query = undefined; + } + if (object.beginBlock !== undefined && object.beginBlock !== null) { + message.beginBlock = RequestBeginBlock.fromPartial(object.beginBlock); + } else { + message.beginBlock = undefined; + } + if (object.checkTx !== undefined && object.checkTx !== null) { + message.checkTx = RequestCheckTx.fromPartial(object.checkTx); + } else { + message.checkTx = undefined; + } + if (object.deliverTx !== undefined && object.deliverTx !== null) { + message.deliverTx = RequestDeliverTx.fromPartial(object.deliverTx); + } else { + message.deliverTx = undefined; + } + if (object.endBlock !== undefined && object.endBlock !== null) { + message.endBlock = RequestEndBlock.fromPartial(object.endBlock); + } else { + message.endBlock = undefined; + } + if (object.commit !== undefined && object.commit !== null) { + message.commit = RequestCommit.fromPartial(object.commit); + } else { + message.commit = undefined; + } + if (object.listSnapshots !== undefined && object.listSnapshots !== null) { + message.listSnapshots = RequestListSnapshots.fromPartial( + object.listSnapshots + ); + } else { + message.listSnapshots = undefined; + } + if (object.offerSnapshot !== undefined && object.offerSnapshot !== null) { + message.offerSnapshot = RequestOfferSnapshot.fromPartial( + object.offerSnapshot + ); + } else { + message.offerSnapshot = undefined; + } + if ( + object.loadSnapshotChunk !== undefined && + object.loadSnapshotChunk !== null + ) { + message.loadSnapshotChunk = RequestLoadSnapshotChunk.fromPartial( + object.loadSnapshotChunk + ); + } else { + message.loadSnapshotChunk = undefined; + } + if ( + object.applySnapshotChunk !== undefined && + object.applySnapshotChunk !== null + ) { + message.applySnapshotChunk = RequestApplySnapshotChunk.fromPartial( + object.applySnapshotChunk + ); + } else { + message.applySnapshotChunk = undefined; + } + return message; + }, +}; + +const baseRequestEcho: object = { message: "" }; + +export const RequestEcho = { + encode(message: RequestEcho, writer: Writer = Writer.create()): Writer { + if (message.message !== "") { + writer.uint32(10).string(message.message); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): RequestEcho { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseRequestEcho } as RequestEcho; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.message = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): RequestEcho { + const message = { ...baseRequestEcho } as RequestEcho; + if (object.message !== undefined && object.message !== null) { + message.message = String(object.message); + } else { + message.message = ""; + } + return message; + }, + + toJSON(message: RequestEcho): unknown { + const obj: any = {}; + message.message !== undefined && (obj.message = message.message); + return obj; + }, + + fromPartial(object: DeepPartial): RequestEcho { + const message = { ...baseRequestEcho } as RequestEcho; + if (object.message !== undefined && object.message !== null) { + message.message = object.message; + } else { + message.message = ""; + } + return message; + }, +}; + +const baseRequestFlush: object = {}; + +export const RequestFlush = { + encode(_: RequestFlush, writer: Writer = Writer.create()): Writer { + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): RequestFlush { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseRequestFlush } as RequestFlush; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): RequestFlush { + const message = { ...baseRequestFlush } as RequestFlush; + return message; + }, + + toJSON(_: RequestFlush): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial(_: DeepPartial): RequestFlush { + const message = { ...baseRequestFlush } as RequestFlush; + return message; + }, +}; + +const baseRequestInfo: object = { version: "", blockVersion: 0, p2pVersion: 0 }; + +export const RequestInfo = { + encode(message: RequestInfo, writer: Writer = Writer.create()): Writer { + if (message.version !== "") { + writer.uint32(10).string(message.version); + } + if (message.blockVersion !== 0) { + writer.uint32(16).uint64(message.blockVersion); + } + if (message.p2pVersion !== 0) { + writer.uint32(24).uint64(message.p2pVersion); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): RequestInfo { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseRequestInfo } as RequestInfo; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.version = reader.string(); + break; + case 2: + message.blockVersion = longToNumber(reader.uint64() as Long); + break; + case 3: + message.p2pVersion = longToNumber(reader.uint64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): RequestInfo { + const message = { ...baseRequestInfo } as RequestInfo; + if (object.version !== undefined && object.version !== null) { + message.version = String(object.version); + } else { + message.version = ""; + } + if (object.blockVersion !== undefined && object.blockVersion !== null) { + message.blockVersion = Number(object.blockVersion); + } else { + message.blockVersion = 0; + } + if (object.p2pVersion !== undefined && object.p2pVersion !== null) { + message.p2pVersion = Number(object.p2pVersion); + } else { + message.p2pVersion = 0; + } + return message; + }, + + toJSON(message: RequestInfo): unknown { + const obj: any = {}; + message.version !== undefined && (obj.version = message.version); + message.blockVersion !== undefined && + (obj.blockVersion = message.blockVersion); + message.p2pVersion !== undefined && (obj.p2pVersion = message.p2pVersion); + return obj; + }, + + fromPartial(object: DeepPartial): RequestInfo { + const message = { ...baseRequestInfo } as RequestInfo; + if (object.version !== undefined && object.version !== null) { + message.version = object.version; + } else { + message.version = ""; + } + if (object.blockVersion !== undefined && object.blockVersion !== null) { + message.blockVersion = object.blockVersion; + } else { + message.blockVersion = 0; + } + if (object.p2pVersion !== undefined && object.p2pVersion !== null) { + message.p2pVersion = object.p2pVersion; + } else { + message.p2pVersion = 0; + } + return message; + }, +}; + +const baseRequestSetOption: object = { key: "", value: "" }; + +export const RequestSetOption = { + encode(message: RequestSetOption, writer: Writer = Writer.create()): Writer { + if (message.key !== "") { + writer.uint32(10).string(message.key); + } + if (message.value !== "") { + writer.uint32(18).string(message.value); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): RequestSetOption { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseRequestSetOption } as RequestSetOption; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.key = reader.string(); + break; + case 2: + message.value = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): RequestSetOption { + const message = { ...baseRequestSetOption } as RequestSetOption; + if (object.key !== undefined && object.key !== null) { + message.key = String(object.key); + } else { + message.key = ""; + } + if (object.value !== undefined && object.value !== null) { + message.value = String(object.value); + } else { + message.value = ""; + } + return message; + }, + + toJSON(message: RequestSetOption): unknown { + const obj: any = {}; + message.key !== undefined && (obj.key = message.key); + message.value !== undefined && (obj.value = message.value); + return obj; + }, + + fromPartial(object: DeepPartial): RequestSetOption { + const message = { ...baseRequestSetOption } as RequestSetOption; + if (object.key !== undefined && object.key !== null) { + message.key = object.key; + } else { + message.key = ""; + } + if (object.value !== undefined && object.value !== null) { + message.value = object.value; + } else { + message.value = ""; + } + return message; + }, +}; + +const baseRequestInitChain: object = { chainId: "", initialHeight: 0 }; + +export const RequestInitChain = { + encode(message: RequestInitChain, writer: Writer = Writer.create()): Writer { + if (message.time !== undefined) { + Timestamp.encode( + toTimestamp(message.time), + writer.uint32(10).fork() + ).ldelim(); + } + if (message.chainId !== "") { + writer.uint32(18).string(message.chainId); + } + if (message.consensusParams !== undefined) { + ConsensusParams.encode( + message.consensusParams, + writer.uint32(26).fork() + ).ldelim(); + } + for (const v of message.validators) { + ValidatorUpdate.encode(v!, writer.uint32(34).fork()).ldelim(); + } + if (message.appStateBytes.length !== 0) { + writer.uint32(42).bytes(message.appStateBytes); + } + if (message.initialHeight !== 0) { + writer.uint32(48).int64(message.initialHeight); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): RequestInitChain { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseRequestInitChain } as RequestInitChain; + message.validators = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.time = fromTimestamp( + Timestamp.decode(reader, reader.uint32()) + ); + break; + case 2: + message.chainId = reader.string(); + break; + case 3: + message.consensusParams = ConsensusParams.decode( + reader, + reader.uint32() + ); + break; + case 4: + message.validators.push( + ValidatorUpdate.decode(reader, reader.uint32()) + ); + break; + case 5: + message.appStateBytes = reader.bytes(); + break; + case 6: + message.initialHeight = longToNumber(reader.int64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): RequestInitChain { + const message = { ...baseRequestInitChain } as RequestInitChain; + message.validators = []; + if (object.time !== undefined && object.time !== null) { + message.time = fromJsonTimestamp(object.time); + } else { + message.time = undefined; + } + if (object.chainId !== undefined && object.chainId !== null) { + message.chainId = String(object.chainId); + } else { + message.chainId = ""; + } + if ( + object.consensusParams !== undefined && + object.consensusParams !== null + ) { + message.consensusParams = ConsensusParams.fromJSON( + object.consensusParams + ); + } else { + message.consensusParams = undefined; + } + if (object.validators !== undefined && object.validators !== null) { + for (const e of object.validators) { + message.validators.push(ValidatorUpdate.fromJSON(e)); + } + } + if (object.appStateBytes !== undefined && object.appStateBytes !== null) { + message.appStateBytes = bytesFromBase64(object.appStateBytes); + } + if (object.initialHeight !== undefined && object.initialHeight !== null) { + message.initialHeight = Number(object.initialHeight); + } else { + message.initialHeight = 0; + } + return message; + }, + + toJSON(message: RequestInitChain): unknown { + const obj: any = {}; + message.time !== undefined && + (obj.time = + message.time !== undefined ? message.time.toISOString() : null); + message.chainId !== undefined && (obj.chainId = message.chainId); + message.consensusParams !== undefined && + (obj.consensusParams = message.consensusParams + ? ConsensusParams.toJSON(message.consensusParams) + : undefined); + if (message.validators) { + obj.validators = message.validators.map((e) => + e ? ValidatorUpdate.toJSON(e) : undefined + ); + } else { + obj.validators = []; + } + message.appStateBytes !== undefined && + (obj.appStateBytes = base64FromBytes( + message.appStateBytes !== undefined + ? message.appStateBytes + : new Uint8Array() + )); + message.initialHeight !== undefined && + (obj.initialHeight = message.initialHeight); + return obj; + }, + + fromPartial(object: DeepPartial): RequestInitChain { + const message = { ...baseRequestInitChain } as RequestInitChain; + message.validators = []; + if (object.time !== undefined && object.time !== null) { + message.time = object.time; + } else { + message.time = undefined; + } + if (object.chainId !== undefined && object.chainId !== null) { + message.chainId = object.chainId; + } else { + message.chainId = ""; + } + if ( + object.consensusParams !== undefined && + object.consensusParams !== null + ) { + message.consensusParams = ConsensusParams.fromPartial( + object.consensusParams + ); + } else { + message.consensusParams = undefined; + } + if (object.validators !== undefined && object.validators !== null) { + for (const e of object.validators) { + message.validators.push(ValidatorUpdate.fromPartial(e)); + } + } + if (object.appStateBytes !== undefined && object.appStateBytes !== null) { + message.appStateBytes = object.appStateBytes; + } else { + message.appStateBytes = new Uint8Array(); + } + if (object.initialHeight !== undefined && object.initialHeight !== null) { + message.initialHeight = object.initialHeight; + } else { + message.initialHeight = 0; + } + return message; + }, +}; + +const baseRequestQuery: object = { path: "", height: 0, prove: false }; + +export const RequestQuery = { + encode(message: RequestQuery, writer: Writer = Writer.create()): Writer { + if (message.data.length !== 0) { + writer.uint32(10).bytes(message.data); + } + if (message.path !== "") { + writer.uint32(18).string(message.path); + } + if (message.height !== 0) { + writer.uint32(24).int64(message.height); + } + if (message.prove === true) { + writer.uint32(32).bool(message.prove); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): RequestQuery { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseRequestQuery } as RequestQuery; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.data = reader.bytes(); + break; + case 2: + message.path = reader.string(); + break; + case 3: + message.height = longToNumber(reader.int64() as Long); + break; + case 4: + message.prove = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): RequestQuery { + const message = { ...baseRequestQuery } as RequestQuery; + if (object.data !== undefined && object.data !== null) { + message.data = bytesFromBase64(object.data); + } + if (object.path !== undefined && object.path !== null) { + message.path = String(object.path); + } else { + message.path = ""; + } + if (object.height !== undefined && object.height !== null) { + message.height = Number(object.height); + } else { + message.height = 0; + } + if (object.prove !== undefined && object.prove !== null) { + message.prove = Boolean(object.prove); + } else { + message.prove = false; + } + return message; + }, + + toJSON(message: RequestQuery): unknown { + const obj: any = {}; + message.data !== undefined && + (obj.data = base64FromBytes( + message.data !== undefined ? message.data : new Uint8Array() + )); + message.path !== undefined && (obj.path = message.path); + message.height !== undefined && (obj.height = message.height); + message.prove !== undefined && (obj.prove = message.prove); + return obj; + }, + + fromPartial(object: DeepPartial): RequestQuery { + const message = { ...baseRequestQuery } as RequestQuery; + if (object.data !== undefined && object.data !== null) { + message.data = object.data; + } else { + message.data = new Uint8Array(); + } + if (object.path !== undefined && object.path !== null) { + message.path = object.path; + } else { + message.path = ""; + } + if (object.height !== undefined && object.height !== null) { + message.height = object.height; + } else { + message.height = 0; + } + if (object.prove !== undefined && object.prove !== null) { + message.prove = object.prove; + } else { + message.prove = false; + } + return message; + }, +}; + +const baseRequestBeginBlock: object = {}; + +export const RequestBeginBlock = { + encode(message: RequestBeginBlock, writer: Writer = Writer.create()): Writer { + if (message.hash.length !== 0) { + writer.uint32(10).bytes(message.hash); + } + if (message.header !== undefined) { + Header.encode(message.header, writer.uint32(18).fork()).ldelim(); + } + if (message.lastCommitInfo !== undefined) { + LastCommitInfo.encode( + message.lastCommitInfo, + writer.uint32(26).fork() + ).ldelim(); + } + for (const v of message.byzantineValidators) { + Evidence.encode(v!, writer.uint32(34).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): RequestBeginBlock { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseRequestBeginBlock } as RequestBeginBlock; + message.byzantineValidators = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.hash = reader.bytes(); + break; + case 2: + message.header = Header.decode(reader, reader.uint32()); + break; + case 3: + message.lastCommitInfo = LastCommitInfo.decode( + reader, + reader.uint32() + ); + break; + case 4: + message.byzantineValidators.push( + Evidence.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): RequestBeginBlock { + const message = { ...baseRequestBeginBlock } as RequestBeginBlock; + message.byzantineValidators = []; + if (object.hash !== undefined && object.hash !== null) { + message.hash = bytesFromBase64(object.hash); + } + if (object.header !== undefined && object.header !== null) { + message.header = Header.fromJSON(object.header); + } else { + message.header = undefined; + } + if (object.lastCommitInfo !== undefined && object.lastCommitInfo !== null) { + message.lastCommitInfo = LastCommitInfo.fromJSON(object.lastCommitInfo); + } else { + message.lastCommitInfo = undefined; + } + if ( + object.byzantineValidators !== undefined && + object.byzantineValidators !== null + ) { + for (const e of object.byzantineValidators) { + message.byzantineValidators.push(Evidence.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: RequestBeginBlock): unknown { + const obj: any = {}; + message.hash !== undefined && + (obj.hash = base64FromBytes( + message.hash !== undefined ? message.hash : new Uint8Array() + )); + message.header !== undefined && + (obj.header = message.header ? Header.toJSON(message.header) : undefined); + message.lastCommitInfo !== undefined && + (obj.lastCommitInfo = message.lastCommitInfo + ? LastCommitInfo.toJSON(message.lastCommitInfo) + : undefined); + if (message.byzantineValidators) { + obj.byzantineValidators = message.byzantineValidators.map((e) => + e ? Evidence.toJSON(e) : undefined + ); + } else { + obj.byzantineValidators = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): RequestBeginBlock { + const message = { ...baseRequestBeginBlock } as RequestBeginBlock; + message.byzantineValidators = []; + if (object.hash !== undefined && object.hash !== null) { + message.hash = object.hash; + } else { + message.hash = new Uint8Array(); + } + if (object.header !== undefined && object.header !== null) { + message.header = Header.fromPartial(object.header); + } else { + message.header = undefined; + } + if (object.lastCommitInfo !== undefined && object.lastCommitInfo !== null) { + message.lastCommitInfo = LastCommitInfo.fromPartial( + object.lastCommitInfo + ); + } else { + message.lastCommitInfo = undefined; + } + if ( + object.byzantineValidators !== undefined && + object.byzantineValidators !== null + ) { + for (const e of object.byzantineValidators) { + message.byzantineValidators.push(Evidence.fromPartial(e)); + } + } + return message; + }, +}; + +const baseRequestCheckTx: object = { type: 0 }; + +export const RequestCheckTx = { + encode(message: RequestCheckTx, writer: Writer = Writer.create()): Writer { + if (message.tx.length !== 0) { + writer.uint32(10).bytes(message.tx); + } + if (message.type !== 0) { + writer.uint32(16).int32(message.type); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): RequestCheckTx { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseRequestCheckTx } as RequestCheckTx; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.tx = reader.bytes(); + break; + case 2: + message.type = reader.int32() as any; + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): RequestCheckTx { + const message = { ...baseRequestCheckTx } as RequestCheckTx; + if (object.tx !== undefined && object.tx !== null) { + message.tx = bytesFromBase64(object.tx); + } + if (object.type !== undefined && object.type !== null) { + message.type = checkTxTypeFromJSON(object.type); + } else { + message.type = 0; + } + return message; + }, + + toJSON(message: RequestCheckTx): unknown { + const obj: any = {}; + message.tx !== undefined && + (obj.tx = base64FromBytes( + message.tx !== undefined ? message.tx : new Uint8Array() + )); + message.type !== undefined && (obj.type = checkTxTypeToJSON(message.type)); + return obj; + }, + + fromPartial(object: DeepPartial): RequestCheckTx { + const message = { ...baseRequestCheckTx } as RequestCheckTx; + if (object.tx !== undefined && object.tx !== null) { + message.tx = object.tx; + } else { + message.tx = new Uint8Array(); + } + if (object.type !== undefined && object.type !== null) { + message.type = object.type; + } else { + message.type = 0; + } + return message; + }, +}; + +const baseRequestDeliverTx: object = {}; + +export const RequestDeliverTx = { + encode(message: RequestDeliverTx, writer: Writer = Writer.create()): Writer { + if (message.tx.length !== 0) { + writer.uint32(10).bytes(message.tx); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): RequestDeliverTx { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseRequestDeliverTx } as RequestDeliverTx; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.tx = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): RequestDeliverTx { + const message = { ...baseRequestDeliverTx } as RequestDeliverTx; + if (object.tx !== undefined && object.tx !== null) { + message.tx = bytesFromBase64(object.tx); + } + return message; + }, + + toJSON(message: RequestDeliverTx): unknown { + const obj: any = {}; + message.tx !== undefined && + (obj.tx = base64FromBytes( + message.tx !== undefined ? message.tx : new Uint8Array() + )); + return obj; + }, + + fromPartial(object: DeepPartial): RequestDeliverTx { + const message = { ...baseRequestDeliverTx } as RequestDeliverTx; + if (object.tx !== undefined && object.tx !== null) { + message.tx = object.tx; + } else { + message.tx = new Uint8Array(); + } + return message; + }, +}; + +const baseRequestEndBlock: object = { height: 0 }; + +export const RequestEndBlock = { + encode(message: RequestEndBlock, writer: Writer = Writer.create()): Writer { + if (message.height !== 0) { + writer.uint32(8).int64(message.height); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): RequestEndBlock { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseRequestEndBlock } as RequestEndBlock; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.height = longToNumber(reader.int64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): RequestEndBlock { + const message = { ...baseRequestEndBlock } as RequestEndBlock; + if (object.height !== undefined && object.height !== null) { + message.height = Number(object.height); + } else { + message.height = 0; + } + return message; + }, + + toJSON(message: RequestEndBlock): unknown { + const obj: any = {}; + message.height !== undefined && (obj.height = message.height); + return obj; + }, + + fromPartial(object: DeepPartial): RequestEndBlock { + const message = { ...baseRequestEndBlock } as RequestEndBlock; + if (object.height !== undefined && object.height !== null) { + message.height = object.height; + } else { + message.height = 0; + } + return message; + }, +}; + +const baseRequestCommit: object = {}; + +export const RequestCommit = { + encode(_: RequestCommit, writer: Writer = Writer.create()): Writer { + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): RequestCommit { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseRequestCommit } as RequestCommit; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): RequestCommit { + const message = { ...baseRequestCommit } as RequestCommit; + return message; + }, + + toJSON(_: RequestCommit): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial(_: DeepPartial): RequestCommit { + const message = { ...baseRequestCommit } as RequestCommit; + return message; + }, +}; + +const baseRequestListSnapshots: object = {}; + +export const RequestListSnapshots = { + encode(_: RequestListSnapshots, writer: Writer = Writer.create()): Writer { + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): RequestListSnapshots { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseRequestListSnapshots } as RequestListSnapshots; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): RequestListSnapshots { + const message = { ...baseRequestListSnapshots } as RequestListSnapshots; + return message; + }, + + toJSON(_: RequestListSnapshots): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial(_: DeepPartial): RequestListSnapshots { + const message = { ...baseRequestListSnapshots } as RequestListSnapshots; + return message; + }, +}; + +const baseRequestOfferSnapshot: object = {}; + +export const RequestOfferSnapshot = { + encode( + message: RequestOfferSnapshot, + writer: Writer = Writer.create() + ): Writer { + if (message.snapshot !== undefined) { + Snapshot.encode(message.snapshot, writer.uint32(10).fork()).ldelim(); + } + if (message.appHash.length !== 0) { + writer.uint32(18).bytes(message.appHash); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): RequestOfferSnapshot { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseRequestOfferSnapshot } as RequestOfferSnapshot; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.snapshot = Snapshot.decode(reader, reader.uint32()); + break; + case 2: + message.appHash = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): RequestOfferSnapshot { + const message = { ...baseRequestOfferSnapshot } as RequestOfferSnapshot; + if (object.snapshot !== undefined && object.snapshot !== null) { + message.snapshot = Snapshot.fromJSON(object.snapshot); + } else { + message.snapshot = undefined; + } + if (object.appHash !== undefined && object.appHash !== null) { + message.appHash = bytesFromBase64(object.appHash); + } + return message; + }, + + toJSON(message: RequestOfferSnapshot): unknown { + const obj: any = {}; + message.snapshot !== undefined && + (obj.snapshot = message.snapshot + ? Snapshot.toJSON(message.snapshot) + : undefined); + message.appHash !== undefined && + (obj.appHash = base64FromBytes( + message.appHash !== undefined ? message.appHash : new Uint8Array() + )); + return obj; + }, + + fromPartial(object: DeepPartial): RequestOfferSnapshot { + const message = { ...baseRequestOfferSnapshot } as RequestOfferSnapshot; + if (object.snapshot !== undefined && object.snapshot !== null) { + message.snapshot = Snapshot.fromPartial(object.snapshot); + } else { + message.snapshot = undefined; + } + if (object.appHash !== undefined && object.appHash !== null) { + message.appHash = object.appHash; + } else { + message.appHash = new Uint8Array(); + } + return message; + }, +}; + +const baseRequestLoadSnapshotChunk: object = { height: 0, format: 0, chunk: 0 }; + +export const RequestLoadSnapshotChunk = { + encode( + message: RequestLoadSnapshotChunk, + writer: Writer = Writer.create() + ): Writer { + if (message.height !== 0) { + writer.uint32(8).uint64(message.height); + } + if (message.format !== 0) { + writer.uint32(16).uint32(message.format); + } + if (message.chunk !== 0) { + writer.uint32(24).uint32(message.chunk); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): RequestLoadSnapshotChunk { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseRequestLoadSnapshotChunk, + } as RequestLoadSnapshotChunk; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.height = longToNumber(reader.uint64() as Long); + break; + case 2: + message.format = reader.uint32(); + break; + case 3: + message.chunk = reader.uint32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): RequestLoadSnapshotChunk { + const message = { + ...baseRequestLoadSnapshotChunk, + } as RequestLoadSnapshotChunk; + if (object.height !== undefined && object.height !== null) { + message.height = Number(object.height); + } else { + message.height = 0; + } + if (object.format !== undefined && object.format !== null) { + message.format = Number(object.format); + } else { + message.format = 0; + } + if (object.chunk !== undefined && object.chunk !== null) { + message.chunk = Number(object.chunk); + } else { + message.chunk = 0; + } + return message; + }, + + toJSON(message: RequestLoadSnapshotChunk): unknown { + const obj: any = {}; + message.height !== undefined && (obj.height = message.height); + message.format !== undefined && (obj.format = message.format); + message.chunk !== undefined && (obj.chunk = message.chunk); + return obj; + }, + + fromPartial( + object: DeepPartial + ): RequestLoadSnapshotChunk { + const message = { + ...baseRequestLoadSnapshotChunk, + } as RequestLoadSnapshotChunk; + if (object.height !== undefined && object.height !== null) { + message.height = object.height; + } else { + message.height = 0; + } + if (object.format !== undefined && object.format !== null) { + message.format = object.format; + } else { + message.format = 0; + } + if (object.chunk !== undefined && object.chunk !== null) { + message.chunk = object.chunk; + } else { + message.chunk = 0; + } + return message; + }, +}; + +const baseRequestApplySnapshotChunk: object = { index: 0, sender: "" }; + +export const RequestApplySnapshotChunk = { + encode( + message: RequestApplySnapshotChunk, + writer: Writer = Writer.create() + ): Writer { + if (message.index !== 0) { + writer.uint32(8).uint32(message.index); + } + if (message.chunk.length !== 0) { + writer.uint32(18).bytes(message.chunk); + } + if (message.sender !== "") { + writer.uint32(26).string(message.sender); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): RequestApplySnapshotChunk { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseRequestApplySnapshotChunk, + } as RequestApplySnapshotChunk; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.index = reader.uint32(); + break; + case 2: + message.chunk = reader.bytes(); + break; + case 3: + message.sender = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): RequestApplySnapshotChunk { + const message = { + ...baseRequestApplySnapshotChunk, + } as RequestApplySnapshotChunk; + if (object.index !== undefined && object.index !== null) { + message.index = Number(object.index); + } else { + message.index = 0; + } + if (object.chunk !== undefined && object.chunk !== null) { + message.chunk = bytesFromBase64(object.chunk); + } + if (object.sender !== undefined && object.sender !== null) { + message.sender = String(object.sender); + } else { + message.sender = ""; + } + return message; + }, + + toJSON(message: RequestApplySnapshotChunk): unknown { + const obj: any = {}; + message.index !== undefined && (obj.index = message.index); + message.chunk !== undefined && + (obj.chunk = base64FromBytes( + message.chunk !== undefined ? message.chunk : new Uint8Array() + )); + message.sender !== undefined && (obj.sender = message.sender); + return obj; + }, + + fromPartial( + object: DeepPartial + ): RequestApplySnapshotChunk { + const message = { + ...baseRequestApplySnapshotChunk, + } as RequestApplySnapshotChunk; + if (object.index !== undefined && object.index !== null) { + message.index = object.index; + } else { + message.index = 0; + } + if (object.chunk !== undefined && object.chunk !== null) { + message.chunk = object.chunk; + } else { + message.chunk = new Uint8Array(); + } + if (object.sender !== undefined && object.sender !== null) { + message.sender = object.sender; + } else { + message.sender = ""; + } + return message; + }, +}; + +const baseResponse: object = {}; + +export const Response = { + encode(message: Response, writer: Writer = Writer.create()): Writer { + if (message.exception !== undefined) { + ResponseException.encode( + message.exception, + writer.uint32(10).fork() + ).ldelim(); + } + if (message.echo !== undefined) { + ResponseEcho.encode(message.echo, writer.uint32(18).fork()).ldelim(); + } + if (message.flush !== undefined) { + ResponseFlush.encode(message.flush, writer.uint32(26).fork()).ldelim(); + } + if (message.info !== undefined) { + ResponseInfo.encode(message.info, writer.uint32(34).fork()).ldelim(); + } + if (message.setOption !== undefined) { + ResponseSetOption.encode( + message.setOption, + writer.uint32(42).fork() + ).ldelim(); + } + if (message.initChain !== undefined) { + ResponseInitChain.encode( + message.initChain, + writer.uint32(50).fork() + ).ldelim(); + } + if (message.query !== undefined) { + ResponseQuery.encode(message.query, writer.uint32(58).fork()).ldelim(); + } + if (message.beginBlock !== undefined) { + ResponseBeginBlock.encode( + message.beginBlock, + writer.uint32(66).fork() + ).ldelim(); + } + if (message.checkTx !== undefined) { + ResponseCheckTx.encode( + message.checkTx, + writer.uint32(74).fork() + ).ldelim(); + } + if (message.deliverTx !== undefined) { + ResponseDeliverTx.encode( + message.deliverTx, + writer.uint32(82).fork() + ).ldelim(); + } + if (message.endBlock !== undefined) { + ResponseEndBlock.encode( + message.endBlock, + writer.uint32(90).fork() + ).ldelim(); + } + if (message.commit !== undefined) { + ResponseCommit.encode(message.commit, writer.uint32(98).fork()).ldelim(); + } + if (message.listSnapshots !== undefined) { + ResponseListSnapshots.encode( + message.listSnapshots, + writer.uint32(106).fork() + ).ldelim(); + } + if (message.offerSnapshot !== undefined) { + ResponseOfferSnapshot.encode( + message.offerSnapshot, + writer.uint32(114).fork() + ).ldelim(); + } + if (message.loadSnapshotChunk !== undefined) { + ResponseLoadSnapshotChunk.encode( + message.loadSnapshotChunk, + writer.uint32(122).fork() + ).ldelim(); + } + if (message.applySnapshotChunk !== undefined) { + ResponseApplySnapshotChunk.encode( + message.applySnapshotChunk, + writer.uint32(130).fork() + ).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Response { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseResponse } as Response; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.exception = ResponseException.decode(reader, reader.uint32()); + break; + case 2: + message.echo = ResponseEcho.decode(reader, reader.uint32()); + break; + case 3: + message.flush = ResponseFlush.decode(reader, reader.uint32()); + break; + case 4: + message.info = ResponseInfo.decode(reader, reader.uint32()); + break; + case 5: + message.setOption = ResponseSetOption.decode(reader, reader.uint32()); + break; + case 6: + message.initChain = ResponseInitChain.decode(reader, reader.uint32()); + break; + case 7: + message.query = ResponseQuery.decode(reader, reader.uint32()); + break; + case 8: + message.beginBlock = ResponseBeginBlock.decode( + reader, + reader.uint32() + ); + break; + case 9: + message.checkTx = ResponseCheckTx.decode(reader, reader.uint32()); + break; + case 10: + message.deliverTx = ResponseDeliverTx.decode(reader, reader.uint32()); + break; + case 11: + message.endBlock = ResponseEndBlock.decode(reader, reader.uint32()); + break; + case 12: + message.commit = ResponseCommit.decode(reader, reader.uint32()); + break; + case 13: + message.listSnapshots = ResponseListSnapshots.decode( + reader, + reader.uint32() + ); + break; + case 14: + message.offerSnapshot = ResponseOfferSnapshot.decode( + reader, + reader.uint32() + ); + break; + case 15: + message.loadSnapshotChunk = ResponseLoadSnapshotChunk.decode( + reader, + reader.uint32() + ); + break; + case 16: + message.applySnapshotChunk = ResponseApplySnapshotChunk.decode( + reader, + reader.uint32() + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Response { + const message = { ...baseResponse } as Response; + if (object.exception !== undefined && object.exception !== null) { + message.exception = ResponseException.fromJSON(object.exception); + } else { + message.exception = undefined; + } + if (object.echo !== undefined && object.echo !== null) { + message.echo = ResponseEcho.fromJSON(object.echo); + } else { + message.echo = undefined; + } + if (object.flush !== undefined && object.flush !== null) { + message.flush = ResponseFlush.fromJSON(object.flush); + } else { + message.flush = undefined; + } + if (object.info !== undefined && object.info !== null) { + message.info = ResponseInfo.fromJSON(object.info); + } else { + message.info = undefined; + } + if (object.setOption !== undefined && object.setOption !== null) { + message.setOption = ResponseSetOption.fromJSON(object.setOption); + } else { + message.setOption = undefined; + } + if (object.initChain !== undefined && object.initChain !== null) { + message.initChain = ResponseInitChain.fromJSON(object.initChain); + } else { + message.initChain = undefined; + } + if (object.query !== undefined && object.query !== null) { + message.query = ResponseQuery.fromJSON(object.query); + } else { + message.query = undefined; + } + if (object.beginBlock !== undefined && object.beginBlock !== null) { + message.beginBlock = ResponseBeginBlock.fromJSON(object.beginBlock); + } else { + message.beginBlock = undefined; + } + if (object.checkTx !== undefined && object.checkTx !== null) { + message.checkTx = ResponseCheckTx.fromJSON(object.checkTx); + } else { + message.checkTx = undefined; + } + if (object.deliverTx !== undefined && object.deliverTx !== null) { + message.deliverTx = ResponseDeliverTx.fromJSON(object.deliverTx); + } else { + message.deliverTx = undefined; + } + if (object.endBlock !== undefined && object.endBlock !== null) { + message.endBlock = ResponseEndBlock.fromJSON(object.endBlock); + } else { + message.endBlock = undefined; + } + if (object.commit !== undefined && object.commit !== null) { + message.commit = ResponseCommit.fromJSON(object.commit); + } else { + message.commit = undefined; + } + if (object.listSnapshots !== undefined && object.listSnapshots !== null) { + message.listSnapshots = ResponseListSnapshots.fromJSON( + object.listSnapshots + ); + } else { + message.listSnapshots = undefined; + } + if (object.offerSnapshot !== undefined && object.offerSnapshot !== null) { + message.offerSnapshot = ResponseOfferSnapshot.fromJSON( + object.offerSnapshot + ); + } else { + message.offerSnapshot = undefined; + } + if ( + object.loadSnapshotChunk !== undefined && + object.loadSnapshotChunk !== null + ) { + message.loadSnapshotChunk = ResponseLoadSnapshotChunk.fromJSON( + object.loadSnapshotChunk + ); + } else { + message.loadSnapshotChunk = undefined; + } + if ( + object.applySnapshotChunk !== undefined && + object.applySnapshotChunk !== null + ) { + message.applySnapshotChunk = ResponseApplySnapshotChunk.fromJSON( + object.applySnapshotChunk + ); + } else { + message.applySnapshotChunk = undefined; + } + return message; + }, + + toJSON(message: Response): unknown { + const obj: any = {}; + message.exception !== undefined && + (obj.exception = message.exception + ? ResponseException.toJSON(message.exception) + : undefined); + message.echo !== undefined && + (obj.echo = message.echo ? ResponseEcho.toJSON(message.echo) : undefined); + message.flush !== undefined && + (obj.flush = message.flush + ? ResponseFlush.toJSON(message.flush) + : undefined); + message.info !== undefined && + (obj.info = message.info ? ResponseInfo.toJSON(message.info) : undefined); + message.setOption !== undefined && + (obj.setOption = message.setOption + ? ResponseSetOption.toJSON(message.setOption) + : undefined); + message.initChain !== undefined && + (obj.initChain = message.initChain + ? ResponseInitChain.toJSON(message.initChain) + : undefined); + message.query !== undefined && + (obj.query = message.query + ? ResponseQuery.toJSON(message.query) + : undefined); + message.beginBlock !== undefined && + (obj.beginBlock = message.beginBlock + ? ResponseBeginBlock.toJSON(message.beginBlock) + : undefined); + message.checkTx !== undefined && + (obj.checkTx = message.checkTx + ? ResponseCheckTx.toJSON(message.checkTx) + : undefined); + message.deliverTx !== undefined && + (obj.deliverTx = message.deliverTx + ? ResponseDeliverTx.toJSON(message.deliverTx) + : undefined); + message.endBlock !== undefined && + (obj.endBlock = message.endBlock + ? ResponseEndBlock.toJSON(message.endBlock) + : undefined); + message.commit !== undefined && + (obj.commit = message.commit + ? ResponseCommit.toJSON(message.commit) + : undefined); + message.listSnapshots !== undefined && + (obj.listSnapshots = message.listSnapshots + ? ResponseListSnapshots.toJSON(message.listSnapshots) + : undefined); + message.offerSnapshot !== undefined && + (obj.offerSnapshot = message.offerSnapshot + ? ResponseOfferSnapshot.toJSON(message.offerSnapshot) + : undefined); + message.loadSnapshotChunk !== undefined && + (obj.loadSnapshotChunk = message.loadSnapshotChunk + ? ResponseLoadSnapshotChunk.toJSON(message.loadSnapshotChunk) + : undefined); + message.applySnapshotChunk !== undefined && + (obj.applySnapshotChunk = message.applySnapshotChunk + ? ResponseApplySnapshotChunk.toJSON(message.applySnapshotChunk) + : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): Response { + const message = { ...baseResponse } as Response; + if (object.exception !== undefined && object.exception !== null) { + message.exception = ResponseException.fromPartial(object.exception); + } else { + message.exception = undefined; + } + if (object.echo !== undefined && object.echo !== null) { + message.echo = ResponseEcho.fromPartial(object.echo); + } else { + message.echo = undefined; + } + if (object.flush !== undefined && object.flush !== null) { + message.flush = ResponseFlush.fromPartial(object.flush); + } else { + message.flush = undefined; + } + if (object.info !== undefined && object.info !== null) { + message.info = ResponseInfo.fromPartial(object.info); + } else { + message.info = undefined; + } + if (object.setOption !== undefined && object.setOption !== null) { + message.setOption = ResponseSetOption.fromPartial(object.setOption); + } else { + message.setOption = undefined; + } + if (object.initChain !== undefined && object.initChain !== null) { + message.initChain = ResponseInitChain.fromPartial(object.initChain); + } else { + message.initChain = undefined; + } + if (object.query !== undefined && object.query !== null) { + message.query = ResponseQuery.fromPartial(object.query); + } else { + message.query = undefined; + } + if (object.beginBlock !== undefined && object.beginBlock !== null) { + message.beginBlock = ResponseBeginBlock.fromPartial(object.beginBlock); + } else { + message.beginBlock = undefined; + } + if (object.checkTx !== undefined && object.checkTx !== null) { + message.checkTx = ResponseCheckTx.fromPartial(object.checkTx); + } else { + message.checkTx = undefined; + } + if (object.deliverTx !== undefined && object.deliverTx !== null) { + message.deliverTx = ResponseDeliverTx.fromPartial(object.deliverTx); + } else { + message.deliverTx = undefined; + } + if (object.endBlock !== undefined && object.endBlock !== null) { + message.endBlock = ResponseEndBlock.fromPartial(object.endBlock); + } else { + message.endBlock = undefined; + } + if (object.commit !== undefined && object.commit !== null) { + message.commit = ResponseCommit.fromPartial(object.commit); + } else { + message.commit = undefined; + } + if (object.listSnapshots !== undefined && object.listSnapshots !== null) { + message.listSnapshots = ResponseListSnapshots.fromPartial( + object.listSnapshots + ); + } else { + message.listSnapshots = undefined; + } + if (object.offerSnapshot !== undefined && object.offerSnapshot !== null) { + message.offerSnapshot = ResponseOfferSnapshot.fromPartial( + object.offerSnapshot + ); + } else { + message.offerSnapshot = undefined; + } + if ( + object.loadSnapshotChunk !== undefined && + object.loadSnapshotChunk !== null + ) { + message.loadSnapshotChunk = ResponseLoadSnapshotChunk.fromPartial( + object.loadSnapshotChunk + ); + } else { + message.loadSnapshotChunk = undefined; + } + if ( + object.applySnapshotChunk !== undefined && + object.applySnapshotChunk !== null + ) { + message.applySnapshotChunk = ResponseApplySnapshotChunk.fromPartial( + object.applySnapshotChunk + ); + } else { + message.applySnapshotChunk = undefined; + } + return message; + }, +}; + +const baseResponseException: object = { error: "" }; + +export const ResponseException = { + encode(message: ResponseException, writer: Writer = Writer.create()): Writer { + if (message.error !== "") { + writer.uint32(10).string(message.error); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ResponseException { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseResponseException } as ResponseException; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.error = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ResponseException { + const message = { ...baseResponseException } as ResponseException; + if (object.error !== undefined && object.error !== null) { + message.error = String(object.error); + } else { + message.error = ""; + } + return message; + }, + + toJSON(message: ResponseException): unknown { + const obj: any = {}; + message.error !== undefined && (obj.error = message.error); + return obj; + }, + + fromPartial(object: DeepPartial): ResponseException { + const message = { ...baseResponseException } as ResponseException; + if (object.error !== undefined && object.error !== null) { + message.error = object.error; + } else { + message.error = ""; + } + return message; + }, +}; + +const baseResponseEcho: object = { message: "" }; + +export const ResponseEcho = { + encode(message: ResponseEcho, writer: Writer = Writer.create()): Writer { + if (message.message !== "") { + writer.uint32(10).string(message.message); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ResponseEcho { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseResponseEcho } as ResponseEcho; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.message = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ResponseEcho { + const message = { ...baseResponseEcho } as ResponseEcho; + if (object.message !== undefined && object.message !== null) { + message.message = String(object.message); + } else { + message.message = ""; + } + return message; + }, + + toJSON(message: ResponseEcho): unknown { + const obj: any = {}; + message.message !== undefined && (obj.message = message.message); + return obj; + }, + + fromPartial(object: DeepPartial): ResponseEcho { + const message = { ...baseResponseEcho } as ResponseEcho; + if (object.message !== undefined && object.message !== null) { + message.message = object.message; + } else { + message.message = ""; + } + return message; + }, +}; + +const baseResponseFlush: object = {}; + +export const ResponseFlush = { + encode(_: ResponseFlush, writer: Writer = Writer.create()): Writer { + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ResponseFlush { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseResponseFlush } as ResponseFlush; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): ResponseFlush { + const message = { ...baseResponseFlush } as ResponseFlush; + return message; + }, + + toJSON(_: ResponseFlush): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial(_: DeepPartial): ResponseFlush { + const message = { ...baseResponseFlush } as ResponseFlush; + return message; + }, +}; + +const baseResponseInfo: object = { + data: "", + version: "", + appVersion: 0, + lastBlockHeight: 0, +}; + +export const ResponseInfo = { + encode(message: ResponseInfo, writer: Writer = Writer.create()): Writer { + if (message.data !== "") { + writer.uint32(10).string(message.data); + } + if (message.version !== "") { + writer.uint32(18).string(message.version); + } + if (message.appVersion !== 0) { + writer.uint32(24).uint64(message.appVersion); + } + if (message.lastBlockHeight !== 0) { + writer.uint32(32).int64(message.lastBlockHeight); + } + if (message.lastBlockAppHash.length !== 0) { + writer.uint32(42).bytes(message.lastBlockAppHash); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ResponseInfo { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseResponseInfo } as ResponseInfo; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.data = reader.string(); + break; + case 2: + message.version = reader.string(); + break; + case 3: + message.appVersion = longToNumber(reader.uint64() as Long); + break; + case 4: + message.lastBlockHeight = longToNumber(reader.int64() as Long); + break; + case 5: + message.lastBlockAppHash = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ResponseInfo { + const message = { ...baseResponseInfo } as ResponseInfo; + if (object.data !== undefined && object.data !== null) { + message.data = String(object.data); + } else { + message.data = ""; + } + if (object.version !== undefined && object.version !== null) { + message.version = String(object.version); + } else { + message.version = ""; + } + if (object.appVersion !== undefined && object.appVersion !== null) { + message.appVersion = Number(object.appVersion); + } else { + message.appVersion = 0; + } + if ( + object.lastBlockHeight !== undefined && + object.lastBlockHeight !== null + ) { + message.lastBlockHeight = Number(object.lastBlockHeight); + } else { + message.lastBlockHeight = 0; + } + if ( + object.lastBlockAppHash !== undefined && + object.lastBlockAppHash !== null + ) { + message.lastBlockAppHash = bytesFromBase64(object.lastBlockAppHash); + } + return message; + }, + + toJSON(message: ResponseInfo): unknown { + const obj: any = {}; + message.data !== undefined && (obj.data = message.data); + message.version !== undefined && (obj.version = message.version); + message.appVersion !== undefined && (obj.appVersion = message.appVersion); + message.lastBlockHeight !== undefined && + (obj.lastBlockHeight = message.lastBlockHeight); + message.lastBlockAppHash !== undefined && + (obj.lastBlockAppHash = base64FromBytes( + message.lastBlockAppHash !== undefined + ? message.lastBlockAppHash + : new Uint8Array() + )); + return obj; + }, + + fromPartial(object: DeepPartial): ResponseInfo { + const message = { ...baseResponseInfo } as ResponseInfo; + if (object.data !== undefined && object.data !== null) { + message.data = object.data; + } else { + message.data = ""; + } + if (object.version !== undefined && object.version !== null) { + message.version = object.version; + } else { + message.version = ""; + } + if (object.appVersion !== undefined && object.appVersion !== null) { + message.appVersion = object.appVersion; + } else { + message.appVersion = 0; + } + if ( + object.lastBlockHeight !== undefined && + object.lastBlockHeight !== null + ) { + message.lastBlockHeight = object.lastBlockHeight; + } else { + message.lastBlockHeight = 0; + } + if ( + object.lastBlockAppHash !== undefined && + object.lastBlockAppHash !== null + ) { + message.lastBlockAppHash = object.lastBlockAppHash; + } else { + message.lastBlockAppHash = new Uint8Array(); + } + return message; + }, +}; + +const baseResponseSetOption: object = { code: 0, log: "", info: "" }; + +export const ResponseSetOption = { + encode(message: ResponseSetOption, writer: Writer = Writer.create()): Writer { + if (message.code !== 0) { + writer.uint32(8).uint32(message.code); + } + if (message.log !== "") { + writer.uint32(26).string(message.log); + } + if (message.info !== "") { + writer.uint32(34).string(message.info); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ResponseSetOption { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseResponseSetOption } as ResponseSetOption; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.code = reader.uint32(); + break; + case 3: + message.log = reader.string(); + break; + case 4: + message.info = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ResponseSetOption { + const message = { ...baseResponseSetOption } as ResponseSetOption; + if (object.code !== undefined && object.code !== null) { + message.code = Number(object.code); + } else { + message.code = 0; + } + if (object.log !== undefined && object.log !== null) { + message.log = String(object.log); + } else { + message.log = ""; + } + if (object.info !== undefined && object.info !== null) { + message.info = String(object.info); + } else { + message.info = ""; + } + return message; + }, + + toJSON(message: ResponseSetOption): unknown { + const obj: any = {}; + message.code !== undefined && (obj.code = message.code); + message.log !== undefined && (obj.log = message.log); + message.info !== undefined && (obj.info = message.info); + return obj; + }, + + fromPartial(object: DeepPartial): ResponseSetOption { + const message = { ...baseResponseSetOption } as ResponseSetOption; + if (object.code !== undefined && object.code !== null) { + message.code = object.code; + } else { + message.code = 0; + } + if (object.log !== undefined && object.log !== null) { + message.log = object.log; + } else { + message.log = ""; + } + if (object.info !== undefined && object.info !== null) { + message.info = object.info; + } else { + message.info = ""; + } + return message; + }, +}; + +const baseResponseInitChain: object = {}; + +export const ResponseInitChain = { + encode(message: ResponseInitChain, writer: Writer = Writer.create()): Writer { + if (message.consensusParams !== undefined) { + ConsensusParams.encode( + message.consensusParams, + writer.uint32(10).fork() + ).ldelim(); + } + for (const v of message.validators) { + ValidatorUpdate.encode(v!, writer.uint32(18).fork()).ldelim(); + } + if (message.appHash.length !== 0) { + writer.uint32(26).bytes(message.appHash); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ResponseInitChain { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseResponseInitChain } as ResponseInitChain; + message.validators = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.consensusParams = ConsensusParams.decode( + reader, + reader.uint32() + ); + break; + case 2: + message.validators.push( + ValidatorUpdate.decode(reader, reader.uint32()) + ); + break; + case 3: + message.appHash = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ResponseInitChain { + const message = { ...baseResponseInitChain } as ResponseInitChain; + message.validators = []; + if ( + object.consensusParams !== undefined && + object.consensusParams !== null + ) { + message.consensusParams = ConsensusParams.fromJSON( + object.consensusParams + ); + } else { + message.consensusParams = undefined; + } + if (object.validators !== undefined && object.validators !== null) { + for (const e of object.validators) { + message.validators.push(ValidatorUpdate.fromJSON(e)); + } + } + if (object.appHash !== undefined && object.appHash !== null) { + message.appHash = bytesFromBase64(object.appHash); + } + return message; + }, + + toJSON(message: ResponseInitChain): unknown { + const obj: any = {}; + message.consensusParams !== undefined && + (obj.consensusParams = message.consensusParams + ? ConsensusParams.toJSON(message.consensusParams) + : undefined); + if (message.validators) { + obj.validators = message.validators.map((e) => + e ? ValidatorUpdate.toJSON(e) : undefined + ); + } else { + obj.validators = []; + } + message.appHash !== undefined && + (obj.appHash = base64FromBytes( + message.appHash !== undefined ? message.appHash : new Uint8Array() + )); + return obj; + }, + + fromPartial(object: DeepPartial): ResponseInitChain { + const message = { ...baseResponseInitChain } as ResponseInitChain; + message.validators = []; + if ( + object.consensusParams !== undefined && + object.consensusParams !== null + ) { + message.consensusParams = ConsensusParams.fromPartial( + object.consensusParams + ); + } else { + message.consensusParams = undefined; + } + if (object.validators !== undefined && object.validators !== null) { + for (const e of object.validators) { + message.validators.push(ValidatorUpdate.fromPartial(e)); + } + } + if (object.appHash !== undefined && object.appHash !== null) { + message.appHash = object.appHash; + } else { + message.appHash = new Uint8Array(); + } + return message; + }, +}; + +const baseResponseQuery: object = { + code: 0, + log: "", + info: "", + index: 0, + height: 0, + codespace: "", +}; + +export const ResponseQuery = { + encode(message: ResponseQuery, writer: Writer = Writer.create()): Writer { + if (message.code !== 0) { + writer.uint32(8).uint32(message.code); + } + if (message.log !== "") { + writer.uint32(26).string(message.log); + } + if (message.info !== "") { + writer.uint32(34).string(message.info); + } + if (message.index !== 0) { + writer.uint32(40).int64(message.index); + } + if (message.key.length !== 0) { + writer.uint32(50).bytes(message.key); + } + if (message.value.length !== 0) { + writer.uint32(58).bytes(message.value); + } + if (message.proofOps !== undefined) { + ProofOps.encode(message.proofOps, writer.uint32(66).fork()).ldelim(); + } + if (message.height !== 0) { + writer.uint32(72).int64(message.height); + } + if (message.codespace !== "") { + writer.uint32(82).string(message.codespace); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ResponseQuery { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseResponseQuery } as ResponseQuery; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.code = reader.uint32(); + break; + case 3: + message.log = reader.string(); + break; + case 4: + message.info = reader.string(); + break; + case 5: + message.index = longToNumber(reader.int64() as Long); + break; + case 6: + message.key = reader.bytes(); + break; + case 7: + message.value = reader.bytes(); + break; + case 8: + message.proofOps = ProofOps.decode(reader, reader.uint32()); + break; + case 9: + message.height = longToNumber(reader.int64() as Long); + break; + case 10: + message.codespace = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ResponseQuery { + const message = { ...baseResponseQuery } as ResponseQuery; + if (object.code !== undefined && object.code !== null) { + message.code = Number(object.code); + } else { + message.code = 0; + } + if (object.log !== undefined && object.log !== null) { + message.log = String(object.log); + } else { + message.log = ""; + } + if (object.info !== undefined && object.info !== null) { + message.info = String(object.info); + } else { + message.info = ""; + } + if (object.index !== undefined && object.index !== null) { + message.index = Number(object.index); + } else { + message.index = 0; + } + if (object.key !== undefined && object.key !== null) { + message.key = bytesFromBase64(object.key); + } + if (object.value !== undefined && object.value !== null) { + message.value = bytesFromBase64(object.value); + } + if (object.proofOps !== undefined && object.proofOps !== null) { + message.proofOps = ProofOps.fromJSON(object.proofOps); + } else { + message.proofOps = undefined; + } + if (object.height !== undefined && object.height !== null) { + message.height = Number(object.height); + } else { + message.height = 0; + } + if (object.codespace !== undefined && object.codespace !== null) { + message.codespace = String(object.codespace); + } else { + message.codespace = ""; + } + return message; + }, + + toJSON(message: ResponseQuery): unknown { + const obj: any = {}; + message.code !== undefined && (obj.code = message.code); + message.log !== undefined && (obj.log = message.log); + message.info !== undefined && (obj.info = message.info); + message.index !== undefined && (obj.index = message.index); + message.key !== undefined && + (obj.key = base64FromBytes( + message.key !== undefined ? message.key : new Uint8Array() + )); + message.value !== undefined && + (obj.value = base64FromBytes( + message.value !== undefined ? message.value : new Uint8Array() + )); + message.proofOps !== undefined && + (obj.proofOps = message.proofOps + ? ProofOps.toJSON(message.proofOps) + : undefined); + message.height !== undefined && (obj.height = message.height); + message.codespace !== undefined && (obj.codespace = message.codespace); + return obj; + }, + + fromPartial(object: DeepPartial): ResponseQuery { + const message = { ...baseResponseQuery } as ResponseQuery; + if (object.code !== undefined && object.code !== null) { + message.code = object.code; + } else { + message.code = 0; + } + if (object.log !== undefined && object.log !== null) { + message.log = object.log; + } else { + message.log = ""; + } + if (object.info !== undefined && object.info !== null) { + message.info = object.info; + } else { + message.info = ""; + } + if (object.index !== undefined && object.index !== null) { + message.index = object.index; + } else { + message.index = 0; + } + if (object.key !== undefined && object.key !== null) { + message.key = object.key; + } else { + message.key = new Uint8Array(); + } + if (object.value !== undefined && object.value !== null) { + message.value = object.value; + } else { + message.value = new Uint8Array(); + } + if (object.proofOps !== undefined && object.proofOps !== null) { + message.proofOps = ProofOps.fromPartial(object.proofOps); + } else { + message.proofOps = undefined; + } + if (object.height !== undefined && object.height !== null) { + message.height = object.height; + } else { + message.height = 0; + } + if (object.codespace !== undefined && object.codespace !== null) { + message.codespace = object.codespace; + } else { + message.codespace = ""; + } + return message; + }, +}; + +const baseResponseBeginBlock: object = {}; + +export const ResponseBeginBlock = { + encode( + message: ResponseBeginBlock, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.events) { + Event.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ResponseBeginBlock { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseResponseBeginBlock } as ResponseBeginBlock; + message.events = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.events.push(Event.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ResponseBeginBlock { + const message = { ...baseResponseBeginBlock } as ResponseBeginBlock; + message.events = []; + if (object.events !== undefined && object.events !== null) { + for (const e of object.events) { + message.events.push(Event.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: ResponseBeginBlock): unknown { + const obj: any = {}; + if (message.events) { + obj.events = message.events.map((e) => (e ? Event.toJSON(e) : undefined)); + } else { + obj.events = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): ResponseBeginBlock { + const message = { ...baseResponseBeginBlock } as ResponseBeginBlock; + message.events = []; + if (object.events !== undefined && object.events !== null) { + for (const e of object.events) { + message.events.push(Event.fromPartial(e)); + } + } + return message; + }, +}; + +const baseResponseCheckTx: object = { + code: 0, + log: "", + info: "", + gasWanted: 0, + gasUsed: 0, + codespace: "", + sender: "", + priority: 0, + mempoolError: "", +}; + +export const ResponseCheckTx = { + encode(message: ResponseCheckTx, writer: Writer = Writer.create()): Writer { + if (message.code !== 0) { + writer.uint32(8).uint32(message.code); + } + if (message.data.length !== 0) { + writer.uint32(18).bytes(message.data); + } + if (message.log !== "") { + writer.uint32(26).string(message.log); + } + if (message.info !== "") { + writer.uint32(34).string(message.info); + } + if (message.gasWanted !== 0) { + writer.uint32(40).int64(message.gasWanted); + } + if (message.gasUsed !== 0) { + writer.uint32(48).int64(message.gasUsed); + } + for (const v of message.events) { + Event.encode(v!, writer.uint32(58).fork()).ldelim(); + } + if (message.codespace !== "") { + writer.uint32(66).string(message.codespace); + } + if (message.sender !== "") { + writer.uint32(74).string(message.sender); + } + if (message.priority !== 0) { + writer.uint32(80).int64(message.priority); + } + if (message.mempoolError !== "") { + writer.uint32(90).string(message.mempoolError); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ResponseCheckTx { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseResponseCheckTx } as ResponseCheckTx; + message.events = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.code = reader.uint32(); + break; + case 2: + message.data = reader.bytes(); + break; + case 3: + message.log = reader.string(); + break; + case 4: + message.info = reader.string(); + break; + case 5: + message.gasWanted = longToNumber(reader.int64() as Long); + break; + case 6: + message.gasUsed = longToNumber(reader.int64() as Long); + break; + case 7: + message.events.push(Event.decode(reader, reader.uint32())); + break; + case 8: + message.codespace = reader.string(); + break; + case 9: + message.sender = reader.string(); + break; + case 10: + message.priority = longToNumber(reader.int64() as Long); + break; + case 11: + message.mempoolError = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ResponseCheckTx { + const message = { ...baseResponseCheckTx } as ResponseCheckTx; + message.events = []; + if (object.code !== undefined && object.code !== null) { + message.code = Number(object.code); + } else { + message.code = 0; + } + if (object.data !== undefined && object.data !== null) { + message.data = bytesFromBase64(object.data); + } + if (object.log !== undefined && object.log !== null) { + message.log = String(object.log); + } else { + message.log = ""; + } + if (object.info !== undefined && object.info !== null) { + message.info = String(object.info); + } else { + message.info = ""; + } + if (object.gasWanted !== undefined && object.gasWanted !== null) { + message.gasWanted = Number(object.gasWanted); + } else { + message.gasWanted = 0; + } + if (object.gasUsed !== undefined && object.gasUsed !== null) { + message.gasUsed = Number(object.gasUsed); + } else { + message.gasUsed = 0; + } + if (object.events !== undefined && object.events !== null) { + for (const e of object.events) { + message.events.push(Event.fromJSON(e)); + } + } + if (object.codespace !== undefined && object.codespace !== null) { + message.codespace = String(object.codespace); + } else { + message.codespace = ""; + } + if (object.sender !== undefined && object.sender !== null) { + message.sender = String(object.sender); + } else { + message.sender = ""; + } + if (object.priority !== undefined && object.priority !== null) { + message.priority = Number(object.priority); + } else { + message.priority = 0; + } + if (object.mempoolError !== undefined && object.mempoolError !== null) { + message.mempoolError = String(object.mempoolError); + } else { + message.mempoolError = ""; + } + return message; + }, + + toJSON(message: ResponseCheckTx): unknown { + const obj: any = {}; + message.code !== undefined && (obj.code = message.code); + message.data !== undefined && + (obj.data = base64FromBytes( + message.data !== undefined ? message.data : new Uint8Array() + )); + message.log !== undefined && (obj.log = message.log); + message.info !== undefined && (obj.info = message.info); + message.gasWanted !== undefined && (obj.gasWanted = message.gasWanted); + message.gasUsed !== undefined && (obj.gasUsed = message.gasUsed); + if (message.events) { + obj.events = message.events.map((e) => (e ? Event.toJSON(e) : undefined)); + } else { + obj.events = []; + } + message.codespace !== undefined && (obj.codespace = message.codespace); + message.sender !== undefined && (obj.sender = message.sender); + message.priority !== undefined && (obj.priority = message.priority); + message.mempoolError !== undefined && + (obj.mempoolError = message.mempoolError); + return obj; + }, + + fromPartial(object: DeepPartial): ResponseCheckTx { + const message = { ...baseResponseCheckTx } as ResponseCheckTx; + message.events = []; + if (object.code !== undefined && object.code !== null) { + message.code = object.code; + } else { + message.code = 0; + } + if (object.data !== undefined && object.data !== null) { + message.data = object.data; + } else { + message.data = new Uint8Array(); + } + if (object.log !== undefined && object.log !== null) { + message.log = object.log; + } else { + message.log = ""; + } + if (object.info !== undefined && object.info !== null) { + message.info = object.info; + } else { + message.info = ""; + } + if (object.gasWanted !== undefined && object.gasWanted !== null) { + message.gasWanted = object.gasWanted; + } else { + message.gasWanted = 0; + } + if (object.gasUsed !== undefined && object.gasUsed !== null) { + message.gasUsed = object.gasUsed; + } else { + message.gasUsed = 0; + } + if (object.events !== undefined && object.events !== null) { + for (const e of object.events) { + message.events.push(Event.fromPartial(e)); + } + } + if (object.codespace !== undefined && object.codespace !== null) { + message.codespace = object.codespace; + } else { + message.codespace = ""; + } + if (object.sender !== undefined && object.sender !== null) { + message.sender = object.sender; + } else { + message.sender = ""; + } + if (object.priority !== undefined && object.priority !== null) { + message.priority = object.priority; + } else { + message.priority = 0; + } + if (object.mempoolError !== undefined && object.mempoolError !== null) { + message.mempoolError = object.mempoolError; + } else { + message.mempoolError = ""; + } + return message; + }, +}; + +const baseResponseDeliverTx: object = { + code: 0, + log: "", + info: "", + gasWanted: 0, + gasUsed: 0, + codespace: "", +}; + +export const ResponseDeliverTx = { + encode(message: ResponseDeliverTx, writer: Writer = Writer.create()): Writer { + if (message.code !== 0) { + writer.uint32(8).uint32(message.code); + } + if (message.data.length !== 0) { + writer.uint32(18).bytes(message.data); + } + if (message.log !== "") { + writer.uint32(26).string(message.log); + } + if (message.info !== "") { + writer.uint32(34).string(message.info); + } + if (message.gasWanted !== 0) { + writer.uint32(40).int64(message.gasWanted); + } + if (message.gasUsed !== 0) { + writer.uint32(48).int64(message.gasUsed); + } + for (const v of message.events) { + Event.encode(v!, writer.uint32(58).fork()).ldelim(); + } + if (message.codespace !== "") { + writer.uint32(66).string(message.codespace); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ResponseDeliverTx { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseResponseDeliverTx } as ResponseDeliverTx; + message.events = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.code = reader.uint32(); + break; + case 2: + message.data = reader.bytes(); + break; + case 3: + message.log = reader.string(); + break; + case 4: + message.info = reader.string(); + break; + case 5: + message.gasWanted = longToNumber(reader.int64() as Long); + break; + case 6: + message.gasUsed = longToNumber(reader.int64() as Long); + break; + case 7: + message.events.push(Event.decode(reader, reader.uint32())); + break; + case 8: + message.codespace = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ResponseDeliverTx { + const message = { ...baseResponseDeliverTx } as ResponseDeliverTx; + message.events = []; + if (object.code !== undefined && object.code !== null) { + message.code = Number(object.code); + } else { + message.code = 0; + } + if (object.data !== undefined && object.data !== null) { + message.data = bytesFromBase64(object.data); + } + if (object.log !== undefined && object.log !== null) { + message.log = String(object.log); + } else { + message.log = ""; + } + if (object.info !== undefined && object.info !== null) { + message.info = String(object.info); + } else { + message.info = ""; + } + if (object.gasWanted !== undefined && object.gasWanted !== null) { + message.gasWanted = Number(object.gasWanted); + } else { + message.gasWanted = 0; + } + if (object.gasUsed !== undefined && object.gasUsed !== null) { + message.gasUsed = Number(object.gasUsed); + } else { + message.gasUsed = 0; + } + if (object.events !== undefined && object.events !== null) { + for (const e of object.events) { + message.events.push(Event.fromJSON(e)); + } + } + if (object.codespace !== undefined && object.codespace !== null) { + message.codespace = String(object.codespace); + } else { + message.codespace = ""; + } + return message; + }, + + toJSON(message: ResponseDeliverTx): unknown { + const obj: any = {}; + message.code !== undefined && (obj.code = message.code); + message.data !== undefined && + (obj.data = base64FromBytes( + message.data !== undefined ? message.data : new Uint8Array() + )); + message.log !== undefined && (obj.log = message.log); + message.info !== undefined && (obj.info = message.info); + message.gasWanted !== undefined && (obj.gasWanted = message.gasWanted); + message.gasUsed !== undefined && (obj.gasUsed = message.gasUsed); + if (message.events) { + obj.events = message.events.map((e) => (e ? Event.toJSON(e) : undefined)); + } else { + obj.events = []; + } + message.codespace !== undefined && (obj.codespace = message.codespace); + return obj; + }, + + fromPartial(object: DeepPartial): ResponseDeliverTx { + const message = { ...baseResponseDeliverTx } as ResponseDeliverTx; + message.events = []; + if (object.code !== undefined && object.code !== null) { + message.code = object.code; + } else { + message.code = 0; + } + if (object.data !== undefined && object.data !== null) { + message.data = object.data; + } else { + message.data = new Uint8Array(); + } + if (object.log !== undefined && object.log !== null) { + message.log = object.log; + } else { + message.log = ""; + } + if (object.info !== undefined && object.info !== null) { + message.info = object.info; + } else { + message.info = ""; + } + if (object.gasWanted !== undefined && object.gasWanted !== null) { + message.gasWanted = object.gasWanted; + } else { + message.gasWanted = 0; + } + if (object.gasUsed !== undefined && object.gasUsed !== null) { + message.gasUsed = object.gasUsed; + } else { + message.gasUsed = 0; + } + if (object.events !== undefined && object.events !== null) { + for (const e of object.events) { + message.events.push(Event.fromPartial(e)); + } + } + if (object.codespace !== undefined && object.codespace !== null) { + message.codespace = object.codespace; + } else { + message.codespace = ""; + } + return message; + }, +}; + +const baseResponseEndBlock: object = {}; + +export const ResponseEndBlock = { + encode(message: ResponseEndBlock, writer: Writer = Writer.create()): Writer { + for (const v of message.validatorUpdates) { + ValidatorUpdate.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.consensusParamUpdates !== undefined) { + ConsensusParams.encode( + message.consensusParamUpdates, + writer.uint32(18).fork() + ).ldelim(); + } + for (const v of message.events) { + Event.encode(v!, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ResponseEndBlock { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseResponseEndBlock } as ResponseEndBlock; + message.validatorUpdates = []; + message.events = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.validatorUpdates.push( + ValidatorUpdate.decode(reader, reader.uint32()) + ); + break; + case 2: + message.consensusParamUpdates = ConsensusParams.decode( + reader, + reader.uint32() + ); + break; + case 3: + message.events.push(Event.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ResponseEndBlock { + const message = { ...baseResponseEndBlock } as ResponseEndBlock; + message.validatorUpdates = []; + message.events = []; + if ( + object.validatorUpdates !== undefined && + object.validatorUpdates !== null + ) { + for (const e of object.validatorUpdates) { + message.validatorUpdates.push(ValidatorUpdate.fromJSON(e)); + } + } + if ( + object.consensusParamUpdates !== undefined && + object.consensusParamUpdates !== null + ) { + message.consensusParamUpdates = ConsensusParams.fromJSON( + object.consensusParamUpdates + ); + } else { + message.consensusParamUpdates = undefined; + } + if (object.events !== undefined && object.events !== null) { + for (const e of object.events) { + message.events.push(Event.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: ResponseEndBlock): unknown { + const obj: any = {}; + if (message.validatorUpdates) { + obj.validatorUpdates = message.validatorUpdates.map((e) => + e ? ValidatorUpdate.toJSON(e) : undefined + ); + } else { + obj.validatorUpdates = []; + } + message.consensusParamUpdates !== undefined && + (obj.consensusParamUpdates = message.consensusParamUpdates + ? ConsensusParams.toJSON(message.consensusParamUpdates) + : undefined); + if (message.events) { + obj.events = message.events.map((e) => (e ? Event.toJSON(e) : undefined)); + } else { + obj.events = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): ResponseEndBlock { + const message = { ...baseResponseEndBlock } as ResponseEndBlock; + message.validatorUpdates = []; + message.events = []; + if ( + object.validatorUpdates !== undefined && + object.validatorUpdates !== null + ) { + for (const e of object.validatorUpdates) { + message.validatorUpdates.push(ValidatorUpdate.fromPartial(e)); + } + } + if ( + object.consensusParamUpdates !== undefined && + object.consensusParamUpdates !== null + ) { + message.consensusParamUpdates = ConsensusParams.fromPartial( + object.consensusParamUpdates + ); + } else { + message.consensusParamUpdates = undefined; + } + if (object.events !== undefined && object.events !== null) { + for (const e of object.events) { + message.events.push(Event.fromPartial(e)); + } + } + return message; + }, +}; + +const baseResponseCommit: object = { retainHeight: 0 }; + +export const ResponseCommit = { + encode(message: ResponseCommit, writer: Writer = Writer.create()): Writer { + if (message.data.length !== 0) { + writer.uint32(18).bytes(message.data); + } + if (message.retainHeight !== 0) { + writer.uint32(24).int64(message.retainHeight); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ResponseCommit { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseResponseCommit } as ResponseCommit; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + message.data = reader.bytes(); + break; + case 3: + message.retainHeight = longToNumber(reader.int64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ResponseCommit { + const message = { ...baseResponseCommit } as ResponseCommit; + if (object.data !== undefined && object.data !== null) { + message.data = bytesFromBase64(object.data); + } + if (object.retainHeight !== undefined && object.retainHeight !== null) { + message.retainHeight = Number(object.retainHeight); + } else { + message.retainHeight = 0; + } + return message; + }, + + toJSON(message: ResponseCommit): unknown { + const obj: any = {}; + message.data !== undefined && + (obj.data = base64FromBytes( + message.data !== undefined ? message.data : new Uint8Array() + )); + message.retainHeight !== undefined && + (obj.retainHeight = message.retainHeight); + return obj; + }, + + fromPartial(object: DeepPartial): ResponseCommit { + const message = { ...baseResponseCommit } as ResponseCommit; + if (object.data !== undefined && object.data !== null) { + message.data = object.data; + } else { + message.data = new Uint8Array(); + } + if (object.retainHeight !== undefined && object.retainHeight !== null) { + message.retainHeight = object.retainHeight; + } else { + message.retainHeight = 0; + } + return message; + }, +}; + +const baseResponseListSnapshots: object = {}; + +export const ResponseListSnapshots = { + encode( + message: ResponseListSnapshots, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.snapshots) { + Snapshot.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ResponseListSnapshots { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseResponseListSnapshots } as ResponseListSnapshots; + message.snapshots = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.snapshots.push(Snapshot.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ResponseListSnapshots { + const message = { ...baseResponseListSnapshots } as ResponseListSnapshots; + message.snapshots = []; + if (object.snapshots !== undefined && object.snapshots !== null) { + for (const e of object.snapshots) { + message.snapshots.push(Snapshot.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: ResponseListSnapshots): unknown { + const obj: any = {}; + if (message.snapshots) { + obj.snapshots = message.snapshots.map((e) => + e ? Snapshot.toJSON(e) : undefined + ); + } else { + obj.snapshots = []; + } + return obj; + }, + + fromPartial( + object: DeepPartial + ): ResponseListSnapshots { + const message = { ...baseResponseListSnapshots } as ResponseListSnapshots; + message.snapshots = []; + if (object.snapshots !== undefined && object.snapshots !== null) { + for (const e of object.snapshots) { + message.snapshots.push(Snapshot.fromPartial(e)); + } + } + return message; + }, +}; + +const baseResponseOfferSnapshot: object = { result: 0 }; + +export const ResponseOfferSnapshot = { + encode( + message: ResponseOfferSnapshot, + writer: Writer = Writer.create() + ): Writer { + if (message.result !== 0) { + writer.uint32(8).int32(message.result); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ResponseOfferSnapshot { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseResponseOfferSnapshot } as ResponseOfferSnapshot; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.result = reader.int32() as any; + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ResponseOfferSnapshot { + const message = { ...baseResponseOfferSnapshot } as ResponseOfferSnapshot; + if (object.result !== undefined && object.result !== null) { + message.result = responseOfferSnapshot_ResultFromJSON(object.result); + } else { + message.result = 0; + } + return message; + }, + + toJSON(message: ResponseOfferSnapshot): unknown { + const obj: any = {}; + message.result !== undefined && + (obj.result = responseOfferSnapshot_ResultToJSON(message.result)); + return obj; + }, + + fromPartial( + object: DeepPartial + ): ResponseOfferSnapshot { + const message = { ...baseResponseOfferSnapshot } as ResponseOfferSnapshot; + if (object.result !== undefined && object.result !== null) { + message.result = object.result; + } else { + message.result = 0; + } + return message; + }, +}; + +const baseResponseLoadSnapshotChunk: object = {}; + +export const ResponseLoadSnapshotChunk = { + encode( + message: ResponseLoadSnapshotChunk, + writer: Writer = Writer.create() + ): Writer { + if (message.chunk.length !== 0) { + writer.uint32(10).bytes(message.chunk); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): ResponseLoadSnapshotChunk { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseResponseLoadSnapshotChunk, + } as ResponseLoadSnapshotChunk; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.chunk = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ResponseLoadSnapshotChunk { + const message = { + ...baseResponseLoadSnapshotChunk, + } as ResponseLoadSnapshotChunk; + if (object.chunk !== undefined && object.chunk !== null) { + message.chunk = bytesFromBase64(object.chunk); + } + return message; + }, + + toJSON(message: ResponseLoadSnapshotChunk): unknown { + const obj: any = {}; + message.chunk !== undefined && + (obj.chunk = base64FromBytes( + message.chunk !== undefined ? message.chunk : new Uint8Array() + )); + return obj; + }, + + fromPartial( + object: DeepPartial + ): ResponseLoadSnapshotChunk { + const message = { + ...baseResponseLoadSnapshotChunk, + } as ResponseLoadSnapshotChunk; + if (object.chunk !== undefined && object.chunk !== null) { + message.chunk = object.chunk; + } else { + message.chunk = new Uint8Array(); + } + return message; + }, +}; + +const baseResponseApplySnapshotChunk: object = { + result: 0, + refetchChunks: 0, + rejectSenders: "", +}; + +export const ResponseApplySnapshotChunk = { + encode( + message: ResponseApplySnapshotChunk, + writer: Writer = Writer.create() + ): Writer { + if (message.result !== 0) { + writer.uint32(8).int32(message.result); + } + writer.uint32(18).fork(); + for (const v of message.refetchChunks) { + writer.uint32(v); + } + writer.ldelim(); + for (const v of message.rejectSenders) { + writer.uint32(26).string(v!); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): ResponseApplySnapshotChunk { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseResponseApplySnapshotChunk, + } as ResponseApplySnapshotChunk; + message.refetchChunks = []; + message.rejectSenders = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.result = reader.int32() as any; + break; + case 2: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.refetchChunks.push(reader.uint32()); + } + } else { + message.refetchChunks.push(reader.uint32()); + } + break; + case 3: + message.rejectSenders.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ResponseApplySnapshotChunk { + const message = { + ...baseResponseApplySnapshotChunk, + } as ResponseApplySnapshotChunk; + message.refetchChunks = []; + message.rejectSenders = []; + if (object.result !== undefined && object.result !== null) { + message.result = responseApplySnapshotChunk_ResultFromJSON(object.result); + } else { + message.result = 0; + } + if (object.refetchChunks !== undefined && object.refetchChunks !== null) { + for (const e of object.refetchChunks) { + message.refetchChunks.push(Number(e)); + } + } + if (object.rejectSenders !== undefined && object.rejectSenders !== null) { + for (const e of object.rejectSenders) { + message.rejectSenders.push(String(e)); + } + } + return message; + }, + + toJSON(message: ResponseApplySnapshotChunk): unknown { + const obj: any = {}; + message.result !== undefined && + (obj.result = responseApplySnapshotChunk_ResultToJSON(message.result)); + if (message.refetchChunks) { + obj.refetchChunks = message.refetchChunks.map((e) => e); + } else { + obj.refetchChunks = []; + } + if (message.rejectSenders) { + obj.rejectSenders = message.rejectSenders.map((e) => e); + } else { + obj.rejectSenders = []; + } + return obj; + }, + + fromPartial( + object: DeepPartial + ): ResponseApplySnapshotChunk { + const message = { + ...baseResponseApplySnapshotChunk, + } as ResponseApplySnapshotChunk; + message.refetchChunks = []; + message.rejectSenders = []; + if (object.result !== undefined && object.result !== null) { + message.result = object.result; + } else { + message.result = 0; + } + if (object.refetchChunks !== undefined && object.refetchChunks !== null) { + for (const e of object.refetchChunks) { + message.refetchChunks.push(e); + } + } + if (object.rejectSenders !== undefined && object.rejectSenders !== null) { + for (const e of object.rejectSenders) { + message.rejectSenders.push(e); + } + } + return message; + }, +}; + +const baseConsensusParams: object = {}; + +export const ConsensusParams = { + encode(message: ConsensusParams, writer: Writer = Writer.create()): Writer { + if (message.block !== undefined) { + BlockParams.encode(message.block, writer.uint32(10).fork()).ldelim(); + } + if (message.evidence !== undefined) { + EvidenceParams.encode( + message.evidence, + writer.uint32(18).fork() + ).ldelim(); + } + if (message.validator !== undefined) { + ValidatorParams.encode( + message.validator, + writer.uint32(26).fork() + ).ldelim(); + } + if (message.version !== undefined) { + VersionParams.encode(message.version, writer.uint32(34).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ConsensusParams { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseConsensusParams } as ConsensusParams; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.block = BlockParams.decode(reader, reader.uint32()); + break; + case 2: + message.evidence = EvidenceParams.decode(reader, reader.uint32()); + break; + case 3: + message.validator = ValidatorParams.decode(reader, reader.uint32()); + break; + case 4: + message.version = VersionParams.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ConsensusParams { + const message = { ...baseConsensusParams } as ConsensusParams; + if (object.block !== undefined && object.block !== null) { + message.block = BlockParams.fromJSON(object.block); + } else { + message.block = undefined; + } + if (object.evidence !== undefined && object.evidence !== null) { + message.evidence = EvidenceParams.fromJSON(object.evidence); + } else { + message.evidence = undefined; + } + if (object.validator !== undefined && object.validator !== null) { + message.validator = ValidatorParams.fromJSON(object.validator); + } else { + message.validator = undefined; + } + if (object.version !== undefined && object.version !== null) { + message.version = VersionParams.fromJSON(object.version); + } else { + message.version = undefined; + } + return message; + }, + + toJSON(message: ConsensusParams): unknown { + const obj: any = {}; + message.block !== undefined && + (obj.block = message.block + ? BlockParams.toJSON(message.block) + : undefined); + message.evidence !== undefined && + (obj.evidence = message.evidence + ? EvidenceParams.toJSON(message.evidence) + : undefined); + message.validator !== undefined && + (obj.validator = message.validator + ? ValidatorParams.toJSON(message.validator) + : undefined); + message.version !== undefined && + (obj.version = message.version + ? VersionParams.toJSON(message.version) + : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): ConsensusParams { + const message = { ...baseConsensusParams } as ConsensusParams; + if (object.block !== undefined && object.block !== null) { + message.block = BlockParams.fromPartial(object.block); + } else { + message.block = undefined; + } + if (object.evidence !== undefined && object.evidence !== null) { + message.evidence = EvidenceParams.fromPartial(object.evidence); + } else { + message.evidence = undefined; + } + if (object.validator !== undefined && object.validator !== null) { + message.validator = ValidatorParams.fromPartial(object.validator); + } else { + message.validator = undefined; + } + if (object.version !== undefined && object.version !== null) { + message.version = VersionParams.fromPartial(object.version); + } else { + message.version = undefined; + } + return message; + }, +}; + +const baseBlockParams: object = { maxBytes: 0, maxGas: 0 }; + +export const BlockParams = { + encode(message: BlockParams, writer: Writer = Writer.create()): Writer { + if (message.maxBytes !== 0) { + writer.uint32(8).int64(message.maxBytes); + } + if (message.maxGas !== 0) { + writer.uint32(16).int64(message.maxGas); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): BlockParams { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseBlockParams } as BlockParams; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.maxBytes = longToNumber(reader.int64() as Long); + break; + case 2: + message.maxGas = longToNumber(reader.int64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): BlockParams { + const message = { ...baseBlockParams } as BlockParams; + if (object.maxBytes !== undefined && object.maxBytes !== null) { + message.maxBytes = Number(object.maxBytes); + } else { + message.maxBytes = 0; + } + if (object.maxGas !== undefined && object.maxGas !== null) { + message.maxGas = Number(object.maxGas); + } else { + message.maxGas = 0; + } + return message; + }, + + toJSON(message: BlockParams): unknown { + const obj: any = {}; + message.maxBytes !== undefined && (obj.maxBytes = message.maxBytes); + message.maxGas !== undefined && (obj.maxGas = message.maxGas); + return obj; + }, + + fromPartial(object: DeepPartial): BlockParams { + const message = { ...baseBlockParams } as BlockParams; + if (object.maxBytes !== undefined && object.maxBytes !== null) { + message.maxBytes = object.maxBytes; + } else { + message.maxBytes = 0; + } + if (object.maxGas !== undefined && object.maxGas !== null) { + message.maxGas = object.maxGas; + } else { + message.maxGas = 0; + } + return message; + }, +}; + +const baseLastCommitInfo: object = { round: 0 }; + +export const LastCommitInfo = { + encode(message: LastCommitInfo, writer: Writer = Writer.create()): Writer { + if (message.round !== 0) { + writer.uint32(8).int32(message.round); + } + for (const v of message.votes) { + VoteInfo.encode(v!, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): LastCommitInfo { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseLastCommitInfo } as LastCommitInfo; + message.votes = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.round = reader.int32(); + break; + case 2: + message.votes.push(VoteInfo.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): LastCommitInfo { + const message = { ...baseLastCommitInfo } as LastCommitInfo; + message.votes = []; + if (object.round !== undefined && object.round !== null) { + message.round = Number(object.round); + } else { + message.round = 0; + } + if (object.votes !== undefined && object.votes !== null) { + for (const e of object.votes) { + message.votes.push(VoteInfo.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: LastCommitInfo): unknown { + const obj: any = {}; + message.round !== undefined && (obj.round = message.round); + if (message.votes) { + obj.votes = message.votes.map((e) => + e ? VoteInfo.toJSON(e) : undefined + ); + } else { + obj.votes = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): LastCommitInfo { + const message = { ...baseLastCommitInfo } as LastCommitInfo; + message.votes = []; + if (object.round !== undefined && object.round !== null) { + message.round = object.round; + } else { + message.round = 0; + } + if (object.votes !== undefined && object.votes !== null) { + for (const e of object.votes) { + message.votes.push(VoteInfo.fromPartial(e)); + } + } + return message; + }, +}; + +const baseEvent: object = { type: "" }; + +export const Event = { + encode(message: Event, writer: Writer = Writer.create()): Writer { + if (message.type !== "") { + writer.uint32(10).string(message.type); + } + for (const v of message.attributes) { + EventAttribute.encode(v!, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Event { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseEvent } as Event; + message.attributes = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.type = reader.string(); + break; + case 2: + message.attributes.push( + EventAttribute.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Event { + const message = { ...baseEvent } as Event; + message.attributes = []; + if (object.type !== undefined && object.type !== null) { + message.type = String(object.type); + } else { + message.type = ""; + } + if (object.attributes !== undefined && object.attributes !== null) { + for (const e of object.attributes) { + message.attributes.push(EventAttribute.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: Event): unknown { + const obj: any = {}; + message.type !== undefined && (obj.type = message.type); + if (message.attributes) { + obj.attributes = message.attributes.map((e) => + e ? EventAttribute.toJSON(e) : undefined + ); + } else { + obj.attributes = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): Event { + const message = { ...baseEvent } as Event; + message.attributes = []; + if (object.type !== undefined && object.type !== null) { + message.type = object.type; + } else { + message.type = ""; + } + if (object.attributes !== undefined && object.attributes !== null) { + for (const e of object.attributes) { + message.attributes.push(EventAttribute.fromPartial(e)); + } + } + return message; + }, +}; + +const baseEventAttribute: object = { index: false }; + +export const EventAttribute = { + encode(message: EventAttribute, writer: Writer = Writer.create()): Writer { + if (message.key.length !== 0) { + writer.uint32(10).bytes(message.key); + } + if (message.value.length !== 0) { + writer.uint32(18).bytes(message.value); + } + if (message.index === true) { + writer.uint32(24).bool(message.index); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): EventAttribute { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseEventAttribute } as EventAttribute; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.key = reader.bytes(); + break; + case 2: + message.value = reader.bytes(); + break; + case 3: + message.index = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EventAttribute { + const message = { ...baseEventAttribute } as EventAttribute; + if (object.key !== undefined && object.key !== null) { + message.key = bytesFromBase64(object.key); + } + if (object.value !== undefined && object.value !== null) { + message.value = bytesFromBase64(object.value); + } + if (object.index !== undefined && object.index !== null) { + message.index = Boolean(object.index); + } else { + message.index = false; + } + return message; + }, + + toJSON(message: EventAttribute): unknown { + const obj: any = {}; + message.key !== undefined && + (obj.key = base64FromBytes( + message.key !== undefined ? message.key : new Uint8Array() + )); + message.value !== undefined && + (obj.value = base64FromBytes( + message.value !== undefined ? message.value : new Uint8Array() + )); + message.index !== undefined && (obj.index = message.index); + return obj; + }, + + fromPartial(object: DeepPartial): EventAttribute { + const message = { ...baseEventAttribute } as EventAttribute; + if (object.key !== undefined && object.key !== null) { + message.key = object.key; + } else { + message.key = new Uint8Array(); + } + if (object.value !== undefined && object.value !== null) { + message.value = object.value; + } else { + message.value = new Uint8Array(); + } + if (object.index !== undefined && object.index !== null) { + message.index = object.index; + } else { + message.index = false; + } + return message; + }, +}; + +const baseTxResult: object = { height: 0, index: 0 }; + +export const TxResult = { + encode(message: TxResult, writer: Writer = Writer.create()): Writer { + if (message.height !== 0) { + writer.uint32(8).int64(message.height); + } + if (message.index !== 0) { + writer.uint32(16).uint32(message.index); + } + if (message.tx.length !== 0) { + writer.uint32(26).bytes(message.tx); + } + if (message.result !== undefined) { + ResponseDeliverTx.encode( + message.result, + writer.uint32(34).fork() + ).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): TxResult { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseTxResult } as TxResult; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.height = longToNumber(reader.int64() as Long); + break; + case 2: + message.index = reader.uint32(); + break; + case 3: + message.tx = reader.bytes(); + break; + case 4: + message.result = ResponseDeliverTx.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): TxResult { + const message = { ...baseTxResult } as TxResult; + if (object.height !== undefined && object.height !== null) { + message.height = Number(object.height); + } else { + message.height = 0; + } + if (object.index !== undefined && object.index !== null) { + message.index = Number(object.index); + } else { + message.index = 0; + } + if (object.tx !== undefined && object.tx !== null) { + message.tx = bytesFromBase64(object.tx); + } + if (object.result !== undefined && object.result !== null) { + message.result = ResponseDeliverTx.fromJSON(object.result); + } else { + message.result = undefined; + } + return message; + }, + + toJSON(message: TxResult): unknown { + const obj: any = {}; + message.height !== undefined && (obj.height = message.height); + message.index !== undefined && (obj.index = message.index); + message.tx !== undefined && + (obj.tx = base64FromBytes( + message.tx !== undefined ? message.tx : new Uint8Array() + )); + message.result !== undefined && + (obj.result = message.result + ? ResponseDeliverTx.toJSON(message.result) + : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): TxResult { + const message = { ...baseTxResult } as TxResult; + if (object.height !== undefined && object.height !== null) { + message.height = object.height; + } else { + message.height = 0; + } + if (object.index !== undefined && object.index !== null) { + message.index = object.index; + } else { + message.index = 0; + } + if (object.tx !== undefined && object.tx !== null) { + message.tx = object.tx; + } else { + message.tx = new Uint8Array(); + } + if (object.result !== undefined && object.result !== null) { + message.result = ResponseDeliverTx.fromPartial(object.result); + } else { + message.result = undefined; + } + return message; + }, +}; + +const baseValidator: object = { power: 0 }; + +export const Validator = { + encode(message: Validator, writer: Writer = Writer.create()): Writer { + if (message.address.length !== 0) { + writer.uint32(10).bytes(message.address); + } + if (message.power !== 0) { + writer.uint32(24).int64(message.power); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Validator { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseValidator } as Validator; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.address = reader.bytes(); + break; + case 3: + message.power = longToNumber(reader.int64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Validator { + const message = { ...baseValidator } as Validator; + if (object.address !== undefined && object.address !== null) { + message.address = bytesFromBase64(object.address); + } + if (object.power !== undefined && object.power !== null) { + message.power = Number(object.power); + } else { + message.power = 0; + } + return message; + }, + + toJSON(message: Validator): unknown { + const obj: any = {}; + message.address !== undefined && + (obj.address = base64FromBytes( + message.address !== undefined ? message.address : new Uint8Array() + )); + message.power !== undefined && (obj.power = message.power); + return obj; + }, + + fromPartial(object: DeepPartial): Validator { + const message = { ...baseValidator } as Validator; + if (object.address !== undefined && object.address !== null) { + message.address = object.address; + } else { + message.address = new Uint8Array(); + } + if (object.power !== undefined && object.power !== null) { + message.power = object.power; + } else { + message.power = 0; + } + return message; + }, +}; + +const baseValidatorUpdate: object = { power: 0 }; + +export const ValidatorUpdate = { + encode(message: ValidatorUpdate, writer: Writer = Writer.create()): Writer { + if (message.pubKey !== undefined) { + PublicKey.encode(message.pubKey, writer.uint32(10).fork()).ldelim(); + } + if (message.power !== 0) { + writer.uint32(16).int64(message.power); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ValidatorUpdate { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseValidatorUpdate } as ValidatorUpdate; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.pubKey = PublicKey.decode(reader, reader.uint32()); + break; + case 2: + message.power = longToNumber(reader.int64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ValidatorUpdate { + const message = { ...baseValidatorUpdate } as ValidatorUpdate; + if (object.pubKey !== undefined && object.pubKey !== null) { + message.pubKey = PublicKey.fromJSON(object.pubKey); + } else { + message.pubKey = undefined; + } + if (object.power !== undefined && object.power !== null) { + message.power = Number(object.power); + } else { + message.power = 0; + } + return message; + }, + + toJSON(message: ValidatorUpdate): unknown { + const obj: any = {}; + message.pubKey !== undefined && + (obj.pubKey = message.pubKey + ? PublicKey.toJSON(message.pubKey) + : undefined); + message.power !== undefined && (obj.power = message.power); + return obj; + }, + + fromPartial(object: DeepPartial): ValidatorUpdate { + const message = { ...baseValidatorUpdate } as ValidatorUpdate; + if (object.pubKey !== undefined && object.pubKey !== null) { + message.pubKey = PublicKey.fromPartial(object.pubKey); + } else { + message.pubKey = undefined; + } + if (object.power !== undefined && object.power !== null) { + message.power = object.power; + } else { + message.power = 0; + } + return message; + }, +}; + +const baseVoteInfo: object = { signedLastBlock: false }; + +export const VoteInfo = { + encode(message: VoteInfo, writer: Writer = Writer.create()): Writer { + if (message.validator !== undefined) { + Validator.encode(message.validator, writer.uint32(10).fork()).ldelim(); + } + if (message.signedLastBlock === true) { + writer.uint32(16).bool(message.signedLastBlock); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): VoteInfo { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseVoteInfo } as VoteInfo; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.validator = Validator.decode(reader, reader.uint32()); + break; + case 2: + message.signedLastBlock = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): VoteInfo { + const message = { ...baseVoteInfo } as VoteInfo; + if (object.validator !== undefined && object.validator !== null) { + message.validator = Validator.fromJSON(object.validator); + } else { + message.validator = undefined; + } + if ( + object.signedLastBlock !== undefined && + object.signedLastBlock !== null + ) { + message.signedLastBlock = Boolean(object.signedLastBlock); + } else { + message.signedLastBlock = false; + } + return message; + }, + + toJSON(message: VoteInfo): unknown { + const obj: any = {}; + message.validator !== undefined && + (obj.validator = message.validator + ? Validator.toJSON(message.validator) + : undefined); + message.signedLastBlock !== undefined && + (obj.signedLastBlock = message.signedLastBlock); + return obj; + }, + + fromPartial(object: DeepPartial): VoteInfo { + const message = { ...baseVoteInfo } as VoteInfo; + if (object.validator !== undefined && object.validator !== null) { + message.validator = Validator.fromPartial(object.validator); + } else { + message.validator = undefined; + } + if ( + object.signedLastBlock !== undefined && + object.signedLastBlock !== null + ) { + message.signedLastBlock = object.signedLastBlock; + } else { + message.signedLastBlock = false; + } + return message; + }, +}; + +const baseEvidence: object = { type: 0, height: 0, totalVotingPower: 0 }; + +export const Evidence = { + encode(message: Evidence, writer: Writer = Writer.create()): Writer { + if (message.type !== 0) { + writer.uint32(8).int32(message.type); + } + if (message.validator !== undefined) { + Validator.encode(message.validator, writer.uint32(18).fork()).ldelim(); + } + if (message.height !== 0) { + writer.uint32(24).int64(message.height); + } + if (message.time !== undefined) { + Timestamp.encode( + toTimestamp(message.time), + writer.uint32(34).fork() + ).ldelim(); + } + if (message.totalVotingPower !== 0) { + writer.uint32(40).int64(message.totalVotingPower); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Evidence { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseEvidence } as Evidence; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.type = reader.int32() as any; + break; + case 2: + message.validator = Validator.decode(reader, reader.uint32()); + break; + case 3: + message.height = longToNumber(reader.int64() as Long); + break; + case 4: + message.time = fromTimestamp( + Timestamp.decode(reader, reader.uint32()) + ); + break; + case 5: + message.totalVotingPower = longToNumber(reader.int64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Evidence { + const message = { ...baseEvidence } as Evidence; + if (object.type !== undefined && object.type !== null) { + message.type = evidenceTypeFromJSON(object.type); + } else { + message.type = 0; + } + if (object.validator !== undefined && object.validator !== null) { + message.validator = Validator.fromJSON(object.validator); + } else { + message.validator = undefined; + } + if (object.height !== undefined && object.height !== null) { + message.height = Number(object.height); + } else { + message.height = 0; + } + if (object.time !== undefined && object.time !== null) { + message.time = fromJsonTimestamp(object.time); + } else { + message.time = undefined; + } + if ( + object.totalVotingPower !== undefined && + object.totalVotingPower !== null + ) { + message.totalVotingPower = Number(object.totalVotingPower); + } else { + message.totalVotingPower = 0; + } + return message; + }, + + toJSON(message: Evidence): unknown { + const obj: any = {}; + message.type !== undefined && (obj.type = evidenceTypeToJSON(message.type)); + message.validator !== undefined && + (obj.validator = message.validator + ? Validator.toJSON(message.validator) + : undefined); + message.height !== undefined && (obj.height = message.height); + message.time !== undefined && + (obj.time = + message.time !== undefined ? message.time.toISOString() : null); + message.totalVotingPower !== undefined && + (obj.totalVotingPower = message.totalVotingPower); + return obj; + }, + + fromPartial(object: DeepPartial): Evidence { + const message = { ...baseEvidence } as Evidence; + if (object.type !== undefined && object.type !== null) { + message.type = object.type; + } else { + message.type = 0; + } + if (object.validator !== undefined && object.validator !== null) { + message.validator = Validator.fromPartial(object.validator); + } else { + message.validator = undefined; + } + if (object.height !== undefined && object.height !== null) { + message.height = object.height; + } else { + message.height = 0; + } + if (object.time !== undefined && object.time !== null) { + message.time = object.time; + } else { + message.time = undefined; + } + if ( + object.totalVotingPower !== undefined && + object.totalVotingPower !== null + ) { + message.totalVotingPower = object.totalVotingPower; + } else { + message.totalVotingPower = 0; + } + return message; + }, +}; + +const baseSnapshot: object = { height: 0, format: 0, chunks: 0 }; + +export const Snapshot = { + encode(message: Snapshot, writer: Writer = Writer.create()): Writer { + if (message.height !== 0) { + writer.uint32(8).uint64(message.height); + } + if (message.format !== 0) { + writer.uint32(16).uint32(message.format); + } + if (message.chunks !== 0) { + writer.uint32(24).uint32(message.chunks); + } + if (message.hash.length !== 0) { + writer.uint32(34).bytes(message.hash); + } + if (message.metadata.length !== 0) { + writer.uint32(42).bytes(message.metadata); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Snapshot { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseSnapshot } as Snapshot; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.height = longToNumber(reader.uint64() as Long); + break; + case 2: + message.format = reader.uint32(); + break; + case 3: + message.chunks = reader.uint32(); + break; + case 4: + message.hash = reader.bytes(); + break; + case 5: + message.metadata = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Snapshot { + const message = { ...baseSnapshot } as Snapshot; + if (object.height !== undefined && object.height !== null) { + message.height = Number(object.height); + } else { + message.height = 0; + } + if (object.format !== undefined && object.format !== null) { + message.format = Number(object.format); + } else { + message.format = 0; + } + if (object.chunks !== undefined && object.chunks !== null) { + message.chunks = Number(object.chunks); + } else { + message.chunks = 0; + } + if (object.hash !== undefined && object.hash !== null) { + message.hash = bytesFromBase64(object.hash); + } + if (object.metadata !== undefined && object.metadata !== null) { + message.metadata = bytesFromBase64(object.metadata); + } + return message; + }, + + toJSON(message: Snapshot): unknown { + const obj: any = {}; + message.height !== undefined && (obj.height = message.height); + message.format !== undefined && (obj.format = message.format); + message.chunks !== undefined && (obj.chunks = message.chunks); + message.hash !== undefined && + (obj.hash = base64FromBytes( + message.hash !== undefined ? message.hash : new Uint8Array() + )); + message.metadata !== undefined && + (obj.metadata = base64FromBytes( + message.metadata !== undefined ? message.metadata : new Uint8Array() + )); + return obj; + }, + + fromPartial(object: DeepPartial): Snapshot { + const message = { ...baseSnapshot } as Snapshot; + if (object.height !== undefined && object.height !== null) { + message.height = object.height; + } else { + message.height = 0; + } + if (object.format !== undefined && object.format !== null) { + message.format = object.format; + } else { + message.format = 0; + } + if (object.chunks !== undefined && object.chunks !== null) { + message.chunks = object.chunks; + } else { + message.chunks = 0; + } + if (object.hash !== undefined && object.hash !== null) { + message.hash = object.hash; + } else { + message.hash = new Uint8Array(); + } + if (object.metadata !== undefined && object.metadata !== null) { + message.metadata = object.metadata; + } else { + message.metadata = new Uint8Array(); + } + return message; + }, +}; + +export interface ABCIApplication { + Echo(request: RequestEcho): Promise; + Flush(request: RequestFlush): Promise; + Info(request: RequestInfo): Promise; + SetOption(request: RequestSetOption): Promise; + DeliverTx(request: RequestDeliverTx): Promise; + CheckTx(request: RequestCheckTx): Promise; + Query(request: RequestQuery): Promise; + Commit(request: RequestCommit): Promise; + InitChain(request: RequestInitChain): Promise; + BeginBlock(request: RequestBeginBlock): Promise; + EndBlock(request: RequestEndBlock): Promise; + ListSnapshots(request: RequestListSnapshots): Promise; + OfferSnapshot(request: RequestOfferSnapshot): Promise; + LoadSnapshotChunk( + request: RequestLoadSnapshotChunk + ): Promise; + ApplySnapshotChunk( + request: RequestApplySnapshotChunk + ): Promise; +} + +export class ABCIApplicationClientImpl implements ABCIApplication { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + } + Echo(request: RequestEcho): Promise { + const data = RequestEcho.encode(request).finish(); + const promise = this.rpc.request( + "tendermint.abci.ABCIApplication", + "Echo", + data + ); + return promise.then((data) => ResponseEcho.decode(new Reader(data))); + } + + Flush(request: RequestFlush): Promise { + const data = RequestFlush.encode(request).finish(); + const promise = this.rpc.request( + "tendermint.abci.ABCIApplication", + "Flush", + data + ); + return promise.then((data) => ResponseFlush.decode(new Reader(data))); + } + + Info(request: RequestInfo): Promise { + const data = RequestInfo.encode(request).finish(); + const promise = this.rpc.request( + "tendermint.abci.ABCIApplication", + "Info", + data + ); + return promise.then((data) => ResponseInfo.decode(new Reader(data))); + } + + SetOption(request: RequestSetOption): Promise { + const data = RequestSetOption.encode(request).finish(); + const promise = this.rpc.request( + "tendermint.abci.ABCIApplication", + "SetOption", + data + ); + return promise.then((data) => ResponseSetOption.decode(new Reader(data))); + } + + DeliverTx(request: RequestDeliverTx): Promise { + const data = RequestDeliverTx.encode(request).finish(); + const promise = this.rpc.request( + "tendermint.abci.ABCIApplication", + "DeliverTx", + data + ); + return promise.then((data) => ResponseDeliverTx.decode(new Reader(data))); + } + + CheckTx(request: RequestCheckTx): Promise { + const data = RequestCheckTx.encode(request).finish(); + const promise = this.rpc.request( + "tendermint.abci.ABCIApplication", + "CheckTx", + data + ); + return promise.then((data) => ResponseCheckTx.decode(new Reader(data))); + } + + Query(request: RequestQuery): Promise { + const data = RequestQuery.encode(request).finish(); + const promise = this.rpc.request( + "tendermint.abci.ABCIApplication", + "Query", + data + ); + return promise.then((data) => ResponseQuery.decode(new Reader(data))); + } + + Commit(request: RequestCommit): Promise { + const data = RequestCommit.encode(request).finish(); + const promise = this.rpc.request( + "tendermint.abci.ABCIApplication", + "Commit", + data + ); + return promise.then((data) => ResponseCommit.decode(new Reader(data))); + } + + InitChain(request: RequestInitChain): Promise { + const data = RequestInitChain.encode(request).finish(); + const promise = this.rpc.request( + "tendermint.abci.ABCIApplication", + "InitChain", + data + ); + return promise.then((data) => ResponseInitChain.decode(new Reader(data))); + } + + BeginBlock(request: RequestBeginBlock): Promise { + const data = RequestBeginBlock.encode(request).finish(); + const promise = this.rpc.request( + "tendermint.abci.ABCIApplication", + "BeginBlock", + data + ); + return promise.then((data) => ResponseBeginBlock.decode(new Reader(data))); + } + + EndBlock(request: RequestEndBlock): Promise { + const data = RequestEndBlock.encode(request).finish(); + const promise = this.rpc.request( + "tendermint.abci.ABCIApplication", + "EndBlock", + data + ); + return promise.then((data) => ResponseEndBlock.decode(new Reader(data))); + } + + ListSnapshots(request: RequestListSnapshots): Promise { + const data = RequestListSnapshots.encode(request).finish(); + const promise = this.rpc.request( + "tendermint.abci.ABCIApplication", + "ListSnapshots", + data + ); + return promise.then((data) => + ResponseListSnapshots.decode(new Reader(data)) + ); + } + + OfferSnapshot(request: RequestOfferSnapshot): Promise { + const data = RequestOfferSnapshot.encode(request).finish(); + const promise = this.rpc.request( + "tendermint.abci.ABCIApplication", + "OfferSnapshot", + data + ); + return promise.then((data) => + ResponseOfferSnapshot.decode(new Reader(data)) + ); + } + + LoadSnapshotChunk( + request: RequestLoadSnapshotChunk + ): Promise { + const data = RequestLoadSnapshotChunk.encode(request).finish(); + const promise = this.rpc.request( + "tendermint.abci.ABCIApplication", + "LoadSnapshotChunk", + data + ); + return promise.then((data) => + ResponseLoadSnapshotChunk.decode(new Reader(data)) + ); + } + + ApplySnapshotChunk( + request: RequestApplySnapshotChunk + ): Promise { + const data = RequestApplySnapshotChunk.encode(request).finish(); + const promise = this.rpc.request( + "tendermint.abci.ABCIApplication", + "ApplySnapshotChunk", + data + ); + return promise.then((data) => + ResponseApplySnapshotChunk.decode(new Reader(data)) + ); + } +} + +interface Rpc { + request( + service: string, + method: string, + data: Uint8Array + ): Promise; +} + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function toTimestamp(date: Date): Timestamp { + const seconds = date.getTime() / 1_000; + const nanos = (date.getTime() % 1_000) * 1_000_000; + return { seconds, nanos }; +} + +function fromTimestamp(t: Timestamp): Date { + let millis = t.seconds * 1_000; + millis += t.nanos / 1_000_000; + return new Date(millis); +} + +function fromJsonTimestamp(o: any): Date { + if (o instanceof Date) { + return o; + } else if (typeof o === "string") { + return new Date(o); + } else { + return fromTimestamp(Timestamp.fromJSON(o)); + } +} + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/cosmos.tx.v1beta1/types/tendermint/crypto/keys.ts b/ts-client/cosmos.tx.v1beta1/types/tendermint/crypto/keys.ts new file mode 100644 index 00000000..d530b047 --- /dev/null +++ b/ts-client/cosmos.tx.v1beta1/types/tendermint/crypto/keys.ts @@ -0,0 +1,130 @@ +/* eslint-disable */ +import { Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "tendermint.crypto"; + +/** PublicKey defines the keys available for use with Validators */ +export interface PublicKey { + ed25519: Uint8Array | undefined; + secp256k1: Uint8Array | undefined; +} + +const basePublicKey: object = {}; + +export const PublicKey = { + encode(message: PublicKey, writer: Writer = Writer.create()): Writer { + if (message.ed25519 !== undefined) { + writer.uint32(10).bytes(message.ed25519); + } + if (message.secp256k1 !== undefined) { + writer.uint32(18).bytes(message.secp256k1); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): PublicKey { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...basePublicKey } as PublicKey; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.ed25519 = reader.bytes(); + break; + case 2: + message.secp256k1 = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): PublicKey { + const message = { ...basePublicKey } as PublicKey; + if (object.ed25519 !== undefined && object.ed25519 !== null) { + message.ed25519 = bytesFromBase64(object.ed25519); + } + if (object.secp256k1 !== undefined && object.secp256k1 !== null) { + message.secp256k1 = bytesFromBase64(object.secp256k1); + } + return message; + }, + + toJSON(message: PublicKey): unknown { + const obj: any = {}; + message.ed25519 !== undefined && + (obj.ed25519 = + message.ed25519 !== undefined + ? base64FromBytes(message.ed25519) + : undefined); + message.secp256k1 !== undefined && + (obj.secp256k1 = + message.secp256k1 !== undefined + ? base64FromBytes(message.secp256k1) + : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): PublicKey { + const message = { ...basePublicKey } as PublicKey; + if (object.ed25519 !== undefined && object.ed25519 !== null) { + message.ed25519 = object.ed25519; + } else { + message.ed25519 = undefined; + } + if (object.secp256k1 !== undefined && object.secp256k1 !== null) { + message.secp256k1 = object.secp256k1; + } else { + message.secp256k1 = undefined; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/cosmos.tx.v1beta1/types/tendermint/crypto/proof.ts b/ts-client/cosmos.tx.v1beta1/types/tendermint/crypto/proof.ts new file mode 100644 index 00000000..dae51600 --- /dev/null +++ b/ts-client/cosmos.tx.v1beta1/types/tendermint/crypto/proof.ts @@ -0,0 +1,529 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "tendermint.crypto"; + +export interface Proof { + total: number; + index: number; + leafHash: Uint8Array; + aunts: Uint8Array[]; +} + +export interface ValueOp { + /** Encoded in ProofOp.Key. */ + key: Uint8Array; + /** To encode in ProofOp.Data */ + proof: Proof | undefined; +} + +export interface DominoOp { + key: string; + input: string; + output: string; +} + +/** + * ProofOp defines an operation used for calculating Merkle root + * The data could be arbitrary format, providing nessecary data + * for example neighbouring node hash + */ +export interface ProofOp { + type: string; + key: Uint8Array; + data: Uint8Array; +} + +/** ProofOps is Merkle proof defined by the list of ProofOps */ +export interface ProofOps { + ops: ProofOp[]; +} + +const baseProof: object = { total: 0, index: 0 }; + +export const Proof = { + encode(message: Proof, writer: Writer = Writer.create()): Writer { + if (message.total !== 0) { + writer.uint32(8).int64(message.total); + } + if (message.index !== 0) { + writer.uint32(16).int64(message.index); + } + if (message.leafHash.length !== 0) { + writer.uint32(26).bytes(message.leafHash); + } + for (const v of message.aunts) { + writer.uint32(34).bytes(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Proof { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseProof } as Proof; + message.aunts = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.total = longToNumber(reader.int64() as Long); + break; + case 2: + message.index = longToNumber(reader.int64() as Long); + break; + case 3: + message.leafHash = reader.bytes(); + break; + case 4: + message.aunts.push(reader.bytes()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Proof { + const message = { ...baseProof } as Proof; + message.aunts = []; + if (object.total !== undefined && object.total !== null) { + message.total = Number(object.total); + } else { + message.total = 0; + } + if (object.index !== undefined && object.index !== null) { + message.index = Number(object.index); + } else { + message.index = 0; + } + if (object.leafHash !== undefined && object.leafHash !== null) { + message.leafHash = bytesFromBase64(object.leafHash); + } + if (object.aunts !== undefined && object.aunts !== null) { + for (const e of object.aunts) { + message.aunts.push(bytesFromBase64(e)); + } + } + return message; + }, + + toJSON(message: Proof): unknown { + const obj: any = {}; + message.total !== undefined && (obj.total = message.total); + message.index !== undefined && (obj.index = message.index); + message.leafHash !== undefined && + (obj.leafHash = base64FromBytes( + message.leafHash !== undefined ? message.leafHash : new Uint8Array() + )); + if (message.aunts) { + obj.aunts = message.aunts.map((e) => + base64FromBytes(e !== undefined ? e : new Uint8Array()) + ); + } else { + obj.aunts = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): Proof { + const message = { ...baseProof } as Proof; + message.aunts = []; + if (object.total !== undefined && object.total !== null) { + message.total = object.total; + } else { + message.total = 0; + } + if (object.index !== undefined && object.index !== null) { + message.index = object.index; + } else { + message.index = 0; + } + if (object.leafHash !== undefined && object.leafHash !== null) { + message.leafHash = object.leafHash; + } else { + message.leafHash = new Uint8Array(); + } + if (object.aunts !== undefined && object.aunts !== null) { + for (const e of object.aunts) { + message.aunts.push(e); + } + } + return message; + }, +}; + +const baseValueOp: object = {}; + +export const ValueOp = { + encode(message: ValueOp, writer: Writer = Writer.create()): Writer { + if (message.key.length !== 0) { + writer.uint32(10).bytes(message.key); + } + if (message.proof !== undefined) { + Proof.encode(message.proof, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ValueOp { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseValueOp } as ValueOp; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.key = reader.bytes(); + break; + case 2: + message.proof = Proof.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ValueOp { + const message = { ...baseValueOp } as ValueOp; + if (object.key !== undefined && object.key !== null) { + message.key = bytesFromBase64(object.key); + } + if (object.proof !== undefined && object.proof !== null) { + message.proof = Proof.fromJSON(object.proof); + } else { + message.proof = undefined; + } + return message; + }, + + toJSON(message: ValueOp): unknown { + const obj: any = {}; + message.key !== undefined && + (obj.key = base64FromBytes( + message.key !== undefined ? message.key : new Uint8Array() + )); + message.proof !== undefined && + (obj.proof = message.proof ? Proof.toJSON(message.proof) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): ValueOp { + const message = { ...baseValueOp } as ValueOp; + if (object.key !== undefined && object.key !== null) { + message.key = object.key; + } else { + message.key = new Uint8Array(); + } + if (object.proof !== undefined && object.proof !== null) { + message.proof = Proof.fromPartial(object.proof); + } else { + message.proof = undefined; + } + return message; + }, +}; + +const baseDominoOp: object = { key: "", input: "", output: "" }; + +export const DominoOp = { + encode(message: DominoOp, writer: Writer = Writer.create()): Writer { + if (message.key !== "") { + writer.uint32(10).string(message.key); + } + if (message.input !== "") { + writer.uint32(18).string(message.input); + } + if (message.output !== "") { + writer.uint32(26).string(message.output); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): DominoOp { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseDominoOp } as DominoOp; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.key = reader.string(); + break; + case 2: + message.input = reader.string(); + break; + case 3: + message.output = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DominoOp { + const message = { ...baseDominoOp } as DominoOp; + if (object.key !== undefined && object.key !== null) { + message.key = String(object.key); + } else { + message.key = ""; + } + if (object.input !== undefined && object.input !== null) { + message.input = String(object.input); + } else { + message.input = ""; + } + if (object.output !== undefined && object.output !== null) { + message.output = String(object.output); + } else { + message.output = ""; + } + return message; + }, + + toJSON(message: DominoOp): unknown { + const obj: any = {}; + message.key !== undefined && (obj.key = message.key); + message.input !== undefined && (obj.input = message.input); + message.output !== undefined && (obj.output = message.output); + return obj; + }, + + fromPartial(object: DeepPartial): DominoOp { + const message = { ...baseDominoOp } as DominoOp; + if (object.key !== undefined && object.key !== null) { + message.key = object.key; + } else { + message.key = ""; + } + if (object.input !== undefined && object.input !== null) { + message.input = object.input; + } else { + message.input = ""; + } + if (object.output !== undefined && object.output !== null) { + message.output = object.output; + } else { + message.output = ""; + } + return message; + }, +}; + +const baseProofOp: object = { type: "" }; + +export const ProofOp = { + encode(message: ProofOp, writer: Writer = Writer.create()): Writer { + if (message.type !== "") { + writer.uint32(10).string(message.type); + } + if (message.key.length !== 0) { + writer.uint32(18).bytes(message.key); + } + if (message.data.length !== 0) { + writer.uint32(26).bytes(message.data); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ProofOp { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseProofOp } as ProofOp; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.type = reader.string(); + break; + case 2: + message.key = reader.bytes(); + break; + case 3: + message.data = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ProofOp { + const message = { ...baseProofOp } as ProofOp; + if (object.type !== undefined && object.type !== null) { + message.type = String(object.type); + } else { + message.type = ""; + } + if (object.key !== undefined && object.key !== null) { + message.key = bytesFromBase64(object.key); + } + if (object.data !== undefined && object.data !== null) { + message.data = bytesFromBase64(object.data); + } + return message; + }, + + toJSON(message: ProofOp): unknown { + const obj: any = {}; + message.type !== undefined && (obj.type = message.type); + message.key !== undefined && + (obj.key = base64FromBytes( + message.key !== undefined ? message.key : new Uint8Array() + )); + message.data !== undefined && + (obj.data = base64FromBytes( + message.data !== undefined ? message.data : new Uint8Array() + )); + return obj; + }, + + fromPartial(object: DeepPartial): ProofOp { + const message = { ...baseProofOp } as ProofOp; + if (object.type !== undefined && object.type !== null) { + message.type = object.type; + } else { + message.type = ""; + } + if (object.key !== undefined && object.key !== null) { + message.key = object.key; + } else { + message.key = new Uint8Array(); + } + if (object.data !== undefined && object.data !== null) { + message.data = object.data; + } else { + message.data = new Uint8Array(); + } + return message; + }, +}; + +const baseProofOps: object = {}; + +export const ProofOps = { + encode(message: ProofOps, writer: Writer = Writer.create()): Writer { + for (const v of message.ops) { + ProofOp.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ProofOps { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseProofOps } as ProofOps; + message.ops = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.ops.push(ProofOp.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ProofOps { + const message = { ...baseProofOps } as ProofOps; + message.ops = []; + if (object.ops !== undefined && object.ops !== null) { + for (const e of object.ops) { + message.ops.push(ProofOp.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: ProofOps): unknown { + const obj: any = {}; + if (message.ops) { + obj.ops = message.ops.map((e) => (e ? ProofOp.toJSON(e) : undefined)); + } else { + obj.ops = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): ProofOps { + const message = { ...baseProofOps } as ProofOps; + message.ops = []; + if (object.ops !== undefined && object.ops !== null) { + for (const e of object.ops) { + message.ops.push(ProofOp.fromPartial(e)); + } + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/cosmos.tx.v1beta1/types/tendermint/types/block.ts b/ts-client/cosmos.tx.v1beta1/types/tendermint/types/block.ts new file mode 100644 index 00000000..64d2bbd3 --- /dev/null +++ b/ts-client/cosmos.tx.v1beta1/types/tendermint/types/block.ts @@ -0,0 +1,138 @@ +/* eslint-disable */ +import { Header, Data, Commit } from "../../tendermint/types/types"; +import { EvidenceList } from "../../tendermint/types/evidence"; +import { Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "tendermint.types"; + +export interface Block { + header: Header | undefined; + data: Data | undefined; + evidence: EvidenceList | undefined; + lastCommit: Commit | undefined; +} + +const baseBlock: object = {}; + +export const Block = { + encode(message: Block, writer: Writer = Writer.create()): Writer { + if (message.header !== undefined) { + Header.encode(message.header, writer.uint32(10).fork()).ldelim(); + } + if (message.data !== undefined) { + Data.encode(message.data, writer.uint32(18).fork()).ldelim(); + } + if (message.evidence !== undefined) { + EvidenceList.encode(message.evidence, writer.uint32(26).fork()).ldelim(); + } + if (message.lastCommit !== undefined) { + Commit.encode(message.lastCommit, writer.uint32(34).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Block { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseBlock } as Block; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.header = Header.decode(reader, reader.uint32()); + break; + case 2: + message.data = Data.decode(reader, reader.uint32()); + break; + case 3: + message.evidence = EvidenceList.decode(reader, reader.uint32()); + break; + case 4: + message.lastCommit = Commit.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Block { + const message = { ...baseBlock } as Block; + if (object.header !== undefined && object.header !== null) { + message.header = Header.fromJSON(object.header); + } else { + message.header = undefined; + } + if (object.data !== undefined && object.data !== null) { + message.data = Data.fromJSON(object.data); + } else { + message.data = undefined; + } + if (object.evidence !== undefined && object.evidence !== null) { + message.evidence = EvidenceList.fromJSON(object.evidence); + } else { + message.evidence = undefined; + } + if (object.lastCommit !== undefined && object.lastCommit !== null) { + message.lastCommit = Commit.fromJSON(object.lastCommit); + } else { + message.lastCommit = undefined; + } + return message; + }, + + toJSON(message: Block): unknown { + const obj: any = {}; + message.header !== undefined && + (obj.header = message.header ? Header.toJSON(message.header) : undefined); + message.data !== undefined && + (obj.data = message.data ? Data.toJSON(message.data) : undefined); + message.evidence !== undefined && + (obj.evidence = message.evidence + ? EvidenceList.toJSON(message.evidence) + : undefined); + message.lastCommit !== undefined && + (obj.lastCommit = message.lastCommit + ? Commit.toJSON(message.lastCommit) + : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): Block { + const message = { ...baseBlock } as Block; + if (object.header !== undefined && object.header !== null) { + message.header = Header.fromPartial(object.header); + } else { + message.header = undefined; + } + if (object.data !== undefined && object.data !== null) { + message.data = Data.fromPartial(object.data); + } else { + message.data = undefined; + } + if (object.evidence !== undefined && object.evidence !== null) { + message.evidence = EvidenceList.fromPartial(object.evidence); + } else { + message.evidence = undefined; + } + if (object.lastCommit !== undefined && object.lastCommit !== null) { + message.lastCommit = Commit.fromPartial(object.lastCommit); + } else { + message.lastCommit = undefined; + } + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/cosmos.tx.v1beta1/types/tendermint/types/evidence.ts b/ts-client/cosmos.tx.v1beta1/types/tendermint/types/evidence.ts new file mode 100644 index 00000000..04ec70a4 --- /dev/null +++ b/ts-client/cosmos.tx.v1beta1/types/tendermint/types/evidence.ts @@ -0,0 +1,602 @@ +/* eslint-disable */ +import { Timestamp } from "../../google/protobuf/timestamp"; +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; +import { Vote, LightBlock } from "../../tendermint/types/types"; +import { Validator } from "../../tendermint/types/validator"; + +export const protobufPackage = "tendermint.types"; + +export interface Evidence { + duplicateVoteEvidence: DuplicateVoteEvidence | undefined; + lightClientAttackEvidence: LightClientAttackEvidence | undefined; +} + +/** DuplicateVoteEvidence contains evidence of a validator signed two conflicting votes. */ +export interface DuplicateVoteEvidence { + voteA: Vote | undefined; + voteB: Vote | undefined; + totalVotingPower: number; + validatorPower: number; + timestamp: Date | undefined; +} + +/** LightClientAttackEvidence contains evidence of a set of validators attempting to mislead a light client. */ +export interface LightClientAttackEvidence { + conflictingBlock: LightBlock | undefined; + commonHeight: number; + byzantineValidators: Validator[]; + totalVotingPower: number; + timestamp: Date | undefined; +} + +export interface EvidenceList { + evidence: Evidence[]; +} + +const baseEvidence: object = {}; + +export const Evidence = { + encode(message: Evidence, writer: Writer = Writer.create()): Writer { + if (message.duplicateVoteEvidence !== undefined) { + DuplicateVoteEvidence.encode( + message.duplicateVoteEvidence, + writer.uint32(10).fork() + ).ldelim(); + } + if (message.lightClientAttackEvidence !== undefined) { + LightClientAttackEvidence.encode( + message.lightClientAttackEvidence, + writer.uint32(18).fork() + ).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Evidence { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseEvidence } as Evidence; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.duplicateVoteEvidence = DuplicateVoteEvidence.decode( + reader, + reader.uint32() + ); + break; + case 2: + message.lightClientAttackEvidence = LightClientAttackEvidence.decode( + reader, + reader.uint32() + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Evidence { + const message = { ...baseEvidence } as Evidence; + if ( + object.duplicateVoteEvidence !== undefined && + object.duplicateVoteEvidence !== null + ) { + message.duplicateVoteEvidence = DuplicateVoteEvidence.fromJSON( + object.duplicateVoteEvidence + ); + } else { + message.duplicateVoteEvidence = undefined; + } + if ( + object.lightClientAttackEvidence !== undefined && + object.lightClientAttackEvidence !== null + ) { + message.lightClientAttackEvidence = LightClientAttackEvidence.fromJSON( + object.lightClientAttackEvidence + ); + } else { + message.lightClientAttackEvidence = undefined; + } + return message; + }, + + toJSON(message: Evidence): unknown { + const obj: any = {}; + message.duplicateVoteEvidence !== undefined && + (obj.duplicateVoteEvidence = message.duplicateVoteEvidence + ? DuplicateVoteEvidence.toJSON(message.duplicateVoteEvidence) + : undefined); + message.lightClientAttackEvidence !== undefined && + (obj.lightClientAttackEvidence = message.lightClientAttackEvidence + ? LightClientAttackEvidence.toJSON(message.lightClientAttackEvidence) + : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): Evidence { + const message = { ...baseEvidence } as Evidence; + if ( + object.duplicateVoteEvidence !== undefined && + object.duplicateVoteEvidence !== null + ) { + message.duplicateVoteEvidence = DuplicateVoteEvidence.fromPartial( + object.duplicateVoteEvidence + ); + } else { + message.duplicateVoteEvidence = undefined; + } + if ( + object.lightClientAttackEvidence !== undefined && + object.lightClientAttackEvidence !== null + ) { + message.lightClientAttackEvidence = LightClientAttackEvidence.fromPartial( + object.lightClientAttackEvidence + ); + } else { + message.lightClientAttackEvidence = undefined; + } + return message; + }, +}; + +const baseDuplicateVoteEvidence: object = { + totalVotingPower: 0, + validatorPower: 0, +}; + +export const DuplicateVoteEvidence = { + encode( + message: DuplicateVoteEvidence, + writer: Writer = Writer.create() + ): Writer { + if (message.voteA !== undefined) { + Vote.encode(message.voteA, writer.uint32(10).fork()).ldelim(); + } + if (message.voteB !== undefined) { + Vote.encode(message.voteB, writer.uint32(18).fork()).ldelim(); + } + if (message.totalVotingPower !== 0) { + writer.uint32(24).int64(message.totalVotingPower); + } + if (message.validatorPower !== 0) { + writer.uint32(32).int64(message.validatorPower); + } + if (message.timestamp !== undefined) { + Timestamp.encode( + toTimestamp(message.timestamp), + writer.uint32(42).fork() + ).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): DuplicateVoteEvidence { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseDuplicateVoteEvidence } as DuplicateVoteEvidence; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.voteA = Vote.decode(reader, reader.uint32()); + break; + case 2: + message.voteB = Vote.decode(reader, reader.uint32()); + break; + case 3: + message.totalVotingPower = longToNumber(reader.int64() as Long); + break; + case 4: + message.validatorPower = longToNumber(reader.int64() as Long); + break; + case 5: + message.timestamp = fromTimestamp( + Timestamp.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DuplicateVoteEvidence { + const message = { ...baseDuplicateVoteEvidence } as DuplicateVoteEvidence; + if (object.voteA !== undefined && object.voteA !== null) { + message.voteA = Vote.fromJSON(object.voteA); + } else { + message.voteA = undefined; + } + if (object.voteB !== undefined && object.voteB !== null) { + message.voteB = Vote.fromJSON(object.voteB); + } else { + message.voteB = undefined; + } + if ( + object.totalVotingPower !== undefined && + object.totalVotingPower !== null + ) { + message.totalVotingPower = Number(object.totalVotingPower); + } else { + message.totalVotingPower = 0; + } + if (object.validatorPower !== undefined && object.validatorPower !== null) { + message.validatorPower = Number(object.validatorPower); + } else { + message.validatorPower = 0; + } + if (object.timestamp !== undefined && object.timestamp !== null) { + message.timestamp = fromJsonTimestamp(object.timestamp); + } else { + message.timestamp = undefined; + } + return message; + }, + + toJSON(message: DuplicateVoteEvidence): unknown { + const obj: any = {}; + message.voteA !== undefined && + (obj.voteA = message.voteA ? Vote.toJSON(message.voteA) : undefined); + message.voteB !== undefined && + (obj.voteB = message.voteB ? Vote.toJSON(message.voteB) : undefined); + message.totalVotingPower !== undefined && + (obj.totalVotingPower = message.totalVotingPower); + message.validatorPower !== undefined && + (obj.validatorPower = message.validatorPower); + message.timestamp !== undefined && + (obj.timestamp = + message.timestamp !== undefined + ? message.timestamp.toISOString() + : null); + return obj; + }, + + fromPartial( + object: DeepPartial + ): DuplicateVoteEvidence { + const message = { ...baseDuplicateVoteEvidence } as DuplicateVoteEvidence; + if (object.voteA !== undefined && object.voteA !== null) { + message.voteA = Vote.fromPartial(object.voteA); + } else { + message.voteA = undefined; + } + if (object.voteB !== undefined && object.voteB !== null) { + message.voteB = Vote.fromPartial(object.voteB); + } else { + message.voteB = undefined; + } + if ( + object.totalVotingPower !== undefined && + object.totalVotingPower !== null + ) { + message.totalVotingPower = object.totalVotingPower; + } else { + message.totalVotingPower = 0; + } + if (object.validatorPower !== undefined && object.validatorPower !== null) { + message.validatorPower = object.validatorPower; + } else { + message.validatorPower = 0; + } + if (object.timestamp !== undefined && object.timestamp !== null) { + message.timestamp = object.timestamp; + } else { + message.timestamp = undefined; + } + return message; + }, +}; + +const baseLightClientAttackEvidence: object = { + commonHeight: 0, + totalVotingPower: 0, +}; + +export const LightClientAttackEvidence = { + encode( + message: LightClientAttackEvidence, + writer: Writer = Writer.create() + ): Writer { + if (message.conflictingBlock !== undefined) { + LightBlock.encode( + message.conflictingBlock, + writer.uint32(10).fork() + ).ldelim(); + } + if (message.commonHeight !== 0) { + writer.uint32(16).int64(message.commonHeight); + } + for (const v of message.byzantineValidators) { + Validator.encode(v!, writer.uint32(26).fork()).ldelim(); + } + if (message.totalVotingPower !== 0) { + writer.uint32(32).int64(message.totalVotingPower); + } + if (message.timestamp !== undefined) { + Timestamp.encode( + toTimestamp(message.timestamp), + writer.uint32(42).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): LightClientAttackEvidence { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseLightClientAttackEvidence, + } as LightClientAttackEvidence; + message.byzantineValidators = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.conflictingBlock = LightBlock.decode(reader, reader.uint32()); + break; + case 2: + message.commonHeight = longToNumber(reader.int64() as Long); + break; + case 3: + message.byzantineValidators.push( + Validator.decode(reader, reader.uint32()) + ); + break; + case 4: + message.totalVotingPower = longToNumber(reader.int64() as Long); + break; + case 5: + message.timestamp = fromTimestamp( + Timestamp.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): LightClientAttackEvidence { + const message = { + ...baseLightClientAttackEvidence, + } as LightClientAttackEvidence; + message.byzantineValidators = []; + if ( + object.conflictingBlock !== undefined && + object.conflictingBlock !== null + ) { + message.conflictingBlock = LightBlock.fromJSON(object.conflictingBlock); + } else { + message.conflictingBlock = undefined; + } + if (object.commonHeight !== undefined && object.commonHeight !== null) { + message.commonHeight = Number(object.commonHeight); + } else { + message.commonHeight = 0; + } + if ( + object.byzantineValidators !== undefined && + object.byzantineValidators !== null + ) { + for (const e of object.byzantineValidators) { + message.byzantineValidators.push(Validator.fromJSON(e)); + } + } + if ( + object.totalVotingPower !== undefined && + object.totalVotingPower !== null + ) { + message.totalVotingPower = Number(object.totalVotingPower); + } else { + message.totalVotingPower = 0; + } + if (object.timestamp !== undefined && object.timestamp !== null) { + message.timestamp = fromJsonTimestamp(object.timestamp); + } else { + message.timestamp = undefined; + } + return message; + }, + + toJSON(message: LightClientAttackEvidence): unknown { + const obj: any = {}; + message.conflictingBlock !== undefined && + (obj.conflictingBlock = message.conflictingBlock + ? LightBlock.toJSON(message.conflictingBlock) + : undefined); + message.commonHeight !== undefined && + (obj.commonHeight = message.commonHeight); + if (message.byzantineValidators) { + obj.byzantineValidators = message.byzantineValidators.map((e) => + e ? Validator.toJSON(e) : undefined + ); + } else { + obj.byzantineValidators = []; + } + message.totalVotingPower !== undefined && + (obj.totalVotingPower = message.totalVotingPower); + message.timestamp !== undefined && + (obj.timestamp = + message.timestamp !== undefined + ? message.timestamp.toISOString() + : null); + return obj; + }, + + fromPartial( + object: DeepPartial + ): LightClientAttackEvidence { + const message = { + ...baseLightClientAttackEvidence, + } as LightClientAttackEvidence; + message.byzantineValidators = []; + if ( + object.conflictingBlock !== undefined && + object.conflictingBlock !== null + ) { + message.conflictingBlock = LightBlock.fromPartial( + object.conflictingBlock + ); + } else { + message.conflictingBlock = undefined; + } + if (object.commonHeight !== undefined && object.commonHeight !== null) { + message.commonHeight = object.commonHeight; + } else { + message.commonHeight = 0; + } + if ( + object.byzantineValidators !== undefined && + object.byzantineValidators !== null + ) { + for (const e of object.byzantineValidators) { + message.byzantineValidators.push(Validator.fromPartial(e)); + } + } + if ( + object.totalVotingPower !== undefined && + object.totalVotingPower !== null + ) { + message.totalVotingPower = object.totalVotingPower; + } else { + message.totalVotingPower = 0; + } + if (object.timestamp !== undefined && object.timestamp !== null) { + message.timestamp = object.timestamp; + } else { + message.timestamp = undefined; + } + return message; + }, +}; + +const baseEvidenceList: object = {}; + +export const EvidenceList = { + encode(message: EvidenceList, writer: Writer = Writer.create()): Writer { + for (const v of message.evidence) { + Evidence.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): EvidenceList { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseEvidenceList } as EvidenceList; + message.evidence = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.evidence.push(Evidence.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EvidenceList { + const message = { ...baseEvidenceList } as EvidenceList; + message.evidence = []; + if (object.evidence !== undefined && object.evidence !== null) { + for (const e of object.evidence) { + message.evidence.push(Evidence.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: EvidenceList): unknown { + const obj: any = {}; + if (message.evidence) { + obj.evidence = message.evidence.map((e) => + e ? Evidence.toJSON(e) : undefined + ); + } else { + obj.evidence = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): EvidenceList { + const message = { ...baseEvidenceList } as EvidenceList; + message.evidence = []; + if (object.evidence !== undefined && object.evidence !== null) { + for (const e of object.evidence) { + message.evidence.push(Evidence.fromPartial(e)); + } + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function toTimestamp(date: Date): Timestamp { + const seconds = date.getTime() / 1_000; + const nanos = (date.getTime() % 1_000) * 1_000_000; + return { seconds, nanos }; +} + +function fromTimestamp(t: Timestamp): Date { + let millis = t.seconds * 1_000; + millis += t.nanos / 1_000_000; + return new Date(millis); +} + +function fromJsonTimestamp(o: any): Date { + if (o instanceof Date) { + return o; + } else if (typeof o === "string") { + return new Date(o); + } else { + return fromTimestamp(Timestamp.fromJSON(o)); + } +} + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/cosmos.tx.v1beta1/types/tendermint/types/params.ts b/ts-client/cosmos.tx.v1beta1/types/tendermint/types/params.ts new file mode 100644 index 00000000..eaa18463 --- /dev/null +++ b/ts-client/cosmos.tx.v1beta1/types/tendermint/types/params.ts @@ -0,0 +1,625 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; +import { Duration } from "../../google/protobuf/duration"; + +export const protobufPackage = "tendermint.types"; + +/** + * ConsensusParams contains consensus critical parameters that determine the + * validity of blocks. + */ +export interface ConsensusParams { + block: BlockParams | undefined; + evidence: EvidenceParams | undefined; + validator: ValidatorParams | undefined; + version: VersionParams | undefined; +} + +/** BlockParams contains limits on the block size. */ +export interface BlockParams { + /** + * Max block size, in bytes. + * Note: must be greater than 0 + */ + maxBytes: number; + /** + * Max gas per block. + * Note: must be greater or equal to -1 + */ + maxGas: number; + /** + * Minimum time increment between consecutive blocks (in milliseconds) If the + * block header timestamp is ahead of the system clock, decrease this value. + * + * Not exposed to the application. + */ + timeIotaMs: number; +} + +/** EvidenceParams determine how we handle evidence of malfeasance. */ +export interface EvidenceParams { + /** + * Max age of evidence, in blocks. + * + * The basic formula for calculating this is: MaxAgeDuration / {average block + * time}. + */ + maxAgeNumBlocks: number; + /** + * Max age of evidence, in time. + * + * It should correspond with an app's "unbonding period" or other similar + * mechanism for handling [Nothing-At-Stake + * attacks](https://github.com/ethereum/wiki/wiki/Proof-of-Stake-FAQ#what-is-the-nothing-at-stake-problem-and-how-can-it-be-fixed). + */ + maxAgeDuration: Duration | undefined; + /** + * This sets the maximum size of total evidence in bytes that can be committed in a single block. + * and should fall comfortably under the max block bytes. + * Default is 1048576 or 1MB + */ + maxBytes: number; +} + +/** + * ValidatorParams restrict the public key types validators can use. + * NOTE: uses ABCI pubkey naming, not Amino names. + */ +export interface ValidatorParams { + pubKeyTypes: string[]; +} + +/** VersionParams contains the ABCI application version. */ +export interface VersionParams { + appVersion: number; +} + +/** + * HashedParams is a subset of ConsensusParams. + * + * It is hashed into the Header.ConsensusHash. + */ +export interface HashedParams { + blockMaxBytes: number; + blockMaxGas: number; +} + +const baseConsensusParams: object = {}; + +export const ConsensusParams = { + encode(message: ConsensusParams, writer: Writer = Writer.create()): Writer { + if (message.block !== undefined) { + BlockParams.encode(message.block, writer.uint32(10).fork()).ldelim(); + } + if (message.evidence !== undefined) { + EvidenceParams.encode( + message.evidence, + writer.uint32(18).fork() + ).ldelim(); + } + if (message.validator !== undefined) { + ValidatorParams.encode( + message.validator, + writer.uint32(26).fork() + ).ldelim(); + } + if (message.version !== undefined) { + VersionParams.encode(message.version, writer.uint32(34).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ConsensusParams { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseConsensusParams } as ConsensusParams; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.block = BlockParams.decode(reader, reader.uint32()); + break; + case 2: + message.evidence = EvidenceParams.decode(reader, reader.uint32()); + break; + case 3: + message.validator = ValidatorParams.decode(reader, reader.uint32()); + break; + case 4: + message.version = VersionParams.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ConsensusParams { + const message = { ...baseConsensusParams } as ConsensusParams; + if (object.block !== undefined && object.block !== null) { + message.block = BlockParams.fromJSON(object.block); + } else { + message.block = undefined; + } + if (object.evidence !== undefined && object.evidence !== null) { + message.evidence = EvidenceParams.fromJSON(object.evidence); + } else { + message.evidence = undefined; + } + if (object.validator !== undefined && object.validator !== null) { + message.validator = ValidatorParams.fromJSON(object.validator); + } else { + message.validator = undefined; + } + if (object.version !== undefined && object.version !== null) { + message.version = VersionParams.fromJSON(object.version); + } else { + message.version = undefined; + } + return message; + }, + + toJSON(message: ConsensusParams): unknown { + const obj: any = {}; + message.block !== undefined && + (obj.block = message.block + ? BlockParams.toJSON(message.block) + : undefined); + message.evidence !== undefined && + (obj.evidence = message.evidence + ? EvidenceParams.toJSON(message.evidence) + : undefined); + message.validator !== undefined && + (obj.validator = message.validator + ? ValidatorParams.toJSON(message.validator) + : undefined); + message.version !== undefined && + (obj.version = message.version + ? VersionParams.toJSON(message.version) + : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): ConsensusParams { + const message = { ...baseConsensusParams } as ConsensusParams; + if (object.block !== undefined && object.block !== null) { + message.block = BlockParams.fromPartial(object.block); + } else { + message.block = undefined; + } + if (object.evidence !== undefined && object.evidence !== null) { + message.evidence = EvidenceParams.fromPartial(object.evidence); + } else { + message.evidence = undefined; + } + if (object.validator !== undefined && object.validator !== null) { + message.validator = ValidatorParams.fromPartial(object.validator); + } else { + message.validator = undefined; + } + if (object.version !== undefined && object.version !== null) { + message.version = VersionParams.fromPartial(object.version); + } else { + message.version = undefined; + } + return message; + }, +}; + +const baseBlockParams: object = { maxBytes: 0, maxGas: 0, timeIotaMs: 0 }; + +export const BlockParams = { + encode(message: BlockParams, writer: Writer = Writer.create()): Writer { + if (message.maxBytes !== 0) { + writer.uint32(8).int64(message.maxBytes); + } + if (message.maxGas !== 0) { + writer.uint32(16).int64(message.maxGas); + } + if (message.timeIotaMs !== 0) { + writer.uint32(24).int64(message.timeIotaMs); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): BlockParams { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseBlockParams } as BlockParams; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.maxBytes = longToNumber(reader.int64() as Long); + break; + case 2: + message.maxGas = longToNumber(reader.int64() as Long); + break; + case 3: + message.timeIotaMs = longToNumber(reader.int64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): BlockParams { + const message = { ...baseBlockParams } as BlockParams; + if (object.maxBytes !== undefined && object.maxBytes !== null) { + message.maxBytes = Number(object.maxBytes); + } else { + message.maxBytes = 0; + } + if (object.maxGas !== undefined && object.maxGas !== null) { + message.maxGas = Number(object.maxGas); + } else { + message.maxGas = 0; + } + if (object.timeIotaMs !== undefined && object.timeIotaMs !== null) { + message.timeIotaMs = Number(object.timeIotaMs); + } else { + message.timeIotaMs = 0; + } + return message; + }, + + toJSON(message: BlockParams): unknown { + const obj: any = {}; + message.maxBytes !== undefined && (obj.maxBytes = message.maxBytes); + message.maxGas !== undefined && (obj.maxGas = message.maxGas); + message.timeIotaMs !== undefined && (obj.timeIotaMs = message.timeIotaMs); + return obj; + }, + + fromPartial(object: DeepPartial): BlockParams { + const message = { ...baseBlockParams } as BlockParams; + if (object.maxBytes !== undefined && object.maxBytes !== null) { + message.maxBytes = object.maxBytes; + } else { + message.maxBytes = 0; + } + if (object.maxGas !== undefined && object.maxGas !== null) { + message.maxGas = object.maxGas; + } else { + message.maxGas = 0; + } + if (object.timeIotaMs !== undefined && object.timeIotaMs !== null) { + message.timeIotaMs = object.timeIotaMs; + } else { + message.timeIotaMs = 0; + } + return message; + }, +}; + +const baseEvidenceParams: object = { maxAgeNumBlocks: 0, maxBytes: 0 }; + +export const EvidenceParams = { + encode(message: EvidenceParams, writer: Writer = Writer.create()): Writer { + if (message.maxAgeNumBlocks !== 0) { + writer.uint32(8).int64(message.maxAgeNumBlocks); + } + if (message.maxAgeDuration !== undefined) { + Duration.encode( + message.maxAgeDuration, + writer.uint32(18).fork() + ).ldelim(); + } + if (message.maxBytes !== 0) { + writer.uint32(24).int64(message.maxBytes); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): EvidenceParams { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseEvidenceParams } as EvidenceParams; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.maxAgeNumBlocks = longToNumber(reader.int64() as Long); + break; + case 2: + message.maxAgeDuration = Duration.decode(reader, reader.uint32()); + break; + case 3: + message.maxBytes = longToNumber(reader.int64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EvidenceParams { + const message = { ...baseEvidenceParams } as EvidenceParams; + if ( + object.maxAgeNumBlocks !== undefined && + object.maxAgeNumBlocks !== null + ) { + message.maxAgeNumBlocks = Number(object.maxAgeNumBlocks); + } else { + message.maxAgeNumBlocks = 0; + } + if (object.maxAgeDuration !== undefined && object.maxAgeDuration !== null) { + message.maxAgeDuration = Duration.fromJSON(object.maxAgeDuration); + } else { + message.maxAgeDuration = undefined; + } + if (object.maxBytes !== undefined && object.maxBytes !== null) { + message.maxBytes = Number(object.maxBytes); + } else { + message.maxBytes = 0; + } + return message; + }, + + toJSON(message: EvidenceParams): unknown { + const obj: any = {}; + message.maxAgeNumBlocks !== undefined && + (obj.maxAgeNumBlocks = message.maxAgeNumBlocks); + message.maxAgeDuration !== undefined && + (obj.maxAgeDuration = message.maxAgeDuration + ? Duration.toJSON(message.maxAgeDuration) + : undefined); + message.maxBytes !== undefined && (obj.maxBytes = message.maxBytes); + return obj; + }, + + fromPartial(object: DeepPartial): EvidenceParams { + const message = { ...baseEvidenceParams } as EvidenceParams; + if ( + object.maxAgeNumBlocks !== undefined && + object.maxAgeNumBlocks !== null + ) { + message.maxAgeNumBlocks = object.maxAgeNumBlocks; + } else { + message.maxAgeNumBlocks = 0; + } + if (object.maxAgeDuration !== undefined && object.maxAgeDuration !== null) { + message.maxAgeDuration = Duration.fromPartial(object.maxAgeDuration); + } else { + message.maxAgeDuration = undefined; + } + if (object.maxBytes !== undefined && object.maxBytes !== null) { + message.maxBytes = object.maxBytes; + } else { + message.maxBytes = 0; + } + return message; + }, +}; + +const baseValidatorParams: object = { pubKeyTypes: "" }; + +export const ValidatorParams = { + encode(message: ValidatorParams, writer: Writer = Writer.create()): Writer { + for (const v of message.pubKeyTypes) { + writer.uint32(10).string(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ValidatorParams { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseValidatorParams } as ValidatorParams; + message.pubKeyTypes = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.pubKeyTypes.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ValidatorParams { + const message = { ...baseValidatorParams } as ValidatorParams; + message.pubKeyTypes = []; + if (object.pubKeyTypes !== undefined && object.pubKeyTypes !== null) { + for (const e of object.pubKeyTypes) { + message.pubKeyTypes.push(String(e)); + } + } + return message; + }, + + toJSON(message: ValidatorParams): unknown { + const obj: any = {}; + if (message.pubKeyTypes) { + obj.pubKeyTypes = message.pubKeyTypes.map((e) => e); + } else { + obj.pubKeyTypes = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): ValidatorParams { + const message = { ...baseValidatorParams } as ValidatorParams; + message.pubKeyTypes = []; + if (object.pubKeyTypes !== undefined && object.pubKeyTypes !== null) { + for (const e of object.pubKeyTypes) { + message.pubKeyTypes.push(e); + } + } + return message; + }, +}; + +const baseVersionParams: object = { appVersion: 0 }; + +export const VersionParams = { + encode(message: VersionParams, writer: Writer = Writer.create()): Writer { + if (message.appVersion !== 0) { + writer.uint32(8).uint64(message.appVersion); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): VersionParams { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseVersionParams } as VersionParams; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.appVersion = longToNumber(reader.uint64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): VersionParams { + const message = { ...baseVersionParams } as VersionParams; + if (object.appVersion !== undefined && object.appVersion !== null) { + message.appVersion = Number(object.appVersion); + } else { + message.appVersion = 0; + } + return message; + }, + + toJSON(message: VersionParams): unknown { + const obj: any = {}; + message.appVersion !== undefined && (obj.appVersion = message.appVersion); + return obj; + }, + + fromPartial(object: DeepPartial): VersionParams { + const message = { ...baseVersionParams } as VersionParams; + if (object.appVersion !== undefined && object.appVersion !== null) { + message.appVersion = object.appVersion; + } else { + message.appVersion = 0; + } + return message; + }, +}; + +const baseHashedParams: object = { blockMaxBytes: 0, blockMaxGas: 0 }; + +export const HashedParams = { + encode(message: HashedParams, writer: Writer = Writer.create()): Writer { + if (message.blockMaxBytes !== 0) { + writer.uint32(8).int64(message.blockMaxBytes); + } + if (message.blockMaxGas !== 0) { + writer.uint32(16).int64(message.blockMaxGas); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): HashedParams { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseHashedParams } as HashedParams; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.blockMaxBytes = longToNumber(reader.int64() as Long); + break; + case 2: + message.blockMaxGas = longToNumber(reader.int64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): HashedParams { + const message = { ...baseHashedParams } as HashedParams; + if (object.blockMaxBytes !== undefined && object.blockMaxBytes !== null) { + message.blockMaxBytes = Number(object.blockMaxBytes); + } else { + message.blockMaxBytes = 0; + } + if (object.blockMaxGas !== undefined && object.blockMaxGas !== null) { + message.blockMaxGas = Number(object.blockMaxGas); + } else { + message.blockMaxGas = 0; + } + return message; + }, + + toJSON(message: HashedParams): unknown { + const obj: any = {}; + message.blockMaxBytes !== undefined && + (obj.blockMaxBytes = message.blockMaxBytes); + message.blockMaxGas !== undefined && + (obj.blockMaxGas = message.blockMaxGas); + return obj; + }, + + fromPartial(object: DeepPartial): HashedParams { + const message = { ...baseHashedParams } as HashedParams; + if (object.blockMaxBytes !== undefined && object.blockMaxBytes !== null) { + message.blockMaxBytes = object.blockMaxBytes; + } else { + message.blockMaxBytes = 0; + } + if (object.blockMaxGas !== undefined && object.blockMaxGas !== null) { + message.blockMaxGas = object.blockMaxGas; + } else { + message.blockMaxGas = 0; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/cosmos.tx.v1beta1/types/tendermint/types/types.ts b/ts-client/cosmos.tx.v1beta1/types/tendermint/types/types.ts new file mode 100644 index 00000000..429c14a4 --- /dev/null +++ b/ts-client/cosmos.tx.v1beta1/types/tendermint/types/types.ts @@ -0,0 +1,1912 @@ +/* eslint-disable */ +import { Timestamp } from "../../google/protobuf/timestamp"; +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; +import { Proof } from "../../tendermint/crypto/proof"; +import { Consensus } from "../../tendermint/version/types"; +import { ValidatorSet } from "../../tendermint/types/validator"; + +export const protobufPackage = "tendermint.types"; + +/** BlockIdFlag indicates which BlcokID the signature is for */ +export enum BlockIDFlag { + BLOCK_ID_FLAG_UNKNOWN = 0, + BLOCK_ID_FLAG_ABSENT = 1, + BLOCK_ID_FLAG_COMMIT = 2, + BLOCK_ID_FLAG_NIL = 3, + UNRECOGNIZED = -1, +} + +export function blockIDFlagFromJSON(object: any): BlockIDFlag { + switch (object) { + case 0: + case "BLOCK_ID_FLAG_UNKNOWN": + return BlockIDFlag.BLOCK_ID_FLAG_UNKNOWN; + case 1: + case "BLOCK_ID_FLAG_ABSENT": + return BlockIDFlag.BLOCK_ID_FLAG_ABSENT; + case 2: + case "BLOCK_ID_FLAG_COMMIT": + return BlockIDFlag.BLOCK_ID_FLAG_COMMIT; + case 3: + case "BLOCK_ID_FLAG_NIL": + return BlockIDFlag.BLOCK_ID_FLAG_NIL; + case -1: + case "UNRECOGNIZED": + default: + return BlockIDFlag.UNRECOGNIZED; + } +} + +export function blockIDFlagToJSON(object: BlockIDFlag): string { + switch (object) { + case BlockIDFlag.BLOCK_ID_FLAG_UNKNOWN: + return "BLOCK_ID_FLAG_UNKNOWN"; + case BlockIDFlag.BLOCK_ID_FLAG_ABSENT: + return "BLOCK_ID_FLAG_ABSENT"; + case BlockIDFlag.BLOCK_ID_FLAG_COMMIT: + return "BLOCK_ID_FLAG_COMMIT"; + case BlockIDFlag.BLOCK_ID_FLAG_NIL: + return "BLOCK_ID_FLAG_NIL"; + default: + return "UNKNOWN"; + } +} + +/** SignedMsgType is a type of signed message in the consensus. */ +export enum SignedMsgType { + SIGNED_MSG_TYPE_UNKNOWN = 0, + /** SIGNED_MSG_TYPE_PREVOTE - Votes */ + SIGNED_MSG_TYPE_PREVOTE = 1, + SIGNED_MSG_TYPE_PRECOMMIT = 2, + /** SIGNED_MSG_TYPE_PROPOSAL - Proposals */ + SIGNED_MSG_TYPE_PROPOSAL = 32, + UNRECOGNIZED = -1, +} + +export function signedMsgTypeFromJSON(object: any): SignedMsgType { + switch (object) { + case 0: + case "SIGNED_MSG_TYPE_UNKNOWN": + return SignedMsgType.SIGNED_MSG_TYPE_UNKNOWN; + case 1: + case "SIGNED_MSG_TYPE_PREVOTE": + return SignedMsgType.SIGNED_MSG_TYPE_PREVOTE; + case 2: + case "SIGNED_MSG_TYPE_PRECOMMIT": + return SignedMsgType.SIGNED_MSG_TYPE_PRECOMMIT; + case 32: + case "SIGNED_MSG_TYPE_PROPOSAL": + return SignedMsgType.SIGNED_MSG_TYPE_PROPOSAL; + case -1: + case "UNRECOGNIZED": + default: + return SignedMsgType.UNRECOGNIZED; + } +} + +export function signedMsgTypeToJSON(object: SignedMsgType): string { + switch (object) { + case SignedMsgType.SIGNED_MSG_TYPE_UNKNOWN: + return "SIGNED_MSG_TYPE_UNKNOWN"; + case SignedMsgType.SIGNED_MSG_TYPE_PREVOTE: + return "SIGNED_MSG_TYPE_PREVOTE"; + case SignedMsgType.SIGNED_MSG_TYPE_PRECOMMIT: + return "SIGNED_MSG_TYPE_PRECOMMIT"; + case SignedMsgType.SIGNED_MSG_TYPE_PROPOSAL: + return "SIGNED_MSG_TYPE_PROPOSAL"; + default: + return "UNKNOWN"; + } +} + +/** PartsetHeader */ +export interface PartSetHeader { + total: number; + hash: Uint8Array; +} + +export interface Part { + index: number; + bytes: Uint8Array; + proof: Proof | undefined; +} + +/** BlockID */ +export interface BlockID { + hash: Uint8Array; + partSetHeader: PartSetHeader | undefined; +} + +/** Header defines the structure of a block header. */ +export interface Header { + /** basic block info */ + version: Consensus | undefined; + chainId: string; + height: number; + time: Date | undefined; + /** prev block info */ + lastBlockId: BlockID | undefined; + /** hashes of block data */ + lastCommitHash: Uint8Array; + /** transactions */ + dataHash: Uint8Array; + /** hashes from the app output from the prev block */ + validatorsHash: Uint8Array; + /** validators for the next block */ + nextValidatorsHash: Uint8Array; + /** consensus params for current block */ + consensusHash: Uint8Array; + /** state after txs from the previous block */ + appHash: Uint8Array; + /** root hash of all results from the txs from the previous block */ + lastResultsHash: Uint8Array; + /** consensus info */ + evidenceHash: Uint8Array; + /** original proposer of the block */ + proposerAddress: Uint8Array; +} + +/** Data contains the set of transactions included in the block */ +export interface Data { + /** + * Txs that will be applied by state @ block.Height+1. + * NOTE: not all txs here are valid. We're just agreeing on the order first. + * This means that block.AppHash does not include these txs. + */ + txs: Uint8Array[]; +} + +/** + * Vote represents a prevote, precommit, or commit vote from validators for + * consensus. + */ +export interface Vote { + type: SignedMsgType; + height: number; + round: number; + /** zero if vote is nil. */ + blockId: BlockID | undefined; + timestamp: Date | undefined; + validatorAddress: Uint8Array; + validatorIndex: number; + signature: Uint8Array; +} + +/** Commit contains the evidence that a block was committed by a set of validators. */ +export interface Commit { + height: number; + round: number; + blockId: BlockID | undefined; + signatures: CommitSig[]; +} + +/** CommitSig is a part of the Vote included in a Commit. */ +export interface CommitSig { + blockIdFlag: BlockIDFlag; + validatorAddress: Uint8Array; + timestamp: Date | undefined; + signature: Uint8Array; +} + +export interface Proposal { + type: SignedMsgType; + height: number; + round: number; + polRound: number; + blockId: BlockID | undefined; + timestamp: Date | undefined; + signature: Uint8Array; +} + +export interface SignedHeader { + header: Header | undefined; + commit: Commit | undefined; +} + +export interface LightBlock { + signedHeader: SignedHeader | undefined; + validatorSet: ValidatorSet | undefined; +} + +export interface BlockMeta { + blockId: BlockID | undefined; + blockSize: number; + header: Header | undefined; + numTxs: number; +} + +/** TxProof represents a Merkle proof of the presence of a transaction in the Merkle tree. */ +export interface TxProof { + rootHash: Uint8Array; + data: Uint8Array; + proof: Proof | undefined; +} + +const basePartSetHeader: object = { total: 0 }; + +export const PartSetHeader = { + encode(message: PartSetHeader, writer: Writer = Writer.create()): Writer { + if (message.total !== 0) { + writer.uint32(8).uint32(message.total); + } + if (message.hash.length !== 0) { + writer.uint32(18).bytes(message.hash); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): PartSetHeader { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...basePartSetHeader } as PartSetHeader; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.total = reader.uint32(); + break; + case 2: + message.hash = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): PartSetHeader { + const message = { ...basePartSetHeader } as PartSetHeader; + if (object.total !== undefined && object.total !== null) { + message.total = Number(object.total); + } else { + message.total = 0; + } + if (object.hash !== undefined && object.hash !== null) { + message.hash = bytesFromBase64(object.hash); + } + return message; + }, + + toJSON(message: PartSetHeader): unknown { + const obj: any = {}; + message.total !== undefined && (obj.total = message.total); + message.hash !== undefined && + (obj.hash = base64FromBytes( + message.hash !== undefined ? message.hash : new Uint8Array() + )); + return obj; + }, + + fromPartial(object: DeepPartial): PartSetHeader { + const message = { ...basePartSetHeader } as PartSetHeader; + if (object.total !== undefined && object.total !== null) { + message.total = object.total; + } else { + message.total = 0; + } + if (object.hash !== undefined && object.hash !== null) { + message.hash = object.hash; + } else { + message.hash = new Uint8Array(); + } + return message; + }, +}; + +const basePart: object = { index: 0 }; + +export const Part = { + encode(message: Part, writer: Writer = Writer.create()): Writer { + if (message.index !== 0) { + writer.uint32(8).uint32(message.index); + } + if (message.bytes.length !== 0) { + writer.uint32(18).bytes(message.bytes); + } + if (message.proof !== undefined) { + Proof.encode(message.proof, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Part { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...basePart } as Part; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.index = reader.uint32(); + break; + case 2: + message.bytes = reader.bytes(); + break; + case 3: + message.proof = Proof.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Part { + const message = { ...basePart } as Part; + if (object.index !== undefined && object.index !== null) { + message.index = Number(object.index); + } else { + message.index = 0; + } + if (object.bytes !== undefined && object.bytes !== null) { + message.bytes = bytesFromBase64(object.bytes); + } + if (object.proof !== undefined && object.proof !== null) { + message.proof = Proof.fromJSON(object.proof); + } else { + message.proof = undefined; + } + return message; + }, + + toJSON(message: Part): unknown { + const obj: any = {}; + message.index !== undefined && (obj.index = message.index); + message.bytes !== undefined && + (obj.bytes = base64FromBytes( + message.bytes !== undefined ? message.bytes : new Uint8Array() + )); + message.proof !== undefined && + (obj.proof = message.proof ? Proof.toJSON(message.proof) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): Part { + const message = { ...basePart } as Part; + if (object.index !== undefined && object.index !== null) { + message.index = object.index; + } else { + message.index = 0; + } + if (object.bytes !== undefined && object.bytes !== null) { + message.bytes = object.bytes; + } else { + message.bytes = new Uint8Array(); + } + if (object.proof !== undefined && object.proof !== null) { + message.proof = Proof.fromPartial(object.proof); + } else { + message.proof = undefined; + } + return message; + }, +}; + +const baseBlockID: object = {}; + +export const BlockID = { + encode(message: BlockID, writer: Writer = Writer.create()): Writer { + if (message.hash.length !== 0) { + writer.uint32(10).bytes(message.hash); + } + if (message.partSetHeader !== undefined) { + PartSetHeader.encode( + message.partSetHeader, + writer.uint32(18).fork() + ).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): BlockID { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseBlockID } as BlockID; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.hash = reader.bytes(); + break; + case 2: + message.partSetHeader = PartSetHeader.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): BlockID { + const message = { ...baseBlockID } as BlockID; + if (object.hash !== undefined && object.hash !== null) { + message.hash = bytesFromBase64(object.hash); + } + if (object.partSetHeader !== undefined && object.partSetHeader !== null) { + message.partSetHeader = PartSetHeader.fromJSON(object.partSetHeader); + } else { + message.partSetHeader = undefined; + } + return message; + }, + + toJSON(message: BlockID): unknown { + const obj: any = {}; + message.hash !== undefined && + (obj.hash = base64FromBytes( + message.hash !== undefined ? message.hash : new Uint8Array() + )); + message.partSetHeader !== undefined && + (obj.partSetHeader = message.partSetHeader + ? PartSetHeader.toJSON(message.partSetHeader) + : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): BlockID { + const message = { ...baseBlockID } as BlockID; + if (object.hash !== undefined && object.hash !== null) { + message.hash = object.hash; + } else { + message.hash = new Uint8Array(); + } + if (object.partSetHeader !== undefined && object.partSetHeader !== null) { + message.partSetHeader = PartSetHeader.fromPartial(object.partSetHeader); + } else { + message.partSetHeader = undefined; + } + return message; + }, +}; + +const baseHeader: object = { chainId: "", height: 0 }; + +export const Header = { + encode(message: Header, writer: Writer = Writer.create()): Writer { + if (message.version !== undefined) { + Consensus.encode(message.version, writer.uint32(10).fork()).ldelim(); + } + if (message.chainId !== "") { + writer.uint32(18).string(message.chainId); + } + if (message.height !== 0) { + writer.uint32(24).int64(message.height); + } + if (message.time !== undefined) { + Timestamp.encode( + toTimestamp(message.time), + writer.uint32(34).fork() + ).ldelim(); + } + if (message.lastBlockId !== undefined) { + BlockID.encode(message.lastBlockId, writer.uint32(42).fork()).ldelim(); + } + if (message.lastCommitHash.length !== 0) { + writer.uint32(50).bytes(message.lastCommitHash); + } + if (message.dataHash.length !== 0) { + writer.uint32(58).bytes(message.dataHash); + } + if (message.validatorsHash.length !== 0) { + writer.uint32(66).bytes(message.validatorsHash); + } + if (message.nextValidatorsHash.length !== 0) { + writer.uint32(74).bytes(message.nextValidatorsHash); + } + if (message.consensusHash.length !== 0) { + writer.uint32(82).bytes(message.consensusHash); + } + if (message.appHash.length !== 0) { + writer.uint32(90).bytes(message.appHash); + } + if (message.lastResultsHash.length !== 0) { + writer.uint32(98).bytes(message.lastResultsHash); + } + if (message.evidenceHash.length !== 0) { + writer.uint32(106).bytes(message.evidenceHash); + } + if (message.proposerAddress.length !== 0) { + writer.uint32(114).bytes(message.proposerAddress); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Header { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseHeader } as Header; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.version = Consensus.decode(reader, reader.uint32()); + break; + case 2: + message.chainId = reader.string(); + break; + case 3: + message.height = longToNumber(reader.int64() as Long); + break; + case 4: + message.time = fromTimestamp( + Timestamp.decode(reader, reader.uint32()) + ); + break; + case 5: + message.lastBlockId = BlockID.decode(reader, reader.uint32()); + break; + case 6: + message.lastCommitHash = reader.bytes(); + break; + case 7: + message.dataHash = reader.bytes(); + break; + case 8: + message.validatorsHash = reader.bytes(); + break; + case 9: + message.nextValidatorsHash = reader.bytes(); + break; + case 10: + message.consensusHash = reader.bytes(); + break; + case 11: + message.appHash = reader.bytes(); + break; + case 12: + message.lastResultsHash = reader.bytes(); + break; + case 13: + message.evidenceHash = reader.bytes(); + break; + case 14: + message.proposerAddress = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Header { + const message = { ...baseHeader } as Header; + if (object.version !== undefined && object.version !== null) { + message.version = Consensus.fromJSON(object.version); + } else { + message.version = undefined; + } + if (object.chainId !== undefined && object.chainId !== null) { + message.chainId = String(object.chainId); + } else { + message.chainId = ""; + } + if (object.height !== undefined && object.height !== null) { + message.height = Number(object.height); + } else { + message.height = 0; + } + if (object.time !== undefined && object.time !== null) { + message.time = fromJsonTimestamp(object.time); + } else { + message.time = undefined; + } + if (object.lastBlockId !== undefined && object.lastBlockId !== null) { + message.lastBlockId = BlockID.fromJSON(object.lastBlockId); + } else { + message.lastBlockId = undefined; + } + if (object.lastCommitHash !== undefined && object.lastCommitHash !== null) { + message.lastCommitHash = bytesFromBase64(object.lastCommitHash); + } + if (object.dataHash !== undefined && object.dataHash !== null) { + message.dataHash = bytesFromBase64(object.dataHash); + } + if (object.validatorsHash !== undefined && object.validatorsHash !== null) { + message.validatorsHash = bytesFromBase64(object.validatorsHash); + } + if ( + object.nextValidatorsHash !== undefined && + object.nextValidatorsHash !== null + ) { + message.nextValidatorsHash = bytesFromBase64(object.nextValidatorsHash); + } + if (object.consensusHash !== undefined && object.consensusHash !== null) { + message.consensusHash = bytesFromBase64(object.consensusHash); + } + if (object.appHash !== undefined && object.appHash !== null) { + message.appHash = bytesFromBase64(object.appHash); + } + if ( + object.lastResultsHash !== undefined && + object.lastResultsHash !== null + ) { + message.lastResultsHash = bytesFromBase64(object.lastResultsHash); + } + if (object.evidenceHash !== undefined && object.evidenceHash !== null) { + message.evidenceHash = bytesFromBase64(object.evidenceHash); + } + if ( + object.proposerAddress !== undefined && + object.proposerAddress !== null + ) { + message.proposerAddress = bytesFromBase64(object.proposerAddress); + } + return message; + }, + + toJSON(message: Header): unknown { + const obj: any = {}; + message.version !== undefined && + (obj.version = message.version + ? Consensus.toJSON(message.version) + : undefined); + message.chainId !== undefined && (obj.chainId = message.chainId); + message.height !== undefined && (obj.height = message.height); + message.time !== undefined && + (obj.time = + message.time !== undefined ? message.time.toISOString() : null); + message.lastBlockId !== undefined && + (obj.lastBlockId = message.lastBlockId + ? BlockID.toJSON(message.lastBlockId) + : undefined); + message.lastCommitHash !== undefined && + (obj.lastCommitHash = base64FromBytes( + message.lastCommitHash !== undefined + ? message.lastCommitHash + : new Uint8Array() + )); + message.dataHash !== undefined && + (obj.dataHash = base64FromBytes( + message.dataHash !== undefined ? message.dataHash : new Uint8Array() + )); + message.validatorsHash !== undefined && + (obj.validatorsHash = base64FromBytes( + message.validatorsHash !== undefined + ? message.validatorsHash + : new Uint8Array() + )); + message.nextValidatorsHash !== undefined && + (obj.nextValidatorsHash = base64FromBytes( + message.nextValidatorsHash !== undefined + ? message.nextValidatorsHash + : new Uint8Array() + )); + message.consensusHash !== undefined && + (obj.consensusHash = base64FromBytes( + message.consensusHash !== undefined + ? message.consensusHash + : new Uint8Array() + )); + message.appHash !== undefined && + (obj.appHash = base64FromBytes( + message.appHash !== undefined ? message.appHash : new Uint8Array() + )); + message.lastResultsHash !== undefined && + (obj.lastResultsHash = base64FromBytes( + message.lastResultsHash !== undefined + ? message.lastResultsHash + : new Uint8Array() + )); + message.evidenceHash !== undefined && + (obj.evidenceHash = base64FromBytes( + message.evidenceHash !== undefined + ? message.evidenceHash + : new Uint8Array() + )); + message.proposerAddress !== undefined && + (obj.proposerAddress = base64FromBytes( + message.proposerAddress !== undefined + ? message.proposerAddress + : new Uint8Array() + )); + return obj; + }, + + fromPartial(object: DeepPartial
): Header { + const message = { ...baseHeader } as Header; + if (object.version !== undefined && object.version !== null) { + message.version = Consensus.fromPartial(object.version); + } else { + message.version = undefined; + } + if (object.chainId !== undefined && object.chainId !== null) { + message.chainId = object.chainId; + } else { + message.chainId = ""; + } + if (object.height !== undefined && object.height !== null) { + message.height = object.height; + } else { + message.height = 0; + } + if (object.time !== undefined && object.time !== null) { + message.time = object.time; + } else { + message.time = undefined; + } + if (object.lastBlockId !== undefined && object.lastBlockId !== null) { + message.lastBlockId = BlockID.fromPartial(object.lastBlockId); + } else { + message.lastBlockId = undefined; + } + if (object.lastCommitHash !== undefined && object.lastCommitHash !== null) { + message.lastCommitHash = object.lastCommitHash; + } else { + message.lastCommitHash = new Uint8Array(); + } + if (object.dataHash !== undefined && object.dataHash !== null) { + message.dataHash = object.dataHash; + } else { + message.dataHash = new Uint8Array(); + } + if (object.validatorsHash !== undefined && object.validatorsHash !== null) { + message.validatorsHash = object.validatorsHash; + } else { + message.validatorsHash = new Uint8Array(); + } + if ( + object.nextValidatorsHash !== undefined && + object.nextValidatorsHash !== null + ) { + message.nextValidatorsHash = object.nextValidatorsHash; + } else { + message.nextValidatorsHash = new Uint8Array(); + } + if (object.consensusHash !== undefined && object.consensusHash !== null) { + message.consensusHash = object.consensusHash; + } else { + message.consensusHash = new Uint8Array(); + } + if (object.appHash !== undefined && object.appHash !== null) { + message.appHash = object.appHash; + } else { + message.appHash = new Uint8Array(); + } + if ( + object.lastResultsHash !== undefined && + object.lastResultsHash !== null + ) { + message.lastResultsHash = object.lastResultsHash; + } else { + message.lastResultsHash = new Uint8Array(); + } + if (object.evidenceHash !== undefined && object.evidenceHash !== null) { + message.evidenceHash = object.evidenceHash; + } else { + message.evidenceHash = new Uint8Array(); + } + if ( + object.proposerAddress !== undefined && + object.proposerAddress !== null + ) { + message.proposerAddress = object.proposerAddress; + } else { + message.proposerAddress = new Uint8Array(); + } + return message; + }, +}; + +const baseData: object = {}; + +export const Data = { + encode(message: Data, writer: Writer = Writer.create()): Writer { + for (const v of message.txs) { + writer.uint32(10).bytes(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Data { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseData } as Data; + message.txs = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.txs.push(reader.bytes()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Data { + const message = { ...baseData } as Data; + message.txs = []; + if (object.txs !== undefined && object.txs !== null) { + for (const e of object.txs) { + message.txs.push(bytesFromBase64(e)); + } + } + return message; + }, + + toJSON(message: Data): unknown { + const obj: any = {}; + if (message.txs) { + obj.txs = message.txs.map((e) => + base64FromBytes(e !== undefined ? e : new Uint8Array()) + ); + } else { + obj.txs = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): Data { + const message = { ...baseData } as Data; + message.txs = []; + if (object.txs !== undefined && object.txs !== null) { + for (const e of object.txs) { + message.txs.push(e); + } + } + return message; + }, +}; + +const baseVote: object = { type: 0, height: 0, round: 0, validatorIndex: 0 }; + +export const Vote = { + encode(message: Vote, writer: Writer = Writer.create()): Writer { + if (message.type !== 0) { + writer.uint32(8).int32(message.type); + } + if (message.height !== 0) { + writer.uint32(16).int64(message.height); + } + if (message.round !== 0) { + writer.uint32(24).int32(message.round); + } + if (message.blockId !== undefined) { + BlockID.encode(message.blockId, writer.uint32(34).fork()).ldelim(); + } + if (message.timestamp !== undefined) { + Timestamp.encode( + toTimestamp(message.timestamp), + writer.uint32(42).fork() + ).ldelim(); + } + if (message.validatorAddress.length !== 0) { + writer.uint32(50).bytes(message.validatorAddress); + } + if (message.validatorIndex !== 0) { + writer.uint32(56).int32(message.validatorIndex); + } + if (message.signature.length !== 0) { + writer.uint32(66).bytes(message.signature); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Vote { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseVote } as Vote; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.type = reader.int32() as any; + break; + case 2: + message.height = longToNumber(reader.int64() as Long); + break; + case 3: + message.round = reader.int32(); + break; + case 4: + message.blockId = BlockID.decode(reader, reader.uint32()); + break; + case 5: + message.timestamp = fromTimestamp( + Timestamp.decode(reader, reader.uint32()) + ); + break; + case 6: + message.validatorAddress = reader.bytes(); + break; + case 7: + message.validatorIndex = reader.int32(); + break; + case 8: + message.signature = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Vote { + const message = { ...baseVote } as Vote; + if (object.type !== undefined && object.type !== null) { + message.type = signedMsgTypeFromJSON(object.type); + } else { + message.type = 0; + } + if (object.height !== undefined && object.height !== null) { + message.height = Number(object.height); + } else { + message.height = 0; + } + if (object.round !== undefined && object.round !== null) { + message.round = Number(object.round); + } else { + message.round = 0; + } + if (object.blockId !== undefined && object.blockId !== null) { + message.blockId = BlockID.fromJSON(object.blockId); + } else { + message.blockId = undefined; + } + if (object.timestamp !== undefined && object.timestamp !== null) { + message.timestamp = fromJsonTimestamp(object.timestamp); + } else { + message.timestamp = undefined; + } + if ( + object.validatorAddress !== undefined && + object.validatorAddress !== null + ) { + message.validatorAddress = bytesFromBase64(object.validatorAddress); + } + if (object.validatorIndex !== undefined && object.validatorIndex !== null) { + message.validatorIndex = Number(object.validatorIndex); + } else { + message.validatorIndex = 0; + } + if (object.signature !== undefined && object.signature !== null) { + message.signature = bytesFromBase64(object.signature); + } + return message; + }, + + toJSON(message: Vote): unknown { + const obj: any = {}; + message.type !== undefined && + (obj.type = signedMsgTypeToJSON(message.type)); + message.height !== undefined && (obj.height = message.height); + message.round !== undefined && (obj.round = message.round); + message.blockId !== undefined && + (obj.blockId = message.blockId + ? BlockID.toJSON(message.blockId) + : undefined); + message.timestamp !== undefined && + (obj.timestamp = + message.timestamp !== undefined + ? message.timestamp.toISOString() + : null); + message.validatorAddress !== undefined && + (obj.validatorAddress = base64FromBytes( + message.validatorAddress !== undefined + ? message.validatorAddress + : new Uint8Array() + )); + message.validatorIndex !== undefined && + (obj.validatorIndex = message.validatorIndex); + message.signature !== undefined && + (obj.signature = base64FromBytes( + message.signature !== undefined ? message.signature : new Uint8Array() + )); + return obj; + }, + + fromPartial(object: DeepPartial): Vote { + const message = { ...baseVote } as Vote; + if (object.type !== undefined && object.type !== null) { + message.type = object.type; + } else { + message.type = 0; + } + if (object.height !== undefined && object.height !== null) { + message.height = object.height; + } else { + message.height = 0; + } + if (object.round !== undefined && object.round !== null) { + message.round = object.round; + } else { + message.round = 0; + } + if (object.blockId !== undefined && object.blockId !== null) { + message.blockId = BlockID.fromPartial(object.blockId); + } else { + message.blockId = undefined; + } + if (object.timestamp !== undefined && object.timestamp !== null) { + message.timestamp = object.timestamp; + } else { + message.timestamp = undefined; + } + if ( + object.validatorAddress !== undefined && + object.validatorAddress !== null + ) { + message.validatorAddress = object.validatorAddress; + } else { + message.validatorAddress = new Uint8Array(); + } + if (object.validatorIndex !== undefined && object.validatorIndex !== null) { + message.validatorIndex = object.validatorIndex; + } else { + message.validatorIndex = 0; + } + if (object.signature !== undefined && object.signature !== null) { + message.signature = object.signature; + } else { + message.signature = new Uint8Array(); + } + return message; + }, +}; + +const baseCommit: object = { height: 0, round: 0 }; + +export const Commit = { + encode(message: Commit, writer: Writer = Writer.create()): Writer { + if (message.height !== 0) { + writer.uint32(8).int64(message.height); + } + if (message.round !== 0) { + writer.uint32(16).int32(message.round); + } + if (message.blockId !== undefined) { + BlockID.encode(message.blockId, writer.uint32(26).fork()).ldelim(); + } + for (const v of message.signatures) { + CommitSig.encode(v!, writer.uint32(34).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Commit { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseCommit } as Commit; + message.signatures = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.height = longToNumber(reader.int64() as Long); + break; + case 2: + message.round = reader.int32(); + break; + case 3: + message.blockId = BlockID.decode(reader, reader.uint32()); + break; + case 4: + message.signatures.push(CommitSig.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Commit { + const message = { ...baseCommit } as Commit; + message.signatures = []; + if (object.height !== undefined && object.height !== null) { + message.height = Number(object.height); + } else { + message.height = 0; + } + if (object.round !== undefined && object.round !== null) { + message.round = Number(object.round); + } else { + message.round = 0; + } + if (object.blockId !== undefined && object.blockId !== null) { + message.blockId = BlockID.fromJSON(object.blockId); + } else { + message.blockId = undefined; + } + if (object.signatures !== undefined && object.signatures !== null) { + for (const e of object.signatures) { + message.signatures.push(CommitSig.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: Commit): unknown { + const obj: any = {}; + message.height !== undefined && (obj.height = message.height); + message.round !== undefined && (obj.round = message.round); + message.blockId !== undefined && + (obj.blockId = message.blockId + ? BlockID.toJSON(message.blockId) + : undefined); + if (message.signatures) { + obj.signatures = message.signatures.map((e) => + e ? CommitSig.toJSON(e) : undefined + ); + } else { + obj.signatures = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): Commit { + const message = { ...baseCommit } as Commit; + message.signatures = []; + if (object.height !== undefined && object.height !== null) { + message.height = object.height; + } else { + message.height = 0; + } + if (object.round !== undefined && object.round !== null) { + message.round = object.round; + } else { + message.round = 0; + } + if (object.blockId !== undefined && object.blockId !== null) { + message.blockId = BlockID.fromPartial(object.blockId); + } else { + message.blockId = undefined; + } + if (object.signatures !== undefined && object.signatures !== null) { + for (const e of object.signatures) { + message.signatures.push(CommitSig.fromPartial(e)); + } + } + return message; + }, +}; + +const baseCommitSig: object = { blockIdFlag: 0 }; + +export const CommitSig = { + encode(message: CommitSig, writer: Writer = Writer.create()): Writer { + if (message.blockIdFlag !== 0) { + writer.uint32(8).int32(message.blockIdFlag); + } + if (message.validatorAddress.length !== 0) { + writer.uint32(18).bytes(message.validatorAddress); + } + if (message.timestamp !== undefined) { + Timestamp.encode( + toTimestamp(message.timestamp), + writer.uint32(26).fork() + ).ldelim(); + } + if (message.signature.length !== 0) { + writer.uint32(34).bytes(message.signature); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): CommitSig { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseCommitSig } as CommitSig; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.blockIdFlag = reader.int32() as any; + break; + case 2: + message.validatorAddress = reader.bytes(); + break; + case 3: + message.timestamp = fromTimestamp( + Timestamp.decode(reader, reader.uint32()) + ); + break; + case 4: + message.signature = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): CommitSig { + const message = { ...baseCommitSig } as CommitSig; + if (object.blockIdFlag !== undefined && object.blockIdFlag !== null) { + message.blockIdFlag = blockIDFlagFromJSON(object.blockIdFlag); + } else { + message.blockIdFlag = 0; + } + if ( + object.validatorAddress !== undefined && + object.validatorAddress !== null + ) { + message.validatorAddress = bytesFromBase64(object.validatorAddress); + } + if (object.timestamp !== undefined && object.timestamp !== null) { + message.timestamp = fromJsonTimestamp(object.timestamp); + } else { + message.timestamp = undefined; + } + if (object.signature !== undefined && object.signature !== null) { + message.signature = bytesFromBase64(object.signature); + } + return message; + }, + + toJSON(message: CommitSig): unknown { + const obj: any = {}; + message.blockIdFlag !== undefined && + (obj.blockIdFlag = blockIDFlagToJSON(message.blockIdFlag)); + message.validatorAddress !== undefined && + (obj.validatorAddress = base64FromBytes( + message.validatorAddress !== undefined + ? message.validatorAddress + : new Uint8Array() + )); + message.timestamp !== undefined && + (obj.timestamp = + message.timestamp !== undefined + ? message.timestamp.toISOString() + : null); + message.signature !== undefined && + (obj.signature = base64FromBytes( + message.signature !== undefined ? message.signature : new Uint8Array() + )); + return obj; + }, + + fromPartial(object: DeepPartial): CommitSig { + const message = { ...baseCommitSig } as CommitSig; + if (object.blockIdFlag !== undefined && object.blockIdFlag !== null) { + message.blockIdFlag = object.blockIdFlag; + } else { + message.blockIdFlag = 0; + } + if ( + object.validatorAddress !== undefined && + object.validatorAddress !== null + ) { + message.validatorAddress = object.validatorAddress; + } else { + message.validatorAddress = new Uint8Array(); + } + if (object.timestamp !== undefined && object.timestamp !== null) { + message.timestamp = object.timestamp; + } else { + message.timestamp = undefined; + } + if (object.signature !== undefined && object.signature !== null) { + message.signature = object.signature; + } else { + message.signature = new Uint8Array(); + } + return message; + }, +}; + +const baseProposal: object = { type: 0, height: 0, round: 0, polRound: 0 }; + +export const Proposal = { + encode(message: Proposal, writer: Writer = Writer.create()): Writer { + if (message.type !== 0) { + writer.uint32(8).int32(message.type); + } + if (message.height !== 0) { + writer.uint32(16).int64(message.height); + } + if (message.round !== 0) { + writer.uint32(24).int32(message.round); + } + if (message.polRound !== 0) { + writer.uint32(32).int32(message.polRound); + } + if (message.blockId !== undefined) { + BlockID.encode(message.blockId, writer.uint32(42).fork()).ldelim(); + } + if (message.timestamp !== undefined) { + Timestamp.encode( + toTimestamp(message.timestamp), + writer.uint32(50).fork() + ).ldelim(); + } + if (message.signature.length !== 0) { + writer.uint32(58).bytes(message.signature); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Proposal { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseProposal } as Proposal; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.type = reader.int32() as any; + break; + case 2: + message.height = longToNumber(reader.int64() as Long); + break; + case 3: + message.round = reader.int32(); + break; + case 4: + message.polRound = reader.int32(); + break; + case 5: + message.blockId = BlockID.decode(reader, reader.uint32()); + break; + case 6: + message.timestamp = fromTimestamp( + Timestamp.decode(reader, reader.uint32()) + ); + break; + case 7: + message.signature = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Proposal { + const message = { ...baseProposal } as Proposal; + if (object.type !== undefined && object.type !== null) { + message.type = signedMsgTypeFromJSON(object.type); + } else { + message.type = 0; + } + if (object.height !== undefined && object.height !== null) { + message.height = Number(object.height); + } else { + message.height = 0; + } + if (object.round !== undefined && object.round !== null) { + message.round = Number(object.round); + } else { + message.round = 0; + } + if (object.polRound !== undefined && object.polRound !== null) { + message.polRound = Number(object.polRound); + } else { + message.polRound = 0; + } + if (object.blockId !== undefined && object.blockId !== null) { + message.blockId = BlockID.fromJSON(object.blockId); + } else { + message.blockId = undefined; + } + if (object.timestamp !== undefined && object.timestamp !== null) { + message.timestamp = fromJsonTimestamp(object.timestamp); + } else { + message.timestamp = undefined; + } + if (object.signature !== undefined && object.signature !== null) { + message.signature = bytesFromBase64(object.signature); + } + return message; + }, + + toJSON(message: Proposal): unknown { + const obj: any = {}; + message.type !== undefined && + (obj.type = signedMsgTypeToJSON(message.type)); + message.height !== undefined && (obj.height = message.height); + message.round !== undefined && (obj.round = message.round); + message.polRound !== undefined && (obj.polRound = message.polRound); + message.blockId !== undefined && + (obj.blockId = message.blockId + ? BlockID.toJSON(message.blockId) + : undefined); + message.timestamp !== undefined && + (obj.timestamp = + message.timestamp !== undefined + ? message.timestamp.toISOString() + : null); + message.signature !== undefined && + (obj.signature = base64FromBytes( + message.signature !== undefined ? message.signature : new Uint8Array() + )); + return obj; + }, + + fromPartial(object: DeepPartial): Proposal { + const message = { ...baseProposal } as Proposal; + if (object.type !== undefined && object.type !== null) { + message.type = object.type; + } else { + message.type = 0; + } + if (object.height !== undefined && object.height !== null) { + message.height = object.height; + } else { + message.height = 0; + } + if (object.round !== undefined && object.round !== null) { + message.round = object.round; + } else { + message.round = 0; + } + if (object.polRound !== undefined && object.polRound !== null) { + message.polRound = object.polRound; + } else { + message.polRound = 0; + } + if (object.blockId !== undefined && object.blockId !== null) { + message.blockId = BlockID.fromPartial(object.blockId); + } else { + message.blockId = undefined; + } + if (object.timestamp !== undefined && object.timestamp !== null) { + message.timestamp = object.timestamp; + } else { + message.timestamp = undefined; + } + if (object.signature !== undefined && object.signature !== null) { + message.signature = object.signature; + } else { + message.signature = new Uint8Array(); + } + return message; + }, +}; + +const baseSignedHeader: object = {}; + +export const SignedHeader = { + encode(message: SignedHeader, writer: Writer = Writer.create()): Writer { + if (message.header !== undefined) { + Header.encode(message.header, writer.uint32(10).fork()).ldelim(); + } + if (message.commit !== undefined) { + Commit.encode(message.commit, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): SignedHeader { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseSignedHeader } as SignedHeader; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.header = Header.decode(reader, reader.uint32()); + break; + case 2: + message.commit = Commit.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): SignedHeader { + const message = { ...baseSignedHeader } as SignedHeader; + if (object.header !== undefined && object.header !== null) { + message.header = Header.fromJSON(object.header); + } else { + message.header = undefined; + } + if (object.commit !== undefined && object.commit !== null) { + message.commit = Commit.fromJSON(object.commit); + } else { + message.commit = undefined; + } + return message; + }, + + toJSON(message: SignedHeader): unknown { + const obj: any = {}; + message.header !== undefined && + (obj.header = message.header ? Header.toJSON(message.header) : undefined); + message.commit !== undefined && + (obj.commit = message.commit ? Commit.toJSON(message.commit) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): SignedHeader { + const message = { ...baseSignedHeader } as SignedHeader; + if (object.header !== undefined && object.header !== null) { + message.header = Header.fromPartial(object.header); + } else { + message.header = undefined; + } + if (object.commit !== undefined && object.commit !== null) { + message.commit = Commit.fromPartial(object.commit); + } else { + message.commit = undefined; + } + return message; + }, +}; + +const baseLightBlock: object = {}; + +export const LightBlock = { + encode(message: LightBlock, writer: Writer = Writer.create()): Writer { + if (message.signedHeader !== undefined) { + SignedHeader.encode( + message.signedHeader, + writer.uint32(10).fork() + ).ldelim(); + } + if (message.validatorSet !== undefined) { + ValidatorSet.encode( + message.validatorSet, + writer.uint32(18).fork() + ).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): LightBlock { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseLightBlock } as LightBlock; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.signedHeader = SignedHeader.decode(reader, reader.uint32()); + break; + case 2: + message.validatorSet = ValidatorSet.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): LightBlock { + const message = { ...baseLightBlock } as LightBlock; + if (object.signedHeader !== undefined && object.signedHeader !== null) { + message.signedHeader = SignedHeader.fromJSON(object.signedHeader); + } else { + message.signedHeader = undefined; + } + if (object.validatorSet !== undefined && object.validatorSet !== null) { + message.validatorSet = ValidatorSet.fromJSON(object.validatorSet); + } else { + message.validatorSet = undefined; + } + return message; + }, + + toJSON(message: LightBlock): unknown { + const obj: any = {}; + message.signedHeader !== undefined && + (obj.signedHeader = message.signedHeader + ? SignedHeader.toJSON(message.signedHeader) + : undefined); + message.validatorSet !== undefined && + (obj.validatorSet = message.validatorSet + ? ValidatorSet.toJSON(message.validatorSet) + : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): LightBlock { + const message = { ...baseLightBlock } as LightBlock; + if (object.signedHeader !== undefined && object.signedHeader !== null) { + message.signedHeader = SignedHeader.fromPartial(object.signedHeader); + } else { + message.signedHeader = undefined; + } + if (object.validatorSet !== undefined && object.validatorSet !== null) { + message.validatorSet = ValidatorSet.fromPartial(object.validatorSet); + } else { + message.validatorSet = undefined; + } + return message; + }, +}; + +const baseBlockMeta: object = { blockSize: 0, numTxs: 0 }; + +export const BlockMeta = { + encode(message: BlockMeta, writer: Writer = Writer.create()): Writer { + if (message.blockId !== undefined) { + BlockID.encode(message.blockId, writer.uint32(10).fork()).ldelim(); + } + if (message.blockSize !== 0) { + writer.uint32(16).int64(message.blockSize); + } + if (message.header !== undefined) { + Header.encode(message.header, writer.uint32(26).fork()).ldelim(); + } + if (message.numTxs !== 0) { + writer.uint32(32).int64(message.numTxs); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): BlockMeta { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseBlockMeta } as BlockMeta; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.blockId = BlockID.decode(reader, reader.uint32()); + break; + case 2: + message.blockSize = longToNumber(reader.int64() as Long); + break; + case 3: + message.header = Header.decode(reader, reader.uint32()); + break; + case 4: + message.numTxs = longToNumber(reader.int64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): BlockMeta { + const message = { ...baseBlockMeta } as BlockMeta; + if (object.blockId !== undefined && object.blockId !== null) { + message.blockId = BlockID.fromJSON(object.blockId); + } else { + message.blockId = undefined; + } + if (object.blockSize !== undefined && object.blockSize !== null) { + message.blockSize = Number(object.blockSize); + } else { + message.blockSize = 0; + } + if (object.header !== undefined && object.header !== null) { + message.header = Header.fromJSON(object.header); + } else { + message.header = undefined; + } + if (object.numTxs !== undefined && object.numTxs !== null) { + message.numTxs = Number(object.numTxs); + } else { + message.numTxs = 0; + } + return message; + }, + + toJSON(message: BlockMeta): unknown { + const obj: any = {}; + message.blockId !== undefined && + (obj.blockId = message.blockId + ? BlockID.toJSON(message.blockId) + : undefined); + message.blockSize !== undefined && (obj.blockSize = message.blockSize); + message.header !== undefined && + (obj.header = message.header ? Header.toJSON(message.header) : undefined); + message.numTxs !== undefined && (obj.numTxs = message.numTxs); + return obj; + }, + + fromPartial(object: DeepPartial): BlockMeta { + const message = { ...baseBlockMeta } as BlockMeta; + if (object.blockId !== undefined && object.blockId !== null) { + message.blockId = BlockID.fromPartial(object.blockId); + } else { + message.blockId = undefined; + } + if (object.blockSize !== undefined && object.blockSize !== null) { + message.blockSize = object.blockSize; + } else { + message.blockSize = 0; + } + if (object.header !== undefined && object.header !== null) { + message.header = Header.fromPartial(object.header); + } else { + message.header = undefined; + } + if (object.numTxs !== undefined && object.numTxs !== null) { + message.numTxs = object.numTxs; + } else { + message.numTxs = 0; + } + return message; + }, +}; + +const baseTxProof: object = {}; + +export const TxProof = { + encode(message: TxProof, writer: Writer = Writer.create()): Writer { + if (message.rootHash.length !== 0) { + writer.uint32(10).bytes(message.rootHash); + } + if (message.data.length !== 0) { + writer.uint32(18).bytes(message.data); + } + if (message.proof !== undefined) { + Proof.encode(message.proof, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): TxProof { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseTxProof } as TxProof; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.rootHash = reader.bytes(); + break; + case 2: + message.data = reader.bytes(); + break; + case 3: + message.proof = Proof.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): TxProof { + const message = { ...baseTxProof } as TxProof; + if (object.rootHash !== undefined && object.rootHash !== null) { + message.rootHash = bytesFromBase64(object.rootHash); + } + if (object.data !== undefined && object.data !== null) { + message.data = bytesFromBase64(object.data); + } + if (object.proof !== undefined && object.proof !== null) { + message.proof = Proof.fromJSON(object.proof); + } else { + message.proof = undefined; + } + return message; + }, + + toJSON(message: TxProof): unknown { + const obj: any = {}; + message.rootHash !== undefined && + (obj.rootHash = base64FromBytes( + message.rootHash !== undefined ? message.rootHash : new Uint8Array() + )); + message.data !== undefined && + (obj.data = base64FromBytes( + message.data !== undefined ? message.data : new Uint8Array() + )); + message.proof !== undefined && + (obj.proof = message.proof ? Proof.toJSON(message.proof) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): TxProof { + const message = { ...baseTxProof } as TxProof; + if (object.rootHash !== undefined && object.rootHash !== null) { + message.rootHash = object.rootHash; + } else { + message.rootHash = new Uint8Array(); + } + if (object.data !== undefined && object.data !== null) { + message.data = object.data; + } else { + message.data = new Uint8Array(); + } + if (object.proof !== undefined && object.proof !== null) { + message.proof = Proof.fromPartial(object.proof); + } else { + message.proof = undefined; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function toTimestamp(date: Date): Timestamp { + const seconds = date.getTime() / 1_000; + const nanos = (date.getTime() % 1_000) * 1_000_000; + return { seconds, nanos }; +} + +function fromTimestamp(t: Timestamp): Date { + let millis = t.seconds * 1_000; + millis += t.nanos / 1_000_000; + return new Date(millis); +} + +function fromJsonTimestamp(o: any): Date { + if (o instanceof Date) { + return o; + } else if (typeof o === "string") { + return new Date(o); + } else { + return fromTimestamp(Timestamp.fromJSON(o)); + } +} + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/cosmos.tx.v1beta1/types/tendermint/types/validator.ts b/ts-client/cosmos.tx.v1beta1/types/tendermint/types/validator.ts new file mode 100644 index 00000000..c5044032 --- /dev/null +++ b/ts-client/cosmos.tx.v1beta1/types/tendermint/types/validator.ts @@ -0,0 +1,382 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; +import { PublicKey } from "../../tendermint/crypto/keys"; + +export const protobufPackage = "tendermint.types"; + +export interface ValidatorSet { + validators: Validator[]; + proposer: Validator | undefined; + totalVotingPower: number; +} + +export interface Validator { + address: Uint8Array; + pubKey: PublicKey | undefined; + votingPower: number; + proposerPriority: number; +} + +export interface SimpleValidator { + pubKey: PublicKey | undefined; + votingPower: number; +} + +const baseValidatorSet: object = { totalVotingPower: 0 }; + +export const ValidatorSet = { + encode(message: ValidatorSet, writer: Writer = Writer.create()): Writer { + for (const v of message.validators) { + Validator.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.proposer !== undefined) { + Validator.encode(message.proposer, writer.uint32(18).fork()).ldelim(); + } + if (message.totalVotingPower !== 0) { + writer.uint32(24).int64(message.totalVotingPower); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ValidatorSet { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseValidatorSet } as ValidatorSet; + message.validators = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.validators.push(Validator.decode(reader, reader.uint32())); + break; + case 2: + message.proposer = Validator.decode(reader, reader.uint32()); + break; + case 3: + message.totalVotingPower = longToNumber(reader.int64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ValidatorSet { + const message = { ...baseValidatorSet } as ValidatorSet; + message.validators = []; + if (object.validators !== undefined && object.validators !== null) { + for (const e of object.validators) { + message.validators.push(Validator.fromJSON(e)); + } + } + if (object.proposer !== undefined && object.proposer !== null) { + message.proposer = Validator.fromJSON(object.proposer); + } else { + message.proposer = undefined; + } + if ( + object.totalVotingPower !== undefined && + object.totalVotingPower !== null + ) { + message.totalVotingPower = Number(object.totalVotingPower); + } else { + message.totalVotingPower = 0; + } + return message; + }, + + toJSON(message: ValidatorSet): unknown { + const obj: any = {}; + if (message.validators) { + obj.validators = message.validators.map((e) => + e ? Validator.toJSON(e) : undefined + ); + } else { + obj.validators = []; + } + message.proposer !== undefined && + (obj.proposer = message.proposer + ? Validator.toJSON(message.proposer) + : undefined); + message.totalVotingPower !== undefined && + (obj.totalVotingPower = message.totalVotingPower); + return obj; + }, + + fromPartial(object: DeepPartial): ValidatorSet { + const message = { ...baseValidatorSet } as ValidatorSet; + message.validators = []; + if (object.validators !== undefined && object.validators !== null) { + for (const e of object.validators) { + message.validators.push(Validator.fromPartial(e)); + } + } + if (object.proposer !== undefined && object.proposer !== null) { + message.proposer = Validator.fromPartial(object.proposer); + } else { + message.proposer = undefined; + } + if ( + object.totalVotingPower !== undefined && + object.totalVotingPower !== null + ) { + message.totalVotingPower = object.totalVotingPower; + } else { + message.totalVotingPower = 0; + } + return message; + }, +}; + +const baseValidator: object = { votingPower: 0, proposerPriority: 0 }; + +export const Validator = { + encode(message: Validator, writer: Writer = Writer.create()): Writer { + if (message.address.length !== 0) { + writer.uint32(10).bytes(message.address); + } + if (message.pubKey !== undefined) { + PublicKey.encode(message.pubKey, writer.uint32(18).fork()).ldelim(); + } + if (message.votingPower !== 0) { + writer.uint32(24).int64(message.votingPower); + } + if (message.proposerPriority !== 0) { + writer.uint32(32).int64(message.proposerPriority); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Validator { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseValidator } as Validator; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.address = reader.bytes(); + break; + case 2: + message.pubKey = PublicKey.decode(reader, reader.uint32()); + break; + case 3: + message.votingPower = longToNumber(reader.int64() as Long); + break; + case 4: + message.proposerPriority = longToNumber(reader.int64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Validator { + const message = { ...baseValidator } as Validator; + if (object.address !== undefined && object.address !== null) { + message.address = bytesFromBase64(object.address); + } + if (object.pubKey !== undefined && object.pubKey !== null) { + message.pubKey = PublicKey.fromJSON(object.pubKey); + } else { + message.pubKey = undefined; + } + if (object.votingPower !== undefined && object.votingPower !== null) { + message.votingPower = Number(object.votingPower); + } else { + message.votingPower = 0; + } + if ( + object.proposerPriority !== undefined && + object.proposerPriority !== null + ) { + message.proposerPriority = Number(object.proposerPriority); + } else { + message.proposerPriority = 0; + } + return message; + }, + + toJSON(message: Validator): unknown { + const obj: any = {}; + message.address !== undefined && + (obj.address = base64FromBytes( + message.address !== undefined ? message.address : new Uint8Array() + )); + message.pubKey !== undefined && + (obj.pubKey = message.pubKey + ? PublicKey.toJSON(message.pubKey) + : undefined); + message.votingPower !== undefined && + (obj.votingPower = message.votingPower); + message.proposerPriority !== undefined && + (obj.proposerPriority = message.proposerPriority); + return obj; + }, + + fromPartial(object: DeepPartial): Validator { + const message = { ...baseValidator } as Validator; + if (object.address !== undefined && object.address !== null) { + message.address = object.address; + } else { + message.address = new Uint8Array(); + } + if (object.pubKey !== undefined && object.pubKey !== null) { + message.pubKey = PublicKey.fromPartial(object.pubKey); + } else { + message.pubKey = undefined; + } + if (object.votingPower !== undefined && object.votingPower !== null) { + message.votingPower = object.votingPower; + } else { + message.votingPower = 0; + } + if ( + object.proposerPriority !== undefined && + object.proposerPriority !== null + ) { + message.proposerPriority = object.proposerPriority; + } else { + message.proposerPriority = 0; + } + return message; + }, +}; + +const baseSimpleValidator: object = { votingPower: 0 }; + +export const SimpleValidator = { + encode(message: SimpleValidator, writer: Writer = Writer.create()): Writer { + if (message.pubKey !== undefined) { + PublicKey.encode(message.pubKey, writer.uint32(10).fork()).ldelim(); + } + if (message.votingPower !== 0) { + writer.uint32(16).int64(message.votingPower); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): SimpleValidator { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseSimpleValidator } as SimpleValidator; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.pubKey = PublicKey.decode(reader, reader.uint32()); + break; + case 2: + message.votingPower = longToNumber(reader.int64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): SimpleValidator { + const message = { ...baseSimpleValidator } as SimpleValidator; + if (object.pubKey !== undefined && object.pubKey !== null) { + message.pubKey = PublicKey.fromJSON(object.pubKey); + } else { + message.pubKey = undefined; + } + if (object.votingPower !== undefined && object.votingPower !== null) { + message.votingPower = Number(object.votingPower); + } else { + message.votingPower = 0; + } + return message; + }, + + toJSON(message: SimpleValidator): unknown { + const obj: any = {}; + message.pubKey !== undefined && + (obj.pubKey = message.pubKey + ? PublicKey.toJSON(message.pubKey) + : undefined); + message.votingPower !== undefined && + (obj.votingPower = message.votingPower); + return obj; + }, + + fromPartial(object: DeepPartial): SimpleValidator { + const message = { ...baseSimpleValidator } as SimpleValidator; + if (object.pubKey !== undefined && object.pubKey !== null) { + message.pubKey = PublicKey.fromPartial(object.pubKey); + } else { + message.pubKey = undefined; + } + if (object.votingPower !== undefined && object.votingPower !== null) { + message.votingPower = object.votingPower; + } else { + message.votingPower = 0; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/cosmos.tx.v1beta1/types/tendermint/version/types.ts b/ts-client/cosmos.tx.v1beta1/types/tendermint/version/types.ts new file mode 100644 index 00000000..4bc6ad82 --- /dev/null +++ b/ts-client/cosmos.tx.v1beta1/types/tendermint/version/types.ts @@ -0,0 +1,202 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "tendermint.version"; + +/** + * App includes the protocol and software version for the application. + * This information is included in ResponseInfo. The App.Protocol can be + * updated in ResponseEndBlock. + */ +export interface App { + protocol: number; + software: string; +} + +/** + * Consensus captures the consensus rules for processing a block in the blockchain, + * including all blockchain data structures and the rules of the application's + * state transition machine. + */ +export interface Consensus { + block: number; + app: number; +} + +const baseApp: object = { protocol: 0, software: "" }; + +export const App = { + encode(message: App, writer: Writer = Writer.create()): Writer { + if (message.protocol !== 0) { + writer.uint32(8).uint64(message.protocol); + } + if (message.software !== "") { + writer.uint32(18).string(message.software); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): App { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseApp } as App; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.protocol = longToNumber(reader.uint64() as Long); + break; + case 2: + message.software = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): App { + const message = { ...baseApp } as App; + if (object.protocol !== undefined && object.protocol !== null) { + message.protocol = Number(object.protocol); + } else { + message.protocol = 0; + } + if (object.software !== undefined && object.software !== null) { + message.software = String(object.software); + } else { + message.software = ""; + } + return message; + }, + + toJSON(message: App): unknown { + const obj: any = {}; + message.protocol !== undefined && (obj.protocol = message.protocol); + message.software !== undefined && (obj.software = message.software); + return obj; + }, + + fromPartial(object: DeepPartial): App { + const message = { ...baseApp } as App; + if (object.protocol !== undefined && object.protocol !== null) { + message.protocol = object.protocol; + } else { + message.protocol = 0; + } + if (object.software !== undefined && object.software !== null) { + message.software = object.software; + } else { + message.software = ""; + } + return message; + }, +}; + +const baseConsensus: object = { block: 0, app: 0 }; + +export const Consensus = { + encode(message: Consensus, writer: Writer = Writer.create()): Writer { + if (message.block !== 0) { + writer.uint32(8).uint64(message.block); + } + if (message.app !== 0) { + writer.uint32(16).uint64(message.app); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Consensus { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseConsensus } as Consensus; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.block = longToNumber(reader.uint64() as Long); + break; + case 2: + message.app = longToNumber(reader.uint64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Consensus { + const message = { ...baseConsensus } as Consensus; + if (object.block !== undefined && object.block !== null) { + message.block = Number(object.block); + } else { + message.block = 0; + } + if (object.app !== undefined && object.app !== null) { + message.app = Number(object.app); + } else { + message.app = 0; + } + return message; + }, + + toJSON(message: Consensus): unknown { + const obj: any = {}; + message.block !== undefined && (obj.block = message.block); + message.app !== undefined && (obj.app = message.app); + return obj; + }, + + fromPartial(object: DeepPartial): Consensus { + const message = { ...baseConsensus } as Consensus; + if (object.block !== undefined && object.block !== null) { + message.block = object.block; + } else { + message.block = 0; + } + if (object.app !== undefined && object.app !== null) { + message.app = object.app; + } else { + message.app = 0; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/cosmos.upgrade.v1beta1/index.ts b/ts-client/cosmos.upgrade.v1beta1/index.ts new file mode 100755 index 00000000..c9dfa159 --- /dev/null +++ b/ts-client/cosmos.upgrade.v1beta1/index.ts @@ -0,0 +1,6 @@ +import Module from './module'; +import { txClient, queryClient, registry } from './module'; +import { msgTypes } from './registry'; + +export * from "./types"; +export { Module, msgTypes, txClient, queryClient, registry }; diff --git a/ts-client/cosmos.upgrade.v1beta1/module.ts b/ts-client/cosmos.upgrade.v1beta1/module.ts new file mode 100755 index 00000000..e275dce6 --- /dev/null +++ b/ts-client/cosmos.upgrade.v1beta1/module.ts @@ -0,0 +1,66 @@ +// Generated by Ignite ignite.com/cli + +import { StdFee } from "@cosmjs/launchpad"; +import { SigningStargateClient, DeliverTxResponse } from "@cosmjs/stargate"; +import { EncodeObject, GeneratedType, OfflineSigner, Registry } from "@cosmjs/proto-signing"; +import { msgTypes } from './registry'; +import { IgniteClient } from "../client" +import { MissingWalletError } from "../helpers" +import { Api } from "./rest"; + + +export { }; + + + +export const registry = new Registry(msgTypes); + +const defaultFee = { + amount: [], + gas: "200000", +}; + +interface TxClientOptions { + addr: string + prefix: string + signer?: OfflineSigner +} + +export const txClient = ({ signer, prefix, addr }: TxClientOptions = { addr: "http://localhost:26657", prefix: "cosmos" }) => { + + return { + + + } +}; + +interface QueryClientOptions { + addr: string +} + +export const queryClient = ({ addr: addr }: QueryClientOptions = { addr: "http://localhost:1317" }) => { + return new Api({ baseUrl: addr }); +}; + +class SDKModule { + public query: ReturnType; + public tx: ReturnType; + + public registry: Array<[string, GeneratedType]>; + + constructor(client: IgniteClient) { + + this.query = queryClient({ addr: client.env.apiURL }); + this.tx = txClient({ signer: client.signer, addr: client.env.rpcURL, prefix: client.env.prefix ?? "cosmos" }); + } +}; + +const Module = (test: IgniteClient) => { + return { + module: { + CosmosUpgradeV1Beta1: new SDKModule(test) + }, + registry: msgTypes + } +} +export default Module; \ No newline at end of file diff --git a/ts-client/cosmos.upgrade.v1beta1/registry.ts b/ts-client/cosmos.upgrade.v1beta1/registry.ts new file mode 100755 index 00000000..26157e4f --- /dev/null +++ b/ts-client/cosmos.upgrade.v1beta1/registry.ts @@ -0,0 +1,7 @@ +import { GeneratedType } from "@cosmjs/proto-signing"; + +const msgTypes: Array<[string, GeneratedType]> = [ + +]; + +export { msgTypes } \ No newline at end of file diff --git a/ts-client/cosmos.upgrade.v1beta1/rest.ts b/ts-client/cosmos.upgrade.v1beta1/rest.ts new file mode 100644 index 00000000..9af9f252 --- /dev/null +++ b/ts-client/cosmos.upgrade.v1beta1/rest.ts @@ -0,0 +1,493 @@ +/* eslint-disable */ +/* tslint:disable */ +/* + * --------------------------------------------------------------- + * ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ## + * ## ## + * ## AUTHOR: acacode ## + * ## SOURCE: https://github.com/acacode/swagger-typescript-api ## + * --------------------------------------------------------------- + */ + +/** +* `Any` contains an arbitrary serialized protocol buffer message along with a +URL that describes the type of the serialized message. + +Protobuf library provides support to pack/unpack Any values in the form +of utility functions or additional generated methods of the Any type. + +Example 1: Pack and unpack a message in C++. + + Foo foo = ...; + Any any; + any.PackFrom(foo); + ... + if (any.UnpackTo(&foo)) { + ... + } + +Example 2: Pack and unpack a message in Java. + + Foo foo = ...; + Any any = Any.pack(foo); + ... + if (any.is(Foo.class)) { + foo = any.unpack(Foo.class); + } + + Example 3: Pack and unpack a message in Python. + + foo = Foo(...) + any = Any() + any.Pack(foo) + ... + if any.Is(Foo.DESCRIPTOR): + any.Unpack(foo) + ... + + Example 4: Pack and unpack a message in Go + + foo := &pb.Foo{...} + any, err := anypb.New(foo) + if err != nil { + ... + } + ... + foo := &pb.Foo{} + if err := any.UnmarshalTo(foo); err != nil { + ... + } + +The pack methods provided by protobuf library will by default use +'type.googleapis.com/full.type.name' as the type URL and the unpack +methods only use the fully qualified type name after the last '/' +in the type URL, for example "foo.bar.com/x/y.z" will yield type +name "y.z". + + +JSON +==== +The JSON representation of an `Any` value uses the regular +representation of the deserialized, embedded message, with an +additional field `@type` which contains the type URL. Example: + + package google.profile; + message Person { + string first_name = 1; + string last_name = 2; + } + + { + "@type": "type.googleapis.com/google.profile.Person", + "firstName": , + "lastName": + } + +If the embedded message type is well-known and has a custom JSON +representation, that representation will be embedded adding a field +`value` which holds the custom JSON in addition to the `@type` +field. Example (for message [google.protobuf.Duration][]): + + { + "@type": "type.googleapis.com/google.protobuf.Duration", + "value": "1.212s" + } +*/ +export interface ProtobufAny { + /** + * A URL/resource name that uniquely identifies the type of the serialized + * protocol buffer message. This string must contain at least + * one "/" character. The last segment of the URL's path must represent + * the fully qualified name of the type (as in + * `path/google.protobuf.Duration`). The name should be in a canonical form + * (e.g., leading "." is not accepted). + * + * In practice, teams usually precompile into the binary all types that they + * expect it to use in the context of Any. However, for URLs which use the + * scheme `http`, `https`, or no scheme, one can optionally set up a type + * server that maps type URLs to message definitions as follows: + * + * * If no scheme is provided, `https` is assumed. + * * An HTTP GET on the URL must yield a [google.protobuf.Type][] + * value in binary format, or produce an error. + * * Applications are allowed to cache lookup results based on the + * URL, or have them precompiled into a binary to avoid any + * lookup. Therefore, binary compatibility needs to be preserved + * on changes to types. (Use versioned type names to manage + * breaking changes.) + * + * Note: this functionality is not currently available in the official + * protobuf release, and it is not used for type URLs beginning with + * type.googleapis.com. + * + * Schemes other than `http`, `https` (or the empty scheme) might be + * used with implementation specific semantics. + */ + "@type"?: string; +} + +export interface RpcStatus { + /** @format int32 */ + code?: number; + message?: string; + details?: ProtobufAny[]; +} + +/** +* ModuleVersion specifies a module and its consensus version. + +Since: cosmos-sdk 0.43 +*/ +export interface V1Beta1ModuleVersion { + name?: string; + + /** @format uint64 */ + version?: string; +} + +/** + * Plan specifies information about a planned upgrade and when it should occur. + */ +export interface V1Beta1Plan { + /** + * Sets the name for the upgrade. This name will be used by the upgraded + * version of the software to apply any special "on-upgrade" commands during + * the first BeginBlock method after the upgrade is applied. It is also used + * to detect whether a software version can handle a given upgrade. If no + * upgrade handler with this name has been set in the software, it will be + * assumed that the software is out-of-date when the upgrade Time or Height is + * reached and the software will exit. + */ + name?: string; + + /** + * Deprecated: Time based upgrades have been deprecated. Time based upgrade logic + * has been removed from the SDK. + * If this field is not empty, an error will be thrown. + * @format date-time + */ + time?: string; + + /** + * The height at which the upgrade must be performed. + * Only used if Time is not set. + * @format int64 + */ + height?: string; + info?: string; + + /** + * Deprecated: UpgradedClientState field has been deprecated. IBC upgrade logic has been + * moved to the IBC module in the sub module 02-client. + * If this field is not empty, an error will be thrown. + */ + upgraded_client_state?: ProtobufAny; +} + +/** +* QueryAppliedPlanResponse is the response type for the Query/AppliedPlan RPC +method. +*/ +export interface V1Beta1QueryAppliedPlanResponse { + /** + * height is the block height at which the plan was applied. + * @format int64 + */ + height?: string; +} + +/** +* QueryCurrentPlanResponse is the response type for the Query/CurrentPlan RPC +method. +*/ +export interface V1Beta1QueryCurrentPlanResponse { + /** plan is the current upgrade plan. */ + plan?: V1Beta1Plan; +} + +/** +* QueryModuleVersionsResponse is the response type for the Query/ModuleVersions +RPC method. + +Since: cosmos-sdk 0.43 +*/ +export interface V1Beta1QueryModuleVersionsResponse { + /** module_versions is a list of module names with their consensus versions. */ + module_versions?: V1Beta1ModuleVersion[]; +} + +/** +* QueryUpgradedConsensusStateResponse is the response type for the Query/UpgradedConsensusState +RPC method. +*/ +export interface V1Beta1QueryUpgradedConsensusStateResponse { + /** @format byte */ + upgraded_consensus_state?: string; +} + +export type QueryParamsType = Record; +export type ResponseFormat = keyof Omit; + +export interface FullRequestParams extends Omit { + /** set parameter to `true` for call `securityWorker` for this request */ + secure?: boolean; + /** request path */ + path: string; + /** content type of request body */ + type?: ContentType; + /** query params */ + query?: QueryParamsType; + /** format of response (i.e. response.json() -> format: "json") */ + format?: keyof Omit; + /** request body */ + body?: unknown; + /** base url */ + baseUrl?: string; + /** request cancellation token */ + cancelToken?: CancelToken; +} + +export type RequestParams = Omit; + +export interface ApiConfig { + baseUrl?: string; + baseApiParams?: Omit; + securityWorker?: (securityData: SecurityDataType) => RequestParams | void; +} + +export interface HttpResponse extends Response { + data: D; + error: E; +} + +type CancelToken = Symbol | string | number; + +export enum ContentType { + Json = "application/json", + FormData = "multipart/form-data", + UrlEncoded = "application/x-www-form-urlencoded", +} + +export class HttpClient { + public baseUrl: string = ""; + private securityData: SecurityDataType = null as any; + private securityWorker: null | ApiConfig["securityWorker"] = null; + private abortControllers = new Map(); + + private baseApiParams: RequestParams = { + credentials: "same-origin", + headers: {}, + redirect: "follow", + referrerPolicy: "no-referrer", + }; + + constructor(apiConfig: ApiConfig = {}) { + Object.assign(this, apiConfig); + } + + public setSecurityData = (data: SecurityDataType) => { + this.securityData = data; + }; + + private addQueryParam(query: QueryParamsType, key: string) { + const value = query[key]; + + return ( + encodeURIComponent(key) + + "=" + + encodeURIComponent(Array.isArray(value) ? value.join(",") : typeof value === "number" ? value : `${value}`) + ); + } + + protected toQueryString(rawQuery?: QueryParamsType): string { + const query = rawQuery || {}; + const keys = Object.keys(query).filter((key) => "undefined" !== typeof query[key]); + return keys + .map((key) => + typeof query[key] === "object" && !Array.isArray(query[key]) + ? this.toQueryString(query[key] as QueryParamsType) + : this.addQueryParam(query, key), + ) + .join("&"); + } + + protected addQueryParams(rawQuery?: QueryParamsType): string { + const queryString = this.toQueryString(rawQuery); + return queryString ? `?${queryString}` : ""; + } + + private contentFormatters: Record any> = { + [ContentType.Json]: (input: any) => + input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input, + [ContentType.FormData]: (input: any) => + Object.keys(input || {}).reduce((data, key) => { + data.append(key, input[key]); + return data; + }, new FormData()), + [ContentType.UrlEncoded]: (input: any) => this.toQueryString(input), + }; + + private mergeRequestParams(params1: RequestParams, params2?: RequestParams): RequestParams { + return { + ...this.baseApiParams, + ...params1, + ...(params2 || {}), + headers: { + ...(this.baseApiParams.headers || {}), + ...(params1.headers || {}), + ...((params2 && params2.headers) || {}), + }, + }; + } + + private createAbortSignal = (cancelToken: CancelToken): AbortSignal | undefined => { + if (this.abortControllers.has(cancelToken)) { + const abortController = this.abortControllers.get(cancelToken); + if (abortController) { + return abortController.signal; + } + return void 0; + } + + const abortController = new AbortController(); + this.abortControllers.set(cancelToken, abortController); + return abortController.signal; + }; + + public abortRequest = (cancelToken: CancelToken) => { + const abortController = this.abortControllers.get(cancelToken); + + if (abortController) { + abortController.abort(); + this.abortControllers.delete(cancelToken); + } + }; + + public request = ({ + body, + secure, + path, + type, + query, + format = "json", + baseUrl, + cancelToken, + ...params + }: FullRequestParams): Promise> => { + const secureParams = (secure && this.securityWorker && this.securityWorker(this.securityData)) || {}; + const requestParams = this.mergeRequestParams(params, secureParams); + const queryString = query && this.toQueryString(query); + const payloadFormatter = this.contentFormatters[type || ContentType.Json]; + + return fetch(`${baseUrl || this.baseUrl || ""}${path}${queryString ? `?${queryString}` : ""}`, { + ...requestParams, + headers: { + ...(type && type !== ContentType.FormData ? { "Content-Type": type } : {}), + ...(requestParams.headers || {}), + }, + signal: cancelToken ? this.createAbortSignal(cancelToken) : void 0, + body: typeof body === "undefined" || body === null ? null : payloadFormatter(body), + }).then(async (response) => { + const r = response as HttpResponse; + r.data = (null as unknown) as T; + r.error = (null as unknown) as E; + + const data = await response[format]() + .then((data) => { + if (r.ok) { + r.data = data; + } else { + r.error = data; + } + return r; + }) + .catch((e) => { + r.error = e; + return r; + }); + + if (cancelToken) { + this.abortControllers.delete(cancelToken); + } + + if (!response.ok) throw data; + return data; + }); + }; +} + +/** + * @title cosmos/upgrade/v1beta1/query.proto + * @version version not set + */ +export class Api extends HttpClient { + /** + * No description + * + * @tags Query + * @name QueryAppliedPlan + * @summary AppliedPlan queries a previously applied upgrade plan by its name. + * @request GET:/cosmos/upgrade/v1beta1/applied_plan/{name} + */ + queryAppliedPlan = (name: string, params: RequestParams = {}) => + this.request({ + path: `/cosmos/upgrade/v1beta1/applied_plan/${name}`, + method: "GET", + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Query + * @name QueryCurrentPlan + * @summary CurrentPlan queries the current upgrade plan. + * @request GET:/cosmos/upgrade/v1beta1/current_plan + */ + queryCurrentPlan = (params: RequestParams = {}) => + this.request({ + path: `/cosmos/upgrade/v1beta1/current_plan`, + method: "GET", + format: "json", + ...params, + }); + + /** + * @description Since: cosmos-sdk 0.43 + * + * @tags Query + * @name QueryModuleVersions + * @summary ModuleVersions queries the list of module versions from state. + * @request GET:/cosmos/upgrade/v1beta1/module_versions + */ + queryModuleVersions = (query?: { module_name?: string }, params: RequestParams = {}) => + this.request({ + path: `/cosmos/upgrade/v1beta1/module_versions`, + method: "GET", + query: query, + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Query + * @name QueryUpgradedConsensusState + * @summary UpgradedConsensusState queries the consensus state that will serve +as a trusted kernel for the next version of this chain. It will only be +stored at the last height of this chain. +UpgradedConsensusState RPC not supported with legacy querier +This rpc is deprecated now that IBC has its own replacement +(https://github.com/cosmos/ibc-go/blob/2c880a22e9f9cc75f62b527ca94aa75ce1106001/proto/ibc/core/client/v1/query.proto#L54) + * @request GET:/cosmos/upgrade/v1beta1/upgraded_consensus_state/{last_height} + */ + queryUpgradedConsensusState = (last_height: string, params: RequestParams = {}) => + this.request({ + path: `/cosmos/upgrade/v1beta1/upgraded_consensus_state/${last_height}`, + method: "GET", + format: "json", + ...params, + }); +} diff --git a/ts-client/cosmos.upgrade.v1beta1/types.ts b/ts-client/cosmos.upgrade.v1beta1/types.ts new file mode 100755 index 00000000..2e7c435e --- /dev/null +++ b/ts-client/cosmos.upgrade.v1beta1/types.ts @@ -0,0 +1,13 @@ +import { Plan } from "./types/cosmos/upgrade/v1beta1/upgrade" +import { SoftwareUpgradeProposal } from "./types/cosmos/upgrade/v1beta1/upgrade" +import { CancelSoftwareUpgradeProposal } from "./types/cosmos/upgrade/v1beta1/upgrade" +import { ModuleVersion } from "./types/cosmos/upgrade/v1beta1/upgrade" + + +export { + Plan, + SoftwareUpgradeProposal, + CancelSoftwareUpgradeProposal, + ModuleVersion, + + } \ No newline at end of file diff --git a/ts-client/cosmos.upgrade.v1beta1/types/cosmos/upgrade/v1beta1/query.ts b/ts-client/cosmos.upgrade.v1beta1/types/cosmos/upgrade/v1beta1/query.ts new file mode 100644 index 00000000..959580fa --- /dev/null +++ b/ts-client/cosmos.upgrade.v1beta1/types/cosmos/upgrade/v1beta1/query.ts @@ -0,0 +1,798 @@ +/* eslint-disable */ +import { Reader, util, configure, Writer } from "protobufjs/minimal"; +import * as Long from "long"; +import { Plan, ModuleVersion } from "../../../cosmos/upgrade/v1beta1/upgrade"; + +export const protobufPackage = "cosmos.upgrade.v1beta1"; + +/** + * QueryCurrentPlanRequest is the request type for the Query/CurrentPlan RPC + * method. + */ +export interface QueryCurrentPlanRequest {} + +/** + * QueryCurrentPlanResponse is the response type for the Query/CurrentPlan RPC + * method. + */ +export interface QueryCurrentPlanResponse { + /** plan is the current upgrade plan. */ + plan: Plan | undefined; +} + +/** + * QueryCurrentPlanRequest is the request type for the Query/AppliedPlan RPC + * method. + */ +export interface QueryAppliedPlanRequest { + /** name is the name of the applied plan to query for. */ + name: string; +} + +/** + * QueryAppliedPlanResponse is the response type for the Query/AppliedPlan RPC + * method. + */ +export interface QueryAppliedPlanResponse { + /** height is the block height at which the plan was applied. */ + height: number; +} + +/** + * QueryUpgradedConsensusStateRequest is the request type for the Query/UpgradedConsensusState + * RPC method. + * + * @deprecated + */ +export interface QueryUpgradedConsensusStateRequest { + /** + * last height of the current chain must be sent in request + * as this is the height under which next consensus state is stored + */ + lastHeight: number; +} + +/** + * QueryUpgradedConsensusStateResponse is the response type for the Query/UpgradedConsensusState + * RPC method. + * + * @deprecated + */ +export interface QueryUpgradedConsensusStateResponse { + /** Since: cosmos-sdk 0.43 */ + upgradedConsensusState: Uint8Array; +} + +/** + * QueryModuleVersionsRequest is the request type for the Query/ModuleVersions + * RPC method. + * + * Since: cosmos-sdk 0.43 + */ +export interface QueryModuleVersionsRequest { + /** + * module_name is a field to query a specific module + * consensus version from state. Leaving this empty will + * fetch the full list of module versions from state + */ + moduleName: string; +} + +/** + * QueryModuleVersionsResponse is the response type for the Query/ModuleVersions + * RPC method. + * + * Since: cosmos-sdk 0.43 + */ +export interface QueryModuleVersionsResponse { + /** module_versions is a list of module names with their consensus versions. */ + moduleVersions: ModuleVersion[]; +} + +const baseQueryCurrentPlanRequest: object = {}; + +export const QueryCurrentPlanRequest = { + encode(_: QueryCurrentPlanRequest, writer: Writer = Writer.create()): Writer { + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QueryCurrentPlanRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryCurrentPlanRequest, + } as QueryCurrentPlanRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): QueryCurrentPlanRequest { + const message = { + ...baseQueryCurrentPlanRequest, + } as QueryCurrentPlanRequest; + return message; + }, + + toJSON(_: QueryCurrentPlanRequest): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial( + _: DeepPartial + ): QueryCurrentPlanRequest { + const message = { + ...baseQueryCurrentPlanRequest, + } as QueryCurrentPlanRequest; + return message; + }, +}; + +const baseQueryCurrentPlanResponse: object = {}; + +export const QueryCurrentPlanResponse = { + encode( + message: QueryCurrentPlanResponse, + writer: Writer = Writer.create() + ): Writer { + if (message.plan !== undefined) { + Plan.encode(message.plan, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryCurrentPlanResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryCurrentPlanResponse, + } as QueryCurrentPlanResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.plan = Plan.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryCurrentPlanResponse { + const message = { + ...baseQueryCurrentPlanResponse, + } as QueryCurrentPlanResponse; + if (object.plan !== undefined && object.plan !== null) { + message.plan = Plan.fromJSON(object.plan); + } else { + message.plan = undefined; + } + return message; + }, + + toJSON(message: QueryCurrentPlanResponse): unknown { + const obj: any = {}; + message.plan !== undefined && + (obj.plan = message.plan ? Plan.toJSON(message.plan) : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryCurrentPlanResponse { + const message = { + ...baseQueryCurrentPlanResponse, + } as QueryCurrentPlanResponse; + if (object.plan !== undefined && object.plan !== null) { + message.plan = Plan.fromPartial(object.plan); + } else { + message.plan = undefined; + } + return message; + }, +}; + +const baseQueryAppliedPlanRequest: object = { name: "" }; + +export const QueryAppliedPlanRequest = { + encode( + message: QueryAppliedPlanRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QueryAppliedPlanRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryAppliedPlanRequest, + } as QueryAppliedPlanRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryAppliedPlanRequest { + const message = { + ...baseQueryAppliedPlanRequest, + } as QueryAppliedPlanRequest; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + return message; + }, + + toJSON(message: QueryAppliedPlanRequest): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryAppliedPlanRequest { + const message = { + ...baseQueryAppliedPlanRequest, + } as QueryAppliedPlanRequest; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + return message; + }, +}; + +const baseQueryAppliedPlanResponse: object = { height: 0 }; + +export const QueryAppliedPlanResponse = { + encode( + message: QueryAppliedPlanResponse, + writer: Writer = Writer.create() + ): Writer { + if (message.height !== 0) { + writer.uint32(8).int64(message.height); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryAppliedPlanResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryAppliedPlanResponse, + } as QueryAppliedPlanResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.height = longToNumber(reader.int64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryAppliedPlanResponse { + const message = { + ...baseQueryAppliedPlanResponse, + } as QueryAppliedPlanResponse; + if (object.height !== undefined && object.height !== null) { + message.height = Number(object.height); + } else { + message.height = 0; + } + return message; + }, + + toJSON(message: QueryAppliedPlanResponse): unknown { + const obj: any = {}; + message.height !== undefined && (obj.height = message.height); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryAppliedPlanResponse { + const message = { + ...baseQueryAppliedPlanResponse, + } as QueryAppliedPlanResponse; + if (object.height !== undefined && object.height !== null) { + message.height = object.height; + } else { + message.height = 0; + } + return message; + }, +}; + +const baseQueryUpgradedConsensusStateRequest: object = { lastHeight: 0 }; + +export const QueryUpgradedConsensusStateRequest = { + encode( + message: QueryUpgradedConsensusStateRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.lastHeight !== 0) { + writer.uint32(8).int64(message.lastHeight); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryUpgradedConsensusStateRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryUpgradedConsensusStateRequest, + } as QueryUpgradedConsensusStateRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.lastHeight = longToNumber(reader.int64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryUpgradedConsensusStateRequest { + const message = { + ...baseQueryUpgradedConsensusStateRequest, + } as QueryUpgradedConsensusStateRequest; + if (object.lastHeight !== undefined && object.lastHeight !== null) { + message.lastHeight = Number(object.lastHeight); + } else { + message.lastHeight = 0; + } + return message; + }, + + toJSON(message: QueryUpgradedConsensusStateRequest): unknown { + const obj: any = {}; + message.lastHeight !== undefined && (obj.lastHeight = message.lastHeight); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryUpgradedConsensusStateRequest { + const message = { + ...baseQueryUpgradedConsensusStateRequest, + } as QueryUpgradedConsensusStateRequest; + if (object.lastHeight !== undefined && object.lastHeight !== null) { + message.lastHeight = object.lastHeight; + } else { + message.lastHeight = 0; + } + return message; + }, +}; + +const baseQueryUpgradedConsensusStateResponse: object = {}; + +export const QueryUpgradedConsensusStateResponse = { + encode( + message: QueryUpgradedConsensusStateResponse, + writer: Writer = Writer.create() + ): Writer { + if (message.upgradedConsensusState.length !== 0) { + writer.uint32(18).bytes(message.upgradedConsensusState); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryUpgradedConsensusStateResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryUpgradedConsensusStateResponse, + } as QueryUpgradedConsensusStateResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + message.upgradedConsensusState = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryUpgradedConsensusStateResponse { + const message = { + ...baseQueryUpgradedConsensusStateResponse, + } as QueryUpgradedConsensusStateResponse; + if ( + object.upgradedConsensusState !== undefined && + object.upgradedConsensusState !== null + ) { + message.upgradedConsensusState = bytesFromBase64( + object.upgradedConsensusState + ); + } + return message; + }, + + toJSON(message: QueryUpgradedConsensusStateResponse): unknown { + const obj: any = {}; + message.upgradedConsensusState !== undefined && + (obj.upgradedConsensusState = base64FromBytes( + message.upgradedConsensusState !== undefined + ? message.upgradedConsensusState + : new Uint8Array() + )); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryUpgradedConsensusStateResponse { + const message = { + ...baseQueryUpgradedConsensusStateResponse, + } as QueryUpgradedConsensusStateResponse; + if ( + object.upgradedConsensusState !== undefined && + object.upgradedConsensusState !== null + ) { + message.upgradedConsensusState = object.upgradedConsensusState; + } else { + message.upgradedConsensusState = new Uint8Array(); + } + return message; + }, +}; + +const baseQueryModuleVersionsRequest: object = { moduleName: "" }; + +export const QueryModuleVersionsRequest = { + encode( + message: QueryModuleVersionsRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.moduleName !== "") { + writer.uint32(10).string(message.moduleName); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryModuleVersionsRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryModuleVersionsRequest, + } as QueryModuleVersionsRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.moduleName = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryModuleVersionsRequest { + const message = { + ...baseQueryModuleVersionsRequest, + } as QueryModuleVersionsRequest; + if (object.moduleName !== undefined && object.moduleName !== null) { + message.moduleName = String(object.moduleName); + } else { + message.moduleName = ""; + } + return message; + }, + + toJSON(message: QueryModuleVersionsRequest): unknown { + const obj: any = {}; + message.moduleName !== undefined && (obj.moduleName = message.moduleName); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryModuleVersionsRequest { + const message = { + ...baseQueryModuleVersionsRequest, + } as QueryModuleVersionsRequest; + if (object.moduleName !== undefined && object.moduleName !== null) { + message.moduleName = object.moduleName; + } else { + message.moduleName = ""; + } + return message; + }, +}; + +const baseQueryModuleVersionsResponse: object = {}; + +export const QueryModuleVersionsResponse = { + encode( + message: QueryModuleVersionsResponse, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.moduleVersions) { + ModuleVersion.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryModuleVersionsResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryModuleVersionsResponse, + } as QueryModuleVersionsResponse; + message.moduleVersions = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.moduleVersions.push( + ModuleVersion.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryModuleVersionsResponse { + const message = { + ...baseQueryModuleVersionsResponse, + } as QueryModuleVersionsResponse; + message.moduleVersions = []; + if (object.moduleVersions !== undefined && object.moduleVersions !== null) { + for (const e of object.moduleVersions) { + message.moduleVersions.push(ModuleVersion.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: QueryModuleVersionsResponse): unknown { + const obj: any = {}; + if (message.moduleVersions) { + obj.moduleVersions = message.moduleVersions.map((e) => + e ? ModuleVersion.toJSON(e) : undefined + ); + } else { + obj.moduleVersions = []; + } + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryModuleVersionsResponse { + const message = { + ...baseQueryModuleVersionsResponse, + } as QueryModuleVersionsResponse; + message.moduleVersions = []; + if (object.moduleVersions !== undefined && object.moduleVersions !== null) { + for (const e of object.moduleVersions) { + message.moduleVersions.push(ModuleVersion.fromPartial(e)); + } + } + return message; + }, +}; + +/** Query defines the gRPC upgrade querier service. */ +export interface Query { + /** CurrentPlan queries the current upgrade plan. */ + CurrentPlan( + request: QueryCurrentPlanRequest + ): Promise; + /** AppliedPlan queries a previously applied upgrade plan by its name. */ + AppliedPlan( + request: QueryAppliedPlanRequest + ): Promise; + /** + * UpgradedConsensusState queries the consensus state that will serve + * as a trusted kernel for the next version of this chain. It will only be + * stored at the last height of this chain. + * UpgradedConsensusState RPC not supported with legacy querier + * This rpc is deprecated now that IBC has its own replacement + * (https://github.com/cosmos/ibc-go/blob/2c880a22e9f9cc75f62b527ca94aa75ce1106001/proto/ibc/core/client/v1/query.proto#L54) + * + * @deprecated + */ + UpgradedConsensusState( + request: QueryUpgradedConsensusStateRequest + ): Promise; + /** + * ModuleVersions queries the list of module versions from state. + * + * Since: cosmos-sdk 0.43 + */ + ModuleVersions( + request: QueryModuleVersionsRequest + ): Promise; +} + +export class QueryClientImpl implements Query { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + } + CurrentPlan( + request: QueryCurrentPlanRequest + ): Promise { + const data = QueryCurrentPlanRequest.encode(request).finish(); + const promise = this.rpc.request( + "cosmos.upgrade.v1beta1.Query", + "CurrentPlan", + data + ); + return promise.then((data) => + QueryCurrentPlanResponse.decode(new Reader(data)) + ); + } + + AppliedPlan( + request: QueryAppliedPlanRequest + ): Promise { + const data = QueryAppliedPlanRequest.encode(request).finish(); + const promise = this.rpc.request( + "cosmos.upgrade.v1beta1.Query", + "AppliedPlan", + data + ); + return promise.then((data) => + QueryAppliedPlanResponse.decode(new Reader(data)) + ); + } + + UpgradedConsensusState( + request: QueryUpgradedConsensusStateRequest + ): Promise { + const data = QueryUpgradedConsensusStateRequest.encode(request).finish(); + const promise = this.rpc.request( + "cosmos.upgrade.v1beta1.Query", + "UpgradedConsensusState", + data + ); + return promise.then((data) => + QueryUpgradedConsensusStateResponse.decode(new Reader(data)) + ); + } + + ModuleVersions( + request: QueryModuleVersionsRequest + ): Promise { + const data = QueryModuleVersionsRequest.encode(request).finish(); + const promise = this.rpc.request( + "cosmos.upgrade.v1beta1.Query", + "ModuleVersions", + data + ); + return promise.then((data) => + QueryModuleVersionsResponse.decode(new Reader(data)) + ); + } +} + +interface Rpc { + request( + service: string, + method: string, + data: Uint8Array + ): Promise; +} + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/cosmos.upgrade.v1beta1/types/cosmos/upgrade/v1beta1/upgrade.ts b/ts-client/cosmos.upgrade.v1beta1/types/cosmos/upgrade/v1beta1/upgrade.ts new file mode 100644 index 00000000..ec9520b0 --- /dev/null +++ b/ts-client/cosmos.upgrade.v1beta1/types/cosmos/upgrade/v1beta1/upgrade.ts @@ -0,0 +1,539 @@ +/* eslint-disable */ +import { Timestamp } from "../../../google/protobuf/timestamp"; +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; +import { Any } from "../../../google/protobuf/any"; + +export const protobufPackage = "cosmos.upgrade.v1beta1"; + +/** Plan specifies information about a planned upgrade and when it should occur. */ +export interface Plan { + /** + * Sets the name for the upgrade. This name will be used by the upgraded + * version of the software to apply any special "on-upgrade" commands during + * the first BeginBlock method after the upgrade is applied. It is also used + * to detect whether a software version can handle a given upgrade. If no + * upgrade handler with this name has been set in the software, it will be + * assumed that the software is out-of-date when the upgrade Time or Height is + * reached and the software will exit. + */ + name: string; + /** + * Deprecated: Time based upgrades have been deprecated. Time based upgrade logic + * has been removed from the SDK. + * If this field is not empty, an error will be thrown. + * + * @deprecated + */ + time: Date | undefined; + /** + * The height at which the upgrade must be performed. + * Only used if Time is not set. + */ + height: number; + /** + * Any application specific upgrade info to be included on-chain + * such as a git commit that validators could automatically upgrade to + */ + info: string; + /** + * Deprecated: UpgradedClientState field has been deprecated. IBC upgrade logic has been + * moved to the IBC module in the sub module 02-client. + * If this field is not empty, an error will be thrown. + * + * @deprecated + */ + upgradedClientState: Any | undefined; +} + +/** + * SoftwareUpgradeProposal is a gov Content type for initiating a software + * upgrade. + */ +export interface SoftwareUpgradeProposal { + title: string; + description: string; + plan: Plan | undefined; +} + +/** + * CancelSoftwareUpgradeProposal is a gov Content type for cancelling a software + * upgrade. + */ +export interface CancelSoftwareUpgradeProposal { + title: string; + description: string; +} + +/** + * ModuleVersion specifies a module and its consensus version. + * + * Since: cosmos-sdk 0.43 + */ +export interface ModuleVersion { + /** name of the app module */ + name: string; + /** consensus version of the app module */ + version: number; +} + +const basePlan: object = { name: "", height: 0, info: "" }; + +export const Plan = { + encode(message: Plan, writer: Writer = Writer.create()): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.time !== undefined) { + Timestamp.encode( + toTimestamp(message.time), + writer.uint32(18).fork() + ).ldelim(); + } + if (message.height !== 0) { + writer.uint32(24).int64(message.height); + } + if (message.info !== "") { + writer.uint32(34).string(message.info); + } + if (message.upgradedClientState !== undefined) { + Any.encode( + message.upgradedClientState, + writer.uint32(42).fork() + ).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Plan { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...basePlan } as Plan; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.time = fromTimestamp( + Timestamp.decode(reader, reader.uint32()) + ); + break; + case 3: + message.height = longToNumber(reader.int64() as Long); + break; + case 4: + message.info = reader.string(); + break; + case 5: + message.upgradedClientState = Any.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Plan { + const message = { ...basePlan } as Plan; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.time !== undefined && object.time !== null) { + message.time = fromJsonTimestamp(object.time); + } else { + message.time = undefined; + } + if (object.height !== undefined && object.height !== null) { + message.height = Number(object.height); + } else { + message.height = 0; + } + if (object.info !== undefined && object.info !== null) { + message.info = String(object.info); + } else { + message.info = ""; + } + if ( + object.upgradedClientState !== undefined && + object.upgradedClientState !== null + ) { + message.upgradedClientState = Any.fromJSON(object.upgradedClientState); + } else { + message.upgradedClientState = undefined; + } + return message; + }, + + toJSON(message: Plan): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.time !== undefined && + (obj.time = + message.time !== undefined ? message.time.toISOString() : null); + message.height !== undefined && (obj.height = message.height); + message.info !== undefined && (obj.info = message.info); + message.upgradedClientState !== undefined && + (obj.upgradedClientState = message.upgradedClientState + ? Any.toJSON(message.upgradedClientState) + : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): Plan { + const message = { ...basePlan } as Plan; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.time !== undefined && object.time !== null) { + message.time = object.time; + } else { + message.time = undefined; + } + if (object.height !== undefined && object.height !== null) { + message.height = object.height; + } else { + message.height = 0; + } + if (object.info !== undefined && object.info !== null) { + message.info = object.info; + } else { + message.info = ""; + } + if ( + object.upgradedClientState !== undefined && + object.upgradedClientState !== null + ) { + message.upgradedClientState = Any.fromPartial(object.upgradedClientState); + } else { + message.upgradedClientState = undefined; + } + return message; + }, +}; + +const baseSoftwareUpgradeProposal: object = { title: "", description: "" }; + +export const SoftwareUpgradeProposal = { + encode( + message: SoftwareUpgradeProposal, + writer: Writer = Writer.create() + ): Writer { + if (message.title !== "") { + writer.uint32(10).string(message.title); + } + if (message.description !== "") { + writer.uint32(18).string(message.description); + } + if (message.plan !== undefined) { + Plan.encode(message.plan, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): SoftwareUpgradeProposal { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseSoftwareUpgradeProposal, + } as SoftwareUpgradeProposal; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.title = reader.string(); + break; + case 2: + message.description = reader.string(); + break; + case 3: + message.plan = Plan.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): SoftwareUpgradeProposal { + const message = { + ...baseSoftwareUpgradeProposal, + } as SoftwareUpgradeProposal; + if (object.title !== undefined && object.title !== null) { + message.title = String(object.title); + } else { + message.title = ""; + } + if (object.description !== undefined && object.description !== null) { + message.description = String(object.description); + } else { + message.description = ""; + } + if (object.plan !== undefined && object.plan !== null) { + message.plan = Plan.fromJSON(object.plan); + } else { + message.plan = undefined; + } + return message; + }, + + toJSON(message: SoftwareUpgradeProposal): unknown { + const obj: any = {}; + message.title !== undefined && (obj.title = message.title); + message.description !== undefined && + (obj.description = message.description); + message.plan !== undefined && + (obj.plan = message.plan ? Plan.toJSON(message.plan) : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): SoftwareUpgradeProposal { + const message = { + ...baseSoftwareUpgradeProposal, + } as SoftwareUpgradeProposal; + if (object.title !== undefined && object.title !== null) { + message.title = object.title; + } else { + message.title = ""; + } + if (object.description !== undefined && object.description !== null) { + message.description = object.description; + } else { + message.description = ""; + } + if (object.plan !== undefined && object.plan !== null) { + message.plan = Plan.fromPartial(object.plan); + } else { + message.plan = undefined; + } + return message; + }, +}; + +const baseCancelSoftwareUpgradeProposal: object = { + title: "", + description: "", +}; + +export const CancelSoftwareUpgradeProposal = { + encode( + message: CancelSoftwareUpgradeProposal, + writer: Writer = Writer.create() + ): Writer { + if (message.title !== "") { + writer.uint32(10).string(message.title); + } + if (message.description !== "") { + writer.uint32(18).string(message.description); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): CancelSoftwareUpgradeProposal { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseCancelSoftwareUpgradeProposal, + } as CancelSoftwareUpgradeProposal; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.title = reader.string(); + break; + case 2: + message.description = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): CancelSoftwareUpgradeProposal { + const message = { + ...baseCancelSoftwareUpgradeProposal, + } as CancelSoftwareUpgradeProposal; + if (object.title !== undefined && object.title !== null) { + message.title = String(object.title); + } else { + message.title = ""; + } + if (object.description !== undefined && object.description !== null) { + message.description = String(object.description); + } else { + message.description = ""; + } + return message; + }, + + toJSON(message: CancelSoftwareUpgradeProposal): unknown { + const obj: any = {}; + message.title !== undefined && (obj.title = message.title); + message.description !== undefined && + (obj.description = message.description); + return obj; + }, + + fromPartial( + object: DeepPartial + ): CancelSoftwareUpgradeProposal { + const message = { + ...baseCancelSoftwareUpgradeProposal, + } as CancelSoftwareUpgradeProposal; + if (object.title !== undefined && object.title !== null) { + message.title = object.title; + } else { + message.title = ""; + } + if (object.description !== undefined && object.description !== null) { + message.description = object.description; + } else { + message.description = ""; + } + return message; + }, +}; + +const baseModuleVersion: object = { name: "", version: 0 }; + +export const ModuleVersion = { + encode(message: ModuleVersion, writer: Writer = Writer.create()): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.version !== 0) { + writer.uint32(16).uint64(message.version); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ModuleVersion { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseModuleVersion } as ModuleVersion; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.version = longToNumber(reader.uint64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ModuleVersion { + const message = { ...baseModuleVersion } as ModuleVersion; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.version !== undefined && object.version !== null) { + message.version = Number(object.version); + } else { + message.version = 0; + } + return message; + }, + + toJSON(message: ModuleVersion): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.version !== undefined && (obj.version = message.version); + return obj; + }, + + fromPartial(object: DeepPartial): ModuleVersion { + const message = { ...baseModuleVersion } as ModuleVersion; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.version !== undefined && object.version !== null) { + message.version = object.version; + } else { + message.version = 0; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function toTimestamp(date: Date): Timestamp { + const seconds = date.getTime() / 1_000; + const nanos = (date.getTime() % 1_000) * 1_000_000; + return { seconds, nanos }; +} + +function fromTimestamp(t: Timestamp): Date { + let millis = t.seconds * 1_000; + millis += t.nanos / 1_000_000; + return new Date(millis); +} + +function fromJsonTimestamp(o: any): Date { + if (o instanceof Date) { + return o; + } else if (typeof o === "string") { + return new Date(o); + } else { + return fromTimestamp(Timestamp.fromJSON(o)); + } +} + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/cosmos.upgrade.v1beta1/types/gogoproto/gogo.ts b/ts-client/cosmos.upgrade.v1beta1/types/gogoproto/gogo.ts new file mode 100644 index 00000000..3f41a047 --- /dev/null +++ b/ts-client/cosmos.upgrade.v1beta1/types/gogoproto/gogo.ts @@ -0,0 +1,2 @@ +/* eslint-disable */ +export const protobufPackage = "gogoproto"; diff --git a/ts-client/cosmos.upgrade.v1beta1/types/google/api/annotations.ts b/ts-client/cosmos.upgrade.v1beta1/types/google/api/annotations.ts new file mode 100644 index 00000000..aace4787 --- /dev/null +++ b/ts-client/cosmos.upgrade.v1beta1/types/google/api/annotations.ts @@ -0,0 +1,2 @@ +/* eslint-disable */ +export const protobufPackage = "google.api"; diff --git a/ts-client/cosmos.upgrade.v1beta1/types/google/api/http.ts b/ts-client/cosmos.upgrade.v1beta1/types/google/api/http.ts new file mode 100644 index 00000000..ddc00f8b --- /dev/null +++ b/ts-client/cosmos.upgrade.v1beta1/types/google/api/http.ts @@ -0,0 +1,705 @@ +/* eslint-disable */ +import { Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "google.api"; + +/** + * Defines the HTTP configuration for an API service. It contains a list of + * [HttpRule][google.api.HttpRule], each specifying the mapping of an RPC method + * to one or more HTTP REST API methods. + */ +export interface Http { + /** + * A list of HTTP configuration rules that apply to individual API methods. + * + * **NOTE:** All service configuration rules follow "last one wins" order. + */ + rules: HttpRule[]; + /** + * When set to true, URL path parmeters will be fully URI-decoded except in + * cases of single segment matches in reserved expansion, where "%2F" will be + * left encoded. + * + * The default behavior is to not decode RFC 6570 reserved characters in multi + * segment matches. + */ + fullyDecodeReservedExpansion: boolean; +} + +/** + * `HttpRule` defines the mapping of an RPC method to one or more HTTP + * REST API methods. The mapping specifies how different portions of the RPC + * request message are mapped to URL path, URL query parameters, and + * HTTP request body. The mapping is typically specified as an + * `google.api.http` annotation on the RPC method, + * see "google/api/annotations.proto" for details. + * + * The mapping consists of a field specifying the path template and + * method kind. The path template can refer to fields in the request + * message, as in the example below which describes a REST GET + * operation on a resource collection of messages: + * + * + * service Messaging { + * rpc GetMessage(GetMessageRequest) returns (Message) { + * option (google.api.http).get = "/v1/messages/{message_id}/{sub.subfield}"; + * } + * } + * message GetMessageRequest { + * message SubMessage { + * string subfield = 1; + * } + * string message_id = 1; // mapped to the URL + * SubMessage sub = 2; // `sub.subfield` is url-mapped + * } + * message Message { + * string text = 1; // content of the resource + * } + * + * The same http annotation can alternatively be expressed inside the + * `GRPC API Configuration` YAML file. + * + * http: + * rules: + * - selector: .Messaging.GetMessage + * get: /v1/messages/{message_id}/{sub.subfield} + * + * This definition enables an automatic, bidrectional mapping of HTTP + * JSON to RPC. Example: + * + * HTTP | RPC + * -----|----- + * `GET /v1/messages/123456/foo` | `GetMessage(message_id: "123456" sub: SubMessage(subfield: "foo"))` + * + * In general, not only fields but also field paths can be referenced + * from a path pattern. Fields mapped to the path pattern cannot be + * repeated and must have a primitive (non-message) type. + * + * Any fields in the request message which are not bound by the path + * pattern automatically become (optional) HTTP query + * parameters. Assume the following definition of the request message: + * + * + * service Messaging { + * rpc GetMessage(GetMessageRequest) returns (Message) { + * option (google.api.http).get = "/v1/messages/{message_id}"; + * } + * } + * message GetMessageRequest { + * message SubMessage { + * string subfield = 1; + * } + * string message_id = 1; // mapped to the URL + * int64 revision = 2; // becomes a parameter + * SubMessage sub = 3; // `sub.subfield` becomes a parameter + * } + * + * + * This enables a HTTP JSON to RPC mapping as below: + * + * HTTP | RPC + * -----|----- + * `GET /v1/messages/123456?revision=2&sub.subfield=foo` | `GetMessage(message_id: "123456" revision: 2 sub: SubMessage(subfield: "foo"))` + * + * Note that fields which are mapped to HTTP parameters must have a + * primitive type or a repeated primitive type. Message types are not + * allowed. In the case of a repeated type, the parameter can be + * repeated in the URL, as in `...?param=A¶m=B`. + * + * For HTTP method kinds which allow a request body, the `body` field + * specifies the mapping. Consider a REST update method on the + * message resource collection: + * + * + * service Messaging { + * rpc UpdateMessage(UpdateMessageRequest) returns (Message) { + * option (google.api.http) = { + * put: "/v1/messages/{message_id}" + * body: "message" + * }; + * } + * } + * message UpdateMessageRequest { + * string message_id = 1; // mapped to the URL + * Message message = 2; // mapped to the body + * } + * + * + * The following HTTP JSON to RPC mapping is enabled, where the + * representation of the JSON in the request body is determined by + * protos JSON encoding: + * + * HTTP | RPC + * -----|----- + * `PUT /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: "123456" message { text: "Hi!" })` + * + * The special name `*` can be used in the body mapping to define that + * every field not bound by the path template should be mapped to the + * request body. This enables the following alternative definition of + * the update method: + * + * service Messaging { + * rpc UpdateMessage(Message) returns (Message) { + * option (google.api.http) = { + * put: "/v1/messages/{message_id}" + * body: "*" + * }; + * } + * } + * message Message { + * string message_id = 1; + * string text = 2; + * } + * + * + * The following HTTP JSON to RPC mapping is enabled: + * + * HTTP | RPC + * -----|----- + * `PUT /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: "123456" text: "Hi!")` + * + * Note that when using `*` in the body mapping, it is not possible to + * have HTTP parameters, as all fields not bound by the path end in + * the body. This makes this option more rarely used in practice of + * defining REST APIs. The common usage of `*` is in custom methods + * which don't use the URL at all for transferring data. + * + * It is possible to define multiple HTTP methods for one RPC by using + * the `additional_bindings` option. Example: + * + * service Messaging { + * rpc GetMessage(GetMessageRequest) returns (Message) { + * option (google.api.http) = { + * get: "/v1/messages/{message_id}" + * additional_bindings { + * get: "/v1/users/{user_id}/messages/{message_id}" + * } + * }; + * } + * } + * message GetMessageRequest { + * string message_id = 1; + * string user_id = 2; + * } + * + * + * This enables the following two alternative HTTP JSON to RPC + * mappings: + * + * HTTP | RPC + * -----|----- + * `GET /v1/messages/123456` | `GetMessage(message_id: "123456")` + * `GET /v1/users/me/messages/123456` | `GetMessage(user_id: "me" message_id: "123456")` + * + * # Rules for HTTP mapping + * + * The rules for mapping HTTP path, query parameters, and body fields + * to the request message are as follows: + * + * 1. The `body` field specifies either `*` or a field path, or is + * omitted. If omitted, it indicates there is no HTTP request body. + * 2. Leaf fields (recursive expansion of nested messages in the + * request) can be classified into three types: + * (a) Matched in the URL template. + * (b) Covered by body (if body is `*`, everything except (a) fields; + * else everything under the body field) + * (c) All other fields. + * 3. URL query parameters found in the HTTP request are mapped to (c) fields. + * 4. Any body sent with an HTTP request can contain only (b) fields. + * + * The syntax of the path template is as follows: + * + * Template = "/" Segments [ Verb ] ; + * Segments = Segment { "/" Segment } ; + * Segment = "*" | "**" | LITERAL | Variable ; + * Variable = "{" FieldPath [ "=" Segments ] "}" ; + * FieldPath = IDENT { "." IDENT } ; + * Verb = ":" LITERAL ; + * + * The syntax `*` matches a single path segment. The syntax `**` matches zero + * or more path segments, which must be the last part of the path except the + * `Verb`. The syntax `LITERAL` matches literal text in the path. + * + * The syntax `Variable` matches part of the URL path as specified by its + * template. A variable template must not contain other variables. If a variable + * matches a single path segment, its template may be omitted, e.g. `{var}` + * is equivalent to `{var=*}`. + * + * If a variable contains exactly one path segment, such as `"{var}"` or + * `"{var=*}"`, when such a variable is expanded into a URL path, all characters + * except `[-_.~0-9a-zA-Z]` are percent-encoded. Such variables show up in the + * Discovery Document as `{var}`. + * + * If a variable contains one or more path segments, such as `"{var=foo/*}"` + * or `"{var=**}"`, when such a variable is expanded into a URL path, all + * characters except `[-_.~/0-9a-zA-Z]` are percent-encoded. Such variables + * show up in the Discovery Document as `{+var}`. + * + * NOTE: While the single segment variable matches the semantics of + * [RFC 6570](https://tools.ietf.org/html/rfc6570) Section 3.2.2 + * Simple String Expansion, the multi segment variable **does not** match + * RFC 6570 Reserved Expansion. The reason is that the Reserved Expansion + * does not expand special characters like `?` and `#`, which would lead + * to invalid URLs. + * + * NOTE: the field paths in variables and in the `body` must not refer to + * repeated fields or map fields. + */ +export interface HttpRule { + /** + * Selects methods to which this rule applies. + * + * Refer to [selector][google.api.DocumentationRule.selector] for syntax details. + */ + selector: string; + /** Used for listing and getting information about resources. */ + get: string | undefined; + /** Used for updating a resource. */ + put: string | undefined; + /** Used for creating a resource. */ + post: string | undefined; + /** Used for deleting a resource. */ + delete: string | undefined; + /** Used for updating a resource. */ + patch: string | undefined; + /** + * The custom pattern is used for specifying an HTTP method that is not + * included in the `pattern` field, such as HEAD, or "*" to leave the + * HTTP method unspecified for this rule. The wild-card rule is useful + * for services that provide content to Web (HTML) clients. + */ + custom: CustomHttpPattern | undefined; + /** + * The name of the request field whose value is mapped to the HTTP body, or + * `*` for mapping all fields not captured by the path pattern to the HTTP + * body. NOTE: the referred field must not be a repeated field and must be + * present at the top-level of request message type. + */ + body: string; + /** + * Optional. The name of the response field whose value is mapped to the HTTP + * body of response. Other response fields are ignored. When + * not set, the response message will be used as HTTP body of response. + */ + responseBody: string; + /** + * Additional HTTP bindings for the selector. Nested bindings must + * not contain an `additional_bindings` field themselves (that is, + * the nesting may only be one level deep). + */ + additionalBindings: HttpRule[]; +} + +/** A custom pattern is used for defining custom HTTP verb. */ +export interface CustomHttpPattern { + /** The name of this custom HTTP verb. */ + kind: string; + /** The path matched by this custom verb. */ + path: string; +} + +const baseHttp: object = { fullyDecodeReservedExpansion: false }; + +export const Http = { + encode(message: Http, writer: Writer = Writer.create()): Writer { + for (const v of message.rules) { + HttpRule.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.fullyDecodeReservedExpansion === true) { + writer.uint32(16).bool(message.fullyDecodeReservedExpansion); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Http { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseHttp } as Http; + message.rules = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.rules.push(HttpRule.decode(reader, reader.uint32())); + break; + case 2: + message.fullyDecodeReservedExpansion = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Http { + const message = { ...baseHttp } as Http; + message.rules = []; + if (object.rules !== undefined && object.rules !== null) { + for (const e of object.rules) { + message.rules.push(HttpRule.fromJSON(e)); + } + } + if ( + object.fullyDecodeReservedExpansion !== undefined && + object.fullyDecodeReservedExpansion !== null + ) { + message.fullyDecodeReservedExpansion = Boolean( + object.fullyDecodeReservedExpansion + ); + } else { + message.fullyDecodeReservedExpansion = false; + } + return message; + }, + + toJSON(message: Http): unknown { + const obj: any = {}; + if (message.rules) { + obj.rules = message.rules.map((e) => + e ? HttpRule.toJSON(e) : undefined + ); + } else { + obj.rules = []; + } + message.fullyDecodeReservedExpansion !== undefined && + (obj.fullyDecodeReservedExpansion = message.fullyDecodeReservedExpansion); + return obj; + }, + + fromPartial(object: DeepPartial): Http { + const message = { ...baseHttp } as Http; + message.rules = []; + if (object.rules !== undefined && object.rules !== null) { + for (const e of object.rules) { + message.rules.push(HttpRule.fromPartial(e)); + } + } + if ( + object.fullyDecodeReservedExpansion !== undefined && + object.fullyDecodeReservedExpansion !== null + ) { + message.fullyDecodeReservedExpansion = + object.fullyDecodeReservedExpansion; + } else { + message.fullyDecodeReservedExpansion = false; + } + return message; + }, +}; + +const baseHttpRule: object = { selector: "", body: "", responseBody: "" }; + +export const HttpRule = { + encode(message: HttpRule, writer: Writer = Writer.create()): Writer { + if (message.selector !== "") { + writer.uint32(10).string(message.selector); + } + if (message.get !== undefined) { + writer.uint32(18).string(message.get); + } + if (message.put !== undefined) { + writer.uint32(26).string(message.put); + } + if (message.post !== undefined) { + writer.uint32(34).string(message.post); + } + if (message.delete !== undefined) { + writer.uint32(42).string(message.delete); + } + if (message.patch !== undefined) { + writer.uint32(50).string(message.patch); + } + if (message.custom !== undefined) { + CustomHttpPattern.encode( + message.custom, + writer.uint32(66).fork() + ).ldelim(); + } + if (message.body !== "") { + writer.uint32(58).string(message.body); + } + if (message.responseBody !== "") { + writer.uint32(98).string(message.responseBody); + } + for (const v of message.additionalBindings) { + HttpRule.encode(v!, writer.uint32(90).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): HttpRule { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseHttpRule } as HttpRule; + message.additionalBindings = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.selector = reader.string(); + break; + case 2: + message.get = reader.string(); + break; + case 3: + message.put = reader.string(); + break; + case 4: + message.post = reader.string(); + break; + case 5: + message.delete = reader.string(); + break; + case 6: + message.patch = reader.string(); + break; + case 8: + message.custom = CustomHttpPattern.decode(reader, reader.uint32()); + break; + case 7: + message.body = reader.string(); + break; + case 12: + message.responseBody = reader.string(); + break; + case 11: + message.additionalBindings.push( + HttpRule.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): HttpRule { + const message = { ...baseHttpRule } as HttpRule; + message.additionalBindings = []; + if (object.selector !== undefined && object.selector !== null) { + message.selector = String(object.selector); + } else { + message.selector = ""; + } + if (object.get !== undefined && object.get !== null) { + message.get = String(object.get); + } else { + message.get = undefined; + } + if (object.put !== undefined && object.put !== null) { + message.put = String(object.put); + } else { + message.put = undefined; + } + if (object.post !== undefined && object.post !== null) { + message.post = String(object.post); + } else { + message.post = undefined; + } + if (object.delete !== undefined && object.delete !== null) { + message.delete = String(object.delete); + } else { + message.delete = undefined; + } + if (object.patch !== undefined && object.patch !== null) { + message.patch = String(object.patch); + } else { + message.patch = undefined; + } + if (object.custom !== undefined && object.custom !== null) { + message.custom = CustomHttpPattern.fromJSON(object.custom); + } else { + message.custom = undefined; + } + if (object.body !== undefined && object.body !== null) { + message.body = String(object.body); + } else { + message.body = ""; + } + if (object.responseBody !== undefined && object.responseBody !== null) { + message.responseBody = String(object.responseBody); + } else { + message.responseBody = ""; + } + if ( + object.additionalBindings !== undefined && + object.additionalBindings !== null + ) { + for (const e of object.additionalBindings) { + message.additionalBindings.push(HttpRule.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: HttpRule): unknown { + const obj: any = {}; + message.selector !== undefined && (obj.selector = message.selector); + message.get !== undefined && (obj.get = message.get); + message.put !== undefined && (obj.put = message.put); + message.post !== undefined && (obj.post = message.post); + message.delete !== undefined && (obj.delete = message.delete); + message.patch !== undefined && (obj.patch = message.patch); + message.custom !== undefined && + (obj.custom = message.custom + ? CustomHttpPattern.toJSON(message.custom) + : undefined); + message.body !== undefined && (obj.body = message.body); + message.responseBody !== undefined && + (obj.responseBody = message.responseBody); + if (message.additionalBindings) { + obj.additionalBindings = message.additionalBindings.map((e) => + e ? HttpRule.toJSON(e) : undefined + ); + } else { + obj.additionalBindings = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): HttpRule { + const message = { ...baseHttpRule } as HttpRule; + message.additionalBindings = []; + if (object.selector !== undefined && object.selector !== null) { + message.selector = object.selector; + } else { + message.selector = ""; + } + if (object.get !== undefined && object.get !== null) { + message.get = object.get; + } else { + message.get = undefined; + } + if (object.put !== undefined && object.put !== null) { + message.put = object.put; + } else { + message.put = undefined; + } + if (object.post !== undefined && object.post !== null) { + message.post = object.post; + } else { + message.post = undefined; + } + if (object.delete !== undefined && object.delete !== null) { + message.delete = object.delete; + } else { + message.delete = undefined; + } + if (object.patch !== undefined && object.patch !== null) { + message.patch = object.patch; + } else { + message.patch = undefined; + } + if (object.custom !== undefined && object.custom !== null) { + message.custom = CustomHttpPattern.fromPartial(object.custom); + } else { + message.custom = undefined; + } + if (object.body !== undefined && object.body !== null) { + message.body = object.body; + } else { + message.body = ""; + } + if (object.responseBody !== undefined && object.responseBody !== null) { + message.responseBody = object.responseBody; + } else { + message.responseBody = ""; + } + if ( + object.additionalBindings !== undefined && + object.additionalBindings !== null + ) { + for (const e of object.additionalBindings) { + message.additionalBindings.push(HttpRule.fromPartial(e)); + } + } + return message; + }, +}; + +const baseCustomHttpPattern: object = { kind: "", path: "" }; + +export const CustomHttpPattern = { + encode(message: CustomHttpPattern, writer: Writer = Writer.create()): Writer { + if (message.kind !== "") { + writer.uint32(10).string(message.kind); + } + if (message.path !== "") { + writer.uint32(18).string(message.path); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): CustomHttpPattern { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseCustomHttpPattern } as CustomHttpPattern; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.kind = reader.string(); + break; + case 2: + message.path = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): CustomHttpPattern { + const message = { ...baseCustomHttpPattern } as CustomHttpPattern; + if (object.kind !== undefined && object.kind !== null) { + message.kind = String(object.kind); + } else { + message.kind = ""; + } + if (object.path !== undefined && object.path !== null) { + message.path = String(object.path); + } else { + message.path = ""; + } + return message; + }, + + toJSON(message: CustomHttpPattern): unknown { + const obj: any = {}; + message.kind !== undefined && (obj.kind = message.kind); + message.path !== undefined && (obj.path = message.path); + return obj; + }, + + fromPartial(object: DeepPartial): CustomHttpPattern { + const message = { ...baseCustomHttpPattern } as CustomHttpPattern; + if (object.kind !== undefined && object.kind !== null) { + message.kind = object.kind; + } else { + message.kind = ""; + } + if (object.path !== undefined && object.path !== null) { + message.path = object.path; + } else { + message.path = ""; + } + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/cosmos.upgrade.v1beta1/types/google/protobuf/any.ts b/ts-client/cosmos.upgrade.v1beta1/types/google/protobuf/any.ts new file mode 100644 index 00000000..b137a629 --- /dev/null +++ b/ts-client/cosmos.upgrade.v1beta1/types/google/protobuf/any.ts @@ -0,0 +1,240 @@ +/* eslint-disable */ +import { Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "google.protobuf"; + +/** + * `Any` contains an arbitrary serialized protocol buffer message along with a + * URL that describes the type of the serialized message. + * + * Protobuf library provides support to pack/unpack Any values in the form + * of utility functions or additional generated methods of the Any type. + * + * Example 1: Pack and unpack a message in C++. + * + * Foo foo = ...; + * Any any; + * any.PackFrom(foo); + * ... + * if (any.UnpackTo(&foo)) { + * ... + * } + * + * Example 2: Pack and unpack a message in Java. + * + * Foo foo = ...; + * Any any = Any.pack(foo); + * ... + * if (any.is(Foo.class)) { + * foo = any.unpack(Foo.class); + * } + * + * Example 3: Pack and unpack a message in Python. + * + * foo = Foo(...) + * any = Any() + * any.Pack(foo) + * ... + * if any.Is(Foo.DESCRIPTOR): + * any.Unpack(foo) + * ... + * + * Example 4: Pack and unpack a message in Go + * + * foo := &pb.Foo{...} + * any, err := anypb.New(foo) + * if err != nil { + * ... + * } + * ... + * foo := &pb.Foo{} + * if err := any.UnmarshalTo(foo); err != nil { + * ... + * } + * + * The pack methods provided by protobuf library will by default use + * 'type.googleapis.com/full.type.name' as the type URL and the unpack + * methods only use the fully qualified type name after the last '/' + * in the type URL, for example "foo.bar.com/x/y.z" will yield type + * name "y.z". + * + * + * JSON + * ==== + * The JSON representation of an `Any` value uses the regular + * representation of the deserialized, embedded message, with an + * additional field `@type` which contains the type URL. Example: + * + * package google.profile; + * message Person { + * string first_name = 1; + * string last_name = 2; + * } + * + * { + * "@type": "type.googleapis.com/google.profile.Person", + * "firstName": , + * "lastName": + * } + * + * If the embedded message type is well-known and has a custom JSON + * representation, that representation will be embedded adding a field + * `value` which holds the custom JSON in addition to the `@type` + * field. Example (for message [google.protobuf.Duration][]): + * + * { + * "@type": "type.googleapis.com/google.protobuf.Duration", + * "value": "1.212s" + * } + */ +export interface Any { + /** + * A URL/resource name that uniquely identifies the type of the serialized + * protocol buffer message. This string must contain at least + * one "/" character. The last segment of the URL's path must represent + * the fully qualified name of the type (as in + * `path/google.protobuf.Duration`). The name should be in a canonical form + * (e.g., leading "." is not accepted). + * + * In practice, teams usually precompile into the binary all types that they + * expect it to use in the context of Any. However, for URLs which use the + * scheme `http`, `https`, or no scheme, one can optionally set up a type + * server that maps type URLs to message definitions as follows: + * + * * If no scheme is provided, `https` is assumed. + * * An HTTP GET on the URL must yield a [google.protobuf.Type][] + * value in binary format, or produce an error. + * * Applications are allowed to cache lookup results based on the + * URL, or have them precompiled into a binary to avoid any + * lookup. Therefore, binary compatibility needs to be preserved + * on changes to types. (Use versioned type names to manage + * breaking changes.) + * + * Note: this functionality is not currently available in the official + * protobuf release, and it is not used for type URLs beginning with + * type.googleapis.com. + * + * Schemes other than `http`, `https` (or the empty scheme) might be + * used with implementation specific semantics. + */ + typeUrl: string; + /** Must be a valid serialized protocol buffer of the above specified type. */ + value: Uint8Array; +} + +const baseAny: object = { typeUrl: "" }; + +export const Any = { + encode(message: Any, writer: Writer = Writer.create()): Writer { + if (message.typeUrl !== "") { + writer.uint32(10).string(message.typeUrl); + } + if (message.value.length !== 0) { + writer.uint32(18).bytes(message.value); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Any { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseAny } as Any; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.typeUrl = reader.string(); + break; + case 2: + message.value = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Any { + const message = { ...baseAny } as Any; + if (object.typeUrl !== undefined && object.typeUrl !== null) { + message.typeUrl = String(object.typeUrl); + } else { + message.typeUrl = ""; + } + if (object.value !== undefined && object.value !== null) { + message.value = bytesFromBase64(object.value); + } + return message; + }, + + toJSON(message: Any): unknown { + const obj: any = {}; + message.typeUrl !== undefined && (obj.typeUrl = message.typeUrl); + message.value !== undefined && + (obj.value = base64FromBytes( + message.value !== undefined ? message.value : new Uint8Array() + )); + return obj; + }, + + fromPartial(object: DeepPartial): Any { + const message = { ...baseAny } as Any; + if (object.typeUrl !== undefined && object.typeUrl !== null) { + message.typeUrl = object.typeUrl; + } else { + message.typeUrl = ""; + } + if (object.value !== undefined && object.value !== null) { + message.value = object.value; + } else { + message.value = new Uint8Array(); + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/cosmos.upgrade.v1beta1/types/google/protobuf/descriptor.ts b/ts-client/cosmos.upgrade.v1beta1/types/google/protobuf/descriptor.ts new file mode 100644 index 00000000..9e508660 --- /dev/null +++ b/ts-client/cosmos.upgrade.v1beta1/types/google/protobuf/descriptor.ts @@ -0,0 +1,5261 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "google.protobuf"; + +/** + * The protocol compiler can output a FileDescriptorSet containing the .proto + * files it parses. + */ +export interface FileDescriptorSet { + file: FileDescriptorProto[]; +} + +/** Describes a complete .proto file. */ +export interface FileDescriptorProto { + /** file name, relative to root of source tree */ + name: string; + /** e.g. "foo", "foo.bar", etc. */ + package: string; + /** Names of files imported by this file. */ + dependency: string[]; + /** Indexes of the public imported files in the dependency list above. */ + publicDependency: number[]; + /** + * Indexes of the weak imported files in the dependency list. + * For Google-internal migration only. Do not use. + */ + weakDependency: number[]; + /** All top-level definitions in this file. */ + messageType: DescriptorProto[]; + enumType: EnumDescriptorProto[]; + service: ServiceDescriptorProto[]; + extension: FieldDescriptorProto[]; + options: FileOptions | undefined; + /** + * This field contains optional information about the original source code. + * You may safely remove this entire field without harming runtime + * functionality of the descriptors -- the information is needed only by + * development tools. + */ + sourceCodeInfo: SourceCodeInfo | undefined; + /** + * The syntax of the proto file. + * The supported values are "proto2" and "proto3". + */ + syntax: string; +} + +/** Describes a message type. */ +export interface DescriptorProto { + name: string; + field: FieldDescriptorProto[]; + extension: FieldDescriptorProto[]; + nestedType: DescriptorProto[]; + enumType: EnumDescriptorProto[]; + extensionRange: DescriptorProto_ExtensionRange[]; + oneofDecl: OneofDescriptorProto[]; + options: MessageOptions | undefined; + reservedRange: DescriptorProto_ReservedRange[]; + /** + * Reserved field names, which may not be used by fields in the same message. + * A given name may only be reserved once. + */ + reservedName: string[]; +} + +export interface DescriptorProto_ExtensionRange { + /** Inclusive. */ + start: number; + /** Exclusive. */ + end: number; + options: ExtensionRangeOptions | undefined; +} + +/** + * Range of reserved tag numbers. Reserved tag numbers may not be used by + * fields or extension ranges in the same message. Reserved ranges may + * not overlap. + */ +export interface DescriptorProto_ReservedRange { + /** Inclusive. */ + start: number; + /** Exclusive. */ + end: number; +} + +export interface ExtensionRangeOptions { + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +/** Describes a field within a message. */ +export interface FieldDescriptorProto { + name: string; + number: number; + label: FieldDescriptorProto_Label; + /** + * If type_name is set, this need not be set. If both this and type_name + * are set, this must be one of TYPE_ENUM, TYPE_MESSAGE or TYPE_GROUP. + */ + type: FieldDescriptorProto_Type; + /** + * For message and enum types, this is the name of the type. If the name + * starts with a '.', it is fully-qualified. Otherwise, C++-like scoping + * rules are used to find the type (i.e. first the nested types within this + * message are searched, then within the parent, on up to the root + * namespace). + */ + typeName: string; + /** + * For extensions, this is the name of the type being extended. It is + * resolved in the same manner as type_name. + */ + extendee: string; + /** + * For numeric types, contains the original text representation of the value. + * For booleans, "true" or "false". + * For strings, contains the default text contents (not escaped in any way). + * For bytes, contains the C escaped value. All bytes >= 128 are escaped. + * TODO(kenton): Base-64 encode? + */ + defaultValue: string; + /** + * If set, gives the index of a oneof in the containing type's oneof_decl + * list. This field is a member of that oneof. + */ + oneofIndex: number; + /** + * JSON name of this field. The value is set by protocol compiler. If the + * user has set a "json_name" option on this field, that option's value + * will be used. Otherwise, it's deduced from the field's name by converting + * it to camelCase. + */ + jsonName: string; + options: FieldOptions | undefined; + /** + * If true, this is a proto3 "optional". When a proto3 field is optional, it + * tracks presence regardless of field type. + * + * When proto3_optional is true, this field must be belong to a oneof to + * signal to old proto3 clients that presence is tracked for this field. This + * oneof is known as a "synthetic" oneof, and this field must be its sole + * member (each proto3 optional field gets its own synthetic oneof). Synthetic + * oneofs exist in the descriptor only, and do not generate any API. Synthetic + * oneofs must be ordered after all "real" oneofs. + * + * For message fields, proto3_optional doesn't create any semantic change, + * since non-repeated message fields always track presence. However it still + * indicates the semantic detail of whether the user wrote "optional" or not. + * This can be useful for round-tripping the .proto file. For consistency we + * give message fields a synthetic oneof also, even though it is not required + * to track presence. This is especially important because the parser can't + * tell if a field is a message or an enum, so it must always create a + * synthetic oneof. + * + * Proto2 optional fields do not set this flag, because they already indicate + * optional with `LABEL_OPTIONAL`. + */ + proto3Optional: boolean; +} + +export enum FieldDescriptorProto_Type { + /** + * TYPE_DOUBLE - 0 is reserved for errors. + * Order is weird for historical reasons. + */ + TYPE_DOUBLE = 1, + TYPE_FLOAT = 2, + /** + * TYPE_INT64 - Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT64 if + * negative values are likely. + */ + TYPE_INT64 = 3, + TYPE_UINT64 = 4, + /** + * TYPE_INT32 - Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT32 if + * negative values are likely. + */ + TYPE_INT32 = 5, + TYPE_FIXED64 = 6, + TYPE_FIXED32 = 7, + TYPE_BOOL = 8, + TYPE_STRING = 9, + /** + * TYPE_GROUP - Tag-delimited aggregate. + * Group type is deprecated and not supported in proto3. However, Proto3 + * implementations should still be able to parse the group wire format and + * treat group fields as unknown fields. + */ + TYPE_GROUP = 10, + /** TYPE_MESSAGE - Length-delimited aggregate. */ + TYPE_MESSAGE = 11, + /** TYPE_BYTES - New in version 2. */ + TYPE_BYTES = 12, + TYPE_UINT32 = 13, + TYPE_ENUM = 14, + TYPE_SFIXED32 = 15, + TYPE_SFIXED64 = 16, + /** TYPE_SINT32 - Uses ZigZag encoding. */ + TYPE_SINT32 = 17, + /** TYPE_SINT64 - Uses ZigZag encoding. */ + TYPE_SINT64 = 18, + UNRECOGNIZED = -1, +} + +export function fieldDescriptorProto_TypeFromJSON( + object: any +): FieldDescriptorProto_Type { + switch (object) { + case 1: + case "TYPE_DOUBLE": + return FieldDescriptorProto_Type.TYPE_DOUBLE; + case 2: + case "TYPE_FLOAT": + return FieldDescriptorProto_Type.TYPE_FLOAT; + case 3: + case "TYPE_INT64": + return FieldDescriptorProto_Type.TYPE_INT64; + case 4: + case "TYPE_UINT64": + return FieldDescriptorProto_Type.TYPE_UINT64; + case 5: + case "TYPE_INT32": + return FieldDescriptorProto_Type.TYPE_INT32; + case 6: + case "TYPE_FIXED64": + return FieldDescriptorProto_Type.TYPE_FIXED64; + case 7: + case "TYPE_FIXED32": + return FieldDescriptorProto_Type.TYPE_FIXED32; + case 8: + case "TYPE_BOOL": + return FieldDescriptorProto_Type.TYPE_BOOL; + case 9: + case "TYPE_STRING": + return FieldDescriptorProto_Type.TYPE_STRING; + case 10: + case "TYPE_GROUP": + return FieldDescriptorProto_Type.TYPE_GROUP; + case 11: + case "TYPE_MESSAGE": + return FieldDescriptorProto_Type.TYPE_MESSAGE; + case 12: + case "TYPE_BYTES": + return FieldDescriptorProto_Type.TYPE_BYTES; + case 13: + case "TYPE_UINT32": + return FieldDescriptorProto_Type.TYPE_UINT32; + case 14: + case "TYPE_ENUM": + return FieldDescriptorProto_Type.TYPE_ENUM; + case 15: + case "TYPE_SFIXED32": + return FieldDescriptorProto_Type.TYPE_SFIXED32; + case 16: + case "TYPE_SFIXED64": + return FieldDescriptorProto_Type.TYPE_SFIXED64; + case 17: + case "TYPE_SINT32": + return FieldDescriptorProto_Type.TYPE_SINT32; + case 18: + case "TYPE_SINT64": + return FieldDescriptorProto_Type.TYPE_SINT64; + case -1: + case "UNRECOGNIZED": + default: + return FieldDescriptorProto_Type.UNRECOGNIZED; + } +} + +export function fieldDescriptorProto_TypeToJSON( + object: FieldDescriptorProto_Type +): string { + switch (object) { + case FieldDescriptorProto_Type.TYPE_DOUBLE: + return "TYPE_DOUBLE"; + case FieldDescriptorProto_Type.TYPE_FLOAT: + return "TYPE_FLOAT"; + case FieldDescriptorProto_Type.TYPE_INT64: + return "TYPE_INT64"; + case FieldDescriptorProto_Type.TYPE_UINT64: + return "TYPE_UINT64"; + case FieldDescriptorProto_Type.TYPE_INT32: + return "TYPE_INT32"; + case FieldDescriptorProto_Type.TYPE_FIXED64: + return "TYPE_FIXED64"; + case FieldDescriptorProto_Type.TYPE_FIXED32: + return "TYPE_FIXED32"; + case FieldDescriptorProto_Type.TYPE_BOOL: + return "TYPE_BOOL"; + case FieldDescriptorProto_Type.TYPE_STRING: + return "TYPE_STRING"; + case FieldDescriptorProto_Type.TYPE_GROUP: + return "TYPE_GROUP"; + case FieldDescriptorProto_Type.TYPE_MESSAGE: + return "TYPE_MESSAGE"; + case FieldDescriptorProto_Type.TYPE_BYTES: + return "TYPE_BYTES"; + case FieldDescriptorProto_Type.TYPE_UINT32: + return "TYPE_UINT32"; + case FieldDescriptorProto_Type.TYPE_ENUM: + return "TYPE_ENUM"; + case FieldDescriptorProto_Type.TYPE_SFIXED32: + return "TYPE_SFIXED32"; + case FieldDescriptorProto_Type.TYPE_SFIXED64: + return "TYPE_SFIXED64"; + case FieldDescriptorProto_Type.TYPE_SINT32: + return "TYPE_SINT32"; + case FieldDescriptorProto_Type.TYPE_SINT64: + return "TYPE_SINT64"; + default: + return "UNKNOWN"; + } +} + +export enum FieldDescriptorProto_Label { + /** LABEL_OPTIONAL - 0 is reserved for errors */ + LABEL_OPTIONAL = 1, + LABEL_REQUIRED = 2, + LABEL_REPEATED = 3, + UNRECOGNIZED = -1, +} + +export function fieldDescriptorProto_LabelFromJSON( + object: any +): FieldDescriptorProto_Label { + switch (object) { + case 1: + case "LABEL_OPTIONAL": + return FieldDescriptorProto_Label.LABEL_OPTIONAL; + case 2: + case "LABEL_REQUIRED": + return FieldDescriptorProto_Label.LABEL_REQUIRED; + case 3: + case "LABEL_REPEATED": + return FieldDescriptorProto_Label.LABEL_REPEATED; + case -1: + case "UNRECOGNIZED": + default: + return FieldDescriptorProto_Label.UNRECOGNIZED; + } +} + +export function fieldDescriptorProto_LabelToJSON( + object: FieldDescriptorProto_Label +): string { + switch (object) { + case FieldDescriptorProto_Label.LABEL_OPTIONAL: + return "LABEL_OPTIONAL"; + case FieldDescriptorProto_Label.LABEL_REQUIRED: + return "LABEL_REQUIRED"; + case FieldDescriptorProto_Label.LABEL_REPEATED: + return "LABEL_REPEATED"; + default: + return "UNKNOWN"; + } +} + +/** Describes a oneof. */ +export interface OneofDescriptorProto { + name: string; + options: OneofOptions | undefined; +} + +/** Describes an enum type. */ +export interface EnumDescriptorProto { + name: string; + value: EnumValueDescriptorProto[]; + options: EnumOptions | undefined; + /** + * Range of reserved numeric values. Reserved numeric values may not be used + * by enum values in the same enum declaration. Reserved ranges may not + * overlap. + */ + reservedRange: EnumDescriptorProto_EnumReservedRange[]; + /** + * Reserved enum value names, which may not be reused. A given name may only + * be reserved once. + */ + reservedName: string[]; +} + +/** + * Range of reserved numeric values. Reserved values may not be used by + * entries in the same enum. Reserved ranges may not overlap. + * + * Note that this is distinct from DescriptorProto.ReservedRange in that it + * is inclusive such that it can appropriately represent the entire int32 + * domain. + */ +export interface EnumDescriptorProto_EnumReservedRange { + /** Inclusive. */ + start: number; + /** Inclusive. */ + end: number; +} + +/** Describes a value within an enum. */ +export interface EnumValueDescriptorProto { + name: string; + number: number; + options: EnumValueOptions | undefined; +} + +/** Describes a service. */ +export interface ServiceDescriptorProto { + name: string; + method: MethodDescriptorProto[]; + options: ServiceOptions | undefined; +} + +/** Describes a method of a service. */ +export interface MethodDescriptorProto { + name: string; + /** + * Input and output type names. These are resolved in the same way as + * FieldDescriptorProto.type_name, but must refer to a message type. + */ + inputType: string; + outputType: string; + options: MethodOptions | undefined; + /** Identifies if client streams multiple client messages */ + clientStreaming: boolean; + /** Identifies if server streams multiple server messages */ + serverStreaming: boolean; +} + +export interface FileOptions { + /** + * Sets the Java package where classes generated from this .proto will be + * placed. By default, the proto package is used, but this is often + * inappropriate because proto packages do not normally start with backwards + * domain names. + */ + javaPackage: string; + /** + * Controls the name of the wrapper Java class generated for the .proto file. + * That class will always contain the .proto file's getDescriptor() method as + * well as any top-level extensions defined in the .proto file. + * If java_multiple_files is disabled, then all the other classes from the + * .proto file will be nested inside the single wrapper outer class. + */ + javaOuterClassname: string; + /** + * If enabled, then the Java code generator will generate a separate .java + * file for each top-level message, enum, and service defined in the .proto + * file. Thus, these types will *not* be nested inside the wrapper class + * named by java_outer_classname. However, the wrapper class will still be + * generated to contain the file's getDescriptor() method as well as any + * top-level extensions defined in the file. + */ + javaMultipleFiles: boolean; + /** + * This option does nothing. + * + * @deprecated + */ + javaGenerateEqualsAndHash: boolean; + /** + * If set true, then the Java2 code generator will generate code that + * throws an exception whenever an attempt is made to assign a non-UTF-8 + * byte sequence to a string field. + * Message reflection will do the same. + * However, an extension field still accepts non-UTF-8 byte sequences. + * This option has no effect on when used with the lite runtime. + */ + javaStringCheckUtf8: boolean; + optimizeFor: FileOptions_OptimizeMode; + /** + * Sets the Go package where structs generated from this .proto will be + * placed. If omitted, the Go package will be derived from the following: + * - The basename of the package import path, if provided. + * - Otherwise, the package statement in the .proto file, if present. + * - Otherwise, the basename of the .proto file, without extension. + */ + goPackage: string; + /** + * Should generic services be generated in each language? "Generic" services + * are not specific to any particular RPC system. They are generated by the + * main code generators in each language (without additional plugins). + * Generic services were the only kind of service generation supported by + * early versions of google.protobuf. + * + * Generic services are now considered deprecated in favor of using plugins + * that generate code specific to your particular RPC system. Therefore, + * these default to false. Old code which depends on generic services should + * explicitly set them to true. + */ + ccGenericServices: boolean; + javaGenericServices: boolean; + pyGenericServices: boolean; + phpGenericServices: boolean; + /** + * Is this file deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for everything in the file, or it will be completely ignored; in the very + * least, this is a formalization for deprecating files. + */ + deprecated: boolean; + /** + * Enables the use of arenas for the proto messages in this file. This applies + * only to generated classes for C++. + */ + ccEnableArenas: boolean; + /** + * Sets the objective c class prefix which is prepended to all objective c + * generated classes from this .proto. There is no default. + */ + objcClassPrefix: string; + /** Namespace for generated classes; defaults to the package. */ + csharpNamespace: string; + /** + * By default Swift generators will take the proto package and CamelCase it + * replacing '.' with underscore and use that to prefix the types/symbols + * defined. When this options is provided, they will use this value instead + * to prefix the types/symbols defined. + */ + swiftPrefix: string; + /** + * Sets the php class prefix which is prepended to all php generated classes + * from this .proto. Default is empty. + */ + phpClassPrefix: string; + /** + * Use this option to change the namespace of php generated classes. Default + * is empty. When this option is empty, the package name will be used for + * determining the namespace. + */ + phpNamespace: string; + /** + * Use this option to change the namespace of php generated metadata classes. + * Default is empty. When this option is empty, the proto file name will be + * used for determining the namespace. + */ + phpMetadataNamespace: string; + /** + * Use this option to change the package of ruby generated classes. Default + * is empty. When this option is not set, the package name will be used for + * determining the ruby package. + */ + rubyPackage: string; + /** + * The parser stores options it doesn't recognize here. + * See the documentation for the "Options" section above. + */ + uninterpretedOption: UninterpretedOption[]; +} + +/** Generated classes can be optimized for speed or code size. */ +export enum FileOptions_OptimizeMode { + /** SPEED - Generate complete code for parsing, serialization, */ + SPEED = 1, + /** CODE_SIZE - etc. */ + CODE_SIZE = 2, + /** LITE_RUNTIME - Generate code using MessageLite and the lite runtime. */ + LITE_RUNTIME = 3, + UNRECOGNIZED = -1, +} + +export function fileOptions_OptimizeModeFromJSON( + object: any +): FileOptions_OptimizeMode { + switch (object) { + case 1: + case "SPEED": + return FileOptions_OptimizeMode.SPEED; + case 2: + case "CODE_SIZE": + return FileOptions_OptimizeMode.CODE_SIZE; + case 3: + case "LITE_RUNTIME": + return FileOptions_OptimizeMode.LITE_RUNTIME; + case -1: + case "UNRECOGNIZED": + default: + return FileOptions_OptimizeMode.UNRECOGNIZED; + } +} + +export function fileOptions_OptimizeModeToJSON( + object: FileOptions_OptimizeMode +): string { + switch (object) { + case FileOptions_OptimizeMode.SPEED: + return "SPEED"; + case FileOptions_OptimizeMode.CODE_SIZE: + return "CODE_SIZE"; + case FileOptions_OptimizeMode.LITE_RUNTIME: + return "LITE_RUNTIME"; + default: + return "UNKNOWN"; + } +} + +export interface MessageOptions { + /** + * Set true to use the old proto1 MessageSet wire format for extensions. + * This is provided for backwards-compatibility with the MessageSet wire + * format. You should not use this for any other reason: It's less + * efficient, has fewer features, and is more complicated. + * + * The message must be defined exactly as follows: + * message Foo { + * option message_set_wire_format = true; + * extensions 4 to max; + * } + * Note that the message cannot have any defined fields; MessageSets only + * have extensions. + * + * All extensions of your type must be singular messages; e.g. they cannot + * be int32s, enums, or repeated messages. + * + * Because this is an option, the above two restrictions are not enforced by + * the protocol compiler. + */ + messageSetWireFormat: boolean; + /** + * Disables the generation of the standard "descriptor()" accessor, which can + * conflict with a field of the same name. This is meant to make migration + * from proto1 easier; new code should avoid fields named "descriptor". + */ + noStandardDescriptorAccessor: boolean; + /** + * Is this message deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the message, or it will be completely ignored; in the very least, + * this is a formalization for deprecating messages. + */ + deprecated: boolean; + /** + * Whether the message is an automatically generated map entry type for the + * maps field. + * + * For maps fields: + * map map_field = 1; + * The parsed descriptor looks like: + * message MapFieldEntry { + * option map_entry = true; + * optional KeyType key = 1; + * optional ValueType value = 2; + * } + * repeated MapFieldEntry map_field = 1; + * + * Implementations may choose not to generate the map_entry=true message, but + * use a native map in the target language to hold the keys and values. + * The reflection APIs in such implementations still need to work as + * if the field is a repeated message field. + * + * NOTE: Do not set the option in .proto files. Always use the maps syntax + * instead. The option should only be implicitly set by the proto compiler + * parser. + */ + mapEntry: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface FieldOptions { + /** + * The ctype option instructs the C++ code generator to use a different + * representation of the field than it normally would. See the specific + * options below. This option is not yet implemented in the open source + * release -- sorry, we'll try to include it in a future version! + */ + ctype: FieldOptions_CType; + /** + * The packed option can be enabled for repeated primitive fields to enable + * a more efficient representation on the wire. Rather than repeatedly + * writing the tag and type for each element, the entire array is encoded as + * a single length-delimited blob. In proto3, only explicit setting it to + * false will avoid using packed encoding. + */ + packed: boolean; + /** + * The jstype option determines the JavaScript type used for values of the + * field. The option is permitted only for 64 bit integral and fixed types + * (int64, uint64, sint64, fixed64, sfixed64). A field with jstype JS_STRING + * is represented as JavaScript string, which avoids loss of precision that + * can happen when a large value is converted to a floating point JavaScript. + * Specifying JS_NUMBER for the jstype causes the generated JavaScript code to + * use the JavaScript "number" type. The behavior of the default option + * JS_NORMAL is implementation dependent. + * + * This option is an enum to permit additional types to be added, e.g. + * goog.math.Integer. + */ + jstype: FieldOptions_JSType; + /** + * Should this field be parsed lazily? Lazy applies only to message-type + * fields. It means that when the outer message is initially parsed, the + * inner message's contents will not be parsed but instead stored in encoded + * form. The inner message will actually be parsed when it is first accessed. + * + * This is only a hint. Implementations are free to choose whether to use + * eager or lazy parsing regardless of the value of this option. However, + * setting this option true suggests that the protocol author believes that + * using lazy parsing on this field is worth the additional bookkeeping + * overhead typically needed to implement it. + * + * This option does not affect the public interface of any generated code; + * all method signatures remain the same. Furthermore, thread-safety of the + * interface is not affected by this option; const methods remain safe to + * call from multiple threads concurrently, while non-const methods continue + * to require exclusive access. + * + * + * Note that implementations may choose not to check required fields within + * a lazy sub-message. That is, calling IsInitialized() on the outer message + * may return true even if the inner message has missing required fields. + * This is necessary because otherwise the inner message would have to be + * parsed in order to perform the check, defeating the purpose of lazy + * parsing. An implementation which chooses not to check required fields + * must be consistent about it. That is, for any particular sub-message, the + * implementation must either *always* check its required fields, or *never* + * check its required fields, regardless of whether or not the message has + * been parsed. + */ + lazy: boolean; + /** + * Is this field deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for accessors, or it will be completely ignored; in the very least, this + * is a formalization for deprecating fields. + */ + deprecated: boolean; + /** For Google-internal migration only. Do not use. */ + weak: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export enum FieldOptions_CType { + /** STRING - Default mode. */ + STRING = 0, + CORD = 1, + STRING_PIECE = 2, + UNRECOGNIZED = -1, +} + +export function fieldOptions_CTypeFromJSON(object: any): FieldOptions_CType { + switch (object) { + case 0: + case "STRING": + return FieldOptions_CType.STRING; + case 1: + case "CORD": + return FieldOptions_CType.CORD; + case 2: + case "STRING_PIECE": + return FieldOptions_CType.STRING_PIECE; + case -1: + case "UNRECOGNIZED": + default: + return FieldOptions_CType.UNRECOGNIZED; + } +} + +export function fieldOptions_CTypeToJSON(object: FieldOptions_CType): string { + switch (object) { + case FieldOptions_CType.STRING: + return "STRING"; + case FieldOptions_CType.CORD: + return "CORD"; + case FieldOptions_CType.STRING_PIECE: + return "STRING_PIECE"; + default: + return "UNKNOWN"; + } +} + +export enum FieldOptions_JSType { + /** JS_NORMAL - Use the default type. */ + JS_NORMAL = 0, + /** JS_STRING - Use JavaScript strings. */ + JS_STRING = 1, + /** JS_NUMBER - Use JavaScript numbers. */ + JS_NUMBER = 2, + UNRECOGNIZED = -1, +} + +export function fieldOptions_JSTypeFromJSON(object: any): FieldOptions_JSType { + switch (object) { + case 0: + case "JS_NORMAL": + return FieldOptions_JSType.JS_NORMAL; + case 1: + case "JS_STRING": + return FieldOptions_JSType.JS_STRING; + case 2: + case "JS_NUMBER": + return FieldOptions_JSType.JS_NUMBER; + case -1: + case "UNRECOGNIZED": + default: + return FieldOptions_JSType.UNRECOGNIZED; + } +} + +export function fieldOptions_JSTypeToJSON(object: FieldOptions_JSType): string { + switch (object) { + case FieldOptions_JSType.JS_NORMAL: + return "JS_NORMAL"; + case FieldOptions_JSType.JS_STRING: + return "JS_STRING"; + case FieldOptions_JSType.JS_NUMBER: + return "JS_NUMBER"; + default: + return "UNKNOWN"; + } +} + +export interface OneofOptions { + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface EnumOptions { + /** + * Set this option to true to allow mapping different tag names to the same + * value. + */ + allowAlias: boolean; + /** + * Is this enum deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the enum, or it will be completely ignored; in the very least, this + * is a formalization for deprecating enums. + */ + deprecated: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface EnumValueOptions { + /** + * Is this enum value deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the enum value, or it will be completely ignored; in the very least, + * this is a formalization for deprecating enum values. + */ + deprecated: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface ServiceOptions { + /** + * Is this service deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the service, or it will be completely ignored; in the very least, + * this is a formalization for deprecating services. + */ + deprecated: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface MethodOptions { + /** + * Is this method deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the method, or it will be completely ignored; in the very least, + * this is a formalization for deprecating methods. + */ + deprecated: boolean; + idempotencyLevel: MethodOptions_IdempotencyLevel; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +/** + * Is this method side-effect-free (or safe in HTTP parlance), or idempotent, + * or neither? HTTP based RPC implementation may choose GET verb for safe + * methods, and PUT verb for idempotent methods instead of the default POST. + */ +export enum MethodOptions_IdempotencyLevel { + IDEMPOTENCY_UNKNOWN = 0, + /** NO_SIDE_EFFECTS - implies idempotent */ + NO_SIDE_EFFECTS = 1, + /** IDEMPOTENT - idempotent, but may have side effects */ + IDEMPOTENT = 2, + UNRECOGNIZED = -1, +} + +export function methodOptions_IdempotencyLevelFromJSON( + object: any +): MethodOptions_IdempotencyLevel { + switch (object) { + case 0: + case "IDEMPOTENCY_UNKNOWN": + return MethodOptions_IdempotencyLevel.IDEMPOTENCY_UNKNOWN; + case 1: + case "NO_SIDE_EFFECTS": + return MethodOptions_IdempotencyLevel.NO_SIDE_EFFECTS; + case 2: + case "IDEMPOTENT": + return MethodOptions_IdempotencyLevel.IDEMPOTENT; + case -1: + case "UNRECOGNIZED": + default: + return MethodOptions_IdempotencyLevel.UNRECOGNIZED; + } +} + +export function methodOptions_IdempotencyLevelToJSON( + object: MethodOptions_IdempotencyLevel +): string { + switch (object) { + case MethodOptions_IdempotencyLevel.IDEMPOTENCY_UNKNOWN: + return "IDEMPOTENCY_UNKNOWN"; + case MethodOptions_IdempotencyLevel.NO_SIDE_EFFECTS: + return "NO_SIDE_EFFECTS"; + case MethodOptions_IdempotencyLevel.IDEMPOTENT: + return "IDEMPOTENT"; + default: + return "UNKNOWN"; + } +} + +/** + * A message representing a option the parser does not recognize. This only + * appears in options protos created by the compiler::Parser class. + * DescriptorPool resolves these when building Descriptor objects. Therefore, + * options protos in descriptor objects (e.g. returned by Descriptor::options(), + * or produced by Descriptor::CopyTo()) will never have UninterpretedOptions + * in them. + */ +export interface UninterpretedOption { + name: UninterpretedOption_NamePart[]; + /** + * The value of the uninterpreted option, in whatever type the tokenizer + * identified it as during parsing. Exactly one of these should be set. + */ + identifierValue: string; + positiveIntValue: number; + negativeIntValue: number; + doubleValue: number; + stringValue: Uint8Array; + aggregateValue: string; +} + +/** + * The name of the uninterpreted option. Each string represents a segment in + * a dot-separated name. is_extension is true iff a segment represents an + * extension (denoted with parentheses in options specs in .proto files). + * E.g.,{ ["foo", false], ["bar.baz", true], ["qux", false] } represents + * "foo.(bar.baz).qux". + */ +export interface UninterpretedOption_NamePart { + namePart: string; + isExtension: boolean; +} + +/** + * Encapsulates information about the original source file from which a + * FileDescriptorProto was generated. + */ +export interface SourceCodeInfo { + /** + * A Location identifies a piece of source code in a .proto file which + * corresponds to a particular definition. This information is intended + * to be useful to IDEs, code indexers, documentation generators, and similar + * tools. + * + * For example, say we have a file like: + * message Foo { + * optional string foo = 1; + * } + * Let's look at just the field definition: + * optional string foo = 1; + * ^ ^^ ^^ ^ ^^^ + * a bc de f ghi + * We have the following locations: + * span path represents + * [a,i) [ 4, 0, 2, 0 ] The whole field definition. + * [a,b) [ 4, 0, 2, 0, 4 ] The label (optional). + * [c,d) [ 4, 0, 2, 0, 5 ] The type (string). + * [e,f) [ 4, 0, 2, 0, 1 ] The name (foo). + * [g,h) [ 4, 0, 2, 0, 3 ] The number (1). + * + * Notes: + * - A location may refer to a repeated field itself (i.e. not to any + * particular index within it). This is used whenever a set of elements are + * logically enclosed in a single code segment. For example, an entire + * extend block (possibly containing multiple extension definitions) will + * have an outer location whose path refers to the "extensions" repeated + * field without an index. + * - Multiple locations may have the same path. This happens when a single + * logical declaration is spread out across multiple places. The most + * obvious example is the "extend" block again -- there may be multiple + * extend blocks in the same scope, each of which will have the same path. + * - A location's span is not always a subset of its parent's span. For + * example, the "extendee" of an extension declaration appears at the + * beginning of the "extend" block and is shared by all extensions within + * the block. + * - Just because a location's span is a subset of some other location's span + * does not mean that it is a descendant. For example, a "group" defines + * both a type and a field in a single declaration. Thus, the locations + * corresponding to the type and field and their components will overlap. + * - Code which tries to interpret locations should probably be designed to + * ignore those that it doesn't understand, as more types of locations could + * be recorded in the future. + */ + location: SourceCodeInfo_Location[]; +} + +export interface SourceCodeInfo_Location { + /** + * Identifies which part of the FileDescriptorProto was defined at this + * location. + * + * Each element is a field number or an index. They form a path from + * the root FileDescriptorProto to the place where the definition. For + * example, this path: + * [ 4, 3, 2, 7, 1 ] + * refers to: + * file.message_type(3) // 4, 3 + * .field(7) // 2, 7 + * .name() // 1 + * This is because FileDescriptorProto.message_type has field number 4: + * repeated DescriptorProto message_type = 4; + * and DescriptorProto.field has field number 2: + * repeated FieldDescriptorProto field = 2; + * and FieldDescriptorProto.name has field number 1: + * optional string name = 1; + * + * Thus, the above path gives the location of a field name. If we removed + * the last element: + * [ 4, 3, 2, 7 ] + * this path refers to the whole field declaration (from the beginning + * of the label to the terminating semicolon). + */ + path: number[]; + /** + * Always has exactly three or four elements: start line, start column, + * end line (optional, otherwise assumed same as start line), end column. + * These are packed into a single field for efficiency. Note that line + * and column numbers are zero-based -- typically you will want to add + * 1 to each before displaying to a user. + */ + span: number[]; + /** + * If this SourceCodeInfo represents a complete declaration, these are any + * comments appearing before and after the declaration which appear to be + * attached to the declaration. + * + * A series of line comments appearing on consecutive lines, with no other + * tokens appearing on those lines, will be treated as a single comment. + * + * leading_detached_comments will keep paragraphs of comments that appear + * before (but not connected to) the current element. Each paragraph, + * separated by empty lines, will be one comment element in the repeated + * field. + * + * Only the comment content is provided; comment markers (e.g. //) are + * stripped out. For block comments, leading whitespace and an asterisk + * will be stripped from the beginning of each line other than the first. + * Newlines are included in the output. + * + * Examples: + * + * optional int32 foo = 1; // Comment attached to foo. + * // Comment attached to bar. + * optional int32 bar = 2; + * + * optional string baz = 3; + * // Comment attached to baz. + * // Another line attached to baz. + * + * // Comment attached to qux. + * // + * // Another line attached to qux. + * optional double qux = 4; + * + * // Detached comment for corge. This is not leading or trailing comments + * // to qux or corge because there are blank lines separating it from + * // both. + * + * // Detached comment for corge paragraph 2. + * + * optional string corge = 5; + * /* Block comment attached + * * to corge. Leading asterisks + * * will be removed. * / + * /* Block comment attached to + * * grault. * / + * optional int32 grault = 6; + * + * // ignored detached comments. + */ + leadingComments: string; + trailingComments: string; + leadingDetachedComments: string[]; +} + +/** + * Describes the relationship between generated code and its original source + * file. A GeneratedCodeInfo message is associated with only one generated + * source file, but may contain references to different source .proto files. + */ +export interface GeneratedCodeInfo { + /** + * An Annotation connects some span of text in generated code to an element + * of its generating .proto file. + */ + annotation: GeneratedCodeInfo_Annotation[]; +} + +export interface GeneratedCodeInfo_Annotation { + /** + * Identifies the element in the original source .proto file. This field + * is formatted the same as SourceCodeInfo.Location.path. + */ + path: number[]; + /** Identifies the filesystem path to the original source .proto. */ + sourceFile: string; + /** + * Identifies the starting offset in bytes in the generated code + * that relates to the identified object. + */ + begin: number; + /** + * Identifies the ending offset in bytes in the generated code that + * relates to the identified offset. The end offset should be one past + * the last relevant byte (so the length of the text = end - begin). + */ + end: number; +} + +const baseFileDescriptorSet: object = {}; + +export const FileDescriptorSet = { + encode(message: FileDescriptorSet, writer: Writer = Writer.create()): Writer { + for (const v of message.file) { + FileDescriptorProto.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FileDescriptorSet { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFileDescriptorSet } as FileDescriptorSet; + message.file = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.file.push( + FileDescriptorProto.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FileDescriptorSet { + const message = { ...baseFileDescriptorSet } as FileDescriptorSet; + message.file = []; + if (object.file !== undefined && object.file !== null) { + for (const e of object.file) { + message.file.push(FileDescriptorProto.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: FileDescriptorSet): unknown { + const obj: any = {}; + if (message.file) { + obj.file = message.file.map((e) => + e ? FileDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.file = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): FileDescriptorSet { + const message = { ...baseFileDescriptorSet } as FileDescriptorSet; + message.file = []; + if (object.file !== undefined && object.file !== null) { + for (const e of object.file) { + message.file.push(FileDescriptorProto.fromPartial(e)); + } + } + return message; + }, +}; + +const baseFileDescriptorProto: object = { + name: "", + package: "", + dependency: "", + publicDependency: 0, + weakDependency: 0, + syntax: "", +}; + +export const FileDescriptorProto = { + encode( + message: FileDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.package !== "") { + writer.uint32(18).string(message.package); + } + for (const v of message.dependency) { + writer.uint32(26).string(v!); + } + writer.uint32(82).fork(); + for (const v of message.publicDependency) { + writer.int32(v); + } + writer.ldelim(); + writer.uint32(90).fork(); + for (const v of message.weakDependency) { + writer.int32(v); + } + writer.ldelim(); + for (const v of message.messageType) { + DescriptorProto.encode(v!, writer.uint32(34).fork()).ldelim(); + } + for (const v of message.enumType) { + EnumDescriptorProto.encode(v!, writer.uint32(42).fork()).ldelim(); + } + for (const v of message.service) { + ServiceDescriptorProto.encode(v!, writer.uint32(50).fork()).ldelim(); + } + for (const v of message.extension) { + FieldDescriptorProto.encode(v!, writer.uint32(58).fork()).ldelim(); + } + if (message.options !== undefined) { + FileOptions.encode(message.options, writer.uint32(66).fork()).ldelim(); + } + if (message.sourceCodeInfo !== undefined) { + SourceCodeInfo.encode( + message.sourceCodeInfo, + writer.uint32(74).fork() + ).ldelim(); + } + if (message.syntax !== "") { + writer.uint32(98).string(message.syntax); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FileDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFileDescriptorProto } as FileDescriptorProto; + message.dependency = []; + message.publicDependency = []; + message.weakDependency = []; + message.messageType = []; + message.enumType = []; + message.service = []; + message.extension = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.package = reader.string(); + break; + case 3: + message.dependency.push(reader.string()); + break; + case 10: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.publicDependency.push(reader.int32()); + } + } else { + message.publicDependency.push(reader.int32()); + } + break; + case 11: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.weakDependency.push(reader.int32()); + } + } else { + message.weakDependency.push(reader.int32()); + } + break; + case 4: + message.messageType.push( + DescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 5: + message.enumType.push( + EnumDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 6: + message.service.push( + ServiceDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 7: + message.extension.push( + FieldDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 8: + message.options = FileOptions.decode(reader, reader.uint32()); + break; + case 9: + message.sourceCodeInfo = SourceCodeInfo.decode( + reader, + reader.uint32() + ); + break; + case 12: + message.syntax = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FileDescriptorProto { + const message = { ...baseFileDescriptorProto } as FileDescriptorProto; + message.dependency = []; + message.publicDependency = []; + message.weakDependency = []; + message.messageType = []; + message.enumType = []; + message.service = []; + message.extension = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.package !== undefined && object.package !== null) { + message.package = String(object.package); + } else { + message.package = ""; + } + if (object.dependency !== undefined && object.dependency !== null) { + for (const e of object.dependency) { + message.dependency.push(String(e)); + } + } + if ( + object.publicDependency !== undefined && + object.publicDependency !== null + ) { + for (const e of object.publicDependency) { + message.publicDependency.push(Number(e)); + } + } + if (object.weakDependency !== undefined && object.weakDependency !== null) { + for (const e of object.weakDependency) { + message.weakDependency.push(Number(e)); + } + } + if (object.messageType !== undefined && object.messageType !== null) { + for (const e of object.messageType) { + message.messageType.push(DescriptorProto.fromJSON(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromJSON(e)); + } + } + if (object.service !== undefined && object.service !== null) { + for (const e of object.service) { + message.service.push(ServiceDescriptorProto.fromJSON(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = FileOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.sourceCodeInfo !== undefined && object.sourceCodeInfo !== null) { + message.sourceCodeInfo = SourceCodeInfo.fromJSON(object.sourceCodeInfo); + } else { + message.sourceCodeInfo = undefined; + } + if (object.syntax !== undefined && object.syntax !== null) { + message.syntax = String(object.syntax); + } else { + message.syntax = ""; + } + return message; + }, + + toJSON(message: FileDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.package !== undefined && (obj.package = message.package); + if (message.dependency) { + obj.dependency = message.dependency.map((e) => e); + } else { + obj.dependency = []; + } + if (message.publicDependency) { + obj.publicDependency = message.publicDependency.map((e) => e); + } else { + obj.publicDependency = []; + } + if (message.weakDependency) { + obj.weakDependency = message.weakDependency.map((e) => e); + } else { + obj.weakDependency = []; + } + if (message.messageType) { + obj.messageType = message.messageType.map((e) => + e ? DescriptorProto.toJSON(e) : undefined + ); + } else { + obj.messageType = []; + } + if (message.enumType) { + obj.enumType = message.enumType.map((e) => + e ? EnumDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.enumType = []; + } + if (message.service) { + obj.service = message.service.map((e) => + e ? ServiceDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.service = []; + } + if (message.extension) { + obj.extension = message.extension.map((e) => + e ? FieldDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.extension = []; + } + message.options !== undefined && + (obj.options = message.options + ? FileOptions.toJSON(message.options) + : undefined); + message.sourceCodeInfo !== undefined && + (obj.sourceCodeInfo = message.sourceCodeInfo + ? SourceCodeInfo.toJSON(message.sourceCodeInfo) + : undefined); + message.syntax !== undefined && (obj.syntax = message.syntax); + return obj; + }, + + fromPartial(object: DeepPartial): FileDescriptorProto { + const message = { ...baseFileDescriptorProto } as FileDescriptorProto; + message.dependency = []; + message.publicDependency = []; + message.weakDependency = []; + message.messageType = []; + message.enumType = []; + message.service = []; + message.extension = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.package !== undefined && object.package !== null) { + message.package = object.package; + } else { + message.package = ""; + } + if (object.dependency !== undefined && object.dependency !== null) { + for (const e of object.dependency) { + message.dependency.push(e); + } + } + if ( + object.publicDependency !== undefined && + object.publicDependency !== null + ) { + for (const e of object.publicDependency) { + message.publicDependency.push(e); + } + } + if (object.weakDependency !== undefined && object.weakDependency !== null) { + for (const e of object.weakDependency) { + message.weakDependency.push(e); + } + } + if (object.messageType !== undefined && object.messageType !== null) { + for (const e of object.messageType) { + message.messageType.push(DescriptorProto.fromPartial(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromPartial(e)); + } + } + if (object.service !== undefined && object.service !== null) { + for (const e of object.service) { + message.service.push(ServiceDescriptorProto.fromPartial(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = FileOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.sourceCodeInfo !== undefined && object.sourceCodeInfo !== null) { + message.sourceCodeInfo = SourceCodeInfo.fromPartial( + object.sourceCodeInfo + ); + } else { + message.sourceCodeInfo = undefined; + } + if (object.syntax !== undefined && object.syntax !== null) { + message.syntax = object.syntax; + } else { + message.syntax = ""; + } + return message; + }, +}; + +const baseDescriptorProto: object = { name: "", reservedName: "" }; + +export const DescriptorProto = { + encode(message: DescriptorProto, writer: Writer = Writer.create()): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + for (const v of message.field) { + FieldDescriptorProto.encode(v!, writer.uint32(18).fork()).ldelim(); + } + for (const v of message.extension) { + FieldDescriptorProto.encode(v!, writer.uint32(50).fork()).ldelim(); + } + for (const v of message.nestedType) { + DescriptorProto.encode(v!, writer.uint32(26).fork()).ldelim(); + } + for (const v of message.enumType) { + EnumDescriptorProto.encode(v!, writer.uint32(34).fork()).ldelim(); + } + for (const v of message.extensionRange) { + DescriptorProto_ExtensionRange.encode( + v!, + writer.uint32(42).fork() + ).ldelim(); + } + for (const v of message.oneofDecl) { + OneofDescriptorProto.encode(v!, writer.uint32(66).fork()).ldelim(); + } + if (message.options !== undefined) { + MessageOptions.encode(message.options, writer.uint32(58).fork()).ldelim(); + } + for (const v of message.reservedRange) { + DescriptorProto_ReservedRange.encode( + v!, + writer.uint32(74).fork() + ).ldelim(); + } + for (const v of message.reservedName) { + writer.uint32(82).string(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): DescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseDescriptorProto } as DescriptorProto; + message.field = []; + message.extension = []; + message.nestedType = []; + message.enumType = []; + message.extensionRange = []; + message.oneofDecl = []; + message.reservedRange = []; + message.reservedName = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.field.push( + FieldDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 6: + message.extension.push( + FieldDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 3: + message.nestedType.push( + DescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 4: + message.enumType.push( + EnumDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 5: + message.extensionRange.push( + DescriptorProto_ExtensionRange.decode(reader, reader.uint32()) + ); + break; + case 8: + message.oneofDecl.push( + OneofDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 7: + message.options = MessageOptions.decode(reader, reader.uint32()); + break; + case 9: + message.reservedRange.push( + DescriptorProto_ReservedRange.decode(reader, reader.uint32()) + ); + break; + case 10: + message.reservedName.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DescriptorProto { + const message = { ...baseDescriptorProto } as DescriptorProto; + message.field = []; + message.extension = []; + message.nestedType = []; + message.enumType = []; + message.extensionRange = []; + message.oneofDecl = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.field !== undefined && object.field !== null) { + for (const e of object.field) { + message.field.push(FieldDescriptorProto.fromJSON(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromJSON(e)); + } + } + if (object.nestedType !== undefined && object.nestedType !== null) { + for (const e of object.nestedType) { + message.nestedType.push(DescriptorProto.fromJSON(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromJSON(e)); + } + } + if (object.extensionRange !== undefined && object.extensionRange !== null) { + for (const e of object.extensionRange) { + message.extensionRange.push(DescriptorProto_ExtensionRange.fromJSON(e)); + } + } + if (object.oneofDecl !== undefined && object.oneofDecl !== null) { + for (const e of object.oneofDecl) { + message.oneofDecl.push(OneofDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = MessageOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push(DescriptorProto_ReservedRange.fromJSON(e)); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(String(e)); + } + } + return message; + }, + + toJSON(message: DescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + if (message.field) { + obj.field = message.field.map((e) => + e ? FieldDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.field = []; + } + if (message.extension) { + obj.extension = message.extension.map((e) => + e ? FieldDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.extension = []; + } + if (message.nestedType) { + obj.nestedType = message.nestedType.map((e) => + e ? DescriptorProto.toJSON(e) : undefined + ); + } else { + obj.nestedType = []; + } + if (message.enumType) { + obj.enumType = message.enumType.map((e) => + e ? EnumDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.enumType = []; + } + if (message.extensionRange) { + obj.extensionRange = message.extensionRange.map((e) => + e ? DescriptorProto_ExtensionRange.toJSON(e) : undefined + ); + } else { + obj.extensionRange = []; + } + if (message.oneofDecl) { + obj.oneofDecl = message.oneofDecl.map((e) => + e ? OneofDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.oneofDecl = []; + } + message.options !== undefined && + (obj.options = message.options + ? MessageOptions.toJSON(message.options) + : undefined); + if (message.reservedRange) { + obj.reservedRange = message.reservedRange.map((e) => + e ? DescriptorProto_ReservedRange.toJSON(e) : undefined + ); + } else { + obj.reservedRange = []; + } + if (message.reservedName) { + obj.reservedName = message.reservedName.map((e) => e); + } else { + obj.reservedName = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): DescriptorProto { + const message = { ...baseDescriptorProto } as DescriptorProto; + message.field = []; + message.extension = []; + message.nestedType = []; + message.enumType = []; + message.extensionRange = []; + message.oneofDecl = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.field !== undefined && object.field !== null) { + for (const e of object.field) { + message.field.push(FieldDescriptorProto.fromPartial(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromPartial(e)); + } + } + if (object.nestedType !== undefined && object.nestedType !== null) { + for (const e of object.nestedType) { + message.nestedType.push(DescriptorProto.fromPartial(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromPartial(e)); + } + } + if (object.extensionRange !== undefined && object.extensionRange !== null) { + for (const e of object.extensionRange) { + message.extensionRange.push( + DescriptorProto_ExtensionRange.fromPartial(e) + ); + } + } + if (object.oneofDecl !== undefined && object.oneofDecl !== null) { + for (const e of object.oneofDecl) { + message.oneofDecl.push(OneofDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = MessageOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push( + DescriptorProto_ReservedRange.fromPartial(e) + ); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(e); + } + } + return message; + }, +}; + +const baseDescriptorProto_ExtensionRange: object = { start: 0, end: 0 }; + +export const DescriptorProto_ExtensionRange = { + encode( + message: DescriptorProto_ExtensionRange, + writer: Writer = Writer.create() + ): Writer { + if (message.start !== 0) { + writer.uint32(8).int32(message.start); + } + if (message.end !== 0) { + writer.uint32(16).int32(message.end); + } + if (message.options !== undefined) { + ExtensionRangeOptions.encode( + message.options, + writer.uint32(26).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): DescriptorProto_ExtensionRange { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseDescriptorProto_ExtensionRange, + } as DescriptorProto_ExtensionRange; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.start = reader.int32(); + break; + case 2: + message.end = reader.int32(); + break; + case 3: + message.options = ExtensionRangeOptions.decode( + reader, + reader.uint32() + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DescriptorProto_ExtensionRange { + const message = { + ...baseDescriptorProto_ExtensionRange, + } as DescriptorProto_ExtensionRange; + if (object.start !== undefined && object.start !== null) { + message.start = Number(object.start); + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = ExtensionRangeOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: DescriptorProto_ExtensionRange): unknown { + const obj: any = {}; + message.start !== undefined && (obj.start = message.start); + message.end !== undefined && (obj.end = message.end); + message.options !== undefined && + (obj.options = message.options + ? ExtensionRangeOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): DescriptorProto_ExtensionRange { + const message = { + ...baseDescriptorProto_ExtensionRange, + } as DescriptorProto_ExtensionRange; + if (object.start !== undefined && object.start !== null) { + message.start = object.start; + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = ExtensionRangeOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseDescriptorProto_ReservedRange: object = { start: 0, end: 0 }; + +export const DescriptorProto_ReservedRange = { + encode( + message: DescriptorProto_ReservedRange, + writer: Writer = Writer.create() + ): Writer { + if (message.start !== 0) { + writer.uint32(8).int32(message.start); + } + if (message.end !== 0) { + writer.uint32(16).int32(message.end); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): DescriptorProto_ReservedRange { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseDescriptorProto_ReservedRange, + } as DescriptorProto_ReservedRange; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.start = reader.int32(); + break; + case 2: + message.end = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DescriptorProto_ReservedRange { + const message = { + ...baseDescriptorProto_ReservedRange, + } as DescriptorProto_ReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = Number(object.start); + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + return message; + }, + + toJSON(message: DescriptorProto_ReservedRange): unknown { + const obj: any = {}; + message.start !== undefined && (obj.start = message.start); + message.end !== undefined && (obj.end = message.end); + return obj; + }, + + fromPartial( + object: DeepPartial + ): DescriptorProto_ReservedRange { + const message = { + ...baseDescriptorProto_ReservedRange, + } as DescriptorProto_ReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = object.start; + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + return message; + }, +}; + +const baseExtensionRangeOptions: object = {}; + +export const ExtensionRangeOptions = { + encode( + message: ExtensionRangeOptions, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ExtensionRangeOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseExtensionRangeOptions } as ExtensionRangeOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ExtensionRangeOptions { + const message = { ...baseExtensionRangeOptions } as ExtensionRangeOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: ExtensionRangeOptions): unknown { + const obj: any = {}; + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial( + object: DeepPartial + ): ExtensionRangeOptions { + const message = { ...baseExtensionRangeOptions } as ExtensionRangeOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseFieldDescriptorProto: object = { + name: "", + number: 0, + label: 1, + type: 1, + typeName: "", + extendee: "", + defaultValue: "", + oneofIndex: 0, + jsonName: "", + proto3Optional: false, +}; + +export const FieldDescriptorProto = { + encode( + message: FieldDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.number !== 0) { + writer.uint32(24).int32(message.number); + } + if (message.label !== 1) { + writer.uint32(32).int32(message.label); + } + if (message.type !== 1) { + writer.uint32(40).int32(message.type); + } + if (message.typeName !== "") { + writer.uint32(50).string(message.typeName); + } + if (message.extendee !== "") { + writer.uint32(18).string(message.extendee); + } + if (message.defaultValue !== "") { + writer.uint32(58).string(message.defaultValue); + } + if (message.oneofIndex !== 0) { + writer.uint32(72).int32(message.oneofIndex); + } + if (message.jsonName !== "") { + writer.uint32(82).string(message.jsonName); + } + if (message.options !== undefined) { + FieldOptions.encode(message.options, writer.uint32(66).fork()).ldelim(); + } + if (message.proto3Optional === true) { + writer.uint32(136).bool(message.proto3Optional); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FieldDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFieldDescriptorProto } as FieldDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 3: + message.number = reader.int32(); + break; + case 4: + message.label = reader.int32() as any; + break; + case 5: + message.type = reader.int32() as any; + break; + case 6: + message.typeName = reader.string(); + break; + case 2: + message.extendee = reader.string(); + break; + case 7: + message.defaultValue = reader.string(); + break; + case 9: + message.oneofIndex = reader.int32(); + break; + case 10: + message.jsonName = reader.string(); + break; + case 8: + message.options = FieldOptions.decode(reader, reader.uint32()); + break; + case 17: + message.proto3Optional = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FieldDescriptorProto { + const message = { ...baseFieldDescriptorProto } as FieldDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = Number(object.number); + } else { + message.number = 0; + } + if (object.label !== undefined && object.label !== null) { + message.label = fieldDescriptorProto_LabelFromJSON(object.label); + } else { + message.label = 1; + } + if (object.type !== undefined && object.type !== null) { + message.type = fieldDescriptorProto_TypeFromJSON(object.type); + } else { + message.type = 1; + } + if (object.typeName !== undefined && object.typeName !== null) { + message.typeName = String(object.typeName); + } else { + message.typeName = ""; + } + if (object.extendee !== undefined && object.extendee !== null) { + message.extendee = String(object.extendee); + } else { + message.extendee = ""; + } + if (object.defaultValue !== undefined && object.defaultValue !== null) { + message.defaultValue = String(object.defaultValue); + } else { + message.defaultValue = ""; + } + if (object.oneofIndex !== undefined && object.oneofIndex !== null) { + message.oneofIndex = Number(object.oneofIndex); + } else { + message.oneofIndex = 0; + } + if (object.jsonName !== undefined && object.jsonName !== null) { + message.jsonName = String(object.jsonName); + } else { + message.jsonName = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = FieldOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.proto3Optional !== undefined && object.proto3Optional !== null) { + message.proto3Optional = Boolean(object.proto3Optional); + } else { + message.proto3Optional = false; + } + return message; + }, + + toJSON(message: FieldDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.number !== undefined && (obj.number = message.number); + message.label !== undefined && + (obj.label = fieldDescriptorProto_LabelToJSON(message.label)); + message.type !== undefined && + (obj.type = fieldDescriptorProto_TypeToJSON(message.type)); + message.typeName !== undefined && (obj.typeName = message.typeName); + message.extendee !== undefined && (obj.extendee = message.extendee); + message.defaultValue !== undefined && + (obj.defaultValue = message.defaultValue); + message.oneofIndex !== undefined && (obj.oneofIndex = message.oneofIndex); + message.jsonName !== undefined && (obj.jsonName = message.jsonName); + message.options !== undefined && + (obj.options = message.options + ? FieldOptions.toJSON(message.options) + : undefined); + message.proto3Optional !== undefined && + (obj.proto3Optional = message.proto3Optional); + return obj; + }, + + fromPartial(object: DeepPartial): FieldDescriptorProto { + const message = { ...baseFieldDescriptorProto } as FieldDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = object.number; + } else { + message.number = 0; + } + if (object.label !== undefined && object.label !== null) { + message.label = object.label; + } else { + message.label = 1; + } + if (object.type !== undefined && object.type !== null) { + message.type = object.type; + } else { + message.type = 1; + } + if (object.typeName !== undefined && object.typeName !== null) { + message.typeName = object.typeName; + } else { + message.typeName = ""; + } + if (object.extendee !== undefined && object.extendee !== null) { + message.extendee = object.extendee; + } else { + message.extendee = ""; + } + if (object.defaultValue !== undefined && object.defaultValue !== null) { + message.defaultValue = object.defaultValue; + } else { + message.defaultValue = ""; + } + if (object.oneofIndex !== undefined && object.oneofIndex !== null) { + message.oneofIndex = object.oneofIndex; + } else { + message.oneofIndex = 0; + } + if (object.jsonName !== undefined && object.jsonName !== null) { + message.jsonName = object.jsonName; + } else { + message.jsonName = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = FieldOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.proto3Optional !== undefined && object.proto3Optional !== null) { + message.proto3Optional = object.proto3Optional; + } else { + message.proto3Optional = false; + } + return message; + }, +}; + +const baseOneofDescriptorProto: object = { name: "" }; + +export const OneofDescriptorProto = { + encode( + message: OneofDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.options !== undefined) { + OneofOptions.encode(message.options, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): OneofDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseOneofDescriptorProto } as OneofDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.options = OneofOptions.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): OneofDescriptorProto { + const message = { ...baseOneofDescriptorProto } as OneofDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = OneofOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: OneofDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.options !== undefined && + (obj.options = message.options + ? OneofOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): OneofDescriptorProto { + const message = { ...baseOneofDescriptorProto } as OneofDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = OneofOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseEnumDescriptorProto: object = { name: "", reservedName: "" }; + +export const EnumDescriptorProto = { + encode( + message: EnumDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + for (const v of message.value) { + EnumValueDescriptorProto.encode(v!, writer.uint32(18).fork()).ldelim(); + } + if (message.options !== undefined) { + EnumOptions.encode(message.options, writer.uint32(26).fork()).ldelim(); + } + for (const v of message.reservedRange) { + EnumDescriptorProto_EnumReservedRange.encode( + v!, + writer.uint32(34).fork() + ).ldelim(); + } + for (const v of message.reservedName) { + writer.uint32(42).string(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): EnumDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseEnumDescriptorProto } as EnumDescriptorProto; + message.value = []; + message.reservedRange = []; + message.reservedName = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.value.push( + EnumValueDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 3: + message.options = EnumOptions.decode(reader, reader.uint32()); + break; + case 4: + message.reservedRange.push( + EnumDescriptorProto_EnumReservedRange.decode( + reader, + reader.uint32() + ) + ); + break; + case 5: + message.reservedName.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumDescriptorProto { + const message = { ...baseEnumDescriptorProto } as EnumDescriptorProto; + message.value = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.value !== undefined && object.value !== null) { + for (const e of object.value) { + message.value.push(EnumValueDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push( + EnumDescriptorProto_EnumReservedRange.fromJSON(e) + ); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(String(e)); + } + } + return message; + }, + + toJSON(message: EnumDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + if (message.value) { + obj.value = message.value.map((e) => + e ? EnumValueDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.value = []; + } + message.options !== undefined && + (obj.options = message.options + ? EnumOptions.toJSON(message.options) + : undefined); + if (message.reservedRange) { + obj.reservedRange = message.reservedRange.map((e) => + e ? EnumDescriptorProto_EnumReservedRange.toJSON(e) : undefined + ); + } else { + obj.reservedRange = []; + } + if (message.reservedName) { + obj.reservedName = message.reservedName.map((e) => e); + } else { + obj.reservedName = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): EnumDescriptorProto { + const message = { ...baseEnumDescriptorProto } as EnumDescriptorProto; + message.value = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.value !== undefined && object.value !== null) { + for (const e of object.value) { + message.value.push(EnumValueDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push( + EnumDescriptorProto_EnumReservedRange.fromPartial(e) + ); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(e); + } + } + return message; + }, +}; + +const baseEnumDescriptorProto_EnumReservedRange: object = { start: 0, end: 0 }; + +export const EnumDescriptorProto_EnumReservedRange = { + encode( + message: EnumDescriptorProto_EnumReservedRange, + writer: Writer = Writer.create() + ): Writer { + if (message.start !== 0) { + writer.uint32(8).int32(message.start); + } + if (message.end !== 0) { + writer.uint32(16).int32(message.end); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): EnumDescriptorProto_EnumReservedRange { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseEnumDescriptorProto_EnumReservedRange, + } as EnumDescriptorProto_EnumReservedRange; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.start = reader.int32(); + break; + case 2: + message.end = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumDescriptorProto_EnumReservedRange { + const message = { + ...baseEnumDescriptorProto_EnumReservedRange, + } as EnumDescriptorProto_EnumReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = Number(object.start); + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + return message; + }, + + toJSON(message: EnumDescriptorProto_EnumReservedRange): unknown { + const obj: any = {}; + message.start !== undefined && (obj.start = message.start); + message.end !== undefined && (obj.end = message.end); + return obj; + }, + + fromPartial( + object: DeepPartial + ): EnumDescriptorProto_EnumReservedRange { + const message = { + ...baseEnumDescriptorProto_EnumReservedRange, + } as EnumDescriptorProto_EnumReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = object.start; + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + return message; + }, +}; + +const baseEnumValueDescriptorProto: object = { name: "", number: 0 }; + +export const EnumValueDescriptorProto = { + encode( + message: EnumValueDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.number !== 0) { + writer.uint32(16).int32(message.number); + } + if (message.options !== undefined) { + EnumValueOptions.encode( + message.options, + writer.uint32(26).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): EnumValueDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseEnumValueDescriptorProto, + } as EnumValueDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.number = reader.int32(); + break; + case 3: + message.options = EnumValueOptions.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumValueDescriptorProto { + const message = { + ...baseEnumValueDescriptorProto, + } as EnumValueDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = Number(object.number); + } else { + message.number = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumValueOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: EnumValueDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.number !== undefined && (obj.number = message.number); + message.options !== undefined && + (obj.options = message.options + ? EnumValueOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): EnumValueDescriptorProto { + const message = { + ...baseEnumValueDescriptorProto, + } as EnumValueDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = object.number; + } else { + message.number = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumValueOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseServiceDescriptorProto: object = { name: "" }; + +export const ServiceDescriptorProto = { + encode( + message: ServiceDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + for (const v of message.method) { + MethodDescriptorProto.encode(v!, writer.uint32(18).fork()).ldelim(); + } + if (message.options !== undefined) { + ServiceOptions.encode(message.options, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ServiceDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseServiceDescriptorProto } as ServiceDescriptorProto; + message.method = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.method.push( + MethodDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 3: + message.options = ServiceOptions.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ServiceDescriptorProto { + const message = { ...baseServiceDescriptorProto } as ServiceDescriptorProto; + message.method = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.method !== undefined && object.method !== null) { + for (const e of object.method) { + message.method.push(MethodDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = ServiceOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: ServiceDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + if (message.method) { + obj.method = message.method.map((e) => + e ? MethodDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.method = []; + } + message.options !== undefined && + (obj.options = message.options + ? ServiceOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): ServiceDescriptorProto { + const message = { ...baseServiceDescriptorProto } as ServiceDescriptorProto; + message.method = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.method !== undefined && object.method !== null) { + for (const e of object.method) { + message.method.push(MethodDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = ServiceOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseMethodDescriptorProto: object = { + name: "", + inputType: "", + outputType: "", + clientStreaming: false, + serverStreaming: false, +}; + +export const MethodDescriptorProto = { + encode( + message: MethodDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.inputType !== "") { + writer.uint32(18).string(message.inputType); + } + if (message.outputType !== "") { + writer.uint32(26).string(message.outputType); + } + if (message.options !== undefined) { + MethodOptions.encode(message.options, writer.uint32(34).fork()).ldelim(); + } + if (message.clientStreaming === true) { + writer.uint32(40).bool(message.clientStreaming); + } + if (message.serverStreaming === true) { + writer.uint32(48).bool(message.serverStreaming); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MethodDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMethodDescriptorProto } as MethodDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.inputType = reader.string(); + break; + case 3: + message.outputType = reader.string(); + break; + case 4: + message.options = MethodOptions.decode(reader, reader.uint32()); + break; + case 5: + message.clientStreaming = reader.bool(); + break; + case 6: + message.serverStreaming = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MethodDescriptorProto { + const message = { ...baseMethodDescriptorProto } as MethodDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.inputType !== undefined && object.inputType !== null) { + message.inputType = String(object.inputType); + } else { + message.inputType = ""; + } + if (object.outputType !== undefined && object.outputType !== null) { + message.outputType = String(object.outputType); + } else { + message.outputType = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = MethodOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if ( + object.clientStreaming !== undefined && + object.clientStreaming !== null + ) { + message.clientStreaming = Boolean(object.clientStreaming); + } else { + message.clientStreaming = false; + } + if ( + object.serverStreaming !== undefined && + object.serverStreaming !== null + ) { + message.serverStreaming = Boolean(object.serverStreaming); + } else { + message.serverStreaming = false; + } + return message; + }, + + toJSON(message: MethodDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.inputType !== undefined && (obj.inputType = message.inputType); + message.outputType !== undefined && (obj.outputType = message.outputType); + message.options !== undefined && + (obj.options = message.options + ? MethodOptions.toJSON(message.options) + : undefined); + message.clientStreaming !== undefined && + (obj.clientStreaming = message.clientStreaming); + message.serverStreaming !== undefined && + (obj.serverStreaming = message.serverStreaming); + return obj; + }, + + fromPartial( + object: DeepPartial + ): MethodDescriptorProto { + const message = { ...baseMethodDescriptorProto } as MethodDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.inputType !== undefined && object.inputType !== null) { + message.inputType = object.inputType; + } else { + message.inputType = ""; + } + if (object.outputType !== undefined && object.outputType !== null) { + message.outputType = object.outputType; + } else { + message.outputType = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = MethodOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if ( + object.clientStreaming !== undefined && + object.clientStreaming !== null + ) { + message.clientStreaming = object.clientStreaming; + } else { + message.clientStreaming = false; + } + if ( + object.serverStreaming !== undefined && + object.serverStreaming !== null + ) { + message.serverStreaming = object.serverStreaming; + } else { + message.serverStreaming = false; + } + return message; + }, +}; + +const baseFileOptions: object = { + javaPackage: "", + javaOuterClassname: "", + javaMultipleFiles: false, + javaGenerateEqualsAndHash: false, + javaStringCheckUtf8: false, + optimizeFor: 1, + goPackage: "", + ccGenericServices: false, + javaGenericServices: false, + pyGenericServices: false, + phpGenericServices: false, + deprecated: false, + ccEnableArenas: false, + objcClassPrefix: "", + csharpNamespace: "", + swiftPrefix: "", + phpClassPrefix: "", + phpNamespace: "", + phpMetadataNamespace: "", + rubyPackage: "", +}; + +export const FileOptions = { + encode(message: FileOptions, writer: Writer = Writer.create()): Writer { + if (message.javaPackage !== "") { + writer.uint32(10).string(message.javaPackage); + } + if (message.javaOuterClassname !== "") { + writer.uint32(66).string(message.javaOuterClassname); + } + if (message.javaMultipleFiles === true) { + writer.uint32(80).bool(message.javaMultipleFiles); + } + if (message.javaGenerateEqualsAndHash === true) { + writer.uint32(160).bool(message.javaGenerateEqualsAndHash); + } + if (message.javaStringCheckUtf8 === true) { + writer.uint32(216).bool(message.javaStringCheckUtf8); + } + if (message.optimizeFor !== 1) { + writer.uint32(72).int32(message.optimizeFor); + } + if (message.goPackage !== "") { + writer.uint32(90).string(message.goPackage); + } + if (message.ccGenericServices === true) { + writer.uint32(128).bool(message.ccGenericServices); + } + if (message.javaGenericServices === true) { + writer.uint32(136).bool(message.javaGenericServices); + } + if (message.pyGenericServices === true) { + writer.uint32(144).bool(message.pyGenericServices); + } + if (message.phpGenericServices === true) { + writer.uint32(336).bool(message.phpGenericServices); + } + if (message.deprecated === true) { + writer.uint32(184).bool(message.deprecated); + } + if (message.ccEnableArenas === true) { + writer.uint32(248).bool(message.ccEnableArenas); + } + if (message.objcClassPrefix !== "") { + writer.uint32(290).string(message.objcClassPrefix); + } + if (message.csharpNamespace !== "") { + writer.uint32(298).string(message.csharpNamespace); + } + if (message.swiftPrefix !== "") { + writer.uint32(314).string(message.swiftPrefix); + } + if (message.phpClassPrefix !== "") { + writer.uint32(322).string(message.phpClassPrefix); + } + if (message.phpNamespace !== "") { + writer.uint32(330).string(message.phpNamespace); + } + if (message.phpMetadataNamespace !== "") { + writer.uint32(354).string(message.phpMetadataNamespace); + } + if (message.rubyPackage !== "") { + writer.uint32(362).string(message.rubyPackage); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FileOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFileOptions } as FileOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.javaPackage = reader.string(); + break; + case 8: + message.javaOuterClassname = reader.string(); + break; + case 10: + message.javaMultipleFiles = reader.bool(); + break; + case 20: + message.javaGenerateEqualsAndHash = reader.bool(); + break; + case 27: + message.javaStringCheckUtf8 = reader.bool(); + break; + case 9: + message.optimizeFor = reader.int32() as any; + break; + case 11: + message.goPackage = reader.string(); + break; + case 16: + message.ccGenericServices = reader.bool(); + break; + case 17: + message.javaGenericServices = reader.bool(); + break; + case 18: + message.pyGenericServices = reader.bool(); + break; + case 42: + message.phpGenericServices = reader.bool(); + break; + case 23: + message.deprecated = reader.bool(); + break; + case 31: + message.ccEnableArenas = reader.bool(); + break; + case 36: + message.objcClassPrefix = reader.string(); + break; + case 37: + message.csharpNamespace = reader.string(); + break; + case 39: + message.swiftPrefix = reader.string(); + break; + case 40: + message.phpClassPrefix = reader.string(); + break; + case 41: + message.phpNamespace = reader.string(); + break; + case 44: + message.phpMetadataNamespace = reader.string(); + break; + case 45: + message.rubyPackage = reader.string(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FileOptions { + const message = { ...baseFileOptions } as FileOptions; + message.uninterpretedOption = []; + if (object.javaPackage !== undefined && object.javaPackage !== null) { + message.javaPackage = String(object.javaPackage); + } else { + message.javaPackage = ""; + } + if ( + object.javaOuterClassname !== undefined && + object.javaOuterClassname !== null + ) { + message.javaOuterClassname = String(object.javaOuterClassname); + } else { + message.javaOuterClassname = ""; + } + if ( + object.javaMultipleFiles !== undefined && + object.javaMultipleFiles !== null + ) { + message.javaMultipleFiles = Boolean(object.javaMultipleFiles); + } else { + message.javaMultipleFiles = false; + } + if ( + object.javaGenerateEqualsAndHash !== undefined && + object.javaGenerateEqualsAndHash !== null + ) { + message.javaGenerateEqualsAndHash = Boolean( + object.javaGenerateEqualsAndHash + ); + } else { + message.javaGenerateEqualsAndHash = false; + } + if ( + object.javaStringCheckUtf8 !== undefined && + object.javaStringCheckUtf8 !== null + ) { + message.javaStringCheckUtf8 = Boolean(object.javaStringCheckUtf8); + } else { + message.javaStringCheckUtf8 = false; + } + if (object.optimizeFor !== undefined && object.optimizeFor !== null) { + message.optimizeFor = fileOptions_OptimizeModeFromJSON( + object.optimizeFor + ); + } else { + message.optimizeFor = 1; + } + if (object.goPackage !== undefined && object.goPackage !== null) { + message.goPackage = String(object.goPackage); + } else { + message.goPackage = ""; + } + if ( + object.ccGenericServices !== undefined && + object.ccGenericServices !== null + ) { + message.ccGenericServices = Boolean(object.ccGenericServices); + } else { + message.ccGenericServices = false; + } + if ( + object.javaGenericServices !== undefined && + object.javaGenericServices !== null + ) { + message.javaGenericServices = Boolean(object.javaGenericServices); + } else { + message.javaGenericServices = false; + } + if ( + object.pyGenericServices !== undefined && + object.pyGenericServices !== null + ) { + message.pyGenericServices = Boolean(object.pyGenericServices); + } else { + message.pyGenericServices = false; + } + if ( + object.phpGenericServices !== undefined && + object.phpGenericServices !== null + ) { + message.phpGenericServices = Boolean(object.phpGenericServices); + } else { + message.phpGenericServices = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if (object.ccEnableArenas !== undefined && object.ccEnableArenas !== null) { + message.ccEnableArenas = Boolean(object.ccEnableArenas); + } else { + message.ccEnableArenas = false; + } + if ( + object.objcClassPrefix !== undefined && + object.objcClassPrefix !== null + ) { + message.objcClassPrefix = String(object.objcClassPrefix); + } else { + message.objcClassPrefix = ""; + } + if ( + object.csharpNamespace !== undefined && + object.csharpNamespace !== null + ) { + message.csharpNamespace = String(object.csharpNamespace); + } else { + message.csharpNamespace = ""; + } + if (object.swiftPrefix !== undefined && object.swiftPrefix !== null) { + message.swiftPrefix = String(object.swiftPrefix); + } else { + message.swiftPrefix = ""; + } + if (object.phpClassPrefix !== undefined && object.phpClassPrefix !== null) { + message.phpClassPrefix = String(object.phpClassPrefix); + } else { + message.phpClassPrefix = ""; + } + if (object.phpNamespace !== undefined && object.phpNamespace !== null) { + message.phpNamespace = String(object.phpNamespace); + } else { + message.phpNamespace = ""; + } + if ( + object.phpMetadataNamespace !== undefined && + object.phpMetadataNamespace !== null + ) { + message.phpMetadataNamespace = String(object.phpMetadataNamespace); + } else { + message.phpMetadataNamespace = ""; + } + if (object.rubyPackage !== undefined && object.rubyPackage !== null) { + message.rubyPackage = String(object.rubyPackage); + } else { + message.rubyPackage = ""; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: FileOptions): unknown { + const obj: any = {}; + message.javaPackage !== undefined && + (obj.javaPackage = message.javaPackage); + message.javaOuterClassname !== undefined && + (obj.javaOuterClassname = message.javaOuterClassname); + message.javaMultipleFiles !== undefined && + (obj.javaMultipleFiles = message.javaMultipleFiles); + message.javaGenerateEqualsAndHash !== undefined && + (obj.javaGenerateEqualsAndHash = message.javaGenerateEqualsAndHash); + message.javaStringCheckUtf8 !== undefined && + (obj.javaStringCheckUtf8 = message.javaStringCheckUtf8); + message.optimizeFor !== undefined && + (obj.optimizeFor = fileOptions_OptimizeModeToJSON(message.optimizeFor)); + message.goPackage !== undefined && (obj.goPackage = message.goPackage); + message.ccGenericServices !== undefined && + (obj.ccGenericServices = message.ccGenericServices); + message.javaGenericServices !== undefined && + (obj.javaGenericServices = message.javaGenericServices); + message.pyGenericServices !== undefined && + (obj.pyGenericServices = message.pyGenericServices); + message.phpGenericServices !== undefined && + (obj.phpGenericServices = message.phpGenericServices); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.ccEnableArenas !== undefined && + (obj.ccEnableArenas = message.ccEnableArenas); + message.objcClassPrefix !== undefined && + (obj.objcClassPrefix = message.objcClassPrefix); + message.csharpNamespace !== undefined && + (obj.csharpNamespace = message.csharpNamespace); + message.swiftPrefix !== undefined && + (obj.swiftPrefix = message.swiftPrefix); + message.phpClassPrefix !== undefined && + (obj.phpClassPrefix = message.phpClassPrefix); + message.phpNamespace !== undefined && + (obj.phpNamespace = message.phpNamespace); + message.phpMetadataNamespace !== undefined && + (obj.phpMetadataNamespace = message.phpMetadataNamespace); + message.rubyPackage !== undefined && + (obj.rubyPackage = message.rubyPackage); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): FileOptions { + const message = { ...baseFileOptions } as FileOptions; + message.uninterpretedOption = []; + if (object.javaPackage !== undefined && object.javaPackage !== null) { + message.javaPackage = object.javaPackage; + } else { + message.javaPackage = ""; + } + if ( + object.javaOuterClassname !== undefined && + object.javaOuterClassname !== null + ) { + message.javaOuterClassname = object.javaOuterClassname; + } else { + message.javaOuterClassname = ""; + } + if ( + object.javaMultipleFiles !== undefined && + object.javaMultipleFiles !== null + ) { + message.javaMultipleFiles = object.javaMultipleFiles; + } else { + message.javaMultipleFiles = false; + } + if ( + object.javaGenerateEqualsAndHash !== undefined && + object.javaGenerateEqualsAndHash !== null + ) { + message.javaGenerateEqualsAndHash = object.javaGenerateEqualsAndHash; + } else { + message.javaGenerateEqualsAndHash = false; + } + if ( + object.javaStringCheckUtf8 !== undefined && + object.javaStringCheckUtf8 !== null + ) { + message.javaStringCheckUtf8 = object.javaStringCheckUtf8; + } else { + message.javaStringCheckUtf8 = false; + } + if (object.optimizeFor !== undefined && object.optimizeFor !== null) { + message.optimizeFor = object.optimizeFor; + } else { + message.optimizeFor = 1; + } + if (object.goPackage !== undefined && object.goPackage !== null) { + message.goPackage = object.goPackage; + } else { + message.goPackage = ""; + } + if ( + object.ccGenericServices !== undefined && + object.ccGenericServices !== null + ) { + message.ccGenericServices = object.ccGenericServices; + } else { + message.ccGenericServices = false; + } + if ( + object.javaGenericServices !== undefined && + object.javaGenericServices !== null + ) { + message.javaGenericServices = object.javaGenericServices; + } else { + message.javaGenericServices = false; + } + if ( + object.pyGenericServices !== undefined && + object.pyGenericServices !== null + ) { + message.pyGenericServices = object.pyGenericServices; + } else { + message.pyGenericServices = false; + } + if ( + object.phpGenericServices !== undefined && + object.phpGenericServices !== null + ) { + message.phpGenericServices = object.phpGenericServices; + } else { + message.phpGenericServices = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if (object.ccEnableArenas !== undefined && object.ccEnableArenas !== null) { + message.ccEnableArenas = object.ccEnableArenas; + } else { + message.ccEnableArenas = false; + } + if ( + object.objcClassPrefix !== undefined && + object.objcClassPrefix !== null + ) { + message.objcClassPrefix = object.objcClassPrefix; + } else { + message.objcClassPrefix = ""; + } + if ( + object.csharpNamespace !== undefined && + object.csharpNamespace !== null + ) { + message.csharpNamespace = object.csharpNamespace; + } else { + message.csharpNamespace = ""; + } + if (object.swiftPrefix !== undefined && object.swiftPrefix !== null) { + message.swiftPrefix = object.swiftPrefix; + } else { + message.swiftPrefix = ""; + } + if (object.phpClassPrefix !== undefined && object.phpClassPrefix !== null) { + message.phpClassPrefix = object.phpClassPrefix; + } else { + message.phpClassPrefix = ""; + } + if (object.phpNamespace !== undefined && object.phpNamespace !== null) { + message.phpNamespace = object.phpNamespace; + } else { + message.phpNamespace = ""; + } + if ( + object.phpMetadataNamespace !== undefined && + object.phpMetadataNamespace !== null + ) { + message.phpMetadataNamespace = object.phpMetadataNamespace; + } else { + message.phpMetadataNamespace = ""; + } + if (object.rubyPackage !== undefined && object.rubyPackage !== null) { + message.rubyPackage = object.rubyPackage; + } else { + message.rubyPackage = ""; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseMessageOptions: object = { + messageSetWireFormat: false, + noStandardDescriptorAccessor: false, + deprecated: false, + mapEntry: false, +}; + +export const MessageOptions = { + encode(message: MessageOptions, writer: Writer = Writer.create()): Writer { + if (message.messageSetWireFormat === true) { + writer.uint32(8).bool(message.messageSetWireFormat); + } + if (message.noStandardDescriptorAccessor === true) { + writer.uint32(16).bool(message.noStandardDescriptorAccessor); + } + if (message.deprecated === true) { + writer.uint32(24).bool(message.deprecated); + } + if (message.mapEntry === true) { + writer.uint32(56).bool(message.mapEntry); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MessageOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMessageOptions } as MessageOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.messageSetWireFormat = reader.bool(); + break; + case 2: + message.noStandardDescriptorAccessor = reader.bool(); + break; + case 3: + message.deprecated = reader.bool(); + break; + case 7: + message.mapEntry = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MessageOptions { + const message = { ...baseMessageOptions } as MessageOptions; + message.uninterpretedOption = []; + if ( + object.messageSetWireFormat !== undefined && + object.messageSetWireFormat !== null + ) { + message.messageSetWireFormat = Boolean(object.messageSetWireFormat); + } else { + message.messageSetWireFormat = false; + } + if ( + object.noStandardDescriptorAccessor !== undefined && + object.noStandardDescriptorAccessor !== null + ) { + message.noStandardDescriptorAccessor = Boolean( + object.noStandardDescriptorAccessor + ); + } else { + message.noStandardDescriptorAccessor = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if (object.mapEntry !== undefined && object.mapEntry !== null) { + message.mapEntry = Boolean(object.mapEntry); + } else { + message.mapEntry = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: MessageOptions): unknown { + const obj: any = {}; + message.messageSetWireFormat !== undefined && + (obj.messageSetWireFormat = message.messageSetWireFormat); + message.noStandardDescriptorAccessor !== undefined && + (obj.noStandardDescriptorAccessor = message.noStandardDescriptorAccessor); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.mapEntry !== undefined && (obj.mapEntry = message.mapEntry); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): MessageOptions { + const message = { ...baseMessageOptions } as MessageOptions; + message.uninterpretedOption = []; + if ( + object.messageSetWireFormat !== undefined && + object.messageSetWireFormat !== null + ) { + message.messageSetWireFormat = object.messageSetWireFormat; + } else { + message.messageSetWireFormat = false; + } + if ( + object.noStandardDescriptorAccessor !== undefined && + object.noStandardDescriptorAccessor !== null + ) { + message.noStandardDescriptorAccessor = + object.noStandardDescriptorAccessor; + } else { + message.noStandardDescriptorAccessor = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if (object.mapEntry !== undefined && object.mapEntry !== null) { + message.mapEntry = object.mapEntry; + } else { + message.mapEntry = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseFieldOptions: object = { + ctype: 0, + packed: false, + jstype: 0, + lazy: false, + deprecated: false, + weak: false, +}; + +export const FieldOptions = { + encode(message: FieldOptions, writer: Writer = Writer.create()): Writer { + if (message.ctype !== 0) { + writer.uint32(8).int32(message.ctype); + } + if (message.packed === true) { + writer.uint32(16).bool(message.packed); + } + if (message.jstype !== 0) { + writer.uint32(48).int32(message.jstype); + } + if (message.lazy === true) { + writer.uint32(40).bool(message.lazy); + } + if (message.deprecated === true) { + writer.uint32(24).bool(message.deprecated); + } + if (message.weak === true) { + writer.uint32(80).bool(message.weak); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FieldOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFieldOptions } as FieldOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.ctype = reader.int32() as any; + break; + case 2: + message.packed = reader.bool(); + break; + case 6: + message.jstype = reader.int32() as any; + break; + case 5: + message.lazy = reader.bool(); + break; + case 3: + message.deprecated = reader.bool(); + break; + case 10: + message.weak = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FieldOptions { + const message = { ...baseFieldOptions } as FieldOptions; + message.uninterpretedOption = []; + if (object.ctype !== undefined && object.ctype !== null) { + message.ctype = fieldOptions_CTypeFromJSON(object.ctype); + } else { + message.ctype = 0; + } + if (object.packed !== undefined && object.packed !== null) { + message.packed = Boolean(object.packed); + } else { + message.packed = false; + } + if (object.jstype !== undefined && object.jstype !== null) { + message.jstype = fieldOptions_JSTypeFromJSON(object.jstype); + } else { + message.jstype = 0; + } + if (object.lazy !== undefined && object.lazy !== null) { + message.lazy = Boolean(object.lazy); + } else { + message.lazy = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if (object.weak !== undefined && object.weak !== null) { + message.weak = Boolean(object.weak); + } else { + message.weak = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: FieldOptions): unknown { + const obj: any = {}; + message.ctype !== undefined && + (obj.ctype = fieldOptions_CTypeToJSON(message.ctype)); + message.packed !== undefined && (obj.packed = message.packed); + message.jstype !== undefined && + (obj.jstype = fieldOptions_JSTypeToJSON(message.jstype)); + message.lazy !== undefined && (obj.lazy = message.lazy); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.weak !== undefined && (obj.weak = message.weak); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): FieldOptions { + const message = { ...baseFieldOptions } as FieldOptions; + message.uninterpretedOption = []; + if (object.ctype !== undefined && object.ctype !== null) { + message.ctype = object.ctype; + } else { + message.ctype = 0; + } + if (object.packed !== undefined && object.packed !== null) { + message.packed = object.packed; + } else { + message.packed = false; + } + if (object.jstype !== undefined && object.jstype !== null) { + message.jstype = object.jstype; + } else { + message.jstype = 0; + } + if (object.lazy !== undefined && object.lazy !== null) { + message.lazy = object.lazy; + } else { + message.lazy = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if (object.weak !== undefined && object.weak !== null) { + message.weak = object.weak; + } else { + message.weak = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseOneofOptions: object = {}; + +export const OneofOptions = { + encode(message: OneofOptions, writer: Writer = Writer.create()): Writer { + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): OneofOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseOneofOptions } as OneofOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): OneofOptions { + const message = { ...baseOneofOptions } as OneofOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: OneofOptions): unknown { + const obj: any = {}; + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): OneofOptions { + const message = { ...baseOneofOptions } as OneofOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseEnumOptions: object = { allowAlias: false, deprecated: false }; + +export const EnumOptions = { + encode(message: EnumOptions, writer: Writer = Writer.create()): Writer { + if (message.allowAlias === true) { + writer.uint32(16).bool(message.allowAlias); + } + if (message.deprecated === true) { + writer.uint32(24).bool(message.deprecated); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): EnumOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseEnumOptions } as EnumOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + message.allowAlias = reader.bool(); + break; + case 3: + message.deprecated = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumOptions { + const message = { ...baseEnumOptions } as EnumOptions; + message.uninterpretedOption = []; + if (object.allowAlias !== undefined && object.allowAlias !== null) { + message.allowAlias = Boolean(object.allowAlias); + } else { + message.allowAlias = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: EnumOptions): unknown { + const obj: any = {}; + message.allowAlias !== undefined && (obj.allowAlias = message.allowAlias); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): EnumOptions { + const message = { ...baseEnumOptions } as EnumOptions; + message.uninterpretedOption = []; + if (object.allowAlias !== undefined && object.allowAlias !== null) { + message.allowAlias = object.allowAlias; + } else { + message.allowAlias = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseEnumValueOptions: object = { deprecated: false }; + +export const EnumValueOptions = { + encode(message: EnumValueOptions, writer: Writer = Writer.create()): Writer { + if (message.deprecated === true) { + writer.uint32(8).bool(message.deprecated); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): EnumValueOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseEnumValueOptions } as EnumValueOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.deprecated = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumValueOptions { + const message = { ...baseEnumValueOptions } as EnumValueOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: EnumValueOptions): unknown { + const obj: any = {}; + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): EnumValueOptions { + const message = { ...baseEnumValueOptions } as EnumValueOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseServiceOptions: object = { deprecated: false }; + +export const ServiceOptions = { + encode(message: ServiceOptions, writer: Writer = Writer.create()): Writer { + if (message.deprecated === true) { + writer.uint32(264).bool(message.deprecated); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ServiceOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseServiceOptions } as ServiceOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 33: + message.deprecated = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ServiceOptions { + const message = { ...baseServiceOptions } as ServiceOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: ServiceOptions): unknown { + const obj: any = {}; + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): ServiceOptions { + const message = { ...baseServiceOptions } as ServiceOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseMethodOptions: object = { deprecated: false, idempotencyLevel: 0 }; + +export const MethodOptions = { + encode(message: MethodOptions, writer: Writer = Writer.create()): Writer { + if (message.deprecated === true) { + writer.uint32(264).bool(message.deprecated); + } + if (message.idempotencyLevel !== 0) { + writer.uint32(272).int32(message.idempotencyLevel); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MethodOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMethodOptions } as MethodOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 33: + message.deprecated = reader.bool(); + break; + case 34: + message.idempotencyLevel = reader.int32() as any; + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MethodOptions { + const message = { ...baseMethodOptions } as MethodOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.idempotencyLevel !== undefined && + object.idempotencyLevel !== null + ) { + message.idempotencyLevel = methodOptions_IdempotencyLevelFromJSON( + object.idempotencyLevel + ); + } else { + message.idempotencyLevel = 0; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: MethodOptions): unknown { + const obj: any = {}; + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.idempotencyLevel !== undefined && + (obj.idempotencyLevel = methodOptions_IdempotencyLevelToJSON( + message.idempotencyLevel + )); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): MethodOptions { + const message = { ...baseMethodOptions } as MethodOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.idempotencyLevel !== undefined && + object.idempotencyLevel !== null + ) { + message.idempotencyLevel = object.idempotencyLevel; + } else { + message.idempotencyLevel = 0; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseUninterpretedOption: object = { + identifierValue: "", + positiveIntValue: 0, + negativeIntValue: 0, + doubleValue: 0, + aggregateValue: "", +}; + +export const UninterpretedOption = { + encode( + message: UninterpretedOption, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.name) { + UninterpretedOption_NamePart.encode( + v!, + writer.uint32(18).fork() + ).ldelim(); + } + if (message.identifierValue !== "") { + writer.uint32(26).string(message.identifierValue); + } + if (message.positiveIntValue !== 0) { + writer.uint32(32).uint64(message.positiveIntValue); + } + if (message.negativeIntValue !== 0) { + writer.uint32(40).int64(message.negativeIntValue); + } + if (message.doubleValue !== 0) { + writer.uint32(49).double(message.doubleValue); + } + if (message.stringValue.length !== 0) { + writer.uint32(58).bytes(message.stringValue); + } + if (message.aggregateValue !== "") { + writer.uint32(66).string(message.aggregateValue); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): UninterpretedOption { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseUninterpretedOption } as UninterpretedOption; + message.name = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + message.name.push( + UninterpretedOption_NamePart.decode(reader, reader.uint32()) + ); + break; + case 3: + message.identifierValue = reader.string(); + break; + case 4: + message.positiveIntValue = longToNumber(reader.uint64() as Long); + break; + case 5: + message.negativeIntValue = longToNumber(reader.int64() as Long); + break; + case 6: + message.doubleValue = reader.double(); + break; + case 7: + message.stringValue = reader.bytes(); + break; + case 8: + message.aggregateValue = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): UninterpretedOption { + const message = { ...baseUninterpretedOption } as UninterpretedOption; + message.name = []; + if (object.name !== undefined && object.name !== null) { + for (const e of object.name) { + message.name.push(UninterpretedOption_NamePart.fromJSON(e)); + } + } + if ( + object.identifierValue !== undefined && + object.identifierValue !== null + ) { + message.identifierValue = String(object.identifierValue); + } else { + message.identifierValue = ""; + } + if ( + object.positiveIntValue !== undefined && + object.positiveIntValue !== null + ) { + message.positiveIntValue = Number(object.positiveIntValue); + } else { + message.positiveIntValue = 0; + } + if ( + object.negativeIntValue !== undefined && + object.negativeIntValue !== null + ) { + message.negativeIntValue = Number(object.negativeIntValue); + } else { + message.negativeIntValue = 0; + } + if (object.doubleValue !== undefined && object.doubleValue !== null) { + message.doubleValue = Number(object.doubleValue); + } else { + message.doubleValue = 0; + } + if (object.stringValue !== undefined && object.stringValue !== null) { + message.stringValue = bytesFromBase64(object.stringValue); + } + if (object.aggregateValue !== undefined && object.aggregateValue !== null) { + message.aggregateValue = String(object.aggregateValue); + } else { + message.aggregateValue = ""; + } + return message; + }, + + toJSON(message: UninterpretedOption): unknown { + const obj: any = {}; + if (message.name) { + obj.name = message.name.map((e) => + e ? UninterpretedOption_NamePart.toJSON(e) : undefined + ); + } else { + obj.name = []; + } + message.identifierValue !== undefined && + (obj.identifierValue = message.identifierValue); + message.positiveIntValue !== undefined && + (obj.positiveIntValue = message.positiveIntValue); + message.negativeIntValue !== undefined && + (obj.negativeIntValue = message.negativeIntValue); + message.doubleValue !== undefined && + (obj.doubleValue = message.doubleValue); + message.stringValue !== undefined && + (obj.stringValue = base64FromBytes( + message.stringValue !== undefined + ? message.stringValue + : new Uint8Array() + )); + message.aggregateValue !== undefined && + (obj.aggregateValue = message.aggregateValue); + return obj; + }, + + fromPartial(object: DeepPartial): UninterpretedOption { + const message = { ...baseUninterpretedOption } as UninterpretedOption; + message.name = []; + if (object.name !== undefined && object.name !== null) { + for (const e of object.name) { + message.name.push(UninterpretedOption_NamePart.fromPartial(e)); + } + } + if ( + object.identifierValue !== undefined && + object.identifierValue !== null + ) { + message.identifierValue = object.identifierValue; + } else { + message.identifierValue = ""; + } + if ( + object.positiveIntValue !== undefined && + object.positiveIntValue !== null + ) { + message.positiveIntValue = object.positiveIntValue; + } else { + message.positiveIntValue = 0; + } + if ( + object.negativeIntValue !== undefined && + object.negativeIntValue !== null + ) { + message.negativeIntValue = object.negativeIntValue; + } else { + message.negativeIntValue = 0; + } + if (object.doubleValue !== undefined && object.doubleValue !== null) { + message.doubleValue = object.doubleValue; + } else { + message.doubleValue = 0; + } + if (object.stringValue !== undefined && object.stringValue !== null) { + message.stringValue = object.stringValue; + } else { + message.stringValue = new Uint8Array(); + } + if (object.aggregateValue !== undefined && object.aggregateValue !== null) { + message.aggregateValue = object.aggregateValue; + } else { + message.aggregateValue = ""; + } + return message; + }, +}; + +const baseUninterpretedOption_NamePart: object = { + namePart: "", + isExtension: false, +}; + +export const UninterpretedOption_NamePart = { + encode( + message: UninterpretedOption_NamePart, + writer: Writer = Writer.create() + ): Writer { + if (message.namePart !== "") { + writer.uint32(10).string(message.namePart); + } + if (message.isExtension === true) { + writer.uint32(16).bool(message.isExtension); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): UninterpretedOption_NamePart { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseUninterpretedOption_NamePart, + } as UninterpretedOption_NamePart; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.namePart = reader.string(); + break; + case 2: + message.isExtension = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): UninterpretedOption_NamePart { + const message = { + ...baseUninterpretedOption_NamePart, + } as UninterpretedOption_NamePart; + if (object.namePart !== undefined && object.namePart !== null) { + message.namePart = String(object.namePart); + } else { + message.namePart = ""; + } + if (object.isExtension !== undefined && object.isExtension !== null) { + message.isExtension = Boolean(object.isExtension); + } else { + message.isExtension = false; + } + return message; + }, + + toJSON(message: UninterpretedOption_NamePart): unknown { + const obj: any = {}; + message.namePart !== undefined && (obj.namePart = message.namePart); + message.isExtension !== undefined && + (obj.isExtension = message.isExtension); + return obj; + }, + + fromPartial( + object: DeepPartial + ): UninterpretedOption_NamePart { + const message = { + ...baseUninterpretedOption_NamePart, + } as UninterpretedOption_NamePart; + if (object.namePart !== undefined && object.namePart !== null) { + message.namePart = object.namePart; + } else { + message.namePart = ""; + } + if (object.isExtension !== undefined && object.isExtension !== null) { + message.isExtension = object.isExtension; + } else { + message.isExtension = false; + } + return message; + }, +}; + +const baseSourceCodeInfo: object = {}; + +export const SourceCodeInfo = { + encode(message: SourceCodeInfo, writer: Writer = Writer.create()): Writer { + for (const v of message.location) { + SourceCodeInfo_Location.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): SourceCodeInfo { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseSourceCodeInfo } as SourceCodeInfo; + message.location = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.location.push( + SourceCodeInfo_Location.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): SourceCodeInfo { + const message = { ...baseSourceCodeInfo } as SourceCodeInfo; + message.location = []; + if (object.location !== undefined && object.location !== null) { + for (const e of object.location) { + message.location.push(SourceCodeInfo_Location.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: SourceCodeInfo): unknown { + const obj: any = {}; + if (message.location) { + obj.location = message.location.map((e) => + e ? SourceCodeInfo_Location.toJSON(e) : undefined + ); + } else { + obj.location = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): SourceCodeInfo { + const message = { ...baseSourceCodeInfo } as SourceCodeInfo; + message.location = []; + if (object.location !== undefined && object.location !== null) { + for (const e of object.location) { + message.location.push(SourceCodeInfo_Location.fromPartial(e)); + } + } + return message; + }, +}; + +const baseSourceCodeInfo_Location: object = { + path: 0, + span: 0, + leadingComments: "", + trailingComments: "", + leadingDetachedComments: "", +}; + +export const SourceCodeInfo_Location = { + encode( + message: SourceCodeInfo_Location, + writer: Writer = Writer.create() + ): Writer { + writer.uint32(10).fork(); + for (const v of message.path) { + writer.int32(v); + } + writer.ldelim(); + writer.uint32(18).fork(); + for (const v of message.span) { + writer.int32(v); + } + writer.ldelim(); + if (message.leadingComments !== "") { + writer.uint32(26).string(message.leadingComments); + } + if (message.trailingComments !== "") { + writer.uint32(34).string(message.trailingComments); + } + for (const v of message.leadingDetachedComments) { + writer.uint32(50).string(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): SourceCodeInfo_Location { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseSourceCodeInfo_Location, + } as SourceCodeInfo_Location; + message.path = []; + message.span = []; + message.leadingDetachedComments = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.path.push(reader.int32()); + } + } else { + message.path.push(reader.int32()); + } + break; + case 2: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.span.push(reader.int32()); + } + } else { + message.span.push(reader.int32()); + } + break; + case 3: + message.leadingComments = reader.string(); + break; + case 4: + message.trailingComments = reader.string(); + break; + case 6: + message.leadingDetachedComments.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): SourceCodeInfo_Location { + const message = { + ...baseSourceCodeInfo_Location, + } as SourceCodeInfo_Location; + message.path = []; + message.span = []; + message.leadingDetachedComments = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(Number(e)); + } + } + if (object.span !== undefined && object.span !== null) { + for (const e of object.span) { + message.span.push(Number(e)); + } + } + if ( + object.leadingComments !== undefined && + object.leadingComments !== null + ) { + message.leadingComments = String(object.leadingComments); + } else { + message.leadingComments = ""; + } + if ( + object.trailingComments !== undefined && + object.trailingComments !== null + ) { + message.trailingComments = String(object.trailingComments); + } else { + message.trailingComments = ""; + } + if ( + object.leadingDetachedComments !== undefined && + object.leadingDetachedComments !== null + ) { + for (const e of object.leadingDetachedComments) { + message.leadingDetachedComments.push(String(e)); + } + } + return message; + }, + + toJSON(message: SourceCodeInfo_Location): unknown { + const obj: any = {}; + if (message.path) { + obj.path = message.path.map((e) => e); + } else { + obj.path = []; + } + if (message.span) { + obj.span = message.span.map((e) => e); + } else { + obj.span = []; + } + message.leadingComments !== undefined && + (obj.leadingComments = message.leadingComments); + message.trailingComments !== undefined && + (obj.trailingComments = message.trailingComments); + if (message.leadingDetachedComments) { + obj.leadingDetachedComments = message.leadingDetachedComments.map( + (e) => e + ); + } else { + obj.leadingDetachedComments = []; + } + return obj; + }, + + fromPartial( + object: DeepPartial + ): SourceCodeInfo_Location { + const message = { + ...baseSourceCodeInfo_Location, + } as SourceCodeInfo_Location; + message.path = []; + message.span = []; + message.leadingDetachedComments = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(e); + } + } + if (object.span !== undefined && object.span !== null) { + for (const e of object.span) { + message.span.push(e); + } + } + if ( + object.leadingComments !== undefined && + object.leadingComments !== null + ) { + message.leadingComments = object.leadingComments; + } else { + message.leadingComments = ""; + } + if ( + object.trailingComments !== undefined && + object.trailingComments !== null + ) { + message.trailingComments = object.trailingComments; + } else { + message.trailingComments = ""; + } + if ( + object.leadingDetachedComments !== undefined && + object.leadingDetachedComments !== null + ) { + for (const e of object.leadingDetachedComments) { + message.leadingDetachedComments.push(e); + } + } + return message; + }, +}; + +const baseGeneratedCodeInfo: object = {}; + +export const GeneratedCodeInfo = { + encode(message: GeneratedCodeInfo, writer: Writer = Writer.create()): Writer { + for (const v of message.annotation) { + GeneratedCodeInfo_Annotation.encode( + v!, + writer.uint32(10).fork() + ).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): GeneratedCodeInfo { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseGeneratedCodeInfo } as GeneratedCodeInfo; + message.annotation = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.annotation.push( + GeneratedCodeInfo_Annotation.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GeneratedCodeInfo { + const message = { ...baseGeneratedCodeInfo } as GeneratedCodeInfo; + message.annotation = []; + if (object.annotation !== undefined && object.annotation !== null) { + for (const e of object.annotation) { + message.annotation.push(GeneratedCodeInfo_Annotation.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: GeneratedCodeInfo): unknown { + const obj: any = {}; + if (message.annotation) { + obj.annotation = message.annotation.map((e) => + e ? GeneratedCodeInfo_Annotation.toJSON(e) : undefined + ); + } else { + obj.annotation = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): GeneratedCodeInfo { + const message = { ...baseGeneratedCodeInfo } as GeneratedCodeInfo; + message.annotation = []; + if (object.annotation !== undefined && object.annotation !== null) { + for (const e of object.annotation) { + message.annotation.push(GeneratedCodeInfo_Annotation.fromPartial(e)); + } + } + return message; + }, +}; + +const baseGeneratedCodeInfo_Annotation: object = { + path: 0, + sourceFile: "", + begin: 0, + end: 0, +}; + +export const GeneratedCodeInfo_Annotation = { + encode( + message: GeneratedCodeInfo_Annotation, + writer: Writer = Writer.create() + ): Writer { + writer.uint32(10).fork(); + for (const v of message.path) { + writer.int32(v); + } + writer.ldelim(); + if (message.sourceFile !== "") { + writer.uint32(18).string(message.sourceFile); + } + if (message.begin !== 0) { + writer.uint32(24).int32(message.begin); + } + if (message.end !== 0) { + writer.uint32(32).int32(message.end); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): GeneratedCodeInfo_Annotation { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseGeneratedCodeInfo_Annotation, + } as GeneratedCodeInfo_Annotation; + message.path = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.path.push(reader.int32()); + } + } else { + message.path.push(reader.int32()); + } + break; + case 2: + message.sourceFile = reader.string(); + break; + case 3: + message.begin = reader.int32(); + break; + case 4: + message.end = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GeneratedCodeInfo_Annotation { + const message = { + ...baseGeneratedCodeInfo_Annotation, + } as GeneratedCodeInfo_Annotation; + message.path = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(Number(e)); + } + } + if (object.sourceFile !== undefined && object.sourceFile !== null) { + message.sourceFile = String(object.sourceFile); + } else { + message.sourceFile = ""; + } + if (object.begin !== undefined && object.begin !== null) { + message.begin = Number(object.begin); + } else { + message.begin = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + return message; + }, + + toJSON(message: GeneratedCodeInfo_Annotation): unknown { + const obj: any = {}; + if (message.path) { + obj.path = message.path.map((e) => e); + } else { + obj.path = []; + } + message.sourceFile !== undefined && (obj.sourceFile = message.sourceFile); + message.begin !== undefined && (obj.begin = message.begin); + message.end !== undefined && (obj.end = message.end); + return obj; + }, + + fromPartial( + object: DeepPartial + ): GeneratedCodeInfo_Annotation { + const message = { + ...baseGeneratedCodeInfo_Annotation, + } as GeneratedCodeInfo_Annotation; + message.path = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(e); + } + } + if (object.sourceFile !== undefined && object.sourceFile !== null) { + message.sourceFile = object.sourceFile; + } else { + message.sourceFile = ""; + } + if (object.begin !== undefined && object.begin !== null) { + message.begin = object.begin; + } else { + message.begin = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/cosmos.upgrade.v1beta1/types/google/protobuf/timestamp.ts b/ts-client/cosmos.upgrade.v1beta1/types/google/protobuf/timestamp.ts new file mode 100644 index 00000000..11864afc --- /dev/null +++ b/ts-client/cosmos.upgrade.v1beta1/types/google/protobuf/timestamp.ts @@ -0,0 +1,219 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "google.protobuf"; + +/** + * A Timestamp represents a point in time independent of any time zone or local + * calendar, encoded as a count of seconds and fractions of seconds at + * nanosecond resolution. The count is relative to an epoch at UTC midnight on + * January 1, 1970, in the proleptic Gregorian calendar which extends the + * Gregorian calendar backwards to year one. + * + * All minutes are 60 seconds long. Leap seconds are "smeared" so that no leap + * second table is needed for interpretation, using a [24-hour linear + * smear](https://developers.google.com/time/smear). + * + * The range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. By + * restricting to that range, we ensure that we can convert to and from [RFC + * 3339](https://www.ietf.org/rfc/rfc3339.txt) date strings. + * + * # Examples + * + * Example 1: Compute Timestamp from POSIX `time()`. + * + * Timestamp timestamp; + * timestamp.set_seconds(time(NULL)); + * timestamp.set_nanos(0); + * + * Example 2: Compute Timestamp from POSIX `gettimeofday()`. + * + * struct timeval tv; + * gettimeofday(&tv, NULL); + * + * Timestamp timestamp; + * timestamp.set_seconds(tv.tv_sec); + * timestamp.set_nanos(tv.tv_usec * 1000); + * + * Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`. + * + * FILETIME ft; + * GetSystemTimeAsFileTime(&ft); + * UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime; + * + * // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z + * // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z. + * Timestamp timestamp; + * timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL)); + * timestamp.set_nanos((INT32) ((ticks % 10000000) * 100)); + * + * Example 4: Compute Timestamp from Java `System.currentTimeMillis()`. + * + * long millis = System.currentTimeMillis(); + * + * Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000) + * .setNanos((int) ((millis % 1000) * 1000000)).build(); + * + * + * Example 5: Compute Timestamp from Java `Instant.now()`. + * + * Instant now = Instant.now(); + * + * Timestamp timestamp = + * Timestamp.newBuilder().setSeconds(now.getEpochSecond()) + * .setNanos(now.getNano()).build(); + * + * + * Example 6: Compute Timestamp from current time in Python. + * + * timestamp = Timestamp() + * timestamp.GetCurrentTime() + * + * # JSON Mapping + * + * In JSON format, the Timestamp type is encoded as a string in the + * [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the + * format is "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z" + * where {year} is always expressed using four digits while {month}, {day}, + * {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional + * seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution), + * are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone + * is required. A proto3 JSON serializer should always use UTC (as indicated by + * "Z") when printing the Timestamp type and a proto3 JSON parser should be + * able to accept both UTC and other timezones (as indicated by an offset). + * + * For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past + * 01:30 UTC on January 15, 2017. + * + * In JavaScript, one can convert a Date object to this format using the + * standard + * [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString) + * method. In Python, a standard `datetime.datetime` object can be converted + * to this format using + * [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) with + * the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one can use + * the Joda Time's [`ISODateTimeFormat.dateTime()`]( + * http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime%2D%2D + * ) to obtain a formatter capable of generating timestamps in this format. + */ +export interface Timestamp { + /** + * Represents seconds of UTC time since Unix epoch + * 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to + * 9999-12-31T23:59:59Z inclusive. + */ + seconds: number; + /** + * Non-negative fractions of a second at nanosecond resolution. Negative + * second values with fractions must still have non-negative nanos values + * that count forward in time. Must be from 0 to 999,999,999 + * inclusive. + */ + nanos: number; +} + +const baseTimestamp: object = { seconds: 0, nanos: 0 }; + +export const Timestamp = { + encode(message: Timestamp, writer: Writer = Writer.create()): Writer { + if (message.seconds !== 0) { + writer.uint32(8).int64(message.seconds); + } + if (message.nanos !== 0) { + writer.uint32(16).int32(message.nanos); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Timestamp { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseTimestamp } as Timestamp; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.seconds = longToNumber(reader.int64() as Long); + break; + case 2: + message.nanos = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Timestamp { + const message = { ...baseTimestamp } as Timestamp; + if (object.seconds !== undefined && object.seconds !== null) { + message.seconds = Number(object.seconds); + } else { + message.seconds = 0; + } + if (object.nanos !== undefined && object.nanos !== null) { + message.nanos = Number(object.nanos); + } else { + message.nanos = 0; + } + return message; + }, + + toJSON(message: Timestamp): unknown { + const obj: any = {}; + message.seconds !== undefined && (obj.seconds = message.seconds); + message.nanos !== undefined && (obj.nanos = message.nanos); + return obj; + }, + + fromPartial(object: DeepPartial): Timestamp { + const message = { ...baseTimestamp } as Timestamp; + if (object.seconds !== undefined && object.seconds !== null) { + message.seconds = object.seconds; + } else { + message.seconds = 0; + } + if (object.nanos !== undefined && object.nanos !== null) { + message.nanos = object.nanos; + } else { + message.nanos = 0; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/cosmos.vesting.v1beta1/index.ts b/ts-client/cosmos.vesting.v1beta1/index.ts new file mode 100755 index 00000000..c9dfa159 --- /dev/null +++ b/ts-client/cosmos.vesting.v1beta1/index.ts @@ -0,0 +1,6 @@ +import Module from './module'; +import { txClient, queryClient, registry } from './module'; +import { msgTypes } from './registry'; + +export * from "./types"; +export { Module, msgTypes, txClient, queryClient, registry }; diff --git a/ts-client/cosmos.vesting.v1beta1/module.ts b/ts-client/cosmos.vesting.v1beta1/module.ts new file mode 100755 index 00000000..36dc0275 --- /dev/null +++ b/ts-client/cosmos.vesting.v1beta1/module.ts @@ -0,0 +1,99 @@ +// Generated by Ignite ignite.com/cli + +import { StdFee } from "@cosmjs/launchpad"; +import { SigningStargateClient, DeliverTxResponse } from "@cosmjs/stargate"; +import { EncodeObject, GeneratedType, OfflineSigner, Registry } from "@cosmjs/proto-signing"; +import { msgTypes } from './registry'; +import { IgniteClient } from "../client" +import { MissingWalletError } from "../helpers" +import { Api } from "./rest"; +import { MsgCreateVestingAccount } from "./types/cosmos/vesting/v1beta1/tx"; + + +export { MsgCreateVestingAccount }; + +type sendMsgCreateVestingAccountParams = { + value: MsgCreateVestingAccount, + fee?: StdFee, + memo?: string +}; + + +type msgCreateVestingAccountParams = { + value: MsgCreateVestingAccount, +}; + + +export const registry = new Registry(msgTypes); + +const defaultFee = { + amount: [], + gas: "200000", +}; + +interface TxClientOptions { + addr: string + prefix: string + signer?: OfflineSigner +} + +export const txClient = ({ signer, prefix, addr }: TxClientOptions = { addr: "http://localhost:26657", prefix: "cosmos" }) => { + + return { + + async sendMsgCreateVestingAccount({ value, fee, memo }: sendMsgCreateVestingAccountParams): Promise { + if (!signer) { + throw new Error('TxClient:sendMsgCreateVestingAccount: Unable to sign Tx. Signer is not present.') + } + try { + const { address } = (await signer.getAccounts())[0]; + const signingClient = await SigningStargateClient.connectWithSigner(addr,signer,{registry, prefix}); + let msg = this.msgCreateVestingAccount({ value: MsgCreateVestingAccount.fromPartial(value) }) + return await signingClient.signAndBroadcast(address, [msg], fee ? fee : defaultFee, memo) + } catch (e: any) { + throw new Error('TxClient:sendMsgCreateVestingAccount: Could not broadcast Tx: '+ e.message) + } + }, + + + msgCreateVestingAccount({ value }: msgCreateVestingAccountParams): EncodeObject { + try { + return { typeUrl: "/cosmos.vesting.v1beta1.MsgCreateVestingAccount", value: MsgCreateVestingAccount.fromPartial( value ) } + } catch (e: any) { + throw new Error('TxClient:MsgCreateVestingAccount: Could not create message: ' + e.message) + } + }, + + } +}; + +interface QueryClientOptions { + addr: string +} + +export const queryClient = ({ addr: addr }: QueryClientOptions = { addr: "http://localhost:1317" }) => { + return new Api({ baseUrl: addr }); +}; + +class SDKModule { + public query: ReturnType; + public tx: ReturnType; + + public registry: Array<[string, GeneratedType]>; + + constructor(client: IgniteClient) { + + this.query = queryClient({ addr: client.env.apiURL }); + this.tx = txClient({ signer: client.signer, addr: client.env.rpcURL, prefix: client.env.prefix ?? "cosmos" }); + } +}; + +const Module = (test: IgniteClient) => { + return { + module: { + CosmosVestingV1Beta1: new SDKModule(test) + }, + registry: msgTypes + } +} +export default Module; \ No newline at end of file diff --git a/ts-client/cosmos.vesting.v1beta1/registry.ts b/ts-client/cosmos.vesting.v1beta1/registry.ts new file mode 100755 index 00000000..3fbe1b76 --- /dev/null +++ b/ts-client/cosmos.vesting.v1beta1/registry.ts @@ -0,0 +1,9 @@ +import { GeneratedType } from "@cosmjs/proto-signing"; +import { MsgCreateVestingAccount } from "./types/cosmos/vesting/v1beta1/tx"; + +const msgTypes: Array<[string, GeneratedType]> = [ + ["/cosmos.vesting.v1beta1.MsgCreateVestingAccount", MsgCreateVestingAccount], + +]; + +export { msgTypes } \ No newline at end of file diff --git a/ts-client/cosmos.vesting.v1beta1/rest.ts b/ts-client/cosmos.vesting.v1beta1/rest.ts new file mode 100644 index 00000000..5ec60ced --- /dev/null +++ b/ts-client/cosmos.vesting.v1beta1/rest.ts @@ -0,0 +1,347 @@ +/* eslint-disable */ +/* tslint:disable */ +/* + * --------------------------------------------------------------- + * ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ## + * ## ## + * ## AUTHOR: acacode ## + * ## SOURCE: https://github.com/acacode/swagger-typescript-api ## + * --------------------------------------------------------------- + */ + +/** +* `Any` contains an arbitrary serialized protocol buffer message along with a +URL that describes the type of the serialized message. + +Protobuf library provides support to pack/unpack Any values in the form +of utility functions or additional generated methods of the Any type. + +Example 1: Pack and unpack a message in C++. + + Foo foo = ...; + Any any; + any.PackFrom(foo); + ... + if (any.UnpackTo(&foo)) { + ... + } + +Example 2: Pack and unpack a message in Java. + + Foo foo = ...; + Any any = Any.pack(foo); + ... + if (any.is(Foo.class)) { + foo = any.unpack(Foo.class); + } + + Example 3: Pack and unpack a message in Python. + + foo = Foo(...) + any = Any() + any.Pack(foo) + ... + if any.Is(Foo.DESCRIPTOR): + any.Unpack(foo) + ... + + Example 4: Pack and unpack a message in Go + + foo := &pb.Foo{...} + any, err := anypb.New(foo) + if err != nil { + ... + } + ... + foo := &pb.Foo{} + if err := any.UnmarshalTo(foo); err != nil { + ... + } + +The pack methods provided by protobuf library will by default use +'type.googleapis.com/full.type.name' as the type URL and the unpack +methods only use the fully qualified type name after the last '/' +in the type URL, for example "foo.bar.com/x/y.z" will yield type +name "y.z". + + +JSON +==== +The JSON representation of an `Any` value uses the regular +representation of the deserialized, embedded message, with an +additional field `@type` which contains the type URL. Example: + + package google.profile; + message Person { + string first_name = 1; + string last_name = 2; + } + + { + "@type": "type.googleapis.com/google.profile.Person", + "firstName": , + "lastName": + } + +If the embedded message type is well-known and has a custom JSON +representation, that representation will be embedded adding a field +`value` which holds the custom JSON in addition to the `@type` +field. Example (for message [google.protobuf.Duration][]): + + { + "@type": "type.googleapis.com/google.protobuf.Duration", + "value": "1.212s" + } +*/ +export interface ProtobufAny { + /** + * A URL/resource name that uniquely identifies the type of the serialized + * protocol buffer message. This string must contain at least + * one "/" character. The last segment of the URL's path must represent + * the fully qualified name of the type (as in + * `path/google.protobuf.Duration`). The name should be in a canonical form + * (e.g., leading "." is not accepted). + * + * In practice, teams usually precompile into the binary all types that they + * expect it to use in the context of Any. However, for URLs which use the + * scheme `http`, `https`, or no scheme, one can optionally set up a type + * server that maps type URLs to message definitions as follows: + * + * * If no scheme is provided, `https` is assumed. + * * An HTTP GET on the URL must yield a [google.protobuf.Type][] + * value in binary format, or produce an error. + * * Applications are allowed to cache lookup results based on the + * URL, or have them precompiled into a binary to avoid any + * lookup. Therefore, binary compatibility needs to be preserved + * on changes to types. (Use versioned type names to manage + * breaking changes.) + * + * Note: this functionality is not currently available in the official + * protobuf release, and it is not used for type URLs beginning with + * type.googleapis.com. + * + * Schemes other than `http`, `https` (or the empty scheme) might be + * used with implementation specific semantics. + */ + "@type"?: string; +} + +export interface RpcStatus { + /** @format int32 */ + code?: number; + message?: string; + details?: ProtobufAny[]; +} + +/** +* Coin defines a token with a denomination and an amount. + +NOTE: The amount field is an Int which implements the custom method +signatures required by gogoproto. +*/ +export interface V1Beta1Coin { + denom?: string; + amount?: string; +} + +/** + * MsgCreateVestingAccountResponse defines the Msg/CreateVestingAccount response type. + */ +export type V1Beta1MsgCreateVestingAccountResponse = object; + +export type QueryParamsType = Record; +export type ResponseFormat = keyof Omit; + +export interface FullRequestParams extends Omit { + /** set parameter to `true` for call `securityWorker` for this request */ + secure?: boolean; + /** request path */ + path: string; + /** content type of request body */ + type?: ContentType; + /** query params */ + query?: QueryParamsType; + /** format of response (i.e. response.json() -> format: "json") */ + format?: keyof Omit; + /** request body */ + body?: unknown; + /** base url */ + baseUrl?: string; + /** request cancellation token */ + cancelToken?: CancelToken; +} + +export type RequestParams = Omit; + +export interface ApiConfig { + baseUrl?: string; + baseApiParams?: Omit; + securityWorker?: (securityData: SecurityDataType) => RequestParams | void; +} + +export interface HttpResponse extends Response { + data: D; + error: E; +} + +type CancelToken = Symbol | string | number; + +export enum ContentType { + Json = "application/json", + FormData = "multipart/form-data", + UrlEncoded = "application/x-www-form-urlencoded", +} + +export class HttpClient { + public baseUrl: string = ""; + private securityData: SecurityDataType = null as any; + private securityWorker: null | ApiConfig["securityWorker"] = null; + private abortControllers = new Map(); + + private baseApiParams: RequestParams = { + credentials: "same-origin", + headers: {}, + redirect: "follow", + referrerPolicy: "no-referrer", + }; + + constructor(apiConfig: ApiConfig = {}) { + Object.assign(this, apiConfig); + } + + public setSecurityData = (data: SecurityDataType) => { + this.securityData = data; + }; + + private addQueryParam(query: QueryParamsType, key: string) { + const value = query[key]; + + return ( + encodeURIComponent(key) + + "=" + + encodeURIComponent(Array.isArray(value) ? value.join(",") : typeof value === "number" ? value : `${value}`) + ); + } + + protected toQueryString(rawQuery?: QueryParamsType): string { + const query = rawQuery || {}; + const keys = Object.keys(query).filter((key) => "undefined" !== typeof query[key]); + return keys + .map((key) => + typeof query[key] === "object" && !Array.isArray(query[key]) + ? this.toQueryString(query[key] as QueryParamsType) + : this.addQueryParam(query, key), + ) + .join("&"); + } + + protected addQueryParams(rawQuery?: QueryParamsType): string { + const queryString = this.toQueryString(rawQuery); + return queryString ? `?${queryString}` : ""; + } + + private contentFormatters: Record any> = { + [ContentType.Json]: (input: any) => + input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input, + [ContentType.FormData]: (input: any) => + Object.keys(input || {}).reduce((data, key) => { + data.append(key, input[key]); + return data; + }, new FormData()), + [ContentType.UrlEncoded]: (input: any) => this.toQueryString(input), + }; + + private mergeRequestParams(params1: RequestParams, params2?: RequestParams): RequestParams { + return { + ...this.baseApiParams, + ...params1, + ...(params2 || {}), + headers: { + ...(this.baseApiParams.headers || {}), + ...(params1.headers || {}), + ...((params2 && params2.headers) || {}), + }, + }; + } + + private createAbortSignal = (cancelToken: CancelToken): AbortSignal | undefined => { + if (this.abortControllers.has(cancelToken)) { + const abortController = this.abortControllers.get(cancelToken); + if (abortController) { + return abortController.signal; + } + return void 0; + } + + const abortController = new AbortController(); + this.abortControllers.set(cancelToken, abortController); + return abortController.signal; + }; + + public abortRequest = (cancelToken: CancelToken) => { + const abortController = this.abortControllers.get(cancelToken); + + if (abortController) { + abortController.abort(); + this.abortControllers.delete(cancelToken); + } + }; + + public request = ({ + body, + secure, + path, + type, + query, + format = "json", + baseUrl, + cancelToken, + ...params + }: FullRequestParams): Promise> => { + const secureParams = (secure && this.securityWorker && this.securityWorker(this.securityData)) || {}; + const requestParams = this.mergeRequestParams(params, secureParams); + const queryString = query && this.toQueryString(query); + const payloadFormatter = this.contentFormatters[type || ContentType.Json]; + + return fetch(`${baseUrl || this.baseUrl || ""}${path}${queryString ? `?${queryString}` : ""}`, { + ...requestParams, + headers: { + ...(type && type !== ContentType.FormData ? { "Content-Type": type } : {}), + ...(requestParams.headers || {}), + }, + signal: cancelToken ? this.createAbortSignal(cancelToken) : void 0, + body: typeof body === "undefined" || body === null ? null : payloadFormatter(body), + }).then(async (response) => { + const r = response as HttpResponse; + r.data = (null as unknown) as T; + r.error = (null as unknown) as E; + + const data = await response[format]() + .then((data) => { + if (r.ok) { + r.data = data; + } else { + r.error = data; + } + return r; + }) + .catch((e) => { + r.error = e; + return r; + }); + + if (cancelToken) { + this.abortControllers.delete(cancelToken); + } + + if (!response.ok) throw data; + return data; + }); + }; +} + +/** + * @title cosmos/vesting/v1beta1/tx.proto + * @version version not set + */ +export class Api extends HttpClient {} diff --git a/ts-client/cosmos.vesting.v1beta1/types.ts b/ts-client/cosmos.vesting.v1beta1/types.ts new file mode 100755 index 00000000..cc45b951 --- /dev/null +++ b/ts-client/cosmos.vesting.v1beta1/types.ts @@ -0,0 +1,17 @@ +import { BaseVestingAccount } from "./types/cosmos/vesting/v1beta1/vesting" +import { ContinuousVestingAccount } from "./types/cosmos/vesting/v1beta1/vesting" +import { DelayedVestingAccount } from "./types/cosmos/vesting/v1beta1/vesting" +import { Period } from "./types/cosmos/vesting/v1beta1/vesting" +import { PeriodicVestingAccount } from "./types/cosmos/vesting/v1beta1/vesting" +import { PermanentLockedAccount } from "./types/cosmos/vesting/v1beta1/vesting" + + +export { + BaseVestingAccount, + ContinuousVestingAccount, + DelayedVestingAccount, + Period, + PeriodicVestingAccount, + PermanentLockedAccount, + + } \ No newline at end of file diff --git a/ts-client/cosmos.vesting.v1beta1/types/cosmos/auth/v1beta1/auth.ts b/ts-client/cosmos.vesting.v1beta1/types/cosmos/auth/v1beta1/auth.ts new file mode 100644 index 00000000..b09676a0 --- /dev/null +++ b/ts-client/cosmos.vesting.v1beta1/types/cosmos/auth/v1beta1/auth.ts @@ -0,0 +1,436 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; +import { Any } from "../../../google/protobuf/any"; + +export const protobufPackage = "cosmos.auth.v1beta1"; + +/** + * BaseAccount defines a base account type. It contains all the necessary fields + * for basic account functionality. Any custom account type should extend this + * type for additional functionality (e.g. vesting). + */ +export interface BaseAccount { + address: string; + pubKey: Any | undefined; + accountNumber: number; + sequence: number; +} + +/** ModuleAccount defines an account for modules that holds coins on a pool. */ +export interface ModuleAccount { + baseAccount: BaseAccount | undefined; + name: string; + permissions: string[]; +} + +/** Params defines the parameters for the auth module. */ +export interface Params { + maxMemoCharacters: number; + txSigLimit: number; + txSizeCostPerByte: number; + sigVerifyCostEd25519: number; + sigVerifyCostSecp256k1: number; +} + +const baseBaseAccount: object = { address: "", accountNumber: 0, sequence: 0 }; + +export const BaseAccount = { + encode(message: BaseAccount, writer: Writer = Writer.create()): Writer { + if (message.address !== "") { + writer.uint32(10).string(message.address); + } + if (message.pubKey !== undefined) { + Any.encode(message.pubKey, writer.uint32(18).fork()).ldelim(); + } + if (message.accountNumber !== 0) { + writer.uint32(24).uint64(message.accountNumber); + } + if (message.sequence !== 0) { + writer.uint32(32).uint64(message.sequence); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): BaseAccount { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseBaseAccount } as BaseAccount; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.address = reader.string(); + break; + case 2: + message.pubKey = Any.decode(reader, reader.uint32()); + break; + case 3: + message.accountNumber = longToNumber(reader.uint64() as Long); + break; + case 4: + message.sequence = longToNumber(reader.uint64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): BaseAccount { + const message = { ...baseBaseAccount } as BaseAccount; + if (object.address !== undefined && object.address !== null) { + message.address = String(object.address); + } else { + message.address = ""; + } + if (object.pubKey !== undefined && object.pubKey !== null) { + message.pubKey = Any.fromJSON(object.pubKey); + } else { + message.pubKey = undefined; + } + if (object.accountNumber !== undefined && object.accountNumber !== null) { + message.accountNumber = Number(object.accountNumber); + } else { + message.accountNumber = 0; + } + if (object.sequence !== undefined && object.sequence !== null) { + message.sequence = Number(object.sequence); + } else { + message.sequence = 0; + } + return message; + }, + + toJSON(message: BaseAccount): unknown { + const obj: any = {}; + message.address !== undefined && (obj.address = message.address); + message.pubKey !== undefined && + (obj.pubKey = message.pubKey ? Any.toJSON(message.pubKey) : undefined); + message.accountNumber !== undefined && + (obj.accountNumber = message.accountNumber); + message.sequence !== undefined && (obj.sequence = message.sequence); + return obj; + }, + + fromPartial(object: DeepPartial): BaseAccount { + const message = { ...baseBaseAccount } as BaseAccount; + if (object.address !== undefined && object.address !== null) { + message.address = object.address; + } else { + message.address = ""; + } + if (object.pubKey !== undefined && object.pubKey !== null) { + message.pubKey = Any.fromPartial(object.pubKey); + } else { + message.pubKey = undefined; + } + if (object.accountNumber !== undefined && object.accountNumber !== null) { + message.accountNumber = object.accountNumber; + } else { + message.accountNumber = 0; + } + if (object.sequence !== undefined && object.sequence !== null) { + message.sequence = object.sequence; + } else { + message.sequence = 0; + } + return message; + }, +}; + +const baseModuleAccount: object = { name: "", permissions: "" }; + +export const ModuleAccount = { + encode(message: ModuleAccount, writer: Writer = Writer.create()): Writer { + if (message.baseAccount !== undefined) { + BaseAccount.encode( + message.baseAccount, + writer.uint32(10).fork() + ).ldelim(); + } + if (message.name !== "") { + writer.uint32(18).string(message.name); + } + for (const v of message.permissions) { + writer.uint32(26).string(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ModuleAccount { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseModuleAccount } as ModuleAccount; + message.permissions = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.baseAccount = BaseAccount.decode(reader, reader.uint32()); + break; + case 2: + message.name = reader.string(); + break; + case 3: + message.permissions.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ModuleAccount { + const message = { ...baseModuleAccount } as ModuleAccount; + message.permissions = []; + if (object.baseAccount !== undefined && object.baseAccount !== null) { + message.baseAccount = BaseAccount.fromJSON(object.baseAccount); + } else { + message.baseAccount = undefined; + } + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.permissions !== undefined && object.permissions !== null) { + for (const e of object.permissions) { + message.permissions.push(String(e)); + } + } + return message; + }, + + toJSON(message: ModuleAccount): unknown { + const obj: any = {}; + message.baseAccount !== undefined && + (obj.baseAccount = message.baseAccount + ? BaseAccount.toJSON(message.baseAccount) + : undefined); + message.name !== undefined && (obj.name = message.name); + if (message.permissions) { + obj.permissions = message.permissions.map((e) => e); + } else { + obj.permissions = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): ModuleAccount { + const message = { ...baseModuleAccount } as ModuleAccount; + message.permissions = []; + if (object.baseAccount !== undefined && object.baseAccount !== null) { + message.baseAccount = BaseAccount.fromPartial(object.baseAccount); + } else { + message.baseAccount = undefined; + } + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.permissions !== undefined && object.permissions !== null) { + for (const e of object.permissions) { + message.permissions.push(e); + } + } + return message; + }, +}; + +const baseParams: object = { + maxMemoCharacters: 0, + txSigLimit: 0, + txSizeCostPerByte: 0, + sigVerifyCostEd25519: 0, + sigVerifyCostSecp256k1: 0, +}; + +export const Params = { + encode(message: Params, writer: Writer = Writer.create()): Writer { + if (message.maxMemoCharacters !== 0) { + writer.uint32(8).uint64(message.maxMemoCharacters); + } + if (message.txSigLimit !== 0) { + writer.uint32(16).uint64(message.txSigLimit); + } + if (message.txSizeCostPerByte !== 0) { + writer.uint32(24).uint64(message.txSizeCostPerByte); + } + if (message.sigVerifyCostEd25519 !== 0) { + writer.uint32(32).uint64(message.sigVerifyCostEd25519); + } + if (message.sigVerifyCostSecp256k1 !== 0) { + writer.uint32(40).uint64(message.sigVerifyCostSecp256k1); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Params { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseParams } as Params; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.maxMemoCharacters = longToNumber(reader.uint64() as Long); + break; + case 2: + message.txSigLimit = longToNumber(reader.uint64() as Long); + break; + case 3: + message.txSizeCostPerByte = longToNumber(reader.uint64() as Long); + break; + case 4: + message.sigVerifyCostEd25519 = longToNumber(reader.uint64() as Long); + break; + case 5: + message.sigVerifyCostSecp256k1 = longToNumber( + reader.uint64() as Long + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Params { + const message = { ...baseParams } as Params; + if ( + object.maxMemoCharacters !== undefined && + object.maxMemoCharacters !== null + ) { + message.maxMemoCharacters = Number(object.maxMemoCharacters); + } else { + message.maxMemoCharacters = 0; + } + if (object.txSigLimit !== undefined && object.txSigLimit !== null) { + message.txSigLimit = Number(object.txSigLimit); + } else { + message.txSigLimit = 0; + } + if ( + object.txSizeCostPerByte !== undefined && + object.txSizeCostPerByte !== null + ) { + message.txSizeCostPerByte = Number(object.txSizeCostPerByte); + } else { + message.txSizeCostPerByte = 0; + } + if ( + object.sigVerifyCostEd25519 !== undefined && + object.sigVerifyCostEd25519 !== null + ) { + message.sigVerifyCostEd25519 = Number(object.sigVerifyCostEd25519); + } else { + message.sigVerifyCostEd25519 = 0; + } + if ( + object.sigVerifyCostSecp256k1 !== undefined && + object.sigVerifyCostSecp256k1 !== null + ) { + message.sigVerifyCostSecp256k1 = Number(object.sigVerifyCostSecp256k1); + } else { + message.sigVerifyCostSecp256k1 = 0; + } + return message; + }, + + toJSON(message: Params): unknown { + const obj: any = {}; + message.maxMemoCharacters !== undefined && + (obj.maxMemoCharacters = message.maxMemoCharacters); + message.txSigLimit !== undefined && (obj.txSigLimit = message.txSigLimit); + message.txSizeCostPerByte !== undefined && + (obj.txSizeCostPerByte = message.txSizeCostPerByte); + message.sigVerifyCostEd25519 !== undefined && + (obj.sigVerifyCostEd25519 = message.sigVerifyCostEd25519); + message.sigVerifyCostSecp256k1 !== undefined && + (obj.sigVerifyCostSecp256k1 = message.sigVerifyCostSecp256k1); + return obj; + }, + + fromPartial(object: DeepPartial): Params { + const message = { ...baseParams } as Params; + if ( + object.maxMemoCharacters !== undefined && + object.maxMemoCharacters !== null + ) { + message.maxMemoCharacters = object.maxMemoCharacters; + } else { + message.maxMemoCharacters = 0; + } + if (object.txSigLimit !== undefined && object.txSigLimit !== null) { + message.txSigLimit = object.txSigLimit; + } else { + message.txSigLimit = 0; + } + if ( + object.txSizeCostPerByte !== undefined && + object.txSizeCostPerByte !== null + ) { + message.txSizeCostPerByte = object.txSizeCostPerByte; + } else { + message.txSizeCostPerByte = 0; + } + if ( + object.sigVerifyCostEd25519 !== undefined && + object.sigVerifyCostEd25519 !== null + ) { + message.sigVerifyCostEd25519 = object.sigVerifyCostEd25519; + } else { + message.sigVerifyCostEd25519 = 0; + } + if ( + object.sigVerifyCostSecp256k1 !== undefined && + object.sigVerifyCostSecp256k1 !== null + ) { + message.sigVerifyCostSecp256k1 = object.sigVerifyCostSecp256k1; + } else { + message.sigVerifyCostSecp256k1 = 0; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/cosmos.vesting.v1beta1/types/cosmos/base/v1beta1/coin.ts b/ts-client/cosmos.vesting.v1beta1/types/cosmos/base/v1beta1/coin.ts new file mode 100644 index 00000000..ce2ac984 --- /dev/null +++ b/ts-client/cosmos.vesting.v1beta1/types/cosmos/base/v1beta1/coin.ts @@ -0,0 +1,301 @@ +/* eslint-disable */ +import { Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "cosmos.base.v1beta1"; + +/** + * Coin defines a token with a denomination and an amount. + * + * NOTE: The amount field is an Int which implements the custom method + * signatures required by gogoproto. + */ +export interface Coin { + denom: string; + amount: string; +} + +/** + * DecCoin defines a token with a denomination and a decimal amount. + * + * NOTE: The amount field is an Dec which implements the custom method + * signatures required by gogoproto. + */ +export interface DecCoin { + denom: string; + amount: string; +} + +/** IntProto defines a Protobuf wrapper around an Int object. */ +export interface IntProto { + int: string; +} + +/** DecProto defines a Protobuf wrapper around a Dec object. */ +export interface DecProto { + dec: string; +} + +const baseCoin: object = { denom: "", amount: "" }; + +export const Coin = { + encode(message: Coin, writer: Writer = Writer.create()): Writer { + if (message.denom !== "") { + writer.uint32(10).string(message.denom); + } + if (message.amount !== "") { + writer.uint32(18).string(message.amount); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Coin { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseCoin } as Coin; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.denom = reader.string(); + break; + case 2: + message.amount = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Coin { + const message = { ...baseCoin } as Coin; + if (object.denom !== undefined && object.denom !== null) { + message.denom = String(object.denom); + } else { + message.denom = ""; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = String(object.amount); + } else { + message.amount = ""; + } + return message; + }, + + toJSON(message: Coin): unknown { + const obj: any = {}; + message.denom !== undefined && (obj.denom = message.denom); + message.amount !== undefined && (obj.amount = message.amount); + return obj; + }, + + fromPartial(object: DeepPartial): Coin { + const message = { ...baseCoin } as Coin; + if (object.denom !== undefined && object.denom !== null) { + message.denom = object.denom; + } else { + message.denom = ""; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = object.amount; + } else { + message.amount = ""; + } + return message; + }, +}; + +const baseDecCoin: object = { denom: "", amount: "" }; + +export const DecCoin = { + encode(message: DecCoin, writer: Writer = Writer.create()): Writer { + if (message.denom !== "") { + writer.uint32(10).string(message.denom); + } + if (message.amount !== "") { + writer.uint32(18).string(message.amount); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): DecCoin { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseDecCoin } as DecCoin; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.denom = reader.string(); + break; + case 2: + message.amount = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DecCoin { + const message = { ...baseDecCoin } as DecCoin; + if (object.denom !== undefined && object.denom !== null) { + message.denom = String(object.denom); + } else { + message.denom = ""; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = String(object.amount); + } else { + message.amount = ""; + } + return message; + }, + + toJSON(message: DecCoin): unknown { + const obj: any = {}; + message.denom !== undefined && (obj.denom = message.denom); + message.amount !== undefined && (obj.amount = message.amount); + return obj; + }, + + fromPartial(object: DeepPartial): DecCoin { + const message = { ...baseDecCoin } as DecCoin; + if (object.denom !== undefined && object.denom !== null) { + message.denom = object.denom; + } else { + message.denom = ""; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = object.amount; + } else { + message.amount = ""; + } + return message; + }, +}; + +const baseIntProto: object = { int: "" }; + +export const IntProto = { + encode(message: IntProto, writer: Writer = Writer.create()): Writer { + if (message.int !== "") { + writer.uint32(10).string(message.int); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): IntProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseIntProto } as IntProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.int = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): IntProto { + const message = { ...baseIntProto } as IntProto; + if (object.int !== undefined && object.int !== null) { + message.int = String(object.int); + } else { + message.int = ""; + } + return message; + }, + + toJSON(message: IntProto): unknown { + const obj: any = {}; + message.int !== undefined && (obj.int = message.int); + return obj; + }, + + fromPartial(object: DeepPartial): IntProto { + const message = { ...baseIntProto } as IntProto; + if (object.int !== undefined && object.int !== null) { + message.int = object.int; + } else { + message.int = ""; + } + return message; + }, +}; + +const baseDecProto: object = { dec: "" }; + +export const DecProto = { + encode(message: DecProto, writer: Writer = Writer.create()): Writer { + if (message.dec !== "") { + writer.uint32(10).string(message.dec); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): DecProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseDecProto } as DecProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.dec = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DecProto { + const message = { ...baseDecProto } as DecProto; + if (object.dec !== undefined && object.dec !== null) { + message.dec = String(object.dec); + } else { + message.dec = ""; + } + return message; + }, + + toJSON(message: DecProto): unknown { + const obj: any = {}; + message.dec !== undefined && (obj.dec = message.dec); + return obj; + }, + + fromPartial(object: DeepPartial): DecProto { + const message = { ...baseDecProto } as DecProto; + if (object.dec !== undefined && object.dec !== null) { + message.dec = object.dec; + } else { + message.dec = ""; + } + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/cosmos.vesting.v1beta1/types/cosmos/vesting/v1beta1/tx.ts b/ts-client/cosmos.vesting.v1beta1/types/cosmos/vesting/v1beta1/tx.ts new file mode 100644 index 00000000..d5acd7d5 --- /dev/null +++ b/ts-client/cosmos.vesting.v1beta1/types/cosmos/vesting/v1beta1/tx.ts @@ -0,0 +1,292 @@ +/* eslint-disable */ +import { Reader, util, configure, Writer } from "protobufjs/minimal"; +import * as Long from "long"; +import { Coin } from "../../../cosmos/base/v1beta1/coin"; + +export const protobufPackage = "cosmos.vesting.v1beta1"; + +/** + * MsgCreateVestingAccount defines a message that enables creating a vesting + * account. + */ +export interface MsgCreateVestingAccount { + fromAddress: string; + toAddress: string; + amount: Coin[]; + endTime: number; + delayed: boolean; +} + +/** MsgCreateVestingAccountResponse defines the Msg/CreateVestingAccount response type. */ +export interface MsgCreateVestingAccountResponse {} + +const baseMsgCreateVestingAccount: object = { + fromAddress: "", + toAddress: "", + endTime: 0, + delayed: false, +}; + +export const MsgCreateVestingAccount = { + encode( + message: MsgCreateVestingAccount, + writer: Writer = Writer.create() + ): Writer { + if (message.fromAddress !== "") { + writer.uint32(10).string(message.fromAddress); + } + if (message.toAddress !== "") { + writer.uint32(18).string(message.toAddress); + } + for (const v of message.amount) { + Coin.encode(v!, writer.uint32(26).fork()).ldelim(); + } + if (message.endTime !== 0) { + writer.uint32(32).int64(message.endTime); + } + if (message.delayed === true) { + writer.uint32(40).bool(message.delayed); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MsgCreateVestingAccount { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseMsgCreateVestingAccount, + } as MsgCreateVestingAccount; + message.amount = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.fromAddress = reader.string(); + break; + case 2: + message.toAddress = reader.string(); + break; + case 3: + message.amount.push(Coin.decode(reader, reader.uint32())); + break; + case 4: + message.endTime = longToNumber(reader.int64() as Long); + break; + case 5: + message.delayed = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgCreateVestingAccount { + const message = { + ...baseMsgCreateVestingAccount, + } as MsgCreateVestingAccount; + message.amount = []; + if (object.fromAddress !== undefined && object.fromAddress !== null) { + message.fromAddress = String(object.fromAddress); + } else { + message.fromAddress = ""; + } + if (object.toAddress !== undefined && object.toAddress !== null) { + message.toAddress = String(object.toAddress); + } else { + message.toAddress = ""; + } + if (object.amount !== undefined && object.amount !== null) { + for (const e of object.amount) { + message.amount.push(Coin.fromJSON(e)); + } + } + if (object.endTime !== undefined && object.endTime !== null) { + message.endTime = Number(object.endTime); + } else { + message.endTime = 0; + } + if (object.delayed !== undefined && object.delayed !== null) { + message.delayed = Boolean(object.delayed); + } else { + message.delayed = false; + } + return message; + }, + + toJSON(message: MsgCreateVestingAccount): unknown { + const obj: any = {}; + message.fromAddress !== undefined && + (obj.fromAddress = message.fromAddress); + message.toAddress !== undefined && (obj.toAddress = message.toAddress); + if (message.amount) { + obj.amount = message.amount.map((e) => (e ? Coin.toJSON(e) : undefined)); + } else { + obj.amount = []; + } + message.endTime !== undefined && (obj.endTime = message.endTime); + message.delayed !== undefined && (obj.delayed = message.delayed); + return obj; + }, + + fromPartial( + object: DeepPartial + ): MsgCreateVestingAccount { + const message = { + ...baseMsgCreateVestingAccount, + } as MsgCreateVestingAccount; + message.amount = []; + if (object.fromAddress !== undefined && object.fromAddress !== null) { + message.fromAddress = object.fromAddress; + } else { + message.fromAddress = ""; + } + if (object.toAddress !== undefined && object.toAddress !== null) { + message.toAddress = object.toAddress; + } else { + message.toAddress = ""; + } + if (object.amount !== undefined && object.amount !== null) { + for (const e of object.amount) { + message.amount.push(Coin.fromPartial(e)); + } + } + if (object.endTime !== undefined && object.endTime !== null) { + message.endTime = object.endTime; + } else { + message.endTime = 0; + } + if (object.delayed !== undefined && object.delayed !== null) { + message.delayed = object.delayed; + } else { + message.delayed = false; + } + return message; + }, +}; + +const baseMsgCreateVestingAccountResponse: object = {}; + +export const MsgCreateVestingAccountResponse = { + encode( + _: MsgCreateVestingAccountResponse, + writer: Writer = Writer.create() + ): Writer { + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): MsgCreateVestingAccountResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseMsgCreateVestingAccountResponse, + } as MsgCreateVestingAccountResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): MsgCreateVestingAccountResponse { + const message = { + ...baseMsgCreateVestingAccountResponse, + } as MsgCreateVestingAccountResponse; + return message; + }, + + toJSON(_: MsgCreateVestingAccountResponse): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial( + _: DeepPartial + ): MsgCreateVestingAccountResponse { + const message = { + ...baseMsgCreateVestingAccountResponse, + } as MsgCreateVestingAccountResponse; + return message; + }, +}; + +/** Msg defines the bank Msg service. */ +export interface Msg { + /** + * CreateVestingAccount defines a method that enables creating a vesting + * account. + */ + CreateVestingAccount( + request: MsgCreateVestingAccount + ): Promise; +} + +export class MsgClientImpl implements Msg { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + } + CreateVestingAccount( + request: MsgCreateVestingAccount + ): Promise { + const data = MsgCreateVestingAccount.encode(request).finish(); + const promise = this.rpc.request( + "cosmos.vesting.v1beta1.Msg", + "CreateVestingAccount", + data + ); + return promise.then((data) => + MsgCreateVestingAccountResponse.decode(new Reader(data)) + ); + } +} + +interface Rpc { + request( + service: string, + method: string, + data: Uint8Array + ): Promise; +} + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/cosmos.vesting.v1beta1/types/cosmos/vesting/v1beta1/vesting.ts b/ts-client/cosmos.vesting.v1beta1/types/cosmos/vesting/v1beta1/vesting.ts new file mode 100644 index 00000000..0cd306dc --- /dev/null +++ b/ts-client/cosmos.vesting.v1beta1/types/cosmos/vesting/v1beta1/vesting.ts @@ -0,0 +1,732 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; +import { BaseAccount } from "../../../cosmos/auth/v1beta1/auth"; +import { Coin } from "../../../cosmos/base/v1beta1/coin"; + +export const protobufPackage = "cosmos.vesting.v1beta1"; + +/** + * BaseVestingAccount implements the VestingAccount interface. It contains all + * the necessary fields needed for any vesting account implementation. + */ +export interface BaseVestingAccount { + baseAccount: BaseAccount | undefined; + originalVesting: Coin[]; + delegatedFree: Coin[]; + delegatedVesting: Coin[]; + endTime: number; +} + +/** + * ContinuousVestingAccount implements the VestingAccount interface. It + * continuously vests by unlocking coins linearly with respect to time. + */ +export interface ContinuousVestingAccount { + baseVestingAccount: BaseVestingAccount | undefined; + startTime: number; +} + +/** + * DelayedVestingAccount implements the VestingAccount interface. It vests all + * coins after a specific time, but non prior. In other words, it keeps them + * locked until a specified time. + */ +export interface DelayedVestingAccount { + baseVestingAccount: BaseVestingAccount | undefined; +} + +/** Period defines a length of time and amount of coins that will vest. */ +export interface Period { + length: number; + amount: Coin[]; +} + +/** + * PeriodicVestingAccount implements the VestingAccount interface. It + * periodically vests by unlocking coins during each specified period. + */ +export interface PeriodicVestingAccount { + baseVestingAccount: BaseVestingAccount | undefined; + startTime: number; + vestingPeriods: Period[]; +} + +/** + * PermanentLockedAccount implements the VestingAccount interface. It does + * not ever release coins, locking them indefinitely. Coins in this account can + * still be used for delegating and for governance votes even while locked. + * + * Since: cosmos-sdk 0.43 + */ +export interface PermanentLockedAccount { + baseVestingAccount: BaseVestingAccount | undefined; +} + +const baseBaseVestingAccount: object = { endTime: 0 }; + +export const BaseVestingAccount = { + encode( + message: BaseVestingAccount, + writer: Writer = Writer.create() + ): Writer { + if (message.baseAccount !== undefined) { + BaseAccount.encode( + message.baseAccount, + writer.uint32(10).fork() + ).ldelim(); + } + for (const v of message.originalVesting) { + Coin.encode(v!, writer.uint32(18).fork()).ldelim(); + } + for (const v of message.delegatedFree) { + Coin.encode(v!, writer.uint32(26).fork()).ldelim(); + } + for (const v of message.delegatedVesting) { + Coin.encode(v!, writer.uint32(34).fork()).ldelim(); + } + if (message.endTime !== 0) { + writer.uint32(40).int64(message.endTime); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): BaseVestingAccount { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseBaseVestingAccount } as BaseVestingAccount; + message.originalVesting = []; + message.delegatedFree = []; + message.delegatedVesting = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.baseAccount = BaseAccount.decode(reader, reader.uint32()); + break; + case 2: + message.originalVesting.push(Coin.decode(reader, reader.uint32())); + break; + case 3: + message.delegatedFree.push(Coin.decode(reader, reader.uint32())); + break; + case 4: + message.delegatedVesting.push(Coin.decode(reader, reader.uint32())); + break; + case 5: + message.endTime = longToNumber(reader.int64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): BaseVestingAccount { + const message = { ...baseBaseVestingAccount } as BaseVestingAccount; + message.originalVesting = []; + message.delegatedFree = []; + message.delegatedVesting = []; + if (object.baseAccount !== undefined && object.baseAccount !== null) { + message.baseAccount = BaseAccount.fromJSON(object.baseAccount); + } else { + message.baseAccount = undefined; + } + if ( + object.originalVesting !== undefined && + object.originalVesting !== null + ) { + for (const e of object.originalVesting) { + message.originalVesting.push(Coin.fromJSON(e)); + } + } + if (object.delegatedFree !== undefined && object.delegatedFree !== null) { + for (const e of object.delegatedFree) { + message.delegatedFree.push(Coin.fromJSON(e)); + } + } + if ( + object.delegatedVesting !== undefined && + object.delegatedVesting !== null + ) { + for (const e of object.delegatedVesting) { + message.delegatedVesting.push(Coin.fromJSON(e)); + } + } + if (object.endTime !== undefined && object.endTime !== null) { + message.endTime = Number(object.endTime); + } else { + message.endTime = 0; + } + return message; + }, + + toJSON(message: BaseVestingAccount): unknown { + const obj: any = {}; + message.baseAccount !== undefined && + (obj.baseAccount = message.baseAccount + ? BaseAccount.toJSON(message.baseAccount) + : undefined); + if (message.originalVesting) { + obj.originalVesting = message.originalVesting.map((e) => + e ? Coin.toJSON(e) : undefined + ); + } else { + obj.originalVesting = []; + } + if (message.delegatedFree) { + obj.delegatedFree = message.delegatedFree.map((e) => + e ? Coin.toJSON(e) : undefined + ); + } else { + obj.delegatedFree = []; + } + if (message.delegatedVesting) { + obj.delegatedVesting = message.delegatedVesting.map((e) => + e ? Coin.toJSON(e) : undefined + ); + } else { + obj.delegatedVesting = []; + } + message.endTime !== undefined && (obj.endTime = message.endTime); + return obj; + }, + + fromPartial(object: DeepPartial): BaseVestingAccount { + const message = { ...baseBaseVestingAccount } as BaseVestingAccount; + message.originalVesting = []; + message.delegatedFree = []; + message.delegatedVesting = []; + if (object.baseAccount !== undefined && object.baseAccount !== null) { + message.baseAccount = BaseAccount.fromPartial(object.baseAccount); + } else { + message.baseAccount = undefined; + } + if ( + object.originalVesting !== undefined && + object.originalVesting !== null + ) { + for (const e of object.originalVesting) { + message.originalVesting.push(Coin.fromPartial(e)); + } + } + if (object.delegatedFree !== undefined && object.delegatedFree !== null) { + for (const e of object.delegatedFree) { + message.delegatedFree.push(Coin.fromPartial(e)); + } + } + if ( + object.delegatedVesting !== undefined && + object.delegatedVesting !== null + ) { + for (const e of object.delegatedVesting) { + message.delegatedVesting.push(Coin.fromPartial(e)); + } + } + if (object.endTime !== undefined && object.endTime !== null) { + message.endTime = object.endTime; + } else { + message.endTime = 0; + } + return message; + }, +}; + +const baseContinuousVestingAccount: object = { startTime: 0 }; + +export const ContinuousVestingAccount = { + encode( + message: ContinuousVestingAccount, + writer: Writer = Writer.create() + ): Writer { + if (message.baseVestingAccount !== undefined) { + BaseVestingAccount.encode( + message.baseVestingAccount, + writer.uint32(10).fork() + ).ldelim(); + } + if (message.startTime !== 0) { + writer.uint32(16).int64(message.startTime); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): ContinuousVestingAccount { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseContinuousVestingAccount, + } as ContinuousVestingAccount; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.baseVestingAccount = BaseVestingAccount.decode( + reader, + reader.uint32() + ); + break; + case 2: + message.startTime = longToNumber(reader.int64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ContinuousVestingAccount { + const message = { + ...baseContinuousVestingAccount, + } as ContinuousVestingAccount; + if ( + object.baseVestingAccount !== undefined && + object.baseVestingAccount !== null + ) { + message.baseVestingAccount = BaseVestingAccount.fromJSON( + object.baseVestingAccount + ); + } else { + message.baseVestingAccount = undefined; + } + if (object.startTime !== undefined && object.startTime !== null) { + message.startTime = Number(object.startTime); + } else { + message.startTime = 0; + } + return message; + }, + + toJSON(message: ContinuousVestingAccount): unknown { + const obj: any = {}; + message.baseVestingAccount !== undefined && + (obj.baseVestingAccount = message.baseVestingAccount + ? BaseVestingAccount.toJSON(message.baseVestingAccount) + : undefined); + message.startTime !== undefined && (obj.startTime = message.startTime); + return obj; + }, + + fromPartial( + object: DeepPartial + ): ContinuousVestingAccount { + const message = { + ...baseContinuousVestingAccount, + } as ContinuousVestingAccount; + if ( + object.baseVestingAccount !== undefined && + object.baseVestingAccount !== null + ) { + message.baseVestingAccount = BaseVestingAccount.fromPartial( + object.baseVestingAccount + ); + } else { + message.baseVestingAccount = undefined; + } + if (object.startTime !== undefined && object.startTime !== null) { + message.startTime = object.startTime; + } else { + message.startTime = 0; + } + return message; + }, +}; + +const baseDelayedVestingAccount: object = {}; + +export const DelayedVestingAccount = { + encode( + message: DelayedVestingAccount, + writer: Writer = Writer.create() + ): Writer { + if (message.baseVestingAccount !== undefined) { + BaseVestingAccount.encode( + message.baseVestingAccount, + writer.uint32(10).fork() + ).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): DelayedVestingAccount { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseDelayedVestingAccount } as DelayedVestingAccount; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.baseVestingAccount = BaseVestingAccount.decode( + reader, + reader.uint32() + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DelayedVestingAccount { + const message = { ...baseDelayedVestingAccount } as DelayedVestingAccount; + if ( + object.baseVestingAccount !== undefined && + object.baseVestingAccount !== null + ) { + message.baseVestingAccount = BaseVestingAccount.fromJSON( + object.baseVestingAccount + ); + } else { + message.baseVestingAccount = undefined; + } + return message; + }, + + toJSON(message: DelayedVestingAccount): unknown { + const obj: any = {}; + message.baseVestingAccount !== undefined && + (obj.baseVestingAccount = message.baseVestingAccount + ? BaseVestingAccount.toJSON(message.baseVestingAccount) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): DelayedVestingAccount { + const message = { ...baseDelayedVestingAccount } as DelayedVestingAccount; + if ( + object.baseVestingAccount !== undefined && + object.baseVestingAccount !== null + ) { + message.baseVestingAccount = BaseVestingAccount.fromPartial( + object.baseVestingAccount + ); + } else { + message.baseVestingAccount = undefined; + } + return message; + }, +}; + +const basePeriod: object = { length: 0 }; + +export const Period = { + encode(message: Period, writer: Writer = Writer.create()): Writer { + if (message.length !== 0) { + writer.uint32(8).int64(message.length); + } + for (const v of message.amount) { + Coin.encode(v!, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Period { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...basePeriod } as Period; + message.amount = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.length = longToNumber(reader.int64() as Long); + break; + case 2: + message.amount.push(Coin.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Period { + const message = { ...basePeriod } as Period; + message.amount = []; + if (object.length !== undefined && object.length !== null) { + message.length = Number(object.length); + } else { + message.length = 0; + } + if (object.amount !== undefined && object.amount !== null) { + for (const e of object.amount) { + message.amount.push(Coin.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: Period): unknown { + const obj: any = {}; + message.length !== undefined && (obj.length = message.length); + if (message.amount) { + obj.amount = message.amount.map((e) => (e ? Coin.toJSON(e) : undefined)); + } else { + obj.amount = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): Period { + const message = { ...basePeriod } as Period; + message.amount = []; + if (object.length !== undefined && object.length !== null) { + message.length = object.length; + } else { + message.length = 0; + } + if (object.amount !== undefined && object.amount !== null) { + for (const e of object.amount) { + message.amount.push(Coin.fromPartial(e)); + } + } + return message; + }, +}; + +const basePeriodicVestingAccount: object = { startTime: 0 }; + +export const PeriodicVestingAccount = { + encode( + message: PeriodicVestingAccount, + writer: Writer = Writer.create() + ): Writer { + if (message.baseVestingAccount !== undefined) { + BaseVestingAccount.encode( + message.baseVestingAccount, + writer.uint32(10).fork() + ).ldelim(); + } + if (message.startTime !== 0) { + writer.uint32(16).int64(message.startTime); + } + for (const v of message.vestingPeriods) { + Period.encode(v!, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): PeriodicVestingAccount { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...basePeriodicVestingAccount } as PeriodicVestingAccount; + message.vestingPeriods = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.baseVestingAccount = BaseVestingAccount.decode( + reader, + reader.uint32() + ); + break; + case 2: + message.startTime = longToNumber(reader.int64() as Long); + break; + case 3: + message.vestingPeriods.push(Period.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): PeriodicVestingAccount { + const message = { ...basePeriodicVestingAccount } as PeriodicVestingAccount; + message.vestingPeriods = []; + if ( + object.baseVestingAccount !== undefined && + object.baseVestingAccount !== null + ) { + message.baseVestingAccount = BaseVestingAccount.fromJSON( + object.baseVestingAccount + ); + } else { + message.baseVestingAccount = undefined; + } + if (object.startTime !== undefined && object.startTime !== null) { + message.startTime = Number(object.startTime); + } else { + message.startTime = 0; + } + if (object.vestingPeriods !== undefined && object.vestingPeriods !== null) { + for (const e of object.vestingPeriods) { + message.vestingPeriods.push(Period.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: PeriodicVestingAccount): unknown { + const obj: any = {}; + message.baseVestingAccount !== undefined && + (obj.baseVestingAccount = message.baseVestingAccount + ? BaseVestingAccount.toJSON(message.baseVestingAccount) + : undefined); + message.startTime !== undefined && (obj.startTime = message.startTime); + if (message.vestingPeriods) { + obj.vestingPeriods = message.vestingPeriods.map((e) => + e ? Period.toJSON(e) : undefined + ); + } else { + obj.vestingPeriods = []; + } + return obj; + }, + + fromPartial( + object: DeepPartial + ): PeriodicVestingAccount { + const message = { ...basePeriodicVestingAccount } as PeriodicVestingAccount; + message.vestingPeriods = []; + if ( + object.baseVestingAccount !== undefined && + object.baseVestingAccount !== null + ) { + message.baseVestingAccount = BaseVestingAccount.fromPartial( + object.baseVestingAccount + ); + } else { + message.baseVestingAccount = undefined; + } + if (object.startTime !== undefined && object.startTime !== null) { + message.startTime = object.startTime; + } else { + message.startTime = 0; + } + if (object.vestingPeriods !== undefined && object.vestingPeriods !== null) { + for (const e of object.vestingPeriods) { + message.vestingPeriods.push(Period.fromPartial(e)); + } + } + return message; + }, +}; + +const basePermanentLockedAccount: object = {}; + +export const PermanentLockedAccount = { + encode( + message: PermanentLockedAccount, + writer: Writer = Writer.create() + ): Writer { + if (message.baseVestingAccount !== undefined) { + BaseVestingAccount.encode( + message.baseVestingAccount, + writer.uint32(10).fork() + ).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): PermanentLockedAccount { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...basePermanentLockedAccount } as PermanentLockedAccount; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.baseVestingAccount = BaseVestingAccount.decode( + reader, + reader.uint32() + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): PermanentLockedAccount { + const message = { ...basePermanentLockedAccount } as PermanentLockedAccount; + if ( + object.baseVestingAccount !== undefined && + object.baseVestingAccount !== null + ) { + message.baseVestingAccount = BaseVestingAccount.fromJSON( + object.baseVestingAccount + ); + } else { + message.baseVestingAccount = undefined; + } + return message; + }, + + toJSON(message: PermanentLockedAccount): unknown { + const obj: any = {}; + message.baseVestingAccount !== undefined && + (obj.baseVestingAccount = message.baseVestingAccount + ? BaseVestingAccount.toJSON(message.baseVestingAccount) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): PermanentLockedAccount { + const message = { ...basePermanentLockedAccount } as PermanentLockedAccount; + if ( + object.baseVestingAccount !== undefined && + object.baseVestingAccount !== null + ) { + message.baseVestingAccount = BaseVestingAccount.fromPartial( + object.baseVestingAccount + ); + } else { + message.baseVestingAccount = undefined; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/cosmos.vesting.v1beta1/types/cosmos_proto/cosmos.ts b/ts-client/cosmos.vesting.v1beta1/types/cosmos_proto/cosmos.ts new file mode 100644 index 00000000..9ec67a12 --- /dev/null +++ b/ts-client/cosmos.vesting.v1beta1/types/cosmos_proto/cosmos.ts @@ -0,0 +1,2 @@ +/* eslint-disable */ +export const protobufPackage = "cosmos_proto"; diff --git a/ts-client/cosmos.vesting.v1beta1/types/gogoproto/gogo.ts b/ts-client/cosmos.vesting.v1beta1/types/gogoproto/gogo.ts new file mode 100644 index 00000000..3f41a047 --- /dev/null +++ b/ts-client/cosmos.vesting.v1beta1/types/gogoproto/gogo.ts @@ -0,0 +1,2 @@ +/* eslint-disable */ +export const protobufPackage = "gogoproto"; diff --git a/ts-client/cosmos.vesting.v1beta1/types/google/protobuf/any.ts b/ts-client/cosmos.vesting.v1beta1/types/google/protobuf/any.ts new file mode 100644 index 00000000..b137a629 --- /dev/null +++ b/ts-client/cosmos.vesting.v1beta1/types/google/protobuf/any.ts @@ -0,0 +1,240 @@ +/* eslint-disable */ +import { Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "google.protobuf"; + +/** + * `Any` contains an arbitrary serialized protocol buffer message along with a + * URL that describes the type of the serialized message. + * + * Protobuf library provides support to pack/unpack Any values in the form + * of utility functions or additional generated methods of the Any type. + * + * Example 1: Pack and unpack a message in C++. + * + * Foo foo = ...; + * Any any; + * any.PackFrom(foo); + * ... + * if (any.UnpackTo(&foo)) { + * ... + * } + * + * Example 2: Pack and unpack a message in Java. + * + * Foo foo = ...; + * Any any = Any.pack(foo); + * ... + * if (any.is(Foo.class)) { + * foo = any.unpack(Foo.class); + * } + * + * Example 3: Pack and unpack a message in Python. + * + * foo = Foo(...) + * any = Any() + * any.Pack(foo) + * ... + * if any.Is(Foo.DESCRIPTOR): + * any.Unpack(foo) + * ... + * + * Example 4: Pack and unpack a message in Go + * + * foo := &pb.Foo{...} + * any, err := anypb.New(foo) + * if err != nil { + * ... + * } + * ... + * foo := &pb.Foo{} + * if err := any.UnmarshalTo(foo); err != nil { + * ... + * } + * + * The pack methods provided by protobuf library will by default use + * 'type.googleapis.com/full.type.name' as the type URL and the unpack + * methods only use the fully qualified type name after the last '/' + * in the type URL, for example "foo.bar.com/x/y.z" will yield type + * name "y.z". + * + * + * JSON + * ==== + * The JSON representation of an `Any` value uses the regular + * representation of the deserialized, embedded message, with an + * additional field `@type` which contains the type URL. Example: + * + * package google.profile; + * message Person { + * string first_name = 1; + * string last_name = 2; + * } + * + * { + * "@type": "type.googleapis.com/google.profile.Person", + * "firstName": , + * "lastName": + * } + * + * If the embedded message type is well-known and has a custom JSON + * representation, that representation will be embedded adding a field + * `value` which holds the custom JSON in addition to the `@type` + * field. Example (for message [google.protobuf.Duration][]): + * + * { + * "@type": "type.googleapis.com/google.protobuf.Duration", + * "value": "1.212s" + * } + */ +export interface Any { + /** + * A URL/resource name that uniquely identifies the type of the serialized + * protocol buffer message. This string must contain at least + * one "/" character. The last segment of the URL's path must represent + * the fully qualified name of the type (as in + * `path/google.protobuf.Duration`). The name should be in a canonical form + * (e.g., leading "." is not accepted). + * + * In practice, teams usually precompile into the binary all types that they + * expect it to use in the context of Any. However, for URLs which use the + * scheme `http`, `https`, or no scheme, one can optionally set up a type + * server that maps type URLs to message definitions as follows: + * + * * If no scheme is provided, `https` is assumed. + * * An HTTP GET on the URL must yield a [google.protobuf.Type][] + * value in binary format, or produce an error. + * * Applications are allowed to cache lookup results based on the + * URL, or have them precompiled into a binary to avoid any + * lookup. Therefore, binary compatibility needs to be preserved + * on changes to types. (Use versioned type names to manage + * breaking changes.) + * + * Note: this functionality is not currently available in the official + * protobuf release, and it is not used for type URLs beginning with + * type.googleapis.com. + * + * Schemes other than `http`, `https` (or the empty scheme) might be + * used with implementation specific semantics. + */ + typeUrl: string; + /** Must be a valid serialized protocol buffer of the above specified type. */ + value: Uint8Array; +} + +const baseAny: object = { typeUrl: "" }; + +export const Any = { + encode(message: Any, writer: Writer = Writer.create()): Writer { + if (message.typeUrl !== "") { + writer.uint32(10).string(message.typeUrl); + } + if (message.value.length !== 0) { + writer.uint32(18).bytes(message.value); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Any { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseAny } as Any; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.typeUrl = reader.string(); + break; + case 2: + message.value = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Any { + const message = { ...baseAny } as Any; + if (object.typeUrl !== undefined && object.typeUrl !== null) { + message.typeUrl = String(object.typeUrl); + } else { + message.typeUrl = ""; + } + if (object.value !== undefined && object.value !== null) { + message.value = bytesFromBase64(object.value); + } + return message; + }, + + toJSON(message: Any): unknown { + const obj: any = {}; + message.typeUrl !== undefined && (obj.typeUrl = message.typeUrl); + message.value !== undefined && + (obj.value = base64FromBytes( + message.value !== undefined ? message.value : new Uint8Array() + )); + return obj; + }, + + fromPartial(object: DeepPartial): Any { + const message = { ...baseAny } as Any; + if (object.typeUrl !== undefined && object.typeUrl !== null) { + message.typeUrl = object.typeUrl; + } else { + message.typeUrl = ""; + } + if (object.value !== undefined && object.value !== null) { + message.value = object.value; + } else { + message.value = new Uint8Array(); + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/cosmos.vesting.v1beta1/types/google/protobuf/descriptor.ts b/ts-client/cosmos.vesting.v1beta1/types/google/protobuf/descriptor.ts new file mode 100644 index 00000000..9e508660 --- /dev/null +++ b/ts-client/cosmos.vesting.v1beta1/types/google/protobuf/descriptor.ts @@ -0,0 +1,5261 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "google.protobuf"; + +/** + * The protocol compiler can output a FileDescriptorSet containing the .proto + * files it parses. + */ +export interface FileDescriptorSet { + file: FileDescriptorProto[]; +} + +/** Describes a complete .proto file. */ +export interface FileDescriptorProto { + /** file name, relative to root of source tree */ + name: string; + /** e.g. "foo", "foo.bar", etc. */ + package: string; + /** Names of files imported by this file. */ + dependency: string[]; + /** Indexes of the public imported files in the dependency list above. */ + publicDependency: number[]; + /** + * Indexes of the weak imported files in the dependency list. + * For Google-internal migration only. Do not use. + */ + weakDependency: number[]; + /** All top-level definitions in this file. */ + messageType: DescriptorProto[]; + enumType: EnumDescriptorProto[]; + service: ServiceDescriptorProto[]; + extension: FieldDescriptorProto[]; + options: FileOptions | undefined; + /** + * This field contains optional information about the original source code. + * You may safely remove this entire field without harming runtime + * functionality of the descriptors -- the information is needed only by + * development tools. + */ + sourceCodeInfo: SourceCodeInfo | undefined; + /** + * The syntax of the proto file. + * The supported values are "proto2" and "proto3". + */ + syntax: string; +} + +/** Describes a message type. */ +export interface DescriptorProto { + name: string; + field: FieldDescriptorProto[]; + extension: FieldDescriptorProto[]; + nestedType: DescriptorProto[]; + enumType: EnumDescriptorProto[]; + extensionRange: DescriptorProto_ExtensionRange[]; + oneofDecl: OneofDescriptorProto[]; + options: MessageOptions | undefined; + reservedRange: DescriptorProto_ReservedRange[]; + /** + * Reserved field names, which may not be used by fields in the same message. + * A given name may only be reserved once. + */ + reservedName: string[]; +} + +export interface DescriptorProto_ExtensionRange { + /** Inclusive. */ + start: number; + /** Exclusive. */ + end: number; + options: ExtensionRangeOptions | undefined; +} + +/** + * Range of reserved tag numbers. Reserved tag numbers may not be used by + * fields or extension ranges in the same message. Reserved ranges may + * not overlap. + */ +export interface DescriptorProto_ReservedRange { + /** Inclusive. */ + start: number; + /** Exclusive. */ + end: number; +} + +export interface ExtensionRangeOptions { + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +/** Describes a field within a message. */ +export interface FieldDescriptorProto { + name: string; + number: number; + label: FieldDescriptorProto_Label; + /** + * If type_name is set, this need not be set. If both this and type_name + * are set, this must be one of TYPE_ENUM, TYPE_MESSAGE or TYPE_GROUP. + */ + type: FieldDescriptorProto_Type; + /** + * For message and enum types, this is the name of the type. If the name + * starts with a '.', it is fully-qualified. Otherwise, C++-like scoping + * rules are used to find the type (i.e. first the nested types within this + * message are searched, then within the parent, on up to the root + * namespace). + */ + typeName: string; + /** + * For extensions, this is the name of the type being extended. It is + * resolved in the same manner as type_name. + */ + extendee: string; + /** + * For numeric types, contains the original text representation of the value. + * For booleans, "true" or "false". + * For strings, contains the default text contents (not escaped in any way). + * For bytes, contains the C escaped value. All bytes >= 128 are escaped. + * TODO(kenton): Base-64 encode? + */ + defaultValue: string; + /** + * If set, gives the index of a oneof in the containing type's oneof_decl + * list. This field is a member of that oneof. + */ + oneofIndex: number; + /** + * JSON name of this field. The value is set by protocol compiler. If the + * user has set a "json_name" option on this field, that option's value + * will be used. Otherwise, it's deduced from the field's name by converting + * it to camelCase. + */ + jsonName: string; + options: FieldOptions | undefined; + /** + * If true, this is a proto3 "optional". When a proto3 field is optional, it + * tracks presence regardless of field type. + * + * When proto3_optional is true, this field must be belong to a oneof to + * signal to old proto3 clients that presence is tracked for this field. This + * oneof is known as a "synthetic" oneof, and this field must be its sole + * member (each proto3 optional field gets its own synthetic oneof). Synthetic + * oneofs exist in the descriptor only, and do not generate any API. Synthetic + * oneofs must be ordered after all "real" oneofs. + * + * For message fields, proto3_optional doesn't create any semantic change, + * since non-repeated message fields always track presence. However it still + * indicates the semantic detail of whether the user wrote "optional" or not. + * This can be useful for round-tripping the .proto file. For consistency we + * give message fields a synthetic oneof also, even though it is not required + * to track presence. This is especially important because the parser can't + * tell if a field is a message or an enum, so it must always create a + * synthetic oneof. + * + * Proto2 optional fields do not set this flag, because they already indicate + * optional with `LABEL_OPTIONAL`. + */ + proto3Optional: boolean; +} + +export enum FieldDescriptorProto_Type { + /** + * TYPE_DOUBLE - 0 is reserved for errors. + * Order is weird for historical reasons. + */ + TYPE_DOUBLE = 1, + TYPE_FLOAT = 2, + /** + * TYPE_INT64 - Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT64 if + * negative values are likely. + */ + TYPE_INT64 = 3, + TYPE_UINT64 = 4, + /** + * TYPE_INT32 - Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT32 if + * negative values are likely. + */ + TYPE_INT32 = 5, + TYPE_FIXED64 = 6, + TYPE_FIXED32 = 7, + TYPE_BOOL = 8, + TYPE_STRING = 9, + /** + * TYPE_GROUP - Tag-delimited aggregate. + * Group type is deprecated and not supported in proto3. However, Proto3 + * implementations should still be able to parse the group wire format and + * treat group fields as unknown fields. + */ + TYPE_GROUP = 10, + /** TYPE_MESSAGE - Length-delimited aggregate. */ + TYPE_MESSAGE = 11, + /** TYPE_BYTES - New in version 2. */ + TYPE_BYTES = 12, + TYPE_UINT32 = 13, + TYPE_ENUM = 14, + TYPE_SFIXED32 = 15, + TYPE_SFIXED64 = 16, + /** TYPE_SINT32 - Uses ZigZag encoding. */ + TYPE_SINT32 = 17, + /** TYPE_SINT64 - Uses ZigZag encoding. */ + TYPE_SINT64 = 18, + UNRECOGNIZED = -1, +} + +export function fieldDescriptorProto_TypeFromJSON( + object: any +): FieldDescriptorProto_Type { + switch (object) { + case 1: + case "TYPE_DOUBLE": + return FieldDescriptorProto_Type.TYPE_DOUBLE; + case 2: + case "TYPE_FLOAT": + return FieldDescriptorProto_Type.TYPE_FLOAT; + case 3: + case "TYPE_INT64": + return FieldDescriptorProto_Type.TYPE_INT64; + case 4: + case "TYPE_UINT64": + return FieldDescriptorProto_Type.TYPE_UINT64; + case 5: + case "TYPE_INT32": + return FieldDescriptorProto_Type.TYPE_INT32; + case 6: + case "TYPE_FIXED64": + return FieldDescriptorProto_Type.TYPE_FIXED64; + case 7: + case "TYPE_FIXED32": + return FieldDescriptorProto_Type.TYPE_FIXED32; + case 8: + case "TYPE_BOOL": + return FieldDescriptorProto_Type.TYPE_BOOL; + case 9: + case "TYPE_STRING": + return FieldDescriptorProto_Type.TYPE_STRING; + case 10: + case "TYPE_GROUP": + return FieldDescriptorProto_Type.TYPE_GROUP; + case 11: + case "TYPE_MESSAGE": + return FieldDescriptorProto_Type.TYPE_MESSAGE; + case 12: + case "TYPE_BYTES": + return FieldDescriptorProto_Type.TYPE_BYTES; + case 13: + case "TYPE_UINT32": + return FieldDescriptorProto_Type.TYPE_UINT32; + case 14: + case "TYPE_ENUM": + return FieldDescriptorProto_Type.TYPE_ENUM; + case 15: + case "TYPE_SFIXED32": + return FieldDescriptorProto_Type.TYPE_SFIXED32; + case 16: + case "TYPE_SFIXED64": + return FieldDescriptorProto_Type.TYPE_SFIXED64; + case 17: + case "TYPE_SINT32": + return FieldDescriptorProto_Type.TYPE_SINT32; + case 18: + case "TYPE_SINT64": + return FieldDescriptorProto_Type.TYPE_SINT64; + case -1: + case "UNRECOGNIZED": + default: + return FieldDescriptorProto_Type.UNRECOGNIZED; + } +} + +export function fieldDescriptorProto_TypeToJSON( + object: FieldDescriptorProto_Type +): string { + switch (object) { + case FieldDescriptorProto_Type.TYPE_DOUBLE: + return "TYPE_DOUBLE"; + case FieldDescriptorProto_Type.TYPE_FLOAT: + return "TYPE_FLOAT"; + case FieldDescriptorProto_Type.TYPE_INT64: + return "TYPE_INT64"; + case FieldDescriptorProto_Type.TYPE_UINT64: + return "TYPE_UINT64"; + case FieldDescriptorProto_Type.TYPE_INT32: + return "TYPE_INT32"; + case FieldDescriptorProto_Type.TYPE_FIXED64: + return "TYPE_FIXED64"; + case FieldDescriptorProto_Type.TYPE_FIXED32: + return "TYPE_FIXED32"; + case FieldDescriptorProto_Type.TYPE_BOOL: + return "TYPE_BOOL"; + case FieldDescriptorProto_Type.TYPE_STRING: + return "TYPE_STRING"; + case FieldDescriptorProto_Type.TYPE_GROUP: + return "TYPE_GROUP"; + case FieldDescriptorProto_Type.TYPE_MESSAGE: + return "TYPE_MESSAGE"; + case FieldDescriptorProto_Type.TYPE_BYTES: + return "TYPE_BYTES"; + case FieldDescriptorProto_Type.TYPE_UINT32: + return "TYPE_UINT32"; + case FieldDescriptorProto_Type.TYPE_ENUM: + return "TYPE_ENUM"; + case FieldDescriptorProto_Type.TYPE_SFIXED32: + return "TYPE_SFIXED32"; + case FieldDescriptorProto_Type.TYPE_SFIXED64: + return "TYPE_SFIXED64"; + case FieldDescriptorProto_Type.TYPE_SINT32: + return "TYPE_SINT32"; + case FieldDescriptorProto_Type.TYPE_SINT64: + return "TYPE_SINT64"; + default: + return "UNKNOWN"; + } +} + +export enum FieldDescriptorProto_Label { + /** LABEL_OPTIONAL - 0 is reserved for errors */ + LABEL_OPTIONAL = 1, + LABEL_REQUIRED = 2, + LABEL_REPEATED = 3, + UNRECOGNIZED = -1, +} + +export function fieldDescriptorProto_LabelFromJSON( + object: any +): FieldDescriptorProto_Label { + switch (object) { + case 1: + case "LABEL_OPTIONAL": + return FieldDescriptorProto_Label.LABEL_OPTIONAL; + case 2: + case "LABEL_REQUIRED": + return FieldDescriptorProto_Label.LABEL_REQUIRED; + case 3: + case "LABEL_REPEATED": + return FieldDescriptorProto_Label.LABEL_REPEATED; + case -1: + case "UNRECOGNIZED": + default: + return FieldDescriptorProto_Label.UNRECOGNIZED; + } +} + +export function fieldDescriptorProto_LabelToJSON( + object: FieldDescriptorProto_Label +): string { + switch (object) { + case FieldDescriptorProto_Label.LABEL_OPTIONAL: + return "LABEL_OPTIONAL"; + case FieldDescriptorProto_Label.LABEL_REQUIRED: + return "LABEL_REQUIRED"; + case FieldDescriptorProto_Label.LABEL_REPEATED: + return "LABEL_REPEATED"; + default: + return "UNKNOWN"; + } +} + +/** Describes a oneof. */ +export interface OneofDescriptorProto { + name: string; + options: OneofOptions | undefined; +} + +/** Describes an enum type. */ +export interface EnumDescriptorProto { + name: string; + value: EnumValueDescriptorProto[]; + options: EnumOptions | undefined; + /** + * Range of reserved numeric values. Reserved numeric values may not be used + * by enum values in the same enum declaration. Reserved ranges may not + * overlap. + */ + reservedRange: EnumDescriptorProto_EnumReservedRange[]; + /** + * Reserved enum value names, which may not be reused. A given name may only + * be reserved once. + */ + reservedName: string[]; +} + +/** + * Range of reserved numeric values. Reserved values may not be used by + * entries in the same enum. Reserved ranges may not overlap. + * + * Note that this is distinct from DescriptorProto.ReservedRange in that it + * is inclusive such that it can appropriately represent the entire int32 + * domain. + */ +export interface EnumDescriptorProto_EnumReservedRange { + /** Inclusive. */ + start: number; + /** Inclusive. */ + end: number; +} + +/** Describes a value within an enum. */ +export interface EnumValueDescriptorProto { + name: string; + number: number; + options: EnumValueOptions | undefined; +} + +/** Describes a service. */ +export interface ServiceDescriptorProto { + name: string; + method: MethodDescriptorProto[]; + options: ServiceOptions | undefined; +} + +/** Describes a method of a service. */ +export interface MethodDescriptorProto { + name: string; + /** + * Input and output type names. These are resolved in the same way as + * FieldDescriptorProto.type_name, but must refer to a message type. + */ + inputType: string; + outputType: string; + options: MethodOptions | undefined; + /** Identifies if client streams multiple client messages */ + clientStreaming: boolean; + /** Identifies if server streams multiple server messages */ + serverStreaming: boolean; +} + +export interface FileOptions { + /** + * Sets the Java package where classes generated from this .proto will be + * placed. By default, the proto package is used, but this is often + * inappropriate because proto packages do not normally start with backwards + * domain names. + */ + javaPackage: string; + /** + * Controls the name of the wrapper Java class generated for the .proto file. + * That class will always contain the .proto file's getDescriptor() method as + * well as any top-level extensions defined in the .proto file. + * If java_multiple_files is disabled, then all the other classes from the + * .proto file will be nested inside the single wrapper outer class. + */ + javaOuterClassname: string; + /** + * If enabled, then the Java code generator will generate a separate .java + * file for each top-level message, enum, and service defined in the .proto + * file. Thus, these types will *not* be nested inside the wrapper class + * named by java_outer_classname. However, the wrapper class will still be + * generated to contain the file's getDescriptor() method as well as any + * top-level extensions defined in the file. + */ + javaMultipleFiles: boolean; + /** + * This option does nothing. + * + * @deprecated + */ + javaGenerateEqualsAndHash: boolean; + /** + * If set true, then the Java2 code generator will generate code that + * throws an exception whenever an attempt is made to assign a non-UTF-8 + * byte sequence to a string field. + * Message reflection will do the same. + * However, an extension field still accepts non-UTF-8 byte sequences. + * This option has no effect on when used with the lite runtime. + */ + javaStringCheckUtf8: boolean; + optimizeFor: FileOptions_OptimizeMode; + /** + * Sets the Go package where structs generated from this .proto will be + * placed. If omitted, the Go package will be derived from the following: + * - The basename of the package import path, if provided. + * - Otherwise, the package statement in the .proto file, if present. + * - Otherwise, the basename of the .proto file, without extension. + */ + goPackage: string; + /** + * Should generic services be generated in each language? "Generic" services + * are not specific to any particular RPC system. They are generated by the + * main code generators in each language (without additional plugins). + * Generic services were the only kind of service generation supported by + * early versions of google.protobuf. + * + * Generic services are now considered deprecated in favor of using plugins + * that generate code specific to your particular RPC system. Therefore, + * these default to false. Old code which depends on generic services should + * explicitly set them to true. + */ + ccGenericServices: boolean; + javaGenericServices: boolean; + pyGenericServices: boolean; + phpGenericServices: boolean; + /** + * Is this file deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for everything in the file, or it will be completely ignored; in the very + * least, this is a formalization for deprecating files. + */ + deprecated: boolean; + /** + * Enables the use of arenas for the proto messages in this file. This applies + * only to generated classes for C++. + */ + ccEnableArenas: boolean; + /** + * Sets the objective c class prefix which is prepended to all objective c + * generated classes from this .proto. There is no default. + */ + objcClassPrefix: string; + /** Namespace for generated classes; defaults to the package. */ + csharpNamespace: string; + /** + * By default Swift generators will take the proto package and CamelCase it + * replacing '.' with underscore and use that to prefix the types/symbols + * defined. When this options is provided, they will use this value instead + * to prefix the types/symbols defined. + */ + swiftPrefix: string; + /** + * Sets the php class prefix which is prepended to all php generated classes + * from this .proto. Default is empty. + */ + phpClassPrefix: string; + /** + * Use this option to change the namespace of php generated classes. Default + * is empty. When this option is empty, the package name will be used for + * determining the namespace. + */ + phpNamespace: string; + /** + * Use this option to change the namespace of php generated metadata classes. + * Default is empty. When this option is empty, the proto file name will be + * used for determining the namespace. + */ + phpMetadataNamespace: string; + /** + * Use this option to change the package of ruby generated classes. Default + * is empty. When this option is not set, the package name will be used for + * determining the ruby package. + */ + rubyPackage: string; + /** + * The parser stores options it doesn't recognize here. + * See the documentation for the "Options" section above. + */ + uninterpretedOption: UninterpretedOption[]; +} + +/** Generated classes can be optimized for speed or code size. */ +export enum FileOptions_OptimizeMode { + /** SPEED - Generate complete code for parsing, serialization, */ + SPEED = 1, + /** CODE_SIZE - etc. */ + CODE_SIZE = 2, + /** LITE_RUNTIME - Generate code using MessageLite and the lite runtime. */ + LITE_RUNTIME = 3, + UNRECOGNIZED = -1, +} + +export function fileOptions_OptimizeModeFromJSON( + object: any +): FileOptions_OptimizeMode { + switch (object) { + case 1: + case "SPEED": + return FileOptions_OptimizeMode.SPEED; + case 2: + case "CODE_SIZE": + return FileOptions_OptimizeMode.CODE_SIZE; + case 3: + case "LITE_RUNTIME": + return FileOptions_OptimizeMode.LITE_RUNTIME; + case -1: + case "UNRECOGNIZED": + default: + return FileOptions_OptimizeMode.UNRECOGNIZED; + } +} + +export function fileOptions_OptimizeModeToJSON( + object: FileOptions_OptimizeMode +): string { + switch (object) { + case FileOptions_OptimizeMode.SPEED: + return "SPEED"; + case FileOptions_OptimizeMode.CODE_SIZE: + return "CODE_SIZE"; + case FileOptions_OptimizeMode.LITE_RUNTIME: + return "LITE_RUNTIME"; + default: + return "UNKNOWN"; + } +} + +export interface MessageOptions { + /** + * Set true to use the old proto1 MessageSet wire format for extensions. + * This is provided for backwards-compatibility with the MessageSet wire + * format. You should not use this for any other reason: It's less + * efficient, has fewer features, and is more complicated. + * + * The message must be defined exactly as follows: + * message Foo { + * option message_set_wire_format = true; + * extensions 4 to max; + * } + * Note that the message cannot have any defined fields; MessageSets only + * have extensions. + * + * All extensions of your type must be singular messages; e.g. they cannot + * be int32s, enums, or repeated messages. + * + * Because this is an option, the above two restrictions are not enforced by + * the protocol compiler. + */ + messageSetWireFormat: boolean; + /** + * Disables the generation of the standard "descriptor()" accessor, which can + * conflict with a field of the same name. This is meant to make migration + * from proto1 easier; new code should avoid fields named "descriptor". + */ + noStandardDescriptorAccessor: boolean; + /** + * Is this message deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the message, or it will be completely ignored; in the very least, + * this is a formalization for deprecating messages. + */ + deprecated: boolean; + /** + * Whether the message is an automatically generated map entry type for the + * maps field. + * + * For maps fields: + * map map_field = 1; + * The parsed descriptor looks like: + * message MapFieldEntry { + * option map_entry = true; + * optional KeyType key = 1; + * optional ValueType value = 2; + * } + * repeated MapFieldEntry map_field = 1; + * + * Implementations may choose not to generate the map_entry=true message, but + * use a native map in the target language to hold the keys and values. + * The reflection APIs in such implementations still need to work as + * if the field is a repeated message field. + * + * NOTE: Do not set the option in .proto files. Always use the maps syntax + * instead. The option should only be implicitly set by the proto compiler + * parser. + */ + mapEntry: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface FieldOptions { + /** + * The ctype option instructs the C++ code generator to use a different + * representation of the field than it normally would. See the specific + * options below. This option is not yet implemented in the open source + * release -- sorry, we'll try to include it in a future version! + */ + ctype: FieldOptions_CType; + /** + * The packed option can be enabled for repeated primitive fields to enable + * a more efficient representation on the wire. Rather than repeatedly + * writing the tag and type for each element, the entire array is encoded as + * a single length-delimited blob. In proto3, only explicit setting it to + * false will avoid using packed encoding. + */ + packed: boolean; + /** + * The jstype option determines the JavaScript type used for values of the + * field. The option is permitted only for 64 bit integral and fixed types + * (int64, uint64, sint64, fixed64, sfixed64). A field with jstype JS_STRING + * is represented as JavaScript string, which avoids loss of precision that + * can happen when a large value is converted to a floating point JavaScript. + * Specifying JS_NUMBER for the jstype causes the generated JavaScript code to + * use the JavaScript "number" type. The behavior of the default option + * JS_NORMAL is implementation dependent. + * + * This option is an enum to permit additional types to be added, e.g. + * goog.math.Integer. + */ + jstype: FieldOptions_JSType; + /** + * Should this field be parsed lazily? Lazy applies only to message-type + * fields. It means that when the outer message is initially parsed, the + * inner message's contents will not be parsed but instead stored in encoded + * form. The inner message will actually be parsed when it is first accessed. + * + * This is only a hint. Implementations are free to choose whether to use + * eager or lazy parsing regardless of the value of this option. However, + * setting this option true suggests that the protocol author believes that + * using lazy parsing on this field is worth the additional bookkeeping + * overhead typically needed to implement it. + * + * This option does not affect the public interface of any generated code; + * all method signatures remain the same. Furthermore, thread-safety of the + * interface is not affected by this option; const methods remain safe to + * call from multiple threads concurrently, while non-const methods continue + * to require exclusive access. + * + * + * Note that implementations may choose not to check required fields within + * a lazy sub-message. That is, calling IsInitialized() on the outer message + * may return true even if the inner message has missing required fields. + * This is necessary because otherwise the inner message would have to be + * parsed in order to perform the check, defeating the purpose of lazy + * parsing. An implementation which chooses not to check required fields + * must be consistent about it. That is, for any particular sub-message, the + * implementation must either *always* check its required fields, or *never* + * check its required fields, regardless of whether or not the message has + * been parsed. + */ + lazy: boolean; + /** + * Is this field deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for accessors, or it will be completely ignored; in the very least, this + * is a formalization for deprecating fields. + */ + deprecated: boolean; + /** For Google-internal migration only. Do not use. */ + weak: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export enum FieldOptions_CType { + /** STRING - Default mode. */ + STRING = 0, + CORD = 1, + STRING_PIECE = 2, + UNRECOGNIZED = -1, +} + +export function fieldOptions_CTypeFromJSON(object: any): FieldOptions_CType { + switch (object) { + case 0: + case "STRING": + return FieldOptions_CType.STRING; + case 1: + case "CORD": + return FieldOptions_CType.CORD; + case 2: + case "STRING_PIECE": + return FieldOptions_CType.STRING_PIECE; + case -1: + case "UNRECOGNIZED": + default: + return FieldOptions_CType.UNRECOGNIZED; + } +} + +export function fieldOptions_CTypeToJSON(object: FieldOptions_CType): string { + switch (object) { + case FieldOptions_CType.STRING: + return "STRING"; + case FieldOptions_CType.CORD: + return "CORD"; + case FieldOptions_CType.STRING_PIECE: + return "STRING_PIECE"; + default: + return "UNKNOWN"; + } +} + +export enum FieldOptions_JSType { + /** JS_NORMAL - Use the default type. */ + JS_NORMAL = 0, + /** JS_STRING - Use JavaScript strings. */ + JS_STRING = 1, + /** JS_NUMBER - Use JavaScript numbers. */ + JS_NUMBER = 2, + UNRECOGNIZED = -1, +} + +export function fieldOptions_JSTypeFromJSON(object: any): FieldOptions_JSType { + switch (object) { + case 0: + case "JS_NORMAL": + return FieldOptions_JSType.JS_NORMAL; + case 1: + case "JS_STRING": + return FieldOptions_JSType.JS_STRING; + case 2: + case "JS_NUMBER": + return FieldOptions_JSType.JS_NUMBER; + case -1: + case "UNRECOGNIZED": + default: + return FieldOptions_JSType.UNRECOGNIZED; + } +} + +export function fieldOptions_JSTypeToJSON(object: FieldOptions_JSType): string { + switch (object) { + case FieldOptions_JSType.JS_NORMAL: + return "JS_NORMAL"; + case FieldOptions_JSType.JS_STRING: + return "JS_STRING"; + case FieldOptions_JSType.JS_NUMBER: + return "JS_NUMBER"; + default: + return "UNKNOWN"; + } +} + +export interface OneofOptions { + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface EnumOptions { + /** + * Set this option to true to allow mapping different tag names to the same + * value. + */ + allowAlias: boolean; + /** + * Is this enum deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the enum, or it will be completely ignored; in the very least, this + * is a formalization for deprecating enums. + */ + deprecated: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface EnumValueOptions { + /** + * Is this enum value deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the enum value, or it will be completely ignored; in the very least, + * this is a formalization for deprecating enum values. + */ + deprecated: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface ServiceOptions { + /** + * Is this service deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the service, or it will be completely ignored; in the very least, + * this is a formalization for deprecating services. + */ + deprecated: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface MethodOptions { + /** + * Is this method deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the method, or it will be completely ignored; in the very least, + * this is a formalization for deprecating methods. + */ + deprecated: boolean; + idempotencyLevel: MethodOptions_IdempotencyLevel; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +/** + * Is this method side-effect-free (or safe in HTTP parlance), or idempotent, + * or neither? HTTP based RPC implementation may choose GET verb for safe + * methods, and PUT verb for idempotent methods instead of the default POST. + */ +export enum MethodOptions_IdempotencyLevel { + IDEMPOTENCY_UNKNOWN = 0, + /** NO_SIDE_EFFECTS - implies idempotent */ + NO_SIDE_EFFECTS = 1, + /** IDEMPOTENT - idempotent, but may have side effects */ + IDEMPOTENT = 2, + UNRECOGNIZED = -1, +} + +export function methodOptions_IdempotencyLevelFromJSON( + object: any +): MethodOptions_IdempotencyLevel { + switch (object) { + case 0: + case "IDEMPOTENCY_UNKNOWN": + return MethodOptions_IdempotencyLevel.IDEMPOTENCY_UNKNOWN; + case 1: + case "NO_SIDE_EFFECTS": + return MethodOptions_IdempotencyLevel.NO_SIDE_EFFECTS; + case 2: + case "IDEMPOTENT": + return MethodOptions_IdempotencyLevel.IDEMPOTENT; + case -1: + case "UNRECOGNIZED": + default: + return MethodOptions_IdempotencyLevel.UNRECOGNIZED; + } +} + +export function methodOptions_IdempotencyLevelToJSON( + object: MethodOptions_IdempotencyLevel +): string { + switch (object) { + case MethodOptions_IdempotencyLevel.IDEMPOTENCY_UNKNOWN: + return "IDEMPOTENCY_UNKNOWN"; + case MethodOptions_IdempotencyLevel.NO_SIDE_EFFECTS: + return "NO_SIDE_EFFECTS"; + case MethodOptions_IdempotencyLevel.IDEMPOTENT: + return "IDEMPOTENT"; + default: + return "UNKNOWN"; + } +} + +/** + * A message representing a option the parser does not recognize. This only + * appears in options protos created by the compiler::Parser class. + * DescriptorPool resolves these when building Descriptor objects. Therefore, + * options protos in descriptor objects (e.g. returned by Descriptor::options(), + * or produced by Descriptor::CopyTo()) will never have UninterpretedOptions + * in them. + */ +export interface UninterpretedOption { + name: UninterpretedOption_NamePart[]; + /** + * The value of the uninterpreted option, in whatever type the tokenizer + * identified it as during parsing. Exactly one of these should be set. + */ + identifierValue: string; + positiveIntValue: number; + negativeIntValue: number; + doubleValue: number; + stringValue: Uint8Array; + aggregateValue: string; +} + +/** + * The name of the uninterpreted option. Each string represents a segment in + * a dot-separated name. is_extension is true iff a segment represents an + * extension (denoted with parentheses in options specs in .proto files). + * E.g.,{ ["foo", false], ["bar.baz", true], ["qux", false] } represents + * "foo.(bar.baz).qux". + */ +export interface UninterpretedOption_NamePart { + namePart: string; + isExtension: boolean; +} + +/** + * Encapsulates information about the original source file from which a + * FileDescriptorProto was generated. + */ +export interface SourceCodeInfo { + /** + * A Location identifies a piece of source code in a .proto file which + * corresponds to a particular definition. This information is intended + * to be useful to IDEs, code indexers, documentation generators, and similar + * tools. + * + * For example, say we have a file like: + * message Foo { + * optional string foo = 1; + * } + * Let's look at just the field definition: + * optional string foo = 1; + * ^ ^^ ^^ ^ ^^^ + * a bc de f ghi + * We have the following locations: + * span path represents + * [a,i) [ 4, 0, 2, 0 ] The whole field definition. + * [a,b) [ 4, 0, 2, 0, 4 ] The label (optional). + * [c,d) [ 4, 0, 2, 0, 5 ] The type (string). + * [e,f) [ 4, 0, 2, 0, 1 ] The name (foo). + * [g,h) [ 4, 0, 2, 0, 3 ] The number (1). + * + * Notes: + * - A location may refer to a repeated field itself (i.e. not to any + * particular index within it). This is used whenever a set of elements are + * logically enclosed in a single code segment. For example, an entire + * extend block (possibly containing multiple extension definitions) will + * have an outer location whose path refers to the "extensions" repeated + * field without an index. + * - Multiple locations may have the same path. This happens when a single + * logical declaration is spread out across multiple places. The most + * obvious example is the "extend" block again -- there may be multiple + * extend blocks in the same scope, each of which will have the same path. + * - A location's span is not always a subset of its parent's span. For + * example, the "extendee" of an extension declaration appears at the + * beginning of the "extend" block and is shared by all extensions within + * the block. + * - Just because a location's span is a subset of some other location's span + * does not mean that it is a descendant. For example, a "group" defines + * both a type and a field in a single declaration. Thus, the locations + * corresponding to the type and field and their components will overlap. + * - Code which tries to interpret locations should probably be designed to + * ignore those that it doesn't understand, as more types of locations could + * be recorded in the future. + */ + location: SourceCodeInfo_Location[]; +} + +export interface SourceCodeInfo_Location { + /** + * Identifies which part of the FileDescriptorProto was defined at this + * location. + * + * Each element is a field number or an index. They form a path from + * the root FileDescriptorProto to the place where the definition. For + * example, this path: + * [ 4, 3, 2, 7, 1 ] + * refers to: + * file.message_type(3) // 4, 3 + * .field(7) // 2, 7 + * .name() // 1 + * This is because FileDescriptorProto.message_type has field number 4: + * repeated DescriptorProto message_type = 4; + * and DescriptorProto.field has field number 2: + * repeated FieldDescriptorProto field = 2; + * and FieldDescriptorProto.name has field number 1: + * optional string name = 1; + * + * Thus, the above path gives the location of a field name. If we removed + * the last element: + * [ 4, 3, 2, 7 ] + * this path refers to the whole field declaration (from the beginning + * of the label to the terminating semicolon). + */ + path: number[]; + /** + * Always has exactly three or four elements: start line, start column, + * end line (optional, otherwise assumed same as start line), end column. + * These are packed into a single field for efficiency. Note that line + * and column numbers are zero-based -- typically you will want to add + * 1 to each before displaying to a user. + */ + span: number[]; + /** + * If this SourceCodeInfo represents a complete declaration, these are any + * comments appearing before and after the declaration which appear to be + * attached to the declaration. + * + * A series of line comments appearing on consecutive lines, with no other + * tokens appearing on those lines, will be treated as a single comment. + * + * leading_detached_comments will keep paragraphs of comments that appear + * before (but not connected to) the current element. Each paragraph, + * separated by empty lines, will be one comment element in the repeated + * field. + * + * Only the comment content is provided; comment markers (e.g. //) are + * stripped out. For block comments, leading whitespace and an asterisk + * will be stripped from the beginning of each line other than the first. + * Newlines are included in the output. + * + * Examples: + * + * optional int32 foo = 1; // Comment attached to foo. + * // Comment attached to bar. + * optional int32 bar = 2; + * + * optional string baz = 3; + * // Comment attached to baz. + * // Another line attached to baz. + * + * // Comment attached to qux. + * // + * // Another line attached to qux. + * optional double qux = 4; + * + * // Detached comment for corge. This is not leading or trailing comments + * // to qux or corge because there are blank lines separating it from + * // both. + * + * // Detached comment for corge paragraph 2. + * + * optional string corge = 5; + * /* Block comment attached + * * to corge. Leading asterisks + * * will be removed. * / + * /* Block comment attached to + * * grault. * / + * optional int32 grault = 6; + * + * // ignored detached comments. + */ + leadingComments: string; + trailingComments: string; + leadingDetachedComments: string[]; +} + +/** + * Describes the relationship between generated code and its original source + * file. A GeneratedCodeInfo message is associated with only one generated + * source file, but may contain references to different source .proto files. + */ +export interface GeneratedCodeInfo { + /** + * An Annotation connects some span of text in generated code to an element + * of its generating .proto file. + */ + annotation: GeneratedCodeInfo_Annotation[]; +} + +export interface GeneratedCodeInfo_Annotation { + /** + * Identifies the element in the original source .proto file. This field + * is formatted the same as SourceCodeInfo.Location.path. + */ + path: number[]; + /** Identifies the filesystem path to the original source .proto. */ + sourceFile: string; + /** + * Identifies the starting offset in bytes in the generated code + * that relates to the identified object. + */ + begin: number; + /** + * Identifies the ending offset in bytes in the generated code that + * relates to the identified offset. The end offset should be one past + * the last relevant byte (so the length of the text = end - begin). + */ + end: number; +} + +const baseFileDescriptorSet: object = {}; + +export const FileDescriptorSet = { + encode(message: FileDescriptorSet, writer: Writer = Writer.create()): Writer { + for (const v of message.file) { + FileDescriptorProto.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FileDescriptorSet { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFileDescriptorSet } as FileDescriptorSet; + message.file = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.file.push( + FileDescriptorProto.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FileDescriptorSet { + const message = { ...baseFileDescriptorSet } as FileDescriptorSet; + message.file = []; + if (object.file !== undefined && object.file !== null) { + for (const e of object.file) { + message.file.push(FileDescriptorProto.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: FileDescriptorSet): unknown { + const obj: any = {}; + if (message.file) { + obj.file = message.file.map((e) => + e ? FileDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.file = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): FileDescriptorSet { + const message = { ...baseFileDescriptorSet } as FileDescriptorSet; + message.file = []; + if (object.file !== undefined && object.file !== null) { + for (const e of object.file) { + message.file.push(FileDescriptorProto.fromPartial(e)); + } + } + return message; + }, +}; + +const baseFileDescriptorProto: object = { + name: "", + package: "", + dependency: "", + publicDependency: 0, + weakDependency: 0, + syntax: "", +}; + +export const FileDescriptorProto = { + encode( + message: FileDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.package !== "") { + writer.uint32(18).string(message.package); + } + for (const v of message.dependency) { + writer.uint32(26).string(v!); + } + writer.uint32(82).fork(); + for (const v of message.publicDependency) { + writer.int32(v); + } + writer.ldelim(); + writer.uint32(90).fork(); + for (const v of message.weakDependency) { + writer.int32(v); + } + writer.ldelim(); + for (const v of message.messageType) { + DescriptorProto.encode(v!, writer.uint32(34).fork()).ldelim(); + } + for (const v of message.enumType) { + EnumDescriptorProto.encode(v!, writer.uint32(42).fork()).ldelim(); + } + for (const v of message.service) { + ServiceDescriptorProto.encode(v!, writer.uint32(50).fork()).ldelim(); + } + for (const v of message.extension) { + FieldDescriptorProto.encode(v!, writer.uint32(58).fork()).ldelim(); + } + if (message.options !== undefined) { + FileOptions.encode(message.options, writer.uint32(66).fork()).ldelim(); + } + if (message.sourceCodeInfo !== undefined) { + SourceCodeInfo.encode( + message.sourceCodeInfo, + writer.uint32(74).fork() + ).ldelim(); + } + if (message.syntax !== "") { + writer.uint32(98).string(message.syntax); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FileDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFileDescriptorProto } as FileDescriptorProto; + message.dependency = []; + message.publicDependency = []; + message.weakDependency = []; + message.messageType = []; + message.enumType = []; + message.service = []; + message.extension = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.package = reader.string(); + break; + case 3: + message.dependency.push(reader.string()); + break; + case 10: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.publicDependency.push(reader.int32()); + } + } else { + message.publicDependency.push(reader.int32()); + } + break; + case 11: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.weakDependency.push(reader.int32()); + } + } else { + message.weakDependency.push(reader.int32()); + } + break; + case 4: + message.messageType.push( + DescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 5: + message.enumType.push( + EnumDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 6: + message.service.push( + ServiceDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 7: + message.extension.push( + FieldDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 8: + message.options = FileOptions.decode(reader, reader.uint32()); + break; + case 9: + message.sourceCodeInfo = SourceCodeInfo.decode( + reader, + reader.uint32() + ); + break; + case 12: + message.syntax = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FileDescriptorProto { + const message = { ...baseFileDescriptorProto } as FileDescriptorProto; + message.dependency = []; + message.publicDependency = []; + message.weakDependency = []; + message.messageType = []; + message.enumType = []; + message.service = []; + message.extension = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.package !== undefined && object.package !== null) { + message.package = String(object.package); + } else { + message.package = ""; + } + if (object.dependency !== undefined && object.dependency !== null) { + for (const e of object.dependency) { + message.dependency.push(String(e)); + } + } + if ( + object.publicDependency !== undefined && + object.publicDependency !== null + ) { + for (const e of object.publicDependency) { + message.publicDependency.push(Number(e)); + } + } + if (object.weakDependency !== undefined && object.weakDependency !== null) { + for (const e of object.weakDependency) { + message.weakDependency.push(Number(e)); + } + } + if (object.messageType !== undefined && object.messageType !== null) { + for (const e of object.messageType) { + message.messageType.push(DescriptorProto.fromJSON(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromJSON(e)); + } + } + if (object.service !== undefined && object.service !== null) { + for (const e of object.service) { + message.service.push(ServiceDescriptorProto.fromJSON(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = FileOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.sourceCodeInfo !== undefined && object.sourceCodeInfo !== null) { + message.sourceCodeInfo = SourceCodeInfo.fromJSON(object.sourceCodeInfo); + } else { + message.sourceCodeInfo = undefined; + } + if (object.syntax !== undefined && object.syntax !== null) { + message.syntax = String(object.syntax); + } else { + message.syntax = ""; + } + return message; + }, + + toJSON(message: FileDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.package !== undefined && (obj.package = message.package); + if (message.dependency) { + obj.dependency = message.dependency.map((e) => e); + } else { + obj.dependency = []; + } + if (message.publicDependency) { + obj.publicDependency = message.publicDependency.map((e) => e); + } else { + obj.publicDependency = []; + } + if (message.weakDependency) { + obj.weakDependency = message.weakDependency.map((e) => e); + } else { + obj.weakDependency = []; + } + if (message.messageType) { + obj.messageType = message.messageType.map((e) => + e ? DescriptorProto.toJSON(e) : undefined + ); + } else { + obj.messageType = []; + } + if (message.enumType) { + obj.enumType = message.enumType.map((e) => + e ? EnumDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.enumType = []; + } + if (message.service) { + obj.service = message.service.map((e) => + e ? ServiceDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.service = []; + } + if (message.extension) { + obj.extension = message.extension.map((e) => + e ? FieldDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.extension = []; + } + message.options !== undefined && + (obj.options = message.options + ? FileOptions.toJSON(message.options) + : undefined); + message.sourceCodeInfo !== undefined && + (obj.sourceCodeInfo = message.sourceCodeInfo + ? SourceCodeInfo.toJSON(message.sourceCodeInfo) + : undefined); + message.syntax !== undefined && (obj.syntax = message.syntax); + return obj; + }, + + fromPartial(object: DeepPartial): FileDescriptorProto { + const message = { ...baseFileDescriptorProto } as FileDescriptorProto; + message.dependency = []; + message.publicDependency = []; + message.weakDependency = []; + message.messageType = []; + message.enumType = []; + message.service = []; + message.extension = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.package !== undefined && object.package !== null) { + message.package = object.package; + } else { + message.package = ""; + } + if (object.dependency !== undefined && object.dependency !== null) { + for (const e of object.dependency) { + message.dependency.push(e); + } + } + if ( + object.publicDependency !== undefined && + object.publicDependency !== null + ) { + for (const e of object.publicDependency) { + message.publicDependency.push(e); + } + } + if (object.weakDependency !== undefined && object.weakDependency !== null) { + for (const e of object.weakDependency) { + message.weakDependency.push(e); + } + } + if (object.messageType !== undefined && object.messageType !== null) { + for (const e of object.messageType) { + message.messageType.push(DescriptorProto.fromPartial(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromPartial(e)); + } + } + if (object.service !== undefined && object.service !== null) { + for (const e of object.service) { + message.service.push(ServiceDescriptorProto.fromPartial(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = FileOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.sourceCodeInfo !== undefined && object.sourceCodeInfo !== null) { + message.sourceCodeInfo = SourceCodeInfo.fromPartial( + object.sourceCodeInfo + ); + } else { + message.sourceCodeInfo = undefined; + } + if (object.syntax !== undefined && object.syntax !== null) { + message.syntax = object.syntax; + } else { + message.syntax = ""; + } + return message; + }, +}; + +const baseDescriptorProto: object = { name: "", reservedName: "" }; + +export const DescriptorProto = { + encode(message: DescriptorProto, writer: Writer = Writer.create()): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + for (const v of message.field) { + FieldDescriptorProto.encode(v!, writer.uint32(18).fork()).ldelim(); + } + for (const v of message.extension) { + FieldDescriptorProto.encode(v!, writer.uint32(50).fork()).ldelim(); + } + for (const v of message.nestedType) { + DescriptorProto.encode(v!, writer.uint32(26).fork()).ldelim(); + } + for (const v of message.enumType) { + EnumDescriptorProto.encode(v!, writer.uint32(34).fork()).ldelim(); + } + for (const v of message.extensionRange) { + DescriptorProto_ExtensionRange.encode( + v!, + writer.uint32(42).fork() + ).ldelim(); + } + for (const v of message.oneofDecl) { + OneofDescriptorProto.encode(v!, writer.uint32(66).fork()).ldelim(); + } + if (message.options !== undefined) { + MessageOptions.encode(message.options, writer.uint32(58).fork()).ldelim(); + } + for (const v of message.reservedRange) { + DescriptorProto_ReservedRange.encode( + v!, + writer.uint32(74).fork() + ).ldelim(); + } + for (const v of message.reservedName) { + writer.uint32(82).string(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): DescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseDescriptorProto } as DescriptorProto; + message.field = []; + message.extension = []; + message.nestedType = []; + message.enumType = []; + message.extensionRange = []; + message.oneofDecl = []; + message.reservedRange = []; + message.reservedName = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.field.push( + FieldDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 6: + message.extension.push( + FieldDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 3: + message.nestedType.push( + DescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 4: + message.enumType.push( + EnumDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 5: + message.extensionRange.push( + DescriptorProto_ExtensionRange.decode(reader, reader.uint32()) + ); + break; + case 8: + message.oneofDecl.push( + OneofDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 7: + message.options = MessageOptions.decode(reader, reader.uint32()); + break; + case 9: + message.reservedRange.push( + DescriptorProto_ReservedRange.decode(reader, reader.uint32()) + ); + break; + case 10: + message.reservedName.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DescriptorProto { + const message = { ...baseDescriptorProto } as DescriptorProto; + message.field = []; + message.extension = []; + message.nestedType = []; + message.enumType = []; + message.extensionRange = []; + message.oneofDecl = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.field !== undefined && object.field !== null) { + for (const e of object.field) { + message.field.push(FieldDescriptorProto.fromJSON(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromJSON(e)); + } + } + if (object.nestedType !== undefined && object.nestedType !== null) { + for (const e of object.nestedType) { + message.nestedType.push(DescriptorProto.fromJSON(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromJSON(e)); + } + } + if (object.extensionRange !== undefined && object.extensionRange !== null) { + for (const e of object.extensionRange) { + message.extensionRange.push(DescriptorProto_ExtensionRange.fromJSON(e)); + } + } + if (object.oneofDecl !== undefined && object.oneofDecl !== null) { + for (const e of object.oneofDecl) { + message.oneofDecl.push(OneofDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = MessageOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push(DescriptorProto_ReservedRange.fromJSON(e)); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(String(e)); + } + } + return message; + }, + + toJSON(message: DescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + if (message.field) { + obj.field = message.field.map((e) => + e ? FieldDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.field = []; + } + if (message.extension) { + obj.extension = message.extension.map((e) => + e ? FieldDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.extension = []; + } + if (message.nestedType) { + obj.nestedType = message.nestedType.map((e) => + e ? DescriptorProto.toJSON(e) : undefined + ); + } else { + obj.nestedType = []; + } + if (message.enumType) { + obj.enumType = message.enumType.map((e) => + e ? EnumDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.enumType = []; + } + if (message.extensionRange) { + obj.extensionRange = message.extensionRange.map((e) => + e ? DescriptorProto_ExtensionRange.toJSON(e) : undefined + ); + } else { + obj.extensionRange = []; + } + if (message.oneofDecl) { + obj.oneofDecl = message.oneofDecl.map((e) => + e ? OneofDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.oneofDecl = []; + } + message.options !== undefined && + (obj.options = message.options + ? MessageOptions.toJSON(message.options) + : undefined); + if (message.reservedRange) { + obj.reservedRange = message.reservedRange.map((e) => + e ? DescriptorProto_ReservedRange.toJSON(e) : undefined + ); + } else { + obj.reservedRange = []; + } + if (message.reservedName) { + obj.reservedName = message.reservedName.map((e) => e); + } else { + obj.reservedName = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): DescriptorProto { + const message = { ...baseDescriptorProto } as DescriptorProto; + message.field = []; + message.extension = []; + message.nestedType = []; + message.enumType = []; + message.extensionRange = []; + message.oneofDecl = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.field !== undefined && object.field !== null) { + for (const e of object.field) { + message.field.push(FieldDescriptorProto.fromPartial(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromPartial(e)); + } + } + if (object.nestedType !== undefined && object.nestedType !== null) { + for (const e of object.nestedType) { + message.nestedType.push(DescriptorProto.fromPartial(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromPartial(e)); + } + } + if (object.extensionRange !== undefined && object.extensionRange !== null) { + for (const e of object.extensionRange) { + message.extensionRange.push( + DescriptorProto_ExtensionRange.fromPartial(e) + ); + } + } + if (object.oneofDecl !== undefined && object.oneofDecl !== null) { + for (const e of object.oneofDecl) { + message.oneofDecl.push(OneofDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = MessageOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push( + DescriptorProto_ReservedRange.fromPartial(e) + ); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(e); + } + } + return message; + }, +}; + +const baseDescriptorProto_ExtensionRange: object = { start: 0, end: 0 }; + +export const DescriptorProto_ExtensionRange = { + encode( + message: DescriptorProto_ExtensionRange, + writer: Writer = Writer.create() + ): Writer { + if (message.start !== 0) { + writer.uint32(8).int32(message.start); + } + if (message.end !== 0) { + writer.uint32(16).int32(message.end); + } + if (message.options !== undefined) { + ExtensionRangeOptions.encode( + message.options, + writer.uint32(26).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): DescriptorProto_ExtensionRange { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseDescriptorProto_ExtensionRange, + } as DescriptorProto_ExtensionRange; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.start = reader.int32(); + break; + case 2: + message.end = reader.int32(); + break; + case 3: + message.options = ExtensionRangeOptions.decode( + reader, + reader.uint32() + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DescriptorProto_ExtensionRange { + const message = { + ...baseDescriptorProto_ExtensionRange, + } as DescriptorProto_ExtensionRange; + if (object.start !== undefined && object.start !== null) { + message.start = Number(object.start); + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = ExtensionRangeOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: DescriptorProto_ExtensionRange): unknown { + const obj: any = {}; + message.start !== undefined && (obj.start = message.start); + message.end !== undefined && (obj.end = message.end); + message.options !== undefined && + (obj.options = message.options + ? ExtensionRangeOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): DescriptorProto_ExtensionRange { + const message = { + ...baseDescriptorProto_ExtensionRange, + } as DescriptorProto_ExtensionRange; + if (object.start !== undefined && object.start !== null) { + message.start = object.start; + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = ExtensionRangeOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseDescriptorProto_ReservedRange: object = { start: 0, end: 0 }; + +export const DescriptorProto_ReservedRange = { + encode( + message: DescriptorProto_ReservedRange, + writer: Writer = Writer.create() + ): Writer { + if (message.start !== 0) { + writer.uint32(8).int32(message.start); + } + if (message.end !== 0) { + writer.uint32(16).int32(message.end); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): DescriptorProto_ReservedRange { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseDescriptorProto_ReservedRange, + } as DescriptorProto_ReservedRange; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.start = reader.int32(); + break; + case 2: + message.end = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DescriptorProto_ReservedRange { + const message = { + ...baseDescriptorProto_ReservedRange, + } as DescriptorProto_ReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = Number(object.start); + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + return message; + }, + + toJSON(message: DescriptorProto_ReservedRange): unknown { + const obj: any = {}; + message.start !== undefined && (obj.start = message.start); + message.end !== undefined && (obj.end = message.end); + return obj; + }, + + fromPartial( + object: DeepPartial + ): DescriptorProto_ReservedRange { + const message = { + ...baseDescriptorProto_ReservedRange, + } as DescriptorProto_ReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = object.start; + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + return message; + }, +}; + +const baseExtensionRangeOptions: object = {}; + +export const ExtensionRangeOptions = { + encode( + message: ExtensionRangeOptions, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ExtensionRangeOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseExtensionRangeOptions } as ExtensionRangeOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ExtensionRangeOptions { + const message = { ...baseExtensionRangeOptions } as ExtensionRangeOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: ExtensionRangeOptions): unknown { + const obj: any = {}; + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial( + object: DeepPartial + ): ExtensionRangeOptions { + const message = { ...baseExtensionRangeOptions } as ExtensionRangeOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseFieldDescriptorProto: object = { + name: "", + number: 0, + label: 1, + type: 1, + typeName: "", + extendee: "", + defaultValue: "", + oneofIndex: 0, + jsonName: "", + proto3Optional: false, +}; + +export const FieldDescriptorProto = { + encode( + message: FieldDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.number !== 0) { + writer.uint32(24).int32(message.number); + } + if (message.label !== 1) { + writer.uint32(32).int32(message.label); + } + if (message.type !== 1) { + writer.uint32(40).int32(message.type); + } + if (message.typeName !== "") { + writer.uint32(50).string(message.typeName); + } + if (message.extendee !== "") { + writer.uint32(18).string(message.extendee); + } + if (message.defaultValue !== "") { + writer.uint32(58).string(message.defaultValue); + } + if (message.oneofIndex !== 0) { + writer.uint32(72).int32(message.oneofIndex); + } + if (message.jsonName !== "") { + writer.uint32(82).string(message.jsonName); + } + if (message.options !== undefined) { + FieldOptions.encode(message.options, writer.uint32(66).fork()).ldelim(); + } + if (message.proto3Optional === true) { + writer.uint32(136).bool(message.proto3Optional); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FieldDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFieldDescriptorProto } as FieldDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 3: + message.number = reader.int32(); + break; + case 4: + message.label = reader.int32() as any; + break; + case 5: + message.type = reader.int32() as any; + break; + case 6: + message.typeName = reader.string(); + break; + case 2: + message.extendee = reader.string(); + break; + case 7: + message.defaultValue = reader.string(); + break; + case 9: + message.oneofIndex = reader.int32(); + break; + case 10: + message.jsonName = reader.string(); + break; + case 8: + message.options = FieldOptions.decode(reader, reader.uint32()); + break; + case 17: + message.proto3Optional = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FieldDescriptorProto { + const message = { ...baseFieldDescriptorProto } as FieldDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = Number(object.number); + } else { + message.number = 0; + } + if (object.label !== undefined && object.label !== null) { + message.label = fieldDescriptorProto_LabelFromJSON(object.label); + } else { + message.label = 1; + } + if (object.type !== undefined && object.type !== null) { + message.type = fieldDescriptorProto_TypeFromJSON(object.type); + } else { + message.type = 1; + } + if (object.typeName !== undefined && object.typeName !== null) { + message.typeName = String(object.typeName); + } else { + message.typeName = ""; + } + if (object.extendee !== undefined && object.extendee !== null) { + message.extendee = String(object.extendee); + } else { + message.extendee = ""; + } + if (object.defaultValue !== undefined && object.defaultValue !== null) { + message.defaultValue = String(object.defaultValue); + } else { + message.defaultValue = ""; + } + if (object.oneofIndex !== undefined && object.oneofIndex !== null) { + message.oneofIndex = Number(object.oneofIndex); + } else { + message.oneofIndex = 0; + } + if (object.jsonName !== undefined && object.jsonName !== null) { + message.jsonName = String(object.jsonName); + } else { + message.jsonName = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = FieldOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.proto3Optional !== undefined && object.proto3Optional !== null) { + message.proto3Optional = Boolean(object.proto3Optional); + } else { + message.proto3Optional = false; + } + return message; + }, + + toJSON(message: FieldDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.number !== undefined && (obj.number = message.number); + message.label !== undefined && + (obj.label = fieldDescriptorProto_LabelToJSON(message.label)); + message.type !== undefined && + (obj.type = fieldDescriptorProto_TypeToJSON(message.type)); + message.typeName !== undefined && (obj.typeName = message.typeName); + message.extendee !== undefined && (obj.extendee = message.extendee); + message.defaultValue !== undefined && + (obj.defaultValue = message.defaultValue); + message.oneofIndex !== undefined && (obj.oneofIndex = message.oneofIndex); + message.jsonName !== undefined && (obj.jsonName = message.jsonName); + message.options !== undefined && + (obj.options = message.options + ? FieldOptions.toJSON(message.options) + : undefined); + message.proto3Optional !== undefined && + (obj.proto3Optional = message.proto3Optional); + return obj; + }, + + fromPartial(object: DeepPartial): FieldDescriptorProto { + const message = { ...baseFieldDescriptorProto } as FieldDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = object.number; + } else { + message.number = 0; + } + if (object.label !== undefined && object.label !== null) { + message.label = object.label; + } else { + message.label = 1; + } + if (object.type !== undefined && object.type !== null) { + message.type = object.type; + } else { + message.type = 1; + } + if (object.typeName !== undefined && object.typeName !== null) { + message.typeName = object.typeName; + } else { + message.typeName = ""; + } + if (object.extendee !== undefined && object.extendee !== null) { + message.extendee = object.extendee; + } else { + message.extendee = ""; + } + if (object.defaultValue !== undefined && object.defaultValue !== null) { + message.defaultValue = object.defaultValue; + } else { + message.defaultValue = ""; + } + if (object.oneofIndex !== undefined && object.oneofIndex !== null) { + message.oneofIndex = object.oneofIndex; + } else { + message.oneofIndex = 0; + } + if (object.jsonName !== undefined && object.jsonName !== null) { + message.jsonName = object.jsonName; + } else { + message.jsonName = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = FieldOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.proto3Optional !== undefined && object.proto3Optional !== null) { + message.proto3Optional = object.proto3Optional; + } else { + message.proto3Optional = false; + } + return message; + }, +}; + +const baseOneofDescriptorProto: object = { name: "" }; + +export const OneofDescriptorProto = { + encode( + message: OneofDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.options !== undefined) { + OneofOptions.encode(message.options, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): OneofDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseOneofDescriptorProto } as OneofDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.options = OneofOptions.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): OneofDescriptorProto { + const message = { ...baseOneofDescriptorProto } as OneofDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = OneofOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: OneofDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.options !== undefined && + (obj.options = message.options + ? OneofOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): OneofDescriptorProto { + const message = { ...baseOneofDescriptorProto } as OneofDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = OneofOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseEnumDescriptorProto: object = { name: "", reservedName: "" }; + +export const EnumDescriptorProto = { + encode( + message: EnumDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + for (const v of message.value) { + EnumValueDescriptorProto.encode(v!, writer.uint32(18).fork()).ldelim(); + } + if (message.options !== undefined) { + EnumOptions.encode(message.options, writer.uint32(26).fork()).ldelim(); + } + for (const v of message.reservedRange) { + EnumDescriptorProto_EnumReservedRange.encode( + v!, + writer.uint32(34).fork() + ).ldelim(); + } + for (const v of message.reservedName) { + writer.uint32(42).string(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): EnumDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseEnumDescriptorProto } as EnumDescriptorProto; + message.value = []; + message.reservedRange = []; + message.reservedName = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.value.push( + EnumValueDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 3: + message.options = EnumOptions.decode(reader, reader.uint32()); + break; + case 4: + message.reservedRange.push( + EnumDescriptorProto_EnumReservedRange.decode( + reader, + reader.uint32() + ) + ); + break; + case 5: + message.reservedName.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumDescriptorProto { + const message = { ...baseEnumDescriptorProto } as EnumDescriptorProto; + message.value = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.value !== undefined && object.value !== null) { + for (const e of object.value) { + message.value.push(EnumValueDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push( + EnumDescriptorProto_EnumReservedRange.fromJSON(e) + ); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(String(e)); + } + } + return message; + }, + + toJSON(message: EnumDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + if (message.value) { + obj.value = message.value.map((e) => + e ? EnumValueDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.value = []; + } + message.options !== undefined && + (obj.options = message.options + ? EnumOptions.toJSON(message.options) + : undefined); + if (message.reservedRange) { + obj.reservedRange = message.reservedRange.map((e) => + e ? EnumDescriptorProto_EnumReservedRange.toJSON(e) : undefined + ); + } else { + obj.reservedRange = []; + } + if (message.reservedName) { + obj.reservedName = message.reservedName.map((e) => e); + } else { + obj.reservedName = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): EnumDescriptorProto { + const message = { ...baseEnumDescriptorProto } as EnumDescriptorProto; + message.value = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.value !== undefined && object.value !== null) { + for (const e of object.value) { + message.value.push(EnumValueDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push( + EnumDescriptorProto_EnumReservedRange.fromPartial(e) + ); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(e); + } + } + return message; + }, +}; + +const baseEnumDescriptorProto_EnumReservedRange: object = { start: 0, end: 0 }; + +export const EnumDescriptorProto_EnumReservedRange = { + encode( + message: EnumDescriptorProto_EnumReservedRange, + writer: Writer = Writer.create() + ): Writer { + if (message.start !== 0) { + writer.uint32(8).int32(message.start); + } + if (message.end !== 0) { + writer.uint32(16).int32(message.end); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): EnumDescriptorProto_EnumReservedRange { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseEnumDescriptorProto_EnumReservedRange, + } as EnumDescriptorProto_EnumReservedRange; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.start = reader.int32(); + break; + case 2: + message.end = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumDescriptorProto_EnumReservedRange { + const message = { + ...baseEnumDescriptorProto_EnumReservedRange, + } as EnumDescriptorProto_EnumReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = Number(object.start); + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + return message; + }, + + toJSON(message: EnumDescriptorProto_EnumReservedRange): unknown { + const obj: any = {}; + message.start !== undefined && (obj.start = message.start); + message.end !== undefined && (obj.end = message.end); + return obj; + }, + + fromPartial( + object: DeepPartial + ): EnumDescriptorProto_EnumReservedRange { + const message = { + ...baseEnumDescriptorProto_EnumReservedRange, + } as EnumDescriptorProto_EnumReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = object.start; + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + return message; + }, +}; + +const baseEnumValueDescriptorProto: object = { name: "", number: 0 }; + +export const EnumValueDescriptorProto = { + encode( + message: EnumValueDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.number !== 0) { + writer.uint32(16).int32(message.number); + } + if (message.options !== undefined) { + EnumValueOptions.encode( + message.options, + writer.uint32(26).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): EnumValueDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseEnumValueDescriptorProto, + } as EnumValueDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.number = reader.int32(); + break; + case 3: + message.options = EnumValueOptions.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumValueDescriptorProto { + const message = { + ...baseEnumValueDescriptorProto, + } as EnumValueDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = Number(object.number); + } else { + message.number = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumValueOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: EnumValueDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.number !== undefined && (obj.number = message.number); + message.options !== undefined && + (obj.options = message.options + ? EnumValueOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): EnumValueDescriptorProto { + const message = { + ...baseEnumValueDescriptorProto, + } as EnumValueDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = object.number; + } else { + message.number = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumValueOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseServiceDescriptorProto: object = { name: "" }; + +export const ServiceDescriptorProto = { + encode( + message: ServiceDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + for (const v of message.method) { + MethodDescriptorProto.encode(v!, writer.uint32(18).fork()).ldelim(); + } + if (message.options !== undefined) { + ServiceOptions.encode(message.options, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ServiceDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseServiceDescriptorProto } as ServiceDescriptorProto; + message.method = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.method.push( + MethodDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 3: + message.options = ServiceOptions.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ServiceDescriptorProto { + const message = { ...baseServiceDescriptorProto } as ServiceDescriptorProto; + message.method = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.method !== undefined && object.method !== null) { + for (const e of object.method) { + message.method.push(MethodDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = ServiceOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: ServiceDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + if (message.method) { + obj.method = message.method.map((e) => + e ? MethodDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.method = []; + } + message.options !== undefined && + (obj.options = message.options + ? ServiceOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): ServiceDescriptorProto { + const message = { ...baseServiceDescriptorProto } as ServiceDescriptorProto; + message.method = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.method !== undefined && object.method !== null) { + for (const e of object.method) { + message.method.push(MethodDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = ServiceOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseMethodDescriptorProto: object = { + name: "", + inputType: "", + outputType: "", + clientStreaming: false, + serverStreaming: false, +}; + +export const MethodDescriptorProto = { + encode( + message: MethodDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.inputType !== "") { + writer.uint32(18).string(message.inputType); + } + if (message.outputType !== "") { + writer.uint32(26).string(message.outputType); + } + if (message.options !== undefined) { + MethodOptions.encode(message.options, writer.uint32(34).fork()).ldelim(); + } + if (message.clientStreaming === true) { + writer.uint32(40).bool(message.clientStreaming); + } + if (message.serverStreaming === true) { + writer.uint32(48).bool(message.serverStreaming); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MethodDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMethodDescriptorProto } as MethodDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.inputType = reader.string(); + break; + case 3: + message.outputType = reader.string(); + break; + case 4: + message.options = MethodOptions.decode(reader, reader.uint32()); + break; + case 5: + message.clientStreaming = reader.bool(); + break; + case 6: + message.serverStreaming = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MethodDescriptorProto { + const message = { ...baseMethodDescriptorProto } as MethodDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.inputType !== undefined && object.inputType !== null) { + message.inputType = String(object.inputType); + } else { + message.inputType = ""; + } + if (object.outputType !== undefined && object.outputType !== null) { + message.outputType = String(object.outputType); + } else { + message.outputType = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = MethodOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if ( + object.clientStreaming !== undefined && + object.clientStreaming !== null + ) { + message.clientStreaming = Boolean(object.clientStreaming); + } else { + message.clientStreaming = false; + } + if ( + object.serverStreaming !== undefined && + object.serverStreaming !== null + ) { + message.serverStreaming = Boolean(object.serverStreaming); + } else { + message.serverStreaming = false; + } + return message; + }, + + toJSON(message: MethodDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.inputType !== undefined && (obj.inputType = message.inputType); + message.outputType !== undefined && (obj.outputType = message.outputType); + message.options !== undefined && + (obj.options = message.options + ? MethodOptions.toJSON(message.options) + : undefined); + message.clientStreaming !== undefined && + (obj.clientStreaming = message.clientStreaming); + message.serverStreaming !== undefined && + (obj.serverStreaming = message.serverStreaming); + return obj; + }, + + fromPartial( + object: DeepPartial + ): MethodDescriptorProto { + const message = { ...baseMethodDescriptorProto } as MethodDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.inputType !== undefined && object.inputType !== null) { + message.inputType = object.inputType; + } else { + message.inputType = ""; + } + if (object.outputType !== undefined && object.outputType !== null) { + message.outputType = object.outputType; + } else { + message.outputType = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = MethodOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if ( + object.clientStreaming !== undefined && + object.clientStreaming !== null + ) { + message.clientStreaming = object.clientStreaming; + } else { + message.clientStreaming = false; + } + if ( + object.serverStreaming !== undefined && + object.serverStreaming !== null + ) { + message.serverStreaming = object.serverStreaming; + } else { + message.serverStreaming = false; + } + return message; + }, +}; + +const baseFileOptions: object = { + javaPackage: "", + javaOuterClassname: "", + javaMultipleFiles: false, + javaGenerateEqualsAndHash: false, + javaStringCheckUtf8: false, + optimizeFor: 1, + goPackage: "", + ccGenericServices: false, + javaGenericServices: false, + pyGenericServices: false, + phpGenericServices: false, + deprecated: false, + ccEnableArenas: false, + objcClassPrefix: "", + csharpNamespace: "", + swiftPrefix: "", + phpClassPrefix: "", + phpNamespace: "", + phpMetadataNamespace: "", + rubyPackage: "", +}; + +export const FileOptions = { + encode(message: FileOptions, writer: Writer = Writer.create()): Writer { + if (message.javaPackage !== "") { + writer.uint32(10).string(message.javaPackage); + } + if (message.javaOuterClassname !== "") { + writer.uint32(66).string(message.javaOuterClassname); + } + if (message.javaMultipleFiles === true) { + writer.uint32(80).bool(message.javaMultipleFiles); + } + if (message.javaGenerateEqualsAndHash === true) { + writer.uint32(160).bool(message.javaGenerateEqualsAndHash); + } + if (message.javaStringCheckUtf8 === true) { + writer.uint32(216).bool(message.javaStringCheckUtf8); + } + if (message.optimizeFor !== 1) { + writer.uint32(72).int32(message.optimizeFor); + } + if (message.goPackage !== "") { + writer.uint32(90).string(message.goPackage); + } + if (message.ccGenericServices === true) { + writer.uint32(128).bool(message.ccGenericServices); + } + if (message.javaGenericServices === true) { + writer.uint32(136).bool(message.javaGenericServices); + } + if (message.pyGenericServices === true) { + writer.uint32(144).bool(message.pyGenericServices); + } + if (message.phpGenericServices === true) { + writer.uint32(336).bool(message.phpGenericServices); + } + if (message.deprecated === true) { + writer.uint32(184).bool(message.deprecated); + } + if (message.ccEnableArenas === true) { + writer.uint32(248).bool(message.ccEnableArenas); + } + if (message.objcClassPrefix !== "") { + writer.uint32(290).string(message.objcClassPrefix); + } + if (message.csharpNamespace !== "") { + writer.uint32(298).string(message.csharpNamespace); + } + if (message.swiftPrefix !== "") { + writer.uint32(314).string(message.swiftPrefix); + } + if (message.phpClassPrefix !== "") { + writer.uint32(322).string(message.phpClassPrefix); + } + if (message.phpNamespace !== "") { + writer.uint32(330).string(message.phpNamespace); + } + if (message.phpMetadataNamespace !== "") { + writer.uint32(354).string(message.phpMetadataNamespace); + } + if (message.rubyPackage !== "") { + writer.uint32(362).string(message.rubyPackage); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FileOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFileOptions } as FileOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.javaPackage = reader.string(); + break; + case 8: + message.javaOuterClassname = reader.string(); + break; + case 10: + message.javaMultipleFiles = reader.bool(); + break; + case 20: + message.javaGenerateEqualsAndHash = reader.bool(); + break; + case 27: + message.javaStringCheckUtf8 = reader.bool(); + break; + case 9: + message.optimizeFor = reader.int32() as any; + break; + case 11: + message.goPackage = reader.string(); + break; + case 16: + message.ccGenericServices = reader.bool(); + break; + case 17: + message.javaGenericServices = reader.bool(); + break; + case 18: + message.pyGenericServices = reader.bool(); + break; + case 42: + message.phpGenericServices = reader.bool(); + break; + case 23: + message.deprecated = reader.bool(); + break; + case 31: + message.ccEnableArenas = reader.bool(); + break; + case 36: + message.objcClassPrefix = reader.string(); + break; + case 37: + message.csharpNamespace = reader.string(); + break; + case 39: + message.swiftPrefix = reader.string(); + break; + case 40: + message.phpClassPrefix = reader.string(); + break; + case 41: + message.phpNamespace = reader.string(); + break; + case 44: + message.phpMetadataNamespace = reader.string(); + break; + case 45: + message.rubyPackage = reader.string(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FileOptions { + const message = { ...baseFileOptions } as FileOptions; + message.uninterpretedOption = []; + if (object.javaPackage !== undefined && object.javaPackage !== null) { + message.javaPackage = String(object.javaPackage); + } else { + message.javaPackage = ""; + } + if ( + object.javaOuterClassname !== undefined && + object.javaOuterClassname !== null + ) { + message.javaOuterClassname = String(object.javaOuterClassname); + } else { + message.javaOuterClassname = ""; + } + if ( + object.javaMultipleFiles !== undefined && + object.javaMultipleFiles !== null + ) { + message.javaMultipleFiles = Boolean(object.javaMultipleFiles); + } else { + message.javaMultipleFiles = false; + } + if ( + object.javaGenerateEqualsAndHash !== undefined && + object.javaGenerateEqualsAndHash !== null + ) { + message.javaGenerateEqualsAndHash = Boolean( + object.javaGenerateEqualsAndHash + ); + } else { + message.javaGenerateEqualsAndHash = false; + } + if ( + object.javaStringCheckUtf8 !== undefined && + object.javaStringCheckUtf8 !== null + ) { + message.javaStringCheckUtf8 = Boolean(object.javaStringCheckUtf8); + } else { + message.javaStringCheckUtf8 = false; + } + if (object.optimizeFor !== undefined && object.optimizeFor !== null) { + message.optimizeFor = fileOptions_OptimizeModeFromJSON( + object.optimizeFor + ); + } else { + message.optimizeFor = 1; + } + if (object.goPackage !== undefined && object.goPackage !== null) { + message.goPackage = String(object.goPackage); + } else { + message.goPackage = ""; + } + if ( + object.ccGenericServices !== undefined && + object.ccGenericServices !== null + ) { + message.ccGenericServices = Boolean(object.ccGenericServices); + } else { + message.ccGenericServices = false; + } + if ( + object.javaGenericServices !== undefined && + object.javaGenericServices !== null + ) { + message.javaGenericServices = Boolean(object.javaGenericServices); + } else { + message.javaGenericServices = false; + } + if ( + object.pyGenericServices !== undefined && + object.pyGenericServices !== null + ) { + message.pyGenericServices = Boolean(object.pyGenericServices); + } else { + message.pyGenericServices = false; + } + if ( + object.phpGenericServices !== undefined && + object.phpGenericServices !== null + ) { + message.phpGenericServices = Boolean(object.phpGenericServices); + } else { + message.phpGenericServices = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if (object.ccEnableArenas !== undefined && object.ccEnableArenas !== null) { + message.ccEnableArenas = Boolean(object.ccEnableArenas); + } else { + message.ccEnableArenas = false; + } + if ( + object.objcClassPrefix !== undefined && + object.objcClassPrefix !== null + ) { + message.objcClassPrefix = String(object.objcClassPrefix); + } else { + message.objcClassPrefix = ""; + } + if ( + object.csharpNamespace !== undefined && + object.csharpNamespace !== null + ) { + message.csharpNamespace = String(object.csharpNamespace); + } else { + message.csharpNamespace = ""; + } + if (object.swiftPrefix !== undefined && object.swiftPrefix !== null) { + message.swiftPrefix = String(object.swiftPrefix); + } else { + message.swiftPrefix = ""; + } + if (object.phpClassPrefix !== undefined && object.phpClassPrefix !== null) { + message.phpClassPrefix = String(object.phpClassPrefix); + } else { + message.phpClassPrefix = ""; + } + if (object.phpNamespace !== undefined && object.phpNamespace !== null) { + message.phpNamespace = String(object.phpNamespace); + } else { + message.phpNamespace = ""; + } + if ( + object.phpMetadataNamespace !== undefined && + object.phpMetadataNamespace !== null + ) { + message.phpMetadataNamespace = String(object.phpMetadataNamespace); + } else { + message.phpMetadataNamespace = ""; + } + if (object.rubyPackage !== undefined && object.rubyPackage !== null) { + message.rubyPackage = String(object.rubyPackage); + } else { + message.rubyPackage = ""; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: FileOptions): unknown { + const obj: any = {}; + message.javaPackage !== undefined && + (obj.javaPackage = message.javaPackage); + message.javaOuterClassname !== undefined && + (obj.javaOuterClassname = message.javaOuterClassname); + message.javaMultipleFiles !== undefined && + (obj.javaMultipleFiles = message.javaMultipleFiles); + message.javaGenerateEqualsAndHash !== undefined && + (obj.javaGenerateEqualsAndHash = message.javaGenerateEqualsAndHash); + message.javaStringCheckUtf8 !== undefined && + (obj.javaStringCheckUtf8 = message.javaStringCheckUtf8); + message.optimizeFor !== undefined && + (obj.optimizeFor = fileOptions_OptimizeModeToJSON(message.optimizeFor)); + message.goPackage !== undefined && (obj.goPackage = message.goPackage); + message.ccGenericServices !== undefined && + (obj.ccGenericServices = message.ccGenericServices); + message.javaGenericServices !== undefined && + (obj.javaGenericServices = message.javaGenericServices); + message.pyGenericServices !== undefined && + (obj.pyGenericServices = message.pyGenericServices); + message.phpGenericServices !== undefined && + (obj.phpGenericServices = message.phpGenericServices); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.ccEnableArenas !== undefined && + (obj.ccEnableArenas = message.ccEnableArenas); + message.objcClassPrefix !== undefined && + (obj.objcClassPrefix = message.objcClassPrefix); + message.csharpNamespace !== undefined && + (obj.csharpNamespace = message.csharpNamespace); + message.swiftPrefix !== undefined && + (obj.swiftPrefix = message.swiftPrefix); + message.phpClassPrefix !== undefined && + (obj.phpClassPrefix = message.phpClassPrefix); + message.phpNamespace !== undefined && + (obj.phpNamespace = message.phpNamespace); + message.phpMetadataNamespace !== undefined && + (obj.phpMetadataNamespace = message.phpMetadataNamespace); + message.rubyPackage !== undefined && + (obj.rubyPackage = message.rubyPackage); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): FileOptions { + const message = { ...baseFileOptions } as FileOptions; + message.uninterpretedOption = []; + if (object.javaPackage !== undefined && object.javaPackage !== null) { + message.javaPackage = object.javaPackage; + } else { + message.javaPackage = ""; + } + if ( + object.javaOuterClassname !== undefined && + object.javaOuterClassname !== null + ) { + message.javaOuterClassname = object.javaOuterClassname; + } else { + message.javaOuterClassname = ""; + } + if ( + object.javaMultipleFiles !== undefined && + object.javaMultipleFiles !== null + ) { + message.javaMultipleFiles = object.javaMultipleFiles; + } else { + message.javaMultipleFiles = false; + } + if ( + object.javaGenerateEqualsAndHash !== undefined && + object.javaGenerateEqualsAndHash !== null + ) { + message.javaGenerateEqualsAndHash = object.javaGenerateEqualsAndHash; + } else { + message.javaGenerateEqualsAndHash = false; + } + if ( + object.javaStringCheckUtf8 !== undefined && + object.javaStringCheckUtf8 !== null + ) { + message.javaStringCheckUtf8 = object.javaStringCheckUtf8; + } else { + message.javaStringCheckUtf8 = false; + } + if (object.optimizeFor !== undefined && object.optimizeFor !== null) { + message.optimizeFor = object.optimizeFor; + } else { + message.optimizeFor = 1; + } + if (object.goPackage !== undefined && object.goPackage !== null) { + message.goPackage = object.goPackage; + } else { + message.goPackage = ""; + } + if ( + object.ccGenericServices !== undefined && + object.ccGenericServices !== null + ) { + message.ccGenericServices = object.ccGenericServices; + } else { + message.ccGenericServices = false; + } + if ( + object.javaGenericServices !== undefined && + object.javaGenericServices !== null + ) { + message.javaGenericServices = object.javaGenericServices; + } else { + message.javaGenericServices = false; + } + if ( + object.pyGenericServices !== undefined && + object.pyGenericServices !== null + ) { + message.pyGenericServices = object.pyGenericServices; + } else { + message.pyGenericServices = false; + } + if ( + object.phpGenericServices !== undefined && + object.phpGenericServices !== null + ) { + message.phpGenericServices = object.phpGenericServices; + } else { + message.phpGenericServices = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if (object.ccEnableArenas !== undefined && object.ccEnableArenas !== null) { + message.ccEnableArenas = object.ccEnableArenas; + } else { + message.ccEnableArenas = false; + } + if ( + object.objcClassPrefix !== undefined && + object.objcClassPrefix !== null + ) { + message.objcClassPrefix = object.objcClassPrefix; + } else { + message.objcClassPrefix = ""; + } + if ( + object.csharpNamespace !== undefined && + object.csharpNamespace !== null + ) { + message.csharpNamespace = object.csharpNamespace; + } else { + message.csharpNamespace = ""; + } + if (object.swiftPrefix !== undefined && object.swiftPrefix !== null) { + message.swiftPrefix = object.swiftPrefix; + } else { + message.swiftPrefix = ""; + } + if (object.phpClassPrefix !== undefined && object.phpClassPrefix !== null) { + message.phpClassPrefix = object.phpClassPrefix; + } else { + message.phpClassPrefix = ""; + } + if (object.phpNamespace !== undefined && object.phpNamespace !== null) { + message.phpNamespace = object.phpNamespace; + } else { + message.phpNamespace = ""; + } + if ( + object.phpMetadataNamespace !== undefined && + object.phpMetadataNamespace !== null + ) { + message.phpMetadataNamespace = object.phpMetadataNamespace; + } else { + message.phpMetadataNamespace = ""; + } + if (object.rubyPackage !== undefined && object.rubyPackage !== null) { + message.rubyPackage = object.rubyPackage; + } else { + message.rubyPackage = ""; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseMessageOptions: object = { + messageSetWireFormat: false, + noStandardDescriptorAccessor: false, + deprecated: false, + mapEntry: false, +}; + +export const MessageOptions = { + encode(message: MessageOptions, writer: Writer = Writer.create()): Writer { + if (message.messageSetWireFormat === true) { + writer.uint32(8).bool(message.messageSetWireFormat); + } + if (message.noStandardDescriptorAccessor === true) { + writer.uint32(16).bool(message.noStandardDescriptorAccessor); + } + if (message.deprecated === true) { + writer.uint32(24).bool(message.deprecated); + } + if (message.mapEntry === true) { + writer.uint32(56).bool(message.mapEntry); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MessageOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMessageOptions } as MessageOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.messageSetWireFormat = reader.bool(); + break; + case 2: + message.noStandardDescriptorAccessor = reader.bool(); + break; + case 3: + message.deprecated = reader.bool(); + break; + case 7: + message.mapEntry = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MessageOptions { + const message = { ...baseMessageOptions } as MessageOptions; + message.uninterpretedOption = []; + if ( + object.messageSetWireFormat !== undefined && + object.messageSetWireFormat !== null + ) { + message.messageSetWireFormat = Boolean(object.messageSetWireFormat); + } else { + message.messageSetWireFormat = false; + } + if ( + object.noStandardDescriptorAccessor !== undefined && + object.noStandardDescriptorAccessor !== null + ) { + message.noStandardDescriptorAccessor = Boolean( + object.noStandardDescriptorAccessor + ); + } else { + message.noStandardDescriptorAccessor = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if (object.mapEntry !== undefined && object.mapEntry !== null) { + message.mapEntry = Boolean(object.mapEntry); + } else { + message.mapEntry = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: MessageOptions): unknown { + const obj: any = {}; + message.messageSetWireFormat !== undefined && + (obj.messageSetWireFormat = message.messageSetWireFormat); + message.noStandardDescriptorAccessor !== undefined && + (obj.noStandardDescriptorAccessor = message.noStandardDescriptorAccessor); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.mapEntry !== undefined && (obj.mapEntry = message.mapEntry); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): MessageOptions { + const message = { ...baseMessageOptions } as MessageOptions; + message.uninterpretedOption = []; + if ( + object.messageSetWireFormat !== undefined && + object.messageSetWireFormat !== null + ) { + message.messageSetWireFormat = object.messageSetWireFormat; + } else { + message.messageSetWireFormat = false; + } + if ( + object.noStandardDescriptorAccessor !== undefined && + object.noStandardDescriptorAccessor !== null + ) { + message.noStandardDescriptorAccessor = + object.noStandardDescriptorAccessor; + } else { + message.noStandardDescriptorAccessor = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if (object.mapEntry !== undefined && object.mapEntry !== null) { + message.mapEntry = object.mapEntry; + } else { + message.mapEntry = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseFieldOptions: object = { + ctype: 0, + packed: false, + jstype: 0, + lazy: false, + deprecated: false, + weak: false, +}; + +export const FieldOptions = { + encode(message: FieldOptions, writer: Writer = Writer.create()): Writer { + if (message.ctype !== 0) { + writer.uint32(8).int32(message.ctype); + } + if (message.packed === true) { + writer.uint32(16).bool(message.packed); + } + if (message.jstype !== 0) { + writer.uint32(48).int32(message.jstype); + } + if (message.lazy === true) { + writer.uint32(40).bool(message.lazy); + } + if (message.deprecated === true) { + writer.uint32(24).bool(message.deprecated); + } + if (message.weak === true) { + writer.uint32(80).bool(message.weak); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FieldOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFieldOptions } as FieldOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.ctype = reader.int32() as any; + break; + case 2: + message.packed = reader.bool(); + break; + case 6: + message.jstype = reader.int32() as any; + break; + case 5: + message.lazy = reader.bool(); + break; + case 3: + message.deprecated = reader.bool(); + break; + case 10: + message.weak = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FieldOptions { + const message = { ...baseFieldOptions } as FieldOptions; + message.uninterpretedOption = []; + if (object.ctype !== undefined && object.ctype !== null) { + message.ctype = fieldOptions_CTypeFromJSON(object.ctype); + } else { + message.ctype = 0; + } + if (object.packed !== undefined && object.packed !== null) { + message.packed = Boolean(object.packed); + } else { + message.packed = false; + } + if (object.jstype !== undefined && object.jstype !== null) { + message.jstype = fieldOptions_JSTypeFromJSON(object.jstype); + } else { + message.jstype = 0; + } + if (object.lazy !== undefined && object.lazy !== null) { + message.lazy = Boolean(object.lazy); + } else { + message.lazy = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if (object.weak !== undefined && object.weak !== null) { + message.weak = Boolean(object.weak); + } else { + message.weak = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: FieldOptions): unknown { + const obj: any = {}; + message.ctype !== undefined && + (obj.ctype = fieldOptions_CTypeToJSON(message.ctype)); + message.packed !== undefined && (obj.packed = message.packed); + message.jstype !== undefined && + (obj.jstype = fieldOptions_JSTypeToJSON(message.jstype)); + message.lazy !== undefined && (obj.lazy = message.lazy); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.weak !== undefined && (obj.weak = message.weak); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): FieldOptions { + const message = { ...baseFieldOptions } as FieldOptions; + message.uninterpretedOption = []; + if (object.ctype !== undefined && object.ctype !== null) { + message.ctype = object.ctype; + } else { + message.ctype = 0; + } + if (object.packed !== undefined && object.packed !== null) { + message.packed = object.packed; + } else { + message.packed = false; + } + if (object.jstype !== undefined && object.jstype !== null) { + message.jstype = object.jstype; + } else { + message.jstype = 0; + } + if (object.lazy !== undefined && object.lazy !== null) { + message.lazy = object.lazy; + } else { + message.lazy = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if (object.weak !== undefined && object.weak !== null) { + message.weak = object.weak; + } else { + message.weak = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseOneofOptions: object = {}; + +export const OneofOptions = { + encode(message: OneofOptions, writer: Writer = Writer.create()): Writer { + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): OneofOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseOneofOptions } as OneofOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): OneofOptions { + const message = { ...baseOneofOptions } as OneofOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: OneofOptions): unknown { + const obj: any = {}; + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): OneofOptions { + const message = { ...baseOneofOptions } as OneofOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseEnumOptions: object = { allowAlias: false, deprecated: false }; + +export const EnumOptions = { + encode(message: EnumOptions, writer: Writer = Writer.create()): Writer { + if (message.allowAlias === true) { + writer.uint32(16).bool(message.allowAlias); + } + if (message.deprecated === true) { + writer.uint32(24).bool(message.deprecated); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): EnumOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseEnumOptions } as EnumOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + message.allowAlias = reader.bool(); + break; + case 3: + message.deprecated = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumOptions { + const message = { ...baseEnumOptions } as EnumOptions; + message.uninterpretedOption = []; + if (object.allowAlias !== undefined && object.allowAlias !== null) { + message.allowAlias = Boolean(object.allowAlias); + } else { + message.allowAlias = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: EnumOptions): unknown { + const obj: any = {}; + message.allowAlias !== undefined && (obj.allowAlias = message.allowAlias); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): EnumOptions { + const message = { ...baseEnumOptions } as EnumOptions; + message.uninterpretedOption = []; + if (object.allowAlias !== undefined && object.allowAlias !== null) { + message.allowAlias = object.allowAlias; + } else { + message.allowAlias = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseEnumValueOptions: object = { deprecated: false }; + +export const EnumValueOptions = { + encode(message: EnumValueOptions, writer: Writer = Writer.create()): Writer { + if (message.deprecated === true) { + writer.uint32(8).bool(message.deprecated); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): EnumValueOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseEnumValueOptions } as EnumValueOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.deprecated = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumValueOptions { + const message = { ...baseEnumValueOptions } as EnumValueOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: EnumValueOptions): unknown { + const obj: any = {}; + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): EnumValueOptions { + const message = { ...baseEnumValueOptions } as EnumValueOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseServiceOptions: object = { deprecated: false }; + +export const ServiceOptions = { + encode(message: ServiceOptions, writer: Writer = Writer.create()): Writer { + if (message.deprecated === true) { + writer.uint32(264).bool(message.deprecated); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ServiceOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseServiceOptions } as ServiceOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 33: + message.deprecated = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ServiceOptions { + const message = { ...baseServiceOptions } as ServiceOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: ServiceOptions): unknown { + const obj: any = {}; + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): ServiceOptions { + const message = { ...baseServiceOptions } as ServiceOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseMethodOptions: object = { deprecated: false, idempotencyLevel: 0 }; + +export const MethodOptions = { + encode(message: MethodOptions, writer: Writer = Writer.create()): Writer { + if (message.deprecated === true) { + writer.uint32(264).bool(message.deprecated); + } + if (message.idempotencyLevel !== 0) { + writer.uint32(272).int32(message.idempotencyLevel); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MethodOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMethodOptions } as MethodOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 33: + message.deprecated = reader.bool(); + break; + case 34: + message.idempotencyLevel = reader.int32() as any; + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MethodOptions { + const message = { ...baseMethodOptions } as MethodOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.idempotencyLevel !== undefined && + object.idempotencyLevel !== null + ) { + message.idempotencyLevel = methodOptions_IdempotencyLevelFromJSON( + object.idempotencyLevel + ); + } else { + message.idempotencyLevel = 0; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: MethodOptions): unknown { + const obj: any = {}; + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.idempotencyLevel !== undefined && + (obj.idempotencyLevel = methodOptions_IdempotencyLevelToJSON( + message.idempotencyLevel + )); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): MethodOptions { + const message = { ...baseMethodOptions } as MethodOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.idempotencyLevel !== undefined && + object.idempotencyLevel !== null + ) { + message.idempotencyLevel = object.idempotencyLevel; + } else { + message.idempotencyLevel = 0; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseUninterpretedOption: object = { + identifierValue: "", + positiveIntValue: 0, + negativeIntValue: 0, + doubleValue: 0, + aggregateValue: "", +}; + +export const UninterpretedOption = { + encode( + message: UninterpretedOption, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.name) { + UninterpretedOption_NamePart.encode( + v!, + writer.uint32(18).fork() + ).ldelim(); + } + if (message.identifierValue !== "") { + writer.uint32(26).string(message.identifierValue); + } + if (message.positiveIntValue !== 0) { + writer.uint32(32).uint64(message.positiveIntValue); + } + if (message.negativeIntValue !== 0) { + writer.uint32(40).int64(message.negativeIntValue); + } + if (message.doubleValue !== 0) { + writer.uint32(49).double(message.doubleValue); + } + if (message.stringValue.length !== 0) { + writer.uint32(58).bytes(message.stringValue); + } + if (message.aggregateValue !== "") { + writer.uint32(66).string(message.aggregateValue); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): UninterpretedOption { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseUninterpretedOption } as UninterpretedOption; + message.name = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + message.name.push( + UninterpretedOption_NamePart.decode(reader, reader.uint32()) + ); + break; + case 3: + message.identifierValue = reader.string(); + break; + case 4: + message.positiveIntValue = longToNumber(reader.uint64() as Long); + break; + case 5: + message.negativeIntValue = longToNumber(reader.int64() as Long); + break; + case 6: + message.doubleValue = reader.double(); + break; + case 7: + message.stringValue = reader.bytes(); + break; + case 8: + message.aggregateValue = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): UninterpretedOption { + const message = { ...baseUninterpretedOption } as UninterpretedOption; + message.name = []; + if (object.name !== undefined && object.name !== null) { + for (const e of object.name) { + message.name.push(UninterpretedOption_NamePart.fromJSON(e)); + } + } + if ( + object.identifierValue !== undefined && + object.identifierValue !== null + ) { + message.identifierValue = String(object.identifierValue); + } else { + message.identifierValue = ""; + } + if ( + object.positiveIntValue !== undefined && + object.positiveIntValue !== null + ) { + message.positiveIntValue = Number(object.positiveIntValue); + } else { + message.positiveIntValue = 0; + } + if ( + object.negativeIntValue !== undefined && + object.negativeIntValue !== null + ) { + message.negativeIntValue = Number(object.negativeIntValue); + } else { + message.negativeIntValue = 0; + } + if (object.doubleValue !== undefined && object.doubleValue !== null) { + message.doubleValue = Number(object.doubleValue); + } else { + message.doubleValue = 0; + } + if (object.stringValue !== undefined && object.stringValue !== null) { + message.stringValue = bytesFromBase64(object.stringValue); + } + if (object.aggregateValue !== undefined && object.aggregateValue !== null) { + message.aggregateValue = String(object.aggregateValue); + } else { + message.aggregateValue = ""; + } + return message; + }, + + toJSON(message: UninterpretedOption): unknown { + const obj: any = {}; + if (message.name) { + obj.name = message.name.map((e) => + e ? UninterpretedOption_NamePart.toJSON(e) : undefined + ); + } else { + obj.name = []; + } + message.identifierValue !== undefined && + (obj.identifierValue = message.identifierValue); + message.positiveIntValue !== undefined && + (obj.positiveIntValue = message.positiveIntValue); + message.negativeIntValue !== undefined && + (obj.negativeIntValue = message.negativeIntValue); + message.doubleValue !== undefined && + (obj.doubleValue = message.doubleValue); + message.stringValue !== undefined && + (obj.stringValue = base64FromBytes( + message.stringValue !== undefined + ? message.stringValue + : new Uint8Array() + )); + message.aggregateValue !== undefined && + (obj.aggregateValue = message.aggregateValue); + return obj; + }, + + fromPartial(object: DeepPartial): UninterpretedOption { + const message = { ...baseUninterpretedOption } as UninterpretedOption; + message.name = []; + if (object.name !== undefined && object.name !== null) { + for (const e of object.name) { + message.name.push(UninterpretedOption_NamePart.fromPartial(e)); + } + } + if ( + object.identifierValue !== undefined && + object.identifierValue !== null + ) { + message.identifierValue = object.identifierValue; + } else { + message.identifierValue = ""; + } + if ( + object.positiveIntValue !== undefined && + object.positiveIntValue !== null + ) { + message.positiveIntValue = object.positiveIntValue; + } else { + message.positiveIntValue = 0; + } + if ( + object.negativeIntValue !== undefined && + object.negativeIntValue !== null + ) { + message.negativeIntValue = object.negativeIntValue; + } else { + message.negativeIntValue = 0; + } + if (object.doubleValue !== undefined && object.doubleValue !== null) { + message.doubleValue = object.doubleValue; + } else { + message.doubleValue = 0; + } + if (object.stringValue !== undefined && object.stringValue !== null) { + message.stringValue = object.stringValue; + } else { + message.stringValue = new Uint8Array(); + } + if (object.aggregateValue !== undefined && object.aggregateValue !== null) { + message.aggregateValue = object.aggregateValue; + } else { + message.aggregateValue = ""; + } + return message; + }, +}; + +const baseUninterpretedOption_NamePart: object = { + namePart: "", + isExtension: false, +}; + +export const UninterpretedOption_NamePart = { + encode( + message: UninterpretedOption_NamePart, + writer: Writer = Writer.create() + ): Writer { + if (message.namePart !== "") { + writer.uint32(10).string(message.namePart); + } + if (message.isExtension === true) { + writer.uint32(16).bool(message.isExtension); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): UninterpretedOption_NamePart { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseUninterpretedOption_NamePart, + } as UninterpretedOption_NamePart; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.namePart = reader.string(); + break; + case 2: + message.isExtension = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): UninterpretedOption_NamePart { + const message = { + ...baseUninterpretedOption_NamePart, + } as UninterpretedOption_NamePart; + if (object.namePart !== undefined && object.namePart !== null) { + message.namePart = String(object.namePart); + } else { + message.namePart = ""; + } + if (object.isExtension !== undefined && object.isExtension !== null) { + message.isExtension = Boolean(object.isExtension); + } else { + message.isExtension = false; + } + return message; + }, + + toJSON(message: UninterpretedOption_NamePart): unknown { + const obj: any = {}; + message.namePart !== undefined && (obj.namePart = message.namePart); + message.isExtension !== undefined && + (obj.isExtension = message.isExtension); + return obj; + }, + + fromPartial( + object: DeepPartial + ): UninterpretedOption_NamePart { + const message = { + ...baseUninterpretedOption_NamePart, + } as UninterpretedOption_NamePart; + if (object.namePart !== undefined && object.namePart !== null) { + message.namePart = object.namePart; + } else { + message.namePart = ""; + } + if (object.isExtension !== undefined && object.isExtension !== null) { + message.isExtension = object.isExtension; + } else { + message.isExtension = false; + } + return message; + }, +}; + +const baseSourceCodeInfo: object = {}; + +export const SourceCodeInfo = { + encode(message: SourceCodeInfo, writer: Writer = Writer.create()): Writer { + for (const v of message.location) { + SourceCodeInfo_Location.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): SourceCodeInfo { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseSourceCodeInfo } as SourceCodeInfo; + message.location = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.location.push( + SourceCodeInfo_Location.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): SourceCodeInfo { + const message = { ...baseSourceCodeInfo } as SourceCodeInfo; + message.location = []; + if (object.location !== undefined && object.location !== null) { + for (const e of object.location) { + message.location.push(SourceCodeInfo_Location.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: SourceCodeInfo): unknown { + const obj: any = {}; + if (message.location) { + obj.location = message.location.map((e) => + e ? SourceCodeInfo_Location.toJSON(e) : undefined + ); + } else { + obj.location = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): SourceCodeInfo { + const message = { ...baseSourceCodeInfo } as SourceCodeInfo; + message.location = []; + if (object.location !== undefined && object.location !== null) { + for (const e of object.location) { + message.location.push(SourceCodeInfo_Location.fromPartial(e)); + } + } + return message; + }, +}; + +const baseSourceCodeInfo_Location: object = { + path: 0, + span: 0, + leadingComments: "", + trailingComments: "", + leadingDetachedComments: "", +}; + +export const SourceCodeInfo_Location = { + encode( + message: SourceCodeInfo_Location, + writer: Writer = Writer.create() + ): Writer { + writer.uint32(10).fork(); + for (const v of message.path) { + writer.int32(v); + } + writer.ldelim(); + writer.uint32(18).fork(); + for (const v of message.span) { + writer.int32(v); + } + writer.ldelim(); + if (message.leadingComments !== "") { + writer.uint32(26).string(message.leadingComments); + } + if (message.trailingComments !== "") { + writer.uint32(34).string(message.trailingComments); + } + for (const v of message.leadingDetachedComments) { + writer.uint32(50).string(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): SourceCodeInfo_Location { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseSourceCodeInfo_Location, + } as SourceCodeInfo_Location; + message.path = []; + message.span = []; + message.leadingDetachedComments = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.path.push(reader.int32()); + } + } else { + message.path.push(reader.int32()); + } + break; + case 2: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.span.push(reader.int32()); + } + } else { + message.span.push(reader.int32()); + } + break; + case 3: + message.leadingComments = reader.string(); + break; + case 4: + message.trailingComments = reader.string(); + break; + case 6: + message.leadingDetachedComments.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): SourceCodeInfo_Location { + const message = { + ...baseSourceCodeInfo_Location, + } as SourceCodeInfo_Location; + message.path = []; + message.span = []; + message.leadingDetachedComments = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(Number(e)); + } + } + if (object.span !== undefined && object.span !== null) { + for (const e of object.span) { + message.span.push(Number(e)); + } + } + if ( + object.leadingComments !== undefined && + object.leadingComments !== null + ) { + message.leadingComments = String(object.leadingComments); + } else { + message.leadingComments = ""; + } + if ( + object.trailingComments !== undefined && + object.trailingComments !== null + ) { + message.trailingComments = String(object.trailingComments); + } else { + message.trailingComments = ""; + } + if ( + object.leadingDetachedComments !== undefined && + object.leadingDetachedComments !== null + ) { + for (const e of object.leadingDetachedComments) { + message.leadingDetachedComments.push(String(e)); + } + } + return message; + }, + + toJSON(message: SourceCodeInfo_Location): unknown { + const obj: any = {}; + if (message.path) { + obj.path = message.path.map((e) => e); + } else { + obj.path = []; + } + if (message.span) { + obj.span = message.span.map((e) => e); + } else { + obj.span = []; + } + message.leadingComments !== undefined && + (obj.leadingComments = message.leadingComments); + message.trailingComments !== undefined && + (obj.trailingComments = message.trailingComments); + if (message.leadingDetachedComments) { + obj.leadingDetachedComments = message.leadingDetachedComments.map( + (e) => e + ); + } else { + obj.leadingDetachedComments = []; + } + return obj; + }, + + fromPartial( + object: DeepPartial + ): SourceCodeInfo_Location { + const message = { + ...baseSourceCodeInfo_Location, + } as SourceCodeInfo_Location; + message.path = []; + message.span = []; + message.leadingDetachedComments = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(e); + } + } + if (object.span !== undefined && object.span !== null) { + for (const e of object.span) { + message.span.push(e); + } + } + if ( + object.leadingComments !== undefined && + object.leadingComments !== null + ) { + message.leadingComments = object.leadingComments; + } else { + message.leadingComments = ""; + } + if ( + object.trailingComments !== undefined && + object.trailingComments !== null + ) { + message.trailingComments = object.trailingComments; + } else { + message.trailingComments = ""; + } + if ( + object.leadingDetachedComments !== undefined && + object.leadingDetachedComments !== null + ) { + for (const e of object.leadingDetachedComments) { + message.leadingDetachedComments.push(e); + } + } + return message; + }, +}; + +const baseGeneratedCodeInfo: object = {}; + +export const GeneratedCodeInfo = { + encode(message: GeneratedCodeInfo, writer: Writer = Writer.create()): Writer { + for (const v of message.annotation) { + GeneratedCodeInfo_Annotation.encode( + v!, + writer.uint32(10).fork() + ).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): GeneratedCodeInfo { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseGeneratedCodeInfo } as GeneratedCodeInfo; + message.annotation = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.annotation.push( + GeneratedCodeInfo_Annotation.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GeneratedCodeInfo { + const message = { ...baseGeneratedCodeInfo } as GeneratedCodeInfo; + message.annotation = []; + if (object.annotation !== undefined && object.annotation !== null) { + for (const e of object.annotation) { + message.annotation.push(GeneratedCodeInfo_Annotation.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: GeneratedCodeInfo): unknown { + const obj: any = {}; + if (message.annotation) { + obj.annotation = message.annotation.map((e) => + e ? GeneratedCodeInfo_Annotation.toJSON(e) : undefined + ); + } else { + obj.annotation = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): GeneratedCodeInfo { + const message = { ...baseGeneratedCodeInfo } as GeneratedCodeInfo; + message.annotation = []; + if (object.annotation !== undefined && object.annotation !== null) { + for (const e of object.annotation) { + message.annotation.push(GeneratedCodeInfo_Annotation.fromPartial(e)); + } + } + return message; + }, +}; + +const baseGeneratedCodeInfo_Annotation: object = { + path: 0, + sourceFile: "", + begin: 0, + end: 0, +}; + +export const GeneratedCodeInfo_Annotation = { + encode( + message: GeneratedCodeInfo_Annotation, + writer: Writer = Writer.create() + ): Writer { + writer.uint32(10).fork(); + for (const v of message.path) { + writer.int32(v); + } + writer.ldelim(); + if (message.sourceFile !== "") { + writer.uint32(18).string(message.sourceFile); + } + if (message.begin !== 0) { + writer.uint32(24).int32(message.begin); + } + if (message.end !== 0) { + writer.uint32(32).int32(message.end); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): GeneratedCodeInfo_Annotation { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseGeneratedCodeInfo_Annotation, + } as GeneratedCodeInfo_Annotation; + message.path = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.path.push(reader.int32()); + } + } else { + message.path.push(reader.int32()); + } + break; + case 2: + message.sourceFile = reader.string(); + break; + case 3: + message.begin = reader.int32(); + break; + case 4: + message.end = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GeneratedCodeInfo_Annotation { + const message = { + ...baseGeneratedCodeInfo_Annotation, + } as GeneratedCodeInfo_Annotation; + message.path = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(Number(e)); + } + } + if (object.sourceFile !== undefined && object.sourceFile !== null) { + message.sourceFile = String(object.sourceFile); + } else { + message.sourceFile = ""; + } + if (object.begin !== undefined && object.begin !== null) { + message.begin = Number(object.begin); + } else { + message.begin = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + return message; + }, + + toJSON(message: GeneratedCodeInfo_Annotation): unknown { + const obj: any = {}; + if (message.path) { + obj.path = message.path.map((e) => e); + } else { + obj.path = []; + } + message.sourceFile !== undefined && (obj.sourceFile = message.sourceFile); + message.begin !== undefined && (obj.begin = message.begin); + message.end !== undefined && (obj.end = message.end); + return obj; + }, + + fromPartial( + object: DeepPartial + ): GeneratedCodeInfo_Annotation { + const message = { + ...baseGeneratedCodeInfo_Annotation, + } as GeneratedCodeInfo_Annotation; + message.path = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(e); + } + } + if (object.sourceFile !== undefined && object.sourceFile !== null) { + message.sourceFile = object.sourceFile; + } else { + message.sourceFile = ""; + } + if (object.begin !== undefined && object.begin !== null) { + message.begin = object.begin; + } else { + message.begin = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/env.ts b/ts-client/env.ts new file mode 100755 index 00000000..92558e4b --- /dev/null +++ b/ts-client/env.ts @@ -0,0 +1,7 @@ +import { OfflineSigner } from "@cosmjs/proto-signing"; + +export interface Env { + apiURL: string + rpcURL: string + prefix?: string +} \ No newline at end of file diff --git a/ts-client/helpers.ts b/ts-client/helpers.ts new file mode 100755 index 00000000..b03727b4 --- /dev/null +++ b/ts-client/helpers.ts @@ -0,0 +1,32 @@ +export type Constructor = new (...args: any[]) => T; + +export type AnyFunction = (...args: any) => any; + +export type UnionToIntersection = + (Union extends any + ? (argument: Union) => void + : never + ) extends (argument: infer Intersection) => void + ? Intersection + : never; + +export type Return = + T extends AnyFunction + ? ReturnType + : T extends AnyFunction[] + ? UnionToIntersection> + : never + + +export const MissingWalletError = new Error("wallet is required"); + +export function getStructure(template) { + let structure = { fields: [] } + for (const [key, value] of Object.entries(template)) { + let field: any = {} + field.name = key + field.type = typeof value + structure.fields.push(field) + } + return structure +} \ No newline at end of file diff --git a/ts-client/ibc.applications.interchain_accounts.host.v1/index.ts b/ts-client/ibc.applications.interchain_accounts.host.v1/index.ts new file mode 100755 index 00000000..c9dfa159 --- /dev/null +++ b/ts-client/ibc.applications.interchain_accounts.host.v1/index.ts @@ -0,0 +1,6 @@ +import Module from './module'; +import { txClient, queryClient, registry } from './module'; +import { msgTypes } from './registry'; + +export * from "./types"; +export { Module, msgTypes, txClient, queryClient, registry }; diff --git a/ts-client/ibc.applications.interchain_accounts.host.v1/module.ts b/ts-client/ibc.applications.interchain_accounts.host.v1/module.ts new file mode 100755 index 00000000..59b0a661 --- /dev/null +++ b/ts-client/ibc.applications.interchain_accounts.host.v1/module.ts @@ -0,0 +1,66 @@ +// Generated by Ignite ignite.com/cli + +import { StdFee } from "@cosmjs/launchpad"; +import { SigningStargateClient, DeliverTxResponse } from "@cosmjs/stargate"; +import { EncodeObject, GeneratedType, OfflineSigner, Registry } from "@cosmjs/proto-signing"; +import { msgTypes } from './registry'; +import { IgniteClient } from "../client" +import { MissingWalletError } from "../helpers" +import { Api } from "./rest"; + + +export { }; + + + +export const registry = new Registry(msgTypes); + +const defaultFee = { + amount: [], + gas: "200000", +}; + +interface TxClientOptions { + addr: string + prefix: string + signer?: OfflineSigner +} + +export const txClient = ({ signer, prefix, addr }: TxClientOptions = { addr: "http://localhost:26657", prefix: "cosmos" }) => { + + return { + + + } +}; + +interface QueryClientOptions { + addr: string +} + +export const queryClient = ({ addr: addr }: QueryClientOptions = { addr: "http://localhost:1317" }) => { + return new Api({ baseUrl: addr }); +}; + +class SDKModule { + public query: ReturnType; + public tx: ReturnType; + + public registry: Array<[string, GeneratedType]>; + + constructor(client: IgniteClient) { + + this.query = queryClient({ addr: client.env.apiURL }); + this.tx = txClient({ signer: client.signer, addr: client.env.rpcURL, prefix: client.env.prefix ?? "cosmos" }); + } +}; + +const Module = (test: IgniteClient) => { + return { + module: { + IbcApplicationsInterchainAccountsHostV1: new SDKModule(test) + }, + registry: msgTypes + } +} +export default Module; \ No newline at end of file diff --git a/ts-client/ibc.applications.interchain_accounts.host.v1/registry.ts b/ts-client/ibc.applications.interchain_accounts.host.v1/registry.ts new file mode 100755 index 00000000..26157e4f --- /dev/null +++ b/ts-client/ibc.applications.interchain_accounts.host.v1/registry.ts @@ -0,0 +1,7 @@ +import { GeneratedType } from "@cosmjs/proto-signing"; + +const msgTypes: Array<[string, GeneratedType]> = [ + +]; + +export { msgTypes } \ No newline at end of file diff --git a/ts-client/ibc.applications.interchain_accounts.host.v1/rest.ts b/ts-client/ibc.applications.interchain_accounts.host.v1/rest.ts new file mode 100644 index 00000000..b18efc84 --- /dev/null +++ b/ts-client/ibc.applications.interchain_accounts.host.v1/rest.ts @@ -0,0 +1,254 @@ +/* eslint-disable */ +/* tslint:disable */ +/* + * --------------------------------------------------------------- + * ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ## + * ## ## + * ## AUTHOR: acacode ## + * ## SOURCE: https://github.com/acacode/swagger-typescript-api ## + * --------------------------------------------------------------- + */ + +/** +* Params defines the set of on-chain interchain accounts parameters. +The following parameters may be used to disable the host submodule. +*/ +export interface Hostv1Params { + /** host_enabled enables or disables the host submodule. */ + host_enabled?: boolean; + + /** allow_messages defines a list of sdk message typeURLs allowed to be executed on a host chain. */ + allow_messages?: string[]; +} + +export interface ProtobufAny { + "@type"?: string; +} + +export interface RpcStatus { + /** @format int32 */ + code?: number; + message?: string; + details?: ProtobufAny[]; +} + +/** + * QueryParamsResponse is the response type for the Query/Params RPC method. + */ +export interface V1QueryParamsResponse { + /** params defines the parameters of the module. */ + params?: Hostv1Params; +} + +export type QueryParamsType = Record; +export type ResponseFormat = keyof Omit; + +export interface FullRequestParams extends Omit { + /** set parameter to `true` for call `securityWorker` for this request */ + secure?: boolean; + /** request path */ + path: string; + /** content type of request body */ + type?: ContentType; + /** query params */ + query?: QueryParamsType; + /** format of response (i.e. response.json() -> format: "json") */ + format?: keyof Omit; + /** request body */ + body?: unknown; + /** base url */ + baseUrl?: string; + /** request cancellation token */ + cancelToken?: CancelToken; +} + +export type RequestParams = Omit; + +export interface ApiConfig { + baseUrl?: string; + baseApiParams?: Omit; + securityWorker?: (securityData: SecurityDataType) => RequestParams | void; +} + +export interface HttpResponse extends Response { + data: D; + error: E; +} + +type CancelToken = Symbol | string | number; + +export enum ContentType { + Json = "application/json", + FormData = "multipart/form-data", + UrlEncoded = "application/x-www-form-urlencoded", +} + +export class HttpClient { + public baseUrl: string = ""; + private securityData: SecurityDataType = null as any; + private securityWorker: null | ApiConfig["securityWorker"] = null; + private abortControllers = new Map(); + + private baseApiParams: RequestParams = { + credentials: "same-origin", + headers: {}, + redirect: "follow", + referrerPolicy: "no-referrer", + }; + + constructor(apiConfig: ApiConfig = {}) { + Object.assign(this, apiConfig); + } + + public setSecurityData = (data: SecurityDataType) => { + this.securityData = data; + }; + + private addQueryParam(query: QueryParamsType, key: string) { + const value = query[key]; + + return ( + encodeURIComponent(key) + + "=" + + encodeURIComponent(Array.isArray(value) ? value.join(",") : typeof value === "number" ? value : `${value}`) + ); + } + + protected toQueryString(rawQuery?: QueryParamsType): string { + const query = rawQuery || {}; + const keys = Object.keys(query).filter((key) => "undefined" !== typeof query[key]); + return keys + .map((key) => + typeof query[key] === "object" && !Array.isArray(query[key]) + ? this.toQueryString(query[key] as QueryParamsType) + : this.addQueryParam(query, key), + ) + .join("&"); + } + + protected addQueryParams(rawQuery?: QueryParamsType): string { + const queryString = this.toQueryString(rawQuery); + return queryString ? `?${queryString}` : ""; + } + + private contentFormatters: Record any> = { + [ContentType.Json]: (input: any) => + input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input, + [ContentType.FormData]: (input: any) => + Object.keys(input || {}).reduce((data, key) => { + data.append(key, input[key]); + return data; + }, new FormData()), + [ContentType.UrlEncoded]: (input: any) => this.toQueryString(input), + }; + + private mergeRequestParams(params1: RequestParams, params2?: RequestParams): RequestParams { + return { + ...this.baseApiParams, + ...params1, + ...(params2 || {}), + headers: { + ...(this.baseApiParams.headers || {}), + ...(params1.headers || {}), + ...((params2 && params2.headers) || {}), + }, + }; + } + + private createAbortSignal = (cancelToken: CancelToken): AbortSignal | undefined => { + if (this.abortControllers.has(cancelToken)) { + const abortController = this.abortControllers.get(cancelToken); + if (abortController) { + return abortController.signal; + } + return void 0; + } + + const abortController = new AbortController(); + this.abortControllers.set(cancelToken, abortController); + return abortController.signal; + }; + + public abortRequest = (cancelToken: CancelToken) => { + const abortController = this.abortControllers.get(cancelToken); + + if (abortController) { + abortController.abort(); + this.abortControllers.delete(cancelToken); + } + }; + + public request = ({ + body, + secure, + path, + type, + query, + format = "json", + baseUrl, + cancelToken, + ...params + }: FullRequestParams): Promise> => { + const secureParams = (secure && this.securityWorker && this.securityWorker(this.securityData)) || {}; + const requestParams = this.mergeRequestParams(params, secureParams); + const queryString = query && this.toQueryString(query); + const payloadFormatter = this.contentFormatters[type || ContentType.Json]; + + return fetch(`${baseUrl || this.baseUrl || ""}${path}${queryString ? `?${queryString}` : ""}`, { + ...requestParams, + headers: { + ...(type && type !== ContentType.FormData ? { "Content-Type": type } : {}), + ...(requestParams.headers || {}), + }, + signal: cancelToken ? this.createAbortSignal(cancelToken) : void 0, + body: typeof body === "undefined" || body === null ? null : payloadFormatter(body), + }).then(async (response) => { + const r = response as HttpResponse; + r.data = (null as unknown) as T; + r.error = (null as unknown) as E; + + const data = await response[format]() + .then((data) => { + if (r.ok) { + r.data = data; + } else { + r.error = data; + } + return r; + }) + .catch((e) => { + r.error = e; + return r; + }); + + if (cancelToken) { + this.abortControllers.delete(cancelToken); + } + + if (!response.ok) throw data; + return data; + }); + }; +} + +/** + * @title ibc/applications/interchain_accounts/host/v1/host.proto + * @version version not set + */ +export class Api extends HttpClient { + /** + * No description + * + * @tags Query + * @name QueryParams + * @summary Params queries all parameters of the ICA host submodule. + * @request GET:/ibc/apps/interchain_accounts/host/v1/params + */ + queryParams = (params: RequestParams = {}) => + this.request({ + path: `/ibc/apps/interchain_accounts/host/v1/params`, + method: "GET", + format: "json", + ...params, + }); +} diff --git a/ts-client/ibc.applications.interchain_accounts.host.v1/types.ts b/ts-client/ibc.applications.interchain_accounts.host.v1/types.ts new file mode 100755 index 00000000..35efdf82 --- /dev/null +++ b/ts-client/ibc.applications.interchain_accounts.host.v1/types.ts @@ -0,0 +1,7 @@ +import { Params } from "./types/ibc/applications/interchain_accounts/host/v1/host" + + +export { + Params, + + } \ No newline at end of file diff --git a/ts-client/ibc.applications.interchain_accounts.host.v1/types/gogoproto/gogo.ts b/ts-client/ibc.applications.interchain_accounts.host.v1/types/gogoproto/gogo.ts new file mode 100644 index 00000000..3f41a047 --- /dev/null +++ b/ts-client/ibc.applications.interchain_accounts.host.v1/types/gogoproto/gogo.ts @@ -0,0 +1,2 @@ +/* eslint-disable */ +export const protobufPackage = "gogoproto"; diff --git a/ts-client/ibc.applications.interchain_accounts.host.v1/types/google/api/annotations.ts b/ts-client/ibc.applications.interchain_accounts.host.v1/types/google/api/annotations.ts new file mode 100644 index 00000000..aace4787 --- /dev/null +++ b/ts-client/ibc.applications.interchain_accounts.host.v1/types/google/api/annotations.ts @@ -0,0 +1,2 @@ +/* eslint-disable */ +export const protobufPackage = "google.api"; diff --git a/ts-client/ibc.applications.interchain_accounts.host.v1/types/google/api/http.ts b/ts-client/ibc.applications.interchain_accounts.host.v1/types/google/api/http.ts new file mode 100644 index 00000000..ddc00f8b --- /dev/null +++ b/ts-client/ibc.applications.interchain_accounts.host.v1/types/google/api/http.ts @@ -0,0 +1,705 @@ +/* eslint-disable */ +import { Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "google.api"; + +/** + * Defines the HTTP configuration for an API service. It contains a list of + * [HttpRule][google.api.HttpRule], each specifying the mapping of an RPC method + * to one or more HTTP REST API methods. + */ +export interface Http { + /** + * A list of HTTP configuration rules that apply to individual API methods. + * + * **NOTE:** All service configuration rules follow "last one wins" order. + */ + rules: HttpRule[]; + /** + * When set to true, URL path parmeters will be fully URI-decoded except in + * cases of single segment matches in reserved expansion, where "%2F" will be + * left encoded. + * + * The default behavior is to not decode RFC 6570 reserved characters in multi + * segment matches. + */ + fullyDecodeReservedExpansion: boolean; +} + +/** + * `HttpRule` defines the mapping of an RPC method to one or more HTTP + * REST API methods. The mapping specifies how different portions of the RPC + * request message are mapped to URL path, URL query parameters, and + * HTTP request body. The mapping is typically specified as an + * `google.api.http` annotation on the RPC method, + * see "google/api/annotations.proto" for details. + * + * The mapping consists of a field specifying the path template and + * method kind. The path template can refer to fields in the request + * message, as in the example below which describes a REST GET + * operation on a resource collection of messages: + * + * + * service Messaging { + * rpc GetMessage(GetMessageRequest) returns (Message) { + * option (google.api.http).get = "/v1/messages/{message_id}/{sub.subfield}"; + * } + * } + * message GetMessageRequest { + * message SubMessage { + * string subfield = 1; + * } + * string message_id = 1; // mapped to the URL + * SubMessage sub = 2; // `sub.subfield` is url-mapped + * } + * message Message { + * string text = 1; // content of the resource + * } + * + * The same http annotation can alternatively be expressed inside the + * `GRPC API Configuration` YAML file. + * + * http: + * rules: + * - selector: .Messaging.GetMessage + * get: /v1/messages/{message_id}/{sub.subfield} + * + * This definition enables an automatic, bidrectional mapping of HTTP + * JSON to RPC. Example: + * + * HTTP | RPC + * -----|----- + * `GET /v1/messages/123456/foo` | `GetMessage(message_id: "123456" sub: SubMessage(subfield: "foo"))` + * + * In general, not only fields but also field paths can be referenced + * from a path pattern. Fields mapped to the path pattern cannot be + * repeated and must have a primitive (non-message) type. + * + * Any fields in the request message which are not bound by the path + * pattern automatically become (optional) HTTP query + * parameters. Assume the following definition of the request message: + * + * + * service Messaging { + * rpc GetMessage(GetMessageRequest) returns (Message) { + * option (google.api.http).get = "/v1/messages/{message_id}"; + * } + * } + * message GetMessageRequest { + * message SubMessage { + * string subfield = 1; + * } + * string message_id = 1; // mapped to the URL + * int64 revision = 2; // becomes a parameter + * SubMessage sub = 3; // `sub.subfield` becomes a parameter + * } + * + * + * This enables a HTTP JSON to RPC mapping as below: + * + * HTTP | RPC + * -----|----- + * `GET /v1/messages/123456?revision=2&sub.subfield=foo` | `GetMessage(message_id: "123456" revision: 2 sub: SubMessage(subfield: "foo"))` + * + * Note that fields which are mapped to HTTP parameters must have a + * primitive type or a repeated primitive type. Message types are not + * allowed. In the case of a repeated type, the parameter can be + * repeated in the URL, as in `...?param=A¶m=B`. + * + * For HTTP method kinds which allow a request body, the `body` field + * specifies the mapping. Consider a REST update method on the + * message resource collection: + * + * + * service Messaging { + * rpc UpdateMessage(UpdateMessageRequest) returns (Message) { + * option (google.api.http) = { + * put: "/v1/messages/{message_id}" + * body: "message" + * }; + * } + * } + * message UpdateMessageRequest { + * string message_id = 1; // mapped to the URL + * Message message = 2; // mapped to the body + * } + * + * + * The following HTTP JSON to RPC mapping is enabled, where the + * representation of the JSON in the request body is determined by + * protos JSON encoding: + * + * HTTP | RPC + * -----|----- + * `PUT /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: "123456" message { text: "Hi!" })` + * + * The special name `*` can be used in the body mapping to define that + * every field not bound by the path template should be mapped to the + * request body. This enables the following alternative definition of + * the update method: + * + * service Messaging { + * rpc UpdateMessage(Message) returns (Message) { + * option (google.api.http) = { + * put: "/v1/messages/{message_id}" + * body: "*" + * }; + * } + * } + * message Message { + * string message_id = 1; + * string text = 2; + * } + * + * + * The following HTTP JSON to RPC mapping is enabled: + * + * HTTP | RPC + * -----|----- + * `PUT /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: "123456" text: "Hi!")` + * + * Note that when using `*` in the body mapping, it is not possible to + * have HTTP parameters, as all fields not bound by the path end in + * the body. This makes this option more rarely used in practice of + * defining REST APIs. The common usage of `*` is in custom methods + * which don't use the URL at all for transferring data. + * + * It is possible to define multiple HTTP methods for one RPC by using + * the `additional_bindings` option. Example: + * + * service Messaging { + * rpc GetMessage(GetMessageRequest) returns (Message) { + * option (google.api.http) = { + * get: "/v1/messages/{message_id}" + * additional_bindings { + * get: "/v1/users/{user_id}/messages/{message_id}" + * } + * }; + * } + * } + * message GetMessageRequest { + * string message_id = 1; + * string user_id = 2; + * } + * + * + * This enables the following two alternative HTTP JSON to RPC + * mappings: + * + * HTTP | RPC + * -----|----- + * `GET /v1/messages/123456` | `GetMessage(message_id: "123456")` + * `GET /v1/users/me/messages/123456` | `GetMessage(user_id: "me" message_id: "123456")` + * + * # Rules for HTTP mapping + * + * The rules for mapping HTTP path, query parameters, and body fields + * to the request message are as follows: + * + * 1. The `body` field specifies either `*` or a field path, or is + * omitted. If omitted, it indicates there is no HTTP request body. + * 2. Leaf fields (recursive expansion of nested messages in the + * request) can be classified into three types: + * (a) Matched in the URL template. + * (b) Covered by body (if body is `*`, everything except (a) fields; + * else everything under the body field) + * (c) All other fields. + * 3. URL query parameters found in the HTTP request are mapped to (c) fields. + * 4. Any body sent with an HTTP request can contain only (b) fields. + * + * The syntax of the path template is as follows: + * + * Template = "/" Segments [ Verb ] ; + * Segments = Segment { "/" Segment } ; + * Segment = "*" | "**" | LITERAL | Variable ; + * Variable = "{" FieldPath [ "=" Segments ] "}" ; + * FieldPath = IDENT { "." IDENT } ; + * Verb = ":" LITERAL ; + * + * The syntax `*` matches a single path segment. The syntax `**` matches zero + * or more path segments, which must be the last part of the path except the + * `Verb`. The syntax `LITERAL` matches literal text in the path. + * + * The syntax `Variable` matches part of the URL path as specified by its + * template. A variable template must not contain other variables. If a variable + * matches a single path segment, its template may be omitted, e.g. `{var}` + * is equivalent to `{var=*}`. + * + * If a variable contains exactly one path segment, such as `"{var}"` or + * `"{var=*}"`, when such a variable is expanded into a URL path, all characters + * except `[-_.~0-9a-zA-Z]` are percent-encoded. Such variables show up in the + * Discovery Document as `{var}`. + * + * If a variable contains one or more path segments, such as `"{var=foo/*}"` + * or `"{var=**}"`, when such a variable is expanded into a URL path, all + * characters except `[-_.~/0-9a-zA-Z]` are percent-encoded. Such variables + * show up in the Discovery Document as `{+var}`. + * + * NOTE: While the single segment variable matches the semantics of + * [RFC 6570](https://tools.ietf.org/html/rfc6570) Section 3.2.2 + * Simple String Expansion, the multi segment variable **does not** match + * RFC 6570 Reserved Expansion. The reason is that the Reserved Expansion + * does not expand special characters like `?` and `#`, which would lead + * to invalid URLs. + * + * NOTE: the field paths in variables and in the `body` must not refer to + * repeated fields or map fields. + */ +export interface HttpRule { + /** + * Selects methods to which this rule applies. + * + * Refer to [selector][google.api.DocumentationRule.selector] for syntax details. + */ + selector: string; + /** Used for listing and getting information about resources. */ + get: string | undefined; + /** Used for updating a resource. */ + put: string | undefined; + /** Used for creating a resource. */ + post: string | undefined; + /** Used for deleting a resource. */ + delete: string | undefined; + /** Used for updating a resource. */ + patch: string | undefined; + /** + * The custom pattern is used for specifying an HTTP method that is not + * included in the `pattern` field, such as HEAD, or "*" to leave the + * HTTP method unspecified for this rule. The wild-card rule is useful + * for services that provide content to Web (HTML) clients. + */ + custom: CustomHttpPattern | undefined; + /** + * The name of the request field whose value is mapped to the HTTP body, or + * `*` for mapping all fields not captured by the path pattern to the HTTP + * body. NOTE: the referred field must not be a repeated field and must be + * present at the top-level of request message type. + */ + body: string; + /** + * Optional. The name of the response field whose value is mapped to the HTTP + * body of response. Other response fields are ignored. When + * not set, the response message will be used as HTTP body of response. + */ + responseBody: string; + /** + * Additional HTTP bindings for the selector. Nested bindings must + * not contain an `additional_bindings` field themselves (that is, + * the nesting may only be one level deep). + */ + additionalBindings: HttpRule[]; +} + +/** A custom pattern is used for defining custom HTTP verb. */ +export interface CustomHttpPattern { + /** The name of this custom HTTP verb. */ + kind: string; + /** The path matched by this custom verb. */ + path: string; +} + +const baseHttp: object = { fullyDecodeReservedExpansion: false }; + +export const Http = { + encode(message: Http, writer: Writer = Writer.create()): Writer { + for (const v of message.rules) { + HttpRule.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.fullyDecodeReservedExpansion === true) { + writer.uint32(16).bool(message.fullyDecodeReservedExpansion); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Http { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseHttp } as Http; + message.rules = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.rules.push(HttpRule.decode(reader, reader.uint32())); + break; + case 2: + message.fullyDecodeReservedExpansion = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Http { + const message = { ...baseHttp } as Http; + message.rules = []; + if (object.rules !== undefined && object.rules !== null) { + for (const e of object.rules) { + message.rules.push(HttpRule.fromJSON(e)); + } + } + if ( + object.fullyDecodeReservedExpansion !== undefined && + object.fullyDecodeReservedExpansion !== null + ) { + message.fullyDecodeReservedExpansion = Boolean( + object.fullyDecodeReservedExpansion + ); + } else { + message.fullyDecodeReservedExpansion = false; + } + return message; + }, + + toJSON(message: Http): unknown { + const obj: any = {}; + if (message.rules) { + obj.rules = message.rules.map((e) => + e ? HttpRule.toJSON(e) : undefined + ); + } else { + obj.rules = []; + } + message.fullyDecodeReservedExpansion !== undefined && + (obj.fullyDecodeReservedExpansion = message.fullyDecodeReservedExpansion); + return obj; + }, + + fromPartial(object: DeepPartial): Http { + const message = { ...baseHttp } as Http; + message.rules = []; + if (object.rules !== undefined && object.rules !== null) { + for (const e of object.rules) { + message.rules.push(HttpRule.fromPartial(e)); + } + } + if ( + object.fullyDecodeReservedExpansion !== undefined && + object.fullyDecodeReservedExpansion !== null + ) { + message.fullyDecodeReservedExpansion = + object.fullyDecodeReservedExpansion; + } else { + message.fullyDecodeReservedExpansion = false; + } + return message; + }, +}; + +const baseHttpRule: object = { selector: "", body: "", responseBody: "" }; + +export const HttpRule = { + encode(message: HttpRule, writer: Writer = Writer.create()): Writer { + if (message.selector !== "") { + writer.uint32(10).string(message.selector); + } + if (message.get !== undefined) { + writer.uint32(18).string(message.get); + } + if (message.put !== undefined) { + writer.uint32(26).string(message.put); + } + if (message.post !== undefined) { + writer.uint32(34).string(message.post); + } + if (message.delete !== undefined) { + writer.uint32(42).string(message.delete); + } + if (message.patch !== undefined) { + writer.uint32(50).string(message.patch); + } + if (message.custom !== undefined) { + CustomHttpPattern.encode( + message.custom, + writer.uint32(66).fork() + ).ldelim(); + } + if (message.body !== "") { + writer.uint32(58).string(message.body); + } + if (message.responseBody !== "") { + writer.uint32(98).string(message.responseBody); + } + for (const v of message.additionalBindings) { + HttpRule.encode(v!, writer.uint32(90).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): HttpRule { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseHttpRule } as HttpRule; + message.additionalBindings = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.selector = reader.string(); + break; + case 2: + message.get = reader.string(); + break; + case 3: + message.put = reader.string(); + break; + case 4: + message.post = reader.string(); + break; + case 5: + message.delete = reader.string(); + break; + case 6: + message.patch = reader.string(); + break; + case 8: + message.custom = CustomHttpPattern.decode(reader, reader.uint32()); + break; + case 7: + message.body = reader.string(); + break; + case 12: + message.responseBody = reader.string(); + break; + case 11: + message.additionalBindings.push( + HttpRule.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): HttpRule { + const message = { ...baseHttpRule } as HttpRule; + message.additionalBindings = []; + if (object.selector !== undefined && object.selector !== null) { + message.selector = String(object.selector); + } else { + message.selector = ""; + } + if (object.get !== undefined && object.get !== null) { + message.get = String(object.get); + } else { + message.get = undefined; + } + if (object.put !== undefined && object.put !== null) { + message.put = String(object.put); + } else { + message.put = undefined; + } + if (object.post !== undefined && object.post !== null) { + message.post = String(object.post); + } else { + message.post = undefined; + } + if (object.delete !== undefined && object.delete !== null) { + message.delete = String(object.delete); + } else { + message.delete = undefined; + } + if (object.patch !== undefined && object.patch !== null) { + message.patch = String(object.patch); + } else { + message.patch = undefined; + } + if (object.custom !== undefined && object.custom !== null) { + message.custom = CustomHttpPattern.fromJSON(object.custom); + } else { + message.custom = undefined; + } + if (object.body !== undefined && object.body !== null) { + message.body = String(object.body); + } else { + message.body = ""; + } + if (object.responseBody !== undefined && object.responseBody !== null) { + message.responseBody = String(object.responseBody); + } else { + message.responseBody = ""; + } + if ( + object.additionalBindings !== undefined && + object.additionalBindings !== null + ) { + for (const e of object.additionalBindings) { + message.additionalBindings.push(HttpRule.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: HttpRule): unknown { + const obj: any = {}; + message.selector !== undefined && (obj.selector = message.selector); + message.get !== undefined && (obj.get = message.get); + message.put !== undefined && (obj.put = message.put); + message.post !== undefined && (obj.post = message.post); + message.delete !== undefined && (obj.delete = message.delete); + message.patch !== undefined && (obj.patch = message.patch); + message.custom !== undefined && + (obj.custom = message.custom + ? CustomHttpPattern.toJSON(message.custom) + : undefined); + message.body !== undefined && (obj.body = message.body); + message.responseBody !== undefined && + (obj.responseBody = message.responseBody); + if (message.additionalBindings) { + obj.additionalBindings = message.additionalBindings.map((e) => + e ? HttpRule.toJSON(e) : undefined + ); + } else { + obj.additionalBindings = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): HttpRule { + const message = { ...baseHttpRule } as HttpRule; + message.additionalBindings = []; + if (object.selector !== undefined && object.selector !== null) { + message.selector = object.selector; + } else { + message.selector = ""; + } + if (object.get !== undefined && object.get !== null) { + message.get = object.get; + } else { + message.get = undefined; + } + if (object.put !== undefined && object.put !== null) { + message.put = object.put; + } else { + message.put = undefined; + } + if (object.post !== undefined && object.post !== null) { + message.post = object.post; + } else { + message.post = undefined; + } + if (object.delete !== undefined && object.delete !== null) { + message.delete = object.delete; + } else { + message.delete = undefined; + } + if (object.patch !== undefined && object.patch !== null) { + message.patch = object.patch; + } else { + message.patch = undefined; + } + if (object.custom !== undefined && object.custom !== null) { + message.custom = CustomHttpPattern.fromPartial(object.custom); + } else { + message.custom = undefined; + } + if (object.body !== undefined && object.body !== null) { + message.body = object.body; + } else { + message.body = ""; + } + if (object.responseBody !== undefined && object.responseBody !== null) { + message.responseBody = object.responseBody; + } else { + message.responseBody = ""; + } + if ( + object.additionalBindings !== undefined && + object.additionalBindings !== null + ) { + for (const e of object.additionalBindings) { + message.additionalBindings.push(HttpRule.fromPartial(e)); + } + } + return message; + }, +}; + +const baseCustomHttpPattern: object = { kind: "", path: "" }; + +export const CustomHttpPattern = { + encode(message: CustomHttpPattern, writer: Writer = Writer.create()): Writer { + if (message.kind !== "") { + writer.uint32(10).string(message.kind); + } + if (message.path !== "") { + writer.uint32(18).string(message.path); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): CustomHttpPattern { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseCustomHttpPattern } as CustomHttpPattern; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.kind = reader.string(); + break; + case 2: + message.path = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): CustomHttpPattern { + const message = { ...baseCustomHttpPattern } as CustomHttpPattern; + if (object.kind !== undefined && object.kind !== null) { + message.kind = String(object.kind); + } else { + message.kind = ""; + } + if (object.path !== undefined && object.path !== null) { + message.path = String(object.path); + } else { + message.path = ""; + } + return message; + }, + + toJSON(message: CustomHttpPattern): unknown { + const obj: any = {}; + message.kind !== undefined && (obj.kind = message.kind); + message.path !== undefined && (obj.path = message.path); + return obj; + }, + + fromPartial(object: DeepPartial): CustomHttpPattern { + const message = { ...baseCustomHttpPattern } as CustomHttpPattern; + if (object.kind !== undefined && object.kind !== null) { + message.kind = object.kind; + } else { + message.kind = ""; + } + if (object.path !== undefined && object.path !== null) { + message.path = object.path; + } else { + message.path = ""; + } + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/ibc.applications.interchain_accounts.host.v1/types/google/protobuf/descriptor.ts b/ts-client/ibc.applications.interchain_accounts.host.v1/types/google/protobuf/descriptor.ts new file mode 100644 index 00000000..9e508660 --- /dev/null +++ b/ts-client/ibc.applications.interchain_accounts.host.v1/types/google/protobuf/descriptor.ts @@ -0,0 +1,5261 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "google.protobuf"; + +/** + * The protocol compiler can output a FileDescriptorSet containing the .proto + * files it parses. + */ +export interface FileDescriptorSet { + file: FileDescriptorProto[]; +} + +/** Describes a complete .proto file. */ +export interface FileDescriptorProto { + /** file name, relative to root of source tree */ + name: string; + /** e.g. "foo", "foo.bar", etc. */ + package: string; + /** Names of files imported by this file. */ + dependency: string[]; + /** Indexes of the public imported files in the dependency list above. */ + publicDependency: number[]; + /** + * Indexes of the weak imported files in the dependency list. + * For Google-internal migration only. Do not use. + */ + weakDependency: number[]; + /** All top-level definitions in this file. */ + messageType: DescriptorProto[]; + enumType: EnumDescriptorProto[]; + service: ServiceDescriptorProto[]; + extension: FieldDescriptorProto[]; + options: FileOptions | undefined; + /** + * This field contains optional information about the original source code. + * You may safely remove this entire field without harming runtime + * functionality of the descriptors -- the information is needed only by + * development tools. + */ + sourceCodeInfo: SourceCodeInfo | undefined; + /** + * The syntax of the proto file. + * The supported values are "proto2" and "proto3". + */ + syntax: string; +} + +/** Describes a message type. */ +export interface DescriptorProto { + name: string; + field: FieldDescriptorProto[]; + extension: FieldDescriptorProto[]; + nestedType: DescriptorProto[]; + enumType: EnumDescriptorProto[]; + extensionRange: DescriptorProto_ExtensionRange[]; + oneofDecl: OneofDescriptorProto[]; + options: MessageOptions | undefined; + reservedRange: DescriptorProto_ReservedRange[]; + /** + * Reserved field names, which may not be used by fields in the same message. + * A given name may only be reserved once. + */ + reservedName: string[]; +} + +export interface DescriptorProto_ExtensionRange { + /** Inclusive. */ + start: number; + /** Exclusive. */ + end: number; + options: ExtensionRangeOptions | undefined; +} + +/** + * Range of reserved tag numbers. Reserved tag numbers may not be used by + * fields or extension ranges in the same message. Reserved ranges may + * not overlap. + */ +export interface DescriptorProto_ReservedRange { + /** Inclusive. */ + start: number; + /** Exclusive. */ + end: number; +} + +export interface ExtensionRangeOptions { + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +/** Describes a field within a message. */ +export interface FieldDescriptorProto { + name: string; + number: number; + label: FieldDescriptorProto_Label; + /** + * If type_name is set, this need not be set. If both this and type_name + * are set, this must be one of TYPE_ENUM, TYPE_MESSAGE or TYPE_GROUP. + */ + type: FieldDescriptorProto_Type; + /** + * For message and enum types, this is the name of the type. If the name + * starts with a '.', it is fully-qualified. Otherwise, C++-like scoping + * rules are used to find the type (i.e. first the nested types within this + * message are searched, then within the parent, on up to the root + * namespace). + */ + typeName: string; + /** + * For extensions, this is the name of the type being extended. It is + * resolved in the same manner as type_name. + */ + extendee: string; + /** + * For numeric types, contains the original text representation of the value. + * For booleans, "true" or "false". + * For strings, contains the default text contents (not escaped in any way). + * For bytes, contains the C escaped value. All bytes >= 128 are escaped. + * TODO(kenton): Base-64 encode? + */ + defaultValue: string; + /** + * If set, gives the index of a oneof in the containing type's oneof_decl + * list. This field is a member of that oneof. + */ + oneofIndex: number; + /** + * JSON name of this field. The value is set by protocol compiler. If the + * user has set a "json_name" option on this field, that option's value + * will be used. Otherwise, it's deduced from the field's name by converting + * it to camelCase. + */ + jsonName: string; + options: FieldOptions | undefined; + /** + * If true, this is a proto3 "optional". When a proto3 field is optional, it + * tracks presence regardless of field type. + * + * When proto3_optional is true, this field must be belong to a oneof to + * signal to old proto3 clients that presence is tracked for this field. This + * oneof is known as a "synthetic" oneof, and this field must be its sole + * member (each proto3 optional field gets its own synthetic oneof). Synthetic + * oneofs exist in the descriptor only, and do not generate any API. Synthetic + * oneofs must be ordered after all "real" oneofs. + * + * For message fields, proto3_optional doesn't create any semantic change, + * since non-repeated message fields always track presence. However it still + * indicates the semantic detail of whether the user wrote "optional" or not. + * This can be useful for round-tripping the .proto file. For consistency we + * give message fields a synthetic oneof also, even though it is not required + * to track presence. This is especially important because the parser can't + * tell if a field is a message or an enum, so it must always create a + * synthetic oneof. + * + * Proto2 optional fields do not set this flag, because they already indicate + * optional with `LABEL_OPTIONAL`. + */ + proto3Optional: boolean; +} + +export enum FieldDescriptorProto_Type { + /** + * TYPE_DOUBLE - 0 is reserved for errors. + * Order is weird for historical reasons. + */ + TYPE_DOUBLE = 1, + TYPE_FLOAT = 2, + /** + * TYPE_INT64 - Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT64 if + * negative values are likely. + */ + TYPE_INT64 = 3, + TYPE_UINT64 = 4, + /** + * TYPE_INT32 - Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT32 if + * negative values are likely. + */ + TYPE_INT32 = 5, + TYPE_FIXED64 = 6, + TYPE_FIXED32 = 7, + TYPE_BOOL = 8, + TYPE_STRING = 9, + /** + * TYPE_GROUP - Tag-delimited aggregate. + * Group type is deprecated and not supported in proto3. However, Proto3 + * implementations should still be able to parse the group wire format and + * treat group fields as unknown fields. + */ + TYPE_GROUP = 10, + /** TYPE_MESSAGE - Length-delimited aggregate. */ + TYPE_MESSAGE = 11, + /** TYPE_BYTES - New in version 2. */ + TYPE_BYTES = 12, + TYPE_UINT32 = 13, + TYPE_ENUM = 14, + TYPE_SFIXED32 = 15, + TYPE_SFIXED64 = 16, + /** TYPE_SINT32 - Uses ZigZag encoding. */ + TYPE_SINT32 = 17, + /** TYPE_SINT64 - Uses ZigZag encoding. */ + TYPE_SINT64 = 18, + UNRECOGNIZED = -1, +} + +export function fieldDescriptorProto_TypeFromJSON( + object: any +): FieldDescriptorProto_Type { + switch (object) { + case 1: + case "TYPE_DOUBLE": + return FieldDescriptorProto_Type.TYPE_DOUBLE; + case 2: + case "TYPE_FLOAT": + return FieldDescriptorProto_Type.TYPE_FLOAT; + case 3: + case "TYPE_INT64": + return FieldDescriptorProto_Type.TYPE_INT64; + case 4: + case "TYPE_UINT64": + return FieldDescriptorProto_Type.TYPE_UINT64; + case 5: + case "TYPE_INT32": + return FieldDescriptorProto_Type.TYPE_INT32; + case 6: + case "TYPE_FIXED64": + return FieldDescriptorProto_Type.TYPE_FIXED64; + case 7: + case "TYPE_FIXED32": + return FieldDescriptorProto_Type.TYPE_FIXED32; + case 8: + case "TYPE_BOOL": + return FieldDescriptorProto_Type.TYPE_BOOL; + case 9: + case "TYPE_STRING": + return FieldDescriptorProto_Type.TYPE_STRING; + case 10: + case "TYPE_GROUP": + return FieldDescriptorProto_Type.TYPE_GROUP; + case 11: + case "TYPE_MESSAGE": + return FieldDescriptorProto_Type.TYPE_MESSAGE; + case 12: + case "TYPE_BYTES": + return FieldDescriptorProto_Type.TYPE_BYTES; + case 13: + case "TYPE_UINT32": + return FieldDescriptorProto_Type.TYPE_UINT32; + case 14: + case "TYPE_ENUM": + return FieldDescriptorProto_Type.TYPE_ENUM; + case 15: + case "TYPE_SFIXED32": + return FieldDescriptorProto_Type.TYPE_SFIXED32; + case 16: + case "TYPE_SFIXED64": + return FieldDescriptorProto_Type.TYPE_SFIXED64; + case 17: + case "TYPE_SINT32": + return FieldDescriptorProto_Type.TYPE_SINT32; + case 18: + case "TYPE_SINT64": + return FieldDescriptorProto_Type.TYPE_SINT64; + case -1: + case "UNRECOGNIZED": + default: + return FieldDescriptorProto_Type.UNRECOGNIZED; + } +} + +export function fieldDescriptorProto_TypeToJSON( + object: FieldDescriptorProto_Type +): string { + switch (object) { + case FieldDescriptorProto_Type.TYPE_DOUBLE: + return "TYPE_DOUBLE"; + case FieldDescriptorProto_Type.TYPE_FLOAT: + return "TYPE_FLOAT"; + case FieldDescriptorProto_Type.TYPE_INT64: + return "TYPE_INT64"; + case FieldDescriptorProto_Type.TYPE_UINT64: + return "TYPE_UINT64"; + case FieldDescriptorProto_Type.TYPE_INT32: + return "TYPE_INT32"; + case FieldDescriptorProto_Type.TYPE_FIXED64: + return "TYPE_FIXED64"; + case FieldDescriptorProto_Type.TYPE_FIXED32: + return "TYPE_FIXED32"; + case FieldDescriptorProto_Type.TYPE_BOOL: + return "TYPE_BOOL"; + case FieldDescriptorProto_Type.TYPE_STRING: + return "TYPE_STRING"; + case FieldDescriptorProto_Type.TYPE_GROUP: + return "TYPE_GROUP"; + case FieldDescriptorProto_Type.TYPE_MESSAGE: + return "TYPE_MESSAGE"; + case FieldDescriptorProto_Type.TYPE_BYTES: + return "TYPE_BYTES"; + case FieldDescriptorProto_Type.TYPE_UINT32: + return "TYPE_UINT32"; + case FieldDescriptorProto_Type.TYPE_ENUM: + return "TYPE_ENUM"; + case FieldDescriptorProto_Type.TYPE_SFIXED32: + return "TYPE_SFIXED32"; + case FieldDescriptorProto_Type.TYPE_SFIXED64: + return "TYPE_SFIXED64"; + case FieldDescriptorProto_Type.TYPE_SINT32: + return "TYPE_SINT32"; + case FieldDescriptorProto_Type.TYPE_SINT64: + return "TYPE_SINT64"; + default: + return "UNKNOWN"; + } +} + +export enum FieldDescriptorProto_Label { + /** LABEL_OPTIONAL - 0 is reserved for errors */ + LABEL_OPTIONAL = 1, + LABEL_REQUIRED = 2, + LABEL_REPEATED = 3, + UNRECOGNIZED = -1, +} + +export function fieldDescriptorProto_LabelFromJSON( + object: any +): FieldDescriptorProto_Label { + switch (object) { + case 1: + case "LABEL_OPTIONAL": + return FieldDescriptorProto_Label.LABEL_OPTIONAL; + case 2: + case "LABEL_REQUIRED": + return FieldDescriptorProto_Label.LABEL_REQUIRED; + case 3: + case "LABEL_REPEATED": + return FieldDescriptorProto_Label.LABEL_REPEATED; + case -1: + case "UNRECOGNIZED": + default: + return FieldDescriptorProto_Label.UNRECOGNIZED; + } +} + +export function fieldDescriptorProto_LabelToJSON( + object: FieldDescriptorProto_Label +): string { + switch (object) { + case FieldDescriptorProto_Label.LABEL_OPTIONAL: + return "LABEL_OPTIONAL"; + case FieldDescriptorProto_Label.LABEL_REQUIRED: + return "LABEL_REQUIRED"; + case FieldDescriptorProto_Label.LABEL_REPEATED: + return "LABEL_REPEATED"; + default: + return "UNKNOWN"; + } +} + +/** Describes a oneof. */ +export interface OneofDescriptorProto { + name: string; + options: OneofOptions | undefined; +} + +/** Describes an enum type. */ +export interface EnumDescriptorProto { + name: string; + value: EnumValueDescriptorProto[]; + options: EnumOptions | undefined; + /** + * Range of reserved numeric values. Reserved numeric values may not be used + * by enum values in the same enum declaration. Reserved ranges may not + * overlap. + */ + reservedRange: EnumDescriptorProto_EnumReservedRange[]; + /** + * Reserved enum value names, which may not be reused. A given name may only + * be reserved once. + */ + reservedName: string[]; +} + +/** + * Range of reserved numeric values. Reserved values may not be used by + * entries in the same enum. Reserved ranges may not overlap. + * + * Note that this is distinct from DescriptorProto.ReservedRange in that it + * is inclusive such that it can appropriately represent the entire int32 + * domain. + */ +export interface EnumDescriptorProto_EnumReservedRange { + /** Inclusive. */ + start: number; + /** Inclusive. */ + end: number; +} + +/** Describes a value within an enum. */ +export interface EnumValueDescriptorProto { + name: string; + number: number; + options: EnumValueOptions | undefined; +} + +/** Describes a service. */ +export interface ServiceDescriptorProto { + name: string; + method: MethodDescriptorProto[]; + options: ServiceOptions | undefined; +} + +/** Describes a method of a service. */ +export interface MethodDescriptorProto { + name: string; + /** + * Input and output type names. These are resolved in the same way as + * FieldDescriptorProto.type_name, but must refer to a message type. + */ + inputType: string; + outputType: string; + options: MethodOptions | undefined; + /** Identifies if client streams multiple client messages */ + clientStreaming: boolean; + /** Identifies if server streams multiple server messages */ + serverStreaming: boolean; +} + +export interface FileOptions { + /** + * Sets the Java package where classes generated from this .proto will be + * placed. By default, the proto package is used, but this is often + * inappropriate because proto packages do not normally start with backwards + * domain names. + */ + javaPackage: string; + /** + * Controls the name of the wrapper Java class generated for the .proto file. + * That class will always contain the .proto file's getDescriptor() method as + * well as any top-level extensions defined in the .proto file. + * If java_multiple_files is disabled, then all the other classes from the + * .proto file will be nested inside the single wrapper outer class. + */ + javaOuterClassname: string; + /** + * If enabled, then the Java code generator will generate a separate .java + * file for each top-level message, enum, and service defined in the .proto + * file. Thus, these types will *not* be nested inside the wrapper class + * named by java_outer_classname. However, the wrapper class will still be + * generated to contain the file's getDescriptor() method as well as any + * top-level extensions defined in the file. + */ + javaMultipleFiles: boolean; + /** + * This option does nothing. + * + * @deprecated + */ + javaGenerateEqualsAndHash: boolean; + /** + * If set true, then the Java2 code generator will generate code that + * throws an exception whenever an attempt is made to assign a non-UTF-8 + * byte sequence to a string field. + * Message reflection will do the same. + * However, an extension field still accepts non-UTF-8 byte sequences. + * This option has no effect on when used with the lite runtime. + */ + javaStringCheckUtf8: boolean; + optimizeFor: FileOptions_OptimizeMode; + /** + * Sets the Go package where structs generated from this .proto will be + * placed. If omitted, the Go package will be derived from the following: + * - The basename of the package import path, if provided. + * - Otherwise, the package statement in the .proto file, if present. + * - Otherwise, the basename of the .proto file, without extension. + */ + goPackage: string; + /** + * Should generic services be generated in each language? "Generic" services + * are not specific to any particular RPC system. They are generated by the + * main code generators in each language (without additional plugins). + * Generic services were the only kind of service generation supported by + * early versions of google.protobuf. + * + * Generic services are now considered deprecated in favor of using plugins + * that generate code specific to your particular RPC system. Therefore, + * these default to false. Old code which depends on generic services should + * explicitly set them to true. + */ + ccGenericServices: boolean; + javaGenericServices: boolean; + pyGenericServices: boolean; + phpGenericServices: boolean; + /** + * Is this file deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for everything in the file, or it will be completely ignored; in the very + * least, this is a formalization for deprecating files. + */ + deprecated: boolean; + /** + * Enables the use of arenas for the proto messages in this file. This applies + * only to generated classes for C++. + */ + ccEnableArenas: boolean; + /** + * Sets the objective c class prefix which is prepended to all objective c + * generated classes from this .proto. There is no default. + */ + objcClassPrefix: string; + /** Namespace for generated classes; defaults to the package. */ + csharpNamespace: string; + /** + * By default Swift generators will take the proto package and CamelCase it + * replacing '.' with underscore and use that to prefix the types/symbols + * defined. When this options is provided, they will use this value instead + * to prefix the types/symbols defined. + */ + swiftPrefix: string; + /** + * Sets the php class prefix which is prepended to all php generated classes + * from this .proto. Default is empty. + */ + phpClassPrefix: string; + /** + * Use this option to change the namespace of php generated classes. Default + * is empty. When this option is empty, the package name will be used for + * determining the namespace. + */ + phpNamespace: string; + /** + * Use this option to change the namespace of php generated metadata classes. + * Default is empty. When this option is empty, the proto file name will be + * used for determining the namespace. + */ + phpMetadataNamespace: string; + /** + * Use this option to change the package of ruby generated classes. Default + * is empty. When this option is not set, the package name will be used for + * determining the ruby package. + */ + rubyPackage: string; + /** + * The parser stores options it doesn't recognize here. + * See the documentation for the "Options" section above. + */ + uninterpretedOption: UninterpretedOption[]; +} + +/** Generated classes can be optimized for speed or code size. */ +export enum FileOptions_OptimizeMode { + /** SPEED - Generate complete code for parsing, serialization, */ + SPEED = 1, + /** CODE_SIZE - etc. */ + CODE_SIZE = 2, + /** LITE_RUNTIME - Generate code using MessageLite and the lite runtime. */ + LITE_RUNTIME = 3, + UNRECOGNIZED = -1, +} + +export function fileOptions_OptimizeModeFromJSON( + object: any +): FileOptions_OptimizeMode { + switch (object) { + case 1: + case "SPEED": + return FileOptions_OptimizeMode.SPEED; + case 2: + case "CODE_SIZE": + return FileOptions_OptimizeMode.CODE_SIZE; + case 3: + case "LITE_RUNTIME": + return FileOptions_OptimizeMode.LITE_RUNTIME; + case -1: + case "UNRECOGNIZED": + default: + return FileOptions_OptimizeMode.UNRECOGNIZED; + } +} + +export function fileOptions_OptimizeModeToJSON( + object: FileOptions_OptimizeMode +): string { + switch (object) { + case FileOptions_OptimizeMode.SPEED: + return "SPEED"; + case FileOptions_OptimizeMode.CODE_SIZE: + return "CODE_SIZE"; + case FileOptions_OptimizeMode.LITE_RUNTIME: + return "LITE_RUNTIME"; + default: + return "UNKNOWN"; + } +} + +export interface MessageOptions { + /** + * Set true to use the old proto1 MessageSet wire format for extensions. + * This is provided for backwards-compatibility with the MessageSet wire + * format. You should not use this for any other reason: It's less + * efficient, has fewer features, and is more complicated. + * + * The message must be defined exactly as follows: + * message Foo { + * option message_set_wire_format = true; + * extensions 4 to max; + * } + * Note that the message cannot have any defined fields; MessageSets only + * have extensions. + * + * All extensions of your type must be singular messages; e.g. they cannot + * be int32s, enums, or repeated messages. + * + * Because this is an option, the above two restrictions are not enforced by + * the protocol compiler. + */ + messageSetWireFormat: boolean; + /** + * Disables the generation of the standard "descriptor()" accessor, which can + * conflict with a field of the same name. This is meant to make migration + * from proto1 easier; new code should avoid fields named "descriptor". + */ + noStandardDescriptorAccessor: boolean; + /** + * Is this message deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the message, or it will be completely ignored; in the very least, + * this is a formalization for deprecating messages. + */ + deprecated: boolean; + /** + * Whether the message is an automatically generated map entry type for the + * maps field. + * + * For maps fields: + * map map_field = 1; + * The parsed descriptor looks like: + * message MapFieldEntry { + * option map_entry = true; + * optional KeyType key = 1; + * optional ValueType value = 2; + * } + * repeated MapFieldEntry map_field = 1; + * + * Implementations may choose not to generate the map_entry=true message, but + * use a native map in the target language to hold the keys and values. + * The reflection APIs in such implementations still need to work as + * if the field is a repeated message field. + * + * NOTE: Do not set the option in .proto files. Always use the maps syntax + * instead. The option should only be implicitly set by the proto compiler + * parser. + */ + mapEntry: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface FieldOptions { + /** + * The ctype option instructs the C++ code generator to use a different + * representation of the field than it normally would. See the specific + * options below. This option is not yet implemented in the open source + * release -- sorry, we'll try to include it in a future version! + */ + ctype: FieldOptions_CType; + /** + * The packed option can be enabled for repeated primitive fields to enable + * a more efficient representation on the wire. Rather than repeatedly + * writing the tag and type for each element, the entire array is encoded as + * a single length-delimited blob. In proto3, only explicit setting it to + * false will avoid using packed encoding. + */ + packed: boolean; + /** + * The jstype option determines the JavaScript type used for values of the + * field. The option is permitted only for 64 bit integral and fixed types + * (int64, uint64, sint64, fixed64, sfixed64). A field with jstype JS_STRING + * is represented as JavaScript string, which avoids loss of precision that + * can happen when a large value is converted to a floating point JavaScript. + * Specifying JS_NUMBER for the jstype causes the generated JavaScript code to + * use the JavaScript "number" type. The behavior of the default option + * JS_NORMAL is implementation dependent. + * + * This option is an enum to permit additional types to be added, e.g. + * goog.math.Integer. + */ + jstype: FieldOptions_JSType; + /** + * Should this field be parsed lazily? Lazy applies only to message-type + * fields. It means that when the outer message is initially parsed, the + * inner message's contents will not be parsed but instead stored in encoded + * form. The inner message will actually be parsed when it is first accessed. + * + * This is only a hint. Implementations are free to choose whether to use + * eager or lazy parsing regardless of the value of this option. However, + * setting this option true suggests that the protocol author believes that + * using lazy parsing on this field is worth the additional bookkeeping + * overhead typically needed to implement it. + * + * This option does not affect the public interface of any generated code; + * all method signatures remain the same. Furthermore, thread-safety of the + * interface is not affected by this option; const methods remain safe to + * call from multiple threads concurrently, while non-const methods continue + * to require exclusive access. + * + * + * Note that implementations may choose not to check required fields within + * a lazy sub-message. That is, calling IsInitialized() on the outer message + * may return true even if the inner message has missing required fields. + * This is necessary because otherwise the inner message would have to be + * parsed in order to perform the check, defeating the purpose of lazy + * parsing. An implementation which chooses not to check required fields + * must be consistent about it. That is, for any particular sub-message, the + * implementation must either *always* check its required fields, or *never* + * check its required fields, regardless of whether or not the message has + * been parsed. + */ + lazy: boolean; + /** + * Is this field deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for accessors, or it will be completely ignored; in the very least, this + * is a formalization for deprecating fields. + */ + deprecated: boolean; + /** For Google-internal migration only. Do not use. */ + weak: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export enum FieldOptions_CType { + /** STRING - Default mode. */ + STRING = 0, + CORD = 1, + STRING_PIECE = 2, + UNRECOGNIZED = -1, +} + +export function fieldOptions_CTypeFromJSON(object: any): FieldOptions_CType { + switch (object) { + case 0: + case "STRING": + return FieldOptions_CType.STRING; + case 1: + case "CORD": + return FieldOptions_CType.CORD; + case 2: + case "STRING_PIECE": + return FieldOptions_CType.STRING_PIECE; + case -1: + case "UNRECOGNIZED": + default: + return FieldOptions_CType.UNRECOGNIZED; + } +} + +export function fieldOptions_CTypeToJSON(object: FieldOptions_CType): string { + switch (object) { + case FieldOptions_CType.STRING: + return "STRING"; + case FieldOptions_CType.CORD: + return "CORD"; + case FieldOptions_CType.STRING_PIECE: + return "STRING_PIECE"; + default: + return "UNKNOWN"; + } +} + +export enum FieldOptions_JSType { + /** JS_NORMAL - Use the default type. */ + JS_NORMAL = 0, + /** JS_STRING - Use JavaScript strings. */ + JS_STRING = 1, + /** JS_NUMBER - Use JavaScript numbers. */ + JS_NUMBER = 2, + UNRECOGNIZED = -1, +} + +export function fieldOptions_JSTypeFromJSON(object: any): FieldOptions_JSType { + switch (object) { + case 0: + case "JS_NORMAL": + return FieldOptions_JSType.JS_NORMAL; + case 1: + case "JS_STRING": + return FieldOptions_JSType.JS_STRING; + case 2: + case "JS_NUMBER": + return FieldOptions_JSType.JS_NUMBER; + case -1: + case "UNRECOGNIZED": + default: + return FieldOptions_JSType.UNRECOGNIZED; + } +} + +export function fieldOptions_JSTypeToJSON(object: FieldOptions_JSType): string { + switch (object) { + case FieldOptions_JSType.JS_NORMAL: + return "JS_NORMAL"; + case FieldOptions_JSType.JS_STRING: + return "JS_STRING"; + case FieldOptions_JSType.JS_NUMBER: + return "JS_NUMBER"; + default: + return "UNKNOWN"; + } +} + +export interface OneofOptions { + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface EnumOptions { + /** + * Set this option to true to allow mapping different tag names to the same + * value. + */ + allowAlias: boolean; + /** + * Is this enum deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the enum, or it will be completely ignored; in the very least, this + * is a formalization for deprecating enums. + */ + deprecated: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface EnumValueOptions { + /** + * Is this enum value deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the enum value, or it will be completely ignored; in the very least, + * this is a formalization for deprecating enum values. + */ + deprecated: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface ServiceOptions { + /** + * Is this service deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the service, or it will be completely ignored; in the very least, + * this is a formalization for deprecating services. + */ + deprecated: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface MethodOptions { + /** + * Is this method deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the method, or it will be completely ignored; in the very least, + * this is a formalization for deprecating methods. + */ + deprecated: boolean; + idempotencyLevel: MethodOptions_IdempotencyLevel; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +/** + * Is this method side-effect-free (or safe in HTTP parlance), or idempotent, + * or neither? HTTP based RPC implementation may choose GET verb for safe + * methods, and PUT verb for idempotent methods instead of the default POST. + */ +export enum MethodOptions_IdempotencyLevel { + IDEMPOTENCY_UNKNOWN = 0, + /** NO_SIDE_EFFECTS - implies idempotent */ + NO_SIDE_EFFECTS = 1, + /** IDEMPOTENT - idempotent, but may have side effects */ + IDEMPOTENT = 2, + UNRECOGNIZED = -1, +} + +export function methodOptions_IdempotencyLevelFromJSON( + object: any +): MethodOptions_IdempotencyLevel { + switch (object) { + case 0: + case "IDEMPOTENCY_UNKNOWN": + return MethodOptions_IdempotencyLevel.IDEMPOTENCY_UNKNOWN; + case 1: + case "NO_SIDE_EFFECTS": + return MethodOptions_IdempotencyLevel.NO_SIDE_EFFECTS; + case 2: + case "IDEMPOTENT": + return MethodOptions_IdempotencyLevel.IDEMPOTENT; + case -1: + case "UNRECOGNIZED": + default: + return MethodOptions_IdempotencyLevel.UNRECOGNIZED; + } +} + +export function methodOptions_IdempotencyLevelToJSON( + object: MethodOptions_IdempotencyLevel +): string { + switch (object) { + case MethodOptions_IdempotencyLevel.IDEMPOTENCY_UNKNOWN: + return "IDEMPOTENCY_UNKNOWN"; + case MethodOptions_IdempotencyLevel.NO_SIDE_EFFECTS: + return "NO_SIDE_EFFECTS"; + case MethodOptions_IdempotencyLevel.IDEMPOTENT: + return "IDEMPOTENT"; + default: + return "UNKNOWN"; + } +} + +/** + * A message representing a option the parser does not recognize. This only + * appears in options protos created by the compiler::Parser class. + * DescriptorPool resolves these when building Descriptor objects. Therefore, + * options protos in descriptor objects (e.g. returned by Descriptor::options(), + * or produced by Descriptor::CopyTo()) will never have UninterpretedOptions + * in them. + */ +export interface UninterpretedOption { + name: UninterpretedOption_NamePart[]; + /** + * The value of the uninterpreted option, in whatever type the tokenizer + * identified it as during parsing. Exactly one of these should be set. + */ + identifierValue: string; + positiveIntValue: number; + negativeIntValue: number; + doubleValue: number; + stringValue: Uint8Array; + aggregateValue: string; +} + +/** + * The name of the uninterpreted option. Each string represents a segment in + * a dot-separated name. is_extension is true iff a segment represents an + * extension (denoted with parentheses in options specs in .proto files). + * E.g.,{ ["foo", false], ["bar.baz", true], ["qux", false] } represents + * "foo.(bar.baz).qux". + */ +export interface UninterpretedOption_NamePart { + namePart: string; + isExtension: boolean; +} + +/** + * Encapsulates information about the original source file from which a + * FileDescriptorProto was generated. + */ +export interface SourceCodeInfo { + /** + * A Location identifies a piece of source code in a .proto file which + * corresponds to a particular definition. This information is intended + * to be useful to IDEs, code indexers, documentation generators, and similar + * tools. + * + * For example, say we have a file like: + * message Foo { + * optional string foo = 1; + * } + * Let's look at just the field definition: + * optional string foo = 1; + * ^ ^^ ^^ ^ ^^^ + * a bc de f ghi + * We have the following locations: + * span path represents + * [a,i) [ 4, 0, 2, 0 ] The whole field definition. + * [a,b) [ 4, 0, 2, 0, 4 ] The label (optional). + * [c,d) [ 4, 0, 2, 0, 5 ] The type (string). + * [e,f) [ 4, 0, 2, 0, 1 ] The name (foo). + * [g,h) [ 4, 0, 2, 0, 3 ] The number (1). + * + * Notes: + * - A location may refer to a repeated field itself (i.e. not to any + * particular index within it). This is used whenever a set of elements are + * logically enclosed in a single code segment. For example, an entire + * extend block (possibly containing multiple extension definitions) will + * have an outer location whose path refers to the "extensions" repeated + * field without an index. + * - Multiple locations may have the same path. This happens when a single + * logical declaration is spread out across multiple places. The most + * obvious example is the "extend" block again -- there may be multiple + * extend blocks in the same scope, each of which will have the same path. + * - A location's span is not always a subset of its parent's span. For + * example, the "extendee" of an extension declaration appears at the + * beginning of the "extend" block and is shared by all extensions within + * the block. + * - Just because a location's span is a subset of some other location's span + * does not mean that it is a descendant. For example, a "group" defines + * both a type and a field in a single declaration. Thus, the locations + * corresponding to the type and field and their components will overlap. + * - Code which tries to interpret locations should probably be designed to + * ignore those that it doesn't understand, as more types of locations could + * be recorded in the future. + */ + location: SourceCodeInfo_Location[]; +} + +export interface SourceCodeInfo_Location { + /** + * Identifies which part of the FileDescriptorProto was defined at this + * location. + * + * Each element is a field number or an index. They form a path from + * the root FileDescriptorProto to the place where the definition. For + * example, this path: + * [ 4, 3, 2, 7, 1 ] + * refers to: + * file.message_type(3) // 4, 3 + * .field(7) // 2, 7 + * .name() // 1 + * This is because FileDescriptorProto.message_type has field number 4: + * repeated DescriptorProto message_type = 4; + * and DescriptorProto.field has field number 2: + * repeated FieldDescriptorProto field = 2; + * and FieldDescriptorProto.name has field number 1: + * optional string name = 1; + * + * Thus, the above path gives the location of a field name. If we removed + * the last element: + * [ 4, 3, 2, 7 ] + * this path refers to the whole field declaration (from the beginning + * of the label to the terminating semicolon). + */ + path: number[]; + /** + * Always has exactly three or four elements: start line, start column, + * end line (optional, otherwise assumed same as start line), end column. + * These are packed into a single field for efficiency. Note that line + * and column numbers are zero-based -- typically you will want to add + * 1 to each before displaying to a user. + */ + span: number[]; + /** + * If this SourceCodeInfo represents a complete declaration, these are any + * comments appearing before and after the declaration which appear to be + * attached to the declaration. + * + * A series of line comments appearing on consecutive lines, with no other + * tokens appearing on those lines, will be treated as a single comment. + * + * leading_detached_comments will keep paragraphs of comments that appear + * before (but not connected to) the current element. Each paragraph, + * separated by empty lines, will be one comment element in the repeated + * field. + * + * Only the comment content is provided; comment markers (e.g. //) are + * stripped out. For block comments, leading whitespace and an asterisk + * will be stripped from the beginning of each line other than the first. + * Newlines are included in the output. + * + * Examples: + * + * optional int32 foo = 1; // Comment attached to foo. + * // Comment attached to bar. + * optional int32 bar = 2; + * + * optional string baz = 3; + * // Comment attached to baz. + * // Another line attached to baz. + * + * // Comment attached to qux. + * // + * // Another line attached to qux. + * optional double qux = 4; + * + * // Detached comment for corge. This is not leading or trailing comments + * // to qux or corge because there are blank lines separating it from + * // both. + * + * // Detached comment for corge paragraph 2. + * + * optional string corge = 5; + * /* Block comment attached + * * to corge. Leading asterisks + * * will be removed. * / + * /* Block comment attached to + * * grault. * / + * optional int32 grault = 6; + * + * // ignored detached comments. + */ + leadingComments: string; + trailingComments: string; + leadingDetachedComments: string[]; +} + +/** + * Describes the relationship between generated code and its original source + * file. A GeneratedCodeInfo message is associated with only one generated + * source file, but may contain references to different source .proto files. + */ +export interface GeneratedCodeInfo { + /** + * An Annotation connects some span of text in generated code to an element + * of its generating .proto file. + */ + annotation: GeneratedCodeInfo_Annotation[]; +} + +export interface GeneratedCodeInfo_Annotation { + /** + * Identifies the element in the original source .proto file. This field + * is formatted the same as SourceCodeInfo.Location.path. + */ + path: number[]; + /** Identifies the filesystem path to the original source .proto. */ + sourceFile: string; + /** + * Identifies the starting offset in bytes in the generated code + * that relates to the identified object. + */ + begin: number; + /** + * Identifies the ending offset in bytes in the generated code that + * relates to the identified offset. The end offset should be one past + * the last relevant byte (so the length of the text = end - begin). + */ + end: number; +} + +const baseFileDescriptorSet: object = {}; + +export const FileDescriptorSet = { + encode(message: FileDescriptorSet, writer: Writer = Writer.create()): Writer { + for (const v of message.file) { + FileDescriptorProto.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FileDescriptorSet { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFileDescriptorSet } as FileDescriptorSet; + message.file = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.file.push( + FileDescriptorProto.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FileDescriptorSet { + const message = { ...baseFileDescriptorSet } as FileDescriptorSet; + message.file = []; + if (object.file !== undefined && object.file !== null) { + for (const e of object.file) { + message.file.push(FileDescriptorProto.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: FileDescriptorSet): unknown { + const obj: any = {}; + if (message.file) { + obj.file = message.file.map((e) => + e ? FileDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.file = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): FileDescriptorSet { + const message = { ...baseFileDescriptorSet } as FileDescriptorSet; + message.file = []; + if (object.file !== undefined && object.file !== null) { + for (const e of object.file) { + message.file.push(FileDescriptorProto.fromPartial(e)); + } + } + return message; + }, +}; + +const baseFileDescriptorProto: object = { + name: "", + package: "", + dependency: "", + publicDependency: 0, + weakDependency: 0, + syntax: "", +}; + +export const FileDescriptorProto = { + encode( + message: FileDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.package !== "") { + writer.uint32(18).string(message.package); + } + for (const v of message.dependency) { + writer.uint32(26).string(v!); + } + writer.uint32(82).fork(); + for (const v of message.publicDependency) { + writer.int32(v); + } + writer.ldelim(); + writer.uint32(90).fork(); + for (const v of message.weakDependency) { + writer.int32(v); + } + writer.ldelim(); + for (const v of message.messageType) { + DescriptorProto.encode(v!, writer.uint32(34).fork()).ldelim(); + } + for (const v of message.enumType) { + EnumDescriptorProto.encode(v!, writer.uint32(42).fork()).ldelim(); + } + for (const v of message.service) { + ServiceDescriptorProto.encode(v!, writer.uint32(50).fork()).ldelim(); + } + for (const v of message.extension) { + FieldDescriptorProto.encode(v!, writer.uint32(58).fork()).ldelim(); + } + if (message.options !== undefined) { + FileOptions.encode(message.options, writer.uint32(66).fork()).ldelim(); + } + if (message.sourceCodeInfo !== undefined) { + SourceCodeInfo.encode( + message.sourceCodeInfo, + writer.uint32(74).fork() + ).ldelim(); + } + if (message.syntax !== "") { + writer.uint32(98).string(message.syntax); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FileDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFileDescriptorProto } as FileDescriptorProto; + message.dependency = []; + message.publicDependency = []; + message.weakDependency = []; + message.messageType = []; + message.enumType = []; + message.service = []; + message.extension = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.package = reader.string(); + break; + case 3: + message.dependency.push(reader.string()); + break; + case 10: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.publicDependency.push(reader.int32()); + } + } else { + message.publicDependency.push(reader.int32()); + } + break; + case 11: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.weakDependency.push(reader.int32()); + } + } else { + message.weakDependency.push(reader.int32()); + } + break; + case 4: + message.messageType.push( + DescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 5: + message.enumType.push( + EnumDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 6: + message.service.push( + ServiceDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 7: + message.extension.push( + FieldDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 8: + message.options = FileOptions.decode(reader, reader.uint32()); + break; + case 9: + message.sourceCodeInfo = SourceCodeInfo.decode( + reader, + reader.uint32() + ); + break; + case 12: + message.syntax = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FileDescriptorProto { + const message = { ...baseFileDescriptorProto } as FileDescriptorProto; + message.dependency = []; + message.publicDependency = []; + message.weakDependency = []; + message.messageType = []; + message.enumType = []; + message.service = []; + message.extension = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.package !== undefined && object.package !== null) { + message.package = String(object.package); + } else { + message.package = ""; + } + if (object.dependency !== undefined && object.dependency !== null) { + for (const e of object.dependency) { + message.dependency.push(String(e)); + } + } + if ( + object.publicDependency !== undefined && + object.publicDependency !== null + ) { + for (const e of object.publicDependency) { + message.publicDependency.push(Number(e)); + } + } + if (object.weakDependency !== undefined && object.weakDependency !== null) { + for (const e of object.weakDependency) { + message.weakDependency.push(Number(e)); + } + } + if (object.messageType !== undefined && object.messageType !== null) { + for (const e of object.messageType) { + message.messageType.push(DescriptorProto.fromJSON(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromJSON(e)); + } + } + if (object.service !== undefined && object.service !== null) { + for (const e of object.service) { + message.service.push(ServiceDescriptorProto.fromJSON(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = FileOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.sourceCodeInfo !== undefined && object.sourceCodeInfo !== null) { + message.sourceCodeInfo = SourceCodeInfo.fromJSON(object.sourceCodeInfo); + } else { + message.sourceCodeInfo = undefined; + } + if (object.syntax !== undefined && object.syntax !== null) { + message.syntax = String(object.syntax); + } else { + message.syntax = ""; + } + return message; + }, + + toJSON(message: FileDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.package !== undefined && (obj.package = message.package); + if (message.dependency) { + obj.dependency = message.dependency.map((e) => e); + } else { + obj.dependency = []; + } + if (message.publicDependency) { + obj.publicDependency = message.publicDependency.map((e) => e); + } else { + obj.publicDependency = []; + } + if (message.weakDependency) { + obj.weakDependency = message.weakDependency.map((e) => e); + } else { + obj.weakDependency = []; + } + if (message.messageType) { + obj.messageType = message.messageType.map((e) => + e ? DescriptorProto.toJSON(e) : undefined + ); + } else { + obj.messageType = []; + } + if (message.enumType) { + obj.enumType = message.enumType.map((e) => + e ? EnumDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.enumType = []; + } + if (message.service) { + obj.service = message.service.map((e) => + e ? ServiceDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.service = []; + } + if (message.extension) { + obj.extension = message.extension.map((e) => + e ? FieldDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.extension = []; + } + message.options !== undefined && + (obj.options = message.options + ? FileOptions.toJSON(message.options) + : undefined); + message.sourceCodeInfo !== undefined && + (obj.sourceCodeInfo = message.sourceCodeInfo + ? SourceCodeInfo.toJSON(message.sourceCodeInfo) + : undefined); + message.syntax !== undefined && (obj.syntax = message.syntax); + return obj; + }, + + fromPartial(object: DeepPartial): FileDescriptorProto { + const message = { ...baseFileDescriptorProto } as FileDescriptorProto; + message.dependency = []; + message.publicDependency = []; + message.weakDependency = []; + message.messageType = []; + message.enumType = []; + message.service = []; + message.extension = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.package !== undefined && object.package !== null) { + message.package = object.package; + } else { + message.package = ""; + } + if (object.dependency !== undefined && object.dependency !== null) { + for (const e of object.dependency) { + message.dependency.push(e); + } + } + if ( + object.publicDependency !== undefined && + object.publicDependency !== null + ) { + for (const e of object.publicDependency) { + message.publicDependency.push(e); + } + } + if (object.weakDependency !== undefined && object.weakDependency !== null) { + for (const e of object.weakDependency) { + message.weakDependency.push(e); + } + } + if (object.messageType !== undefined && object.messageType !== null) { + for (const e of object.messageType) { + message.messageType.push(DescriptorProto.fromPartial(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromPartial(e)); + } + } + if (object.service !== undefined && object.service !== null) { + for (const e of object.service) { + message.service.push(ServiceDescriptorProto.fromPartial(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = FileOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.sourceCodeInfo !== undefined && object.sourceCodeInfo !== null) { + message.sourceCodeInfo = SourceCodeInfo.fromPartial( + object.sourceCodeInfo + ); + } else { + message.sourceCodeInfo = undefined; + } + if (object.syntax !== undefined && object.syntax !== null) { + message.syntax = object.syntax; + } else { + message.syntax = ""; + } + return message; + }, +}; + +const baseDescriptorProto: object = { name: "", reservedName: "" }; + +export const DescriptorProto = { + encode(message: DescriptorProto, writer: Writer = Writer.create()): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + for (const v of message.field) { + FieldDescriptorProto.encode(v!, writer.uint32(18).fork()).ldelim(); + } + for (const v of message.extension) { + FieldDescriptorProto.encode(v!, writer.uint32(50).fork()).ldelim(); + } + for (const v of message.nestedType) { + DescriptorProto.encode(v!, writer.uint32(26).fork()).ldelim(); + } + for (const v of message.enumType) { + EnumDescriptorProto.encode(v!, writer.uint32(34).fork()).ldelim(); + } + for (const v of message.extensionRange) { + DescriptorProto_ExtensionRange.encode( + v!, + writer.uint32(42).fork() + ).ldelim(); + } + for (const v of message.oneofDecl) { + OneofDescriptorProto.encode(v!, writer.uint32(66).fork()).ldelim(); + } + if (message.options !== undefined) { + MessageOptions.encode(message.options, writer.uint32(58).fork()).ldelim(); + } + for (const v of message.reservedRange) { + DescriptorProto_ReservedRange.encode( + v!, + writer.uint32(74).fork() + ).ldelim(); + } + for (const v of message.reservedName) { + writer.uint32(82).string(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): DescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseDescriptorProto } as DescriptorProto; + message.field = []; + message.extension = []; + message.nestedType = []; + message.enumType = []; + message.extensionRange = []; + message.oneofDecl = []; + message.reservedRange = []; + message.reservedName = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.field.push( + FieldDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 6: + message.extension.push( + FieldDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 3: + message.nestedType.push( + DescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 4: + message.enumType.push( + EnumDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 5: + message.extensionRange.push( + DescriptorProto_ExtensionRange.decode(reader, reader.uint32()) + ); + break; + case 8: + message.oneofDecl.push( + OneofDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 7: + message.options = MessageOptions.decode(reader, reader.uint32()); + break; + case 9: + message.reservedRange.push( + DescriptorProto_ReservedRange.decode(reader, reader.uint32()) + ); + break; + case 10: + message.reservedName.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DescriptorProto { + const message = { ...baseDescriptorProto } as DescriptorProto; + message.field = []; + message.extension = []; + message.nestedType = []; + message.enumType = []; + message.extensionRange = []; + message.oneofDecl = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.field !== undefined && object.field !== null) { + for (const e of object.field) { + message.field.push(FieldDescriptorProto.fromJSON(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromJSON(e)); + } + } + if (object.nestedType !== undefined && object.nestedType !== null) { + for (const e of object.nestedType) { + message.nestedType.push(DescriptorProto.fromJSON(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromJSON(e)); + } + } + if (object.extensionRange !== undefined && object.extensionRange !== null) { + for (const e of object.extensionRange) { + message.extensionRange.push(DescriptorProto_ExtensionRange.fromJSON(e)); + } + } + if (object.oneofDecl !== undefined && object.oneofDecl !== null) { + for (const e of object.oneofDecl) { + message.oneofDecl.push(OneofDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = MessageOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push(DescriptorProto_ReservedRange.fromJSON(e)); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(String(e)); + } + } + return message; + }, + + toJSON(message: DescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + if (message.field) { + obj.field = message.field.map((e) => + e ? FieldDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.field = []; + } + if (message.extension) { + obj.extension = message.extension.map((e) => + e ? FieldDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.extension = []; + } + if (message.nestedType) { + obj.nestedType = message.nestedType.map((e) => + e ? DescriptorProto.toJSON(e) : undefined + ); + } else { + obj.nestedType = []; + } + if (message.enumType) { + obj.enumType = message.enumType.map((e) => + e ? EnumDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.enumType = []; + } + if (message.extensionRange) { + obj.extensionRange = message.extensionRange.map((e) => + e ? DescriptorProto_ExtensionRange.toJSON(e) : undefined + ); + } else { + obj.extensionRange = []; + } + if (message.oneofDecl) { + obj.oneofDecl = message.oneofDecl.map((e) => + e ? OneofDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.oneofDecl = []; + } + message.options !== undefined && + (obj.options = message.options + ? MessageOptions.toJSON(message.options) + : undefined); + if (message.reservedRange) { + obj.reservedRange = message.reservedRange.map((e) => + e ? DescriptorProto_ReservedRange.toJSON(e) : undefined + ); + } else { + obj.reservedRange = []; + } + if (message.reservedName) { + obj.reservedName = message.reservedName.map((e) => e); + } else { + obj.reservedName = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): DescriptorProto { + const message = { ...baseDescriptorProto } as DescriptorProto; + message.field = []; + message.extension = []; + message.nestedType = []; + message.enumType = []; + message.extensionRange = []; + message.oneofDecl = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.field !== undefined && object.field !== null) { + for (const e of object.field) { + message.field.push(FieldDescriptorProto.fromPartial(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromPartial(e)); + } + } + if (object.nestedType !== undefined && object.nestedType !== null) { + for (const e of object.nestedType) { + message.nestedType.push(DescriptorProto.fromPartial(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromPartial(e)); + } + } + if (object.extensionRange !== undefined && object.extensionRange !== null) { + for (const e of object.extensionRange) { + message.extensionRange.push( + DescriptorProto_ExtensionRange.fromPartial(e) + ); + } + } + if (object.oneofDecl !== undefined && object.oneofDecl !== null) { + for (const e of object.oneofDecl) { + message.oneofDecl.push(OneofDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = MessageOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push( + DescriptorProto_ReservedRange.fromPartial(e) + ); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(e); + } + } + return message; + }, +}; + +const baseDescriptorProto_ExtensionRange: object = { start: 0, end: 0 }; + +export const DescriptorProto_ExtensionRange = { + encode( + message: DescriptorProto_ExtensionRange, + writer: Writer = Writer.create() + ): Writer { + if (message.start !== 0) { + writer.uint32(8).int32(message.start); + } + if (message.end !== 0) { + writer.uint32(16).int32(message.end); + } + if (message.options !== undefined) { + ExtensionRangeOptions.encode( + message.options, + writer.uint32(26).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): DescriptorProto_ExtensionRange { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseDescriptorProto_ExtensionRange, + } as DescriptorProto_ExtensionRange; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.start = reader.int32(); + break; + case 2: + message.end = reader.int32(); + break; + case 3: + message.options = ExtensionRangeOptions.decode( + reader, + reader.uint32() + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DescriptorProto_ExtensionRange { + const message = { + ...baseDescriptorProto_ExtensionRange, + } as DescriptorProto_ExtensionRange; + if (object.start !== undefined && object.start !== null) { + message.start = Number(object.start); + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = ExtensionRangeOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: DescriptorProto_ExtensionRange): unknown { + const obj: any = {}; + message.start !== undefined && (obj.start = message.start); + message.end !== undefined && (obj.end = message.end); + message.options !== undefined && + (obj.options = message.options + ? ExtensionRangeOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): DescriptorProto_ExtensionRange { + const message = { + ...baseDescriptorProto_ExtensionRange, + } as DescriptorProto_ExtensionRange; + if (object.start !== undefined && object.start !== null) { + message.start = object.start; + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = ExtensionRangeOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseDescriptorProto_ReservedRange: object = { start: 0, end: 0 }; + +export const DescriptorProto_ReservedRange = { + encode( + message: DescriptorProto_ReservedRange, + writer: Writer = Writer.create() + ): Writer { + if (message.start !== 0) { + writer.uint32(8).int32(message.start); + } + if (message.end !== 0) { + writer.uint32(16).int32(message.end); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): DescriptorProto_ReservedRange { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseDescriptorProto_ReservedRange, + } as DescriptorProto_ReservedRange; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.start = reader.int32(); + break; + case 2: + message.end = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DescriptorProto_ReservedRange { + const message = { + ...baseDescriptorProto_ReservedRange, + } as DescriptorProto_ReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = Number(object.start); + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + return message; + }, + + toJSON(message: DescriptorProto_ReservedRange): unknown { + const obj: any = {}; + message.start !== undefined && (obj.start = message.start); + message.end !== undefined && (obj.end = message.end); + return obj; + }, + + fromPartial( + object: DeepPartial + ): DescriptorProto_ReservedRange { + const message = { + ...baseDescriptorProto_ReservedRange, + } as DescriptorProto_ReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = object.start; + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + return message; + }, +}; + +const baseExtensionRangeOptions: object = {}; + +export const ExtensionRangeOptions = { + encode( + message: ExtensionRangeOptions, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ExtensionRangeOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseExtensionRangeOptions } as ExtensionRangeOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ExtensionRangeOptions { + const message = { ...baseExtensionRangeOptions } as ExtensionRangeOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: ExtensionRangeOptions): unknown { + const obj: any = {}; + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial( + object: DeepPartial + ): ExtensionRangeOptions { + const message = { ...baseExtensionRangeOptions } as ExtensionRangeOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseFieldDescriptorProto: object = { + name: "", + number: 0, + label: 1, + type: 1, + typeName: "", + extendee: "", + defaultValue: "", + oneofIndex: 0, + jsonName: "", + proto3Optional: false, +}; + +export const FieldDescriptorProto = { + encode( + message: FieldDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.number !== 0) { + writer.uint32(24).int32(message.number); + } + if (message.label !== 1) { + writer.uint32(32).int32(message.label); + } + if (message.type !== 1) { + writer.uint32(40).int32(message.type); + } + if (message.typeName !== "") { + writer.uint32(50).string(message.typeName); + } + if (message.extendee !== "") { + writer.uint32(18).string(message.extendee); + } + if (message.defaultValue !== "") { + writer.uint32(58).string(message.defaultValue); + } + if (message.oneofIndex !== 0) { + writer.uint32(72).int32(message.oneofIndex); + } + if (message.jsonName !== "") { + writer.uint32(82).string(message.jsonName); + } + if (message.options !== undefined) { + FieldOptions.encode(message.options, writer.uint32(66).fork()).ldelim(); + } + if (message.proto3Optional === true) { + writer.uint32(136).bool(message.proto3Optional); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FieldDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFieldDescriptorProto } as FieldDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 3: + message.number = reader.int32(); + break; + case 4: + message.label = reader.int32() as any; + break; + case 5: + message.type = reader.int32() as any; + break; + case 6: + message.typeName = reader.string(); + break; + case 2: + message.extendee = reader.string(); + break; + case 7: + message.defaultValue = reader.string(); + break; + case 9: + message.oneofIndex = reader.int32(); + break; + case 10: + message.jsonName = reader.string(); + break; + case 8: + message.options = FieldOptions.decode(reader, reader.uint32()); + break; + case 17: + message.proto3Optional = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FieldDescriptorProto { + const message = { ...baseFieldDescriptorProto } as FieldDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = Number(object.number); + } else { + message.number = 0; + } + if (object.label !== undefined && object.label !== null) { + message.label = fieldDescriptorProto_LabelFromJSON(object.label); + } else { + message.label = 1; + } + if (object.type !== undefined && object.type !== null) { + message.type = fieldDescriptorProto_TypeFromJSON(object.type); + } else { + message.type = 1; + } + if (object.typeName !== undefined && object.typeName !== null) { + message.typeName = String(object.typeName); + } else { + message.typeName = ""; + } + if (object.extendee !== undefined && object.extendee !== null) { + message.extendee = String(object.extendee); + } else { + message.extendee = ""; + } + if (object.defaultValue !== undefined && object.defaultValue !== null) { + message.defaultValue = String(object.defaultValue); + } else { + message.defaultValue = ""; + } + if (object.oneofIndex !== undefined && object.oneofIndex !== null) { + message.oneofIndex = Number(object.oneofIndex); + } else { + message.oneofIndex = 0; + } + if (object.jsonName !== undefined && object.jsonName !== null) { + message.jsonName = String(object.jsonName); + } else { + message.jsonName = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = FieldOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.proto3Optional !== undefined && object.proto3Optional !== null) { + message.proto3Optional = Boolean(object.proto3Optional); + } else { + message.proto3Optional = false; + } + return message; + }, + + toJSON(message: FieldDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.number !== undefined && (obj.number = message.number); + message.label !== undefined && + (obj.label = fieldDescriptorProto_LabelToJSON(message.label)); + message.type !== undefined && + (obj.type = fieldDescriptorProto_TypeToJSON(message.type)); + message.typeName !== undefined && (obj.typeName = message.typeName); + message.extendee !== undefined && (obj.extendee = message.extendee); + message.defaultValue !== undefined && + (obj.defaultValue = message.defaultValue); + message.oneofIndex !== undefined && (obj.oneofIndex = message.oneofIndex); + message.jsonName !== undefined && (obj.jsonName = message.jsonName); + message.options !== undefined && + (obj.options = message.options + ? FieldOptions.toJSON(message.options) + : undefined); + message.proto3Optional !== undefined && + (obj.proto3Optional = message.proto3Optional); + return obj; + }, + + fromPartial(object: DeepPartial): FieldDescriptorProto { + const message = { ...baseFieldDescriptorProto } as FieldDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = object.number; + } else { + message.number = 0; + } + if (object.label !== undefined && object.label !== null) { + message.label = object.label; + } else { + message.label = 1; + } + if (object.type !== undefined && object.type !== null) { + message.type = object.type; + } else { + message.type = 1; + } + if (object.typeName !== undefined && object.typeName !== null) { + message.typeName = object.typeName; + } else { + message.typeName = ""; + } + if (object.extendee !== undefined && object.extendee !== null) { + message.extendee = object.extendee; + } else { + message.extendee = ""; + } + if (object.defaultValue !== undefined && object.defaultValue !== null) { + message.defaultValue = object.defaultValue; + } else { + message.defaultValue = ""; + } + if (object.oneofIndex !== undefined && object.oneofIndex !== null) { + message.oneofIndex = object.oneofIndex; + } else { + message.oneofIndex = 0; + } + if (object.jsonName !== undefined && object.jsonName !== null) { + message.jsonName = object.jsonName; + } else { + message.jsonName = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = FieldOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.proto3Optional !== undefined && object.proto3Optional !== null) { + message.proto3Optional = object.proto3Optional; + } else { + message.proto3Optional = false; + } + return message; + }, +}; + +const baseOneofDescriptorProto: object = { name: "" }; + +export const OneofDescriptorProto = { + encode( + message: OneofDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.options !== undefined) { + OneofOptions.encode(message.options, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): OneofDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseOneofDescriptorProto } as OneofDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.options = OneofOptions.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): OneofDescriptorProto { + const message = { ...baseOneofDescriptorProto } as OneofDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = OneofOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: OneofDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.options !== undefined && + (obj.options = message.options + ? OneofOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): OneofDescriptorProto { + const message = { ...baseOneofDescriptorProto } as OneofDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = OneofOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseEnumDescriptorProto: object = { name: "", reservedName: "" }; + +export const EnumDescriptorProto = { + encode( + message: EnumDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + for (const v of message.value) { + EnumValueDescriptorProto.encode(v!, writer.uint32(18).fork()).ldelim(); + } + if (message.options !== undefined) { + EnumOptions.encode(message.options, writer.uint32(26).fork()).ldelim(); + } + for (const v of message.reservedRange) { + EnumDescriptorProto_EnumReservedRange.encode( + v!, + writer.uint32(34).fork() + ).ldelim(); + } + for (const v of message.reservedName) { + writer.uint32(42).string(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): EnumDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseEnumDescriptorProto } as EnumDescriptorProto; + message.value = []; + message.reservedRange = []; + message.reservedName = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.value.push( + EnumValueDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 3: + message.options = EnumOptions.decode(reader, reader.uint32()); + break; + case 4: + message.reservedRange.push( + EnumDescriptorProto_EnumReservedRange.decode( + reader, + reader.uint32() + ) + ); + break; + case 5: + message.reservedName.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumDescriptorProto { + const message = { ...baseEnumDescriptorProto } as EnumDescriptorProto; + message.value = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.value !== undefined && object.value !== null) { + for (const e of object.value) { + message.value.push(EnumValueDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push( + EnumDescriptorProto_EnumReservedRange.fromJSON(e) + ); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(String(e)); + } + } + return message; + }, + + toJSON(message: EnumDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + if (message.value) { + obj.value = message.value.map((e) => + e ? EnumValueDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.value = []; + } + message.options !== undefined && + (obj.options = message.options + ? EnumOptions.toJSON(message.options) + : undefined); + if (message.reservedRange) { + obj.reservedRange = message.reservedRange.map((e) => + e ? EnumDescriptorProto_EnumReservedRange.toJSON(e) : undefined + ); + } else { + obj.reservedRange = []; + } + if (message.reservedName) { + obj.reservedName = message.reservedName.map((e) => e); + } else { + obj.reservedName = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): EnumDescriptorProto { + const message = { ...baseEnumDescriptorProto } as EnumDescriptorProto; + message.value = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.value !== undefined && object.value !== null) { + for (const e of object.value) { + message.value.push(EnumValueDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push( + EnumDescriptorProto_EnumReservedRange.fromPartial(e) + ); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(e); + } + } + return message; + }, +}; + +const baseEnumDescriptorProto_EnumReservedRange: object = { start: 0, end: 0 }; + +export const EnumDescriptorProto_EnumReservedRange = { + encode( + message: EnumDescriptorProto_EnumReservedRange, + writer: Writer = Writer.create() + ): Writer { + if (message.start !== 0) { + writer.uint32(8).int32(message.start); + } + if (message.end !== 0) { + writer.uint32(16).int32(message.end); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): EnumDescriptorProto_EnumReservedRange { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseEnumDescriptorProto_EnumReservedRange, + } as EnumDescriptorProto_EnumReservedRange; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.start = reader.int32(); + break; + case 2: + message.end = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumDescriptorProto_EnumReservedRange { + const message = { + ...baseEnumDescriptorProto_EnumReservedRange, + } as EnumDescriptorProto_EnumReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = Number(object.start); + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + return message; + }, + + toJSON(message: EnumDescriptorProto_EnumReservedRange): unknown { + const obj: any = {}; + message.start !== undefined && (obj.start = message.start); + message.end !== undefined && (obj.end = message.end); + return obj; + }, + + fromPartial( + object: DeepPartial + ): EnumDescriptorProto_EnumReservedRange { + const message = { + ...baseEnumDescriptorProto_EnumReservedRange, + } as EnumDescriptorProto_EnumReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = object.start; + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + return message; + }, +}; + +const baseEnumValueDescriptorProto: object = { name: "", number: 0 }; + +export const EnumValueDescriptorProto = { + encode( + message: EnumValueDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.number !== 0) { + writer.uint32(16).int32(message.number); + } + if (message.options !== undefined) { + EnumValueOptions.encode( + message.options, + writer.uint32(26).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): EnumValueDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseEnumValueDescriptorProto, + } as EnumValueDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.number = reader.int32(); + break; + case 3: + message.options = EnumValueOptions.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumValueDescriptorProto { + const message = { + ...baseEnumValueDescriptorProto, + } as EnumValueDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = Number(object.number); + } else { + message.number = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumValueOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: EnumValueDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.number !== undefined && (obj.number = message.number); + message.options !== undefined && + (obj.options = message.options + ? EnumValueOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): EnumValueDescriptorProto { + const message = { + ...baseEnumValueDescriptorProto, + } as EnumValueDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = object.number; + } else { + message.number = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumValueOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseServiceDescriptorProto: object = { name: "" }; + +export const ServiceDescriptorProto = { + encode( + message: ServiceDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + for (const v of message.method) { + MethodDescriptorProto.encode(v!, writer.uint32(18).fork()).ldelim(); + } + if (message.options !== undefined) { + ServiceOptions.encode(message.options, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ServiceDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseServiceDescriptorProto } as ServiceDescriptorProto; + message.method = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.method.push( + MethodDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 3: + message.options = ServiceOptions.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ServiceDescriptorProto { + const message = { ...baseServiceDescriptorProto } as ServiceDescriptorProto; + message.method = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.method !== undefined && object.method !== null) { + for (const e of object.method) { + message.method.push(MethodDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = ServiceOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: ServiceDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + if (message.method) { + obj.method = message.method.map((e) => + e ? MethodDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.method = []; + } + message.options !== undefined && + (obj.options = message.options + ? ServiceOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): ServiceDescriptorProto { + const message = { ...baseServiceDescriptorProto } as ServiceDescriptorProto; + message.method = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.method !== undefined && object.method !== null) { + for (const e of object.method) { + message.method.push(MethodDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = ServiceOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseMethodDescriptorProto: object = { + name: "", + inputType: "", + outputType: "", + clientStreaming: false, + serverStreaming: false, +}; + +export const MethodDescriptorProto = { + encode( + message: MethodDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.inputType !== "") { + writer.uint32(18).string(message.inputType); + } + if (message.outputType !== "") { + writer.uint32(26).string(message.outputType); + } + if (message.options !== undefined) { + MethodOptions.encode(message.options, writer.uint32(34).fork()).ldelim(); + } + if (message.clientStreaming === true) { + writer.uint32(40).bool(message.clientStreaming); + } + if (message.serverStreaming === true) { + writer.uint32(48).bool(message.serverStreaming); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MethodDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMethodDescriptorProto } as MethodDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.inputType = reader.string(); + break; + case 3: + message.outputType = reader.string(); + break; + case 4: + message.options = MethodOptions.decode(reader, reader.uint32()); + break; + case 5: + message.clientStreaming = reader.bool(); + break; + case 6: + message.serverStreaming = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MethodDescriptorProto { + const message = { ...baseMethodDescriptorProto } as MethodDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.inputType !== undefined && object.inputType !== null) { + message.inputType = String(object.inputType); + } else { + message.inputType = ""; + } + if (object.outputType !== undefined && object.outputType !== null) { + message.outputType = String(object.outputType); + } else { + message.outputType = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = MethodOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if ( + object.clientStreaming !== undefined && + object.clientStreaming !== null + ) { + message.clientStreaming = Boolean(object.clientStreaming); + } else { + message.clientStreaming = false; + } + if ( + object.serverStreaming !== undefined && + object.serverStreaming !== null + ) { + message.serverStreaming = Boolean(object.serverStreaming); + } else { + message.serverStreaming = false; + } + return message; + }, + + toJSON(message: MethodDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.inputType !== undefined && (obj.inputType = message.inputType); + message.outputType !== undefined && (obj.outputType = message.outputType); + message.options !== undefined && + (obj.options = message.options + ? MethodOptions.toJSON(message.options) + : undefined); + message.clientStreaming !== undefined && + (obj.clientStreaming = message.clientStreaming); + message.serverStreaming !== undefined && + (obj.serverStreaming = message.serverStreaming); + return obj; + }, + + fromPartial( + object: DeepPartial + ): MethodDescriptorProto { + const message = { ...baseMethodDescriptorProto } as MethodDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.inputType !== undefined && object.inputType !== null) { + message.inputType = object.inputType; + } else { + message.inputType = ""; + } + if (object.outputType !== undefined && object.outputType !== null) { + message.outputType = object.outputType; + } else { + message.outputType = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = MethodOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if ( + object.clientStreaming !== undefined && + object.clientStreaming !== null + ) { + message.clientStreaming = object.clientStreaming; + } else { + message.clientStreaming = false; + } + if ( + object.serverStreaming !== undefined && + object.serverStreaming !== null + ) { + message.serverStreaming = object.serverStreaming; + } else { + message.serverStreaming = false; + } + return message; + }, +}; + +const baseFileOptions: object = { + javaPackage: "", + javaOuterClassname: "", + javaMultipleFiles: false, + javaGenerateEqualsAndHash: false, + javaStringCheckUtf8: false, + optimizeFor: 1, + goPackage: "", + ccGenericServices: false, + javaGenericServices: false, + pyGenericServices: false, + phpGenericServices: false, + deprecated: false, + ccEnableArenas: false, + objcClassPrefix: "", + csharpNamespace: "", + swiftPrefix: "", + phpClassPrefix: "", + phpNamespace: "", + phpMetadataNamespace: "", + rubyPackage: "", +}; + +export const FileOptions = { + encode(message: FileOptions, writer: Writer = Writer.create()): Writer { + if (message.javaPackage !== "") { + writer.uint32(10).string(message.javaPackage); + } + if (message.javaOuterClassname !== "") { + writer.uint32(66).string(message.javaOuterClassname); + } + if (message.javaMultipleFiles === true) { + writer.uint32(80).bool(message.javaMultipleFiles); + } + if (message.javaGenerateEqualsAndHash === true) { + writer.uint32(160).bool(message.javaGenerateEqualsAndHash); + } + if (message.javaStringCheckUtf8 === true) { + writer.uint32(216).bool(message.javaStringCheckUtf8); + } + if (message.optimizeFor !== 1) { + writer.uint32(72).int32(message.optimizeFor); + } + if (message.goPackage !== "") { + writer.uint32(90).string(message.goPackage); + } + if (message.ccGenericServices === true) { + writer.uint32(128).bool(message.ccGenericServices); + } + if (message.javaGenericServices === true) { + writer.uint32(136).bool(message.javaGenericServices); + } + if (message.pyGenericServices === true) { + writer.uint32(144).bool(message.pyGenericServices); + } + if (message.phpGenericServices === true) { + writer.uint32(336).bool(message.phpGenericServices); + } + if (message.deprecated === true) { + writer.uint32(184).bool(message.deprecated); + } + if (message.ccEnableArenas === true) { + writer.uint32(248).bool(message.ccEnableArenas); + } + if (message.objcClassPrefix !== "") { + writer.uint32(290).string(message.objcClassPrefix); + } + if (message.csharpNamespace !== "") { + writer.uint32(298).string(message.csharpNamespace); + } + if (message.swiftPrefix !== "") { + writer.uint32(314).string(message.swiftPrefix); + } + if (message.phpClassPrefix !== "") { + writer.uint32(322).string(message.phpClassPrefix); + } + if (message.phpNamespace !== "") { + writer.uint32(330).string(message.phpNamespace); + } + if (message.phpMetadataNamespace !== "") { + writer.uint32(354).string(message.phpMetadataNamespace); + } + if (message.rubyPackage !== "") { + writer.uint32(362).string(message.rubyPackage); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FileOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFileOptions } as FileOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.javaPackage = reader.string(); + break; + case 8: + message.javaOuterClassname = reader.string(); + break; + case 10: + message.javaMultipleFiles = reader.bool(); + break; + case 20: + message.javaGenerateEqualsAndHash = reader.bool(); + break; + case 27: + message.javaStringCheckUtf8 = reader.bool(); + break; + case 9: + message.optimizeFor = reader.int32() as any; + break; + case 11: + message.goPackage = reader.string(); + break; + case 16: + message.ccGenericServices = reader.bool(); + break; + case 17: + message.javaGenericServices = reader.bool(); + break; + case 18: + message.pyGenericServices = reader.bool(); + break; + case 42: + message.phpGenericServices = reader.bool(); + break; + case 23: + message.deprecated = reader.bool(); + break; + case 31: + message.ccEnableArenas = reader.bool(); + break; + case 36: + message.objcClassPrefix = reader.string(); + break; + case 37: + message.csharpNamespace = reader.string(); + break; + case 39: + message.swiftPrefix = reader.string(); + break; + case 40: + message.phpClassPrefix = reader.string(); + break; + case 41: + message.phpNamespace = reader.string(); + break; + case 44: + message.phpMetadataNamespace = reader.string(); + break; + case 45: + message.rubyPackage = reader.string(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FileOptions { + const message = { ...baseFileOptions } as FileOptions; + message.uninterpretedOption = []; + if (object.javaPackage !== undefined && object.javaPackage !== null) { + message.javaPackage = String(object.javaPackage); + } else { + message.javaPackage = ""; + } + if ( + object.javaOuterClassname !== undefined && + object.javaOuterClassname !== null + ) { + message.javaOuterClassname = String(object.javaOuterClassname); + } else { + message.javaOuterClassname = ""; + } + if ( + object.javaMultipleFiles !== undefined && + object.javaMultipleFiles !== null + ) { + message.javaMultipleFiles = Boolean(object.javaMultipleFiles); + } else { + message.javaMultipleFiles = false; + } + if ( + object.javaGenerateEqualsAndHash !== undefined && + object.javaGenerateEqualsAndHash !== null + ) { + message.javaGenerateEqualsAndHash = Boolean( + object.javaGenerateEqualsAndHash + ); + } else { + message.javaGenerateEqualsAndHash = false; + } + if ( + object.javaStringCheckUtf8 !== undefined && + object.javaStringCheckUtf8 !== null + ) { + message.javaStringCheckUtf8 = Boolean(object.javaStringCheckUtf8); + } else { + message.javaStringCheckUtf8 = false; + } + if (object.optimizeFor !== undefined && object.optimizeFor !== null) { + message.optimizeFor = fileOptions_OptimizeModeFromJSON( + object.optimizeFor + ); + } else { + message.optimizeFor = 1; + } + if (object.goPackage !== undefined && object.goPackage !== null) { + message.goPackage = String(object.goPackage); + } else { + message.goPackage = ""; + } + if ( + object.ccGenericServices !== undefined && + object.ccGenericServices !== null + ) { + message.ccGenericServices = Boolean(object.ccGenericServices); + } else { + message.ccGenericServices = false; + } + if ( + object.javaGenericServices !== undefined && + object.javaGenericServices !== null + ) { + message.javaGenericServices = Boolean(object.javaGenericServices); + } else { + message.javaGenericServices = false; + } + if ( + object.pyGenericServices !== undefined && + object.pyGenericServices !== null + ) { + message.pyGenericServices = Boolean(object.pyGenericServices); + } else { + message.pyGenericServices = false; + } + if ( + object.phpGenericServices !== undefined && + object.phpGenericServices !== null + ) { + message.phpGenericServices = Boolean(object.phpGenericServices); + } else { + message.phpGenericServices = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if (object.ccEnableArenas !== undefined && object.ccEnableArenas !== null) { + message.ccEnableArenas = Boolean(object.ccEnableArenas); + } else { + message.ccEnableArenas = false; + } + if ( + object.objcClassPrefix !== undefined && + object.objcClassPrefix !== null + ) { + message.objcClassPrefix = String(object.objcClassPrefix); + } else { + message.objcClassPrefix = ""; + } + if ( + object.csharpNamespace !== undefined && + object.csharpNamespace !== null + ) { + message.csharpNamespace = String(object.csharpNamespace); + } else { + message.csharpNamespace = ""; + } + if (object.swiftPrefix !== undefined && object.swiftPrefix !== null) { + message.swiftPrefix = String(object.swiftPrefix); + } else { + message.swiftPrefix = ""; + } + if (object.phpClassPrefix !== undefined && object.phpClassPrefix !== null) { + message.phpClassPrefix = String(object.phpClassPrefix); + } else { + message.phpClassPrefix = ""; + } + if (object.phpNamespace !== undefined && object.phpNamespace !== null) { + message.phpNamespace = String(object.phpNamespace); + } else { + message.phpNamespace = ""; + } + if ( + object.phpMetadataNamespace !== undefined && + object.phpMetadataNamespace !== null + ) { + message.phpMetadataNamespace = String(object.phpMetadataNamespace); + } else { + message.phpMetadataNamespace = ""; + } + if (object.rubyPackage !== undefined && object.rubyPackage !== null) { + message.rubyPackage = String(object.rubyPackage); + } else { + message.rubyPackage = ""; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: FileOptions): unknown { + const obj: any = {}; + message.javaPackage !== undefined && + (obj.javaPackage = message.javaPackage); + message.javaOuterClassname !== undefined && + (obj.javaOuterClassname = message.javaOuterClassname); + message.javaMultipleFiles !== undefined && + (obj.javaMultipleFiles = message.javaMultipleFiles); + message.javaGenerateEqualsAndHash !== undefined && + (obj.javaGenerateEqualsAndHash = message.javaGenerateEqualsAndHash); + message.javaStringCheckUtf8 !== undefined && + (obj.javaStringCheckUtf8 = message.javaStringCheckUtf8); + message.optimizeFor !== undefined && + (obj.optimizeFor = fileOptions_OptimizeModeToJSON(message.optimizeFor)); + message.goPackage !== undefined && (obj.goPackage = message.goPackage); + message.ccGenericServices !== undefined && + (obj.ccGenericServices = message.ccGenericServices); + message.javaGenericServices !== undefined && + (obj.javaGenericServices = message.javaGenericServices); + message.pyGenericServices !== undefined && + (obj.pyGenericServices = message.pyGenericServices); + message.phpGenericServices !== undefined && + (obj.phpGenericServices = message.phpGenericServices); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.ccEnableArenas !== undefined && + (obj.ccEnableArenas = message.ccEnableArenas); + message.objcClassPrefix !== undefined && + (obj.objcClassPrefix = message.objcClassPrefix); + message.csharpNamespace !== undefined && + (obj.csharpNamespace = message.csharpNamespace); + message.swiftPrefix !== undefined && + (obj.swiftPrefix = message.swiftPrefix); + message.phpClassPrefix !== undefined && + (obj.phpClassPrefix = message.phpClassPrefix); + message.phpNamespace !== undefined && + (obj.phpNamespace = message.phpNamespace); + message.phpMetadataNamespace !== undefined && + (obj.phpMetadataNamespace = message.phpMetadataNamespace); + message.rubyPackage !== undefined && + (obj.rubyPackage = message.rubyPackage); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): FileOptions { + const message = { ...baseFileOptions } as FileOptions; + message.uninterpretedOption = []; + if (object.javaPackage !== undefined && object.javaPackage !== null) { + message.javaPackage = object.javaPackage; + } else { + message.javaPackage = ""; + } + if ( + object.javaOuterClassname !== undefined && + object.javaOuterClassname !== null + ) { + message.javaOuterClassname = object.javaOuterClassname; + } else { + message.javaOuterClassname = ""; + } + if ( + object.javaMultipleFiles !== undefined && + object.javaMultipleFiles !== null + ) { + message.javaMultipleFiles = object.javaMultipleFiles; + } else { + message.javaMultipleFiles = false; + } + if ( + object.javaGenerateEqualsAndHash !== undefined && + object.javaGenerateEqualsAndHash !== null + ) { + message.javaGenerateEqualsAndHash = object.javaGenerateEqualsAndHash; + } else { + message.javaGenerateEqualsAndHash = false; + } + if ( + object.javaStringCheckUtf8 !== undefined && + object.javaStringCheckUtf8 !== null + ) { + message.javaStringCheckUtf8 = object.javaStringCheckUtf8; + } else { + message.javaStringCheckUtf8 = false; + } + if (object.optimizeFor !== undefined && object.optimizeFor !== null) { + message.optimizeFor = object.optimizeFor; + } else { + message.optimizeFor = 1; + } + if (object.goPackage !== undefined && object.goPackage !== null) { + message.goPackage = object.goPackage; + } else { + message.goPackage = ""; + } + if ( + object.ccGenericServices !== undefined && + object.ccGenericServices !== null + ) { + message.ccGenericServices = object.ccGenericServices; + } else { + message.ccGenericServices = false; + } + if ( + object.javaGenericServices !== undefined && + object.javaGenericServices !== null + ) { + message.javaGenericServices = object.javaGenericServices; + } else { + message.javaGenericServices = false; + } + if ( + object.pyGenericServices !== undefined && + object.pyGenericServices !== null + ) { + message.pyGenericServices = object.pyGenericServices; + } else { + message.pyGenericServices = false; + } + if ( + object.phpGenericServices !== undefined && + object.phpGenericServices !== null + ) { + message.phpGenericServices = object.phpGenericServices; + } else { + message.phpGenericServices = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if (object.ccEnableArenas !== undefined && object.ccEnableArenas !== null) { + message.ccEnableArenas = object.ccEnableArenas; + } else { + message.ccEnableArenas = false; + } + if ( + object.objcClassPrefix !== undefined && + object.objcClassPrefix !== null + ) { + message.objcClassPrefix = object.objcClassPrefix; + } else { + message.objcClassPrefix = ""; + } + if ( + object.csharpNamespace !== undefined && + object.csharpNamespace !== null + ) { + message.csharpNamespace = object.csharpNamespace; + } else { + message.csharpNamespace = ""; + } + if (object.swiftPrefix !== undefined && object.swiftPrefix !== null) { + message.swiftPrefix = object.swiftPrefix; + } else { + message.swiftPrefix = ""; + } + if (object.phpClassPrefix !== undefined && object.phpClassPrefix !== null) { + message.phpClassPrefix = object.phpClassPrefix; + } else { + message.phpClassPrefix = ""; + } + if (object.phpNamespace !== undefined && object.phpNamespace !== null) { + message.phpNamespace = object.phpNamespace; + } else { + message.phpNamespace = ""; + } + if ( + object.phpMetadataNamespace !== undefined && + object.phpMetadataNamespace !== null + ) { + message.phpMetadataNamespace = object.phpMetadataNamespace; + } else { + message.phpMetadataNamespace = ""; + } + if (object.rubyPackage !== undefined && object.rubyPackage !== null) { + message.rubyPackage = object.rubyPackage; + } else { + message.rubyPackage = ""; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseMessageOptions: object = { + messageSetWireFormat: false, + noStandardDescriptorAccessor: false, + deprecated: false, + mapEntry: false, +}; + +export const MessageOptions = { + encode(message: MessageOptions, writer: Writer = Writer.create()): Writer { + if (message.messageSetWireFormat === true) { + writer.uint32(8).bool(message.messageSetWireFormat); + } + if (message.noStandardDescriptorAccessor === true) { + writer.uint32(16).bool(message.noStandardDescriptorAccessor); + } + if (message.deprecated === true) { + writer.uint32(24).bool(message.deprecated); + } + if (message.mapEntry === true) { + writer.uint32(56).bool(message.mapEntry); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MessageOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMessageOptions } as MessageOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.messageSetWireFormat = reader.bool(); + break; + case 2: + message.noStandardDescriptorAccessor = reader.bool(); + break; + case 3: + message.deprecated = reader.bool(); + break; + case 7: + message.mapEntry = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MessageOptions { + const message = { ...baseMessageOptions } as MessageOptions; + message.uninterpretedOption = []; + if ( + object.messageSetWireFormat !== undefined && + object.messageSetWireFormat !== null + ) { + message.messageSetWireFormat = Boolean(object.messageSetWireFormat); + } else { + message.messageSetWireFormat = false; + } + if ( + object.noStandardDescriptorAccessor !== undefined && + object.noStandardDescriptorAccessor !== null + ) { + message.noStandardDescriptorAccessor = Boolean( + object.noStandardDescriptorAccessor + ); + } else { + message.noStandardDescriptorAccessor = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if (object.mapEntry !== undefined && object.mapEntry !== null) { + message.mapEntry = Boolean(object.mapEntry); + } else { + message.mapEntry = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: MessageOptions): unknown { + const obj: any = {}; + message.messageSetWireFormat !== undefined && + (obj.messageSetWireFormat = message.messageSetWireFormat); + message.noStandardDescriptorAccessor !== undefined && + (obj.noStandardDescriptorAccessor = message.noStandardDescriptorAccessor); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.mapEntry !== undefined && (obj.mapEntry = message.mapEntry); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): MessageOptions { + const message = { ...baseMessageOptions } as MessageOptions; + message.uninterpretedOption = []; + if ( + object.messageSetWireFormat !== undefined && + object.messageSetWireFormat !== null + ) { + message.messageSetWireFormat = object.messageSetWireFormat; + } else { + message.messageSetWireFormat = false; + } + if ( + object.noStandardDescriptorAccessor !== undefined && + object.noStandardDescriptorAccessor !== null + ) { + message.noStandardDescriptorAccessor = + object.noStandardDescriptorAccessor; + } else { + message.noStandardDescriptorAccessor = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if (object.mapEntry !== undefined && object.mapEntry !== null) { + message.mapEntry = object.mapEntry; + } else { + message.mapEntry = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseFieldOptions: object = { + ctype: 0, + packed: false, + jstype: 0, + lazy: false, + deprecated: false, + weak: false, +}; + +export const FieldOptions = { + encode(message: FieldOptions, writer: Writer = Writer.create()): Writer { + if (message.ctype !== 0) { + writer.uint32(8).int32(message.ctype); + } + if (message.packed === true) { + writer.uint32(16).bool(message.packed); + } + if (message.jstype !== 0) { + writer.uint32(48).int32(message.jstype); + } + if (message.lazy === true) { + writer.uint32(40).bool(message.lazy); + } + if (message.deprecated === true) { + writer.uint32(24).bool(message.deprecated); + } + if (message.weak === true) { + writer.uint32(80).bool(message.weak); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FieldOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFieldOptions } as FieldOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.ctype = reader.int32() as any; + break; + case 2: + message.packed = reader.bool(); + break; + case 6: + message.jstype = reader.int32() as any; + break; + case 5: + message.lazy = reader.bool(); + break; + case 3: + message.deprecated = reader.bool(); + break; + case 10: + message.weak = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FieldOptions { + const message = { ...baseFieldOptions } as FieldOptions; + message.uninterpretedOption = []; + if (object.ctype !== undefined && object.ctype !== null) { + message.ctype = fieldOptions_CTypeFromJSON(object.ctype); + } else { + message.ctype = 0; + } + if (object.packed !== undefined && object.packed !== null) { + message.packed = Boolean(object.packed); + } else { + message.packed = false; + } + if (object.jstype !== undefined && object.jstype !== null) { + message.jstype = fieldOptions_JSTypeFromJSON(object.jstype); + } else { + message.jstype = 0; + } + if (object.lazy !== undefined && object.lazy !== null) { + message.lazy = Boolean(object.lazy); + } else { + message.lazy = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if (object.weak !== undefined && object.weak !== null) { + message.weak = Boolean(object.weak); + } else { + message.weak = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: FieldOptions): unknown { + const obj: any = {}; + message.ctype !== undefined && + (obj.ctype = fieldOptions_CTypeToJSON(message.ctype)); + message.packed !== undefined && (obj.packed = message.packed); + message.jstype !== undefined && + (obj.jstype = fieldOptions_JSTypeToJSON(message.jstype)); + message.lazy !== undefined && (obj.lazy = message.lazy); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.weak !== undefined && (obj.weak = message.weak); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): FieldOptions { + const message = { ...baseFieldOptions } as FieldOptions; + message.uninterpretedOption = []; + if (object.ctype !== undefined && object.ctype !== null) { + message.ctype = object.ctype; + } else { + message.ctype = 0; + } + if (object.packed !== undefined && object.packed !== null) { + message.packed = object.packed; + } else { + message.packed = false; + } + if (object.jstype !== undefined && object.jstype !== null) { + message.jstype = object.jstype; + } else { + message.jstype = 0; + } + if (object.lazy !== undefined && object.lazy !== null) { + message.lazy = object.lazy; + } else { + message.lazy = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if (object.weak !== undefined && object.weak !== null) { + message.weak = object.weak; + } else { + message.weak = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseOneofOptions: object = {}; + +export const OneofOptions = { + encode(message: OneofOptions, writer: Writer = Writer.create()): Writer { + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): OneofOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseOneofOptions } as OneofOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): OneofOptions { + const message = { ...baseOneofOptions } as OneofOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: OneofOptions): unknown { + const obj: any = {}; + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): OneofOptions { + const message = { ...baseOneofOptions } as OneofOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseEnumOptions: object = { allowAlias: false, deprecated: false }; + +export const EnumOptions = { + encode(message: EnumOptions, writer: Writer = Writer.create()): Writer { + if (message.allowAlias === true) { + writer.uint32(16).bool(message.allowAlias); + } + if (message.deprecated === true) { + writer.uint32(24).bool(message.deprecated); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): EnumOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseEnumOptions } as EnumOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + message.allowAlias = reader.bool(); + break; + case 3: + message.deprecated = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumOptions { + const message = { ...baseEnumOptions } as EnumOptions; + message.uninterpretedOption = []; + if (object.allowAlias !== undefined && object.allowAlias !== null) { + message.allowAlias = Boolean(object.allowAlias); + } else { + message.allowAlias = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: EnumOptions): unknown { + const obj: any = {}; + message.allowAlias !== undefined && (obj.allowAlias = message.allowAlias); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): EnumOptions { + const message = { ...baseEnumOptions } as EnumOptions; + message.uninterpretedOption = []; + if (object.allowAlias !== undefined && object.allowAlias !== null) { + message.allowAlias = object.allowAlias; + } else { + message.allowAlias = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseEnumValueOptions: object = { deprecated: false }; + +export const EnumValueOptions = { + encode(message: EnumValueOptions, writer: Writer = Writer.create()): Writer { + if (message.deprecated === true) { + writer.uint32(8).bool(message.deprecated); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): EnumValueOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseEnumValueOptions } as EnumValueOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.deprecated = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumValueOptions { + const message = { ...baseEnumValueOptions } as EnumValueOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: EnumValueOptions): unknown { + const obj: any = {}; + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): EnumValueOptions { + const message = { ...baseEnumValueOptions } as EnumValueOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseServiceOptions: object = { deprecated: false }; + +export const ServiceOptions = { + encode(message: ServiceOptions, writer: Writer = Writer.create()): Writer { + if (message.deprecated === true) { + writer.uint32(264).bool(message.deprecated); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ServiceOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseServiceOptions } as ServiceOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 33: + message.deprecated = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ServiceOptions { + const message = { ...baseServiceOptions } as ServiceOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: ServiceOptions): unknown { + const obj: any = {}; + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): ServiceOptions { + const message = { ...baseServiceOptions } as ServiceOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseMethodOptions: object = { deprecated: false, idempotencyLevel: 0 }; + +export const MethodOptions = { + encode(message: MethodOptions, writer: Writer = Writer.create()): Writer { + if (message.deprecated === true) { + writer.uint32(264).bool(message.deprecated); + } + if (message.idempotencyLevel !== 0) { + writer.uint32(272).int32(message.idempotencyLevel); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MethodOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMethodOptions } as MethodOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 33: + message.deprecated = reader.bool(); + break; + case 34: + message.idempotencyLevel = reader.int32() as any; + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MethodOptions { + const message = { ...baseMethodOptions } as MethodOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.idempotencyLevel !== undefined && + object.idempotencyLevel !== null + ) { + message.idempotencyLevel = methodOptions_IdempotencyLevelFromJSON( + object.idempotencyLevel + ); + } else { + message.idempotencyLevel = 0; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: MethodOptions): unknown { + const obj: any = {}; + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.idempotencyLevel !== undefined && + (obj.idempotencyLevel = methodOptions_IdempotencyLevelToJSON( + message.idempotencyLevel + )); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): MethodOptions { + const message = { ...baseMethodOptions } as MethodOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.idempotencyLevel !== undefined && + object.idempotencyLevel !== null + ) { + message.idempotencyLevel = object.idempotencyLevel; + } else { + message.idempotencyLevel = 0; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseUninterpretedOption: object = { + identifierValue: "", + positiveIntValue: 0, + negativeIntValue: 0, + doubleValue: 0, + aggregateValue: "", +}; + +export const UninterpretedOption = { + encode( + message: UninterpretedOption, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.name) { + UninterpretedOption_NamePart.encode( + v!, + writer.uint32(18).fork() + ).ldelim(); + } + if (message.identifierValue !== "") { + writer.uint32(26).string(message.identifierValue); + } + if (message.positiveIntValue !== 0) { + writer.uint32(32).uint64(message.positiveIntValue); + } + if (message.negativeIntValue !== 0) { + writer.uint32(40).int64(message.negativeIntValue); + } + if (message.doubleValue !== 0) { + writer.uint32(49).double(message.doubleValue); + } + if (message.stringValue.length !== 0) { + writer.uint32(58).bytes(message.stringValue); + } + if (message.aggregateValue !== "") { + writer.uint32(66).string(message.aggregateValue); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): UninterpretedOption { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseUninterpretedOption } as UninterpretedOption; + message.name = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + message.name.push( + UninterpretedOption_NamePart.decode(reader, reader.uint32()) + ); + break; + case 3: + message.identifierValue = reader.string(); + break; + case 4: + message.positiveIntValue = longToNumber(reader.uint64() as Long); + break; + case 5: + message.negativeIntValue = longToNumber(reader.int64() as Long); + break; + case 6: + message.doubleValue = reader.double(); + break; + case 7: + message.stringValue = reader.bytes(); + break; + case 8: + message.aggregateValue = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): UninterpretedOption { + const message = { ...baseUninterpretedOption } as UninterpretedOption; + message.name = []; + if (object.name !== undefined && object.name !== null) { + for (const e of object.name) { + message.name.push(UninterpretedOption_NamePart.fromJSON(e)); + } + } + if ( + object.identifierValue !== undefined && + object.identifierValue !== null + ) { + message.identifierValue = String(object.identifierValue); + } else { + message.identifierValue = ""; + } + if ( + object.positiveIntValue !== undefined && + object.positiveIntValue !== null + ) { + message.positiveIntValue = Number(object.positiveIntValue); + } else { + message.positiveIntValue = 0; + } + if ( + object.negativeIntValue !== undefined && + object.negativeIntValue !== null + ) { + message.negativeIntValue = Number(object.negativeIntValue); + } else { + message.negativeIntValue = 0; + } + if (object.doubleValue !== undefined && object.doubleValue !== null) { + message.doubleValue = Number(object.doubleValue); + } else { + message.doubleValue = 0; + } + if (object.stringValue !== undefined && object.stringValue !== null) { + message.stringValue = bytesFromBase64(object.stringValue); + } + if (object.aggregateValue !== undefined && object.aggregateValue !== null) { + message.aggregateValue = String(object.aggregateValue); + } else { + message.aggregateValue = ""; + } + return message; + }, + + toJSON(message: UninterpretedOption): unknown { + const obj: any = {}; + if (message.name) { + obj.name = message.name.map((e) => + e ? UninterpretedOption_NamePart.toJSON(e) : undefined + ); + } else { + obj.name = []; + } + message.identifierValue !== undefined && + (obj.identifierValue = message.identifierValue); + message.positiveIntValue !== undefined && + (obj.positiveIntValue = message.positiveIntValue); + message.negativeIntValue !== undefined && + (obj.negativeIntValue = message.negativeIntValue); + message.doubleValue !== undefined && + (obj.doubleValue = message.doubleValue); + message.stringValue !== undefined && + (obj.stringValue = base64FromBytes( + message.stringValue !== undefined + ? message.stringValue + : new Uint8Array() + )); + message.aggregateValue !== undefined && + (obj.aggregateValue = message.aggregateValue); + return obj; + }, + + fromPartial(object: DeepPartial): UninterpretedOption { + const message = { ...baseUninterpretedOption } as UninterpretedOption; + message.name = []; + if (object.name !== undefined && object.name !== null) { + for (const e of object.name) { + message.name.push(UninterpretedOption_NamePart.fromPartial(e)); + } + } + if ( + object.identifierValue !== undefined && + object.identifierValue !== null + ) { + message.identifierValue = object.identifierValue; + } else { + message.identifierValue = ""; + } + if ( + object.positiveIntValue !== undefined && + object.positiveIntValue !== null + ) { + message.positiveIntValue = object.positiveIntValue; + } else { + message.positiveIntValue = 0; + } + if ( + object.negativeIntValue !== undefined && + object.negativeIntValue !== null + ) { + message.negativeIntValue = object.negativeIntValue; + } else { + message.negativeIntValue = 0; + } + if (object.doubleValue !== undefined && object.doubleValue !== null) { + message.doubleValue = object.doubleValue; + } else { + message.doubleValue = 0; + } + if (object.stringValue !== undefined && object.stringValue !== null) { + message.stringValue = object.stringValue; + } else { + message.stringValue = new Uint8Array(); + } + if (object.aggregateValue !== undefined && object.aggregateValue !== null) { + message.aggregateValue = object.aggregateValue; + } else { + message.aggregateValue = ""; + } + return message; + }, +}; + +const baseUninterpretedOption_NamePart: object = { + namePart: "", + isExtension: false, +}; + +export const UninterpretedOption_NamePart = { + encode( + message: UninterpretedOption_NamePart, + writer: Writer = Writer.create() + ): Writer { + if (message.namePart !== "") { + writer.uint32(10).string(message.namePart); + } + if (message.isExtension === true) { + writer.uint32(16).bool(message.isExtension); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): UninterpretedOption_NamePart { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseUninterpretedOption_NamePart, + } as UninterpretedOption_NamePart; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.namePart = reader.string(); + break; + case 2: + message.isExtension = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): UninterpretedOption_NamePart { + const message = { + ...baseUninterpretedOption_NamePart, + } as UninterpretedOption_NamePart; + if (object.namePart !== undefined && object.namePart !== null) { + message.namePart = String(object.namePart); + } else { + message.namePart = ""; + } + if (object.isExtension !== undefined && object.isExtension !== null) { + message.isExtension = Boolean(object.isExtension); + } else { + message.isExtension = false; + } + return message; + }, + + toJSON(message: UninterpretedOption_NamePart): unknown { + const obj: any = {}; + message.namePart !== undefined && (obj.namePart = message.namePart); + message.isExtension !== undefined && + (obj.isExtension = message.isExtension); + return obj; + }, + + fromPartial( + object: DeepPartial + ): UninterpretedOption_NamePart { + const message = { + ...baseUninterpretedOption_NamePart, + } as UninterpretedOption_NamePart; + if (object.namePart !== undefined && object.namePart !== null) { + message.namePart = object.namePart; + } else { + message.namePart = ""; + } + if (object.isExtension !== undefined && object.isExtension !== null) { + message.isExtension = object.isExtension; + } else { + message.isExtension = false; + } + return message; + }, +}; + +const baseSourceCodeInfo: object = {}; + +export const SourceCodeInfo = { + encode(message: SourceCodeInfo, writer: Writer = Writer.create()): Writer { + for (const v of message.location) { + SourceCodeInfo_Location.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): SourceCodeInfo { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseSourceCodeInfo } as SourceCodeInfo; + message.location = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.location.push( + SourceCodeInfo_Location.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): SourceCodeInfo { + const message = { ...baseSourceCodeInfo } as SourceCodeInfo; + message.location = []; + if (object.location !== undefined && object.location !== null) { + for (const e of object.location) { + message.location.push(SourceCodeInfo_Location.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: SourceCodeInfo): unknown { + const obj: any = {}; + if (message.location) { + obj.location = message.location.map((e) => + e ? SourceCodeInfo_Location.toJSON(e) : undefined + ); + } else { + obj.location = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): SourceCodeInfo { + const message = { ...baseSourceCodeInfo } as SourceCodeInfo; + message.location = []; + if (object.location !== undefined && object.location !== null) { + for (const e of object.location) { + message.location.push(SourceCodeInfo_Location.fromPartial(e)); + } + } + return message; + }, +}; + +const baseSourceCodeInfo_Location: object = { + path: 0, + span: 0, + leadingComments: "", + trailingComments: "", + leadingDetachedComments: "", +}; + +export const SourceCodeInfo_Location = { + encode( + message: SourceCodeInfo_Location, + writer: Writer = Writer.create() + ): Writer { + writer.uint32(10).fork(); + for (const v of message.path) { + writer.int32(v); + } + writer.ldelim(); + writer.uint32(18).fork(); + for (const v of message.span) { + writer.int32(v); + } + writer.ldelim(); + if (message.leadingComments !== "") { + writer.uint32(26).string(message.leadingComments); + } + if (message.trailingComments !== "") { + writer.uint32(34).string(message.trailingComments); + } + for (const v of message.leadingDetachedComments) { + writer.uint32(50).string(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): SourceCodeInfo_Location { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseSourceCodeInfo_Location, + } as SourceCodeInfo_Location; + message.path = []; + message.span = []; + message.leadingDetachedComments = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.path.push(reader.int32()); + } + } else { + message.path.push(reader.int32()); + } + break; + case 2: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.span.push(reader.int32()); + } + } else { + message.span.push(reader.int32()); + } + break; + case 3: + message.leadingComments = reader.string(); + break; + case 4: + message.trailingComments = reader.string(); + break; + case 6: + message.leadingDetachedComments.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): SourceCodeInfo_Location { + const message = { + ...baseSourceCodeInfo_Location, + } as SourceCodeInfo_Location; + message.path = []; + message.span = []; + message.leadingDetachedComments = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(Number(e)); + } + } + if (object.span !== undefined && object.span !== null) { + for (const e of object.span) { + message.span.push(Number(e)); + } + } + if ( + object.leadingComments !== undefined && + object.leadingComments !== null + ) { + message.leadingComments = String(object.leadingComments); + } else { + message.leadingComments = ""; + } + if ( + object.trailingComments !== undefined && + object.trailingComments !== null + ) { + message.trailingComments = String(object.trailingComments); + } else { + message.trailingComments = ""; + } + if ( + object.leadingDetachedComments !== undefined && + object.leadingDetachedComments !== null + ) { + for (const e of object.leadingDetachedComments) { + message.leadingDetachedComments.push(String(e)); + } + } + return message; + }, + + toJSON(message: SourceCodeInfo_Location): unknown { + const obj: any = {}; + if (message.path) { + obj.path = message.path.map((e) => e); + } else { + obj.path = []; + } + if (message.span) { + obj.span = message.span.map((e) => e); + } else { + obj.span = []; + } + message.leadingComments !== undefined && + (obj.leadingComments = message.leadingComments); + message.trailingComments !== undefined && + (obj.trailingComments = message.trailingComments); + if (message.leadingDetachedComments) { + obj.leadingDetachedComments = message.leadingDetachedComments.map( + (e) => e + ); + } else { + obj.leadingDetachedComments = []; + } + return obj; + }, + + fromPartial( + object: DeepPartial + ): SourceCodeInfo_Location { + const message = { + ...baseSourceCodeInfo_Location, + } as SourceCodeInfo_Location; + message.path = []; + message.span = []; + message.leadingDetachedComments = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(e); + } + } + if (object.span !== undefined && object.span !== null) { + for (const e of object.span) { + message.span.push(e); + } + } + if ( + object.leadingComments !== undefined && + object.leadingComments !== null + ) { + message.leadingComments = object.leadingComments; + } else { + message.leadingComments = ""; + } + if ( + object.trailingComments !== undefined && + object.trailingComments !== null + ) { + message.trailingComments = object.trailingComments; + } else { + message.trailingComments = ""; + } + if ( + object.leadingDetachedComments !== undefined && + object.leadingDetachedComments !== null + ) { + for (const e of object.leadingDetachedComments) { + message.leadingDetachedComments.push(e); + } + } + return message; + }, +}; + +const baseGeneratedCodeInfo: object = {}; + +export const GeneratedCodeInfo = { + encode(message: GeneratedCodeInfo, writer: Writer = Writer.create()): Writer { + for (const v of message.annotation) { + GeneratedCodeInfo_Annotation.encode( + v!, + writer.uint32(10).fork() + ).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): GeneratedCodeInfo { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseGeneratedCodeInfo } as GeneratedCodeInfo; + message.annotation = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.annotation.push( + GeneratedCodeInfo_Annotation.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GeneratedCodeInfo { + const message = { ...baseGeneratedCodeInfo } as GeneratedCodeInfo; + message.annotation = []; + if (object.annotation !== undefined && object.annotation !== null) { + for (const e of object.annotation) { + message.annotation.push(GeneratedCodeInfo_Annotation.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: GeneratedCodeInfo): unknown { + const obj: any = {}; + if (message.annotation) { + obj.annotation = message.annotation.map((e) => + e ? GeneratedCodeInfo_Annotation.toJSON(e) : undefined + ); + } else { + obj.annotation = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): GeneratedCodeInfo { + const message = { ...baseGeneratedCodeInfo } as GeneratedCodeInfo; + message.annotation = []; + if (object.annotation !== undefined && object.annotation !== null) { + for (const e of object.annotation) { + message.annotation.push(GeneratedCodeInfo_Annotation.fromPartial(e)); + } + } + return message; + }, +}; + +const baseGeneratedCodeInfo_Annotation: object = { + path: 0, + sourceFile: "", + begin: 0, + end: 0, +}; + +export const GeneratedCodeInfo_Annotation = { + encode( + message: GeneratedCodeInfo_Annotation, + writer: Writer = Writer.create() + ): Writer { + writer.uint32(10).fork(); + for (const v of message.path) { + writer.int32(v); + } + writer.ldelim(); + if (message.sourceFile !== "") { + writer.uint32(18).string(message.sourceFile); + } + if (message.begin !== 0) { + writer.uint32(24).int32(message.begin); + } + if (message.end !== 0) { + writer.uint32(32).int32(message.end); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): GeneratedCodeInfo_Annotation { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseGeneratedCodeInfo_Annotation, + } as GeneratedCodeInfo_Annotation; + message.path = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.path.push(reader.int32()); + } + } else { + message.path.push(reader.int32()); + } + break; + case 2: + message.sourceFile = reader.string(); + break; + case 3: + message.begin = reader.int32(); + break; + case 4: + message.end = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GeneratedCodeInfo_Annotation { + const message = { + ...baseGeneratedCodeInfo_Annotation, + } as GeneratedCodeInfo_Annotation; + message.path = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(Number(e)); + } + } + if (object.sourceFile !== undefined && object.sourceFile !== null) { + message.sourceFile = String(object.sourceFile); + } else { + message.sourceFile = ""; + } + if (object.begin !== undefined && object.begin !== null) { + message.begin = Number(object.begin); + } else { + message.begin = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + return message; + }, + + toJSON(message: GeneratedCodeInfo_Annotation): unknown { + const obj: any = {}; + if (message.path) { + obj.path = message.path.map((e) => e); + } else { + obj.path = []; + } + message.sourceFile !== undefined && (obj.sourceFile = message.sourceFile); + message.begin !== undefined && (obj.begin = message.begin); + message.end !== undefined && (obj.end = message.end); + return obj; + }, + + fromPartial( + object: DeepPartial + ): GeneratedCodeInfo_Annotation { + const message = { + ...baseGeneratedCodeInfo_Annotation, + } as GeneratedCodeInfo_Annotation; + message.path = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(e); + } + } + if (object.sourceFile !== undefined && object.sourceFile !== null) { + message.sourceFile = object.sourceFile; + } else { + message.sourceFile = ""; + } + if (object.begin !== undefined && object.begin !== null) { + message.begin = object.begin; + } else { + message.begin = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/ibc.applications.interchain_accounts.host.v1/types/ibc/applications/interchain_accounts/host/v1/host.ts b/ts-client/ibc.applications.interchain_accounts.host.v1/types/ibc/applications/interchain_accounts/host/v1/host.ts new file mode 100644 index 00000000..3266f1a6 --- /dev/null +++ b/ts-client/ibc.applications.interchain_accounts.host.v1/types/ibc/applications/interchain_accounts/host/v1/host.ts @@ -0,0 +1,106 @@ +/* eslint-disable */ +import { Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "ibc.applications.interchain_accounts.host.v1"; + +/** + * Params defines the set of on-chain interchain accounts parameters. + * The following parameters may be used to disable the host submodule. + */ +export interface Params { + /** host_enabled enables or disables the host submodule. */ + hostEnabled: boolean; + /** allow_messages defines a list of sdk message typeURLs allowed to be executed on a host chain. */ + allowMessages: string[]; +} + +const baseParams: object = { hostEnabled: false, allowMessages: "" }; + +export const Params = { + encode(message: Params, writer: Writer = Writer.create()): Writer { + if (message.hostEnabled === true) { + writer.uint32(8).bool(message.hostEnabled); + } + for (const v of message.allowMessages) { + writer.uint32(18).string(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Params { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseParams } as Params; + message.allowMessages = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.hostEnabled = reader.bool(); + break; + case 2: + message.allowMessages.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Params { + const message = { ...baseParams } as Params; + message.allowMessages = []; + if (object.hostEnabled !== undefined && object.hostEnabled !== null) { + message.hostEnabled = Boolean(object.hostEnabled); + } else { + message.hostEnabled = false; + } + if (object.allowMessages !== undefined && object.allowMessages !== null) { + for (const e of object.allowMessages) { + message.allowMessages.push(String(e)); + } + } + return message; + }, + + toJSON(message: Params): unknown { + const obj: any = {}; + message.hostEnabled !== undefined && + (obj.hostEnabled = message.hostEnabled); + if (message.allowMessages) { + obj.allowMessages = message.allowMessages.map((e) => e); + } else { + obj.allowMessages = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): Params { + const message = { ...baseParams } as Params; + message.allowMessages = []; + if (object.hostEnabled !== undefined && object.hostEnabled !== null) { + message.hostEnabled = object.hostEnabled; + } else { + message.hostEnabled = false; + } + if (object.allowMessages !== undefined && object.allowMessages !== null) { + for (const e of object.allowMessages) { + message.allowMessages.push(e); + } + } + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/ibc.applications.interchain_accounts.host.v1/types/ibc/applications/interchain_accounts/host/v1/query.ts b/ts-client/ibc.applications.interchain_accounts.host.v1/types/ibc/applications/interchain_accounts/host/v1/query.ts new file mode 100644 index 00000000..0b8bfc98 --- /dev/null +++ b/ts-client/ibc.applications.interchain_accounts.host.v1/types/ibc/applications/interchain_accounts/host/v1/query.ts @@ -0,0 +1,152 @@ +/* eslint-disable */ +import { Reader, Writer } from "protobufjs/minimal"; +import { Params } from "../../../../../ibc/applications/interchain_accounts/host/v1/host"; + +export const protobufPackage = "ibc.applications.interchain_accounts.host.v1"; + +/** QueryParamsRequest is the request type for the Query/Params RPC method. */ +export interface QueryParamsRequest {} + +/** QueryParamsResponse is the response type for the Query/Params RPC method. */ +export interface QueryParamsResponse { + /** params defines the parameters of the module. */ + params: Params | undefined; +} + +const baseQueryParamsRequest: object = {}; + +export const QueryParamsRequest = { + encode(_: QueryParamsRequest, writer: Writer = Writer.create()): Writer { + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QueryParamsRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryParamsRequest } as QueryParamsRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): QueryParamsRequest { + const message = { ...baseQueryParamsRequest } as QueryParamsRequest; + return message; + }, + + toJSON(_: QueryParamsRequest): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial(_: DeepPartial): QueryParamsRequest { + const message = { ...baseQueryParamsRequest } as QueryParamsRequest; + return message; + }, +}; + +const baseQueryParamsResponse: object = {}; + +export const QueryParamsResponse = { + encode( + message: QueryParamsResponse, + writer: Writer = Writer.create() + ): Writer { + if (message.params !== undefined) { + Params.encode(message.params, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QueryParamsResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryParamsResponse } as QueryParamsResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.params = Params.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryParamsResponse { + const message = { ...baseQueryParamsResponse } as QueryParamsResponse; + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromJSON(object.params); + } else { + message.params = undefined; + } + return message; + }, + + toJSON(message: QueryParamsResponse): unknown { + const obj: any = {}; + message.params !== undefined && + (obj.params = message.params ? Params.toJSON(message.params) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): QueryParamsResponse { + const message = { ...baseQueryParamsResponse } as QueryParamsResponse; + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromPartial(object.params); + } else { + message.params = undefined; + } + return message; + }, +}; + +/** Query provides defines the gRPC querier service. */ +export interface Query { + /** Params queries all parameters of the ICA host submodule. */ + Params(request: QueryParamsRequest): Promise; +} + +export class QueryClientImpl implements Query { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + } + Params(request: QueryParamsRequest): Promise { + const data = QueryParamsRequest.encode(request).finish(); + const promise = this.rpc.request( + "ibc.applications.interchain_accounts.host.v1.Query", + "Params", + data + ); + return promise.then((data) => QueryParamsResponse.decode(new Reader(data))); + } +} + +interface Rpc { + request( + service: string, + method: string, + data: Uint8Array + ): Promise; +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/ibc.applications.transfer.v1/index.ts b/ts-client/ibc.applications.transfer.v1/index.ts new file mode 100755 index 00000000..c9dfa159 --- /dev/null +++ b/ts-client/ibc.applications.transfer.v1/index.ts @@ -0,0 +1,6 @@ +import Module from './module'; +import { txClient, queryClient, registry } from './module'; +import { msgTypes } from './registry'; + +export * from "./types"; +export { Module, msgTypes, txClient, queryClient, registry }; diff --git a/ts-client/ibc.applications.transfer.v1/module.ts b/ts-client/ibc.applications.transfer.v1/module.ts new file mode 100755 index 00000000..0f2d9c34 --- /dev/null +++ b/ts-client/ibc.applications.transfer.v1/module.ts @@ -0,0 +1,99 @@ +// Generated by Ignite ignite.com/cli + +import { StdFee } from "@cosmjs/launchpad"; +import { SigningStargateClient, DeliverTxResponse } from "@cosmjs/stargate"; +import { EncodeObject, GeneratedType, OfflineSigner, Registry } from "@cosmjs/proto-signing"; +import { msgTypes } from './registry'; +import { IgniteClient } from "../client" +import { MissingWalletError } from "../helpers" +import { Api } from "./rest"; +import { MsgTransfer } from "./types/ibc/applications/transfer/v1/tx"; + + +export { MsgTransfer }; + +type sendMsgTransferParams = { + value: MsgTransfer, + fee?: StdFee, + memo?: string +}; + + +type msgTransferParams = { + value: MsgTransfer, +}; + + +export const registry = new Registry(msgTypes); + +const defaultFee = { + amount: [], + gas: "200000", +}; + +interface TxClientOptions { + addr: string + prefix: string + signer?: OfflineSigner +} + +export const txClient = ({ signer, prefix, addr }: TxClientOptions = { addr: "http://localhost:26657", prefix: "cosmos" }) => { + + return { + + async sendMsgTransfer({ value, fee, memo }: sendMsgTransferParams): Promise { + if (!signer) { + throw new Error('TxClient:sendMsgTransfer: Unable to sign Tx. Signer is not present.') + } + try { + const { address } = (await signer.getAccounts())[0]; + const signingClient = await SigningStargateClient.connectWithSigner(addr,signer,{registry, prefix}); + let msg = this.msgTransfer({ value: MsgTransfer.fromPartial(value) }) + return await signingClient.signAndBroadcast(address, [msg], fee ? fee : defaultFee, memo) + } catch (e: any) { + throw new Error('TxClient:sendMsgTransfer: Could not broadcast Tx: '+ e.message) + } + }, + + + msgTransfer({ value }: msgTransferParams): EncodeObject { + try { + return { typeUrl: "/ibc.applications.transfer.v1.MsgTransfer", value: MsgTransfer.fromPartial( value ) } + } catch (e: any) { + throw new Error('TxClient:MsgTransfer: Could not create message: ' + e.message) + } + }, + + } +}; + +interface QueryClientOptions { + addr: string +} + +export const queryClient = ({ addr: addr }: QueryClientOptions = { addr: "http://localhost:1317" }) => { + return new Api({ baseUrl: addr }); +}; + +class SDKModule { + public query: ReturnType; + public tx: ReturnType; + + public registry: Array<[string, GeneratedType]>; + + constructor(client: IgniteClient) { + + this.query = queryClient({ addr: client.env.apiURL }); + this.tx = txClient({ signer: client.signer, addr: client.env.rpcURL, prefix: client.env.prefix ?? "cosmos" }); + } +}; + +const Module = (test: IgniteClient) => { + return { + module: { + IbcApplicationsTransferV1: new SDKModule(test) + }, + registry: msgTypes + } +} +export default Module; \ No newline at end of file diff --git a/ts-client/ibc.applications.transfer.v1/registry.ts b/ts-client/ibc.applications.transfer.v1/registry.ts new file mode 100755 index 00000000..727fde23 --- /dev/null +++ b/ts-client/ibc.applications.transfer.v1/registry.ts @@ -0,0 +1,9 @@ +import { GeneratedType } from "@cosmjs/proto-signing"; +import { MsgTransfer } from "./types/ibc/applications/transfer/v1/tx"; + +const msgTypes: Array<[string, GeneratedType]> = [ + ["/ibc.applications.transfer.v1.MsgTransfer", MsgTransfer], + +]; + +export { msgTypes } \ No newline at end of file diff --git a/ts-client/ibc.applications.transfer.v1/rest.ts b/ts-client/ibc.applications.transfer.v1/rest.ts new file mode 100644 index 00000000..d399915d --- /dev/null +++ b/ts-client/ibc.applications.transfer.v1/rest.ts @@ -0,0 +1,599 @@ +/* eslint-disable */ +/* tslint:disable */ +/* + * --------------------------------------------------------------- + * ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ## + * ## ## + * ## AUTHOR: acacode ## + * ## SOURCE: https://github.com/acacode/swagger-typescript-api ## + * --------------------------------------------------------------- + */ + +/** +* Params defines the set of IBC transfer parameters. +NOTE: To prevent a single token from being transferred, set the +TransfersEnabled parameter to true and then set the bank module's SendEnabled +parameter for the denomination to false. +*/ +export interface Applicationstransferv1Params { + /** + * send_enabled enables or disables all cross-chain token transfers from this + * chain. + */ + send_enabled?: boolean; + + /** + * receive_enabled enables or disables all cross-chain token transfers to this + * chain. + */ + receive_enabled?: boolean; +} + +/** +* `Any` contains an arbitrary serialized protocol buffer message along with a +URL that describes the type of the serialized message. + +Protobuf library provides support to pack/unpack Any values in the form +of utility functions or additional generated methods of the Any type. + +Example 1: Pack and unpack a message in C++. + + Foo foo = ...; + Any any; + any.PackFrom(foo); + ... + if (any.UnpackTo(&foo)) { + ... + } + +Example 2: Pack and unpack a message in Java. + + Foo foo = ...; + Any any = Any.pack(foo); + ... + if (any.is(Foo.class)) { + foo = any.unpack(Foo.class); + } + + Example 3: Pack and unpack a message in Python. + + foo = Foo(...) + any = Any() + any.Pack(foo) + ... + if any.Is(Foo.DESCRIPTOR): + any.Unpack(foo) + ... + + Example 4: Pack and unpack a message in Go + + foo := &pb.Foo{...} + any, err := anypb.New(foo) + if err != nil { + ... + } + ... + foo := &pb.Foo{} + if err := any.UnmarshalTo(foo); err != nil { + ... + } + +The pack methods provided by protobuf library will by default use +'type.googleapis.com/full.type.name' as the type URL and the unpack +methods only use the fully qualified type name after the last '/' +in the type URL, for example "foo.bar.com/x/y.z" will yield type +name "y.z". + + +JSON +==== +The JSON representation of an `Any` value uses the regular +representation of the deserialized, embedded message, with an +additional field `@type` which contains the type URL. Example: + + package google.profile; + message Person { + string first_name = 1; + string last_name = 2; + } + + { + "@type": "type.googleapis.com/google.profile.Person", + "firstName": , + "lastName": + } + +If the embedded message type is well-known and has a custom JSON +representation, that representation will be embedded adding a field +`value` which holds the custom JSON in addition to the `@type` +field. Example (for message [google.protobuf.Duration][]): + + { + "@type": "type.googleapis.com/google.protobuf.Duration", + "value": "1.212s" + } +*/ +export interface ProtobufAny { + /** + * A URL/resource name that uniquely identifies the type of the serialized + * protocol buffer message. This string must contain at least + * one "/" character. The last segment of the URL's path must represent + * the fully qualified name of the type (as in + * `path/google.protobuf.Duration`). The name should be in a canonical form + * (e.g., leading "." is not accepted). + * + * In practice, teams usually precompile into the binary all types that they + * expect it to use in the context of Any. However, for URLs which use the + * scheme `http`, `https`, or no scheme, one can optionally set up a type + * server that maps type URLs to message definitions as follows: + * + * * If no scheme is provided, `https` is assumed. + * * An HTTP GET on the URL must yield a [google.protobuf.Type][] + * value in binary format, or produce an error. + * * Applications are allowed to cache lookup results based on the + * URL, or have them precompiled into a binary to avoid any + * lookup. Therefore, binary compatibility needs to be preserved + * on changes to types. (Use versioned type names to manage + * breaking changes.) + * + * Note: this functionality is not currently available in the official + * protobuf release, and it is not used for type URLs beginning with + * type.googleapis.com. + * + * Schemes other than `http`, `https` (or the empty scheme) might be + * used with implementation specific semantics. + */ + "@type"?: string; +} + +export interface RpcStatus { + /** @format int32 */ + code?: number; + message?: string; + details?: ProtobufAny[]; +} + +/** +* DenomTrace contains the base denomination for ICS20 fungible tokens and the +source tracing information path. +*/ +export interface Transferv1DenomTrace { + /** + * path defines the chain of port/channel identifiers used for tracing the + * source of the fungible token. + */ + path?: string; + + /** base denomination of the relayed fungible token. */ + base_denom?: string; +} + +/** +* Normally the RevisionHeight is incremented at each height while keeping +RevisionNumber the same. However some consensus algorithms may choose to +reset the height in certain conditions e.g. hard forks, state-machine +breaking changes In these cases, the RevisionNumber is incremented so that +height continues to be monitonically increasing even as the RevisionHeight +gets reset +*/ +export interface V1Height { + /** @format uint64 */ + revision_number?: string; + + /** @format uint64 */ + revision_height?: string; +} + +/** + * MsgTransferResponse defines the Msg/Transfer response type. + */ +export interface V1MsgTransferResponse { + /** @format uint64 */ + sequence?: string; +} + +/** +* QueryDenomHashResponse is the response type for the Query/DenomHash RPC +method. +*/ +export interface V1QueryDenomHashResponse { + /** hash (in hex format) of the denomination trace information. */ + hash?: string; +} + +/** +* QueryDenomTraceResponse is the response type for the Query/DenomTrace RPC +method. +*/ +export interface V1QueryDenomTraceResponse { + /** denom_trace returns the requested denomination trace information. */ + denom_trace?: Transferv1DenomTrace; +} + +/** +* QueryConnectionsResponse is the response type for the Query/DenomTraces RPC +method. +*/ +export interface V1QueryDenomTracesResponse { + /** denom_traces returns all denominations trace information. */ + denom_traces?: Transferv1DenomTrace[]; + + /** pagination defines the pagination in the response. */ + pagination?: V1Beta1PageResponse; +} + +/** + * QueryEscrowAddressResponse is the response type of the EscrowAddress RPC method. + */ +export interface V1QueryEscrowAddressResponse { + escrow_address?: string; +} + +/** + * QueryParamsResponse is the response type for the Query/Params RPC method. + */ +export interface V1QueryParamsResponse { + /** params defines the parameters of the module. */ + params?: Applicationstransferv1Params; +} + +/** +* Coin defines a token with a denomination and an amount. + +NOTE: The amount field is an Int which implements the custom method +signatures required by gogoproto. +*/ +export interface V1Beta1Coin { + denom?: string; + amount?: string; +} + +/** +* message SomeRequest { + Foo some_parameter = 1; + PageRequest pagination = 2; + } +*/ +export interface V1Beta1PageRequest { + /** + * key is a value returned in PageResponse.next_key to begin + * querying the next page most efficiently. Only one of offset or key + * should be set. + * @format byte + */ + key?: string; + + /** + * offset is a numeric offset that can be used when key is unavailable. + * It is less efficient than using key. Only one of offset or key should + * be set. + * @format uint64 + */ + offset?: string; + + /** + * limit is the total number of results to be returned in the result page. + * If left empty it will default to a value to be set by each app. + * @format uint64 + */ + limit?: string; + + /** + * count_total is set to true to indicate that the result set should include + * a count of the total number of items available for pagination in UIs. + * count_total is only respected when offset is used. It is ignored when key + * is set. + */ + count_total?: boolean; + + /** + * reverse is set to true if results are to be returned in the descending order. + * + * Since: cosmos-sdk 0.43 + */ + reverse?: boolean; +} + +/** +* PageResponse is to be embedded in gRPC response messages where the +corresponding request message has used PageRequest. + + message SomeResponse { + repeated Bar results = 1; + PageResponse page = 2; + } +*/ +export interface V1Beta1PageResponse { + /** @format byte */ + next_key?: string; + + /** @format uint64 */ + total?: string; +} + +export type QueryParamsType = Record; +export type ResponseFormat = keyof Omit; + +export interface FullRequestParams extends Omit { + /** set parameter to `true` for call `securityWorker` for this request */ + secure?: boolean; + /** request path */ + path: string; + /** content type of request body */ + type?: ContentType; + /** query params */ + query?: QueryParamsType; + /** format of response (i.e. response.json() -> format: "json") */ + format?: keyof Omit; + /** request body */ + body?: unknown; + /** base url */ + baseUrl?: string; + /** request cancellation token */ + cancelToken?: CancelToken; +} + +export type RequestParams = Omit; + +export interface ApiConfig { + baseUrl?: string; + baseApiParams?: Omit; + securityWorker?: (securityData: SecurityDataType) => RequestParams | void; +} + +export interface HttpResponse extends Response { + data: D; + error: E; +} + +type CancelToken = Symbol | string | number; + +export enum ContentType { + Json = "application/json", + FormData = "multipart/form-data", + UrlEncoded = "application/x-www-form-urlencoded", +} + +export class HttpClient { + public baseUrl: string = ""; + private securityData: SecurityDataType = null as any; + private securityWorker: null | ApiConfig["securityWorker"] = null; + private abortControllers = new Map(); + + private baseApiParams: RequestParams = { + credentials: "same-origin", + headers: {}, + redirect: "follow", + referrerPolicy: "no-referrer", + }; + + constructor(apiConfig: ApiConfig = {}) { + Object.assign(this, apiConfig); + } + + public setSecurityData = (data: SecurityDataType) => { + this.securityData = data; + }; + + private addQueryParam(query: QueryParamsType, key: string) { + const value = query[key]; + + return ( + encodeURIComponent(key) + + "=" + + encodeURIComponent(Array.isArray(value) ? value.join(",") : typeof value === "number" ? value : `${value}`) + ); + } + + protected toQueryString(rawQuery?: QueryParamsType): string { + const query = rawQuery || {}; + const keys = Object.keys(query).filter((key) => "undefined" !== typeof query[key]); + return keys + .map((key) => + typeof query[key] === "object" && !Array.isArray(query[key]) + ? this.toQueryString(query[key] as QueryParamsType) + : this.addQueryParam(query, key), + ) + .join("&"); + } + + protected addQueryParams(rawQuery?: QueryParamsType): string { + const queryString = this.toQueryString(rawQuery); + return queryString ? `?${queryString}` : ""; + } + + private contentFormatters: Record any> = { + [ContentType.Json]: (input: any) => + input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input, + [ContentType.FormData]: (input: any) => + Object.keys(input || {}).reduce((data, key) => { + data.append(key, input[key]); + return data; + }, new FormData()), + [ContentType.UrlEncoded]: (input: any) => this.toQueryString(input), + }; + + private mergeRequestParams(params1: RequestParams, params2?: RequestParams): RequestParams { + return { + ...this.baseApiParams, + ...params1, + ...(params2 || {}), + headers: { + ...(this.baseApiParams.headers || {}), + ...(params1.headers || {}), + ...((params2 && params2.headers) || {}), + }, + }; + } + + private createAbortSignal = (cancelToken: CancelToken): AbortSignal | undefined => { + if (this.abortControllers.has(cancelToken)) { + const abortController = this.abortControllers.get(cancelToken); + if (abortController) { + return abortController.signal; + } + return void 0; + } + + const abortController = new AbortController(); + this.abortControllers.set(cancelToken, abortController); + return abortController.signal; + }; + + public abortRequest = (cancelToken: CancelToken) => { + const abortController = this.abortControllers.get(cancelToken); + + if (abortController) { + abortController.abort(); + this.abortControllers.delete(cancelToken); + } + }; + + public request = ({ + body, + secure, + path, + type, + query, + format = "json", + baseUrl, + cancelToken, + ...params + }: FullRequestParams): Promise> => { + const secureParams = (secure && this.securityWorker && this.securityWorker(this.securityData)) || {}; + const requestParams = this.mergeRequestParams(params, secureParams); + const queryString = query && this.toQueryString(query); + const payloadFormatter = this.contentFormatters[type || ContentType.Json]; + + return fetch(`${baseUrl || this.baseUrl || ""}${path}${queryString ? `?${queryString}` : ""}`, { + ...requestParams, + headers: { + ...(type && type !== ContentType.FormData ? { "Content-Type": type } : {}), + ...(requestParams.headers || {}), + }, + signal: cancelToken ? this.createAbortSignal(cancelToken) : void 0, + body: typeof body === "undefined" || body === null ? null : payloadFormatter(body), + }).then(async (response) => { + const r = response as HttpResponse; + r.data = (null as unknown) as T; + r.error = (null as unknown) as E; + + const data = await response[format]() + .then((data) => { + if (r.ok) { + r.data = data; + } else { + r.error = data; + } + return r; + }) + .catch((e) => { + r.error = e; + return r; + }); + + if (cancelToken) { + this.abortControllers.delete(cancelToken); + } + + if (!response.ok) throw data; + return data; + }); + }; +} + +/** + * @title ibc/applications/transfer/v1/genesis.proto + * @version version not set + */ +export class Api extends HttpClient { + /** + * No description + * + * @tags Query + * @name QueryEscrowAddress + * @summary EscrowAddress returns the escrow address for a particular port and channel id. + * @request GET:/ibc/apps/transfer/v1/channels/{channel_id}/ports/{port_id}/escrow_address + */ + queryEscrowAddress = (channel_id: string, port_id: string, params: RequestParams = {}) => + this.request({ + path: `/ibc/apps/transfer/v1/channels/${channel_id}/ports/${port_id}/escrow_address`, + method: "GET", + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Query + * @name QueryDenomHash + * @summary DenomHash queries a denomination hash information. + * @request GET:/ibc/apps/transfer/v1/denom_hashes/{trace} + */ + queryDenomHash = (trace: string, params: RequestParams = {}) => + this.request({ + path: `/ibc/apps/transfer/v1/denom_hashes/${trace}`, + method: "GET", + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Query + * @name QueryDenomTraces + * @summary DenomTraces queries all denomination traces. + * @request GET:/ibc/apps/transfer/v1/denom_traces + */ + queryDenomTraces = ( + query?: { + "pagination.key"?: string; + "pagination.offset"?: string; + "pagination.limit"?: string; + "pagination.count_total"?: boolean; + "pagination.reverse"?: boolean; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/ibc/apps/transfer/v1/denom_traces`, + method: "GET", + query: query, + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Query + * @name QueryDenomTrace + * @summary DenomTrace queries a denomination trace information. + * @request GET:/ibc/apps/transfer/v1/denom_traces/{hash} + */ + queryDenomTrace = (hash: string, params: RequestParams = {}) => + this.request({ + path: `/ibc/apps/transfer/v1/denom_traces/${hash}`, + method: "GET", + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Query + * @name QueryParams + * @summary Params queries all parameters of the ibc-transfer module. + * @request GET:/ibc/apps/transfer/v1/params + */ + queryParams = (params: RequestParams = {}) => + this.request({ + path: `/ibc/apps/transfer/v1/params`, + method: "GET", + format: "json", + ...params, + }); +} diff --git a/ts-client/ibc.applications.transfer.v1/types.ts b/ts-client/ibc.applications.transfer.v1/types.ts new file mode 100755 index 00000000..c565a7f6 --- /dev/null +++ b/ts-client/ibc.applications.transfer.v1/types.ts @@ -0,0 +1,9 @@ +import { DenomTrace } from "./types/ibc/applications/transfer/v1/transfer" +import { Params } from "./types/ibc/applications/transfer/v1/transfer" + + +export { + DenomTrace, + Params, + + } \ No newline at end of file diff --git a/ts-client/ibc.applications.transfer.v1/types/cosmos/base/query/v1beta1/pagination.ts b/ts-client/ibc.applications.transfer.v1/types/cosmos/base/query/v1beta1/pagination.ts new file mode 100644 index 00000000..cd4b2d78 --- /dev/null +++ b/ts-client/ibc.applications.transfer.v1/types/cosmos/base/query/v1beta1/pagination.ts @@ -0,0 +1,327 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "cosmos.base.query.v1beta1"; + +/** + * PageRequest is to be embedded in gRPC request messages for efficient + * pagination. Ex: + * + * message SomeRequest { + * Foo some_parameter = 1; + * PageRequest pagination = 2; + * } + */ +export interface PageRequest { + /** + * key is a value returned in PageResponse.next_key to begin + * querying the next page most efficiently. Only one of offset or key + * should be set. + */ + key: Uint8Array; + /** + * offset is a numeric offset that can be used when key is unavailable. + * It is less efficient than using key. Only one of offset or key should + * be set. + */ + offset: number; + /** + * limit is the total number of results to be returned in the result page. + * If left empty it will default to a value to be set by each app. + */ + limit: number; + /** + * count_total is set to true to indicate that the result set should include + * a count of the total number of items available for pagination in UIs. + * count_total is only respected when offset is used. It is ignored when key + * is set. + */ + countTotal: boolean; + /** + * reverse is set to true if results are to be returned in the descending order. + * + * Since: cosmos-sdk 0.43 + */ + reverse: boolean; +} + +/** + * PageResponse is to be embedded in gRPC response messages where the + * corresponding request message has used PageRequest. + * + * message SomeResponse { + * repeated Bar results = 1; + * PageResponse page = 2; + * } + */ +export interface PageResponse { + /** + * next_key is the key to be passed to PageRequest.key to + * query the next page most efficiently + */ + nextKey: Uint8Array; + /** + * total is total number of results available if PageRequest.count_total + * was set, its value is undefined otherwise + */ + total: number; +} + +const basePageRequest: object = { + offset: 0, + limit: 0, + countTotal: false, + reverse: false, +}; + +export const PageRequest = { + encode(message: PageRequest, writer: Writer = Writer.create()): Writer { + if (message.key.length !== 0) { + writer.uint32(10).bytes(message.key); + } + if (message.offset !== 0) { + writer.uint32(16).uint64(message.offset); + } + if (message.limit !== 0) { + writer.uint32(24).uint64(message.limit); + } + if (message.countTotal === true) { + writer.uint32(32).bool(message.countTotal); + } + if (message.reverse === true) { + writer.uint32(40).bool(message.reverse); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): PageRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...basePageRequest } as PageRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.key = reader.bytes(); + break; + case 2: + message.offset = longToNumber(reader.uint64() as Long); + break; + case 3: + message.limit = longToNumber(reader.uint64() as Long); + break; + case 4: + message.countTotal = reader.bool(); + break; + case 5: + message.reverse = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): PageRequest { + const message = { ...basePageRequest } as PageRequest; + if (object.key !== undefined && object.key !== null) { + message.key = bytesFromBase64(object.key); + } + if (object.offset !== undefined && object.offset !== null) { + message.offset = Number(object.offset); + } else { + message.offset = 0; + } + if (object.limit !== undefined && object.limit !== null) { + message.limit = Number(object.limit); + } else { + message.limit = 0; + } + if (object.countTotal !== undefined && object.countTotal !== null) { + message.countTotal = Boolean(object.countTotal); + } else { + message.countTotal = false; + } + if (object.reverse !== undefined && object.reverse !== null) { + message.reverse = Boolean(object.reverse); + } else { + message.reverse = false; + } + return message; + }, + + toJSON(message: PageRequest): unknown { + const obj: any = {}; + message.key !== undefined && + (obj.key = base64FromBytes( + message.key !== undefined ? message.key : new Uint8Array() + )); + message.offset !== undefined && (obj.offset = message.offset); + message.limit !== undefined && (obj.limit = message.limit); + message.countTotal !== undefined && (obj.countTotal = message.countTotal); + message.reverse !== undefined && (obj.reverse = message.reverse); + return obj; + }, + + fromPartial(object: DeepPartial): PageRequest { + const message = { ...basePageRequest } as PageRequest; + if (object.key !== undefined && object.key !== null) { + message.key = object.key; + } else { + message.key = new Uint8Array(); + } + if (object.offset !== undefined && object.offset !== null) { + message.offset = object.offset; + } else { + message.offset = 0; + } + if (object.limit !== undefined && object.limit !== null) { + message.limit = object.limit; + } else { + message.limit = 0; + } + if (object.countTotal !== undefined && object.countTotal !== null) { + message.countTotal = object.countTotal; + } else { + message.countTotal = false; + } + if (object.reverse !== undefined && object.reverse !== null) { + message.reverse = object.reverse; + } else { + message.reverse = false; + } + return message; + }, +}; + +const basePageResponse: object = { total: 0 }; + +export const PageResponse = { + encode(message: PageResponse, writer: Writer = Writer.create()): Writer { + if (message.nextKey.length !== 0) { + writer.uint32(10).bytes(message.nextKey); + } + if (message.total !== 0) { + writer.uint32(16).uint64(message.total); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): PageResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...basePageResponse } as PageResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.nextKey = reader.bytes(); + break; + case 2: + message.total = longToNumber(reader.uint64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): PageResponse { + const message = { ...basePageResponse } as PageResponse; + if (object.nextKey !== undefined && object.nextKey !== null) { + message.nextKey = bytesFromBase64(object.nextKey); + } + if (object.total !== undefined && object.total !== null) { + message.total = Number(object.total); + } else { + message.total = 0; + } + return message; + }, + + toJSON(message: PageResponse): unknown { + const obj: any = {}; + message.nextKey !== undefined && + (obj.nextKey = base64FromBytes( + message.nextKey !== undefined ? message.nextKey : new Uint8Array() + )); + message.total !== undefined && (obj.total = message.total); + return obj; + }, + + fromPartial(object: DeepPartial): PageResponse { + const message = { ...basePageResponse } as PageResponse; + if (object.nextKey !== undefined && object.nextKey !== null) { + message.nextKey = object.nextKey; + } else { + message.nextKey = new Uint8Array(); + } + if (object.total !== undefined && object.total !== null) { + message.total = object.total; + } else { + message.total = 0; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/ibc.applications.transfer.v1/types/cosmos/base/v1beta1/coin.ts b/ts-client/ibc.applications.transfer.v1/types/cosmos/base/v1beta1/coin.ts new file mode 100644 index 00000000..ce2ac984 --- /dev/null +++ b/ts-client/ibc.applications.transfer.v1/types/cosmos/base/v1beta1/coin.ts @@ -0,0 +1,301 @@ +/* eslint-disable */ +import { Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "cosmos.base.v1beta1"; + +/** + * Coin defines a token with a denomination and an amount. + * + * NOTE: The amount field is an Int which implements the custom method + * signatures required by gogoproto. + */ +export interface Coin { + denom: string; + amount: string; +} + +/** + * DecCoin defines a token with a denomination and a decimal amount. + * + * NOTE: The amount field is an Dec which implements the custom method + * signatures required by gogoproto. + */ +export interface DecCoin { + denom: string; + amount: string; +} + +/** IntProto defines a Protobuf wrapper around an Int object. */ +export interface IntProto { + int: string; +} + +/** DecProto defines a Protobuf wrapper around a Dec object. */ +export interface DecProto { + dec: string; +} + +const baseCoin: object = { denom: "", amount: "" }; + +export const Coin = { + encode(message: Coin, writer: Writer = Writer.create()): Writer { + if (message.denom !== "") { + writer.uint32(10).string(message.denom); + } + if (message.amount !== "") { + writer.uint32(18).string(message.amount); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Coin { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseCoin } as Coin; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.denom = reader.string(); + break; + case 2: + message.amount = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Coin { + const message = { ...baseCoin } as Coin; + if (object.denom !== undefined && object.denom !== null) { + message.denom = String(object.denom); + } else { + message.denom = ""; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = String(object.amount); + } else { + message.amount = ""; + } + return message; + }, + + toJSON(message: Coin): unknown { + const obj: any = {}; + message.denom !== undefined && (obj.denom = message.denom); + message.amount !== undefined && (obj.amount = message.amount); + return obj; + }, + + fromPartial(object: DeepPartial): Coin { + const message = { ...baseCoin } as Coin; + if (object.denom !== undefined && object.denom !== null) { + message.denom = object.denom; + } else { + message.denom = ""; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = object.amount; + } else { + message.amount = ""; + } + return message; + }, +}; + +const baseDecCoin: object = { denom: "", amount: "" }; + +export const DecCoin = { + encode(message: DecCoin, writer: Writer = Writer.create()): Writer { + if (message.denom !== "") { + writer.uint32(10).string(message.denom); + } + if (message.amount !== "") { + writer.uint32(18).string(message.amount); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): DecCoin { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseDecCoin } as DecCoin; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.denom = reader.string(); + break; + case 2: + message.amount = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DecCoin { + const message = { ...baseDecCoin } as DecCoin; + if (object.denom !== undefined && object.denom !== null) { + message.denom = String(object.denom); + } else { + message.denom = ""; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = String(object.amount); + } else { + message.amount = ""; + } + return message; + }, + + toJSON(message: DecCoin): unknown { + const obj: any = {}; + message.denom !== undefined && (obj.denom = message.denom); + message.amount !== undefined && (obj.amount = message.amount); + return obj; + }, + + fromPartial(object: DeepPartial): DecCoin { + const message = { ...baseDecCoin } as DecCoin; + if (object.denom !== undefined && object.denom !== null) { + message.denom = object.denom; + } else { + message.denom = ""; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = object.amount; + } else { + message.amount = ""; + } + return message; + }, +}; + +const baseIntProto: object = { int: "" }; + +export const IntProto = { + encode(message: IntProto, writer: Writer = Writer.create()): Writer { + if (message.int !== "") { + writer.uint32(10).string(message.int); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): IntProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseIntProto } as IntProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.int = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): IntProto { + const message = { ...baseIntProto } as IntProto; + if (object.int !== undefined && object.int !== null) { + message.int = String(object.int); + } else { + message.int = ""; + } + return message; + }, + + toJSON(message: IntProto): unknown { + const obj: any = {}; + message.int !== undefined && (obj.int = message.int); + return obj; + }, + + fromPartial(object: DeepPartial): IntProto { + const message = { ...baseIntProto } as IntProto; + if (object.int !== undefined && object.int !== null) { + message.int = object.int; + } else { + message.int = ""; + } + return message; + }, +}; + +const baseDecProto: object = { dec: "" }; + +export const DecProto = { + encode(message: DecProto, writer: Writer = Writer.create()): Writer { + if (message.dec !== "") { + writer.uint32(10).string(message.dec); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): DecProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseDecProto } as DecProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.dec = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DecProto { + const message = { ...baseDecProto } as DecProto; + if (object.dec !== undefined && object.dec !== null) { + message.dec = String(object.dec); + } else { + message.dec = ""; + } + return message; + }, + + toJSON(message: DecProto): unknown { + const obj: any = {}; + message.dec !== undefined && (obj.dec = message.dec); + return obj; + }, + + fromPartial(object: DeepPartial): DecProto { + const message = { ...baseDecProto } as DecProto; + if (object.dec !== undefined && object.dec !== null) { + message.dec = object.dec; + } else { + message.dec = ""; + } + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/ibc.applications.transfer.v1/types/cosmos/upgrade/v1beta1/upgrade.ts b/ts-client/ibc.applications.transfer.v1/types/cosmos/upgrade/v1beta1/upgrade.ts new file mode 100644 index 00000000..ec9520b0 --- /dev/null +++ b/ts-client/ibc.applications.transfer.v1/types/cosmos/upgrade/v1beta1/upgrade.ts @@ -0,0 +1,539 @@ +/* eslint-disable */ +import { Timestamp } from "../../../google/protobuf/timestamp"; +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; +import { Any } from "../../../google/protobuf/any"; + +export const protobufPackage = "cosmos.upgrade.v1beta1"; + +/** Plan specifies information about a planned upgrade and when it should occur. */ +export interface Plan { + /** + * Sets the name for the upgrade. This name will be used by the upgraded + * version of the software to apply any special "on-upgrade" commands during + * the first BeginBlock method after the upgrade is applied. It is also used + * to detect whether a software version can handle a given upgrade. If no + * upgrade handler with this name has been set in the software, it will be + * assumed that the software is out-of-date when the upgrade Time or Height is + * reached and the software will exit. + */ + name: string; + /** + * Deprecated: Time based upgrades have been deprecated. Time based upgrade logic + * has been removed from the SDK. + * If this field is not empty, an error will be thrown. + * + * @deprecated + */ + time: Date | undefined; + /** + * The height at which the upgrade must be performed. + * Only used if Time is not set. + */ + height: number; + /** + * Any application specific upgrade info to be included on-chain + * such as a git commit that validators could automatically upgrade to + */ + info: string; + /** + * Deprecated: UpgradedClientState field has been deprecated. IBC upgrade logic has been + * moved to the IBC module in the sub module 02-client. + * If this field is not empty, an error will be thrown. + * + * @deprecated + */ + upgradedClientState: Any | undefined; +} + +/** + * SoftwareUpgradeProposal is a gov Content type for initiating a software + * upgrade. + */ +export interface SoftwareUpgradeProposal { + title: string; + description: string; + plan: Plan | undefined; +} + +/** + * CancelSoftwareUpgradeProposal is a gov Content type for cancelling a software + * upgrade. + */ +export interface CancelSoftwareUpgradeProposal { + title: string; + description: string; +} + +/** + * ModuleVersion specifies a module and its consensus version. + * + * Since: cosmos-sdk 0.43 + */ +export interface ModuleVersion { + /** name of the app module */ + name: string; + /** consensus version of the app module */ + version: number; +} + +const basePlan: object = { name: "", height: 0, info: "" }; + +export const Plan = { + encode(message: Plan, writer: Writer = Writer.create()): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.time !== undefined) { + Timestamp.encode( + toTimestamp(message.time), + writer.uint32(18).fork() + ).ldelim(); + } + if (message.height !== 0) { + writer.uint32(24).int64(message.height); + } + if (message.info !== "") { + writer.uint32(34).string(message.info); + } + if (message.upgradedClientState !== undefined) { + Any.encode( + message.upgradedClientState, + writer.uint32(42).fork() + ).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Plan { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...basePlan } as Plan; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.time = fromTimestamp( + Timestamp.decode(reader, reader.uint32()) + ); + break; + case 3: + message.height = longToNumber(reader.int64() as Long); + break; + case 4: + message.info = reader.string(); + break; + case 5: + message.upgradedClientState = Any.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Plan { + const message = { ...basePlan } as Plan; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.time !== undefined && object.time !== null) { + message.time = fromJsonTimestamp(object.time); + } else { + message.time = undefined; + } + if (object.height !== undefined && object.height !== null) { + message.height = Number(object.height); + } else { + message.height = 0; + } + if (object.info !== undefined && object.info !== null) { + message.info = String(object.info); + } else { + message.info = ""; + } + if ( + object.upgradedClientState !== undefined && + object.upgradedClientState !== null + ) { + message.upgradedClientState = Any.fromJSON(object.upgradedClientState); + } else { + message.upgradedClientState = undefined; + } + return message; + }, + + toJSON(message: Plan): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.time !== undefined && + (obj.time = + message.time !== undefined ? message.time.toISOString() : null); + message.height !== undefined && (obj.height = message.height); + message.info !== undefined && (obj.info = message.info); + message.upgradedClientState !== undefined && + (obj.upgradedClientState = message.upgradedClientState + ? Any.toJSON(message.upgradedClientState) + : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): Plan { + const message = { ...basePlan } as Plan; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.time !== undefined && object.time !== null) { + message.time = object.time; + } else { + message.time = undefined; + } + if (object.height !== undefined && object.height !== null) { + message.height = object.height; + } else { + message.height = 0; + } + if (object.info !== undefined && object.info !== null) { + message.info = object.info; + } else { + message.info = ""; + } + if ( + object.upgradedClientState !== undefined && + object.upgradedClientState !== null + ) { + message.upgradedClientState = Any.fromPartial(object.upgradedClientState); + } else { + message.upgradedClientState = undefined; + } + return message; + }, +}; + +const baseSoftwareUpgradeProposal: object = { title: "", description: "" }; + +export const SoftwareUpgradeProposal = { + encode( + message: SoftwareUpgradeProposal, + writer: Writer = Writer.create() + ): Writer { + if (message.title !== "") { + writer.uint32(10).string(message.title); + } + if (message.description !== "") { + writer.uint32(18).string(message.description); + } + if (message.plan !== undefined) { + Plan.encode(message.plan, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): SoftwareUpgradeProposal { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseSoftwareUpgradeProposal, + } as SoftwareUpgradeProposal; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.title = reader.string(); + break; + case 2: + message.description = reader.string(); + break; + case 3: + message.plan = Plan.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): SoftwareUpgradeProposal { + const message = { + ...baseSoftwareUpgradeProposal, + } as SoftwareUpgradeProposal; + if (object.title !== undefined && object.title !== null) { + message.title = String(object.title); + } else { + message.title = ""; + } + if (object.description !== undefined && object.description !== null) { + message.description = String(object.description); + } else { + message.description = ""; + } + if (object.plan !== undefined && object.plan !== null) { + message.plan = Plan.fromJSON(object.plan); + } else { + message.plan = undefined; + } + return message; + }, + + toJSON(message: SoftwareUpgradeProposal): unknown { + const obj: any = {}; + message.title !== undefined && (obj.title = message.title); + message.description !== undefined && + (obj.description = message.description); + message.plan !== undefined && + (obj.plan = message.plan ? Plan.toJSON(message.plan) : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): SoftwareUpgradeProposal { + const message = { + ...baseSoftwareUpgradeProposal, + } as SoftwareUpgradeProposal; + if (object.title !== undefined && object.title !== null) { + message.title = object.title; + } else { + message.title = ""; + } + if (object.description !== undefined && object.description !== null) { + message.description = object.description; + } else { + message.description = ""; + } + if (object.plan !== undefined && object.plan !== null) { + message.plan = Plan.fromPartial(object.plan); + } else { + message.plan = undefined; + } + return message; + }, +}; + +const baseCancelSoftwareUpgradeProposal: object = { + title: "", + description: "", +}; + +export const CancelSoftwareUpgradeProposal = { + encode( + message: CancelSoftwareUpgradeProposal, + writer: Writer = Writer.create() + ): Writer { + if (message.title !== "") { + writer.uint32(10).string(message.title); + } + if (message.description !== "") { + writer.uint32(18).string(message.description); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): CancelSoftwareUpgradeProposal { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseCancelSoftwareUpgradeProposal, + } as CancelSoftwareUpgradeProposal; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.title = reader.string(); + break; + case 2: + message.description = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): CancelSoftwareUpgradeProposal { + const message = { + ...baseCancelSoftwareUpgradeProposal, + } as CancelSoftwareUpgradeProposal; + if (object.title !== undefined && object.title !== null) { + message.title = String(object.title); + } else { + message.title = ""; + } + if (object.description !== undefined && object.description !== null) { + message.description = String(object.description); + } else { + message.description = ""; + } + return message; + }, + + toJSON(message: CancelSoftwareUpgradeProposal): unknown { + const obj: any = {}; + message.title !== undefined && (obj.title = message.title); + message.description !== undefined && + (obj.description = message.description); + return obj; + }, + + fromPartial( + object: DeepPartial + ): CancelSoftwareUpgradeProposal { + const message = { + ...baseCancelSoftwareUpgradeProposal, + } as CancelSoftwareUpgradeProposal; + if (object.title !== undefined && object.title !== null) { + message.title = object.title; + } else { + message.title = ""; + } + if (object.description !== undefined && object.description !== null) { + message.description = object.description; + } else { + message.description = ""; + } + return message; + }, +}; + +const baseModuleVersion: object = { name: "", version: 0 }; + +export const ModuleVersion = { + encode(message: ModuleVersion, writer: Writer = Writer.create()): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.version !== 0) { + writer.uint32(16).uint64(message.version); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ModuleVersion { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseModuleVersion } as ModuleVersion; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.version = longToNumber(reader.uint64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ModuleVersion { + const message = { ...baseModuleVersion } as ModuleVersion; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.version !== undefined && object.version !== null) { + message.version = Number(object.version); + } else { + message.version = 0; + } + return message; + }, + + toJSON(message: ModuleVersion): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.version !== undefined && (obj.version = message.version); + return obj; + }, + + fromPartial(object: DeepPartial): ModuleVersion { + const message = { ...baseModuleVersion } as ModuleVersion; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.version !== undefined && object.version !== null) { + message.version = object.version; + } else { + message.version = 0; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function toTimestamp(date: Date): Timestamp { + const seconds = date.getTime() / 1_000; + const nanos = (date.getTime() % 1_000) * 1_000_000; + return { seconds, nanos }; +} + +function fromTimestamp(t: Timestamp): Date { + let millis = t.seconds * 1_000; + millis += t.nanos / 1_000_000; + return new Date(millis); +} + +function fromJsonTimestamp(o: any): Date { + if (o instanceof Date) { + return o; + } else if (typeof o === "string") { + return new Date(o); + } else { + return fromTimestamp(Timestamp.fromJSON(o)); + } +} + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/ibc.applications.transfer.v1/types/cosmos_proto/cosmos.ts b/ts-client/ibc.applications.transfer.v1/types/cosmos_proto/cosmos.ts new file mode 100644 index 00000000..9ec67a12 --- /dev/null +++ b/ts-client/ibc.applications.transfer.v1/types/cosmos_proto/cosmos.ts @@ -0,0 +1,2 @@ +/* eslint-disable */ +export const protobufPackage = "cosmos_proto"; diff --git a/ts-client/ibc.applications.transfer.v1/types/gogoproto/gogo.ts b/ts-client/ibc.applications.transfer.v1/types/gogoproto/gogo.ts new file mode 100644 index 00000000..3f41a047 --- /dev/null +++ b/ts-client/ibc.applications.transfer.v1/types/gogoproto/gogo.ts @@ -0,0 +1,2 @@ +/* eslint-disable */ +export const protobufPackage = "gogoproto"; diff --git a/ts-client/ibc.applications.transfer.v1/types/google/api/annotations.ts b/ts-client/ibc.applications.transfer.v1/types/google/api/annotations.ts new file mode 100644 index 00000000..aace4787 --- /dev/null +++ b/ts-client/ibc.applications.transfer.v1/types/google/api/annotations.ts @@ -0,0 +1,2 @@ +/* eslint-disable */ +export const protobufPackage = "google.api"; diff --git a/ts-client/ibc.applications.transfer.v1/types/google/api/http.ts b/ts-client/ibc.applications.transfer.v1/types/google/api/http.ts new file mode 100644 index 00000000..ddc00f8b --- /dev/null +++ b/ts-client/ibc.applications.transfer.v1/types/google/api/http.ts @@ -0,0 +1,705 @@ +/* eslint-disable */ +import { Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "google.api"; + +/** + * Defines the HTTP configuration for an API service. It contains a list of + * [HttpRule][google.api.HttpRule], each specifying the mapping of an RPC method + * to one or more HTTP REST API methods. + */ +export interface Http { + /** + * A list of HTTP configuration rules that apply to individual API methods. + * + * **NOTE:** All service configuration rules follow "last one wins" order. + */ + rules: HttpRule[]; + /** + * When set to true, URL path parmeters will be fully URI-decoded except in + * cases of single segment matches in reserved expansion, where "%2F" will be + * left encoded. + * + * The default behavior is to not decode RFC 6570 reserved characters in multi + * segment matches. + */ + fullyDecodeReservedExpansion: boolean; +} + +/** + * `HttpRule` defines the mapping of an RPC method to one or more HTTP + * REST API methods. The mapping specifies how different portions of the RPC + * request message are mapped to URL path, URL query parameters, and + * HTTP request body. The mapping is typically specified as an + * `google.api.http` annotation on the RPC method, + * see "google/api/annotations.proto" for details. + * + * The mapping consists of a field specifying the path template and + * method kind. The path template can refer to fields in the request + * message, as in the example below which describes a REST GET + * operation on a resource collection of messages: + * + * + * service Messaging { + * rpc GetMessage(GetMessageRequest) returns (Message) { + * option (google.api.http).get = "/v1/messages/{message_id}/{sub.subfield}"; + * } + * } + * message GetMessageRequest { + * message SubMessage { + * string subfield = 1; + * } + * string message_id = 1; // mapped to the URL + * SubMessage sub = 2; // `sub.subfield` is url-mapped + * } + * message Message { + * string text = 1; // content of the resource + * } + * + * The same http annotation can alternatively be expressed inside the + * `GRPC API Configuration` YAML file. + * + * http: + * rules: + * - selector: .Messaging.GetMessage + * get: /v1/messages/{message_id}/{sub.subfield} + * + * This definition enables an automatic, bidrectional mapping of HTTP + * JSON to RPC. Example: + * + * HTTP | RPC + * -----|----- + * `GET /v1/messages/123456/foo` | `GetMessage(message_id: "123456" sub: SubMessage(subfield: "foo"))` + * + * In general, not only fields but also field paths can be referenced + * from a path pattern. Fields mapped to the path pattern cannot be + * repeated and must have a primitive (non-message) type. + * + * Any fields in the request message which are not bound by the path + * pattern automatically become (optional) HTTP query + * parameters. Assume the following definition of the request message: + * + * + * service Messaging { + * rpc GetMessage(GetMessageRequest) returns (Message) { + * option (google.api.http).get = "/v1/messages/{message_id}"; + * } + * } + * message GetMessageRequest { + * message SubMessage { + * string subfield = 1; + * } + * string message_id = 1; // mapped to the URL + * int64 revision = 2; // becomes a parameter + * SubMessage sub = 3; // `sub.subfield` becomes a parameter + * } + * + * + * This enables a HTTP JSON to RPC mapping as below: + * + * HTTP | RPC + * -----|----- + * `GET /v1/messages/123456?revision=2&sub.subfield=foo` | `GetMessage(message_id: "123456" revision: 2 sub: SubMessage(subfield: "foo"))` + * + * Note that fields which are mapped to HTTP parameters must have a + * primitive type or a repeated primitive type. Message types are not + * allowed. In the case of a repeated type, the parameter can be + * repeated in the URL, as in `...?param=A¶m=B`. + * + * For HTTP method kinds which allow a request body, the `body` field + * specifies the mapping. Consider a REST update method on the + * message resource collection: + * + * + * service Messaging { + * rpc UpdateMessage(UpdateMessageRequest) returns (Message) { + * option (google.api.http) = { + * put: "/v1/messages/{message_id}" + * body: "message" + * }; + * } + * } + * message UpdateMessageRequest { + * string message_id = 1; // mapped to the URL + * Message message = 2; // mapped to the body + * } + * + * + * The following HTTP JSON to RPC mapping is enabled, where the + * representation of the JSON in the request body is determined by + * protos JSON encoding: + * + * HTTP | RPC + * -----|----- + * `PUT /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: "123456" message { text: "Hi!" })` + * + * The special name `*` can be used in the body mapping to define that + * every field not bound by the path template should be mapped to the + * request body. This enables the following alternative definition of + * the update method: + * + * service Messaging { + * rpc UpdateMessage(Message) returns (Message) { + * option (google.api.http) = { + * put: "/v1/messages/{message_id}" + * body: "*" + * }; + * } + * } + * message Message { + * string message_id = 1; + * string text = 2; + * } + * + * + * The following HTTP JSON to RPC mapping is enabled: + * + * HTTP | RPC + * -----|----- + * `PUT /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: "123456" text: "Hi!")` + * + * Note that when using `*` in the body mapping, it is not possible to + * have HTTP parameters, as all fields not bound by the path end in + * the body. This makes this option more rarely used in practice of + * defining REST APIs. The common usage of `*` is in custom methods + * which don't use the URL at all for transferring data. + * + * It is possible to define multiple HTTP methods for one RPC by using + * the `additional_bindings` option. Example: + * + * service Messaging { + * rpc GetMessage(GetMessageRequest) returns (Message) { + * option (google.api.http) = { + * get: "/v1/messages/{message_id}" + * additional_bindings { + * get: "/v1/users/{user_id}/messages/{message_id}" + * } + * }; + * } + * } + * message GetMessageRequest { + * string message_id = 1; + * string user_id = 2; + * } + * + * + * This enables the following two alternative HTTP JSON to RPC + * mappings: + * + * HTTP | RPC + * -----|----- + * `GET /v1/messages/123456` | `GetMessage(message_id: "123456")` + * `GET /v1/users/me/messages/123456` | `GetMessage(user_id: "me" message_id: "123456")` + * + * # Rules for HTTP mapping + * + * The rules for mapping HTTP path, query parameters, and body fields + * to the request message are as follows: + * + * 1. The `body` field specifies either `*` or a field path, or is + * omitted. If omitted, it indicates there is no HTTP request body. + * 2. Leaf fields (recursive expansion of nested messages in the + * request) can be classified into three types: + * (a) Matched in the URL template. + * (b) Covered by body (if body is `*`, everything except (a) fields; + * else everything under the body field) + * (c) All other fields. + * 3. URL query parameters found in the HTTP request are mapped to (c) fields. + * 4. Any body sent with an HTTP request can contain only (b) fields. + * + * The syntax of the path template is as follows: + * + * Template = "/" Segments [ Verb ] ; + * Segments = Segment { "/" Segment } ; + * Segment = "*" | "**" | LITERAL | Variable ; + * Variable = "{" FieldPath [ "=" Segments ] "}" ; + * FieldPath = IDENT { "." IDENT } ; + * Verb = ":" LITERAL ; + * + * The syntax `*` matches a single path segment. The syntax `**` matches zero + * or more path segments, which must be the last part of the path except the + * `Verb`. The syntax `LITERAL` matches literal text in the path. + * + * The syntax `Variable` matches part of the URL path as specified by its + * template. A variable template must not contain other variables. If a variable + * matches a single path segment, its template may be omitted, e.g. `{var}` + * is equivalent to `{var=*}`. + * + * If a variable contains exactly one path segment, such as `"{var}"` or + * `"{var=*}"`, when such a variable is expanded into a URL path, all characters + * except `[-_.~0-9a-zA-Z]` are percent-encoded. Such variables show up in the + * Discovery Document as `{var}`. + * + * If a variable contains one or more path segments, such as `"{var=foo/*}"` + * or `"{var=**}"`, when such a variable is expanded into a URL path, all + * characters except `[-_.~/0-9a-zA-Z]` are percent-encoded. Such variables + * show up in the Discovery Document as `{+var}`. + * + * NOTE: While the single segment variable matches the semantics of + * [RFC 6570](https://tools.ietf.org/html/rfc6570) Section 3.2.2 + * Simple String Expansion, the multi segment variable **does not** match + * RFC 6570 Reserved Expansion. The reason is that the Reserved Expansion + * does not expand special characters like `?` and `#`, which would lead + * to invalid URLs. + * + * NOTE: the field paths in variables and in the `body` must not refer to + * repeated fields or map fields. + */ +export interface HttpRule { + /** + * Selects methods to which this rule applies. + * + * Refer to [selector][google.api.DocumentationRule.selector] for syntax details. + */ + selector: string; + /** Used for listing and getting information about resources. */ + get: string | undefined; + /** Used for updating a resource. */ + put: string | undefined; + /** Used for creating a resource. */ + post: string | undefined; + /** Used for deleting a resource. */ + delete: string | undefined; + /** Used for updating a resource. */ + patch: string | undefined; + /** + * The custom pattern is used for specifying an HTTP method that is not + * included in the `pattern` field, such as HEAD, or "*" to leave the + * HTTP method unspecified for this rule. The wild-card rule is useful + * for services that provide content to Web (HTML) clients. + */ + custom: CustomHttpPattern | undefined; + /** + * The name of the request field whose value is mapped to the HTTP body, or + * `*` for mapping all fields not captured by the path pattern to the HTTP + * body. NOTE: the referred field must not be a repeated field and must be + * present at the top-level of request message type. + */ + body: string; + /** + * Optional. The name of the response field whose value is mapped to the HTTP + * body of response. Other response fields are ignored. When + * not set, the response message will be used as HTTP body of response. + */ + responseBody: string; + /** + * Additional HTTP bindings for the selector. Nested bindings must + * not contain an `additional_bindings` field themselves (that is, + * the nesting may only be one level deep). + */ + additionalBindings: HttpRule[]; +} + +/** A custom pattern is used for defining custom HTTP verb. */ +export interface CustomHttpPattern { + /** The name of this custom HTTP verb. */ + kind: string; + /** The path matched by this custom verb. */ + path: string; +} + +const baseHttp: object = { fullyDecodeReservedExpansion: false }; + +export const Http = { + encode(message: Http, writer: Writer = Writer.create()): Writer { + for (const v of message.rules) { + HttpRule.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.fullyDecodeReservedExpansion === true) { + writer.uint32(16).bool(message.fullyDecodeReservedExpansion); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Http { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseHttp } as Http; + message.rules = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.rules.push(HttpRule.decode(reader, reader.uint32())); + break; + case 2: + message.fullyDecodeReservedExpansion = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Http { + const message = { ...baseHttp } as Http; + message.rules = []; + if (object.rules !== undefined && object.rules !== null) { + for (const e of object.rules) { + message.rules.push(HttpRule.fromJSON(e)); + } + } + if ( + object.fullyDecodeReservedExpansion !== undefined && + object.fullyDecodeReservedExpansion !== null + ) { + message.fullyDecodeReservedExpansion = Boolean( + object.fullyDecodeReservedExpansion + ); + } else { + message.fullyDecodeReservedExpansion = false; + } + return message; + }, + + toJSON(message: Http): unknown { + const obj: any = {}; + if (message.rules) { + obj.rules = message.rules.map((e) => + e ? HttpRule.toJSON(e) : undefined + ); + } else { + obj.rules = []; + } + message.fullyDecodeReservedExpansion !== undefined && + (obj.fullyDecodeReservedExpansion = message.fullyDecodeReservedExpansion); + return obj; + }, + + fromPartial(object: DeepPartial): Http { + const message = { ...baseHttp } as Http; + message.rules = []; + if (object.rules !== undefined && object.rules !== null) { + for (const e of object.rules) { + message.rules.push(HttpRule.fromPartial(e)); + } + } + if ( + object.fullyDecodeReservedExpansion !== undefined && + object.fullyDecodeReservedExpansion !== null + ) { + message.fullyDecodeReservedExpansion = + object.fullyDecodeReservedExpansion; + } else { + message.fullyDecodeReservedExpansion = false; + } + return message; + }, +}; + +const baseHttpRule: object = { selector: "", body: "", responseBody: "" }; + +export const HttpRule = { + encode(message: HttpRule, writer: Writer = Writer.create()): Writer { + if (message.selector !== "") { + writer.uint32(10).string(message.selector); + } + if (message.get !== undefined) { + writer.uint32(18).string(message.get); + } + if (message.put !== undefined) { + writer.uint32(26).string(message.put); + } + if (message.post !== undefined) { + writer.uint32(34).string(message.post); + } + if (message.delete !== undefined) { + writer.uint32(42).string(message.delete); + } + if (message.patch !== undefined) { + writer.uint32(50).string(message.patch); + } + if (message.custom !== undefined) { + CustomHttpPattern.encode( + message.custom, + writer.uint32(66).fork() + ).ldelim(); + } + if (message.body !== "") { + writer.uint32(58).string(message.body); + } + if (message.responseBody !== "") { + writer.uint32(98).string(message.responseBody); + } + for (const v of message.additionalBindings) { + HttpRule.encode(v!, writer.uint32(90).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): HttpRule { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseHttpRule } as HttpRule; + message.additionalBindings = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.selector = reader.string(); + break; + case 2: + message.get = reader.string(); + break; + case 3: + message.put = reader.string(); + break; + case 4: + message.post = reader.string(); + break; + case 5: + message.delete = reader.string(); + break; + case 6: + message.patch = reader.string(); + break; + case 8: + message.custom = CustomHttpPattern.decode(reader, reader.uint32()); + break; + case 7: + message.body = reader.string(); + break; + case 12: + message.responseBody = reader.string(); + break; + case 11: + message.additionalBindings.push( + HttpRule.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): HttpRule { + const message = { ...baseHttpRule } as HttpRule; + message.additionalBindings = []; + if (object.selector !== undefined && object.selector !== null) { + message.selector = String(object.selector); + } else { + message.selector = ""; + } + if (object.get !== undefined && object.get !== null) { + message.get = String(object.get); + } else { + message.get = undefined; + } + if (object.put !== undefined && object.put !== null) { + message.put = String(object.put); + } else { + message.put = undefined; + } + if (object.post !== undefined && object.post !== null) { + message.post = String(object.post); + } else { + message.post = undefined; + } + if (object.delete !== undefined && object.delete !== null) { + message.delete = String(object.delete); + } else { + message.delete = undefined; + } + if (object.patch !== undefined && object.patch !== null) { + message.patch = String(object.patch); + } else { + message.patch = undefined; + } + if (object.custom !== undefined && object.custom !== null) { + message.custom = CustomHttpPattern.fromJSON(object.custom); + } else { + message.custom = undefined; + } + if (object.body !== undefined && object.body !== null) { + message.body = String(object.body); + } else { + message.body = ""; + } + if (object.responseBody !== undefined && object.responseBody !== null) { + message.responseBody = String(object.responseBody); + } else { + message.responseBody = ""; + } + if ( + object.additionalBindings !== undefined && + object.additionalBindings !== null + ) { + for (const e of object.additionalBindings) { + message.additionalBindings.push(HttpRule.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: HttpRule): unknown { + const obj: any = {}; + message.selector !== undefined && (obj.selector = message.selector); + message.get !== undefined && (obj.get = message.get); + message.put !== undefined && (obj.put = message.put); + message.post !== undefined && (obj.post = message.post); + message.delete !== undefined && (obj.delete = message.delete); + message.patch !== undefined && (obj.patch = message.patch); + message.custom !== undefined && + (obj.custom = message.custom + ? CustomHttpPattern.toJSON(message.custom) + : undefined); + message.body !== undefined && (obj.body = message.body); + message.responseBody !== undefined && + (obj.responseBody = message.responseBody); + if (message.additionalBindings) { + obj.additionalBindings = message.additionalBindings.map((e) => + e ? HttpRule.toJSON(e) : undefined + ); + } else { + obj.additionalBindings = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): HttpRule { + const message = { ...baseHttpRule } as HttpRule; + message.additionalBindings = []; + if (object.selector !== undefined && object.selector !== null) { + message.selector = object.selector; + } else { + message.selector = ""; + } + if (object.get !== undefined && object.get !== null) { + message.get = object.get; + } else { + message.get = undefined; + } + if (object.put !== undefined && object.put !== null) { + message.put = object.put; + } else { + message.put = undefined; + } + if (object.post !== undefined && object.post !== null) { + message.post = object.post; + } else { + message.post = undefined; + } + if (object.delete !== undefined && object.delete !== null) { + message.delete = object.delete; + } else { + message.delete = undefined; + } + if (object.patch !== undefined && object.patch !== null) { + message.patch = object.patch; + } else { + message.patch = undefined; + } + if (object.custom !== undefined && object.custom !== null) { + message.custom = CustomHttpPattern.fromPartial(object.custom); + } else { + message.custom = undefined; + } + if (object.body !== undefined && object.body !== null) { + message.body = object.body; + } else { + message.body = ""; + } + if (object.responseBody !== undefined && object.responseBody !== null) { + message.responseBody = object.responseBody; + } else { + message.responseBody = ""; + } + if ( + object.additionalBindings !== undefined && + object.additionalBindings !== null + ) { + for (const e of object.additionalBindings) { + message.additionalBindings.push(HttpRule.fromPartial(e)); + } + } + return message; + }, +}; + +const baseCustomHttpPattern: object = { kind: "", path: "" }; + +export const CustomHttpPattern = { + encode(message: CustomHttpPattern, writer: Writer = Writer.create()): Writer { + if (message.kind !== "") { + writer.uint32(10).string(message.kind); + } + if (message.path !== "") { + writer.uint32(18).string(message.path); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): CustomHttpPattern { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseCustomHttpPattern } as CustomHttpPattern; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.kind = reader.string(); + break; + case 2: + message.path = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): CustomHttpPattern { + const message = { ...baseCustomHttpPattern } as CustomHttpPattern; + if (object.kind !== undefined && object.kind !== null) { + message.kind = String(object.kind); + } else { + message.kind = ""; + } + if (object.path !== undefined && object.path !== null) { + message.path = String(object.path); + } else { + message.path = ""; + } + return message; + }, + + toJSON(message: CustomHttpPattern): unknown { + const obj: any = {}; + message.kind !== undefined && (obj.kind = message.kind); + message.path !== undefined && (obj.path = message.path); + return obj; + }, + + fromPartial(object: DeepPartial): CustomHttpPattern { + const message = { ...baseCustomHttpPattern } as CustomHttpPattern; + if (object.kind !== undefined && object.kind !== null) { + message.kind = object.kind; + } else { + message.kind = ""; + } + if (object.path !== undefined && object.path !== null) { + message.path = object.path; + } else { + message.path = ""; + } + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/ibc.applications.transfer.v1/types/google/protobuf/any.ts b/ts-client/ibc.applications.transfer.v1/types/google/protobuf/any.ts new file mode 100644 index 00000000..b137a629 --- /dev/null +++ b/ts-client/ibc.applications.transfer.v1/types/google/protobuf/any.ts @@ -0,0 +1,240 @@ +/* eslint-disable */ +import { Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "google.protobuf"; + +/** + * `Any` contains an arbitrary serialized protocol buffer message along with a + * URL that describes the type of the serialized message. + * + * Protobuf library provides support to pack/unpack Any values in the form + * of utility functions or additional generated methods of the Any type. + * + * Example 1: Pack and unpack a message in C++. + * + * Foo foo = ...; + * Any any; + * any.PackFrom(foo); + * ... + * if (any.UnpackTo(&foo)) { + * ... + * } + * + * Example 2: Pack and unpack a message in Java. + * + * Foo foo = ...; + * Any any = Any.pack(foo); + * ... + * if (any.is(Foo.class)) { + * foo = any.unpack(Foo.class); + * } + * + * Example 3: Pack and unpack a message in Python. + * + * foo = Foo(...) + * any = Any() + * any.Pack(foo) + * ... + * if any.Is(Foo.DESCRIPTOR): + * any.Unpack(foo) + * ... + * + * Example 4: Pack and unpack a message in Go + * + * foo := &pb.Foo{...} + * any, err := anypb.New(foo) + * if err != nil { + * ... + * } + * ... + * foo := &pb.Foo{} + * if err := any.UnmarshalTo(foo); err != nil { + * ... + * } + * + * The pack methods provided by protobuf library will by default use + * 'type.googleapis.com/full.type.name' as the type URL and the unpack + * methods only use the fully qualified type name after the last '/' + * in the type URL, for example "foo.bar.com/x/y.z" will yield type + * name "y.z". + * + * + * JSON + * ==== + * The JSON representation of an `Any` value uses the regular + * representation of the deserialized, embedded message, with an + * additional field `@type` which contains the type URL. Example: + * + * package google.profile; + * message Person { + * string first_name = 1; + * string last_name = 2; + * } + * + * { + * "@type": "type.googleapis.com/google.profile.Person", + * "firstName": , + * "lastName": + * } + * + * If the embedded message type is well-known and has a custom JSON + * representation, that representation will be embedded adding a field + * `value` which holds the custom JSON in addition to the `@type` + * field. Example (for message [google.protobuf.Duration][]): + * + * { + * "@type": "type.googleapis.com/google.protobuf.Duration", + * "value": "1.212s" + * } + */ +export interface Any { + /** + * A URL/resource name that uniquely identifies the type of the serialized + * protocol buffer message. This string must contain at least + * one "/" character. The last segment of the URL's path must represent + * the fully qualified name of the type (as in + * `path/google.protobuf.Duration`). The name should be in a canonical form + * (e.g., leading "." is not accepted). + * + * In practice, teams usually precompile into the binary all types that they + * expect it to use in the context of Any. However, for URLs which use the + * scheme `http`, `https`, or no scheme, one can optionally set up a type + * server that maps type URLs to message definitions as follows: + * + * * If no scheme is provided, `https` is assumed. + * * An HTTP GET on the URL must yield a [google.protobuf.Type][] + * value in binary format, or produce an error. + * * Applications are allowed to cache lookup results based on the + * URL, or have them precompiled into a binary to avoid any + * lookup. Therefore, binary compatibility needs to be preserved + * on changes to types. (Use versioned type names to manage + * breaking changes.) + * + * Note: this functionality is not currently available in the official + * protobuf release, and it is not used for type URLs beginning with + * type.googleapis.com. + * + * Schemes other than `http`, `https` (or the empty scheme) might be + * used with implementation specific semantics. + */ + typeUrl: string; + /** Must be a valid serialized protocol buffer of the above specified type. */ + value: Uint8Array; +} + +const baseAny: object = { typeUrl: "" }; + +export const Any = { + encode(message: Any, writer: Writer = Writer.create()): Writer { + if (message.typeUrl !== "") { + writer.uint32(10).string(message.typeUrl); + } + if (message.value.length !== 0) { + writer.uint32(18).bytes(message.value); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Any { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseAny } as Any; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.typeUrl = reader.string(); + break; + case 2: + message.value = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Any { + const message = { ...baseAny } as Any; + if (object.typeUrl !== undefined && object.typeUrl !== null) { + message.typeUrl = String(object.typeUrl); + } else { + message.typeUrl = ""; + } + if (object.value !== undefined && object.value !== null) { + message.value = bytesFromBase64(object.value); + } + return message; + }, + + toJSON(message: Any): unknown { + const obj: any = {}; + message.typeUrl !== undefined && (obj.typeUrl = message.typeUrl); + message.value !== undefined && + (obj.value = base64FromBytes( + message.value !== undefined ? message.value : new Uint8Array() + )); + return obj; + }, + + fromPartial(object: DeepPartial): Any { + const message = { ...baseAny } as Any; + if (object.typeUrl !== undefined && object.typeUrl !== null) { + message.typeUrl = object.typeUrl; + } else { + message.typeUrl = ""; + } + if (object.value !== undefined && object.value !== null) { + message.value = object.value; + } else { + message.value = new Uint8Array(); + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/ibc.applications.transfer.v1/types/google/protobuf/descriptor.ts b/ts-client/ibc.applications.transfer.v1/types/google/protobuf/descriptor.ts new file mode 100644 index 00000000..9e508660 --- /dev/null +++ b/ts-client/ibc.applications.transfer.v1/types/google/protobuf/descriptor.ts @@ -0,0 +1,5261 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "google.protobuf"; + +/** + * The protocol compiler can output a FileDescriptorSet containing the .proto + * files it parses. + */ +export interface FileDescriptorSet { + file: FileDescriptorProto[]; +} + +/** Describes a complete .proto file. */ +export interface FileDescriptorProto { + /** file name, relative to root of source tree */ + name: string; + /** e.g. "foo", "foo.bar", etc. */ + package: string; + /** Names of files imported by this file. */ + dependency: string[]; + /** Indexes of the public imported files in the dependency list above. */ + publicDependency: number[]; + /** + * Indexes of the weak imported files in the dependency list. + * For Google-internal migration only. Do not use. + */ + weakDependency: number[]; + /** All top-level definitions in this file. */ + messageType: DescriptorProto[]; + enumType: EnumDescriptorProto[]; + service: ServiceDescriptorProto[]; + extension: FieldDescriptorProto[]; + options: FileOptions | undefined; + /** + * This field contains optional information about the original source code. + * You may safely remove this entire field without harming runtime + * functionality of the descriptors -- the information is needed only by + * development tools. + */ + sourceCodeInfo: SourceCodeInfo | undefined; + /** + * The syntax of the proto file. + * The supported values are "proto2" and "proto3". + */ + syntax: string; +} + +/** Describes a message type. */ +export interface DescriptorProto { + name: string; + field: FieldDescriptorProto[]; + extension: FieldDescriptorProto[]; + nestedType: DescriptorProto[]; + enumType: EnumDescriptorProto[]; + extensionRange: DescriptorProto_ExtensionRange[]; + oneofDecl: OneofDescriptorProto[]; + options: MessageOptions | undefined; + reservedRange: DescriptorProto_ReservedRange[]; + /** + * Reserved field names, which may not be used by fields in the same message. + * A given name may only be reserved once. + */ + reservedName: string[]; +} + +export interface DescriptorProto_ExtensionRange { + /** Inclusive. */ + start: number; + /** Exclusive. */ + end: number; + options: ExtensionRangeOptions | undefined; +} + +/** + * Range of reserved tag numbers. Reserved tag numbers may not be used by + * fields or extension ranges in the same message. Reserved ranges may + * not overlap. + */ +export interface DescriptorProto_ReservedRange { + /** Inclusive. */ + start: number; + /** Exclusive. */ + end: number; +} + +export interface ExtensionRangeOptions { + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +/** Describes a field within a message. */ +export interface FieldDescriptorProto { + name: string; + number: number; + label: FieldDescriptorProto_Label; + /** + * If type_name is set, this need not be set. If both this and type_name + * are set, this must be one of TYPE_ENUM, TYPE_MESSAGE or TYPE_GROUP. + */ + type: FieldDescriptorProto_Type; + /** + * For message and enum types, this is the name of the type. If the name + * starts with a '.', it is fully-qualified. Otherwise, C++-like scoping + * rules are used to find the type (i.e. first the nested types within this + * message are searched, then within the parent, on up to the root + * namespace). + */ + typeName: string; + /** + * For extensions, this is the name of the type being extended. It is + * resolved in the same manner as type_name. + */ + extendee: string; + /** + * For numeric types, contains the original text representation of the value. + * For booleans, "true" or "false". + * For strings, contains the default text contents (not escaped in any way). + * For bytes, contains the C escaped value. All bytes >= 128 are escaped. + * TODO(kenton): Base-64 encode? + */ + defaultValue: string; + /** + * If set, gives the index of a oneof in the containing type's oneof_decl + * list. This field is a member of that oneof. + */ + oneofIndex: number; + /** + * JSON name of this field. The value is set by protocol compiler. If the + * user has set a "json_name" option on this field, that option's value + * will be used. Otherwise, it's deduced from the field's name by converting + * it to camelCase. + */ + jsonName: string; + options: FieldOptions | undefined; + /** + * If true, this is a proto3 "optional". When a proto3 field is optional, it + * tracks presence regardless of field type. + * + * When proto3_optional is true, this field must be belong to a oneof to + * signal to old proto3 clients that presence is tracked for this field. This + * oneof is known as a "synthetic" oneof, and this field must be its sole + * member (each proto3 optional field gets its own synthetic oneof). Synthetic + * oneofs exist in the descriptor only, and do not generate any API. Synthetic + * oneofs must be ordered after all "real" oneofs. + * + * For message fields, proto3_optional doesn't create any semantic change, + * since non-repeated message fields always track presence. However it still + * indicates the semantic detail of whether the user wrote "optional" or not. + * This can be useful for round-tripping the .proto file. For consistency we + * give message fields a synthetic oneof also, even though it is not required + * to track presence. This is especially important because the parser can't + * tell if a field is a message or an enum, so it must always create a + * synthetic oneof. + * + * Proto2 optional fields do not set this flag, because they already indicate + * optional with `LABEL_OPTIONAL`. + */ + proto3Optional: boolean; +} + +export enum FieldDescriptorProto_Type { + /** + * TYPE_DOUBLE - 0 is reserved for errors. + * Order is weird for historical reasons. + */ + TYPE_DOUBLE = 1, + TYPE_FLOAT = 2, + /** + * TYPE_INT64 - Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT64 if + * negative values are likely. + */ + TYPE_INT64 = 3, + TYPE_UINT64 = 4, + /** + * TYPE_INT32 - Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT32 if + * negative values are likely. + */ + TYPE_INT32 = 5, + TYPE_FIXED64 = 6, + TYPE_FIXED32 = 7, + TYPE_BOOL = 8, + TYPE_STRING = 9, + /** + * TYPE_GROUP - Tag-delimited aggregate. + * Group type is deprecated and not supported in proto3. However, Proto3 + * implementations should still be able to parse the group wire format and + * treat group fields as unknown fields. + */ + TYPE_GROUP = 10, + /** TYPE_MESSAGE - Length-delimited aggregate. */ + TYPE_MESSAGE = 11, + /** TYPE_BYTES - New in version 2. */ + TYPE_BYTES = 12, + TYPE_UINT32 = 13, + TYPE_ENUM = 14, + TYPE_SFIXED32 = 15, + TYPE_SFIXED64 = 16, + /** TYPE_SINT32 - Uses ZigZag encoding. */ + TYPE_SINT32 = 17, + /** TYPE_SINT64 - Uses ZigZag encoding. */ + TYPE_SINT64 = 18, + UNRECOGNIZED = -1, +} + +export function fieldDescriptorProto_TypeFromJSON( + object: any +): FieldDescriptorProto_Type { + switch (object) { + case 1: + case "TYPE_DOUBLE": + return FieldDescriptorProto_Type.TYPE_DOUBLE; + case 2: + case "TYPE_FLOAT": + return FieldDescriptorProto_Type.TYPE_FLOAT; + case 3: + case "TYPE_INT64": + return FieldDescriptorProto_Type.TYPE_INT64; + case 4: + case "TYPE_UINT64": + return FieldDescriptorProto_Type.TYPE_UINT64; + case 5: + case "TYPE_INT32": + return FieldDescriptorProto_Type.TYPE_INT32; + case 6: + case "TYPE_FIXED64": + return FieldDescriptorProto_Type.TYPE_FIXED64; + case 7: + case "TYPE_FIXED32": + return FieldDescriptorProto_Type.TYPE_FIXED32; + case 8: + case "TYPE_BOOL": + return FieldDescriptorProto_Type.TYPE_BOOL; + case 9: + case "TYPE_STRING": + return FieldDescriptorProto_Type.TYPE_STRING; + case 10: + case "TYPE_GROUP": + return FieldDescriptorProto_Type.TYPE_GROUP; + case 11: + case "TYPE_MESSAGE": + return FieldDescriptorProto_Type.TYPE_MESSAGE; + case 12: + case "TYPE_BYTES": + return FieldDescriptorProto_Type.TYPE_BYTES; + case 13: + case "TYPE_UINT32": + return FieldDescriptorProto_Type.TYPE_UINT32; + case 14: + case "TYPE_ENUM": + return FieldDescriptorProto_Type.TYPE_ENUM; + case 15: + case "TYPE_SFIXED32": + return FieldDescriptorProto_Type.TYPE_SFIXED32; + case 16: + case "TYPE_SFIXED64": + return FieldDescriptorProto_Type.TYPE_SFIXED64; + case 17: + case "TYPE_SINT32": + return FieldDescriptorProto_Type.TYPE_SINT32; + case 18: + case "TYPE_SINT64": + return FieldDescriptorProto_Type.TYPE_SINT64; + case -1: + case "UNRECOGNIZED": + default: + return FieldDescriptorProto_Type.UNRECOGNIZED; + } +} + +export function fieldDescriptorProto_TypeToJSON( + object: FieldDescriptorProto_Type +): string { + switch (object) { + case FieldDescriptorProto_Type.TYPE_DOUBLE: + return "TYPE_DOUBLE"; + case FieldDescriptorProto_Type.TYPE_FLOAT: + return "TYPE_FLOAT"; + case FieldDescriptorProto_Type.TYPE_INT64: + return "TYPE_INT64"; + case FieldDescriptorProto_Type.TYPE_UINT64: + return "TYPE_UINT64"; + case FieldDescriptorProto_Type.TYPE_INT32: + return "TYPE_INT32"; + case FieldDescriptorProto_Type.TYPE_FIXED64: + return "TYPE_FIXED64"; + case FieldDescriptorProto_Type.TYPE_FIXED32: + return "TYPE_FIXED32"; + case FieldDescriptorProto_Type.TYPE_BOOL: + return "TYPE_BOOL"; + case FieldDescriptorProto_Type.TYPE_STRING: + return "TYPE_STRING"; + case FieldDescriptorProto_Type.TYPE_GROUP: + return "TYPE_GROUP"; + case FieldDescriptorProto_Type.TYPE_MESSAGE: + return "TYPE_MESSAGE"; + case FieldDescriptorProto_Type.TYPE_BYTES: + return "TYPE_BYTES"; + case FieldDescriptorProto_Type.TYPE_UINT32: + return "TYPE_UINT32"; + case FieldDescriptorProto_Type.TYPE_ENUM: + return "TYPE_ENUM"; + case FieldDescriptorProto_Type.TYPE_SFIXED32: + return "TYPE_SFIXED32"; + case FieldDescriptorProto_Type.TYPE_SFIXED64: + return "TYPE_SFIXED64"; + case FieldDescriptorProto_Type.TYPE_SINT32: + return "TYPE_SINT32"; + case FieldDescriptorProto_Type.TYPE_SINT64: + return "TYPE_SINT64"; + default: + return "UNKNOWN"; + } +} + +export enum FieldDescriptorProto_Label { + /** LABEL_OPTIONAL - 0 is reserved for errors */ + LABEL_OPTIONAL = 1, + LABEL_REQUIRED = 2, + LABEL_REPEATED = 3, + UNRECOGNIZED = -1, +} + +export function fieldDescriptorProto_LabelFromJSON( + object: any +): FieldDescriptorProto_Label { + switch (object) { + case 1: + case "LABEL_OPTIONAL": + return FieldDescriptorProto_Label.LABEL_OPTIONAL; + case 2: + case "LABEL_REQUIRED": + return FieldDescriptorProto_Label.LABEL_REQUIRED; + case 3: + case "LABEL_REPEATED": + return FieldDescriptorProto_Label.LABEL_REPEATED; + case -1: + case "UNRECOGNIZED": + default: + return FieldDescriptorProto_Label.UNRECOGNIZED; + } +} + +export function fieldDescriptorProto_LabelToJSON( + object: FieldDescriptorProto_Label +): string { + switch (object) { + case FieldDescriptorProto_Label.LABEL_OPTIONAL: + return "LABEL_OPTIONAL"; + case FieldDescriptorProto_Label.LABEL_REQUIRED: + return "LABEL_REQUIRED"; + case FieldDescriptorProto_Label.LABEL_REPEATED: + return "LABEL_REPEATED"; + default: + return "UNKNOWN"; + } +} + +/** Describes a oneof. */ +export interface OneofDescriptorProto { + name: string; + options: OneofOptions | undefined; +} + +/** Describes an enum type. */ +export interface EnumDescriptorProto { + name: string; + value: EnumValueDescriptorProto[]; + options: EnumOptions | undefined; + /** + * Range of reserved numeric values. Reserved numeric values may not be used + * by enum values in the same enum declaration. Reserved ranges may not + * overlap. + */ + reservedRange: EnumDescriptorProto_EnumReservedRange[]; + /** + * Reserved enum value names, which may not be reused. A given name may only + * be reserved once. + */ + reservedName: string[]; +} + +/** + * Range of reserved numeric values. Reserved values may not be used by + * entries in the same enum. Reserved ranges may not overlap. + * + * Note that this is distinct from DescriptorProto.ReservedRange in that it + * is inclusive such that it can appropriately represent the entire int32 + * domain. + */ +export interface EnumDescriptorProto_EnumReservedRange { + /** Inclusive. */ + start: number; + /** Inclusive. */ + end: number; +} + +/** Describes a value within an enum. */ +export interface EnumValueDescriptorProto { + name: string; + number: number; + options: EnumValueOptions | undefined; +} + +/** Describes a service. */ +export interface ServiceDescriptorProto { + name: string; + method: MethodDescriptorProto[]; + options: ServiceOptions | undefined; +} + +/** Describes a method of a service. */ +export interface MethodDescriptorProto { + name: string; + /** + * Input and output type names. These are resolved in the same way as + * FieldDescriptorProto.type_name, but must refer to a message type. + */ + inputType: string; + outputType: string; + options: MethodOptions | undefined; + /** Identifies if client streams multiple client messages */ + clientStreaming: boolean; + /** Identifies if server streams multiple server messages */ + serverStreaming: boolean; +} + +export interface FileOptions { + /** + * Sets the Java package where classes generated from this .proto will be + * placed. By default, the proto package is used, but this is often + * inappropriate because proto packages do not normally start with backwards + * domain names. + */ + javaPackage: string; + /** + * Controls the name of the wrapper Java class generated for the .proto file. + * That class will always contain the .proto file's getDescriptor() method as + * well as any top-level extensions defined in the .proto file. + * If java_multiple_files is disabled, then all the other classes from the + * .proto file will be nested inside the single wrapper outer class. + */ + javaOuterClassname: string; + /** + * If enabled, then the Java code generator will generate a separate .java + * file for each top-level message, enum, and service defined in the .proto + * file. Thus, these types will *not* be nested inside the wrapper class + * named by java_outer_classname. However, the wrapper class will still be + * generated to contain the file's getDescriptor() method as well as any + * top-level extensions defined in the file. + */ + javaMultipleFiles: boolean; + /** + * This option does nothing. + * + * @deprecated + */ + javaGenerateEqualsAndHash: boolean; + /** + * If set true, then the Java2 code generator will generate code that + * throws an exception whenever an attempt is made to assign a non-UTF-8 + * byte sequence to a string field. + * Message reflection will do the same. + * However, an extension field still accepts non-UTF-8 byte sequences. + * This option has no effect on when used with the lite runtime. + */ + javaStringCheckUtf8: boolean; + optimizeFor: FileOptions_OptimizeMode; + /** + * Sets the Go package where structs generated from this .proto will be + * placed. If omitted, the Go package will be derived from the following: + * - The basename of the package import path, if provided. + * - Otherwise, the package statement in the .proto file, if present. + * - Otherwise, the basename of the .proto file, without extension. + */ + goPackage: string; + /** + * Should generic services be generated in each language? "Generic" services + * are not specific to any particular RPC system. They are generated by the + * main code generators in each language (without additional plugins). + * Generic services were the only kind of service generation supported by + * early versions of google.protobuf. + * + * Generic services are now considered deprecated in favor of using plugins + * that generate code specific to your particular RPC system. Therefore, + * these default to false. Old code which depends on generic services should + * explicitly set them to true. + */ + ccGenericServices: boolean; + javaGenericServices: boolean; + pyGenericServices: boolean; + phpGenericServices: boolean; + /** + * Is this file deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for everything in the file, or it will be completely ignored; in the very + * least, this is a formalization for deprecating files. + */ + deprecated: boolean; + /** + * Enables the use of arenas for the proto messages in this file. This applies + * only to generated classes for C++. + */ + ccEnableArenas: boolean; + /** + * Sets the objective c class prefix which is prepended to all objective c + * generated classes from this .proto. There is no default. + */ + objcClassPrefix: string; + /** Namespace for generated classes; defaults to the package. */ + csharpNamespace: string; + /** + * By default Swift generators will take the proto package and CamelCase it + * replacing '.' with underscore and use that to prefix the types/symbols + * defined. When this options is provided, they will use this value instead + * to prefix the types/symbols defined. + */ + swiftPrefix: string; + /** + * Sets the php class prefix which is prepended to all php generated classes + * from this .proto. Default is empty. + */ + phpClassPrefix: string; + /** + * Use this option to change the namespace of php generated classes. Default + * is empty. When this option is empty, the package name will be used for + * determining the namespace. + */ + phpNamespace: string; + /** + * Use this option to change the namespace of php generated metadata classes. + * Default is empty. When this option is empty, the proto file name will be + * used for determining the namespace. + */ + phpMetadataNamespace: string; + /** + * Use this option to change the package of ruby generated classes. Default + * is empty. When this option is not set, the package name will be used for + * determining the ruby package. + */ + rubyPackage: string; + /** + * The parser stores options it doesn't recognize here. + * See the documentation for the "Options" section above. + */ + uninterpretedOption: UninterpretedOption[]; +} + +/** Generated classes can be optimized for speed or code size. */ +export enum FileOptions_OptimizeMode { + /** SPEED - Generate complete code for parsing, serialization, */ + SPEED = 1, + /** CODE_SIZE - etc. */ + CODE_SIZE = 2, + /** LITE_RUNTIME - Generate code using MessageLite and the lite runtime. */ + LITE_RUNTIME = 3, + UNRECOGNIZED = -1, +} + +export function fileOptions_OptimizeModeFromJSON( + object: any +): FileOptions_OptimizeMode { + switch (object) { + case 1: + case "SPEED": + return FileOptions_OptimizeMode.SPEED; + case 2: + case "CODE_SIZE": + return FileOptions_OptimizeMode.CODE_SIZE; + case 3: + case "LITE_RUNTIME": + return FileOptions_OptimizeMode.LITE_RUNTIME; + case -1: + case "UNRECOGNIZED": + default: + return FileOptions_OptimizeMode.UNRECOGNIZED; + } +} + +export function fileOptions_OptimizeModeToJSON( + object: FileOptions_OptimizeMode +): string { + switch (object) { + case FileOptions_OptimizeMode.SPEED: + return "SPEED"; + case FileOptions_OptimizeMode.CODE_SIZE: + return "CODE_SIZE"; + case FileOptions_OptimizeMode.LITE_RUNTIME: + return "LITE_RUNTIME"; + default: + return "UNKNOWN"; + } +} + +export interface MessageOptions { + /** + * Set true to use the old proto1 MessageSet wire format for extensions. + * This is provided for backwards-compatibility with the MessageSet wire + * format. You should not use this for any other reason: It's less + * efficient, has fewer features, and is more complicated. + * + * The message must be defined exactly as follows: + * message Foo { + * option message_set_wire_format = true; + * extensions 4 to max; + * } + * Note that the message cannot have any defined fields; MessageSets only + * have extensions. + * + * All extensions of your type must be singular messages; e.g. they cannot + * be int32s, enums, or repeated messages. + * + * Because this is an option, the above two restrictions are not enforced by + * the protocol compiler. + */ + messageSetWireFormat: boolean; + /** + * Disables the generation of the standard "descriptor()" accessor, which can + * conflict with a field of the same name. This is meant to make migration + * from proto1 easier; new code should avoid fields named "descriptor". + */ + noStandardDescriptorAccessor: boolean; + /** + * Is this message deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the message, or it will be completely ignored; in the very least, + * this is a formalization for deprecating messages. + */ + deprecated: boolean; + /** + * Whether the message is an automatically generated map entry type for the + * maps field. + * + * For maps fields: + * map map_field = 1; + * The parsed descriptor looks like: + * message MapFieldEntry { + * option map_entry = true; + * optional KeyType key = 1; + * optional ValueType value = 2; + * } + * repeated MapFieldEntry map_field = 1; + * + * Implementations may choose not to generate the map_entry=true message, but + * use a native map in the target language to hold the keys and values. + * The reflection APIs in such implementations still need to work as + * if the field is a repeated message field. + * + * NOTE: Do not set the option in .proto files. Always use the maps syntax + * instead. The option should only be implicitly set by the proto compiler + * parser. + */ + mapEntry: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface FieldOptions { + /** + * The ctype option instructs the C++ code generator to use a different + * representation of the field than it normally would. See the specific + * options below. This option is not yet implemented in the open source + * release -- sorry, we'll try to include it in a future version! + */ + ctype: FieldOptions_CType; + /** + * The packed option can be enabled for repeated primitive fields to enable + * a more efficient representation on the wire. Rather than repeatedly + * writing the tag and type for each element, the entire array is encoded as + * a single length-delimited blob. In proto3, only explicit setting it to + * false will avoid using packed encoding. + */ + packed: boolean; + /** + * The jstype option determines the JavaScript type used for values of the + * field. The option is permitted only for 64 bit integral and fixed types + * (int64, uint64, sint64, fixed64, sfixed64). A field with jstype JS_STRING + * is represented as JavaScript string, which avoids loss of precision that + * can happen when a large value is converted to a floating point JavaScript. + * Specifying JS_NUMBER for the jstype causes the generated JavaScript code to + * use the JavaScript "number" type. The behavior of the default option + * JS_NORMAL is implementation dependent. + * + * This option is an enum to permit additional types to be added, e.g. + * goog.math.Integer. + */ + jstype: FieldOptions_JSType; + /** + * Should this field be parsed lazily? Lazy applies only to message-type + * fields. It means that when the outer message is initially parsed, the + * inner message's contents will not be parsed but instead stored in encoded + * form. The inner message will actually be parsed when it is first accessed. + * + * This is only a hint. Implementations are free to choose whether to use + * eager or lazy parsing regardless of the value of this option. However, + * setting this option true suggests that the protocol author believes that + * using lazy parsing on this field is worth the additional bookkeeping + * overhead typically needed to implement it. + * + * This option does not affect the public interface of any generated code; + * all method signatures remain the same. Furthermore, thread-safety of the + * interface is not affected by this option; const methods remain safe to + * call from multiple threads concurrently, while non-const methods continue + * to require exclusive access. + * + * + * Note that implementations may choose not to check required fields within + * a lazy sub-message. That is, calling IsInitialized() on the outer message + * may return true even if the inner message has missing required fields. + * This is necessary because otherwise the inner message would have to be + * parsed in order to perform the check, defeating the purpose of lazy + * parsing. An implementation which chooses not to check required fields + * must be consistent about it. That is, for any particular sub-message, the + * implementation must either *always* check its required fields, or *never* + * check its required fields, regardless of whether or not the message has + * been parsed. + */ + lazy: boolean; + /** + * Is this field deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for accessors, or it will be completely ignored; in the very least, this + * is a formalization for deprecating fields. + */ + deprecated: boolean; + /** For Google-internal migration only. Do not use. */ + weak: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export enum FieldOptions_CType { + /** STRING - Default mode. */ + STRING = 0, + CORD = 1, + STRING_PIECE = 2, + UNRECOGNIZED = -1, +} + +export function fieldOptions_CTypeFromJSON(object: any): FieldOptions_CType { + switch (object) { + case 0: + case "STRING": + return FieldOptions_CType.STRING; + case 1: + case "CORD": + return FieldOptions_CType.CORD; + case 2: + case "STRING_PIECE": + return FieldOptions_CType.STRING_PIECE; + case -1: + case "UNRECOGNIZED": + default: + return FieldOptions_CType.UNRECOGNIZED; + } +} + +export function fieldOptions_CTypeToJSON(object: FieldOptions_CType): string { + switch (object) { + case FieldOptions_CType.STRING: + return "STRING"; + case FieldOptions_CType.CORD: + return "CORD"; + case FieldOptions_CType.STRING_PIECE: + return "STRING_PIECE"; + default: + return "UNKNOWN"; + } +} + +export enum FieldOptions_JSType { + /** JS_NORMAL - Use the default type. */ + JS_NORMAL = 0, + /** JS_STRING - Use JavaScript strings. */ + JS_STRING = 1, + /** JS_NUMBER - Use JavaScript numbers. */ + JS_NUMBER = 2, + UNRECOGNIZED = -1, +} + +export function fieldOptions_JSTypeFromJSON(object: any): FieldOptions_JSType { + switch (object) { + case 0: + case "JS_NORMAL": + return FieldOptions_JSType.JS_NORMAL; + case 1: + case "JS_STRING": + return FieldOptions_JSType.JS_STRING; + case 2: + case "JS_NUMBER": + return FieldOptions_JSType.JS_NUMBER; + case -1: + case "UNRECOGNIZED": + default: + return FieldOptions_JSType.UNRECOGNIZED; + } +} + +export function fieldOptions_JSTypeToJSON(object: FieldOptions_JSType): string { + switch (object) { + case FieldOptions_JSType.JS_NORMAL: + return "JS_NORMAL"; + case FieldOptions_JSType.JS_STRING: + return "JS_STRING"; + case FieldOptions_JSType.JS_NUMBER: + return "JS_NUMBER"; + default: + return "UNKNOWN"; + } +} + +export interface OneofOptions { + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface EnumOptions { + /** + * Set this option to true to allow mapping different tag names to the same + * value. + */ + allowAlias: boolean; + /** + * Is this enum deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the enum, or it will be completely ignored; in the very least, this + * is a formalization for deprecating enums. + */ + deprecated: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface EnumValueOptions { + /** + * Is this enum value deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the enum value, or it will be completely ignored; in the very least, + * this is a formalization for deprecating enum values. + */ + deprecated: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface ServiceOptions { + /** + * Is this service deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the service, or it will be completely ignored; in the very least, + * this is a formalization for deprecating services. + */ + deprecated: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface MethodOptions { + /** + * Is this method deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the method, or it will be completely ignored; in the very least, + * this is a formalization for deprecating methods. + */ + deprecated: boolean; + idempotencyLevel: MethodOptions_IdempotencyLevel; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +/** + * Is this method side-effect-free (or safe in HTTP parlance), or idempotent, + * or neither? HTTP based RPC implementation may choose GET verb for safe + * methods, and PUT verb for idempotent methods instead of the default POST. + */ +export enum MethodOptions_IdempotencyLevel { + IDEMPOTENCY_UNKNOWN = 0, + /** NO_SIDE_EFFECTS - implies idempotent */ + NO_SIDE_EFFECTS = 1, + /** IDEMPOTENT - idempotent, but may have side effects */ + IDEMPOTENT = 2, + UNRECOGNIZED = -1, +} + +export function methodOptions_IdempotencyLevelFromJSON( + object: any +): MethodOptions_IdempotencyLevel { + switch (object) { + case 0: + case "IDEMPOTENCY_UNKNOWN": + return MethodOptions_IdempotencyLevel.IDEMPOTENCY_UNKNOWN; + case 1: + case "NO_SIDE_EFFECTS": + return MethodOptions_IdempotencyLevel.NO_SIDE_EFFECTS; + case 2: + case "IDEMPOTENT": + return MethodOptions_IdempotencyLevel.IDEMPOTENT; + case -1: + case "UNRECOGNIZED": + default: + return MethodOptions_IdempotencyLevel.UNRECOGNIZED; + } +} + +export function methodOptions_IdempotencyLevelToJSON( + object: MethodOptions_IdempotencyLevel +): string { + switch (object) { + case MethodOptions_IdempotencyLevel.IDEMPOTENCY_UNKNOWN: + return "IDEMPOTENCY_UNKNOWN"; + case MethodOptions_IdempotencyLevel.NO_SIDE_EFFECTS: + return "NO_SIDE_EFFECTS"; + case MethodOptions_IdempotencyLevel.IDEMPOTENT: + return "IDEMPOTENT"; + default: + return "UNKNOWN"; + } +} + +/** + * A message representing a option the parser does not recognize. This only + * appears in options protos created by the compiler::Parser class. + * DescriptorPool resolves these when building Descriptor objects. Therefore, + * options protos in descriptor objects (e.g. returned by Descriptor::options(), + * or produced by Descriptor::CopyTo()) will never have UninterpretedOptions + * in them. + */ +export interface UninterpretedOption { + name: UninterpretedOption_NamePart[]; + /** + * The value of the uninterpreted option, in whatever type the tokenizer + * identified it as during parsing. Exactly one of these should be set. + */ + identifierValue: string; + positiveIntValue: number; + negativeIntValue: number; + doubleValue: number; + stringValue: Uint8Array; + aggregateValue: string; +} + +/** + * The name of the uninterpreted option. Each string represents a segment in + * a dot-separated name. is_extension is true iff a segment represents an + * extension (denoted with parentheses in options specs in .proto files). + * E.g.,{ ["foo", false], ["bar.baz", true], ["qux", false] } represents + * "foo.(bar.baz).qux". + */ +export interface UninterpretedOption_NamePart { + namePart: string; + isExtension: boolean; +} + +/** + * Encapsulates information about the original source file from which a + * FileDescriptorProto was generated. + */ +export interface SourceCodeInfo { + /** + * A Location identifies a piece of source code in a .proto file which + * corresponds to a particular definition. This information is intended + * to be useful to IDEs, code indexers, documentation generators, and similar + * tools. + * + * For example, say we have a file like: + * message Foo { + * optional string foo = 1; + * } + * Let's look at just the field definition: + * optional string foo = 1; + * ^ ^^ ^^ ^ ^^^ + * a bc de f ghi + * We have the following locations: + * span path represents + * [a,i) [ 4, 0, 2, 0 ] The whole field definition. + * [a,b) [ 4, 0, 2, 0, 4 ] The label (optional). + * [c,d) [ 4, 0, 2, 0, 5 ] The type (string). + * [e,f) [ 4, 0, 2, 0, 1 ] The name (foo). + * [g,h) [ 4, 0, 2, 0, 3 ] The number (1). + * + * Notes: + * - A location may refer to a repeated field itself (i.e. not to any + * particular index within it). This is used whenever a set of elements are + * logically enclosed in a single code segment. For example, an entire + * extend block (possibly containing multiple extension definitions) will + * have an outer location whose path refers to the "extensions" repeated + * field without an index. + * - Multiple locations may have the same path. This happens when a single + * logical declaration is spread out across multiple places. The most + * obvious example is the "extend" block again -- there may be multiple + * extend blocks in the same scope, each of which will have the same path. + * - A location's span is not always a subset of its parent's span. For + * example, the "extendee" of an extension declaration appears at the + * beginning of the "extend" block and is shared by all extensions within + * the block. + * - Just because a location's span is a subset of some other location's span + * does not mean that it is a descendant. For example, a "group" defines + * both a type and a field in a single declaration. Thus, the locations + * corresponding to the type and field and their components will overlap. + * - Code which tries to interpret locations should probably be designed to + * ignore those that it doesn't understand, as more types of locations could + * be recorded in the future. + */ + location: SourceCodeInfo_Location[]; +} + +export interface SourceCodeInfo_Location { + /** + * Identifies which part of the FileDescriptorProto was defined at this + * location. + * + * Each element is a field number or an index. They form a path from + * the root FileDescriptorProto to the place where the definition. For + * example, this path: + * [ 4, 3, 2, 7, 1 ] + * refers to: + * file.message_type(3) // 4, 3 + * .field(7) // 2, 7 + * .name() // 1 + * This is because FileDescriptorProto.message_type has field number 4: + * repeated DescriptorProto message_type = 4; + * and DescriptorProto.field has field number 2: + * repeated FieldDescriptorProto field = 2; + * and FieldDescriptorProto.name has field number 1: + * optional string name = 1; + * + * Thus, the above path gives the location of a field name. If we removed + * the last element: + * [ 4, 3, 2, 7 ] + * this path refers to the whole field declaration (from the beginning + * of the label to the terminating semicolon). + */ + path: number[]; + /** + * Always has exactly three or four elements: start line, start column, + * end line (optional, otherwise assumed same as start line), end column. + * These are packed into a single field for efficiency. Note that line + * and column numbers are zero-based -- typically you will want to add + * 1 to each before displaying to a user. + */ + span: number[]; + /** + * If this SourceCodeInfo represents a complete declaration, these are any + * comments appearing before and after the declaration which appear to be + * attached to the declaration. + * + * A series of line comments appearing on consecutive lines, with no other + * tokens appearing on those lines, will be treated as a single comment. + * + * leading_detached_comments will keep paragraphs of comments that appear + * before (but not connected to) the current element. Each paragraph, + * separated by empty lines, will be one comment element in the repeated + * field. + * + * Only the comment content is provided; comment markers (e.g. //) are + * stripped out. For block comments, leading whitespace and an asterisk + * will be stripped from the beginning of each line other than the first. + * Newlines are included in the output. + * + * Examples: + * + * optional int32 foo = 1; // Comment attached to foo. + * // Comment attached to bar. + * optional int32 bar = 2; + * + * optional string baz = 3; + * // Comment attached to baz. + * // Another line attached to baz. + * + * // Comment attached to qux. + * // + * // Another line attached to qux. + * optional double qux = 4; + * + * // Detached comment for corge. This is not leading or trailing comments + * // to qux or corge because there are blank lines separating it from + * // both. + * + * // Detached comment for corge paragraph 2. + * + * optional string corge = 5; + * /* Block comment attached + * * to corge. Leading asterisks + * * will be removed. * / + * /* Block comment attached to + * * grault. * / + * optional int32 grault = 6; + * + * // ignored detached comments. + */ + leadingComments: string; + trailingComments: string; + leadingDetachedComments: string[]; +} + +/** + * Describes the relationship between generated code and its original source + * file. A GeneratedCodeInfo message is associated with only one generated + * source file, but may contain references to different source .proto files. + */ +export interface GeneratedCodeInfo { + /** + * An Annotation connects some span of text in generated code to an element + * of its generating .proto file. + */ + annotation: GeneratedCodeInfo_Annotation[]; +} + +export interface GeneratedCodeInfo_Annotation { + /** + * Identifies the element in the original source .proto file. This field + * is formatted the same as SourceCodeInfo.Location.path. + */ + path: number[]; + /** Identifies the filesystem path to the original source .proto. */ + sourceFile: string; + /** + * Identifies the starting offset in bytes in the generated code + * that relates to the identified object. + */ + begin: number; + /** + * Identifies the ending offset in bytes in the generated code that + * relates to the identified offset. The end offset should be one past + * the last relevant byte (so the length of the text = end - begin). + */ + end: number; +} + +const baseFileDescriptorSet: object = {}; + +export const FileDescriptorSet = { + encode(message: FileDescriptorSet, writer: Writer = Writer.create()): Writer { + for (const v of message.file) { + FileDescriptorProto.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FileDescriptorSet { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFileDescriptorSet } as FileDescriptorSet; + message.file = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.file.push( + FileDescriptorProto.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FileDescriptorSet { + const message = { ...baseFileDescriptorSet } as FileDescriptorSet; + message.file = []; + if (object.file !== undefined && object.file !== null) { + for (const e of object.file) { + message.file.push(FileDescriptorProto.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: FileDescriptorSet): unknown { + const obj: any = {}; + if (message.file) { + obj.file = message.file.map((e) => + e ? FileDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.file = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): FileDescriptorSet { + const message = { ...baseFileDescriptorSet } as FileDescriptorSet; + message.file = []; + if (object.file !== undefined && object.file !== null) { + for (const e of object.file) { + message.file.push(FileDescriptorProto.fromPartial(e)); + } + } + return message; + }, +}; + +const baseFileDescriptorProto: object = { + name: "", + package: "", + dependency: "", + publicDependency: 0, + weakDependency: 0, + syntax: "", +}; + +export const FileDescriptorProto = { + encode( + message: FileDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.package !== "") { + writer.uint32(18).string(message.package); + } + for (const v of message.dependency) { + writer.uint32(26).string(v!); + } + writer.uint32(82).fork(); + for (const v of message.publicDependency) { + writer.int32(v); + } + writer.ldelim(); + writer.uint32(90).fork(); + for (const v of message.weakDependency) { + writer.int32(v); + } + writer.ldelim(); + for (const v of message.messageType) { + DescriptorProto.encode(v!, writer.uint32(34).fork()).ldelim(); + } + for (const v of message.enumType) { + EnumDescriptorProto.encode(v!, writer.uint32(42).fork()).ldelim(); + } + for (const v of message.service) { + ServiceDescriptorProto.encode(v!, writer.uint32(50).fork()).ldelim(); + } + for (const v of message.extension) { + FieldDescriptorProto.encode(v!, writer.uint32(58).fork()).ldelim(); + } + if (message.options !== undefined) { + FileOptions.encode(message.options, writer.uint32(66).fork()).ldelim(); + } + if (message.sourceCodeInfo !== undefined) { + SourceCodeInfo.encode( + message.sourceCodeInfo, + writer.uint32(74).fork() + ).ldelim(); + } + if (message.syntax !== "") { + writer.uint32(98).string(message.syntax); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FileDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFileDescriptorProto } as FileDescriptorProto; + message.dependency = []; + message.publicDependency = []; + message.weakDependency = []; + message.messageType = []; + message.enumType = []; + message.service = []; + message.extension = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.package = reader.string(); + break; + case 3: + message.dependency.push(reader.string()); + break; + case 10: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.publicDependency.push(reader.int32()); + } + } else { + message.publicDependency.push(reader.int32()); + } + break; + case 11: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.weakDependency.push(reader.int32()); + } + } else { + message.weakDependency.push(reader.int32()); + } + break; + case 4: + message.messageType.push( + DescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 5: + message.enumType.push( + EnumDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 6: + message.service.push( + ServiceDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 7: + message.extension.push( + FieldDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 8: + message.options = FileOptions.decode(reader, reader.uint32()); + break; + case 9: + message.sourceCodeInfo = SourceCodeInfo.decode( + reader, + reader.uint32() + ); + break; + case 12: + message.syntax = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FileDescriptorProto { + const message = { ...baseFileDescriptorProto } as FileDescriptorProto; + message.dependency = []; + message.publicDependency = []; + message.weakDependency = []; + message.messageType = []; + message.enumType = []; + message.service = []; + message.extension = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.package !== undefined && object.package !== null) { + message.package = String(object.package); + } else { + message.package = ""; + } + if (object.dependency !== undefined && object.dependency !== null) { + for (const e of object.dependency) { + message.dependency.push(String(e)); + } + } + if ( + object.publicDependency !== undefined && + object.publicDependency !== null + ) { + for (const e of object.publicDependency) { + message.publicDependency.push(Number(e)); + } + } + if (object.weakDependency !== undefined && object.weakDependency !== null) { + for (const e of object.weakDependency) { + message.weakDependency.push(Number(e)); + } + } + if (object.messageType !== undefined && object.messageType !== null) { + for (const e of object.messageType) { + message.messageType.push(DescriptorProto.fromJSON(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromJSON(e)); + } + } + if (object.service !== undefined && object.service !== null) { + for (const e of object.service) { + message.service.push(ServiceDescriptorProto.fromJSON(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = FileOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.sourceCodeInfo !== undefined && object.sourceCodeInfo !== null) { + message.sourceCodeInfo = SourceCodeInfo.fromJSON(object.sourceCodeInfo); + } else { + message.sourceCodeInfo = undefined; + } + if (object.syntax !== undefined && object.syntax !== null) { + message.syntax = String(object.syntax); + } else { + message.syntax = ""; + } + return message; + }, + + toJSON(message: FileDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.package !== undefined && (obj.package = message.package); + if (message.dependency) { + obj.dependency = message.dependency.map((e) => e); + } else { + obj.dependency = []; + } + if (message.publicDependency) { + obj.publicDependency = message.publicDependency.map((e) => e); + } else { + obj.publicDependency = []; + } + if (message.weakDependency) { + obj.weakDependency = message.weakDependency.map((e) => e); + } else { + obj.weakDependency = []; + } + if (message.messageType) { + obj.messageType = message.messageType.map((e) => + e ? DescriptorProto.toJSON(e) : undefined + ); + } else { + obj.messageType = []; + } + if (message.enumType) { + obj.enumType = message.enumType.map((e) => + e ? EnumDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.enumType = []; + } + if (message.service) { + obj.service = message.service.map((e) => + e ? ServiceDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.service = []; + } + if (message.extension) { + obj.extension = message.extension.map((e) => + e ? FieldDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.extension = []; + } + message.options !== undefined && + (obj.options = message.options + ? FileOptions.toJSON(message.options) + : undefined); + message.sourceCodeInfo !== undefined && + (obj.sourceCodeInfo = message.sourceCodeInfo + ? SourceCodeInfo.toJSON(message.sourceCodeInfo) + : undefined); + message.syntax !== undefined && (obj.syntax = message.syntax); + return obj; + }, + + fromPartial(object: DeepPartial): FileDescriptorProto { + const message = { ...baseFileDescriptorProto } as FileDescriptorProto; + message.dependency = []; + message.publicDependency = []; + message.weakDependency = []; + message.messageType = []; + message.enumType = []; + message.service = []; + message.extension = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.package !== undefined && object.package !== null) { + message.package = object.package; + } else { + message.package = ""; + } + if (object.dependency !== undefined && object.dependency !== null) { + for (const e of object.dependency) { + message.dependency.push(e); + } + } + if ( + object.publicDependency !== undefined && + object.publicDependency !== null + ) { + for (const e of object.publicDependency) { + message.publicDependency.push(e); + } + } + if (object.weakDependency !== undefined && object.weakDependency !== null) { + for (const e of object.weakDependency) { + message.weakDependency.push(e); + } + } + if (object.messageType !== undefined && object.messageType !== null) { + for (const e of object.messageType) { + message.messageType.push(DescriptorProto.fromPartial(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromPartial(e)); + } + } + if (object.service !== undefined && object.service !== null) { + for (const e of object.service) { + message.service.push(ServiceDescriptorProto.fromPartial(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = FileOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.sourceCodeInfo !== undefined && object.sourceCodeInfo !== null) { + message.sourceCodeInfo = SourceCodeInfo.fromPartial( + object.sourceCodeInfo + ); + } else { + message.sourceCodeInfo = undefined; + } + if (object.syntax !== undefined && object.syntax !== null) { + message.syntax = object.syntax; + } else { + message.syntax = ""; + } + return message; + }, +}; + +const baseDescriptorProto: object = { name: "", reservedName: "" }; + +export const DescriptorProto = { + encode(message: DescriptorProto, writer: Writer = Writer.create()): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + for (const v of message.field) { + FieldDescriptorProto.encode(v!, writer.uint32(18).fork()).ldelim(); + } + for (const v of message.extension) { + FieldDescriptorProto.encode(v!, writer.uint32(50).fork()).ldelim(); + } + for (const v of message.nestedType) { + DescriptorProto.encode(v!, writer.uint32(26).fork()).ldelim(); + } + for (const v of message.enumType) { + EnumDescriptorProto.encode(v!, writer.uint32(34).fork()).ldelim(); + } + for (const v of message.extensionRange) { + DescriptorProto_ExtensionRange.encode( + v!, + writer.uint32(42).fork() + ).ldelim(); + } + for (const v of message.oneofDecl) { + OneofDescriptorProto.encode(v!, writer.uint32(66).fork()).ldelim(); + } + if (message.options !== undefined) { + MessageOptions.encode(message.options, writer.uint32(58).fork()).ldelim(); + } + for (const v of message.reservedRange) { + DescriptorProto_ReservedRange.encode( + v!, + writer.uint32(74).fork() + ).ldelim(); + } + for (const v of message.reservedName) { + writer.uint32(82).string(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): DescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseDescriptorProto } as DescriptorProto; + message.field = []; + message.extension = []; + message.nestedType = []; + message.enumType = []; + message.extensionRange = []; + message.oneofDecl = []; + message.reservedRange = []; + message.reservedName = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.field.push( + FieldDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 6: + message.extension.push( + FieldDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 3: + message.nestedType.push( + DescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 4: + message.enumType.push( + EnumDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 5: + message.extensionRange.push( + DescriptorProto_ExtensionRange.decode(reader, reader.uint32()) + ); + break; + case 8: + message.oneofDecl.push( + OneofDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 7: + message.options = MessageOptions.decode(reader, reader.uint32()); + break; + case 9: + message.reservedRange.push( + DescriptorProto_ReservedRange.decode(reader, reader.uint32()) + ); + break; + case 10: + message.reservedName.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DescriptorProto { + const message = { ...baseDescriptorProto } as DescriptorProto; + message.field = []; + message.extension = []; + message.nestedType = []; + message.enumType = []; + message.extensionRange = []; + message.oneofDecl = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.field !== undefined && object.field !== null) { + for (const e of object.field) { + message.field.push(FieldDescriptorProto.fromJSON(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromJSON(e)); + } + } + if (object.nestedType !== undefined && object.nestedType !== null) { + for (const e of object.nestedType) { + message.nestedType.push(DescriptorProto.fromJSON(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromJSON(e)); + } + } + if (object.extensionRange !== undefined && object.extensionRange !== null) { + for (const e of object.extensionRange) { + message.extensionRange.push(DescriptorProto_ExtensionRange.fromJSON(e)); + } + } + if (object.oneofDecl !== undefined && object.oneofDecl !== null) { + for (const e of object.oneofDecl) { + message.oneofDecl.push(OneofDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = MessageOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push(DescriptorProto_ReservedRange.fromJSON(e)); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(String(e)); + } + } + return message; + }, + + toJSON(message: DescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + if (message.field) { + obj.field = message.field.map((e) => + e ? FieldDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.field = []; + } + if (message.extension) { + obj.extension = message.extension.map((e) => + e ? FieldDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.extension = []; + } + if (message.nestedType) { + obj.nestedType = message.nestedType.map((e) => + e ? DescriptorProto.toJSON(e) : undefined + ); + } else { + obj.nestedType = []; + } + if (message.enumType) { + obj.enumType = message.enumType.map((e) => + e ? EnumDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.enumType = []; + } + if (message.extensionRange) { + obj.extensionRange = message.extensionRange.map((e) => + e ? DescriptorProto_ExtensionRange.toJSON(e) : undefined + ); + } else { + obj.extensionRange = []; + } + if (message.oneofDecl) { + obj.oneofDecl = message.oneofDecl.map((e) => + e ? OneofDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.oneofDecl = []; + } + message.options !== undefined && + (obj.options = message.options + ? MessageOptions.toJSON(message.options) + : undefined); + if (message.reservedRange) { + obj.reservedRange = message.reservedRange.map((e) => + e ? DescriptorProto_ReservedRange.toJSON(e) : undefined + ); + } else { + obj.reservedRange = []; + } + if (message.reservedName) { + obj.reservedName = message.reservedName.map((e) => e); + } else { + obj.reservedName = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): DescriptorProto { + const message = { ...baseDescriptorProto } as DescriptorProto; + message.field = []; + message.extension = []; + message.nestedType = []; + message.enumType = []; + message.extensionRange = []; + message.oneofDecl = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.field !== undefined && object.field !== null) { + for (const e of object.field) { + message.field.push(FieldDescriptorProto.fromPartial(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromPartial(e)); + } + } + if (object.nestedType !== undefined && object.nestedType !== null) { + for (const e of object.nestedType) { + message.nestedType.push(DescriptorProto.fromPartial(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromPartial(e)); + } + } + if (object.extensionRange !== undefined && object.extensionRange !== null) { + for (const e of object.extensionRange) { + message.extensionRange.push( + DescriptorProto_ExtensionRange.fromPartial(e) + ); + } + } + if (object.oneofDecl !== undefined && object.oneofDecl !== null) { + for (const e of object.oneofDecl) { + message.oneofDecl.push(OneofDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = MessageOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push( + DescriptorProto_ReservedRange.fromPartial(e) + ); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(e); + } + } + return message; + }, +}; + +const baseDescriptorProto_ExtensionRange: object = { start: 0, end: 0 }; + +export const DescriptorProto_ExtensionRange = { + encode( + message: DescriptorProto_ExtensionRange, + writer: Writer = Writer.create() + ): Writer { + if (message.start !== 0) { + writer.uint32(8).int32(message.start); + } + if (message.end !== 0) { + writer.uint32(16).int32(message.end); + } + if (message.options !== undefined) { + ExtensionRangeOptions.encode( + message.options, + writer.uint32(26).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): DescriptorProto_ExtensionRange { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseDescriptorProto_ExtensionRange, + } as DescriptorProto_ExtensionRange; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.start = reader.int32(); + break; + case 2: + message.end = reader.int32(); + break; + case 3: + message.options = ExtensionRangeOptions.decode( + reader, + reader.uint32() + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DescriptorProto_ExtensionRange { + const message = { + ...baseDescriptorProto_ExtensionRange, + } as DescriptorProto_ExtensionRange; + if (object.start !== undefined && object.start !== null) { + message.start = Number(object.start); + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = ExtensionRangeOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: DescriptorProto_ExtensionRange): unknown { + const obj: any = {}; + message.start !== undefined && (obj.start = message.start); + message.end !== undefined && (obj.end = message.end); + message.options !== undefined && + (obj.options = message.options + ? ExtensionRangeOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): DescriptorProto_ExtensionRange { + const message = { + ...baseDescriptorProto_ExtensionRange, + } as DescriptorProto_ExtensionRange; + if (object.start !== undefined && object.start !== null) { + message.start = object.start; + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = ExtensionRangeOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseDescriptorProto_ReservedRange: object = { start: 0, end: 0 }; + +export const DescriptorProto_ReservedRange = { + encode( + message: DescriptorProto_ReservedRange, + writer: Writer = Writer.create() + ): Writer { + if (message.start !== 0) { + writer.uint32(8).int32(message.start); + } + if (message.end !== 0) { + writer.uint32(16).int32(message.end); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): DescriptorProto_ReservedRange { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseDescriptorProto_ReservedRange, + } as DescriptorProto_ReservedRange; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.start = reader.int32(); + break; + case 2: + message.end = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DescriptorProto_ReservedRange { + const message = { + ...baseDescriptorProto_ReservedRange, + } as DescriptorProto_ReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = Number(object.start); + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + return message; + }, + + toJSON(message: DescriptorProto_ReservedRange): unknown { + const obj: any = {}; + message.start !== undefined && (obj.start = message.start); + message.end !== undefined && (obj.end = message.end); + return obj; + }, + + fromPartial( + object: DeepPartial + ): DescriptorProto_ReservedRange { + const message = { + ...baseDescriptorProto_ReservedRange, + } as DescriptorProto_ReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = object.start; + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + return message; + }, +}; + +const baseExtensionRangeOptions: object = {}; + +export const ExtensionRangeOptions = { + encode( + message: ExtensionRangeOptions, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ExtensionRangeOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseExtensionRangeOptions } as ExtensionRangeOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ExtensionRangeOptions { + const message = { ...baseExtensionRangeOptions } as ExtensionRangeOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: ExtensionRangeOptions): unknown { + const obj: any = {}; + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial( + object: DeepPartial + ): ExtensionRangeOptions { + const message = { ...baseExtensionRangeOptions } as ExtensionRangeOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseFieldDescriptorProto: object = { + name: "", + number: 0, + label: 1, + type: 1, + typeName: "", + extendee: "", + defaultValue: "", + oneofIndex: 0, + jsonName: "", + proto3Optional: false, +}; + +export const FieldDescriptorProto = { + encode( + message: FieldDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.number !== 0) { + writer.uint32(24).int32(message.number); + } + if (message.label !== 1) { + writer.uint32(32).int32(message.label); + } + if (message.type !== 1) { + writer.uint32(40).int32(message.type); + } + if (message.typeName !== "") { + writer.uint32(50).string(message.typeName); + } + if (message.extendee !== "") { + writer.uint32(18).string(message.extendee); + } + if (message.defaultValue !== "") { + writer.uint32(58).string(message.defaultValue); + } + if (message.oneofIndex !== 0) { + writer.uint32(72).int32(message.oneofIndex); + } + if (message.jsonName !== "") { + writer.uint32(82).string(message.jsonName); + } + if (message.options !== undefined) { + FieldOptions.encode(message.options, writer.uint32(66).fork()).ldelim(); + } + if (message.proto3Optional === true) { + writer.uint32(136).bool(message.proto3Optional); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FieldDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFieldDescriptorProto } as FieldDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 3: + message.number = reader.int32(); + break; + case 4: + message.label = reader.int32() as any; + break; + case 5: + message.type = reader.int32() as any; + break; + case 6: + message.typeName = reader.string(); + break; + case 2: + message.extendee = reader.string(); + break; + case 7: + message.defaultValue = reader.string(); + break; + case 9: + message.oneofIndex = reader.int32(); + break; + case 10: + message.jsonName = reader.string(); + break; + case 8: + message.options = FieldOptions.decode(reader, reader.uint32()); + break; + case 17: + message.proto3Optional = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FieldDescriptorProto { + const message = { ...baseFieldDescriptorProto } as FieldDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = Number(object.number); + } else { + message.number = 0; + } + if (object.label !== undefined && object.label !== null) { + message.label = fieldDescriptorProto_LabelFromJSON(object.label); + } else { + message.label = 1; + } + if (object.type !== undefined && object.type !== null) { + message.type = fieldDescriptorProto_TypeFromJSON(object.type); + } else { + message.type = 1; + } + if (object.typeName !== undefined && object.typeName !== null) { + message.typeName = String(object.typeName); + } else { + message.typeName = ""; + } + if (object.extendee !== undefined && object.extendee !== null) { + message.extendee = String(object.extendee); + } else { + message.extendee = ""; + } + if (object.defaultValue !== undefined && object.defaultValue !== null) { + message.defaultValue = String(object.defaultValue); + } else { + message.defaultValue = ""; + } + if (object.oneofIndex !== undefined && object.oneofIndex !== null) { + message.oneofIndex = Number(object.oneofIndex); + } else { + message.oneofIndex = 0; + } + if (object.jsonName !== undefined && object.jsonName !== null) { + message.jsonName = String(object.jsonName); + } else { + message.jsonName = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = FieldOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.proto3Optional !== undefined && object.proto3Optional !== null) { + message.proto3Optional = Boolean(object.proto3Optional); + } else { + message.proto3Optional = false; + } + return message; + }, + + toJSON(message: FieldDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.number !== undefined && (obj.number = message.number); + message.label !== undefined && + (obj.label = fieldDescriptorProto_LabelToJSON(message.label)); + message.type !== undefined && + (obj.type = fieldDescriptorProto_TypeToJSON(message.type)); + message.typeName !== undefined && (obj.typeName = message.typeName); + message.extendee !== undefined && (obj.extendee = message.extendee); + message.defaultValue !== undefined && + (obj.defaultValue = message.defaultValue); + message.oneofIndex !== undefined && (obj.oneofIndex = message.oneofIndex); + message.jsonName !== undefined && (obj.jsonName = message.jsonName); + message.options !== undefined && + (obj.options = message.options + ? FieldOptions.toJSON(message.options) + : undefined); + message.proto3Optional !== undefined && + (obj.proto3Optional = message.proto3Optional); + return obj; + }, + + fromPartial(object: DeepPartial): FieldDescriptorProto { + const message = { ...baseFieldDescriptorProto } as FieldDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = object.number; + } else { + message.number = 0; + } + if (object.label !== undefined && object.label !== null) { + message.label = object.label; + } else { + message.label = 1; + } + if (object.type !== undefined && object.type !== null) { + message.type = object.type; + } else { + message.type = 1; + } + if (object.typeName !== undefined && object.typeName !== null) { + message.typeName = object.typeName; + } else { + message.typeName = ""; + } + if (object.extendee !== undefined && object.extendee !== null) { + message.extendee = object.extendee; + } else { + message.extendee = ""; + } + if (object.defaultValue !== undefined && object.defaultValue !== null) { + message.defaultValue = object.defaultValue; + } else { + message.defaultValue = ""; + } + if (object.oneofIndex !== undefined && object.oneofIndex !== null) { + message.oneofIndex = object.oneofIndex; + } else { + message.oneofIndex = 0; + } + if (object.jsonName !== undefined && object.jsonName !== null) { + message.jsonName = object.jsonName; + } else { + message.jsonName = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = FieldOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.proto3Optional !== undefined && object.proto3Optional !== null) { + message.proto3Optional = object.proto3Optional; + } else { + message.proto3Optional = false; + } + return message; + }, +}; + +const baseOneofDescriptorProto: object = { name: "" }; + +export const OneofDescriptorProto = { + encode( + message: OneofDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.options !== undefined) { + OneofOptions.encode(message.options, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): OneofDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseOneofDescriptorProto } as OneofDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.options = OneofOptions.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): OneofDescriptorProto { + const message = { ...baseOneofDescriptorProto } as OneofDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = OneofOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: OneofDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.options !== undefined && + (obj.options = message.options + ? OneofOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): OneofDescriptorProto { + const message = { ...baseOneofDescriptorProto } as OneofDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = OneofOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseEnumDescriptorProto: object = { name: "", reservedName: "" }; + +export const EnumDescriptorProto = { + encode( + message: EnumDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + for (const v of message.value) { + EnumValueDescriptorProto.encode(v!, writer.uint32(18).fork()).ldelim(); + } + if (message.options !== undefined) { + EnumOptions.encode(message.options, writer.uint32(26).fork()).ldelim(); + } + for (const v of message.reservedRange) { + EnumDescriptorProto_EnumReservedRange.encode( + v!, + writer.uint32(34).fork() + ).ldelim(); + } + for (const v of message.reservedName) { + writer.uint32(42).string(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): EnumDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseEnumDescriptorProto } as EnumDescriptorProto; + message.value = []; + message.reservedRange = []; + message.reservedName = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.value.push( + EnumValueDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 3: + message.options = EnumOptions.decode(reader, reader.uint32()); + break; + case 4: + message.reservedRange.push( + EnumDescriptorProto_EnumReservedRange.decode( + reader, + reader.uint32() + ) + ); + break; + case 5: + message.reservedName.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumDescriptorProto { + const message = { ...baseEnumDescriptorProto } as EnumDescriptorProto; + message.value = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.value !== undefined && object.value !== null) { + for (const e of object.value) { + message.value.push(EnumValueDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push( + EnumDescriptorProto_EnumReservedRange.fromJSON(e) + ); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(String(e)); + } + } + return message; + }, + + toJSON(message: EnumDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + if (message.value) { + obj.value = message.value.map((e) => + e ? EnumValueDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.value = []; + } + message.options !== undefined && + (obj.options = message.options + ? EnumOptions.toJSON(message.options) + : undefined); + if (message.reservedRange) { + obj.reservedRange = message.reservedRange.map((e) => + e ? EnumDescriptorProto_EnumReservedRange.toJSON(e) : undefined + ); + } else { + obj.reservedRange = []; + } + if (message.reservedName) { + obj.reservedName = message.reservedName.map((e) => e); + } else { + obj.reservedName = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): EnumDescriptorProto { + const message = { ...baseEnumDescriptorProto } as EnumDescriptorProto; + message.value = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.value !== undefined && object.value !== null) { + for (const e of object.value) { + message.value.push(EnumValueDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push( + EnumDescriptorProto_EnumReservedRange.fromPartial(e) + ); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(e); + } + } + return message; + }, +}; + +const baseEnumDescriptorProto_EnumReservedRange: object = { start: 0, end: 0 }; + +export const EnumDescriptorProto_EnumReservedRange = { + encode( + message: EnumDescriptorProto_EnumReservedRange, + writer: Writer = Writer.create() + ): Writer { + if (message.start !== 0) { + writer.uint32(8).int32(message.start); + } + if (message.end !== 0) { + writer.uint32(16).int32(message.end); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): EnumDescriptorProto_EnumReservedRange { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseEnumDescriptorProto_EnumReservedRange, + } as EnumDescriptorProto_EnumReservedRange; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.start = reader.int32(); + break; + case 2: + message.end = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumDescriptorProto_EnumReservedRange { + const message = { + ...baseEnumDescriptorProto_EnumReservedRange, + } as EnumDescriptorProto_EnumReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = Number(object.start); + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + return message; + }, + + toJSON(message: EnumDescriptorProto_EnumReservedRange): unknown { + const obj: any = {}; + message.start !== undefined && (obj.start = message.start); + message.end !== undefined && (obj.end = message.end); + return obj; + }, + + fromPartial( + object: DeepPartial + ): EnumDescriptorProto_EnumReservedRange { + const message = { + ...baseEnumDescriptorProto_EnumReservedRange, + } as EnumDescriptorProto_EnumReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = object.start; + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + return message; + }, +}; + +const baseEnumValueDescriptorProto: object = { name: "", number: 0 }; + +export const EnumValueDescriptorProto = { + encode( + message: EnumValueDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.number !== 0) { + writer.uint32(16).int32(message.number); + } + if (message.options !== undefined) { + EnumValueOptions.encode( + message.options, + writer.uint32(26).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): EnumValueDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseEnumValueDescriptorProto, + } as EnumValueDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.number = reader.int32(); + break; + case 3: + message.options = EnumValueOptions.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumValueDescriptorProto { + const message = { + ...baseEnumValueDescriptorProto, + } as EnumValueDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = Number(object.number); + } else { + message.number = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumValueOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: EnumValueDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.number !== undefined && (obj.number = message.number); + message.options !== undefined && + (obj.options = message.options + ? EnumValueOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): EnumValueDescriptorProto { + const message = { + ...baseEnumValueDescriptorProto, + } as EnumValueDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = object.number; + } else { + message.number = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumValueOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseServiceDescriptorProto: object = { name: "" }; + +export const ServiceDescriptorProto = { + encode( + message: ServiceDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + for (const v of message.method) { + MethodDescriptorProto.encode(v!, writer.uint32(18).fork()).ldelim(); + } + if (message.options !== undefined) { + ServiceOptions.encode(message.options, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ServiceDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseServiceDescriptorProto } as ServiceDescriptorProto; + message.method = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.method.push( + MethodDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 3: + message.options = ServiceOptions.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ServiceDescriptorProto { + const message = { ...baseServiceDescriptorProto } as ServiceDescriptorProto; + message.method = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.method !== undefined && object.method !== null) { + for (const e of object.method) { + message.method.push(MethodDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = ServiceOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: ServiceDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + if (message.method) { + obj.method = message.method.map((e) => + e ? MethodDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.method = []; + } + message.options !== undefined && + (obj.options = message.options + ? ServiceOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): ServiceDescriptorProto { + const message = { ...baseServiceDescriptorProto } as ServiceDescriptorProto; + message.method = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.method !== undefined && object.method !== null) { + for (const e of object.method) { + message.method.push(MethodDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = ServiceOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseMethodDescriptorProto: object = { + name: "", + inputType: "", + outputType: "", + clientStreaming: false, + serverStreaming: false, +}; + +export const MethodDescriptorProto = { + encode( + message: MethodDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.inputType !== "") { + writer.uint32(18).string(message.inputType); + } + if (message.outputType !== "") { + writer.uint32(26).string(message.outputType); + } + if (message.options !== undefined) { + MethodOptions.encode(message.options, writer.uint32(34).fork()).ldelim(); + } + if (message.clientStreaming === true) { + writer.uint32(40).bool(message.clientStreaming); + } + if (message.serverStreaming === true) { + writer.uint32(48).bool(message.serverStreaming); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MethodDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMethodDescriptorProto } as MethodDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.inputType = reader.string(); + break; + case 3: + message.outputType = reader.string(); + break; + case 4: + message.options = MethodOptions.decode(reader, reader.uint32()); + break; + case 5: + message.clientStreaming = reader.bool(); + break; + case 6: + message.serverStreaming = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MethodDescriptorProto { + const message = { ...baseMethodDescriptorProto } as MethodDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.inputType !== undefined && object.inputType !== null) { + message.inputType = String(object.inputType); + } else { + message.inputType = ""; + } + if (object.outputType !== undefined && object.outputType !== null) { + message.outputType = String(object.outputType); + } else { + message.outputType = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = MethodOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if ( + object.clientStreaming !== undefined && + object.clientStreaming !== null + ) { + message.clientStreaming = Boolean(object.clientStreaming); + } else { + message.clientStreaming = false; + } + if ( + object.serverStreaming !== undefined && + object.serverStreaming !== null + ) { + message.serverStreaming = Boolean(object.serverStreaming); + } else { + message.serverStreaming = false; + } + return message; + }, + + toJSON(message: MethodDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.inputType !== undefined && (obj.inputType = message.inputType); + message.outputType !== undefined && (obj.outputType = message.outputType); + message.options !== undefined && + (obj.options = message.options + ? MethodOptions.toJSON(message.options) + : undefined); + message.clientStreaming !== undefined && + (obj.clientStreaming = message.clientStreaming); + message.serverStreaming !== undefined && + (obj.serverStreaming = message.serverStreaming); + return obj; + }, + + fromPartial( + object: DeepPartial + ): MethodDescriptorProto { + const message = { ...baseMethodDescriptorProto } as MethodDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.inputType !== undefined && object.inputType !== null) { + message.inputType = object.inputType; + } else { + message.inputType = ""; + } + if (object.outputType !== undefined && object.outputType !== null) { + message.outputType = object.outputType; + } else { + message.outputType = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = MethodOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if ( + object.clientStreaming !== undefined && + object.clientStreaming !== null + ) { + message.clientStreaming = object.clientStreaming; + } else { + message.clientStreaming = false; + } + if ( + object.serverStreaming !== undefined && + object.serverStreaming !== null + ) { + message.serverStreaming = object.serverStreaming; + } else { + message.serverStreaming = false; + } + return message; + }, +}; + +const baseFileOptions: object = { + javaPackage: "", + javaOuterClassname: "", + javaMultipleFiles: false, + javaGenerateEqualsAndHash: false, + javaStringCheckUtf8: false, + optimizeFor: 1, + goPackage: "", + ccGenericServices: false, + javaGenericServices: false, + pyGenericServices: false, + phpGenericServices: false, + deprecated: false, + ccEnableArenas: false, + objcClassPrefix: "", + csharpNamespace: "", + swiftPrefix: "", + phpClassPrefix: "", + phpNamespace: "", + phpMetadataNamespace: "", + rubyPackage: "", +}; + +export const FileOptions = { + encode(message: FileOptions, writer: Writer = Writer.create()): Writer { + if (message.javaPackage !== "") { + writer.uint32(10).string(message.javaPackage); + } + if (message.javaOuterClassname !== "") { + writer.uint32(66).string(message.javaOuterClassname); + } + if (message.javaMultipleFiles === true) { + writer.uint32(80).bool(message.javaMultipleFiles); + } + if (message.javaGenerateEqualsAndHash === true) { + writer.uint32(160).bool(message.javaGenerateEqualsAndHash); + } + if (message.javaStringCheckUtf8 === true) { + writer.uint32(216).bool(message.javaStringCheckUtf8); + } + if (message.optimizeFor !== 1) { + writer.uint32(72).int32(message.optimizeFor); + } + if (message.goPackage !== "") { + writer.uint32(90).string(message.goPackage); + } + if (message.ccGenericServices === true) { + writer.uint32(128).bool(message.ccGenericServices); + } + if (message.javaGenericServices === true) { + writer.uint32(136).bool(message.javaGenericServices); + } + if (message.pyGenericServices === true) { + writer.uint32(144).bool(message.pyGenericServices); + } + if (message.phpGenericServices === true) { + writer.uint32(336).bool(message.phpGenericServices); + } + if (message.deprecated === true) { + writer.uint32(184).bool(message.deprecated); + } + if (message.ccEnableArenas === true) { + writer.uint32(248).bool(message.ccEnableArenas); + } + if (message.objcClassPrefix !== "") { + writer.uint32(290).string(message.objcClassPrefix); + } + if (message.csharpNamespace !== "") { + writer.uint32(298).string(message.csharpNamespace); + } + if (message.swiftPrefix !== "") { + writer.uint32(314).string(message.swiftPrefix); + } + if (message.phpClassPrefix !== "") { + writer.uint32(322).string(message.phpClassPrefix); + } + if (message.phpNamespace !== "") { + writer.uint32(330).string(message.phpNamespace); + } + if (message.phpMetadataNamespace !== "") { + writer.uint32(354).string(message.phpMetadataNamespace); + } + if (message.rubyPackage !== "") { + writer.uint32(362).string(message.rubyPackage); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FileOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFileOptions } as FileOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.javaPackage = reader.string(); + break; + case 8: + message.javaOuterClassname = reader.string(); + break; + case 10: + message.javaMultipleFiles = reader.bool(); + break; + case 20: + message.javaGenerateEqualsAndHash = reader.bool(); + break; + case 27: + message.javaStringCheckUtf8 = reader.bool(); + break; + case 9: + message.optimizeFor = reader.int32() as any; + break; + case 11: + message.goPackage = reader.string(); + break; + case 16: + message.ccGenericServices = reader.bool(); + break; + case 17: + message.javaGenericServices = reader.bool(); + break; + case 18: + message.pyGenericServices = reader.bool(); + break; + case 42: + message.phpGenericServices = reader.bool(); + break; + case 23: + message.deprecated = reader.bool(); + break; + case 31: + message.ccEnableArenas = reader.bool(); + break; + case 36: + message.objcClassPrefix = reader.string(); + break; + case 37: + message.csharpNamespace = reader.string(); + break; + case 39: + message.swiftPrefix = reader.string(); + break; + case 40: + message.phpClassPrefix = reader.string(); + break; + case 41: + message.phpNamespace = reader.string(); + break; + case 44: + message.phpMetadataNamespace = reader.string(); + break; + case 45: + message.rubyPackage = reader.string(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FileOptions { + const message = { ...baseFileOptions } as FileOptions; + message.uninterpretedOption = []; + if (object.javaPackage !== undefined && object.javaPackage !== null) { + message.javaPackage = String(object.javaPackage); + } else { + message.javaPackage = ""; + } + if ( + object.javaOuterClassname !== undefined && + object.javaOuterClassname !== null + ) { + message.javaOuterClassname = String(object.javaOuterClassname); + } else { + message.javaOuterClassname = ""; + } + if ( + object.javaMultipleFiles !== undefined && + object.javaMultipleFiles !== null + ) { + message.javaMultipleFiles = Boolean(object.javaMultipleFiles); + } else { + message.javaMultipleFiles = false; + } + if ( + object.javaGenerateEqualsAndHash !== undefined && + object.javaGenerateEqualsAndHash !== null + ) { + message.javaGenerateEqualsAndHash = Boolean( + object.javaGenerateEqualsAndHash + ); + } else { + message.javaGenerateEqualsAndHash = false; + } + if ( + object.javaStringCheckUtf8 !== undefined && + object.javaStringCheckUtf8 !== null + ) { + message.javaStringCheckUtf8 = Boolean(object.javaStringCheckUtf8); + } else { + message.javaStringCheckUtf8 = false; + } + if (object.optimizeFor !== undefined && object.optimizeFor !== null) { + message.optimizeFor = fileOptions_OptimizeModeFromJSON( + object.optimizeFor + ); + } else { + message.optimizeFor = 1; + } + if (object.goPackage !== undefined && object.goPackage !== null) { + message.goPackage = String(object.goPackage); + } else { + message.goPackage = ""; + } + if ( + object.ccGenericServices !== undefined && + object.ccGenericServices !== null + ) { + message.ccGenericServices = Boolean(object.ccGenericServices); + } else { + message.ccGenericServices = false; + } + if ( + object.javaGenericServices !== undefined && + object.javaGenericServices !== null + ) { + message.javaGenericServices = Boolean(object.javaGenericServices); + } else { + message.javaGenericServices = false; + } + if ( + object.pyGenericServices !== undefined && + object.pyGenericServices !== null + ) { + message.pyGenericServices = Boolean(object.pyGenericServices); + } else { + message.pyGenericServices = false; + } + if ( + object.phpGenericServices !== undefined && + object.phpGenericServices !== null + ) { + message.phpGenericServices = Boolean(object.phpGenericServices); + } else { + message.phpGenericServices = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if (object.ccEnableArenas !== undefined && object.ccEnableArenas !== null) { + message.ccEnableArenas = Boolean(object.ccEnableArenas); + } else { + message.ccEnableArenas = false; + } + if ( + object.objcClassPrefix !== undefined && + object.objcClassPrefix !== null + ) { + message.objcClassPrefix = String(object.objcClassPrefix); + } else { + message.objcClassPrefix = ""; + } + if ( + object.csharpNamespace !== undefined && + object.csharpNamespace !== null + ) { + message.csharpNamespace = String(object.csharpNamespace); + } else { + message.csharpNamespace = ""; + } + if (object.swiftPrefix !== undefined && object.swiftPrefix !== null) { + message.swiftPrefix = String(object.swiftPrefix); + } else { + message.swiftPrefix = ""; + } + if (object.phpClassPrefix !== undefined && object.phpClassPrefix !== null) { + message.phpClassPrefix = String(object.phpClassPrefix); + } else { + message.phpClassPrefix = ""; + } + if (object.phpNamespace !== undefined && object.phpNamespace !== null) { + message.phpNamespace = String(object.phpNamespace); + } else { + message.phpNamespace = ""; + } + if ( + object.phpMetadataNamespace !== undefined && + object.phpMetadataNamespace !== null + ) { + message.phpMetadataNamespace = String(object.phpMetadataNamespace); + } else { + message.phpMetadataNamespace = ""; + } + if (object.rubyPackage !== undefined && object.rubyPackage !== null) { + message.rubyPackage = String(object.rubyPackage); + } else { + message.rubyPackage = ""; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: FileOptions): unknown { + const obj: any = {}; + message.javaPackage !== undefined && + (obj.javaPackage = message.javaPackage); + message.javaOuterClassname !== undefined && + (obj.javaOuterClassname = message.javaOuterClassname); + message.javaMultipleFiles !== undefined && + (obj.javaMultipleFiles = message.javaMultipleFiles); + message.javaGenerateEqualsAndHash !== undefined && + (obj.javaGenerateEqualsAndHash = message.javaGenerateEqualsAndHash); + message.javaStringCheckUtf8 !== undefined && + (obj.javaStringCheckUtf8 = message.javaStringCheckUtf8); + message.optimizeFor !== undefined && + (obj.optimizeFor = fileOptions_OptimizeModeToJSON(message.optimizeFor)); + message.goPackage !== undefined && (obj.goPackage = message.goPackage); + message.ccGenericServices !== undefined && + (obj.ccGenericServices = message.ccGenericServices); + message.javaGenericServices !== undefined && + (obj.javaGenericServices = message.javaGenericServices); + message.pyGenericServices !== undefined && + (obj.pyGenericServices = message.pyGenericServices); + message.phpGenericServices !== undefined && + (obj.phpGenericServices = message.phpGenericServices); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.ccEnableArenas !== undefined && + (obj.ccEnableArenas = message.ccEnableArenas); + message.objcClassPrefix !== undefined && + (obj.objcClassPrefix = message.objcClassPrefix); + message.csharpNamespace !== undefined && + (obj.csharpNamespace = message.csharpNamespace); + message.swiftPrefix !== undefined && + (obj.swiftPrefix = message.swiftPrefix); + message.phpClassPrefix !== undefined && + (obj.phpClassPrefix = message.phpClassPrefix); + message.phpNamespace !== undefined && + (obj.phpNamespace = message.phpNamespace); + message.phpMetadataNamespace !== undefined && + (obj.phpMetadataNamespace = message.phpMetadataNamespace); + message.rubyPackage !== undefined && + (obj.rubyPackage = message.rubyPackage); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): FileOptions { + const message = { ...baseFileOptions } as FileOptions; + message.uninterpretedOption = []; + if (object.javaPackage !== undefined && object.javaPackage !== null) { + message.javaPackage = object.javaPackage; + } else { + message.javaPackage = ""; + } + if ( + object.javaOuterClassname !== undefined && + object.javaOuterClassname !== null + ) { + message.javaOuterClassname = object.javaOuterClassname; + } else { + message.javaOuterClassname = ""; + } + if ( + object.javaMultipleFiles !== undefined && + object.javaMultipleFiles !== null + ) { + message.javaMultipleFiles = object.javaMultipleFiles; + } else { + message.javaMultipleFiles = false; + } + if ( + object.javaGenerateEqualsAndHash !== undefined && + object.javaGenerateEqualsAndHash !== null + ) { + message.javaGenerateEqualsAndHash = object.javaGenerateEqualsAndHash; + } else { + message.javaGenerateEqualsAndHash = false; + } + if ( + object.javaStringCheckUtf8 !== undefined && + object.javaStringCheckUtf8 !== null + ) { + message.javaStringCheckUtf8 = object.javaStringCheckUtf8; + } else { + message.javaStringCheckUtf8 = false; + } + if (object.optimizeFor !== undefined && object.optimizeFor !== null) { + message.optimizeFor = object.optimizeFor; + } else { + message.optimizeFor = 1; + } + if (object.goPackage !== undefined && object.goPackage !== null) { + message.goPackage = object.goPackage; + } else { + message.goPackage = ""; + } + if ( + object.ccGenericServices !== undefined && + object.ccGenericServices !== null + ) { + message.ccGenericServices = object.ccGenericServices; + } else { + message.ccGenericServices = false; + } + if ( + object.javaGenericServices !== undefined && + object.javaGenericServices !== null + ) { + message.javaGenericServices = object.javaGenericServices; + } else { + message.javaGenericServices = false; + } + if ( + object.pyGenericServices !== undefined && + object.pyGenericServices !== null + ) { + message.pyGenericServices = object.pyGenericServices; + } else { + message.pyGenericServices = false; + } + if ( + object.phpGenericServices !== undefined && + object.phpGenericServices !== null + ) { + message.phpGenericServices = object.phpGenericServices; + } else { + message.phpGenericServices = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if (object.ccEnableArenas !== undefined && object.ccEnableArenas !== null) { + message.ccEnableArenas = object.ccEnableArenas; + } else { + message.ccEnableArenas = false; + } + if ( + object.objcClassPrefix !== undefined && + object.objcClassPrefix !== null + ) { + message.objcClassPrefix = object.objcClassPrefix; + } else { + message.objcClassPrefix = ""; + } + if ( + object.csharpNamespace !== undefined && + object.csharpNamespace !== null + ) { + message.csharpNamespace = object.csharpNamespace; + } else { + message.csharpNamespace = ""; + } + if (object.swiftPrefix !== undefined && object.swiftPrefix !== null) { + message.swiftPrefix = object.swiftPrefix; + } else { + message.swiftPrefix = ""; + } + if (object.phpClassPrefix !== undefined && object.phpClassPrefix !== null) { + message.phpClassPrefix = object.phpClassPrefix; + } else { + message.phpClassPrefix = ""; + } + if (object.phpNamespace !== undefined && object.phpNamespace !== null) { + message.phpNamespace = object.phpNamespace; + } else { + message.phpNamespace = ""; + } + if ( + object.phpMetadataNamespace !== undefined && + object.phpMetadataNamespace !== null + ) { + message.phpMetadataNamespace = object.phpMetadataNamespace; + } else { + message.phpMetadataNamespace = ""; + } + if (object.rubyPackage !== undefined && object.rubyPackage !== null) { + message.rubyPackage = object.rubyPackage; + } else { + message.rubyPackage = ""; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseMessageOptions: object = { + messageSetWireFormat: false, + noStandardDescriptorAccessor: false, + deprecated: false, + mapEntry: false, +}; + +export const MessageOptions = { + encode(message: MessageOptions, writer: Writer = Writer.create()): Writer { + if (message.messageSetWireFormat === true) { + writer.uint32(8).bool(message.messageSetWireFormat); + } + if (message.noStandardDescriptorAccessor === true) { + writer.uint32(16).bool(message.noStandardDescriptorAccessor); + } + if (message.deprecated === true) { + writer.uint32(24).bool(message.deprecated); + } + if (message.mapEntry === true) { + writer.uint32(56).bool(message.mapEntry); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MessageOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMessageOptions } as MessageOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.messageSetWireFormat = reader.bool(); + break; + case 2: + message.noStandardDescriptorAccessor = reader.bool(); + break; + case 3: + message.deprecated = reader.bool(); + break; + case 7: + message.mapEntry = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MessageOptions { + const message = { ...baseMessageOptions } as MessageOptions; + message.uninterpretedOption = []; + if ( + object.messageSetWireFormat !== undefined && + object.messageSetWireFormat !== null + ) { + message.messageSetWireFormat = Boolean(object.messageSetWireFormat); + } else { + message.messageSetWireFormat = false; + } + if ( + object.noStandardDescriptorAccessor !== undefined && + object.noStandardDescriptorAccessor !== null + ) { + message.noStandardDescriptorAccessor = Boolean( + object.noStandardDescriptorAccessor + ); + } else { + message.noStandardDescriptorAccessor = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if (object.mapEntry !== undefined && object.mapEntry !== null) { + message.mapEntry = Boolean(object.mapEntry); + } else { + message.mapEntry = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: MessageOptions): unknown { + const obj: any = {}; + message.messageSetWireFormat !== undefined && + (obj.messageSetWireFormat = message.messageSetWireFormat); + message.noStandardDescriptorAccessor !== undefined && + (obj.noStandardDescriptorAccessor = message.noStandardDescriptorAccessor); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.mapEntry !== undefined && (obj.mapEntry = message.mapEntry); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): MessageOptions { + const message = { ...baseMessageOptions } as MessageOptions; + message.uninterpretedOption = []; + if ( + object.messageSetWireFormat !== undefined && + object.messageSetWireFormat !== null + ) { + message.messageSetWireFormat = object.messageSetWireFormat; + } else { + message.messageSetWireFormat = false; + } + if ( + object.noStandardDescriptorAccessor !== undefined && + object.noStandardDescriptorAccessor !== null + ) { + message.noStandardDescriptorAccessor = + object.noStandardDescriptorAccessor; + } else { + message.noStandardDescriptorAccessor = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if (object.mapEntry !== undefined && object.mapEntry !== null) { + message.mapEntry = object.mapEntry; + } else { + message.mapEntry = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseFieldOptions: object = { + ctype: 0, + packed: false, + jstype: 0, + lazy: false, + deprecated: false, + weak: false, +}; + +export const FieldOptions = { + encode(message: FieldOptions, writer: Writer = Writer.create()): Writer { + if (message.ctype !== 0) { + writer.uint32(8).int32(message.ctype); + } + if (message.packed === true) { + writer.uint32(16).bool(message.packed); + } + if (message.jstype !== 0) { + writer.uint32(48).int32(message.jstype); + } + if (message.lazy === true) { + writer.uint32(40).bool(message.lazy); + } + if (message.deprecated === true) { + writer.uint32(24).bool(message.deprecated); + } + if (message.weak === true) { + writer.uint32(80).bool(message.weak); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FieldOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFieldOptions } as FieldOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.ctype = reader.int32() as any; + break; + case 2: + message.packed = reader.bool(); + break; + case 6: + message.jstype = reader.int32() as any; + break; + case 5: + message.lazy = reader.bool(); + break; + case 3: + message.deprecated = reader.bool(); + break; + case 10: + message.weak = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FieldOptions { + const message = { ...baseFieldOptions } as FieldOptions; + message.uninterpretedOption = []; + if (object.ctype !== undefined && object.ctype !== null) { + message.ctype = fieldOptions_CTypeFromJSON(object.ctype); + } else { + message.ctype = 0; + } + if (object.packed !== undefined && object.packed !== null) { + message.packed = Boolean(object.packed); + } else { + message.packed = false; + } + if (object.jstype !== undefined && object.jstype !== null) { + message.jstype = fieldOptions_JSTypeFromJSON(object.jstype); + } else { + message.jstype = 0; + } + if (object.lazy !== undefined && object.lazy !== null) { + message.lazy = Boolean(object.lazy); + } else { + message.lazy = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if (object.weak !== undefined && object.weak !== null) { + message.weak = Boolean(object.weak); + } else { + message.weak = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: FieldOptions): unknown { + const obj: any = {}; + message.ctype !== undefined && + (obj.ctype = fieldOptions_CTypeToJSON(message.ctype)); + message.packed !== undefined && (obj.packed = message.packed); + message.jstype !== undefined && + (obj.jstype = fieldOptions_JSTypeToJSON(message.jstype)); + message.lazy !== undefined && (obj.lazy = message.lazy); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.weak !== undefined && (obj.weak = message.weak); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): FieldOptions { + const message = { ...baseFieldOptions } as FieldOptions; + message.uninterpretedOption = []; + if (object.ctype !== undefined && object.ctype !== null) { + message.ctype = object.ctype; + } else { + message.ctype = 0; + } + if (object.packed !== undefined && object.packed !== null) { + message.packed = object.packed; + } else { + message.packed = false; + } + if (object.jstype !== undefined && object.jstype !== null) { + message.jstype = object.jstype; + } else { + message.jstype = 0; + } + if (object.lazy !== undefined && object.lazy !== null) { + message.lazy = object.lazy; + } else { + message.lazy = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if (object.weak !== undefined && object.weak !== null) { + message.weak = object.weak; + } else { + message.weak = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseOneofOptions: object = {}; + +export const OneofOptions = { + encode(message: OneofOptions, writer: Writer = Writer.create()): Writer { + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): OneofOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseOneofOptions } as OneofOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): OneofOptions { + const message = { ...baseOneofOptions } as OneofOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: OneofOptions): unknown { + const obj: any = {}; + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): OneofOptions { + const message = { ...baseOneofOptions } as OneofOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseEnumOptions: object = { allowAlias: false, deprecated: false }; + +export const EnumOptions = { + encode(message: EnumOptions, writer: Writer = Writer.create()): Writer { + if (message.allowAlias === true) { + writer.uint32(16).bool(message.allowAlias); + } + if (message.deprecated === true) { + writer.uint32(24).bool(message.deprecated); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): EnumOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseEnumOptions } as EnumOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + message.allowAlias = reader.bool(); + break; + case 3: + message.deprecated = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumOptions { + const message = { ...baseEnumOptions } as EnumOptions; + message.uninterpretedOption = []; + if (object.allowAlias !== undefined && object.allowAlias !== null) { + message.allowAlias = Boolean(object.allowAlias); + } else { + message.allowAlias = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: EnumOptions): unknown { + const obj: any = {}; + message.allowAlias !== undefined && (obj.allowAlias = message.allowAlias); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): EnumOptions { + const message = { ...baseEnumOptions } as EnumOptions; + message.uninterpretedOption = []; + if (object.allowAlias !== undefined && object.allowAlias !== null) { + message.allowAlias = object.allowAlias; + } else { + message.allowAlias = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseEnumValueOptions: object = { deprecated: false }; + +export const EnumValueOptions = { + encode(message: EnumValueOptions, writer: Writer = Writer.create()): Writer { + if (message.deprecated === true) { + writer.uint32(8).bool(message.deprecated); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): EnumValueOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseEnumValueOptions } as EnumValueOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.deprecated = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumValueOptions { + const message = { ...baseEnumValueOptions } as EnumValueOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: EnumValueOptions): unknown { + const obj: any = {}; + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): EnumValueOptions { + const message = { ...baseEnumValueOptions } as EnumValueOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseServiceOptions: object = { deprecated: false }; + +export const ServiceOptions = { + encode(message: ServiceOptions, writer: Writer = Writer.create()): Writer { + if (message.deprecated === true) { + writer.uint32(264).bool(message.deprecated); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ServiceOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseServiceOptions } as ServiceOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 33: + message.deprecated = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ServiceOptions { + const message = { ...baseServiceOptions } as ServiceOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: ServiceOptions): unknown { + const obj: any = {}; + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): ServiceOptions { + const message = { ...baseServiceOptions } as ServiceOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseMethodOptions: object = { deprecated: false, idempotencyLevel: 0 }; + +export const MethodOptions = { + encode(message: MethodOptions, writer: Writer = Writer.create()): Writer { + if (message.deprecated === true) { + writer.uint32(264).bool(message.deprecated); + } + if (message.idempotencyLevel !== 0) { + writer.uint32(272).int32(message.idempotencyLevel); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MethodOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMethodOptions } as MethodOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 33: + message.deprecated = reader.bool(); + break; + case 34: + message.idempotencyLevel = reader.int32() as any; + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MethodOptions { + const message = { ...baseMethodOptions } as MethodOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.idempotencyLevel !== undefined && + object.idempotencyLevel !== null + ) { + message.idempotencyLevel = methodOptions_IdempotencyLevelFromJSON( + object.idempotencyLevel + ); + } else { + message.idempotencyLevel = 0; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: MethodOptions): unknown { + const obj: any = {}; + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.idempotencyLevel !== undefined && + (obj.idempotencyLevel = methodOptions_IdempotencyLevelToJSON( + message.idempotencyLevel + )); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): MethodOptions { + const message = { ...baseMethodOptions } as MethodOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.idempotencyLevel !== undefined && + object.idempotencyLevel !== null + ) { + message.idempotencyLevel = object.idempotencyLevel; + } else { + message.idempotencyLevel = 0; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseUninterpretedOption: object = { + identifierValue: "", + positiveIntValue: 0, + negativeIntValue: 0, + doubleValue: 0, + aggregateValue: "", +}; + +export const UninterpretedOption = { + encode( + message: UninterpretedOption, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.name) { + UninterpretedOption_NamePart.encode( + v!, + writer.uint32(18).fork() + ).ldelim(); + } + if (message.identifierValue !== "") { + writer.uint32(26).string(message.identifierValue); + } + if (message.positiveIntValue !== 0) { + writer.uint32(32).uint64(message.positiveIntValue); + } + if (message.negativeIntValue !== 0) { + writer.uint32(40).int64(message.negativeIntValue); + } + if (message.doubleValue !== 0) { + writer.uint32(49).double(message.doubleValue); + } + if (message.stringValue.length !== 0) { + writer.uint32(58).bytes(message.stringValue); + } + if (message.aggregateValue !== "") { + writer.uint32(66).string(message.aggregateValue); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): UninterpretedOption { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseUninterpretedOption } as UninterpretedOption; + message.name = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + message.name.push( + UninterpretedOption_NamePart.decode(reader, reader.uint32()) + ); + break; + case 3: + message.identifierValue = reader.string(); + break; + case 4: + message.positiveIntValue = longToNumber(reader.uint64() as Long); + break; + case 5: + message.negativeIntValue = longToNumber(reader.int64() as Long); + break; + case 6: + message.doubleValue = reader.double(); + break; + case 7: + message.stringValue = reader.bytes(); + break; + case 8: + message.aggregateValue = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): UninterpretedOption { + const message = { ...baseUninterpretedOption } as UninterpretedOption; + message.name = []; + if (object.name !== undefined && object.name !== null) { + for (const e of object.name) { + message.name.push(UninterpretedOption_NamePart.fromJSON(e)); + } + } + if ( + object.identifierValue !== undefined && + object.identifierValue !== null + ) { + message.identifierValue = String(object.identifierValue); + } else { + message.identifierValue = ""; + } + if ( + object.positiveIntValue !== undefined && + object.positiveIntValue !== null + ) { + message.positiveIntValue = Number(object.positiveIntValue); + } else { + message.positiveIntValue = 0; + } + if ( + object.negativeIntValue !== undefined && + object.negativeIntValue !== null + ) { + message.negativeIntValue = Number(object.negativeIntValue); + } else { + message.negativeIntValue = 0; + } + if (object.doubleValue !== undefined && object.doubleValue !== null) { + message.doubleValue = Number(object.doubleValue); + } else { + message.doubleValue = 0; + } + if (object.stringValue !== undefined && object.stringValue !== null) { + message.stringValue = bytesFromBase64(object.stringValue); + } + if (object.aggregateValue !== undefined && object.aggregateValue !== null) { + message.aggregateValue = String(object.aggregateValue); + } else { + message.aggregateValue = ""; + } + return message; + }, + + toJSON(message: UninterpretedOption): unknown { + const obj: any = {}; + if (message.name) { + obj.name = message.name.map((e) => + e ? UninterpretedOption_NamePart.toJSON(e) : undefined + ); + } else { + obj.name = []; + } + message.identifierValue !== undefined && + (obj.identifierValue = message.identifierValue); + message.positiveIntValue !== undefined && + (obj.positiveIntValue = message.positiveIntValue); + message.negativeIntValue !== undefined && + (obj.negativeIntValue = message.negativeIntValue); + message.doubleValue !== undefined && + (obj.doubleValue = message.doubleValue); + message.stringValue !== undefined && + (obj.stringValue = base64FromBytes( + message.stringValue !== undefined + ? message.stringValue + : new Uint8Array() + )); + message.aggregateValue !== undefined && + (obj.aggregateValue = message.aggregateValue); + return obj; + }, + + fromPartial(object: DeepPartial): UninterpretedOption { + const message = { ...baseUninterpretedOption } as UninterpretedOption; + message.name = []; + if (object.name !== undefined && object.name !== null) { + for (const e of object.name) { + message.name.push(UninterpretedOption_NamePart.fromPartial(e)); + } + } + if ( + object.identifierValue !== undefined && + object.identifierValue !== null + ) { + message.identifierValue = object.identifierValue; + } else { + message.identifierValue = ""; + } + if ( + object.positiveIntValue !== undefined && + object.positiveIntValue !== null + ) { + message.positiveIntValue = object.positiveIntValue; + } else { + message.positiveIntValue = 0; + } + if ( + object.negativeIntValue !== undefined && + object.negativeIntValue !== null + ) { + message.negativeIntValue = object.negativeIntValue; + } else { + message.negativeIntValue = 0; + } + if (object.doubleValue !== undefined && object.doubleValue !== null) { + message.doubleValue = object.doubleValue; + } else { + message.doubleValue = 0; + } + if (object.stringValue !== undefined && object.stringValue !== null) { + message.stringValue = object.stringValue; + } else { + message.stringValue = new Uint8Array(); + } + if (object.aggregateValue !== undefined && object.aggregateValue !== null) { + message.aggregateValue = object.aggregateValue; + } else { + message.aggregateValue = ""; + } + return message; + }, +}; + +const baseUninterpretedOption_NamePart: object = { + namePart: "", + isExtension: false, +}; + +export const UninterpretedOption_NamePart = { + encode( + message: UninterpretedOption_NamePart, + writer: Writer = Writer.create() + ): Writer { + if (message.namePart !== "") { + writer.uint32(10).string(message.namePart); + } + if (message.isExtension === true) { + writer.uint32(16).bool(message.isExtension); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): UninterpretedOption_NamePart { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseUninterpretedOption_NamePart, + } as UninterpretedOption_NamePart; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.namePart = reader.string(); + break; + case 2: + message.isExtension = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): UninterpretedOption_NamePart { + const message = { + ...baseUninterpretedOption_NamePart, + } as UninterpretedOption_NamePart; + if (object.namePart !== undefined && object.namePart !== null) { + message.namePart = String(object.namePart); + } else { + message.namePart = ""; + } + if (object.isExtension !== undefined && object.isExtension !== null) { + message.isExtension = Boolean(object.isExtension); + } else { + message.isExtension = false; + } + return message; + }, + + toJSON(message: UninterpretedOption_NamePart): unknown { + const obj: any = {}; + message.namePart !== undefined && (obj.namePart = message.namePart); + message.isExtension !== undefined && + (obj.isExtension = message.isExtension); + return obj; + }, + + fromPartial( + object: DeepPartial + ): UninterpretedOption_NamePart { + const message = { + ...baseUninterpretedOption_NamePart, + } as UninterpretedOption_NamePart; + if (object.namePart !== undefined && object.namePart !== null) { + message.namePart = object.namePart; + } else { + message.namePart = ""; + } + if (object.isExtension !== undefined && object.isExtension !== null) { + message.isExtension = object.isExtension; + } else { + message.isExtension = false; + } + return message; + }, +}; + +const baseSourceCodeInfo: object = {}; + +export const SourceCodeInfo = { + encode(message: SourceCodeInfo, writer: Writer = Writer.create()): Writer { + for (const v of message.location) { + SourceCodeInfo_Location.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): SourceCodeInfo { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseSourceCodeInfo } as SourceCodeInfo; + message.location = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.location.push( + SourceCodeInfo_Location.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): SourceCodeInfo { + const message = { ...baseSourceCodeInfo } as SourceCodeInfo; + message.location = []; + if (object.location !== undefined && object.location !== null) { + for (const e of object.location) { + message.location.push(SourceCodeInfo_Location.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: SourceCodeInfo): unknown { + const obj: any = {}; + if (message.location) { + obj.location = message.location.map((e) => + e ? SourceCodeInfo_Location.toJSON(e) : undefined + ); + } else { + obj.location = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): SourceCodeInfo { + const message = { ...baseSourceCodeInfo } as SourceCodeInfo; + message.location = []; + if (object.location !== undefined && object.location !== null) { + for (const e of object.location) { + message.location.push(SourceCodeInfo_Location.fromPartial(e)); + } + } + return message; + }, +}; + +const baseSourceCodeInfo_Location: object = { + path: 0, + span: 0, + leadingComments: "", + trailingComments: "", + leadingDetachedComments: "", +}; + +export const SourceCodeInfo_Location = { + encode( + message: SourceCodeInfo_Location, + writer: Writer = Writer.create() + ): Writer { + writer.uint32(10).fork(); + for (const v of message.path) { + writer.int32(v); + } + writer.ldelim(); + writer.uint32(18).fork(); + for (const v of message.span) { + writer.int32(v); + } + writer.ldelim(); + if (message.leadingComments !== "") { + writer.uint32(26).string(message.leadingComments); + } + if (message.trailingComments !== "") { + writer.uint32(34).string(message.trailingComments); + } + for (const v of message.leadingDetachedComments) { + writer.uint32(50).string(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): SourceCodeInfo_Location { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseSourceCodeInfo_Location, + } as SourceCodeInfo_Location; + message.path = []; + message.span = []; + message.leadingDetachedComments = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.path.push(reader.int32()); + } + } else { + message.path.push(reader.int32()); + } + break; + case 2: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.span.push(reader.int32()); + } + } else { + message.span.push(reader.int32()); + } + break; + case 3: + message.leadingComments = reader.string(); + break; + case 4: + message.trailingComments = reader.string(); + break; + case 6: + message.leadingDetachedComments.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): SourceCodeInfo_Location { + const message = { + ...baseSourceCodeInfo_Location, + } as SourceCodeInfo_Location; + message.path = []; + message.span = []; + message.leadingDetachedComments = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(Number(e)); + } + } + if (object.span !== undefined && object.span !== null) { + for (const e of object.span) { + message.span.push(Number(e)); + } + } + if ( + object.leadingComments !== undefined && + object.leadingComments !== null + ) { + message.leadingComments = String(object.leadingComments); + } else { + message.leadingComments = ""; + } + if ( + object.trailingComments !== undefined && + object.trailingComments !== null + ) { + message.trailingComments = String(object.trailingComments); + } else { + message.trailingComments = ""; + } + if ( + object.leadingDetachedComments !== undefined && + object.leadingDetachedComments !== null + ) { + for (const e of object.leadingDetachedComments) { + message.leadingDetachedComments.push(String(e)); + } + } + return message; + }, + + toJSON(message: SourceCodeInfo_Location): unknown { + const obj: any = {}; + if (message.path) { + obj.path = message.path.map((e) => e); + } else { + obj.path = []; + } + if (message.span) { + obj.span = message.span.map((e) => e); + } else { + obj.span = []; + } + message.leadingComments !== undefined && + (obj.leadingComments = message.leadingComments); + message.trailingComments !== undefined && + (obj.trailingComments = message.trailingComments); + if (message.leadingDetachedComments) { + obj.leadingDetachedComments = message.leadingDetachedComments.map( + (e) => e + ); + } else { + obj.leadingDetachedComments = []; + } + return obj; + }, + + fromPartial( + object: DeepPartial + ): SourceCodeInfo_Location { + const message = { + ...baseSourceCodeInfo_Location, + } as SourceCodeInfo_Location; + message.path = []; + message.span = []; + message.leadingDetachedComments = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(e); + } + } + if (object.span !== undefined && object.span !== null) { + for (const e of object.span) { + message.span.push(e); + } + } + if ( + object.leadingComments !== undefined && + object.leadingComments !== null + ) { + message.leadingComments = object.leadingComments; + } else { + message.leadingComments = ""; + } + if ( + object.trailingComments !== undefined && + object.trailingComments !== null + ) { + message.trailingComments = object.trailingComments; + } else { + message.trailingComments = ""; + } + if ( + object.leadingDetachedComments !== undefined && + object.leadingDetachedComments !== null + ) { + for (const e of object.leadingDetachedComments) { + message.leadingDetachedComments.push(e); + } + } + return message; + }, +}; + +const baseGeneratedCodeInfo: object = {}; + +export const GeneratedCodeInfo = { + encode(message: GeneratedCodeInfo, writer: Writer = Writer.create()): Writer { + for (const v of message.annotation) { + GeneratedCodeInfo_Annotation.encode( + v!, + writer.uint32(10).fork() + ).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): GeneratedCodeInfo { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseGeneratedCodeInfo } as GeneratedCodeInfo; + message.annotation = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.annotation.push( + GeneratedCodeInfo_Annotation.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GeneratedCodeInfo { + const message = { ...baseGeneratedCodeInfo } as GeneratedCodeInfo; + message.annotation = []; + if (object.annotation !== undefined && object.annotation !== null) { + for (const e of object.annotation) { + message.annotation.push(GeneratedCodeInfo_Annotation.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: GeneratedCodeInfo): unknown { + const obj: any = {}; + if (message.annotation) { + obj.annotation = message.annotation.map((e) => + e ? GeneratedCodeInfo_Annotation.toJSON(e) : undefined + ); + } else { + obj.annotation = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): GeneratedCodeInfo { + const message = { ...baseGeneratedCodeInfo } as GeneratedCodeInfo; + message.annotation = []; + if (object.annotation !== undefined && object.annotation !== null) { + for (const e of object.annotation) { + message.annotation.push(GeneratedCodeInfo_Annotation.fromPartial(e)); + } + } + return message; + }, +}; + +const baseGeneratedCodeInfo_Annotation: object = { + path: 0, + sourceFile: "", + begin: 0, + end: 0, +}; + +export const GeneratedCodeInfo_Annotation = { + encode( + message: GeneratedCodeInfo_Annotation, + writer: Writer = Writer.create() + ): Writer { + writer.uint32(10).fork(); + for (const v of message.path) { + writer.int32(v); + } + writer.ldelim(); + if (message.sourceFile !== "") { + writer.uint32(18).string(message.sourceFile); + } + if (message.begin !== 0) { + writer.uint32(24).int32(message.begin); + } + if (message.end !== 0) { + writer.uint32(32).int32(message.end); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): GeneratedCodeInfo_Annotation { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseGeneratedCodeInfo_Annotation, + } as GeneratedCodeInfo_Annotation; + message.path = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.path.push(reader.int32()); + } + } else { + message.path.push(reader.int32()); + } + break; + case 2: + message.sourceFile = reader.string(); + break; + case 3: + message.begin = reader.int32(); + break; + case 4: + message.end = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GeneratedCodeInfo_Annotation { + const message = { + ...baseGeneratedCodeInfo_Annotation, + } as GeneratedCodeInfo_Annotation; + message.path = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(Number(e)); + } + } + if (object.sourceFile !== undefined && object.sourceFile !== null) { + message.sourceFile = String(object.sourceFile); + } else { + message.sourceFile = ""; + } + if (object.begin !== undefined && object.begin !== null) { + message.begin = Number(object.begin); + } else { + message.begin = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + return message; + }, + + toJSON(message: GeneratedCodeInfo_Annotation): unknown { + const obj: any = {}; + if (message.path) { + obj.path = message.path.map((e) => e); + } else { + obj.path = []; + } + message.sourceFile !== undefined && (obj.sourceFile = message.sourceFile); + message.begin !== undefined && (obj.begin = message.begin); + message.end !== undefined && (obj.end = message.end); + return obj; + }, + + fromPartial( + object: DeepPartial + ): GeneratedCodeInfo_Annotation { + const message = { + ...baseGeneratedCodeInfo_Annotation, + } as GeneratedCodeInfo_Annotation; + message.path = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(e); + } + } + if (object.sourceFile !== undefined && object.sourceFile !== null) { + message.sourceFile = object.sourceFile; + } else { + message.sourceFile = ""; + } + if (object.begin !== undefined && object.begin !== null) { + message.begin = object.begin; + } else { + message.begin = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/ibc.applications.transfer.v1/types/google/protobuf/timestamp.ts b/ts-client/ibc.applications.transfer.v1/types/google/protobuf/timestamp.ts new file mode 100644 index 00000000..11864afc --- /dev/null +++ b/ts-client/ibc.applications.transfer.v1/types/google/protobuf/timestamp.ts @@ -0,0 +1,219 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "google.protobuf"; + +/** + * A Timestamp represents a point in time independent of any time zone or local + * calendar, encoded as a count of seconds and fractions of seconds at + * nanosecond resolution. The count is relative to an epoch at UTC midnight on + * January 1, 1970, in the proleptic Gregorian calendar which extends the + * Gregorian calendar backwards to year one. + * + * All minutes are 60 seconds long. Leap seconds are "smeared" so that no leap + * second table is needed for interpretation, using a [24-hour linear + * smear](https://developers.google.com/time/smear). + * + * The range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. By + * restricting to that range, we ensure that we can convert to and from [RFC + * 3339](https://www.ietf.org/rfc/rfc3339.txt) date strings. + * + * # Examples + * + * Example 1: Compute Timestamp from POSIX `time()`. + * + * Timestamp timestamp; + * timestamp.set_seconds(time(NULL)); + * timestamp.set_nanos(0); + * + * Example 2: Compute Timestamp from POSIX `gettimeofday()`. + * + * struct timeval tv; + * gettimeofday(&tv, NULL); + * + * Timestamp timestamp; + * timestamp.set_seconds(tv.tv_sec); + * timestamp.set_nanos(tv.tv_usec * 1000); + * + * Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`. + * + * FILETIME ft; + * GetSystemTimeAsFileTime(&ft); + * UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime; + * + * // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z + * // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z. + * Timestamp timestamp; + * timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL)); + * timestamp.set_nanos((INT32) ((ticks % 10000000) * 100)); + * + * Example 4: Compute Timestamp from Java `System.currentTimeMillis()`. + * + * long millis = System.currentTimeMillis(); + * + * Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000) + * .setNanos((int) ((millis % 1000) * 1000000)).build(); + * + * + * Example 5: Compute Timestamp from Java `Instant.now()`. + * + * Instant now = Instant.now(); + * + * Timestamp timestamp = + * Timestamp.newBuilder().setSeconds(now.getEpochSecond()) + * .setNanos(now.getNano()).build(); + * + * + * Example 6: Compute Timestamp from current time in Python. + * + * timestamp = Timestamp() + * timestamp.GetCurrentTime() + * + * # JSON Mapping + * + * In JSON format, the Timestamp type is encoded as a string in the + * [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the + * format is "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z" + * where {year} is always expressed using four digits while {month}, {day}, + * {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional + * seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution), + * are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone + * is required. A proto3 JSON serializer should always use UTC (as indicated by + * "Z") when printing the Timestamp type and a proto3 JSON parser should be + * able to accept both UTC and other timezones (as indicated by an offset). + * + * For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past + * 01:30 UTC on January 15, 2017. + * + * In JavaScript, one can convert a Date object to this format using the + * standard + * [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString) + * method. In Python, a standard `datetime.datetime` object can be converted + * to this format using + * [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) with + * the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one can use + * the Joda Time's [`ISODateTimeFormat.dateTime()`]( + * http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime%2D%2D + * ) to obtain a formatter capable of generating timestamps in this format. + */ +export interface Timestamp { + /** + * Represents seconds of UTC time since Unix epoch + * 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to + * 9999-12-31T23:59:59Z inclusive. + */ + seconds: number; + /** + * Non-negative fractions of a second at nanosecond resolution. Negative + * second values with fractions must still have non-negative nanos values + * that count forward in time. Must be from 0 to 999,999,999 + * inclusive. + */ + nanos: number; +} + +const baseTimestamp: object = { seconds: 0, nanos: 0 }; + +export const Timestamp = { + encode(message: Timestamp, writer: Writer = Writer.create()): Writer { + if (message.seconds !== 0) { + writer.uint32(8).int64(message.seconds); + } + if (message.nanos !== 0) { + writer.uint32(16).int32(message.nanos); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Timestamp { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseTimestamp } as Timestamp; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.seconds = longToNumber(reader.int64() as Long); + break; + case 2: + message.nanos = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Timestamp { + const message = { ...baseTimestamp } as Timestamp; + if (object.seconds !== undefined && object.seconds !== null) { + message.seconds = Number(object.seconds); + } else { + message.seconds = 0; + } + if (object.nanos !== undefined && object.nanos !== null) { + message.nanos = Number(object.nanos); + } else { + message.nanos = 0; + } + return message; + }, + + toJSON(message: Timestamp): unknown { + const obj: any = {}; + message.seconds !== undefined && (obj.seconds = message.seconds); + message.nanos !== undefined && (obj.nanos = message.nanos); + return obj; + }, + + fromPartial(object: DeepPartial): Timestamp { + const message = { ...baseTimestamp } as Timestamp; + if (object.seconds !== undefined && object.seconds !== null) { + message.seconds = object.seconds; + } else { + message.seconds = 0; + } + if (object.nanos !== undefined && object.nanos !== null) { + message.nanos = object.nanos; + } else { + message.nanos = 0; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/ibc.applications.transfer.v1/types/ibc/applications/transfer/v1/genesis.ts b/ts-client/ibc.applications.transfer.v1/types/ibc/applications/transfer/v1/genesis.ts new file mode 100644 index 00000000..6fdd36c3 --- /dev/null +++ b/ts-client/ibc.applications.transfer.v1/types/ibc/applications/transfer/v1/genesis.ts @@ -0,0 +1,125 @@ +/* eslint-disable */ +import { + DenomTrace, + Params, +} from "../../../../ibc/applications/transfer/v1/transfer"; +import { Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "ibc.applications.transfer.v1"; + +/** GenesisState defines the ibc-transfer genesis state */ +export interface GenesisState { + portId: string; + denomTraces: DenomTrace[]; + params: Params | undefined; +} + +const baseGenesisState: object = { portId: "" }; + +export const GenesisState = { + encode(message: GenesisState, writer: Writer = Writer.create()): Writer { + if (message.portId !== "") { + writer.uint32(10).string(message.portId); + } + for (const v of message.denomTraces) { + DenomTrace.encode(v!, writer.uint32(18).fork()).ldelim(); + } + if (message.params !== undefined) { + Params.encode(message.params, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): GenesisState { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseGenesisState } as GenesisState; + message.denomTraces = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.portId = reader.string(); + break; + case 2: + message.denomTraces.push(DenomTrace.decode(reader, reader.uint32())); + break; + case 3: + message.params = Params.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GenesisState { + const message = { ...baseGenesisState } as GenesisState; + message.denomTraces = []; + if (object.portId !== undefined && object.portId !== null) { + message.portId = String(object.portId); + } else { + message.portId = ""; + } + if (object.denomTraces !== undefined && object.denomTraces !== null) { + for (const e of object.denomTraces) { + message.denomTraces.push(DenomTrace.fromJSON(e)); + } + } + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromJSON(object.params); + } else { + message.params = undefined; + } + return message; + }, + + toJSON(message: GenesisState): unknown { + const obj: any = {}; + message.portId !== undefined && (obj.portId = message.portId); + if (message.denomTraces) { + obj.denomTraces = message.denomTraces.map((e) => + e ? DenomTrace.toJSON(e) : undefined + ); + } else { + obj.denomTraces = []; + } + message.params !== undefined && + (obj.params = message.params ? Params.toJSON(message.params) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): GenesisState { + const message = { ...baseGenesisState } as GenesisState; + message.denomTraces = []; + if (object.portId !== undefined && object.portId !== null) { + message.portId = object.portId; + } else { + message.portId = ""; + } + if (object.denomTraces !== undefined && object.denomTraces !== null) { + for (const e of object.denomTraces) { + message.denomTraces.push(DenomTrace.fromPartial(e)); + } + } + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromPartial(object.params); + } else { + message.params = undefined; + } + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/ibc.applications.transfer.v1/types/ibc/applications/transfer/v1/query.ts b/ts-client/ibc.applications.transfer.v1/types/ibc/applications/transfer/v1/query.ts new file mode 100644 index 00000000..f83e823d --- /dev/null +++ b/ts-client/ibc.applications.transfer.v1/types/ibc/applications/transfer/v1/query.ts @@ -0,0 +1,870 @@ +/* eslint-disable */ +import { Reader, Writer } from "protobufjs/minimal"; +import { + DenomTrace, + Params, +} from "../../../../ibc/applications/transfer/v1/transfer"; +import { + PageRequest, + PageResponse, +} from "../../../../cosmos/base/query/v1beta1/pagination"; + +export const protobufPackage = "ibc.applications.transfer.v1"; + +/** + * QueryDenomTraceRequest is the request type for the Query/DenomTrace RPC + * method + */ +export interface QueryDenomTraceRequest { + /** hash (in hex format) or denom (full denom with ibc prefix) of the denomination trace information. */ + hash: string; +} + +/** + * QueryDenomTraceResponse is the response type for the Query/DenomTrace RPC + * method. + */ +export interface QueryDenomTraceResponse { + /** denom_trace returns the requested denomination trace information. */ + denomTrace: DenomTrace | undefined; +} + +/** + * QueryConnectionsRequest is the request type for the Query/DenomTraces RPC + * method + */ +export interface QueryDenomTracesRequest { + /** pagination defines an optional pagination for the request. */ + pagination: PageRequest | undefined; +} + +/** + * QueryConnectionsResponse is the response type for the Query/DenomTraces RPC + * method. + */ +export interface QueryDenomTracesResponse { + /** denom_traces returns all denominations trace information. */ + denomTraces: DenomTrace[]; + /** pagination defines the pagination in the response. */ + pagination: PageResponse | undefined; +} + +/** QueryParamsRequest is the request type for the Query/Params RPC method. */ +export interface QueryParamsRequest {} + +/** QueryParamsResponse is the response type for the Query/Params RPC method. */ +export interface QueryParamsResponse { + /** params defines the parameters of the module. */ + params: Params | undefined; +} + +/** + * QueryDenomHashRequest is the request type for the Query/DenomHash RPC + * method + */ +export interface QueryDenomHashRequest { + /** The denomination trace ([port_id]/[channel_id])+/[denom] */ + trace: string; +} + +/** + * QueryDenomHashResponse is the response type for the Query/DenomHash RPC + * method. + */ +export interface QueryDenomHashResponse { + /** hash (in hex format) of the denomination trace information. */ + hash: string; +} + +/** QueryEscrowAddressRequest is the request type for the EscrowAddress RPC method. */ +export interface QueryEscrowAddressRequest { + /** unique port identifier */ + portId: string; + /** unique channel identifier */ + channelId: string; +} + +/** QueryEscrowAddressResponse is the response type of the EscrowAddress RPC method. */ +export interface QueryEscrowAddressResponse { + /** the escrow account address */ + escrowAddress: string; +} + +const baseQueryDenomTraceRequest: object = { hash: "" }; + +export const QueryDenomTraceRequest = { + encode( + message: QueryDenomTraceRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.hash !== "") { + writer.uint32(10).string(message.hash); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QueryDenomTraceRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryDenomTraceRequest } as QueryDenomTraceRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.hash = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryDenomTraceRequest { + const message = { ...baseQueryDenomTraceRequest } as QueryDenomTraceRequest; + if (object.hash !== undefined && object.hash !== null) { + message.hash = String(object.hash); + } else { + message.hash = ""; + } + return message; + }, + + toJSON(message: QueryDenomTraceRequest): unknown { + const obj: any = {}; + message.hash !== undefined && (obj.hash = message.hash); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryDenomTraceRequest { + const message = { ...baseQueryDenomTraceRequest } as QueryDenomTraceRequest; + if (object.hash !== undefined && object.hash !== null) { + message.hash = object.hash; + } else { + message.hash = ""; + } + return message; + }, +}; + +const baseQueryDenomTraceResponse: object = {}; + +export const QueryDenomTraceResponse = { + encode( + message: QueryDenomTraceResponse, + writer: Writer = Writer.create() + ): Writer { + if (message.denomTrace !== undefined) { + DenomTrace.encode(message.denomTrace, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QueryDenomTraceResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryDenomTraceResponse, + } as QueryDenomTraceResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.denomTrace = DenomTrace.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryDenomTraceResponse { + const message = { + ...baseQueryDenomTraceResponse, + } as QueryDenomTraceResponse; + if (object.denomTrace !== undefined && object.denomTrace !== null) { + message.denomTrace = DenomTrace.fromJSON(object.denomTrace); + } else { + message.denomTrace = undefined; + } + return message; + }, + + toJSON(message: QueryDenomTraceResponse): unknown { + const obj: any = {}; + message.denomTrace !== undefined && + (obj.denomTrace = message.denomTrace + ? DenomTrace.toJSON(message.denomTrace) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryDenomTraceResponse { + const message = { + ...baseQueryDenomTraceResponse, + } as QueryDenomTraceResponse; + if (object.denomTrace !== undefined && object.denomTrace !== null) { + message.denomTrace = DenomTrace.fromPartial(object.denomTrace); + } else { + message.denomTrace = undefined; + } + return message; + }, +}; + +const baseQueryDenomTracesRequest: object = {}; + +export const QueryDenomTracesRequest = { + encode( + message: QueryDenomTracesRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QueryDenomTracesRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryDenomTracesRequest, + } as QueryDenomTracesRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryDenomTracesRequest { + const message = { + ...baseQueryDenomTracesRequest, + } as QueryDenomTracesRequest; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryDenomTracesRequest): unknown { + const obj: any = {}; + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageRequest.toJSON(message.pagination) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryDenomTracesRequest { + const message = { + ...baseQueryDenomTracesRequest, + } as QueryDenomTracesRequest; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseQueryDenomTracesResponse: object = {}; + +export const QueryDenomTracesResponse = { + encode( + message: QueryDenomTracesResponse, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.denomTraces) { + DenomTrace.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode( + message.pagination, + writer.uint32(18).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryDenomTracesResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryDenomTracesResponse, + } as QueryDenomTracesResponse; + message.denomTraces = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.denomTraces.push(DenomTrace.decode(reader, reader.uint32())); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryDenomTracesResponse { + const message = { + ...baseQueryDenomTracesResponse, + } as QueryDenomTracesResponse; + message.denomTraces = []; + if (object.denomTraces !== undefined && object.denomTraces !== null) { + for (const e of object.denomTraces) { + message.denomTraces.push(DenomTrace.fromJSON(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryDenomTracesResponse): unknown { + const obj: any = {}; + if (message.denomTraces) { + obj.denomTraces = message.denomTraces.map((e) => + e ? DenomTrace.toJSON(e) : undefined + ); + } else { + obj.denomTraces = []; + } + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageResponse.toJSON(message.pagination) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryDenomTracesResponse { + const message = { + ...baseQueryDenomTracesResponse, + } as QueryDenomTracesResponse; + message.denomTraces = []; + if (object.denomTraces !== undefined && object.denomTraces !== null) { + for (const e of object.denomTraces) { + message.denomTraces.push(DenomTrace.fromPartial(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseQueryParamsRequest: object = {}; + +export const QueryParamsRequest = { + encode(_: QueryParamsRequest, writer: Writer = Writer.create()): Writer { + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QueryParamsRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryParamsRequest } as QueryParamsRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): QueryParamsRequest { + const message = { ...baseQueryParamsRequest } as QueryParamsRequest; + return message; + }, + + toJSON(_: QueryParamsRequest): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial(_: DeepPartial): QueryParamsRequest { + const message = { ...baseQueryParamsRequest } as QueryParamsRequest; + return message; + }, +}; + +const baseQueryParamsResponse: object = {}; + +export const QueryParamsResponse = { + encode( + message: QueryParamsResponse, + writer: Writer = Writer.create() + ): Writer { + if (message.params !== undefined) { + Params.encode(message.params, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QueryParamsResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryParamsResponse } as QueryParamsResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.params = Params.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryParamsResponse { + const message = { ...baseQueryParamsResponse } as QueryParamsResponse; + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromJSON(object.params); + } else { + message.params = undefined; + } + return message; + }, + + toJSON(message: QueryParamsResponse): unknown { + const obj: any = {}; + message.params !== undefined && + (obj.params = message.params ? Params.toJSON(message.params) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): QueryParamsResponse { + const message = { ...baseQueryParamsResponse } as QueryParamsResponse; + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromPartial(object.params); + } else { + message.params = undefined; + } + return message; + }, +}; + +const baseQueryDenomHashRequest: object = { trace: "" }; + +export const QueryDenomHashRequest = { + encode( + message: QueryDenomHashRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.trace !== "") { + writer.uint32(10).string(message.trace); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QueryDenomHashRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryDenomHashRequest } as QueryDenomHashRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.trace = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryDenomHashRequest { + const message = { ...baseQueryDenomHashRequest } as QueryDenomHashRequest; + if (object.trace !== undefined && object.trace !== null) { + message.trace = String(object.trace); + } else { + message.trace = ""; + } + return message; + }, + + toJSON(message: QueryDenomHashRequest): unknown { + const obj: any = {}; + message.trace !== undefined && (obj.trace = message.trace); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryDenomHashRequest { + const message = { ...baseQueryDenomHashRequest } as QueryDenomHashRequest; + if (object.trace !== undefined && object.trace !== null) { + message.trace = object.trace; + } else { + message.trace = ""; + } + return message; + }, +}; + +const baseQueryDenomHashResponse: object = { hash: "" }; + +export const QueryDenomHashResponse = { + encode( + message: QueryDenomHashResponse, + writer: Writer = Writer.create() + ): Writer { + if (message.hash !== "") { + writer.uint32(10).string(message.hash); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QueryDenomHashResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryDenomHashResponse } as QueryDenomHashResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.hash = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryDenomHashResponse { + const message = { ...baseQueryDenomHashResponse } as QueryDenomHashResponse; + if (object.hash !== undefined && object.hash !== null) { + message.hash = String(object.hash); + } else { + message.hash = ""; + } + return message; + }, + + toJSON(message: QueryDenomHashResponse): unknown { + const obj: any = {}; + message.hash !== undefined && (obj.hash = message.hash); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryDenomHashResponse { + const message = { ...baseQueryDenomHashResponse } as QueryDenomHashResponse; + if (object.hash !== undefined && object.hash !== null) { + message.hash = object.hash; + } else { + message.hash = ""; + } + return message; + }, +}; + +const baseQueryEscrowAddressRequest: object = { portId: "", channelId: "" }; + +export const QueryEscrowAddressRequest = { + encode( + message: QueryEscrowAddressRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.portId !== "") { + writer.uint32(10).string(message.portId); + } + if (message.channelId !== "") { + writer.uint32(18).string(message.channelId); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryEscrowAddressRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryEscrowAddressRequest, + } as QueryEscrowAddressRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.portId = reader.string(); + break; + case 2: + message.channelId = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryEscrowAddressRequest { + const message = { + ...baseQueryEscrowAddressRequest, + } as QueryEscrowAddressRequest; + if (object.portId !== undefined && object.portId !== null) { + message.portId = String(object.portId); + } else { + message.portId = ""; + } + if (object.channelId !== undefined && object.channelId !== null) { + message.channelId = String(object.channelId); + } else { + message.channelId = ""; + } + return message; + }, + + toJSON(message: QueryEscrowAddressRequest): unknown { + const obj: any = {}; + message.portId !== undefined && (obj.portId = message.portId); + message.channelId !== undefined && (obj.channelId = message.channelId); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryEscrowAddressRequest { + const message = { + ...baseQueryEscrowAddressRequest, + } as QueryEscrowAddressRequest; + if (object.portId !== undefined && object.portId !== null) { + message.portId = object.portId; + } else { + message.portId = ""; + } + if (object.channelId !== undefined && object.channelId !== null) { + message.channelId = object.channelId; + } else { + message.channelId = ""; + } + return message; + }, +}; + +const baseQueryEscrowAddressResponse: object = { escrowAddress: "" }; + +export const QueryEscrowAddressResponse = { + encode( + message: QueryEscrowAddressResponse, + writer: Writer = Writer.create() + ): Writer { + if (message.escrowAddress !== "") { + writer.uint32(10).string(message.escrowAddress); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryEscrowAddressResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryEscrowAddressResponse, + } as QueryEscrowAddressResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.escrowAddress = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryEscrowAddressResponse { + const message = { + ...baseQueryEscrowAddressResponse, + } as QueryEscrowAddressResponse; + if (object.escrowAddress !== undefined && object.escrowAddress !== null) { + message.escrowAddress = String(object.escrowAddress); + } else { + message.escrowAddress = ""; + } + return message; + }, + + toJSON(message: QueryEscrowAddressResponse): unknown { + const obj: any = {}; + message.escrowAddress !== undefined && + (obj.escrowAddress = message.escrowAddress); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryEscrowAddressResponse { + const message = { + ...baseQueryEscrowAddressResponse, + } as QueryEscrowAddressResponse; + if (object.escrowAddress !== undefined && object.escrowAddress !== null) { + message.escrowAddress = object.escrowAddress; + } else { + message.escrowAddress = ""; + } + return message; + }, +}; + +/** Query provides defines the gRPC querier service. */ +export interface Query { + /** DenomTraces queries all denomination traces. */ + DenomTraces( + request: QueryDenomTracesRequest + ): Promise; + /** DenomTrace queries a denomination trace information. */ + DenomTrace(request: QueryDenomTraceRequest): Promise; + /** Params queries all parameters of the ibc-transfer module. */ + Params(request: QueryParamsRequest): Promise; + /** DenomHash queries a denomination hash information. */ + DenomHash(request: QueryDenomHashRequest): Promise; + /** EscrowAddress returns the escrow address for a particular port and channel id. */ + EscrowAddress( + request: QueryEscrowAddressRequest + ): Promise; +} + +export class QueryClientImpl implements Query { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + } + DenomTraces( + request: QueryDenomTracesRequest + ): Promise { + const data = QueryDenomTracesRequest.encode(request).finish(); + const promise = this.rpc.request( + "ibc.applications.transfer.v1.Query", + "DenomTraces", + data + ); + return promise.then((data) => + QueryDenomTracesResponse.decode(new Reader(data)) + ); + } + + DenomTrace( + request: QueryDenomTraceRequest + ): Promise { + const data = QueryDenomTraceRequest.encode(request).finish(); + const promise = this.rpc.request( + "ibc.applications.transfer.v1.Query", + "DenomTrace", + data + ); + return promise.then((data) => + QueryDenomTraceResponse.decode(new Reader(data)) + ); + } + + Params(request: QueryParamsRequest): Promise { + const data = QueryParamsRequest.encode(request).finish(); + const promise = this.rpc.request( + "ibc.applications.transfer.v1.Query", + "Params", + data + ); + return promise.then((data) => QueryParamsResponse.decode(new Reader(data))); + } + + DenomHash(request: QueryDenomHashRequest): Promise { + const data = QueryDenomHashRequest.encode(request).finish(); + const promise = this.rpc.request( + "ibc.applications.transfer.v1.Query", + "DenomHash", + data + ); + return promise.then((data) => + QueryDenomHashResponse.decode(new Reader(data)) + ); + } + + EscrowAddress( + request: QueryEscrowAddressRequest + ): Promise { + const data = QueryEscrowAddressRequest.encode(request).finish(); + const promise = this.rpc.request( + "ibc.applications.transfer.v1.Query", + "EscrowAddress", + data + ); + return promise.then((data) => + QueryEscrowAddressResponse.decode(new Reader(data)) + ); + } +} + +interface Rpc { + request( + service: string, + method: string, + data: Uint8Array + ): Promise; +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/ibc.applications.transfer.v1/types/ibc/applications/transfer/v1/transfer.ts b/ts-client/ibc.applications.transfer.v1/types/ibc/applications/transfer/v1/transfer.ts new file mode 100644 index 00000000..95144785 --- /dev/null +++ b/ts-client/ibc.applications.transfer.v1/types/ibc/applications/transfer/v1/transfer.ts @@ -0,0 +1,194 @@ +/* eslint-disable */ +import { Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "ibc.applications.transfer.v1"; + +/** + * DenomTrace contains the base denomination for ICS20 fungible tokens and the + * source tracing information path. + */ +export interface DenomTrace { + /** + * path defines the chain of port/channel identifiers used for tracing the + * source of the fungible token. + */ + path: string; + /** base denomination of the relayed fungible token. */ + baseDenom: string; +} + +/** + * Params defines the set of IBC transfer parameters. + * NOTE: To prevent a single token from being transferred, set the + * TransfersEnabled parameter to true and then set the bank module's SendEnabled + * parameter for the denomination to false. + */ +export interface Params { + /** + * send_enabled enables or disables all cross-chain token transfers from this + * chain. + */ + sendEnabled: boolean; + /** + * receive_enabled enables or disables all cross-chain token transfers to this + * chain. + */ + receiveEnabled: boolean; +} + +const baseDenomTrace: object = { path: "", baseDenom: "" }; + +export const DenomTrace = { + encode(message: DenomTrace, writer: Writer = Writer.create()): Writer { + if (message.path !== "") { + writer.uint32(10).string(message.path); + } + if (message.baseDenom !== "") { + writer.uint32(18).string(message.baseDenom); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): DenomTrace { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseDenomTrace } as DenomTrace; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.path = reader.string(); + break; + case 2: + message.baseDenom = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DenomTrace { + const message = { ...baseDenomTrace } as DenomTrace; + if (object.path !== undefined && object.path !== null) { + message.path = String(object.path); + } else { + message.path = ""; + } + if (object.baseDenom !== undefined && object.baseDenom !== null) { + message.baseDenom = String(object.baseDenom); + } else { + message.baseDenom = ""; + } + return message; + }, + + toJSON(message: DenomTrace): unknown { + const obj: any = {}; + message.path !== undefined && (obj.path = message.path); + message.baseDenom !== undefined && (obj.baseDenom = message.baseDenom); + return obj; + }, + + fromPartial(object: DeepPartial): DenomTrace { + const message = { ...baseDenomTrace } as DenomTrace; + if (object.path !== undefined && object.path !== null) { + message.path = object.path; + } else { + message.path = ""; + } + if (object.baseDenom !== undefined && object.baseDenom !== null) { + message.baseDenom = object.baseDenom; + } else { + message.baseDenom = ""; + } + return message; + }, +}; + +const baseParams: object = { sendEnabled: false, receiveEnabled: false }; + +export const Params = { + encode(message: Params, writer: Writer = Writer.create()): Writer { + if (message.sendEnabled === true) { + writer.uint32(8).bool(message.sendEnabled); + } + if (message.receiveEnabled === true) { + writer.uint32(16).bool(message.receiveEnabled); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Params { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseParams } as Params; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.sendEnabled = reader.bool(); + break; + case 2: + message.receiveEnabled = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Params { + const message = { ...baseParams } as Params; + if (object.sendEnabled !== undefined && object.sendEnabled !== null) { + message.sendEnabled = Boolean(object.sendEnabled); + } else { + message.sendEnabled = false; + } + if (object.receiveEnabled !== undefined && object.receiveEnabled !== null) { + message.receiveEnabled = Boolean(object.receiveEnabled); + } else { + message.receiveEnabled = false; + } + return message; + }, + + toJSON(message: Params): unknown { + const obj: any = {}; + message.sendEnabled !== undefined && + (obj.sendEnabled = message.sendEnabled); + message.receiveEnabled !== undefined && + (obj.receiveEnabled = message.receiveEnabled); + return obj; + }, + + fromPartial(object: DeepPartial): Params { + const message = { ...baseParams } as Params; + if (object.sendEnabled !== undefined && object.sendEnabled !== null) { + message.sendEnabled = object.sendEnabled; + } else { + message.sendEnabled = false; + } + if (object.receiveEnabled !== undefined && object.receiveEnabled !== null) { + message.receiveEnabled = object.receiveEnabled; + } else { + message.receiveEnabled = false; + } + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/ibc.applications.transfer.v1/types/ibc/applications/transfer/v1/tx.ts b/ts-client/ibc.applications.transfer.v1/types/ibc/applications/transfer/v1/tx.ts new file mode 100644 index 00000000..76dd719c --- /dev/null +++ b/ts-client/ibc.applications.transfer.v1/types/ibc/applications/transfer/v1/tx.ts @@ -0,0 +1,357 @@ +/* eslint-disable */ +import { Reader, util, configure, Writer } from "protobufjs/minimal"; +import * as Long from "long"; +import { Coin } from "../../../../cosmos/base/v1beta1/coin"; +import { Height } from "../../../../ibc/core/client/v1/client"; + +export const protobufPackage = "ibc.applications.transfer.v1"; + +/** + * MsgTransfer defines a msg to transfer fungible tokens (i.e Coins) between + * ICS20 enabled chains. See ICS Spec here: + * https://github.com/cosmos/ibc/tree/master/spec/app/ics-020-fungible-token-transfer#data-structures + */ +export interface MsgTransfer { + /** the port on which the packet will be sent */ + sourcePort: string; + /** the channel by which the packet will be sent */ + sourceChannel: string; + /** the tokens to be transferred */ + token: Coin | undefined; + /** the sender address */ + sender: string; + /** the recipient address on the destination chain */ + receiver: string; + /** + * Timeout height relative to the current block height. + * The timeout is disabled when set to 0. + */ + timeoutHeight: Height | undefined; + /** + * Timeout timestamp in absolute nanoseconds since unix epoch. + * The timeout is disabled when set to 0. + */ + timeoutTimestamp: number; + /** optional memo */ + memo: string; +} + +/** MsgTransferResponse defines the Msg/Transfer response type. */ +export interface MsgTransferResponse { + /** sequence number of the transfer packet sent */ + sequence: number; +} + +const baseMsgTransfer: object = { + sourcePort: "", + sourceChannel: "", + sender: "", + receiver: "", + timeoutTimestamp: 0, + memo: "", +}; + +export const MsgTransfer = { + encode(message: MsgTransfer, writer: Writer = Writer.create()): Writer { + if (message.sourcePort !== "") { + writer.uint32(10).string(message.sourcePort); + } + if (message.sourceChannel !== "") { + writer.uint32(18).string(message.sourceChannel); + } + if (message.token !== undefined) { + Coin.encode(message.token, writer.uint32(26).fork()).ldelim(); + } + if (message.sender !== "") { + writer.uint32(34).string(message.sender); + } + if (message.receiver !== "") { + writer.uint32(42).string(message.receiver); + } + if (message.timeoutHeight !== undefined) { + Height.encode(message.timeoutHeight, writer.uint32(50).fork()).ldelim(); + } + if (message.timeoutTimestamp !== 0) { + writer.uint32(56).uint64(message.timeoutTimestamp); + } + if (message.memo !== "") { + writer.uint32(66).string(message.memo); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MsgTransfer { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgTransfer } as MsgTransfer; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.sourcePort = reader.string(); + break; + case 2: + message.sourceChannel = reader.string(); + break; + case 3: + message.token = Coin.decode(reader, reader.uint32()); + break; + case 4: + message.sender = reader.string(); + break; + case 5: + message.receiver = reader.string(); + break; + case 6: + message.timeoutHeight = Height.decode(reader, reader.uint32()); + break; + case 7: + message.timeoutTimestamp = longToNumber(reader.uint64() as Long); + break; + case 8: + message.memo = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgTransfer { + const message = { ...baseMsgTransfer } as MsgTransfer; + if (object.sourcePort !== undefined && object.sourcePort !== null) { + message.sourcePort = String(object.sourcePort); + } else { + message.sourcePort = ""; + } + if (object.sourceChannel !== undefined && object.sourceChannel !== null) { + message.sourceChannel = String(object.sourceChannel); + } else { + message.sourceChannel = ""; + } + if (object.token !== undefined && object.token !== null) { + message.token = Coin.fromJSON(object.token); + } else { + message.token = undefined; + } + if (object.sender !== undefined && object.sender !== null) { + message.sender = String(object.sender); + } else { + message.sender = ""; + } + if (object.receiver !== undefined && object.receiver !== null) { + message.receiver = String(object.receiver); + } else { + message.receiver = ""; + } + if (object.timeoutHeight !== undefined && object.timeoutHeight !== null) { + message.timeoutHeight = Height.fromJSON(object.timeoutHeight); + } else { + message.timeoutHeight = undefined; + } + if ( + object.timeoutTimestamp !== undefined && + object.timeoutTimestamp !== null + ) { + message.timeoutTimestamp = Number(object.timeoutTimestamp); + } else { + message.timeoutTimestamp = 0; + } + if (object.memo !== undefined && object.memo !== null) { + message.memo = String(object.memo); + } else { + message.memo = ""; + } + return message; + }, + + toJSON(message: MsgTransfer): unknown { + const obj: any = {}; + message.sourcePort !== undefined && (obj.sourcePort = message.sourcePort); + message.sourceChannel !== undefined && + (obj.sourceChannel = message.sourceChannel); + message.token !== undefined && + (obj.token = message.token ? Coin.toJSON(message.token) : undefined); + message.sender !== undefined && (obj.sender = message.sender); + message.receiver !== undefined && (obj.receiver = message.receiver); + message.timeoutHeight !== undefined && + (obj.timeoutHeight = message.timeoutHeight + ? Height.toJSON(message.timeoutHeight) + : undefined); + message.timeoutTimestamp !== undefined && + (obj.timeoutTimestamp = message.timeoutTimestamp); + message.memo !== undefined && (obj.memo = message.memo); + return obj; + }, + + fromPartial(object: DeepPartial): MsgTransfer { + const message = { ...baseMsgTransfer } as MsgTransfer; + if (object.sourcePort !== undefined && object.sourcePort !== null) { + message.sourcePort = object.sourcePort; + } else { + message.sourcePort = ""; + } + if (object.sourceChannel !== undefined && object.sourceChannel !== null) { + message.sourceChannel = object.sourceChannel; + } else { + message.sourceChannel = ""; + } + if (object.token !== undefined && object.token !== null) { + message.token = Coin.fromPartial(object.token); + } else { + message.token = undefined; + } + if (object.sender !== undefined && object.sender !== null) { + message.sender = object.sender; + } else { + message.sender = ""; + } + if (object.receiver !== undefined && object.receiver !== null) { + message.receiver = object.receiver; + } else { + message.receiver = ""; + } + if (object.timeoutHeight !== undefined && object.timeoutHeight !== null) { + message.timeoutHeight = Height.fromPartial(object.timeoutHeight); + } else { + message.timeoutHeight = undefined; + } + if ( + object.timeoutTimestamp !== undefined && + object.timeoutTimestamp !== null + ) { + message.timeoutTimestamp = object.timeoutTimestamp; + } else { + message.timeoutTimestamp = 0; + } + if (object.memo !== undefined && object.memo !== null) { + message.memo = object.memo; + } else { + message.memo = ""; + } + return message; + }, +}; + +const baseMsgTransferResponse: object = { sequence: 0 }; + +export const MsgTransferResponse = { + encode( + message: MsgTransferResponse, + writer: Writer = Writer.create() + ): Writer { + if (message.sequence !== 0) { + writer.uint32(8).uint64(message.sequence); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MsgTransferResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgTransferResponse } as MsgTransferResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.sequence = longToNumber(reader.uint64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgTransferResponse { + const message = { ...baseMsgTransferResponse } as MsgTransferResponse; + if (object.sequence !== undefined && object.sequence !== null) { + message.sequence = Number(object.sequence); + } else { + message.sequence = 0; + } + return message; + }, + + toJSON(message: MsgTransferResponse): unknown { + const obj: any = {}; + message.sequence !== undefined && (obj.sequence = message.sequence); + return obj; + }, + + fromPartial(object: DeepPartial): MsgTransferResponse { + const message = { ...baseMsgTransferResponse } as MsgTransferResponse; + if (object.sequence !== undefined && object.sequence !== null) { + message.sequence = object.sequence; + } else { + message.sequence = 0; + } + return message; + }, +}; + +/** Msg defines the ibc/transfer Msg service. */ +export interface Msg { + /** Transfer defines a rpc handler method for MsgTransfer. */ + Transfer(request: MsgTransfer): Promise; +} + +export class MsgClientImpl implements Msg { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + } + Transfer(request: MsgTransfer): Promise { + const data = MsgTransfer.encode(request).finish(); + const promise = this.rpc.request( + "ibc.applications.transfer.v1.Msg", + "Transfer", + data + ); + return promise.then((data) => MsgTransferResponse.decode(new Reader(data))); + } +} + +interface Rpc { + request( + service: string, + method: string, + data: Uint8Array + ): Promise; +} + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/ibc.applications.transfer.v1/types/ibc/core/client/v1/client.ts b/ts-client/ibc.applications.transfer.v1/types/ibc/core/client/v1/client.ts new file mode 100644 index 00000000..7a8e15b6 --- /dev/null +++ b/ts-client/ibc.applications.transfer.v1/types/ibc/core/client/v1/client.ts @@ -0,0 +1,786 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; +import { Any } from "../../../../google/protobuf/any"; +import { Plan } from "../../../../cosmos/upgrade/v1beta1/upgrade"; + +export const protobufPackage = "ibc.core.client.v1"; + +/** + * IdentifiedClientState defines a client state with an additional client + * identifier field. + */ +export interface IdentifiedClientState { + /** client identifier */ + clientId: string; + /** client state */ + clientState: Any | undefined; +} + +/** + * ConsensusStateWithHeight defines a consensus state with an additional height + * field. + */ +export interface ConsensusStateWithHeight { + /** consensus state height */ + height: Height | undefined; + /** consensus state */ + consensusState: Any | undefined; +} + +/** + * ClientConsensusStates defines all the stored consensus states for a given + * client. + */ +export interface ClientConsensusStates { + /** client identifier */ + clientId: string; + /** consensus states and their heights associated with the client */ + consensusStates: ConsensusStateWithHeight[]; +} + +/** + * ClientUpdateProposal is a governance proposal. If it passes, the substitute + * client's latest consensus state is copied over to the subject client. The proposal + * handler may fail if the subject and the substitute do not match in client and + * chain parameters (with exception to latest height, frozen height, and chain-id). + */ +export interface ClientUpdateProposal { + /** the title of the update proposal */ + title: string; + /** the description of the proposal */ + description: string; + /** the client identifier for the client to be updated if the proposal passes */ + subjectClientId: string; + /** + * the substitute client identifier for the client standing in for the subject + * client + */ + substituteClientId: string; +} + +/** + * UpgradeProposal is a gov Content type for initiating an IBC breaking + * upgrade. + */ +export interface UpgradeProposal { + title: string; + description: string; + plan: Plan | undefined; + /** + * An UpgradedClientState must be provided to perform an IBC breaking upgrade. + * This will make the chain commit to the correct upgraded (self) client state + * before the upgrade occurs, so that connecting chains can verify that the + * new upgraded client is valid by verifying a proof on the previous version + * of the chain. This will allow IBC connections to persist smoothly across + * planned chain upgrades + */ + upgradedClientState: Any | undefined; +} + +/** + * Height is a monotonically increasing data type + * that can be compared against another Height for the purposes of updating and + * freezing clients + * + * Normally the RevisionHeight is incremented at each height while keeping + * RevisionNumber the same. However some consensus algorithms may choose to + * reset the height in certain conditions e.g. hard forks, state-machine + * breaking changes In these cases, the RevisionNumber is incremented so that + * height continues to be monitonically increasing even as the RevisionHeight + * gets reset + */ +export interface Height { + /** the revision that the client is currently on */ + revisionNumber: number; + /** the height within the given revision */ + revisionHeight: number; +} + +/** Params defines the set of IBC light client parameters. */ +export interface Params { + /** allowed_clients defines the list of allowed client state types. */ + allowedClients: string[]; +} + +const baseIdentifiedClientState: object = { clientId: "" }; + +export const IdentifiedClientState = { + encode( + message: IdentifiedClientState, + writer: Writer = Writer.create() + ): Writer { + if (message.clientId !== "") { + writer.uint32(10).string(message.clientId); + } + if (message.clientState !== undefined) { + Any.encode(message.clientState, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): IdentifiedClientState { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseIdentifiedClientState } as IdentifiedClientState; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.clientId = reader.string(); + break; + case 2: + message.clientState = Any.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): IdentifiedClientState { + const message = { ...baseIdentifiedClientState } as IdentifiedClientState; + if (object.clientId !== undefined && object.clientId !== null) { + message.clientId = String(object.clientId); + } else { + message.clientId = ""; + } + if (object.clientState !== undefined && object.clientState !== null) { + message.clientState = Any.fromJSON(object.clientState); + } else { + message.clientState = undefined; + } + return message; + }, + + toJSON(message: IdentifiedClientState): unknown { + const obj: any = {}; + message.clientId !== undefined && (obj.clientId = message.clientId); + message.clientState !== undefined && + (obj.clientState = message.clientState + ? Any.toJSON(message.clientState) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): IdentifiedClientState { + const message = { ...baseIdentifiedClientState } as IdentifiedClientState; + if (object.clientId !== undefined && object.clientId !== null) { + message.clientId = object.clientId; + } else { + message.clientId = ""; + } + if (object.clientState !== undefined && object.clientState !== null) { + message.clientState = Any.fromPartial(object.clientState); + } else { + message.clientState = undefined; + } + return message; + }, +}; + +const baseConsensusStateWithHeight: object = {}; + +export const ConsensusStateWithHeight = { + encode( + message: ConsensusStateWithHeight, + writer: Writer = Writer.create() + ): Writer { + if (message.height !== undefined) { + Height.encode(message.height, writer.uint32(10).fork()).ldelim(); + } + if (message.consensusState !== undefined) { + Any.encode(message.consensusState, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): ConsensusStateWithHeight { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseConsensusStateWithHeight, + } as ConsensusStateWithHeight; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.height = Height.decode(reader, reader.uint32()); + break; + case 2: + message.consensusState = Any.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ConsensusStateWithHeight { + const message = { + ...baseConsensusStateWithHeight, + } as ConsensusStateWithHeight; + if (object.height !== undefined && object.height !== null) { + message.height = Height.fromJSON(object.height); + } else { + message.height = undefined; + } + if (object.consensusState !== undefined && object.consensusState !== null) { + message.consensusState = Any.fromJSON(object.consensusState); + } else { + message.consensusState = undefined; + } + return message; + }, + + toJSON(message: ConsensusStateWithHeight): unknown { + const obj: any = {}; + message.height !== undefined && + (obj.height = message.height ? Height.toJSON(message.height) : undefined); + message.consensusState !== undefined && + (obj.consensusState = message.consensusState + ? Any.toJSON(message.consensusState) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): ConsensusStateWithHeight { + const message = { + ...baseConsensusStateWithHeight, + } as ConsensusStateWithHeight; + if (object.height !== undefined && object.height !== null) { + message.height = Height.fromPartial(object.height); + } else { + message.height = undefined; + } + if (object.consensusState !== undefined && object.consensusState !== null) { + message.consensusState = Any.fromPartial(object.consensusState); + } else { + message.consensusState = undefined; + } + return message; + }, +}; + +const baseClientConsensusStates: object = { clientId: "" }; + +export const ClientConsensusStates = { + encode( + message: ClientConsensusStates, + writer: Writer = Writer.create() + ): Writer { + if (message.clientId !== "") { + writer.uint32(10).string(message.clientId); + } + for (const v of message.consensusStates) { + ConsensusStateWithHeight.encode(v!, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ClientConsensusStates { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseClientConsensusStates } as ClientConsensusStates; + message.consensusStates = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.clientId = reader.string(); + break; + case 2: + message.consensusStates.push( + ConsensusStateWithHeight.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ClientConsensusStates { + const message = { ...baseClientConsensusStates } as ClientConsensusStates; + message.consensusStates = []; + if (object.clientId !== undefined && object.clientId !== null) { + message.clientId = String(object.clientId); + } else { + message.clientId = ""; + } + if ( + object.consensusStates !== undefined && + object.consensusStates !== null + ) { + for (const e of object.consensusStates) { + message.consensusStates.push(ConsensusStateWithHeight.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: ClientConsensusStates): unknown { + const obj: any = {}; + message.clientId !== undefined && (obj.clientId = message.clientId); + if (message.consensusStates) { + obj.consensusStates = message.consensusStates.map((e) => + e ? ConsensusStateWithHeight.toJSON(e) : undefined + ); + } else { + obj.consensusStates = []; + } + return obj; + }, + + fromPartial( + object: DeepPartial + ): ClientConsensusStates { + const message = { ...baseClientConsensusStates } as ClientConsensusStates; + message.consensusStates = []; + if (object.clientId !== undefined && object.clientId !== null) { + message.clientId = object.clientId; + } else { + message.clientId = ""; + } + if ( + object.consensusStates !== undefined && + object.consensusStates !== null + ) { + for (const e of object.consensusStates) { + message.consensusStates.push(ConsensusStateWithHeight.fromPartial(e)); + } + } + return message; + }, +}; + +const baseClientUpdateProposal: object = { + title: "", + description: "", + subjectClientId: "", + substituteClientId: "", +}; + +export const ClientUpdateProposal = { + encode( + message: ClientUpdateProposal, + writer: Writer = Writer.create() + ): Writer { + if (message.title !== "") { + writer.uint32(10).string(message.title); + } + if (message.description !== "") { + writer.uint32(18).string(message.description); + } + if (message.subjectClientId !== "") { + writer.uint32(26).string(message.subjectClientId); + } + if (message.substituteClientId !== "") { + writer.uint32(34).string(message.substituteClientId); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ClientUpdateProposal { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseClientUpdateProposal } as ClientUpdateProposal; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.title = reader.string(); + break; + case 2: + message.description = reader.string(); + break; + case 3: + message.subjectClientId = reader.string(); + break; + case 4: + message.substituteClientId = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ClientUpdateProposal { + const message = { ...baseClientUpdateProposal } as ClientUpdateProposal; + if (object.title !== undefined && object.title !== null) { + message.title = String(object.title); + } else { + message.title = ""; + } + if (object.description !== undefined && object.description !== null) { + message.description = String(object.description); + } else { + message.description = ""; + } + if ( + object.subjectClientId !== undefined && + object.subjectClientId !== null + ) { + message.subjectClientId = String(object.subjectClientId); + } else { + message.subjectClientId = ""; + } + if ( + object.substituteClientId !== undefined && + object.substituteClientId !== null + ) { + message.substituteClientId = String(object.substituteClientId); + } else { + message.substituteClientId = ""; + } + return message; + }, + + toJSON(message: ClientUpdateProposal): unknown { + const obj: any = {}; + message.title !== undefined && (obj.title = message.title); + message.description !== undefined && + (obj.description = message.description); + message.subjectClientId !== undefined && + (obj.subjectClientId = message.subjectClientId); + message.substituteClientId !== undefined && + (obj.substituteClientId = message.substituteClientId); + return obj; + }, + + fromPartial(object: DeepPartial): ClientUpdateProposal { + const message = { ...baseClientUpdateProposal } as ClientUpdateProposal; + if (object.title !== undefined && object.title !== null) { + message.title = object.title; + } else { + message.title = ""; + } + if (object.description !== undefined && object.description !== null) { + message.description = object.description; + } else { + message.description = ""; + } + if ( + object.subjectClientId !== undefined && + object.subjectClientId !== null + ) { + message.subjectClientId = object.subjectClientId; + } else { + message.subjectClientId = ""; + } + if ( + object.substituteClientId !== undefined && + object.substituteClientId !== null + ) { + message.substituteClientId = object.substituteClientId; + } else { + message.substituteClientId = ""; + } + return message; + }, +}; + +const baseUpgradeProposal: object = { title: "", description: "" }; + +export const UpgradeProposal = { + encode(message: UpgradeProposal, writer: Writer = Writer.create()): Writer { + if (message.title !== "") { + writer.uint32(10).string(message.title); + } + if (message.description !== "") { + writer.uint32(18).string(message.description); + } + if (message.plan !== undefined) { + Plan.encode(message.plan, writer.uint32(26).fork()).ldelim(); + } + if (message.upgradedClientState !== undefined) { + Any.encode( + message.upgradedClientState, + writer.uint32(34).fork() + ).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): UpgradeProposal { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseUpgradeProposal } as UpgradeProposal; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.title = reader.string(); + break; + case 2: + message.description = reader.string(); + break; + case 3: + message.plan = Plan.decode(reader, reader.uint32()); + break; + case 4: + message.upgradedClientState = Any.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): UpgradeProposal { + const message = { ...baseUpgradeProposal } as UpgradeProposal; + if (object.title !== undefined && object.title !== null) { + message.title = String(object.title); + } else { + message.title = ""; + } + if (object.description !== undefined && object.description !== null) { + message.description = String(object.description); + } else { + message.description = ""; + } + if (object.plan !== undefined && object.plan !== null) { + message.plan = Plan.fromJSON(object.plan); + } else { + message.plan = undefined; + } + if ( + object.upgradedClientState !== undefined && + object.upgradedClientState !== null + ) { + message.upgradedClientState = Any.fromJSON(object.upgradedClientState); + } else { + message.upgradedClientState = undefined; + } + return message; + }, + + toJSON(message: UpgradeProposal): unknown { + const obj: any = {}; + message.title !== undefined && (obj.title = message.title); + message.description !== undefined && + (obj.description = message.description); + message.plan !== undefined && + (obj.plan = message.plan ? Plan.toJSON(message.plan) : undefined); + message.upgradedClientState !== undefined && + (obj.upgradedClientState = message.upgradedClientState + ? Any.toJSON(message.upgradedClientState) + : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): UpgradeProposal { + const message = { ...baseUpgradeProposal } as UpgradeProposal; + if (object.title !== undefined && object.title !== null) { + message.title = object.title; + } else { + message.title = ""; + } + if (object.description !== undefined && object.description !== null) { + message.description = object.description; + } else { + message.description = ""; + } + if (object.plan !== undefined && object.plan !== null) { + message.plan = Plan.fromPartial(object.plan); + } else { + message.plan = undefined; + } + if ( + object.upgradedClientState !== undefined && + object.upgradedClientState !== null + ) { + message.upgradedClientState = Any.fromPartial(object.upgradedClientState); + } else { + message.upgradedClientState = undefined; + } + return message; + }, +}; + +const baseHeight: object = { revisionNumber: 0, revisionHeight: 0 }; + +export const Height = { + encode(message: Height, writer: Writer = Writer.create()): Writer { + if (message.revisionNumber !== 0) { + writer.uint32(8).uint64(message.revisionNumber); + } + if (message.revisionHeight !== 0) { + writer.uint32(16).uint64(message.revisionHeight); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Height { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseHeight } as Height; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.revisionNumber = longToNumber(reader.uint64() as Long); + break; + case 2: + message.revisionHeight = longToNumber(reader.uint64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Height { + const message = { ...baseHeight } as Height; + if (object.revisionNumber !== undefined && object.revisionNumber !== null) { + message.revisionNumber = Number(object.revisionNumber); + } else { + message.revisionNumber = 0; + } + if (object.revisionHeight !== undefined && object.revisionHeight !== null) { + message.revisionHeight = Number(object.revisionHeight); + } else { + message.revisionHeight = 0; + } + return message; + }, + + toJSON(message: Height): unknown { + const obj: any = {}; + message.revisionNumber !== undefined && + (obj.revisionNumber = message.revisionNumber); + message.revisionHeight !== undefined && + (obj.revisionHeight = message.revisionHeight); + return obj; + }, + + fromPartial(object: DeepPartial): Height { + const message = { ...baseHeight } as Height; + if (object.revisionNumber !== undefined && object.revisionNumber !== null) { + message.revisionNumber = object.revisionNumber; + } else { + message.revisionNumber = 0; + } + if (object.revisionHeight !== undefined && object.revisionHeight !== null) { + message.revisionHeight = object.revisionHeight; + } else { + message.revisionHeight = 0; + } + return message; + }, +}; + +const baseParams: object = { allowedClients: "" }; + +export const Params = { + encode(message: Params, writer: Writer = Writer.create()): Writer { + for (const v of message.allowedClients) { + writer.uint32(10).string(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Params { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseParams } as Params; + message.allowedClients = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.allowedClients.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Params { + const message = { ...baseParams } as Params; + message.allowedClients = []; + if (object.allowedClients !== undefined && object.allowedClients !== null) { + for (const e of object.allowedClients) { + message.allowedClients.push(String(e)); + } + } + return message; + }, + + toJSON(message: Params): unknown { + const obj: any = {}; + if (message.allowedClients) { + obj.allowedClients = message.allowedClients.map((e) => e); + } else { + obj.allowedClients = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): Params { + const message = { ...baseParams } as Params; + message.allowedClients = []; + if (object.allowedClients !== undefined && object.allowedClients !== null) { + for (const e of object.allowedClients) { + message.allowedClients.push(e); + } + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/ibc.core.channel.v1/index.ts b/ts-client/ibc.core.channel.v1/index.ts new file mode 100755 index 00000000..c9dfa159 --- /dev/null +++ b/ts-client/ibc.core.channel.v1/index.ts @@ -0,0 +1,6 @@ +import Module from './module'; +import { txClient, queryClient, registry } from './module'; +import { msgTypes } from './registry'; + +export * from "./types"; +export { Module, msgTypes, txClient, queryClient, registry }; diff --git a/ts-client/ibc.core.channel.v1/module.ts b/ts-client/ibc.core.channel.v1/module.ts new file mode 100755 index 00000000..79c8a694 --- /dev/null +++ b/ts-client/ibc.core.channel.v1/module.ts @@ -0,0 +1,66 @@ +// Generated by Ignite ignite.com/cli + +import { StdFee } from "@cosmjs/launchpad"; +import { SigningStargateClient, DeliverTxResponse } from "@cosmjs/stargate"; +import { EncodeObject, GeneratedType, OfflineSigner, Registry } from "@cosmjs/proto-signing"; +import { msgTypes } from './registry'; +import { IgniteClient } from "../client" +import { MissingWalletError } from "../helpers" +import { Api } from "./rest"; + + +export { }; + + + +export const registry = new Registry(msgTypes); + +const defaultFee = { + amount: [], + gas: "200000", +}; + +interface TxClientOptions { + addr: string + prefix: string + signer?: OfflineSigner +} + +export const txClient = ({ signer, prefix, addr }: TxClientOptions = { addr: "http://localhost:26657", prefix: "cosmos" }) => { + + return { + + + } +}; + +interface QueryClientOptions { + addr: string +} + +export const queryClient = ({ addr: addr }: QueryClientOptions = { addr: "http://localhost:1317" }) => { + return new Api({ baseUrl: addr }); +}; + +class SDKModule { + public query: ReturnType; + public tx: ReturnType; + + public registry: Array<[string, GeneratedType]>; + + constructor(client: IgniteClient) { + + this.query = queryClient({ addr: client.env.apiURL }); + this.tx = txClient({ signer: client.signer, addr: client.env.rpcURL, prefix: client.env.prefix ?? "cosmos" }); + } +}; + +const Module = (test: IgniteClient) => { + return { + module: { + IbcCoreChannelV1: new SDKModule(test) + }, + registry: msgTypes + } +} +export default Module; \ No newline at end of file diff --git a/ts-client/ibc.core.channel.v1/registry.ts b/ts-client/ibc.core.channel.v1/registry.ts new file mode 100755 index 00000000..26157e4f --- /dev/null +++ b/ts-client/ibc.core.channel.v1/registry.ts @@ -0,0 +1,7 @@ +import { GeneratedType } from "@cosmjs/proto-signing"; + +const msgTypes: Array<[string, GeneratedType]> = [ + +]; + +export { msgTypes } \ No newline at end of file diff --git a/ts-client/ibc.core.channel.v1/rest.ts b/ts-client/ibc.core.channel.v1/rest.ts new file mode 100644 index 00000000..740ef065 --- /dev/null +++ b/ts-client/ibc.core.channel.v1/rest.ts @@ -0,0 +1,1399 @@ +/* eslint-disable */ +/* tslint:disable */ +/* + * --------------------------------------------------------------- + * ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ## + * ## ## + * ## AUTHOR: acacode ## + * ## SOURCE: https://github.com/acacode/swagger-typescript-api ## + * --------------------------------------------------------------- + */ + +/** +* Channel defines pipeline for exactly-once packet delivery between specific +modules on separate blockchains, which has at least one end capable of +sending packets and one end capable of receiving packets. +*/ +export interface Channelv1Channel { + /** + * State defines if a channel is in one of the following states: + * CLOSED, INIT, TRYOPEN, OPEN or UNINITIALIZED. + * + * - STATE_UNINITIALIZED_UNSPECIFIED: Default State + * - STATE_INIT: A channel has just started the opening handshake. + * - STATE_TRYOPEN: A channel has acknowledged the handshake step on the counterparty chain. + * - STATE_OPEN: A channel has completed the handshake. Open channels are + * ready to send and receive packets. + * - STATE_CLOSED: A channel has been closed and can no longer be used to send or receive + * packets. + */ + state?: V1State; + + /** + * - ORDER_NONE_UNSPECIFIED: zero-value for channel ordering + * - ORDER_UNORDERED: packets can be delivered in any order, which may differ from the order in + * which they were sent. + * - ORDER_ORDERED: packets are delivered exactly in the order which they were sent + */ + ordering?: V1Order; + counterparty?: V1Counterparty; + connection_hops?: string[]; + version?: string; +} + +/** +* `Any` contains an arbitrary serialized protocol buffer message along with a +URL that describes the type of the serialized message. + +Protobuf library provides support to pack/unpack Any values in the form +of utility functions or additional generated methods of the Any type. + +Example 1: Pack and unpack a message in C++. + + Foo foo = ...; + Any any; + any.PackFrom(foo); + ... + if (any.UnpackTo(&foo)) { + ... + } + +Example 2: Pack and unpack a message in Java. + + Foo foo = ...; + Any any = Any.pack(foo); + ... + if (any.is(Foo.class)) { + foo = any.unpack(Foo.class); + } + + Example 3: Pack and unpack a message in Python. + + foo = Foo(...) + any = Any() + any.Pack(foo) + ... + if any.Is(Foo.DESCRIPTOR): + any.Unpack(foo) + ... + + Example 4: Pack and unpack a message in Go + + foo := &pb.Foo{...} + any, err := anypb.New(foo) + if err != nil { + ... + } + ... + foo := &pb.Foo{} + if err := any.UnmarshalTo(foo); err != nil { + ... + } + +The pack methods provided by protobuf library will by default use +'type.googleapis.com/full.type.name' as the type URL and the unpack +methods only use the fully qualified type name after the last '/' +in the type URL, for example "foo.bar.com/x/y.z" will yield type +name "y.z". + + +JSON +==== +The JSON representation of an `Any` value uses the regular +representation of the deserialized, embedded message, with an +additional field `@type` which contains the type URL. Example: + + package google.profile; + message Person { + string first_name = 1; + string last_name = 2; + } + + { + "@type": "type.googleapis.com/google.profile.Person", + "firstName": , + "lastName": + } + +If the embedded message type is well-known and has a custom JSON +representation, that representation will be embedded adding a field +`value` which holds the custom JSON in addition to the `@type` +field. Example (for message [google.protobuf.Duration][]): + + { + "@type": "type.googleapis.com/google.protobuf.Duration", + "value": "1.212s" + } +*/ +export interface ProtobufAny { + /** + * A URL/resource name that uniquely identifies the type of the serialized + * protocol buffer message. This string must contain at least + * one "/" character. The last segment of the URL's path must represent + * the fully qualified name of the type (as in + * `path/google.protobuf.Duration`). The name should be in a canonical form + * (e.g., leading "." is not accepted). + * + * In practice, teams usually precompile into the binary all types that they + * expect it to use in the context of Any. However, for URLs which use the + * scheme `http`, `https`, or no scheme, one can optionally set up a type + * server that maps type URLs to message definitions as follows: + * + * * If no scheme is provided, `https` is assumed. + * * An HTTP GET on the URL must yield a [google.protobuf.Type][] + * value in binary format, or produce an error. + * * Applications are allowed to cache lookup results based on the + * URL, or have them precompiled into a binary to avoid any + * lookup. Therefore, binary compatibility needs to be preserved + * on changes to types. (Use versioned type names to manage + * breaking changes.) + * + * Note: this functionality is not currently available in the official + * protobuf release, and it is not used for type URLs beginning with + * type.googleapis.com. + * + * Schemes other than `http`, `https` (or the empty scheme) might be + * used with implementation specific semantics. + */ + "@type"?: string; +} + +export interface RpcStatus { + /** @format int32 */ + code?: number; + message?: string; + details?: ProtobufAny[]; +} + +export interface V1Counterparty { + /** port on the counterparty chain which owns the other end of the channel. */ + port_id?: string; + channel_id?: string; +} + +/** +* Normally the RevisionHeight is incremented at each height while keeping +RevisionNumber the same. However some consensus algorithms may choose to +reset the height in certain conditions e.g. hard forks, state-machine +breaking changes In these cases, the RevisionNumber is incremented so that +height continues to be monitonically increasing even as the RevisionHeight +gets reset +*/ +export interface V1Height { + /** @format uint64 */ + revision_number?: string; + + /** @format uint64 */ + revision_height?: string; +} + +/** +* IdentifiedChannel defines a channel with additional port and channel +identifier fields. +*/ +export interface V1IdentifiedChannel { + /** + * State defines if a channel is in one of the following states: + * CLOSED, INIT, TRYOPEN, OPEN or UNINITIALIZED. + * + * - STATE_UNINITIALIZED_UNSPECIFIED: Default State + * - STATE_INIT: A channel has just started the opening handshake. + * - STATE_TRYOPEN: A channel has acknowledged the handshake step on the counterparty chain. + * - STATE_OPEN: A channel has completed the handshake. Open channels are + * ready to send and receive packets. + * - STATE_CLOSED: A channel has been closed and can no longer be used to send or receive + * packets. + */ + state?: V1State; + + /** + * - ORDER_NONE_UNSPECIFIED: zero-value for channel ordering + * - ORDER_UNORDERED: packets can be delivered in any order, which may differ from the order in + * which they were sent. + * - ORDER_ORDERED: packets are delivered exactly in the order which they were sent + */ + ordering?: V1Order; + counterparty?: V1Counterparty; + connection_hops?: string[]; + version?: string; + port_id?: string; + channel_id?: string; +} + +/** +* IdentifiedClientState defines a client state with an additional client +identifier field. +*/ +export interface V1IdentifiedClientState { + client_id?: string; + + /** + * `Any` contains an arbitrary serialized protocol buffer message along with a + * URL that describes the type of the serialized message. + * + * Protobuf library provides support to pack/unpack Any values in the form + * of utility functions or additional generated methods of the Any type. + * + * Example 1: Pack and unpack a message in C++. + * + * Foo foo = ...; + * Any any; + * any.PackFrom(foo); + * ... + * if (any.UnpackTo(&foo)) { + * ... + * } + * + * Example 2: Pack and unpack a message in Java. + * + * Foo foo = ...; + * Any any = Any.pack(foo); + * ... + * if (any.is(Foo.class)) { + * foo = any.unpack(Foo.class); + * } + * + * Example 3: Pack and unpack a message in Python. + * + * foo = Foo(...) + * any = Any() + * any.Pack(foo) + * ... + * if any.Is(Foo.DESCRIPTOR): + * any.Unpack(foo) + * ... + * + * Example 4: Pack and unpack a message in Go + * + * foo := &pb.Foo{...} + * any, err := anypb.New(foo) + * if err != nil { + * ... + * } + * ... + * foo := &pb.Foo{} + * if err := any.UnmarshalTo(foo); err != nil { + * ... + * } + * + * The pack methods provided by protobuf library will by default use + * 'type.googleapis.com/full.type.name' as the type URL and the unpack + * methods only use the fully qualified type name after the last '/' + * in the type URL, for example "foo.bar.com/x/y.z" will yield type + * name "y.z". + * + * + * JSON + * ==== + * The JSON representation of an `Any` value uses the regular + * representation of the deserialized, embedded message, with an + * additional field `@type` which contains the type URL. Example: + * + * package google.profile; + * message Person { + * string first_name = 1; + * string last_name = 2; + * } + * + * { + * "@type": "type.googleapis.com/google.profile.Person", + * "firstName": , + * "lastName": + * } + * + * If the embedded message type is well-known and has a custom JSON + * representation, that representation will be embedded adding a field + * `value` which holds the custom JSON in addition to the `@type` + * field. Example (for message [google.protobuf.Duration][]): + * + * { + * "@type": "type.googleapis.com/google.protobuf.Duration", + * "value": "1.212s" + * } + */ + client_state?: ProtobufAny; +} + +/** + * MsgAcknowledgementResponse defines the Msg/Acknowledgement response type. + */ +export interface V1MsgAcknowledgementResponse { + /** + * - RESPONSE_RESULT_TYPE_UNSPECIFIED: Default zero value enumeration + * - RESPONSE_RESULT_TYPE_NOOP: The message did not call the IBC application callbacks (because, for example, the packet had already been relayed) + * - RESPONSE_RESULT_TYPE_SUCCESS: The message was executed successfully + */ + result?: V1ResponseResultType; +} + +/** +* MsgChannelCloseConfirmResponse defines the Msg/ChannelCloseConfirm response +type. +*/ +export type V1MsgChannelCloseConfirmResponse = object; + +/** + * MsgChannelCloseInitResponse defines the Msg/ChannelCloseInit response type. + */ +export type V1MsgChannelCloseInitResponse = object; + +/** + * MsgChannelOpenAckResponse defines the Msg/ChannelOpenAck response type. + */ +export type V1MsgChannelOpenAckResponse = object; + +/** +* MsgChannelOpenConfirmResponse defines the Msg/ChannelOpenConfirm response +type. +*/ +export type V1MsgChannelOpenConfirmResponse = object; + +/** + * MsgChannelOpenInitResponse defines the Msg/ChannelOpenInit response type. + */ +export interface V1MsgChannelOpenInitResponse { + channel_id?: string; + version?: string; +} + +/** + * MsgChannelOpenTryResponse defines the Msg/ChannelOpenTry response type. + */ +export interface V1MsgChannelOpenTryResponse { + version?: string; +} + +/** + * MsgRecvPacketResponse defines the Msg/RecvPacket response type. + */ +export interface V1MsgRecvPacketResponse { + /** + * - RESPONSE_RESULT_TYPE_UNSPECIFIED: Default zero value enumeration + * - RESPONSE_RESULT_TYPE_NOOP: The message did not call the IBC application callbacks (because, for example, the packet had already been relayed) + * - RESPONSE_RESULT_TYPE_SUCCESS: The message was executed successfully + */ + result?: V1ResponseResultType; +} + +/** + * MsgTimeoutOnCloseResponse defines the Msg/TimeoutOnClose response type. + */ +export interface V1MsgTimeoutOnCloseResponse { + /** + * - RESPONSE_RESULT_TYPE_UNSPECIFIED: Default zero value enumeration + * - RESPONSE_RESULT_TYPE_NOOP: The message did not call the IBC application callbacks (because, for example, the packet had already been relayed) + * - RESPONSE_RESULT_TYPE_SUCCESS: The message was executed successfully + */ + result?: V1ResponseResultType; +} + +/** + * MsgTimeoutResponse defines the Msg/Timeout response type. + */ +export interface V1MsgTimeoutResponse { + /** + * - RESPONSE_RESULT_TYPE_UNSPECIFIED: Default zero value enumeration + * - RESPONSE_RESULT_TYPE_NOOP: The message did not call the IBC application callbacks (because, for example, the packet had already been relayed) + * - RESPONSE_RESULT_TYPE_SUCCESS: The message was executed successfully + */ + result?: V1ResponseResultType; +} + +/** +* - ORDER_NONE_UNSPECIFIED: zero-value for channel ordering + - ORDER_UNORDERED: packets can be delivered in any order, which may differ from the order in +which they were sent. + - ORDER_ORDERED: packets are delivered exactly in the order which they were sent +*/ +export enum V1Order { + ORDER_NONE_UNSPECIFIED = "ORDER_NONE_UNSPECIFIED", + ORDER_UNORDERED = "ORDER_UNORDERED", + ORDER_ORDERED = "ORDER_ORDERED", +} + +export interface V1Packet { + /** + * number corresponds to the order of sends and receives, where a Packet + * with an earlier sequence number must be sent and received before a Packet + * with a later sequence number. + * @format uint64 + */ + sequence?: string; + + /** identifies the port on the sending chain. */ + source_port?: string; + + /** identifies the channel end on the sending chain. */ + source_channel?: string; + + /** identifies the port on the receiving chain. */ + destination_port?: string; + + /** identifies the channel end on the receiving chain. */ + destination_channel?: string; + + /** @format byte */ + data?: string; + + /** + * Normally the RevisionHeight is incremented at each height while keeping + * RevisionNumber the same. However some consensus algorithms may choose to + * reset the height in certain conditions e.g. hard forks, state-machine + * breaking changes In these cases, the RevisionNumber is incremented so that + * height continues to be monitonically increasing even as the RevisionHeight + * gets reset + */ + timeout_height?: V1Height; + + /** @format uint64 */ + timeout_timestamp?: string; +} + +/** +* PacketState defines the generic type necessary to retrieve and store +packet commitments, acknowledgements, and receipts. +Caller is responsible for knowing the context necessary to interpret this +state as a commitment, acknowledgement, or a receipt. +*/ +export interface V1PacketState { + /** channel port identifier. */ + port_id?: string; + + /** channel unique identifier. */ + channel_id?: string; + + /** + * packet sequence. + * @format uint64 + */ + sequence?: string; + + /** + * embedded data that represents packet state. + * @format byte + */ + data?: string; +} + +export interface V1QueryChannelClientStateResponse { + /** + * IdentifiedClientState defines a client state with an additional client + * identifier field. + */ + identified_client_state?: V1IdentifiedClientState; + + /** @format byte */ + proof?: string; + + /** + * Normally the RevisionHeight is incremented at each height while keeping + * RevisionNumber the same. However some consensus algorithms may choose to + * reset the height in certain conditions e.g. hard forks, state-machine + * breaking changes In these cases, the RevisionNumber is incremented so that + * height continues to be monitonically increasing even as the RevisionHeight + * gets reset + */ + proof_height?: V1Height; +} + +export interface V1QueryChannelConsensusStateResponse { + /** + * `Any` contains an arbitrary serialized protocol buffer message along with a + * URL that describes the type of the serialized message. + * + * Protobuf library provides support to pack/unpack Any values in the form + * of utility functions or additional generated methods of the Any type. + * + * Example 1: Pack and unpack a message in C++. + * + * Foo foo = ...; + * Any any; + * any.PackFrom(foo); + * ... + * if (any.UnpackTo(&foo)) { + * ... + * } + * + * Example 2: Pack and unpack a message in Java. + * + * Foo foo = ...; + * Any any = Any.pack(foo); + * ... + * if (any.is(Foo.class)) { + * foo = any.unpack(Foo.class); + * } + * + * Example 3: Pack and unpack a message in Python. + * + * foo = Foo(...) + * any = Any() + * any.Pack(foo) + * ... + * if any.Is(Foo.DESCRIPTOR): + * any.Unpack(foo) + * ... + * + * Example 4: Pack and unpack a message in Go + * + * foo := &pb.Foo{...} + * any, err := anypb.New(foo) + * if err != nil { + * ... + * } + * ... + * foo := &pb.Foo{} + * if err := any.UnmarshalTo(foo); err != nil { + * ... + * } + * + * The pack methods provided by protobuf library will by default use + * 'type.googleapis.com/full.type.name' as the type URL and the unpack + * methods only use the fully qualified type name after the last '/' + * in the type URL, for example "foo.bar.com/x/y.z" will yield type + * name "y.z". + * + * + * JSON + * ==== + * The JSON representation of an `Any` value uses the regular + * representation of the deserialized, embedded message, with an + * additional field `@type` which contains the type URL. Example: + * + * package google.profile; + * message Person { + * string first_name = 1; + * string last_name = 2; + * } + * + * { + * "@type": "type.googleapis.com/google.profile.Person", + * "firstName": , + * "lastName": + * } + * + * If the embedded message type is well-known and has a custom JSON + * representation, that representation will be embedded adding a field + * `value` which holds the custom JSON in addition to the `@type` + * field. Example (for message [google.protobuf.Duration][]): + * + * { + * "@type": "type.googleapis.com/google.protobuf.Duration", + * "value": "1.212s" + * } + */ + consensus_state?: ProtobufAny; + client_id?: string; + + /** @format byte */ + proof?: string; + + /** + * Normally the RevisionHeight is incremented at each height while keeping + * RevisionNumber the same. However some consensus algorithms may choose to + * reset the height in certain conditions e.g. hard forks, state-machine + * breaking changes In these cases, the RevisionNumber is incremented so that + * height continues to be monitonically increasing even as the RevisionHeight + * gets reset + */ + proof_height?: V1Height; +} + +/** +* QueryChannelResponse is the response type for the Query/Channel RPC method. +Besides the Channel end, it includes a proof and the height from which the +proof was retrieved. +*/ +export interface V1QueryChannelResponse { + /** + * Channel defines pipeline for exactly-once packet delivery between specific + * modules on separate blockchains, which has at least one end capable of + * sending packets and one end capable of receiving packets. + */ + channel?: Channelv1Channel; + + /** @format byte */ + proof?: string; + + /** + * Normally the RevisionHeight is incremented at each height while keeping + * RevisionNumber the same. However some consensus algorithms may choose to + * reset the height in certain conditions e.g. hard forks, state-machine + * breaking changes In these cases, the RevisionNumber is incremented so that + * height continues to be monitonically increasing even as the RevisionHeight + * gets reset + */ + proof_height?: V1Height; +} + +/** + * QueryChannelsResponse is the response type for the Query/Channels RPC method. + */ +export interface V1QueryChannelsResponse { + /** list of stored channels of the chain. */ + channels?: V1IdentifiedChannel[]; + + /** + * PageResponse is to be embedded in gRPC response messages where the + * corresponding request message has used PageRequest. + * + * message SomeResponse { + * repeated Bar results = 1; + * PageResponse page = 2; + * } + */ + pagination?: V1Beta1PageResponse; + + /** + * Normally the RevisionHeight is incremented at each height while keeping + * RevisionNumber the same. However some consensus algorithms may choose to + * reset the height in certain conditions e.g. hard forks, state-machine + * breaking changes In these cases, the RevisionNumber is incremented so that + * height continues to be monitonically increasing even as the RevisionHeight + * gets reset + */ + height?: V1Height; +} + +export interface V1QueryConnectionChannelsResponse { + /** list of channels associated with a connection. */ + channels?: V1IdentifiedChannel[]; + + /** + * PageResponse is to be embedded in gRPC response messages where the + * corresponding request message has used PageRequest. + * + * message SomeResponse { + * repeated Bar results = 1; + * PageResponse page = 2; + * } + */ + pagination?: V1Beta1PageResponse; + + /** + * Normally the RevisionHeight is incremented at each height while keeping + * RevisionNumber the same. However some consensus algorithms may choose to + * reset the height in certain conditions e.g. hard forks, state-machine + * breaking changes In these cases, the RevisionNumber is incremented so that + * height continues to be monitonically increasing even as the RevisionHeight + * gets reset + */ + height?: V1Height; +} + +export interface V1QueryNextSequenceReceiveResponse { + /** @format uint64 */ + next_sequence_receive?: string; + + /** @format byte */ + proof?: string; + + /** + * Normally the RevisionHeight is incremented at each height while keeping + * RevisionNumber the same. However some consensus algorithms may choose to + * reset the height in certain conditions e.g. hard forks, state-machine + * breaking changes In these cases, the RevisionNumber is incremented so that + * height continues to be monitonically increasing even as the RevisionHeight + * gets reset + */ + proof_height?: V1Height; +} + +export interface V1QueryPacketAcknowledgementResponse { + /** @format byte */ + acknowledgement?: string; + + /** @format byte */ + proof?: string; + + /** + * Normally the RevisionHeight is incremented at each height while keeping + * RevisionNumber the same. However some consensus algorithms may choose to + * reset the height in certain conditions e.g. hard forks, state-machine + * breaking changes In these cases, the RevisionNumber is incremented so that + * height continues to be monitonically increasing even as the RevisionHeight + * gets reset + */ + proof_height?: V1Height; +} + +export interface V1QueryPacketAcknowledgementsResponse { + acknowledgements?: V1PacketState[]; + + /** + * PageResponse is to be embedded in gRPC response messages where the + * corresponding request message has used PageRequest. + * + * message SomeResponse { + * repeated Bar results = 1; + * PageResponse page = 2; + * } + */ + pagination?: V1Beta1PageResponse; + + /** + * Normally the RevisionHeight is incremented at each height while keeping + * RevisionNumber the same. However some consensus algorithms may choose to + * reset the height in certain conditions e.g. hard forks, state-machine + * breaking changes In these cases, the RevisionNumber is incremented so that + * height continues to be monitonically increasing even as the RevisionHeight + * gets reset + */ + height?: V1Height; +} + +export interface V1QueryPacketCommitmentResponse { + /** @format byte */ + commitment?: string; + + /** @format byte */ + proof?: string; + + /** + * Normally the RevisionHeight is incremented at each height while keeping + * RevisionNumber the same. However some consensus algorithms may choose to + * reset the height in certain conditions e.g. hard forks, state-machine + * breaking changes In these cases, the RevisionNumber is incremented so that + * height continues to be monitonically increasing even as the RevisionHeight + * gets reset + */ + proof_height?: V1Height; +} + +export interface V1QueryPacketCommitmentsResponse { + commitments?: V1PacketState[]; + + /** + * PageResponse is to be embedded in gRPC response messages where the + * corresponding request message has used PageRequest. + * + * message SomeResponse { + * repeated Bar results = 1; + * PageResponse page = 2; + * } + */ + pagination?: V1Beta1PageResponse; + + /** + * Normally the RevisionHeight is incremented at each height while keeping + * RevisionNumber the same. However some consensus algorithms may choose to + * reset the height in certain conditions e.g. hard forks, state-machine + * breaking changes In these cases, the RevisionNumber is incremented so that + * height continues to be monitonically increasing even as the RevisionHeight + * gets reset + */ + height?: V1Height; +} + +export interface V1QueryPacketReceiptResponse { + received?: boolean; + + /** @format byte */ + proof?: string; + + /** + * Normally the RevisionHeight is incremented at each height while keeping + * RevisionNumber the same. However some consensus algorithms may choose to + * reset the height in certain conditions e.g. hard forks, state-machine + * breaking changes In these cases, the RevisionNumber is incremented so that + * height continues to be monitonically increasing even as the RevisionHeight + * gets reset + */ + proof_height?: V1Height; +} + +export interface V1QueryUnreceivedAcksResponse { + sequences?: string[]; + + /** + * Normally the RevisionHeight is incremented at each height while keeping + * RevisionNumber the same. However some consensus algorithms may choose to + * reset the height in certain conditions e.g. hard forks, state-machine + * breaking changes In these cases, the RevisionNumber is incremented so that + * height continues to be monitonically increasing even as the RevisionHeight + * gets reset + */ + height?: V1Height; +} + +export interface V1QueryUnreceivedPacketsResponse { + sequences?: string[]; + + /** + * Normally the RevisionHeight is incremented at each height while keeping + * RevisionNumber the same. However some consensus algorithms may choose to + * reset the height in certain conditions e.g. hard forks, state-machine + * breaking changes In these cases, the RevisionNumber is incremented so that + * height continues to be monitonically increasing even as the RevisionHeight + * gets reset + */ + height?: V1Height; +} + +/** +* - RESPONSE_RESULT_TYPE_UNSPECIFIED: Default zero value enumeration + - RESPONSE_RESULT_TYPE_NOOP: The message did not call the IBC application callbacks (because, for example, the packet had already been relayed) + - RESPONSE_RESULT_TYPE_SUCCESS: The message was executed successfully +*/ +export enum V1ResponseResultType { + RESPONSE_RESULT_TYPE_UNSPECIFIED = "RESPONSE_RESULT_TYPE_UNSPECIFIED", + RESPONSE_RESULT_TYPE_NOOP = "RESPONSE_RESULT_TYPE_NOOP", + RESPONSE_RESULT_TYPE_SUCCESS = "RESPONSE_RESULT_TYPE_SUCCESS", +} + +/** +* State defines if a channel is in one of the following states: +CLOSED, INIT, TRYOPEN, OPEN or UNINITIALIZED. + + - STATE_UNINITIALIZED_UNSPECIFIED: Default State + - STATE_INIT: A channel has just started the opening handshake. + - STATE_TRYOPEN: A channel has acknowledged the handshake step on the counterparty chain. + - STATE_OPEN: A channel has completed the handshake. Open channels are +ready to send and receive packets. + - STATE_CLOSED: A channel has been closed and can no longer be used to send or receive +packets. +*/ +export enum V1State { + STATE_UNINITIALIZED_UNSPECIFIED = "STATE_UNINITIALIZED_UNSPECIFIED", + STATE_INIT = "STATE_INIT", + STATE_TRYOPEN = "STATE_TRYOPEN", + STATE_OPEN = "STATE_OPEN", + STATE_CLOSED = "STATE_CLOSED", +} + +/** +* message SomeRequest { + Foo some_parameter = 1; + PageRequest pagination = 2; + } +*/ +export interface V1Beta1PageRequest { + /** + * key is a value returned in PageResponse.next_key to begin + * querying the next page most efficiently. Only one of offset or key + * should be set. + * @format byte + */ + key?: string; + + /** + * offset is a numeric offset that can be used when key is unavailable. + * It is less efficient than using key. Only one of offset or key should + * be set. + * @format uint64 + */ + offset?: string; + + /** + * limit is the total number of results to be returned in the result page. + * If left empty it will default to a value to be set by each app. + * @format uint64 + */ + limit?: string; + + /** + * count_total is set to true to indicate that the result set should include + * a count of the total number of items available for pagination in UIs. + * count_total is only respected when offset is used. It is ignored when key + * is set. + */ + count_total?: boolean; + + /** + * reverse is set to true if results are to be returned in the descending order. + * + * Since: cosmos-sdk 0.43 + */ + reverse?: boolean; +} + +/** +* PageResponse is to be embedded in gRPC response messages where the +corresponding request message has used PageRequest. + + message SomeResponse { + repeated Bar results = 1; + PageResponse page = 2; + } +*/ +export interface V1Beta1PageResponse { + /** @format byte */ + next_key?: string; + + /** @format uint64 */ + total?: string; +} + +export type QueryParamsType = Record; +export type ResponseFormat = keyof Omit; + +export interface FullRequestParams extends Omit { + /** set parameter to `true` for call `securityWorker` for this request */ + secure?: boolean; + /** request path */ + path: string; + /** content type of request body */ + type?: ContentType; + /** query params */ + query?: QueryParamsType; + /** format of response (i.e. response.json() -> format: "json") */ + format?: keyof Omit; + /** request body */ + body?: unknown; + /** base url */ + baseUrl?: string; + /** request cancellation token */ + cancelToken?: CancelToken; +} + +export type RequestParams = Omit; + +export interface ApiConfig { + baseUrl?: string; + baseApiParams?: Omit; + securityWorker?: (securityData: SecurityDataType) => RequestParams | void; +} + +export interface HttpResponse extends Response { + data: D; + error: E; +} + +type CancelToken = Symbol | string | number; + +export enum ContentType { + Json = "application/json", + FormData = "multipart/form-data", + UrlEncoded = "application/x-www-form-urlencoded", +} + +export class HttpClient { + public baseUrl: string = ""; + private securityData: SecurityDataType = null as any; + private securityWorker: null | ApiConfig["securityWorker"] = null; + private abortControllers = new Map(); + + private baseApiParams: RequestParams = { + credentials: "same-origin", + headers: {}, + redirect: "follow", + referrerPolicy: "no-referrer", + }; + + constructor(apiConfig: ApiConfig = {}) { + Object.assign(this, apiConfig); + } + + public setSecurityData = (data: SecurityDataType) => { + this.securityData = data; + }; + + private addQueryParam(query: QueryParamsType, key: string) { + const value = query[key]; + + return ( + encodeURIComponent(key) + + "=" + + encodeURIComponent(Array.isArray(value) ? value.join(",") : typeof value === "number" ? value : `${value}`) + ); + } + + protected toQueryString(rawQuery?: QueryParamsType): string { + const query = rawQuery || {}; + const keys = Object.keys(query).filter((key) => "undefined" !== typeof query[key]); + return keys + .map((key) => + typeof query[key] === "object" && !Array.isArray(query[key]) + ? this.toQueryString(query[key] as QueryParamsType) + : this.addQueryParam(query, key), + ) + .join("&"); + } + + protected addQueryParams(rawQuery?: QueryParamsType): string { + const queryString = this.toQueryString(rawQuery); + return queryString ? `?${queryString}` : ""; + } + + private contentFormatters: Record any> = { + [ContentType.Json]: (input: any) => + input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input, + [ContentType.FormData]: (input: any) => + Object.keys(input || {}).reduce((data, key) => { + data.append(key, input[key]); + return data; + }, new FormData()), + [ContentType.UrlEncoded]: (input: any) => this.toQueryString(input), + }; + + private mergeRequestParams(params1: RequestParams, params2?: RequestParams): RequestParams { + return { + ...this.baseApiParams, + ...params1, + ...(params2 || {}), + headers: { + ...(this.baseApiParams.headers || {}), + ...(params1.headers || {}), + ...((params2 && params2.headers) || {}), + }, + }; + } + + private createAbortSignal = (cancelToken: CancelToken): AbortSignal | undefined => { + if (this.abortControllers.has(cancelToken)) { + const abortController = this.abortControllers.get(cancelToken); + if (abortController) { + return abortController.signal; + } + return void 0; + } + + const abortController = new AbortController(); + this.abortControllers.set(cancelToken, abortController); + return abortController.signal; + }; + + public abortRequest = (cancelToken: CancelToken) => { + const abortController = this.abortControllers.get(cancelToken); + + if (abortController) { + abortController.abort(); + this.abortControllers.delete(cancelToken); + } + }; + + public request = ({ + body, + secure, + path, + type, + query, + format = "json", + baseUrl, + cancelToken, + ...params + }: FullRequestParams): Promise> => { + const secureParams = (secure && this.securityWorker && this.securityWorker(this.securityData)) || {}; + const requestParams = this.mergeRequestParams(params, secureParams); + const queryString = query && this.toQueryString(query); + const payloadFormatter = this.contentFormatters[type || ContentType.Json]; + + return fetch(`${baseUrl || this.baseUrl || ""}${path}${queryString ? `?${queryString}` : ""}`, { + ...requestParams, + headers: { + ...(type && type !== ContentType.FormData ? { "Content-Type": type } : {}), + ...(requestParams.headers || {}), + }, + signal: cancelToken ? this.createAbortSignal(cancelToken) : void 0, + body: typeof body === "undefined" || body === null ? null : payloadFormatter(body), + }).then(async (response) => { + const r = response as HttpResponse; + r.data = (null as unknown) as T; + r.error = (null as unknown) as E; + + const data = await response[format]() + .then((data) => { + if (r.ok) { + r.data = data; + } else { + r.error = data; + } + return r; + }) + .catch((e) => { + r.error = e; + return r; + }); + + if (cancelToken) { + this.abortControllers.delete(cancelToken); + } + + if (!response.ok) throw data; + return data; + }); + }; +} + +/** + * @title ibc/core/channel/v1/channel.proto + * @version version not set + */ +export class Api extends HttpClient { + /** + * No description + * + * @tags Query + * @name QueryChannels + * @summary Channels queries all the IBC channels of a chain. + * @request GET:/ibc/core/channel/v1/channels + */ + queryChannels = ( + query?: { + "pagination.key"?: string; + "pagination.offset"?: string; + "pagination.limit"?: string; + "pagination.count_total"?: boolean; + "pagination.reverse"?: boolean; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/ibc/core/channel/v1/channels`, + method: "GET", + query: query, + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Query + * @name QueryChannel + * @summary Channel queries an IBC Channel. + * @request GET:/ibc/core/channel/v1/channels/{channel_id}/ports/{port_id} + */ + queryChannel = (channel_id: string, port_id: string, params: RequestParams = {}) => + this.request({ + path: `/ibc/core/channel/v1/channels/${channel_id}/ports/${port_id}`, + method: "GET", + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Query + * @name QueryChannelClientState + * @summary ChannelClientState queries for the client state for the channel associated +with the provided channel identifiers. + * @request GET:/ibc/core/channel/v1/channels/{channel_id}/ports/{port_id}/client_state + */ + queryChannelClientState = (channel_id: string, port_id: string, params: RequestParams = {}) => + this.request({ + path: `/ibc/core/channel/v1/channels/${channel_id}/ports/${port_id}/client_state`, + method: "GET", + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Query + * @name QueryChannelConsensusState + * @summary ChannelConsensusState queries for the consensus state for the channel +associated with the provided channel identifiers. + * @request GET:/ibc/core/channel/v1/channels/{channel_id}/ports/{port_id}/consensus_state/revision/{revision_number}/height/{revision_height} + */ + queryChannelConsensusState = ( + channel_id: string, + port_id: string, + revision_number: string, + revision_height: string, + params: RequestParams = {}, + ) => + this.request({ + path: `/ibc/core/channel/v1/channels/${channel_id}/ports/${port_id}/consensus_state/revision/${revision_number}/height/${revision_height}`, + method: "GET", + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Query + * @name QueryNextSequenceReceive + * @summary NextSequenceReceive returns the next receive sequence for a given channel. + * @request GET:/ibc/core/channel/v1/channels/{channel_id}/ports/{port_id}/next_sequence + */ + queryNextSequenceReceive = (channel_id: string, port_id: string, params: RequestParams = {}) => + this.request({ + path: `/ibc/core/channel/v1/channels/${channel_id}/ports/${port_id}/next_sequence`, + method: "GET", + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Query + * @name QueryPacketAcknowledgements + * @summary PacketAcknowledgements returns all the packet acknowledgements associated +with a channel. + * @request GET:/ibc/core/channel/v1/channels/{channel_id}/ports/{port_id}/packet_acknowledgements + */ + queryPacketAcknowledgements = ( + channel_id: string, + port_id: string, + query?: { + "pagination.key"?: string; + "pagination.offset"?: string; + "pagination.limit"?: string; + "pagination.count_total"?: boolean; + "pagination.reverse"?: boolean; + packet_commitment_sequences?: string[]; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/ibc/core/channel/v1/channels/${channel_id}/ports/${port_id}/packet_acknowledgements`, + method: "GET", + query: query, + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Query + * @name QueryPacketAcknowledgement + * @summary PacketAcknowledgement queries a stored packet acknowledgement hash. + * @request GET:/ibc/core/channel/v1/channels/{channel_id}/ports/{port_id}/packet_acks/{sequence} + */ + queryPacketAcknowledgement = (channel_id: string, port_id: string, sequence: string, params: RequestParams = {}) => + this.request({ + path: `/ibc/core/channel/v1/channels/${channel_id}/ports/${port_id}/packet_acks/${sequence}`, + method: "GET", + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Query + * @name QueryPacketCommitments + * @summary PacketCommitments returns all the packet commitments hashes associated +with a channel. + * @request GET:/ibc/core/channel/v1/channels/{channel_id}/ports/{port_id}/packet_commitments + */ + queryPacketCommitments = ( + channel_id: string, + port_id: string, + query?: { + "pagination.key"?: string; + "pagination.offset"?: string; + "pagination.limit"?: string; + "pagination.count_total"?: boolean; + "pagination.reverse"?: boolean; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/ibc/core/channel/v1/channels/${channel_id}/ports/${port_id}/packet_commitments`, + method: "GET", + query: query, + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Query + * @name QueryUnreceivedAcks + * @summary UnreceivedAcks returns all the unreceived IBC acknowledgements associated +with a channel and sequences. + * @request GET:/ibc/core/channel/v1/channels/{channel_id}/ports/{port_id}/packet_commitments/{packet_ack_sequences}/unreceived_acks + */ + queryUnreceivedAcks = ( + channel_id: string, + port_id: string, + packet_ack_sequences: string[], + params: RequestParams = {}, + ) => + this.request({ + path: `/ibc/core/channel/v1/channels/${channel_id}/ports/${port_id}/packet_commitments/${packet_ack_sequences}/unreceived_acks`, + method: "GET", + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Query + * @name QueryUnreceivedPackets + * @summary UnreceivedPackets returns all the unreceived IBC packets associated with a +channel and sequences. + * @request GET:/ibc/core/channel/v1/channels/{channel_id}/ports/{port_id}/packet_commitments/{packet_commitment_sequences}/unreceived_packets + */ + queryUnreceivedPackets = ( + channel_id: string, + port_id: string, + packet_commitment_sequences: string[], + params: RequestParams = {}, + ) => + this.request({ + path: `/ibc/core/channel/v1/channels/${channel_id}/ports/${port_id}/packet_commitments/${packet_commitment_sequences}/unreceived_packets`, + method: "GET", + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Query + * @name QueryPacketCommitment + * @summary PacketCommitment queries a stored packet commitment hash. + * @request GET:/ibc/core/channel/v1/channels/{channel_id}/ports/{port_id}/packet_commitments/{sequence} + */ + queryPacketCommitment = (channel_id: string, port_id: string, sequence: string, params: RequestParams = {}) => + this.request({ + path: `/ibc/core/channel/v1/channels/${channel_id}/ports/${port_id}/packet_commitments/${sequence}`, + method: "GET", + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Query + * @name QueryPacketReceipt + * @summary PacketReceipt queries if a given packet sequence has been received on the +queried chain + * @request GET:/ibc/core/channel/v1/channels/{channel_id}/ports/{port_id}/packet_receipts/{sequence} + */ + queryPacketReceipt = (channel_id: string, port_id: string, sequence: string, params: RequestParams = {}) => + this.request({ + path: `/ibc/core/channel/v1/channels/${channel_id}/ports/${port_id}/packet_receipts/${sequence}`, + method: "GET", + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Query + * @name QueryConnectionChannels + * @summary ConnectionChannels queries all the channels associated with a connection +end. + * @request GET:/ibc/core/channel/v1/connections/{connection}/channels + */ + queryConnectionChannels = ( + connection: string, + query?: { + "pagination.key"?: string; + "pagination.offset"?: string; + "pagination.limit"?: string; + "pagination.count_total"?: boolean; + "pagination.reverse"?: boolean; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/ibc/core/channel/v1/connections/${connection}/channels`, + method: "GET", + query: query, + format: "json", + ...params, + }); +} diff --git a/ts-client/ibc.core.channel.v1/types.ts b/ts-client/ibc.core.channel.v1/types.ts new file mode 100755 index 00000000..4c8223c6 --- /dev/null +++ b/ts-client/ibc.core.channel.v1/types.ts @@ -0,0 +1,21 @@ +import { Channel } from "./types/ibc/core/channel/v1/channel" +import { IdentifiedChannel } from "./types/ibc/core/channel/v1/channel" +import { Counterparty } from "./types/ibc/core/channel/v1/channel" +import { Packet } from "./types/ibc/core/channel/v1/channel" +import { PacketState } from "./types/ibc/core/channel/v1/channel" +import { PacketId } from "./types/ibc/core/channel/v1/channel" +import { Acknowledgement } from "./types/ibc/core/channel/v1/channel" +import { PacketSequence } from "./types/ibc/core/channel/v1/genesis" + + +export { + Channel, + IdentifiedChannel, + Counterparty, + Packet, + PacketState, + PacketId, + Acknowledgement, + PacketSequence, + + } \ No newline at end of file diff --git a/ts-client/ibc.core.channel.v1/types/cosmos/base/query/v1beta1/pagination.ts b/ts-client/ibc.core.channel.v1/types/cosmos/base/query/v1beta1/pagination.ts new file mode 100644 index 00000000..cd4b2d78 --- /dev/null +++ b/ts-client/ibc.core.channel.v1/types/cosmos/base/query/v1beta1/pagination.ts @@ -0,0 +1,327 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "cosmos.base.query.v1beta1"; + +/** + * PageRequest is to be embedded in gRPC request messages for efficient + * pagination. Ex: + * + * message SomeRequest { + * Foo some_parameter = 1; + * PageRequest pagination = 2; + * } + */ +export interface PageRequest { + /** + * key is a value returned in PageResponse.next_key to begin + * querying the next page most efficiently. Only one of offset or key + * should be set. + */ + key: Uint8Array; + /** + * offset is a numeric offset that can be used when key is unavailable. + * It is less efficient than using key. Only one of offset or key should + * be set. + */ + offset: number; + /** + * limit is the total number of results to be returned in the result page. + * If left empty it will default to a value to be set by each app. + */ + limit: number; + /** + * count_total is set to true to indicate that the result set should include + * a count of the total number of items available for pagination in UIs. + * count_total is only respected when offset is used. It is ignored when key + * is set. + */ + countTotal: boolean; + /** + * reverse is set to true if results are to be returned in the descending order. + * + * Since: cosmos-sdk 0.43 + */ + reverse: boolean; +} + +/** + * PageResponse is to be embedded in gRPC response messages where the + * corresponding request message has used PageRequest. + * + * message SomeResponse { + * repeated Bar results = 1; + * PageResponse page = 2; + * } + */ +export interface PageResponse { + /** + * next_key is the key to be passed to PageRequest.key to + * query the next page most efficiently + */ + nextKey: Uint8Array; + /** + * total is total number of results available if PageRequest.count_total + * was set, its value is undefined otherwise + */ + total: number; +} + +const basePageRequest: object = { + offset: 0, + limit: 0, + countTotal: false, + reverse: false, +}; + +export const PageRequest = { + encode(message: PageRequest, writer: Writer = Writer.create()): Writer { + if (message.key.length !== 0) { + writer.uint32(10).bytes(message.key); + } + if (message.offset !== 0) { + writer.uint32(16).uint64(message.offset); + } + if (message.limit !== 0) { + writer.uint32(24).uint64(message.limit); + } + if (message.countTotal === true) { + writer.uint32(32).bool(message.countTotal); + } + if (message.reverse === true) { + writer.uint32(40).bool(message.reverse); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): PageRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...basePageRequest } as PageRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.key = reader.bytes(); + break; + case 2: + message.offset = longToNumber(reader.uint64() as Long); + break; + case 3: + message.limit = longToNumber(reader.uint64() as Long); + break; + case 4: + message.countTotal = reader.bool(); + break; + case 5: + message.reverse = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): PageRequest { + const message = { ...basePageRequest } as PageRequest; + if (object.key !== undefined && object.key !== null) { + message.key = bytesFromBase64(object.key); + } + if (object.offset !== undefined && object.offset !== null) { + message.offset = Number(object.offset); + } else { + message.offset = 0; + } + if (object.limit !== undefined && object.limit !== null) { + message.limit = Number(object.limit); + } else { + message.limit = 0; + } + if (object.countTotal !== undefined && object.countTotal !== null) { + message.countTotal = Boolean(object.countTotal); + } else { + message.countTotal = false; + } + if (object.reverse !== undefined && object.reverse !== null) { + message.reverse = Boolean(object.reverse); + } else { + message.reverse = false; + } + return message; + }, + + toJSON(message: PageRequest): unknown { + const obj: any = {}; + message.key !== undefined && + (obj.key = base64FromBytes( + message.key !== undefined ? message.key : new Uint8Array() + )); + message.offset !== undefined && (obj.offset = message.offset); + message.limit !== undefined && (obj.limit = message.limit); + message.countTotal !== undefined && (obj.countTotal = message.countTotal); + message.reverse !== undefined && (obj.reverse = message.reverse); + return obj; + }, + + fromPartial(object: DeepPartial): PageRequest { + const message = { ...basePageRequest } as PageRequest; + if (object.key !== undefined && object.key !== null) { + message.key = object.key; + } else { + message.key = new Uint8Array(); + } + if (object.offset !== undefined && object.offset !== null) { + message.offset = object.offset; + } else { + message.offset = 0; + } + if (object.limit !== undefined && object.limit !== null) { + message.limit = object.limit; + } else { + message.limit = 0; + } + if (object.countTotal !== undefined && object.countTotal !== null) { + message.countTotal = object.countTotal; + } else { + message.countTotal = false; + } + if (object.reverse !== undefined && object.reverse !== null) { + message.reverse = object.reverse; + } else { + message.reverse = false; + } + return message; + }, +}; + +const basePageResponse: object = { total: 0 }; + +export const PageResponse = { + encode(message: PageResponse, writer: Writer = Writer.create()): Writer { + if (message.nextKey.length !== 0) { + writer.uint32(10).bytes(message.nextKey); + } + if (message.total !== 0) { + writer.uint32(16).uint64(message.total); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): PageResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...basePageResponse } as PageResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.nextKey = reader.bytes(); + break; + case 2: + message.total = longToNumber(reader.uint64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): PageResponse { + const message = { ...basePageResponse } as PageResponse; + if (object.nextKey !== undefined && object.nextKey !== null) { + message.nextKey = bytesFromBase64(object.nextKey); + } + if (object.total !== undefined && object.total !== null) { + message.total = Number(object.total); + } else { + message.total = 0; + } + return message; + }, + + toJSON(message: PageResponse): unknown { + const obj: any = {}; + message.nextKey !== undefined && + (obj.nextKey = base64FromBytes( + message.nextKey !== undefined ? message.nextKey : new Uint8Array() + )); + message.total !== undefined && (obj.total = message.total); + return obj; + }, + + fromPartial(object: DeepPartial): PageResponse { + const message = { ...basePageResponse } as PageResponse; + if (object.nextKey !== undefined && object.nextKey !== null) { + message.nextKey = object.nextKey; + } else { + message.nextKey = new Uint8Array(); + } + if (object.total !== undefined && object.total !== null) { + message.total = object.total; + } else { + message.total = 0; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/ibc.core.channel.v1/types/cosmos/upgrade/v1beta1/upgrade.ts b/ts-client/ibc.core.channel.v1/types/cosmos/upgrade/v1beta1/upgrade.ts new file mode 100644 index 00000000..ec9520b0 --- /dev/null +++ b/ts-client/ibc.core.channel.v1/types/cosmos/upgrade/v1beta1/upgrade.ts @@ -0,0 +1,539 @@ +/* eslint-disable */ +import { Timestamp } from "../../../google/protobuf/timestamp"; +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; +import { Any } from "../../../google/protobuf/any"; + +export const protobufPackage = "cosmos.upgrade.v1beta1"; + +/** Plan specifies information about a planned upgrade and when it should occur. */ +export interface Plan { + /** + * Sets the name for the upgrade. This name will be used by the upgraded + * version of the software to apply any special "on-upgrade" commands during + * the first BeginBlock method after the upgrade is applied. It is also used + * to detect whether a software version can handle a given upgrade. If no + * upgrade handler with this name has been set in the software, it will be + * assumed that the software is out-of-date when the upgrade Time or Height is + * reached and the software will exit. + */ + name: string; + /** + * Deprecated: Time based upgrades have been deprecated. Time based upgrade logic + * has been removed from the SDK. + * If this field is not empty, an error will be thrown. + * + * @deprecated + */ + time: Date | undefined; + /** + * The height at which the upgrade must be performed. + * Only used if Time is not set. + */ + height: number; + /** + * Any application specific upgrade info to be included on-chain + * such as a git commit that validators could automatically upgrade to + */ + info: string; + /** + * Deprecated: UpgradedClientState field has been deprecated. IBC upgrade logic has been + * moved to the IBC module in the sub module 02-client. + * If this field is not empty, an error will be thrown. + * + * @deprecated + */ + upgradedClientState: Any | undefined; +} + +/** + * SoftwareUpgradeProposal is a gov Content type for initiating a software + * upgrade. + */ +export interface SoftwareUpgradeProposal { + title: string; + description: string; + plan: Plan | undefined; +} + +/** + * CancelSoftwareUpgradeProposal is a gov Content type for cancelling a software + * upgrade. + */ +export interface CancelSoftwareUpgradeProposal { + title: string; + description: string; +} + +/** + * ModuleVersion specifies a module and its consensus version. + * + * Since: cosmos-sdk 0.43 + */ +export interface ModuleVersion { + /** name of the app module */ + name: string; + /** consensus version of the app module */ + version: number; +} + +const basePlan: object = { name: "", height: 0, info: "" }; + +export const Plan = { + encode(message: Plan, writer: Writer = Writer.create()): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.time !== undefined) { + Timestamp.encode( + toTimestamp(message.time), + writer.uint32(18).fork() + ).ldelim(); + } + if (message.height !== 0) { + writer.uint32(24).int64(message.height); + } + if (message.info !== "") { + writer.uint32(34).string(message.info); + } + if (message.upgradedClientState !== undefined) { + Any.encode( + message.upgradedClientState, + writer.uint32(42).fork() + ).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Plan { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...basePlan } as Plan; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.time = fromTimestamp( + Timestamp.decode(reader, reader.uint32()) + ); + break; + case 3: + message.height = longToNumber(reader.int64() as Long); + break; + case 4: + message.info = reader.string(); + break; + case 5: + message.upgradedClientState = Any.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Plan { + const message = { ...basePlan } as Plan; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.time !== undefined && object.time !== null) { + message.time = fromJsonTimestamp(object.time); + } else { + message.time = undefined; + } + if (object.height !== undefined && object.height !== null) { + message.height = Number(object.height); + } else { + message.height = 0; + } + if (object.info !== undefined && object.info !== null) { + message.info = String(object.info); + } else { + message.info = ""; + } + if ( + object.upgradedClientState !== undefined && + object.upgradedClientState !== null + ) { + message.upgradedClientState = Any.fromJSON(object.upgradedClientState); + } else { + message.upgradedClientState = undefined; + } + return message; + }, + + toJSON(message: Plan): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.time !== undefined && + (obj.time = + message.time !== undefined ? message.time.toISOString() : null); + message.height !== undefined && (obj.height = message.height); + message.info !== undefined && (obj.info = message.info); + message.upgradedClientState !== undefined && + (obj.upgradedClientState = message.upgradedClientState + ? Any.toJSON(message.upgradedClientState) + : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): Plan { + const message = { ...basePlan } as Plan; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.time !== undefined && object.time !== null) { + message.time = object.time; + } else { + message.time = undefined; + } + if (object.height !== undefined && object.height !== null) { + message.height = object.height; + } else { + message.height = 0; + } + if (object.info !== undefined && object.info !== null) { + message.info = object.info; + } else { + message.info = ""; + } + if ( + object.upgradedClientState !== undefined && + object.upgradedClientState !== null + ) { + message.upgradedClientState = Any.fromPartial(object.upgradedClientState); + } else { + message.upgradedClientState = undefined; + } + return message; + }, +}; + +const baseSoftwareUpgradeProposal: object = { title: "", description: "" }; + +export const SoftwareUpgradeProposal = { + encode( + message: SoftwareUpgradeProposal, + writer: Writer = Writer.create() + ): Writer { + if (message.title !== "") { + writer.uint32(10).string(message.title); + } + if (message.description !== "") { + writer.uint32(18).string(message.description); + } + if (message.plan !== undefined) { + Plan.encode(message.plan, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): SoftwareUpgradeProposal { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseSoftwareUpgradeProposal, + } as SoftwareUpgradeProposal; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.title = reader.string(); + break; + case 2: + message.description = reader.string(); + break; + case 3: + message.plan = Plan.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): SoftwareUpgradeProposal { + const message = { + ...baseSoftwareUpgradeProposal, + } as SoftwareUpgradeProposal; + if (object.title !== undefined && object.title !== null) { + message.title = String(object.title); + } else { + message.title = ""; + } + if (object.description !== undefined && object.description !== null) { + message.description = String(object.description); + } else { + message.description = ""; + } + if (object.plan !== undefined && object.plan !== null) { + message.plan = Plan.fromJSON(object.plan); + } else { + message.plan = undefined; + } + return message; + }, + + toJSON(message: SoftwareUpgradeProposal): unknown { + const obj: any = {}; + message.title !== undefined && (obj.title = message.title); + message.description !== undefined && + (obj.description = message.description); + message.plan !== undefined && + (obj.plan = message.plan ? Plan.toJSON(message.plan) : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): SoftwareUpgradeProposal { + const message = { + ...baseSoftwareUpgradeProposal, + } as SoftwareUpgradeProposal; + if (object.title !== undefined && object.title !== null) { + message.title = object.title; + } else { + message.title = ""; + } + if (object.description !== undefined && object.description !== null) { + message.description = object.description; + } else { + message.description = ""; + } + if (object.plan !== undefined && object.plan !== null) { + message.plan = Plan.fromPartial(object.plan); + } else { + message.plan = undefined; + } + return message; + }, +}; + +const baseCancelSoftwareUpgradeProposal: object = { + title: "", + description: "", +}; + +export const CancelSoftwareUpgradeProposal = { + encode( + message: CancelSoftwareUpgradeProposal, + writer: Writer = Writer.create() + ): Writer { + if (message.title !== "") { + writer.uint32(10).string(message.title); + } + if (message.description !== "") { + writer.uint32(18).string(message.description); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): CancelSoftwareUpgradeProposal { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseCancelSoftwareUpgradeProposal, + } as CancelSoftwareUpgradeProposal; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.title = reader.string(); + break; + case 2: + message.description = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): CancelSoftwareUpgradeProposal { + const message = { + ...baseCancelSoftwareUpgradeProposal, + } as CancelSoftwareUpgradeProposal; + if (object.title !== undefined && object.title !== null) { + message.title = String(object.title); + } else { + message.title = ""; + } + if (object.description !== undefined && object.description !== null) { + message.description = String(object.description); + } else { + message.description = ""; + } + return message; + }, + + toJSON(message: CancelSoftwareUpgradeProposal): unknown { + const obj: any = {}; + message.title !== undefined && (obj.title = message.title); + message.description !== undefined && + (obj.description = message.description); + return obj; + }, + + fromPartial( + object: DeepPartial + ): CancelSoftwareUpgradeProposal { + const message = { + ...baseCancelSoftwareUpgradeProposal, + } as CancelSoftwareUpgradeProposal; + if (object.title !== undefined && object.title !== null) { + message.title = object.title; + } else { + message.title = ""; + } + if (object.description !== undefined && object.description !== null) { + message.description = object.description; + } else { + message.description = ""; + } + return message; + }, +}; + +const baseModuleVersion: object = { name: "", version: 0 }; + +export const ModuleVersion = { + encode(message: ModuleVersion, writer: Writer = Writer.create()): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.version !== 0) { + writer.uint32(16).uint64(message.version); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ModuleVersion { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseModuleVersion } as ModuleVersion; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.version = longToNumber(reader.uint64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ModuleVersion { + const message = { ...baseModuleVersion } as ModuleVersion; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.version !== undefined && object.version !== null) { + message.version = Number(object.version); + } else { + message.version = 0; + } + return message; + }, + + toJSON(message: ModuleVersion): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.version !== undefined && (obj.version = message.version); + return obj; + }, + + fromPartial(object: DeepPartial): ModuleVersion { + const message = { ...baseModuleVersion } as ModuleVersion; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.version !== undefined && object.version !== null) { + message.version = object.version; + } else { + message.version = 0; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function toTimestamp(date: Date): Timestamp { + const seconds = date.getTime() / 1_000; + const nanos = (date.getTime() % 1_000) * 1_000_000; + return { seconds, nanos }; +} + +function fromTimestamp(t: Timestamp): Date { + let millis = t.seconds * 1_000; + millis += t.nanos / 1_000_000; + return new Date(millis); +} + +function fromJsonTimestamp(o: any): Date { + if (o instanceof Date) { + return o; + } else if (typeof o === "string") { + return new Date(o); + } else { + return fromTimestamp(Timestamp.fromJSON(o)); + } +} + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/ibc.core.channel.v1/types/cosmos_proto/cosmos.ts b/ts-client/ibc.core.channel.v1/types/cosmos_proto/cosmos.ts new file mode 100644 index 00000000..9ec67a12 --- /dev/null +++ b/ts-client/ibc.core.channel.v1/types/cosmos_proto/cosmos.ts @@ -0,0 +1,2 @@ +/* eslint-disable */ +export const protobufPackage = "cosmos_proto"; diff --git a/ts-client/ibc.core.channel.v1/types/gogoproto/gogo.ts b/ts-client/ibc.core.channel.v1/types/gogoproto/gogo.ts new file mode 100644 index 00000000..3f41a047 --- /dev/null +++ b/ts-client/ibc.core.channel.v1/types/gogoproto/gogo.ts @@ -0,0 +1,2 @@ +/* eslint-disable */ +export const protobufPackage = "gogoproto"; diff --git a/ts-client/ibc.core.channel.v1/types/google/api/annotations.ts b/ts-client/ibc.core.channel.v1/types/google/api/annotations.ts new file mode 100644 index 00000000..aace4787 --- /dev/null +++ b/ts-client/ibc.core.channel.v1/types/google/api/annotations.ts @@ -0,0 +1,2 @@ +/* eslint-disable */ +export const protobufPackage = "google.api"; diff --git a/ts-client/ibc.core.channel.v1/types/google/api/http.ts b/ts-client/ibc.core.channel.v1/types/google/api/http.ts new file mode 100644 index 00000000..ddc00f8b --- /dev/null +++ b/ts-client/ibc.core.channel.v1/types/google/api/http.ts @@ -0,0 +1,705 @@ +/* eslint-disable */ +import { Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "google.api"; + +/** + * Defines the HTTP configuration for an API service. It contains a list of + * [HttpRule][google.api.HttpRule], each specifying the mapping of an RPC method + * to one or more HTTP REST API methods. + */ +export interface Http { + /** + * A list of HTTP configuration rules that apply to individual API methods. + * + * **NOTE:** All service configuration rules follow "last one wins" order. + */ + rules: HttpRule[]; + /** + * When set to true, URL path parmeters will be fully URI-decoded except in + * cases of single segment matches in reserved expansion, where "%2F" will be + * left encoded. + * + * The default behavior is to not decode RFC 6570 reserved characters in multi + * segment matches. + */ + fullyDecodeReservedExpansion: boolean; +} + +/** + * `HttpRule` defines the mapping of an RPC method to one or more HTTP + * REST API methods. The mapping specifies how different portions of the RPC + * request message are mapped to URL path, URL query parameters, and + * HTTP request body. The mapping is typically specified as an + * `google.api.http` annotation on the RPC method, + * see "google/api/annotations.proto" for details. + * + * The mapping consists of a field specifying the path template and + * method kind. The path template can refer to fields in the request + * message, as in the example below which describes a REST GET + * operation on a resource collection of messages: + * + * + * service Messaging { + * rpc GetMessage(GetMessageRequest) returns (Message) { + * option (google.api.http).get = "/v1/messages/{message_id}/{sub.subfield}"; + * } + * } + * message GetMessageRequest { + * message SubMessage { + * string subfield = 1; + * } + * string message_id = 1; // mapped to the URL + * SubMessage sub = 2; // `sub.subfield` is url-mapped + * } + * message Message { + * string text = 1; // content of the resource + * } + * + * The same http annotation can alternatively be expressed inside the + * `GRPC API Configuration` YAML file. + * + * http: + * rules: + * - selector: .Messaging.GetMessage + * get: /v1/messages/{message_id}/{sub.subfield} + * + * This definition enables an automatic, bidrectional mapping of HTTP + * JSON to RPC. Example: + * + * HTTP | RPC + * -----|----- + * `GET /v1/messages/123456/foo` | `GetMessage(message_id: "123456" sub: SubMessage(subfield: "foo"))` + * + * In general, not only fields but also field paths can be referenced + * from a path pattern. Fields mapped to the path pattern cannot be + * repeated and must have a primitive (non-message) type. + * + * Any fields in the request message which are not bound by the path + * pattern automatically become (optional) HTTP query + * parameters. Assume the following definition of the request message: + * + * + * service Messaging { + * rpc GetMessage(GetMessageRequest) returns (Message) { + * option (google.api.http).get = "/v1/messages/{message_id}"; + * } + * } + * message GetMessageRequest { + * message SubMessage { + * string subfield = 1; + * } + * string message_id = 1; // mapped to the URL + * int64 revision = 2; // becomes a parameter + * SubMessage sub = 3; // `sub.subfield` becomes a parameter + * } + * + * + * This enables a HTTP JSON to RPC mapping as below: + * + * HTTP | RPC + * -----|----- + * `GET /v1/messages/123456?revision=2&sub.subfield=foo` | `GetMessage(message_id: "123456" revision: 2 sub: SubMessage(subfield: "foo"))` + * + * Note that fields which are mapped to HTTP parameters must have a + * primitive type or a repeated primitive type. Message types are not + * allowed. In the case of a repeated type, the parameter can be + * repeated in the URL, as in `...?param=A¶m=B`. + * + * For HTTP method kinds which allow a request body, the `body` field + * specifies the mapping. Consider a REST update method on the + * message resource collection: + * + * + * service Messaging { + * rpc UpdateMessage(UpdateMessageRequest) returns (Message) { + * option (google.api.http) = { + * put: "/v1/messages/{message_id}" + * body: "message" + * }; + * } + * } + * message UpdateMessageRequest { + * string message_id = 1; // mapped to the URL + * Message message = 2; // mapped to the body + * } + * + * + * The following HTTP JSON to RPC mapping is enabled, where the + * representation of the JSON in the request body is determined by + * protos JSON encoding: + * + * HTTP | RPC + * -----|----- + * `PUT /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: "123456" message { text: "Hi!" })` + * + * The special name `*` can be used in the body mapping to define that + * every field not bound by the path template should be mapped to the + * request body. This enables the following alternative definition of + * the update method: + * + * service Messaging { + * rpc UpdateMessage(Message) returns (Message) { + * option (google.api.http) = { + * put: "/v1/messages/{message_id}" + * body: "*" + * }; + * } + * } + * message Message { + * string message_id = 1; + * string text = 2; + * } + * + * + * The following HTTP JSON to RPC mapping is enabled: + * + * HTTP | RPC + * -----|----- + * `PUT /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: "123456" text: "Hi!")` + * + * Note that when using `*` in the body mapping, it is not possible to + * have HTTP parameters, as all fields not bound by the path end in + * the body. This makes this option more rarely used in practice of + * defining REST APIs. The common usage of `*` is in custom methods + * which don't use the URL at all for transferring data. + * + * It is possible to define multiple HTTP methods for one RPC by using + * the `additional_bindings` option. Example: + * + * service Messaging { + * rpc GetMessage(GetMessageRequest) returns (Message) { + * option (google.api.http) = { + * get: "/v1/messages/{message_id}" + * additional_bindings { + * get: "/v1/users/{user_id}/messages/{message_id}" + * } + * }; + * } + * } + * message GetMessageRequest { + * string message_id = 1; + * string user_id = 2; + * } + * + * + * This enables the following two alternative HTTP JSON to RPC + * mappings: + * + * HTTP | RPC + * -----|----- + * `GET /v1/messages/123456` | `GetMessage(message_id: "123456")` + * `GET /v1/users/me/messages/123456` | `GetMessage(user_id: "me" message_id: "123456")` + * + * # Rules for HTTP mapping + * + * The rules for mapping HTTP path, query parameters, and body fields + * to the request message are as follows: + * + * 1. The `body` field specifies either `*` or a field path, or is + * omitted. If omitted, it indicates there is no HTTP request body. + * 2. Leaf fields (recursive expansion of nested messages in the + * request) can be classified into three types: + * (a) Matched in the URL template. + * (b) Covered by body (if body is `*`, everything except (a) fields; + * else everything under the body field) + * (c) All other fields. + * 3. URL query parameters found in the HTTP request are mapped to (c) fields. + * 4. Any body sent with an HTTP request can contain only (b) fields. + * + * The syntax of the path template is as follows: + * + * Template = "/" Segments [ Verb ] ; + * Segments = Segment { "/" Segment } ; + * Segment = "*" | "**" | LITERAL | Variable ; + * Variable = "{" FieldPath [ "=" Segments ] "}" ; + * FieldPath = IDENT { "." IDENT } ; + * Verb = ":" LITERAL ; + * + * The syntax `*` matches a single path segment. The syntax `**` matches zero + * or more path segments, which must be the last part of the path except the + * `Verb`. The syntax `LITERAL` matches literal text in the path. + * + * The syntax `Variable` matches part of the URL path as specified by its + * template. A variable template must not contain other variables. If a variable + * matches a single path segment, its template may be omitted, e.g. `{var}` + * is equivalent to `{var=*}`. + * + * If a variable contains exactly one path segment, such as `"{var}"` or + * `"{var=*}"`, when such a variable is expanded into a URL path, all characters + * except `[-_.~0-9a-zA-Z]` are percent-encoded. Such variables show up in the + * Discovery Document as `{var}`. + * + * If a variable contains one or more path segments, such as `"{var=foo/*}"` + * or `"{var=**}"`, when such a variable is expanded into a URL path, all + * characters except `[-_.~/0-9a-zA-Z]` are percent-encoded. Such variables + * show up in the Discovery Document as `{+var}`. + * + * NOTE: While the single segment variable matches the semantics of + * [RFC 6570](https://tools.ietf.org/html/rfc6570) Section 3.2.2 + * Simple String Expansion, the multi segment variable **does not** match + * RFC 6570 Reserved Expansion. The reason is that the Reserved Expansion + * does not expand special characters like `?` and `#`, which would lead + * to invalid URLs. + * + * NOTE: the field paths in variables and in the `body` must not refer to + * repeated fields or map fields. + */ +export interface HttpRule { + /** + * Selects methods to which this rule applies. + * + * Refer to [selector][google.api.DocumentationRule.selector] for syntax details. + */ + selector: string; + /** Used for listing and getting information about resources. */ + get: string | undefined; + /** Used for updating a resource. */ + put: string | undefined; + /** Used for creating a resource. */ + post: string | undefined; + /** Used for deleting a resource. */ + delete: string | undefined; + /** Used for updating a resource. */ + patch: string | undefined; + /** + * The custom pattern is used for specifying an HTTP method that is not + * included in the `pattern` field, such as HEAD, or "*" to leave the + * HTTP method unspecified for this rule. The wild-card rule is useful + * for services that provide content to Web (HTML) clients. + */ + custom: CustomHttpPattern | undefined; + /** + * The name of the request field whose value is mapped to the HTTP body, or + * `*` for mapping all fields not captured by the path pattern to the HTTP + * body. NOTE: the referred field must not be a repeated field and must be + * present at the top-level of request message type. + */ + body: string; + /** + * Optional. The name of the response field whose value is mapped to the HTTP + * body of response. Other response fields are ignored. When + * not set, the response message will be used as HTTP body of response. + */ + responseBody: string; + /** + * Additional HTTP bindings for the selector. Nested bindings must + * not contain an `additional_bindings` field themselves (that is, + * the nesting may only be one level deep). + */ + additionalBindings: HttpRule[]; +} + +/** A custom pattern is used for defining custom HTTP verb. */ +export interface CustomHttpPattern { + /** The name of this custom HTTP verb. */ + kind: string; + /** The path matched by this custom verb. */ + path: string; +} + +const baseHttp: object = { fullyDecodeReservedExpansion: false }; + +export const Http = { + encode(message: Http, writer: Writer = Writer.create()): Writer { + for (const v of message.rules) { + HttpRule.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.fullyDecodeReservedExpansion === true) { + writer.uint32(16).bool(message.fullyDecodeReservedExpansion); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Http { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseHttp } as Http; + message.rules = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.rules.push(HttpRule.decode(reader, reader.uint32())); + break; + case 2: + message.fullyDecodeReservedExpansion = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Http { + const message = { ...baseHttp } as Http; + message.rules = []; + if (object.rules !== undefined && object.rules !== null) { + for (const e of object.rules) { + message.rules.push(HttpRule.fromJSON(e)); + } + } + if ( + object.fullyDecodeReservedExpansion !== undefined && + object.fullyDecodeReservedExpansion !== null + ) { + message.fullyDecodeReservedExpansion = Boolean( + object.fullyDecodeReservedExpansion + ); + } else { + message.fullyDecodeReservedExpansion = false; + } + return message; + }, + + toJSON(message: Http): unknown { + const obj: any = {}; + if (message.rules) { + obj.rules = message.rules.map((e) => + e ? HttpRule.toJSON(e) : undefined + ); + } else { + obj.rules = []; + } + message.fullyDecodeReservedExpansion !== undefined && + (obj.fullyDecodeReservedExpansion = message.fullyDecodeReservedExpansion); + return obj; + }, + + fromPartial(object: DeepPartial): Http { + const message = { ...baseHttp } as Http; + message.rules = []; + if (object.rules !== undefined && object.rules !== null) { + for (const e of object.rules) { + message.rules.push(HttpRule.fromPartial(e)); + } + } + if ( + object.fullyDecodeReservedExpansion !== undefined && + object.fullyDecodeReservedExpansion !== null + ) { + message.fullyDecodeReservedExpansion = + object.fullyDecodeReservedExpansion; + } else { + message.fullyDecodeReservedExpansion = false; + } + return message; + }, +}; + +const baseHttpRule: object = { selector: "", body: "", responseBody: "" }; + +export const HttpRule = { + encode(message: HttpRule, writer: Writer = Writer.create()): Writer { + if (message.selector !== "") { + writer.uint32(10).string(message.selector); + } + if (message.get !== undefined) { + writer.uint32(18).string(message.get); + } + if (message.put !== undefined) { + writer.uint32(26).string(message.put); + } + if (message.post !== undefined) { + writer.uint32(34).string(message.post); + } + if (message.delete !== undefined) { + writer.uint32(42).string(message.delete); + } + if (message.patch !== undefined) { + writer.uint32(50).string(message.patch); + } + if (message.custom !== undefined) { + CustomHttpPattern.encode( + message.custom, + writer.uint32(66).fork() + ).ldelim(); + } + if (message.body !== "") { + writer.uint32(58).string(message.body); + } + if (message.responseBody !== "") { + writer.uint32(98).string(message.responseBody); + } + for (const v of message.additionalBindings) { + HttpRule.encode(v!, writer.uint32(90).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): HttpRule { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseHttpRule } as HttpRule; + message.additionalBindings = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.selector = reader.string(); + break; + case 2: + message.get = reader.string(); + break; + case 3: + message.put = reader.string(); + break; + case 4: + message.post = reader.string(); + break; + case 5: + message.delete = reader.string(); + break; + case 6: + message.patch = reader.string(); + break; + case 8: + message.custom = CustomHttpPattern.decode(reader, reader.uint32()); + break; + case 7: + message.body = reader.string(); + break; + case 12: + message.responseBody = reader.string(); + break; + case 11: + message.additionalBindings.push( + HttpRule.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): HttpRule { + const message = { ...baseHttpRule } as HttpRule; + message.additionalBindings = []; + if (object.selector !== undefined && object.selector !== null) { + message.selector = String(object.selector); + } else { + message.selector = ""; + } + if (object.get !== undefined && object.get !== null) { + message.get = String(object.get); + } else { + message.get = undefined; + } + if (object.put !== undefined && object.put !== null) { + message.put = String(object.put); + } else { + message.put = undefined; + } + if (object.post !== undefined && object.post !== null) { + message.post = String(object.post); + } else { + message.post = undefined; + } + if (object.delete !== undefined && object.delete !== null) { + message.delete = String(object.delete); + } else { + message.delete = undefined; + } + if (object.patch !== undefined && object.patch !== null) { + message.patch = String(object.patch); + } else { + message.patch = undefined; + } + if (object.custom !== undefined && object.custom !== null) { + message.custom = CustomHttpPattern.fromJSON(object.custom); + } else { + message.custom = undefined; + } + if (object.body !== undefined && object.body !== null) { + message.body = String(object.body); + } else { + message.body = ""; + } + if (object.responseBody !== undefined && object.responseBody !== null) { + message.responseBody = String(object.responseBody); + } else { + message.responseBody = ""; + } + if ( + object.additionalBindings !== undefined && + object.additionalBindings !== null + ) { + for (const e of object.additionalBindings) { + message.additionalBindings.push(HttpRule.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: HttpRule): unknown { + const obj: any = {}; + message.selector !== undefined && (obj.selector = message.selector); + message.get !== undefined && (obj.get = message.get); + message.put !== undefined && (obj.put = message.put); + message.post !== undefined && (obj.post = message.post); + message.delete !== undefined && (obj.delete = message.delete); + message.patch !== undefined && (obj.patch = message.patch); + message.custom !== undefined && + (obj.custom = message.custom + ? CustomHttpPattern.toJSON(message.custom) + : undefined); + message.body !== undefined && (obj.body = message.body); + message.responseBody !== undefined && + (obj.responseBody = message.responseBody); + if (message.additionalBindings) { + obj.additionalBindings = message.additionalBindings.map((e) => + e ? HttpRule.toJSON(e) : undefined + ); + } else { + obj.additionalBindings = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): HttpRule { + const message = { ...baseHttpRule } as HttpRule; + message.additionalBindings = []; + if (object.selector !== undefined && object.selector !== null) { + message.selector = object.selector; + } else { + message.selector = ""; + } + if (object.get !== undefined && object.get !== null) { + message.get = object.get; + } else { + message.get = undefined; + } + if (object.put !== undefined && object.put !== null) { + message.put = object.put; + } else { + message.put = undefined; + } + if (object.post !== undefined && object.post !== null) { + message.post = object.post; + } else { + message.post = undefined; + } + if (object.delete !== undefined && object.delete !== null) { + message.delete = object.delete; + } else { + message.delete = undefined; + } + if (object.patch !== undefined && object.patch !== null) { + message.patch = object.patch; + } else { + message.patch = undefined; + } + if (object.custom !== undefined && object.custom !== null) { + message.custom = CustomHttpPattern.fromPartial(object.custom); + } else { + message.custom = undefined; + } + if (object.body !== undefined && object.body !== null) { + message.body = object.body; + } else { + message.body = ""; + } + if (object.responseBody !== undefined && object.responseBody !== null) { + message.responseBody = object.responseBody; + } else { + message.responseBody = ""; + } + if ( + object.additionalBindings !== undefined && + object.additionalBindings !== null + ) { + for (const e of object.additionalBindings) { + message.additionalBindings.push(HttpRule.fromPartial(e)); + } + } + return message; + }, +}; + +const baseCustomHttpPattern: object = { kind: "", path: "" }; + +export const CustomHttpPattern = { + encode(message: CustomHttpPattern, writer: Writer = Writer.create()): Writer { + if (message.kind !== "") { + writer.uint32(10).string(message.kind); + } + if (message.path !== "") { + writer.uint32(18).string(message.path); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): CustomHttpPattern { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseCustomHttpPattern } as CustomHttpPattern; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.kind = reader.string(); + break; + case 2: + message.path = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): CustomHttpPattern { + const message = { ...baseCustomHttpPattern } as CustomHttpPattern; + if (object.kind !== undefined && object.kind !== null) { + message.kind = String(object.kind); + } else { + message.kind = ""; + } + if (object.path !== undefined && object.path !== null) { + message.path = String(object.path); + } else { + message.path = ""; + } + return message; + }, + + toJSON(message: CustomHttpPattern): unknown { + const obj: any = {}; + message.kind !== undefined && (obj.kind = message.kind); + message.path !== undefined && (obj.path = message.path); + return obj; + }, + + fromPartial(object: DeepPartial): CustomHttpPattern { + const message = { ...baseCustomHttpPattern } as CustomHttpPattern; + if (object.kind !== undefined && object.kind !== null) { + message.kind = object.kind; + } else { + message.kind = ""; + } + if (object.path !== undefined && object.path !== null) { + message.path = object.path; + } else { + message.path = ""; + } + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/ibc.core.channel.v1/types/google/protobuf/any.ts b/ts-client/ibc.core.channel.v1/types/google/protobuf/any.ts new file mode 100644 index 00000000..b137a629 --- /dev/null +++ b/ts-client/ibc.core.channel.v1/types/google/protobuf/any.ts @@ -0,0 +1,240 @@ +/* eslint-disable */ +import { Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "google.protobuf"; + +/** + * `Any` contains an arbitrary serialized protocol buffer message along with a + * URL that describes the type of the serialized message. + * + * Protobuf library provides support to pack/unpack Any values in the form + * of utility functions or additional generated methods of the Any type. + * + * Example 1: Pack and unpack a message in C++. + * + * Foo foo = ...; + * Any any; + * any.PackFrom(foo); + * ... + * if (any.UnpackTo(&foo)) { + * ... + * } + * + * Example 2: Pack and unpack a message in Java. + * + * Foo foo = ...; + * Any any = Any.pack(foo); + * ... + * if (any.is(Foo.class)) { + * foo = any.unpack(Foo.class); + * } + * + * Example 3: Pack and unpack a message in Python. + * + * foo = Foo(...) + * any = Any() + * any.Pack(foo) + * ... + * if any.Is(Foo.DESCRIPTOR): + * any.Unpack(foo) + * ... + * + * Example 4: Pack and unpack a message in Go + * + * foo := &pb.Foo{...} + * any, err := anypb.New(foo) + * if err != nil { + * ... + * } + * ... + * foo := &pb.Foo{} + * if err := any.UnmarshalTo(foo); err != nil { + * ... + * } + * + * The pack methods provided by protobuf library will by default use + * 'type.googleapis.com/full.type.name' as the type URL and the unpack + * methods only use the fully qualified type name after the last '/' + * in the type URL, for example "foo.bar.com/x/y.z" will yield type + * name "y.z". + * + * + * JSON + * ==== + * The JSON representation of an `Any` value uses the regular + * representation of the deserialized, embedded message, with an + * additional field `@type` which contains the type URL. Example: + * + * package google.profile; + * message Person { + * string first_name = 1; + * string last_name = 2; + * } + * + * { + * "@type": "type.googleapis.com/google.profile.Person", + * "firstName": , + * "lastName": + * } + * + * If the embedded message type is well-known and has a custom JSON + * representation, that representation will be embedded adding a field + * `value` which holds the custom JSON in addition to the `@type` + * field. Example (for message [google.protobuf.Duration][]): + * + * { + * "@type": "type.googleapis.com/google.protobuf.Duration", + * "value": "1.212s" + * } + */ +export interface Any { + /** + * A URL/resource name that uniquely identifies the type of the serialized + * protocol buffer message. This string must contain at least + * one "/" character. The last segment of the URL's path must represent + * the fully qualified name of the type (as in + * `path/google.protobuf.Duration`). The name should be in a canonical form + * (e.g., leading "." is not accepted). + * + * In practice, teams usually precompile into the binary all types that they + * expect it to use in the context of Any. However, for URLs which use the + * scheme `http`, `https`, or no scheme, one can optionally set up a type + * server that maps type URLs to message definitions as follows: + * + * * If no scheme is provided, `https` is assumed. + * * An HTTP GET on the URL must yield a [google.protobuf.Type][] + * value in binary format, or produce an error. + * * Applications are allowed to cache lookup results based on the + * URL, or have them precompiled into a binary to avoid any + * lookup. Therefore, binary compatibility needs to be preserved + * on changes to types. (Use versioned type names to manage + * breaking changes.) + * + * Note: this functionality is not currently available in the official + * protobuf release, and it is not used for type URLs beginning with + * type.googleapis.com. + * + * Schemes other than `http`, `https` (or the empty scheme) might be + * used with implementation specific semantics. + */ + typeUrl: string; + /** Must be a valid serialized protocol buffer of the above specified type. */ + value: Uint8Array; +} + +const baseAny: object = { typeUrl: "" }; + +export const Any = { + encode(message: Any, writer: Writer = Writer.create()): Writer { + if (message.typeUrl !== "") { + writer.uint32(10).string(message.typeUrl); + } + if (message.value.length !== 0) { + writer.uint32(18).bytes(message.value); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Any { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseAny } as Any; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.typeUrl = reader.string(); + break; + case 2: + message.value = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Any { + const message = { ...baseAny } as Any; + if (object.typeUrl !== undefined && object.typeUrl !== null) { + message.typeUrl = String(object.typeUrl); + } else { + message.typeUrl = ""; + } + if (object.value !== undefined && object.value !== null) { + message.value = bytesFromBase64(object.value); + } + return message; + }, + + toJSON(message: Any): unknown { + const obj: any = {}; + message.typeUrl !== undefined && (obj.typeUrl = message.typeUrl); + message.value !== undefined && + (obj.value = base64FromBytes( + message.value !== undefined ? message.value : new Uint8Array() + )); + return obj; + }, + + fromPartial(object: DeepPartial): Any { + const message = { ...baseAny } as Any; + if (object.typeUrl !== undefined && object.typeUrl !== null) { + message.typeUrl = object.typeUrl; + } else { + message.typeUrl = ""; + } + if (object.value !== undefined && object.value !== null) { + message.value = object.value; + } else { + message.value = new Uint8Array(); + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/ibc.core.channel.v1/types/google/protobuf/descriptor.ts b/ts-client/ibc.core.channel.v1/types/google/protobuf/descriptor.ts new file mode 100644 index 00000000..9e508660 --- /dev/null +++ b/ts-client/ibc.core.channel.v1/types/google/protobuf/descriptor.ts @@ -0,0 +1,5261 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "google.protobuf"; + +/** + * The protocol compiler can output a FileDescriptorSet containing the .proto + * files it parses. + */ +export interface FileDescriptorSet { + file: FileDescriptorProto[]; +} + +/** Describes a complete .proto file. */ +export interface FileDescriptorProto { + /** file name, relative to root of source tree */ + name: string; + /** e.g. "foo", "foo.bar", etc. */ + package: string; + /** Names of files imported by this file. */ + dependency: string[]; + /** Indexes of the public imported files in the dependency list above. */ + publicDependency: number[]; + /** + * Indexes of the weak imported files in the dependency list. + * For Google-internal migration only. Do not use. + */ + weakDependency: number[]; + /** All top-level definitions in this file. */ + messageType: DescriptorProto[]; + enumType: EnumDescriptorProto[]; + service: ServiceDescriptorProto[]; + extension: FieldDescriptorProto[]; + options: FileOptions | undefined; + /** + * This field contains optional information about the original source code. + * You may safely remove this entire field without harming runtime + * functionality of the descriptors -- the information is needed only by + * development tools. + */ + sourceCodeInfo: SourceCodeInfo | undefined; + /** + * The syntax of the proto file. + * The supported values are "proto2" and "proto3". + */ + syntax: string; +} + +/** Describes a message type. */ +export interface DescriptorProto { + name: string; + field: FieldDescriptorProto[]; + extension: FieldDescriptorProto[]; + nestedType: DescriptorProto[]; + enumType: EnumDescriptorProto[]; + extensionRange: DescriptorProto_ExtensionRange[]; + oneofDecl: OneofDescriptorProto[]; + options: MessageOptions | undefined; + reservedRange: DescriptorProto_ReservedRange[]; + /** + * Reserved field names, which may not be used by fields in the same message. + * A given name may only be reserved once. + */ + reservedName: string[]; +} + +export interface DescriptorProto_ExtensionRange { + /** Inclusive. */ + start: number; + /** Exclusive. */ + end: number; + options: ExtensionRangeOptions | undefined; +} + +/** + * Range of reserved tag numbers. Reserved tag numbers may not be used by + * fields or extension ranges in the same message. Reserved ranges may + * not overlap. + */ +export interface DescriptorProto_ReservedRange { + /** Inclusive. */ + start: number; + /** Exclusive. */ + end: number; +} + +export interface ExtensionRangeOptions { + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +/** Describes a field within a message. */ +export interface FieldDescriptorProto { + name: string; + number: number; + label: FieldDescriptorProto_Label; + /** + * If type_name is set, this need not be set. If both this and type_name + * are set, this must be one of TYPE_ENUM, TYPE_MESSAGE or TYPE_GROUP. + */ + type: FieldDescriptorProto_Type; + /** + * For message and enum types, this is the name of the type. If the name + * starts with a '.', it is fully-qualified. Otherwise, C++-like scoping + * rules are used to find the type (i.e. first the nested types within this + * message are searched, then within the parent, on up to the root + * namespace). + */ + typeName: string; + /** + * For extensions, this is the name of the type being extended. It is + * resolved in the same manner as type_name. + */ + extendee: string; + /** + * For numeric types, contains the original text representation of the value. + * For booleans, "true" or "false". + * For strings, contains the default text contents (not escaped in any way). + * For bytes, contains the C escaped value. All bytes >= 128 are escaped. + * TODO(kenton): Base-64 encode? + */ + defaultValue: string; + /** + * If set, gives the index of a oneof in the containing type's oneof_decl + * list. This field is a member of that oneof. + */ + oneofIndex: number; + /** + * JSON name of this field. The value is set by protocol compiler. If the + * user has set a "json_name" option on this field, that option's value + * will be used. Otherwise, it's deduced from the field's name by converting + * it to camelCase. + */ + jsonName: string; + options: FieldOptions | undefined; + /** + * If true, this is a proto3 "optional". When a proto3 field is optional, it + * tracks presence regardless of field type. + * + * When proto3_optional is true, this field must be belong to a oneof to + * signal to old proto3 clients that presence is tracked for this field. This + * oneof is known as a "synthetic" oneof, and this field must be its sole + * member (each proto3 optional field gets its own synthetic oneof). Synthetic + * oneofs exist in the descriptor only, and do not generate any API. Synthetic + * oneofs must be ordered after all "real" oneofs. + * + * For message fields, proto3_optional doesn't create any semantic change, + * since non-repeated message fields always track presence. However it still + * indicates the semantic detail of whether the user wrote "optional" or not. + * This can be useful for round-tripping the .proto file. For consistency we + * give message fields a synthetic oneof also, even though it is not required + * to track presence. This is especially important because the parser can't + * tell if a field is a message or an enum, so it must always create a + * synthetic oneof. + * + * Proto2 optional fields do not set this flag, because they already indicate + * optional with `LABEL_OPTIONAL`. + */ + proto3Optional: boolean; +} + +export enum FieldDescriptorProto_Type { + /** + * TYPE_DOUBLE - 0 is reserved for errors. + * Order is weird for historical reasons. + */ + TYPE_DOUBLE = 1, + TYPE_FLOAT = 2, + /** + * TYPE_INT64 - Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT64 if + * negative values are likely. + */ + TYPE_INT64 = 3, + TYPE_UINT64 = 4, + /** + * TYPE_INT32 - Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT32 if + * negative values are likely. + */ + TYPE_INT32 = 5, + TYPE_FIXED64 = 6, + TYPE_FIXED32 = 7, + TYPE_BOOL = 8, + TYPE_STRING = 9, + /** + * TYPE_GROUP - Tag-delimited aggregate. + * Group type is deprecated and not supported in proto3. However, Proto3 + * implementations should still be able to parse the group wire format and + * treat group fields as unknown fields. + */ + TYPE_GROUP = 10, + /** TYPE_MESSAGE - Length-delimited aggregate. */ + TYPE_MESSAGE = 11, + /** TYPE_BYTES - New in version 2. */ + TYPE_BYTES = 12, + TYPE_UINT32 = 13, + TYPE_ENUM = 14, + TYPE_SFIXED32 = 15, + TYPE_SFIXED64 = 16, + /** TYPE_SINT32 - Uses ZigZag encoding. */ + TYPE_SINT32 = 17, + /** TYPE_SINT64 - Uses ZigZag encoding. */ + TYPE_SINT64 = 18, + UNRECOGNIZED = -1, +} + +export function fieldDescriptorProto_TypeFromJSON( + object: any +): FieldDescriptorProto_Type { + switch (object) { + case 1: + case "TYPE_DOUBLE": + return FieldDescriptorProto_Type.TYPE_DOUBLE; + case 2: + case "TYPE_FLOAT": + return FieldDescriptorProto_Type.TYPE_FLOAT; + case 3: + case "TYPE_INT64": + return FieldDescriptorProto_Type.TYPE_INT64; + case 4: + case "TYPE_UINT64": + return FieldDescriptorProto_Type.TYPE_UINT64; + case 5: + case "TYPE_INT32": + return FieldDescriptorProto_Type.TYPE_INT32; + case 6: + case "TYPE_FIXED64": + return FieldDescriptorProto_Type.TYPE_FIXED64; + case 7: + case "TYPE_FIXED32": + return FieldDescriptorProto_Type.TYPE_FIXED32; + case 8: + case "TYPE_BOOL": + return FieldDescriptorProto_Type.TYPE_BOOL; + case 9: + case "TYPE_STRING": + return FieldDescriptorProto_Type.TYPE_STRING; + case 10: + case "TYPE_GROUP": + return FieldDescriptorProto_Type.TYPE_GROUP; + case 11: + case "TYPE_MESSAGE": + return FieldDescriptorProto_Type.TYPE_MESSAGE; + case 12: + case "TYPE_BYTES": + return FieldDescriptorProto_Type.TYPE_BYTES; + case 13: + case "TYPE_UINT32": + return FieldDescriptorProto_Type.TYPE_UINT32; + case 14: + case "TYPE_ENUM": + return FieldDescriptorProto_Type.TYPE_ENUM; + case 15: + case "TYPE_SFIXED32": + return FieldDescriptorProto_Type.TYPE_SFIXED32; + case 16: + case "TYPE_SFIXED64": + return FieldDescriptorProto_Type.TYPE_SFIXED64; + case 17: + case "TYPE_SINT32": + return FieldDescriptorProto_Type.TYPE_SINT32; + case 18: + case "TYPE_SINT64": + return FieldDescriptorProto_Type.TYPE_SINT64; + case -1: + case "UNRECOGNIZED": + default: + return FieldDescriptorProto_Type.UNRECOGNIZED; + } +} + +export function fieldDescriptorProto_TypeToJSON( + object: FieldDescriptorProto_Type +): string { + switch (object) { + case FieldDescriptorProto_Type.TYPE_DOUBLE: + return "TYPE_DOUBLE"; + case FieldDescriptorProto_Type.TYPE_FLOAT: + return "TYPE_FLOAT"; + case FieldDescriptorProto_Type.TYPE_INT64: + return "TYPE_INT64"; + case FieldDescriptorProto_Type.TYPE_UINT64: + return "TYPE_UINT64"; + case FieldDescriptorProto_Type.TYPE_INT32: + return "TYPE_INT32"; + case FieldDescriptorProto_Type.TYPE_FIXED64: + return "TYPE_FIXED64"; + case FieldDescriptorProto_Type.TYPE_FIXED32: + return "TYPE_FIXED32"; + case FieldDescriptorProto_Type.TYPE_BOOL: + return "TYPE_BOOL"; + case FieldDescriptorProto_Type.TYPE_STRING: + return "TYPE_STRING"; + case FieldDescriptorProto_Type.TYPE_GROUP: + return "TYPE_GROUP"; + case FieldDescriptorProto_Type.TYPE_MESSAGE: + return "TYPE_MESSAGE"; + case FieldDescriptorProto_Type.TYPE_BYTES: + return "TYPE_BYTES"; + case FieldDescriptorProto_Type.TYPE_UINT32: + return "TYPE_UINT32"; + case FieldDescriptorProto_Type.TYPE_ENUM: + return "TYPE_ENUM"; + case FieldDescriptorProto_Type.TYPE_SFIXED32: + return "TYPE_SFIXED32"; + case FieldDescriptorProto_Type.TYPE_SFIXED64: + return "TYPE_SFIXED64"; + case FieldDescriptorProto_Type.TYPE_SINT32: + return "TYPE_SINT32"; + case FieldDescriptorProto_Type.TYPE_SINT64: + return "TYPE_SINT64"; + default: + return "UNKNOWN"; + } +} + +export enum FieldDescriptorProto_Label { + /** LABEL_OPTIONAL - 0 is reserved for errors */ + LABEL_OPTIONAL = 1, + LABEL_REQUIRED = 2, + LABEL_REPEATED = 3, + UNRECOGNIZED = -1, +} + +export function fieldDescriptorProto_LabelFromJSON( + object: any +): FieldDescriptorProto_Label { + switch (object) { + case 1: + case "LABEL_OPTIONAL": + return FieldDescriptorProto_Label.LABEL_OPTIONAL; + case 2: + case "LABEL_REQUIRED": + return FieldDescriptorProto_Label.LABEL_REQUIRED; + case 3: + case "LABEL_REPEATED": + return FieldDescriptorProto_Label.LABEL_REPEATED; + case -1: + case "UNRECOGNIZED": + default: + return FieldDescriptorProto_Label.UNRECOGNIZED; + } +} + +export function fieldDescriptorProto_LabelToJSON( + object: FieldDescriptorProto_Label +): string { + switch (object) { + case FieldDescriptorProto_Label.LABEL_OPTIONAL: + return "LABEL_OPTIONAL"; + case FieldDescriptorProto_Label.LABEL_REQUIRED: + return "LABEL_REQUIRED"; + case FieldDescriptorProto_Label.LABEL_REPEATED: + return "LABEL_REPEATED"; + default: + return "UNKNOWN"; + } +} + +/** Describes a oneof. */ +export interface OneofDescriptorProto { + name: string; + options: OneofOptions | undefined; +} + +/** Describes an enum type. */ +export interface EnumDescriptorProto { + name: string; + value: EnumValueDescriptorProto[]; + options: EnumOptions | undefined; + /** + * Range of reserved numeric values. Reserved numeric values may not be used + * by enum values in the same enum declaration. Reserved ranges may not + * overlap. + */ + reservedRange: EnumDescriptorProto_EnumReservedRange[]; + /** + * Reserved enum value names, which may not be reused. A given name may only + * be reserved once. + */ + reservedName: string[]; +} + +/** + * Range of reserved numeric values. Reserved values may not be used by + * entries in the same enum. Reserved ranges may not overlap. + * + * Note that this is distinct from DescriptorProto.ReservedRange in that it + * is inclusive such that it can appropriately represent the entire int32 + * domain. + */ +export interface EnumDescriptorProto_EnumReservedRange { + /** Inclusive. */ + start: number; + /** Inclusive. */ + end: number; +} + +/** Describes a value within an enum. */ +export interface EnumValueDescriptorProto { + name: string; + number: number; + options: EnumValueOptions | undefined; +} + +/** Describes a service. */ +export interface ServiceDescriptorProto { + name: string; + method: MethodDescriptorProto[]; + options: ServiceOptions | undefined; +} + +/** Describes a method of a service. */ +export interface MethodDescriptorProto { + name: string; + /** + * Input and output type names. These are resolved in the same way as + * FieldDescriptorProto.type_name, but must refer to a message type. + */ + inputType: string; + outputType: string; + options: MethodOptions | undefined; + /** Identifies if client streams multiple client messages */ + clientStreaming: boolean; + /** Identifies if server streams multiple server messages */ + serverStreaming: boolean; +} + +export interface FileOptions { + /** + * Sets the Java package where classes generated from this .proto will be + * placed. By default, the proto package is used, but this is often + * inappropriate because proto packages do not normally start with backwards + * domain names. + */ + javaPackage: string; + /** + * Controls the name of the wrapper Java class generated for the .proto file. + * That class will always contain the .proto file's getDescriptor() method as + * well as any top-level extensions defined in the .proto file. + * If java_multiple_files is disabled, then all the other classes from the + * .proto file will be nested inside the single wrapper outer class. + */ + javaOuterClassname: string; + /** + * If enabled, then the Java code generator will generate a separate .java + * file for each top-level message, enum, and service defined in the .proto + * file. Thus, these types will *not* be nested inside the wrapper class + * named by java_outer_classname. However, the wrapper class will still be + * generated to contain the file's getDescriptor() method as well as any + * top-level extensions defined in the file. + */ + javaMultipleFiles: boolean; + /** + * This option does nothing. + * + * @deprecated + */ + javaGenerateEqualsAndHash: boolean; + /** + * If set true, then the Java2 code generator will generate code that + * throws an exception whenever an attempt is made to assign a non-UTF-8 + * byte sequence to a string field. + * Message reflection will do the same. + * However, an extension field still accepts non-UTF-8 byte sequences. + * This option has no effect on when used with the lite runtime. + */ + javaStringCheckUtf8: boolean; + optimizeFor: FileOptions_OptimizeMode; + /** + * Sets the Go package where structs generated from this .proto will be + * placed. If omitted, the Go package will be derived from the following: + * - The basename of the package import path, if provided. + * - Otherwise, the package statement in the .proto file, if present. + * - Otherwise, the basename of the .proto file, without extension. + */ + goPackage: string; + /** + * Should generic services be generated in each language? "Generic" services + * are not specific to any particular RPC system. They are generated by the + * main code generators in each language (without additional plugins). + * Generic services were the only kind of service generation supported by + * early versions of google.protobuf. + * + * Generic services are now considered deprecated in favor of using plugins + * that generate code specific to your particular RPC system. Therefore, + * these default to false. Old code which depends on generic services should + * explicitly set them to true. + */ + ccGenericServices: boolean; + javaGenericServices: boolean; + pyGenericServices: boolean; + phpGenericServices: boolean; + /** + * Is this file deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for everything in the file, or it will be completely ignored; in the very + * least, this is a formalization for deprecating files. + */ + deprecated: boolean; + /** + * Enables the use of arenas for the proto messages in this file. This applies + * only to generated classes for C++. + */ + ccEnableArenas: boolean; + /** + * Sets the objective c class prefix which is prepended to all objective c + * generated classes from this .proto. There is no default. + */ + objcClassPrefix: string; + /** Namespace for generated classes; defaults to the package. */ + csharpNamespace: string; + /** + * By default Swift generators will take the proto package and CamelCase it + * replacing '.' with underscore and use that to prefix the types/symbols + * defined. When this options is provided, they will use this value instead + * to prefix the types/symbols defined. + */ + swiftPrefix: string; + /** + * Sets the php class prefix which is prepended to all php generated classes + * from this .proto. Default is empty. + */ + phpClassPrefix: string; + /** + * Use this option to change the namespace of php generated classes. Default + * is empty. When this option is empty, the package name will be used for + * determining the namespace. + */ + phpNamespace: string; + /** + * Use this option to change the namespace of php generated metadata classes. + * Default is empty. When this option is empty, the proto file name will be + * used for determining the namespace. + */ + phpMetadataNamespace: string; + /** + * Use this option to change the package of ruby generated classes. Default + * is empty. When this option is not set, the package name will be used for + * determining the ruby package. + */ + rubyPackage: string; + /** + * The parser stores options it doesn't recognize here. + * See the documentation for the "Options" section above. + */ + uninterpretedOption: UninterpretedOption[]; +} + +/** Generated classes can be optimized for speed or code size. */ +export enum FileOptions_OptimizeMode { + /** SPEED - Generate complete code for parsing, serialization, */ + SPEED = 1, + /** CODE_SIZE - etc. */ + CODE_SIZE = 2, + /** LITE_RUNTIME - Generate code using MessageLite and the lite runtime. */ + LITE_RUNTIME = 3, + UNRECOGNIZED = -1, +} + +export function fileOptions_OptimizeModeFromJSON( + object: any +): FileOptions_OptimizeMode { + switch (object) { + case 1: + case "SPEED": + return FileOptions_OptimizeMode.SPEED; + case 2: + case "CODE_SIZE": + return FileOptions_OptimizeMode.CODE_SIZE; + case 3: + case "LITE_RUNTIME": + return FileOptions_OptimizeMode.LITE_RUNTIME; + case -1: + case "UNRECOGNIZED": + default: + return FileOptions_OptimizeMode.UNRECOGNIZED; + } +} + +export function fileOptions_OptimizeModeToJSON( + object: FileOptions_OptimizeMode +): string { + switch (object) { + case FileOptions_OptimizeMode.SPEED: + return "SPEED"; + case FileOptions_OptimizeMode.CODE_SIZE: + return "CODE_SIZE"; + case FileOptions_OptimizeMode.LITE_RUNTIME: + return "LITE_RUNTIME"; + default: + return "UNKNOWN"; + } +} + +export interface MessageOptions { + /** + * Set true to use the old proto1 MessageSet wire format for extensions. + * This is provided for backwards-compatibility with the MessageSet wire + * format. You should not use this for any other reason: It's less + * efficient, has fewer features, and is more complicated. + * + * The message must be defined exactly as follows: + * message Foo { + * option message_set_wire_format = true; + * extensions 4 to max; + * } + * Note that the message cannot have any defined fields; MessageSets only + * have extensions. + * + * All extensions of your type must be singular messages; e.g. they cannot + * be int32s, enums, or repeated messages. + * + * Because this is an option, the above two restrictions are not enforced by + * the protocol compiler. + */ + messageSetWireFormat: boolean; + /** + * Disables the generation of the standard "descriptor()" accessor, which can + * conflict with a field of the same name. This is meant to make migration + * from proto1 easier; new code should avoid fields named "descriptor". + */ + noStandardDescriptorAccessor: boolean; + /** + * Is this message deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the message, or it will be completely ignored; in the very least, + * this is a formalization for deprecating messages. + */ + deprecated: boolean; + /** + * Whether the message is an automatically generated map entry type for the + * maps field. + * + * For maps fields: + * map map_field = 1; + * The parsed descriptor looks like: + * message MapFieldEntry { + * option map_entry = true; + * optional KeyType key = 1; + * optional ValueType value = 2; + * } + * repeated MapFieldEntry map_field = 1; + * + * Implementations may choose not to generate the map_entry=true message, but + * use a native map in the target language to hold the keys and values. + * The reflection APIs in such implementations still need to work as + * if the field is a repeated message field. + * + * NOTE: Do not set the option in .proto files. Always use the maps syntax + * instead. The option should only be implicitly set by the proto compiler + * parser. + */ + mapEntry: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface FieldOptions { + /** + * The ctype option instructs the C++ code generator to use a different + * representation of the field than it normally would. See the specific + * options below. This option is not yet implemented in the open source + * release -- sorry, we'll try to include it in a future version! + */ + ctype: FieldOptions_CType; + /** + * The packed option can be enabled for repeated primitive fields to enable + * a more efficient representation on the wire. Rather than repeatedly + * writing the tag and type for each element, the entire array is encoded as + * a single length-delimited blob. In proto3, only explicit setting it to + * false will avoid using packed encoding. + */ + packed: boolean; + /** + * The jstype option determines the JavaScript type used for values of the + * field. The option is permitted only for 64 bit integral and fixed types + * (int64, uint64, sint64, fixed64, sfixed64). A field with jstype JS_STRING + * is represented as JavaScript string, which avoids loss of precision that + * can happen when a large value is converted to a floating point JavaScript. + * Specifying JS_NUMBER for the jstype causes the generated JavaScript code to + * use the JavaScript "number" type. The behavior of the default option + * JS_NORMAL is implementation dependent. + * + * This option is an enum to permit additional types to be added, e.g. + * goog.math.Integer. + */ + jstype: FieldOptions_JSType; + /** + * Should this field be parsed lazily? Lazy applies only to message-type + * fields. It means that when the outer message is initially parsed, the + * inner message's contents will not be parsed but instead stored in encoded + * form. The inner message will actually be parsed when it is first accessed. + * + * This is only a hint. Implementations are free to choose whether to use + * eager or lazy parsing regardless of the value of this option. However, + * setting this option true suggests that the protocol author believes that + * using lazy parsing on this field is worth the additional bookkeeping + * overhead typically needed to implement it. + * + * This option does not affect the public interface of any generated code; + * all method signatures remain the same. Furthermore, thread-safety of the + * interface is not affected by this option; const methods remain safe to + * call from multiple threads concurrently, while non-const methods continue + * to require exclusive access. + * + * + * Note that implementations may choose not to check required fields within + * a lazy sub-message. That is, calling IsInitialized() on the outer message + * may return true even if the inner message has missing required fields. + * This is necessary because otherwise the inner message would have to be + * parsed in order to perform the check, defeating the purpose of lazy + * parsing. An implementation which chooses not to check required fields + * must be consistent about it. That is, for any particular sub-message, the + * implementation must either *always* check its required fields, or *never* + * check its required fields, regardless of whether or not the message has + * been parsed. + */ + lazy: boolean; + /** + * Is this field deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for accessors, or it will be completely ignored; in the very least, this + * is a formalization for deprecating fields. + */ + deprecated: boolean; + /** For Google-internal migration only. Do not use. */ + weak: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export enum FieldOptions_CType { + /** STRING - Default mode. */ + STRING = 0, + CORD = 1, + STRING_PIECE = 2, + UNRECOGNIZED = -1, +} + +export function fieldOptions_CTypeFromJSON(object: any): FieldOptions_CType { + switch (object) { + case 0: + case "STRING": + return FieldOptions_CType.STRING; + case 1: + case "CORD": + return FieldOptions_CType.CORD; + case 2: + case "STRING_PIECE": + return FieldOptions_CType.STRING_PIECE; + case -1: + case "UNRECOGNIZED": + default: + return FieldOptions_CType.UNRECOGNIZED; + } +} + +export function fieldOptions_CTypeToJSON(object: FieldOptions_CType): string { + switch (object) { + case FieldOptions_CType.STRING: + return "STRING"; + case FieldOptions_CType.CORD: + return "CORD"; + case FieldOptions_CType.STRING_PIECE: + return "STRING_PIECE"; + default: + return "UNKNOWN"; + } +} + +export enum FieldOptions_JSType { + /** JS_NORMAL - Use the default type. */ + JS_NORMAL = 0, + /** JS_STRING - Use JavaScript strings. */ + JS_STRING = 1, + /** JS_NUMBER - Use JavaScript numbers. */ + JS_NUMBER = 2, + UNRECOGNIZED = -1, +} + +export function fieldOptions_JSTypeFromJSON(object: any): FieldOptions_JSType { + switch (object) { + case 0: + case "JS_NORMAL": + return FieldOptions_JSType.JS_NORMAL; + case 1: + case "JS_STRING": + return FieldOptions_JSType.JS_STRING; + case 2: + case "JS_NUMBER": + return FieldOptions_JSType.JS_NUMBER; + case -1: + case "UNRECOGNIZED": + default: + return FieldOptions_JSType.UNRECOGNIZED; + } +} + +export function fieldOptions_JSTypeToJSON(object: FieldOptions_JSType): string { + switch (object) { + case FieldOptions_JSType.JS_NORMAL: + return "JS_NORMAL"; + case FieldOptions_JSType.JS_STRING: + return "JS_STRING"; + case FieldOptions_JSType.JS_NUMBER: + return "JS_NUMBER"; + default: + return "UNKNOWN"; + } +} + +export interface OneofOptions { + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface EnumOptions { + /** + * Set this option to true to allow mapping different tag names to the same + * value. + */ + allowAlias: boolean; + /** + * Is this enum deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the enum, or it will be completely ignored; in the very least, this + * is a formalization for deprecating enums. + */ + deprecated: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface EnumValueOptions { + /** + * Is this enum value deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the enum value, or it will be completely ignored; in the very least, + * this is a formalization for deprecating enum values. + */ + deprecated: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface ServiceOptions { + /** + * Is this service deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the service, or it will be completely ignored; in the very least, + * this is a formalization for deprecating services. + */ + deprecated: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface MethodOptions { + /** + * Is this method deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the method, or it will be completely ignored; in the very least, + * this is a formalization for deprecating methods. + */ + deprecated: boolean; + idempotencyLevel: MethodOptions_IdempotencyLevel; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +/** + * Is this method side-effect-free (or safe in HTTP parlance), or idempotent, + * or neither? HTTP based RPC implementation may choose GET verb for safe + * methods, and PUT verb for idempotent methods instead of the default POST. + */ +export enum MethodOptions_IdempotencyLevel { + IDEMPOTENCY_UNKNOWN = 0, + /** NO_SIDE_EFFECTS - implies idempotent */ + NO_SIDE_EFFECTS = 1, + /** IDEMPOTENT - idempotent, but may have side effects */ + IDEMPOTENT = 2, + UNRECOGNIZED = -1, +} + +export function methodOptions_IdempotencyLevelFromJSON( + object: any +): MethodOptions_IdempotencyLevel { + switch (object) { + case 0: + case "IDEMPOTENCY_UNKNOWN": + return MethodOptions_IdempotencyLevel.IDEMPOTENCY_UNKNOWN; + case 1: + case "NO_SIDE_EFFECTS": + return MethodOptions_IdempotencyLevel.NO_SIDE_EFFECTS; + case 2: + case "IDEMPOTENT": + return MethodOptions_IdempotencyLevel.IDEMPOTENT; + case -1: + case "UNRECOGNIZED": + default: + return MethodOptions_IdempotencyLevel.UNRECOGNIZED; + } +} + +export function methodOptions_IdempotencyLevelToJSON( + object: MethodOptions_IdempotencyLevel +): string { + switch (object) { + case MethodOptions_IdempotencyLevel.IDEMPOTENCY_UNKNOWN: + return "IDEMPOTENCY_UNKNOWN"; + case MethodOptions_IdempotencyLevel.NO_SIDE_EFFECTS: + return "NO_SIDE_EFFECTS"; + case MethodOptions_IdempotencyLevel.IDEMPOTENT: + return "IDEMPOTENT"; + default: + return "UNKNOWN"; + } +} + +/** + * A message representing a option the parser does not recognize. This only + * appears in options protos created by the compiler::Parser class. + * DescriptorPool resolves these when building Descriptor objects. Therefore, + * options protos in descriptor objects (e.g. returned by Descriptor::options(), + * or produced by Descriptor::CopyTo()) will never have UninterpretedOptions + * in them. + */ +export interface UninterpretedOption { + name: UninterpretedOption_NamePart[]; + /** + * The value of the uninterpreted option, in whatever type the tokenizer + * identified it as during parsing. Exactly one of these should be set. + */ + identifierValue: string; + positiveIntValue: number; + negativeIntValue: number; + doubleValue: number; + stringValue: Uint8Array; + aggregateValue: string; +} + +/** + * The name of the uninterpreted option. Each string represents a segment in + * a dot-separated name. is_extension is true iff a segment represents an + * extension (denoted with parentheses in options specs in .proto files). + * E.g.,{ ["foo", false], ["bar.baz", true], ["qux", false] } represents + * "foo.(bar.baz).qux". + */ +export interface UninterpretedOption_NamePart { + namePart: string; + isExtension: boolean; +} + +/** + * Encapsulates information about the original source file from which a + * FileDescriptorProto was generated. + */ +export interface SourceCodeInfo { + /** + * A Location identifies a piece of source code in a .proto file which + * corresponds to a particular definition. This information is intended + * to be useful to IDEs, code indexers, documentation generators, and similar + * tools. + * + * For example, say we have a file like: + * message Foo { + * optional string foo = 1; + * } + * Let's look at just the field definition: + * optional string foo = 1; + * ^ ^^ ^^ ^ ^^^ + * a bc de f ghi + * We have the following locations: + * span path represents + * [a,i) [ 4, 0, 2, 0 ] The whole field definition. + * [a,b) [ 4, 0, 2, 0, 4 ] The label (optional). + * [c,d) [ 4, 0, 2, 0, 5 ] The type (string). + * [e,f) [ 4, 0, 2, 0, 1 ] The name (foo). + * [g,h) [ 4, 0, 2, 0, 3 ] The number (1). + * + * Notes: + * - A location may refer to a repeated field itself (i.e. not to any + * particular index within it). This is used whenever a set of elements are + * logically enclosed in a single code segment. For example, an entire + * extend block (possibly containing multiple extension definitions) will + * have an outer location whose path refers to the "extensions" repeated + * field without an index. + * - Multiple locations may have the same path. This happens when a single + * logical declaration is spread out across multiple places. The most + * obvious example is the "extend" block again -- there may be multiple + * extend blocks in the same scope, each of which will have the same path. + * - A location's span is not always a subset of its parent's span. For + * example, the "extendee" of an extension declaration appears at the + * beginning of the "extend" block and is shared by all extensions within + * the block. + * - Just because a location's span is a subset of some other location's span + * does not mean that it is a descendant. For example, a "group" defines + * both a type and a field in a single declaration. Thus, the locations + * corresponding to the type and field and their components will overlap. + * - Code which tries to interpret locations should probably be designed to + * ignore those that it doesn't understand, as more types of locations could + * be recorded in the future. + */ + location: SourceCodeInfo_Location[]; +} + +export interface SourceCodeInfo_Location { + /** + * Identifies which part of the FileDescriptorProto was defined at this + * location. + * + * Each element is a field number or an index. They form a path from + * the root FileDescriptorProto to the place where the definition. For + * example, this path: + * [ 4, 3, 2, 7, 1 ] + * refers to: + * file.message_type(3) // 4, 3 + * .field(7) // 2, 7 + * .name() // 1 + * This is because FileDescriptorProto.message_type has field number 4: + * repeated DescriptorProto message_type = 4; + * and DescriptorProto.field has field number 2: + * repeated FieldDescriptorProto field = 2; + * and FieldDescriptorProto.name has field number 1: + * optional string name = 1; + * + * Thus, the above path gives the location of a field name. If we removed + * the last element: + * [ 4, 3, 2, 7 ] + * this path refers to the whole field declaration (from the beginning + * of the label to the terminating semicolon). + */ + path: number[]; + /** + * Always has exactly three or four elements: start line, start column, + * end line (optional, otherwise assumed same as start line), end column. + * These are packed into a single field for efficiency. Note that line + * and column numbers are zero-based -- typically you will want to add + * 1 to each before displaying to a user. + */ + span: number[]; + /** + * If this SourceCodeInfo represents a complete declaration, these are any + * comments appearing before and after the declaration which appear to be + * attached to the declaration. + * + * A series of line comments appearing on consecutive lines, with no other + * tokens appearing on those lines, will be treated as a single comment. + * + * leading_detached_comments will keep paragraphs of comments that appear + * before (but not connected to) the current element. Each paragraph, + * separated by empty lines, will be one comment element in the repeated + * field. + * + * Only the comment content is provided; comment markers (e.g. //) are + * stripped out. For block comments, leading whitespace and an asterisk + * will be stripped from the beginning of each line other than the first. + * Newlines are included in the output. + * + * Examples: + * + * optional int32 foo = 1; // Comment attached to foo. + * // Comment attached to bar. + * optional int32 bar = 2; + * + * optional string baz = 3; + * // Comment attached to baz. + * // Another line attached to baz. + * + * // Comment attached to qux. + * // + * // Another line attached to qux. + * optional double qux = 4; + * + * // Detached comment for corge. This is not leading or trailing comments + * // to qux or corge because there are blank lines separating it from + * // both. + * + * // Detached comment for corge paragraph 2. + * + * optional string corge = 5; + * /* Block comment attached + * * to corge. Leading asterisks + * * will be removed. * / + * /* Block comment attached to + * * grault. * / + * optional int32 grault = 6; + * + * // ignored detached comments. + */ + leadingComments: string; + trailingComments: string; + leadingDetachedComments: string[]; +} + +/** + * Describes the relationship between generated code and its original source + * file. A GeneratedCodeInfo message is associated with only one generated + * source file, but may contain references to different source .proto files. + */ +export interface GeneratedCodeInfo { + /** + * An Annotation connects some span of text in generated code to an element + * of its generating .proto file. + */ + annotation: GeneratedCodeInfo_Annotation[]; +} + +export interface GeneratedCodeInfo_Annotation { + /** + * Identifies the element in the original source .proto file. This field + * is formatted the same as SourceCodeInfo.Location.path. + */ + path: number[]; + /** Identifies the filesystem path to the original source .proto. */ + sourceFile: string; + /** + * Identifies the starting offset in bytes in the generated code + * that relates to the identified object. + */ + begin: number; + /** + * Identifies the ending offset in bytes in the generated code that + * relates to the identified offset. The end offset should be one past + * the last relevant byte (so the length of the text = end - begin). + */ + end: number; +} + +const baseFileDescriptorSet: object = {}; + +export const FileDescriptorSet = { + encode(message: FileDescriptorSet, writer: Writer = Writer.create()): Writer { + for (const v of message.file) { + FileDescriptorProto.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FileDescriptorSet { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFileDescriptorSet } as FileDescriptorSet; + message.file = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.file.push( + FileDescriptorProto.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FileDescriptorSet { + const message = { ...baseFileDescriptorSet } as FileDescriptorSet; + message.file = []; + if (object.file !== undefined && object.file !== null) { + for (const e of object.file) { + message.file.push(FileDescriptorProto.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: FileDescriptorSet): unknown { + const obj: any = {}; + if (message.file) { + obj.file = message.file.map((e) => + e ? FileDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.file = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): FileDescriptorSet { + const message = { ...baseFileDescriptorSet } as FileDescriptorSet; + message.file = []; + if (object.file !== undefined && object.file !== null) { + for (const e of object.file) { + message.file.push(FileDescriptorProto.fromPartial(e)); + } + } + return message; + }, +}; + +const baseFileDescriptorProto: object = { + name: "", + package: "", + dependency: "", + publicDependency: 0, + weakDependency: 0, + syntax: "", +}; + +export const FileDescriptorProto = { + encode( + message: FileDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.package !== "") { + writer.uint32(18).string(message.package); + } + for (const v of message.dependency) { + writer.uint32(26).string(v!); + } + writer.uint32(82).fork(); + for (const v of message.publicDependency) { + writer.int32(v); + } + writer.ldelim(); + writer.uint32(90).fork(); + for (const v of message.weakDependency) { + writer.int32(v); + } + writer.ldelim(); + for (const v of message.messageType) { + DescriptorProto.encode(v!, writer.uint32(34).fork()).ldelim(); + } + for (const v of message.enumType) { + EnumDescriptorProto.encode(v!, writer.uint32(42).fork()).ldelim(); + } + for (const v of message.service) { + ServiceDescriptorProto.encode(v!, writer.uint32(50).fork()).ldelim(); + } + for (const v of message.extension) { + FieldDescriptorProto.encode(v!, writer.uint32(58).fork()).ldelim(); + } + if (message.options !== undefined) { + FileOptions.encode(message.options, writer.uint32(66).fork()).ldelim(); + } + if (message.sourceCodeInfo !== undefined) { + SourceCodeInfo.encode( + message.sourceCodeInfo, + writer.uint32(74).fork() + ).ldelim(); + } + if (message.syntax !== "") { + writer.uint32(98).string(message.syntax); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FileDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFileDescriptorProto } as FileDescriptorProto; + message.dependency = []; + message.publicDependency = []; + message.weakDependency = []; + message.messageType = []; + message.enumType = []; + message.service = []; + message.extension = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.package = reader.string(); + break; + case 3: + message.dependency.push(reader.string()); + break; + case 10: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.publicDependency.push(reader.int32()); + } + } else { + message.publicDependency.push(reader.int32()); + } + break; + case 11: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.weakDependency.push(reader.int32()); + } + } else { + message.weakDependency.push(reader.int32()); + } + break; + case 4: + message.messageType.push( + DescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 5: + message.enumType.push( + EnumDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 6: + message.service.push( + ServiceDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 7: + message.extension.push( + FieldDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 8: + message.options = FileOptions.decode(reader, reader.uint32()); + break; + case 9: + message.sourceCodeInfo = SourceCodeInfo.decode( + reader, + reader.uint32() + ); + break; + case 12: + message.syntax = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FileDescriptorProto { + const message = { ...baseFileDescriptorProto } as FileDescriptorProto; + message.dependency = []; + message.publicDependency = []; + message.weakDependency = []; + message.messageType = []; + message.enumType = []; + message.service = []; + message.extension = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.package !== undefined && object.package !== null) { + message.package = String(object.package); + } else { + message.package = ""; + } + if (object.dependency !== undefined && object.dependency !== null) { + for (const e of object.dependency) { + message.dependency.push(String(e)); + } + } + if ( + object.publicDependency !== undefined && + object.publicDependency !== null + ) { + for (const e of object.publicDependency) { + message.publicDependency.push(Number(e)); + } + } + if (object.weakDependency !== undefined && object.weakDependency !== null) { + for (const e of object.weakDependency) { + message.weakDependency.push(Number(e)); + } + } + if (object.messageType !== undefined && object.messageType !== null) { + for (const e of object.messageType) { + message.messageType.push(DescriptorProto.fromJSON(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromJSON(e)); + } + } + if (object.service !== undefined && object.service !== null) { + for (const e of object.service) { + message.service.push(ServiceDescriptorProto.fromJSON(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = FileOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.sourceCodeInfo !== undefined && object.sourceCodeInfo !== null) { + message.sourceCodeInfo = SourceCodeInfo.fromJSON(object.sourceCodeInfo); + } else { + message.sourceCodeInfo = undefined; + } + if (object.syntax !== undefined && object.syntax !== null) { + message.syntax = String(object.syntax); + } else { + message.syntax = ""; + } + return message; + }, + + toJSON(message: FileDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.package !== undefined && (obj.package = message.package); + if (message.dependency) { + obj.dependency = message.dependency.map((e) => e); + } else { + obj.dependency = []; + } + if (message.publicDependency) { + obj.publicDependency = message.publicDependency.map((e) => e); + } else { + obj.publicDependency = []; + } + if (message.weakDependency) { + obj.weakDependency = message.weakDependency.map((e) => e); + } else { + obj.weakDependency = []; + } + if (message.messageType) { + obj.messageType = message.messageType.map((e) => + e ? DescriptorProto.toJSON(e) : undefined + ); + } else { + obj.messageType = []; + } + if (message.enumType) { + obj.enumType = message.enumType.map((e) => + e ? EnumDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.enumType = []; + } + if (message.service) { + obj.service = message.service.map((e) => + e ? ServiceDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.service = []; + } + if (message.extension) { + obj.extension = message.extension.map((e) => + e ? FieldDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.extension = []; + } + message.options !== undefined && + (obj.options = message.options + ? FileOptions.toJSON(message.options) + : undefined); + message.sourceCodeInfo !== undefined && + (obj.sourceCodeInfo = message.sourceCodeInfo + ? SourceCodeInfo.toJSON(message.sourceCodeInfo) + : undefined); + message.syntax !== undefined && (obj.syntax = message.syntax); + return obj; + }, + + fromPartial(object: DeepPartial): FileDescriptorProto { + const message = { ...baseFileDescriptorProto } as FileDescriptorProto; + message.dependency = []; + message.publicDependency = []; + message.weakDependency = []; + message.messageType = []; + message.enumType = []; + message.service = []; + message.extension = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.package !== undefined && object.package !== null) { + message.package = object.package; + } else { + message.package = ""; + } + if (object.dependency !== undefined && object.dependency !== null) { + for (const e of object.dependency) { + message.dependency.push(e); + } + } + if ( + object.publicDependency !== undefined && + object.publicDependency !== null + ) { + for (const e of object.publicDependency) { + message.publicDependency.push(e); + } + } + if (object.weakDependency !== undefined && object.weakDependency !== null) { + for (const e of object.weakDependency) { + message.weakDependency.push(e); + } + } + if (object.messageType !== undefined && object.messageType !== null) { + for (const e of object.messageType) { + message.messageType.push(DescriptorProto.fromPartial(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromPartial(e)); + } + } + if (object.service !== undefined && object.service !== null) { + for (const e of object.service) { + message.service.push(ServiceDescriptorProto.fromPartial(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = FileOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.sourceCodeInfo !== undefined && object.sourceCodeInfo !== null) { + message.sourceCodeInfo = SourceCodeInfo.fromPartial( + object.sourceCodeInfo + ); + } else { + message.sourceCodeInfo = undefined; + } + if (object.syntax !== undefined && object.syntax !== null) { + message.syntax = object.syntax; + } else { + message.syntax = ""; + } + return message; + }, +}; + +const baseDescriptorProto: object = { name: "", reservedName: "" }; + +export const DescriptorProto = { + encode(message: DescriptorProto, writer: Writer = Writer.create()): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + for (const v of message.field) { + FieldDescriptorProto.encode(v!, writer.uint32(18).fork()).ldelim(); + } + for (const v of message.extension) { + FieldDescriptorProto.encode(v!, writer.uint32(50).fork()).ldelim(); + } + for (const v of message.nestedType) { + DescriptorProto.encode(v!, writer.uint32(26).fork()).ldelim(); + } + for (const v of message.enumType) { + EnumDescriptorProto.encode(v!, writer.uint32(34).fork()).ldelim(); + } + for (const v of message.extensionRange) { + DescriptorProto_ExtensionRange.encode( + v!, + writer.uint32(42).fork() + ).ldelim(); + } + for (const v of message.oneofDecl) { + OneofDescriptorProto.encode(v!, writer.uint32(66).fork()).ldelim(); + } + if (message.options !== undefined) { + MessageOptions.encode(message.options, writer.uint32(58).fork()).ldelim(); + } + for (const v of message.reservedRange) { + DescriptorProto_ReservedRange.encode( + v!, + writer.uint32(74).fork() + ).ldelim(); + } + for (const v of message.reservedName) { + writer.uint32(82).string(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): DescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseDescriptorProto } as DescriptorProto; + message.field = []; + message.extension = []; + message.nestedType = []; + message.enumType = []; + message.extensionRange = []; + message.oneofDecl = []; + message.reservedRange = []; + message.reservedName = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.field.push( + FieldDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 6: + message.extension.push( + FieldDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 3: + message.nestedType.push( + DescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 4: + message.enumType.push( + EnumDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 5: + message.extensionRange.push( + DescriptorProto_ExtensionRange.decode(reader, reader.uint32()) + ); + break; + case 8: + message.oneofDecl.push( + OneofDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 7: + message.options = MessageOptions.decode(reader, reader.uint32()); + break; + case 9: + message.reservedRange.push( + DescriptorProto_ReservedRange.decode(reader, reader.uint32()) + ); + break; + case 10: + message.reservedName.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DescriptorProto { + const message = { ...baseDescriptorProto } as DescriptorProto; + message.field = []; + message.extension = []; + message.nestedType = []; + message.enumType = []; + message.extensionRange = []; + message.oneofDecl = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.field !== undefined && object.field !== null) { + for (const e of object.field) { + message.field.push(FieldDescriptorProto.fromJSON(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromJSON(e)); + } + } + if (object.nestedType !== undefined && object.nestedType !== null) { + for (const e of object.nestedType) { + message.nestedType.push(DescriptorProto.fromJSON(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromJSON(e)); + } + } + if (object.extensionRange !== undefined && object.extensionRange !== null) { + for (const e of object.extensionRange) { + message.extensionRange.push(DescriptorProto_ExtensionRange.fromJSON(e)); + } + } + if (object.oneofDecl !== undefined && object.oneofDecl !== null) { + for (const e of object.oneofDecl) { + message.oneofDecl.push(OneofDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = MessageOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push(DescriptorProto_ReservedRange.fromJSON(e)); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(String(e)); + } + } + return message; + }, + + toJSON(message: DescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + if (message.field) { + obj.field = message.field.map((e) => + e ? FieldDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.field = []; + } + if (message.extension) { + obj.extension = message.extension.map((e) => + e ? FieldDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.extension = []; + } + if (message.nestedType) { + obj.nestedType = message.nestedType.map((e) => + e ? DescriptorProto.toJSON(e) : undefined + ); + } else { + obj.nestedType = []; + } + if (message.enumType) { + obj.enumType = message.enumType.map((e) => + e ? EnumDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.enumType = []; + } + if (message.extensionRange) { + obj.extensionRange = message.extensionRange.map((e) => + e ? DescriptorProto_ExtensionRange.toJSON(e) : undefined + ); + } else { + obj.extensionRange = []; + } + if (message.oneofDecl) { + obj.oneofDecl = message.oneofDecl.map((e) => + e ? OneofDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.oneofDecl = []; + } + message.options !== undefined && + (obj.options = message.options + ? MessageOptions.toJSON(message.options) + : undefined); + if (message.reservedRange) { + obj.reservedRange = message.reservedRange.map((e) => + e ? DescriptorProto_ReservedRange.toJSON(e) : undefined + ); + } else { + obj.reservedRange = []; + } + if (message.reservedName) { + obj.reservedName = message.reservedName.map((e) => e); + } else { + obj.reservedName = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): DescriptorProto { + const message = { ...baseDescriptorProto } as DescriptorProto; + message.field = []; + message.extension = []; + message.nestedType = []; + message.enumType = []; + message.extensionRange = []; + message.oneofDecl = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.field !== undefined && object.field !== null) { + for (const e of object.field) { + message.field.push(FieldDescriptorProto.fromPartial(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromPartial(e)); + } + } + if (object.nestedType !== undefined && object.nestedType !== null) { + for (const e of object.nestedType) { + message.nestedType.push(DescriptorProto.fromPartial(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromPartial(e)); + } + } + if (object.extensionRange !== undefined && object.extensionRange !== null) { + for (const e of object.extensionRange) { + message.extensionRange.push( + DescriptorProto_ExtensionRange.fromPartial(e) + ); + } + } + if (object.oneofDecl !== undefined && object.oneofDecl !== null) { + for (const e of object.oneofDecl) { + message.oneofDecl.push(OneofDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = MessageOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push( + DescriptorProto_ReservedRange.fromPartial(e) + ); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(e); + } + } + return message; + }, +}; + +const baseDescriptorProto_ExtensionRange: object = { start: 0, end: 0 }; + +export const DescriptorProto_ExtensionRange = { + encode( + message: DescriptorProto_ExtensionRange, + writer: Writer = Writer.create() + ): Writer { + if (message.start !== 0) { + writer.uint32(8).int32(message.start); + } + if (message.end !== 0) { + writer.uint32(16).int32(message.end); + } + if (message.options !== undefined) { + ExtensionRangeOptions.encode( + message.options, + writer.uint32(26).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): DescriptorProto_ExtensionRange { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseDescriptorProto_ExtensionRange, + } as DescriptorProto_ExtensionRange; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.start = reader.int32(); + break; + case 2: + message.end = reader.int32(); + break; + case 3: + message.options = ExtensionRangeOptions.decode( + reader, + reader.uint32() + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DescriptorProto_ExtensionRange { + const message = { + ...baseDescriptorProto_ExtensionRange, + } as DescriptorProto_ExtensionRange; + if (object.start !== undefined && object.start !== null) { + message.start = Number(object.start); + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = ExtensionRangeOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: DescriptorProto_ExtensionRange): unknown { + const obj: any = {}; + message.start !== undefined && (obj.start = message.start); + message.end !== undefined && (obj.end = message.end); + message.options !== undefined && + (obj.options = message.options + ? ExtensionRangeOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): DescriptorProto_ExtensionRange { + const message = { + ...baseDescriptorProto_ExtensionRange, + } as DescriptorProto_ExtensionRange; + if (object.start !== undefined && object.start !== null) { + message.start = object.start; + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = ExtensionRangeOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseDescriptorProto_ReservedRange: object = { start: 0, end: 0 }; + +export const DescriptorProto_ReservedRange = { + encode( + message: DescriptorProto_ReservedRange, + writer: Writer = Writer.create() + ): Writer { + if (message.start !== 0) { + writer.uint32(8).int32(message.start); + } + if (message.end !== 0) { + writer.uint32(16).int32(message.end); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): DescriptorProto_ReservedRange { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseDescriptorProto_ReservedRange, + } as DescriptorProto_ReservedRange; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.start = reader.int32(); + break; + case 2: + message.end = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DescriptorProto_ReservedRange { + const message = { + ...baseDescriptorProto_ReservedRange, + } as DescriptorProto_ReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = Number(object.start); + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + return message; + }, + + toJSON(message: DescriptorProto_ReservedRange): unknown { + const obj: any = {}; + message.start !== undefined && (obj.start = message.start); + message.end !== undefined && (obj.end = message.end); + return obj; + }, + + fromPartial( + object: DeepPartial + ): DescriptorProto_ReservedRange { + const message = { + ...baseDescriptorProto_ReservedRange, + } as DescriptorProto_ReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = object.start; + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + return message; + }, +}; + +const baseExtensionRangeOptions: object = {}; + +export const ExtensionRangeOptions = { + encode( + message: ExtensionRangeOptions, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ExtensionRangeOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseExtensionRangeOptions } as ExtensionRangeOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ExtensionRangeOptions { + const message = { ...baseExtensionRangeOptions } as ExtensionRangeOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: ExtensionRangeOptions): unknown { + const obj: any = {}; + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial( + object: DeepPartial + ): ExtensionRangeOptions { + const message = { ...baseExtensionRangeOptions } as ExtensionRangeOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseFieldDescriptorProto: object = { + name: "", + number: 0, + label: 1, + type: 1, + typeName: "", + extendee: "", + defaultValue: "", + oneofIndex: 0, + jsonName: "", + proto3Optional: false, +}; + +export const FieldDescriptorProto = { + encode( + message: FieldDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.number !== 0) { + writer.uint32(24).int32(message.number); + } + if (message.label !== 1) { + writer.uint32(32).int32(message.label); + } + if (message.type !== 1) { + writer.uint32(40).int32(message.type); + } + if (message.typeName !== "") { + writer.uint32(50).string(message.typeName); + } + if (message.extendee !== "") { + writer.uint32(18).string(message.extendee); + } + if (message.defaultValue !== "") { + writer.uint32(58).string(message.defaultValue); + } + if (message.oneofIndex !== 0) { + writer.uint32(72).int32(message.oneofIndex); + } + if (message.jsonName !== "") { + writer.uint32(82).string(message.jsonName); + } + if (message.options !== undefined) { + FieldOptions.encode(message.options, writer.uint32(66).fork()).ldelim(); + } + if (message.proto3Optional === true) { + writer.uint32(136).bool(message.proto3Optional); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FieldDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFieldDescriptorProto } as FieldDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 3: + message.number = reader.int32(); + break; + case 4: + message.label = reader.int32() as any; + break; + case 5: + message.type = reader.int32() as any; + break; + case 6: + message.typeName = reader.string(); + break; + case 2: + message.extendee = reader.string(); + break; + case 7: + message.defaultValue = reader.string(); + break; + case 9: + message.oneofIndex = reader.int32(); + break; + case 10: + message.jsonName = reader.string(); + break; + case 8: + message.options = FieldOptions.decode(reader, reader.uint32()); + break; + case 17: + message.proto3Optional = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FieldDescriptorProto { + const message = { ...baseFieldDescriptorProto } as FieldDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = Number(object.number); + } else { + message.number = 0; + } + if (object.label !== undefined && object.label !== null) { + message.label = fieldDescriptorProto_LabelFromJSON(object.label); + } else { + message.label = 1; + } + if (object.type !== undefined && object.type !== null) { + message.type = fieldDescriptorProto_TypeFromJSON(object.type); + } else { + message.type = 1; + } + if (object.typeName !== undefined && object.typeName !== null) { + message.typeName = String(object.typeName); + } else { + message.typeName = ""; + } + if (object.extendee !== undefined && object.extendee !== null) { + message.extendee = String(object.extendee); + } else { + message.extendee = ""; + } + if (object.defaultValue !== undefined && object.defaultValue !== null) { + message.defaultValue = String(object.defaultValue); + } else { + message.defaultValue = ""; + } + if (object.oneofIndex !== undefined && object.oneofIndex !== null) { + message.oneofIndex = Number(object.oneofIndex); + } else { + message.oneofIndex = 0; + } + if (object.jsonName !== undefined && object.jsonName !== null) { + message.jsonName = String(object.jsonName); + } else { + message.jsonName = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = FieldOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.proto3Optional !== undefined && object.proto3Optional !== null) { + message.proto3Optional = Boolean(object.proto3Optional); + } else { + message.proto3Optional = false; + } + return message; + }, + + toJSON(message: FieldDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.number !== undefined && (obj.number = message.number); + message.label !== undefined && + (obj.label = fieldDescriptorProto_LabelToJSON(message.label)); + message.type !== undefined && + (obj.type = fieldDescriptorProto_TypeToJSON(message.type)); + message.typeName !== undefined && (obj.typeName = message.typeName); + message.extendee !== undefined && (obj.extendee = message.extendee); + message.defaultValue !== undefined && + (obj.defaultValue = message.defaultValue); + message.oneofIndex !== undefined && (obj.oneofIndex = message.oneofIndex); + message.jsonName !== undefined && (obj.jsonName = message.jsonName); + message.options !== undefined && + (obj.options = message.options + ? FieldOptions.toJSON(message.options) + : undefined); + message.proto3Optional !== undefined && + (obj.proto3Optional = message.proto3Optional); + return obj; + }, + + fromPartial(object: DeepPartial): FieldDescriptorProto { + const message = { ...baseFieldDescriptorProto } as FieldDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = object.number; + } else { + message.number = 0; + } + if (object.label !== undefined && object.label !== null) { + message.label = object.label; + } else { + message.label = 1; + } + if (object.type !== undefined && object.type !== null) { + message.type = object.type; + } else { + message.type = 1; + } + if (object.typeName !== undefined && object.typeName !== null) { + message.typeName = object.typeName; + } else { + message.typeName = ""; + } + if (object.extendee !== undefined && object.extendee !== null) { + message.extendee = object.extendee; + } else { + message.extendee = ""; + } + if (object.defaultValue !== undefined && object.defaultValue !== null) { + message.defaultValue = object.defaultValue; + } else { + message.defaultValue = ""; + } + if (object.oneofIndex !== undefined && object.oneofIndex !== null) { + message.oneofIndex = object.oneofIndex; + } else { + message.oneofIndex = 0; + } + if (object.jsonName !== undefined && object.jsonName !== null) { + message.jsonName = object.jsonName; + } else { + message.jsonName = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = FieldOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.proto3Optional !== undefined && object.proto3Optional !== null) { + message.proto3Optional = object.proto3Optional; + } else { + message.proto3Optional = false; + } + return message; + }, +}; + +const baseOneofDescriptorProto: object = { name: "" }; + +export const OneofDescriptorProto = { + encode( + message: OneofDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.options !== undefined) { + OneofOptions.encode(message.options, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): OneofDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseOneofDescriptorProto } as OneofDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.options = OneofOptions.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): OneofDescriptorProto { + const message = { ...baseOneofDescriptorProto } as OneofDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = OneofOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: OneofDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.options !== undefined && + (obj.options = message.options + ? OneofOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): OneofDescriptorProto { + const message = { ...baseOneofDescriptorProto } as OneofDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = OneofOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseEnumDescriptorProto: object = { name: "", reservedName: "" }; + +export const EnumDescriptorProto = { + encode( + message: EnumDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + for (const v of message.value) { + EnumValueDescriptorProto.encode(v!, writer.uint32(18).fork()).ldelim(); + } + if (message.options !== undefined) { + EnumOptions.encode(message.options, writer.uint32(26).fork()).ldelim(); + } + for (const v of message.reservedRange) { + EnumDescriptorProto_EnumReservedRange.encode( + v!, + writer.uint32(34).fork() + ).ldelim(); + } + for (const v of message.reservedName) { + writer.uint32(42).string(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): EnumDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseEnumDescriptorProto } as EnumDescriptorProto; + message.value = []; + message.reservedRange = []; + message.reservedName = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.value.push( + EnumValueDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 3: + message.options = EnumOptions.decode(reader, reader.uint32()); + break; + case 4: + message.reservedRange.push( + EnumDescriptorProto_EnumReservedRange.decode( + reader, + reader.uint32() + ) + ); + break; + case 5: + message.reservedName.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumDescriptorProto { + const message = { ...baseEnumDescriptorProto } as EnumDescriptorProto; + message.value = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.value !== undefined && object.value !== null) { + for (const e of object.value) { + message.value.push(EnumValueDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push( + EnumDescriptorProto_EnumReservedRange.fromJSON(e) + ); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(String(e)); + } + } + return message; + }, + + toJSON(message: EnumDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + if (message.value) { + obj.value = message.value.map((e) => + e ? EnumValueDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.value = []; + } + message.options !== undefined && + (obj.options = message.options + ? EnumOptions.toJSON(message.options) + : undefined); + if (message.reservedRange) { + obj.reservedRange = message.reservedRange.map((e) => + e ? EnumDescriptorProto_EnumReservedRange.toJSON(e) : undefined + ); + } else { + obj.reservedRange = []; + } + if (message.reservedName) { + obj.reservedName = message.reservedName.map((e) => e); + } else { + obj.reservedName = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): EnumDescriptorProto { + const message = { ...baseEnumDescriptorProto } as EnumDescriptorProto; + message.value = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.value !== undefined && object.value !== null) { + for (const e of object.value) { + message.value.push(EnumValueDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push( + EnumDescriptorProto_EnumReservedRange.fromPartial(e) + ); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(e); + } + } + return message; + }, +}; + +const baseEnumDescriptorProto_EnumReservedRange: object = { start: 0, end: 0 }; + +export const EnumDescriptorProto_EnumReservedRange = { + encode( + message: EnumDescriptorProto_EnumReservedRange, + writer: Writer = Writer.create() + ): Writer { + if (message.start !== 0) { + writer.uint32(8).int32(message.start); + } + if (message.end !== 0) { + writer.uint32(16).int32(message.end); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): EnumDescriptorProto_EnumReservedRange { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseEnumDescriptorProto_EnumReservedRange, + } as EnumDescriptorProto_EnumReservedRange; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.start = reader.int32(); + break; + case 2: + message.end = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumDescriptorProto_EnumReservedRange { + const message = { + ...baseEnumDescriptorProto_EnumReservedRange, + } as EnumDescriptorProto_EnumReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = Number(object.start); + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + return message; + }, + + toJSON(message: EnumDescriptorProto_EnumReservedRange): unknown { + const obj: any = {}; + message.start !== undefined && (obj.start = message.start); + message.end !== undefined && (obj.end = message.end); + return obj; + }, + + fromPartial( + object: DeepPartial + ): EnumDescriptorProto_EnumReservedRange { + const message = { + ...baseEnumDescriptorProto_EnumReservedRange, + } as EnumDescriptorProto_EnumReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = object.start; + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + return message; + }, +}; + +const baseEnumValueDescriptorProto: object = { name: "", number: 0 }; + +export const EnumValueDescriptorProto = { + encode( + message: EnumValueDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.number !== 0) { + writer.uint32(16).int32(message.number); + } + if (message.options !== undefined) { + EnumValueOptions.encode( + message.options, + writer.uint32(26).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): EnumValueDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseEnumValueDescriptorProto, + } as EnumValueDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.number = reader.int32(); + break; + case 3: + message.options = EnumValueOptions.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumValueDescriptorProto { + const message = { + ...baseEnumValueDescriptorProto, + } as EnumValueDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = Number(object.number); + } else { + message.number = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumValueOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: EnumValueDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.number !== undefined && (obj.number = message.number); + message.options !== undefined && + (obj.options = message.options + ? EnumValueOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): EnumValueDescriptorProto { + const message = { + ...baseEnumValueDescriptorProto, + } as EnumValueDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = object.number; + } else { + message.number = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumValueOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseServiceDescriptorProto: object = { name: "" }; + +export const ServiceDescriptorProto = { + encode( + message: ServiceDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + for (const v of message.method) { + MethodDescriptorProto.encode(v!, writer.uint32(18).fork()).ldelim(); + } + if (message.options !== undefined) { + ServiceOptions.encode(message.options, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ServiceDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseServiceDescriptorProto } as ServiceDescriptorProto; + message.method = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.method.push( + MethodDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 3: + message.options = ServiceOptions.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ServiceDescriptorProto { + const message = { ...baseServiceDescriptorProto } as ServiceDescriptorProto; + message.method = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.method !== undefined && object.method !== null) { + for (const e of object.method) { + message.method.push(MethodDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = ServiceOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: ServiceDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + if (message.method) { + obj.method = message.method.map((e) => + e ? MethodDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.method = []; + } + message.options !== undefined && + (obj.options = message.options + ? ServiceOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): ServiceDescriptorProto { + const message = { ...baseServiceDescriptorProto } as ServiceDescriptorProto; + message.method = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.method !== undefined && object.method !== null) { + for (const e of object.method) { + message.method.push(MethodDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = ServiceOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseMethodDescriptorProto: object = { + name: "", + inputType: "", + outputType: "", + clientStreaming: false, + serverStreaming: false, +}; + +export const MethodDescriptorProto = { + encode( + message: MethodDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.inputType !== "") { + writer.uint32(18).string(message.inputType); + } + if (message.outputType !== "") { + writer.uint32(26).string(message.outputType); + } + if (message.options !== undefined) { + MethodOptions.encode(message.options, writer.uint32(34).fork()).ldelim(); + } + if (message.clientStreaming === true) { + writer.uint32(40).bool(message.clientStreaming); + } + if (message.serverStreaming === true) { + writer.uint32(48).bool(message.serverStreaming); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MethodDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMethodDescriptorProto } as MethodDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.inputType = reader.string(); + break; + case 3: + message.outputType = reader.string(); + break; + case 4: + message.options = MethodOptions.decode(reader, reader.uint32()); + break; + case 5: + message.clientStreaming = reader.bool(); + break; + case 6: + message.serverStreaming = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MethodDescriptorProto { + const message = { ...baseMethodDescriptorProto } as MethodDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.inputType !== undefined && object.inputType !== null) { + message.inputType = String(object.inputType); + } else { + message.inputType = ""; + } + if (object.outputType !== undefined && object.outputType !== null) { + message.outputType = String(object.outputType); + } else { + message.outputType = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = MethodOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if ( + object.clientStreaming !== undefined && + object.clientStreaming !== null + ) { + message.clientStreaming = Boolean(object.clientStreaming); + } else { + message.clientStreaming = false; + } + if ( + object.serverStreaming !== undefined && + object.serverStreaming !== null + ) { + message.serverStreaming = Boolean(object.serverStreaming); + } else { + message.serverStreaming = false; + } + return message; + }, + + toJSON(message: MethodDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.inputType !== undefined && (obj.inputType = message.inputType); + message.outputType !== undefined && (obj.outputType = message.outputType); + message.options !== undefined && + (obj.options = message.options + ? MethodOptions.toJSON(message.options) + : undefined); + message.clientStreaming !== undefined && + (obj.clientStreaming = message.clientStreaming); + message.serverStreaming !== undefined && + (obj.serverStreaming = message.serverStreaming); + return obj; + }, + + fromPartial( + object: DeepPartial + ): MethodDescriptorProto { + const message = { ...baseMethodDescriptorProto } as MethodDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.inputType !== undefined && object.inputType !== null) { + message.inputType = object.inputType; + } else { + message.inputType = ""; + } + if (object.outputType !== undefined && object.outputType !== null) { + message.outputType = object.outputType; + } else { + message.outputType = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = MethodOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if ( + object.clientStreaming !== undefined && + object.clientStreaming !== null + ) { + message.clientStreaming = object.clientStreaming; + } else { + message.clientStreaming = false; + } + if ( + object.serverStreaming !== undefined && + object.serverStreaming !== null + ) { + message.serverStreaming = object.serverStreaming; + } else { + message.serverStreaming = false; + } + return message; + }, +}; + +const baseFileOptions: object = { + javaPackage: "", + javaOuterClassname: "", + javaMultipleFiles: false, + javaGenerateEqualsAndHash: false, + javaStringCheckUtf8: false, + optimizeFor: 1, + goPackage: "", + ccGenericServices: false, + javaGenericServices: false, + pyGenericServices: false, + phpGenericServices: false, + deprecated: false, + ccEnableArenas: false, + objcClassPrefix: "", + csharpNamespace: "", + swiftPrefix: "", + phpClassPrefix: "", + phpNamespace: "", + phpMetadataNamespace: "", + rubyPackage: "", +}; + +export const FileOptions = { + encode(message: FileOptions, writer: Writer = Writer.create()): Writer { + if (message.javaPackage !== "") { + writer.uint32(10).string(message.javaPackage); + } + if (message.javaOuterClassname !== "") { + writer.uint32(66).string(message.javaOuterClassname); + } + if (message.javaMultipleFiles === true) { + writer.uint32(80).bool(message.javaMultipleFiles); + } + if (message.javaGenerateEqualsAndHash === true) { + writer.uint32(160).bool(message.javaGenerateEqualsAndHash); + } + if (message.javaStringCheckUtf8 === true) { + writer.uint32(216).bool(message.javaStringCheckUtf8); + } + if (message.optimizeFor !== 1) { + writer.uint32(72).int32(message.optimizeFor); + } + if (message.goPackage !== "") { + writer.uint32(90).string(message.goPackage); + } + if (message.ccGenericServices === true) { + writer.uint32(128).bool(message.ccGenericServices); + } + if (message.javaGenericServices === true) { + writer.uint32(136).bool(message.javaGenericServices); + } + if (message.pyGenericServices === true) { + writer.uint32(144).bool(message.pyGenericServices); + } + if (message.phpGenericServices === true) { + writer.uint32(336).bool(message.phpGenericServices); + } + if (message.deprecated === true) { + writer.uint32(184).bool(message.deprecated); + } + if (message.ccEnableArenas === true) { + writer.uint32(248).bool(message.ccEnableArenas); + } + if (message.objcClassPrefix !== "") { + writer.uint32(290).string(message.objcClassPrefix); + } + if (message.csharpNamespace !== "") { + writer.uint32(298).string(message.csharpNamespace); + } + if (message.swiftPrefix !== "") { + writer.uint32(314).string(message.swiftPrefix); + } + if (message.phpClassPrefix !== "") { + writer.uint32(322).string(message.phpClassPrefix); + } + if (message.phpNamespace !== "") { + writer.uint32(330).string(message.phpNamespace); + } + if (message.phpMetadataNamespace !== "") { + writer.uint32(354).string(message.phpMetadataNamespace); + } + if (message.rubyPackage !== "") { + writer.uint32(362).string(message.rubyPackage); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FileOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFileOptions } as FileOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.javaPackage = reader.string(); + break; + case 8: + message.javaOuterClassname = reader.string(); + break; + case 10: + message.javaMultipleFiles = reader.bool(); + break; + case 20: + message.javaGenerateEqualsAndHash = reader.bool(); + break; + case 27: + message.javaStringCheckUtf8 = reader.bool(); + break; + case 9: + message.optimizeFor = reader.int32() as any; + break; + case 11: + message.goPackage = reader.string(); + break; + case 16: + message.ccGenericServices = reader.bool(); + break; + case 17: + message.javaGenericServices = reader.bool(); + break; + case 18: + message.pyGenericServices = reader.bool(); + break; + case 42: + message.phpGenericServices = reader.bool(); + break; + case 23: + message.deprecated = reader.bool(); + break; + case 31: + message.ccEnableArenas = reader.bool(); + break; + case 36: + message.objcClassPrefix = reader.string(); + break; + case 37: + message.csharpNamespace = reader.string(); + break; + case 39: + message.swiftPrefix = reader.string(); + break; + case 40: + message.phpClassPrefix = reader.string(); + break; + case 41: + message.phpNamespace = reader.string(); + break; + case 44: + message.phpMetadataNamespace = reader.string(); + break; + case 45: + message.rubyPackage = reader.string(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FileOptions { + const message = { ...baseFileOptions } as FileOptions; + message.uninterpretedOption = []; + if (object.javaPackage !== undefined && object.javaPackage !== null) { + message.javaPackage = String(object.javaPackage); + } else { + message.javaPackage = ""; + } + if ( + object.javaOuterClassname !== undefined && + object.javaOuterClassname !== null + ) { + message.javaOuterClassname = String(object.javaOuterClassname); + } else { + message.javaOuterClassname = ""; + } + if ( + object.javaMultipleFiles !== undefined && + object.javaMultipleFiles !== null + ) { + message.javaMultipleFiles = Boolean(object.javaMultipleFiles); + } else { + message.javaMultipleFiles = false; + } + if ( + object.javaGenerateEqualsAndHash !== undefined && + object.javaGenerateEqualsAndHash !== null + ) { + message.javaGenerateEqualsAndHash = Boolean( + object.javaGenerateEqualsAndHash + ); + } else { + message.javaGenerateEqualsAndHash = false; + } + if ( + object.javaStringCheckUtf8 !== undefined && + object.javaStringCheckUtf8 !== null + ) { + message.javaStringCheckUtf8 = Boolean(object.javaStringCheckUtf8); + } else { + message.javaStringCheckUtf8 = false; + } + if (object.optimizeFor !== undefined && object.optimizeFor !== null) { + message.optimizeFor = fileOptions_OptimizeModeFromJSON( + object.optimizeFor + ); + } else { + message.optimizeFor = 1; + } + if (object.goPackage !== undefined && object.goPackage !== null) { + message.goPackage = String(object.goPackage); + } else { + message.goPackage = ""; + } + if ( + object.ccGenericServices !== undefined && + object.ccGenericServices !== null + ) { + message.ccGenericServices = Boolean(object.ccGenericServices); + } else { + message.ccGenericServices = false; + } + if ( + object.javaGenericServices !== undefined && + object.javaGenericServices !== null + ) { + message.javaGenericServices = Boolean(object.javaGenericServices); + } else { + message.javaGenericServices = false; + } + if ( + object.pyGenericServices !== undefined && + object.pyGenericServices !== null + ) { + message.pyGenericServices = Boolean(object.pyGenericServices); + } else { + message.pyGenericServices = false; + } + if ( + object.phpGenericServices !== undefined && + object.phpGenericServices !== null + ) { + message.phpGenericServices = Boolean(object.phpGenericServices); + } else { + message.phpGenericServices = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if (object.ccEnableArenas !== undefined && object.ccEnableArenas !== null) { + message.ccEnableArenas = Boolean(object.ccEnableArenas); + } else { + message.ccEnableArenas = false; + } + if ( + object.objcClassPrefix !== undefined && + object.objcClassPrefix !== null + ) { + message.objcClassPrefix = String(object.objcClassPrefix); + } else { + message.objcClassPrefix = ""; + } + if ( + object.csharpNamespace !== undefined && + object.csharpNamespace !== null + ) { + message.csharpNamespace = String(object.csharpNamespace); + } else { + message.csharpNamespace = ""; + } + if (object.swiftPrefix !== undefined && object.swiftPrefix !== null) { + message.swiftPrefix = String(object.swiftPrefix); + } else { + message.swiftPrefix = ""; + } + if (object.phpClassPrefix !== undefined && object.phpClassPrefix !== null) { + message.phpClassPrefix = String(object.phpClassPrefix); + } else { + message.phpClassPrefix = ""; + } + if (object.phpNamespace !== undefined && object.phpNamespace !== null) { + message.phpNamespace = String(object.phpNamespace); + } else { + message.phpNamespace = ""; + } + if ( + object.phpMetadataNamespace !== undefined && + object.phpMetadataNamespace !== null + ) { + message.phpMetadataNamespace = String(object.phpMetadataNamespace); + } else { + message.phpMetadataNamespace = ""; + } + if (object.rubyPackage !== undefined && object.rubyPackage !== null) { + message.rubyPackage = String(object.rubyPackage); + } else { + message.rubyPackage = ""; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: FileOptions): unknown { + const obj: any = {}; + message.javaPackage !== undefined && + (obj.javaPackage = message.javaPackage); + message.javaOuterClassname !== undefined && + (obj.javaOuterClassname = message.javaOuterClassname); + message.javaMultipleFiles !== undefined && + (obj.javaMultipleFiles = message.javaMultipleFiles); + message.javaGenerateEqualsAndHash !== undefined && + (obj.javaGenerateEqualsAndHash = message.javaGenerateEqualsAndHash); + message.javaStringCheckUtf8 !== undefined && + (obj.javaStringCheckUtf8 = message.javaStringCheckUtf8); + message.optimizeFor !== undefined && + (obj.optimizeFor = fileOptions_OptimizeModeToJSON(message.optimizeFor)); + message.goPackage !== undefined && (obj.goPackage = message.goPackage); + message.ccGenericServices !== undefined && + (obj.ccGenericServices = message.ccGenericServices); + message.javaGenericServices !== undefined && + (obj.javaGenericServices = message.javaGenericServices); + message.pyGenericServices !== undefined && + (obj.pyGenericServices = message.pyGenericServices); + message.phpGenericServices !== undefined && + (obj.phpGenericServices = message.phpGenericServices); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.ccEnableArenas !== undefined && + (obj.ccEnableArenas = message.ccEnableArenas); + message.objcClassPrefix !== undefined && + (obj.objcClassPrefix = message.objcClassPrefix); + message.csharpNamespace !== undefined && + (obj.csharpNamespace = message.csharpNamespace); + message.swiftPrefix !== undefined && + (obj.swiftPrefix = message.swiftPrefix); + message.phpClassPrefix !== undefined && + (obj.phpClassPrefix = message.phpClassPrefix); + message.phpNamespace !== undefined && + (obj.phpNamespace = message.phpNamespace); + message.phpMetadataNamespace !== undefined && + (obj.phpMetadataNamespace = message.phpMetadataNamespace); + message.rubyPackage !== undefined && + (obj.rubyPackage = message.rubyPackage); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): FileOptions { + const message = { ...baseFileOptions } as FileOptions; + message.uninterpretedOption = []; + if (object.javaPackage !== undefined && object.javaPackage !== null) { + message.javaPackage = object.javaPackage; + } else { + message.javaPackage = ""; + } + if ( + object.javaOuterClassname !== undefined && + object.javaOuterClassname !== null + ) { + message.javaOuterClassname = object.javaOuterClassname; + } else { + message.javaOuterClassname = ""; + } + if ( + object.javaMultipleFiles !== undefined && + object.javaMultipleFiles !== null + ) { + message.javaMultipleFiles = object.javaMultipleFiles; + } else { + message.javaMultipleFiles = false; + } + if ( + object.javaGenerateEqualsAndHash !== undefined && + object.javaGenerateEqualsAndHash !== null + ) { + message.javaGenerateEqualsAndHash = object.javaGenerateEqualsAndHash; + } else { + message.javaGenerateEqualsAndHash = false; + } + if ( + object.javaStringCheckUtf8 !== undefined && + object.javaStringCheckUtf8 !== null + ) { + message.javaStringCheckUtf8 = object.javaStringCheckUtf8; + } else { + message.javaStringCheckUtf8 = false; + } + if (object.optimizeFor !== undefined && object.optimizeFor !== null) { + message.optimizeFor = object.optimizeFor; + } else { + message.optimizeFor = 1; + } + if (object.goPackage !== undefined && object.goPackage !== null) { + message.goPackage = object.goPackage; + } else { + message.goPackage = ""; + } + if ( + object.ccGenericServices !== undefined && + object.ccGenericServices !== null + ) { + message.ccGenericServices = object.ccGenericServices; + } else { + message.ccGenericServices = false; + } + if ( + object.javaGenericServices !== undefined && + object.javaGenericServices !== null + ) { + message.javaGenericServices = object.javaGenericServices; + } else { + message.javaGenericServices = false; + } + if ( + object.pyGenericServices !== undefined && + object.pyGenericServices !== null + ) { + message.pyGenericServices = object.pyGenericServices; + } else { + message.pyGenericServices = false; + } + if ( + object.phpGenericServices !== undefined && + object.phpGenericServices !== null + ) { + message.phpGenericServices = object.phpGenericServices; + } else { + message.phpGenericServices = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if (object.ccEnableArenas !== undefined && object.ccEnableArenas !== null) { + message.ccEnableArenas = object.ccEnableArenas; + } else { + message.ccEnableArenas = false; + } + if ( + object.objcClassPrefix !== undefined && + object.objcClassPrefix !== null + ) { + message.objcClassPrefix = object.objcClassPrefix; + } else { + message.objcClassPrefix = ""; + } + if ( + object.csharpNamespace !== undefined && + object.csharpNamespace !== null + ) { + message.csharpNamespace = object.csharpNamespace; + } else { + message.csharpNamespace = ""; + } + if (object.swiftPrefix !== undefined && object.swiftPrefix !== null) { + message.swiftPrefix = object.swiftPrefix; + } else { + message.swiftPrefix = ""; + } + if (object.phpClassPrefix !== undefined && object.phpClassPrefix !== null) { + message.phpClassPrefix = object.phpClassPrefix; + } else { + message.phpClassPrefix = ""; + } + if (object.phpNamespace !== undefined && object.phpNamespace !== null) { + message.phpNamespace = object.phpNamespace; + } else { + message.phpNamespace = ""; + } + if ( + object.phpMetadataNamespace !== undefined && + object.phpMetadataNamespace !== null + ) { + message.phpMetadataNamespace = object.phpMetadataNamespace; + } else { + message.phpMetadataNamespace = ""; + } + if (object.rubyPackage !== undefined && object.rubyPackage !== null) { + message.rubyPackage = object.rubyPackage; + } else { + message.rubyPackage = ""; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseMessageOptions: object = { + messageSetWireFormat: false, + noStandardDescriptorAccessor: false, + deprecated: false, + mapEntry: false, +}; + +export const MessageOptions = { + encode(message: MessageOptions, writer: Writer = Writer.create()): Writer { + if (message.messageSetWireFormat === true) { + writer.uint32(8).bool(message.messageSetWireFormat); + } + if (message.noStandardDescriptorAccessor === true) { + writer.uint32(16).bool(message.noStandardDescriptorAccessor); + } + if (message.deprecated === true) { + writer.uint32(24).bool(message.deprecated); + } + if (message.mapEntry === true) { + writer.uint32(56).bool(message.mapEntry); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MessageOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMessageOptions } as MessageOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.messageSetWireFormat = reader.bool(); + break; + case 2: + message.noStandardDescriptorAccessor = reader.bool(); + break; + case 3: + message.deprecated = reader.bool(); + break; + case 7: + message.mapEntry = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MessageOptions { + const message = { ...baseMessageOptions } as MessageOptions; + message.uninterpretedOption = []; + if ( + object.messageSetWireFormat !== undefined && + object.messageSetWireFormat !== null + ) { + message.messageSetWireFormat = Boolean(object.messageSetWireFormat); + } else { + message.messageSetWireFormat = false; + } + if ( + object.noStandardDescriptorAccessor !== undefined && + object.noStandardDescriptorAccessor !== null + ) { + message.noStandardDescriptorAccessor = Boolean( + object.noStandardDescriptorAccessor + ); + } else { + message.noStandardDescriptorAccessor = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if (object.mapEntry !== undefined && object.mapEntry !== null) { + message.mapEntry = Boolean(object.mapEntry); + } else { + message.mapEntry = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: MessageOptions): unknown { + const obj: any = {}; + message.messageSetWireFormat !== undefined && + (obj.messageSetWireFormat = message.messageSetWireFormat); + message.noStandardDescriptorAccessor !== undefined && + (obj.noStandardDescriptorAccessor = message.noStandardDescriptorAccessor); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.mapEntry !== undefined && (obj.mapEntry = message.mapEntry); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): MessageOptions { + const message = { ...baseMessageOptions } as MessageOptions; + message.uninterpretedOption = []; + if ( + object.messageSetWireFormat !== undefined && + object.messageSetWireFormat !== null + ) { + message.messageSetWireFormat = object.messageSetWireFormat; + } else { + message.messageSetWireFormat = false; + } + if ( + object.noStandardDescriptorAccessor !== undefined && + object.noStandardDescriptorAccessor !== null + ) { + message.noStandardDescriptorAccessor = + object.noStandardDescriptorAccessor; + } else { + message.noStandardDescriptorAccessor = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if (object.mapEntry !== undefined && object.mapEntry !== null) { + message.mapEntry = object.mapEntry; + } else { + message.mapEntry = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseFieldOptions: object = { + ctype: 0, + packed: false, + jstype: 0, + lazy: false, + deprecated: false, + weak: false, +}; + +export const FieldOptions = { + encode(message: FieldOptions, writer: Writer = Writer.create()): Writer { + if (message.ctype !== 0) { + writer.uint32(8).int32(message.ctype); + } + if (message.packed === true) { + writer.uint32(16).bool(message.packed); + } + if (message.jstype !== 0) { + writer.uint32(48).int32(message.jstype); + } + if (message.lazy === true) { + writer.uint32(40).bool(message.lazy); + } + if (message.deprecated === true) { + writer.uint32(24).bool(message.deprecated); + } + if (message.weak === true) { + writer.uint32(80).bool(message.weak); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FieldOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFieldOptions } as FieldOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.ctype = reader.int32() as any; + break; + case 2: + message.packed = reader.bool(); + break; + case 6: + message.jstype = reader.int32() as any; + break; + case 5: + message.lazy = reader.bool(); + break; + case 3: + message.deprecated = reader.bool(); + break; + case 10: + message.weak = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FieldOptions { + const message = { ...baseFieldOptions } as FieldOptions; + message.uninterpretedOption = []; + if (object.ctype !== undefined && object.ctype !== null) { + message.ctype = fieldOptions_CTypeFromJSON(object.ctype); + } else { + message.ctype = 0; + } + if (object.packed !== undefined && object.packed !== null) { + message.packed = Boolean(object.packed); + } else { + message.packed = false; + } + if (object.jstype !== undefined && object.jstype !== null) { + message.jstype = fieldOptions_JSTypeFromJSON(object.jstype); + } else { + message.jstype = 0; + } + if (object.lazy !== undefined && object.lazy !== null) { + message.lazy = Boolean(object.lazy); + } else { + message.lazy = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if (object.weak !== undefined && object.weak !== null) { + message.weak = Boolean(object.weak); + } else { + message.weak = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: FieldOptions): unknown { + const obj: any = {}; + message.ctype !== undefined && + (obj.ctype = fieldOptions_CTypeToJSON(message.ctype)); + message.packed !== undefined && (obj.packed = message.packed); + message.jstype !== undefined && + (obj.jstype = fieldOptions_JSTypeToJSON(message.jstype)); + message.lazy !== undefined && (obj.lazy = message.lazy); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.weak !== undefined && (obj.weak = message.weak); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): FieldOptions { + const message = { ...baseFieldOptions } as FieldOptions; + message.uninterpretedOption = []; + if (object.ctype !== undefined && object.ctype !== null) { + message.ctype = object.ctype; + } else { + message.ctype = 0; + } + if (object.packed !== undefined && object.packed !== null) { + message.packed = object.packed; + } else { + message.packed = false; + } + if (object.jstype !== undefined && object.jstype !== null) { + message.jstype = object.jstype; + } else { + message.jstype = 0; + } + if (object.lazy !== undefined && object.lazy !== null) { + message.lazy = object.lazy; + } else { + message.lazy = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if (object.weak !== undefined && object.weak !== null) { + message.weak = object.weak; + } else { + message.weak = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseOneofOptions: object = {}; + +export const OneofOptions = { + encode(message: OneofOptions, writer: Writer = Writer.create()): Writer { + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): OneofOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseOneofOptions } as OneofOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): OneofOptions { + const message = { ...baseOneofOptions } as OneofOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: OneofOptions): unknown { + const obj: any = {}; + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): OneofOptions { + const message = { ...baseOneofOptions } as OneofOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseEnumOptions: object = { allowAlias: false, deprecated: false }; + +export const EnumOptions = { + encode(message: EnumOptions, writer: Writer = Writer.create()): Writer { + if (message.allowAlias === true) { + writer.uint32(16).bool(message.allowAlias); + } + if (message.deprecated === true) { + writer.uint32(24).bool(message.deprecated); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): EnumOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseEnumOptions } as EnumOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + message.allowAlias = reader.bool(); + break; + case 3: + message.deprecated = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumOptions { + const message = { ...baseEnumOptions } as EnumOptions; + message.uninterpretedOption = []; + if (object.allowAlias !== undefined && object.allowAlias !== null) { + message.allowAlias = Boolean(object.allowAlias); + } else { + message.allowAlias = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: EnumOptions): unknown { + const obj: any = {}; + message.allowAlias !== undefined && (obj.allowAlias = message.allowAlias); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): EnumOptions { + const message = { ...baseEnumOptions } as EnumOptions; + message.uninterpretedOption = []; + if (object.allowAlias !== undefined && object.allowAlias !== null) { + message.allowAlias = object.allowAlias; + } else { + message.allowAlias = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseEnumValueOptions: object = { deprecated: false }; + +export const EnumValueOptions = { + encode(message: EnumValueOptions, writer: Writer = Writer.create()): Writer { + if (message.deprecated === true) { + writer.uint32(8).bool(message.deprecated); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): EnumValueOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseEnumValueOptions } as EnumValueOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.deprecated = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumValueOptions { + const message = { ...baseEnumValueOptions } as EnumValueOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: EnumValueOptions): unknown { + const obj: any = {}; + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): EnumValueOptions { + const message = { ...baseEnumValueOptions } as EnumValueOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseServiceOptions: object = { deprecated: false }; + +export const ServiceOptions = { + encode(message: ServiceOptions, writer: Writer = Writer.create()): Writer { + if (message.deprecated === true) { + writer.uint32(264).bool(message.deprecated); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ServiceOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseServiceOptions } as ServiceOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 33: + message.deprecated = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ServiceOptions { + const message = { ...baseServiceOptions } as ServiceOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: ServiceOptions): unknown { + const obj: any = {}; + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): ServiceOptions { + const message = { ...baseServiceOptions } as ServiceOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseMethodOptions: object = { deprecated: false, idempotencyLevel: 0 }; + +export const MethodOptions = { + encode(message: MethodOptions, writer: Writer = Writer.create()): Writer { + if (message.deprecated === true) { + writer.uint32(264).bool(message.deprecated); + } + if (message.idempotencyLevel !== 0) { + writer.uint32(272).int32(message.idempotencyLevel); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MethodOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMethodOptions } as MethodOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 33: + message.deprecated = reader.bool(); + break; + case 34: + message.idempotencyLevel = reader.int32() as any; + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MethodOptions { + const message = { ...baseMethodOptions } as MethodOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.idempotencyLevel !== undefined && + object.idempotencyLevel !== null + ) { + message.idempotencyLevel = methodOptions_IdempotencyLevelFromJSON( + object.idempotencyLevel + ); + } else { + message.idempotencyLevel = 0; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: MethodOptions): unknown { + const obj: any = {}; + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.idempotencyLevel !== undefined && + (obj.idempotencyLevel = methodOptions_IdempotencyLevelToJSON( + message.idempotencyLevel + )); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): MethodOptions { + const message = { ...baseMethodOptions } as MethodOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.idempotencyLevel !== undefined && + object.idempotencyLevel !== null + ) { + message.idempotencyLevel = object.idempotencyLevel; + } else { + message.idempotencyLevel = 0; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseUninterpretedOption: object = { + identifierValue: "", + positiveIntValue: 0, + negativeIntValue: 0, + doubleValue: 0, + aggregateValue: "", +}; + +export const UninterpretedOption = { + encode( + message: UninterpretedOption, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.name) { + UninterpretedOption_NamePart.encode( + v!, + writer.uint32(18).fork() + ).ldelim(); + } + if (message.identifierValue !== "") { + writer.uint32(26).string(message.identifierValue); + } + if (message.positiveIntValue !== 0) { + writer.uint32(32).uint64(message.positiveIntValue); + } + if (message.negativeIntValue !== 0) { + writer.uint32(40).int64(message.negativeIntValue); + } + if (message.doubleValue !== 0) { + writer.uint32(49).double(message.doubleValue); + } + if (message.stringValue.length !== 0) { + writer.uint32(58).bytes(message.stringValue); + } + if (message.aggregateValue !== "") { + writer.uint32(66).string(message.aggregateValue); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): UninterpretedOption { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseUninterpretedOption } as UninterpretedOption; + message.name = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + message.name.push( + UninterpretedOption_NamePart.decode(reader, reader.uint32()) + ); + break; + case 3: + message.identifierValue = reader.string(); + break; + case 4: + message.positiveIntValue = longToNumber(reader.uint64() as Long); + break; + case 5: + message.negativeIntValue = longToNumber(reader.int64() as Long); + break; + case 6: + message.doubleValue = reader.double(); + break; + case 7: + message.stringValue = reader.bytes(); + break; + case 8: + message.aggregateValue = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): UninterpretedOption { + const message = { ...baseUninterpretedOption } as UninterpretedOption; + message.name = []; + if (object.name !== undefined && object.name !== null) { + for (const e of object.name) { + message.name.push(UninterpretedOption_NamePart.fromJSON(e)); + } + } + if ( + object.identifierValue !== undefined && + object.identifierValue !== null + ) { + message.identifierValue = String(object.identifierValue); + } else { + message.identifierValue = ""; + } + if ( + object.positiveIntValue !== undefined && + object.positiveIntValue !== null + ) { + message.positiveIntValue = Number(object.positiveIntValue); + } else { + message.positiveIntValue = 0; + } + if ( + object.negativeIntValue !== undefined && + object.negativeIntValue !== null + ) { + message.negativeIntValue = Number(object.negativeIntValue); + } else { + message.negativeIntValue = 0; + } + if (object.doubleValue !== undefined && object.doubleValue !== null) { + message.doubleValue = Number(object.doubleValue); + } else { + message.doubleValue = 0; + } + if (object.stringValue !== undefined && object.stringValue !== null) { + message.stringValue = bytesFromBase64(object.stringValue); + } + if (object.aggregateValue !== undefined && object.aggregateValue !== null) { + message.aggregateValue = String(object.aggregateValue); + } else { + message.aggregateValue = ""; + } + return message; + }, + + toJSON(message: UninterpretedOption): unknown { + const obj: any = {}; + if (message.name) { + obj.name = message.name.map((e) => + e ? UninterpretedOption_NamePart.toJSON(e) : undefined + ); + } else { + obj.name = []; + } + message.identifierValue !== undefined && + (obj.identifierValue = message.identifierValue); + message.positiveIntValue !== undefined && + (obj.positiveIntValue = message.positiveIntValue); + message.negativeIntValue !== undefined && + (obj.negativeIntValue = message.negativeIntValue); + message.doubleValue !== undefined && + (obj.doubleValue = message.doubleValue); + message.stringValue !== undefined && + (obj.stringValue = base64FromBytes( + message.stringValue !== undefined + ? message.stringValue + : new Uint8Array() + )); + message.aggregateValue !== undefined && + (obj.aggregateValue = message.aggregateValue); + return obj; + }, + + fromPartial(object: DeepPartial): UninterpretedOption { + const message = { ...baseUninterpretedOption } as UninterpretedOption; + message.name = []; + if (object.name !== undefined && object.name !== null) { + for (const e of object.name) { + message.name.push(UninterpretedOption_NamePart.fromPartial(e)); + } + } + if ( + object.identifierValue !== undefined && + object.identifierValue !== null + ) { + message.identifierValue = object.identifierValue; + } else { + message.identifierValue = ""; + } + if ( + object.positiveIntValue !== undefined && + object.positiveIntValue !== null + ) { + message.positiveIntValue = object.positiveIntValue; + } else { + message.positiveIntValue = 0; + } + if ( + object.negativeIntValue !== undefined && + object.negativeIntValue !== null + ) { + message.negativeIntValue = object.negativeIntValue; + } else { + message.negativeIntValue = 0; + } + if (object.doubleValue !== undefined && object.doubleValue !== null) { + message.doubleValue = object.doubleValue; + } else { + message.doubleValue = 0; + } + if (object.stringValue !== undefined && object.stringValue !== null) { + message.stringValue = object.stringValue; + } else { + message.stringValue = new Uint8Array(); + } + if (object.aggregateValue !== undefined && object.aggregateValue !== null) { + message.aggregateValue = object.aggregateValue; + } else { + message.aggregateValue = ""; + } + return message; + }, +}; + +const baseUninterpretedOption_NamePart: object = { + namePart: "", + isExtension: false, +}; + +export const UninterpretedOption_NamePart = { + encode( + message: UninterpretedOption_NamePart, + writer: Writer = Writer.create() + ): Writer { + if (message.namePart !== "") { + writer.uint32(10).string(message.namePart); + } + if (message.isExtension === true) { + writer.uint32(16).bool(message.isExtension); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): UninterpretedOption_NamePart { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseUninterpretedOption_NamePart, + } as UninterpretedOption_NamePart; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.namePart = reader.string(); + break; + case 2: + message.isExtension = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): UninterpretedOption_NamePart { + const message = { + ...baseUninterpretedOption_NamePart, + } as UninterpretedOption_NamePart; + if (object.namePart !== undefined && object.namePart !== null) { + message.namePart = String(object.namePart); + } else { + message.namePart = ""; + } + if (object.isExtension !== undefined && object.isExtension !== null) { + message.isExtension = Boolean(object.isExtension); + } else { + message.isExtension = false; + } + return message; + }, + + toJSON(message: UninterpretedOption_NamePart): unknown { + const obj: any = {}; + message.namePart !== undefined && (obj.namePart = message.namePart); + message.isExtension !== undefined && + (obj.isExtension = message.isExtension); + return obj; + }, + + fromPartial( + object: DeepPartial + ): UninterpretedOption_NamePart { + const message = { + ...baseUninterpretedOption_NamePart, + } as UninterpretedOption_NamePart; + if (object.namePart !== undefined && object.namePart !== null) { + message.namePart = object.namePart; + } else { + message.namePart = ""; + } + if (object.isExtension !== undefined && object.isExtension !== null) { + message.isExtension = object.isExtension; + } else { + message.isExtension = false; + } + return message; + }, +}; + +const baseSourceCodeInfo: object = {}; + +export const SourceCodeInfo = { + encode(message: SourceCodeInfo, writer: Writer = Writer.create()): Writer { + for (const v of message.location) { + SourceCodeInfo_Location.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): SourceCodeInfo { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseSourceCodeInfo } as SourceCodeInfo; + message.location = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.location.push( + SourceCodeInfo_Location.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): SourceCodeInfo { + const message = { ...baseSourceCodeInfo } as SourceCodeInfo; + message.location = []; + if (object.location !== undefined && object.location !== null) { + for (const e of object.location) { + message.location.push(SourceCodeInfo_Location.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: SourceCodeInfo): unknown { + const obj: any = {}; + if (message.location) { + obj.location = message.location.map((e) => + e ? SourceCodeInfo_Location.toJSON(e) : undefined + ); + } else { + obj.location = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): SourceCodeInfo { + const message = { ...baseSourceCodeInfo } as SourceCodeInfo; + message.location = []; + if (object.location !== undefined && object.location !== null) { + for (const e of object.location) { + message.location.push(SourceCodeInfo_Location.fromPartial(e)); + } + } + return message; + }, +}; + +const baseSourceCodeInfo_Location: object = { + path: 0, + span: 0, + leadingComments: "", + trailingComments: "", + leadingDetachedComments: "", +}; + +export const SourceCodeInfo_Location = { + encode( + message: SourceCodeInfo_Location, + writer: Writer = Writer.create() + ): Writer { + writer.uint32(10).fork(); + for (const v of message.path) { + writer.int32(v); + } + writer.ldelim(); + writer.uint32(18).fork(); + for (const v of message.span) { + writer.int32(v); + } + writer.ldelim(); + if (message.leadingComments !== "") { + writer.uint32(26).string(message.leadingComments); + } + if (message.trailingComments !== "") { + writer.uint32(34).string(message.trailingComments); + } + for (const v of message.leadingDetachedComments) { + writer.uint32(50).string(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): SourceCodeInfo_Location { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseSourceCodeInfo_Location, + } as SourceCodeInfo_Location; + message.path = []; + message.span = []; + message.leadingDetachedComments = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.path.push(reader.int32()); + } + } else { + message.path.push(reader.int32()); + } + break; + case 2: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.span.push(reader.int32()); + } + } else { + message.span.push(reader.int32()); + } + break; + case 3: + message.leadingComments = reader.string(); + break; + case 4: + message.trailingComments = reader.string(); + break; + case 6: + message.leadingDetachedComments.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): SourceCodeInfo_Location { + const message = { + ...baseSourceCodeInfo_Location, + } as SourceCodeInfo_Location; + message.path = []; + message.span = []; + message.leadingDetachedComments = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(Number(e)); + } + } + if (object.span !== undefined && object.span !== null) { + for (const e of object.span) { + message.span.push(Number(e)); + } + } + if ( + object.leadingComments !== undefined && + object.leadingComments !== null + ) { + message.leadingComments = String(object.leadingComments); + } else { + message.leadingComments = ""; + } + if ( + object.trailingComments !== undefined && + object.trailingComments !== null + ) { + message.trailingComments = String(object.trailingComments); + } else { + message.trailingComments = ""; + } + if ( + object.leadingDetachedComments !== undefined && + object.leadingDetachedComments !== null + ) { + for (const e of object.leadingDetachedComments) { + message.leadingDetachedComments.push(String(e)); + } + } + return message; + }, + + toJSON(message: SourceCodeInfo_Location): unknown { + const obj: any = {}; + if (message.path) { + obj.path = message.path.map((e) => e); + } else { + obj.path = []; + } + if (message.span) { + obj.span = message.span.map((e) => e); + } else { + obj.span = []; + } + message.leadingComments !== undefined && + (obj.leadingComments = message.leadingComments); + message.trailingComments !== undefined && + (obj.trailingComments = message.trailingComments); + if (message.leadingDetachedComments) { + obj.leadingDetachedComments = message.leadingDetachedComments.map( + (e) => e + ); + } else { + obj.leadingDetachedComments = []; + } + return obj; + }, + + fromPartial( + object: DeepPartial + ): SourceCodeInfo_Location { + const message = { + ...baseSourceCodeInfo_Location, + } as SourceCodeInfo_Location; + message.path = []; + message.span = []; + message.leadingDetachedComments = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(e); + } + } + if (object.span !== undefined && object.span !== null) { + for (const e of object.span) { + message.span.push(e); + } + } + if ( + object.leadingComments !== undefined && + object.leadingComments !== null + ) { + message.leadingComments = object.leadingComments; + } else { + message.leadingComments = ""; + } + if ( + object.trailingComments !== undefined && + object.trailingComments !== null + ) { + message.trailingComments = object.trailingComments; + } else { + message.trailingComments = ""; + } + if ( + object.leadingDetachedComments !== undefined && + object.leadingDetachedComments !== null + ) { + for (const e of object.leadingDetachedComments) { + message.leadingDetachedComments.push(e); + } + } + return message; + }, +}; + +const baseGeneratedCodeInfo: object = {}; + +export const GeneratedCodeInfo = { + encode(message: GeneratedCodeInfo, writer: Writer = Writer.create()): Writer { + for (const v of message.annotation) { + GeneratedCodeInfo_Annotation.encode( + v!, + writer.uint32(10).fork() + ).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): GeneratedCodeInfo { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseGeneratedCodeInfo } as GeneratedCodeInfo; + message.annotation = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.annotation.push( + GeneratedCodeInfo_Annotation.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GeneratedCodeInfo { + const message = { ...baseGeneratedCodeInfo } as GeneratedCodeInfo; + message.annotation = []; + if (object.annotation !== undefined && object.annotation !== null) { + for (const e of object.annotation) { + message.annotation.push(GeneratedCodeInfo_Annotation.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: GeneratedCodeInfo): unknown { + const obj: any = {}; + if (message.annotation) { + obj.annotation = message.annotation.map((e) => + e ? GeneratedCodeInfo_Annotation.toJSON(e) : undefined + ); + } else { + obj.annotation = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): GeneratedCodeInfo { + const message = { ...baseGeneratedCodeInfo } as GeneratedCodeInfo; + message.annotation = []; + if (object.annotation !== undefined && object.annotation !== null) { + for (const e of object.annotation) { + message.annotation.push(GeneratedCodeInfo_Annotation.fromPartial(e)); + } + } + return message; + }, +}; + +const baseGeneratedCodeInfo_Annotation: object = { + path: 0, + sourceFile: "", + begin: 0, + end: 0, +}; + +export const GeneratedCodeInfo_Annotation = { + encode( + message: GeneratedCodeInfo_Annotation, + writer: Writer = Writer.create() + ): Writer { + writer.uint32(10).fork(); + for (const v of message.path) { + writer.int32(v); + } + writer.ldelim(); + if (message.sourceFile !== "") { + writer.uint32(18).string(message.sourceFile); + } + if (message.begin !== 0) { + writer.uint32(24).int32(message.begin); + } + if (message.end !== 0) { + writer.uint32(32).int32(message.end); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): GeneratedCodeInfo_Annotation { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseGeneratedCodeInfo_Annotation, + } as GeneratedCodeInfo_Annotation; + message.path = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.path.push(reader.int32()); + } + } else { + message.path.push(reader.int32()); + } + break; + case 2: + message.sourceFile = reader.string(); + break; + case 3: + message.begin = reader.int32(); + break; + case 4: + message.end = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GeneratedCodeInfo_Annotation { + const message = { + ...baseGeneratedCodeInfo_Annotation, + } as GeneratedCodeInfo_Annotation; + message.path = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(Number(e)); + } + } + if (object.sourceFile !== undefined && object.sourceFile !== null) { + message.sourceFile = String(object.sourceFile); + } else { + message.sourceFile = ""; + } + if (object.begin !== undefined && object.begin !== null) { + message.begin = Number(object.begin); + } else { + message.begin = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + return message; + }, + + toJSON(message: GeneratedCodeInfo_Annotation): unknown { + const obj: any = {}; + if (message.path) { + obj.path = message.path.map((e) => e); + } else { + obj.path = []; + } + message.sourceFile !== undefined && (obj.sourceFile = message.sourceFile); + message.begin !== undefined && (obj.begin = message.begin); + message.end !== undefined && (obj.end = message.end); + return obj; + }, + + fromPartial( + object: DeepPartial + ): GeneratedCodeInfo_Annotation { + const message = { + ...baseGeneratedCodeInfo_Annotation, + } as GeneratedCodeInfo_Annotation; + message.path = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(e); + } + } + if (object.sourceFile !== undefined && object.sourceFile !== null) { + message.sourceFile = object.sourceFile; + } else { + message.sourceFile = ""; + } + if (object.begin !== undefined && object.begin !== null) { + message.begin = object.begin; + } else { + message.begin = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/ibc.core.channel.v1/types/google/protobuf/timestamp.ts b/ts-client/ibc.core.channel.v1/types/google/protobuf/timestamp.ts new file mode 100644 index 00000000..11864afc --- /dev/null +++ b/ts-client/ibc.core.channel.v1/types/google/protobuf/timestamp.ts @@ -0,0 +1,219 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "google.protobuf"; + +/** + * A Timestamp represents a point in time independent of any time zone or local + * calendar, encoded as a count of seconds and fractions of seconds at + * nanosecond resolution. The count is relative to an epoch at UTC midnight on + * January 1, 1970, in the proleptic Gregorian calendar which extends the + * Gregorian calendar backwards to year one. + * + * All minutes are 60 seconds long. Leap seconds are "smeared" so that no leap + * second table is needed for interpretation, using a [24-hour linear + * smear](https://developers.google.com/time/smear). + * + * The range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. By + * restricting to that range, we ensure that we can convert to and from [RFC + * 3339](https://www.ietf.org/rfc/rfc3339.txt) date strings. + * + * # Examples + * + * Example 1: Compute Timestamp from POSIX `time()`. + * + * Timestamp timestamp; + * timestamp.set_seconds(time(NULL)); + * timestamp.set_nanos(0); + * + * Example 2: Compute Timestamp from POSIX `gettimeofday()`. + * + * struct timeval tv; + * gettimeofday(&tv, NULL); + * + * Timestamp timestamp; + * timestamp.set_seconds(tv.tv_sec); + * timestamp.set_nanos(tv.tv_usec * 1000); + * + * Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`. + * + * FILETIME ft; + * GetSystemTimeAsFileTime(&ft); + * UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime; + * + * // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z + * // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z. + * Timestamp timestamp; + * timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL)); + * timestamp.set_nanos((INT32) ((ticks % 10000000) * 100)); + * + * Example 4: Compute Timestamp from Java `System.currentTimeMillis()`. + * + * long millis = System.currentTimeMillis(); + * + * Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000) + * .setNanos((int) ((millis % 1000) * 1000000)).build(); + * + * + * Example 5: Compute Timestamp from Java `Instant.now()`. + * + * Instant now = Instant.now(); + * + * Timestamp timestamp = + * Timestamp.newBuilder().setSeconds(now.getEpochSecond()) + * .setNanos(now.getNano()).build(); + * + * + * Example 6: Compute Timestamp from current time in Python. + * + * timestamp = Timestamp() + * timestamp.GetCurrentTime() + * + * # JSON Mapping + * + * In JSON format, the Timestamp type is encoded as a string in the + * [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the + * format is "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z" + * where {year} is always expressed using four digits while {month}, {day}, + * {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional + * seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution), + * are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone + * is required. A proto3 JSON serializer should always use UTC (as indicated by + * "Z") when printing the Timestamp type and a proto3 JSON parser should be + * able to accept both UTC and other timezones (as indicated by an offset). + * + * For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past + * 01:30 UTC on January 15, 2017. + * + * In JavaScript, one can convert a Date object to this format using the + * standard + * [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString) + * method. In Python, a standard `datetime.datetime` object can be converted + * to this format using + * [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) with + * the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one can use + * the Joda Time's [`ISODateTimeFormat.dateTime()`]( + * http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime%2D%2D + * ) to obtain a formatter capable of generating timestamps in this format. + */ +export interface Timestamp { + /** + * Represents seconds of UTC time since Unix epoch + * 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to + * 9999-12-31T23:59:59Z inclusive. + */ + seconds: number; + /** + * Non-negative fractions of a second at nanosecond resolution. Negative + * second values with fractions must still have non-negative nanos values + * that count forward in time. Must be from 0 to 999,999,999 + * inclusive. + */ + nanos: number; +} + +const baseTimestamp: object = { seconds: 0, nanos: 0 }; + +export const Timestamp = { + encode(message: Timestamp, writer: Writer = Writer.create()): Writer { + if (message.seconds !== 0) { + writer.uint32(8).int64(message.seconds); + } + if (message.nanos !== 0) { + writer.uint32(16).int32(message.nanos); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Timestamp { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseTimestamp } as Timestamp; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.seconds = longToNumber(reader.int64() as Long); + break; + case 2: + message.nanos = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Timestamp { + const message = { ...baseTimestamp } as Timestamp; + if (object.seconds !== undefined && object.seconds !== null) { + message.seconds = Number(object.seconds); + } else { + message.seconds = 0; + } + if (object.nanos !== undefined && object.nanos !== null) { + message.nanos = Number(object.nanos); + } else { + message.nanos = 0; + } + return message; + }, + + toJSON(message: Timestamp): unknown { + const obj: any = {}; + message.seconds !== undefined && (obj.seconds = message.seconds); + message.nanos !== undefined && (obj.nanos = message.nanos); + return obj; + }, + + fromPartial(object: DeepPartial): Timestamp { + const message = { ...baseTimestamp } as Timestamp; + if (object.seconds !== undefined && object.seconds !== null) { + message.seconds = object.seconds; + } else { + message.seconds = 0; + } + if (object.nanos !== undefined && object.nanos !== null) { + message.nanos = object.nanos; + } else { + message.nanos = 0; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/ibc.core.channel.v1/types/ibc/core/channel/v1/channel.ts b/ts-client/ibc.core.channel.v1/types/ibc/core/channel/v1/channel.ts new file mode 100644 index 00000000..9b9715b2 --- /dev/null +++ b/ts-client/ibc.core.channel.v1/types/ibc/core/channel/v1/channel.ts @@ -0,0 +1,1163 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; +import { Height } from "../../../../ibc/core/client/v1/client"; + +export const protobufPackage = "ibc.core.channel.v1"; + +/** + * State defines if a channel is in one of the following states: + * CLOSED, INIT, TRYOPEN, OPEN or UNINITIALIZED. + */ +export enum State { + /** STATE_UNINITIALIZED_UNSPECIFIED - Default State */ + STATE_UNINITIALIZED_UNSPECIFIED = 0, + /** STATE_INIT - A channel has just started the opening handshake. */ + STATE_INIT = 1, + /** STATE_TRYOPEN - A channel has acknowledged the handshake step on the counterparty chain. */ + STATE_TRYOPEN = 2, + /** + * STATE_OPEN - A channel has completed the handshake. Open channels are + * ready to send and receive packets. + */ + STATE_OPEN = 3, + /** + * STATE_CLOSED - A channel has been closed and can no longer be used to send or receive + * packets. + */ + STATE_CLOSED = 4, + UNRECOGNIZED = -1, +} + +export function stateFromJSON(object: any): State { + switch (object) { + case 0: + case "STATE_UNINITIALIZED_UNSPECIFIED": + return State.STATE_UNINITIALIZED_UNSPECIFIED; + case 1: + case "STATE_INIT": + return State.STATE_INIT; + case 2: + case "STATE_TRYOPEN": + return State.STATE_TRYOPEN; + case 3: + case "STATE_OPEN": + return State.STATE_OPEN; + case 4: + case "STATE_CLOSED": + return State.STATE_CLOSED; + case -1: + case "UNRECOGNIZED": + default: + return State.UNRECOGNIZED; + } +} + +export function stateToJSON(object: State): string { + switch (object) { + case State.STATE_UNINITIALIZED_UNSPECIFIED: + return "STATE_UNINITIALIZED_UNSPECIFIED"; + case State.STATE_INIT: + return "STATE_INIT"; + case State.STATE_TRYOPEN: + return "STATE_TRYOPEN"; + case State.STATE_OPEN: + return "STATE_OPEN"; + case State.STATE_CLOSED: + return "STATE_CLOSED"; + default: + return "UNKNOWN"; + } +} + +/** Order defines if a channel is ORDERED or UNORDERED */ +export enum Order { + /** ORDER_NONE_UNSPECIFIED - zero-value for channel ordering */ + ORDER_NONE_UNSPECIFIED = 0, + /** + * ORDER_UNORDERED - packets can be delivered in any order, which may differ from the order in + * which they were sent. + */ + ORDER_UNORDERED = 1, + /** ORDER_ORDERED - packets are delivered exactly in the order which they were sent */ + ORDER_ORDERED = 2, + UNRECOGNIZED = -1, +} + +export function orderFromJSON(object: any): Order { + switch (object) { + case 0: + case "ORDER_NONE_UNSPECIFIED": + return Order.ORDER_NONE_UNSPECIFIED; + case 1: + case "ORDER_UNORDERED": + return Order.ORDER_UNORDERED; + case 2: + case "ORDER_ORDERED": + return Order.ORDER_ORDERED; + case -1: + case "UNRECOGNIZED": + default: + return Order.UNRECOGNIZED; + } +} + +export function orderToJSON(object: Order): string { + switch (object) { + case Order.ORDER_NONE_UNSPECIFIED: + return "ORDER_NONE_UNSPECIFIED"; + case Order.ORDER_UNORDERED: + return "ORDER_UNORDERED"; + case Order.ORDER_ORDERED: + return "ORDER_ORDERED"; + default: + return "UNKNOWN"; + } +} + +/** + * Channel defines pipeline for exactly-once packet delivery between specific + * modules on separate blockchains, which has at least one end capable of + * sending packets and one end capable of receiving packets. + */ +export interface Channel { + /** current state of the channel end */ + state: State; + /** whether the channel is ordered or unordered */ + ordering: Order; + /** counterparty channel end */ + counterparty: Counterparty | undefined; + /** + * list of connection identifiers, in order, along which packets sent on + * this channel will travel + */ + connectionHops: string[]; + /** opaque channel version, which is agreed upon during the handshake */ + version: string; +} + +/** + * IdentifiedChannel defines a channel with additional port and channel + * identifier fields. + */ +export interface IdentifiedChannel { + /** current state of the channel end */ + state: State; + /** whether the channel is ordered or unordered */ + ordering: Order; + /** counterparty channel end */ + counterparty: Counterparty | undefined; + /** + * list of connection identifiers, in order, along which packets sent on + * this channel will travel + */ + connectionHops: string[]; + /** opaque channel version, which is agreed upon during the handshake */ + version: string; + /** port identifier */ + portId: string; + /** channel identifier */ + channelId: string; +} + +/** Counterparty defines a channel end counterparty */ +export interface Counterparty { + /** port on the counterparty chain which owns the other end of the channel. */ + portId: string; + /** channel end on the counterparty chain */ + channelId: string; +} + +/** Packet defines a type that carries data across different chains through IBC */ +export interface Packet { + /** + * number corresponds to the order of sends and receives, where a Packet + * with an earlier sequence number must be sent and received before a Packet + * with a later sequence number. + */ + sequence: number; + /** identifies the port on the sending chain. */ + sourcePort: string; + /** identifies the channel end on the sending chain. */ + sourceChannel: string; + /** identifies the port on the receiving chain. */ + destinationPort: string; + /** identifies the channel end on the receiving chain. */ + destinationChannel: string; + /** actual opaque bytes transferred directly to the application module */ + data: Uint8Array; + /** block height after which the packet times out */ + timeoutHeight: Height | undefined; + /** block timestamp (in nanoseconds) after which the packet times out */ + timeoutTimestamp: number; +} + +/** + * PacketState defines the generic type necessary to retrieve and store + * packet commitments, acknowledgements, and receipts. + * Caller is responsible for knowing the context necessary to interpret this + * state as a commitment, acknowledgement, or a receipt. + */ +export interface PacketState { + /** channel port identifier. */ + portId: string; + /** channel unique identifier. */ + channelId: string; + /** packet sequence. */ + sequence: number; + /** embedded data that represents packet state. */ + data: Uint8Array; +} + +/** + * PacketId is an identifer for a unique Packet + * Source chains refer to packets by source port/channel + * Destination chains refer to packets by destination port/channel + */ +export interface PacketId { + /** channel port identifier */ + portId: string; + /** channel unique identifier */ + channelId: string; + /** packet sequence */ + sequence: number; +} + +/** + * Acknowledgement is the recommended acknowledgement format to be used by + * app-specific protocols. + * NOTE: The field numbers 21 and 22 were explicitly chosen to avoid accidental + * conflicts with other protobuf message formats used for acknowledgements. + * The first byte of any message with this format will be the non-ASCII values + * `0xaa` (result) or `0xb2` (error). Implemented as defined by ICS: + * https://github.com/cosmos/ibc/tree/master/spec/core/ics-004-channel-and-packet-semantics#acknowledgement-envelope + */ +export interface Acknowledgement { + result: Uint8Array | undefined; + error: string | undefined; +} + +const baseChannel: object = { + state: 0, + ordering: 0, + connectionHops: "", + version: "", +}; + +export const Channel = { + encode(message: Channel, writer: Writer = Writer.create()): Writer { + if (message.state !== 0) { + writer.uint32(8).int32(message.state); + } + if (message.ordering !== 0) { + writer.uint32(16).int32(message.ordering); + } + if (message.counterparty !== undefined) { + Counterparty.encode( + message.counterparty, + writer.uint32(26).fork() + ).ldelim(); + } + for (const v of message.connectionHops) { + writer.uint32(34).string(v!); + } + if (message.version !== "") { + writer.uint32(42).string(message.version); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Channel { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseChannel } as Channel; + message.connectionHops = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.state = reader.int32() as any; + break; + case 2: + message.ordering = reader.int32() as any; + break; + case 3: + message.counterparty = Counterparty.decode(reader, reader.uint32()); + break; + case 4: + message.connectionHops.push(reader.string()); + break; + case 5: + message.version = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Channel { + const message = { ...baseChannel } as Channel; + message.connectionHops = []; + if (object.state !== undefined && object.state !== null) { + message.state = stateFromJSON(object.state); + } else { + message.state = 0; + } + if (object.ordering !== undefined && object.ordering !== null) { + message.ordering = orderFromJSON(object.ordering); + } else { + message.ordering = 0; + } + if (object.counterparty !== undefined && object.counterparty !== null) { + message.counterparty = Counterparty.fromJSON(object.counterparty); + } else { + message.counterparty = undefined; + } + if (object.connectionHops !== undefined && object.connectionHops !== null) { + for (const e of object.connectionHops) { + message.connectionHops.push(String(e)); + } + } + if (object.version !== undefined && object.version !== null) { + message.version = String(object.version); + } else { + message.version = ""; + } + return message; + }, + + toJSON(message: Channel): unknown { + const obj: any = {}; + message.state !== undefined && (obj.state = stateToJSON(message.state)); + message.ordering !== undefined && + (obj.ordering = orderToJSON(message.ordering)); + message.counterparty !== undefined && + (obj.counterparty = message.counterparty + ? Counterparty.toJSON(message.counterparty) + : undefined); + if (message.connectionHops) { + obj.connectionHops = message.connectionHops.map((e) => e); + } else { + obj.connectionHops = []; + } + message.version !== undefined && (obj.version = message.version); + return obj; + }, + + fromPartial(object: DeepPartial): Channel { + const message = { ...baseChannel } as Channel; + message.connectionHops = []; + if (object.state !== undefined && object.state !== null) { + message.state = object.state; + } else { + message.state = 0; + } + if (object.ordering !== undefined && object.ordering !== null) { + message.ordering = object.ordering; + } else { + message.ordering = 0; + } + if (object.counterparty !== undefined && object.counterparty !== null) { + message.counterparty = Counterparty.fromPartial(object.counterparty); + } else { + message.counterparty = undefined; + } + if (object.connectionHops !== undefined && object.connectionHops !== null) { + for (const e of object.connectionHops) { + message.connectionHops.push(e); + } + } + if (object.version !== undefined && object.version !== null) { + message.version = object.version; + } else { + message.version = ""; + } + return message; + }, +}; + +const baseIdentifiedChannel: object = { + state: 0, + ordering: 0, + connectionHops: "", + version: "", + portId: "", + channelId: "", +}; + +export const IdentifiedChannel = { + encode(message: IdentifiedChannel, writer: Writer = Writer.create()): Writer { + if (message.state !== 0) { + writer.uint32(8).int32(message.state); + } + if (message.ordering !== 0) { + writer.uint32(16).int32(message.ordering); + } + if (message.counterparty !== undefined) { + Counterparty.encode( + message.counterparty, + writer.uint32(26).fork() + ).ldelim(); + } + for (const v of message.connectionHops) { + writer.uint32(34).string(v!); + } + if (message.version !== "") { + writer.uint32(42).string(message.version); + } + if (message.portId !== "") { + writer.uint32(50).string(message.portId); + } + if (message.channelId !== "") { + writer.uint32(58).string(message.channelId); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): IdentifiedChannel { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseIdentifiedChannel } as IdentifiedChannel; + message.connectionHops = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.state = reader.int32() as any; + break; + case 2: + message.ordering = reader.int32() as any; + break; + case 3: + message.counterparty = Counterparty.decode(reader, reader.uint32()); + break; + case 4: + message.connectionHops.push(reader.string()); + break; + case 5: + message.version = reader.string(); + break; + case 6: + message.portId = reader.string(); + break; + case 7: + message.channelId = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): IdentifiedChannel { + const message = { ...baseIdentifiedChannel } as IdentifiedChannel; + message.connectionHops = []; + if (object.state !== undefined && object.state !== null) { + message.state = stateFromJSON(object.state); + } else { + message.state = 0; + } + if (object.ordering !== undefined && object.ordering !== null) { + message.ordering = orderFromJSON(object.ordering); + } else { + message.ordering = 0; + } + if (object.counterparty !== undefined && object.counterparty !== null) { + message.counterparty = Counterparty.fromJSON(object.counterparty); + } else { + message.counterparty = undefined; + } + if (object.connectionHops !== undefined && object.connectionHops !== null) { + for (const e of object.connectionHops) { + message.connectionHops.push(String(e)); + } + } + if (object.version !== undefined && object.version !== null) { + message.version = String(object.version); + } else { + message.version = ""; + } + if (object.portId !== undefined && object.portId !== null) { + message.portId = String(object.portId); + } else { + message.portId = ""; + } + if (object.channelId !== undefined && object.channelId !== null) { + message.channelId = String(object.channelId); + } else { + message.channelId = ""; + } + return message; + }, + + toJSON(message: IdentifiedChannel): unknown { + const obj: any = {}; + message.state !== undefined && (obj.state = stateToJSON(message.state)); + message.ordering !== undefined && + (obj.ordering = orderToJSON(message.ordering)); + message.counterparty !== undefined && + (obj.counterparty = message.counterparty + ? Counterparty.toJSON(message.counterparty) + : undefined); + if (message.connectionHops) { + obj.connectionHops = message.connectionHops.map((e) => e); + } else { + obj.connectionHops = []; + } + message.version !== undefined && (obj.version = message.version); + message.portId !== undefined && (obj.portId = message.portId); + message.channelId !== undefined && (obj.channelId = message.channelId); + return obj; + }, + + fromPartial(object: DeepPartial): IdentifiedChannel { + const message = { ...baseIdentifiedChannel } as IdentifiedChannel; + message.connectionHops = []; + if (object.state !== undefined && object.state !== null) { + message.state = object.state; + } else { + message.state = 0; + } + if (object.ordering !== undefined && object.ordering !== null) { + message.ordering = object.ordering; + } else { + message.ordering = 0; + } + if (object.counterparty !== undefined && object.counterparty !== null) { + message.counterparty = Counterparty.fromPartial(object.counterparty); + } else { + message.counterparty = undefined; + } + if (object.connectionHops !== undefined && object.connectionHops !== null) { + for (const e of object.connectionHops) { + message.connectionHops.push(e); + } + } + if (object.version !== undefined && object.version !== null) { + message.version = object.version; + } else { + message.version = ""; + } + if (object.portId !== undefined && object.portId !== null) { + message.portId = object.portId; + } else { + message.portId = ""; + } + if (object.channelId !== undefined && object.channelId !== null) { + message.channelId = object.channelId; + } else { + message.channelId = ""; + } + return message; + }, +}; + +const baseCounterparty: object = { portId: "", channelId: "" }; + +export const Counterparty = { + encode(message: Counterparty, writer: Writer = Writer.create()): Writer { + if (message.portId !== "") { + writer.uint32(10).string(message.portId); + } + if (message.channelId !== "") { + writer.uint32(18).string(message.channelId); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Counterparty { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseCounterparty } as Counterparty; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.portId = reader.string(); + break; + case 2: + message.channelId = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Counterparty { + const message = { ...baseCounterparty } as Counterparty; + if (object.portId !== undefined && object.portId !== null) { + message.portId = String(object.portId); + } else { + message.portId = ""; + } + if (object.channelId !== undefined && object.channelId !== null) { + message.channelId = String(object.channelId); + } else { + message.channelId = ""; + } + return message; + }, + + toJSON(message: Counterparty): unknown { + const obj: any = {}; + message.portId !== undefined && (obj.portId = message.portId); + message.channelId !== undefined && (obj.channelId = message.channelId); + return obj; + }, + + fromPartial(object: DeepPartial): Counterparty { + const message = { ...baseCounterparty } as Counterparty; + if (object.portId !== undefined && object.portId !== null) { + message.portId = object.portId; + } else { + message.portId = ""; + } + if (object.channelId !== undefined && object.channelId !== null) { + message.channelId = object.channelId; + } else { + message.channelId = ""; + } + return message; + }, +}; + +const basePacket: object = { + sequence: 0, + sourcePort: "", + sourceChannel: "", + destinationPort: "", + destinationChannel: "", + timeoutTimestamp: 0, +}; + +export const Packet = { + encode(message: Packet, writer: Writer = Writer.create()): Writer { + if (message.sequence !== 0) { + writer.uint32(8).uint64(message.sequence); + } + if (message.sourcePort !== "") { + writer.uint32(18).string(message.sourcePort); + } + if (message.sourceChannel !== "") { + writer.uint32(26).string(message.sourceChannel); + } + if (message.destinationPort !== "") { + writer.uint32(34).string(message.destinationPort); + } + if (message.destinationChannel !== "") { + writer.uint32(42).string(message.destinationChannel); + } + if (message.data.length !== 0) { + writer.uint32(50).bytes(message.data); + } + if (message.timeoutHeight !== undefined) { + Height.encode(message.timeoutHeight, writer.uint32(58).fork()).ldelim(); + } + if (message.timeoutTimestamp !== 0) { + writer.uint32(64).uint64(message.timeoutTimestamp); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Packet { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...basePacket } as Packet; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.sequence = longToNumber(reader.uint64() as Long); + break; + case 2: + message.sourcePort = reader.string(); + break; + case 3: + message.sourceChannel = reader.string(); + break; + case 4: + message.destinationPort = reader.string(); + break; + case 5: + message.destinationChannel = reader.string(); + break; + case 6: + message.data = reader.bytes(); + break; + case 7: + message.timeoutHeight = Height.decode(reader, reader.uint32()); + break; + case 8: + message.timeoutTimestamp = longToNumber(reader.uint64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Packet { + const message = { ...basePacket } as Packet; + if (object.sequence !== undefined && object.sequence !== null) { + message.sequence = Number(object.sequence); + } else { + message.sequence = 0; + } + if (object.sourcePort !== undefined && object.sourcePort !== null) { + message.sourcePort = String(object.sourcePort); + } else { + message.sourcePort = ""; + } + if (object.sourceChannel !== undefined && object.sourceChannel !== null) { + message.sourceChannel = String(object.sourceChannel); + } else { + message.sourceChannel = ""; + } + if ( + object.destinationPort !== undefined && + object.destinationPort !== null + ) { + message.destinationPort = String(object.destinationPort); + } else { + message.destinationPort = ""; + } + if ( + object.destinationChannel !== undefined && + object.destinationChannel !== null + ) { + message.destinationChannel = String(object.destinationChannel); + } else { + message.destinationChannel = ""; + } + if (object.data !== undefined && object.data !== null) { + message.data = bytesFromBase64(object.data); + } + if (object.timeoutHeight !== undefined && object.timeoutHeight !== null) { + message.timeoutHeight = Height.fromJSON(object.timeoutHeight); + } else { + message.timeoutHeight = undefined; + } + if ( + object.timeoutTimestamp !== undefined && + object.timeoutTimestamp !== null + ) { + message.timeoutTimestamp = Number(object.timeoutTimestamp); + } else { + message.timeoutTimestamp = 0; + } + return message; + }, + + toJSON(message: Packet): unknown { + const obj: any = {}; + message.sequence !== undefined && (obj.sequence = message.sequence); + message.sourcePort !== undefined && (obj.sourcePort = message.sourcePort); + message.sourceChannel !== undefined && + (obj.sourceChannel = message.sourceChannel); + message.destinationPort !== undefined && + (obj.destinationPort = message.destinationPort); + message.destinationChannel !== undefined && + (obj.destinationChannel = message.destinationChannel); + message.data !== undefined && + (obj.data = base64FromBytes( + message.data !== undefined ? message.data : new Uint8Array() + )); + message.timeoutHeight !== undefined && + (obj.timeoutHeight = message.timeoutHeight + ? Height.toJSON(message.timeoutHeight) + : undefined); + message.timeoutTimestamp !== undefined && + (obj.timeoutTimestamp = message.timeoutTimestamp); + return obj; + }, + + fromPartial(object: DeepPartial): Packet { + const message = { ...basePacket } as Packet; + if (object.sequence !== undefined && object.sequence !== null) { + message.sequence = object.sequence; + } else { + message.sequence = 0; + } + if (object.sourcePort !== undefined && object.sourcePort !== null) { + message.sourcePort = object.sourcePort; + } else { + message.sourcePort = ""; + } + if (object.sourceChannel !== undefined && object.sourceChannel !== null) { + message.sourceChannel = object.sourceChannel; + } else { + message.sourceChannel = ""; + } + if ( + object.destinationPort !== undefined && + object.destinationPort !== null + ) { + message.destinationPort = object.destinationPort; + } else { + message.destinationPort = ""; + } + if ( + object.destinationChannel !== undefined && + object.destinationChannel !== null + ) { + message.destinationChannel = object.destinationChannel; + } else { + message.destinationChannel = ""; + } + if (object.data !== undefined && object.data !== null) { + message.data = object.data; + } else { + message.data = new Uint8Array(); + } + if (object.timeoutHeight !== undefined && object.timeoutHeight !== null) { + message.timeoutHeight = Height.fromPartial(object.timeoutHeight); + } else { + message.timeoutHeight = undefined; + } + if ( + object.timeoutTimestamp !== undefined && + object.timeoutTimestamp !== null + ) { + message.timeoutTimestamp = object.timeoutTimestamp; + } else { + message.timeoutTimestamp = 0; + } + return message; + }, +}; + +const basePacketState: object = { portId: "", channelId: "", sequence: 0 }; + +export const PacketState = { + encode(message: PacketState, writer: Writer = Writer.create()): Writer { + if (message.portId !== "") { + writer.uint32(10).string(message.portId); + } + if (message.channelId !== "") { + writer.uint32(18).string(message.channelId); + } + if (message.sequence !== 0) { + writer.uint32(24).uint64(message.sequence); + } + if (message.data.length !== 0) { + writer.uint32(34).bytes(message.data); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): PacketState { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...basePacketState } as PacketState; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.portId = reader.string(); + break; + case 2: + message.channelId = reader.string(); + break; + case 3: + message.sequence = longToNumber(reader.uint64() as Long); + break; + case 4: + message.data = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): PacketState { + const message = { ...basePacketState } as PacketState; + if (object.portId !== undefined && object.portId !== null) { + message.portId = String(object.portId); + } else { + message.portId = ""; + } + if (object.channelId !== undefined && object.channelId !== null) { + message.channelId = String(object.channelId); + } else { + message.channelId = ""; + } + if (object.sequence !== undefined && object.sequence !== null) { + message.sequence = Number(object.sequence); + } else { + message.sequence = 0; + } + if (object.data !== undefined && object.data !== null) { + message.data = bytesFromBase64(object.data); + } + return message; + }, + + toJSON(message: PacketState): unknown { + const obj: any = {}; + message.portId !== undefined && (obj.portId = message.portId); + message.channelId !== undefined && (obj.channelId = message.channelId); + message.sequence !== undefined && (obj.sequence = message.sequence); + message.data !== undefined && + (obj.data = base64FromBytes( + message.data !== undefined ? message.data : new Uint8Array() + )); + return obj; + }, + + fromPartial(object: DeepPartial): PacketState { + const message = { ...basePacketState } as PacketState; + if (object.portId !== undefined && object.portId !== null) { + message.portId = object.portId; + } else { + message.portId = ""; + } + if (object.channelId !== undefined && object.channelId !== null) { + message.channelId = object.channelId; + } else { + message.channelId = ""; + } + if (object.sequence !== undefined && object.sequence !== null) { + message.sequence = object.sequence; + } else { + message.sequence = 0; + } + if (object.data !== undefined && object.data !== null) { + message.data = object.data; + } else { + message.data = new Uint8Array(); + } + return message; + }, +}; + +const basePacketId: object = { portId: "", channelId: "", sequence: 0 }; + +export const PacketId = { + encode(message: PacketId, writer: Writer = Writer.create()): Writer { + if (message.portId !== "") { + writer.uint32(10).string(message.portId); + } + if (message.channelId !== "") { + writer.uint32(18).string(message.channelId); + } + if (message.sequence !== 0) { + writer.uint32(24).uint64(message.sequence); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): PacketId { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...basePacketId } as PacketId; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.portId = reader.string(); + break; + case 2: + message.channelId = reader.string(); + break; + case 3: + message.sequence = longToNumber(reader.uint64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): PacketId { + const message = { ...basePacketId } as PacketId; + if (object.portId !== undefined && object.portId !== null) { + message.portId = String(object.portId); + } else { + message.portId = ""; + } + if (object.channelId !== undefined && object.channelId !== null) { + message.channelId = String(object.channelId); + } else { + message.channelId = ""; + } + if (object.sequence !== undefined && object.sequence !== null) { + message.sequence = Number(object.sequence); + } else { + message.sequence = 0; + } + return message; + }, + + toJSON(message: PacketId): unknown { + const obj: any = {}; + message.portId !== undefined && (obj.portId = message.portId); + message.channelId !== undefined && (obj.channelId = message.channelId); + message.sequence !== undefined && (obj.sequence = message.sequence); + return obj; + }, + + fromPartial(object: DeepPartial): PacketId { + const message = { ...basePacketId } as PacketId; + if (object.portId !== undefined && object.portId !== null) { + message.portId = object.portId; + } else { + message.portId = ""; + } + if (object.channelId !== undefined && object.channelId !== null) { + message.channelId = object.channelId; + } else { + message.channelId = ""; + } + if (object.sequence !== undefined && object.sequence !== null) { + message.sequence = object.sequence; + } else { + message.sequence = 0; + } + return message; + }, +}; + +const baseAcknowledgement: object = {}; + +export const Acknowledgement = { + encode(message: Acknowledgement, writer: Writer = Writer.create()): Writer { + if (message.result !== undefined) { + writer.uint32(170).bytes(message.result); + } + if (message.error !== undefined) { + writer.uint32(178).string(message.error); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Acknowledgement { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseAcknowledgement } as Acknowledgement; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 21: + message.result = reader.bytes(); + break; + case 22: + message.error = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Acknowledgement { + const message = { ...baseAcknowledgement } as Acknowledgement; + if (object.result !== undefined && object.result !== null) { + message.result = bytesFromBase64(object.result); + } + if (object.error !== undefined && object.error !== null) { + message.error = String(object.error); + } else { + message.error = undefined; + } + return message; + }, + + toJSON(message: Acknowledgement): unknown { + const obj: any = {}; + message.result !== undefined && + (obj.result = + message.result !== undefined + ? base64FromBytes(message.result) + : undefined); + message.error !== undefined && (obj.error = message.error); + return obj; + }, + + fromPartial(object: DeepPartial): Acknowledgement { + const message = { ...baseAcknowledgement } as Acknowledgement; + if (object.result !== undefined && object.result !== null) { + message.result = object.result; + } else { + message.result = undefined; + } + if (object.error !== undefined && object.error !== null) { + message.error = object.error; + } else { + message.error = undefined; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/ibc.core.channel.v1/types/ibc/core/channel/v1/genesis.ts b/ts-client/ibc.core.channel.v1/types/ibc/core/channel/v1/genesis.ts new file mode 100644 index 00000000..5729159a --- /dev/null +++ b/ts-client/ibc.core.channel.v1/types/ibc/core/channel/v1/genesis.ts @@ -0,0 +1,414 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; +import { + IdentifiedChannel, + PacketState, +} from "../../../../ibc/core/channel/v1/channel"; + +export const protobufPackage = "ibc.core.channel.v1"; + +/** GenesisState defines the ibc channel submodule's genesis state. */ +export interface GenesisState { + channels: IdentifiedChannel[]; + acknowledgements: PacketState[]; + commitments: PacketState[]; + receipts: PacketState[]; + sendSequences: PacketSequence[]; + recvSequences: PacketSequence[]; + ackSequences: PacketSequence[]; + /** the sequence for the next generated channel identifier */ + nextChannelSequence: number; +} + +/** + * PacketSequence defines the genesis type necessary to retrieve and store + * next send and receive sequences. + */ +export interface PacketSequence { + portId: string; + channelId: string; + sequence: number; +} + +const baseGenesisState: object = { nextChannelSequence: 0 }; + +export const GenesisState = { + encode(message: GenesisState, writer: Writer = Writer.create()): Writer { + for (const v of message.channels) { + IdentifiedChannel.encode(v!, writer.uint32(10).fork()).ldelim(); + } + for (const v of message.acknowledgements) { + PacketState.encode(v!, writer.uint32(18).fork()).ldelim(); + } + for (const v of message.commitments) { + PacketState.encode(v!, writer.uint32(26).fork()).ldelim(); + } + for (const v of message.receipts) { + PacketState.encode(v!, writer.uint32(34).fork()).ldelim(); + } + for (const v of message.sendSequences) { + PacketSequence.encode(v!, writer.uint32(42).fork()).ldelim(); + } + for (const v of message.recvSequences) { + PacketSequence.encode(v!, writer.uint32(50).fork()).ldelim(); + } + for (const v of message.ackSequences) { + PacketSequence.encode(v!, writer.uint32(58).fork()).ldelim(); + } + if (message.nextChannelSequence !== 0) { + writer.uint32(64).uint64(message.nextChannelSequence); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): GenesisState { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseGenesisState } as GenesisState; + message.channels = []; + message.acknowledgements = []; + message.commitments = []; + message.receipts = []; + message.sendSequences = []; + message.recvSequences = []; + message.ackSequences = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.channels.push( + IdentifiedChannel.decode(reader, reader.uint32()) + ); + break; + case 2: + message.acknowledgements.push( + PacketState.decode(reader, reader.uint32()) + ); + break; + case 3: + message.commitments.push(PacketState.decode(reader, reader.uint32())); + break; + case 4: + message.receipts.push(PacketState.decode(reader, reader.uint32())); + break; + case 5: + message.sendSequences.push( + PacketSequence.decode(reader, reader.uint32()) + ); + break; + case 6: + message.recvSequences.push( + PacketSequence.decode(reader, reader.uint32()) + ); + break; + case 7: + message.ackSequences.push( + PacketSequence.decode(reader, reader.uint32()) + ); + break; + case 8: + message.nextChannelSequence = longToNumber(reader.uint64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GenesisState { + const message = { ...baseGenesisState } as GenesisState; + message.channels = []; + message.acknowledgements = []; + message.commitments = []; + message.receipts = []; + message.sendSequences = []; + message.recvSequences = []; + message.ackSequences = []; + if (object.channels !== undefined && object.channels !== null) { + for (const e of object.channels) { + message.channels.push(IdentifiedChannel.fromJSON(e)); + } + } + if ( + object.acknowledgements !== undefined && + object.acknowledgements !== null + ) { + for (const e of object.acknowledgements) { + message.acknowledgements.push(PacketState.fromJSON(e)); + } + } + if (object.commitments !== undefined && object.commitments !== null) { + for (const e of object.commitments) { + message.commitments.push(PacketState.fromJSON(e)); + } + } + if (object.receipts !== undefined && object.receipts !== null) { + for (const e of object.receipts) { + message.receipts.push(PacketState.fromJSON(e)); + } + } + if (object.sendSequences !== undefined && object.sendSequences !== null) { + for (const e of object.sendSequences) { + message.sendSequences.push(PacketSequence.fromJSON(e)); + } + } + if (object.recvSequences !== undefined && object.recvSequences !== null) { + for (const e of object.recvSequences) { + message.recvSequences.push(PacketSequence.fromJSON(e)); + } + } + if (object.ackSequences !== undefined && object.ackSequences !== null) { + for (const e of object.ackSequences) { + message.ackSequences.push(PacketSequence.fromJSON(e)); + } + } + if ( + object.nextChannelSequence !== undefined && + object.nextChannelSequence !== null + ) { + message.nextChannelSequence = Number(object.nextChannelSequence); + } else { + message.nextChannelSequence = 0; + } + return message; + }, + + toJSON(message: GenesisState): unknown { + const obj: any = {}; + if (message.channels) { + obj.channels = message.channels.map((e) => + e ? IdentifiedChannel.toJSON(e) : undefined + ); + } else { + obj.channels = []; + } + if (message.acknowledgements) { + obj.acknowledgements = message.acknowledgements.map((e) => + e ? PacketState.toJSON(e) : undefined + ); + } else { + obj.acknowledgements = []; + } + if (message.commitments) { + obj.commitments = message.commitments.map((e) => + e ? PacketState.toJSON(e) : undefined + ); + } else { + obj.commitments = []; + } + if (message.receipts) { + obj.receipts = message.receipts.map((e) => + e ? PacketState.toJSON(e) : undefined + ); + } else { + obj.receipts = []; + } + if (message.sendSequences) { + obj.sendSequences = message.sendSequences.map((e) => + e ? PacketSequence.toJSON(e) : undefined + ); + } else { + obj.sendSequences = []; + } + if (message.recvSequences) { + obj.recvSequences = message.recvSequences.map((e) => + e ? PacketSequence.toJSON(e) : undefined + ); + } else { + obj.recvSequences = []; + } + if (message.ackSequences) { + obj.ackSequences = message.ackSequences.map((e) => + e ? PacketSequence.toJSON(e) : undefined + ); + } else { + obj.ackSequences = []; + } + message.nextChannelSequence !== undefined && + (obj.nextChannelSequence = message.nextChannelSequence); + return obj; + }, + + fromPartial(object: DeepPartial): GenesisState { + const message = { ...baseGenesisState } as GenesisState; + message.channels = []; + message.acknowledgements = []; + message.commitments = []; + message.receipts = []; + message.sendSequences = []; + message.recvSequences = []; + message.ackSequences = []; + if (object.channels !== undefined && object.channels !== null) { + for (const e of object.channels) { + message.channels.push(IdentifiedChannel.fromPartial(e)); + } + } + if ( + object.acknowledgements !== undefined && + object.acknowledgements !== null + ) { + for (const e of object.acknowledgements) { + message.acknowledgements.push(PacketState.fromPartial(e)); + } + } + if (object.commitments !== undefined && object.commitments !== null) { + for (const e of object.commitments) { + message.commitments.push(PacketState.fromPartial(e)); + } + } + if (object.receipts !== undefined && object.receipts !== null) { + for (const e of object.receipts) { + message.receipts.push(PacketState.fromPartial(e)); + } + } + if (object.sendSequences !== undefined && object.sendSequences !== null) { + for (const e of object.sendSequences) { + message.sendSequences.push(PacketSequence.fromPartial(e)); + } + } + if (object.recvSequences !== undefined && object.recvSequences !== null) { + for (const e of object.recvSequences) { + message.recvSequences.push(PacketSequence.fromPartial(e)); + } + } + if (object.ackSequences !== undefined && object.ackSequences !== null) { + for (const e of object.ackSequences) { + message.ackSequences.push(PacketSequence.fromPartial(e)); + } + } + if ( + object.nextChannelSequence !== undefined && + object.nextChannelSequence !== null + ) { + message.nextChannelSequence = object.nextChannelSequence; + } else { + message.nextChannelSequence = 0; + } + return message; + }, +}; + +const basePacketSequence: object = { portId: "", channelId: "", sequence: 0 }; + +export const PacketSequence = { + encode(message: PacketSequence, writer: Writer = Writer.create()): Writer { + if (message.portId !== "") { + writer.uint32(10).string(message.portId); + } + if (message.channelId !== "") { + writer.uint32(18).string(message.channelId); + } + if (message.sequence !== 0) { + writer.uint32(24).uint64(message.sequence); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): PacketSequence { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...basePacketSequence } as PacketSequence; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.portId = reader.string(); + break; + case 2: + message.channelId = reader.string(); + break; + case 3: + message.sequence = longToNumber(reader.uint64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): PacketSequence { + const message = { ...basePacketSequence } as PacketSequence; + if (object.portId !== undefined && object.portId !== null) { + message.portId = String(object.portId); + } else { + message.portId = ""; + } + if (object.channelId !== undefined && object.channelId !== null) { + message.channelId = String(object.channelId); + } else { + message.channelId = ""; + } + if (object.sequence !== undefined && object.sequence !== null) { + message.sequence = Number(object.sequence); + } else { + message.sequence = 0; + } + return message; + }, + + toJSON(message: PacketSequence): unknown { + const obj: any = {}; + message.portId !== undefined && (obj.portId = message.portId); + message.channelId !== undefined && (obj.channelId = message.channelId); + message.sequence !== undefined && (obj.sequence = message.sequence); + return obj; + }, + + fromPartial(object: DeepPartial): PacketSequence { + const message = { ...basePacketSequence } as PacketSequence; + if (object.portId !== undefined && object.portId !== null) { + message.portId = object.portId; + } else { + message.portId = ""; + } + if (object.channelId !== undefined && object.channelId !== null) { + message.channelId = object.channelId; + } else { + message.channelId = ""; + } + if (object.sequence !== undefined && object.sequence !== null) { + message.sequence = object.sequence; + } else { + message.sequence = 0; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/ibc.core.channel.v1/types/ibc/core/channel/v1/query.ts b/ts-client/ibc.core.channel.v1/types/ibc/core/channel/v1/query.ts new file mode 100644 index 00000000..0eb97754 --- /dev/null +++ b/ts-client/ibc.core.channel.v1/types/ibc/core/channel/v1/query.ts @@ -0,0 +1,3526 @@ +/* eslint-disable */ +import { Reader, util, configure, Writer } from "protobufjs/minimal"; +import * as Long from "long"; +import { + Channel, + IdentifiedChannel, + PacketState, +} from "../../../../ibc/core/channel/v1/channel"; +import { + Height, + IdentifiedClientState, +} from "../../../../ibc/core/client/v1/client"; +import { + PageRequest, + PageResponse, +} from "../../../../cosmos/base/query/v1beta1/pagination"; +import { Any } from "../../../../google/protobuf/any"; + +export const protobufPackage = "ibc.core.channel.v1"; + +/** QueryChannelRequest is the request type for the Query/Channel RPC method */ +export interface QueryChannelRequest { + /** port unique identifier */ + portId: string; + /** channel unique identifier */ + channelId: string; +} + +/** + * QueryChannelResponse is the response type for the Query/Channel RPC method. + * Besides the Channel end, it includes a proof and the height from which the + * proof was retrieved. + */ +export interface QueryChannelResponse { + /** channel associated with the request identifiers */ + channel: Channel | undefined; + /** merkle proof of existence */ + proof: Uint8Array; + /** height at which the proof was retrieved */ + proofHeight: Height | undefined; +} + +/** QueryChannelsRequest is the request type for the Query/Channels RPC method */ +export interface QueryChannelsRequest { + /** pagination request */ + pagination: PageRequest | undefined; +} + +/** QueryChannelsResponse is the response type for the Query/Channels RPC method. */ +export interface QueryChannelsResponse { + /** list of stored channels of the chain. */ + channels: IdentifiedChannel[]; + /** pagination response */ + pagination: PageResponse | undefined; + /** query block height */ + height: Height | undefined; +} + +/** + * QueryConnectionChannelsRequest is the request type for the + * Query/QueryConnectionChannels RPC method + */ +export interface QueryConnectionChannelsRequest { + /** connection unique identifier */ + connection: string; + /** pagination request */ + pagination: PageRequest | undefined; +} + +/** + * QueryConnectionChannelsResponse is the Response type for the + * Query/QueryConnectionChannels RPC method + */ +export interface QueryConnectionChannelsResponse { + /** list of channels associated with a connection. */ + channels: IdentifiedChannel[]; + /** pagination response */ + pagination: PageResponse | undefined; + /** query block height */ + height: Height | undefined; +} + +/** + * QueryChannelClientStateRequest is the request type for the Query/ClientState + * RPC method + */ +export interface QueryChannelClientStateRequest { + /** port unique identifier */ + portId: string; + /** channel unique identifier */ + channelId: string; +} + +/** + * QueryChannelClientStateResponse is the Response type for the + * Query/QueryChannelClientState RPC method + */ +export interface QueryChannelClientStateResponse { + /** client state associated with the channel */ + identifiedClientState: IdentifiedClientState | undefined; + /** merkle proof of existence */ + proof: Uint8Array; + /** height at which the proof was retrieved */ + proofHeight: Height | undefined; +} + +/** + * QueryChannelConsensusStateRequest is the request type for the + * Query/ConsensusState RPC method + */ +export interface QueryChannelConsensusStateRequest { + /** port unique identifier */ + portId: string; + /** channel unique identifier */ + channelId: string; + /** revision number of the consensus state */ + revisionNumber: number; + /** revision height of the consensus state */ + revisionHeight: number; +} + +/** + * QueryChannelClientStateResponse is the Response type for the + * Query/QueryChannelClientState RPC method + */ +export interface QueryChannelConsensusStateResponse { + /** consensus state associated with the channel */ + consensusState: Any | undefined; + /** client ID associated with the consensus state */ + clientId: string; + /** merkle proof of existence */ + proof: Uint8Array; + /** height at which the proof was retrieved */ + proofHeight: Height | undefined; +} + +/** + * QueryPacketCommitmentRequest is the request type for the + * Query/PacketCommitment RPC method + */ +export interface QueryPacketCommitmentRequest { + /** port unique identifier */ + portId: string; + /** channel unique identifier */ + channelId: string; + /** packet sequence */ + sequence: number; +} + +/** + * QueryPacketCommitmentResponse defines the client query response for a packet + * which also includes a proof and the height from which the proof was + * retrieved + */ +export interface QueryPacketCommitmentResponse { + /** packet associated with the request fields */ + commitment: Uint8Array; + /** merkle proof of existence */ + proof: Uint8Array; + /** height at which the proof was retrieved */ + proofHeight: Height | undefined; +} + +/** + * QueryPacketCommitmentsRequest is the request type for the + * Query/QueryPacketCommitments RPC method + */ +export interface QueryPacketCommitmentsRequest { + /** port unique identifier */ + portId: string; + /** channel unique identifier */ + channelId: string; + /** pagination request */ + pagination: PageRequest | undefined; +} + +/** + * QueryPacketCommitmentsResponse is the request type for the + * Query/QueryPacketCommitments RPC method + */ +export interface QueryPacketCommitmentsResponse { + commitments: PacketState[]; + /** pagination response */ + pagination: PageResponse | undefined; + /** query block height */ + height: Height | undefined; +} + +/** + * QueryPacketReceiptRequest is the request type for the + * Query/PacketReceipt RPC method + */ +export interface QueryPacketReceiptRequest { + /** port unique identifier */ + portId: string; + /** channel unique identifier */ + channelId: string; + /** packet sequence */ + sequence: number; +} + +/** + * QueryPacketReceiptResponse defines the client query response for a packet + * receipt which also includes a proof, and the height from which the proof was + * retrieved + */ +export interface QueryPacketReceiptResponse { + /** success flag for if receipt exists */ + received: boolean; + /** merkle proof of existence */ + proof: Uint8Array; + /** height at which the proof was retrieved */ + proofHeight: Height | undefined; +} + +/** + * QueryPacketAcknowledgementRequest is the request type for the + * Query/PacketAcknowledgement RPC method + */ +export interface QueryPacketAcknowledgementRequest { + /** port unique identifier */ + portId: string; + /** channel unique identifier */ + channelId: string; + /** packet sequence */ + sequence: number; +} + +/** + * QueryPacketAcknowledgementResponse defines the client query response for a + * packet which also includes a proof and the height from which the + * proof was retrieved + */ +export interface QueryPacketAcknowledgementResponse { + /** packet associated with the request fields */ + acknowledgement: Uint8Array; + /** merkle proof of existence */ + proof: Uint8Array; + /** height at which the proof was retrieved */ + proofHeight: Height | undefined; +} + +/** + * QueryPacketAcknowledgementsRequest is the request type for the + * Query/QueryPacketCommitments RPC method + */ +export interface QueryPacketAcknowledgementsRequest { + /** port unique identifier */ + portId: string; + /** channel unique identifier */ + channelId: string; + /** pagination request */ + pagination: PageRequest | undefined; + /** list of packet sequences */ + packetCommitmentSequences: number[]; +} + +/** + * QueryPacketAcknowledgemetsResponse is the request type for the + * Query/QueryPacketAcknowledgements RPC method + */ +export interface QueryPacketAcknowledgementsResponse { + acknowledgements: PacketState[]; + /** pagination response */ + pagination: PageResponse | undefined; + /** query block height */ + height: Height | undefined; +} + +/** + * QueryUnreceivedPacketsRequest is the request type for the + * Query/UnreceivedPackets RPC method + */ +export interface QueryUnreceivedPacketsRequest { + /** port unique identifier */ + portId: string; + /** channel unique identifier */ + channelId: string; + /** list of packet sequences */ + packetCommitmentSequences: number[]; +} + +/** + * QueryUnreceivedPacketsResponse is the response type for the + * Query/UnreceivedPacketCommitments RPC method + */ +export interface QueryUnreceivedPacketsResponse { + /** list of unreceived packet sequences */ + sequences: number[]; + /** query block height */ + height: Height | undefined; +} + +/** + * QueryUnreceivedAcks is the request type for the + * Query/UnreceivedAcks RPC method + */ +export interface QueryUnreceivedAcksRequest { + /** port unique identifier */ + portId: string; + /** channel unique identifier */ + channelId: string; + /** list of acknowledgement sequences */ + packetAckSequences: number[]; +} + +/** + * QueryUnreceivedAcksResponse is the response type for the + * Query/UnreceivedAcks RPC method + */ +export interface QueryUnreceivedAcksResponse { + /** list of unreceived acknowledgement sequences */ + sequences: number[]; + /** query block height */ + height: Height | undefined; +} + +/** + * QueryNextSequenceReceiveRequest is the request type for the + * Query/QueryNextSequenceReceiveRequest RPC method + */ +export interface QueryNextSequenceReceiveRequest { + /** port unique identifier */ + portId: string; + /** channel unique identifier */ + channelId: string; +} + +/** + * QuerySequenceResponse is the request type for the + * Query/QueryNextSequenceReceiveResponse RPC method + */ +export interface QueryNextSequenceReceiveResponse { + /** next sequence receive number */ + nextSequenceReceive: number; + /** merkle proof of existence */ + proof: Uint8Array; + /** height at which the proof was retrieved */ + proofHeight: Height | undefined; +} + +const baseQueryChannelRequest: object = { portId: "", channelId: "" }; + +export const QueryChannelRequest = { + encode( + message: QueryChannelRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.portId !== "") { + writer.uint32(10).string(message.portId); + } + if (message.channelId !== "") { + writer.uint32(18).string(message.channelId); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QueryChannelRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryChannelRequest } as QueryChannelRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.portId = reader.string(); + break; + case 2: + message.channelId = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryChannelRequest { + const message = { ...baseQueryChannelRequest } as QueryChannelRequest; + if (object.portId !== undefined && object.portId !== null) { + message.portId = String(object.portId); + } else { + message.portId = ""; + } + if (object.channelId !== undefined && object.channelId !== null) { + message.channelId = String(object.channelId); + } else { + message.channelId = ""; + } + return message; + }, + + toJSON(message: QueryChannelRequest): unknown { + const obj: any = {}; + message.portId !== undefined && (obj.portId = message.portId); + message.channelId !== undefined && (obj.channelId = message.channelId); + return obj; + }, + + fromPartial(object: DeepPartial): QueryChannelRequest { + const message = { ...baseQueryChannelRequest } as QueryChannelRequest; + if (object.portId !== undefined && object.portId !== null) { + message.portId = object.portId; + } else { + message.portId = ""; + } + if (object.channelId !== undefined && object.channelId !== null) { + message.channelId = object.channelId; + } else { + message.channelId = ""; + } + return message; + }, +}; + +const baseQueryChannelResponse: object = {}; + +export const QueryChannelResponse = { + encode( + message: QueryChannelResponse, + writer: Writer = Writer.create() + ): Writer { + if (message.channel !== undefined) { + Channel.encode(message.channel, writer.uint32(10).fork()).ldelim(); + } + if (message.proof.length !== 0) { + writer.uint32(18).bytes(message.proof); + } + if (message.proofHeight !== undefined) { + Height.encode(message.proofHeight, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QueryChannelResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryChannelResponse } as QueryChannelResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.channel = Channel.decode(reader, reader.uint32()); + break; + case 2: + message.proof = reader.bytes(); + break; + case 3: + message.proofHeight = Height.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryChannelResponse { + const message = { ...baseQueryChannelResponse } as QueryChannelResponse; + if (object.channel !== undefined && object.channel !== null) { + message.channel = Channel.fromJSON(object.channel); + } else { + message.channel = undefined; + } + if (object.proof !== undefined && object.proof !== null) { + message.proof = bytesFromBase64(object.proof); + } + if (object.proofHeight !== undefined && object.proofHeight !== null) { + message.proofHeight = Height.fromJSON(object.proofHeight); + } else { + message.proofHeight = undefined; + } + return message; + }, + + toJSON(message: QueryChannelResponse): unknown { + const obj: any = {}; + message.channel !== undefined && + (obj.channel = message.channel + ? Channel.toJSON(message.channel) + : undefined); + message.proof !== undefined && + (obj.proof = base64FromBytes( + message.proof !== undefined ? message.proof : new Uint8Array() + )); + message.proofHeight !== undefined && + (obj.proofHeight = message.proofHeight + ? Height.toJSON(message.proofHeight) + : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): QueryChannelResponse { + const message = { ...baseQueryChannelResponse } as QueryChannelResponse; + if (object.channel !== undefined && object.channel !== null) { + message.channel = Channel.fromPartial(object.channel); + } else { + message.channel = undefined; + } + if (object.proof !== undefined && object.proof !== null) { + message.proof = object.proof; + } else { + message.proof = new Uint8Array(); + } + if (object.proofHeight !== undefined && object.proofHeight !== null) { + message.proofHeight = Height.fromPartial(object.proofHeight); + } else { + message.proofHeight = undefined; + } + return message; + }, +}; + +const baseQueryChannelsRequest: object = {}; + +export const QueryChannelsRequest = { + encode( + message: QueryChannelsRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QueryChannelsRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryChannelsRequest } as QueryChannelsRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryChannelsRequest { + const message = { ...baseQueryChannelsRequest } as QueryChannelsRequest; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryChannelsRequest): unknown { + const obj: any = {}; + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageRequest.toJSON(message.pagination) + : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): QueryChannelsRequest { + const message = { ...baseQueryChannelsRequest } as QueryChannelsRequest; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseQueryChannelsResponse: object = {}; + +export const QueryChannelsResponse = { + encode( + message: QueryChannelsResponse, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.channels) { + IdentifiedChannel.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode( + message.pagination, + writer.uint32(18).fork() + ).ldelim(); + } + if (message.height !== undefined) { + Height.encode(message.height, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QueryChannelsResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryChannelsResponse } as QueryChannelsResponse; + message.channels = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.channels.push( + IdentifiedChannel.decode(reader, reader.uint32()) + ); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + case 3: + message.height = Height.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryChannelsResponse { + const message = { ...baseQueryChannelsResponse } as QueryChannelsResponse; + message.channels = []; + if (object.channels !== undefined && object.channels !== null) { + for (const e of object.channels) { + message.channels.push(IdentifiedChannel.fromJSON(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + if (object.height !== undefined && object.height !== null) { + message.height = Height.fromJSON(object.height); + } else { + message.height = undefined; + } + return message; + }, + + toJSON(message: QueryChannelsResponse): unknown { + const obj: any = {}; + if (message.channels) { + obj.channels = message.channels.map((e) => + e ? IdentifiedChannel.toJSON(e) : undefined + ); + } else { + obj.channels = []; + } + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageResponse.toJSON(message.pagination) + : undefined); + message.height !== undefined && + (obj.height = message.height ? Height.toJSON(message.height) : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryChannelsResponse { + const message = { ...baseQueryChannelsResponse } as QueryChannelsResponse; + message.channels = []; + if (object.channels !== undefined && object.channels !== null) { + for (const e of object.channels) { + message.channels.push(IdentifiedChannel.fromPartial(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + if (object.height !== undefined && object.height !== null) { + message.height = Height.fromPartial(object.height); + } else { + message.height = undefined; + } + return message; + }, +}; + +const baseQueryConnectionChannelsRequest: object = { connection: "" }; + +export const QueryConnectionChannelsRequest = { + encode( + message: QueryConnectionChannelsRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.connection !== "") { + writer.uint32(10).string(message.connection); + } + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryConnectionChannelsRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryConnectionChannelsRequest, + } as QueryConnectionChannelsRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.connection = reader.string(); + break; + case 2: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryConnectionChannelsRequest { + const message = { + ...baseQueryConnectionChannelsRequest, + } as QueryConnectionChannelsRequest; + if (object.connection !== undefined && object.connection !== null) { + message.connection = String(object.connection); + } else { + message.connection = ""; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryConnectionChannelsRequest): unknown { + const obj: any = {}; + message.connection !== undefined && (obj.connection = message.connection); + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageRequest.toJSON(message.pagination) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryConnectionChannelsRequest { + const message = { + ...baseQueryConnectionChannelsRequest, + } as QueryConnectionChannelsRequest; + if (object.connection !== undefined && object.connection !== null) { + message.connection = object.connection; + } else { + message.connection = ""; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseQueryConnectionChannelsResponse: object = {}; + +export const QueryConnectionChannelsResponse = { + encode( + message: QueryConnectionChannelsResponse, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.channels) { + IdentifiedChannel.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode( + message.pagination, + writer.uint32(18).fork() + ).ldelim(); + } + if (message.height !== undefined) { + Height.encode(message.height, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryConnectionChannelsResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryConnectionChannelsResponse, + } as QueryConnectionChannelsResponse; + message.channels = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.channels.push( + IdentifiedChannel.decode(reader, reader.uint32()) + ); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + case 3: + message.height = Height.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryConnectionChannelsResponse { + const message = { + ...baseQueryConnectionChannelsResponse, + } as QueryConnectionChannelsResponse; + message.channels = []; + if (object.channels !== undefined && object.channels !== null) { + for (const e of object.channels) { + message.channels.push(IdentifiedChannel.fromJSON(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + if (object.height !== undefined && object.height !== null) { + message.height = Height.fromJSON(object.height); + } else { + message.height = undefined; + } + return message; + }, + + toJSON(message: QueryConnectionChannelsResponse): unknown { + const obj: any = {}; + if (message.channels) { + obj.channels = message.channels.map((e) => + e ? IdentifiedChannel.toJSON(e) : undefined + ); + } else { + obj.channels = []; + } + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageResponse.toJSON(message.pagination) + : undefined); + message.height !== undefined && + (obj.height = message.height ? Height.toJSON(message.height) : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryConnectionChannelsResponse { + const message = { + ...baseQueryConnectionChannelsResponse, + } as QueryConnectionChannelsResponse; + message.channels = []; + if (object.channels !== undefined && object.channels !== null) { + for (const e of object.channels) { + message.channels.push(IdentifiedChannel.fromPartial(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + if (object.height !== undefined && object.height !== null) { + message.height = Height.fromPartial(object.height); + } else { + message.height = undefined; + } + return message; + }, +}; + +const baseQueryChannelClientStateRequest: object = { + portId: "", + channelId: "", +}; + +export const QueryChannelClientStateRequest = { + encode( + message: QueryChannelClientStateRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.portId !== "") { + writer.uint32(10).string(message.portId); + } + if (message.channelId !== "") { + writer.uint32(18).string(message.channelId); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryChannelClientStateRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryChannelClientStateRequest, + } as QueryChannelClientStateRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.portId = reader.string(); + break; + case 2: + message.channelId = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryChannelClientStateRequest { + const message = { + ...baseQueryChannelClientStateRequest, + } as QueryChannelClientStateRequest; + if (object.portId !== undefined && object.portId !== null) { + message.portId = String(object.portId); + } else { + message.portId = ""; + } + if (object.channelId !== undefined && object.channelId !== null) { + message.channelId = String(object.channelId); + } else { + message.channelId = ""; + } + return message; + }, + + toJSON(message: QueryChannelClientStateRequest): unknown { + const obj: any = {}; + message.portId !== undefined && (obj.portId = message.portId); + message.channelId !== undefined && (obj.channelId = message.channelId); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryChannelClientStateRequest { + const message = { + ...baseQueryChannelClientStateRequest, + } as QueryChannelClientStateRequest; + if (object.portId !== undefined && object.portId !== null) { + message.portId = object.portId; + } else { + message.portId = ""; + } + if (object.channelId !== undefined && object.channelId !== null) { + message.channelId = object.channelId; + } else { + message.channelId = ""; + } + return message; + }, +}; + +const baseQueryChannelClientStateResponse: object = {}; + +export const QueryChannelClientStateResponse = { + encode( + message: QueryChannelClientStateResponse, + writer: Writer = Writer.create() + ): Writer { + if (message.identifiedClientState !== undefined) { + IdentifiedClientState.encode( + message.identifiedClientState, + writer.uint32(10).fork() + ).ldelim(); + } + if (message.proof.length !== 0) { + writer.uint32(18).bytes(message.proof); + } + if (message.proofHeight !== undefined) { + Height.encode(message.proofHeight, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryChannelClientStateResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryChannelClientStateResponse, + } as QueryChannelClientStateResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.identifiedClientState = IdentifiedClientState.decode( + reader, + reader.uint32() + ); + break; + case 2: + message.proof = reader.bytes(); + break; + case 3: + message.proofHeight = Height.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryChannelClientStateResponse { + const message = { + ...baseQueryChannelClientStateResponse, + } as QueryChannelClientStateResponse; + if ( + object.identifiedClientState !== undefined && + object.identifiedClientState !== null + ) { + message.identifiedClientState = IdentifiedClientState.fromJSON( + object.identifiedClientState + ); + } else { + message.identifiedClientState = undefined; + } + if (object.proof !== undefined && object.proof !== null) { + message.proof = bytesFromBase64(object.proof); + } + if (object.proofHeight !== undefined && object.proofHeight !== null) { + message.proofHeight = Height.fromJSON(object.proofHeight); + } else { + message.proofHeight = undefined; + } + return message; + }, + + toJSON(message: QueryChannelClientStateResponse): unknown { + const obj: any = {}; + message.identifiedClientState !== undefined && + (obj.identifiedClientState = message.identifiedClientState + ? IdentifiedClientState.toJSON(message.identifiedClientState) + : undefined); + message.proof !== undefined && + (obj.proof = base64FromBytes( + message.proof !== undefined ? message.proof : new Uint8Array() + )); + message.proofHeight !== undefined && + (obj.proofHeight = message.proofHeight + ? Height.toJSON(message.proofHeight) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryChannelClientStateResponse { + const message = { + ...baseQueryChannelClientStateResponse, + } as QueryChannelClientStateResponse; + if ( + object.identifiedClientState !== undefined && + object.identifiedClientState !== null + ) { + message.identifiedClientState = IdentifiedClientState.fromPartial( + object.identifiedClientState + ); + } else { + message.identifiedClientState = undefined; + } + if (object.proof !== undefined && object.proof !== null) { + message.proof = object.proof; + } else { + message.proof = new Uint8Array(); + } + if (object.proofHeight !== undefined && object.proofHeight !== null) { + message.proofHeight = Height.fromPartial(object.proofHeight); + } else { + message.proofHeight = undefined; + } + return message; + }, +}; + +const baseQueryChannelConsensusStateRequest: object = { + portId: "", + channelId: "", + revisionNumber: 0, + revisionHeight: 0, +}; + +export const QueryChannelConsensusStateRequest = { + encode( + message: QueryChannelConsensusStateRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.portId !== "") { + writer.uint32(10).string(message.portId); + } + if (message.channelId !== "") { + writer.uint32(18).string(message.channelId); + } + if (message.revisionNumber !== 0) { + writer.uint32(24).uint64(message.revisionNumber); + } + if (message.revisionHeight !== 0) { + writer.uint32(32).uint64(message.revisionHeight); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryChannelConsensusStateRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryChannelConsensusStateRequest, + } as QueryChannelConsensusStateRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.portId = reader.string(); + break; + case 2: + message.channelId = reader.string(); + break; + case 3: + message.revisionNumber = longToNumber(reader.uint64() as Long); + break; + case 4: + message.revisionHeight = longToNumber(reader.uint64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryChannelConsensusStateRequest { + const message = { + ...baseQueryChannelConsensusStateRequest, + } as QueryChannelConsensusStateRequest; + if (object.portId !== undefined && object.portId !== null) { + message.portId = String(object.portId); + } else { + message.portId = ""; + } + if (object.channelId !== undefined && object.channelId !== null) { + message.channelId = String(object.channelId); + } else { + message.channelId = ""; + } + if (object.revisionNumber !== undefined && object.revisionNumber !== null) { + message.revisionNumber = Number(object.revisionNumber); + } else { + message.revisionNumber = 0; + } + if (object.revisionHeight !== undefined && object.revisionHeight !== null) { + message.revisionHeight = Number(object.revisionHeight); + } else { + message.revisionHeight = 0; + } + return message; + }, + + toJSON(message: QueryChannelConsensusStateRequest): unknown { + const obj: any = {}; + message.portId !== undefined && (obj.portId = message.portId); + message.channelId !== undefined && (obj.channelId = message.channelId); + message.revisionNumber !== undefined && + (obj.revisionNumber = message.revisionNumber); + message.revisionHeight !== undefined && + (obj.revisionHeight = message.revisionHeight); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryChannelConsensusStateRequest { + const message = { + ...baseQueryChannelConsensusStateRequest, + } as QueryChannelConsensusStateRequest; + if (object.portId !== undefined && object.portId !== null) { + message.portId = object.portId; + } else { + message.portId = ""; + } + if (object.channelId !== undefined && object.channelId !== null) { + message.channelId = object.channelId; + } else { + message.channelId = ""; + } + if (object.revisionNumber !== undefined && object.revisionNumber !== null) { + message.revisionNumber = object.revisionNumber; + } else { + message.revisionNumber = 0; + } + if (object.revisionHeight !== undefined && object.revisionHeight !== null) { + message.revisionHeight = object.revisionHeight; + } else { + message.revisionHeight = 0; + } + return message; + }, +}; + +const baseQueryChannelConsensusStateResponse: object = { clientId: "" }; + +export const QueryChannelConsensusStateResponse = { + encode( + message: QueryChannelConsensusStateResponse, + writer: Writer = Writer.create() + ): Writer { + if (message.consensusState !== undefined) { + Any.encode(message.consensusState, writer.uint32(10).fork()).ldelim(); + } + if (message.clientId !== "") { + writer.uint32(18).string(message.clientId); + } + if (message.proof.length !== 0) { + writer.uint32(26).bytes(message.proof); + } + if (message.proofHeight !== undefined) { + Height.encode(message.proofHeight, writer.uint32(34).fork()).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryChannelConsensusStateResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryChannelConsensusStateResponse, + } as QueryChannelConsensusStateResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.consensusState = Any.decode(reader, reader.uint32()); + break; + case 2: + message.clientId = reader.string(); + break; + case 3: + message.proof = reader.bytes(); + break; + case 4: + message.proofHeight = Height.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryChannelConsensusStateResponse { + const message = { + ...baseQueryChannelConsensusStateResponse, + } as QueryChannelConsensusStateResponse; + if (object.consensusState !== undefined && object.consensusState !== null) { + message.consensusState = Any.fromJSON(object.consensusState); + } else { + message.consensusState = undefined; + } + if (object.clientId !== undefined && object.clientId !== null) { + message.clientId = String(object.clientId); + } else { + message.clientId = ""; + } + if (object.proof !== undefined && object.proof !== null) { + message.proof = bytesFromBase64(object.proof); + } + if (object.proofHeight !== undefined && object.proofHeight !== null) { + message.proofHeight = Height.fromJSON(object.proofHeight); + } else { + message.proofHeight = undefined; + } + return message; + }, + + toJSON(message: QueryChannelConsensusStateResponse): unknown { + const obj: any = {}; + message.consensusState !== undefined && + (obj.consensusState = message.consensusState + ? Any.toJSON(message.consensusState) + : undefined); + message.clientId !== undefined && (obj.clientId = message.clientId); + message.proof !== undefined && + (obj.proof = base64FromBytes( + message.proof !== undefined ? message.proof : new Uint8Array() + )); + message.proofHeight !== undefined && + (obj.proofHeight = message.proofHeight + ? Height.toJSON(message.proofHeight) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryChannelConsensusStateResponse { + const message = { + ...baseQueryChannelConsensusStateResponse, + } as QueryChannelConsensusStateResponse; + if (object.consensusState !== undefined && object.consensusState !== null) { + message.consensusState = Any.fromPartial(object.consensusState); + } else { + message.consensusState = undefined; + } + if (object.clientId !== undefined && object.clientId !== null) { + message.clientId = object.clientId; + } else { + message.clientId = ""; + } + if (object.proof !== undefined && object.proof !== null) { + message.proof = object.proof; + } else { + message.proof = new Uint8Array(); + } + if (object.proofHeight !== undefined && object.proofHeight !== null) { + message.proofHeight = Height.fromPartial(object.proofHeight); + } else { + message.proofHeight = undefined; + } + return message; + }, +}; + +const baseQueryPacketCommitmentRequest: object = { + portId: "", + channelId: "", + sequence: 0, +}; + +export const QueryPacketCommitmentRequest = { + encode( + message: QueryPacketCommitmentRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.portId !== "") { + writer.uint32(10).string(message.portId); + } + if (message.channelId !== "") { + writer.uint32(18).string(message.channelId); + } + if (message.sequence !== 0) { + writer.uint32(24).uint64(message.sequence); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryPacketCommitmentRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryPacketCommitmentRequest, + } as QueryPacketCommitmentRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.portId = reader.string(); + break; + case 2: + message.channelId = reader.string(); + break; + case 3: + message.sequence = longToNumber(reader.uint64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryPacketCommitmentRequest { + const message = { + ...baseQueryPacketCommitmentRequest, + } as QueryPacketCommitmentRequest; + if (object.portId !== undefined && object.portId !== null) { + message.portId = String(object.portId); + } else { + message.portId = ""; + } + if (object.channelId !== undefined && object.channelId !== null) { + message.channelId = String(object.channelId); + } else { + message.channelId = ""; + } + if (object.sequence !== undefined && object.sequence !== null) { + message.sequence = Number(object.sequence); + } else { + message.sequence = 0; + } + return message; + }, + + toJSON(message: QueryPacketCommitmentRequest): unknown { + const obj: any = {}; + message.portId !== undefined && (obj.portId = message.portId); + message.channelId !== undefined && (obj.channelId = message.channelId); + message.sequence !== undefined && (obj.sequence = message.sequence); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryPacketCommitmentRequest { + const message = { + ...baseQueryPacketCommitmentRequest, + } as QueryPacketCommitmentRequest; + if (object.portId !== undefined && object.portId !== null) { + message.portId = object.portId; + } else { + message.portId = ""; + } + if (object.channelId !== undefined && object.channelId !== null) { + message.channelId = object.channelId; + } else { + message.channelId = ""; + } + if (object.sequence !== undefined && object.sequence !== null) { + message.sequence = object.sequence; + } else { + message.sequence = 0; + } + return message; + }, +}; + +const baseQueryPacketCommitmentResponse: object = {}; + +export const QueryPacketCommitmentResponse = { + encode( + message: QueryPacketCommitmentResponse, + writer: Writer = Writer.create() + ): Writer { + if (message.commitment.length !== 0) { + writer.uint32(10).bytes(message.commitment); + } + if (message.proof.length !== 0) { + writer.uint32(18).bytes(message.proof); + } + if (message.proofHeight !== undefined) { + Height.encode(message.proofHeight, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryPacketCommitmentResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryPacketCommitmentResponse, + } as QueryPacketCommitmentResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.commitment = reader.bytes(); + break; + case 2: + message.proof = reader.bytes(); + break; + case 3: + message.proofHeight = Height.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryPacketCommitmentResponse { + const message = { + ...baseQueryPacketCommitmentResponse, + } as QueryPacketCommitmentResponse; + if (object.commitment !== undefined && object.commitment !== null) { + message.commitment = bytesFromBase64(object.commitment); + } + if (object.proof !== undefined && object.proof !== null) { + message.proof = bytesFromBase64(object.proof); + } + if (object.proofHeight !== undefined && object.proofHeight !== null) { + message.proofHeight = Height.fromJSON(object.proofHeight); + } else { + message.proofHeight = undefined; + } + return message; + }, + + toJSON(message: QueryPacketCommitmentResponse): unknown { + const obj: any = {}; + message.commitment !== undefined && + (obj.commitment = base64FromBytes( + message.commitment !== undefined ? message.commitment : new Uint8Array() + )); + message.proof !== undefined && + (obj.proof = base64FromBytes( + message.proof !== undefined ? message.proof : new Uint8Array() + )); + message.proofHeight !== undefined && + (obj.proofHeight = message.proofHeight + ? Height.toJSON(message.proofHeight) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryPacketCommitmentResponse { + const message = { + ...baseQueryPacketCommitmentResponse, + } as QueryPacketCommitmentResponse; + if (object.commitment !== undefined && object.commitment !== null) { + message.commitment = object.commitment; + } else { + message.commitment = new Uint8Array(); + } + if (object.proof !== undefined && object.proof !== null) { + message.proof = object.proof; + } else { + message.proof = new Uint8Array(); + } + if (object.proofHeight !== undefined && object.proofHeight !== null) { + message.proofHeight = Height.fromPartial(object.proofHeight); + } else { + message.proofHeight = undefined; + } + return message; + }, +}; + +const baseQueryPacketCommitmentsRequest: object = { portId: "", channelId: "" }; + +export const QueryPacketCommitmentsRequest = { + encode( + message: QueryPacketCommitmentsRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.portId !== "") { + writer.uint32(10).string(message.portId); + } + if (message.channelId !== "") { + writer.uint32(18).string(message.channelId); + } + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryPacketCommitmentsRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryPacketCommitmentsRequest, + } as QueryPacketCommitmentsRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.portId = reader.string(); + break; + case 2: + message.channelId = reader.string(); + break; + case 3: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryPacketCommitmentsRequest { + const message = { + ...baseQueryPacketCommitmentsRequest, + } as QueryPacketCommitmentsRequest; + if (object.portId !== undefined && object.portId !== null) { + message.portId = String(object.portId); + } else { + message.portId = ""; + } + if (object.channelId !== undefined && object.channelId !== null) { + message.channelId = String(object.channelId); + } else { + message.channelId = ""; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryPacketCommitmentsRequest): unknown { + const obj: any = {}; + message.portId !== undefined && (obj.portId = message.portId); + message.channelId !== undefined && (obj.channelId = message.channelId); + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageRequest.toJSON(message.pagination) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryPacketCommitmentsRequest { + const message = { + ...baseQueryPacketCommitmentsRequest, + } as QueryPacketCommitmentsRequest; + if (object.portId !== undefined && object.portId !== null) { + message.portId = object.portId; + } else { + message.portId = ""; + } + if (object.channelId !== undefined && object.channelId !== null) { + message.channelId = object.channelId; + } else { + message.channelId = ""; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseQueryPacketCommitmentsResponse: object = {}; + +export const QueryPacketCommitmentsResponse = { + encode( + message: QueryPacketCommitmentsResponse, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.commitments) { + PacketState.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode( + message.pagination, + writer.uint32(18).fork() + ).ldelim(); + } + if (message.height !== undefined) { + Height.encode(message.height, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryPacketCommitmentsResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryPacketCommitmentsResponse, + } as QueryPacketCommitmentsResponse; + message.commitments = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.commitments.push(PacketState.decode(reader, reader.uint32())); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + case 3: + message.height = Height.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryPacketCommitmentsResponse { + const message = { + ...baseQueryPacketCommitmentsResponse, + } as QueryPacketCommitmentsResponse; + message.commitments = []; + if (object.commitments !== undefined && object.commitments !== null) { + for (const e of object.commitments) { + message.commitments.push(PacketState.fromJSON(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + if (object.height !== undefined && object.height !== null) { + message.height = Height.fromJSON(object.height); + } else { + message.height = undefined; + } + return message; + }, + + toJSON(message: QueryPacketCommitmentsResponse): unknown { + const obj: any = {}; + if (message.commitments) { + obj.commitments = message.commitments.map((e) => + e ? PacketState.toJSON(e) : undefined + ); + } else { + obj.commitments = []; + } + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageResponse.toJSON(message.pagination) + : undefined); + message.height !== undefined && + (obj.height = message.height ? Height.toJSON(message.height) : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryPacketCommitmentsResponse { + const message = { + ...baseQueryPacketCommitmentsResponse, + } as QueryPacketCommitmentsResponse; + message.commitments = []; + if (object.commitments !== undefined && object.commitments !== null) { + for (const e of object.commitments) { + message.commitments.push(PacketState.fromPartial(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + if (object.height !== undefined && object.height !== null) { + message.height = Height.fromPartial(object.height); + } else { + message.height = undefined; + } + return message; + }, +}; + +const baseQueryPacketReceiptRequest: object = { + portId: "", + channelId: "", + sequence: 0, +}; + +export const QueryPacketReceiptRequest = { + encode( + message: QueryPacketReceiptRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.portId !== "") { + writer.uint32(10).string(message.portId); + } + if (message.channelId !== "") { + writer.uint32(18).string(message.channelId); + } + if (message.sequence !== 0) { + writer.uint32(24).uint64(message.sequence); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryPacketReceiptRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryPacketReceiptRequest, + } as QueryPacketReceiptRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.portId = reader.string(); + break; + case 2: + message.channelId = reader.string(); + break; + case 3: + message.sequence = longToNumber(reader.uint64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryPacketReceiptRequest { + const message = { + ...baseQueryPacketReceiptRequest, + } as QueryPacketReceiptRequest; + if (object.portId !== undefined && object.portId !== null) { + message.portId = String(object.portId); + } else { + message.portId = ""; + } + if (object.channelId !== undefined && object.channelId !== null) { + message.channelId = String(object.channelId); + } else { + message.channelId = ""; + } + if (object.sequence !== undefined && object.sequence !== null) { + message.sequence = Number(object.sequence); + } else { + message.sequence = 0; + } + return message; + }, + + toJSON(message: QueryPacketReceiptRequest): unknown { + const obj: any = {}; + message.portId !== undefined && (obj.portId = message.portId); + message.channelId !== undefined && (obj.channelId = message.channelId); + message.sequence !== undefined && (obj.sequence = message.sequence); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryPacketReceiptRequest { + const message = { + ...baseQueryPacketReceiptRequest, + } as QueryPacketReceiptRequest; + if (object.portId !== undefined && object.portId !== null) { + message.portId = object.portId; + } else { + message.portId = ""; + } + if (object.channelId !== undefined && object.channelId !== null) { + message.channelId = object.channelId; + } else { + message.channelId = ""; + } + if (object.sequence !== undefined && object.sequence !== null) { + message.sequence = object.sequence; + } else { + message.sequence = 0; + } + return message; + }, +}; + +const baseQueryPacketReceiptResponse: object = { received: false }; + +export const QueryPacketReceiptResponse = { + encode( + message: QueryPacketReceiptResponse, + writer: Writer = Writer.create() + ): Writer { + if (message.received === true) { + writer.uint32(16).bool(message.received); + } + if (message.proof.length !== 0) { + writer.uint32(26).bytes(message.proof); + } + if (message.proofHeight !== undefined) { + Height.encode(message.proofHeight, writer.uint32(34).fork()).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryPacketReceiptResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryPacketReceiptResponse, + } as QueryPacketReceiptResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + message.received = reader.bool(); + break; + case 3: + message.proof = reader.bytes(); + break; + case 4: + message.proofHeight = Height.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryPacketReceiptResponse { + const message = { + ...baseQueryPacketReceiptResponse, + } as QueryPacketReceiptResponse; + if (object.received !== undefined && object.received !== null) { + message.received = Boolean(object.received); + } else { + message.received = false; + } + if (object.proof !== undefined && object.proof !== null) { + message.proof = bytesFromBase64(object.proof); + } + if (object.proofHeight !== undefined && object.proofHeight !== null) { + message.proofHeight = Height.fromJSON(object.proofHeight); + } else { + message.proofHeight = undefined; + } + return message; + }, + + toJSON(message: QueryPacketReceiptResponse): unknown { + const obj: any = {}; + message.received !== undefined && (obj.received = message.received); + message.proof !== undefined && + (obj.proof = base64FromBytes( + message.proof !== undefined ? message.proof : new Uint8Array() + )); + message.proofHeight !== undefined && + (obj.proofHeight = message.proofHeight + ? Height.toJSON(message.proofHeight) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryPacketReceiptResponse { + const message = { + ...baseQueryPacketReceiptResponse, + } as QueryPacketReceiptResponse; + if (object.received !== undefined && object.received !== null) { + message.received = object.received; + } else { + message.received = false; + } + if (object.proof !== undefined && object.proof !== null) { + message.proof = object.proof; + } else { + message.proof = new Uint8Array(); + } + if (object.proofHeight !== undefined && object.proofHeight !== null) { + message.proofHeight = Height.fromPartial(object.proofHeight); + } else { + message.proofHeight = undefined; + } + return message; + }, +}; + +const baseQueryPacketAcknowledgementRequest: object = { + portId: "", + channelId: "", + sequence: 0, +}; + +export const QueryPacketAcknowledgementRequest = { + encode( + message: QueryPacketAcknowledgementRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.portId !== "") { + writer.uint32(10).string(message.portId); + } + if (message.channelId !== "") { + writer.uint32(18).string(message.channelId); + } + if (message.sequence !== 0) { + writer.uint32(24).uint64(message.sequence); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryPacketAcknowledgementRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryPacketAcknowledgementRequest, + } as QueryPacketAcknowledgementRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.portId = reader.string(); + break; + case 2: + message.channelId = reader.string(); + break; + case 3: + message.sequence = longToNumber(reader.uint64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryPacketAcknowledgementRequest { + const message = { + ...baseQueryPacketAcknowledgementRequest, + } as QueryPacketAcknowledgementRequest; + if (object.portId !== undefined && object.portId !== null) { + message.portId = String(object.portId); + } else { + message.portId = ""; + } + if (object.channelId !== undefined && object.channelId !== null) { + message.channelId = String(object.channelId); + } else { + message.channelId = ""; + } + if (object.sequence !== undefined && object.sequence !== null) { + message.sequence = Number(object.sequence); + } else { + message.sequence = 0; + } + return message; + }, + + toJSON(message: QueryPacketAcknowledgementRequest): unknown { + const obj: any = {}; + message.portId !== undefined && (obj.portId = message.portId); + message.channelId !== undefined && (obj.channelId = message.channelId); + message.sequence !== undefined && (obj.sequence = message.sequence); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryPacketAcknowledgementRequest { + const message = { + ...baseQueryPacketAcknowledgementRequest, + } as QueryPacketAcknowledgementRequest; + if (object.portId !== undefined && object.portId !== null) { + message.portId = object.portId; + } else { + message.portId = ""; + } + if (object.channelId !== undefined && object.channelId !== null) { + message.channelId = object.channelId; + } else { + message.channelId = ""; + } + if (object.sequence !== undefined && object.sequence !== null) { + message.sequence = object.sequence; + } else { + message.sequence = 0; + } + return message; + }, +}; + +const baseQueryPacketAcknowledgementResponse: object = {}; + +export const QueryPacketAcknowledgementResponse = { + encode( + message: QueryPacketAcknowledgementResponse, + writer: Writer = Writer.create() + ): Writer { + if (message.acknowledgement.length !== 0) { + writer.uint32(10).bytes(message.acknowledgement); + } + if (message.proof.length !== 0) { + writer.uint32(18).bytes(message.proof); + } + if (message.proofHeight !== undefined) { + Height.encode(message.proofHeight, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryPacketAcknowledgementResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryPacketAcknowledgementResponse, + } as QueryPacketAcknowledgementResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.acknowledgement = reader.bytes(); + break; + case 2: + message.proof = reader.bytes(); + break; + case 3: + message.proofHeight = Height.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryPacketAcknowledgementResponse { + const message = { + ...baseQueryPacketAcknowledgementResponse, + } as QueryPacketAcknowledgementResponse; + if ( + object.acknowledgement !== undefined && + object.acknowledgement !== null + ) { + message.acknowledgement = bytesFromBase64(object.acknowledgement); + } + if (object.proof !== undefined && object.proof !== null) { + message.proof = bytesFromBase64(object.proof); + } + if (object.proofHeight !== undefined && object.proofHeight !== null) { + message.proofHeight = Height.fromJSON(object.proofHeight); + } else { + message.proofHeight = undefined; + } + return message; + }, + + toJSON(message: QueryPacketAcknowledgementResponse): unknown { + const obj: any = {}; + message.acknowledgement !== undefined && + (obj.acknowledgement = base64FromBytes( + message.acknowledgement !== undefined + ? message.acknowledgement + : new Uint8Array() + )); + message.proof !== undefined && + (obj.proof = base64FromBytes( + message.proof !== undefined ? message.proof : new Uint8Array() + )); + message.proofHeight !== undefined && + (obj.proofHeight = message.proofHeight + ? Height.toJSON(message.proofHeight) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryPacketAcknowledgementResponse { + const message = { + ...baseQueryPacketAcknowledgementResponse, + } as QueryPacketAcknowledgementResponse; + if ( + object.acknowledgement !== undefined && + object.acknowledgement !== null + ) { + message.acknowledgement = object.acknowledgement; + } else { + message.acknowledgement = new Uint8Array(); + } + if (object.proof !== undefined && object.proof !== null) { + message.proof = object.proof; + } else { + message.proof = new Uint8Array(); + } + if (object.proofHeight !== undefined && object.proofHeight !== null) { + message.proofHeight = Height.fromPartial(object.proofHeight); + } else { + message.proofHeight = undefined; + } + return message; + }, +}; + +const baseQueryPacketAcknowledgementsRequest: object = { + portId: "", + channelId: "", + packetCommitmentSequences: 0, +}; + +export const QueryPacketAcknowledgementsRequest = { + encode( + message: QueryPacketAcknowledgementsRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.portId !== "") { + writer.uint32(10).string(message.portId); + } + if (message.channelId !== "") { + writer.uint32(18).string(message.channelId); + } + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(26).fork()).ldelim(); + } + writer.uint32(34).fork(); + for (const v of message.packetCommitmentSequences) { + writer.uint64(v); + } + writer.ldelim(); + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryPacketAcknowledgementsRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryPacketAcknowledgementsRequest, + } as QueryPacketAcknowledgementsRequest; + message.packetCommitmentSequences = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.portId = reader.string(); + break; + case 2: + message.channelId = reader.string(); + break; + case 3: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + case 4: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.packetCommitmentSequences.push( + longToNumber(reader.uint64() as Long) + ); + } + } else { + message.packetCommitmentSequences.push( + longToNumber(reader.uint64() as Long) + ); + } + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryPacketAcknowledgementsRequest { + const message = { + ...baseQueryPacketAcknowledgementsRequest, + } as QueryPacketAcknowledgementsRequest; + message.packetCommitmentSequences = []; + if (object.portId !== undefined && object.portId !== null) { + message.portId = String(object.portId); + } else { + message.portId = ""; + } + if (object.channelId !== undefined && object.channelId !== null) { + message.channelId = String(object.channelId); + } else { + message.channelId = ""; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + if ( + object.packetCommitmentSequences !== undefined && + object.packetCommitmentSequences !== null + ) { + for (const e of object.packetCommitmentSequences) { + message.packetCommitmentSequences.push(Number(e)); + } + } + return message; + }, + + toJSON(message: QueryPacketAcknowledgementsRequest): unknown { + const obj: any = {}; + message.portId !== undefined && (obj.portId = message.portId); + message.channelId !== undefined && (obj.channelId = message.channelId); + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageRequest.toJSON(message.pagination) + : undefined); + if (message.packetCommitmentSequences) { + obj.packetCommitmentSequences = message.packetCommitmentSequences.map( + (e) => e + ); + } else { + obj.packetCommitmentSequences = []; + } + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryPacketAcknowledgementsRequest { + const message = { + ...baseQueryPacketAcknowledgementsRequest, + } as QueryPacketAcknowledgementsRequest; + message.packetCommitmentSequences = []; + if (object.portId !== undefined && object.portId !== null) { + message.portId = object.portId; + } else { + message.portId = ""; + } + if (object.channelId !== undefined && object.channelId !== null) { + message.channelId = object.channelId; + } else { + message.channelId = ""; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + if ( + object.packetCommitmentSequences !== undefined && + object.packetCommitmentSequences !== null + ) { + for (const e of object.packetCommitmentSequences) { + message.packetCommitmentSequences.push(e); + } + } + return message; + }, +}; + +const baseQueryPacketAcknowledgementsResponse: object = {}; + +export const QueryPacketAcknowledgementsResponse = { + encode( + message: QueryPacketAcknowledgementsResponse, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.acknowledgements) { + PacketState.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode( + message.pagination, + writer.uint32(18).fork() + ).ldelim(); + } + if (message.height !== undefined) { + Height.encode(message.height, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryPacketAcknowledgementsResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryPacketAcknowledgementsResponse, + } as QueryPacketAcknowledgementsResponse; + message.acknowledgements = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.acknowledgements.push( + PacketState.decode(reader, reader.uint32()) + ); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + case 3: + message.height = Height.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryPacketAcknowledgementsResponse { + const message = { + ...baseQueryPacketAcknowledgementsResponse, + } as QueryPacketAcknowledgementsResponse; + message.acknowledgements = []; + if ( + object.acknowledgements !== undefined && + object.acknowledgements !== null + ) { + for (const e of object.acknowledgements) { + message.acknowledgements.push(PacketState.fromJSON(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + if (object.height !== undefined && object.height !== null) { + message.height = Height.fromJSON(object.height); + } else { + message.height = undefined; + } + return message; + }, + + toJSON(message: QueryPacketAcknowledgementsResponse): unknown { + const obj: any = {}; + if (message.acknowledgements) { + obj.acknowledgements = message.acknowledgements.map((e) => + e ? PacketState.toJSON(e) : undefined + ); + } else { + obj.acknowledgements = []; + } + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageResponse.toJSON(message.pagination) + : undefined); + message.height !== undefined && + (obj.height = message.height ? Height.toJSON(message.height) : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryPacketAcknowledgementsResponse { + const message = { + ...baseQueryPacketAcknowledgementsResponse, + } as QueryPacketAcknowledgementsResponse; + message.acknowledgements = []; + if ( + object.acknowledgements !== undefined && + object.acknowledgements !== null + ) { + for (const e of object.acknowledgements) { + message.acknowledgements.push(PacketState.fromPartial(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + if (object.height !== undefined && object.height !== null) { + message.height = Height.fromPartial(object.height); + } else { + message.height = undefined; + } + return message; + }, +}; + +const baseQueryUnreceivedPacketsRequest: object = { + portId: "", + channelId: "", + packetCommitmentSequences: 0, +}; + +export const QueryUnreceivedPacketsRequest = { + encode( + message: QueryUnreceivedPacketsRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.portId !== "") { + writer.uint32(10).string(message.portId); + } + if (message.channelId !== "") { + writer.uint32(18).string(message.channelId); + } + writer.uint32(26).fork(); + for (const v of message.packetCommitmentSequences) { + writer.uint64(v); + } + writer.ldelim(); + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryUnreceivedPacketsRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryUnreceivedPacketsRequest, + } as QueryUnreceivedPacketsRequest; + message.packetCommitmentSequences = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.portId = reader.string(); + break; + case 2: + message.channelId = reader.string(); + break; + case 3: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.packetCommitmentSequences.push( + longToNumber(reader.uint64() as Long) + ); + } + } else { + message.packetCommitmentSequences.push( + longToNumber(reader.uint64() as Long) + ); + } + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryUnreceivedPacketsRequest { + const message = { + ...baseQueryUnreceivedPacketsRequest, + } as QueryUnreceivedPacketsRequest; + message.packetCommitmentSequences = []; + if (object.portId !== undefined && object.portId !== null) { + message.portId = String(object.portId); + } else { + message.portId = ""; + } + if (object.channelId !== undefined && object.channelId !== null) { + message.channelId = String(object.channelId); + } else { + message.channelId = ""; + } + if ( + object.packetCommitmentSequences !== undefined && + object.packetCommitmentSequences !== null + ) { + for (const e of object.packetCommitmentSequences) { + message.packetCommitmentSequences.push(Number(e)); + } + } + return message; + }, + + toJSON(message: QueryUnreceivedPacketsRequest): unknown { + const obj: any = {}; + message.portId !== undefined && (obj.portId = message.portId); + message.channelId !== undefined && (obj.channelId = message.channelId); + if (message.packetCommitmentSequences) { + obj.packetCommitmentSequences = message.packetCommitmentSequences.map( + (e) => e + ); + } else { + obj.packetCommitmentSequences = []; + } + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryUnreceivedPacketsRequest { + const message = { + ...baseQueryUnreceivedPacketsRequest, + } as QueryUnreceivedPacketsRequest; + message.packetCommitmentSequences = []; + if (object.portId !== undefined && object.portId !== null) { + message.portId = object.portId; + } else { + message.portId = ""; + } + if (object.channelId !== undefined && object.channelId !== null) { + message.channelId = object.channelId; + } else { + message.channelId = ""; + } + if ( + object.packetCommitmentSequences !== undefined && + object.packetCommitmentSequences !== null + ) { + for (const e of object.packetCommitmentSequences) { + message.packetCommitmentSequences.push(e); + } + } + return message; + }, +}; + +const baseQueryUnreceivedPacketsResponse: object = { sequences: 0 }; + +export const QueryUnreceivedPacketsResponse = { + encode( + message: QueryUnreceivedPacketsResponse, + writer: Writer = Writer.create() + ): Writer { + writer.uint32(10).fork(); + for (const v of message.sequences) { + writer.uint64(v); + } + writer.ldelim(); + if (message.height !== undefined) { + Height.encode(message.height, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryUnreceivedPacketsResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryUnreceivedPacketsResponse, + } as QueryUnreceivedPacketsResponse; + message.sequences = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.sequences.push(longToNumber(reader.uint64() as Long)); + } + } else { + message.sequences.push(longToNumber(reader.uint64() as Long)); + } + break; + case 2: + message.height = Height.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryUnreceivedPacketsResponse { + const message = { + ...baseQueryUnreceivedPacketsResponse, + } as QueryUnreceivedPacketsResponse; + message.sequences = []; + if (object.sequences !== undefined && object.sequences !== null) { + for (const e of object.sequences) { + message.sequences.push(Number(e)); + } + } + if (object.height !== undefined && object.height !== null) { + message.height = Height.fromJSON(object.height); + } else { + message.height = undefined; + } + return message; + }, + + toJSON(message: QueryUnreceivedPacketsResponse): unknown { + const obj: any = {}; + if (message.sequences) { + obj.sequences = message.sequences.map((e) => e); + } else { + obj.sequences = []; + } + message.height !== undefined && + (obj.height = message.height ? Height.toJSON(message.height) : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryUnreceivedPacketsResponse { + const message = { + ...baseQueryUnreceivedPacketsResponse, + } as QueryUnreceivedPacketsResponse; + message.sequences = []; + if (object.sequences !== undefined && object.sequences !== null) { + for (const e of object.sequences) { + message.sequences.push(e); + } + } + if (object.height !== undefined && object.height !== null) { + message.height = Height.fromPartial(object.height); + } else { + message.height = undefined; + } + return message; + }, +}; + +const baseQueryUnreceivedAcksRequest: object = { + portId: "", + channelId: "", + packetAckSequences: 0, +}; + +export const QueryUnreceivedAcksRequest = { + encode( + message: QueryUnreceivedAcksRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.portId !== "") { + writer.uint32(10).string(message.portId); + } + if (message.channelId !== "") { + writer.uint32(18).string(message.channelId); + } + writer.uint32(26).fork(); + for (const v of message.packetAckSequences) { + writer.uint64(v); + } + writer.ldelim(); + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryUnreceivedAcksRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryUnreceivedAcksRequest, + } as QueryUnreceivedAcksRequest; + message.packetAckSequences = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.portId = reader.string(); + break; + case 2: + message.channelId = reader.string(); + break; + case 3: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.packetAckSequences.push( + longToNumber(reader.uint64() as Long) + ); + } + } else { + message.packetAckSequences.push( + longToNumber(reader.uint64() as Long) + ); + } + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryUnreceivedAcksRequest { + const message = { + ...baseQueryUnreceivedAcksRequest, + } as QueryUnreceivedAcksRequest; + message.packetAckSequences = []; + if (object.portId !== undefined && object.portId !== null) { + message.portId = String(object.portId); + } else { + message.portId = ""; + } + if (object.channelId !== undefined && object.channelId !== null) { + message.channelId = String(object.channelId); + } else { + message.channelId = ""; + } + if ( + object.packetAckSequences !== undefined && + object.packetAckSequences !== null + ) { + for (const e of object.packetAckSequences) { + message.packetAckSequences.push(Number(e)); + } + } + return message; + }, + + toJSON(message: QueryUnreceivedAcksRequest): unknown { + const obj: any = {}; + message.portId !== undefined && (obj.portId = message.portId); + message.channelId !== undefined && (obj.channelId = message.channelId); + if (message.packetAckSequences) { + obj.packetAckSequences = message.packetAckSequences.map((e) => e); + } else { + obj.packetAckSequences = []; + } + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryUnreceivedAcksRequest { + const message = { + ...baseQueryUnreceivedAcksRequest, + } as QueryUnreceivedAcksRequest; + message.packetAckSequences = []; + if (object.portId !== undefined && object.portId !== null) { + message.portId = object.portId; + } else { + message.portId = ""; + } + if (object.channelId !== undefined && object.channelId !== null) { + message.channelId = object.channelId; + } else { + message.channelId = ""; + } + if ( + object.packetAckSequences !== undefined && + object.packetAckSequences !== null + ) { + for (const e of object.packetAckSequences) { + message.packetAckSequences.push(e); + } + } + return message; + }, +}; + +const baseQueryUnreceivedAcksResponse: object = { sequences: 0 }; + +export const QueryUnreceivedAcksResponse = { + encode( + message: QueryUnreceivedAcksResponse, + writer: Writer = Writer.create() + ): Writer { + writer.uint32(10).fork(); + for (const v of message.sequences) { + writer.uint64(v); + } + writer.ldelim(); + if (message.height !== undefined) { + Height.encode(message.height, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryUnreceivedAcksResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryUnreceivedAcksResponse, + } as QueryUnreceivedAcksResponse; + message.sequences = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.sequences.push(longToNumber(reader.uint64() as Long)); + } + } else { + message.sequences.push(longToNumber(reader.uint64() as Long)); + } + break; + case 2: + message.height = Height.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryUnreceivedAcksResponse { + const message = { + ...baseQueryUnreceivedAcksResponse, + } as QueryUnreceivedAcksResponse; + message.sequences = []; + if (object.sequences !== undefined && object.sequences !== null) { + for (const e of object.sequences) { + message.sequences.push(Number(e)); + } + } + if (object.height !== undefined && object.height !== null) { + message.height = Height.fromJSON(object.height); + } else { + message.height = undefined; + } + return message; + }, + + toJSON(message: QueryUnreceivedAcksResponse): unknown { + const obj: any = {}; + if (message.sequences) { + obj.sequences = message.sequences.map((e) => e); + } else { + obj.sequences = []; + } + message.height !== undefined && + (obj.height = message.height ? Height.toJSON(message.height) : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryUnreceivedAcksResponse { + const message = { + ...baseQueryUnreceivedAcksResponse, + } as QueryUnreceivedAcksResponse; + message.sequences = []; + if (object.sequences !== undefined && object.sequences !== null) { + for (const e of object.sequences) { + message.sequences.push(e); + } + } + if (object.height !== undefined && object.height !== null) { + message.height = Height.fromPartial(object.height); + } else { + message.height = undefined; + } + return message; + }, +}; + +const baseQueryNextSequenceReceiveRequest: object = { + portId: "", + channelId: "", +}; + +export const QueryNextSequenceReceiveRequest = { + encode( + message: QueryNextSequenceReceiveRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.portId !== "") { + writer.uint32(10).string(message.portId); + } + if (message.channelId !== "") { + writer.uint32(18).string(message.channelId); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryNextSequenceReceiveRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryNextSequenceReceiveRequest, + } as QueryNextSequenceReceiveRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.portId = reader.string(); + break; + case 2: + message.channelId = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryNextSequenceReceiveRequest { + const message = { + ...baseQueryNextSequenceReceiveRequest, + } as QueryNextSequenceReceiveRequest; + if (object.portId !== undefined && object.portId !== null) { + message.portId = String(object.portId); + } else { + message.portId = ""; + } + if (object.channelId !== undefined && object.channelId !== null) { + message.channelId = String(object.channelId); + } else { + message.channelId = ""; + } + return message; + }, + + toJSON(message: QueryNextSequenceReceiveRequest): unknown { + const obj: any = {}; + message.portId !== undefined && (obj.portId = message.portId); + message.channelId !== undefined && (obj.channelId = message.channelId); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryNextSequenceReceiveRequest { + const message = { + ...baseQueryNextSequenceReceiveRequest, + } as QueryNextSequenceReceiveRequest; + if (object.portId !== undefined && object.portId !== null) { + message.portId = object.portId; + } else { + message.portId = ""; + } + if (object.channelId !== undefined && object.channelId !== null) { + message.channelId = object.channelId; + } else { + message.channelId = ""; + } + return message; + }, +}; + +const baseQueryNextSequenceReceiveResponse: object = { nextSequenceReceive: 0 }; + +export const QueryNextSequenceReceiveResponse = { + encode( + message: QueryNextSequenceReceiveResponse, + writer: Writer = Writer.create() + ): Writer { + if (message.nextSequenceReceive !== 0) { + writer.uint32(8).uint64(message.nextSequenceReceive); + } + if (message.proof.length !== 0) { + writer.uint32(18).bytes(message.proof); + } + if (message.proofHeight !== undefined) { + Height.encode(message.proofHeight, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryNextSequenceReceiveResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryNextSequenceReceiveResponse, + } as QueryNextSequenceReceiveResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.nextSequenceReceive = longToNumber(reader.uint64() as Long); + break; + case 2: + message.proof = reader.bytes(); + break; + case 3: + message.proofHeight = Height.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryNextSequenceReceiveResponse { + const message = { + ...baseQueryNextSequenceReceiveResponse, + } as QueryNextSequenceReceiveResponse; + if ( + object.nextSequenceReceive !== undefined && + object.nextSequenceReceive !== null + ) { + message.nextSequenceReceive = Number(object.nextSequenceReceive); + } else { + message.nextSequenceReceive = 0; + } + if (object.proof !== undefined && object.proof !== null) { + message.proof = bytesFromBase64(object.proof); + } + if (object.proofHeight !== undefined && object.proofHeight !== null) { + message.proofHeight = Height.fromJSON(object.proofHeight); + } else { + message.proofHeight = undefined; + } + return message; + }, + + toJSON(message: QueryNextSequenceReceiveResponse): unknown { + const obj: any = {}; + message.nextSequenceReceive !== undefined && + (obj.nextSequenceReceive = message.nextSequenceReceive); + message.proof !== undefined && + (obj.proof = base64FromBytes( + message.proof !== undefined ? message.proof : new Uint8Array() + )); + message.proofHeight !== undefined && + (obj.proofHeight = message.proofHeight + ? Height.toJSON(message.proofHeight) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryNextSequenceReceiveResponse { + const message = { + ...baseQueryNextSequenceReceiveResponse, + } as QueryNextSequenceReceiveResponse; + if ( + object.nextSequenceReceive !== undefined && + object.nextSequenceReceive !== null + ) { + message.nextSequenceReceive = object.nextSequenceReceive; + } else { + message.nextSequenceReceive = 0; + } + if (object.proof !== undefined && object.proof !== null) { + message.proof = object.proof; + } else { + message.proof = new Uint8Array(); + } + if (object.proofHeight !== undefined && object.proofHeight !== null) { + message.proofHeight = Height.fromPartial(object.proofHeight); + } else { + message.proofHeight = undefined; + } + return message; + }, +}; + +/** Query provides defines the gRPC querier service */ +export interface Query { + /** Channel queries an IBC Channel. */ + Channel(request: QueryChannelRequest): Promise; + /** Channels queries all the IBC channels of a chain. */ + Channels(request: QueryChannelsRequest): Promise; + /** + * ConnectionChannels queries all the channels associated with a connection + * end. + */ + ConnectionChannels( + request: QueryConnectionChannelsRequest + ): Promise; + /** + * ChannelClientState queries for the client state for the channel associated + * with the provided channel identifiers. + */ + ChannelClientState( + request: QueryChannelClientStateRequest + ): Promise; + /** + * ChannelConsensusState queries for the consensus state for the channel + * associated with the provided channel identifiers. + */ + ChannelConsensusState( + request: QueryChannelConsensusStateRequest + ): Promise; + /** PacketCommitment queries a stored packet commitment hash. */ + PacketCommitment( + request: QueryPacketCommitmentRequest + ): Promise; + /** + * PacketCommitments returns all the packet commitments hashes associated + * with a channel. + */ + PacketCommitments( + request: QueryPacketCommitmentsRequest + ): Promise; + /** + * PacketReceipt queries if a given packet sequence has been received on the + * queried chain + */ + PacketReceipt( + request: QueryPacketReceiptRequest + ): Promise; + /** PacketAcknowledgement queries a stored packet acknowledgement hash. */ + PacketAcknowledgement( + request: QueryPacketAcknowledgementRequest + ): Promise; + /** + * PacketAcknowledgements returns all the packet acknowledgements associated + * with a channel. + */ + PacketAcknowledgements( + request: QueryPacketAcknowledgementsRequest + ): Promise; + /** + * UnreceivedPackets returns all the unreceived IBC packets associated with a + * channel and sequences. + */ + UnreceivedPackets( + request: QueryUnreceivedPacketsRequest + ): Promise; + /** + * UnreceivedAcks returns all the unreceived IBC acknowledgements associated + * with a channel and sequences. + */ + UnreceivedAcks( + request: QueryUnreceivedAcksRequest + ): Promise; + /** NextSequenceReceive returns the next receive sequence for a given channel. */ + NextSequenceReceive( + request: QueryNextSequenceReceiveRequest + ): Promise; +} + +export class QueryClientImpl implements Query { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + } + Channel(request: QueryChannelRequest): Promise { + const data = QueryChannelRequest.encode(request).finish(); + const promise = this.rpc.request( + "ibc.core.channel.v1.Query", + "Channel", + data + ); + return promise.then((data) => + QueryChannelResponse.decode(new Reader(data)) + ); + } + + Channels(request: QueryChannelsRequest): Promise { + const data = QueryChannelsRequest.encode(request).finish(); + const promise = this.rpc.request( + "ibc.core.channel.v1.Query", + "Channels", + data + ); + return promise.then((data) => + QueryChannelsResponse.decode(new Reader(data)) + ); + } + + ConnectionChannels( + request: QueryConnectionChannelsRequest + ): Promise { + const data = QueryConnectionChannelsRequest.encode(request).finish(); + const promise = this.rpc.request( + "ibc.core.channel.v1.Query", + "ConnectionChannels", + data + ); + return promise.then((data) => + QueryConnectionChannelsResponse.decode(new Reader(data)) + ); + } + + ChannelClientState( + request: QueryChannelClientStateRequest + ): Promise { + const data = QueryChannelClientStateRequest.encode(request).finish(); + const promise = this.rpc.request( + "ibc.core.channel.v1.Query", + "ChannelClientState", + data + ); + return promise.then((data) => + QueryChannelClientStateResponse.decode(new Reader(data)) + ); + } + + ChannelConsensusState( + request: QueryChannelConsensusStateRequest + ): Promise { + const data = QueryChannelConsensusStateRequest.encode(request).finish(); + const promise = this.rpc.request( + "ibc.core.channel.v1.Query", + "ChannelConsensusState", + data + ); + return promise.then((data) => + QueryChannelConsensusStateResponse.decode(new Reader(data)) + ); + } + + PacketCommitment( + request: QueryPacketCommitmentRequest + ): Promise { + const data = QueryPacketCommitmentRequest.encode(request).finish(); + const promise = this.rpc.request( + "ibc.core.channel.v1.Query", + "PacketCommitment", + data + ); + return promise.then((data) => + QueryPacketCommitmentResponse.decode(new Reader(data)) + ); + } + + PacketCommitments( + request: QueryPacketCommitmentsRequest + ): Promise { + const data = QueryPacketCommitmentsRequest.encode(request).finish(); + const promise = this.rpc.request( + "ibc.core.channel.v1.Query", + "PacketCommitments", + data + ); + return promise.then((data) => + QueryPacketCommitmentsResponse.decode(new Reader(data)) + ); + } + + PacketReceipt( + request: QueryPacketReceiptRequest + ): Promise { + const data = QueryPacketReceiptRequest.encode(request).finish(); + const promise = this.rpc.request( + "ibc.core.channel.v1.Query", + "PacketReceipt", + data + ); + return promise.then((data) => + QueryPacketReceiptResponse.decode(new Reader(data)) + ); + } + + PacketAcknowledgement( + request: QueryPacketAcknowledgementRequest + ): Promise { + const data = QueryPacketAcknowledgementRequest.encode(request).finish(); + const promise = this.rpc.request( + "ibc.core.channel.v1.Query", + "PacketAcknowledgement", + data + ); + return promise.then((data) => + QueryPacketAcknowledgementResponse.decode(new Reader(data)) + ); + } + + PacketAcknowledgements( + request: QueryPacketAcknowledgementsRequest + ): Promise { + const data = QueryPacketAcknowledgementsRequest.encode(request).finish(); + const promise = this.rpc.request( + "ibc.core.channel.v1.Query", + "PacketAcknowledgements", + data + ); + return promise.then((data) => + QueryPacketAcknowledgementsResponse.decode(new Reader(data)) + ); + } + + UnreceivedPackets( + request: QueryUnreceivedPacketsRequest + ): Promise { + const data = QueryUnreceivedPacketsRequest.encode(request).finish(); + const promise = this.rpc.request( + "ibc.core.channel.v1.Query", + "UnreceivedPackets", + data + ); + return promise.then((data) => + QueryUnreceivedPacketsResponse.decode(new Reader(data)) + ); + } + + UnreceivedAcks( + request: QueryUnreceivedAcksRequest + ): Promise { + const data = QueryUnreceivedAcksRequest.encode(request).finish(); + const promise = this.rpc.request( + "ibc.core.channel.v1.Query", + "UnreceivedAcks", + data + ); + return promise.then((data) => + QueryUnreceivedAcksResponse.decode(new Reader(data)) + ); + } + + NextSequenceReceive( + request: QueryNextSequenceReceiveRequest + ): Promise { + const data = QueryNextSequenceReceiveRequest.encode(request).finish(); + const promise = this.rpc.request( + "ibc.core.channel.v1.Query", + "NextSequenceReceive", + data + ); + return promise.then((data) => + QueryNextSequenceReceiveResponse.decode(new Reader(data)) + ); + } +} + +interface Rpc { + request( + service: string, + method: string, + data: Uint8Array + ): Promise; +} + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/ibc.core.channel.v1/types/ibc/core/channel/v1/tx.ts b/ts-client/ibc.core.channel.v1/types/ibc/core/channel/v1/tx.ts new file mode 100644 index 00000000..84e3cc68 --- /dev/null +++ b/ts-client/ibc.core.channel.v1/types/ibc/core/channel/v1/tx.ts @@ -0,0 +1,2473 @@ +/* eslint-disable */ +import { Reader, util, configure, Writer } from "protobufjs/minimal"; +import * as Long from "long"; +import { Channel, Packet } from "../../../../ibc/core/channel/v1/channel"; +import { Height } from "../../../../ibc/core/client/v1/client"; + +export const protobufPackage = "ibc.core.channel.v1"; + +/** ResponseResultType defines the possible outcomes of the execution of a message */ +export enum ResponseResultType { + /** RESPONSE_RESULT_TYPE_UNSPECIFIED - Default zero value enumeration */ + RESPONSE_RESULT_TYPE_UNSPECIFIED = 0, + /** RESPONSE_RESULT_TYPE_NOOP - The message did not call the IBC application callbacks (because, for example, the packet had already been relayed) */ + RESPONSE_RESULT_TYPE_NOOP = 1, + /** RESPONSE_RESULT_TYPE_SUCCESS - The message was executed successfully */ + RESPONSE_RESULT_TYPE_SUCCESS = 2, + UNRECOGNIZED = -1, +} + +export function responseResultTypeFromJSON(object: any): ResponseResultType { + switch (object) { + case 0: + case "RESPONSE_RESULT_TYPE_UNSPECIFIED": + return ResponseResultType.RESPONSE_RESULT_TYPE_UNSPECIFIED; + case 1: + case "RESPONSE_RESULT_TYPE_NOOP": + return ResponseResultType.RESPONSE_RESULT_TYPE_NOOP; + case 2: + case "RESPONSE_RESULT_TYPE_SUCCESS": + return ResponseResultType.RESPONSE_RESULT_TYPE_SUCCESS; + case -1: + case "UNRECOGNIZED": + default: + return ResponseResultType.UNRECOGNIZED; + } +} + +export function responseResultTypeToJSON(object: ResponseResultType): string { + switch (object) { + case ResponseResultType.RESPONSE_RESULT_TYPE_UNSPECIFIED: + return "RESPONSE_RESULT_TYPE_UNSPECIFIED"; + case ResponseResultType.RESPONSE_RESULT_TYPE_NOOP: + return "RESPONSE_RESULT_TYPE_NOOP"; + case ResponseResultType.RESPONSE_RESULT_TYPE_SUCCESS: + return "RESPONSE_RESULT_TYPE_SUCCESS"; + default: + return "UNKNOWN"; + } +} + +/** + * MsgChannelOpenInit defines an sdk.Msg to initialize a channel handshake. It + * is called by a relayer on Chain A. + */ +export interface MsgChannelOpenInit { + portId: string; + channel: Channel | undefined; + signer: string; +} + +/** MsgChannelOpenInitResponse defines the Msg/ChannelOpenInit response type. */ +export interface MsgChannelOpenInitResponse { + channelId: string; + version: string; +} + +/** + * MsgChannelOpenInit defines a msg sent by a Relayer to try to open a channel + * on Chain B. The version field within the Channel field has been deprecated. Its + * value will be ignored by core IBC. + */ +export interface MsgChannelOpenTry { + portId: string; + /** + * Deprecated: this field is unused. Crossing hello's are no longer supported in core IBC. + * + * @deprecated + */ + previousChannelId: string; + /** NOTE: the version field within the channel has been deprecated. Its value will be ignored by core IBC. */ + channel: Channel | undefined; + counterpartyVersion: string; + proofInit: Uint8Array; + proofHeight: Height | undefined; + signer: string; +} + +/** MsgChannelOpenTryResponse defines the Msg/ChannelOpenTry response type. */ +export interface MsgChannelOpenTryResponse { + version: string; +} + +/** + * MsgChannelOpenAck defines a msg sent by a Relayer to Chain A to acknowledge + * the change of channel state to TRYOPEN on Chain B. + */ +export interface MsgChannelOpenAck { + portId: string; + channelId: string; + counterpartyChannelId: string; + counterpartyVersion: string; + proofTry: Uint8Array; + proofHeight: Height | undefined; + signer: string; +} + +/** MsgChannelOpenAckResponse defines the Msg/ChannelOpenAck response type. */ +export interface MsgChannelOpenAckResponse {} + +/** + * MsgChannelOpenConfirm defines a msg sent by a Relayer to Chain B to + * acknowledge the change of channel state to OPEN on Chain A. + */ +export interface MsgChannelOpenConfirm { + portId: string; + channelId: string; + proofAck: Uint8Array; + proofHeight: Height | undefined; + signer: string; +} + +/** + * MsgChannelOpenConfirmResponse defines the Msg/ChannelOpenConfirm response + * type. + */ +export interface MsgChannelOpenConfirmResponse {} + +/** + * MsgChannelCloseInit defines a msg sent by a Relayer to Chain A + * to close a channel with Chain B. + */ +export interface MsgChannelCloseInit { + portId: string; + channelId: string; + signer: string; +} + +/** MsgChannelCloseInitResponse defines the Msg/ChannelCloseInit response type. */ +export interface MsgChannelCloseInitResponse {} + +/** + * MsgChannelCloseConfirm defines a msg sent by a Relayer to Chain B + * to acknowledge the change of channel state to CLOSED on Chain A. + */ +export interface MsgChannelCloseConfirm { + portId: string; + channelId: string; + proofInit: Uint8Array; + proofHeight: Height | undefined; + signer: string; +} + +/** + * MsgChannelCloseConfirmResponse defines the Msg/ChannelCloseConfirm response + * type. + */ +export interface MsgChannelCloseConfirmResponse {} + +/** MsgRecvPacket receives incoming IBC packet */ +export interface MsgRecvPacket { + packet: Packet | undefined; + proofCommitment: Uint8Array; + proofHeight: Height | undefined; + signer: string; +} + +/** MsgRecvPacketResponse defines the Msg/RecvPacket response type. */ +export interface MsgRecvPacketResponse { + result: ResponseResultType; +} + +/** MsgTimeout receives timed-out packet */ +export interface MsgTimeout { + packet: Packet | undefined; + proofUnreceived: Uint8Array; + proofHeight: Height | undefined; + nextSequenceRecv: number; + signer: string; +} + +/** MsgTimeoutResponse defines the Msg/Timeout response type. */ +export interface MsgTimeoutResponse { + result: ResponseResultType; +} + +/** MsgTimeoutOnClose timed-out packet upon counterparty channel closure. */ +export interface MsgTimeoutOnClose { + packet: Packet | undefined; + proofUnreceived: Uint8Array; + proofClose: Uint8Array; + proofHeight: Height | undefined; + nextSequenceRecv: number; + signer: string; +} + +/** MsgTimeoutOnCloseResponse defines the Msg/TimeoutOnClose response type. */ +export interface MsgTimeoutOnCloseResponse { + result: ResponseResultType; +} + +/** MsgAcknowledgement receives incoming IBC acknowledgement */ +export interface MsgAcknowledgement { + packet: Packet | undefined; + acknowledgement: Uint8Array; + proofAcked: Uint8Array; + proofHeight: Height | undefined; + signer: string; +} + +/** MsgAcknowledgementResponse defines the Msg/Acknowledgement response type. */ +export interface MsgAcknowledgementResponse { + result: ResponseResultType; +} + +const baseMsgChannelOpenInit: object = { portId: "", signer: "" }; + +export const MsgChannelOpenInit = { + encode( + message: MsgChannelOpenInit, + writer: Writer = Writer.create() + ): Writer { + if (message.portId !== "") { + writer.uint32(10).string(message.portId); + } + if (message.channel !== undefined) { + Channel.encode(message.channel, writer.uint32(18).fork()).ldelim(); + } + if (message.signer !== "") { + writer.uint32(26).string(message.signer); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MsgChannelOpenInit { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgChannelOpenInit } as MsgChannelOpenInit; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.portId = reader.string(); + break; + case 2: + message.channel = Channel.decode(reader, reader.uint32()); + break; + case 3: + message.signer = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgChannelOpenInit { + const message = { ...baseMsgChannelOpenInit } as MsgChannelOpenInit; + if (object.portId !== undefined && object.portId !== null) { + message.portId = String(object.portId); + } else { + message.portId = ""; + } + if (object.channel !== undefined && object.channel !== null) { + message.channel = Channel.fromJSON(object.channel); + } else { + message.channel = undefined; + } + if (object.signer !== undefined && object.signer !== null) { + message.signer = String(object.signer); + } else { + message.signer = ""; + } + return message; + }, + + toJSON(message: MsgChannelOpenInit): unknown { + const obj: any = {}; + message.portId !== undefined && (obj.portId = message.portId); + message.channel !== undefined && + (obj.channel = message.channel + ? Channel.toJSON(message.channel) + : undefined); + message.signer !== undefined && (obj.signer = message.signer); + return obj; + }, + + fromPartial(object: DeepPartial): MsgChannelOpenInit { + const message = { ...baseMsgChannelOpenInit } as MsgChannelOpenInit; + if (object.portId !== undefined && object.portId !== null) { + message.portId = object.portId; + } else { + message.portId = ""; + } + if (object.channel !== undefined && object.channel !== null) { + message.channel = Channel.fromPartial(object.channel); + } else { + message.channel = undefined; + } + if (object.signer !== undefined && object.signer !== null) { + message.signer = object.signer; + } else { + message.signer = ""; + } + return message; + }, +}; + +const baseMsgChannelOpenInitResponse: object = { channelId: "", version: "" }; + +export const MsgChannelOpenInitResponse = { + encode( + message: MsgChannelOpenInitResponse, + writer: Writer = Writer.create() + ): Writer { + if (message.channelId !== "") { + writer.uint32(10).string(message.channelId); + } + if (message.version !== "") { + writer.uint32(18).string(message.version); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): MsgChannelOpenInitResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseMsgChannelOpenInitResponse, + } as MsgChannelOpenInitResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.channelId = reader.string(); + break; + case 2: + message.version = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgChannelOpenInitResponse { + const message = { + ...baseMsgChannelOpenInitResponse, + } as MsgChannelOpenInitResponse; + if (object.channelId !== undefined && object.channelId !== null) { + message.channelId = String(object.channelId); + } else { + message.channelId = ""; + } + if (object.version !== undefined && object.version !== null) { + message.version = String(object.version); + } else { + message.version = ""; + } + return message; + }, + + toJSON(message: MsgChannelOpenInitResponse): unknown { + const obj: any = {}; + message.channelId !== undefined && (obj.channelId = message.channelId); + message.version !== undefined && (obj.version = message.version); + return obj; + }, + + fromPartial( + object: DeepPartial + ): MsgChannelOpenInitResponse { + const message = { + ...baseMsgChannelOpenInitResponse, + } as MsgChannelOpenInitResponse; + if (object.channelId !== undefined && object.channelId !== null) { + message.channelId = object.channelId; + } else { + message.channelId = ""; + } + if (object.version !== undefined && object.version !== null) { + message.version = object.version; + } else { + message.version = ""; + } + return message; + }, +}; + +const baseMsgChannelOpenTry: object = { + portId: "", + previousChannelId: "", + counterpartyVersion: "", + signer: "", +}; + +export const MsgChannelOpenTry = { + encode(message: MsgChannelOpenTry, writer: Writer = Writer.create()): Writer { + if (message.portId !== "") { + writer.uint32(10).string(message.portId); + } + if (message.previousChannelId !== "") { + writer.uint32(18).string(message.previousChannelId); + } + if (message.channel !== undefined) { + Channel.encode(message.channel, writer.uint32(26).fork()).ldelim(); + } + if (message.counterpartyVersion !== "") { + writer.uint32(34).string(message.counterpartyVersion); + } + if (message.proofInit.length !== 0) { + writer.uint32(42).bytes(message.proofInit); + } + if (message.proofHeight !== undefined) { + Height.encode(message.proofHeight, writer.uint32(50).fork()).ldelim(); + } + if (message.signer !== "") { + writer.uint32(58).string(message.signer); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MsgChannelOpenTry { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgChannelOpenTry } as MsgChannelOpenTry; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.portId = reader.string(); + break; + case 2: + message.previousChannelId = reader.string(); + break; + case 3: + message.channel = Channel.decode(reader, reader.uint32()); + break; + case 4: + message.counterpartyVersion = reader.string(); + break; + case 5: + message.proofInit = reader.bytes(); + break; + case 6: + message.proofHeight = Height.decode(reader, reader.uint32()); + break; + case 7: + message.signer = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgChannelOpenTry { + const message = { ...baseMsgChannelOpenTry } as MsgChannelOpenTry; + if (object.portId !== undefined && object.portId !== null) { + message.portId = String(object.portId); + } else { + message.portId = ""; + } + if ( + object.previousChannelId !== undefined && + object.previousChannelId !== null + ) { + message.previousChannelId = String(object.previousChannelId); + } else { + message.previousChannelId = ""; + } + if (object.channel !== undefined && object.channel !== null) { + message.channel = Channel.fromJSON(object.channel); + } else { + message.channel = undefined; + } + if ( + object.counterpartyVersion !== undefined && + object.counterpartyVersion !== null + ) { + message.counterpartyVersion = String(object.counterpartyVersion); + } else { + message.counterpartyVersion = ""; + } + if (object.proofInit !== undefined && object.proofInit !== null) { + message.proofInit = bytesFromBase64(object.proofInit); + } + if (object.proofHeight !== undefined && object.proofHeight !== null) { + message.proofHeight = Height.fromJSON(object.proofHeight); + } else { + message.proofHeight = undefined; + } + if (object.signer !== undefined && object.signer !== null) { + message.signer = String(object.signer); + } else { + message.signer = ""; + } + return message; + }, + + toJSON(message: MsgChannelOpenTry): unknown { + const obj: any = {}; + message.portId !== undefined && (obj.portId = message.portId); + message.previousChannelId !== undefined && + (obj.previousChannelId = message.previousChannelId); + message.channel !== undefined && + (obj.channel = message.channel + ? Channel.toJSON(message.channel) + : undefined); + message.counterpartyVersion !== undefined && + (obj.counterpartyVersion = message.counterpartyVersion); + message.proofInit !== undefined && + (obj.proofInit = base64FromBytes( + message.proofInit !== undefined ? message.proofInit : new Uint8Array() + )); + message.proofHeight !== undefined && + (obj.proofHeight = message.proofHeight + ? Height.toJSON(message.proofHeight) + : undefined); + message.signer !== undefined && (obj.signer = message.signer); + return obj; + }, + + fromPartial(object: DeepPartial): MsgChannelOpenTry { + const message = { ...baseMsgChannelOpenTry } as MsgChannelOpenTry; + if (object.portId !== undefined && object.portId !== null) { + message.portId = object.portId; + } else { + message.portId = ""; + } + if ( + object.previousChannelId !== undefined && + object.previousChannelId !== null + ) { + message.previousChannelId = object.previousChannelId; + } else { + message.previousChannelId = ""; + } + if (object.channel !== undefined && object.channel !== null) { + message.channel = Channel.fromPartial(object.channel); + } else { + message.channel = undefined; + } + if ( + object.counterpartyVersion !== undefined && + object.counterpartyVersion !== null + ) { + message.counterpartyVersion = object.counterpartyVersion; + } else { + message.counterpartyVersion = ""; + } + if (object.proofInit !== undefined && object.proofInit !== null) { + message.proofInit = object.proofInit; + } else { + message.proofInit = new Uint8Array(); + } + if (object.proofHeight !== undefined && object.proofHeight !== null) { + message.proofHeight = Height.fromPartial(object.proofHeight); + } else { + message.proofHeight = undefined; + } + if (object.signer !== undefined && object.signer !== null) { + message.signer = object.signer; + } else { + message.signer = ""; + } + return message; + }, +}; + +const baseMsgChannelOpenTryResponse: object = { version: "" }; + +export const MsgChannelOpenTryResponse = { + encode( + message: MsgChannelOpenTryResponse, + writer: Writer = Writer.create() + ): Writer { + if (message.version !== "") { + writer.uint32(10).string(message.version); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): MsgChannelOpenTryResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseMsgChannelOpenTryResponse, + } as MsgChannelOpenTryResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.version = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgChannelOpenTryResponse { + const message = { + ...baseMsgChannelOpenTryResponse, + } as MsgChannelOpenTryResponse; + if (object.version !== undefined && object.version !== null) { + message.version = String(object.version); + } else { + message.version = ""; + } + return message; + }, + + toJSON(message: MsgChannelOpenTryResponse): unknown { + const obj: any = {}; + message.version !== undefined && (obj.version = message.version); + return obj; + }, + + fromPartial( + object: DeepPartial + ): MsgChannelOpenTryResponse { + const message = { + ...baseMsgChannelOpenTryResponse, + } as MsgChannelOpenTryResponse; + if (object.version !== undefined && object.version !== null) { + message.version = object.version; + } else { + message.version = ""; + } + return message; + }, +}; + +const baseMsgChannelOpenAck: object = { + portId: "", + channelId: "", + counterpartyChannelId: "", + counterpartyVersion: "", + signer: "", +}; + +export const MsgChannelOpenAck = { + encode(message: MsgChannelOpenAck, writer: Writer = Writer.create()): Writer { + if (message.portId !== "") { + writer.uint32(10).string(message.portId); + } + if (message.channelId !== "") { + writer.uint32(18).string(message.channelId); + } + if (message.counterpartyChannelId !== "") { + writer.uint32(26).string(message.counterpartyChannelId); + } + if (message.counterpartyVersion !== "") { + writer.uint32(34).string(message.counterpartyVersion); + } + if (message.proofTry.length !== 0) { + writer.uint32(42).bytes(message.proofTry); + } + if (message.proofHeight !== undefined) { + Height.encode(message.proofHeight, writer.uint32(50).fork()).ldelim(); + } + if (message.signer !== "") { + writer.uint32(58).string(message.signer); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MsgChannelOpenAck { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgChannelOpenAck } as MsgChannelOpenAck; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.portId = reader.string(); + break; + case 2: + message.channelId = reader.string(); + break; + case 3: + message.counterpartyChannelId = reader.string(); + break; + case 4: + message.counterpartyVersion = reader.string(); + break; + case 5: + message.proofTry = reader.bytes(); + break; + case 6: + message.proofHeight = Height.decode(reader, reader.uint32()); + break; + case 7: + message.signer = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgChannelOpenAck { + const message = { ...baseMsgChannelOpenAck } as MsgChannelOpenAck; + if (object.portId !== undefined && object.portId !== null) { + message.portId = String(object.portId); + } else { + message.portId = ""; + } + if (object.channelId !== undefined && object.channelId !== null) { + message.channelId = String(object.channelId); + } else { + message.channelId = ""; + } + if ( + object.counterpartyChannelId !== undefined && + object.counterpartyChannelId !== null + ) { + message.counterpartyChannelId = String(object.counterpartyChannelId); + } else { + message.counterpartyChannelId = ""; + } + if ( + object.counterpartyVersion !== undefined && + object.counterpartyVersion !== null + ) { + message.counterpartyVersion = String(object.counterpartyVersion); + } else { + message.counterpartyVersion = ""; + } + if (object.proofTry !== undefined && object.proofTry !== null) { + message.proofTry = bytesFromBase64(object.proofTry); + } + if (object.proofHeight !== undefined && object.proofHeight !== null) { + message.proofHeight = Height.fromJSON(object.proofHeight); + } else { + message.proofHeight = undefined; + } + if (object.signer !== undefined && object.signer !== null) { + message.signer = String(object.signer); + } else { + message.signer = ""; + } + return message; + }, + + toJSON(message: MsgChannelOpenAck): unknown { + const obj: any = {}; + message.portId !== undefined && (obj.portId = message.portId); + message.channelId !== undefined && (obj.channelId = message.channelId); + message.counterpartyChannelId !== undefined && + (obj.counterpartyChannelId = message.counterpartyChannelId); + message.counterpartyVersion !== undefined && + (obj.counterpartyVersion = message.counterpartyVersion); + message.proofTry !== undefined && + (obj.proofTry = base64FromBytes( + message.proofTry !== undefined ? message.proofTry : new Uint8Array() + )); + message.proofHeight !== undefined && + (obj.proofHeight = message.proofHeight + ? Height.toJSON(message.proofHeight) + : undefined); + message.signer !== undefined && (obj.signer = message.signer); + return obj; + }, + + fromPartial(object: DeepPartial): MsgChannelOpenAck { + const message = { ...baseMsgChannelOpenAck } as MsgChannelOpenAck; + if (object.portId !== undefined && object.portId !== null) { + message.portId = object.portId; + } else { + message.portId = ""; + } + if (object.channelId !== undefined && object.channelId !== null) { + message.channelId = object.channelId; + } else { + message.channelId = ""; + } + if ( + object.counterpartyChannelId !== undefined && + object.counterpartyChannelId !== null + ) { + message.counterpartyChannelId = object.counterpartyChannelId; + } else { + message.counterpartyChannelId = ""; + } + if ( + object.counterpartyVersion !== undefined && + object.counterpartyVersion !== null + ) { + message.counterpartyVersion = object.counterpartyVersion; + } else { + message.counterpartyVersion = ""; + } + if (object.proofTry !== undefined && object.proofTry !== null) { + message.proofTry = object.proofTry; + } else { + message.proofTry = new Uint8Array(); + } + if (object.proofHeight !== undefined && object.proofHeight !== null) { + message.proofHeight = Height.fromPartial(object.proofHeight); + } else { + message.proofHeight = undefined; + } + if (object.signer !== undefined && object.signer !== null) { + message.signer = object.signer; + } else { + message.signer = ""; + } + return message; + }, +}; + +const baseMsgChannelOpenAckResponse: object = {}; + +export const MsgChannelOpenAckResponse = { + encode( + _: MsgChannelOpenAckResponse, + writer: Writer = Writer.create() + ): Writer { + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): MsgChannelOpenAckResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseMsgChannelOpenAckResponse, + } as MsgChannelOpenAckResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): MsgChannelOpenAckResponse { + const message = { + ...baseMsgChannelOpenAckResponse, + } as MsgChannelOpenAckResponse; + return message; + }, + + toJSON(_: MsgChannelOpenAckResponse): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial( + _: DeepPartial + ): MsgChannelOpenAckResponse { + const message = { + ...baseMsgChannelOpenAckResponse, + } as MsgChannelOpenAckResponse; + return message; + }, +}; + +const baseMsgChannelOpenConfirm: object = { + portId: "", + channelId: "", + signer: "", +}; + +export const MsgChannelOpenConfirm = { + encode( + message: MsgChannelOpenConfirm, + writer: Writer = Writer.create() + ): Writer { + if (message.portId !== "") { + writer.uint32(10).string(message.portId); + } + if (message.channelId !== "") { + writer.uint32(18).string(message.channelId); + } + if (message.proofAck.length !== 0) { + writer.uint32(26).bytes(message.proofAck); + } + if (message.proofHeight !== undefined) { + Height.encode(message.proofHeight, writer.uint32(34).fork()).ldelim(); + } + if (message.signer !== "") { + writer.uint32(42).string(message.signer); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MsgChannelOpenConfirm { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgChannelOpenConfirm } as MsgChannelOpenConfirm; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.portId = reader.string(); + break; + case 2: + message.channelId = reader.string(); + break; + case 3: + message.proofAck = reader.bytes(); + break; + case 4: + message.proofHeight = Height.decode(reader, reader.uint32()); + break; + case 5: + message.signer = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgChannelOpenConfirm { + const message = { ...baseMsgChannelOpenConfirm } as MsgChannelOpenConfirm; + if (object.portId !== undefined && object.portId !== null) { + message.portId = String(object.portId); + } else { + message.portId = ""; + } + if (object.channelId !== undefined && object.channelId !== null) { + message.channelId = String(object.channelId); + } else { + message.channelId = ""; + } + if (object.proofAck !== undefined && object.proofAck !== null) { + message.proofAck = bytesFromBase64(object.proofAck); + } + if (object.proofHeight !== undefined && object.proofHeight !== null) { + message.proofHeight = Height.fromJSON(object.proofHeight); + } else { + message.proofHeight = undefined; + } + if (object.signer !== undefined && object.signer !== null) { + message.signer = String(object.signer); + } else { + message.signer = ""; + } + return message; + }, + + toJSON(message: MsgChannelOpenConfirm): unknown { + const obj: any = {}; + message.portId !== undefined && (obj.portId = message.portId); + message.channelId !== undefined && (obj.channelId = message.channelId); + message.proofAck !== undefined && + (obj.proofAck = base64FromBytes( + message.proofAck !== undefined ? message.proofAck : new Uint8Array() + )); + message.proofHeight !== undefined && + (obj.proofHeight = message.proofHeight + ? Height.toJSON(message.proofHeight) + : undefined); + message.signer !== undefined && (obj.signer = message.signer); + return obj; + }, + + fromPartial( + object: DeepPartial + ): MsgChannelOpenConfirm { + const message = { ...baseMsgChannelOpenConfirm } as MsgChannelOpenConfirm; + if (object.portId !== undefined && object.portId !== null) { + message.portId = object.portId; + } else { + message.portId = ""; + } + if (object.channelId !== undefined && object.channelId !== null) { + message.channelId = object.channelId; + } else { + message.channelId = ""; + } + if (object.proofAck !== undefined && object.proofAck !== null) { + message.proofAck = object.proofAck; + } else { + message.proofAck = new Uint8Array(); + } + if (object.proofHeight !== undefined && object.proofHeight !== null) { + message.proofHeight = Height.fromPartial(object.proofHeight); + } else { + message.proofHeight = undefined; + } + if (object.signer !== undefined && object.signer !== null) { + message.signer = object.signer; + } else { + message.signer = ""; + } + return message; + }, +}; + +const baseMsgChannelOpenConfirmResponse: object = {}; + +export const MsgChannelOpenConfirmResponse = { + encode( + _: MsgChannelOpenConfirmResponse, + writer: Writer = Writer.create() + ): Writer { + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): MsgChannelOpenConfirmResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseMsgChannelOpenConfirmResponse, + } as MsgChannelOpenConfirmResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): MsgChannelOpenConfirmResponse { + const message = { + ...baseMsgChannelOpenConfirmResponse, + } as MsgChannelOpenConfirmResponse; + return message; + }, + + toJSON(_: MsgChannelOpenConfirmResponse): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial( + _: DeepPartial + ): MsgChannelOpenConfirmResponse { + const message = { + ...baseMsgChannelOpenConfirmResponse, + } as MsgChannelOpenConfirmResponse; + return message; + }, +}; + +const baseMsgChannelCloseInit: object = { + portId: "", + channelId: "", + signer: "", +}; + +export const MsgChannelCloseInit = { + encode( + message: MsgChannelCloseInit, + writer: Writer = Writer.create() + ): Writer { + if (message.portId !== "") { + writer.uint32(10).string(message.portId); + } + if (message.channelId !== "") { + writer.uint32(18).string(message.channelId); + } + if (message.signer !== "") { + writer.uint32(26).string(message.signer); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MsgChannelCloseInit { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgChannelCloseInit } as MsgChannelCloseInit; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.portId = reader.string(); + break; + case 2: + message.channelId = reader.string(); + break; + case 3: + message.signer = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgChannelCloseInit { + const message = { ...baseMsgChannelCloseInit } as MsgChannelCloseInit; + if (object.portId !== undefined && object.portId !== null) { + message.portId = String(object.portId); + } else { + message.portId = ""; + } + if (object.channelId !== undefined && object.channelId !== null) { + message.channelId = String(object.channelId); + } else { + message.channelId = ""; + } + if (object.signer !== undefined && object.signer !== null) { + message.signer = String(object.signer); + } else { + message.signer = ""; + } + return message; + }, + + toJSON(message: MsgChannelCloseInit): unknown { + const obj: any = {}; + message.portId !== undefined && (obj.portId = message.portId); + message.channelId !== undefined && (obj.channelId = message.channelId); + message.signer !== undefined && (obj.signer = message.signer); + return obj; + }, + + fromPartial(object: DeepPartial): MsgChannelCloseInit { + const message = { ...baseMsgChannelCloseInit } as MsgChannelCloseInit; + if (object.portId !== undefined && object.portId !== null) { + message.portId = object.portId; + } else { + message.portId = ""; + } + if (object.channelId !== undefined && object.channelId !== null) { + message.channelId = object.channelId; + } else { + message.channelId = ""; + } + if (object.signer !== undefined && object.signer !== null) { + message.signer = object.signer; + } else { + message.signer = ""; + } + return message; + }, +}; + +const baseMsgChannelCloseInitResponse: object = {}; + +export const MsgChannelCloseInitResponse = { + encode( + _: MsgChannelCloseInitResponse, + writer: Writer = Writer.create() + ): Writer { + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): MsgChannelCloseInitResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseMsgChannelCloseInitResponse, + } as MsgChannelCloseInitResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): MsgChannelCloseInitResponse { + const message = { + ...baseMsgChannelCloseInitResponse, + } as MsgChannelCloseInitResponse; + return message; + }, + + toJSON(_: MsgChannelCloseInitResponse): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial( + _: DeepPartial + ): MsgChannelCloseInitResponse { + const message = { + ...baseMsgChannelCloseInitResponse, + } as MsgChannelCloseInitResponse; + return message; + }, +}; + +const baseMsgChannelCloseConfirm: object = { + portId: "", + channelId: "", + signer: "", +}; + +export const MsgChannelCloseConfirm = { + encode( + message: MsgChannelCloseConfirm, + writer: Writer = Writer.create() + ): Writer { + if (message.portId !== "") { + writer.uint32(10).string(message.portId); + } + if (message.channelId !== "") { + writer.uint32(18).string(message.channelId); + } + if (message.proofInit.length !== 0) { + writer.uint32(26).bytes(message.proofInit); + } + if (message.proofHeight !== undefined) { + Height.encode(message.proofHeight, writer.uint32(34).fork()).ldelim(); + } + if (message.signer !== "") { + writer.uint32(42).string(message.signer); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MsgChannelCloseConfirm { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgChannelCloseConfirm } as MsgChannelCloseConfirm; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.portId = reader.string(); + break; + case 2: + message.channelId = reader.string(); + break; + case 3: + message.proofInit = reader.bytes(); + break; + case 4: + message.proofHeight = Height.decode(reader, reader.uint32()); + break; + case 5: + message.signer = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgChannelCloseConfirm { + const message = { ...baseMsgChannelCloseConfirm } as MsgChannelCloseConfirm; + if (object.portId !== undefined && object.portId !== null) { + message.portId = String(object.portId); + } else { + message.portId = ""; + } + if (object.channelId !== undefined && object.channelId !== null) { + message.channelId = String(object.channelId); + } else { + message.channelId = ""; + } + if (object.proofInit !== undefined && object.proofInit !== null) { + message.proofInit = bytesFromBase64(object.proofInit); + } + if (object.proofHeight !== undefined && object.proofHeight !== null) { + message.proofHeight = Height.fromJSON(object.proofHeight); + } else { + message.proofHeight = undefined; + } + if (object.signer !== undefined && object.signer !== null) { + message.signer = String(object.signer); + } else { + message.signer = ""; + } + return message; + }, + + toJSON(message: MsgChannelCloseConfirm): unknown { + const obj: any = {}; + message.portId !== undefined && (obj.portId = message.portId); + message.channelId !== undefined && (obj.channelId = message.channelId); + message.proofInit !== undefined && + (obj.proofInit = base64FromBytes( + message.proofInit !== undefined ? message.proofInit : new Uint8Array() + )); + message.proofHeight !== undefined && + (obj.proofHeight = message.proofHeight + ? Height.toJSON(message.proofHeight) + : undefined); + message.signer !== undefined && (obj.signer = message.signer); + return obj; + }, + + fromPartial( + object: DeepPartial + ): MsgChannelCloseConfirm { + const message = { ...baseMsgChannelCloseConfirm } as MsgChannelCloseConfirm; + if (object.portId !== undefined && object.portId !== null) { + message.portId = object.portId; + } else { + message.portId = ""; + } + if (object.channelId !== undefined && object.channelId !== null) { + message.channelId = object.channelId; + } else { + message.channelId = ""; + } + if (object.proofInit !== undefined && object.proofInit !== null) { + message.proofInit = object.proofInit; + } else { + message.proofInit = new Uint8Array(); + } + if (object.proofHeight !== undefined && object.proofHeight !== null) { + message.proofHeight = Height.fromPartial(object.proofHeight); + } else { + message.proofHeight = undefined; + } + if (object.signer !== undefined && object.signer !== null) { + message.signer = object.signer; + } else { + message.signer = ""; + } + return message; + }, +}; + +const baseMsgChannelCloseConfirmResponse: object = {}; + +export const MsgChannelCloseConfirmResponse = { + encode( + _: MsgChannelCloseConfirmResponse, + writer: Writer = Writer.create() + ): Writer { + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): MsgChannelCloseConfirmResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseMsgChannelCloseConfirmResponse, + } as MsgChannelCloseConfirmResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): MsgChannelCloseConfirmResponse { + const message = { + ...baseMsgChannelCloseConfirmResponse, + } as MsgChannelCloseConfirmResponse; + return message; + }, + + toJSON(_: MsgChannelCloseConfirmResponse): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial( + _: DeepPartial + ): MsgChannelCloseConfirmResponse { + const message = { + ...baseMsgChannelCloseConfirmResponse, + } as MsgChannelCloseConfirmResponse; + return message; + }, +}; + +const baseMsgRecvPacket: object = { signer: "" }; + +export const MsgRecvPacket = { + encode(message: MsgRecvPacket, writer: Writer = Writer.create()): Writer { + if (message.packet !== undefined) { + Packet.encode(message.packet, writer.uint32(10).fork()).ldelim(); + } + if (message.proofCommitment.length !== 0) { + writer.uint32(18).bytes(message.proofCommitment); + } + if (message.proofHeight !== undefined) { + Height.encode(message.proofHeight, writer.uint32(26).fork()).ldelim(); + } + if (message.signer !== "") { + writer.uint32(34).string(message.signer); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MsgRecvPacket { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgRecvPacket } as MsgRecvPacket; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.packet = Packet.decode(reader, reader.uint32()); + break; + case 2: + message.proofCommitment = reader.bytes(); + break; + case 3: + message.proofHeight = Height.decode(reader, reader.uint32()); + break; + case 4: + message.signer = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgRecvPacket { + const message = { ...baseMsgRecvPacket } as MsgRecvPacket; + if (object.packet !== undefined && object.packet !== null) { + message.packet = Packet.fromJSON(object.packet); + } else { + message.packet = undefined; + } + if ( + object.proofCommitment !== undefined && + object.proofCommitment !== null + ) { + message.proofCommitment = bytesFromBase64(object.proofCommitment); + } + if (object.proofHeight !== undefined && object.proofHeight !== null) { + message.proofHeight = Height.fromJSON(object.proofHeight); + } else { + message.proofHeight = undefined; + } + if (object.signer !== undefined && object.signer !== null) { + message.signer = String(object.signer); + } else { + message.signer = ""; + } + return message; + }, + + toJSON(message: MsgRecvPacket): unknown { + const obj: any = {}; + message.packet !== undefined && + (obj.packet = message.packet ? Packet.toJSON(message.packet) : undefined); + message.proofCommitment !== undefined && + (obj.proofCommitment = base64FromBytes( + message.proofCommitment !== undefined + ? message.proofCommitment + : new Uint8Array() + )); + message.proofHeight !== undefined && + (obj.proofHeight = message.proofHeight + ? Height.toJSON(message.proofHeight) + : undefined); + message.signer !== undefined && (obj.signer = message.signer); + return obj; + }, + + fromPartial(object: DeepPartial): MsgRecvPacket { + const message = { ...baseMsgRecvPacket } as MsgRecvPacket; + if (object.packet !== undefined && object.packet !== null) { + message.packet = Packet.fromPartial(object.packet); + } else { + message.packet = undefined; + } + if ( + object.proofCommitment !== undefined && + object.proofCommitment !== null + ) { + message.proofCommitment = object.proofCommitment; + } else { + message.proofCommitment = new Uint8Array(); + } + if (object.proofHeight !== undefined && object.proofHeight !== null) { + message.proofHeight = Height.fromPartial(object.proofHeight); + } else { + message.proofHeight = undefined; + } + if (object.signer !== undefined && object.signer !== null) { + message.signer = object.signer; + } else { + message.signer = ""; + } + return message; + }, +}; + +const baseMsgRecvPacketResponse: object = { result: 0 }; + +export const MsgRecvPacketResponse = { + encode( + message: MsgRecvPacketResponse, + writer: Writer = Writer.create() + ): Writer { + if (message.result !== 0) { + writer.uint32(8).int32(message.result); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MsgRecvPacketResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgRecvPacketResponse } as MsgRecvPacketResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.result = reader.int32() as any; + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgRecvPacketResponse { + const message = { ...baseMsgRecvPacketResponse } as MsgRecvPacketResponse; + if (object.result !== undefined && object.result !== null) { + message.result = responseResultTypeFromJSON(object.result); + } else { + message.result = 0; + } + return message; + }, + + toJSON(message: MsgRecvPacketResponse): unknown { + const obj: any = {}; + message.result !== undefined && + (obj.result = responseResultTypeToJSON(message.result)); + return obj; + }, + + fromPartial( + object: DeepPartial + ): MsgRecvPacketResponse { + const message = { ...baseMsgRecvPacketResponse } as MsgRecvPacketResponse; + if (object.result !== undefined && object.result !== null) { + message.result = object.result; + } else { + message.result = 0; + } + return message; + }, +}; + +const baseMsgTimeout: object = { nextSequenceRecv: 0, signer: "" }; + +export const MsgTimeout = { + encode(message: MsgTimeout, writer: Writer = Writer.create()): Writer { + if (message.packet !== undefined) { + Packet.encode(message.packet, writer.uint32(10).fork()).ldelim(); + } + if (message.proofUnreceived.length !== 0) { + writer.uint32(18).bytes(message.proofUnreceived); + } + if (message.proofHeight !== undefined) { + Height.encode(message.proofHeight, writer.uint32(26).fork()).ldelim(); + } + if (message.nextSequenceRecv !== 0) { + writer.uint32(32).uint64(message.nextSequenceRecv); + } + if (message.signer !== "") { + writer.uint32(42).string(message.signer); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MsgTimeout { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgTimeout } as MsgTimeout; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.packet = Packet.decode(reader, reader.uint32()); + break; + case 2: + message.proofUnreceived = reader.bytes(); + break; + case 3: + message.proofHeight = Height.decode(reader, reader.uint32()); + break; + case 4: + message.nextSequenceRecv = longToNumber(reader.uint64() as Long); + break; + case 5: + message.signer = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgTimeout { + const message = { ...baseMsgTimeout } as MsgTimeout; + if (object.packet !== undefined && object.packet !== null) { + message.packet = Packet.fromJSON(object.packet); + } else { + message.packet = undefined; + } + if ( + object.proofUnreceived !== undefined && + object.proofUnreceived !== null + ) { + message.proofUnreceived = bytesFromBase64(object.proofUnreceived); + } + if (object.proofHeight !== undefined && object.proofHeight !== null) { + message.proofHeight = Height.fromJSON(object.proofHeight); + } else { + message.proofHeight = undefined; + } + if ( + object.nextSequenceRecv !== undefined && + object.nextSequenceRecv !== null + ) { + message.nextSequenceRecv = Number(object.nextSequenceRecv); + } else { + message.nextSequenceRecv = 0; + } + if (object.signer !== undefined && object.signer !== null) { + message.signer = String(object.signer); + } else { + message.signer = ""; + } + return message; + }, + + toJSON(message: MsgTimeout): unknown { + const obj: any = {}; + message.packet !== undefined && + (obj.packet = message.packet ? Packet.toJSON(message.packet) : undefined); + message.proofUnreceived !== undefined && + (obj.proofUnreceived = base64FromBytes( + message.proofUnreceived !== undefined + ? message.proofUnreceived + : new Uint8Array() + )); + message.proofHeight !== undefined && + (obj.proofHeight = message.proofHeight + ? Height.toJSON(message.proofHeight) + : undefined); + message.nextSequenceRecv !== undefined && + (obj.nextSequenceRecv = message.nextSequenceRecv); + message.signer !== undefined && (obj.signer = message.signer); + return obj; + }, + + fromPartial(object: DeepPartial): MsgTimeout { + const message = { ...baseMsgTimeout } as MsgTimeout; + if (object.packet !== undefined && object.packet !== null) { + message.packet = Packet.fromPartial(object.packet); + } else { + message.packet = undefined; + } + if ( + object.proofUnreceived !== undefined && + object.proofUnreceived !== null + ) { + message.proofUnreceived = object.proofUnreceived; + } else { + message.proofUnreceived = new Uint8Array(); + } + if (object.proofHeight !== undefined && object.proofHeight !== null) { + message.proofHeight = Height.fromPartial(object.proofHeight); + } else { + message.proofHeight = undefined; + } + if ( + object.nextSequenceRecv !== undefined && + object.nextSequenceRecv !== null + ) { + message.nextSequenceRecv = object.nextSequenceRecv; + } else { + message.nextSequenceRecv = 0; + } + if (object.signer !== undefined && object.signer !== null) { + message.signer = object.signer; + } else { + message.signer = ""; + } + return message; + }, +}; + +const baseMsgTimeoutResponse: object = { result: 0 }; + +export const MsgTimeoutResponse = { + encode( + message: MsgTimeoutResponse, + writer: Writer = Writer.create() + ): Writer { + if (message.result !== 0) { + writer.uint32(8).int32(message.result); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MsgTimeoutResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgTimeoutResponse } as MsgTimeoutResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.result = reader.int32() as any; + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgTimeoutResponse { + const message = { ...baseMsgTimeoutResponse } as MsgTimeoutResponse; + if (object.result !== undefined && object.result !== null) { + message.result = responseResultTypeFromJSON(object.result); + } else { + message.result = 0; + } + return message; + }, + + toJSON(message: MsgTimeoutResponse): unknown { + const obj: any = {}; + message.result !== undefined && + (obj.result = responseResultTypeToJSON(message.result)); + return obj; + }, + + fromPartial(object: DeepPartial): MsgTimeoutResponse { + const message = { ...baseMsgTimeoutResponse } as MsgTimeoutResponse; + if (object.result !== undefined && object.result !== null) { + message.result = object.result; + } else { + message.result = 0; + } + return message; + }, +}; + +const baseMsgTimeoutOnClose: object = { nextSequenceRecv: 0, signer: "" }; + +export const MsgTimeoutOnClose = { + encode(message: MsgTimeoutOnClose, writer: Writer = Writer.create()): Writer { + if (message.packet !== undefined) { + Packet.encode(message.packet, writer.uint32(10).fork()).ldelim(); + } + if (message.proofUnreceived.length !== 0) { + writer.uint32(18).bytes(message.proofUnreceived); + } + if (message.proofClose.length !== 0) { + writer.uint32(26).bytes(message.proofClose); + } + if (message.proofHeight !== undefined) { + Height.encode(message.proofHeight, writer.uint32(34).fork()).ldelim(); + } + if (message.nextSequenceRecv !== 0) { + writer.uint32(40).uint64(message.nextSequenceRecv); + } + if (message.signer !== "") { + writer.uint32(50).string(message.signer); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MsgTimeoutOnClose { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgTimeoutOnClose } as MsgTimeoutOnClose; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.packet = Packet.decode(reader, reader.uint32()); + break; + case 2: + message.proofUnreceived = reader.bytes(); + break; + case 3: + message.proofClose = reader.bytes(); + break; + case 4: + message.proofHeight = Height.decode(reader, reader.uint32()); + break; + case 5: + message.nextSequenceRecv = longToNumber(reader.uint64() as Long); + break; + case 6: + message.signer = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgTimeoutOnClose { + const message = { ...baseMsgTimeoutOnClose } as MsgTimeoutOnClose; + if (object.packet !== undefined && object.packet !== null) { + message.packet = Packet.fromJSON(object.packet); + } else { + message.packet = undefined; + } + if ( + object.proofUnreceived !== undefined && + object.proofUnreceived !== null + ) { + message.proofUnreceived = bytesFromBase64(object.proofUnreceived); + } + if (object.proofClose !== undefined && object.proofClose !== null) { + message.proofClose = bytesFromBase64(object.proofClose); + } + if (object.proofHeight !== undefined && object.proofHeight !== null) { + message.proofHeight = Height.fromJSON(object.proofHeight); + } else { + message.proofHeight = undefined; + } + if ( + object.nextSequenceRecv !== undefined && + object.nextSequenceRecv !== null + ) { + message.nextSequenceRecv = Number(object.nextSequenceRecv); + } else { + message.nextSequenceRecv = 0; + } + if (object.signer !== undefined && object.signer !== null) { + message.signer = String(object.signer); + } else { + message.signer = ""; + } + return message; + }, + + toJSON(message: MsgTimeoutOnClose): unknown { + const obj: any = {}; + message.packet !== undefined && + (obj.packet = message.packet ? Packet.toJSON(message.packet) : undefined); + message.proofUnreceived !== undefined && + (obj.proofUnreceived = base64FromBytes( + message.proofUnreceived !== undefined + ? message.proofUnreceived + : new Uint8Array() + )); + message.proofClose !== undefined && + (obj.proofClose = base64FromBytes( + message.proofClose !== undefined ? message.proofClose : new Uint8Array() + )); + message.proofHeight !== undefined && + (obj.proofHeight = message.proofHeight + ? Height.toJSON(message.proofHeight) + : undefined); + message.nextSequenceRecv !== undefined && + (obj.nextSequenceRecv = message.nextSequenceRecv); + message.signer !== undefined && (obj.signer = message.signer); + return obj; + }, + + fromPartial(object: DeepPartial): MsgTimeoutOnClose { + const message = { ...baseMsgTimeoutOnClose } as MsgTimeoutOnClose; + if (object.packet !== undefined && object.packet !== null) { + message.packet = Packet.fromPartial(object.packet); + } else { + message.packet = undefined; + } + if ( + object.proofUnreceived !== undefined && + object.proofUnreceived !== null + ) { + message.proofUnreceived = object.proofUnreceived; + } else { + message.proofUnreceived = new Uint8Array(); + } + if (object.proofClose !== undefined && object.proofClose !== null) { + message.proofClose = object.proofClose; + } else { + message.proofClose = new Uint8Array(); + } + if (object.proofHeight !== undefined && object.proofHeight !== null) { + message.proofHeight = Height.fromPartial(object.proofHeight); + } else { + message.proofHeight = undefined; + } + if ( + object.nextSequenceRecv !== undefined && + object.nextSequenceRecv !== null + ) { + message.nextSequenceRecv = object.nextSequenceRecv; + } else { + message.nextSequenceRecv = 0; + } + if (object.signer !== undefined && object.signer !== null) { + message.signer = object.signer; + } else { + message.signer = ""; + } + return message; + }, +}; + +const baseMsgTimeoutOnCloseResponse: object = { result: 0 }; + +export const MsgTimeoutOnCloseResponse = { + encode( + message: MsgTimeoutOnCloseResponse, + writer: Writer = Writer.create() + ): Writer { + if (message.result !== 0) { + writer.uint32(8).int32(message.result); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): MsgTimeoutOnCloseResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseMsgTimeoutOnCloseResponse, + } as MsgTimeoutOnCloseResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.result = reader.int32() as any; + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgTimeoutOnCloseResponse { + const message = { + ...baseMsgTimeoutOnCloseResponse, + } as MsgTimeoutOnCloseResponse; + if (object.result !== undefined && object.result !== null) { + message.result = responseResultTypeFromJSON(object.result); + } else { + message.result = 0; + } + return message; + }, + + toJSON(message: MsgTimeoutOnCloseResponse): unknown { + const obj: any = {}; + message.result !== undefined && + (obj.result = responseResultTypeToJSON(message.result)); + return obj; + }, + + fromPartial( + object: DeepPartial + ): MsgTimeoutOnCloseResponse { + const message = { + ...baseMsgTimeoutOnCloseResponse, + } as MsgTimeoutOnCloseResponse; + if (object.result !== undefined && object.result !== null) { + message.result = object.result; + } else { + message.result = 0; + } + return message; + }, +}; + +const baseMsgAcknowledgement: object = { signer: "" }; + +export const MsgAcknowledgement = { + encode( + message: MsgAcknowledgement, + writer: Writer = Writer.create() + ): Writer { + if (message.packet !== undefined) { + Packet.encode(message.packet, writer.uint32(10).fork()).ldelim(); + } + if (message.acknowledgement.length !== 0) { + writer.uint32(18).bytes(message.acknowledgement); + } + if (message.proofAcked.length !== 0) { + writer.uint32(26).bytes(message.proofAcked); + } + if (message.proofHeight !== undefined) { + Height.encode(message.proofHeight, writer.uint32(34).fork()).ldelim(); + } + if (message.signer !== "") { + writer.uint32(42).string(message.signer); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MsgAcknowledgement { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgAcknowledgement } as MsgAcknowledgement; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.packet = Packet.decode(reader, reader.uint32()); + break; + case 2: + message.acknowledgement = reader.bytes(); + break; + case 3: + message.proofAcked = reader.bytes(); + break; + case 4: + message.proofHeight = Height.decode(reader, reader.uint32()); + break; + case 5: + message.signer = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgAcknowledgement { + const message = { ...baseMsgAcknowledgement } as MsgAcknowledgement; + if (object.packet !== undefined && object.packet !== null) { + message.packet = Packet.fromJSON(object.packet); + } else { + message.packet = undefined; + } + if ( + object.acknowledgement !== undefined && + object.acknowledgement !== null + ) { + message.acknowledgement = bytesFromBase64(object.acknowledgement); + } + if (object.proofAcked !== undefined && object.proofAcked !== null) { + message.proofAcked = bytesFromBase64(object.proofAcked); + } + if (object.proofHeight !== undefined && object.proofHeight !== null) { + message.proofHeight = Height.fromJSON(object.proofHeight); + } else { + message.proofHeight = undefined; + } + if (object.signer !== undefined && object.signer !== null) { + message.signer = String(object.signer); + } else { + message.signer = ""; + } + return message; + }, + + toJSON(message: MsgAcknowledgement): unknown { + const obj: any = {}; + message.packet !== undefined && + (obj.packet = message.packet ? Packet.toJSON(message.packet) : undefined); + message.acknowledgement !== undefined && + (obj.acknowledgement = base64FromBytes( + message.acknowledgement !== undefined + ? message.acknowledgement + : new Uint8Array() + )); + message.proofAcked !== undefined && + (obj.proofAcked = base64FromBytes( + message.proofAcked !== undefined ? message.proofAcked : new Uint8Array() + )); + message.proofHeight !== undefined && + (obj.proofHeight = message.proofHeight + ? Height.toJSON(message.proofHeight) + : undefined); + message.signer !== undefined && (obj.signer = message.signer); + return obj; + }, + + fromPartial(object: DeepPartial): MsgAcknowledgement { + const message = { ...baseMsgAcknowledgement } as MsgAcknowledgement; + if (object.packet !== undefined && object.packet !== null) { + message.packet = Packet.fromPartial(object.packet); + } else { + message.packet = undefined; + } + if ( + object.acknowledgement !== undefined && + object.acknowledgement !== null + ) { + message.acknowledgement = object.acknowledgement; + } else { + message.acknowledgement = new Uint8Array(); + } + if (object.proofAcked !== undefined && object.proofAcked !== null) { + message.proofAcked = object.proofAcked; + } else { + message.proofAcked = new Uint8Array(); + } + if (object.proofHeight !== undefined && object.proofHeight !== null) { + message.proofHeight = Height.fromPartial(object.proofHeight); + } else { + message.proofHeight = undefined; + } + if (object.signer !== undefined && object.signer !== null) { + message.signer = object.signer; + } else { + message.signer = ""; + } + return message; + }, +}; + +const baseMsgAcknowledgementResponse: object = { result: 0 }; + +export const MsgAcknowledgementResponse = { + encode( + message: MsgAcknowledgementResponse, + writer: Writer = Writer.create() + ): Writer { + if (message.result !== 0) { + writer.uint32(8).int32(message.result); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): MsgAcknowledgementResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseMsgAcknowledgementResponse, + } as MsgAcknowledgementResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.result = reader.int32() as any; + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgAcknowledgementResponse { + const message = { + ...baseMsgAcknowledgementResponse, + } as MsgAcknowledgementResponse; + if (object.result !== undefined && object.result !== null) { + message.result = responseResultTypeFromJSON(object.result); + } else { + message.result = 0; + } + return message; + }, + + toJSON(message: MsgAcknowledgementResponse): unknown { + const obj: any = {}; + message.result !== undefined && + (obj.result = responseResultTypeToJSON(message.result)); + return obj; + }, + + fromPartial( + object: DeepPartial + ): MsgAcknowledgementResponse { + const message = { + ...baseMsgAcknowledgementResponse, + } as MsgAcknowledgementResponse; + if (object.result !== undefined && object.result !== null) { + message.result = object.result; + } else { + message.result = 0; + } + return message; + }, +}; + +/** Msg defines the ibc/channel Msg service. */ +export interface Msg { + /** ChannelOpenInit defines a rpc handler method for MsgChannelOpenInit. */ + ChannelOpenInit( + request: MsgChannelOpenInit + ): Promise; + /** ChannelOpenTry defines a rpc handler method for MsgChannelOpenTry. */ + ChannelOpenTry( + request: MsgChannelOpenTry + ): Promise; + /** ChannelOpenAck defines a rpc handler method for MsgChannelOpenAck. */ + ChannelOpenAck( + request: MsgChannelOpenAck + ): Promise; + /** ChannelOpenConfirm defines a rpc handler method for MsgChannelOpenConfirm. */ + ChannelOpenConfirm( + request: MsgChannelOpenConfirm + ): Promise; + /** ChannelCloseInit defines a rpc handler method for MsgChannelCloseInit. */ + ChannelCloseInit( + request: MsgChannelCloseInit + ): Promise; + /** + * ChannelCloseConfirm defines a rpc handler method for + * MsgChannelCloseConfirm. + */ + ChannelCloseConfirm( + request: MsgChannelCloseConfirm + ): Promise; + /** RecvPacket defines a rpc handler method for MsgRecvPacket. */ + RecvPacket(request: MsgRecvPacket): Promise; + /** Timeout defines a rpc handler method for MsgTimeout. */ + Timeout(request: MsgTimeout): Promise; + /** TimeoutOnClose defines a rpc handler method for MsgTimeoutOnClose. */ + TimeoutOnClose( + request: MsgTimeoutOnClose + ): Promise; + /** Acknowledgement defines a rpc handler method for MsgAcknowledgement. */ + Acknowledgement( + request: MsgAcknowledgement + ): Promise; +} + +export class MsgClientImpl implements Msg { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + } + ChannelOpenInit( + request: MsgChannelOpenInit + ): Promise { + const data = MsgChannelOpenInit.encode(request).finish(); + const promise = this.rpc.request( + "ibc.core.channel.v1.Msg", + "ChannelOpenInit", + data + ); + return promise.then((data) => + MsgChannelOpenInitResponse.decode(new Reader(data)) + ); + } + + ChannelOpenTry( + request: MsgChannelOpenTry + ): Promise { + const data = MsgChannelOpenTry.encode(request).finish(); + const promise = this.rpc.request( + "ibc.core.channel.v1.Msg", + "ChannelOpenTry", + data + ); + return promise.then((data) => + MsgChannelOpenTryResponse.decode(new Reader(data)) + ); + } + + ChannelOpenAck( + request: MsgChannelOpenAck + ): Promise { + const data = MsgChannelOpenAck.encode(request).finish(); + const promise = this.rpc.request( + "ibc.core.channel.v1.Msg", + "ChannelOpenAck", + data + ); + return promise.then((data) => + MsgChannelOpenAckResponse.decode(new Reader(data)) + ); + } + + ChannelOpenConfirm( + request: MsgChannelOpenConfirm + ): Promise { + const data = MsgChannelOpenConfirm.encode(request).finish(); + const promise = this.rpc.request( + "ibc.core.channel.v1.Msg", + "ChannelOpenConfirm", + data + ); + return promise.then((data) => + MsgChannelOpenConfirmResponse.decode(new Reader(data)) + ); + } + + ChannelCloseInit( + request: MsgChannelCloseInit + ): Promise { + const data = MsgChannelCloseInit.encode(request).finish(); + const promise = this.rpc.request( + "ibc.core.channel.v1.Msg", + "ChannelCloseInit", + data + ); + return promise.then((data) => + MsgChannelCloseInitResponse.decode(new Reader(data)) + ); + } + + ChannelCloseConfirm( + request: MsgChannelCloseConfirm + ): Promise { + const data = MsgChannelCloseConfirm.encode(request).finish(); + const promise = this.rpc.request( + "ibc.core.channel.v1.Msg", + "ChannelCloseConfirm", + data + ); + return promise.then((data) => + MsgChannelCloseConfirmResponse.decode(new Reader(data)) + ); + } + + RecvPacket(request: MsgRecvPacket): Promise { + const data = MsgRecvPacket.encode(request).finish(); + const promise = this.rpc.request( + "ibc.core.channel.v1.Msg", + "RecvPacket", + data + ); + return promise.then((data) => + MsgRecvPacketResponse.decode(new Reader(data)) + ); + } + + Timeout(request: MsgTimeout): Promise { + const data = MsgTimeout.encode(request).finish(); + const promise = this.rpc.request( + "ibc.core.channel.v1.Msg", + "Timeout", + data + ); + return promise.then((data) => MsgTimeoutResponse.decode(new Reader(data))); + } + + TimeoutOnClose( + request: MsgTimeoutOnClose + ): Promise { + const data = MsgTimeoutOnClose.encode(request).finish(); + const promise = this.rpc.request( + "ibc.core.channel.v1.Msg", + "TimeoutOnClose", + data + ); + return promise.then((data) => + MsgTimeoutOnCloseResponse.decode(new Reader(data)) + ); + } + + Acknowledgement( + request: MsgAcknowledgement + ): Promise { + const data = MsgAcknowledgement.encode(request).finish(); + const promise = this.rpc.request( + "ibc.core.channel.v1.Msg", + "Acknowledgement", + data + ); + return promise.then((data) => + MsgAcknowledgementResponse.decode(new Reader(data)) + ); + } +} + +interface Rpc { + request( + service: string, + method: string, + data: Uint8Array + ): Promise; +} + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/ibc.core.channel.v1/types/ibc/core/client/v1/client.ts b/ts-client/ibc.core.channel.v1/types/ibc/core/client/v1/client.ts new file mode 100644 index 00000000..7a8e15b6 --- /dev/null +++ b/ts-client/ibc.core.channel.v1/types/ibc/core/client/v1/client.ts @@ -0,0 +1,786 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; +import { Any } from "../../../../google/protobuf/any"; +import { Plan } from "../../../../cosmos/upgrade/v1beta1/upgrade"; + +export const protobufPackage = "ibc.core.client.v1"; + +/** + * IdentifiedClientState defines a client state with an additional client + * identifier field. + */ +export interface IdentifiedClientState { + /** client identifier */ + clientId: string; + /** client state */ + clientState: Any | undefined; +} + +/** + * ConsensusStateWithHeight defines a consensus state with an additional height + * field. + */ +export interface ConsensusStateWithHeight { + /** consensus state height */ + height: Height | undefined; + /** consensus state */ + consensusState: Any | undefined; +} + +/** + * ClientConsensusStates defines all the stored consensus states for a given + * client. + */ +export interface ClientConsensusStates { + /** client identifier */ + clientId: string; + /** consensus states and their heights associated with the client */ + consensusStates: ConsensusStateWithHeight[]; +} + +/** + * ClientUpdateProposal is a governance proposal. If it passes, the substitute + * client's latest consensus state is copied over to the subject client. The proposal + * handler may fail if the subject and the substitute do not match in client and + * chain parameters (with exception to latest height, frozen height, and chain-id). + */ +export interface ClientUpdateProposal { + /** the title of the update proposal */ + title: string; + /** the description of the proposal */ + description: string; + /** the client identifier for the client to be updated if the proposal passes */ + subjectClientId: string; + /** + * the substitute client identifier for the client standing in for the subject + * client + */ + substituteClientId: string; +} + +/** + * UpgradeProposal is a gov Content type for initiating an IBC breaking + * upgrade. + */ +export interface UpgradeProposal { + title: string; + description: string; + plan: Plan | undefined; + /** + * An UpgradedClientState must be provided to perform an IBC breaking upgrade. + * This will make the chain commit to the correct upgraded (self) client state + * before the upgrade occurs, so that connecting chains can verify that the + * new upgraded client is valid by verifying a proof on the previous version + * of the chain. This will allow IBC connections to persist smoothly across + * planned chain upgrades + */ + upgradedClientState: Any | undefined; +} + +/** + * Height is a monotonically increasing data type + * that can be compared against another Height for the purposes of updating and + * freezing clients + * + * Normally the RevisionHeight is incremented at each height while keeping + * RevisionNumber the same. However some consensus algorithms may choose to + * reset the height in certain conditions e.g. hard forks, state-machine + * breaking changes In these cases, the RevisionNumber is incremented so that + * height continues to be monitonically increasing even as the RevisionHeight + * gets reset + */ +export interface Height { + /** the revision that the client is currently on */ + revisionNumber: number; + /** the height within the given revision */ + revisionHeight: number; +} + +/** Params defines the set of IBC light client parameters. */ +export interface Params { + /** allowed_clients defines the list of allowed client state types. */ + allowedClients: string[]; +} + +const baseIdentifiedClientState: object = { clientId: "" }; + +export const IdentifiedClientState = { + encode( + message: IdentifiedClientState, + writer: Writer = Writer.create() + ): Writer { + if (message.clientId !== "") { + writer.uint32(10).string(message.clientId); + } + if (message.clientState !== undefined) { + Any.encode(message.clientState, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): IdentifiedClientState { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseIdentifiedClientState } as IdentifiedClientState; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.clientId = reader.string(); + break; + case 2: + message.clientState = Any.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): IdentifiedClientState { + const message = { ...baseIdentifiedClientState } as IdentifiedClientState; + if (object.clientId !== undefined && object.clientId !== null) { + message.clientId = String(object.clientId); + } else { + message.clientId = ""; + } + if (object.clientState !== undefined && object.clientState !== null) { + message.clientState = Any.fromJSON(object.clientState); + } else { + message.clientState = undefined; + } + return message; + }, + + toJSON(message: IdentifiedClientState): unknown { + const obj: any = {}; + message.clientId !== undefined && (obj.clientId = message.clientId); + message.clientState !== undefined && + (obj.clientState = message.clientState + ? Any.toJSON(message.clientState) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): IdentifiedClientState { + const message = { ...baseIdentifiedClientState } as IdentifiedClientState; + if (object.clientId !== undefined && object.clientId !== null) { + message.clientId = object.clientId; + } else { + message.clientId = ""; + } + if (object.clientState !== undefined && object.clientState !== null) { + message.clientState = Any.fromPartial(object.clientState); + } else { + message.clientState = undefined; + } + return message; + }, +}; + +const baseConsensusStateWithHeight: object = {}; + +export const ConsensusStateWithHeight = { + encode( + message: ConsensusStateWithHeight, + writer: Writer = Writer.create() + ): Writer { + if (message.height !== undefined) { + Height.encode(message.height, writer.uint32(10).fork()).ldelim(); + } + if (message.consensusState !== undefined) { + Any.encode(message.consensusState, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): ConsensusStateWithHeight { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseConsensusStateWithHeight, + } as ConsensusStateWithHeight; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.height = Height.decode(reader, reader.uint32()); + break; + case 2: + message.consensusState = Any.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ConsensusStateWithHeight { + const message = { + ...baseConsensusStateWithHeight, + } as ConsensusStateWithHeight; + if (object.height !== undefined && object.height !== null) { + message.height = Height.fromJSON(object.height); + } else { + message.height = undefined; + } + if (object.consensusState !== undefined && object.consensusState !== null) { + message.consensusState = Any.fromJSON(object.consensusState); + } else { + message.consensusState = undefined; + } + return message; + }, + + toJSON(message: ConsensusStateWithHeight): unknown { + const obj: any = {}; + message.height !== undefined && + (obj.height = message.height ? Height.toJSON(message.height) : undefined); + message.consensusState !== undefined && + (obj.consensusState = message.consensusState + ? Any.toJSON(message.consensusState) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): ConsensusStateWithHeight { + const message = { + ...baseConsensusStateWithHeight, + } as ConsensusStateWithHeight; + if (object.height !== undefined && object.height !== null) { + message.height = Height.fromPartial(object.height); + } else { + message.height = undefined; + } + if (object.consensusState !== undefined && object.consensusState !== null) { + message.consensusState = Any.fromPartial(object.consensusState); + } else { + message.consensusState = undefined; + } + return message; + }, +}; + +const baseClientConsensusStates: object = { clientId: "" }; + +export const ClientConsensusStates = { + encode( + message: ClientConsensusStates, + writer: Writer = Writer.create() + ): Writer { + if (message.clientId !== "") { + writer.uint32(10).string(message.clientId); + } + for (const v of message.consensusStates) { + ConsensusStateWithHeight.encode(v!, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ClientConsensusStates { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseClientConsensusStates } as ClientConsensusStates; + message.consensusStates = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.clientId = reader.string(); + break; + case 2: + message.consensusStates.push( + ConsensusStateWithHeight.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ClientConsensusStates { + const message = { ...baseClientConsensusStates } as ClientConsensusStates; + message.consensusStates = []; + if (object.clientId !== undefined && object.clientId !== null) { + message.clientId = String(object.clientId); + } else { + message.clientId = ""; + } + if ( + object.consensusStates !== undefined && + object.consensusStates !== null + ) { + for (const e of object.consensusStates) { + message.consensusStates.push(ConsensusStateWithHeight.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: ClientConsensusStates): unknown { + const obj: any = {}; + message.clientId !== undefined && (obj.clientId = message.clientId); + if (message.consensusStates) { + obj.consensusStates = message.consensusStates.map((e) => + e ? ConsensusStateWithHeight.toJSON(e) : undefined + ); + } else { + obj.consensusStates = []; + } + return obj; + }, + + fromPartial( + object: DeepPartial + ): ClientConsensusStates { + const message = { ...baseClientConsensusStates } as ClientConsensusStates; + message.consensusStates = []; + if (object.clientId !== undefined && object.clientId !== null) { + message.clientId = object.clientId; + } else { + message.clientId = ""; + } + if ( + object.consensusStates !== undefined && + object.consensusStates !== null + ) { + for (const e of object.consensusStates) { + message.consensusStates.push(ConsensusStateWithHeight.fromPartial(e)); + } + } + return message; + }, +}; + +const baseClientUpdateProposal: object = { + title: "", + description: "", + subjectClientId: "", + substituteClientId: "", +}; + +export const ClientUpdateProposal = { + encode( + message: ClientUpdateProposal, + writer: Writer = Writer.create() + ): Writer { + if (message.title !== "") { + writer.uint32(10).string(message.title); + } + if (message.description !== "") { + writer.uint32(18).string(message.description); + } + if (message.subjectClientId !== "") { + writer.uint32(26).string(message.subjectClientId); + } + if (message.substituteClientId !== "") { + writer.uint32(34).string(message.substituteClientId); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ClientUpdateProposal { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseClientUpdateProposal } as ClientUpdateProposal; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.title = reader.string(); + break; + case 2: + message.description = reader.string(); + break; + case 3: + message.subjectClientId = reader.string(); + break; + case 4: + message.substituteClientId = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ClientUpdateProposal { + const message = { ...baseClientUpdateProposal } as ClientUpdateProposal; + if (object.title !== undefined && object.title !== null) { + message.title = String(object.title); + } else { + message.title = ""; + } + if (object.description !== undefined && object.description !== null) { + message.description = String(object.description); + } else { + message.description = ""; + } + if ( + object.subjectClientId !== undefined && + object.subjectClientId !== null + ) { + message.subjectClientId = String(object.subjectClientId); + } else { + message.subjectClientId = ""; + } + if ( + object.substituteClientId !== undefined && + object.substituteClientId !== null + ) { + message.substituteClientId = String(object.substituteClientId); + } else { + message.substituteClientId = ""; + } + return message; + }, + + toJSON(message: ClientUpdateProposal): unknown { + const obj: any = {}; + message.title !== undefined && (obj.title = message.title); + message.description !== undefined && + (obj.description = message.description); + message.subjectClientId !== undefined && + (obj.subjectClientId = message.subjectClientId); + message.substituteClientId !== undefined && + (obj.substituteClientId = message.substituteClientId); + return obj; + }, + + fromPartial(object: DeepPartial): ClientUpdateProposal { + const message = { ...baseClientUpdateProposal } as ClientUpdateProposal; + if (object.title !== undefined && object.title !== null) { + message.title = object.title; + } else { + message.title = ""; + } + if (object.description !== undefined && object.description !== null) { + message.description = object.description; + } else { + message.description = ""; + } + if ( + object.subjectClientId !== undefined && + object.subjectClientId !== null + ) { + message.subjectClientId = object.subjectClientId; + } else { + message.subjectClientId = ""; + } + if ( + object.substituteClientId !== undefined && + object.substituteClientId !== null + ) { + message.substituteClientId = object.substituteClientId; + } else { + message.substituteClientId = ""; + } + return message; + }, +}; + +const baseUpgradeProposal: object = { title: "", description: "" }; + +export const UpgradeProposal = { + encode(message: UpgradeProposal, writer: Writer = Writer.create()): Writer { + if (message.title !== "") { + writer.uint32(10).string(message.title); + } + if (message.description !== "") { + writer.uint32(18).string(message.description); + } + if (message.plan !== undefined) { + Plan.encode(message.plan, writer.uint32(26).fork()).ldelim(); + } + if (message.upgradedClientState !== undefined) { + Any.encode( + message.upgradedClientState, + writer.uint32(34).fork() + ).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): UpgradeProposal { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseUpgradeProposal } as UpgradeProposal; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.title = reader.string(); + break; + case 2: + message.description = reader.string(); + break; + case 3: + message.plan = Plan.decode(reader, reader.uint32()); + break; + case 4: + message.upgradedClientState = Any.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): UpgradeProposal { + const message = { ...baseUpgradeProposal } as UpgradeProposal; + if (object.title !== undefined && object.title !== null) { + message.title = String(object.title); + } else { + message.title = ""; + } + if (object.description !== undefined && object.description !== null) { + message.description = String(object.description); + } else { + message.description = ""; + } + if (object.plan !== undefined && object.plan !== null) { + message.plan = Plan.fromJSON(object.plan); + } else { + message.plan = undefined; + } + if ( + object.upgradedClientState !== undefined && + object.upgradedClientState !== null + ) { + message.upgradedClientState = Any.fromJSON(object.upgradedClientState); + } else { + message.upgradedClientState = undefined; + } + return message; + }, + + toJSON(message: UpgradeProposal): unknown { + const obj: any = {}; + message.title !== undefined && (obj.title = message.title); + message.description !== undefined && + (obj.description = message.description); + message.plan !== undefined && + (obj.plan = message.plan ? Plan.toJSON(message.plan) : undefined); + message.upgradedClientState !== undefined && + (obj.upgradedClientState = message.upgradedClientState + ? Any.toJSON(message.upgradedClientState) + : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): UpgradeProposal { + const message = { ...baseUpgradeProposal } as UpgradeProposal; + if (object.title !== undefined && object.title !== null) { + message.title = object.title; + } else { + message.title = ""; + } + if (object.description !== undefined && object.description !== null) { + message.description = object.description; + } else { + message.description = ""; + } + if (object.plan !== undefined && object.plan !== null) { + message.plan = Plan.fromPartial(object.plan); + } else { + message.plan = undefined; + } + if ( + object.upgradedClientState !== undefined && + object.upgradedClientState !== null + ) { + message.upgradedClientState = Any.fromPartial(object.upgradedClientState); + } else { + message.upgradedClientState = undefined; + } + return message; + }, +}; + +const baseHeight: object = { revisionNumber: 0, revisionHeight: 0 }; + +export const Height = { + encode(message: Height, writer: Writer = Writer.create()): Writer { + if (message.revisionNumber !== 0) { + writer.uint32(8).uint64(message.revisionNumber); + } + if (message.revisionHeight !== 0) { + writer.uint32(16).uint64(message.revisionHeight); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Height { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseHeight } as Height; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.revisionNumber = longToNumber(reader.uint64() as Long); + break; + case 2: + message.revisionHeight = longToNumber(reader.uint64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Height { + const message = { ...baseHeight } as Height; + if (object.revisionNumber !== undefined && object.revisionNumber !== null) { + message.revisionNumber = Number(object.revisionNumber); + } else { + message.revisionNumber = 0; + } + if (object.revisionHeight !== undefined && object.revisionHeight !== null) { + message.revisionHeight = Number(object.revisionHeight); + } else { + message.revisionHeight = 0; + } + return message; + }, + + toJSON(message: Height): unknown { + const obj: any = {}; + message.revisionNumber !== undefined && + (obj.revisionNumber = message.revisionNumber); + message.revisionHeight !== undefined && + (obj.revisionHeight = message.revisionHeight); + return obj; + }, + + fromPartial(object: DeepPartial): Height { + const message = { ...baseHeight } as Height; + if (object.revisionNumber !== undefined && object.revisionNumber !== null) { + message.revisionNumber = object.revisionNumber; + } else { + message.revisionNumber = 0; + } + if (object.revisionHeight !== undefined && object.revisionHeight !== null) { + message.revisionHeight = object.revisionHeight; + } else { + message.revisionHeight = 0; + } + return message; + }, +}; + +const baseParams: object = { allowedClients: "" }; + +export const Params = { + encode(message: Params, writer: Writer = Writer.create()): Writer { + for (const v of message.allowedClients) { + writer.uint32(10).string(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Params { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseParams } as Params; + message.allowedClients = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.allowedClients.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Params { + const message = { ...baseParams } as Params; + message.allowedClients = []; + if (object.allowedClients !== undefined && object.allowedClients !== null) { + for (const e of object.allowedClients) { + message.allowedClients.push(String(e)); + } + } + return message; + }, + + toJSON(message: Params): unknown { + const obj: any = {}; + if (message.allowedClients) { + obj.allowedClients = message.allowedClients.map((e) => e); + } else { + obj.allowedClients = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): Params { + const message = { ...baseParams } as Params; + message.allowedClients = []; + if (object.allowedClients !== undefined && object.allowedClients !== null) { + for (const e of object.allowedClients) { + message.allowedClients.push(e); + } + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/ibc.core.client.v1/index.ts b/ts-client/ibc.core.client.v1/index.ts new file mode 100755 index 00000000..c9dfa159 --- /dev/null +++ b/ts-client/ibc.core.client.v1/index.ts @@ -0,0 +1,6 @@ +import Module from './module'; +import { txClient, queryClient, registry } from './module'; +import { msgTypes } from './registry'; + +export * from "./types"; +export { Module, msgTypes, txClient, queryClient, registry }; diff --git a/ts-client/ibc.core.client.v1/module.ts b/ts-client/ibc.core.client.v1/module.ts new file mode 100755 index 00000000..1ae4eb95 --- /dev/null +++ b/ts-client/ibc.core.client.v1/module.ts @@ -0,0 +1,66 @@ +// Generated by Ignite ignite.com/cli + +import { StdFee } from "@cosmjs/launchpad"; +import { SigningStargateClient, DeliverTxResponse } from "@cosmjs/stargate"; +import { EncodeObject, GeneratedType, OfflineSigner, Registry } from "@cosmjs/proto-signing"; +import { msgTypes } from './registry'; +import { IgniteClient } from "../client" +import { MissingWalletError } from "../helpers" +import { Api } from "./rest"; + + +export { }; + + + +export const registry = new Registry(msgTypes); + +const defaultFee = { + amount: [], + gas: "200000", +}; + +interface TxClientOptions { + addr: string + prefix: string + signer?: OfflineSigner +} + +export const txClient = ({ signer, prefix, addr }: TxClientOptions = { addr: "http://localhost:26657", prefix: "cosmos" }) => { + + return { + + + } +}; + +interface QueryClientOptions { + addr: string +} + +export const queryClient = ({ addr: addr }: QueryClientOptions = { addr: "http://localhost:1317" }) => { + return new Api({ baseUrl: addr }); +}; + +class SDKModule { + public query: ReturnType; + public tx: ReturnType; + + public registry: Array<[string, GeneratedType]>; + + constructor(client: IgniteClient) { + + this.query = queryClient({ addr: client.env.apiURL }); + this.tx = txClient({ signer: client.signer, addr: client.env.rpcURL, prefix: client.env.prefix ?? "cosmos" }); + } +}; + +const Module = (test: IgniteClient) => { + return { + module: { + IbcCoreClientV1: new SDKModule(test) + }, + registry: msgTypes + } +} +export default Module; \ No newline at end of file diff --git a/ts-client/ibc.core.client.v1/registry.ts b/ts-client/ibc.core.client.v1/registry.ts new file mode 100755 index 00000000..26157e4f --- /dev/null +++ b/ts-client/ibc.core.client.v1/registry.ts @@ -0,0 +1,7 @@ +import { GeneratedType } from "@cosmjs/proto-signing"; + +const msgTypes: Array<[string, GeneratedType]> = [ + +]; + +export { msgTypes } \ No newline at end of file diff --git a/ts-client/ibc.core.client.v1/rest.ts b/ts-client/ibc.core.client.v1/rest.ts new file mode 100644 index 00000000..1c581070 --- /dev/null +++ b/ts-client/ibc.core.client.v1/rest.ts @@ -0,0 +1,1278 @@ +/* eslint-disable */ +/* tslint:disable */ +/* + * --------------------------------------------------------------- + * ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ## + * ## ## + * ## AUTHOR: acacode ## + * ## SOURCE: https://github.com/acacode/swagger-typescript-api ## + * --------------------------------------------------------------- + */ + +/** +* `Any` contains an arbitrary serialized protocol buffer message along with a +URL that describes the type of the serialized message. + +Protobuf library provides support to pack/unpack Any values in the form +of utility functions or additional generated methods of the Any type. + +Example 1: Pack and unpack a message in C++. + + Foo foo = ...; + Any any; + any.PackFrom(foo); + ... + if (any.UnpackTo(&foo)) { + ... + } + +Example 2: Pack and unpack a message in Java. + + Foo foo = ...; + Any any = Any.pack(foo); + ... + if (any.is(Foo.class)) { + foo = any.unpack(Foo.class); + } + + Example 3: Pack and unpack a message in Python. + + foo = Foo(...) + any = Any() + any.Pack(foo) + ... + if any.Is(Foo.DESCRIPTOR): + any.Unpack(foo) + ... + + Example 4: Pack and unpack a message in Go + + foo := &pb.Foo{...} + any, err := anypb.New(foo) + if err != nil { + ... + } + ... + foo := &pb.Foo{} + if err := any.UnmarshalTo(foo); err != nil { + ... + } + +The pack methods provided by protobuf library will by default use +'type.googleapis.com/full.type.name' as the type URL and the unpack +methods only use the fully qualified type name after the last '/' +in the type URL, for example "foo.bar.com/x/y.z" will yield type +name "y.z". + + +JSON +==== +The JSON representation of an `Any` value uses the regular +representation of the deserialized, embedded message, with an +additional field `@type` which contains the type URL. Example: + + package google.profile; + message Person { + string first_name = 1; + string last_name = 2; + } + + { + "@type": "type.googleapis.com/google.profile.Person", + "firstName": , + "lastName": + } + +If the embedded message type is well-known and has a custom JSON +representation, that representation will be embedded adding a field +`value` which holds the custom JSON in addition to the `@type` +field. Example (for message [google.protobuf.Duration][]): + + { + "@type": "type.googleapis.com/google.protobuf.Duration", + "value": "1.212s" + } +*/ +export interface ProtobufAny { + /** + * A URL/resource name that uniquely identifies the type of the serialized + * protocol buffer message. This string must contain at least + * one "/" character. The last segment of the URL's path must represent + * the fully qualified name of the type (as in + * `path/google.protobuf.Duration`). The name should be in a canonical form + * (e.g., leading "." is not accepted). + * + * In practice, teams usually precompile into the binary all types that they + * expect it to use in the context of Any. However, for URLs which use the + * scheme `http`, `https`, or no scheme, one can optionally set up a type + * server that maps type URLs to message definitions as follows: + * + * * If no scheme is provided, `https` is assumed. + * * An HTTP GET on the URL must yield a [google.protobuf.Type][] + * value in binary format, or produce an error. + * * Applications are allowed to cache lookup results based on the + * URL, or have them precompiled into a binary to avoid any + * lookup. Therefore, binary compatibility needs to be preserved + * on changes to types. (Use versioned type names to manage + * breaking changes.) + * + * Note: this functionality is not currently available in the official + * protobuf release, and it is not used for type URLs beginning with + * type.googleapis.com. + * + * Schemes other than `http`, `https` (or the empty scheme) might be + * used with implementation specific semantics. + */ + "@type"?: string; +} + +export interface RpcStatus { + /** @format int32 */ + code?: number; + message?: string; + details?: ProtobufAny[]; +} + +/** +* ConsensusStateWithHeight defines a consensus state with an additional height +field. +*/ +export interface V1ConsensusStateWithHeight { + /** + * Normally the RevisionHeight is incremented at each height while keeping + * RevisionNumber the same. However some consensus algorithms may choose to + * reset the height in certain conditions e.g. hard forks, state-machine + * breaking changes In these cases, the RevisionNumber is incremented so that + * height continues to be monitonically increasing even as the RevisionHeight + * gets reset + */ + height?: V1Height; + + /** + * `Any` contains an arbitrary serialized protocol buffer message along with a + * URL that describes the type of the serialized message. + * + * Protobuf library provides support to pack/unpack Any values in the form + * of utility functions or additional generated methods of the Any type. + * + * Example 1: Pack and unpack a message in C++. + * + * Foo foo = ...; + * Any any; + * any.PackFrom(foo); + * ... + * if (any.UnpackTo(&foo)) { + * ... + * } + * + * Example 2: Pack and unpack a message in Java. + * + * Foo foo = ...; + * Any any = Any.pack(foo); + * ... + * if (any.is(Foo.class)) { + * foo = any.unpack(Foo.class); + * } + * + * Example 3: Pack and unpack a message in Python. + * + * foo = Foo(...) + * any = Any() + * any.Pack(foo) + * ... + * if any.Is(Foo.DESCRIPTOR): + * any.Unpack(foo) + * ... + * + * Example 4: Pack and unpack a message in Go + * + * foo := &pb.Foo{...} + * any, err := anypb.New(foo) + * if err != nil { + * ... + * } + * ... + * foo := &pb.Foo{} + * if err := any.UnmarshalTo(foo); err != nil { + * ... + * } + * + * The pack methods provided by protobuf library will by default use + * 'type.googleapis.com/full.type.name' as the type URL and the unpack + * methods only use the fully qualified type name after the last '/' + * in the type URL, for example "foo.bar.com/x/y.z" will yield type + * name "y.z". + * + * + * JSON + * ==== + * The JSON representation of an `Any` value uses the regular + * representation of the deserialized, embedded message, with an + * additional field `@type` which contains the type URL. Example: + * + * package google.profile; + * message Person { + * string first_name = 1; + * string last_name = 2; + * } + * + * { + * "@type": "type.googleapis.com/google.profile.Person", + * "firstName": , + * "lastName": + * } + * + * If the embedded message type is well-known and has a custom JSON + * representation, that representation will be embedded adding a field + * `value` which holds the custom JSON in addition to the `@type` + * field. Example (for message [google.protobuf.Duration][]): + * + * { + * "@type": "type.googleapis.com/google.protobuf.Duration", + * "value": "1.212s" + * } + */ + consensus_state?: ProtobufAny; +} + +/** +* Normally the RevisionHeight is incremented at each height while keeping +RevisionNumber the same. However some consensus algorithms may choose to +reset the height in certain conditions e.g. hard forks, state-machine +breaking changes In these cases, the RevisionNumber is incremented so that +height continues to be monitonically increasing even as the RevisionHeight +gets reset +*/ +export interface V1Height { + /** @format uint64 */ + revision_number?: string; + + /** @format uint64 */ + revision_height?: string; +} + +/** +* IdentifiedClientState defines a client state with an additional client +identifier field. +*/ +export interface V1IdentifiedClientState { + client_id?: string; + + /** + * `Any` contains an arbitrary serialized protocol buffer message along with a + * URL that describes the type of the serialized message. + * + * Protobuf library provides support to pack/unpack Any values in the form + * of utility functions or additional generated methods of the Any type. + * + * Example 1: Pack and unpack a message in C++. + * + * Foo foo = ...; + * Any any; + * any.PackFrom(foo); + * ... + * if (any.UnpackTo(&foo)) { + * ... + * } + * + * Example 2: Pack and unpack a message in Java. + * + * Foo foo = ...; + * Any any = Any.pack(foo); + * ... + * if (any.is(Foo.class)) { + * foo = any.unpack(Foo.class); + * } + * + * Example 3: Pack and unpack a message in Python. + * + * foo = Foo(...) + * any = Any() + * any.Pack(foo) + * ... + * if any.Is(Foo.DESCRIPTOR): + * any.Unpack(foo) + * ... + * + * Example 4: Pack and unpack a message in Go + * + * foo := &pb.Foo{...} + * any, err := anypb.New(foo) + * if err != nil { + * ... + * } + * ... + * foo := &pb.Foo{} + * if err := any.UnmarshalTo(foo); err != nil { + * ... + * } + * + * The pack methods provided by protobuf library will by default use + * 'type.googleapis.com/full.type.name' as the type URL and the unpack + * methods only use the fully qualified type name after the last '/' + * in the type URL, for example "foo.bar.com/x/y.z" will yield type + * name "y.z". + * + * + * JSON + * ==== + * The JSON representation of an `Any` value uses the regular + * representation of the deserialized, embedded message, with an + * additional field `@type` which contains the type URL. Example: + * + * package google.profile; + * message Person { + * string first_name = 1; + * string last_name = 2; + * } + * + * { + * "@type": "type.googleapis.com/google.profile.Person", + * "firstName": , + * "lastName": + * } + * + * If the embedded message type is well-known and has a custom JSON + * representation, that representation will be embedded adding a field + * `value` which holds the custom JSON in addition to the `@type` + * field. Example (for message [google.protobuf.Duration][]): + * + * { + * "@type": "type.googleapis.com/google.protobuf.Duration", + * "value": "1.212s" + * } + */ + client_state?: ProtobufAny; +} + +/** + * MsgCreateClientResponse defines the Msg/CreateClient response type. + */ +export type V1MsgCreateClientResponse = object; + +/** +* MsgSubmitMisbehaviourResponse defines the Msg/SubmitMisbehaviour response +type. +*/ +export type V1MsgSubmitMisbehaviourResponse = object; + +/** + * MsgUpdateClientResponse defines the Msg/UpdateClient response type. + */ +export type V1MsgUpdateClientResponse = object; + +/** + * MsgUpgradeClientResponse defines the Msg/UpgradeClient response type. + */ +export type V1MsgUpgradeClientResponse = object; + +/** + * Params defines the set of IBC light client parameters. + */ +export interface V1Params { + /** allowed_clients defines the list of allowed client state types. */ + allowed_clients?: string[]; +} + +/** +* QueryClientParamsResponse is the response type for the Query/ClientParams RPC +method. +*/ +export interface V1QueryClientParamsResponse { + /** params defines the parameters of the module. */ + params?: V1Params; +} + +/** +* QueryClientStateResponse is the response type for the Query/ClientState RPC +method. Besides the client state, it includes a proof and the height from +which the proof was retrieved. +*/ +export interface V1QueryClientStateResponse { + /** + * `Any` contains an arbitrary serialized protocol buffer message along with a + * URL that describes the type of the serialized message. + * + * Protobuf library provides support to pack/unpack Any values in the form + * of utility functions or additional generated methods of the Any type. + * + * Example 1: Pack and unpack a message in C++. + * + * Foo foo = ...; + * Any any; + * any.PackFrom(foo); + * ... + * if (any.UnpackTo(&foo)) { + * ... + * } + * + * Example 2: Pack and unpack a message in Java. + * + * Foo foo = ...; + * Any any = Any.pack(foo); + * ... + * if (any.is(Foo.class)) { + * foo = any.unpack(Foo.class); + * } + * + * Example 3: Pack and unpack a message in Python. + * + * foo = Foo(...) + * any = Any() + * any.Pack(foo) + * ... + * if any.Is(Foo.DESCRIPTOR): + * any.Unpack(foo) + * ... + * + * Example 4: Pack and unpack a message in Go + * + * foo := &pb.Foo{...} + * any, err := anypb.New(foo) + * if err != nil { + * ... + * } + * ... + * foo := &pb.Foo{} + * if err := any.UnmarshalTo(foo); err != nil { + * ... + * } + * + * The pack methods provided by protobuf library will by default use + * 'type.googleapis.com/full.type.name' as the type URL and the unpack + * methods only use the fully qualified type name after the last '/' + * in the type URL, for example "foo.bar.com/x/y.z" will yield type + * name "y.z". + * + * + * JSON + * ==== + * The JSON representation of an `Any` value uses the regular + * representation of the deserialized, embedded message, with an + * additional field `@type` which contains the type URL. Example: + * + * package google.profile; + * message Person { + * string first_name = 1; + * string last_name = 2; + * } + * + * { + * "@type": "type.googleapis.com/google.profile.Person", + * "firstName": , + * "lastName": + * } + * + * If the embedded message type is well-known and has a custom JSON + * representation, that representation will be embedded adding a field + * `value` which holds the custom JSON in addition to the `@type` + * field. Example (for message [google.protobuf.Duration][]): + * + * { + * "@type": "type.googleapis.com/google.protobuf.Duration", + * "value": "1.212s" + * } + */ + client_state?: ProtobufAny; + + /** @format byte */ + proof?: string; + + /** + * Normally the RevisionHeight is incremented at each height while keeping + * RevisionNumber the same. However some consensus algorithms may choose to + * reset the height in certain conditions e.g. hard forks, state-machine + * breaking changes In these cases, the RevisionNumber is incremented so that + * height continues to be monitonically increasing even as the RevisionHeight + * gets reset + */ + proof_height?: V1Height; +} + +/** +* QueryClientStatesResponse is the response type for the Query/ClientStates RPC +method. +*/ +export interface V1QueryClientStatesResponse { + /** list of stored ClientStates of the chain. */ + client_states?: V1IdentifiedClientState[]; + + /** + * PageResponse is to be embedded in gRPC response messages where the + * corresponding request message has used PageRequest. + * + * message SomeResponse { + * repeated Bar results = 1; + * PageResponse page = 2; + * } + */ + pagination?: V1Beta1PageResponse; +} + +/** +* QueryClientStatusResponse is the response type for the Query/ClientStatus RPC +method. It returns the current status of the IBC client. +*/ +export interface V1QueryClientStatusResponse { + status?: string; +} + +export interface V1QueryConsensusStateHeightsResponse { + consensus_state_heights?: V1Height[]; + + /** + * PageResponse is to be embedded in gRPC response messages where the + * corresponding request message has used PageRequest. + * + * message SomeResponse { + * repeated Bar results = 1; + * PageResponse page = 2; + * } + */ + pagination?: V1Beta1PageResponse; +} + +export interface V1QueryConsensusStateResponse { + /** + * `Any` contains an arbitrary serialized protocol buffer message along with a + * URL that describes the type of the serialized message. + * + * Protobuf library provides support to pack/unpack Any values in the form + * of utility functions or additional generated methods of the Any type. + * + * Example 1: Pack and unpack a message in C++. + * + * Foo foo = ...; + * Any any; + * any.PackFrom(foo); + * ... + * if (any.UnpackTo(&foo)) { + * ... + * } + * + * Example 2: Pack and unpack a message in Java. + * + * Foo foo = ...; + * Any any = Any.pack(foo); + * ... + * if (any.is(Foo.class)) { + * foo = any.unpack(Foo.class); + * } + * + * Example 3: Pack and unpack a message in Python. + * + * foo = Foo(...) + * any = Any() + * any.Pack(foo) + * ... + * if any.Is(Foo.DESCRIPTOR): + * any.Unpack(foo) + * ... + * + * Example 4: Pack and unpack a message in Go + * + * foo := &pb.Foo{...} + * any, err := anypb.New(foo) + * if err != nil { + * ... + * } + * ... + * foo := &pb.Foo{} + * if err := any.UnmarshalTo(foo); err != nil { + * ... + * } + * + * The pack methods provided by protobuf library will by default use + * 'type.googleapis.com/full.type.name' as the type URL and the unpack + * methods only use the fully qualified type name after the last '/' + * in the type URL, for example "foo.bar.com/x/y.z" will yield type + * name "y.z". + * + * + * JSON + * ==== + * The JSON representation of an `Any` value uses the regular + * representation of the deserialized, embedded message, with an + * additional field `@type` which contains the type URL. Example: + * + * package google.profile; + * message Person { + * string first_name = 1; + * string last_name = 2; + * } + * + * { + * "@type": "type.googleapis.com/google.profile.Person", + * "firstName": , + * "lastName": + * } + * + * If the embedded message type is well-known and has a custom JSON + * representation, that representation will be embedded adding a field + * `value` which holds the custom JSON in addition to the `@type` + * field. Example (for message [google.protobuf.Duration][]): + * + * { + * "@type": "type.googleapis.com/google.protobuf.Duration", + * "value": "1.212s" + * } + */ + consensus_state?: ProtobufAny; + + /** @format byte */ + proof?: string; + + /** + * Normally the RevisionHeight is incremented at each height while keeping + * RevisionNumber the same. However some consensus algorithms may choose to + * reset the height in certain conditions e.g. hard forks, state-machine + * breaking changes In these cases, the RevisionNumber is incremented so that + * height continues to be monitonically increasing even as the RevisionHeight + * gets reset + */ + proof_height?: V1Height; +} + +export interface V1QueryConsensusStatesResponse { + consensus_states?: V1ConsensusStateWithHeight[]; + + /** + * PageResponse is to be embedded in gRPC response messages where the + * corresponding request message has used PageRequest. + * + * message SomeResponse { + * repeated Bar results = 1; + * PageResponse page = 2; + * } + */ + pagination?: V1Beta1PageResponse; +} + +/** +* QueryUpgradedClientStateResponse is the response type for the +Query/UpgradedClientState RPC method. +*/ +export interface V1QueryUpgradedClientStateResponse { + /** + * `Any` contains an arbitrary serialized protocol buffer message along with a + * URL that describes the type of the serialized message. + * + * Protobuf library provides support to pack/unpack Any values in the form + * of utility functions or additional generated methods of the Any type. + * + * Example 1: Pack and unpack a message in C++. + * + * Foo foo = ...; + * Any any; + * any.PackFrom(foo); + * ... + * if (any.UnpackTo(&foo)) { + * ... + * } + * + * Example 2: Pack and unpack a message in Java. + * + * Foo foo = ...; + * Any any = Any.pack(foo); + * ... + * if (any.is(Foo.class)) { + * foo = any.unpack(Foo.class); + * } + * + * Example 3: Pack and unpack a message in Python. + * + * foo = Foo(...) + * any = Any() + * any.Pack(foo) + * ... + * if any.Is(Foo.DESCRIPTOR): + * any.Unpack(foo) + * ... + * + * Example 4: Pack and unpack a message in Go + * + * foo := &pb.Foo{...} + * any, err := anypb.New(foo) + * if err != nil { + * ... + * } + * ... + * foo := &pb.Foo{} + * if err := any.UnmarshalTo(foo); err != nil { + * ... + * } + * + * The pack methods provided by protobuf library will by default use + * 'type.googleapis.com/full.type.name' as the type URL and the unpack + * methods only use the fully qualified type name after the last '/' + * in the type URL, for example "foo.bar.com/x/y.z" will yield type + * name "y.z". + * + * + * JSON + * ==== + * The JSON representation of an `Any` value uses the regular + * representation of the deserialized, embedded message, with an + * additional field `@type` which contains the type URL. Example: + * + * package google.profile; + * message Person { + * string first_name = 1; + * string last_name = 2; + * } + * + * { + * "@type": "type.googleapis.com/google.profile.Person", + * "firstName": , + * "lastName": + * } + * + * If the embedded message type is well-known and has a custom JSON + * representation, that representation will be embedded adding a field + * `value` which holds the custom JSON in addition to the `@type` + * field. Example (for message [google.protobuf.Duration][]): + * + * { + * "@type": "type.googleapis.com/google.protobuf.Duration", + * "value": "1.212s" + * } + */ + upgraded_client_state?: ProtobufAny; +} + +/** +* QueryUpgradedConsensusStateResponse is the response type for the +Query/UpgradedConsensusState RPC method. +*/ +export interface V1QueryUpgradedConsensusStateResponse { + /** + * `Any` contains an arbitrary serialized protocol buffer message along with a + * URL that describes the type of the serialized message. + * + * Protobuf library provides support to pack/unpack Any values in the form + * of utility functions or additional generated methods of the Any type. + * + * Example 1: Pack and unpack a message in C++. + * + * Foo foo = ...; + * Any any; + * any.PackFrom(foo); + * ... + * if (any.UnpackTo(&foo)) { + * ... + * } + * + * Example 2: Pack and unpack a message in Java. + * + * Foo foo = ...; + * Any any = Any.pack(foo); + * ... + * if (any.is(Foo.class)) { + * foo = any.unpack(Foo.class); + * } + * + * Example 3: Pack and unpack a message in Python. + * + * foo = Foo(...) + * any = Any() + * any.Pack(foo) + * ... + * if any.Is(Foo.DESCRIPTOR): + * any.Unpack(foo) + * ... + * + * Example 4: Pack and unpack a message in Go + * + * foo := &pb.Foo{...} + * any, err := anypb.New(foo) + * if err != nil { + * ... + * } + * ... + * foo := &pb.Foo{} + * if err := any.UnmarshalTo(foo); err != nil { + * ... + * } + * + * The pack methods provided by protobuf library will by default use + * 'type.googleapis.com/full.type.name' as the type URL and the unpack + * methods only use the fully qualified type name after the last '/' + * in the type URL, for example "foo.bar.com/x/y.z" will yield type + * name "y.z". + * + * + * JSON + * ==== + * The JSON representation of an `Any` value uses the regular + * representation of the deserialized, embedded message, with an + * additional field `@type` which contains the type URL. Example: + * + * package google.profile; + * message Person { + * string first_name = 1; + * string last_name = 2; + * } + * + * { + * "@type": "type.googleapis.com/google.profile.Person", + * "firstName": , + * "lastName": + * } + * + * If the embedded message type is well-known and has a custom JSON + * representation, that representation will be embedded adding a field + * `value` which holds the custom JSON in addition to the `@type` + * field. Example (for message [google.protobuf.Duration][]): + * + * { + * "@type": "type.googleapis.com/google.protobuf.Duration", + * "value": "1.212s" + * } + */ + upgraded_consensus_state?: ProtobufAny; +} + +/** +* message SomeRequest { + Foo some_parameter = 1; + PageRequest pagination = 2; + } +*/ +export interface V1Beta1PageRequest { + /** + * key is a value returned in PageResponse.next_key to begin + * querying the next page most efficiently. Only one of offset or key + * should be set. + * @format byte + */ + key?: string; + + /** + * offset is a numeric offset that can be used when key is unavailable. + * It is less efficient than using key. Only one of offset or key should + * be set. + * @format uint64 + */ + offset?: string; + + /** + * limit is the total number of results to be returned in the result page. + * If left empty it will default to a value to be set by each app. + * @format uint64 + */ + limit?: string; + + /** + * count_total is set to true to indicate that the result set should include + * a count of the total number of items available for pagination in UIs. + * count_total is only respected when offset is used. It is ignored when key + * is set. + */ + count_total?: boolean; + + /** + * reverse is set to true if results are to be returned in the descending order. + * + * Since: cosmos-sdk 0.43 + */ + reverse?: boolean; +} + +/** +* PageResponse is to be embedded in gRPC response messages where the +corresponding request message has used PageRequest. + + message SomeResponse { + repeated Bar results = 1; + PageResponse page = 2; + } +*/ +export interface V1Beta1PageResponse { + /** @format byte */ + next_key?: string; + + /** @format uint64 */ + total?: string; +} + +export type QueryParamsType = Record; +export type ResponseFormat = keyof Omit; + +export interface FullRequestParams extends Omit { + /** set parameter to `true` for call `securityWorker` for this request */ + secure?: boolean; + /** request path */ + path: string; + /** content type of request body */ + type?: ContentType; + /** query params */ + query?: QueryParamsType; + /** format of response (i.e. response.json() -> format: "json") */ + format?: keyof Omit; + /** request body */ + body?: unknown; + /** base url */ + baseUrl?: string; + /** request cancellation token */ + cancelToken?: CancelToken; +} + +export type RequestParams = Omit; + +export interface ApiConfig { + baseUrl?: string; + baseApiParams?: Omit; + securityWorker?: (securityData: SecurityDataType) => RequestParams | void; +} + +export interface HttpResponse extends Response { + data: D; + error: E; +} + +type CancelToken = Symbol | string | number; + +export enum ContentType { + Json = "application/json", + FormData = "multipart/form-data", + UrlEncoded = "application/x-www-form-urlencoded", +} + +export class HttpClient { + public baseUrl: string = ""; + private securityData: SecurityDataType = null as any; + private securityWorker: null | ApiConfig["securityWorker"] = null; + private abortControllers = new Map(); + + private baseApiParams: RequestParams = { + credentials: "same-origin", + headers: {}, + redirect: "follow", + referrerPolicy: "no-referrer", + }; + + constructor(apiConfig: ApiConfig = {}) { + Object.assign(this, apiConfig); + } + + public setSecurityData = (data: SecurityDataType) => { + this.securityData = data; + }; + + private addQueryParam(query: QueryParamsType, key: string) { + const value = query[key]; + + return ( + encodeURIComponent(key) + + "=" + + encodeURIComponent(Array.isArray(value) ? value.join(",") : typeof value === "number" ? value : `${value}`) + ); + } + + protected toQueryString(rawQuery?: QueryParamsType): string { + const query = rawQuery || {}; + const keys = Object.keys(query).filter((key) => "undefined" !== typeof query[key]); + return keys + .map((key) => + typeof query[key] === "object" && !Array.isArray(query[key]) + ? this.toQueryString(query[key] as QueryParamsType) + : this.addQueryParam(query, key), + ) + .join("&"); + } + + protected addQueryParams(rawQuery?: QueryParamsType): string { + const queryString = this.toQueryString(rawQuery); + return queryString ? `?${queryString}` : ""; + } + + private contentFormatters: Record any> = { + [ContentType.Json]: (input: any) => + input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input, + [ContentType.FormData]: (input: any) => + Object.keys(input || {}).reduce((data, key) => { + data.append(key, input[key]); + return data; + }, new FormData()), + [ContentType.UrlEncoded]: (input: any) => this.toQueryString(input), + }; + + private mergeRequestParams(params1: RequestParams, params2?: RequestParams): RequestParams { + return { + ...this.baseApiParams, + ...params1, + ...(params2 || {}), + headers: { + ...(this.baseApiParams.headers || {}), + ...(params1.headers || {}), + ...((params2 && params2.headers) || {}), + }, + }; + } + + private createAbortSignal = (cancelToken: CancelToken): AbortSignal | undefined => { + if (this.abortControllers.has(cancelToken)) { + const abortController = this.abortControllers.get(cancelToken); + if (abortController) { + return abortController.signal; + } + return void 0; + } + + const abortController = new AbortController(); + this.abortControllers.set(cancelToken, abortController); + return abortController.signal; + }; + + public abortRequest = (cancelToken: CancelToken) => { + const abortController = this.abortControllers.get(cancelToken); + + if (abortController) { + abortController.abort(); + this.abortControllers.delete(cancelToken); + } + }; + + public request = ({ + body, + secure, + path, + type, + query, + format = "json", + baseUrl, + cancelToken, + ...params + }: FullRequestParams): Promise> => { + const secureParams = (secure && this.securityWorker && this.securityWorker(this.securityData)) || {}; + const requestParams = this.mergeRequestParams(params, secureParams); + const queryString = query && this.toQueryString(query); + const payloadFormatter = this.contentFormatters[type || ContentType.Json]; + + return fetch(`${baseUrl || this.baseUrl || ""}${path}${queryString ? `?${queryString}` : ""}`, { + ...requestParams, + headers: { + ...(type && type !== ContentType.FormData ? { "Content-Type": type } : {}), + ...(requestParams.headers || {}), + }, + signal: cancelToken ? this.createAbortSignal(cancelToken) : void 0, + body: typeof body === "undefined" || body === null ? null : payloadFormatter(body), + }).then(async (response) => { + const r = response as HttpResponse; + r.data = (null as unknown) as T; + r.error = (null as unknown) as E; + + const data = await response[format]() + .then((data) => { + if (r.ok) { + r.data = data; + } else { + r.error = data; + } + return r; + }) + .catch((e) => { + r.error = e; + return r; + }); + + if (cancelToken) { + this.abortControllers.delete(cancelToken); + } + + if (!response.ok) throw data; + return data; + }); + }; +} + +/** + * @title ibc/core/client/v1/client.proto + * @version version not set + */ +export class Api extends HttpClient { + /** + * No description + * + * @tags Query + * @name QueryClientParams + * @summary ClientParams queries all parameters of the ibc client. + * @request GET:/ibc/client/v1/params + */ + queryClientParams = (params: RequestParams = {}) => + this.request({ + path: `/ibc/client/v1/params`, + method: "GET", + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Query + * @name QueryClientStates + * @summary ClientStates queries all the IBC light clients of a chain. + * @request GET:/ibc/core/client/v1/client_states + */ + queryClientStates = ( + query?: { + "pagination.key"?: string; + "pagination.offset"?: string; + "pagination.limit"?: string; + "pagination.count_total"?: boolean; + "pagination.reverse"?: boolean; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/ibc/core/client/v1/client_states`, + method: "GET", + query: query, + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Query + * @name QueryClientState + * @summary ClientState queries an IBC light client. + * @request GET:/ibc/core/client/v1/client_states/{client_id} + */ + queryClientState = (client_id: string, params: RequestParams = {}) => + this.request({ + path: `/ibc/core/client/v1/client_states/${client_id}`, + method: "GET", + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Query + * @name QueryClientStatus + * @summary Status queries the status of an IBC client. + * @request GET:/ibc/core/client/v1/client_status/{client_id} + */ + queryClientStatus = (client_id: string, params: RequestParams = {}) => + this.request({ + path: `/ibc/core/client/v1/client_status/${client_id}`, + method: "GET", + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Query + * @name QueryConsensusStates + * @summary ConsensusStates queries all the consensus state associated with a given +client. + * @request GET:/ibc/core/client/v1/consensus_states/{client_id} + */ + queryConsensusStates = ( + client_id: string, + query?: { + "pagination.key"?: string; + "pagination.offset"?: string; + "pagination.limit"?: string; + "pagination.count_total"?: boolean; + "pagination.reverse"?: boolean; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/ibc/core/client/v1/consensus_states/${client_id}`, + method: "GET", + query: query, + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Query + * @name QueryConsensusStateHeights + * @summary ConsensusStateHeights queries the height of every consensus states associated with a given client. + * @request GET:/ibc/core/client/v1/consensus_states/{client_id}/heights + */ + queryConsensusStateHeights = ( + client_id: string, + query?: { + "pagination.key"?: string; + "pagination.offset"?: string; + "pagination.limit"?: string; + "pagination.count_total"?: boolean; + "pagination.reverse"?: boolean; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/ibc/core/client/v1/consensus_states/${client_id}/heights`, + method: "GET", + query: query, + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Query + * @name QueryConsensusState + * @summary ConsensusState queries a consensus state associated with a client state at +a given height. + * @request GET:/ibc/core/client/v1/consensus_states/{client_id}/revision/{revision_number}/height/{revision_height} + */ + queryConsensusState = ( + client_id: string, + revision_number: string, + revision_height: string, + query?: { latest_height?: boolean }, + params: RequestParams = {}, + ) => + this.request({ + path: `/ibc/core/client/v1/consensus_states/${client_id}/revision/${revision_number}/height/${revision_height}`, + method: "GET", + query: query, + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Query + * @name QueryUpgradedClientState + * @summary UpgradedClientState queries an Upgraded IBC light client. + * @request GET:/ibc/core/client/v1/upgraded_client_states + */ + queryUpgradedClientState = (params: RequestParams = {}) => + this.request({ + path: `/ibc/core/client/v1/upgraded_client_states`, + method: "GET", + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Query + * @name QueryUpgradedConsensusState + * @summary UpgradedConsensusState queries an Upgraded IBC consensus state. + * @request GET:/ibc/core/client/v1/upgraded_consensus_states + */ + queryUpgradedConsensusState = (params: RequestParams = {}) => + this.request({ + path: `/ibc/core/client/v1/upgraded_consensus_states`, + method: "GET", + format: "json", + ...params, + }); +} diff --git a/ts-client/ibc.core.client.v1/types.ts b/ts-client/ibc.core.client.v1/types.ts new file mode 100755 index 00000000..e9aea16f --- /dev/null +++ b/ts-client/ibc.core.client.v1/types.ts @@ -0,0 +1,23 @@ +import { IdentifiedClientState } from "./types/ibc/core/client/v1/client" +import { ConsensusStateWithHeight } from "./types/ibc/core/client/v1/client" +import { ClientConsensusStates } from "./types/ibc/core/client/v1/client" +import { ClientUpdateProposal } from "./types/ibc/core/client/v1/client" +import { UpgradeProposal } from "./types/ibc/core/client/v1/client" +import { Height } from "./types/ibc/core/client/v1/client" +import { Params } from "./types/ibc/core/client/v1/client" +import { GenesisMetadata } from "./types/ibc/core/client/v1/genesis" +import { IdentifiedGenesisMetadata } from "./types/ibc/core/client/v1/genesis" + + +export { + IdentifiedClientState, + ConsensusStateWithHeight, + ClientConsensusStates, + ClientUpdateProposal, + UpgradeProposal, + Height, + Params, + GenesisMetadata, + IdentifiedGenesisMetadata, + + } \ No newline at end of file diff --git a/ts-client/ibc.core.client.v1/types/cosmos/base/query/v1beta1/pagination.ts b/ts-client/ibc.core.client.v1/types/cosmos/base/query/v1beta1/pagination.ts new file mode 100644 index 00000000..cd4b2d78 --- /dev/null +++ b/ts-client/ibc.core.client.v1/types/cosmos/base/query/v1beta1/pagination.ts @@ -0,0 +1,327 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "cosmos.base.query.v1beta1"; + +/** + * PageRequest is to be embedded in gRPC request messages for efficient + * pagination. Ex: + * + * message SomeRequest { + * Foo some_parameter = 1; + * PageRequest pagination = 2; + * } + */ +export interface PageRequest { + /** + * key is a value returned in PageResponse.next_key to begin + * querying the next page most efficiently. Only one of offset or key + * should be set. + */ + key: Uint8Array; + /** + * offset is a numeric offset that can be used when key is unavailable. + * It is less efficient than using key. Only one of offset or key should + * be set. + */ + offset: number; + /** + * limit is the total number of results to be returned in the result page. + * If left empty it will default to a value to be set by each app. + */ + limit: number; + /** + * count_total is set to true to indicate that the result set should include + * a count of the total number of items available for pagination in UIs. + * count_total is only respected when offset is used. It is ignored when key + * is set. + */ + countTotal: boolean; + /** + * reverse is set to true if results are to be returned in the descending order. + * + * Since: cosmos-sdk 0.43 + */ + reverse: boolean; +} + +/** + * PageResponse is to be embedded in gRPC response messages where the + * corresponding request message has used PageRequest. + * + * message SomeResponse { + * repeated Bar results = 1; + * PageResponse page = 2; + * } + */ +export interface PageResponse { + /** + * next_key is the key to be passed to PageRequest.key to + * query the next page most efficiently + */ + nextKey: Uint8Array; + /** + * total is total number of results available if PageRequest.count_total + * was set, its value is undefined otherwise + */ + total: number; +} + +const basePageRequest: object = { + offset: 0, + limit: 0, + countTotal: false, + reverse: false, +}; + +export const PageRequest = { + encode(message: PageRequest, writer: Writer = Writer.create()): Writer { + if (message.key.length !== 0) { + writer.uint32(10).bytes(message.key); + } + if (message.offset !== 0) { + writer.uint32(16).uint64(message.offset); + } + if (message.limit !== 0) { + writer.uint32(24).uint64(message.limit); + } + if (message.countTotal === true) { + writer.uint32(32).bool(message.countTotal); + } + if (message.reverse === true) { + writer.uint32(40).bool(message.reverse); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): PageRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...basePageRequest } as PageRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.key = reader.bytes(); + break; + case 2: + message.offset = longToNumber(reader.uint64() as Long); + break; + case 3: + message.limit = longToNumber(reader.uint64() as Long); + break; + case 4: + message.countTotal = reader.bool(); + break; + case 5: + message.reverse = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): PageRequest { + const message = { ...basePageRequest } as PageRequest; + if (object.key !== undefined && object.key !== null) { + message.key = bytesFromBase64(object.key); + } + if (object.offset !== undefined && object.offset !== null) { + message.offset = Number(object.offset); + } else { + message.offset = 0; + } + if (object.limit !== undefined && object.limit !== null) { + message.limit = Number(object.limit); + } else { + message.limit = 0; + } + if (object.countTotal !== undefined && object.countTotal !== null) { + message.countTotal = Boolean(object.countTotal); + } else { + message.countTotal = false; + } + if (object.reverse !== undefined && object.reverse !== null) { + message.reverse = Boolean(object.reverse); + } else { + message.reverse = false; + } + return message; + }, + + toJSON(message: PageRequest): unknown { + const obj: any = {}; + message.key !== undefined && + (obj.key = base64FromBytes( + message.key !== undefined ? message.key : new Uint8Array() + )); + message.offset !== undefined && (obj.offset = message.offset); + message.limit !== undefined && (obj.limit = message.limit); + message.countTotal !== undefined && (obj.countTotal = message.countTotal); + message.reverse !== undefined && (obj.reverse = message.reverse); + return obj; + }, + + fromPartial(object: DeepPartial): PageRequest { + const message = { ...basePageRequest } as PageRequest; + if (object.key !== undefined && object.key !== null) { + message.key = object.key; + } else { + message.key = new Uint8Array(); + } + if (object.offset !== undefined && object.offset !== null) { + message.offset = object.offset; + } else { + message.offset = 0; + } + if (object.limit !== undefined && object.limit !== null) { + message.limit = object.limit; + } else { + message.limit = 0; + } + if (object.countTotal !== undefined && object.countTotal !== null) { + message.countTotal = object.countTotal; + } else { + message.countTotal = false; + } + if (object.reverse !== undefined && object.reverse !== null) { + message.reverse = object.reverse; + } else { + message.reverse = false; + } + return message; + }, +}; + +const basePageResponse: object = { total: 0 }; + +export const PageResponse = { + encode(message: PageResponse, writer: Writer = Writer.create()): Writer { + if (message.nextKey.length !== 0) { + writer.uint32(10).bytes(message.nextKey); + } + if (message.total !== 0) { + writer.uint32(16).uint64(message.total); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): PageResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...basePageResponse } as PageResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.nextKey = reader.bytes(); + break; + case 2: + message.total = longToNumber(reader.uint64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): PageResponse { + const message = { ...basePageResponse } as PageResponse; + if (object.nextKey !== undefined && object.nextKey !== null) { + message.nextKey = bytesFromBase64(object.nextKey); + } + if (object.total !== undefined && object.total !== null) { + message.total = Number(object.total); + } else { + message.total = 0; + } + return message; + }, + + toJSON(message: PageResponse): unknown { + const obj: any = {}; + message.nextKey !== undefined && + (obj.nextKey = base64FromBytes( + message.nextKey !== undefined ? message.nextKey : new Uint8Array() + )); + message.total !== undefined && (obj.total = message.total); + return obj; + }, + + fromPartial(object: DeepPartial): PageResponse { + const message = { ...basePageResponse } as PageResponse; + if (object.nextKey !== undefined && object.nextKey !== null) { + message.nextKey = object.nextKey; + } else { + message.nextKey = new Uint8Array(); + } + if (object.total !== undefined && object.total !== null) { + message.total = object.total; + } else { + message.total = 0; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/ibc.core.client.v1/types/cosmos/upgrade/v1beta1/upgrade.ts b/ts-client/ibc.core.client.v1/types/cosmos/upgrade/v1beta1/upgrade.ts new file mode 100644 index 00000000..ec9520b0 --- /dev/null +++ b/ts-client/ibc.core.client.v1/types/cosmos/upgrade/v1beta1/upgrade.ts @@ -0,0 +1,539 @@ +/* eslint-disable */ +import { Timestamp } from "../../../google/protobuf/timestamp"; +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; +import { Any } from "../../../google/protobuf/any"; + +export const protobufPackage = "cosmos.upgrade.v1beta1"; + +/** Plan specifies information about a planned upgrade and when it should occur. */ +export interface Plan { + /** + * Sets the name for the upgrade. This name will be used by the upgraded + * version of the software to apply any special "on-upgrade" commands during + * the first BeginBlock method after the upgrade is applied. It is also used + * to detect whether a software version can handle a given upgrade. If no + * upgrade handler with this name has been set in the software, it will be + * assumed that the software is out-of-date when the upgrade Time or Height is + * reached and the software will exit. + */ + name: string; + /** + * Deprecated: Time based upgrades have been deprecated. Time based upgrade logic + * has been removed from the SDK. + * If this field is not empty, an error will be thrown. + * + * @deprecated + */ + time: Date | undefined; + /** + * The height at which the upgrade must be performed. + * Only used if Time is not set. + */ + height: number; + /** + * Any application specific upgrade info to be included on-chain + * such as a git commit that validators could automatically upgrade to + */ + info: string; + /** + * Deprecated: UpgradedClientState field has been deprecated. IBC upgrade logic has been + * moved to the IBC module in the sub module 02-client. + * If this field is not empty, an error will be thrown. + * + * @deprecated + */ + upgradedClientState: Any | undefined; +} + +/** + * SoftwareUpgradeProposal is a gov Content type for initiating a software + * upgrade. + */ +export interface SoftwareUpgradeProposal { + title: string; + description: string; + plan: Plan | undefined; +} + +/** + * CancelSoftwareUpgradeProposal is a gov Content type for cancelling a software + * upgrade. + */ +export interface CancelSoftwareUpgradeProposal { + title: string; + description: string; +} + +/** + * ModuleVersion specifies a module and its consensus version. + * + * Since: cosmos-sdk 0.43 + */ +export interface ModuleVersion { + /** name of the app module */ + name: string; + /** consensus version of the app module */ + version: number; +} + +const basePlan: object = { name: "", height: 0, info: "" }; + +export const Plan = { + encode(message: Plan, writer: Writer = Writer.create()): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.time !== undefined) { + Timestamp.encode( + toTimestamp(message.time), + writer.uint32(18).fork() + ).ldelim(); + } + if (message.height !== 0) { + writer.uint32(24).int64(message.height); + } + if (message.info !== "") { + writer.uint32(34).string(message.info); + } + if (message.upgradedClientState !== undefined) { + Any.encode( + message.upgradedClientState, + writer.uint32(42).fork() + ).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Plan { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...basePlan } as Plan; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.time = fromTimestamp( + Timestamp.decode(reader, reader.uint32()) + ); + break; + case 3: + message.height = longToNumber(reader.int64() as Long); + break; + case 4: + message.info = reader.string(); + break; + case 5: + message.upgradedClientState = Any.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Plan { + const message = { ...basePlan } as Plan; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.time !== undefined && object.time !== null) { + message.time = fromJsonTimestamp(object.time); + } else { + message.time = undefined; + } + if (object.height !== undefined && object.height !== null) { + message.height = Number(object.height); + } else { + message.height = 0; + } + if (object.info !== undefined && object.info !== null) { + message.info = String(object.info); + } else { + message.info = ""; + } + if ( + object.upgradedClientState !== undefined && + object.upgradedClientState !== null + ) { + message.upgradedClientState = Any.fromJSON(object.upgradedClientState); + } else { + message.upgradedClientState = undefined; + } + return message; + }, + + toJSON(message: Plan): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.time !== undefined && + (obj.time = + message.time !== undefined ? message.time.toISOString() : null); + message.height !== undefined && (obj.height = message.height); + message.info !== undefined && (obj.info = message.info); + message.upgradedClientState !== undefined && + (obj.upgradedClientState = message.upgradedClientState + ? Any.toJSON(message.upgradedClientState) + : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): Plan { + const message = { ...basePlan } as Plan; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.time !== undefined && object.time !== null) { + message.time = object.time; + } else { + message.time = undefined; + } + if (object.height !== undefined && object.height !== null) { + message.height = object.height; + } else { + message.height = 0; + } + if (object.info !== undefined && object.info !== null) { + message.info = object.info; + } else { + message.info = ""; + } + if ( + object.upgradedClientState !== undefined && + object.upgradedClientState !== null + ) { + message.upgradedClientState = Any.fromPartial(object.upgradedClientState); + } else { + message.upgradedClientState = undefined; + } + return message; + }, +}; + +const baseSoftwareUpgradeProposal: object = { title: "", description: "" }; + +export const SoftwareUpgradeProposal = { + encode( + message: SoftwareUpgradeProposal, + writer: Writer = Writer.create() + ): Writer { + if (message.title !== "") { + writer.uint32(10).string(message.title); + } + if (message.description !== "") { + writer.uint32(18).string(message.description); + } + if (message.plan !== undefined) { + Plan.encode(message.plan, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): SoftwareUpgradeProposal { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseSoftwareUpgradeProposal, + } as SoftwareUpgradeProposal; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.title = reader.string(); + break; + case 2: + message.description = reader.string(); + break; + case 3: + message.plan = Plan.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): SoftwareUpgradeProposal { + const message = { + ...baseSoftwareUpgradeProposal, + } as SoftwareUpgradeProposal; + if (object.title !== undefined && object.title !== null) { + message.title = String(object.title); + } else { + message.title = ""; + } + if (object.description !== undefined && object.description !== null) { + message.description = String(object.description); + } else { + message.description = ""; + } + if (object.plan !== undefined && object.plan !== null) { + message.plan = Plan.fromJSON(object.plan); + } else { + message.plan = undefined; + } + return message; + }, + + toJSON(message: SoftwareUpgradeProposal): unknown { + const obj: any = {}; + message.title !== undefined && (obj.title = message.title); + message.description !== undefined && + (obj.description = message.description); + message.plan !== undefined && + (obj.plan = message.plan ? Plan.toJSON(message.plan) : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): SoftwareUpgradeProposal { + const message = { + ...baseSoftwareUpgradeProposal, + } as SoftwareUpgradeProposal; + if (object.title !== undefined && object.title !== null) { + message.title = object.title; + } else { + message.title = ""; + } + if (object.description !== undefined && object.description !== null) { + message.description = object.description; + } else { + message.description = ""; + } + if (object.plan !== undefined && object.plan !== null) { + message.plan = Plan.fromPartial(object.plan); + } else { + message.plan = undefined; + } + return message; + }, +}; + +const baseCancelSoftwareUpgradeProposal: object = { + title: "", + description: "", +}; + +export const CancelSoftwareUpgradeProposal = { + encode( + message: CancelSoftwareUpgradeProposal, + writer: Writer = Writer.create() + ): Writer { + if (message.title !== "") { + writer.uint32(10).string(message.title); + } + if (message.description !== "") { + writer.uint32(18).string(message.description); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): CancelSoftwareUpgradeProposal { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseCancelSoftwareUpgradeProposal, + } as CancelSoftwareUpgradeProposal; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.title = reader.string(); + break; + case 2: + message.description = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): CancelSoftwareUpgradeProposal { + const message = { + ...baseCancelSoftwareUpgradeProposal, + } as CancelSoftwareUpgradeProposal; + if (object.title !== undefined && object.title !== null) { + message.title = String(object.title); + } else { + message.title = ""; + } + if (object.description !== undefined && object.description !== null) { + message.description = String(object.description); + } else { + message.description = ""; + } + return message; + }, + + toJSON(message: CancelSoftwareUpgradeProposal): unknown { + const obj: any = {}; + message.title !== undefined && (obj.title = message.title); + message.description !== undefined && + (obj.description = message.description); + return obj; + }, + + fromPartial( + object: DeepPartial + ): CancelSoftwareUpgradeProposal { + const message = { + ...baseCancelSoftwareUpgradeProposal, + } as CancelSoftwareUpgradeProposal; + if (object.title !== undefined && object.title !== null) { + message.title = object.title; + } else { + message.title = ""; + } + if (object.description !== undefined && object.description !== null) { + message.description = object.description; + } else { + message.description = ""; + } + return message; + }, +}; + +const baseModuleVersion: object = { name: "", version: 0 }; + +export const ModuleVersion = { + encode(message: ModuleVersion, writer: Writer = Writer.create()): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.version !== 0) { + writer.uint32(16).uint64(message.version); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ModuleVersion { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseModuleVersion } as ModuleVersion; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.version = longToNumber(reader.uint64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ModuleVersion { + const message = { ...baseModuleVersion } as ModuleVersion; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.version !== undefined && object.version !== null) { + message.version = Number(object.version); + } else { + message.version = 0; + } + return message; + }, + + toJSON(message: ModuleVersion): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.version !== undefined && (obj.version = message.version); + return obj; + }, + + fromPartial(object: DeepPartial): ModuleVersion { + const message = { ...baseModuleVersion } as ModuleVersion; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.version !== undefined && object.version !== null) { + message.version = object.version; + } else { + message.version = 0; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function toTimestamp(date: Date): Timestamp { + const seconds = date.getTime() / 1_000; + const nanos = (date.getTime() % 1_000) * 1_000_000; + return { seconds, nanos }; +} + +function fromTimestamp(t: Timestamp): Date { + let millis = t.seconds * 1_000; + millis += t.nanos / 1_000_000; + return new Date(millis); +} + +function fromJsonTimestamp(o: any): Date { + if (o instanceof Date) { + return o; + } else if (typeof o === "string") { + return new Date(o); + } else { + return fromTimestamp(Timestamp.fromJSON(o)); + } +} + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/ibc.core.client.v1/types/cosmos_proto/cosmos.ts b/ts-client/ibc.core.client.v1/types/cosmos_proto/cosmos.ts new file mode 100644 index 00000000..9ec67a12 --- /dev/null +++ b/ts-client/ibc.core.client.v1/types/cosmos_proto/cosmos.ts @@ -0,0 +1,2 @@ +/* eslint-disable */ +export const protobufPackage = "cosmos_proto"; diff --git a/ts-client/ibc.core.client.v1/types/gogoproto/gogo.ts b/ts-client/ibc.core.client.v1/types/gogoproto/gogo.ts new file mode 100644 index 00000000..3f41a047 --- /dev/null +++ b/ts-client/ibc.core.client.v1/types/gogoproto/gogo.ts @@ -0,0 +1,2 @@ +/* eslint-disable */ +export const protobufPackage = "gogoproto"; diff --git a/ts-client/ibc.core.client.v1/types/google/api/annotations.ts b/ts-client/ibc.core.client.v1/types/google/api/annotations.ts new file mode 100644 index 00000000..aace4787 --- /dev/null +++ b/ts-client/ibc.core.client.v1/types/google/api/annotations.ts @@ -0,0 +1,2 @@ +/* eslint-disable */ +export const protobufPackage = "google.api"; diff --git a/ts-client/ibc.core.client.v1/types/google/api/http.ts b/ts-client/ibc.core.client.v1/types/google/api/http.ts new file mode 100644 index 00000000..ddc00f8b --- /dev/null +++ b/ts-client/ibc.core.client.v1/types/google/api/http.ts @@ -0,0 +1,705 @@ +/* eslint-disable */ +import { Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "google.api"; + +/** + * Defines the HTTP configuration for an API service. It contains a list of + * [HttpRule][google.api.HttpRule], each specifying the mapping of an RPC method + * to one or more HTTP REST API methods. + */ +export interface Http { + /** + * A list of HTTP configuration rules that apply to individual API methods. + * + * **NOTE:** All service configuration rules follow "last one wins" order. + */ + rules: HttpRule[]; + /** + * When set to true, URL path parmeters will be fully URI-decoded except in + * cases of single segment matches in reserved expansion, where "%2F" will be + * left encoded. + * + * The default behavior is to not decode RFC 6570 reserved characters in multi + * segment matches. + */ + fullyDecodeReservedExpansion: boolean; +} + +/** + * `HttpRule` defines the mapping of an RPC method to one or more HTTP + * REST API methods. The mapping specifies how different portions of the RPC + * request message are mapped to URL path, URL query parameters, and + * HTTP request body. The mapping is typically specified as an + * `google.api.http` annotation on the RPC method, + * see "google/api/annotations.proto" for details. + * + * The mapping consists of a field specifying the path template and + * method kind. The path template can refer to fields in the request + * message, as in the example below which describes a REST GET + * operation on a resource collection of messages: + * + * + * service Messaging { + * rpc GetMessage(GetMessageRequest) returns (Message) { + * option (google.api.http).get = "/v1/messages/{message_id}/{sub.subfield}"; + * } + * } + * message GetMessageRequest { + * message SubMessage { + * string subfield = 1; + * } + * string message_id = 1; // mapped to the URL + * SubMessage sub = 2; // `sub.subfield` is url-mapped + * } + * message Message { + * string text = 1; // content of the resource + * } + * + * The same http annotation can alternatively be expressed inside the + * `GRPC API Configuration` YAML file. + * + * http: + * rules: + * - selector: .Messaging.GetMessage + * get: /v1/messages/{message_id}/{sub.subfield} + * + * This definition enables an automatic, bidrectional mapping of HTTP + * JSON to RPC. Example: + * + * HTTP | RPC + * -----|----- + * `GET /v1/messages/123456/foo` | `GetMessage(message_id: "123456" sub: SubMessage(subfield: "foo"))` + * + * In general, not only fields but also field paths can be referenced + * from a path pattern. Fields mapped to the path pattern cannot be + * repeated and must have a primitive (non-message) type. + * + * Any fields in the request message which are not bound by the path + * pattern automatically become (optional) HTTP query + * parameters. Assume the following definition of the request message: + * + * + * service Messaging { + * rpc GetMessage(GetMessageRequest) returns (Message) { + * option (google.api.http).get = "/v1/messages/{message_id}"; + * } + * } + * message GetMessageRequest { + * message SubMessage { + * string subfield = 1; + * } + * string message_id = 1; // mapped to the URL + * int64 revision = 2; // becomes a parameter + * SubMessage sub = 3; // `sub.subfield` becomes a parameter + * } + * + * + * This enables a HTTP JSON to RPC mapping as below: + * + * HTTP | RPC + * -----|----- + * `GET /v1/messages/123456?revision=2&sub.subfield=foo` | `GetMessage(message_id: "123456" revision: 2 sub: SubMessage(subfield: "foo"))` + * + * Note that fields which are mapped to HTTP parameters must have a + * primitive type or a repeated primitive type. Message types are not + * allowed. In the case of a repeated type, the parameter can be + * repeated in the URL, as in `...?param=A¶m=B`. + * + * For HTTP method kinds which allow a request body, the `body` field + * specifies the mapping. Consider a REST update method on the + * message resource collection: + * + * + * service Messaging { + * rpc UpdateMessage(UpdateMessageRequest) returns (Message) { + * option (google.api.http) = { + * put: "/v1/messages/{message_id}" + * body: "message" + * }; + * } + * } + * message UpdateMessageRequest { + * string message_id = 1; // mapped to the URL + * Message message = 2; // mapped to the body + * } + * + * + * The following HTTP JSON to RPC mapping is enabled, where the + * representation of the JSON in the request body is determined by + * protos JSON encoding: + * + * HTTP | RPC + * -----|----- + * `PUT /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: "123456" message { text: "Hi!" })` + * + * The special name `*` can be used in the body mapping to define that + * every field not bound by the path template should be mapped to the + * request body. This enables the following alternative definition of + * the update method: + * + * service Messaging { + * rpc UpdateMessage(Message) returns (Message) { + * option (google.api.http) = { + * put: "/v1/messages/{message_id}" + * body: "*" + * }; + * } + * } + * message Message { + * string message_id = 1; + * string text = 2; + * } + * + * + * The following HTTP JSON to RPC mapping is enabled: + * + * HTTP | RPC + * -----|----- + * `PUT /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: "123456" text: "Hi!")` + * + * Note that when using `*` in the body mapping, it is not possible to + * have HTTP parameters, as all fields not bound by the path end in + * the body. This makes this option more rarely used in practice of + * defining REST APIs. The common usage of `*` is in custom methods + * which don't use the URL at all for transferring data. + * + * It is possible to define multiple HTTP methods for one RPC by using + * the `additional_bindings` option. Example: + * + * service Messaging { + * rpc GetMessage(GetMessageRequest) returns (Message) { + * option (google.api.http) = { + * get: "/v1/messages/{message_id}" + * additional_bindings { + * get: "/v1/users/{user_id}/messages/{message_id}" + * } + * }; + * } + * } + * message GetMessageRequest { + * string message_id = 1; + * string user_id = 2; + * } + * + * + * This enables the following two alternative HTTP JSON to RPC + * mappings: + * + * HTTP | RPC + * -----|----- + * `GET /v1/messages/123456` | `GetMessage(message_id: "123456")` + * `GET /v1/users/me/messages/123456` | `GetMessage(user_id: "me" message_id: "123456")` + * + * # Rules for HTTP mapping + * + * The rules for mapping HTTP path, query parameters, and body fields + * to the request message are as follows: + * + * 1. The `body` field specifies either `*` or a field path, or is + * omitted. If omitted, it indicates there is no HTTP request body. + * 2. Leaf fields (recursive expansion of nested messages in the + * request) can be classified into three types: + * (a) Matched in the URL template. + * (b) Covered by body (if body is `*`, everything except (a) fields; + * else everything under the body field) + * (c) All other fields. + * 3. URL query parameters found in the HTTP request are mapped to (c) fields. + * 4. Any body sent with an HTTP request can contain only (b) fields. + * + * The syntax of the path template is as follows: + * + * Template = "/" Segments [ Verb ] ; + * Segments = Segment { "/" Segment } ; + * Segment = "*" | "**" | LITERAL | Variable ; + * Variable = "{" FieldPath [ "=" Segments ] "}" ; + * FieldPath = IDENT { "." IDENT } ; + * Verb = ":" LITERAL ; + * + * The syntax `*` matches a single path segment. The syntax `**` matches zero + * or more path segments, which must be the last part of the path except the + * `Verb`. The syntax `LITERAL` matches literal text in the path. + * + * The syntax `Variable` matches part of the URL path as specified by its + * template. A variable template must not contain other variables. If a variable + * matches a single path segment, its template may be omitted, e.g. `{var}` + * is equivalent to `{var=*}`. + * + * If a variable contains exactly one path segment, such as `"{var}"` or + * `"{var=*}"`, when such a variable is expanded into a URL path, all characters + * except `[-_.~0-9a-zA-Z]` are percent-encoded. Such variables show up in the + * Discovery Document as `{var}`. + * + * If a variable contains one or more path segments, such as `"{var=foo/*}"` + * or `"{var=**}"`, when such a variable is expanded into a URL path, all + * characters except `[-_.~/0-9a-zA-Z]` are percent-encoded. Such variables + * show up in the Discovery Document as `{+var}`. + * + * NOTE: While the single segment variable matches the semantics of + * [RFC 6570](https://tools.ietf.org/html/rfc6570) Section 3.2.2 + * Simple String Expansion, the multi segment variable **does not** match + * RFC 6570 Reserved Expansion. The reason is that the Reserved Expansion + * does not expand special characters like `?` and `#`, which would lead + * to invalid URLs. + * + * NOTE: the field paths in variables and in the `body` must not refer to + * repeated fields or map fields. + */ +export interface HttpRule { + /** + * Selects methods to which this rule applies. + * + * Refer to [selector][google.api.DocumentationRule.selector] for syntax details. + */ + selector: string; + /** Used for listing and getting information about resources. */ + get: string | undefined; + /** Used for updating a resource. */ + put: string | undefined; + /** Used for creating a resource. */ + post: string | undefined; + /** Used for deleting a resource. */ + delete: string | undefined; + /** Used for updating a resource. */ + patch: string | undefined; + /** + * The custom pattern is used for specifying an HTTP method that is not + * included in the `pattern` field, such as HEAD, or "*" to leave the + * HTTP method unspecified for this rule. The wild-card rule is useful + * for services that provide content to Web (HTML) clients. + */ + custom: CustomHttpPattern | undefined; + /** + * The name of the request field whose value is mapped to the HTTP body, or + * `*` for mapping all fields not captured by the path pattern to the HTTP + * body. NOTE: the referred field must not be a repeated field and must be + * present at the top-level of request message type. + */ + body: string; + /** + * Optional. The name of the response field whose value is mapped to the HTTP + * body of response. Other response fields are ignored. When + * not set, the response message will be used as HTTP body of response. + */ + responseBody: string; + /** + * Additional HTTP bindings for the selector. Nested bindings must + * not contain an `additional_bindings` field themselves (that is, + * the nesting may only be one level deep). + */ + additionalBindings: HttpRule[]; +} + +/** A custom pattern is used for defining custom HTTP verb. */ +export interface CustomHttpPattern { + /** The name of this custom HTTP verb. */ + kind: string; + /** The path matched by this custom verb. */ + path: string; +} + +const baseHttp: object = { fullyDecodeReservedExpansion: false }; + +export const Http = { + encode(message: Http, writer: Writer = Writer.create()): Writer { + for (const v of message.rules) { + HttpRule.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.fullyDecodeReservedExpansion === true) { + writer.uint32(16).bool(message.fullyDecodeReservedExpansion); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Http { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseHttp } as Http; + message.rules = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.rules.push(HttpRule.decode(reader, reader.uint32())); + break; + case 2: + message.fullyDecodeReservedExpansion = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Http { + const message = { ...baseHttp } as Http; + message.rules = []; + if (object.rules !== undefined && object.rules !== null) { + for (const e of object.rules) { + message.rules.push(HttpRule.fromJSON(e)); + } + } + if ( + object.fullyDecodeReservedExpansion !== undefined && + object.fullyDecodeReservedExpansion !== null + ) { + message.fullyDecodeReservedExpansion = Boolean( + object.fullyDecodeReservedExpansion + ); + } else { + message.fullyDecodeReservedExpansion = false; + } + return message; + }, + + toJSON(message: Http): unknown { + const obj: any = {}; + if (message.rules) { + obj.rules = message.rules.map((e) => + e ? HttpRule.toJSON(e) : undefined + ); + } else { + obj.rules = []; + } + message.fullyDecodeReservedExpansion !== undefined && + (obj.fullyDecodeReservedExpansion = message.fullyDecodeReservedExpansion); + return obj; + }, + + fromPartial(object: DeepPartial): Http { + const message = { ...baseHttp } as Http; + message.rules = []; + if (object.rules !== undefined && object.rules !== null) { + for (const e of object.rules) { + message.rules.push(HttpRule.fromPartial(e)); + } + } + if ( + object.fullyDecodeReservedExpansion !== undefined && + object.fullyDecodeReservedExpansion !== null + ) { + message.fullyDecodeReservedExpansion = + object.fullyDecodeReservedExpansion; + } else { + message.fullyDecodeReservedExpansion = false; + } + return message; + }, +}; + +const baseHttpRule: object = { selector: "", body: "", responseBody: "" }; + +export const HttpRule = { + encode(message: HttpRule, writer: Writer = Writer.create()): Writer { + if (message.selector !== "") { + writer.uint32(10).string(message.selector); + } + if (message.get !== undefined) { + writer.uint32(18).string(message.get); + } + if (message.put !== undefined) { + writer.uint32(26).string(message.put); + } + if (message.post !== undefined) { + writer.uint32(34).string(message.post); + } + if (message.delete !== undefined) { + writer.uint32(42).string(message.delete); + } + if (message.patch !== undefined) { + writer.uint32(50).string(message.patch); + } + if (message.custom !== undefined) { + CustomHttpPattern.encode( + message.custom, + writer.uint32(66).fork() + ).ldelim(); + } + if (message.body !== "") { + writer.uint32(58).string(message.body); + } + if (message.responseBody !== "") { + writer.uint32(98).string(message.responseBody); + } + for (const v of message.additionalBindings) { + HttpRule.encode(v!, writer.uint32(90).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): HttpRule { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseHttpRule } as HttpRule; + message.additionalBindings = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.selector = reader.string(); + break; + case 2: + message.get = reader.string(); + break; + case 3: + message.put = reader.string(); + break; + case 4: + message.post = reader.string(); + break; + case 5: + message.delete = reader.string(); + break; + case 6: + message.patch = reader.string(); + break; + case 8: + message.custom = CustomHttpPattern.decode(reader, reader.uint32()); + break; + case 7: + message.body = reader.string(); + break; + case 12: + message.responseBody = reader.string(); + break; + case 11: + message.additionalBindings.push( + HttpRule.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): HttpRule { + const message = { ...baseHttpRule } as HttpRule; + message.additionalBindings = []; + if (object.selector !== undefined && object.selector !== null) { + message.selector = String(object.selector); + } else { + message.selector = ""; + } + if (object.get !== undefined && object.get !== null) { + message.get = String(object.get); + } else { + message.get = undefined; + } + if (object.put !== undefined && object.put !== null) { + message.put = String(object.put); + } else { + message.put = undefined; + } + if (object.post !== undefined && object.post !== null) { + message.post = String(object.post); + } else { + message.post = undefined; + } + if (object.delete !== undefined && object.delete !== null) { + message.delete = String(object.delete); + } else { + message.delete = undefined; + } + if (object.patch !== undefined && object.patch !== null) { + message.patch = String(object.patch); + } else { + message.patch = undefined; + } + if (object.custom !== undefined && object.custom !== null) { + message.custom = CustomHttpPattern.fromJSON(object.custom); + } else { + message.custom = undefined; + } + if (object.body !== undefined && object.body !== null) { + message.body = String(object.body); + } else { + message.body = ""; + } + if (object.responseBody !== undefined && object.responseBody !== null) { + message.responseBody = String(object.responseBody); + } else { + message.responseBody = ""; + } + if ( + object.additionalBindings !== undefined && + object.additionalBindings !== null + ) { + for (const e of object.additionalBindings) { + message.additionalBindings.push(HttpRule.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: HttpRule): unknown { + const obj: any = {}; + message.selector !== undefined && (obj.selector = message.selector); + message.get !== undefined && (obj.get = message.get); + message.put !== undefined && (obj.put = message.put); + message.post !== undefined && (obj.post = message.post); + message.delete !== undefined && (obj.delete = message.delete); + message.patch !== undefined && (obj.patch = message.patch); + message.custom !== undefined && + (obj.custom = message.custom + ? CustomHttpPattern.toJSON(message.custom) + : undefined); + message.body !== undefined && (obj.body = message.body); + message.responseBody !== undefined && + (obj.responseBody = message.responseBody); + if (message.additionalBindings) { + obj.additionalBindings = message.additionalBindings.map((e) => + e ? HttpRule.toJSON(e) : undefined + ); + } else { + obj.additionalBindings = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): HttpRule { + const message = { ...baseHttpRule } as HttpRule; + message.additionalBindings = []; + if (object.selector !== undefined && object.selector !== null) { + message.selector = object.selector; + } else { + message.selector = ""; + } + if (object.get !== undefined && object.get !== null) { + message.get = object.get; + } else { + message.get = undefined; + } + if (object.put !== undefined && object.put !== null) { + message.put = object.put; + } else { + message.put = undefined; + } + if (object.post !== undefined && object.post !== null) { + message.post = object.post; + } else { + message.post = undefined; + } + if (object.delete !== undefined && object.delete !== null) { + message.delete = object.delete; + } else { + message.delete = undefined; + } + if (object.patch !== undefined && object.patch !== null) { + message.patch = object.patch; + } else { + message.patch = undefined; + } + if (object.custom !== undefined && object.custom !== null) { + message.custom = CustomHttpPattern.fromPartial(object.custom); + } else { + message.custom = undefined; + } + if (object.body !== undefined && object.body !== null) { + message.body = object.body; + } else { + message.body = ""; + } + if (object.responseBody !== undefined && object.responseBody !== null) { + message.responseBody = object.responseBody; + } else { + message.responseBody = ""; + } + if ( + object.additionalBindings !== undefined && + object.additionalBindings !== null + ) { + for (const e of object.additionalBindings) { + message.additionalBindings.push(HttpRule.fromPartial(e)); + } + } + return message; + }, +}; + +const baseCustomHttpPattern: object = { kind: "", path: "" }; + +export const CustomHttpPattern = { + encode(message: CustomHttpPattern, writer: Writer = Writer.create()): Writer { + if (message.kind !== "") { + writer.uint32(10).string(message.kind); + } + if (message.path !== "") { + writer.uint32(18).string(message.path); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): CustomHttpPattern { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseCustomHttpPattern } as CustomHttpPattern; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.kind = reader.string(); + break; + case 2: + message.path = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): CustomHttpPattern { + const message = { ...baseCustomHttpPattern } as CustomHttpPattern; + if (object.kind !== undefined && object.kind !== null) { + message.kind = String(object.kind); + } else { + message.kind = ""; + } + if (object.path !== undefined && object.path !== null) { + message.path = String(object.path); + } else { + message.path = ""; + } + return message; + }, + + toJSON(message: CustomHttpPattern): unknown { + const obj: any = {}; + message.kind !== undefined && (obj.kind = message.kind); + message.path !== undefined && (obj.path = message.path); + return obj; + }, + + fromPartial(object: DeepPartial): CustomHttpPattern { + const message = { ...baseCustomHttpPattern } as CustomHttpPattern; + if (object.kind !== undefined && object.kind !== null) { + message.kind = object.kind; + } else { + message.kind = ""; + } + if (object.path !== undefined && object.path !== null) { + message.path = object.path; + } else { + message.path = ""; + } + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/ibc.core.client.v1/types/google/protobuf/any.ts b/ts-client/ibc.core.client.v1/types/google/protobuf/any.ts new file mode 100644 index 00000000..b137a629 --- /dev/null +++ b/ts-client/ibc.core.client.v1/types/google/protobuf/any.ts @@ -0,0 +1,240 @@ +/* eslint-disable */ +import { Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "google.protobuf"; + +/** + * `Any` contains an arbitrary serialized protocol buffer message along with a + * URL that describes the type of the serialized message. + * + * Protobuf library provides support to pack/unpack Any values in the form + * of utility functions or additional generated methods of the Any type. + * + * Example 1: Pack and unpack a message in C++. + * + * Foo foo = ...; + * Any any; + * any.PackFrom(foo); + * ... + * if (any.UnpackTo(&foo)) { + * ... + * } + * + * Example 2: Pack and unpack a message in Java. + * + * Foo foo = ...; + * Any any = Any.pack(foo); + * ... + * if (any.is(Foo.class)) { + * foo = any.unpack(Foo.class); + * } + * + * Example 3: Pack and unpack a message in Python. + * + * foo = Foo(...) + * any = Any() + * any.Pack(foo) + * ... + * if any.Is(Foo.DESCRIPTOR): + * any.Unpack(foo) + * ... + * + * Example 4: Pack and unpack a message in Go + * + * foo := &pb.Foo{...} + * any, err := anypb.New(foo) + * if err != nil { + * ... + * } + * ... + * foo := &pb.Foo{} + * if err := any.UnmarshalTo(foo); err != nil { + * ... + * } + * + * The pack methods provided by protobuf library will by default use + * 'type.googleapis.com/full.type.name' as the type URL and the unpack + * methods only use the fully qualified type name after the last '/' + * in the type URL, for example "foo.bar.com/x/y.z" will yield type + * name "y.z". + * + * + * JSON + * ==== + * The JSON representation of an `Any` value uses the regular + * representation of the deserialized, embedded message, with an + * additional field `@type` which contains the type URL. Example: + * + * package google.profile; + * message Person { + * string first_name = 1; + * string last_name = 2; + * } + * + * { + * "@type": "type.googleapis.com/google.profile.Person", + * "firstName": , + * "lastName": + * } + * + * If the embedded message type is well-known and has a custom JSON + * representation, that representation will be embedded adding a field + * `value` which holds the custom JSON in addition to the `@type` + * field. Example (for message [google.protobuf.Duration][]): + * + * { + * "@type": "type.googleapis.com/google.protobuf.Duration", + * "value": "1.212s" + * } + */ +export interface Any { + /** + * A URL/resource name that uniquely identifies the type of the serialized + * protocol buffer message. This string must contain at least + * one "/" character. The last segment of the URL's path must represent + * the fully qualified name of the type (as in + * `path/google.protobuf.Duration`). The name should be in a canonical form + * (e.g., leading "." is not accepted). + * + * In practice, teams usually precompile into the binary all types that they + * expect it to use in the context of Any. However, for URLs which use the + * scheme `http`, `https`, or no scheme, one can optionally set up a type + * server that maps type URLs to message definitions as follows: + * + * * If no scheme is provided, `https` is assumed. + * * An HTTP GET on the URL must yield a [google.protobuf.Type][] + * value in binary format, or produce an error. + * * Applications are allowed to cache lookup results based on the + * URL, or have them precompiled into a binary to avoid any + * lookup. Therefore, binary compatibility needs to be preserved + * on changes to types. (Use versioned type names to manage + * breaking changes.) + * + * Note: this functionality is not currently available in the official + * protobuf release, and it is not used for type URLs beginning with + * type.googleapis.com. + * + * Schemes other than `http`, `https` (or the empty scheme) might be + * used with implementation specific semantics. + */ + typeUrl: string; + /** Must be a valid serialized protocol buffer of the above specified type. */ + value: Uint8Array; +} + +const baseAny: object = { typeUrl: "" }; + +export const Any = { + encode(message: Any, writer: Writer = Writer.create()): Writer { + if (message.typeUrl !== "") { + writer.uint32(10).string(message.typeUrl); + } + if (message.value.length !== 0) { + writer.uint32(18).bytes(message.value); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Any { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseAny } as Any; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.typeUrl = reader.string(); + break; + case 2: + message.value = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Any { + const message = { ...baseAny } as Any; + if (object.typeUrl !== undefined && object.typeUrl !== null) { + message.typeUrl = String(object.typeUrl); + } else { + message.typeUrl = ""; + } + if (object.value !== undefined && object.value !== null) { + message.value = bytesFromBase64(object.value); + } + return message; + }, + + toJSON(message: Any): unknown { + const obj: any = {}; + message.typeUrl !== undefined && (obj.typeUrl = message.typeUrl); + message.value !== undefined && + (obj.value = base64FromBytes( + message.value !== undefined ? message.value : new Uint8Array() + )); + return obj; + }, + + fromPartial(object: DeepPartial): Any { + const message = { ...baseAny } as Any; + if (object.typeUrl !== undefined && object.typeUrl !== null) { + message.typeUrl = object.typeUrl; + } else { + message.typeUrl = ""; + } + if (object.value !== undefined && object.value !== null) { + message.value = object.value; + } else { + message.value = new Uint8Array(); + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/ibc.core.client.v1/types/google/protobuf/descriptor.ts b/ts-client/ibc.core.client.v1/types/google/protobuf/descriptor.ts new file mode 100644 index 00000000..9e508660 --- /dev/null +++ b/ts-client/ibc.core.client.v1/types/google/protobuf/descriptor.ts @@ -0,0 +1,5261 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "google.protobuf"; + +/** + * The protocol compiler can output a FileDescriptorSet containing the .proto + * files it parses. + */ +export interface FileDescriptorSet { + file: FileDescriptorProto[]; +} + +/** Describes a complete .proto file. */ +export interface FileDescriptorProto { + /** file name, relative to root of source tree */ + name: string; + /** e.g. "foo", "foo.bar", etc. */ + package: string; + /** Names of files imported by this file. */ + dependency: string[]; + /** Indexes of the public imported files in the dependency list above. */ + publicDependency: number[]; + /** + * Indexes of the weak imported files in the dependency list. + * For Google-internal migration only. Do not use. + */ + weakDependency: number[]; + /** All top-level definitions in this file. */ + messageType: DescriptorProto[]; + enumType: EnumDescriptorProto[]; + service: ServiceDescriptorProto[]; + extension: FieldDescriptorProto[]; + options: FileOptions | undefined; + /** + * This field contains optional information about the original source code. + * You may safely remove this entire field without harming runtime + * functionality of the descriptors -- the information is needed only by + * development tools. + */ + sourceCodeInfo: SourceCodeInfo | undefined; + /** + * The syntax of the proto file. + * The supported values are "proto2" and "proto3". + */ + syntax: string; +} + +/** Describes a message type. */ +export interface DescriptorProto { + name: string; + field: FieldDescriptorProto[]; + extension: FieldDescriptorProto[]; + nestedType: DescriptorProto[]; + enumType: EnumDescriptorProto[]; + extensionRange: DescriptorProto_ExtensionRange[]; + oneofDecl: OneofDescriptorProto[]; + options: MessageOptions | undefined; + reservedRange: DescriptorProto_ReservedRange[]; + /** + * Reserved field names, which may not be used by fields in the same message. + * A given name may only be reserved once. + */ + reservedName: string[]; +} + +export interface DescriptorProto_ExtensionRange { + /** Inclusive. */ + start: number; + /** Exclusive. */ + end: number; + options: ExtensionRangeOptions | undefined; +} + +/** + * Range of reserved tag numbers. Reserved tag numbers may not be used by + * fields or extension ranges in the same message. Reserved ranges may + * not overlap. + */ +export interface DescriptorProto_ReservedRange { + /** Inclusive. */ + start: number; + /** Exclusive. */ + end: number; +} + +export interface ExtensionRangeOptions { + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +/** Describes a field within a message. */ +export interface FieldDescriptorProto { + name: string; + number: number; + label: FieldDescriptorProto_Label; + /** + * If type_name is set, this need not be set. If both this and type_name + * are set, this must be one of TYPE_ENUM, TYPE_MESSAGE or TYPE_GROUP. + */ + type: FieldDescriptorProto_Type; + /** + * For message and enum types, this is the name of the type. If the name + * starts with a '.', it is fully-qualified. Otherwise, C++-like scoping + * rules are used to find the type (i.e. first the nested types within this + * message are searched, then within the parent, on up to the root + * namespace). + */ + typeName: string; + /** + * For extensions, this is the name of the type being extended. It is + * resolved in the same manner as type_name. + */ + extendee: string; + /** + * For numeric types, contains the original text representation of the value. + * For booleans, "true" or "false". + * For strings, contains the default text contents (not escaped in any way). + * For bytes, contains the C escaped value. All bytes >= 128 are escaped. + * TODO(kenton): Base-64 encode? + */ + defaultValue: string; + /** + * If set, gives the index of a oneof in the containing type's oneof_decl + * list. This field is a member of that oneof. + */ + oneofIndex: number; + /** + * JSON name of this field. The value is set by protocol compiler. If the + * user has set a "json_name" option on this field, that option's value + * will be used. Otherwise, it's deduced from the field's name by converting + * it to camelCase. + */ + jsonName: string; + options: FieldOptions | undefined; + /** + * If true, this is a proto3 "optional". When a proto3 field is optional, it + * tracks presence regardless of field type. + * + * When proto3_optional is true, this field must be belong to a oneof to + * signal to old proto3 clients that presence is tracked for this field. This + * oneof is known as a "synthetic" oneof, and this field must be its sole + * member (each proto3 optional field gets its own synthetic oneof). Synthetic + * oneofs exist in the descriptor only, and do not generate any API. Synthetic + * oneofs must be ordered after all "real" oneofs. + * + * For message fields, proto3_optional doesn't create any semantic change, + * since non-repeated message fields always track presence. However it still + * indicates the semantic detail of whether the user wrote "optional" or not. + * This can be useful for round-tripping the .proto file. For consistency we + * give message fields a synthetic oneof also, even though it is not required + * to track presence. This is especially important because the parser can't + * tell if a field is a message or an enum, so it must always create a + * synthetic oneof. + * + * Proto2 optional fields do not set this flag, because they already indicate + * optional with `LABEL_OPTIONAL`. + */ + proto3Optional: boolean; +} + +export enum FieldDescriptorProto_Type { + /** + * TYPE_DOUBLE - 0 is reserved for errors. + * Order is weird for historical reasons. + */ + TYPE_DOUBLE = 1, + TYPE_FLOAT = 2, + /** + * TYPE_INT64 - Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT64 if + * negative values are likely. + */ + TYPE_INT64 = 3, + TYPE_UINT64 = 4, + /** + * TYPE_INT32 - Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT32 if + * negative values are likely. + */ + TYPE_INT32 = 5, + TYPE_FIXED64 = 6, + TYPE_FIXED32 = 7, + TYPE_BOOL = 8, + TYPE_STRING = 9, + /** + * TYPE_GROUP - Tag-delimited aggregate. + * Group type is deprecated and not supported in proto3. However, Proto3 + * implementations should still be able to parse the group wire format and + * treat group fields as unknown fields. + */ + TYPE_GROUP = 10, + /** TYPE_MESSAGE - Length-delimited aggregate. */ + TYPE_MESSAGE = 11, + /** TYPE_BYTES - New in version 2. */ + TYPE_BYTES = 12, + TYPE_UINT32 = 13, + TYPE_ENUM = 14, + TYPE_SFIXED32 = 15, + TYPE_SFIXED64 = 16, + /** TYPE_SINT32 - Uses ZigZag encoding. */ + TYPE_SINT32 = 17, + /** TYPE_SINT64 - Uses ZigZag encoding. */ + TYPE_SINT64 = 18, + UNRECOGNIZED = -1, +} + +export function fieldDescriptorProto_TypeFromJSON( + object: any +): FieldDescriptorProto_Type { + switch (object) { + case 1: + case "TYPE_DOUBLE": + return FieldDescriptorProto_Type.TYPE_DOUBLE; + case 2: + case "TYPE_FLOAT": + return FieldDescriptorProto_Type.TYPE_FLOAT; + case 3: + case "TYPE_INT64": + return FieldDescriptorProto_Type.TYPE_INT64; + case 4: + case "TYPE_UINT64": + return FieldDescriptorProto_Type.TYPE_UINT64; + case 5: + case "TYPE_INT32": + return FieldDescriptorProto_Type.TYPE_INT32; + case 6: + case "TYPE_FIXED64": + return FieldDescriptorProto_Type.TYPE_FIXED64; + case 7: + case "TYPE_FIXED32": + return FieldDescriptorProto_Type.TYPE_FIXED32; + case 8: + case "TYPE_BOOL": + return FieldDescriptorProto_Type.TYPE_BOOL; + case 9: + case "TYPE_STRING": + return FieldDescriptorProto_Type.TYPE_STRING; + case 10: + case "TYPE_GROUP": + return FieldDescriptorProto_Type.TYPE_GROUP; + case 11: + case "TYPE_MESSAGE": + return FieldDescriptorProto_Type.TYPE_MESSAGE; + case 12: + case "TYPE_BYTES": + return FieldDescriptorProto_Type.TYPE_BYTES; + case 13: + case "TYPE_UINT32": + return FieldDescriptorProto_Type.TYPE_UINT32; + case 14: + case "TYPE_ENUM": + return FieldDescriptorProto_Type.TYPE_ENUM; + case 15: + case "TYPE_SFIXED32": + return FieldDescriptorProto_Type.TYPE_SFIXED32; + case 16: + case "TYPE_SFIXED64": + return FieldDescriptorProto_Type.TYPE_SFIXED64; + case 17: + case "TYPE_SINT32": + return FieldDescriptorProto_Type.TYPE_SINT32; + case 18: + case "TYPE_SINT64": + return FieldDescriptorProto_Type.TYPE_SINT64; + case -1: + case "UNRECOGNIZED": + default: + return FieldDescriptorProto_Type.UNRECOGNIZED; + } +} + +export function fieldDescriptorProto_TypeToJSON( + object: FieldDescriptorProto_Type +): string { + switch (object) { + case FieldDescriptorProto_Type.TYPE_DOUBLE: + return "TYPE_DOUBLE"; + case FieldDescriptorProto_Type.TYPE_FLOAT: + return "TYPE_FLOAT"; + case FieldDescriptorProto_Type.TYPE_INT64: + return "TYPE_INT64"; + case FieldDescriptorProto_Type.TYPE_UINT64: + return "TYPE_UINT64"; + case FieldDescriptorProto_Type.TYPE_INT32: + return "TYPE_INT32"; + case FieldDescriptorProto_Type.TYPE_FIXED64: + return "TYPE_FIXED64"; + case FieldDescriptorProto_Type.TYPE_FIXED32: + return "TYPE_FIXED32"; + case FieldDescriptorProto_Type.TYPE_BOOL: + return "TYPE_BOOL"; + case FieldDescriptorProto_Type.TYPE_STRING: + return "TYPE_STRING"; + case FieldDescriptorProto_Type.TYPE_GROUP: + return "TYPE_GROUP"; + case FieldDescriptorProto_Type.TYPE_MESSAGE: + return "TYPE_MESSAGE"; + case FieldDescriptorProto_Type.TYPE_BYTES: + return "TYPE_BYTES"; + case FieldDescriptorProto_Type.TYPE_UINT32: + return "TYPE_UINT32"; + case FieldDescriptorProto_Type.TYPE_ENUM: + return "TYPE_ENUM"; + case FieldDescriptorProto_Type.TYPE_SFIXED32: + return "TYPE_SFIXED32"; + case FieldDescriptorProto_Type.TYPE_SFIXED64: + return "TYPE_SFIXED64"; + case FieldDescriptorProto_Type.TYPE_SINT32: + return "TYPE_SINT32"; + case FieldDescriptorProto_Type.TYPE_SINT64: + return "TYPE_SINT64"; + default: + return "UNKNOWN"; + } +} + +export enum FieldDescriptorProto_Label { + /** LABEL_OPTIONAL - 0 is reserved for errors */ + LABEL_OPTIONAL = 1, + LABEL_REQUIRED = 2, + LABEL_REPEATED = 3, + UNRECOGNIZED = -1, +} + +export function fieldDescriptorProto_LabelFromJSON( + object: any +): FieldDescriptorProto_Label { + switch (object) { + case 1: + case "LABEL_OPTIONAL": + return FieldDescriptorProto_Label.LABEL_OPTIONAL; + case 2: + case "LABEL_REQUIRED": + return FieldDescriptorProto_Label.LABEL_REQUIRED; + case 3: + case "LABEL_REPEATED": + return FieldDescriptorProto_Label.LABEL_REPEATED; + case -1: + case "UNRECOGNIZED": + default: + return FieldDescriptorProto_Label.UNRECOGNIZED; + } +} + +export function fieldDescriptorProto_LabelToJSON( + object: FieldDescriptorProto_Label +): string { + switch (object) { + case FieldDescriptorProto_Label.LABEL_OPTIONAL: + return "LABEL_OPTIONAL"; + case FieldDescriptorProto_Label.LABEL_REQUIRED: + return "LABEL_REQUIRED"; + case FieldDescriptorProto_Label.LABEL_REPEATED: + return "LABEL_REPEATED"; + default: + return "UNKNOWN"; + } +} + +/** Describes a oneof. */ +export interface OneofDescriptorProto { + name: string; + options: OneofOptions | undefined; +} + +/** Describes an enum type. */ +export interface EnumDescriptorProto { + name: string; + value: EnumValueDescriptorProto[]; + options: EnumOptions | undefined; + /** + * Range of reserved numeric values. Reserved numeric values may not be used + * by enum values in the same enum declaration. Reserved ranges may not + * overlap. + */ + reservedRange: EnumDescriptorProto_EnumReservedRange[]; + /** + * Reserved enum value names, which may not be reused. A given name may only + * be reserved once. + */ + reservedName: string[]; +} + +/** + * Range of reserved numeric values. Reserved values may not be used by + * entries in the same enum. Reserved ranges may not overlap. + * + * Note that this is distinct from DescriptorProto.ReservedRange in that it + * is inclusive such that it can appropriately represent the entire int32 + * domain. + */ +export interface EnumDescriptorProto_EnumReservedRange { + /** Inclusive. */ + start: number; + /** Inclusive. */ + end: number; +} + +/** Describes a value within an enum. */ +export interface EnumValueDescriptorProto { + name: string; + number: number; + options: EnumValueOptions | undefined; +} + +/** Describes a service. */ +export interface ServiceDescriptorProto { + name: string; + method: MethodDescriptorProto[]; + options: ServiceOptions | undefined; +} + +/** Describes a method of a service. */ +export interface MethodDescriptorProto { + name: string; + /** + * Input and output type names. These are resolved in the same way as + * FieldDescriptorProto.type_name, but must refer to a message type. + */ + inputType: string; + outputType: string; + options: MethodOptions | undefined; + /** Identifies if client streams multiple client messages */ + clientStreaming: boolean; + /** Identifies if server streams multiple server messages */ + serverStreaming: boolean; +} + +export interface FileOptions { + /** + * Sets the Java package where classes generated from this .proto will be + * placed. By default, the proto package is used, but this is often + * inappropriate because proto packages do not normally start with backwards + * domain names. + */ + javaPackage: string; + /** + * Controls the name of the wrapper Java class generated for the .proto file. + * That class will always contain the .proto file's getDescriptor() method as + * well as any top-level extensions defined in the .proto file. + * If java_multiple_files is disabled, then all the other classes from the + * .proto file will be nested inside the single wrapper outer class. + */ + javaOuterClassname: string; + /** + * If enabled, then the Java code generator will generate a separate .java + * file for each top-level message, enum, and service defined in the .proto + * file. Thus, these types will *not* be nested inside the wrapper class + * named by java_outer_classname. However, the wrapper class will still be + * generated to contain the file's getDescriptor() method as well as any + * top-level extensions defined in the file. + */ + javaMultipleFiles: boolean; + /** + * This option does nothing. + * + * @deprecated + */ + javaGenerateEqualsAndHash: boolean; + /** + * If set true, then the Java2 code generator will generate code that + * throws an exception whenever an attempt is made to assign a non-UTF-8 + * byte sequence to a string field. + * Message reflection will do the same. + * However, an extension field still accepts non-UTF-8 byte sequences. + * This option has no effect on when used with the lite runtime. + */ + javaStringCheckUtf8: boolean; + optimizeFor: FileOptions_OptimizeMode; + /** + * Sets the Go package where structs generated from this .proto will be + * placed. If omitted, the Go package will be derived from the following: + * - The basename of the package import path, if provided. + * - Otherwise, the package statement in the .proto file, if present. + * - Otherwise, the basename of the .proto file, without extension. + */ + goPackage: string; + /** + * Should generic services be generated in each language? "Generic" services + * are not specific to any particular RPC system. They are generated by the + * main code generators in each language (without additional plugins). + * Generic services were the only kind of service generation supported by + * early versions of google.protobuf. + * + * Generic services are now considered deprecated in favor of using plugins + * that generate code specific to your particular RPC system. Therefore, + * these default to false. Old code which depends on generic services should + * explicitly set them to true. + */ + ccGenericServices: boolean; + javaGenericServices: boolean; + pyGenericServices: boolean; + phpGenericServices: boolean; + /** + * Is this file deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for everything in the file, or it will be completely ignored; in the very + * least, this is a formalization for deprecating files. + */ + deprecated: boolean; + /** + * Enables the use of arenas for the proto messages in this file. This applies + * only to generated classes for C++. + */ + ccEnableArenas: boolean; + /** + * Sets the objective c class prefix which is prepended to all objective c + * generated classes from this .proto. There is no default. + */ + objcClassPrefix: string; + /** Namespace for generated classes; defaults to the package. */ + csharpNamespace: string; + /** + * By default Swift generators will take the proto package and CamelCase it + * replacing '.' with underscore and use that to prefix the types/symbols + * defined. When this options is provided, they will use this value instead + * to prefix the types/symbols defined. + */ + swiftPrefix: string; + /** + * Sets the php class prefix which is prepended to all php generated classes + * from this .proto. Default is empty. + */ + phpClassPrefix: string; + /** + * Use this option to change the namespace of php generated classes. Default + * is empty. When this option is empty, the package name will be used for + * determining the namespace. + */ + phpNamespace: string; + /** + * Use this option to change the namespace of php generated metadata classes. + * Default is empty. When this option is empty, the proto file name will be + * used for determining the namespace. + */ + phpMetadataNamespace: string; + /** + * Use this option to change the package of ruby generated classes. Default + * is empty. When this option is not set, the package name will be used for + * determining the ruby package. + */ + rubyPackage: string; + /** + * The parser stores options it doesn't recognize here. + * See the documentation for the "Options" section above. + */ + uninterpretedOption: UninterpretedOption[]; +} + +/** Generated classes can be optimized for speed or code size. */ +export enum FileOptions_OptimizeMode { + /** SPEED - Generate complete code for parsing, serialization, */ + SPEED = 1, + /** CODE_SIZE - etc. */ + CODE_SIZE = 2, + /** LITE_RUNTIME - Generate code using MessageLite and the lite runtime. */ + LITE_RUNTIME = 3, + UNRECOGNIZED = -1, +} + +export function fileOptions_OptimizeModeFromJSON( + object: any +): FileOptions_OptimizeMode { + switch (object) { + case 1: + case "SPEED": + return FileOptions_OptimizeMode.SPEED; + case 2: + case "CODE_SIZE": + return FileOptions_OptimizeMode.CODE_SIZE; + case 3: + case "LITE_RUNTIME": + return FileOptions_OptimizeMode.LITE_RUNTIME; + case -1: + case "UNRECOGNIZED": + default: + return FileOptions_OptimizeMode.UNRECOGNIZED; + } +} + +export function fileOptions_OptimizeModeToJSON( + object: FileOptions_OptimizeMode +): string { + switch (object) { + case FileOptions_OptimizeMode.SPEED: + return "SPEED"; + case FileOptions_OptimizeMode.CODE_SIZE: + return "CODE_SIZE"; + case FileOptions_OptimizeMode.LITE_RUNTIME: + return "LITE_RUNTIME"; + default: + return "UNKNOWN"; + } +} + +export interface MessageOptions { + /** + * Set true to use the old proto1 MessageSet wire format for extensions. + * This is provided for backwards-compatibility with the MessageSet wire + * format. You should not use this for any other reason: It's less + * efficient, has fewer features, and is more complicated. + * + * The message must be defined exactly as follows: + * message Foo { + * option message_set_wire_format = true; + * extensions 4 to max; + * } + * Note that the message cannot have any defined fields; MessageSets only + * have extensions. + * + * All extensions of your type must be singular messages; e.g. they cannot + * be int32s, enums, or repeated messages. + * + * Because this is an option, the above two restrictions are not enforced by + * the protocol compiler. + */ + messageSetWireFormat: boolean; + /** + * Disables the generation of the standard "descriptor()" accessor, which can + * conflict with a field of the same name. This is meant to make migration + * from proto1 easier; new code should avoid fields named "descriptor". + */ + noStandardDescriptorAccessor: boolean; + /** + * Is this message deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the message, or it will be completely ignored; in the very least, + * this is a formalization for deprecating messages. + */ + deprecated: boolean; + /** + * Whether the message is an automatically generated map entry type for the + * maps field. + * + * For maps fields: + * map map_field = 1; + * The parsed descriptor looks like: + * message MapFieldEntry { + * option map_entry = true; + * optional KeyType key = 1; + * optional ValueType value = 2; + * } + * repeated MapFieldEntry map_field = 1; + * + * Implementations may choose not to generate the map_entry=true message, but + * use a native map in the target language to hold the keys and values. + * The reflection APIs in such implementations still need to work as + * if the field is a repeated message field. + * + * NOTE: Do not set the option in .proto files. Always use the maps syntax + * instead. The option should only be implicitly set by the proto compiler + * parser. + */ + mapEntry: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface FieldOptions { + /** + * The ctype option instructs the C++ code generator to use a different + * representation of the field than it normally would. See the specific + * options below. This option is not yet implemented in the open source + * release -- sorry, we'll try to include it in a future version! + */ + ctype: FieldOptions_CType; + /** + * The packed option can be enabled for repeated primitive fields to enable + * a more efficient representation on the wire. Rather than repeatedly + * writing the tag and type for each element, the entire array is encoded as + * a single length-delimited blob. In proto3, only explicit setting it to + * false will avoid using packed encoding. + */ + packed: boolean; + /** + * The jstype option determines the JavaScript type used for values of the + * field. The option is permitted only for 64 bit integral and fixed types + * (int64, uint64, sint64, fixed64, sfixed64). A field with jstype JS_STRING + * is represented as JavaScript string, which avoids loss of precision that + * can happen when a large value is converted to a floating point JavaScript. + * Specifying JS_NUMBER for the jstype causes the generated JavaScript code to + * use the JavaScript "number" type. The behavior of the default option + * JS_NORMAL is implementation dependent. + * + * This option is an enum to permit additional types to be added, e.g. + * goog.math.Integer. + */ + jstype: FieldOptions_JSType; + /** + * Should this field be parsed lazily? Lazy applies only to message-type + * fields. It means that when the outer message is initially parsed, the + * inner message's contents will not be parsed but instead stored in encoded + * form. The inner message will actually be parsed when it is first accessed. + * + * This is only a hint. Implementations are free to choose whether to use + * eager or lazy parsing regardless of the value of this option. However, + * setting this option true suggests that the protocol author believes that + * using lazy parsing on this field is worth the additional bookkeeping + * overhead typically needed to implement it. + * + * This option does not affect the public interface of any generated code; + * all method signatures remain the same. Furthermore, thread-safety of the + * interface is not affected by this option; const methods remain safe to + * call from multiple threads concurrently, while non-const methods continue + * to require exclusive access. + * + * + * Note that implementations may choose not to check required fields within + * a lazy sub-message. That is, calling IsInitialized() on the outer message + * may return true even if the inner message has missing required fields. + * This is necessary because otherwise the inner message would have to be + * parsed in order to perform the check, defeating the purpose of lazy + * parsing. An implementation which chooses not to check required fields + * must be consistent about it. That is, for any particular sub-message, the + * implementation must either *always* check its required fields, or *never* + * check its required fields, regardless of whether or not the message has + * been parsed. + */ + lazy: boolean; + /** + * Is this field deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for accessors, or it will be completely ignored; in the very least, this + * is a formalization for deprecating fields. + */ + deprecated: boolean; + /** For Google-internal migration only. Do not use. */ + weak: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export enum FieldOptions_CType { + /** STRING - Default mode. */ + STRING = 0, + CORD = 1, + STRING_PIECE = 2, + UNRECOGNIZED = -1, +} + +export function fieldOptions_CTypeFromJSON(object: any): FieldOptions_CType { + switch (object) { + case 0: + case "STRING": + return FieldOptions_CType.STRING; + case 1: + case "CORD": + return FieldOptions_CType.CORD; + case 2: + case "STRING_PIECE": + return FieldOptions_CType.STRING_PIECE; + case -1: + case "UNRECOGNIZED": + default: + return FieldOptions_CType.UNRECOGNIZED; + } +} + +export function fieldOptions_CTypeToJSON(object: FieldOptions_CType): string { + switch (object) { + case FieldOptions_CType.STRING: + return "STRING"; + case FieldOptions_CType.CORD: + return "CORD"; + case FieldOptions_CType.STRING_PIECE: + return "STRING_PIECE"; + default: + return "UNKNOWN"; + } +} + +export enum FieldOptions_JSType { + /** JS_NORMAL - Use the default type. */ + JS_NORMAL = 0, + /** JS_STRING - Use JavaScript strings. */ + JS_STRING = 1, + /** JS_NUMBER - Use JavaScript numbers. */ + JS_NUMBER = 2, + UNRECOGNIZED = -1, +} + +export function fieldOptions_JSTypeFromJSON(object: any): FieldOptions_JSType { + switch (object) { + case 0: + case "JS_NORMAL": + return FieldOptions_JSType.JS_NORMAL; + case 1: + case "JS_STRING": + return FieldOptions_JSType.JS_STRING; + case 2: + case "JS_NUMBER": + return FieldOptions_JSType.JS_NUMBER; + case -1: + case "UNRECOGNIZED": + default: + return FieldOptions_JSType.UNRECOGNIZED; + } +} + +export function fieldOptions_JSTypeToJSON(object: FieldOptions_JSType): string { + switch (object) { + case FieldOptions_JSType.JS_NORMAL: + return "JS_NORMAL"; + case FieldOptions_JSType.JS_STRING: + return "JS_STRING"; + case FieldOptions_JSType.JS_NUMBER: + return "JS_NUMBER"; + default: + return "UNKNOWN"; + } +} + +export interface OneofOptions { + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface EnumOptions { + /** + * Set this option to true to allow mapping different tag names to the same + * value. + */ + allowAlias: boolean; + /** + * Is this enum deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the enum, or it will be completely ignored; in the very least, this + * is a formalization for deprecating enums. + */ + deprecated: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface EnumValueOptions { + /** + * Is this enum value deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the enum value, or it will be completely ignored; in the very least, + * this is a formalization for deprecating enum values. + */ + deprecated: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface ServiceOptions { + /** + * Is this service deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the service, or it will be completely ignored; in the very least, + * this is a formalization for deprecating services. + */ + deprecated: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface MethodOptions { + /** + * Is this method deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the method, or it will be completely ignored; in the very least, + * this is a formalization for deprecating methods. + */ + deprecated: boolean; + idempotencyLevel: MethodOptions_IdempotencyLevel; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +/** + * Is this method side-effect-free (or safe in HTTP parlance), or idempotent, + * or neither? HTTP based RPC implementation may choose GET verb for safe + * methods, and PUT verb for idempotent methods instead of the default POST. + */ +export enum MethodOptions_IdempotencyLevel { + IDEMPOTENCY_UNKNOWN = 0, + /** NO_SIDE_EFFECTS - implies idempotent */ + NO_SIDE_EFFECTS = 1, + /** IDEMPOTENT - idempotent, but may have side effects */ + IDEMPOTENT = 2, + UNRECOGNIZED = -1, +} + +export function methodOptions_IdempotencyLevelFromJSON( + object: any +): MethodOptions_IdempotencyLevel { + switch (object) { + case 0: + case "IDEMPOTENCY_UNKNOWN": + return MethodOptions_IdempotencyLevel.IDEMPOTENCY_UNKNOWN; + case 1: + case "NO_SIDE_EFFECTS": + return MethodOptions_IdempotencyLevel.NO_SIDE_EFFECTS; + case 2: + case "IDEMPOTENT": + return MethodOptions_IdempotencyLevel.IDEMPOTENT; + case -1: + case "UNRECOGNIZED": + default: + return MethodOptions_IdempotencyLevel.UNRECOGNIZED; + } +} + +export function methodOptions_IdempotencyLevelToJSON( + object: MethodOptions_IdempotencyLevel +): string { + switch (object) { + case MethodOptions_IdempotencyLevel.IDEMPOTENCY_UNKNOWN: + return "IDEMPOTENCY_UNKNOWN"; + case MethodOptions_IdempotencyLevel.NO_SIDE_EFFECTS: + return "NO_SIDE_EFFECTS"; + case MethodOptions_IdempotencyLevel.IDEMPOTENT: + return "IDEMPOTENT"; + default: + return "UNKNOWN"; + } +} + +/** + * A message representing a option the parser does not recognize. This only + * appears in options protos created by the compiler::Parser class. + * DescriptorPool resolves these when building Descriptor objects. Therefore, + * options protos in descriptor objects (e.g. returned by Descriptor::options(), + * or produced by Descriptor::CopyTo()) will never have UninterpretedOptions + * in them. + */ +export interface UninterpretedOption { + name: UninterpretedOption_NamePart[]; + /** + * The value of the uninterpreted option, in whatever type the tokenizer + * identified it as during parsing. Exactly one of these should be set. + */ + identifierValue: string; + positiveIntValue: number; + negativeIntValue: number; + doubleValue: number; + stringValue: Uint8Array; + aggregateValue: string; +} + +/** + * The name of the uninterpreted option. Each string represents a segment in + * a dot-separated name. is_extension is true iff a segment represents an + * extension (denoted with parentheses in options specs in .proto files). + * E.g.,{ ["foo", false], ["bar.baz", true], ["qux", false] } represents + * "foo.(bar.baz).qux". + */ +export interface UninterpretedOption_NamePart { + namePart: string; + isExtension: boolean; +} + +/** + * Encapsulates information about the original source file from which a + * FileDescriptorProto was generated. + */ +export interface SourceCodeInfo { + /** + * A Location identifies a piece of source code in a .proto file which + * corresponds to a particular definition. This information is intended + * to be useful to IDEs, code indexers, documentation generators, and similar + * tools. + * + * For example, say we have a file like: + * message Foo { + * optional string foo = 1; + * } + * Let's look at just the field definition: + * optional string foo = 1; + * ^ ^^ ^^ ^ ^^^ + * a bc de f ghi + * We have the following locations: + * span path represents + * [a,i) [ 4, 0, 2, 0 ] The whole field definition. + * [a,b) [ 4, 0, 2, 0, 4 ] The label (optional). + * [c,d) [ 4, 0, 2, 0, 5 ] The type (string). + * [e,f) [ 4, 0, 2, 0, 1 ] The name (foo). + * [g,h) [ 4, 0, 2, 0, 3 ] The number (1). + * + * Notes: + * - A location may refer to a repeated field itself (i.e. not to any + * particular index within it). This is used whenever a set of elements are + * logically enclosed in a single code segment. For example, an entire + * extend block (possibly containing multiple extension definitions) will + * have an outer location whose path refers to the "extensions" repeated + * field without an index. + * - Multiple locations may have the same path. This happens when a single + * logical declaration is spread out across multiple places. The most + * obvious example is the "extend" block again -- there may be multiple + * extend blocks in the same scope, each of which will have the same path. + * - A location's span is not always a subset of its parent's span. For + * example, the "extendee" of an extension declaration appears at the + * beginning of the "extend" block and is shared by all extensions within + * the block. + * - Just because a location's span is a subset of some other location's span + * does not mean that it is a descendant. For example, a "group" defines + * both a type and a field in a single declaration. Thus, the locations + * corresponding to the type and field and their components will overlap. + * - Code which tries to interpret locations should probably be designed to + * ignore those that it doesn't understand, as more types of locations could + * be recorded in the future. + */ + location: SourceCodeInfo_Location[]; +} + +export interface SourceCodeInfo_Location { + /** + * Identifies which part of the FileDescriptorProto was defined at this + * location. + * + * Each element is a field number or an index. They form a path from + * the root FileDescriptorProto to the place where the definition. For + * example, this path: + * [ 4, 3, 2, 7, 1 ] + * refers to: + * file.message_type(3) // 4, 3 + * .field(7) // 2, 7 + * .name() // 1 + * This is because FileDescriptorProto.message_type has field number 4: + * repeated DescriptorProto message_type = 4; + * and DescriptorProto.field has field number 2: + * repeated FieldDescriptorProto field = 2; + * and FieldDescriptorProto.name has field number 1: + * optional string name = 1; + * + * Thus, the above path gives the location of a field name. If we removed + * the last element: + * [ 4, 3, 2, 7 ] + * this path refers to the whole field declaration (from the beginning + * of the label to the terminating semicolon). + */ + path: number[]; + /** + * Always has exactly three or four elements: start line, start column, + * end line (optional, otherwise assumed same as start line), end column. + * These are packed into a single field for efficiency. Note that line + * and column numbers are zero-based -- typically you will want to add + * 1 to each before displaying to a user. + */ + span: number[]; + /** + * If this SourceCodeInfo represents a complete declaration, these are any + * comments appearing before and after the declaration which appear to be + * attached to the declaration. + * + * A series of line comments appearing on consecutive lines, with no other + * tokens appearing on those lines, will be treated as a single comment. + * + * leading_detached_comments will keep paragraphs of comments that appear + * before (but not connected to) the current element. Each paragraph, + * separated by empty lines, will be one comment element in the repeated + * field. + * + * Only the comment content is provided; comment markers (e.g. //) are + * stripped out. For block comments, leading whitespace and an asterisk + * will be stripped from the beginning of each line other than the first. + * Newlines are included in the output. + * + * Examples: + * + * optional int32 foo = 1; // Comment attached to foo. + * // Comment attached to bar. + * optional int32 bar = 2; + * + * optional string baz = 3; + * // Comment attached to baz. + * // Another line attached to baz. + * + * // Comment attached to qux. + * // + * // Another line attached to qux. + * optional double qux = 4; + * + * // Detached comment for corge. This is not leading or trailing comments + * // to qux or corge because there are blank lines separating it from + * // both. + * + * // Detached comment for corge paragraph 2. + * + * optional string corge = 5; + * /* Block comment attached + * * to corge. Leading asterisks + * * will be removed. * / + * /* Block comment attached to + * * grault. * / + * optional int32 grault = 6; + * + * // ignored detached comments. + */ + leadingComments: string; + trailingComments: string; + leadingDetachedComments: string[]; +} + +/** + * Describes the relationship between generated code and its original source + * file. A GeneratedCodeInfo message is associated with only one generated + * source file, but may contain references to different source .proto files. + */ +export interface GeneratedCodeInfo { + /** + * An Annotation connects some span of text in generated code to an element + * of its generating .proto file. + */ + annotation: GeneratedCodeInfo_Annotation[]; +} + +export interface GeneratedCodeInfo_Annotation { + /** + * Identifies the element in the original source .proto file. This field + * is formatted the same as SourceCodeInfo.Location.path. + */ + path: number[]; + /** Identifies the filesystem path to the original source .proto. */ + sourceFile: string; + /** + * Identifies the starting offset in bytes in the generated code + * that relates to the identified object. + */ + begin: number; + /** + * Identifies the ending offset in bytes in the generated code that + * relates to the identified offset. The end offset should be one past + * the last relevant byte (so the length of the text = end - begin). + */ + end: number; +} + +const baseFileDescriptorSet: object = {}; + +export const FileDescriptorSet = { + encode(message: FileDescriptorSet, writer: Writer = Writer.create()): Writer { + for (const v of message.file) { + FileDescriptorProto.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FileDescriptorSet { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFileDescriptorSet } as FileDescriptorSet; + message.file = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.file.push( + FileDescriptorProto.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FileDescriptorSet { + const message = { ...baseFileDescriptorSet } as FileDescriptorSet; + message.file = []; + if (object.file !== undefined && object.file !== null) { + for (const e of object.file) { + message.file.push(FileDescriptorProto.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: FileDescriptorSet): unknown { + const obj: any = {}; + if (message.file) { + obj.file = message.file.map((e) => + e ? FileDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.file = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): FileDescriptorSet { + const message = { ...baseFileDescriptorSet } as FileDescriptorSet; + message.file = []; + if (object.file !== undefined && object.file !== null) { + for (const e of object.file) { + message.file.push(FileDescriptorProto.fromPartial(e)); + } + } + return message; + }, +}; + +const baseFileDescriptorProto: object = { + name: "", + package: "", + dependency: "", + publicDependency: 0, + weakDependency: 0, + syntax: "", +}; + +export const FileDescriptorProto = { + encode( + message: FileDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.package !== "") { + writer.uint32(18).string(message.package); + } + for (const v of message.dependency) { + writer.uint32(26).string(v!); + } + writer.uint32(82).fork(); + for (const v of message.publicDependency) { + writer.int32(v); + } + writer.ldelim(); + writer.uint32(90).fork(); + for (const v of message.weakDependency) { + writer.int32(v); + } + writer.ldelim(); + for (const v of message.messageType) { + DescriptorProto.encode(v!, writer.uint32(34).fork()).ldelim(); + } + for (const v of message.enumType) { + EnumDescriptorProto.encode(v!, writer.uint32(42).fork()).ldelim(); + } + for (const v of message.service) { + ServiceDescriptorProto.encode(v!, writer.uint32(50).fork()).ldelim(); + } + for (const v of message.extension) { + FieldDescriptorProto.encode(v!, writer.uint32(58).fork()).ldelim(); + } + if (message.options !== undefined) { + FileOptions.encode(message.options, writer.uint32(66).fork()).ldelim(); + } + if (message.sourceCodeInfo !== undefined) { + SourceCodeInfo.encode( + message.sourceCodeInfo, + writer.uint32(74).fork() + ).ldelim(); + } + if (message.syntax !== "") { + writer.uint32(98).string(message.syntax); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FileDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFileDescriptorProto } as FileDescriptorProto; + message.dependency = []; + message.publicDependency = []; + message.weakDependency = []; + message.messageType = []; + message.enumType = []; + message.service = []; + message.extension = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.package = reader.string(); + break; + case 3: + message.dependency.push(reader.string()); + break; + case 10: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.publicDependency.push(reader.int32()); + } + } else { + message.publicDependency.push(reader.int32()); + } + break; + case 11: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.weakDependency.push(reader.int32()); + } + } else { + message.weakDependency.push(reader.int32()); + } + break; + case 4: + message.messageType.push( + DescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 5: + message.enumType.push( + EnumDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 6: + message.service.push( + ServiceDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 7: + message.extension.push( + FieldDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 8: + message.options = FileOptions.decode(reader, reader.uint32()); + break; + case 9: + message.sourceCodeInfo = SourceCodeInfo.decode( + reader, + reader.uint32() + ); + break; + case 12: + message.syntax = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FileDescriptorProto { + const message = { ...baseFileDescriptorProto } as FileDescriptorProto; + message.dependency = []; + message.publicDependency = []; + message.weakDependency = []; + message.messageType = []; + message.enumType = []; + message.service = []; + message.extension = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.package !== undefined && object.package !== null) { + message.package = String(object.package); + } else { + message.package = ""; + } + if (object.dependency !== undefined && object.dependency !== null) { + for (const e of object.dependency) { + message.dependency.push(String(e)); + } + } + if ( + object.publicDependency !== undefined && + object.publicDependency !== null + ) { + for (const e of object.publicDependency) { + message.publicDependency.push(Number(e)); + } + } + if (object.weakDependency !== undefined && object.weakDependency !== null) { + for (const e of object.weakDependency) { + message.weakDependency.push(Number(e)); + } + } + if (object.messageType !== undefined && object.messageType !== null) { + for (const e of object.messageType) { + message.messageType.push(DescriptorProto.fromJSON(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromJSON(e)); + } + } + if (object.service !== undefined && object.service !== null) { + for (const e of object.service) { + message.service.push(ServiceDescriptorProto.fromJSON(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = FileOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.sourceCodeInfo !== undefined && object.sourceCodeInfo !== null) { + message.sourceCodeInfo = SourceCodeInfo.fromJSON(object.sourceCodeInfo); + } else { + message.sourceCodeInfo = undefined; + } + if (object.syntax !== undefined && object.syntax !== null) { + message.syntax = String(object.syntax); + } else { + message.syntax = ""; + } + return message; + }, + + toJSON(message: FileDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.package !== undefined && (obj.package = message.package); + if (message.dependency) { + obj.dependency = message.dependency.map((e) => e); + } else { + obj.dependency = []; + } + if (message.publicDependency) { + obj.publicDependency = message.publicDependency.map((e) => e); + } else { + obj.publicDependency = []; + } + if (message.weakDependency) { + obj.weakDependency = message.weakDependency.map((e) => e); + } else { + obj.weakDependency = []; + } + if (message.messageType) { + obj.messageType = message.messageType.map((e) => + e ? DescriptorProto.toJSON(e) : undefined + ); + } else { + obj.messageType = []; + } + if (message.enumType) { + obj.enumType = message.enumType.map((e) => + e ? EnumDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.enumType = []; + } + if (message.service) { + obj.service = message.service.map((e) => + e ? ServiceDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.service = []; + } + if (message.extension) { + obj.extension = message.extension.map((e) => + e ? FieldDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.extension = []; + } + message.options !== undefined && + (obj.options = message.options + ? FileOptions.toJSON(message.options) + : undefined); + message.sourceCodeInfo !== undefined && + (obj.sourceCodeInfo = message.sourceCodeInfo + ? SourceCodeInfo.toJSON(message.sourceCodeInfo) + : undefined); + message.syntax !== undefined && (obj.syntax = message.syntax); + return obj; + }, + + fromPartial(object: DeepPartial): FileDescriptorProto { + const message = { ...baseFileDescriptorProto } as FileDescriptorProto; + message.dependency = []; + message.publicDependency = []; + message.weakDependency = []; + message.messageType = []; + message.enumType = []; + message.service = []; + message.extension = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.package !== undefined && object.package !== null) { + message.package = object.package; + } else { + message.package = ""; + } + if (object.dependency !== undefined && object.dependency !== null) { + for (const e of object.dependency) { + message.dependency.push(e); + } + } + if ( + object.publicDependency !== undefined && + object.publicDependency !== null + ) { + for (const e of object.publicDependency) { + message.publicDependency.push(e); + } + } + if (object.weakDependency !== undefined && object.weakDependency !== null) { + for (const e of object.weakDependency) { + message.weakDependency.push(e); + } + } + if (object.messageType !== undefined && object.messageType !== null) { + for (const e of object.messageType) { + message.messageType.push(DescriptorProto.fromPartial(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromPartial(e)); + } + } + if (object.service !== undefined && object.service !== null) { + for (const e of object.service) { + message.service.push(ServiceDescriptorProto.fromPartial(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = FileOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.sourceCodeInfo !== undefined && object.sourceCodeInfo !== null) { + message.sourceCodeInfo = SourceCodeInfo.fromPartial( + object.sourceCodeInfo + ); + } else { + message.sourceCodeInfo = undefined; + } + if (object.syntax !== undefined && object.syntax !== null) { + message.syntax = object.syntax; + } else { + message.syntax = ""; + } + return message; + }, +}; + +const baseDescriptorProto: object = { name: "", reservedName: "" }; + +export const DescriptorProto = { + encode(message: DescriptorProto, writer: Writer = Writer.create()): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + for (const v of message.field) { + FieldDescriptorProto.encode(v!, writer.uint32(18).fork()).ldelim(); + } + for (const v of message.extension) { + FieldDescriptorProto.encode(v!, writer.uint32(50).fork()).ldelim(); + } + for (const v of message.nestedType) { + DescriptorProto.encode(v!, writer.uint32(26).fork()).ldelim(); + } + for (const v of message.enumType) { + EnumDescriptorProto.encode(v!, writer.uint32(34).fork()).ldelim(); + } + for (const v of message.extensionRange) { + DescriptorProto_ExtensionRange.encode( + v!, + writer.uint32(42).fork() + ).ldelim(); + } + for (const v of message.oneofDecl) { + OneofDescriptorProto.encode(v!, writer.uint32(66).fork()).ldelim(); + } + if (message.options !== undefined) { + MessageOptions.encode(message.options, writer.uint32(58).fork()).ldelim(); + } + for (const v of message.reservedRange) { + DescriptorProto_ReservedRange.encode( + v!, + writer.uint32(74).fork() + ).ldelim(); + } + for (const v of message.reservedName) { + writer.uint32(82).string(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): DescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseDescriptorProto } as DescriptorProto; + message.field = []; + message.extension = []; + message.nestedType = []; + message.enumType = []; + message.extensionRange = []; + message.oneofDecl = []; + message.reservedRange = []; + message.reservedName = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.field.push( + FieldDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 6: + message.extension.push( + FieldDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 3: + message.nestedType.push( + DescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 4: + message.enumType.push( + EnumDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 5: + message.extensionRange.push( + DescriptorProto_ExtensionRange.decode(reader, reader.uint32()) + ); + break; + case 8: + message.oneofDecl.push( + OneofDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 7: + message.options = MessageOptions.decode(reader, reader.uint32()); + break; + case 9: + message.reservedRange.push( + DescriptorProto_ReservedRange.decode(reader, reader.uint32()) + ); + break; + case 10: + message.reservedName.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DescriptorProto { + const message = { ...baseDescriptorProto } as DescriptorProto; + message.field = []; + message.extension = []; + message.nestedType = []; + message.enumType = []; + message.extensionRange = []; + message.oneofDecl = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.field !== undefined && object.field !== null) { + for (const e of object.field) { + message.field.push(FieldDescriptorProto.fromJSON(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromJSON(e)); + } + } + if (object.nestedType !== undefined && object.nestedType !== null) { + for (const e of object.nestedType) { + message.nestedType.push(DescriptorProto.fromJSON(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromJSON(e)); + } + } + if (object.extensionRange !== undefined && object.extensionRange !== null) { + for (const e of object.extensionRange) { + message.extensionRange.push(DescriptorProto_ExtensionRange.fromJSON(e)); + } + } + if (object.oneofDecl !== undefined && object.oneofDecl !== null) { + for (const e of object.oneofDecl) { + message.oneofDecl.push(OneofDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = MessageOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push(DescriptorProto_ReservedRange.fromJSON(e)); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(String(e)); + } + } + return message; + }, + + toJSON(message: DescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + if (message.field) { + obj.field = message.field.map((e) => + e ? FieldDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.field = []; + } + if (message.extension) { + obj.extension = message.extension.map((e) => + e ? FieldDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.extension = []; + } + if (message.nestedType) { + obj.nestedType = message.nestedType.map((e) => + e ? DescriptorProto.toJSON(e) : undefined + ); + } else { + obj.nestedType = []; + } + if (message.enumType) { + obj.enumType = message.enumType.map((e) => + e ? EnumDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.enumType = []; + } + if (message.extensionRange) { + obj.extensionRange = message.extensionRange.map((e) => + e ? DescriptorProto_ExtensionRange.toJSON(e) : undefined + ); + } else { + obj.extensionRange = []; + } + if (message.oneofDecl) { + obj.oneofDecl = message.oneofDecl.map((e) => + e ? OneofDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.oneofDecl = []; + } + message.options !== undefined && + (obj.options = message.options + ? MessageOptions.toJSON(message.options) + : undefined); + if (message.reservedRange) { + obj.reservedRange = message.reservedRange.map((e) => + e ? DescriptorProto_ReservedRange.toJSON(e) : undefined + ); + } else { + obj.reservedRange = []; + } + if (message.reservedName) { + obj.reservedName = message.reservedName.map((e) => e); + } else { + obj.reservedName = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): DescriptorProto { + const message = { ...baseDescriptorProto } as DescriptorProto; + message.field = []; + message.extension = []; + message.nestedType = []; + message.enumType = []; + message.extensionRange = []; + message.oneofDecl = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.field !== undefined && object.field !== null) { + for (const e of object.field) { + message.field.push(FieldDescriptorProto.fromPartial(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromPartial(e)); + } + } + if (object.nestedType !== undefined && object.nestedType !== null) { + for (const e of object.nestedType) { + message.nestedType.push(DescriptorProto.fromPartial(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromPartial(e)); + } + } + if (object.extensionRange !== undefined && object.extensionRange !== null) { + for (const e of object.extensionRange) { + message.extensionRange.push( + DescriptorProto_ExtensionRange.fromPartial(e) + ); + } + } + if (object.oneofDecl !== undefined && object.oneofDecl !== null) { + for (const e of object.oneofDecl) { + message.oneofDecl.push(OneofDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = MessageOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push( + DescriptorProto_ReservedRange.fromPartial(e) + ); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(e); + } + } + return message; + }, +}; + +const baseDescriptorProto_ExtensionRange: object = { start: 0, end: 0 }; + +export const DescriptorProto_ExtensionRange = { + encode( + message: DescriptorProto_ExtensionRange, + writer: Writer = Writer.create() + ): Writer { + if (message.start !== 0) { + writer.uint32(8).int32(message.start); + } + if (message.end !== 0) { + writer.uint32(16).int32(message.end); + } + if (message.options !== undefined) { + ExtensionRangeOptions.encode( + message.options, + writer.uint32(26).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): DescriptorProto_ExtensionRange { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseDescriptorProto_ExtensionRange, + } as DescriptorProto_ExtensionRange; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.start = reader.int32(); + break; + case 2: + message.end = reader.int32(); + break; + case 3: + message.options = ExtensionRangeOptions.decode( + reader, + reader.uint32() + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DescriptorProto_ExtensionRange { + const message = { + ...baseDescriptorProto_ExtensionRange, + } as DescriptorProto_ExtensionRange; + if (object.start !== undefined && object.start !== null) { + message.start = Number(object.start); + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = ExtensionRangeOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: DescriptorProto_ExtensionRange): unknown { + const obj: any = {}; + message.start !== undefined && (obj.start = message.start); + message.end !== undefined && (obj.end = message.end); + message.options !== undefined && + (obj.options = message.options + ? ExtensionRangeOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): DescriptorProto_ExtensionRange { + const message = { + ...baseDescriptorProto_ExtensionRange, + } as DescriptorProto_ExtensionRange; + if (object.start !== undefined && object.start !== null) { + message.start = object.start; + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = ExtensionRangeOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseDescriptorProto_ReservedRange: object = { start: 0, end: 0 }; + +export const DescriptorProto_ReservedRange = { + encode( + message: DescriptorProto_ReservedRange, + writer: Writer = Writer.create() + ): Writer { + if (message.start !== 0) { + writer.uint32(8).int32(message.start); + } + if (message.end !== 0) { + writer.uint32(16).int32(message.end); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): DescriptorProto_ReservedRange { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseDescriptorProto_ReservedRange, + } as DescriptorProto_ReservedRange; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.start = reader.int32(); + break; + case 2: + message.end = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DescriptorProto_ReservedRange { + const message = { + ...baseDescriptorProto_ReservedRange, + } as DescriptorProto_ReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = Number(object.start); + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + return message; + }, + + toJSON(message: DescriptorProto_ReservedRange): unknown { + const obj: any = {}; + message.start !== undefined && (obj.start = message.start); + message.end !== undefined && (obj.end = message.end); + return obj; + }, + + fromPartial( + object: DeepPartial + ): DescriptorProto_ReservedRange { + const message = { + ...baseDescriptorProto_ReservedRange, + } as DescriptorProto_ReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = object.start; + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + return message; + }, +}; + +const baseExtensionRangeOptions: object = {}; + +export const ExtensionRangeOptions = { + encode( + message: ExtensionRangeOptions, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ExtensionRangeOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseExtensionRangeOptions } as ExtensionRangeOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ExtensionRangeOptions { + const message = { ...baseExtensionRangeOptions } as ExtensionRangeOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: ExtensionRangeOptions): unknown { + const obj: any = {}; + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial( + object: DeepPartial + ): ExtensionRangeOptions { + const message = { ...baseExtensionRangeOptions } as ExtensionRangeOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseFieldDescriptorProto: object = { + name: "", + number: 0, + label: 1, + type: 1, + typeName: "", + extendee: "", + defaultValue: "", + oneofIndex: 0, + jsonName: "", + proto3Optional: false, +}; + +export const FieldDescriptorProto = { + encode( + message: FieldDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.number !== 0) { + writer.uint32(24).int32(message.number); + } + if (message.label !== 1) { + writer.uint32(32).int32(message.label); + } + if (message.type !== 1) { + writer.uint32(40).int32(message.type); + } + if (message.typeName !== "") { + writer.uint32(50).string(message.typeName); + } + if (message.extendee !== "") { + writer.uint32(18).string(message.extendee); + } + if (message.defaultValue !== "") { + writer.uint32(58).string(message.defaultValue); + } + if (message.oneofIndex !== 0) { + writer.uint32(72).int32(message.oneofIndex); + } + if (message.jsonName !== "") { + writer.uint32(82).string(message.jsonName); + } + if (message.options !== undefined) { + FieldOptions.encode(message.options, writer.uint32(66).fork()).ldelim(); + } + if (message.proto3Optional === true) { + writer.uint32(136).bool(message.proto3Optional); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FieldDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFieldDescriptorProto } as FieldDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 3: + message.number = reader.int32(); + break; + case 4: + message.label = reader.int32() as any; + break; + case 5: + message.type = reader.int32() as any; + break; + case 6: + message.typeName = reader.string(); + break; + case 2: + message.extendee = reader.string(); + break; + case 7: + message.defaultValue = reader.string(); + break; + case 9: + message.oneofIndex = reader.int32(); + break; + case 10: + message.jsonName = reader.string(); + break; + case 8: + message.options = FieldOptions.decode(reader, reader.uint32()); + break; + case 17: + message.proto3Optional = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FieldDescriptorProto { + const message = { ...baseFieldDescriptorProto } as FieldDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = Number(object.number); + } else { + message.number = 0; + } + if (object.label !== undefined && object.label !== null) { + message.label = fieldDescriptorProto_LabelFromJSON(object.label); + } else { + message.label = 1; + } + if (object.type !== undefined && object.type !== null) { + message.type = fieldDescriptorProto_TypeFromJSON(object.type); + } else { + message.type = 1; + } + if (object.typeName !== undefined && object.typeName !== null) { + message.typeName = String(object.typeName); + } else { + message.typeName = ""; + } + if (object.extendee !== undefined && object.extendee !== null) { + message.extendee = String(object.extendee); + } else { + message.extendee = ""; + } + if (object.defaultValue !== undefined && object.defaultValue !== null) { + message.defaultValue = String(object.defaultValue); + } else { + message.defaultValue = ""; + } + if (object.oneofIndex !== undefined && object.oneofIndex !== null) { + message.oneofIndex = Number(object.oneofIndex); + } else { + message.oneofIndex = 0; + } + if (object.jsonName !== undefined && object.jsonName !== null) { + message.jsonName = String(object.jsonName); + } else { + message.jsonName = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = FieldOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.proto3Optional !== undefined && object.proto3Optional !== null) { + message.proto3Optional = Boolean(object.proto3Optional); + } else { + message.proto3Optional = false; + } + return message; + }, + + toJSON(message: FieldDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.number !== undefined && (obj.number = message.number); + message.label !== undefined && + (obj.label = fieldDescriptorProto_LabelToJSON(message.label)); + message.type !== undefined && + (obj.type = fieldDescriptorProto_TypeToJSON(message.type)); + message.typeName !== undefined && (obj.typeName = message.typeName); + message.extendee !== undefined && (obj.extendee = message.extendee); + message.defaultValue !== undefined && + (obj.defaultValue = message.defaultValue); + message.oneofIndex !== undefined && (obj.oneofIndex = message.oneofIndex); + message.jsonName !== undefined && (obj.jsonName = message.jsonName); + message.options !== undefined && + (obj.options = message.options + ? FieldOptions.toJSON(message.options) + : undefined); + message.proto3Optional !== undefined && + (obj.proto3Optional = message.proto3Optional); + return obj; + }, + + fromPartial(object: DeepPartial): FieldDescriptorProto { + const message = { ...baseFieldDescriptorProto } as FieldDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = object.number; + } else { + message.number = 0; + } + if (object.label !== undefined && object.label !== null) { + message.label = object.label; + } else { + message.label = 1; + } + if (object.type !== undefined && object.type !== null) { + message.type = object.type; + } else { + message.type = 1; + } + if (object.typeName !== undefined && object.typeName !== null) { + message.typeName = object.typeName; + } else { + message.typeName = ""; + } + if (object.extendee !== undefined && object.extendee !== null) { + message.extendee = object.extendee; + } else { + message.extendee = ""; + } + if (object.defaultValue !== undefined && object.defaultValue !== null) { + message.defaultValue = object.defaultValue; + } else { + message.defaultValue = ""; + } + if (object.oneofIndex !== undefined && object.oneofIndex !== null) { + message.oneofIndex = object.oneofIndex; + } else { + message.oneofIndex = 0; + } + if (object.jsonName !== undefined && object.jsonName !== null) { + message.jsonName = object.jsonName; + } else { + message.jsonName = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = FieldOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.proto3Optional !== undefined && object.proto3Optional !== null) { + message.proto3Optional = object.proto3Optional; + } else { + message.proto3Optional = false; + } + return message; + }, +}; + +const baseOneofDescriptorProto: object = { name: "" }; + +export const OneofDescriptorProto = { + encode( + message: OneofDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.options !== undefined) { + OneofOptions.encode(message.options, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): OneofDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseOneofDescriptorProto } as OneofDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.options = OneofOptions.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): OneofDescriptorProto { + const message = { ...baseOneofDescriptorProto } as OneofDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = OneofOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: OneofDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.options !== undefined && + (obj.options = message.options + ? OneofOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): OneofDescriptorProto { + const message = { ...baseOneofDescriptorProto } as OneofDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = OneofOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseEnumDescriptorProto: object = { name: "", reservedName: "" }; + +export const EnumDescriptorProto = { + encode( + message: EnumDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + for (const v of message.value) { + EnumValueDescriptorProto.encode(v!, writer.uint32(18).fork()).ldelim(); + } + if (message.options !== undefined) { + EnumOptions.encode(message.options, writer.uint32(26).fork()).ldelim(); + } + for (const v of message.reservedRange) { + EnumDescriptorProto_EnumReservedRange.encode( + v!, + writer.uint32(34).fork() + ).ldelim(); + } + for (const v of message.reservedName) { + writer.uint32(42).string(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): EnumDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseEnumDescriptorProto } as EnumDescriptorProto; + message.value = []; + message.reservedRange = []; + message.reservedName = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.value.push( + EnumValueDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 3: + message.options = EnumOptions.decode(reader, reader.uint32()); + break; + case 4: + message.reservedRange.push( + EnumDescriptorProto_EnumReservedRange.decode( + reader, + reader.uint32() + ) + ); + break; + case 5: + message.reservedName.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumDescriptorProto { + const message = { ...baseEnumDescriptorProto } as EnumDescriptorProto; + message.value = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.value !== undefined && object.value !== null) { + for (const e of object.value) { + message.value.push(EnumValueDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push( + EnumDescriptorProto_EnumReservedRange.fromJSON(e) + ); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(String(e)); + } + } + return message; + }, + + toJSON(message: EnumDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + if (message.value) { + obj.value = message.value.map((e) => + e ? EnumValueDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.value = []; + } + message.options !== undefined && + (obj.options = message.options + ? EnumOptions.toJSON(message.options) + : undefined); + if (message.reservedRange) { + obj.reservedRange = message.reservedRange.map((e) => + e ? EnumDescriptorProto_EnumReservedRange.toJSON(e) : undefined + ); + } else { + obj.reservedRange = []; + } + if (message.reservedName) { + obj.reservedName = message.reservedName.map((e) => e); + } else { + obj.reservedName = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): EnumDescriptorProto { + const message = { ...baseEnumDescriptorProto } as EnumDescriptorProto; + message.value = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.value !== undefined && object.value !== null) { + for (const e of object.value) { + message.value.push(EnumValueDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push( + EnumDescriptorProto_EnumReservedRange.fromPartial(e) + ); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(e); + } + } + return message; + }, +}; + +const baseEnumDescriptorProto_EnumReservedRange: object = { start: 0, end: 0 }; + +export const EnumDescriptorProto_EnumReservedRange = { + encode( + message: EnumDescriptorProto_EnumReservedRange, + writer: Writer = Writer.create() + ): Writer { + if (message.start !== 0) { + writer.uint32(8).int32(message.start); + } + if (message.end !== 0) { + writer.uint32(16).int32(message.end); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): EnumDescriptorProto_EnumReservedRange { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseEnumDescriptorProto_EnumReservedRange, + } as EnumDescriptorProto_EnumReservedRange; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.start = reader.int32(); + break; + case 2: + message.end = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumDescriptorProto_EnumReservedRange { + const message = { + ...baseEnumDescriptorProto_EnumReservedRange, + } as EnumDescriptorProto_EnumReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = Number(object.start); + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + return message; + }, + + toJSON(message: EnumDescriptorProto_EnumReservedRange): unknown { + const obj: any = {}; + message.start !== undefined && (obj.start = message.start); + message.end !== undefined && (obj.end = message.end); + return obj; + }, + + fromPartial( + object: DeepPartial + ): EnumDescriptorProto_EnumReservedRange { + const message = { + ...baseEnumDescriptorProto_EnumReservedRange, + } as EnumDescriptorProto_EnumReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = object.start; + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + return message; + }, +}; + +const baseEnumValueDescriptorProto: object = { name: "", number: 0 }; + +export const EnumValueDescriptorProto = { + encode( + message: EnumValueDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.number !== 0) { + writer.uint32(16).int32(message.number); + } + if (message.options !== undefined) { + EnumValueOptions.encode( + message.options, + writer.uint32(26).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): EnumValueDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseEnumValueDescriptorProto, + } as EnumValueDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.number = reader.int32(); + break; + case 3: + message.options = EnumValueOptions.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumValueDescriptorProto { + const message = { + ...baseEnumValueDescriptorProto, + } as EnumValueDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = Number(object.number); + } else { + message.number = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumValueOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: EnumValueDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.number !== undefined && (obj.number = message.number); + message.options !== undefined && + (obj.options = message.options + ? EnumValueOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): EnumValueDescriptorProto { + const message = { + ...baseEnumValueDescriptorProto, + } as EnumValueDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = object.number; + } else { + message.number = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumValueOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseServiceDescriptorProto: object = { name: "" }; + +export const ServiceDescriptorProto = { + encode( + message: ServiceDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + for (const v of message.method) { + MethodDescriptorProto.encode(v!, writer.uint32(18).fork()).ldelim(); + } + if (message.options !== undefined) { + ServiceOptions.encode(message.options, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ServiceDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseServiceDescriptorProto } as ServiceDescriptorProto; + message.method = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.method.push( + MethodDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 3: + message.options = ServiceOptions.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ServiceDescriptorProto { + const message = { ...baseServiceDescriptorProto } as ServiceDescriptorProto; + message.method = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.method !== undefined && object.method !== null) { + for (const e of object.method) { + message.method.push(MethodDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = ServiceOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: ServiceDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + if (message.method) { + obj.method = message.method.map((e) => + e ? MethodDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.method = []; + } + message.options !== undefined && + (obj.options = message.options + ? ServiceOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): ServiceDescriptorProto { + const message = { ...baseServiceDescriptorProto } as ServiceDescriptorProto; + message.method = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.method !== undefined && object.method !== null) { + for (const e of object.method) { + message.method.push(MethodDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = ServiceOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseMethodDescriptorProto: object = { + name: "", + inputType: "", + outputType: "", + clientStreaming: false, + serverStreaming: false, +}; + +export const MethodDescriptorProto = { + encode( + message: MethodDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.inputType !== "") { + writer.uint32(18).string(message.inputType); + } + if (message.outputType !== "") { + writer.uint32(26).string(message.outputType); + } + if (message.options !== undefined) { + MethodOptions.encode(message.options, writer.uint32(34).fork()).ldelim(); + } + if (message.clientStreaming === true) { + writer.uint32(40).bool(message.clientStreaming); + } + if (message.serverStreaming === true) { + writer.uint32(48).bool(message.serverStreaming); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MethodDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMethodDescriptorProto } as MethodDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.inputType = reader.string(); + break; + case 3: + message.outputType = reader.string(); + break; + case 4: + message.options = MethodOptions.decode(reader, reader.uint32()); + break; + case 5: + message.clientStreaming = reader.bool(); + break; + case 6: + message.serverStreaming = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MethodDescriptorProto { + const message = { ...baseMethodDescriptorProto } as MethodDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.inputType !== undefined && object.inputType !== null) { + message.inputType = String(object.inputType); + } else { + message.inputType = ""; + } + if (object.outputType !== undefined && object.outputType !== null) { + message.outputType = String(object.outputType); + } else { + message.outputType = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = MethodOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if ( + object.clientStreaming !== undefined && + object.clientStreaming !== null + ) { + message.clientStreaming = Boolean(object.clientStreaming); + } else { + message.clientStreaming = false; + } + if ( + object.serverStreaming !== undefined && + object.serverStreaming !== null + ) { + message.serverStreaming = Boolean(object.serverStreaming); + } else { + message.serverStreaming = false; + } + return message; + }, + + toJSON(message: MethodDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.inputType !== undefined && (obj.inputType = message.inputType); + message.outputType !== undefined && (obj.outputType = message.outputType); + message.options !== undefined && + (obj.options = message.options + ? MethodOptions.toJSON(message.options) + : undefined); + message.clientStreaming !== undefined && + (obj.clientStreaming = message.clientStreaming); + message.serverStreaming !== undefined && + (obj.serverStreaming = message.serverStreaming); + return obj; + }, + + fromPartial( + object: DeepPartial + ): MethodDescriptorProto { + const message = { ...baseMethodDescriptorProto } as MethodDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.inputType !== undefined && object.inputType !== null) { + message.inputType = object.inputType; + } else { + message.inputType = ""; + } + if (object.outputType !== undefined && object.outputType !== null) { + message.outputType = object.outputType; + } else { + message.outputType = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = MethodOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if ( + object.clientStreaming !== undefined && + object.clientStreaming !== null + ) { + message.clientStreaming = object.clientStreaming; + } else { + message.clientStreaming = false; + } + if ( + object.serverStreaming !== undefined && + object.serverStreaming !== null + ) { + message.serverStreaming = object.serverStreaming; + } else { + message.serverStreaming = false; + } + return message; + }, +}; + +const baseFileOptions: object = { + javaPackage: "", + javaOuterClassname: "", + javaMultipleFiles: false, + javaGenerateEqualsAndHash: false, + javaStringCheckUtf8: false, + optimizeFor: 1, + goPackage: "", + ccGenericServices: false, + javaGenericServices: false, + pyGenericServices: false, + phpGenericServices: false, + deprecated: false, + ccEnableArenas: false, + objcClassPrefix: "", + csharpNamespace: "", + swiftPrefix: "", + phpClassPrefix: "", + phpNamespace: "", + phpMetadataNamespace: "", + rubyPackage: "", +}; + +export const FileOptions = { + encode(message: FileOptions, writer: Writer = Writer.create()): Writer { + if (message.javaPackage !== "") { + writer.uint32(10).string(message.javaPackage); + } + if (message.javaOuterClassname !== "") { + writer.uint32(66).string(message.javaOuterClassname); + } + if (message.javaMultipleFiles === true) { + writer.uint32(80).bool(message.javaMultipleFiles); + } + if (message.javaGenerateEqualsAndHash === true) { + writer.uint32(160).bool(message.javaGenerateEqualsAndHash); + } + if (message.javaStringCheckUtf8 === true) { + writer.uint32(216).bool(message.javaStringCheckUtf8); + } + if (message.optimizeFor !== 1) { + writer.uint32(72).int32(message.optimizeFor); + } + if (message.goPackage !== "") { + writer.uint32(90).string(message.goPackage); + } + if (message.ccGenericServices === true) { + writer.uint32(128).bool(message.ccGenericServices); + } + if (message.javaGenericServices === true) { + writer.uint32(136).bool(message.javaGenericServices); + } + if (message.pyGenericServices === true) { + writer.uint32(144).bool(message.pyGenericServices); + } + if (message.phpGenericServices === true) { + writer.uint32(336).bool(message.phpGenericServices); + } + if (message.deprecated === true) { + writer.uint32(184).bool(message.deprecated); + } + if (message.ccEnableArenas === true) { + writer.uint32(248).bool(message.ccEnableArenas); + } + if (message.objcClassPrefix !== "") { + writer.uint32(290).string(message.objcClassPrefix); + } + if (message.csharpNamespace !== "") { + writer.uint32(298).string(message.csharpNamespace); + } + if (message.swiftPrefix !== "") { + writer.uint32(314).string(message.swiftPrefix); + } + if (message.phpClassPrefix !== "") { + writer.uint32(322).string(message.phpClassPrefix); + } + if (message.phpNamespace !== "") { + writer.uint32(330).string(message.phpNamespace); + } + if (message.phpMetadataNamespace !== "") { + writer.uint32(354).string(message.phpMetadataNamespace); + } + if (message.rubyPackage !== "") { + writer.uint32(362).string(message.rubyPackage); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FileOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFileOptions } as FileOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.javaPackage = reader.string(); + break; + case 8: + message.javaOuterClassname = reader.string(); + break; + case 10: + message.javaMultipleFiles = reader.bool(); + break; + case 20: + message.javaGenerateEqualsAndHash = reader.bool(); + break; + case 27: + message.javaStringCheckUtf8 = reader.bool(); + break; + case 9: + message.optimizeFor = reader.int32() as any; + break; + case 11: + message.goPackage = reader.string(); + break; + case 16: + message.ccGenericServices = reader.bool(); + break; + case 17: + message.javaGenericServices = reader.bool(); + break; + case 18: + message.pyGenericServices = reader.bool(); + break; + case 42: + message.phpGenericServices = reader.bool(); + break; + case 23: + message.deprecated = reader.bool(); + break; + case 31: + message.ccEnableArenas = reader.bool(); + break; + case 36: + message.objcClassPrefix = reader.string(); + break; + case 37: + message.csharpNamespace = reader.string(); + break; + case 39: + message.swiftPrefix = reader.string(); + break; + case 40: + message.phpClassPrefix = reader.string(); + break; + case 41: + message.phpNamespace = reader.string(); + break; + case 44: + message.phpMetadataNamespace = reader.string(); + break; + case 45: + message.rubyPackage = reader.string(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FileOptions { + const message = { ...baseFileOptions } as FileOptions; + message.uninterpretedOption = []; + if (object.javaPackage !== undefined && object.javaPackage !== null) { + message.javaPackage = String(object.javaPackage); + } else { + message.javaPackage = ""; + } + if ( + object.javaOuterClassname !== undefined && + object.javaOuterClassname !== null + ) { + message.javaOuterClassname = String(object.javaOuterClassname); + } else { + message.javaOuterClassname = ""; + } + if ( + object.javaMultipleFiles !== undefined && + object.javaMultipleFiles !== null + ) { + message.javaMultipleFiles = Boolean(object.javaMultipleFiles); + } else { + message.javaMultipleFiles = false; + } + if ( + object.javaGenerateEqualsAndHash !== undefined && + object.javaGenerateEqualsAndHash !== null + ) { + message.javaGenerateEqualsAndHash = Boolean( + object.javaGenerateEqualsAndHash + ); + } else { + message.javaGenerateEqualsAndHash = false; + } + if ( + object.javaStringCheckUtf8 !== undefined && + object.javaStringCheckUtf8 !== null + ) { + message.javaStringCheckUtf8 = Boolean(object.javaStringCheckUtf8); + } else { + message.javaStringCheckUtf8 = false; + } + if (object.optimizeFor !== undefined && object.optimizeFor !== null) { + message.optimizeFor = fileOptions_OptimizeModeFromJSON( + object.optimizeFor + ); + } else { + message.optimizeFor = 1; + } + if (object.goPackage !== undefined && object.goPackage !== null) { + message.goPackage = String(object.goPackage); + } else { + message.goPackage = ""; + } + if ( + object.ccGenericServices !== undefined && + object.ccGenericServices !== null + ) { + message.ccGenericServices = Boolean(object.ccGenericServices); + } else { + message.ccGenericServices = false; + } + if ( + object.javaGenericServices !== undefined && + object.javaGenericServices !== null + ) { + message.javaGenericServices = Boolean(object.javaGenericServices); + } else { + message.javaGenericServices = false; + } + if ( + object.pyGenericServices !== undefined && + object.pyGenericServices !== null + ) { + message.pyGenericServices = Boolean(object.pyGenericServices); + } else { + message.pyGenericServices = false; + } + if ( + object.phpGenericServices !== undefined && + object.phpGenericServices !== null + ) { + message.phpGenericServices = Boolean(object.phpGenericServices); + } else { + message.phpGenericServices = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if (object.ccEnableArenas !== undefined && object.ccEnableArenas !== null) { + message.ccEnableArenas = Boolean(object.ccEnableArenas); + } else { + message.ccEnableArenas = false; + } + if ( + object.objcClassPrefix !== undefined && + object.objcClassPrefix !== null + ) { + message.objcClassPrefix = String(object.objcClassPrefix); + } else { + message.objcClassPrefix = ""; + } + if ( + object.csharpNamespace !== undefined && + object.csharpNamespace !== null + ) { + message.csharpNamespace = String(object.csharpNamespace); + } else { + message.csharpNamespace = ""; + } + if (object.swiftPrefix !== undefined && object.swiftPrefix !== null) { + message.swiftPrefix = String(object.swiftPrefix); + } else { + message.swiftPrefix = ""; + } + if (object.phpClassPrefix !== undefined && object.phpClassPrefix !== null) { + message.phpClassPrefix = String(object.phpClassPrefix); + } else { + message.phpClassPrefix = ""; + } + if (object.phpNamespace !== undefined && object.phpNamespace !== null) { + message.phpNamespace = String(object.phpNamespace); + } else { + message.phpNamespace = ""; + } + if ( + object.phpMetadataNamespace !== undefined && + object.phpMetadataNamespace !== null + ) { + message.phpMetadataNamespace = String(object.phpMetadataNamespace); + } else { + message.phpMetadataNamespace = ""; + } + if (object.rubyPackage !== undefined && object.rubyPackage !== null) { + message.rubyPackage = String(object.rubyPackage); + } else { + message.rubyPackage = ""; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: FileOptions): unknown { + const obj: any = {}; + message.javaPackage !== undefined && + (obj.javaPackage = message.javaPackage); + message.javaOuterClassname !== undefined && + (obj.javaOuterClassname = message.javaOuterClassname); + message.javaMultipleFiles !== undefined && + (obj.javaMultipleFiles = message.javaMultipleFiles); + message.javaGenerateEqualsAndHash !== undefined && + (obj.javaGenerateEqualsAndHash = message.javaGenerateEqualsAndHash); + message.javaStringCheckUtf8 !== undefined && + (obj.javaStringCheckUtf8 = message.javaStringCheckUtf8); + message.optimizeFor !== undefined && + (obj.optimizeFor = fileOptions_OptimizeModeToJSON(message.optimizeFor)); + message.goPackage !== undefined && (obj.goPackage = message.goPackage); + message.ccGenericServices !== undefined && + (obj.ccGenericServices = message.ccGenericServices); + message.javaGenericServices !== undefined && + (obj.javaGenericServices = message.javaGenericServices); + message.pyGenericServices !== undefined && + (obj.pyGenericServices = message.pyGenericServices); + message.phpGenericServices !== undefined && + (obj.phpGenericServices = message.phpGenericServices); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.ccEnableArenas !== undefined && + (obj.ccEnableArenas = message.ccEnableArenas); + message.objcClassPrefix !== undefined && + (obj.objcClassPrefix = message.objcClassPrefix); + message.csharpNamespace !== undefined && + (obj.csharpNamespace = message.csharpNamespace); + message.swiftPrefix !== undefined && + (obj.swiftPrefix = message.swiftPrefix); + message.phpClassPrefix !== undefined && + (obj.phpClassPrefix = message.phpClassPrefix); + message.phpNamespace !== undefined && + (obj.phpNamespace = message.phpNamespace); + message.phpMetadataNamespace !== undefined && + (obj.phpMetadataNamespace = message.phpMetadataNamespace); + message.rubyPackage !== undefined && + (obj.rubyPackage = message.rubyPackage); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): FileOptions { + const message = { ...baseFileOptions } as FileOptions; + message.uninterpretedOption = []; + if (object.javaPackage !== undefined && object.javaPackage !== null) { + message.javaPackage = object.javaPackage; + } else { + message.javaPackage = ""; + } + if ( + object.javaOuterClassname !== undefined && + object.javaOuterClassname !== null + ) { + message.javaOuterClassname = object.javaOuterClassname; + } else { + message.javaOuterClassname = ""; + } + if ( + object.javaMultipleFiles !== undefined && + object.javaMultipleFiles !== null + ) { + message.javaMultipleFiles = object.javaMultipleFiles; + } else { + message.javaMultipleFiles = false; + } + if ( + object.javaGenerateEqualsAndHash !== undefined && + object.javaGenerateEqualsAndHash !== null + ) { + message.javaGenerateEqualsAndHash = object.javaGenerateEqualsAndHash; + } else { + message.javaGenerateEqualsAndHash = false; + } + if ( + object.javaStringCheckUtf8 !== undefined && + object.javaStringCheckUtf8 !== null + ) { + message.javaStringCheckUtf8 = object.javaStringCheckUtf8; + } else { + message.javaStringCheckUtf8 = false; + } + if (object.optimizeFor !== undefined && object.optimizeFor !== null) { + message.optimizeFor = object.optimizeFor; + } else { + message.optimizeFor = 1; + } + if (object.goPackage !== undefined && object.goPackage !== null) { + message.goPackage = object.goPackage; + } else { + message.goPackage = ""; + } + if ( + object.ccGenericServices !== undefined && + object.ccGenericServices !== null + ) { + message.ccGenericServices = object.ccGenericServices; + } else { + message.ccGenericServices = false; + } + if ( + object.javaGenericServices !== undefined && + object.javaGenericServices !== null + ) { + message.javaGenericServices = object.javaGenericServices; + } else { + message.javaGenericServices = false; + } + if ( + object.pyGenericServices !== undefined && + object.pyGenericServices !== null + ) { + message.pyGenericServices = object.pyGenericServices; + } else { + message.pyGenericServices = false; + } + if ( + object.phpGenericServices !== undefined && + object.phpGenericServices !== null + ) { + message.phpGenericServices = object.phpGenericServices; + } else { + message.phpGenericServices = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if (object.ccEnableArenas !== undefined && object.ccEnableArenas !== null) { + message.ccEnableArenas = object.ccEnableArenas; + } else { + message.ccEnableArenas = false; + } + if ( + object.objcClassPrefix !== undefined && + object.objcClassPrefix !== null + ) { + message.objcClassPrefix = object.objcClassPrefix; + } else { + message.objcClassPrefix = ""; + } + if ( + object.csharpNamespace !== undefined && + object.csharpNamespace !== null + ) { + message.csharpNamespace = object.csharpNamespace; + } else { + message.csharpNamespace = ""; + } + if (object.swiftPrefix !== undefined && object.swiftPrefix !== null) { + message.swiftPrefix = object.swiftPrefix; + } else { + message.swiftPrefix = ""; + } + if (object.phpClassPrefix !== undefined && object.phpClassPrefix !== null) { + message.phpClassPrefix = object.phpClassPrefix; + } else { + message.phpClassPrefix = ""; + } + if (object.phpNamespace !== undefined && object.phpNamespace !== null) { + message.phpNamespace = object.phpNamespace; + } else { + message.phpNamespace = ""; + } + if ( + object.phpMetadataNamespace !== undefined && + object.phpMetadataNamespace !== null + ) { + message.phpMetadataNamespace = object.phpMetadataNamespace; + } else { + message.phpMetadataNamespace = ""; + } + if (object.rubyPackage !== undefined && object.rubyPackage !== null) { + message.rubyPackage = object.rubyPackage; + } else { + message.rubyPackage = ""; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseMessageOptions: object = { + messageSetWireFormat: false, + noStandardDescriptorAccessor: false, + deprecated: false, + mapEntry: false, +}; + +export const MessageOptions = { + encode(message: MessageOptions, writer: Writer = Writer.create()): Writer { + if (message.messageSetWireFormat === true) { + writer.uint32(8).bool(message.messageSetWireFormat); + } + if (message.noStandardDescriptorAccessor === true) { + writer.uint32(16).bool(message.noStandardDescriptorAccessor); + } + if (message.deprecated === true) { + writer.uint32(24).bool(message.deprecated); + } + if (message.mapEntry === true) { + writer.uint32(56).bool(message.mapEntry); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MessageOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMessageOptions } as MessageOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.messageSetWireFormat = reader.bool(); + break; + case 2: + message.noStandardDescriptorAccessor = reader.bool(); + break; + case 3: + message.deprecated = reader.bool(); + break; + case 7: + message.mapEntry = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MessageOptions { + const message = { ...baseMessageOptions } as MessageOptions; + message.uninterpretedOption = []; + if ( + object.messageSetWireFormat !== undefined && + object.messageSetWireFormat !== null + ) { + message.messageSetWireFormat = Boolean(object.messageSetWireFormat); + } else { + message.messageSetWireFormat = false; + } + if ( + object.noStandardDescriptorAccessor !== undefined && + object.noStandardDescriptorAccessor !== null + ) { + message.noStandardDescriptorAccessor = Boolean( + object.noStandardDescriptorAccessor + ); + } else { + message.noStandardDescriptorAccessor = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if (object.mapEntry !== undefined && object.mapEntry !== null) { + message.mapEntry = Boolean(object.mapEntry); + } else { + message.mapEntry = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: MessageOptions): unknown { + const obj: any = {}; + message.messageSetWireFormat !== undefined && + (obj.messageSetWireFormat = message.messageSetWireFormat); + message.noStandardDescriptorAccessor !== undefined && + (obj.noStandardDescriptorAccessor = message.noStandardDescriptorAccessor); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.mapEntry !== undefined && (obj.mapEntry = message.mapEntry); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): MessageOptions { + const message = { ...baseMessageOptions } as MessageOptions; + message.uninterpretedOption = []; + if ( + object.messageSetWireFormat !== undefined && + object.messageSetWireFormat !== null + ) { + message.messageSetWireFormat = object.messageSetWireFormat; + } else { + message.messageSetWireFormat = false; + } + if ( + object.noStandardDescriptorAccessor !== undefined && + object.noStandardDescriptorAccessor !== null + ) { + message.noStandardDescriptorAccessor = + object.noStandardDescriptorAccessor; + } else { + message.noStandardDescriptorAccessor = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if (object.mapEntry !== undefined && object.mapEntry !== null) { + message.mapEntry = object.mapEntry; + } else { + message.mapEntry = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseFieldOptions: object = { + ctype: 0, + packed: false, + jstype: 0, + lazy: false, + deprecated: false, + weak: false, +}; + +export const FieldOptions = { + encode(message: FieldOptions, writer: Writer = Writer.create()): Writer { + if (message.ctype !== 0) { + writer.uint32(8).int32(message.ctype); + } + if (message.packed === true) { + writer.uint32(16).bool(message.packed); + } + if (message.jstype !== 0) { + writer.uint32(48).int32(message.jstype); + } + if (message.lazy === true) { + writer.uint32(40).bool(message.lazy); + } + if (message.deprecated === true) { + writer.uint32(24).bool(message.deprecated); + } + if (message.weak === true) { + writer.uint32(80).bool(message.weak); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FieldOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFieldOptions } as FieldOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.ctype = reader.int32() as any; + break; + case 2: + message.packed = reader.bool(); + break; + case 6: + message.jstype = reader.int32() as any; + break; + case 5: + message.lazy = reader.bool(); + break; + case 3: + message.deprecated = reader.bool(); + break; + case 10: + message.weak = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FieldOptions { + const message = { ...baseFieldOptions } as FieldOptions; + message.uninterpretedOption = []; + if (object.ctype !== undefined && object.ctype !== null) { + message.ctype = fieldOptions_CTypeFromJSON(object.ctype); + } else { + message.ctype = 0; + } + if (object.packed !== undefined && object.packed !== null) { + message.packed = Boolean(object.packed); + } else { + message.packed = false; + } + if (object.jstype !== undefined && object.jstype !== null) { + message.jstype = fieldOptions_JSTypeFromJSON(object.jstype); + } else { + message.jstype = 0; + } + if (object.lazy !== undefined && object.lazy !== null) { + message.lazy = Boolean(object.lazy); + } else { + message.lazy = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if (object.weak !== undefined && object.weak !== null) { + message.weak = Boolean(object.weak); + } else { + message.weak = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: FieldOptions): unknown { + const obj: any = {}; + message.ctype !== undefined && + (obj.ctype = fieldOptions_CTypeToJSON(message.ctype)); + message.packed !== undefined && (obj.packed = message.packed); + message.jstype !== undefined && + (obj.jstype = fieldOptions_JSTypeToJSON(message.jstype)); + message.lazy !== undefined && (obj.lazy = message.lazy); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.weak !== undefined && (obj.weak = message.weak); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): FieldOptions { + const message = { ...baseFieldOptions } as FieldOptions; + message.uninterpretedOption = []; + if (object.ctype !== undefined && object.ctype !== null) { + message.ctype = object.ctype; + } else { + message.ctype = 0; + } + if (object.packed !== undefined && object.packed !== null) { + message.packed = object.packed; + } else { + message.packed = false; + } + if (object.jstype !== undefined && object.jstype !== null) { + message.jstype = object.jstype; + } else { + message.jstype = 0; + } + if (object.lazy !== undefined && object.lazy !== null) { + message.lazy = object.lazy; + } else { + message.lazy = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if (object.weak !== undefined && object.weak !== null) { + message.weak = object.weak; + } else { + message.weak = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseOneofOptions: object = {}; + +export const OneofOptions = { + encode(message: OneofOptions, writer: Writer = Writer.create()): Writer { + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): OneofOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseOneofOptions } as OneofOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): OneofOptions { + const message = { ...baseOneofOptions } as OneofOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: OneofOptions): unknown { + const obj: any = {}; + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): OneofOptions { + const message = { ...baseOneofOptions } as OneofOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseEnumOptions: object = { allowAlias: false, deprecated: false }; + +export const EnumOptions = { + encode(message: EnumOptions, writer: Writer = Writer.create()): Writer { + if (message.allowAlias === true) { + writer.uint32(16).bool(message.allowAlias); + } + if (message.deprecated === true) { + writer.uint32(24).bool(message.deprecated); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): EnumOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseEnumOptions } as EnumOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + message.allowAlias = reader.bool(); + break; + case 3: + message.deprecated = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumOptions { + const message = { ...baseEnumOptions } as EnumOptions; + message.uninterpretedOption = []; + if (object.allowAlias !== undefined && object.allowAlias !== null) { + message.allowAlias = Boolean(object.allowAlias); + } else { + message.allowAlias = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: EnumOptions): unknown { + const obj: any = {}; + message.allowAlias !== undefined && (obj.allowAlias = message.allowAlias); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): EnumOptions { + const message = { ...baseEnumOptions } as EnumOptions; + message.uninterpretedOption = []; + if (object.allowAlias !== undefined && object.allowAlias !== null) { + message.allowAlias = object.allowAlias; + } else { + message.allowAlias = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseEnumValueOptions: object = { deprecated: false }; + +export const EnumValueOptions = { + encode(message: EnumValueOptions, writer: Writer = Writer.create()): Writer { + if (message.deprecated === true) { + writer.uint32(8).bool(message.deprecated); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): EnumValueOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseEnumValueOptions } as EnumValueOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.deprecated = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumValueOptions { + const message = { ...baseEnumValueOptions } as EnumValueOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: EnumValueOptions): unknown { + const obj: any = {}; + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): EnumValueOptions { + const message = { ...baseEnumValueOptions } as EnumValueOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseServiceOptions: object = { deprecated: false }; + +export const ServiceOptions = { + encode(message: ServiceOptions, writer: Writer = Writer.create()): Writer { + if (message.deprecated === true) { + writer.uint32(264).bool(message.deprecated); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ServiceOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseServiceOptions } as ServiceOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 33: + message.deprecated = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ServiceOptions { + const message = { ...baseServiceOptions } as ServiceOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: ServiceOptions): unknown { + const obj: any = {}; + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): ServiceOptions { + const message = { ...baseServiceOptions } as ServiceOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseMethodOptions: object = { deprecated: false, idempotencyLevel: 0 }; + +export const MethodOptions = { + encode(message: MethodOptions, writer: Writer = Writer.create()): Writer { + if (message.deprecated === true) { + writer.uint32(264).bool(message.deprecated); + } + if (message.idempotencyLevel !== 0) { + writer.uint32(272).int32(message.idempotencyLevel); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MethodOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMethodOptions } as MethodOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 33: + message.deprecated = reader.bool(); + break; + case 34: + message.idempotencyLevel = reader.int32() as any; + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MethodOptions { + const message = { ...baseMethodOptions } as MethodOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.idempotencyLevel !== undefined && + object.idempotencyLevel !== null + ) { + message.idempotencyLevel = methodOptions_IdempotencyLevelFromJSON( + object.idempotencyLevel + ); + } else { + message.idempotencyLevel = 0; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: MethodOptions): unknown { + const obj: any = {}; + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.idempotencyLevel !== undefined && + (obj.idempotencyLevel = methodOptions_IdempotencyLevelToJSON( + message.idempotencyLevel + )); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): MethodOptions { + const message = { ...baseMethodOptions } as MethodOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.idempotencyLevel !== undefined && + object.idempotencyLevel !== null + ) { + message.idempotencyLevel = object.idempotencyLevel; + } else { + message.idempotencyLevel = 0; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseUninterpretedOption: object = { + identifierValue: "", + positiveIntValue: 0, + negativeIntValue: 0, + doubleValue: 0, + aggregateValue: "", +}; + +export const UninterpretedOption = { + encode( + message: UninterpretedOption, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.name) { + UninterpretedOption_NamePart.encode( + v!, + writer.uint32(18).fork() + ).ldelim(); + } + if (message.identifierValue !== "") { + writer.uint32(26).string(message.identifierValue); + } + if (message.positiveIntValue !== 0) { + writer.uint32(32).uint64(message.positiveIntValue); + } + if (message.negativeIntValue !== 0) { + writer.uint32(40).int64(message.negativeIntValue); + } + if (message.doubleValue !== 0) { + writer.uint32(49).double(message.doubleValue); + } + if (message.stringValue.length !== 0) { + writer.uint32(58).bytes(message.stringValue); + } + if (message.aggregateValue !== "") { + writer.uint32(66).string(message.aggregateValue); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): UninterpretedOption { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseUninterpretedOption } as UninterpretedOption; + message.name = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + message.name.push( + UninterpretedOption_NamePart.decode(reader, reader.uint32()) + ); + break; + case 3: + message.identifierValue = reader.string(); + break; + case 4: + message.positiveIntValue = longToNumber(reader.uint64() as Long); + break; + case 5: + message.negativeIntValue = longToNumber(reader.int64() as Long); + break; + case 6: + message.doubleValue = reader.double(); + break; + case 7: + message.stringValue = reader.bytes(); + break; + case 8: + message.aggregateValue = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): UninterpretedOption { + const message = { ...baseUninterpretedOption } as UninterpretedOption; + message.name = []; + if (object.name !== undefined && object.name !== null) { + for (const e of object.name) { + message.name.push(UninterpretedOption_NamePart.fromJSON(e)); + } + } + if ( + object.identifierValue !== undefined && + object.identifierValue !== null + ) { + message.identifierValue = String(object.identifierValue); + } else { + message.identifierValue = ""; + } + if ( + object.positiveIntValue !== undefined && + object.positiveIntValue !== null + ) { + message.positiveIntValue = Number(object.positiveIntValue); + } else { + message.positiveIntValue = 0; + } + if ( + object.negativeIntValue !== undefined && + object.negativeIntValue !== null + ) { + message.negativeIntValue = Number(object.negativeIntValue); + } else { + message.negativeIntValue = 0; + } + if (object.doubleValue !== undefined && object.doubleValue !== null) { + message.doubleValue = Number(object.doubleValue); + } else { + message.doubleValue = 0; + } + if (object.stringValue !== undefined && object.stringValue !== null) { + message.stringValue = bytesFromBase64(object.stringValue); + } + if (object.aggregateValue !== undefined && object.aggregateValue !== null) { + message.aggregateValue = String(object.aggregateValue); + } else { + message.aggregateValue = ""; + } + return message; + }, + + toJSON(message: UninterpretedOption): unknown { + const obj: any = {}; + if (message.name) { + obj.name = message.name.map((e) => + e ? UninterpretedOption_NamePart.toJSON(e) : undefined + ); + } else { + obj.name = []; + } + message.identifierValue !== undefined && + (obj.identifierValue = message.identifierValue); + message.positiveIntValue !== undefined && + (obj.positiveIntValue = message.positiveIntValue); + message.negativeIntValue !== undefined && + (obj.negativeIntValue = message.negativeIntValue); + message.doubleValue !== undefined && + (obj.doubleValue = message.doubleValue); + message.stringValue !== undefined && + (obj.stringValue = base64FromBytes( + message.stringValue !== undefined + ? message.stringValue + : new Uint8Array() + )); + message.aggregateValue !== undefined && + (obj.aggregateValue = message.aggregateValue); + return obj; + }, + + fromPartial(object: DeepPartial): UninterpretedOption { + const message = { ...baseUninterpretedOption } as UninterpretedOption; + message.name = []; + if (object.name !== undefined && object.name !== null) { + for (const e of object.name) { + message.name.push(UninterpretedOption_NamePart.fromPartial(e)); + } + } + if ( + object.identifierValue !== undefined && + object.identifierValue !== null + ) { + message.identifierValue = object.identifierValue; + } else { + message.identifierValue = ""; + } + if ( + object.positiveIntValue !== undefined && + object.positiveIntValue !== null + ) { + message.positiveIntValue = object.positiveIntValue; + } else { + message.positiveIntValue = 0; + } + if ( + object.negativeIntValue !== undefined && + object.negativeIntValue !== null + ) { + message.negativeIntValue = object.negativeIntValue; + } else { + message.negativeIntValue = 0; + } + if (object.doubleValue !== undefined && object.doubleValue !== null) { + message.doubleValue = object.doubleValue; + } else { + message.doubleValue = 0; + } + if (object.stringValue !== undefined && object.stringValue !== null) { + message.stringValue = object.stringValue; + } else { + message.stringValue = new Uint8Array(); + } + if (object.aggregateValue !== undefined && object.aggregateValue !== null) { + message.aggregateValue = object.aggregateValue; + } else { + message.aggregateValue = ""; + } + return message; + }, +}; + +const baseUninterpretedOption_NamePart: object = { + namePart: "", + isExtension: false, +}; + +export const UninterpretedOption_NamePart = { + encode( + message: UninterpretedOption_NamePart, + writer: Writer = Writer.create() + ): Writer { + if (message.namePart !== "") { + writer.uint32(10).string(message.namePart); + } + if (message.isExtension === true) { + writer.uint32(16).bool(message.isExtension); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): UninterpretedOption_NamePart { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseUninterpretedOption_NamePart, + } as UninterpretedOption_NamePart; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.namePart = reader.string(); + break; + case 2: + message.isExtension = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): UninterpretedOption_NamePart { + const message = { + ...baseUninterpretedOption_NamePart, + } as UninterpretedOption_NamePart; + if (object.namePart !== undefined && object.namePart !== null) { + message.namePart = String(object.namePart); + } else { + message.namePart = ""; + } + if (object.isExtension !== undefined && object.isExtension !== null) { + message.isExtension = Boolean(object.isExtension); + } else { + message.isExtension = false; + } + return message; + }, + + toJSON(message: UninterpretedOption_NamePart): unknown { + const obj: any = {}; + message.namePart !== undefined && (obj.namePart = message.namePart); + message.isExtension !== undefined && + (obj.isExtension = message.isExtension); + return obj; + }, + + fromPartial( + object: DeepPartial + ): UninterpretedOption_NamePart { + const message = { + ...baseUninterpretedOption_NamePart, + } as UninterpretedOption_NamePart; + if (object.namePart !== undefined && object.namePart !== null) { + message.namePart = object.namePart; + } else { + message.namePart = ""; + } + if (object.isExtension !== undefined && object.isExtension !== null) { + message.isExtension = object.isExtension; + } else { + message.isExtension = false; + } + return message; + }, +}; + +const baseSourceCodeInfo: object = {}; + +export const SourceCodeInfo = { + encode(message: SourceCodeInfo, writer: Writer = Writer.create()): Writer { + for (const v of message.location) { + SourceCodeInfo_Location.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): SourceCodeInfo { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseSourceCodeInfo } as SourceCodeInfo; + message.location = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.location.push( + SourceCodeInfo_Location.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): SourceCodeInfo { + const message = { ...baseSourceCodeInfo } as SourceCodeInfo; + message.location = []; + if (object.location !== undefined && object.location !== null) { + for (const e of object.location) { + message.location.push(SourceCodeInfo_Location.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: SourceCodeInfo): unknown { + const obj: any = {}; + if (message.location) { + obj.location = message.location.map((e) => + e ? SourceCodeInfo_Location.toJSON(e) : undefined + ); + } else { + obj.location = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): SourceCodeInfo { + const message = { ...baseSourceCodeInfo } as SourceCodeInfo; + message.location = []; + if (object.location !== undefined && object.location !== null) { + for (const e of object.location) { + message.location.push(SourceCodeInfo_Location.fromPartial(e)); + } + } + return message; + }, +}; + +const baseSourceCodeInfo_Location: object = { + path: 0, + span: 0, + leadingComments: "", + trailingComments: "", + leadingDetachedComments: "", +}; + +export const SourceCodeInfo_Location = { + encode( + message: SourceCodeInfo_Location, + writer: Writer = Writer.create() + ): Writer { + writer.uint32(10).fork(); + for (const v of message.path) { + writer.int32(v); + } + writer.ldelim(); + writer.uint32(18).fork(); + for (const v of message.span) { + writer.int32(v); + } + writer.ldelim(); + if (message.leadingComments !== "") { + writer.uint32(26).string(message.leadingComments); + } + if (message.trailingComments !== "") { + writer.uint32(34).string(message.trailingComments); + } + for (const v of message.leadingDetachedComments) { + writer.uint32(50).string(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): SourceCodeInfo_Location { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseSourceCodeInfo_Location, + } as SourceCodeInfo_Location; + message.path = []; + message.span = []; + message.leadingDetachedComments = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.path.push(reader.int32()); + } + } else { + message.path.push(reader.int32()); + } + break; + case 2: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.span.push(reader.int32()); + } + } else { + message.span.push(reader.int32()); + } + break; + case 3: + message.leadingComments = reader.string(); + break; + case 4: + message.trailingComments = reader.string(); + break; + case 6: + message.leadingDetachedComments.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): SourceCodeInfo_Location { + const message = { + ...baseSourceCodeInfo_Location, + } as SourceCodeInfo_Location; + message.path = []; + message.span = []; + message.leadingDetachedComments = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(Number(e)); + } + } + if (object.span !== undefined && object.span !== null) { + for (const e of object.span) { + message.span.push(Number(e)); + } + } + if ( + object.leadingComments !== undefined && + object.leadingComments !== null + ) { + message.leadingComments = String(object.leadingComments); + } else { + message.leadingComments = ""; + } + if ( + object.trailingComments !== undefined && + object.trailingComments !== null + ) { + message.trailingComments = String(object.trailingComments); + } else { + message.trailingComments = ""; + } + if ( + object.leadingDetachedComments !== undefined && + object.leadingDetachedComments !== null + ) { + for (const e of object.leadingDetachedComments) { + message.leadingDetachedComments.push(String(e)); + } + } + return message; + }, + + toJSON(message: SourceCodeInfo_Location): unknown { + const obj: any = {}; + if (message.path) { + obj.path = message.path.map((e) => e); + } else { + obj.path = []; + } + if (message.span) { + obj.span = message.span.map((e) => e); + } else { + obj.span = []; + } + message.leadingComments !== undefined && + (obj.leadingComments = message.leadingComments); + message.trailingComments !== undefined && + (obj.trailingComments = message.trailingComments); + if (message.leadingDetachedComments) { + obj.leadingDetachedComments = message.leadingDetachedComments.map( + (e) => e + ); + } else { + obj.leadingDetachedComments = []; + } + return obj; + }, + + fromPartial( + object: DeepPartial + ): SourceCodeInfo_Location { + const message = { + ...baseSourceCodeInfo_Location, + } as SourceCodeInfo_Location; + message.path = []; + message.span = []; + message.leadingDetachedComments = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(e); + } + } + if (object.span !== undefined && object.span !== null) { + for (const e of object.span) { + message.span.push(e); + } + } + if ( + object.leadingComments !== undefined && + object.leadingComments !== null + ) { + message.leadingComments = object.leadingComments; + } else { + message.leadingComments = ""; + } + if ( + object.trailingComments !== undefined && + object.trailingComments !== null + ) { + message.trailingComments = object.trailingComments; + } else { + message.trailingComments = ""; + } + if ( + object.leadingDetachedComments !== undefined && + object.leadingDetachedComments !== null + ) { + for (const e of object.leadingDetachedComments) { + message.leadingDetachedComments.push(e); + } + } + return message; + }, +}; + +const baseGeneratedCodeInfo: object = {}; + +export const GeneratedCodeInfo = { + encode(message: GeneratedCodeInfo, writer: Writer = Writer.create()): Writer { + for (const v of message.annotation) { + GeneratedCodeInfo_Annotation.encode( + v!, + writer.uint32(10).fork() + ).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): GeneratedCodeInfo { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseGeneratedCodeInfo } as GeneratedCodeInfo; + message.annotation = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.annotation.push( + GeneratedCodeInfo_Annotation.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GeneratedCodeInfo { + const message = { ...baseGeneratedCodeInfo } as GeneratedCodeInfo; + message.annotation = []; + if (object.annotation !== undefined && object.annotation !== null) { + for (const e of object.annotation) { + message.annotation.push(GeneratedCodeInfo_Annotation.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: GeneratedCodeInfo): unknown { + const obj: any = {}; + if (message.annotation) { + obj.annotation = message.annotation.map((e) => + e ? GeneratedCodeInfo_Annotation.toJSON(e) : undefined + ); + } else { + obj.annotation = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): GeneratedCodeInfo { + const message = { ...baseGeneratedCodeInfo } as GeneratedCodeInfo; + message.annotation = []; + if (object.annotation !== undefined && object.annotation !== null) { + for (const e of object.annotation) { + message.annotation.push(GeneratedCodeInfo_Annotation.fromPartial(e)); + } + } + return message; + }, +}; + +const baseGeneratedCodeInfo_Annotation: object = { + path: 0, + sourceFile: "", + begin: 0, + end: 0, +}; + +export const GeneratedCodeInfo_Annotation = { + encode( + message: GeneratedCodeInfo_Annotation, + writer: Writer = Writer.create() + ): Writer { + writer.uint32(10).fork(); + for (const v of message.path) { + writer.int32(v); + } + writer.ldelim(); + if (message.sourceFile !== "") { + writer.uint32(18).string(message.sourceFile); + } + if (message.begin !== 0) { + writer.uint32(24).int32(message.begin); + } + if (message.end !== 0) { + writer.uint32(32).int32(message.end); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): GeneratedCodeInfo_Annotation { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseGeneratedCodeInfo_Annotation, + } as GeneratedCodeInfo_Annotation; + message.path = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.path.push(reader.int32()); + } + } else { + message.path.push(reader.int32()); + } + break; + case 2: + message.sourceFile = reader.string(); + break; + case 3: + message.begin = reader.int32(); + break; + case 4: + message.end = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GeneratedCodeInfo_Annotation { + const message = { + ...baseGeneratedCodeInfo_Annotation, + } as GeneratedCodeInfo_Annotation; + message.path = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(Number(e)); + } + } + if (object.sourceFile !== undefined && object.sourceFile !== null) { + message.sourceFile = String(object.sourceFile); + } else { + message.sourceFile = ""; + } + if (object.begin !== undefined && object.begin !== null) { + message.begin = Number(object.begin); + } else { + message.begin = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + return message; + }, + + toJSON(message: GeneratedCodeInfo_Annotation): unknown { + const obj: any = {}; + if (message.path) { + obj.path = message.path.map((e) => e); + } else { + obj.path = []; + } + message.sourceFile !== undefined && (obj.sourceFile = message.sourceFile); + message.begin !== undefined && (obj.begin = message.begin); + message.end !== undefined && (obj.end = message.end); + return obj; + }, + + fromPartial( + object: DeepPartial + ): GeneratedCodeInfo_Annotation { + const message = { + ...baseGeneratedCodeInfo_Annotation, + } as GeneratedCodeInfo_Annotation; + message.path = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(e); + } + } + if (object.sourceFile !== undefined && object.sourceFile !== null) { + message.sourceFile = object.sourceFile; + } else { + message.sourceFile = ""; + } + if (object.begin !== undefined && object.begin !== null) { + message.begin = object.begin; + } else { + message.begin = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/ibc.core.client.v1/types/google/protobuf/timestamp.ts b/ts-client/ibc.core.client.v1/types/google/protobuf/timestamp.ts new file mode 100644 index 00000000..11864afc --- /dev/null +++ b/ts-client/ibc.core.client.v1/types/google/protobuf/timestamp.ts @@ -0,0 +1,219 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "google.protobuf"; + +/** + * A Timestamp represents a point in time independent of any time zone or local + * calendar, encoded as a count of seconds and fractions of seconds at + * nanosecond resolution. The count is relative to an epoch at UTC midnight on + * January 1, 1970, in the proleptic Gregorian calendar which extends the + * Gregorian calendar backwards to year one. + * + * All minutes are 60 seconds long. Leap seconds are "smeared" so that no leap + * second table is needed for interpretation, using a [24-hour linear + * smear](https://developers.google.com/time/smear). + * + * The range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. By + * restricting to that range, we ensure that we can convert to and from [RFC + * 3339](https://www.ietf.org/rfc/rfc3339.txt) date strings. + * + * # Examples + * + * Example 1: Compute Timestamp from POSIX `time()`. + * + * Timestamp timestamp; + * timestamp.set_seconds(time(NULL)); + * timestamp.set_nanos(0); + * + * Example 2: Compute Timestamp from POSIX `gettimeofday()`. + * + * struct timeval tv; + * gettimeofday(&tv, NULL); + * + * Timestamp timestamp; + * timestamp.set_seconds(tv.tv_sec); + * timestamp.set_nanos(tv.tv_usec * 1000); + * + * Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`. + * + * FILETIME ft; + * GetSystemTimeAsFileTime(&ft); + * UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime; + * + * // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z + * // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z. + * Timestamp timestamp; + * timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL)); + * timestamp.set_nanos((INT32) ((ticks % 10000000) * 100)); + * + * Example 4: Compute Timestamp from Java `System.currentTimeMillis()`. + * + * long millis = System.currentTimeMillis(); + * + * Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000) + * .setNanos((int) ((millis % 1000) * 1000000)).build(); + * + * + * Example 5: Compute Timestamp from Java `Instant.now()`. + * + * Instant now = Instant.now(); + * + * Timestamp timestamp = + * Timestamp.newBuilder().setSeconds(now.getEpochSecond()) + * .setNanos(now.getNano()).build(); + * + * + * Example 6: Compute Timestamp from current time in Python. + * + * timestamp = Timestamp() + * timestamp.GetCurrentTime() + * + * # JSON Mapping + * + * In JSON format, the Timestamp type is encoded as a string in the + * [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the + * format is "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z" + * where {year} is always expressed using four digits while {month}, {day}, + * {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional + * seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution), + * are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone + * is required. A proto3 JSON serializer should always use UTC (as indicated by + * "Z") when printing the Timestamp type and a proto3 JSON parser should be + * able to accept both UTC and other timezones (as indicated by an offset). + * + * For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past + * 01:30 UTC on January 15, 2017. + * + * In JavaScript, one can convert a Date object to this format using the + * standard + * [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString) + * method. In Python, a standard `datetime.datetime` object can be converted + * to this format using + * [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) with + * the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one can use + * the Joda Time's [`ISODateTimeFormat.dateTime()`]( + * http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime%2D%2D + * ) to obtain a formatter capable of generating timestamps in this format. + */ +export interface Timestamp { + /** + * Represents seconds of UTC time since Unix epoch + * 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to + * 9999-12-31T23:59:59Z inclusive. + */ + seconds: number; + /** + * Non-negative fractions of a second at nanosecond resolution. Negative + * second values with fractions must still have non-negative nanos values + * that count forward in time. Must be from 0 to 999,999,999 + * inclusive. + */ + nanos: number; +} + +const baseTimestamp: object = { seconds: 0, nanos: 0 }; + +export const Timestamp = { + encode(message: Timestamp, writer: Writer = Writer.create()): Writer { + if (message.seconds !== 0) { + writer.uint32(8).int64(message.seconds); + } + if (message.nanos !== 0) { + writer.uint32(16).int32(message.nanos); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Timestamp { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseTimestamp } as Timestamp; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.seconds = longToNumber(reader.int64() as Long); + break; + case 2: + message.nanos = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Timestamp { + const message = { ...baseTimestamp } as Timestamp; + if (object.seconds !== undefined && object.seconds !== null) { + message.seconds = Number(object.seconds); + } else { + message.seconds = 0; + } + if (object.nanos !== undefined && object.nanos !== null) { + message.nanos = Number(object.nanos); + } else { + message.nanos = 0; + } + return message; + }, + + toJSON(message: Timestamp): unknown { + const obj: any = {}; + message.seconds !== undefined && (obj.seconds = message.seconds); + message.nanos !== undefined && (obj.nanos = message.nanos); + return obj; + }, + + fromPartial(object: DeepPartial): Timestamp { + const message = { ...baseTimestamp } as Timestamp; + if (object.seconds !== undefined && object.seconds !== null) { + message.seconds = object.seconds; + } else { + message.seconds = 0; + } + if (object.nanos !== undefined && object.nanos !== null) { + message.nanos = object.nanos; + } else { + message.nanos = 0; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/ibc.core.client.v1/types/ibc/core/client/v1/client.ts b/ts-client/ibc.core.client.v1/types/ibc/core/client/v1/client.ts new file mode 100644 index 00000000..7a8e15b6 --- /dev/null +++ b/ts-client/ibc.core.client.v1/types/ibc/core/client/v1/client.ts @@ -0,0 +1,786 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; +import { Any } from "../../../../google/protobuf/any"; +import { Plan } from "../../../../cosmos/upgrade/v1beta1/upgrade"; + +export const protobufPackage = "ibc.core.client.v1"; + +/** + * IdentifiedClientState defines a client state with an additional client + * identifier field. + */ +export interface IdentifiedClientState { + /** client identifier */ + clientId: string; + /** client state */ + clientState: Any | undefined; +} + +/** + * ConsensusStateWithHeight defines a consensus state with an additional height + * field. + */ +export interface ConsensusStateWithHeight { + /** consensus state height */ + height: Height | undefined; + /** consensus state */ + consensusState: Any | undefined; +} + +/** + * ClientConsensusStates defines all the stored consensus states for a given + * client. + */ +export interface ClientConsensusStates { + /** client identifier */ + clientId: string; + /** consensus states and their heights associated with the client */ + consensusStates: ConsensusStateWithHeight[]; +} + +/** + * ClientUpdateProposal is a governance proposal. If it passes, the substitute + * client's latest consensus state is copied over to the subject client. The proposal + * handler may fail if the subject and the substitute do not match in client and + * chain parameters (with exception to latest height, frozen height, and chain-id). + */ +export interface ClientUpdateProposal { + /** the title of the update proposal */ + title: string; + /** the description of the proposal */ + description: string; + /** the client identifier for the client to be updated if the proposal passes */ + subjectClientId: string; + /** + * the substitute client identifier for the client standing in for the subject + * client + */ + substituteClientId: string; +} + +/** + * UpgradeProposal is a gov Content type for initiating an IBC breaking + * upgrade. + */ +export interface UpgradeProposal { + title: string; + description: string; + plan: Plan | undefined; + /** + * An UpgradedClientState must be provided to perform an IBC breaking upgrade. + * This will make the chain commit to the correct upgraded (self) client state + * before the upgrade occurs, so that connecting chains can verify that the + * new upgraded client is valid by verifying a proof on the previous version + * of the chain. This will allow IBC connections to persist smoothly across + * planned chain upgrades + */ + upgradedClientState: Any | undefined; +} + +/** + * Height is a monotonically increasing data type + * that can be compared against another Height for the purposes of updating and + * freezing clients + * + * Normally the RevisionHeight is incremented at each height while keeping + * RevisionNumber the same. However some consensus algorithms may choose to + * reset the height in certain conditions e.g. hard forks, state-machine + * breaking changes In these cases, the RevisionNumber is incremented so that + * height continues to be monitonically increasing even as the RevisionHeight + * gets reset + */ +export interface Height { + /** the revision that the client is currently on */ + revisionNumber: number; + /** the height within the given revision */ + revisionHeight: number; +} + +/** Params defines the set of IBC light client parameters. */ +export interface Params { + /** allowed_clients defines the list of allowed client state types. */ + allowedClients: string[]; +} + +const baseIdentifiedClientState: object = { clientId: "" }; + +export const IdentifiedClientState = { + encode( + message: IdentifiedClientState, + writer: Writer = Writer.create() + ): Writer { + if (message.clientId !== "") { + writer.uint32(10).string(message.clientId); + } + if (message.clientState !== undefined) { + Any.encode(message.clientState, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): IdentifiedClientState { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseIdentifiedClientState } as IdentifiedClientState; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.clientId = reader.string(); + break; + case 2: + message.clientState = Any.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): IdentifiedClientState { + const message = { ...baseIdentifiedClientState } as IdentifiedClientState; + if (object.clientId !== undefined && object.clientId !== null) { + message.clientId = String(object.clientId); + } else { + message.clientId = ""; + } + if (object.clientState !== undefined && object.clientState !== null) { + message.clientState = Any.fromJSON(object.clientState); + } else { + message.clientState = undefined; + } + return message; + }, + + toJSON(message: IdentifiedClientState): unknown { + const obj: any = {}; + message.clientId !== undefined && (obj.clientId = message.clientId); + message.clientState !== undefined && + (obj.clientState = message.clientState + ? Any.toJSON(message.clientState) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): IdentifiedClientState { + const message = { ...baseIdentifiedClientState } as IdentifiedClientState; + if (object.clientId !== undefined && object.clientId !== null) { + message.clientId = object.clientId; + } else { + message.clientId = ""; + } + if (object.clientState !== undefined && object.clientState !== null) { + message.clientState = Any.fromPartial(object.clientState); + } else { + message.clientState = undefined; + } + return message; + }, +}; + +const baseConsensusStateWithHeight: object = {}; + +export const ConsensusStateWithHeight = { + encode( + message: ConsensusStateWithHeight, + writer: Writer = Writer.create() + ): Writer { + if (message.height !== undefined) { + Height.encode(message.height, writer.uint32(10).fork()).ldelim(); + } + if (message.consensusState !== undefined) { + Any.encode(message.consensusState, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): ConsensusStateWithHeight { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseConsensusStateWithHeight, + } as ConsensusStateWithHeight; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.height = Height.decode(reader, reader.uint32()); + break; + case 2: + message.consensusState = Any.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ConsensusStateWithHeight { + const message = { + ...baseConsensusStateWithHeight, + } as ConsensusStateWithHeight; + if (object.height !== undefined && object.height !== null) { + message.height = Height.fromJSON(object.height); + } else { + message.height = undefined; + } + if (object.consensusState !== undefined && object.consensusState !== null) { + message.consensusState = Any.fromJSON(object.consensusState); + } else { + message.consensusState = undefined; + } + return message; + }, + + toJSON(message: ConsensusStateWithHeight): unknown { + const obj: any = {}; + message.height !== undefined && + (obj.height = message.height ? Height.toJSON(message.height) : undefined); + message.consensusState !== undefined && + (obj.consensusState = message.consensusState + ? Any.toJSON(message.consensusState) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): ConsensusStateWithHeight { + const message = { + ...baseConsensusStateWithHeight, + } as ConsensusStateWithHeight; + if (object.height !== undefined && object.height !== null) { + message.height = Height.fromPartial(object.height); + } else { + message.height = undefined; + } + if (object.consensusState !== undefined && object.consensusState !== null) { + message.consensusState = Any.fromPartial(object.consensusState); + } else { + message.consensusState = undefined; + } + return message; + }, +}; + +const baseClientConsensusStates: object = { clientId: "" }; + +export const ClientConsensusStates = { + encode( + message: ClientConsensusStates, + writer: Writer = Writer.create() + ): Writer { + if (message.clientId !== "") { + writer.uint32(10).string(message.clientId); + } + for (const v of message.consensusStates) { + ConsensusStateWithHeight.encode(v!, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ClientConsensusStates { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseClientConsensusStates } as ClientConsensusStates; + message.consensusStates = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.clientId = reader.string(); + break; + case 2: + message.consensusStates.push( + ConsensusStateWithHeight.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ClientConsensusStates { + const message = { ...baseClientConsensusStates } as ClientConsensusStates; + message.consensusStates = []; + if (object.clientId !== undefined && object.clientId !== null) { + message.clientId = String(object.clientId); + } else { + message.clientId = ""; + } + if ( + object.consensusStates !== undefined && + object.consensusStates !== null + ) { + for (const e of object.consensusStates) { + message.consensusStates.push(ConsensusStateWithHeight.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: ClientConsensusStates): unknown { + const obj: any = {}; + message.clientId !== undefined && (obj.clientId = message.clientId); + if (message.consensusStates) { + obj.consensusStates = message.consensusStates.map((e) => + e ? ConsensusStateWithHeight.toJSON(e) : undefined + ); + } else { + obj.consensusStates = []; + } + return obj; + }, + + fromPartial( + object: DeepPartial + ): ClientConsensusStates { + const message = { ...baseClientConsensusStates } as ClientConsensusStates; + message.consensusStates = []; + if (object.clientId !== undefined && object.clientId !== null) { + message.clientId = object.clientId; + } else { + message.clientId = ""; + } + if ( + object.consensusStates !== undefined && + object.consensusStates !== null + ) { + for (const e of object.consensusStates) { + message.consensusStates.push(ConsensusStateWithHeight.fromPartial(e)); + } + } + return message; + }, +}; + +const baseClientUpdateProposal: object = { + title: "", + description: "", + subjectClientId: "", + substituteClientId: "", +}; + +export const ClientUpdateProposal = { + encode( + message: ClientUpdateProposal, + writer: Writer = Writer.create() + ): Writer { + if (message.title !== "") { + writer.uint32(10).string(message.title); + } + if (message.description !== "") { + writer.uint32(18).string(message.description); + } + if (message.subjectClientId !== "") { + writer.uint32(26).string(message.subjectClientId); + } + if (message.substituteClientId !== "") { + writer.uint32(34).string(message.substituteClientId); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ClientUpdateProposal { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseClientUpdateProposal } as ClientUpdateProposal; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.title = reader.string(); + break; + case 2: + message.description = reader.string(); + break; + case 3: + message.subjectClientId = reader.string(); + break; + case 4: + message.substituteClientId = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ClientUpdateProposal { + const message = { ...baseClientUpdateProposal } as ClientUpdateProposal; + if (object.title !== undefined && object.title !== null) { + message.title = String(object.title); + } else { + message.title = ""; + } + if (object.description !== undefined && object.description !== null) { + message.description = String(object.description); + } else { + message.description = ""; + } + if ( + object.subjectClientId !== undefined && + object.subjectClientId !== null + ) { + message.subjectClientId = String(object.subjectClientId); + } else { + message.subjectClientId = ""; + } + if ( + object.substituteClientId !== undefined && + object.substituteClientId !== null + ) { + message.substituteClientId = String(object.substituteClientId); + } else { + message.substituteClientId = ""; + } + return message; + }, + + toJSON(message: ClientUpdateProposal): unknown { + const obj: any = {}; + message.title !== undefined && (obj.title = message.title); + message.description !== undefined && + (obj.description = message.description); + message.subjectClientId !== undefined && + (obj.subjectClientId = message.subjectClientId); + message.substituteClientId !== undefined && + (obj.substituteClientId = message.substituteClientId); + return obj; + }, + + fromPartial(object: DeepPartial): ClientUpdateProposal { + const message = { ...baseClientUpdateProposal } as ClientUpdateProposal; + if (object.title !== undefined && object.title !== null) { + message.title = object.title; + } else { + message.title = ""; + } + if (object.description !== undefined && object.description !== null) { + message.description = object.description; + } else { + message.description = ""; + } + if ( + object.subjectClientId !== undefined && + object.subjectClientId !== null + ) { + message.subjectClientId = object.subjectClientId; + } else { + message.subjectClientId = ""; + } + if ( + object.substituteClientId !== undefined && + object.substituteClientId !== null + ) { + message.substituteClientId = object.substituteClientId; + } else { + message.substituteClientId = ""; + } + return message; + }, +}; + +const baseUpgradeProposal: object = { title: "", description: "" }; + +export const UpgradeProposal = { + encode(message: UpgradeProposal, writer: Writer = Writer.create()): Writer { + if (message.title !== "") { + writer.uint32(10).string(message.title); + } + if (message.description !== "") { + writer.uint32(18).string(message.description); + } + if (message.plan !== undefined) { + Plan.encode(message.plan, writer.uint32(26).fork()).ldelim(); + } + if (message.upgradedClientState !== undefined) { + Any.encode( + message.upgradedClientState, + writer.uint32(34).fork() + ).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): UpgradeProposal { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseUpgradeProposal } as UpgradeProposal; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.title = reader.string(); + break; + case 2: + message.description = reader.string(); + break; + case 3: + message.plan = Plan.decode(reader, reader.uint32()); + break; + case 4: + message.upgradedClientState = Any.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): UpgradeProposal { + const message = { ...baseUpgradeProposal } as UpgradeProposal; + if (object.title !== undefined && object.title !== null) { + message.title = String(object.title); + } else { + message.title = ""; + } + if (object.description !== undefined && object.description !== null) { + message.description = String(object.description); + } else { + message.description = ""; + } + if (object.plan !== undefined && object.plan !== null) { + message.plan = Plan.fromJSON(object.plan); + } else { + message.plan = undefined; + } + if ( + object.upgradedClientState !== undefined && + object.upgradedClientState !== null + ) { + message.upgradedClientState = Any.fromJSON(object.upgradedClientState); + } else { + message.upgradedClientState = undefined; + } + return message; + }, + + toJSON(message: UpgradeProposal): unknown { + const obj: any = {}; + message.title !== undefined && (obj.title = message.title); + message.description !== undefined && + (obj.description = message.description); + message.plan !== undefined && + (obj.plan = message.plan ? Plan.toJSON(message.plan) : undefined); + message.upgradedClientState !== undefined && + (obj.upgradedClientState = message.upgradedClientState + ? Any.toJSON(message.upgradedClientState) + : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): UpgradeProposal { + const message = { ...baseUpgradeProposal } as UpgradeProposal; + if (object.title !== undefined && object.title !== null) { + message.title = object.title; + } else { + message.title = ""; + } + if (object.description !== undefined && object.description !== null) { + message.description = object.description; + } else { + message.description = ""; + } + if (object.plan !== undefined && object.plan !== null) { + message.plan = Plan.fromPartial(object.plan); + } else { + message.plan = undefined; + } + if ( + object.upgradedClientState !== undefined && + object.upgradedClientState !== null + ) { + message.upgradedClientState = Any.fromPartial(object.upgradedClientState); + } else { + message.upgradedClientState = undefined; + } + return message; + }, +}; + +const baseHeight: object = { revisionNumber: 0, revisionHeight: 0 }; + +export const Height = { + encode(message: Height, writer: Writer = Writer.create()): Writer { + if (message.revisionNumber !== 0) { + writer.uint32(8).uint64(message.revisionNumber); + } + if (message.revisionHeight !== 0) { + writer.uint32(16).uint64(message.revisionHeight); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Height { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseHeight } as Height; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.revisionNumber = longToNumber(reader.uint64() as Long); + break; + case 2: + message.revisionHeight = longToNumber(reader.uint64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Height { + const message = { ...baseHeight } as Height; + if (object.revisionNumber !== undefined && object.revisionNumber !== null) { + message.revisionNumber = Number(object.revisionNumber); + } else { + message.revisionNumber = 0; + } + if (object.revisionHeight !== undefined && object.revisionHeight !== null) { + message.revisionHeight = Number(object.revisionHeight); + } else { + message.revisionHeight = 0; + } + return message; + }, + + toJSON(message: Height): unknown { + const obj: any = {}; + message.revisionNumber !== undefined && + (obj.revisionNumber = message.revisionNumber); + message.revisionHeight !== undefined && + (obj.revisionHeight = message.revisionHeight); + return obj; + }, + + fromPartial(object: DeepPartial): Height { + const message = { ...baseHeight } as Height; + if (object.revisionNumber !== undefined && object.revisionNumber !== null) { + message.revisionNumber = object.revisionNumber; + } else { + message.revisionNumber = 0; + } + if (object.revisionHeight !== undefined && object.revisionHeight !== null) { + message.revisionHeight = object.revisionHeight; + } else { + message.revisionHeight = 0; + } + return message; + }, +}; + +const baseParams: object = { allowedClients: "" }; + +export const Params = { + encode(message: Params, writer: Writer = Writer.create()): Writer { + for (const v of message.allowedClients) { + writer.uint32(10).string(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Params { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseParams } as Params; + message.allowedClients = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.allowedClients.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Params { + const message = { ...baseParams } as Params; + message.allowedClients = []; + if (object.allowedClients !== undefined && object.allowedClients !== null) { + for (const e of object.allowedClients) { + message.allowedClients.push(String(e)); + } + } + return message; + }, + + toJSON(message: Params): unknown { + const obj: any = {}; + if (message.allowedClients) { + obj.allowedClients = message.allowedClients.map((e) => e); + } else { + obj.allowedClients = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): Params { + const message = { ...baseParams } as Params; + message.allowedClients = []; + if (object.allowedClients !== undefined && object.allowedClients !== null) { + for (const e of object.allowedClients) { + message.allowedClients.push(e); + } + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/ibc.core.client.v1/types/ibc/core/client/v1/genesis.ts b/ts-client/ibc.core.client.v1/types/ibc/core/client/v1/genesis.ts new file mode 100644 index 00000000..d8f14cf4 --- /dev/null +++ b/ts-client/ibc.core.client.v1/types/ibc/core/client/v1/genesis.ts @@ -0,0 +1,475 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; +import { + IdentifiedClientState, + ClientConsensusStates, + Params, +} from "../../../../ibc/core/client/v1/client"; + +export const protobufPackage = "ibc.core.client.v1"; + +/** GenesisState defines the ibc client submodule's genesis state. */ +export interface GenesisState { + /** client states with their corresponding identifiers */ + clients: IdentifiedClientState[]; + /** consensus states from each client */ + clientsConsensus: ClientConsensusStates[]; + /** metadata from each client */ + clientsMetadata: IdentifiedGenesisMetadata[]; + params: Params | undefined; + /** create localhost on initialization */ + createLocalhost: boolean; + /** the sequence for the next generated client identifier */ + nextClientSequence: number; +} + +/** + * GenesisMetadata defines the genesis type for metadata that clients may return + * with ExportMetadata + */ +export interface GenesisMetadata { + /** store key of metadata without clientID-prefix */ + key: Uint8Array; + /** metadata value */ + value: Uint8Array; +} + +/** + * IdentifiedGenesisMetadata has the client metadata with the corresponding + * client id. + */ +export interface IdentifiedGenesisMetadata { + clientId: string; + clientMetadata: GenesisMetadata[]; +} + +const baseGenesisState: object = { + createLocalhost: false, + nextClientSequence: 0, +}; + +export const GenesisState = { + encode(message: GenesisState, writer: Writer = Writer.create()): Writer { + for (const v of message.clients) { + IdentifiedClientState.encode(v!, writer.uint32(10).fork()).ldelim(); + } + for (const v of message.clientsConsensus) { + ClientConsensusStates.encode(v!, writer.uint32(18).fork()).ldelim(); + } + for (const v of message.clientsMetadata) { + IdentifiedGenesisMetadata.encode(v!, writer.uint32(26).fork()).ldelim(); + } + if (message.params !== undefined) { + Params.encode(message.params, writer.uint32(34).fork()).ldelim(); + } + if (message.createLocalhost === true) { + writer.uint32(40).bool(message.createLocalhost); + } + if (message.nextClientSequence !== 0) { + writer.uint32(48).uint64(message.nextClientSequence); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): GenesisState { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseGenesisState } as GenesisState; + message.clients = []; + message.clientsConsensus = []; + message.clientsMetadata = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.clients.push( + IdentifiedClientState.decode(reader, reader.uint32()) + ); + break; + case 2: + message.clientsConsensus.push( + ClientConsensusStates.decode(reader, reader.uint32()) + ); + break; + case 3: + message.clientsMetadata.push( + IdentifiedGenesisMetadata.decode(reader, reader.uint32()) + ); + break; + case 4: + message.params = Params.decode(reader, reader.uint32()); + break; + case 5: + message.createLocalhost = reader.bool(); + break; + case 6: + message.nextClientSequence = longToNumber(reader.uint64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GenesisState { + const message = { ...baseGenesisState } as GenesisState; + message.clients = []; + message.clientsConsensus = []; + message.clientsMetadata = []; + if (object.clients !== undefined && object.clients !== null) { + for (const e of object.clients) { + message.clients.push(IdentifiedClientState.fromJSON(e)); + } + } + if ( + object.clientsConsensus !== undefined && + object.clientsConsensus !== null + ) { + for (const e of object.clientsConsensus) { + message.clientsConsensus.push(ClientConsensusStates.fromJSON(e)); + } + } + if ( + object.clientsMetadata !== undefined && + object.clientsMetadata !== null + ) { + for (const e of object.clientsMetadata) { + message.clientsMetadata.push(IdentifiedGenesisMetadata.fromJSON(e)); + } + } + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromJSON(object.params); + } else { + message.params = undefined; + } + if ( + object.createLocalhost !== undefined && + object.createLocalhost !== null + ) { + message.createLocalhost = Boolean(object.createLocalhost); + } else { + message.createLocalhost = false; + } + if ( + object.nextClientSequence !== undefined && + object.nextClientSequence !== null + ) { + message.nextClientSequence = Number(object.nextClientSequence); + } else { + message.nextClientSequence = 0; + } + return message; + }, + + toJSON(message: GenesisState): unknown { + const obj: any = {}; + if (message.clients) { + obj.clients = message.clients.map((e) => + e ? IdentifiedClientState.toJSON(e) : undefined + ); + } else { + obj.clients = []; + } + if (message.clientsConsensus) { + obj.clientsConsensus = message.clientsConsensus.map((e) => + e ? ClientConsensusStates.toJSON(e) : undefined + ); + } else { + obj.clientsConsensus = []; + } + if (message.clientsMetadata) { + obj.clientsMetadata = message.clientsMetadata.map((e) => + e ? IdentifiedGenesisMetadata.toJSON(e) : undefined + ); + } else { + obj.clientsMetadata = []; + } + message.params !== undefined && + (obj.params = message.params ? Params.toJSON(message.params) : undefined); + message.createLocalhost !== undefined && + (obj.createLocalhost = message.createLocalhost); + message.nextClientSequence !== undefined && + (obj.nextClientSequence = message.nextClientSequence); + return obj; + }, + + fromPartial(object: DeepPartial): GenesisState { + const message = { ...baseGenesisState } as GenesisState; + message.clients = []; + message.clientsConsensus = []; + message.clientsMetadata = []; + if (object.clients !== undefined && object.clients !== null) { + for (const e of object.clients) { + message.clients.push(IdentifiedClientState.fromPartial(e)); + } + } + if ( + object.clientsConsensus !== undefined && + object.clientsConsensus !== null + ) { + for (const e of object.clientsConsensus) { + message.clientsConsensus.push(ClientConsensusStates.fromPartial(e)); + } + } + if ( + object.clientsMetadata !== undefined && + object.clientsMetadata !== null + ) { + for (const e of object.clientsMetadata) { + message.clientsMetadata.push(IdentifiedGenesisMetadata.fromPartial(e)); + } + } + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromPartial(object.params); + } else { + message.params = undefined; + } + if ( + object.createLocalhost !== undefined && + object.createLocalhost !== null + ) { + message.createLocalhost = object.createLocalhost; + } else { + message.createLocalhost = false; + } + if ( + object.nextClientSequence !== undefined && + object.nextClientSequence !== null + ) { + message.nextClientSequence = object.nextClientSequence; + } else { + message.nextClientSequence = 0; + } + return message; + }, +}; + +const baseGenesisMetadata: object = {}; + +export const GenesisMetadata = { + encode(message: GenesisMetadata, writer: Writer = Writer.create()): Writer { + if (message.key.length !== 0) { + writer.uint32(10).bytes(message.key); + } + if (message.value.length !== 0) { + writer.uint32(18).bytes(message.value); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): GenesisMetadata { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseGenesisMetadata } as GenesisMetadata; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.key = reader.bytes(); + break; + case 2: + message.value = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GenesisMetadata { + const message = { ...baseGenesisMetadata } as GenesisMetadata; + if (object.key !== undefined && object.key !== null) { + message.key = bytesFromBase64(object.key); + } + if (object.value !== undefined && object.value !== null) { + message.value = bytesFromBase64(object.value); + } + return message; + }, + + toJSON(message: GenesisMetadata): unknown { + const obj: any = {}; + message.key !== undefined && + (obj.key = base64FromBytes( + message.key !== undefined ? message.key : new Uint8Array() + )); + message.value !== undefined && + (obj.value = base64FromBytes( + message.value !== undefined ? message.value : new Uint8Array() + )); + return obj; + }, + + fromPartial(object: DeepPartial): GenesisMetadata { + const message = { ...baseGenesisMetadata } as GenesisMetadata; + if (object.key !== undefined && object.key !== null) { + message.key = object.key; + } else { + message.key = new Uint8Array(); + } + if (object.value !== undefined && object.value !== null) { + message.value = object.value; + } else { + message.value = new Uint8Array(); + } + return message; + }, +}; + +const baseIdentifiedGenesisMetadata: object = { clientId: "" }; + +export const IdentifiedGenesisMetadata = { + encode( + message: IdentifiedGenesisMetadata, + writer: Writer = Writer.create() + ): Writer { + if (message.clientId !== "") { + writer.uint32(10).string(message.clientId); + } + for (const v of message.clientMetadata) { + GenesisMetadata.encode(v!, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): IdentifiedGenesisMetadata { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseIdentifiedGenesisMetadata, + } as IdentifiedGenesisMetadata; + message.clientMetadata = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.clientId = reader.string(); + break; + case 2: + message.clientMetadata.push( + GenesisMetadata.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): IdentifiedGenesisMetadata { + const message = { + ...baseIdentifiedGenesisMetadata, + } as IdentifiedGenesisMetadata; + message.clientMetadata = []; + if (object.clientId !== undefined && object.clientId !== null) { + message.clientId = String(object.clientId); + } else { + message.clientId = ""; + } + if (object.clientMetadata !== undefined && object.clientMetadata !== null) { + for (const e of object.clientMetadata) { + message.clientMetadata.push(GenesisMetadata.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: IdentifiedGenesisMetadata): unknown { + const obj: any = {}; + message.clientId !== undefined && (obj.clientId = message.clientId); + if (message.clientMetadata) { + obj.clientMetadata = message.clientMetadata.map((e) => + e ? GenesisMetadata.toJSON(e) : undefined + ); + } else { + obj.clientMetadata = []; + } + return obj; + }, + + fromPartial( + object: DeepPartial + ): IdentifiedGenesisMetadata { + const message = { + ...baseIdentifiedGenesisMetadata, + } as IdentifiedGenesisMetadata; + message.clientMetadata = []; + if (object.clientId !== undefined && object.clientId !== null) { + message.clientId = object.clientId; + } else { + message.clientId = ""; + } + if (object.clientMetadata !== undefined && object.clientMetadata !== null) { + for (const e of object.clientMetadata) { + message.clientMetadata.push(GenesisMetadata.fromPartial(e)); + } + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/ibc.core.client.v1/types/ibc/core/client/v1/query.ts b/ts-client/ibc.core.client.v1/types/ibc/core/client/v1/query.ts new file mode 100644 index 00000000..c2c0dafd --- /dev/null +++ b/ts-client/ibc.core.client.v1/types/ibc/core/client/v1/query.ts @@ -0,0 +1,1954 @@ +/* eslint-disable */ +import { Reader, util, configure, Writer } from "protobufjs/minimal"; +import * as Long from "long"; +import { Any } from "../../../../google/protobuf/any"; +import { + Height, + IdentifiedClientState, + ConsensusStateWithHeight, + Params, +} from "../../../../ibc/core/client/v1/client"; +import { + PageRequest, + PageResponse, +} from "../../../../cosmos/base/query/v1beta1/pagination"; + +export const protobufPackage = "ibc.core.client.v1"; + +/** + * QueryClientStateRequest is the request type for the Query/ClientState RPC + * method + */ +export interface QueryClientStateRequest { + /** client state unique identifier */ + clientId: string; +} + +/** + * QueryClientStateResponse is the response type for the Query/ClientState RPC + * method. Besides the client state, it includes a proof and the height from + * which the proof was retrieved. + */ +export interface QueryClientStateResponse { + /** client state associated with the request identifier */ + clientState: Any | undefined; + /** merkle proof of existence */ + proof: Uint8Array; + /** height at which the proof was retrieved */ + proofHeight: Height | undefined; +} + +/** + * QueryClientStatesRequest is the request type for the Query/ClientStates RPC + * method + */ +export interface QueryClientStatesRequest { + /** pagination request */ + pagination: PageRequest | undefined; +} + +/** + * QueryClientStatesResponse is the response type for the Query/ClientStates RPC + * method. + */ +export interface QueryClientStatesResponse { + /** list of stored ClientStates of the chain. */ + clientStates: IdentifiedClientState[]; + /** pagination response */ + pagination: PageResponse | undefined; +} + +/** + * QueryConsensusStateRequest is the request type for the Query/ConsensusState + * RPC method. Besides the consensus state, it includes a proof and the height + * from which the proof was retrieved. + */ +export interface QueryConsensusStateRequest { + /** client identifier */ + clientId: string; + /** consensus state revision number */ + revisionNumber: number; + /** consensus state revision height */ + revisionHeight: number; + /** + * latest_height overrrides the height field and queries the latest stored + * ConsensusState + */ + latestHeight: boolean; +} + +/** + * QueryConsensusStateResponse is the response type for the Query/ConsensusState + * RPC method + */ +export interface QueryConsensusStateResponse { + /** consensus state associated with the client identifier at the given height */ + consensusState: Any | undefined; + /** merkle proof of existence */ + proof: Uint8Array; + /** height at which the proof was retrieved */ + proofHeight: Height | undefined; +} + +/** + * QueryConsensusStatesRequest is the request type for the Query/ConsensusStates + * RPC method. + */ +export interface QueryConsensusStatesRequest { + /** client identifier */ + clientId: string; + /** pagination request */ + pagination: PageRequest | undefined; +} + +/** + * QueryConsensusStatesResponse is the response type for the + * Query/ConsensusStates RPC method + */ +export interface QueryConsensusStatesResponse { + /** consensus states associated with the identifier */ + consensusStates: ConsensusStateWithHeight[]; + /** pagination response */ + pagination: PageResponse | undefined; +} + +/** + * QueryConsensusStateHeightsRequest is the request type for Query/ConsensusStateHeights + * RPC method. + */ +export interface QueryConsensusStateHeightsRequest { + /** client identifier */ + clientId: string; + /** pagination request */ + pagination: PageRequest | undefined; +} + +/** + * QueryConsensusStateHeightsResponse is the response type for the + * Query/ConsensusStateHeights RPC method + */ +export interface QueryConsensusStateHeightsResponse { + /** consensus state heights */ + consensusStateHeights: Height[]; + /** pagination response */ + pagination: PageResponse | undefined; +} + +/** + * QueryClientStatusRequest is the request type for the Query/ClientStatus RPC + * method + */ +export interface QueryClientStatusRequest { + /** client unique identifier */ + clientId: string; +} + +/** + * QueryClientStatusResponse is the response type for the Query/ClientStatus RPC + * method. It returns the current status of the IBC client. + */ +export interface QueryClientStatusResponse { + status: string; +} + +/** + * QueryClientParamsRequest is the request type for the Query/ClientParams RPC + * method. + */ +export interface QueryClientParamsRequest {} + +/** + * QueryClientParamsResponse is the response type for the Query/ClientParams RPC + * method. + */ +export interface QueryClientParamsResponse { + /** params defines the parameters of the module. */ + params: Params | undefined; +} + +/** + * QueryUpgradedClientStateRequest is the request type for the + * Query/UpgradedClientState RPC method + */ +export interface QueryUpgradedClientStateRequest {} + +/** + * QueryUpgradedClientStateResponse is the response type for the + * Query/UpgradedClientState RPC method. + */ +export interface QueryUpgradedClientStateResponse { + /** client state associated with the request identifier */ + upgradedClientState: Any | undefined; +} + +/** + * QueryUpgradedConsensusStateRequest is the request type for the + * Query/UpgradedConsensusState RPC method + */ +export interface QueryUpgradedConsensusStateRequest {} + +/** + * QueryUpgradedConsensusStateResponse is the response type for the + * Query/UpgradedConsensusState RPC method. + */ +export interface QueryUpgradedConsensusStateResponse { + /** Consensus state associated with the request identifier */ + upgradedConsensusState: Any | undefined; +} + +const baseQueryClientStateRequest: object = { clientId: "" }; + +export const QueryClientStateRequest = { + encode( + message: QueryClientStateRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.clientId !== "") { + writer.uint32(10).string(message.clientId); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QueryClientStateRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryClientStateRequest, + } as QueryClientStateRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.clientId = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryClientStateRequest { + const message = { + ...baseQueryClientStateRequest, + } as QueryClientStateRequest; + if (object.clientId !== undefined && object.clientId !== null) { + message.clientId = String(object.clientId); + } else { + message.clientId = ""; + } + return message; + }, + + toJSON(message: QueryClientStateRequest): unknown { + const obj: any = {}; + message.clientId !== undefined && (obj.clientId = message.clientId); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryClientStateRequest { + const message = { + ...baseQueryClientStateRequest, + } as QueryClientStateRequest; + if (object.clientId !== undefined && object.clientId !== null) { + message.clientId = object.clientId; + } else { + message.clientId = ""; + } + return message; + }, +}; + +const baseQueryClientStateResponse: object = {}; + +export const QueryClientStateResponse = { + encode( + message: QueryClientStateResponse, + writer: Writer = Writer.create() + ): Writer { + if (message.clientState !== undefined) { + Any.encode(message.clientState, writer.uint32(10).fork()).ldelim(); + } + if (message.proof.length !== 0) { + writer.uint32(18).bytes(message.proof); + } + if (message.proofHeight !== undefined) { + Height.encode(message.proofHeight, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryClientStateResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryClientStateResponse, + } as QueryClientStateResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.clientState = Any.decode(reader, reader.uint32()); + break; + case 2: + message.proof = reader.bytes(); + break; + case 3: + message.proofHeight = Height.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryClientStateResponse { + const message = { + ...baseQueryClientStateResponse, + } as QueryClientStateResponse; + if (object.clientState !== undefined && object.clientState !== null) { + message.clientState = Any.fromJSON(object.clientState); + } else { + message.clientState = undefined; + } + if (object.proof !== undefined && object.proof !== null) { + message.proof = bytesFromBase64(object.proof); + } + if (object.proofHeight !== undefined && object.proofHeight !== null) { + message.proofHeight = Height.fromJSON(object.proofHeight); + } else { + message.proofHeight = undefined; + } + return message; + }, + + toJSON(message: QueryClientStateResponse): unknown { + const obj: any = {}; + message.clientState !== undefined && + (obj.clientState = message.clientState + ? Any.toJSON(message.clientState) + : undefined); + message.proof !== undefined && + (obj.proof = base64FromBytes( + message.proof !== undefined ? message.proof : new Uint8Array() + )); + message.proofHeight !== undefined && + (obj.proofHeight = message.proofHeight + ? Height.toJSON(message.proofHeight) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryClientStateResponse { + const message = { + ...baseQueryClientStateResponse, + } as QueryClientStateResponse; + if (object.clientState !== undefined && object.clientState !== null) { + message.clientState = Any.fromPartial(object.clientState); + } else { + message.clientState = undefined; + } + if (object.proof !== undefined && object.proof !== null) { + message.proof = object.proof; + } else { + message.proof = new Uint8Array(); + } + if (object.proofHeight !== undefined && object.proofHeight !== null) { + message.proofHeight = Height.fromPartial(object.proofHeight); + } else { + message.proofHeight = undefined; + } + return message; + }, +}; + +const baseQueryClientStatesRequest: object = {}; + +export const QueryClientStatesRequest = { + encode( + message: QueryClientStatesRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryClientStatesRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryClientStatesRequest, + } as QueryClientStatesRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryClientStatesRequest { + const message = { + ...baseQueryClientStatesRequest, + } as QueryClientStatesRequest; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryClientStatesRequest): unknown { + const obj: any = {}; + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageRequest.toJSON(message.pagination) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryClientStatesRequest { + const message = { + ...baseQueryClientStatesRequest, + } as QueryClientStatesRequest; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseQueryClientStatesResponse: object = {}; + +export const QueryClientStatesResponse = { + encode( + message: QueryClientStatesResponse, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.clientStates) { + IdentifiedClientState.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode( + message.pagination, + writer.uint32(18).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryClientStatesResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryClientStatesResponse, + } as QueryClientStatesResponse; + message.clientStates = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.clientStates.push( + IdentifiedClientState.decode(reader, reader.uint32()) + ); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryClientStatesResponse { + const message = { + ...baseQueryClientStatesResponse, + } as QueryClientStatesResponse; + message.clientStates = []; + if (object.clientStates !== undefined && object.clientStates !== null) { + for (const e of object.clientStates) { + message.clientStates.push(IdentifiedClientState.fromJSON(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryClientStatesResponse): unknown { + const obj: any = {}; + if (message.clientStates) { + obj.clientStates = message.clientStates.map((e) => + e ? IdentifiedClientState.toJSON(e) : undefined + ); + } else { + obj.clientStates = []; + } + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageResponse.toJSON(message.pagination) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryClientStatesResponse { + const message = { + ...baseQueryClientStatesResponse, + } as QueryClientStatesResponse; + message.clientStates = []; + if (object.clientStates !== undefined && object.clientStates !== null) { + for (const e of object.clientStates) { + message.clientStates.push(IdentifiedClientState.fromPartial(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseQueryConsensusStateRequest: object = { + clientId: "", + revisionNumber: 0, + revisionHeight: 0, + latestHeight: false, +}; + +export const QueryConsensusStateRequest = { + encode( + message: QueryConsensusStateRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.clientId !== "") { + writer.uint32(10).string(message.clientId); + } + if (message.revisionNumber !== 0) { + writer.uint32(16).uint64(message.revisionNumber); + } + if (message.revisionHeight !== 0) { + writer.uint32(24).uint64(message.revisionHeight); + } + if (message.latestHeight === true) { + writer.uint32(32).bool(message.latestHeight); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryConsensusStateRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryConsensusStateRequest, + } as QueryConsensusStateRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.clientId = reader.string(); + break; + case 2: + message.revisionNumber = longToNumber(reader.uint64() as Long); + break; + case 3: + message.revisionHeight = longToNumber(reader.uint64() as Long); + break; + case 4: + message.latestHeight = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryConsensusStateRequest { + const message = { + ...baseQueryConsensusStateRequest, + } as QueryConsensusStateRequest; + if (object.clientId !== undefined && object.clientId !== null) { + message.clientId = String(object.clientId); + } else { + message.clientId = ""; + } + if (object.revisionNumber !== undefined && object.revisionNumber !== null) { + message.revisionNumber = Number(object.revisionNumber); + } else { + message.revisionNumber = 0; + } + if (object.revisionHeight !== undefined && object.revisionHeight !== null) { + message.revisionHeight = Number(object.revisionHeight); + } else { + message.revisionHeight = 0; + } + if (object.latestHeight !== undefined && object.latestHeight !== null) { + message.latestHeight = Boolean(object.latestHeight); + } else { + message.latestHeight = false; + } + return message; + }, + + toJSON(message: QueryConsensusStateRequest): unknown { + const obj: any = {}; + message.clientId !== undefined && (obj.clientId = message.clientId); + message.revisionNumber !== undefined && + (obj.revisionNumber = message.revisionNumber); + message.revisionHeight !== undefined && + (obj.revisionHeight = message.revisionHeight); + message.latestHeight !== undefined && + (obj.latestHeight = message.latestHeight); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryConsensusStateRequest { + const message = { + ...baseQueryConsensusStateRequest, + } as QueryConsensusStateRequest; + if (object.clientId !== undefined && object.clientId !== null) { + message.clientId = object.clientId; + } else { + message.clientId = ""; + } + if (object.revisionNumber !== undefined && object.revisionNumber !== null) { + message.revisionNumber = object.revisionNumber; + } else { + message.revisionNumber = 0; + } + if (object.revisionHeight !== undefined && object.revisionHeight !== null) { + message.revisionHeight = object.revisionHeight; + } else { + message.revisionHeight = 0; + } + if (object.latestHeight !== undefined && object.latestHeight !== null) { + message.latestHeight = object.latestHeight; + } else { + message.latestHeight = false; + } + return message; + }, +}; + +const baseQueryConsensusStateResponse: object = {}; + +export const QueryConsensusStateResponse = { + encode( + message: QueryConsensusStateResponse, + writer: Writer = Writer.create() + ): Writer { + if (message.consensusState !== undefined) { + Any.encode(message.consensusState, writer.uint32(10).fork()).ldelim(); + } + if (message.proof.length !== 0) { + writer.uint32(18).bytes(message.proof); + } + if (message.proofHeight !== undefined) { + Height.encode(message.proofHeight, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryConsensusStateResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryConsensusStateResponse, + } as QueryConsensusStateResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.consensusState = Any.decode(reader, reader.uint32()); + break; + case 2: + message.proof = reader.bytes(); + break; + case 3: + message.proofHeight = Height.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryConsensusStateResponse { + const message = { + ...baseQueryConsensusStateResponse, + } as QueryConsensusStateResponse; + if (object.consensusState !== undefined && object.consensusState !== null) { + message.consensusState = Any.fromJSON(object.consensusState); + } else { + message.consensusState = undefined; + } + if (object.proof !== undefined && object.proof !== null) { + message.proof = bytesFromBase64(object.proof); + } + if (object.proofHeight !== undefined && object.proofHeight !== null) { + message.proofHeight = Height.fromJSON(object.proofHeight); + } else { + message.proofHeight = undefined; + } + return message; + }, + + toJSON(message: QueryConsensusStateResponse): unknown { + const obj: any = {}; + message.consensusState !== undefined && + (obj.consensusState = message.consensusState + ? Any.toJSON(message.consensusState) + : undefined); + message.proof !== undefined && + (obj.proof = base64FromBytes( + message.proof !== undefined ? message.proof : new Uint8Array() + )); + message.proofHeight !== undefined && + (obj.proofHeight = message.proofHeight + ? Height.toJSON(message.proofHeight) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryConsensusStateResponse { + const message = { + ...baseQueryConsensusStateResponse, + } as QueryConsensusStateResponse; + if (object.consensusState !== undefined && object.consensusState !== null) { + message.consensusState = Any.fromPartial(object.consensusState); + } else { + message.consensusState = undefined; + } + if (object.proof !== undefined && object.proof !== null) { + message.proof = object.proof; + } else { + message.proof = new Uint8Array(); + } + if (object.proofHeight !== undefined && object.proofHeight !== null) { + message.proofHeight = Height.fromPartial(object.proofHeight); + } else { + message.proofHeight = undefined; + } + return message; + }, +}; + +const baseQueryConsensusStatesRequest: object = { clientId: "" }; + +export const QueryConsensusStatesRequest = { + encode( + message: QueryConsensusStatesRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.clientId !== "") { + writer.uint32(10).string(message.clientId); + } + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryConsensusStatesRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryConsensusStatesRequest, + } as QueryConsensusStatesRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.clientId = reader.string(); + break; + case 2: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryConsensusStatesRequest { + const message = { + ...baseQueryConsensusStatesRequest, + } as QueryConsensusStatesRequest; + if (object.clientId !== undefined && object.clientId !== null) { + message.clientId = String(object.clientId); + } else { + message.clientId = ""; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryConsensusStatesRequest): unknown { + const obj: any = {}; + message.clientId !== undefined && (obj.clientId = message.clientId); + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageRequest.toJSON(message.pagination) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryConsensusStatesRequest { + const message = { + ...baseQueryConsensusStatesRequest, + } as QueryConsensusStatesRequest; + if (object.clientId !== undefined && object.clientId !== null) { + message.clientId = object.clientId; + } else { + message.clientId = ""; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseQueryConsensusStatesResponse: object = {}; + +export const QueryConsensusStatesResponse = { + encode( + message: QueryConsensusStatesResponse, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.consensusStates) { + ConsensusStateWithHeight.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode( + message.pagination, + writer.uint32(18).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryConsensusStatesResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryConsensusStatesResponse, + } as QueryConsensusStatesResponse; + message.consensusStates = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.consensusStates.push( + ConsensusStateWithHeight.decode(reader, reader.uint32()) + ); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryConsensusStatesResponse { + const message = { + ...baseQueryConsensusStatesResponse, + } as QueryConsensusStatesResponse; + message.consensusStates = []; + if ( + object.consensusStates !== undefined && + object.consensusStates !== null + ) { + for (const e of object.consensusStates) { + message.consensusStates.push(ConsensusStateWithHeight.fromJSON(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryConsensusStatesResponse): unknown { + const obj: any = {}; + if (message.consensusStates) { + obj.consensusStates = message.consensusStates.map((e) => + e ? ConsensusStateWithHeight.toJSON(e) : undefined + ); + } else { + obj.consensusStates = []; + } + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageResponse.toJSON(message.pagination) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryConsensusStatesResponse { + const message = { + ...baseQueryConsensusStatesResponse, + } as QueryConsensusStatesResponse; + message.consensusStates = []; + if ( + object.consensusStates !== undefined && + object.consensusStates !== null + ) { + for (const e of object.consensusStates) { + message.consensusStates.push(ConsensusStateWithHeight.fromPartial(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseQueryConsensusStateHeightsRequest: object = { clientId: "" }; + +export const QueryConsensusStateHeightsRequest = { + encode( + message: QueryConsensusStateHeightsRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.clientId !== "") { + writer.uint32(10).string(message.clientId); + } + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryConsensusStateHeightsRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryConsensusStateHeightsRequest, + } as QueryConsensusStateHeightsRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.clientId = reader.string(); + break; + case 2: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryConsensusStateHeightsRequest { + const message = { + ...baseQueryConsensusStateHeightsRequest, + } as QueryConsensusStateHeightsRequest; + if (object.clientId !== undefined && object.clientId !== null) { + message.clientId = String(object.clientId); + } else { + message.clientId = ""; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryConsensusStateHeightsRequest): unknown { + const obj: any = {}; + message.clientId !== undefined && (obj.clientId = message.clientId); + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageRequest.toJSON(message.pagination) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryConsensusStateHeightsRequest { + const message = { + ...baseQueryConsensusStateHeightsRequest, + } as QueryConsensusStateHeightsRequest; + if (object.clientId !== undefined && object.clientId !== null) { + message.clientId = object.clientId; + } else { + message.clientId = ""; + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseQueryConsensusStateHeightsResponse: object = {}; + +export const QueryConsensusStateHeightsResponse = { + encode( + message: QueryConsensusStateHeightsResponse, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.consensusStateHeights) { + Height.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode( + message.pagination, + writer.uint32(18).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryConsensusStateHeightsResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryConsensusStateHeightsResponse, + } as QueryConsensusStateHeightsResponse; + message.consensusStateHeights = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.consensusStateHeights.push( + Height.decode(reader, reader.uint32()) + ); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryConsensusStateHeightsResponse { + const message = { + ...baseQueryConsensusStateHeightsResponse, + } as QueryConsensusStateHeightsResponse; + message.consensusStateHeights = []; + if ( + object.consensusStateHeights !== undefined && + object.consensusStateHeights !== null + ) { + for (const e of object.consensusStateHeights) { + message.consensusStateHeights.push(Height.fromJSON(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryConsensusStateHeightsResponse): unknown { + const obj: any = {}; + if (message.consensusStateHeights) { + obj.consensusStateHeights = message.consensusStateHeights.map((e) => + e ? Height.toJSON(e) : undefined + ); + } else { + obj.consensusStateHeights = []; + } + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageResponse.toJSON(message.pagination) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryConsensusStateHeightsResponse { + const message = { + ...baseQueryConsensusStateHeightsResponse, + } as QueryConsensusStateHeightsResponse; + message.consensusStateHeights = []; + if ( + object.consensusStateHeights !== undefined && + object.consensusStateHeights !== null + ) { + for (const e of object.consensusStateHeights) { + message.consensusStateHeights.push(Height.fromPartial(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseQueryClientStatusRequest: object = { clientId: "" }; + +export const QueryClientStatusRequest = { + encode( + message: QueryClientStatusRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.clientId !== "") { + writer.uint32(10).string(message.clientId); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryClientStatusRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryClientStatusRequest, + } as QueryClientStatusRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.clientId = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryClientStatusRequest { + const message = { + ...baseQueryClientStatusRequest, + } as QueryClientStatusRequest; + if (object.clientId !== undefined && object.clientId !== null) { + message.clientId = String(object.clientId); + } else { + message.clientId = ""; + } + return message; + }, + + toJSON(message: QueryClientStatusRequest): unknown { + const obj: any = {}; + message.clientId !== undefined && (obj.clientId = message.clientId); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryClientStatusRequest { + const message = { + ...baseQueryClientStatusRequest, + } as QueryClientStatusRequest; + if (object.clientId !== undefined && object.clientId !== null) { + message.clientId = object.clientId; + } else { + message.clientId = ""; + } + return message; + }, +}; + +const baseQueryClientStatusResponse: object = { status: "" }; + +export const QueryClientStatusResponse = { + encode( + message: QueryClientStatusResponse, + writer: Writer = Writer.create() + ): Writer { + if (message.status !== "") { + writer.uint32(10).string(message.status); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryClientStatusResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryClientStatusResponse, + } as QueryClientStatusResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.status = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryClientStatusResponse { + const message = { + ...baseQueryClientStatusResponse, + } as QueryClientStatusResponse; + if (object.status !== undefined && object.status !== null) { + message.status = String(object.status); + } else { + message.status = ""; + } + return message; + }, + + toJSON(message: QueryClientStatusResponse): unknown { + const obj: any = {}; + message.status !== undefined && (obj.status = message.status); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryClientStatusResponse { + const message = { + ...baseQueryClientStatusResponse, + } as QueryClientStatusResponse; + if (object.status !== undefined && object.status !== null) { + message.status = object.status; + } else { + message.status = ""; + } + return message; + }, +}; + +const baseQueryClientParamsRequest: object = {}; + +export const QueryClientParamsRequest = { + encode( + _: QueryClientParamsRequest, + writer: Writer = Writer.create() + ): Writer { + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryClientParamsRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryClientParamsRequest, + } as QueryClientParamsRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): QueryClientParamsRequest { + const message = { + ...baseQueryClientParamsRequest, + } as QueryClientParamsRequest; + return message; + }, + + toJSON(_: QueryClientParamsRequest): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial( + _: DeepPartial + ): QueryClientParamsRequest { + const message = { + ...baseQueryClientParamsRequest, + } as QueryClientParamsRequest; + return message; + }, +}; + +const baseQueryClientParamsResponse: object = {}; + +export const QueryClientParamsResponse = { + encode( + message: QueryClientParamsResponse, + writer: Writer = Writer.create() + ): Writer { + if (message.params !== undefined) { + Params.encode(message.params, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryClientParamsResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryClientParamsResponse, + } as QueryClientParamsResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.params = Params.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryClientParamsResponse { + const message = { + ...baseQueryClientParamsResponse, + } as QueryClientParamsResponse; + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromJSON(object.params); + } else { + message.params = undefined; + } + return message; + }, + + toJSON(message: QueryClientParamsResponse): unknown { + const obj: any = {}; + message.params !== undefined && + (obj.params = message.params ? Params.toJSON(message.params) : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryClientParamsResponse { + const message = { + ...baseQueryClientParamsResponse, + } as QueryClientParamsResponse; + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromPartial(object.params); + } else { + message.params = undefined; + } + return message; + }, +}; + +const baseQueryUpgradedClientStateRequest: object = {}; + +export const QueryUpgradedClientStateRequest = { + encode( + _: QueryUpgradedClientStateRequest, + writer: Writer = Writer.create() + ): Writer { + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryUpgradedClientStateRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryUpgradedClientStateRequest, + } as QueryUpgradedClientStateRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): QueryUpgradedClientStateRequest { + const message = { + ...baseQueryUpgradedClientStateRequest, + } as QueryUpgradedClientStateRequest; + return message; + }, + + toJSON(_: QueryUpgradedClientStateRequest): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial( + _: DeepPartial + ): QueryUpgradedClientStateRequest { + const message = { + ...baseQueryUpgradedClientStateRequest, + } as QueryUpgradedClientStateRequest; + return message; + }, +}; + +const baseQueryUpgradedClientStateResponse: object = {}; + +export const QueryUpgradedClientStateResponse = { + encode( + message: QueryUpgradedClientStateResponse, + writer: Writer = Writer.create() + ): Writer { + if (message.upgradedClientState !== undefined) { + Any.encode( + message.upgradedClientState, + writer.uint32(10).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryUpgradedClientStateResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryUpgradedClientStateResponse, + } as QueryUpgradedClientStateResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.upgradedClientState = Any.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryUpgradedClientStateResponse { + const message = { + ...baseQueryUpgradedClientStateResponse, + } as QueryUpgradedClientStateResponse; + if ( + object.upgradedClientState !== undefined && + object.upgradedClientState !== null + ) { + message.upgradedClientState = Any.fromJSON(object.upgradedClientState); + } else { + message.upgradedClientState = undefined; + } + return message; + }, + + toJSON(message: QueryUpgradedClientStateResponse): unknown { + const obj: any = {}; + message.upgradedClientState !== undefined && + (obj.upgradedClientState = message.upgradedClientState + ? Any.toJSON(message.upgradedClientState) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryUpgradedClientStateResponse { + const message = { + ...baseQueryUpgradedClientStateResponse, + } as QueryUpgradedClientStateResponse; + if ( + object.upgradedClientState !== undefined && + object.upgradedClientState !== null + ) { + message.upgradedClientState = Any.fromPartial(object.upgradedClientState); + } else { + message.upgradedClientState = undefined; + } + return message; + }, +}; + +const baseQueryUpgradedConsensusStateRequest: object = {}; + +export const QueryUpgradedConsensusStateRequest = { + encode( + _: QueryUpgradedConsensusStateRequest, + writer: Writer = Writer.create() + ): Writer { + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryUpgradedConsensusStateRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryUpgradedConsensusStateRequest, + } as QueryUpgradedConsensusStateRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): QueryUpgradedConsensusStateRequest { + const message = { + ...baseQueryUpgradedConsensusStateRequest, + } as QueryUpgradedConsensusStateRequest; + return message; + }, + + toJSON(_: QueryUpgradedConsensusStateRequest): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial( + _: DeepPartial + ): QueryUpgradedConsensusStateRequest { + const message = { + ...baseQueryUpgradedConsensusStateRequest, + } as QueryUpgradedConsensusStateRequest; + return message; + }, +}; + +const baseQueryUpgradedConsensusStateResponse: object = {}; + +export const QueryUpgradedConsensusStateResponse = { + encode( + message: QueryUpgradedConsensusStateResponse, + writer: Writer = Writer.create() + ): Writer { + if (message.upgradedConsensusState !== undefined) { + Any.encode( + message.upgradedConsensusState, + writer.uint32(10).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryUpgradedConsensusStateResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryUpgradedConsensusStateResponse, + } as QueryUpgradedConsensusStateResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.upgradedConsensusState = Any.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryUpgradedConsensusStateResponse { + const message = { + ...baseQueryUpgradedConsensusStateResponse, + } as QueryUpgradedConsensusStateResponse; + if ( + object.upgradedConsensusState !== undefined && + object.upgradedConsensusState !== null + ) { + message.upgradedConsensusState = Any.fromJSON( + object.upgradedConsensusState + ); + } else { + message.upgradedConsensusState = undefined; + } + return message; + }, + + toJSON(message: QueryUpgradedConsensusStateResponse): unknown { + const obj: any = {}; + message.upgradedConsensusState !== undefined && + (obj.upgradedConsensusState = message.upgradedConsensusState + ? Any.toJSON(message.upgradedConsensusState) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryUpgradedConsensusStateResponse { + const message = { + ...baseQueryUpgradedConsensusStateResponse, + } as QueryUpgradedConsensusStateResponse; + if ( + object.upgradedConsensusState !== undefined && + object.upgradedConsensusState !== null + ) { + message.upgradedConsensusState = Any.fromPartial( + object.upgradedConsensusState + ); + } else { + message.upgradedConsensusState = undefined; + } + return message; + }, +}; + +/** Query provides defines the gRPC querier service */ +export interface Query { + /** ClientState queries an IBC light client. */ + ClientState( + request: QueryClientStateRequest + ): Promise; + /** ClientStates queries all the IBC light clients of a chain. */ + ClientStates( + request: QueryClientStatesRequest + ): Promise; + /** + * ConsensusState queries a consensus state associated with a client state at + * a given height. + */ + ConsensusState( + request: QueryConsensusStateRequest + ): Promise; + /** + * ConsensusStates queries all the consensus state associated with a given + * client. + */ + ConsensusStates( + request: QueryConsensusStatesRequest + ): Promise; + /** ConsensusStateHeights queries the height of every consensus states associated with a given client. */ + ConsensusStateHeights( + request: QueryConsensusStateHeightsRequest + ): Promise; + /** Status queries the status of an IBC client. */ + ClientStatus( + request: QueryClientStatusRequest + ): Promise; + /** ClientParams queries all parameters of the ibc client. */ + ClientParams( + request: QueryClientParamsRequest + ): Promise; + /** UpgradedClientState queries an Upgraded IBC light client. */ + UpgradedClientState( + request: QueryUpgradedClientStateRequest + ): Promise; + /** UpgradedConsensusState queries an Upgraded IBC consensus state. */ + UpgradedConsensusState( + request: QueryUpgradedConsensusStateRequest + ): Promise; +} + +export class QueryClientImpl implements Query { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + } + ClientState( + request: QueryClientStateRequest + ): Promise { + const data = QueryClientStateRequest.encode(request).finish(); + const promise = this.rpc.request( + "ibc.core.client.v1.Query", + "ClientState", + data + ); + return promise.then((data) => + QueryClientStateResponse.decode(new Reader(data)) + ); + } + + ClientStates( + request: QueryClientStatesRequest + ): Promise { + const data = QueryClientStatesRequest.encode(request).finish(); + const promise = this.rpc.request( + "ibc.core.client.v1.Query", + "ClientStates", + data + ); + return promise.then((data) => + QueryClientStatesResponse.decode(new Reader(data)) + ); + } + + ConsensusState( + request: QueryConsensusStateRequest + ): Promise { + const data = QueryConsensusStateRequest.encode(request).finish(); + const promise = this.rpc.request( + "ibc.core.client.v1.Query", + "ConsensusState", + data + ); + return promise.then((data) => + QueryConsensusStateResponse.decode(new Reader(data)) + ); + } + + ConsensusStates( + request: QueryConsensusStatesRequest + ): Promise { + const data = QueryConsensusStatesRequest.encode(request).finish(); + const promise = this.rpc.request( + "ibc.core.client.v1.Query", + "ConsensusStates", + data + ); + return promise.then((data) => + QueryConsensusStatesResponse.decode(new Reader(data)) + ); + } + + ConsensusStateHeights( + request: QueryConsensusStateHeightsRequest + ): Promise { + const data = QueryConsensusStateHeightsRequest.encode(request).finish(); + const promise = this.rpc.request( + "ibc.core.client.v1.Query", + "ConsensusStateHeights", + data + ); + return promise.then((data) => + QueryConsensusStateHeightsResponse.decode(new Reader(data)) + ); + } + + ClientStatus( + request: QueryClientStatusRequest + ): Promise { + const data = QueryClientStatusRequest.encode(request).finish(); + const promise = this.rpc.request( + "ibc.core.client.v1.Query", + "ClientStatus", + data + ); + return promise.then((data) => + QueryClientStatusResponse.decode(new Reader(data)) + ); + } + + ClientParams( + request: QueryClientParamsRequest + ): Promise { + const data = QueryClientParamsRequest.encode(request).finish(); + const promise = this.rpc.request( + "ibc.core.client.v1.Query", + "ClientParams", + data + ); + return promise.then((data) => + QueryClientParamsResponse.decode(new Reader(data)) + ); + } + + UpgradedClientState( + request: QueryUpgradedClientStateRequest + ): Promise { + const data = QueryUpgradedClientStateRequest.encode(request).finish(); + const promise = this.rpc.request( + "ibc.core.client.v1.Query", + "UpgradedClientState", + data + ); + return promise.then((data) => + QueryUpgradedClientStateResponse.decode(new Reader(data)) + ); + } + + UpgradedConsensusState( + request: QueryUpgradedConsensusStateRequest + ): Promise { + const data = QueryUpgradedConsensusStateRequest.encode(request).finish(); + const promise = this.rpc.request( + "ibc.core.client.v1.Query", + "UpgradedConsensusState", + data + ); + return promise.then((data) => + QueryUpgradedConsensusStateResponse.decode(new Reader(data)) + ); + } +} + +interface Rpc { + request( + service: string, + method: string, + data: Uint8Array + ): Promise; +} + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/ibc.core.client.v1/types/ibc/core/client/v1/tx.ts b/ts-client/ibc.core.client.v1/types/ibc/core/client/v1/tx.ts new file mode 100644 index 00000000..0420793f --- /dev/null +++ b/ts-client/ibc.core.client.v1/types/ibc/core/client/v1/tx.ts @@ -0,0 +1,847 @@ +/* eslint-disable */ +import { Reader, Writer } from "protobufjs/minimal"; +import { Any } from "../../../../google/protobuf/any"; + +export const protobufPackage = "ibc.core.client.v1"; + +/** MsgCreateClient defines a message to create an IBC client */ +export interface MsgCreateClient { + /** light client state */ + clientState: Any | undefined; + /** + * consensus state associated with the client that corresponds to a given + * height. + */ + consensusState: Any | undefined; + /** signer address */ + signer: string; +} + +/** MsgCreateClientResponse defines the Msg/CreateClient response type. */ +export interface MsgCreateClientResponse {} + +/** + * MsgUpdateClient defines an sdk.Msg to update a IBC client state using + * the given header. + */ +export interface MsgUpdateClient { + /** client unique identifier */ + clientId: string; + /** header to update the light client */ + header: Any | undefined; + /** signer address */ + signer: string; +} + +/** MsgUpdateClientResponse defines the Msg/UpdateClient response type. */ +export interface MsgUpdateClientResponse {} + +/** + * MsgUpgradeClient defines an sdk.Msg to upgrade an IBC client to a new client + * state + */ +export interface MsgUpgradeClient { + /** client unique identifier */ + clientId: string; + /** upgraded client state */ + clientState: Any | undefined; + /** + * upgraded consensus state, only contains enough information to serve as a + * basis of trust in update logic + */ + consensusState: Any | undefined; + /** proof that old chain committed to new client */ + proofUpgradeClient: Uint8Array; + /** proof that old chain committed to new consensus state */ + proofUpgradeConsensusState: Uint8Array; + /** signer address */ + signer: string; +} + +/** MsgUpgradeClientResponse defines the Msg/UpgradeClient response type. */ +export interface MsgUpgradeClientResponse {} + +/** + * MsgSubmitMisbehaviour defines an sdk.Msg type that submits Evidence for + * light client misbehaviour. + */ +export interface MsgSubmitMisbehaviour { + /** client unique identifier */ + clientId: string; + /** misbehaviour used for freezing the light client */ + misbehaviour: Any | undefined; + /** signer address */ + signer: string; +} + +/** + * MsgSubmitMisbehaviourResponse defines the Msg/SubmitMisbehaviour response + * type. + */ +export interface MsgSubmitMisbehaviourResponse {} + +const baseMsgCreateClient: object = { signer: "" }; + +export const MsgCreateClient = { + encode(message: MsgCreateClient, writer: Writer = Writer.create()): Writer { + if (message.clientState !== undefined) { + Any.encode(message.clientState, writer.uint32(10).fork()).ldelim(); + } + if (message.consensusState !== undefined) { + Any.encode(message.consensusState, writer.uint32(18).fork()).ldelim(); + } + if (message.signer !== "") { + writer.uint32(26).string(message.signer); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MsgCreateClient { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgCreateClient } as MsgCreateClient; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.clientState = Any.decode(reader, reader.uint32()); + break; + case 2: + message.consensusState = Any.decode(reader, reader.uint32()); + break; + case 3: + message.signer = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgCreateClient { + const message = { ...baseMsgCreateClient } as MsgCreateClient; + if (object.clientState !== undefined && object.clientState !== null) { + message.clientState = Any.fromJSON(object.clientState); + } else { + message.clientState = undefined; + } + if (object.consensusState !== undefined && object.consensusState !== null) { + message.consensusState = Any.fromJSON(object.consensusState); + } else { + message.consensusState = undefined; + } + if (object.signer !== undefined && object.signer !== null) { + message.signer = String(object.signer); + } else { + message.signer = ""; + } + return message; + }, + + toJSON(message: MsgCreateClient): unknown { + const obj: any = {}; + message.clientState !== undefined && + (obj.clientState = message.clientState + ? Any.toJSON(message.clientState) + : undefined); + message.consensusState !== undefined && + (obj.consensusState = message.consensusState + ? Any.toJSON(message.consensusState) + : undefined); + message.signer !== undefined && (obj.signer = message.signer); + return obj; + }, + + fromPartial(object: DeepPartial): MsgCreateClient { + const message = { ...baseMsgCreateClient } as MsgCreateClient; + if (object.clientState !== undefined && object.clientState !== null) { + message.clientState = Any.fromPartial(object.clientState); + } else { + message.clientState = undefined; + } + if (object.consensusState !== undefined && object.consensusState !== null) { + message.consensusState = Any.fromPartial(object.consensusState); + } else { + message.consensusState = undefined; + } + if (object.signer !== undefined && object.signer !== null) { + message.signer = object.signer; + } else { + message.signer = ""; + } + return message; + }, +}; + +const baseMsgCreateClientResponse: object = {}; + +export const MsgCreateClientResponse = { + encode(_: MsgCreateClientResponse, writer: Writer = Writer.create()): Writer { + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MsgCreateClientResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseMsgCreateClientResponse, + } as MsgCreateClientResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): MsgCreateClientResponse { + const message = { + ...baseMsgCreateClientResponse, + } as MsgCreateClientResponse; + return message; + }, + + toJSON(_: MsgCreateClientResponse): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial( + _: DeepPartial + ): MsgCreateClientResponse { + const message = { + ...baseMsgCreateClientResponse, + } as MsgCreateClientResponse; + return message; + }, +}; + +const baseMsgUpdateClient: object = { clientId: "", signer: "" }; + +export const MsgUpdateClient = { + encode(message: MsgUpdateClient, writer: Writer = Writer.create()): Writer { + if (message.clientId !== "") { + writer.uint32(10).string(message.clientId); + } + if (message.header !== undefined) { + Any.encode(message.header, writer.uint32(18).fork()).ldelim(); + } + if (message.signer !== "") { + writer.uint32(26).string(message.signer); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MsgUpdateClient { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgUpdateClient } as MsgUpdateClient; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.clientId = reader.string(); + break; + case 2: + message.header = Any.decode(reader, reader.uint32()); + break; + case 3: + message.signer = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgUpdateClient { + const message = { ...baseMsgUpdateClient } as MsgUpdateClient; + if (object.clientId !== undefined && object.clientId !== null) { + message.clientId = String(object.clientId); + } else { + message.clientId = ""; + } + if (object.header !== undefined && object.header !== null) { + message.header = Any.fromJSON(object.header); + } else { + message.header = undefined; + } + if (object.signer !== undefined && object.signer !== null) { + message.signer = String(object.signer); + } else { + message.signer = ""; + } + return message; + }, + + toJSON(message: MsgUpdateClient): unknown { + const obj: any = {}; + message.clientId !== undefined && (obj.clientId = message.clientId); + message.header !== undefined && + (obj.header = message.header ? Any.toJSON(message.header) : undefined); + message.signer !== undefined && (obj.signer = message.signer); + return obj; + }, + + fromPartial(object: DeepPartial): MsgUpdateClient { + const message = { ...baseMsgUpdateClient } as MsgUpdateClient; + if (object.clientId !== undefined && object.clientId !== null) { + message.clientId = object.clientId; + } else { + message.clientId = ""; + } + if (object.header !== undefined && object.header !== null) { + message.header = Any.fromPartial(object.header); + } else { + message.header = undefined; + } + if (object.signer !== undefined && object.signer !== null) { + message.signer = object.signer; + } else { + message.signer = ""; + } + return message; + }, +}; + +const baseMsgUpdateClientResponse: object = {}; + +export const MsgUpdateClientResponse = { + encode(_: MsgUpdateClientResponse, writer: Writer = Writer.create()): Writer { + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MsgUpdateClientResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseMsgUpdateClientResponse, + } as MsgUpdateClientResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): MsgUpdateClientResponse { + const message = { + ...baseMsgUpdateClientResponse, + } as MsgUpdateClientResponse; + return message; + }, + + toJSON(_: MsgUpdateClientResponse): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial( + _: DeepPartial + ): MsgUpdateClientResponse { + const message = { + ...baseMsgUpdateClientResponse, + } as MsgUpdateClientResponse; + return message; + }, +}; + +const baseMsgUpgradeClient: object = { clientId: "", signer: "" }; + +export const MsgUpgradeClient = { + encode(message: MsgUpgradeClient, writer: Writer = Writer.create()): Writer { + if (message.clientId !== "") { + writer.uint32(10).string(message.clientId); + } + if (message.clientState !== undefined) { + Any.encode(message.clientState, writer.uint32(18).fork()).ldelim(); + } + if (message.consensusState !== undefined) { + Any.encode(message.consensusState, writer.uint32(26).fork()).ldelim(); + } + if (message.proofUpgradeClient.length !== 0) { + writer.uint32(34).bytes(message.proofUpgradeClient); + } + if (message.proofUpgradeConsensusState.length !== 0) { + writer.uint32(42).bytes(message.proofUpgradeConsensusState); + } + if (message.signer !== "") { + writer.uint32(50).string(message.signer); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MsgUpgradeClient { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgUpgradeClient } as MsgUpgradeClient; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.clientId = reader.string(); + break; + case 2: + message.clientState = Any.decode(reader, reader.uint32()); + break; + case 3: + message.consensusState = Any.decode(reader, reader.uint32()); + break; + case 4: + message.proofUpgradeClient = reader.bytes(); + break; + case 5: + message.proofUpgradeConsensusState = reader.bytes(); + break; + case 6: + message.signer = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgUpgradeClient { + const message = { ...baseMsgUpgradeClient } as MsgUpgradeClient; + if (object.clientId !== undefined && object.clientId !== null) { + message.clientId = String(object.clientId); + } else { + message.clientId = ""; + } + if (object.clientState !== undefined && object.clientState !== null) { + message.clientState = Any.fromJSON(object.clientState); + } else { + message.clientState = undefined; + } + if (object.consensusState !== undefined && object.consensusState !== null) { + message.consensusState = Any.fromJSON(object.consensusState); + } else { + message.consensusState = undefined; + } + if ( + object.proofUpgradeClient !== undefined && + object.proofUpgradeClient !== null + ) { + message.proofUpgradeClient = bytesFromBase64(object.proofUpgradeClient); + } + if ( + object.proofUpgradeConsensusState !== undefined && + object.proofUpgradeConsensusState !== null + ) { + message.proofUpgradeConsensusState = bytesFromBase64( + object.proofUpgradeConsensusState + ); + } + if (object.signer !== undefined && object.signer !== null) { + message.signer = String(object.signer); + } else { + message.signer = ""; + } + return message; + }, + + toJSON(message: MsgUpgradeClient): unknown { + const obj: any = {}; + message.clientId !== undefined && (obj.clientId = message.clientId); + message.clientState !== undefined && + (obj.clientState = message.clientState + ? Any.toJSON(message.clientState) + : undefined); + message.consensusState !== undefined && + (obj.consensusState = message.consensusState + ? Any.toJSON(message.consensusState) + : undefined); + message.proofUpgradeClient !== undefined && + (obj.proofUpgradeClient = base64FromBytes( + message.proofUpgradeClient !== undefined + ? message.proofUpgradeClient + : new Uint8Array() + )); + message.proofUpgradeConsensusState !== undefined && + (obj.proofUpgradeConsensusState = base64FromBytes( + message.proofUpgradeConsensusState !== undefined + ? message.proofUpgradeConsensusState + : new Uint8Array() + )); + message.signer !== undefined && (obj.signer = message.signer); + return obj; + }, + + fromPartial(object: DeepPartial): MsgUpgradeClient { + const message = { ...baseMsgUpgradeClient } as MsgUpgradeClient; + if (object.clientId !== undefined && object.clientId !== null) { + message.clientId = object.clientId; + } else { + message.clientId = ""; + } + if (object.clientState !== undefined && object.clientState !== null) { + message.clientState = Any.fromPartial(object.clientState); + } else { + message.clientState = undefined; + } + if (object.consensusState !== undefined && object.consensusState !== null) { + message.consensusState = Any.fromPartial(object.consensusState); + } else { + message.consensusState = undefined; + } + if ( + object.proofUpgradeClient !== undefined && + object.proofUpgradeClient !== null + ) { + message.proofUpgradeClient = object.proofUpgradeClient; + } else { + message.proofUpgradeClient = new Uint8Array(); + } + if ( + object.proofUpgradeConsensusState !== undefined && + object.proofUpgradeConsensusState !== null + ) { + message.proofUpgradeConsensusState = object.proofUpgradeConsensusState; + } else { + message.proofUpgradeConsensusState = new Uint8Array(); + } + if (object.signer !== undefined && object.signer !== null) { + message.signer = object.signer; + } else { + message.signer = ""; + } + return message; + }, +}; + +const baseMsgUpgradeClientResponse: object = {}; + +export const MsgUpgradeClientResponse = { + encode( + _: MsgUpgradeClientResponse, + writer: Writer = Writer.create() + ): Writer { + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): MsgUpgradeClientResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseMsgUpgradeClientResponse, + } as MsgUpgradeClientResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): MsgUpgradeClientResponse { + const message = { + ...baseMsgUpgradeClientResponse, + } as MsgUpgradeClientResponse; + return message; + }, + + toJSON(_: MsgUpgradeClientResponse): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial( + _: DeepPartial + ): MsgUpgradeClientResponse { + const message = { + ...baseMsgUpgradeClientResponse, + } as MsgUpgradeClientResponse; + return message; + }, +}; + +const baseMsgSubmitMisbehaviour: object = { clientId: "", signer: "" }; + +export const MsgSubmitMisbehaviour = { + encode( + message: MsgSubmitMisbehaviour, + writer: Writer = Writer.create() + ): Writer { + if (message.clientId !== "") { + writer.uint32(10).string(message.clientId); + } + if (message.misbehaviour !== undefined) { + Any.encode(message.misbehaviour, writer.uint32(18).fork()).ldelim(); + } + if (message.signer !== "") { + writer.uint32(26).string(message.signer); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MsgSubmitMisbehaviour { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgSubmitMisbehaviour } as MsgSubmitMisbehaviour; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.clientId = reader.string(); + break; + case 2: + message.misbehaviour = Any.decode(reader, reader.uint32()); + break; + case 3: + message.signer = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgSubmitMisbehaviour { + const message = { ...baseMsgSubmitMisbehaviour } as MsgSubmitMisbehaviour; + if (object.clientId !== undefined && object.clientId !== null) { + message.clientId = String(object.clientId); + } else { + message.clientId = ""; + } + if (object.misbehaviour !== undefined && object.misbehaviour !== null) { + message.misbehaviour = Any.fromJSON(object.misbehaviour); + } else { + message.misbehaviour = undefined; + } + if (object.signer !== undefined && object.signer !== null) { + message.signer = String(object.signer); + } else { + message.signer = ""; + } + return message; + }, + + toJSON(message: MsgSubmitMisbehaviour): unknown { + const obj: any = {}; + message.clientId !== undefined && (obj.clientId = message.clientId); + message.misbehaviour !== undefined && + (obj.misbehaviour = message.misbehaviour + ? Any.toJSON(message.misbehaviour) + : undefined); + message.signer !== undefined && (obj.signer = message.signer); + return obj; + }, + + fromPartial( + object: DeepPartial + ): MsgSubmitMisbehaviour { + const message = { ...baseMsgSubmitMisbehaviour } as MsgSubmitMisbehaviour; + if (object.clientId !== undefined && object.clientId !== null) { + message.clientId = object.clientId; + } else { + message.clientId = ""; + } + if (object.misbehaviour !== undefined && object.misbehaviour !== null) { + message.misbehaviour = Any.fromPartial(object.misbehaviour); + } else { + message.misbehaviour = undefined; + } + if (object.signer !== undefined && object.signer !== null) { + message.signer = object.signer; + } else { + message.signer = ""; + } + return message; + }, +}; + +const baseMsgSubmitMisbehaviourResponse: object = {}; + +export const MsgSubmitMisbehaviourResponse = { + encode( + _: MsgSubmitMisbehaviourResponse, + writer: Writer = Writer.create() + ): Writer { + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): MsgSubmitMisbehaviourResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseMsgSubmitMisbehaviourResponse, + } as MsgSubmitMisbehaviourResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): MsgSubmitMisbehaviourResponse { + const message = { + ...baseMsgSubmitMisbehaviourResponse, + } as MsgSubmitMisbehaviourResponse; + return message; + }, + + toJSON(_: MsgSubmitMisbehaviourResponse): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial( + _: DeepPartial + ): MsgSubmitMisbehaviourResponse { + const message = { + ...baseMsgSubmitMisbehaviourResponse, + } as MsgSubmitMisbehaviourResponse; + return message; + }, +}; + +/** Msg defines the ibc/client Msg service. */ +export interface Msg { + /** CreateClient defines a rpc handler method for MsgCreateClient. */ + CreateClient(request: MsgCreateClient): Promise; + /** UpdateClient defines a rpc handler method for MsgUpdateClient. */ + UpdateClient(request: MsgUpdateClient): Promise; + /** UpgradeClient defines a rpc handler method for MsgUpgradeClient. */ + UpgradeClient(request: MsgUpgradeClient): Promise; + /** SubmitMisbehaviour defines a rpc handler method for MsgSubmitMisbehaviour. */ + SubmitMisbehaviour( + request: MsgSubmitMisbehaviour + ): Promise; +} + +export class MsgClientImpl implements Msg { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + } + CreateClient(request: MsgCreateClient): Promise { + const data = MsgCreateClient.encode(request).finish(); + const promise = this.rpc.request( + "ibc.core.client.v1.Msg", + "CreateClient", + data + ); + return promise.then((data) => + MsgCreateClientResponse.decode(new Reader(data)) + ); + } + + UpdateClient(request: MsgUpdateClient): Promise { + const data = MsgUpdateClient.encode(request).finish(); + const promise = this.rpc.request( + "ibc.core.client.v1.Msg", + "UpdateClient", + data + ); + return promise.then((data) => + MsgUpdateClientResponse.decode(new Reader(data)) + ); + } + + UpgradeClient(request: MsgUpgradeClient): Promise { + const data = MsgUpgradeClient.encode(request).finish(); + const promise = this.rpc.request( + "ibc.core.client.v1.Msg", + "UpgradeClient", + data + ); + return promise.then((data) => + MsgUpgradeClientResponse.decode(new Reader(data)) + ); + } + + SubmitMisbehaviour( + request: MsgSubmitMisbehaviour + ): Promise { + const data = MsgSubmitMisbehaviour.encode(request).finish(); + const promise = this.rpc.request( + "ibc.core.client.v1.Msg", + "SubmitMisbehaviour", + data + ); + return promise.then((data) => + MsgSubmitMisbehaviourResponse.decode(new Reader(data)) + ); + } +} + +interface Rpc { + request( + service: string, + method: string, + data: Uint8Array + ): Promise; +} + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/ibc.core.connection.v1/index.ts b/ts-client/ibc.core.connection.v1/index.ts new file mode 100755 index 00000000..c9dfa159 --- /dev/null +++ b/ts-client/ibc.core.connection.v1/index.ts @@ -0,0 +1,6 @@ +import Module from './module'; +import { txClient, queryClient, registry } from './module'; +import { msgTypes } from './registry'; + +export * from "./types"; +export { Module, msgTypes, txClient, queryClient, registry }; diff --git a/ts-client/ibc.core.connection.v1/module.ts b/ts-client/ibc.core.connection.v1/module.ts new file mode 100755 index 00000000..17fa611c --- /dev/null +++ b/ts-client/ibc.core.connection.v1/module.ts @@ -0,0 +1,66 @@ +// Generated by Ignite ignite.com/cli + +import { StdFee } from "@cosmjs/launchpad"; +import { SigningStargateClient, DeliverTxResponse } from "@cosmjs/stargate"; +import { EncodeObject, GeneratedType, OfflineSigner, Registry } from "@cosmjs/proto-signing"; +import { msgTypes } from './registry'; +import { IgniteClient } from "../client" +import { MissingWalletError } from "../helpers" +import { Api } from "./rest"; + + +export { }; + + + +export const registry = new Registry(msgTypes); + +const defaultFee = { + amount: [], + gas: "200000", +}; + +interface TxClientOptions { + addr: string + prefix: string + signer?: OfflineSigner +} + +export const txClient = ({ signer, prefix, addr }: TxClientOptions = { addr: "http://localhost:26657", prefix: "cosmos" }) => { + + return { + + + } +}; + +interface QueryClientOptions { + addr: string +} + +export const queryClient = ({ addr: addr }: QueryClientOptions = { addr: "http://localhost:1317" }) => { + return new Api({ baseUrl: addr }); +}; + +class SDKModule { + public query: ReturnType; + public tx: ReturnType; + + public registry: Array<[string, GeneratedType]>; + + constructor(client: IgniteClient) { + + this.query = queryClient({ addr: client.env.apiURL }); + this.tx = txClient({ signer: client.signer, addr: client.env.rpcURL, prefix: client.env.prefix ?? "cosmos" }); + } +}; + +const Module = (test: IgniteClient) => { + return { + module: { + IbcCoreConnectionV1: new SDKModule(test) + }, + registry: msgTypes + } +} +export default Module; \ No newline at end of file diff --git a/ts-client/ibc.core.connection.v1/registry.ts b/ts-client/ibc.core.connection.v1/registry.ts new file mode 100755 index 00000000..26157e4f --- /dev/null +++ b/ts-client/ibc.core.connection.v1/registry.ts @@ -0,0 +1,7 @@ +import { GeneratedType } from "@cosmjs/proto-signing"; + +const msgTypes: Array<[string, GeneratedType]> = [ + +]; + +export { msgTypes } \ No newline at end of file diff --git a/ts-client/ibc.core.connection.v1/rest.ts b/ts-client/ibc.core.connection.v1/rest.ts new file mode 100644 index 00000000..5affb814 --- /dev/null +++ b/ts-client/ibc.core.connection.v1/rest.ts @@ -0,0 +1,930 @@ +/* eslint-disable */ +/* tslint:disable */ +/* + * --------------------------------------------------------------- + * ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ## + * ## ## + * ## AUTHOR: acacode ## + * ## SOURCE: https://github.com/acacode/swagger-typescript-api ## + * --------------------------------------------------------------- + */ + +/** +* `Any` contains an arbitrary serialized protocol buffer message along with a +URL that describes the type of the serialized message. + +Protobuf library provides support to pack/unpack Any values in the form +of utility functions or additional generated methods of the Any type. + +Example 1: Pack and unpack a message in C++. + + Foo foo = ...; + Any any; + any.PackFrom(foo); + ... + if (any.UnpackTo(&foo)) { + ... + } + +Example 2: Pack and unpack a message in Java. + + Foo foo = ...; + Any any = Any.pack(foo); + ... + if (any.is(Foo.class)) { + foo = any.unpack(Foo.class); + } + + Example 3: Pack and unpack a message in Python. + + foo = Foo(...) + any = Any() + any.Pack(foo) + ... + if any.Is(Foo.DESCRIPTOR): + any.Unpack(foo) + ... + + Example 4: Pack and unpack a message in Go + + foo := &pb.Foo{...} + any, err := anypb.New(foo) + if err != nil { + ... + } + ... + foo := &pb.Foo{} + if err := any.UnmarshalTo(foo); err != nil { + ... + } + +The pack methods provided by protobuf library will by default use +'type.googleapis.com/full.type.name' as the type URL and the unpack +methods only use the fully qualified type name after the last '/' +in the type URL, for example "foo.bar.com/x/y.z" will yield type +name "y.z". + + +JSON +==== +The JSON representation of an `Any` value uses the regular +representation of the deserialized, embedded message, with an +additional field `@type` which contains the type URL. Example: + + package google.profile; + message Person { + string first_name = 1; + string last_name = 2; + } + + { + "@type": "type.googleapis.com/google.profile.Person", + "firstName": , + "lastName": + } + +If the embedded message type is well-known and has a custom JSON +representation, that representation will be embedded adding a field +`value` which holds the custom JSON in addition to the `@type` +field. Example (for message [google.protobuf.Duration][]): + + { + "@type": "type.googleapis.com/google.protobuf.Duration", + "value": "1.212s" + } +*/ +export interface ProtobufAny { + /** + * A URL/resource name that uniquely identifies the type of the serialized + * protocol buffer message. This string must contain at least + * one "/" character. The last segment of the URL's path must represent + * the fully qualified name of the type (as in + * `path/google.protobuf.Duration`). The name should be in a canonical form + * (e.g., leading "." is not accepted). + * + * In practice, teams usually precompile into the binary all types that they + * expect it to use in the context of Any. However, for URLs which use the + * scheme `http`, `https`, or no scheme, one can optionally set up a type + * server that maps type URLs to message definitions as follows: + * + * * If no scheme is provided, `https` is assumed. + * * An HTTP GET on the URL must yield a [google.protobuf.Type][] + * value in binary format, or produce an error. + * * Applications are allowed to cache lookup results based on the + * URL, or have them precompiled into a binary to avoid any + * lookup. Therefore, binary compatibility needs to be preserved + * on changes to types. (Use versioned type names to manage + * breaking changes.) + * + * Note: this functionality is not currently available in the official + * protobuf release, and it is not used for type URLs beginning with + * type.googleapis.com. + * + * Schemes other than `http`, `https` (or the empty scheme) might be + * used with implementation specific semantics. + */ + "@type"?: string; +} + +export interface RpcStatus { + /** @format int32 */ + code?: number; + message?: string; + details?: ProtobufAny[]; +} + +/** +* ConnectionEnd defines a stateful object on a chain connected to another +separate one. +NOTE: there must only be 2 defined ConnectionEnds to establish +a connection between two chains. +*/ +export interface V1ConnectionEnd { + /** client associated with this connection. */ + client_id?: string; + + /** + * IBC version which can be utilised to determine encodings or protocols for + * channels or packets utilising this connection. + */ + versions?: V1Version[]; + + /** current state of the connection end. */ + state?: V1State; + + /** counterparty chain associated with this connection. */ + counterparty?: V1Counterparty; + + /** + * delay period that must pass before a consensus state can be used for + * packet-verification NOTE: delay period logic is only implemented by some + * clients. + * @format uint64 + */ + delay_period?: string; +} + +/** + * Counterparty defines the counterparty chain associated with a connection end. + */ +export interface V1Counterparty { + /** + * identifies the client on the counterparty chain associated with a given + * connection. + */ + client_id?: string; + + /** + * identifies the connection end on the counterparty chain associated with a + * given connection. + */ + connection_id?: string; + + /** commitment merkle prefix of the counterparty chain. */ + prefix?: V1MerklePrefix; +} + +/** +* Normally the RevisionHeight is incremented at each height while keeping +RevisionNumber the same. However some consensus algorithms may choose to +reset the height in certain conditions e.g. hard forks, state-machine +breaking changes In these cases, the RevisionNumber is incremented so that +height continues to be monitonically increasing even as the RevisionHeight +gets reset +*/ +export interface V1Height { + /** @format uint64 */ + revision_number?: string; + + /** @format uint64 */ + revision_height?: string; +} + +/** +* IdentifiedClientState defines a client state with an additional client +identifier field. +*/ +export interface V1IdentifiedClientState { + client_id?: string; + + /** + * `Any` contains an arbitrary serialized protocol buffer message along with a + * URL that describes the type of the serialized message. + * + * Protobuf library provides support to pack/unpack Any values in the form + * of utility functions or additional generated methods of the Any type. + * + * Example 1: Pack and unpack a message in C++. + * + * Foo foo = ...; + * Any any; + * any.PackFrom(foo); + * ... + * if (any.UnpackTo(&foo)) { + * ... + * } + * + * Example 2: Pack and unpack a message in Java. + * + * Foo foo = ...; + * Any any = Any.pack(foo); + * ... + * if (any.is(Foo.class)) { + * foo = any.unpack(Foo.class); + * } + * + * Example 3: Pack and unpack a message in Python. + * + * foo = Foo(...) + * any = Any() + * any.Pack(foo) + * ... + * if any.Is(Foo.DESCRIPTOR): + * any.Unpack(foo) + * ... + * + * Example 4: Pack and unpack a message in Go + * + * foo := &pb.Foo{...} + * any, err := anypb.New(foo) + * if err != nil { + * ... + * } + * ... + * foo := &pb.Foo{} + * if err := any.UnmarshalTo(foo); err != nil { + * ... + * } + * + * The pack methods provided by protobuf library will by default use + * 'type.googleapis.com/full.type.name' as the type URL and the unpack + * methods only use the fully qualified type name after the last '/' + * in the type URL, for example "foo.bar.com/x/y.z" will yield type + * name "y.z". + * + * + * JSON + * ==== + * The JSON representation of an `Any` value uses the regular + * representation of the deserialized, embedded message, with an + * additional field `@type` which contains the type URL. Example: + * + * package google.profile; + * message Person { + * string first_name = 1; + * string last_name = 2; + * } + * + * { + * "@type": "type.googleapis.com/google.profile.Person", + * "firstName": , + * "lastName": + * } + * + * If the embedded message type is well-known and has a custom JSON + * representation, that representation will be embedded adding a field + * `value` which holds the custom JSON in addition to the `@type` + * field. Example (for message [google.protobuf.Duration][]): + * + * { + * "@type": "type.googleapis.com/google.protobuf.Duration", + * "value": "1.212s" + * } + */ + client_state?: ProtobufAny; +} + +/** +* IdentifiedConnection defines a connection with additional connection +identifier field. +*/ +export interface V1IdentifiedConnection { + /** connection identifier. */ + id?: string; + + /** client associated with this connection. */ + client_id?: string; + versions?: V1Version[]; + + /** current state of the connection end. */ + state?: V1State; + + /** counterparty chain associated with this connection. */ + counterparty?: V1Counterparty; + + /** + * delay period associated with this connection. + * @format uint64 + */ + delay_period?: string; +} + +export interface V1MerklePrefix { + /** @format byte */ + key_prefix?: string; +} + +/** + * MsgConnectionOpenAckResponse defines the Msg/ConnectionOpenAck response type. + */ +export type V1MsgConnectionOpenAckResponse = object; + +/** +* MsgConnectionOpenConfirmResponse defines the Msg/ConnectionOpenConfirm +response type. +*/ +export type V1MsgConnectionOpenConfirmResponse = object; + +/** +* MsgConnectionOpenInitResponse defines the Msg/ConnectionOpenInit response +type. +*/ +export type V1MsgConnectionOpenInitResponse = object; + +/** + * MsgConnectionOpenTryResponse defines the Msg/ConnectionOpenTry response type. + */ +export type V1MsgConnectionOpenTryResponse = object; + +export interface V1QueryClientConnectionsResponse { + /** slice of all the connection paths associated with a client. */ + connection_paths?: string[]; + + /** @format byte */ + proof?: string; + + /** + * Normally the RevisionHeight is incremented at each height while keeping + * RevisionNumber the same. However some consensus algorithms may choose to + * reset the height in certain conditions e.g. hard forks, state-machine + * breaking changes In these cases, the RevisionNumber is incremented so that + * height continues to be monitonically increasing even as the RevisionHeight + * gets reset + */ + proof_height?: V1Height; +} + +export interface V1QueryConnectionClientStateResponse { + /** + * IdentifiedClientState defines a client state with an additional client + * identifier field. + */ + identified_client_state?: V1IdentifiedClientState; + + /** @format byte */ + proof?: string; + + /** + * Normally the RevisionHeight is incremented at each height while keeping + * RevisionNumber the same. However some consensus algorithms may choose to + * reset the height in certain conditions e.g. hard forks, state-machine + * breaking changes In these cases, the RevisionNumber is incremented so that + * height continues to be monitonically increasing even as the RevisionHeight + * gets reset + */ + proof_height?: V1Height; +} + +export interface V1QueryConnectionConsensusStateResponse { + /** + * `Any` contains an arbitrary serialized protocol buffer message along with a + * URL that describes the type of the serialized message. + * + * Protobuf library provides support to pack/unpack Any values in the form + * of utility functions or additional generated methods of the Any type. + * + * Example 1: Pack and unpack a message in C++. + * + * Foo foo = ...; + * Any any; + * any.PackFrom(foo); + * ... + * if (any.UnpackTo(&foo)) { + * ... + * } + * + * Example 2: Pack and unpack a message in Java. + * + * Foo foo = ...; + * Any any = Any.pack(foo); + * ... + * if (any.is(Foo.class)) { + * foo = any.unpack(Foo.class); + * } + * + * Example 3: Pack and unpack a message in Python. + * + * foo = Foo(...) + * any = Any() + * any.Pack(foo) + * ... + * if any.Is(Foo.DESCRIPTOR): + * any.Unpack(foo) + * ... + * + * Example 4: Pack and unpack a message in Go + * + * foo := &pb.Foo{...} + * any, err := anypb.New(foo) + * if err != nil { + * ... + * } + * ... + * foo := &pb.Foo{} + * if err := any.UnmarshalTo(foo); err != nil { + * ... + * } + * + * The pack methods provided by protobuf library will by default use + * 'type.googleapis.com/full.type.name' as the type URL and the unpack + * methods only use the fully qualified type name after the last '/' + * in the type URL, for example "foo.bar.com/x/y.z" will yield type + * name "y.z". + * + * + * JSON + * ==== + * The JSON representation of an `Any` value uses the regular + * representation of the deserialized, embedded message, with an + * additional field `@type` which contains the type URL. Example: + * + * package google.profile; + * message Person { + * string first_name = 1; + * string last_name = 2; + * } + * + * { + * "@type": "type.googleapis.com/google.profile.Person", + * "firstName": , + * "lastName": + * } + * + * If the embedded message type is well-known and has a custom JSON + * representation, that representation will be embedded adding a field + * `value` which holds the custom JSON in addition to the `@type` + * field. Example (for message [google.protobuf.Duration][]): + * + * { + * "@type": "type.googleapis.com/google.protobuf.Duration", + * "value": "1.212s" + * } + */ + consensus_state?: ProtobufAny; + client_id?: string; + + /** @format byte */ + proof?: string; + + /** + * Normally the RevisionHeight is incremented at each height while keeping + * RevisionNumber the same. However some consensus algorithms may choose to + * reset the height in certain conditions e.g. hard forks, state-machine + * breaking changes In these cases, the RevisionNumber is incremented so that + * height continues to be monitonically increasing even as the RevisionHeight + * gets reset + */ + proof_height?: V1Height; +} + +/** +* QueryConnectionResponse is the response type for the Query/Connection RPC +method. Besides the connection end, it includes a proof and the height from +which the proof was retrieved. +*/ +export interface V1QueryConnectionResponse { + /** + * ConnectionEnd defines a stateful object on a chain connected to another + * separate one. + * NOTE: there must only be 2 defined ConnectionEnds to establish + * a connection between two chains. + */ + connection?: V1ConnectionEnd; + + /** @format byte */ + proof?: string; + + /** + * Normally the RevisionHeight is incremented at each height while keeping + * RevisionNumber the same. However some consensus algorithms may choose to + * reset the height in certain conditions e.g. hard forks, state-machine + * breaking changes In these cases, the RevisionNumber is incremented so that + * height continues to be monitonically increasing even as the RevisionHeight + * gets reset + */ + proof_height?: V1Height; +} + +/** +* QueryConnectionsResponse is the response type for the Query/Connections RPC +method. +*/ +export interface V1QueryConnectionsResponse { + /** list of stored connections of the chain. */ + connections?: V1IdentifiedConnection[]; + + /** + * PageResponse is to be embedded in gRPC response messages where the + * corresponding request message has used PageRequest. + * + * message SomeResponse { + * repeated Bar results = 1; + * PageResponse page = 2; + * } + */ + pagination?: V1Beta1PageResponse; + + /** + * Normally the RevisionHeight is incremented at each height while keeping + * RevisionNumber the same. However some consensus algorithms may choose to + * reset the height in certain conditions e.g. hard forks, state-machine + * breaking changes In these cases, the RevisionNumber is incremented so that + * height continues to be monitonically increasing even as the RevisionHeight + * gets reset + */ + height?: V1Height; +} + +/** +* State defines if a connection is in one of the following states: +INIT, TRYOPEN, OPEN or UNINITIALIZED. + + - STATE_UNINITIALIZED_UNSPECIFIED: Default State + - STATE_INIT: A connection end has just started the opening handshake. + - STATE_TRYOPEN: A connection end has acknowledged the handshake step on the counterparty +chain. + - STATE_OPEN: A connection end has completed the handshake. +*/ +export enum V1State { + STATE_UNINITIALIZED_UNSPECIFIED = "STATE_UNINITIALIZED_UNSPECIFIED", + STATE_INIT = "STATE_INIT", + STATE_TRYOPEN = "STATE_TRYOPEN", + STATE_OPEN = "STATE_OPEN", +} + +/** +* Version defines the versioning scheme used to negotiate the IBC verison in +the connection handshake. +*/ +export interface V1Version { + identifier?: string; + features?: string[]; +} + +/** +* message SomeRequest { + Foo some_parameter = 1; + PageRequest pagination = 2; + } +*/ +export interface V1Beta1PageRequest { + /** + * key is a value returned in PageResponse.next_key to begin + * querying the next page most efficiently. Only one of offset or key + * should be set. + * @format byte + */ + key?: string; + + /** + * offset is a numeric offset that can be used when key is unavailable. + * It is less efficient than using key. Only one of offset or key should + * be set. + * @format uint64 + */ + offset?: string; + + /** + * limit is the total number of results to be returned in the result page. + * If left empty it will default to a value to be set by each app. + * @format uint64 + */ + limit?: string; + + /** + * count_total is set to true to indicate that the result set should include + * a count of the total number of items available for pagination in UIs. + * count_total is only respected when offset is used. It is ignored when key + * is set. + */ + count_total?: boolean; + + /** + * reverse is set to true if results are to be returned in the descending order. + * + * Since: cosmos-sdk 0.43 + */ + reverse?: boolean; +} + +/** +* PageResponse is to be embedded in gRPC response messages where the +corresponding request message has used PageRequest. + + message SomeResponse { + repeated Bar results = 1; + PageResponse page = 2; + } +*/ +export interface V1Beta1PageResponse { + /** @format byte */ + next_key?: string; + + /** @format uint64 */ + total?: string; +} + +export type QueryParamsType = Record; +export type ResponseFormat = keyof Omit; + +export interface FullRequestParams extends Omit { + /** set parameter to `true` for call `securityWorker` for this request */ + secure?: boolean; + /** request path */ + path: string; + /** content type of request body */ + type?: ContentType; + /** query params */ + query?: QueryParamsType; + /** format of response (i.e. response.json() -> format: "json") */ + format?: keyof Omit; + /** request body */ + body?: unknown; + /** base url */ + baseUrl?: string; + /** request cancellation token */ + cancelToken?: CancelToken; +} + +export type RequestParams = Omit; + +export interface ApiConfig { + baseUrl?: string; + baseApiParams?: Omit; + securityWorker?: (securityData: SecurityDataType) => RequestParams | void; +} + +export interface HttpResponse extends Response { + data: D; + error: E; +} + +type CancelToken = Symbol | string | number; + +export enum ContentType { + Json = "application/json", + FormData = "multipart/form-data", + UrlEncoded = "application/x-www-form-urlencoded", +} + +export class HttpClient { + public baseUrl: string = ""; + private securityData: SecurityDataType = null as any; + private securityWorker: null | ApiConfig["securityWorker"] = null; + private abortControllers = new Map(); + + private baseApiParams: RequestParams = { + credentials: "same-origin", + headers: {}, + redirect: "follow", + referrerPolicy: "no-referrer", + }; + + constructor(apiConfig: ApiConfig = {}) { + Object.assign(this, apiConfig); + } + + public setSecurityData = (data: SecurityDataType) => { + this.securityData = data; + }; + + private addQueryParam(query: QueryParamsType, key: string) { + const value = query[key]; + + return ( + encodeURIComponent(key) + + "=" + + encodeURIComponent(Array.isArray(value) ? value.join(",") : typeof value === "number" ? value : `${value}`) + ); + } + + protected toQueryString(rawQuery?: QueryParamsType): string { + const query = rawQuery || {}; + const keys = Object.keys(query).filter((key) => "undefined" !== typeof query[key]); + return keys + .map((key) => + typeof query[key] === "object" && !Array.isArray(query[key]) + ? this.toQueryString(query[key] as QueryParamsType) + : this.addQueryParam(query, key), + ) + .join("&"); + } + + protected addQueryParams(rawQuery?: QueryParamsType): string { + const queryString = this.toQueryString(rawQuery); + return queryString ? `?${queryString}` : ""; + } + + private contentFormatters: Record any> = { + [ContentType.Json]: (input: any) => + input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input, + [ContentType.FormData]: (input: any) => + Object.keys(input || {}).reduce((data, key) => { + data.append(key, input[key]); + return data; + }, new FormData()), + [ContentType.UrlEncoded]: (input: any) => this.toQueryString(input), + }; + + private mergeRequestParams(params1: RequestParams, params2?: RequestParams): RequestParams { + return { + ...this.baseApiParams, + ...params1, + ...(params2 || {}), + headers: { + ...(this.baseApiParams.headers || {}), + ...(params1.headers || {}), + ...((params2 && params2.headers) || {}), + }, + }; + } + + private createAbortSignal = (cancelToken: CancelToken): AbortSignal | undefined => { + if (this.abortControllers.has(cancelToken)) { + const abortController = this.abortControllers.get(cancelToken); + if (abortController) { + return abortController.signal; + } + return void 0; + } + + const abortController = new AbortController(); + this.abortControllers.set(cancelToken, abortController); + return abortController.signal; + }; + + public abortRequest = (cancelToken: CancelToken) => { + const abortController = this.abortControllers.get(cancelToken); + + if (abortController) { + abortController.abort(); + this.abortControllers.delete(cancelToken); + } + }; + + public request = ({ + body, + secure, + path, + type, + query, + format = "json", + baseUrl, + cancelToken, + ...params + }: FullRequestParams): Promise> => { + const secureParams = (secure && this.securityWorker && this.securityWorker(this.securityData)) || {}; + const requestParams = this.mergeRequestParams(params, secureParams); + const queryString = query && this.toQueryString(query); + const payloadFormatter = this.contentFormatters[type || ContentType.Json]; + + return fetch(`${baseUrl || this.baseUrl || ""}${path}${queryString ? `?${queryString}` : ""}`, { + ...requestParams, + headers: { + ...(type && type !== ContentType.FormData ? { "Content-Type": type } : {}), + ...(requestParams.headers || {}), + }, + signal: cancelToken ? this.createAbortSignal(cancelToken) : void 0, + body: typeof body === "undefined" || body === null ? null : payloadFormatter(body), + }).then(async (response) => { + const r = response as HttpResponse; + r.data = (null as unknown) as T; + r.error = (null as unknown) as E; + + const data = await response[format]() + .then((data) => { + if (r.ok) { + r.data = data; + } else { + r.error = data; + } + return r; + }) + .catch((e) => { + r.error = e; + return r; + }); + + if (cancelToken) { + this.abortControllers.delete(cancelToken); + } + + if (!response.ok) throw data; + return data; + }); + }; +} + +/** + * @title ibc/core/connection/v1/connection.proto + * @version version not set + */ +export class Api extends HttpClient { + /** + * No description + * + * @tags Query + * @name QueryClientConnections + * @summary ClientConnections queries the connection paths associated with a client +state. + * @request GET:/ibc/core/connection/v1/client_connections/{client_id} + */ + queryClientConnections = (client_id: string, params: RequestParams = {}) => + this.request({ + path: `/ibc/core/connection/v1/client_connections/${client_id}`, + method: "GET", + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Query + * @name QueryConnections + * @summary Connections queries all the IBC connections of a chain. + * @request GET:/ibc/core/connection/v1/connections + */ + queryConnections = ( + query?: { + "pagination.key"?: string; + "pagination.offset"?: string; + "pagination.limit"?: string; + "pagination.count_total"?: boolean; + "pagination.reverse"?: boolean; + }, + params: RequestParams = {}, + ) => + this.request({ + path: `/ibc/core/connection/v1/connections`, + method: "GET", + query: query, + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Query + * @name QueryConnection + * @summary Connection queries an IBC connection end. + * @request GET:/ibc/core/connection/v1/connections/{connection_id} + */ + queryConnection = (connection_id: string, params: RequestParams = {}) => + this.request({ + path: `/ibc/core/connection/v1/connections/${connection_id}`, + method: "GET", + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Query + * @name QueryConnectionClientState + * @summary ConnectionClientState queries the client state associated with the +connection. + * @request GET:/ibc/core/connection/v1/connections/{connection_id}/client_state + */ + queryConnectionClientState = (connection_id: string, params: RequestParams = {}) => + this.request({ + path: `/ibc/core/connection/v1/connections/${connection_id}/client_state`, + method: "GET", + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Query + * @name QueryConnectionConsensusState + * @summary ConnectionConsensusState queries the consensus state associated with the +connection. + * @request GET:/ibc/core/connection/v1/connections/{connection_id}/consensus_state/revision/{revision_number}/height/{revision_height} + */ + queryConnectionConsensusState = ( + connection_id: string, + revision_number: string, + revision_height: string, + params: RequestParams = {}, + ) => + this.request({ + path: `/ibc/core/connection/v1/connections/${connection_id}/consensus_state/revision/${revision_number}/height/${revision_height}`, + method: "GET", + format: "json", + ...params, + }); +} diff --git a/ts-client/ibc.core.connection.v1/types.ts b/ts-client/ibc.core.connection.v1/types.ts new file mode 100755 index 00000000..4a35f0df --- /dev/null +++ b/ts-client/ibc.core.connection.v1/types.ts @@ -0,0 +1,19 @@ +import { ConnectionEnd } from "./types/ibc/core/connection/v1/connection" +import { IdentifiedConnection } from "./types/ibc/core/connection/v1/connection" +import { Counterparty } from "./types/ibc/core/connection/v1/connection" +import { ClientPaths } from "./types/ibc/core/connection/v1/connection" +import { ConnectionPaths } from "./types/ibc/core/connection/v1/connection" +import { Version } from "./types/ibc/core/connection/v1/connection" +import { Params } from "./types/ibc/core/connection/v1/connection" + + +export { + ConnectionEnd, + IdentifiedConnection, + Counterparty, + ClientPaths, + ConnectionPaths, + Version, + Params, + + } \ No newline at end of file diff --git a/ts-client/ibc.core.connection.v1/types/cosmos/base/query/v1beta1/pagination.ts b/ts-client/ibc.core.connection.v1/types/cosmos/base/query/v1beta1/pagination.ts new file mode 100644 index 00000000..cd4b2d78 --- /dev/null +++ b/ts-client/ibc.core.connection.v1/types/cosmos/base/query/v1beta1/pagination.ts @@ -0,0 +1,327 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "cosmos.base.query.v1beta1"; + +/** + * PageRequest is to be embedded in gRPC request messages for efficient + * pagination. Ex: + * + * message SomeRequest { + * Foo some_parameter = 1; + * PageRequest pagination = 2; + * } + */ +export interface PageRequest { + /** + * key is a value returned in PageResponse.next_key to begin + * querying the next page most efficiently. Only one of offset or key + * should be set. + */ + key: Uint8Array; + /** + * offset is a numeric offset that can be used when key is unavailable. + * It is less efficient than using key. Only one of offset or key should + * be set. + */ + offset: number; + /** + * limit is the total number of results to be returned in the result page. + * If left empty it will default to a value to be set by each app. + */ + limit: number; + /** + * count_total is set to true to indicate that the result set should include + * a count of the total number of items available for pagination in UIs. + * count_total is only respected when offset is used. It is ignored when key + * is set. + */ + countTotal: boolean; + /** + * reverse is set to true if results are to be returned in the descending order. + * + * Since: cosmos-sdk 0.43 + */ + reverse: boolean; +} + +/** + * PageResponse is to be embedded in gRPC response messages where the + * corresponding request message has used PageRequest. + * + * message SomeResponse { + * repeated Bar results = 1; + * PageResponse page = 2; + * } + */ +export interface PageResponse { + /** + * next_key is the key to be passed to PageRequest.key to + * query the next page most efficiently + */ + nextKey: Uint8Array; + /** + * total is total number of results available if PageRequest.count_total + * was set, its value is undefined otherwise + */ + total: number; +} + +const basePageRequest: object = { + offset: 0, + limit: 0, + countTotal: false, + reverse: false, +}; + +export const PageRequest = { + encode(message: PageRequest, writer: Writer = Writer.create()): Writer { + if (message.key.length !== 0) { + writer.uint32(10).bytes(message.key); + } + if (message.offset !== 0) { + writer.uint32(16).uint64(message.offset); + } + if (message.limit !== 0) { + writer.uint32(24).uint64(message.limit); + } + if (message.countTotal === true) { + writer.uint32(32).bool(message.countTotal); + } + if (message.reverse === true) { + writer.uint32(40).bool(message.reverse); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): PageRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...basePageRequest } as PageRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.key = reader.bytes(); + break; + case 2: + message.offset = longToNumber(reader.uint64() as Long); + break; + case 3: + message.limit = longToNumber(reader.uint64() as Long); + break; + case 4: + message.countTotal = reader.bool(); + break; + case 5: + message.reverse = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): PageRequest { + const message = { ...basePageRequest } as PageRequest; + if (object.key !== undefined && object.key !== null) { + message.key = bytesFromBase64(object.key); + } + if (object.offset !== undefined && object.offset !== null) { + message.offset = Number(object.offset); + } else { + message.offset = 0; + } + if (object.limit !== undefined && object.limit !== null) { + message.limit = Number(object.limit); + } else { + message.limit = 0; + } + if (object.countTotal !== undefined && object.countTotal !== null) { + message.countTotal = Boolean(object.countTotal); + } else { + message.countTotal = false; + } + if (object.reverse !== undefined && object.reverse !== null) { + message.reverse = Boolean(object.reverse); + } else { + message.reverse = false; + } + return message; + }, + + toJSON(message: PageRequest): unknown { + const obj: any = {}; + message.key !== undefined && + (obj.key = base64FromBytes( + message.key !== undefined ? message.key : new Uint8Array() + )); + message.offset !== undefined && (obj.offset = message.offset); + message.limit !== undefined && (obj.limit = message.limit); + message.countTotal !== undefined && (obj.countTotal = message.countTotal); + message.reverse !== undefined && (obj.reverse = message.reverse); + return obj; + }, + + fromPartial(object: DeepPartial): PageRequest { + const message = { ...basePageRequest } as PageRequest; + if (object.key !== undefined && object.key !== null) { + message.key = object.key; + } else { + message.key = new Uint8Array(); + } + if (object.offset !== undefined && object.offset !== null) { + message.offset = object.offset; + } else { + message.offset = 0; + } + if (object.limit !== undefined && object.limit !== null) { + message.limit = object.limit; + } else { + message.limit = 0; + } + if (object.countTotal !== undefined && object.countTotal !== null) { + message.countTotal = object.countTotal; + } else { + message.countTotal = false; + } + if (object.reverse !== undefined && object.reverse !== null) { + message.reverse = object.reverse; + } else { + message.reverse = false; + } + return message; + }, +}; + +const basePageResponse: object = { total: 0 }; + +export const PageResponse = { + encode(message: PageResponse, writer: Writer = Writer.create()): Writer { + if (message.nextKey.length !== 0) { + writer.uint32(10).bytes(message.nextKey); + } + if (message.total !== 0) { + writer.uint32(16).uint64(message.total); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): PageResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...basePageResponse } as PageResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.nextKey = reader.bytes(); + break; + case 2: + message.total = longToNumber(reader.uint64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): PageResponse { + const message = { ...basePageResponse } as PageResponse; + if (object.nextKey !== undefined && object.nextKey !== null) { + message.nextKey = bytesFromBase64(object.nextKey); + } + if (object.total !== undefined && object.total !== null) { + message.total = Number(object.total); + } else { + message.total = 0; + } + return message; + }, + + toJSON(message: PageResponse): unknown { + const obj: any = {}; + message.nextKey !== undefined && + (obj.nextKey = base64FromBytes( + message.nextKey !== undefined ? message.nextKey : new Uint8Array() + )); + message.total !== undefined && (obj.total = message.total); + return obj; + }, + + fromPartial(object: DeepPartial): PageResponse { + const message = { ...basePageResponse } as PageResponse; + if (object.nextKey !== undefined && object.nextKey !== null) { + message.nextKey = object.nextKey; + } else { + message.nextKey = new Uint8Array(); + } + if (object.total !== undefined && object.total !== null) { + message.total = object.total; + } else { + message.total = 0; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/ibc.core.connection.v1/types/cosmos/upgrade/v1beta1/upgrade.ts b/ts-client/ibc.core.connection.v1/types/cosmos/upgrade/v1beta1/upgrade.ts new file mode 100644 index 00000000..ec9520b0 --- /dev/null +++ b/ts-client/ibc.core.connection.v1/types/cosmos/upgrade/v1beta1/upgrade.ts @@ -0,0 +1,539 @@ +/* eslint-disable */ +import { Timestamp } from "../../../google/protobuf/timestamp"; +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; +import { Any } from "../../../google/protobuf/any"; + +export const protobufPackage = "cosmos.upgrade.v1beta1"; + +/** Plan specifies information about a planned upgrade and when it should occur. */ +export interface Plan { + /** + * Sets the name for the upgrade. This name will be used by the upgraded + * version of the software to apply any special "on-upgrade" commands during + * the first BeginBlock method after the upgrade is applied. It is also used + * to detect whether a software version can handle a given upgrade. If no + * upgrade handler with this name has been set in the software, it will be + * assumed that the software is out-of-date when the upgrade Time or Height is + * reached and the software will exit. + */ + name: string; + /** + * Deprecated: Time based upgrades have been deprecated. Time based upgrade logic + * has been removed from the SDK. + * If this field is not empty, an error will be thrown. + * + * @deprecated + */ + time: Date | undefined; + /** + * The height at which the upgrade must be performed. + * Only used if Time is not set. + */ + height: number; + /** + * Any application specific upgrade info to be included on-chain + * such as a git commit that validators could automatically upgrade to + */ + info: string; + /** + * Deprecated: UpgradedClientState field has been deprecated. IBC upgrade logic has been + * moved to the IBC module in the sub module 02-client. + * If this field is not empty, an error will be thrown. + * + * @deprecated + */ + upgradedClientState: Any | undefined; +} + +/** + * SoftwareUpgradeProposal is a gov Content type for initiating a software + * upgrade. + */ +export interface SoftwareUpgradeProposal { + title: string; + description: string; + plan: Plan | undefined; +} + +/** + * CancelSoftwareUpgradeProposal is a gov Content type for cancelling a software + * upgrade. + */ +export interface CancelSoftwareUpgradeProposal { + title: string; + description: string; +} + +/** + * ModuleVersion specifies a module and its consensus version. + * + * Since: cosmos-sdk 0.43 + */ +export interface ModuleVersion { + /** name of the app module */ + name: string; + /** consensus version of the app module */ + version: number; +} + +const basePlan: object = { name: "", height: 0, info: "" }; + +export const Plan = { + encode(message: Plan, writer: Writer = Writer.create()): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.time !== undefined) { + Timestamp.encode( + toTimestamp(message.time), + writer.uint32(18).fork() + ).ldelim(); + } + if (message.height !== 0) { + writer.uint32(24).int64(message.height); + } + if (message.info !== "") { + writer.uint32(34).string(message.info); + } + if (message.upgradedClientState !== undefined) { + Any.encode( + message.upgradedClientState, + writer.uint32(42).fork() + ).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Plan { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...basePlan } as Plan; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.time = fromTimestamp( + Timestamp.decode(reader, reader.uint32()) + ); + break; + case 3: + message.height = longToNumber(reader.int64() as Long); + break; + case 4: + message.info = reader.string(); + break; + case 5: + message.upgradedClientState = Any.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Plan { + const message = { ...basePlan } as Plan; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.time !== undefined && object.time !== null) { + message.time = fromJsonTimestamp(object.time); + } else { + message.time = undefined; + } + if (object.height !== undefined && object.height !== null) { + message.height = Number(object.height); + } else { + message.height = 0; + } + if (object.info !== undefined && object.info !== null) { + message.info = String(object.info); + } else { + message.info = ""; + } + if ( + object.upgradedClientState !== undefined && + object.upgradedClientState !== null + ) { + message.upgradedClientState = Any.fromJSON(object.upgradedClientState); + } else { + message.upgradedClientState = undefined; + } + return message; + }, + + toJSON(message: Plan): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.time !== undefined && + (obj.time = + message.time !== undefined ? message.time.toISOString() : null); + message.height !== undefined && (obj.height = message.height); + message.info !== undefined && (obj.info = message.info); + message.upgradedClientState !== undefined && + (obj.upgradedClientState = message.upgradedClientState + ? Any.toJSON(message.upgradedClientState) + : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): Plan { + const message = { ...basePlan } as Plan; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.time !== undefined && object.time !== null) { + message.time = object.time; + } else { + message.time = undefined; + } + if (object.height !== undefined && object.height !== null) { + message.height = object.height; + } else { + message.height = 0; + } + if (object.info !== undefined && object.info !== null) { + message.info = object.info; + } else { + message.info = ""; + } + if ( + object.upgradedClientState !== undefined && + object.upgradedClientState !== null + ) { + message.upgradedClientState = Any.fromPartial(object.upgradedClientState); + } else { + message.upgradedClientState = undefined; + } + return message; + }, +}; + +const baseSoftwareUpgradeProposal: object = { title: "", description: "" }; + +export const SoftwareUpgradeProposal = { + encode( + message: SoftwareUpgradeProposal, + writer: Writer = Writer.create() + ): Writer { + if (message.title !== "") { + writer.uint32(10).string(message.title); + } + if (message.description !== "") { + writer.uint32(18).string(message.description); + } + if (message.plan !== undefined) { + Plan.encode(message.plan, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): SoftwareUpgradeProposal { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseSoftwareUpgradeProposal, + } as SoftwareUpgradeProposal; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.title = reader.string(); + break; + case 2: + message.description = reader.string(); + break; + case 3: + message.plan = Plan.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): SoftwareUpgradeProposal { + const message = { + ...baseSoftwareUpgradeProposal, + } as SoftwareUpgradeProposal; + if (object.title !== undefined && object.title !== null) { + message.title = String(object.title); + } else { + message.title = ""; + } + if (object.description !== undefined && object.description !== null) { + message.description = String(object.description); + } else { + message.description = ""; + } + if (object.plan !== undefined && object.plan !== null) { + message.plan = Plan.fromJSON(object.plan); + } else { + message.plan = undefined; + } + return message; + }, + + toJSON(message: SoftwareUpgradeProposal): unknown { + const obj: any = {}; + message.title !== undefined && (obj.title = message.title); + message.description !== undefined && + (obj.description = message.description); + message.plan !== undefined && + (obj.plan = message.plan ? Plan.toJSON(message.plan) : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): SoftwareUpgradeProposal { + const message = { + ...baseSoftwareUpgradeProposal, + } as SoftwareUpgradeProposal; + if (object.title !== undefined && object.title !== null) { + message.title = object.title; + } else { + message.title = ""; + } + if (object.description !== undefined && object.description !== null) { + message.description = object.description; + } else { + message.description = ""; + } + if (object.plan !== undefined && object.plan !== null) { + message.plan = Plan.fromPartial(object.plan); + } else { + message.plan = undefined; + } + return message; + }, +}; + +const baseCancelSoftwareUpgradeProposal: object = { + title: "", + description: "", +}; + +export const CancelSoftwareUpgradeProposal = { + encode( + message: CancelSoftwareUpgradeProposal, + writer: Writer = Writer.create() + ): Writer { + if (message.title !== "") { + writer.uint32(10).string(message.title); + } + if (message.description !== "") { + writer.uint32(18).string(message.description); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): CancelSoftwareUpgradeProposal { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseCancelSoftwareUpgradeProposal, + } as CancelSoftwareUpgradeProposal; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.title = reader.string(); + break; + case 2: + message.description = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): CancelSoftwareUpgradeProposal { + const message = { + ...baseCancelSoftwareUpgradeProposal, + } as CancelSoftwareUpgradeProposal; + if (object.title !== undefined && object.title !== null) { + message.title = String(object.title); + } else { + message.title = ""; + } + if (object.description !== undefined && object.description !== null) { + message.description = String(object.description); + } else { + message.description = ""; + } + return message; + }, + + toJSON(message: CancelSoftwareUpgradeProposal): unknown { + const obj: any = {}; + message.title !== undefined && (obj.title = message.title); + message.description !== undefined && + (obj.description = message.description); + return obj; + }, + + fromPartial( + object: DeepPartial + ): CancelSoftwareUpgradeProposal { + const message = { + ...baseCancelSoftwareUpgradeProposal, + } as CancelSoftwareUpgradeProposal; + if (object.title !== undefined && object.title !== null) { + message.title = object.title; + } else { + message.title = ""; + } + if (object.description !== undefined && object.description !== null) { + message.description = object.description; + } else { + message.description = ""; + } + return message; + }, +}; + +const baseModuleVersion: object = { name: "", version: 0 }; + +export const ModuleVersion = { + encode(message: ModuleVersion, writer: Writer = Writer.create()): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.version !== 0) { + writer.uint32(16).uint64(message.version); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ModuleVersion { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseModuleVersion } as ModuleVersion; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.version = longToNumber(reader.uint64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ModuleVersion { + const message = { ...baseModuleVersion } as ModuleVersion; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.version !== undefined && object.version !== null) { + message.version = Number(object.version); + } else { + message.version = 0; + } + return message; + }, + + toJSON(message: ModuleVersion): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.version !== undefined && (obj.version = message.version); + return obj; + }, + + fromPartial(object: DeepPartial): ModuleVersion { + const message = { ...baseModuleVersion } as ModuleVersion; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.version !== undefined && object.version !== null) { + message.version = object.version; + } else { + message.version = 0; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function toTimestamp(date: Date): Timestamp { + const seconds = date.getTime() / 1_000; + const nanos = (date.getTime() % 1_000) * 1_000_000; + return { seconds, nanos }; +} + +function fromTimestamp(t: Timestamp): Date { + let millis = t.seconds * 1_000; + millis += t.nanos / 1_000_000; + return new Date(millis); +} + +function fromJsonTimestamp(o: any): Date { + if (o instanceof Date) { + return o; + } else if (typeof o === "string") { + return new Date(o); + } else { + return fromTimestamp(Timestamp.fromJSON(o)); + } +} + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/ibc.core.connection.v1/types/cosmos_proto/cosmos.ts b/ts-client/ibc.core.connection.v1/types/cosmos_proto/cosmos.ts new file mode 100644 index 00000000..9ec67a12 --- /dev/null +++ b/ts-client/ibc.core.connection.v1/types/cosmos_proto/cosmos.ts @@ -0,0 +1,2 @@ +/* eslint-disable */ +export const protobufPackage = "cosmos_proto"; diff --git a/ts-client/ibc.core.connection.v1/types/gogoproto/gogo.ts b/ts-client/ibc.core.connection.v1/types/gogoproto/gogo.ts new file mode 100644 index 00000000..3f41a047 --- /dev/null +++ b/ts-client/ibc.core.connection.v1/types/gogoproto/gogo.ts @@ -0,0 +1,2 @@ +/* eslint-disable */ +export const protobufPackage = "gogoproto"; diff --git a/ts-client/ibc.core.connection.v1/types/google/api/annotations.ts b/ts-client/ibc.core.connection.v1/types/google/api/annotations.ts new file mode 100644 index 00000000..aace4787 --- /dev/null +++ b/ts-client/ibc.core.connection.v1/types/google/api/annotations.ts @@ -0,0 +1,2 @@ +/* eslint-disable */ +export const protobufPackage = "google.api"; diff --git a/ts-client/ibc.core.connection.v1/types/google/api/http.ts b/ts-client/ibc.core.connection.v1/types/google/api/http.ts new file mode 100644 index 00000000..ddc00f8b --- /dev/null +++ b/ts-client/ibc.core.connection.v1/types/google/api/http.ts @@ -0,0 +1,705 @@ +/* eslint-disable */ +import { Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "google.api"; + +/** + * Defines the HTTP configuration for an API service. It contains a list of + * [HttpRule][google.api.HttpRule], each specifying the mapping of an RPC method + * to one or more HTTP REST API methods. + */ +export interface Http { + /** + * A list of HTTP configuration rules that apply to individual API methods. + * + * **NOTE:** All service configuration rules follow "last one wins" order. + */ + rules: HttpRule[]; + /** + * When set to true, URL path parmeters will be fully URI-decoded except in + * cases of single segment matches in reserved expansion, where "%2F" will be + * left encoded. + * + * The default behavior is to not decode RFC 6570 reserved characters in multi + * segment matches. + */ + fullyDecodeReservedExpansion: boolean; +} + +/** + * `HttpRule` defines the mapping of an RPC method to one or more HTTP + * REST API methods. The mapping specifies how different portions of the RPC + * request message are mapped to URL path, URL query parameters, and + * HTTP request body. The mapping is typically specified as an + * `google.api.http` annotation on the RPC method, + * see "google/api/annotations.proto" for details. + * + * The mapping consists of a field specifying the path template and + * method kind. The path template can refer to fields in the request + * message, as in the example below which describes a REST GET + * operation on a resource collection of messages: + * + * + * service Messaging { + * rpc GetMessage(GetMessageRequest) returns (Message) { + * option (google.api.http).get = "/v1/messages/{message_id}/{sub.subfield}"; + * } + * } + * message GetMessageRequest { + * message SubMessage { + * string subfield = 1; + * } + * string message_id = 1; // mapped to the URL + * SubMessage sub = 2; // `sub.subfield` is url-mapped + * } + * message Message { + * string text = 1; // content of the resource + * } + * + * The same http annotation can alternatively be expressed inside the + * `GRPC API Configuration` YAML file. + * + * http: + * rules: + * - selector: .Messaging.GetMessage + * get: /v1/messages/{message_id}/{sub.subfield} + * + * This definition enables an automatic, bidrectional mapping of HTTP + * JSON to RPC. Example: + * + * HTTP | RPC + * -----|----- + * `GET /v1/messages/123456/foo` | `GetMessage(message_id: "123456" sub: SubMessage(subfield: "foo"))` + * + * In general, not only fields but also field paths can be referenced + * from a path pattern. Fields mapped to the path pattern cannot be + * repeated and must have a primitive (non-message) type. + * + * Any fields in the request message which are not bound by the path + * pattern automatically become (optional) HTTP query + * parameters. Assume the following definition of the request message: + * + * + * service Messaging { + * rpc GetMessage(GetMessageRequest) returns (Message) { + * option (google.api.http).get = "/v1/messages/{message_id}"; + * } + * } + * message GetMessageRequest { + * message SubMessage { + * string subfield = 1; + * } + * string message_id = 1; // mapped to the URL + * int64 revision = 2; // becomes a parameter + * SubMessage sub = 3; // `sub.subfield` becomes a parameter + * } + * + * + * This enables a HTTP JSON to RPC mapping as below: + * + * HTTP | RPC + * -----|----- + * `GET /v1/messages/123456?revision=2&sub.subfield=foo` | `GetMessage(message_id: "123456" revision: 2 sub: SubMessage(subfield: "foo"))` + * + * Note that fields which are mapped to HTTP parameters must have a + * primitive type or a repeated primitive type. Message types are not + * allowed. In the case of a repeated type, the parameter can be + * repeated in the URL, as in `...?param=A¶m=B`. + * + * For HTTP method kinds which allow a request body, the `body` field + * specifies the mapping. Consider a REST update method on the + * message resource collection: + * + * + * service Messaging { + * rpc UpdateMessage(UpdateMessageRequest) returns (Message) { + * option (google.api.http) = { + * put: "/v1/messages/{message_id}" + * body: "message" + * }; + * } + * } + * message UpdateMessageRequest { + * string message_id = 1; // mapped to the URL + * Message message = 2; // mapped to the body + * } + * + * + * The following HTTP JSON to RPC mapping is enabled, where the + * representation of the JSON in the request body is determined by + * protos JSON encoding: + * + * HTTP | RPC + * -----|----- + * `PUT /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: "123456" message { text: "Hi!" })` + * + * The special name `*` can be used in the body mapping to define that + * every field not bound by the path template should be mapped to the + * request body. This enables the following alternative definition of + * the update method: + * + * service Messaging { + * rpc UpdateMessage(Message) returns (Message) { + * option (google.api.http) = { + * put: "/v1/messages/{message_id}" + * body: "*" + * }; + * } + * } + * message Message { + * string message_id = 1; + * string text = 2; + * } + * + * + * The following HTTP JSON to RPC mapping is enabled: + * + * HTTP | RPC + * -----|----- + * `PUT /v1/messages/123456 { "text": "Hi!" }` | `UpdateMessage(message_id: "123456" text: "Hi!")` + * + * Note that when using `*` in the body mapping, it is not possible to + * have HTTP parameters, as all fields not bound by the path end in + * the body. This makes this option more rarely used in practice of + * defining REST APIs. The common usage of `*` is in custom methods + * which don't use the URL at all for transferring data. + * + * It is possible to define multiple HTTP methods for one RPC by using + * the `additional_bindings` option. Example: + * + * service Messaging { + * rpc GetMessage(GetMessageRequest) returns (Message) { + * option (google.api.http) = { + * get: "/v1/messages/{message_id}" + * additional_bindings { + * get: "/v1/users/{user_id}/messages/{message_id}" + * } + * }; + * } + * } + * message GetMessageRequest { + * string message_id = 1; + * string user_id = 2; + * } + * + * + * This enables the following two alternative HTTP JSON to RPC + * mappings: + * + * HTTP | RPC + * -----|----- + * `GET /v1/messages/123456` | `GetMessage(message_id: "123456")` + * `GET /v1/users/me/messages/123456` | `GetMessage(user_id: "me" message_id: "123456")` + * + * # Rules for HTTP mapping + * + * The rules for mapping HTTP path, query parameters, and body fields + * to the request message are as follows: + * + * 1. The `body` field specifies either `*` or a field path, or is + * omitted. If omitted, it indicates there is no HTTP request body. + * 2. Leaf fields (recursive expansion of nested messages in the + * request) can be classified into three types: + * (a) Matched in the URL template. + * (b) Covered by body (if body is `*`, everything except (a) fields; + * else everything under the body field) + * (c) All other fields. + * 3. URL query parameters found in the HTTP request are mapped to (c) fields. + * 4. Any body sent with an HTTP request can contain only (b) fields. + * + * The syntax of the path template is as follows: + * + * Template = "/" Segments [ Verb ] ; + * Segments = Segment { "/" Segment } ; + * Segment = "*" | "**" | LITERAL | Variable ; + * Variable = "{" FieldPath [ "=" Segments ] "}" ; + * FieldPath = IDENT { "." IDENT } ; + * Verb = ":" LITERAL ; + * + * The syntax `*` matches a single path segment. The syntax `**` matches zero + * or more path segments, which must be the last part of the path except the + * `Verb`. The syntax `LITERAL` matches literal text in the path. + * + * The syntax `Variable` matches part of the URL path as specified by its + * template. A variable template must not contain other variables. If a variable + * matches a single path segment, its template may be omitted, e.g. `{var}` + * is equivalent to `{var=*}`. + * + * If a variable contains exactly one path segment, such as `"{var}"` or + * `"{var=*}"`, when such a variable is expanded into a URL path, all characters + * except `[-_.~0-9a-zA-Z]` are percent-encoded. Such variables show up in the + * Discovery Document as `{var}`. + * + * If a variable contains one or more path segments, such as `"{var=foo/*}"` + * or `"{var=**}"`, when such a variable is expanded into a URL path, all + * characters except `[-_.~/0-9a-zA-Z]` are percent-encoded. Such variables + * show up in the Discovery Document as `{+var}`. + * + * NOTE: While the single segment variable matches the semantics of + * [RFC 6570](https://tools.ietf.org/html/rfc6570) Section 3.2.2 + * Simple String Expansion, the multi segment variable **does not** match + * RFC 6570 Reserved Expansion. The reason is that the Reserved Expansion + * does not expand special characters like `?` and `#`, which would lead + * to invalid URLs. + * + * NOTE: the field paths in variables and in the `body` must not refer to + * repeated fields or map fields. + */ +export interface HttpRule { + /** + * Selects methods to which this rule applies. + * + * Refer to [selector][google.api.DocumentationRule.selector] for syntax details. + */ + selector: string; + /** Used for listing and getting information about resources. */ + get: string | undefined; + /** Used for updating a resource. */ + put: string | undefined; + /** Used for creating a resource. */ + post: string | undefined; + /** Used for deleting a resource. */ + delete: string | undefined; + /** Used for updating a resource. */ + patch: string | undefined; + /** + * The custom pattern is used for specifying an HTTP method that is not + * included in the `pattern` field, such as HEAD, or "*" to leave the + * HTTP method unspecified for this rule. The wild-card rule is useful + * for services that provide content to Web (HTML) clients. + */ + custom: CustomHttpPattern | undefined; + /** + * The name of the request field whose value is mapped to the HTTP body, or + * `*` for mapping all fields not captured by the path pattern to the HTTP + * body. NOTE: the referred field must not be a repeated field and must be + * present at the top-level of request message type. + */ + body: string; + /** + * Optional. The name of the response field whose value is mapped to the HTTP + * body of response. Other response fields are ignored. When + * not set, the response message will be used as HTTP body of response. + */ + responseBody: string; + /** + * Additional HTTP bindings for the selector. Nested bindings must + * not contain an `additional_bindings` field themselves (that is, + * the nesting may only be one level deep). + */ + additionalBindings: HttpRule[]; +} + +/** A custom pattern is used for defining custom HTTP verb. */ +export interface CustomHttpPattern { + /** The name of this custom HTTP verb. */ + kind: string; + /** The path matched by this custom verb. */ + path: string; +} + +const baseHttp: object = { fullyDecodeReservedExpansion: false }; + +export const Http = { + encode(message: Http, writer: Writer = Writer.create()): Writer { + for (const v of message.rules) { + HttpRule.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.fullyDecodeReservedExpansion === true) { + writer.uint32(16).bool(message.fullyDecodeReservedExpansion); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Http { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseHttp } as Http; + message.rules = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.rules.push(HttpRule.decode(reader, reader.uint32())); + break; + case 2: + message.fullyDecodeReservedExpansion = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Http { + const message = { ...baseHttp } as Http; + message.rules = []; + if (object.rules !== undefined && object.rules !== null) { + for (const e of object.rules) { + message.rules.push(HttpRule.fromJSON(e)); + } + } + if ( + object.fullyDecodeReservedExpansion !== undefined && + object.fullyDecodeReservedExpansion !== null + ) { + message.fullyDecodeReservedExpansion = Boolean( + object.fullyDecodeReservedExpansion + ); + } else { + message.fullyDecodeReservedExpansion = false; + } + return message; + }, + + toJSON(message: Http): unknown { + const obj: any = {}; + if (message.rules) { + obj.rules = message.rules.map((e) => + e ? HttpRule.toJSON(e) : undefined + ); + } else { + obj.rules = []; + } + message.fullyDecodeReservedExpansion !== undefined && + (obj.fullyDecodeReservedExpansion = message.fullyDecodeReservedExpansion); + return obj; + }, + + fromPartial(object: DeepPartial): Http { + const message = { ...baseHttp } as Http; + message.rules = []; + if (object.rules !== undefined && object.rules !== null) { + for (const e of object.rules) { + message.rules.push(HttpRule.fromPartial(e)); + } + } + if ( + object.fullyDecodeReservedExpansion !== undefined && + object.fullyDecodeReservedExpansion !== null + ) { + message.fullyDecodeReservedExpansion = + object.fullyDecodeReservedExpansion; + } else { + message.fullyDecodeReservedExpansion = false; + } + return message; + }, +}; + +const baseHttpRule: object = { selector: "", body: "", responseBody: "" }; + +export const HttpRule = { + encode(message: HttpRule, writer: Writer = Writer.create()): Writer { + if (message.selector !== "") { + writer.uint32(10).string(message.selector); + } + if (message.get !== undefined) { + writer.uint32(18).string(message.get); + } + if (message.put !== undefined) { + writer.uint32(26).string(message.put); + } + if (message.post !== undefined) { + writer.uint32(34).string(message.post); + } + if (message.delete !== undefined) { + writer.uint32(42).string(message.delete); + } + if (message.patch !== undefined) { + writer.uint32(50).string(message.patch); + } + if (message.custom !== undefined) { + CustomHttpPattern.encode( + message.custom, + writer.uint32(66).fork() + ).ldelim(); + } + if (message.body !== "") { + writer.uint32(58).string(message.body); + } + if (message.responseBody !== "") { + writer.uint32(98).string(message.responseBody); + } + for (const v of message.additionalBindings) { + HttpRule.encode(v!, writer.uint32(90).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): HttpRule { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseHttpRule } as HttpRule; + message.additionalBindings = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.selector = reader.string(); + break; + case 2: + message.get = reader.string(); + break; + case 3: + message.put = reader.string(); + break; + case 4: + message.post = reader.string(); + break; + case 5: + message.delete = reader.string(); + break; + case 6: + message.patch = reader.string(); + break; + case 8: + message.custom = CustomHttpPattern.decode(reader, reader.uint32()); + break; + case 7: + message.body = reader.string(); + break; + case 12: + message.responseBody = reader.string(); + break; + case 11: + message.additionalBindings.push( + HttpRule.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): HttpRule { + const message = { ...baseHttpRule } as HttpRule; + message.additionalBindings = []; + if (object.selector !== undefined && object.selector !== null) { + message.selector = String(object.selector); + } else { + message.selector = ""; + } + if (object.get !== undefined && object.get !== null) { + message.get = String(object.get); + } else { + message.get = undefined; + } + if (object.put !== undefined && object.put !== null) { + message.put = String(object.put); + } else { + message.put = undefined; + } + if (object.post !== undefined && object.post !== null) { + message.post = String(object.post); + } else { + message.post = undefined; + } + if (object.delete !== undefined && object.delete !== null) { + message.delete = String(object.delete); + } else { + message.delete = undefined; + } + if (object.patch !== undefined && object.patch !== null) { + message.patch = String(object.patch); + } else { + message.patch = undefined; + } + if (object.custom !== undefined && object.custom !== null) { + message.custom = CustomHttpPattern.fromJSON(object.custom); + } else { + message.custom = undefined; + } + if (object.body !== undefined && object.body !== null) { + message.body = String(object.body); + } else { + message.body = ""; + } + if (object.responseBody !== undefined && object.responseBody !== null) { + message.responseBody = String(object.responseBody); + } else { + message.responseBody = ""; + } + if ( + object.additionalBindings !== undefined && + object.additionalBindings !== null + ) { + for (const e of object.additionalBindings) { + message.additionalBindings.push(HttpRule.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: HttpRule): unknown { + const obj: any = {}; + message.selector !== undefined && (obj.selector = message.selector); + message.get !== undefined && (obj.get = message.get); + message.put !== undefined && (obj.put = message.put); + message.post !== undefined && (obj.post = message.post); + message.delete !== undefined && (obj.delete = message.delete); + message.patch !== undefined && (obj.patch = message.patch); + message.custom !== undefined && + (obj.custom = message.custom + ? CustomHttpPattern.toJSON(message.custom) + : undefined); + message.body !== undefined && (obj.body = message.body); + message.responseBody !== undefined && + (obj.responseBody = message.responseBody); + if (message.additionalBindings) { + obj.additionalBindings = message.additionalBindings.map((e) => + e ? HttpRule.toJSON(e) : undefined + ); + } else { + obj.additionalBindings = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): HttpRule { + const message = { ...baseHttpRule } as HttpRule; + message.additionalBindings = []; + if (object.selector !== undefined && object.selector !== null) { + message.selector = object.selector; + } else { + message.selector = ""; + } + if (object.get !== undefined && object.get !== null) { + message.get = object.get; + } else { + message.get = undefined; + } + if (object.put !== undefined && object.put !== null) { + message.put = object.put; + } else { + message.put = undefined; + } + if (object.post !== undefined && object.post !== null) { + message.post = object.post; + } else { + message.post = undefined; + } + if (object.delete !== undefined && object.delete !== null) { + message.delete = object.delete; + } else { + message.delete = undefined; + } + if (object.patch !== undefined && object.patch !== null) { + message.patch = object.patch; + } else { + message.patch = undefined; + } + if (object.custom !== undefined && object.custom !== null) { + message.custom = CustomHttpPattern.fromPartial(object.custom); + } else { + message.custom = undefined; + } + if (object.body !== undefined && object.body !== null) { + message.body = object.body; + } else { + message.body = ""; + } + if (object.responseBody !== undefined && object.responseBody !== null) { + message.responseBody = object.responseBody; + } else { + message.responseBody = ""; + } + if ( + object.additionalBindings !== undefined && + object.additionalBindings !== null + ) { + for (const e of object.additionalBindings) { + message.additionalBindings.push(HttpRule.fromPartial(e)); + } + } + return message; + }, +}; + +const baseCustomHttpPattern: object = { kind: "", path: "" }; + +export const CustomHttpPattern = { + encode(message: CustomHttpPattern, writer: Writer = Writer.create()): Writer { + if (message.kind !== "") { + writer.uint32(10).string(message.kind); + } + if (message.path !== "") { + writer.uint32(18).string(message.path); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): CustomHttpPattern { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseCustomHttpPattern } as CustomHttpPattern; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.kind = reader.string(); + break; + case 2: + message.path = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): CustomHttpPattern { + const message = { ...baseCustomHttpPattern } as CustomHttpPattern; + if (object.kind !== undefined && object.kind !== null) { + message.kind = String(object.kind); + } else { + message.kind = ""; + } + if (object.path !== undefined && object.path !== null) { + message.path = String(object.path); + } else { + message.path = ""; + } + return message; + }, + + toJSON(message: CustomHttpPattern): unknown { + const obj: any = {}; + message.kind !== undefined && (obj.kind = message.kind); + message.path !== undefined && (obj.path = message.path); + return obj; + }, + + fromPartial(object: DeepPartial): CustomHttpPattern { + const message = { ...baseCustomHttpPattern } as CustomHttpPattern; + if (object.kind !== undefined && object.kind !== null) { + message.kind = object.kind; + } else { + message.kind = ""; + } + if (object.path !== undefined && object.path !== null) { + message.path = object.path; + } else { + message.path = ""; + } + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/ibc.core.connection.v1/types/google/protobuf/any.ts b/ts-client/ibc.core.connection.v1/types/google/protobuf/any.ts new file mode 100644 index 00000000..b137a629 --- /dev/null +++ b/ts-client/ibc.core.connection.v1/types/google/protobuf/any.ts @@ -0,0 +1,240 @@ +/* eslint-disable */ +import { Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "google.protobuf"; + +/** + * `Any` contains an arbitrary serialized protocol buffer message along with a + * URL that describes the type of the serialized message. + * + * Protobuf library provides support to pack/unpack Any values in the form + * of utility functions or additional generated methods of the Any type. + * + * Example 1: Pack and unpack a message in C++. + * + * Foo foo = ...; + * Any any; + * any.PackFrom(foo); + * ... + * if (any.UnpackTo(&foo)) { + * ... + * } + * + * Example 2: Pack and unpack a message in Java. + * + * Foo foo = ...; + * Any any = Any.pack(foo); + * ... + * if (any.is(Foo.class)) { + * foo = any.unpack(Foo.class); + * } + * + * Example 3: Pack and unpack a message in Python. + * + * foo = Foo(...) + * any = Any() + * any.Pack(foo) + * ... + * if any.Is(Foo.DESCRIPTOR): + * any.Unpack(foo) + * ... + * + * Example 4: Pack and unpack a message in Go + * + * foo := &pb.Foo{...} + * any, err := anypb.New(foo) + * if err != nil { + * ... + * } + * ... + * foo := &pb.Foo{} + * if err := any.UnmarshalTo(foo); err != nil { + * ... + * } + * + * The pack methods provided by protobuf library will by default use + * 'type.googleapis.com/full.type.name' as the type URL and the unpack + * methods only use the fully qualified type name after the last '/' + * in the type URL, for example "foo.bar.com/x/y.z" will yield type + * name "y.z". + * + * + * JSON + * ==== + * The JSON representation of an `Any` value uses the regular + * representation of the deserialized, embedded message, with an + * additional field `@type` which contains the type URL. Example: + * + * package google.profile; + * message Person { + * string first_name = 1; + * string last_name = 2; + * } + * + * { + * "@type": "type.googleapis.com/google.profile.Person", + * "firstName": , + * "lastName": + * } + * + * If the embedded message type is well-known and has a custom JSON + * representation, that representation will be embedded adding a field + * `value` which holds the custom JSON in addition to the `@type` + * field. Example (for message [google.protobuf.Duration][]): + * + * { + * "@type": "type.googleapis.com/google.protobuf.Duration", + * "value": "1.212s" + * } + */ +export interface Any { + /** + * A URL/resource name that uniquely identifies the type of the serialized + * protocol buffer message. This string must contain at least + * one "/" character. The last segment of the URL's path must represent + * the fully qualified name of the type (as in + * `path/google.protobuf.Duration`). The name should be in a canonical form + * (e.g., leading "." is not accepted). + * + * In practice, teams usually precompile into the binary all types that they + * expect it to use in the context of Any. However, for URLs which use the + * scheme `http`, `https`, or no scheme, one can optionally set up a type + * server that maps type URLs to message definitions as follows: + * + * * If no scheme is provided, `https` is assumed. + * * An HTTP GET on the URL must yield a [google.protobuf.Type][] + * value in binary format, or produce an error. + * * Applications are allowed to cache lookup results based on the + * URL, or have them precompiled into a binary to avoid any + * lookup. Therefore, binary compatibility needs to be preserved + * on changes to types. (Use versioned type names to manage + * breaking changes.) + * + * Note: this functionality is not currently available in the official + * protobuf release, and it is not used for type URLs beginning with + * type.googleapis.com. + * + * Schemes other than `http`, `https` (or the empty scheme) might be + * used with implementation specific semantics. + */ + typeUrl: string; + /** Must be a valid serialized protocol buffer of the above specified type. */ + value: Uint8Array; +} + +const baseAny: object = { typeUrl: "" }; + +export const Any = { + encode(message: Any, writer: Writer = Writer.create()): Writer { + if (message.typeUrl !== "") { + writer.uint32(10).string(message.typeUrl); + } + if (message.value.length !== 0) { + writer.uint32(18).bytes(message.value); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Any { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseAny } as Any; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.typeUrl = reader.string(); + break; + case 2: + message.value = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Any { + const message = { ...baseAny } as Any; + if (object.typeUrl !== undefined && object.typeUrl !== null) { + message.typeUrl = String(object.typeUrl); + } else { + message.typeUrl = ""; + } + if (object.value !== undefined && object.value !== null) { + message.value = bytesFromBase64(object.value); + } + return message; + }, + + toJSON(message: Any): unknown { + const obj: any = {}; + message.typeUrl !== undefined && (obj.typeUrl = message.typeUrl); + message.value !== undefined && + (obj.value = base64FromBytes( + message.value !== undefined ? message.value : new Uint8Array() + )); + return obj; + }, + + fromPartial(object: DeepPartial): Any { + const message = { ...baseAny } as Any; + if (object.typeUrl !== undefined && object.typeUrl !== null) { + message.typeUrl = object.typeUrl; + } else { + message.typeUrl = ""; + } + if (object.value !== undefined && object.value !== null) { + message.value = object.value; + } else { + message.value = new Uint8Array(); + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/ibc.core.connection.v1/types/google/protobuf/descriptor.ts b/ts-client/ibc.core.connection.v1/types/google/protobuf/descriptor.ts new file mode 100644 index 00000000..9e508660 --- /dev/null +++ b/ts-client/ibc.core.connection.v1/types/google/protobuf/descriptor.ts @@ -0,0 +1,5261 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "google.protobuf"; + +/** + * The protocol compiler can output a FileDescriptorSet containing the .proto + * files it parses. + */ +export interface FileDescriptorSet { + file: FileDescriptorProto[]; +} + +/** Describes a complete .proto file. */ +export interface FileDescriptorProto { + /** file name, relative to root of source tree */ + name: string; + /** e.g. "foo", "foo.bar", etc. */ + package: string; + /** Names of files imported by this file. */ + dependency: string[]; + /** Indexes of the public imported files in the dependency list above. */ + publicDependency: number[]; + /** + * Indexes of the weak imported files in the dependency list. + * For Google-internal migration only. Do not use. + */ + weakDependency: number[]; + /** All top-level definitions in this file. */ + messageType: DescriptorProto[]; + enumType: EnumDescriptorProto[]; + service: ServiceDescriptorProto[]; + extension: FieldDescriptorProto[]; + options: FileOptions | undefined; + /** + * This field contains optional information about the original source code. + * You may safely remove this entire field without harming runtime + * functionality of the descriptors -- the information is needed only by + * development tools. + */ + sourceCodeInfo: SourceCodeInfo | undefined; + /** + * The syntax of the proto file. + * The supported values are "proto2" and "proto3". + */ + syntax: string; +} + +/** Describes a message type. */ +export interface DescriptorProto { + name: string; + field: FieldDescriptorProto[]; + extension: FieldDescriptorProto[]; + nestedType: DescriptorProto[]; + enumType: EnumDescriptorProto[]; + extensionRange: DescriptorProto_ExtensionRange[]; + oneofDecl: OneofDescriptorProto[]; + options: MessageOptions | undefined; + reservedRange: DescriptorProto_ReservedRange[]; + /** + * Reserved field names, which may not be used by fields in the same message. + * A given name may only be reserved once. + */ + reservedName: string[]; +} + +export interface DescriptorProto_ExtensionRange { + /** Inclusive. */ + start: number; + /** Exclusive. */ + end: number; + options: ExtensionRangeOptions | undefined; +} + +/** + * Range of reserved tag numbers. Reserved tag numbers may not be used by + * fields or extension ranges in the same message. Reserved ranges may + * not overlap. + */ +export interface DescriptorProto_ReservedRange { + /** Inclusive. */ + start: number; + /** Exclusive. */ + end: number; +} + +export interface ExtensionRangeOptions { + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +/** Describes a field within a message. */ +export interface FieldDescriptorProto { + name: string; + number: number; + label: FieldDescriptorProto_Label; + /** + * If type_name is set, this need not be set. If both this and type_name + * are set, this must be one of TYPE_ENUM, TYPE_MESSAGE or TYPE_GROUP. + */ + type: FieldDescriptorProto_Type; + /** + * For message and enum types, this is the name of the type. If the name + * starts with a '.', it is fully-qualified. Otherwise, C++-like scoping + * rules are used to find the type (i.e. first the nested types within this + * message are searched, then within the parent, on up to the root + * namespace). + */ + typeName: string; + /** + * For extensions, this is the name of the type being extended. It is + * resolved in the same manner as type_name. + */ + extendee: string; + /** + * For numeric types, contains the original text representation of the value. + * For booleans, "true" or "false". + * For strings, contains the default text contents (not escaped in any way). + * For bytes, contains the C escaped value. All bytes >= 128 are escaped. + * TODO(kenton): Base-64 encode? + */ + defaultValue: string; + /** + * If set, gives the index of a oneof in the containing type's oneof_decl + * list. This field is a member of that oneof. + */ + oneofIndex: number; + /** + * JSON name of this field. The value is set by protocol compiler. If the + * user has set a "json_name" option on this field, that option's value + * will be used. Otherwise, it's deduced from the field's name by converting + * it to camelCase. + */ + jsonName: string; + options: FieldOptions | undefined; + /** + * If true, this is a proto3 "optional". When a proto3 field is optional, it + * tracks presence regardless of field type. + * + * When proto3_optional is true, this field must be belong to a oneof to + * signal to old proto3 clients that presence is tracked for this field. This + * oneof is known as a "synthetic" oneof, and this field must be its sole + * member (each proto3 optional field gets its own synthetic oneof). Synthetic + * oneofs exist in the descriptor only, and do not generate any API. Synthetic + * oneofs must be ordered after all "real" oneofs. + * + * For message fields, proto3_optional doesn't create any semantic change, + * since non-repeated message fields always track presence. However it still + * indicates the semantic detail of whether the user wrote "optional" or not. + * This can be useful for round-tripping the .proto file. For consistency we + * give message fields a synthetic oneof also, even though it is not required + * to track presence. This is especially important because the parser can't + * tell if a field is a message or an enum, so it must always create a + * synthetic oneof. + * + * Proto2 optional fields do not set this flag, because they already indicate + * optional with `LABEL_OPTIONAL`. + */ + proto3Optional: boolean; +} + +export enum FieldDescriptorProto_Type { + /** + * TYPE_DOUBLE - 0 is reserved for errors. + * Order is weird for historical reasons. + */ + TYPE_DOUBLE = 1, + TYPE_FLOAT = 2, + /** + * TYPE_INT64 - Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT64 if + * negative values are likely. + */ + TYPE_INT64 = 3, + TYPE_UINT64 = 4, + /** + * TYPE_INT32 - Not ZigZag encoded. Negative numbers take 10 bytes. Use TYPE_SINT32 if + * negative values are likely. + */ + TYPE_INT32 = 5, + TYPE_FIXED64 = 6, + TYPE_FIXED32 = 7, + TYPE_BOOL = 8, + TYPE_STRING = 9, + /** + * TYPE_GROUP - Tag-delimited aggregate. + * Group type is deprecated and not supported in proto3. However, Proto3 + * implementations should still be able to parse the group wire format and + * treat group fields as unknown fields. + */ + TYPE_GROUP = 10, + /** TYPE_MESSAGE - Length-delimited aggregate. */ + TYPE_MESSAGE = 11, + /** TYPE_BYTES - New in version 2. */ + TYPE_BYTES = 12, + TYPE_UINT32 = 13, + TYPE_ENUM = 14, + TYPE_SFIXED32 = 15, + TYPE_SFIXED64 = 16, + /** TYPE_SINT32 - Uses ZigZag encoding. */ + TYPE_SINT32 = 17, + /** TYPE_SINT64 - Uses ZigZag encoding. */ + TYPE_SINT64 = 18, + UNRECOGNIZED = -1, +} + +export function fieldDescriptorProto_TypeFromJSON( + object: any +): FieldDescriptorProto_Type { + switch (object) { + case 1: + case "TYPE_DOUBLE": + return FieldDescriptorProto_Type.TYPE_DOUBLE; + case 2: + case "TYPE_FLOAT": + return FieldDescriptorProto_Type.TYPE_FLOAT; + case 3: + case "TYPE_INT64": + return FieldDescriptorProto_Type.TYPE_INT64; + case 4: + case "TYPE_UINT64": + return FieldDescriptorProto_Type.TYPE_UINT64; + case 5: + case "TYPE_INT32": + return FieldDescriptorProto_Type.TYPE_INT32; + case 6: + case "TYPE_FIXED64": + return FieldDescriptorProto_Type.TYPE_FIXED64; + case 7: + case "TYPE_FIXED32": + return FieldDescriptorProto_Type.TYPE_FIXED32; + case 8: + case "TYPE_BOOL": + return FieldDescriptorProto_Type.TYPE_BOOL; + case 9: + case "TYPE_STRING": + return FieldDescriptorProto_Type.TYPE_STRING; + case 10: + case "TYPE_GROUP": + return FieldDescriptorProto_Type.TYPE_GROUP; + case 11: + case "TYPE_MESSAGE": + return FieldDescriptorProto_Type.TYPE_MESSAGE; + case 12: + case "TYPE_BYTES": + return FieldDescriptorProto_Type.TYPE_BYTES; + case 13: + case "TYPE_UINT32": + return FieldDescriptorProto_Type.TYPE_UINT32; + case 14: + case "TYPE_ENUM": + return FieldDescriptorProto_Type.TYPE_ENUM; + case 15: + case "TYPE_SFIXED32": + return FieldDescriptorProto_Type.TYPE_SFIXED32; + case 16: + case "TYPE_SFIXED64": + return FieldDescriptorProto_Type.TYPE_SFIXED64; + case 17: + case "TYPE_SINT32": + return FieldDescriptorProto_Type.TYPE_SINT32; + case 18: + case "TYPE_SINT64": + return FieldDescriptorProto_Type.TYPE_SINT64; + case -1: + case "UNRECOGNIZED": + default: + return FieldDescriptorProto_Type.UNRECOGNIZED; + } +} + +export function fieldDescriptorProto_TypeToJSON( + object: FieldDescriptorProto_Type +): string { + switch (object) { + case FieldDescriptorProto_Type.TYPE_DOUBLE: + return "TYPE_DOUBLE"; + case FieldDescriptorProto_Type.TYPE_FLOAT: + return "TYPE_FLOAT"; + case FieldDescriptorProto_Type.TYPE_INT64: + return "TYPE_INT64"; + case FieldDescriptorProto_Type.TYPE_UINT64: + return "TYPE_UINT64"; + case FieldDescriptorProto_Type.TYPE_INT32: + return "TYPE_INT32"; + case FieldDescriptorProto_Type.TYPE_FIXED64: + return "TYPE_FIXED64"; + case FieldDescriptorProto_Type.TYPE_FIXED32: + return "TYPE_FIXED32"; + case FieldDescriptorProto_Type.TYPE_BOOL: + return "TYPE_BOOL"; + case FieldDescriptorProto_Type.TYPE_STRING: + return "TYPE_STRING"; + case FieldDescriptorProto_Type.TYPE_GROUP: + return "TYPE_GROUP"; + case FieldDescriptorProto_Type.TYPE_MESSAGE: + return "TYPE_MESSAGE"; + case FieldDescriptorProto_Type.TYPE_BYTES: + return "TYPE_BYTES"; + case FieldDescriptorProto_Type.TYPE_UINT32: + return "TYPE_UINT32"; + case FieldDescriptorProto_Type.TYPE_ENUM: + return "TYPE_ENUM"; + case FieldDescriptorProto_Type.TYPE_SFIXED32: + return "TYPE_SFIXED32"; + case FieldDescriptorProto_Type.TYPE_SFIXED64: + return "TYPE_SFIXED64"; + case FieldDescriptorProto_Type.TYPE_SINT32: + return "TYPE_SINT32"; + case FieldDescriptorProto_Type.TYPE_SINT64: + return "TYPE_SINT64"; + default: + return "UNKNOWN"; + } +} + +export enum FieldDescriptorProto_Label { + /** LABEL_OPTIONAL - 0 is reserved for errors */ + LABEL_OPTIONAL = 1, + LABEL_REQUIRED = 2, + LABEL_REPEATED = 3, + UNRECOGNIZED = -1, +} + +export function fieldDescriptorProto_LabelFromJSON( + object: any +): FieldDescriptorProto_Label { + switch (object) { + case 1: + case "LABEL_OPTIONAL": + return FieldDescriptorProto_Label.LABEL_OPTIONAL; + case 2: + case "LABEL_REQUIRED": + return FieldDescriptorProto_Label.LABEL_REQUIRED; + case 3: + case "LABEL_REPEATED": + return FieldDescriptorProto_Label.LABEL_REPEATED; + case -1: + case "UNRECOGNIZED": + default: + return FieldDescriptorProto_Label.UNRECOGNIZED; + } +} + +export function fieldDescriptorProto_LabelToJSON( + object: FieldDescriptorProto_Label +): string { + switch (object) { + case FieldDescriptorProto_Label.LABEL_OPTIONAL: + return "LABEL_OPTIONAL"; + case FieldDescriptorProto_Label.LABEL_REQUIRED: + return "LABEL_REQUIRED"; + case FieldDescriptorProto_Label.LABEL_REPEATED: + return "LABEL_REPEATED"; + default: + return "UNKNOWN"; + } +} + +/** Describes a oneof. */ +export interface OneofDescriptorProto { + name: string; + options: OneofOptions | undefined; +} + +/** Describes an enum type. */ +export interface EnumDescriptorProto { + name: string; + value: EnumValueDescriptorProto[]; + options: EnumOptions | undefined; + /** + * Range of reserved numeric values. Reserved numeric values may not be used + * by enum values in the same enum declaration. Reserved ranges may not + * overlap. + */ + reservedRange: EnumDescriptorProto_EnumReservedRange[]; + /** + * Reserved enum value names, which may not be reused. A given name may only + * be reserved once. + */ + reservedName: string[]; +} + +/** + * Range of reserved numeric values. Reserved values may not be used by + * entries in the same enum. Reserved ranges may not overlap. + * + * Note that this is distinct from DescriptorProto.ReservedRange in that it + * is inclusive such that it can appropriately represent the entire int32 + * domain. + */ +export interface EnumDescriptorProto_EnumReservedRange { + /** Inclusive. */ + start: number; + /** Inclusive. */ + end: number; +} + +/** Describes a value within an enum. */ +export interface EnumValueDescriptorProto { + name: string; + number: number; + options: EnumValueOptions | undefined; +} + +/** Describes a service. */ +export interface ServiceDescriptorProto { + name: string; + method: MethodDescriptorProto[]; + options: ServiceOptions | undefined; +} + +/** Describes a method of a service. */ +export interface MethodDescriptorProto { + name: string; + /** + * Input and output type names. These are resolved in the same way as + * FieldDescriptorProto.type_name, but must refer to a message type. + */ + inputType: string; + outputType: string; + options: MethodOptions | undefined; + /** Identifies if client streams multiple client messages */ + clientStreaming: boolean; + /** Identifies if server streams multiple server messages */ + serverStreaming: boolean; +} + +export interface FileOptions { + /** + * Sets the Java package where classes generated from this .proto will be + * placed. By default, the proto package is used, but this is often + * inappropriate because proto packages do not normally start with backwards + * domain names. + */ + javaPackage: string; + /** + * Controls the name of the wrapper Java class generated for the .proto file. + * That class will always contain the .proto file's getDescriptor() method as + * well as any top-level extensions defined in the .proto file. + * If java_multiple_files is disabled, then all the other classes from the + * .proto file will be nested inside the single wrapper outer class. + */ + javaOuterClassname: string; + /** + * If enabled, then the Java code generator will generate a separate .java + * file for each top-level message, enum, and service defined in the .proto + * file. Thus, these types will *not* be nested inside the wrapper class + * named by java_outer_classname. However, the wrapper class will still be + * generated to contain the file's getDescriptor() method as well as any + * top-level extensions defined in the file. + */ + javaMultipleFiles: boolean; + /** + * This option does nothing. + * + * @deprecated + */ + javaGenerateEqualsAndHash: boolean; + /** + * If set true, then the Java2 code generator will generate code that + * throws an exception whenever an attempt is made to assign a non-UTF-8 + * byte sequence to a string field. + * Message reflection will do the same. + * However, an extension field still accepts non-UTF-8 byte sequences. + * This option has no effect on when used with the lite runtime. + */ + javaStringCheckUtf8: boolean; + optimizeFor: FileOptions_OptimizeMode; + /** + * Sets the Go package where structs generated from this .proto will be + * placed. If omitted, the Go package will be derived from the following: + * - The basename of the package import path, if provided. + * - Otherwise, the package statement in the .proto file, if present. + * - Otherwise, the basename of the .proto file, without extension. + */ + goPackage: string; + /** + * Should generic services be generated in each language? "Generic" services + * are not specific to any particular RPC system. They are generated by the + * main code generators in each language (without additional plugins). + * Generic services were the only kind of service generation supported by + * early versions of google.protobuf. + * + * Generic services are now considered deprecated in favor of using plugins + * that generate code specific to your particular RPC system. Therefore, + * these default to false. Old code which depends on generic services should + * explicitly set them to true. + */ + ccGenericServices: boolean; + javaGenericServices: boolean; + pyGenericServices: boolean; + phpGenericServices: boolean; + /** + * Is this file deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for everything in the file, or it will be completely ignored; in the very + * least, this is a formalization for deprecating files. + */ + deprecated: boolean; + /** + * Enables the use of arenas for the proto messages in this file. This applies + * only to generated classes for C++. + */ + ccEnableArenas: boolean; + /** + * Sets the objective c class prefix which is prepended to all objective c + * generated classes from this .proto. There is no default. + */ + objcClassPrefix: string; + /** Namespace for generated classes; defaults to the package. */ + csharpNamespace: string; + /** + * By default Swift generators will take the proto package and CamelCase it + * replacing '.' with underscore and use that to prefix the types/symbols + * defined. When this options is provided, they will use this value instead + * to prefix the types/symbols defined. + */ + swiftPrefix: string; + /** + * Sets the php class prefix which is prepended to all php generated classes + * from this .proto. Default is empty. + */ + phpClassPrefix: string; + /** + * Use this option to change the namespace of php generated classes. Default + * is empty. When this option is empty, the package name will be used for + * determining the namespace. + */ + phpNamespace: string; + /** + * Use this option to change the namespace of php generated metadata classes. + * Default is empty. When this option is empty, the proto file name will be + * used for determining the namespace. + */ + phpMetadataNamespace: string; + /** + * Use this option to change the package of ruby generated classes. Default + * is empty. When this option is not set, the package name will be used for + * determining the ruby package. + */ + rubyPackage: string; + /** + * The parser stores options it doesn't recognize here. + * See the documentation for the "Options" section above. + */ + uninterpretedOption: UninterpretedOption[]; +} + +/** Generated classes can be optimized for speed or code size. */ +export enum FileOptions_OptimizeMode { + /** SPEED - Generate complete code for parsing, serialization, */ + SPEED = 1, + /** CODE_SIZE - etc. */ + CODE_SIZE = 2, + /** LITE_RUNTIME - Generate code using MessageLite and the lite runtime. */ + LITE_RUNTIME = 3, + UNRECOGNIZED = -1, +} + +export function fileOptions_OptimizeModeFromJSON( + object: any +): FileOptions_OptimizeMode { + switch (object) { + case 1: + case "SPEED": + return FileOptions_OptimizeMode.SPEED; + case 2: + case "CODE_SIZE": + return FileOptions_OptimizeMode.CODE_SIZE; + case 3: + case "LITE_RUNTIME": + return FileOptions_OptimizeMode.LITE_RUNTIME; + case -1: + case "UNRECOGNIZED": + default: + return FileOptions_OptimizeMode.UNRECOGNIZED; + } +} + +export function fileOptions_OptimizeModeToJSON( + object: FileOptions_OptimizeMode +): string { + switch (object) { + case FileOptions_OptimizeMode.SPEED: + return "SPEED"; + case FileOptions_OptimizeMode.CODE_SIZE: + return "CODE_SIZE"; + case FileOptions_OptimizeMode.LITE_RUNTIME: + return "LITE_RUNTIME"; + default: + return "UNKNOWN"; + } +} + +export interface MessageOptions { + /** + * Set true to use the old proto1 MessageSet wire format for extensions. + * This is provided for backwards-compatibility with the MessageSet wire + * format. You should not use this for any other reason: It's less + * efficient, has fewer features, and is more complicated. + * + * The message must be defined exactly as follows: + * message Foo { + * option message_set_wire_format = true; + * extensions 4 to max; + * } + * Note that the message cannot have any defined fields; MessageSets only + * have extensions. + * + * All extensions of your type must be singular messages; e.g. they cannot + * be int32s, enums, or repeated messages. + * + * Because this is an option, the above two restrictions are not enforced by + * the protocol compiler. + */ + messageSetWireFormat: boolean; + /** + * Disables the generation of the standard "descriptor()" accessor, which can + * conflict with a field of the same name. This is meant to make migration + * from proto1 easier; new code should avoid fields named "descriptor". + */ + noStandardDescriptorAccessor: boolean; + /** + * Is this message deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the message, or it will be completely ignored; in the very least, + * this is a formalization for deprecating messages. + */ + deprecated: boolean; + /** + * Whether the message is an automatically generated map entry type for the + * maps field. + * + * For maps fields: + * map map_field = 1; + * The parsed descriptor looks like: + * message MapFieldEntry { + * option map_entry = true; + * optional KeyType key = 1; + * optional ValueType value = 2; + * } + * repeated MapFieldEntry map_field = 1; + * + * Implementations may choose not to generate the map_entry=true message, but + * use a native map in the target language to hold the keys and values. + * The reflection APIs in such implementations still need to work as + * if the field is a repeated message field. + * + * NOTE: Do not set the option in .proto files. Always use the maps syntax + * instead. The option should only be implicitly set by the proto compiler + * parser. + */ + mapEntry: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface FieldOptions { + /** + * The ctype option instructs the C++ code generator to use a different + * representation of the field than it normally would. See the specific + * options below. This option is not yet implemented in the open source + * release -- sorry, we'll try to include it in a future version! + */ + ctype: FieldOptions_CType; + /** + * The packed option can be enabled for repeated primitive fields to enable + * a more efficient representation on the wire. Rather than repeatedly + * writing the tag and type for each element, the entire array is encoded as + * a single length-delimited blob. In proto3, only explicit setting it to + * false will avoid using packed encoding. + */ + packed: boolean; + /** + * The jstype option determines the JavaScript type used for values of the + * field. The option is permitted only for 64 bit integral and fixed types + * (int64, uint64, sint64, fixed64, sfixed64). A field with jstype JS_STRING + * is represented as JavaScript string, which avoids loss of precision that + * can happen when a large value is converted to a floating point JavaScript. + * Specifying JS_NUMBER for the jstype causes the generated JavaScript code to + * use the JavaScript "number" type. The behavior of the default option + * JS_NORMAL is implementation dependent. + * + * This option is an enum to permit additional types to be added, e.g. + * goog.math.Integer. + */ + jstype: FieldOptions_JSType; + /** + * Should this field be parsed lazily? Lazy applies only to message-type + * fields. It means that when the outer message is initially parsed, the + * inner message's contents will not be parsed but instead stored in encoded + * form. The inner message will actually be parsed when it is first accessed. + * + * This is only a hint. Implementations are free to choose whether to use + * eager or lazy parsing regardless of the value of this option. However, + * setting this option true suggests that the protocol author believes that + * using lazy parsing on this field is worth the additional bookkeeping + * overhead typically needed to implement it. + * + * This option does not affect the public interface of any generated code; + * all method signatures remain the same. Furthermore, thread-safety of the + * interface is not affected by this option; const methods remain safe to + * call from multiple threads concurrently, while non-const methods continue + * to require exclusive access. + * + * + * Note that implementations may choose not to check required fields within + * a lazy sub-message. That is, calling IsInitialized() on the outer message + * may return true even if the inner message has missing required fields. + * This is necessary because otherwise the inner message would have to be + * parsed in order to perform the check, defeating the purpose of lazy + * parsing. An implementation which chooses not to check required fields + * must be consistent about it. That is, for any particular sub-message, the + * implementation must either *always* check its required fields, or *never* + * check its required fields, regardless of whether or not the message has + * been parsed. + */ + lazy: boolean; + /** + * Is this field deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for accessors, or it will be completely ignored; in the very least, this + * is a formalization for deprecating fields. + */ + deprecated: boolean; + /** For Google-internal migration only. Do not use. */ + weak: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export enum FieldOptions_CType { + /** STRING - Default mode. */ + STRING = 0, + CORD = 1, + STRING_PIECE = 2, + UNRECOGNIZED = -1, +} + +export function fieldOptions_CTypeFromJSON(object: any): FieldOptions_CType { + switch (object) { + case 0: + case "STRING": + return FieldOptions_CType.STRING; + case 1: + case "CORD": + return FieldOptions_CType.CORD; + case 2: + case "STRING_PIECE": + return FieldOptions_CType.STRING_PIECE; + case -1: + case "UNRECOGNIZED": + default: + return FieldOptions_CType.UNRECOGNIZED; + } +} + +export function fieldOptions_CTypeToJSON(object: FieldOptions_CType): string { + switch (object) { + case FieldOptions_CType.STRING: + return "STRING"; + case FieldOptions_CType.CORD: + return "CORD"; + case FieldOptions_CType.STRING_PIECE: + return "STRING_PIECE"; + default: + return "UNKNOWN"; + } +} + +export enum FieldOptions_JSType { + /** JS_NORMAL - Use the default type. */ + JS_NORMAL = 0, + /** JS_STRING - Use JavaScript strings. */ + JS_STRING = 1, + /** JS_NUMBER - Use JavaScript numbers. */ + JS_NUMBER = 2, + UNRECOGNIZED = -1, +} + +export function fieldOptions_JSTypeFromJSON(object: any): FieldOptions_JSType { + switch (object) { + case 0: + case "JS_NORMAL": + return FieldOptions_JSType.JS_NORMAL; + case 1: + case "JS_STRING": + return FieldOptions_JSType.JS_STRING; + case 2: + case "JS_NUMBER": + return FieldOptions_JSType.JS_NUMBER; + case -1: + case "UNRECOGNIZED": + default: + return FieldOptions_JSType.UNRECOGNIZED; + } +} + +export function fieldOptions_JSTypeToJSON(object: FieldOptions_JSType): string { + switch (object) { + case FieldOptions_JSType.JS_NORMAL: + return "JS_NORMAL"; + case FieldOptions_JSType.JS_STRING: + return "JS_STRING"; + case FieldOptions_JSType.JS_NUMBER: + return "JS_NUMBER"; + default: + return "UNKNOWN"; + } +} + +export interface OneofOptions { + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface EnumOptions { + /** + * Set this option to true to allow mapping different tag names to the same + * value. + */ + allowAlias: boolean; + /** + * Is this enum deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the enum, or it will be completely ignored; in the very least, this + * is a formalization for deprecating enums. + */ + deprecated: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface EnumValueOptions { + /** + * Is this enum value deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the enum value, or it will be completely ignored; in the very least, + * this is a formalization for deprecating enum values. + */ + deprecated: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface ServiceOptions { + /** + * Is this service deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the service, or it will be completely ignored; in the very least, + * this is a formalization for deprecating services. + */ + deprecated: boolean; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +export interface MethodOptions { + /** + * Is this method deprecated? + * Depending on the target platform, this can emit Deprecated annotations + * for the method, or it will be completely ignored; in the very least, + * this is a formalization for deprecating methods. + */ + deprecated: boolean; + idempotencyLevel: MethodOptions_IdempotencyLevel; + /** The parser stores options it doesn't recognize here. See above. */ + uninterpretedOption: UninterpretedOption[]; +} + +/** + * Is this method side-effect-free (or safe in HTTP parlance), or idempotent, + * or neither? HTTP based RPC implementation may choose GET verb for safe + * methods, and PUT verb for idempotent methods instead of the default POST. + */ +export enum MethodOptions_IdempotencyLevel { + IDEMPOTENCY_UNKNOWN = 0, + /** NO_SIDE_EFFECTS - implies idempotent */ + NO_SIDE_EFFECTS = 1, + /** IDEMPOTENT - idempotent, but may have side effects */ + IDEMPOTENT = 2, + UNRECOGNIZED = -1, +} + +export function methodOptions_IdempotencyLevelFromJSON( + object: any +): MethodOptions_IdempotencyLevel { + switch (object) { + case 0: + case "IDEMPOTENCY_UNKNOWN": + return MethodOptions_IdempotencyLevel.IDEMPOTENCY_UNKNOWN; + case 1: + case "NO_SIDE_EFFECTS": + return MethodOptions_IdempotencyLevel.NO_SIDE_EFFECTS; + case 2: + case "IDEMPOTENT": + return MethodOptions_IdempotencyLevel.IDEMPOTENT; + case -1: + case "UNRECOGNIZED": + default: + return MethodOptions_IdempotencyLevel.UNRECOGNIZED; + } +} + +export function methodOptions_IdempotencyLevelToJSON( + object: MethodOptions_IdempotencyLevel +): string { + switch (object) { + case MethodOptions_IdempotencyLevel.IDEMPOTENCY_UNKNOWN: + return "IDEMPOTENCY_UNKNOWN"; + case MethodOptions_IdempotencyLevel.NO_SIDE_EFFECTS: + return "NO_SIDE_EFFECTS"; + case MethodOptions_IdempotencyLevel.IDEMPOTENT: + return "IDEMPOTENT"; + default: + return "UNKNOWN"; + } +} + +/** + * A message representing a option the parser does not recognize. This only + * appears in options protos created by the compiler::Parser class. + * DescriptorPool resolves these when building Descriptor objects. Therefore, + * options protos in descriptor objects (e.g. returned by Descriptor::options(), + * or produced by Descriptor::CopyTo()) will never have UninterpretedOptions + * in them. + */ +export interface UninterpretedOption { + name: UninterpretedOption_NamePart[]; + /** + * The value of the uninterpreted option, in whatever type the tokenizer + * identified it as during parsing. Exactly one of these should be set. + */ + identifierValue: string; + positiveIntValue: number; + negativeIntValue: number; + doubleValue: number; + stringValue: Uint8Array; + aggregateValue: string; +} + +/** + * The name of the uninterpreted option. Each string represents a segment in + * a dot-separated name. is_extension is true iff a segment represents an + * extension (denoted with parentheses in options specs in .proto files). + * E.g.,{ ["foo", false], ["bar.baz", true], ["qux", false] } represents + * "foo.(bar.baz).qux". + */ +export interface UninterpretedOption_NamePart { + namePart: string; + isExtension: boolean; +} + +/** + * Encapsulates information about the original source file from which a + * FileDescriptorProto was generated. + */ +export interface SourceCodeInfo { + /** + * A Location identifies a piece of source code in a .proto file which + * corresponds to a particular definition. This information is intended + * to be useful to IDEs, code indexers, documentation generators, and similar + * tools. + * + * For example, say we have a file like: + * message Foo { + * optional string foo = 1; + * } + * Let's look at just the field definition: + * optional string foo = 1; + * ^ ^^ ^^ ^ ^^^ + * a bc de f ghi + * We have the following locations: + * span path represents + * [a,i) [ 4, 0, 2, 0 ] The whole field definition. + * [a,b) [ 4, 0, 2, 0, 4 ] The label (optional). + * [c,d) [ 4, 0, 2, 0, 5 ] The type (string). + * [e,f) [ 4, 0, 2, 0, 1 ] The name (foo). + * [g,h) [ 4, 0, 2, 0, 3 ] The number (1). + * + * Notes: + * - A location may refer to a repeated field itself (i.e. not to any + * particular index within it). This is used whenever a set of elements are + * logically enclosed in a single code segment. For example, an entire + * extend block (possibly containing multiple extension definitions) will + * have an outer location whose path refers to the "extensions" repeated + * field without an index. + * - Multiple locations may have the same path. This happens when a single + * logical declaration is spread out across multiple places. The most + * obvious example is the "extend" block again -- there may be multiple + * extend blocks in the same scope, each of which will have the same path. + * - A location's span is not always a subset of its parent's span. For + * example, the "extendee" of an extension declaration appears at the + * beginning of the "extend" block and is shared by all extensions within + * the block. + * - Just because a location's span is a subset of some other location's span + * does not mean that it is a descendant. For example, a "group" defines + * both a type and a field in a single declaration. Thus, the locations + * corresponding to the type and field and their components will overlap. + * - Code which tries to interpret locations should probably be designed to + * ignore those that it doesn't understand, as more types of locations could + * be recorded in the future. + */ + location: SourceCodeInfo_Location[]; +} + +export interface SourceCodeInfo_Location { + /** + * Identifies which part of the FileDescriptorProto was defined at this + * location. + * + * Each element is a field number or an index. They form a path from + * the root FileDescriptorProto to the place where the definition. For + * example, this path: + * [ 4, 3, 2, 7, 1 ] + * refers to: + * file.message_type(3) // 4, 3 + * .field(7) // 2, 7 + * .name() // 1 + * This is because FileDescriptorProto.message_type has field number 4: + * repeated DescriptorProto message_type = 4; + * and DescriptorProto.field has field number 2: + * repeated FieldDescriptorProto field = 2; + * and FieldDescriptorProto.name has field number 1: + * optional string name = 1; + * + * Thus, the above path gives the location of a field name. If we removed + * the last element: + * [ 4, 3, 2, 7 ] + * this path refers to the whole field declaration (from the beginning + * of the label to the terminating semicolon). + */ + path: number[]; + /** + * Always has exactly three or four elements: start line, start column, + * end line (optional, otherwise assumed same as start line), end column. + * These are packed into a single field for efficiency. Note that line + * and column numbers are zero-based -- typically you will want to add + * 1 to each before displaying to a user. + */ + span: number[]; + /** + * If this SourceCodeInfo represents a complete declaration, these are any + * comments appearing before and after the declaration which appear to be + * attached to the declaration. + * + * A series of line comments appearing on consecutive lines, with no other + * tokens appearing on those lines, will be treated as a single comment. + * + * leading_detached_comments will keep paragraphs of comments that appear + * before (but not connected to) the current element. Each paragraph, + * separated by empty lines, will be one comment element in the repeated + * field. + * + * Only the comment content is provided; comment markers (e.g. //) are + * stripped out. For block comments, leading whitespace and an asterisk + * will be stripped from the beginning of each line other than the first. + * Newlines are included in the output. + * + * Examples: + * + * optional int32 foo = 1; // Comment attached to foo. + * // Comment attached to bar. + * optional int32 bar = 2; + * + * optional string baz = 3; + * // Comment attached to baz. + * // Another line attached to baz. + * + * // Comment attached to qux. + * // + * // Another line attached to qux. + * optional double qux = 4; + * + * // Detached comment for corge. This is not leading or trailing comments + * // to qux or corge because there are blank lines separating it from + * // both. + * + * // Detached comment for corge paragraph 2. + * + * optional string corge = 5; + * /* Block comment attached + * * to corge. Leading asterisks + * * will be removed. * / + * /* Block comment attached to + * * grault. * / + * optional int32 grault = 6; + * + * // ignored detached comments. + */ + leadingComments: string; + trailingComments: string; + leadingDetachedComments: string[]; +} + +/** + * Describes the relationship between generated code and its original source + * file. A GeneratedCodeInfo message is associated with only one generated + * source file, but may contain references to different source .proto files. + */ +export interface GeneratedCodeInfo { + /** + * An Annotation connects some span of text in generated code to an element + * of its generating .proto file. + */ + annotation: GeneratedCodeInfo_Annotation[]; +} + +export interface GeneratedCodeInfo_Annotation { + /** + * Identifies the element in the original source .proto file. This field + * is formatted the same as SourceCodeInfo.Location.path. + */ + path: number[]; + /** Identifies the filesystem path to the original source .proto. */ + sourceFile: string; + /** + * Identifies the starting offset in bytes in the generated code + * that relates to the identified object. + */ + begin: number; + /** + * Identifies the ending offset in bytes in the generated code that + * relates to the identified offset. The end offset should be one past + * the last relevant byte (so the length of the text = end - begin). + */ + end: number; +} + +const baseFileDescriptorSet: object = {}; + +export const FileDescriptorSet = { + encode(message: FileDescriptorSet, writer: Writer = Writer.create()): Writer { + for (const v of message.file) { + FileDescriptorProto.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FileDescriptorSet { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFileDescriptorSet } as FileDescriptorSet; + message.file = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.file.push( + FileDescriptorProto.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FileDescriptorSet { + const message = { ...baseFileDescriptorSet } as FileDescriptorSet; + message.file = []; + if (object.file !== undefined && object.file !== null) { + for (const e of object.file) { + message.file.push(FileDescriptorProto.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: FileDescriptorSet): unknown { + const obj: any = {}; + if (message.file) { + obj.file = message.file.map((e) => + e ? FileDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.file = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): FileDescriptorSet { + const message = { ...baseFileDescriptorSet } as FileDescriptorSet; + message.file = []; + if (object.file !== undefined && object.file !== null) { + for (const e of object.file) { + message.file.push(FileDescriptorProto.fromPartial(e)); + } + } + return message; + }, +}; + +const baseFileDescriptorProto: object = { + name: "", + package: "", + dependency: "", + publicDependency: 0, + weakDependency: 0, + syntax: "", +}; + +export const FileDescriptorProto = { + encode( + message: FileDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.package !== "") { + writer.uint32(18).string(message.package); + } + for (const v of message.dependency) { + writer.uint32(26).string(v!); + } + writer.uint32(82).fork(); + for (const v of message.publicDependency) { + writer.int32(v); + } + writer.ldelim(); + writer.uint32(90).fork(); + for (const v of message.weakDependency) { + writer.int32(v); + } + writer.ldelim(); + for (const v of message.messageType) { + DescriptorProto.encode(v!, writer.uint32(34).fork()).ldelim(); + } + for (const v of message.enumType) { + EnumDescriptorProto.encode(v!, writer.uint32(42).fork()).ldelim(); + } + for (const v of message.service) { + ServiceDescriptorProto.encode(v!, writer.uint32(50).fork()).ldelim(); + } + for (const v of message.extension) { + FieldDescriptorProto.encode(v!, writer.uint32(58).fork()).ldelim(); + } + if (message.options !== undefined) { + FileOptions.encode(message.options, writer.uint32(66).fork()).ldelim(); + } + if (message.sourceCodeInfo !== undefined) { + SourceCodeInfo.encode( + message.sourceCodeInfo, + writer.uint32(74).fork() + ).ldelim(); + } + if (message.syntax !== "") { + writer.uint32(98).string(message.syntax); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FileDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFileDescriptorProto } as FileDescriptorProto; + message.dependency = []; + message.publicDependency = []; + message.weakDependency = []; + message.messageType = []; + message.enumType = []; + message.service = []; + message.extension = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.package = reader.string(); + break; + case 3: + message.dependency.push(reader.string()); + break; + case 10: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.publicDependency.push(reader.int32()); + } + } else { + message.publicDependency.push(reader.int32()); + } + break; + case 11: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.weakDependency.push(reader.int32()); + } + } else { + message.weakDependency.push(reader.int32()); + } + break; + case 4: + message.messageType.push( + DescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 5: + message.enumType.push( + EnumDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 6: + message.service.push( + ServiceDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 7: + message.extension.push( + FieldDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 8: + message.options = FileOptions.decode(reader, reader.uint32()); + break; + case 9: + message.sourceCodeInfo = SourceCodeInfo.decode( + reader, + reader.uint32() + ); + break; + case 12: + message.syntax = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FileDescriptorProto { + const message = { ...baseFileDescriptorProto } as FileDescriptorProto; + message.dependency = []; + message.publicDependency = []; + message.weakDependency = []; + message.messageType = []; + message.enumType = []; + message.service = []; + message.extension = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.package !== undefined && object.package !== null) { + message.package = String(object.package); + } else { + message.package = ""; + } + if (object.dependency !== undefined && object.dependency !== null) { + for (const e of object.dependency) { + message.dependency.push(String(e)); + } + } + if ( + object.publicDependency !== undefined && + object.publicDependency !== null + ) { + for (const e of object.publicDependency) { + message.publicDependency.push(Number(e)); + } + } + if (object.weakDependency !== undefined && object.weakDependency !== null) { + for (const e of object.weakDependency) { + message.weakDependency.push(Number(e)); + } + } + if (object.messageType !== undefined && object.messageType !== null) { + for (const e of object.messageType) { + message.messageType.push(DescriptorProto.fromJSON(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromJSON(e)); + } + } + if (object.service !== undefined && object.service !== null) { + for (const e of object.service) { + message.service.push(ServiceDescriptorProto.fromJSON(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = FileOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.sourceCodeInfo !== undefined && object.sourceCodeInfo !== null) { + message.sourceCodeInfo = SourceCodeInfo.fromJSON(object.sourceCodeInfo); + } else { + message.sourceCodeInfo = undefined; + } + if (object.syntax !== undefined && object.syntax !== null) { + message.syntax = String(object.syntax); + } else { + message.syntax = ""; + } + return message; + }, + + toJSON(message: FileDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.package !== undefined && (obj.package = message.package); + if (message.dependency) { + obj.dependency = message.dependency.map((e) => e); + } else { + obj.dependency = []; + } + if (message.publicDependency) { + obj.publicDependency = message.publicDependency.map((e) => e); + } else { + obj.publicDependency = []; + } + if (message.weakDependency) { + obj.weakDependency = message.weakDependency.map((e) => e); + } else { + obj.weakDependency = []; + } + if (message.messageType) { + obj.messageType = message.messageType.map((e) => + e ? DescriptorProto.toJSON(e) : undefined + ); + } else { + obj.messageType = []; + } + if (message.enumType) { + obj.enumType = message.enumType.map((e) => + e ? EnumDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.enumType = []; + } + if (message.service) { + obj.service = message.service.map((e) => + e ? ServiceDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.service = []; + } + if (message.extension) { + obj.extension = message.extension.map((e) => + e ? FieldDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.extension = []; + } + message.options !== undefined && + (obj.options = message.options + ? FileOptions.toJSON(message.options) + : undefined); + message.sourceCodeInfo !== undefined && + (obj.sourceCodeInfo = message.sourceCodeInfo + ? SourceCodeInfo.toJSON(message.sourceCodeInfo) + : undefined); + message.syntax !== undefined && (obj.syntax = message.syntax); + return obj; + }, + + fromPartial(object: DeepPartial): FileDescriptorProto { + const message = { ...baseFileDescriptorProto } as FileDescriptorProto; + message.dependency = []; + message.publicDependency = []; + message.weakDependency = []; + message.messageType = []; + message.enumType = []; + message.service = []; + message.extension = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.package !== undefined && object.package !== null) { + message.package = object.package; + } else { + message.package = ""; + } + if (object.dependency !== undefined && object.dependency !== null) { + for (const e of object.dependency) { + message.dependency.push(e); + } + } + if ( + object.publicDependency !== undefined && + object.publicDependency !== null + ) { + for (const e of object.publicDependency) { + message.publicDependency.push(e); + } + } + if (object.weakDependency !== undefined && object.weakDependency !== null) { + for (const e of object.weakDependency) { + message.weakDependency.push(e); + } + } + if (object.messageType !== undefined && object.messageType !== null) { + for (const e of object.messageType) { + message.messageType.push(DescriptorProto.fromPartial(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromPartial(e)); + } + } + if (object.service !== undefined && object.service !== null) { + for (const e of object.service) { + message.service.push(ServiceDescriptorProto.fromPartial(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = FileOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.sourceCodeInfo !== undefined && object.sourceCodeInfo !== null) { + message.sourceCodeInfo = SourceCodeInfo.fromPartial( + object.sourceCodeInfo + ); + } else { + message.sourceCodeInfo = undefined; + } + if (object.syntax !== undefined && object.syntax !== null) { + message.syntax = object.syntax; + } else { + message.syntax = ""; + } + return message; + }, +}; + +const baseDescriptorProto: object = { name: "", reservedName: "" }; + +export const DescriptorProto = { + encode(message: DescriptorProto, writer: Writer = Writer.create()): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + for (const v of message.field) { + FieldDescriptorProto.encode(v!, writer.uint32(18).fork()).ldelim(); + } + for (const v of message.extension) { + FieldDescriptorProto.encode(v!, writer.uint32(50).fork()).ldelim(); + } + for (const v of message.nestedType) { + DescriptorProto.encode(v!, writer.uint32(26).fork()).ldelim(); + } + for (const v of message.enumType) { + EnumDescriptorProto.encode(v!, writer.uint32(34).fork()).ldelim(); + } + for (const v of message.extensionRange) { + DescriptorProto_ExtensionRange.encode( + v!, + writer.uint32(42).fork() + ).ldelim(); + } + for (const v of message.oneofDecl) { + OneofDescriptorProto.encode(v!, writer.uint32(66).fork()).ldelim(); + } + if (message.options !== undefined) { + MessageOptions.encode(message.options, writer.uint32(58).fork()).ldelim(); + } + for (const v of message.reservedRange) { + DescriptorProto_ReservedRange.encode( + v!, + writer.uint32(74).fork() + ).ldelim(); + } + for (const v of message.reservedName) { + writer.uint32(82).string(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): DescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseDescriptorProto } as DescriptorProto; + message.field = []; + message.extension = []; + message.nestedType = []; + message.enumType = []; + message.extensionRange = []; + message.oneofDecl = []; + message.reservedRange = []; + message.reservedName = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.field.push( + FieldDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 6: + message.extension.push( + FieldDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 3: + message.nestedType.push( + DescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 4: + message.enumType.push( + EnumDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 5: + message.extensionRange.push( + DescriptorProto_ExtensionRange.decode(reader, reader.uint32()) + ); + break; + case 8: + message.oneofDecl.push( + OneofDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 7: + message.options = MessageOptions.decode(reader, reader.uint32()); + break; + case 9: + message.reservedRange.push( + DescriptorProto_ReservedRange.decode(reader, reader.uint32()) + ); + break; + case 10: + message.reservedName.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DescriptorProto { + const message = { ...baseDescriptorProto } as DescriptorProto; + message.field = []; + message.extension = []; + message.nestedType = []; + message.enumType = []; + message.extensionRange = []; + message.oneofDecl = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.field !== undefined && object.field !== null) { + for (const e of object.field) { + message.field.push(FieldDescriptorProto.fromJSON(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromJSON(e)); + } + } + if (object.nestedType !== undefined && object.nestedType !== null) { + for (const e of object.nestedType) { + message.nestedType.push(DescriptorProto.fromJSON(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromJSON(e)); + } + } + if (object.extensionRange !== undefined && object.extensionRange !== null) { + for (const e of object.extensionRange) { + message.extensionRange.push(DescriptorProto_ExtensionRange.fromJSON(e)); + } + } + if (object.oneofDecl !== undefined && object.oneofDecl !== null) { + for (const e of object.oneofDecl) { + message.oneofDecl.push(OneofDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = MessageOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push(DescriptorProto_ReservedRange.fromJSON(e)); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(String(e)); + } + } + return message; + }, + + toJSON(message: DescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + if (message.field) { + obj.field = message.field.map((e) => + e ? FieldDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.field = []; + } + if (message.extension) { + obj.extension = message.extension.map((e) => + e ? FieldDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.extension = []; + } + if (message.nestedType) { + obj.nestedType = message.nestedType.map((e) => + e ? DescriptorProto.toJSON(e) : undefined + ); + } else { + obj.nestedType = []; + } + if (message.enumType) { + obj.enumType = message.enumType.map((e) => + e ? EnumDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.enumType = []; + } + if (message.extensionRange) { + obj.extensionRange = message.extensionRange.map((e) => + e ? DescriptorProto_ExtensionRange.toJSON(e) : undefined + ); + } else { + obj.extensionRange = []; + } + if (message.oneofDecl) { + obj.oneofDecl = message.oneofDecl.map((e) => + e ? OneofDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.oneofDecl = []; + } + message.options !== undefined && + (obj.options = message.options + ? MessageOptions.toJSON(message.options) + : undefined); + if (message.reservedRange) { + obj.reservedRange = message.reservedRange.map((e) => + e ? DescriptorProto_ReservedRange.toJSON(e) : undefined + ); + } else { + obj.reservedRange = []; + } + if (message.reservedName) { + obj.reservedName = message.reservedName.map((e) => e); + } else { + obj.reservedName = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): DescriptorProto { + const message = { ...baseDescriptorProto } as DescriptorProto; + message.field = []; + message.extension = []; + message.nestedType = []; + message.enumType = []; + message.extensionRange = []; + message.oneofDecl = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.field !== undefined && object.field !== null) { + for (const e of object.field) { + message.field.push(FieldDescriptorProto.fromPartial(e)); + } + } + if (object.extension !== undefined && object.extension !== null) { + for (const e of object.extension) { + message.extension.push(FieldDescriptorProto.fromPartial(e)); + } + } + if (object.nestedType !== undefined && object.nestedType !== null) { + for (const e of object.nestedType) { + message.nestedType.push(DescriptorProto.fromPartial(e)); + } + } + if (object.enumType !== undefined && object.enumType !== null) { + for (const e of object.enumType) { + message.enumType.push(EnumDescriptorProto.fromPartial(e)); + } + } + if (object.extensionRange !== undefined && object.extensionRange !== null) { + for (const e of object.extensionRange) { + message.extensionRange.push( + DescriptorProto_ExtensionRange.fromPartial(e) + ); + } + } + if (object.oneofDecl !== undefined && object.oneofDecl !== null) { + for (const e of object.oneofDecl) { + message.oneofDecl.push(OneofDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = MessageOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push( + DescriptorProto_ReservedRange.fromPartial(e) + ); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(e); + } + } + return message; + }, +}; + +const baseDescriptorProto_ExtensionRange: object = { start: 0, end: 0 }; + +export const DescriptorProto_ExtensionRange = { + encode( + message: DescriptorProto_ExtensionRange, + writer: Writer = Writer.create() + ): Writer { + if (message.start !== 0) { + writer.uint32(8).int32(message.start); + } + if (message.end !== 0) { + writer.uint32(16).int32(message.end); + } + if (message.options !== undefined) { + ExtensionRangeOptions.encode( + message.options, + writer.uint32(26).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): DescriptorProto_ExtensionRange { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseDescriptorProto_ExtensionRange, + } as DescriptorProto_ExtensionRange; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.start = reader.int32(); + break; + case 2: + message.end = reader.int32(); + break; + case 3: + message.options = ExtensionRangeOptions.decode( + reader, + reader.uint32() + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DescriptorProto_ExtensionRange { + const message = { + ...baseDescriptorProto_ExtensionRange, + } as DescriptorProto_ExtensionRange; + if (object.start !== undefined && object.start !== null) { + message.start = Number(object.start); + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = ExtensionRangeOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: DescriptorProto_ExtensionRange): unknown { + const obj: any = {}; + message.start !== undefined && (obj.start = message.start); + message.end !== undefined && (obj.end = message.end); + message.options !== undefined && + (obj.options = message.options + ? ExtensionRangeOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): DescriptorProto_ExtensionRange { + const message = { + ...baseDescriptorProto_ExtensionRange, + } as DescriptorProto_ExtensionRange; + if (object.start !== undefined && object.start !== null) { + message.start = object.start; + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = ExtensionRangeOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseDescriptorProto_ReservedRange: object = { start: 0, end: 0 }; + +export const DescriptorProto_ReservedRange = { + encode( + message: DescriptorProto_ReservedRange, + writer: Writer = Writer.create() + ): Writer { + if (message.start !== 0) { + writer.uint32(8).int32(message.start); + } + if (message.end !== 0) { + writer.uint32(16).int32(message.end); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): DescriptorProto_ReservedRange { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseDescriptorProto_ReservedRange, + } as DescriptorProto_ReservedRange; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.start = reader.int32(); + break; + case 2: + message.end = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): DescriptorProto_ReservedRange { + const message = { + ...baseDescriptorProto_ReservedRange, + } as DescriptorProto_ReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = Number(object.start); + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + return message; + }, + + toJSON(message: DescriptorProto_ReservedRange): unknown { + const obj: any = {}; + message.start !== undefined && (obj.start = message.start); + message.end !== undefined && (obj.end = message.end); + return obj; + }, + + fromPartial( + object: DeepPartial + ): DescriptorProto_ReservedRange { + const message = { + ...baseDescriptorProto_ReservedRange, + } as DescriptorProto_ReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = object.start; + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + return message; + }, +}; + +const baseExtensionRangeOptions: object = {}; + +export const ExtensionRangeOptions = { + encode( + message: ExtensionRangeOptions, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ExtensionRangeOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseExtensionRangeOptions } as ExtensionRangeOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ExtensionRangeOptions { + const message = { ...baseExtensionRangeOptions } as ExtensionRangeOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: ExtensionRangeOptions): unknown { + const obj: any = {}; + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial( + object: DeepPartial + ): ExtensionRangeOptions { + const message = { ...baseExtensionRangeOptions } as ExtensionRangeOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseFieldDescriptorProto: object = { + name: "", + number: 0, + label: 1, + type: 1, + typeName: "", + extendee: "", + defaultValue: "", + oneofIndex: 0, + jsonName: "", + proto3Optional: false, +}; + +export const FieldDescriptorProto = { + encode( + message: FieldDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.number !== 0) { + writer.uint32(24).int32(message.number); + } + if (message.label !== 1) { + writer.uint32(32).int32(message.label); + } + if (message.type !== 1) { + writer.uint32(40).int32(message.type); + } + if (message.typeName !== "") { + writer.uint32(50).string(message.typeName); + } + if (message.extendee !== "") { + writer.uint32(18).string(message.extendee); + } + if (message.defaultValue !== "") { + writer.uint32(58).string(message.defaultValue); + } + if (message.oneofIndex !== 0) { + writer.uint32(72).int32(message.oneofIndex); + } + if (message.jsonName !== "") { + writer.uint32(82).string(message.jsonName); + } + if (message.options !== undefined) { + FieldOptions.encode(message.options, writer.uint32(66).fork()).ldelim(); + } + if (message.proto3Optional === true) { + writer.uint32(136).bool(message.proto3Optional); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FieldDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFieldDescriptorProto } as FieldDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 3: + message.number = reader.int32(); + break; + case 4: + message.label = reader.int32() as any; + break; + case 5: + message.type = reader.int32() as any; + break; + case 6: + message.typeName = reader.string(); + break; + case 2: + message.extendee = reader.string(); + break; + case 7: + message.defaultValue = reader.string(); + break; + case 9: + message.oneofIndex = reader.int32(); + break; + case 10: + message.jsonName = reader.string(); + break; + case 8: + message.options = FieldOptions.decode(reader, reader.uint32()); + break; + case 17: + message.proto3Optional = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FieldDescriptorProto { + const message = { ...baseFieldDescriptorProto } as FieldDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = Number(object.number); + } else { + message.number = 0; + } + if (object.label !== undefined && object.label !== null) { + message.label = fieldDescriptorProto_LabelFromJSON(object.label); + } else { + message.label = 1; + } + if (object.type !== undefined && object.type !== null) { + message.type = fieldDescriptorProto_TypeFromJSON(object.type); + } else { + message.type = 1; + } + if (object.typeName !== undefined && object.typeName !== null) { + message.typeName = String(object.typeName); + } else { + message.typeName = ""; + } + if (object.extendee !== undefined && object.extendee !== null) { + message.extendee = String(object.extendee); + } else { + message.extendee = ""; + } + if (object.defaultValue !== undefined && object.defaultValue !== null) { + message.defaultValue = String(object.defaultValue); + } else { + message.defaultValue = ""; + } + if (object.oneofIndex !== undefined && object.oneofIndex !== null) { + message.oneofIndex = Number(object.oneofIndex); + } else { + message.oneofIndex = 0; + } + if (object.jsonName !== undefined && object.jsonName !== null) { + message.jsonName = String(object.jsonName); + } else { + message.jsonName = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = FieldOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.proto3Optional !== undefined && object.proto3Optional !== null) { + message.proto3Optional = Boolean(object.proto3Optional); + } else { + message.proto3Optional = false; + } + return message; + }, + + toJSON(message: FieldDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.number !== undefined && (obj.number = message.number); + message.label !== undefined && + (obj.label = fieldDescriptorProto_LabelToJSON(message.label)); + message.type !== undefined && + (obj.type = fieldDescriptorProto_TypeToJSON(message.type)); + message.typeName !== undefined && (obj.typeName = message.typeName); + message.extendee !== undefined && (obj.extendee = message.extendee); + message.defaultValue !== undefined && + (obj.defaultValue = message.defaultValue); + message.oneofIndex !== undefined && (obj.oneofIndex = message.oneofIndex); + message.jsonName !== undefined && (obj.jsonName = message.jsonName); + message.options !== undefined && + (obj.options = message.options + ? FieldOptions.toJSON(message.options) + : undefined); + message.proto3Optional !== undefined && + (obj.proto3Optional = message.proto3Optional); + return obj; + }, + + fromPartial(object: DeepPartial): FieldDescriptorProto { + const message = { ...baseFieldDescriptorProto } as FieldDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = object.number; + } else { + message.number = 0; + } + if (object.label !== undefined && object.label !== null) { + message.label = object.label; + } else { + message.label = 1; + } + if (object.type !== undefined && object.type !== null) { + message.type = object.type; + } else { + message.type = 1; + } + if (object.typeName !== undefined && object.typeName !== null) { + message.typeName = object.typeName; + } else { + message.typeName = ""; + } + if (object.extendee !== undefined && object.extendee !== null) { + message.extendee = object.extendee; + } else { + message.extendee = ""; + } + if (object.defaultValue !== undefined && object.defaultValue !== null) { + message.defaultValue = object.defaultValue; + } else { + message.defaultValue = ""; + } + if (object.oneofIndex !== undefined && object.oneofIndex !== null) { + message.oneofIndex = object.oneofIndex; + } else { + message.oneofIndex = 0; + } + if (object.jsonName !== undefined && object.jsonName !== null) { + message.jsonName = object.jsonName; + } else { + message.jsonName = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = FieldOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.proto3Optional !== undefined && object.proto3Optional !== null) { + message.proto3Optional = object.proto3Optional; + } else { + message.proto3Optional = false; + } + return message; + }, +}; + +const baseOneofDescriptorProto: object = { name: "" }; + +export const OneofDescriptorProto = { + encode( + message: OneofDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.options !== undefined) { + OneofOptions.encode(message.options, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): OneofDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseOneofDescriptorProto } as OneofDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.options = OneofOptions.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): OneofDescriptorProto { + const message = { ...baseOneofDescriptorProto } as OneofDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = OneofOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: OneofDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.options !== undefined && + (obj.options = message.options + ? OneofOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): OneofDescriptorProto { + const message = { ...baseOneofDescriptorProto } as OneofDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = OneofOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseEnumDescriptorProto: object = { name: "", reservedName: "" }; + +export const EnumDescriptorProto = { + encode( + message: EnumDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + for (const v of message.value) { + EnumValueDescriptorProto.encode(v!, writer.uint32(18).fork()).ldelim(); + } + if (message.options !== undefined) { + EnumOptions.encode(message.options, writer.uint32(26).fork()).ldelim(); + } + for (const v of message.reservedRange) { + EnumDescriptorProto_EnumReservedRange.encode( + v!, + writer.uint32(34).fork() + ).ldelim(); + } + for (const v of message.reservedName) { + writer.uint32(42).string(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): EnumDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseEnumDescriptorProto } as EnumDescriptorProto; + message.value = []; + message.reservedRange = []; + message.reservedName = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.value.push( + EnumValueDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 3: + message.options = EnumOptions.decode(reader, reader.uint32()); + break; + case 4: + message.reservedRange.push( + EnumDescriptorProto_EnumReservedRange.decode( + reader, + reader.uint32() + ) + ); + break; + case 5: + message.reservedName.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumDescriptorProto { + const message = { ...baseEnumDescriptorProto } as EnumDescriptorProto; + message.value = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.value !== undefined && object.value !== null) { + for (const e of object.value) { + message.value.push(EnumValueDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push( + EnumDescriptorProto_EnumReservedRange.fromJSON(e) + ); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(String(e)); + } + } + return message; + }, + + toJSON(message: EnumDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + if (message.value) { + obj.value = message.value.map((e) => + e ? EnumValueDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.value = []; + } + message.options !== undefined && + (obj.options = message.options + ? EnumOptions.toJSON(message.options) + : undefined); + if (message.reservedRange) { + obj.reservedRange = message.reservedRange.map((e) => + e ? EnumDescriptorProto_EnumReservedRange.toJSON(e) : undefined + ); + } else { + obj.reservedRange = []; + } + if (message.reservedName) { + obj.reservedName = message.reservedName.map((e) => e); + } else { + obj.reservedName = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): EnumDescriptorProto { + const message = { ...baseEnumDescriptorProto } as EnumDescriptorProto; + message.value = []; + message.reservedRange = []; + message.reservedName = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.value !== undefined && object.value !== null) { + for (const e of object.value) { + message.value.push(EnumValueDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if (object.reservedRange !== undefined && object.reservedRange !== null) { + for (const e of object.reservedRange) { + message.reservedRange.push( + EnumDescriptorProto_EnumReservedRange.fromPartial(e) + ); + } + } + if (object.reservedName !== undefined && object.reservedName !== null) { + for (const e of object.reservedName) { + message.reservedName.push(e); + } + } + return message; + }, +}; + +const baseEnumDescriptorProto_EnumReservedRange: object = { start: 0, end: 0 }; + +export const EnumDescriptorProto_EnumReservedRange = { + encode( + message: EnumDescriptorProto_EnumReservedRange, + writer: Writer = Writer.create() + ): Writer { + if (message.start !== 0) { + writer.uint32(8).int32(message.start); + } + if (message.end !== 0) { + writer.uint32(16).int32(message.end); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): EnumDescriptorProto_EnumReservedRange { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseEnumDescriptorProto_EnumReservedRange, + } as EnumDescriptorProto_EnumReservedRange; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.start = reader.int32(); + break; + case 2: + message.end = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumDescriptorProto_EnumReservedRange { + const message = { + ...baseEnumDescriptorProto_EnumReservedRange, + } as EnumDescriptorProto_EnumReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = Number(object.start); + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + return message; + }, + + toJSON(message: EnumDescriptorProto_EnumReservedRange): unknown { + const obj: any = {}; + message.start !== undefined && (obj.start = message.start); + message.end !== undefined && (obj.end = message.end); + return obj; + }, + + fromPartial( + object: DeepPartial + ): EnumDescriptorProto_EnumReservedRange { + const message = { + ...baseEnumDescriptorProto_EnumReservedRange, + } as EnumDescriptorProto_EnumReservedRange; + if (object.start !== undefined && object.start !== null) { + message.start = object.start; + } else { + message.start = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + return message; + }, +}; + +const baseEnumValueDescriptorProto: object = { name: "", number: 0 }; + +export const EnumValueDescriptorProto = { + encode( + message: EnumValueDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.number !== 0) { + writer.uint32(16).int32(message.number); + } + if (message.options !== undefined) { + EnumValueOptions.encode( + message.options, + writer.uint32(26).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): EnumValueDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseEnumValueDescriptorProto, + } as EnumValueDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.number = reader.int32(); + break; + case 3: + message.options = EnumValueOptions.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumValueDescriptorProto { + const message = { + ...baseEnumValueDescriptorProto, + } as EnumValueDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = Number(object.number); + } else { + message.number = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumValueOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: EnumValueDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.number !== undefined && (obj.number = message.number); + message.options !== undefined && + (obj.options = message.options + ? EnumValueOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): EnumValueDescriptorProto { + const message = { + ...baseEnumValueDescriptorProto, + } as EnumValueDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.number !== undefined && object.number !== null) { + message.number = object.number; + } else { + message.number = 0; + } + if (object.options !== undefined && object.options !== null) { + message.options = EnumValueOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseServiceDescriptorProto: object = { name: "" }; + +export const ServiceDescriptorProto = { + encode( + message: ServiceDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + for (const v of message.method) { + MethodDescriptorProto.encode(v!, writer.uint32(18).fork()).ldelim(); + } + if (message.options !== undefined) { + ServiceOptions.encode(message.options, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ServiceDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseServiceDescriptorProto } as ServiceDescriptorProto; + message.method = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.method.push( + MethodDescriptorProto.decode(reader, reader.uint32()) + ); + break; + case 3: + message.options = ServiceOptions.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ServiceDescriptorProto { + const message = { ...baseServiceDescriptorProto } as ServiceDescriptorProto; + message.method = []; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.method !== undefined && object.method !== null) { + for (const e of object.method) { + message.method.push(MethodDescriptorProto.fromJSON(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = ServiceOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + return message; + }, + + toJSON(message: ServiceDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + if (message.method) { + obj.method = message.method.map((e) => + e ? MethodDescriptorProto.toJSON(e) : undefined + ); + } else { + obj.method = []; + } + message.options !== undefined && + (obj.options = message.options + ? ServiceOptions.toJSON(message.options) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): ServiceDescriptorProto { + const message = { ...baseServiceDescriptorProto } as ServiceDescriptorProto; + message.method = []; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.method !== undefined && object.method !== null) { + for (const e of object.method) { + message.method.push(MethodDescriptorProto.fromPartial(e)); + } + } + if (object.options !== undefined && object.options !== null) { + message.options = ServiceOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + return message; + }, +}; + +const baseMethodDescriptorProto: object = { + name: "", + inputType: "", + outputType: "", + clientStreaming: false, + serverStreaming: false, +}; + +export const MethodDescriptorProto = { + encode( + message: MethodDescriptorProto, + writer: Writer = Writer.create() + ): Writer { + if (message.name !== "") { + writer.uint32(10).string(message.name); + } + if (message.inputType !== "") { + writer.uint32(18).string(message.inputType); + } + if (message.outputType !== "") { + writer.uint32(26).string(message.outputType); + } + if (message.options !== undefined) { + MethodOptions.encode(message.options, writer.uint32(34).fork()).ldelim(); + } + if (message.clientStreaming === true) { + writer.uint32(40).bool(message.clientStreaming); + } + if (message.serverStreaming === true) { + writer.uint32(48).bool(message.serverStreaming); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MethodDescriptorProto { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMethodDescriptorProto } as MethodDescriptorProto; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.name = reader.string(); + break; + case 2: + message.inputType = reader.string(); + break; + case 3: + message.outputType = reader.string(); + break; + case 4: + message.options = MethodOptions.decode(reader, reader.uint32()); + break; + case 5: + message.clientStreaming = reader.bool(); + break; + case 6: + message.serverStreaming = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MethodDescriptorProto { + const message = { ...baseMethodDescriptorProto } as MethodDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = String(object.name); + } else { + message.name = ""; + } + if (object.inputType !== undefined && object.inputType !== null) { + message.inputType = String(object.inputType); + } else { + message.inputType = ""; + } + if (object.outputType !== undefined && object.outputType !== null) { + message.outputType = String(object.outputType); + } else { + message.outputType = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = MethodOptions.fromJSON(object.options); + } else { + message.options = undefined; + } + if ( + object.clientStreaming !== undefined && + object.clientStreaming !== null + ) { + message.clientStreaming = Boolean(object.clientStreaming); + } else { + message.clientStreaming = false; + } + if ( + object.serverStreaming !== undefined && + object.serverStreaming !== null + ) { + message.serverStreaming = Boolean(object.serverStreaming); + } else { + message.serverStreaming = false; + } + return message; + }, + + toJSON(message: MethodDescriptorProto): unknown { + const obj: any = {}; + message.name !== undefined && (obj.name = message.name); + message.inputType !== undefined && (obj.inputType = message.inputType); + message.outputType !== undefined && (obj.outputType = message.outputType); + message.options !== undefined && + (obj.options = message.options + ? MethodOptions.toJSON(message.options) + : undefined); + message.clientStreaming !== undefined && + (obj.clientStreaming = message.clientStreaming); + message.serverStreaming !== undefined && + (obj.serverStreaming = message.serverStreaming); + return obj; + }, + + fromPartial( + object: DeepPartial + ): MethodDescriptorProto { + const message = { ...baseMethodDescriptorProto } as MethodDescriptorProto; + if (object.name !== undefined && object.name !== null) { + message.name = object.name; + } else { + message.name = ""; + } + if (object.inputType !== undefined && object.inputType !== null) { + message.inputType = object.inputType; + } else { + message.inputType = ""; + } + if (object.outputType !== undefined && object.outputType !== null) { + message.outputType = object.outputType; + } else { + message.outputType = ""; + } + if (object.options !== undefined && object.options !== null) { + message.options = MethodOptions.fromPartial(object.options); + } else { + message.options = undefined; + } + if ( + object.clientStreaming !== undefined && + object.clientStreaming !== null + ) { + message.clientStreaming = object.clientStreaming; + } else { + message.clientStreaming = false; + } + if ( + object.serverStreaming !== undefined && + object.serverStreaming !== null + ) { + message.serverStreaming = object.serverStreaming; + } else { + message.serverStreaming = false; + } + return message; + }, +}; + +const baseFileOptions: object = { + javaPackage: "", + javaOuterClassname: "", + javaMultipleFiles: false, + javaGenerateEqualsAndHash: false, + javaStringCheckUtf8: false, + optimizeFor: 1, + goPackage: "", + ccGenericServices: false, + javaGenericServices: false, + pyGenericServices: false, + phpGenericServices: false, + deprecated: false, + ccEnableArenas: false, + objcClassPrefix: "", + csharpNamespace: "", + swiftPrefix: "", + phpClassPrefix: "", + phpNamespace: "", + phpMetadataNamespace: "", + rubyPackage: "", +}; + +export const FileOptions = { + encode(message: FileOptions, writer: Writer = Writer.create()): Writer { + if (message.javaPackage !== "") { + writer.uint32(10).string(message.javaPackage); + } + if (message.javaOuterClassname !== "") { + writer.uint32(66).string(message.javaOuterClassname); + } + if (message.javaMultipleFiles === true) { + writer.uint32(80).bool(message.javaMultipleFiles); + } + if (message.javaGenerateEqualsAndHash === true) { + writer.uint32(160).bool(message.javaGenerateEqualsAndHash); + } + if (message.javaStringCheckUtf8 === true) { + writer.uint32(216).bool(message.javaStringCheckUtf8); + } + if (message.optimizeFor !== 1) { + writer.uint32(72).int32(message.optimizeFor); + } + if (message.goPackage !== "") { + writer.uint32(90).string(message.goPackage); + } + if (message.ccGenericServices === true) { + writer.uint32(128).bool(message.ccGenericServices); + } + if (message.javaGenericServices === true) { + writer.uint32(136).bool(message.javaGenericServices); + } + if (message.pyGenericServices === true) { + writer.uint32(144).bool(message.pyGenericServices); + } + if (message.phpGenericServices === true) { + writer.uint32(336).bool(message.phpGenericServices); + } + if (message.deprecated === true) { + writer.uint32(184).bool(message.deprecated); + } + if (message.ccEnableArenas === true) { + writer.uint32(248).bool(message.ccEnableArenas); + } + if (message.objcClassPrefix !== "") { + writer.uint32(290).string(message.objcClassPrefix); + } + if (message.csharpNamespace !== "") { + writer.uint32(298).string(message.csharpNamespace); + } + if (message.swiftPrefix !== "") { + writer.uint32(314).string(message.swiftPrefix); + } + if (message.phpClassPrefix !== "") { + writer.uint32(322).string(message.phpClassPrefix); + } + if (message.phpNamespace !== "") { + writer.uint32(330).string(message.phpNamespace); + } + if (message.phpMetadataNamespace !== "") { + writer.uint32(354).string(message.phpMetadataNamespace); + } + if (message.rubyPackage !== "") { + writer.uint32(362).string(message.rubyPackage); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FileOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFileOptions } as FileOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.javaPackage = reader.string(); + break; + case 8: + message.javaOuterClassname = reader.string(); + break; + case 10: + message.javaMultipleFiles = reader.bool(); + break; + case 20: + message.javaGenerateEqualsAndHash = reader.bool(); + break; + case 27: + message.javaStringCheckUtf8 = reader.bool(); + break; + case 9: + message.optimizeFor = reader.int32() as any; + break; + case 11: + message.goPackage = reader.string(); + break; + case 16: + message.ccGenericServices = reader.bool(); + break; + case 17: + message.javaGenericServices = reader.bool(); + break; + case 18: + message.pyGenericServices = reader.bool(); + break; + case 42: + message.phpGenericServices = reader.bool(); + break; + case 23: + message.deprecated = reader.bool(); + break; + case 31: + message.ccEnableArenas = reader.bool(); + break; + case 36: + message.objcClassPrefix = reader.string(); + break; + case 37: + message.csharpNamespace = reader.string(); + break; + case 39: + message.swiftPrefix = reader.string(); + break; + case 40: + message.phpClassPrefix = reader.string(); + break; + case 41: + message.phpNamespace = reader.string(); + break; + case 44: + message.phpMetadataNamespace = reader.string(); + break; + case 45: + message.rubyPackage = reader.string(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FileOptions { + const message = { ...baseFileOptions } as FileOptions; + message.uninterpretedOption = []; + if (object.javaPackage !== undefined && object.javaPackage !== null) { + message.javaPackage = String(object.javaPackage); + } else { + message.javaPackage = ""; + } + if ( + object.javaOuterClassname !== undefined && + object.javaOuterClassname !== null + ) { + message.javaOuterClassname = String(object.javaOuterClassname); + } else { + message.javaOuterClassname = ""; + } + if ( + object.javaMultipleFiles !== undefined && + object.javaMultipleFiles !== null + ) { + message.javaMultipleFiles = Boolean(object.javaMultipleFiles); + } else { + message.javaMultipleFiles = false; + } + if ( + object.javaGenerateEqualsAndHash !== undefined && + object.javaGenerateEqualsAndHash !== null + ) { + message.javaGenerateEqualsAndHash = Boolean( + object.javaGenerateEqualsAndHash + ); + } else { + message.javaGenerateEqualsAndHash = false; + } + if ( + object.javaStringCheckUtf8 !== undefined && + object.javaStringCheckUtf8 !== null + ) { + message.javaStringCheckUtf8 = Boolean(object.javaStringCheckUtf8); + } else { + message.javaStringCheckUtf8 = false; + } + if (object.optimizeFor !== undefined && object.optimizeFor !== null) { + message.optimizeFor = fileOptions_OptimizeModeFromJSON( + object.optimizeFor + ); + } else { + message.optimizeFor = 1; + } + if (object.goPackage !== undefined && object.goPackage !== null) { + message.goPackage = String(object.goPackage); + } else { + message.goPackage = ""; + } + if ( + object.ccGenericServices !== undefined && + object.ccGenericServices !== null + ) { + message.ccGenericServices = Boolean(object.ccGenericServices); + } else { + message.ccGenericServices = false; + } + if ( + object.javaGenericServices !== undefined && + object.javaGenericServices !== null + ) { + message.javaGenericServices = Boolean(object.javaGenericServices); + } else { + message.javaGenericServices = false; + } + if ( + object.pyGenericServices !== undefined && + object.pyGenericServices !== null + ) { + message.pyGenericServices = Boolean(object.pyGenericServices); + } else { + message.pyGenericServices = false; + } + if ( + object.phpGenericServices !== undefined && + object.phpGenericServices !== null + ) { + message.phpGenericServices = Boolean(object.phpGenericServices); + } else { + message.phpGenericServices = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if (object.ccEnableArenas !== undefined && object.ccEnableArenas !== null) { + message.ccEnableArenas = Boolean(object.ccEnableArenas); + } else { + message.ccEnableArenas = false; + } + if ( + object.objcClassPrefix !== undefined && + object.objcClassPrefix !== null + ) { + message.objcClassPrefix = String(object.objcClassPrefix); + } else { + message.objcClassPrefix = ""; + } + if ( + object.csharpNamespace !== undefined && + object.csharpNamespace !== null + ) { + message.csharpNamespace = String(object.csharpNamespace); + } else { + message.csharpNamespace = ""; + } + if (object.swiftPrefix !== undefined && object.swiftPrefix !== null) { + message.swiftPrefix = String(object.swiftPrefix); + } else { + message.swiftPrefix = ""; + } + if (object.phpClassPrefix !== undefined && object.phpClassPrefix !== null) { + message.phpClassPrefix = String(object.phpClassPrefix); + } else { + message.phpClassPrefix = ""; + } + if (object.phpNamespace !== undefined && object.phpNamespace !== null) { + message.phpNamespace = String(object.phpNamespace); + } else { + message.phpNamespace = ""; + } + if ( + object.phpMetadataNamespace !== undefined && + object.phpMetadataNamespace !== null + ) { + message.phpMetadataNamespace = String(object.phpMetadataNamespace); + } else { + message.phpMetadataNamespace = ""; + } + if (object.rubyPackage !== undefined && object.rubyPackage !== null) { + message.rubyPackage = String(object.rubyPackage); + } else { + message.rubyPackage = ""; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: FileOptions): unknown { + const obj: any = {}; + message.javaPackage !== undefined && + (obj.javaPackage = message.javaPackage); + message.javaOuterClassname !== undefined && + (obj.javaOuterClassname = message.javaOuterClassname); + message.javaMultipleFiles !== undefined && + (obj.javaMultipleFiles = message.javaMultipleFiles); + message.javaGenerateEqualsAndHash !== undefined && + (obj.javaGenerateEqualsAndHash = message.javaGenerateEqualsAndHash); + message.javaStringCheckUtf8 !== undefined && + (obj.javaStringCheckUtf8 = message.javaStringCheckUtf8); + message.optimizeFor !== undefined && + (obj.optimizeFor = fileOptions_OptimizeModeToJSON(message.optimizeFor)); + message.goPackage !== undefined && (obj.goPackage = message.goPackage); + message.ccGenericServices !== undefined && + (obj.ccGenericServices = message.ccGenericServices); + message.javaGenericServices !== undefined && + (obj.javaGenericServices = message.javaGenericServices); + message.pyGenericServices !== undefined && + (obj.pyGenericServices = message.pyGenericServices); + message.phpGenericServices !== undefined && + (obj.phpGenericServices = message.phpGenericServices); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.ccEnableArenas !== undefined && + (obj.ccEnableArenas = message.ccEnableArenas); + message.objcClassPrefix !== undefined && + (obj.objcClassPrefix = message.objcClassPrefix); + message.csharpNamespace !== undefined && + (obj.csharpNamespace = message.csharpNamespace); + message.swiftPrefix !== undefined && + (obj.swiftPrefix = message.swiftPrefix); + message.phpClassPrefix !== undefined && + (obj.phpClassPrefix = message.phpClassPrefix); + message.phpNamespace !== undefined && + (obj.phpNamespace = message.phpNamespace); + message.phpMetadataNamespace !== undefined && + (obj.phpMetadataNamespace = message.phpMetadataNamespace); + message.rubyPackage !== undefined && + (obj.rubyPackage = message.rubyPackage); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): FileOptions { + const message = { ...baseFileOptions } as FileOptions; + message.uninterpretedOption = []; + if (object.javaPackage !== undefined && object.javaPackage !== null) { + message.javaPackage = object.javaPackage; + } else { + message.javaPackage = ""; + } + if ( + object.javaOuterClassname !== undefined && + object.javaOuterClassname !== null + ) { + message.javaOuterClassname = object.javaOuterClassname; + } else { + message.javaOuterClassname = ""; + } + if ( + object.javaMultipleFiles !== undefined && + object.javaMultipleFiles !== null + ) { + message.javaMultipleFiles = object.javaMultipleFiles; + } else { + message.javaMultipleFiles = false; + } + if ( + object.javaGenerateEqualsAndHash !== undefined && + object.javaGenerateEqualsAndHash !== null + ) { + message.javaGenerateEqualsAndHash = object.javaGenerateEqualsAndHash; + } else { + message.javaGenerateEqualsAndHash = false; + } + if ( + object.javaStringCheckUtf8 !== undefined && + object.javaStringCheckUtf8 !== null + ) { + message.javaStringCheckUtf8 = object.javaStringCheckUtf8; + } else { + message.javaStringCheckUtf8 = false; + } + if (object.optimizeFor !== undefined && object.optimizeFor !== null) { + message.optimizeFor = object.optimizeFor; + } else { + message.optimizeFor = 1; + } + if (object.goPackage !== undefined && object.goPackage !== null) { + message.goPackage = object.goPackage; + } else { + message.goPackage = ""; + } + if ( + object.ccGenericServices !== undefined && + object.ccGenericServices !== null + ) { + message.ccGenericServices = object.ccGenericServices; + } else { + message.ccGenericServices = false; + } + if ( + object.javaGenericServices !== undefined && + object.javaGenericServices !== null + ) { + message.javaGenericServices = object.javaGenericServices; + } else { + message.javaGenericServices = false; + } + if ( + object.pyGenericServices !== undefined && + object.pyGenericServices !== null + ) { + message.pyGenericServices = object.pyGenericServices; + } else { + message.pyGenericServices = false; + } + if ( + object.phpGenericServices !== undefined && + object.phpGenericServices !== null + ) { + message.phpGenericServices = object.phpGenericServices; + } else { + message.phpGenericServices = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if (object.ccEnableArenas !== undefined && object.ccEnableArenas !== null) { + message.ccEnableArenas = object.ccEnableArenas; + } else { + message.ccEnableArenas = false; + } + if ( + object.objcClassPrefix !== undefined && + object.objcClassPrefix !== null + ) { + message.objcClassPrefix = object.objcClassPrefix; + } else { + message.objcClassPrefix = ""; + } + if ( + object.csharpNamespace !== undefined && + object.csharpNamespace !== null + ) { + message.csharpNamespace = object.csharpNamespace; + } else { + message.csharpNamespace = ""; + } + if (object.swiftPrefix !== undefined && object.swiftPrefix !== null) { + message.swiftPrefix = object.swiftPrefix; + } else { + message.swiftPrefix = ""; + } + if (object.phpClassPrefix !== undefined && object.phpClassPrefix !== null) { + message.phpClassPrefix = object.phpClassPrefix; + } else { + message.phpClassPrefix = ""; + } + if (object.phpNamespace !== undefined && object.phpNamespace !== null) { + message.phpNamespace = object.phpNamespace; + } else { + message.phpNamespace = ""; + } + if ( + object.phpMetadataNamespace !== undefined && + object.phpMetadataNamespace !== null + ) { + message.phpMetadataNamespace = object.phpMetadataNamespace; + } else { + message.phpMetadataNamespace = ""; + } + if (object.rubyPackage !== undefined && object.rubyPackage !== null) { + message.rubyPackage = object.rubyPackage; + } else { + message.rubyPackage = ""; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseMessageOptions: object = { + messageSetWireFormat: false, + noStandardDescriptorAccessor: false, + deprecated: false, + mapEntry: false, +}; + +export const MessageOptions = { + encode(message: MessageOptions, writer: Writer = Writer.create()): Writer { + if (message.messageSetWireFormat === true) { + writer.uint32(8).bool(message.messageSetWireFormat); + } + if (message.noStandardDescriptorAccessor === true) { + writer.uint32(16).bool(message.noStandardDescriptorAccessor); + } + if (message.deprecated === true) { + writer.uint32(24).bool(message.deprecated); + } + if (message.mapEntry === true) { + writer.uint32(56).bool(message.mapEntry); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MessageOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMessageOptions } as MessageOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.messageSetWireFormat = reader.bool(); + break; + case 2: + message.noStandardDescriptorAccessor = reader.bool(); + break; + case 3: + message.deprecated = reader.bool(); + break; + case 7: + message.mapEntry = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MessageOptions { + const message = { ...baseMessageOptions } as MessageOptions; + message.uninterpretedOption = []; + if ( + object.messageSetWireFormat !== undefined && + object.messageSetWireFormat !== null + ) { + message.messageSetWireFormat = Boolean(object.messageSetWireFormat); + } else { + message.messageSetWireFormat = false; + } + if ( + object.noStandardDescriptorAccessor !== undefined && + object.noStandardDescriptorAccessor !== null + ) { + message.noStandardDescriptorAccessor = Boolean( + object.noStandardDescriptorAccessor + ); + } else { + message.noStandardDescriptorAccessor = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if (object.mapEntry !== undefined && object.mapEntry !== null) { + message.mapEntry = Boolean(object.mapEntry); + } else { + message.mapEntry = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: MessageOptions): unknown { + const obj: any = {}; + message.messageSetWireFormat !== undefined && + (obj.messageSetWireFormat = message.messageSetWireFormat); + message.noStandardDescriptorAccessor !== undefined && + (obj.noStandardDescriptorAccessor = message.noStandardDescriptorAccessor); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.mapEntry !== undefined && (obj.mapEntry = message.mapEntry); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): MessageOptions { + const message = { ...baseMessageOptions } as MessageOptions; + message.uninterpretedOption = []; + if ( + object.messageSetWireFormat !== undefined && + object.messageSetWireFormat !== null + ) { + message.messageSetWireFormat = object.messageSetWireFormat; + } else { + message.messageSetWireFormat = false; + } + if ( + object.noStandardDescriptorAccessor !== undefined && + object.noStandardDescriptorAccessor !== null + ) { + message.noStandardDescriptorAccessor = + object.noStandardDescriptorAccessor; + } else { + message.noStandardDescriptorAccessor = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if (object.mapEntry !== undefined && object.mapEntry !== null) { + message.mapEntry = object.mapEntry; + } else { + message.mapEntry = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseFieldOptions: object = { + ctype: 0, + packed: false, + jstype: 0, + lazy: false, + deprecated: false, + weak: false, +}; + +export const FieldOptions = { + encode(message: FieldOptions, writer: Writer = Writer.create()): Writer { + if (message.ctype !== 0) { + writer.uint32(8).int32(message.ctype); + } + if (message.packed === true) { + writer.uint32(16).bool(message.packed); + } + if (message.jstype !== 0) { + writer.uint32(48).int32(message.jstype); + } + if (message.lazy === true) { + writer.uint32(40).bool(message.lazy); + } + if (message.deprecated === true) { + writer.uint32(24).bool(message.deprecated); + } + if (message.weak === true) { + writer.uint32(80).bool(message.weak); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): FieldOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseFieldOptions } as FieldOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.ctype = reader.int32() as any; + break; + case 2: + message.packed = reader.bool(); + break; + case 6: + message.jstype = reader.int32() as any; + break; + case 5: + message.lazy = reader.bool(); + break; + case 3: + message.deprecated = reader.bool(); + break; + case 10: + message.weak = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): FieldOptions { + const message = { ...baseFieldOptions } as FieldOptions; + message.uninterpretedOption = []; + if (object.ctype !== undefined && object.ctype !== null) { + message.ctype = fieldOptions_CTypeFromJSON(object.ctype); + } else { + message.ctype = 0; + } + if (object.packed !== undefined && object.packed !== null) { + message.packed = Boolean(object.packed); + } else { + message.packed = false; + } + if (object.jstype !== undefined && object.jstype !== null) { + message.jstype = fieldOptions_JSTypeFromJSON(object.jstype); + } else { + message.jstype = 0; + } + if (object.lazy !== undefined && object.lazy !== null) { + message.lazy = Boolean(object.lazy); + } else { + message.lazy = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if (object.weak !== undefined && object.weak !== null) { + message.weak = Boolean(object.weak); + } else { + message.weak = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: FieldOptions): unknown { + const obj: any = {}; + message.ctype !== undefined && + (obj.ctype = fieldOptions_CTypeToJSON(message.ctype)); + message.packed !== undefined && (obj.packed = message.packed); + message.jstype !== undefined && + (obj.jstype = fieldOptions_JSTypeToJSON(message.jstype)); + message.lazy !== undefined && (obj.lazy = message.lazy); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.weak !== undefined && (obj.weak = message.weak); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): FieldOptions { + const message = { ...baseFieldOptions } as FieldOptions; + message.uninterpretedOption = []; + if (object.ctype !== undefined && object.ctype !== null) { + message.ctype = object.ctype; + } else { + message.ctype = 0; + } + if (object.packed !== undefined && object.packed !== null) { + message.packed = object.packed; + } else { + message.packed = false; + } + if (object.jstype !== undefined && object.jstype !== null) { + message.jstype = object.jstype; + } else { + message.jstype = 0; + } + if (object.lazy !== undefined && object.lazy !== null) { + message.lazy = object.lazy; + } else { + message.lazy = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if (object.weak !== undefined && object.weak !== null) { + message.weak = object.weak; + } else { + message.weak = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseOneofOptions: object = {}; + +export const OneofOptions = { + encode(message: OneofOptions, writer: Writer = Writer.create()): Writer { + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): OneofOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseOneofOptions } as OneofOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): OneofOptions { + const message = { ...baseOneofOptions } as OneofOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: OneofOptions): unknown { + const obj: any = {}; + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): OneofOptions { + const message = { ...baseOneofOptions } as OneofOptions; + message.uninterpretedOption = []; + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseEnumOptions: object = { allowAlias: false, deprecated: false }; + +export const EnumOptions = { + encode(message: EnumOptions, writer: Writer = Writer.create()): Writer { + if (message.allowAlias === true) { + writer.uint32(16).bool(message.allowAlias); + } + if (message.deprecated === true) { + writer.uint32(24).bool(message.deprecated); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): EnumOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseEnumOptions } as EnumOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + message.allowAlias = reader.bool(); + break; + case 3: + message.deprecated = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumOptions { + const message = { ...baseEnumOptions } as EnumOptions; + message.uninterpretedOption = []; + if (object.allowAlias !== undefined && object.allowAlias !== null) { + message.allowAlias = Boolean(object.allowAlias); + } else { + message.allowAlias = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: EnumOptions): unknown { + const obj: any = {}; + message.allowAlias !== undefined && (obj.allowAlias = message.allowAlias); + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): EnumOptions { + const message = { ...baseEnumOptions } as EnumOptions; + message.uninterpretedOption = []; + if (object.allowAlias !== undefined && object.allowAlias !== null) { + message.allowAlias = object.allowAlias; + } else { + message.allowAlias = false; + } + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseEnumValueOptions: object = { deprecated: false }; + +export const EnumValueOptions = { + encode(message: EnumValueOptions, writer: Writer = Writer.create()): Writer { + if (message.deprecated === true) { + writer.uint32(8).bool(message.deprecated); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): EnumValueOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseEnumValueOptions } as EnumValueOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.deprecated = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): EnumValueOptions { + const message = { ...baseEnumValueOptions } as EnumValueOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: EnumValueOptions): unknown { + const obj: any = {}; + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): EnumValueOptions { + const message = { ...baseEnumValueOptions } as EnumValueOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseServiceOptions: object = { deprecated: false }; + +export const ServiceOptions = { + encode(message: ServiceOptions, writer: Writer = Writer.create()): Writer { + if (message.deprecated === true) { + writer.uint32(264).bool(message.deprecated); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ServiceOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseServiceOptions } as ServiceOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 33: + message.deprecated = reader.bool(); + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ServiceOptions { + const message = { ...baseServiceOptions } as ServiceOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: ServiceOptions): unknown { + const obj: any = {}; + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): ServiceOptions { + const message = { ...baseServiceOptions } as ServiceOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseMethodOptions: object = { deprecated: false, idempotencyLevel: 0 }; + +export const MethodOptions = { + encode(message: MethodOptions, writer: Writer = Writer.create()): Writer { + if (message.deprecated === true) { + writer.uint32(264).bool(message.deprecated); + } + if (message.idempotencyLevel !== 0) { + writer.uint32(272).int32(message.idempotencyLevel); + } + for (const v of message.uninterpretedOption) { + UninterpretedOption.encode(v!, writer.uint32(7994).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MethodOptions { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMethodOptions } as MethodOptions; + message.uninterpretedOption = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 33: + message.deprecated = reader.bool(); + break; + case 34: + message.idempotencyLevel = reader.int32() as any; + break; + case 999: + message.uninterpretedOption.push( + UninterpretedOption.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MethodOptions { + const message = { ...baseMethodOptions } as MethodOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = Boolean(object.deprecated); + } else { + message.deprecated = false; + } + if ( + object.idempotencyLevel !== undefined && + object.idempotencyLevel !== null + ) { + message.idempotencyLevel = methodOptions_IdempotencyLevelFromJSON( + object.idempotencyLevel + ); + } else { + message.idempotencyLevel = 0; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: MethodOptions): unknown { + const obj: any = {}; + message.deprecated !== undefined && (obj.deprecated = message.deprecated); + message.idempotencyLevel !== undefined && + (obj.idempotencyLevel = methodOptions_IdempotencyLevelToJSON( + message.idempotencyLevel + )); + if (message.uninterpretedOption) { + obj.uninterpretedOption = message.uninterpretedOption.map((e) => + e ? UninterpretedOption.toJSON(e) : undefined + ); + } else { + obj.uninterpretedOption = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): MethodOptions { + const message = { ...baseMethodOptions } as MethodOptions; + message.uninterpretedOption = []; + if (object.deprecated !== undefined && object.deprecated !== null) { + message.deprecated = object.deprecated; + } else { + message.deprecated = false; + } + if ( + object.idempotencyLevel !== undefined && + object.idempotencyLevel !== null + ) { + message.idempotencyLevel = object.idempotencyLevel; + } else { + message.idempotencyLevel = 0; + } + if ( + object.uninterpretedOption !== undefined && + object.uninterpretedOption !== null + ) { + for (const e of object.uninterpretedOption) { + message.uninterpretedOption.push(UninterpretedOption.fromPartial(e)); + } + } + return message; + }, +}; + +const baseUninterpretedOption: object = { + identifierValue: "", + positiveIntValue: 0, + negativeIntValue: 0, + doubleValue: 0, + aggregateValue: "", +}; + +export const UninterpretedOption = { + encode( + message: UninterpretedOption, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.name) { + UninterpretedOption_NamePart.encode( + v!, + writer.uint32(18).fork() + ).ldelim(); + } + if (message.identifierValue !== "") { + writer.uint32(26).string(message.identifierValue); + } + if (message.positiveIntValue !== 0) { + writer.uint32(32).uint64(message.positiveIntValue); + } + if (message.negativeIntValue !== 0) { + writer.uint32(40).int64(message.negativeIntValue); + } + if (message.doubleValue !== 0) { + writer.uint32(49).double(message.doubleValue); + } + if (message.stringValue.length !== 0) { + writer.uint32(58).bytes(message.stringValue); + } + if (message.aggregateValue !== "") { + writer.uint32(66).string(message.aggregateValue); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): UninterpretedOption { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseUninterpretedOption } as UninterpretedOption; + message.name = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 2: + message.name.push( + UninterpretedOption_NamePart.decode(reader, reader.uint32()) + ); + break; + case 3: + message.identifierValue = reader.string(); + break; + case 4: + message.positiveIntValue = longToNumber(reader.uint64() as Long); + break; + case 5: + message.negativeIntValue = longToNumber(reader.int64() as Long); + break; + case 6: + message.doubleValue = reader.double(); + break; + case 7: + message.stringValue = reader.bytes(); + break; + case 8: + message.aggregateValue = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): UninterpretedOption { + const message = { ...baseUninterpretedOption } as UninterpretedOption; + message.name = []; + if (object.name !== undefined && object.name !== null) { + for (const e of object.name) { + message.name.push(UninterpretedOption_NamePart.fromJSON(e)); + } + } + if ( + object.identifierValue !== undefined && + object.identifierValue !== null + ) { + message.identifierValue = String(object.identifierValue); + } else { + message.identifierValue = ""; + } + if ( + object.positiveIntValue !== undefined && + object.positiveIntValue !== null + ) { + message.positiveIntValue = Number(object.positiveIntValue); + } else { + message.positiveIntValue = 0; + } + if ( + object.negativeIntValue !== undefined && + object.negativeIntValue !== null + ) { + message.negativeIntValue = Number(object.negativeIntValue); + } else { + message.negativeIntValue = 0; + } + if (object.doubleValue !== undefined && object.doubleValue !== null) { + message.doubleValue = Number(object.doubleValue); + } else { + message.doubleValue = 0; + } + if (object.stringValue !== undefined && object.stringValue !== null) { + message.stringValue = bytesFromBase64(object.stringValue); + } + if (object.aggregateValue !== undefined && object.aggregateValue !== null) { + message.aggregateValue = String(object.aggregateValue); + } else { + message.aggregateValue = ""; + } + return message; + }, + + toJSON(message: UninterpretedOption): unknown { + const obj: any = {}; + if (message.name) { + obj.name = message.name.map((e) => + e ? UninterpretedOption_NamePart.toJSON(e) : undefined + ); + } else { + obj.name = []; + } + message.identifierValue !== undefined && + (obj.identifierValue = message.identifierValue); + message.positiveIntValue !== undefined && + (obj.positiveIntValue = message.positiveIntValue); + message.negativeIntValue !== undefined && + (obj.negativeIntValue = message.negativeIntValue); + message.doubleValue !== undefined && + (obj.doubleValue = message.doubleValue); + message.stringValue !== undefined && + (obj.stringValue = base64FromBytes( + message.stringValue !== undefined + ? message.stringValue + : new Uint8Array() + )); + message.aggregateValue !== undefined && + (obj.aggregateValue = message.aggregateValue); + return obj; + }, + + fromPartial(object: DeepPartial): UninterpretedOption { + const message = { ...baseUninterpretedOption } as UninterpretedOption; + message.name = []; + if (object.name !== undefined && object.name !== null) { + for (const e of object.name) { + message.name.push(UninterpretedOption_NamePart.fromPartial(e)); + } + } + if ( + object.identifierValue !== undefined && + object.identifierValue !== null + ) { + message.identifierValue = object.identifierValue; + } else { + message.identifierValue = ""; + } + if ( + object.positiveIntValue !== undefined && + object.positiveIntValue !== null + ) { + message.positiveIntValue = object.positiveIntValue; + } else { + message.positiveIntValue = 0; + } + if ( + object.negativeIntValue !== undefined && + object.negativeIntValue !== null + ) { + message.negativeIntValue = object.negativeIntValue; + } else { + message.negativeIntValue = 0; + } + if (object.doubleValue !== undefined && object.doubleValue !== null) { + message.doubleValue = object.doubleValue; + } else { + message.doubleValue = 0; + } + if (object.stringValue !== undefined && object.stringValue !== null) { + message.stringValue = object.stringValue; + } else { + message.stringValue = new Uint8Array(); + } + if (object.aggregateValue !== undefined && object.aggregateValue !== null) { + message.aggregateValue = object.aggregateValue; + } else { + message.aggregateValue = ""; + } + return message; + }, +}; + +const baseUninterpretedOption_NamePart: object = { + namePart: "", + isExtension: false, +}; + +export const UninterpretedOption_NamePart = { + encode( + message: UninterpretedOption_NamePart, + writer: Writer = Writer.create() + ): Writer { + if (message.namePart !== "") { + writer.uint32(10).string(message.namePart); + } + if (message.isExtension === true) { + writer.uint32(16).bool(message.isExtension); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): UninterpretedOption_NamePart { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseUninterpretedOption_NamePart, + } as UninterpretedOption_NamePart; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.namePart = reader.string(); + break; + case 2: + message.isExtension = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): UninterpretedOption_NamePart { + const message = { + ...baseUninterpretedOption_NamePart, + } as UninterpretedOption_NamePart; + if (object.namePart !== undefined && object.namePart !== null) { + message.namePart = String(object.namePart); + } else { + message.namePart = ""; + } + if (object.isExtension !== undefined && object.isExtension !== null) { + message.isExtension = Boolean(object.isExtension); + } else { + message.isExtension = false; + } + return message; + }, + + toJSON(message: UninterpretedOption_NamePart): unknown { + const obj: any = {}; + message.namePart !== undefined && (obj.namePart = message.namePart); + message.isExtension !== undefined && + (obj.isExtension = message.isExtension); + return obj; + }, + + fromPartial( + object: DeepPartial + ): UninterpretedOption_NamePart { + const message = { + ...baseUninterpretedOption_NamePart, + } as UninterpretedOption_NamePart; + if (object.namePart !== undefined && object.namePart !== null) { + message.namePart = object.namePart; + } else { + message.namePart = ""; + } + if (object.isExtension !== undefined && object.isExtension !== null) { + message.isExtension = object.isExtension; + } else { + message.isExtension = false; + } + return message; + }, +}; + +const baseSourceCodeInfo: object = {}; + +export const SourceCodeInfo = { + encode(message: SourceCodeInfo, writer: Writer = Writer.create()): Writer { + for (const v of message.location) { + SourceCodeInfo_Location.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): SourceCodeInfo { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseSourceCodeInfo } as SourceCodeInfo; + message.location = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.location.push( + SourceCodeInfo_Location.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): SourceCodeInfo { + const message = { ...baseSourceCodeInfo } as SourceCodeInfo; + message.location = []; + if (object.location !== undefined && object.location !== null) { + for (const e of object.location) { + message.location.push(SourceCodeInfo_Location.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: SourceCodeInfo): unknown { + const obj: any = {}; + if (message.location) { + obj.location = message.location.map((e) => + e ? SourceCodeInfo_Location.toJSON(e) : undefined + ); + } else { + obj.location = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): SourceCodeInfo { + const message = { ...baseSourceCodeInfo } as SourceCodeInfo; + message.location = []; + if (object.location !== undefined && object.location !== null) { + for (const e of object.location) { + message.location.push(SourceCodeInfo_Location.fromPartial(e)); + } + } + return message; + }, +}; + +const baseSourceCodeInfo_Location: object = { + path: 0, + span: 0, + leadingComments: "", + trailingComments: "", + leadingDetachedComments: "", +}; + +export const SourceCodeInfo_Location = { + encode( + message: SourceCodeInfo_Location, + writer: Writer = Writer.create() + ): Writer { + writer.uint32(10).fork(); + for (const v of message.path) { + writer.int32(v); + } + writer.ldelim(); + writer.uint32(18).fork(); + for (const v of message.span) { + writer.int32(v); + } + writer.ldelim(); + if (message.leadingComments !== "") { + writer.uint32(26).string(message.leadingComments); + } + if (message.trailingComments !== "") { + writer.uint32(34).string(message.trailingComments); + } + for (const v of message.leadingDetachedComments) { + writer.uint32(50).string(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): SourceCodeInfo_Location { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseSourceCodeInfo_Location, + } as SourceCodeInfo_Location; + message.path = []; + message.span = []; + message.leadingDetachedComments = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.path.push(reader.int32()); + } + } else { + message.path.push(reader.int32()); + } + break; + case 2: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.span.push(reader.int32()); + } + } else { + message.span.push(reader.int32()); + } + break; + case 3: + message.leadingComments = reader.string(); + break; + case 4: + message.trailingComments = reader.string(); + break; + case 6: + message.leadingDetachedComments.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): SourceCodeInfo_Location { + const message = { + ...baseSourceCodeInfo_Location, + } as SourceCodeInfo_Location; + message.path = []; + message.span = []; + message.leadingDetachedComments = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(Number(e)); + } + } + if (object.span !== undefined && object.span !== null) { + for (const e of object.span) { + message.span.push(Number(e)); + } + } + if ( + object.leadingComments !== undefined && + object.leadingComments !== null + ) { + message.leadingComments = String(object.leadingComments); + } else { + message.leadingComments = ""; + } + if ( + object.trailingComments !== undefined && + object.trailingComments !== null + ) { + message.trailingComments = String(object.trailingComments); + } else { + message.trailingComments = ""; + } + if ( + object.leadingDetachedComments !== undefined && + object.leadingDetachedComments !== null + ) { + for (const e of object.leadingDetachedComments) { + message.leadingDetachedComments.push(String(e)); + } + } + return message; + }, + + toJSON(message: SourceCodeInfo_Location): unknown { + const obj: any = {}; + if (message.path) { + obj.path = message.path.map((e) => e); + } else { + obj.path = []; + } + if (message.span) { + obj.span = message.span.map((e) => e); + } else { + obj.span = []; + } + message.leadingComments !== undefined && + (obj.leadingComments = message.leadingComments); + message.trailingComments !== undefined && + (obj.trailingComments = message.trailingComments); + if (message.leadingDetachedComments) { + obj.leadingDetachedComments = message.leadingDetachedComments.map( + (e) => e + ); + } else { + obj.leadingDetachedComments = []; + } + return obj; + }, + + fromPartial( + object: DeepPartial + ): SourceCodeInfo_Location { + const message = { + ...baseSourceCodeInfo_Location, + } as SourceCodeInfo_Location; + message.path = []; + message.span = []; + message.leadingDetachedComments = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(e); + } + } + if (object.span !== undefined && object.span !== null) { + for (const e of object.span) { + message.span.push(e); + } + } + if ( + object.leadingComments !== undefined && + object.leadingComments !== null + ) { + message.leadingComments = object.leadingComments; + } else { + message.leadingComments = ""; + } + if ( + object.trailingComments !== undefined && + object.trailingComments !== null + ) { + message.trailingComments = object.trailingComments; + } else { + message.trailingComments = ""; + } + if ( + object.leadingDetachedComments !== undefined && + object.leadingDetachedComments !== null + ) { + for (const e of object.leadingDetachedComments) { + message.leadingDetachedComments.push(e); + } + } + return message; + }, +}; + +const baseGeneratedCodeInfo: object = {}; + +export const GeneratedCodeInfo = { + encode(message: GeneratedCodeInfo, writer: Writer = Writer.create()): Writer { + for (const v of message.annotation) { + GeneratedCodeInfo_Annotation.encode( + v!, + writer.uint32(10).fork() + ).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): GeneratedCodeInfo { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseGeneratedCodeInfo } as GeneratedCodeInfo; + message.annotation = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.annotation.push( + GeneratedCodeInfo_Annotation.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GeneratedCodeInfo { + const message = { ...baseGeneratedCodeInfo } as GeneratedCodeInfo; + message.annotation = []; + if (object.annotation !== undefined && object.annotation !== null) { + for (const e of object.annotation) { + message.annotation.push(GeneratedCodeInfo_Annotation.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: GeneratedCodeInfo): unknown { + const obj: any = {}; + if (message.annotation) { + obj.annotation = message.annotation.map((e) => + e ? GeneratedCodeInfo_Annotation.toJSON(e) : undefined + ); + } else { + obj.annotation = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): GeneratedCodeInfo { + const message = { ...baseGeneratedCodeInfo } as GeneratedCodeInfo; + message.annotation = []; + if (object.annotation !== undefined && object.annotation !== null) { + for (const e of object.annotation) { + message.annotation.push(GeneratedCodeInfo_Annotation.fromPartial(e)); + } + } + return message; + }, +}; + +const baseGeneratedCodeInfo_Annotation: object = { + path: 0, + sourceFile: "", + begin: 0, + end: 0, +}; + +export const GeneratedCodeInfo_Annotation = { + encode( + message: GeneratedCodeInfo_Annotation, + writer: Writer = Writer.create() + ): Writer { + writer.uint32(10).fork(); + for (const v of message.path) { + writer.int32(v); + } + writer.ldelim(); + if (message.sourceFile !== "") { + writer.uint32(18).string(message.sourceFile); + } + if (message.begin !== 0) { + writer.uint32(24).int32(message.begin); + } + if (message.end !== 0) { + writer.uint32(32).int32(message.end); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): GeneratedCodeInfo_Annotation { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseGeneratedCodeInfo_Annotation, + } as GeneratedCodeInfo_Annotation; + message.path = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.path.push(reader.int32()); + } + } else { + message.path.push(reader.int32()); + } + break; + case 2: + message.sourceFile = reader.string(); + break; + case 3: + message.begin = reader.int32(); + break; + case 4: + message.end = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GeneratedCodeInfo_Annotation { + const message = { + ...baseGeneratedCodeInfo_Annotation, + } as GeneratedCodeInfo_Annotation; + message.path = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(Number(e)); + } + } + if (object.sourceFile !== undefined && object.sourceFile !== null) { + message.sourceFile = String(object.sourceFile); + } else { + message.sourceFile = ""; + } + if (object.begin !== undefined && object.begin !== null) { + message.begin = Number(object.begin); + } else { + message.begin = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = Number(object.end); + } else { + message.end = 0; + } + return message; + }, + + toJSON(message: GeneratedCodeInfo_Annotation): unknown { + const obj: any = {}; + if (message.path) { + obj.path = message.path.map((e) => e); + } else { + obj.path = []; + } + message.sourceFile !== undefined && (obj.sourceFile = message.sourceFile); + message.begin !== undefined && (obj.begin = message.begin); + message.end !== undefined && (obj.end = message.end); + return obj; + }, + + fromPartial( + object: DeepPartial + ): GeneratedCodeInfo_Annotation { + const message = { + ...baseGeneratedCodeInfo_Annotation, + } as GeneratedCodeInfo_Annotation; + message.path = []; + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(e); + } + } + if (object.sourceFile !== undefined && object.sourceFile !== null) { + message.sourceFile = object.sourceFile; + } else { + message.sourceFile = ""; + } + if (object.begin !== undefined && object.begin !== null) { + message.begin = object.begin; + } else { + message.begin = 0; + } + if (object.end !== undefined && object.end !== null) { + message.end = object.end; + } else { + message.end = 0; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/ibc.core.connection.v1/types/google/protobuf/timestamp.ts b/ts-client/ibc.core.connection.v1/types/google/protobuf/timestamp.ts new file mode 100644 index 00000000..11864afc --- /dev/null +++ b/ts-client/ibc.core.connection.v1/types/google/protobuf/timestamp.ts @@ -0,0 +1,219 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "google.protobuf"; + +/** + * A Timestamp represents a point in time independent of any time zone or local + * calendar, encoded as a count of seconds and fractions of seconds at + * nanosecond resolution. The count is relative to an epoch at UTC midnight on + * January 1, 1970, in the proleptic Gregorian calendar which extends the + * Gregorian calendar backwards to year one. + * + * All minutes are 60 seconds long. Leap seconds are "smeared" so that no leap + * second table is needed for interpretation, using a [24-hour linear + * smear](https://developers.google.com/time/smear). + * + * The range is from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. By + * restricting to that range, we ensure that we can convert to and from [RFC + * 3339](https://www.ietf.org/rfc/rfc3339.txt) date strings. + * + * # Examples + * + * Example 1: Compute Timestamp from POSIX `time()`. + * + * Timestamp timestamp; + * timestamp.set_seconds(time(NULL)); + * timestamp.set_nanos(0); + * + * Example 2: Compute Timestamp from POSIX `gettimeofday()`. + * + * struct timeval tv; + * gettimeofday(&tv, NULL); + * + * Timestamp timestamp; + * timestamp.set_seconds(tv.tv_sec); + * timestamp.set_nanos(tv.tv_usec * 1000); + * + * Example 3: Compute Timestamp from Win32 `GetSystemTimeAsFileTime()`. + * + * FILETIME ft; + * GetSystemTimeAsFileTime(&ft); + * UINT64 ticks = (((UINT64)ft.dwHighDateTime) << 32) | ft.dwLowDateTime; + * + * // A Windows tick is 100 nanoseconds. Windows epoch 1601-01-01T00:00:00Z + * // is 11644473600 seconds before Unix epoch 1970-01-01T00:00:00Z. + * Timestamp timestamp; + * timestamp.set_seconds((INT64) ((ticks / 10000000) - 11644473600LL)); + * timestamp.set_nanos((INT32) ((ticks % 10000000) * 100)); + * + * Example 4: Compute Timestamp from Java `System.currentTimeMillis()`. + * + * long millis = System.currentTimeMillis(); + * + * Timestamp timestamp = Timestamp.newBuilder().setSeconds(millis / 1000) + * .setNanos((int) ((millis % 1000) * 1000000)).build(); + * + * + * Example 5: Compute Timestamp from Java `Instant.now()`. + * + * Instant now = Instant.now(); + * + * Timestamp timestamp = + * Timestamp.newBuilder().setSeconds(now.getEpochSecond()) + * .setNanos(now.getNano()).build(); + * + * + * Example 6: Compute Timestamp from current time in Python. + * + * timestamp = Timestamp() + * timestamp.GetCurrentTime() + * + * # JSON Mapping + * + * In JSON format, the Timestamp type is encoded as a string in the + * [RFC 3339](https://www.ietf.org/rfc/rfc3339.txt) format. That is, the + * format is "{year}-{month}-{day}T{hour}:{min}:{sec}[.{frac_sec}]Z" + * where {year} is always expressed using four digits while {month}, {day}, + * {hour}, {min}, and {sec} are zero-padded to two digits each. The fractional + * seconds, which can go up to 9 digits (i.e. up to 1 nanosecond resolution), + * are optional. The "Z" suffix indicates the timezone ("UTC"); the timezone + * is required. A proto3 JSON serializer should always use UTC (as indicated by + * "Z") when printing the Timestamp type and a proto3 JSON parser should be + * able to accept both UTC and other timezones (as indicated by an offset). + * + * For example, "2017-01-15T01:30:15.01Z" encodes 15.01 seconds past + * 01:30 UTC on January 15, 2017. + * + * In JavaScript, one can convert a Date object to this format using the + * standard + * [toISOString()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString) + * method. In Python, a standard `datetime.datetime` object can be converted + * to this format using + * [`strftime`](https://docs.python.org/2/library/time.html#time.strftime) with + * the time format spec '%Y-%m-%dT%H:%M:%S.%fZ'. Likewise, in Java, one can use + * the Joda Time's [`ISODateTimeFormat.dateTime()`]( + * http://www.joda.org/joda-time/apidocs/org/joda/time/format/ISODateTimeFormat.html#dateTime%2D%2D + * ) to obtain a formatter capable of generating timestamps in this format. + */ +export interface Timestamp { + /** + * Represents seconds of UTC time since Unix epoch + * 1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to + * 9999-12-31T23:59:59Z inclusive. + */ + seconds: number; + /** + * Non-negative fractions of a second at nanosecond resolution. Negative + * second values with fractions must still have non-negative nanos values + * that count forward in time. Must be from 0 to 999,999,999 + * inclusive. + */ + nanos: number; +} + +const baseTimestamp: object = { seconds: 0, nanos: 0 }; + +export const Timestamp = { + encode(message: Timestamp, writer: Writer = Writer.create()): Writer { + if (message.seconds !== 0) { + writer.uint32(8).int64(message.seconds); + } + if (message.nanos !== 0) { + writer.uint32(16).int32(message.nanos); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Timestamp { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseTimestamp } as Timestamp; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.seconds = longToNumber(reader.int64() as Long); + break; + case 2: + message.nanos = reader.int32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Timestamp { + const message = { ...baseTimestamp } as Timestamp; + if (object.seconds !== undefined && object.seconds !== null) { + message.seconds = Number(object.seconds); + } else { + message.seconds = 0; + } + if (object.nanos !== undefined && object.nanos !== null) { + message.nanos = Number(object.nanos); + } else { + message.nanos = 0; + } + return message; + }, + + toJSON(message: Timestamp): unknown { + const obj: any = {}; + message.seconds !== undefined && (obj.seconds = message.seconds); + message.nanos !== undefined && (obj.nanos = message.nanos); + return obj; + }, + + fromPartial(object: DeepPartial): Timestamp { + const message = { ...baseTimestamp } as Timestamp; + if (object.seconds !== undefined && object.seconds !== null) { + message.seconds = object.seconds; + } else { + message.seconds = 0; + } + if (object.nanos !== undefined && object.nanos !== null) { + message.nanos = object.nanos; + } else { + message.nanos = 0; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/ibc.core.connection.v1/types/ibc/core/client/v1/client.ts b/ts-client/ibc.core.connection.v1/types/ibc/core/client/v1/client.ts new file mode 100644 index 00000000..7a8e15b6 --- /dev/null +++ b/ts-client/ibc.core.connection.v1/types/ibc/core/client/v1/client.ts @@ -0,0 +1,786 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; +import { Any } from "../../../../google/protobuf/any"; +import { Plan } from "../../../../cosmos/upgrade/v1beta1/upgrade"; + +export const protobufPackage = "ibc.core.client.v1"; + +/** + * IdentifiedClientState defines a client state with an additional client + * identifier field. + */ +export interface IdentifiedClientState { + /** client identifier */ + clientId: string; + /** client state */ + clientState: Any | undefined; +} + +/** + * ConsensusStateWithHeight defines a consensus state with an additional height + * field. + */ +export interface ConsensusStateWithHeight { + /** consensus state height */ + height: Height | undefined; + /** consensus state */ + consensusState: Any | undefined; +} + +/** + * ClientConsensusStates defines all the stored consensus states for a given + * client. + */ +export interface ClientConsensusStates { + /** client identifier */ + clientId: string; + /** consensus states and their heights associated with the client */ + consensusStates: ConsensusStateWithHeight[]; +} + +/** + * ClientUpdateProposal is a governance proposal. If it passes, the substitute + * client's latest consensus state is copied over to the subject client. The proposal + * handler may fail if the subject and the substitute do not match in client and + * chain parameters (with exception to latest height, frozen height, and chain-id). + */ +export interface ClientUpdateProposal { + /** the title of the update proposal */ + title: string; + /** the description of the proposal */ + description: string; + /** the client identifier for the client to be updated if the proposal passes */ + subjectClientId: string; + /** + * the substitute client identifier for the client standing in for the subject + * client + */ + substituteClientId: string; +} + +/** + * UpgradeProposal is a gov Content type for initiating an IBC breaking + * upgrade. + */ +export interface UpgradeProposal { + title: string; + description: string; + plan: Plan | undefined; + /** + * An UpgradedClientState must be provided to perform an IBC breaking upgrade. + * This will make the chain commit to the correct upgraded (self) client state + * before the upgrade occurs, so that connecting chains can verify that the + * new upgraded client is valid by verifying a proof on the previous version + * of the chain. This will allow IBC connections to persist smoothly across + * planned chain upgrades + */ + upgradedClientState: Any | undefined; +} + +/** + * Height is a monotonically increasing data type + * that can be compared against another Height for the purposes of updating and + * freezing clients + * + * Normally the RevisionHeight is incremented at each height while keeping + * RevisionNumber the same. However some consensus algorithms may choose to + * reset the height in certain conditions e.g. hard forks, state-machine + * breaking changes In these cases, the RevisionNumber is incremented so that + * height continues to be monitonically increasing even as the RevisionHeight + * gets reset + */ +export interface Height { + /** the revision that the client is currently on */ + revisionNumber: number; + /** the height within the given revision */ + revisionHeight: number; +} + +/** Params defines the set of IBC light client parameters. */ +export interface Params { + /** allowed_clients defines the list of allowed client state types. */ + allowedClients: string[]; +} + +const baseIdentifiedClientState: object = { clientId: "" }; + +export const IdentifiedClientState = { + encode( + message: IdentifiedClientState, + writer: Writer = Writer.create() + ): Writer { + if (message.clientId !== "") { + writer.uint32(10).string(message.clientId); + } + if (message.clientState !== undefined) { + Any.encode(message.clientState, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): IdentifiedClientState { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseIdentifiedClientState } as IdentifiedClientState; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.clientId = reader.string(); + break; + case 2: + message.clientState = Any.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): IdentifiedClientState { + const message = { ...baseIdentifiedClientState } as IdentifiedClientState; + if (object.clientId !== undefined && object.clientId !== null) { + message.clientId = String(object.clientId); + } else { + message.clientId = ""; + } + if (object.clientState !== undefined && object.clientState !== null) { + message.clientState = Any.fromJSON(object.clientState); + } else { + message.clientState = undefined; + } + return message; + }, + + toJSON(message: IdentifiedClientState): unknown { + const obj: any = {}; + message.clientId !== undefined && (obj.clientId = message.clientId); + message.clientState !== undefined && + (obj.clientState = message.clientState + ? Any.toJSON(message.clientState) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): IdentifiedClientState { + const message = { ...baseIdentifiedClientState } as IdentifiedClientState; + if (object.clientId !== undefined && object.clientId !== null) { + message.clientId = object.clientId; + } else { + message.clientId = ""; + } + if (object.clientState !== undefined && object.clientState !== null) { + message.clientState = Any.fromPartial(object.clientState); + } else { + message.clientState = undefined; + } + return message; + }, +}; + +const baseConsensusStateWithHeight: object = {}; + +export const ConsensusStateWithHeight = { + encode( + message: ConsensusStateWithHeight, + writer: Writer = Writer.create() + ): Writer { + if (message.height !== undefined) { + Height.encode(message.height, writer.uint32(10).fork()).ldelim(); + } + if (message.consensusState !== undefined) { + Any.encode(message.consensusState, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): ConsensusStateWithHeight { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseConsensusStateWithHeight, + } as ConsensusStateWithHeight; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.height = Height.decode(reader, reader.uint32()); + break; + case 2: + message.consensusState = Any.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ConsensusStateWithHeight { + const message = { + ...baseConsensusStateWithHeight, + } as ConsensusStateWithHeight; + if (object.height !== undefined && object.height !== null) { + message.height = Height.fromJSON(object.height); + } else { + message.height = undefined; + } + if (object.consensusState !== undefined && object.consensusState !== null) { + message.consensusState = Any.fromJSON(object.consensusState); + } else { + message.consensusState = undefined; + } + return message; + }, + + toJSON(message: ConsensusStateWithHeight): unknown { + const obj: any = {}; + message.height !== undefined && + (obj.height = message.height ? Height.toJSON(message.height) : undefined); + message.consensusState !== undefined && + (obj.consensusState = message.consensusState + ? Any.toJSON(message.consensusState) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): ConsensusStateWithHeight { + const message = { + ...baseConsensusStateWithHeight, + } as ConsensusStateWithHeight; + if (object.height !== undefined && object.height !== null) { + message.height = Height.fromPartial(object.height); + } else { + message.height = undefined; + } + if (object.consensusState !== undefined && object.consensusState !== null) { + message.consensusState = Any.fromPartial(object.consensusState); + } else { + message.consensusState = undefined; + } + return message; + }, +}; + +const baseClientConsensusStates: object = { clientId: "" }; + +export const ClientConsensusStates = { + encode( + message: ClientConsensusStates, + writer: Writer = Writer.create() + ): Writer { + if (message.clientId !== "") { + writer.uint32(10).string(message.clientId); + } + for (const v of message.consensusStates) { + ConsensusStateWithHeight.encode(v!, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ClientConsensusStates { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseClientConsensusStates } as ClientConsensusStates; + message.consensusStates = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.clientId = reader.string(); + break; + case 2: + message.consensusStates.push( + ConsensusStateWithHeight.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ClientConsensusStates { + const message = { ...baseClientConsensusStates } as ClientConsensusStates; + message.consensusStates = []; + if (object.clientId !== undefined && object.clientId !== null) { + message.clientId = String(object.clientId); + } else { + message.clientId = ""; + } + if ( + object.consensusStates !== undefined && + object.consensusStates !== null + ) { + for (const e of object.consensusStates) { + message.consensusStates.push(ConsensusStateWithHeight.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: ClientConsensusStates): unknown { + const obj: any = {}; + message.clientId !== undefined && (obj.clientId = message.clientId); + if (message.consensusStates) { + obj.consensusStates = message.consensusStates.map((e) => + e ? ConsensusStateWithHeight.toJSON(e) : undefined + ); + } else { + obj.consensusStates = []; + } + return obj; + }, + + fromPartial( + object: DeepPartial + ): ClientConsensusStates { + const message = { ...baseClientConsensusStates } as ClientConsensusStates; + message.consensusStates = []; + if (object.clientId !== undefined && object.clientId !== null) { + message.clientId = object.clientId; + } else { + message.clientId = ""; + } + if ( + object.consensusStates !== undefined && + object.consensusStates !== null + ) { + for (const e of object.consensusStates) { + message.consensusStates.push(ConsensusStateWithHeight.fromPartial(e)); + } + } + return message; + }, +}; + +const baseClientUpdateProposal: object = { + title: "", + description: "", + subjectClientId: "", + substituteClientId: "", +}; + +export const ClientUpdateProposal = { + encode( + message: ClientUpdateProposal, + writer: Writer = Writer.create() + ): Writer { + if (message.title !== "") { + writer.uint32(10).string(message.title); + } + if (message.description !== "") { + writer.uint32(18).string(message.description); + } + if (message.subjectClientId !== "") { + writer.uint32(26).string(message.subjectClientId); + } + if (message.substituteClientId !== "") { + writer.uint32(34).string(message.substituteClientId); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ClientUpdateProposal { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseClientUpdateProposal } as ClientUpdateProposal; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.title = reader.string(); + break; + case 2: + message.description = reader.string(); + break; + case 3: + message.subjectClientId = reader.string(); + break; + case 4: + message.substituteClientId = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ClientUpdateProposal { + const message = { ...baseClientUpdateProposal } as ClientUpdateProposal; + if (object.title !== undefined && object.title !== null) { + message.title = String(object.title); + } else { + message.title = ""; + } + if (object.description !== undefined && object.description !== null) { + message.description = String(object.description); + } else { + message.description = ""; + } + if ( + object.subjectClientId !== undefined && + object.subjectClientId !== null + ) { + message.subjectClientId = String(object.subjectClientId); + } else { + message.subjectClientId = ""; + } + if ( + object.substituteClientId !== undefined && + object.substituteClientId !== null + ) { + message.substituteClientId = String(object.substituteClientId); + } else { + message.substituteClientId = ""; + } + return message; + }, + + toJSON(message: ClientUpdateProposal): unknown { + const obj: any = {}; + message.title !== undefined && (obj.title = message.title); + message.description !== undefined && + (obj.description = message.description); + message.subjectClientId !== undefined && + (obj.subjectClientId = message.subjectClientId); + message.substituteClientId !== undefined && + (obj.substituteClientId = message.substituteClientId); + return obj; + }, + + fromPartial(object: DeepPartial): ClientUpdateProposal { + const message = { ...baseClientUpdateProposal } as ClientUpdateProposal; + if (object.title !== undefined && object.title !== null) { + message.title = object.title; + } else { + message.title = ""; + } + if (object.description !== undefined && object.description !== null) { + message.description = object.description; + } else { + message.description = ""; + } + if ( + object.subjectClientId !== undefined && + object.subjectClientId !== null + ) { + message.subjectClientId = object.subjectClientId; + } else { + message.subjectClientId = ""; + } + if ( + object.substituteClientId !== undefined && + object.substituteClientId !== null + ) { + message.substituteClientId = object.substituteClientId; + } else { + message.substituteClientId = ""; + } + return message; + }, +}; + +const baseUpgradeProposal: object = { title: "", description: "" }; + +export const UpgradeProposal = { + encode(message: UpgradeProposal, writer: Writer = Writer.create()): Writer { + if (message.title !== "") { + writer.uint32(10).string(message.title); + } + if (message.description !== "") { + writer.uint32(18).string(message.description); + } + if (message.plan !== undefined) { + Plan.encode(message.plan, writer.uint32(26).fork()).ldelim(); + } + if (message.upgradedClientState !== undefined) { + Any.encode( + message.upgradedClientState, + writer.uint32(34).fork() + ).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): UpgradeProposal { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseUpgradeProposal } as UpgradeProposal; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.title = reader.string(); + break; + case 2: + message.description = reader.string(); + break; + case 3: + message.plan = Plan.decode(reader, reader.uint32()); + break; + case 4: + message.upgradedClientState = Any.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): UpgradeProposal { + const message = { ...baseUpgradeProposal } as UpgradeProposal; + if (object.title !== undefined && object.title !== null) { + message.title = String(object.title); + } else { + message.title = ""; + } + if (object.description !== undefined && object.description !== null) { + message.description = String(object.description); + } else { + message.description = ""; + } + if (object.plan !== undefined && object.plan !== null) { + message.plan = Plan.fromJSON(object.plan); + } else { + message.plan = undefined; + } + if ( + object.upgradedClientState !== undefined && + object.upgradedClientState !== null + ) { + message.upgradedClientState = Any.fromJSON(object.upgradedClientState); + } else { + message.upgradedClientState = undefined; + } + return message; + }, + + toJSON(message: UpgradeProposal): unknown { + const obj: any = {}; + message.title !== undefined && (obj.title = message.title); + message.description !== undefined && + (obj.description = message.description); + message.plan !== undefined && + (obj.plan = message.plan ? Plan.toJSON(message.plan) : undefined); + message.upgradedClientState !== undefined && + (obj.upgradedClientState = message.upgradedClientState + ? Any.toJSON(message.upgradedClientState) + : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): UpgradeProposal { + const message = { ...baseUpgradeProposal } as UpgradeProposal; + if (object.title !== undefined && object.title !== null) { + message.title = object.title; + } else { + message.title = ""; + } + if (object.description !== undefined && object.description !== null) { + message.description = object.description; + } else { + message.description = ""; + } + if (object.plan !== undefined && object.plan !== null) { + message.plan = Plan.fromPartial(object.plan); + } else { + message.plan = undefined; + } + if ( + object.upgradedClientState !== undefined && + object.upgradedClientState !== null + ) { + message.upgradedClientState = Any.fromPartial(object.upgradedClientState); + } else { + message.upgradedClientState = undefined; + } + return message; + }, +}; + +const baseHeight: object = { revisionNumber: 0, revisionHeight: 0 }; + +export const Height = { + encode(message: Height, writer: Writer = Writer.create()): Writer { + if (message.revisionNumber !== 0) { + writer.uint32(8).uint64(message.revisionNumber); + } + if (message.revisionHeight !== 0) { + writer.uint32(16).uint64(message.revisionHeight); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Height { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseHeight } as Height; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.revisionNumber = longToNumber(reader.uint64() as Long); + break; + case 2: + message.revisionHeight = longToNumber(reader.uint64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Height { + const message = { ...baseHeight } as Height; + if (object.revisionNumber !== undefined && object.revisionNumber !== null) { + message.revisionNumber = Number(object.revisionNumber); + } else { + message.revisionNumber = 0; + } + if (object.revisionHeight !== undefined && object.revisionHeight !== null) { + message.revisionHeight = Number(object.revisionHeight); + } else { + message.revisionHeight = 0; + } + return message; + }, + + toJSON(message: Height): unknown { + const obj: any = {}; + message.revisionNumber !== undefined && + (obj.revisionNumber = message.revisionNumber); + message.revisionHeight !== undefined && + (obj.revisionHeight = message.revisionHeight); + return obj; + }, + + fromPartial(object: DeepPartial): Height { + const message = { ...baseHeight } as Height; + if (object.revisionNumber !== undefined && object.revisionNumber !== null) { + message.revisionNumber = object.revisionNumber; + } else { + message.revisionNumber = 0; + } + if (object.revisionHeight !== undefined && object.revisionHeight !== null) { + message.revisionHeight = object.revisionHeight; + } else { + message.revisionHeight = 0; + } + return message; + }, +}; + +const baseParams: object = { allowedClients: "" }; + +export const Params = { + encode(message: Params, writer: Writer = Writer.create()): Writer { + for (const v of message.allowedClients) { + writer.uint32(10).string(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Params { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseParams } as Params; + message.allowedClients = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.allowedClients.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Params { + const message = { ...baseParams } as Params; + message.allowedClients = []; + if (object.allowedClients !== undefined && object.allowedClients !== null) { + for (const e of object.allowedClients) { + message.allowedClients.push(String(e)); + } + } + return message; + }, + + toJSON(message: Params): unknown { + const obj: any = {}; + if (message.allowedClients) { + obj.allowedClients = message.allowedClients.map((e) => e); + } else { + obj.allowedClients = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): Params { + const message = { ...baseParams } as Params; + message.allowedClients = []; + if (object.allowedClients !== undefined && object.allowedClients !== null) { + for (const e of object.allowedClients) { + message.allowedClients.push(e); + } + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/ibc.core.connection.v1/types/ibc/core/commitment/v1/commitment.ts b/ts-client/ibc.core.connection.v1/types/ibc/core/commitment/v1/commitment.ts new file mode 100644 index 00000000..cc8a6d80 --- /dev/null +++ b/ts-client/ibc.core.connection.v1/types/ibc/core/commitment/v1/commitment.ts @@ -0,0 +1,324 @@ +/* eslint-disable */ +import { CommitmentProof } from "../../../../proofs"; +import { Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "ibc.core.commitment.v1"; + +/** + * MerkleRoot defines a merkle root hash. + * In the Cosmos SDK, the AppHash of a block header becomes the root. + */ +export interface MerkleRoot { + hash: Uint8Array; +} + +/** + * MerklePrefix is merkle path prefixed to the key. + * The constructed key from the Path and the key will be append(Path.KeyPath, + * append(Path.KeyPrefix, key...)) + */ +export interface MerklePrefix { + keyPrefix: Uint8Array; +} + +/** + * MerklePath is the path used to verify commitment proofs, which can be an + * arbitrary structured object (defined by a commitment type). + * MerklePath is represented from root-to-leaf + */ +export interface MerklePath { + keyPath: string[]; +} + +/** + * MerkleProof is a wrapper type over a chain of CommitmentProofs. + * It demonstrates membership or non-membership for an element or set of + * elements, verifiable in conjunction with a known commitment root. Proofs + * should be succinct. + * MerkleProofs are ordered from leaf-to-root + */ +export interface MerkleProof { + proofs: CommitmentProof[]; +} + +const baseMerkleRoot: object = {}; + +export const MerkleRoot = { + encode(message: MerkleRoot, writer: Writer = Writer.create()): Writer { + if (message.hash.length !== 0) { + writer.uint32(10).bytes(message.hash); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MerkleRoot { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMerkleRoot } as MerkleRoot; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.hash = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MerkleRoot { + const message = { ...baseMerkleRoot } as MerkleRoot; + if (object.hash !== undefined && object.hash !== null) { + message.hash = bytesFromBase64(object.hash); + } + return message; + }, + + toJSON(message: MerkleRoot): unknown { + const obj: any = {}; + message.hash !== undefined && + (obj.hash = base64FromBytes( + message.hash !== undefined ? message.hash : new Uint8Array() + )); + return obj; + }, + + fromPartial(object: DeepPartial): MerkleRoot { + const message = { ...baseMerkleRoot } as MerkleRoot; + if (object.hash !== undefined && object.hash !== null) { + message.hash = object.hash; + } else { + message.hash = new Uint8Array(); + } + return message; + }, +}; + +const baseMerklePrefix: object = {}; + +export const MerklePrefix = { + encode(message: MerklePrefix, writer: Writer = Writer.create()): Writer { + if (message.keyPrefix.length !== 0) { + writer.uint32(10).bytes(message.keyPrefix); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MerklePrefix { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMerklePrefix } as MerklePrefix; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.keyPrefix = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MerklePrefix { + const message = { ...baseMerklePrefix } as MerklePrefix; + if (object.keyPrefix !== undefined && object.keyPrefix !== null) { + message.keyPrefix = bytesFromBase64(object.keyPrefix); + } + return message; + }, + + toJSON(message: MerklePrefix): unknown { + const obj: any = {}; + message.keyPrefix !== undefined && + (obj.keyPrefix = base64FromBytes( + message.keyPrefix !== undefined ? message.keyPrefix : new Uint8Array() + )); + return obj; + }, + + fromPartial(object: DeepPartial): MerklePrefix { + const message = { ...baseMerklePrefix } as MerklePrefix; + if (object.keyPrefix !== undefined && object.keyPrefix !== null) { + message.keyPrefix = object.keyPrefix; + } else { + message.keyPrefix = new Uint8Array(); + } + return message; + }, +}; + +const baseMerklePath: object = { keyPath: "" }; + +export const MerklePath = { + encode(message: MerklePath, writer: Writer = Writer.create()): Writer { + for (const v of message.keyPath) { + writer.uint32(10).string(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MerklePath { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMerklePath } as MerklePath; + message.keyPath = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.keyPath.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MerklePath { + const message = { ...baseMerklePath } as MerklePath; + message.keyPath = []; + if (object.keyPath !== undefined && object.keyPath !== null) { + for (const e of object.keyPath) { + message.keyPath.push(String(e)); + } + } + return message; + }, + + toJSON(message: MerklePath): unknown { + const obj: any = {}; + if (message.keyPath) { + obj.keyPath = message.keyPath.map((e) => e); + } else { + obj.keyPath = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): MerklePath { + const message = { ...baseMerklePath } as MerklePath; + message.keyPath = []; + if (object.keyPath !== undefined && object.keyPath !== null) { + for (const e of object.keyPath) { + message.keyPath.push(e); + } + } + return message; + }, +}; + +const baseMerkleProof: object = {}; + +export const MerkleProof = { + encode(message: MerkleProof, writer: Writer = Writer.create()): Writer { + for (const v of message.proofs) { + CommitmentProof.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MerkleProof { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMerkleProof } as MerkleProof; + message.proofs = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.proofs.push(CommitmentProof.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MerkleProof { + const message = { ...baseMerkleProof } as MerkleProof; + message.proofs = []; + if (object.proofs !== undefined && object.proofs !== null) { + for (const e of object.proofs) { + message.proofs.push(CommitmentProof.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: MerkleProof): unknown { + const obj: any = {}; + if (message.proofs) { + obj.proofs = message.proofs.map((e) => + e ? CommitmentProof.toJSON(e) : undefined + ); + } else { + obj.proofs = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): MerkleProof { + const message = { ...baseMerkleProof } as MerkleProof; + message.proofs = []; + if (object.proofs !== undefined && object.proofs !== null) { + for (const e of object.proofs) { + message.proofs.push(CommitmentProof.fromPartial(e)); + } + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/ibc.core.connection.v1/types/ibc/core/connection/v1/connection.ts b/ts-client/ibc.core.connection.v1/types/ibc/core/connection/v1/connection.ts new file mode 100644 index 00000000..55e33aaa --- /dev/null +++ b/ts-client/ibc.core.connection.v1/types/ibc/core/connection/v1/connection.ts @@ -0,0 +1,873 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; +import { MerklePrefix } from "../../../../ibc/core/commitment/v1/commitment"; + +export const protobufPackage = "ibc.core.connection.v1"; + +/** + * State defines if a connection is in one of the following states: + * INIT, TRYOPEN, OPEN or UNINITIALIZED. + */ +export enum State { + /** STATE_UNINITIALIZED_UNSPECIFIED - Default State */ + STATE_UNINITIALIZED_UNSPECIFIED = 0, + /** STATE_INIT - A connection end has just started the opening handshake. */ + STATE_INIT = 1, + /** + * STATE_TRYOPEN - A connection end has acknowledged the handshake step on the counterparty + * chain. + */ + STATE_TRYOPEN = 2, + /** STATE_OPEN - A connection end has completed the handshake. */ + STATE_OPEN = 3, + UNRECOGNIZED = -1, +} + +export function stateFromJSON(object: any): State { + switch (object) { + case 0: + case "STATE_UNINITIALIZED_UNSPECIFIED": + return State.STATE_UNINITIALIZED_UNSPECIFIED; + case 1: + case "STATE_INIT": + return State.STATE_INIT; + case 2: + case "STATE_TRYOPEN": + return State.STATE_TRYOPEN; + case 3: + case "STATE_OPEN": + return State.STATE_OPEN; + case -1: + case "UNRECOGNIZED": + default: + return State.UNRECOGNIZED; + } +} + +export function stateToJSON(object: State): string { + switch (object) { + case State.STATE_UNINITIALIZED_UNSPECIFIED: + return "STATE_UNINITIALIZED_UNSPECIFIED"; + case State.STATE_INIT: + return "STATE_INIT"; + case State.STATE_TRYOPEN: + return "STATE_TRYOPEN"; + case State.STATE_OPEN: + return "STATE_OPEN"; + default: + return "UNKNOWN"; + } +} + +/** + * ConnectionEnd defines a stateful object on a chain connected to another + * separate one. + * NOTE: there must only be 2 defined ConnectionEnds to establish + * a connection between two chains. + */ +export interface ConnectionEnd { + /** client associated with this connection. */ + clientId: string; + /** + * IBC version which can be utilised to determine encodings or protocols for + * channels or packets utilising this connection. + */ + versions: Version[]; + /** current state of the connection end. */ + state: State; + /** counterparty chain associated with this connection. */ + counterparty: Counterparty | undefined; + /** + * delay period that must pass before a consensus state can be used for + * packet-verification NOTE: delay period logic is only implemented by some + * clients. + */ + delayPeriod: number; +} + +/** + * IdentifiedConnection defines a connection with additional connection + * identifier field. + */ +export interface IdentifiedConnection { + /** connection identifier. */ + id: string; + /** client associated with this connection. */ + clientId: string; + /** + * IBC version which can be utilised to determine encodings or protocols for + * channels or packets utilising this connection + */ + versions: Version[]; + /** current state of the connection end. */ + state: State; + /** counterparty chain associated with this connection. */ + counterparty: Counterparty | undefined; + /** delay period associated with this connection. */ + delayPeriod: number; +} + +/** Counterparty defines the counterparty chain associated with a connection end. */ +export interface Counterparty { + /** + * identifies the client on the counterparty chain associated with a given + * connection. + */ + clientId: string; + /** + * identifies the connection end on the counterparty chain associated with a + * given connection. + */ + connectionId: string; + /** commitment merkle prefix of the counterparty chain. */ + prefix: MerklePrefix | undefined; +} + +/** ClientPaths define all the connection paths for a client state. */ +export interface ClientPaths { + /** list of connection paths */ + paths: string[]; +} + +/** ConnectionPaths define all the connection paths for a given client state. */ +export interface ConnectionPaths { + /** client state unique identifier */ + clientId: string; + /** list of connection paths */ + paths: string[]; +} + +/** + * Version defines the versioning scheme used to negotiate the IBC verison in + * the connection handshake. + */ +export interface Version { + /** unique version identifier */ + identifier: string; + /** list of features compatible with the specified identifier */ + features: string[]; +} + +/** Params defines the set of Connection parameters. */ +export interface Params { + /** + * maximum expected time per block (in nanoseconds), used to enforce block delay. This parameter should reflect the + * largest amount of time that the chain might reasonably take to produce the next block under normal operating + * conditions. A safe choice is 3-5x the expected time per block. + */ + maxExpectedTimePerBlock: number; +} + +const baseConnectionEnd: object = { clientId: "", state: 0, delayPeriod: 0 }; + +export const ConnectionEnd = { + encode(message: ConnectionEnd, writer: Writer = Writer.create()): Writer { + if (message.clientId !== "") { + writer.uint32(10).string(message.clientId); + } + for (const v of message.versions) { + Version.encode(v!, writer.uint32(18).fork()).ldelim(); + } + if (message.state !== 0) { + writer.uint32(24).int32(message.state); + } + if (message.counterparty !== undefined) { + Counterparty.encode( + message.counterparty, + writer.uint32(34).fork() + ).ldelim(); + } + if (message.delayPeriod !== 0) { + writer.uint32(40).uint64(message.delayPeriod); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ConnectionEnd { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseConnectionEnd } as ConnectionEnd; + message.versions = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.clientId = reader.string(); + break; + case 2: + message.versions.push(Version.decode(reader, reader.uint32())); + break; + case 3: + message.state = reader.int32() as any; + break; + case 4: + message.counterparty = Counterparty.decode(reader, reader.uint32()); + break; + case 5: + message.delayPeriod = longToNumber(reader.uint64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ConnectionEnd { + const message = { ...baseConnectionEnd } as ConnectionEnd; + message.versions = []; + if (object.clientId !== undefined && object.clientId !== null) { + message.clientId = String(object.clientId); + } else { + message.clientId = ""; + } + if (object.versions !== undefined && object.versions !== null) { + for (const e of object.versions) { + message.versions.push(Version.fromJSON(e)); + } + } + if (object.state !== undefined && object.state !== null) { + message.state = stateFromJSON(object.state); + } else { + message.state = 0; + } + if (object.counterparty !== undefined && object.counterparty !== null) { + message.counterparty = Counterparty.fromJSON(object.counterparty); + } else { + message.counterparty = undefined; + } + if (object.delayPeriod !== undefined && object.delayPeriod !== null) { + message.delayPeriod = Number(object.delayPeriod); + } else { + message.delayPeriod = 0; + } + return message; + }, + + toJSON(message: ConnectionEnd): unknown { + const obj: any = {}; + message.clientId !== undefined && (obj.clientId = message.clientId); + if (message.versions) { + obj.versions = message.versions.map((e) => + e ? Version.toJSON(e) : undefined + ); + } else { + obj.versions = []; + } + message.state !== undefined && (obj.state = stateToJSON(message.state)); + message.counterparty !== undefined && + (obj.counterparty = message.counterparty + ? Counterparty.toJSON(message.counterparty) + : undefined); + message.delayPeriod !== undefined && + (obj.delayPeriod = message.delayPeriod); + return obj; + }, + + fromPartial(object: DeepPartial): ConnectionEnd { + const message = { ...baseConnectionEnd } as ConnectionEnd; + message.versions = []; + if (object.clientId !== undefined && object.clientId !== null) { + message.clientId = object.clientId; + } else { + message.clientId = ""; + } + if (object.versions !== undefined && object.versions !== null) { + for (const e of object.versions) { + message.versions.push(Version.fromPartial(e)); + } + } + if (object.state !== undefined && object.state !== null) { + message.state = object.state; + } else { + message.state = 0; + } + if (object.counterparty !== undefined && object.counterparty !== null) { + message.counterparty = Counterparty.fromPartial(object.counterparty); + } else { + message.counterparty = undefined; + } + if (object.delayPeriod !== undefined && object.delayPeriod !== null) { + message.delayPeriod = object.delayPeriod; + } else { + message.delayPeriod = 0; + } + return message; + }, +}; + +const baseIdentifiedConnection: object = { + id: "", + clientId: "", + state: 0, + delayPeriod: 0, +}; + +export const IdentifiedConnection = { + encode( + message: IdentifiedConnection, + writer: Writer = Writer.create() + ): Writer { + if (message.id !== "") { + writer.uint32(10).string(message.id); + } + if (message.clientId !== "") { + writer.uint32(18).string(message.clientId); + } + for (const v of message.versions) { + Version.encode(v!, writer.uint32(26).fork()).ldelim(); + } + if (message.state !== 0) { + writer.uint32(32).int32(message.state); + } + if (message.counterparty !== undefined) { + Counterparty.encode( + message.counterparty, + writer.uint32(42).fork() + ).ldelim(); + } + if (message.delayPeriod !== 0) { + writer.uint32(48).uint64(message.delayPeriod); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): IdentifiedConnection { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseIdentifiedConnection } as IdentifiedConnection; + message.versions = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.id = reader.string(); + break; + case 2: + message.clientId = reader.string(); + break; + case 3: + message.versions.push(Version.decode(reader, reader.uint32())); + break; + case 4: + message.state = reader.int32() as any; + break; + case 5: + message.counterparty = Counterparty.decode(reader, reader.uint32()); + break; + case 6: + message.delayPeriod = longToNumber(reader.uint64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): IdentifiedConnection { + const message = { ...baseIdentifiedConnection } as IdentifiedConnection; + message.versions = []; + if (object.id !== undefined && object.id !== null) { + message.id = String(object.id); + } else { + message.id = ""; + } + if (object.clientId !== undefined && object.clientId !== null) { + message.clientId = String(object.clientId); + } else { + message.clientId = ""; + } + if (object.versions !== undefined && object.versions !== null) { + for (const e of object.versions) { + message.versions.push(Version.fromJSON(e)); + } + } + if (object.state !== undefined && object.state !== null) { + message.state = stateFromJSON(object.state); + } else { + message.state = 0; + } + if (object.counterparty !== undefined && object.counterparty !== null) { + message.counterparty = Counterparty.fromJSON(object.counterparty); + } else { + message.counterparty = undefined; + } + if (object.delayPeriod !== undefined && object.delayPeriod !== null) { + message.delayPeriod = Number(object.delayPeriod); + } else { + message.delayPeriod = 0; + } + return message; + }, + + toJSON(message: IdentifiedConnection): unknown { + const obj: any = {}; + message.id !== undefined && (obj.id = message.id); + message.clientId !== undefined && (obj.clientId = message.clientId); + if (message.versions) { + obj.versions = message.versions.map((e) => + e ? Version.toJSON(e) : undefined + ); + } else { + obj.versions = []; + } + message.state !== undefined && (obj.state = stateToJSON(message.state)); + message.counterparty !== undefined && + (obj.counterparty = message.counterparty + ? Counterparty.toJSON(message.counterparty) + : undefined); + message.delayPeriod !== undefined && + (obj.delayPeriod = message.delayPeriod); + return obj; + }, + + fromPartial(object: DeepPartial): IdentifiedConnection { + const message = { ...baseIdentifiedConnection } as IdentifiedConnection; + message.versions = []; + if (object.id !== undefined && object.id !== null) { + message.id = object.id; + } else { + message.id = ""; + } + if (object.clientId !== undefined && object.clientId !== null) { + message.clientId = object.clientId; + } else { + message.clientId = ""; + } + if (object.versions !== undefined && object.versions !== null) { + for (const e of object.versions) { + message.versions.push(Version.fromPartial(e)); + } + } + if (object.state !== undefined && object.state !== null) { + message.state = object.state; + } else { + message.state = 0; + } + if (object.counterparty !== undefined && object.counterparty !== null) { + message.counterparty = Counterparty.fromPartial(object.counterparty); + } else { + message.counterparty = undefined; + } + if (object.delayPeriod !== undefined && object.delayPeriod !== null) { + message.delayPeriod = object.delayPeriod; + } else { + message.delayPeriod = 0; + } + return message; + }, +}; + +const baseCounterparty: object = { clientId: "", connectionId: "" }; + +export const Counterparty = { + encode(message: Counterparty, writer: Writer = Writer.create()): Writer { + if (message.clientId !== "") { + writer.uint32(10).string(message.clientId); + } + if (message.connectionId !== "") { + writer.uint32(18).string(message.connectionId); + } + if (message.prefix !== undefined) { + MerklePrefix.encode(message.prefix, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Counterparty { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseCounterparty } as Counterparty; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.clientId = reader.string(); + break; + case 2: + message.connectionId = reader.string(); + break; + case 3: + message.prefix = MerklePrefix.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Counterparty { + const message = { ...baseCounterparty } as Counterparty; + if (object.clientId !== undefined && object.clientId !== null) { + message.clientId = String(object.clientId); + } else { + message.clientId = ""; + } + if (object.connectionId !== undefined && object.connectionId !== null) { + message.connectionId = String(object.connectionId); + } else { + message.connectionId = ""; + } + if (object.prefix !== undefined && object.prefix !== null) { + message.prefix = MerklePrefix.fromJSON(object.prefix); + } else { + message.prefix = undefined; + } + return message; + }, + + toJSON(message: Counterparty): unknown { + const obj: any = {}; + message.clientId !== undefined && (obj.clientId = message.clientId); + message.connectionId !== undefined && + (obj.connectionId = message.connectionId); + message.prefix !== undefined && + (obj.prefix = message.prefix + ? MerklePrefix.toJSON(message.prefix) + : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): Counterparty { + const message = { ...baseCounterparty } as Counterparty; + if (object.clientId !== undefined && object.clientId !== null) { + message.clientId = object.clientId; + } else { + message.clientId = ""; + } + if (object.connectionId !== undefined && object.connectionId !== null) { + message.connectionId = object.connectionId; + } else { + message.connectionId = ""; + } + if (object.prefix !== undefined && object.prefix !== null) { + message.prefix = MerklePrefix.fromPartial(object.prefix); + } else { + message.prefix = undefined; + } + return message; + }, +}; + +const baseClientPaths: object = { paths: "" }; + +export const ClientPaths = { + encode(message: ClientPaths, writer: Writer = Writer.create()): Writer { + for (const v of message.paths) { + writer.uint32(10).string(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ClientPaths { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseClientPaths } as ClientPaths; + message.paths = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.paths.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ClientPaths { + const message = { ...baseClientPaths } as ClientPaths; + message.paths = []; + if (object.paths !== undefined && object.paths !== null) { + for (const e of object.paths) { + message.paths.push(String(e)); + } + } + return message; + }, + + toJSON(message: ClientPaths): unknown { + const obj: any = {}; + if (message.paths) { + obj.paths = message.paths.map((e) => e); + } else { + obj.paths = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): ClientPaths { + const message = { ...baseClientPaths } as ClientPaths; + message.paths = []; + if (object.paths !== undefined && object.paths !== null) { + for (const e of object.paths) { + message.paths.push(e); + } + } + return message; + }, +}; + +const baseConnectionPaths: object = { clientId: "", paths: "" }; + +export const ConnectionPaths = { + encode(message: ConnectionPaths, writer: Writer = Writer.create()): Writer { + if (message.clientId !== "") { + writer.uint32(10).string(message.clientId); + } + for (const v of message.paths) { + writer.uint32(18).string(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ConnectionPaths { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseConnectionPaths } as ConnectionPaths; + message.paths = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.clientId = reader.string(); + break; + case 2: + message.paths.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ConnectionPaths { + const message = { ...baseConnectionPaths } as ConnectionPaths; + message.paths = []; + if (object.clientId !== undefined && object.clientId !== null) { + message.clientId = String(object.clientId); + } else { + message.clientId = ""; + } + if (object.paths !== undefined && object.paths !== null) { + for (const e of object.paths) { + message.paths.push(String(e)); + } + } + return message; + }, + + toJSON(message: ConnectionPaths): unknown { + const obj: any = {}; + message.clientId !== undefined && (obj.clientId = message.clientId); + if (message.paths) { + obj.paths = message.paths.map((e) => e); + } else { + obj.paths = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): ConnectionPaths { + const message = { ...baseConnectionPaths } as ConnectionPaths; + message.paths = []; + if (object.clientId !== undefined && object.clientId !== null) { + message.clientId = object.clientId; + } else { + message.clientId = ""; + } + if (object.paths !== undefined && object.paths !== null) { + for (const e of object.paths) { + message.paths.push(e); + } + } + return message; + }, +}; + +const baseVersion: object = { identifier: "", features: "" }; + +export const Version = { + encode(message: Version, writer: Writer = Writer.create()): Writer { + if (message.identifier !== "") { + writer.uint32(10).string(message.identifier); + } + for (const v of message.features) { + writer.uint32(18).string(v!); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Version { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseVersion } as Version; + message.features = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.identifier = reader.string(); + break; + case 2: + message.features.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Version { + const message = { ...baseVersion } as Version; + message.features = []; + if (object.identifier !== undefined && object.identifier !== null) { + message.identifier = String(object.identifier); + } else { + message.identifier = ""; + } + if (object.features !== undefined && object.features !== null) { + for (const e of object.features) { + message.features.push(String(e)); + } + } + return message; + }, + + toJSON(message: Version): unknown { + const obj: any = {}; + message.identifier !== undefined && (obj.identifier = message.identifier); + if (message.features) { + obj.features = message.features.map((e) => e); + } else { + obj.features = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): Version { + const message = { ...baseVersion } as Version; + message.features = []; + if (object.identifier !== undefined && object.identifier !== null) { + message.identifier = object.identifier; + } else { + message.identifier = ""; + } + if (object.features !== undefined && object.features !== null) { + for (const e of object.features) { + message.features.push(e); + } + } + return message; + }, +}; + +const baseParams: object = { maxExpectedTimePerBlock: 0 }; + +export const Params = { + encode(message: Params, writer: Writer = Writer.create()): Writer { + if (message.maxExpectedTimePerBlock !== 0) { + writer.uint32(8).uint64(message.maxExpectedTimePerBlock); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): Params { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseParams } as Params; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.maxExpectedTimePerBlock = longToNumber( + reader.uint64() as Long + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): Params { + const message = { ...baseParams } as Params; + if ( + object.maxExpectedTimePerBlock !== undefined && + object.maxExpectedTimePerBlock !== null + ) { + message.maxExpectedTimePerBlock = Number(object.maxExpectedTimePerBlock); + } else { + message.maxExpectedTimePerBlock = 0; + } + return message; + }, + + toJSON(message: Params): unknown { + const obj: any = {}; + message.maxExpectedTimePerBlock !== undefined && + (obj.maxExpectedTimePerBlock = message.maxExpectedTimePerBlock); + return obj; + }, + + fromPartial(object: DeepPartial): Params { + const message = { ...baseParams } as Params; + if ( + object.maxExpectedTimePerBlock !== undefined && + object.maxExpectedTimePerBlock !== null + ) { + message.maxExpectedTimePerBlock = object.maxExpectedTimePerBlock; + } else { + message.maxExpectedTimePerBlock = 0; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/ibc.core.connection.v1/types/ibc/core/connection/v1/genesis.ts b/ts-client/ibc.core.connection.v1/types/ibc/core/connection/v1/genesis.ts new file mode 100644 index 00000000..5843f4f7 --- /dev/null +++ b/ts-client/ibc.core.connection.v1/types/ibc/core/connection/v1/genesis.ts @@ -0,0 +1,196 @@ +/* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; +import { + IdentifiedConnection, + ConnectionPaths, + Params, +} from "../../../../ibc/core/connection/v1/connection"; + +export const protobufPackage = "ibc.core.connection.v1"; + +/** GenesisState defines the ibc connection submodule's genesis state. */ +export interface GenesisState { + connections: IdentifiedConnection[]; + clientConnectionPaths: ConnectionPaths[]; + /** the sequence for the next generated connection identifier */ + nextConnectionSequence: number; + params: Params | undefined; +} + +const baseGenesisState: object = { nextConnectionSequence: 0 }; + +export const GenesisState = { + encode(message: GenesisState, writer: Writer = Writer.create()): Writer { + for (const v of message.connections) { + IdentifiedConnection.encode(v!, writer.uint32(10).fork()).ldelim(); + } + for (const v of message.clientConnectionPaths) { + ConnectionPaths.encode(v!, writer.uint32(18).fork()).ldelim(); + } + if (message.nextConnectionSequence !== 0) { + writer.uint32(24).uint64(message.nextConnectionSequence); + } + if (message.params !== undefined) { + Params.encode(message.params, writer.uint32(34).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): GenesisState { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseGenesisState } as GenesisState; + message.connections = []; + message.clientConnectionPaths = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.connections.push( + IdentifiedConnection.decode(reader, reader.uint32()) + ); + break; + case 2: + message.clientConnectionPaths.push( + ConnectionPaths.decode(reader, reader.uint32()) + ); + break; + case 3: + message.nextConnectionSequence = longToNumber( + reader.uint64() as Long + ); + break; + case 4: + message.params = Params.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): GenesisState { + const message = { ...baseGenesisState } as GenesisState; + message.connections = []; + message.clientConnectionPaths = []; + if (object.connections !== undefined && object.connections !== null) { + for (const e of object.connections) { + message.connections.push(IdentifiedConnection.fromJSON(e)); + } + } + if ( + object.clientConnectionPaths !== undefined && + object.clientConnectionPaths !== null + ) { + for (const e of object.clientConnectionPaths) { + message.clientConnectionPaths.push(ConnectionPaths.fromJSON(e)); + } + } + if ( + object.nextConnectionSequence !== undefined && + object.nextConnectionSequence !== null + ) { + message.nextConnectionSequence = Number(object.nextConnectionSequence); + } else { + message.nextConnectionSequence = 0; + } + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromJSON(object.params); + } else { + message.params = undefined; + } + return message; + }, + + toJSON(message: GenesisState): unknown { + const obj: any = {}; + if (message.connections) { + obj.connections = message.connections.map((e) => + e ? IdentifiedConnection.toJSON(e) : undefined + ); + } else { + obj.connections = []; + } + if (message.clientConnectionPaths) { + obj.clientConnectionPaths = message.clientConnectionPaths.map((e) => + e ? ConnectionPaths.toJSON(e) : undefined + ); + } else { + obj.clientConnectionPaths = []; + } + message.nextConnectionSequence !== undefined && + (obj.nextConnectionSequence = message.nextConnectionSequence); + message.params !== undefined && + (obj.params = message.params ? Params.toJSON(message.params) : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): GenesisState { + const message = { ...baseGenesisState } as GenesisState; + message.connections = []; + message.clientConnectionPaths = []; + if (object.connections !== undefined && object.connections !== null) { + for (const e of object.connections) { + message.connections.push(IdentifiedConnection.fromPartial(e)); + } + } + if ( + object.clientConnectionPaths !== undefined && + object.clientConnectionPaths !== null + ) { + for (const e of object.clientConnectionPaths) { + message.clientConnectionPaths.push(ConnectionPaths.fromPartial(e)); + } + } + if ( + object.nextConnectionSequence !== undefined && + object.nextConnectionSequence !== null + ) { + message.nextConnectionSequence = object.nextConnectionSequence; + } else { + message.nextConnectionSequence = 0; + } + if (object.params !== undefined && object.params !== null) { + message.params = Params.fromPartial(object.params); + } else { + message.params = undefined; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/ibc.core.connection.v1/types/ibc/core/connection/v1/query.ts b/ts-client/ibc.core.connection.v1/types/ibc/core/connection/v1/query.ts new file mode 100644 index 00000000..6c2b3313 --- /dev/null +++ b/ts-client/ibc.core.connection.v1/types/ibc/core/connection/v1/query.ts @@ -0,0 +1,1286 @@ +/* eslint-disable */ +import { Reader, util, configure, Writer } from "protobufjs/minimal"; +import * as Long from "long"; +import { + ConnectionEnd, + IdentifiedConnection, +} from "../../../../ibc/core/connection/v1/connection"; +import { + Height, + IdentifiedClientState, +} from "../../../../ibc/core/client/v1/client"; +import { + PageRequest, + PageResponse, +} from "../../../../cosmos/base/query/v1beta1/pagination"; +import { Any } from "../../../../google/protobuf/any"; + +export const protobufPackage = "ibc.core.connection.v1"; + +/** + * QueryConnectionRequest is the request type for the Query/Connection RPC + * method + */ +export interface QueryConnectionRequest { + /** connection unique identifier */ + connectionId: string; +} + +/** + * QueryConnectionResponse is the response type for the Query/Connection RPC + * method. Besides the connection end, it includes a proof and the height from + * which the proof was retrieved. + */ +export interface QueryConnectionResponse { + /** connection associated with the request identifier */ + connection: ConnectionEnd | undefined; + /** merkle proof of existence */ + proof: Uint8Array; + /** height at which the proof was retrieved */ + proofHeight: Height | undefined; +} + +/** + * QueryConnectionsRequest is the request type for the Query/Connections RPC + * method + */ +export interface QueryConnectionsRequest { + pagination: PageRequest | undefined; +} + +/** + * QueryConnectionsResponse is the response type for the Query/Connections RPC + * method. + */ +export interface QueryConnectionsResponse { + /** list of stored connections of the chain. */ + connections: IdentifiedConnection[]; + /** pagination response */ + pagination: PageResponse | undefined; + /** query block height */ + height: Height | undefined; +} + +/** + * QueryClientConnectionsRequest is the request type for the + * Query/ClientConnections RPC method + */ +export interface QueryClientConnectionsRequest { + /** client identifier associated with a connection */ + clientId: string; +} + +/** + * QueryClientConnectionsResponse is the response type for the + * Query/ClientConnections RPC method + */ +export interface QueryClientConnectionsResponse { + /** slice of all the connection paths associated with a client. */ + connectionPaths: string[]; + /** merkle proof of existence */ + proof: Uint8Array; + /** height at which the proof was generated */ + proofHeight: Height | undefined; +} + +/** + * QueryConnectionClientStateRequest is the request type for the + * Query/ConnectionClientState RPC method + */ +export interface QueryConnectionClientStateRequest { + /** connection identifier */ + connectionId: string; +} + +/** + * QueryConnectionClientStateResponse is the response type for the + * Query/ConnectionClientState RPC method + */ +export interface QueryConnectionClientStateResponse { + /** client state associated with the channel */ + identifiedClientState: IdentifiedClientState | undefined; + /** merkle proof of existence */ + proof: Uint8Array; + /** height at which the proof was retrieved */ + proofHeight: Height | undefined; +} + +/** + * QueryConnectionConsensusStateRequest is the request type for the + * Query/ConnectionConsensusState RPC method + */ +export interface QueryConnectionConsensusStateRequest { + /** connection identifier */ + connectionId: string; + revisionNumber: number; + revisionHeight: number; +} + +/** + * QueryConnectionConsensusStateResponse is the response type for the + * Query/ConnectionConsensusState RPC method + */ +export interface QueryConnectionConsensusStateResponse { + /** consensus state associated with the channel */ + consensusState: Any | undefined; + /** client ID associated with the consensus state */ + clientId: string; + /** merkle proof of existence */ + proof: Uint8Array; + /** height at which the proof was retrieved */ + proofHeight: Height | undefined; +} + +const baseQueryConnectionRequest: object = { connectionId: "" }; + +export const QueryConnectionRequest = { + encode( + message: QueryConnectionRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.connectionId !== "") { + writer.uint32(10).string(message.connectionId); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QueryConnectionRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseQueryConnectionRequest } as QueryConnectionRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.connectionId = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryConnectionRequest { + const message = { ...baseQueryConnectionRequest } as QueryConnectionRequest; + if (object.connectionId !== undefined && object.connectionId !== null) { + message.connectionId = String(object.connectionId); + } else { + message.connectionId = ""; + } + return message; + }, + + toJSON(message: QueryConnectionRequest): unknown { + const obj: any = {}; + message.connectionId !== undefined && + (obj.connectionId = message.connectionId); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryConnectionRequest { + const message = { ...baseQueryConnectionRequest } as QueryConnectionRequest; + if (object.connectionId !== undefined && object.connectionId !== null) { + message.connectionId = object.connectionId; + } else { + message.connectionId = ""; + } + return message; + }, +}; + +const baseQueryConnectionResponse: object = {}; + +export const QueryConnectionResponse = { + encode( + message: QueryConnectionResponse, + writer: Writer = Writer.create() + ): Writer { + if (message.connection !== undefined) { + ConnectionEnd.encode( + message.connection, + writer.uint32(10).fork() + ).ldelim(); + } + if (message.proof.length !== 0) { + writer.uint32(18).bytes(message.proof); + } + if (message.proofHeight !== undefined) { + Height.encode(message.proofHeight, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QueryConnectionResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryConnectionResponse, + } as QueryConnectionResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.connection = ConnectionEnd.decode(reader, reader.uint32()); + break; + case 2: + message.proof = reader.bytes(); + break; + case 3: + message.proofHeight = Height.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryConnectionResponse { + const message = { + ...baseQueryConnectionResponse, + } as QueryConnectionResponse; + if (object.connection !== undefined && object.connection !== null) { + message.connection = ConnectionEnd.fromJSON(object.connection); + } else { + message.connection = undefined; + } + if (object.proof !== undefined && object.proof !== null) { + message.proof = bytesFromBase64(object.proof); + } + if (object.proofHeight !== undefined && object.proofHeight !== null) { + message.proofHeight = Height.fromJSON(object.proofHeight); + } else { + message.proofHeight = undefined; + } + return message; + }, + + toJSON(message: QueryConnectionResponse): unknown { + const obj: any = {}; + message.connection !== undefined && + (obj.connection = message.connection + ? ConnectionEnd.toJSON(message.connection) + : undefined); + message.proof !== undefined && + (obj.proof = base64FromBytes( + message.proof !== undefined ? message.proof : new Uint8Array() + )); + message.proofHeight !== undefined && + (obj.proofHeight = message.proofHeight + ? Height.toJSON(message.proofHeight) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryConnectionResponse { + const message = { + ...baseQueryConnectionResponse, + } as QueryConnectionResponse; + if (object.connection !== undefined && object.connection !== null) { + message.connection = ConnectionEnd.fromPartial(object.connection); + } else { + message.connection = undefined; + } + if (object.proof !== undefined && object.proof !== null) { + message.proof = object.proof; + } else { + message.proof = new Uint8Array(); + } + if (object.proofHeight !== undefined && object.proofHeight !== null) { + message.proofHeight = Height.fromPartial(object.proofHeight); + } else { + message.proofHeight = undefined; + } + return message; + }, +}; + +const baseQueryConnectionsRequest: object = {}; + +export const QueryConnectionsRequest = { + encode( + message: QueryConnectionsRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.pagination !== undefined) { + PageRequest.encode(message.pagination, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): QueryConnectionsRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryConnectionsRequest, + } as QueryConnectionsRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.pagination = PageRequest.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryConnectionsRequest { + const message = { + ...baseQueryConnectionsRequest, + } as QueryConnectionsRequest; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, + + toJSON(message: QueryConnectionsRequest): unknown { + const obj: any = {}; + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageRequest.toJSON(message.pagination) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryConnectionsRequest { + const message = { + ...baseQueryConnectionsRequest, + } as QueryConnectionsRequest; + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageRequest.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + return message; + }, +}; + +const baseQueryConnectionsResponse: object = {}; + +export const QueryConnectionsResponse = { + encode( + message: QueryConnectionsResponse, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.connections) { + IdentifiedConnection.encode(v!, writer.uint32(10).fork()).ldelim(); + } + if (message.pagination !== undefined) { + PageResponse.encode( + message.pagination, + writer.uint32(18).fork() + ).ldelim(); + } + if (message.height !== undefined) { + Height.encode(message.height, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryConnectionsResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryConnectionsResponse, + } as QueryConnectionsResponse; + message.connections = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.connections.push( + IdentifiedConnection.decode(reader, reader.uint32()) + ); + break; + case 2: + message.pagination = PageResponse.decode(reader, reader.uint32()); + break; + case 3: + message.height = Height.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryConnectionsResponse { + const message = { + ...baseQueryConnectionsResponse, + } as QueryConnectionsResponse; + message.connections = []; + if (object.connections !== undefined && object.connections !== null) { + for (const e of object.connections) { + message.connections.push(IdentifiedConnection.fromJSON(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromJSON(object.pagination); + } else { + message.pagination = undefined; + } + if (object.height !== undefined && object.height !== null) { + message.height = Height.fromJSON(object.height); + } else { + message.height = undefined; + } + return message; + }, + + toJSON(message: QueryConnectionsResponse): unknown { + const obj: any = {}; + if (message.connections) { + obj.connections = message.connections.map((e) => + e ? IdentifiedConnection.toJSON(e) : undefined + ); + } else { + obj.connections = []; + } + message.pagination !== undefined && + (obj.pagination = message.pagination + ? PageResponse.toJSON(message.pagination) + : undefined); + message.height !== undefined && + (obj.height = message.height ? Height.toJSON(message.height) : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryConnectionsResponse { + const message = { + ...baseQueryConnectionsResponse, + } as QueryConnectionsResponse; + message.connections = []; + if (object.connections !== undefined && object.connections !== null) { + for (const e of object.connections) { + message.connections.push(IdentifiedConnection.fromPartial(e)); + } + } + if (object.pagination !== undefined && object.pagination !== null) { + message.pagination = PageResponse.fromPartial(object.pagination); + } else { + message.pagination = undefined; + } + if (object.height !== undefined && object.height !== null) { + message.height = Height.fromPartial(object.height); + } else { + message.height = undefined; + } + return message; + }, +}; + +const baseQueryClientConnectionsRequest: object = { clientId: "" }; + +export const QueryClientConnectionsRequest = { + encode( + message: QueryClientConnectionsRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.clientId !== "") { + writer.uint32(10).string(message.clientId); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryClientConnectionsRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryClientConnectionsRequest, + } as QueryClientConnectionsRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.clientId = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryClientConnectionsRequest { + const message = { + ...baseQueryClientConnectionsRequest, + } as QueryClientConnectionsRequest; + if (object.clientId !== undefined && object.clientId !== null) { + message.clientId = String(object.clientId); + } else { + message.clientId = ""; + } + return message; + }, + + toJSON(message: QueryClientConnectionsRequest): unknown { + const obj: any = {}; + message.clientId !== undefined && (obj.clientId = message.clientId); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryClientConnectionsRequest { + const message = { + ...baseQueryClientConnectionsRequest, + } as QueryClientConnectionsRequest; + if (object.clientId !== undefined && object.clientId !== null) { + message.clientId = object.clientId; + } else { + message.clientId = ""; + } + return message; + }, +}; + +const baseQueryClientConnectionsResponse: object = { connectionPaths: "" }; + +export const QueryClientConnectionsResponse = { + encode( + message: QueryClientConnectionsResponse, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.connectionPaths) { + writer.uint32(10).string(v!); + } + if (message.proof.length !== 0) { + writer.uint32(18).bytes(message.proof); + } + if (message.proofHeight !== undefined) { + Height.encode(message.proofHeight, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryClientConnectionsResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryClientConnectionsResponse, + } as QueryClientConnectionsResponse; + message.connectionPaths = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.connectionPaths.push(reader.string()); + break; + case 2: + message.proof = reader.bytes(); + break; + case 3: + message.proofHeight = Height.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryClientConnectionsResponse { + const message = { + ...baseQueryClientConnectionsResponse, + } as QueryClientConnectionsResponse; + message.connectionPaths = []; + if ( + object.connectionPaths !== undefined && + object.connectionPaths !== null + ) { + for (const e of object.connectionPaths) { + message.connectionPaths.push(String(e)); + } + } + if (object.proof !== undefined && object.proof !== null) { + message.proof = bytesFromBase64(object.proof); + } + if (object.proofHeight !== undefined && object.proofHeight !== null) { + message.proofHeight = Height.fromJSON(object.proofHeight); + } else { + message.proofHeight = undefined; + } + return message; + }, + + toJSON(message: QueryClientConnectionsResponse): unknown { + const obj: any = {}; + if (message.connectionPaths) { + obj.connectionPaths = message.connectionPaths.map((e) => e); + } else { + obj.connectionPaths = []; + } + message.proof !== undefined && + (obj.proof = base64FromBytes( + message.proof !== undefined ? message.proof : new Uint8Array() + )); + message.proofHeight !== undefined && + (obj.proofHeight = message.proofHeight + ? Height.toJSON(message.proofHeight) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryClientConnectionsResponse { + const message = { + ...baseQueryClientConnectionsResponse, + } as QueryClientConnectionsResponse; + message.connectionPaths = []; + if ( + object.connectionPaths !== undefined && + object.connectionPaths !== null + ) { + for (const e of object.connectionPaths) { + message.connectionPaths.push(e); + } + } + if (object.proof !== undefined && object.proof !== null) { + message.proof = object.proof; + } else { + message.proof = new Uint8Array(); + } + if (object.proofHeight !== undefined && object.proofHeight !== null) { + message.proofHeight = Height.fromPartial(object.proofHeight); + } else { + message.proofHeight = undefined; + } + return message; + }, +}; + +const baseQueryConnectionClientStateRequest: object = { connectionId: "" }; + +export const QueryConnectionClientStateRequest = { + encode( + message: QueryConnectionClientStateRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.connectionId !== "") { + writer.uint32(10).string(message.connectionId); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryConnectionClientStateRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryConnectionClientStateRequest, + } as QueryConnectionClientStateRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.connectionId = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryConnectionClientStateRequest { + const message = { + ...baseQueryConnectionClientStateRequest, + } as QueryConnectionClientStateRequest; + if (object.connectionId !== undefined && object.connectionId !== null) { + message.connectionId = String(object.connectionId); + } else { + message.connectionId = ""; + } + return message; + }, + + toJSON(message: QueryConnectionClientStateRequest): unknown { + const obj: any = {}; + message.connectionId !== undefined && + (obj.connectionId = message.connectionId); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryConnectionClientStateRequest { + const message = { + ...baseQueryConnectionClientStateRequest, + } as QueryConnectionClientStateRequest; + if (object.connectionId !== undefined && object.connectionId !== null) { + message.connectionId = object.connectionId; + } else { + message.connectionId = ""; + } + return message; + }, +}; + +const baseQueryConnectionClientStateResponse: object = {}; + +export const QueryConnectionClientStateResponse = { + encode( + message: QueryConnectionClientStateResponse, + writer: Writer = Writer.create() + ): Writer { + if (message.identifiedClientState !== undefined) { + IdentifiedClientState.encode( + message.identifiedClientState, + writer.uint32(10).fork() + ).ldelim(); + } + if (message.proof.length !== 0) { + writer.uint32(18).bytes(message.proof); + } + if (message.proofHeight !== undefined) { + Height.encode(message.proofHeight, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryConnectionClientStateResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryConnectionClientStateResponse, + } as QueryConnectionClientStateResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.identifiedClientState = IdentifiedClientState.decode( + reader, + reader.uint32() + ); + break; + case 2: + message.proof = reader.bytes(); + break; + case 3: + message.proofHeight = Height.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryConnectionClientStateResponse { + const message = { + ...baseQueryConnectionClientStateResponse, + } as QueryConnectionClientStateResponse; + if ( + object.identifiedClientState !== undefined && + object.identifiedClientState !== null + ) { + message.identifiedClientState = IdentifiedClientState.fromJSON( + object.identifiedClientState + ); + } else { + message.identifiedClientState = undefined; + } + if (object.proof !== undefined && object.proof !== null) { + message.proof = bytesFromBase64(object.proof); + } + if (object.proofHeight !== undefined && object.proofHeight !== null) { + message.proofHeight = Height.fromJSON(object.proofHeight); + } else { + message.proofHeight = undefined; + } + return message; + }, + + toJSON(message: QueryConnectionClientStateResponse): unknown { + const obj: any = {}; + message.identifiedClientState !== undefined && + (obj.identifiedClientState = message.identifiedClientState + ? IdentifiedClientState.toJSON(message.identifiedClientState) + : undefined); + message.proof !== undefined && + (obj.proof = base64FromBytes( + message.proof !== undefined ? message.proof : new Uint8Array() + )); + message.proofHeight !== undefined && + (obj.proofHeight = message.proofHeight + ? Height.toJSON(message.proofHeight) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryConnectionClientStateResponse { + const message = { + ...baseQueryConnectionClientStateResponse, + } as QueryConnectionClientStateResponse; + if ( + object.identifiedClientState !== undefined && + object.identifiedClientState !== null + ) { + message.identifiedClientState = IdentifiedClientState.fromPartial( + object.identifiedClientState + ); + } else { + message.identifiedClientState = undefined; + } + if (object.proof !== undefined && object.proof !== null) { + message.proof = object.proof; + } else { + message.proof = new Uint8Array(); + } + if (object.proofHeight !== undefined && object.proofHeight !== null) { + message.proofHeight = Height.fromPartial(object.proofHeight); + } else { + message.proofHeight = undefined; + } + return message; + }, +}; + +const baseQueryConnectionConsensusStateRequest: object = { + connectionId: "", + revisionNumber: 0, + revisionHeight: 0, +}; + +export const QueryConnectionConsensusStateRequest = { + encode( + message: QueryConnectionConsensusStateRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.connectionId !== "") { + writer.uint32(10).string(message.connectionId); + } + if (message.revisionNumber !== 0) { + writer.uint32(16).uint64(message.revisionNumber); + } + if (message.revisionHeight !== 0) { + writer.uint32(24).uint64(message.revisionHeight); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryConnectionConsensusStateRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryConnectionConsensusStateRequest, + } as QueryConnectionConsensusStateRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.connectionId = reader.string(); + break; + case 2: + message.revisionNumber = longToNumber(reader.uint64() as Long); + break; + case 3: + message.revisionHeight = longToNumber(reader.uint64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryConnectionConsensusStateRequest { + const message = { + ...baseQueryConnectionConsensusStateRequest, + } as QueryConnectionConsensusStateRequest; + if (object.connectionId !== undefined && object.connectionId !== null) { + message.connectionId = String(object.connectionId); + } else { + message.connectionId = ""; + } + if (object.revisionNumber !== undefined && object.revisionNumber !== null) { + message.revisionNumber = Number(object.revisionNumber); + } else { + message.revisionNumber = 0; + } + if (object.revisionHeight !== undefined && object.revisionHeight !== null) { + message.revisionHeight = Number(object.revisionHeight); + } else { + message.revisionHeight = 0; + } + return message; + }, + + toJSON(message: QueryConnectionConsensusStateRequest): unknown { + const obj: any = {}; + message.connectionId !== undefined && + (obj.connectionId = message.connectionId); + message.revisionNumber !== undefined && + (obj.revisionNumber = message.revisionNumber); + message.revisionHeight !== undefined && + (obj.revisionHeight = message.revisionHeight); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryConnectionConsensusStateRequest { + const message = { + ...baseQueryConnectionConsensusStateRequest, + } as QueryConnectionConsensusStateRequest; + if (object.connectionId !== undefined && object.connectionId !== null) { + message.connectionId = object.connectionId; + } else { + message.connectionId = ""; + } + if (object.revisionNumber !== undefined && object.revisionNumber !== null) { + message.revisionNumber = object.revisionNumber; + } else { + message.revisionNumber = 0; + } + if (object.revisionHeight !== undefined && object.revisionHeight !== null) { + message.revisionHeight = object.revisionHeight; + } else { + message.revisionHeight = 0; + } + return message; + }, +}; + +const baseQueryConnectionConsensusStateResponse: object = { clientId: "" }; + +export const QueryConnectionConsensusStateResponse = { + encode( + message: QueryConnectionConsensusStateResponse, + writer: Writer = Writer.create() + ): Writer { + if (message.consensusState !== undefined) { + Any.encode(message.consensusState, writer.uint32(10).fork()).ldelim(); + } + if (message.clientId !== "") { + writer.uint32(18).string(message.clientId); + } + if (message.proof.length !== 0) { + writer.uint32(26).bytes(message.proof); + } + if (message.proofHeight !== undefined) { + Height.encode(message.proofHeight, writer.uint32(34).fork()).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryConnectionConsensusStateResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryConnectionConsensusStateResponse, + } as QueryConnectionConsensusStateResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.consensusState = Any.decode(reader, reader.uint32()); + break; + case 2: + message.clientId = reader.string(); + break; + case 3: + message.proof = reader.bytes(); + break; + case 4: + message.proofHeight = Height.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryConnectionConsensusStateResponse { + const message = { + ...baseQueryConnectionConsensusStateResponse, + } as QueryConnectionConsensusStateResponse; + if (object.consensusState !== undefined && object.consensusState !== null) { + message.consensusState = Any.fromJSON(object.consensusState); + } else { + message.consensusState = undefined; + } + if (object.clientId !== undefined && object.clientId !== null) { + message.clientId = String(object.clientId); + } else { + message.clientId = ""; + } + if (object.proof !== undefined && object.proof !== null) { + message.proof = bytesFromBase64(object.proof); + } + if (object.proofHeight !== undefined && object.proofHeight !== null) { + message.proofHeight = Height.fromJSON(object.proofHeight); + } else { + message.proofHeight = undefined; + } + return message; + }, + + toJSON(message: QueryConnectionConsensusStateResponse): unknown { + const obj: any = {}; + message.consensusState !== undefined && + (obj.consensusState = message.consensusState + ? Any.toJSON(message.consensusState) + : undefined); + message.clientId !== undefined && (obj.clientId = message.clientId); + message.proof !== undefined && + (obj.proof = base64FromBytes( + message.proof !== undefined ? message.proof : new Uint8Array() + )); + message.proofHeight !== undefined && + (obj.proofHeight = message.proofHeight + ? Height.toJSON(message.proofHeight) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryConnectionConsensusStateResponse { + const message = { + ...baseQueryConnectionConsensusStateResponse, + } as QueryConnectionConsensusStateResponse; + if (object.consensusState !== undefined && object.consensusState !== null) { + message.consensusState = Any.fromPartial(object.consensusState); + } else { + message.consensusState = undefined; + } + if (object.clientId !== undefined && object.clientId !== null) { + message.clientId = object.clientId; + } else { + message.clientId = ""; + } + if (object.proof !== undefined && object.proof !== null) { + message.proof = object.proof; + } else { + message.proof = new Uint8Array(); + } + if (object.proofHeight !== undefined && object.proofHeight !== null) { + message.proofHeight = Height.fromPartial(object.proofHeight); + } else { + message.proofHeight = undefined; + } + return message; + }, +}; + +/** Query provides defines the gRPC querier service */ +export interface Query { + /** Connection queries an IBC connection end. */ + Connection(request: QueryConnectionRequest): Promise; + /** Connections queries all the IBC connections of a chain. */ + Connections( + request: QueryConnectionsRequest + ): Promise; + /** + * ClientConnections queries the connection paths associated with a client + * state. + */ + ClientConnections( + request: QueryClientConnectionsRequest + ): Promise; + /** + * ConnectionClientState queries the client state associated with the + * connection. + */ + ConnectionClientState( + request: QueryConnectionClientStateRequest + ): Promise; + /** + * ConnectionConsensusState queries the consensus state associated with the + * connection. + */ + ConnectionConsensusState( + request: QueryConnectionConsensusStateRequest + ): Promise; +} + +export class QueryClientImpl implements Query { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + } + Connection( + request: QueryConnectionRequest + ): Promise { + const data = QueryConnectionRequest.encode(request).finish(); + const promise = this.rpc.request( + "ibc.core.connection.v1.Query", + "Connection", + data + ); + return promise.then((data) => + QueryConnectionResponse.decode(new Reader(data)) + ); + } + + Connections( + request: QueryConnectionsRequest + ): Promise { + const data = QueryConnectionsRequest.encode(request).finish(); + const promise = this.rpc.request( + "ibc.core.connection.v1.Query", + "Connections", + data + ); + return promise.then((data) => + QueryConnectionsResponse.decode(new Reader(data)) + ); + } + + ClientConnections( + request: QueryClientConnectionsRequest + ): Promise { + const data = QueryClientConnectionsRequest.encode(request).finish(); + const promise = this.rpc.request( + "ibc.core.connection.v1.Query", + "ClientConnections", + data + ); + return promise.then((data) => + QueryClientConnectionsResponse.decode(new Reader(data)) + ); + } + + ConnectionClientState( + request: QueryConnectionClientStateRequest + ): Promise { + const data = QueryConnectionClientStateRequest.encode(request).finish(); + const promise = this.rpc.request( + "ibc.core.connection.v1.Query", + "ConnectionClientState", + data + ); + return promise.then((data) => + QueryConnectionClientStateResponse.decode(new Reader(data)) + ); + } + + ConnectionConsensusState( + request: QueryConnectionConsensusStateRequest + ): Promise { + const data = QueryConnectionConsensusStateRequest.encode(request).finish(); + const promise = this.rpc.request( + "ibc.core.connection.v1.Query", + "ConnectionConsensusState", + data + ); + return promise.then((data) => + QueryConnectionConsensusStateResponse.decode(new Reader(data)) + ); + } +} + +interface Rpc { + request( + service: string, + method: string, + data: Uint8Array + ): Promise; +} + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/ibc.core.connection.v1/types/ibc/core/connection/v1/tx.ts b/ts-client/ibc.core.connection.v1/types/ibc/core/connection/v1/tx.ts new file mode 100644 index 00000000..3fc491a3 --- /dev/null +++ b/ts-client/ibc.core.connection.v1/types/ibc/core/connection/v1/tx.ts @@ -0,0 +1,1283 @@ +/* eslint-disable */ +import { Reader, util, configure, Writer } from "protobufjs/minimal"; +import * as Long from "long"; +import { + Counterparty, + Version, +} from "../../../../ibc/core/connection/v1/connection"; +import { Any } from "../../../../google/protobuf/any"; +import { Height } from "../../../../ibc/core/client/v1/client"; + +export const protobufPackage = "ibc.core.connection.v1"; + +/** + * MsgConnectionOpenInit defines the msg sent by an account on Chain A to + * initialize a connection with Chain B. + */ +export interface MsgConnectionOpenInit { + clientId: string; + counterparty: Counterparty | undefined; + version: Version | undefined; + delayPeriod: number; + signer: string; +} + +/** + * MsgConnectionOpenInitResponse defines the Msg/ConnectionOpenInit response + * type. + */ +export interface MsgConnectionOpenInitResponse {} + +/** + * MsgConnectionOpenTry defines a msg sent by a Relayer to try to open a + * connection on Chain B. + */ +export interface MsgConnectionOpenTry { + clientId: string; + /** + * Deprecated: this field is unused. Crossing hellos are no longer supported in core IBC. + * + * @deprecated + */ + previousConnectionId: string; + clientState: Any | undefined; + counterparty: Counterparty | undefined; + delayPeriod: number; + counterpartyVersions: Version[]; + proofHeight: Height | undefined; + /** + * proof of the initialization the connection on Chain A: `UNITIALIZED -> + * INIT` + */ + proofInit: Uint8Array; + /** proof of client state included in message */ + proofClient: Uint8Array; + /** proof of client consensus state */ + proofConsensus: Uint8Array; + consensusHeight: Height | undefined; + signer: string; +} + +/** MsgConnectionOpenTryResponse defines the Msg/ConnectionOpenTry response type. */ +export interface MsgConnectionOpenTryResponse {} + +/** + * MsgConnectionOpenAck defines a msg sent by a Relayer to Chain A to + * acknowledge the change of connection state to TRYOPEN on Chain B. + */ +export interface MsgConnectionOpenAck { + connectionId: string; + counterpartyConnectionId: string; + version: Version | undefined; + clientState: Any | undefined; + proofHeight: Height | undefined; + /** + * proof of the initialization the connection on Chain B: `UNITIALIZED -> + * TRYOPEN` + */ + proofTry: Uint8Array; + /** proof of client state included in message */ + proofClient: Uint8Array; + /** proof of client consensus state */ + proofConsensus: Uint8Array; + consensusHeight: Height | undefined; + signer: string; +} + +/** MsgConnectionOpenAckResponse defines the Msg/ConnectionOpenAck response type. */ +export interface MsgConnectionOpenAckResponse {} + +/** + * MsgConnectionOpenConfirm defines a msg sent by a Relayer to Chain B to + * acknowledge the change of connection state to OPEN on Chain A. + */ +export interface MsgConnectionOpenConfirm { + connectionId: string; + /** proof for the change of the connection state on Chain A: `INIT -> OPEN` */ + proofAck: Uint8Array; + proofHeight: Height | undefined; + signer: string; +} + +/** + * MsgConnectionOpenConfirmResponse defines the Msg/ConnectionOpenConfirm + * response type. + */ +export interface MsgConnectionOpenConfirmResponse {} + +const baseMsgConnectionOpenInit: object = { + clientId: "", + delayPeriod: 0, + signer: "", +}; + +export const MsgConnectionOpenInit = { + encode( + message: MsgConnectionOpenInit, + writer: Writer = Writer.create() + ): Writer { + if (message.clientId !== "") { + writer.uint32(10).string(message.clientId); + } + if (message.counterparty !== undefined) { + Counterparty.encode( + message.counterparty, + writer.uint32(18).fork() + ).ldelim(); + } + if (message.version !== undefined) { + Version.encode(message.version, writer.uint32(26).fork()).ldelim(); + } + if (message.delayPeriod !== 0) { + writer.uint32(32).uint64(message.delayPeriod); + } + if (message.signer !== "") { + writer.uint32(42).string(message.signer); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MsgConnectionOpenInit { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgConnectionOpenInit } as MsgConnectionOpenInit; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.clientId = reader.string(); + break; + case 2: + message.counterparty = Counterparty.decode(reader, reader.uint32()); + break; + case 3: + message.version = Version.decode(reader, reader.uint32()); + break; + case 4: + message.delayPeriod = longToNumber(reader.uint64() as Long); + break; + case 5: + message.signer = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgConnectionOpenInit { + const message = { ...baseMsgConnectionOpenInit } as MsgConnectionOpenInit; + if (object.clientId !== undefined && object.clientId !== null) { + message.clientId = String(object.clientId); + } else { + message.clientId = ""; + } + if (object.counterparty !== undefined && object.counterparty !== null) { + message.counterparty = Counterparty.fromJSON(object.counterparty); + } else { + message.counterparty = undefined; + } + if (object.version !== undefined && object.version !== null) { + message.version = Version.fromJSON(object.version); + } else { + message.version = undefined; + } + if (object.delayPeriod !== undefined && object.delayPeriod !== null) { + message.delayPeriod = Number(object.delayPeriod); + } else { + message.delayPeriod = 0; + } + if (object.signer !== undefined && object.signer !== null) { + message.signer = String(object.signer); + } else { + message.signer = ""; + } + return message; + }, + + toJSON(message: MsgConnectionOpenInit): unknown { + const obj: any = {}; + message.clientId !== undefined && (obj.clientId = message.clientId); + message.counterparty !== undefined && + (obj.counterparty = message.counterparty + ? Counterparty.toJSON(message.counterparty) + : undefined); + message.version !== undefined && + (obj.version = message.version + ? Version.toJSON(message.version) + : undefined); + message.delayPeriod !== undefined && + (obj.delayPeriod = message.delayPeriod); + message.signer !== undefined && (obj.signer = message.signer); + return obj; + }, + + fromPartial( + object: DeepPartial + ): MsgConnectionOpenInit { + const message = { ...baseMsgConnectionOpenInit } as MsgConnectionOpenInit; + if (object.clientId !== undefined && object.clientId !== null) { + message.clientId = object.clientId; + } else { + message.clientId = ""; + } + if (object.counterparty !== undefined && object.counterparty !== null) { + message.counterparty = Counterparty.fromPartial(object.counterparty); + } else { + message.counterparty = undefined; + } + if (object.version !== undefined && object.version !== null) { + message.version = Version.fromPartial(object.version); + } else { + message.version = undefined; + } + if (object.delayPeriod !== undefined && object.delayPeriod !== null) { + message.delayPeriod = object.delayPeriod; + } else { + message.delayPeriod = 0; + } + if (object.signer !== undefined && object.signer !== null) { + message.signer = object.signer; + } else { + message.signer = ""; + } + return message; + }, +}; + +const baseMsgConnectionOpenInitResponse: object = {}; + +export const MsgConnectionOpenInitResponse = { + encode( + _: MsgConnectionOpenInitResponse, + writer: Writer = Writer.create() + ): Writer { + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): MsgConnectionOpenInitResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseMsgConnectionOpenInitResponse, + } as MsgConnectionOpenInitResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): MsgConnectionOpenInitResponse { + const message = { + ...baseMsgConnectionOpenInitResponse, + } as MsgConnectionOpenInitResponse; + return message; + }, + + toJSON(_: MsgConnectionOpenInitResponse): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial( + _: DeepPartial + ): MsgConnectionOpenInitResponse { + const message = { + ...baseMsgConnectionOpenInitResponse, + } as MsgConnectionOpenInitResponse; + return message; + }, +}; + +const baseMsgConnectionOpenTry: object = { + clientId: "", + previousConnectionId: "", + delayPeriod: 0, + signer: "", +}; + +export const MsgConnectionOpenTry = { + encode( + message: MsgConnectionOpenTry, + writer: Writer = Writer.create() + ): Writer { + if (message.clientId !== "") { + writer.uint32(10).string(message.clientId); + } + if (message.previousConnectionId !== "") { + writer.uint32(18).string(message.previousConnectionId); + } + if (message.clientState !== undefined) { + Any.encode(message.clientState, writer.uint32(26).fork()).ldelim(); + } + if (message.counterparty !== undefined) { + Counterparty.encode( + message.counterparty, + writer.uint32(34).fork() + ).ldelim(); + } + if (message.delayPeriod !== 0) { + writer.uint32(40).uint64(message.delayPeriod); + } + for (const v of message.counterpartyVersions) { + Version.encode(v!, writer.uint32(50).fork()).ldelim(); + } + if (message.proofHeight !== undefined) { + Height.encode(message.proofHeight, writer.uint32(58).fork()).ldelim(); + } + if (message.proofInit.length !== 0) { + writer.uint32(66).bytes(message.proofInit); + } + if (message.proofClient.length !== 0) { + writer.uint32(74).bytes(message.proofClient); + } + if (message.proofConsensus.length !== 0) { + writer.uint32(82).bytes(message.proofConsensus); + } + if (message.consensusHeight !== undefined) { + Height.encode(message.consensusHeight, writer.uint32(90).fork()).ldelim(); + } + if (message.signer !== "") { + writer.uint32(98).string(message.signer); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MsgConnectionOpenTry { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgConnectionOpenTry } as MsgConnectionOpenTry; + message.counterpartyVersions = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.clientId = reader.string(); + break; + case 2: + message.previousConnectionId = reader.string(); + break; + case 3: + message.clientState = Any.decode(reader, reader.uint32()); + break; + case 4: + message.counterparty = Counterparty.decode(reader, reader.uint32()); + break; + case 5: + message.delayPeriod = longToNumber(reader.uint64() as Long); + break; + case 6: + message.counterpartyVersions.push( + Version.decode(reader, reader.uint32()) + ); + break; + case 7: + message.proofHeight = Height.decode(reader, reader.uint32()); + break; + case 8: + message.proofInit = reader.bytes(); + break; + case 9: + message.proofClient = reader.bytes(); + break; + case 10: + message.proofConsensus = reader.bytes(); + break; + case 11: + message.consensusHeight = Height.decode(reader, reader.uint32()); + break; + case 12: + message.signer = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgConnectionOpenTry { + const message = { ...baseMsgConnectionOpenTry } as MsgConnectionOpenTry; + message.counterpartyVersions = []; + if (object.clientId !== undefined && object.clientId !== null) { + message.clientId = String(object.clientId); + } else { + message.clientId = ""; + } + if ( + object.previousConnectionId !== undefined && + object.previousConnectionId !== null + ) { + message.previousConnectionId = String(object.previousConnectionId); + } else { + message.previousConnectionId = ""; + } + if (object.clientState !== undefined && object.clientState !== null) { + message.clientState = Any.fromJSON(object.clientState); + } else { + message.clientState = undefined; + } + if (object.counterparty !== undefined && object.counterparty !== null) { + message.counterparty = Counterparty.fromJSON(object.counterparty); + } else { + message.counterparty = undefined; + } + if (object.delayPeriod !== undefined && object.delayPeriod !== null) { + message.delayPeriod = Number(object.delayPeriod); + } else { + message.delayPeriod = 0; + } + if ( + object.counterpartyVersions !== undefined && + object.counterpartyVersions !== null + ) { + for (const e of object.counterpartyVersions) { + message.counterpartyVersions.push(Version.fromJSON(e)); + } + } + if (object.proofHeight !== undefined && object.proofHeight !== null) { + message.proofHeight = Height.fromJSON(object.proofHeight); + } else { + message.proofHeight = undefined; + } + if (object.proofInit !== undefined && object.proofInit !== null) { + message.proofInit = bytesFromBase64(object.proofInit); + } + if (object.proofClient !== undefined && object.proofClient !== null) { + message.proofClient = bytesFromBase64(object.proofClient); + } + if (object.proofConsensus !== undefined && object.proofConsensus !== null) { + message.proofConsensus = bytesFromBase64(object.proofConsensus); + } + if ( + object.consensusHeight !== undefined && + object.consensusHeight !== null + ) { + message.consensusHeight = Height.fromJSON(object.consensusHeight); + } else { + message.consensusHeight = undefined; + } + if (object.signer !== undefined && object.signer !== null) { + message.signer = String(object.signer); + } else { + message.signer = ""; + } + return message; + }, + + toJSON(message: MsgConnectionOpenTry): unknown { + const obj: any = {}; + message.clientId !== undefined && (obj.clientId = message.clientId); + message.previousConnectionId !== undefined && + (obj.previousConnectionId = message.previousConnectionId); + message.clientState !== undefined && + (obj.clientState = message.clientState + ? Any.toJSON(message.clientState) + : undefined); + message.counterparty !== undefined && + (obj.counterparty = message.counterparty + ? Counterparty.toJSON(message.counterparty) + : undefined); + message.delayPeriod !== undefined && + (obj.delayPeriod = message.delayPeriod); + if (message.counterpartyVersions) { + obj.counterpartyVersions = message.counterpartyVersions.map((e) => + e ? Version.toJSON(e) : undefined + ); + } else { + obj.counterpartyVersions = []; + } + message.proofHeight !== undefined && + (obj.proofHeight = message.proofHeight + ? Height.toJSON(message.proofHeight) + : undefined); + message.proofInit !== undefined && + (obj.proofInit = base64FromBytes( + message.proofInit !== undefined ? message.proofInit : new Uint8Array() + )); + message.proofClient !== undefined && + (obj.proofClient = base64FromBytes( + message.proofClient !== undefined + ? message.proofClient + : new Uint8Array() + )); + message.proofConsensus !== undefined && + (obj.proofConsensus = base64FromBytes( + message.proofConsensus !== undefined + ? message.proofConsensus + : new Uint8Array() + )); + message.consensusHeight !== undefined && + (obj.consensusHeight = message.consensusHeight + ? Height.toJSON(message.consensusHeight) + : undefined); + message.signer !== undefined && (obj.signer = message.signer); + return obj; + }, + + fromPartial(object: DeepPartial): MsgConnectionOpenTry { + const message = { ...baseMsgConnectionOpenTry } as MsgConnectionOpenTry; + message.counterpartyVersions = []; + if (object.clientId !== undefined && object.clientId !== null) { + message.clientId = object.clientId; + } else { + message.clientId = ""; + } + if ( + object.previousConnectionId !== undefined && + object.previousConnectionId !== null + ) { + message.previousConnectionId = object.previousConnectionId; + } else { + message.previousConnectionId = ""; + } + if (object.clientState !== undefined && object.clientState !== null) { + message.clientState = Any.fromPartial(object.clientState); + } else { + message.clientState = undefined; + } + if (object.counterparty !== undefined && object.counterparty !== null) { + message.counterparty = Counterparty.fromPartial(object.counterparty); + } else { + message.counterparty = undefined; + } + if (object.delayPeriod !== undefined && object.delayPeriod !== null) { + message.delayPeriod = object.delayPeriod; + } else { + message.delayPeriod = 0; + } + if ( + object.counterpartyVersions !== undefined && + object.counterpartyVersions !== null + ) { + for (const e of object.counterpartyVersions) { + message.counterpartyVersions.push(Version.fromPartial(e)); + } + } + if (object.proofHeight !== undefined && object.proofHeight !== null) { + message.proofHeight = Height.fromPartial(object.proofHeight); + } else { + message.proofHeight = undefined; + } + if (object.proofInit !== undefined && object.proofInit !== null) { + message.proofInit = object.proofInit; + } else { + message.proofInit = new Uint8Array(); + } + if (object.proofClient !== undefined && object.proofClient !== null) { + message.proofClient = object.proofClient; + } else { + message.proofClient = new Uint8Array(); + } + if (object.proofConsensus !== undefined && object.proofConsensus !== null) { + message.proofConsensus = object.proofConsensus; + } else { + message.proofConsensus = new Uint8Array(); + } + if ( + object.consensusHeight !== undefined && + object.consensusHeight !== null + ) { + message.consensusHeight = Height.fromPartial(object.consensusHeight); + } else { + message.consensusHeight = undefined; + } + if (object.signer !== undefined && object.signer !== null) { + message.signer = object.signer; + } else { + message.signer = ""; + } + return message; + }, +}; + +const baseMsgConnectionOpenTryResponse: object = {}; + +export const MsgConnectionOpenTryResponse = { + encode( + _: MsgConnectionOpenTryResponse, + writer: Writer = Writer.create() + ): Writer { + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): MsgConnectionOpenTryResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseMsgConnectionOpenTryResponse, + } as MsgConnectionOpenTryResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): MsgConnectionOpenTryResponse { + const message = { + ...baseMsgConnectionOpenTryResponse, + } as MsgConnectionOpenTryResponse; + return message; + }, + + toJSON(_: MsgConnectionOpenTryResponse): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial( + _: DeepPartial + ): MsgConnectionOpenTryResponse { + const message = { + ...baseMsgConnectionOpenTryResponse, + } as MsgConnectionOpenTryResponse; + return message; + }, +}; + +const baseMsgConnectionOpenAck: object = { + connectionId: "", + counterpartyConnectionId: "", + signer: "", +}; + +export const MsgConnectionOpenAck = { + encode( + message: MsgConnectionOpenAck, + writer: Writer = Writer.create() + ): Writer { + if (message.connectionId !== "") { + writer.uint32(10).string(message.connectionId); + } + if (message.counterpartyConnectionId !== "") { + writer.uint32(18).string(message.counterpartyConnectionId); + } + if (message.version !== undefined) { + Version.encode(message.version, writer.uint32(26).fork()).ldelim(); + } + if (message.clientState !== undefined) { + Any.encode(message.clientState, writer.uint32(34).fork()).ldelim(); + } + if (message.proofHeight !== undefined) { + Height.encode(message.proofHeight, writer.uint32(42).fork()).ldelim(); + } + if (message.proofTry.length !== 0) { + writer.uint32(50).bytes(message.proofTry); + } + if (message.proofClient.length !== 0) { + writer.uint32(58).bytes(message.proofClient); + } + if (message.proofConsensus.length !== 0) { + writer.uint32(66).bytes(message.proofConsensus); + } + if (message.consensusHeight !== undefined) { + Height.encode(message.consensusHeight, writer.uint32(74).fork()).ldelim(); + } + if (message.signer !== "") { + writer.uint32(82).string(message.signer); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MsgConnectionOpenAck { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseMsgConnectionOpenAck } as MsgConnectionOpenAck; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.connectionId = reader.string(); + break; + case 2: + message.counterpartyConnectionId = reader.string(); + break; + case 3: + message.version = Version.decode(reader, reader.uint32()); + break; + case 4: + message.clientState = Any.decode(reader, reader.uint32()); + break; + case 5: + message.proofHeight = Height.decode(reader, reader.uint32()); + break; + case 6: + message.proofTry = reader.bytes(); + break; + case 7: + message.proofClient = reader.bytes(); + break; + case 8: + message.proofConsensus = reader.bytes(); + break; + case 9: + message.consensusHeight = Height.decode(reader, reader.uint32()); + break; + case 10: + message.signer = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgConnectionOpenAck { + const message = { ...baseMsgConnectionOpenAck } as MsgConnectionOpenAck; + if (object.connectionId !== undefined && object.connectionId !== null) { + message.connectionId = String(object.connectionId); + } else { + message.connectionId = ""; + } + if ( + object.counterpartyConnectionId !== undefined && + object.counterpartyConnectionId !== null + ) { + message.counterpartyConnectionId = String( + object.counterpartyConnectionId + ); + } else { + message.counterpartyConnectionId = ""; + } + if (object.version !== undefined && object.version !== null) { + message.version = Version.fromJSON(object.version); + } else { + message.version = undefined; + } + if (object.clientState !== undefined && object.clientState !== null) { + message.clientState = Any.fromJSON(object.clientState); + } else { + message.clientState = undefined; + } + if (object.proofHeight !== undefined && object.proofHeight !== null) { + message.proofHeight = Height.fromJSON(object.proofHeight); + } else { + message.proofHeight = undefined; + } + if (object.proofTry !== undefined && object.proofTry !== null) { + message.proofTry = bytesFromBase64(object.proofTry); + } + if (object.proofClient !== undefined && object.proofClient !== null) { + message.proofClient = bytesFromBase64(object.proofClient); + } + if (object.proofConsensus !== undefined && object.proofConsensus !== null) { + message.proofConsensus = bytesFromBase64(object.proofConsensus); + } + if ( + object.consensusHeight !== undefined && + object.consensusHeight !== null + ) { + message.consensusHeight = Height.fromJSON(object.consensusHeight); + } else { + message.consensusHeight = undefined; + } + if (object.signer !== undefined && object.signer !== null) { + message.signer = String(object.signer); + } else { + message.signer = ""; + } + return message; + }, + + toJSON(message: MsgConnectionOpenAck): unknown { + const obj: any = {}; + message.connectionId !== undefined && + (obj.connectionId = message.connectionId); + message.counterpartyConnectionId !== undefined && + (obj.counterpartyConnectionId = message.counterpartyConnectionId); + message.version !== undefined && + (obj.version = message.version + ? Version.toJSON(message.version) + : undefined); + message.clientState !== undefined && + (obj.clientState = message.clientState + ? Any.toJSON(message.clientState) + : undefined); + message.proofHeight !== undefined && + (obj.proofHeight = message.proofHeight + ? Height.toJSON(message.proofHeight) + : undefined); + message.proofTry !== undefined && + (obj.proofTry = base64FromBytes( + message.proofTry !== undefined ? message.proofTry : new Uint8Array() + )); + message.proofClient !== undefined && + (obj.proofClient = base64FromBytes( + message.proofClient !== undefined + ? message.proofClient + : new Uint8Array() + )); + message.proofConsensus !== undefined && + (obj.proofConsensus = base64FromBytes( + message.proofConsensus !== undefined + ? message.proofConsensus + : new Uint8Array() + )); + message.consensusHeight !== undefined && + (obj.consensusHeight = message.consensusHeight + ? Height.toJSON(message.consensusHeight) + : undefined); + message.signer !== undefined && (obj.signer = message.signer); + return obj; + }, + + fromPartial(object: DeepPartial): MsgConnectionOpenAck { + const message = { ...baseMsgConnectionOpenAck } as MsgConnectionOpenAck; + if (object.connectionId !== undefined && object.connectionId !== null) { + message.connectionId = object.connectionId; + } else { + message.connectionId = ""; + } + if ( + object.counterpartyConnectionId !== undefined && + object.counterpartyConnectionId !== null + ) { + message.counterpartyConnectionId = object.counterpartyConnectionId; + } else { + message.counterpartyConnectionId = ""; + } + if (object.version !== undefined && object.version !== null) { + message.version = Version.fromPartial(object.version); + } else { + message.version = undefined; + } + if (object.clientState !== undefined && object.clientState !== null) { + message.clientState = Any.fromPartial(object.clientState); + } else { + message.clientState = undefined; + } + if (object.proofHeight !== undefined && object.proofHeight !== null) { + message.proofHeight = Height.fromPartial(object.proofHeight); + } else { + message.proofHeight = undefined; + } + if (object.proofTry !== undefined && object.proofTry !== null) { + message.proofTry = object.proofTry; + } else { + message.proofTry = new Uint8Array(); + } + if (object.proofClient !== undefined && object.proofClient !== null) { + message.proofClient = object.proofClient; + } else { + message.proofClient = new Uint8Array(); + } + if (object.proofConsensus !== undefined && object.proofConsensus !== null) { + message.proofConsensus = object.proofConsensus; + } else { + message.proofConsensus = new Uint8Array(); + } + if ( + object.consensusHeight !== undefined && + object.consensusHeight !== null + ) { + message.consensusHeight = Height.fromPartial(object.consensusHeight); + } else { + message.consensusHeight = undefined; + } + if (object.signer !== undefined && object.signer !== null) { + message.signer = object.signer; + } else { + message.signer = ""; + } + return message; + }, +}; + +const baseMsgConnectionOpenAckResponse: object = {}; + +export const MsgConnectionOpenAckResponse = { + encode( + _: MsgConnectionOpenAckResponse, + writer: Writer = Writer.create() + ): Writer { + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): MsgConnectionOpenAckResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseMsgConnectionOpenAckResponse, + } as MsgConnectionOpenAckResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): MsgConnectionOpenAckResponse { + const message = { + ...baseMsgConnectionOpenAckResponse, + } as MsgConnectionOpenAckResponse; + return message; + }, + + toJSON(_: MsgConnectionOpenAckResponse): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial( + _: DeepPartial + ): MsgConnectionOpenAckResponse { + const message = { + ...baseMsgConnectionOpenAckResponse, + } as MsgConnectionOpenAckResponse; + return message; + }, +}; + +const baseMsgConnectionOpenConfirm: object = { connectionId: "", signer: "" }; + +export const MsgConnectionOpenConfirm = { + encode( + message: MsgConnectionOpenConfirm, + writer: Writer = Writer.create() + ): Writer { + if (message.connectionId !== "") { + writer.uint32(10).string(message.connectionId); + } + if (message.proofAck.length !== 0) { + writer.uint32(18).bytes(message.proofAck); + } + if (message.proofHeight !== undefined) { + Height.encode(message.proofHeight, writer.uint32(26).fork()).ldelim(); + } + if (message.signer !== "") { + writer.uint32(34).string(message.signer); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): MsgConnectionOpenConfirm { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseMsgConnectionOpenConfirm, + } as MsgConnectionOpenConfirm; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.connectionId = reader.string(); + break; + case 2: + message.proofAck = reader.bytes(); + break; + case 3: + message.proofHeight = Height.decode(reader, reader.uint32()); + break; + case 4: + message.signer = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgConnectionOpenConfirm { + const message = { + ...baseMsgConnectionOpenConfirm, + } as MsgConnectionOpenConfirm; + if (object.connectionId !== undefined && object.connectionId !== null) { + message.connectionId = String(object.connectionId); + } else { + message.connectionId = ""; + } + if (object.proofAck !== undefined && object.proofAck !== null) { + message.proofAck = bytesFromBase64(object.proofAck); + } + if (object.proofHeight !== undefined && object.proofHeight !== null) { + message.proofHeight = Height.fromJSON(object.proofHeight); + } else { + message.proofHeight = undefined; + } + if (object.signer !== undefined && object.signer !== null) { + message.signer = String(object.signer); + } else { + message.signer = ""; + } + return message; + }, + + toJSON(message: MsgConnectionOpenConfirm): unknown { + const obj: any = {}; + message.connectionId !== undefined && + (obj.connectionId = message.connectionId); + message.proofAck !== undefined && + (obj.proofAck = base64FromBytes( + message.proofAck !== undefined ? message.proofAck : new Uint8Array() + )); + message.proofHeight !== undefined && + (obj.proofHeight = message.proofHeight + ? Height.toJSON(message.proofHeight) + : undefined); + message.signer !== undefined && (obj.signer = message.signer); + return obj; + }, + + fromPartial( + object: DeepPartial + ): MsgConnectionOpenConfirm { + const message = { + ...baseMsgConnectionOpenConfirm, + } as MsgConnectionOpenConfirm; + if (object.connectionId !== undefined && object.connectionId !== null) { + message.connectionId = object.connectionId; + } else { + message.connectionId = ""; + } + if (object.proofAck !== undefined && object.proofAck !== null) { + message.proofAck = object.proofAck; + } else { + message.proofAck = new Uint8Array(); + } + if (object.proofHeight !== undefined && object.proofHeight !== null) { + message.proofHeight = Height.fromPartial(object.proofHeight); + } else { + message.proofHeight = undefined; + } + if (object.signer !== undefined && object.signer !== null) { + message.signer = object.signer; + } else { + message.signer = ""; + } + return message; + }, +}; + +const baseMsgConnectionOpenConfirmResponse: object = {}; + +export const MsgConnectionOpenConfirmResponse = { + encode( + _: MsgConnectionOpenConfirmResponse, + writer: Writer = Writer.create() + ): Writer { + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): MsgConnectionOpenConfirmResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseMsgConnectionOpenConfirmResponse, + } as MsgConnectionOpenConfirmResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): MsgConnectionOpenConfirmResponse { + const message = { + ...baseMsgConnectionOpenConfirmResponse, + } as MsgConnectionOpenConfirmResponse; + return message; + }, + + toJSON(_: MsgConnectionOpenConfirmResponse): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial( + _: DeepPartial + ): MsgConnectionOpenConfirmResponse { + const message = { + ...baseMsgConnectionOpenConfirmResponse, + } as MsgConnectionOpenConfirmResponse; + return message; + }, +}; + +/** Msg defines the ibc/connection Msg service. */ +export interface Msg { + /** ConnectionOpenInit defines a rpc handler method for MsgConnectionOpenInit. */ + ConnectionOpenInit( + request: MsgConnectionOpenInit + ): Promise; + /** ConnectionOpenTry defines a rpc handler method for MsgConnectionOpenTry. */ + ConnectionOpenTry( + request: MsgConnectionOpenTry + ): Promise; + /** ConnectionOpenAck defines a rpc handler method for MsgConnectionOpenAck. */ + ConnectionOpenAck( + request: MsgConnectionOpenAck + ): Promise; + /** + * ConnectionOpenConfirm defines a rpc handler method for + * MsgConnectionOpenConfirm. + */ + ConnectionOpenConfirm( + request: MsgConnectionOpenConfirm + ): Promise; +} + +export class MsgClientImpl implements Msg { + private readonly rpc: Rpc; + constructor(rpc: Rpc) { + this.rpc = rpc; + } + ConnectionOpenInit( + request: MsgConnectionOpenInit + ): Promise { + const data = MsgConnectionOpenInit.encode(request).finish(); + const promise = this.rpc.request( + "ibc.core.connection.v1.Msg", + "ConnectionOpenInit", + data + ); + return promise.then((data) => + MsgConnectionOpenInitResponse.decode(new Reader(data)) + ); + } + + ConnectionOpenTry( + request: MsgConnectionOpenTry + ): Promise { + const data = MsgConnectionOpenTry.encode(request).finish(); + const promise = this.rpc.request( + "ibc.core.connection.v1.Msg", + "ConnectionOpenTry", + data + ); + return promise.then((data) => + MsgConnectionOpenTryResponse.decode(new Reader(data)) + ); + } + + ConnectionOpenAck( + request: MsgConnectionOpenAck + ): Promise { + const data = MsgConnectionOpenAck.encode(request).finish(); + const promise = this.rpc.request( + "ibc.core.connection.v1.Msg", + "ConnectionOpenAck", + data + ); + return promise.then((data) => + MsgConnectionOpenAckResponse.decode(new Reader(data)) + ); + } + + ConnectionOpenConfirm( + request: MsgConnectionOpenConfirm + ): Promise { + const data = MsgConnectionOpenConfirm.encode(request).finish(); + const promise = this.rpc.request( + "ibc.core.connection.v1.Msg", + "ConnectionOpenConfirm", + data + ); + return promise.then((data) => + MsgConnectionOpenConfirmResponse.decode(new Reader(data)) + ); + } +} + +interface Rpc { + request( + service: string, + method: string, + data: Uint8Array + ): Promise; +} + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/ts-client/ibc.core.connection.v1/types/proofs.ts b/ts-client/ibc.core.connection.v1/types/proofs.ts new file mode 100644 index 00000000..524d3886 --- /dev/null +++ b/ts-client/ibc.core.connection.v1/types/proofs.ts @@ -0,0 +1,1871 @@ +/* eslint-disable */ +import { Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "ics23"; + +export enum HashOp { + /** NO_HASH - NO_HASH is the default if no data passed. Note this is an illegal argument some places. */ + NO_HASH = 0, + SHA256 = 1, + SHA512 = 2, + KECCAK = 3, + RIPEMD160 = 4, + /** BITCOIN - ripemd160(sha256(x)) */ + BITCOIN = 5, + SHA512_256 = 6, + UNRECOGNIZED = -1, +} + +export function hashOpFromJSON(object: any): HashOp { + switch (object) { + case 0: + case "NO_HASH": + return HashOp.NO_HASH; + case 1: + case "SHA256": + return HashOp.SHA256; + case 2: + case "SHA512": + return HashOp.SHA512; + case 3: + case "KECCAK": + return HashOp.KECCAK; + case 4: + case "RIPEMD160": + return HashOp.RIPEMD160; + case 5: + case "BITCOIN": + return HashOp.BITCOIN; + case 6: + case "SHA512_256": + return HashOp.SHA512_256; + case -1: + case "UNRECOGNIZED": + default: + return HashOp.UNRECOGNIZED; + } +} + +export function hashOpToJSON(object: HashOp): string { + switch (object) { + case HashOp.NO_HASH: + return "NO_HASH"; + case HashOp.SHA256: + return "SHA256"; + case HashOp.SHA512: + return "SHA512"; + case HashOp.KECCAK: + return "KECCAK"; + case HashOp.RIPEMD160: + return "RIPEMD160"; + case HashOp.BITCOIN: + return "BITCOIN"; + case HashOp.SHA512_256: + return "SHA512_256"; + default: + return "UNKNOWN"; + } +} + +/** + * LengthOp defines how to process the key and value of the LeafOp + * to include length information. After encoding the length with the given + * algorithm, the length will be prepended to the key and value bytes. + * (Each one with it's own encoded length) + */ +export enum LengthOp { + /** NO_PREFIX - NO_PREFIX don't include any length info */ + NO_PREFIX = 0, + /** VAR_PROTO - VAR_PROTO uses protobuf (and go-amino) varint encoding of the length */ + VAR_PROTO = 1, + /** VAR_RLP - VAR_RLP uses rlp int encoding of the length */ + VAR_RLP = 2, + /** FIXED32_BIG - FIXED32_BIG uses big-endian encoding of the length as a 32 bit integer */ + FIXED32_BIG = 3, + /** FIXED32_LITTLE - FIXED32_LITTLE uses little-endian encoding of the length as a 32 bit integer */ + FIXED32_LITTLE = 4, + /** FIXED64_BIG - FIXED64_BIG uses big-endian encoding of the length as a 64 bit integer */ + FIXED64_BIG = 5, + /** FIXED64_LITTLE - FIXED64_LITTLE uses little-endian encoding of the length as a 64 bit integer */ + FIXED64_LITTLE = 6, + /** REQUIRE_32_BYTES - REQUIRE_32_BYTES is like NONE, but will fail if the input is not exactly 32 bytes (sha256 output) */ + REQUIRE_32_BYTES = 7, + /** REQUIRE_64_BYTES - REQUIRE_64_BYTES is like NONE, but will fail if the input is not exactly 64 bytes (sha512 output) */ + REQUIRE_64_BYTES = 8, + UNRECOGNIZED = -1, +} + +export function lengthOpFromJSON(object: any): LengthOp { + switch (object) { + case 0: + case "NO_PREFIX": + return LengthOp.NO_PREFIX; + case 1: + case "VAR_PROTO": + return LengthOp.VAR_PROTO; + case 2: + case "VAR_RLP": + return LengthOp.VAR_RLP; + case 3: + case "FIXED32_BIG": + return LengthOp.FIXED32_BIG; + case 4: + case "FIXED32_LITTLE": + return LengthOp.FIXED32_LITTLE; + case 5: + case "FIXED64_BIG": + return LengthOp.FIXED64_BIG; + case 6: + case "FIXED64_LITTLE": + return LengthOp.FIXED64_LITTLE; + case 7: + case "REQUIRE_32_BYTES": + return LengthOp.REQUIRE_32_BYTES; + case 8: + case "REQUIRE_64_BYTES": + return LengthOp.REQUIRE_64_BYTES; + case -1: + case "UNRECOGNIZED": + default: + return LengthOp.UNRECOGNIZED; + } +} + +export function lengthOpToJSON(object: LengthOp): string { + switch (object) { + case LengthOp.NO_PREFIX: + return "NO_PREFIX"; + case LengthOp.VAR_PROTO: + return "VAR_PROTO"; + case LengthOp.VAR_RLP: + return "VAR_RLP"; + case LengthOp.FIXED32_BIG: + return "FIXED32_BIG"; + case LengthOp.FIXED32_LITTLE: + return "FIXED32_LITTLE"; + case LengthOp.FIXED64_BIG: + return "FIXED64_BIG"; + case LengthOp.FIXED64_LITTLE: + return "FIXED64_LITTLE"; + case LengthOp.REQUIRE_32_BYTES: + return "REQUIRE_32_BYTES"; + case LengthOp.REQUIRE_64_BYTES: + return "REQUIRE_64_BYTES"; + default: + return "UNKNOWN"; + } +} + +/** + * ExistenceProof takes a key and a value and a set of steps to perform on it. + * The result of peforming all these steps will provide a "root hash", which can + * be compared to the value in a header. + * + * Since it is computationally infeasible to produce a hash collission for any of the used + * cryptographic hash functions, if someone can provide a series of operations to transform + * a given key and value into a root hash that matches some trusted root, these key and values + * must be in the referenced merkle tree. + * + * The only possible issue is maliablity in LeafOp, such as providing extra prefix data, + * which should be controlled by a spec. Eg. with lengthOp as NONE, + * prefix = FOO, key = BAR, value = CHOICE + * and + * prefix = F, key = OOBAR, value = CHOICE + * would produce the same value. + * + * With LengthOp this is tricker but not impossible. Which is why the "leafPrefixEqual" field + * in the ProofSpec is valuable to prevent this mutability. And why all trees should + * length-prefix the data before hashing it. + */ +export interface ExistenceProof { + key: Uint8Array; + value: Uint8Array; + leaf: LeafOp | undefined; + path: InnerOp[]; +} + +/** + * NonExistenceProof takes a proof of two neighbors, one left of the desired key, + * one right of the desired key. If both proofs are valid AND they are neighbors, + * then there is no valid proof for the given key. + */ +export interface NonExistenceProof { + /** TODO: remove this as unnecessary??? we prove a range */ + key: Uint8Array; + left: ExistenceProof | undefined; + right: ExistenceProof | undefined; +} + +/** CommitmentProof is either an ExistenceProof or a NonExistenceProof, or a Batch of such messages */ +export interface CommitmentProof { + exist: ExistenceProof | undefined; + nonexist: NonExistenceProof | undefined; + batch: BatchProof | undefined; + compressed: CompressedBatchProof | undefined; +} + +/** + * LeafOp represents the raw key-value data we wish to prove, and + * must be flexible to represent the internal transformation from + * the original key-value pairs into the basis hash, for many existing + * merkle trees. + * + * key and value are passed in. So that the signature of this operation is: + * leafOp(key, value) -> output + * + * To process this, first prehash the keys and values if needed (ANY means no hash in this case): + * hkey = prehashKey(key) + * hvalue = prehashValue(value) + * + * Then combine the bytes, and hash it + * output = hash(prefix || length(hkey) || hkey || length(hvalue) || hvalue) + */ +export interface LeafOp { + hash: HashOp; + prehashKey: HashOp; + prehashValue: HashOp; + length: LengthOp; + /** + * prefix is a fixed bytes that may optionally be included at the beginning to differentiate + * a leaf node from an inner node. + */ + prefix: Uint8Array; +} + +/** + * InnerOp represents a merkle-proof step that is not a leaf. + * It represents concatenating two children and hashing them to provide the next result. + * + * The result of the previous step is passed in, so the signature of this op is: + * innerOp(child) -> output + * + * The result of applying InnerOp should be: + * output = op.hash(op.prefix || child || op.suffix) + * + * where the || operator is concatenation of binary data, + * and child is the result of hashing all the tree below this step. + * + * Any special data, like prepending child with the length, or prepending the entire operation with + * some value to differentiate from leaf nodes, should be included in prefix and suffix. + * If either of prefix or suffix is empty, we just treat it as an empty string + */ +export interface InnerOp { + hash: HashOp; + prefix: Uint8Array; + suffix: Uint8Array; +} + +/** + * ProofSpec defines what the expected parameters are for a given proof type. + * This can be stored in the client and used to validate any incoming proofs. + * + * verify(ProofSpec, Proof) -> Proof | Error + * + * As demonstrated in tests, if we don't fix the algorithm used to calculate the + * LeafHash for a given tree, there are many possible key-value pairs that can + * generate a given hash (by interpretting the preimage differently). + * We need this for proper security, requires client knows a priori what + * tree format server uses. But not in code, rather a configuration object. + */ +export interface ProofSpec { + /** + * any field in the ExistenceProof must be the same as in this spec. + * except Prefix, which is just the first bytes of prefix (spec can be longer) + */ + leafSpec: LeafOp | undefined; + innerSpec: InnerSpec | undefined; + /** max_depth (if > 0) is the maximum number of InnerOps allowed (mainly for fixed-depth tries) */ + maxDepth: number; + /** min_depth (if > 0) is the minimum number of InnerOps allowed (mainly for fixed-depth tries) */ + minDepth: number; + /** + * prehash_key_before_comparison is a flag that indicates whether to use the + * prehash_key specified by LeafOp to compare lexical ordering of keys for + * non-existence proofs. + */ + prehashKeyBeforeComparison: boolean; +} + +/** + * InnerSpec contains all store-specific structure info to determine if two proofs from a + * given store are neighbors. + * + * This enables: + * + * isLeftMost(spec: InnerSpec, op: InnerOp) + * isRightMost(spec: InnerSpec, op: InnerOp) + * isLeftNeighbor(spec: InnerSpec, left: InnerOp, right: InnerOp) + */ +export interface InnerSpec { + /** + * Child order is the ordering of the children node, must count from 0 + * iavl tree is [0, 1] (left then right) + * merk is [0, 2, 1] (left, right, here) + */ + childOrder: number[]; + childSize: number; + minPrefixLength: number; + maxPrefixLength: number; + /** empty child is the prehash image that is used when one child is nil (eg. 20 bytes of 0) */ + emptyChild: Uint8Array; + /** hash is the algorithm that must be used for each InnerOp */ + hash: HashOp; +} + +/** BatchProof is a group of multiple proof types than can be compressed */ +export interface BatchProof { + entries: BatchEntry[]; +} + +/** Use BatchEntry not CommitmentProof, to avoid recursion */ +export interface BatchEntry { + exist: ExistenceProof | undefined; + nonexist: NonExistenceProof | undefined; +} + +export interface CompressedBatchProof { + entries: CompressedBatchEntry[]; + lookupInners: InnerOp[]; +} + +/** Use BatchEntry not CommitmentProof, to avoid recursion */ +export interface CompressedBatchEntry { + exist: CompressedExistenceProof | undefined; + nonexist: CompressedNonExistenceProof | undefined; +} + +export interface CompressedExistenceProof { + key: Uint8Array; + value: Uint8Array; + leaf: LeafOp | undefined; + /** these are indexes into the lookup_inners table in CompressedBatchProof */ + path: number[]; +} + +export interface CompressedNonExistenceProof { + /** TODO: remove this as unnecessary??? we prove a range */ + key: Uint8Array; + left: CompressedExistenceProof | undefined; + right: CompressedExistenceProof | undefined; +} + +const baseExistenceProof: object = {}; + +export const ExistenceProof = { + encode(message: ExistenceProof, writer: Writer = Writer.create()): Writer { + if (message.key.length !== 0) { + writer.uint32(10).bytes(message.key); + } + if (message.value.length !== 0) { + writer.uint32(18).bytes(message.value); + } + if (message.leaf !== undefined) { + LeafOp.encode(message.leaf, writer.uint32(26).fork()).ldelim(); + } + for (const v of message.path) { + InnerOp.encode(v!, writer.uint32(34).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ExistenceProof { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseExistenceProof } as ExistenceProof; + message.path = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.key = reader.bytes(); + break; + case 2: + message.value = reader.bytes(); + break; + case 3: + message.leaf = LeafOp.decode(reader, reader.uint32()); + break; + case 4: + message.path.push(InnerOp.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ExistenceProof { + const message = { ...baseExistenceProof } as ExistenceProof; + message.path = []; + if (object.key !== undefined && object.key !== null) { + message.key = bytesFromBase64(object.key); + } + if (object.value !== undefined && object.value !== null) { + message.value = bytesFromBase64(object.value); + } + if (object.leaf !== undefined && object.leaf !== null) { + message.leaf = LeafOp.fromJSON(object.leaf); + } else { + message.leaf = undefined; + } + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(InnerOp.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: ExistenceProof): unknown { + const obj: any = {}; + message.key !== undefined && + (obj.key = base64FromBytes( + message.key !== undefined ? message.key : new Uint8Array() + )); + message.value !== undefined && + (obj.value = base64FromBytes( + message.value !== undefined ? message.value : new Uint8Array() + )); + message.leaf !== undefined && + (obj.leaf = message.leaf ? LeafOp.toJSON(message.leaf) : undefined); + if (message.path) { + obj.path = message.path.map((e) => (e ? InnerOp.toJSON(e) : undefined)); + } else { + obj.path = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): ExistenceProof { + const message = { ...baseExistenceProof } as ExistenceProof; + message.path = []; + if (object.key !== undefined && object.key !== null) { + message.key = object.key; + } else { + message.key = new Uint8Array(); + } + if (object.value !== undefined && object.value !== null) { + message.value = object.value; + } else { + message.value = new Uint8Array(); + } + if (object.leaf !== undefined && object.leaf !== null) { + message.leaf = LeafOp.fromPartial(object.leaf); + } else { + message.leaf = undefined; + } + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(InnerOp.fromPartial(e)); + } + } + return message; + }, +}; + +const baseNonExistenceProof: object = {}; + +export const NonExistenceProof = { + encode(message: NonExistenceProof, writer: Writer = Writer.create()): Writer { + if (message.key.length !== 0) { + writer.uint32(10).bytes(message.key); + } + if (message.left !== undefined) { + ExistenceProof.encode(message.left, writer.uint32(18).fork()).ldelim(); + } + if (message.right !== undefined) { + ExistenceProof.encode(message.right, writer.uint32(26).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): NonExistenceProof { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseNonExistenceProof } as NonExistenceProof; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.key = reader.bytes(); + break; + case 2: + message.left = ExistenceProof.decode(reader, reader.uint32()); + break; + case 3: + message.right = ExistenceProof.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): NonExistenceProof { + const message = { ...baseNonExistenceProof } as NonExistenceProof; + if (object.key !== undefined && object.key !== null) { + message.key = bytesFromBase64(object.key); + } + if (object.left !== undefined && object.left !== null) { + message.left = ExistenceProof.fromJSON(object.left); + } else { + message.left = undefined; + } + if (object.right !== undefined && object.right !== null) { + message.right = ExistenceProof.fromJSON(object.right); + } else { + message.right = undefined; + } + return message; + }, + + toJSON(message: NonExistenceProof): unknown { + const obj: any = {}; + message.key !== undefined && + (obj.key = base64FromBytes( + message.key !== undefined ? message.key : new Uint8Array() + )); + message.left !== undefined && + (obj.left = message.left + ? ExistenceProof.toJSON(message.left) + : undefined); + message.right !== undefined && + (obj.right = message.right + ? ExistenceProof.toJSON(message.right) + : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): NonExistenceProof { + const message = { ...baseNonExistenceProof } as NonExistenceProof; + if (object.key !== undefined && object.key !== null) { + message.key = object.key; + } else { + message.key = new Uint8Array(); + } + if (object.left !== undefined && object.left !== null) { + message.left = ExistenceProof.fromPartial(object.left); + } else { + message.left = undefined; + } + if (object.right !== undefined && object.right !== null) { + message.right = ExistenceProof.fromPartial(object.right); + } else { + message.right = undefined; + } + return message; + }, +}; + +const baseCommitmentProof: object = {}; + +export const CommitmentProof = { + encode(message: CommitmentProof, writer: Writer = Writer.create()): Writer { + if (message.exist !== undefined) { + ExistenceProof.encode(message.exist, writer.uint32(10).fork()).ldelim(); + } + if (message.nonexist !== undefined) { + NonExistenceProof.encode( + message.nonexist, + writer.uint32(18).fork() + ).ldelim(); + } + if (message.batch !== undefined) { + BatchProof.encode(message.batch, writer.uint32(26).fork()).ldelim(); + } + if (message.compressed !== undefined) { + CompressedBatchProof.encode( + message.compressed, + writer.uint32(34).fork() + ).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): CommitmentProof { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseCommitmentProof } as CommitmentProof; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.exist = ExistenceProof.decode(reader, reader.uint32()); + break; + case 2: + message.nonexist = NonExistenceProof.decode(reader, reader.uint32()); + break; + case 3: + message.batch = BatchProof.decode(reader, reader.uint32()); + break; + case 4: + message.compressed = CompressedBatchProof.decode( + reader, + reader.uint32() + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): CommitmentProof { + const message = { ...baseCommitmentProof } as CommitmentProof; + if (object.exist !== undefined && object.exist !== null) { + message.exist = ExistenceProof.fromJSON(object.exist); + } else { + message.exist = undefined; + } + if (object.nonexist !== undefined && object.nonexist !== null) { + message.nonexist = NonExistenceProof.fromJSON(object.nonexist); + } else { + message.nonexist = undefined; + } + if (object.batch !== undefined && object.batch !== null) { + message.batch = BatchProof.fromJSON(object.batch); + } else { + message.batch = undefined; + } + if (object.compressed !== undefined && object.compressed !== null) { + message.compressed = CompressedBatchProof.fromJSON(object.compressed); + } else { + message.compressed = undefined; + } + return message; + }, + + toJSON(message: CommitmentProof): unknown { + const obj: any = {}; + message.exist !== undefined && + (obj.exist = message.exist + ? ExistenceProof.toJSON(message.exist) + : undefined); + message.nonexist !== undefined && + (obj.nonexist = message.nonexist + ? NonExistenceProof.toJSON(message.nonexist) + : undefined); + message.batch !== undefined && + (obj.batch = message.batch + ? BatchProof.toJSON(message.batch) + : undefined); + message.compressed !== undefined && + (obj.compressed = message.compressed + ? CompressedBatchProof.toJSON(message.compressed) + : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): CommitmentProof { + const message = { ...baseCommitmentProof } as CommitmentProof; + if (object.exist !== undefined && object.exist !== null) { + message.exist = ExistenceProof.fromPartial(object.exist); + } else { + message.exist = undefined; + } + if (object.nonexist !== undefined && object.nonexist !== null) { + message.nonexist = NonExistenceProof.fromPartial(object.nonexist); + } else { + message.nonexist = undefined; + } + if (object.batch !== undefined && object.batch !== null) { + message.batch = BatchProof.fromPartial(object.batch); + } else { + message.batch = undefined; + } + if (object.compressed !== undefined && object.compressed !== null) { + message.compressed = CompressedBatchProof.fromPartial(object.compressed); + } else { + message.compressed = undefined; + } + return message; + }, +}; + +const baseLeafOp: object = { + hash: 0, + prehashKey: 0, + prehashValue: 0, + length: 0, +}; + +export const LeafOp = { + encode(message: LeafOp, writer: Writer = Writer.create()): Writer { + if (message.hash !== 0) { + writer.uint32(8).int32(message.hash); + } + if (message.prehashKey !== 0) { + writer.uint32(16).int32(message.prehashKey); + } + if (message.prehashValue !== 0) { + writer.uint32(24).int32(message.prehashValue); + } + if (message.length !== 0) { + writer.uint32(32).int32(message.length); + } + if (message.prefix.length !== 0) { + writer.uint32(42).bytes(message.prefix); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): LeafOp { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseLeafOp } as LeafOp; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.hash = reader.int32() as any; + break; + case 2: + message.prehashKey = reader.int32() as any; + break; + case 3: + message.prehashValue = reader.int32() as any; + break; + case 4: + message.length = reader.int32() as any; + break; + case 5: + message.prefix = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): LeafOp { + const message = { ...baseLeafOp } as LeafOp; + if (object.hash !== undefined && object.hash !== null) { + message.hash = hashOpFromJSON(object.hash); + } else { + message.hash = 0; + } + if (object.prehashKey !== undefined && object.prehashKey !== null) { + message.prehashKey = hashOpFromJSON(object.prehashKey); + } else { + message.prehashKey = 0; + } + if (object.prehashValue !== undefined && object.prehashValue !== null) { + message.prehashValue = hashOpFromJSON(object.prehashValue); + } else { + message.prehashValue = 0; + } + if (object.length !== undefined && object.length !== null) { + message.length = lengthOpFromJSON(object.length); + } else { + message.length = 0; + } + if (object.prefix !== undefined && object.prefix !== null) { + message.prefix = bytesFromBase64(object.prefix); + } + return message; + }, + + toJSON(message: LeafOp): unknown { + const obj: any = {}; + message.hash !== undefined && (obj.hash = hashOpToJSON(message.hash)); + message.prehashKey !== undefined && + (obj.prehashKey = hashOpToJSON(message.prehashKey)); + message.prehashValue !== undefined && + (obj.prehashValue = hashOpToJSON(message.prehashValue)); + message.length !== undefined && + (obj.length = lengthOpToJSON(message.length)); + message.prefix !== undefined && + (obj.prefix = base64FromBytes( + message.prefix !== undefined ? message.prefix : new Uint8Array() + )); + return obj; + }, + + fromPartial(object: DeepPartial): LeafOp { + const message = { ...baseLeafOp } as LeafOp; + if (object.hash !== undefined && object.hash !== null) { + message.hash = object.hash; + } else { + message.hash = 0; + } + if (object.prehashKey !== undefined && object.prehashKey !== null) { + message.prehashKey = object.prehashKey; + } else { + message.prehashKey = 0; + } + if (object.prehashValue !== undefined && object.prehashValue !== null) { + message.prehashValue = object.prehashValue; + } else { + message.prehashValue = 0; + } + if (object.length !== undefined && object.length !== null) { + message.length = object.length; + } else { + message.length = 0; + } + if (object.prefix !== undefined && object.prefix !== null) { + message.prefix = object.prefix; + } else { + message.prefix = new Uint8Array(); + } + return message; + }, +}; + +const baseInnerOp: object = { hash: 0 }; + +export const InnerOp = { + encode(message: InnerOp, writer: Writer = Writer.create()): Writer { + if (message.hash !== 0) { + writer.uint32(8).int32(message.hash); + } + if (message.prefix.length !== 0) { + writer.uint32(18).bytes(message.prefix); + } + if (message.suffix.length !== 0) { + writer.uint32(26).bytes(message.suffix); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): InnerOp { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseInnerOp } as InnerOp; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.hash = reader.int32() as any; + break; + case 2: + message.prefix = reader.bytes(); + break; + case 3: + message.suffix = reader.bytes(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): InnerOp { + const message = { ...baseInnerOp } as InnerOp; + if (object.hash !== undefined && object.hash !== null) { + message.hash = hashOpFromJSON(object.hash); + } else { + message.hash = 0; + } + if (object.prefix !== undefined && object.prefix !== null) { + message.prefix = bytesFromBase64(object.prefix); + } + if (object.suffix !== undefined && object.suffix !== null) { + message.suffix = bytesFromBase64(object.suffix); + } + return message; + }, + + toJSON(message: InnerOp): unknown { + const obj: any = {}; + message.hash !== undefined && (obj.hash = hashOpToJSON(message.hash)); + message.prefix !== undefined && + (obj.prefix = base64FromBytes( + message.prefix !== undefined ? message.prefix : new Uint8Array() + )); + message.suffix !== undefined && + (obj.suffix = base64FromBytes( + message.suffix !== undefined ? message.suffix : new Uint8Array() + )); + return obj; + }, + + fromPartial(object: DeepPartial): InnerOp { + const message = { ...baseInnerOp } as InnerOp; + if (object.hash !== undefined && object.hash !== null) { + message.hash = object.hash; + } else { + message.hash = 0; + } + if (object.prefix !== undefined && object.prefix !== null) { + message.prefix = object.prefix; + } else { + message.prefix = new Uint8Array(); + } + if (object.suffix !== undefined && object.suffix !== null) { + message.suffix = object.suffix; + } else { + message.suffix = new Uint8Array(); + } + return message; + }, +}; + +const baseProofSpec: object = { + maxDepth: 0, + minDepth: 0, + prehashKeyBeforeComparison: false, +}; + +export const ProofSpec = { + encode(message: ProofSpec, writer: Writer = Writer.create()): Writer { + if (message.leafSpec !== undefined) { + LeafOp.encode(message.leafSpec, writer.uint32(10).fork()).ldelim(); + } + if (message.innerSpec !== undefined) { + InnerSpec.encode(message.innerSpec, writer.uint32(18).fork()).ldelim(); + } + if (message.maxDepth !== 0) { + writer.uint32(24).int32(message.maxDepth); + } + if (message.minDepth !== 0) { + writer.uint32(32).int32(message.minDepth); + } + if (message.prehashKeyBeforeComparison === true) { + writer.uint32(40).bool(message.prehashKeyBeforeComparison); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): ProofSpec { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseProofSpec } as ProofSpec; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.leafSpec = LeafOp.decode(reader, reader.uint32()); + break; + case 2: + message.innerSpec = InnerSpec.decode(reader, reader.uint32()); + break; + case 3: + message.maxDepth = reader.int32(); + break; + case 4: + message.minDepth = reader.int32(); + break; + case 5: + message.prehashKeyBeforeComparison = reader.bool(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ProofSpec { + const message = { ...baseProofSpec } as ProofSpec; + if (object.leafSpec !== undefined && object.leafSpec !== null) { + message.leafSpec = LeafOp.fromJSON(object.leafSpec); + } else { + message.leafSpec = undefined; + } + if (object.innerSpec !== undefined && object.innerSpec !== null) { + message.innerSpec = InnerSpec.fromJSON(object.innerSpec); + } else { + message.innerSpec = undefined; + } + if (object.maxDepth !== undefined && object.maxDepth !== null) { + message.maxDepth = Number(object.maxDepth); + } else { + message.maxDepth = 0; + } + if (object.minDepth !== undefined && object.minDepth !== null) { + message.minDepth = Number(object.minDepth); + } else { + message.minDepth = 0; + } + if ( + object.prehashKeyBeforeComparison !== undefined && + object.prehashKeyBeforeComparison !== null + ) { + message.prehashKeyBeforeComparison = Boolean( + object.prehashKeyBeforeComparison + ); + } else { + message.prehashKeyBeforeComparison = false; + } + return message; + }, + + toJSON(message: ProofSpec): unknown { + const obj: any = {}; + message.leafSpec !== undefined && + (obj.leafSpec = message.leafSpec + ? LeafOp.toJSON(message.leafSpec) + : undefined); + message.innerSpec !== undefined && + (obj.innerSpec = message.innerSpec + ? InnerSpec.toJSON(message.innerSpec) + : undefined); + message.maxDepth !== undefined && (obj.maxDepth = message.maxDepth); + message.minDepth !== undefined && (obj.minDepth = message.minDepth); + message.prehashKeyBeforeComparison !== undefined && + (obj.prehashKeyBeforeComparison = message.prehashKeyBeforeComparison); + return obj; + }, + + fromPartial(object: DeepPartial): ProofSpec { + const message = { ...baseProofSpec } as ProofSpec; + if (object.leafSpec !== undefined && object.leafSpec !== null) { + message.leafSpec = LeafOp.fromPartial(object.leafSpec); + } else { + message.leafSpec = undefined; + } + if (object.innerSpec !== undefined && object.innerSpec !== null) { + message.innerSpec = InnerSpec.fromPartial(object.innerSpec); + } else { + message.innerSpec = undefined; + } + if (object.maxDepth !== undefined && object.maxDepth !== null) { + message.maxDepth = object.maxDepth; + } else { + message.maxDepth = 0; + } + if (object.minDepth !== undefined && object.minDepth !== null) { + message.minDepth = object.minDepth; + } else { + message.minDepth = 0; + } + if ( + object.prehashKeyBeforeComparison !== undefined && + object.prehashKeyBeforeComparison !== null + ) { + message.prehashKeyBeforeComparison = object.prehashKeyBeforeComparison; + } else { + message.prehashKeyBeforeComparison = false; + } + return message; + }, +}; + +const baseInnerSpec: object = { + childOrder: 0, + childSize: 0, + minPrefixLength: 0, + maxPrefixLength: 0, + hash: 0, +}; + +export const InnerSpec = { + encode(message: InnerSpec, writer: Writer = Writer.create()): Writer { + writer.uint32(10).fork(); + for (const v of message.childOrder) { + writer.int32(v); + } + writer.ldelim(); + if (message.childSize !== 0) { + writer.uint32(16).int32(message.childSize); + } + if (message.minPrefixLength !== 0) { + writer.uint32(24).int32(message.minPrefixLength); + } + if (message.maxPrefixLength !== 0) { + writer.uint32(32).int32(message.maxPrefixLength); + } + if (message.emptyChild.length !== 0) { + writer.uint32(42).bytes(message.emptyChild); + } + if (message.hash !== 0) { + writer.uint32(48).int32(message.hash); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): InnerSpec { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseInnerSpec } as InnerSpec; + message.childOrder = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.childOrder.push(reader.int32()); + } + } else { + message.childOrder.push(reader.int32()); + } + break; + case 2: + message.childSize = reader.int32(); + break; + case 3: + message.minPrefixLength = reader.int32(); + break; + case 4: + message.maxPrefixLength = reader.int32(); + break; + case 5: + message.emptyChild = reader.bytes(); + break; + case 6: + message.hash = reader.int32() as any; + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): InnerSpec { + const message = { ...baseInnerSpec } as InnerSpec; + message.childOrder = []; + if (object.childOrder !== undefined && object.childOrder !== null) { + for (const e of object.childOrder) { + message.childOrder.push(Number(e)); + } + } + if (object.childSize !== undefined && object.childSize !== null) { + message.childSize = Number(object.childSize); + } else { + message.childSize = 0; + } + if ( + object.minPrefixLength !== undefined && + object.minPrefixLength !== null + ) { + message.minPrefixLength = Number(object.minPrefixLength); + } else { + message.minPrefixLength = 0; + } + if ( + object.maxPrefixLength !== undefined && + object.maxPrefixLength !== null + ) { + message.maxPrefixLength = Number(object.maxPrefixLength); + } else { + message.maxPrefixLength = 0; + } + if (object.emptyChild !== undefined && object.emptyChild !== null) { + message.emptyChild = bytesFromBase64(object.emptyChild); + } + if (object.hash !== undefined && object.hash !== null) { + message.hash = hashOpFromJSON(object.hash); + } else { + message.hash = 0; + } + return message; + }, + + toJSON(message: InnerSpec): unknown { + const obj: any = {}; + if (message.childOrder) { + obj.childOrder = message.childOrder.map((e) => e); + } else { + obj.childOrder = []; + } + message.childSize !== undefined && (obj.childSize = message.childSize); + message.minPrefixLength !== undefined && + (obj.minPrefixLength = message.minPrefixLength); + message.maxPrefixLength !== undefined && + (obj.maxPrefixLength = message.maxPrefixLength); + message.emptyChild !== undefined && + (obj.emptyChild = base64FromBytes( + message.emptyChild !== undefined ? message.emptyChild : new Uint8Array() + )); + message.hash !== undefined && (obj.hash = hashOpToJSON(message.hash)); + return obj; + }, + + fromPartial(object: DeepPartial): InnerSpec { + const message = { ...baseInnerSpec } as InnerSpec; + message.childOrder = []; + if (object.childOrder !== undefined && object.childOrder !== null) { + for (const e of object.childOrder) { + message.childOrder.push(e); + } + } + if (object.childSize !== undefined && object.childSize !== null) { + message.childSize = object.childSize; + } else { + message.childSize = 0; + } + if ( + object.minPrefixLength !== undefined && + object.minPrefixLength !== null + ) { + message.minPrefixLength = object.minPrefixLength; + } else { + message.minPrefixLength = 0; + } + if ( + object.maxPrefixLength !== undefined && + object.maxPrefixLength !== null + ) { + message.maxPrefixLength = object.maxPrefixLength; + } else { + message.maxPrefixLength = 0; + } + if (object.emptyChild !== undefined && object.emptyChild !== null) { + message.emptyChild = object.emptyChild; + } else { + message.emptyChild = new Uint8Array(); + } + if (object.hash !== undefined && object.hash !== null) { + message.hash = object.hash; + } else { + message.hash = 0; + } + return message; + }, +}; + +const baseBatchProof: object = {}; + +export const BatchProof = { + encode(message: BatchProof, writer: Writer = Writer.create()): Writer { + for (const v of message.entries) { + BatchEntry.encode(v!, writer.uint32(10).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): BatchProof { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseBatchProof } as BatchProof; + message.entries = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.entries.push(BatchEntry.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): BatchProof { + const message = { ...baseBatchProof } as BatchProof; + message.entries = []; + if (object.entries !== undefined && object.entries !== null) { + for (const e of object.entries) { + message.entries.push(BatchEntry.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: BatchProof): unknown { + const obj: any = {}; + if (message.entries) { + obj.entries = message.entries.map((e) => + e ? BatchEntry.toJSON(e) : undefined + ); + } else { + obj.entries = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): BatchProof { + const message = { ...baseBatchProof } as BatchProof; + message.entries = []; + if (object.entries !== undefined && object.entries !== null) { + for (const e of object.entries) { + message.entries.push(BatchEntry.fromPartial(e)); + } + } + return message; + }, +}; + +const baseBatchEntry: object = {}; + +export const BatchEntry = { + encode(message: BatchEntry, writer: Writer = Writer.create()): Writer { + if (message.exist !== undefined) { + ExistenceProof.encode(message.exist, writer.uint32(10).fork()).ldelim(); + } + if (message.nonexist !== undefined) { + NonExistenceProof.encode( + message.nonexist, + writer.uint32(18).fork() + ).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): BatchEntry { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseBatchEntry } as BatchEntry; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.exist = ExistenceProof.decode(reader, reader.uint32()); + break; + case 2: + message.nonexist = NonExistenceProof.decode(reader, reader.uint32()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): BatchEntry { + const message = { ...baseBatchEntry } as BatchEntry; + if (object.exist !== undefined && object.exist !== null) { + message.exist = ExistenceProof.fromJSON(object.exist); + } else { + message.exist = undefined; + } + if (object.nonexist !== undefined && object.nonexist !== null) { + message.nonexist = NonExistenceProof.fromJSON(object.nonexist); + } else { + message.nonexist = undefined; + } + return message; + }, + + toJSON(message: BatchEntry): unknown { + const obj: any = {}; + message.exist !== undefined && + (obj.exist = message.exist + ? ExistenceProof.toJSON(message.exist) + : undefined); + message.nonexist !== undefined && + (obj.nonexist = message.nonexist + ? NonExistenceProof.toJSON(message.nonexist) + : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): BatchEntry { + const message = { ...baseBatchEntry } as BatchEntry; + if (object.exist !== undefined && object.exist !== null) { + message.exist = ExistenceProof.fromPartial(object.exist); + } else { + message.exist = undefined; + } + if (object.nonexist !== undefined && object.nonexist !== null) { + message.nonexist = NonExistenceProof.fromPartial(object.nonexist); + } else { + message.nonexist = undefined; + } + return message; + }, +}; + +const baseCompressedBatchProof: object = {}; + +export const CompressedBatchProof = { + encode( + message: CompressedBatchProof, + writer: Writer = Writer.create() + ): Writer { + for (const v of message.entries) { + CompressedBatchEntry.encode(v!, writer.uint32(10).fork()).ldelim(); + } + for (const v of message.lookupInners) { + InnerOp.encode(v!, writer.uint32(18).fork()).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): CompressedBatchProof { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseCompressedBatchProof } as CompressedBatchProof; + message.entries = []; + message.lookupInners = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.entries.push( + CompressedBatchEntry.decode(reader, reader.uint32()) + ); + break; + case 2: + message.lookupInners.push(InnerOp.decode(reader, reader.uint32())); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): CompressedBatchProof { + const message = { ...baseCompressedBatchProof } as CompressedBatchProof; + message.entries = []; + message.lookupInners = []; + if (object.entries !== undefined && object.entries !== null) { + for (const e of object.entries) { + message.entries.push(CompressedBatchEntry.fromJSON(e)); + } + } + if (object.lookupInners !== undefined && object.lookupInners !== null) { + for (const e of object.lookupInners) { + message.lookupInners.push(InnerOp.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: CompressedBatchProof): unknown { + const obj: any = {}; + if (message.entries) { + obj.entries = message.entries.map((e) => + e ? CompressedBatchEntry.toJSON(e) : undefined + ); + } else { + obj.entries = []; + } + if (message.lookupInners) { + obj.lookupInners = message.lookupInners.map((e) => + e ? InnerOp.toJSON(e) : undefined + ); + } else { + obj.lookupInners = []; + } + return obj; + }, + + fromPartial(object: DeepPartial): CompressedBatchProof { + const message = { ...baseCompressedBatchProof } as CompressedBatchProof; + message.entries = []; + message.lookupInners = []; + if (object.entries !== undefined && object.entries !== null) { + for (const e of object.entries) { + message.entries.push(CompressedBatchEntry.fromPartial(e)); + } + } + if (object.lookupInners !== undefined && object.lookupInners !== null) { + for (const e of object.lookupInners) { + message.lookupInners.push(InnerOp.fromPartial(e)); + } + } + return message; + }, +}; + +const baseCompressedBatchEntry: object = {}; + +export const CompressedBatchEntry = { + encode( + message: CompressedBatchEntry, + writer: Writer = Writer.create() + ): Writer { + if (message.exist !== undefined) { + CompressedExistenceProof.encode( + message.exist, + writer.uint32(10).fork() + ).ldelim(); + } + if (message.nonexist !== undefined) { + CompressedNonExistenceProof.encode( + message.nonexist, + writer.uint32(18).fork() + ).ldelim(); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): CompressedBatchEntry { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseCompressedBatchEntry } as CompressedBatchEntry; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.exist = CompressedExistenceProof.decode( + reader, + reader.uint32() + ); + break; + case 2: + message.nonexist = CompressedNonExistenceProof.decode( + reader, + reader.uint32() + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): CompressedBatchEntry { + const message = { ...baseCompressedBatchEntry } as CompressedBatchEntry; + if (object.exist !== undefined && object.exist !== null) { + message.exist = CompressedExistenceProof.fromJSON(object.exist); + } else { + message.exist = undefined; + } + if (object.nonexist !== undefined && object.nonexist !== null) { + message.nonexist = CompressedNonExistenceProof.fromJSON(object.nonexist); + } else { + message.nonexist = undefined; + } + return message; + }, + + toJSON(message: CompressedBatchEntry): unknown { + const obj: any = {}; + message.exist !== undefined && + (obj.exist = message.exist + ? CompressedExistenceProof.toJSON(message.exist) + : undefined); + message.nonexist !== undefined && + (obj.nonexist = message.nonexist + ? CompressedNonExistenceProof.toJSON(message.nonexist) + : undefined); + return obj; + }, + + fromPartial(object: DeepPartial): CompressedBatchEntry { + const message = { ...baseCompressedBatchEntry } as CompressedBatchEntry; + if (object.exist !== undefined && object.exist !== null) { + message.exist = CompressedExistenceProof.fromPartial(object.exist); + } else { + message.exist = undefined; + } + if (object.nonexist !== undefined && object.nonexist !== null) { + message.nonexist = CompressedNonExistenceProof.fromPartial( + object.nonexist + ); + } else { + message.nonexist = undefined; + } + return message; + }, +}; + +const baseCompressedExistenceProof: object = { path: 0 }; + +export const CompressedExistenceProof = { + encode( + message: CompressedExistenceProof, + writer: Writer = Writer.create() + ): Writer { + if (message.key.length !== 0) { + writer.uint32(10).bytes(message.key); + } + if (message.value.length !== 0) { + writer.uint32(18).bytes(message.value); + } + if (message.leaf !== undefined) { + LeafOp.encode(message.leaf, writer.uint32(26).fork()).ldelim(); + } + writer.uint32(34).fork(); + for (const v of message.path) { + writer.int32(v); + } + writer.ldelim(); + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): CompressedExistenceProof { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseCompressedExistenceProof, + } as CompressedExistenceProof; + message.path = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.key = reader.bytes(); + break; + case 2: + message.value = reader.bytes(); + break; + case 3: + message.leaf = LeafOp.decode(reader, reader.uint32()); + break; + case 4: + if ((tag & 7) === 2) { + const end2 = reader.uint32() + reader.pos; + while (reader.pos < end2) { + message.path.push(reader.int32()); + } + } else { + message.path.push(reader.int32()); + } + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): CompressedExistenceProof { + const message = { + ...baseCompressedExistenceProof, + } as CompressedExistenceProof; + message.path = []; + if (object.key !== undefined && object.key !== null) { + message.key = bytesFromBase64(object.key); + } + if (object.value !== undefined && object.value !== null) { + message.value = bytesFromBase64(object.value); + } + if (object.leaf !== undefined && object.leaf !== null) { + message.leaf = LeafOp.fromJSON(object.leaf); + } else { + message.leaf = undefined; + } + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(Number(e)); + } + } + return message; + }, + + toJSON(message: CompressedExistenceProof): unknown { + const obj: any = {}; + message.key !== undefined && + (obj.key = base64FromBytes( + message.key !== undefined ? message.key : new Uint8Array() + )); + message.value !== undefined && + (obj.value = base64FromBytes( + message.value !== undefined ? message.value : new Uint8Array() + )); + message.leaf !== undefined && + (obj.leaf = message.leaf ? LeafOp.toJSON(message.leaf) : undefined); + if (message.path) { + obj.path = message.path.map((e) => e); + } else { + obj.path = []; + } + return obj; + }, + + fromPartial( + object: DeepPartial + ): CompressedExistenceProof { + const message = { + ...baseCompressedExistenceProof, + } as CompressedExistenceProof; + message.path = []; + if (object.key !== undefined && object.key !== null) { + message.key = object.key; + } else { + message.key = new Uint8Array(); + } + if (object.value !== undefined && object.value !== null) { + message.value = object.value; + } else { + message.value = new Uint8Array(); + } + if (object.leaf !== undefined && object.leaf !== null) { + message.leaf = LeafOp.fromPartial(object.leaf); + } else { + message.leaf = undefined; + } + if (object.path !== undefined && object.path !== null) { + for (const e of object.path) { + message.path.push(e); + } + } + return message; + }, +}; + +const baseCompressedNonExistenceProof: object = {}; + +export const CompressedNonExistenceProof = { + encode( + message: CompressedNonExistenceProof, + writer: Writer = Writer.create() + ): Writer { + if (message.key.length !== 0) { + writer.uint32(10).bytes(message.key); + } + if (message.left !== undefined) { + CompressedExistenceProof.encode( + message.left, + writer.uint32(18).fork() + ).ldelim(); + } + if (message.right !== undefined) { + CompressedExistenceProof.encode( + message.right, + writer.uint32(26).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): CompressedNonExistenceProof { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseCompressedNonExistenceProof, + } as CompressedNonExistenceProof; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.key = reader.bytes(); + break; + case 2: + message.left = CompressedExistenceProof.decode( + reader, + reader.uint32() + ); + break; + case 3: + message.right = CompressedExistenceProof.decode( + reader, + reader.uint32() + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): CompressedNonExistenceProof { + const message = { + ...baseCompressedNonExistenceProof, + } as CompressedNonExistenceProof; + if (object.key !== undefined && object.key !== null) { + message.key = bytesFromBase64(object.key); + } + if (object.left !== undefined && object.left !== null) { + message.left = CompressedExistenceProof.fromJSON(object.left); + } else { + message.left = undefined; + } + if (object.right !== undefined && object.right !== null) { + message.right = CompressedExistenceProof.fromJSON(object.right); + } else { + message.right = undefined; + } + return message; + }, + + toJSON(message: CompressedNonExistenceProof): unknown { + const obj: any = {}; + message.key !== undefined && + (obj.key = base64FromBytes( + message.key !== undefined ? message.key : new Uint8Array() + )); + message.left !== undefined && + (obj.left = message.left + ? CompressedExistenceProof.toJSON(message.left) + : undefined); + message.right !== undefined && + (obj.right = message.right + ? CompressedExistenceProof.toJSON(message.right) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): CompressedNonExistenceProof { + const message = { + ...baseCompressedNonExistenceProof, + } as CompressedNonExistenceProof; + if (object.key !== undefined && object.key !== null) { + message.key = object.key; + } else { + message.key = new Uint8Array(); + } + if (object.left !== undefined && object.left !== null) { + message.left = CompressedExistenceProof.fromPartial(object.left); + } else { + message.left = undefined; + } + if (object.right !== undefined && object.right !== null) { + message.right = CompressedExistenceProof.fromPartial(object.right); + } else { + message.right = undefined; + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +const atob: (b64: string) => string = + globalThis.atob || + ((b64) => globalThis.Buffer.from(b64, "base64").toString("binary")); +function bytesFromBase64(b64: string): Uint8Array { + const bin = atob(b64); + const arr = new Uint8Array(bin.length); + for (let i = 0; i < bin.length; ++i) { + arr[i] = bin.charCodeAt(i); + } + return arr; +} + +const btoa: (bin: string) => string = + globalThis.btoa || + ((bin) => globalThis.Buffer.from(bin, "binary").toString("base64")); +function base64FromBytes(arr: Uint8Array): string { + const bin: string[] = []; + for (let i = 0; i < arr.byteLength; ++i) { + bin.push(String.fromCharCode(arr[i])); + } + return btoa(bin.join("")); +} + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/ts-client/index.ts b/ts-client/index.ts new file mode 100755 index 00000000..ed2904a4 --- /dev/null +++ b/ts-client/index.ts @@ -0,0 +1,75 @@ +// Generated by Ignite ignite.com/cli +import { Registry } from '@cosmjs/proto-signing' +import { IgniteClient } from "./client"; +import { MissingWalletError } from "./helpers"; +import { Module as BzeBurnerV1, msgTypes as BzeBurnerV1MsgTypes } from './bze.burner.v1' +import { Module as BzeCointrunkV1, msgTypes as BzeCointrunkV1MsgTypes } from './bze.cointrunk.v1' +import { Module as BzeEpochsV1, msgTypes as BzeEpochsV1MsgTypes } from './bze.epochs.v1' +import { Module as BzeScavenge, msgTypes as BzeScavengeMsgTypes } from './bze.scavenge' +import { Module as BzeTokenfactoryV1, msgTypes as BzeTokenfactoryV1MsgTypes } from './bze.tokenfactory.v1' +import { Module as BzeTradebinV1, msgTypes as BzeTradebinV1MsgTypes } from './bze.tradebin.v1' +import { Module as BzeV1Rewards, msgTypes as BzeV1RewardsMsgTypes } from './bze.v1.rewards' +import { Module as CosmosAuthV1Beta1, msgTypes as CosmosAuthV1Beta1MsgTypes } from './cosmos.auth.v1beta1' +import { Module as CosmosAuthzV1Beta1, msgTypes as CosmosAuthzV1Beta1MsgTypes } from './cosmos.authz.v1beta1' +import { Module as CosmosBankV1Beta1, msgTypes as CosmosBankV1Beta1MsgTypes } from './cosmos.bank.v1beta1' +import { Module as CosmosBaseTendermintV1Beta1, msgTypes as CosmosBaseTendermintV1Beta1MsgTypes } from './cosmos.base.tendermint.v1beta1' +import { Module as CosmosCrisisV1Beta1, msgTypes as CosmosCrisisV1Beta1MsgTypes } from './cosmos.crisis.v1beta1' +import { Module as CosmosDistributionV1Beta1, msgTypes as CosmosDistributionV1Beta1MsgTypes } from './cosmos.distribution.v1beta1' +import { Module as CosmosEvidenceV1Beta1, msgTypes as CosmosEvidenceV1Beta1MsgTypes } from './cosmos.evidence.v1beta1' +import { Module as CosmosFeegrantV1Beta1, msgTypes as CosmosFeegrantV1Beta1MsgTypes } from './cosmos.feegrant.v1beta1' +import { Module as CosmosGovV1Beta1, msgTypes as CosmosGovV1Beta1MsgTypes } from './cosmos.gov.v1beta1' +import { Module as CosmosMintV1Beta1, msgTypes as CosmosMintV1Beta1MsgTypes } from './cosmos.mint.v1beta1' +import { Module as CosmosParamsV1Beta1, msgTypes as CosmosParamsV1Beta1MsgTypes } from './cosmos.params.v1beta1' +import { Module as CosmosSlashingV1Beta1, msgTypes as CosmosSlashingV1Beta1MsgTypes } from './cosmos.slashing.v1beta1' +import { Module as CosmosStakingV1Beta1, msgTypes as CosmosStakingV1Beta1MsgTypes } from './cosmos.staking.v1beta1' +import { Module as CosmosTxV1Beta1, msgTypes as CosmosTxV1Beta1MsgTypes } from './cosmos.tx.v1beta1' +import { Module as CosmosUpgradeV1Beta1, msgTypes as CosmosUpgradeV1Beta1MsgTypes } from './cosmos.upgrade.v1beta1' +import { Module as CosmosVestingV1Beta1, msgTypes as CosmosVestingV1Beta1MsgTypes } from './cosmos.vesting.v1beta1' +import { Module as IbcApplicationsInterchainAccountsHostV1, msgTypes as IbcApplicationsInterchainAccountsHostV1MsgTypes } from './ibc.applications.interchain_accounts.host.v1' +import { Module as IbcApplicationsTransferV1, msgTypes as IbcApplicationsTransferV1MsgTypes } from './ibc.applications.transfer.v1' +import { Module as IbcCoreChannelV1, msgTypes as IbcCoreChannelV1MsgTypes } from './ibc.core.channel.v1' +import { Module as IbcCoreClientV1, msgTypes as IbcCoreClientV1MsgTypes } from './ibc.core.client.v1' +import { Module as IbcCoreConnectionV1, msgTypes as IbcCoreConnectionV1MsgTypes } from './ibc.core.connection.v1' + + +const Client = IgniteClient.plugin([ + BzeBurnerV1, BzeCointrunkV1, BzeEpochsV1, BzeScavenge, BzeTokenfactoryV1, BzeTradebinV1, BzeV1Rewards, CosmosAuthV1Beta1, CosmosAuthzV1Beta1, CosmosBankV1Beta1, CosmosBaseTendermintV1Beta1, CosmosCrisisV1Beta1, CosmosDistributionV1Beta1, CosmosEvidenceV1Beta1, CosmosFeegrantV1Beta1, CosmosGovV1Beta1, CosmosMintV1Beta1, CosmosParamsV1Beta1, CosmosSlashingV1Beta1, CosmosStakingV1Beta1, CosmosTxV1Beta1, CosmosUpgradeV1Beta1, CosmosVestingV1Beta1, IbcApplicationsInterchainAccountsHostV1, IbcApplicationsTransferV1, IbcCoreChannelV1, IbcCoreClientV1, IbcCoreConnectionV1 +]); + +const registry = new Registry([ + ...BzeBurnerV1MsgTypes, + ...BzeCointrunkV1MsgTypes, + ...BzeEpochsV1MsgTypes, + ...BzeScavengeMsgTypes, + ...BzeTokenfactoryV1MsgTypes, + ...BzeTradebinV1MsgTypes, + ...BzeV1RewardsMsgTypes, + ...CosmosAuthV1Beta1MsgTypes, + ...CosmosAuthzV1Beta1MsgTypes, + ...CosmosBankV1Beta1MsgTypes, + ...CosmosBaseTendermintV1Beta1MsgTypes, + ...CosmosCrisisV1Beta1MsgTypes, + ...CosmosDistributionV1Beta1MsgTypes, + ...CosmosEvidenceV1Beta1MsgTypes, + ...CosmosFeegrantV1Beta1MsgTypes, + ...CosmosGovV1Beta1MsgTypes, + ...CosmosMintV1Beta1MsgTypes, + ...CosmosParamsV1Beta1MsgTypes, + ...CosmosSlashingV1Beta1MsgTypes, + ...CosmosStakingV1Beta1MsgTypes, + ...CosmosTxV1Beta1MsgTypes, + ...CosmosUpgradeV1Beta1MsgTypes, + ...CosmosVestingV1Beta1MsgTypes, + ...IbcApplicationsInterchainAccountsHostV1MsgTypes, + ...IbcApplicationsTransferV1MsgTypes, + ...IbcCoreChannelV1MsgTypes, + ...IbcCoreClientV1MsgTypes, + ...IbcCoreConnectionV1MsgTypes, + +]) + +export { + Client, + registry, + MissingWalletError +} diff --git a/ts-client/modules.ts b/ts-client/modules.ts new file mode 100755 index 00000000..634b83c1 --- /dev/null +++ b/ts-client/modules.ts @@ -0,0 +1,5 @@ +import { IgniteClient } from "./client"; +import { GeneratedType } from "@cosmjs/proto-signing"; + +export type ModuleInterface = { [key: string]: any } +export type Module = (instance: IgniteClient) => { module: ModuleInterface, registry: [string, GeneratedType][] } diff --git a/ts-client/package.json b/ts-client/package.json new file mode 100755 index 00000000..cb47ea4d --- /dev/null +++ b/ts-client/package.json @@ -0,0 +1,28 @@ +{ + "name": "bze-alphateam-bze-client-ts", + "version": "0.0.1", + "description": "Autogenerated Typescript Client", + "author": "Ignite Codegen ", + "license": "Apache-2.0", + "licenses": [ + { + "type": "Apache-2.0", + "url": "http://www.apache.org/licenses/LICENSE-2.0" + } + ], + "main": "index.ts", + "publishConfig": { + "access": "public" + }, + "dependencies": { + "@cosmjs/launchpad": "0.27.0", + "@cosmjs/proto-signing": "0.27.0", + "@cosmjs/stargate": "0.27.0", + "buffer": "^6.0.3" + }, + "peerDependencies": { + "@cosmjs/launchpad": "0.27.0", + "@cosmjs/proto-signing": "0.27.0", + "@cosmjs/stargate": "0.27.0" + } +} diff --git a/vue/package.json b/vue/package.json index 6ae37a8c..736c54d5 100644 --- a/vue/package.json +++ b/vue/package.json @@ -1,27 +1,18 @@ { - "name": "@starport/template", - "version": "0.1.55", - "description": "A Vue 3 boilerplate project utilizing @starport/vue and @starport/vuex", - "author": "Tendermint, Inc ", - "private": true, - "scripts": { - "serve": "vue-cli-service serve --mode=production", - "dev": "vue-cli-service serve", - "lint": "vue-cli-service lint", - "build": "vue-cli-service build", - "test:unit": "vue-cli-service test:unit" - }, + "author": "Tendermint, Inc \u003chello@tendermint.com\u003e", "dependencies": { "@cosmjs/launchpad": "^0.26.1", "@cosmjs/proto-signing": "^0.26.1", "@cosmjs/stargate": "^0.26.1", "@starport/vue": "^0.1.55", "@starport/vuex": "^0.1.55", + "bze-alphateam-bze-client-ts": "file:../ts-client", "core-js": "^3.18.2", "vue": "^3.2.6", "vue-router": "^4.0.3", "vuex": "^4.0.0" }, + "description": "A Vue 3 boilerplate project utilizing @starport/vue and @starport/vuex", "devDependencies": { "@babel/core": "^7.15.5", "@babel/eslint-parser": "^7.15.7", @@ -49,5 +40,15 @@ }, "gitHooks": { "pre-commit": "lint-staged" - } + }, + "name": "@starport/template", + "private": true, + "scripts": { + "build": "vue-cli-service build", + "dev": "vue-cli-service serve", + "lint": "vue-cli-service lint", + "serve": "vue-cli-service serve --mode=production", + "test:unit": "vue-cli-service test:unit" + }, + "version": "0.1.55" } diff --git a/vue/src/store/generated/bze.burner.v1/index.ts b/vue/src/store/generated/bze.burner.v1/index.ts new file mode 100755 index 00000000..8ce7632a --- /dev/null +++ b/vue/src/store/generated/bze.burner.v1/index.ts @@ -0,0 +1,201 @@ +import { Client, registry, MissingWalletError } from 'bze-alphateam-bze-client-ts' + +import { BurnCoinsProposal } from "bze-alphateam-bze-client-ts/bze.burner.v1/types" +import { BurnedCoins } from "bze-alphateam-bze-client-ts/bze.burner.v1/types" +import { CoinsBurnedEvent } from "bze-alphateam-bze-client-ts/bze.burner.v1/types" +import { FundBurnerEvent } from "bze-alphateam-bze-client-ts/bze.burner.v1/types" +import { Params } from "bze-alphateam-bze-client-ts/bze.burner.v1/types" + + +export { BurnCoinsProposal, BurnedCoins, CoinsBurnedEvent, FundBurnerEvent, Params }; + +function initClient(vuexGetters) { + return new Client(vuexGetters['common/env/getEnv'], vuexGetters['common/wallet/signer']) +} + +function mergeResults(value, next_values) { + for (let prop of Object.keys(next_values)) { + if (Array.isArray(next_values[prop])) { + value[prop]=[...value[prop], ...next_values[prop]] + }else{ + value[prop]=next_values[prop] + } + } + return value +} + +type Field = { + name: string; + type: unknown; +} +function getStructure(template) { + let structure: {fields: Field[]} = { fields: [] } + for (const [key, value] of Object.entries(template)) { + let field = { name: key, type: typeof value } + structure.fields.push(field) + } + return structure +} +const getDefaultState = () => { + return { + Params: {}, + AllBurnedCoins: {}, + + _Structure: { + BurnCoinsProposal: getStructure(BurnCoinsProposal.fromPartial({})), + BurnedCoins: getStructure(BurnedCoins.fromPartial({})), + CoinsBurnedEvent: getStructure(CoinsBurnedEvent.fromPartial({})), + FundBurnerEvent: getStructure(FundBurnerEvent.fromPartial({})), + Params: getStructure(Params.fromPartial({})), + + }, + _Registry: registry, + _Subscriptions: new Set(), + } +} + +// initial state +const state = getDefaultState() + +export default { + namespaced: true, + state, + mutations: { + RESET_STATE(state) { + Object.assign(state, getDefaultState()) + }, + QUERY(state, { query, key, value }) { + state[query][JSON.stringify(key)] = value + }, + SUBSCRIBE(state, subscription) { + state._Subscriptions.add(JSON.stringify(subscription)) + }, + UNSUBSCRIBE(state, subscription) { + state._Subscriptions.delete(JSON.stringify(subscription)) + } + }, + getters: { + getParams: (state) => (params = { params: {}}) => { + if (!( params).query) { + ( params).query=null + } + return state.Params[JSON.stringify(params)] ?? {} + }, + getAllBurnedCoins: (state) => (params = { params: {}}) => { + if (!( params).query) { + ( params).query=null + } + return state.AllBurnedCoins[JSON.stringify(params)] ?? {} + }, + + getTypeStructure: (state) => (type) => { + return state._Structure[type].fields + }, + getRegistry: (state) => { + return state._Registry + } + }, + actions: { + init({ dispatch, rootGetters }) { + console.log('Vuex module: bze.burner.v1 initialized!') + if (rootGetters['common/env/client']) { + rootGetters['common/env/client'].on('newblock', () => { + dispatch('StoreUpdate') + }) + } + }, + resetState({ commit }) { + commit('RESET_STATE') + }, + unsubscribe({ commit }, subscription) { + commit('UNSUBSCRIBE', subscription) + }, + async StoreUpdate({ state, dispatch }) { + state._Subscriptions.forEach(async (subscription) => { + try { + const sub=JSON.parse(subscription) + await dispatch(sub.action, sub.payload) + }catch(e) { + throw new Error('Subscriptions: ' + e.message) + } + }) + }, + + + + + + + async QueryParams({ commit, rootGetters, getters }, { options: { subscribe, all} = { subscribe:false, all:false}, params, query=null }) { + try { + const key = params ?? {}; + const client = initClient(rootGetters); + let value= (await client.BzeBurnerV1.query.queryParams()).data + + + commit('QUERY', { query: 'Params', key: { params: {...key}, query}, value }) + if (subscribe) commit('SUBSCRIBE', { action: 'QueryParams', payload: { options: { all }, params: {...key},query }}) + return getters['getParams']( { params: {...key}, query}) ?? {} + } catch (e) { + throw new Error('QueryClient:QueryParams API Node Unavailable. Could not perform query: ' + e.message) + + } + }, + + + + + + + + async QueryAllBurnedCoins({ commit, rootGetters, getters }, { options: { subscribe, all} = { subscribe:false, all:false}, params, query=null }) { + try { + const key = params ?? {}; + const client = initClient(rootGetters); + let value= (await client.BzeBurnerV1.query.queryAllBurnedCoins(query ?? undefined)).data + + + while (all && ( value).pagination && ( value).pagination.next_key!=null) { + let next_values=(await client.BzeBurnerV1.query.queryAllBurnedCoins({...query ?? {}, 'pagination.key':( value).pagination.next_key} as any)).data + value = mergeResults(value, next_values); + } + commit('QUERY', { query: 'AllBurnedCoins', key: { params: {...key}, query}, value }) + if (subscribe) commit('SUBSCRIBE', { action: 'QueryAllBurnedCoins', payload: { options: { all }, params: {...key},query }}) + return getters['getAllBurnedCoins']( { params: {...key}, query}) ?? {} + } catch (e) { + throw new Error('QueryClient:QueryAllBurnedCoins API Node Unavailable. Could not perform query: ' + e.message) + + } + }, + + + async sendMsgFundBurner({ rootGetters }, { value, fee = [], memo = '' }) { + try { + const client=await initClient(rootGetters) + const result = await client.BzeBurnerV1.tx.sendMsgFundBurner({ value, fee: {amount: fee, gas: "200000"}, memo }) + return result + } catch (e) { + if (e == MissingWalletError) { + throw new Error('TxClient:MsgFundBurner:Init Could not initialize signing client. Wallet is required.') + }else{ + throw new Error('TxClient:MsgFundBurner:Send Could not broadcast Tx: '+ e.message) + } + } + }, + + async MsgFundBurner({ rootGetters }, { value }) { + try { + const client=initClient(rootGetters) + const msg = await client.BzeBurnerV1.tx.msgFundBurner({value}) + return msg + } catch (e) { + if (e == MissingWalletError) { + throw new Error('TxClient:MsgFundBurner:Init Could not initialize signing client. Wallet is required.') + } else{ + throw new Error('TxClient:MsgFundBurner:Create Could not create message: ' + e.message) + } + } + }, + + } +} diff --git a/vue/src/store/generated/bze.cointrunk.v1/index.ts b/vue/src/store/generated/bze.cointrunk.v1/index.ts new file mode 100755 index 00000000..5a5b651c --- /dev/null +++ b/vue/src/store/generated/bze.cointrunk.v1/index.ts @@ -0,0 +1,373 @@ +import { Client, registry, MissingWalletError } from 'bze-alphateam-bze-client-ts' + +import { AcceptedDomain } from "bze-alphateam-bze-client-ts/bze.cointrunk.v1/types" +import { AcceptedDomainProposal } from "bze-alphateam-bze-client-ts/bze.cointrunk.v1/types" +import { AnonArticlesCounter } from "bze-alphateam-bze-client-ts/bze.cointrunk.v1/types" +import { Article } from "bze-alphateam-bze-client-ts/bze.cointrunk.v1/types" +import { ArticleAddedEvent } from "bze-alphateam-bze-client-ts/bze.cointrunk.v1/types" +import { PublisherAddedEvent } from "bze-alphateam-bze-client-ts/bze.cointrunk.v1/types" +import { PublisherUpdatedEvent } from "bze-alphateam-bze-client-ts/bze.cointrunk.v1/types" +import { AcceptedDomainAddedEvent } from "bze-alphateam-bze-client-ts/bze.cointrunk.v1/types" +import { AcceptedDomainUpdatedEvent } from "bze-alphateam-bze-client-ts/bze.cointrunk.v1/types" +import { PublisherRespectPaidEvent } from "bze-alphateam-bze-client-ts/bze.cointrunk.v1/types" +import { PublisherRespectParams } from "bze-alphateam-bze-client-ts/bze.cointrunk.v1/types" +import { Params } from "bze-alphateam-bze-client-ts/bze.cointrunk.v1/types" +import { Publisher } from "bze-alphateam-bze-client-ts/bze.cointrunk.v1/types" +import { PublisherProposal } from "bze-alphateam-bze-client-ts/bze.cointrunk.v1/types" + + +export { AcceptedDomain, AcceptedDomainProposal, AnonArticlesCounter, Article, ArticleAddedEvent, PublisherAddedEvent, PublisherUpdatedEvent, AcceptedDomainAddedEvent, AcceptedDomainUpdatedEvent, PublisherRespectPaidEvent, PublisherRespectParams, Params, Publisher, PublisherProposal }; + +function initClient(vuexGetters) { + return new Client(vuexGetters['common/env/getEnv'], vuexGetters['common/wallet/signer']) +} + +function mergeResults(value, next_values) { + for (let prop of Object.keys(next_values)) { + if (Array.isArray(next_values[prop])) { + value[prop]=[...value[prop], ...next_values[prop]] + }else{ + value[prop]=next_values[prop] + } + } + return value +} + +type Field = { + name: string; + type: unknown; +} +function getStructure(template) { + let structure: {fields: Field[]} = { fields: [] } + for (const [key, value] of Object.entries(template)) { + let field = { name: key, type: typeof value } + structure.fields.push(field) + } + return structure +} +const getDefaultState = () => { + return { + Params: {}, + AcceptedDomain: {}, + Publisher: {}, + PublisherByIndex: {}, + AllArticles: {}, + AllAnonArticlesCounters: {}, + + _Structure: { + AcceptedDomain: getStructure(AcceptedDomain.fromPartial({})), + AcceptedDomainProposal: getStructure(AcceptedDomainProposal.fromPartial({})), + AnonArticlesCounter: getStructure(AnonArticlesCounter.fromPartial({})), + Article: getStructure(Article.fromPartial({})), + ArticleAddedEvent: getStructure(ArticleAddedEvent.fromPartial({})), + PublisherAddedEvent: getStructure(PublisherAddedEvent.fromPartial({})), + PublisherUpdatedEvent: getStructure(PublisherUpdatedEvent.fromPartial({})), + AcceptedDomainAddedEvent: getStructure(AcceptedDomainAddedEvent.fromPartial({})), + AcceptedDomainUpdatedEvent: getStructure(AcceptedDomainUpdatedEvent.fromPartial({})), + PublisherRespectPaidEvent: getStructure(PublisherRespectPaidEvent.fromPartial({})), + PublisherRespectParams: getStructure(PublisherRespectParams.fromPartial({})), + Params: getStructure(Params.fromPartial({})), + Publisher: getStructure(Publisher.fromPartial({})), + PublisherProposal: getStructure(PublisherProposal.fromPartial({})), + + }, + _Registry: registry, + _Subscriptions: new Set(), + } +} + +// initial state +const state = getDefaultState() + +export default { + namespaced: true, + state, + mutations: { + RESET_STATE(state) { + Object.assign(state, getDefaultState()) + }, + QUERY(state, { query, key, value }) { + state[query][JSON.stringify(key)] = value + }, + SUBSCRIBE(state, subscription) { + state._Subscriptions.add(JSON.stringify(subscription)) + }, + UNSUBSCRIBE(state, subscription) { + state._Subscriptions.delete(JSON.stringify(subscription)) + } + }, + getters: { + getParams: (state) => (params = { params: {}}) => { + if (!( params).query) { + ( params).query=null + } + return state.Params[JSON.stringify(params)] ?? {} + }, + getAcceptedDomain: (state) => (params = { params: {}}) => { + if (!( params).query) { + ( params).query=null + } + return state.AcceptedDomain[JSON.stringify(params)] ?? {} + }, + getPublisher: (state) => (params = { params: {}}) => { + if (!( params).query) { + ( params).query=null + } + return state.Publisher[JSON.stringify(params)] ?? {} + }, + getPublisherByIndex: (state) => (params = { params: {}}) => { + if (!( params).query) { + ( params).query=null + } + return state.PublisherByIndex[JSON.stringify(params)] ?? {} + }, + getAllArticles: (state) => (params = { params: {}}) => { + if (!( params).query) { + ( params).query=null + } + return state.AllArticles[JSON.stringify(params)] ?? {} + }, + getAllAnonArticlesCounters: (state) => (params = { params: {}}) => { + if (!( params).query) { + ( params).query=null + } + return state.AllAnonArticlesCounters[JSON.stringify(params)] ?? {} + }, + + getTypeStructure: (state) => (type) => { + return state._Structure[type].fields + }, + getRegistry: (state) => { + return state._Registry + } + }, + actions: { + init({ dispatch, rootGetters }) { + console.log('Vuex module: bze.cointrunk.v1 initialized!') + if (rootGetters['common/env/client']) { + rootGetters['common/env/client'].on('newblock', () => { + dispatch('StoreUpdate') + }) + } + }, + resetState({ commit }) { + commit('RESET_STATE') + }, + unsubscribe({ commit }, subscription) { + commit('UNSUBSCRIBE', subscription) + }, + async StoreUpdate({ state, dispatch }) { + state._Subscriptions.forEach(async (subscription) => { + try { + const sub=JSON.parse(subscription) + await dispatch(sub.action, sub.payload) + }catch(e) { + throw new Error('Subscriptions: ' + e.message) + } + }) + }, + + + + + + + async QueryParams({ commit, rootGetters, getters }, { options: { subscribe, all} = { subscribe:false, all:false}, params, query=null }) { + try { + const key = params ?? {}; + const client = initClient(rootGetters); + let value= (await client.BzeCointrunkV1.query.queryParams()).data + + + commit('QUERY', { query: 'Params', key: { params: {...key}, query}, value }) + if (subscribe) commit('SUBSCRIBE', { action: 'QueryParams', payload: { options: { all }, params: {...key},query }}) + return getters['getParams']( { params: {...key}, query}) ?? {} + } catch (e) { + throw new Error('QueryClient:QueryParams API Node Unavailable. Could not perform query: ' + e.message) + + } + }, + + + + + + + + async QueryAcceptedDomain({ commit, rootGetters, getters }, { options: { subscribe, all} = { subscribe:false, all:false}, params, query=null }) { + try { + const key = params ?? {}; + const client = initClient(rootGetters); + let value= (await client.BzeCointrunkV1.query.queryAcceptedDomain(query ?? undefined)).data + + + while (all && ( value).pagination && ( value).pagination.next_key!=null) { + let next_values=(await client.BzeCointrunkV1.query.queryAcceptedDomain({...query ?? {}, 'pagination.key':( value).pagination.next_key} as any)).data + value = mergeResults(value, next_values); + } + commit('QUERY', { query: 'AcceptedDomain', key: { params: {...key}, query}, value }) + if (subscribe) commit('SUBSCRIBE', { action: 'QueryAcceptedDomain', payload: { options: { all }, params: {...key},query }}) + return getters['getAcceptedDomain']( { params: {...key}, query}) ?? {} + } catch (e) { + throw new Error('QueryClient:QueryAcceptedDomain API Node Unavailable. Could not perform query: ' + e.message) + + } + }, + + + + + + + + async QueryPublisher({ commit, rootGetters, getters }, { options: { subscribe, all} = { subscribe:false, all:false}, params, query=null }) { + try { + const key = params ?? {}; + const client = initClient(rootGetters); + let value= (await client.BzeCointrunkV1.query.queryPublisher(query ?? undefined)).data + + + while (all && ( value).pagination && ( value).pagination.next_key!=null) { + let next_values=(await client.BzeCointrunkV1.query.queryPublisher({...query ?? {}, 'pagination.key':( value).pagination.next_key} as any)).data + value = mergeResults(value, next_values); + } + commit('QUERY', { query: 'Publisher', key: { params: {...key}, query}, value }) + if (subscribe) commit('SUBSCRIBE', { action: 'QueryPublisher', payload: { options: { all }, params: {...key},query }}) + return getters['getPublisher']( { params: {...key}, query}) ?? {} + } catch (e) { + throw new Error('QueryClient:QueryPublisher API Node Unavailable. Could not perform query: ' + e.message) + + } + }, + + + + + + + + async QueryPublisherByIndex({ commit, rootGetters, getters }, { options: { subscribe, all} = { subscribe:false, all:false}, params, query=null }) { + try { + const key = params ?? {}; + const client = initClient(rootGetters); + let value= (await client.BzeCointrunkV1.query.queryPublisherByIndex( key.index)).data + + + commit('QUERY', { query: 'PublisherByIndex', key: { params: {...key}, query}, value }) + if (subscribe) commit('SUBSCRIBE', { action: 'QueryPublisherByIndex', payload: { options: { all }, params: {...key},query }}) + return getters['getPublisherByIndex']( { params: {...key}, query}) ?? {} + } catch (e) { + throw new Error('QueryClient:QueryPublisherByIndex API Node Unavailable. Could not perform query: ' + e.message) + + } + }, + + + + + + + + async QueryAllArticles({ commit, rootGetters, getters }, { options: { subscribe, all} = { subscribe:false, all:false}, params, query=null }) { + try { + const key = params ?? {}; + const client = initClient(rootGetters); + let value= (await client.BzeCointrunkV1.query.queryAllArticles(query ?? undefined)).data + + + while (all && ( value).pagination && ( value).pagination.next_key!=null) { + let next_values=(await client.BzeCointrunkV1.query.queryAllArticles({...query ?? {}, 'pagination.key':( value).pagination.next_key} as any)).data + value = mergeResults(value, next_values); + } + commit('QUERY', { query: 'AllArticles', key: { params: {...key}, query}, value }) + if (subscribe) commit('SUBSCRIBE', { action: 'QueryAllArticles', payload: { options: { all }, params: {...key},query }}) + return getters['getAllArticles']( { params: {...key}, query}) ?? {} + } catch (e) { + throw new Error('QueryClient:QueryAllArticles API Node Unavailable. Could not perform query: ' + e.message) + + } + }, + + + + + + + + async QueryAllAnonArticlesCounters({ commit, rootGetters, getters }, { options: { subscribe, all} = { subscribe:false, all:false}, params, query=null }) { + try { + const key = params ?? {}; + const client = initClient(rootGetters); + let value= (await client.BzeCointrunkV1.query.queryAllAnonArticlesCounters(query ?? undefined)).data + + + while (all && ( value).pagination && ( value).pagination.next_key!=null) { + let next_values=(await client.BzeCointrunkV1.query.queryAllAnonArticlesCounters({...query ?? {}, 'pagination.key':( value).pagination.next_key} as any)).data + value = mergeResults(value, next_values); + } + commit('QUERY', { query: 'AllAnonArticlesCounters', key: { params: {...key}, query}, value }) + if (subscribe) commit('SUBSCRIBE', { action: 'QueryAllAnonArticlesCounters', payload: { options: { all }, params: {...key},query }}) + return getters['getAllAnonArticlesCounters']( { params: {...key}, query}) ?? {} + } catch (e) { + throw new Error('QueryClient:QueryAllAnonArticlesCounters API Node Unavailable. Could not perform query: ' + e.message) + + } + }, + + + async sendMsgPayPublisherRespect({ rootGetters }, { value, fee = [], memo = '' }) { + try { + const client=await initClient(rootGetters) + const result = await client.BzeCointrunkV1.tx.sendMsgPayPublisherRespect({ value, fee: {amount: fee, gas: "200000"}, memo }) + return result + } catch (e) { + if (e == MissingWalletError) { + throw new Error('TxClient:MsgPayPublisherRespect:Init Could not initialize signing client. Wallet is required.') + }else{ + throw new Error('TxClient:MsgPayPublisherRespect:Send Could not broadcast Tx: '+ e.message) + } + } + }, + async sendMsgAddArticle({ rootGetters }, { value, fee = [], memo = '' }) { + try { + const client=await initClient(rootGetters) + const result = await client.BzeCointrunkV1.tx.sendMsgAddArticle({ value, fee: {amount: fee, gas: "200000"}, memo }) + return result + } catch (e) { + if (e == MissingWalletError) { + throw new Error('TxClient:MsgAddArticle:Init Could not initialize signing client. Wallet is required.') + }else{ + throw new Error('TxClient:MsgAddArticle:Send Could not broadcast Tx: '+ e.message) + } + } + }, + + async MsgPayPublisherRespect({ rootGetters }, { value }) { + try { + const client=initClient(rootGetters) + const msg = await client.BzeCointrunkV1.tx.msgPayPublisherRespect({value}) + return msg + } catch (e) { + if (e == MissingWalletError) { + throw new Error('TxClient:MsgPayPublisherRespect:Init Could not initialize signing client. Wallet is required.') + } else{ + throw new Error('TxClient:MsgPayPublisherRespect:Create Could not create message: ' + e.message) + } + } + }, + async MsgAddArticle({ rootGetters }, { value }) { + try { + const client=initClient(rootGetters) + const msg = await client.BzeCointrunkV1.tx.msgAddArticle({value}) + return msg + } catch (e) { + if (e == MissingWalletError) { + throw new Error('TxClient:MsgAddArticle:Init Could not initialize signing client. Wallet is required.') + } else{ + throw new Error('TxClient:MsgAddArticle:Create Could not create message: ' + e.message) + } + } + }, + + } +} diff --git a/vue/src/store/generated/bze.epochs.v1/index.ts b/vue/src/store/generated/bze.epochs.v1/index.ts new file mode 100755 index 00000000..1447fec4 --- /dev/null +++ b/vue/src/store/generated/bze.epochs.v1/index.ts @@ -0,0 +1,171 @@ +import { Client, registry, MissingWalletError } from 'bze-alphateam-bze-client-ts' + +import { EpochStartEvent } from "bze-alphateam-bze-client-ts/bze.epochs.v1/types" +import { EpochEndEvent } from "bze-alphateam-bze-client-ts/bze.epochs.v1/types" +import { EpochInfo } from "bze-alphateam-bze-client-ts/bze.epochs.v1/types" + + +export { EpochStartEvent, EpochEndEvent, EpochInfo }; + +function initClient(vuexGetters) { + return new Client(vuexGetters['common/env/getEnv'], vuexGetters['common/wallet/signer']) +} + +function mergeResults(value, next_values) { + for (let prop of Object.keys(next_values)) { + if (Array.isArray(next_values[prop])) { + value[prop]=[...value[prop], ...next_values[prop]] + }else{ + value[prop]=next_values[prop] + } + } + return value +} + +type Field = { + name: string; + type: unknown; +} +function getStructure(template) { + let structure: {fields: Field[]} = { fields: [] } + for (const [key, value] of Object.entries(template)) { + let field = { name: key, type: typeof value } + structure.fields.push(field) + } + return structure +} +const getDefaultState = () => { + return { + EpochInfos: {}, + CurrentEpoch: {}, + + _Structure: { + EpochStartEvent: getStructure(EpochStartEvent.fromPartial({})), + EpochEndEvent: getStructure(EpochEndEvent.fromPartial({})), + EpochInfo: getStructure(EpochInfo.fromPartial({})), + + }, + _Registry: registry, + _Subscriptions: new Set(), + } +} + +// initial state +const state = getDefaultState() + +export default { + namespaced: true, + state, + mutations: { + RESET_STATE(state) { + Object.assign(state, getDefaultState()) + }, + QUERY(state, { query, key, value }) { + state[query][JSON.stringify(key)] = value + }, + SUBSCRIBE(state, subscription) { + state._Subscriptions.add(JSON.stringify(subscription)) + }, + UNSUBSCRIBE(state, subscription) { + state._Subscriptions.delete(JSON.stringify(subscription)) + } + }, + getters: { + getEpochInfos: (state) => (params = { params: {}}) => { + if (!( params).query) { + ( params).query=null + } + return state.EpochInfos[JSON.stringify(params)] ?? {} + }, + getCurrentEpoch: (state) => (params = { params: {}}) => { + if (!( params).query) { + ( params).query=null + } + return state.CurrentEpoch[JSON.stringify(params)] ?? {} + }, + + getTypeStructure: (state) => (type) => { + return state._Structure[type].fields + }, + getRegistry: (state) => { + return state._Registry + } + }, + actions: { + init({ dispatch, rootGetters }) { + console.log('Vuex module: bze.epochs.v1 initialized!') + if (rootGetters['common/env/client']) { + rootGetters['common/env/client'].on('newblock', () => { + dispatch('StoreUpdate') + }) + } + }, + resetState({ commit }) { + commit('RESET_STATE') + }, + unsubscribe({ commit }, subscription) { + commit('UNSUBSCRIBE', subscription) + }, + async StoreUpdate({ state, dispatch }) { + state._Subscriptions.forEach(async (subscription) => { + try { + const sub=JSON.parse(subscription) + await dispatch(sub.action, sub.payload) + }catch(e) { + throw new Error('Subscriptions: ' + e.message) + } + }) + }, + + + + + + + async QueryEpochInfos({ commit, rootGetters, getters }, { options: { subscribe, all} = { subscribe:false, all:false}, params, query=null }) { + try { + const key = params ?? {}; + const client = initClient(rootGetters); + let value= (await client.BzeEpochsV1.query.queryEpochInfos()).data + + + commit('QUERY', { query: 'EpochInfos', key: { params: {...key}, query}, value }) + if (subscribe) commit('SUBSCRIBE', { action: 'QueryEpochInfos', payload: { options: { all }, params: {...key},query }}) + return getters['getEpochInfos']( { params: {...key}, query}) ?? {} + } catch (e) { + throw new Error('QueryClient:QueryEpochInfos API Node Unavailable. Could not perform query: ' + e.message) + + } + }, + + + + + + + + async QueryCurrentEpoch({ commit, rootGetters, getters }, { options: { subscribe, all} = { subscribe:false, all:false}, params, query=null }) { + try { + const key = params ?? {}; + const client = initClient(rootGetters); + let value= (await client.BzeEpochsV1.query.queryCurrentEpoch(query ?? undefined)).data + + + while (all && ( value).pagination && ( value).pagination.next_key!=null) { + let next_values=(await client.BzeEpochsV1.query.queryCurrentEpoch({...query ?? {}, 'pagination.key':( value).pagination.next_key} as any)).data + value = mergeResults(value, next_values); + } + commit('QUERY', { query: 'CurrentEpoch', key: { params: {...key}, query}, value }) + if (subscribe) commit('SUBSCRIBE', { action: 'QueryCurrentEpoch', payload: { options: { all }, params: {...key},query }}) + return getters['getCurrentEpoch']( { params: {...key}, query}) ?? {} + } catch (e) { + throw new Error('QueryClient:QueryCurrentEpoch API Node Unavailable. Could not perform query: ' + e.message) + + } + }, + + + + + } +} diff --git a/vue/src/store/generated/bze.scavenge/index.ts b/vue/src/store/generated/bze.scavenge/index.ts new file mode 100755 index 00000000..08436e57 --- /dev/null +++ b/vue/src/store/generated/bze.scavenge/index.ts @@ -0,0 +1,309 @@ +import { Client, registry, MissingWalletError } from 'bze-alphateam-bze-client-ts' + +import { Commit } from "bze-alphateam-bze-client-ts/bze.scavenge/types" +import { Scavenge } from "bze-alphateam-bze-client-ts/bze.scavenge/types" + + +export { Commit, Scavenge }; + +function initClient(vuexGetters) { + return new Client(vuexGetters['common/env/getEnv'], vuexGetters['common/wallet/signer']) +} + +function mergeResults(value, next_values) { + for (let prop of Object.keys(next_values)) { + if (Array.isArray(next_values[prop])) { + value[prop]=[...value[prop], ...next_values[prop]] + }else{ + value[prop]=next_values[prop] + } + } + return value +} + +type Field = { + name: string; + type: unknown; +} +function getStructure(template) { + let structure: {fields: Field[]} = { fields: [] } + for (const [key, value] of Object.entries(template)) { + let field = { name: key, type: typeof value } + structure.fields.push(field) + } + return structure +} +const getDefaultState = () => { + return { + Scavenge: {}, + ScavengeAll: {}, + Commit: {}, + CommitAll: {}, + + _Structure: { + Commit: getStructure(Commit.fromPartial({})), + Scavenge: getStructure(Scavenge.fromPartial({})), + + }, + _Registry: registry, + _Subscriptions: new Set(), + } +} + +// initial state +const state = getDefaultState() + +export default { + namespaced: true, + state, + mutations: { + RESET_STATE(state) { + Object.assign(state, getDefaultState()) + }, + QUERY(state, { query, key, value }) { + state[query][JSON.stringify(key)] = value + }, + SUBSCRIBE(state, subscription) { + state._Subscriptions.add(JSON.stringify(subscription)) + }, + UNSUBSCRIBE(state, subscription) { + state._Subscriptions.delete(JSON.stringify(subscription)) + } + }, + getters: { + getScavenge: (state) => (params = { params: {}}) => { + if (!( params).query) { + ( params).query=null + } + return state.Scavenge[JSON.stringify(params)] ?? {} + }, + getScavengeAll: (state) => (params = { params: {}}) => { + if (!( params).query) { + ( params).query=null + } + return state.ScavengeAll[JSON.stringify(params)] ?? {} + }, + getCommit: (state) => (params = { params: {}}) => { + if (!( params).query) { + ( params).query=null + } + return state.Commit[JSON.stringify(params)] ?? {} + }, + getCommitAll: (state) => (params = { params: {}}) => { + if (!( params).query) { + ( params).query=null + } + return state.CommitAll[JSON.stringify(params)] ?? {} + }, + + getTypeStructure: (state) => (type) => { + return state._Structure[type].fields + }, + getRegistry: (state) => { + return state._Registry + } + }, + actions: { + init({ dispatch, rootGetters }) { + console.log('Vuex module: bze.scavenge initialized!') + if (rootGetters['common/env/client']) { + rootGetters['common/env/client'].on('newblock', () => { + dispatch('StoreUpdate') + }) + } + }, + resetState({ commit }) { + commit('RESET_STATE') + }, + unsubscribe({ commit }, subscription) { + commit('UNSUBSCRIBE', subscription) + }, + async StoreUpdate({ state, dispatch }) { + state._Subscriptions.forEach(async (subscription) => { + try { + const sub=JSON.parse(subscription) + await dispatch(sub.action, sub.payload) + }catch(e) { + throw new Error('Subscriptions: ' + e.message) + } + }) + }, + + + + + + + async QueryScavenge({ commit, rootGetters, getters }, { options: { subscribe, all} = { subscribe:false, all:false}, params, query=null }) { + try { + const key = params ?? {}; + const client = initClient(rootGetters); + let value= (await client.BzeScavenge.query.queryScavenge( key.index)).data + + + commit('QUERY', { query: 'Scavenge', key: { params: {...key}, query}, value }) + if (subscribe) commit('SUBSCRIBE', { action: 'QueryScavenge', payload: { options: { all }, params: {...key},query }}) + return getters['getScavenge']( { params: {...key}, query}) ?? {} + } catch (e) { + throw new Error('QueryClient:QueryScavenge API Node Unavailable. Could not perform query: ' + e.message) + + } + }, + + + + + + + + async QueryScavengeAll({ commit, rootGetters, getters }, { options: { subscribe, all} = { subscribe:false, all:false}, params, query=null }) { + try { + const key = params ?? {}; + const client = initClient(rootGetters); + let value= (await client.BzeScavenge.query.queryScavengeAll(query ?? undefined)).data + + + while (all && ( value).pagination && ( value).pagination.next_key!=null) { + let next_values=(await client.BzeScavenge.query.queryScavengeAll({...query ?? {}, 'pagination.key':( value).pagination.next_key} as any)).data + value = mergeResults(value, next_values); + } + commit('QUERY', { query: 'ScavengeAll', key: { params: {...key}, query}, value }) + if (subscribe) commit('SUBSCRIBE', { action: 'QueryScavengeAll', payload: { options: { all }, params: {...key},query }}) + return getters['getScavengeAll']( { params: {...key}, query}) ?? {} + } catch (e) { + throw new Error('QueryClient:QueryScavengeAll API Node Unavailable. Could not perform query: ' + e.message) + + } + }, + + + + + + + + async QueryCommit({ commit, rootGetters, getters }, { options: { subscribe, all} = { subscribe:false, all:false}, params, query=null }) { + try { + const key = params ?? {}; + const client = initClient(rootGetters); + let value= (await client.BzeScavenge.query.queryCommit( key.index)).data + + + commit('QUERY', { query: 'Commit', key: { params: {...key}, query}, value }) + if (subscribe) commit('SUBSCRIBE', { action: 'QueryCommit', payload: { options: { all }, params: {...key},query }}) + return getters['getCommit']( { params: {...key}, query}) ?? {} + } catch (e) { + throw new Error('QueryClient:QueryCommit API Node Unavailable. Could not perform query: ' + e.message) + + } + }, + + + + + + + + async QueryCommitAll({ commit, rootGetters, getters }, { options: { subscribe, all} = { subscribe:false, all:false}, params, query=null }) { + try { + const key = params ?? {}; + const client = initClient(rootGetters); + let value= (await client.BzeScavenge.query.queryCommitAll(query ?? undefined)).data + + + while (all && ( value).pagination && ( value).pagination.next_key!=null) { + let next_values=(await client.BzeScavenge.query.queryCommitAll({...query ?? {}, 'pagination.key':( value).pagination.next_key} as any)).data + value = mergeResults(value, next_values); + } + commit('QUERY', { query: 'CommitAll', key: { params: {...key}, query}, value }) + if (subscribe) commit('SUBSCRIBE', { action: 'QueryCommitAll', payload: { options: { all }, params: {...key},query }}) + return getters['getCommitAll']( { params: {...key}, query}) ?? {} + } catch (e) { + throw new Error('QueryClient:QueryCommitAll API Node Unavailable. Could not perform query: ' + e.message) + + } + }, + + + async sendMsgSubmitScavenge({ rootGetters }, { value, fee = [], memo = '' }) { + try { + const client=await initClient(rootGetters) + const result = await client.BzeScavenge.tx.sendMsgSubmitScavenge({ value, fee: {amount: fee, gas: "200000"}, memo }) + return result + } catch (e) { + if (e == MissingWalletError) { + throw new Error('TxClient:MsgSubmitScavenge:Init Could not initialize signing client. Wallet is required.') + }else{ + throw new Error('TxClient:MsgSubmitScavenge:Send Could not broadcast Tx: '+ e.message) + } + } + }, + async sendMsgRevealSolution({ rootGetters }, { value, fee = [], memo = '' }) { + try { + const client=await initClient(rootGetters) + const result = await client.BzeScavenge.tx.sendMsgRevealSolution({ value, fee: {amount: fee, gas: "200000"}, memo }) + return result + } catch (e) { + if (e == MissingWalletError) { + throw new Error('TxClient:MsgRevealSolution:Init Could not initialize signing client. Wallet is required.') + }else{ + throw new Error('TxClient:MsgRevealSolution:Send Could not broadcast Tx: '+ e.message) + } + } + }, + async sendMsgCommitSolution({ rootGetters }, { value, fee = [], memo = '' }) { + try { + const client=await initClient(rootGetters) + const result = await client.BzeScavenge.tx.sendMsgCommitSolution({ value, fee: {amount: fee, gas: "200000"}, memo }) + return result + } catch (e) { + if (e == MissingWalletError) { + throw new Error('TxClient:MsgCommitSolution:Init Could not initialize signing client. Wallet is required.') + }else{ + throw new Error('TxClient:MsgCommitSolution:Send Could not broadcast Tx: '+ e.message) + } + } + }, + + async MsgSubmitScavenge({ rootGetters }, { value }) { + try { + const client=initClient(rootGetters) + const msg = await client.BzeScavenge.tx.msgSubmitScavenge({value}) + return msg + } catch (e) { + if (e == MissingWalletError) { + throw new Error('TxClient:MsgSubmitScavenge:Init Could not initialize signing client. Wallet is required.') + } else{ + throw new Error('TxClient:MsgSubmitScavenge:Create Could not create message: ' + e.message) + } + } + }, + async MsgRevealSolution({ rootGetters }, { value }) { + try { + const client=initClient(rootGetters) + const msg = await client.BzeScavenge.tx.msgRevealSolution({value}) + return msg + } catch (e) { + if (e == MissingWalletError) { + throw new Error('TxClient:MsgRevealSolution:Init Could not initialize signing client. Wallet is required.') + } else{ + throw new Error('TxClient:MsgRevealSolution:Create Could not create message: ' + e.message) + } + } + }, + async MsgCommitSolution({ rootGetters }, { value }) { + try { + const client=initClient(rootGetters) + const msg = await client.BzeScavenge.tx.msgCommitSolution({value}) + return msg + } catch (e) { + if (e == MissingWalletError) { + throw new Error('TxClient:MsgCommitSolution:Init Could not initialize signing client. Wallet is required.') + } else{ + throw new Error('TxClient:MsgCommitSolution:Create Could not create message: ' + e.message) + } + } + }, + + } +} diff --git a/vue/src/store/generated/bze.tokenfactory.v1/index.ts b/vue/src/store/generated/bze.tokenfactory.v1/index.ts new file mode 100755 index 00000000..6ca4a9d5 --- /dev/null +++ b/vue/src/store/generated/bze.tokenfactory.v1/index.ts @@ -0,0 +1,301 @@ +import { Client, registry, MissingWalletError } from 'bze-alphateam-bze-client-ts' + +import { DenomAuthority } from "bze-alphateam-bze-client-ts/bze.tokenfactory.v1/types" +import { GenesisDenom } from "bze-alphateam-bze-client-ts/bze.tokenfactory.v1/types" +import { Params } from "bze-alphateam-bze-client-ts/bze.tokenfactory.v1/types" + + +export { DenomAuthority, GenesisDenom, Params }; + +function initClient(vuexGetters) { + return new Client(vuexGetters['common/env/getEnv'], vuexGetters['common/wallet/signer']) +} + +function mergeResults(value, next_values) { + for (let prop of Object.keys(next_values)) { + if (Array.isArray(next_values[prop])) { + value[prop]=[...value[prop], ...next_values[prop]] + }else{ + value[prop]=next_values[prop] + } + } + return value +} + +type Field = { + name: string; + type: unknown; +} +function getStructure(template) { + let structure: {fields: Field[]} = { fields: [] } + for (const [key, value] of Object.entries(template)) { + let field = { name: key, type: typeof value } + structure.fields.push(field) + } + return structure +} +const getDefaultState = () => { + return { + Params: {}, + DenomAuthority: {}, + + _Structure: { + DenomAuthority: getStructure(DenomAuthority.fromPartial({})), + GenesisDenom: getStructure(GenesisDenom.fromPartial({})), + Params: getStructure(Params.fromPartial({})), + + }, + _Registry: registry, + _Subscriptions: new Set(), + } +} + +// initial state +const state = getDefaultState() + +export default { + namespaced: true, + state, + mutations: { + RESET_STATE(state) { + Object.assign(state, getDefaultState()) + }, + QUERY(state, { query, key, value }) { + state[query][JSON.stringify(key)] = value + }, + SUBSCRIBE(state, subscription) { + state._Subscriptions.add(JSON.stringify(subscription)) + }, + UNSUBSCRIBE(state, subscription) { + state._Subscriptions.delete(JSON.stringify(subscription)) + } + }, + getters: { + getParams: (state) => (params = { params: {}}) => { + if (!( params).query) { + ( params).query=null + } + return state.Params[JSON.stringify(params)] ?? {} + }, + getDenomAuthority: (state) => (params = { params: {}}) => { + if (!( params).query) { + ( params).query=null + } + return state.DenomAuthority[JSON.stringify(params)] ?? {} + }, + + getTypeStructure: (state) => (type) => { + return state._Structure[type].fields + }, + getRegistry: (state) => { + return state._Registry + } + }, + actions: { + init({ dispatch, rootGetters }) { + console.log('Vuex module: bze.tokenfactory.v1 initialized!') + if (rootGetters['common/env/client']) { + rootGetters['common/env/client'].on('newblock', () => { + dispatch('StoreUpdate') + }) + } + }, + resetState({ commit }) { + commit('RESET_STATE') + }, + unsubscribe({ commit }, subscription) { + commit('UNSUBSCRIBE', subscription) + }, + async StoreUpdate({ state, dispatch }) { + state._Subscriptions.forEach(async (subscription) => { + try { + const sub=JSON.parse(subscription) + await dispatch(sub.action, sub.payload) + }catch(e) { + throw new Error('Subscriptions: ' + e.message) + } + }) + }, + + + + + + + async QueryParams({ commit, rootGetters, getters }, { options: { subscribe, all} = { subscribe:false, all:false}, params, query=null }) { + try { + const key = params ?? {}; + const client = initClient(rootGetters); + let value= (await client.BzeTokenfactoryV1.query.queryParams()).data + + + commit('QUERY', { query: 'Params', key: { params: {...key}, query}, value }) + if (subscribe) commit('SUBSCRIBE', { action: 'QueryParams', payload: { options: { all }, params: {...key},query }}) + return getters['getParams']( { params: {...key}, query}) ?? {} + } catch (e) { + throw new Error('QueryClient:QueryParams API Node Unavailable. Could not perform query: ' + e.message) + + } + }, + + + + + + + + async QueryDenomAuthority({ commit, rootGetters, getters }, { options: { subscribe, all} = { subscribe:false, all:false}, params, query=null }) { + try { + const key = params ?? {}; + const client = initClient(rootGetters); + let value= (await client.BzeTokenfactoryV1.query.queryDenomAuthority(query ?? undefined)).data + + + while (all && ( value).pagination && ( value).pagination.next_key!=null) { + let next_values=(await client.BzeTokenfactoryV1.query.queryDenomAuthority({...query ?? {}, 'pagination.key':( value).pagination.next_key} as any)).data + value = mergeResults(value, next_values); + } + commit('QUERY', { query: 'DenomAuthority', key: { params: {...key}, query}, value }) + if (subscribe) commit('SUBSCRIBE', { action: 'QueryDenomAuthority', payload: { options: { all }, params: {...key},query }}) + return getters['getDenomAuthority']( { params: {...key}, query}) ?? {} + } catch (e) { + throw new Error('QueryClient:QueryDenomAuthority API Node Unavailable. Could not perform query: ' + e.message) + + } + }, + + + async sendMsgMint({ rootGetters }, { value, fee = [], memo = '' }) { + try { + const client=await initClient(rootGetters) + const result = await client.BzeTokenfactoryV1.tx.sendMsgMint({ value, fee: {amount: fee, gas: "200000"}, memo }) + return result + } catch (e) { + if (e == MissingWalletError) { + throw new Error('TxClient:MsgMint:Init Could not initialize signing client. Wallet is required.') + }else{ + throw new Error('TxClient:MsgMint:Send Could not broadcast Tx: '+ e.message) + } + } + }, + async sendMsgBurn({ rootGetters }, { value, fee = [], memo = '' }) { + try { + const client=await initClient(rootGetters) + const result = await client.BzeTokenfactoryV1.tx.sendMsgBurn({ value, fee: {amount: fee, gas: "200000"}, memo }) + return result + } catch (e) { + if (e == MissingWalletError) { + throw new Error('TxClient:MsgBurn:Init Could not initialize signing client. Wallet is required.') + }else{ + throw new Error('TxClient:MsgBurn:Send Could not broadcast Tx: '+ e.message) + } + } + }, + async sendMsgSetDenomMetadata({ rootGetters }, { value, fee = [], memo = '' }) { + try { + const client=await initClient(rootGetters) + const result = await client.BzeTokenfactoryV1.tx.sendMsgSetDenomMetadata({ value, fee: {amount: fee, gas: "200000"}, memo }) + return result + } catch (e) { + if (e == MissingWalletError) { + throw new Error('TxClient:MsgSetDenomMetadata:Init Could not initialize signing client. Wallet is required.') + }else{ + throw new Error('TxClient:MsgSetDenomMetadata:Send Could not broadcast Tx: '+ e.message) + } + } + }, + async sendMsgCreateDenom({ rootGetters }, { value, fee = [], memo = '' }) { + try { + const client=await initClient(rootGetters) + const result = await client.BzeTokenfactoryV1.tx.sendMsgCreateDenom({ value, fee: {amount: fee, gas: "200000"}, memo }) + return result + } catch (e) { + if (e == MissingWalletError) { + throw new Error('TxClient:MsgCreateDenom:Init Could not initialize signing client. Wallet is required.') + }else{ + throw new Error('TxClient:MsgCreateDenom:Send Could not broadcast Tx: '+ e.message) + } + } + }, + async sendMsgChangeAdmin({ rootGetters }, { value, fee = [], memo = '' }) { + try { + const client=await initClient(rootGetters) + const result = await client.BzeTokenfactoryV1.tx.sendMsgChangeAdmin({ value, fee: {amount: fee, gas: "200000"}, memo }) + return result + } catch (e) { + if (e == MissingWalletError) { + throw new Error('TxClient:MsgChangeAdmin:Init Could not initialize signing client. Wallet is required.') + }else{ + throw new Error('TxClient:MsgChangeAdmin:Send Could not broadcast Tx: '+ e.message) + } + } + }, + + async MsgMint({ rootGetters }, { value }) { + try { + const client=initClient(rootGetters) + const msg = await client.BzeTokenfactoryV1.tx.msgMint({value}) + return msg + } catch (e) { + if (e == MissingWalletError) { + throw new Error('TxClient:MsgMint:Init Could not initialize signing client. Wallet is required.') + } else{ + throw new Error('TxClient:MsgMint:Create Could not create message: ' + e.message) + } + } + }, + async MsgBurn({ rootGetters }, { value }) { + try { + const client=initClient(rootGetters) + const msg = await client.BzeTokenfactoryV1.tx.msgBurn({value}) + return msg + } catch (e) { + if (e == MissingWalletError) { + throw new Error('TxClient:MsgBurn:Init Could not initialize signing client. Wallet is required.') + } else{ + throw new Error('TxClient:MsgBurn:Create Could not create message: ' + e.message) + } + } + }, + async MsgSetDenomMetadata({ rootGetters }, { value }) { + try { + const client=initClient(rootGetters) + const msg = await client.BzeTokenfactoryV1.tx.msgSetDenomMetadata({value}) + return msg + } catch (e) { + if (e == MissingWalletError) { + throw new Error('TxClient:MsgSetDenomMetadata:Init Could not initialize signing client. Wallet is required.') + } else{ + throw new Error('TxClient:MsgSetDenomMetadata:Create Could not create message: ' + e.message) + } + } + }, + async MsgCreateDenom({ rootGetters }, { value }) { + try { + const client=initClient(rootGetters) + const msg = await client.BzeTokenfactoryV1.tx.msgCreateDenom({value}) + return msg + } catch (e) { + if (e == MissingWalletError) { + throw new Error('TxClient:MsgCreateDenom:Init Could not initialize signing client. Wallet is required.') + } else{ + throw new Error('TxClient:MsgCreateDenom:Create Could not create message: ' + e.message) + } + } + }, + async MsgChangeAdmin({ rootGetters }, { value }) { + try { + const client=initClient(rootGetters) + const msg = await client.BzeTokenfactoryV1.tx.msgChangeAdmin({value}) + return msg + } catch (e) { + if (e == MissingWalletError) { + throw new Error('TxClient:MsgChangeAdmin:Init Could not initialize signing client. Wallet is required.') + } else{ + throw new Error('TxClient:MsgChangeAdmin:Create Could not create message: ' + e.message) + } + } + }, + + } +} diff --git a/vue/src/store/generated/bze.tradebin.v1/index.ts b/vue/src/store/generated/bze.tradebin.v1/index.ts new file mode 100755 index 00000000..ed7084fe --- /dev/null +++ b/vue/src/store/generated/bze.tradebin.v1/index.ts @@ -0,0 +1,467 @@ +import { Client, registry, MissingWalletError } from 'bze-alphateam-bze-client-ts' + +import { OrderCreateMessageEvent } from "bze-alphateam-bze-client-ts/bze.tradebin.v1/types" +import { OrderCancelMessageEvent } from "bze-alphateam-bze-client-ts/bze.tradebin.v1/types" +import { MarketCreatedEvent } from "bze-alphateam-bze-client-ts/bze.tradebin.v1/types" +import { OrderExecutedEvent } from "bze-alphateam-bze-client-ts/bze.tradebin.v1/types" +import { OrderCanceledEvent } from "bze-alphateam-bze-client-ts/bze.tradebin.v1/types" +import { OrderSavedEvent } from "bze-alphateam-bze-client-ts/bze.tradebin.v1/types" +import { Market } from "bze-alphateam-bze-client-ts/bze.tradebin.v1/types" +import { Order } from "bze-alphateam-bze-client-ts/bze.tradebin.v1/types" +import { OrderReference } from "bze-alphateam-bze-client-ts/bze.tradebin.v1/types" +import { AggregatedOrder } from "bze-alphateam-bze-client-ts/bze.tradebin.v1/types" +import { HistoryOrder } from "bze-alphateam-bze-client-ts/bze.tradebin.v1/types" +import { Params } from "bze-alphateam-bze-client-ts/bze.tradebin.v1/types" +import { QueueMessage } from "bze-alphateam-bze-client-ts/bze.tradebin.v1/types" + + +export { OrderCreateMessageEvent, OrderCancelMessageEvent, MarketCreatedEvent, OrderExecutedEvent, OrderCanceledEvent, OrderSavedEvent, Market, Order, OrderReference, AggregatedOrder, HistoryOrder, Params, QueueMessage }; + +function initClient(vuexGetters) { + return new Client(vuexGetters['common/env/getEnv'], vuexGetters['common/wallet/signer']) +} + +function mergeResults(value, next_values) { + for (let prop of Object.keys(next_values)) { + if (Array.isArray(next_values[prop])) { + value[prop]=[...value[prop], ...next_values[prop]] + }else{ + value[prop]=next_values[prop] + } + } + return value +} + +type Field = { + name: string; + type: unknown; +} +function getStructure(template) { + let structure: {fields: Field[]} = { fields: [] } + for (const [key, value] of Object.entries(template)) { + let field = { name: key, type: typeof value } + structure.fields.push(field) + } + return structure +} +const getDefaultState = () => { + return { + Params: {}, + Market: {}, + MarketAll: {}, + AssetMarkets: {}, + UserMarketOrders: {}, + MarketAggregatedOrders: {}, + MarketHistory: {}, + MarketOrder: {}, + + _Structure: { + OrderCreateMessageEvent: getStructure(OrderCreateMessageEvent.fromPartial({})), + OrderCancelMessageEvent: getStructure(OrderCancelMessageEvent.fromPartial({})), + MarketCreatedEvent: getStructure(MarketCreatedEvent.fromPartial({})), + OrderExecutedEvent: getStructure(OrderExecutedEvent.fromPartial({})), + OrderCanceledEvent: getStructure(OrderCanceledEvent.fromPartial({})), + OrderSavedEvent: getStructure(OrderSavedEvent.fromPartial({})), + Market: getStructure(Market.fromPartial({})), + Order: getStructure(Order.fromPartial({})), + OrderReference: getStructure(OrderReference.fromPartial({})), + AggregatedOrder: getStructure(AggregatedOrder.fromPartial({})), + HistoryOrder: getStructure(HistoryOrder.fromPartial({})), + Params: getStructure(Params.fromPartial({})), + QueueMessage: getStructure(QueueMessage.fromPartial({})), + + }, + _Registry: registry, + _Subscriptions: new Set(), + } +} + +// initial state +const state = getDefaultState() + +export default { + namespaced: true, + state, + mutations: { + RESET_STATE(state) { + Object.assign(state, getDefaultState()) + }, + QUERY(state, { query, key, value }) { + state[query][JSON.stringify(key)] = value + }, + SUBSCRIBE(state, subscription) { + state._Subscriptions.add(JSON.stringify(subscription)) + }, + UNSUBSCRIBE(state, subscription) { + state._Subscriptions.delete(JSON.stringify(subscription)) + } + }, + getters: { + getParams: (state) => (params = { params: {}}) => { + if (!( params).query) { + ( params).query=null + } + return state.Params[JSON.stringify(params)] ?? {} + }, + getMarket: (state) => (params = { params: {}}) => { + if (!( params).query) { + ( params).query=null + } + return state.Market[JSON.stringify(params)] ?? {} + }, + getMarketAll: (state) => (params = { params: {}}) => { + if (!( params).query) { + ( params).query=null + } + return state.MarketAll[JSON.stringify(params)] ?? {} + }, + getAssetMarkets: (state) => (params = { params: {}}) => { + if (!( params).query) { + ( params).query=null + } + return state.AssetMarkets[JSON.stringify(params)] ?? {} + }, + getUserMarketOrders: (state) => (params = { params: {}}) => { + if (!( params).query) { + ( params).query=null + } + return state.UserMarketOrders[JSON.stringify(params)] ?? {} + }, + getMarketAggregatedOrders: (state) => (params = { params: {}}) => { + if (!( params).query) { + ( params).query=null + } + return state.MarketAggregatedOrders[JSON.stringify(params)] ?? {} + }, + getMarketHistory: (state) => (params = { params: {}}) => { + if (!( params).query) { + ( params).query=null + } + return state.MarketHistory[JSON.stringify(params)] ?? {} + }, + getMarketOrder: (state) => (params = { params: {}}) => { + if (!( params).query) { + ( params).query=null + } + return state.MarketOrder[JSON.stringify(params)] ?? {} + }, + + getTypeStructure: (state) => (type) => { + return state._Structure[type].fields + }, + getRegistry: (state) => { + return state._Registry + } + }, + actions: { + init({ dispatch, rootGetters }) { + console.log('Vuex module: bze.tradebin.v1 initialized!') + if (rootGetters['common/env/client']) { + rootGetters['common/env/client'].on('newblock', () => { + dispatch('StoreUpdate') + }) + } + }, + resetState({ commit }) { + commit('RESET_STATE') + }, + unsubscribe({ commit }, subscription) { + commit('UNSUBSCRIBE', subscription) + }, + async StoreUpdate({ state, dispatch }) { + state._Subscriptions.forEach(async (subscription) => { + try { + const sub=JSON.parse(subscription) + await dispatch(sub.action, sub.payload) + }catch(e) { + throw new Error('Subscriptions: ' + e.message) + } + }) + }, + + + + + + + async QueryParams({ commit, rootGetters, getters }, { options: { subscribe, all} = { subscribe:false, all:false}, params, query=null }) { + try { + const key = params ?? {}; + const client = initClient(rootGetters); + let value= (await client.BzeTradebinV1.query.queryParams()).data + + + commit('QUERY', { query: 'Params', key: { params: {...key}, query}, value }) + if (subscribe) commit('SUBSCRIBE', { action: 'QueryParams', payload: { options: { all }, params: {...key},query }}) + return getters['getParams']( { params: {...key}, query}) ?? {} + } catch (e) { + throw new Error('QueryClient:QueryParams API Node Unavailable. Could not perform query: ' + e.message) + + } + }, + + + + + + + + async QueryMarket({ commit, rootGetters, getters }, { options: { subscribe, all} = { subscribe:false, all:false}, params, query=null }) { + try { + const key = params ?? {}; + const client = initClient(rootGetters); + let value= (await client.BzeTradebinV1.query.queryMarket(query ?? undefined)).data + + + while (all && ( value).pagination && ( value).pagination.next_key!=null) { + let next_values=(await client.BzeTradebinV1.query.queryMarket({...query ?? {}, 'pagination.key':( value).pagination.next_key} as any)).data + value = mergeResults(value, next_values); + } + commit('QUERY', { query: 'Market', key: { params: {...key}, query}, value }) + if (subscribe) commit('SUBSCRIBE', { action: 'QueryMarket', payload: { options: { all }, params: {...key},query }}) + return getters['getMarket']( { params: {...key}, query}) ?? {} + } catch (e) { + throw new Error('QueryClient:QueryMarket API Node Unavailable. Could not perform query: ' + e.message) + + } + }, + + + + + + + + async QueryMarketAll({ commit, rootGetters, getters }, { options: { subscribe, all} = { subscribe:false, all:false}, params, query=null }) { + try { + const key = params ?? {}; + const client = initClient(rootGetters); + let value= (await client.BzeTradebinV1.query.queryMarketAll(query ?? undefined)).data + + + while (all && ( value).pagination && ( value).pagination.next_key!=null) { + let next_values=(await client.BzeTradebinV1.query.queryMarketAll({...query ?? {}, 'pagination.key':( value).pagination.next_key} as any)).data + value = mergeResults(value, next_values); + } + commit('QUERY', { query: 'MarketAll', key: { params: {...key}, query}, value }) + if (subscribe) commit('SUBSCRIBE', { action: 'QueryMarketAll', payload: { options: { all }, params: {...key},query }}) + return getters['getMarketAll']( { params: {...key}, query}) ?? {} + } catch (e) { + throw new Error('QueryClient:QueryMarketAll API Node Unavailable. Could not perform query: ' + e.message) + + } + }, + + + + + + + + async QueryAssetMarkets({ commit, rootGetters, getters }, { options: { subscribe, all} = { subscribe:false, all:false}, params, query=null }) { + try { + const key = params ?? {}; + const client = initClient(rootGetters); + let value= (await client.BzeTradebinV1.query.queryAssetMarkets(query ?? undefined)).data + + + while (all && ( value).pagination && ( value).pagination.next_key!=null) { + let next_values=(await client.BzeTradebinV1.query.queryAssetMarkets({...query ?? {}, 'pagination.key':( value).pagination.next_key} as any)).data + value = mergeResults(value, next_values); + } + commit('QUERY', { query: 'AssetMarkets', key: { params: {...key}, query}, value }) + if (subscribe) commit('SUBSCRIBE', { action: 'QueryAssetMarkets', payload: { options: { all }, params: {...key},query }}) + return getters['getAssetMarkets']( { params: {...key}, query}) ?? {} + } catch (e) { + throw new Error('QueryClient:QueryAssetMarkets API Node Unavailable. Could not perform query: ' + e.message) + + } + }, + + + + + + + + async QueryUserMarketOrders({ commit, rootGetters, getters }, { options: { subscribe, all} = { subscribe:false, all:false}, params, query=null }) { + try { + const key = params ?? {}; + const client = initClient(rootGetters); + let value= (await client.BzeTradebinV1.query.queryUserMarketOrders( key.address, query ?? undefined)).data + + + while (all && ( value).pagination && ( value).pagination.next_key!=null) { + let next_values=(await client.BzeTradebinV1.query.queryUserMarketOrders( key.address, {...query ?? {}, 'pagination.key':( value).pagination.next_key} as any)).data + value = mergeResults(value, next_values); + } + commit('QUERY', { query: 'UserMarketOrders', key: { params: {...key}, query}, value }) + if (subscribe) commit('SUBSCRIBE', { action: 'QueryUserMarketOrders', payload: { options: { all }, params: {...key},query }}) + return getters['getUserMarketOrders']( { params: {...key}, query}) ?? {} + } catch (e) { + throw new Error('QueryClient:QueryUserMarketOrders API Node Unavailable. Could not perform query: ' + e.message) + + } + }, + + + + + + + + async QueryMarketAggregatedOrders({ commit, rootGetters, getters }, { options: { subscribe, all} = { subscribe:false, all:false}, params, query=null }) { + try { + const key = params ?? {}; + const client = initClient(rootGetters); + let value= (await client.BzeTradebinV1.query.queryMarketAggregatedOrders(query ?? undefined)).data + + + while (all && ( value).pagination && ( value).pagination.next_key!=null) { + let next_values=(await client.BzeTradebinV1.query.queryMarketAggregatedOrders({...query ?? {}, 'pagination.key':( value).pagination.next_key} as any)).data + value = mergeResults(value, next_values); + } + commit('QUERY', { query: 'MarketAggregatedOrders', key: { params: {...key}, query}, value }) + if (subscribe) commit('SUBSCRIBE', { action: 'QueryMarketAggregatedOrders', payload: { options: { all }, params: {...key},query }}) + return getters['getMarketAggregatedOrders']( { params: {...key}, query}) ?? {} + } catch (e) { + throw new Error('QueryClient:QueryMarketAggregatedOrders API Node Unavailable. Could not perform query: ' + e.message) + + } + }, + + + + + + + + async QueryMarketHistory({ commit, rootGetters, getters }, { options: { subscribe, all} = { subscribe:false, all:false}, params, query=null }) { + try { + const key = params ?? {}; + const client = initClient(rootGetters); + let value= (await client.BzeTradebinV1.query.queryMarketHistory(query ?? undefined)).data + + + while (all && ( value).pagination && ( value).pagination.next_key!=null) { + let next_values=(await client.BzeTradebinV1.query.queryMarketHistory({...query ?? {}, 'pagination.key':( value).pagination.next_key} as any)).data + value = mergeResults(value, next_values); + } + commit('QUERY', { query: 'MarketHistory', key: { params: {...key}, query}, value }) + if (subscribe) commit('SUBSCRIBE', { action: 'QueryMarketHistory', payload: { options: { all }, params: {...key},query }}) + return getters['getMarketHistory']( { params: {...key}, query}) ?? {} + } catch (e) { + throw new Error('QueryClient:QueryMarketHistory API Node Unavailable. Could not perform query: ' + e.message) + + } + }, + + + + + + + + async QueryMarketOrder({ commit, rootGetters, getters }, { options: { subscribe, all} = { subscribe:false, all:false}, params, query=null }) { + try { + const key = params ?? {}; + const client = initClient(rootGetters); + let value= (await client.BzeTradebinV1.query.queryMarketOrder(query ?? undefined)).data + + + while (all && ( value).pagination && ( value).pagination.next_key!=null) { + let next_values=(await client.BzeTradebinV1.query.queryMarketOrder({...query ?? {}, 'pagination.key':( value).pagination.next_key} as any)).data + value = mergeResults(value, next_values); + } + commit('QUERY', { query: 'MarketOrder', key: { params: {...key}, query}, value }) + if (subscribe) commit('SUBSCRIBE', { action: 'QueryMarketOrder', payload: { options: { all }, params: {...key},query }}) + return getters['getMarketOrder']( { params: {...key}, query}) ?? {} + } catch (e) { + throw new Error('QueryClient:QueryMarketOrder API Node Unavailable. Could not perform query: ' + e.message) + + } + }, + + + async sendMsgCreateMarket({ rootGetters }, { value, fee = [], memo = '' }) { + try { + const client=await initClient(rootGetters) + const result = await client.BzeTradebinV1.tx.sendMsgCreateMarket({ value, fee: {amount: fee, gas: "200000"}, memo }) + return result + } catch (e) { + if (e == MissingWalletError) { + throw new Error('TxClient:MsgCreateMarket:Init Could not initialize signing client. Wallet is required.') + }else{ + throw new Error('TxClient:MsgCreateMarket:Send Could not broadcast Tx: '+ e.message) + } + } + }, + async sendMsgCreateOrder({ rootGetters }, { value, fee = [], memo = '' }) { + try { + const client=await initClient(rootGetters) + const result = await client.BzeTradebinV1.tx.sendMsgCreateOrder({ value, fee: {amount: fee, gas: "200000"}, memo }) + return result + } catch (e) { + if (e == MissingWalletError) { + throw new Error('TxClient:MsgCreateOrder:Init Could not initialize signing client. Wallet is required.') + }else{ + throw new Error('TxClient:MsgCreateOrder:Send Could not broadcast Tx: '+ e.message) + } + } + }, + async sendMsgCancelOrder({ rootGetters }, { value, fee = [], memo = '' }) { + try { + const client=await initClient(rootGetters) + const result = await client.BzeTradebinV1.tx.sendMsgCancelOrder({ value, fee: {amount: fee, gas: "200000"}, memo }) + return result + } catch (e) { + if (e == MissingWalletError) { + throw new Error('TxClient:MsgCancelOrder:Init Could not initialize signing client. Wallet is required.') + }else{ + throw new Error('TxClient:MsgCancelOrder:Send Could not broadcast Tx: '+ e.message) + } + } + }, + + async MsgCreateMarket({ rootGetters }, { value }) { + try { + const client=initClient(rootGetters) + const msg = await client.BzeTradebinV1.tx.msgCreateMarket({value}) + return msg + } catch (e) { + if (e == MissingWalletError) { + throw new Error('TxClient:MsgCreateMarket:Init Could not initialize signing client. Wallet is required.') + } else{ + throw new Error('TxClient:MsgCreateMarket:Create Could not create message: ' + e.message) + } + } + }, + async MsgCreateOrder({ rootGetters }, { value }) { + try { + const client=initClient(rootGetters) + const msg = await client.BzeTradebinV1.tx.msgCreateOrder({value}) + return msg + } catch (e) { + if (e == MissingWalletError) { + throw new Error('TxClient:MsgCreateOrder:Init Could not initialize signing client. Wallet is required.') + } else{ + throw new Error('TxClient:MsgCreateOrder:Create Could not create message: ' + e.message) + } + } + }, + async MsgCancelOrder({ rootGetters }, { value }) { + try { + const client=initClient(rootGetters) + const msg = await client.BzeTradebinV1.tx.msgCancelOrder({value}) + return msg + } catch (e) { + if (e == MissingWalletError) { + throw new Error('TxClient:MsgCancelOrder:Init Could not initialize signing client. Wallet is required.') + } else{ + throw new Error('TxClient:MsgCancelOrder:Create Could not create message: ' + e.message) + } + } + }, + + } +} diff --git a/vue/src/store/generated/bze.v1.rewards/index.ts b/vue/src/store/generated/bze.v1.rewards/index.ts new file mode 100755 index 00000000..0cdecbbe --- /dev/null +++ b/vue/src/store/generated/bze.v1.rewards/index.ts @@ -0,0 +1,498 @@ +import { Client, registry, MissingWalletError } from 'bze-alphateam-bze-client-ts' + +import { Params } from "bze-alphateam-bze-client-ts/bze.v1.rewards/types" +import { StakingReward } from "bze-alphateam-bze-client-ts/bze.v1.rewards/types" +import { StakingRewardParticipant } from "bze-alphateam-bze-client-ts/bze.v1.rewards/types" +import { PendingUnlockParticipant } from "bze-alphateam-bze-client-ts/bze.v1.rewards/types" +import { TradingReward } from "bze-alphateam-bze-client-ts/bze.v1.rewards/types" +import { TradingRewardExpiration } from "bze-alphateam-bze-client-ts/bze.v1.rewards/types" +import { TradingRewardLeaderboard } from "bze-alphateam-bze-client-ts/bze.v1.rewards/types" +import { TradingRewardLeaderboardEntry } from "bze-alphateam-bze-client-ts/bze.v1.rewards/types" +import { TradingRewardCandidate } from "bze-alphateam-bze-client-ts/bze.v1.rewards/types" +import { MarketIdTradingRewardId } from "bze-alphateam-bze-client-ts/bze.v1.rewards/types" + + +export { Params, StakingReward, StakingRewardParticipant, PendingUnlockParticipant, TradingReward, TradingRewardExpiration, TradingRewardLeaderboard, TradingRewardLeaderboardEntry, TradingRewardCandidate, MarketIdTradingRewardId }; + +function initClient(vuexGetters) { + return new Client(vuexGetters['common/env/getEnv'], vuexGetters['common/wallet/signer']) +} + +function mergeResults(value, next_values) { + for (let prop of Object.keys(next_values)) { + if (Array.isArray(next_values[prop])) { + value[prop]=[...value[prop], ...next_values[prop]] + }else{ + value[prop]=next_values[prop] + } + } + return value +} + +type Field = { + name: string; + type: unknown; +} +function getStructure(template) { + let structure: {fields: Field[]} = { fields: [] } + for (const [key, value] of Object.entries(template)) { + let field = { name: key, type: typeof value } + structure.fields.push(field) + } + return structure +} +const getDefaultState = () => { + return { + Params: {}, + StakingReward: {}, + StakingRewardAll: {}, + TradingReward: {}, + TradingRewardAll: {}, + StakingRewardParticipant: {}, + StakingRewardParticipantAll: {}, + + _Structure: { + Params: getStructure(Params.fromPartial({})), + StakingReward: getStructure(StakingReward.fromPartial({})), + StakingRewardParticipant: getStructure(StakingRewardParticipant.fromPartial({})), + PendingUnlockParticipant: getStructure(PendingUnlockParticipant.fromPartial({})), + TradingReward: getStructure(TradingReward.fromPartial({})), + TradingRewardExpiration: getStructure(TradingRewardExpiration.fromPartial({})), + TradingRewardLeaderboard: getStructure(TradingRewardLeaderboard.fromPartial({})), + TradingRewardLeaderboardEntry: getStructure(TradingRewardLeaderboardEntry.fromPartial({})), + TradingRewardCandidate: getStructure(TradingRewardCandidate.fromPartial({})), + MarketIdTradingRewardId: getStructure(MarketIdTradingRewardId.fromPartial({})), + + }, + _Registry: registry, + _Subscriptions: new Set(), + } +} + +// initial state +const state = getDefaultState() + +export default { + namespaced: true, + state, + mutations: { + RESET_STATE(state) { + Object.assign(state, getDefaultState()) + }, + QUERY(state, { query, key, value }) { + state[query][JSON.stringify(key)] = value + }, + SUBSCRIBE(state, subscription) { + state._Subscriptions.add(JSON.stringify(subscription)) + }, + UNSUBSCRIBE(state, subscription) { + state._Subscriptions.delete(JSON.stringify(subscription)) + } + }, + getters: { + getParams: (state) => (params = { params: {}}) => { + if (!( params).query) { + ( params).query=null + } + return state.Params[JSON.stringify(params)] ?? {} + }, + getStakingReward: (state) => (params = { params: {}}) => { + if (!( params).query) { + ( params).query=null + } + return state.StakingReward[JSON.stringify(params)] ?? {} + }, + getStakingRewardAll: (state) => (params = { params: {}}) => { + if (!( params).query) { + ( params).query=null + } + return state.StakingRewardAll[JSON.stringify(params)] ?? {} + }, + getTradingReward: (state) => (params = { params: {}}) => { + if (!( params).query) { + ( params).query=null + } + return state.TradingReward[JSON.stringify(params)] ?? {} + }, + getTradingRewardAll: (state) => (params = { params: {}}) => { + if (!( params).query) { + ( params).query=null + } + return state.TradingRewardAll[JSON.stringify(params)] ?? {} + }, + getStakingRewardParticipant: (state) => (params = { params: {}}) => { + if (!( params).query) { + ( params).query=null + } + return state.StakingRewardParticipant[JSON.stringify(params)] ?? {} + }, + getStakingRewardParticipantAll: (state) => (params = { params: {}}) => { + if (!( params).query) { + ( params).query=null + } + return state.StakingRewardParticipantAll[JSON.stringify(params)] ?? {} + }, + + getTypeStructure: (state) => (type) => { + return state._Structure[type].fields + }, + getRegistry: (state) => { + return state._Registry + } + }, + actions: { + init({ dispatch, rootGetters }) { + console.log('Vuex module: bze.v1.rewards initialized!') + if (rootGetters['common/env/client']) { + rootGetters['common/env/client'].on('newblock', () => { + dispatch('StoreUpdate') + }) + } + }, + resetState({ commit }) { + commit('RESET_STATE') + }, + unsubscribe({ commit }, subscription) { + commit('UNSUBSCRIBE', subscription) + }, + async StoreUpdate({ state, dispatch }) { + state._Subscriptions.forEach(async (subscription) => { + try { + const sub=JSON.parse(subscription) + await dispatch(sub.action, sub.payload) + }catch(e) { + throw new Error('Subscriptions: ' + e.message) + } + }) + }, + + + + + + + async QueryParams({ commit, rootGetters, getters }, { options: { subscribe, all} = { subscribe:false, all:false}, params, query=null }) { + try { + const key = params ?? {}; + const client = initClient(rootGetters); + let value= (await client.BzeV1Rewards.query.queryParams()).data + + + commit('QUERY', { query: 'Params', key: { params: {...key}, query}, value }) + if (subscribe) commit('SUBSCRIBE', { action: 'QueryParams', payload: { options: { all }, params: {...key},query }}) + return getters['getParams']( { params: {...key}, query}) ?? {} + } catch (e) { + throw new Error('QueryClient:QueryParams API Node Unavailable. Could not perform query: ' + e.message) + + } + }, + + + + + + + + async QueryStakingReward({ commit, rootGetters, getters }, { options: { subscribe, all} = { subscribe:false, all:false}, params, query=null }) { + try { + const key = params ?? {}; + const client = initClient(rootGetters); + let value= (await client.BzeV1Rewards.query.queryStakingReward( key.reward_id)).data + + + commit('QUERY', { query: 'StakingReward', key: { params: {...key}, query}, value }) + if (subscribe) commit('SUBSCRIBE', { action: 'QueryStakingReward', payload: { options: { all }, params: {...key},query }}) + return getters['getStakingReward']( { params: {...key}, query}) ?? {} + } catch (e) { + throw new Error('QueryClient:QueryStakingReward API Node Unavailable. Could not perform query: ' + e.message) + + } + }, + + + + + + + + async QueryStakingRewardAll({ commit, rootGetters, getters }, { options: { subscribe, all} = { subscribe:false, all:false}, params, query=null }) { + try { + const key = params ?? {}; + const client = initClient(rootGetters); + let value= (await client.BzeV1Rewards.query.queryStakingRewardAll(query ?? undefined)).data + + + while (all && ( value).pagination && ( value).pagination.next_key!=null) { + let next_values=(await client.BzeV1Rewards.query.queryStakingRewardAll({...query ?? {}, 'pagination.key':( value).pagination.next_key} as any)).data + value = mergeResults(value, next_values); + } + commit('QUERY', { query: 'StakingRewardAll', key: { params: {...key}, query}, value }) + if (subscribe) commit('SUBSCRIBE', { action: 'QueryStakingRewardAll', payload: { options: { all }, params: {...key},query }}) + return getters['getStakingRewardAll']( { params: {...key}, query}) ?? {} + } catch (e) { + throw new Error('QueryClient:QueryStakingRewardAll API Node Unavailable. Could not perform query: ' + e.message) + + } + }, + + + + + + + + async QueryTradingReward({ commit, rootGetters, getters }, { options: { subscribe, all} = { subscribe:false, all:false}, params, query=null }) { + try { + const key = params ?? {}; + const client = initClient(rootGetters); + let value= (await client.BzeV1Rewards.query.queryTradingReward( key.reward_id)).data + + + commit('QUERY', { query: 'TradingReward', key: { params: {...key}, query}, value }) + if (subscribe) commit('SUBSCRIBE', { action: 'QueryTradingReward', payload: { options: { all }, params: {...key},query }}) + return getters['getTradingReward']( { params: {...key}, query}) ?? {} + } catch (e) { + throw new Error('QueryClient:QueryTradingReward API Node Unavailable. Could not perform query: ' + e.message) + + } + }, + + + + + + + + async QueryTradingRewardAll({ commit, rootGetters, getters }, { options: { subscribe, all} = { subscribe:false, all:false}, params, query=null }) { + try { + const key = params ?? {}; + const client = initClient(rootGetters); + let value= (await client.BzeV1Rewards.query.queryTradingRewardAll(query ?? undefined)).data + + + while (all && ( value).pagination && ( value).pagination.next_key!=null) { + let next_values=(await client.BzeV1Rewards.query.queryTradingRewardAll({...query ?? {}, 'pagination.key':( value).pagination.next_key} as any)).data + value = mergeResults(value, next_values); + } + commit('QUERY', { query: 'TradingRewardAll', key: { params: {...key}, query}, value }) + if (subscribe) commit('SUBSCRIBE', { action: 'QueryTradingRewardAll', payload: { options: { all }, params: {...key},query }}) + return getters['getTradingRewardAll']( { params: {...key}, query}) ?? {} + } catch (e) { + throw new Error('QueryClient:QueryTradingRewardAll API Node Unavailable. Could not perform query: ' + e.message) + + } + }, + + + + + + + + async QueryStakingRewardParticipant({ commit, rootGetters, getters }, { options: { subscribe, all} = { subscribe:false, all:false}, params, query=null }) { + try { + const key = params ?? {}; + const client = initClient(rootGetters); + let value= (await client.BzeV1Rewards.query.queryStakingRewardParticipant( key.address, query ?? undefined)).data + + + while (all && ( value).pagination && ( value).pagination.next_key!=null) { + let next_values=(await client.BzeV1Rewards.query.queryStakingRewardParticipant( key.address, {...query ?? {}, 'pagination.key':( value).pagination.next_key} as any)).data + value = mergeResults(value, next_values); + } + commit('QUERY', { query: 'StakingRewardParticipant', key: { params: {...key}, query}, value }) + if (subscribe) commit('SUBSCRIBE', { action: 'QueryStakingRewardParticipant', payload: { options: { all }, params: {...key},query }}) + return getters['getStakingRewardParticipant']( { params: {...key}, query}) ?? {} + } catch (e) { + throw new Error('QueryClient:QueryStakingRewardParticipant API Node Unavailable. Could not perform query: ' + e.message) + + } + }, + + + + + + + + async QueryStakingRewardParticipantAll({ commit, rootGetters, getters }, { options: { subscribe, all} = { subscribe:false, all:false}, params, query=null }) { + try { + const key = params ?? {}; + const client = initClient(rootGetters); + let value= (await client.BzeV1Rewards.query.queryStakingRewardParticipantAll(query ?? undefined)).data + + + while (all && ( value).pagination && ( value).pagination.next_key!=null) { + let next_values=(await client.BzeV1Rewards.query.queryStakingRewardParticipantAll({...query ?? {}, 'pagination.key':( value).pagination.next_key} as any)).data + value = mergeResults(value, next_values); + } + commit('QUERY', { query: 'StakingRewardParticipantAll', key: { params: {...key}, query}, value }) + if (subscribe) commit('SUBSCRIBE', { action: 'QueryStakingRewardParticipantAll', payload: { options: { all }, params: {...key},query }}) + return getters['getStakingRewardParticipantAll']( { params: {...key}, query}) ?? {} + } catch (e) { + throw new Error('QueryClient:QueryStakingRewardParticipantAll API Node Unavailable. Could not perform query: ' + e.message) + + } + }, + + + async sendMsgUpdateStakingReward({ rootGetters }, { value, fee = [], memo = '' }) { + try { + const client=await initClient(rootGetters) + const result = await client.BzeV1Rewards.tx.sendMsgUpdateStakingReward({ value, fee: {amount: fee, gas: "200000"}, memo }) + return result + } catch (e) { + if (e == MissingWalletError) { + throw new Error('TxClient:MsgUpdateStakingReward:Init Could not initialize signing client. Wallet is required.') + }else{ + throw new Error('TxClient:MsgUpdateStakingReward:Send Could not broadcast Tx: '+ e.message) + } + } + }, + async sendMsgCreateTradingReward({ rootGetters }, { value, fee = [], memo = '' }) { + try { + const client=await initClient(rootGetters) + const result = await client.BzeV1Rewards.tx.sendMsgCreateTradingReward({ value, fee: {amount: fee, gas: "200000"}, memo }) + return result + } catch (e) { + if (e == MissingWalletError) { + throw new Error('TxClient:MsgCreateTradingReward:Init Could not initialize signing client. Wallet is required.') + }else{ + throw new Error('TxClient:MsgCreateTradingReward:Send Could not broadcast Tx: '+ e.message) + } + } + }, + async sendMsgJoinStaking({ rootGetters }, { value, fee = [], memo = '' }) { + try { + const client=await initClient(rootGetters) + const result = await client.BzeV1Rewards.tx.sendMsgJoinStaking({ value, fee: {amount: fee, gas: "200000"}, memo }) + return result + } catch (e) { + if (e == MissingWalletError) { + throw new Error('TxClient:MsgJoinStaking:Init Could not initialize signing client. Wallet is required.') + }else{ + throw new Error('TxClient:MsgJoinStaking:Send Could not broadcast Tx: '+ e.message) + } + } + }, + async sendMsgExitStaking({ rootGetters }, { value, fee = [], memo = '' }) { + try { + const client=await initClient(rootGetters) + const result = await client.BzeV1Rewards.tx.sendMsgExitStaking({ value, fee: {amount: fee, gas: "200000"}, memo }) + return result + } catch (e) { + if (e == MissingWalletError) { + throw new Error('TxClient:MsgExitStaking:Init Could not initialize signing client. Wallet is required.') + }else{ + throw new Error('TxClient:MsgExitStaking:Send Could not broadcast Tx: '+ e.message) + } + } + }, + async sendMsgCreateStakingReward({ rootGetters }, { value, fee = [], memo = '' }) { + try { + const client=await initClient(rootGetters) + const result = await client.BzeV1Rewards.tx.sendMsgCreateStakingReward({ value, fee: {amount: fee, gas: "200000"}, memo }) + return result + } catch (e) { + if (e == MissingWalletError) { + throw new Error('TxClient:MsgCreateStakingReward:Init Could not initialize signing client. Wallet is required.') + }else{ + throw new Error('TxClient:MsgCreateStakingReward:Send Could not broadcast Tx: '+ e.message) + } + } + }, + async sendMsgClaimStakingRewards({ rootGetters }, { value, fee = [], memo = '' }) { + try { + const client=await initClient(rootGetters) + const result = await client.BzeV1Rewards.tx.sendMsgClaimStakingRewards({ value, fee: {amount: fee, gas: "200000"}, memo }) + return result + } catch (e) { + if (e == MissingWalletError) { + throw new Error('TxClient:MsgClaimStakingRewards:Init Could not initialize signing client. Wallet is required.') + }else{ + throw new Error('TxClient:MsgClaimStakingRewards:Send Could not broadcast Tx: '+ e.message) + } + } + }, + + async MsgUpdateStakingReward({ rootGetters }, { value }) { + try { + const client=initClient(rootGetters) + const msg = await client.BzeV1Rewards.tx.msgUpdateStakingReward({value}) + return msg + } catch (e) { + if (e == MissingWalletError) { + throw new Error('TxClient:MsgUpdateStakingReward:Init Could not initialize signing client. Wallet is required.') + } else{ + throw new Error('TxClient:MsgUpdateStakingReward:Create Could not create message: ' + e.message) + } + } + }, + async MsgCreateTradingReward({ rootGetters }, { value }) { + try { + const client=initClient(rootGetters) + const msg = await client.BzeV1Rewards.tx.msgCreateTradingReward({value}) + return msg + } catch (e) { + if (e == MissingWalletError) { + throw new Error('TxClient:MsgCreateTradingReward:Init Could not initialize signing client. Wallet is required.') + } else{ + throw new Error('TxClient:MsgCreateTradingReward:Create Could not create message: ' + e.message) + } + } + }, + async MsgJoinStaking({ rootGetters }, { value }) { + try { + const client=initClient(rootGetters) + const msg = await client.BzeV1Rewards.tx.msgJoinStaking({value}) + return msg + } catch (e) { + if (e == MissingWalletError) { + throw new Error('TxClient:MsgJoinStaking:Init Could not initialize signing client. Wallet is required.') + } else{ + throw new Error('TxClient:MsgJoinStaking:Create Could not create message: ' + e.message) + } + } + }, + async MsgExitStaking({ rootGetters }, { value }) { + try { + const client=initClient(rootGetters) + const msg = await client.BzeV1Rewards.tx.msgExitStaking({value}) + return msg + } catch (e) { + if (e == MissingWalletError) { + throw new Error('TxClient:MsgExitStaking:Init Could not initialize signing client. Wallet is required.') + } else{ + throw new Error('TxClient:MsgExitStaking:Create Could not create message: ' + e.message) + } + } + }, + async MsgCreateStakingReward({ rootGetters }, { value }) { + try { + const client=initClient(rootGetters) + const msg = await client.BzeV1Rewards.tx.msgCreateStakingReward({value}) + return msg + } catch (e) { + if (e == MissingWalletError) { + throw new Error('TxClient:MsgCreateStakingReward:Init Could not initialize signing client. Wallet is required.') + } else{ + throw new Error('TxClient:MsgCreateStakingReward:Create Could not create message: ' + e.message) + } + } + }, + async MsgClaimStakingRewards({ rootGetters }, { value }) { + try { + const client=initClient(rootGetters) + const msg = await client.BzeV1Rewards.tx.msgClaimStakingRewards({value}) + return msg + } catch (e) { + if (e == MissingWalletError) { + throw new Error('TxClient:MsgClaimStakingRewards:Init Could not initialize signing client. Wallet is required.') + } else{ + throw new Error('TxClient:MsgClaimStakingRewards:Create Could not create message: ' + e.message) + } + } + }, + + } +} diff --git a/vue/src/store/generated/index.ts b/vue/src/store/generated/index.ts index 44ca0f46..20a55cc8 100755 --- a/vue/src/store/generated/index.ts +++ b/vue/src/store/generated/index.ts @@ -1,58 +1,22 @@ // THIS FILE IS GENERATED AUTOMATICALLY. DO NOT MODIFY. -import BzeAlphateamBzeBzeBurnerV1 from './bze-alphateam/bze/bze.burner.v1' -import BzeAlphateamBzeBzeCointrunkV1 from './bze-alphateam/bze/bze.cointrunk.v1' -import BzeAlphateamBzeBzeCointrunk from './bze-alphateam/bze/bze.cointrunk' -import BzeAlphateamBzeBzeEpochsV1 from './bze-alphateam/bze/bze.epochs.v1' -import BzeAlphateamBzeBzeScavenge from './bze-alphateam/bze/bze.scavenge' -import BzeAlphateamBzeBzeTokenfactoryV1 from './bze-alphateam/bze/bze.tokenfactory.v1' -import BzeAlphateamBzeBzeTradebinV1 from './bze-alphateam/bze/bze.tradebin.v1' -import BzeAlphateamBzeBzeV1Rewards from './bze-alphateam/bze/bze.v1.rewards' -import BzeAlphateamBzeBzealphateamBzeBurner from './bze-alphateam/bze/bzealphateam.bze.burner' -import BzeAlphateamBzeBzealphateamBzeCointrunk from './bze-alphateam/bze/bzealphateam.bze.cointrunk' -import BzeAlphateamBzeBzealphateamBzeEpochs from './bze-alphateam/bze/bzealphateam.bze.epochs' -import BzeAlphateamBzeBzealphateamBzeRewards from './bze-alphateam/bze/bzealphateam.bze.rewards' -import BzeAlphateamBzeBzealphateamBzeTokenfactory from './bze-alphateam/bze/bzealphateam.bze.tokenfactory' -import BzeAlphateamBzeBzealphateamBzeTradebin from './bze-alphateam/bze/bzealphateam.bze.tradebin' -import CosmosCosmosSdkCosmosAuthzV1Beta1 from './cosmos/cosmos-sdk/cosmos.authz.v1beta1' -import CosmosCosmosSdkCosmosBankV1Beta1 from './cosmos/cosmos-sdk/cosmos.bank.v1beta1' -import CosmosCosmosSdkCosmosCrisisV1Beta1 from './cosmos/cosmos-sdk/cosmos.crisis.v1beta1' -import CosmosCosmosSdkCosmosDistributionV1Beta1 from './cosmos/cosmos-sdk/cosmos.distribution.v1beta1' -import CosmosCosmosSdkCosmosEvidenceV1Beta1 from './cosmos/cosmos-sdk/cosmos.evidence.v1beta1' -import CosmosCosmosSdkCosmosFeegrantV1Beta1 from './cosmos/cosmos-sdk/cosmos.feegrant.v1beta1' -import CosmosCosmosSdkCosmosGovV1Beta1 from './cosmos/cosmos-sdk/cosmos.gov.v1beta1' -import CosmosCosmosSdkCosmosSlashingV1Beta1 from './cosmos/cosmos-sdk/cosmos.slashing.v1beta1' -import CosmosCosmosSdkCosmosStakingV1Beta1 from './cosmos/cosmos-sdk/cosmos.staking.v1beta1' -import CosmosCosmosSdkCosmosVestingV1Beta1 from './cosmos/cosmos-sdk/cosmos.vesting.v1beta1' -import CosmosIbcGoIbcApplicationsTransferV1 from './cosmos/ibc-go/ibc.applications.transfer.v1' +import BzeBurnerV1 from './bze.burner.v1' +import BzeCointrunkV1 from './bze.cointrunk.v1' +import BzeEpochsV1 from './bze.epochs.v1' +import BzeV1Rewards from './bze.v1.rewards' +import BzeScavenge from './bze.scavenge' +import BzeTokenfactoryV1 from './bze.tokenfactory.v1' +import BzeTradebinV1 from './bze.tradebin.v1' export default { - BzeAlphateamBzeBzeBurnerV1: load(BzeAlphateamBzeBzeBurnerV1, 'bze.burner.v1'), - BzeAlphateamBzeBzeCointrunkV1: load(BzeAlphateamBzeBzeCointrunkV1, 'bze.cointrunk.v1'), - BzeAlphateamBzeBzeCointrunk: load(BzeAlphateamBzeBzeCointrunk, 'bze.cointrunk'), - BzeAlphateamBzeBzeEpochsV1: load(BzeAlphateamBzeBzeEpochsV1, 'bze.epochs.v1'), - BzeAlphateamBzeBzeScavenge: load(BzeAlphateamBzeBzeScavenge, 'bze.scavenge'), - BzeAlphateamBzeBzeTokenfactoryV1: load(BzeAlphateamBzeBzeTokenfactoryV1, 'bze.tokenfactory.v1'), - BzeAlphateamBzeBzeTradebinV1: load(BzeAlphateamBzeBzeTradebinV1, 'bze.tradebin.v1'), - BzeAlphateamBzeBzeV1Rewards: load(BzeAlphateamBzeBzeV1Rewards, 'bze.v1.rewards'), - BzeAlphateamBzeBzealphateamBzeBurner: load(BzeAlphateamBzeBzealphateamBzeBurner, 'bzealphateam.bze.burner'), - BzeAlphateamBzeBzealphateamBzeCointrunk: load(BzeAlphateamBzeBzealphateamBzeCointrunk, 'bzealphateam.bze.cointrunk'), - BzeAlphateamBzeBzealphateamBzeEpochs: load(BzeAlphateamBzeBzealphateamBzeEpochs, 'bzealphateam.bze.epochs'), - BzeAlphateamBzeBzealphateamBzeRewards: load(BzeAlphateamBzeBzealphateamBzeRewards, 'bzealphateam.bze.rewards'), - BzeAlphateamBzeBzealphateamBzeTokenfactory: load(BzeAlphateamBzeBzealphateamBzeTokenfactory, 'bzealphateam.bze.tokenfactory'), - BzeAlphateamBzeBzealphateamBzeTradebin: load(BzeAlphateamBzeBzealphateamBzeTradebin, 'bzealphateam.bze.tradebin'), - CosmosCosmosSdkCosmosAuthzV1Beta1: load(CosmosCosmosSdkCosmosAuthzV1Beta1, 'cosmos.authz.v1beta1'), - CosmosCosmosSdkCosmosBankV1Beta1: load(CosmosCosmosSdkCosmosBankV1Beta1, 'cosmos.bank.v1beta1'), - CosmosCosmosSdkCosmosCrisisV1Beta1: load(CosmosCosmosSdkCosmosCrisisV1Beta1, 'cosmos.crisis.v1beta1'), - CosmosCosmosSdkCosmosDistributionV1Beta1: load(CosmosCosmosSdkCosmosDistributionV1Beta1, 'cosmos.distribution.v1beta1'), - CosmosCosmosSdkCosmosEvidenceV1Beta1: load(CosmosCosmosSdkCosmosEvidenceV1Beta1, 'cosmos.evidence.v1beta1'), - CosmosCosmosSdkCosmosFeegrantV1Beta1: load(CosmosCosmosSdkCosmosFeegrantV1Beta1, 'cosmos.feegrant.v1beta1'), - CosmosCosmosSdkCosmosGovV1Beta1: load(CosmosCosmosSdkCosmosGovV1Beta1, 'cosmos.gov.v1beta1'), - CosmosCosmosSdkCosmosSlashingV1Beta1: load(CosmosCosmosSdkCosmosSlashingV1Beta1, 'cosmos.slashing.v1beta1'), - CosmosCosmosSdkCosmosStakingV1Beta1: load(CosmosCosmosSdkCosmosStakingV1Beta1, 'cosmos.staking.v1beta1'), - CosmosCosmosSdkCosmosVestingV1Beta1: load(CosmosCosmosSdkCosmosVestingV1Beta1, 'cosmos.vesting.v1beta1'), - CosmosIbcGoIbcApplicationsTransferV1: load(CosmosIbcGoIbcApplicationsTransferV1, 'ibc.applications.transfer.v1'), + BzeBurnerV1: load(BzeBurnerV1, 'bze.burner.v1'), + BzeCointrunkV1: load(BzeCointrunkV1, 'bze.cointrunk.v1'), + BzeEpochsV1: load(BzeEpochsV1, 'bze.epochs.v1'), + BzeV1Rewards: load(BzeV1Rewards, 'bze.v1.rewards'), + BzeScavenge: load(BzeScavenge, 'bze.scavenge'), + BzeTokenfactoryV1: load(BzeTokenfactoryV1, 'bze.tokenfactory.v1'), + BzeTradebinV1: load(BzeTradebinV1, 'bze.tradebin.v1'), } @@ -72,4 +36,4 @@ function load(mod, fullns) { }) } } -} +} \ No newline at end of file diff --git a/vue/src/store/generated/package.json b/vue/src/store/generated/package.json index 4d1bd602..ba7a2dc4 100755 --- a/vue/src/store/generated/package.json +++ b/vue/src/store/generated/package.json @@ -1,8 +1,8 @@ { - "name": "bze-alphateam-bze-js", - "version": "0.1.0", - "description": "Autogenerated cosmos modules vuex store", - "author": "Starport Codegen ", + "name": "bze-alphateam-bze-vue", + "version": "0.0.1", + "description": "Autogenerated Vue Utils", + "author": "Ignite Codegen ", "license": "Apache-2.0", "licenses": [ { @@ -10,8 +10,17 @@ "url": "http://www.apache.org/licenses/LICENSE-2.0" } ], - "main": "index.js", + "main": "index.ts", "publishConfig": { "access": "public" + }, + "dependencies": { + "bze-alphateam-bze-client": "0.0.1", + "buffer": "^6.0.3" + }, + "peerDependencies": { + "@cosmjs/proto-signing": "0.27.0", + "@cosmjs/stargate": "0.27.0", + "vue": "3.2.31" } } diff --git a/x/rewards/genesis.go b/x/rewards/genesis.go index 38896a1d..65a46dba 100644 --- a/x/rewards/genesis.go +++ b/x/rewards/genesis.go @@ -14,10 +14,12 @@ func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) k.SetStakingReward(ctx, elem) } // Set all the tradingReward - for _, elem := range genState.TradingRewardList { - k.SetTradingReward(ctx, elem) - //TODO: move this to its own genesis export/import - k.SetMarketIdRewardId(ctx, elem) + for _, elem := range genState.PendingTradingRewardList { + k.SetPendingTradingReward(ctx, elem) + } + + for _, elem := range genState.ActiveTradingRewardList { + k.SetActiveTradingReward(ctx, elem) } for _, elem := range genState.TradingRewardLeaderboardList { @@ -38,6 +40,18 @@ func InitGenesis(ctx sdk.Context, k keeper.Keeper, genState types.GenesisState) k.SetPendingUnlockParticipant(ctx, elem) } + for _, elem := range genState.PendingTradingRewardExpirationList { + k.SetPendingTradingRewardExpiration(ctx, elem) + } + + for _, elem := range genState.ActiveTradingRewardExpirationList { + k.SetActiveTradingRewardExpiration(ctx, elem) + } + + for _, elem := range genState.MarketIdTradingRewardIdList { + k.SetMarketIdRewardId(ctx, elem) + } + // this line is used by starport scaffolding # genesis/module/init k.SetParams(ctx, genState.Params) k.SetTradingRewardsCounter(ctx, genState.TradingRewardsCounter) @@ -52,11 +66,17 @@ func ExportGenesis(ctx sdk.Context, k keeper.Keeper) *types.GenesisState { genesis.StakingRewardList = k.GetAllStakingReward(ctx) genesis.StakingRewardsCounter = k.GetStakingRewardsCounter(ctx) genesis.TradingRewardsCounter = k.GetTradingRewardsCounter(ctx) - genesis.TradingRewardList = k.GetAllTradingReward(ctx) + + genesis.PendingTradingRewardList = k.GetAllPendingTradingReward(ctx) + genesis.ActiveTradingRewardList = k.GetAllActiveTradingReward(ctx) genesis.StakingRewardParticipantList = k.GetAllStakingRewardParticipant(ctx) genesis.PendingUnlockParticipantList = k.GetAllPendingUnlockParticipant(ctx) genesis.TradingRewardLeaderboardList = k.GetAllTradingRewardLeaderboard(ctx) genesis.TradingRewardCandidateList = k.GetAllTradingRewardCandidate(ctx) + + genesis.MarketIdTradingRewardIdList = k.GetAllMarketIdRewardId(ctx) + genesis.PendingTradingRewardExpirationList = k.GetAllPendingTradingRewardExpiration(ctx) + genesis.ActiveTradingRewardExpirationList = k.GetAllActiveTradingRewardExpiration(ctx) // this line is used by starport scaffolding # genesis/module/export return genesis diff --git a/x/rewards/keeper/cleanup.go b/x/rewards/keeper/cleanup.go index bdb7a359..c34d047f 100644 --- a/x/rewards/keeper/cleanup.go +++ b/x/rewards/keeper/cleanup.go @@ -7,20 +7,20 @@ import ( func (k Keeper) removeExpiredTradingRewards(ctx sdk.Context, epochNumber int64) { logger := k.Logger(ctx).With("epoch_number", epochNumber) - toRemove := k.GetAllTradingRewardExpirationByExpireAt(ctx, uint32(epochNumber)) + toRemove := k.GetAllPendingTradingRewardExpirationByExpireAt(ctx, uint32(epochNumber)) for _, exp := range toRemove { - k.RemoveTradingRewardExpiration(ctx, exp.ExpireAt, exp.RewardId) - tr, found := k.GetTradingReward(ctx, exp.RewardId) + k.RemovePendingTradingRewardExpiration(ctx, exp.ExpireAt, exp.RewardId) + tr, found := k.GetPendingTradingReward(ctx, exp.RewardId) if !found { logger.With("trading_reward_expiration", exp).Error("trading reward not found for this trading reward expiration") continue } - k.RemoveTradingReward(ctx, exp.RewardId) + k.RemovePendingTradingReward(ctx, exp.RewardId) //burn coins that were captured toBurn, err := k.getAmountToCapture("", tr.PrizeDenom, tr.PrizeAmount, int64(tr.Slots)) if err != nil { - logger.With("trading_reward", tr).Error("could not create amount to capture") + logger.With("trading_reward", tr).Error("could not create amount to burn from trading reward") continue } @@ -30,6 +30,7 @@ func (k Keeper) removeExpiredTradingRewards(ctx sdk.Context, epochNumber int64) continue } - logger.With("trading_reward_expiration", exp).Debug("removed expired trading reward") + logger.With("trading_reward", tr, "to_burn", toBurn). + Debug("removed expired trading reward and burnt the tokens associated with it") } } diff --git a/x/rewards/keeper/grpc_query_trading_reward.go b/x/rewards/keeper/grpc_query_trading_reward.go index 05baa235..d8b106c0 100644 --- a/x/rewards/keeper/grpc_query_trading_reward.go +++ b/x/rewards/keeper/grpc_query_trading_reward.go @@ -20,7 +20,7 @@ func (k Keeper) TradingRewardAll(c context.Context, req *types.QueryAllTradingRe ctx := sdk.UnwrapSDKContext(c) store := ctx.KVStore(k.storeKey) - tradingRewardStore := prefix.NewStore(store, types.KeyPrefix(types.TradingRewardKeyPrefix)) + tradingRewardStore := prefix.NewStore(store, types.KeyPrefix(types.PendingTradingRewardKeyPrefix)) pageRes, err := query.Paginate(tradingRewardStore, req.Pagination, func(key []byte, value []byte) error { var tradingReward types.TradingReward @@ -45,7 +45,7 @@ func (k Keeper) TradingReward(c context.Context, req *types.QueryGetTradingRewar } ctx := sdk.UnwrapSDKContext(c) - val, found := k.GetTradingReward(ctx, req.RewardId) + val, found := k.GetPendingTradingReward(ctx, req.RewardId) if !found { return nil, status.Error(codes.NotFound, "not found") } diff --git a/x/rewards/keeper/hooks.go b/x/rewards/keeper/hooks.go index d6eefc8e..38f4b2fb 100644 --- a/x/rewards/keeper/hooks.go +++ b/x/rewards/keeper/hooks.go @@ -57,19 +57,36 @@ func (k Keeper) GetRemoveExpiredTradingRewardsHook() types.EpochHook { }) } +func (k Keeper) GetTradingRewardsDistributionHook() types.EpochHook { + hookName := "trading_rewards_distribution" + return types.NewAfterEpochHook(hookName, func(ctx sdk.Context, epochIdentifier string, epochNumber int64) error { + if epochIdentifier != expirationEpoch { + return nil + } + + k.Logger(ctx). + With("epoch", epochIdentifier, "epoch_number", epochNumber, "hook_name", hookName). + Debug("preparing to execute hook") + + k.distributeTradingRewards(ctx, epochNumber) + + return nil + }) +} + func (k Keeper) GetOnOrderFillHook() func(ctx sdk.Context, marketId, amountTraded, userAddress string) { return func(ctx sdk.Context, marketId, amountTraded, userAddress string) { logger := ctx.Logger().With("market_id", marketId) - existingRewardId, found := k.GetMarketIdRewardId(ctx, marketId) + existingReward, found := k.GetMarketIdRewardId(ctx, marketId) if !found { logger.Debug("no rewards found for this market id") return } - reward, found := k.GetTradingReward(ctx, existingRewardId) + reward, found := k.GetActiveTradingReward(ctx, existingReward.RewardId) if !found { - logger.With("reward_id", existingRewardId). - Error("the reward id found for this market does not exist in trading reward store") + logger.With("reward_id", existingReward). + Error("the reward id found for this market does not exist in active trading reward store") return } logger = logger.With("reward", reward) diff --git a/x/rewards/keeper/msg_server_staking_reward.go b/x/rewards/keeper/msg_server_staking_reward.go index 8a66e054..1b5e6373 100644 --- a/x/rewards/keeper/msg_server_staking_reward.go +++ b/x/rewards/keeper/msg_server_staking_reward.go @@ -90,6 +90,11 @@ func (k msgServer) UpdateStakingReward(goCtx context.Context, msg *types.MsgUpda return nil, sdkerrors.Wrapf(err, "could not calculate amount needed to create the reward") } + err = k.checkUserBalances(ctx, toCapture, acc) + if err != nil { + return nil, err + } + err = k.bankKeeper.SendCoinsFromAccountToModule(ctx, acc, types.ModuleName, toCapture) if err != nil { return nil, err diff --git a/x/rewards/keeper/msg_server_trading_reward.go b/x/rewards/keeper/msg_server_trading_reward.go index 34e3fb39..5c6907f6 100644 --- a/x/rewards/keeper/msg_server_trading_reward.go +++ b/x/rewards/keeper/msg_server_trading_reward.go @@ -63,7 +63,7 @@ func (k msgServer) CreateTradingReward(goCtx context.Context, msg *types.MsgCrea //add ID tradingReward.RewardId = k.smallZeroFillId(k.GetTradingRewardsCounter(ctx)) tradingReward.ExpireAt = k.getNewTradingRewardExpireAt(ctx) - k.SetTradingReward( + k.SetPendingTradingReward( ctx, tradingReward, ) @@ -73,7 +73,7 @@ func (k msgServer) CreateTradingReward(goCtx context.Context, msg *types.MsgCrea RewardId: tradingReward.RewardId, ExpireAt: tradingReward.ExpireAt, } - k.SetTradingRewardExpiration(ctx, exp) + k.SetPendingTradingRewardExpiration(ctx, exp) return &types.MsgCreateTradingRewardResponse{RewardId: tradingReward.RewardId}, nil } diff --git a/x/rewards/keeper/msg_server_trading_reward_test.go b/x/rewards/keeper/msg_server_trading_reward_test.go index 977f77b8..b1ed017b 100644 --- a/x/rewards/keeper/msg_server_trading_reward_test.go +++ b/x/rewards/keeper/msg_server_trading_reward_test.go @@ -247,7 +247,7 @@ func (suite *IntegrationTestSuite) TestCreateTradingReward_Success() { res, err := suite.msgServer.CreateTradingReward(goCtx, &msg) suite.Require().NoError(err) - storeTradingReward, ok := suite.k.GetTradingReward(suite.ctx, res.RewardId) + storeTradingReward, ok := suite.k.GetPendingTradingReward(suite.ctx, res.RewardId) suite.Require().True(ok) suite.Require().EqualValues(msg.PrizeAmount, storeTradingReward.PrizeAmount) diff --git a/x/rewards/keeper/trading_reward.go b/x/rewards/keeper/trading_reward.go index 23e3a8ed..eafa5917 100644 --- a/x/rewards/keeper/trading_reward.go +++ b/x/rewards/keeper/trading_reward.go @@ -6,35 +6,36 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ) -// SetTradingReward set a specific tradingReward in the store from its index -func (k Keeper) SetTradingReward(ctx sdk.Context, tradingReward types.TradingReward) { - store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.TradingRewardKeyPrefix)) +func (k Keeper) getActiveTradingRewardStore(ctx sdk.Context) prefix.Store { + return prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.ActiveTradingRewardKeyPrefix)) +} + +func (k Keeper) getPendingTradingRewardStore(ctx sdk.Context) prefix.Store { + return prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.PendingTradingRewardKeyPrefix)) +} + +func (k Keeper) setTradingReward(store prefix.Store, tradingReward types.TradingReward) { b := k.cdc.MustMarshal(&tradingReward) store.Set(types.TradingRewardKey(tradingReward.RewardId), b) } -// GetTradingReward returns a tradingReward from its index -func (k Keeper) GetTradingReward(ctx sdk.Context, rewardId string) (val types.TradingReward, found bool) { - store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.TradingRewardKeyPrefix)) - +func (k Keeper) getTradingReward(store prefix.Store, rewardId string) (val types.TradingReward, found bool) { b := store.Get(types.TradingRewardKey(rewardId)) if b == nil { return val, false } k.cdc.MustUnmarshal(b, &val) + return val, true } -// RemoveTradingReward removes a tradingReward from the store -func (k Keeper) RemoveTradingReward(ctx sdk.Context, rewardId string) { - store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.TradingRewardKeyPrefix)) +// RemovePendingTradingReward removes a tradingReward from the store +func (k Keeper) removeTradingReward(store prefix.Store, rewardId string) { store.Delete(types.TradingRewardKey(rewardId)) } -// GetAllTradingReward returns all tradingReward -func (k Keeper) GetAllTradingReward(ctx sdk.Context) (list []types.TradingReward) { - store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.TradingRewardKeyPrefix)) +func (k Keeper) getAllTradingReward(store prefix.Store) (list []types.TradingReward) { iterator := sdk.KVStorePrefixIterator(store, []byte{}) defer iterator.Close() @@ -48,78 +49,92 @@ func (k Keeper) GetAllTradingReward(ctx sdk.Context) (list []types.TradingReward return } -// SetMarketIdRewardId save a reward id on a market id key -func (k Keeper) SetMarketIdRewardId(ctx sdk.Context, tradingReward types.TradingReward) { - store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.MarketIdRewardIdKeyPrefix)) - val := []byte(tradingReward.RewardId) - store.Set(types.MarketIdRewardIdKey(tradingReward.MarketId), val) +// SetPendingTradingReward set a specific tradingReward in the store from its index +func (k Keeper) SetPendingTradingReward(ctx sdk.Context, tradingReward types.TradingReward) { + store := k.getPendingTradingRewardStore(ctx) + k.setTradingReward(store, tradingReward) } -// GetMarketIdRewardId get a reward id for a market id key -func (k Keeper) GetMarketIdRewardId(ctx sdk.Context, marketId string) (string, bool) { - store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.MarketIdRewardIdKeyPrefix)) - val := store.Get(types.MarketIdRewardIdKey(marketId)) - if val == nil { - return "", false - } +// GetPendingTradingReward returns a tradingReward from its index +func (k Keeper) GetPendingTradingReward(ctx sdk.Context, rewardId string) (val types.TradingReward, found bool) { + store := k.getPendingTradingRewardStore(ctx) - return string(val), true + return k.getTradingReward(store, rewardId) } -// RemoveMarketIdRewardId removes the reward id stored for a market id -func (k Keeper) RemoveMarketIdRewardId(ctx sdk.Context, marketId string) { - store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.MarketIdRewardIdKeyPrefix)) - store.Delete(types.MarketIdRewardIdKey(marketId)) +// RemovePendingTradingReward removes a tradingReward from the store +func (k Keeper) RemovePendingTradingReward(ctx sdk.Context, rewardId string) { + store := k.getPendingTradingRewardStore(ctx) + k.removeTradingReward(store, rewardId) } -func (k Keeper) GetAllMarketIdRewardId(ctx sdk.Context) (list []string) { - store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.MarketIdRewardIdKeyPrefix)) - iterator := sdk.KVStorePrefixIterator(store, []byte{}) - - defer iterator.Close() +// GetAllPendingTradingReward returns all tradingReward +func (k Keeper) GetAllPendingTradingReward(ctx sdk.Context) []types.TradingReward { + store := k.getPendingTradingRewardStore(ctx) - for ; iterator.Valid(); iterator.Next() { - list = append(list, string(iterator.Value())) - } + return k.getAllTradingReward(store) +} - return +// SetActiveTradingReward set a specific tradingReward in the store from its index +func (k Keeper) SetActiveTradingReward(ctx sdk.Context, tradingReward types.TradingReward) { + store := k.getActiveTradingRewardStore(ctx) + k.setTradingReward(store, tradingReward) } -// SetTradingRewardExpiration save the reward id on the expiration key -func (k Keeper) SetTradingRewardExpiration(ctx sdk.Context, expiration types.TradingRewardExpiration) { - store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.TradingRewardExpirationKeyPrefix)) - b := k.cdc.MustMarshal(&expiration) - store.Set(types.TradingRewardExpirationKey(expiration.ExpireAt, expiration.RewardId), b) +// GetActiveTradingReward returns a tradingReward from its index +func (k Keeper) GetActiveTradingReward(ctx sdk.Context, rewardId string) (val types.TradingReward, found bool) { + store := k.getActiveTradingRewardStore(ctx) + + return k.getTradingReward(store, rewardId) } -func (k Keeper) RemoveTradingRewardExpiration(ctx sdk.Context, expireAt uint32, rewardId string) { - store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.TradingRewardExpirationKeyPrefix)) - store.Delete(types.TradingRewardExpirationKey(expireAt, rewardId)) +// RemoveActiveTradingReward removes a tradingReward from the store +func (k Keeper) RemoveActiveTradingReward(ctx sdk.Context, rewardId string) { + store := k.getActiveTradingRewardStore(ctx) + k.removeTradingReward(store, rewardId) } -func (k Keeper) GetAllTradingRewardExpiration(ctx sdk.Context) (list []types.TradingRewardExpiration) { - store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.TradingRewardExpirationKeyPrefix)) - iterator := sdk.KVStorePrefixIterator(store, []byte{}) +// GetAllActiveTradingReward returns all tradingReward +func (k Keeper) GetAllActiveTradingReward(ctx sdk.Context) []types.TradingReward { + store := k.getActiveTradingRewardStore(ctx) - defer iterator.Close() + return k.getAllTradingReward(store) +} - for ; iterator.Valid(); iterator.Next() { - var val types.TradingRewardExpiration - k.cdc.MustUnmarshal(iterator.Value(), &val) - list = append(list, val) +// SetMarketIdRewardId save a reward id on a market id key +func (k Keeper) SetMarketIdRewardId(ctx sdk.Context, marketIdRewardId types.MarketIdTradingRewardId) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.MarketIdRewardIdKeyPrefix)) + val := k.cdc.MustMarshal(&marketIdRewardId) + store.Set(types.MarketIdRewardIdKey(marketIdRewardId.MarketId), val) +} + +// GetMarketIdRewardId get a reward id for a market id key +func (k Keeper) GetMarketIdRewardId(ctx sdk.Context, marketId string) (val types.MarketIdTradingRewardId, found bool) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.MarketIdRewardIdKeyPrefix)) + valStorage := store.Get(types.MarketIdRewardIdKey(marketId)) + if valStorage == nil { + return val, false } - return + k.cdc.MustUnmarshal(valStorage, &val) + + return val, true +} + +// RemoveMarketIdRewardId removes the reward id stored for a market id +func (k Keeper) RemoveMarketIdRewardId(ctx sdk.Context, marketId string) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.MarketIdRewardIdKeyPrefix)) + store.Delete(types.MarketIdRewardIdKey(marketId)) } -func (k Keeper) GetAllTradingRewardExpirationByExpireAt(ctx sdk.Context, expireAt uint32) (list []types.TradingRewardExpiration) { - store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.TradingRewardExpirationKeyPrefix)) - iterator := sdk.KVStorePrefixIterator(store, []byte(types.TradingRewardExpirationByExpireAtPrefix(expireAt))) +func (k Keeper) GetAllMarketIdRewardId(ctx sdk.Context) (list []types.MarketIdTradingRewardId) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.MarketIdRewardIdKeyPrefix)) + iterator := sdk.KVStorePrefixIterator(store, []byte{}) defer iterator.Close() for ; iterator.Valid(); iterator.Next() { - var val types.TradingRewardExpiration + var val types.MarketIdTradingRewardId k.cdc.MustUnmarshal(iterator.Value(), &val) list = append(list, val) } diff --git a/x/rewards/keeper/trading_reward_distribution.go b/x/rewards/keeper/trading_reward_distribution.go new file mode 100644 index 00000000..a480482e --- /dev/null +++ b/x/rewards/keeper/trading_reward_distribution.go @@ -0,0 +1,59 @@ +package keeper + +import ( + "github.com/bze-alphateam/bze/x/rewards/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +const ( + oneWeekInHours = 7 * 24 +) + +func (k Keeper) distributeTradingRewards(ctx sdk.Context, epochNumber int64) { + logger := k.Logger(ctx).With("epoch_number", epochNumber) + toPay := k.GetAllActiveTradingRewardExpirationByExpireAt(ctx, uint32(epochNumber)) + for _, exp := range toPay { + tr, found := k.GetActiveTradingReward(ctx, exp.RewardId) + if !found { + logger.With("trading_reward_expiration", exp).Error("trading reward not found for this trading reward expiration") + continue + } + logger = logger.With("trading_reward", tr) + + //delete those already paid in a previous epoch that were extended just so we can display them for a few more days + if int64(tr.ExpireAt) != epochNumber { + k.RemoveActiveTradingRewardExpiration(ctx, exp.ExpireAt, exp.RewardId) + k.RemoveActiveTradingReward(ctx, exp.RewardId) + k.RemoveTradingRewardLeaderboard(ctx, exp.RewardId) + + continue + } + + rewardPerSlot, err := k.getAmountToCapture("", tr.PrizeDenom, tr.PrizeAmount, 1) + if err != nil { + logger.Error("could not get reward per slot") + continue + } + + leaderboard, found := k.GetTradingRewardLeaderboard(ctx, tr.RewardId) + if !found { + logger.Error("trading reward leaderboard not found") + continue + } + + for _, winner := range leaderboard.List { + acc, err := sdk.AccAddressFromBech32(winner.Address) + if err != nil { + panic(err) + } + + _ = k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, acc, rewardPerSlot) + } + + //the trading reward is finished. remove the market id + k.RemoveMarketIdRewardId(ctx, tr.MarketId) + //extend the expiration of this paid trading reward for another period just to display the winners + exp.ExpireAt += oneWeekInHours + k.SetActiveTradingRewardExpiration(ctx, exp) + } +} diff --git a/x/rewards/keeper/trading_reward_expiration.go b/x/rewards/keeper/trading_reward_expiration.go new file mode 100644 index 00000000..c3e39a48 --- /dev/null +++ b/x/rewards/keeper/trading_reward_expiration.go @@ -0,0 +1,97 @@ +package keeper + +import ( + "github.com/bze-alphateam/bze/x/rewards/types" + "github.com/cosmos/cosmos-sdk/store/prefix" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +func (k Keeper) getActiveTradingRewardExpirationStore(ctx sdk.Context) prefix.Store { + return prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.ActiveTradingRewardExpirationKeyPrefix)) +} + +func (k Keeper) getPendingTradingRewardExpirationStore(ctx sdk.Context) prefix.Store { + return prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.PendingTradingRewardExpirationKeyPrefix)) +} + +func (k Keeper) setTradingRewardExpiration(store prefix.Store, expiration types.TradingRewardExpiration) { + b := k.cdc.MustMarshal(&expiration) + store.Set(types.TradingRewardExpirationKey(expiration.ExpireAt, expiration.RewardId), b) +} + +func (k Keeper) removeTradingRewardExpiration(store prefix.Store, expireAt uint32, rewardId string) { + store.Delete(types.TradingRewardExpirationKey(expireAt, rewardId)) +} + +func (k Keeper) getAllTradingRewardExpiration(store prefix.Store) (list []types.TradingRewardExpiration) { + iterator := sdk.KVStorePrefixIterator(store, []byte{}) + + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + var val types.TradingRewardExpiration + k.cdc.MustUnmarshal(iterator.Value(), &val) + list = append(list, val) + } + + return +} + +func (k Keeper) getAllTradingRewardExpirationByExpireAt(store prefix.Store, expireAt uint32) (list []types.TradingRewardExpiration) { + iterator := sdk.KVStorePrefixIterator(store, []byte(types.TradingRewardExpirationByExpireAtPrefix(expireAt))) + + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + var val types.TradingRewardExpiration + k.cdc.MustUnmarshal(iterator.Value(), &val) + list = append(list, val) + } + + return +} + +// SetPendingTradingRewardExpiration save the reward id on the expiration key +func (k Keeper) SetPendingTradingRewardExpiration(ctx sdk.Context, expiration types.TradingRewardExpiration) { + store := k.getPendingTradingRewardExpirationStore(ctx) + k.setTradingRewardExpiration(store, expiration) +} + +func (k Keeper) RemovePendingTradingRewardExpiration(ctx sdk.Context, expireAt uint32, rewardId string) { + store := k.getPendingTradingRewardExpirationStore(ctx) + k.removeTradingRewardExpiration(store, expireAt, rewardId) +} + +func (k Keeper) GetAllPendingTradingRewardExpiration(ctx sdk.Context) []types.TradingRewardExpiration { + store := k.getPendingTradingRewardExpirationStore(ctx) + + return k.getAllTradingRewardExpiration(store) +} + +func (k Keeper) GetAllPendingTradingRewardExpirationByExpireAt(ctx sdk.Context, expireAt uint32) []types.TradingRewardExpiration { + store := k.getPendingTradingRewardExpirationStore(ctx) + + return k.getAllTradingRewardExpirationByExpireAt(store, expireAt) +} + +func (k Keeper) SetActiveTradingRewardExpiration(ctx sdk.Context, expiration types.TradingRewardExpiration) { + store := k.getActiveTradingRewardExpirationStore(ctx) + k.setTradingRewardExpiration(store, expiration) +} + +func (k Keeper) RemoveActiveTradingRewardExpiration(ctx sdk.Context, expireAt uint32, rewardId string) { + store := k.getActiveTradingRewardExpirationStore(ctx) + k.removeTradingRewardExpiration(store, expireAt, rewardId) +} + +func (k Keeper) GetAllActiveTradingRewardExpiration(ctx sdk.Context) []types.TradingRewardExpiration { + store := k.getActiveTradingRewardExpirationStore(ctx) + + return k.getAllTradingRewardExpiration(store) +} + +func (k Keeper) GetAllActiveTradingRewardExpirationByExpireAt(ctx sdk.Context, expireAt uint32) []types.TradingRewardExpiration { + store := k.getActiveTradingRewardExpirationStore(ctx) + + return k.getAllTradingRewardExpirationByExpireAt(store, expireAt) +} diff --git a/x/rewards/keeper/trading_reward_leaderboard.go b/x/rewards/keeper/trading_reward_leaderboard.go index 304c561c..bad1f58b 100644 --- a/x/rewards/keeper/trading_reward_leaderboard.go +++ b/x/rewards/keeper/trading_reward_leaderboard.go @@ -13,6 +13,11 @@ func (k Keeper) SetTradingRewardLeaderboard(ctx sdk.Context, leaderboard types.T store.Set(types.TradingRewardKey(leaderboard.RewardId), b) } +func (k Keeper) RemoveTradingRewardLeaderboard(ctx sdk.Context, rewardId string) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.LeaderboardKeyPrefix)) + store.Delete(types.TradingRewardKey(rewardId)) +} + // GetTradingRewardLeaderboard returns a types.TradingRewardLeaderboard from its index func (k Keeper) GetTradingRewardLeaderboard(ctx sdk.Context, rewardId string) (val types.TradingRewardLeaderboard, found bool) { store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.LeaderboardKeyPrefix)) diff --git a/x/rewards/keeper/trading_reward_test.go b/x/rewards/keeper/trading_reward_test.go index b228ce97..f65ccdba 100644 --- a/x/rewards/keeper/trading_reward_test.go +++ b/x/rewards/keeper/trading_reward_test.go @@ -20,7 +20,7 @@ func createNTradingReward(keeper *keeper.Keeper, ctx sdk.Context, n int) []types for i := range items { items[i].RewardId = strconv.Itoa(i) - keeper.SetTradingReward(ctx, items[i]) + keeper.SetPendingTradingReward(ctx, items[i]) } return items } @@ -29,7 +29,7 @@ func TestTradingRewardGet(t *testing.T) { keeper, ctx := keepertest.RewardsKeeper(t) items := createNTradingReward(keeper, ctx, 10) for _, item := range items { - rst, found := keeper.GetTradingReward(ctx, + rst, found := keeper.GetPendingTradingReward(ctx, item.RewardId, ) require.True(t, found) @@ -43,10 +43,10 @@ func TestTradingRewardRemove(t *testing.T) { keeper, ctx := keepertest.RewardsKeeper(t) items := createNTradingReward(keeper, ctx, 10) for _, item := range items { - keeper.RemoveTradingReward(ctx, + keeper.RemovePendingTradingReward(ctx, item.RewardId, ) - _, found := keeper.GetTradingReward(ctx, + _, found := keeper.GetPendingTradingReward(ctx, item.RewardId, ) require.False(t, found) @@ -58,6 +58,6 @@ func TestTradingRewardGetAll(t *testing.T) { items := createNTradingReward(keeper, ctx, 10) require.ElementsMatch(t, nullify.Fill(items), - nullify.Fill(keeper.GetAllTradingReward(ctx)), + nullify.Fill(keeper.GetAllPendingTradingReward(ctx)), ) } diff --git a/x/rewards/module_simulation.go b/x/rewards/module_simulation.go index e65e5270..8e0cd8b4 100644 --- a/x/rewards/module_simulation.go +++ b/x/rewards/module_simulation.go @@ -71,14 +71,6 @@ func (AppModule) GenerateGenesisState(simState *module.SimulationState) { RewardId: "1", }, }, - TradingRewardList: []types.TradingReward{ - { - RewardId: "0", - }, - { - RewardId: "1", - }, - }, // this line is used by starport scaffolding # simapp/module/genesisState } simState.GenState[types.ModuleName] = simState.Cdc.MustMarshalJSON(&rewardsGenesis) diff --git a/x/rewards/types/errors.go b/x/rewards/types/errors.go index df995c54..70cce2ec 100644 --- a/x/rewards/types/errors.go +++ b/x/rewards/types/errors.go @@ -17,5 +17,5 @@ var ( ErrInvalidMarketId = sdkerrors.Register(ModuleName, 5007, "invalid market_id") ErrInvalidSlots = sdkerrors.Register(ModuleName, 5008, "invalid slots") ErrInvalidRewardId = sdkerrors.Register(ModuleName, 5009, "invalid reward_id") - ErrRewardAlreadyExists = sdkerrors.Register(ModuleName, 5009, "a reward is already running for this market") + ErrRewardAlreadyExists = sdkerrors.Register(ModuleName, 5010, "a reward is already running for this market") ) diff --git a/x/rewards/types/genesis.go b/x/rewards/types/genesis.go index 7573c747..91d617e7 100644 --- a/x/rewards/types/genesis.go +++ b/x/rewards/types/genesis.go @@ -11,13 +11,19 @@ const DefaultIndex uint64 = 1 // DefaultGenesis returns the default Capability genesis state func DefaultGenesis() *GenesisState { return &GenesisState{ - StakingRewardList: []StakingReward{}, - StakingRewardsCounter: 0, - TradingRewardsCounter: 0, - TradingRewardList: []TradingReward{}, - StakingRewardParticipantList: []StakingRewardParticipant{}, - // this line is used by starport scaffolding # genesis/types/default - Params: DefaultParams(), + Params: DefaultParams(), + StakingRewardList: []StakingReward{}, + StakingRewardsCounter: 0, + TradingRewardsCounter: 0, + ActiveTradingRewardList: []TradingReward{}, + PendingTradingRewardList: []TradingReward{}, + StakingRewardParticipantList: []StakingRewardParticipant{}, + PendingUnlockParticipantList: []PendingUnlockParticipant{}, + TradingRewardLeaderboardList: []TradingRewardLeaderboard{}, + TradingRewardCandidateList: []TradingRewardCandidate{}, + MarketIdTradingRewardIdList: []MarketIdTradingRewardId{}, + PendingTradingRewardExpirationList: []TradingRewardExpiration{}, + ActiveTradingRewardExpirationList: []TradingRewardExpiration{}, } } @@ -34,19 +40,19 @@ func (gs GenesisState) Validate() error { } stakingRewardIndexMap[index] = struct{}{} } + // Check for duplicated index in tradingReward tradingRewardIndexMap := make(map[string]struct{}) - - for _, elem := range gs.TradingRewardList { + for _, elem := range gs.ActiveTradingRewardList { index := string(TradingRewardKey(elem.RewardId)) if _, ok := tradingRewardIndexMap[index]; ok { return fmt.Errorf("duplicated index for tradingReward") } tradingRewardIndexMap[index] = struct{}{} } + // Check for duplicated index in stakingRewardParticipant stakingRewardParticipantIndexMap := make(map[string]struct{}) - for _, elem := range gs.StakingRewardParticipantList { index := string(StakingRewardParticipantKey(elem.Address, elem.RewardId)) if _, ok := stakingRewardParticipantIndexMap[index]; ok { diff --git a/x/rewards/types/genesis.pb.go b/x/rewards/types/genesis.pb.go index 84cf279a..4e5b68bf 100644 --- a/x/rewards/types/genesis.pb.go +++ b/x/rewards/types/genesis.pb.go @@ -25,15 +25,19 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package // GenesisState defines the rewards module's genesis state. type GenesisState struct { - Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` - StakingRewardList []StakingReward `protobuf:"bytes,2,rep,name=staking_reward_list,json=stakingRewardList,proto3" json:"staking_reward_list"` - StakingRewardsCounter uint64 `protobuf:"varint,3,opt,name=staking_rewards_counter,json=stakingRewardsCounter,proto3" json:"staking_rewards_counter,omitempty"` - TradingRewardsCounter uint64 `protobuf:"varint,4,opt,name=trading_rewards_counter,json=tradingRewardsCounter,proto3" json:"trading_rewards_counter,omitempty"` - TradingRewardList []TradingReward `protobuf:"bytes,5,rep,name=trading_reward_list,json=tradingRewardList,proto3" json:"trading_reward_list"` - StakingRewardParticipantList []StakingRewardParticipant `protobuf:"bytes,6,rep,name=staking_reward_participant_list,json=stakingRewardParticipantList,proto3" json:"staking_reward_participant_list"` - PendingUnlockParticipantList []PendingUnlockParticipant `protobuf:"bytes,7,rep,name=pending_unlock_participant_list,json=pendingUnlockParticipantList,proto3" json:"pending_unlock_participant_list"` - TradingRewardLeaderboardList []TradingRewardLeaderboard `protobuf:"bytes,8,rep,name=trading_reward_leaderboard_list,json=tradingRewardLeaderboardList,proto3" json:"trading_reward_leaderboard_list"` - TradingRewardCandidateList []TradingRewardCandidate `protobuf:"bytes,9,rep,name=trading_reward_candidate_list,json=tradingRewardCandidateList,proto3" json:"trading_reward_candidate_list"` + Params Params `protobuf:"bytes,1,opt,name=params,proto3" json:"params"` + StakingRewardList []StakingReward `protobuf:"bytes,2,rep,name=staking_reward_list,json=stakingRewardList,proto3" json:"staking_reward_list"` + StakingRewardsCounter uint64 `protobuf:"varint,3,opt,name=staking_rewards_counter,json=stakingRewardsCounter,proto3" json:"staking_rewards_counter,omitempty"` + TradingRewardsCounter uint64 `protobuf:"varint,4,opt,name=trading_rewards_counter,json=tradingRewardsCounter,proto3" json:"trading_rewards_counter,omitempty"` + ActiveTradingRewardList []TradingReward `protobuf:"bytes,5,rep,name=active_trading_reward_list,json=activeTradingRewardList,proto3" json:"active_trading_reward_list"` + PendingTradingRewardList []TradingReward `protobuf:"bytes,6,rep,name=pending_trading_reward_list,json=pendingTradingRewardList,proto3" json:"pending_trading_reward_list"` + StakingRewardParticipantList []StakingRewardParticipant `protobuf:"bytes,7,rep,name=staking_reward_participant_list,json=stakingRewardParticipantList,proto3" json:"staking_reward_participant_list"` + PendingUnlockParticipantList []PendingUnlockParticipant `protobuf:"bytes,8,rep,name=pending_unlock_participant_list,json=pendingUnlockParticipantList,proto3" json:"pending_unlock_participant_list"` + TradingRewardLeaderboardList []TradingRewardLeaderboard `protobuf:"bytes,9,rep,name=trading_reward_leaderboard_list,json=tradingRewardLeaderboardList,proto3" json:"trading_reward_leaderboard_list"` + TradingRewardCandidateList []TradingRewardCandidate `protobuf:"bytes,10,rep,name=trading_reward_candidate_list,json=tradingRewardCandidateList,proto3" json:"trading_reward_candidate_list"` + MarketIdTradingRewardIdList []MarketIdTradingRewardId `protobuf:"bytes,11,rep,name=market_id_trading_reward_id_list,json=marketIdTradingRewardIdList,proto3" json:"market_id_trading_reward_id_list"` + PendingTradingRewardExpirationList []TradingRewardExpiration `protobuf:"bytes,12,rep,name=pending_trading_reward_expiration_list,json=pendingTradingRewardExpirationList,proto3" json:"pending_trading_reward_expiration_list"` + ActiveTradingRewardExpirationList []TradingRewardExpiration `protobuf:"bytes,13,rep,name=active_trading_reward_expiration_list,json=activeTradingRewardExpirationList,proto3" json:"active_trading_reward_expiration_list"` } func (m *GenesisState) Reset() { *m = GenesisState{} } @@ -97,9 +101,16 @@ func (m *GenesisState) GetTradingRewardsCounter() uint64 { return 0 } -func (m *GenesisState) GetTradingRewardList() []TradingReward { +func (m *GenesisState) GetActiveTradingRewardList() []TradingReward { if m != nil { - return m.TradingRewardList + return m.ActiveTradingRewardList + } + return nil +} + +func (m *GenesisState) GetPendingTradingRewardList() []TradingReward { + if m != nil { + return m.PendingTradingRewardList } return nil } @@ -132,6 +143,27 @@ func (m *GenesisState) GetTradingRewardCandidateList() []TradingRewardCandidate return nil } +func (m *GenesisState) GetMarketIdTradingRewardIdList() []MarketIdTradingRewardId { + if m != nil { + return m.MarketIdTradingRewardIdList + } + return nil +} + +func (m *GenesisState) GetPendingTradingRewardExpirationList() []TradingRewardExpiration { + if m != nil { + return m.PendingTradingRewardExpirationList + } + return nil +} + +func (m *GenesisState) GetActiveTradingRewardExpirationList() []TradingRewardExpiration { + if m != nil { + return m.ActiveTradingRewardExpirationList + } + return nil +} + func init() { proto.RegisterType((*GenesisState)(nil), "bze.v1.rewards.GenesisState") } @@ -139,35 +171,42 @@ func init() { func init() { proto.RegisterFile("rewards/genesis.proto", fileDescriptor_04e261dd19d07881) } var fileDescriptor_04e261dd19d07881 = []byte{ - // 437 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x7c, 0x93, 0xcf, 0xae, 0xd2, 0x40, - 0x14, 0x87, 0x5b, 0x2f, 0x56, 0x9d, 0x6b, 0x4c, 0xec, 0x05, 0x25, 0x0d, 0x14, 0xe2, 0xc2, 0x74, - 0xa1, 0x6d, 0x44, 0xe3, 0x03, 0x40, 0xa2, 0x1b, 0x16, 0x84, 0xea, 0xc6, 0x0d, 0x99, 0xb6, 0x93, - 0x32, 0x01, 0x3a, 0x93, 0x99, 0xa9, 0x7f, 0x78, 0x0a, 0x1f, 0xc6, 0x87, 0x60, 0xc9, 0xd2, 0x95, - 0x31, 0xf0, 0x22, 0x37, 0xcc, 0xb4, 0x40, 0x4b, 0xcb, 0x8e, 0xe9, 0xef, 0x7c, 0xe7, 0x9b, 0x73, - 0xc8, 0x80, 0x16, 0x43, 0x3f, 0x20, 0x8b, 0xb8, 0x17, 0xa3, 0x04, 0x71, 0xcc, 0x5d, 0xca, 0x88, - 0x20, 0xe6, 0xb3, 0x60, 0x8d, 0xdc, 0xef, 0xef, 0xdc, 0x2c, 0xb5, 0x9a, 0x31, 0x89, 0x89, 0x8c, - 0xbc, 0xc3, 0x2f, 0x55, 0x65, 0x35, 0x73, 0x98, 0x42, 0x06, 0x57, 0x19, 0x6b, 0x75, 0xf2, 0xaf, - 0x5c, 0xc0, 0x05, 0x4e, 0xe2, 0x99, 0x3a, 0x97, 0x53, 0xc1, 0x60, 0x74, 0x91, 0x3a, 0xd5, 0xec, - 0x8c, 0x42, 0x26, 0x70, 0x88, 0x29, 0x4c, 0x84, 0xaa, 0x7c, 0xf5, 0xc7, 0x00, 0x4f, 0x3f, 0xab, - 0x3b, 0xfb, 0x02, 0x0a, 0x64, 0x7e, 0x00, 0x86, 0xba, 0x46, 0x5b, 0xef, 0xeb, 0xce, 0xed, 0xe0, - 0x85, 0x5b, 0x9c, 0xc1, 0x9d, 0xc8, 0x74, 0xd8, 0xd8, 0xfc, 0xeb, 0x69, 0xd3, 0xac, 0xd6, 0xf4, - 0xc1, 0x5d, 0x49, 0xb5, 0xc4, 0x5c, 0xb4, 0x1f, 0xf4, 0x6f, 0x9c, 0xdb, 0x41, 0xb7, 0xdc, 0xc2, - 0x57, 0xa5, 0x53, 0x79, 0xcc, 0x3a, 0x3d, 0xe7, 0xe7, 0x1f, 0xc7, 0x98, 0x0b, 0xf3, 0x23, 0x78, - 0x59, 0x6c, 0xca, 0x67, 0x21, 0x49, 0x13, 0x81, 0x58, 0xfb, 0xa6, 0xaf, 0x3b, 0x8d, 0x69, 0xab, - 0xc0, 0xf0, 0x91, 0x0a, 0x0f, 0x5c, 0x71, 0x2b, 0x27, 0xae, 0xa1, 0xb8, 0x2c, 0x2e, 0x71, 0x3e, - 0xb8, 0x2b, 0x72, 0x6a, 0x88, 0x87, 0xd5, 0x43, 0x7c, 0x39, 0xef, 0x91, 0x0f, 0x51, 0x68, 0x2c, - 0x87, 0x48, 0x41, 0xaf, 0xfe, 0x4f, 0x50, 0x02, 0x43, 0x0a, 0x9c, 0xab, 0x5b, 0x9a, 0x9c, 0xa0, - 0xcc, 0xd5, 0xe1, 0x35, 0x79, 0xae, 0xa5, 0x28, 0x91, 0xb3, 0xa4, 0xc9, 0x92, 0x84, 0x8b, 0x4b, - 0xed, 0xa3, 0x6a, 0xed, 0x44, 0x61, 0x5f, 0x25, 0x55, 0xa1, 0xa5, 0x35, 0x79, 0xae, 0x2d, 0xaf, - 0x10, 0xc1, 0x08, 0xb1, 0x80, 0x1c, 0xd7, 0xf9, 0xb8, 0x5a, 0x5b, 0x58, 0xe7, 0xf8, 0x04, 0xe5, - 0x5a, 0x51, 0x93, 0x4b, 0x2d, 0x01, 0xdd, 0x92, 0x36, 0x84, 0x49, 0x84, 0x23, 0x28, 0x90, 0x92, - 0x3e, 0x91, 0xd2, 0xd7, 0x57, 0xa5, 0xa3, 0x1c, 0xc9, 0x94, 0x96, 0xa8, 0x4c, 0x0f, 0xc2, 0xe1, - 0xa7, 0xcd, 0xce, 0xd6, 0xb7, 0x3b, 0x5b, 0xff, 0xbf, 0xb3, 0xf5, 0xdf, 0x7b, 0x5b, 0xdb, 0xee, - 0x6d, 0xed, 0xef, 0xde, 0xd6, 0xbe, 0xbd, 0x89, 0xb1, 0x98, 0xa7, 0x81, 0x1b, 0x92, 0x95, 0x17, - 0xac, 0xd1, 0x5b, 0xb8, 0xa4, 0x73, 0x28, 0x10, 0x94, 0x27, 0xef, 0xa7, 0x77, 0x7c, 0xb7, 0xbf, - 0x28, 0xe2, 0x81, 0x21, 0x5f, 0xe1, 0xfb, 0xfb, 0x00, 0x00, 0x00, 0xff, 0xff, 0x07, 0xd5, 0x14, - 0x50, 0x40, 0x04, 0x00, 0x00, + // 546 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x94, 0xc1, 0x6e, 0xd3, 0x30, + 0x18, 0xc7, 0x1b, 0x56, 0x0a, 0xb8, 0x03, 0x89, 0xb2, 0xb1, 0xaa, 0xdb, 0xb2, 0x32, 0x89, 0x91, + 0x03, 0x24, 0x62, 0x20, 0x1e, 0x60, 0x13, 0xa0, 0x49, 0x20, 0x55, 0x2d, 0x5c, 0xb8, 0x04, 0x27, + 0xb1, 0x32, 0xab, 0x6d, 0x1c, 0xd9, 0x5f, 0xc7, 0xd8, 0x05, 0xf1, 0x06, 0x3c, 0x02, 0x8f, 0xb3, + 0xe3, 0x8e, 0x9c, 0x10, 0x6a, 0x5f, 0x04, 0xcd, 0x76, 0xda, 0x39, 0x75, 0x26, 0xc4, 0x2d, 0xce, + 0xff, 0xfb, 0x7f, 0xbf, 0xef, 0xef, 0x38, 0x46, 0xeb, 0x9c, 0x7c, 0xc1, 0x3c, 0x11, 0x41, 0x4a, + 0x32, 0x22, 0xa8, 0xf0, 0x73, 0xce, 0x80, 0xb5, 0xee, 0x45, 0x67, 0xc4, 0x3f, 0x79, 0xee, 0x6b, + 0xb5, 0xb3, 0x96, 0xb2, 0x94, 0x49, 0x29, 0xb8, 0x7c, 0x52, 0x55, 0x9d, 0xb5, 0xc2, 0x9c, 0x63, + 0x8e, 0xc7, 0xda, 0xdb, 0xd9, 0x2a, 0xde, 0x0a, 0xc0, 0x43, 0x9a, 0xa5, 0xa1, 0x5a, 0x97, 0x55, + 0xe0, 0x38, 0x59, 0x52, 0x3d, 0xbb, 0x37, 0xcc, 0x31, 0x07, 0x1a, 0xd3, 0x1c, 0x67, 0xa0, 0x2a, + 0x77, 0x7f, 0x22, 0xb4, 0xfa, 0x56, 0xcd, 0x3c, 0x00, 0x0c, 0xa4, 0xf5, 0x12, 0x35, 0xd4, 0x18, + 0x6d, 0xa7, 0xeb, 0x78, 0xcd, 0xfd, 0x87, 0xbe, 0x99, 0xc1, 0xef, 0x49, 0xf5, 0xa0, 0x7e, 0xfe, + 0x7b, 0xa7, 0xd6, 0xd7, 0xb5, 0xad, 0x01, 0x7a, 0x50, 0x42, 0x8d, 0xa8, 0x80, 0xf6, 0x8d, 0xee, + 0x8a, 0xd7, 0xdc, 0xdf, 0x2e, 0xb7, 0x18, 0xa8, 0xd2, 0xbe, 0x5c, 0xea, 0x4e, 0xf7, 0xc5, 0xd5, + 0x97, 0xef, 0xa8, 0x80, 0xd6, 0x2b, 0xb4, 0x61, 0x36, 0x15, 0x61, 0xcc, 0x26, 0x19, 0x10, 0xde, + 0x5e, 0xe9, 0x3a, 0x5e, 0xbd, 0xbf, 0x6e, 0x78, 0xc4, 0xa1, 0x12, 0x2f, 0x7d, 0xe6, 0xae, 0x2c, + 0x7c, 0x75, 0xe5, 0xd3, 0x72, 0xc9, 0xf7, 0x19, 0x75, 0x70, 0x0c, 0xf4, 0x84, 0x84, 0xa6, 0x5d, + 0x65, 0xb9, 0x69, 0xcf, 0xf2, 0xe1, 0x6a, 0x2b, 0x9d, 0x65, 0x43, 0xb5, 0x31, 0x24, 0x99, 0x28, + 0x42, 0x9b, 0x39, 0xc9, 0x64, 0x6b, 0x1b, 0xa2, 0xf1, 0xef, 0x88, 0xb6, 0xee, 0xb3, 0xcc, 0x98, + 0xa0, 0x9d, 0xea, 0xaf, 0xae, 0x38, 0xb7, 0x24, 0xc7, 0xbb, 0xf6, 0xb3, 0xf4, 0x16, 0x26, 0x8d, + 0xdc, 0x12, 0x15, 0x7a, 0x81, 0x2d, 0xa2, 0x4d, 0xb2, 0x11, 0x8b, 0x87, 0xcb, 0xd8, 0xdb, 0x76, + 0x6c, 0x4f, 0xd9, 0x3e, 0x4a, 0x97, 0x05, 0x9b, 0x57, 0xe8, 0x05, 0xb6, 0xbc, 0x93, 0x04, 0x27, + 0x84, 0x47, 0x6c, 0xbe, 0xab, 0x77, 0xec, 0x58, 0x73, 0xe7, 0x16, 0xa6, 0x02, 0x0b, 0x15, 0xba, + 0xc4, 0x32, 0xb4, 0x5d, 0xc2, 0xc6, 0x38, 0x4b, 0x68, 0x82, 0x81, 0x28, 0x28, 0x92, 0xd0, 0xbd, + 0x6b, 0xa1, 0x87, 0x85, 0x45, 0x23, 0x3b, 0x60, 0x55, 0x25, 0x10, 0x50, 0x77, 0x8c, 0xf9, 0x90, + 0x40, 0x48, 0x93, 0xf2, 0xd9, 0xa1, 0x3a, 0x68, 0x53, 0x32, 0x9f, 0x94, 0x99, 0xef, 0xa5, 0xef, + 0x28, 0x31, 0xd8, 0x47, 0x45, 0xce, 0xcd, 0xb1, 0x5d, 0x96, 0xd4, 0xef, 0x0e, 0xda, 0xab, 0x38, + 0xb0, 0xe4, 0x34, 0xa7, 0x1c, 0x03, 0x65, 0x99, 0x82, 0xaf, 0xda, 0xe1, 0x46, 0xd7, 0xd7, 0x73, + 0x8f, 0x86, 0xef, 0xda, 0x4e, 0xf1, 0xa2, 0x4a, 0xce, 0xf0, 0x0d, 0x3d, 0xb6, 0xff, 0x95, 0xe5, + 0x09, 0xee, 0xfe, 0xcf, 0x04, 0x8f, 0x2c, 0xbf, 0xaa, 0x39, 0xc0, 0xc1, 0x9b, 0xf3, 0xa9, 0xeb, + 0x5c, 0x4c, 0x5d, 0xe7, 0xcf, 0xd4, 0x75, 0x7e, 0xcc, 0xdc, 0xda, 0xc5, 0xcc, 0xad, 0xfd, 0x9a, + 0xb9, 0xb5, 0x4f, 0x4f, 0x53, 0x0a, 0xc7, 0x93, 0xc8, 0x8f, 0xd9, 0x38, 0x88, 0xce, 0xc8, 0x33, + 0x3c, 0xca, 0x8f, 0x31, 0x10, 0x2c, 0x57, 0xc1, 0x69, 0x30, 0xbf, 0xa3, 0xbf, 0xe6, 0x44, 0x44, + 0x0d, 0x79, 0xe3, 0xbe, 0xf8, 0x1b, 0x00, 0x00, 0xff, 0xff, 0x64, 0x66, 0x31, 0xf2, 0x2c, 0x06, + 0x00, 0x00, } func (m *GenesisState) Marshal() (dAtA []byte, err error) { @@ -190,6 +229,48 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.ActiveTradingRewardExpirationList) > 0 { + for iNdEx := len(m.ActiveTradingRewardExpirationList) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.ActiveTradingRewardExpirationList[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x6a + } + } + if len(m.PendingTradingRewardExpirationList) > 0 { + for iNdEx := len(m.PendingTradingRewardExpirationList) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.PendingTradingRewardExpirationList[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x62 + } + } + if len(m.MarketIdTradingRewardIdList) > 0 { + for iNdEx := len(m.MarketIdTradingRewardIdList) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.MarketIdTradingRewardIdList[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x5a + } + } if len(m.TradingRewardCandidateList) > 0 { for iNdEx := len(m.TradingRewardCandidateList) - 1; iNdEx >= 0; iNdEx-- { { @@ -201,7 +282,7 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintGenesis(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x4a + dAtA[i] = 0x52 } } if len(m.TradingRewardLeaderboardList) > 0 { @@ -215,7 +296,7 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintGenesis(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x42 + dAtA[i] = 0x4a } } if len(m.PendingUnlockParticipantList) > 0 { @@ -229,7 +310,7 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintGenesis(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x3a + dAtA[i] = 0x42 } } if len(m.StakingRewardParticipantList) > 0 { @@ -243,13 +324,27 @@ func (m *GenesisState) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintGenesis(dAtA, i, uint64(size)) } i-- + dAtA[i] = 0x3a + } + } + if len(m.PendingTradingRewardList) > 0 { + for iNdEx := len(m.PendingTradingRewardList) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.PendingTradingRewardList[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintGenesis(dAtA, i, uint64(size)) + } + i-- dAtA[i] = 0x32 } } - if len(m.TradingRewardList) > 0 { - for iNdEx := len(m.TradingRewardList) - 1; iNdEx >= 0; iNdEx-- { + if len(m.ActiveTradingRewardList) > 0 { + for iNdEx := len(m.ActiveTradingRewardList) - 1; iNdEx >= 0; iNdEx-- { { - size, err := m.TradingRewardList[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + size, err := m.ActiveTradingRewardList[iNdEx].MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -328,8 +423,14 @@ func (m *GenesisState) Size() (n int) { if m.TradingRewardsCounter != 0 { n += 1 + sovGenesis(uint64(m.TradingRewardsCounter)) } - if len(m.TradingRewardList) > 0 { - for _, e := range m.TradingRewardList { + if len(m.ActiveTradingRewardList) > 0 { + for _, e := range m.ActiveTradingRewardList { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if len(m.PendingTradingRewardList) > 0 { + for _, e := range m.PendingTradingRewardList { l = e.Size() n += 1 + l + sovGenesis(uint64(l)) } @@ -358,6 +459,24 @@ func (m *GenesisState) Size() (n int) { n += 1 + l + sovGenesis(uint64(l)) } } + if len(m.MarketIdTradingRewardIdList) > 0 { + for _, e := range m.MarketIdTradingRewardIdList { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if len(m.PendingTradingRewardExpirationList) > 0 { + for _, e := range m.PendingTradingRewardExpirationList { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } + if len(m.ActiveTradingRewardExpirationList) > 0 { + for _, e := range m.ActiveTradingRewardExpirationList { + l = e.Size() + n += 1 + l + sovGenesis(uint64(l)) + } + } return n } @@ -503,7 +622,7 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { } case 5: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field TradingRewardList", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field ActiveTradingRewardList", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -530,12 +649,46 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.TradingRewardList = append(m.TradingRewardList, TradingReward{}) - if err := m.TradingRewardList[len(m.TradingRewardList)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + m.ActiveTradingRewardList = append(m.ActiveTradingRewardList, TradingReward{}) + if err := m.ActiveTradingRewardList[len(m.ActiveTradingRewardList)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PendingTradingRewardList", 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 + } + m.PendingTradingRewardList = append(m.PendingTradingRewardList, TradingReward{}) + if err := m.PendingTradingRewardList[len(m.PendingTradingRewardList)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 7: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field StakingRewardParticipantList", wireType) } @@ -569,7 +722,7 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 7: + case 8: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field PendingUnlockParticipantList", wireType) } @@ -603,7 +756,7 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 8: + case 9: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field TradingRewardLeaderboardList", wireType) } @@ -637,7 +790,7 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 9: + case 10: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field TradingRewardCandidateList", wireType) } @@ -671,6 +824,108 @@ func (m *GenesisState) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 11: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MarketIdTradingRewardIdList", 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 + } + m.MarketIdTradingRewardIdList = append(m.MarketIdTradingRewardIdList, MarketIdTradingRewardId{}) + if err := m.MarketIdTradingRewardIdList[len(m.MarketIdTradingRewardIdList)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 12: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PendingTradingRewardExpirationList", 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 + } + m.PendingTradingRewardExpirationList = append(m.PendingTradingRewardExpirationList, TradingRewardExpiration{}) + if err := m.PendingTradingRewardExpirationList[len(m.PendingTradingRewardExpirationList)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 13: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ActiveTradingRewardExpirationList", 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 + } + m.ActiveTradingRewardExpirationList = append(m.ActiveTradingRewardExpirationList, TradingRewardExpiration{}) + if err := m.ActiveTradingRewardExpirationList[len(m.ActiveTradingRewardExpirationList)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipGenesis(dAtA[iNdEx:]) diff --git a/x/rewards/types/key_staking_reward.go b/x/rewards/types/key_staking_reward.go index d701a274..f84e7314 100644 --- a/x/rewards/types/key_staking_reward.go +++ b/x/rewards/types/key_staking_reward.go @@ -12,7 +12,7 @@ const ( // StakingRewardKey returns the store key to retrieve a StakingReward from the index fields func StakingRewardKey(rewardId string) []byte { - return []byte(rewardId) + return []byte(rewardId + "/") } func StakingRewardCounterKey() []byte { diff --git a/x/rewards/types/key_staking_reward_participant.go b/x/rewards/types/key_staking_reward_participant.go index c42b8894..d57bd75c 100644 --- a/x/rewards/types/key_staking_reward_participant.go +++ b/x/rewards/types/key_staking_reward_participant.go @@ -11,7 +11,7 @@ const ( // StakingRewardParticipantKey returns the store key to retrieve a StakingRewardParticipant from the index fields func StakingRewardParticipantKey(address, rewardId string) []byte { - return []byte(address + "/" + rewardId) + return []byte(address + "/" + rewardId + "/") } // StakingRewardParticipantPrefix returns the store prefix key to retrieve a StakingRewardParticipant for an address diff --git a/x/rewards/types/key_trading_reward.go b/x/rewards/types/key_trading_reward.go index df38a8a9..7ecb6783 100644 --- a/x/rewards/types/key_trading_reward.go +++ b/x/rewards/types/key_trading_reward.go @@ -8,16 +8,19 @@ import ( var _ binary.ByteOrder const ( - // TradingRewardKeyPrefix is the prefix to retrieve all TradingReward - TradingRewardKeyPrefix = "tr/value/" + // PendingTradingRewardKeyPrefix is the prefix to retrieve all pending TradingReward + PendingTradingRewardKeyPrefix = "tr/v/p/" + // ActiveTradingRewardKeyPrefix is the prefix to retrieve all active TradingReward + ActiveTradingRewardKeyPrefix = "tr/v/a/" // MarketIdRewardIdKeyPrefix is the prefix to retrieve a reward id for a market id MarketIdRewardIdKeyPrefix = "tr/mr/" // LeaderboardKeyPrefix is the prefix of a leaderboard for a trading reward LeaderboardKeyPrefix = "tr/lb/" // RewardCandidateKeyPrefix prefix that holds entries/participants for trading rewards RewardCandidateKeyPrefix = "tr/r/" - // TradingRewardExpirationKeyPrefix - the prefix used to save trading reward expiration - TradingRewardExpirationKeyPrefix = "tr/exp/" + // PendingTradingRewardExpirationKeyPrefix - the prefix used to save trading reward expiration + PendingTradingRewardExpirationKeyPrefix = "tr/exp/p/" + ActiveTradingRewardExpirationKeyPrefix = "tr/exp/a/" ) // TradingRewardCandidateKey returns the store key to retrieve a reward candidate diff --git a/x/rewards/types/trading_reward.pb.go b/x/rewards/types/trading_reward.pb.go index 93de07ea..5811a8b8 100644 --- a/x/rewards/types/trading_reward.pb.go +++ b/x/rewards/types/trading_reward.pb.go @@ -339,45 +339,99 @@ func (m *TradingRewardCandidate) GetAddress() string { return "" } +type MarketIdTradingRewardId struct { + RewardId string `protobuf:"bytes,1,opt,name=reward_id,json=rewardId,proto3" json:"reward_id,omitempty"` + MarketId string `protobuf:"bytes,2,opt,name=market_id,json=marketId,proto3" json:"market_id,omitempty"` +} + +func (m *MarketIdTradingRewardId) Reset() { *m = MarketIdTradingRewardId{} } +func (m *MarketIdTradingRewardId) String() string { return proto.CompactTextString(m) } +func (*MarketIdTradingRewardId) ProtoMessage() {} +func (*MarketIdTradingRewardId) Descriptor() ([]byte, []int) { + return fileDescriptor_e96afcb90471b82d, []int{5} +} +func (m *MarketIdTradingRewardId) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MarketIdTradingRewardId) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MarketIdTradingRewardId.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 *MarketIdTradingRewardId) XXX_Merge(src proto.Message) { + xxx_messageInfo_MarketIdTradingRewardId.Merge(m, src) +} +func (m *MarketIdTradingRewardId) XXX_Size() int { + return m.Size() +} +func (m *MarketIdTradingRewardId) XXX_DiscardUnknown() { + xxx_messageInfo_MarketIdTradingRewardId.DiscardUnknown(m) +} + +var xxx_messageInfo_MarketIdTradingRewardId proto.InternalMessageInfo + +func (m *MarketIdTradingRewardId) GetRewardId() string { + if m != nil { + return m.RewardId + } + return "" +} + +func (m *MarketIdTradingRewardId) GetMarketId() string { + if m != nil { + return m.MarketId + } + return "" +} + func init() { proto.RegisterType((*TradingReward)(nil), "bze.v1.rewards.TradingReward") proto.RegisterType((*TradingRewardExpiration)(nil), "bze.v1.rewards.TradingRewardExpiration") proto.RegisterType((*TradingRewardLeaderboard)(nil), "bze.v1.rewards.TradingRewardLeaderboard") proto.RegisterType((*TradingRewardLeaderboardEntry)(nil), "bze.v1.rewards.TradingRewardLeaderboardEntry") proto.RegisterType((*TradingRewardCandidate)(nil), "bze.v1.rewards.TradingRewardCandidate") + proto.RegisterType((*MarketIdTradingRewardId)(nil), "bze.v1.rewards.MarketIdTradingRewardId") } func init() { proto.RegisterFile("rewards/trading_reward.proto", fileDescriptor_e96afcb90471b82d) } var fileDescriptor_e96afcb90471b82d = []byte{ - // 424 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x53, 0xc1, 0x6e, 0xd3, 0x40, - 0x10, 0xf5, 0xc6, 0x69, 0xda, 0x4c, 0x29, 0x87, 0x55, 0x55, 0x56, 0x85, 0xba, 0xc5, 0xa7, 0x1c, - 0xa8, 0x2d, 0xe0, 0x0b, 0x52, 0x28, 0xa8, 0x12, 0x27, 0xc3, 0x89, 0x8b, 0xb5, 0xee, 0x8e, 0xdc, - 0x15, 0xb1, 0xd7, 0x5a, 0x6f, 0xa0, 0xcd, 0x89, 0x4f, 0xe0, 0xb3, 0x7a, 0xec, 0x91, 0x03, 0x42, - 0x28, 0xf9, 0x11, 0xb4, 0xbb, 0x26, 0xc8, 0x48, 0x29, 0x37, 0xbf, 0x37, 0x6f, 0xde, 0x9b, 0xf1, - 0xd8, 0xf0, 0x44, 0xe3, 0x17, 0xae, 0x45, 0x9b, 0x1a, 0xcd, 0x85, 0xac, 0xcb, 0xdc, 0xe3, 0xa4, - 0xd1, 0xca, 0x28, 0xfa, 0xb0, 0x58, 0x60, 0xf2, 0xf9, 0x79, 0xd2, 0x89, 0x0e, 0xf7, 0x4b, 0x55, - 0x2a, 0x57, 0x4a, 0xed, 0x93, 0x57, 0xc5, 0x3f, 0x08, 0xec, 0x7d, 0xf0, 0xed, 0x99, 0x13, 0xd2, - 0xc7, 0x30, 0xf6, 0x2d, 0xb9, 0x14, 0x8c, 0x9c, 0x90, 0xc9, 0x38, 0xdb, 0xf1, 0xc4, 0x85, 0xa0, - 0x4f, 0xe1, 0x41, 0xa3, 0xe5, 0x02, 0x73, 0x5e, 0xa9, 0x79, 0x6d, 0xd8, 0xc0, 0xd5, 0x77, 0x1d, - 0x37, 0x75, 0x14, 0x3d, 0x06, 0x0f, 0x73, 0x81, 0xb5, 0xaa, 0x58, 0xe8, 0x14, 0xe0, 0xa8, 0xd7, - 0x96, 0xa1, 0x87, 0xb0, 0x23, 0xe6, 0x9a, 0x1b, 0xa9, 0x6a, 0x36, 0x3c, 0x21, 0x93, 0xbd, 0x6c, - 0x8d, 0x6d, 0x78, 0xc5, 0xf5, 0x27, 0x34, 0x36, 0x7c, 0xcb, 0x87, 0x7b, 0xe2, 0x42, 0xd0, 0x7d, - 0xd8, 0x6a, 0x67, 0xca, 0xb4, 0x6c, 0xe4, 0xba, 0x3c, 0xb0, 0x2d, 0x78, 0xdd, 0x48, 0x8d, 0x39, - 0x37, 0x6c, 0xdb, 0xfb, 0x79, 0x62, 0x6a, 0xe2, 0xf7, 0xf0, 0xa8, 0xb7, 0xdd, 0xb9, 0x2d, 0xac, - 0xa3, 0x36, 0xef, 0xd9, 0x33, 0x1d, 0xfc, 0x63, 0xfa, 0x95, 0x00, 0xeb, 0xb9, 0xbe, 0x43, 0x2e, - 0x50, 0x17, 0xea, 0xbf, 0xaf, 0xef, 0x2d, 0x0c, 0x67, 0xb2, 0xb5, 0x8e, 0xe1, 0x64, 0xf7, 0xc5, - 0x69, 0xd2, 0x3f, 0x51, 0xb2, 0xc9, 0xf4, 0xbc, 0x36, 0xfa, 0xe6, 0x6c, 0x78, 0xfb, 0xf3, 0x38, - 0xc8, 0x9c, 0x41, 0xdc, 0xc0, 0xd1, 0xbd, 0x62, 0x7a, 0x00, 0xa3, 0xee, 0x44, 0x7e, 0x86, 0x0e, - 0x51, 0x06, 0xdb, 0x5c, 0x08, 0x8d, 0x6d, 0xdb, 0xdd, 0xee, 0x0f, 0xa4, 0x47, 0x00, 0x97, 0x1a, - 0xb9, 0x41, 0x61, 0x77, 0xb6, 0x67, 0x0b, 0xb3, 0x71, 0xc7, 0x4c, 0x4d, 0x5c, 0xc2, 0x41, 0x2f, - 0xf1, 0x15, 0xaf, 0x85, 0x14, 0xdc, 0xe0, 0xfd, 0x1b, 0xff, 0x9d, 0x63, 0xb0, 0x69, 0x8e, 0xb0, - 0x37, 0xc7, 0xd9, 0x9b, 0xdb, 0x65, 0x44, 0xee, 0x96, 0x11, 0xf9, 0xb5, 0x8c, 0xc8, 0xb7, 0x55, - 0x14, 0xdc, 0xad, 0xa2, 0xe0, 0xfb, 0x2a, 0x0a, 0x3e, 0x3e, 0x2b, 0xa5, 0xb9, 0x9a, 0x17, 0xc9, - 0xa5, 0xaa, 0xd2, 0x62, 0x81, 0xa7, 0x7c, 0xd6, 0x5c, 0x71, 0x83, 0xdc, 0xa1, 0xf4, 0x3a, 0x5d, - 0xff, 0x0e, 0x37, 0x0d, 0xb6, 0xc5, 0xc8, 0x7d, 0xe0, 0x2f, 0x7f, 0x07, 0x00, 0x00, 0xff, 0xff, - 0x32, 0x24, 0xaa, 0x45, 0x26, 0x03, 0x00, 0x00, + // 442 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x53, 0xc1, 0x6e, 0x13, 0x31, + 0x10, 0x8d, 0x93, 0x34, 0x6d, 0xa6, 0x94, 0x83, 0x55, 0x15, 0xab, 0xd0, 0x6d, 0xc9, 0x29, 0x07, + 0xba, 0x2b, 0xe0, 0x0b, 0x52, 0x28, 0x28, 0x12, 0x5c, 0x16, 0x4e, 0x5c, 0x56, 0xde, 0x7a, 0xb4, + 0xb5, 0x48, 0xd6, 0x2b, 0xaf, 0x03, 0x6d, 0x4e, 0x7c, 0x02, 0x9f, 0xd5, 0x63, 0x8f, 0x1c, 0x10, + 0x42, 0xc9, 0x8f, 0x20, 0xdb, 0x4b, 0x2a, 0x57, 0x4a, 0x73, 0xdb, 0xf7, 0x3c, 0xf3, 0xde, 0xcc, + 0x3e, 0x1b, 0x9e, 0x69, 0xfc, 0xce, 0xb5, 0xa8, 0x13, 0xa3, 0xb9, 0x90, 0x65, 0x91, 0x79, 0x1c, + 0x57, 0x5a, 0x19, 0x45, 0x1f, 0xe7, 0x73, 0x8c, 0xbf, 0xbd, 0x8c, 0x9b, 0xa2, 0xc3, 0xfd, 0x42, + 0x15, 0xca, 0x1d, 0x25, 0xf6, 0xcb, 0x57, 0x0d, 0x7e, 0x13, 0xd8, 0xfb, 0xec, 0xdb, 0x53, 0x57, + 0x48, 0x9f, 0x42, 0xdf, 0xb7, 0x64, 0x52, 0x30, 0x72, 0x42, 0x86, 0xfd, 0x74, 0xc7, 0x13, 0x63, + 0x41, 0x9f, 0xc3, 0xa3, 0x4a, 0xcb, 0x39, 0x66, 0x7c, 0xaa, 0x66, 0xa5, 0x61, 0x6d, 0x77, 0xbe, + 0xeb, 0xb8, 0x91, 0xa3, 0xe8, 0x31, 0x78, 0x98, 0x09, 0x2c, 0xd5, 0x94, 0x75, 0x5c, 0x05, 0x38, + 0xea, 0xad, 0x65, 0xe8, 0x21, 0xec, 0x88, 0x99, 0xe6, 0x46, 0xaa, 0x92, 0x75, 0x4f, 0xc8, 0x70, + 0x2f, 0x5d, 0x61, 0x6b, 0x3e, 0xe5, 0xfa, 0x2b, 0x1a, 0x6b, 0xbe, 0xe5, 0xcd, 0x3d, 0x31, 0x16, + 0x74, 0x1f, 0xb6, 0xea, 0x89, 0x32, 0x35, 0xeb, 0xb9, 0x2e, 0x0f, 0x6c, 0x0b, 0x5e, 0x55, 0x52, + 0x63, 0xc6, 0x0d, 0xdb, 0xf6, 0x7a, 0x9e, 0x18, 0x99, 0xc1, 0x27, 0x78, 0x12, 0x6c, 0x77, 0x6e, + 0x0f, 0x56, 0x56, 0xeb, 0xf7, 0x0c, 0x44, 0xdb, 0xf7, 0x44, 0x7f, 0x10, 0x60, 0x81, 0xea, 0x07, + 0xe4, 0x02, 0x75, 0xae, 0x36, 0xfe, 0xbe, 0xf7, 0xd0, 0x9d, 0xc8, 0xda, 0x2a, 0x76, 0x86, 0xbb, + 0xaf, 0x4e, 0xe3, 0x30, 0xa2, 0x78, 0x9d, 0xe8, 0x79, 0x69, 0xf4, 0xf5, 0x59, 0xf7, 0xe6, 0xcf, + 0x71, 0x2b, 0x75, 0x02, 0x83, 0x0a, 0x8e, 0x1e, 0x2c, 0xa6, 0x07, 0xd0, 0x6b, 0x22, 0xf2, 0x33, + 0x34, 0x88, 0x32, 0xd8, 0xe6, 0x42, 0x68, 0xac, 0xeb, 0x26, 0xbb, 0xff, 0x90, 0x1e, 0x01, 0x5c, + 0x68, 0xe4, 0x06, 0x85, 0xdd, 0xd9, 0xc6, 0xd6, 0x49, 0xfb, 0x0d, 0x33, 0x32, 0x83, 0x02, 0x0e, + 0x02, 0xc7, 0x37, 0xbc, 0x14, 0x52, 0x70, 0x83, 0x0f, 0x6f, 0x7c, 0x37, 0x47, 0x7b, 0xdd, 0x1c, + 0x9d, 0x60, 0x0e, 0x1b, 0xd9, 0xc7, 0x26, 0xf1, 0xc0, 0x70, 0x2c, 0x36, 0x46, 0x76, 0x77, 0x75, + 0xda, 0xe1, 0xd5, 0x39, 0x7b, 0x77, 0xb3, 0x88, 0xc8, 0xed, 0x22, 0x22, 0x7f, 0x17, 0x11, 0xf9, + 0xb9, 0x8c, 0x5a, 0xb7, 0xcb, 0xa8, 0xf5, 0x6b, 0x19, 0xb5, 0xbe, 0xbc, 0x28, 0xa4, 0xb9, 0x9c, + 0xe5, 0xf1, 0x85, 0x9a, 0x26, 0xf9, 0x1c, 0x4f, 0xf9, 0xa4, 0xba, 0xe4, 0x06, 0xb9, 0x43, 0xc9, + 0x55, 0xb2, 0x7a, 0x63, 0xd7, 0x15, 0xd6, 0x79, 0xcf, 0xbd, 0x9a, 0xd7, 0xff, 0x02, 0x00, 0x00, + 0xff, 0xff, 0x66, 0x54, 0xef, 0x9a, 0x7b, 0x03, 0x00, 0x00, } func (m *TradingReward) Marshal() (dAtA []byte, err error) { @@ -611,6 +665,43 @@ func (m *TradingRewardCandidate) MarshalToSizedBuffer(dAtA []byte) (int, error) return len(dAtA) - i, nil } +func (m *MarketIdTradingRewardId) 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 *MarketIdTradingRewardId) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MarketIdTradingRewardId) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.MarketId) > 0 { + i -= len(m.MarketId) + copy(dAtA[i:], m.MarketId) + i = encodeVarintTradingReward(dAtA, i, uint64(len(m.MarketId))) + i-- + dAtA[i] = 0x12 + } + if len(m.RewardId) > 0 { + i -= len(m.RewardId) + copy(dAtA[i:], m.RewardId) + i = encodeVarintTradingReward(dAtA, i, uint64(len(m.RewardId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func encodeVarintTradingReward(dAtA []byte, offset int, v uint64) int { offset -= sovTradingReward(v) base := offset @@ -732,6 +823,23 @@ func (m *TradingRewardCandidate) Size() (n int) { return n } +func (m *MarketIdTradingRewardId) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.RewardId) + if l > 0 { + n += 1 + l + sovTradingReward(uint64(l)) + } + l = len(m.MarketId) + if l > 0 { + n += 1 + l + sovTradingReward(uint64(l)) + } + return n +} + func sovTradingReward(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -1469,6 +1577,120 @@ func (m *TradingRewardCandidate) Unmarshal(dAtA []byte) error { } return nil } +func (m *MarketIdTradingRewardId) 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 ErrIntOverflowTradingReward + } + 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: MarketIdTradingRewardId: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MarketIdTradingRewardId: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RewardId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTradingReward + } + 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 ErrInvalidLengthTradingReward + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTradingReward + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.RewardId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MarketId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTradingReward + } + 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 ErrInvalidLengthTradingReward + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTradingReward + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.MarketId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTradingReward(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTradingReward + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipTradingReward(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 From 7416b2dc1b65d1c13ee020d7e6b5636b4f1e706a Mon Sep 17 00:00:00 2001 From: faneaatiku Date: Wed, 27 Mar 2024 00:01:18 +0200 Subject: [PATCH 18/35] fixed staking reward removal at last exit --- x/rewards/keeper/msg_server_exit_staking.go | 5 ++++- x/rewards/keeper/staking_reward_distribution.go | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/x/rewards/keeper/msg_server_exit_staking.go b/x/rewards/keeper/msg_server_exit_staking.go index 35e3d759..6f89db7f 100644 --- a/x/rewards/keeper/msg_server_exit_staking.go +++ b/x/rewards/keeper/msg_server_exit_staking.go @@ -46,7 +46,10 @@ func (k msgServer) ExitStaking(goCtx context.Context, msg *types.MsgExitStaking) stakingReward.StakedAmount = remainingStakedAmount.String() k.SetStakingReward(ctx, stakingReward) } else { - k.RemoveStakingReward(ctx, stakingReward.RewardId) + //if this staking reward is finished (all funds were distributed and payouts executed) we should remove it + if stakingReward.Payouts >= stakingReward.Duration { + k.RemoveStakingReward(ctx, stakingReward.RewardId) + } } return &types.MsgExitStakingResponse{}, nil diff --git a/x/rewards/keeper/staking_reward_distribution.go b/x/rewards/keeper/staking_reward_distribution.go index 1cfe8616..becd4b58 100644 --- a/x/rewards/keeper/staking_reward_distribution.go +++ b/x/rewards/keeper/staking_reward_distribution.go @@ -25,7 +25,7 @@ func (k Keeper) getDistributeRewardHandler() func(ctx sdk.Context, reward types. err := k.distributeStakingRewards(&sr, sr.PrizeAmount) if err != nil { logger.Error(err.Error()) - stop = true + stop = false return } From 4859465d043dbbb019b14b9af5dce35c026e0a20 Mon Sep 17 00:00:00 2001 From: faneaatiku Date: Wed, 27 Mar 2024 00:10:11 +0200 Subject: [PATCH 19/35] fix min staking amount check --- x/rewards/keeper/msg_server_join_staking.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/x/rewards/keeper/msg_server_join_staking.go b/x/rewards/keeper/msg_server_join_staking.go index 0d3f33b3..e0d515e8 100644 --- a/x/rewards/keeper/msg_server_join_staking.go +++ b/x/rewards/keeper/msg_server_join_staking.go @@ -38,6 +38,11 @@ func (k msgServer) JoinStaking(goCtx context.Context, msg *types.MsgJoinStaking) return nil, err } + //check if min stake requirement is met + if toCapture.AmountOf(stakingReward.StakingDenom).LT(sdk.NewIntFromUint64(stakingReward.MinStake)) { + return nil, fmt.Errorf("amount is smaller than staking reward min stake") + } + if err = k.checkUserBalances(ctx, toCapture, acc); err != nil { return nil, err } From 5bb41b77660b7617d6ecf51cc9694a31977fefd5 Mon Sep 17 00:00:00 2001 From: faneaatiku Date: Wed, 27 Mar 2024 01:25:33 +0200 Subject: [PATCH 20/35] validate genesis on rewards module --- .../generated/bze.tokenfactory.v1/index.ts | 64 ++++++------- .../store/generated/bze.tradebin.v1/index.ts | 32 +++---- .../store/generated/bze.v1.rewards/index.ts | 90 +++++++++---------- x/rewards/types/genesis.go | 67 +++++++++++++- 4 files changed, 158 insertions(+), 95 deletions(-) diff --git a/vue/src/store/generated/bze.tokenfactory.v1/index.ts b/vue/src/store/generated/bze.tokenfactory.v1/index.ts index 6ca4a9d5..ceb33976 100755 --- a/vue/src/store/generated/bze.tokenfactory.v1/index.ts +++ b/vue/src/store/generated/bze.tokenfactory.v1/index.ts @@ -165,42 +165,42 @@ export default { }, - async sendMsgMint({ rootGetters }, { value, fee = [], memo = '' }) { + async sendMsgBurn({ rootGetters }, { value, fee = [], memo = '' }) { try { const client=await initClient(rootGetters) - const result = await client.BzeTokenfactoryV1.tx.sendMsgMint({ value, fee: {amount: fee, gas: "200000"}, memo }) + const result = await client.BzeTokenfactoryV1.tx.sendMsgBurn({ value, fee: {amount: fee, gas: "200000"}, memo }) return result } catch (e) { if (e == MissingWalletError) { - throw new Error('TxClient:MsgMint:Init Could not initialize signing client. Wallet is required.') + throw new Error('TxClient:MsgBurn:Init Could not initialize signing client. Wallet is required.') }else{ - throw new Error('TxClient:MsgMint:Send Could not broadcast Tx: '+ e.message) + throw new Error('TxClient:MsgBurn:Send Could not broadcast Tx: '+ e.message) } } }, - async sendMsgBurn({ rootGetters }, { value, fee = [], memo = '' }) { + async sendMsgChangeAdmin({ rootGetters }, { value, fee = [], memo = '' }) { try { const client=await initClient(rootGetters) - const result = await client.BzeTokenfactoryV1.tx.sendMsgBurn({ value, fee: {amount: fee, gas: "200000"}, memo }) + const result = await client.BzeTokenfactoryV1.tx.sendMsgChangeAdmin({ value, fee: {amount: fee, gas: "200000"}, memo }) return result } catch (e) { if (e == MissingWalletError) { - throw new Error('TxClient:MsgBurn:Init Could not initialize signing client. Wallet is required.') + throw new Error('TxClient:MsgChangeAdmin:Init Could not initialize signing client. Wallet is required.') }else{ - throw new Error('TxClient:MsgBurn:Send Could not broadcast Tx: '+ e.message) + throw new Error('TxClient:MsgChangeAdmin:Send Could not broadcast Tx: '+ e.message) } } }, - async sendMsgSetDenomMetadata({ rootGetters }, { value, fee = [], memo = '' }) { + async sendMsgMint({ rootGetters }, { value, fee = [], memo = '' }) { try { const client=await initClient(rootGetters) - const result = await client.BzeTokenfactoryV1.tx.sendMsgSetDenomMetadata({ value, fee: {amount: fee, gas: "200000"}, memo }) + const result = await client.BzeTokenfactoryV1.tx.sendMsgMint({ value, fee: {amount: fee, gas: "200000"}, memo }) return result } catch (e) { if (e == MissingWalletError) { - throw new Error('TxClient:MsgSetDenomMetadata:Init Could not initialize signing client. Wallet is required.') + throw new Error('TxClient:MsgMint:Init Could not initialize signing client. Wallet is required.') }else{ - throw new Error('TxClient:MsgSetDenomMetadata:Send Could not broadcast Tx: '+ e.message) + throw new Error('TxClient:MsgMint:Send Could not broadcast Tx: '+ e.message) } } }, @@ -217,56 +217,56 @@ export default { } } }, - async sendMsgChangeAdmin({ rootGetters }, { value, fee = [], memo = '' }) { + async sendMsgSetDenomMetadata({ rootGetters }, { value, fee = [], memo = '' }) { try { const client=await initClient(rootGetters) - const result = await client.BzeTokenfactoryV1.tx.sendMsgChangeAdmin({ value, fee: {amount: fee, gas: "200000"}, memo }) + const result = await client.BzeTokenfactoryV1.tx.sendMsgSetDenomMetadata({ value, fee: {amount: fee, gas: "200000"}, memo }) return result } catch (e) { if (e == MissingWalletError) { - throw new Error('TxClient:MsgChangeAdmin:Init Could not initialize signing client. Wallet is required.') + throw new Error('TxClient:MsgSetDenomMetadata:Init Could not initialize signing client. Wallet is required.') }else{ - throw new Error('TxClient:MsgChangeAdmin:Send Could not broadcast Tx: '+ e.message) + throw new Error('TxClient:MsgSetDenomMetadata:Send Could not broadcast Tx: '+ e.message) } } }, - async MsgMint({ rootGetters }, { value }) { + async MsgBurn({ rootGetters }, { value }) { try { const client=initClient(rootGetters) - const msg = await client.BzeTokenfactoryV1.tx.msgMint({value}) + const msg = await client.BzeTokenfactoryV1.tx.msgBurn({value}) return msg } catch (e) { if (e == MissingWalletError) { - throw new Error('TxClient:MsgMint:Init Could not initialize signing client. Wallet is required.') + throw new Error('TxClient:MsgBurn:Init Could not initialize signing client. Wallet is required.') } else{ - throw new Error('TxClient:MsgMint:Create Could not create message: ' + e.message) + throw new Error('TxClient:MsgBurn:Create Could not create message: ' + e.message) } } }, - async MsgBurn({ rootGetters }, { value }) { + async MsgChangeAdmin({ rootGetters }, { value }) { try { const client=initClient(rootGetters) - const msg = await client.BzeTokenfactoryV1.tx.msgBurn({value}) + const msg = await client.BzeTokenfactoryV1.tx.msgChangeAdmin({value}) return msg } catch (e) { if (e == MissingWalletError) { - throw new Error('TxClient:MsgBurn:Init Could not initialize signing client. Wallet is required.') + throw new Error('TxClient:MsgChangeAdmin:Init Could not initialize signing client. Wallet is required.') } else{ - throw new Error('TxClient:MsgBurn:Create Could not create message: ' + e.message) + throw new Error('TxClient:MsgChangeAdmin:Create Could not create message: ' + e.message) } } }, - async MsgSetDenomMetadata({ rootGetters }, { value }) { + async MsgMint({ rootGetters }, { value }) { try { const client=initClient(rootGetters) - const msg = await client.BzeTokenfactoryV1.tx.msgSetDenomMetadata({value}) + const msg = await client.BzeTokenfactoryV1.tx.msgMint({value}) return msg } catch (e) { if (e == MissingWalletError) { - throw new Error('TxClient:MsgSetDenomMetadata:Init Could not initialize signing client. Wallet is required.') + throw new Error('TxClient:MsgMint:Init Could not initialize signing client. Wallet is required.') } else{ - throw new Error('TxClient:MsgSetDenomMetadata:Create Could not create message: ' + e.message) + throw new Error('TxClient:MsgMint:Create Could not create message: ' + e.message) } } }, @@ -283,16 +283,16 @@ export default { } } }, - async MsgChangeAdmin({ rootGetters }, { value }) { + async MsgSetDenomMetadata({ rootGetters }, { value }) { try { const client=initClient(rootGetters) - const msg = await client.BzeTokenfactoryV1.tx.msgChangeAdmin({value}) + const msg = await client.BzeTokenfactoryV1.tx.msgSetDenomMetadata({value}) return msg } catch (e) { if (e == MissingWalletError) { - throw new Error('TxClient:MsgChangeAdmin:Init Could not initialize signing client. Wallet is required.') + throw new Error('TxClient:MsgSetDenomMetadata:Init Could not initialize signing client. Wallet is required.') } else{ - throw new Error('TxClient:MsgChangeAdmin:Create Could not create message: ' + e.message) + throw new Error('TxClient:MsgSetDenomMetadata:Create Could not create message: ' + e.message) } } }, diff --git a/vue/src/store/generated/bze.tradebin.v1/index.ts b/vue/src/store/generated/bze.tradebin.v1/index.ts index ed7084fe..158d35bc 100755 --- a/vue/src/store/generated/bze.tradebin.v1/index.ts +++ b/vue/src/store/generated/bze.tradebin.v1/index.ts @@ -383,29 +383,29 @@ export default { }, - async sendMsgCreateMarket({ rootGetters }, { value, fee = [], memo = '' }) { + async sendMsgCreateOrder({ rootGetters }, { value, fee = [], memo = '' }) { try { const client=await initClient(rootGetters) - const result = await client.BzeTradebinV1.tx.sendMsgCreateMarket({ value, fee: {amount: fee, gas: "200000"}, memo }) + const result = await client.BzeTradebinV1.tx.sendMsgCreateOrder({ value, fee: {amount: fee, gas: "200000"}, memo }) return result } catch (e) { if (e == MissingWalletError) { - throw new Error('TxClient:MsgCreateMarket:Init Could not initialize signing client. Wallet is required.') + throw new Error('TxClient:MsgCreateOrder:Init Could not initialize signing client. Wallet is required.') }else{ - throw new Error('TxClient:MsgCreateMarket:Send Could not broadcast Tx: '+ e.message) + throw new Error('TxClient:MsgCreateOrder:Send Could not broadcast Tx: '+ e.message) } } }, - async sendMsgCreateOrder({ rootGetters }, { value, fee = [], memo = '' }) { + async sendMsgCreateMarket({ rootGetters }, { value, fee = [], memo = '' }) { try { const client=await initClient(rootGetters) - const result = await client.BzeTradebinV1.tx.sendMsgCreateOrder({ value, fee: {amount: fee, gas: "200000"}, memo }) + const result = await client.BzeTradebinV1.tx.sendMsgCreateMarket({ value, fee: {amount: fee, gas: "200000"}, memo }) return result } catch (e) { if (e == MissingWalletError) { - throw new Error('TxClient:MsgCreateOrder:Init Could not initialize signing client. Wallet is required.') + throw new Error('TxClient:MsgCreateMarket:Init Could not initialize signing client. Wallet is required.') }else{ - throw new Error('TxClient:MsgCreateOrder:Send Could not broadcast Tx: '+ e.message) + throw new Error('TxClient:MsgCreateMarket:Send Could not broadcast Tx: '+ e.message) } } }, @@ -423,29 +423,29 @@ export default { } }, - async MsgCreateMarket({ rootGetters }, { value }) { + async MsgCreateOrder({ rootGetters }, { value }) { try { const client=initClient(rootGetters) - const msg = await client.BzeTradebinV1.tx.msgCreateMarket({value}) + const msg = await client.BzeTradebinV1.tx.msgCreateOrder({value}) return msg } catch (e) { if (e == MissingWalletError) { - throw new Error('TxClient:MsgCreateMarket:Init Could not initialize signing client. Wallet is required.') + throw new Error('TxClient:MsgCreateOrder:Init Could not initialize signing client. Wallet is required.') } else{ - throw new Error('TxClient:MsgCreateMarket:Create Could not create message: ' + e.message) + throw new Error('TxClient:MsgCreateOrder:Create Could not create message: ' + e.message) } } }, - async MsgCreateOrder({ rootGetters }, { value }) { + async MsgCreateMarket({ rootGetters }, { value }) { try { const client=initClient(rootGetters) - const msg = await client.BzeTradebinV1.tx.msgCreateOrder({value}) + const msg = await client.BzeTradebinV1.tx.msgCreateMarket({value}) return msg } catch (e) { if (e == MissingWalletError) { - throw new Error('TxClient:MsgCreateOrder:Init Could not initialize signing client. Wallet is required.') + throw new Error('TxClient:MsgCreateMarket:Init Could not initialize signing client. Wallet is required.') } else{ - throw new Error('TxClient:MsgCreateOrder:Create Could not create message: ' + e.message) + throw new Error('TxClient:MsgCreateMarket:Create Could not create message: ' + e.message) } } }, diff --git a/vue/src/store/generated/bze.v1.rewards/index.ts b/vue/src/store/generated/bze.v1.rewards/index.ts index 0cdecbbe..2a6dda46 100755 --- a/vue/src/store/generated/bze.v1.rewards/index.ts +++ b/vue/src/store/generated/bze.v1.rewards/index.ts @@ -336,6 +336,19 @@ export default { }, + async sendMsgExitStaking({ rootGetters }, { value, fee = [], memo = '' }) { + try { + const client=await initClient(rootGetters) + const result = await client.BzeV1Rewards.tx.sendMsgExitStaking({ value, fee: {amount: fee, gas: "200000"}, memo }) + return result + } catch (e) { + if (e == MissingWalletError) { + throw new Error('TxClient:MsgExitStaking:Init Could not initialize signing client. Wallet is required.') + }else{ + throw new Error('TxClient:MsgExitStaking:Send Could not broadcast Tx: '+ e.message) + } + } + }, async sendMsgUpdateStakingReward({ rootGetters }, { value, fee = [], memo = '' }) { try { const client=await initClient(rootGetters) @@ -349,16 +362,16 @@ export default { } } }, - async sendMsgCreateTradingReward({ rootGetters }, { value, fee = [], memo = '' }) { + async sendMsgCreateStakingReward({ rootGetters }, { value, fee = [], memo = '' }) { try { const client=await initClient(rootGetters) - const result = await client.BzeV1Rewards.tx.sendMsgCreateTradingReward({ value, fee: {amount: fee, gas: "200000"}, memo }) + const result = await client.BzeV1Rewards.tx.sendMsgCreateStakingReward({ value, fee: {amount: fee, gas: "200000"}, memo }) return result } catch (e) { if (e == MissingWalletError) { - throw new Error('TxClient:MsgCreateTradingReward:Init Could not initialize signing client. Wallet is required.') + throw new Error('TxClient:MsgCreateStakingReward:Init Could not initialize signing client. Wallet is required.') }else{ - throw new Error('TxClient:MsgCreateTradingReward:Send Could not broadcast Tx: '+ e.message) + throw new Error('TxClient:MsgCreateStakingReward:Send Could not broadcast Tx: '+ e.message) } } }, @@ -375,46 +388,46 @@ export default { } } }, - async sendMsgExitStaking({ rootGetters }, { value, fee = [], memo = '' }) { + async sendMsgClaimStakingRewards({ rootGetters }, { value, fee = [], memo = '' }) { try { const client=await initClient(rootGetters) - const result = await client.BzeV1Rewards.tx.sendMsgExitStaking({ value, fee: {amount: fee, gas: "200000"}, memo }) + const result = await client.BzeV1Rewards.tx.sendMsgClaimStakingRewards({ value, fee: {amount: fee, gas: "200000"}, memo }) return result } catch (e) { if (e == MissingWalletError) { - throw new Error('TxClient:MsgExitStaking:Init Could not initialize signing client. Wallet is required.') + throw new Error('TxClient:MsgClaimStakingRewards:Init Could not initialize signing client. Wallet is required.') }else{ - throw new Error('TxClient:MsgExitStaking:Send Could not broadcast Tx: '+ e.message) + throw new Error('TxClient:MsgClaimStakingRewards:Send Could not broadcast Tx: '+ e.message) } } }, - async sendMsgCreateStakingReward({ rootGetters }, { value, fee = [], memo = '' }) { + async sendMsgCreateTradingReward({ rootGetters }, { value, fee = [], memo = '' }) { try { const client=await initClient(rootGetters) - const result = await client.BzeV1Rewards.tx.sendMsgCreateStakingReward({ value, fee: {amount: fee, gas: "200000"}, memo }) + const result = await client.BzeV1Rewards.tx.sendMsgCreateTradingReward({ value, fee: {amount: fee, gas: "200000"}, memo }) return result } catch (e) { if (e == MissingWalletError) { - throw new Error('TxClient:MsgCreateStakingReward:Init Could not initialize signing client. Wallet is required.') + throw new Error('TxClient:MsgCreateTradingReward:Init Could not initialize signing client. Wallet is required.') }else{ - throw new Error('TxClient:MsgCreateStakingReward:Send Could not broadcast Tx: '+ e.message) + throw new Error('TxClient:MsgCreateTradingReward:Send Could not broadcast Tx: '+ e.message) } } }, - async sendMsgClaimStakingRewards({ rootGetters }, { value, fee = [], memo = '' }) { + + async MsgExitStaking({ rootGetters }, { value }) { try { - const client=await initClient(rootGetters) - const result = await client.BzeV1Rewards.tx.sendMsgClaimStakingRewards({ value, fee: {amount: fee, gas: "200000"}, memo }) - return result + const client=initClient(rootGetters) + const msg = await client.BzeV1Rewards.tx.msgExitStaking({value}) + return msg } catch (e) { if (e == MissingWalletError) { - throw new Error('TxClient:MsgClaimStakingRewards:Init Could not initialize signing client. Wallet is required.') - }else{ - throw new Error('TxClient:MsgClaimStakingRewards:Send Could not broadcast Tx: '+ e.message) + throw new Error('TxClient:MsgExitStaking:Init Could not initialize signing client. Wallet is required.') + } else{ + throw new Error('TxClient:MsgExitStaking:Create Could not create message: ' + e.message) } } }, - async MsgUpdateStakingReward({ rootGetters }, { value }) { try { const client=initClient(rootGetters) @@ -428,16 +441,16 @@ export default { } } }, - async MsgCreateTradingReward({ rootGetters }, { value }) { + async MsgCreateStakingReward({ rootGetters }, { value }) { try { const client=initClient(rootGetters) - const msg = await client.BzeV1Rewards.tx.msgCreateTradingReward({value}) + const msg = await client.BzeV1Rewards.tx.msgCreateStakingReward({value}) return msg } catch (e) { if (e == MissingWalletError) { - throw new Error('TxClient:MsgCreateTradingReward:Init Could not initialize signing client. Wallet is required.') + throw new Error('TxClient:MsgCreateStakingReward:Init Could not initialize signing client. Wallet is required.') } else{ - throw new Error('TxClient:MsgCreateTradingReward:Create Could not create message: ' + e.message) + throw new Error('TxClient:MsgCreateStakingReward:Create Could not create message: ' + e.message) } } }, @@ -454,42 +467,29 @@ export default { } } }, - async MsgExitStaking({ rootGetters }, { value }) { - try { - const client=initClient(rootGetters) - const msg = await client.BzeV1Rewards.tx.msgExitStaking({value}) - return msg - } catch (e) { - if (e == MissingWalletError) { - throw new Error('TxClient:MsgExitStaking:Init Could not initialize signing client. Wallet is required.') - } else{ - throw new Error('TxClient:MsgExitStaking:Create Could not create message: ' + e.message) - } - } - }, - async MsgCreateStakingReward({ rootGetters }, { value }) { + async MsgClaimStakingRewards({ rootGetters }, { value }) { try { const client=initClient(rootGetters) - const msg = await client.BzeV1Rewards.tx.msgCreateStakingReward({value}) + const msg = await client.BzeV1Rewards.tx.msgClaimStakingRewards({value}) return msg } catch (e) { if (e == MissingWalletError) { - throw new Error('TxClient:MsgCreateStakingReward:Init Could not initialize signing client. Wallet is required.') + throw new Error('TxClient:MsgClaimStakingRewards:Init Could not initialize signing client. Wallet is required.') } else{ - throw new Error('TxClient:MsgCreateStakingReward:Create Could not create message: ' + e.message) + throw new Error('TxClient:MsgClaimStakingRewards:Create Could not create message: ' + e.message) } } }, - async MsgClaimStakingRewards({ rootGetters }, { value }) { + async MsgCreateTradingReward({ rootGetters }, { value }) { try { const client=initClient(rootGetters) - const msg = await client.BzeV1Rewards.tx.msgClaimStakingRewards({value}) + const msg = await client.BzeV1Rewards.tx.msgCreateTradingReward({value}) return msg } catch (e) { if (e == MissingWalletError) { - throw new Error('TxClient:MsgClaimStakingRewards:Init Could not initialize signing client. Wallet is required.') + throw new Error('TxClient:MsgCreateTradingReward:Init Could not initialize signing client. Wallet is required.') } else{ - throw new Error('TxClient:MsgClaimStakingRewards:Create Could not create message: ' + e.message) + throw new Error('TxClient:MsgCreateTradingReward:Create Could not create message: ' + e.message) } } }, diff --git a/x/rewards/types/genesis.go b/x/rewards/types/genesis.go index 91d617e7..49f549f3 100644 --- a/x/rewards/types/genesis.go +++ b/x/rewards/types/genesis.go @@ -32,7 +32,6 @@ func DefaultGenesis() *GenesisState { func (gs GenesisState) Validate() error { // Check for duplicated index in stakingReward stakingRewardIndexMap := make(map[string]struct{}) - for _, elem := range gs.StakingRewardList { index := string(StakingRewardKey(elem.RewardId)) if _, ok := stakingRewardIndexMap[index]; ok { @@ -51,15 +50,79 @@ func (gs GenesisState) Validate() error { tradingRewardIndexMap[index] = struct{}{} } + pendingTradingRewardListIndexMap := make(map[string]struct{}) + for _, elem := range gs.PendingTradingRewardList { + index := string(TradingRewardKey(elem.RewardId)) + if _, ok := pendingTradingRewardListIndexMap[index]; ok { + return fmt.Errorf("duplicated index for PendingTradingRewardList") + } + pendingTradingRewardListIndexMap[index] = struct{}{} + } + // Check for duplicated index in stakingRewardParticipant stakingRewardParticipantIndexMap := make(map[string]struct{}) for _, elem := range gs.StakingRewardParticipantList { index := string(StakingRewardParticipantKey(elem.Address, elem.RewardId)) if _, ok := stakingRewardParticipantIndexMap[index]; ok { - return fmt.Errorf("duplicated index for stakingRewardParticipant") + return fmt.Errorf("duplicated index for StakingRewardParticipantList") } stakingRewardParticipantIndexMap[index] = struct{}{} } + + pendingUnlockParticipantListIndexMap := make(map[string]struct{}) + for _, elem := range gs.PendingUnlockParticipantList { + index := string(PendingUnlockParticipantKey(elem.Index)) + if _, ok := pendingUnlockParticipantListIndexMap[index]; ok { + return fmt.Errorf("duplicated index for PendingUnlockParticipantList") + } + pendingUnlockParticipantListIndexMap[index] = struct{}{} + } + + tradingRewardLeaderboardListIndexMap := make(map[string]struct{}) + for _, elem := range gs.TradingRewardLeaderboardList { + index := string(TradingRewardKey(elem.RewardId)) + if _, ok := tradingRewardLeaderboardListIndexMap[index]; ok { + return fmt.Errorf("duplicated index for TradingRewardLeaderboardList") + } + tradingRewardLeaderboardListIndexMap[index] = struct{}{} + } + + tradingRewardCandidateListIndexMap := make(map[string]struct{}) + for _, elem := range gs.TradingRewardCandidateList { + index := string(TradingRewardCandidateKey(elem.RewardId, elem.Address)) + if _, ok := tradingRewardCandidateListIndexMap[index]; ok { + return fmt.Errorf("duplicated index for TradingRewardCandidateList") + } + tradingRewardCandidateListIndexMap[index] = struct{}{} + } + + marketIdTradingRewardIdListIndexMap := make(map[string]struct{}) + for _, elem := range gs.MarketIdTradingRewardIdList { + index := string(MarketIdRewardIdKey(elem.MarketId)) + if _, ok := marketIdTradingRewardIdListIndexMap[index]; ok { + return fmt.Errorf("duplicated index for MarketIdTradingRewardIdList") + } + marketIdTradingRewardIdListIndexMap[index] = struct{}{} + } + + pendingTradingRewardExpirationListIndexMap := make(map[string]struct{}) + for _, elem := range gs.PendingTradingRewardExpirationList { + index := string(TradingRewardExpirationKey(elem.ExpireAt, elem.RewardId)) + if _, ok := pendingTradingRewardExpirationListIndexMap[index]; ok { + return fmt.Errorf("duplicated index for PendingTradingRewardExpirationList") + } + pendingTradingRewardExpirationListIndexMap[index] = struct{}{} + } + + activeTradingRewardExpirationListIndexMap := make(map[string]struct{}) + for _, elem := range gs.ActiveTradingRewardExpirationList { + index := string(TradingRewardExpirationKey(elem.ExpireAt, elem.RewardId)) + if _, ok := activeTradingRewardExpirationListIndexMap[index]; ok { + return fmt.Errorf("duplicated index for ActiveTradingRewardExpirationList") + } + activeTradingRewardExpirationListIndexMap[index] = struct{}{} + } + // this line is used by starport scaffolding # genesis/types/validate return gs.Params.Validate() From 2511be489ab846ade50b0f33b74c0e81b2b8e6e2 Mon Sep 17 00:00:00 2001 From: faneaatiku Date: Wed, 27 Mar 2024 01:39:47 +0200 Subject: [PATCH 21/35] modified get trading reward to use two indexes --- go.mod | 3 + go.sum | 12 ++ proto/rewards/query.proto | 5 +- x/rewards/client/cli/query_trading_reward.go | 6 +- x/rewards/keeper/grpc_query_trading_reward.go | 28 +++- x/rewards/types/query.pb.go | 153 ++++++++++++------ x/rewards/types/query.pb.gw.go | 40 ++++- 7 files changed, 184 insertions(+), 63 deletions(-) diff --git a/go.mod b/go.mod index 23080d06..0519be13 100644 --- a/go.mod +++ b/go.mod @@ -99,6 +99,7 @@ require ( github.com/fsnotify/fsnotify v1.6.0 // indirect github.com/fzipp/gocyclo v0.6.0 // indirect github.com/getsentry/sentry-go v0.17.0 // indirect + github.com/ghodss/yaml v1.0.0 // indirect github.com/go-critic/go-critic v0.6.5 // indirect github.com/go-kit/kit v0.12.0 // indirect github.com/go-kit/log v0.2.1 // indirect @@ -115,6 +116,7 @@ require ( github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect github.com/gofrs/flock v0.8.1 // indirect github.com/gogo/gateway v1.1.0 // indirect + github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b // indirect github.com/golang/snappy v0.0.4 // indirect github.com/golangci/check v0.0.0-20180506172741-cfe4005ccda2 // indirect github.com/golangci/dupl v0.0.0-20180902072040-3e9179ac440a // indirect @@ -137,6 +139,7 @@ require ( github.com/gostaticanalysis/forcetypeassert v0.1.0 // indirect github.com/gostaticanalysis/nilerr v0.1.1 // indirect github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 // indirect + github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1 // 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 diff --git a/go.sum b/go.sum index bd2604ca..5fd2428c 100644 --- a/go.sum +++ b/go.sum @@ -154,6 +154,7 @@ github.com/aymerick/douceur v0.2.0 h1:Mv+mAeH1Q+n9Fr+oyamOlAkUNPWPlA8PPGR0QAaYuP github.com/aymerick/douceur v0.2.0/go.mod h1:wlT5vV2O3h55X9m7iVYN0TBM0NH/MmbLnd30/FjWUq4= github.com/aymerick/raymond v2.0.3-0.20180322193309-b565731e1464+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g= github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= +github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= @@ -261,6 +262,7 @@ github.com/containerd/continuity v0.3.0 h1:nisirsYROK15TAMVukJOUyGJjz4BNQJBVsNvA github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= +github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= github.com/coreos/go-systemd v0.0.0-20180511133405-39ca1b05acc7/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/coreos/go-systemd/v22 v22.3.3-0.20220203105225-a9a7ef127534/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= @@ -395,6 +397,7 @@ github.com/getsentry/sentry-go v0.12.0/go.mod h1:NSap0JBYWzHND8oMbyi0+XZhUalc1TB github.com/getsentry/sentry-go v0.17.0 h1:UustVWnOoDFHBS7IJUB2QK/nB5pap748ZEp0swnQJak= github.com/getsentry/sentry-go v0.17.0/go.mod h1:B82dxtBvxG0KaPD8/hfSV+VcHD+Lg/xUS4JuQn1P4cM= github.com/ghemawat/stream v0.0.0-20171120220530-696b145b53b9/go.mod h1:106OIgooyS7OzLDOpUGgm9fA3bQENb/cFSyyBmMoJDs= +github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/gin-contrib/sse v0.0.0-20190301062529-5545eab6dad3/go.mod h1:VJ0WA2NBN22VlZ2dKZQPAPnyWw5XTlK1KymzLKsr59s= github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= @@ -487,11 +490,13 @@ github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzq github.com/golang-jwt/jwt/v4 v4.3.0/go.mod h1:/xlHOz8bRuivTWchD4jCa+NbatV+wEUSzwAxVc6locg= github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k= github.com/golang/geo v0.0.0-20190916061304-5b978397cfec/go.mod h1:QZ0nwyI2jOfgRAoBvP+ab5aRr7c9x7lhGEJrKvBwjWI= +github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= @@ -499,6 +504,7 @@ github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= +github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.0/go.mod h1:Qd/q+1AKNOZr9uGQzbzCmRO6sUih6GTPZv6a1/R87v0= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= @@ -633,6 +639,8 @@ github.com/grpc-ecosystem/grpc-gateway v1.8.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4M0+kPpLofRdBo= github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1 h1:/c3QmbOGMGTOumP2iT/rCwB7b0QDGLKzqOmktBjT+Is= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1/go.mod h1:5SN9VR2LTsRFsrEC6FHgRbTWrTHu6tqPeKxEQv15giM= 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= @@ -648,6 +656,7 @@ github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brv github.com/hashicorp/go-bexpr v0.1.10/go.mod h1:oxlubA2vC/gFVfX1A6JGp7ls7uCDlfJn732ehYYg+g0= github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= +github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48= github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= github.com/hashicorp/go-immutable-radix v1.3.1 h1:DKHmCUm2hRBK510BaiZlwvpD40f8bJFeZnpfm2KLowc= github.com/hashicorp/go-immutable-radix v1.3.1/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= @@ -657,6 +666,7 @@ github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+l github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= github.com/hashicorp/go-retryablehttp v0.5.3/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs= github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU= +github.com/hashicorp/go-rootcerts v1.0.2/go.mod h1:pqUvnprVnM5bf7AOirdbb01K4ccR319Vf4pU3K5EGc8= github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU= github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4= github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= @@ -1314,6 +1324,7 @@ go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= +go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= @@ -1321,6 +1332,7 @@ go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/atomic v1.10.0 h1:9qC72Qh0+3MqyJbAn8YU5xVq1frD8bn3JtD2oXtafVQ= go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= go.uber.org/goleak v1.1.11 h1:wy28qYRKZgnJTxGxvye5/wgWr1EKjmUDGYox5mGlRlI= +go.uber.org/goleak v1.1.11/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4= go.uber.org/multierr v1.8.0 h1:dg6GjLku4EH+249NNmoIciG9N/jURbDG+pFlTkhzIC8= diff --git a/proto/rewards/query.proto b/proto/rewards/query.proto index 06a0fd52..dde5cf24 100644 --- a/proto/rewards/query.proto +++ b/proto/rewards/query.proto @@ -35,7 +35,7 @@ service Query { // Queries a list of TradingReward items. rpc TradingRewardAll(QueryAllTradingRewardRequest) returns (QueryAllTradingRewardResponse) { - option (google.api.http).get = "/bze/rewards/v1/trading_reward"; + option (google.api.http).get = "/bze/rewards/v1/trading_reward/{state}"; } // Queries a StakingRewardParticipant by index. @@ -86,7 +86,8 @@ message QueryGetTradingRewardResponse { } message QueryAllTradingRewardRequest { - cosmos.base.query.v1beta1.PageRequest pagination = 1; + string state = 1; + cosmos.base.query.v1beta1.PageRequest pagination = 2; } message QueryAllTradingRewardResponse { diff --git a/x/rewards/client/cli/query_trading_reward.go b/x/rewards/client/cli/query_trading_reward.go index 0915587f..5b71263a 100644 --- a/x/rewards/client/cli/query_trading_reward.go +++ b/x/rewards/client/cli/query_trading_reward.go @@ -11,8 +11,9 @@ import ( func CmdListTradingReward() *cobra.Command { cmd := &cobra.Command{ - Use: "list-trading-reward", + Use: "list-trading-reward [state]", Short: "list all TradingReward", + Args: cobra.ExactArgs(1), RunE: func(cmd *cobra.Command, args []string) error { clientCtx := client.GetClientContextFromCmd(cmd) @@ -21,9 +22,12 @@ func CmdListTradingReward() *cobra.Command { return err } + argState := args[0] + queryClient := types.NewQueryClient(clientCtx) params := &types.QueryAllTradingRewardRequest{ + State: argState, Pagination: pageReq, } diff --git a/x/rewards/keeper/grpc_query_trading_reward.go b/x/rewards/keeper/grpc_query_trading_reward.go index d8b106c0..d68bdf95 100644 --- a/x/rewards/keeper/grpc_query_trading_reward.go +++ b/x/rewards/keeper/grpc_query_trading_reward.go @@ -11,7 +11,7 @@ import ( "google.golang.org/grpc/status" ) -func (k Keeper) TradingRewardAll(c context.Context, req *types.QueryAllTradingRewardRequest) (*types.QueryAllTradingRewardResponse, error) { +func (k msgServer) TradingRewardAll(c context.Context, req *types.QueryAllTradingRewardRequest) (*types.QueryAllTradingRewardResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "invalid request") } @@ -19,9 +19,7 @@ func (k Keeper) TradingRewardAll(c context.Context, req *types.QueryAllTradingRe var tradingRewards []types.TradingReward ctx := sdk.UnwrapSDKContext(c) - store := ctx.KVStore(k.storeKey) - tradingRewardStore := prefix.NewStore(store, types.KeyPrefix(types.PendingTradingRewardKeyPrefix)) - + tradingRewardStore := k.getTradingRewardStore(ctx, req.State) pageRes, err := query.Paginate(tradingRewardStore, req.Pagination, func(key []byte, value []byte) error { var tradingReward types.TradingReward if err := k.cdc.Unmarshal(value, &tradingReward); err != nil { @@ -39,16 +37,30 @@ func (k Keeper) TradingRewardAll(c context.Context, req *types.QueryAllTradingRe return &types.QueryAllTradingRewardResponse{List: tradingRewards, Pagination: pageRes}, nil } -func (k Keeper) TradingReward(c context.Context, req *types.QueryGetTradingRewardRequest) (*types.QueryGetTradingRewardResponse, error) { +func (k msgServer) TradingReward(c context.Context, req *types.QueryGetTradingRewardRequest) (*types.QueryGetTradingRewardResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "invalid request") } ctx := sdk.UnwrapSDKContext(c) val, found := k.GetPendingTradingReward(ctx, req.RewardId) - if !found { - return nil, status.Error(codes.NotFound, "not found") + if found { + return &types.QueryGetTradingRewardResponse{TradingReward: val}, nil + } + + val, found = k.GetActiveTradingReward(ctx, req.RewardId) + if found { + return &types.QueryGetTradingRewardResponse{TradingReward: val}, nil + } + + return nil, status.Error(codes.NotFound, "not found") +} + +func (k msgServer) getTradingRewardStore(ctx sdk.Context, state string) prefix.Store { + s := k.getActiveTradingRewardStore(ctx) + if state == "pending" { + s = k.getPendingTradingRewardStore(ctx) } - return &types.QueryGetTradingRewardResponse{TradingReward: val}, nil + return s } diff --git a/x/rewards/types/query.pb.go b/x/rewards/types/query.pb.go index 672195fd..515e7d76 100644 --- a/x/rewards/types/query.pb.go +++ b/x/rewards/types/query.pb.go @@ -386,7 +386,8 @@ func (m *QueryGetTradingRewardResponse) GetTradingReward() TradingReward { } type QueryAllTradingRewardRequest struct { - Pagination *query.PageRequest `protobuf:"bytes,1,opt,name=pagination,proto3" json:"pagination,omitempty"` + State string `protobuf:"bytes,1,opt,name=state,proto3" json:"state,omitempty"` + Pagination *query.PageRequest `protobuf:"bytes,2,opt,name=pagination,proto3" json:"pagination,omitempty"` } func (m *QueryAllTradingRewardRequest) Reset() { *m = QueryAllTradingRewardRequest{} } @@ -422,6 +423,13 @@ func (m *QueryAllTradingRewardRequest) XXX_DiscardUnknown() { var xxx_messageInfo_QueryAllTradingRewardRequest proto.InternalMessageInfo +func (m *QueryAllTradingRewardRequest) GetState() string { + if m != nil { + return m.State + } + return "" +} + func (m *QueryAllTradingRewardRequest) GetPagination() *query.PageRequest { if m != nil { return m.Pagination @@ -709,55 +717,57 @@ func init() { func init() { proto.RegisterFile("rewards/query.proto", fileDescriptor_5ddc078ee02fb5e8) } var fileDescriptor_5ddc078ee02fb5e8 = []byte{ - // 763 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x96, 0xc1, 0x4f, 0xd4, 0x4e, - 0x14, 0xc7, 0x77, 0xf8, 0xf1, 0x43, 0x19, 0x03, 0x31, 0x03, 0x21, 0x9b, 0x05, 0x2a, 0xa9, 0x09, - 0x6c, 0x10, 0xda, 0x2c, 0x10, 0x31, 0xd1, 0x0b, 0x1c, 0x20, 0xea, 0x05, 0x57, 0x4f, 0x5e, 0xc8, - 0x2c, 0x3b, 0x96, 0x86, 0xd2, 0x76, 0x3b, 0x03, 0x0a, 0x84, 0x8b, 0x47, 0xbd, 0x98, 0x78, 0xf0, - 0xaa, 0x7f, 0x85, 0x7f, 0x81, 0x09, 0x89, 0x17, 0x12, 0x2f, 0x9e, 0x8c, 0x01, 0xff, 0x10, 0xb3, - 0x33, 0x53, 0xe8, 0x74, 0x3b, 0xdd, 0x42, 0x20, 0xf1, 0xb6, 0x9d, 0x79, 0x6f, 0xde, 0xe7, 0x7d, - 0xdf, 0xcc, 0x7b, 0x0b, 0x87, 0x22, 0xf2, 0x1a, 0x47, 0x4d, 0x6a, 0xb7, 0x76, 0x48, 0xb4, 0x67, - 0x85, 0x51, 0xc0, 0x02, 0x34, 0xd8, 0xd8, 0x27, 0xd6, 0x6e, 0xcd, 0x92, 0x7b, 0x95, 0x61, 0x27, - 0x70, 0x02, 0xbe, 0x65, 0xb7, 0x7f, 0x09, 0xab, 0xca, 0x98, 0x13, 0x04, 0x8e, 0x47, 0x6c, 0x1c, - 0xba, 0x36, 0xf6, 0xfd, 0x80, 0x61, 0xe6, 0x06, 0x3e, 0x95, 0xbb, 0xd3, 0x1b, 0x01, 0xdd, 0x0e, - 0xa8, 0xdd, 0xc0, 0x94, 0x88, 0xc3, 0xed, 0xdd, 0x5a, 0x83, 0x30, 0x5c, 0xb3, 0x43, 0xec, 0xb8, - 0x3e, 0x37, 0x96, 0xb6, 0xc3, 0x31, 0x44, 0x88, 0x23, 0xbc, 0x1d, 0x9f, 0x30, 0x16, 0xaf, 0x52, - 0x86, 0xb7, 0x5c, 0xdf, 0x59, 0x17, 0xdf, 0xe9, 0x5d, 0x16, 0xe1, 0x66, 0xc7, 0x6e, 0x35, 0xdb, - 0x77, 0x3d, 0xc4, 0x11, 0x73, 0x37, 0xdc, 0x10, 0xfb, 0x4c, 0x58, 0x9a, 0xc3, 0x10, 0x3d, 0x6b, - 0xd3, 0xad, 0xf1, 0xd0, 0x75, 0xd2, 0xda, 0x21, 0x94, 0x99, 0x4f, 0xe1, 0x90, 0xb2, 0x4a, 0xc3, - 0xc0, 0xa7, 0x04, 0x2d, 0xc0, 0x3e, 0x81, 0x58, 0x06, 0x13, 0xa0, 0x7a, 0x6b, 0x6e, 0xc4, 0x52, - 0x95, 0xb2, 0x84, 0xfd, 0x72, 0xef, 0xd1, 0xaf, 0x3b, 0xa5, 0xba, 0xb4, 0x35, 0x1f, 0xc2, 0x31, - 0x7e, 0xd8, 0x2a, 0x61, 0xcf, 0x05, 0x4e, 0x9d, 0x9b, 0xcb, 0x60, 0x68, 0x14, 0xf6, 0x4b, 0x3c, - 0xb7, 0xc9, 0x0f, 0xee, 0xaf, 0xdf, 0x14, 0x0b, 0x8f, 0x9b, 0xe6, 0x16, 0x1c, 0xd7, 0x38, 0x4b, - 0xa6, 0x27, 0x70, 0x50, 0x4d, 0x52, 0xb2, 0x8d, 0xa7, 0xd9, 0x14, 0x77, 0x89, 0x38, 0x40, 0x93, - 0x8b, 0xe6, 0x2b, 0x49, 0xba, 0xe4, 0x79, 0x99, 0xa4, 0x2b, 0x10, 0x9e, 0x17, 0x4f, 0xc6, 0x99, - 0xb4, 0x44, 0xa5, 0xad, 0x76, 0xa5, 0x2d, 0x71, 0x8d, 0x64, 0xa5, 0xad, 0x35, 0xec, 0x10, 0xe9, - 0x5b, 0x4f, 0x78, 0x9a, 0x5f, 0x80, 0xcc, 0xaa, 0x33, 0x90, 0xcc, 0x6a, 0x11, 0xf6, 0x7a, 0x2e, - 0x65, 0x65, 0x30, 0xf1, 0x5f, 0xd1, 0x5c, 0xb8, 0x03, 0x5a, 0x55, 0x10, 0x7b, 0x38, 0xe2, 0x54, - 0x57, 0x44, 0x11, 0x55, 0x61, 0x4c, 0x54, 0xed, 0x85, 0xb8, 0x62, 0x97, 0xab, 0x5a, 0xca, 0xf9, - 0xbc, 0x6a, 0xea, 0xc5, 0xd5, 0x55, 0x4d, 0x71, 0x8f, 0xab, 0xc6, 0x92, 0x8b, 0xc9, 0xaa, 0x65, - 0x92, 0x5e, 0x47, 0xd5, 0xb2, 0xb3, 0xea, 0x52, 0xb5, 0xac, 0x5c, 0xae, 0xb8, 0x6a, 0xef, 0x01, - 0x9c, 0xca, 0x7c, 0x2f, 0x6b, 0xe7, 0x2f, 0x3f, 0xd6, 0xa5, 0x0c, 0x6f, 0xe0, 0x66, 0x33, 0x22, - 0x94, 0xca, 0xfa, 0xc5, 0x9f, 0x29, 0xc5, 0x7a, 0x2e, 0xad, 0xd8, 0x57, 0x00, 0xab, 0xdd, 0x69, - 0xa4, 0x78, 0xcb, 0x8a, 0x78, 0xd5, 0xdc, 0x2b, 0x9f, 0xf0, 0xbf, 0x1e, 0x1d, 0x5b, 0x52, 0xc6, - 0xf4, 0x03, 0xcd, 0x90, 0xf1, 0xaa, 0xae, 0xd7, 0x99, 0x58, 0xb9, 0x31, 0xff, 0x41, 0xb1, 0xe6, - 0xde, 0xf5, 0xc3, 0xff, 0x39, 0x39, 0x6a, 0xc1, 0x3e, 0x31, 0x02, 0x90, 0x99, 0x46, 0xea, 0x9c, - 0x32, 0x95, 0xbb, 0xb9, 0x36, 0x22, 0x90, 0x69, 0xbc, 0xfd, 0xf1, 0xe7, 0x63, 0x4f, 0x19, 0x8d, - 0xd8, 0x8d, 0x7d, 0x62, 0xc7, 0x73, 0x6d, 0xb7, 0x26, 0x87, 0x25, 0xfa, 0x0c, 0xe0, 0x80, 0x92, - 0x2e, 0x9a, 0xc9, 0x3c, 0x56, 0x33, 0x7d, 0x2a, 0xb3, 0x05, 0xad, 0x25, 0xce, 0x1c, 0xc7, 0x99, - 0x41, 0xd3, 0x69, 0x1c, 0x75, 0x08, 0xd9, 0x07, 0x67, 0xcd, 0xf1, 0x10, 0x7d, 0x02, 0xf0, 0xb6, - 0x72, 0xda, 0x92, 0xe7, 0x69, 0x28, 0x35, 0x93, 0x47, 0x43, 0xa9, 0x1b, 0x1f, 0xe6, 0x24, 0xa7, - 0x9c, 0x40, 0x46, 0x3e, 0x25, 0x17, 0x4f, 0xe9, 0x4a, 0x7a, 0xf1, 0xb2, 0x5a, 0xab, 0x5e, 0xbc, - 0xcc, 0xfe, 0xa8, 0x17, 0x4f, 0x9d, 0x05, 0x1d, 0xe2, 0x29, 0xa7, 0xe5, 0x8a, 0x77, 0x01, 0x4a, - 0x5d, 0x17, 0xd7, 0x8b, 0xa7, 0x52, 0xa2, 0xef, 0x00, 0x96, 0x75, 0x0f, 0x0d, 0x2d, 0x16, 0xba, - 0x56, 0x9d, 0xed, 0xa4, 0xf2, 0xe0, 0xe2, 0x8e, 0x92, 0xfb, 0x11, 0xe7, 0xbe, 0x8f, 0x16, 0xf2, - 0x8b, 0x9e, 0xfc, 0x13, 0x68, 0x1f, 0xc8, 0x96, 0x7f, 0x88, 0xbe, 0x01, 0x38, 0xaa, 0x0b, 0xd1, - 0x96, 0x7c, 0xb1, 0xd0, 0x0d, 0x2c, 0x9c, 0x50, 0x81, 0x26, 0x67, 0xce, 0xf3, 0x84, 0x66, 0xd1, - 0xbd, 0xe2, 0x09, 0xd1, 0xe5, 0x95, 0xa3, 0x13, 0x03, 0x1c, 0x9f, 0x18, 0xe0, 0xf7, 0x89, 0x01, - 0x3e, 0x9c, 0x1a, 0xa5, 0xe3, 0x53, 0xa3, 0xf4, 0xf3, 0xd4, 0x28, 0xbd, 0x9c, 0x71, 0x5c, 0xb6, - 0xb9, 0xd3, 0xb0, 0x36, 0x82, 0xed, 0xf6, 0x81, 0xb3, 0xd8, 0x0b, 0x37, 0x31, 0x23, 0x98, 0x7f, - 0xd9, 0x6f, 0xce, 0x02, 0xb0, 0xbd, 0x90, 0xd0, 0x46, 0x1f, 0xff, 0x7f, 0x3c, 0xff, 0x37, 0x00, - 0x00, 0xff, 0xff, 0xf0, 0x0c, 0xec, 0x8c, 0x22, 0x0c, 0x00, 0x00, + // 785 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x96, 0xc1, 0x4f, 0x13, 0x4f, + 0x14, 0xc7, 0x3b, 0xfc, 0x80, 0x9f, 0x8c, 0x81, 0x90, 0xa1, 0x21, 0x4d, 0x81, 0x95, 0xac, 0x09, + 0x34, 0x08, 0xbb, 0x29, 0x10, 0x31, 0xd1, 0x0b, 0x1c, 0x20, 0xea, 0x05, 0xab, 0x27, 0x2f, 0x64, + 0x4a, 0xc7, 0x65, 0xc3, 0xb2, 0xbb, 0xdd, 0x19, 0x50, 0x40, 0x2e, 0x5e, 0xbd, 0x18, 0x3d, 0x78, + 0x54, 0xff, 0x0a, 0xff, 0x02, 0x13, 0x12, 0x2f, 0x24, 0x5e, 0x3c, 0x19, 0x03, 0xfe, 0x21, 0xa6, + 0x33, 0xb3, 0xb4, 0xb3, 0xdd, 0x69, 0x17, 0x53, 0x13, 0x6f, 0xdd, 0x99, 0xf7, 0xe6, 0x7d, 0xde, + 0xf7, 0xcd, 0xbc, 0x57, 0x38, 0x16, 0x91, 0xe7, 0x38, 0xaa, 0x51, 0xbb, 0xbe, 0x4f, 0xa2, 0x43, + 0x2b, 0x8c, 0x02, 0x16, 0xa0, 0x91, 0xea, 0x11, 0xb1, 0x0e, 0xca, 0x96, 0xdc, 0x2b, 0xe6, 0x9d, + 0xc0, 0x09, 0xf8, 0x96, 0xdd, 0xf8, 0x25, 0xac, 0x8a, 0x93, 0x4e, 0x10, 0x38, 0x1e, 0xb1, 0x71, + 0xe8, 0xda, 0xd8, 0xf7, 0x03, 0x86, 0x99, 0x1b, 0xf8, 0x54, 0xee, 0xce, 0x6d, 0x07, 0x74, 0x2f, + 0xa0, 0x76, 0x15, 0x53, 0x22, 0x0e, 0xb7, 0x0f, 0xca, 0x55, 0xc2, 0x70, 0xd9, 0x0e, 0xb1, 0xe3, + 0xfa, 0xdc, 0x58, 0xda, 0xe6, 0x63, 0x88, 0x10, 0x47, 0x78, 0x2f, 0x3e, 0x61, 0x32, 0x5e, 0xa5, + 0x0c, 0xef, 0xba, 0xbe, 0xb3, 0x25, 0xbe, 0x93, 0xbb, 0x2c, 0xc2, 0xb5, 0xb6, 0xdd, 0x52, 0xba, + 0xef, 0x56, 0x88, 0x23, 0xe6, 0x6e, 0xbb, 0x21, 0xf6, 0x99, 0xb0, 0x34, 0xf3, 0x10, 0x3d, 0x6a, + 0xd0, 0x6d, 0xf2, 0xd0, 0x15, 0x52, 0xdf, 0x27, 0x94, 0x99, 0x0f, 0xe1, 0x98, 0xb2, 0x4a, 0xc3, + 0xc0, 0xa7, 0x04, 0x2d, 0xc3, 0x41, 0x81, 0x58, 0x00, 0xd3, 0xa0, 0x74, 0x7d, 0x71, 0xdc, 0x52, + 0x95, 0xb2, 0x84, 0xfd, 0x5a, 0xff, 0xe9, 0x8f, 0x1b, 0xb9, 0x8a, 0xb4, 0x35, 0xef, 0xc2, 0x49, + 0x7e, 0xd8, 0x06, 0x61, 0x8f, 0x05, 0x4e, 0x85, 0x9b, 0xcb, 0x60, 0x68, 0x02, 0x0e, 0x49, 0x3c, + 0xb7, 0xc6, 0x0f, 0x1e, 0xaa, 0x5c, 0x13, 0x0b, 0xf7, 0x6b, 0xe6, 0x2e, 0x9c, 0xd2, 0x38, 0x4b, + 0xa6, 0x07, 0x70, 0x44, 0x4d, 0x52, 0xb2, 0x4d, 0x25, 0xd9, 0x14, 0x77, 0x89, 0x38, 0x4c, 0x5b, + 0x17, 0xcd, 0x67, 0x92, 0x74, 0xd5, 0xf3, 0x52, 0x49, 0xd7, 0x21, 0x6c, 0x16, 0x4f, 0xc6, 0x99, + 0xb1, 0x44, 0xa5, 0xad, 0x46, 0xa5, 0x2d, 0x71, 0x8d, 0x64, 0xa5, 0xad, 0x4d, 0xec, 0x10, 0xe9, + 0x5b, 0x69, 0xf1, 0x34, 0x3f, 0x01, 0x99, 0x55, 0x7b, 0x20, 0x99, 0xd5, 0x0a, 0xec, 0xf7, 0x5c, + 0xca, 0x0a, 0x60, 0xfa, 0xbf, 0xac, 0xb9, 0x70, 0x07, 0xb4, 0xa1, 0x20, 0xf6, 0x71, 0xc4, 0xd9, + 0xae, 0x88, 0x22, 0xaa, 0xc2, 0xd8, 0x52, 0xb5, 0x27, 0xe2, 0x8a, 0xfd, 0x59, 0xd5, 0x12, 0xce, + 0xcd, 0xaa, 0xa9, 0x17, 0x57, 0x57, 0x35, 0xc5, 0x3d, 0xae, 0x1a, 0x6b, 0x5d, 0x34, 0x5f, 0x36, + 0xab, 0x96, 0x4a, 0x9a, 0x87, 0x03, 0x94, 0x61, 0x46, 0x24, 0xa5, 0xf8, 0x48, 0xd4, 0xb2, 0xaf, + 0x27, 0xb5, 0x4c, 0xcf, 0xb5, 0x4b, 0x2d, 0xd3, 0x32, 0xec, 0x71, 0x2d, 0x5f, 0x03, 0x38, 0x9b, + 0xfa, 0x8a, 0x36, 0x9b, 0xfd, 0x20, 0x56, 0xab, 0x00, 0xff, 0xc7, 0xb5, 0x5a, 0x44, 0x28, 0x95, + 0x7a, 0xc5, 0x9f, 0x3d, 0x53, 0xec, 0x33, 0x80, 0xa5, 0xee, 0x34, 0x52, 0xbc, 0x35, 0x45, 0xbc, + 0x52, 0xc7, 0x87, 0xd0, 0xe2, 0xff, 0x77, 0x74, 0xac, 0x4b, 0x19, 0x93, 0xcf, 0x36, 0x45, 0xc6, + 0x5e, 0xb5, 0x8a, 0x4b, 0xb1, 0x3a, 0xc6, 0xfc, 0x07, 0xc5, 0x5a, 0x7c, 0x3b, 0x04, 0x07, 0x38, + 0x39, 0xaa, 0xc3, 0x41, 0x31, 0x18, 0x90, 0x99, 0x44, 0x6a, 0x9f, 0x3d, 0xc5, 0x9b, 0x1d, 0x6d, + 0x44, 0x20, 0xd3, 0x78, 0xf5, 0xed, 0xd7, 0xbb, 0xbe, 0x02, 0x1a, 0xb7, 0xab, 0x47, 0xc4, 0x8e, + 0xa7, 0xdd, 0x41, 0x59, 0x8e, 0x50, 0xf4, 0x11, 0xc0, 0x61, 0x25, 0x5d, 0x34, 0x9f, 0x7a, 0xac, + 0x66, 0x26, 0x15, 0x17, 0x32, 0x5a, 0x4b, 0x9c, 0x45, 0x8e, 0x33, 0x8f, 0xe6, 0x92, 0x38, 0xea, + 0x68, 0xb2, 0x8f, 0x2f, 0x5b, 0xe6, 0x09, 0x7a, 0x0f, 0xe0, 0xa8, 0x72, 0xda, 0xaa, 0xe7, 0x69, + 0x28, 0x35, 0xf3, 0x48, 0x43, 0xa9, 0x1b, 0x2a, 0xe6, 0x0c, 0xa7, 0x9c, 0x46, 0x46, 0x67, 0x4a, + 0x2e, 0x9e, 0xd2, 0x95, 0xf4, 0xe2, 0xa5, 0x35, 0x5c, 0xbd, 0x78, 0xa9, 0xfd, 0x51, 0x2f, 0x9e, + 0x3a, 0x21, 0x14, 0xf1, 0x3e, 0x00, 0x38, 0xaa, 0x9c, 0xd6, 0x51, 0xbc, 0x2b, 0x50, 0xea, 0xba, + 0xb8, 0x69, 0x71, 0xca, 0x12, 0x9a, 0xe9, 0x46, 0xc9, 0xc7, 0xcb, 0x09, 0xfa, 0x0a, 0x60, 0x41, + 0xf7, 0xe0, 0xd0, 0x4a, 0xa6, 0xeb, 0xd5, 0xde, 0x56, 0x8a, 0x77, 0xae, 0xee, 0x28, 0xf9, 0xef, + 0x71, 0xfe, 0xdb, 0x68, 0xb9, 0x73, 0xf1, 0x5b, 0xff, 0x22, 0xda, 0xc7, 0xb2, 0xf5, 0x9f, 0xa0, + 0x2f, 0x00, 0x4e, 0xe8, 0x42, 0x34, 0xa4, 0x5f, 0xc9, 0x74, 0x13, 0x33, 0x27, 0x94, 0xa1, 0xd9, + 0x99, 0x4b, 0x3c, 0xa1, 0x05, 0x74, 0x2b, 0x7b, 0x42, 0x74, 0x6d, 0xfd, 0xf4, 0xdc, 0x00, 0x67, + 0xe7, 0x06, 0xf8, 0x79, 0x6e, 0x80, 0x37, 0x17, 0x46, 0xee, 0xec, 0xc2, 0xc8, 0x7d, 0xbf, 0x30, + 0x72, 0x4f, 0xe7, 0x1d, 0x97, 0xed, 0xec, 0x57, 0xad, 0xed, 0x60, 0xaf, 0x71, 0xe0, 0x02, 0xf6, + 0xc2, 0x1d, 0xcc, 0x08, 0xe6, 0x5f, 0xf6, 0x8b, 0xcb, 0x00, 0xec, 0x30, 0x24, 0xb4, 0x3a, 0xc8, + 0xff, 0x3d, 0x2f, 0xfd, 0x0e, 0x00, 0x00, 0xff, 0xff, 0x1c, 0xf2, 0x7c, 0x09, 0x40, 0x0c, 0x00, + 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1366,6 +1376,13 @@ func (m *QueryAllTradingRewardRequest) MarshalToSizedBuffer(dAtA []byte) (int, e i = encodeVarintQuery(dAtA, i, uint64(size)) } i-- + dAtA[i] = 0x12 + } + if len(m.State) > 0 { + i -= len(m.State) + copy(dAtA[i:], m.State) + i = encodeVarintQuery(dAtA, i, uint64(len(m.State))) + i-- dAtA[i] = 0xa } return len(dAtA) - i, nil @@ -1712,6 +1729,10 @@ func (m *QueryAllTradingRewardRequest) Size() (n int) { } var l int _ = l + l = len(m.State) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } if m.Pagination != nil { l = m.Pagination.Size() n += 1 + l + sovQuery(uint64(l)) @@ -2511,6 +2532,38 @@ func (m *QueryAllTradingRewardRequest) Unmarshal(dAtA []byte) error { } switch fieldNum { case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field State", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.State = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Pagination", wireType) } diff --git a/x/rewards/types/query.pb.gw.go b/x/rewards/types/query.pb.gw.go index 149a2535..dfacde24 100644 --- a/x/rewards/types/query.pb.gw.go +++ b/x/rewards/types/query.pb.gw.go @@ -196,13 +196,31 @@ func local_request_Query_TradingReward_0(ctx context.Context, marshaler runtime. } var ( - filter_Query_TradingRewardAll_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} + filter_Query_TradingRewardAll_0 = &utilities.DoubleArray{Encoding: map[string]int{"state": 0}, Base: []int{1, 1, 0}, Check: []int{0, 1, 2}} ) func request_Query_TradingRewardAll_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { var protoReq QueryAllTradingRewardRequest var metadata runtime.ServerMetadata + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["state"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "state") + } + + protoReq.State, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "state", err) + } + if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } @@ -219,6 +237,24 @@ func local_request_Query_TradingRewardAll_0(ctx context.Context, marshaler runti var protoReq QueryAllTradingRewardRequest var metadata runtime.ServerMetadata + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["state"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "state") + } + + protoReq.State, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "state", err) + } + if err := req.ParseForm(); err != nil { return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) } @@ -699,7 +735,7 @@ var ( pattern_Query_TradingReward_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"bze", "rewards", "v1", "trading_reward", "reward_id"}, "", runtime.AssumeColonVerbOpt(true))) - pattern_Query_TradingRewardAll_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"bze", "rewards", "v1", "trading_reward"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_Query_TradingRewardAll_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"bze", "rewards", "v1", "trading_reward", "state"}, "", runtime.AssumeColonVerbOpt(true))) pattern_Query_StakingRewardParticipant_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"bze", "rewards", "v1", "staking_reward_participant", "address"}, "", runtime.AssumeColonVerbOpt(true))) From 749f1486cb90f4ca6e83b9a58d200833f6271afa Mon Sep 17 00:00:00 2001 From: faneaatiku Date: Tue, 9 Apr 2024 01:00:59 +0200 Subject: [PATCH 22/35] cleanup trading reward candidates after expiration --- .../keeper/trading_reward_distribution.go | 8 +++++++ .../keeper/trading_reward_leaderboard.go | 21 +++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/x/rewards/keeper/trading_reward_distribution.go b/x/rewards/keeper/trading_reward_distribution.go index a480482e..2f5d15ca 100644 --- a/x/rewards/keeper/trading_reward_distribution.go +++ b/x/rewards/keeper/trading_reward_distribution.go @@ -25,6 +25,7 @@ func (k Keeper) distributeTradingRewards(ctx sdk.Context, epochNumber int64) { k.RemoveActiveTradingRewardExpiration(ctx, exp.ExpireAt, exp.RewardId) k.RemoveActiveTradingReward(ctx, exp.RewardId) k.RemoveTradingRewardLeaderboard(ctx, exp.RewardId) + k.cleanupTradingRewardCandidates(ctx, exp.RewardId) continue } @@ -57,3 +58,10 @@ func (k Keeper) distributeTradingRewards(ctx sdk.Context, epochNumber int64) { k.SetActiveTradingRewardExpiration(ctx, exp) } } + +func (k Keeper) cleanupTradingRewardCandidates(ctx sdk.Context, rewardId string) { + toRemove := k.GetTradingRewardCandidateByRewardId(ctx, rewardId) + for _, trc := range toRemove { + k.RemoveTradingRewardCandidate(ctx, trc.RewardId, trc.Address) + } +} diff --git a/x/rewards/keeper/trading_reward_leaderboard.go b/x/rewards/keeper/trading_reward_leaderboard.go index bad1f58b..58c5637b 100644 --- a/x/rewards/keeper/trading_reward_leaderboard.go +++ b/x/rewards/keeper/trading_reward_leaderboard.go @@ -66,6 +66,11 @@ func (k Keeper) GetTradingRewardCandidate(ctx sdk.Context, rewardId, address str return val, true } +func (k Keeper) RemoveTradingRewardCandidate(ctx sdk.Context, rewardId, address string) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.RewardCandidateKeyPrefix)) + store.Delete(types.TradingRewardCandidateKey(rewardId, address)) +} + // GetAllTradingRewardCandidate returns all []types.TradingRewardCandidate func (k Keeper) GetAllTradingRewardCandidate(ctx sdk.Context) (list []types.TradingRewardCandidate) { store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.RewardCandidateKeyPrefix)) @@ -81,3 +86,19 @@ func (k Keeper) GetAllTradingRewardCandidate(ctx sdk.Context) (list []types.Trad return } + +// GetTradingRewardCandidateByRewardId returns all []types.TradingRewardCandidate for a rewardId +func (k Keeper) GetTradingRewardCandidateByRewardId(ctx sdk.Context, rewardId string) (list []types.TradingRewardCandidate) { + store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.RewardCandidateKeyPrefix)) + iterator := sdk.KVStorePrefixIterator(store, []byte(rewardId+"/")) + + defer iterator.Close() + + for ; iterator.Valid(); iterator.Next() { + var val types.TradingRewardCandidate + k.cdc.MustUnmarshal(iterator.Value(), &val) + list = append(list, val) + } + + return +} From c1142e619e603e7dffc6b231687852fa780535f2 Mon Sep 17 00:00:00 2001 From: faneaatiku Date: Sat, 13 Apr 2024 22:20:46 +0200 Subject: [PATCH 23/35] updated some dependencies --- docs/static/openapi.yml | 116 ++-- go.mod | 3 - go.sum | 12 - .../bze-alphateam/bze/bze.v1.rewards/index.ts | 96 ++-- .../bze/bze.v1.rewards/module/index.ts | 18 +- .../bze/bze.v1.rewards/module/rest.ts | 42 +- .../module/types/rewards/events.ts | 2 + .../module/types/rewards/genesis.ts | 282 ++++++++- .../module/types/rewards/query.ts | 22 +- .../module/types/rewards/trading_reward.ts | 542 +++++++++++++++++- vue/src/store/generated/index.ts | 66 ++- vue/src/store/generated/package.json | 19 +- 12 files changed, 1023 insertions(+), 197 deletions(-) create mode 100644 vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/events.ts diff --git a/docs/static/openapi.yml b/docs/static/openapi.yml index d60329a9..10ee57f3 100644 --- a/docs/static/openapi.yml +++ b/docs/static/openapi.yml @@ -2663,7 +2663,62 @@ paths: type: boolean tags: - Query - /bze/rewards/v1/trading_reward: + '/bze/rewards/v1/trading_reward/{reward_id}': + get: + summary: Queries a TradingReward by index. + operationId: BzeV1RewardsTradingReward + responses: + '200': + description: A successful response. + schema: + type: object + properties: + trading_reward: + type: object + properties: + reward_id: + type: string + prize_amount: + type: string + prize_denom: + type: string + duration: + type: integer + format: int64 + market_id: + type: string + slots: + type: integer + format: int64 + expire_at: + type: integer + format: int64 + 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: {} + parameters: + - name: reward_id + in: path + required: true + type: string + tags: + - Query + '/bze/rewards/v1/trading_reward/{state}': get: summary: Queries a list of TradingReward items. operationId: BzeV1RewardsTradingRewardAll @@ -2741,6 +2796,10 @@ paths: type: string additionalProperties: {} parameters: + - name: state + in: path + required: true + type: string - name: pagination.key description: |- key is a value returned in PageResponse.next_key to begin @@ -2799,61 +2858,6 @@ paths: type: boolean tags: - Query - '/bze/rewards/v1/trading_reward/{reward_id}': - get: - summary: Queries a TradingReward by index. - operationId: BzeV1RewardsTradingReward - responses: - '200': - description: A successful response. - schema: - type: object - properties: - trading_reward: - type: object - properties: - reward_id: - type: string - prize_amount: - type: string - prize_denom: - type: string - duration: - type: integer - format: int64 - market_id: - type: string - slots: - type: integer - format: int64 - expire_at: - type: integer - format: int64 - 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: {} - parameters: - - name: reward_id - in: path - required: true - type: string - tags: - - Query /cosmos/auth/v1beta1/accounts: get: summary: Accounts returns all the existing accounts diff --git a/go.mod b/go.mod index 0519be13..23080d06 100644 --- a/go.mod +++ b/go.mod @@ -99,7 +99,6 @@ require ( github.com/fsnotify/fsnotify v1.6.0 // indirect github.com/fzipp/gocyclo v0.6.0 // indirect github.com/getsentry/sentry-go v0.17.0 // indirect - github.com/ghodss/yaml v1.0.0 // indirect github.com/go-critic/go-critic v0.6.5 // indirect github.com/go-kit/kit v0.12.0 // indirect github.com/go-kit/log v0.2.1 // indirect @@ -116,7 +115,6 @@ require ( github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect github.com/gofrs/flock v0.8.1 // indirect github.com/gogo/gateway v1.1.0 // indirect - github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b // indirect github.com/golang/snappy v0.0.4 // indirect github.com/golangci/check v0.0.0-20180506172741-cfe4005ccda2 // indirect github.com/golangci/dupl v0.0.0-20180902072040-3e9179ac440a // indirect @@ -139,7 +137,6 @@ require ( github.com/gostaticanalysis/forcetypeassert v0.1.0 // indirect github.com/gostaticanalysis/nilerr v0.1.1 // indirect github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 // indirect - github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1 // 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 diff --git a/go.sum b/go.sum index 5fd2428c..bd2604ca 100644 --- a/go.sum +++ b/go.sum @@ -154,7 +154,6 @@ github.com/aymerick/douceur v0.2.0 h1:Mv+mAeH1Q+n9Fr+oyamOlAkUNPWPlA8PPGR0QAaYuP github.com/aymerick/douceur v0.2.0/go.mod h1:wlT5vV2O3h55X9m7iVYN0TBM0NH/MmbLnd30/FjWUq4= github.com/aymerick/raymond v2.0.3-0.20180322193309-b565731e1464+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g= github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= -github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= @@ -262,7 +261,6 @@ github.com/containerd/continuity v0.3.0 h1:nisirsYROK15TAMVukJOUyGJjz4BNQJBVsNvA github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= -github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= github.com/coreos/go-systemd v0.0.0-20180511133405-39ca1b05acc7/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/coreos/go-systemd/v22 v22.3.3-0.20220203105225-a9a7ef127534/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= @@ -397,7 +395,6 @@ github.com/getsentry/sentry-go v0.12.0/go.mod h1:NSap0JBYWzHND8oMbyi0+XZhUalc1TB github.com/getsentry/sentry-go v0.17.0 h1:UustVWnOoDFHBS7IJUB2QK/nB5pap748ZEp0swnQJak= github.com/getsentry/sentry-go v0.17.0/go.mod h1:B82dxtBvxG0KaPD8/hfSV+VcHD+Lg/xUS4JuQn1P4cM= github.com/ghemawat/stream v0.0.0-20171120220530-696b145b53b9/go.mod h1:106OIgooyS7OzLDOpUGgm9fA3bQENb/cFSyyBmMoJDs= -github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/gin-contrib/sse v0.0.0-20190301062529-5545eab6dad3/go.mod h1:VJ0WA2NBN22VlZ2dKZQPAPnyWw5XTlK1KymzLKsr59s= github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= @@ -490,13 +487,11 @@ github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzq github.com/golang-jwt/jwt/v4 v4.3.0/go.mod h1:/xlHOz8bRuivTWchD4jCa+NbatV+wEUSzwAxVc6locg= github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k= github.com/golang/geo v0.0.0-20190916061304-5b978397cfec/go.mod h1:QZ0nwyI2jOfgRAoBvP+ab5aRr7c9x7lhGEJrKvBwjWI= -github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= @@ -504,7 +499,6 @@ github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= -github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.0/go.mod h1:Qd/q+1AKNOZr9uGQzbzCmRO6sUih6GTPZv6a1/R87v0= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= @@ -639,8 +633,6 @@ github.com/grpc-ecosystem/grpc-gateway v1.8.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4M0+kPpLofRdBo= github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1 h1:/c3QmbOGMGTOumP2iT/rCwB7b0QDGLKzqOmktBjT+Is= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1/go.mod h1:5SN9VR2LTsRFsrEC6FHgRbTWrTHu6tqPeKxEQv15giM= 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= @@ -656,7 +648,6 @@ github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brv github.com/hashicorp/go-bexpr v0.1.10/go.mod h1:oxlubA2vC/gFVfX1A6JGp7ls7uCDlfJn732ehYYg+g0= github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= -github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48= github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= github.com/hashicorp/go-immutable-radix v1.3.1 h1:DKHmCUm2hRBK510BaiZlwvpD40f8bJFeZnpfm2KLowc= github.com/hashicorp/go-immutable-radix v1.3.1/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= @@ -666,7 +657,6 @@ github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+l github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= github.com/hashicorp/go-retryablehttp v0.5.3/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs= github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU= -github.com/hashicorp/go-rootcerts v1.0.2/go.mod h1:pqUvnprVnM5bf7AOirdbb01K4ccR319Vf4pU3K5EGc8= github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU= github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4= github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= @@ -1324,7 +1314,6 @@ go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= -go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= @@ -1332,7 +1321,6 @@ go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/atomic v1.10.0 h1:9qC72Qh0+3MqyJbAn8YU5xVq1frD8bn3JtD2oXtafVQ= go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= go.uber.org/goleak v1.1.11 h1:wy28qYRKZgnJTxGxvye5/wgWr1EKjmUDGYox5mGlRlI= -go.uber.org/goleak v1.1.11/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4= go.uber.org/multierr v1.8.0 h1:dg6GjLku4EH+249NNmoIciG9N/jURbDG+pFlTkhzIC8= diff --git a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/index.ts b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/index.ts index a52629a2..7a0e590e 100755 --- a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/index.ts +++ b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/index.ts @@ -5,9 +5,14 @@ import { StakingReward } from "./module/types/rewards/staking_reward" import { StakingRewardParticipant } from "./module/types/rewards/staking_reward_participant" import { PendingUnlockParticipant } from "./module/types/rewards/staking_reward_participant" import { TradingReward } from "./module/types/rewards/trading_reward" +import { TradingRewardExpiration } from "./module/types/rewards/trading_reward" +import { TradingRewardLeaderboard } from "./module/types/rewards/trading_reward" +import { TradingRewardLeaderboardEntry } from "./module/types/rewards/trading_reward" +import { TradingRewardCandidate } from "./module/types/rewards/trading_reward" +import { MarketIdTradingRewardId } from "./module/types/rewards/trading_reward" -export { Params, StakingReward, StakingRewardParticipant, PendingUnlockParticipant, TradingReward }; +export { Params, StakingReward, StakingRewardParticipant, PendingUnlockParticipant, TradingReward, TradingRewardExpiration, TradingRewardLeaderboard, TradingRewardLeaderboardEntry, TradingRewardCandidate, MarketIdTradingRewardId }; async function initTxClient(vuexGetters) { return await txClient(vuexGetters['common/wallet/signer'], { @@ -59,6 +64,11 @@ const getDefaultState = () => { StakingRewardParticipant: getStructure(StakingRewardParticipant.fromPartial({})), PendingUnlockParticipant: getStructure(PendingUnlockParticipant.fromPartial({})), TradingReward: getStructure(TradingReward.fromPartial({})), + TradingRewardExpiration: getStructure(TradingRewardExpiration.fromPartial({})), + TradingRewardLeaderboard: getStructure(TradingRewardLeaderboard.fromPartial({})), + TradingRewardLeaderboardEntry: getStructure(TradingRewardLeaderboardEntry.fromPartial({})), + TradingRewardCandidate: getStructure(TradingRewardCandidate.fromPartial({})), + MarketIdTradingRewardId: getStructure(MarketIdTradingRewardId.fromPartial({})), }, _Registry: registry, @@ -264,11 +274,11 @@ export default { try { const key = params ?? {}; const queryClient=await initQueryClient(rootGetters) - let value= (await queryClient.queryTradingRewardAll(query)).data + let value= (await queryClient.queryTradingRewardAll( key.state, query)).data while (all && ( value).pagination && ( value).pagination.next_key!=null) { - let next_values=(await queryClient.queryTradingRewardAll({...query, 'pagination.key':( value).pagination.next_key})).data + let next_values=(await queryClient.queryTradingRewardAll( key.state, {...query, 'pagination.key':( value).pagination.next_key})).data value = mergeResults(value, next_values); } commit('QUERY', { query: 'TradingRewardAll', key: { params: {...key}, query}, value }) @@ -333,48 +343,48 @@ export default { }, - async sendMsgJoinStaking({ rootGetters }, { value, fee = [], memo = '' }) { + async sendMsgExitStaking({ rootGetters }, { value, fee = [], memo = '' }) { try { const txClient=await initTxClient(rootGetters) - const msg = await txClient.msgJoinStaking(value) + const msg = await txClient.msgExitStaking(value) const result = await txClient.signAndBroadcast([msg], {fee: { amount: fee, gas: "200000" }, memo}) return result } catch (e) { if (e == MissingWalletError) { - throw new Error('TxClient:MsgJoinStaking:Init Could not initialize signing client. Wallet is required.') + throw new Error('TxClient:MsgExitStaking:Init Could not initialize signing client. Wallet is required.') }else{ - throw new Error('TxClient:MsgJoinStaking:Send Could not broadcast Tx: '+ e.message) + throw new Error('TxClient:MsgExitStaking:Send Could not broadcast Tx: '+ e.message) } } }, - async sendMsgExitStaking({ rootGetters }, { value, fee = [], memo = '' }) { + async sendMsgJoinStaking({ rootGetters }, { value, fee = [], memo = '' }) { try { const txClient=await initTxClient(rootGetters) - const msg = await txClient.msgExitStaking(value) + const msg = await txClient.msgJoinStaking(value) const result = await txClient.signAndBroadcast([msg], {fee: { amount: fee, gas: "200000" }, memo}) return result } catch (e) { if (e == MissingWalletError) { - throw new Error('TxClient:MsgExitStaking:Init Could not initialize signing client. Wallet is required.') + throw new Error('TxClient:MsgJoinStaking:Init Could not initialize signing client. Wallet is required.') }else{ - throw new Error('TxClient:MsgExitStaking:Send Could not broadcast Tx: '+ e.message) + throw new Error('TxClient:MsgJoinStaking:Send Could not broadcast Tx: '+ e.message) } } }, - async sendMsgUpdateStakingReward({ rootGetters }, { value, fee = [], memo = '' }) { + async sendMsgClaimStakingRewards({ rootGetters }, { value, fee = [], memo = '' }) { try { const txClient=await initTxClient(rootGetters) - const msg = await txClient.msgUpdateStakingReward(value) + const msg = await txClient.msgClaimStakingRewards(value) const result = await txClient.signAndBroadcast([msg], {fee: { amount: fee, gas: "200000" }, memo}) return result } catch (e) { if (e == MissingWalletError) { - throw new Error('TxClient:MsgUpdateStakingReward:Init Could not initialize signing client. Wallet is required.') + throw new Error('TxClient:MsgClaimStakingRewards:Init Could not initialize signing client. Wallet is required.') }else{ - throw new Error('TxClient:MsgUpdateStakingReward:Send Could not broadcast Tx: '+ e.message) + throw new Error('TxClient:MsgClaimStakingRewards:Send Could not broadcast Tx: '+ e.message) } } }, @@ -393,73 +403,73 @@ export default { } } }, - async sendMsgCreateStakingReward({ rootGetters }, { value, fee = [], memo = '' }) { + async sendMsgUpdateStakingReward({ rootGetters }, { value, fee = [], memo = '' }) { try { const txClient=await initTxClient(rootGetters) - const msg = await txClient.msgCreateStakingReward(value) + const msg = await txClient.msgUpdateStakingReward(value) const result = await txClient.signAndBroadcast([msg], {fee: { amount: fee, gas: "200000" }, memo}) return result } catch (e) { if (e == MissingWalletError) { - throw new Error('TxClient:MsgCreateStakingReward:Init Could not initialize signing client. Wallet is required.') + throw new Error('TxClient:MsgUpdateStakingReward:Init Could not initialize signing client. Wallet is required.') }else{ - throw new Error('TxClient:MsgCreateStakingReward:Send Could not broadcast Tx: '+ e.message) + throw new Error('TxClient:MsgUpdateStakingReward:Send Could not broadcast Tx: '+ e.message) } } }, - async sendMsgClaimStakingRewards({ rootGetters }, { value, fee = [], memo = '' }) { + async sendMsgCreateStakingReward({ rootGetters }, { value, fee = [], memo = '' }) { try { const txClient=await initTxClient(rootGetters) - const msg = await txClient.msgClaimStakingRewards(value) + const msg = await txClient.msgCreateStakingReward(value) const result = await txClient.signAndBroadcast([msg], {fee: { amount: fee, gas: "200000" }, memo}) return result } catch (e) { if (e == MissingWalletError) { - throw new Error('TxClient:MsgClaimStakingRewards:Init Could not initialize signing client. Wallet is required.') + throw new Error('TxClient:MsgCreateStakingReward:Init Could not initialize signing client. Wallet is required.') }else{ - throw new Error('TxClient:MsgClaimStakingRewards:Send Could not broadcast Tx: '+ e.message) + throw new Error('TxClient:MsgCreateStakingReward:Send Could not broadcast Tx: '+ e.message) } } }, - async MsgJoinStaking({ rootGetters }, { value }) { + async MsgExitStaking({ rootGetters }, { value }) { try { const txClient=await initTxClient(rootGetters) - const msg = await txClient.msgJoinStaking(value) + const msg = await txClient.msgExitStaking(value) return msg } catch (e) { if (e == MissingWalletError) { - throw new Error('TxClient:MsgJoinStaking:Init Could not initialize signing client. Wallet is required.') + throw new Error('TxClient:MsgExitStaking:Init Could not initialize signing client. Wallet is required.') } else{ - throw new Error('TxClient:MsgJoinStaking:Create Could not create message: ' + e.message) + throw new Error('TxClient:MsgExitStaking:Create Could not create message: ' + e.message) } } }, - async MsgExitStaking({ rootGetters }, { value }) { + async MsgJoinStaking({ rootGetters }, { value }) { try { const txClient=await initTxClient(rootGetters) - const msg = await txClient.msgExitStaking(value) + const msg = await txClient.msgJoinStaking(value) return msg } catch (e) { if (e == MissingWalletError) { - throw new Error('TxClient:MsgExitStaking:Init Could not initialize signing client. Wallet is required.') + throw new Error('TxClient:MsgJoinStaking:Init Could not initialize signing client. Wallet is required.') } else{ - throw new Error('TxClient:MsgExitStaking:Create Could not create message: ' + e.message) + throw new Error('TxClient:MsgJoinStaking:Create Could not create message: ' + e.message) } } }, - async MsgUpdateStakingReward({ rootGetters }, { value }) { + async MsgClaimStakingRewards({ rootGetters }, { value }) { try { const txClient=await initTxClient(rootGetters) - const msg = await txClient.msgUpdateStakingReward(value) + const msg = await txClient.msgClaimStakingRewards(value) return msg } catch (e) { if (e == MissingWalletError) { - throw new Error('TxClient:MsgUpdateStakingReward:Init Could not initialize signing client. Wallet is required.') + throw new Error('TxClient:MsgClaimStakingRewards:Init Could not initialize signing client. Wallet is required.') } else{ - throw new Error('TxClient:MsgUpdateStakingReward:Create Could not create message: ' + e.message) + throw new Error('TxClient:MsgClaimStakingRewards:Create Could not create message: ' + e.message) } } }, @@ -476,29 +486,29 @@ export default { } } }, - async MsgCreateStakingReward({ rootGetters }, { value }) { + async MsgUpdateStakingReward({ rootGetters }, { value }) { try { const txClient=await initTxClient(rootGetters) - const msg = await txClient.msgCreateStakingReward(value) + const msg = await txClient.msgUpdateStakingReward(value) return msg } catch (e) { if (e == MissingWalletError) { - throw new Error('TxClient:MsgCreateStakingReward:Init Could not initialize signing client. Wallet is required.') + throw new Error('TxClient:MsgUpdateStakingReward:Init Could not initialize signing client. Wallet is required.') } else{ - throw new Error('TxClient:MsgCreateStakingReward:Create Could not create message: ' + e.message) + throw new Error('TxClient:MsgUpdateStakingReward:Create Could not create message: ' + e.message) } } }, - async MsgClaimStakingRewards({ rootGetters }, { value }) { + async MsgCreateStakingReward({ rootGetters }, { value }) { try { const txClient=await initTxClient(rootGetters) - const msg = await txClient.msgClaimStakingRewards(value) + const msg = await txClient.msgCreateStakingReward(value) return msg } catch (e) { if (e == MissingWalletError) { - throw new Error('TxClient:MsgClaimStakingRewards:Init Could not initialize signing client. Wallet is required.') + throw new Error('TxClient:MsgCreateStakingReward:Init Could not initialize signing client. Wallet is required.') } else{ - throw new Error('TxClient:MsgClaimStakingRewards:Create Could not create message: ' + e.message) + throw new Error('TxClient:MsgCreateStakingReward:Create Could not create message: ' + e.message) } } }, diff --git a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/index.ts b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/index.ts index ad7f8f00..73aff351 100755 --- a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/index.ts +++ b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/index.ts @@ -4,21 +4,21 @@ import { StdFee } from "@cosmjs/launchpad"; import { SigningStargateClient } from "@cosmjs/stargate"; import { Registry, OfflineSigner, EncodeObject, DirectSecp256k1HdWallet } from "@cosmjs/proto-signing"; import { Api } from "./rest"; -import { MsgJoinStaking } from "./types/rewards/tx"; import { MsgExitStaking } from "./types/rewards/tx"; -import { MsgUpdateStakingReward } from "./types/rewards/tx"; +import { MsgJoinStaking } from "./types/rewards/tx"; +import { MsgClaimStakingRewards } from "./types/rewards/tx"; import { MsgCreateTradingReward } from "./types/rewards/tx"; +import { MsgUpdateStakingReward } from "./types/rewards/tx"; import { MsgCreateStakingReward } from "./types/rewards/tx"; -import { MsgClaimStakingRewards } from "./types/rewards/tx"; const types = [ - ["/bze.v1.rewards.MsgJoinStaking", MsgJoinStaking], ["/bze.v1.rewards.MsgExitStaking", MsgExitStaking], - ["/bze.v1.rewards.MsgUpdateStakingReward", MsgUpdateStakingReward], + ["/bze.v1.rewards.MsgJoinStaking", MsgJoinStaking], + ["/bze.v1.rewards.MsgClaimStakingRewards", MsgClaimStakingRewards], ["/bze.v1.rewards.MsgCreateTradingReward", MsgCreateTradingReward], + ["/bze.v1.rewards.MsgUpdateStakingReward", MsgUpdateStakingReward], ["/bze.v1.rewards.MsgCreateStakingReward", MsgCreateStakingReward], - ["/bze.v1.rewards.MsgClaimStakingRewards", MsgClaimStakingRewards], ]; export const MissingWalletError = new Error("wallet is required"); @@ -51,12 +51,12 @@ const txClient = async (wallet: OfflineSigner, { addr: addr }: TxClientOptions = return { signAndBroadcast: (msgs: EncodeObject[], { fee, memo }: SignAndBroadcastOptions = {fee: defaultFee, memo: ""}) => client.signAndBroadcast(address, msgs, fee,memo), - msgJoinStaking: (data: MsgJoinStaking): EncodeObject => ({ typeUrl: "/bze.v1.rewards.MsgJoinStaking", value: MsgJoinStaking.fromPartial( data ) }), msgExitStaking: (data: MsgExitStaking): EncodeObject => ({ typeUrl: "/bze.v1.rewards.MsgExitStaking", value: MsgExitStaking.fromPartial( data ) }), - msgUpdateStakingReward: (data: MsgUpdateStakingReward): EncodeObject => ({ typeUrl: "/bze.v1.rewards.MsgUpdateStakingReward", value: MsgUpdateStakingReward.fromPartial( data ) }), + msgJoinStaking: (data: MsgJoinStaking): EncodeObject => ({ typeUrl: "/bze.v1.rewards.MsgJoinStaking", value: MsgJoinStaking.fromPartial( data ) }), + msgClaimStakingRewards: (data: MsgClaimStakingRewards): EncodeObject => ({ typeUrl: "/bze.v1.rewards.MsgClaimStakingRewards", value: MsgClaimStakingRewards.fromPartial( data ) }), msgCreateTradingReward: (data: MsgCreateTradingReward): EncodeObject => ({ typeUrl: "/bze.v1.rewards.MsgCreateTradingReward", value: MsgCreateTradingReward.fromPartial( data ) }), + msgUpdateStakingReward: (data: MsgUpdateStakingReward): EncodeObject => ({ typeUrl: "/bze.v1.rewards.MsgUpdateStakingReward", value: MsgUpdateStakingReward.fromPartial( data ) }), msgCreateStakingReward: (data: MsgCreateStakingReward): EncodeObject => ({ typeUrl: "/bze.v1.rewards.MsgCreateStakingReward", value: MsgCreateStakingReward.fromPartial( data ) }), - msgClaimStakingRewards: (data: MsgClaimStakingRewards): EncodeObject => ({ typeUrl: "/bze.v1.rewards.MsgClaimStakingRewards", value: MsgClaimStakingRewards.fromPartial( data ) }), }; }; diff --git a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/rest.ts b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/rest.ts index c95a8286..f7cb5167 100644 --- a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/rest.ts +++ b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/rest.ts @@ -224,6 +224,9 @@ export interface V1RewardsTradingReward { /** @format int64 */ slots?: number; + + /** @format int64 */ + expire_at?: number; } export type QueryParamsType = Record; @@ -418,7 +421,7 @@ export class HttpClient { } /** - * @title rewards/genesis.proto + * @title rewards/events.proto * @version version not set */ export class Api extends HttpClient { @@ -533,15 +536,32 @@ export class Api extends HttpClient + this.request({ + path: `/bze/rewards/v1/trading_reward/${reward_id}`, + method: "GET", + format: "json", + ...params, + }); + /** * No description * * @tags Query * @name QueryTradingRewardAll * @summary Queries a list of TradingReward items. - * @request GET:/bze/rewards/v1/trading_reward + * @request GET:/bze/rewards/v1/trading_reward/{state} */ queryTradingRewardAll = ( + state: string, query?: { "pagination.key"?: string; "pagination.offset"?: string; @@ -552,26 +572,10 @@ export class Api extends HttpClient this.request({ - path: `/bze/rewards/v1/trading_reward`, + path: `/bze/rewards/v1/trading_reward/${state}`, method: "GET", query: query, format: "json", ...params, }); - - /** - * No description - * - * @tags Query - * @name QueryTradingReward - * @summary Queries a TradingReward by index. - * @request GET:/bze/rewards/v1/trading_reward/{reward_id} - */ - queryTradingReward = (reward_id: string, params: RequestParams = {}) => - this.request({ - path: `/bze/rewards/v1/trading_reward/${reward_id}`, - method: "GET", - format: "json", - ...params, - }); } diff --git a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/events.ts b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/events.ts new file mode 100644 index 00000000..069fc0b6 --- /dev/null +++ b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/events.ts @@ -0,0 +1,2 @@ +/* eslint-disable */ +export const protobufPackage = "bze.rewards.v1"; diff --git a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/genesis.ts b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/genesis.ts index 75e96d25..df30f9f0 100644 --- a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/genesis.ts +++ b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/genesis.ts @@ -3,7 +3,13 @@ import * as Long from "long"; import { util, configure, Writer, Reader } from "protobufjs/minimal"; import { Params } from "../rewards/params"; import { StakingReward } from "../rewards/staking_reward"; -import { TradingReward } from "../rewards/trading_reward"; +import { + TradingReward, + TradingRewardLeaderboard, + TradingRewardCandidate, + MarketIdTradingRewardId, + TradingRewardExpiration, +} from "../rewards/trading_reward"; import { StakingRewardParticipant, PendingUnlockParticipant, @@ -17,10 +23,16 @@ export interface GenesisState { staking_reward_list: StakingReward[]; staking_rewards_counter: number; trading_rewards_counter: number; - trading_reward_list: TradingReward[]; + active_trading_reward_list: TradingReward[]; + pending_trading_reward_list: TradingReward[]; staking_reward_participant_list: StakingRewardParticipant[]; - /** this line is used by starport scaffolding # genesis/proto/state */ pending_unlock_participant_list: PendingUnlockParticipant[]; + trading_reward_leaderboard_list: TradingRewardLeaderboard[]; + trading_reward_candidate_list: TradingRewardCandidate[]; + market_id_trading_reward_id_list: MarketIdTradingRewardId[]; + pending_trading_reward_expiration_list: TradingRewardExpiration[]; + /** this line is used by starport scaffolding # genesis/proto/state */ + active_trading_reward_expiration_list: TradingRewardExpiration[]; } const baseGenesisState: object = { @@ -42,14 +54,32 @@ export const GenesisState = { if (message.trading_rewards_counter !== 0) { writer.uint32(32).uint64(message.trading_rewards_counter); } - for (const v of message.trading_reward_list) { + for (const v of message.active_trading_reward_list) { TradingReward.encode(v!, writer.uint32(42).fork()).ldelim(); } + for (const v of message.pending_trading_reward_list) { + TradingReward.encode(v!, writer.uint32(50).fork()).ldelim(); + } for (const v of message.staking_reward_participant_list) { - StakingRewardParticipant.encode(v!, writer.uint32(50).fork()).ldelim(); + StakingRewardParticipant.encode(v!, writer.uint32(58).fork()).ldelim(); } for (const v of message.pending_unlock_participant_list) { - PendingUnlockParticipant.encode(v!, writer.uint32(58).fork()).ldelim(); + PendingUnlockParticipant.encode(v!, writer.uint32(66).fork()).ldelim(); + } + for (const v of message.trading_reward_leaderboard_list) { + TradingRewardLeaderboard.encode(v!, writer.uint32(74).fork()).ldelim(); + } + for (const v of message.trading_reward_candidate_list) { + TradingRewardCandidate.encode(v!, writer.uint32(82).fork()).ldelim(); + } + for (const v of message.market_id_trading_reward_id_list) { + MarketIdTradingRewardId.encode(v!, writer.uint32(90).fork()).ldelim(); + } + for (const v of message.pending_trading_reward_expiration_list) { + TradingRewardExpiration.encode(v!, writer.uint32(98).fork()).ldelim(); + } + for (const v of message.active_trading_reward_expiration_list) { + TradingRewardExpiration.encode(v!, writer.uint32(106).fork()).ldelim(); } return writer; }, @@ -59,9 +89,15 @@ export const GenesisState = { let end = length === undefined ? reader.len : reader.pos + length; const message = { ...baseGenesisState } as GenesisState; message.staking_reward_list = []; - message.trading_reward_list = []; + message.active_trading_reward_list = []; + message.pending_trading_reward_list = []; message.staking_reward_participant_list = []; message.pending_unlock_participant_list = []; + message.trading_reward_leaderboard_list = []; + message.trading_reward_candidate_list = []; + message.market_id_trading_reward_id_list = []; + message.pending_trading_reward_expiration_list = []; + message.active_trading_reward_expiration_list = []; while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { @@ -84,20 +120,50 @@ export const GenesisState = { ); break; case 5: - message.trading_reward_list.push( + message.active_trading_reward_list.push( TradingReward.decode(reader, reader.uint32()) ); break; case 6: + message.pending_trading_reward_list.push( + TradingReward.decode(reader, reader.uint32()) + ); + break; + case 7: message.staking_reward_participant_list.push( StakingRewardParticipant.decode(reader, reader.uint32()) ); break; - case 7: + case 8: message.pending_unlock_participant_list.push( PendingUnlockParticipant.decode(reader, reader.uint32()) ); break; + case 9: + message.trading_reward_leaderboard_list.push( + TradingRewardLeaderboard.decode(reader, reader.uint32()) + ); + break; + case 10: + message.trading_reward_candidate_list.push( + TradingRewardCandidate.decode(reader, reader.uint32()) + ); + break; + case 11: + message.market_id_trading_reward_id_list.push( + MarketIdTradingRewardId.decode(reader, reader.uint32()) + ); + break; + case 12: + message.pending_trading_reward_expiration_list.push( + TradingRewardExpiration.decode(reader, reader.uint32()) + ); + break; + case 13: + message.active_trading_reward_expiration_list.push( + TradingRewardExpiration.decode(reader, reader.uint32()) + ); + break; default: reader.skipType(tag & 7); break; @@ -109,9 +175,15 @@ export const GenesisState = { fromJSON(object: any): GenesisState { const message = { ...baseGenesisState } as GenesisState; message.staking_reward_list = []; - message.trading_reward_list = []; + message.active_trading_reward_list = []; + message.pending_trading_reward_list = []; message.staking_reward_participant_list = []; message.pending_unlock_participant_list = []; + message.trading_reward_leaderboard_list = []; + message.trading_reward_candidate_list = []; + message.market_id_trading_reward_id_list = []; + message.pending_trading_reward_expiration_list = []; + message.active_trading_reward_expiration_list = []; if (object.params !== undefined && object.params !== null) { message.params = Params.fromJSON(object.params); } else { @@ -142,11 +214,19 @@ export const GenesisState = { message.trading_rewards_counter = 0; } if ( - object.trading_reward_list !== undefined && - object.trading_reward_list !== null + object.active_trading_reward_list !== undefined && + object.active_trading_reward_list !== null + ) { + for (const e of object.active_trading_reward_list) { + message.active_trading_reward_list.push(TradingReward.fromJSON(e)); + } + } + if ( + object.pending_trading_reward_list !== undefined && + object.pending_trading_reward_list !== null ) { - for (const e of object.trading_reward_list) { - message.trading_reward_list.push(TradingReward.fromJSON(e)); + for (const e of object.pending_trading_reward_list) { + message.pending_trading_reward_list.push(TradingReward.fromJSON(e)); } } if ( @@ -169,6 +249,56 @@ export const GenesisState = { ); } } + if ( + object.trading_reward_leaderboard_list !== undefined && + object.trading_reward_leaderboard_list !== null + ) { + for (const e of object.trading_reward_leaderboard_list) { + message.trading_reward_leaderboard_list.push( + TradingRewardLeaderboard.fromJSON(e) + ); + } + } + if ( + object.trading_reward_candidate_list !== undefined && + object.trading_reward_candidate_list !== null + ) { + for (const e of object.trading_reward_candidate_list) { + message.trading_reward_candidate_list.push( + TradingRewardCandidate.fromJSON(e) + ); + } + } + if ( + object.market_id_trading_reward_id_list !== undefined && + object.market_id_trading_reward_id_list !== null + ) { + for (const e of object.market_id_trading_reward_id_list) { + message.market_id_trading_reward_id_list.push( + MarketIdTradingRewardId.fromJSON(e) + ); + } + } + if ( + object.pending_trading_reward_expiration_list !== undefined && + object.pending_trading_reward_expiration_list !== null + ) { + for (const e of object.pending_trading_reward_expiration_list) { + message.pending_trading_reward_expiration_list.push( + TradingRewardExpiration.fromJSON(e) + ); + } + } + if ( + object.active_trading_reward_expiration_list !== undefined && + object.active_trading_reward_expiration_list !== null + ) { + for (const e of object.active_trading_reward_expiration_list) { + message.active_trading_reward_expiration_list.push( + TradingRewardExpiration.fromJSON(e) + ); + } + } return message; }, @@ -187,12 +317,19 @@ export const GenesisState = { (obj.staking_rewards_counter = message.staking_rewards_counter); message.trading_rewards_counter !== undefined && (obj.trading_rewards_counter = message.trading_rewards_counter); - if (message.trading_reward_list) { - obj.trading_reward_list = message.trading_reward_list.map((e) => - e ? TradingReward.toJSON(e) : undefined + if (message.active_trading_reward_list) { + obj.active_trading_reward_list = message.active_trading_reward_list.map( + (e) => (e ? TradingReward.toJSON(e) : undefined) ); } else { - obj.trading_reward_list = []; + obj.active_trading_reward_list = []; + } + if (message.pending_trading_reward_list) { + obj.pending_trading_reward_list = message.pending_trading_reward_list.map( + (e) => (e ? TradingReward.toJSON(e) : undefined) + ); + } else { + obj.pending_trading_reward_list = []; } if (message.staking_reward_participant_list) { obj.staking_reward_participant_list = message.staking_reward_participant_list.map( @@ -208,15 +345,56 @@ export const GenesisState = { } else { obj.pending_unlock_participant_list = []; } + if (message.trading_reward_leaderboard_list) { + obj.trading_reward_leaderboard_list = message.trading_reward_leaderboard_list.map( + (e) => (e ? TradingRewardLeaderboard.toJSON(e) : undefined) + ); + } else { + obj.trading_reward_leaderboard_list = []; + } + if (message.trading_reward_candidate_list) { + obj.trading_reward_candidate_list = message.trading_reward_candidate_list.map( + (e) => (e ? TradingRewardCandidate.toJSON(e) : undefined) + ); + } else { + obj.trading_reward_candidate_list = []; + } + if (message.market_id_trading_reward_id_list) { + obj.market_id_trading_reward_id_list = message.market_id_trading_reward_id_list.map( + (e) => (e ? MarketIdTradingRewardId.toJSON(e) : undefined) + ); + } else { + obj.market_id_trading_reward_id_list = []; + } + if (message.pending_trading_reward_expiration_list) { + obj.pending_trading_reward_expiration_list = message.pending_trading_reward_expiration_list.map( + (e) => (e ? TradingRewardExpiration.toJSON(e) : undefined) + ); + } else { + obj.pending_trading_reward_expiration_list = []; + } + if (message.active_trading_reward_expiration_list) { + obj.active_trading_reward_expiration_list = message.active_trading_reward_expiration_list.map( + (e) => (e ? TradingRewardExpiration.toJSON(e) : undefined) + ); + } else { + obj.active_trading_reward_expiration_list = []; + } return obj; }, fromPartial(object: DeepPartial): GenesisState { const message = { ...baseGenesisState } as GenesisState; message.staking_reward_list = []; - message.trading_reward_list = []; + message.active_trading_reward_list = []; + message.pending_trading_reward_list = []; message.staking_reward_participant_list = []; message.pending_unlock_participant_list = []; + message.trading_reward_leaderboard_list = []; + message.trading_reward_candidate_list = []; + message.market_id_trading_reward_id_list = []; + message.pending_trading_reward_expiration_list = []; + message.active_trading_reward_expiration_list = []; if (object.params !== undefined && object.params !== null) { message.params = Params.fromPartial(object.params); } else { @@ -247,11 +425,19 @@ export const GenesisState = { message.trading_rewards_counter = 0; } if ( - object.trading_reward_list !== undefined && - object.trading_reward_list !== null + object.active_trading_reward_list !== undefined && + object.active_trading_reward_list !== null + ) { + for (const e of object.active_trading_reward_list) { + message.active_trading_reward_list.push(TradingReward.fromPartial(e)); + } + } + if ( + object.pending_trading_reward_list !== undefined && + object.pending_trading_reward_list !== null ) { - for (const e of object.trading_reward_list) { - message.trading_reward_list.push(TradingReward.fromPartial(e)); + for (const e of object.pending_trading_reward_list) { + message.pending_trading_reward_list.push(TradingReward.fromPartial(e)); } } if ( @@ -274,6 +460,56 @@ export const GenesisState = { ); } } + if ( + object.trading_reward_leaderboard_list !== undefined && + object.trading_reward_leaderboard_list !== null + ) { + for (const e of object.trading_reward_leaderboard_list) { + message.trading_reward_leaderboard_list.push( + TradingRewardLeaderboard.fromPartial(e) + ); + } + } + if ( + object.trading_reward_candidate_list !== undefined && + object.trading_reward_candidate_list !== null + ) { + for (const e of object.trading_reward_candidate_list) { + message.trading_reward_candidate_list.push( + TradingRewardCandidate.fromPartial(e) + ); + } + } + if ( + object.market_id_trading_reward_id_list !== undefined && + object.market_id_trading_reward_id_list !== null + ) { + for (const e of object.market_id_trading_reward_id_list) { + message.market_id_trading_reward_id_list.push( + MarketIdTradingRewardId.fromPartial(e) + ); + } + } + if ( + object.pending_trading_reward_expiration_list !== undefined && + object.pending_trading_reward_expiration_list !== null + ) { + for (const e of object.pending_trading_reward_expiration_list) { + message.pending_trading_reward_expiration_list.push( + TradingRewardExpiration.fromPartial(e) + ); + } + } + if ( + object.active_trading_reward_expiration_list !== undefined && + object.active_trading_reward_expiration_list !== null + ) { + for (const e of object.active_trading_reward_expiration_list) { + message.active_trading_reward_expiration_list.push( + TradingRewardExpiration.fromPartial(e) + ); + } + } return message; }, }; diff --git a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/query.ts b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/query.ts index e3e87501..aedd037b 100644 --- a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/query.ts +++ b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/query.ts @@ -46,6 +46,7 @@ export interface QueryGetTradingRewardResponse { } export interface QueryAllTradingRewardRequest { + state: string; pagination: PageRequest | undefined; } @@ -637,15 +638,18 @@ export const QueryGetTradingRewardResponse = { }, }; -const baseQueryAllTradingRewardRequest: object = {}; +const baseQueryAllTradingRewardRequest: object = { state: "" }; export const QueryAllTradingRewardRequest = { encode( message: QueryAllTradingRewardRequest, writer: Writer = Writer.create() ): Writer { + if (message.state !== "") { + writer.uint32(10).string(message.state); + } if (message.pagination !== undefined) { - PageRequest.encode(message.pagination, writer.uint32(10).fork()).ldelim(); + PageRequest.encode(message.pagination, writer.uint32(18).fork()).ldelim(); } return writer; }, @@ -663,6 +667,9 @@ export const QueryAllTradingRewardRequest = { const tag = reader.uint32(); switch (tag >>> 3) { case 1: + message.state = reader.string(); + break; + case 2: message.pagination = PageRequest.decode(reader, reader.uint32()); break; default: @@ -677,6 +684,11 @@ export const QueryAllTradingRewardRequest = { const message = { ...baseQueryAllTradingRewardRequest, } as QueryAllTradingRewardRequest; + if (object.state !== undefined && object.state !== null) { + message.state = String(object.state); + } else { + message.state = ""; + } if (object.pagination !== undefined && object.pagination !== null) { message.pagination = PageRequest.fromJSON(object.pagination); } else { @@ -687,6 +699,7 @@ export const QueryAllTradingRewardRequest = { toJSON(message: QueryAllTradingRewardRequest): unknown { const obj: any = {}; + message.state !== undefined && (obj.state = message.state); message.pagination !== undefined && (obj.pagination = message.pagination ? PageRequest.toJSON(message.pagination) @@ -700,6 +713,11 @@ export const QueryAllTradingRewardRequest = { const message = { ...baseQueryAllTradingRewardRequest, } as QueryAllTradingRewardRequest; + if (object.state !== undefined && object.state !== null) { + message.state = object.state; + } else { + message.state = ""; + } if (object.pagination !== undefined && object.pagination !== null) { message.pagination = PageRequest.fromPartial(object.pagination); } else { diff --git a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/trading_reward.ts b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/trading_reward.ts index 48b20ae9..fba1fdde 100644 --- a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/trading_reward.ts +++ b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/trading_reward.ts @@ -1,5 +1,6 @@ /* eslint-disable */ -import { Writer, Reader } from "protobufjs/minimal"; +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; export const protobufPackage = "bze.v1.rewards"; @@ -10,6 +11,34 @@ export interface TradingReward { duration: number; market_id: string; slots: number; + expire_at: number; +} + +export interface TradingRewardExpiration { + reward_id: string; + expire_at: number; +} + +export interface TradingRewardLeaderboard { + reward_id: string; + list: TradingRewardLeaderboardEntry[]; +} + +export interface TradingRewardLeaderboardEntry { + amount: string; + address: string; + created_at: number; +} + +export interface TradingRewardCandidate { + reward_id: string; + amount: string; + address: string; +} + +export interface MarketIdTradingRewardId { + reward_id: string; + market_id: string; } const baseTradingReward: object = { @@ -19,6 +48,7 @@ const baseTradingReward: object = { duration: 0, market_id: "", slots: 0, + expire_at: 0, }; export const TradingReward = { @@ -41,6 +71,9 @@ export const TradingReward = { if (message.slots !== 0) { writer.uint32(48).uint32(message.slots); } + if (message.expire_at !== 0) { + writer.uint32(56).uint32(message.expire_at); + } return writer; }, @@ -69,6 +102,9 @@ export const TradingReward = { case 6: message.slots = reader.uint32(); break; + case 7: + message.expire_at = reader.uint32(); + break; default: reader.skipType(tag & 7); break; @@ -109,6 +145,11 @@ export const TradingReward = { } else { message.slots = 0; } + if (object.expire_at !== undefined && object.expire_at !== null) { + message.expire_at = Number(object.expire_at); + } else { + message.expire_at = 0; + } return message; }, @@ -122,6 +163,7 @@ export const TradingReward = { message.duration !== undefined && (obj.duration = message.duration); message.market_id !== undefined && (obj.market_id = message.market_id); message.slots !== undefined && (obj.slots = message.slots); + message.expire_at !== undefined && (obj.expire_at = message.expire_at); return obj; }, @@ -157,10 +199,496 @@ export const TradingReward = { } else { message.slots = 0; } + if (object.expire_at !== undefined && object.expire_at !== null) { + message.expire_at = object.expire_at; + } else { + message.expire_at = 0; + } + return message; + }, +}; + +const baseTradingRewardExpiration: object = { reward_id: "", expire_at: 0 }; + +export const TradingRewardExpiration = { + encode( + message: TradingRewardExpiration, + writer: Writer = Writer.create() + ): Writer { + if (message.reward_id !== "") { + writer.uint32(10).string(message.reward_id); + } + if (message.expire_at !== 0) { + writer.uint32(16).uint32(message.expire_at); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): TradingRewardExpiration { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseTradingRewardExpiration, + } as TradingRewardExpiration; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.reward_id = reader.string(); + break; + case 2: + message.expire_at = reader.uint32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): TradingRewardExpiration { + const message = { + ...baseTradingRewardExpiration, + } as TradingRewardExpiration; + if (object.reward_id !== undefined && object.reward_id !== null) { + message.reward_id = String(object.reward_id); + } else { + message.reward_id = ""; + } + if (object.expire_at !== undefined && object.expire_at !== null) { + message.expire_at = Number(object.expire_at); + } else { + message.expire_at = 0; + } + return message; + }, + + toJSON(message: TradingRewardExpiration): unknown { + const obj: any = {}; + message.reward_id !== undefined && (obj.reward_id = message.reward_id); + message.expire_at !== undefined && (obj.expire_at = message.expire_at); + return obj; + }, + + fromPartial( + object: DeepPartial + ): TradingRewardExpiration { + const message = { + ...baseTradingRewardExpiration, + } as TradingRewardExpiration; + if (object.reward_id !== undefined && object.reward_id !== null) { + message.reward_id = object.reward_id; + } else { + message.reward_id = ""; + } + if (object.expire_at !== undefined && object.expire_at !== null) { + message.expire_at = object.expire_at; + } else { + message.expire_at = 0; + } + return message; + }, +}; + +const baseTradingRewardLeaderboard: object = { reward_id: "" }; + +export const TradingRewardLeaderboard = { + encode( + message: TradingRewardLeaderboard, + writer: Writer = Writer.create() + ): Writer { + if (message.reward_id !== "") { + writer.uint32(10).string(message.reward_id); + } + for (const v of message.list) { + TradingRewardLeaderboardEntry.encode( + v!, + writer.uint32(18).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): TradingRewardLeaderboard { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseTradingRewardLeaderboard, + } as TradingRewardLeaderboard; + message.list = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.reward_id = reader.string(); + break; + case 2: + message.list.push( + TradingRewardLeaderboardEntry.decode(reader, reader.uint32()) + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): TradingRewardLeaderboard { + const message = { + ...baseTradingRewardLeaderboard, + } as TradingRewardLeaderboard; + message.list = []; + if (object.reward_id !== undefined && object.reward_id !== null) { + message.reward_id = String(object.reward_id); + } else { + message.reward_id = ""; + } + if (object.list !== undefined && object.list !== null) { + for (const e of object.list) { + message.list.push(TradingRewardLeaderboardEntry.fromJSON(e)); + } + } + return message; + }, + + toJSON(message: TradingRewardLeaderboard): unknown { + const obj: any = {}; + message.reward_id !== undefined && (obj.reward_id = message.reward_id); + if (message.list) { + obj.list = message.list.map((e) => + e ? TradingRewardLeaderboardEntry.toJSON(e) : undefined + ); + } else { + obj.list = []; + } + return obj; + }, + + fromPartial( + object: DeepPartial + ): TradingRewardLeaderboard { + const message = { + ...baseTradingRewardLeaderboard, + } as TradingRewardLeaderboard; + message.list = []; + if (object.reward_id !== undefined && object.reward_id !== null) { + message.reward_id = object.reward_id; + } else { + message.reward_id = ""; + } + if (object.list !== undefined && object.list !== null) { + for (const e of object.list) { + message.list.push(TradingRewardLeaderboardEntry.fromPartial(e)); + } + } + return message; + }, +}; + +const baseTradingRewardLeaderboardEntry: object = { + amount: "", + address: "", + created_at: 0, +}; + +export const TradingRewardLeaderboardEntry = { + encode( + message: TradingRewardLeaderboardEntry, + writer: Writer = Writer.create() + ): Writer { + if (message.amount !== "") { + writer.uint32(10).string(message.amount); + } + if (message.address !== "") { + writer.uint32(18).string(message.address); + } + if (message.created_at !== 0) { + writer.uint32(24).int64(message.created_at); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): TradingRewardLeaderboardEntry { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseTradingRewardLeaderboardEntry, + } as TradingRewardLeaderboardEntry; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.amount = reader.string(); + break; + case 2: + message.address = reader.string(); + break; + case 3: + message.created_at = longToNumber(reader.int64() as Long); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): TradingRewardLeaderboardEntry { + const message = { + ...baseTradingRewardLeaderboardEntry, + } as TradingRewardLeaderboardEntry; + if (object.amount !== undefined && object.amount !== null) { + message.amount = String(object.amount); + } else { + message.amount = ""; + } + if (object.address !== undefined && object.address !== null) { + message.address = String(object.address); + } else { + message.address = ""; + } + if (object.created_at !== undefined && object.created_at !== null) { + message.created_at = Number(object.created_at); + } else { + message.created_at = 0; + } + return message; + }, + + toJSON(message: TradingRewardLeaderboardEntry): unknown { + const obj: any = {}; + message.amount !== undefined && (obj.amount = message.amount); + message.address !== undefined && (obj.address = message.address); + message.created_at !== undefined && (obj.created_at = message.created_at); + return obj; + }, + + fromPartial( + object: DeepPartial + ): TradingRewardLeaderboardEntry { + const message = { + ...baseTradingRewardLeaderboardEntry, + } as TradingRewardLeaderboardEntry; + if (object.amount !== undefined && object.amount !== null) { + message.amount = object.amount; + } else { + message.amount = ""; + } + if (object.address !== undefined && object.address !== null) { + message.address = object.address; + } else { + message.address = ""; + } + if (object.created_at !== undefined && object.created_at !== null) { + message.created_at = object.created_at; + } else { + message.created_at = 0; + } + return message; + }, +}; + +const baseTradingRewardCandidate: object = { + reward_id: "", + amount: "", + address: "", +}; + +export const TradingRewardCandidate = { + encode( + message: TradingRewardCandidate, + writer: Writer = Writer.create() + ): Writer { + if (message.reward_id !== "") { + writer.uint32(10).string(message.reward_id); + } + if (message.amount !== "") { + writer.uint32(18).string(message.amount); + } + if (message.address !== "") { + writer.uint32(26).string(message.address); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): TradingRewardCandidate { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseTradingRewardCandidate } as TradingRewardCandidate; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.reward_id = reader.string(); + break; + case 2: + message.amount = reader.string(); + break; + case 3: + message.address = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): TradingRewardCandidate { + const message = { ...baseTradingRewardCandidate } as TradingRewardCandidate; + if (object.reward_id !== undefined && object.reward_id !== null) { + message.reward_id = String(object.reward_id); + } else { + message.reward_id = ""; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = String(object.amount); + } else { + message.amount = ""; + } + if (object.address !== undefined && object.address !== null) { + message.address = String(object.address); + } else { + message.address = ""; + } + return message; + }, + + toJSON(message: TradingRewardCandidate): unknown { + const obj: any = {}; + message.reward_id !== undefined && (obj.reward_id = message.reward_id); + message.amount !== undefined && (obj.amount = message.amount); + message.address !== undefined && (obj.address = message.address); + return obj; + }, + + fromPartial( + object: DeepPartial + ): TradingRewardCandidate { + const message = { ...baseTradingRewardCandidate } as TradingRewardCandidate; + if (object.reward_id !== undefined && object.reward_id !== null) { + message.reward_id = object.reward_id; + } else { + message.reward_id = ""; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = object.amount; + } else { + message.amount = ""; + } + if (object.address !== undefined && object.address !== null) { + message.address = object.address; + } else { + message.address = ""; + } + return message; + }, +}; + +const baseMarketIdTradingRewardId: object = { reward_id: "", market_id: "" }; + +export const MarketIdTradingRewardId = { + encode( + message: MarketIdTradingRewardId, + writer: Writer = Writer.create() + ): Writer { + if (message.reward_id !== "") { + writer.uint32(10).string(message.reward_id); + } + if (message.market_id !== "") { + writer.uint32(18).string(message.market_id); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): MarketIdTradingRewardId { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseMarketIdTradingRewardId, + } as MarketIdTradingRewardId; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.reward_id = reader.string(); + break; + case 2: + message.market_id = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MarketIdTradingRewardId { + const message = { + ...baseMarketIdTradingRewardId, + } as MarketIdTradingRewardId; + if (object.reward_id !== undefined && object.reward_id !== null) { + message.reward_id = String(object.reward_id); + } else { + message.reward_id = ""; + } + if (object.market_id !== undefined && object.market_id !== null) { + message.market_id = String(object.market_id); + } else { + message.market_id = ""; + } + return message; + }, + + toJSON(message: MarketIdTradingRewardId): unknown { + const obj: any = {}; + message.reward_id !== undefined && (obj.reward_id = message.reward_id); + message.market_id !== undefined && (obj.market_id = message.market_id); + return obj; + }, + + fromPartial( + object: DeepPartial + ): MarketIdTradingRewardId { + const message = { + ...baseMarketIdTradingRewardId, + } as MarketIdTradingRewardId; + if (object.reward_id !== undefined && object.reward_id !== null) { + message.reward_id = object.reward_id; + } else { + message.reward_id = ""; + } + if (object.market_id !== undefined && object.market_id !== null) { + message.market_id = object.market_id; + } else { + message.market_id = ""; + } return message; }, }; +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + type Builtin = Date | Function | Uint8Array | string | number | undefined; export type DeepPartial = T extends Builtin ? T @@ -171,3 +699,15 @@ export type DeepPartial = T extends Builtin : T extends {} ? { [K in keyof T]?: DeepPartial } : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/vue/src/store/generated/index.ts b/vue/src/store/generated/index.ts index 20a55cc8..44ca0f46 100755 --- a/vue/src/store/generated/index.ts +++ b/vue/src/store/generated/index.ts @@ -1,22 +1,58 @@ // THIS FILE IS GENERATED AUTOMATICALLY. DO NOT MODIFY. -import BzeBurnerV1 from './bze.burner.v1' -import BzeCointrunkV1 from './bze.cointrunk.v1' -import BzeEpochsV1 from './bze.epochs.v1' -import BzeV1Rewards from './bze.v1.rewards' -import BzeScavenge from './bze.scavenge' -import BzeTokenfactoryV1 from './bze.tokenfactory.v1' -import BzeTradebinV1 from './bze.tradebin.v1' +import BzeAlphateamBzeBzeBurnerV1 from './bze-alphateam/bze/bze.burner.v1' +import BzeAlphateamBzeBzeCointrunkV1 from './bze-alphateam/bze/bze.cointrunk.v1' +import BzeAlphateamBzeBzeCointrunk from './bze-alphateam/bze/bze.cointrunk' +import BzeAlphateamBzeBzeEpochsV1 from './bze-alphateam/bze/bze.epochs.v1' +import BzeAlphateamBzeBzeScavenge from './bze-alphateam/bze/bze.scavenge' +import BzeAlphateamBzeBzeTokenfactoryV1 from './bze-alphateam/bze/bze.tokenfactory.v1' +import BzeAlphateamBzeBzeTradebinV1 from './bze-alphateam/bze/bze.tradebin.v1' +import BzeAlphateamBzeBzeV1Rewards from './bze-alphateam/bze/bze.v1.rewards' +import BzeAlphateamBzeBzealphateamBzeBurner from './bze-alphateam/bze/bzealphateam.bze.burner' +import BzeAlphateamBzeBzealphateamBzeCointrunk from './bze-alphateam/bze/bzealphateam.bze.cointrunk' +import BzeAlphateamBzeBzealphateamBzeEpochs from './bze-alphateam/bze/bzealphateam.bze.epochs' +import BzeAlphateamBzeBzealphateamBzeRewards from './bze-alphateam/bze/bzealphateam.bze.rewards' +import BzeAlphateamBzeBzealphateamBzeTokenfactory from './bze-alphateam/bze/bzealphateam.bze.tokenfactory' +import BzeAlphateamBzeBzealphateamBzeTradebin from './bze-alphateam/bze/bzealphateam.bze.tradebin' +import CosmosCosmosSdkCosmosAuthzV1Beta1 from './cosmos/cosmos-sdk/cosmos.authz.v1beta1' +import CosmosCosmosSdkCosmosBankV1Beta1 from './cosmos/cosmos-sdk/cosmos.bank.v1beta1' +import CosmosCosmosSdkCosmosCrisisV1Beta1 from './cosmos/cosmos-sdk/cosmos.crisis.v1beta1' +import CosmosCosmosSdkCosmosDistributionV1Beta1 from './cosmos/cosmos-sdk/cosmos.distribution.v1beta1' +import CosmosCosmosSdkCosmosEvidenceV1Beta1 from './cosmos/cosmos-sdk/cosmos.evidence.v1beta1' +import CosmosCosmosSdkCosmosFeegrantV1Beta1 from './cosmos/cosmos-sdk/cosmos.feegrant.v1beta1' +import CosmosCosmosSdkCosmosGovV1Beta1 from './cosmos/cosmos-sdk/cosmos.gov.v1beta1' +import CosmosCosmosSdkCosmosSlashingV1Beta1 from './cosmos/cosmos-sdk/cosmos.slashing.v1beta1' +import CosmosCosmosSdkCosmosStakingV1Beta1 from './cosmos/cosmos-sdk/cosmos.staking.v1beta1' +import CosmosCosmosSdkCosmosVestingV1Beta1 from './cosmos/cosmos-sdk/cosmos.vesting.v1beta1' +import CosmosIbcGoIbcApplicationsTransferV1 from './cosmos/ibc-go/ibc.applications.transfer.v1' export default { - BzeBurnerV1: load(BzeBurnerV1, 'bze.burner.v1'), - BzeCointrunkV1: load(BzeCointrunkV1, 'bze.cointrunk.v1'), - BzeEpochsV1: load(BzeEpochsV1, 'bze.epochs.v1'), - BzeV1Rewards: load(BzeV1Rewards, 'bze.v1.rewards'), - BzeScavenge: load(BzeScavenge, 'bze.scavenge'), - BzeTokenfactoryV1: load(BzeTokenfactoryV1, 'bze.tokenfactory.v1'), - BzeTradebinV1: load(BzeTradebinV1, 'bze.tradebin.v1'), + BzeAlphateamBzeBzeBurnerV1: load(BzeAlphateamBzeBzeBurnerV1, 'bze.burner.v1'), + BzeAlphateamBzeBzeCointrunkV1: load(BzeAlphateamBzeBzeCointrunkV1, 'bze.cointrunk.v1'), + BzeAlphateamBzeBzeCointrunk: load(BzeAlphateamBzeBzeCointrunk, 'bze.cointrunk'), + BzeAlphateamBzeBzeEpochsV1: load(BzeAlphateamBzeBzeEpochsV1, 'bze.epochs.v1'), + BzeAlphateamBzeBzeScavenge: load(BzeAlphateamBzeBzeScavenge, 'bze.scavenge'), + BzeAlphateamBzeBzeTokenfactoryV1: load(BzeAlphateamBzeBzeTokenfactoryV1, 'bze.tokenfactory.v1'), + BzeAlphateamBzeBzeTradebinV1: load(BzeAlphateamBzeBzeTradebinV1, 'bze.tradebin.v1'), + BzeAlphateamBzeBzeV1Rewards: load(BzeAlphateamBzeBzeV1Rewards, 'bze.v1.rewards'), + BzeAlphateamBzeBzealphateamBzeBurner: load(BzeAlphateamBzeBzealphateamBzeBurner, 'bzealphateam.bze.burner'), + BzeAlphateamBzeBzealphateamBzeCointrunk: load(BzeAlphateamBzeBzealphateamBzeCointrunk, 'bzealphateam.bze.cointrunk'), + BzeAlphateamBzeBzealphateamBzeEpochs: load(BzeAlphateamBzeBzealphateamBzeEpochs, 'bzealphateam.bze.epochs'), + BzeAlphateamBzeBzealphateamBzeRewards: load(BzeAlphateamBzeBzealphateamBzeRewards, 'bzealphateam.bze.rewards'), + BzeAlphateamBzeBzealphateamBzeTokenfactory: load(BzeAlphateamBzeBzealphateamBzeTokenfactory, 'bzealphateam.bze.tokenfactory'), + BzeAlphateamBzeBzealphateamBzeTradebin: load(BzeAlphateamBzeBzealphateamBzeTradebin, 'bzealphateam.bze.tradebin'), + CosmosCosmosSdkCosmosAuthzV1Beta1: load(CosmosCosmosSdkCosmosAuthzV1Beta1, 'cosmos.authz.v1beta1'), + CosmosCosmosSdkCosmosBankV1Beta1: load(CosmosCosmosSdkCosmosBankV1Beta1, 'cosmos.bank.v1beta1'), + CosmosCosmosSdkCosmosCrisisV1Beta1: load(CosmosCosmosSdkCosmosCrisisV1Beta1, 'cosmos.crisis.v1beta1'), + CosmosCosmosSdkCosmosDistributionV1Beta1: load(CosmosCosmosSdkCosmosDistributionV1Beta1, 'cosmos.distribution.v1beta1'), + CosmosCosmosSdkCosmosEvidenceV1Beta1: load(CosmosCosmosSdkCosmosEvidenceV1Beta1, 'cosmos.evidence.v1beta1'), + CosmosCosmosSdkCosmosFeegrantV1Beta1: load(CosmosCosmosSdkCosmosFeegrantV1Beta1, 'cosmos.feegrant.v1beta1'), + CosmosCosmosSdkCosmosGovV1Beta1: load(CosmosCosmosSdkCosmosGovV1Beta1, 'cosmos.gov.v1beta1'), + CosmosCosmosSdkCosmosSlashingV1Beta1: load(CosmosCosmosSdkCosmosSlashingV1Beta1, 'cosmos.slashing.v1beta1'), + CosmosCosmosSdkCosmosStakingV1Beta1: load(CosmosCosmosSdkCosmosStakingV1Beta1, 'cosmos.staking.v1beta1'), + CosmosCosmosSdkCosmosVestingV1Beta1: load(CosmosCosmosSdkCosmosVestingV1Beta1, 'cosmos.vesting.v1beta1'), + CosmosIbcGoIbcApplicationsTransferV1: load(CosmosIbcGoIbcApplicationsTransferV1, 'ibc.applications.transfer.v1'), } @@ -36,4 +72,4 @@ function load(mod, fullns) { }) } } -} \ No newline at end of file +} diff --git a/vue/src/store/generated/package.json b/vue/src/store/generated/package.json index ba7a2dc4..4d1bd602 100755 --- a/vue/src/store/generated/package.json +++ b/vue/src/store/generated/package.json @@ -1,8 +1,8 @@ { - "name": "bze-alphateam-bze-vue", - "version": "0.0.1", - "description": "Autogenerated Vue Utils", - "author": "Ignite Codegen ", + "name": "bze-alphateam-bze-js", + "version": "0.1.0", + "description": "Autogenerated cosmos modules vuex store", + "author": "Starport Codegen ", "license": "Apache-2.0", "licenses": [ { @@ -10,17 +10,8 @@ "url": "http://www.apache.org/licenses/LICENSE-2.0" } ], - "main": "index.ts", + "main": "index.js", "publishConfig": { "access": "public" - }, - "dependencies": { - "bze-alphateam-bze-client": "0.0.1", - "buffer": "^6.0.3" - }, - "peerDependencies": { - "@cosmjs/proto-signing": "0.27.0", - "@cosmjs/stargate": "0.27.0", - "vue": "3.2.31" } } From 7b91d00ea8d0612de98f5bedee1c78a6da019bc1 Mon Sep 17 00:00:00 2001 From: faneaatiku Date: Sat, 13 Apr 2024 22:49:37 +0200 Subject: [PATCH 24/35] added trading reward leaderboard queries by reward id and market id --- docs/static/openapi.yml | 135 +++ go.mod | 3 + go.sum | 12 + proto/rewards/query.proto | 26 + .../bze-alphateam/bze/bze.v1.rewards/index.ts | 138 ++- .../bze/bze.v1.rewards/module/index.ts | 18 +- .../bze/bze.v1.rewards/module/rest.ts | 51 + .../module/types/rewards/query.ts | 333 +++++- x/rewards/client/cli/query.go | 4 + ...get_market_id_trading_reward_id_handler.go | 46 + .../query_get_trading_reward_leaderboard.go | 46 + ...get_market_id_trading_reward_id_handler.go | 25 + ...pc_query_get_trading_reward_leaderboard.go | 24 + .../types/message_claim_staking_rewards.go | 2 +- x/rewards/types/query.pb.go | 1028 +++++++++++++++-- x/rewards/types/query.pb.gw.go | 184 +++ 16 files changed, 1908 insertions(+), 167 deletions(-) create mode 100644 x/rewards/client/cli/query_get_market_id_trading_reward_id_handler.go create mode 100644 x/rewards/client/cli/query_get_trading_reward_leaderboard.go create mode 100644 x/rewards/keeper/grpc_query_get_market_id_trading_reward_id_handler.go create mode 100644 x/rewards/keeper/grpc_query_get_trading_reward_leaderboard.go diff --git a/docs/static/openapi.yml b/docs/static/openapi.yml index 10ee57f3..c0399b31 100644 --- a/docs/static/openapi.yml +++ b/docs/static/openapi.yml @@ -2151,6 +2151,92 @@ paths: type: boolean tags: - Query + '/bze-alphateam/bze/rewards/get_market_id_trading_reward_id_handler/{marketId}': + get: + summary: Queries a list of GetMarketIdTradingRewardIdHandler items. + operationId: BzeV1RewardsGetMarketIdTradingRewardIdHandler + responses: + '200': + description: A successful response. + schema: + type: object + 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: {} + parameters: + - name: marketId + in: path + required: true + type: string + tags: + - Query + '/bze/rewards/v1/get_trading_reward_leaderboard/{reward_id}': + get: + summary: Queries a list of GetTradingRewardLeaderboard items. + operationId: BzeV1RewardsGetTradingRewardLeaderboardHandler + responses: + '200': + description: A successful response. + schema: + type: object + properties: + leaderboard: + type: object + properties: + reward_id: + type: string + list: + type: array + items: + type: object + properties: + amount: + type: string + address: + type: string + created_at: + type: string + format: int64 + 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: {} + parameters: + - name: reward_id + in: path + required: true + type: string + tags: + - Query /bze/rewards/v1/params: get: summary: Parameters queries the parameters of the module. @@ -34808,6 +34894,8 @@ definitions: repeated Bar results = 1; PageResponse page = 2; } + bze.v1.rewards.QueryGetMarketIdTradingRewardIdHandlerResponse: + type: object bze.v1.rewards.QueryGetStakingRewardParticipantResponse: type: object properties: @@ -34883,6 +34971,26 @@ definitions: distributed_stake: type: string title: S + bze.v1.rewards.QueryGetTradingRewardLeaderboardResponse: + type: object + properties: + leaderboard: + type: object + properties: + reward_id: + type: string + list: + type: array + items: + type: object + properties: + amount: + type: string + address: + type: string + created_at: + type: string + format: int64 bze.v1.rewards.QueryGetTradingRewardResponse: type: object properties: @@ -34980,6 +35088,33 @@ definitions: expire_at: type: integer format: int64 + bze.v1.rewards.TradingRewardLeaderboard: + type: object + properties: + reward_id: + type: string + list: + type: array + items: + type: object + properties: + amount: + type: string + address: + type: string + created_at: + type: string + format: int64 + bze.v1.rewards.TradingRewardLeaderboardEntry: + type: object + properties: + amount: + type: string + address: + type: string + created_at: + type: string + format: int64 cosmos.auth.v1beta1.Params: type: object properties: diff --git a/go.mod b/go.mod index 23080d06..0519be13 100644 --- a/go.mod +++ b/go.mod @@ -99,6 +99,7 @@ require ( github.com/fsnotify/fsnotify v1.6.0 // indirect github.com/fzipp/gocyclo v0.6.0 // indirect github.com/getsentry/sentry-go v0.17.0 // indirect + github.com/ghodss/yaml v1.0.0 // indirect github.com/go-critic/go-critic v0.6.5 // indirect github.com/go-kit/kit v0.12.0 // indirect github.com/go-kit/log v0.2.1 // indirect @@ -115,6 +116,7 @@ require ( github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect github.com/gofrs/flock v0.8.1 // indirect github.com/gogo/gateway v1.1.0 // indirect + github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b // indirect github.com/golang/snappy v0.0.4 // indirect github.com/golangci/check v0.0.0-20180506172741-cfe4005ccda2 // indirect github.com/golangci/dupl v0.0.0-20180902072040-3e9179ac440a // indirect @@ -137,6 +139,7 @@ require ( github.com/gostaticanalysis/forcetypeassert v0.1.0 // indirect github.com/gostaticanalysis/nilerr v0.1.1 // indirect github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 // indirect + github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1 // 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 diff --git a/go.sum b/go.sum index bd2604ca..5fd2428c 100644 --- a/go.sum +++ b/go.sum @@ -154,6 +154,7 @@ github.com/aymerick/douceur v0.2.0 h1:Mv+mAeH1Q+n9Fr+oyamOlAkUNPWPlA8PPGR0QAaYuP github.com/aymerick/douceur v0.2.0/go.mod h1:wlT5vV2O3h55X9m7iVYN0TBM0NH/MmbLnd30/FjWUq4= github.com/aymerick/raymond v2.0.3-0.20180322193309-b565731e1464+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g= github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= +github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= @@ -261,6 +262,7 @@ github.com/containerd/continuity v0.3.0 h1:nisirsYROK15TAMVukJOUyGJjz4BNQJBVsNvA github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= +github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= github.com/coreos/go-systemd v0.0.0-20180511133405-39ca1b05acc7/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/coreos/go-systemd/v22 v22.3.3-0.20220203105225-a9a7ef127534/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= @@ -395,6 +397,7 @@ github.com/getsentry/sentry-go v0.12.0/go.mod h1:NSap0JBYWzHND8oMbyi0+XZhUalc1TB github.com/getsentry/sentry-go v0.17.0 h1:UustVWnOoDFHBS7IJUB2QK/nB5pap748ZEp0swnQJak= github.com/getsentry/sentry-go v0.17.0/go.mod h1:B82dxtBvxG0KaPD8/hfSV+VcHD+Lg/xUS4JuQn1P4cM= github.com/ghemawat/stream v0.0.0-20171120220530-696b145b53b9/go.mod h1:106OIgooyS7OzLDOpUGgm9fA3bQENb/cFSyyBmMoJDs= +github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/gin-contrib/sse v0.0.0-20190301062529-5545eab6dad3/go.mod h1:VJ0WA2NBN22VlZ2dKZQPAPnyWw5XTlK1KymzLKsr59s= github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= @@ -487,11 +490,13 @@ github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzq github.com/golang-jwt/jwt/v4 v4.3.0/go.mod h1:/xlHOz8bRuivTWchD4jCa+NbatV+wEUSzwAxVc6locg= github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k= github.com/golang/geo v0.0.0-20190916061304-5b978397cfec/go.mod h1:QZ0nwyI2jOfgRAoBvP+ab5aRr7c9x7lhGEJrKvBwjWI= +github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= @@ -499,6 +504,7 @@ github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= +github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.0/go.mod h1:Qd/q+1AKNOZr9uGQzbzCmRO6sUih6GTPZv6a1/R87v0= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= @@ -633,6 +639,8 @@ github.com/grpc-ecosystem/grpc-gateway v1.8.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4M0+kPpLofRdBo= github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1 h1:/c3QmbOGMGTOumP2iT/rCwB7b0QDGLKzqOmktBjT+Is= +github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1/go.mod h1:5SN9VR2LTsRFsrEC6FHgRbTWrTHu6tqPeKxEQv15giM= 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= @@ -648,6 +656,7 @@ github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brv github.com/hashicorp/go-bexpr v0.1.10/go.mod h1:oxlubA2vC/gFVfX1A6JGp7ls7uCDlfJn732ehYYg+g0= github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= +github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48= github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= github.com/hashicorp/go-immutable-radix v1.3.1 h1:DKHmCUm2hRBK510BaiZlwvpD40f8bJFeZnpfm2KLowc= github.com/hashicorp/go-immutable-radix v1.3.1/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= @@ -657,6 +666,7 @@ github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+l github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= github.com/hashicorp/go-retryablehttp v0.5.3/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs= github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU= +github.com/hashicorp/go-rootcerts v1.0.2/go.mod h1:pqUvnprVnM5bf7AOirdbb01K4ccR319Vf4pU3K5EGc8= github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU= github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4= github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= @@ -1314,6 +1324,7 @@ go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= +go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= @@ -1321,6 +1332,7 @@ go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/atomic v1.10.0 h1:9qC72Qh0+3MqyJbAn8YU5xVq1frD8bn3JtD2oXtafVQ= go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= go.uber.org/goleak v1.1.11 h1:wy28qYRKZgnJTxGxvye5/wgWr1EKjmUDGYox5mGlRlI= +go.uber.org/goleak v1.1.11/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4= go.uber.org/multierr v1.8.0 h1:dg6GjLku4EH+249NNmoIciG9N/jURbDG+pFlTkhzIC8= diff --git a/proto/rewards/query.proto b/proto/rewards/query.proto index dde5cf24..c8cdadc2 100644 --- a/proto/rewards/query.proto +++ b/proto/rewards/query.proto @@ -48,6 +48,16 @@ service Query { option (google.api.http).get = "/bze/rewards/v1/staking_reward_participants"; } + // Queries a list of GetTradingRewardLeaderboard items. + rpc GetTradingRewardLeaderboardHandler(QueryGetTradingRewardLeaderboardRequest) returns (QueryGetTradingRewardLeaderboardResponse) { + option (google.api.http).get = "/bze/rewards/v1/trading_reward_leaderboard/{reward_id}"; + } + +// Queries a list of GetMarketIdTradingRewardIdHandler items. + rpc GetMarketIdTradingRewardIdHandler(QueryGetMarketIdTradingRewardIdHandlerRequest) returns (QueryGetMarketIdTradingRewardIdHandlerResponse) { + option (google.api.http).get = "/bze/rewards/v1/market_id_trading_reward_id"; + } + // this line is used by starport scaffolding # 2 } @@ -114,4 +124,20 @@ message QueryAllStakingRewardParticipantResponse { cosmos.base.query.v1beta1.PageResponse pagination = 2; } +message QueryGetTradingRewardLeaderboardRequest { + string reward_id = 1; +} + +message QueryGetTradingRewardLeaderboardResponse { + TradingRewardLeaderboard leaderboard = 1; +} + +message QueryGetMarketIdTradingRewardIdHandlerRequest { + string market_id = 1; +} + +message QueryGetMarketIdTradingRewardIdHandlerResponse { + MarketIdTradingRewardId market_id_reward_id = 1; +} + // this line is used by starport scaffolding # 3 diff --git a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/index.ts b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/index.ts index 7a0e590e..4e5e8d1a 100755 --- a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/index.ts +++ b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/index.ts @@ -57,6 +57,8 @@ const getDefaultState = () => { TradingRewardAll: {}, StakingRewardParticipant: {}, StakingRewardParticipantAll: {}, + GetTradingRewardLeaderboardHandler: {}, + GetMarketIdTradingRewardIdHandler: {}, _Structure: { Params: getStructure(Params.fromPartial({})), @@ -139,6 +141,18 @@ export default { } return state.StakingRewardParticipantAll[JSON.stringify(params)] ?? {} }, + getGetTradingRewardLeaderboardHandler: (state) => (params = { params: {}}) => { + if (!( params).query) { + ( params).query=null + } + return state.GetTradingRewardLeaderboardHandler[JSON.stringify(params)] ?? {} + }, + getGetMarketIdTradingRewardIdHandler: (state) => (params = { params: {}}) => { + if (!( params).query) { + ( params).query=null + } + return state.GetMarketIdTradingRewardIdHandler[JSON.stringify(params)] ?? {} + }, getTypeStructure: (state) => (type) => { return state._Structure[type].fields @@ -343,18 +357,62 @@ export default { }, - async sendMsgExitStaking({ rootGetters }, { value, fee = [], memo = '' }) { + + + + + + async QueryGetTradingRewardLeaderboardHandler({ commit, rootGetters, getters }, { options: { subscribe, all} = { subscribe:false, all:false}, params, query=null }) { + try { + const key = params ?? {}; + const queryClient=await initQueryClient(rootGetters) + let value= (await queryClient.queryGetTradingRewardLeaderboardHandler( key.reward_id)).data + + + commit('QUERY', { query: 'GetTradingRewardLeaderboardHandler', key: { params: {...key}, query}, value }) + if (subscribe) commit('SUBSCRIBE', { action: 'QueryGetTradingRewardLeaderboardHandler', payload: { options: { all }, params: {...key},query }}) + return getters['getGetTradingRewardLeaderboardHandler']( { params: {...key}, query}) ?? {} + } catch (e) { + throw new Error('QueryClient:QueryGetTradingRewardLeaderboardHandler API Node Unavailable. Could not perform query: ' + e.message) + + } + }, + + + + + + + + async QueryGetMarketIdTradingRewardIdHandler({ commit, rootGetters, getters }, { options: { subscribe, all} = { subscribe:false, all:false}, params, query=null }) { + try { + const key = params ?? {}; + const queryClient=await initQueryClient(rootGetters) + let value= (await queryClient.queryGetMarketIdTradingRewardIdHandler( key.marketId)).data + + + commit('QUERY', { query: 'GetMarketIdTradingRewardIdHandler', key: { params: {...key}, query}, value }) + if (subscribe) commit('SUBSCRIBE', { action: 'QueryGetMarketIdTradingRewardIdHandler', payload: { options: { all }, params: {...key},query }}) + return getters['getGetMarketIdTradingRewardIdHandler']( { params: {...key}, query}) ?? {} + } catch (e) { + throw new Error('QueryClient:QueryGetMarketIdTradingRewardIdHandler API Node Unavailable. Could not perform query: ' + e.message) + + } + }, + + + async sendMsgClaimStakingRewards({ rootGetters }, { value, fee = [], memo = '' }) { try { const txClient=await initTxClient(rootGetters) - const msg = await txClient.msgExitStaking(value) + const msg = await txClient.msgClaimStakingRewards(value) const result = await txClient.signAndBroadcast([msg], {fee: { amount: fee, gas: "200000" }, memo}) return result } catch (e) { if (e == MissingWalletError) { - throw new Error('TxClient:MsgExitStaking:Init Could not initialize signing client. Wallet is required.') + throw new Error('TxClient:MsgClaimStakingRewards:Init Could not initialize signing client. Wallet is required.') }else{ - throw new Error('TxClient:MsgExitStaking:Send Could not broadcast Tx: '+ e.message) + throw new Error('TxClient:MsgClaimStakingRewards:Send Could not broadcast Tx: '+ e.message) } } }, @@ -373,77 +431,77 @@ export default { } } }, - async sendMsgClaimStakingRewards({ rootGetters }, { value, fee = [], memo = '' }) { + async sendMsgCreateTradingReward({ rootGetters }, { value, fee = [], memo = '' }) { try { const txClient=await initTxClient(rootGetters) - const msg = await txClient.msgClaimStakingRewards(value) + const msg = await txClient.msgCreateTradingReward(value) const result = await txClient.signAndBroadcast([msg], {fee: { amount: fee, gas: "200000" }, memo}) return result } catch (e) { if (e == MissingWalletError) { - throw new Error('TxClient:MsgClaimStakingRewards:Init Could not initialize signing client. Wallet is required.') + throw new Error('TxClient:MsgCreateTradingReward:Init Could not initialize signing client. Wallet is required.') }else{ - throw new Error('TxClient:MsgClaimStakingRewards:Send Could not broadcast Tx: '+ e.message) + throw new Error('TxClient:MsgCreateTradingReward:Send Could not broadcast Tx: '+ e.message) } } }, - async sendMsgCreateTradingReward({ rootGetters }, { value, fee = [], memo = '' }) { + async sendMsgExitStaking({ rootGetters }, { value, fee = [], memo = '' }) { try { const txClient=await initTxClient(rootGetters) - const msg = await txClient.msgCreateTradingReward(value) + const msg = await txClient.msgExitStaking(value) const result = await txClient.signAndBroadcast([msg], {fee: { amount: fee, gas: "200000" }, memo}) return result } catch (e) { if (e == MissingWalletError) { - throw new Error('TxClient:MsgCreateTradingReward:Init Could not initialize signing client. Wallet is required.') + throw new Error('TxClient:MsgExitStaking:Init Could not initialize signing client. Wallet is required.') }else{ - throw new Error('TxClient:MsgCreateTradingReward:Send Could not broadcast Tx: '+ e.message) + throw new Error('TxClient:MsgExitStaking:Send Could not broadcast Tx: '+ e.message) } } }, - async sendMsgUpdateStakingReward({ rootGetters }, { value, fee = [], memo = '' }) { + async sendMsgCreateStakingReward({ rootGetters }, { value, fee = [], memo = '' }) { try { const txClient=await initTxClient(rootGetters) - const msg = await txClient.msgUpdateStakingReward(value) + const msg = await txClient.msgCreateStakingReward(value) const result = await txClient.signAndBroadcast([msg], {fee: { amount: fee, gas: "200000" }, memo}) return result } catch (e) { if (e == MissingWalletError) { - throw new Error('TxClient:MsgUpdateStakingReward:Init Could not initialize signing client. Wallet is required.') + throw new Error('TxClient:MsgCreateStakingReward:Init Could not initialize signing client. Wallet is required.') }else{ - throw new Error('TxClient:MsgUpdateStakingReward:Send Could not broadcast Tx: '+ e.message) + throw new Error('TxClient:MsgCreateStakingReward:Send Could not broadcast Tx: '+ e.message) } } }, - async sendMsgCreateStakingReward({ rootGetters }, { value, fee = [], memo = '' }) { + async sendMsgUpdateStakingReward({ rootGetters }, { value, fee = [], memo = '' }) { try { const txClient=await initTxClient(rootGetters) - const msg = await txClient.msgCreateStakingReward(value) + const msg = await txClient.msgUpdateStakingReward(value) const result = await txClient.signAndBroadcast([msg], {fee: { amount: fee, gas: "200000" }, memo}) return result } catch (e) { if (e == MissingWalletError) { - throw new Error('TxClient:MsgCreateStakingReward:Init Could not initialize signing client. Wallet is required.') + throw new Error('TxClient:MsgUpdateStakingReward:Init Could not initialize signing client. Wallet is required.') }else{ - throw new Error('TxClient:MsgCreateStakingReward:Send Could not broadcast Tx: '+ e.message) + throw new Error('TxClient:MsgUpdateStakingReward:Send Could not broadcast Tx: '+ e.message) } } }, - async MsgExitStaking({ rootGetters }, { value }) { + async MsgClaimStakingRewards({ rootGetters }, { value }) { try { const txClient=await initTxClient(rootGetters) - const msg = await txClient.msgExitStaking(value) + const msg = await txClient.msgClaimStakingRewards(value) return msg } catch (e) { if (e == MissingWalletError) { - throw new Error('TxClient:MsgExitStaking:Init Could not initialize signing client. Wallet is required.') + throw new Error('TxClient:MsgClaimStakingRewards:Init Could not initialize signing client. Wallet is required.') } else{ - throw new Error('TxClient:MsgExitStaking:Create Could not create message: ' + e.message) + throw new Error('TxClient:MsgClaimStakingRewards:Create Could not create message: ' + e.message) } } }, @@ -460,55 +518,55 @@ export default { } } }, - async MsgClaimStakingRewards({ rootGetters }, { value }) { + async MsgCreateTradingReward({ rootGetters }, { value }) { try { const txClient=await initTxClient(rootGetters) - const msg = await txClient.msgClaimStakingRewards(value) + const msg = await txClient.msgCreateTradingReward(value) return msg } catch (e) { if (e == MissingWalletError) { - throw new Error('TxClient:MsgClaimStakingRewards:Init Could not initialize signing client. Wallet is required.') + throw new Error('TxClient:MsgCreateTradingReward:Init Could not initialize signing client. Wallet is required.') } else{ - throw new Error('TxClient:MsgClaimStakingRewards:Create Could not create message: ' + e.message) + throw new Error('TxClient:MsgCreateTradingReward:Create Could not create message: ' + e.message) } } }, - async MsgCreateTradingReward({ rootGetters }, { value }) { + async MsgExitStaking({ rootGetters }, { value }) { try { const txClient=await initTxClient(rootGetters) - const msg = await txClient.msgCreateTradingReward(value) + const msg = await txClient.msgExitStaking(value) return msg } catch (e) { if (e == MissingWalletError) { - throw new Error('TxClient:MsgCreateTradingReward:Init Could not initialize signing client. Wallet is required.') + throw new Error('TxClient:MsgExitStaking:Init Could not initialize signing client. Wallet is required.') } else{ - throw new Error('TxClient:MsgCreateTradingReward:Create Could not create message: ' + e.message) + throw new Error('TxClient:MsgExitStaking:Create Could not create message: ' + e.message) } } }, - async MsgUpdateStakingReward({ rootGetters }, { value }) { + async MsgCreateStakingReward({ rootGetters }, { value }) { try { const txClient=await initTxClient(rootGetters) - const msg = await txClient.msgUpdateStakingReward(value) + const msg = await txClient.msgCreateStakingReward(value) return msg } catch (e) { if (e == MissingWalletError) { - throw new Error('TxClient:MsgUpdateStakingReward:Init Could not initialize signing client. Wallet is required.') + throw new Error('TxClient:MsgCreateStakingReward:Init Could not initialize signing client. Wallet is required.') } else{ - throw new Error('TxClient:MsgUpdateStakingReward:Create Could not create message: ' + e.message) + throw new Error('TxClient:MsgCreateStakingReward:Create Could not create message: ' + e.message) } } }, - async MsgCreateStakingReward({ rootGetters }, { value }) { + async MsgUpdateStakingReward({ rootGetters }, { value }) { try { const txClient=await initTxClient(rootGetters) - const msg = await txClient.msgCreateStakingReward(value) + const msg = await txClient.msgUpdateStakingReward(value) return msg } catch (e) { if (e == MissingWalletError) { - throw new Error('TxClient:MsgCreateStakingReward:Init Could not initialize signing client. Wallet is required.') + throw new Error('TxClient:MsgUpdateStakingReward:Init Could not initialize signing client. Wallet is required.') } else{ - throw new Error('TxClient:MsgCreateStakingReward:Create Could not create message: ' + e.message) + throw new Error('TxClient:MsgUpdateStakingReward:Create Could not create message: ' + e.message) } } }, diff --git a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/index.ts b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/index.ts index 73aff351..c277808f 100755 --- a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/index.ts +++ b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/index.ts @@ -4,21 +4,21 @@ import { StdFee } from "@cosmjs/launchpad"; import { SigningStargateClient } from "@cosmjs/stargate"; import { Registry, OfflineSigner, EncodeObject, DirectSecp256k1HdWallet } from "@cosmjs/proto-signing"; import { Api } from "./rest"; -import { MsgExitStaking } from "./types/rewards/tx"; -import { MsgJoinStaking } from "./types/rewards/tx"; import { MsgClaimStakingRewards } from "./types/rewards/tx"; +import { MsgJoinStaking } from "./types/rewards/tx"; import { MsgCreateTradingReward } from "./types/rewards/tx"; -import { MsgUpdateStakingReward } from "./types/rewards/tx"; +import { MsgExitStaking } from "./types/rewards/tx"; import { MsgCreateStakingReward } from "./types/rewards/tx"; +import { MsgUpdateStakingReward } from "./types/rewards/tx"; const types = [ - ["/bze.v1.rewards.MsgExitStaking", MsgExitStaking], - ["/bze.v1.rewards.MsgJoinStaking", MsgJoinStaking], ["/bze.v1.rewards.MsgClaimStakingRewards", MsgClaimStakingRewards], + ["/bze.v1.rewards.MsgJoinStaking", MsgJoinStaking], ["/bze.v1.rewards.MsgCreateTradingReward", MsgCreateTradingReward], - ["/bze.v1.rewards.MsgUpdateStakingReward", MsgUpdateStakingReward], + ["/bze.v1.rewards.MsgExitStaking", MsgExitStaking], ["/bze.v1.rewards.MsgCreateStakingReward", MsgCreateStakingReward], + ["/bze.v1.rewards.MsgUpdateStakingReward", MsgUpdateStakingReward], ]; export const MissingWalletError = new Error("wallet is required"); @@ -51,12 +51,12 @@ const txClient = async (wallet: OfflineSigner, { addr: addr }: TxClientOptions = return { signAndBroadcast: (msgs: EncodeObject[], { fee, memo }: SignAndBroadcastOptions = {fee: defaultFee, memo: ""}) => client.signAndBroadcast(address, msgs, fee,memo), - msgExitStaking: (data: MsgExitStaking): EncodeObject => ({ typeUrl: "/bze.v1.rewards.MsgExitStaking", value: MsgExitStaking.fromPartial( data ) }), - msgJoinStaking: (data: MsgJoinStaking): EncodeObject => ({ typeUrl: "/bze.v1.rewards.MsgJoinStaking", value: MsgJoinStaking.fromPartial( data ) }), msgClaimStakingRewards: (data: MsgClaimStakingRewards): EncodeObject => ({ typeUrl: "/bze.v1.rewards.MsgClaimStakingRewards", value: MsgClaimStakingRewards.fromPartial( data ) }), + msgJoinStaking: (data: MsgJoinStaking): EncodeObject => ({ typeUrl: "/bze.v1.rewards.MsgJoinStaking", value: MsgJoinStaking.fromPartial( data ) }), msgCreateTradingReward: (data: MsgCreateTradingReward): EncodeObject => ({ typeUrl: "/bze.v1.rewards.MsgCreateTradingReward", value: MsgCreateTradingReward.fromPartial( data ) }), - msgUpdateStakingReward: (data: MsgUpdateStakingReward): EncodeObject => ({ typeUrl: "/bze.v1.rewards.MsgUpdateStakingReward", value: MsgUpdateStakingReward.fromPartial( data ) }), + msgExitStaking: (data: MsgExitStaking): EncodeObject => ({ typeUrl: "/bze.v1.rewards.MsgExitStaking", value: MsgExitStaking.fromPartial( data ) }), msgCreateStakingReward: (data: MsgCreateStakingReward): EncodeObject => ({ typeUrl: "/bze.v1.rewards.MsgCreateStakingReward", value: MsgCreateStakingReward.fromPartial( data ) }), + msgUpdateStakingReward: (data: MsgUpdateStakingReward): EncodeObject => ({ typeUrl: "/bze.v1.rewards.MsgUpdateStakingReward", value: MsgUpdateStakingReward.fromPartial( data ) }), }; }; diff --git a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/rest.ts b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/rest.ts index f7cb5167..456d755e 100644 --- a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/rest.ts +++ b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/rest.ts @@ -76,6 +76,8 @@ export interface RewardsQueryAllTradingRewardResponse { pagination?: V1Beta1PageResponse; } +export type RewardsQueryGetMarketIdTradingRewardIdHandlerResponse = object; + export interface RewardsQueryGetStakingRewardParticipantResponse { list?: V1RewardsStakingRewardParticipant[]; @@ -95,6 +97,10 @@ export interface RewardsQueryGetStakingRewardResponse { staking_reward?: V1RewardsStakingReward; } +export interface RewardsQueryGetTradingRewardLeaderboardResponse { + leaderboard?: RewardsTradingRewardLeaderboard; +} + export interface RewardsQueryGetTradingRewardResponse { trading_reward?: V1RewardsTradingReward; } @@ -107,6 +113,19 @@ export interface RewardsQueryParamsResponse { params?: V1RewardsParams; } +export interface RewardsTradingRewardLeaderboard { + reward_id?: string; + list?: RewardsTradingRewardLeaderboardEntry[]; +} + +export interface RewardsTradingRewardLeaderboardEntry { + amount?: string; + address?: string; + + /** @format int64 */ + created_at?: string; +} + export interface RpcStatus { /** @format int32 */ code?: number; @@ -425,6 +444,38 @@ export class HttpClient { * @version version not set */ export class Api extends HttpClient { + /** + * No description + * + * @tags Query + * @name QueryGetMarketIdTradingRewardIdHandler + * @summary Queries a list of GetMarketIdTradingRewardIdHandler items. + * @request GET:/bze-alphateam/bze/rewards/get_market_id_trading_reward_id_handler/{marketId} + */ + queryGetMarketIdTradingRewardIdHandler = (marketId: string, params: RequestParams = {}) => + this.request({ + path: `/bze-alphateam/bze/rewards/get_market_id_trading_reward_id_handler/${marketId}`, + method: "GET", + format: "json", + ...params, + }); + + /** + * No description + * + * @tags Query + * @name QueryGetTradingRewardLeaderboardHandler + * @summary Queries a list of GetTradingRewardLeaderboard items. + * @request GET:/bze/rewards/v1/get_trading_reward_leaderboard/{reward_id} + */ + queryGetTradingRewardLeaderboardHandler = (reward_id: string, params: RequestParams = {}) => + this.request({ + path: `/bze/rewards/v1/get_trading_reward_leaderboard/${reward_id}`, + method: "GET", + format: "json", + ...params, + }); + /** * No description * diff --git a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/query.ts b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/query.ts index aedd037b..182f16d2 100644 --- a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/query.ts +++ b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/query.ts @@ -6,7 +6,10 @@ import { PageRequest, PageResponse, } from "../cosmos/base/query/v1beta1/pagination"; -import { TradingReward } from "../rewards/trading_reward"; +import { + TradingReward, + TradingRewardLeaderboard, +} from "../rewards/trading_reward"; import { StakingRewardParticipant } from "../rewards/staking_reward_participant"; export const protobufPackage = "bze.v1.rewards"; @@ -74,6 +77,20 @@ export interface QueryAllStakingRewardParticipantResponse { pagination: PageResponse | undefined; } +export interface QueryGetTradingRewardLeaderboardRequest { + reward_id: string; +} + +export interface QueryGetTradingRewardLeaderboardResponse { + leaderboard: TradingRewardLeaderboard | undefined; +} + +export interface QueryGetMarketIdTradingRewardIdHandlerRequest { + marketId: string; +} + +export interface QueryGetMarketIdTradingRewardIdHandlerResponse {} + const baseQueryParamsRequest: object = {}; export const QueryParamsRequest = { @@ -1195,6 +1212,280 @@ export const QueryAllStakingRewardParticipantResponse = { }, }; +const baseQueryGetTradingRewardLeaderboardRequest: object = { reward_id: "" }; + +export const QueryGetTradingRewardLeaderboardRequest = { + encode( + message: QueryGetTradingRewardLeaderboardRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.reward_id !== "") { + writer.uint32(10).string(message.reward_id); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryGetTradingRewardLeaderboardRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryGetTradingRewardLeaderboardRequest, + } as QueryGetTradingRewardLeaderboardRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.reward_id = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryGetTradingRewardLeaderboardRequest { + const message = { + ...baseQueryGetTradingRewardLeaderboardRequest, + } as QueryGetTradingRewardLeaderboardRequest; + if (object.reward_id !== undefined && object.reward_id !== null) { + message.reward_id = String(object.reward_id); + } else { + message.reward_id = ""; + } + return message; + }, + + toJSON(message: QueryGetTradingRewardLeaderboardRequest): unknown { + const obj: any = {}; + message.reward_id !== undefined && (obj.reward_id = message.reward_id); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryGetTradingRewardLeaderboardRequest { + const message = { + ...baseQueryGetTradingRewardLeaderboardRequest, + } as QueryGetTradingRewardLeaderboardRequest; + if (object.reward_id !== undefined && object.reward_id !== null) { + message.reward_id = object.reward_id; + } else { + message.reward_id = ""; + } + return message; + }, +}; + +const baseQueryGetTradingRewardLeaderboardResponse: object = {}; + +export const QueryGetTradingRewardLeaderboardResponse = { + encode( + message: QueryGetTradingRewardLeaderboardResponse, + writer: Writer = Writer.create() + ): Writer { + if (message.leaderboard !== undefined) { + TradingRewardLeaderboard.encode( + message.leaderboard, + writer.uint32(10).fork() + ).ldelim(); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryGetTradingRewardLeaderboardResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryGetTradingRewardLeaderboardResponse, + } as QueryGetTradingRewardLeaderboardResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.leaderboard = TradingRewardLeaderboard.decode( + reader, + reader.uint32() + ); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryGetTradingRewardLeaderboardResponse { + const message = { + ...baseQueryGetTradingRewardLeaderboardResponse, + } as QueryGetTradingRewardLeaderboardResponse; + if (object.leaderboard !== undefined && object.leaderboard !== null) { + message.leaderboard = TradingRewardLeaderboard.fromJSON( + object.leaderboard + ); + } else { + message.leaderboard = undefined; + } + return message; + }, + + toJSON(message: QueryGetTradingRewardLeaderboardResponse): unknown { + const obj: any = {}; + message.leaderboard !== undefined && + (obj.leaderboard = message.leaderboard + ? TradingRewardLeaderboard.toJSON(message.leaderboard) + : undefined); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryGetTradingRewardLeaderboardResponse { + const message = { + ...baseQueryGetTradingRewardLeaderboardResponse, + } as QueryGetTradingRewardLeaderboardResponse; + if (object.leaderboard !== undefined && object.leaderboard !== null) { + message.leaderboard = TradingRewardLeaderboard.fromPartial( + object.leaderboard + ); + } else { + message.leaderboard = undefined; + } + return message; + }, +}; + +const baseQueryGetMarketIdTradingRewardIdHandlerRequest: object = { + marketId: "", +}; + +export const QueryGetMarketIdTradingRewardIdHandlerRequest = { + encode( + message: QueryGetMarketIdTradingRewardIdHandlerRequest, + writer: Writer = Writer.create() + ): Writer { + if (message.marketId !== "") { + writer.uint32(10).string(message.marketId); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryGetMarketIdTradingRewardIdHandlerRequest { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryGetMarketIdTradingRewardIdHandlerRequest, + } as QueryGetMarketIdTradingRewardIdHandlerRequest; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.marketId = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): QueryGetMarketIdTradingRewardIdHandlerRequest { + const message = { + ...baseQueryGetMarketIdTradingRewardIdHandlerRequest, + } as QueryGetMarketIdTradingRewardIdHandlerRequest; + if (object.marketId !== undefined && object.marketId !== null) { + message.marketId = String(object.marketId); + } else { + message.marketId = ""; + } + return message; + }, + + toJSON(message: QueryGetMarketIdTradingRewardIdHandlerRequest): unknown { + const obj: any = {}; + message.marketId !== undefined && (obj.marketId = message.marketId); + return obj; + }, + + fromPartial( + object: DeepPartial + ): QueryGetMarketIdTradingRewardIdHandlerRequest { + const message = { + ...baseQueryGetMarketIdTradingRewardIdHandlerRequest, + } as QueryGetMarketIdTradingRewardIdHandlerRequest; + if (object.marketId !== undefined && object.marketId !== null) { + message.marketId = object.marketId; + } else { + message.marketId = ""; + } + return message; + }, +}; + +const baseQueryGetMarketIdTradingRewardIdHandlerResponse: object = {}; + +export const QueryGetMarketIdTradingRewardIdHandlerResponse = { + encode( + _: QueryGetMarketIdTradingRewardIdHandlerResponse, + writer: Writer = Writer.create() + ): Writer { + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): QueryGetMarketIdTradingRewardIdHandlerResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseQueryGetMarketIdTradingRewardIdHandlerResponse, + } as QueryGetMarketIdTradingRewardIdHandlerResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): QueryGetMarketIdTradingRewardIdHandlerResponse { + const message = { + ...baseQueryGetMarketIdTradingRewardIdHandlerResponse, + } as QueryGetMarketIdTradingRewardIdHandlerResponse; + return message; + }, + + toJSON(_: QueryGetMarketIdTradingRewardIdHandlerResponse): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial( + _: DeepPartial + ): QueryGetMarketIdTradingRewardIdHandlerResponse { + const message = { + ...baseQueryGetMarketIdTradingRewardIdHandlerResponse, + } as QueryGetMarketIdTradingRewardIdHandlerResponse; + return message; + }, +}; + /** Query defines the gRPC querier service. */ export interface Query { /** Parameters queries the parameters of the module. */ @@ -1223,6 +1514,14 @@ export interface Query { StakingRewardParticipantAll( request: QueryAllStakingRewardParticipantRequest ): Promise; + /** Queries a list of GetTradingRewardLeaderboard items. */ + GetTradingRewardLeaderboardHandler( + request: QueryGetTradingRewardLeaderboardRequest + ): Promise; + /** Queries a list of GetMarketIdTradingRewardIdHandler items. */ + GetMarketIdTradingRewardIdHandler( + request: QueryGetMarketIdTradingRewardIdHandlerRequest + ): Promise; } export class QueryClientImpl implements Query { @@ -1323,6 +1622,38 @@ export class QueryClientImpl implements Query { QueryAllStakingRewardParticipantResponse.decode(new Reader(data)) ); } + + GetTradingRewardLeaderboardHandler( + request: QueryGetTradingRewardLeaderboardRequest + ): Promise { + const data = QueryGetTradingRewardLeaderboardRequest.encode( + request + ).finish(); + const promise = this.rpc.request( + "bze.v1.rewards.Query", + "GetTradingRewardLeaderboardHandler", + data + ); + return promise.then((data) => + QueryGetTradingRewardLeaderboardResponse.decode(new Reader(data)) + ); + } + + GetMarketIdTradingRewardIdHandler( + request: QueryGetMarketIdTradingRewardIdHandlerRequest + ): Promise { + const data = QueryGetMarketIdTradingRewardIdHandlerRequest.encode( + request + ).finish(); + const promise = this.rpc.request( + "bze.v1.rewards.Query", + "GetMarketIdTradingRewardIdHandler", + data + ); + return promise.then((data) => + QueryGetMarketIdTradingRewardIdHandlerResponse.decode(new Reader(data)) + ); + } } interface Rpc { diff --git a/x/rewards/client/cli/query.go b/x/rewards/client/cli/query.go index 834f8f3e..20560b23 100644 --- a/x/rewards/client/cli/query.go +++ b/x/rewards/client/cli/query.go @@ -31,6 +31,10 @@ func GetQueryCmd(queryRoute string) *cobra.Command { cmd.AddCommand(CmdShowTradingReward()) cmd.AddCommand(CmdListStakingRewardParticipant()) cmd.AddCommand(CmdShowStakingRewardParticipant()) + cmd.AddCommand(CmdGetTradingRewardLeaderboard()) + + cmd.AddCommand(CmdGetMarketIdTradingRewardIdHandler()) + // this line is used by starport scaffolding # 1 return cmd diff --git a/x/rewards/client/cli/query_get_market_id_trading_reward_id_handler.go b/x/rewards/client/cli/query_get_market_id_trading_reward_id_handler.go new file mode 100644 index 00000000..95da3c64 --- /dev/null +++ b/x/rewards/client/cli/query_get_market_id_trading_reward_id_handler.go @@ -0,0 +1,46 @@ +package cli + +import ( + "strconv" + + "github.com/bze-alphateam/bze/x/rewards/types" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/spf13/cobra" +) + +var _ = strconv.Itoa(0) + +func CmdGetMarketIdTradingRewardIdHandler() *cobra.Command { + cmd := &cobra.Command{ + Use: "get-market-id-trading-reward-id-handler [market-id]", + Short: "Query GetMarketIdTradingRewardIdHandler", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) (err error) { + reqMarketId := args[0] + + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + + params := &types.QueryGetMarketIdTradingRewardIdHandlerRequest{ + + MarketId: reqMarketId, + } + + res, err := queryClient.GetMarketIdTradingRewardIdHandler(cmd.Context(), params) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/rewards/client/cli/query_get_trading_reward_leaderboard.go b/x/rewards/client/cli/query_get_trading_reward_leaderboard.go new file mode 100644 index 00000000..1eecc63d --- /dev/null +++ b/x/rewards/client/cli/query_get_trading_reward_leaderboard.go @@ -0,0 +1,46 @@ +package cli + +import ( + "strconv" + + "github.com/bze-alphateam/bze/x/rewards/types" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/spf13/cobra" +) + +var _ = strconv.Itoa(0) + +func CmdGetTradingRewardLeaderboard() *cobra.Command { + cmd := &cobra.Command{ + Use: "get-trading-reward-leaderboard [reward-id]", + Short: "Query GetTradingRewardLeaderboard", + Args: cobra.ExactArgs(1), + RunE: func(cmd *cobra.Command, args []string) (err error) { + reqRewardId := args[0] + + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + queryClient := types.NewQueryClient(clientCtx) + + params := &types.QueryGetTradingRewardLeaderboardRequest{ + + RewardId: reqRewardId, + } + + res, err := queryClient.GetTradingRewardLeaderboard(cmd.Context(), params) + if err != nil { + return err + } + + return clientCtx.PrintProto(res) + }, + } + + flags.AddQueryFlagsToCmd(cmd) + + return cmd +} diff --git a/x/rewards/keeper/grpc_query_get_market_id_trading_reward_id_handler.go b/x/rewards/keeper/grpc_query_get_market_id_trading_reward_id_handler.go new file mode 100644 index 00000000..d58c4a2e --- /dev/null +++ b/x/rewards/keeper/grpc_query_get_market_id_trading_reward_id_handler.go @@ -0,0 +1,25 @@ +package keeper + +import ( + "context" + + "github.com/bze-alphateam/bze/x/rewards/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +func (k Keeper) GetMarketIdTradingRewardIdHandler(goCtx context.Context, req *types.QueryGetMarketIdTradingRewardIdHandlerRequest) (*types.QueryGetMarketIdTradingRewardIdHandlerResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + + ctx := sdk.UnwrapSDKContext(goCtx) + + mr, found := k.GetMarketIdRewardId(ctx, req.MarketId) + if !found { + return nil, status.Error(codes.NotFound, "not found") + } + + return &types.QueryGetMarketIdTradingRewardIdHandlerResponse{MarketIdRewardId: &mr}, nil +} diff --git a/x/rewards/keeper/grpc_query_get_trading_reward_leaderboard.go b/x/rewards/keeper/grpc_query_get_trading_reward_leaderboard.go new file mode 100644 index 00000000..97b2544c --- /dev/null +++ b/x/rewards/keeper/grpc_query_get_trading_reward_leaderboard.go @@ -0,0 +1,24 @@ +package keeper + +import ( + "context" + + "github.com/bze-alphateam/bze/x/rewards/types" + sdk "github.com/cosmos/cosmos-sdk/types" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +func (k Keeper) GetTradingRewardLeaderboardHandler(goCtx context.Context, req *types.QueryGetTradingRewardLeaderboardRequest) (*types.QueryGetTradingRewardLeaderboardResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + + ctx := sdk.UnwrapSDKContext(goCtx) + trl, found := k.GetTradingRewardLeaderboard(ctx, req.RewardId) + if !found { + return nil, status.Error(codes.NotFound, "not found") + } + + return &types.QueryGetTradingRewardLeaderboardResponse{Leaderboard: &trl}, nil +} diff --git a/x/rewards/types/message_claim_staking_rewards.go b/x/rewards/types/message_claim_staking_rewards.go index 8a737809..7d46a117 100644 --- a/x/rewards/types/message_claim_staking_rewards.go +++ b/x/rewards/types/message_claim_staking_rewards.go @@ -42,7 +42,7 @@ func (msg *MsgClaimStakingRewards) ValidateBasic() error { if err != nil { return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err) } - + if msg.RewardId == "" { return sdkerrors.Wrapf(ErrInvalidRewardId, "empty reward id") } diff --git a/x/rewards/types/query.pb.go b/x/rewards/types/query.pb.go index 515e7d76..c96de059 100644 --- a/x/rewards/types/query.pb.go +++ b/x/rewards/types/query.pb.go @@ -697,6 +697,194 @@ func (m *QueryAllStakingRewardParticipantResponse) GetPagination() *query.PageRe return nil } +type QueryGetTradingRewardLeaderboardRequest struct { + RewardId string `protobuf:"bytes,1,opt,name=reward_id,json=rewardId,proto3" json:"reward_id,omitempty"` +} + +func (m *QueryGetTradingRewardLeaderboardRequest) Reset() { + *m = QueryGetTradingRewardLeaderboardRequest{} +} +func (m *QueryGetTradingRewardLeaderboardRequest) String() string { return proto.CompactTextString(m) } +func (*QueryGetTradingRewardLeaderboardRequest) ProtoMessage() {} +func (*QueryGetTradingRewardLeaderboardRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_5ddc078ee02fb5e8, []int{14} +} +func (m *QueryGetTradingRewardLeaderboardRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryGetTradingRewardLeaderboardRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryGetTradingRewardLeaderboardRequest.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 *QueryGetTradingRewardLeaderboardRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryGetTradingRewardLeaderboardRequest.Merge(m, src) +} +func (m *QueryGetTradingRewardLeaderboardRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryGetTradingRewardLeaderboardRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryGetTradingRewardLeaderboardRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryGetTradingRewardLeaderboardRequest proto.InternalMessageInfo + +func (m *QueryGetTradingRewardLeaderboardRequest) GetRewardId() string { + if m != nil { + return m.RewardId + } + return "" +} + +type QueryGetTradingRewardLeaderboardResponse struct { + Leaderboard *TradingRewardLeaderboard `protobuf:"bytes,1,opt,name=leaderboard,proto3" json:"leaderboard,omitempty"` +} + +func (m *QueryGetTradingRewardLeaderboardResponse) Reset() { + *m = QueryGetTradingRewardLeaderboardResponse{} +} +func (m *QueryGetTradingRewardLeaderboardResponse) String() string { return proto.CompactTextString(m) } +func (*QueryGetTradingRewardLeaderboardResponse) ProtoMessage() {} +func (*QueryGetTradingRewardLeaderboardResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_5ddc078ee02fb5e8, []int{15} +} +func (m *QueryGetTradingRewardLeaderboardResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryGetTradingRewardLeaderboardResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryGetTradingRewardLeaderboardResponse.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 *QueryGetTradingRewardLeaderboardResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryGetTradingRewardLeaderboardResponse.Merge(m, src) +} +func (m *QueryGetTradingRewardLeaderboardResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryGetTradingRewardLeaderboardResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryGetTradingRewardLeaderboardResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryGetTradingRewardLeaderboardResponse proto.InternalMessageInfo + +func (m *QueryGetTradingRewardLeaderboardResponse) GetLeaderboard() *TradingRewardLeaderboard { + if m != nil { + return m.Leaderboard + } + return nil +} + +type QueryGetMarketIdTradingRewardIdHandlerRequest struct { + MarketId string `protobuf:"bytes,1,opt,name=market_id,json=marketId,proto3" json:"market_id,omitempty"` +} + +func (m *QueryGetMarketIdTradingRewardIdHandlerRequest) Reset() { + *m = QueryGetMarketIdTradingRewardIdHandlerRequest{} +} +func (m *QueryGetMarketIdTradingRewardIdHandlerRequest) String() string { + return proto.CompactTextString(m) +} +func (*QueryGetMarketIdTradingRewardIdHandlerRequest) ProtoMessage() {} +func (*QueryGetMarketIdTradingRewardIdHandlerRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_5ddc078ee02fb5e8, []int{16} +} +func (m *QueryGetMarketIdTradingRewardIdHandlerRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryGetMarketIdTradingRewardIdHandlerRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryGetMarketIdTradingRewardIdHandlerRequest.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 *QueryGetMarketIdTradingRewardIdHandlerRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryGetMarketIdTradingRewardIdHandlerRequest.Merge(m, src) +} +func (m *QueryGetMarketIdTradingRewardIdHandlerRequest) XXX_Size() int { + return m.Size() +} +func (m *QueryGetMarketIdTradingRewardIdHandlerRequest) XXX_DiscardUnknown() { + xxx_messageInfo_QueryGetMarketIdTradingRewardIdHandlerRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryGetMarketIdTradingRewardIdHandlerRequest proto.InternalMessageInfo + +func (m *QueryGetMarketIdTradingRewardIdHandlerRequest) GetMarketId() string { + if m != nil { + return m.MarketId + } + return "" +} + +type QueryGetMarketIdTradingRewardIdHandlerResponse struct { + MarketIdRewardId *MarketIdTradingRewardId `protobuf:"bytes,1,opt,name=market_id_reward_id,json=marketIdRewardId,proto3" json:"market_id_reward_id,omitempty"` +} + +func (m *QueryGetMarketIdTradingRewardIdHandlerResponse) Reset() { + *m = QueryGetMarketIdTradingRewardIdHandlerResponse{} +} +func (m *QueryGetMarketIdTradingRewardIdHandlerResponse) String() string { + return proto.CompactTextString(m) +} +func (*QueryGetMarketIdTradingRewardIdHandlerResponse) ProtoMessage() {} +func (*QueryGetMarketIdTradingRewardIdHandlerResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_5ddc078ee02fb5e8, []int{17} +} +func (m *QueryGetMarketIdTradingRewardIdHandlerResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *QueryGetMarketIdTradingRewardIdHandlerResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_QueryGetMarketIdTradingRewardIdHandlerResponse.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 *QueryGetMarketIdTradingRewardIdHandlerResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_QueryGetMarketIdTradingRewardIdHandlerResponse.Merge(m, src) +} +func (m *QueryGetMarketIdTradingRewardIdHandlerResponse) XXX_Size() int { + return m.Size() +} +func (m *QueryGetMarketIdTradingRewardIdHandlerResponse) XXX_DiscardUnknown() { + xxx_messageInfo_QueryGetMarketIdTradingRewardIdHandlerResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_QueryGetMarketIdTradingRewardIdHandlerResponse proto.InternalMessageInfo + +func (m *QueryGetMarketIdTradingRewardIdHandlerResponse) GetMarketIdRewardId() *MarketIdTradingRewardId { + if m != nil { + return m.MarketIdRewardId + } + return nil +} + func init() { proto.RegisterType((*QueryParamsRequest)(nil), "bze.v1.rewards.QueryParamsRequest") proto.RegisterType((*QueryParamsResponse)(nil), "bze.v1.rewards.QueryParamsResponse") @@ -712,62 +900,76 @@ func init() { proto.RegisterType((*QueryGetStakingRewardParticipantResponse)(nil), "bze.v1.rewards.QueryGetStakingRewardParticipantResponse") proto.RegisterType((*QueryAllStakingRewardParticipantRequest)(nil), "bze.v1.rewards.QueryAllStakingRewardParticipantRequest") proto.RegisterType((*QueryAllStakingRewardParticipantResponse)(nil), "bze.v1.rewards.QueryAllStakingRewardParticipantResponse") + proto.RegisterType((*QueryGetTradingRewardLeaderboardRequest)(nil), "bze.v1.rewards.QueryGetTradingRewardLeaderboardRequest") + proto.RegisterType((*QueryGetTradingRewardLeaderboardResponse)(nil), "bze.v1.rewards.QueryGetTradingRewardLeaderboardResponse") + proto.RegisterType((*QueryGetMarketIdTradingRewardIdHandlerRequest)(nil), "bze.v1.rewards.QueryGetMarketIdTradingRewardIdHandlerRequest") + proto.RegisterType((*QueryGetMarketIdTradingRewardIdHandlerResponse)(nil), "bze.v1.rewards.QueryGetMarketIdTradingRewardIdHandlerResponse") } func init() { proto.RegisterFile("rewards/query.proto", fileDescriptor_5ddc078ee02fb5e8) } var fileDescriptor_5ddc078ee02fb5e8 = []byte{ - // 785 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x96, 0xc1, 0x4f, 0x13, 0x4f, - 0x14, 0xc7, 0x3b, 0xfc, 0x80, 0x9f, 0x8c, 0x81, 0x90, 0xa1, 0x21, 0x4d, 0x81, 0x95, 0xac, 0x09, - 0x34, 0x08, 0xbb, 0x29, 0x10, 0x31, 0xd1, 0x0b, 0x1c, 0x20, 0xea, 0x05, 0xab, 0x27, 0x2f, 0x64, - 0x4a, 0xc7, 0x65, 0xc3, 0xb2, 0xbb, 0xdd, 0x19, 0x50, 0x40, 0x2e, 0x5e, 0xbd, 0x18, 0x3d, 0x78, - 0x54, 0xff, 0x0a, 0xff, 0x02, 0x13, 0x12, 0x2f, 0x24, 0x5e, 0x3c, 0x19, 0x03, 0xfe, 0x21, 0xa6, - 0x33, 0xb3, 0xb4, 0xb3, 0xdd, 0x69, 0x17, 0x53, 0x13, 0x6f, 0xdd, 0x99, 0xf7, 0xe6, 0x7d, 0xde, - 0xf7, 0xcd, 0xbc, 0x57, 0x38, 0x16, 0x91, 0xe7, 0x38, 0xaa, 0x51, 0xbb, 0xbe, 0x4f, 0xa2, 0x43, - 0x2b, 0x8c, 0x02, 0x16, 0xa0, 0x91, 0xea, 0x11, 0xb1, 0x0e, 0xca, 0x96, 0xdc, 0x2b, 0xe6, 0x9d, - 0xc0, 0x09, 0xf8, 0x96, 0xdd, 0xf8, 0x25, 0xac, 0x8a, 0x93, 0x4e, 0x10, 0x38, 0x1e, 0xb1, 0x71, - 0xe8, 0xda, 0xd8, 0xf7, 0x03, 0x86, 0x99, 0x1b, 0xf8, 0x54, 0xee, 0xce, 0x6d, 0x07, 0x74, 0x2f, - 0xa0, 0x76, 0x15, 0x53, 0x22, 0x0e, 0xb7, 0x0f, 0xca, 0x55, 0xc2, 0x70, 0xd9, 0x0e, 0xb1, 0xe3, - 0xfa, 0xdc, 0x58, 0xda, 0xe6, 0x63, 0x88, 0x10, 0x47, 0x78, 0x2f, 0x3e, 0x61, 0x32, 0x5e, 0xa5, - 0x0c, 0xef, 0xba, 0xbe, 0xb3, 0x25, 0xbe, 0x93, 0xbb, 0x2c, 0xc2, 0xb5, 0xb6, 0xdd, 0x52, 0xba, - 0xef, 0x56, 0x88, 0x23, 0xe6, 0x6e, 0xbb, 0x21, 0xf6, 0x99, 0xb0, 0x34, 0xf3, 0x10, 0x3d, 0x6a, - 0xd0, 0x6d, 0xf2, 0xd0, 0x15, 0x52, 0xdf, 0x27, 0x94, 0x99, 0x0f, 0xe1, 0x98, 0xb2, 0x4a, 0xc3, - 0xc0, 0xa7, 0x04, 0x2d, 0xc3, 0x41, 0x81, 0x58, 0x00, 0xd3, 0xa0, 0x74, 0x7d, 0x71, 0xdc, 0x52, - 0x95, 0xb2, 0x84, 0xfd, 0x5a, 0xff, 0xe9, 0x8f, 0x1b, 0xb9, 0x8a, 0xb4, 0x35, 0xef, 0xc2, 0x49, - 0x7e, 0xd8, 0x06, 0x61, 0x8f, 0x05, 0x4e, 0x85, 0x9b, 0xcb, 0x60, 0x68, 0x02, 0x0e, 0x49, 0x3c, - 0xb7, 0xc6, 0x0f, 0x1e, 0xaa, 0x5c, 0x13, 0x0b, 0xf7, 0x6b, 0xe6, 0x2e, 0x9c, 0xd2, 0x38, 0x4b, - 0xa6, 0x07, 0x70, 0x44, 0x4d, 0x52, 0xb2, 0x4d, 0x25, 0xd9, 0x14, 0x77, 0x89, 0x38, 0x4c, 0x5b, - 0x17, 0xcd, 0x67, 0x92, 0x74, 0xd5, 0xf3, 0x52, 0x49, 0xd7, 0x21, 0x6c, 0x16, 0x4f, 0xc6, 0x99, - 0xb1, 0x44, 0xa5, 0xad, 0x46, 0xa5, 0x2d, 0x71, 0x8d, 0x64, 0xa5, 0xad, 0x4d, 0xec, 0x10, 0xe9, - 0x5b, 0x69, 0xf1, 0x34, 0x3f, 0x01, 0x99, 0x55, 0x7b, 0x20, 0x99, 0xd5, 0x0a, 0xec, 0xf7, 0x5c, - 0xca, 0x0a, 0x60, 0xfa, 0xbf, 0xac, 0xb9, 0x70, 0x07, 0xb4, 0xa1, 0x20, 0xf6, 0x71, 0xc4, 0xd9, - 0xae, 0x88, 0x22, 0xaa, 0xc2, 0xd8, 0x52, 0xb5, 0x27, 0xe2, 0x8a, 0xfd, 0x59, 0xd5, 0x12, 0xce, - 0xcd, 0xaa, 0xa9, 0x17, 0x57, 0x57, 0x35, 0xc5, 0x3d, 0xae, 0x1a, 0x6b, 0x5d, 0x34, 0x5f, 0x36, - 0xab, 0x96, 0x4a, 0x9a, 0x87, 0x03, 0x94, 0x61, 0x46, 0x24, 0xa5, 0xf8, 0x48, 0xd4, 0xb2, 0xaf, - 0x27, 0xb5, 0x4c, 0xcf, 0xb5, 0x4b, 0x2d, 0xd3, 0x32, 0xec, 0x71, 0x2d, 0x5f, 0x03, 0x38, 0x9b, - 0xfa, 0x8a, 0x36, 0x9b, 0xfd, 0x20, 0x56, 0xab, 0x00, 0xff, 0xc7, 0xb5, 0x5a, 0x44, 0x28, 0x95, - 0x7a, 0xc5, 0x9f, 0x3d, 0x53, 0xec, 0x33, 0x80, 0xa5, 0xee, 0x34, 0x52, 0xbc, 0x35, 0x45, 0xbc, - 0x52, 0xc7, 0x87, 0xd0, 0xe2, 0xff, 0x77, 0x74, 0xac, 0x4b, 0x19, 0x93, 0xcf, 0x36, 0x45, 0xc6, - 0x5e, 0xb5, 0x8a, 0x4b, 0xb1, 0x3a, 0xc6, 0xfc, 0x07, 0xc5, 0x5a, 0x7c, 0x3b, 0x04, 0x07, 0x38, - 0x39, 0xaa, 0xc3, 0x41, 0x31, 0x18, 0x90, 0x99, 0x44, 0x6a, 0x9f, 0x3d, 0xc5, 0x9b, 0x1d, 0x6d, - 0x44, 0x20, 0xd3, 0x78, 0xf5, 0xed, 0xd7, 0xbb, 0xbe, 0x02, 0x1a, 0xb7, 0xab, 0x47, 0xc4, 0x8e, - 0xa7, 0xdd, 0x41, 0x59, 0x8e, 0x50, 0xf4, 0x11, 0xc0, 0x61, 0x25, 0x5d, 0x34, 0x9f, 0x7a, 0xac, - 0x66, 0x26, 0x15, 0x17, 0x32, 0x5a, 0x4b, 0x9c, 0x45, 0x8e, 0x33, 0x8f, 0xe6, 0x92, 0x38, 0xea, - 0x68, 0xb2, 0x8f, 0x2f, 0x5b, 0xe6, 0x09, 0x7a, 0x0f, 0xe0, 0xa8, 0x72, 0xda, 0xaa, 0xe7, 0x69, - 0x28, 0x35, 0xf3, 0x48, 0x43, 0xa9, 0x1b, 0x2a, 0xe6, 0x0c, 0xa7, 0x9c, 0x46, 0x46, 0x67, 0x4a, - 0x2e, 0x9e, 0xd2, 0x95, 0xf4, 0xe2, 0xa5, 0x35, 0x5c, 0xbd, 0x78, 0xa9, 0xfd, 0x51, 0x2f, 0x9e, - 0x3a, 0x21, 0x14, 0xf1, 0x3e, 0x00, 0x38, 0xaa, 0x9c, 0xd6, 0x51, 0xbc, 0x2b, 0x50, 0xea, 0xba, - 0xb8, 0x69, 0x71, 0xca, 0x12, 0x9a, 0xe9, 0x46, 0xc9, 0xc7, 0xcb, 0x09, 0xfa, 0x0a, 0x60, 0x41, - 0xf7, 0xe0, 0xd0, 0x4a, 0xa6, 0xeb, 0xd5, 0xde, 0x56, 0x8a, 0x77, 0xae, 0xee, 0x28, 0xf9, 0xef, - 0x71, 0xfe, 0xdb, 0x68, 0xb9, 0x73, 0xf1, 0x5b, 0xff, 0x22, 0xda, 0xc7, 0xb2, 0xf5, 0x9f, 0xa0, - 0x2f, 0x00, 0x4e, 0xe8, 0x42, 0x34, 0xa4, 0x5f, 0xc9, 0x74, 0x13, 0x33, 0x27, 0x94, 0xa1, 0xd9, - 0x99, 0x4b, 0x3c, 0xa1, 0x05, 0x74, 0x2b, 0x7b, 0x42, 0x74, 0x6d, 0xfd, 0xf4, 0xdc, 0x00, 0x67, - 0xe7, 0x06, 0xf8, 0x79, 0x6e, 0x80, 0x37, 0x17, 0x46, 0xee, 0xec, 0xc2, 0xc8, 0x7d, 0xbf, 0x30, - 0x72, 0x4f, 0xe7, 0x1d, 0x97, 0xed, 0xec, 0x57, 0xad, 0xed, 0x60, 0xaf, 0x71, 0xe0, 0x02, 0xf6, - 0xc2, 0x1d, 0xcc, 0x08, 0xe6, 0x5f, 0xf6, 0x8b, 0xcb, 0x00, 0xec, 0x30, 0x24, 0xb4, 0x3a, 0xc8, - 0xff, 0x3d, 0x2f, 0xfd, 0x0e, 0x00, 0x00, 0xff, 0xff, 0x1c, 0xf2, 0x7c, 0x09, 0x40, 0x0c, 0x00, - 0x00, + // 951 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x57, 0x41, 0x6f, 0xdc, 0x44, + 0x14, 0xde, 0x09, 0x6d, 0xa0, 0x53, 0x5a, 0x45, 0x93, 0x55, 0xb5, 0xda, 0xa6, 0x26, 0x0c, 0x52, + 0xba, 0x2a, 0x59, 0x5b, 0x9b, 0x56, 0x4d, 0x25, 0xa0, 0x52, 0x73, 0x48, 0x09, 0x14, 0x29, 0x2c, + 0x88, 0x03, 0x97, 0xd5, 0x6c, 0x3c, 0xb8, 0x56, 0xbc, 0xb6, 0xd7, 0x33, 0x59, 0x68, 0x4b, 0x2e, + 0x9c, 0x90, 0xb8, 0x20, 0x71, 0xe0, 0x08, 0xfc, 0x0a, 0x7e, 0x01, 0xa8, 0x12, 0x97, 0x4a, 0x1c, + 0xca, 0x09, 0xa1, 0x84, 0x1f, 0x82, 0x76, 0x3c, 0x5e, 0x7b, 0xbc, 0x1e, 0xdb, 0x8d, 0x16, 0xa9, + 0xb7, 0xf5, 0xcc, 0x7b, 0x6f, 0xbe, 0xf7, 0x7d, 0x6f, 0xde, 0x9b, 0x85, 0xab, 0x11, 0xfd, 0x92, + 0x44, 0x36, 0xb3, 0xc6, 0x47, 0x34, 0x7a, 0x64, 0x86, 0x51, 0xc0, 0x03, 0x74, 0x79, 0xf8, 0x98, + 0x9a, 0x93, 0x9e, 0x29, 0xf7, 0xda, 0x4d, 0x27, 0x70, 0x02, 0xb1, 0x65, 0x4d, 0x7f, 0xc5, 0x56, + 0xed, 0x35, 0x27, 0x08, 0x1c, 0x8f, 0x5a, 0x24, 0x74, 0x2d, 0xe2, 0xfb, 0x01, 0x27, 0xdc, 0x0d, + 0x7c, 0x26, 0x77, 0x6f, 0x1c, 0x04, 0x6c, 0x14, 0x30, 0x6b, 0x48, 0x18, 0x8d, 0x83, 0x5b, 0x93, + 0xde, 0x90, 0x72, 0xd2, 0xb3, 0x42, 0xe2, 0xb8, 0xbe, 0x30, 0x96, 0xb6, 0xcd, 0x04, 0x44, 0x48, + 0x22, 0x32, 0x4a, 0x22, 0xac, 0x25, 0xab, 0x8c, 0x93, 0x43, 0xd7, 0x77, 0x06, 0xf1, 0x77, 0x7e, + 0x97, 0x47, 0xc4, 0x9e, 0xdb, 0xed, 0x14, 0xfb, 0x0e, 0x42, 0x12, 0x71, 0xf7, 0xc0, 0x0d, 0x89, + 0xcf, 0x63, 0x4b, 0xdc, 0x84, 0xe8, 0xe3, 0x29, 0xba, 0x7d, 0x71, 0x74, 0x9f, 0x8e, 0x8f, 0x28, + 0xe3, 0xf8, 0x43, 0xb8, 0xaa, 0xac, 0xb2, 0x30, 0xf0, 0x19, 0x45, 0xb7, 0xe0, 0x72, 0x0c, 0xb1, + 0x05, 0xd6, 0x41, 0xe7, 0xe2, 0xd6, 0x15, 0x53, 0x65, 0xca, 0x8c, 0xed, 0x77, 0xce, 0x3d, 0xfd, + 0xfb, 0x8d, 0x46, 0x5f, 0xda, 0xe2, 0x77, 0xe0, 0x9a, 0x08, 0x76, 0x9f, 0xf2, 0x4f, 0x62, 0x38, + 0x7d, 0x61, 0x2e, 0x0f, 0x43, 0x57, 0xe1, 0x05, 0x09, 0xcf, 0xb5, 0x45, 0xe0, 0x0b, 0xfd, 0xd7, + 0xe2, 0x85, 0x3d, 0x1b, 0x1f, 0xc2, 0x6b, 0x1a, 0x67, 0x89, 0xe9, 0x03, 0x78, 0x59, 0x4d, 0x52, + 0x62, 0xbb, 0x96, 0xc7, 0xa6, 0xb8, 0x4b, 0x88, 0x97, 0x58, 0x76, 0x11, 0x7f, 0x21, 0x91, 0xde, + 0xf3, 0xbc, 0x42, 0xa4, 0xbb, 0x10, 0xa6, 0xe2, 0xc9, 0x73, 0x36, 0xcc, 0x58, 0x69, 0x73, 0xaa, + 0xb4, 0x19, 0x97, 0x91, 0x54, 0xda, 0xdc, 0x27, 0x0e, 0x95, 0xbe, 0xfd, 0x8c, 0x27, 0xfe, 0x05, + 0xc8, 0xac, 0xe6, 0x0f, 0x92, 0x59, 0x6d, 0xc3, 0x73, 0x9e, 0xcb, 0x78, 0x0b, 0xac, 0xbf, 0x52, + 0x37, 0x17, 0xe1, 0x80, 0xee, 0x2b, 0x10, 0x97, 0x04, 0xc4, 0xeb, 0x95, 0x10, 0xe3, 0x53, 0x15, + 0x8c, 0x19, 0xd5, 0x3e, 0x8d, 0x4b, 0xec, 0x6c, 0xaa, 0xe5, 0x9c, 0x53, 0xd5, 0xd4, 0xc2, 0xd5, + 0xa9, 0xa6, 0xb8, 0x27, 0xaa, 0xf1, 0xec, 0x22, 0xfe, 0x3a, 0x55, 0xad, 0x10, 0x69, 0x13, 0x9e, + 0x67, 0x9c, 0x70, 0x2a, 0x51, 0xc6, 0x1f, 0x39, 0x2d, 0x97, 0x16, 0xa2, 0x65, 0x71, 0xae, 0x15, + 0x5a, 0x16, 0x65, 0xb8, 0x60, 0x2d, 0xbf, 0x03, 0xf0, 0x7a, 0xe1, 0x2d, 0xda, 0x4f, 0xfb, 0x41, + 0xc2, 0x56, 0x0b, 0xbe, 0x4a, 0x6c, 0x3b, 0xa2, 0x8c, 0x49, 0xbe, 0x92, 0xcf, 0x85, 0x31, 0xf6, + 0x2b, 0x80, 0x9d, 0x6a, 0x34, 0x92, 0xbc, 0x1d, 0x85, 0xbc, 0x4e, 0xe9, 0x45, 0xc8, 0xf8, 0xff, + 0x3f, 0x3c, 0x8e, 0x25, 0x8d, 0xf9, 0x6b, 0x5b, 0x40, 0xe3, 0xa2, 0x5a, 0xc5, 0x8c, 0xac, 0xd2, + 0x33, 0x5f, 0x46, 0xb2, 0x76, 0xd3, 0x9a, 0x53, 0x4a, 0xfc, 0x01, 0x25, 0x36, 0x8d, 0x86, 0x41, + 0xdd, 0x5e, 0x32, 0x49, 0xab, 0x45, 0x1f, 0x67, 0xd6, 0x56, 0x2e, 0x7a, 0xe9, 0xb2, 0xa4, 0xbd, + 0x53, 0x7a, 0xe3, 0xb2, 0x61, 0xb2, 0xce, 0xf8, 0x01, 0xec, 0x26, 0xe7, 0x7e, 0x44, 0xa2, 0x43, + 0xca, 0xf7, 0x6c, 0xc5, 0x71, 0xcf, 0x7e, 0x9f, 0xf8, 0xb6, 0x47, 0xa3, 0x4c, 0x16, 0x23, 0x61, + 0x98, 0xc9, 0x62, 0x24, 0x3d, 0xf1, 0xb7, 0x00, 0x9a, 0x75, 0xc3, 0xc9, 0x64, 0x3e, 0x83, 0xab, + 0xb3, 0x78, 0x03, 0x95, 0x9f, 0xa9, 0x24, 0xb9, 0xa4, 0x34, 0x41, 0xfb, 0x2b, 0x09, 0x84, 0x64, + 0x65, 0xeb, 0xf7, 0xd7, 0xe1, 0x79, 0x01, 0x05, 0x8d, 0xe1, 0x72, 0x3c, 0xb1, 0x11, 0xce, 0x87, + 0x9b, 0x7f, 0x14, 0xb4, 0xdf, 0x2a, 0xb5, 0x89, 0x41, 0x63, 0xe3, 0x9b, 0x3f, 0xff, 0xfd, 0x61, + 0xa9, 0x85, 0xae, 0x58, 0xc3, 0xc7, 0xd4, 0x4a, 0x9e, 0x21, 0x93, 0x9e, 0x7c, 0xdb, 0xa0, 0x9f, + 0x01, 0xbc, 0xa4, 0xd4, 0x21, 0xda, 0x2c, 0x0c, 0xab, 0x79, 0x2c, 0xb4, 0xbb, 0x35, 0xad, 0x25, + 0x9c, 0x2d, 0x01, 0x67, 0x13, 0xdd, 0xc8, 0xc3, 0x51, 0xdf, 0x0c, 0xd6, 0x93, 0x19, 0xbf, 0xc7, + 0xe8, 0x47, 0x00, 0x57, 0x94, 0x68, 0xf7, 0x3c, 0x4f, 0x83, 0x52, 0xf3, 0x50, 0xd0, 0xa0, 0xd4, + 0x4d, 0x7b, 0xbc, 0x21, 0x50, 0xae, 0x23, 0xa3, 0x1c, 0xa5, 0x20, 0x4f, 0xd1, 0x57, 0x4f, 0x5e, + 0xd1, 0x24, 0xd4, 0x93, 0x57, 0x38, 0xb8, 0xf4, 0xe4, 0xa9, 0xa3, 0x5b, 0x21, 0xef, 0x27, 0x00, + 0x57, 0x94, 0x68, 0xa5, 0xe4, 0xbd, 0x00, 0x4a, 0xdd, 0x78, 0xc5, 0xa6, 0x40, 0xd9, 0x41, 0x1b, + 0x55, 0x28, 0xc5, 0xdc, 0x3f, 0x46, 0x7f, 0x00, 0xd8, 0xd2, 0x75, 0x42, 0xb4, 0x5d, 0xab, 0xbc, + 0xe6, 0xfb, 0x7d, 0xfb, 0xce, 0x8b, 0x3b, 0x4a, 0xfc, 0xef, 0x0a, 0xfc, 0xb7, 0xd1, 0xad, 0x72, + 0xf1, 0xb3, 0x6f, 0x77, 0xeb, 0x89, 0x9c, 0xc9, 0xc7, 0xe8, 0x37, 0x00, 0xaf, 0xea, 0x8e, 0x98, + 0x52, 0xbf, 0x5d, 0xab, 0x12, 0x6b, 0x27, 0x54, 0x63, 0x0a, 0xe1, 0x9b, 0x22, 0xa1, 0x2e, 0x7a, + 0xbb, 0x7e, 0x42, 0x0c, 0x3d, 0x07, 0x10, 0x97, 0x74, 0x78, 0xd9, 0x1b, 0xf5, 0xfa, 0x54, 0x8c, + 0x18, 0xbd, 0x3e, 0x55, 0x33, 0x05, 0xdf, 0x15, 0xe9, 0xdc, 0x41, 0xb7, 0xcb, 0xeb, 0x6b, 0x90, + 0x99, 0x1d, 0xca, 0x8d, 0x78, 0x0e, 0xe0, 0x9b, 0x95, 0x4d, 0x1f, 0xbd, 0xa7, 0xc3, 0x57, 0x6b, + 0xf6, 0xb4, 0xef, 0x9e, 0xd5, 0xbd, 0x4a, 0xb3, 0x74, 0x02, 0xe5, 0xd2, 0x75, 0xed, 0x9d, 0xdd, + 0xa7, 0x27, 0x06, 0x78, 0x76, 0x62, 0x80, 0x7f, 0x4e, 0x0c, 0xf0, 0xfd, 0xa9, 0xd1, 0x78, 0x76, + 0x6a, 0x34, 0xfe, 0x3a, 0x35, 0x1a, 0x9f, 0x6f, 0x3a, 0x2e, 0x7f, 0x78, 0x34, 0x34, 0x0f, 0x82, + 0xd1, 0x34, 0x60, 0x97, 0x78, 0xe1, 0x43, 0xc2, 0x29, 0x11, 0x5f, 0xd6, 0x57, 0xb3, 0x03, 0xf8, + 0xa3, 0x90, 0xb2, 0xe1, 0xb2, 0xf8, 0x2b, 0x7a, 0xf3, 0xbf, 0x00, 0x00, 0x00, 0xff, 0xff, 0x26, + 0x2a, 0x7d, 0x46, 0x8d, 0x0f, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -796,6 +998,10 @@ type QueryClient interface { StakingRewardParticipant(ctx context.Context, in *QueryGetStakingRewardParticipantRequest, opts ...grpc.CallOption) (*QueryGetStakingRewardParticipantResponse, error) // Queries a list of StakingRewardParticipant items. StakingRewardParticipantAll(ctx context.Context, in *QueryAllStakingRewardParticipantRequest, opts ...grpc.CallOption) (*QueryAllStakingRewardParticipantResponse, error) + // Queries a list of GetTradingRewardLeaderboard items. + GetTradingRewardLeaderboardHandler(ctx context.Context, in *QueryGetTradingRewardLeaderboardRequest, opts ...grpc.CallOption) (*QueryGetTradingRewardLeaderboardResponse, error) + // Queries a list of GetMarketIdTradingRewardIdHandler items. + GetMarketIdTradingRewardIdHandler(ctx context.Context, in *QueryGetMarketIdTradingRewardIdHandlerRequest, opts ...grpc.CallOption) (*QueryGetMarketIdTradingRewardIdHandlerResponse, error) } type queryClient struct { @@ -869,6 +1075,24 @@ func (c *queryClient) StakingRewardParticipantAll(ctx context.Context, in *Query return out, nil } +func (c *queryClient) GetTradingRewardLeaderboardHandler(ctx context.Context, in *QueryGetTradingRewardLeaderboardRequest, opts ...grpc.CallOption) (*QueryGetTradingRewardLeaderboardResponse, error) { + out := new(QueryGetTradingRewardLeaderboardResponse) + err := c.cc.Invoke(ctx, "/bze.v1.rewards.Query/GetTradingRewardLeaderboardHandler", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *queryClient) GetMarketIdTradingRewardIdHandler(ctx context.Context, in *QueryGetMarketIdTradingRewardIdHandlerRequest, opts ...grpc.CallOption) (*QueryGetMarketIdTradingRewardIdHandlerResponse, error) { + out := new(QueryGetMarketIdTradingRewardIdHandlerResponse) + err := c.cc.Invoke(ctx, "/bze.v1.rewards.Query/GetMarketIdTradingRewardIdHandler", 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. @@ -885,6 +1109,10 @@ type QueryServer interface { StakingRewardParticipant(context.Context, *QueryGetStakingRewardParticipantRequest) (*QueryGetStakingRewardParticipantResponse, error) // Queries a list of StakingRewardParticipant items. StakingRewardParticipantAll(context.Context, *QueryAllStakingRewardParticipantRequest) (*QueryAllStakingRewardParticipantResponse, error) + // Queries a list of GetTradingRewardLeaderboard items. + GetTradingRewardLeaderboardHandler(context.Context, *QueryGetTradingRewardLeaderboardRequest) (*QueryGetTradingRewardLeaderboardResponse, error) + // Queries a list of GetMarketIdTradingRewardIdHandler items. + GetMarketIdTradingRewardIdHandler(context.Context, *QueryGetMarketIdTradingRewardIdHandlerRequest) (*QueryGetMarketIdTradingRewardIdHandlerResponse, error) } // UnimplementedQueryServer can be embedded to have forward compatible implementations. @@ -912,6 +1140,12 @@ func (*UnimplementedQueryServer) StakingRewardParticipant(ctx context.Context, r func (*UnimplementedQueryServer) StakingRewardParticipantAll(ctx context.Context, req *QueryAllStakingRewardParticipantRequest) (*QueryAllStakingRewardParticipantResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method StakingRewardParticipantAll not implemented") } +func (*UnimplementedQueryServer) GetTradingRewardLeaderboardHandler(ctx context.Context, req *QueryGetTradingRewardLeaderboardRequest) (*QueryGetTradingRewardLeaderboardResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetTradingRewardLeaderboardHandler not implemented") +} +func (*UnimplementedQueryServer) GetMarketIdTradingRewardIdHandler(ctx context.Context, req *QueryGetMarketIdTradingRewardIdHandlerRequest) (*QueryGetMarketIdTradingRewardIdHandlerResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetMarketIdTradingRewardIdHandler not implemented") +} func RegisterQueryServer(s grpc1.Server, srv QueryServer) { s.RegisterService(&_Query_serviceDesc, srv) @@ -1043,6 +1277,42 @@ func _Query_StakingRewardParticipantAll_Handler(srv interface{}, ctx context.Con return interceptor(ctx, in, info, handler) } +func _Query_GetTradingRewardLeaderboardHandler_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryGetTradingRewardLeaderboardRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).GetTradingRewardLeaderboardHandler(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/bze.v1.rewards.Query/GetTradingRewardLeaderboardHandler", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).GetTradingRewardLeaderboardHandler(ctx, req.(*QueryGetTradingRewardLeaderboardRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Query_GetMarketIdTradingRewardIdHandler_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(QueryGetMarketIdTradingRewardIdHandlerRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(QueryServer).GetMarketIdTradingRewardIdHandler(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/bze.v1.rewards.Query/GetMarketIdTradingRewardIdHandler", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(QueryServer).GetMarketIdTradingRewardIdHandler(ctx, req.(*QueryGetMarketIdTradingRewardIdHandlerRequest)) + } + return interceptor(ctx, in, info, handler) +} + var _Query_serviceDesc = grpc.ServiceDesc{ ServiceName: "bze.v1.rewards.Query", HandlerType: (*QueryServer)(nil), @@ -1075,6 +1345,14 @@ var _Query_serviceDesc = grpc.ServiceDesc{ MethodName: "StakingRewardParticipantAll", Handler: _Query_StakingRewardParticipantAll_Handler, }, + { + MethodName: "GetTradingRewardLeaderboardHandler", + Handler: _Query_GetTradingRewardLeaderboardHandler_Handler, + }, + { + MethodName: "GetMarketIdTradingRewardIdHandler", + Handler: _Query_GetMarketIdTradingRewardIdHandler_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "rewards/query.proto", @@ -1612,90 +1890,220 @@ func (m *QueryAllStakingRewardParticipantResponse) MarshalToSizedBuffer(dAtA []b 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 +func (m *QueryGetTradingRewardLeaderboardRequest) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err } - var l int - _ = l - return n + return dAtA[:n], nil } -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 (m *QueryGetTradingRewardLeaderboardRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryGetStakingRewardRequest) Size() (n int) { - if m == nil { - return 0 - } +func (m *QueryGetTradingRewardLeaderboardRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - l = len(m.RewardId) - if l > 0 { - n += 1 + l + sovQuery(uint64(l)) + if len(m.RewardId) > 0 { + i -= len(m.RewardId) + copy(dAtA[i:], m.RewardId) + i = encodeVarintQuery(dAtA, i, uint64(len(m.RewardId))) + i-- + dAtA[i] = 0xa } - return n + return len(dAtA) - i, nil } -func (m *QueryGetStakingRewardResponse) Size() (n int) { - if m == nil { - return 0 +func (m *QueryGetTradingRewardLeaderboardResponse) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err } - var l int - _ = l - l = m.StakingReward.Size() - n += 1 + l + sovQuery(uint64(l)) - return n + return dAtA[:n], nil } -func (m *QueryAllStakingRewardRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Pagination != nil { - l = m.Pagination.Size() - n += 1 + l + sovQuery(uint64(l)) - } - return n +func (m *QueryGetTradingRewardLeaderboardResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *QueryAllStakingRewardResponse) Size() (n int) { - if m == nil { - return 0 - } +func (m *QueryGetTradingRewardLeaderboardResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i var l int _ = l - if len(m.List) > 0 { - for _, e := range m.List { - l = e.Size() - n += 1 + l + sovQuery(uint64(l)) + if m.Leaderboard != nil { + { + size, err := m.Leaderboard.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 (m *QueryGetMarketIdTradingRewardIdHandlerRequest) 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 *QueryGetMarketIdTradingRewardIdHandlerRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryGetMarketIdTradingRewardIdHandlerRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.MarketId) > 0 { + i -= len(m.MarketId) + copy(dAtA[i:], m.MarketId) + i = encodeVarintQuery(dAtA, i, uint64(len(m.MarketId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *QueryGetMarketIdTradingRewardIdHandlerResponse) 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 *QueryGetMarketIdTradingRewardIdHandlerResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *QueryGetMarketIdTradingRewardIdHandlerResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.MarketIdRewardId != nil { + { + size, err := m.MarketIdRewardId.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 (m *QueryGetStakingRewardRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.RewardId) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryGetStakingRewardResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = m.StakingReward.Size() + n += 1 + l + sovQuery(uint64(l)) + return n +} + +func (m *QueryAllStakingRewardRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryAllStakingRewardResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.List) > 0 { + for _, e := range m.List { + l = e.Size() + n += 1 + l + sovQuery(uint64(l)) + } + } + if m.Pagination != nil { + l = m.Pagination.Size() + n += 1 + l + sovQuery(uint64(l)) } - if m.Pagination != nil { - l = m.Pagination.Size() - n += 1 + l + sovQuery(uint64(l)) - } return n } @@ -1827,6 +2235,58 @@ func (m *QueryAllStakingRewardParticipantResponse) Size() (n int) { return n } +func (m *QueryGetTradingRewardLeaderboardRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.RewardId) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryGetTradingRewardLeaderboardResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Leaderboard != nil { + l = m.Leaderboard.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryGetMarketIdTradingRewardIdHandlerRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.MarketId) + if l > 0 { + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *QueryGetMarketIdTradingRewardIdHandlerResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.MarketIdRewardId != nil { + l = m.MarketIdRewardId.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + func sovQuery(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -3184,6 +3644,342 @@ func (m *QueryAllStakingRewardParticipantResponse) Unmarshal(dAtA []byte) error } return nil } +func (m *QueryGetTradingRewardLeaderboardRequest) 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: QueryGetTradingRewardLeaderboardRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGetTradingRewardLeaderboardRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RewardId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.RewardId = string(dAtA[iNdEx:postIndex]) + 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 (m *QueryGetTradingRewardLeaderboardResponse) 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: QueryGetTradingRewardLeaderboardResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGetTradingRewardLeaderboardResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Leaderboard", 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 m.Leaderboard == nil { + m.Leaderboard = &TradingRewardLeaderboard{} + } + if err := m.Leaderboard.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 (m *QueryGetMarketIdTradingRewardIdHandlerRequest) 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: QueryGetMarketIdTradingRewardIdHandlerRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGetMarketIdTradingRewardIdHandlerRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MarketId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + 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 ErrInvalidLengthQuery + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthQuery + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.MarketId = string(dAtA[iNdEx:postIndex]) + 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 (m *QueryGetMarketIdTradingRewardIdHandlerResponse) 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: QueryGetMarketIdTradingRewardIdHandlerResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: QueryGetMarketIdTradingRewardIdHandlerResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MarketIdRewardId", 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 m.MarketIdRewardId == nil { + m.MarketIdRewardId = &MarketIdTradingRewardId{} + } + if err := m.MarketIdRewardId.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 diff --git a/x/rewards/types/query.pb.gw.go b/x/rewards/types/query.pb.gw.go index dfacde24..8fb4990d 100644 --- a/x/rewards/types/query.pb.gw.go +++ b/x/rewards/types/query.pb.gw.go @@ -375,6 +375,96 @@ func local_request_Query_StakingRewardParticipantAll_0(ctx context.Context, mars } +func request_Query_GetTradingRewardLeaderboardHandler_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryGetTradingRewardLeaderboardRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["reward_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "reward_id") + } + + protoReq.RewardId, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "reward_id", err) + } + + msg, err := client.GetTradingRewardLeaderboardHandler(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_GetTradingRewardLeaderboardHandler_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryGetTradingRewardLeaderboardRequest + var metadata runtime.ServerMetadata + + var ( + val string + ok bool + err error + _ = err + ) + + val, ok = pathParams["reward_id"] + if !ok { + return nil, metadata, status.Errorf(codes.InvalidArgument, "missing parameter %s", "reward_id") + } + + protoReq.RewardId, err = runtime.String(val) + + if err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "type mismatch, parameter: %s, error: %v", "reward_id", err) + } + + msg, err := server.GetTradingRewardLeaderboardHandler(ctx, &protoReq) + return msg, metadata, err + +} + +var ( + filter_Query_GetMarketIdTradingRewardIdHandler_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_Query_GetMarketIdTradingRewardIdHandler_0(ctx context.Context, marshaler runtime.Marshaler, client QueryClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryGetMarketIdTradingRewardIdHandlerRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_GetMarketIdTradingRewardIdHandler_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.GetMarketIdTradingRewardIdHandler(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_Query_GetMarketIdTradingRewardIdHandler_0(ctx context.Context, marshaler runtime.Marshaler, server QueryServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq QueryGetMarketIdTradingRewardIdHandlerRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Query_GetMarketIdTradingRewardIdHandler_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.GetMarketIdTradingRewardIdHandler(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. @@ -542,6 +632,52 @@ func RegisterQueryHandlerServer(ctx context.Context, mux *runtime.ServeMux, serv }) + mux.Handle("GET", pattern_Query_GetTradingRewardLeaderboardHandler_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_GetTradingRewardLeaderboardHandler_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_GetTradingRewardLeaderboardHandler_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_GetMarketIdTradingRewardIdHandler_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_GetMarketIdTradingRewardIdHandler_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_GetMarketIdTradingRewardIdHandler_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -723,6 +859,46 @@ func RegisterQueryHandlerClient(ctx context.Context, mux *runtime.ServeMux, clie }) + mux.Handle("GET", pattern_Query_GetTradingRewardLeaderboardHandler_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_GetTradingRewardLeaderboardHandler_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_GetTradingRewardLeaderboardHandler_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + + mux.Handle("GET", pattern_Query_GetMarketIdTradingRewardIdHandler_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_GetMarketIdTradingRewardIdHandler_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_GetMarketIdTradingRewardIdHandler_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + return nil } @@ -740,6 +916,10 @@ var ( pattern_Query_StakingRewardParticipant_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"bze", "rewards", "v1", "staking_reward_participant", "address"}, "", runtime.AssumeColonVerbOpt(true))) pattern_Query_StakingRewardParticipantAll_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"bze", "rewards", "v1", "staking_reward_participants"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_GetTradingRewardLeaderboardHandler_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3, 1, 0, 4, 1, 5, 4}, []string{"bze", "rewards", "v1", "trading_reward_leaderboard", "reward_id"}, "", runtime.AssumeColonVerbOpt(true))) + + pattern_Query_GetMarketIdTradingRewardIdHandler_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"bze", "rewards", "v1", "market_id_trading_reward_id"}, "", runtime.AssumeColonVerbOpt(true))) ) var ( @@ -756,4 +936,8 @@ var ( forward_Query_StakingRewardParticipant_0 = runtime.ForwardResponseMessage forward_Query_StakingRewardParticipantAll_0 = runtime.ForwardResponseMessage + + forward_Query_GetTradingRewardLeaderboardHandler_0 = runtime.ForwardResponseMessage + + forward_Query_GetMarketIdTradingRewardIdHandler_0 = runtime.ForwardResponseMessage ) From 26e283ba2d39bb4fb6e41de7329b2462a708f45d Mon Sep 17 00:00:00 2001 From: faneaatiku Date: Sun, 14 Apr 2024 17:54:27 +0300 Subject: [PATCH 25/35] fixed trading reward queries --- docs/static/openapi.yml | 125 +++++++++++------- go.mod | 3 - go.sum | 12 -- .../bze-alphateam/bze/bze.v1.rewards/index.ts | 86 ++++++------ .../bze/bze.v1.rewards/module/index.ts | 18 +-- .../bze/bze.v1.rewards/module/rest.ts | 48 ++++--- .../module/types/rewards/query.ts | 73 +++++++--- .../query_get_trading_reward_leaderboard.go | 2 +- x/rewards/keeper/grpc_query_trading_reward.go | 6 +- 9 files changed, 216 insertions(+), 157 deletions(-) diff --git a/docs/static/openapi.yml b/docs/static/openapi.yml index c0399b31..96d738e6 100644 --- a/docs/static/openapi.yml +++ b/docs/static/openapi.yml @@ -2151,67 +2151,23 @@ paths: type: boolean tags: - Query - '/bze-alphateam/bze/rewards/get_market_id_trading_reward_id_handler/{marketId}': + /bze/rewards/v1/market_id_trading_reward_id: get: summary: Queries a list of GetMarketIdTradingRewardIdHandler items. operationId: BzeV1RewardsGetMarketIdTradingRewardIdHandler - responses: - '200': - description: A successful response. - schema: - type: object - 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: {} - parameters: - - name: marketId - in: path - required: true - type: string - tags: - - Query - '/bze/rewards/v1/get_trading_reward_leaderboard/{reward_id}': - get: - summary: Queries a list of GetTradingRewardLeaderboard items. - operationId: BzeV1RewardsGetTradingRewardLeaderboardHandler responses: '200': description: A successful response. schema: type: object properties: - leaderboard: + market_id_reward_id: type: object properties: reward_id: type: string - list: - type: array - items: - type: object - properties: - amount: - type: string - address: - type: string - created_at: - type: string - format: int64 + market_id: + type: string default: description: An unexpected error response. schema: @@ -2231,9 +2187,9 @@ paths: type: string additionalProperties: {} parameters: - - name: reward_id - in: path - required: true + - name: market_id + in: query + required: false type: string tags: - Query @@ -2944,6 +2900,58 @@ paths: type: boolean tags: - Query + '/bze/rewards/v1/trading_reward_leaderboard/{reward_id}': + get: + summary: Queries a list of GetTradingRewardLeaderboard items. + operationId: BzeV1RewardsGetTradingRewardLeaderboardHandler + responses: + '200': + description: A successful response. + schema: + type: object + properties: + leaderboard: + type: object + properties: + reward_id: + type: string + list: + type: array + items: + type: object + properties: + amount: + type: string + address: + type: string + created_at: + type: string + format: int64 + 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: {} + parameters: + - name: reward_id + in: path + required: true + type: string + tags: + - Query /cosmos/auth/v1beta1/accounts: get: summary: Accounts returns all the existing accounts @@ -34713,6 +34721,13 @@ definitions: repeated Bar results = 1; PageResponse page = 2; } + bze.v1.rewards.MarketIdTradingRewardId: + type: object + properties: + reward_id: + type: string + market_id: + type: string bze.v1.rewards.MsgClaimStakingRewardsResponse: type: object properties: @@ -34896,6 +34911,14 @@ definitions: } bze.v1.rewards.QueryGetMarketIdTradingRewardIdHandlerResponse: type: object + properties: + market_id_reward_id: + type: object + properties: + reward_id: + type: string + market_id: + type: string bze.v1.rewards.QueryGetStakingRewardParticipantResponse: type: object properties: diff --git a/go.mod b/go.mod index 0519be13..23080d06 100644 --- a/go.mod +++ b/go.mod @@ -99,7 +99,6 @@ require ( github.com/fsnotify/fsnotify v1.6.0 // indirect github.com/fzipp/gocyclo v0.6.0 // indirect github.com/getsentry/sentry-go v0.17.0 // indirect - github.com/ghodss/yaml v1.0.0 // indirect github.com/go-critic/go-critic v0.6.5 // indirect github.com/go-kit/kit v0.12.0 // indirect github.com/go-kit/log v0.2.1 // indirect @@ -116,7 +115,6 @@ require ( github.com/godbus/dbus v0.0.0-20190726142602-4481cbc300e2 // indirect github.com/gofrs/flock v0.8.1 // indirect github.com/gogo/gateway v1.1.0 // indirect - github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b // indirect github.com/golang/snappy v0.0.4 // indirect github.com/golangci/check v0.0.0-20180506172741-cfe4005ccda2 // indirect github.com/golangci/dupl v0.0.0-20180902072040-3e9179ac440a // indirect @@ -139,7 +137,6 @@ require ( github.com/gostaticanalysis/forcetypeassert v0.1.0 // indirect github.com/gostaticanalysis/nilerr v0.1.1 // indirect github.com/grpc-ecosystem/go-grpc-middleware v1.3.0 // indirect - github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1 // 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 diff --git a/go.sum b/go.sum index 5fd2428c..bd2604ca 100644 --- a/go.sum +++ b/go.sum @@ -154,7 +154,6 @@ github.com/aymerick/douceur v0.2.0 h1:Mv+mAeH1Q+n9Fr+oyamOlAkUNPWPlA8PPGR0QAaYuP github.com/aymerick/douceur v0.2.0/go.mod h1:wlT5vV2O3h55X9m7iVYN0TBM0NH/MmbLnd30/FjWUq4= github.com/aymerick/raymond v2.0.3-0.20180322193309-b565731e1464+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g= github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= -github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= @@ -262,7 +261,6 @@ github.com/containerd/continuity v0.3.0 h1:nisirsYROK15TAMVukJOUyGJjz4BNQJBVsNvA github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= -github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= github.com/coreos/go-systemd v0.0.0-20180511133405-39ca1b05acc7/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/coreos/go-systemd/v22 v22.3.3-0.20220203105225-a9a7ef127534/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= @@ -397,7 +395,6 @@ github.com/getsentry/sentry-go v0.12.0/go.mod h1:NSap0JBYWzHND8oMbyi0+XZhUalc1TB github.com/getsentry/sentry-go v0.17.0 h1:UustVWnOoDFHBS7IJUB2QK/nB5pap748ZEp0swnQJak= github.com/getsentry/sentry-go v0.17.0/go.mod h1:B82dxtBvxG0KaPD8/hfSV+VcHD+Lg/xUS4JuQn1P4cM= github.com/ghemawat/stream v0.0.0-20171120220530-696b145b53b9/go.mod h1:106OIgooyS7OzLDOpUGgm9fA3bQENb/cFSyyBmMoJDs= -github.com/ghodss/yaml v1.0.0 h1:wQHKEahhL6wmXdzwWG11gIVCkOv05bNOh+Rxn0yngAk= github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= github.com/gin-contrib/sse v0.0.0-20190301062529-5545eab6dad3/go.mod h1:VJ0WA2NBN22VlZ2dKZQPAPnyWw5XTlK1KymzLKsr59s= github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE= @@ -490,13 +487,11 @@ github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzq github.com/golang-jwt/jwt/v4 v4.3.0/go.mod h1:/xlHOz8bRuivTWchD4jCa+NbatV+wEUSzwAxVc6locg= github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k= github.com/golang/geo v0.0.0-20190916061304-5b978397cfec/go.mod h1:QZ0nwyI2jOfgRAoBvP+ab5aRr7c9x7lhGEJrKvBwjWI= -github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b h1:VKtxabqXZkF25pY9ekfRL6a582T4P37/31XEstQ5p58= github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= @@ -504,7 +499,6 @@ github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= -github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.0/go.mod h1:Qd/q+1AKNOZr9uGQzbzCmRO6sUih6GTPZv6a1/R87v0= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= @@ -639,8 +633,6 @@ github.com/grpc-ecosystem/grpc-gateway v1.8.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t github.com/grpc-ecosystem/grpc-gateway v1.9.5/go.mod h1:vNeuVxBJEsws4ogUvrchl83t/GYV9WGTSLVdBhOQFDY= github.com/grpc-ecosystem/grpc-gateway v1.16.0 h1:gmcG1KaJ57LophUzW0Hy8NmPhnMZb4M0+kPpLofRdBo= github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1 h1:/c3QmbOGMGTOumP2iT/rCwB7b0QDGLKzqOmktBjT+Is= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.1/go.mod h1:5SN9VR2LTsRFsrEC6FHgRbTWrTHu6tqPeKxEQv15giM= 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= @@ -656,7 +648,6 @@ github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brv github.com/hashicorp/go-bexpr v0.1.10/go.mod h1:oxlubA2vC/gFVfX1A6JGp7ls7uCDlfJn732ehYYg+g0= github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= -github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48= github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= github.com/hashicorp/go-immutable-radix v1.3.1 h1:DKHmCUm2hRBK510BaiZlwvpD40f8bJFeZnpfm2KLowc= github.com/hashicorp/go-immutable-radix v1.3.1/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= @@ -666,7 +657,6 @@ github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+l github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= github.com/hashicorp/go-retryablehttp v0.5.3/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs= github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU= -github.com/hashicorp/go-rootcerts v1.0.2/go.mod h1:pqUvnprVnM5bf7AOirdbb01K4ccR319Vf4pU3K5EGc8= github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU= github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4= github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= @@ -1324,7 +1314,6 @@ go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= -go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= @@ -1332,7 +1321,6 @@ go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/atomic v1.10.0 h1:9qC72Qh0+3MqyJbAn8YU5xVq1frD8bn3JtD2oXtafVQ= go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= go.uber.org/goleak v1.1.11 h1:wy28qYRKZgnJTxGxvye5/wgWr1EKjmUDGYox5mGlRlI= -go.uber.org/goleak v1.1.11/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4= go.uber.org/multierr v1.8.0 h1:dg6GjLku4EH+249NNmoIciG9N/jURbDG+pFlTkhzIC8= diff --git a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/index.ts b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/index.ts index 4e5e8d1a..9be84c17 100755 --- a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/index.ts +++ b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/index.ts @@ -388,9 +388,13 @@ export default { try { const key = params ?? {}; const queryClient=await initQueryClient(rootGetters) - let value= (await queryClient.queryGetMarketIdTradingRewardIdHandler( key.marketId)).data + let value= (await queryClient.queryGetMarketIdTradingRewardIdHandler(query)).data + while (all && ( value).pagination && ( value).pagination.next_key!=null) { + let next_values=(await queryClient.queryGetMarketIdTradingRewardIdHandler({...query, 'pagination.key':( value).pagination.next_key})).data + value = mergeResults(value, next_values); + } commit('QUERY', { query: 'GetMarketIdTradingRewardIdHandler', key: { params: {...key}, query}, value }) if (subscribe) commit('SUBSCRIBE', { action: 'QueryGetMarketIdTradingRewardIdHandler', payload: { options: { all }, params: {...key},query }}) return getters['getGetMarketIdTradingRewardIdHandler']( { params: {...key}, query}) ?? {} @@ -401,18 +405,18 @@ export default { }, - async sendMsgClaimStakingRewards({ rootGetters }, { value, fee = [], memo = '' }) { + async sendMsgCreateStakingReward({ rootGetters }, { value, fee = [], memo = '' }) { try { const txClient=await initTxClient(rootGetters) - const msg = await txClient.msgClaimStakingRewards(value) + const msg = await txClient.msgCreateStakingReward(value) const result = await txClient.signAndBroadcast([msg], {fee: { amount: fee, gas: "200000" }, memo}) return result } catch (e) { if (e == MissingWalletError) { - throw new Error('TxClient:MsgClaimStakingRewards:Init Could not initialize signing client. Wallet is required.') + throw new Error('TxClient:MsgCreateStakingReward:Init Could not initialize signing client. Wallet is required.') }else{ - throw new Error('TxClient:MsgClaimStakingRewards:Send Could not broadcast Tx: '+ e.message) + throw new Error('TxClient:MsgCreateStakingReward:Send Could not broadcast Tx: '+ e.message) } } }, @@ -431,77 +435,77 @@ export default { } } }, - async sendMsgCreateTradingReward({ rootGetters }, { value, fee = [], memo = '' }) { + async sendMsgClaimStakingRewards({ rootGetters }, { value, fee = [], memo = '' }) { try { const txClient=await initTxClient(rootGetters) - const msg = await txClient.msgCreateTradingReward(value) + const msg = await txClient.msgClaimStakingRewards(value) const result = await txClient.signAndBroadcast([msg], {fee: { amount: fee, gas: "200000" }, memo}) return result } catch (e) { if (e == MissingWalletError) { - throw new Error('TxClient:MsgCreateTradingReward:Init Could not initialize signing client. Wallet is required.') + throw new Error('TxClient:MsgClaimStakingRewards:Init Could not initialize signing client. Wallet is required.') }else{ - throw new Error('TxClient:MsgCreateTradingReward:Send Could not broadcast Tx: '+ e.message) + throw new Error('TxClient:MsgClaimStakingRewards:Send Could not broadcast Tx: '+ e.message) } } }, - async sendMsgExitStaking({ rootGetters }, { value, fee = [], memo = '' }) { + async sendMsgUpdateStakingReward({ rootGetters }, { value, fee = [], memo = '' }) { try { const txClient=await initTxClient(rootGetters) - const msg = await txClient.msgExitStaking(value) + const msg = await txClient.msgUpdateStakingReward(value) const result = await txClient.signAndBroadcast([msg], {fee: { amount: fee, gas: "200000" }, memo}) return result } catch (e) { if (e == MissingWalletError) { - throw new Error('TxClient:MsgExitStaking:Init Could not initialize signing client. Wallet is required.') + throw new Error('TxClient:MsgUpdateStakingReward:Init Could not initialize signing client. Wallet is required.') }else{ - throw new Error('TxClient:MsgExitStaking:Send Could not broadcast Tx: '+ e.message) + throw new Error('TxClient:MsgUpdateStakingReward:Send Could not broadcast Tx: '+ e.message) } } }, - async sendMsgCreateStakingReward({ rootGetters }, { value, fee = [], memo = '' }) { + async sendMsgCreateTradingReward({ rootGetters }, { value, fee = [], memo = '' }) { try { const txClient=await initTxClient(rootGetters) - const msg = await txClient.msgCreateStakingReward(value) + const msg = await txClient.msgCreateTradingReward(value) const result = await txClient.signAndBroadcast([msg], {fee: { amount: fee, gas: "200000" }, memo}) return result } catch (e) { if (e == MissingWalletError) { - throw new Error('TxClient:MsgCreateStakingReward:Init Could not initialize signing client. Wallet is required.') + throw new Error('TxClient:MsgCreateTradingReward:Init Could not initialize signing client. Wallet is required.') }else{ - throw new Error('TxClient:MsgCreateStakingReward:Send Could not broadcast Tx: '+ e.message) + throw new Error('TxClient:MsgCreateTradingReward:Send Could not broadcast Tx: '+ e.message) } } }, - async sendMsgUpdateStakingReward({ rootGetters }, { value, fee = [], memo = '' }) { + async sendMsgExitStaking({ rootGetters }, { value, fee = [], memo = '' }) { try { const txClient=await initTxClient(rootGetters) - const msg = await txClient.msgUpdateStakingReward(value) + const msg = await txClient.msgExitStaking(value) const result = await txClient.signAndBroadcast([msg], {fee: { amount: fee, gas: "200000" }, memo}) return result } catch (e) { if (e == MissingWalletError) { - throw new Error('TxClient:MsgUpdateStakingReward:Init Could not initialize signing client. Wallet is required.') + throw new Error('TxClient:MsgExitStaking:Init Could not initialize signing client. Wallet is required.') }else{ - throw new Error('TxClient:MsgUpdateStakingReward:Send Could not broadcast Tx: '+ e.message) + throw new Error('TxClient:MsgExitStaking:Send Could not broadcast Tx: '+ e.message) } } }, - async MsgClaimStakingRewards({ rootGetters }, { value }) { + async MsgCreateStakingReward({ rootGetters }, { value }) { try { const txClient=await initTxClient(rootGetters) - const msg = await txClient.msgClaimStakingRewards(value) + const msg = await txClient.msgCreateStakingReward(value) return msg } catch (e) { if (e == MissingWalletError) { - throw new Error('TxClient:MsgClaimStakingRewards:Init Could not initialize signing client. Wallet is required.') + throw new Error('TxClient:MsgCreateStakingReward:Init Could not initialize signing client. Wallet is required.') } else{ - throw new Error('TxClient:MsgClaimStakingRewards:Create Could not create message: ' + e.message) + throw new Error('TxClient:MsgCreateStakingReward:Create Could not create message: ' + e.message) } } }, @@ -518,55 +522,55 @@ export default { } } }, - async MsgCreateTradingReward({ rootGetters }, { value }) { + async MsgClaimStakingRewards({ rootGetters }, { value }) { try { const txClient=await initTxClient(rootGetters) - const msg = await txClient.msgCreateTradingReward(value) + const msg = await txClient.msgClaimStakingRewards(value) return msg } catch (e) { if (e == MissingWalletError) { - throw new Error('TxClient:MsgCreateTradingReward:Init Could not initialize signing client. Wallet is required.') + throw new Error('TxClient:MsgClaimStakingRewards:Init Could not initialize signing client. Wallet is required.') } else{ - throw new Error('TxClient:MsgCreateTradingReward:Create Could not create message: ' + e.message) + throw new Error('TxClient:MsgClaimStakingRewards:Create Could not create message: ' + e.message) } } }, - async MsgExitStaking({ rootGetters }, { value }) { + async MsgUpdateStakingReward({ rootGetters }, { value }) { try { const txClient=await initTxClient(rootGetters) - const msg = await txClient.msgExitStaking(value) + const msg = await txClient.msgUpdateStakingReward(value) return msg } catch (e) { if (e == MissingWalletError) { - throw new Error('TxClient:MsgExitStaking:Init Could not initialize signing client. Wallet is required.') + throw new Error('TxClient:MsgUpdateStakingReward:Init Could not initialize signing client. Wallet is required.') } else{ - throw new Error('TxClient:MsgExitStaking:Create Could not create message: ' + e.message) + throw new Error('TxClient:MsgUpdateStakingReward:Create Could not create message: ' + e.message) } } }, - async MsgCreateStakingReward({ rootGetters }, { value }) { + async MsgCreateTradingReward({ rootGetters }, { value }) { try { const txClient=await initTxClient(rootGetters) - const msg = await txClient.msgCreateStakingReward(value) + const msg = await txClient.msgCreateTradingReward(value) return msg } catch (e) { if (e == MissingWalletError) { - throw new Error('TxClient:MsgCreateStakingReward:Init Could not initialize signing client. Wallet is required.') + throw new Error('TxClient:MsgCreateTradingReward:Init Could not initialize signing client. Wallet is required.') } else{ - throw new Error('TxClient:MsgCreateStakingReward:Create Could not create message: ' + e.message) + throw new Error('TxClient:MsgCreateTradingReward:Create Could not create message: ' + e.message) } } }, - async MsgUpdateStakingReward({ rootGetters }, { value }) { + async MsgExitStaking({ rootGetters }, { value }) { try { const txClient=await initTxClient(rootGetters) - const msg = await txClient.msgUpdateStakingReward(value) + const msg = await txClient.msgExitStaking(value) return msg } catch (e) { if (e == MissingWalletError) { - throw new Error('TxClient:MsgUpdateStakingReward:Init Could not initialize signing client. Wallet is required.') + throw new Error('TxClient:MsgExitStaking:Init Could not initialize signing client. Wallet is required.') } else{ - throw new Error('TxClient:MsgUpdateStakingReward:Create Could not create message: ' + e.message) + throw new Error('TxClient:MsgExitStaking:Create Could not create message: ' + e.message) } } }, diff --git a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/index.ts b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/index.ts index c277808f..a7af324d 100755 --- a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/index.ts +++ b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/index.ts @@ -4,21 +4,21 @@ import { StdFee } from "@cosmjs/launchpad"; import { SigningStargateClient } from "@cosmjs/stargate"; import { Registry, OfflineSigner, EncodeObject, DirectSecp256k1HdWallet } from "@cosmjs/proto-signing"; import { Api } from "./rest"; -import { MsgClaimStakingRewards } from "./types/rewards/tx"; +import { MsgCreateStakingReward } from "./types/rewards/tx"; import { MsgJoinStaking } from "./types/rewards/tx"; +import { MsgClaimStakingRewards } from "./types/rewards/tx"; +import { MsgUpdateStakingReward } from "./types/rewards/tx"; import { MsgCreateTradingReward } from "./types/rewards/tx"; import { MsgExitStaking } from "./types/rewards/tx"; -import { MsgCreateStakingReward } from "./types/rewards/tx"; -import { MsgUpdateStakingReward } from "./types/rewards/tx"; const types = [ - ["/bze.v1.rewards.MsgClaimStakingRewards", MsgClaimStakingRewards], + ["/bze.v1.rewards.MsgCreateStakingReward", MsgCreateStakingReward], ["/bze.v1.rewards.MsgJoinStaking", MsgJoinStaking], + ["/bze.v1.rewards.MsgClaimStakingRewards", MsgClaimStakingRewards], + ["/bze.v1.rewards.MsgUpdateStakingReward", MsgUpdateStakingReward], ["/bze.v1.rewards.MsgCreateTradingReward", MsgCreateTradingReward], ["/bze.v1.rewards.MsgExitStaking", MsgExitStaking], - ["/bze.v1.rewards.MsgCreateStakingReward", MsgCreateStakingReward], - ["/bze.v1.rewards.MsgUpdateStakingReward", MsgUpdateStakingReward], ]; export const MissingWalletError = new Error("wallet is required"); @@ -51,12 +51,12 @@ const txClient = async (wallet: OfflineSigner, { addr: addr }: TxClientOptions = return { signAndBroadcast: (msgs: EncodeObject[], { fee, memo }: SignAndBroadcastOptions = {fee: defaultFee, memo: ""}) => client.signAndBroadcast(address, msgs, fee,memo), - msgClaimStakingRewards: (data: MsgClaimStakingRewards): EncodeObject => ({ typeUrl: "/bze.v1.rewards.MsgClaimStakingRewards", value: MsgClaimStakingRewards.fromPartial( data ) }), + msgCreateStakingReward: (data: MsgCreateStakingReward): EncodeObject => ({ typeUrl: "/bze.v1.rewards.MsgCreateStakingReward", value: MsgCreateStakingReward.fromPartial( data ) }), msgJoinStaking: (data: MsgJoinStaking): EncodeObject => ({ typeUrl: "/bze.v1.rewards.MsgJoinStaking", value: MsgJoinStaking.fromPartial( data ) }), + msgClaimStakingRewards: (data: MsgClaimStakingRewards): EncodeObject => ({ typeUrl: "/bze.v1.rewards.MsgClaimStakingRewards", value: MsgClaimStakingRewards.fromPartial( data ) }), + msgUpdateStakingReward: (data: MsgUpdateStakingReward): EncodeObject => ({ typeUrl: "/bze.v1.rewards.MsgUpdateStakingReward", value: MsgUpdateStakingReward.fromPartial( data ) }), msgCreateTradingReward: (data: MsgCreateTradingReward): EncodeObject => ({ typeUrl: "/bze.v1.rewards.MsgCreateTradingReward", value: MsgCreateTradingReward.fromPartial( data ) }), msgExitStaking: (data: MsgExitStaking): EncodeObject => ({ typeUrl: "/bze.v1.rewards.MsgExitStaking", value: MsgExitStaking.fromPartial( data ) }), - msgCreateStakingReward: (data: MsgCreateStakingReward): EncodeObject => ({ typeUrl: "/bze.v1.rewards.MsgCreateStakingReward", value: MsgCreateStakingReward.fromPartial( data ) }), - msgUpdateStakingReward: (data: MsgUpdateStakingReward): EncodeObject => ({ typeUrl: "/bze.v1.rewards.MsgUpdateStakingReward", value: MsgUpdateStakingReward.fromPartial( data ) }), }; }; diff --git a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/rest.ts b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/rest.ts index 456d755e..00a2b53c 100644 --- a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/rest.ts +++ b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/rest.ts @@ -13,6 +13,11 @@ export interface ProtobufAny { "@type"?: string; } +export interface RewardsMarketIdTradingRewardId { + reward_id?: string; + market_id?: string; +} + export interface RewardsMsgClaimStakingRewardsResponse { amount?: string; } @@ -76,7 +81,9 @@ export interface RewardsQueryAllTradingRewardResponse { pagination?: V1Beta1PageResponse; } -export type RewardsQueryGetMarketIdTradingRewardIdHandlerResponse = object; +export interface RewardsQueryGetMarketIdTradingRewardIdHandlerResponse { + market_id_reward_id?: RewardsMarketIdTradingRewardId; +} export interface RewardsQueryGetStakingRewardParticipantResponse { list?: V1RewardsStakingRewardParticipant[]; @@ -450,28 +457,13 @@ export class Api extends HttpClient + queryGetMarketIdTradingRewardIdHandler = (query?: { market_id?: string }, params: RequestParams = {}) => this.request({ - path: `/bze-alphateam/bze/rewards/get_market_id_trading_reward_id_handler/${marketId}`, - method: "GET", - format: "json", - ...params, - }); - - /** - * No description - * - * @tags Query - * @name QueryGetTradingRewardLeaderboardHandler - * @summary Queries a list of GetTradingRewardLeaderboard items. - * @request GET:/bze/rewards/v1/get_trading_reward_leaderboard/{reward_id} - */ - queryGetTradingRewardLeaderboardHandler = (reward_id: string, params: RequestParams = {}) => - this.request({ - path: `/bze/rewards/v1/get_trading_reward_leaderboard/${reward_id}`, + path: `/bze/rewards/v1/market_id_trading_reward_id`, method: "GET", + query: query, format: "json", ...params, }); @@ -629,4 +621,20 @@ export class Api extends HttpClient + this.request({ + path: `/bze/rewards/v1/trading_reward_leaderboard/${reward_id}`, + method: "GET", + format: "json", + ...params, + }); } diff --git a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/query.ts b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/query.ts index 182f16d2..db84ae9b 100644 --- a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/query.ts +++ b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/query.ts @@ -9,6 +9,7 @@ import { import { TradingReward, TradingRewardLeaderboard, + MarketIdTradingRewardId, } from "../rewards/trading_reward"; import { StakingRewardParticipant } from "../rewards/staking_reward_participant"; @@ -86,10 +87,12 @@ export interface QueryGetTradingRewardLeaderboardResponse { } export interface QueryGetMarketIdTradingRewardIdHandlerRequest { - marketId: string; + market_id: string; } -export interface QueryGetMarketIdTradingRewardIdHandlerResponse {} +export interface QueryGetMarketIdTradingRewardIdHandlerResponse { + market_id_reward_id: MarketIdTradingRewardId | undefined; +} const baseQueryParamsRequest: object = {}; @@ -1364,7 +1367,7 @@ export const QueryGetTradingRewardLeaderboardResponse = { }; const baseQueryGetMarketIdTradingRewardIdHandlerRequest: object = { - marketId: "", + market_id: "", }; export const QueryGetMarketIdTradingRewardIdHandlerRequest = { @@ -1372,8 +1375,8 @@ export const QueryGetMarketIdTradingRewardIdHandlerRequest = { message: QueryGetMarketIdTradingRewardIdHandlerRequest, writer: Writer = Writer.create() ): Writer { - if (message.marketId !== "") { - writer.uint32(10).string(message.marketId); + if (message.market_id !== "") { + writer.uint32(10).string(message.market_id); } return writer; }, @@ -1391,7 +1394,7 @@ export const QueryGetMarketIdTradingRewardIdHandlerRequest = { const tag = reader.uint32(); switch (tag >>> 3) { case 1: - message.marketId = reader.string(); + message.market_id = reader.string(); break; default: reader.skipType(tag & 7); @@ -1405,17 +1408,17 @@ export const QueryGetMarketIdTradingRewardIdHandlerRequest = { const message = { ...baseQueryGetMarketIdTradingRewardIdHandlerRequest, } as QueryGetMarketIdTradingRewardIdHandlerRequest; - if (object.marketId !== undefined && object.marketId !== null) { - message.marketId = String(object.marketId); + if (object.market_id !== undefined && object.market_id !== null) { + message.market_id = String(object.market_id); } else { - message.marketId = ""; + message.market_id = ""; } return message; }, toJSON(message: QueryGetMarketIdTradingRewardIdHandlerRequest): unknown { const obj: any = {}; - message.marketId !== undefined && (obj.marketId = message.marketId); + message.market_id !== undefined && (obj.market_id = message.market_id); return obj; }, @@ -1425,10 +1428,10 @@ export const QueryGetMarketIdTradingRewardIdHandlerRequest = { const message = { ...baseQueryGetMarketIdTradingRewardIdHandlerRequest, } as QueryGetMarketIdTradingRewardIdHandlerRequest; - if (object.marketId !== undefined && object.marketId !== null) { - message.marketId = object.marketId; + if (object.market_id !== undefined && object.market_id !== null) { + message.market_id = object.market_id; } else { - message.marketId = ""; + message.market_id = ""; } return message; }, @@ -1438,9 +1441,15 @@ const baseQueryGetMarketIdTradingRewardIdHandlerResponse: object = {}; export const QueryGetMarketIdTradingRewardIdHandlerResponse = { encode( - _: QueryGetMarketIdTradingRewardIdHandlerResponse, + message: QueryGetMarketIdTradingRewardIdHandlerResponse, writer: Writer = Writer.create() ): Writer { + if (message.market_id_reward_id !== undefined) { + MarketIdTradingRewardId.encode( + message.market_id_reward_id, + writer.uint32(10).fork() + ).ldelim(); + } return writer; }, @@ -1456,6 +1465,12 @@ export const QueryGetMarketIdTradingRewardIdHandlerResponse = { while (reader.pos < end) { const tag = reader.uint32(); switch (tag >>> 3) { + case 1: + message.market_id_reward_id = MarketIdTradingRewardId.decode( + reader, + reader.uint32() + ); + break; default: reader.skipType(tag & 7); break; @@ -1464,24 +1479,48 @@ export const QueryGetMarketIdTradingRewardIdHandlerResponse = { return message; }, - fromJSON(_: any): QueryGetMarketIdTradingRewardIdHandlerResponse { + fromJSON(object: any): QueryGetMarketIdTradingRewardIdHandlerResponse { const message = { ...baseQueryGetMarketIdTradingRewardIdHandlerResponse, } as QueryGetMarketIdTradingRewardIdHandlerResponse; + if ( + object.market_id_reward_id !== undefined && + object.market_id_reward_id !== null + ) { + message.market_id_reward_id = MarketIdTradingRewardId.fromJSON( + object.market_id_reward_id + ); + } else { + message.market_id_reward_id = undefined; + } return message; }, - toJSON(_: QueryGetMarketIdTradingRewardIdHandlerResponse): unknown { + toJSON(message: QueryGetMarketIdTradingRewardIdHandlerResponse): unknown { const obj: any = {}; + message.market_id_reward_id !== undefined && + (obj.market_id_reward_id = message.market_id_reward_id + ? MarketIdTradingRewardId.toJSON(message.market_id_reward_id) + : undefined); return obj; }, fromPartial( - _: DeepPartial + object: DeepPartial ): QueryGetMarketIdTradingRewardIdHandlerResponse { const message = { ...baseQueryGetMarketIdTradingRewardIdHandlerResponse, } as QueryGetMarketIdTradingRewardIdHandlerResponse; + if ( + object.market_id_reward_id !== undefined && + object.market_id_reward_id !== null + ) { + message.market_id_reward_id = MarketIdTradingRewardId.fromPartial( + object.market_id_reward_id + ); + } else { + message.market_id_reward_id = undefined; + } return message; }, }; diff --git a/x/rewards/client/cli/query_get_trading_reward_leaderboard.go b/x/rewards/client/cli/query_get_trading_reward_leaderboard.go index 1eecc63d..570efcf0 100644 --- a/x/rewards/client/cli/query_get_trading_reward_leaderboard.go +++ b/x/rewards/client/cli/query_get_trading_reward_leaderboard.go @@ -31,7 +31,7 @@ func CmdGetTradingRewardLeaderboard() *cobra.Command { RewardId: reqRewardId, } - res, err := queryClient.GetTradingRewardLeaderboard(cmd.Context(), params) + res, err := queryClient.GetTradingRewardLeaderboardHandler(cmd.Context(), params) if err != nil { return err } diff --git a/x/rewards/keeper/grpc_query_trading_reward.go b/x/rewards/keeper/grpc_query_trading_reward.go index d68bdf95..2b5c4d9b 100644 --- a/x/rewards/keeper/grpc_query_trading_reward.go +++ b/x/rewards/keeper/grpc_query_trading_reward.go @@ -11,7 +11,7 @@ import ( "google.golang.org/grpc/status" ) -func (k msgServer) TradingRewardAll(c context.Context, req *types.QueryAllTradingRewardRequest) (*types.QueryAllTradingRewardResponse, error) { +func (k Keeper) TradingRewardAll(c context.Context, req *types.QueryAllTradingRewardRequest) (*types.QueryAllTradingRewardResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "invalid request") } @@ -37,7 +37,7 @@ func (k msgServer) TradingRewardAll(c context.Context, req *types.QueryAllTradin return &types.QueryAllTradingRewardResponse{List: tradingRewards, Pagination: pageRes}, nil } -func (k msgServer) TradingReward(c context.Context, req *types.QueryGetTradingRewardRequest) (*types.QueryGetTradingRewardResponse, error) { +func (k Keeper) TradingReward(c context.Context, req *types.QueryGetTradingRewardRequest) (*types.QueryGetTradingRewardResponse, error) { if req == nil { return nil, status.Error(codes.InvalidArgument, "invalid request") } @@ -56,7 +56,7 @@ func (k msgServer) TradingReward(c context.Context, req *types.QueryGetTradingRe return nil, status.Error(codes.NotFound, "not found") } -func (k msgServer) getTradingRewardStore(ctx sdk.Context, state string) prefix.Store { +func (k Keeper) getTradingRewardStore(ctx sdk.Context, state string) prefix.Store { s := k.getActiveTradingRewardStore(ctx) if state == "pending" { s = k.getPendingTradingRewardStore(ctx) From 5404194acdd6e1bbbd3652ecd25a41e43ea6b904 Mon Sep 17 00:00:00 2001 From: faneaatiku Date: Thu, 18 Apr 2024 17:13:14 +0300 Subject: [PATCH 26/35] fixed key duplication on token staking participant --- x/rewards/keeper/msg_server_exit_staking.go | 2 +- x/rewards/types/key_pending_unlock_participant.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/x/rewards/keeper/msg_server_exit_staking.go b/x/rewards/keeper/msg_server_exit_staking.go index 6f89db7f..afa3e7d4 100644 --- a/x/rewards/keeper/msg_server_exit_staking.go +++ b/x/rewards/keeper/msg_server_exit_staking.go @@ -59,7 +59,7 @@ func (k msgServer) beginUnlock(ctx sdk.Context, p types.StakingRewardParticipant lockedUntil := k.epochKeeper.GetEpochCountByIdentifier(ctx, expirationEpoch) lockedUntil += int64(sr.Lock) * 24 pending := types.PendingUnlockParticipant{ - Index: types.CreatePendingUnlockParticipantKey(lockedUntil, sr.RewardId), + Index: types.CreatePendingUnlockParticipantKey(lockedUntil, fmt.Sprintf("%s/%s", sr.RewardId, p.Address)), Address: p.Address, Amount: p.Amount, Denom: sr.StakingDenom, diff --git a/x/rewards/types/key_pending_unlock_participant.go b/x/rewards/types/key_pending_unlock_participant.go index d8f1186b..bb007492 100644 --- a/x/rewards/types/key_pending_unlock_participant.go +++ b/x/rewards/types/key_pending_unlock_participant.go @@ -18,7 +18,7 @@ func PendingUnlockParticipantKey(key string) []byte { } func CreatePendingUnlockParticipantKey(epoch int64, key string) string { - return fmt.Sprintf("%d/%s/", epoch, key) + return fmt.Sprintf("%d/%s", epoch, key) } // PendingUnlockParticipantPrefix returns the store key to retrieve all PendingUnlockParticipant for an epoch From b5271e524ea2fd4c41aab031cfb538468cabb0e6 Mon Sep 17 00:00:00 2001 From: faneaatiku Date: Thu, 18 Apr 2024 18:48:39 +0300 Subject: [PATCH 27/35] added gov proposal to enable trading reward --- app/app.go | 5 +- proto/rewards/gov.proto | 10 + testutil/simapp/app.go | 5 +- .../bze-alphateam/bze/bze.v1.rewards/index.ts | 68 +-- .../bze/bze.v1.rewards/module/index.ts | 24 +- .../module/types/rewards/gov.ts | 129 ++++++ x/burner/client/cli/gov.go | 4 - x/rewards/client/cli/gov.go | 72 +++ x/rewards/client/proposal_handler.go | 23 + x/rewards/keeper/gov.go | 46 ++ x/rewards/keeper/keeper.go | 6 + x/rewards/keeper/msg_server_trading_reward.go | 6 - x/rewards/proposal_handler.go | 20 + x/rewards/types/gov.go | 41 ++ x/rewards/types/gov.pb.go | 420 ++++++++++++++++++ 15 files changed, 822 insertions(+), 57 deletions(-) create mode 100644 proto/rewards/gov.proto create mode 100644 vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/gov.ts create mode 100644 x/rewards/client/cli/gov.go create mode 100644 x/rewards/client/proposal_handler.go create mode 100644 x/rewards/keeper/gov.go create mode 100644 x/rewards/proposal_handler.go create mode 100644 x/rewards/types/gov.go create mode 100644 x/rewards/types/gov.pb.go diff --git a/app/app.go b/app/app.go index 2b3b8b7e..6210e679 100644 --- a/app/app.go +++ b/app/app.go @@ -7,6 +7,7 @@ import ( epochskeeper "github.com/bze-alphateam/bze/x/epochs/keeper" epochstypes "github.com/bze-alphateam/bze/x/epochs/types" "github.com/bze-alphateam/bze/x/rewards" + rewardsclient "github.com/bze-alphateam/bze/x/rewards/client" rewardskeeper "github.com/bze-alphateam/bze/x/rewards/keeper" rewardstypes "github.com/bze-alphateam/bze/x/rewards/types" "github.com/bze-alphateam/bze/x/tradebin" @@ -143,6 +144,7 @@ func getGovProposalHandlers() []govclient.ProposalHandler { cointrunkmoduleclient.AcceptedDomainProposalHandler, cointrunkmoduleclient.PublisherProposalHandler, burnermoduleclient.BurnCoinsProposalHandler, + rewardsclient.ActivateTradingRewardProposalHandler, // this line is used by starport scaffolding # stargate/app/govProposalHandler ) @@ -509,7 +511,8 @@ func New( AddRoute(upgradetypes.RouterKey, upgrade.NewSoftwareUpgradeProposalHandler(app.UpgradeKeeper)). AddRoute(ibcclienttypes.RouterKey, ibcclient.NewClientProposalHandler(app.IBCKeeper.ClientKeeper)). AddRoute(cointrunkmoduletypes.RouterKey, cointrunkmodule.NewCointrunkProposalHandler(app.CointrunkKeeper)). - AddRoute(burnermoduletypes.RouterKey, burnermodule.NewBurnerProposalHandler(app.BurnerKeeper)) + AddRoute(burnermoduletypes.RouterKey, burnermodule.NewBurnerProposalHandler(app.BurnerKeeper)). + AddRoute(rewardstypes.RouterKey, rewards.NewRewardsProposalHandler(app.RewardsKeeper)) app.GovKeeper = govkeeper.NewKeeper( appCodec, keys[govtypes.StoreKey], app.GetSubspace(govtypes.ModuleName), app.AccountKeeper, app.BankKeeper, diff --git a/proto/rewards/gov.proto b/proto/rewards/gov.proto new file mode 100644 index 00000000..8972ee53 --- /dev/null +++ b/proto/rewards/gov.proto @@ -0,0 +1,10 @@ +syntax = "proto3"; +package bze.v1.rewards; + +option go_package = "github.com/bze-alphateam/bze/x/rewards/types"; + +message ActivateTradingRewardProposal { + string title = 1; + string description = 2; + string reward_id = 3; +} diff --git a/testutil/simapp/app.go b/testutil/simapp/app.go index 7568bb8e..1a324da1 100644 --- a/testutil/simapp/app.go +++ b/testutil/simapp/app.go @@ -8,6 +8,7 @@ import ( epochskeeper "github.com/bze-alphateam/bze/x/epochs/keeper" epochstypes "github.com/bze-alphateam/bze/x/epochs/types" "github.com/bze-alphateam/bze/x/rewards" + rewardsclient "github.com/bze-alphateam/bze/x/rewards/client" rewardskeeper "github.com/bze-alphateam/bze/x/rewards/keeper" rewardstypes "github.com/bze-alphateam/bze/x/rewards/types" "github.com/bze-alphateam/bze/x/tradebin" @@ -144,6 +145,7 @@ func getGovProposalHandlers() []govclient.ProposalHandler { cointrunkmoduleclient.AcceptedDomainProposalHandler, cointrunkmoduleclient.PublisherProposalHandler, burnermoduleclient.BurnCoinsProposalHandler, + rewardsclient.ActivateTradingRewardProposalHandler, // this line is used by starport scaffolding # stargate/app/govProposalHandler ) @@ -508,7 +510,8 @@ func New( AddRoute(upgradetypes.RouterKey, upgrade.NewSoftwareUpgradeProposalHandler(app.UpgradeKeeper)). AddRoute(ibcclienttypes.RouterKey, ibcclient.NewClientProposalHandler(app.IBCKeeper.ClientKeeper)). AddRoute(cointrunkmoduletypes.RouterKey, cointrunkmodule.NewCointrunkProposalHandler(app.CointrunkKeeper)). - AddRoute(burnermoduletypes.RouterKey, burnermodule.NewBurnerProposalHandler(app.BurnerKeeper)) + AddRoute(burnermoduletypes.RouterKey, burnermodule.NewBurnerProposalHandler(app.BurnerKeeper)). + AddRoute(rewardstypes.RouterKey, rewards.NewRewardsProposalHandler(app.RewardsKeeper)) app.GovKeeper = govkeeper.NewKeeper( appCodec, keys[govtypes.StoreKey], app.GetSubspace(govtypes.ModuleName), app.AccountKeeper, app.BankKeeper, diff --git a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/index.ts b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/index.ts index 9be84c17..5d4200d4 100755 --- a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/index.ts +++ b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/index.ts @@ -1,5 +1,6 @@ import { txClient, queryClient, MissingWalletError , registry} from './module' +import { ActivateTradingRewardProposal } from "./module/types/rewards/gov" import { Params } from "./module/types/rewards/params" import { StakingReward } from "./module/types/rewards/staking_reward" import { StakingRewardParticipant } from "./module/types/rewards/staking_reward_participant" @@ -12,7 +13,7 @@ import { TradingRewardCandidate } from "./module/types/rewards/trading_reward" import { MarketIdTradingRewardId } from "./module/types/rewards/trading_reward" -export { Params, StakingReward, StakingRewardParticipant, PendingUnlockParticipant, TradingReward, TradingRewardExpiration, TradingRewardLeaderboard, TradingRewardLeaderboardEntry, TradingRewardCandidate, MarketIdTradingRewardId }; +export { ActivateTradingRewardProposal, Params, StakingReward, StakingRewardParticipant, PendingUnlockParticipant, TradingReward, TradingRewardExpiration, TradingRewardLeaderboard, TradingRewardLeaderboardEntry, TradingRewardCandidate, MarketIdTradingRewardId }; async function initTxClient(vuexGetters) { return await txClient(vuexGetters['common/wallet/signer'], { @@ -61,6 +62,7 @@ const getDefaultState = () => { GetMarketIdTradingRewardIdHandler: {}, _Structure: { + ActivateTradingRewardProposal: getStructure(ActivateTradingRewardProposal.fromPartial({})), Params: getStructure(Params.fromPartial({})), StakingReward: getStructure(StakingReward.fromPartial({})), StakingRewardParticipant: getStructure(StakingRewardParticipant.fromPartial({})), @@ -405,33 +407,33 @@ export default { }, - async sendMsgCreateStakingReward({ rootGetters }, { value, fee = [], memo = '' }) { + async sendMsgCreateTradingReward({ rootGetters }, { value, fee = [], memo = '' }) { try { const txClient=await initTxClient(rootGetters) - const msg = await txClient.msgCreateStakingReward(value) + const msg = await txClient.msgCreateTradingReward(value) const result = await txClient.signAndBroadcast([msg], {fee: { amount: fee, gas: "200000" }, memo}) return result } catch (e) { if (e == MissingWalletError) { - throw new Error('TxClient:MsgCreateStakingReward:Init Could not initialize signing client. Wallet is required.') + throw new Error('TxClient:MsgCreateTradingReward:Init Could not initialize signing client. Wallet is required.') }else{ - throw new Error('TxClient:MsgCreateStakingReward:Send Could not broadcast Tx: '+ e.message) + throw new Error('TxClient:MsgCreateTradingReward:Send Could not broadcast Tx: '+ e.message) } } }, - async sendMsgJoinStaking({ rootGetters }, { value, fee = [], memo = '' }) { + async sendMsgExitStaking({ rootGetters }, { value, fee = [], memo = '' }) { try { const txClient=await initTxClient(rootGetters) - const msg = await txClient.msgJoinStaking(value) + const msg = await txClient.msgExitStaking(value) const result = await txClient.signAndBroadcast([msg], {fee: { amount: fee, gas: "200000" }, memo}) return result } catch (e) { if (e == MissingWalletError) { - throw new Error('TxClient:MsgJoinStaking:Init Could not initialize signing client. Wallet is required.') + throw new Error('TxClient:MsgExitStaking:Init Could not initialize signing client. Wallet is required.') }else{ - throw new Error('TxClient:MsgJoinStaking:Send Could not broadcast Tx: '+ e.message) + throw new Error('TxClient:MsgExitStaking:Send Could not broadcast Tx: '+ e.message) } } }, @@ -465,60 +467,60 @@ export default { } } }, - async sendMsgCreateTradingReward({ rootGetters }, { value, fee = [], memo = '' }) { + async sendMsgJoinStaking({ rootGetters }, { value, fee = [], memo = '' }) { try { const txClient=await initTxClient(rootGetters) - const msg = await txClient.msgCreateTradingReward(value) + const msg = await txClient.msgJoinStaking(value) const result = await txClient.signAndBroadcast([msg], {fee: { amount: fee, gas: "200000" }, memo}) return result } catch (e) { if (e == MissingWalletError) { - throw new Error('TxClient:MsgCreateTradingReward:Init Could not initialize signing client. Wallet is required.') + throw new Error('TxClient:MsgJoinStaking:Init Could not initialize signing client. Wallet is required.') }else{ - throw new Error('TxClient:MsgCreateTradingReward:Send Could not broadcast Tx: '+ e.message) + throw new Error('TxClient:MsgJoinStaking:Send Could not broadcast Tx: '+ e.message) } } }, - async sendMsgExitStaking({ rootGetters }, { value, fee = [], memo = '' }) { + async sendMsgCreateStakingReward({ rootGetters }, { value, fee = [], memo = '' }) { try { const txClient=await initTxClient(rootGetters) - const msg = await txClient.msgExitStaking(value) + const msg = await txClient.msgCreateStakingReward(value) const result = await txClient.signAndBroadcast([msg], {fee: { amount: fee, gas: "200000" }, memo}) return result } catch (e) { if (e == MissingWalletError) { - throw new Error('TxClient:MsgExitStaking:Init Could not initialize signing client. Wallet is required.') + throw new Error('TxClient:MsgCreateStakingReward:Init Could not initialize signing client. Wallet is required.') }else{ - throw new Error('TxClient:MsgExitStaking:Send Could not broadcast Tx: '+ e.message) + throw new Error('TxClient:MsgCreateStakingReward:Send Could not broadcast Tx: '+ e.message) } } }, - async MsgCreateStakingReward({ rootGetters }, { value }) { + async MsgCreateTradingReward({ rootGetters }, { value }) { try { const txClient=await initTxClient(rootGetters) - const msg = await txClient.msgCreateStakingReward(value) + const msg = await txClient.msgCreateTradingReward(value) return msg } catch (e) { if (e == MissingWalletError) { - throw new Error('TxClient:MsgCreateStakingReward:Init Could not initialize signing client. Wallet is required.') + throw new Error('TxClient:MsgCreateTradingReward:Init Could not initialize signing client. Wallet is required.') } else{ - throw new Error('TxClient:MsgCreateStakingReward:Create Could not create message: ' + e.message) + throw new Error('TxClient:MsgCreateTradingReward:Create Could not create message: ' + e.message) } } }, - async MsgJoinStaking({ rootGetters }, { value }) { + async MsgExitStaking({ rootGetters }, { value }) { try { const txClient=await initTxClient(rootGetters) - const msg = await txClient.msgJoinStaking(value) + const msg = await txClient.msgExitStaking(value) return msg } catch (e) { if (e == MissingWalletError) { - throw new Error('TxClient:MsgJoinStaking:Init Could not initialize signing client. Wallet is required.') + throw new Error('TxClient:MsgExitStaking:Init Could not initialize signing client. Wallet is required.') } else{ - throw new Error('TxClient:MsgJoinStaking:Create Could not create message: ' + e.message) + throw new Error('TxClient:MsgExitStaking:Create Could not create message: ' + e.message) } } }, @@ -548,29 +550,29 @@ export default { } } }, - async MsgCreateTradingReward({ rootGetters }, { value }) { + async MsgJoinStaking({ rootGetters }, { value }) { try { const txClient=await initTxClient(rootGetters) - const msg = await txClient.msgCreateTradingReward(value) + const msg = await txClient.msgJoinStaking(value) return msg } catch (e) { if (e == MissingWalletError) { - throw new Error('TxClient:MsgCreateTradingReward:Init Could not initialize signing client. Wallet is required.') + throw new Error('TxClient:MsgJoinStaking:Init Could not initialize signing client. Wallet is required.') } else{ - throw new Error('TxClient:MsgCreateTradingReward:Create Could not create message: ' + e.message) + throw new Error('TxClient:MsgJoinStaking:Create Could not create message: ' + e.message) } } }, - async MsgExitStaking({ rootGetters }, { value }) { + async MsgCreateStakingReward({ rootGetters }, { value }) { try { const txClient=await initTxClient(rootGetters) - const msg = await txClient.msgExitStaking(value) + const msg = await txClient.msgCreateStakingReward(value) return msg } catch (e) { if (e == MissingWalletError) { - throw new Error('TxClient:MsgExitStaking:Init Could not initialize signing client. Wallet is required.') + throw new Error('TxClient:MsgCreateStakingReward:Init Could not initialize signing client. Wallet is required.') } else{ - throw new Error('TxClient:MsgExitStaking:Create Could not create message: ' + e.message) + throw new Error('TxClient:MsgCreateStakingReward:Create Could not create message: ' + e.message) } } }, diff --git a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/index.ts b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/index.ts index a7af324d..b4d29687 100755 --- a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/index.ts +++ b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/index.ts @@ -4,21 +4,21 @@ import { StdFee } from "@cosmjs/launchpad"; import { SigningStargateClient } from "@cosmjs/stargate"; import { Registry, OfflineSigner, EncodeObject, DirectSecp256k1HdWallet } from "@cosmjs/proto-signing"; import { Api } from "./rest"; -import { MsgCreateStakingReward } from "./types/rewards/tx"; -import { MsgJoinStaking } from "./types/rewards/tx"; -import { MsgClaimStakingRewards } from "./types/rewards/tx"; -import { MsgUpdateStakingReward } from "./types/rewards/tx"; import { MsgCreateTradingReward } from "./types/rewards/tx"; import { MsgExitStaking } from "./types/rewards/tx"; +import { MsgClaimStakingRewards } from "./types/rewards/tx"; +import { MsgUpdateStakingReward } from "./types/rewards/tx"; +import { MsgJoinStaking } from "./types/rewards/tx"; +import { MsgCreateStakingReward } from "./types/rewards/tx"; const types = [ - ["/bze.v1.rewards.MsgCreateStakingReward", MsgCreateStakingReward], - ["/bze.v1.rewards.MsgJoinStaking", MsgJoinStaking], - ["/bze.v1.rewards.MsgClaimStakingRewards", MsgClaimStakingRewards], - ["/bze.v1.rewards.MsgUpdateStakingReward", MsgUpdateStakingReward], ["/bze.v1.rewards.MsgCreateTradingReward", MsgCreateTradingReward], ["/bze.v1.rewards.MsgExitStaking", MsgExitStaking], + ["/bze.v1.rewards.MsgClaimStakingRewards", MsgClaimStakingRewards], + ["/bze.v1.rewards.MsgUpdateStakingReward", MsgUpdateStakingReward], + ["/bze.v1.rewards.MsgJoinStaking", MsgJoinStaking], + ["/bze.v1.rewards.MsgCreateStakingReward", MsgCreateStakingReward], ]; export const MissingWalletError = new Error("wallet is required"); @@ -51,12 +51,12 @@ const txClient = async (wallet: OfflineSigner, { addr: addr }: TxClientOptions = return { signAndBroadcast: (msgs: EncodeObject[], { fee, memo }: SignAndBroadcastOptions = {fee: defaultFee, memo: ""}) => client.signAndBroadcast(address, msgs, fee,memo), - msgCreateStakingReward: (data: MsgCreateStakingReward): EncodeObject => ({ typeUrl: "/bze.v1.rewards.MsgCreateStakingReward", value: MsgCreateStakingReward.fromPartial( data ) }), - msgJoinStaking: (data: MsgJoinStaking): EncodeObject => ({ typeUrl: "/bze.v1.rewards.MsgJoinStaking", value: MsgJoinStaking.fromPartial( data ) }), - msgClaimStakingRewards: (data: MsgClaimStakingRewards): EncodeObject => ({ typeUrl: "/bze.v1.rewards.MsgClaimStakingRewards", value: MsgClaimStakingRewards.fromPartial( data ) }), - msgUpdateStakingReward: (data: MsgUpdateStakingReward): EncodeObject => ({ typeUrl: "/bze.v1.rewards.MsgUpdateStakingReward", value: MsgUpdateStakingReward.fromPartial( data ) }), msgCreateTradingReward: (data: MsgCreateTradingReward): EncodeObject => ({ typeUrl: "/bze.v1.rewards.MsgCreateTradingReward", value: MsgCreateTradingReward.fromPartial( data ) }), msgExitStaking: (data: MsgExitStaking): EncodeObject => ({ typeUrl: "/bze.v1.rewards.MsgExitStaking", value: MsgExitStaking.fromPartial( data ) }), + msgClaimStakingRewards: (data: MsgClaimStakingRewards): EncodeObject => ({ typeUrl: "/bze.v1.rewards.MsgClaimStakingRewards", value: MsgClaimStakingRewards.fromPartial( data ) }), + msgUpdateStakingReward: (data: MsgUpdateStakingReward): EncodeObject => ({ typeUrl: "/bze.v1.rewards.MsgUpdateStakingReward", value: MsgUpdateStakingReward.fromPartial( data ) }), + msgJoinStaking: (data: MsgJoinStaking): EncodeObject => ({ typeUrl: "/bze.v1.rewards.MsgJoinStaking", value: MsgJoinStaking.fromPartial( data ) }), + msgCreateStakingReward: (data: MsgCreateStakingReward): EncodeObject => ({ typeUrl: "/bze.v1.rewards.MsgCreateStakingReward", value: MsgCreateStakingReward.fromPartial( data ) }), }; }; diff --git a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/gov.ts b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/gov.ts new file mode 100644 index 00000000..da16280c --- /dev/null +++ b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/gov.ts @@ -0,0 +1,129 @@ +/* eslint-disable */ +import { Writer, Reader } from "protobufjs/minimal"; + +export const protobufPackage = "bze.v1.rewards"; + +export interface ActivateTradingRewardProposal { + title: string; + description: string; + reward_id: string; +} + +const baseActivateTradingRewardProposal: object = { + title: "", + description: "", + reward_id: "", +}; + +export const ActivateTradingRewardProposal = { + encode( + message: ActivateTradingRewardProposal, + writer: Writer = Writer.create() + ): Writer { + if (message.title !== "") { + writer.uint32(10).string(message.title); + } + if (message.description !== "") { + writer.uint32(18).string(message.description); + } + if (message.reward_id !== "") { + writer.uint32(26).string(message.reward_id); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): ActivateTradingRewardProposal { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseActivateTradingRewardProposal, + } as ActivateTradingRewardProposal; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.title = reader.string(); + break; + case 2: + message.description = reader.string(); + break; + case 3: + message.reward_id = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): ActivateTradingRewardProposal { + const message = { + ...baseActivateTradingRewardProposal, + } as ActivateTradingRewardProposal; + if (object.title !== undefined && object.title !== null) { + message.title = String(object.title); + } else { + message.title = ""; + } + if (object.description !== undefined && object.description !== null) { + message.description = String(object.description); + } else { + message.description = ""; + } + if (object.reward_id !== undefined && object.reward_id !== null) { + message.reward_id = String(object.reward_id); + } else { + message.reward_id = ""; + } + return message; + }, + + toJSON(message: ActivateTradingRewardProposal): unknown { + const obj: any = {}; + message.title !== undefined && (obj.title = message.title); + message.description !== undefined && + (obj.description = message.description); + message.reward_id !== undefined && (obj.reward_id = message.reward_id); + return obj; + }, + + fromPartial( + object: DeepPartial + ): ActivateTradingRewardProposal { + const message = { + ...baseActivateTradingRewardProposal, + } as ActivateTradingRewardProposal; + if (object.title !== undefined && object.title !== null) { + message.title = object.title; + } else { + message.title = ""; + } + if (object.description !== undefined && object.description !== null) { + message.description = object.description; + } else { + message.description = ""; + } + if (object.reward_id !== undefined && object.reward_id !== null) { + message.reward_id = object.reward_id; + } else { + message.reward_id = ""; + } + return message; + }, +}; + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; diff --git a/x/burner/client/cli/gov.go b/x/burner/client/cli/gov.go index 2436ce1d..ff9c5259 100644 --- a/x/burner/client/cli/gov.go +++ b/x/burner/client/cli/gov.go @@ -10,10 +10,6 @@ import ( "github.com/spf13/cobra" ) -const ( - ActiveFlag = "active" -) - func NewCmdSubmitBurnCoinsProposal() *cobra.Command { cmd := &cobra.Command{ Use: "burn-coins", diff --git a/x/rewards/client/cli/gov.go b/x/rewards/client/cli/gov.go new file mode 100644 index 00000000..c7580050 --- /dev/null +++ b/x/rewards/client/cli/gov.go @@ -0,0 +1,72 @@ +package cli + +import ( + "fmt" + "github.com/bze-alphateam/bze/x/rewards/types" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/tx" + sdk "github.com/cosmos/cosmos-sdk/types" + govcli "github.com/cosmos/cosmos-sdk/x/gov/client/cli" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" + "github.com/spf13/cobra" +) + +func NewCmdSubmitActivateTradingRewardProposal() *cobra.Command { + cmd := &cobra.Command{ + Use: "activate-trading-reward", + Args: cobra.ExactArgs(1), + Short: "Submit activate trading reward proposal", + Long: "Submit activate trading reward proposal along with an initial deposit.\n", + RunE: func(cmd *cobra.Command, args []string) error { + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + argRewardId := args[0] + if argRewardId == "" { + return fmt.Errorf("empty reward id provided") + } + + title, err := cmd.Flags().GetString(govcli.FlagTitle) + if err != nil { + return err + } + + description, err := cmd.Flags().GetString(govcli.FlagDescription) + if err != nil { + return err + } + + content := types.NewActivateTradingRewardProposal(argRewardId, title, description) + + from := clientCtx.GetFromAddress() + + depositStr, err := cmd.Flags().GetString(govcli.FlagDeposit) + if err != nil { + return err + } + deposit, err := sdk.ParseCoinsNormalized(depositStr) + if err != nil { + return err + } + + msg, err := govtypes.NewMsgSubmitProposal(content, deposit, from) + if err != nil { + return err + } + + if err = msg.ValidateBasic(); err != nil { + return err + } + + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + cmd.Flags().String(govcli.FlagTitle, "", "title of proposal") + cmd.Flags().String(govcli.FlagDescription, "", "description of proposal") + cmd.Flags().String(govcli.FlagDeposit, "", "deposit of proposal") + + return cmd +} diff --git a/x/rewards/client/proposal_handler.go b/x/rewards/client/proposal_handler.go new file mode 100644 index 00000000..22f3790e --- /dev/null +++ b/x/rewards/client/proposal_handler.go @@ -0,0 +1,23 @@ +package client + +import ( + "net/http" + + "github.com/bze-alphateam/bze/x/rewards/client/cli" + + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/types/rest" + govclient "github.com/cosmos/cosmos-sdk/x/gov/client" + govrest "github.com/cosmos/cosmos-sdk/x/gov/client/rest" +) + +var ActivateTradingRewardProposalHandler = govclient.NewProposalHandler(cli.NewCmdSubmitActivateTradingRewardProposal, emptyRestHandler) + +func emptyRestHandler(client.Context) govrest.ProposalRESTHandler { + return govrest.ProposalRESTHandler{ + SubRoute: "unsupported-activate-trading-reward", + Handler: func(w http.ResponseWriter, r *http.Request) { + rest.WriteErrorResponse(w, http.StatusBadRequest, "Legacy REST Routes are not supported for Rewards proposals") + }, + } +} diff --git a/x/rewards/keeper/gov.go b/x/rewards/keeper/gov.go new file mode 100644 index 00000000..912e762a --- /dev/null +++ b/x/rewards/keeper/gov.go @@ -0,0 +1,46 @@ +package keeper + +import ( + "fmt" + "github.com/bze-alphateam/bze/x/rewards/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +func (k Keeper) HandleActivateTradingRewardProposal(ctx sdk.Context, proposal *types.ActivateTradingRewardProposal) error { + //check if already active + _, found := k.GetActiveTradingReward(ctx, proposal.RewardId) + if found { + return fmt.Errorf("trading reward already active") + } + + //check if the reward exists and is pending + r, found := k.GetPendingTradingReward(ctx, proposal.RewardId) + if !found { + return fmt.Errorf("trading reward not found") + } + + //remove the pending reward expiration because we're moving this one to active trading reward + k.RemovePendingTradingRewardExpiration(ctx, r.ExpireAt, r.RewardId) + k.RemovePendingTradingReward(ctx, r.RewardId) + + //move the trading reward to active + r.ExpireAt = k.getNewTradingRewardExpireAt(ctx) + k.SetActiveTradingReward(ctx, r) + + //save expiration + exp := types.TradingRewardExpiration{ + RewardId: r.RewardId, + ExpireAt: r.ExpireAt, + } + k.SetActiveTradingRewardExpiration(ctx, exp) + + //save the market id, so we can find the reward by market id + k.SetMarketIdRewardId(ctx, types.MarketIdTradingRewardId{ + RewardId: r.RewardId, + MarketId: r.MarketId, + }) + + k.Logger(ctx).Info(fmt.Sprintf("trading reward with id [%s] has been activated", r.RewardId)) + + return nil +} diff --git a/x/rewards/keeper/keeper.go b/x/rewards/keeper/keeper.go index 760caa26..76db0717 100644 --- a/x/rewards/keeper/keeper.go +++ b/x/rewards/keeper/keeper.go @@ -105,3 +105,9 @@ func (k Keeper) getAmountToCapture(feeParam, denom, amount string, multiplier in return result, nil } + +func (k Keeper) getNewTradingRewardExpireAt(ctx sdk.Context) uint32 { + cnt := uint32(k.epochKeeper.GetEpochCountByIdentifier(ctx, expirationEpoch)) + + return cnt + expirationPeriodInHours +} diff --git a/x/rewards/keeper/msg_server_trading_reward.go b/x/rewards/keeper/msg_server_trading_reward.go index 5c6907f6..0719f23c 100644 --- a/x/rewards/keeper/msg_server_trading_reward.go +++ b/x/rewards/keeper/msg_server_trading_reward.go @@ -86,9 +86,3 @@ func (k msgServer) checkUserBalances(ctx sdk.Context, neededCoins sdk.Coins, add return nil } - -func (k msgServer) getNewTradingRewardExpireAt(ctx sdk.Context) uint32 { - cnt := uint32(k.epochKeeper.GetEpochCountByIdentifier(ctx, expirationEpoch)) - - return cnt + expirationPeriodInHours -} diff --git a/x/rewards/proposal_handler.go b/x/rewards/proposal_handler.go new file mode 100644 index 00000000..3d2e9099 --- /dev/null +++ b/x/rewards/proposal_handler.go @@ -0,0 +1,20 @@ +package rewards + +import ( + "github.com/bze-alphateam/bze/x/rewards/keeper" + "github.com/bze-alphateam/bze/x/rewards/types" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" +) + +func NewRewardsProposalHandler(k keeper.Keeper) govtypes.Handler { + return func(ctx sdk.Context, content govtypes.Content) error { + switch c := content.(type) { + case *types.ActivateTradingRewardProposal: + return k.HandleActivateTradingRewardProposal(ctx, c) + default: + return sdkerrors.Wrapf(sdkerrors.ErrUnknownRequest, "unrecognized rewards proposal content type: %T", c) + } + } +} diff --git a/x/rewards/types/gov.go b/x/rewards/types/gov.go new file mode 100644 index 00000000..b4de14c7 --- /dev/null +++ b/x/rewards/types/gov.go @@ -0,0 +1,41 @@ +package types + +import ( + govtypes "github.com/cosmos/cosmos-sdk/x/gov/types" +) + +const ( + ProposalTypeActivateTradingReward = "ActivateTradingRewardProposal" +) + +func init() { + govtypes.RegisterProposalType(ProposalTypeActivateTradingReward) + govtypes.RegisterProposalTypeCodec(&ActivateTradingRewardProposal{}, "rewards/ActivateTradingRewardProposal") +} + +var ( + _ govtypes.Content = &ActivateTradingRewardProposal{} +) + +func NewActivateTradingRewardProposal(rewardId, title, description string) govtypes.Content { + return &ActivateTradingRewardProposal{ + RewardId: rewardId, + Title: title, + Description: description, + } +} + +func (m *ActivateTradingRewardProposal) ProposalRoute() string { return RouterKey } + +func (m *ActivateTradingRewardProposal) ProposalType() string { + return ProposalTypeActivateTradingReward +} + +func (m *ActivateTradingRewardProposal) ValidateBasic() error { + err := govtypes.ValidateAbstract(m) + if err != nil { + return err + } + + return nil +} diff --git a/x/rewards/types/gov.pb.go b/x/rewards/types/gov.pb.go new file mode 100644 index 00000000..abbf5d06 --- /dev/null +++ b/x/rewards/types/gov.pb.go @@ -0,0 +1,420 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: rewards/gov.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 ActivateTradingRewardProposal struct { + Title string `protobuf:"bytes,1,opt,name=title,proto3" json:"title,omitempty"` + Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"` + RewardId string `protobuf:"bytes,3,opt,name=reward_id,json=rewardId,proto3" json:"reward_id,omitempty"` +} + +func (m *ActivateTradingRewardProposal) Reset() { *m = ActivateTradingRewardProposal{} } +func (m *ActivateTradingRewardProposal) String() string { return proto.CompactTextString(m) } +func (*ActivateTradingRewardProposal) ProtoMessage() {} +func (*ActivateTradingRewardProposal) Descriptor() ([]byte, []int) { + return fileDescriptor_82dfa7fb9d195861, []int{0} +} +func (m *ActivateTradingRewardProposal) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ActivateTradingRewardProposal) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ActivateTradingRewardProposal.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 *ActivateTradingRewardProposal) XXX_Merge(src proto.Message) { + xxx_messageInfo_ActivateTradingRewardProposal.Merge(m, src) +} +func (m *ActivateTradingRewardProposal) XXX_Size() int { + return m.Size() +} +func (m *ActivateTradingRewardProposal) XXX_DiscardUnknown() { + xxx_messageInfo_ActivateTradingRewardProposal.DiscardUnknown(m) +} + +var xxx_messageInfo_ActivateTradingRewardProposal proto.InternalMessageInfo + +func (m *ActivateTradingRewardProposal) GetTitle() string { + if m != nil { + return m.Title + } + return "" +} + +func (m *ActivateTradingRewardProposal) GetDescription() string { + if m != nil { + return m.Description + } + return "" +} + +func (m *ActivateTradingRewardProposal) GetRewardId() string { + if m != nil { + return m.RewardId + } + return "" +} + +func init() { + proto.RegisterType((*ActivateTradingRewardProposal)(nil), "bze.v1.rewards.ActivateTradingRewardProposal") +} + +func init() { proto.RegisterFile("rewards/gov.proto", fileDescriptor_82dfa7fb9d195861) } + +var fileDescriptor_82dfa7fb9d195861 = []byte{ + // 210 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x2c, 0x4a, 0x2d, 0x4f, + 0x2c, 0x4a, 0x29, 0xd6, 0x4f, 0xcf, 0x2f, 0xd3, 0x2b, 0x28, 0xca, 0x2f, 0xc9, 0x17, 0xe2, 0x4b, + 0xaa, 0x4a, 0xd5, 0x2b, 0x33, 0xd4, 0x83, 0xca, 0x28, 0x95, 0x70, 0xc9, 0x3a, 0x26, 0x97, 0x64, + 0x96, 0x25, 0x96, 0xa4, 0x86, 0x14, 0x25, 0xa6, 0x64, 0xe6, 0xa5, 0x07, 0x81, 0x65, 0x02, 0x8a, + 0xf2, 0x0b, 0xf2, 0x8b, 0x13, 0x73, 0x84, 0x44, 0xb8, 0x58, 0x4b, 0x32, 0x4b, 0x72, 0x52, 0x25, + 0x18, 0x15, 0x18, 0x35, 0x38, 0x83, 0x20, 0x1c, 0x21, 0x05, 0x2e, 0xee, 0x94, 0xd4, 0xe2, 0xe4, + 0xa2, 0xcc, 0x82, 0x92, 0xcc, 0xfc, 0x3c, 0x09, 0x26, 0xb0, 0x1c, 0xb2, 0x90, 0x90, 0x34, 0x17, + 0x27, 0xc4, 0x8e, 0xf8, 0xcc, 0x14, 0x09, 0x66, 0xb0, 0x3c, 0x07, 0x44, 0xc0, 0x33, 0xc5, 0xc9, + 0xed, 0xc4, 0x23, 0x39, 0xc6, 0x0b, 0x8f, 0xe4, 0x18, 0x1f, 0x3c, 0x92, 0x63, 0x9c, 0xf0, 0x58, + 0x8e, 0xe1, 0xc2, 0x63, 0x39, 0x86, 0x1b, 0x8f, 0xe5, 0x18, 0xa2, 0x74, 0xd2, 0x33, 0x4b, 0x32, + 0x4a, 0x93, 0xf4, 0x92, 0xf3, 0x73, 0xf5, 0x93, 0xaa, 0x52, 0x75, 0x13, 0x73, 0x0a, 0x32, 0x12, + 0x4b, 0x52, 0x13, 0xc1, 0x3c, 0xfd, 0x0a, 0x7d, 0x98, 0x8f, 0x4a, 0x2a, 0x0b, 0x52, 0x8b, 0x93, + 0xd8, 0xc0, 0x9e, 0x32, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0xc8, 0x48, 0xae, 0xf1, 0xe9, 0x00, + 0x00, 0x00, +} + +func (m *ActivateTradingRewardProposal) 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 *ActivateTradingRewardProposal) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ActivateTradingRewardProposal) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.RewardId) > 0 { + i -= len(m.RewardId) + copy(dAtA[i:], m.RewardId) + i = encodeVarintGov(dAtA, i, uint64(len(m.RewardId))) + i-- + dAtA[i] = 0x1a + } + if len(m.Description) > 0 { + i -= len(m.Description) + copy(dAtA[i:], m.Description) + i = encodeVarintGov(dAtA, i, uint64(len(m.Description))) + i-- + dAtA[i] = 0x12 + } + if len(m.Title) > 0 { + i -= len(m.Title) + copy(dAtA[i:], m.Title) + i = encodeVarintGov(dAtA, i, uint64(len(m.Title))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintGov(dAtA []byte, offset int, v uint64) int { + offset -= sovGov(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *ActivateTradingRewardProposal) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Title) + if l > 0 { + n += 1 + l + sovGov(uint64(l)) + } + l = len(m.Description) + if l > 0 { + n += 1 + l + sovGov(uint64(l)) + } + l = len(m.RewardId) + if l > 0 { + n += 1 + l + sovGov(uint64(l)) + } + return n +} + +func sovGov(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozGov(x uint64) (n int) { + return sovGov(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *ActivateTradingRewardProposal) 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 ErrIntOverflowGov + } + 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: ActivateTradingRewardProposal: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ActivateTradingRewardProposal: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Title", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGov + } + 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 ErrInvalidLengthGov + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGov + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Title = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Description", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGov + } + 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 ErrInvalidLengthGov + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGov + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Description = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RewardId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowGov + } + 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 ErrInvalidLengthGov + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthGov + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.RewardId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipGov(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthGov + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipGov(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, ErrIntOverflowGov + } + 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, ErrIntOverflowGov + } + 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, ErrIntOverflowGov + } + 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, ErrInvalidLengthGov + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupGov + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthGov + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthGov = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowGov = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupGov = fmt.Errorf("proto: unexpected end of group") +) From ebb8ad6b0721f0857f6bed0ee3ab8dc3e206fa25 Mon Sep 17 00:00:00 2001 From: faneaatiku Date: Thu, 18 Apr 2024 19:29:08 +0300 Subject: [PATCH 28/35] upgraded ibc-go --- go.mod | 2 +- go.sum | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 23080d06..06970810 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.20 require ( github.com/cosmos/cosmos-sdk v0.45.16 - github.com/cosmos/ibc-go/v4 v4.5.1 + github.com/cosmos/ibc-go/v4 v4.6.0 github.com/gogo/protobuf v1.3.3 github.com/golang/protobuf v1.5.4 github.com/golangci/golangci-lint v1.50.1 diff --git a/go.sum b/go.sum index bd2604ca..3ed3026a 100644 --- a/go.sum +++ b/go.sum @@ -154,6 +154,7 @@ github.com/aymerick/douceur v0.2.0 h1:Mv+mAeH1Q+n9Fr+oyamOlAkUNPWPlA8PPGR0QAaYuP github.com/aymerick/douceur v0.2.0/go.mod h1:wlT5vV2O3h55X9m7iVYN0TBM0NH/MmbLnd30/FjWUq4= github.com/aymerick/raymond v2.0.3-0.20180322193309-b565731e1464+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g= github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= +github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= @@ -261,6 +262,7 @@ github.com/containerd/continuity v0.3.0 h1:nisirsYROK15TAMVukJOUyGJjz4BNQJBVsNvA github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= +github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= github.com/coreos/go-systemd v0.0.0-20180511133405-39ca1b05acc7/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/coreos/go-systemd/v22 v22.3.3-0.20220203105225-a9a7ef127534/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= @@ -281,6 +283,8 @@ github.com/cosmos/iavl v0.19.5 h1:rGA3hOrgNxgRM5wYcSCxgQBap7fW82WZgY78V9po/iY= github.com/cosmos/iavl v0.19.5/go.mod h1:X9PKD3J0iFxdmgNLa7b2LYWdsGd90ToV5cAONApkEPw= github.com/cosmos/ibc-go/v4 v4.5.1 h1:+P73X7aIikGAXBUJ9vP9rEbvdSuekt3KGXmAWCSYets= github.com/cosmos/ibc-go/v4 v4.5.1/go.mod h1:2EOi40Bx/j6rJrtP1ui8k8yUAMpGybmL1EjakYqYv5U= +github.com/cosmos/ibc-go/v4 v4.6.0 h1:G7kiD4Zf8Wrxc8BXWIKuFnzI0W4wpvRPrl5HwdfTIsA= +github.com/cosmos/ibc-go/v4 v4.6.0/go.mod h1:ksiZHUypws0NVP50E3ea0ivVFO/bfS8q8yLg8yZ2ATQ= github.com/cosmos/keyring v1.2.0 h1:8C1lBP9xhImmIabyXW4c3vFjjLiBdGCmfLUfeZlV1Yo= github.com/cosmos/keyring v1.2.0/go.mod h1:fc+wB5KTk9wQ9sDx0kFXB3A0MaeGHM9AwRStKOQ5vOA= github.com/cosmos/ledger-cosmos-go v0.12.2 h1:/XYaBlE2BJxtvpkHiBm97gFGSGmYGKunKyF3nNqAXZA= @@ -492,6 +496,7 @@ github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4er github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= +github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= @@ -499,6 +504,7 @@ github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= +github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.0/go.mod h1:Qd/q+1AKNOZr9uGQzbzCmRO6sUih6GTPZv6a1/R87v0= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= @@ -648,6 +654,7 @@ github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brv github.com/hashicorp/go-bexpr v0.1.10/go.mod h1:oxlubA2vC/gFVfX1A6JGp7ls7uCDlfJn732ehYYg+g0= github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= +github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48= github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= github.com/hashicorp/go-immutable-radix v1.3.1 h1:DKHmCUm2hRBK510BaiZlwvpD40f8bJFeZnpfm2KLowc= github.com/hashicorp/go-immutable-radix v1.3.1/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= @@ -657,6 +664,7 @@ github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+l github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= github.com/hashicorp/go-retryablehttp v0.5.3/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs= github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU= +github.com/hashicorp/go-rootcerts v1.0.2/go.mod h1:pqUvnprVnM5bf7AOirdbb01K4ccR319Vf4pU3K5EGc8= github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU= github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4= github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= @@ -1314,6 +1322,7 @@ go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= +go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= @@ -1321,6 +1330,7 @@ go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/atomic v1.10.0 h1:9qC72Qh0+3MqyJbAn8YU5xVq1frD8bn3JtD2oXtafVQ= go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= go.uber.org/goleak v1.1.11 h1:wy28qYRKZgnJTxGxvye5/wgWr1EKjmUDGYox5mGlRlI= +go.uber.org/goleak v1.1.11/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4= go.uber.org/multierr v1.8.0 h1:dg6GjLku4EH+249NNmoIciG9N/jURbDG+pFlTkhzIC8= From f11f7a3c6ae5ddb8bc84df50ff76acce2d046793 Mon Sep 17 00:00:00 2001 From: faneaatiku Date: Thu, 18 Apr 2024 23:15:14 +0300 Subject: [PATCH 29/35] added events for rewards module --- go.sum | 10 - proto/rewards/events.proto | 64 + .../bze-alphateam/bze/bze.v1.rewards/index.ts | 92 +- .../bze/bze.v1.rewards/module/index.ts | 18 +- .../module/types/rewards/events.ts | 1262 +++++++ x/rewards/keeper/cleanup.go | 10 + x/rewards/keeper/gov.go | 10 + .../msg_server_claim_staking_rewards.go | 12 + x/rewards/keeper/msg_server_exit_staking.go | 20 + x/rewards/keeper/msg_server_join_staking.go | 12 + x/rewards/keeper/msg_server_staking_reward.go | 27 + x/rewards/keeper/msg_server_trading_reward.go | 16 + .../keeper/staking_reward_distribution.go | 15 +- .../keeper/trading_reward_distribution.go | 15 + x/rewards/types/events.pb.go | 3050 ++++++++++++++++- 15 files changed, 4556 insertions(+), 77 deletions(-) diff --git a/go.sum b/go.sum index 3ed3026a..0b9bbbdd 100644 --- a/go.sum +++ b/go.sum @@ -154,7 +154,6 @@ github.com/aymerick/douceur v0.2.0 h1:Mv+mAeH1Q+n9Fr+oyamOlAkUNPWPlA8PPGR0QAaYuP github.com/aymerick/douceur v0.2.0/go.mod h1:wlT5vV2O3h55X9m7iVYN0TBM0NH/MmbLnd30/FjWUq4= github.com/aymerick/raymond v2.0.3-0.20180322193309-b565731e1464+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g= github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= -github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= @@ -262,7 +261,6 @@ github.com/containerd/continuity v0.3.0 h1:nisirsYROK15TAMVukJOUyGJjz4BNQJBVsNvA github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE= github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk= github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= -github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= github.com/coreos/go-systemd v0.0.0-20180511133405-39ca1b05acc7/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4= github.com/coreos/go-systemd/v22 v22.3.3-0.20220203105225-a9a7ef127534/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= @@ -281,8 +279,6 @@ github.com/cosmos/gorocksdb v1.2.0 h1:d0l3jJG8M4hBouIZq0mDUHZ+zjOx044J3nGRskwTb4 github.com/cosmos/gorocksdb v1.2.0/go.mod h1:aaKvKItm514hKfNJpUJXnnOWeBnk2GL4+Qw9NHizILw= github.com/cosmos/iavl v0.19.5 h1:rGA3hOrgNxgRM5wYcSCxgQBap7fW82WZgY78V9po/iY= github.com/cosmos/iavl v0.19.5/go.mod h1:X9PKD3J0iFxdmgNLa7b2LYWdsGd90ToV5cAONApkEPw= -github.com/cosmos/ibc-go/v4 v4.5.1 h1:+P73X7aIikGAXBUJ9vP9rEbvdSuekt3KGXmAWCSYets= -github.com/cosmos/ibc-go/v4 v4.5.1/go.mod h1:2EOi40Bx/j6rJrtP1ui8k8yUAMpGybmL1EjakYqYv5U= github.com/cosmos/ibc-go/v4 v4.6.0 h1:G7kiD4Zf8Wrxc8BXWIKuFnzI0W4wpvRPrl5HwdfTIsA= github.com/cosmos/ibc-go/v4 v4.6.0/go.mod h1:ksiZHUypws0NVP50E3ea0ivVFO/bfS8q8yLg8yZ2ATQ= github.com/cosmos/keyring v1.2.0 h1:8C1lBP9xhImmIabyXW4c3vFjjLiBdGCmfLUfeZlV1Yo= @@ -496,7 +492,6 @@ github.com/golang/groupcache v0.0.0-20160516000752-02826c3e7903/go.mod h1:cIg4er github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= @@ -504,7 +499,6 @@ github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= -github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.0/go.mod h1:Qd/q+1AKNOZr9uGQzbzCmRO6sUih6GTPZv6a1/R87v0= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= @@ -654,7 +648,6 @@ github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brv github.com/hashicorp/go-bexpr v0.1.10/go.mod h1:oxlubA2vC/gFVfX1A6JGp7ls7uCDlfJn732ehYYg+g0= github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= -github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48= github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= github.com/hashicorp/go-immutable-radix v1.3.1 h1:DKHmCUm2hRBK510BaiZlwvpD40f8bJFeZnpfm2KLowc= github.com/hashicorp/go-immutable-radix v1.3.1/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= @@ -664,7 +657,6 @@ github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+l github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= github.com/hashicorp/go-retryablehttp v0.5.3/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs= github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU= -github.com/hashicorp/go-rootcerts v1.0.2/go.mod h1:pqUvnprVnM5bf7AOirdbb01K4ccR319Vf4pU3K5EGc8= github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU= github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4= github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= @@ -1322,7 +1314,6 @@ go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= -go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE= go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ= @@ -1330,7 +1321,6 @@ go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/atomic v1.10.0 h1:9qC72Qh0+3MqyJbAn8YU5xVq1frD8bn3JtD2oXtafVQ= go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= go.uber.org/goleak v1.1.11 h1:wy28qYRKZgnJTxGxvye5/wgWr1EKjmUDGYox5mGlRlI= -go.uber.org/goleak v1.1.11/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0= go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4= go.uber.org/multierr v1.8.0 h1:dg6GjLku4EH+249NNmoIciG9N/jURbDG+pFlTkhzIC8= diff --git a/proto/rewards/events.proto b/proto/rewards/events.proto index 7337c04b..c4ecad15 100644 --- a/proto/rewards/events.proto +++ b/proto/rewards/events.proto @@ -5,4 +5,68 @@ import "gogoproto/gogo.proto"; option go_package = "github.com/bze-alphateam/bze/x/rewards/types"; +message StakingRewardCreateEvent { + string reward_id = 1; + string prize_amount = 2; + string prize_denom = 3; + string staking_denom = 4; + uint32 duration = 5; + uint64 min_stake = 6; + uint32 lock = 7; +} +message StakingRewardUpdateEvent { + string reward_id = 1; + uint32 duration = 2; +} + +message StakingRewardClaimEvent { + string reward_id = 1; + string address = 2; + string amount = 3; +} + +message StakingRewardJoinEvent { + string reward_id = 1; + string address = 2; + string amount = 3; +} + +message StakingRewardExitEvent { + string reward_id = 1; + string address = 2; +} + +message StakingRewardFinishEvent { + string reward_id = 1; +} + +message StakingRewardDistributionEvent { + string reward_id = 1; + string amount = 2; +} + +message TradingRewardCreateEvent { + string reward_id = 1; + string prize_amount = 2; //the amount paid as prize for each slot + string prize_denom = 3; //the denom paid as prize + uint32 duration = 4; + string market_id = 5; + uint32 slots = 6; + string creator = 7; +} + +message TradingRewardExpireEvent { + string reward_id = 1; +} + +message TradingRewardActivationEvent { + string reward_id = 1; +} + +message TradingRewardDistributionEvent { + string reward_id = 1; + string prize_amount = 2; + string prize_denom = 3; + repeated string winners = 4; +} diff --git a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/index.ts b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/index.ts index 5d4200d4..d01443e2 100755 --- a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/index.ts +++ b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/index.ts @@ -407,6 +407,21 @@ export default { }, + async sendMsgClaimStakingRewards({ rootGetters }, { value, fee = [], memo = '' }) { + try { + const txClient=await initTxClient(rootGetters) + const msg = await txClient.msgClaimStakingRewards(value) + const result = await txClient.signAndBroadcast([msg], {fee: { amount: fee, + gas: "200000" }, memo}) + return result + } catch (e) { + if (e == MissingWalletError) { + throw new Error('TxClient:MsgClaimStakingRewards:Init Could not initialize signing client. Wallet is required.') + }else{ + throw new Error('TxClient:MsgClaimStakingRewards:Send Could not broadcast Tx: '+ e.message) + } + } + }, async sendMsgCreateTradingReward({ rootGetters }, { value, fee = [], memo = '' }) { try { const txClient=await initTxClient(rootGetters) @@ -422,33 +437,33 @@ export default { } } }, - async sendMsgExitStaking({ rootGetters }, { value, fee = [], memo = '' }) { + async sendMsgJoinStaking({ rootGetters }, { value, fee = [], memo = '' }) { try { const txClient=await initTxClient(rootGetters) - const msg = await txClient.msgExitStaking(value) + const msg = await txClient.msgJoinStaking(value) const result = await txClient.signAndBroadcast([msg], {fee: { amount: fee, gas: "200000" }, memo}) return result } catch (e) { if (e == MissingWalletError) { - throw new Error('TxClient:MsgExitStaking:Init Could not initialize signing client. Wallet is required.') + throw new Error('TxClient:MsgJoinStaking:Init Could not initialize signing client. Wallet is required.') }else{ - throw new Error('TxClient:MsgExitStaking:Send Could not broadcast Tx: '+ e.message) + throw new Error('TxClient:MsgJoinStaking:Send Could not broadcast Tx: '+ e.message) } } }, - async sendMsgClaimStakingRewards({ rootGetters }, { value, fee = [], memo = '' }) { + async sendMsgCreateStakingReward({ rootGetters }, { value, fee = [], memo = '' }) { try { const txClient=await initTxClient(rootGetters) - const msg = await txClient.msgClaimStakingRewards(value) + const msg = await txClient.msgCreateStakingReward(value) const result = await txClient.signAndBroadcast([msg], {fee: { amount: fee, gas: "200000" }, memo}) return result } catch (e) { if (e == MissingWalletError) { - throw new Error('TxClient:MsgClaimStakingRewards:Init Could not initialize signing client. Wallet is required.') + throw new Error('TxClient:MsgCreateStakingReward:Init Could not initialize signing client. Wallet is required.') }else{ - throw new Error('TxClient:MsgClaimStakingRewards:Send Could not broadcast Tx: '+ e.message) + throw new Error('TxClient:MsgCreateStakingReward:Send Could not broadcast Tx: '+ e.message) } } }, @@ -467,37 +482,35 @@ export default { } } }, - async sendMsgJoinStaking({ rootGetters }, { value, fee = [], memo = '' }) { + async sendMsgExitStaking({ rootGetters }, { value, fee = [], memo = '' }) { try { const txClient=await initTxClient(rootGetters) - const msg = await txClient.msgJoinStaking(value) + const msg = await txClient.msgExitStaking(value) const result = await txClient.signAndBroadcast([msg], {fee: { amount: fee, gas: "200000" }, memo}) return result } catch (e) { if (e == MissingWalletError) { - throw new Error('TxClient:MsgJoinStaking:Init Could not initialize signing client. Wallet is required.') + throw new Error('TxClient:MsgExitStaking:Init Could not initialize signing client. Wallet is required.') }else{ - throw new Error('TxClient:MsgJoinStaking:Send Could not broadcast Tx: '+ e.message) + throw new Error('TxClient:MsgExitStaking:Send Could not broadcast Tx: '+ e.message) } } }, - async sendMsgCreateStakingReward({ rootGetters }, { value, fee = [], memo = '' }) { + + async MsgClaimStakingRewards({ rootGetters }, { value }) { try { const txClient=await initTxClient(rootGetters) - const msg = await txClient.msgCreateStakingReward(value) - const result = await txClient.signAndBroadcast([msg], {fee: { amount: fee, - gas: "200000" }, memo}) - return result + const msg = await txClient.msgClaimStakingRewards(value) + return msg } catch (e) { if (e == MissingWalletError) { - throw new Error('TxClient:MsgCreateStakingReward:Init Could not initialize signing client. Wallet is required.') - }else{ - throw new Error('TxClient:MsgCreateStakingReward:Send Could not broadcast Tx: '+ e.message) + throw new Error('TxClient:MsgClaimStakingRewards:Init Could not initialize signing client. Wallet is required.') + } else{ + throw new Error('TxClient:MsgClaimStakingRewards:Create Could not create message: ' + e.message) } } }, - async MsgCreateTradingReward({ rootGetters }, { value }) { try { const txClient=await initTxClient(rootGetters) @@ -511,29 +524,29 @@ export default { } } }, - async MsgExitStaking({ rootGetters }, { value }) { + async MsgJoinStaking({ rootGetters }, { value }) { try { const txClient=await initTxClient(rootGetters) - const msg = await txClient.msgExitStaking(value) + const msg = await txClient.msgJoinStaking(value) return msg } catch (e) { if (e == MissingWalletError) { - throw new Error('TxClient:MsgExitStaking:Init Could not initialize signing client. Wallet is required.') + throw new Error('TxClient:MsgJoinStaking:Init Could not initialize signing client. Wallet is required.') } else{ - throw new Error('TxClient:MsgExitStaking:Create Could not create message: ' + e.message) + throw new Error('TxClient:MsgJoinStaking:Create Could not create message: ' + e.message) } } }, - async MsgClaimStakingRewards({ rootGetters }, { value }) { + async MsgCreateStakingReward({ rootGetters }, { value }) { try { const txClient=await initTxClient(rootGetters) - const msg = await txClient.msgClaimStakingRewards(value) + const msg = await txClient.msgCreateStakingReward(value) return msg } catch (e) { if (e == MissingWalletError) { - throw new Error('TxClient:MsgClaimStakingRewards:Init Could not initialize signing client. Wallet is required.') + throw new Error('TxClient:MsgCreateStakingReward:Init Could not initialize signing client. Wallet is required.') } else{ - throw new Error('TxClient:MsgClaimStakingRewards:Create Could not create message: ' + e.message) + throw new Error('TxClient:MsgCreateStakingReward:Create Could not create message: ' + e.message) } } }, @@ -550,29 +563,16 @@ export default { } } }, - async MsgJoinStaking({ rootGetters }, { value }) { - try { - const txClient=await initTxClient(rootGetters) - const msg = await txClient.msgJoinStaking(value) - return msg - } catch (e) { - if (e == MissingWalletError) { - throw new Error('TxClient:MsgJoinStaking:Init Could not initialize signing client. Wallet is required.') - } else{ - throw new Error('TxClient:MsgJoinStaking:Create Could not create message: ' + e.message) - } - } - }, - async MsgCreateStakingReward({ rootGetters }, { value }) { + async MsgExitStaking({ rootGetters }, { value }) { try { const txClient=await initTxClient(rootGetters) - const msg = await txClient.msgCreateStakingReward(value) + const msg = await txClient.msgExitStaking(value) return msg } catch (e) { if (e == MissingWalletError) { - throw new Error('TxClient:MsgCreateStakingReward:Init Could not initialize signing client. Wallet is required.') + throw new Error('TxClient:MsgExitStaking:Init Could not initialize signing client. Wallet is required.') } else{ - throw new Error('TxClient:MsgCreateStakingReward:Create Could not create message: ' + e.message) + throw new Error('TxClient:MsgExitStaking:Create Could not create message: ' + e.message) } } }, diff --git a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/index.ts b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/index.ts index b4d29687..abad584e 100755 --- a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/index.ts +++ b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/index.ts @@ -4,21 +4,21 @@ import { StdFee } from "@cosmjs/launchpad"; import { SigningStargateClient } from "@cosmjs/stargate"; import { Registry, OfflineSigner, EncodeObject, DirectSecp256k1HdWallet } from "@cosmjs/proto-signing"; import { Api } from "./rest"; -import { MsgCreateTradingReward } from "./types/rewards/tx"; -import { MsgExitStaking } from "./types/rewards/tx"; import { MsgClaimStakingRewards } from "./types/rewards/tx"; -import { MsgUpdateStakingReward } from "./types/rewards/tx"; +import { MsgCreateTradingReward } from "./types/rewards/tx"; import { MsgJoinStaking } from "./types/rewards/tx"; import { MsgCreateStakingReward } from "./types/rewards/tx"; +import { MsgUpdateStakingReward } from "./types/rewards/tx"; +import { MsgExitStaking } from "./types/rewards/tx"; const types = [ - ["/bze.v1.rewards.MsgCreateTradingReward", MsgCreateTradingReward], - ["/bze.v1.rewards.MsgExitStaking", MsgExitStaking], ["/bze.v1.rewards.MsgClaimStakingRewards", MsgClaimStakingRewards], - ["/bze.v1.rewards.MsgUpdateStakingReward", MsgUpdateStakingReward], + ["/bze.v1.rewards.MsgCreateTradingReward", MsgCreateTradingReward], ["/bze.v1.rewards.MsgJoinStaking", MsgJoinStaking], ["/bze.v1.rewards.MsgCreateStakingReward", MsgCreateStakingReward], + ["/bze.v1.rewards.MsgUpdateStakingReward", MsgUpdateStakingReward], + ["/bze.v1.rewards.MsgExitStaking", MsgExitStaking], ]; export const MissingWalletError = new Error("wallet is required"); @@ -51,12 +51,12 @@ const txClient = async (wallet: OfflineSigner, { addr: addr }: TxClientOptions = return { signAndBroadcast: (msgs: EncodeObject[], { fee, memo }: SignAndBroadcastOptions = {fee: defaultFee, memo: ""}) => client.signAndBroadcast(address, msgs, fee,memo), - msgCreateTradingReward: (data: MsgCreateTradingReward): EncodeObject => ({ typeUrl: "/bze.v1.rewards.MsgCreateTradingReward", value: MsgCreateTradingReward.fromPartial( data ) }), - msgExitStaking: (data: MsgExitStaking): EncodeObject => ({ typeUrl: "/bze.v1.rewards.MsgExitStaking", value: MsgExitStaking.fromPartial( data ) }), msgClaimStakingRewards: (data: MsgClaimStakingRewards): EncodeObject => ({ typeUrl: "/bze.v1.rewards.MsgClaimStakingRewards", value: MsgClaimStakingRewards.fromPartial( data ) }), - msgUpdateStakingReward: (data: MsgUpdateStakingReward): EncodeObject => ({ typeUrl: "/bze.v1.rewards.MsgUpdateStakingReward", value: MsgUpdateStakingReward.fromPartial( data ) }), + msgCreateTradingReward: (data: MsgCreateTradingReward): EncodeObject => ({ typeUrl: "/bze.v1.rewards.MsgCreateTradingReward", value: MsgCreateTradingReward.fromPartial( data ) }), msgJoinStaking: (data: MsgJoinStaking): EncodeObject => ({ typeUrl: "/bze.v1.rewards.MsgJoinStaking", value: MsgJoinStaking.fromPartial( data ) }), msgCreateStakingReward: (data: MsgCreateStakingReward): EncodeObject => ({ typeUrl: "/bze.v1.rewards.MsgCreateStakingReward", value: MsgCreateStakingReward.fromPartial( data ) }), + msgUpdateStakingReward: (data: MsgUpdateStakingReward): EncodeObject => ({ typeUrl: "/bze.v1.rewards.MsgUpdateStakingReward", value: MsgUpdateStakingReward.fromPartial( data ) }), + msgExitStaking: (data: MsgExitStaking): EncodeObject => ({ typeUrl: "/bze.v1.rewards.MsgExitStaking", value: MsgExitStaking.fromPartial( data ) }), }; }; diff --git a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/events.ts b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/events.ts index 069fc0b6..b13693e9 100644 --- a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/events.ts +++ b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/events.ts @@ -1,2 +1,1264 @@ /* eslint-disable */ +import * as Long from "long"; +import { util, configure, Writer, Reader } from "protobufjs/minimal"; + export const protobufPackage = "bze.rewards.v1"; + +export interface StakingRewardCreateEvent { + reward_id: string; + prize_amount: string; + prize_denom: string; + staking_denom: string; + duration: number; + min_stake: number; + lock: number; +} + +export interface StakingRewardUpdateEvent { + reward_id: string; + duration: number; +} + +export interface StakingRewardClaimEvent { + reward_id: string; + address: string; + amount: string; +} + +export interface StakingRewardJoinEvent { + reward_id: string; + address: string; + amount: string; +} + +export interface StakingRewardExitEvent { + reward_id: string; + address: string; +} + +export interface StakingRewardFinishEvent { + reward_id: string; +} + +export interface StakingRewardDistributionEvent { + reward_id: string; + amount: string; +} + +export interface TradingRewardCreateEvent { + reward_id: string; + /** the amount paid as prize for each slot */ + prize_amount: string; + /** the denom paid as prize */ + prize_denom: string; + duration: number; + market_id: string; + slots: number; + creator: string; +} + +export interface TradingRewardExpireEvent { + reward_id: string; +} + +export interface TradingRewardActivationEvent { + reward_id: string; +} + +export interface TradingRewardDistributionEvent { + reward_id: string; + prize_amount: string; + prize_denom: string; + winners: string[]; +} + +const baseStakingRewardCreateEvent: object = { + reward_id: "", + prize_amount: "", + prize_denom: "", + staking_denom: "", + duration: 0, + min_stake: 0, + lock: 0, +}; + +export const StakingRewardCreateEvent = { + encode( + message: StakingRewardCreateEvent, + writer: Writer = Writer.create() + ): Writer { + if (message.reward_id !== "") { + writer.uint32(10).string(message.reward_id); + } + if (message.prize_amount !== "") { + writer.uint32(18).string(message.prize_amount); + } + if (message.prize_denom !== "") { + writer.uint32(26).string(message.prize_denom); + } + if (message.staking_denom !== "") { + writer.uint32(34).string(message.staking_denom); + } + if (message.duration !== 0) { + writer.uint32(40).uint32(message.duration); + } + if (message.min_stake !== 0) { + writer.uint32(48).uint64(message.min_stake); + } + if (message.lock !== 0) { + writer.uint32(56).uint32(message.lock); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): StakingRewardCreateEvent { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseStakingRewardCreateEvent, + } as StakingRewardCreateEvent; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.reward_id = reader.string(); + break; + case 2: + message.prize_amount = reader.string(); + break; + case 3: + message.prize_denom = reader.string(); + break; + case 4: + message.staking_denom = reader.string(); + break; + case 5: + message.duration = reader.uint32(); + break; + case 6: + message.min_stake = longToNumber(reader.uint64() as Long); + break; + case 7: + message.lock = reader.uint32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): StakingRewardCreateEvent { + const message = { + ...baseStakingRewardCreateEvent, + } as StakingRewardCreateEvent; + if (object.reward_id !== undefined && object.reward_id !== null) { + message.reward_id = String(object.reward_id); + } else { + message.reward_id = ""; + } + if (object.prize_amount !== undefined && object.prize_amount !== null) { + message.prize_amount = String(object.prize_amount); + } else { + message.prize_amount = ""; + } + if (object.prize_denom !== undefined && object.prize_denom !== null) { + message.prize_denom = String(object.prize_denom); + } else { + message.prize_denom = ""; + } + if (object.staking_denom !== undefined && object.staking_denom !== null) { + message.staking_denom = String(object.staking_denom); + } else { + message.staking_denom = ""; + } + if (object.duration !== undefined && object.duration !== null) { + message.duration = Number(object.duration); + } else { + message.duration = 0; + } + if (object.min_stake !== undefined && object.min_stake !== null) { + message.min_stake = Number(object.min_stake); + } else { + message.min_stake = 0; + } + if (object.lock !== undefined && object.lock !== null) { + message.lock = Number(object.lock); + } else { + message.lock = 0; + } + return message; + }, + + toJSON(message: StakingRewardCreateEvent): unknown { + const obj: any = {}; + message.reward_id !== undefined && (obj.reward_id = message.reward_id); + message.prize_amount !== undefined && + (obj.prize_amount = message.prize_amount); + message.prize_denom !== undefined && + (obj.prize_denom = message.prize_denom); + message.staking_denom !== undefined && + (obj.staking_denom = message.staking_denom); + message.duration !== undefined && (obj.duration = message.duration); + message.min_stake !== undefined && (obj.min_stake = message.min_stake); + message.lock !== undefined && (obj.lock = message.lock); + return obj; + }, + + fromPartial( + object: DeepPartial + ): StakingRewardCreateEvent { + const message = { + ...baseStakingRewardCreateEvent, + } as StakingRewardCreateEvent; + if (object.reward_id !== undefined && object.reward_id !== null) { + message.reward_id = object.reward_id; + } else { + message.reward_id = ""; + } + if (object.prize_amount !== undefined && object.prize_amount !== null) { + message.prize_amount = object.prize_amount; + } else { + message.prize_amount = ""; + } + if (object.prize_denom !== undefined && object.prize_denom !== null) { + message.prize_denom = object.prize_denom; + } else { + message.prize_denom = ""; + } + if (object.staking_denom !== undefined && object.staking_denom !== null) { + message.staking_denom = object.staking_denom; + } else { + message.staking_denom = ""; + } + if (object.duration !== undefined && object.duration !== null) { + message.duration = object.duration; + } else { + message.duration = 0; + } + if (object.min_stake !== undefined && object.min_stake !== null) { + message.min_stake = object.min_stake; + } else { + message.min_stake = 0; + } + if (object.lock !== undefined && object.lock !== null) { + message.lock = object.lock; + } else { + message.lock = 0; + } + return message; + }, +}; + +const baseStakingRewardUpdateEvent: object = { reward_id: "", duration: 0 }; + +export const StakingRewardUpdateEvent = { + encode( + message: StakingRewardUpdateEvent, + writer: Writer = Writer.create() + ): Writer { + if (message.reward_id !== "") { + writer.uint32(10).string(message.reward_id); + } + if (message.duration !== 0) { + writer.uint32(16).uint32(message.duration); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): StakingRewardUpdateEvent { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseStakingRewardUpdateEvent, + } as StakingRewardUpdateEvent; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.reward_id = reader.string(); + break; + case 2: + message.duration = reader.uint32(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): StakingRewardUpdateEvent { + const message = { + ...baseStakingRewardUpdateEvent, + } as StakingRewardUpdateEvent; + if (object.reward_id !== undefined && object.reward_id !== null) { + message.reward_id = String(object.reward_id); + } else { + message.reward_id = ""; + } + if (object.duration !== undefined && object.duration !== null) { + message.duration = Number(object.duration); + } else { + message.duration = 0; + } + return message; + }, + + toJSON(message: StakingRewardUpdateEvent): unknown { + const obj: any = {}; + message.reward_id !== undefined && (obj.reward_id = message.reward_id); + message.duration !== undefined && (obj.duration = message.duration); + return obj; + }, + + fromPartial( + object: DeepPartial + ): StakingRewardUpdateEvent { + const message = { + ...baseStakingRewardUpdateEvent, + } as StakingRewardUpdateEvent; + if (object.reward_id !== undefined && object.reward_id !== null) { + message.reward_id = object.reward_id; + } else { + message.reward_id = ""; + } + if (object.duration !== undefined && object.duration !== null) { + message.duration = object.duration; + } else { + message.duration = 0; + } + return message; + }, +}; + +const baseStakingRewardClaimEvent: object = { + reward_id: "", + address: "", + amount: "", +}; + +export const StakingRewardClaimEvent = { + encode( + message: StakingRewardClaimEvent, + writer: Writer = Writer.create() + ): Writer { + if (message.reward_id !== "") { + writer.uint32(10).string(message.reward_id); + } + if (message.address !== "") { + writer.uint32(18).string(message.address); + } + if (message.amount !== "") { + writer.uint32(26).string(message.amount); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): StakingRewardClaimEvent { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseStakingRewardClaimEvent, + } as StakingRewardClaimEvent; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.reward_id = reader.string(); + break; + case 2: + message.address = reader.string(); + break; + case 3: + message.amount = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): StakingRewardClaimEvent { + const message = { + ...baseStakingRewardClaimEvent, + } as StakingRewardClaimEvent; + if (object.reward_id !== undefined && object.reward_id !== null) { + message.reward_id = String(object.reward_id); + } else { + message.reward_id = ""; + } + if (object.address !== undefined && object.address !== null) { + message.address = String(object.address); + } else { + message.address = ""; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = String(object.amount); + } else { + message.amount = ""; + } + return message; + }, + + toJSON(message: StakingRewardClaimEvent): unknown { + const obj: any = {}; + message.reward_id !== undefined && (obj.reward_id = message.reward_id); + message.address !== undefined && (obj.address = message.address); + message.amount !== undefined && (obj.amount = message.amount); + return obj; + }, + + fromPartial( + object: DeepPartial + ): StakingRewardClaimEvent { + const message = { + ...baseStakingRewardClaimEvent, + } as StakingRewardClaimEvent; + if (object.reward_id !== undefined && object.reward_id !== null) { + message.reward_id = object.reward_id; + } else { + message.reward_id = ""; + } + if (object.address !== undefined && object.address !== null) { + message.address = object.address; + } else { + message.address = ""; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = object.amount; + } else { + message.amount = ""; + } + return message; + }, +}; + +const baseStakingRewardJoinEvent: object = { + reward_id: "", + address: "", + amount: "", +}; + +export const StakingRewardJoinEvent = { + encode( + message: StakingRewardJoinEvent, + writer: Writer = Writer.create() + ): Writer { + if (message.reward_id !== "") { + writer.uint32(10).string(message.reward_id); + } + if (message.address !== "") { + writer.uint32(18).string(message.address); + } + if (message.amount !== "") { + writer.uint32(26).string(message.amount); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): StakingRewardJoinEvent { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseStakingRewardJoinEvent } as StakingRewardJoinEvent; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.reward_id = reader.string(); + break; + case 2: + message.address = reader.string(); + break; + case 3: + message.amount = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): StakingRewardJoinEvent { + const message = { ...baseStakingRewardJoinEvent } as StakingRewardJoinEvent; + if (object.reward_id !== undefined && object.reward_id !== null) { + message.reward_id = String(object.reward_id); + } else { + message.reward_id = ""; + } + if (object.address !== undefined && object.address !== null) { + message.address = String(object.address); + } else { + message.address = ""; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = String(object.amount); + } else { + message.amount = ""; + } + return message; + }, + + toJSON(message: StakingRewardJoinEvent): unknown { + const obj: any = {}; + message.reward_id !== undefined && (obj.reward_id = message.reward_id); + message.address !== undefined && (obj.address = message.address); + message.amount !== undefined && (obj.amount = message.amount); + return obj; + }, + + fromPartial( + object: DeepPartial + ): StakingRewardJoinEvent { + const message = { ...baseStakingRewardJoinEvent } as StakingRewardJoinEvent; + if (object.reward_id !== undefined && object.reward_id !== null) { + message.reward_id = object.reward_id; + } else { + message.reward_id = ""; + } + if (object.address !== undefined && object.address !== null) { + message.address = object.address; + } else { + message.address = ""; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = object.amount; + } else { + message.amount = ""; + } + return message; + }, +}; + +const baseStakingRewardExitEvent: object = { reward_id: "", address: "" }; + +export const StakingRewardExitEvent = { + encode( + message: StakingRewardExitEvent, + writer: Writer = Writer.create() + ): Writer { + if (message.reward_id !== "") { + writer.uint32(10).string(message.reward_id); + } + if (message.address !== "") { + writer.uint32(18).string(message.address); + } + return writer; + }, + + decode(input: Reader | Uint8Array, length?: number): StakingRewardExitEvent { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { ...baseStakingRewardExitEvent } as StakingRewardExitEvent; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.reward_id = reader.string(); + break; + case 2: + message.address = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): StakingRewardExitEvent { + const message = { ...baseStakingRewardExitEvent } as StakingRewardExitEvent; + if (object.reward_id !== undefined && object.reward_id !== null) { + message.reward_id = String(object.reward_id); + } else { + message.reward_id = ""; + } + if (object.address !== undefined && object.address !== null) { + message.address = String(object.address); + } else { + message.address = ""; + } + return message; + }, + + toJSON(message: StakingRewardExitEvent): unknown { + const obj: any = {}; + message.reward_id !== undefined && (obj.reward_id = message.reward_id); + message.address !== undefined && (obj.address = message.address); + return obj; + }, + + fromPartial( + object: DeepPartial + ): StakingRewardExitEvent { + const message = { ...baseStakingRewardExitEvent } as StakingRewardExitEvent; + if (object.reward_id !== undefined && object.reward_id !== null) { + message.reward_id = object.reward_id; + } else { + message.reward_id = ""; + } + if (object.address !== undefined && object.address !== null) { + message.address = object.address; + } else { + message.address = ""; + } + return message; + }, +}; + +const baseStakingRewardFinishEvent: object = { reward_id: "" }; + +export const StakingRewardFinishEvent = { + encode( + message: StakingRewardFinishEvent, + writer: Writer = Writer.create() + ): Writer { + if (message.reward_id !== "") { + writer.uint32(10).string(message.reward_id); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): StakingRewardFinishEvent { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseStakingRewardFinishEvent, + } as StakingRewardFinishEvent; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.reward_id = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): StakingRewardFinishEvent { + const message = { + ...baseStakingRewardFinishEvent, + } as StakingRewardFinishEvent; + if (object.reward_id !== undefined && object.reward_id !== null) { + message.reward_id = String(object.reward_id); + } else { + message.reward_id = ""; + } + return message; + }, + + toJSON(message: StakingRewardFinishEvent): unknown { + const obj: any = {}; + message.reward_id !== undefined && (obj.reward_id = message.reward_id); + return obj; + }, + + fromPartial( + object: DeepPartial + ): StakingRewardFinishEvent { + const message = { + ...baseStakingRewardFinishEvent, + } as StakingRewardFinishEvent; + if (object.reward_id !== undefined && object.reward_id !== null) { + message.reward_id = object.reward_id; + } else { + message.reward_id = ""; + } + return message; + }, +}; + +const baseStakingRewardDistributionEvent: object = { + reward_id: "", + amount: "", +}; + +export const StakingRewardDistributionEvent = { + encode( + message: StakingRewardDistributionEvent, + writer: Writer = Writer.create() + ): Writer { + if (message.reward_id !== "") { + writer.uint32(10).string(message.reward_id); + } + if (message.amount !== "") { + writer.uint32(18).string(message.amount); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): StakingRewardDistributionEvent { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseStakingRewardDistributionEvent, + } as StakingRewardDistributionEvent; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.reward_id = reader.string(); + break; + case 2: + message.amount = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): StakingRewardDistributionEvent { + const message = { + ...baseStakingRewardDistributionEvent, + } as StakingRewardDistributionEvent; + if (object.reward_id !== undefined && object.reward_id !== null) { + message.reward_id = String(object.reward_id); + } else { + message.reward_id = ""; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = String(object.amount); + } else { + message.amount = ""; + } + return message; + }, + + toJSON(message: StakingRewardDistributionEvent): unknown { + const obj: any = {}; + message.reward_id !== undefined && (obj.reward_id = message.reward_id); + message.amount !== undefined && (obj.amount = message.amount); + return obj; + }, + + fromPartial( + object: DeepPartial + ): StakingRewardDistributionEvent { + const message = { + ...baseStakingRewardDistributionEvent, + } as StakingRewardDistributionEvent; + if (object.reward_id !== undefined && object.reward_id !== null) { + message.reward_id = object.reward_id; + } else { + message.reward_id = ""; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = object.amount; + } else { + message.amount = ""; + } + return message; + }, +}; + +const baseTradingRewardCreateEvent: object = { + reward_id: "", + prize_amount: "", + prize_denom: "", + duration: 0, + market_id: "", + slots: 0, + creator: "", +}; + +export const TradingRewardCreateEvent = { + encode( + message: TradingRewardCreateEvent, + writer: Writer = Writer.create() + ): Writer { + if (message.reward_id !== "") { + writer.uint32(10).string(message.reward_id); + } + if (message.prize_amount !== "") { + writer.uint32(18).string(message.prize_amount); + } + if (message.prize_denom !== "") { + writer.uint32(26).string(message.prize_denom); + } + if (message.duration !== 0) { + writer.uint32(32).uint32(message.duration); + } + if (message.market_id !== "") { + writer.uint32(42).string(message.market_id); + } + if (message.slots !== 0) { + writer.uint32(48).uint32(message.slots); + } + if (message.creator !== "") { + writer.uint32(58).string(message.creator); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): TradingRewardCreateEvent { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseTradingRewardCreateEvent, + } as TradingRewardCreateEvent; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.reward_id = reader.string(); + break; + case 2: + message.prize_amount = reader.string(); + break; + case 3: + message.prize_denom = reader.string(); + break; + case 4: + message.duration = reader.uint32(); + break; + case 5: + message.market_id = reader.string(); + break; + case 6: + message.slots = reader.uint32(); + break; + case 7: + message.creator = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): TradingRewardCreateEvent { + const message = { + ...baseTradingRewardCreateEvent, + } as TradingRewardCreateEvent; + if (object.reward_id !== undefined && object.reward_id !== null) { + message.reward_id = String(object.reward_id); + } else { + message.reward_id = ""; + } + if (object.prize_amount !== undefined && object.prize_amount !== null) { + message.prize_amount = String(object.prize_amount); + } else { + message.prize_amount = ""; + } + if (object.prize_denom !== undefined && object.prize_denom !== null) { + message.prize_denom = String(object.prize_denom); + } else { + message.prize_denom = ""; + } + if (object.duration !== undefined && object.duration !== null) { + message.duration = Number(object.duration); + } else { + message.duration = 0; + } + if (object.market_id !== undefined && object.market_id !== null) { + message.market_id = String(object.market_id); + } else { + message.market_id = ""; + } + if (object.slots !== undefined && object.slots !== null) { + message.slots = Number(object.slots); + } else { + message.slots = 0; + } + if (object.creator !== undefined && object.creator !== null) { + message.creator = String(object.creator); + } else { + message.creator = ""; + } + return message; + }, + + toJSON(message: TradingRewardCreateEvent): unknown { + const obj: any = {}; + message.reward_id !== undefined && (obj.reward_id = message.reward_id); + message.prize_amount !== undefined && + (obj.prize_amount = message.prize_amount); + message.prize_denom !== undefined && + (obj.prize_denom = message.prize_denom); + message.duration !== undefined && (obj.duration = message.duration); + message.market_id !== undefined && (obj.market_id = message.market_id); + message.slots !== undefined && (obj.slots = message.slots); + message.creator !== undefined && (obj.creator = message.creator); + return obj; + }, + + fromPartial( + object: DeepPartial + ): TradingRewardCreateEvent { + const message = { + ...baseTradingRewardCreateEvent, + } as TradingRewardCreateEvent; + if (object.reward_id !== undefined && object.reward_id !== null) { + message.reward_id = object.reward_id; + } else { + message.reward_id = ""; + } + if (object.prize_amount !== undefined && object.prize_amount !== null) { + message.prize_amount = object.prize_amount; + } else { + message.prize_amount = ""; + } + if (object.prize_denom !== undefined && object.prize_denom !== null) { + message.prize_denom = object.prize_denom; + } else { + message.prize_denom = ""; + } + if (object.duration !== undefined && object.duration !== null) { + message.duration = object.duration; + } else { + message.duration = 0; + } + if (object.market_id !== undefined && object.market_id !== null) { + message.market_id = object.market_id; + } else { + message.market_id = ""; + } + if (object.slots !== undefined && object.slots !== null) { + message.slots = object.slots; + } else { + message.slots = 0; + } + if (object.creator !== undefined && object.creator !== null) { + message.creator = object.creator; + } else { + message.creator = ""; + } + return message; + }, +}; + +const baseTradingRewardExpireEvent: object = { reward_id: "" }; + +export const TradingRewardExpireEvent = { + encode( + message: TradingRewardExpireEvent, + writer: Writer = Writer.create() + ): Writer { + if (message.reward_id !== "") { + writer.uint32(10).string(message.reward_id); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): TradingRewardExpireEvent { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseTradingRewardExpireEvent, + } as TradingRewardExpireEvent; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.reward_id = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): TradingRewardExpireEvent { + const message = { + ...baseTradingRewardExpireEvent, + } as TradingRewardExpireEvent; + if (object.reward_id !== undefined && object.reward_id !== null) { + message.reward_id = String(object.reward_id); + } else { + message.reward_id = ""; + } + return message; + }, + + toJSON(message: TradingRewardExpireEvent): unknown { + const obj: any = {}; + message.reward_id !== undefined && (obj.reward_id = message.reward_id); + return obj; + }, + + fromPartial( + object: DeepPartial + ): TradingRewardExpireEvent { + const message = { + ...baseTradingRewardExpireEvent, + } as TradingRewardExpireEvent; + if (object.reward_id !== undefined && object.reward_id !== null) { + message.reward_id = object.reward_id; + } else { + message.reward_id = ""; + } + return message; + }, +}; + +const baseTradingRewardActivationEvent: object = { reward_id: "" }; + +export const TradingRewardActivationEvent = { + encode( + message: TradingRewardActivationEvent, + writer: Writer = Writer.create() + ): Writer { + if (message.reward_id !== "") { + writer.uint32(10).string(message.reward_id); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): TradingRewardActivationEvent { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseTradingRewardActivationEvent, + } as TradingRewardActivationEvent; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.reward_id = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): TradingRewardActivationEvent { + const message = { + ...baseTradingRewardActivationEvent, + } as TradingRewardActivationEvent; + if (object.reward_id !== undefined && object.reward_id !== null) { + message.reward_id = String(object.reward_id); + } else { + message.reward_id = ""; + } + return message; + }, + + toJSON(message: TradingRewardActivationEvent): unknown { + const obj: any = {}; + message.reward_id !== undefined && (obj.reward_id = message.reward_id); + return obj; + }, + + fromPartial( + object: DeepPartial + ): TradingRewardActivationEvent { + const message = { + ...baseTradingRewardActivationEvent, + } as TradingRewardActivationEvent; + if (object.reward_id !== undefined && object.reward_id !== null) { + message.reward_id = object.reward_id; + } else { + message.reward_id = ""; + } + return message; + }, +}; + +const baseTradingRewardDistributionEvent: object = { + reward_id: "", + prize_amount: "", + prize_denom: "", + winners: "", +}; + +export const TradingRewardDistributionEvent = { + encode( + message: TradingRewardDistributionEvent, + writer: Writer = Writer.create() + ): Writer { + if (message.reward_id !== "") { + writer.uint32(10).string(message.reward_id); + } + if (message.prize_amount !== "") { + writer.uint32(18).string(message.prize_amount); + } + if (message.prize_denom !== "") { + writer.uint32(26).string(message.prize_denom); + } + for (const v of message.winners) { + writer.uint32(34).string(v!); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): TradingRewardDistributionEvent { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseTradingRewardDistributionEvent, + } as TradingRewardDistributionEvent; + message.winners = []; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.reward_id = reader.string(); + break; + case 2: + message.prize_amount = reader.string(); + break; + case 3: + message.prize_denom = reader.string(); + break; + case 4: + message.winners.push(reader.string()); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): TradingRewardDistributionEvent { + const message = { + ...baseTradingRewardDistributionEvent, + } as TradingRewardDistributionEvent; + message.winners = []; + if (object.reward_id !== undefined && object.reward_id !== null) { + message.reward_id = String(object.reward_id); + } else { + message.reward_id = ""; + } + if (object.prize_amount !== undefined && object.prize_amount !== null) { + message.prize_amount = String(object.prize_amount); + } else { + message.prize_amount = ""; + } + if (object.prize_denom !== undefined && object.prize_denom !== null) { + message.prize_denom = String(object.prize_denom); + } else { + message.prize_denom = ""; + } + if (object.winners !== undefined && object.winners !== null) { + for (const e of object.winners) { + message.winners.push(String(e)); + } + } + return message; + }, + + toJSON(message: TradingRewardDistributionEvent): unknown { + const obj: any = {}; + message.reward_id !== undefined && (obj.reward_id = message.reward_id); + message.prize_amount !== undefined && + (obj.prize_amount = message.prize_amount); + message.prize_denom !== undefined && + (obj.prize_denom = message.prize_denom); + if (message.winners) { + obj.winners = message.winners.map((e) => e); + } else { + obj.winners = []; + } + return obj; + }, + + fromPartial( + object: DeepPartial + ): TradingRewardDistributionEvent { + const message = { + ...baseTradingRewardDistributionEvent, + } as TradingRewardDistributionEvent; + message.winners = []; + if (object.reward_id !== undefined && object.reward_id !== null) { + message.reward_id = object.reward_id; + } else { + message.reward_id = ""; + } + if (object.prize_amount !== undefined && object.prize_amount !== null) { + message.prize_amount = object.prize_amount; + } else { + message.prize_amount = ""; + } + if (object.prize_denom !== undefined && object.prize_denom !== null) { + message.prize_denom = object.prize_denom; + } else { + message.prize_denom = ""; + } + if (object.winners !== undefined && object.winners !== null) { + for (const e of object.winners) { + message.winners.push(e); + } + } + return message; + }, +}; + +declare var self: any | undefined; +declare var window: any | undefined; +var globalThis: any = (() => { + if (typeof globalThis !== "undefined") return globalThis; + if (typeof self !== "undefined") return self; + if (typeof window !== "undefined") return window; + if (typeof global !== "undefined") return global; + throw "Unable to locate global object"; +})(); + +type Builtin = Date | Function | Uint8Array | string | number | undefined; +export type DeepPartial = T extends Builtin + ? T + : T extends Array + ? Array> + : T extends ReadonlyArray + ? ReadonlyArray> + : T extends {} + ? { [K in keyof T]?: DeepPartial } + : Partial; + +function longToNumber(long: Long): number { + if (long.gt(Number.MAX_SAFE_INTEGER)) { + throw new globalThis.Error("Value is larger than Number.MAX_SAFE_INTEGER"); + } + return long.toNumber(); +} + +if (util.Long !== Long) { + util.Long = Long as any; + configure(); +} diff --git a/x/rewards/keeper/cleanup.go b/x/rewards/keeper/cleanup.go index c34d047f..36348bcb 100644 --- a/x/rewards/keeper/cleanup.go +++ b/x/rewards/keeper/cleanup.go @@ -32,5 +32,15 @@ func (k Keeper) removeExpiredTradingRewards(ctx sdk.Context, epochNumber int64) logger.With("trading_reward", tr, "to_burn", toBurn). Debug("removed expired trading reward and burnt the tokens associated with it") + + err = ctx.EventManager().EmitTypedEvent( + &types.TradingRewardExpireEvent{ + RewardId: exp.RewardId, + }, + ) + + if err != nil { + k.Logger(ctx).Error(err.Error()) + } } } diff --git a/x/rewards/keeper/gov.go b/x/rewards/keeper/gov.go index 912e762a..a0a7af39 100644 --- a/x/rewards/keeper/gov.go +++ b/x/rewards/keeper/gov.go @@ -40,6 +40,16 @@ func (k Keeper) HandleActivateTradingRewardProposal(ctx sdk.Context, proposal *t MarketId: r.MarketId, }) + err := ctx.EventManager().EmitTypedEvent( + &types.TradingRewardActivationEvent{ + RewardId: exp.RewardId, + }, + ) + + if err != nil { + k.Logger(ctx).Error(err.Error()) + } + k.Logger(ctx).Info(fmt.Sprintf("trading reward with id [%s] has been activated", r.RewardId)) return nil diff --git a/x/rewards/keeper/msg_server_claim_staking_rewards.go b/x/rewards/keeper/msg_server_claim_staking_rewards.go index 3ed59b30..0404a087 100644 --- a/x/rewards/keeper/msg_server_claim_staking_rewards.go +++ b/x/rewards/keeper/msg_server_claim_staking_rewards.go @@ -30,5 +30,17 @@ func (k msgServer) ClaimStakingRewards(goCtx context.Context, msg *types.MsgClai k.SetStakingRewardParticipant(ctx, participant) + err = ctx.EventManager().EmitTypedEvent( + &types.StakingRewardClaimEvent{ + RewardId: stakingReward.RewardId, + Address: msg.Creator, + Amount: paid.Amount.String(), + }, + ) + + if err != nil { + k.Logger(ctx).Error(err.Error()) + } + return &types.MsgClaimStakingRewardsResponse{Amount: paid.Amount.String()}, nil } diff --git a/x/rewards/keeper/msg_server_exit_staking.go b/x/rewards/keeper/msg_server_exit_staking.go index afa3e7d4..07ae30c1 100644 --- a/x/rewards/keeper/msg_server_exit_staking.go +++ b/x/rewards/keeper/msg_server_exit_staking.go @@ -49,9 +49,29 @@ func (k msgServer) ExitStaking(goCtx context.Context, msg *types.MsgExitStaking) //if this staking reward is finished (all funds were distributed and payouts executed) we should remove it if stakingReward.Payouts >= stakingReward.Duration { k.RemoveStakingReward(ctx, stakingReward.RewardId) + err = ctx.EventManager().EmitTypedEvent( + &types.StakingRewardFinishEvent{ + RewardId: stakingReward.RewardId, + }, + ) + + if err != nil { + k.Logger(ctx).Error(err.Error()) + } } } + err = ctx.EventManager().EmitTypedEvent( + &types.StakingRewardExitEvent{ + RewardId: stakingReward.RewardId, + Address: msg.Creator, + }, + ) + + if err != nil { + k.Logger(ctx).Error(err.Error()) + } + return &types.MsgExitStakingResponse{}, nil } diff --git a/x/rewards/keeper/msg_server_join_staking.go b/x/rewards/keeper/msg_server_join_staking.go index e0d515e8..c450f38a 100644 --- a/x/rewards/keeper/msg_server_join_staking.go +++ b/x/rewards/keeper/msg_server_join_staking.go @@ -79,6 +79,18 @@ func (k msgServer) JoinStaking(goCtx context.Context, msg *types.MsgJoinStaking) k.SetStakingRewardParticipant(ctx, participant) k.SetStakingReward(ctx, stakingReward) + err = ctx.EventManager().EmitTypedEvent( + &types.StakingRewardJoinEvent{ + RewardId: stakingReward.RewardId, + Address: msg.Creator, + Amount: toCapture.AmountOf(stakingReward.StakingDenom).String(), + }, + ) + + if err != nil { + k.Logger(ctx).Error(err.Error()) + } + return &types.MsgJoinStakingResponse{}, nil } diff --git a/x/rewards/keeper/msg_server_staking_reward.go b/x/rewards/keeper/msg_server_staking_reward.go index 1b5e6373..96aef589 100644 --- a/x/rewards/keeper/msg_server_staking_reward.go +++ b/x/rewards/keeper/msg_server_staking_reward.go @@ -57,6 +57,22 @@ func (k msgServer) CreateStakingReward(goCtx context.Context, msg *types.MsgCrea stakingReward, ) + err = ctx.EventManager().EmitTypedEvent( + &types.StakingRewardCreateEvent{ + RewardId: stakingReward.RewardId, + PrizeAmount: stakingReward.PrizeAmount, + PrizeDenom: stakingReward.PrizeDenom, + StakingDenom: stakingReward.StakingDenom, + Duration: stakingReward.Duration, + MinStake: stakingReward.MinStake, + Lock: stakingReward.Lock, + }, + ) + + if err != nil { + k.Logger(ctx).Error(err.Error()) + } + return &types.MsgCreateStakingRewardResponse{RewardId: stakingReward.RewardId}, nil } @@ -103,5 +119,16 @@ func (k msgServer) UpdateStakingReward(goCtx context.Context, msg *types.MsgUpda stakingReward.Duration += uint32(durationInt) k.SetStakingReward(ctx, stakingReward) + err = ctx.EventManager().EmitTypedEvent( + &types.StakingRewardUpdateEvent{ + RewardId: stakingReward.RewardId, + Duration: stakingReward.Duration, + }, + ) + + if err != nil { + k.Logger(ctx).Error(err.Error()) + } + return &types.MsgUpdateStakingRewardResponse{}, nil } diff --git a/x/rewards/keeper/msg_server_trading_reward.go b/x/rewards/keeper/msg_server_trading_reward.go index 0719f23c..cc1aed2d 100644 --- a/x/rewards/keeper/msg_server_trading_reward.go +++ b/x/rewards/keeper/msg_server_trading_reward.go @@ -75,6 +75,22 @@ func (k msgServer) CreateTradingReward(goCtx context.Context, msg *types.MsgCrea } k.SetPendingTradingRewardExpiration(ctx, exp) + err = ctx.EventManager().EmitTypedEvent( + &types.TradingRewardCreateEvent{ + RewardId: tradingReward.RewardId, + PrizeAmount: tradingReward.PrizeAmount, + PrizeDenom: tradingReward.PrizeDenom, + Duration: tradingReward.Duration, + MarketId: tradingReward.MarketId, + Slots: tradingReward.Slots, + Creator: msg.Creator, + }, + ) + + if err != nil { + k.Logger(ctx).Error(err.Error()) + } + return &types.MsgCreateTradingRewardResponse{RewardId: tradingReward.RewardId}, nil } diff --git a/x/rewards/keeper/staking_reward_distribution.go b/x/rewards/keeper/staking_reward_distribution.go index becd4b58..396f69ed 100644 --- a/x/rewards/keeper/staking_reward_distribution.go +++ b/x/rewards/keeper/staking_reward_distribution.go @@ -22,7 +22,7 @@ func (k Keeper) getDistributeRewardHandler() func(ctx sdk.Context, reward types. return } - err := k.distributeStakingRewards(&sr, sr.PrizeAmount) + err := k.distributeStakingRewards(ctx, &sr, sr.PrizeAmount) if err != nil { logger.Error(err.Error()) stop = false @@ -39,7 +39,7 @@ func (k Keeper) getDistributeRewardHandler() func(ctx sdk.Context, reward types. } } -func (k Keeper) distributeStakingRewards(sr *types.StakingReward, rewardAmount string) error { +func (k Keeper) distributeStakingRewards(ctx sdk.Context, sr *types.StakingReward, rewardAmount string) error { stakedAmount, ok := sdk.NewIntFromString(sr.StakedAmount) if !ok { return fmt.Errorf("could not transform staked amount from storage into int") @@ -67,5 +67,16 @@ func (k Keeper) distributeStakingRewards(sr *types.StakingReward, rewardAmount s sFloat = sFloat.Add(reward.ToDec().Quo(stakedAmount.ToDec())) sr.DistributedStake = sFloat.String() + err = ctx.EventManager().EmitTypedEvent( + &types.StakingRewardDistributionEvent{ + RewardId: sr.RewardId, + Amount: rewardAmount, + }, + ) + + if err != nil { + k.Logger(ctx).Error(err.Error()) + } + return nil } diff --git a/x/rewards/keeper/trading_reward_distribution.go b/x/rewards/keeper/trading_reward_distribution.go index 2f5d15ca..b8aec5ca 100644 --- a/x/rewards/keeper/trading_reward_distribution.go +++ b/x/rewards/keeper/trading_reward_distribution.go @@ -42,6 +42,7 @@ func (k Keeper) distributeTradingRewards(ctx sdk.Context, epochNumber int64) { continue } + var eventWinners []string for _, winner := range leaderboard.List { acc, err := sdk.AccAddressFromBech32(winner.Address) if err != nil { @@ -49,6 +50,7 @@ func (k Keeper) distributeTradingRewards(ctx sdk.Context, epochNumber int64) { } _ = k.bankKeeper.SendCoinsFromModuleToAccount(ctx, types.ModuleName, acc, rewardPerSlot) + eventWinners = append(eventWinners, winner.Address) } //the trading reward is finished. remove the market id @@ -56,6 +58,19 @@ func (k Keeper) distributeTradingRewards(ctx sdk.Context, epochNumber int64) { //extend the expiration of this paid trading reward for another period just to display the winners exp.ExpireAt += oneWeekInHours k.SetActiveTradingRewardExpiration(ctx, exp) + + err = ctx.EventManager().EmitTypedEvent( + &types.TradingRewardDistributionEvent{ + RewardId: exp.RewardId, + PrizeAmount: rewardPerSlot.String(), + PrizeDenom: tr.PrizeDenom, + Winners: eventWinners, + }, + ) + + if err != nil { + k.Logger(ctx).Error(err.Error()) + } } } diff --git a/x/rewards/types/events.pb.go b/x/rewards/types/events.pb.go index 84fc2f8c..9fcd4fb4 100644 --- a/x/rewards/types/events.pb.go +++ b/x/rewards/types/events.pb.go @@ -7,7 +7,9 @@ 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. @@ -21,17 +23,3045 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package +type StakingRewardCreateEvent struct { + RewardId string `protobuf:"bytes,1,opt,name=reward_id,json=rewardId,proto3" json:"reward_id,omitempty"` + PrizeAmount string `protobuf:"bytes,2,opt,name=prize_amount,json=prizeAmount,proto3" json:"prize_amount,omitempty"` + PrizeDenom string `protobuf:"bytes,3,opt,name=prize_denom,json=prizeDenom,proto3" json:"prize_denom,omitempty"` + StakingDenom string `protobuf:"bytes,4,opt,name=staking_denom,json=stakingDenom,proto3" json:"staking_denom,omitempty"` + Duration uint32 `protobuf:"varint,5,opt,name=duration,proto3" json:"duration,omitempty"` + MinStake uint64 `protobuf:"varint,6,opt,name=min_stake,json=minStake,proto3" json:"min_stake,omitempty"` + Lock uint32 `protobuf:"varint,7,opt,name=lock,proto3" json:"lock,omitempty"` +} + +func (m *StakingRewardCreateEvent) Reset() { *m = StakingRewardCreateEvent{} } +func (m *StakingRewardCreateEvent) String() string { return proto.CompactTextString(m) } +func (*StakingRewardCreateEvent) ProtoMessage() {} +func (*StakingRewardCreateEvent) Descriptor() ([]byte, []int) { + return fileDescriptor_d74b3d0352ba8267, []int{0} +} +func (m *StakingRewardCreateEvent) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *StakingRewardCreateEvent) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_StakingRewardCreateEvent.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 *StakingRewardCreateEvent) XXX_Merge(src proto.Message) { + xxx_messageInfo_StakingRewardCreateEvent.Merge(m, src) +} +func (m *StakingRewardCreateEvent) XXX_Size() int { + return m.Size() +} +func (m *StakingRewardCreateEvent) XXX_DiscardUnknown() { + xxx_messageInfo_StakingRewardCreateEvent.DiscardUnknown(m) +} + +var xxx_messageInfo_StakingRewardCreateEvent proto.InternalMessageInfo + +func (m *StakingRewardCreateEvent) GetRewardId() string { + if m != nil { + return m.RewardId + } + return "" +} + +func (m *StakingRewardCreateEvent) GetPrizeAmount() string { + if m != nil { + return m.PrizeAmount + } + return "" +} + +func (m *StakingRewardCreateEvent) GetPrizeDenom() string { + if m != nil { + return m.PrizeDenom + } + return "" +} + +func (m *StakingRewardCreateEvent) GetStakingDenom() string { + if m != nil { + return m.StakingDenom + } + return "" +} + +func (m *StakingRewardCreateEvent) GetDuration() uint32 { + if m != nil { + return m.Duration + } + return 0 +} + +func (m *StakingRewardCreateEvent) GetMinStake() uint64 { + if m != nil { + return m.MinStake + } + return 0 +} + +func (m *StakingRewardCreateEvent) GetLock() uint32 { + if m != nil { + return m.Lock + } + return 0 +} + +type StakingRewardUpdateEvent struct { + RewardId string `protobuf:"bytes,1,opt,name=reward_id,json=rewardId,proto3" json:"reward_id,omitempty"` + Duration uint32 `protobuf:"varint,2,opt,name=duration,proto3" json:"duration,omitempty"` +} + +func (m *StakingRewardUpdateEvent) Reset() { *m = StakingRewardUpdateEvent{} } +func (m *StakingRewardUpdateEvent) String() string { return proto.CompactTextString(m) } +func (*StakingRewardUpdateEvent) ProtoMessage() {} +func (*StakingRewardUpdateEvent) Descriptor() ([]byte, []int) { + return fileDescriptor_d74b3d0352ba8267, []int{1} +} +func (m *StakingRewardUpdateEvent) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *StakingRewardUpdateEvent) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_StakingRewardUpdateEvent.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 *StakingRewardUpdateEvent) XXX_Merge(src proto.Message) { + xxx_messageInfo_StakingRewardUpdateEvent.Merge(m, src) +} +func (m *StakingRewardUpdateEvent) XXX_Size() int { + return m.Size() +} +func (m *StakingRewardUpdateEvent) XXX_DiscardUnknown() { + xxx_messageInfo_StakingRewardUpdateEvent.DiscardUnknown(m) +} + +var xxx_messageInfo_StakingRewardUpdateEvent proto.InternalMessageInfo + +func (m *StakingRewardUpdateEvent) GetRewardId() string { + if m != nil { + return m.RewardId + } + return "" +} + +func (m *StakingRewardUpdateEvent) GetDuration() uint32 { + if m != nil { + return m.Duration + } + return 0 +} + +type StakingRewardClaimEvent struct { + RewardId string `protobuf:"bytes,1,opt,name=reward_id,json=rewardId,proto3" json:"reward_id,omitempty"` + Address string `protobuf:"bytes,2,opt,name=address,proto3" json:"address,omitempty"` + Amount string `protobuf:"bytes,3,opt,name=amount,proto3" json:"amount,omitempty"` +} + +func (m *StakingRewardClaimEvent) Reset() { *m = StakingRewardClaimEvent{} } +func (m *StakingRewardClaimEvent) String() string { return proto.CompactTextString(m) } +func (*StakingRewardClaimEvent) ProtoMessage() {} +func (*StakingRewardClaimEvent) Descriptor() ([]byte, []int) { + return fileDescriptor_d74b3d0352ba8267, []int{2} +} +func (m *StakingRewardClaimEvent) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *StakingRewardClaimEvent) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_StakingRewardClaimEvent.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 *StakingRewardClaimEvent) XXX_Merge(src proto.Message) { + xxx_messageInfo_StakingRewardClaimEvent.Merge(m, src) +} +func (m *StakingRewardClaimEvent) XXX_Size() int { + return m.Size() +} +func (m *StakingRewardClaimEvent) XXX_DiscardUnknown() { + xxx_messageInfo_StakingRewardClaimEvent.DiscardUnknown(m) +} + +var xxx_messageInfo_StakingRewardClaimEvent proto.InternalMessageInfo + +func (m *StakingRewardClaimEvent) GetRewardId() string { + if m != nil { + return m.RewardId + } + return "" +} + +func (m *StakingRewardClaimEvent) GetAddress() string { + if m != nil { + return m.Address + } + return "" +} + +func (m *StakingRewardClaimEvent) GetAmount() string { + if m != nil { + return m.Amount + } + return "" +} + +type StakingRewardJoinEvent struct { + RewardId string `protobuf:"bytes,1,opt,name=reward_id,json=rewardId,proto3" json:"reward_id,omitempty"` + Address string `protobuf:"bytes,2,opt,name=address,proto3" json:"address,omitempty"` + Amount string `protobuf:"bytes,3,opt,name=amount,proto3" json:"amount,omitempty"` +} + +func (m *StakingRewardJoinEvent) Reset() { *m = StakingRewardJoinEvent{} } +func (m *StakingRewardJoinEvent) String() string { return proto.CompactTextString(m) } +func (*StakingRewardJoinEvent) ProtoMessage() {} +func (*StakingRewardJoinEvent) Descriptor() ([]byte, []int) { + return fileDescriptor_d74b3d0352ba8267, []int{3} +} +func (m *StakingRewardJoinEvent) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *StakingRewardJoinEvent) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_StakingRewardJoinEvent.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 *StakingRewardJoinEvent) XXX_Merge(src proto.Message) { + xxx_messageInfo_StakingRewardJoinEvent.Merge(m, src) +} +func (m *StakingRewardJoinEvent) XXX_Size() int { + return m.Size() +} +func (m *StakingRewardJoinEvent) XXX_DiscardUnknown() { + xxx_messageInfo_StakingRewardJoinEvent.DiscardUnknown(m) +} + +var xxx_messageInfo_StakingRewardJoinEvent proto.InternalMessageInfo + +func (m *StakingRewardJoinEvent) GetRewardId() string { + if m != nil { + return m.RewardId + } + return "" +} + +func (m *StakingRewardJoinEvent) GetAddress() string { + if m != nil { + return m.Address + } + return "" +} + +func (m *StakingRewardJoinEvent) GetAmount() string { + if m != nil { + return m.Amount + } + return "" +} + +type StakingRewardExitEvent struct { + RewardId string `protobuf:"bytes,1,opt,name=reward_id,json=rewardId,proto3" json:"reward_id,omitempty"` + Address string `protobuf:"bytes,2,opt,name=address,proto3" json:"address,omitempty"` +} + +func (m *StakingRewardExitEvent) Reset() { *m = StakingRewardExitEvent{} } +func (m *StakingRewardExitEvent) String() string { return proto.CompactTextString(m) } +func (*StakingRewardExitEvent) ProtoMessage() {} +func (*StakingRewardExitEvent) Descriptor() ([]byte, []int) { + return fileDescriptor_d74b3d0352ba8267, []int{4} +} +func (m *StakingRewardExitEvent) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *StakingRewardExitEvent) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_StakingRewardExitEvent.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 *StakingRewardExitEvent) XXX_Merge(src proto.Message) { + xxx_messageInfo_StakingRewardExitEvent.Merge(m, src) +} +func (m *StakingRewardExitEvent) XXX_Size() int { + return m.Size() +} +func (m *StakingRewardExitEvent) XXX_DiscardUnknown() { + xxx_messageInfo_StakingRewardExitEvent.DiscardUnknown(m) +} + +var xxx_messageInfo_StakingRewardExitEvent proto.InternalMessageInfo + +func (m *StakingRewardExitEvent) GetRewardId() string { + if m != nil { + return m.RewardId + } + return "" +} + +func (m *StakingRewardExitEvent) GetAddress() string { + if m != nil { + return m.Address + } + return "" +} + +type StakingRewardFinishEvent struct { + RewardId string `protobuf:"bytes,1,opt,name=reward_id,json=rewardId,proto3" json:"reward_id,omitempty"` +} + +func (m *StakingRewardFinishEvent) Reset() { *m = StakingRewardFinishEvent{} } +func (m *StakingRewardFinishEvent) String() string { return proto.CompactTextString(m) } +func (*StakingRewardFinishEvent) ProtoMessage() {} +func (*StakingRewardFinishEvent) Descriptor() ([]byte, []int) { + return fileDescriptor_d74b3d0352ba8267, []int{5} +} +func (m *StakingRewardFinishEvent) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *StakingRewardFinishEvent) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_StakingRewardFinishEvent.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 *StakingRewardFinishEvent) XXX_Merge(src proto.Message) { + xxx_messageInfo_StakingRewardFinishEvent.Merge(m, src) +} +func (m *StakingRewardFinishEvent) XXX_Size() int { + return m.Size() +} +func (m *StakingRewardFinishEvent) XXX_DiscardUnknown() { + xxx_messageInfo_StakingRewardFinishEvent.DiscardUnknown(m) +} + +var xxx_messageInfo_StakingRewardFinishEvent proto.InternalMessageInfo + +func (m *StakingRewardFinishEvent) GetRewardId() string { + if m != nil { + return m.RewardId + } + return "" +} + +type StakingRewardDistributionEvent struct { + RewardId string `protobuf:"bytes,1,opt,name=reward_id,json=rewardId,proto3" json:"reward_id,omitempty"` + Amount string `protobuf:"bytes,2,opt,name=amount,proto3" json:"amount,omitempty"` +} + +func (m *StakingRewardDistributionEvent) Reset() { *m = StakingRewardDistributionEvent{} } +func (m *StakingRewardDistributionEvent) String() string { return proto.CompactTextString(m) } +func (*StakingRewardDistributionEvent) ProtoMessage() {} +func (*StakingRewardDistributionEvent) Descriptor() ([]byte, []int) { + return fileDescriptor_d74b3d0352ba8267, []int{6} +} +func (m *StakingRewardDistributionEvent) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *StakingRewardDistributionEvent) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_StakingRewardDistributionEvent.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 *StakingRewardDistributionEvent) XXX_Merge(src proto.Message) { + xxx_messageInfo_StakingRewardDistributionEvent.Merge(m, src) +} +func (m *StakingRewardDistributionEvent) XXX_Size() int { + return m.Size() +} +func (m *StakingRewardDistributionEvent) XXX_DiscardUnknown() { + xxx_messageInfo_StakingRewardDistributionEvent.DiscardUnknown(m) +} + +var xxx_messageInfo_StakingRewardDistributionEvent proto.InternalMessageInfo + +func (m *StakingRewardDistributionEvent) GetRewardId() string { + if m != nil { + return m.RewardId + } + return "" +} + +func (m *StakingRewardDistributionEvent) GetAmount() string { + if m != nil { + return m.Amount + } + return "" +} + +type TradingRewardCreateEvent struct { + RewardId string `protobuf:"bytes,1,opt,name=reward_id,json=rewardId,proto3" json:"reward_id,omitempty"` + PrizeAmount string `protobuf:"bytes,2,opt,name=prize_amount,json=prizeAmount,proto3" json:"prize_amount,omitempty"` + PrizeDenom string `protobuf:"bytes,3,opt,name=prize_denom,json=prizeDenom,proto3" json:"prize_denom,omitempty"` + Duration uint32 `protobuf:"varint,4,opt,name=duration,proto3" json:"duration,omitempty"` + MarketId string `protobuf:"bytes,5,opt,name=market_id,json=marketId,proto3" json:"market_id,omitempty"` + Slots uint32 `protobuf:"varint,6,opt,name=slots,proto3" json:"slots,omitempty"` + Creator string `protobuf:"bytes,7,opt,name=creator,proto3" json:"creator,omitempty"` +} + +func (m *TradingRewardCreateEvent) Reset() { *m = TradingRewardCreateEvent{} } +func (m *TradingRewardCreateEvent) String() string { return proto.CompactTextString(m) } +func (*TradingRewardCreateEvent) ProtoMessage() {} +func (*TradingRewardCreateEvent) Descriptor() ([]byte, []int) { + return fileDescriptor_d74b3d0352ba8267, []int{7} +} +func (m *TradingRewardCreateEvent) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *TradingRewardCreateEvent) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_TradingRewardCreateEvent.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 *TradingRewardCreateEvent) XXX_Merge(src proto.Message) { + xxx_messageInfo_TradingRewardCreateEvent.Merge(m, src) +} +func (m *TradingRewardCreateEvent) XXX_Size() int { + return m.Size() +} +func (m *TradingRewardCreateEvent) XXX_DiscardUnknown() { + xxx_messageInfo_TradingRewardCreateEvent.DiscardUnknown(m) +} + +var xxx_messageInfo_TradingRewardCreateEvent proto.InternalMessageInfo + +func (m *TradingRewardCreateEvent) GetRewardId() string { + if m != nil { + return m.RewardId + } + return "" +} + +func (m *TradingRewardCreateEvent) GetPrizeAmount() string { + if m != nil { + return m.PrizeAmount + } + return "" +} + +func (m *TradingRewardCreateEvent) GetPrizeDenom() string { + if m != nil { + return m.PrizeDenom + } + return "" +} + +func (m *TradingRewardCreateEvent) GetDuration() uint32 { + if m != nil { + return m.Duration + } + return 0 +} + +func (m *TradingRewardCreateEvent) GetMarketId() string { + if m != nil { + return m.MarketId + } + return "" +} + +func (m *TradingRewardCreateEvent) GetSlots() uint32 { + if m != nil { + return m.Slots + } + return 0 +} + +func (m *TradingRewardCreateEvent) GetCreator() string { + if m != nil { + return m.Creator + } + return "" +} + +type TradingRewardExpireEvent struct { + RewardId string `protobuf:"bytes,1,opt,name=reward_id,json=rewardId,proto3" json:"reward_id,omitempty"` +} + +func (m *TradingRewardExpireEvent) Reset() { *m = TradingRewardExpireEvent{} } +func (m *TradingRewardExpireEvent) String() string { return proto.CompactTextString(m) } +func (*TradingRewardExpireEvent) ProtoMessage() {} +func (*TradingRewardExpireEvent) Descriptor() ([]byte, []int) { + return fileDescriptor_d74b3d0352ba8267, []int{8} +} +func (m *TradingRewardExpireEvent) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *TradingRewardExpireEvent) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_TradingRewardExpireEvent.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 *TradingRewardExpireEvent) XXX_Merge(src proto.Message) { + xxx_messageInfo_TradingRewardExpireEvent.Merge(m, src) +} +func (m *TradingRewardExpireEvent) XXX_Size() int { + return m.Size() +} +func (m *TradingRewardExpireEvent) XXX_DiscardUnknown() { + xxx_messageInfo_TradingRewardExpireEvent.DiscardUnknown(m) +} + +var xxx_messageInfo_TradingRewardExpireEvent proto.InternalMessageInfo + +func (m *TradingRewardExpireEvent) GetRewardId() string { + if m != nil { + return m.RewardId + } + return "" +} + +type TradingRewardActivationEvent struct { + RewardId string `protobuf:"bytes,1,opt,name=reward_id,json=rewardId,proto3" json:"reward_id,omitempty"` +} + +func (m *TradingRewardActivationEvent) Reset() { *m = TradingRewardActivationEvent{} } +func (m *TradingRewardActivationEvent) String() string { return proto.CompactTextString(m) } +func (*TradingRewardActivationEvent) ProtoMessage() {} +func (*TradingRewardActivationEvent) Descriptor() ([]byte, []int) { + return fileDescriptor_d74b3d0352ba8267, []int{9} +} +func (m *TradingRewardActivationEvent) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *TradingRewardActivationEvent) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_TradingRewardActivationEvent.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 *TradingRewardActivationEvent) XXX_Merge(src proto.Message) { + xxx_messageInfo_TradingRewardActivationEvent.Merge(m, src) +} +func (m *TradingRewardActivationEvent) XXX_Size() int { + return m.Size() +} +func (m *TradingRewardActivationEvent) XXX_DiscardUnknown() { + xxx_messageInfo_TradingRewardActivationEvent.DiscardUnknown(m) +} + +var xxx_messageInfo_TradingRewardActivationEvent proto.InternalMessageInfo + +func (m *TradingRewardActivationEvent) GetRewardId() string { + if m != nil { + return m.RewardId + } + return "" +} + +type TradingRewardDistributionEvent struct { + RewardId string `protobuf:"bytes,1,opt,name=reward_id,json=rewardId,proto3" json:"reward_id,omitempty"` + PrizeAmount string `protobuf:"bytes,2,opt,name=prize_amount,json=prizeAmount,proto3" json:"prize_amount,omitempty"` + PrizeDenom string `protobuf:"bytes,3,opt,name=prize_denom,json=prizeDenom,proto3" json:"prize_denom,omitempty"` + Winners []string `protobuf:"bytes,4,rep,name=winners,proto3" json:"winners,omitempty"` +} + +func (m *TradingRewardDistributionEvent) Reset() { *m = TradingRewardDistributionEvent{} } +func (m *TradingRewardDistributionEvent) String() string { return proto.CompactTextString(m) } +func (*TradingRewardDistributionEvent) ProtoMessage() {} +func (*TradingRewardDistributionEvent) Descriptor() ([]byte, []int) { + return fileDescriptor_d74b3d0352ba8267, []int{10} +} +func (m *TradingRewardDistributionEvent) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *TradingRewardDistributionEvent) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_TradingRewardDistributionEvent.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 *TradingRewardDistributionEvent) XXX_Merge(src proto.Message) { + xxx_messageInfo_TradingRewardDistributionEvent.Merge(m, src) +} +func (m *TradingRewardDistributionEvent) XXX_Size() int { + return m.Size() +} +func (m *TradingRewardDistributionEvent) XXX_DiscardUnknown() { + xxx_messageInfo_TradingRewardDistributionEvent.DiscardUnknown(m) +} + +var xxx_messageInfo_TradingRewardDistributionEvent proto.InternalMessageInfo + +func (m *TradingRewardDistributionEvent) GetRewardId() string { + if m != nil { + return m.RewardId + } + return "" +} + +func (m *TradingRewardDistributionEvent) GetPrizeAmount() string { + if m != nil { + return m.PrizeAmount + } + return "" +} + +func (m *TradingRewardDistributionEvent) GetPrizeDenom() string { + if m != nil { + return m.PrizeDenom + } + return "" +} + +func (m *TradingRewardDistributionEvent) GetWinners() []string { + if m != nil { + return m.Winners + } + return nil +} + +func init() { + proto.RegisterType((*StakingRewardCreateEvent)(nil), "bze.rewards.v1.StakingRewardCreateEvent") + proto.RegisterType((*StakingRewardUpdateEvent)(nil), "bze.rewards.v1.StakingRewardUpdateEvent") + proto.RegisterType((*StakingRewardClaimEvent)(nil), "bze.rewards.v1.StakingRewardClaimEvent") + proto.RegisterType((*StakingRewardJoinEvent)(nil), "bze.rewards.v1.StakingRewardJoinEvent") + proto.RegisterType((*StakingRewardExitEvent)(nil), "bze.rewards.v1.StakingRewardExitEvent") + proto.RegisterType((*StakingRewardFinishEvent)(nil), "bze.rewards.v1.StakingRewardFinishEvent") + proto.RegisterType((*StakingRewardDistributionEvent)(nil), "bze.rewards.v1.StakingRewardDistributionEvent") + proto.RegisterType((*TradingRewardCreateEvent)(nil), "bze.rewards.v1.TradingRewardCreateEvent") + proto.RegisterType((*TradingRewardExpireEvent)(nil), "bze.rewards.v1.TradingRewardExpireEvent") + proto.RegisterType((*TradingRewardActivationEvent)(nil), "bze.rewards.v1.TradingRewardActivationEvent") + proto.RegisterType((*TradingRewardDistributionEvent)(nil), "bze.rewards.v1.TradingRewardDistributionEvent") +} + func init() { proto.RegisterFile("rewards/events.proto", fileDescriptor_d74b3d0352ba8267) } var fileDescriptor_d74b3d0352ba8267 = []byte{ - // 139 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x12, 0x29, 0x4a, 0x2d, 0x4f, - 0x2c, 0x4a, 0x29, 0xd6, 0x4f, 0x2d, 0x4b, 0xcd, 0x2b, 0x29, 0xd6, 0x2b, 0x28, 0xca, 0x2f, 0xc9, - 0x17, 0xe2, 0x4b, 0xaa, 0x4a, 0xd5, 0x83, 0xca, 0xe8, 0x95, 0x19, 0x4a, 0x89, 0xa4, 0xe7, 0xa7, - 0xe7, 0x83, 0xa5, 0xf4, 0x41, 0x2c, 0x88, 0x2a, 0x27, 0xb7, 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, 0xd2, 0x49, 0xcf, 0x2c, 0xc9, 0x28, 0x4d, 0xd2, 0x4b, 0xce, 0xcf, 0xd5, - 0x4f, 0xaa, 0x4a, 0xd5, 0x4d, 0xcc, 0x29, 0xc8, 0x48, 0x2c, 0x49, 0x4d, 0x04, 0xf3, 0xf4, 0x2b, - 0xf4, 0x61, 0x96, 0x96, 0x54, 0x16, 0xa4, 0x16, 0x27, 0xb1, 0x81, 0x8d, 0x33, 0x06, 0x04, 0x00, - 0x00, 0xff, 0xff, 0x9f, 0x97, 0x71, 0x1d, 0x8c, 0x00, 0x00, 0x00, + // 510 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x54, 0xbf, 0x8f, 0xd3, 0x30, + 0x18, 0xad, 0x7b, 0xe9, 0x2f, 0x73, 0x65, 0x88, 0xaa, 0xc3, 0x3a, 0x50, 0x28, 0x61, 0xe9, 0x00, + 0x8d, 0x10, 0x03, 0x03, 0xd3, 0xc1, 0xf5, 0xa4, 0x63, 0x41, 0xca, 0x71, 0x0b, 0x4b, 0xe5, 0xd4, + 0x56, 0x6a, 0xb5, 0xb1, 0x23, 0xdb, 0xed, 0x95, 0xfe, 0x15, 0xec, 0xfc, 0x43, 0x8c, 0x37, 0x32, + 0xa2, 0x96, 0x95, 0xff, 0x01, 0xd9, 0x4e, 0xe1, 0x52, 0x21, 0x11, 0x04, 0x88, 0x2d, 0xef, 0xf3, + 0xf3, 0xf7, 0xbe, 0xf7, 0xf2, 0xc9, 0xb0, 0x27, 0xe9, 0x15, 0x96, 0x44, 0x45, 0x74, 0x49, 0xb9, + 0x56, 0xc3, 0x5c, 0x0a, 0x2d, 0xfc, 0xdb, 0xc9, 0x9a, 0x0e, 0x8b, 0x93, 0xe1, 0xf2, 0xc9, 0x71, + 0x2f, 0x15, 0xa9, 0xb0, 0x47, 0x91, 0xf9, 0x72, 0xac, 0xf0, 0x2b, 0x80, 0xe8, 0x42, 0xe3, 0x19, + 0xe3, 0x69, 0x6c, 0xb9, 0x2f, 0x25, 0xc5, 0x9a, 0x8e, 0x4c, 0x27, 0xff, 0x2e, 0xec, 0xb8, 0x06, + 0x63, 0x46, 0x10, 0xe8, 0x83, 0x41, 0x27, 0x6e, 0xbb, 0xc2, 0x39, 0xf1, 0x1f, 0xc0, 0xc3, 0x5c, + 0xb2, 0x35, 0x1d, 0xe3, 0x4c, 0x2c, 0xb8, 0x46, 0x75, 0x7b, 0x7e, 0xcb, 0xd6, 0x4e, 0x6c, 0xc9, + 0xbf, 0x0f, 0x1d, 0x1c, 0x13, 0xca, 0x45, 0x86, 0x0e, 0x2c, 0x03, 0xda, 0xd2, 0xa9, 0xa9, 0xf8, + 0x0f, 0x61, 0x57, 0x39, 0xf1, 0x82, 0xe2, 0x59, 0xca, 0x61, 0x51, 0x74, 0xa4, 0x63, 0xd8, 0x26, + 0x0b, 0x89, 0x35, 0x13, 0x1c, 0x35, 0xfa, 0x60, 0xd0, 0x8d, 0xbf, 0x63, 0x33, 0x61, 0xc6, 0xf8, + 0xd8, 0xf0, 0x29, 0x6a, 0xf6, 0xc1, 0xc0, 0x8b, 0xdb, 0x19, 0xe3, 0xc6, 0x11, 0xf5, 0x7d, 0xe8, + 0xcd, 0xc5, 0x64, 0x86, 0x5a, 0xf6, 0x92, 0xfd, 0x0e, 0x2f, 0xf6, 0xec, 0x5e, 0xe6, 0xa4, 0x9a, + 0xdd, 0x9b, 0x53, 0xd4, 0xcb, 0x53, 0x84, 0x53, 0x78, 0xa7, 0x9c, 0xe1, 0x1c, 0xb3, 0xac, 0x42, + 0x4f, 0x04, 0x5b, 0x98, 0x10, 0x49, 0x95, 0x2a, 0xd2, 0xdb, 0x41, 0xff, 0x08, 0x36, 0x8b, 0x58, + 0x5d, 0x68, 0x05, 0x0a, 0x53, 0x78, 0x54, 0x52, 0x7a, 0x25, 0x18, 0xff, 0x27, 0x42, 0xaf, 0xf7, + 0x84, 0x46, 0x2b, 0xa6, 0xff, 0x44, 0x28, 0x7c, 0xb6, 0x17, 0xfc, 0x19, 0xe3, 0x4c, 0x4d, 0x7f, + 0xdd, 0x32, 0xbc, 0x84, 0x41, 0xe9, 0xe2, 0x29, 0x53, 0x5a, 0xb2, 0x64, 0x61, 0x92, 0xaf, 0x30, + 0xd1, 0x0f, 0x83, 0xf5, 0x92, 0xc1, 0x2f, 0x00, 0xa2, 0x37, 0x12, 0x93, 0xff, 0xb3, 0xf8, 0x37, + 0xb7, 0xc9, 0xfb, 0xc9, 0x4e, 0x63, 0x39, 0xa3, 0xda, 0x88, 0x37, 0x9c, 0xb8, 0x2b, 0x9c, 0x13, + 0xbf, 0x07, 0x1b, 0x6a, 0x2e, 0xb4, 0xb2, 0xcb, 0xde, 0x8d, 0x1d, 0x30, 0xb1, 0x4f, 0xcc, 0xf8, + 0x42, 0xda, 0x65, 0xef, 0xc4, 0x3b, 0x68, 0x62, 0x2f, 0xb9, 0x1c, 0xad, 0x72, 0x26, 0x2b, 0xb8, + 0x0c, 0x9f, 0xc3, 0x7b, 0xa5, 0x8b, 0x27, 0x13, 0xcd, 0x96, 0xb8, 0x5a, 0xe8, 0xe1, 0x07, 0x00, + 0x83, 0xd2, 0xed, 0xdf, 0xfc, 0x69, 0x7f, 0x23, 0x62, 0x04, 0x5b, 0x57, 0x8c, 0x73, 0x2a, 0x15, + 0xf2, 0xfa, 0x07, 0x26, 0x93, 0x02, 0xbe, 0x38, 0xfb, 0xb8, 0x09, 0xc0, 0xf5, 0x26, 0x00, 0x9f, + 0x37, 0x01, 0x78, 0xbf, 0x0d, 0x6a, 0xd7, 0xdb, 0xa0, 0xf6, 0x69, 0x1b, 0xd4, 0xde, 0x3e, 0x4a, + 0x99, 0x9e, 0x2e, 0x92, 0xe1, 0x44, 0x64, 0x51, 0xb2, 0xa6, 0x8f, 0xf1, 0x3c, 0x9f, 0x62, 0x4d, + 0xb1, 0x45, 0xd1, 0x2a, 0xda, 0x3d, 0xb4, 0xfa, 0x5d, 0x4e, 0x55, 0xd2, 0xb4, 0x4f, 0xe8, 0xd3, + 0x6f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x19, 0xa8, 0x2b, 0x37, 0x80, 0x05, 0x00, 0x00, +} + +func (m *StakingRewardCreateEvent) 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 *StakingRewardCreateEvent) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *StakingRewardCreateEvent) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Lock != 0 { + i = encodeVarintEvents(dAtA, i, uint64(m.Lock)) + i-- + dAtA[i] = 0x38 + } + if m.MinStake != 0 { + i = encodeVarintEvents(dAtA, i, uint64(m.MinStake)) + i-- + dAtA[i] = 0x30 + } + if m.Duration != 0 { + i = encodeVarintEvents(dAtA, i, uint64(m.Duration)) + i-- + dAtA[i] = 0x28 + } + if len(m.StakingDenom) > 0 { + i -= len(m.StakingDenom) + copy(dAtA[i:], m.StakingDenom) + i = encodeVarintEvents(dAtA, i, uint64(len(m.StakingDenom))) + i-- + dAtA[i] = 0x22 + } + if len(m.PrizeDenom) > 0 { + i -= len(m.PrizeDenom) + copy(dAtA[i:], m.PrizeDenom) + i = encodeVarintEvents(dAtA, i, uint64(len(m.PrizeDenom))) + i-- + dAtA[i] = 0x1a + } + if len(m.PrizeAmount) > 0 { + i -= len(m.PrizeAmount) + copy(dAtA[i:], m.PrizeAmount) + i = encodeVarintEvents(dAtA, i, uint64(len(m.PrizeAmount))) + i-- + dAtA[i] = 0x12 + } + if len(m.RewardId) > 0 { + i -= len(m.RewardId) + copy(dAtA[i:], m.RewardId) + i = encodeVarintEvents(dAtA, i, uint64(len(m.RewardId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *StakingRewardUpdateEvent) 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 *StakingRewardUpdateEvent) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *StakingRewardUpdateEvent) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Duration != 0 { + i = encodeVarintEvents(dAtA, i, uint64(m.Duration)) + i-- + dAtA[i] = 0x10 + } + if len(m.RewardId) > 0 { + i -= len(m.RewardId) + copy(dAtA[i:], m.RewardId) + i = encodeVarintEvents(dAtA, i, uint64(len(m.RewardId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *StakingRewardClaimEvent) 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 *StakingRewardClaimEvent) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *StakingRewardClaimEvent) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Amount) > 0 { + i -= len(m.Amount) + copy(dAtA[i:], m.Amount) + i = encodeVarintEvents(dAtA, i, uint64(len(m.Amount))) + i-- + dAtA[i] = 0x1a + } + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintEvents(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0x12 + } + if len(m.RewardId) > 0 { + i -= len(m.RewardId) + copy(dAtA[i:], m.RewardId) + i = encodeVarintEvents(dAtA, i, uint64(len(m.RewardId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *StakingRewardJoinEvent) 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 *StakingRewardJoinEvent) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *StakingRewardJoinEvent) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Amount) > 0 { + i -= len(m.Amount) + copy(dAtA[i:], m.Amount) + i = encodeVarintEvents(dAtA, i, uint64(len(m.Amount))) + i-- + dAtA[i] = 0x1a + } + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintEvents(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0x12 + } + if len(m.RewardId) > 0 { + i -= len(m.RewardId) + copy(dAtA[i:], m.RewardId) + i = encodeVarintEvents(dAtA, i, uint64(len(m.RewardId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *StakingRewardExitEvent) 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 *StakingRewardExitEvent) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *StakingRewardExitEvent) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Address) > 0 { + i -= len(m.Address) + copy(dAtA[i:], m.Address) + i = encodeVarintEvents(dAtA, i, uint64(len(m.Address))) + i-- + dAtA[i] = 0x12 + } + if len(m.RewardId) > 0 { + i -= len(m.RewardId) + copy(dAtA[i:], m.RewardId) + i = encodeVarintEvents(dAtA, i, uint64(len(m.RewardId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *StakingRewardFinishEvent) 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 *StakingRewardFinishEvent) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *StakingRewardFinishEvent) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.RewardId) > 0 { + i -= len(m.RewardId) + copy(dAtA[i:], m.RewardId) + i = encodeVarintEvents(dAtA, i, uint64(len(m.RewardId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *StakingRewardDistributionEvent) 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 *StakingRewardDistributionEvent) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *StakingRewardDistributionEvent) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Amount) > 0 { + i -= len(m.Amount) + copy(dAtA[i:], m.Amount) + i = encodeVarintEvents(dAtA, i, uint64(len(m.Amount))) + i-- + dAtA[i] = 0x12 + } + if len(m.RewardId) > 0 { + i -= len(m.RewardId) + copy(dAtA[i:], m.RewardId) + i = encodeVarintEvents(dAtA, i, uint64(len(m.RewardId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *TradingRewardCreateEvent) 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 *TradingRewardCreateEvent) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *TradingRewardCreateEvent) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Creator) > 0 { + i -= len(m.Creator) + copy(dAtA[i:], m.Creator) + i = encodeVarintEvents(dAtA, i, uint64(len(m.Creator))) + i-- + dAtA[i] = 0x3a + } + if m.Slots != 0 { + i = encodeVarintEvents(dAtA, i, uint64(m.Slots)) + i-- + dAtA[i] = 0x30 + } + if len(m.MarketId) > 0 { + i -= len(m.MarketId) + copy(dAtA[i:], m.MarketId) + i = encodeVarintEvents(dAtA, i, uint64(len(m.MarketId))) + i-- + dAtA[i] = 0x2a + } + if m.Duration != 0 { + i = encodeVarintEvents(dAtA, i, uint64(m.Duration)) + i-- + dAtA[i] = 0x20 + } + if len(m.PrizeDenom) > 0 { + i -= len(m.PrizeDenom) + copy(dAtA[i:], m.PrizeDenom) + i = encodeVarintEvents(dAtA, i, uint64(len(m.PrizeDenom))) + i-- + dAtA[i] = 0x1a + } + if len(m.PrizeAmount) > 0 { + i -= len(m.PrizeAmount) + copy(dAtA[i:], m.PrizeAmount) + i = encodeVarintEvents(dAtA, i, uint64(len(m.PrizeAmount))) + i-- + dAtA[i] = 0x12 + } + if len(m.RewardId) > 0 { + i -= len(m.RewardId) + copy(dAtA[i:], m.RewardId) + i = encodeVarintEvents(dAtA, i, uint64(len(m.RewardId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *TradingRewardExpireEvent) 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 *TradingRewardExpireEvent) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *TradingRewardExpireEvent) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.RewardId) > 0 { + i -= len(m.RewardId) + copy(dAtA[i:], m.RewardId) + i = encodeVarintEvents(dAtA, i, uint64(len(m.RewardId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *TradingRewardActivationEvent) 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 *TradingRewardActivationEvent) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *TradingRewardActivationEvent) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.RewardId) > 0 { + i -= len(m.RewardId) + copy(dAtA[i:], m.RewardId) + i = encodeVarintEvents(dAtA, i, uint64(len(m.RewardId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *TradingRewardDistributionEvent) 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 *TradingRewardDistributionEvent) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *TradingRewardDistributionEvent) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Winners) > 0 { + for iNdEx := len(m.Winners) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Winners[iNdEx]) + copy(dAtA[i:], m.Winners[iNdEx]) + i = encodeVarintEvents(dAtA, i, uint64(len(m.Winners[iNdEx]))) + i-- + dAtA[i] = 0x22 + } + } + if len(m.PrizeDenom) > 0 { + i -= len(m.PrizeDenom) + copy(dAtA[i:], m.PrizeDenom) + i = encodeVarintEvents(dAtA, i, uint64(len(m.PrizeDenom))) + i-- + dAtA[i] = 0x1a + } + if len(m.PrizeAmount) > 0 { + i -= len(m.PrizeAmount) + copy(dAtA[i:], m.PrizeAmount) + i = encodeVarintEvents(dAtA, i, uint64(len(m.PrizeAmount))) + i-- + dAtA[i] = 0x12 + } + if len(m.RewardId) > 0 { + i -= len(m.RewardId) + copy(dAtA[i:], m.RewardId) + i = encodeVarintEvents(dAtA, i, uint64(len(m.RewardId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintEvents(dAtA []byte, offset int, v uint64) int { + offset -= sovEvents(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *StakingRewardCreateEvent) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.RewardId) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.PrizeAmount) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.PrizeDenom) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.StakingDenom) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + if m.Duration != 0 { + n += 1 + sovEvents(uint64(m.Duration)) + } + if m.MinStake != 0 { + n += 1 + sovEvents(uint64(m.MinStake)) + } + if m.Lock != 0 { + n += 1 + sovEvents(uint64(m.Lock)) + } + return n +} + +func (m *StakingRewardUpdateEvent) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.RewardId) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + if m.Duration != 0 { + n += 1 + sovEvents(uint64(m.Duration)) + } + return n +} + +func (m *StakingRewardClaimEvent) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.RewardId) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.Address) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.Amount) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + return n +} + +func (m *StakingRewardJoinEvent) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.RewardId) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.Address) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.Amount) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + return n +} + +func (m *StakingRewardExitEvent) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.RewardId) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.Address) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + return n +} + +func (m *StakingRewardFinishEvent) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.RewardId) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + return n +} + +func (m *StakingRewardDistributionEvent) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.RewardId) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.Amount) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + return n +} + +func (m *TradingRewardCreateEvent) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.RewardId) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.PrizeAmount) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.PrizeDenom) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + if m.Duration != 0 { + n += 1 + sovEvents(uint64(m.Duration)) + } + l = len(m.MarketId) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + if m.Slots != 0 { + n += 1 + sovEvents(uint64(m.Slots)) + } + l = len(m.Creator) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + return n +} + +func (m *TradingRewardExpireEvent) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.RewardId) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + return n +} + +func (m *TradingRewardActivationEvent) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.RewardId) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + return n +} + +func (m *TradingRewardDistributionEvent) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.RewardId) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.PrizeAmount) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + l = len(m.PrizeDenom) + if l > 0 { + n += 1 + l + sovEvents(uint64(l)) + } + if len(m.Winners) > 0 { + for _, s := range m.Winners { + l = len(s) + n += 1 + l + sovEvents(uint64(l)) + } + } + return n +} + +func sovEvents(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozEvents(x uint64) (n int) { + return sovEvents(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *StakingRewardCreateEvent) 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 ErrIntOverflowEvents + } + 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: StakingRewardCreateEvent: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: StakingRewardCreateEvent: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RewardId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.RewardId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PrizeAmount", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PrizeAmount = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PrizeDenom", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PrizeDenom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field StakingDenom", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.StakingDenom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Duration", wireType) + } + m.Duration = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Duration |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field MinStake", wireType) + } + m.MinStake = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.MinStake |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 7: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Lock", wireType) + } + m.Lock = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Lock |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipEvents(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthEvents + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *StakingRewardUpdateEvent) 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 ErrIntOverflowEvents + } + 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: StakingRewardUpdateEvent: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: StakingRewardUpdateEvent: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RewardId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.RewardId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Duration", wireType) + } + m.Duration = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Duration |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipEvents(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthEvents + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *StakingRewardClaimEvent) 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 ErrIntOverflowEvents + } + 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: StakingRewardClaimEvent: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: StakingRewardClaimEvent: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RewardId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.RewardId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Amount = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipEvents(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthEvents + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *StakingRewardJoinEvent) 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 ErrIntOverflowEvents + } + 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: StakingRewardJoinEvent: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: StakingRewardJoinEvent: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RewardId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.RewardId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Amount = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipEvents(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthEvents + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *StakingRewardExitEvent) 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 ErrIntOverflowEvents + } + 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: StakingRewardExitEvent: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: StakingRewardExitEvent: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RewardId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.RewardId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Address", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Address = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipEvents(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthEvents + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *StakingRewardFinishEvent) 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 ErrIntOverflowEvents + } + 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: StakingRewardFinishEvent: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: StakingRewardFinishEvent: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RewardId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.RewardId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipEvents(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthEvents + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *StakingRewardDistributionEvent) 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 ErrIntOverflowEvents + } + 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: StakingRewardDistributionEvent: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: StakingRewardDistributionEvent: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RewardId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.RewardId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Amount = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipEvents(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthEvents + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *TradingRewardCreateEvent) 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 ErrIntOverflowEvents + } + 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: TradingRewardCreateEvent: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: TradingRewardCreateEvent: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RewardId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.RewardId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PrizeAmount", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PrizeAmount = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PrizeDenom", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PrizeDenom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Duration", wireType) + } + m.Duration = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Duration |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MarketId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.MarketId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Slots", wireType) + } + m.Slots = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Slots |= uint32(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Creator", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Creator = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipEvents(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthEvents + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *TradingRewardExpireEvent) 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 ErrIntOverflowEvents + } + 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: TradingRewardExpireEvent: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: TradingRewardExpireEvent: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RewardId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.RewardId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipEvents(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthEvents + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *TradingRewardActivationEvent) 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 ErrIntOverflowEvents + } + 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: TradingRewardActivationEvent: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: TradingRewardActivationEvent: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RewardId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.RewardId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipEvents(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthEvents + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *TradingRewardDistributionEvent) 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 ErrIntOverflowEvents + } + 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: TradingRewardDistributionEvent: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: TradingRewardDistributionEvent: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RewardId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.RewardId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PrizeAmount", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PrizeAmount = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PrizeDenom", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.PrizeDenom = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Winners", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowEvents + } + 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 ErrInvalidLengthEvents + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthEvents + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Winners = append(m.Winners, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipEvents(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthEvents + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipEvents(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, ErrIntOverflowEvents + } + 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, ErrIntOverflowEvents + } + 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, ErrIntOverflowEvents + } + 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, ErrInvalidLengthEvents + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupEvents + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthEvents + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthEvents = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowEvents = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupEvents = fmt.Errorf("proto: unexpected end of group") +) From d199ac83641101355c842fb36a8ddf8ce70e490f Mon Sep 17 00:00:00 2001 From: faneaatiku Date: Thu, 18 Apr 2024 23:27:00 +0300 Subject: [PATCH 30/35] added distribute staking reward message --- docs/static/openapi.yml | 2 + proto/rewards/tx.proto | 10 + .../bze-alphateam/bze/bze.v1.rewards/index.ts | 108 ++-- .../bze/bze.v1.rewards/module/index.ts | 15 +- .../bze/bze.v1.rewards/module/rest.ts | 2 + .../bze.v1.rewards/module/types/rewards/tx.ts | 186 ++++++- x/rewards/client/cli/tx.go | 1 + .../cli/tx_distribute_staking_rewards.go | 44 ++ x/rewards/handler.go | 3 + .../msg_server_distribute_staking_rewards.go | 46 ++ x/rewards/module_simulation.go | 15 + .../simulation/distribute_staking_rewards.go | 29 + x/rewards/types/codec.go | 4 + .../message_distribute_staking_rewards.go | 57 ++ ...message_distribute_staking_rewards_test.go | 40 ++ x/rewards/types/tx.pb.go | 502 ++++++++++++++++-- 16 files changed, 981 insertions(+), 83 deletions(-) create mode 100644 x/rewards/client/cli/tx_distribute_staking_rewards.go create mode 100644 x/rewards/keeper/msg_server_distribute_staking_rewards.go create mode 100644 x/rewards/simulation/distribute_staking_rewards.go create mode 100644 x/rewards/types/message_distribute_staking_rewards.go create mode 100644 x/rewards/types/message_distribute_staking_rewards_test.go diff --git a/docs/static/openapi.yml b/docs/static/openapi.yml index 96d738e6..9f93ed9a 100644 --- a/docs/static/openapi.yml +++ b/docs/static/openapi.yml @@ -34743,6 +34743,8 @@ definitions: properties: reward_id: type: string + bze.v1.rewards.MsgDistributeStakingRewardsResponse: + type: object bze.v1.rewards.MsgExitStakingResponse: type: object bze.v1.rewards.MsgJoinStakingResponse: diff --git a/proto/rewards/tx.proto b/proto/rewards/tx.proto index 4db9362f..a4462c3d 100644 --- a/proto/rewards/tx.proto +++ b/proto/rewards/tx.proto @@ -13,6 +13,7 @@ service Msg { rpc JoinStaking(MsgJoinStaking) returns (MsgJoinStakingResponse); rpc ExitStaking(MsgExitStaking) returns (MsgExitStakingResponse); rpc ClaimStakingRewards(MsgClaimStakingRewards) returns (MsgClaimStakingRewardsResponse); + rpc DistributeStakingRewards(MsgDistributeStakingRewards) returns (MsgDistributeStakingRewardsResponse); // this line is used by starport scaffolding # proto/tx/rpc } @@ -75,4 +76,13 @@ message MsgClaimStakingRewardsResponse { string amount = 1; } +message MsgDistributeStakingRewards { + string creator = 1; + string rewardId = 2; + string amount = 3; +} + +message MsgDistributeStakingRewardsResponse { +} + // this line is used by starport scaffolding # proto/tx/message diff --git a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/index.ts b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/index.ts index d01443e2..c239a382 100755 --- a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/index.ts +++ b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/index.ts @@ -407,33 +407,48 @@ export default { }, - async sendMsgClaimStakingRewards({ rootGetters }, { value, fee = [], memo = '' }) { + async sendMsgCreateTradingReward({ rootGetters }, { value, fee = [], memo = '' }) { try { const txClient=await initTxClient(rootGetters) - const msg = await txClient.msgClaimStakingRewards(value) + const msg = await txClient.msgCreateTradingReward(value) const result = await txClient.signAndBroadcast([msg], {fee: { amount: fee, gas: "200000" }, memo}) return result } catch (e) { if (e == MissingWalletError) { - throw new Error('TxClient:MsgClaimStakingRewards:Init Could not initialize signing client. Wallet is required.') + throw new Error('TxClient:MsgCreateTradingReward:Init Could not initialize signing client. Wallet is required.') }else{ - throw new Error('TxClient:MsgClaimStakingRewards:Send Could not broadcast Tx: '+ e.message) + throw new Error('TxClient:MsgCreateTradingReward:Send Could not broadcast Tx: '+ e.message) } } }, - async sendMsgCreateTradingReward({ rootGetters }, { value, fee = [], memo = '' }) { + async sendMsgCreateStakingReward({ rootGetters }, { value, fee = [], memo = '' }) { try { const txClient=await initTxClient(rootGetters) - const msg = await txClient.msgCreateTradingReward(value) + const msg = await txClient.msgCreateStakingReward(value) const result = await txClient.signAndBroadcast([msg], {fee: { amount: fee, gas: "200000" }, memo}) return result } catch (e) { if (e == MissingWalletError) { - throw new Error('TxClient:MsgCreateTradingReward:Init Could not initialize signing client. Wallet is required.') + throw new Error('TxClient:MsgCreateStakingReward:Init Could not initialize signing client. Wallet is required.') }else{ - throw new Error('TxClient:MsgCreateTradingReward:Send Could not broadcast Tx: '+ e.message) + throw new Error('TxClient:MsgCreateStakingReward:Send Could not broadcast Tx: '+ e.message) + } + } + }, + async sendMsgUpdateStakingReward({ rootGetters }, { value, fee = [], memo = '' }) { + try { + const txClient=await initTxClient(rootGetters) + const msg = await txClient.msgUpdateStakingReward(value) + const result = await txClient.signAndBroadcast([msg], {fee: { amount: fee, + gas: "200000" }, memo}) + return result + } catch (e) { + if (e == MissingWalletError) { + throw new Error('TxClient:MsgUpdateStakingReward:Init Could not initialize signing client. Wallet is required.') + }else{ + throw new Error('TxClient:MsgUpdateStakingReward:Send Could not broadcast Tx: '+ e.message) } } }, @@ -452,75 +467,88 @@ export default { } } }, - async sendMsgCreateStakingReward({ rootGetters }, { value, fee = [], memo = '' }) { + async sendMsgExitStaking({ rootGetters }, { value, fee = [], memo = '' }) { try { const txClient=await initTxClient(rootGetters) - const msg = await txClient.msgCreateStakingReward(value) + const msg = await txClient.msgExitStaking(value) const result = await txClient.signAndBroadcast([msg], {fee: { amount: fee, gas: "200000" }, memo}) return result } catch (e) { if (e == MissingWalletError) { - throw new Error('TxClient:MsgCreateStakingReward:Init Could not initialize signing client. Wallet is required.') + throw new Error('TxClient:MsgExitStaking:Init Could not initialize signing client. Wallet is required.') }else{ - throw new Error('TxClient:MsgCreateStakingReward:Send Could not broadcast Tx: '+ e.message) + throw new Error('TxClient:MsgExitStaking:Send Could not broadcast Tx: '+ e.message) } } }, - async sendMsgUpdateStakingReward({ rootGetters }, { value, fee = [], memo = '' }) { + async sendMsgClaimStakingRewards({ rootGetters }, { value, fee = [], memo = '' }) { try { const txClient=await initTxClient(rootGetters) - const msg = await txClient.msgUpdateStakingReward(value) + const msg = await txClient.msgClaimStakingRewards(value) const result = await txClient.signAndBroadcast([msg], {fee: { amount: fee, gas: "200000" }, memo}) return result } catch (e) { if (e == MissingWalletError) { - throw new Error('TxClient:MsgUpdateStakingReward:Init Could not initialize signing client. Wallet is required.') + throw new Error('TxClient:MsgClaimStakingRewards:Init Could not initialize signing client. Wallet is required.') }else{ - throw new Error('TxClient:MsgUpdateStakingReward:Send Could not broadcast Tx: '+ e.message) + throw new Error('TxClient:MsgClaimStakingRewards:Send Could not broadcast Tx: '+ e.message) } } }, - async sendMsgExitStaking({ rootGetters }, { value, fee = [], memo = '' }) { + async sendMsgDistributeStakingRewards({ rootGetters }, { value, fee = [], memo = '' }) { try { const txClient=await initTxClient(rootGetters) - const msg = await txClient.msgExitStaking(value) + const msg = await txClient.msgDistributeStakingRewards(value) const result = await txClient.signAndBroadcast([msg], {fee: { amount: fee, gas: "200000" }, memo}) return result } catch (e) { if (e == MissingWalletError) { - throw new Error('TxClient:MsgExitStaking:Init Could not initialize signing client. Wallet is required.') + throw new Error('TxClient:MsgDistributeStakingRewards:Init Could not initialize signing client. Wallet is required.') }else{ - throw new Error('TxClient:MsgExitStaking:Send Could not broadcast Tx: '+ e.message) + throw new Error('TxClient:MsgDistributeStakingRewards:Send Could not broadcast Tx: '+ e.message) } } }, - async MsgClaimStakingRewards({ rootGetters }, { value }) { + async MsgCreateTradingReward({ rootGetters }, { value }) { try { const txClient=await initTxClient(rootGetters) - const msg = await txClient.msgClaimStakingRewards(value) + const msg = await txClient.msgCreateTradingReward(value) return msg } catch (e) { if (e == MissingWalletError) { - throw new Error('TxClient:MsgClaimStakingRewards:Init Could not initialize signing client. Wallet is required.') + throw new Error('TxClient:MsgCreateTradingReward:Init Could not initialize signing client. Wallet is required.') } else{ - throw new Error('TxClient:MsgClaimStakingRewards:Create Could not create message: ' + e.message) + throw new Error('TxClient:MsgCreateTradingReward:Create Could not create message: ' + e.message) } } }, - async MsgCreateTradingReward({ rootGetters }, { value }) { + async MsgCreateStakingReward({ rootGetters }, { value }) { try { const txClient=await initTxClient(rootGetters) - const msg = await txClient.msgCreateTradingReward(value) + const msg = await txClient.msgCreateStakingReward(value) return msg } catch (e) { if (e == MissingWalletError) { - throw new Error('TxClient:MsgCreateTradingReward:Init Could not initialize signing client. Wallet is required.') + throw new Error('TxClient:MsgCreateStakingReward:Init Could not initialize signing client. Wallet is required.') } else{ - throw new Error('TxClient:MsgCreateTradingReward:Create Could not create message: ' + e.message) + throw new Error('TxClient:MsgCreateStakingReward:Create Could not create message: ' + e.message) + } + } + }, + async MsgUpdateStakingReward({ rootGetters }, { value }) { + try { + const txClient=await initTxClient(rootGetters) + const msg = await txClient.msgUpdateStakingReward(value) + return msg + } catch (e) { + if (e == MissingWalletError) { + throw new Error('TxClient:MsgUpdateStakingReward:Init Could not initialize signing client. Wallet is required.') + } else{ + throw new Error('TxClient:MsgUpdateStakingReward:Create Could not create message: ' + e.message) } } }, @@ -537,42 +565,42 @@ export default { } } }, - async MsgCreateStakingReward({ rootGetters }, { value }) { + async MsgExitStaking({ rootGetters }, { value }) { try { const txClient=await initTxClient(rootGetters) - const msg = await txClient.msgCreateStakingReward(value) + const msg = await txClient.msgExitStaking(value) return msg } catch (e) { if (e == MissingWalletError) { - throw new Error('TxClient:MsgCreateStakingReward:Init Could not initialize signing client. Wallet is required.') + throw new Error('TxClient:MsgExitStaking:Init Could not initialize signing client. Wallet is required.') } else{ - throw new Error('TxClient:MsgCreateStakingReward:Create Could not create message: ' + e.message) + throw new Error('TxClient:MsgExitStaking:Create Could not create message: ' + e.message) } } }, - async MsgUpdateStakingReward({ rootGetters }, { value }) { + async MsgClaimStakingRewards({ rootGetters }, { value }) { try { const txClient=await initTxClient(rootGetters) - const msg = await txClient.msgUpdateStakingReward(value) + const msg = await txClient.msgClaimStakingRewards(value) return msg } catch (e) { if (e == MissingWalletError) { - throw new Error('TxClient:MsgUpdateStakingReward:Init Could not initialize signing client. Wallet is required.') + throw new Error('TxClient:MsgClaimStakingRewards:Init Could not initialize signing client. Wallet is required.') } else{ - throw new Error('TxClient:MsgUpdateStakingReward:Create Could not create message: ' + e.message) + throw new Error('TxClient:MsgClaimStakingRewards:Create Could not create message: ' + e.message) } } }, - async MsgExitStaking({ rootGetters }, { value }) { + async MsgDistributeStakingRewards({ rootGetters }, { value }) { try { const txClient=await initTxClient(rootGetters) - const msg = await txClient.msgExitStaking(value) + const msg = await txClient.msgDistributeStakingRewards(value) return msg } catch (e) { if (e == MissingWalletError) { - throw new Error('TxClient:MsgExitStaking:Init Could not initialize signing client. Wallet is required.') + throw new Error('TxClient:MsgDistributeStakingRewards:Init Could not initialize signing client. Wallet is required.') } else{ - throw new Error('TxClient:MsgExitStaking:Create Could not create message: ' + e.message) + throw new Error('TxClient:MsgDistributeStakingRewards:Create Could not create message: ' + e.message) } } }, diff --git a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/index.ts b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/index.ts index abad584e..2664186c 100755 --- a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/index.ts +++ b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/index.ts @@ -4,21 +4,23 @@ import { StdFee } from "@cosmjs/launchpad"; import { SigningStargateClient } from "@cosmjs/stargate"; import { Registry, OfflineSigner, EncodeObject, DirectSecp256k1HdWallet } from "@cosmjs/proto-signing"; import { Api } from "./rest"; -import { MsgClaimStakingRewards } from "./types/rewards/tx"; import { MsgCreateTradingReward } from "./types/rewards/tx"; -import { MsgJoinStaking } from "./types/rewards/tx"; import { MsgCreateStakingReward } from "./types/rewards/tx"; import { MsgUpdateStakingReward } from "./types/rewards/tx"; +import { MsgJoinStaking } from "./types/rewards/tx"; import { MsgExitStaking } from "./types/rewards/tx"; +import { MsgClaimStakingRewards } from "./types/rewards/tx"; +import { MsgDistributeStakingRewards } from "./types/rewards/tx"; const types = [ - ["/bze.v1.rewards.MsgClaimStakingRewards", MsgClaimStakingRewards], ["/bze.v1.rewards.MsgCreateTradingReward", MsgCreateTradingReward], - ["/bze.v1.rewards.MsgJoinStaking", MsgJoinStaking], ["/bze.v1.rewards.MsgCreateStakingReward", MsgCreateStakingReward], ["/bze.v1.rewards.MsgUpdateStakingReward", MsgUpdateStakingReward], + ["/bze.v1.rewards.MsgJoinStaking", MsgJoinStaking], ["/bze.v1.rewards.MsgExitStaking", MsgExitStaking], + ["/bze.v1.rewards.MsgClaimStakingRewards", MsgClaimStakingRewards], + ["/bze.v1.rewards.MsgDistributeStakingRewards", MsgDistributeStakingRewards], ]; export const MissingWalletError = new Error("wallet is required"); @@ -51,12 +53,13 @@ const txClient = async (wallet: OfflineSigner, { addr: addr }: TxClientOptions = return { signAndBroadcast: (msgs: EncodeObject[], { fee, memo }: SignAndBroadcastOptions = {fee: defaultFee, memo: ""}) => client.signAndBroadcast(address, msgs, fee,memo), - msgClaimStakingRewards: (data: MsgClaimStakingRewards): EncodeObject => ({ typeUrl: "/bze.v1.rewards.MsgClaimStakingRewards", value: MsgClaimStakingRewards.fromPartial( data ) }), msgCreateTradingReward: (data: MsgCreateTradingReward): EncodeObject => ({ typeUrl: "/bze.v1.rewards.MsgCreateTradingReward", value: MsgCreateTradingReward.fromPartial( data ) }), - msgJoinStaking: (data: MsgJoinStaking): EncodeObject => ({ typeUrl: "/bze.v1.rewards.MsgJoinStaking", value: MsgJoinStaking.fromPartial( data ) }), msgCreateStakingReward: (data: MsgCreateStakingReward): EncodeObject => ({ typeUrl: "/bze.v1.rewards.MsgCreateStakingReward", value: MsgCreateStakingReward.fromPartial( data ) }), msgUpdateStakingReward: (data: MsgUpdateStakingReward): EncodeObject => ({ typeUrl: "/bze.v1.rewards.MsgUpdateStakingReward", value: MsgUpdateStakingReward.fromPartial( data ) }), + msgJoinStaking: (data: MsgJoinStaking): EncodeObject => ({ typeUrl: "/bze.v1.rewards.MsgJoinStaking", value: MsgJoinStaking.fromPartial( data ) }), msgExitStaking: (data: MsgExitStaking): EncodeObject => ({ typeUrl: "/bze.v1.rewards.MsgExitStaking", value: MsgExitStaking.fromPartial( data ) }), + msgClaimStakingRewards: (data: MsgClaimStakingRewards): EncodeObject => ({ typeUrl: "/bze.v1.rewards.MsgClaimStakingRewards", value: MsgClaimStakingRewards.fromPartial( data ) }), + msgDistributeStakingRewards: (data: MsgDistributeStakingRewards): EncodeObject => ({ typeUrl: "/bze.v1.rewards.MsgDistributeStakingRewards", value: MsgDistributeStakingRewards.fromPartial( data ) }), }; }; diff --git a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/rest.ts b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/rest.ts index 00a2b53c..017b8dd2 100644 --- a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/rest.ts +++ b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/rest.ts @@ -30,6 +30,8 @@ export interface RewardsMsgCreateTradingRewardResponse { reward_id?: string; } +export type RewardsMsgDistributeStakingRewardsResponse = object; + export type RewardsMsgExitStakingResponse = object; export type RewardsMsgJoinStakingResponse = object; diff --git a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/tx.ts b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/tx.ts index cbdc9ea8..aba37c47 100644 --- a/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/tx.ts +++ b/vue/src/store/generated/bze-alphateam/bze/bze.v1.rewards/module/types/rewards/tx.ts @@ -72,6 +72,14 @@ export interface MsgClaimStakingRewardsResponse { amount: string; } +export interface MsgDistributeStakingRewards { + creator: string; + rewardId: string; + amount: string; +} + +export interface MsgDistributeStakingRewardsResponse {} + const baseMsgCreateStakingReward: object = { creator: "", prize_amount: "", @@ -1070,6 +1078,165 @@ export const MsgClaimStakingRewardsResponse = { }, }; +const baseMsgDistributeStakingRewards: object = { + creator: "", + rewardId: "", + amount: "", +}; + +export const MsgDistributeStakingRewards = { + encode( + message: MsgDistributeStakingRewards, + writer: Writer = Writer.create() + ): Writer { + if (message.creator !== "") { + writer.uint32(10).string(message.creator); + } + if (message.rewardId !== "") { + writer.uint32(18).string(message.rewardId); + } + if (message.amount !== "") { + writer.uint32(26).string(message.amount); + } + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): MsgDistributeStakingRewards { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseMsgDistributeStakingRewards, + } as MsgDistributeStakingRewards; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + case 1: + message.creator = reader.string(); + break; + case 2: + message.rewardId = reader.string(); + break; + case 3: + message.amount = reader.string(); + break; + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(object: any): MsgDistributeStakingRewards { + const message = { + ...baseMsgDistributeStakingRewards, + } as MsgDistributeStakingRewards; + if (object.creator !== undefined && object.creator !== null) { + message.creator = String(object.creator); + } else { + message.creator = ""; + } + if (object.rewardId !== undefined && object.rewardId !== null) { + message.rewardId = String(object.rewardId); + } else { + message.rewardId = ""; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = String(object.amount); + } else { + message.amount = ""; + } + return message; + }, + + toJSON(message: MsgDistributeStakingRewards): unknown { + const obj: any = {}; + message.creator !== undefined && (obj.creator = message.creator); + message.rewardId !== undefined && (obj.rewardId = message.rewardId); + message.amount !== undefined && (obj.amount = message.amount); + return obj; + }, + + fromPartial( + object: DeepPartial + ): MsgDistributeStakingRewards { + const message = { + ...baseMsgDistributeStakingRewards, + } as MsgDistributeStakingRewards; + if (object.creator !== undefined && object.creator !== null) { + message.creator = object.creator; + } else { + message.creator = ""; + } + if (object.rewardId !== undefined && object.rewardId !== null) { + message.rewardId = object.rewardId; + } else { + message.rewardId = ""; + } + if (object.amount !== undefined && object.amount !== null) { + message.amount = object.amount; + } else { + message.amount = ""; + } + return message; + }, +}; + +const baseMsgDistributeStakingRewardsResponse: object = {}; + +export const MsgDistributeStakingRewardsResponse = { + encode( + _: MsgDistributeStakingRewardsResponse, + writer: Writer = Writer.create() + ): Writer { + return writer; + }, + + decode( + input: Reader | Uint8Array, + length?: number + ): MsgDistributeStakingRewardsResponse { + const reader = input instanceof Uint8Array ? new Reader(input) : input; + let end = length === undefined ? reader.len : reader.pos + length; + const message = { + ...baseMsgDistributeStakingRewardsResponse, + } as MsgDistributeStakingRewardsResponse; + while (reader.pos < end) { + const tag = reader.uint32(); + switch (tag >>> 3) { + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }, + + fromJSON(_: any): MsgDistributeStakingRewardsResponse { + const message = { + ...baseMsgDistributeStakingRewardsResponse, + } as MsgDistributeStakingRewardsResponse; + return message; + }, + + toJSON(_: MsgDistributeStakingRewardsResponse): unknown { + const obj: any = {}; + return obj; + }, + + fromPartial( + _: DeepPartial + ): MsgDistributeStakingRewardsResponse { + const message = { + ...baseMsgDistributeStakingRewardsResponse, + } as MsgDistributeStakingRewardsResponse; + return message; + }, +}; + /** Msg defines the Msg service. */ export interface Msg { CreateStakingReward( @@ -1083,10 +1250,13 @@ export interface Msg { ): Promise; JoinStaking(request: MsgJoinStaking): Promise; ExitStaking(request: MsgExitStaking): Promise; - /** this line is used by starport scaffolding # proto/tx/rpc */ ClaimStakingRewards( request: MsgClaimStakingRewards ): Promise; + /** this line is used by starport scaffolding # proto/tx/rpc */ + DistributeStakingRewards( + request: MsgDistributeStakingRewards + ): Promise; } export class MsgClientImpl implements Msg { @@ -1165,6 +1335,20 @@ export class MsgClientImpl implements Msg { MsgClaimStakingRewardsResponse.decode(new Reader(data)) ); } + + DistributeStakingRewards( + request: MsgDistributeStakingRewards + ): Promise { + const data = MsgDistributeStakingRewards.encode(request).finish(); + const promise = this.rpc.request( + "bze.v1.rewards.Msg", + "DistributeStakingRewards", + data + ); + return promise.then((data) => + MsgDistributeStakingRewardsResponse.decode(new Reader(data)) + ); + } } interface Rpc { diff --git a/x/rewards/client/cli/tx.go b/x/rewards/client/cli/tx.go index 74b0f597..8d370db2 100644 --- a/x/rewards/client/cli/tx.go +++ b/x/rewards/client/cli/tx.go @@ -36,6 +36,7 @@ func GetTxCmd() *cobra.Command { cmd.AddCommand(CmdJoinStaking()) cmd.AddCommand(CmdExitStaking()) cmd.AddCommand(CmdClaimStakingRewards()) + cmd.AddCommand(CmdDistributeStakingRewards()) // this line is used by starport scaffolding # 1 return cmd diff --git a/x/rewards/client/cli/tx_distribute_staking_rewards.go b/x/rewards/client/cli/tx_distribute_staking_rewards.go new file mode 100644 index 00000000..6adb890c --- /dev/null +++ b/x/rewards/client/cli/tx_distribute_staking_rewards.go @@ -0,0 +1,44 @@ +package cli + +import ( + "strconv" + + "github.com/bze-alphateam/bze/x/rewards/types" + "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/client/flags" + "github.com/cosmos/cosmos-sdk/client/tx" + "github.com/spf13/cobra" +) + +var _ = strconv.Itoa(0) + +func CmdDistributeStakingRewards() *cobra.Command { + cmd := &cobra.Command{ + Use: "distribute-staking-rewards [reward-id] [amount]", + Short: "Broadcast message DistributeStakingRewards", + Args: cobra.ExactArgs(2), + RunE: func(cmd *cobra.Command, args []string) (err error) { + argRewardId := args[0] + argAmount := args[1] + + clientCtx, err := client.GetClientTxContext(cmd) + if err != nil { + return err + } + + msg := types.NewMsgDistributeStakingRewards( + clientCtx.GetFromAddress().String(), + argRewardId, + argAmount, + ) + if err := msg.ValidateBasic(); err != nil { + return err + } + return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), msg) + }, + } + + flags.AddTxFlagsToCmd(cmd) + + return cmd +} diff --git a/x/rewards/handler.go b/x/rewards/handler.go index a1ee96f4..5dff6127 100644 --- a/x/rewards/handler.go +++ b/x/rewards/handler.go @@ -35,6 +35,9 @@ func NewHandler(k keeper.Keeper) sdk.Handler { case *types.MsgClaimStakingRewards: res, err := msgServer.ClaimStakingRewards(sdk.WrapSDKContext(ctx), msg) return sdk.WrapServiceResult(ctx, res, err) + case *types.MsgDistributeStakingRewards: + res, err := msgServer.DistributeStakingRewards(sdk.WrapSDKContext(ctx), msg) + return sdk.WrapServiceResult(ctx, res, err) // this line is used by starport scaffolding # 1 default: errMsg := fmt.Sprintf("unrecognized %s message type: %T", types.ModuleName, msg) diff --git a/x/rewards/keeper/msg_server_distribute_staking_rewards.go b/x/rewards/keeper/msg_server_distribute_staking_rewards.go new file mode 100644 index 00000000..d54b1f71 --- /dev/null +++ b/x/rewards/keeper/msg_server_distribute_staking_rewards.go @@ -0,0 +1,46 @@ +package keeper + +import ( + "context" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + + "github.com/bze-alphateam/bze/x/rewards/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +func (k msgServer) DistributeStakingRewards(goCtx context.Context, msg *types.MsgDistributeStakingRewards) (*types.MsgDistributeStakingRewardsResponse, error) { + if msg == nil { + return nil, sdkerrors.ErrInvalidRequest + } + + _, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + return nil, err + } + + amtInt, ok := sdk.NewIntFromString(msg.Amount) + if !ok { + return nil, sdkerrors.Wrapf(types.ErrInvalidAmount, "could not convert order amount") + } + + if !amtInt.IsPositive() { + return nil, sdkerrors.Wrapf(types.ErrInvalidAmount, "amount should be greater than 0") + } + + ctx := sdk.UnwrapSDKContext(goCtx) + stakingReward, isFound := k.GetStakingReward(ctx, msg.RewardId) + if !isFound { + return nil, sdkerrors.Wrap(sdkerrors.ErrKeyNotFound, "staking reward not found") + } + + err = k.distributeStakingRewards(ctx, &stakingReward, msg.Amount) + if err != nil { + return nil, err + } + + k.SetStakingReward(ctx, stakingReward) + + k.Logger(ctx).Debug("staking reward distributed") + + return &types.MsgDistributeStakingRewardsResponse{}, nil +} diff --git a/x/rewards/module_simulation.go b/x/rewards/module_simulation.go index 8e0cd8b4..4a6bab6a 100644 --- a/x/rewards/module_simulation.go +++ b/x/rewards/module_simulation.go @@ -52,6 +52,10 @@ const ( // TODO: Determine the simulation weight value defaultWeightMsgClaimStakingRewards int = 100 + opWeightMsgDistributeStakingRewards = "op_weight_msg_distribute_staking_rewards" + // TODO: Determine the simulation weight value + defaultWeightMsgDistributeStakingRewards int = 100 + // this line is used by starport scaffolding # simapp/module/const ) @@ -178,6 +182,17 @@ func (am AppModule) WeightedOperations(simState module.SimulationState) []simtyp rewardssimulation.SimulateMsgClaimStakingRewards(am.accountKeeper, am.bankKeeper, am.keeper), )) + var weightMsgDistributeStakingRewards int + simState.AppParams.GetOrGenerate(simState.Cdc, opWeightMsgDistributeStakingRewards, &weightMsgDistributeStakingRewards, nil, + func(_ *rand.Rand) { + weightMsgDistributeStakingRewards = defaultWeightMsgDistributeStakingRewards + }, + ) + operations = append(operations, simulation.NewWeightedOperation( + weightMsgDistributeStakingRewards, + rewardssimulation.SimulateMsgDistributeStakingRewards(am.accountKeeper, am.bankKeeper, am.keeper), + )) + // this line is used by starport scaffolding # simapp/module/operation return operations diff --git a/x/rewards/simulation/distribute_staking_rewards.go b/x/rewards/simulation/distribute_staking_rewards.go new file mode 100644 index 00000000..7154bf6c --- /dev/null +++ b/x/rewards/simulation/distribute_staking_rewards.go @@ -0,0 +1,29 @@ +package simulation + +import ( + "math/rand" + + "github.com/bze-alphateam/bze/x/rewards/keeper" + "github.com/bze-alphateam/bze/x/rewards/types" + "github.com/cosmos/cosmos-sdk/baseapp" + sdk "github.com/cosmos/cosmos-sdk/types" + simtypes "github.com/cosmos/cosmos-sdk/types/simulation" +) + +func SimulateMsgDistributeStakingRewards( + ak types.AccountKeeper, + bk types.BankKeeper, + k keeper.Keeper, +) simtypes.Operation { + return func(r *rand.Rand, app *baseapp.BaseApp, ctx sdk.Context, accs []simtypes.Account, chainID string, + ) (simtypes.OperationMsg, []simtypes.FutureOperation, error) { + simAccount, _ := simtypes.RandomAcc(r, accs) + msg := &types.MsgDistributeStakingRewards{ + Creator: simAccount.Address.String(), + } + + // TODO: Handling the DistributeStakingRewards simulation + + return simtypes.NoOpMsg(types.ModuleName, msg.Type(), "DistributeStakingRewards simulation not implemented"), nil, nil + } +} diff --git a/x/rewards/types/codec.go b/x/rewards/types/codec.go index bf0bffcc..250d107b 100644 --- a/x/rewards/types/codec.go +++ b/x/rewards/types/codec.go @@ -14,6 +14,7 @@ func RegisterCodec(cdc *codec.LegacyAmino) { cdc.RegisterConcrete(&MsgJoinStaking{}, "rewards/JoinStaking", nil) cdc.RegisterConcrete(&MsgExitStaking{}, "rewards/ExitStaking", nil) cdc.RegisterConcrete(&MsgClaimStakingRewards{}, "rewards/ClaimStakingRewards", nil) + cdc.RegisterConcrete(&MsgDistributeStakingRewards{}, "rewards/DistributeStakingRewards", nil) // this line is used by starport scaffolding # 2 } @@ -34,6 +35,9 @@ func RegisterInterfaces(registry cdctypes.InterfaceRegistry) { registry.RegisterImplementations((*sdk.Msg)(nil), &MsgClaimStakingRewards{}, ) + registry.RegisterImplementations((*sdk.Msg)(nil), + &MsgDistributeStakingRewards{}, + ) // this line is used by starport scaffolding # 3 msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc) diff --git a/x/rewards/types/message_distribute_staking_rewards.go b/x/rewards/types/message_distribute_staking_rewards.go new file mode 100644 index 00000000..8a98674d --- /dev/null +++ b/x/rewards/types/message_distribute_staking_rewards.go @@ -0,0 +1,57 @@ +package types + +import ( + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +const TypeMsgDistributeStakingRewards = "distribute_staking_rewards" + +var _ sdk.Msg = &MsgDistributeStakingRewards{} + +func NewMsgDistributeStakingRewards(creator string, rewardId string, amount string) *MsgDistributeStakingRewards { + return &MsgDistributeStakingRewards{ + Creator: creator, + RewardId: rewardId, + Amount: amount, + } +} + +func (msg *MsgDistributeStakingRewards) Route() string { + return RouterKey +} + +func (msg *MsgDistributeStakingRewards) Type() string { + return TypeMsgDistributeStakingRewards +} + +func (msg *MsgDistributeStakingRewards) GetSigners() []sdk.AccAddress { + creator, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + panic(err) + } + return []sdk.AccAddress{creator} +} + +func (msg *MsgDistributeStakingRewards) GetSignBytes() []byte { + bz := ModuleCdc.MustMarshalJSON(msg) + return sdk.MustSortJSON(bz) +} + +func (msg *MsgDistributeStakingRewards) ValidateBasic() error { + _, err := sdk.AccAddressFromBech32(msg.Creator) + if err != nil { + return sdkerrors.Wrapf(sdkerrors.ErrInvalidAddress, "invalid creator address (%s)", err) + } + + amtInt, ok := sdk.NewIntFromString(msg.Amount) + if !ok { + return sdkerrors.Wrapf(ErrInvalidAmount, "could not convert order amount") + } + + if !amtInt.IsPositive() { + return sdkerrors.Wrapf(ErrInvalidAmount, "amount should be greater than 0") + } + + return nil +} diff --git a/x/rewards/types/message_distribute_staking_rewards_test.go b/x/rewards/types/message_distribute_staking_rewards_test.go new file mode 100644 index 00000000..90c1815d --- /dev/null +++ b/x/rewards/types/message_distribute_staking_rewards_test.go @@ -0,0 +1,40 @@ +package types + +import ( + "testing" + + "github.com/bze-alphateam/bze/testutil/sample" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/stretchr/testify/require" +) + +func TestMsgDistributeStakingRewards_ValidateBasic(t *testing.T) { + tests := []struct { + name string + msg MsgDistributeStakingRewards + err error + }{ + { + name: "invalid address", + msg: MsgDistributeStakingRewards{ + Creator: "invalid_address", + }, + err: sdkerrors.ErrInvalidAddress, + }, { + name: "valid address", + msg: MsgDistributeStakingRewards{ + Creator: sample.AccAddress(), + }, + }, + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + err := tt.msg.ValidateBasic() + if tt.err != nil { + require.ErrorIs(t, err, tt.err) + return + } + require.NoError(t, err) + }) + } +} diff --git a/x/rewards/types/tx.pb.go b/x/rewards/types/tx.pb.go index a30c2ee8..6c3b4e80 100644 --- a/x/rewards/types/tx.pb.go +++ b/x/rewards/types/tx.pb.go @@ -667,6 +667,102 @@ func (m *MsgClaimStakingRewardsResponse) GetAmount() string { return "" } +type MsgDistributeStakingRewards struct { + Creator string `protobuf:"bytes,1,opt,name=creator,proto3" json:"creator,omitempty"` + RewardId string `protobuf:"bytes,2,opt,name=rewardId,proto3" json:"rewardId,omitempty"` + Amount string `protobuf:"bytes,3,opt,name=amount,proto3" json:"amount,omitempty"` +} + +func (m *MsgDistributeStakingRewards) Reset() { *m = MsgDistributeStakingRewards{} } +func (m *MsgDistributeStakingRewards) String() string { return proto.CompactTextString(m) } +func (*MsgDistributeStakingRewards) ProtoMessage() {} +func (*MsgDistributeStakingRewards) Descriptor() ([]byte, []int) { + return fileDescriptor_4c0d543e6be8610a, []int{12} +} +func (m *MsgDistributeStakingRewards) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgDistributeStakingRewards) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgDistributeStakingRewards.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 *MsgDistributeStakingRewards) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgDistributeStakingRewards.Merge(m, src) +} +func (m *MsgDistributeStakingRewards) XXX_Size() int { + return m.Size() +} +func (m *MsgDistributeStakingRewards) XXX_DiscardUnknown() { + xxx_messageInfo_MsgDistributeStakingRewards.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgDistributeStakingRewards proto.InternalMessageInfo + +func (m *MsgDistributeStakingRewards) GetCreator() string { + if m != nil { + return m.Creator + } + return "" +} + +func (m *MsgDistributeStakingRewards) GetRewardId() string { + if m != nil { + return m.RewardId + } + return "" +} + +func (m *MsgDistributeStakingRewards) GetAmount() string { + if m != nil { + return m.Amount + } + return "" +} + +type MsgDistributeStakingRewardsResponse struct { +} + +func (m *MsgDistributeStakingRewardsResponse) Reset() { *m = MsgDistributeStakingRewardsResponse{} } +func (m *MsgDistributeStakingRewardsResponse) String() string { return proto.CompactTextString(m) } +func (*MsgDistributeStakingRewardsResponse) ProtoMessage() {} +func (*MsgDistributeStakingRewardsResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_4c0d543e6be8610a, []int{13} +} +func (m *MsgDistributeStakingRewardsResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *MsgDistributeStakingRewardsResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_MsgDistributeStakingRewardsResponse.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 *MsgDistributeStakingRewardsResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_MsgDistributeStakingRewardsResponse.Merge(m, src) +} +func (m *MsgDistributeStakingRewardsResponse) XXX_Size() int { + return m.Size() +} +func (m *MsgDistributeStakingRewardsResponse) XXX_DiscardUnknown() { + xxx_messageInfo_MsgDistributeStakingRewardsResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_MsgDistributeStakingRewardsResponse proto.InternalMessageInfo + func init() { proto.RegisterType((*MsgCreateStakingReward)(nil), "bze.v1.rewards.MsgCreateStakingReward") proto.RegisterType((*MsgCreateStakingRewardResponse)(nil), "bze.v1.rewards.MsgCreateStakingRewardResponse") @@ -680,47 +776,52 @@ func init() { proto.RegisterType((*MsgExitStakingResponse)(nil), "bze.v1.rewards.MsgExitStakingResponse") proto.RegisterType((*MsgClaimStakingRewards)(nil), "bze.v1.rewards.MsgClaimStakingRewards") proto.RegisterType((*MsgClaimStakingRewardsResponse)(nil), "bze.v1.rewards.MsgClaimStakingRewardsResponse") + proto.RegisterType((*MsgDistributeStakingRewards)(nil), "bze.v1.rewards.MsgDistributeStakingRewards") + proto.RegisterType((*MsgDistributeStakingRewardsResponse)(nil), "bze.v1.rewards.MsgDistributeStakingRewardsResponse") } func init() { proto.RegisterFile("rewards/tx.proto", fileDescriptor_4c0d543e6be8610a) } var fileDescriptor_4c0d543e6be8610a = []byte{ - // 557 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x55, 0x4d, 0x6f, 0xd3, 0x30, - 0x18, 0x6e, 0xd6, 0xae, 0xdb, 0xde, 0x8d, 0x09, 0x79, 0x68, 0x8a, 0x8a, 0x14, 0x46, 0x90, 0x26, - 0x0e, 0x90, 0x0a, 0xb8, 0x70, 0xe1, 0xc0, 0xd7, 0xa4, 0x21, 0x95, 0x43, 0x61, 0x17, 0x2e, 0x91, - 0xdb, 0x58, 0x99, 0xd5, 0x26, 0x8e, 0x62, 0x17, 0x4a, 0x7f, 0x05, 0x7f, 0x0a, 0x89, 0xe3, 0x8e, - 0x1c, 0x51, 0x7b, 0xe1, 0xc6, 0x5f, 0x40, 0xb1, 0xbd, 0xcc, 0x66, 0x5e, 0x19, 0x3d, 0x70, 0xeb, - 0xfb, 0xd1, 0xf7, 0xf1, 0xf3, 0x3c, 0xaf, 0x63, 0xb8, 0x59, 0x92, 0x4f, 0xb8, 0x4c, 0x78, 0x57, - 0x4c, 0xa3, 0xa2, 0x64, 0x82, 0xa1, 0xdd, 0xc1, 0x8c, 0x44, 0x1f, 0x1f, 0x45, 0xba, 0x10, 0xfe, - 0xf4, 0x60, 0xbf, 0xc7, 0xd3, 0x97, 0x25, 0xc1, 0x82, 0xbc, 0x13, 0x78, 0x44, 0xf3, 0xb4, 0x2f, - 0x6b, 0xc8, 0x87, 0x8d, 0x61, 0x95, 0x66, 0xa5, 0xef, 0x1d, 0x78, 0xf7, 0xb7, 0xfa, 0xe7, 0x21, - 0xba, 0x0b, 0x3b, 0x45, 0x49, 0x67, 0x24, 0xc6, 0x19, 0x9b, 0xe4, 0xc2, 0x5f, 0x93, 0xe5, 0x6d, - 0x99, 0x7b, 0x2e, 0x53, 0xe8, 0x0e, 0xa8, 0x30, 0x4e, 0x48, 0xce, 0x32, 0xbf, 0x29, 0x3b, 0x40, - 0xa6, 0x5e, 0x55, 0x19, 0x74, 0x0f, 0x6e, 0x70, 0x05, 0xa7, 0x5b, 0x5a, 0xb2, 0x65, 0x47, 0x27, - 0x55, 0x53, 0x07, 0x36, 0x93, 0x49, 0x89, 0x05, 0x65, 0xb9, 0xbf, 0x2e, 0xeb, 0x75, 0x8c, 0x6e, - 0xc3, 0x56, 0x46, 0xf3, 0xb8, 0xea, 0x27, 0x7e, 0x5b, 0x15, 0x33, 0x9a, 0x57, 0x1c, 0x08, 0x42, - 0xd0, 0x1a, 0xb3, 0xe1, 0xc8, 0xdf, 0x90, 0x79, 0xf9, 0x3b, 0x7c, 0x06, 0x81, 0x9b, 0x69, 0x9f, - 0xf0, 0x82, 0xe5, 0x9c, 0x54, 0x23, 0x95, 0x2e, 0x31, 0x4d, 0x34, 0xe7, 0x4d, 0x95, 0x38, 0x4e, - 0xc2, 0x91, 0x14, 0xea, 0xa4, 0x48, 0xfe, 0x41, 0x28, 0x6b, 0xe0, 0x9a, 0x3d, 0xd0, 0x22, 0xd7, - 0xb4, 0xc9, 0x85, 0x07, 0xf2, 0xac, 0x0e, 0xb0, 0xf3, 0xb3, 0x86, 0x5f, 0x4d, 0xe3, 0xde, 0x97, - 0x38, 0xf9, 0x5f, 0xc6, 0x99, 0xc7, 0x6e, 0x39, 0x3c, 0xc1, 0xe5, 0x88, 0x88, 0x8a, 0xaf, 0x36, - 0x4c, 0x25, 0x8e, 0x13, 0x74, 0x0b, 0xd6, 0xf9, 0x98, 0x09, 0xae, 0xcd, 0x52, 0x81, 0xe5, 0x8a, - 0x45, 0xe3, 0x7a, 0xae, 0xc4, 0xb0, 0xdb, 0xe3, 0xe9, 0x1b, 0xa6, 0x8c, 0xa7, 0x79, 0xba, 0xaa, - 0x1b, 0xfb, 0xd0, 0xd6, 0xa2, 0x28, 0xca, 0x3a, 0x0a, 0x7d, 0x29, 0xb3, 0x01, 0x50, 0x3b, 0x70, - 0x24, 0xa1, 0x5f, 0x4f, 0xa9, 0xf8, 0x3b, 0x74, 0x07, 0x6a, 0xa4, 0x3f, 0x91, 0x35, 0x82, 0x31, - 0xa7, 0x46, 0x78, 0xab, 0x2c, 0x1e, 0x63, 0x9a, 0x59, 0x4b, 0xc0, 0x57, 0x44, 0x7a, 0xaa, 0xb4, - 0xbe, 0x3c, 0xaf, 0xd6, 0xfa, 0x42, 0x05, 0xcf, 0x54, 0xe1, 0xf1, 0xaf, 0x16, 0x34, 0x7b, 0x3c, - 0x45, 0x19, 0xec, 0xb9, 0x3e, 0x15, 0x87, 0x91, 0xfd, 0x59, 0x89, 0xdc, 0x17, 0xad, 0x13, 0x5d, - 0xaf, 0xaf, 0x3e, 0x4e, 0x06, 0x7b, 0xae, 0x0b, 0xe7, 0x82, 0x73, 0xf4, 0x39, 0xe1, 0x96, 0xdc, - 0xa9, 0x0b, 0x76, 0xf6, 0x7d, 0xba, 0x9a, 0x9d, 0xd5, 0xb7, 0x84, 0x9d, 0x7b, 0xb1, 0x4f, 0x60, - 0xdb, 0x5c, 0xdc, 0xc0, 0xf1, 0x77, 0xa3, 0xde, 0x39, 0x5c, 0x5e, 0x37, 0xc7, 0x9a, 0x4b, 0xe9, - 0x1a, 0x6b, 0xd4, 0x9d, 0x63, 0x1d, 0xcb, 0x28, 0xc5, 0x71, 0x6c, 0xa2, 0x53, 0x9c, 0xcb, 0x7d, - 0x6e, 0x71, 0xae, 0xde, 0xc4, 0x17, 0x47, 0xdf, 0xe6, 0x81, 0x77, 0x36, 0x0f, 0xbc, 0x1f, 0xf3, - 0xc0, 0xfb, 0xb2, 0x08, 0x1a, 0x67, 0x8b, 0xa0, 0xf1, 0x7d, 0x11, 0x34, 0x3e, 0x3c, 0x48, 0xa9, - 0x38, 0x9d, 0x0c, 0xa2, 0x21, 0xcb, 0xba, 0x83, 0x19, 0x79, 0x88, 0xc7, 0xc5, 0x29, 0x16, 0x04, - 0xcb, 0xa8, 0x3b, 0xed, 0xd6, 0x6f, 0xde, 0xe7, 0x82, 0xf0, 0x41, 0x5b, 0xbe, 0x7b, 0x4f, 0x7e, - 0x07, 0x00, 0x00, 0xff, 0xff, 0x17, 0x12, 0xfe, 0xbb, 0x0b, 0x07, 0x00, 0x00, + // 602 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x56, 0x4d, 0x6f, 0xd3, 0x40, + 0x10, 0x8d, 0x9b, 0x8f, 0xb6, 0xd3, 0x52, 0x21, 0x17, 0x55, 0x56, 0x2a, 0x99, 0xe2, 0x8a, 0x0a, + 0x09, 0x70, 0x04, 0xbd, 0x70, 0xe1, 0x00, 0x94, 0x4a, 0x45, 0x0a, 0x87, 0x40, 0x2f, 0x5c, 0xa2, + 0x4d, 0xbc, 0x72, 0x57, 0x89, 0xbd, 0xd6, 0xee, 0x06, 0x42, 0xc4, 0x8f, 0xe0, 0x4f, 0x21, 0x71, + 0xec, 0x91, 0x23, 0x4a, 0x2e, 0x5c, 0xf8, 0x0f, 0xc8, 0xbb, 0x8e, 0xeb, 0x6d, 0x37, 0xa6, 0xcd, + 0xa1, 0xb7, 0xec, 0xcc, 0xcb, 0xbc, 0x7d, 0xef, 0x79, 0x2c, 0xc3, 0x5d, 0x86, 0xbf, 0x20, 0x16, + 0xf0, 0x96, 0x18, 0xfb, 0x09, 0xa3, 0x82, 0xda, 0x5b, 0xbd, 0x09, 0xf6, 0x3f, 0x3f, 0xf3, 0xb3, + 0x86, 0xf7, 0xc7, 0x82, 0x9d, 0x36, 0x0f, 0xdf, 0x30, 0x8c, 0x04, 0xfe, 0x20, 0xd0, 0x80, 0xc4, + 0x61, 0x47, 0xf6, 0x6c, 0x07, 0x56, 0xfb, 0x69, 0x99, 0x32, 0xc7, 0xda, 0xb3, 0x1e, 0xad, 0x77, + 0xe6, 0x47, 0xfb, 0x01, 0x6c, 0x26, 0x8c, 0x4c, 0x70, 0x17, 0x45, 0x74, 0x14, 0x0b, 0x67, 0x45, + 0xb6, 0x37, 0x64, 0xed, 0x95, 0x2c, 0xd9, 0xf7, 0x41, 0x1d, 0xbb, 0x01, 0x8e, 0x69, 0xe4, 0x54, + 0x25, 0x02, 0x64, 0xe9, 0x28, 0xad, 0xd8, 0xfb, 0x70, 0x87, 0x2b, 0xba, 0x0c, 0x52, 0x93, 0x90, + 0xcd, 0xac, 0xa8, 0x40, 0x4d, 0x58, 0x0b, 0x46, 0x0c, 0x09, 0x42, 0x63, 0xa7, 0x2e, 0xfb, 0xf9, + 0xd9, 0xde, 0x85, 0xf5, 0x88, 0xc4, 0xdd, 0x14, 0x8f, 0x9d, 0x86, 0x6a, 0x46, 0x24, 0x4e, 0x35, + 0x60, 0xdb, 0x86, 0xda, 0x90, 0xf6, 0x07, 0xce, 0xaa, 0xac, 0xcb, 0xdf, 0xde, 0x4b, 0x70, 0xcd, + 0x4a, 0x3b, 0x98, 0x27, 0x34, 0xe6, 0x38, 0x1d, 0xa9, 0x7c, 0xe9, 0x92, 0x20, 0xd3, 0xbc, 0xa6, + 0x0a, 0x27, 0x81, 0x37, 0x90, 0x46, 0x9d, 0x26, 0xc1, 0x0d, 0x8c, 0xd2, 0x06, 0xae, 0xe8, 0x03, + 0x35, 0x71, 0x55, 0x5d, 0x9c, 0xb7, 0x27, 0xef, 0x6a, 0x20, 0x9b, 0xdf, 0xd5, 0xfb, 0x51, 0x0c, + 0xee, 0x23, 0x43, 0xc1, 0x6d, 0x05, 0x57, 0xbc, 0x76, 0xcd, 0x90, 0x09, 0x62, 0x03, 0x2c, 0x52, + 0xbd, 0x59, 0x60, 0xaa, 0x70, 0x12, 0xd8, 0xf7, 0xa0, 0xce, 0x87, 0x54, 0xf0, 0x2c, 0x2c, 0x75, + 0xd0, 0x52, 0xd1, 0x64, 0x5c, 0x2f, 0x95, 0x2e, 0x6c, 0xb5, 0x79, 0xf8, 0x8e, 0xaa, 0xe0, 0x49, + 0x1c, 0x2e, 0x9b, 0xc6, 0x0e, 0x34, 0x32, 0x53, 0x94, 0xe4, 0xec, 0xe4, 0x39, 0xd2, 0xe6, 0x02, + 0x41, 0x9e, 0xc0, 0xb1, 0xa4, 0x7e, 0x3b, 0x26, 0xe2, 0xff, 0xd4, 0x4d, 0xc8, 0x99, 0x2e, 0x33, + 0x67, 0x0c, 0x85, 0x39, 0x39, 0xc3, 0x7b, 0x15, 0xf1, 0x10, 0x91, 0x48, 0x7b, 0x08, 0xf8, 0x92, + 0x4c, 0x2f, 0x94, 0xd7, 0x57, 0xe7, 0xe5, 0x5e, 0x5f, 0xb8, 0x60, 0x69, 0x2e, 0x0c, 0x60, 0xb7, + 0xcd, 0xc3, 0x23, 0xc2, 0x05, 0x23, 0xbd, 0xd1, 0xa5, 0x67, 0x72, 0xc9, 0xeb, 0x2c, 0xb4, 0xfc, + 0x21, 0xec, 0x97, 0x90, 0xcd, 0xef, 0xfa, 0xfc, 0x6f, 0x1d, 0xaa, 0x6d, 0x1e, 0xda, 0x11, 0x6c, + 0x9b, 0x5e, 0x5f, 0x07, 0xbe, 0xfe, 0xaa, 0xf3, 0xcd, 0xcb, 0xdf, 0xf4, 0xaf, 0x87, 0xcb, 0x2d, + 0x8a, 0x60, 0xdb, 0xf4, 0x12, 0x30, 0xd1, 0x19, 0x70, 0x46, 0xba, 0x92, 0x3d, 0xbf, 0x50, 0xa7, + 0xef, 0xf8, 0x62, 0x75, 0x1a, 0xae, 0x44, 0x9d, 0x79, 0xd9, 0x4e, 0x61, 0xa3, 0xb8, 0x4c, 0xae, + 0xe1, 0xef, 0x85, 0x7e, 0xf3, 0xa0, 0xbc, 0x5f, 0x1c, 0x5b, 0x5c, 0x14, 0xd3, 0xd8, 0x42, 0xdf, + 0x38, 0xd6, 0xb0, 0x20, 0xd2, 0x1c, 0xc3, 0x76, 0x18, 0xcd, 0xb9, 0x8a, 0x33, 0x9b, 0x53, 0xb2, + 0x1d, 0xdf, 0xc0, 0x59, 0xb8, 0x02, 0x8f, 0x0d, 0xb3, 0x16, 0x81, 0x9b, 0x87, 0x37, 0x00, 0xcf, + 0xd9, 0x5f, 0x1f, 0xff, 0x9c, 0xba, 0xd6, 0xf9, 0xd4, 0xb5, 0x7e, 0x4f, 0x5d, 0xeb, 0xfb, 0xcc, + 0xad, 0x9c, 0xcf, 0xdc, 0xca, 0xaf, 0x99, 0x5b, 0xf9, 0xf4, 0x24, 0x24, 0xe2, 0x6c, 0xd4, 0xf3, + 0xfb, 0x34, 0x6a, 0xf5, 0x26, 0xf8, 0x29, 0x1a, 0x26, 0x67, 0x48, 0x60, 0x24, 0x4f, 0xad, 0x71, + 0x2b, 0xff, 0x0a, 0xf8, 0x9a, 0x60, 0xde, 0x6b, 0xc8, 0x2f, 0x81, 0xc3, 0x7f, 0x01, 0x00, 0x00, + 0xff, 0xff, 0x40, 0x2e, 0x11, 0x1c, 0x1d, 0x08, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -741,6 +842,7 @@ type MsgClient interface { JoinStaking(ctx context.Context, in *MsgJoinStaking, opts ...grpc.CallOption) (*MsgJoinStakingResponse, error) ExitStaking(ctx context.Context, in *MsgExitStaking, opts ...grpc.CallOption) (*MsgExitStakingResponse, error) ClaimStakingRewards(ctx context.Context, in *MsgClaimStakingRewards, opts ...grpc.CallOption) (*MsgClaimStakingRewardsResponse, error) + DistributeStakingRewards(ctx context.Context, in *MsgDistributeStakingRewards, opts ...grpc.CallOption) (*MsgDistributeStakingRewardsResponse, error) } type msgClient struct { @@ -805,6 +907,15 @@ func (c *msgClient) ClaimStakingRewards(ctx context.Context, in *MsgClaimStaking return out, nil } +func (c *msgClient) DistributeStakingRewards(ctx context.Context, in *MsgDistributeStakingRewards, opts ...grpc.CallOption) (*MsgDistributeStakingRewardsResponse, error) { + out := new(MsgDistributeStakingRewardsResponse) + err := c.cc.Invoke(ctx, "/bze.v1.rewards.Msg/DistributeStakingRewards", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + // MsgServer is the server API for Msg service. type MsgServer interface { CreateStakingReward(context.Context, *MsgCreateStakingReward) (*MsgCreateStakingRewardResponse, error) @@ -813,6 +924,7 @@ type MsgServer interface { JoinStaking(context.Context, *MsgJoinStaking) (*MsgJoinStakingResponse, error) ExitStaking(context.Context, *MsgExitStaking) (*MsgExitStakingResponse, error) ClaimStakingRewards(context.Context, *MsgClaimStakingRewards) (*MsgClaimStakingRewardsResponse, error) + DistributeStakingRewards(context.Context, *MsgDistributeStakingRewards) (*MsgDistributeStakingRewardsResponse, error) } // UnimplementedMsgServer can be embedded to have forward compatible implementations. @@ -837,6 +949,9 @@ func (*UnimplementedMsgServer) ExitStaking(ctx context.Context, req *MsgExitStak func (*UnimplementedMsgServer) ClaimStakingRewards(ctx context.Context, req *MsgClaimStakingRewards) (*MsgClaimStakingRewardsResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method ClaimStakingRewards not implemented") } +func (*UnimplementedMsgServer) DistributeStakingRewards(ctx context.Context, req *MsgDistributeStakingRewards) (*MsgDistributeStakingRewardsResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method DistributeStakingRewards not implemented") +} func RegisterMsgServer(s grpc1.Server, srv MsgServer) { s.RegisterService(&_Msg_serviceDesc, srv) @@ -950,6 +1065,24 @@ func _Msg_ClaimStakingRewards_Handler(srv interface{}, ctx context.Context, dec return interceptor(ctx, in, info, handler) } +func _Msg_DistributeStakingRewards_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(MsgDistributeStakingRewards) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(MsgServer).DistributeStakingRewards(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/bze.v1.rewards.Msg/DistributeStakingRewards", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(MsgServer).DistributeStakingRewards(ctx, req.(*MsgDistributeStakingRewards)) + } + return interceptor(ctx, in, info, handler) +} + var _Msg_serviceDesc = grpc.ServiceDesc{ ServiceName: "bze.v1.rewards.Msg", HandlerType: (*MsgServer)(nil), @@ -978,6 +1111,10 @@ var _Msg_serviceDesc = grpc.ServiceDesc{ MethodName: "ClaimStakingRewards", Handler: _Msg_ClaimStakingRewards_Handler, }, + { + MethodName: "DistributeStakingRewards", + Handler: _Msg_DistributeStakingRewards_Handler, + }, }, Streams: []grpc.StreamDesc{}, Metadata: "rewards/tx.proto", @@ -1441,6 +1578,73 @@ func (m *MsgClaimStakingRewardsResponse) MarshalToSizedBuffer(dAtA []byte) (int, return len(dAtA) - i, nil } +func (m *MsgDistributeStakingRewards) 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 *MsgDistributeStakingRewards) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgDistributeStakingRewards) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Amount) > 0 { + i -= len(m.Amount) + copy(dAtA[i:], m.Amount) + i = encodeVarintTx(dAtA, i, uint64(len(m.Amount))) + i-- + dAtA[i] = 0x1a + } + if len(m.RewardId) > 0 { + i -= len(m.RewardId) + copy(dAtA[i:], m.RewardId) + i = encodeVarintTx(dAtA, i, uint64(len(m.RewardId))) + i-- + dAtA[i] = 0x12 + } + if len(m.Creator) > 0 { + i -= len(m.Creator) + copy(dAtA[i:], m.Creator) + i = encodeVarintTx(dAtA, i, uint64(len(m.Creator))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *MsgDistributeStakingRewardsResponse) 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 *MsgDistributeStakingRewardsResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *MsgDistributeStakingRewardsResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + func encodeVarintTx(dAtA []byte, offset int, v uint64) int { offset -= sovTx(v) base := offset @@ -1664,6 +1868,36 @@ func (m *MsgClaimStakingRewardsResponse) Size() (n int) { return n } +func (m *MsgDistributeStakingRewards) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Creator) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.RewardId) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + l = len(m.Amount) + if l > 0 { + n += 1 + l + sovTx(uint64(l)) + } + return n +} + +func (m *MsgDistributeStakingRewardsResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + func sovTx(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -3102,6 +3336,202 @@ func (m *MsgClaimStakingRewardsResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *MsgDistributeStakingRewards) 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 ErrIntOverflowTx + } + 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: MsgDistributeStakingRewards: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgDistributeStakingRewards: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Creator", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Creator = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RewardId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.RewardId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTx + } + 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 ErrInvalidLengthTx + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTx + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Amount = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *MsgDistributeStakingRewardsResponse) 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 ErrIntOverflowTx + } + 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: MsgDistributeStakingRewardsResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: MsgDistributeStakingRewardsResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipTx(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTx + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipTx(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 From 9fa71eb913a43fc19ae32fad9ff9fe42da018c00 Mon Sep 17 00:00:00 2001 From: faneaatiku Date: Fri, 19 Apr 2024 01:17:54 +0300 Subject: [PATCH 31/35] fixed broken tests and commented outdated ones --- testutil/keeper/epochs.go | 1 - testutil/keeper/rewards.go | 1 + ...c_query_staking_reward_participant_test.go | 224 +++++++++--------- .../keeper/grpc_query_trading_reward_test.go | 224 +++++++++--------- .../keeper/msg_server_trading_reward_test.go | 8 +- .../keeper/staking_reward_participant_test.go | 101 ++++---- 6 files changed, 266 insertions(+), 293 deletions(-) diff --git a/testutil/keeper/epochs.go b/testutil/keeper/epochs.go index bc52bd4a..40c85837 100644 --- a/testutil/keeper/epochs.go +++ b/testutil/keeper/epochs.go @@ -33,7 +33,6 @@ func EpochsKeeper(t testing.TB) (*keeper.Keeper, sdk.Context) { cdc, storeKey, memStoreKey, - nil, ) ctx := sdk.NewContext(stateStore, tmproto.Header{}, false, log.NewNopLogger()) diff --git a/testutil/keeper/rewards.go b/testutil/keeper/rewards.go index 6d9a808a..543dcae1 100644 --- a/testutil/keeper/rewards.go +++ b/testutil/keeper/rewards.go @@ -44,6 +44,7 @@ func RewardsKeeper(t testing.TB) (*keeper.Keeper, sdk.Context) { nil, nil, nil, + nil, ) ctx := sdk.NewContext(stateStore, tmproto.Header{}, false, log.NewNopLogger()) diff --git a/x/rewards/keeper/grpc_query_staking_reward_participant_test.go b/x/rewards/keeper/grpc_query_staking_reward_participant_test.go index b1b6d370..e6f96a12 100644 --- a/x/rewards/keeper/grpc_query_staking_reward_participant_test.go +++ b/x/rewards/keeper/grpc_query_staking_reward_participant_test.go @@ -2,125 +2,115 @@ package keeper_test import ( "strconv" - "testing" - - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/query" - "github.com/stretchr/testify/require" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/status" - - keepertest "github.com/bze-alphateam/bze/testutil/keeper" - "github.com/bze-alphateam/bze/testutil/nullify" - "github.com/bze-alphateam/bze/x/rewards/types" ) // Prevent strconv unused error var _ = strconv.IntSize -func TestStakingRewardParticipantQuerySingle(t *testing.T) { - keeper, ctx := keepertest.RewardsKeeper(t) - wctx := sdk.WrapSDKContext(ctx) - msgs := createNStakingRewardParticipant(keeper, ctx, 2) - for _, tc := range []struct { - desc string - request *types.QueryGetStakingRewardParticipantRequest - response *types.QueryGetStakingRewardParticipantResponse - err error - }{ - { - desc: "First", - request: &types.QueryGetStakingRewardParticipantRequest{ - Index: msgs[0].Index, - }, - response: &types.QueryGetStakingRewardParticipantResponse{StakingRewardParticipant: msgs[0]}, - }, - { - desc: "Second", - request: &types.QueryGetStakingRewardParticipantRequest{ - Index: msgs[1].Index, - }, - response: &types.QueryGetStakingRewardParticipantResponse{StakingRewardParticipant: msgs[1]}, - }, - { - desc: "KeyNotFound", - request: &types.QueryGetStakingRewardParticipantRequest{ - Index: strconv.Itoa(100000), - }, - err: status.Error(codes.NotFound, "not found"), - }, - { - desc: "InvalidRequest", - err: status.Error(codes.InvalidArgument, "invalid request"), - }, - } { - t.Run(tc.desc, func(t *testing.T) { - response, err := keeper.StakingRewardParticipant(wctx, tc.request) - if tc.err != nil { - require.ErrorIs(t, err, tc.err) - } else { - require.NoError(t, err) - require.Equal(t, - nullify.Fill(tc.response), - nullify.Fill(response), - ) - } - }) - } -} - -func TestStakingRewardParticipantQueryPaginated(t *testing.T) { - keeper, ctx := keepertest.RewardsKeeper(t) - wctx := sdk.WrapSDKContext(ctx) - msgs := createNStakingRewardParticipant(keeper, ctx, 5) - - request := func(next []byte, offset, limit uint64, total bool) *types.QueryAllStakingRewardParticipantRequest { - return &types.QueryAllStakingRewardParticipantRequest{ - Pagination: &query.PageRequest{ - Key: next, - Offset: offset, - Limit: limit, - CountTotal: total, - }, - } - } - t.Run("ByOffset", func(t *testing.T) { - step := 2 - for i := 0; i < len(msgs); i += step { - resp, err := keeper.StakingRewardParticipantAll(wctx, request(nil, uint64(i), uint64(step), false)) - require.NoError(t, err) - require.LessOrEqual(t, len(resp.StakingRewardParticipant), step) - require.Subset(t, - nullify.Fill(msgs), - nullify.Fill(resp.StakingRewardParticipant), - ) - } - }) - t.Run("ByKey", func(t *testing.T) { - step := 2 - var next []byte - for i := 0; i < len(msgs); i += step { - resp, err := keeper.StakingRewardParticipantAll(wctx, request(next, 0, uint64(step), false)) - require.NoError(t, err) - require.LessOrEqual(t, len(resp.StakingRewardParticipant), step) - require.Subset(t, - nullify.Fill(msgs), - nullify.Fill(resp.StakingRewardParticipant), - ) - next = resp.Pagination.NextKey - } - }) - t.Run("Total", func(t *testing.T) { - resp, err := keeper.StakingRewardParticipantAll(wctx, request(nil, 0, 0, true)) - require.NoError(t, err) - require.Equal(t, len(msgs), int(resp.Pagination.Total)) - require.ElementsMatch(t, - nullify.Fill(msgs), - nullify.Fill(resp.StakingRewardParticipant), - ) - }) - t.Run("InvalidRequest", func(t *testing.T) { - _, err := keeper.StakingRewardParticipantAll(wctx, nil) - require.ErrorIs(t, err, status.Error(codes.InvalidArgument, "invalid request")) - }) -} +// +//func TestStakingRewardParticipantQuerySingle(t *testing.T) { +// keeper, ctx := keepertest.RewardsKeeper(t) +// wctx := sdk.WrapSDKContext(ctx) +// msgs := createNStakingRewardParticipant(keeper, ctx, 2) +// for _, tc := range []struct { +// desc string +// request *types.QueryGetStakingRewardParticipantRequest +// response *types.QueryGetStakingRewardParticipantResponse +// err error +// }{ +// { +// desc: "First", +// request: &types.QueryGetStakingRewardParticipantRequest{ +// Index: msgs[0].Index, +// }, +// response: &types.QueryGetStakingRewardParticipantResponse{StakingRewardParticipant: msgs[0]}, +// }, +// { +// desc: "Second", +// request: &types.QueryGetStakingRewardParticipantRequest{ +// Index: msgs[1].Index, +// }, +// response: &types.QueryGetStakingRewardParticipantResponse{StakingRewardParticipant: msgs[1]}, +// }, +// { +// desc: "KeyNotFound", +// request: &types.QueryGetStakingRewardParticipantRequest{ +// Index: strconv.Itoa(100000), +// }, +// err: status.Error(codes.NotFound, "not found"), +// }, +// { +// desc: "InvalidRequest", +// err: status.Error(codes.InvalidArgument, "invalid request"), +// }, +// } { +// t.Run(tc.desc, func(t *testing.T) { +// response, err := keeper.StakingRewardParticipant(wctx, tc.request) +// if tc.err != nil { +// require.ErrorIs(t, err, tc.err) +// } else { +// require.NoError(t, err) +// require.Equal(t, +// nullify.Fill(tc.response), +// nullify.Fill(response), +// ) +// } +// }) +// } +//} +// +//func TestStakingRewardParticipantQueryPaginated(t *testing.T) { +// keeper, ctx := keepertest.RewardsKeeper(t) +// wctx := sdk.WrapSDKContext(ctx) +// msgs := createNStakingRewardParticipant(keeper, ctx, 5) +// +// request := func(next []byte, offset, limit uint64, total bool) *types.QueryAllStakingRewardParticipantRequest { +// return &types.QueryAllStakingRewardParticipantRequest{ +// Pagination: &query.PageRequest{ +// Key: next, +// Offset: offset, +// Limit: limit, +// CountTotal: total, +// }, +// } +// } +// t.Run("ByOffset", func(t *testing.T) { +// step := 2 +// for i := 0; i < len(msgs); i += step { +// resp, err := keeper.StakingRewardParticipantAll(wctx, request(nil, uint64(i), uint64(step), false)) +// require.NoError(t, err) +// require.LessOrEqual(t, len(resp.StakingRewardParticipant), step) +// require.Subset(t, +// nullify.Fill(msgs), +// nullify.Fill(resp.StakingRewardParticipant), +// ) +// } +// }) +// t.Run("ByKey", func(t *testing.T) { +// step := 2 +// var next []byte +// for i := 0; i < len(msgs); i += step { +// resp, err := keeper.StakingRewardParticipantAll(wctx, request(next, 0, uint64(step), false)) +// require.NoError(t, err) +// require.LessOrEqual(t, len(resp.StakingRewardParticipant), step) +// require.Subset(t, +// nullify.Fill(msgs), +// nullify.Fill(resp.StakingRewardParticipant), +// ) +// next = resp.Pagination.NextKey +// } +// }) +// t.Run("Total", func(t *testing.T) { +// resp, err := keeper.StakingRewardParticipantAll(wctx, request(nil, 0, 0, true)) +// require.NoError(t, err) +// require.Equal(t, len(msgs), int(resp.Pagination.Total)) +// require.ElementsMatch(t, +// nullify.Fill(msgs), +// nullify.Fill(resp.StakingRewardParticipant), +// ) +// }) +// t.Run("InvalidRequest", func(t *testing.T) { +// _, err := keeper.StakingRewardParticipantAll(wctx, nil) +// require.ErrorIs(t, err, status.Error(codes.InvalidArgument, "invalid request")) +// }) +//} diff --git a/x/rewards/keeper/grpc_query_trading_reward_test.go b/x/rewards/keeper/grpc_query_trading_reward_test.go index 3733af92..d837fc1b 100644 --- a/x/rewards/keeper/grpc_query_trading_reward_test.go +++ b/x/rewards/keeper/grpc_query_trading_reward_test.go @@ -2,125 +2,115 @@ package keeper_test import ( "strconv" - "testing" - - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/query" - "github.com/stretchr/testify/require" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/status" - - keepertest "github.com/bze-alphateam/bze/testutil/keeper" - "github.com/bze-alphateam/bze/testutil/nullify" - "github.com/bze-alphateam/bze/x/rewards/types" ) // Prevent strconv unused error var _ = strconv.IntSize -func TestTradingRewardQuerySingle(t *testing.T) { - keeper, ctx := keepertest.RewardsKeeper(t) - wctx := sdk.WrapSDKContext(ctx) - msgs := createNTradingReward(keeper, ctx, 2) - for _, tc := range []struct { - desc string - request *types.QueryGetTradingRewardRequest - response *types.QueryGetTradingRewardResponse - err error - }{ - { - desc: "First", - request: &types.QueryGetTradingRewardRequest{ - RewardId: msgs[0].RewardId, - }, - response: &types.QueryGetTradingRewardResponse{TradingReward: msgs[0]}, - }, - { - desc: "Second", - request: &types.QueryGetTradingRewardRequest{ - RewardId: msgs[1].RewardId, - }, - response: &types.QueryGetTradingRewardResponse{TradingReward: msgs[1]}, - }, - { - desc: "KeyNotFound", - request: &types.QueryGetTradingRewardRequest{ - RewardId: strconv.Itoa(100000), - }, - err: status.Error(codes.NotFound, "not found"), - }, - { - desc: "InvalidRequest", - err: status.Error(codes.InvalidArgument, "invalid request"), - }, - } { - t.Run(tc.desc, func(t *testing.T) { - response, err := keeper.TradingReward(wctx, tc.request) - if tc.err != nil { - require.ErrorIs(t, err, tc.err) - } else { - require.NoError(t, err) - require.Equal(t, - nullify.Fill(tc.response), - nullify.Fill(response), - ) - } - }) - } -} - -func TestTradingRewardQueryPaginated(t *testing.T) { - keeper, ctx := keepertest.RewardsKeeper(t) - wctx := sdk.WrapSDKContext(ctx) - msgs := createNTradingReward(keeper, ctx, 5) - - request := func(next []byte, offset, limit uint64, total bool) *types.QueryAllTradingRewardRequest { - return &types.QueryAllTradingRewardRequest{ - Pagination: &query.PageRequest{ - Key: next, - Offset: offset, - Limit: limit, - CountTotal: total, - }, - } - } - t.Run("ByOffset", func(t *testing.T) { - step := 2 - for i := 0; i < len(msgs); i += step { - resp, err := keeper.TradingRewardAll(wctx, request(nil, uint64(i), uint64(step), false)) - require.NoError(t, err) - require.LessOrEqual(t, len(resp.TradingReward), step) - require.Subset(t, - nullify.Fill(msgs), - nullify.Fill(resp.TradingReward), - ) - } - }) - t.Run("ByKey", func(t *testing.T) { - step := 2 - var next []byte - for i := 0; i < len(msgs); i += step { - resp, err := keeper.TradingRewardAll(wctx, request(next, 0, uint64(step), false)) - require.NoError(t, err) - require.LessOrEqual(t, len(resp.TradingReward), step) - require.Subset(t, - nullify.Fill(msgs), - nullify.Fill(resp.TradingReward), - ) - next = resp.Pagination.NextKey - } - }) - t.Run("Total", func(t *testing.T) { - resp, err := keeper.TradingRewardAll(wctx, request(nil, 0, 0, true)) - require.NoError(t, err) - require.Equal(t, len(msgs), int(resp.Pagination.Total)) - require.ElementsMatch(t, - nullify.Fill(msgs), - nullify.Fill(resp.TradingReward), - ) - }) - t.Run("InvalidRequest", func(t *testing.T) { - _, err := keeper.TradingRewardAll(wctx, nil) - require.ErrorIs(t, err, status.Error(codes.InvalidArgument, "invalid request")) - }) -} +// +//func TestTradingRewardQuerySingle(t *testing.T) { +// keeper, ctx := keepertest.RewardsKeeper(t) +// wctx := sdk.WrapSDKContext(ctx) +// msgs := createNTradingReward(keeper, ctx, 2) +// for _, tc := range []struct { +// desc string +// request *types.QueryGetTradingRewardRequest +// response *types.QueryGetTradingRewardResponse +// err error +// }{ +// { +// desc: "First", +// request: &types.QueryGetTradingRewardRequest{ +// RewardId: msgs[0].RewardId, +// }, +// response: &types.QueryGetTradingRewardResponse{TradingReward: msgs[0]}, +// }, +// { +// desc: "Second", +// request: &types.QueryGetTradingRewardRequest{ +// RewardId: msgs[1].RewardId, +// }, +// response: &types.QueryGetTradingRewardResponse{TradingReward: msgs[1]}, +// }, +// { +// desc: "KeyNotFound", +// request: &types.QueryGetTradingRewardRequest{ +// RewardId: strconv.Itoa(100000), +// }, +// err: status.Error(codes.NotFound, "not found"), +// }, +// { +// desc: "InvalidRequest", +// err: status.Error(codes.InvalidArgument, "invalid request"), +// }, +// } { +// t.Run(tc.desc, func(t *testing.T) { +// response, err := keeper.TradingReward(wctx, tc.request) +// if tc.err != nil { +// require.ErrorIs(t, err, tc.err) +// } else { +// require.NoError(t, err) +// require.Equal(t, +// nullify.Fill(tc.response), +// nullify.Fill(response), +// ) +// } +// }) +// } +//} +// +//func TestTradingRewardQueryPaginated(t *testing.T) { +// keeper, ctx := keepertest.RewardsKeeper(t) +// wctx := sdk.WrapSDKContext(ctx) +// msgs := createNTradingReward(keeper, ctx, 5) +// +// request := func(next []byte, offset, limit uint64, total bool) *types.QueryAllTradingRewardRequest { +// return &types.QueryAllTradingRewardRequest{ +// Pagination: &query.PageRequest{ +// Key: next, +// Offset: offset, +// Limit: limit, +// CountTotal: total, +// }, +// } +// } +// t.Run("ByOffset", func(t *testing.T) { +// step := 2 +// for i := 0; i < len(msgs); i += step { +// resp, err := keeper.TradingRewardAll(wctx, request(nil, uint64(i), uint64(step), false)) +// require.NoError(t, err) +// require.LessOrEqual(t, len(resp.TradingReward), step) +// require.Subset(t, +// nullify.Fill(msgs), +// nullify.Fill(resp.TradingReward), +// ) +// } +// }) +// t.Run("ByKey", func(t *testing.T) { +// step := 2 +// var next []byte +// for i := 0; i < len(msgs); i += step { +// resp, err := keeper.TradingRewardAll(wctx, request(next, 0, uint64(step), false)) +// require.NoError(t, err) +// require.LessOrEqual(t, len(resp.TradingReward), step) +// require.Subset(t, +// nullify.Fill(msgs), +// nullify.Fill(resp.TradingReward), +// ) +// next = resp.Pagination.NextKey +// } +// }) +// t.Run("Total", func(t *testing.T) { +// resp, err := keeper.TradingRewardAll(wctx, request(nil, 0, 0, true)) +// require.NoError(t, err) +// require.Equal(t, len(msgs), int(resp.Pagination.Total)) +// require.ElementsMatch(t, +// nullify.Fill(msgs), +// nullify.Fill(resp.TradingReward), +// ) +// }) +// t.Run("InvalidRequest", func(t *testing.T) { +// _, err := keeper.TradingRewardAll(wctx, nil) +// require.ErrorIs(t, err, status.Error(codes.InvalidArgument, "invalid request")) +// }) +//} diff --git a/x/rewards/keeper/msg_server_trading_reward_test.go b/x/rewards/keeper/msg_server_trading_reward_test.go index b1ed017b..99005809 100644 --- a/x/rewards/keeper/msg_server_trading_reward_test.go +++ b/x/rewards/keeper/msg_server_trading_reward_test.go @@ -176,7 +176,7 @@ func (suite *IntegrationTestSuite) TestCreateTradingReward_MissingSupply() { PrizeDenom: "ubzesd", Duration: "100", MarketId: "stake/ubze", - Slots: "99", + Slots: "1", } _, err := suite.msgServer.CreateTradingReward(goCtx, &msg) @@ -227,7 +227,7 @@ func (suite *IntegrationTestSuite) TestCreateTradingReward_Success() { initialUserBalances := suite.app.BankKeeper.GetAllBalances(suite.ctx, addr1) suite.Require().True(initialUserBalances.IsZero()) - balances := sdk.NewCoins(sdk.NewInt64Coin("ubze", 10000020000)) + balances := sdk.NewCoins(sdk.NewInt64Coin("ubze", 10000002000)) suite.Require().NoError(simapp.FundAccount(suite.app.BankKeeper, suite.ctx, addr1, balances)) suite.app.TradebinKeeper.SetMarket(suite.ctx, types2.Market{ Base: "stake", @@ -241,7 +241,7 @@ func (suite *IntegrationTestSuite) TestCreateTradingReward_Success() { PrizeDenom: "ubze", Duration: "100", MarketId: "stake/ubze", - Slots: "100", + Slots: "10", } res, err := suite.msgServer.CreateTradingReward(goCtx, &msg) @@ -254,7 +254,7 @@ func (suite *IntegrationTestSuite) TestCreateTradingReward_Success() { suite.Require().EqualValues(msg.PrizeDenom, storeTradingReward.PrizeDenom) suite.Require().EqualValues(uint32(100), storeTradingReward.Duration) suite.Require().EqualValues(msg.MarketId, storeTradingReward.MarketId) - suite.Require().EqualValues(uint32(100), storeTradingReward.Slots) + suite.Require().EqualValues(uint32(10), storeTradingReward.Slots) expectedRemainingBalance := sdk.NewCoins(sdk.NewInt64Coin("ubze", 0)) actualRemainingBalance := suite.app.BankKeeper.GetAllBalances(suite.ctx, addr1) diff --git a/x/rewards/keeper/staking_reward_participant_test.go b/x/rewards/keeper/staking_reward_participant_test.go index 9bb84f06..225c948f 100644 --- a/x/rewards/keeper/staking_reward_participant_test.go +++ b/x/rewards/keeper/staking_reward_participant_test.go @@ -2,62 +2,55 @@ package keeper_test import ( "strconv" - "testing" - - keepertest "github.com/bze-alphateam/bze/testutil/keeper" - "github.com/bze-alphateam/bze/testutil/nullify" - "github.com/bze-alphateam/bze/x/rewards/keeper" - "github.com/bze-alphateam/bze/x/rewards/types" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/stretchr/testify/require" ) // Prevent strconv unused error var _ = strconv.IntSize -func createNStakingRewardParticipant(keeper *keeper.Keeper, ctx sdk.Context, n int) []types.StakingRewardParticipant { - items := make([]types.StakingRewardParticipant, n) - for i := range items { - items[i].Index = strconv.Itoa(i) - - keeper.SetStakingRewardParticipant(ctx, items[i]) - } - return items -} - -func TestStakingRewardParticipantGet(t *testing.T) { - keeper, ctx := keepertest.RewardsKeeper(t) - items := createNStakingRewardParticipant(keeper, ctx, 10) - for _, item := range items { - rst, found := keeper.GetStakingRewardParticipant(ctx, - item.Index, - ) - require.True(t, found) - require.Equal(t, - nullify.Fill(&item), - nullify.Fill(&rst), - ) - } -} -func TestStakingRewardParticipantRemove(t *testing.T) { - keeper, ctx := keepertest.RewardsKeeper(t) - items := createNStakingRewardParticipant(keeper, ctx, 10) - for _, item := range items { - keeper.RemoveStakingRewardParticipant(ctx, - item.Index, - ) - _, found := keeper.GetStakingRewardParticipant(ctx, - item.Index, - ) - require.False(t, found) - } -} - -func TestStakingRewardParticipantGetAll(t *testing.T) { - keeper, ctx := keepertest.RewardsKeeper(t) - items := createNStakingRewardParticipant(keeper, ctx, 10) - require.ElementsMatch(t, - nullify.Fill(items), - nullify.Fill(keeper.GetAllStakingRewardParticipant(ctx)), - ) -} +// +//func createNStakingRewardParticipant(keeper *keeper.Keeper, ctx sdk.Context, n int) []types.StakingRewardParticipant { +// items := make([]types.StakingRewardParticipant, n) +// for i := range items { +// items[i].Index = strconv.Itoa(i) +// +// keeper.SetStakingRewardParticipant(ctx, items[i]) +// } +// return items +//} +// +//func TestStakingRewardParticipantGet(t *testing.T) { +// keeper, ctx := keepertest.RewardsKeeper(t) +// items := createNStakingRewardParticipant(keeper, ctx, 10) +// for _, item := range items { +// rst, found := keeper.GetStakingRewardParticipant(ctx, +// item.Index, +// ) +// require.True(t, found) +// require.Equal(t, +// nullify.Fill(&item), +// nullify.Fill(&rst), +// ) +// } +//} +//func TestStakingRewardParticipantRemove(t *testing.T) { +// keeper, ctx := keepertest.RewardsKeeper(t) +// items := createNStakingRewardParticipant(keeper, ctx, 10) +// for _, item := range items { +// keeper.RemoveStakingRewardParticipant(ctx, +// item.Index, +// ) +// _, found := keeper.GetStakingRewardParticipant(ctx, +// item.Index, +// ) +// require.False(t, found) +// } +//} +// +//func TestStakingRewardParticipantGetAll(t *testing.T) { +// keeper, ctx := keepertest.RewardsKeeper(t) +// items := createNStakingRewardParticipant(keeper, ctx, 10) +// require.ElementsMatch(t, +// nullify.Fill(items), +// nullify.Fill(keeper.GetAllStakingRewardParticipant(ctx)), +// ) +//} From 3eb65d34bf2a79c142a29bda86f61f93465cfa51 Mon Sep 17 00:00:00 2001 From: faneaatiku Date: Sat, 20 Apr 2024 01:34:54 +0300 Subject: [PATCH 32/35] added tests for queries and msg servers and fixed bugs --- x/rewards/keeper/counter_test.go | 32 +++ x/rewards/keeper/gov_test.go | 75 ++++++ ...get_market_id_trading_reward_id_handler.go | 25 -- ...pc_query_get_trading_reward_leaderboard.go | 24 -- x/rewards/keeper/grpc_query_params_test.go | 25 +- x/rewards/keeper/grpc_query_staking_reward.go | 55 ++++ .../grpc_query_staking_reward_participant.go | 67 ----- ...c_query_staking_reward_participant_test.go | 116 -------- .../keeper/grpc_query_staking_reward_test.go | 121 +++++++++ x/rewards/keeper/grpc_query_trading_reward.go | 29 ++ .../keeper/grpc_query_trading_reward_test.go | 248 ++++++++++-------- .../msg_server_claim_staking_rewards_test.go | 104 ++++++++ .../msg_server_distribute_staking_rewards.go | 30 ++- ..._server_distribute_staking_rewards_test.go | 131 +++++++++ x/rewards/keeper/msg_server_exit_staking.go | 33 +-- .../keeper/msg_server_exit_staking_test.go | 244 +++++++++++++++++ x/rewards/keeper/msg_server_join_staking.go | 6 + .../keeper/staking_reward_distribution.go | 26 +- 18 files changed, 1004 insertions(+), 387 deletions(-) create mode 100644 x/rewards/keeper/counter_test.go create mode 100644 x/rewards/keeper/gov_test.go delete mode 100644 x/rewards/keeper/grpc_query_get_market_id_trading_reward_id_handler.go delete mode 100644 x/rewards/keeper/grpc_query_get_trading_reward_leaderboard.go delete mode 100644 x/rewards/keeper/grpc_query_staking_reward_participant.go delete mode 100644 x/rewards/keeper/grpc_query_staking_reward_participant_test.go create mode 100644 x/rewards/keeper/msg_server_claim_staking_rewards_test.go create mode 100644 x/rewards/keeper/msg_server_distribute_staking_rewards_test.go create mode 100644 x/rewards/keeper/msg_server_exit_staking_test.go diff --git a/x/rewards/keeper/counter_test.go b/x/rewards/keeper/counter_test.go new file mode 100644 index 00000000..a43f7de6 --- /dev/null +++ b/x/rewards/keeper/counter_test.go @@ -0,0 +1,32 @@ +package keeper_test + +func (suite *IntegrationTestSuite) TestCounter() { + key := []byte("test") + initial := suite.k.GetCounter(suite.ctx, key) + suite.Require().Equal(initial, uint64(0)) + + suite.k.SetCounter(suite.ctx, key, 2) + + counter := suite.k.GetCounter(suite.ctx, key) + suite.Require().Equal(counter, uint64(2)) +} + +func (suite *IntegrationTestSuite) TestStakingRewardsCounter() { + initial := suite.k.GetStakingRewardsCounter(suite.ctx) + suite.Require().Equal(initial, uint64(0)) + + suite.k.SetStakingRewardsCounter(suite.ctx, uint64(2323)) + + counter := suite.k.GetStakingRewardsCounter(suite.ctx) + suite.Require().Equal(counter, uint64(2323)) +} + +func (suite *IntegrationTestSuite) TestTradingRewardsCounter() { + initial := suite.k.GetTradingRewardsCounter(suite.ctx) + suite.Require().Equal(initial, uint64(0)) + + suite.k.SetTradingRewardsCounter(suite.ctx, uint64(2323)) + + counter := suite.k.GetTradingRewardsCounter(suite.ctx) + suite.Require().Equal(counter, uint64(2323)) +} diff --git a/x/rewards/keeper/gov_test.go b/x/rewards/keeper/gov_test.go new file mode 100644 index 00000000..036c9529 --- /dev/null +++ b/x/rewards/keeper/gov_test.go @@ -0,0 +1,75 @@ +package keeper_test + +import ( + "github.com/bze-alphateam/bze/x/rewards/types" +) + +func (suite *IntegrationTestSuite) TestHandleActivateTradingRewardProposal_AlreadyActiveError() { + tr := types.TradingReward{RewardId: "123"} + suite.k.SetActiveTradingReward(suite.ctx, tr) + + prop := types.ActivateTradingRewardProposal{ + Title: "", + Description: "", + RewardId: tr.RewardId, + } + + suite.Require().Error(suite.k.HandleActivateTradingRewardProposal(suite.ctx, &prop)) +} + +func (suite *IntegrationTestSuite) TestHandleActivateTradingRewardProposal_TradingRewardNotFoundError() { + prop := types.ActivateTradingRewardProposal{ + Title: "", + Description: "", + RewardId: "0", + } + + suite.Require().Error(suite.k.HandleActivateTradingRewardProposal(suite.ctx, &prop)) +} + +func (suite *IntegrationTestSuite) TestHandleActivateTradingRewardProposal_Success() { + tr := types.TradingReward{ + RewardId: "123", + ExpireAt: 123, + MarketId: "da", + } + suite.k.SetPendingTradingReward(suite.ctx, tr) + + trExp := types.TradingRewardExpiration{ + RewardId: tr.RewardId, + ExpireAt: tr.ExpireAt, + } + suite.k.SetPendingTradingRewardExpiration(suite.ctx, trExp) + + prop := types.ActivateTradingRewardProposal{ + Title: "", + Description: "", + RewardId: tr.RewardId, + } + + suite.Require().NoError(suite.k.HandleActivateTradingRewardProposal(suite.ctx, &prop)) + + //check the reward is not in pending anymore + _, found := suite.k.GetPendingTradingReward(suite.ctx, tr.RewardId) + suite.Require().False(found) + + //check the expiration does not exist + allPendingExp := suite.k.GetAllPendingTradingRewardExpiration(suite.ctx) + suite.Require().Empty(allPendingExp) + + //check it is active + activeTr, found := suite.k.GetActiveTradingReward(suite.ctx, tr.RewardId) + suite.Require().True(found) + //check the expire at was modified in the document + suite.Require().NotEqual(activeTr.ExpireAt, tr.ExpireAt) + + //check there's an active exp + allActiveExp := suite.k.GetAllActiveTradingRewardExpiration(suite.ctx) + suite.Require().Equal(len(allActiveExp), 1) + //check the reward id exists in active exp + suite.Require().Equal(allActiveExp[0].RewardId, tr.RewardId) + + //check we can find the TR by market id + _, found = suite.k.GetMarketIdRewardId(suite.ctx, tr.MarketId) + suite.Require().True(found) +} diff --git a/x/rewards/keeper/grpc_query_get_market_id_trading_reward_id_handler.go b/x/rewards/keeper/grpc_query_get_market_id_trading_reward_id_handler.go deleted file mode 100644 index d58c4a2e..00000000 --- a/x/rewards/keeper/grpc_query_get_market_id_trading_reward_id_handler.go +++ /dev/null @@ -1,25 +0,0 @@ -package keeper - -import ( - "context" - - "github.com/bze-alphateam/bze/x/rewards/types" - sdk "github.com/cosmos/cosmos-sdk/types" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/status" -) - -func (k Keeper) GetMarketIdTradingRewardIdHandler(goCtx context.Context, req *types.QueryGetMarketIdTradingRewardIdHandlerRequest) (*types.QueryGetMarketIdTradingRewardIdHandlerResponse, error) { - if req == nil { - return nil, status.Error(codes.InvalidArgument, "invalid request") - } - - ctx := sdk.UnwrapSDKContext(goCtx) - - mr, found := k.GetMarketIdRewardId(ctx, req.MarketId) - if !found { - return nil, status.Error(codes.NotFound, "not found") - } - - return &types.QueryGetMarketIdTradingRewardIdHandlerResponse{MarketIdRewardId: &mr}, nil -} diff --git a/x/rewards/keeper/grpc_query_get_trading_reward_leaderboard.go b/x/rewards/keeper/grpc_query_get_trading_reward_leaderboard.go deleted file mode 100644 index 97b2544c..00000000 --- a/x/rewards/keeper/grpc_query_get_trading_reward_leaderboard.go +++ /dev/null @@ -1,24 +0,0 @@ -package keeper - -import ( - "context" - - "github.com/bze-alphateam/bze/x/rewards/types" - sdk "github.com/cosmos/cosmos-sdk/types" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/status" -) - -func (k Keeper) GetTradingRewardLeaderboardHandler(goCtx context.Context, req *types.QueryGetTradingRewardLeaderboardRequest) (*types.QueryGetTradingRewardLeaderboardResponse, error) { - if req == nil { - return nil, status.Error(codes.InvalidArgument, "invalid request") - } - - ctx := sdk.UnwrapSDKContext(goCtx) - trl, found := k.GetTradingRewardLeaderboard(ctx, req.RewardId) - if !found { - return nil, status.Error(codes.NotFound, "not found") - } - - return &types.QueryGetTradingRewardLeaderboardResponse{Leaderboard: &trl}, nil -} diff --git a/x/rewards/keeper/grpc_query_params_test.go b/x/rewards/keeper/grpc_query_params_test.go index ed10f4e8..13862e2d 100644 --- a/x/rewards/keeper/grpc_query_params_test.go +++ b/x/rewards/keeper/grpc_query_params_test.go @@ -1,21 +1,22 @@ package keeper_test import ( - "testing" - - testkeeper "github.com/bze-alphateam/bze/testutil/keeper" "github.com/bze-alphateam/bze/x/rewards/types" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/stretchr/testify/require" ) -func TestParamsQuery(t *testing.T) { - keeper, ctx := testkeeper.RewardsKeeper(t) - wctx := sdk.WrapSDKContext(ctx) - params := types.DefaultParams() - keeper.SetParams(ctx, params) +func (suite *IntegrationTestSuite) TestQueryGetParams_InvalidRequest() { + goCtx := sdk.WrapSDKContext(suite.ctx) + _, err := suite.k.Params(goCtx, nil) + suite.Require().Error(err) +} + +func (suite *IntegrationTestSuite) TestQueryGetParams_Success() { + goCtx := sdk.WrapSDKContext(suite.ctx) + + resp, err := suite.k.Params(goCtx, &types.QueryParamsRequest{}) + suite.Require().NoError(err) - response, err := keeper.Params(wctx, &types.QueryParamsRequest{}) - require.NoError(t, err) - require.Equal(t, &types.QueryParamsResponse{Params: params}, response) + def := types.DefaultGenesis() + suite.Require().Equal(resp.Params, def.GetParams()) } diff --git a/x/rewards/keeper/grpc_query_staking_reward.go b/x/rewards/keeper/grpc_query_staking_reward.go index bb78e5ae..352fb789 100644 --- a/x/rewards/keeper/grpc_query_staking_reward.go +++ b/x/rewards/keeper/grpc_query_staking_reward.go @@ -55,3 +55,58 @@ func (k Keeper) StakingReward(c context.Context, req *types.QueryGetStakingRewar return &types.QueryGetStakingRewardResponse{StakingReward: val}, nil } + +func (k Keeper) StakingRewardParticipantAll(c context.Context, req *types.QueryAllStakingRewardParticipantRequest) (*types.QueryAllStakingRewardParticipantResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + + var stakingRewardParticipants []types.StakingRewardParticipant + ctx := sdk.UnwrapSDKContext(c) + + store := ctx.KVStore(k.storeKey) + stakingRewardParticipantStore := prefix.NewStore(store, types.KeyPrefix(types.StakingRewardParticipantKeyPrefix)) + + pageRes, err := query.Paginate(stakingRewardParticipantStore, req.Pagination, func(key []byte, value []byte) error { + var stakingRewardParticipant types.StakingRewardParticipant + if err := k.cdc.Unmarshal(value, &stakingRewardParticipant); err != nil { + return err + } + + stakingRewardParticipants = append(stakingRewardParticipants, stakingRewardParticipant) + return nil + }) + + if err != nil { + return nil, status.Error(codes.Internal, err.Error()) + } + + return &types.QueryAllStakingRewardParticipantResponse{List: stakingRewardParticipants, Pagination: pageRes}, nil +} + +func (k Keeper) StakingRewardParticipant(c context.Context, req *types.QueryGetStakingRewardParticipantRequest) (*types.QueryGetStakingRewardParticipantResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + var list []types.StakingRewardParticipant + ctx := sdk.UnwrapSDKContext(c) + + store := ctx.KVStore(k.storeKey) + stakingRewardParticipantStore := prefix.NewStore(store, types.StakingRewardParticipantPrefix(req.Address)) + + pageRes, err := query.Paginate(stakingRewardParticipantStore, req.Pagination, func(key []byte, value []byte) error { + var stakingRewardParticipant types.StakingRewardParticipant + if err := k.cdc.Unmarshal(value, &stakingRewardParticipant); err != nil { + return err + } + + list = append(list, stakingRewardParticipant) + return nil + }) + + if err != nil { + return nil, status.Error(codes.Internal, err.Error()) + } + + return &types.QueryGetStakingRewardParticipantResponse{List: list, Pagination: pageRes}, nil +} diff --git a/x/rewards/keeper/grpc_query_staking_reward_participant.go b/x/rewards/keeper/grpc_query_staking_reward_participant.go deleted file mode 100644 index 0f76c4f7..00000000 --- a/x/rewards/keeper/grpc_query_staking_reward_participant.go +++ /dev/null @@ -1,67 +0,0 @@ -package keeper - -import ( - "context" - - "github.com/bze-alphateam/bze/x/rewards/types" - "github.com/cosmos/cosmos-sdk/store/prefix" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/cosmos/cosmos-sdk/types/query" - "google.golang.org/grpc/codes" - "google.golang.org/grpc/status" -) - -func (k Keeper) StakingRewardParticipantAll(c context.Context, req *types.QueryAllStakingRewardParticipantRequest) (*types.QueryAllStakingRewardParticipantResponse, error) { - if req == nil { - return nil, status.Error(codes.InvalidArgument, "invalid request") - } - - var stakingRewardParticipants []types.StakingRewardParticipant - ctx := sdk.UnwrapSDKContext(c) - - store := ctx.KVStore(k.storeKey) - stakingRewardParticipantStore := prefix.NewStore(store, types.KeyPrefix(types.StakingRewardParticipantKeyPrefix)) - - pageRes, err := query.Paginate(stakingRewardParticipantStore, req.Pagination, func(key []byte, value []byte) error { - var stakingRewardParticipant types.StakingRewardParticipant - if err := k.cdc.Unmarshal(value, &stakingRewardParticipant); err != nil { - return err - } - - stakingRewardParticipants = append(stakingRewardParticipants, stakingRewardParticipant) - return nil - }) - - if err != nil { - return nil, status.Error(codes.Internal, err.Error()) - } - - return &types.QueryAllStakingRewardParticipantResponse{List: stakingRewardParticipants, Pagination: pageRes}, nil -} - -func (k Keeper) StakingRewardParticipant(c context.Context, req *types.QueryGetStakingRewardParticipantRequest) (*types.QueryGetStakingRewardParticipantResponse, error) { - if req == nil { - return nil, status.Error(codes.InvalidArgument, "invalid request") - } - var list []types.StakingRewardParticipant - ctx := sdk.UnwrapSDKContext(c) - - store := ctx.KVStore(k.storeKey) - stakingRewardParticipantStore := prefix.NewStore(store, types.StakingRewardParticipantPrefix(req.Address)) - - pageRes, err := query.Paginate(stakingRewardParticipantStore, req.Pagination, func(key []byte, value []byte) error { - var stakingRewardParticipant types.StakingRewardParticipant - if err := k.cdc.Unmarshal(value, &stakingRewardParticipant); err != nil { - return err - } - - list = append(list, stakingRewardParticipant) - return nil - }) - - if err != nil { - return nil, status.Error(codes.Internal, err.Error()) - } - - return &types.QueryGetStakingRewardParticipantResponse{List: list, Pagination: pageRes}, nil -} diff --git a/x/rewards/keeper/grpc_query_staking_reward_participant_test.go b/x/rewards/keeper/grpc_query_staking_reward_participant_test.go deleted file mode 100644 index e6f96a12..00000000 --- a/x/rewards/keeper/grpc_query_staking_reward_participant_test.go +++ /dev/null @@ -1,116 +0,0 @@ -package keeper_test - -import ( - "strconv" -) - -// Prevent strconv unused error -var _ = strconv.IntSize - -// -//func TestStakingRewardParticipantQuerySingle(t *testing.T) { -// keeper, ctx := keepertest.RewardsKeeper(t) -// wctx := sdk.WrapSDKContext(ctx) -// msgs := createNStakingRewardParticipant(keeper, ctx, 2) -// for _, tc := range []struct { -// desc string -// request *types.QueryGetStakingRewardParticipantRequest -// response *types.QueryGetStakingRewardParticipantResponse -// err error -// }{ -// { -// desc: "First", -// request: &types.QueryGetStakingRewardParticipantRequest{ -// Index: msgs[0].Index, -// }, -// response: &types.QueryGetStakingRewardParticipantResponse{StakingRewardParticipant: msgs[0]}, -// }, -// { -// desc: "Second", -// request: &types.QueryGetStakingRewardParticipantRequest{ -// Index: msgs[1].Index, -// }, -// response: &types.QueryGetStakingRewardParticipantResponse{StakingRewardParticipant: msgs[1]}, -// }, -// { -// desc: "KeyNotFound", -// request: &types.QueryGetStakingRewardParticipantRequest{ -// Index: strconv.Itoa(100000), -// }, -// err: status.Error(codes.NotFound, "not found"), -// }, -// { -// desc: "InvalidRequest", -// err: status.Error(codes.InvalidArgument, "invalid request"), -// }, -// } { -// t.Run(tc.desc, func(t *testing.T) { -// response, err := keeper.StakingRewardParticipant(wctx, tc.request) -// if tc.err != nil { -// require.ErrorIs(t, err, tc.err) -// } else { -// require.NoError(t, err) -// require.Equal(t, -// nullify.Fill(tc.response), -// nullify.Fill(response), -// ) -// } -// }) -// } -//} -// -//func TestStakingRewardParticipantQueryPaginated(t *testing.T) { -// keeper, ctx := keepertest.RewardsKeeper(t) -// wctx := sdk.WrapSDKContext(ctx) -// msgs := createNStakingRewardParticipant(keeper, ctx, 5) -// -// request := func(next []byte, offset, limit uint64, total bool) *types.QueryAllStakingRewardParticipantRequest { -// return &types.QueryAllStakingRewardParticipantRequest{ -// Pagination: &query.PageRequest{ -// Key: next, -// Offset: offset, -// Limit: limit, -// CountTotal: total, -// }, -// } -// } -// t.Run("ByOffset", func(t *testing.T) { -// step := 2 -// for i := 0; i < len(msgs); i += step { -// resp, err := keeper.StakingRewardParticipantAll(wctx, request(nil, uint64(i), uint64(step), false)) -// require.NoError(t, err) -// require.LessOrEqual(t, len(resp.StakingRewardParticipant), step) -// require.Subset(t, -// nullify.Fill(msgs), -// nullify.Fill(resp.StakingRewardParticipant), -// ) -// } -// }) -// t.Run("ByKey", func(t *testing.T) { -// step := 2 -// var next []byte -// for i := 0; i < len(msgs); i += step { -// resp, err := keeper.StakingRewardParticipantAll(wctx, request(next, 0, uint64(step), false)) -// require.NoError(t, err) -// require.LessOrEqual(t, len(resp.StakingRewardParticipant), step) -// require.Subset(t, -// nullify.Fill(msgs), -// nullify.Fill(resp.StakingRewardParticipant), -// ) -// next = resp.Pagination.NextKey -// } -// }) -// t.Run("Total", func(t *testing.T) { -// resp, err := keeper.StakingRewardParticipantAll(wctx, request(nil, 0, 0, true)) -// require.NoError(t, err) -// require.Equal(t, len(msgs), int(resp.Pagination.Total)) -// require.ElementsMatch(t, -// nullify.Fill(msgs), -// nullify.Fill(resp.StakingRewardParticipant), -// ) -// }) -// t.Run("InvalidRequest", func(t *testing.T) { -// _, err := keeper.StakingRewardParticipantAll(wctx, nil) -// require.ErrorIs(t, err, status.Error(codes.InvalidArgument, "invalid request")) -// }) -//} diff --git a/x/rewards/keeper/grpc_query_staking_reward_test.go b/x/rewards/keeper/grpc_query_staking_reward_test.go index 94292649..f707a2b4 100644 --- a/x/rewards/keeper/grpc_query_staking_reward_test.go +++ b/x/rewards/keeper/grpc_query_staking_reward_test.go @@ -1 +1,122 @@ package keeper_test + +import ( + "github.com/bze-alphateam/bze/x/rewards/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +func (suite *IntegrationTestSuite) TestQueryStakingRewardAll_Success_EmptyList() { + goCtx := sdk.WrapSDKContext(suite.ctx) + + l, err := suite.k.StakingRewardAll(goCtx, &types.QueryAllStakingRewardRequest{}) + suite.Require().NoError(err) + suite.Require().Empty(l.List) +} + +func (suite *IntegrationTestSuite) TestQueryStakingRewardAll_Success_OneItem() { + goCtx := sdk.WrapSDKContext(suite.ctx) + + suite.k.SetStakingReward(suite.ctx, types.StakingReward{RewardId: "123"}) + + l, err := suite.k.StakingRewardAll(goCtx, &types.QueryAllStakingRewardRequest{}) + suite.Require().NoError(err) + suite.Require().Equal(len(l.List), 1) +} + +func (suite *IntegrationTestSuite) TestQueryStakingRewardAll_Success_TwoItems() { + goCtx := sdk.WrapSDKContext(suite.ctx) + + suite.k.SetStakingReward(suite.ctx, types.StakingReward{RewardId: "123"}) + suite.k.SetStakingReward(suite.ctx, types.StakingReward{RewardId: "456"}) + + l, err := suite.k.StakingRewardAll(goCtx, &types.QueryAllStakingRewardRequest{}) + suite.Require().NoError(err) + suite.Require().Equal(len(l.List), 2) +} + +func (suite *IntegrationTestSuite) TestQueryStakingReward_InvalidRequest() { + goCtx := sdk.WrapSDKContext(suite.ctx) + _, err := suite.k.StakingReward(goCtx, nil) + suite.Require().Error(err) +} + +func (suite *IntegrationTestSuite) TestQueryStakingReward_NotFound() { + goCtx := sdk.WrapSDKContext(suite.ctx) + + _, err := suite.k.StakingReward(goCtx, &types.QueryGetStakingRewardRequest{RewardId: "1"}) + suite.Require().Error(err) +} + +func (suite *IntegrationTestSuite) TestQueryStakingReward_Success() { + goCtx := sdk.WrapSDKContext(suite.ctx) + + sr := types.StakingReward{RewardId: "1"} + suite.k.SetStakingReward(suite.ctx, sr) + + l, err := suite.k.StakingReward(goCtx, &types.QueryGetStakingRewardRequest{RewardId: sr.RewardId}) + suite.Require().NoError(err) + suite.Require().EqualValues(l.StakingReward, sr) +} + +func (suite *IntegrationTestSuite) TestQueryStakingRewardParticipantAll_InvalidRequest() { + goCtx := sdk.WrapSDKContext(suite.ctx) + _, err := suite.k.StakingRewardParticipantAll(goCtx, nil) + suite.Require().Error(err) +} + +func (suite *IntegrationTestSuite) TestQueryStakingRewardParticipantAll_Success_EmptyList() { + goCtx := sdk.WrapSDKContext(suite.ctx) + + list, err := suite.k.StakingRewardParticipantAll(goCtx, &types.QueryAllStakingRewardParticipantRequest{}) + suite.Require().NoError(err) + suite.Require().Empty(list.List) +} + +func (suite *IntegrationTestSuite) TestQueryStakingRewardParticipantAll_Success() { + goCtx := sdk.WrapSDKContext(suite.ctx) + + srp := types.StakingRewardParticipant{ + Address: "abc", + RewardId: "001", + Amount: "123", + JoinedAt: "2002", + } + + suite.k.SetStakingRewardParticipant(suite.ctx, srp) + + list, err := suite.k.StakingRewardParticipantAll(goCtx, &types.QueryAllStakingRewardParticipantRequest{}) + suite.Require().NoError(err) + suite.Require().NotEmpty(list.List) + suite.Require().EqualValues(srp, list.List[0]) +} + +func (suite *IntegrationTestSuite) TestQueryStakingRewardParticipant_InvalidRequest() { + goCtx := sdk.WrapSDKContext(suite.ctx) + _, err := suite.k.StakingRewardParticipant(goCtx, nil) + suite.Require().Error(err) +} + +func (suite *IntegrationTestSuite) TestQueryStakingRewardParticipant_NotFound() { + goCtx := sdk.WrapSDKContext(suite.ctx) + + l, err := suite.k.StakingRewardParticipant(goCtx, &types.QueryGetStakingRewardParticipantRequest{Address: "1"}) + suite.Require().NoError(err) + suite.Require().Empty(l.List) +} + +func (suite *IntegrationTestSuite) TestQueryStakingRewardParticipant_Success() { + goCtx := sdk.WrapSDKContext(suite.ctx) + + sr := types.StakingRewardParticipant{RewardId: "1", Address: "abc123"} + suite.k.SetStakingRewardParticipant(suite.ctx, sr) + + l, err := suite.k.StakingRewardParticipant(goCtx, &types.QueryGetStakingRewardParticipantRequest{Address: "abc123"}) + suite.Require().NoError(err) + suite.Require().NotEmpty(l.List) + suite.Require().EqualValues(l.List[0], sr) + + //check a random address returns an empty list + l, err = suite.k.StakingRewardParticipant(goCtx, &types.QueryGetStakingRewardParticipantRequest{Address: "abc1233332"}) + suite.Require().NoError(err) + suite.Require().Empty(l.List) +} diff --git a/x/rewards/keeper/grpc_query_trading_reward.go b/x/rewards/keeper/grpc_query_trading_reward.go index 2b5c4d9b..1bdddb72 100644 --- a/x/rewards/keeper/grpc_query_trading_reward.go +++ b/x/rewards/keeper/grpc_query_trading_reward.go @@ -64,3 +64,32 @@ func (k Keeper) getTradingRewardStore(ctx sdk.Context, state string) prefix.Stor return s } + +func (k Keeper) GetMarketIdTradingRewardIdHandler(goCtx context.Context, req *types.QueryGetMarketIdTradingRewardIdHandlerRequest) (*types.QueryGetMarketIdTradingRewardIdHandlerResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + + ctx := sdk.UnwrapSDKContext(goCtx) + + mr, found := k.GetMarketIdRewardId(ctx, req.MarketId) + if !found { + return nil, status.Error(codes.NotFound, "not found") + } + + return &types.QueryGetMarketIdTradingRewardIdHandlerResponse{MarketIdRewardId: &mr}, nil +} + +func (k Keeper) GetTradingRewardLeaderboardHandler(goCtx context.Context, req *types.QueryGetTradingRewardLeaderboardRequest) (*types.QueryGetTradingRewardLeaderboardResponse, error) { + if req == nil { + return nil, status.Error(codes.InvalidArgument, "invalid request") + } + + ctx := sdk.UnwrapSDKContext(goCtx) + trl, found := k.GetTradingRewardLeaderboard(ctx, req.RewardId) + if !found { + return nil, status.Error(codes.NotFound, "not found") + } + + return &types.QueryGetTradingRewardLeaderboardResponse{Leaderboard: &trl}, nil +} diff --git a/x/rewards/keeper/grpc_query_trading_reward_test.go b/x/rewards/keeper/grpc_query_trading_reward_test.go index d837fc1b..404fffab 100644 --- a/x/rewards/keeper/grpc_query_trading_reward_test.go +++ b/x/rewards/keeper/grpc_query_trading_reward_test.go @@ -1,116 +1,142 @@ package keeper_test import ( - "strconv" + "github.com/bze-alphateam/bze/x/rewards/types" + sdk "github.com/cosmos/cosmos-sdk/types" ) -// Prevent strconv unused error -var _ = strconv.IntSize - -// -//func TestTradingRewardQuerySingle(t *testing.T) { -// keeper, ctx := keepertest.RewardsKeeper(t) -// wctx := sdk.WrapSDKContext(ctx) -// msgs := createNTradingReward(keeper, ctx, 2) -// for _, tc := range []struct { -// desc string -// request *types.QueryGetTradingRewardRequest -// response *types.QueryGetTradingRewardResponse -// err error -// }{ -// { -// desc: "First", -// request: &types.QueryGetTradingRewardRequest{ -// RewardId: msgs[0].RewardId, -// }, -// response: &types.QueryGetTradingRewardResponse{TradingReward: msgs[0]}, -// }, -// { -// desc: "Second", -// request: &types.QueryGetTradingRewardRequest{ -// RewardId: msgs[1].RewardId, -// }, -// response: &types.QueryGetTradingRewardResponse{TradingReward: msgs[1]}, -// }, -// { -// desc: "KeyNotFound", -// request: &types.QueryGetTradingRewardRequest{ -// RewardId: strconv.Itoa(100000), -// }, -// err: status.Error(codes.NotFound, "not found"), -// }, -// { -// desc: "InvalidRequest", -// err: status.Error(codes.InvalidArgument, "invalid request"), -// }, -// } { -// t.Run(tc.desc, func(t *testing.T) { -// response, err := keeper.TradingReward(wctx, tc.request) -// if tc.err != nil { -// require.ErrorIs(t, err, tc.err) -// } else { -// require.NoError(t, err) -// require.Equal(t, -// nullify.Fill(tc.response), -// nullify.Fill(response), -// ) -// } -// }) -// } -//} -// -//func TestTradingRewardQueryPaginated(t *testing.T) { -// keeper, ctx := keepertest.RewardsKeeper(t) -// wctx := sdk.WrapSDKContext(ctx) -// msgs := createNTradingReward(keeper, ctx, 5) -// -// request := func(next []byte, offset, limit uint64, total bool) *types.QueryAllTradingRewardRequest { -// return &types.QueryAllTradingRewardRequest{ -// Pagination: &query.PageRequest{ -// Key: next, -// Offset: offset, -// Limit: limit, -// CountTotal: total, -// }, -// } -// } -// t.Run("ByOffset", func(t *testing.T) { -// step := 2 -// for i := 0; i < len(msgs); i += step { -// resp, err := keeper.TradingRewardAll(wctx, request(nil, uint64(i), uint64(step), false)) -// require.NoError(t, err) -// require.LessOrEqual(t, len(resp.TradingReward), step) -// require.Subset(t, -// nullify.Fill(msgs), -// nullify.Fill(resp.TradingReward), -// ) -// } -// }) -// t.Run("ByKey", func(t *testing.T) { -// step := 2 -// var next []byte -// for i := 0; i < len(msgs); i += step { -// resp, err := keeper.TradingRewardAll(wctx, request(next, 0, uint64(step), false)) -// require.NoError(t, err) -// require.LessOrEqual(t, len(resp.TradingReward), step) -// require.Subset(t, -// nullify.Fill(msgs), -// nullify.Fill(resp.TradingReward), -// ) -// next = resp.Pagination.NextKey -// } -// }) -// t.Run("Total", func(t *testing.T) { -// resp, err := keeper.TradingRewardAll(wctx, request(nil, 0, 0, true)) -// require.NoError(t, err) -// require.Equal(t, len(msgs), int(resp.Pagination.Total)) -// require.ElementsMatch(t, -// nullify.Fill(msgs), -// nullify.Fill(resp.TradingReward), -// ) -// }) -// t.Run("InvalidRequest", func(t *testing.T) { -// _, err := keeper.TradingRewardAll(wctx, nil) -// require.ErrorIs(t, err, status.Error(codes.InvalidArgument, "invalid request")) -// }) -//} +func (suite *IntegrationTestSuite) TestQueryTradingRewardAll_Success_EmptyList() { + goCtx := sdk.WrapSDKContext(suite.ctx) + + l, err := suite.k.TradingRewardAll(goCtx, &types.QueryAllTradingRewardRequest{}) + suite.Require().NoError(err) + suite.Require().Empty(l.List) +} + +func (suite *IntegrationTestSuite) TestQueryTradingRewardAll_InvalidRequest() { + goCtx := sdk.WrapSDKContext(suite.ctx) + _, err := suite.k.TradingRewardAll(goCtx, nil) + suite.Require().Error(err) +} + +func (suite *IntegrationTestSuite) TestQueryTradingRewardAll_Pending_Success() { + goCtx := sdk.WrapSDKContext(suite.ctx) + + tr := types.TradingReward{ + RewardId: "2132", + } + suite.k.SetPendingTradingReward(suite.ctx, tr) + + l, err := suite.k.TradingRewardAll(goCtx, &types.QueryAllTradingRewardRequest{State: "pending"}) + suite.Require().NoError(err) + suite.Require().NotEmpty(l.List) + suite.Require().EqualValues(l.List[0], tr) +} + +func (suite *IntegrationTestSuite) TestQueryTradingRewardAll_Active_Success() { + goCtx := sdk.WrapSDKContext(suite.ctx) + + tr := types.TradingReward{ + RewardId: "2132", + } + suite.k.SetActiveTradingReward(suite.ctx, tr) + + shouldBeEmpty, err := suite.k.TradingRewardAll(goCtx, &types.QueryAllTradingRewardRequest{State: "pending"}) + suite.Require().Empty(shouldBeEmpty.List) + + l, err := suite.k.TradingRewardAll(goCtx, &types.QueryAllTradingRewardRequest{State: "active"}) + suite.Require().NoError(err) + suite.Require().NotEmpty(l.List) + suite.Require().EqualValues(l.List[0], tr) +} + +func (suite *IntegrationTestSuite) TestQueryTradingReward_InvalidRequest() { + goCtx := sdk.WrapSDKContext(suite.ctx) + _, err := suite.k.TradingReward(goCtx, nil) + suite.Require().Error(err) +} + +func (suite *IntegrationTestSuite) TestQueryTradingReward_NotFound() { + goCtx := sdk.WrapSDKContext(suite.ctx) + _, err := suite.k.TradingReward(goCtx, &types.QueryGetTradingRewardRequest{RewardId: "da"}) + suite.Require().Error(err) +} + +func (suite *IntegrationTestSuite) TestQueryTradingReward_Pending_Success() { + goCtx := sdk.WrapSDKContext(suite.ctx) + + tr := types.TradingReward{ + RewardId: "2132", + } + suite.k.SetPendingTradingReward(suite.ctx, tr) + + resp, err := suite.k.TradingReward(goCtx, &types.QueryGetTradingRewardRequest{RewardId: tr.RewardId}) + suite.Require().NoError(err) + suite.Require().EqualValues(resp.TradingReward, tr) +} + +func (suite *IntegrationTestSuite) TestQueryTradingReward_Active_Success() { + goCtx := sdk.WrapSDKContext(suite.ctx) + + tr := types.TradingReward{ + RewardId: "2132", + } + suite.k.SetActiveTradingReward(suite.ctx, tr) + + resp, err := suite.k.TradingReward(goCtx, &types.QueryGetTradingRewardRequest{RewardId: tr.RewardId}) + suite.Require().NoError(err) + suite.Require().EqualValues(resp.TradingReward, tr) +} + +func (suite *IntegrationTestSuite) TestQueryGetMarketIdTradingRewardIdHandler_InvalidRequest() { + goCtx := sdk.WrapSDKContext(suite.ctx) + _, err := suite.k.GetMarketIdTradingRewardIdHandler(goCtx, nil) + suite.Require().Error(err) +} + +func (suite *IntegrationTestSuite) TestQueryGetMarketIdTradingRewardIdHandler_NotFound() { + goCtx := sdk.WrapSDKContext(suite.ctx) + _, err := suite.k.GetMarketIdTradingRewardIdHandler(goCtx, &types.QueryGetMarketIdTradingRewardIdHandlerRequest{MarketId: "s"}) + suite.Require().Error(err) +} + +func (suite *IntegrationTestSuite) TestQueryGetMarketIdTradingRewardIdHandler_Success() { + goCtx := sdk.WrapSDKContext(suite.ctx) + + mid := types.MarketIdTradingRewardId{ + RewardId: "123", + MarketId: "asd/dsa", + } + + suite.k.SetMarketIdRewardId(suite.ctx, mid) + + resp, err := suite.k.GetMarketIdTradingRewardIdHandler(goCtx, &types.QueryGetMarketIdTradingRewardIdHandlerRequest{MarketId: mid.MarketId}) + suite.Require().NoError(err) + suite.Require().EqualValues(resp.MarketIdRewardId, &mid) +} + +func (suite *IntegrationTestSuite) TestQueryGetTradingRewardLeaderboardHandler_InvalidRequest() { + goCtx := sdk.WrapSDKContext(suite.ctx) + _, err := suite.k.GetTradingRewardLeaderboardHandler(goCtx, nil) + suite.Require().Error(err) +} + +func (suite *IntegrationTestSuite) TestQueryGetTradingRewardLeaderboardHandler_NotFound() { + goCtx := sdk.WrapSDKContext(suite.ctx) + _, err := suite.k.GetTradingRewardLeaderboardHandler(goCtx, &types.QueryGetTradingRewardLeaderboardRequest{RewardId: "a"}) + suite.Require().Error(err) +} + +func (suite *IntegrationTestSuite) TestQueryGetTradingRewardLeaderboardHandler_Success() { + goCtx := sdk.WrapSDKContext(suite.ctx) + + lb := types.TradingRewardLeaderboard{ + RewardId: "123", + } + + suite.k.SetTradingRewardLeaderboard(suite.ctx, lb) + + resp, err := suite.k.GetTradingRewardLeaderboardHandler(goCtx, &types.QueryGetTradingRewardLeaderboardRequest{RewardId: lb.RewardId}) + suite.Require().NoError(err) + suite.Require().EqualValues(resp.Leaderboard, &lb) +} diff --git a/x/rewards/keeper/msg_server_claim_staking_rewards_test.go b/x/rewards/keeper/msg_server_claim_staking_rewards_test.go new file mode 100644 index 00000000..2fcdaaf0 --- /dev/null +++ b/x/rewards/keeper/msg_server_claim_staking_rewards_test.go @@ -0,0 +1,104 @@ +package keeper_test + +import ( + "github.com/bze-alphateam/bze/testutil/simapp" + "github.com/bze-alphateam/bze/x/rewards/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +const ( + denomBze = "ubze" + denomStake = "stake" +) + +func newStakeCoin(amt int64) sdk.Coin { + return sdk.NewInt64Coin(denomStake, amt) +} + +func newBzeCoin(amt int64) sdk.Coin { + return sdk.NewInt64Coin(denomBze, amt) +} + +func (suite *IntegrationTestSuite) TestMsgClaimStakingRewards_InvalidRequest() { + goCtx := sdk.WrapSDKContext(suite.ctx) + + _, err := suite.msgServer.ClaimStakingRewards(goCtx, nil) + suite.Require().Error(err) +} + +func (suite *IntegrationTestSuite) TestMsgClaimStakingRewards_StakingRewardNotFound() { + goCtx := sdk.WrapSDKContext(suite.ctx) + + msg := types.MsgClaimStakingRewards{ + Creator: "", + RewardId: "asd", + } + + _, err := suite.msgServer.ClaimStakingRewards(goCtx, &msg) + suite.Require().Error(err) +} + +func (suite *IntegrationTestSuite) TestMsgClaimStakingRewards_ParticipantNotFound() { + goCtx := sdk.WrapSDKContext(suite.ctx) + + sr := types.StakingReward{RewardId: "a"} + suite.k.SetStakingReward(suite.ctx, sr) + + msg := types.MsgClaimStakingRewards{ + Creator: "not_a_participant", + RewardId: "asd", + } + + _, err := suite.msgServer.ClaimStakingRewards(goCtx, &msg) + suite.Require().Error(err) +} + +func (suite *IntegrationTestSuite) TestMsgClaimStakingRewards_Success() { + goCtx := sdk.WrapSDKContext(suite.ctx) + + addr1 := sdk.AccAddress("addr1_______________") + + balances := sdk.NewCoins(newStakeCoin(10000), newBzeCoin(50000)) + suite.Require().NoError(simapp.FundModuleAccount(suite.app.BankKeeper, suite.ctx, types.ModuleName, balances)) + + sr := types.StakingReward{ + RewardId: "0001", + DistributedStake: "100", + PrizeDenom: denomBze, + } + suite.k.SetStakingReward(suite.ctx, sr) + + srp := types.StakingRewardParticipant{ + Address: addr1.String(), + RewardId: sr.RewardId, + Amount: "12", + JoinedAt: "0", + } + suite.k.SetStakingRewardParticipant(suite.ctx, srp) + + msg := types.MsgClaimStakingRewards{ + Creator: addr1.String(), + RewardId: sr.RewardId, + } + + resp, err := suite.msgServer.ClaimStakingRewards(goCtx, &msg) + suite.Require().NoError(err) + suite.Require().EqualValues(resp.Amount, "1200") + + resultedParticipant, f := suite.k.GetStakingRewardParticipant(suite.ctx, addr1.String(), sr.RewardId) + suite.Require().True(f) + //check if new participant is different than the old one (after claim some fields are updated) + suite.Require().NotEqualValues(resultedParticipant, srp) + + //check joined at is equal to sr.DistributedStake + suite.Require().EqualValues(resultedParticipant.JoinedAt, sr.DistributedStake) + + //check balances were subtracted from module + moduleAddr := suite.app.AccountKeeper.GetModuleAddress(types.ModuleName) + newBalances := suite.app.BankKeeper.GetAllBalances(suite.ctx, moduleAddr) + suite.Require().EqualValues(newBalances.AmountOf(denomBze).String(), "48800") + + //check user was awarded with the amount + takerBalance := suite.app.BankKeeper.GetAllBalances(suite.ctx, addr1) + suite.Require().EqualValues(takerBalance.AmountOf(denomBze).String(), "1200") +} diff --git a/x/rewards/keeper/msg_server_distribute_staking_rewards.go b/x/rewards/keeper/msg_server_distribute_staking_rewards.go index d54b1f71..dabf0587 100644 --- a/x/rewards/keeper/msg_server_distribute_staking_rewards.go +++ b/x/rewards/keeper/msg_server_distribute_staking_rewards.go @@ -13,7 +13,7 @@ func (k msgServer) DistributeStakingRewards(goCtx context.Context, msg *types.Ms return nil, sdkerrors.ErrInvalidRequest } - _, err := sdk.AccAddressFromBech32(msg.Creator) + acc, err := sdk.AccAddressFromBech32(msg.Creator) if err != nil { return nil, err } @@ -33,14 +33,38 @@ func (k msgServer) DistributeStakingRewards(goCtx context.Context, msg *types.Ms return nil, sdkerrors.Wrap(sdkerrors.ErrKeyNotFound, "staking reward not found") } - err = k.distributeStakingRewards(ctx, &stakingReward, msg.Amount) + toCapture, err := k.getAmountToCapture("", stakingReward.PrizeDenom, msg.Amount, 1) + if err != nil { + return nil, sdkerrors.Wrap(types.ErrInvalidAmount, "could not create capture amount") + } + + err = k.checkUserBalances(ctx, toCapture, acc) + if err != nil { + return nil, sdkerrors.ErrInsufficientFunds + } + + err = k.distributeStakingRewards(&stakingReward, msg.Amount) + if err != nil { + return nil, err + } + + err = k.bankKeeper.SendCoinsFromAccountToModule(ctx, acc, types.ModuleName, toCapture) if err != nil { return nil, err } k.SetStakingReward(ctx, stakingReward) - k.Logger(ctx).Debug("staking reward distributed") + err = ctx.EventManager().EmitTypedEvent( + &types.StakingRewardDistributionEvent{ + RewardId: stakingReward.RewardId, + Amount: msg.Amount, + }, + ) + + if err != nil { + k.Logger(ctx).Error(err.Error()) + } return &types.MsgDistributeStakingRewardsResponse{}, nil } diff --git a/x/rewards/keeper/msg_server_distribute_staking_rewards_test.go b/x/rewards/keeper/msg_server_distribute_staking_rewards_test.go new file mode 100644 index 00000000..66604888 --- /dev/null +++ b/x/rewards/keeper/msg_server_distribute_staking_rewards_test.go @@ -0,0 +1,131 @@ +package keeper_test + +import ( + "github.com/bze-alphateam/bze/testutil/simapp" + "github.com/bze-alphateam/bze/x/rewards/types" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +func (suite *IntegrationTestSuite) TestMsgDistributeStakingRewards_InvalidRequest() { + goCtx := sdk.WrapSDKContext(suite.ctx) + + _, err := suite.msgServer.DistributeStakingRewards(goCtx, nil) + suite.Require().Error(err) + suite.Require().ErrorIs(err, sdkerrors.ErrInvalidRequest) +} + +func (suite *IntegrationTestSuite) TestMsgDistributeStakingRewards_InvalidCreator() { + goCtx := sdk.WrapSDKContext(suite.ctx) + + msg := types.MsgDistributeStakingRewards{ + Creator: "", + } + + _, err := suite.msgServer.DistributeStakingRewards(goCtx, &msg) + suite.Require().Error(err) + suite.Require().Equal(err.Error(), "empty address string is not allowed") +} + +func (suite *IntegrationTestSuite) TestMsgDistributeStakingRewards_InvalidAmount() { + goCtx := sdk.WrapSDKContext(suite.ctx) + addr1 := sdk.AccAddress("addr1_______________") + msg := types.MsgDistributeStakingRewards{ + Creator: addr1.String(), + } + + _, err := suite.msgServer.DistributeStakingRewards(goCtx, &msg) + suite.Require().Error(err) + suite.Require().ErrorContains(err, "could not convert order amount") +} + +func (suite *IntegrationTestSuite) TestMsgDistributeStakingRewards_NegativeAmount() { + goCtx := sdk.WrapSDKContext(suite.ctx) + addr1 := sdk.AccAddress("addr1_______________") + msg := types.MsgDistributeStakingRewards{ + Creator: addr1.String(), + Amount: "-1", + } + + _, err := suite.msgServer.DistributeStakingRewards(goCtx, &msg) + suite.Require().Error(err) + suite.Require().ErrorContains(err, "amount should be greater than 0") +} + +func (suite *IntegrationTestSuite) TestMsgDistributeStakingRewards_MissingStakingReward() { + goCtx := sdk.WrapSDKContext(suite.ctx) + addr1 := sdk.AccAddress("addr1_______________") + msg := types.MsgDistributeStakingRewards{ + Creator: addr1.String(), + Amount: "100", + } + + _, err := suite.msgServer.DistributeStakingRewards(goCtx, &msg) + suite.Require().Error(err) + suite.Require().ErrorContains(err, "staking reward not found") +} + +func (suite *IntegrationTestSuite) TestMsgDistributeStakingRewards_NoUserBalance() { + goCtx := sdk.WrapSDKContext(suite.ctx) + addr1 := sdk.AccAddress("addr1_______________") + sr := types.StakingReward{ + RewardId: "01", + PrizeDenom: denomBze, + StakedAmount: "50", + DistributedStake: "0", + } + suite.k.SetStakingReward(suite.ctx, sr) + + msg := types.MsgDistributeStakingRewards{ + Creator: addr1.String(), + Amount: "100", + RewardId: sr.RewardId, + } + + _, err := suite.msgServer.DistributeStakingRewards(goCtx, &msg) + suite.Require().Error(err) + suite.Require().ErrorIs(err, sdkerrors.ErrInsufficientFunds) +} + +func (suite *IntegrationTestSuite) TestMsgDistributeStakingRewards_Success() { + //dependencies + goCtx := sdk.WrapSDKContext(suite.ctx) + balances := sdk.NewCoins(newBzeCoin(10000)) + addr1 := sdk.AccAddress("addr1_______________") + creatorAcc := suite.app.AccountKeeper.NewAccountWithAddress(suite.ctx, addr1) + suite.app.AccountKeeper.SetAccount(suite.ctx, creatorAcc) + suite.Require().NoError(simapp.FundAccount(suite.app.BankKeeper, suite.ctx, creatorAcc.GetAddress(), balances)) + + sr := types.StakingReward{ + RewardId: "01", + PrizeDenom: denomBze, + StakedAmount: "50", + DistributedStake: "0", + } + suite.k.SetStakingReward(suite.ctx, sr) + + msg := types.MsgDistributeStakingRewards{ + Creator: addr1.String(), + Amount: "1000", + RewardId: sr.RewardId, + } + + //test & asserts + _, err := suite.msgServer.DistributeStakingRewards(goCtx, &msg) + suite.Require().NoError(err) + + //check sr was updated + newSr, f := suite.k.GetStakingReward(suite.ctx, sr.RewardId) + suite.Require().True(f) + suite.Require().NotEqualValues(newSr, sr) + suite.Require().NotEqualValues(newSr.DistributedStake, sr.DistributedStake) + + //check user balance was deducted + creatorBal := suite.app.BankKeeper.GetAllBalances(suite.ctx, creatorAcc.GetAddress()) + suite.Require().EqualValues(creatorBal.AmountOf(denomBze).String(), "9000") + + //check module received the reward + moduleAddr := suite.app.AccountKeeper.GetModuleAddress(types.ModuleName) + moduleBalances := suite.app.BankKeeper.GetAllBalances(suite.ctx, moduleAddr) + suite.Require().EqualValues(moduleBalances.AmountOf(denomBze).String(), "1000") +} diff --git a/x/rewards/keeper/msg_server_exit_staking.go b/x/rewards/keeper/msg_server_exit_staking.go index 07ae30c1..6979e492 100644 --- a/x/rewards/keeper/msg_server_exit_staking.go +++ b/x/rewards/keeper/msg_server_exit_staking.go @@ -32,6 +32,10 @@ func (k msgServer) ExitStaking(goCtx context.Context, msg *types.MsgExitStaking) if !ok { return nil, fmt.Errorf("could not transform amount from storage into int") } + if !stakedAmountInt.IsPositive() { + //disaster in this case + return nil, fmt.Errorf("no staked amount left") + } //send pending rewards _, err = k.claimPending(ctx, stakingReward, &participation) @@ -41,23 +45,22 @@ func (k msgServer) ExitStaking(goCtx context.Context, msg *types.MsgExitStaking) k.beginUnlock(ctx, participation, stakingReward) k.RemoveStakingRewardParticipant(ctx, participation.Address, participation.RewardId) + remainingStakedAmount := stakedAmountInt.Sub(partCoins.AmountOf(stakingReward.StakingDenom)) - if remainingStakedAmount.IsPositive() { - stakingReward.StakedAmount = remainingStakedAmount.String() - k.SetStakingReward(ctx, stakingReward) - } else { - //if this staking reward is finished (all funds were distributed and payouts executed) we should remove it - if stakingReward.Payouts >= stakingReward.Duration { - k.RemoveStakingReward(ctx, stakingReward.RewardId) - err = ctx.EventManager().EmitTypedEvent( - &types.StakingRewardFinishEvent{ - RewardId: stakingReward.RewardId, - }, - ) + stakingReward.StakedAmount = remainingStakedAmount.String() + k.SetStakingReward(ctx, stakingReward) + + //if this staking reward is finished (all funds were distributed and payouts executed) we should remove it + if remainingStakedAmount.IsZero() && stakingReward.Payouts >= stakingReward.Duration { + k.RemoveStakingReward(ctx, stakingReward.RewardId) + err = ctx.EventManager().EmitTypedEvent( + &types.StakingRewardFinishEvent{ + RewardId: stakingReward.RewardId, + }, + ) - if err != nil { - k.Logger(ctx).Error(err.Error()) - } + if err != nil { + k.Logger(ctx).Error(err.Error()) } } diff --git a/x/rewards/keeper/msg_server_exit_staking_test.go b/x/rewards/keeper/msg_server_exit_staking_test.go new file mode 100644 index 00000000..6b31211d --- /dev/null +++ b/x/rewards/keeper/msg_server_exit_staking_test.go @@ -0,0 +1,244 @@ +package keeper_test + +import ( + "fmt" + "github.com/bze-alphateam/bze/testutil/simapp" + "github.com/bze-alphateam/bze/x/rewards/types" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +func (suite *IntegrationTestSuite) TestMsgExitStaking_InvalidRequest() { + goCtx := sdk.WrapSDKContext(suite.ctx) + + _, err := suite.msgServer.ExitStaking(goCtx, nil) + suite.Require().Error(err) + suite.Require().ErrorIs(err, sdkerrors.ErrInvalidRequest) +} + +func (suite *IntegrationTestSuite) TestMsgExitStaking_MissingStakingReward() { + goCtx := sdk.WrapSDKContext(suite.ctx) + msg := types.MsgExitStaking{ + Creator: "", + RewardId: "a", + } + + _, err := suite.msgServer.ExitStaking(goCtx, &msg) + suite.Require().Error(err) + suite.Require().ErrorContains(err, "reward with provided id not found") +} + +func (suite *IntegrationTestSuite) TestMsgExitStaking_MissingStakingRewardParticipant() { + goCtx := sdk.WrapSDKContext(suite.ctx) + sr := types.StakingReward{ + RewardId: "01", + PrizeDenom: denomBze, + StakedAmount: "50", + DistributedStake: "0", + } + suite.k.SetStakingReward(suite.ctx, sr) + + msg := types.MsgExitStaking{ + Creator: "aaa", + RewardId: sr.RewardId, + } + _, err := suite.msgServer.ExitStaking(goCtx, &msg) + suite.Require().Error(err) + suite.Require().ErrorContains(err, "you are not a participant in this staking reward") +} + +func (suite *IntegrationTestSuite) TestMsgExitStaking_Success_OngoingStakingReward() { + //dependencies + goCtx := sdk.WrapSDKContext(suite.ctx) + addr1 := sdk.AccAddress("addr1_______________") + sr := types.StakingReward{ + RewardId: "01", + PrizeDenom: denomBze, + StakedAmount: "50", + DistributedStake: "5", + Lock: 100, + StakingDenom: denomBze, + } + suite.k.SetStakingReward(suite.ctx, sr) + + untouchedSrp := types.StakingRewardParticipant{ + Address: "asadsadasda", + RewardId: sr.RewardId, + Amount: "50", + JoinedAt: "0", + } + srp := types.StakingRewardParticipant{ + Address: addr1.String(), + RewardId: sr.RewardId, + Amount: "22", + JoinedAt: "0", + } + suite.k.SetStakingRewardParticipant(suite.ctx, srp) + suite.k.SetStakingRewardParticipant(suite.ctx, untouchedSrp) + + balances := sdk.NewCoins(newStakeCoin(10000), newBzeCoin(50000)) + suite.Require().NoError(simapp.FundModuleAccount(suite.app.BankKeeper, suite.ctx, types.ModuleName, balances)) + + //tests and asserts + msg := types.MsgExitStaking{ + Creator: addr1.String(), + RewardId: sr.RewardId, + } + _, err := suite.msgServer.ExitStaking(goCtx, &msg) + suite.Require().NoError(err) + + creatorBalance := suite.app.BankKeeper.GetAllBalances(suite.ctx, addr1) + //check the user retrieves the unclaimed rewards first + suite.Require().EqualValues(creatorBalance.AmountOf(denomBze).String(), "110") + + //check the unlock was created + lockKey := types.CreatePendingUnlockParticipantKey(int64(sr.Lock*24), fmt.Sprintf("%s/%s", sr.RewardId, srp.Address)) + unlockList := suite.k.GetAllPendingUnlockParticipant(suite.ctx) + suite.Require().NotEmpty(unlockList) + suite.Require().EqualValues(unlockList[0].Index, lockKey) + suite.Require().EqualValues(unlockList[0].Address, srp.Address) + suite.Require().EqualValues(unlockList[0].Amount, "22") + suite.Require().EqualValues(unlockList[0].Denom, sr.StakingDenom) + + //check the staking reward participant was deleted + _, f := suite.k.GetStakingRewardParticipant(suite.ctx, srp.Address, sr.RewardId) + suite.Require().False(f) + + //check the staking reward was updated + newSr, f := suite.k.GetStakingReward(suite.ctx, sr.RewardId) + suite.Require().True(f) + suite.Require().EqualValues(newSr.StakedAmount, "28") + + //check that the dummy srp is not touched since it wasn't belonging to the message creator + untouchedSrpStorage, f := suite.k.GetStakingRewardParticipant(suite.ctx, untouchedSrp.Address, untouchedSrp.RewardId) + suite.Require().True(f) + suite.Require().EqualValues(untouchedSrpStorage, untouchedSrp) +} + +func (suite *IntegrationTestSuite) TestMsgExitStaking_Success_EmptyingStakingReward() { + //dependencies + goCtx := sdk.WrapSDKContext(suite.ctx) + addr1 := sdk.AccAddress("addr1_______________") + sr := types.StakingReward{ + RewardId: "01", + PrizeDenom: denomBze, + StakedAmount: "50", + DistributedStake: "5", + Lock: 100, + StakingDenom: denomBze, + Duration: 100, + Payouts: 5, + } + suite.k.SetStakingReward(suite.ctx, sr) + + untouchedSrp := types.StakingRewardParticipant{ + Address: "asadsadasda", + RewardId: sr.RewardId, + Amount: "50", + JoinedAt: "0", + } + + srp := types.StakingRewardParticipant{ + Address: addr1.String(), + RewardId: sr.RewardId, + Amount: "50", + JoinedAt: "0", + } + suite.k.SetStakingRewardParticipant(suite.ctx, srp) + suite.k.SetStakingRewardParticipant(suite.ctx, untouchedSrp) + + balances := sdk.NewCoins(newStakeCoin(10000), newBzeCoin(50000)) + suite.Require().NoError(simapp.FundModuleAccount(suite.app.BankKeeper, suite.ctx, types.ModuleName, balances)) + + //tests and asserts + msg := types.MsgExitStaking{ + Creator: addr1.String(), + RewardId: sr.RewardId, + } + _, err := suite.msgServer.ExitStaking(goCtx, &msg) + suite.Require().NoError(err) + + creatorBalance := suite.app.BankKeeper.GetAllBalances(suite.ctx, addr1) + //check the user retrieves the unclaimed rewards first + suite.Require().EqualValues(creatorBalance.AmountOf(denomBze).String(), "250") + + //check the unlock was created + lockKey := types.CreatePendingUnlockParticipantKey(int64(sr.Lock*24), fmt.Sprintf("%s/%s", sr.RewardId, srp.Address)) + unlockList := suite.k.GetAllPendingUnlockParticipant(suite.ctx) + suite.Require().NotEmpty(unlockList) + suite.Require().EqualValues(unlockList[0].Index, lockKey) + suite.Require().EqualValues(unlockList[0].Address, srp.Address) + suite.Require().EqualValues(unlockList[0].Amount, "50") + suite.Require().EqualValues(unlockList[0].Denom, sr.StakingDenom) + + //check the staking reward participant was deleted + _, f := suite.k.GetStakingRewardParticipant(suite.ctx, srp.Address, sr.RewardId) + suite.Require().False(f) + + //check the staking reward was updated + newSr, f := suite.k.GetStakingReward(suite.ctx, sr.RewardId) + suite.Require().True(f) + suite.Require().EqualValues(newSr.StakedAmount, "0") + + //check that the dummy srp is not touched since it wasn't belonging to the message creator + untouchedSrpStorage, f := suite.k.GetStakingRewardParticipant(suite.ctx, untouchedSrp.Address, untouchedSrp.RewardId) + suite.Require().True(f) + suite.Require().EqualValues(untouchedSrpStorage, untouchedSrp) +} + +func (suite *IntegrationTestSuite) TestMsgExitStaking_Success_RemovingStakingReward() { + //dependencies + goCtx := sdk.WrapSDKContext(suite.ctx) + addr1 := sdk.AccAddress("addr1_______________") + sr := types.StakingReward{ + RewardId: "01", + PrizeDenom: denomBze, + StakedAmount: "50", + DistributedStake: "5", + Lock: 100, + StakingDenom: denomBze, + Duration: 100, + Payouts: 100, + } + suite.k.SetStakingReward(suite.ctx, sr) + + srp := types.StakingRewardParticipant{ + Address: addr1.String(), + RewardId: sr.RewardId, + Amount: "50", + JoinedAt: "0", + } + suite.k.SetStakingRewardParticipant(suite.ctx, srp) + + balances := sdk.NewCoins(newStakeCoin(10000), newBzeCoin(50000)) + suite.Require().NoError(simapp.FundModuleAccount(suite.app.BankKeeper, suite.ctx, types.ModuleName, balances)) + + //tests and asserts + msg := types.MsgExitStaking{ + Creator: addr1.String(), + RewardId: sr.RewardId, + } + _, err := suite.msgServer.ExitStaking(goCtx, &msg) + suite.Require().NoError(err) + + creatorBalance := suite.app.BankKeeper.GetAllBalances(suite.ctx, addr1) + //check the user retrieves the unclaimed rewards first + suite.Require().EqualValues(creatorBalance.AmountOf(denomBze).String(), "250") + + //check the unlock was created + lockKey := types.CreatePendingUnlockParticipantKey(int64(sr.Lock*24), fmt.Sprintf("%s/%s", sr.RewardId, srp.Address)) + unlockList := suite.k.GetAllPendingUnlockParticipant(suite.ctx) + suite.Require().NotEmpty(unlockList) + suite.Require().EqualValues(unlockList[0].Index, lockKey) + suite.Require().EqualValues(unlockList[0].Address, srp.Address) + suite.Require().EqualValues(unlockList[0].Amount, "50") + suite.Require().EqualValues(unlockList[0].Denom, sr.StakingDenom) + + //check the staking reward participant was deleted + _, f := suite.k.GetStakingRewardParticipant(suite.ctx, srp.Address, sr.RewardId) + suite.Require().False(f) + + //check the staking reward was deleted + _, f = suite.k.GetStakingReward(suite.ctx, sr.RewardId) + suite.Require().False(f) +} diff --git a/x/rewards/keeper/msg_server_join_staking.go b/x/rewards/keeper/msg_server_join_staking.go index c450f38a..017182b8 100644 --- a/x/rewards/keeper/msg_server_join_staking.go +++ b/x/rewards/keeper/msg_server_join_staking.go @@ -110,6 +110,12 @@ func (k msgServer) claimPending(ctx sdk.Context, sr types.StakingReward, partici return nil, err } + //user has nothing to claim + if distributedStake.Equal(joinedAt) { + zeroCoins := sdk.NewCoin(sr.PrizeDenom, sdk.NewInt(0)) + return &zeroCoins, nil + } + reward := deposited.Mul(distributedStake.Sub(joinedAt)).TruncateInt() if !reward.IsPositive() { return nil, fmt.Errorf("no rewards to claim") diff --git a/x/rewards/keeper/staking_reward_distribution.go b/x/rewards/keeper/staking_reward_distribution.go index 396f69ed..a5eb6f55 100644 --- a/x/rewards/keeper/staking_reward_distribution.go +++ b/x/rewards/keeper/staking_reward_distribution.go @@ -22,7 +22,7 @@ func (k Keeper) getDistributeRewardHandler() func(ctx sdk.Context, reward types. return } - err := k.distributeStakingRewards(ctx, &sr, sr.PrizeAmount) + err := k.distributeStakingRewards(&sr, sr.PrizeAmount) if err != nil { logger.Error(err.Error()) stop = false @@ -33,13 +33,22 @@ func (k Keeper) getDistributeRewardHandler() func(ctx sdk.Context, reward types. sr.Payouts++ k.SetStakingReward(ctx, sr) - logger.Debug("staking reward distributed") + err = ctx.EventManager().EmitTypedEvent( + &types.StakingRewardDistributionEvent{ + RewardId: sr.RewardId, + Amount: sr.PrizeAmount, + }, + ) + + if err != nil { + k.Logger(ctx).Error(err.Error()) + } return } } -func (k Keeper) distributeStakingRewards(ctx sdk.Context, sr *types.StakingReward, rewardAmount string) error { +func (k Keeper) distributeStakingRewards(sr *types.StakingReward, rewardAmount string) error { stakedAmount, ok := sdk.NewIntFromString(sr.StakedAmount) if !ok { return fmt.Errorf("could not transform staked amount from storage into int") @@ -67,16 +76,5 @@ func (k Keeper) distributeStakingRewards(ctx sdk.Context, sr *types.StakingRewar sFloat = sFloat.Add(reward.ToDec().Quo(stakedAmount.ToDec())) sr.DistributedStake = sFloat.String() - err = ctx.EventManager().EmitTypedEvent( - &types.StakingRewardDistributionEvent{ - RewardId: sr.RewardId, - Amount: rewardAmount, - }, - ) - - if err != nil { - k.Logger(ctx).Error(err.Error()) - } - return nil } From ddb39dc5e20cbe53841a4a3af8328635b0040267 Mon Sep 17 00:00:00 2001 From: faneaatiku Date: Sat, 20 Apr 2024 11:10:23 +0300 Subject: [PATCH 33/35] test join staking and fix trading reward counter --- .../keeper/msg_server_join_staking_test.go | 213 ++++++++++++++++++ x/rewards/keeper/trading_reward.go | 7 +- 2 files changed, 217 insertions(+), 3 deletions(-) create mode 100644 x/rewards/keeper/msg_server_join_staking_test.go diff --git a/x/rewards/keeper/msg_server_join_staking_test.go b/x/rewards/keeper/msg_server_join_staking_test.go new file mode 100644 index 00000000..fec3b01e --- /dev/null +++ b/x/rewards/keeper/msg_server_join_staking_test.go @@ -0,0 +1,213 @@ +package keeper_test + +import ( + "github.com/bze-alphateam/bze/testutil/simapp" + "github.com/bze-alphateam/bze/x/rewards/types" + sdk "github.com/cosmos/cosmos-sdk/types" + sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" +) + +func (suite *IntegrationTestSuite) TestMsgJoinStaking_InvalidRequest() { + goCtx := sdk.WrapSDKContext(suite.ctx) + + _, err := suite.msgServer.JoinStaking(goCtx, nil) + suite.Require().Error(err) + suite.Require().ErrorIs(err, sdkerrors.ErrInvalidRequest) +} + +func (suite *IntegrationTestSuite) TestMsgJoinStaking_InvalidCreator() { + //dependencies + goCtx := sdk.WrapSDKContext(suite.ctx) + msg := types.MsgJoinStaking{ + Creator: "", + RewardId: "", + Amount: "", + } + + _, err := suite.msgServer.JoinStaking(goCtx, &msg) + suite.Require().Error(err) +} + +func (suite *IntegrationTestSuite) TestMsgJoinStaking_MissingStakingReward() { + //dependencies + goCtx := sdk.WrapSDKContext(suite.ctx) + addr1 := sdk.AccAddress("addr1_______________") + msg := types.MsgJoinStaking{ + Creator: addr1.String(), + RewardId: "0001", + Amount: "", + } + + _, err := suite.msgServer.JoinStaking(goCtx, &msg) + suite.Require().Error(err) + suite.Require().ErrorContains(err, "reward with provided id not found") +} + +func (suite *IntegrationTestSuite) TestMsgJoinStaking_AmountLowerThanMinStake() { + //dependencies + goCtx := sdk.WrapSDKContext(suite.ctx) + addr1 := sdk.AccAddress("addr1_______________") + sr := types.StakingReward{ + RewardId: "01", + PrizeDenom: denomBze, + StakedAmount: "50", + DistributedStake: "5", + Lock: 100, + StakingDenom: denomBze, + Duration: 100, + Payouts: 5, + MinStake: 1000, + } + suite.k.SetStakingReward(suite.ctx, sr) + + msg := types.MsgJoinStaking{ + Creator: addr1.String(), + RewardId: sr.RewardId, + Amount: "1", + } + + _, err := suite.msgServer.JoinStaking(goCtx, &msg) + suite.Require().Error(err) + suite.Require().ErrorContains(err, "amount is smaller than staking reward min stake") +} + +func (suite *IntegrationTestSuite) TestMsgJoinStaking_NotEnoughBalance() { + //dependencies + goCtx := sdk.WrapSDKContext(suite.ctx) + addr1 := sdk.AccAddress("addr1_______________") + sr := types.StakingReward{ + RewardId: "01", + PrizeDenom: denomBze, + StakedAmount: "50", + DistributedStake: "5", + Lock: 100, + StakingDenom: denomBze, + Duration: 100, + Payouts: 5, + MinStake: 1, + } + suite.k.SetStakingReward(suite.ctx, sr) + + //test and assertions + msg := types.MsgJoinStaking{ + Creator: addr1.String(), + RewardId: sr.RewardId, + Amount: "10", + } + + _, err := suite.msgServer.JoinStaking(goCtx, &msg) + suite.Require().Error(err) + suite.Require().ErrorContains(err, "user balance is too low") +} + +func (suite *IntegrationTestSuite) TestMsgJoinStaking_Success_NewParticipant() { + //dependencies + goCtx := sdk.WrapSDKContext(suite.ctx) + addr1 := sdk.AccAddress("addr1_______________") + + balances := sdk.NewCoins(sdk.NewInt64Coin("ubze", 10000)) + suite.Require().NoError(simapp.FundAccount(suite.app.BankKeeper, suite.ctx, addr1, balances)) + + sr := types.StakingReward{ + RewardId: "01", + PrizeDenom: denomBze, + StakedAmount: "0", + DistributedStake: "0", + Lock: 100, + StakingDenom: denomBze, + Duration: 100, + Payouts: 5, + MinStake: 1, + } + suite.k.SetStakingReward(suite.ctx, sr) + + //test and assertions + msg := types.MsgJoinStaking{ + Creator: addr1.String(), + RewardId: sr.RewardId, + Amount: "10", + } + + _, err := suite.msgServer.JoinStaking(goCtx, &msg) + suite.Require().NoError(err) + + part, f := suite.k.GetStakingRewardParticipant(suite.ctx, msg.Creator, sr.RewardId) + suite.Require().True(f) + suite.Require().EqualValues(part.JoinedAt, sr.DistributedStake) + suite.Require().EqualValues(part.Address, msg.Creator) + suite.Require().EqualValues(part.Amount, msg.Amount) + suite.Require().EqualValues(part.RewardId, msg.RewardId) + + storageSr, f := suite.k.GetStakingReward(suite.ctx, sr.RewardId) + suite.Require().True(f) + suite.Require().EqualValues(storageSr.StakedAmount, "10") + + creatorBalance := suite.app.BankKeeper.GetAllBalances(suite.ctx, addr1) + //check the user retrieves the unclaimed rewards first + suite.Require().EqualValues(creatorBalance.AmountOf(denomBze).String(), "9990") + + //check balances were subtracted from module + moduleAddr := suite.app.AccountKeeper.GetModuleAddress(types.ModuleName) + newBalances := suite.app.BankKeeper.GetAllBalances(suite.ctx, moduleAddr) + suite.Require().EqualValues(newBalances.AmountOf(denomBze).String(), "10") +} + +func (suite *IntegrationTestSuite) TestMsgJoinStaking_Success_ExistingParticipant() { + //dependencies + goCtx := sdk.WrapSDKContext(suite.ctx) + addr1 := sdk.AccAddress("addr1_______________") + + balances := sdk.NewCoins(sdk.NewInt64Coin("ubze", 10000)) + suite.Require().NoError(simapp.FundAccount(suite.app.BankKeeper, suite.ctx, addr1, balances)) + + sr := types.StakingReward{ + RewardId: "01", + PrizeDenom: denomBze, + StakedAmount: "50", + DistributedStake: "0", + Lock: 100, + StakingDenom: denomBze, + Duration: 100, + Payouts: 0, + MinStake: 10, + } + suite.k.SetStakingReward(suite.ctx, sr) + + srp := types.StakingRewardParticipant{ + Address: addr1.String(), + RewardId: sr.RewardId, + Amount: "50", + JoinedAt: "0", + } + suite.k.SetStakingRewardParticipant(suite.ctx, srp) + + //test and assertions + msg := types.MsgJoinStaking{ + Creator: addr1.String(), + RewardId: sr.RewardId, + Amount: "10", + } + + _, err := suite.msgServer.JoinStaking(goCtx, &msg) + suite.Require().NoError(err) + + part, f := suite.k.GetStakingRewardParticipant(suite.ctx, msg.Creator, sr.RewardId) + suite.Require().True(f) + suite.Require().EqualValues(part.JoinedAt, sr.DistributedStake) + suite.Require().EqualValues(part.Address, msg.Creator) + suite.Require().EqualValues(part.Amount, "60") + suite.Require().EqualValues(part.RewardId, msg.RewardId) + + storageSr, f := suite.k.GetStakingReward(suite.ctx, sr.RewardId) + suite.Require().True(f) + suite.Require().EqualValues(storageSr.StakedAmount, "60") + + creatorBalance := suite.app.BankKeeper.GetAllBalances(suite.ctx, addr1) + //check the user retrieves the unclaimed rewards first + suite.Require().EqualValues(creatorBalance.AmountOf(denomBze).String(), "9990") + + //check balances were subtracted from module + moduleAddr := suite.app.AccountKeeper.GetModuleAddress(types.ModuleName) + newBalances := suite.app.BankKeeper.GetAllBalances(suite.ctx, moduleAddr) + suite.Require().EqualValues(newBalances.AmountOf(denomBze).String(), "10") +} diff --git a/x/rewards/keeper/trading_reward.go b/x/rewards/keeper/trading_reward.go index eafa5917..bb3dd375 100644 --- a/x/rewards/keeper/trading_reward.go +++ b/x/rewards/keeper/trading_reward.go @@ -14,9 +14,10 @@ func (k Keeper) getPendingTradingRewardStore(ctx sdk.Context) prefix.Store { return prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.PendingTradingRewardKeyPrefix)) } -func (k Keeper) setTradingReward(store prefix.Store, tradingReward types.TradingReward) { +func (k Keeper) setTradingReward(ctx sdk.Context, store prefix.Store, tradingReward types.TradingReward) { b := k.cdc.MustMarshal(&tradingReward) store.Set(types.TradingRewardKey(tradingReward.RewardId), b) + k.incrementTradingRewardsCounter(ctx) } func (k Keeper) getTradingReward(store prefix.Store, rewardId string) (val types.TradingReward, found bool) { @@ -52,7 +53,7 @@ func (k Keeper) getAllTradingReward(store prefix.Store) (list []types.TradingRew // SetPendingTradingReward set a specific tradingReward in the store from its index func (k Keeper) SetPendingTradingReward(ctx sdk.Context, tradingReward types.TradingReward) { store := k.getPendingTradingRewardStore(ctx) - k.setTradingReward(store, tradingReward) + k.setTradingReward(ctx, store, tradingReward) } // GetPendingTradingReward returns a tradingReward from its index @@ -78,7 +79,7 @@ func (k Keeper) GetAllPendingTradingReward(ctx sdk.Context) []types.TradingRewar // SetActiveTradingReward set a specific tradingReward in the store from its index func (k Keeper) SetActiveTradingReward(ctx sdk.Context, tradingReward types.TradingReward) { store := k.getActiveTradingRewardStore(ctx) - k.setTradingReward(store, tradingReward) + k.setTradingReward(ctx, store, tradingReward) } // GetActiveTradingReward returns a tradingReward from its index From 62f203630b6380af8d35c69be27b46431c82f3ad Mon Sep 17 00:00:00 2001 From: faneaatiku Date: Sun, 21 Apr 2024 01:37:52 +0300 Subject: [PATCH 34/35] more tests and fixes --- x/rewards/keeper/msg_server_test.go | 16 -- .../keeper/pending_unlock_participant_test.go | 40 +++++ .../keeper/staking_reward_distribution.go | 6 + .../staking_reward_distribution_test.go | 58 ++++++++ .../keeper/staking_reward_participant_test.go | 81 ++++------ x/rewards/keeper/staking_reward_test.go | 86 +++++------ .../trading_reward_distribution_test.go | 1 + .../keeper/trading_reward_expiration_test.go | 62 ++++++++ x/rewards/keeper/trading_reward_test.go | 139 ++++++++++++------ 9 files changed, 326 insertions(+), 163 deletions(-) delete mode 100644 x/rewards/keeper/msg_server_test.go create mode 100644 x/rewards/keeper/pending_unlock_participant_test.go create mode 100644 x/rewards/keeper/staking_reward_distribution_test.go create mode 100644 x/rewards/keeper/trading_reward_distribution_test.go create mode 100644 x/rewards/keeper/trading_reward_expiration_test.go diff --git a/x/rewards/keeper/msg_server_test.go b/x/rewards/keeper/msg_server_test.go deleted file mode 100644 index cfb4eb52..00000000 --- a/x/rewards/keeper/msg_server_test.go +++ /dev/null @@ -1,16 +0,0 @@ -package keeper_test - -import ( - "context" - "testing" - - keepertest "github.com/bze-alphateam/bze/testutil/keeper" - "github.com/bze-alphateam/bze/x/rewards/keeper" - "github.com/bze-alphateam/bze/x/rewards/types" - sdk "github.com/cosmos/cosmos-sdk/types" -) - -func setupMsgServer(t testing.TB) (types.MsgServer, context.Context) { - k, ctx := keepertest.RewardsKeeper(t) - return keeper.NewMsgServerImpl(*k), sdk.WrapSDKContext(ctx) -} diff --git a/x/rewards/keeper/pending_unlock_participant_test.go b/x/rewards/keeper/pending_unlock_participant_test.go new file mode 100644 index 00000000..7f65636e --- /dev/null +++ b/x/rewards/keeper/pending_unlock_participant_test.go @@ -0,0 +1,40 @@ +package keeper_test + +import ( + "github.com/bze-alphateam/bze/x/rewards/types" + "strconv" +) + +func (suite *IntegrationTestSuite) TestPendingUnlockParticipant() { + list := suite.k.GetAllPendingUnlockParticipant(suite.ctx) + suite.Require().Empty(list) + + staticEpoch := 500 + max := 10 + for i := 1; i <= max; i++ { + pup := types.PendingUnlockParticipant{Index: types.CreatePendingUnlockParticipantKey(int64(i), "something")} + suite.k.SetPendingUnlockParticipant(suite.ctx, pup) + + pup = types.PendingUnlockParticipant{Index: types.CreatePendingUnlockParticipantKey(int64(staticEpoch), strconv.Itoa(i))} + suite.k.SetPendingUnlockParticipant(suite.ctx, pup) + + list = suite.k.GetAllPendingUnlockParticipant(suite.ctx) + suite.Require().NotEmpty(list) + suite.Require().EqualValues(len(list), 2*i) + + list = suite.k.GetAllEpochPendingUnlockParticipant(suite.ctx, int64(i)) + suite.Require().NotEmpty(list) + suite.Require().EqualValues(len(list), 1) + } + + list = suite.k.GetAllEpochPendingUnlockParticipant(suite.ctx, int64(staticEpoch)) + suite.Require().NotEmpty(list) + suite.Require().EqualValues(len(list), max) + + pup := types.PendingUnlockParticipant{Index: types.CreatePendingUnlockParticipantKey(int64(staticEpoch), "5")} + suite.k.RemovePendingUnlockParticipant(suite.ctx, pup) + + list = suite.k.GetAllEpochPendingUnlockParticipant(suite.ctx, int64(staticEpoch)) + suite.Require().NotEmpty(list) + suite.Require().EqualValues(len(list), max-1) +} diff --git a/x/rewards/keeper/staking_reward_distribution.go b/x/rewards/keeper/staking_reward_distribution.go index a5eb6f55..68caf8a1 100644 --- a/x/rewards/keeper/staking_reward_distribution.go +++ b/x/rewards/keeper/staking_reward_distribution.go @@ -16,6 +16,12 @@ func (k Keeper) getDistributeRewardHandler() func(ctx sdk.Context, reward types. logger.Debug("preparing to distribute staking reward") + if sr.StakedAmount == "0" { + logger.Debug("staking reward has no staked coins. skipping distribution") + stop = false + return + } + if sr.Payouts >= sr.Duration { logger.Debug("staking reward finished. skipping distribution") stop = false diff --git a/x/rewards/keeper/staking_reward_distribution_test.go b/x/rewards/keeper/staking_reward_distribution_test.go new file mode 100644 index 00000000..3331a3ac --- /dev/null +++ b/x/rewards/keeper/staking_reward_distribution_test.go @@ -0,0 +1,58 @@ +package keeper_test + +import ( + "fmt" + "github.com/bze-alphateam/bze/x/rewards/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +func (suite *IntegrationTestSuite) TestDistributeAllStakingRewards() { + initial := types.StakingReward{ + RewardId: "01", + PrizeAmount: "100", + PrizeDenom: denomBze, + StakingDenom: denomStake, + Duration: 10, + Payouts: 0, + MinStake: 0, + Lock: 10, + StakedAmount: "10", + DistributedStake: "0", + } + suite.k.SetStakingReward(suite.ctx, initial) + + rewardAmt, ok := sdk.NewIntFromString(initial.PrizeAmount) + suite.Require().True(ok) + + for i := uint32(0); i < initial.Duration; i++ { + suite.k.DistributeAllStakingRewards(suite.ctx) + storage, f := suite.k.GetStakingReward(suite.ctx, initial.RewardId) + suite.Require().True(f) + suite.Require().EqualValues(storage.Payouts, i+1) + + staked, ok := sdk.NewIntFromString(storage.StakedAmount) + suite.Require().True(ok) + + newDistribution := rewardAmt.ToDec().Quo(staked.ToDec()) + distributed, err := sdk.NewDecFromStr(initial.DistributedStake) + suite.Require().NoError(err) + + distributed = distributed.Add(newDistribution) + suite.Require().EqualValuesf(distributed.String(), storage.DistributedStake, fmt.Sprintf("values not equal on %d iteration", i)) + + initial.DistributedStake = distributed.String() + staked = staked.AddRaw(int64(i)) + initial.StakedAmount = staked.String() + storage.StakedAmount = initial.StakedAmount + + suite.k.SetStakingReward(suite.ctx, storage) + } + + suite.k.DistributeAllStakingRewards(suite.ctx) + suite.k.DistributeAllStakingRewards(suite.ctx) + suite.k.DistributeAllStakingRewards(suite.ctx) + storage, f := suite.k.GetStakingReward(suite.ctx, initial.RewardId) + suite.Require().True(f) + suite.Require().EqualValues(storage.Payouts, initial.Duration) + suite.Require().EqualValues(storage.DistributedStake, initial.DistributedStake) +} diff --git a/x/rewards/keeper/staking_reward_participant_test.go b/x/rewards/keeper/staking_reward_participant_test.go index 225c948f..1823ea7d 100644 --- a/x/rewards/keeper/staking_reward_participant_test.go +++ b/x/rewards/keeper/staking_reward_participant_test.go @@ -1,56 +1,37 @@ package keeper_test import ( + "github.com/bze-alphateam/bze/x/rewards/types" "strconv" ) -// Prevent strconv unused error -var _ = strconv.IntSize - -// -//func createNStakingRewardParticipant(keeper *keeper.Keeper, ctx sdk.Context, n int) []types.StakingRewardParticipant { -// items := make([]types.StakingRewardParticipant, n) -// for i := range items { -// items[i].Index = strconv.Itoa(i) -// -// keeper.SetStakingRewardParticipant(ctx, items[i]) -// } -// return items -//} -// -//func TestStakingRewardParticipantGet(t *testing.T) { -// keeper, ctx := keepertest.RewardsKeeper(t) -// items := createNStakingRewardParticipant(keeper, ctx, 10) -// for _, item := range items { -// rst, found := keeper.GetStakingRewardParticipant(ctx, -// item.Index, -// ) -// require.True(t, found) -// require.Equal(t, -// nullify.Fill(&item), -// nullify.Fill(&rst), -// ) -// } -//} -//func TestStakingRewardParticipantRemove(t *testing.T) { -// keeper, ctx := keepertest.RewardsKeeper(t) -// items := createNStakingRewardParticipant(keeper, ctx, 10) -// for _, item := range items { -// keeper.RemoveStakingRewardParticipant(ctx, -// item.Index, -// ) -// _, found := keeper.GetStakingRewardParticipant(ctx, -// item.Index, -// ) -// require.False(t, found) -// } -//} -// -//func TestStakingRewardParticipantGetAll(t *testing.T) { -// keeper, ctx := keepertest.RewardsKeeper(t) -// items := createNStakingRewardParticipant(keeper, ctx, 10) -// require.ElementsMatch(t, -// nullify.Fill(items), -// nullify.Fill(keeper.GetAllStakingRewardParticipant(ctx)), -// ) -//} +func (suite *IntegrationTestSuite) TestStakingRewardParticipant() { + list := suite.k.GetAllStakingRewardParticipant(suite.ctx) + suite.Require().Empty(list) + + _, f := suite.k.GetStakingRewardParticipant(suite.ctx, "fake", "fake2") + suite.Require().False(f) + + max := 10 + for i := 0; i < max; i++ { + convI := strconv.Itoa(i) + srp := types.StakingRewardParticipant{Address: convI, RewardId: convI} + suite.k.SetStakingRewardParticipant(suite.ctx, srp) + + newSrp, f := suite.k.GetStakingRewardParticipant(suite.ctx, convI, convI) + suite.Require().True(f) + suite.Require().EqualValues(newSrp, srp) + } + + list = suite.k.GetAllStakingRewardParticipant(suite.ctx) + suite.Require().NotEmpty(list) + suite.Require().EqualValues(len(list), max) + + suite.k.RemoveStakingRewardParticipant(suite.ctx, "0", "0") + _, f = suite.k.GetStakingRewardParticipant(suite.ctx, "0", "0") + suite.Require().False(f) + + list = suite.k.GetAllStakingRewardParticipant(suite.ctx) + suite.Require().NotEmpty(list) + suite.Require().EqualValues(len(list), max-1) +} diff --git a/x/rewards/keeper/staking_reward_test.go b/x/rewards/keeper/staking_reward_test.go index ba855045..68c63d40 100644 --- a/x/rewards/keeper/staking_reward_test.go +++ b/x/rewards/keeper/staking_reward_test.go @@ -1,63 +1,49 @@ package keeper_test import ( - "strconv" - "testing" - - keepertest "github.com/bze-alphateam/bze/testutil/keeper" - "github.com/bze-alphateam/bze/testutil/nullify" - "github.com/bze-alphateam/bze/x/rewards/keeper" "github.com/bze-alphateam/bze/x/rewards/types" sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/stretchr/testify/require" + "strconv" ) -// Prevent strconv unused error -var _ = strconv.IntSize +func (suite *IntegrationTestSuite) TestStakingReward() { + list := suite.k.GetAllStakingReward(suite.ctx) + suite.Require().Empty(list) -func createNStakingReward(keeper *keeper.Keeper, ctx sdk.Context, n int) []types.StakingReward { - items := make([]types.StakingReward, n) - for i := range items { - items[i].RewardId = strconv.Itoa(i) + _, f := suite.k.GetStakingReward(suite.ctx, "fake") + suite.Require().False(f) - keeper.SetStakingReward(ctx, items[i]) - } - return items -} + counter := suite.k.GetStakingRewardsCounter(suite.ctx) + suite.Require().EqualValues(counter, 0) -func TestStakingRewardGet(t *testing.T) { - keeper, ctx := keepertest.RewardsKeeper(t) - items := createNStakingReward(keeper, ctx, 10) - for _, item := range items { - rst, found := keeper.GetStakingReward(ctx, - item.RewardId, - ) - require.True(t, found) - require.Equal(t, - nullify.Fill(&item), - nullify.Fill(&rst), - ) - } -} -func TestStakingRewardRemove(t *testing.T) { - keeper, ctx := keepertest.RewardsKeeper(t) - items := createNStakingReward(keeper, ctx, 10) - for _, item := range items { - keeper.RemoveStakingReward(ctx, - item.RewardId, - ) - _, found := keeper.GetStakingReward(ctx, - item.RewardId, - ) - require.False(t, found) + max := 10 + for i := 0; i < max; i++ { + sr := types.StakingReward{RewardId: strconv.Itoa(i), Lock: uint32(i)} + suite.k.SetStakingReward(suite.ctx, sr) + + newSr, f := suite.k.GetStakingReward(suite.ctx, sr.RewardId) + suite.Require().True(f) + suite.Require().EqualValues(newSr, sr) } -} -func TestStakingRewardGetAll(t *testing.T) { - keeper, ctx := keepertest.RewardsKeeper(t) - items := createNStakingReward(keeper, ctx, 10) - require.ElementsMatch(t, - nullify.Fill(items), - nullify.Fill(keeper.GetAllStakingReward(ctx)), - ) + list = suite.k.GetAllStakingReward(suite.ctx) + suite.Require().NotEmpty(list) + suite.Require().EqualValues(len(list), max) + + suite.k.IterateAllStakingRewards(suite.ctx, func(ctx sdk.Context, sr types.StakingReward) (stop bool) { + suite.Require().LessOrEqual(sr.Lock, uint32(max)) + + return false + }) + + counter = suite.k.GetStakingRewardsCounter(suite.ctx) + suite.Require().EqualValues(counter, max) + + suite.k.RemoveStakingReward(suite.ctx, "0") + _, f = suite.k.GetStakingReward(suite.ctx, "0") + suite.Require().False(f) + + list = suite.k.GetAllStakingReward(suite.ctx) + suite.Require().NotEmpty(list) + suite.Require().EqualValues(len(list), max-1) } diff --git a/x/rewards/keeper/trading_reward_distribution_test.go b/x/rewards/keeper/trading_reward_distribution_test.go new file mode 100644 index 00000000..94292649 --- /dev/null +++ b/x/rewards/keeper/trading_reward_distribution_test.go @@ -0,0 +1 @@ +package keeper_test diff --git a/x/rewards/keeper/trading_reward_expiration_test.go b/x/rewards/keeper/trading_reward_expiration_test.go new file mode 100644 index 00000000..7a344b06 --- /dev/null +++ b/x/rewards/keeper/trading_reward_expiration_test.go @@ -0,0 +1,62 @@ +package keeper_test + +import ( + "github.com/bze-alphateam/bze/x/rewards/types" + "strconv" +) + +func (suite *IntegrationTestSuite) TestPendingTradingRewardExpiration() { + list := suite.k.GetAllPendingTradingRewardExpiration(suite.ctx) + suite.Require().Empty(list) + + max := 10 + for i := 1; i <= max; i++ { + ptre := types.TradingRewardExpiration{RewardId: "01", ExpireAt: uint32(i)} + suite.k.SetPendingTradingRewardExpiration(suite.ctx, ptre) + + ptre = types.TradingRewardExpiration{RewardId: strconv.Itoa(i), ExpireAt: uint32(i)} + suite.k.SetPendingTradingRewardExpiration(suite.ctx, ptre) + + list = suite.k.GetAllPendingTradingRewardExpiration(suite.ctx) + suite.Require().EqualValues(len(list), i*2) + + //just check the other list is not altered + list = suite.k.GetAllActiveTradingRewardExpiration(suite.ctx) + suite.Require().Empty(list) + + list = suite.k.GetAllPendingTradingRewardExpirationByExpireAt(suite.ctx, uint32(i)) + suite.Require().EqualValues(len(list), 2) + } + + suite.k.RemovePendingTradingRewardExpiration(suite.ctx, 1, "1") + list = suite.k.GetAllPendingTradingRewardExpirationByExpireAt(suite.ctx, uint32(1)) + suite.Require().EqualValues(len(list), 1) +} + +func (suite *IntegrationTestSuite) TestActiveTradingRewardExpiration() { + list := suite.k.GetAllActiveTradingRewardExpiration(suite.ctx) + suite.Require().Empty(list) + + max := 10 + for i := 1; i <= max; i++ { + ptre := types.TradingRewardExpiration{RewardId: "01", ExpireAt: uint32(i)} + suite.k.SetActiveTradingRewardExpiration(suite.ctx, ptre) + + ptre = types.TradingRewardExpiration{RewardId: strconv.Itoa(i), ExpireAt: uint32(i)} + suite.k.SetActiveTradingRewardExpiration(suite.ctx, ptre) + + list = suite.k.GetAllActiveTradingRewardExpiration(suite.ctx) + suite.Require().EqualValues(len(list), i*2) + + //just check the other list is not altered + list = suite.k.GetAllPendingTradingRewardExpiration(suite.ctx) + suite.Require().Empty(list) + + list = suite.k.GetAllActiveTradingRewardExpirationByExpireAt(suite.ctx, uint32(i)) + suite.Require().EqualValues(len(list), 2) + } + + suite.k.RemoveActiveTradingRewardExpiration(suite.ctx, 1, "1") + list = suite.k.GetAllActiveTradingRewardExpirationByExpireAt(suite.ctx, uint32(1)) + suite.Require().EqualValues(len(list), 1) +} diff --git a/x/rewards/keeper/trading_reward_test.go b/x/rewards/keeper/trading_reward_test.go index f65ccdba..5ac6bba1 100644 --- a/x/rewards/keeper/trading_reward_test.go +++ b/x/rewards/keeper/trading_reward_test.go @@ -1,63 +1,108 @@ package keeper_test import ( - "strconv" - "testing" - - keepertest "github.com/bze-alphateam/bze/testutil/keeper" - "github.com/bze-alphateam/bze/testutil/nullify" - "github.com/bze-alphateam/bze/x/rewards/keeper" "github.com/bze-alphateam/bze/x/rewards/types" - sdk "github.com/cosmos/cosmos-sdk/types" - "github.com/stretchr/testify/require" + "strconv" ) -// Prevent strconv unused error -var _ = strconv.IntSize +func (suite *IntegrationTestSuite) TestPendingTradingReward() { + list := suite.k.GetAllPendingTradingReward(suite.ctx) + suite.Require().Empty(list) -func createNTradingReward(keeper *keeper.Keeper, ctx sdk.Context, n int) []types.TradingReward { - items := make([]types.TradingReward, n) - for i := range items { - items[i].RewardId = strconv.Itoa(i) + _, f := suite.k.GetPendingTradingReward(suite.ctx, "fake") + suite.Require().False(f) - keeper.SetPendingTradingReward(ctx, items[i]) + counter := suite.k.GetTradingRewardsCounter(suite.ctx) + suite.Require().EqualValues(counter, 0) + + max := 10 + for i := 0; i < max; i++ { + tr := types.TradingReward{RewardId: strconv.Itoa(i), Slots: uint32(i)} + suite.k.SetPendingTradingReward(suite.ctx, tr) + + newSr, f := suite.k.GetPendingTradingReward(suite.ctx, tr.RewardId) + suite.Require().True(f) + suite.Require().EqualValues(newSr, tr) } - return items + + list = suite.k.GetAllPendingTradingReward(suite.ctx) + suite.Require().NotEmpty(list) + suite.Require().EqualValues(len(list), max) + + counter = suite.k.GetTradingRewardsCounter(suite.ctx) + suite.Require().EqualValues(counter, max) + + suite.k.RemovePendingTradingReward(suite.ctx, "0") + _, f = suite.k.GetPendingTradingReward(suite.ctx, "0") + suite.Require().False(f) + + list = suite.k.GetAllPendingTradingReward(suite.ctx) + suite.Require().NotEmpty(list) + suite.Require().EqualValues(len(list), max-1) } -func TestTradingRewardGet(t *testing.T) { - keeper, ctx := keepertest.RewardsKeeper(t) - items := createNTradingReward(keeper, ctx, 10) - for _, item := range items { - rst, found := keeper.GetPendingTradingReward(ctx, - item.RewardId, - ) - require.True(t, found) - require.Equal(t, - nullify.Fill(&item), - nullify.Fill(&rst), - ) +func (suite *IntegrationTestSuite) TestActiveTradingReward() { + list := suite.k.GetAllActiveTradingReward(suite.ctx) + suite.Require().Empty(list) + + _, f := suite.k.GetActiveTradingReward(suite.ctx, "fake") + suite.Require().False(f) + + counter := suite.k.GetTradingRewardsCounter(suite.ctx) + suite.Require().EqualValues(counter, 0) + + max := 10 + for i := 0; i < max; i++ { + tr := types.TradingReward{RewardId: strconv.Itoa(i), Slots: uint32(i)} + suite.k.SetActiveTradingReward(suite.ctx, tr) + + newSr, f := suite.k.GetActiveTradingReward(suite.ctx, tr.RewardId) + suite.Require().True(f) + suite.Require().EqualValues(newSr, tr) } + + list = suite.k.GetAllActiveTradingReward(suite.ctx) + suite.Require().NotEmpty(list) + suite.Require().EqualValues(len(list), max) + + counter = suite.k.GetTradingRewardsCounter(suite.ctx) + suite.Require().EqualValues(counter, max) + + suite.k.RemoveActiveTradingReward(suite.ctx, "0") + _, f = suite.k.GetActiveTradingReward(suite.ctx, "0") + suite.Require().False(f) + + list = suite.k.GetAllActiveTradingReward(suite.ctx) + suite.Require().NotEmpty(list) + suite.Require().EqualValues(len(list), max-1) } -func TestTradingRewardRemove(t *testing.T) { - keeper, ctx := keepertest.RewardsKeeper(t) - items := createNTradingReward(keeper, ctx, 10) - for _, item := range items { - keeper.RemovePendingTradingReward(ctx, - item.RewardId, - ) - _, found := keeper.GetPendingTradingReward(ctx, - item.RewardId, - ) - require.False(t, found) + +func (suite *IntegrationTestSuite) TestMarketIdRewardId() { + list := suite.k.GetAllMarketIdRewardId(suite.ctx) + suite.Require().Empty(list) + + _, f := suite.k.GetMarketIdRewardId(suite.ctx, "fake") + suite.Require().False(f) + + max := 10 + for i := 0; i < max; i++ { + mid := types.MarketIdTradingRewardId{MarketId: strconv.Itoa(i)} + suite.k.SetMarketIdRewardId(suite.ctx, mid) + + newSr, f := suite.k.GetMarketIdRewardId(suite.ctx, mid.MarketId) + suite.Require().True(f) + suite.Require().EqualValues(newSr, mid) } -} -func TestTradingRewardGetAll(t *testing.T) { - keeper, ctx := keepertest.RewardsKeeper(t) - items := createNTradingReward(keeper, ctx, 10) - require.ElementsMatch(t, - nullify.Fill(items), - nullify.Fill(keeper.GetAllPendingTradingReward(ctx)), - ) + list = suite.k.GetAllMarketIdRewardId(suite.ctx) + suite.Require().NotEmpty(list) + suite.Require().EqualValues(len(list), max) + + suite.k.RemoveMarketIdRewardId(suite.ctx, "0") + _, f = suite.k.GetMarketIdRewardId(suite.ctx, "0") + suite.Require().False(f) + + list = suite.k.GetAllMarketIdRewardId(suite.ctx) + suite.Require().NotEmpty(list) + suite.Require().EqualValues(len(list), max-1) } From e355a8ecac6bcbc7eaf4c3c641a581265be9a5b5 Mon Sep 17 00:00:00 2001 From: faneaatiku Date: Sun, 21 Apr 2024 02:15:38 +0300 Subject: [PATCH 35/35] test hooks and renamed confusing function --- app/app.go | 2 +- testutil/simapp/app.go | 2 +- x/rewards/keeper/cleanup.go | 2 +- x/rewards/keeper/hooks.go | 4 +- x/rewards/keeper/hooks_test.go | 152 +++++++++++++++++++++++++++++++++ 5 files changed, 157 insertions(+), 5 deletions(-) create mode 100644 x/rewards/keeper/hooks_test.go diff --git a/app/app.go b/app/app.go index 6210e679..05b1f4df 100644 --- a/app/app.go +++ b/app/app.go @@ -489,7 +489,7 @@ func New( []epochstypes.EpochHook{ app.RewardsKeeper.GetDistributeAllStakingRewardsHook(), app.RewardsKeeper.GetUnlockPendingUnlockParticipantsHook(), - app.RewardsKeeper.GetRemoveExpiredTradingRewardsHook(), + app.RewardsKeeper.GetRemoveExpiredPendingTradingRewardsHook(), app.RewardsKeeper.GetTradingRewardsDistributionHook(), }, ) diff --git a/testutil/simapp/app.go b/testutil/simapp/app.go index 1a324da1..ba2ae85d 100644 --- a/testutil/simapp/app.go +++ b/testutil/simapp/app.go @@ -203,7 +203,7 @@ var ( tokenfactorytypes.ModuleName: {authtypes.Minter, authtypes.Burner}, tradebintypes.ModuleName: nil, epochstypes.ModuleName: nil, - rewardstypes.ModuleName: nil, + rewardstypes.ModuleName: {authtypes.Burner}, // this line is used by starport scaffolding # stargate/app/maccPerms } diff --git a/x/rewards/keeper/cleanup.go b/x/rewards/keeper/cleanup.go index 36348bcb..1bedb2cf 100644 --- a/x/rewards/keeper/cleanup.go +++ b/x/rewards/keeper/cleanup.go @@ -5,7 +5,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" ) -func (k Keeper) removeExpiredTradingRewards(ctx sdk.Context, epochNumber int64) { +func (k Keeper) removeExpiredPendingTradingRewards(ctx sdk.Context, epochNumber int64) { logger := k.Logger(ctx).With("epoch_number", epochNumber) toRemove := k.GetAllPendingTradingRewardExpirationByExpireAt(ctx, uint32(epochNumber)) for _, exp := range toRemove { diff --git a/x/rewards/keeper/hooks.go b/x/rewards/keeper/hooks.go index 38f4b2fb..c305d9a8 100644 --- a/x/rewards/keeper/hooks.go +++ b/x/rewards/keeper/hooks.go @@ -40,7 +40,7 @@ func (k Keeper) GetUnlockPendingUnlockParticipantsHook() types.EpochHook { }) } -func (k Keeper) GetRemoveExpiredTradingRewardsHook() types.EpochHook { +func (k Keeper) GetRemoveExpiredPendingTradingRewardsHook() types.EpochHook { hookName := "remove_expired_trading_rewards" return types.NewAfterEpochHook(hookName, func(ctx sdk.Context, epochIdentifier string, epochNumber int64) error { if epochIdentifier != expirationEpoch { @@ -51,7 +51,7 @@ func (k Keeper) GetRemoveExpiredTradingRewardsHook() types.EpochHook { With("epoch", epochIdentifier, "epoch_number", epochNumber, "hook_name", hookName). Debug("preparing to execute hook") - k.removeExpiredTradingRewards(ctx, epochNumber) + k.removeExpiredPendingTradingRewards(ctx, epochNumber) return nil }) diff --git a/x/rewards/keeper/hooks_test.go b/x/rewards/keeper/hooks_test.go new file mode 100644 index 00000000..f120771b --- /dev/null +++ b/x/rewards/keeper/hooks_test.go @@ -0,0 +1,152 @@ +package keeper_test + +import ( + "github.com/bze-alphateam/bze/testutil/simapp" + "github.com/bze-alphateam/bze/x/rewards/types" + sdk "github.com/cosmos/cosmos-sdk/types" +) + +func (suite *IntegrationTestSuite) TestGetDistributeAllStakingRewardsHook_NoEpoch() { + hook := suite.k.GetDistributeAllStakingRewardsHook() + sr := types.StakingReward{ + RewardId: "01", + PrizeAmount: "100", + PrizeDenom: denomBze, + StakingDenom: denomStake, + Duration: 10, + Payouts: 0, + MinStake: 0, + Lock: 10, + StakedAmount: "10", + DistributedStake: "0", + } + suite.k.SetStakingReward(suite.ctx, sr) + + err := hook.AfterEpochEnd(suite.ctx, "not_an_epoch", 321) + suite.Require().NoError(err) + + storageSr, f := suite.k.GetStakingReward(suite.ctx, sr.RewardId) + suite.Require().True(f) + suite.Require().EqualValues(storageSr, sr) +} + +func (suite *IntegrationTestSuite) TestGetDistributeAllStakingRewardsHook_Success() { + hook := suite.k.GetDistributeAllStakingRewardsHook() + sr := types.StakingReward{ + RewardId: "01", + PrizeAmount: "100", + PrizeDenom: denomBze, + StakingDenom: denomStake, + Duration: 10, + Payouts: 0, + MinStake: 0, + Lock: 10, + StakedAmount: "10", + DistributedStake: "0", + } + suite.k.SetStakingReward(suite.ctx, sr) + + err := hook.AfterEpochEnd(suite.ctx, "day", 101) + suite.Require().NoError(err) + + storageSr, f := suite.k.GetStakingReward(suite.ctx, sr.RewardId) + suite.Require().True(f) + suite.Require().NotEqualValues(storageSr, sr) +} + +func (suite *IntegrationTestSuite) TestGetUnlockPendingUnlockParticipantsHook_NoEpoch() { + hook := suite.k.GetUnlockPendingUnlockParticipantsHook() + + pup := types.PendingUnlockParticipant{Index: types.CreatePendingUnlockParticipantKey(int64(321), "something")} + suite.k.SetPendingUnlockParticipant(suite.ctx, pup) + + err := hook.AfterEpochEnd(suite.ctx, "not_an_epoch", 321) + suite.Require().NoError(err) + + storageList := suite.k.GetAllPendingUnlockParticipant(suite.ctx) + suite.Require().NotEmpty(storageList) + suite.Require().EqualValues(pup, storageList[0]) +} + +func (suite *IntegrationTestSuite) TestGetUnlockPendingUnlockParticipantsHook_Success() { + hook := suite.k.GetUnlockPendingUnlockParticipantsHook() + + balances := sdk.NewCoins(newStakeCoin(10000), newBzeCoin(50000)) + suite.Require().NoError(simapp.FundModuleAccount(suite.app.BankKeeper, suite.ctx, types.ModuleName, balances)) + addr1 := sdk.AccAddress("addr1_______________") + pup := types.PendingUnlockParticipant{ + Index: types.CreatePendingUnlockParticipantKey(int64(321), "something"), + Address: addr1.String(), + Amount: "1", + Denom: denomBze, + } + suite.k.SetPendingUnlockParticipant(suite.ctx, pup) + + err := hook.AfterEpochEnd(suite.ctx, "hour", 321) + suite.Require().NoError(err) + + storageList := suite.k.GetAllPendingUnlockParticipant(suite.ctx) + suite.Require().Empty(storageList) +} + +func (suite *IntegrationTestSuite) TestGetRemoveExpiredPendingTradingRewardsHook_NoEpoch() { + hook := suite.k.GetRemoveExpiredPendingTradingRewardsHook() + + ptre := types.TradingRewardExpiration{RewardId: "01", ExpireAt: uint32(1)} + suite.k.SetPendingTradingRewardExpiration(suite.ctx, ptre) + + err := hook.AfterEpochEnd(suite.ctx, "not_an_epoch", 1) + suite.Require().NoError(err) + + storageList := suite.k.GetAllPendingTradingRewardExpiration(suite.ctx) + suite.Require().NotEmpty(storageList) +} + +func (suite *IntegrationTestSuite) TestGetRemoveExpiredPendingTradingRewardsHook_Success() { + hook := suite.k.GetRemoveExpiredPendingTradingRewardsHook() + + balances := sdk.NewCoins(newBzeCoin(1000)) + suite.Require().NoError(simapp.FundModuleAccount(suite.app.BankKeeper, suite.ctx, types.ModuleName, balances)) + tr := types.TradingReward{ + RewardId: "01", + PrizeDenom: denomBze, + PrizeAmount: "100", + Slots: 1, + } + suite.k.SetPendingTradingReward(suite.ctx, tr) + ptre := types.TradingRewardExpiration{RewardId: tr.RewardId, ExpireAt: uint32(1)} + suite.k.SetPendingTradingRewardExpiration(suite.ctx, ptre) + + err := hook.AfterEpochEnd(suite.ctx, "hour", 1) + suite.Require().NoError(err) + + _, f := suite.k.GetPendingTradingReward(suite.ctx, tr.RewardId) + suite.Require().False(f) + + expList := suite.k.GetAllPendingTradingRewardExpiration(suite.ctx) + suite.Require().Empty(expList) + + //check burned balances were subtracted from module + moduleAddr := suite.app.AccountKeeper.GetModuleAddress(types.ModuleName) + newBalances := suite.app.BankKeeper.GetAllBalances(suite.ctx, moduleAddr) + suite.Require().EqualValues(newBalances.AmountOf(denomBze).String(), "900") +} + +func (suite *IntegrationTestSuite) TestGetTradingRewardsDistributionHook_NoEpoch() { + hook := suite.k.GetTradingRewardsDistributionHook() + + balances := sdk.NewCoins(newBzeCoin(1000)) + suite.Require().NoError(simapp.FundModuleAccount(suite.app.BankKeeper, suite.ctx, types.ModuleName, balances)) + tr := types.TradingReward{ + RewardId: "01", + PrizeDenom: denomBze, + PrizeAmount: "100", + Slots: 1, + } + suite.k.SetActiveTradingReward(suite.ctx, tr) + ptre := types.TradingRewardExpiration{RewardId: tr.RewardId, ExpireAt: uint32(1)} + suite.k.SetActiveTradingRewardExpiration(suite.ctx, ptre) + + err := hook.AfterEpochEnd(suite.ctx, "not_an_epoch", 1) + suite.Require().NoError(err) +}